@dxos/react-ui-form 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +400 -357
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +400 -357
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Form/Form.d.ts +5 -5
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts +1 -1
- 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 +1 -1
- 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/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.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/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/util/echo.d.ts +6 -0
- package/dist/types/src/util/echo.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -34
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
- package/src/components/Form/Form-old.stories.tsx +1 -1
- package/src/components/Form/Form.stories.tsx +5 -2
- package/src/components/Form/Form.tsx +31 -21
- package/src/components/Form/FormFieldComponent.stories.tsx +1 -1
- package/src/components/Form/FormFieldComponent.tsx +15 -15
- package/src/components/Form/FormFieldSet.tsx +4 -2
- package/src/components/Form/fields/ArrayField.tsx +3 -0
- package/src/components/Form/fields/RefField.tsx +11 -3
- package/src/components/Form/fields/SelectOptionField.stories.tsx +1 -1
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +1 -1
- package/src/components/Settings/Settings.stories.tsx +56 -0
- package/src/components/Settings/Settings.tsx +234 -0
- package/src/components/{ControlSection → Settings}/index.ts +1 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +3 -3
- package/src/components/ViewEditor/ViewEditor.test.tsx +1 -5
- package/src/components/ViewEditor/ViewEditor.tsx +39 -44
- package/src/components/index.ts +1 -1
- package/src/hooks/useFormHandler.ts +7 -1
- package/src/util/echo.ts +25 -0
- package/src/util/index.ts +1 -0
- 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/src/components/ControlSection/ControlSection.stories.tsx +0 -38
- package/src/components/ControlSection/ControlSection.tsx +0 -153
|
@@ -75,104 +75,27 @@ 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 } from "@dxos/echo";
|
|
79
|
+
import React17, { useCallback as useCallback14, useEffect as useEffect7, useMemo as useMemo7, useState as useState5 } from "react";
|
|
80
|
+
import { Obj as Obj3 } 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
|
|
|
86
|
+
// src/util/echo.ts
|
|
87
|
+
import { Obj } from "@dxos/echo";
|
|
88
|
+
import { setValue as setValuePlain, splitJsonPath } from "@dxos/effect";
|
|
89
|
+
var setValueEchoAware = (obj, path, value3) => {
|
|
90
|
+
if (Obj.isObject(obj)) {
|
|
91
|
+
Obj.change(obj, (mutableObj) => {
|
|
92
|
+
Obj.setValue(mutableObj, splitJsonPath(path), value3);
|
|
93
|
+
});
|
|
94
|
+
return obj;
|
|
95
|
+
}
|
|
96
|
+
return setValuePlain(obj, path, value3);
|
|
97
|
+
};
|
|
98
|
+
|
|
176
99
|
// src/util/field.ts
|
|
177
100
|
import { Format, GeoLocation, TypeEnum } from "@dxos/echo/internal";
|
|
178
101
|
var parseValue = ({ type, format, value: value3 }) => {
|
|
@@ -467,21 +390,22 @@ var getRefProps = (ast) => {
|
|
|
467
390
|
// src/components/Form/fields/ArrayField.tsx
|
|
468
391
|
import * as Option3 from "effect/Option";
|
|
469
392
|
import * as SchemaAST2 from "effect/SchemaAST";
|
|
470
|
-
import
|
|
393
|
+
import React5, { useCallback as useCallback3 } from "react";
|
|
471
394
|
import { findNode as findNode2, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
|
|
472
|
-
import { IconButton as IconButton2, useTranslation as
|
|
395
|
+
import { IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
473
396
|
|
|
474
397
|
// src/components/Form/Form.tsx
|
|
475
398
|
import { createContext } from "@radix-ui/react-context";
|
|
476
399
|
import * as Schema2 from "effect/Schema";
|
|
477
|
-
import
|
|
478
|
-
import { createJsonPath as createJsonPath3, getValue as getValue$2
|
|
479
|
-
import { IconButton, ScrollArea, useTranslation as
|
|
480
|
-
import { mx as
|
|
400
|
+
import React4, { useEffect as useEffect3, useMemo as useMemo4, useRef } from "react";
|
|
401
|
+
import { createJsonPath as createJsonPath3, getValue as getValue$2 } from "@dxos/effect";
|
|
402
|
+
import { IconButton, ScrollArea, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
403
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
481
404
|
|
|
482
405
|
// src/hooks/useFormHandler.ts
|
|
483
406
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
484
407
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
408
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
485
409
|
import { createJsonPath, fromEffectValidationPath, getValue as getValue$, setValue as setValue$ } from "@dxos/effect";
|
|
486
410
|
import { log } from "@dxos/log";
|
|
487
411
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
@@ -515,7 +439,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
515
439
|
errors: errors2
|
|
516
440
|
}, {
|
|
517
441
|
F: __dxlog_file,
|
|
518
|
-
L:
|
|
442
|
+
L: 160,
|
|
519
443
|
S: void 0,
|
|
520
444
|
C: (f, a) => f(...a)
|
|
521
445
|
});
|
|
@@ -608,7 +532,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
608
532
|
value: value3
|
|
609
533
|
}, {
|
|
610
534
|
F: __dxlog_file,
|
|
611
|
-
L:
|
|
535
|
+
L: 259,
|
|
612
536
|
S: void 0,
|
|
613
537
|
C: (f, a) => f(...a)
|
|
614
538
|
});
|
|
@@ -621,13 +545,13 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
621
545
|
} catch (err) {
|
|
622
546
|
log.catch(err, void 0, {
|
|
623
547
|
F: __dxlog_file,
|
|
624
|
-
L:
|
|
548
|
+
L: 268,
|
|
625
549
|
S: void 0,
|
|
626
550
|
C: (f, a) => f(...a)
|
|
627
551
|
});
|
|
628
552
|
parsedValue = void 0;
|
|
629
553
|
}
|
|
630
|
-
const newValues = {
|
|
554
|
+
const newValues = Obj2.isObject(values) ? (setValueEchoAware(values, jsonPath, parsedValue), values) : {
|
|
631
555
|
...setValue$(values, jsonPath, parsedValue)
|
|
632
556
|
};
|
|
633
557
|
setValues(newValues);
|
|
@@ -745,25 +669,16 @@ var useKeyHandler = (formElement, form) => {
|
|
|
745
669
|
};
|
|
746
670
|
|
|
747
671
|
// src/components/Form/FormFieldComponent.tsx
|
|
748
|
-
import
|
|
749
|
-
import { Icon, Input
|
|
750
|
-
import { errorText
|
|
751
|
-
var labelSpacing = "mbs-inputSpacingBlock mbe-labelSpacingBlock";
|
|
672
|
+
import React, { Component } from "react";
|
|
673
|
+
import { Icon, Input, Tooltip } from "@dxos/react-ui";
|
|
674
|
+
import { errorText } from "@dxos/ui-theme";
|
|
752
675
|
var FormFieldLabel = ({ label, error, readonly, asChild }) => {
|
|
753
|
-
const Label = readonly || asChild ? "span" :
|
|
754
|
-
|
|
755
|
-
className: "text-description text-sm"
|
|
756
|
-
} : {
|
|
757
|
-
classNames: "!mlb-0 text-sm"
|
|
758
|
-
};
|
|
759
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
760
|
-
role: "none",
|
|
761
|
-
className: mx2("flex justify-between items-center", labelSpacing)
|
|
762
|
-
}, /* @__PURE__ */ React2.createElement(Label, labelProps, label), error && /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
|
|
676
|
+
const Label = readonly || asChild ? "span" : Input.Label;
|
|
677
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Label, null, label), error && /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
|
|
763
678
|
asChild: true,
|
|
764
679
|
content: error,
|
|
765
680
|
side: "bottom"
|
|
766
|
-
}, /* @__PURE__ */
|
|
681
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
767
682
|
icon: "ph--warning--regular",
|
|
768
683
|
size: 4,
|
|
769
684
|
classNames: errorText
|
|
@@ -778,15 +693,18 @@ var FormFieldWrapper = (props) => {
|
|
|
778
693
|
return null;
|
|
779
694
|
}
|
|
780
695
|
const str = String(value3 ?? "");
|
|
781
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
697
|
+
role: "none",
|
|
698
|
+
className: "contents"
|
|
699
|
+
}, /* @__PURE__ */ React.createElement(Input.Root, {
|
|
782
700
|
validationValence: status
|
|
783
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
701
|
+
}, layout !== "inline" && /* @__PURE__ */ React.createElement(FormFieldLabel, {
|
|
784
702
|
error,
|
|
785
703
|
readonly,
|
|
786
704
|
label
|
|
787
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
705
|
+
}), layout === "static" ? /* @__PURE__ */ React.createElement("p", null, str) : children ? children({
|
|
788
706
|
value: value3
|
|
789
|
-
}) : null, layout === "full" && /* @__PURE__ */
|
|
707
|
+
}) : null, layout === "full" && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Validation, null, error))));
|
|
790
708
|
};
|
|
791
709
|
var FormFieldErrorBoundary = class extends Component {
|
|
792
710
|
static getDerivedStateFromError(error) {
|
|
@@ -804,9 +722,9 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
804
722
|
}
|
|
805
723
|
render() {
|
|
806
724
|
if (this.state.error) {
|
|
807
|
-
return /* @__PURE__ */
|
|
725
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
808
726
|
className: "flex gap-2 border border-roseFill font-mono text-sm"
|
|
809
|
-
}, /* @__PURE__ */
|
|
727
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
810
728
|
className: "bg-roseFill text-surfaceText pli-1 font-thin"
|
|
811
729
|
}, "ERROR"), String(this.props.path?.join(".")));
|
|
812
730
|
}
|
|
@@ -820,8 +738,8 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
820
738
|
};
|
|
821
739
|
|
|
822
740
|
// src/components/Form/FormFieldSet.tsx
|
|
823
|
-
import
|
|
824
|
-
import { mx
|
|
741
|
+
import React3, { forwardRef, useMemo as useMemo3 } from "react";
|
|
742
|
+
import { mx } from "@dxos/ui-theme";
|
|
825
743
|
import { isTruthy } from "@dxos/util";
|
|
826
744
|
|
|
827
745
|
// src/components/Form/FormField.tsx
|
|
@@ -830,10 +748,10 @@ import * as Option2 from "effect/Option";
|
|
|
830
748
|
import * as Schema from "effect/Schema";
|
|
831
749
|
import * as SchemaAST from "effect/SchemaAST";
|
|
832
750
|
import * as String2 from "effect/String";
|
|
833
|
-
import
|
|
751
|
+
import React2, { useMemo as useMemo2 } from "react";
|
|
834
752
|
import { Format as Format3 } from "@dxos/echo";
|
|
835
753
|
import { createJsonPath as createJsonPath2, findNode, getAnnotation, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion, isNestedType } from "@dxos/effect";
|
|
836
|
-
import { useTranslation
|
|
754
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
837
755
|
var FormField = (props) => {
|
|
838
756
|
const {
|
|
839
757
|
type,
|
|
@@ -853,7 +771,7 @@ var FormField = (props) => {
|
|
|
853
771
|
getOptions: getRefOptions,
|
|
854
772
|
onCreate
|
|
855
773
|
} = props;
|
|
856
|
-
const { t } =
|
|
774
|
+
const { t } = useTranslation(translationKey);
|
|
857
775
|
const title = getAnnotation(SchemaAST.TitleAnnotationId)(type);
|
|
858
776
|
const description = getAnnotation(SchemaAST.DescriptionAnnotationId)(type);
|
|
859
777
|
const examples = getAnnotation(SchemaAST.ExamplesAnnotationId)(type);
|
|
@@ -879,7 +797,7 @@ var FormField = (props) => {
|
|
|
879
797
|
const jsonPath = createJsonPath2(path ?? []);
|
|
880
798
|
const CustomField = fieldMap?.[jsonPath];
|
|
881
799
|
if (CustomField) {
|
|
882
|
-
return /* @__PURE__ */
|
|
800
|
+
return /* @__PURE__ */ React2.createElement(CustomField, fieldProps);
|
|
883
801
|
}
|
|
884
802
|
const component = fieldProvider?.({
|
|
885
803
|
schema: Schema.make(type),
|
|
@@ -890,7 +808,7 @@ var FormField = (props) => {
|
|
|
890
808
|
return component;
|
|
891
809
|
}
|
|
892
810
|
if (isArrayType2(type)) {
|
|
893
|
-
return /* @__PURE__ */
|
|
811
|
+
return /* @__PURE__ */ React2.createElement(ArrayField, {
|
|
894
812
|
fieldProps: fieldState,
|
|
895
813
|
label,
|
|
896
814
|
...props
|
|
@@ -898,11 +816,11 @@ var FormField = (props) => {
|
|
|
898
816
|
}
|
|
899
817
|
const Field = getFormField(fieldProps);
|
|
900
818
|
if (Field) {
|
|
901
|
-
return /* @__PURE__ */
|
|
819
|
+
return /* @__PURE__ */ React2.createElement(Field, fieldProps);
|
|
902
820
|
}
|
|
903
821
|
const options = getOptions(type);
|
|
904
822
|
if (options) {
|
|
905
|
-
return /* @__PURE__ */
|
|
823
|
+
return /* @__PURE__ */ React2.createElement(SelectField, {
|
|
906
824
|
...fieldProps,
|
|
907
825
|
options: options.map((option) => ({
|
|
908
826
|
value: option,
|
|
@@ -912,7 +830,7 @@ var FormField = (props) => {
|
|
|
912
830
|
}
|
|
913
831
|
const refProps = getRefProps(type);
|
|
914
832
|
if (refProps) {
|
|
915
|
-
return /* @__PURE__ */
|
|
833
|
+
return /* @__PURE__ */ React2.createElement(RefField, {
|
|
916
834
|
...fieldProps,
|
|
917
835
|
...refProps,
|
|
918
836
|
createOptionLabel,
|
|
@@ -929,7 +847,7 @@ var FormField = (props) => {
|
|
|
929
847
|
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST.isTypeLiteral);
|
|
930
848
|
if (typeLiteral) {
|
|
931
849
|
const schema = Schema.make(typeLiteral);
|
|
932
|
-
return /* @__PURE__ */
|
|
850
|
+
return /* @__PURE__ */ React2.createElement(FormFieldSet, {
|
|
933
851
|
schema,
|
|
934
852
|
path,
|
|
935
853
|
readonly,
|
|
@@ -975,8 +893,9 @@ var getOptions = (ast) => {
|
|
|
975
893
|
};
|
|
976
894
|
|
|
977
895
|
// src/components/Form/FormFieldSet.tsx
|
|
896
|
+
var FORM_FIELDSET_NAME = "Form.FieldSet";
|
|
978
897
|
var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, readonly, path, exclude, sort, projection, layout, ...props }, forwardRef4) => {
|
|
979
|
-
const values = useFormValues(
|
|
898
|
+
const values = useFormValues(FORM_FIELDSET_NAME, path);
|
|
980
899
|
const properties = useMemo3(() => {
|
|
981
900
|
if (!schema) {
|
|
982
901
|
return [];
|
|
@@ -1011,22 +930,22 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
|
|
|
1011
930
|
if ((readonly || layout === "static") && values == null) {
|
|
1012
931
|
return null;
|
|
1013
932
|
}
|
|
1014
|
-
return /* @__PURE__ */
|
|
933
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
1015
934
|
role: "form",
|
|
1016
|
-
className:
|
|
935
|
+
className: mx("is-full", layout === "inline" && "flex flex-col gap-2", classNames),
|
|
1017
936
|
ref: forwardRef4
|
|
1018
|
-
}, layout !== "inline" && label && /* @__PURE__ */
|
|
937
|
+
}, layout !== "inline" && label && /* @__PURE__ */ React3.createElement(FormFieldLabel, {
|
|
1019
938
|
label,
|
|
1020
939
|
asChild: true
|
|
1021
940
|
}), properties.map((property) => {
|
|
1022
941
|
const name = property.name.toString();
|
|
1023
|
-
return /* @__PURE__ */
|
|
942
|
+
return /* @__PURE__ */ React3.createElement(FormFieldErrorBoundary, {
|
|
1024
943
|
key: name,
|
|
1025
944
|
path: [
|
|
1026
945
|
...path ?? [],
|
|
1027
946
|
name
|
|
1028
947
|
]
|
|
1029
|
-
}, /* @__PURE__ */
|
|
948
|
+
}, /* @__PURE__ */ React3.createElement(FormField, {
|
|
1030
949
|
type: property.type,
|
|
1031
950
|
name,
|
|
1032
951
|
path: [
|
|
@@ -1040,7 +959,7 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
|
|
|
1040
959
|
}));
|
|
1041
960
|
}).filter(isTruthy));
|
|
1042
961
|
});
|
|
1043
|
-
FormFieldSet.displayName =
|
|
962
|
+
FormFieldSet.displayName = FORM_FIELDSET_NAME;
|
|
1044
963
|
|
|
1045
964
|
// src/components/Form/Form.tsx
|
|
1046
965
|
var omitId = (schema) => schema.pipe(Schema2.omit("id"));
|
|
@@ -1051,7 +970,7 @@ var useFormValues = (componentName, path = [], defaultValue) => {
|
|
|
1051
970
|
const value3 = getValue$2(values, jsonPath);
|
|
1052
971
|
useEffect3(() => {
|
|
1053
972
|
if (!value3 && defaultValue) {
|
|
1054
|
-
|
|
973
|
+
setValueEchoAware(values, jsonPath, defaultValue());
|
|
1055
974
|
}
|
|
1056
975
|
}, [
|
|
1057
976
|
value3,
|
|
@@ -1085,60 +1004,59 @@ var FormRoot = ({ children, schema, values, onSave, onCancel, ...props }) => {
|
|
|
1085
1004
|
onCancel,
|
|
1086
1005
|
...props
|
|
1087
1006
|
});
|
|
1088
|
-
return /* @__PURE__ */
|
|
1007
|
+
return /* @__PURE__ */ React4.createElement(FormContextProvider, {
|
|
1089
1008
|
form,
|
|
1090
1009
|
...props
|
|
1091
1010
|
}, children);
|
|
1092
1011
|
};
|
|
1093
1012
|
FormRoot.displayName = "Form.Root";
|
|
1094
|
-
var
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
"plb-cardSpacingBlock",
|
|
1098
|
-
classNames
|
|
1099
|
-
]
|
|
1100
|
-
}, children), /* @__PURE__ */ React5.createElement(ScrollArea.Scrollbar, {
|
|
1013
|
+
var FORM_VIEWPORT_NAME = "Form.Viewport";
|
|
1014
|
+
var FormViewport = ({ children }) => {
|
|
1015
|
+
return /* @__PURE__ */ React4.createElement(ScrollArea.Root, {
|
|
1101
1016
|
orientation: "vertical"
|
|
1102
|
-
}, /* @__PURE__ */
|
|
1017
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, children));
|
|
1103
1018
|
};
|
|
1104
|
-
FormViewport.displayName =
|
|
1019
|
+
FormViewport.displayName = FORM_VIEWPORT_NAME;
|
|
1020
|
+
var FORM_CONTENT_NAME = "Form.Content";
|
|
1105
1021
|
var FormContent = ({ classNames, children }) => {
|
|
1106
|
-
const { form, testId } = useFormContext(
|
|
1022
|
+
const { form, testId } = useFormContext(FORM_CONTENT_NAME);
|
|
1107
1023
|
const ref = useRef(null);
|
|
1108
1024
|
useKeyHandler(ref.current, form);
|
|
1109
|
-
return /* @__PURE__ */
|
|
1025
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1110
1026
|
ref,
|
|
1111
1027
|
role: "form",
|
|
1112
|
-
className:
|
|
1028
|
+
className: mx2("flex flex-col is-full pli-cardSpacingInline density-fine", classNames),
|
|
1113
1029
|
"data-testid": testId
|
|
1114
1030
|
}, children);
|
|
1115
1031
|
};
|
|
1116
|
-
FormContent.displayName =
|
|
1032
|
+
FormContent.displayName = FORM_CONTENT_NAME;
|
|
1033
|
+
var FORM_FIELDSET_NAME2 = "Form.FieldSet";
|
|
1117
1034
|
var FormFieldSet2 = ({ classNames }) => {
|
|
1118
|
-
const { form, ...props } = useFormContext(
|
|
1119
|
-
return /* @__PURE__ */
|
|
1035
|
+
const { form, ...props } = useFormContext(FORM_FIELDSET_NAME2);
|
|
1036
|
+
return /* @__PURE__ */ React4.createElement(FormFieldSet, {
|
|
1120
1037
|
classNames,
|
|
1121
1038
|
schema: form.schema,
|
|
1122
1039
|
...props
|
|
1123
1040
|
});
|
|
1124
1041
|
};
|
|
1125
|
-
FormFieldSet2.displayName =
|
|
1042
|
+
FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
|
|
1043
|
+
var FORM_ACTIONS_NAME = "Form.Actions";
|
|
1126
1044
|
var FormActions = ({ classNames }) => {
|
|
1127
|
-
const { t } =
|
|
1128
|
-
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(
|
|
1045
|
+
const { t } = useTranslation2(translationKey);
|
|
1046
|
+
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
|
|
1129
1047
|
if (readonly || layout === "static") {
|
|
1130
1048
|
return null;
|
|
1131
1049
|
}
|
|
1132
|
-
return /* @__PURE__ */
|
|
1050
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1133
1051
|
role: "none",
|
|
1134
|
-
className:
|
|
1135
|
-
}, onCancel && /* @__PURE__ */
|
|
1052
|
+
className: mx2("grid grid-flow-col auto-cols-fr gap-2 pbs-cardSpacingBlock", classNames)
|
|
1053
|
+
}, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1136
1054
|
icon: "ph--x--regular",
|
|
1137
1055
|
iconEnd: true,
|
|
1138
1056
|
label: t("cancel button label"),
|
|
1139
1057
|
onClick: onCancel,
|
|
1140
1058
|
"data-testid": "cancel-button"
|
|
1141
|
-
}), onSave && /* @__PURE__ */
|
|
1059
|
+
}), onSave && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1142
1060
|
type: "submit",
|
|
1143
1061
|
variant: "primary",
|
|
1144
1062
|
disabled: !canSave,
|
|
@@ -1149,28 +1067,29 @@ var FormActions = ({ classNames }) => {
|
|
|
1149
1067
|
"data-testid": "save-button"
|
|
1150
1068
|
}));
|
|
1151
1069
|
};
|
|
1152
|
-
FormActions.displayName =
|
|
1153
|
-
var
|
|
1154
|
-
|
|
1155
|
-
const {
|
|
1070
|
+
FormActions.displayName = FORM_ACTIONS_NAME;
|
|
1071
|
+
var FORM_SUBMIT_NAME = "Form.Submit";
|
|
1072
|
+
var FormSubmit = ({ classNames, label, icon, disabled }) => {
|
|
1073
|
+
const { t } = useTranslation2(translationKey);
|
|
1074
|
+
const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
|
|
1156
1075
|
if (readonly || layout === "static") {
|
|
1157
1076
|
return null;
|
|
1158
1077
|
}
|
|
1159
|
-
return /* @__PURE__ */
|
|
1078
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1160
1079
|
role: "none",
|
|
1161
|
-
className:
|
|
1162
|
-
}, /* @__PURE__ */
|
|
1080
|
+
className: mx2("flex is-full pbs-cardSpacingBlock", classNames)
|
|
1081
|
+
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1163
1082
|
classNames: "is-full",
|
|
1164
1083
|
type: "submit",
|
|
1165
1084
|
variant: "primary",
|
|
1166
|
-
disabled: !canSave,
|
|
1085
|
+
disabled: disabled ?? !canSave,
|
|
1167
1086
|
icon: icon ?? "ph--check--regular",
|
|
1168
1087
|
label: label ?? t("save button label"),
|
|
1169
1088
|
onClick: onSave,
|
|
1170
1089
|
"data-testid": "save-button"
|
|
1171
1090
|
}));
|
|
1172
1091
|
};
|
|
1173
|
-
FormSubmit.displayName =
|
|
1092
|
+
FormSubmit.displayName = FORM_SUBMIT_NAME;
|
|
1174
1093
|
var Form = {
|
|
1175
1094
|
Root: FormRoot,
|
|
1176
1095
|
Viewport: FormViewport,
|
|
@@ -1183,7 +1102,7 @@ var Form = {
|
|
|
1183
1102
|
|
|
1184
1103
|
// src/components/Form/fields/ArrayField.tsx
|
|
1185
1104
|
var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
|
|
1186
|
-
const { t } =
|
|
1105
|
+
const { t } = useTranslation3(translationKey);
|
|
1187
1106
|
const elementType = getArrayElementType2(type);
|
|
1188
1107
|
const { onValueChange } = inputProps;
|
|
1189
1108
|
const values = useFormValues(ArrayField.displayName, path, () => []);
|
|
@@ -1223,19 +1142,19 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1223
1142
|
if (!elementType || (readonly || layout === "static") && values && values.length < 1) {
|
|
1224
1143
|
return null;
|
|
1225
1144
|
}
|
|
1226
|
-
return /* @__PURE__ */
|
|
1145
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React5.createElement(FormFieldLabel, {
|
|
1227
1146
|
readonly,
|
|
1228
1147
|
label,
|
|
1229
1148
|
asChild: true
|
|
1230
|
-
}), /* @__PURE__ */
|
|
1149
|
+
}), /* @__PURE__ */ React5.createElement("div", {
|
|
1231
1150
|
role: "none",
|
|
1232
1151
|
className: "flex flex-col gap-2"
|
|
1233
1152
|
}, values?.map((_, index) => {
|
|
1234
|
-
return /* @__PURE__ */
|
|
1153
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1235
1154
|
role: "none",
|
|
1236
1155
|
key: index,
|
|
1237
1156
|
className: "grid grid-cols-[1fr_min-content] gap-2 last:mb-3"
|
|
1238
|
-
}, /* @__PURE__ */
|
|
1157
|
+
}, /* @__PURE__ */ React5.createElement(FormField, {
|
|
1239
1158
|
autoFocus: index === values.length - 1,
|
|
1240
1159
|
type: elementType,
|
|
1241
1160
|
path: [
|
|
@@ -1245,20 +1164,20 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1245
1164
|
readonly: readonly || layout === "static",
|
|
1246
1165
|
layout: "inline",
|
|
1247
1166
|
...props
|
|
1248
|
-
}), !readonly && layout !== "static" && /* @__PURE__ */
|
|
1167
|
+
}), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement("div", {
|
|
1249
1168
|
role: "none",
|
|
1250
1169
|
className: "flex flex-col bs-full justify-end"
|
|
1251
|
-
}, /* @__PURE__ */
|
|
1170
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1252
1171
|
role: "none",
|
|
1253
1172
|
className: "flex items-center bs-[var(--line-height)]"
|
|
1254
|
-
}, /* @__PURE__ */
|
|
1173
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1255
1174
|
icon: "ph--x--regular",
|
|
1256
1175
|
iconOnly: true,
|
|
1257
1176
|
label: t("button remove"),
|
|
1258
1177
|
onClick: () => handleDelete(index),
|
|
1259
1178
|
classNames: "self-center"
|
|
1260
1179
|
}))));
|
|
1261
|
-
})), !readonly && layout !== "static" && /* @__PURE__ */
|
|
1180
|
+
})), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1262
1181
|
classNames: "flex is-full _mlb-cardSpacingBlock",
|
|
1263
1182
|
icon: "ph--plus--regular",
|
|
1264
1183
|
label: t("add field"),
|
|
@@ -1277,6 +1196,9 @@ var getDefaultValue = (ast) => {
|
|
|
1277
1196
|
case "BooleanKeyword": {
|
|
1278
1197
|
return false;
|
|
1279
1198
|
}
|
|
1199
|
+
case "Suspend": {
|
|
1200
|
+
return getDefaultValue(ast.f());
|
|
1201
|
+
}
|
|
1280
1202
|
default: {
|
|
1281
1203
|
if (ast && isNestedType2(ast)) {
|
|
1282
1204
|
return {};
|
|
@@ -1288,17 +1210,17 @@ var getDefaultValue = (ast) => {
|
|
|
1288
1210
|
};
|
|
1289
1211
|
|
|
1290
1212
|
// src/components/Form/fields/BooleanField.tsx
|
|
1291
|
-
import
|
|
1292
|
-
import { Input as
|
|
1213
|
+
import React6, { useCallback as useCallback4 } from "react";
|
|
1214
|
+
import { Input as Input2 } from "@dxos/react-ui";
|
|
1293
1215
|
var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
1294
1216
|
const handleChange = useCallback4((value3) => onValueChange?.(type, value3), [
|
|
1295
1217
|
type,
|
|
1296
1218
|
onValueChange
|
|
1297
1219
|
]);
|
|
1298
|
-
return /* @__PURE__ */
|
|
1220
|
+
return /* @__PURE__ */ React6.createElement(FormFieldWrapper, {
|
|
1299
1221
|
readonly,
|
|
1300
1222
|
...props
|
|
1301
|
-
}, ({ value: value3 }) => /* @__PURE__ */
|
|
1223
|
+
}, ({ value: value3 }) => /* @__PURE__ */ React6.createElement(Input2.Switch, {
|
|
1302
1224
|
disabled: !!readonly,
|
|
1303
1225
|
checked: value3,
|
|
1304
1226
|
onCheckedChange: handleChange
|
|
@@ -1306,12 +1228,12 @@ var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
|
1306
1228
|
};
|
|
1307
1229
|
|
|
1308
1230
|
// src/components/Form/fields/GeoPointField.tsx
|
|
1309
|
-
import
|
|
1231
|
+
import React7, { useCallback as useCallback5, useEffect as useEffect4, useMemo as useMemo5, useState as useState2 } from "react";
|
|
1310
1232
|
import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
|
|
1311
|
-
import { Input as
|
|
1233
|
+
import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1312
1234
|
import { safeParseFloat } from "@dxos/util";
|
|
1313
1235
|
var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1314
|
-
const { t } =
|
|
1236
|
+
const { t } = useTranslation4(translationKey);
|
|
1315
1237
|
const { status, error } = getStatus();
|
|
1316
1238
|
const geoPoint = useMemo5(() => getValue() ?? [
|
|
1317
1239
|
0,
|
|
@@ -1357,17 +1279,17 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1357
1279
|
if ((readonly || layout === "static") && !value3?.latitude && !value3?.longitude) {
|
|
1358
1280
|
return null;
|
|
1359
1281
|
}
|
|
1360
|
-
return /* @__PURE__ */
|
|
1282
|
+
return /* @__PURE__ */ React7.createElement(Input3.Root, {
|
|
1361
1283
|
validationValence: status
|
|
1362
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1284
|
+
}, layout !== "inline" && /* @__PURE__ */ React7.createElement(FormFieldLabel, {
|
|
1363
1285
|
error,
|
|
1364
1286
|
readonly,
|
|
1365
1287
|
label,
|
|
1366
1288
|
asChild: true
|
|
1367
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1289
|
+
}), layout === "static" ? /* @__PURE__ */ React7.createElement(LatLng, value3) : /* @__PURE__ */ React7.createElement("div", {
|
|
1368
1290
|
role: "none",
|
|
1369
1291
|
className: "grid grid-cols-2 gap-2"
|
|
1370
|
-
}, /* @__PURE__ */
|
|
1292
|
+
}, /* @__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, {
|
|
1371
1293
|
type: "number",
|
|
1372
1294
|
step: "0.00001",
|
|
1373
1295
|
min: "-90",
|
|
@@ -1377,7 +1299,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1377
1299
|
value: latitudeText ?? "",
|
|
1378
1300
|
onChange: handleChange("latitude", setLatitudeText),
|
|
1379
1301
|
onBlur
|
|
1380
|
-
}))), /* @__PURE__ */
|
|
1302
|
+
}))), /* @__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, {
|
|
1381
1303
|
type: "number",
|
|
1382
1304
|
step: "0.00001",
|
|
1383
1305
|
min: "-180",
|
|
@@ -1392,18 +1314,18 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1392
1314
|
var LatLng = ({ latitude = 0, longitude = 0 }) => {
|
|
1393
1315
|
const latHem = latitude >= 0 ? "N" : "S";
|
|
1394
1316
|
const lngHem = longitude >= 0 ? "E" : "W";
|
|
1395
|
-
return /* @__PURE__ */
|
|
1317
|
+
return /* @__PURE__ */ React7.createElement("span", {
|
|
1396
1318
|
className: "inline-flex items-center gap-1"
|
|
1397
|
-
}, /* @__PURE__ */
|
|
1319
|
+
}, /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
|
|
1398
1320
|
className: "text-subdued"
|
|
1399
|
-
}, "\xB0", latHem)), /* @__PURE__ */
|
|
1321
|
+
}, "\xB0", latHem)), /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
|
|
1400
1322
|
className: "text-subdued"
|
|
1401
1323
|
}, "\xB0", lngHem)));
|
|
1402
1324
|
};
|
|
1403
1325
|
|
|
1404
1326
|
// src/components/Form/fields/MarkdownField.tsx
|
|
1405
|
-
import
|
|
1406
|
-
import { Input as
|
|
1327
|
+
import React8, { useCallback as useCallback6, useEffect as useEffect5, useRef as useRef2 } from "react";
|
|
1328
|
+
import { Input as Input4 } from "@dxos/react-ui";
|
|
1407
1329
|
var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1408
1330
|
const { status, error } = getStatus();
|
|
1409
1331
|
const textareaRef = useRef2(null);
|
|
@@ -1433,13 +1355,13 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, ge
|
|
|
1433
1355
|
if ((readonly || layout === "static") && !value3) {
|
|
1434
1356
|
return null;
|
|
1435
1357
|
}
|
|
1436
|
-
return /* @__PURE__ */
|
|
1358
|
+
return /* @__PURE__ */ React8.createElement(Input4.Root, {
|
|
1437
1359
|
validationValence: status
|
|
1438
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1360
|
+
}, layout !== "inline" && /* @__PURE__ */ React8.createElement(FormFieldLabel, {
|
|
1439
1361
|
error,
|
|
1440
1362
|
readonly,
|
|
1441
1363
|
label
|
|
1442
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1364
|
+
}), layout === "static" ? /* @__PURE__ */ React8.createElement("p", null, value3) : /* @__PURE__ */ React8.createElement(Input4.TextArea, {
|
|
1443
1365
|
ref: textareaRef,
|
|
1444
1366
|
disabled: !!readonly,
|
|
1445
1367
|
placeholder,
|
|
@@ -1451,22 +1373,22 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, ge
|
|
|
1451
1373
|
resize: "none"
|
|
1452
1374
|
},
|
|
1453
1375
|
spellCheck: false
|
|
1454
|
-
}), layout === "full" && /* @__PURE__ */
|
|
1376
|
+
}), layout === "full" && /* @__PURE__ */ React8.createElement(Input4.Validation, null, error));
|
|
1455
1377
|
};
|
|
1456
1378
|
|
|
1457
1379
|
// src/components/Form/fields/NumberField.tsx
|
|
1458
|
-
import
|
|
1459
|
-
import { Input as
|
|
1380
|
+
import React9, { useCallback as useCallback7 } from "react";
|
|
1381
|
+
import { Input as Input5 } from "@dxos/react-ui";
|
|
1460
1382
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
1461
1383
|
var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1462
1384
|
const handleChange = useCallback7((event) => onValueChange(type, safeParseFloat2(event.target.value) || 0), [
|
|
1463
1385
|
type,
|
|
1464
1386
|
onValueChange
|
|
1465
1387
|
]);
|
|
1466
|
-
return /* @__PURE__ */
|
|
1388
|
+
return /* @__PURE__ */ React9.createElement(FormFieldWrapper, {
|
|
1467
1389
|
readonly,
|
|
1468
1390
|
...props
|
|
1469
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1391
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React9.createElement(Input5.TextInput, {
|
|
1470
1392
|
type: "number",
|
|
1471
1393
|
disabled: !!readonly,
|
|
1472
1394
|
placeholder,
|
|
@@ -1478,24 +1400,24 @@ var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...prop
|
|
|
1478
1400
|
|
|
1479
1401
|
// src/components/Form/fields/RefField.tsx
|
|
1480
1402
|
import "@dxos/lit-ui/dx-tag-picker.pcss";
|
|
1481
|
-
import
|
|
1482
|
-
import { Entity, Filter, Ref as Ref2 } from "@dxos/echo";
|
|
1403
|
+
import React11, { useCallback as useCallback9, useMemo as useMemo6 } from "react";
|
|
1404
|
+
import { Entity, Filter, Ref as Ref2, Type } from "@dxos/echo";
|
|
1483
1405
|
import { ReferenceAnnotationId } from "@dxos/echo/internal";
|
|
1484
1406
|
import { useQuery, useSchema as useSchema$ } from "@dxos/echo-react";
|
|
1485
1407
|
import { findAnnotation } from "@dxos/effect";
|
|
1486
1408
|
import { DXN } from "@dxos/keys";
|
|
1487
1409
|
import { DxAnchor } from "@dxos/lit-ui/react";
|
|
1488
|
-
import { Button
|
|
1489
|
-
import { descriptionText, mx as
|
|
1410
|
+
import { Button, Icon as Icon2, Input as Input6, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1411
|
+
import { descriptionText, mx as mx3 } from "@dxos/ui-theme";
|
|
1490
1412
|
|
|
1491
1413
|
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
1492
|
-
import
|
|
1493
|
-
import { Popover, useTranslation as
|
|
1414
|
+
import React10, { forwardRef as forwardRef2, useCallback as useCallback8, useState as useState3 } from "react";
|
|
1415
|
+
import { Popover, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1494
1416
|
import { Combobox, useSearchListInput, useSearchListResults } from "@dxos/react-ui-searchlist";
|
|
1495
1417
|
var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
1496
|
-
const { t } =
|
|
1418
|
+
const { t } = useTranslation5(translationKey);
|
|
1497
1419
|
const { query } = useSearchListInput();
|
|
1498
|
-
return /* @__PURE__ */
|
|
1420
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1499
1421
|
value: "__create__",
|
|
1500
1422
|
label: t(createOptionLabel[0], {
|
|
1501
1423
|
ns: createOptionLabel[1].ns,
|
|
@@ -1510,7 +1432,7 @@ var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) =
|
|
|
1510
1432
|
});
|
|
1511
1433
|
};
|
|
1512
1434
|
var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, onSelect, onCreate, ...props }, ref) => {
|
|
1513
|
-
const { t } =
|
|
1435
|
+
const { t } = useTranslation5(translationKey);
|
|
1514
1436
|
const [showForm, setShowForm] = useState3(false);
|
|
1515
1437
|
const [formInitialValue, setFormInitialValue] = useState3("");
|
|
1516
1438
|
const { results, handleSearch } = useSearchListResults({
|
|
@@ -1539,12 +1461,12 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
|
|
|
1539
1461
|
}, [
|
|
1540
1462
|
createSchema
|
|
1541
1463
|
]);
|
|
1542
|
-
return /* @__PURE__ */
|
|
1464
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Content, {
|
|
1543
1465
|
...props,
|
|
1544
1466
|
ref,
|
|
1545
1467
|
onSearch: handleSearch,
|
|
1546
1468
|
onKeyDownCapture: handleKeyDown
|
|
1547
|
-
}, showForm && createSchema ? /* @__PURE__ */
|
|
1469
|
+
}, showForm && createSchema ? /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Root, {
|
|
1548
1470
|
testId: "create-referenced-object-form",
|
|
1549
1471
|
schema: createSchema,
|
|
1550
1472
|
values: createInitialValuePath ? {
|
|
@@ -1552,24 +1474,24 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
|
|
|
1552
1474
|
} : {},
|
|
1553
1475
|
onSave: handleFormSave,
|
|
1554
1476
|
onCancel: handleFormCancel
|
|
1555
|
-
}, /* @__PURE__ */
|
|
1477
|
+
}, /* @__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, {
|
|
1556
1478
|
placeholder: t("ref field combobox input placeholder"),
|
|
1557
1479
|
autoFocus: true
|
|
1558
|
-
}), /* @__PURE__ */
|
|
1480
|
+
}), /* @__PURE__ */ React10.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1559
1481
|
key: option.id,
|
|
1560
1482
|
value: option.id,
|
|
1561
1483
|
label: option.label,
|
|
1562
1484
|
checked: selectedIds?.includes(option.id),
|
|
1563
1485
|
onSelect: () => onSelect(option.id),
|
|
1564
1486
|
classNames: "flex items-center gap-2"
|
|
1565
|
-
})), createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */
|
|
1487
|
+
})), createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */ React10.createElement(CreateItem, {
|
|
1566
1488
|
createOptionLabel,
|
|
1567
1489
|
createOptionIcon,
|
|
1568
1490
|
onCreateItemSelect: (query) => {
|
|
1569
1491
|
setFormInitialValue(query);
|
|
1570
1492
|
setShowForm(true);
|
|
1571
1493
|
}
|
|
1572
|
-
}))), /* @__PURE__ */
|
|
1494
|
+
}))), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
|
|
1573
1495
|
});
|
|
1574
1496
|
ObjectPickerContent.displayName = "ObjectPickerContent";
|
|
1575
1497
|
var ObjectPicker = {
|
|
@@ -1592,10 +1514,10 @@ var defaultGetOptions = (results) => results.map((result) => {
|
|
|
1592
1514
|
label: label ?? id
|
|
1593
1515
|
};
|
|
1594
1516
|
});
|
|
1595
|
-
var defaultResultsHook = (db, typename) => useQuery(db, typename ? Filter.typename(typename) : Filter.nothing());
|
|
1517
|
+
var defaultResultsHook = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Type.Obj) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
|
|
1596
1518
|
var RefField = (props) => {
|
|
1597
1519
|
const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, db, resultsHook: useResults = defaultResultsHook, schemaHook: useSchema = useSchema$, getOptions: getOptions2 = defaultGetOptions, onCreate, onValueChange } = props;
|
|
1598
|
-
const { t } =
|
|
1520
|
+
const { t } = useTranslation6(translationKey);
|
|
1599
1521
|
const { status, error } = getStatus();
|
|
1600
1522
|
const typename = useMemo6(() => type ? findAnnotation(type, ReferenceAnnotationId)?.typename : void 0, [
|
|
1601
1523
|
type
|
|
@@ -1660,40 +1582,40 @@ var RefField = (props) => {
|
|
|
1660
1582
|
if (!typename || (readonly || layout === "static") && !item) {
|
|
1661
1583
|
return null;
|
|
1662
1584
|
}
|
|
1663
|
-
return /* @__PURE__ */
|
|
1585
|
+
return /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1664
1586
|
validationValence: status
|
|
1665
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1587
|
+
}, layout !== "inline" && /* @__PURE__ */ React11.createElement(FormFieldLabel, {
|
|
1666
1588
|
error,
|
|
1667
1589
|
readonly,
|
|
1668
1590
|
label
|
|
1669
|
-
}), /* @__PURE__ */
|
|
1670
|
-
className:
|
|
1671
|
-
}, t("empty readonly ref field label")) : /* @__PURE__ */
|
|
1591
|
+
}), /* @__PURE__ */ React11.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React11.createElement("p", {
|
|
1592
|
+
className: mx3(descriptionText, "mbe-2")
|
|
1593
|
+
}, t("empty readonly ref field label")) : /* @__PURE__ */ React11.createElement(DxAnchor, {
|
|
1672
1594
|
key: item.id,
|
|
1673
|
-
|
|
1595
|
+
dxn: item.id,
|
|
1674
1596
|
rootclassname: "mie-1"
|
|
1675
|
-
}, item.label) : /* @__PURE__ */
|
|
1597
|
+
}, item.label) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
|
|
1676
1598
|
asChild: true,
|
|
1677
1599
|
classNames: "p-0"
|
|
1678
|
-
}, item ? /* @__PURE__ */
|
|
1600
|
+
}, item ? /* @__PURE__ */ React11.createElement("div", {
|
|
1679
1601
|
className: "flex gap-2 is-full"
|
|
1680
|
-
}, /* @__PURE__ */
|
|
1602
|
+
}, /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1681
1603
|
key: item.id
|
|
1682
|
-
}, /* @__PURE__ */
|
|
1604
|
+
}, /* @__PURE__ */ React11.createElement(Input6.TextInput, {
|
|
1683
1605
|
value: item.label,
|
|
1684
1606
|
readOnly: true,
|
|
1685
1607
|
classNames: "is-full"
|
|
1686
|
-
}))) : /* @__PURE__ */
|
|
1608
|
+
}))) : /* @__PURE__ */ React11.createElement(Button, {
|
|
1687
1609
|
classNames: "is-full text-start gap-2"
|
|
1688
|
-
}, /* @__PURE__ */
|
|
1610
|
+
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1689
1611
|
role: "none",
|
|
1690
1612
|
className: "grow overflow-hidden"
|
|
1691
|
-
}, /* @__PURE__ */
|
|
1613
|
+
}, /* @__PURE__ */ React11.createElement("span", {
|
|
1692
1614
|
className: "flex truncate text-description"
|
|
1693
|
-
}, placeholder ?? t("ref field placeholder"))), /* @__PURE__ */
|
|
1615
|
+
}, placeholder ?? t("ref field placeholder"))), /* @__PURE__ */ React11.createElement(Icon2, {
|
|
1694
1616
|
size: 3,
|
|
1695
1617
|
icon: "ph--caret-down--bold"
|
|
1696
|
-
}))), /* @__PURE__ */
|
|
1618
|
+
}))), /* @__PURE__ */ React11.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
|
|
1697
1619
|
classNames: "popover-card-width",
|
|
1698
1620
|
options,
|
|
1699
1621
|
selectedIds,
|
|
@@ -1703,12 +1625,12 @@ var RefField = (props) => {
|
|
|
1703
1625
|
createInitialValuePath,
|
|
1704
1626
|
onCreate: handleCreate,
|
|
1705
1627
|
onSelect: handleSelect
|
|
1706
|
-
})))), layout === "full" && /* @__PURE__ */
|
|
1628
|
+
})))), layout === "full" && /* @__PURE__ */ React11.createElement(Input6.DescriptionAndValidation, null, error));
|
|
1707
1629
|
};
|
|
1708
1630
|
|
|
1709
1631
|
// src/components/Form/fields/SelectField.tsx
|
|
1710
|
-
import
|
|
1711
|
-
import { Input as
|
|
1632
|
+
import React12, { useCallback as useCallback10 } from "react";
|
|
1633
|
+
import { Input as Input7, Select } from "@dxos/react-ui";
|
|
1712
1634
|
var SelectField = ({ type, readonly, label, layout, placeholder, options, getStatus, getValue, onValueChange }) => {
|
|
1713
1635
|
const { status, error } = getStatus();
|
|
1714
1636
|
const value3 = getValue();
|
|
@@ -1719,37 +1641,37 @@ var SelectField = ({ type, readonly, label, layout, placeholder, options, getSta
|
|
|
1719
1641
|
if ((readonly || layout === "static") && value3 == null) {
|
|
1720
1642
|
return null;
|
|
1721
1643
|
}
|
|
1722
|
-
return /* @__PURE__ */
|
|
1644
|
+
return /* @__PURE__ */ React12.createElement(Input7.Root, {
|
|
1723
1645
|
validationValence: status
|
|
1724
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1646
|
+
}, layout !== "inline" && /* @__PURE__ */ React12.createElement(FormFieldLabel, {
|
|
1725
1647
|
error,
|
|
1726
1648
|
readonly,
|
|
1727
1649
|
label
|
|
1728
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1650
|
+
}), layout === "static" ? /* @__PURE__ */ React12.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React12.createElement(Select.Root, {
|
|
1729
1651
|
value: value3,
|
|
1730
1652
|
onValueChange: handleValueChange
|
|
1731
|
-
}, /* @__PURE__ */
|
|
1653
|
+
}, /* @__PURE__ */ React12.createElement(Select.TriggerButton, {
|
|
1732
1654
|
classNames: "is-full",
|
|
1733
1655
|
disabled: !!readonly,
|
|
1734
1656
|
placeholder
|
|
1735
|
-
}), /* @__PURE__ */
|
|
1657
|
+
}), /* @__PURE__ */ React12.createElement(Select.Portal, null, /* @__PURE__ */ React12.createElement(Select.Content, null, /* @__PURE__ */ React12.createElement(Select.Viewport, null, options?.map(({ value: value4, label: label2 }) => (
|
|
1736
1658
|
// NOTE: Numeric values are converted to and from strings.
|
|
1737
|
-
/* @__PURE__ */
|
|
1659
|
+
/* @__PURE__ */ React12.createElement(Select.Option, {
|
|
1738
1660
|
key: String(value4),
|
|
1739
1661
|
value: String(value4)
|
|
1740
1662
|
}, label2 ?? String(value4))
|
|
1741
|
-
))), /* @__PURE__ */
|
|
1663
|
+
))), /* @__PURE__ */ React12.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React12.createElement(Input7.DescriptionAndValidation, null, error));
|
|
1742
1664
|
};
|
|
1743
1665
|
|
|
1744
1666
|
// src/components/Form/fields/SelectOptionField.tsx
|
|
1745
|
-
import
|
|
1667
|
+
import React13, { useCallback as useCallback11, useEffect as useEffect6, useRef as useRef3, useState as useState4 } from "react";
|
|
1746
1668
|
import { PublicKey } from "@dxos/keys";
|
|
1747
|
-
import { IconButton as IconButton3, Input as
|
|
1669
|
+
import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1748
1670
|
import { List } from "@dxos/react-ui-list";
|
|
1749
1671
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
1750
1672
|
import { hues, osTranslations, subtleHover } from "@dxos/ui-theme";
|
|
1751
1673
|
var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
|
|
1752
|
-
const { t } =
|
|
1674
|
+
const { t } = useTranslation7(translationKey);
|
|
1753
1675
|
const { status, error } = getStatus();
|
|
1754
1676
|
const [selected, setSelectedId] = useState4(null);
|
|
1755
1677
|
const [isNewOption, setIsNewOption] = useState4(false);
|
|
@@ -1855,25 +1777,25 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1855
1777
|
selected,
|
|
1856
1778
|
isNewOption
|
|
1857
1779
|
]);
|
|
1858
|
-
return /* @__PURE__ */
|
|
1780
|
+
return /* @__PURE__ */ React13.createElement(Input8.Root, {
|
|
1859
1781
|
validationValence: status
|
|
1860
|
-
}, /* @__PURE__ */
|
|
1782
|
+
}, /* @__PURE__ */ React13.createElement(FormFieldLabel, {
|
|
1861
1783
|
error,
|
|
1862
1784
|
readonly,
|
|
1863
1785
|
label
|
|
1864
|
-
}), /* @__PURE__ */
|
|
1786
|
+
}), /* @__PURE__ */ React13.createElement("div", {
|
|
1865
1787
|
role: "none"
|
|
1866
|
-
}, options && /* @__PURE__ */
|
|
1788
|
+
}, options && /* @__PURE__ */ React13.createElement(List.Root, {
|
|
1867
1789
|
items: options,
|
|
1868
1790
|
isItem: (_item) => true,
|
|
1869
1791
|
onMove: readonly ? void 0 : handleMove,
|
|
1870
1792
|
readonly: !!readonly
|
|
1871
|
-
}, ({ items }) => /* @__PURE__ */
|
|
1793
|
+
}, ({ items }) => /* @__PURE__ */ React13.createElement("div", {
|
|
1872
1794
|
role: "list",
|
|
1873
1795
|
className: "is-full overflow-auto"
|
|
1874
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
1796
|
+
}, items?.map((item) => /* @__PURE__ */ React13.createElement("div", {
|
|
1875
1797
|
key: item.id
|
|
1876
|
-
}, /* @__PURE__ */
|
|
1798
|
+
}, /* @__PURE__ */ React13.createElement(List.Item, {
|
|
1877
1799
|
role: "button",
|
|
1878
1800
|
item,
|
|
1879
1801
|
classNames: [
|
|
@@ -1881,16 +1803,16 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1881
1803
|
"flex flex-col cursor-pointer rounded-sm"
|
|
1882
1804
|
],
|
|
1883
1805
|
"aria-expanded": selected === item.id
|
|
1884
|
-
}, /* @__PURE__ */
|
|
1806
|
+
}, /* @__PURE__ */ React13.createElement("div", {
|
|
1885
1807
|
className: "flex items-center"
|
|
1886
|
-
}, /* @__PURE__ */
|
|
1808
|
+
}, /* @__PURE__ */ React13.createElement(List.ItemDragHandle, {
|
|
1887
1809
|
disabled: !!readonly
|
|
1888
|
-
}), /* @__PURE__ */
|
|
1810
|
+
}), /* @__PURE__ */ React13.createElement(List.ItemTitle, {
|
|
1889
1811
|
onClick: () => handleClick(item.id),
|
|
1890
1812
|
classNames: "flex-1"
|
|
1891
|
-
}, /* @__PURE__ */
|
|
1813
|
+
}, /* @__PURE__ */ React13.createElement(Tag, {
|
|
1892
1814
|
palette: item.color
|
|
1893
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
1815
|
+
}, item.title || "\u200B")), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1894
1816
|
iconOnly: true,
|
|
1895
1817
|
variant: "ghost",
|
|
1896
1818
|
label: t(selected === item.id ? "collapse label" : "expand label", {
|
|
@@ -1898,13 +1820,13 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1898
1820
|
}),
|
|
1899
1821
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
1900
1822
|
onClick: () => handleClick(item.id)
|
|
1901
|
-
})), selected === item.id && /* @__PURE__ */
|
|
1823
|
+
})), selected === item.id && /* @__PURE__ */ React13.createElement("div", {
|
|
1902
1824
|
className: "pli-cardSpacingInline plb-cardSpacingBlock flex flex-col gap-1 density-fine"
|
|
1903
|
-
}, /* @__PURE__ */
|
|
1825
|
+
}, /* @__PURE__ */ React13.createElement(Input8.Label, {
|
|
1904
1826
|
classNames: "text-xs"
|
|
1905
|
-
}, t("select option label")), /* @__PURE__ */
|
|
1827
|
+
}, t("select option label")), /* @__PURE__ */ React13.createElement("div", {
|
|
1906
1828
|
className: "grid grid-cols-[1fr_min-content_min-content] gap-1"
|
|
1907
|
-
}, /* @__PURE__ */
|
|
1829
|
+
}, /* @__PURE__ */ React13.createElement(Input8.TextInput, {
|
|
1908
1830
|
disabled: !!readonly,
|
|
1909
1831
|
placeholder: t("select option label placeholder"),
|
|
1910
1832
|
ref: selected === item.id ? inputRef : void 0,
|
|
@@ -1912,17 +1834,17 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1912
1834
|
onChange: handleTitleChange(item.id),
|
|
1913
1835
|
onKeyDown: handleKeyDown,
|
|
1914
1836
|
classNames: "flex-1"
|
|
1915
|
-
}), /* @__PURE__ */
|
|
1837
|
+
}), /* @__PURE__ */ React13.createElement(HuePicker, {
|
|
1916
1838
|
disabled: !!readonly,
|
|
1917
1839
|
value: item.color,
|
|
1918
1840
|
onChange: handleColorChange(item.id)
|
|
1919
|
-
}), /* @__PURE__ */
|
|
1841
|
+
}), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1920
1842
|
disabled: !!readonly,
|
|
1921
1843
|
icon: "ph--trash--fill",
|
|
1922
1844
|
iconOnly: true,
|
|
1923
1845
|
label: t("select option delete"),
|
|
1924
1846
|
onClick: () => handleDelete(item.id)
|
|
1925
|
-
})))))), /* @__PURE__ */
|
|
1847
|
+
})))))), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1926
1848
|
variant: "ghost",
|
|
1927
1849
|
icon: "ph--plus--regular",
|
|
1928
1850
|
label: t("select option add"),
|
|
@@ -1933,17 +1855,17 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1933
1855
|
};
|
|
1934
1856
|
|
|
1935
1857
|
// src/components/Form/fields/TextField.tsx
|
|
1936
|
-
import
|
|
1937
|
-
import { Input as
|
|
1858
|
+
import React14, { useCallback as useCallback12 } from "react";
|
|
1859
|
+
import { Input as Input9 } from "@dxos/react-ui";
|
|
1938
1860
|
var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1939
1861
|
const handleChange = useCallback12((event) => onValueChange(type, event.target.value), [
|
|
1940
1862
|
type,
|
|
1941
1863
|
onValueChange
|
|
1942
1864
|
]);
|
|
1943
|
-
return /* @__PURE__ */
|
|
1865
|
+
return /* @__PURE__ */ React14.createElement(FormFieldWrapper, {
|
|
1944
1866
|
readonly,
|
|
1945
1867
|
...props
|
|
1946
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1868
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React14.createElement(Input9.TextInput, {
|
|
1947
1869
|
noAutoFill: true,
|
|
1948
1870
|
disabled: !!readonly,
|
|
1949
1871
|
placeholder,
|
|
@@ -1954,17 +1876,17 @@ var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props
|
|
|
1954
1876
|
};
|
|
1955
1877
|
|
|
1956
1878
|
// src/components/Form/fields/TextAreaField.tsx
|
|
1957
|
-
import
|
|
1958
|
-
import { Input as
|
|
1879
|
+
import React15, { useCallback as useCallback13 } from "react";
|
|
1880
|
+
import { Input as Input10 } from "@dxos/react-ui";
|
|
1959
1881
|
var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1960
1882
|
const handleChange = useCallback13((event) => onValueChange(type, event.target.value), [
|
|
1961
1883
|
type,
|
|
1962
1884
|
onValueChange
|
|
1963
1885
|
]);
|
|
1964
|
-
return /* @__PURE__ */
|
|
1886
|
+
return /* @__PURE__ */ React15.createElement(FormFieldWrapper, {
|
|
1965
1887
|
readonly,
|
|
1966
1888
|
...props
|
|
1967
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1889
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React15.createElement(Input10.TextArea, {
|
|
1968
1890
|
rows: 3,
|
|
1969
1891
|
disabled: !!readonly,
|
|
1970
1892
|
placeholder,
|
|
@@ -1975,9 +1897,9 @@ var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...pr
|
|
|
1975
1897
|
};
|
|
1976
1898
|
|
|
1977
1899
|
// src/components/Form/fields/TupleField.tsx
|
|
1978
|
-
import
|
|
1979
|
-
import { Input as
|
|
1980
|
-
import { mx as
|
|
1900
|
+
import React16 from "react";
|
|
1901
|
+
import { Input as Input11 } from "@dxos/react-ui";
|
|
1902
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
1981
1903
|
import { safeParseFloat as safeParseFloat3 } from "@dxos/util";
|
|
1982
1904
|
var gridCols = [
|
|
1983
1905
|
"grid-cols-1",
|
|
@@ -1988,15 +1910,15 @@ var gridCols = [
|
|
|
1988
1910
|
var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1989
1911
|
const { status, error } = getStatus();
|
|
1990
1912
|
const values = getValue() ?? {};
|
|
1991
|
-
return /* @__PURE__ */
|
|
1913
|
+
return /* @__PURE__ */ React16.createElement(Input11.Root, {
|
|
1992
1914
|
validationValence: status
|
|
1993
|
-
}, /* @__PURE__ */
|
|
1915
|
+
}, /* @__PURE__ */ React16.createElement(FormFieldLabel, {
|
|
1994
1916
|
error,
|
|
1995
1917
|
readonly,
|
|
1996
1918
|
label
|
|
1997
|
-
}), /* @__PURE__ */
|
|
1998
|
-
className:
|
|
1999
|
-
}, binding.map((prop) => /* @__PURE__ */
|
|
1919
|
+
}), /* @__PURE__ */ React16.createElement("div", {
|
|
1920
|
+
className: mx4("grid gap-2", gridCols[binding.length - 1])
|
|
1921
|
+
}, binding.map((prop) => /* @__PURE__ */ React16.createElement(Input11.TextInput, {
|
|
2000
1922
|
key: prop,
|
|
2001
1923
|
type: "number",
|
|
2002
1924
|
disabled: !!readonly,
|
|
@@ -2014,7 +1936,7 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
|
|
|
2014
1936
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
2015
1937
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
2016
1938
|
var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
|
|
2017
|
-
const { t } =
|
|
1939
|
+
const { t } = useTranslation8(translationKey);
|
|
2018
1940
|
const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
|
|
2019
1941
|
useEffect7(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
2020
1942
|
field,
|
|
@@ -2045,26 +1967,26 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2045
1967
|
fieldSchema: getFormatSchema(props?.format)
|
|
2046
1968
|
});
|
|
2047
1969
|
const fieldMap = useMemo7(() => ({
|
|
2048
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
1970
|
+
["format"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2049
1971
|
...props2,
|
|
2050
1972
|
options: FormatEnums.filter((value3) => value3 !== Format4.TypeFormat.None).map((value3) => ({
|
|
2051
1973
|
value: value3,
|
|
2052
1974
|
label: t(`format ${value3}`)
|
|
2053
1975
|
}))
|
|
2054
1976
|
}),
|
|
2055
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
1977
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2056
1978
|
...props2,
|
|
2057
1979
|
options: schemas.map((schema) => ({
|
|
2058
1980
|
value: schema.typename
|
|
2059
1981
|
}))
|
|
2060
1982
|
}),
|
|
2061
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
1983
|
+
["referencePath"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2062
1984
|
...props2,
|
|
2063
1985
|
options: referenceSchema ? getFormProperties(referenceSchema.ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
|
|
2064
1986
|
value: p.name.toString()
|
|
2065
1987
|
})) : []
|
|
2066
1988
|
}),
|
|
2067
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
1989
|
+
["options"]: (props2) => /* @__PURE__ */ React17.createElement(SelectOptionField, props2)
|
|
2068
1990
|
}), [
|
|
2069
1991
|
t,
|
|
2070
1992
|
schemas,
|
|
@@ -2123,7 +2045,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2123
2045
|
]);
|
|
2124
2046
|
const handleSave = useCallback14((props2) => {
|
|
2125
2047
|
if (view) {
|
|
2126
|
-
|
|
2048
|
+
Obj3.change(view, () => {
|
|
2127
2049
|
projection.setFieldProjection({
|
|
2128
2050
|
field,
|
|
2129
2051
|
props: props2
|
|
@@ -2159,7 +2081,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2159
2081
|
});
|
|
2160
2082
|
return null;
|
|
2161
2083
|
}
|
|
2162
|
-
return /* @__PURE__ */
|
|
2084
|
+
return /* @__PURE__ */ React17.createElement(Form.Root, {
|
|
2163
2085
|
key: field.id,
|
|
2164
2086
|
fieldMap,
|
|
2165
2087
|
autoFocus: true,
|
|
@@ -2175,7 +2097,137 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2175
2097
|
onValidate: handleValidate,
|
|
2176
2098
|
onSave: handleSave,
|
|
2177
2099
|
onCancel: handleCancel
|
|
2178
|
-
}, /* @__PURE__ */
|
|
2100
|
+
}, /* @__PURE__ */ React17.createElement(Form.Content, null, /* @__PURE__ */ React17.createElement(Form.FieldSet, null), /* @__PURE__ */ React17.createElement(Form.Actions, null)));
|
|
2101
|
+
};
|
|
2102
|
+
|
|
2103
|
+
// src/components/Settings/Settings.tsx
|
|
2104
|
+
import React18 from "react";
|
|
2105
|
+
import { Button as Button2, Input as Input12, ScrollArea as ScrollArea2, toLocalizedString, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
2106
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
2107
|
+
var SETTINGS_ROOT_NAME = "Settings.Root";
|
|
2108
|
+
var SETTINGS_SECTION_NAME = "Settings.Section";
|
|
2109
|
+
var SETTINGS_SECTION_HEADING_NAME = "Settings.SectionHeading";
|
|
2110
|
+
var SETTINGS_GROUP_NAME = "Settings.Group";
|
|
2111
|
+
var SETTINGS_GROUP_BUTTON_NAME = "Settings.GroupButton";
|
|
2112
|
+
var SETTINGS_CONTAINER_NAME = "Settings.Container";
|
|
2113
|
+
var SETTINGS_FRAME_NAME = "Settings.Frame";
|
|
2114
|
+
var SETTINGS_FRAME_ITEM_NAME = "Settings.FrameItem";
|
|
2115
|
+
var SETTINGS_ITEM_NAME = "Settings.Item";
|
|
2116
|
+
var SETTINGS_ITEM_INPUT_NAME = "Settings.ItemInput";
|
|
2117
|
+
var styles = {
|
|
2118
|
+
title: "pbe-trimMd text-baseText text-lg",
|
|
2119
|
+
description: "text-base text-description",
|
|
2120
|
+
grid: "grid grid-cols-1 md:grid-cols-[3fr_2fr] gap-x-trimLg"
|
|
2121
|
+
};
|
|
2122
|
+
var SettingsRoot = ({ children }) => {
|
|
2123
|
+
return /* @__PURE__ */ React18.createElement(ScrollArea2.Root, {
|
|
2124
|
+
orientation: "vertical"
|
|
2125
|
+
}, /* @__PURE__ */ React18.createElement(ScrollArea2.Viewport, {
|
|
2126
|
+
classNames: "p-trimMd"
|
|
2127
|
+
}, children));
|
|
2128
|
+
};
|
|
2129
|
+
SettingsRoot.displayName = SETTINGS_ROOT_NAME;
|
|
2130
|
+
var SettingsSection = ({ title, description, children }) => {
|
|
2131
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(SettingsSectionHeading, {
|
|
2132
|
+
title,
|
|
2133
|
+
description
|
|
2134
|
+
}), /* @__PURE__ */ React18.createElement("div", {
|
|
2135
|
+
className: "is-full pbs-trimMd space-y-trimMd"
|
|
2136
|
+
}, children));
|
|
2137
|
+
};
|
|
2138
|
+
SettingsSection.displayName = SETTINGS_SECTION_NAME;
|
|
2139
|
+
var SettingsSectionHeading = ({ title, description }) => {
|
|
2140
|
+
const { t } = useTranslation9(translationKey);
|
|
2141
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement("h2", {
|
|
2142
|
+
className: "pli-trimMd container-max-width text-xl mbs-trimMd mbe-trimMd"
|
|
2143
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React18.createElement("p", {
|
|
2144
|
+
className: "pli-trimMd mlb-trimMd container-max-width text-description"
|
|
2145
|
+
}, toLocalizedString(description, t)));
|
|
2146
|
+
};
|
|
2147
|
+
SettingsSectionHeading.displayName = SETTINGS_SECTION_HEADING_NAME;
|
|
2148
|
+
var SettingsGroupButton = ({ classNames, ...props }) => {
|
|
2149
|
+
return /* @__PURE__ */ React18.createElement(Button2, {
|
|
2150
|
+
...props,
|
|
2151
|
+
classNames: [
|
|
2152
|
+
"md:col-span-2",
|
|
2153
|
+
classNames
|
|
2154
|
+
]
|
|
2155
|
+
});
|
|
2156
|
+
};
|
|
2157
|
+
SettingsGroupButton.displayName = SETTINGS_GROUP_BUTTON_NAME;
|
|
2158
|
+
var SettingsGroup = ({ children, classNames }) => /* @__PURE__ */ React18.createElement("div", {
|
|
2159
|
+
role: "none",
|
|
2160
|
+
className: mx5("group container-max-width space-y-trimMd", classNames)
|
|
2161
|
+
}, children);
|
|
2162
|
+
SettingsGroup.displayName = SETTINGS_GROUP_NAME;
|
|
2163
|
+
var SettingsFrame = ({ children }) => /* @__PURE__ */ React18.createElement("div", {
|
|
2164
|
+
role: "none",
|
|
2165
|
+
className: mx5("container-max-width p-trimMd", "border border-separator rounded-md")
|
|
2166
|
+
}, children);
|
|
2167
|
+
SettingsFrame.displayName = SETTINGS_FRAME_NAME;
|
|
2168
|
+
var SettingsFrameItem = ({ title, description, children }) => {
|
|
2169
|
+
const { t } = useTranslation9(translationKey);
|
|
2170
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
2171
|
+
role: "group",
|
|
2172
|
+
className: "min-is-0"
|
|
2173
|
+
}, /* @__PURE__ */ React18.createElement("h3", {
|
|
2174
|
+
className: "text-lg mbe-2"
|
|
2175
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React18.createElement("p", {
|
|
2176
|
+
className: "mlb-trimSm md:mbe-0 text-description"
|
|
2177
|
+
}, toLocalizedString(description, t)), children);
|
|
2178
|
+
};
|
|
2179
|
+
SettingsFrameItem.displayName = SETTINGS_FRAME_ITEM_NAME;
|
|
2180
|
+
var SettingsContainer = ({ classNames, children }) => {
|
|
2181
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
2182
|
+
role: "none",
|
|
2183
|
+
className: mx5([
|
|
2184
|
+
"container-max-width",
|
|
2185
|
+
"*:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd",
|
|
2186
|
+
"border border-separator rounded-md",
|
|
2187
|
+
classNames
|
|
2188
|
+
])
|
|
2189
|
+
}, children);
|
|
2190
|
+
};
|
|
2191
|
+
SettingsContainer.displayName = SETTINGS_CONTAINER_NAME;
|
|
2192
|
+
var SettingsItem = ({ title, description = "", children }) => {
|
|
2193
|
+
const { t } = useTranslation9(translationKey);
|
|
2194
|
+
return /* @__PURE__ */ React18.createElement(SettingsContainer, {
|
|
2195
|
+
classNames: styles.grid
|
|
2196
|
+
}, /* @__PURE__ */ React18.createElement("h3", {
|
|
2197
|
+
className: mx5(styles.title, "md:col-span-2")
|
|
2198
|
+
}, toLocalizedString(title, t)), /* @__PURE__ */ React18.createElement("p", {
|
|
2199
|
+
className: styles.description
|
|
2200
|
+
}, toLocalizedString(description, t)), /* @__PURE__ */ React18.createElement("div", {
|
|
2201
|
+
role: "none",
|
|
2202
|
+
className: "text-end plb-1"
|
|
2203
|
+
}, children));
|
|
2204
|
+
};
|
|
2205
|
+
SettingsItem.displayName = SETTINGS_ITEM_NAME;
|
|
2206
|
+
var SettingsItemInput = ({ title, description = "", children }) => {
|
|
2207
|
+
const { t } = useTranslation9(translationKey);
|
|
2208
|
+
return /* @__PURE__ */ React18.createElement(Input12.Root, null, /* @__PURE__ */ React18.createElement(SettingsContainer, {
|
|
2209
|
+
classNames: styles.grid
|
|
2210
|
+
}, /* @__PURE__ */ React18.createElement(Input12.Label, {
|
|
2211
|
+
classNames: mx5(styles.title, "md:col-span-2")
|
|
2212
|
+
}, toLocalizedString(title, t)), /* @__PURE__ */ React18.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React18.createElement(Input12.Description, {
|
|
2213
|
+
classNames: styles.description
|
|
2214
|
+
}, toLocalizedString(description, t))), /* @__PURE__ */ React18.createElement("div", {
|
|
2215
|
+
role: "none",
|
|
2216
|
+
className: "text-end plb-1"
|
|
2217
|
+
}, children)));
|
|
2218
|
+
};
|
|
2219
|
+
SettingsItemInput.displayName = SETTINGS_ITEM_INPUT_NAME;
|
|
2220
|
+
var Settings = {
|
|
2221
|
+
Root: SettingsRoot,
|
|
2222
|
+
Section: SettingsSection,
|
|
2223
|
+
SectionHeading: SettingsSectionHeading,
|
|
2224
|
+
Group: SettingsGroup,
|
|
2225
|
+
GroupButton: SettingsGroupButton,
|
|
2226
|
+
Container: SettingsContainer,
|
|
2227
|
+
Frame: SettingsFrame,
|
|
2228
|
+
FrameItem: SettingsFrameItem,
|
|
2229
|
+
Item: SettingsItem,
|
|
2230
|
+
ItemInput: SettingsItemInput
|
|
2179
2231
|
};
|
|
2180
2232
|
|
|
2181
2233
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
@@ -2185,14 +2237,15 @@ import * as Match2 from "effect/Match";
|
|
|
2185
2237
|
import * as Option4 from "effect/Option";
|
|
2186
2238
|
import * as Schema3 from "effect/Schema";
|
|
2187
2239
|
import React19, { forwardRef as forwardRef3, useCallback as useCallback15, useContext, useImperativeHandle, useMemo as useMemo8, useState as useState6 } from "react";
|
|
2188
|
-
import { Filter as Filter2, Format as Format5, Obj as
|
|
2240
|
+
import { Filter as Filter2, Format as Format5, Obj as Obj4, Query, QueryAST } from "@dxos/echo";
|
|
2189
2241
|
import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
|
|
2190
2242
|
import { invariant } from "@dxos/invariant";
|
|
2243
|
+
import { useObject } from "@dxos/react-client/echo";
|
|
2191
2244
|
import { Callout, IconButton as IconButton4, Input as Input13, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
2192
2245
|
import { QueryForm } from "@dxos/react-ui-components";
|
|
2193
2246
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2194
|
-
import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT,
|
|
2195
|
-
import { mx as
|
|
2247
|
+
import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2248
|
+
import { mx as mx6, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
|
|
2196
2249
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2197
2250
|
var listGrid = "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]";
|
|
2198
2251
|
var listItemGrid = "grid grid-cols-subgrid col-span-5";
|
|
@@ -2202,7 +2255,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2202
2255
|
const { t } = useTranslation10(translationKey);
|
|
2203
2256
|
const projectionModel = useMemo8(() => {
|
|
2204
2257
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2205
|
-
const change = schema instanceof EchoSchema ?
|
|
2258
|
+
const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
|
|
2206
2259
|
const model = new ProjectionModel({
|
|
2207
2260
|
registry: atomRegistry,
|
|
2208
2261
|
view,
|
|
@@ -2218,7 +2271,6 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2218
2271
|
useImperativeHandle(forwardedRef, () => projectionModel, [
|
|
2219
2272
|
projectionModel
|
|
2220
2273
|
]);
|
|
2221
|
-
const [expandedField, setExpandedField] = useState6();
|
|
2222
2274
|
const queueTarget = Match2.value(view.query.ast).pipe(Match2.when({
|
|
2223
2275
|
type: "options"
|
|
2224
2276
|
}, ({ options }) => {
|
|
@@ -2260,22 +2312,6 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2260
2312
|
types,
|
|
2261
2313
|
tags
|
|
2262
2314
|
]);
|
|
2263
|
-
const handleAdd = useCallback15(() => {
|
|
2264
|
-
invariant(!readonly, void 0, {
|
|
2265
|
-
F: __dxlog_file3,
|
|
2266
|
-
L: 148,
|
|
2267
|
-
S: void 0,
|
|
2268
|
-
A: [
|
|
2269
|
-
"!readonly",
|
|
2270
|
-
""
|
|
2271
|
-
]
|
|
2272
|
-
});
|
|
2273
|
-
const field = projectionModel.createFieldProjection();
|
|
2274
|
-
setExpandedField(field.id);
|
|
2275
|
-
}, [
|
|
2276
|
-
projectionModel,
|
|
2277
|
-
readonly
|
|
2278
|
-
]);
|
|
2279
2315
|
const handleUpdate = useCallback15((values) => {
|
|
2280
2316
|
requestAnimationFrame(() => {
|
|
2281
2317
|
const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : values.query;
|
|
@@ -2290,25 +2326,21 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2290
2326
|
const handleDelete = useCallback15((fieldId) => {
|
|
2291
2327
|
invariant(!readonly, void 0, {
|
|
2292
2328
|
F: __dxlog_file3,
|
|
2293
|
-
L:
|
|
2329
|
+
L: 155,
|
|
2294
2330
|
S: void 0,
|
|
2295
2331
|
A: [
|
|
2296
2332
|
"!readonly",
|
|
2297
2333
|
""
|
|
2298
2334
|
]
|
|
2299
2335
|
});
|
|
2300
|
-
if (fieldId === expandedField) {
|
|
2301
|
-
setExpandedField(void 0);
|
|
2302
|
-
}
|
|
2303
2336
|
onDelete?.(fieldId);
|
|
2304
2337
|
}, [
|
|
2305
|
-
expandedField,
|
|
2306
2338
|
onDelete,
|
|
2307
2339
|
readonly
|
|
2308
2340
|
]);
|
|
2309
2341
|
return /* @__PURE__ */ React19.createElement("div", {
|
|
2310
2342
|
role: "none",
|
|
2311
|
-
className:
|
|
2343
|
+
className: mx6(classNames)
|
|
2312
2344
|
}, schemaReadonly && !readonly && /* @__PURE__ */ React19.createElement(Callout.Root, {
|
|
2313
2345
|
valence: "info",
|
|
2314
2346
|
classNames: "mlb-cardSpacingBlock"
|
|
@@ -2328,25 +2360,16 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2328
2360
|
readonly,
|
|
2329
2361
|
showHeading,
|
|
2330
2362
|
onDelete: handleDelete
|
|
2331
|
-
})), !readonly && !expandedField && /* @__PURE__ */ React19.createElement("div", {
|
|
2332
|
-
role: "none",
|
|
2333
|
-
className: "mlb-cardSpacingBlock"
|
|
2334
|
-
}, /* @__PURE__ */ React19.createElement(IconButton4, {
|
|
2335
|
-
icon: "ph--plus--regular",
|
|
2336
|
-
label: t("add property button label"),
|
|
2337
|
-
onClick: readonly ? void 0 : handleAdd,
|
|
2338
|
-
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2339
|
-
disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2340
|
-
classNames: "is-full"
|
|
2341
2363
|
})));
|
|
2342
2364
|
});
|
|
2343
2365
|
var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
|
|
2344
2366
|
const atomRegistry = useContext(RegistryContext);
|
|
2345
2367
|
const schemaReadonly = !isMutable(schema);
|
|
2346
2368
|
const { t } = useTranslation10(translationKey);
|
|
2369
|
+
const [viewSnapshot] = useObject(view);
|
|
2347
2370
|
const projectionModel = useMemo8(() => {
|
|
2348
2371
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2349
|
-
const change = schema instanceof EchoSchema ?
|
|
2372
|
+
const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
|
|
2350
2373
|
const model = new ProjectionModel({
|
|
2351
2374
|
registry: atomRegistry,
|
|
2352
2375
|
view,
|
|
@@ -2360,6 +2383,22 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2360
2383
|
view
|
|
2361
2384
|
]);
|
|
2362
2385
|
const [expandedField, setExpandedField] = useState6();
|
|
2386
|
+
const handleAdd = useCallback15(() => {
|
|
2387
|
+
invariant(!readonly, void 0, {
|
|
2388
|
+
F: __dxlog_file3,
|
|
2389
|
+
L: 220,
|
|
2390
|
+
S: void 0,
|
|
2391
|
+
A: [
|
|
2392
|
+
"!readonly",
|
|
2393
|
+
""
|
|
2394
|
+
]
|
|
2395
|
+
});
|
|
2396
|
+
const field = projectionModel.createFieldProjection();
|
|
2397
|
+
setExpandedField(field.id);
|
|
2398
|
+
}, [
|
|
2399
|
+
projectionModel,
|
|
2400
|
+
readonly
|
|
2401
|
+
]);
|
|
2363
2402
|
const handleToggleField = useCallback15((field) => {
|
|
2364
2403
|
setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
|
|
2365
2404
|
}, [
|
|
@@ -2368,7 +2407,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2368
2407
|
const handleDelete = useCallback15((fieldId) => {
|
|
2369
2408
|
invariant(!readonly, void 0, {
|
|
2370
2409
|
F: __dxlog_file3,
|
|
2371
|
-
L:
|
|
2410
|
+
L: 234,
|
|
2372
2411
|
S: void 0,
|
|
2373
2412
|
A: [
|
|
2374
2413
|
"!readonly",
|
|
@@ -2387,23 +2426,23 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2387
2426
|
const handleMove = useCallback15((fromIndex, toIndex) => {
|
|
2388
2427
|
invariant(!readonly, void 0, {
|
|
2389
2428
|
F: __dxlog_file3,
|
|
2390
|
-
L:
|
|
2429
|
+
L: 246,
|
|
2391
2430
|
S: void 0,
|
|
2392
2431
|
A: [
|
|
2393
2432
|
"!readonly",
|
|
2394
2433
|
""
|
|
2395
2434
|
]
|
|
2396
2435
|
});
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2436
|
+
Obj4.change(view, (v) => {
|
|
2437
|
+
const fields = [
|
|
2438
|
+
...v.projection.fields
|
|
2439
|
+
];
|
|
2440
|
+
const [moved] = fields.splice(fromIndex, 1);
|
|
2441
|
+
fields.splice(toIndex, 0, moved);
|
|
2403
2442
|
v.projection.fields = fields;
|
|
2404
2443
|
});
|
|
2405
2444
|
}, [
|
|
2406
|
-
view
|
|
2445
|
+
view,
|
|
2407
2446
|
readonly
|
|
2408
2447
|
]);
|
|
2409
2448
|
const handleClose = useCallback15(() => setExpandedField(void 0), []);
|
|
@@ -2419,8 +2458,11 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2419
2458
|
}, [
|
|
2420
2459
|
projectionModel
|
|
2421
2460
|
]);
|
|
2461
|
+
if (!viewSnapshot) {
|
|
2462
|
+
return null;
|
|
2463
|
+
}
|
|
2422
2464
|
return /* @__PURE__ */ React19.createElement(List2.Root, {
|
|
2423
|
-
items:
|
|
2465
|
+
items: viewSnapshot.projection.fields,
|
|
2424
2466
|
isItem: Schema3.is(FieldSchema),
|
|
2425
2467
|
getId: (field) => field.id,
|
|
2426
2468
|
onMove: readonly ? void 0 : handleMove,
|
|
@@ -2439,7 +2481,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2439
2481
|
"aria-expanded": expandedField === field.id
|
|
2440
2482
|
}, /* @__PURE__ */ React19.createElement("div", {
|
|
2441
2483
|
role: "none",
|
|
2442
|
-
className:
|
|
2484
|
+
className: mx6(subtleHover2, listItemGrid, "rounded-sm cursor-pointer min-bs-10")
|
|
2443
2485
|
}, /* @__PURE__ */ React19.createElement(List2.ItemDragHandle, {
|
|
2444
2486
|
disabled: readonly || schemaReadonly
|
|
2445
2487
|
}), /* @__PURE__ */ React19.createElement(List2.ItemTitle, {
|
|
@@ -2455,7 +2497,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2455
2497
|
}), !readonly && /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(List2.ItemDeleteButton, {
|
|
2456
2498
|
label: t("delete field label"),
|
|
2457
2499
|
autoHide: false,
|
|
2458
|
-
disabled: readonly || schemaReadonly ||
|
|
2500
|
+
disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
|
|
2459
2501
|
onClick: () => handleDelete(field.id),
|
|
2460
2502
|
"data-testid": "field.delete"
|
|
2461
2503
|
}), /* @__PURE__ */ React19.createElement(IconButton4, {
|
|
@@ -2477,6 +2519,15 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2477
2519
|
field,
|
|
2478
2520
|
onSave: handleClose
|
|
2479
2521
|
})));
|
|
2522
|
+
})), !readonly && !expandedField && /* @__PURE__ */ React19.createElement("div", {
|
|
2523
|
+
role: "none",
|
|
2524
|
+
className: "mlb-cardSpacingBlock"
|
|
2525
|
+
}, /* @__PURE__ */ React19.createElement(IconButton4, {
|
|
2526
|
+
icon: "ph--plus--regular",
|
|
2527
|
+
label: t("add property button label"),
|
|
2528
|
+
onClick: handleAdd,
|
|
2529
|
+
disabled: viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2530
|
+
classNames: "is-full"
|
|
2480
2531
|
}))));
|
|
2481
2532
|
};
|
|
2482
2533
|
var customFields = ({ types, tags }) => ({
|
|
@@ -2498,15 +2549,6 @@ var customFields = ({ types, tags }) => ({
|
|
|
2498
2549
|
export {
|
|
2499
2550
|
ArrayField,
|
|
2500
2551
|
BooleanField,
|
|
2501
|
-
ControlFrame,
|
|
2502
|
-
ControlFrameItem,
|
|
2503
|
-
ControlGroup,
|
|
2504
|
-
ControlGroupButton,
|
|
2505
|
-
ControlItem,
|
|
2506
|
-
ControlItemInput,
|
|
2507
|
-
ControlPage,
|
|
2508
|
-
ControlSection,
|
|
2509
|
-
ControlSectionHeading,
|
|
2510
2552
|
FieldEditor,
|
|
2511
2553
|
Form,
|
|
2512
2554
|
FormFieldErrorBoundary,
|
|
@@ -2519,12 +2561,12 @@ export {
|
|
|
2519
2561
|
RefField,
|
|
2520
2562
|
SelectField,
|
|
2521
2563
|
SelectOptionField,
|
|
2564
|
+
Settings,
|
|
2522
2565
|
TextAreaField,
|
|
2523
2566
|
TextField,
|
|
2524
2567
|
TupleField,
|
|
2525
2568
|
ViewEditor,
|
|
2526
2569
|
cellClassesForFieldType,
|
|
2527
|
-
controlItemClasses,
|
|
2528
2570
|
formatForDisplay,
|
|
2529
2571
|
formatForEditing,
|
|
2530
2572
|
getDefaultValue,
|
|
@@ -2533,6 +2575,7 @@ export {
|
|
|
2533
2575
|
omitId,
|
|
2534
2576
|
parseValue,
|
|
2535
2577
|
pathNotUniqueError,
|
|
2578
|
+
setValueEchoAware,
|
|
2536
2579
|
translations,
|
|
2537
2580
|
useFormContext,
|
|
2538
2581
|
useFormFieldState,
|