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