@dxos/react-ui-form 0.8.4-main.b97322e → 0.8.4-main.c4373fc
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 +810 -594
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +810 -594
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.d.ts +2 -2
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +81 -5
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -2
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +76 -5
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/ArrayField.d.ts +2 -2
- package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/Defaults.d.ts +5 -5
- package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +7 -6
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +129 -32
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +17 -11
- package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContext.d.ts +3 -3
- package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
- package/dist/types/src/components/Form/Input.d.ts +5 -2
- package/dist/types/src/components/Form/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/RefField.d.ts +14 -5
- package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +1 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +76 -4
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts +1 -1
- package/dist/types/src/components/Form/factory.d.ts +1 -1
- package/dist/types/src/components/Form/factory.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +41 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +81 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectPicker/index.d.ts +2 -0
- package/dist/types/src/components/ObjectPicker/index.d.ts.map +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +16 -4
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +79 -7
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +6 -3
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useForm.d.ts +3 -3
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueryRefOptions.d.ts +8 -3
- package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +11 -5
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/field.d.ts +1 -1
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts +1 -1
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/dist/types/src/util/refs.d.ts +1 -1
- package/dist/types/src/util/refs.d.ts.map +1 -1
- package/dist/types/src/util/schema.d.ts +1 -1
- package/dist/types/src/util/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -36
- package/src/components/ControlSection/ControlSection.stories.tsx +11 -14
- package/src/components/ControlSection/ControlSection.tsx +26 -12
- package/src/components/FieldEditor/FieldEditor.stories.tsx +14 -14
- package/src/components/FieldEditor/FieldEditor.test.tsx +3 -2
- package/src/components/FieldEditor/FieldEditor.tsx +26 -18
- package/src/components/Form/ArrayField.tsx +12 -11
- package/src/components/Form/Defaults.tsx +22 -20
- package/src/components/Form/Form.stories.tsx +135 -99
- package/src/components/Form/Form.tsx +26 -15
- package/src/components/Form/FormActions.tsx +2 -1
- package/src/components/Form/FormContent.tsx +121 -39
- package/src/components/Form/FormContext.tsx +8 -8
- package/src/components/Form/Input.tsx +5 -2
- package/src/components/Form/RefField.tsx +97 -41
- package/src/components/Form/custom/GeoPointInput.tsx +29 -21
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +11 -11
- package/src/components/Form/custom/SelectOptionsInput.tsx +30 -31
- package/src/components/Form/custom/TupleInput.tsx +2 -2
- package/src/components/Form/factory.tsx +2 -2
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +207 -0
- package/src/components/ObjectPicker/ObjectPicker.tsx +161 -0
- package/src/components/ObjectPicker/index.ts +5 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +102 -44
- package/src/components/ViewEditor/ViewEditor.test.tsx +9 -12
- package/src/components/ViewEditor/ViewEditor.tsx +328 -220
- package/src/components/index.ts +1 -2
- package/src/components/testing.tsx +15 -9
- package/src/hooks/useForm.ts +8 -4
- package/src/hooks/useQueryRefOptions.ts +9 -3
- package/src/hooks/useRefQueryLookupHandler.ts +1 -1
- package/src/translations.ts +13 -6
- package/src/util/field.ts +9 -19
- package/src/util/formatting.ts +1 -1
- package/src/util/refs.ts +2 -2
- package/src/util/schema.ts +2 -4
- package/dist/types/src/components/deprecated/Form.d.ts +0 -15
- package/dist/types/src/components/deprecated/Form.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts +0 -13
- package/dist/types/src/components/deprecated/Form.stories.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/FormInput.d.ts +0 -16
- package/dist/types/src/components/deprecated/FormInput.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/index.d.ts +0 -2
- package/dist/types/src/components/deprecated/index.d.ts.map +0 -1
- package/src/components/deprecated/Form.stories.tsx +0 -62
- package/src/components/deprecated/Form.tsx +0 -119
- package/src/components/deprecated/FormInput.tsx +0 -71
- package/src/components/deprecated/index.ts +0 -5
|
@@ -18,6 +18,12 @@ var translations = [
|
|
|
18
18
|
"field limit reached": "Maximum number of fields reached",
|
|
19
19
|
"boolean input true value": "Yes",
|
|
20
20
|
"boolean input false value": "No",
|
|
21
|
+
"show field label": "Show field",
|
|
22
|
+
"hide field label": "Hide field",
|
|
23
|
+
"delete field label": "Delete field",
|
|
24
|
+
"ref field combobox input placeholder": "Search\u2026",
|
|
25
|
+
"ref field placeholder_one": "Select\u2026",
|
|
26
|
+
"ref field placeholder_other": "Select items\u2026",
|
|
21
27
|
// TODO(burdon): Factor out?
|
|
22
28
|
"button cancel": "Cancel",
|
|
23
29
|
"button save": "Save",
|
|
@@ -34,7 +40,7 @@ var translations = [
|
|
|
34
40
|
"format hostname": "Hostname",
|
|
35
41
|
"format integer": "Integer",
|
|
36
42
|
"format json": "JSON",
|
|
37
|
-
"format
|
|
43
|
+
"format lnglat": "Geopoint",
|
|
38
44
|
"format markdown": "Markdown",
|
|
39
45
|
"format percent": "Percent",
|
|
40
46
|
"format ref": "Reference",
|
|
@@ -50,9 +56,9 @@ var translations = [
|
|
|
50
56
|
"format uri": "URI",
|
|
51
57
|
"format url": "URL",
|
|
52
58
|
"format uuid": "UUID",
|
|
53
|
-
//
|
|
54
|
-
"
|
|
55
|
-
"
|
|
59
|
+
// GeoPointInput.
|
|
60
|
+
"latitude label": "Latitude",
|
|
61
|
+
"longitude label": "Longitude",
|
|
56
62
|
// SelectOptionsInput.
|
|
57
63
|
"select option label": "Label",
|
|
58
64
|
"select option label placeholder": "Option label",
|
|
@@ -60,86 +66,38 @@ var translations = [
|
|
|
60
66
|
"select option delete": "Delete",
|
|
61
67
|
"select option add": "Add option",
|
|
62
68
|
// System schema message.
|
|
63
|
-
"system schema title": "System
|
|
64
|
-
"system schema description": "This is a system
|
|
69
|
+
"system schema title": "System record type",
|
|
70
|
+
"system schema description": "This is a system record type and cannot be modified, though the view can still be configured."
|
|
65
71
|
}
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
];
|
|
69
75
|
|
|
70
|
-
// src/components/
|
|
76
|
+
// src/components/ControlSection/ControlSection.tsx
|
|
71
77
|
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
72
78
|
import React from "react";
|
|
73
|
-
import { Input } from "@dxos/react-ui";
|
|
74
|
-
import {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
79
|
-
role: "none",
|
|
80
|
-
className: "container-max-width p-4 justify-center overflow-x-hidden overflow-y-auto"
|
|
81
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
82
|
-
role: "form",
|
|
83
|
-
className: mx("flex flex-col", textBlockWidth, classNames)
|
|
84
|
-
}, children));
|
|
85
|
-
} finally {
|
|
86
|
-
_effect.f();
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
var DeprecatedFormInput = ({ label, description, secondary, children }) => {
|
|
79
|
+
import { Button, Input, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
80
|
+
import { StackItem } from "@dxos/react-ui-stack";
|
|
81
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
82
|
+
var ControlPage = ({ children, classNames, ...props }) => {
|
|
90
83
|
var _effect = _useSignals();
|
|
91
84
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
|
|
96
|
-
role: "none",
|
|
97
|
-
className: "flex flex-col w-full"
|
|
98
|
-
}, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
99
|
-
classNames: "flex min-bs-[--rail-action] items-center",
|
|
100
|
-
style: {
|
|
101
|
-
fontSize: "unset"
|
|
102
|
-
}
|
|
103
|
-
}, label), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, {
|
|
104
|
-
classNames: "mbs-0.5"
|
|
105
|
-
}, /* @__PURE__ */ React.createElement(Input.Description, null, description))), /* @__PURE__ */ React.createElement("div", {
|
|
106
|
-
role: "none"
|
|
85
|
+
return /* @__PURE__ */ React.createElement(StackItem.Content, {
|
|
86
|
+
scrollable: true,
|
|
87
|
+
classNames: "[--control-spacing:var(--dx-trimMd)]"
|
|
107
88
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
108
89
|
role: "none",
|
|
109
|
-
className: "
|
|
110
|
-
}, children))));
|
|
111
|
-
if (secondary) {
|
|
112
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
113
|
-
role: "none"
|
|
114
|
-
}, primary, secondary);
|
|
115
|
-
}
|
|
116
|
-
return primary;
|
|
117
|
-
} finally {
|
|
118
|
-
_effect.f();
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
// src/components/ControlSection/ControlSection.tsx
|
|
123
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
124
|
-
import React2 from "react";
|
|
125
|
-
import { Button, Input as Input2, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
126
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
127
|
-
var ControlPage = ({ children, classNames, ...props }) => {
|
|
128
|
-
var _effect = _useSignals2();
|
|
129
|
-
try {
|
|
130
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
131
|
-
role: "none",
|
|
132
|
-
className: mx2("pli-cardSpacingInline", classNames),
|
|
90
|
+
className: mx("pli-cardSpacingInline pbe-trimLg", classNames),
|
|
133
91
|
...props
|
|
134
|
-
}, children);
|
|
92
|
+
}, children));
|
|
135
93
|
} finally {
|
|
136
94
|
_effect.f();
|
|
137
95
|
}
|
|
138
96
|
};
|
|
139
97
|
var ControlSection = ({ title, description, children }) => {
|
|
140
|
-
var _effect =
|
|
98
|
+
var _effect = _useSignals();
|
|
141
99
|
try {
|
|
142
|
-
return /* @__PURE__ */
|
|
100
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ControlSectionHeading, {
|
|
143
101
|
title,
|
|
144
102
|
description
|
|
145
103
|
}), children);
|
|
@@ -148,12 +106,12 @@ var ControlSection = ({ title, description, children }) => {
|
|
|
148
106
|
}
|
|
149
107
|
};
|
|
150
108
|
var ControlSectionHeading = ({ title, description }) => {
|
|
151
|
-
var _effect =
|
|
109
|
+
var _effect = _useSignals();
|
|
152
110
|
try {
|
|
153
111
|
const { t } = useTranslation(translationKey);
|
|
154
|
-
return /* @__PURE__ */
|
|
112
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", {
|
|
155
113
|
className: "pli-trimMd container-max-width text-xl mbs-trimLg mbe-trimMd"
|
|
156
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */
|
|
114
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
157
115
|
className: "pli-trimMd mlb-trimMd container-max-width text-description"
|
|
158
116
|
}, toLocalizedString(description, t)));
|
|
159
117
|
} finally {
|
|
@@ -161,9 +119,9 @@ var ControlSectionHeading = ({ title, description }) => {
|
|
|
161
119
|
}
|
|
162
120
|
};
|
|
163
121
|
var ControlGroupButton = ({ classNames, ...props }) => {
|
|
164
|
-
var _effect =
|
|
122
|
+
var _effect = _useSignals();
|
|
165
123
|
try {
|
|
166
|
-
return /* @__PURE__ */
|
|
124
|
+
return /* @__PURE__ */ React.createElement(Button, {
|
|
167
125
|
...props,
|
|
168
126
|
classNames: [
|
|
169
127
|
"md:col-span-2",
|
|
@@ -175,41 +133,46 @@ var ControlGroupButton = ({ classNames, ...props }) => {
|
|
|
175
133
|
}
|
|
176
134
|
};
|
|
177
135
|
var ControlGroup = ({ children, classNames }) => {
|
|
178
|
-
var _effect =
|
|
136
|
+
var _effect = _useSignals();
|
|
179
137
|
try {
|
|
180
|
-
return /* @__PURE__ */
|
|
138
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
181
139
|
role: "none",
|
|
182
|
-
className:
|
|
140
|
+
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)
|
|
183
141
|
}, children);
|
|
184
142
|
} finally {
|
|
185
143
|
_effect.f();
|
|
186
144
|
}
|
|
187
145
|
};
|
|
188
146
|
var ControlFrame = ({ children }) => {
|
|
189
|
-
var _effect =
|
|
147
|
+
var _effect = _useSignals();
|
|
190
148
|
try {
|
|
191
|
-
return /* @__PURE__ */
|
|
149
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
192
150
|
role: "none",
|
|
193
|
-
className: "
|
|
151
|
+
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")
|
|
194
152
|
}, children);
|
|
195
153
|
} finally {
|
|
196
154
|
_effect.f();
|
|
197
155
|
}
|
|
198
156
|
};
|
|
199
|
-
var controlItemClasses =
|
|
200
|
-
|
|
201
|
-
|
|
157
|
+
var controlItemClasses = mx([
|
|
158
|
+
"container-max-width grid md:col-span-2 grid-cols-subgrid gap-trimSm items-center",
|
|
159
|
+
// TODO(burdon): Use grid gap consistently or apply margins consistently?
|
|
160
|
+
"mlb-[--control-spacing] *:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd",
|
|
161
|
+
"border border-separator rounded-md"
|
|
162
|
+
]);
|
|
163
|
+
var controlItemTitleClasses = "mbe-0 text-lg text-baseText font-normal";
|
|
164
|
+
var controlItemDescriptionClasses = "mlb-trimSm md:mbe-0 text-base text-description";
|
|
202
165
|
var ControlItem = ({ title, description, children }) => {
|
|
203
|
-
var _effect =
|
|
166
|
+
var _effect = _useSignals();
|
|
204
167
|
try {
|
|
205
168
|
const { t } = useTranslation(translationKey);
|
|
206
|
-
return /* @__PURE__ */
|
|
169
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
207
170
|
className: controlItemClasses
|
|
208
|
-
}, /* @__PURE__ */
|
|
171
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
209
172
|
role: "none"
|
|
210
|
-
}, /* @__PURE__ */
|
|
173
|
+
}, /* @__PURE__ */ React.createElement("h3", {
|
|
211
174
|
className: controlItemTitleClasses
|
|
212
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */
|
|
175
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
213
176
|
className: controlItemDescriptionClasses
|
|
214
177
|
}, toLocalizedString(description, t))), children);
|
|
215
178
|
} finally {
|
|
@@ -217,16 +180,16 @@ var ControlItem = ({ title, description, children }) => {
|
|
|
217
180
|
}
|
|
218
181
|
};
|
|
219
182
|
var ControlItemInput = ({ title, description, children }) => {
|
|
220
|
-
var _effect =
|
|
183
|
+
var _effect = _useSignals();
|
|
221
184
|
try {
|
|
222
185
|
const { t } = useTranslation(translationKey);
|
|
223
|
-
return /* @__PURE__ */
|
|
186
|
+
return /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
|
|
224
187
|
className: controlItemClasses
|
|
225
|
-
}, /* @__PURE__ */
|
|
188
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
226
189
|
role: "none"
|
|
227
|
-
}, /* @__PURE__ */
|
|
190
|
+
}, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
228
191
|
classNames: controlItemTitleClasses
|
|
229
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */
|
|
192
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Description, {
|
|
230
193
|
classNames: controlItemDescriptionClasses
|
|
231
194
|
}, toLocalizedString(description, t)))), children));
|
|
232
195
|
} finally {
|
|
@@ -234,15 +197,15 @@ var ControlItemInput = ({ title, description, children }) => {
|
|
|
234
197
|
}
|
|
235
198
|
};
|
|
236
199
|
var ControlFrameItem = ({ title, description, children }) => {
|
|
237
|
-
var _effect =
|
|
200
|
+
var _effect = _useSignals();
|
|
238
201
|
try {
|
|
239
202
|
const { t } = useTranslation(translationKey);
|
|
240
|
-
return /* @__PURE__ */
|
|
203
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
241
204
|
role: "group",
|
|
242
205
|
className: "min-is-0"
|
|
243
|
-
}, /* @__PURE__ */
|
|
206
|
+
}, /* @__PURE__ */ React.createElement("h3", {
|
|
244
207
|
className: "text-lg mbe-2"
|
|
245
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */
|
|
208
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
246
209
|
className: "mlb-trimSm md:mbe-0 text-description"
|
|
247
210
|
}, toLocalizedString(description, t)), children);
|
|
248
211
|
} finally {
|
|
@@ -252,40 +215,40 @@ var ControlFrameItem = ({ title, description, children }) => {
|
|
|
252
215
|
|
|
253
216
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
254
217
|
import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
|
|
255
|
-
import React14, { useCallback as
|
|
256
|
-
import { FormatEnum as FormatEnum5, FormatEnums, formatToType } from "@dxos/echo
|
|
218
|
+
import React14, { useCallback as useCallback11, useEffect as useEffect8, useMemo as useMemo7, useState as useState6 } from "react";
|
|
219
|
+
import { FormatEnum as FormatEnum5, FormatEnums, formatToType } from "@dxos/echo/internal";
|
|
257
220
|
import { log as log3 } from "@dxos/log";
|
|
258
|
-
import { useTranslation as
|
|
259
|
-
import { getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
|
|
221
|
+
import { useAsyncEffect, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
222
|
+
import { formatToAdditionalPropertyAttributes, getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
|
|
260
223
|
|
|
261
224
|
// src/components/Form/custom/GeoPointInput.tsx
|
|
262
|
-
import { useSignals as
|
|
263
|
-
import
|
|
264
|
-
import { GeoLocation } from "@dxos/echo
|
|
265
|
-
import { Input as
|
|
225
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
226
|
+
import React3, { useCallback, useEffect, useMemo, useState } from "react";
|
|
227
|
+
import { GeoLocation } from "@dxos/echo/internal";
|
|
228
|
+
import { Input as Input3, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
266
229
|
import { safeParseFloat } from "@dxos/util";
|
|
267
230
|
|
|
268
231
|
// src/components/Form/Input.tsx
|
|
269
|
-
import { useSignals as
|
|
270
|
-
import
|
|
271
|
-
import { Icon, Input as
|
|
232
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
233
|
+
import React2 from "react";
|
|
234
|
+
import { Icon, Input as Input2, Tooltip } from "@dxos/react-ui";
|
|
272
235
|
import { labelSpacing } from "@dxos/react-ui-stack";
|
|
273
|
-
import { errorText, mx as
|
|
236
|
+
import { errorText, mx as mx2 } from "@dxos/react-ui-theme";
|
|
274
237
|
var InputHeader = ({ error, label, readonly }) => {
|
|
275
|
-
var _effect =
|
|
238
|
+
var _effect = _useSignals2();
|
|
276
239
|
try {
|
|
277
|
-
const Label = readonly ? "span" :
|
|
240
|
+
const Label = readonly ? "span" : Input2.Label;
|
|
278
241
|
const labelProps = readonly ? {} : {
|
|
279
242
|
classNames: "!mlb-0"
|
|
280
243
|
};
|
|
281
|
-
return /* @__PURE__ */
|
|
244
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
282
245
|
role: "none",
|
|
283
|
-
className:
|
|
284
|
-
}, /* @__PURE__ */
|
|
246
|
+
className: mx2("flex justify-between items-center", labelSpacing)
|
|
247
|
+
}, /* @__PURE__ */ React2.createElement(Label, labelProps, label), error && /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
|
|
285
248
|
asChild: true,
|
|
286
249
|
content: error,
|
|
287
250
|
side: "bottom"
|
|
288
|
-
}, /* @__PURE__ */
|
|
251
|
+
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
289
252
|
icon: "ph--warning--regular",
|
|
290
253
|
size: 4,
|
|
291
254
|
classNames: errorText
|
|
@@ -296,8 +259,8 @@ var InputHeader = ({ error, label, readonly }) => {
|
|
|
296
259
|
};
|
|
297
260
|
|
|
298
261
|
// src/components/Form/custom/GeoPointInput.tsx
|
|
299
|
-
var GeoPointInput = ({ type, label,
|
|
300
|
-
var _effect =
|
|
262
|
+
var GeoPointInput = ({ type, label, readonly, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
263
|
+
var _effect = _useSignals3();
|
|
301
264
|
try {
|
|
302
265
|
const { t } = useTranslation2(translationKey);
|
|
303
266
|
const { status, error } = getStatus();
|
|
@@ -342,46 +305,52 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
342
305
|
onValueChange,
|
|
343
306
|
type
|
|
344
307
|
]);
|
|
345
|
-
return /* @__PURE__ */
|
|
308
|
+
return /* @__PURE__ */ React3.createElement(Input3.Root, {
|
|
346
309
|
validationValence: status
|
|
347
|
-
}, /* @__PURE__ */
|
|
310
|
+
}, /* @__PURE__ */ React3.createElement(InputHeader, {
|
|
348
311
|
error,
|
|
349
312
|
label
|
|
350
|
-
}), /* @__PURE__ */
|
|
313
|
+
}), /* @__PURE__ */ React3.createElement("div", {
|
|
351
314
|
role: "none",
|
|
352
315
|
className: "grid grid-cols-2 gap-2"
|
|
353
|
-
}, /* @__PURE__ */
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
316
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
317
|
+
role: "none"
|
|
318
|
+
}, /* @__PURE__ */ React3.createElement(Input3.Label, null, t("latitude label")), /* @__PURE__ */ React3.createElement(Input3.TextInput, {
|
|
319
|
+
type: "number",
|
|
320
|
+
step: "0.00001",
|
|
321
|
+
min: "-90",
|
|
322
|
+
max: "90",
|
|
323
|
+
disabled: !!readonly,
|
|
358
324
|
value: latitudeText,
|
|
359
325
|
onChange: handleCoordinateChange("latitude", setLatitudeText),
|
|
360
326
|
onBlur
|
|
361
|
-
}), /* @__PURE__ */
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
327
|
+
})), /* @__PURE__ */ React3.createElement("div", {
|
|
328
|
+
role: "none"
|
|
329
|
+
}, /* @__PURE__ */ React3.createElement(Input3.Label, null, t("longitude label")), /* @__PURE__ */ React3.createElement(Input3.TextInput, {
|
|
330
|
+
type: "number",
|
|
331
|
+
step: "0.00001",
|
|
332
|
+
min: "-180",
|
|
333
|
+
max: "180",
|
|
334
|
+
disabled: !!readonly,
|
|
366
335
|
value: longitudeText,
|
|
367
336
|
onChange: handleCoordinateChange("longitude", setLongitudeText),
|
|
368
337
|
onBlur
|
|
369
|
-
})));
|
|
338
|
+
}))));
|
|
370
339
|
} finally {
|
|
371
340
|
_effect.f();
|
|
372
341
|
}
|
|
373
342
|
};
|
|
374
343
|
|
|
375
344
|
// src/components/Form/custom/SelectOptionsInput.tsx
|
|
376
|
-
import { useSignals as
|
|
377
|
-
import
|
|
345
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
346
|
+
import React4, { useCallback as useCallback2, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
378
347
|
import { PublicKey } from "@dxos/keys";
|
|
379
|
-
import {
|
|
348
|
+
import { IconButton, Input as Input4, Tag, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
380
349
|
import { List } from "@dxos/react-ui-list";
|
|
381
350
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
382
|
-
import { hues,
|
|
383
|
-
var SelectOptionInput = ({ type, label,
|
|
384
|
-
var _effect =
|
|
351
|
+
import { hues, subtleHover } from "@dxos/react-ui-theme";
|
|
352
|
+
var SelectOptionInput = ({ type, label, readonly, getStatus, getValue: getValue3, onValueChange }) => {
|
|
353
|
+
var _effect = _useSignals4();
|
|
385
354
|
try {
|
|
386
355
|
const [selected, setSelectedId] = useState2(null);
|
|
387
356
|
const [isNewOption, setIsNewOption] = useState2(false);
|
|
@@ -489,49 +458,56 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
489
458
|
selected,
|
|
490
459
|
isNewOption
|
|
491
460
|
]);
|
|
492
|
-
return /* @__PURE__ */
|
|
461
|
+
return /* @__PURE__ */ React4.createElement(Input4.Root, {
|
|
493
462
|
validationValence: status
|
|
494
|
-
}, /* @__PURE__ */
|
|
463
|
+
}, /* @__PURE__ */ React4.createElement(InputHeader, {
|
|
495
464
|
error,
|
|
496
465
|
label
|
|
497
|
-
}), /* @__PURE__ */
|
|
466
|
+
}), /* @__PURE__ */ React4.createElement("div", {
|
|
498
467
|
role: "none"
|
|
499
|
-
}, options && /* @__PURE__ */
|
|
468
|
+
}, options && /* @__PURE__ */ React4.createElement(List.Root, {
|
|
500
469
|
items: options,
|
|
501
470
|
isItem: (item) => true,
|
|
502
|
-
onMove: handleMove
|
|
503
|
-
|
|
471
|
+
onMove: readonly ? void 0 : handleMove,
|
|
472
|
+
readonly: !!readonly
|
|
473
|
+
}, ({ items }) => /* @__PURE__ */ React4.createElement("div", {
|
|
504
474
|
role: "list",
|
|
505
475
|
className: "w-full overflow-auto"
|
|
506
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
476
|
+
}, items?.map((item) => /* @__PURE__ */ React4.createElement("div", {
|
|
507
477
|
key: item.id
|
|
508
|
-
}, /* @__PURE__ */
|
|
478
|
+
}, /* @__PURE__ */ React4.createElement(List.Item, {
|
|
509
479
|
role: "button",
|
|
510
480
|
item,
|
|
511
481
|
classNames: [
|
|
512
|
-
|
|
513
|
-
"flex flex-col"
|
|
514
|
-
"cursor-pointer",
|
|
515
|
-
"hover:bg-hoverOverlay"
|
|
482
|
+
subtleHover,
|
|
483
|
+
"flex flex-col cursor-pointer rounded-sm"
|
|
516
484
|
],
|
|
517
485
|
"aria-expanded": selected === item.id
|
|
518
|
-
}, /* @__PURE__ */
|
|
486
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
519
487
|
className: "flex items-center"
|
|
520
|
-
}, /* @__PURE__ */
|
|
488
|
+
}, /* @__PURE__ */ React4.createElement(List.ItemDragHandle, {
|
|
489
|
+
disabled: !!readonly
|
|
490
|
+
}), /* @__PURE__ */ React4.createElement(List.ItemTitle, {
|
|
521
491
|
onClick: () => handleClick(item.id),
|
|
522
492
|
classNames: "flex-1"
|
|
523
|
-
}, /* @__PURE__ */
|
|
493
|
+
}, /* @__PURE__ */ React4.createElement(Tag, {
|
|
524
494
|
palette: item.color
|
|
525
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
495
|
+
}, item.title || "\u200B")), /* @__PURE__ */ React4.createElement(IconButton, {
|
|
496
|
+
iconOnly: true,
|
|
497
|
+
variant: "ghost",
|
|
498
|
+
label: t(selected === item.id ? "collapse label" : "expand label", {
|
|
499
|
+
ns: "os"
|
|
500
|
+
}),
|
|
526
501
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
527
502
|
onClick: () => handleClick(item.id)
|
|
528
|
-
})), selected === item.id && /* @__PURE__ */
|
|
529
|
-
className: "
|
|
530
|
-
}, /* @__PURE__ */
|
|
503
|
+
})), selected === item.id && /* @__PURE__ */ React4.createElement("div", {
|
|
504
|
+
className: "pli-cardSpacingInline plb-cardSpacingBlock flex flex-col gap-1 density-fine"
|
|
505
|
+
}, /* @__PURE__ */ React4.createElement(Input4.Label, {
|
|
531
506
|
classNames: "text-xs"
|
|
532
|
-
}, t("select option label")), /* @__PURE__ */
|
|
533
|
-
className: "
|
|
534
|
-
}, /* @__PURE__ */
|
|
507
|
+
}, t("select option label")), /* @__PURE__ */ React4.createElement("div", {
|
|
508
|
+
className: "grid grid-cols-[1fr_min-content_min-content] gap-1"
|
|
509
|
+
}, /* @__PURE__ */ React4.createElement(Input4.TextInput, {
|
|
510
|
+
disabled: !!readonly,
|
|
535
511
|
placeholder: t("select option label placeholder"),
|
|
536
512
|
ref: selected === item.id ? inputRef : void 0,
|
|
537
513
|
value: item.title,
|
|
@@ -539,40 +515,34 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
539
515
|
onKeyDown: handleKeyDown,
|
|
540
516
|
classNames: "flex-1",
|
|
541
517
|
"data-no-submit": true
|
|
542
|
-
}), /* @__PURE__ */
|
|
543
|
-
|
|
544
|
-
}, /* @__PURE__ */ React5.createElement(HuePicker, {
|
|
518
|
+
}), /* @__PURE__ */ React4.createElement(HuePicker, {
|
|
519
|
+
disabled: !!readonly,
|
|
545
520
|
value: item.color,
|
|
546
|
-
onChange: handleColorChange(item.id)
|
|
547
|
-
|
|
548
|
-
|
|
521
|
+
onChange: handleColorChange(item.id)
|
|
522
|
+
}), /* @__PURE__ */ React4.createElement(IconButton, {
|
|
523
|
+
disabled: !!readonly,
|
|
549
524
|
icon: "ph--trash--fill",
|
|
550
525
|
iconOnly: true,
|
|
551
526
|
label: t("select option delete"),
|
|
552
527
|
onClick: () => handleDelete(item.id)
|
|
553
|
-
})))))), /* @__PURE__ */
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}, /* @__PURE__ */ React5.createElement(Icon2, {
|
|
562
|
-
icon: "ph--plus--regular"
|
|
563
|
-
}), /* @__PURE__ */ React5.createElement("span", {
|
|
564
|
-
className: "text-sm"
|
|
565
|
-
}, t("select option add")))))))));
|
|
528
|
+
})))))), /* @__PURE__ */ React4.createElement(IconButton, {
|
|
529
|
+
variant: "ghost",
|
|
530
|
+
icon: "ph--plus--regular",
|
|
531
|
+
label: t("select option add"),
|
|
532
|
+
onClick: handleAdd,
|
|
533
|
+
disabled: !!readonly,
|
|
534
|
+
classNames: "is-full"
|
|
535
|
+
})))));
|
|
566
536
|
} finally {
|
|
567
537
|
_effect.f();
|
|
568
538
|
}
|
|
569
539
|
};
|
|
570
540
|
|
|
571
541
|
// src/components/Form/custom/TupleInput.tsx
|
|
572
|
-
import { useSignals as
|
|
573
|
-
import
|
|
574
|
-
import { Input as
|
|
575
|
-
import { mx as
|
|
542
|
+
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
543
|
+
import React5 from "react";
|
|
544
|
+
import { Input as Input5 } from "@dxos/react-ui";
|
|
545
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
576
546
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
577
547
|
var gridCols = [
|
|
578
548
|
"grid-cols-1",
|
|
@@ -580,22 +550,22 @@ var gridCols = [
|
|
|
580
550
|
"grid-cols-3",
|
|
581
551
|
"grid-cols-4"
|
|
582
552
|
];
|
|
583
|
-
var TupleInput = ({ binding, type, label,
|
|
584
|
-
var _effect =
|
|
553
|
+
var TupleInput = ({ binding, type, label, readonly, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
554
|
+
var _effect = _useSignals5();
|
|
585
555
|
try {
|
|
586
556
|
const { status, error } = getStatus();
|
|
587
557
|
const values = getValue3() ?? {};
|
|
588
|
-
return /* @__PURE__ */
|
|
558
|
+
return /* @__PURE__ */ React5.createElement(Input5.Root, {
|
|
589
559
|
validationValence: status
|
|
590
|
-
}, /* @__PURE__ */
|
|
560
|
+
}, /* @__PURE__ */ React5.createElement(InputHeader, {
|
|
591
561
|
error,
|
|
592
562
|
label
|
|
593
|
-
}), /* @__PURE__ */
|
|
594
|
-
className:
|
|
595
|
-
}, binding.map((prop) => /* @__PURE__ */
|
|
563
|
+
}), /* @__PURE__ */ React5.createElement("div", {
|
|
564
|
+
className: mx3("grid gap-2", gridCols[binding.length - 1])
|
|
565
|
+
}, binding.map((prop) => /* @__PURE__ */ React5.createElement(Input5.TextInput, {
|
|
596
566
|
key: prop,
|
|
597
567
|
type: "number",
|
|
598
|
-
disabled,
|
|
568
|
+
disabled: !!readonly,
|
|
599
569
|
value: values[prop],
|
|
600
570
|
onChange: (event) => onValueChange(type, {
|
|
601
571
|
...values,
|
|
@@ -609,103 +579,104 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
|
|
|
609
579
|
};
|
|
610
580
|
|
|
611
581
|
// src/components/Form/Defaults.tsx
|
|
612
|
-
import { useSignals as
|
|
613
|
-
import
|
|
614
|
-
import { Input as
|
|
615
|
-
var TextInput = ({ type, label, inputOnly,
|
|
616
|
-
var _effect =
|
|
582
|
+
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
583
|
+
import React6, { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
584
|
+
import { Input as Input6, Select, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
585
|
+
var TextInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
586
|
+
var _effect = _useSignals6();
|
|
617
587
|
try {
|
|
618
588
|
const { status, error } = getStatus();
|
|
619
|
-
return
|
|
589
|
+
return readonly && !getValue3() ? null : readonly === "static" && inputOnly ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
620
590
|
validationValence: status
|
|
621
|
-
}, !inputOnly && /* @__PURE__ */
|
|
591
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
622
592
|
error,
|
|
623
593
|
label
|
|
624
|
-
}),
|
|
625
|
-
disabled,
|
|
594
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextInput, {
|
|
595
|
+
disabled: !!readonly,
|
|
626
596
|
placeholder,
|
|
627
597
|
value: getValue3() ?? "",
|
|
628
598
|
onChange: (event) => onValueChange(type, event.target.value),
|
|
629
599
|
onBlur
|
|
630
|
-
}), inputOnly && /* @__PURE__ */
|
|
600
|
+
}), inputOnly && /* @__PURE__ */ React6.createElement(Input6.Validation, null, error));
|
|
631
601
|
} finally {
|
|
632
602
|
_effect.f();
|
|
633
603
|
}
|
|
634
604
|
};
|
|
635
|
-
var NumberInput = ({ type, label, inputOnly,
|
|
636
|
-
var _effect =
|
|
605
|
+
var NumberInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
606
|
+
var _effect = _useSignals6();
|
|
637
607
|
try {
|
|
638
608
|
const { status, error } = getStatus();
|
|
639
|
-
return
|
|
609
|
+
return readonly && !getValue3() ? null : readonly === "static" && inputOnly ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
640
610
|
validationValence: status
|
|
641
|
-
}, !inputOnly && /* @__PURE__ */
|
|
611
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
642
612
|
error,
|
|
643
613
|
label
|
|
644
|
-
}),
|
|
614
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextInput, {
|
|
645
615
|
type: "number",
|
|
646
|
-
disabled,
|
|
616
|
+
disabled: !!readonly,
|
|
647
617
|
placeholder,
|
|
648
|
-
value: getValue3()
|
|
618
|
+
value: getValue3(),
|
|
649
619
|
onChange: (event) => onValueChange(type, event.target.value),
|
|
650
620
|
onBlur
|
|
651
|
-
}), inputOnly && /* @__PURE__ */
|
|
621
|
+
}), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
|
|
652
622
|
} finally {
|
|
653
623
|
_effect.f();
|
|
654
624
|
}
|
|
655
625
|
};
|
|
656
|
-
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange,
|
|
657
|
-
var _effect =
|
|
626
|
+
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange, readonly }) => {
|
|
627
|
+
var _effect = _useSignals6();
|
|
658
628
|
try {
|
|
659
629
|
const { status, error } = getStatus();
|
|
660
630
|
const checked = Boolean(getValue3());
|
|
661
631
|
const { t } = useTranslation4(translationKey);
|
|
662
|
-
return /* @__PURE__ */
|
|
632
|
+
return /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
663
633
|
validationValence: status
|
|
664
|
-
}, !inputOnly && /* @__PURE__ */
|
|
634
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
665
635
|
error,
|
|
666
636
|
label
|
|
667
|
-
}),
|
|
637
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ React6.createElement(Input6.Switch, {
|
|
638
|
+
disabled: !!readonly,
|
|
668
639
|
checked,
|
|
669
|
-
onCheckedChange: (
|
|
670
|
-
}), inputOnly && /* @__PURE__ */
|
|
640
|
+
onCheckedChange: (value2) => onValueChange(type, value2)
|
|
641
|
+
}), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
|
|
671
642
|
} finally {
|
|
672
643
|
_effect.f();
|
|
673
644
|
}
|
|
674
645
|
};
|
|
675
|
-
var SelectInput = ({ type, label, inputOnly,
|
|
676
|
-
var _effect =
|
|
646
|
+
var SelectInput = ({ type, label, inputOnly, readonly, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
647
|
+
var _effect = _useSignals6();
|
|
677
648
|
try {
|
|
678
649
|
const { status, error } = getStatus();
|
|
679
|
-
const
|
|
680
|
-
const handleValueChange = useCallback3((
|
|
650
|
+
const value2 = getValue3();
|
|
651
|
+
const handleValueChange = useCallback3((value3) => onValueChange(type, value3), [
|
|
681
652
|
type,
|
|
682
653
|
onValueChange
|
|
683
654
|
]);
|
|
684
|
-
return
|
|
655
|
+
return readonly && !value2 ? null : /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
685
656
|
validationValence: status
|
|
686
|
-
}, !inputOnly && /* @__PURE__ */
|
|
657
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
687
658
|
error,
|
|
688
659
|
label
|
|
689
|
-
}),
|
|
690
|
-
value,
|
|
660
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value2)?.label ?? String(value2)) : /* @__PURE__ */ React6.createElement(Select.Root, {
|
|
661
|
+
value: value2,
|
|
691
662
|
onValueChange: handleValueChange
|
|
692
|
-
}, /* @__PURE__ */
|
|
663
|
+
}, /* @__PURE__ */ React6.createElement(Select.TriggerButton, {
|
|
693
664
|
classNames: "is-full",
|
|
694
|
-
disabled,
|
|
665
|
+
disabled: !!readonly,
|
|
695
666
|
placeholder
|
|
696
|
-
}), /* @__PURE__ */
|
|
667
|
+
}), /* @__PURE__ */ React6.createElement(Select.Portal, null, /* @__PURE__ */ React6.createElement(Select.Content, null, /* @__PURE__ */ React6.createElement(Select.Viewport, null, options?.map(({ value: value3, label: label2 }) => (
|
|
697
668
|
// NOTE: Numeric values are converted to and from strings.
|
|
698
|
-
/* @__PURE__ */
|
|
699
|
-
key: String(
|
|
700
|
-
value: String(
|
|
701
|
-
}, label2 ?? String(
|
|
702
|
-
)))))), inputOnly && /* @__PURE__ */
|
|
669
|
+
/* @__PURE__ */ React6.createElement(Select.Option, {
|
|
670
|
+
key: String(value3),
|
|
671
|
+
value: String(value3)
|
|
672
|
+
}, label2 ?? String(value3))
|
|
673
|
+
))), /* @__PURE__ */ React6.createElement(Select.Arrow, null)))), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
|
|
703
674
|
} finally {
|
|
704
675
|
_effect.f();
|
|
705
676
|
}
|
|
706
677
|
};
|
|
707
|
-
var MarkdownInput = ({ type, label, inputOnly,
|
|
708
|
-
var _effect =
|
|
678
|
+
var MarkdownInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
679
|
+
var _effect = _useSignals6();
|
|
709
680
|
try {
|
|
710
681
|
const { status, error } = getStatus();
|
|
711
682
|
const textareaRef = useRef2(null);
|
|
@@ -727,14 +698,14 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
727
698
|
getValue3(),
|
|
728
699
|
adjustHeight
|
|
729
700
|
]);
|
|
730
|
-
return /* @__PURE__ */
|
|
701
|
+
return /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
731
702
|
validationValence: status
|
|
732
|
-
}, !inputOnly && /* @__PURE__ */
|
|
703
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
733
704
|
error,
|
|
734
705
|
label
|
|
735
|
-
}),
|
|
706
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextArea, {
|
|
736
707
|
ref: textareaRef,
|
|
737
|
-
disabled,
|
|
708
|
+
disabled: !!readonly,
|
|
738
709
|
placeholder,
|
|
739
710
|
value: getValue3() ?? "",
|
|
740
711
|
classNames: "min-bs-auto max-h-40 overflow-auto",
|
|
@@ -744,7 +715,7 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
744
715
|
resize: "none"
|
|
745
716
|
},
|
|
746
717
|
spellCheck: false
|
|
747
|
-
}), inputOnly && /* @__PURE__ */
|
|
718
|
+
}), inputOnly && /* @__PURE__ */ React6.createElement(Input6.Validation, null, error));
|
|
748
719
|
} finally {
|
|
749
720
|
_effect.f();
|
|
750
721
|
}
|
|
@@ -752,27 +723,28 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
752
723
|
|
|
753
724
|
// src/components/Form/Form.tsx
|
|
754
725
|
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
755
|
-
import
|
|
726
|
+
import { useFocusFinders } from "@fluentui/react-tabster";
|
|
727
|
+
import React13, { useCallback as useCallback10, useEffect as useEffect7, useRef as useRef3 } from "react";
|
|
756
728
|
import { cardDialogOverflow, cardSpacing as cardSpacing2 } from "@dxos/react-ui-stack";
|
|
757
729
|
|
|
758
730
|
// src/components/Form/FormActions.tsx
|
|
759
|
-
import { useSignals as
|
|
760
|
-
import
|
|
731
|
+
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
732
|
+
import React8 from "react";
|
|
761
733
|
import { IconButton as IconButton2, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
762
734
|
import { cardSpacing } from "@dxos/react-ui-stack";
|
|
763
|
-
import { mx as
|
|
735
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
764
736
|
|
|
765
737
|
// src/components/Form/FormContext.tsx
|
|
766
|
-
import { useSignals as
|
|
767
|
-
import
|
|
738
|
+
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
739
|
+
import React7, { createContext, useCallback as useCallback6, useContext, useEffect as useEffect6, useMemo as useMemo3 } from "react";
|
|
768
740
|
import { raise } from "@dxos/debug";
|
|
769
|
-
import { getValue as getValue2 } from "@dxos/echo
|
|
741
|
+
import { getValue as getValue2 } from "@dxos/echo/internal";
|
|
770
742
|
import { createJsonPath as createJsonPath2 } from "@dxos/effect";
|
|
771
743
|
|
|
772
744
|
// src/hooks/useForm.ts
|
|
773
|
-
import
|
|
745
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
774
746
|
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo2, useState as useState3 } from "react";
|
|
775
|
-
import { getValue, setValue } from "@dxos/echo
|
|
747
|
+
import { getValue, setValue } from "@dxos/echo/internal";
|
|
776
748
|
import { createJsonPath, fromEffectValidationPath } from "@dxos/effect";
|
|
777
749
|
import { invariant } from "@dxos/invariant";
|
|
778
750
|
import { log } from "@dxos/log";
|
|
@@ -781,7 +753,7 @@ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.t
|
|
|
781
753
|
var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
|
|
782
754
|
invariant(SchemaAST.isTypeLiteral(schema.ast), void 0, {
|
|
783
755
|
F: __dxlog_file,
|
|
784
|
-
L:
|
|
756
|
+
L: 96,
|
|
785
757
|
S: void 0,
|
|
786
758
|
A: [
|
|
787
759
|
"SchemaAST.isTypeLiteral(schema.ast)",
|
|
@@ -875,17 +847,17 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
875
847
|
}, [
|
|
876
848
|
values
|
|
877
849
|
]);
|
|
878
|
-
const onValueChange = useCallback4((path, type,
|
|
850
|
+
const onValueChange = useCallback4((path, type, value2) => {
|
|
879
851
|
const jsonPath = createJsonPath(path);
|
|
880
|
-
let parsedValue =
|
|
852
|
+
let parsedValue = value2;
|
|
881
853
|
try {
|
|
882
854
|
if (type === "number") {
|
|
883
|
-
parsedValue = parseFloat(
|
|
855
|
+
parsedValue = parseFloat(value2) || 0;
|
|
884
856
|
}
|
|
885
857
|
} catch (err) {
|
|
886
858
|
log.catch(err, void 0, {
|
|
887
859
|
F: __dxlog_file,
|
|
888
|
-
L:
|
|
860
|
+
L: 217,
|
|
889
861
|
S: void 0,
|
|
890
862
|
C: (f, a) => f(...a)
|
|
891
863
|
});
|
|
@@ -953,10 +925,10 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
953
925
|
onTouched
|
|
954
926
|
]);
|
|
955
927
|
};
|
|
956
|
-
var createKeySet = (obj,
|
|
928
|
+
var createKeySet = (obj, value2) => {
|
|
957
929
|
invariant(obj, void 0, {
|
|
958
930
|
F: __dxlog_file,
|
|
959
|
-
L:
|
|
931
|
+
L: 279,
|
|
960
932
|
S: void 0,
|
|
961
933
|
A: [
|
|
962
934
|
"obj",
|
|
@@ -965,7 +937,7 @@ var createKeySet = (obj, value) => {
|
|
|
965
937
|
});
|
|
966
938
|
return Object.keys(obj).reduce((acc, key) => ({
|
|
967
939
|
...acc,
|
|
968
|
-
[key]:
|
|
940
|
+
[key]: value2
|
|
969
941
|
}), {});
|
|
970
942
|
};
|
|
971
943
|
var flatMap = (errors) => {
|
|
@@ -980,7 +952,7 @@ var flatMap = (errors) => {
|
|
|
980
952
|
|
|
981
953
|
// src/hooks/useRefQueryLookupHandler.ts
|
|
982
954
|
import { useCallback as useCallback5 } from "react";
|
|
983
|
-
import { getObjectDXN } from "@dxos/echo
|
|
955
|
+
import { getObjectDXN } from "@dxos/echo/internal";
|
|
984
956
|
import { Filter } from "@dxos/react-client/echo";
|
|
985
957
|
import { isNonNullable } from "@dxos/util";
|
|
986
958
|
var useRefQueryLookupHandler = ({ space }) => {
|
|
@@ -1032,7 +1004,7 @@ var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
|
|
|
1032
1004
|
} catch (error) {
|
|
1033
1005
|
log2.error("Failed to fetch ref options:", error, {
|
|
1034
1006
|
F: __dxlog_file2,
|
|
1035
|
-
L:
|
|
1007
|
+
L: 48,
|
|
1036
1008
|
S: void 0,
|
|
1037
1009
|
C: (f, a) => f(...a)
|
|
1038
1010
|
});
|
|
@@ -1070,7 +1042,7 @@ var useInputProps = (path = []) => {
|
|
|
1070
1042
|
return useMemo3(() => ({
|
|
1071
1043
|
getStatus: () => getStatus(stablePath),
|
|
1072
1044
|
getValue: () => getFormValue(stablePath),
|
|
1073
|
-
onValueChange: (type,
|
|
1045
|
+
onValueChange: (type, value2) => onValueChange(stablePath, type, value2),
|
|
1074
1046
|
onBlur: () => onTouched(stablePath)
|
|
1075
1047
|
}), [
|
|
1076
1048
|
getStatus,
|
|
@@ -1081,7 +1053,7 @@ var useInputProps = (path = []) => {
|
|
|
1081
1053
|
]);
|
|
1082
1054
|
};
|
|
1083
1055
|
var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
1084
|
-
var _effect =
|
|
1056
|
+
var _effect = _useSignals7();
|
|
1085
1057
|
try {
|
|
1086
1058
|
const form = useForm(formOptions);
|
|
1087
1059
|
const handleKeyDown = useCallback6((event) => {
|
|
@@ -1100,7 +1072,9 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1100
1072
|
}
|
|
1101
1073
|
}
|
|
1102
1074
|
}, [
|
|
1103
|
-
form,
|
|
1075
|
+
form.canSave,
|
|
1076
|
+
form.formIsValid,
|
|
1077
|
+
form.handleSave,
|
|
1104
1078
|
autoSave
|
|
1105
1079
|
]);
|
|
1106
1080
|
useEffect6(() => {
|
|
@@ -1117,7 +1091,7 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1117
1091
|
form.handleSave,
|
|
1118
1092
|
autoSave
|
|
1119
1093
|
]);
|
|
1120
|
-
return /* @__PURE__ */
|
|
1094
|
+
return /* @__PURE__ */ React7.createElement(FormContext.Provider, {
|
|
1121
1095
|
value: form
|
|
1122
1096
|
}, children);
|
|
1123
1097
|
} finally {
|
|
@@ -1127,19 +1101,19 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1127
1101
|
|
|
1128
1102
|
// src/components/Form/FormActions.tsx
|
|
1129
1103
|
var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
|
|
1130
|
-
var _effect =
|
|
1104
|
+
var _effect = _useSignals8();
|
|
1131
1105
|
try {
|
|
1132
1106
|
const { t } = useTranslation5(translationKey);
|
|
1133
1107
|
const { canSave, handleSave } = useFormContext();
|
|
1134
|
-
return /* @__PURE__ */
|
|
1108
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1135
1109
|
role: "none",
|
|
1136
|
-
className:
|
|
1137
|
-
}, onCancel && !readonly && /* @__PURE__ */
|
|
1110
|
+
className: mx4(outerSpacing === "scroll-fields" ? "pli-cardSpacingInline mbe-cardSpacingBlock" : outerSpacing ? cardSpacing : "mbs-cardSpacingBlock", "flex [&_button]:grow gap-1 first:mbs-0")
|
|
1111
|
+
}, onCancel && !readonly && /* @__PURE__ */ React8.createElement(IconButton2, {
|
|
1138
1112
|
"data-testid": "cancel-button",
|
|
1139
1113
|
icon: "ph--x--regular",
|
|
1140
1114
|
label: t("button cancel"),
|
|
1141
1115
|
onClick: onCancel
|
|
1142
|
-
}), handleSave && /* @__PURE__ */
|
|
1116
|
+
}), handleSave && /* @__PURE__ */ React8.createElement(IconButton2, {
|
|
1143
1117
|
type: "submit",
|
|
1144
1118
|
"data-testid": "save-button",
|
|
1145
1119
|
disabled: !canSave,
|
|
@@ -1154,53 +1128,45 @@ var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
|
|
|
1154
1128
|
|
|
1155
1129
|
// src/components/Form/FormContent.tsx
|
|
1156
1130
|
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1157
|
-
import
|
|
1158
|
-
import
|
|
1159
|
-
import
|
|
1131
|
+
import * as Function2 from "effect/Function";
|
|
1132
|
+
import * as Schema from "effect/Schema";
|
|
1133
|
+
import * as SchemaAST4 from "effect/SchemaAST";
|
|
1134
|
+
import * as StringEffect from "effect/String";
|
|
1135
|
+
import React12, { forwardRef as forwardRef2, useMemo as useMemo6 } from "react";
|
|
1160
1136
|
import { createJsonPath as createJsonPath3, findNode as findNode3, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
|
|
1161
|
-
import { mx as
|
|
1137
|
+
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
1162
1138
|
import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
|
|
1163
|
-
import {
|
|
1164
|
-
|
|
1165
|
-
// src/components/Form/ArrayField.tsx
|
|
1166
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1167
|
-
import { SchemaAST as SchemaAST3, pipe } from "effect";
|
|
1168
|
-
import { capitalize } from "effect/String";
|
|
1169
|
-
import React10, { Fragment, useCallback as useCallback7 } from "react";
|
|
1170
|
-
import { findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from "@dxos/effect";
|
|
1171
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1172
|
-
import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1173
|
-
import { getSchemaProperties } from "@dxos/schema";
|
|
1139
|
+
import { isTruthy } from "@dxos/util";
|
|
1174
1140
|
|
|
1175
1141
|
// src/util/field.ts
|
|
1176
|
-
import { FormatEnum, GeoLocation as GeoLocation2, TypeEnum } from "@dxos/echo
|
|
1177
|
-
var parseValue = ({ type, format, value }) => {
|
|
1178
|
-
if (
|
|
1142
|
+
import { FormatEnum, GeoLocation as GeoLocation2, TypeEnum } from "@dxos/echo/internal";
|
|
1143
|
+
var parseValue = ({ type, format, value: value2 }) => {
|
|
1144
|
+
if (value2 === void 0 || value2 === null || value2 === "") {
|
|
1179
1145
|
return void 0;
|
|
1180
1146
|
}
|
|
1181
1147
|
const parseScalar = (type2) => {
|
|
1182
1148
|
switch (type2) {
|
|
1183
1149
|
case TypeEnum.Boolean: {
|
|
1184
|
-
if (typeof
|
|
1185
|
-
const lowercaseValue =
|
|
1150
|
+
if (typeof value2 === "string") {
|
|
1151
|
+
const lowercaseValue = value2.toLowerCase();
|
|
1186
1152
|
if (lowercaseValue === "0" || lowercaseValue === "false") {
|
|
1187
1153
|
return false;
|
|
1188
1154
|
} else if (lowercaseValue === "1" || lowercaseValue === "true") {
|
|
1189
1155
|
return true;
|
|
1190
1156
|
}
|
|
1191
1157
|
}
|
|
1192
|
-
return Boolean(
|
|
1158
|
+
return Boolean(value2);
|
|
1193
1159
|
}
|
|
1194
1160
|
case TypeEnum.Number: {
|
|
1195
|
-
const cleaned = typeof
|
|
1161
|
+
const cleaned = typeof value2 === "string" ? value2.replace(/[^0-9.-]+/g, "") : value2;
|
|
1196
1162
|
const num = Number(cleaned);
|
|
1197
1163
|
return Number.isNaN(num) ? null : num;
|
|
1198
1164
|
}
|
|
1199
1165
|
case TypeEnum.String:
|
|
1200
1166
|
case TypeEnum.Ref:
|
|
1201
|
-
return String(
|
|
1167
|
+
return String(value2);
|
|
1202
1168
|
default: {
|
|
1203
|
-
return
|
|
1169
|
+
return value2;
|
|
1204
1170
|
}
|
|
1205
1171
|
}
|
|
1206
1172
|
};
|
|
@@ -1224,12 +1190,12 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1224
1190
|
case FormatEnum.Date:
|
|
1225
1191
|
case FormatEnum.Time:
|
|
1226
1192
|
case FormatEnum.Timestamp: {
|
|
1227
|
-
const date = new Date(
|
|
1193
|
+
const date = new Date(value2);
|
|
1228
1194
|
return isNaN(date.getTime()) ? null : date;
|
|
1229
1195
|
}
|
|
1230
1196
|
case FormatEnum.GeoPoint: {
|
|
1231
|
-
if (typeof
|
|
1232
|
-
const cleaned =
|
|
1197
|
+
if (typeof value2 === "string") {
|
|
1198
|
+
const cleaned = value2.replace(/[^0-9.,-]+/g, "");
|
|
1233
1199
|
const parts = cleaned.split(",");
|
|
1234
1200
|
if (parts.length === 2) {
|
|
1235
1201
|
const lat = parseFloat(parts[0]);
|
|
@@ -1248,33 +1214,12 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1248
1214
|
];
|
|
1249
1215
|
}
|
|
1250
1216
|
default: {
|
|
1251
|
-
return
|
|
1217
|
+
return value2;
|
|
1252
1218
|
}
|
|
1253
1219
|
}
|
|
1254
1220
|
};
|
|
1255
1221
|
var cellClassesForFieldType = ({ type, format }) => {
|
|
1256
|
-
|
|
1257
|
-
switch (type) {
|
|
1258
|
-
case TypeEnum.Number:
|
|
1259
|
-
return [
|
|
1260
|
-
"text-right",
|
|
1261
|
-
"font-mono"
|
|
1262
|
-
];
|
|
1263
|
-
case TypeEnum.Boolean:
|
|
1264
|
-
return [
|
|
1265
|
-
"text-right",
|
|
1266
|
-
"font-mono"
|
|
1267
|
-
];
|
|
1268
|
-
case TypeEnum.String:
|
|
1269
|
-
return void 0;
|
|
1270
|
-
case TypeEnum.Ref:
|
|
1271
|
-
return void 0;
|
|
1272
|
-
default: {
|
|
1273
|
-
return void 0;
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
switch (format) {
|
|
1222
|
+
switch (format || type) {
|
|
1278
1223
|
case FormatEnum.Markdown:
|
|
1279
1224
|
return void 0;
|
|
1280
1225
|
case FormatEnum.Time:
|
|
@@ -1295,6 +1240,16 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1295
1240
|
return [
|
|
1296
1241
|
"font-mono"
|
|
1297
1242
|
];
|
|
1243
|
+
case TypeEnum.Number:
|
|
1244
|
+
case TypeEnum.Boolean:
|
|
1245
|
+
return [
|
|
1246
|
+
"text-right",
|
|
1247
|
+
"font-mono"
|
|
1248
|
+
];
|
|
1249
|
+
case TypeEnum.String:
|
|
1250
|
+
return void 0;
|
|
1251
|
+
case TypeEnum.Ref:
|
|
1252
|
+
return void 0;
|
|
1298
1253
|
default:
|
|
1299
1254
|
return void 0;
|
|
1300
1255
|
}
|
|
@@ -1306,19 +1261,19 @@ var pathNotUniqueError = (path) => ({
|
|
|
1306
1261
|
|
|
1307
1262
|
// src/util/formatting.ts
|
|
1308
1263
|
import { format as formatDate } from "date-fns/format";
|
|
1309
|
-
import { FormatEnum as FormatEnum2, GeoLocation as GeoLocation3, TypeEnum as TypeEnum2 } from "@dxos/echo
|
|
1310
|
-
var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
1264
|
+
import { FormatEnum as FormatEnum2, GeoLocation as GeoLocation3, TypeEnum as TypeEnum2 } from "@dxos/echo/internal";
|
|
1265
|
+
var formatForDisplay = ({ type, format, value: value2, locale = void 0 }) => {
|
|
1311
1266
|
const formatScalar = (type2) => {
|
|
1312
1267
|
switch (type2) {
|
|
1313
1268
|
case TypeEnum2.Boolean:
|
|
1314
|
-
return
|
|
1269
|
+
return value2.toLocaleString().toUpperCase();
|
|
1315
1270
|
case TypeEnum2.Number:
|
|
1316
|
-
return
|
|
1271
|
+
return value2.toLocaleString(locale);
|
|
1317
1272
|
case TypeEnum2.String:
|
|
1318
1273
|
case TypeEnum2.Ref:
|
|
1319
|
-
return String(
|
|
1274
|
+
return String(value2);
|
|
1320
1275
|
default: {
|
|
1321
|
-
return String(
|
|
1276
|
+
return String(value2);
|
|
1322
1277
|
}
|
|
1323
1278
|
}
|
|
1324
1279
|
};
|
|
@@ -1337,10 +1292,10 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1337
1292
|
return formatScalar(TypeEnum2.String);
|
|
1338
1293
|
}
|
|
1339
1294
|
case FormatEnum2.Percent: {
|
|
1340
|
-
return `${
|
|
1295
|
+
return `${value2 * 100}%`;
|
|
1341
1296
|
}
|
|
1342
1297
|
case FormatEnum2.Currency: {
|
|
1343
|
-
return
|
|
1298
|
+
return value2.toLocaleString(locale, {
|
|
1344
1299
|
style: "currency",
|
|
1345
1300
|
currency: "USD",
|
|
1346
1301
|
minimumFractionDigits: 2,
|
|
@@ -1349,53 +1304,53 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1349
1304
|
}
|
|
1350
1305
|
case FormatEnum2.Date: {
|
|
1351
1306
|
try {
|
|
1352
|
-
return formatDate(new Date(
|
|
1307
|
+
return formatDate(new Date(value2), "yyyy-MM-dd");
|
|
1353
1308
|
} catch (error) {
|
|
1354
1309
|
return "Invalid Date";
|
|
1355
1310
|
}
|
|
1356
1311
|
}
|
|
1357
1312
|
case FormatEnum2.Time: {
|
|
1358
1313
|
try {
|
|
1359
|
-
return formatDate(new Date(
|
|
1314
|
+
return formatDate(new Date(value2), "HH:mm:ss");
|
|
1360
1315
|
} catch (error) {
|
|
1361
1316
|
return "Invalid Time";
|
|
1362
1317
|
}
|
|
1363
1318
|
}
|
|
1364
1319
|
case FormatEnum2.DateTime: {
|
|
1365
1320
|
try {
|
|
1366
|
-
return formatDate(new Date(
|
|
1321
|
+
return formatDate(new Date(value2), "yyyy-MM-dd HH:mm:ss");
|
|
1367
1322
|
} catch (error) {
|
|
1368
1323
|
return "Invalid DateTime";
|
|
1369
1324
|
}
|
|
1370
1325
|
}
|
|
1371
1326
|
case FormatEnum2.GeoPoint: {
|
|
1372
|
-
if (
|
|
1327
|
+
if (value2 === null || value2 === void 0) {
|
|
1373
1328
|
return "";
|
|
1374
1329
|
}
|
|
1375
|
-
if (Array.isArray(
|
|
1376
|
-
const { latitude, longitude } = GeoLocation3.fromGeoPoint(
|
|
1330
|
+
if (Array.isArray(value2) && value2.length >= 2 && value2.every(Number.isFinite)) {
|
|
1331
|
+
const { latitude, longitude } = GeoLocation3.fromGeoPoint(value2);
|
|
1377
1332
|
return `${latitude},${longitude}`;
|
|
1378
1333
|
}
|
|
1379
|
-
return String(
|
|
1334
|
+
return String(value2);
|
|
1380
1335
|
}
|
|
1381
1336
|
default: {
|
|
1382
|
-
if (
|
|
1337
|
+
if (value2 === null || value2 === "undefined") {
|
|
1383
1338
|
return "";
|
|
1384
1339
|
}
|
|
1385
|
-
return String(
|
|
1340
|
+
return String(value2);
|
|
1386
1341
|
}
|
|
1387
1342
|
}
|
|
1388
1343
|
};
|
|
1389
|
-
var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
1344
|
+
var formatForEditing = ({ type, format, value: value2, locale = void 0 }) => {
|
|
1390
1345
|
const formatScalar = (type2) => {
|
|
1391
1346
|
switch (type2) {
|
|
1392
1347
|
case TypeEnum2.Boolean:
|
|
1393
1348
|
case TypeEnum2.Number:
|
|
1394
1349
|
case TypeEnum2.String:
|
|
1395
1350
|
case TypeEnum2.Ref:
|
|
1396
|
-
return String(
|
|
1351
|
+
return String(value2);
|
|
1397
1352
|
default:
|
|
1398
|
-
return String(
|
|
1353
|
+
return String(value2);
|
|
1399
1354
|
}
|
|
1400
1355
|
};
|
|
1401
1356
|
if (!format) {
|
|
@@ -1409,50 +1364,49 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
1409
1364
|
return formatScalar(type);
|
|
1410
1365
|
}
|
|
1411
1366
|
case FormatEnum2.Percent: {
|
|
1412
|
-
return String(
|
|
1367
|
+
return String(value2 * 100);
|
|
1413
1368
|
}
|
|
1414
1369
|
case FormatEnum2.Currency: {
|
|
1415
|
-
return String(
|
|
1370
|
+
return String(value2);
|
|
1416
1371
|
}
|
|
1417
1372
|
case FormatEnum2.DateTime: {
|
|
1418
|
-
const date = new Date(
|
|
1373
|
+
const date = new Date(value2);
|
|
1419
1374
|
return date.toISOString();
|
|
1420
1375
|
}
|
|
1421
1376
|
case FormatEnum2.Date: {
|
|
1422
|
-
const date = new Date(
|
|
1377
|
+
const date = new Date(value2);
|
|
1423
1378
|
return date.toISOString().split("T")[0];
|
|
1424
1379
|
}
|
|
1425
1380
|
case FormatEnum2.Time: {
|
|
1426
|
-
const date = new Date(
|
|
1381
|
+
const date = new Date(value2);
|
|
1427
1382
|
return date.toISOString().split("T")[1].split(".")[0];
|
|
1428
1383
|
}
|
|
1429
1384
|
case FormatEnum2.GeoPoint: {
|
|
1430
|
-
if (
|
|
1385
|
+
if (value2 === null || value2 === void 0) {
|
|
1431
1386
|
return "";
|
|
1432
1387
|
}
|
|
1433
|
-
if (Array.isArray(
|
|
1434
|
-
const { latitude, longitude } = GeoLocation3.fromGeoPoint(
|
|
1388
|
+
if (Array.isArray(value2) && value2.length >= 2 && value2.every(Number.isFinite)) {
|
|
1389
|
+
const { latitude, longitude } = GeoLocation3.fromGeoPoint(value2);
|
|
1435
1390
|
return `${latitude},${longitude}`;
|
|
1436
1391
|
}
|
|
1437
|
-
return String(
|
|
1392
|
+
return String(value2);
|
|
1438
1393
|
}
|
|
1439
1394
|
default: {
|
|
1440
|
-
return String(
|
|
1395
|
+
return String(value2);
|
|
1441
1396
|
}
|
|
1442
1397
|
}
|
|
1443
1398
|
};
|
|
1444
1399
|
|
|
1445
1400
|
// src/util/refs.ts
|
|
1446
|
-
import { FormatEnum as FormatEnum3, ReferenceAnnotationId } from "@dxos/echo
|
|
1401
|
+
import { FormatEnum as FormatEnum3, ReferenceAnnotationId } from "@dxos/echo/internal";
|
|
1447
1402
|
import { findAnnotation } from "@dxos/effect";
|
|
1448
1403
|
|
|
1449
1404
|
// src/util/schema.ts
|
|
1450
|
-
import
|
|
1405
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
1451
1406
|
import { findNode } from "@dxos/effect";
|
|
1452
1407
|
var findArrayElementType = (ast) => {
|
|
1453
1408
|
const tupleType = findNode(ast, SchemaAST2.isTupleType);
|
|
1454
|
-
|
|
1455
|
-
return elementType;
|
|
1409
|
+
return tupleType?.rest[0]?.type;
|
|
1456
1410
|
};
|
|
1457
1411
|
|
|
1458
1412
|
// src/util/refs.ts
|
|
@@ -1480,23 +1434,32 @@ var getRefProps = (property) => {
|
|
|
1480
1434
|
};
|
|
1481
1435
|
|
|
1482
1436
|
// src/components/Form/ArrayField.tsx
|
|
1437
|
+
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1438
|
+
import * as Function from "effect/Function";
|
|
1439
|
+
import * as SchemaAST3 from "effect/SchemaAST";
|
|
1440
|
+
import * as String2 from "effect/String";
|
|
1441
|
+
import React9, { Fragment, useCallback as useCallback7 } from "react";
|
|
1442
|
+
import { SimpleType, findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion } from "@dxos/effect";
|
|
1443
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1444
|
+
import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1445
|
+
import { getSchemaProperties } from "@dxos/schema";
|
|
1483
1446
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
1484
1447
|
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
1485
|
-
var _effect =
|
|
1448
|
+
var _effect = _useSignals9();
|
|
1486
1449
|
try {
|
|
1487
1450
|
const { t } = useTranslation6(translationKey);
|
|
1488
1451
|
const { ast, name, type, title } = property;
|
|
1489
1452
|
const values = useFormValues(path ?? []) ?? [];
|
|
1490
1453
|
invariant2(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
1491
1454
|
F: __dxlog_file3,
|
|
1492
|
-
L:
|
|
1455
|
+
L: 37,
|
|
1493
1456
|
S: void 0,
|
|
1494
1457
|
A: [
|
|
1495
1458
|
"Array.isArray(values)",
|
|
1496
1459
|
"`Values at path ${path?.join('.')} must be an array.`"
|
|
1497
1460
|
]
|
|
1498
1461
|
});
|
|
1499
|
-
const label = title ?? pipe(name, capitalize);
|
|
1462
|
+
const label = title ?? Function.pipe(name, String2.capitalize);
|
|
1500
1463
|
const elementType = findArrayElementType(ast);
|
|
1501
1464
|
const getDefaultObjectValue = (typeNode) => {
|
|
1502
1465
|
const baseNode = findNode2(typeNode, isDiscriminatedUnion);
|
|
@@ -1532,14 +1495,14 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1532
1495
|
if (!elementType) {
|
|
1533
1496
|
return null;
|
|
1534
1497
|
}
|
|
1535
|
-
return readonly && values.length < 1 ? null : /* @__PURE__ */
|
|
1498
|
+
return readonly && values.length < 1 ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(InputHeader, {
|
|
1536
1499
|
readonly: true,
|
|
1537
1500
|
label
|
|
1538
|
-
}), /* @__PURE__ */
|
|
1501
|
+
}), /* @__PURE__ */ React9.createElement("div", {
|
|
1539
1502
|
role: "none",
|
|
1540
1503
|
className: readonly ? "flex flex-wrap gap-1 mlb-1" : values.length > 0 ? "grid gap-1 grid-cols-[1fr_min-content] mlb-1" : "hidden"
|
|
1541
1504
|
}, values.map((_value, index) => {
|
|
1542
|
-
const field = /* @__PURE__ */
|
|
1505
|
+
const field = /* @__PURE__ */ React9.createElement(FormField, {
|
|
1543
1506
|
property: {
|
|
1544
1507
|
...property,
|
|
1545
1508
|
array: false,
|
|
@@ -1554,18 +1517,18 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1554
1517
|
Custom,
|
|
1555
1518
|
lookupComponent
|
|
1556
1519
|
});
|
|
1557
|
-
return readonly ? field : /* @__PURE__ */
|
|
1520
|
+
return readonly ? field : /* @__PURE__ */ React9.createElement(Fragment, {
|
|
1558
1521
|
key: index
|
|
1559
|
-
}, /* @__PURE__ */
|
|
1522
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1560
1523
|
role: "none"
|
|
1561
|
-
}, field), /* @__PURE__ */
|
|
1524
|
+
}, field), /* @__PURE__ */ React9.createElement(IconButton3, {
|
|
1562
1525
|
icon: "ph--trash--regular",
|
|
1563
1526
|
iconOnly: true,
|
|
1564
1527
|
label: t("button remove"),
|
|
1565
1528
|
onClick: () => handleRemove(index),
|
|
1566
1529
|
classNames: "self-center"
|
|
1567
1530
|
}));
|
|
1568
|
-
})), !readonly && /* @__PURE__ */
|
|
1531
|
+
})), !readonly && /* @__PURE__ */ React9.createElement(IconButton3, {
|
|
1569
1532
|
classNames: "is-full mlb-cardSpacingBlock flex",
|
|
1570
1533
|
icon: "ph--plus--regular",
|
|
1571
1534
|
label: t("add field"),
|
|
@@ -1576,22 +1539,140 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1576
1539
|
}
|
|
1577
1540
|
};
|
|
1578
1541
|
|
|
1542
|
+
// src/components/Form/factory.tsx
|
|
1543
|
+
import { FormatEnum as FormatEnum4 } from "@dxos/echo/internal";
|
|
1544
|
+
var getInputComponent = (type, format) => {
|
|
1545
|
+
switch (format) {
|
|
1546
|
+
case FormatEnum4.GeoPoint:
|
|
1547
|
+
return GeoPointInput;
|
|
1548
|
+
case FormatEnum4.Markdown:
|
|
1549
|
+
return MarkdownInput;
|
|
1550
|
+
}
|
|
1551
|
+
switch (type) {
|
|
1552
|
+
case "string":
|
|
1553
|
+
return TextInput;
|
|
1554
|
+
case "number":
|
|
1555
|
+
return NumberInput;
|
|
1556
|
+
case "boolean":
|
|
1557
|
+
return BooleanInput;
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1579
1561
|
// src/components/Form/RefField.tsx
|
|
1580
1562
|
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1581
|
-
import React11, { useCallback as
|
|
1582
|
-
import { Expando,
|
|
1563
|
+
import React11, { useCallback as useCallback9, useMemo as useMemo5 } from "react";
|
|
1564
|
+
import { Expando, Ref, ReferenceAnnotationId as ReferenceAnnotationId2, getTypeAnnotation } from "@dxos/echo/internal";
|
|
1583
1565
|
import { findAnnotation as findAnnotation2 } from "@dxos/effect";
|
|
1584
1566
|
import { DXN } from "@dxos/keys";
|
|
1585
|
-
import {
|
|
1586
|
-
import { Input as
|
|
1587
|
-
import {
|
|
1588
|
-
import { descriptionText, mx as mx7 } from "@dxos/react-ui-theme";
|
|
1567
|
+
import { DxAnchor, DxTagPickerItem } from "@dxos/lit-ui/react";
|
|
1568
|
+
import { Button as Button2, Icon as Icon3, Input as Input7, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
1569
|
+
import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
|
|
1589
1570
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1590
|
-
|
|
1591
|
-
|
|
1571
|
+
|
|
1572
|
+
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
1573
|
+
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1574
|
+
import React10, { forwardRef, useCallback as useCallback8, useMemo as useMemo4, useState as useState5 } from "react";
|
|
1575
|
+
import { Icon as Icon2, Popover, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1576
|
+
import { PopoverCombobox } from "@dxos/react-ui-searchlist";
|
|
1577
|
+
var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, onSelect, onCreate, ...props }, ref) => {
|
|
1578
|
+
var _effect = _useSignals10();
|
|
1592
1579
|
try {
|
|
1593
1580
|
const { t } = useTranslation7(translationKey);
|
|
1594
|
-
const
|
|
1581
|
+
const [searchString, setSearchString] = useState5("");
|
|
1582
|
+
const [showForm, setShowForm] = useState5(false);
|
|
1583
|
+
const handleFormSave = useCallback8((values) => {
|
|
1584
|
+
onCreate?.(values);
|
|
1585
|
+
setShowForm(false);
|
|
1586
|
+
setSearchString("");
|
|
1587
|
+
}, [
|
|
1588
|
+
onCreate
|
|
1589
|
+
]);
|
|
1590
|
+
const handleFormCancel = useCallback8(() => {
|
|
1591
|
+
setShowForm(false);
|
|
1592
|
+
setSearchString("");
|
|
1593
|
+
}, []);
|
|
1594
|
+
const handleClick = useCallback8((event) => {
|
|
1595
|
+
if (createSchema && event.target.closest('[data-value="__create__"]')) {
|
|
1596
|
+
event.stopPropagation();
|
|
1597
|
+
event.preventDefault();
|
|
1598
|
+
setShowForm(true);
|
|
1599
|
+
}
|
|
1600
|
+
}, [
|
|
1601
|
+
createSchema
|
|
1602
|
+
]);
|
|
1603
|
+
const handleKeyDown = useCallback8((event) => {
|
|
1604
|
+
if (event.key === "Enter" && createSchema && event.currentTarget.querySelector('[role="option"][aria-selected="true"][data-value="__create__"]')) {
|
|
1605
|
+
event.stopPropagation();
|
|
1606
|
+
event.preventDefault();
|
|
1607
|
+
setShowForm(true);
|
|
1608
|
+
}
|
|
1609
|
+
}, [
|
|
1610
|
+
createSchema
|
|
1611
|
+
]);
|
|
1612
|
+
const labelById = useMemo4(() => options.reduce((acc, option) => {
|
|
1613
|
+
acc[option.id.toLowerCase()] = option.label.toLowerCase();
|
|
1614
|
+
return acc;
|
|
1615
|
+
}, {}), [
|
|
1616
|
+
options
|
|
1617
|
+
]);
|
|
1618
|
+
return /* @__PURE__ */ React10.createElement(PopoverCombobox.Content, {
|
|
1619
|
+
...props,
|
|
1620
|
+
ref,
|
|
1621
|
+
filter: (value2, search) => value2 === "__create__" || labelById[value2]?.includes(search.toLowerCase()) ? 1 : 0,
|
|
1622
|
+
onClickCapture: handleClick,
|
|
1623
|
+
onKeyDownCapture: handleKeyDown
|
|
1624
|
+
}, showForm && createSchema ? /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form, {
|
|
1625
|
+
schema: createSchema,
|
|
1626
|
+
values: createInitialValuePath ? {
|
|
1627
|
+
[createInitialValuePath]: searchString
|
|
1628
|
+
} : {},
|
|
1629
|
+
onSave: handleFormSave,
|
|
1630
|
+
onCancel: handleFormCancel,
|
|
1631
|
+
testId: "create-referenced-object-form"
|
|
1632
|
+
})) : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(PopoverCombobox.Input, {
|
|
1633
|
+
placeholder: t("ref field combobox input placeholder"),
|
|
1634
|
+
value: searchString,
|
|
1635
|
+
onValueChange: setSearchString,
|
|
1636
|
+
autoFocus: true
|
|
1637
|
+
}), /* @__PURE__ */ React10.createElement(PopoverCombobox.List, null, options.map((option) => /* @__PURE__ */ React10.createElement(PopoverCombobox.Item, {
|
|
1638
|
+
key: option.id,
|
|
1639
|
+
value: option.id,
|
|
1640
|
+
onSelect: () => onSelect(option.id),
|
|
1641
|
+
classNames: "flex items-center gap-2"
|
|
1642
|
+
}, /* @__PURE__ */ React10.createElement("span", {
|
|
1643
|
+
className: "grow"
|
|
1644
|
+
}, option.label), selectedIds?.includes(option.id) && /* @__PURE__ */ React10.createElement(Icon2, {
|
|
1645
|
+
icon: "ph--check--regular"
|
|
1646
|
+
}))), searchString.length > 0 && createOptionLabel && createOptionIcon && createSchema && onCreate && /* @__PURE__ */ React10.createElement(PopoverCombobox.Item, {
|
|
1647
|
+
value: "__create__",
|
|
1648
|
+
classNames: "flex items-center gap-2"
|
|
1649
|
+
}, /* @__PURE__ */ React10.createElement(Icon2, {
|
|
1650
|
+
icon: createOptionIcon
|
|
1651
|
+
}), t(createOptionLabel[0], {
|
|
1652
|
+
ns: createOptionLabel[1].ns,
|
|
1653
|
+
text: searchString
|
|
1654
|
+
})))), /* @__PURE__ */ React10.createElement(PopoverCombobox.Arrow, null));
|
|
1655
|
+
} finally {
|
|
1656
|
+
_effect.f();
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
ObjectPickerContent.displayName = "ObjectPickerContent";
|
|
1660
|
+
var ObjectPicker = {
|
|
1661
|
+
Root: PopoverCombobox.Root,
|
|
1662
|
+
Trigger: PopoverCombobox.Trigger,
|
|
1663
|
+
VirtualTrigger: PopoverCombobox.VirtualTrigger,
|
|
1664
|
+
Content: ObjectPickerContent
|
|
1665
|
+
};
|
|
1666
|
+
|
|
1667
|
+
// src/components/Form/RefField.tsx
|
|
1668
|
+
var isRefSnapShot = (val) => {
|
|
1669
|
+
return typeof val === "object" && typeof val?.["/"] === "string";
|
|
1670
|
+
};
|
|
1671
|
+
var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, getValue: getValue3, createOptionLabel, createOptionIcon, onBlur, onCreate, createSchema, createInitialValuePath, onQueryRefOptions, onValueChange, ...restInputProps }) => {
|
|
1672
|
+
var _effect = _useSignals11();
|
|
1673
|
+
try {
|
|
1674
|
+
const { t } = useTranslation8(translationKey);
|
|
1675
|
+
const refTypeInfo = useMemo5(() => ast ? findAnnotation2(ast, ReferenceAnnotationId2) : void 0, [
|
|
1595
1676
|
ast
|
|
1596
1677
|
]);
|
|
1597
1678
|
const { options: availableOptions, loading: _loading } = useQueryRefOptions({
|
|
@@ -1603,7 +1684,7 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1603
1684
|
type,
|
|
1604
1685
|
label,
|
|
1605
1686
|
placeholder,
|
|
1606
|
-
|
|
1687
|
+
readonly,
|
|
1607
1688
|
inputOnly,
|
|
1608
1689
|
getValue: getValue3,
|
|
1609
1690
|
onBlur,
|
|
@@ -1611,11 +1692,12 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1611
1692
|
...restInputProps
|
|
1612
1693
|
});
|
|
1613
1694
|
}
|
|
1614
|
-
const handleGetValue =
|
|
1695
|
+
const handleGetValue = useCallback9(() => {
|
|
1615
1696
|
const formValue = getValue3();
|
|
1616
1697
|
const unknownToRefOption = (val) => {
|
|
1617
|
-
|
|
1618
|
-
|
|
1698
|
+
const isRef = Ref.isRef(val);
|
|
1699
|
+
if (isRef || isRefSnapShot(val)) {
|
|
1700
|
+
const dxnString = isRef ? val.dxn.toString() : val["/"];
|
|
1619
1701
|
const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
|
|
1620
1702
|
if (matchingOption) {
|
|
1621
1703
|
return matchingOption;
|
|
@@ -1638,14 +1720,7 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1638
1720
|
availableOptions,
|
|
1639
1721
|
array
|
|
1640
1722
|
]);
|
|
1641
|
-
const
|
|
1642
|
-
id: option.id,
|
|
1643
|
-
label: option.label,
|
|
1644
|
-
hue: option.hue
|
|
1645
|
-
})), [
|
|
1646
|
-
availableOptions
|
|
1647
|
-
]);
|
|
1648
|
-
const handleUpdate = useCallback8((ids) => {
|
|
1723
|
+
const handleUpdate = useCallback9((ids) => {
|
|
1649
1724
|
if (ids.length === 0) {
|
|
1650
1725
|
onValueChange("object", void 0);
|
|
1651
1726
|
return;
|
|
@@ -1668,44 +1743,91 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1668
1743
|
array,
|
|
1669
1744
|
onValueChange
|
|
1670
1745
|
]);
|
|
1671
|
-
const tagPickerMode = useMemo4(() => array ? "multi-select" : "single-select", [
|
|
1672
|
-
array
|
|
1673
|
-
]);
|
|
1674
1746
|
if (!refTypeInfo) {
|
|
1675
1747
|
return null;
|
|
1676
1748
|
}
|
|
1677
1749
|
const { status, error } = restInputProps.getStatus();
|
|
1678
1750
|
const items = handleGetValue();
|
|
1679
|
-
|
|
1751
|
+
const selectedIds = useMemo5(() => items.map((i) => i.id), [
|
|
1752
|
+
items
|
|
1753
|
+
]);
|
|
1754
|
+
const toggleSelect = useCallback9((id) => {
|
|
1755
|
+
if (array) {
|
|
1756
|
+
const nextIds = selectedIds.includes(id) ? selectedIds.filter((x) => x !== id) : [
|
|
1757
|
+
...selectedIds,
|
|
1758
|
+
id
|
|
1759
|
+
];
|
|
1760
|
+
handleUpdate(nextIds);
|
|
1761
|
+
} else {
|
|
1762
|
+
if (selectedIds[0] === id) {
|
|
1763
|
+
handleUpdate([]);
|
|
1764
|
+
} else {
|
|
1765
|
+
handleUpdate([
|
|
1766
|
+
id
|
|
1767
|
+
]);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
}, [
|
|
1771
|
+
array,
|
|
1772
|
+
selectedIds,
|
|
1773
|
+
handleUpdate
|
|
1774
|
+
]);
|
|
1775
|
+
return readonly && items.length < 1 ? null : /* @__PURE__ */ React11.createElement(Input7.Root, {
|
|
1680
1776
|
validationValence: status
|
|
1681
1777
|
}, !inputOnly && /* @__PURE__ */ React11.createElement(InputHeader, {
|
|
1682
1778
|
error,
|
|
1683
1779
|
label
|
|
1684
1780
|
}), /* @__PURE__ */ React11.createElement("div", {
|
|
1685
1781
|
"data-no-submit": true
|
|
1686
|
-
},
|
|
1687
|
-
className:
|
|
1688
|
-
}, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React11.createElement(
|
|
1782
|
+
}, readonly ? items.length < 1 ? /* @__PURE__ */ React11.createElement("p", {
|
|
1783
|
+
className: mx5(descriptionText, "mbe-2")
|
|
1784
|
+
}, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React11.createElement(DxAnchor, {
|
|
1689
1785
|
key: item.id,
|
|
1690
1786
|
refid: item.id,
|
|
1691
|
-
rootclassname: "mie-1"
|
|
1692
|
-
|
|
1693
|
-
|
|
1787
|
+
rootclassname: "mie-1"
|
|
1788
|
+
}, item.label)) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
|
|
1789
|
+
asChild: true
|
|
1790
|
+
}, /* @__PURE__ */ React11.createElement(Button2, {
|
|
1791
|
+
variant: "ghost",
|
|
1792
|
+
classNames: "is-full text-start gap-2"
|
|
1793
|
+
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1794
|
+
role: "none",
|
|
1795
|
+
className: "grow"
|
|
1796
|
+
}, items?.length ? items?.map((item) => /* @__PURE__ */ React11.createElement(DxTagPickerItem, {
|
|
1797
|
+
key: item.id,
|
|
1798
|
+
itemId: item.id,
|
|
1799
|
+
label: item.label,
|
|
1800
|
+
...item.hue ? {
|
|
1801
|
+
hue: item.hue
|
|
1802
|
+
} : {},
|
|
1803
|
+
removeLabel: t("remove item label"),
|
|
1804
|
+
onItemClick: (event) => {
|
|
1805
|
+
if (event.action === "remove") {
|
|
1806
|
+
toggleSelect(item.id);
|
|
1807
|
+
}
|
|
1694
1808
|
}
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1809
|
+
})) : /* @__PURE__ */ React11.createElement("span", {
|
|
1810
|
+
className: "text-description"
|
|
1811
|
+
}, placeholder ?? t("ref field placeholder", {
|
|
1812
|
+
count: array ? 99 : 1
|
|
1813
|
+
}))), /* @__PURE__ */ React11.createElement(Icon3, {
|
|
1814
|
+
size: 3,
|
|
1815
|
+
icon: "ph--caret-down--bold"
|
|
1816
|
+
}))), /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
|
|
1817
|
+
options: availableOptions,
|
|
1818
|
+
selectedIds,
|
|
1819
|
+
onSelect: toggleSelect,
|
|
1820
|
+
createSchema,
|
|
1821
|
+
createOptionLabel,
|
|
1822
|
+
createOptionIcon,
|
|
1823
|
+
createInitialValuePath,
|
|
1824
|
+
onCreate
|
|
1825
|
+
}))), inputOnly && /* @__PURE__ */ React11.createElement(Input7.DescriptionAndValidation, null, error));
|
|
1704
1826
|
} finally {
|
|
1705
1827
|
_effect.f();
|
|
1706
1828
|
}
|
|
1707
1829
|
};
|
|
1708
|
-
var RefFieldFallback = ({ type, label,
|
|
1830
|
+
var RefFieldFallback = ({ type, label, readonly, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
|
|
1709
1831
|
var _effect = _useSignals11();
|
|
1710
1832
|
try {
|
|
1711
1833
|
const handleOnValueChange = (_type, dxnString) => {
|
|
@@ -1731,7 +1853,7 @@ var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValu
|
|
|
1731
1853
|
return /* @__PURE__ */ React11.createElement(TextInput, {
|
|
1732
1854
|
type,
|
|
1733
1855
|
label,
|
|
1734
|
-
|
|
1856
|
+
readonly,
|
|
1735
1857
|
placeholder,
|
|
1736
1858
|
inputOnly,
|
|
1737
1859
|
getValue: handleGetValue,
|
|
@@ -1743,36 +1865,17 @@ var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValu
|
|
|
1743
1865
|
}
|
|
1744
1866
|
};
|
|
1745
1867
|
|
|
1746
|
-
// src/components/Form/factory.tsx
|
|
1747
|
-
import { FormatEnum as FormatEnum4 } from "@dxos/echo-schema";
|
|
1748
|
-
var getInputComponent = (type, format) => {
|
|
1749
|
-
switch (format) {
|
|
1750
|
-
case FormatEnum4.GeoPoint:
|
|
1751
|
-
return GeoPointInput;
|
|
1752
|
-
case FormatEnum4.Markdown:
|
|
1753
|
-
return MarkdownInput;
|
|
1754
|
-
}
|
|
1755
|
-
switch (type) {
|
|
1756
|
-
case "string":
|
|
1757
|
-
return TextInput;
|
|
1758
|
-
case "number":
|
|
1759
|
-
return NumberInput;
|
|
1760
|
-
case "boolean":
|
|
1761
|
-
return BooleanInput;
|
|
1762
|
-
}
|
|
1763
|
-
};
|
|
1764
|
-
|
|
1765
1868
|
// src/components/Form/FormContent.tsx
|
|
1766
|
-
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1869
|
+
var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptions, createOptionLabel, createOptionIcon, onCreate, createSchema, createInitialValuePath, lookupComponent, Custom }) => {
|
|
1767
1870
|
var _effect = _useSignals12();
|
|
1768
1871
|
try {
|
|
1769
1872
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1770
1873
|
const inputProps = useInputProps(path);
|
|
1771
|
-
const label =
|
|
1874
|
+
const label = useMemo6(() => title ?? Function2.pipe(name, StringEffect.capitalize), [
|
|
1772
1875
|
title,
|
|
1773
1876
|
name
|
|
1774
1877
|
]);
|
|
1775
|
-
const placeholder =
|
|
1878
|
+
const placeholder = useMemo6(() => examples?.length ? `Example: "${examples[0]}"` : description, [
|
|
1776
1879
|
examples,
|
|
1777
1880
|
description
|
|
1778
1881
|
]);
|
|
@@ -1783,7 +1886,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1783
1886
|
type,
|
|
1784
1887
|
format,
|
|
1785
1888
|
label,
|
|
1786
|
-
|
|
1889
|
+
readonly,
|
|
1787
1890
|
placeholder,
|
|
1788
1891
|
...inputProps
|
|
1789
1892
|
}
|
|
@@ -1800,7 +1903,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1800
1903
|
label,
|
|
1801
1904
|
inputOnly: inline,
|
|
1802
1905
|
placeholder,
|
|
1803
|
-
|
|
1906
|
+
readonly,
|
|
1804
1907
|
...inputProps
|
|
1805
1908
|
});
|
|
1806
1909
|
}
|
|
@@ -1813,9 +1916,14 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1813
1916
|
format,
|
|
1814
1917
|
label,
|
|
1815
1918
|
placeholder,
|
|
1816
|
-
|
|
1919
|
+
readonly,
|
|
1817
1920
|
inputOnly: inline,
|
|
1818
1921
|
onQueryRefOptions,
|
|
1922
|
+
createOptionLabel,
|
|
1923
|
+
createOptionIcon,
|
|
1924
|
+
onCreate,
|
|
1925
|
+
createSchema,
|
|
1926
|
+
createInitialValuePath,
|
|
1819
1927
|
...inputProps
|
|
1820
1928
|
});
|
|
1821
1929
|
}
|
|
@@ -1836,7 +1944,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1836
1944
|
label,
|
|
1837
1945
|
inputOnly: inline,
|
|
1838
1946
|
placeholder,
|
|
1839
|
-
|
|
1947
|
+
readonly,
|
|
1840
1948
|
...inputProps
|
|
1841
1949
|
});
|
|
1842
1950
|
}
|
|
@@ -1844,7 +1952,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1844
1952
|
return /* @__PURE__ */ React12.createElement(SelectInput, {
|
|
1845
1953
|
type,
|
|
1846
1954
|
format,
|
|
1847
|
-
|
|
1955
|
+
readonly,
|
|
1848
1956
|
inputOnly: inline,
|
|
1849
1957
|
label,
|
|
1850
1958
|
options: options.map((option) => ({
|
|
@@ -1860,12 +1968,16 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1860
1968
|
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
|
|
1861
1969
|
if (typeLiteral) {
|
|
1862
1970
|
return /* @__PURE__ */ React12.createElement(React12.Fragment, null, !inline && /* @__PURE__ */ React12.createElement("h3", {
|
|
1863
|
-
className:
|
|
1971
|
+
className: mx6("text-lg mlb-inputSpacingBlock first:mbs-0")
|
|
1864
1972
|
}, label), /* @__PURE__ */ React12.createElement(FormFields, {
|
|
1865
1973
|
schema: Schema.make(typeLiteral),
|
|
1866
1974
|
path,
|
|
1867
1975
|
readonly,
|
|
1976
|
+
projection,
|
|
1868
1977
|
onQueryRefOptions,
|
|
1978
|
+
createOptionLabel,
|
|
1979
|
+
createOptionIcon,
|
|
1980
|
+
onCreate,
|
|
1869
1981
|
Custom,
|
|
1870
1982
|
lookupComponent
|
|
1871
1983
|
}));
|
|
@@ -1876,24 +1988,42 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1876
1988
|
_effect.f();
|
|
1877
1989
|
}
|
|
1878
1990
|
};
|
|
1879
|
-
var FormFields = /* @__PURE__ */
|
|
1991
|
+
var FormFields = /* @__PURE__ */ forwardRef2(({ classNames, schema, path, filter, sort, projection, readonly, lookupComponent, Custom, onQueryRefOptions, ...props }, forwardRef4) => {
|
|
1880
1992
|
var _effect = _useSignals12();
|
|
1881
1993
|
try {
|
|
1882
1994
|
const values = useFormValues(path);
|
|
1883
|
-
const properties =
|
|
1884
|
-
const
|
|
1885
|
-
|
|
1995
|
+
const properties = useMemo6(() => {
|
|
1996
|
+
const props2 = getSchemaProperties2(schema.ast, values);
|
|
1997
|
+
if (projection) {
|
|
1998
|
+
const fieldProjections = projection.getFieldProjections();
|
|
1999
|
+
const hiddenProperties = new Set(projection.getHiddenProperties());
|
|
2000
|
+
const visibleProps = props2.filter((prop) => !hiddenProperties.has(prop.name));
|
|
2001
|
+
const orderedProps = [];
|
|
2002
|
+
for (const fieldProjection of fieldProjections) {
|
|
2003
|
+
const fieldPath = String(fieldProjection.field.path);
|
|
2004
|
+
const prop = visibleProps.find((p) => p.name === fieldPath);
|
|
2005
|
+
if (prop) {
|
|
2006
|
+
orderedProps.push(prop);
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
const projectionPaths = new Set(fieldProjections.map((fp) => String(fp.field.path)));
|
|
2010
|
+
const remainingProps = visibleProps.filter((prop) => !projectionPaths.has(prop.name));
|
|
2011
|
+
orderedProps.push(...remainingProps);
|
|
2012
|
+
return orderedProps;
|
|
2013
|
+
}
|
|
2014
|
+
const filtered = filter ? filter(props2) : props2;
|
|
1886
2015
|
return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
|
|
1887
2016
|
}, [
|
|
1888
2017
|
schema,
|
|
1889
2018
|
values,
|
|
1890
2019
|
filter,
|
|
1891
|
-
sort
|
|
2020
|
+
sort,
|
|
2021
|
+
projection?.fields
|
|
1892
2022
|
]);
|
|
1893
2023
|
return /* @__PURE__ */ React12.createElement("div", {
|
|
1894
2024
|
role: "form",
|
|
1895
|
-
className:
|
|
1896
|
-
ref:
|
|
2025
|
+
className: mx6("is-full", classNames),
|
|
2026
|
+
ref: forwardRef4
|
|
1897
2027
|
}, properties.map((property) => {
|
|
1898
2028
|
return /* @__PURE__ */ React12.createElement(FormField, {
|
|
1899
2029
|
key: property.name,
|
|
@@ -1903,35 +2033,42 @@ var FormFields = /* @__PURE__ */ forwardRef(({ classNames, testId, schema, path,
|
|
|
1903
2033
|
property.name
|
|
1904
2034
|
],
|
|
1905
2035
|
readonly,
|
|
2036
|
+
projection,
|
|
1906
2037
|
onQueryRefOptions,
|
|
1907
2038
|
lookupComponent,
|
|
1908
|
-
Custom
|
|
2039
|
+
Custom,
|
|
2040
|
+
...props
|
|
1909
2041
|
});
|
|
1910
|
-
}).filter(
|
|
2042
|
+
}).filter(isTruthy));
|
|
1911
2043
|
} finally {
|
|
1912
2044
|
_effect.f();
|
|
1913
2045
|
}
|
|
1914
2046
|
});
|
|
1915
2047
|
|
|
1916
2048
|
// src/components/Form/Form.tsx
|
|
1917
|
-
var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true,
|
|
2049
|
+
var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true, schema, onCancel, onValuesChanged, onValidate, onSave, ...props }) => {
|
|
1918
2050
|
var _effect = _useSignals13();
|
|
1919
2051
|
try {
|
|
1920
2052
|
const formRef = useRef3(null);
|
|
1921
|
-
const
|
|
1922
|
-
autoSave,
|
|
1923
|
-
onSave
|
|
1924
|
-
]);
|
|
2053
|
+
const { findFirstFocusable } = useFocusFinders();
|
|
1925
2054
|
useEffect7(() => {
|
|
1926
2055
|
if (autoFocus && formRef.current) {
|
|
1927
|
-
const
|
|
1928
|
-
if (
|
|
1929
|
-
|
|
2056
|
+
const firstFocusable = findFirstFocusable(formRef.current);
|
|
2057
|
+
if (firstFocusable) {
|
|
2058
|
+
firstFocusable.focus();
|
|
1930
2059
|
}
|
|
1931
2060
|
}
|
|
1932
2061
|
}, [
|
|
1933
2062
|
autoFocus
|
|
1934
2063
|
]);
|
|
2064
|
+
const handleValid = useCallback10(async (values, meta) => {
|
|
2065
|
+
if (autoSave) {
|
|
2066
|
+
await onSave?.(values, meta);
|
|
2067
|
+
}
|
|
2068
|
+
}, [
|
|
2069
|
+
autoSave,
|
|
2070
|
+
onSave
|
|
2071
|
+
]);
|
|
1935
2072
|
return /* @__PURE__ */ React13.createElement(FormProvider, {
|
|
1936
2073
|
formRef,
|
|
1937
2074
|
schema,
|
|
@@ -1955,7 +2092,7 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
|
|
|
1955
2092
|
],
|
|
1956
2093
|
readonly,
|
|
1957
2094
|
schema
|
|
1958
|
-
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React13.createElement(FormActions, {
|
|
2095
|
+
}), (onCancel || onSave) && !autoSave && !readonly && /* @__PURE__ */ React13.createElement(FormActions, {
|
|
1959
2096
|
readonly,
|
|
1960
2097
|
onCancel,
|
|
1961
2098
|
outerSpacing
|
|
@@ -1967,45 +2104,40 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
|
|
|
1967
2104
|
|
|
1968
2105
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
1969
2106
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1970
|
-
var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing }) => {
|
|
2107
|
+
var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, outerSpacing }) => {
|
|
1971
2108
|
var _effect = _useSignals14();
|
|
1972
2109
|
try {
|
|
1973
|
-
const { t } =
|
|
1974
|
-
const [props, setProps] =
|
|
2110
|
+
const { t } = useTranslation9(translationKey);
|
|
2111
|
+
const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
|
|
1975
2112
|
useEffect8(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
1976
2113
|
field,
|
|
1977
2114
|
projection
|
|
1978
2115
|
]);
|
|
1979
|
-
const [schemas, setSchemas] =
|
|
1980
|
-
|
|
2116
|
+
const [schemas, setSchemas] = useState6([]);
|
|
2117
|
+
useAsyncEffect(async () => {
|
|
1981
2118
|
if (!registry) {
|
|
1982
2119
|
return;
|
|
1983
2120
|
}
|
|
1984
2121
|
const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
|
|
1985
2122
|
fire: true
|
|
1986
2123
|
});
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
});
|
|
1991
|
-
return () => {
|
|
1992
|
-
clearTimeout(t2);
|
|
1993
|
-
subscription?.();
|
|
1994
|
-
};
|
|
2124
|
+
const schemas2 = await registry.query().run();
|
|
2125
|
+
setSchemas(schemas2);
|
|
2126
|
+
return () => subscription?.();
|
|
1995
2127
|
}, [
|
|
1996
2128
|
registry
|
|
1997
2129
|
]);
|
|
1998
|
-
const [referenceSchema, setReferenceSchema] =
|
|
2130
|
+
const [referenceSchema, setReferenceSchema] = useState6();
|
|
1999
2131
|
useEffect8(() => {
|
|
2000
2132
|
setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
|
|
2001
2133
|
}, [
|
|
2002
2134
|
schemas,
|
|
2003
2135
|
props?.referenceSchema
|
|
2004
2136
|
]);
|
|
2005
|
-
const [{ fieldSchema }, setFieldSchema] =
|
|
2137
|
+
const [{ fieldSchema }, setFieldSchema] = useState6({
|
|
2006
2138
|
fieldSchema: getFormatSchema(props?.format)
|
|
2007
2139
|
});
|
|
2008
|
-
const handleValuesChanged =
|
|
2140
|
+
const handleValuesChanged = useCallback11((_props) => {
|
|
2009
2141
|
setFieldSchema((prev) => {
|
|
2010
2142
|
const fieldSchema2 = getFormatSchema(_props.format);
|
|
2011
2143
|
if (prev.fieldSchema === fieldSchema2) {
|
|
@@ -2026,10 +2158,12 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
|
|
|
2026
2158
|
});
|
|
2027
2159
|
setProps((props2) => {
|
|
2028
2160
|
const type = formatToType[_props.format];
|
|
2161
|
+
const additionalProps = formatToAdditionalPropertyAttributes[_props.format];
|
|
2029
2162
|
if (props2.type !== type) {
|
|
2030
2163
|
return {
|
|
2031
2164
|
...props2,
|
|
2032
2165
|
..._props,
|
|
2166
|
+
...additionalProps,
|
|
2033
2167
|
type
|
|
2034
2168
|
};
|
|
2035
2169
|
}
|
|
@@ -2040,7 +2174,7 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
|
|
|
2040
2174
|
props.format,
|
|
2041
2175
|
props.referenceSchema
|
|
2042
2176
|
]);
|
|
2043
|
-
const handleValidate =
|
|
2177
|
+
const handleValidate = useCallback11(({ property }) => {
|
|
2044
2178
|
if (property && projection.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
2045
2179
|
return [
|
|
2046
2180
|
{
|
|
@@ -2053,7 +2187,7 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
|
|
|
2053
2187
|
projection.fields,
|
|
2054
2188
|
field
|
|
2055
2189
|
]);
|
|
2056
|
-
const handleSave =
|
|
2190
|
+
const handleSave = useCallback11((props2) => {
|
|
2057
2191
|
projection.setFieldProjection({
|
|
2058
2192
|
field,
|
|
2059
2193
|
props: props2
|
|
@@ -2064,7 +2198,7 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
|
|
|
2064
2198
|
field,
|
|
2065
2199
|
onSave
|
|
2066
2200
|
]);
|
|
2067
|
-
const handleCancel =
|
|
2201
|
+
const handleCancel = useCallback11(() => {
|
|
2068
2202
|
requestAnimationFrame(() => onCancel?.());
|
|
2069
2203
|
onSave();
|
|
2070
2204
|
}, [
|
|
@@ -2073,9 +2207,9 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
|
|
|
2073
2207
|
const custom = useMemo7(() => ({
|
|
2074
2208
|
["format"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
|
|
2075
2209
|
...props2,
|
|
2076
|
-
options: FormatEnums.filter((
|
|
2077
|
-
value,
|
|
2078
|
-
label: t(`format ${
|
|
2210
|
+
options: FormatEnums.filter((value2) => value2 !== FormatEnum5.None).map((value2) => ({
|
|
2211
|
+
value: value2,
|
|
2212
|
+
label: t(`format ${value2}`)
|
|
2079
2213
|
}))
|
|
2080
2214
|
}),
|
|
2081
2215
|
["referenceSchema"]: (props2) => /* @__PURE__ */ React14.createElement(SelectInput, {
|
|
@@ -2096,13 +2230,13 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
|
|
|
2096
2230
|
schemas,
|
|
2097
2231
|
referenceSchema
|
|
2098
2232
|
]);
|
|
2099
|
-
const propIsNotType =
|
|
2233
|
+
const propIsNotType = useCallback11((props2) => props2.filter((p) => p.name !== "type"), []);
|
|
2100
2234
|
if (!fieldSchema) {
|
|
2101
2235
|
log3.warn("invalid format", {
|
|
2102
2236
|
props
|
|
2103
2237
|
}, {
|
|
2104
2238
|
F: __dxlog_file4,
|
|
2105
|
-
L:
|
|
2239
|
+
L: 180,
|
|
2106
2240
|
S: void 0,
|
|
2107
2241
|
C: (f, a) => f(...a)
|
|
2108
2242
|
});
|
|
@@ -2111,6 +2245,7 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
|
|
|
2111
2245
|
return /* @__PURE__ */ React14.createElement(Form, {
|
|
2112
2246
|
key: field.id,
|
|
2113
2247
|
autoFocus: true,
|
|
2248
|
+
readonly,
|
|
2114
2249
|
values: props,
|
|
2115
2250
|
schema: fieldSchema,
|
|
2116
2251
|
filter: propIsNotType,
|
|
@@ -2132,73 +2267,109 @@ var FieldEditor = ({ projection, field, registry, onSave, onCancel, outerSpacing
|
|
|
2132
2267
|
|
|
2133
2268
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
2134
2269
|
import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
|
|
2135
|
-
import
|
|
2136
|
-
import
|
|
2137
|
-
import
|
|
2270
|
+
import * as Array2 from "effect/Array";
|
|
2271
|
+
import * as Match from "effect/Match";
|
|
2272
|
+
import * as Option from "effect/Option";
|
|
2273
|
+
import * as Schema2 from "effect/Schema";
|
|
2274
|
+
import React15, { forwardRef as forwardRef3, useCallback as useCallback12, useEffect as useEffect9, useImperativeHandle, useMemo as useMemo8, useRef as useRef4, useState as useState7 } from "react";
|
|
2275
|
+
import { EchoSchema, Format, isMutable, toJsonSchema } from "@dxos/echo/internal";
|
|
2138
2276
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2139
|
-
import { Callout, IconButton as IconButton4, useTranslation as
|
|
2277
|
+
import { Callout, IconButton as IconButton4, Input as Input8, useDensityContext, useElevationContext, useThemeContext, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
2278
|
+
import { Editor, createBasicExtensions, createThemeExtensions } from "@dxos/react-ui-editor";
|
|
2140
2279
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2141
2280
|
import { cardSpacing as cardSpacing3 } from "@dxos/react-ui-stack";
|
|
2142
|
-
import {
|
|
2143
|
-
import {
|
|
2281
|
+
import { inputTheme } from "@dxos/react-ui-theme";
|
|
2282
|
+
import { inputTextLabel, mx as mx7, subtleHover as subtleHover2 } from "@dxos/react-ui-theme";
|
|
2283
|
+
import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT, getTypenameFromQuery } from "@dxos/schema";
|
|
2144
2284
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2145
|
-
var
|
|
2146
|
-
var
|
|
2147
|
-
|
|
2148
|
-
title: "Typename"
|
|
2149
|
-
})
|
|
2150
|
-
}).pipe(Schema2.mutable);
|
|
2151
|
-
var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, showHeading = false, onTypenameChanged, onDelete, outerSpacing = true }) => {
|
|
2285
|
+
var listGrid = "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]";
|
|
2286
|
+
var listItemGrid = "grid grid-cols-subgrid col-span-5";
|
|
2287
|
+
var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode = "schema", registry, readonly, showHeading = false, onQueryChanged, onDelete, outerSpacing = true }, forwardedRef) => {
|
|
2152
2288
|
var _effect = _useSignals15();
|
|
2153
2289
|
try {
|
|
2154
|
-
const
|
|
2155
|
-
const
|
|
2290
|
+
const schemaReadonly = !isMutable(schema);
|
|
2291
|
+
const { t } = useTranslation10(translationKey);
|
|
2292
|
+
const projectionModel = useMemo8(() => {
|
|
2156
2293
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2157
2294
|
return new ProjectionModel(jsonSchema, view.projection);
|
|
2158
2295
|
}, [
|
|
2159
2296
|
schema,
|
|
2160
|
-
view.projection
|
|
2297
|
+
JSON.stringify(view.projection)
|
|
2161
2298
|
]);
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
const viewValues = useMemo8(() => {
|
|
2165
|
-
return {
|
|
2166
|
-
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
2167
|
-
// TODO(burdon): Settings should have domain name owned by user.
|
|
2168
|
-
typename: view.query.typename
|
|
2169
|
-
};
|
|
2170
|
-
}, [
|
|
2171
|
-
view.query.typename
|
|
2299
|
+
useImperativeHandle(forwardedRef, () => projectionModel, [
|
|
2300
|
+
projectionModel
|
|
2172
2301
|
]);
|
|
2173
|
-
const
|
|
2174
|
-
|
|
2175
|
-
|
|
2302
|
+
const [expandedField, setExpandedField] = useState7();
|
|
2303
|
+
const serializedQuery = Match.value(mode).pipe(Match.when("schema", () => getTypenameFromQuery(view.query.ast)), Match.when("query", () => {
|
|
2304
|
+
if (view.query.string) {
|
|
2305
|
+
return view.query.string;
|
|
2306
|
+
} else {
|
|
2307
|
+
return "Serializing query AST is not currently supported.";
|
|
2176
2308
|
}
|
|
2177
|
-
|
|
2309
|
+
}), Match.exhaustive);
|
|
2310
|
+
const queueTarget = Match.value(view.query.ast).pipe(Match.when({
|
|
2311
|
+
type: "options"
|
|
2312
|
+
}, ({ options }) => {
|
|
2313
|
+
return Option.fromNullable(options.queues).pipe(Option.flatMap((queues) => Array2.head(queues)), Option.getOrUndefined);
|
|
2314
|
+
}), Match.orElse(() => void 0));
|
|
2315
|
+
const viewSchema = useMemo8(() => {
|
|
2316
|
+
const base = Schema2.Struct({
|
|
2317
|
+
query: mode === "schema" ? Format.URL.annotations({
|
|
2318
|
+
title: "Record type"
|
|
2319
|
+
}) : Schema2.String.annotations({
|
|
2320
|
+
title: "Query"
|
|
2321
|
+
})
|
|
2322
|
+
});
|
|
2323
|
+
if (mode === "query") {
|
|
2324
|
+
return Schema2.Struct({
|
|
2325
|
+
name: Schema2.optional(Schema2.String.annotations({
|
|
2326
|
+
title: "Name"
|
|
2327
|
+
})),
|
|
2328
|
+
...base.fields,
|
|
2329
|
+
target: Schema2.optional(Schema2.String.annotations({
|
|
2330
|
+
title: "Target Queue"
|
|
2331
|
+
}))
|
|
2332
|
+
}).pipe(Schema2.mutable);
|
|
2333
|
+
}
|
|
2334
|
+
return base.pipe(Schema2.mutable);
|
|
2335
|
+
}, [
|
|
2336
|
+
mode
|
|
2337
|
+
]);
|
|
2338
|
+
const viewValues = useMemo8(() => ({
|
|
2339
|
+
name: view.name,
|
|
2340
|
+
query: serializedQuery,
|
|
2341
|
+
target: queueTarget
|
|
2342
|
+
}), [
|
|
2343
|
+
view.name,
|
|
2344
|
+
serializedQuery,
|
|
2345
|
+
queueTarget
|
|
2346
|
+
]);
|
|
2347
|
+
const handleToggleField = useCallback12((field) => {
|
|
2348
|
+
setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
|
|
2178
2349
|
}, [
|
|
2179
2350
|
readonly
|
|
2180
2351
|
]);
|
|
2181
|
-
const handleAdd =
|
|
2352
|
+
const handleAdd = useCallback12(() => {
|
|
2182
2353
|
invariant3(!readonly, void 0, {
|
|
2183
2354
|
F: __dxlog_file5,
|
|
2184
|
-
L:
|
|
2355
|
+
L: 144,
|
|
2185
2356
|
S: void 0,
|
|
2186
2357
|
A: [
|
|
2187
2358
|
"!readonly",
|
|
2188
2359
|
""
|
|
2189
2360
|
]
|
|
2190
2361
|
});
|
|
2191
|
-
const
|
|
2192
|
-
|
|
2362
|
+
const field = projectionModel.createFieldProjection();
|
|
2363
|
+
setExpandedField(field.id);
|
|
2193
2364
|
}, [
|
|
2194
2365
|
schema,
|
|
2195
|
-
|
|
2366
|
+
projectionModel,
|
|
2196
2367
|
readonly
|
|
2197
2368
|
]);
|
|
2198
|
-
const handleUpdate =
|
|
2369
|
+
const handleUpdate = useCallback12((values) => {
|
|
2199
2370
|
invariant3(!readonly, void 0, {
|
|
2200
2371
|
F: __dxlog_file5,
|
|
2201
|
-
L:
|
|
2372
|
+
L: 151,
|
|
2202
2373
|
S: void 0,
|
|
2203
2374
|
A: [
|
|
2204
2375
|
"!readonly",
|
|
@@ -2206,38 +2377,46 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2206
2377
|
]
|
|
2207
2378
|
});
|
|
2208
2379
|
requestAnimationFrame(() => {
|
|
2209
|
-
if (view.
|
|
2210
|
-
|
|
2380
|
+
if ("name" in values && view.name !== values.name) {
|
|
2381
|
+
view.name = values.name;
|
|
2382
|
+
}
|
|
2383
|
+
const queryChanged = serializedQuery !== values.query;
|
|
2384
|
+
const targetValue = "target" in values ? values.target : void 0;
|
|
2385
|
+
const targetChanged = "target" in values && values.target && queueTarget !== targetValue;
|
|
2386
|
+
if ((queryChanged || targetChanged) && !readonly) {
|
|
2387
|
+
onQueryChanged?.(values.query, targetValue);
|
|
2211
2388
|
}
|
|
2212
2389
|
});
|
|
2213
2390
|
}, [
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
readonly
|
|
2391
|
+
serializedQuery,
|
|
2392
|
+
onQueryChanged,
|
|
2393
|
+
readonly,
|
|
2394
|
+
view,
|
|
2395
|
+
queueTarget
|
|
2217
2396
|
]);
|
|
2218
|
-
const handleDelete =
|
|
2397
|
+
const handleDelete = useCallback12((fieldId) => {
|
|
2219
2398
|
invariant3(!readonly, void 0, {
|
|
2220
2399
|
F: __dxlog_file5,
|
|
2221
|
-
L:
|
|
2400
|
+
L: 171,
|
|
2222
2401
|
S: void 0,
|
|
2223
2402
|
A: [
|
|
2224
2403
|
"!readonly",
|
|
2225
2404
|
""
|
|
2226
2405
|
]
|
|
2227
2406
|
});
|
|
2228
|
-
if (fieldId ===
|
|
2229
|
-
|
|
2407
|
+
if (fieldId === expandedField) {
|
|
2408
|
+
setExpandedField(void 0);
|
|
2230
2409
|
}
|
|
2231
2410
|
onDelete?.(fieldId);
|
|
2232
2411
|
}, [
|
|
2233
|
-
|
|
2412
|
+
expandedField,
|
|
2234
2413
|
onDelete,
|
|
2235
2414
|
readonly
|
|
2236
2415
|
]);
|
|
2237
|
-
const handleMove =
|
|
2416
|
+
const handleMove = useCallback12((fromIndex, toIndex) => {
|
|
2238
2417
|
invariant3(!readonly, void 0, {
|
|
2239
2418
|
F: __dxlog_file5,
|
|
2240
|
-
L:
|
|
2419
|
+
L: 183,
|
|
2241
2420
|
S: void 0,
|
|
2242
2421
|
A: [
|
|
2243
2422
|
"!readonly",
|
|
@@ -2254,95 +2433,99 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2254
2433
|
view.projection.fields,
|
|
2255
2434
|
readonly
|
|
2256
2435
|
]);
|
|
2257
|
-
const handleClose =
|
|
2258
|
-
const
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
projection.hideFieldProjection(fieldId);
|
|
2436
|
+
const handleClose = useCallback12(() => setExpandedField(void 0), []);
|
|
2437
|
+
const handleHide = useCallback12((fieldId) => {
|
|
2438
|
+
setExpandedField(void 0);
|
|
2439
|
+
projectionModel.hideFieldProjection(fieldId);
|
|
2262
2440
|
}, [
|
|
2263
|
-
|
|
2441
|
+
projectionModel
|
|
2264
2442
|
]);
|
|
2265
|
-
const handleShow =
|
|
2266
|
-
|
|
2267
|
-
|
|
2443
|
+
const handleShow = useCallback12((property) => {
|
|
2444
|
+
setExpandedField(void 0);
|
|
2445
|
+
projectionModel.showFieldProjection(property);
|
|
2268
2446
|
}, [
|
|
2269
|
-
|
|
2447
|
+
projectionModel
|
|
2270
2448
|
]);
|
|
2271
2449
|
return /* @__PURE__ */ React15.createElement("div", {
|
|
2272
2450
|
role: "none",
|
|
2273
|
-
className:
|
|
2274
|
-
},
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2451
|
+
className: mx7(classNames)
|
|
2452
|
+
}, schemaReadonly && mode === "schema" && /* @__PURE__ */ React15.createElement(Callout.Root, {
|
|
2453
|
+
valence: "info",
|
|
2454
|
+
classNames: [
|
|
2455
|
+
"mlb-cardSpacingBlock",
|
|
2456
|
+
outerSpacing && "mli-cardSpacingInline"
|
|
2457
|
+
]
|
|
2458
|
+
}, /* @__PURE__ */ React15.createElement(Callout.Title, null, t("system schema description"))), /* @__PURE__ */ React15.createElement(Form, {
|
|
2280
2459
|
autoSave: true,
|
|
2281
|
-
schema:
|
|
2460
|
+
schema: viewSchema,
|
|
2282
2461
|
values: viewValues,
|
|
2283
|
-
readonly,
|
|
2462
|
+
readonly: readonly ? "disabled-input" : false,
|
|
2284
2463
|
onSave: handleUpdate,
|
|
2285
|
-
outerSpacing
|
|
2464
|
+
outerSpacing,
|
|
2465
|
+
Custom: mode === "query" ? customFields : void 0
|
|
2286
2466
|
}), /* @__PURE__ */ React15.createElement("div", {
|
|
2287
2467
|
role: "none",
|
|
2288
2468
|
className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
|
|
2289
|
-
}, /* @__PURE__ */ React15.createElement("
|
|
2290
|
-
className:
|
|
2469
|
+
}, /* @__PURE__ */ React15.createElement("h2", {
|
|
2470
|
+
className: mx7(inputTextLabel)
|
|
2291
2471
|
}, t("fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
2292
2472
|
items: view.projection.fields,
|
|
2293
2473
|
isItem: Schema2.is(FieldSchema),
|
|
2294
|
-
getId: (
|
|
2295
|
-
readonly,
|
|
2296
|
-
|
|
2297
|
-
}, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
}, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement("div", {
|
|
2301
|
-
className: "flex items-center text-sm"
|
|
2302
|
-
}, t("field path label"))), /* @__PURE__ */ React15.createElement("div", {
|
|
2303
|
-
role: "list",
|
|
2304
|
-
className: "flex flex-col is-full"
|
|
2305
|
-
}, fields?.map((field2) => /* @__PURE__ */ React15.createElement(List2.Item, {
|
|
2306
|
-
key: field2.id,
|
|
2307
|
-
item: field2,
|
|
2308
|
-
classNames: mx9(grid, ghostHover, "overflow-hidden", !readonly && "cursor-pointer")
|
|
2309
|
-
}, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
|
|
2310
|
-
onClick: () => handleSelect(field2)
|
|
2311
|
-
}, field2.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2312
|
-
"data-testid": "hide-field-button",
|
|
2313
|
-
icon: "ph--eye-slash--regular",
|
|
2314
|
-
// TDOO(burdon): Is this the correct test?
|
|
2315
|
-
disabled: view.projection.fields.length <= 1,
|
|
2316
|
-
onClick: () => handleHide(field2.id)
|
|
2317
|
-
}), !readonly && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2318
|
-
disabled: view.projection.fields.length <= 1,
|
|
2319
|
-
onClick: () => handleDelete(field2.id)
|
|
2320
|
-
})))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement("label", {
|
|
2321
|
-
className: mx9(inputTextLabel)
|
|
2322
|
-
}, t("hidden fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
2323
|
-
items: hiddenProperties,
|
|
2324
|
-
isItem: (item) => typeof item === "string",
|
|
2325
|
-
getId: (property) => property
|
|
2326
|
-
}, ({ items: properties }) => /* @__PURE__ */ React15.createElement("div", {
|
|
2474
|
+
getId: (field) => field.id,
|
|
2475
|
+
onMove: readonly ? void 0 : handleMove,
|
|
2476
|
+
readonly
|
|
2477
|
+
}, ({ items: fields }) => /* @__PURE__ */ React15.createElement(React15.Fragment, null, showHeading && /* @__PURE__ */ React15.createElement("h3", {
|
|
2478
|
+
className: "text-sm"
|
|
2479
|
+
}, t("field path label")), /* @__PURE__ */ React15.createElement("div", {
|
|
2327
2480
|
role: "list",
|
|
2328
|
-
className:
|
|
2329
|
-
},
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2481
|
+
className: listGrid
|
|
2482
|
+
}, fields?.map((field) => {
|
|
2483
|
+
const hidden = field.visible === false;
|
|
2484
|
+
return /* @__PURE__ */ React15.createElement(List2.Item, {
|
|
2485
|
+
key: field.id,
|
|
2486
|
+
item: field,
|
|
2487
|
+
classNames: listItemGrid,
|
|
2488
|
+
"aria-expanded": expandedField === field.id
|
|
2489
|
+
}, /* @__PURE__ */ React15.createElement("div", {
|
|
2490
|
+
role: "none",
|
|
2491
|
+
className: mx7(subtleHover2, listItemGrid, "rounded-sm cursor-pointer min-bs-10")
|
|
2492
|
+
}, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, {
|
|
2493
|
+
disabled: readonly
|
|
2494
|
+
}), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
|
|
2495
|
+
classNames: hidden && "text-subdued",
|
|
2496
|
+
onClick: () => handleToggleField(field)
|
|
2497
|
+
}, field.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2498
|
+
label: t(hidden ? "show field label" : "hide field label"),
|
|
2499
|
+
"data-testid": hidden ? "show-field-button" : "hide-field-button",
|
|
2500
|
+
icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
|
|
2501
|
+
autoHide: false,
|
|
2502
|
+
disabled: readonly || !hidden && projectionModel.fields.length <= 1,
|
|
2503
|
+
onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
|
|
2504
|
+
}), mode === "schema" && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2505
|
+
label: t("delete field label"),
|
|
2506
|
+
autoHide: false,
|
|
2507
|
+
disabled: readonly || schemaReadonly || view.projection.fields.length <= 1,
|
|
2508
|
+
onClick: () => handleDelete(field.id),
|
|
2509
|
+
"data-testid": "field.delete"
|
|
2510
|
+
}), /* @__PURE__ */ React15.createElement(IconButton4, {
|
|
2511
|
+
iconOnly: true,
|
|
2512
|
+
variant: "ghost",
|
|
2513
|
+
label: t("toggle expand label", {
|
|
2514
|
+
ns: "os"
|
|
2515
|
+
}),
|
|
2516
|
+
icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
2517
|
+
onClick: () => handleToggleField(field)
|
|
2518
|
+
}))), expandedField === field.id && mode === "schema" && /* @__PURE__ */ React15.createElement("div", {
|
|
2519
|
+
role: "none",
|
|
2520
|
+
className: "col-span-5 mbs-1 mbe-1 border border-separator rounded-md"
|
|
2521
|
+
}, /* @__PURE__ */ React15.createElement(FieldEditor, {
|
|
2522
|
+
readonly: readonly || schemaReadonly ? "disabled-input" : false,
|
|
2523
|
+
projection: projectionModel,
|
|
2524
|
+
field,
|
|
2525
|
+
registry,
|
|
2526
|
+
onSave: handleClose
|
|
2527
|
+
})));
|
|
2528
|
+
}))))), !readonly && !expandedField && mode === "schema" && /* @__PURE__ */ React15.createElement("div", {
|
|
2346
2529
|
role: "none",
|
|
2347
2530
|
className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
|
|
2348
2531
|
}, /* @__PURE__ */ React15.createElement(IconButton4, {
|
|
@@ -2351,11 +2534,45 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2351
2534
|
onClick: readonly ? void 0 : handleAdd,
|
|
2352
2535
|
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2353
2536
|
disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2354
|
-
classNames: "
|
|
2537
|
+
classNames: "is-full"
|
|
2355
2538
|
})));
|
|
2356
2539
|
} finally {
|
|
2357
2540
|
_effect.f();
|
|
2358
2541
|
}
|
|
2542
|
+
});
|
|
2543
|
+
var customFields = {
|
|
2544
|
+
query: (props) => {
|
|
2545
|
+
const { themeMode } = useThemeContext();
|
|
2546
|
+
const { t } = useTranslation10(translationKey);
|
|
2547
|
+
const density = useDensityContext();
|
|
2548
|
+
const elevation = useElevationContext();
|
|
2549
|
+
const onValueChange = useRef4(props.onValueChange);
|
|
2550
|
+
useEffect9(() => {
|
|
2551
|
+
onValueChange.current = props.onValueChange;
|
|
2552
|
+
}, [
|
|
2553
|
+
props.onValueChange
|
|
2554
|
+
]);
|
|
2555
|
+
const handleChange = useCallback12((text) => onValueChange.current("string", text), []);
|
|
2556
|
+
const extensions = useMemo8(() => [
|
|
2557
|
+
createBasicExtensions({
|
|
2558
|
+
placeholder: t("query placeholder")
|
|
2559
|
+
}),
|
|
2560
|
+
createThemeExtensions({
|
|
2561
|
+
themeMode
|
|
2562
|
+
})
|
|
2563
|
+
], []);
|
|
2564
|
+
return /* @__PURE__ */ React15.createElement(Input8.Root, null, /* @__PURE__ */ React15.createElement(InputHeader, {
|
|
2565
|
+
label: props.label
|
|
2566
|
+
}), /* @__PURE__ */ React15.createElement(Editor, {
|
|
2567
|
+
classNames: mx7(inputTheme.input({
|
|
2568
|
+
density,
|
|
2569
|
+
elevation
|
|
2570
|
+
}), "flex items-center", "focus-within:bg-focusSurface focus-within:border-separator focus-within:hover:bg-focusSurface"),
|
|
2571
|
+
extensions,
|
|
2572
|
+
value: props.getValue(),
|
|
2573
|
+
onChange: handleChange
|
|
2574
|
+
}));
|
|
2575
|
+
}
|
|
2359
2576
|
};
|
|
2360
2577
|
export {
|
|
2361
2578
|
BooleanInput,
|
|
@@ -2368,8 +2585,6 @@ export {
|
|
|
2368
2585
|
ControlPage,
|
|
2369
2586
|
ControlSection,
|
|
2370
2587
|
ControlSectionHeading,
|
|
2371
|
-
DeprecatedFormContainer,
|
|
2372
|
-
DeprecatedFormInput,
|
|
2373
2588
|
FieldEditor,
|
|
2374
2589
|
Form,
|
|
2375
2590
|
FormProvider,
|
|
@@ -2377,6 +2592,7 @@ export {
|
|
|
2377
2592
|
InputHeader,
|
|
2378
2593
|
MarkdownInput,
|
|
2379
2594
|
NumberInput,
|
|
2595
|
+
ObjectPicker,
|
|
2380
2596
|
SelectInput,
|
|
2381
2597
|
SelectOptionInput,
|
|
2382
2598
|
TextInput,
|