@dxos/react-ui-form 0.8.4-main.84f28bd → 0.8.4-main.a4bbb77
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 +710 -553
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +710 -553
- 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 +4 -5
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +78 -7
- 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 +5 -4
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +128 -31
- 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 +16 -10
- package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContext.d.ts +2 -2
- package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
- package/dist/types/src/components/Form/Input.d.ts +4 -1
- package/dist/types/src/components/Form/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/RefField.d.ts +13 -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.map +1 -1
- 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 +80 -8
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -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 +1 -1
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueryRefOptions.d.ts +7 -2
- 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.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -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 +25 -23
- package/src/components/FieldEditor/FieldEditor.test.tsx +14 -13
- package/src/components/FieldEditor/FieldEditor.tsx +21 -23
- package/src/components/Form/ArrayField.tsx +9 -9
- package/src/components/Form/Defaults.tsx +22 -20
- package/src/components/Form/Form.stories.tsx +133 -97
- package/src/components/Form/Form.tsx +16 -12
- package/src/components/Form/FormActions.tsx +2 -1
- package/src/components/Form/FormContent.tsx +116 -36
- package/src/components/Form/FormContext.tsx +6 -6
- package/src/components/Form/Input.tsx +4 -1
- package/src/components/Form/RefField.tsx +190 -40
- package/src/components/Form/custom/GeoPointInput.tsx +29 -21
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +10 -10
- package/src/components/Form/custom/SelectOptionsInput.tsx +29 -30
- package/src/components/Form/custom/TupleInput.tsx +2 -2
- package/src/components/Form/factory.tsx +1 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +110 -46
- package/src/components/ViewEditor/ViewEditor.test.tsx +17 -18
- package/src/components/ViewEditor/ViewEditor.tsx +329 -235
- package/src/components/index.ts +0 -2
- package/src/components/testing.tsx +15 -9
- package/src/hooks/useForm.ts +6 -3
- package/src/hooks/useQueryRefOptions.ts +8 -2
- package/src/hooks/useRefQueryLookupHandler.ts +1 -1
- package/src/translations.ts +13 -6
- package/src/util/field.ts +8 -18
- 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,37 @@ 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
|
-
className: "flex w-full gap-4 py-1"
|
|
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
|
+
classNames: "block overflow-y-auto [--control-spacing:var(--dx-trimMd)]"
|
|
107
87
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
108
88
|
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),
|
|
89
|
+
className: mx("pli-cardSpacingInline pbe-trimLg", classNames),
|
|
133
90
|
...props
|
|
134
|
-
}, children);
|
|
91
|
+
}, children));
|
|
135
92
|
} finally {
|
|
136
93
|
_effect.f();
|
|
137
94
|
}
|
|
138
95
|
};
|
|
139
96
|
var ControlSection = ({ title, description, children }) => {
|
|
140
|
-
var _effect =
|
|
97
|
+
var _effect = _useSignals();
|
|
141
98
|
try {
|
|
142
|
-
return /* @__PURE__ */
|
|
99
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ControlSectionHeading, {
|
|
143
100
|
title,
|
|
144
101
|
description
|
|
145
102
|
}), children);
|
|
@@ -148,12 +105,12 @@ var ControlSection = ({ title, description, children }) => {
|
|
|
148
105
|
}
|
|
149
106
|
};
|
|
150
107
|
var ControlSectionHeading = ({ title, description }) => {
|
|
151
|
-
var _effect =
|
|
108
|
+
var _effect = _useSignals();
|
|
152
109
|
try {
|
|
153
110
|
const { t } = useTranslation(translationKey);
|
|
154
|
-
return /* @__PURE__ */
|
|
111
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", {
|
|
155
112
|
className: "pli-trimMd container-max-width text-xl mbs-trimLg mbe-trimMd"
|
|
156
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */
|
|
113
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
157
114
|
className: "pli-trimMd mlb-trimMd container-max-width text-description"
|
|
158
115
|
}, toLocalizedString(description, t)));
|
|
159
116
|
} finally {
|
|
@@ -161,9 +118,9 @@ var ControlSectionHeading = ({ title, description }) => {
|
|
|
161
118
|
}
|
|
162
119
|
};
|
|
163
120
|
var ControlGroupButton = ({ classNames, ...props }) => {
|
|
164
|
-
var _effect =
|
|
121
|
+
var _effect = _useSignals();
|
|
165
122
|
try {
|
|
166
|
-
return /* @__PURE__ */
|
|
123
|
+
return /* @__PURE__ */ React.createElement(Button, {
|
|
167
124
|
...props,
|
|
168
125
|
classNames: [
|
|
169
126
|
"md:col-span-2",
|
|
@@ -175,41 +132,46 @@ var ControlGroupButton = ({ classNames, ...props }) => {
|
|
|
175
132
|
}
|
|
176
133
|
};
|
|
177
134
|
var ControlGroup = ({ children, classNames }) => {
|
|
178
|
-
var _effect =
|
|
135
|
+
var _effect = _useSignals();
|
|
179
136
|
try {
|
|
180
|
-
return /* @__PURE__ */
|
|
137
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
181
138
|
role: "none",
|
|
182
|
-
className:
|
|
139
|
+
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
140
|
}, children);
|
|
184
141
|
} finally {
|
|
185
142
|
_effect.f();
|
|
186
143
|
}
|
|
187
144
|
};
|
|
188
145
|
var ControlFrame = ({ children }) => {
|
|
189
|
-
var _effect =
|
|
146
|
+
var _effect = _useSignals();
|
|
190
147
|
try {
|
|
191
|
-
return /* @__PURE__ */
|
|
148
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
192
149
|
role: "none",
|
|
193
|
-
className: "
|
|
150
|
+
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
151
|
}, children);
|
|
195
152
|
} finally {
|
|
196
153
|
_effect.f();
|
|
197
154
|
}
|
|
198
155
|
};
|
|
199
|
-
var controlItemClasses =
|
|
200
|
-
|
|
201
|
-
|
|
156
|
+
var controlItemClasses = mx([
|
|
157
|
+
"container-max-width grid md:col-span-2 grid-cols-subgrid gap-trimSm items-center",
|
|
158
|
+
// TODO(burdon): Use grid gap consistently or apply margins consistently?
|
|
159
|
+
"mlb-[--control-spacing] *:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd",
|
|
160
|
+
"border border-separator rounded-md"
|
|
161
|
+
]);
|
|
162
|
+
var controlItemTitleClasses = "mbe-0 text-lg text-baseText font-normal";
|
|
163
|
+
var controlItemDescriptionClasses = "mlb-trimSm md:mbe-0 text-base text-description";
|
|
202
164
|
var ControlItem = ({ title, description, children }) => {
|
|
203
|
-
var _effect =
|
|
165
|
+
var _effect = _useSignals();
|
|
204
166
|
try {
|
|
205
167
|
const { t } = useTranslation(translationKey);
|
|
206
|
-
return /* @__PURE__ */
|
|
168
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
207
169
|
className: controlItemClasses
|
|
208
|
-
}, /* @__PURE__ */
|
|
170
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
209
171
|
role: "none"
|
|
210
|
-
}, /* @__PURE__ */
|
|
172
|
+
}, /* @__PURE__ */ React.createElement("h3", {
|
|
211
173
|
className: controlItemTitleClasses
|
|
212
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */
|
|
174
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
213
175
|
className: controlItemDescriptionClasses
|
|
214
176
|
}, toLocalizedString(description, t))), children);
|
|
215
177
|
} finally {
|
|
@@ -217,16 +179,16 @@ var ControlItem = ({ title, description, children }) => {
|
|
|
217
179
|
}
|
|
218
180
|
};
|
|
219
181
|
var ControlItemInput = ({ title, description, children }) => {
|
|
220
|
-
var _effect =
|
|
182
|
+
var _effect = _useSignals();
|
|
221
183
|
try {
|
|
222
184
|
const { t } = useTranslation(translationKey);
|
|
223
|
-
return /* @__PURE__ */
|
|
185
|
+
return /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
|
|
224
186
|
className: controlItemClasses
|
|
225
|
-
}, /* @__PURE__ */
|
|
187
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
226
188
|
role: "none"
|
|
227
|
-
}, /* @__PURE__ */
|
|
189
|
+
}, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
228
190
|
classNames: controlItemTitleClasses
|
|
229
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */
|
|
191
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Description, {
|
|
230
192
|
classNames: controlItemDescriptionClasses
|
|
231
193
|
}, toLocalizedString(description, t)))), children));
|
|
232
194
|
} finally {
|
|
@@ -234,15 +196,15 @@ var ControlItemInput = ({ title, description, children }) => {
|
|
|
234
196
|
}
|
|
235
197
|
};
|
|
236
198
|
var ControlFrameItem = ({ title, description, children }) => {
|
|
237
|
-
var _effect =
|
|
199
|
+
var _effect = _useSignals();
|
|
238
200
|
try {
|
|
239
201
|
const { t } = useTranslation(translationKey);
|
|
240
|
-
return /* @__PURE__ */
|
|
202
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
241
203
|
role: "group",
|
|
242
204
|
className: "min-is-0"
|
|
243
|
-
}, /* @__PURE__ */
|
|
205
|
+
}, /* @__PURE__ */ React.createElement("h3", {
|
|
244
206
|
className: "text-lg mbe-2"
|
|
245
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */
|
|
207
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
246
208
|
className: "mlb-trimSm md:mbe-0 text-description"
|
|
247
209
|
}, toLocalizedString(description, t)), children);
|
|
248
210
|
} finally {
|
|
@@ -251,41 +213,41 @@ var ControlFrameItem = ({ title, description, children }) => {
|
|
|
251
213
|
};
|
|
252
214
|
|
|
253
215
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
254
|
-
import { useSignals as
|
|
255
|
-
import
|
|
216
|
+
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
217
|
+
import React13, { useCallback as useCallback9, useEffect as useEffect8, useMemo as useMemo7, useState as useState6 } from "react";
|
|
256
218
|
import { FormatEnum as FormatEnum5, FormatEnums, formatToType } from "@dxos/echo-schema";
|
|
257
219
|
import { log as log3 } from "@dxos/log";
|
|
258
|
-
import { useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
259
|
-
import { getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
|
|
220
|
+
import { useAsyncEffect, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
221
|
+
import { formatToAdditionalPropertyAttributes, getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
|
|
260
222
|
|
|
261
223
|
// src/components/Form/custom/GeoPointInput.tsx
|
|
262
|
-
import { useSignals as
|
|
263
|
-
import
|
|
224
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
225
|
+
import React3, { useCallback, useEffect, useMemo, useState } from "react";
|
|
264
226
|
import { GeoLocation } from "@dxos/echo-schema";
|
|
265
|
-
import { Input as
|
|
227
|
+
import { Input as Input3, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
266
228
|
import { safeParseFloat } from "@dxos/util";
|
|
267
229
|
|
|
268
230
|
// src/components/Form/Input.tsx
|
|
269
|
-
import { useSignals as
|
|
270
|
-
import
|
|
271
|
-
import { Icon, Input as
|
|
231
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
232
|
+
import React2 from "react";
|
|
233
|
+
import { Icon, Input as Input2, Tooltip } from "@dxos/react-ui";
|
|
272
234
|
import { labelSpacing } from "@dxos/react-ui-stack";
|
|
273
|
-
import { errorText, mx as
|
|
235
|
+
import { errorText, mx as mx2 } from "@dxos/react-ui-theme";
|
|
274
236
|
var InputHeader = ({ error, label, readonly }) => {
|
|
275
|
-
var _effect =
|
|
237
|
+
var _effect = _useSignals2();
|
|
276
238
|
try {
|
|
277
|
-
const Label = readonly ? "span" :
|
|
239
|
+
const Label = readonly ? "span" : Input2.Label;
|
|
278
240
|
const labelProps = readonly ? {} : {
|
|
279
241
|
classNames: "!mlb-0"
|
|
280
242
|
};
|
|
281
|
-
return /* @__PURE__ */
|
|
243
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
282
244
|
role: "none",
|
|
283
|
-
className:
|
|
284
|
-
}, /* @__PURE__ */
|
|
245
|
+
className: mx2("flex justify-between items-center", labelSpacing)
|
|
246
|
+
}, /* @__PURE__ */ React2.createElement(Label, labelProps, label), error && /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
|
|
285
247
|
asChild: true,
|
|
286
248
|
content: error,
|
|
287
249
|
side: "bottom"
|
|
288
|
-
}, /* @__PURE__ */
|
|
250
|
+
}, /* @__PURE__ */ React2.createElement(Icon, {
|
|
289
251
|
icon: "ph--warning--regular",
|
|
290
252
|
size: 4,
|
|
291
253
|
classNames: errorText
|
|
@@ -296,8 +258,8 @@ var InputHeader = ({ error, label, readonly }) => {
|
|
|
296
258
|
};
|
|
297
259
|
|
|
298
260
|
// src/components/Form/custom/GeoPointInput.tsx
|
|
299
|
-
var GeoPointInput = ({ type, label,
|
|
300
|
-
var _effect =
|
|
261
|
+
var GeoPointInput = ({ type, label, readonly, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
262
|
+
var _effect = _useSignals3();
|
|
301
263
|
try {
|
|
302
264
|
const { t } = useTranslation2(translationKey);
|
|
303
265
|
const { status, error } = getStatus();
|
|
@@ -342,46 +304,52 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
342
304
|
onValueChange,
|
|
343
305
|
type
|
|
344
306
|
]);
|
|
345
|
-
return /* @__PURE__ */
|
|
307
|
+
return /* @__PURE__ */ React3.createElement(Input3.Root, {
|
|
346
308
|
validationValence: status
|
|
347
|
-
}, /* @__PURE__ */
|
|
309
|
+
}, /* @__PURE__ */ React3.createElement(InputHeader, {
|
|
348
310
|
error,
|
|
349
311
|
label
|
|
350
|
-
}), /* @__PURE__ */
|
|
312
|
+
}), /* @__PURE__ */ React3.createElement("div", {
|
|
351
313
|
role: "none",
|
|
352
314
|
className: "grid grid-cols-2 gap-2"
|
|
353
|
-
}, /* @__PURE__ */
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
315
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
316
|
+
role: "none"
|
|
317
|
+
}, /* @__PURE__ */ React3.createElement(Input3.Label, null, t("latitude label")), /* @__PURE__ */ React3.createElement(Input3.TextInput, {
|
|
318
|
+
type: "number",
|
|
319
|
+
step: "0.00001",
|
|
320
|
+
min: "-90",
|
|
321
|
+
max: "90",
|
|
322
|
+
disabled: !!readonly,
|
|
358
323
|
value: latitudeText,
|
|
359
324
|
onChange: handleCoordinateChange("latitude", setLatitudeText),
|
|
360
325
|
onBlur
|
|
361
|
-
}), /* @__PURE__ */
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
326
|
+
})), /* @__PURE__ */ React3.createElement("div", {
|
|
327
|
+
role: "none"
|
|
328
|
+
}, /* @__PURE__ */ React3.createElement(Input3.Label, null, t("longitude label")), /* @__PURE__ */ React3.createElement(Input3.TextInput, {
|
|
329
|
+
type: "number",
|
|
330
|
+
step: "0.00001",
|
|
331
|
+
min: "-180",
|
|
332
|
+
max: "180",
|
|
333
|
+
disabled: !!readonly,
|
|
366
334
|
value: longitudeText,
|
|
367
335
|
onChange: handleCoordinateChange("longitude", setLongitudeText),
|
|
368
336
|
onBlur
|
|
369
|
-
})));
|
|
337
|
+
}))));
|
|
370
338
|
} finally {
|
|
371
339
|
_effect.f();
|
|
372
340
|
}
|
|
373
341
|
};
|
|
374
342
|
|
|
375
343
|
// src/components/Form/custom/SelectOptionsInput.tsx
|
|
376
|
-
import { useSignals as
|
|
377
|
-
import
|
|
344
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
345
|
+
import React4, { useCallback as useCallback2, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
378
346
|
import { PublicKey } from "@dxos/keys";
|
|
379
|
-
import {
|
|
347
|
+
import { IconButton, Input as Input4, Tag, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
380
348
|
import { List } from "@dxos/react-ui-list";
|
|
381
349
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
382
|
-
import { hues,
|
|
383
|
-
var SelectOptionInput = ({ type, label,
|
|
384
|
-
var _effect =
|
|
350
|
+
import { hues, subtleHover } from "@dxos/react-ui-theme";
|
|
351
|
+
var SelectOptionInput = ({ type, label, readonly, getStatus, getValue: getValue3, onValueChange }) => {
|
|
352
|
+
var _effect = _useSignals4();
|
|
385
353
|
try {
|
|
386
354
|
const [selected, setSelectedId] = useState2(null);
|
|
387
355
|
const [isNewOption, setIsNewOption] = useState2(false);
|
|
@@ -489,44 +457,56 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
489
457
|
selected,
|
|
490
458
|
isNewOption
|
|
491
459
|
]);
|
|
492
|
-
return /* @__PURE__ */
|
|
460
|
+
return /* @__PURE__ */ React4.createElement(Input4.Root, {
|
|
493
461
|
validationValence: status
|
|
494
|
-
}, /* @__PURE__ */
|
|
462
|
+
}, /* @__PURE__ */ React4.createElement(InputHeader, {
|
|
495
463
|
error,
|
|
496
464
|
label
|
|
497
|
-
}), /* @__PURE__ */
|
|
465
|
+
}), /* @__PURE__ */ React4.createElement("div", {
|
|
498
466
|
role: "none"
|
|
499
|
-
}, options && /* @__PURE__ */
|
|
467
|
+
}, options && /* @__PURE__ */ React4.createElement(List.Root, {
|
|
500
468
|
items: options,
|
|
501
469
|
isItem: (item) => true,
|
|
502
|
-
onMove: handleMove
|
|
503
|
-
|
|
470
|
+
onMove: readonly ? void 0 : handleMove,
|
|
471
|
+
readonly: !!readonly
|
|
472
|
+
}, ({ items }) => /* @__PURE__ */ React4.createElement("div", {
|
|
504
473
|
role: "list",
|
|
505
474
|
className: "w-full overflow-auto"
|
|
506
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
475
|
+
}, items?.map((item) => /* @__PURE__ */ React4.createElement("div", {
|
|
507
476
|
key: item.id
|
|
508
|
-
}, /* @__PURE__ */
|
|
477
|
+
}, /* @__PURE__ */ React4.createElement(List.Item, {
|
|
509
478
|
role: "button",
|
|
510
479
|
item,
|
|
511
|
-
classNames:
|
|
480
|
+
classNames: [
|
|
481
|
+
subtleHover,
|
|
482
|
+
"flex flex-col cursor-pointer rounded-sm"
|
|
483
|
+
],
|
|
512
484
|
"aria-expanded": selected === item.id
|
|
513
|
-
}, /* @__PURE__ */
|
|
485
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
514
486
|
className: "flex items-center"
|
|
515
|
-
}, /* @__PURE__ */
|
|
487
|
+
}, /* @__PURE__ */ React4.createElement(List.ItemDragHandle, {
|
|
488
|
+
disabled: !!readonly
|
|
489
|
+
}), /* @__PURE__ */ React4.createElement(List.ItemTitle, {
|
|
516
490
|
onClick: () => handleClick(item.id),
|
|
517
491
|
classNames: "flex-1"
|
|
518
|
-
}, /* @__PURE__ */
|
|
492
|
+
}, /* @__PURE__ */ React4.createElement(Tag, {
|
|
519
493
|
palette: item.color
|
|
520
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
494
|
+
}, item.title || "\u200B")), /* @__PURE__ */ React4.createElement(IconButton, {
|
|
495
|
+
iconOnly: true,
|
|
496
|
+
variant: "ghost",
|
|
497
|
+
label: t(selected === item.id ? "collapse label" : "expand label", {
|
|
498
|
+
ns: "os"
|
|
499
|
+
}),
|
|
521
500
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
522
501
|
onClick: () => handleClick(item.id)
|
|
523
|
-
})), selected === item.id && /* @__PURE__ */
|
|
524
|
-
className: "
|
|
525
|
-
}, /* @__PURE__ */
|
|
502
|
+
})), selected === item.id && /* @__PURE__ */ React4.createElement("div", {
|
|
503
|
+
className: "pli-cardSpacingInline plb-cardSpacingBlock flex flex-col gap-1 density-fine"
|
|
504
|
+
}, /* @__PURE__ */ React4.createElement(Input4.Label, {
|
|
526
505
|
classNames: "text-xs"
|
|
527
|
-
}, t("select option label")), /* @__PURE__ */
|
|
528
|
-
className: "
|
|
529
|
-
}, /* @__PURE__ */
|
|
506
|
+
}, t("select option label")), /* @__PURE__ */ React4.createElement("div", {
|
|
507
|
+
className: "grid grid-cols-[1fr_min-content_min-content] gap-1"
|
|
508
|
+
}, /* @__PURE__ */ React4.createElement(Input4.TextInput, {
|
|
509
|
+
disabled: !!readonly,
|
|
530
510
|
placeholder: t("select option label placeholder"),
|
|
531
511
|
ref: selected === item.id ? inputRef : void 0,
|
|
532
512
|
value: item.title,
|
|
@@ -534,40 +514,34 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
534
514
|
onKeyDown: handleKeyDown,
|
|
535
515
|
classNames: "flex-1",
|
|
536
516
|
"data-no-submit": true
|
|
537
|
-
}), /* @__PURE__ */
|
|
538
|
-
|
|
539
|
-
}, /* @__PURE__ */ React5.createElement(HuePicker, {
|
|
517
|
+
}), /* @__PURE__ */ React4.createElement(HuePicker, {
|
|
518
|
+
disabled: !!readonly,
|
|
540
519
|
value: item.color,
|
|
541
|
-
onChange: handleColorChange(item.id)
|
|
542
|
-
|
|
543
|
-
|
|
520
|
+
onChange: handleColorChange(item.id)
|
|
521
|
+
}), /* @__PURE__ */ React4.createElement(IconButton, {
|
|
522
|
+
disabled: !!readonly,
|
|
544
523
|
icon: "ph--trash--fill",
|
|
545
524
|
iconOnly: true,
|
|
546
525
|
label: t("select option delete"),
|
|
547
526
|
onClick: () => handleDelete(item.id)
|
|
548
|
-
})))))), /* @__PURE__ */
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}, /* @__PURE__ */ React5.createElement(Icon2, {
|
|
557
|
-
icon: "ph--plus--regular"
|
|
558
|
-
}), /* @__PURE__ */ React5.createElement("span", {
|
|
559
|
-
className: "text-sm"
|
|
560
|
-
}, t("select option add")))))))));
|
|
527
|
+
})))))), /* @__PURE__ */ React4.createElement(IconButton, {
|
|
528
|
+
variant: "ghost",
|
|
529
|
+
icon: "ph--plus--regular",
|
|
530
|
+
label: t("select option add"),
|
|
531
|
+
onClick: handleAdd,
|
|
532
|
+
disabled: !!readonly,
|
|
533
|
+
classNames: "is-full"
|
|
534
|
+
})))));
|
|
561
535
|
} finally {
|
|
562
536
|
_effect.f();
|
|
563
537
|
}
|
|
564
538
|
};
|
|
565
539
|
|
|
566
540
|
// src/components/Form/custom/TupleInput.tsx
|
|
567
|
-
import { useSignals as
|
|
568
|
-
import
|
|
569
|
-
import { Input as
|
|
570
|
-
import { mx as
|
|
541
|
+
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
542
|
+
import React5 from "react";
|
|
543
|
+
import { Input as Input5 } from "@dxos/react-ui";
|
|
544
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
571
545
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
572
546
|
var gridCols = [
|
|
573
547
|
"grid-cols-1",
|
|
@@ -575,22 +549,22 @@ var gridCols = [
|
|
|
575
549
|
"grid-cols-3",
|
|
576
550
|
"grid-cols-4"
|
|
577
551
|
];
|
|
578
|
-
var TupleInput = ({ binding, type, label,
|
|
579
|
-
var _effect =
|
|
552
|
+
var TupleInput = ({ binding, type, label, readonly, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
553
|
+
var _effect = _useSignals5();
|
|
580
554
|
try {
|
|
581
555
|
const { status, error } = getStatus();
|
|
582
556
|
const values = getValue3() ?? {};
|
|
583
|
-
return /* @__PURE__ */
|
|
557
|
+
return /* @__PURE__ */ React5.createElement(Input5.Root, {
|
|
584
558
|
validationValence: status
|
|
585
|
-
}, /* @__PURE__ */
|
|
559
|
+
}, /* @__PURE__ */ React5.createElement(InputHeader, {
|
|
586
560
|
error,
|
|
587
561
|
label
|
|
588
|
-
}), /* @__PURE__ */
|
|
589
|
-
className:
|
|
590
|
-
}, binding.map((prop) => /* @__PURE__ */
|
|
562
|
+
}), /* @__PURE__ */ React5.createElement("div", {
|
|
563
|
+
className: mx3("grid gap-2", gridCols[binding.length - 1])
|
|
564
|
+
}, binding.map((prop) => /* @__PURE__ */ React5.createElement(Input5.TextInput, {
|
|
591
565
|
key: prop,
|
|
592
566
|
type: "number",
|
|
593
|
-
disabled,
|
|
567
|
+
disabled: !!readonly,
|
|
594
568
|
value: values[prop],
|
|
595
569
|
onChange: (event) => onValueChange(type, {
|
|
596
570
|
...values,
|
|
@@ -604,71 +578,72 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
|
|
|
604
578
|
};
|
|
605
579
|
|
|
606
580
|
// src/components/Form/Defaults.tsx
|
|
607
|
-
import { useSignals as
|
|
608
|
-
import
|
|
609
|
-
import { Input as
|
|
610
|
-
var TextInput = ({ type, label, inputOnly,
|
|
611
|
-
var _effect =
|
|
581
|
+
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
582
|
+
import React6, { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
583
|
+
import { Input as Input6, Select, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
584
|
+
var TextInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
585
|
+
var _effect = _useSignals6();
|
|
612
586
|
try {
|
|
613
587
|
const { status, error } = getStatus();
|
|
614
|
-
return
|
|
588
|
+
return readonly && !getValue3() ? null : readonly === "static" && inputOnly ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
615
589
|
validationValence: status
|
|
616
|
-
}, !inputOnly && /* @__PURE__ */
|
|
590
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
617
591
|
error,
|
|
618
592
|
label
|
|
619
|
-
}),
|
|
620
|
-
disabled,
|
|
593
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextInput, {
|
|
594
|
+
disabled: !!readonly,
|
|
621
595
|
placeholder,
|
|
622
596
|
value: getValue3() ?? "",
|
|
623
597
|
onChange: (event) => onValueChange(type, event.target.value),
|
|
624
598
|
onBlur
|
|
625
|
-
}), inputOnly && /* @__PURE__ */
|
|
599
|
+
}), inputOnly && /* @__PURE__ */ React6.createElement(Input6.Validation, null, error));
|
|
626
600
|
} finally {
|
|
627
601
|
_effect.f();
|
|
628
602
|
}
|
|
629
603
|
};
|
|
630
|
-
var NumberInput = ({ type, label, inputOnly,
|
|
631
|
-
var _effect =
|
|
604
|
+
var NumberInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
605
|
+
var _effect = _useSignals6();
|
|
632
606
|
try {
|
|
633
607
|
const { status, error } = getStatus();
|
|
634
|
-
return
|
|
608
|
+
return readonly && !getValue3() ? null : readonly === "static" && inputOnly ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
635
609
|
validationValence: status
|
|
636
|
-
}, !inputOnly && /* @__PURE__ */
|
|
610
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
637
611
|
error,
|
|
638
612
|
label
|
|
639
|
-
}),
|
|
613
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextInput, {
|
|
640
614
|
type: "number",
|
|
641
|
-
disabled,
|
|
615
|
+
disabled: !!readonly,
|
|
642
616
|
placeholder,
|
|
643
|
-
value: getValue3()
|
|
617
|
+
value: getValue3(),
|
|
644
618
|
onChange: (event) => onValueChange(type, event.target.value),
|
|
645
619
|
onBlur
|
|
646
|
-
}), inputOnly && /* @__PURE__ */
|
|
620
|
+
}), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
|
|
647
621
|
} finally {
|
|
648
622
|
_effect.f();
|
|
649
623
|
}
|
|
650
624
|
};
|
|
651
|
-
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange,
|
|
652
|
-
var _effect =
|
|
625
|
+
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange, readonly }) => {
|
|
626
|
+
var _effect = _useSignals6();
|
|
653
627
|
try {
|
|
654
628
|
const { status, error } = getStatus();
|
|
655
629
|
const checked = Boolean(getValue3());
|
|
656
630
|
const { t } = useTranslation4(translationKey);
|
|
657
|
-
return /* @__PURE__ */
|
|
631
|
+
return /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
658
632
|
validationValence: status
|
|
659
|
-
}, !inputOnly && /* @__PURE__ */
|
|
633
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
660
634
|
error,
|
|
661
635
|
label
|
|
662
|
-
}),
|
|
636
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ React6.createElement(Input6.Switch, {
|
|
637
|
+
disabled: !!readonly,
|
|
663
638
|
checked,
|
|
664
639
|
onCheckedChange: (value) => onValueChange(type, value)
|
|
665
|
-
}), inputOnly && /* @__PURE__ */
|
|
640
|
+
}), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
|
|
666
641
|
} finally {
|
|
667
642
|
_effect.f();
|
|
668
643
|
}
|
|
669
644
|
};
|
|
670
|
-
var SelectInput = ({ type, label, inputOnly,
|
|
671
|
-
var _effect =
|
|
645
|
+
var SelectInput = ({ type, label, inputOnly, readonly, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
646
|
+
var _effect = _useSignals6();
|
|
672
647
|
try {
|
|
673
648
|
const { status, error } = getStatus();
|
|
674
649
|
const value = getValue3();
|
|
@@ -676,31 +651,31 @@ var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, get
|
|
|
676
651
|
type,
|
|
677
652
|
onValueChange
|
|
678
653
|
]);
|
|
679
|
-
return
|
|
654
|
+
return readonly && !value ? null : /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
680
655
|
validationValence: status
|
|
681
|
-
}, !inputOnly && /* @__PURE__ */
|
|
656
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
682
657
|
error,
|
|
683
658
|
label
|
|
684
|
-
}),
|
|
659
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)) : /* @__PURE__ */ React6.createElement(Select.Root, {
|
|
685
660
|
value,
|
|
686
661
|
onValueChange: handleValueChange
|
|
687
|
-
}, /* @__PURE__ */
|
|
662
|
+
}, /* @__PURE__ */ React6.createElement(Select.TriggerButton, {
|
|
688
663
|
classNames: "is-full",
|
|
689
|
-
disabled,
|
|
664
|
+
disabled: !!readonly,
|
|
690
665
|
placeholder
|
|
691
|
-
}), /* @__PURE__ */
|
|
666
|
+
}), /* @__PURE__ */ React6.createElement(Select.Portal, null, /* @__PURE__ */ React6.createElement(Select.Content, null, /* @__PURE__ */ React6.createElement(Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
|
|
692
667
|
// NOTE: Numeric values are converted to and from strings.
|
|
693
|
-
/* @__PURE__ */
|
|
668
|
+
/* @__PURE__ */ React6.createElement(Select.Option, {
|
|
694
669
|
key: String(value2),
|
|
695
670
|
value: String(value2)
|
|
696
671
|
}, label2 ?? String(value2))
|
|
697
|
-
)))))), inputOnly && /* @__PURE__ */
|
|
672
|
+
))), /* @__PURE__ */ React6.createElement(Select.Arrow, null)))), inputOnly && /* @__PURE__ */ React6.createElement(Input6.DescriptionAndValidation, null, error));
|
|
698
673
|
} finally {
|
|
699
674
|
_effect.f();
|
|
700
675
|
}
|
|
701
676
|
};
|
|
702
|
-
var MarkdownInput = ({ type, label, inputOnly,
|
|
703
|
-
var _effect =
|
|
677
|
+
var MarkdownInput = ({ type, label, inputOnly, readonly, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
678
|
+
var _effect = _useSignals6();
|
|
704
679
|
try {
|
|
705
680
|
const { status, error } = getStatus();
|
|
706
681
|
const textareaRef = useRef2(null);
|
|
@@ -722,14 +697,14 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
722
697
|
getValue3(),
|
|
723
698
|
adjustHeight
|
|
724
699
|
]);
|
|
725
|
-
return /* @__PURE__ */
|
|
700
|
+
return /* @__PURE__ */ React6.createElement(Input6.Root, {
|
|
726
701
|
validationValence: status
|
|
727
|
-
}, !inputOnly && /* @__PURE__ */
|
|
702
|
+
}, !inputOnly && /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
728
703
|
error,
|
|
729
704
|
label
|
|
730
|
-
}),
|
|
705
|
+
}), readonly === "static" ? /* @__PURE__ */ React6.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ React6.createElement(Input6.TextArea, {
|
|
731
706
|
ref: textareaRef,
|
|
732
|
-
disabled,
|
|
707
|
+
disabled: !!readonly,
|
|
733
708
|
placeholder,
|
|
734
709
|
value: getValue3() ?? "",
|
|
735
710
|
classNames: "min-bs-auto max-h-40 overflow-auto",
|
|
@@ -739,27 +714,28 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
739
714
|
resize: "none"
|
|
740
715
|
},
|
|
741
716
|
spellCheck: false
|
|
742
|
-
}), inputOnly && /* @__PURE__ */
|
|
717
|
+
}), inputOnly && /* @__PURE__ */ React6.createElement(Input6.Validation, null, error));
|
|
743
718
|
} finally {
|
|
744
719
|
_effect.f();
|
|
745
720
|
}
|
|
746
721
|
};
|
|
747
722
|
|
|
748
723
|
// src/components/Form/Form.tsx
|
|
749
|
-
import { useSignals as
|
|
750
|
-
import
|
|
724
|
+
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
725
|
+
import { useFocusFinders } from "@fluentui/react-tabster";
|
|
726
|
+
import React12, { useEffect as useEffect7, useMemo as useMemo6, useRef as useRef3 } from "react";
|
|
751
727
|
import { cardDialogOverflow, cardSpacing as cardSpacing2 } from "@dxos/react-ui-stack";
|
|
752
728
|
|
|
753
729
|
// src/components/Form/FormActions.tsx
|
|
754
|
-
import { useSignals as
|
|
755
|
-
import
|
|
730
|
+
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
731
|
+
import React8 from "react";
|
|
756
732
|
import { IconButton as IconButton2, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
757
733
|
import { cardSpacing } from "@dxos/react-ui-stack";
|
|
758
|
-
import { mx as
|
|
734
|
+
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
759
735
|
|
|
760
736
|
// src/components/Form/FormContext.tsx
|
|
761
|
-
import { useSignals as
|
|
762
|
-
import
|
|
737
|
+
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
738
|
+
import React7, { createContext, useCallback as useCallback6, useContext, useEffect as useEffect6, useMemo as useMemo3 } from "react";
|
|
763
739
|
import { raise } from "@dxos/debug";
|
|
764
740
|
import { getValue as getValue2 } from "@dxos/echo-schema";
|
|
765
741
|
import { createJsonPath as createJsonPath2 } from "@dxos/effect";
|
|
@@ -776,7 +752,7 @@ var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.t
|
|
|
776
752
|
var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
|
|
777
753
|
invariant(SchemaAST.isTypeLiteral(schema.ast), void 0, {
|
|
778
754
|
F: __dxlog_file,
|
|
779
|
-
L:
|
|
755
|
+
L: 95,
|
|
780
756
|
S: void 0,
|
|
781
757
|
A: [
|
|
782
758
|
"SchemaAST.isTypeLiteral(schema.ast)",
|
|
@@ -880,7 +856,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
880
856
|
} catch (err) {
|
|
881
857
|
log.catch(err, void 0, {
|
|
882
858
|
F: __dxlog_file,
|
|
883
|
-
L:
|
|
859
|
+
L: 216,
|
|
884
860
|
S: void 0,
|
|
885
861
|
C: (f, a) => f(...a)
|
|
886
862
|
});
|
|
@@ -951,7 +927,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
951
927
|
var createKeySet = (obj, value) => {
|
|
952
928
|
invariant(obj, void 0, {
|
|
953
929
|
F: __dxlog_file,
|
|
954
|
-
L:
|
|
930
|
+
L: 278,
|
|
955
931
|
S: void 0,
|
|
956
932
|
A: [
|
|
957
933
|
"obj",
|
|
@@ -1027,7 +1003,7 @@ var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
|
|
|
1027
1003
|
} catch (error) {
|
|
1028
1004
|
log2.error("Failed to fetch ref options:", error, {
|
|
1029
1005
|
F: __dxlog_file2,
|
|
1030
|
-
L:
|
|
1006
|
+
L: 48,
|
|
1031
1007
|
S: void 0,
|
|
1032
1008
|
C: (f, a) => f(...a)
|
|
1033
1009
|
});
|
|
@@ -1076,7 +1052,7 @@ var useInputProps = (path = []) => {
|
|
|
1076
1052
|
]);
|
|
1077
1053
|
};
|
|
1078
1054
|
var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
1079
|
-
var _effect =
|
|
1055
|
+
var _effect = _useSignals7();
|
|
1080
1056
|
try {
|
|
1081
1057
|
const form = useForm(formOptions);
|
|
1082
1058
|
const handleKeyDown = useCallback6((event) => {
|
|
@@ -1112,7 +1088,7 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1112
1088
|
form.handleSave,
|
|
1113
1089
|
autoSave
|
|
1114
1090
|
]);
|
|
1115
|
-
return /* @__PURE__ */
|
|
1091
|
+
return /* @__PURE__ */ React7.createElement(FormContext.Provider, {
|
|
1116
1092
|
value: form
|
|
1117
1093
|
}, children);
|
|
1118
1094
|
} finally {
|
|
@@ -1122,19 +1098,19 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1122
1098
|
|
|
1123
1099
|
// src/components/Form/FormActions.tsx
|
|
1124
1100
|
var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
|
|
1125
|
-
var _effect =
|
|
1101
|
+
var _effect = _useSignals8();
|
|
1126
1102
|
try {
|
|
1127
1103
|
const { t } = useTranslation5(translationKey);
|
|
1128
1104
|
const { canSave, handleSave } = useFormContext();
|
|
1129
|
-
return /* @__PURE__ */
|
|
1105
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1130
1106
|
role: "none",
|
|
1131
|
-
className:
|
|
1132
|
-
}, onCancel && !readonly && /* @__PURE__ */
|
|
1107
|
+
className: mx4(outerSpacing === "scroll-fields" ? "pli-cardSpacingInline mbe-cardSpacingBlock" : outerSpacing ? cardSpacing : "mbs-cardSpacingBlock", "flex [&_button]:grow gap-1 first:mbs-0")
|
|
1108
|
+
}, onCancel && !readonly && /* @__PURE__ */ React8.createElement(IconButton2, {
|
|
1133
1109
|
"data-testid": "cancel-button",
|
|
1134
1110
|
icon: "ph--x--regular",
|
|
1135
1111
|
label: t("button cancel"),
|
|
1136
1112
|
onClick: onCancel
|
|
1137
|
-
}), handleSave && /* @__PURE__ */
|
|
1113
|
+
}), handleSave && /* @__PURE__ */ React8.createElement(IconButton2, {
|
|
1138
1114
|
type: "submit",
|
|
1139
1115
|
"data-testid": "save-button",
|
|
1140
1116
|
disabled: !canSave,
|
|
@@ -1148,24 +1124,14 @@ var FormActions = ({ readonly, onCancel, outerSpacing = true }) => {
|
|
|
1148
1124
|
};
|
|
1149
1125
|
|
|
1150
1126
|
// src/components/Form/FormContent.tsx
|
|
1151
|
-
import { useSignals as
|
|
1127
|
+
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1152
1128
|
import { Schema, SchemaAST as SchemaAST4, pipe as pipe2 } from "effect";
|
|
1153
1129
|
import { capitalize as capitalize2 } from "effect/String";
|
|
1154
|
-
import
|
|
1130
|
+
import React11, { forwardRef, useMemo as useMemo5 } from "react";
|
|
1155
1131
|
import { createJsonPath as createJsonPath3, findNode as findNode3, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
|
|
1156
|
-
import { mx as
|
|
1132
|
+
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
1157
1133
|
import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
|
|
1158
|
-
import {
|
|
1159
|
-
|
|
1160
|
-
// src/components/Form/ArrayField.tsx
|
|
1161
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1162
|
-
import { SchemaAST as SchemaAST3, pipe } from "effect";
|
|
1163
|
-
import { capitalize } from "effect/String";
|
|
1164
|
-
import React10, { Fragment, useCallback as useCallback7 } from "react";
|
|
1165
|
-
import { findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from "@dxos/effect";
|
|
1166
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1167
|
-
import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1168
|
-
import { getSchemaProperties } from "@dxos/schema";
|
|
1134
|
+
import { isTruthy } from "@dxos/util";
|
|
1169
1135
|
|
|
1170
1136
|
// src/util/field.ts
|
|
1171
1137
|
import { FormatEnum, GeoLocation as GeoLocation2, TypeEnum } from "@dxos/echo-schema";
|
|
@@ -1248,28 +1214,7 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1248
1214
|
}
|
|
1249
1215
|
};
|
|
1250
1216
|
var cellClassesForFieldType = ({ type, format }) => {
|
|
1251
|
-
|
|
1252
|
-
switch (type) {
|
|
1253
|
-
case TypeEnum.Number:
|
|
1254
|
-
return [
|
|
1255
|
-
"text-right",
|
|
1256
|
-
"font-mono"
|
|
1257
|
-
];
|
|
1258
|
-
case TypeEnum.Boolean:
|
|
1259
|
-
return [
|
|
1260
|
-
"text-right",
|
|
1261
|
-
"font-mono"
|
|
1262
|
-
];
|
|
1263
|
-
case TypeEnum.String:
|
|
1264
|
-
return void 0;
|
|
1265
|
-
case TypeEnum.Ref:
|
|
1266
|
-
return void 0;
|
|
1267
|
-
default: {
|
|
1268
|
-
return void 0;
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
switch (format) {
|
|
1217
|
+
switch (format || type) {
|
|
1273
1218
|
case FormatEnum.Markdown:
|
|
1274
1219
|
return void 0;
|
|
1275
1220
|
case FormatEnum.Time:
|
|
@@ -1290,6 +1235,16 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1290
1235
|
return [
|
|
1291
1236
|
"font-mono"
|
|
1292
1237
|
];
|
|
1238
|
+
case TypeEnum.Number:
|
|
1239
|
+
case TypeEnum.Boolean:
|
|
1240
|
+
return [
|
|
1241
|
+
"text-right",
|
|
1242
|
+
"font-mono"
|
|
1243
|
+
];
|
|
1244
|
+
case TypeEnum.String:
|
|
1245
|
+
return void 0;
|
|
1246
|
+
case TypeEnum.Ref:
|
|
1247
|
+
return void 0;
|
|
1293
1248
|
default:
|
|
1294
1249
|
return void 0;
|
|
1295
1250
|
}
|
|
@@ -1475,9 +1430,17 @@ var getRefProps = (property) => {
|
|
|
1475
1430
|
};
|
|
1476
1431
|
|
|
1477
1432
|
// src/components/Form/ArrayField.tsx
|
|
1433
|
+
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1434
|
+
import { SchemaAST as SchemaAST3, pipe } from "effect";
|
|
1435
|
+
import { capitalize } from "effect/String";
|
|
1436
|
+
import React9, { Fragment, useCallback as useCallback7 } from "react";
|
|
1437
|
+
import { SimpleType, findNode as findNode2, getDiscriminatedType, isDiscriminatedUnion } from "@dxos/effect";
|
|
1438
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
1439
|
+
import { IconButton as IconButton3, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1440
|
+
import { getSchemaProperties } from "@dxos/schema";
|
|
1478
1441
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
1479
1442
|
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
1480
|
-
var _effect =
|
|
1443
|
+
var _effect = _useSignals9();
|
|
1481
1444
|
try {
|
|
1482
1445
|
const { t } = useTranslation6(translationKey);
|
|
1483
1446
|
const { ast, name, type, title } = property;
|
|
@@ -1527,14 +1490,14 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1527
1490
|
if (!elementType) {
|
|
1528
1491
|
return null;
|
|
1529
1492
|
}
|
|
1530
|
-
return readonly && values.length < 1 ? null : /* @__PURE__ */
|
|
1493
|
+
return readonly && values.length < 1 ? null : /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(InputHeader, {
|
|
1531
1494
|
readonly: true,
|
|
1532
1495
|
label
|
|
1533
|
-
}), /* @__PURE__ */
|
|
1496
|
+
}), /* @__PURE__ */ React9.createElement("div", {
|
|
1534
1497
|
role: "none",
|
|
1535
1498
|
className: readonly ? "flex flex-wrap gap-1 mlb-1" : values.length > 0 ? "grid gap-1 grid-cols-[1fr_min-content] mlb-1" : "hidden"
|
|
1536
1499
|
}, values.map((_value, index) => {
|
|
1537
|
-
const field = /* @__PURE__ */
|
|
1500
|
+
const field = /* @__PURE__ */ React9.createElement(FormField, {
|
|
1538
1501
|
property: {
|
|
1539
1502
|
...property,
|
|
1540
1503
|
array: false,
|
|
@@ -1549,19 +1512,19 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1549
1512
|
Custom,
|
|
1550
1513
|
lookupComponent
|
|
1551
1514
|
});
|
|
1552
|
-
return readonly ? field : /* @__PURE__ */
|
|
1515
|
+
return readonly ? field : /* @__PURE__ */ React9.createElement(Fragment, {
|
|
1553
1516
|
key: index
|
|
1554
|
-
}, /* @__PURE__ */
|
|
1517
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
1555
1518
|
role: "none"
|
|
1556
|
-
}, field), /* @__PURE__ */
|
|
1519
|
+
}, field), /* @__PURE__ */ React9.createElement(IconButton3, {
|
|
1557
1520
|
icon: "ph--trash--regular",
|
|
1558
1521
|
iconOnly: true,
|
|
1559
1522
|
label: t("button remove"),
|
|
1560
1523
|
onClick: () => handleRemove(index),
|
|
1561
1524
|
classNames: "self-center"
|
|
1562
1525
|
}));
|
|
1563
|
-
})), !readonly && /* @__PURE__ */
|
|
1564
|
-
classNames: "is-full mlb-
|
|
1526
|
+
})), !readonly && /* @__PURE__ */ React9.createElement(IconButton3, {
|
|
1527
|
+
classNames: "is-full mlb-cardSpacingBlock flex",
|
|
1565
1528
|
icon: "ph--plus--regular",
|
|
1566
1529
|
label: t("add field"),
|
|
1567
1530
|
onClick: handleAdd
|
|
@@ -1571,19 +1534,41 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1571
1534
|
}
|
|
1572
1535
|
};
|
|
1573
1536
|
|
|
1537
|
+
// src/components/Form/factory.tsx
|
|
1538
|
+
import { FormatEnum as FormatEnum4 } from "@dxos/echo-schema";
|
|
1539
|
+
var getInputComponent = (type, format) => {
|
|
1540
|
+
switch (format) {
|
|
1541
|
+
case FormatEnum4.GeoPoint:
|
|
1542
|
+
return GeoPointInput;
|
|
1543
|
+
case FormatEnum4.Markdown:
|
|
1544
|
+
return MarkdownInput;
|
|
1545
|
+
}
|
|
1546
|
+
switch (type) {
|
|
1547
|
+
case "string":
|
|
1548
|
+
return TextInput;
|
|
1549
|
+
case "number":
|
|
1550
|
+
return NumberInput;
|
|
1551
|
+
case "boolean":
|
|
1552
|
+
return BooleanInput;
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1574
1556
|
// src/components/Form/RefField.tsx
|
|
1575
|
-
import { useSignals as
|
|
1576
|
-
import
|
|
1577
|
-
import { Expando,
|
|
1557
|
+
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1558
|
+
import React10, { useCallback as useCallback8, useMemo as useMemo4, useState as useState5 } from "react";
|
|
1559
|
+
import { Expando, Ref, ReferenceAnnotationId as ReferenceAnnotationId2, getTypeAnnotation } from "@dxos/echo-schema";
|
|
1578
1560
|
import { findAnnotation as findAnnotation2 } from "@dxos/effect";
|
|
1579
1561
|
import { DXN } from "@dxos/keys";
|
|
1580
|
-
import {
|
|
1581
|
-
import { Input as
|
|
1582
|
-
import {
|
|
1583
|
-
import { descriptionText, mx as
|
|
1562
|
+
import { DxAnchor, DxTagPickerItem } from "@dxos/lit-ui/react";
|
|
1563
|
+
import { Button as Button2, Icon as Icon2, Input as Input7, Popover, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1564
|
+
import { PopoverCombobox } from "@dxos/react-ui-searchlist";
|
|
1565
|
+
import { descriptionText, mx as mx5 } from "@dxos/react-ui-theme";
|
|
1584
1566
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
1585
|
-
var
|
|
1586
|
-
|
|
1567
|
+
var isRefSnapShot = (val) => {
|
|
1568
|
+
return typeof val === "object" && typeof val?.["/"] === "string";
|
|
1569
|
+
};
|
|
1570
|
+
var RefField = ({ type, label, readonly, placeholder, inputOnly, array, ast, getValue: getValue3, createOptionLabel, createOptionIcon, onBlur, onCreate, createSchema, createInitialValuePath, onQueryRefOptions, onValueChange, ...restInputProps }) => {
|
|
1571
|
+
var _effect = _useSignals10();
|
|
1587
1572
|
try {
|
|
1588
1573
|
const { t } = useTranslation7(translationKey);
|
|
1589
1574
|
const refTypeInfo = useMemo4(() => ast ? findAnnotation2(ast, ReferenceAnnotationId2) : void 0, [
|
|
@@ -1593,12 +1578,44 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1593
1578
|
refTypeInfo,
|
|
1594
1579
|
onQueryRefOptions
|
|
1595
1580
|
});
|
|
1581
|
+
const [showForm, setShowForm] = useState5(false);
|
|
1582
|
+
const [searchString, setSearchString] = useState5("");
|
|
1583
|
+
const handleFormSave = useCallback8((values) => {
|
|
1584
|
+
onCreate?.(values);
|
|
1585
|
+
setShowForm(false);
|
|
1586
|
+
setSearchString("");
|
|
1587
|
+
}, [
|
|
1588
|
+
refTypeInfo,
|
|
1589
|
+
onCreate
|
|
1590
|
+
]);
|
|
1591
|
+
const handleFormCancel = useCallback8(() => {
|
|
1592
|
+
setShowForm(false);
|
|
1593
|
+
setSearchString("");
|
|
1594
|
+
}, []);
|
|
1595
|
+
const handleClick = useCallback8((event) => {
|
|
1596
|
+
if (createSchema && event.target.closest('[data-value="__create__"]')) {
|
|
1597
|
+
event.stopPropagation();
|
|
1598
|
+
event.preventDefault();
|
|
1599
|
+
setShowForm(true);
|
|
1600
|
+
}
|
|
1601
|
+
}, [
|
|
1602
|
+
createSchema
|
|
1603
|
+
]);
|
|
1604
|
+
const handleKeyDown = useCallback8((event) => {
|
|
1605
|
+
if (event.key === "Enter" && createSchema && event.currentTarget.querySelector('[role="option"][aria-selected="true"][data-value="__create__"]')) {
|
|
1606
|
+
event.stopPropagation();
|
|
1607
|
+
event.preventDefault();
|
|
1608
|
+
setShowForm(true);
|
|
1609
|
+
}
|
|
1610
|
+
}, [
|
|
1611
|
+
createSchema
|
|
1612
|
+
]);
|
|
1596
1613
|
if (refTypeInfo && refTypeInfo?.typename === getTypeAnnotation(Expando)?.typename || !onQueryRefOptions) {
|
|
1597
|
-
return /* @__PURE__ */
|
|
1614
|
+
return /* @__PURE__ */ React10.createElement(RefFieldFallback, {
|
|
1598
1615
|
type,
|
|
1599
1616
|
label,
|
|
1600
1617
|
placeholder,
|
|
1601
|
-
|
|
1618
|
+
readonly,
|
|
1602
1619
|
inputOnly,
|
|
1603
1620
|
getValue: getValue3,
|
|
1604
1621
|
onBlur,
|
|
@@ -1609,8 +1626,9 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1609
1626
|
const handleGetValue = useCallback8(() => {
|
|
1610
1627
|
const formValue = getValue3();
|
|
1611
1628
|
const unknownToRefOption = (val) => {
|
|
1612
|
-
|
|
1613
|
-
|
|
1629
|
+
const isRef = Ref.isRef(val);
|
|
1630
|
+
if (isRef || isRefSnapShot(val)) {
|
|
1631
|
+
const dxnString = isRef ? val.dxn.toString() : val["/"];
|
|
1614
1632
|
const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
|
|
1615
1633
|
if (matchingOption) {
|
|
1616
1634
|
return matchingOption;
|
|
@@ -1633,13 +1651,6 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1633
1651
|
availableOptions,
|
|
1634
1652
|
array
|
|
1635
1653
|
]);
|
|
1636
|
-
const handleSearch = useCallback8((text, ids) => availableOptions.filter((option) => !ids.includes(option.id)).filter((option) => option.label.toLowerCase().includes(text.toLowerCase())).map((option) => ({
|
|
1637
|
-
id: option.id,
|
|
1638
|
-
label: option.label,
|
|
1639
|
-
hue: option.hue
|
|
1640
|
-
})), [
|
|
1641
|
-
availableOptions
|
|
1642
|
-
]);
|
|
1643
1654
|
const handleUpdate = useCallback8((ids) => {
|
|
1644
1655
|
if (ids.length === 0) {
|
|
1645
1656
|
onValueChange("object", void 0);
|
|
@@ -1663,45 +1674,123 @@ var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, get
|
|
|
1663
1674
|
array,
|
|
1664
1675
|
onValueChange
|
|
1665
1676
|
]);
|
|
1666
|
-
const tagPickerMode = useMemo4(() => array ? "multi-select" : "single-select", [
|
|
1667
|
-
array
|
|
1668
|
-
]);
|
|
1669
1677
|
if (!refTypeInfo) {
|
|
1670
1678
|
return null;
|
|
1671
1679
|
}
|
|
1672
1680
|
const { status, error } = restInputProps.getStatus();
|
|
1673
1681
|
const items = handleGetValue();
|
|
1674
|
-
|
|
1682
|
+
const selectedIds = useMemo4(() => items.map((i) => i.id), [
|
|
1683
|
+
items
|
|
1684
|
+
]);
|
|
1685
|
+
const labelById = useMemo4(() => availableOptions.reduce((acc, option) => {
|
|
1686
|
+
acc[option.id.toLowerCase()] = option.label.toLowerCase();
|
|
1687
|
+
return acc;
|
|
1688
|
+
}, {}), [
|
|
1689
|
+
availableOptions
|
|
1690
|
+
]);
|
|
1691
|
+
const toggleSelect = useCallback8((id) => {
|
|
1692
|
+
if (array) {
|
|
1693
|
+
const nextIds = selectedIds.includes(id) ? selectedIds.filter((x) => x !== id) : [
|
|
1694
|
+
...selectedIds,
|
|
1695
|
+
id
|
|
1696
|
+
];
|
|
1697
|
+
handleUpdate(nextIds);
|
|
1698
|
+
} else {
|
|
1699
|
+
if (selectedIds[0] === id) {
|
|
1700
|
+
handleUpdate([]);
|
|
1701
|
+
} else {
|
|
1702
|
+
handleUpdate([
|
|
1703
|
+
id
|
|
1704
|
+
]);
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
}, [
|
|
1708
|
+
array,
|
|
1709
|
+
selectedIds,
|
|
1710
|
+
handleUpdate
|
|
1711
|
+
]);
|
|
1712
|
+
return readonly && items.length < 1 ? null : /* @__PURE__ */ React10.createElement(Input7.Root, {
|
|
1675
1713
|
validationValence: status
|
|
1676
|
-
}, !inputOnly && /* @__PURE__ */
|
|
1714
|
+
}, !inputOnly && /* @__PURE__ */ React10.createElement(InputHeader, {
|
|
1677
1715
|
error,
|
|
1678
1716
|
label
|
|
1679
|
-
}), /* @__PURE__ */
|
|
1717
|
+
}), /* @__PURE__ */ React10.createElement("div", {
|
|
1680
1718
|
"data-no-submit": true
|
|
1681
|
-
},
|
|
1682
|
-
className:
|
|
1683
|
-
}, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */
|
|
1719
|
+
}, readonly ? items.length < 1 ? /* @__PURE__ */ React10.createElement("p", {
|
|
1720
|
+
className: mx5(descriptionText, "mbe-2")
|
|
1721
|
+
}, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ React10.createElement(DxAnchor, {
|
|
1684
1722
|
key: item.id,
|
|
1685
1723
|
refid: item.id,
|
|
1686
|
-
rootclassname: "mie-1"
|
|
1687
|
-
|
|
1688
|
-
|
|
1724
|
+
rootclassname: "mie-1"
|
|
1725
|
+
}, item.label)) : /* @__PURE__ */ React10.createElement(PopoverCombobox.Root, null, /* @__PURE__ */ React10.createElement(PopoverCombobox.Trigger, {
|
|
1726
|
+
asChild: true
|
|
1727
|
+
}, /* @__PURE__ */ React10.createElement(Button2, {
|
|
1728
|
+
variant: "ghost",
|
|
1729
|
+
classNames: "is-full text-start gap-2"
|
|
1730
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
1731
|
+
role: "none",
|
|
1732
|
+
className: "grow"
|
|
1733
|
+
}, items?.length ? items?.map((item) => /* @__PURE__ */ React10.createElement(DxTagPickerItem, {
|
|
1734
|
+
key: item.id,
|
|
1735
|
+
itemId: item.id,
|
|
1736
|
+
label: item.label,
|
|
1737
|
+
...item.hue ? {
|
|
1738
|
+
hue: item.hue
|
|
1739
|
+
} : {},
|
|
1740
|
+
removeLabel: t("remove item label"),
|
|
1741
|
+
onItemClick: (event) => {
|
|
1742
|
+
if (event.action === "remove") {
|
|
1743
|
+
toggleSelect(item.id);
|
|
1744
|
+
}
|
|
1689
1745
|
}
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1746
|
+
})) : /* @__PURE__ */ React10.createElement("span", {
|
|
1747
|
+
className: "text-description"
|
|
1748
|
+
}, placeholder ?? t("ref field placeholder", {
|
|
1749
|
+
count: array ? 99 : 1
|
|
1750
|
+
}))), /* @__PURE__ */ React10.createElement(Icon2, {
|
|
1751
|
+
size: 3,
|
|
1752
|
+
icon: "ph--caret-down--bold"
|
|
1753
|
+
}))), /* @__PURE__ */ React10.createElement(PopoverCombobox.Content, {
|
|
1754
|
+
filter: (value, search) => value === "__create__" || labelById[value]?.includes(search.toLowerCase()) ? 1 : 0,
|
|
1755
|
+
onClickCapture: handleClick,
|
|
1756
|
+
onKeyDownCapture: handleKeyDown
|
|
1757
|
+
}, showForm && createSchema ? /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form, {
|
|
1758
|
+
schema: createSchema,
|
|
1759
|
+
values: createInitialValuePath ? {
|
|
1760
|
+
[createInitialValuePath]: searchString
|
|
1761
|
+
} : {},
|
|
1762
|
+
onSave: handleFormSave,
|
|
1763
|
+
onCancel: handleFormCancel,
|
|
1764
|
+
testId: "create-referenced-object-form"
|
|
1765
|
+
})) : /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(PopoverCombobox.Input, {
|
|
1766
|
+
placeholder: t("ref field combobox input placeholder"),
|
|
1767
|
+
value: searchString,
|
|
1768
|
+
onValueChange: (v) => setSearchString(v),
|
|
1769
|
+
autoFocus: true
|
|
1770
|
+
}), /* @__PURE__ */ React10.createElement(PopoverCombobox.List, null, availableOptions.map((option) => /* @__PURE__ */ React10.createElement(PopoverCombobox.Item, {
|
|
1771
|
+
key: option.id,
|
|
1772
|
+
value: option.id,
|
|
1773
|
+
onSelect: () => toggleSelect(option.id),
|
|
1774
|
+
classNames: "flex items-center gap-2"
|
|
1775
|
+
}, /* @__PURE__ */ React10.createElement("span", {
|
|
1776
|
+
className: "grow"
|
|
1777
|
+
}, option.label), selectedIds.includes(option.id) && /* @__PURE__ */ React10.createElement(Icon2, {
|
|
1778
|
+
icon: "ph--check--regular"
|
|
1779
|
+
}))), searchString.length > 0 && createOptionLabel && createOptionIcon && createSchema && /* @__PURE__ */ React10.createElement(PopoverCombobox.Item, {
|
|
1780
|
+
value: "__create__",
|
|
1781
|
+
classNames: "flex items-center gap-2"
|
|
1782
|
+
}, /* @__PURE__ */ React10.createElement(Icon2, {
|
|
1783
|
+
icon: createOptionIcon
|
|
1784
|
+
}), t(createOptionLabel[0], {
|
|
1785
|
+
ns: createOptionLabel[1].ns,
|
|
1786
|
+
text: searchString
|
|
1787
|
+
})))), /* @__PURE__ */ React10.createElement(PopoverCombobox.Arrow, null)))), inputOnly && /* @__PURE__ */ React10.createElement(Input7.DescriptionAndValidation, null, error));
|
|
1699
1788
|
} finally {
|
|
1700
1789
|
_effect.f();
|
|
1701
1790
|
}
|
|
1702
1791
|
};
|
|
1703
|
-
var RefFieldFallback = ({ type, label,
|
|
1704
|
-
var _effect =
|
|
1792
|
+
var RefFieldFallback = ({ type, label, readonly, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
|
|
1793
|
+
var _effect = _useSignals10();
|
|
1705
1794
|
try {
|
|
1706
1795
|
const handleOnValueChange = (_type, dxnString) => {
|
|
1707
1796
|
const dxn = DXN.tryParse(dxnString);
|
|
@@ -1723,10 +1812,10 @@ var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValu
|
|
|
1723
1812
|
}
|
|
1724
1813
|
return void 0;
|
|
1725
1814
|
};
|
|
1726
|
-
return /* @__PURE__ */
|
|
1815
|
+
return /* @__PURE__ */ React10.createElement(TextInput, {
|
|
1727
1816
|
type,
|
|
1728
1817
|
label,
|
|
1729
|
-
|
|
1818
|
+
readonly,
|
|
1730
1819
|
placeholder,
|
|
1731
1820
|
inputOnly,
|
|
1732
1821
|
getValue: handleGetValue,
|
|
@@ -1738,28 +1827,9 @@ var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValu
|
|
|
1738
1827
|
}
|
|
1739
1828
|
};
|
|
1740
1829
|
|
|
1741
|
-
// src/components/Form/factory.tsx
|
|
1742
|
-
import { FormatEnum as FormatEnum4 } from "@dxos/echo-schema";
|
|
1743
|
-
var getInputComponent = (type, format) => {
|
|
1744
|
-
switch (format) {
|
|
1745
|
-
case FormatEnum4.GeoPoint:
|
|
1746
|
-
return GeoPointInput;
|
|
1747
|
-
case FormatEnum4.Markdown:
|
|
1748
|
-
return MarkdownInput;
|
|
1749
|
-
}
|
|
1750
|
-
switch (type) {
|
|
1751
|
-
case "string":
|
|
1752
|
-
return TextInput;
|
|
1753
|
-
case "number":
|
|
1754
|
-
return NumberInput;
|
|
1755
|
-
case "boolean":
|
|
1756
|
-
return BooleanInput;
|
|
1757
|
-
}
|
|
1758
|
-
};
|
|
1759
|
-
|
|
1760
1830
|
// src/components/Form/FormContent.tsx
|
|
1761
|
-
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1762
|
-
var _effect =
|
|
1831
|
+
var FormField = ({ property, path, readonly, inline, projection, onQueryRefOptions, createOptionLabel, createOptionIcon, onCreate, createSchema, createInitialValuePath, lookupComponent, Custom }) => {
|
|
1832
|
+
var _effect = _useSignals11();
|
|
1763
1833
|
try {
|
|
1764
1834
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1765
1835
|
const inputProps = useInputProps(path);
|
|
@@ -1778,7 +1848,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1778
1848
|
type,
|
|
1779
1849
|
format,
|
|
1780
1850
|
label,
|
|
1781
|
-
|
|
1851
|
+
readonly,
|
|
1782
1852
|
placeholder,
|
|
1783
1853
|
...inputProps
|
|
1784
1854
|
}
|
|
@@ -1789,33 +1859,38 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1789
1859
|
const jsonPath = createJsonPath3(path ?? []);
|
|
1790
1860
|
const CustomComponent = Custom?.[jsonPath];
|
|
1791
1861
|
if (CustomComponent) {
|
|
1792
|
-
return /* @__PURE__ */
|
|
1862
|
+
return /* @__PURE__ */ React11.createElement(CustomComponent, {
|
|
1793
1863
|
type,
|
|
1794
1864
|
format,
|
|
1795
1865
|
label,
|
|
1796
1866
|
inputOnly: inline,
|
|
1797
1867
|
placeholder,
|
|
1798
|
-
|
|
1868
|
+
readonly,
|
|
1799
1869
|
...inputProps
|
|
1800
1870
|
});
|
|
1801
1871
|
}
|
|
1802
1872
|
const refProps = getRefProps(property);
|
|
1803
1873
|
if (refProps) {
|
|
1804
|
-
return /* @__PURE__ */
|
|
1874
|
+
return /* @__PURE__ */ React11.createElement(RefField, {
|
|
1805
1875
|
ast: refProps.ast,
|
|
1806
1876
|
array: refProps.isArray,
|
|
1807
1877
|
type,
|
|
1808
1878
|
format,
|
|
1809
1879
|
label,
|
|
1810
1880
|
placeholder,
|
|
1811
|
-
|
|
1881
|
+
readonly,
|
|
1812
1882
|
inputOnly: inline,
|
|
1813
1883
|
onQueryRefOptions,
|
|
1884
|
+
createOptionLabel,
|
|
1885
|
+
createOptionIcon,
|
|
1886
|
+
onCreate,
|
|
1887
|
+
createSchema,
|
|
1888
|
+
createInitialValuePath,
|
|
1814
1889
|
...inputProps
|
|
1815
1890
|
});
|
|
1816
1891
|
}
|
|
1817
1892
|
if (array) {
|
|
1818
|
-
return /* @__PURE__ */
|
|
1893
|
+
return /* @__PURE__ */ React11.createElement(ArrayField, {
|
|
1819
1894
|
property,
|
|
1820
1895
|
path,
|
|
1821
1896
|
inputProps,
|
|
@@ -1825,21 +1900,21 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1825
1900
|
}
|
|
1826
1901
|
const InputComponent = getInputComponent(type, format);
|
|
1827
1902
|
if (InputComponent) {
|
|
1828
|
-
return /* @__PURE__ */
|
|
1903
|
+
return /* @__PURE__ */ React11.createElement(InputComponent, {
|
|
1829
1904
|
type,
|
|
1830
1905
|
format,
|
|
1831
1906
|
label,
|
|
1832
1907
|
inputOnly: inline,
|
|
1833
1908
|
placeholder,
|
|
1834
|
-
|
|
1909
|
+
readonly,
|
|
1835
1910
|
...inputProps
|
|
1836
1911
|
});
|
|
1837
1912
|
}
|
|
1838
1913
|
if (options) {
|
|
1839
|
-
return /* @__PURE__ */
|
|
1914
|
+
return /* @__PURE__ */ React11.createElement(SelectInput, {
|
|
1840
1915
|
type,
|
|
1841
1916
|
format,
|
|
1842
|
-
|
|
1917
|
+
readonly,
|
|
1843
1918
|
inputOnly: inline,
|
|
1844
1919
|
label,
|
|
1845
1920
|
options: options.map((option) => ({
|
|
@@ -1854,13 +1929,17 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1854
1929
|
const baseNode = findNode3(ast, isDiscriminatedUnion2);
|
|
1855
1930
|
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode3(ast, SchemaAST4.isTypeLiteral);
|
|
1856
1931
|
if (typeLiteral) {
|
|
1857
|
-
return /* @__PURE__ */
|
|
1858
|
-
className:
|
|
1859
|
-
}, label), /* @__PURE__ */
|
|
1932
|
+
return /* @__PURE__ */ React11.createElement(React11.Fragment, null, !inline && /* @__PURE__ */ React11.createElement("h3", {
|
|
1933
|
+
className: mx6("text-lg mlb-inputSpacingBlock first:mbs-0")
|
|
1934
|
+
}, label), /* @__PURE__ */ React11.createElement(FormFields, {
|
|
1860
1935
|
schema: Schema.make(typeLiteral),
|
|
1861
1936
|
path,
|
|
1862
1937
|
readonly,
|
|
1938
|
+
projection,
|
|
1863
1939
|
onQueryRefOptions,
|
|
1940
|
+
createOptionLabel,
|
|
1941
|
+
createOptionIcon,
|
|
1942
|
+
onCreate,
|
|
1864
1943
|
Custom,
|
|
1865
1944
|
lookupComponent
|
|
1866
1945
|
}));
|
|
@@ -1871,26 +1950,44 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1871
1950
|
_effect.f();
|
|
1872
1951
|
}
|
|
1873
1952
|
};
|
|
1874
|
-
var FormFields = /* @__PURE__ */ forwardRef(({ classNames,
|
|
1875
|
-
var _effect =
|
|
1953
|
+
var FormFields = /* @__PURE__ */ forwardRef(({ classNames, schema, path, filter, sort, projection, readonly, lookupComponent, Custom, onQueryRefOptions, ...props }, forwardRef3) => {
|
|
1954
|
+
var _effect = _useSignals11();
|
|
1876
1955
|
try {
|
|
1877
1956
|
const values = useFormValues(path);
|
|
1878
1957
|
const properties = useMemo5(() => {
|
|
1879
|
-
const
|
|
1880
|
-
|
|
1958
|
+
const props2 = getSchemaProperties2(schema.ast, values);
|
|
1959
|
+
if (projection) {
|
|
1960
|
+
const fieldProjections = projection.getFieldProjections();
|
|
1961
|
+
const hiddenProperties = new Set(projection.getHiddenProperties());
|
|
1962
|
+
const visibleProps = props2.filter((prop) => !hiddenProperties.has(prop.name));
|
|
1963
|
+
const orderedProps = [];
|
|
1964
|
+
for (const fieldProjection of fieldProjections) {
|
|
1965
|
+
const fieldPath = String(fieldProjection.field.path);
|
|
1966
|
+
const prop = visibleProps.find((p) => p.name === fieldPath);
|
|
1967
|
+
if (prop) {
|
|
1968
|
+
orderedProps.push(prop);
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
const projectionPaths = new Set(fieldProjections.map((fp) => String(fp.field.path)));
|
|
1972
|
+
const remainingProps = visibleProps.filter((prop) => !projectionPaths.has(prop.name));
|
|
1973
|
+
orderedProps.push(...remainingProps);
|
|
1974
|
+
return orderedProps;
|
|
1975
|
+
}
|
|
1976
|
+
const filtered = filter ? filter(props2) : props2;
|
|
1881
1977
|
return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
|
|
1882
1978
|
}, [
|
|
1883
1979
|
schema,
|
|
1884
1980
|
values,
|
|
1885
1981
|
filter,
|
|
1886
|
-
sort
|
|
1982
|
+
sort,
|
|
1983
|
+
projection?.fields
|
|
1887
1984
|
]);
|
|
1888
|
-
return /* @__PURE__ */
|
|
1985
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1889
1986
|
role: "form",
|
|
1890
|
-
className:
|
|
1891
|
-
ref:
|
|
1987
|
+
className: mx6("is-full", classNames),
|
|
1988
|
+
ref: forwardRef3
|
|
1892
1989
|
}, properties.map((property) => {
|
|
1893
|
-
return /* @__PURE__ */
|
|
1990
|
+
return /* @__PURE__ */ React11.createElement(FormField, {
|
|
1894
1991
|
key: property.name,
|
|
1895
1992
|
property,
|
|
1896
1993
|
path: [
|
|
@@ -1898,36 +1995,39 @@ var FormFields = /* @__PURE__ */ forwardRef(({ classNames, testId, schema, path,
|
|
|
1898
1995
|
property.name
|
|
1899
1996
|
],
|
|
1900
1997
|
readonly,
|
|
1998
|
+
projection,
|
|
1901
1999
|
onQueryRefOptions,
|
|
1902
2000
|
lookupComponent,
|
|
1903
|
-
Custom
|
|
2001
|
+
Custom,
|
|
2002
|
+
...props
|
|
1904
2003
|
});
|
|
1905
|
-
}).filter(
|
|
2004
|
+
}).filter(isTruthy));
|
|
1906
2005
|
} finally {
|
|
1907
2006
|
_effect.f();
|
|
1908
2007
|
}
|
|
1909
2008
|
});
|
|
1910
2009
|
|
|
1911
2010
|
// src/components/Form/Form.tsx
|
|
1912
|
-
var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true,
|
|
1913
|
-
var _effect =
|
|
2011
|
+
var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, autoSave, outerSpacing = true, schema, onCancel, onValuesChanged, onValidate, onSave, ...props }) => {
|
|
2012
|
+
var _effect = _useSignals12();
|
|
1914
2013
|
try {
|
|
1915
2014
|
const formRef = useRef3(null);
|
|
1916
|
-
const
|
|
1917
|
-
autoSave,
|
|
1918
|
-
onSave
|
|
1919
|
-
]);
|
|
2015
|
+
const { findFirstFocusable } = useFocusFinders();
|
|
1920
2016
|
useEffect7(() => {
|
|
1921
2017
|
if (autoFocus && formRef.current) {
|
|
1922
|
-
const
|
|
1923
|
-
if (
|
|
1924
|
-
|
|
2018
|
+
const firstFocusable = findFirstFocusable(formRef.current);
|
|
2019
|
+
if (firstFocusable) {
|
|
2020
|
+
firstFocusable.focus();
|
|
1925
2021
|
}
|
|
1926
2022
|
}
|
|
1927
2023
|
}, [
|
|
1928
2024
|
autoFocus
|
|
1929
2025
|
]);
|
|
1930
|
-
|
|
2026
|
+
const handleValid = useMemo6(() => autoSave ? onSave : void 0, [
|
|
2027
|
+
autoSave,
|
|
2028
|
+
onSave
|
|
2029
|
+
]);
|
|
2030
|
+
return /* @__PURE__ */ React12.createElement(FormProvider, {
|
|
1931
2031
|
formRef,
|
|
1932
2032
|
schema,
|
|
1933
2033
|
autoSave,
|
|
@@ -1936,11 +2036,11 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
|
|
|
1936
2036
|
onValidate,
|
|
1937
2037
|
onValid: handleValid,
|
|
1938
2038
|
onSave
|
|
1939
|
-
}, /* @__PURE__ */
|
|
2039
|
+
}, /* @__PURE__ */ React12.createElement("div", {
|
|
1940
2040
|
role: "none",
|
|
1941
2041
|
className: "contents",
|
|
1942
2042
|
"data-testid": testId
|
|
1943
|
-
}, /* @__PURE__ */
|
|
2043
|
+
}, /* @__PURE__ */ React12.createElement(FormFields, {
|
|
1944
2044
|
...props,
|
|
1945
2045
|
ref: formRef,
|
|
1946
2046
|
classNames: [
|
|
@@ -1950,7 +2050,7 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
|
|
|
1950
2050
|
],
|
|
1951
2051
|
readonly,
|
|
1952
2052
|
schema
|
|
1953
|
-
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */
|
|
2053
|
+
}), (onCancel || onSave) && !autoSave && !readonly && /* @__PURE__ */ React12.createElement(FormActions, {
|
|
1954
2054
|
readonly,
|
|
1955
2055
|
onCancel,
|
|
1956
2056
|
outerSpacing
|
|
@@ -1962,42 +2062,37 @@ var Form = ({ classNames, testId, values: initialValues, autoFocus, readonly, au
|
|
|
1962
2062
|
|
|
1963
2063
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
1964
2064
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1965
|
-
var FieldEditor = ({
|
|
1966
|
-
var _effect =
|
|
2065
|
+
var FieldEditor = ({ readonly, projection, field, registry, onSave, onCancel, outerSpacing }) => {
|
|
2066
|
+
var _effect = _useSignals13();
|
|
1967
2067
|
try {
|
|
1968
2068
|
const { t } = useTranslation8(translationKey);
|
|
1969
|
-
const [props, setProps] =
|
|
2069
|
+
const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
|
|
1970
2070
|
useEffect8(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
1971
2071
|
field,
|
|
1972
2072
|
projection
|
|
1973
2073
|
]);
|
|
1974
|
-
const [schemas, setSchemas] =
|
|
1975
|
-
|
|
2074
|
+
const [schemas, setSchemas] = useState6([]);
|
|
2075
|
+
useAsyncEffect(async () => {
|
|
1976
2076
|
if (!registry) {
|
|
1977
2077
|
return;
|
|
1978
2078
|
}
|
|
1979
2079
|
const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
|
|
1980
2080
|
fire: true
|
|
1981
2081
|
});
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
});
|
|
1986
|
-
return () => {
|
|
1987
|
-
clearTimeout(t2);
|
|
1988
|
-
subscription?.();
|
|
1989
|
-
};
|
|
2082
|
+
const schemas2 = await registry.query().run();
|
|
2083
|
+
setSchemas(schemas2);
|
|
2084
|
+
return () => subscription?.();
|
|
1990
2085
|
}, [
|
|
1991
2086
|
registry
|
|
1992
2087
|
]);
|
|
1993
|
-
const [referenceSchema, setReferenceSchema] =
|
|
2088
|
+
const [referenceSchema, setReferenceSchema] = useState6();
|
|
1994
2089
|
useEffect8(() => {
|
|
1995
2090
|
setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
|
|
1996
2091
|
}, [
|
|
1997
2092
|
schemas,
|
|
1998
2093
|
props?.referenceSchema
|
|
1999
2094
|
]);
|
|
2000
|
-
const [{ fieldSchema }, setFieldSchema] =
|
|
2095
|
+
const [{ fieldSchema }, setFieldSchema] = useState6({
|
|
2001
2096
|
fieldSchema: getFormatSchema(props?.format)
|
|
2002
2097
|
});
|
|
2003
2098
|
const handleValuesChanged = useCallback9((_props) => {
|
|
@@ -2021,10 +2116,12 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2021
2116
|
});
|
|
2022
2117
|
setProps((props2) => {
|
|
2023
2118
|
const type = formatToType[_props.format];
|
|
2119
|
+
const additionalProps = formatToAdditionalPropertyAttributes[_props.format];
|
|
2024
2120
|
if (props2.type !== type) {
|
|
2025
2121
|
return {
|
|
2026
2122
|
...props2,
|
|
2027
2123
|
..._props,
|
|
2124
|
+
...additionalProps,
|
|
2028
2125
|
type
|
|
2029
2126
|
};
|
|
2030
2127
|
}
|
|
@@ -2036,7 +2133,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2036
2133
|
props.referenceSchema
|
|
2037
2134
|
]);
|
|
2038
2135
|
const handleValidate = useCallback9(({ property }) => {
|
|
2039
|
-
if (property &&
|
|
2136
|
+
if (property && projection.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
2040
2137
|
return [
|
|
2041
2138
|
{
|
|
2042
2139
|
path: "property",
|
|
@@ -2045,7 +2142,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2045
2142
|
];
|
|
2046
2143
|
}
|
|
2047
2144
|
}, [
|
|
2048
|
-
|
|
2145
|
+
projection.fields,
|
|
2049
2146
|
field
|
|
2050
2147
|
]);
|
|
2051
2148
|
const handleSave = useCallback9((props2) => {
|
|
@@ -2066,26 +2163,26 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2066
2163
|
onSave
|
|
2067
2164
|
]);
|
|
2068
2165
|
const custom = useMemo7(() => ({
|
|
2069
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
2166
|
+
["format"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
2070
2167
|
...props2,
|
|
2071
2168
|
options: FormatEnums.filter((value) => value !== FormatEnum5.None).map((value) => ({
|
|
2072
2169
|
value,
|
|
2073
2170
|
label: t(`format ${value}`)
|
|
2074
2171
|
}))
|
|
2075
2172
|
}),
|
|
2076
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
2173
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
2077
2174
|
...props2,
|
|
2078
2175
|
options: schemas.map((schema) => ({
|
|
2079
2176
|
value: schema.typename
|
|
2080
2177
|
}))
|
|
2081
2178
|
}),
|
|
2082
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
2179
|
+
["referencePath"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
2083
2180
|
...props2,
|
|
2084
2181
|
options: referenceSchema ? getSchemaProperties3(referenceSchema.ast).sort(sortProperties).map((p) => ({
|
|
2085
2182
|
value: p.name
|
|
2086
2183
|
})) : []
|
|
2087
2184
|
}),
|
|
2088
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
2185
|
+
["options"]: (props2) => /* @__PURE__ */ React13.createElement(SelectOptionInput, props2)
|
|
2089
2186
|
}), [
|
|
2090
2187
|
t,
|
|
2091
2188
|
schemas,
|
|
@@ -2097,15 +2194,16 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2097
2194
|
props
|
|
2098
2195
|
}, {
|
|
2099
2196
|
F: __dxlog_file4,
|
|
2100
|
-
L:
|
|
2197
|
+
L: 180,
|
|
2101
2198
|
S: void 0,
|
|
2102
2199
|
C: (f, a) => f(...a)
|
|
2103
2200
|
});
|
|
2104
2201
|
return null;
|
|
2105
2202
|
}
|
|
2106
|
-
return /* @__PURE__ */
|
|
2203
|
+
return /* @__PURE__ */ React13.createElement(Form, {
|
|
2107
2204
|
key: field.id,
|
|
2108
2205
|
autoFocus: true,
|
|
2206
|
+
readonly,
|
|
2109
2207
|
values: props,
|
|
2110
2208
|
schema: fieldSchema,
|
|
2111
2209
|
filter: propIsNotType,
|
|
@@ -2126,78 +2224,107 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel, outerS
|
|
|
2126
2224
|
};
|
|
2127
2225
|
|
|
2128
2226
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
2129
|
-
import { useSignals as
|
|
2130
|
-
import { Schema as Schema2 } from "effect";
|
|
2131
|
-
import
|
|
2227
|
+
import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
|
|
2228
|
+
import { Array as Array2, Match, Option, Schema as Schema2 } from "effect";
|
|
2229
|
+
import React14, { forwardRef as forwardRef2, useCallback as useCallback10, useImperativeHandle, useMemo as useMemo8, useState as useState7 } from "react";
|
|
2132
2230
|
import { EchoSchema, Format, isMutable, toJsonSchema } from "@dxos/echo-schema";
|
|
2133
2231
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2134
|
-
import { Callout, IconButton as IconButton4, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
2232
|
+
import { Callout, IconButton as IconButton4, Input as Input8, useDensityContext, useElevationContext, useThemeContext, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
2233
|
+
import { Editor, createBasicExtensions, createThemeExtensions } from "@dxos/react-ui-editor";
|
|
2135
2234
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2136
2235
|
import { cardSpacing as cardSpacing3 } from "@dxos/react-ui-stack";
|
|
2137
|
-
import {
|
|
2138
|
-
import {
|
|
2236
|
+
import { inputTheme } from "@dxos/react-ui-theme";
|
|
2237
|
+
import { inputTextLabel, mx as mx7, subtleHover as subtleHover2 } from "@dxos/react-ui-theme";
|
|
2238
|
+
import { FieldSchema, ProjectionModel, VIEW_FIELD_LIMIT, typenameFromQuery } from "@dxos/schema";
|
|
2139
2239
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2140
|
-
var
|
|
2141
|
-
var
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
}),
|
|
2145
|
-
typename: Format.URL.annotations({
|
|
2146
|
-
title: "Typename"
|
|
2147
|
-
})
|
|
2148
|
-
}).pipe(Schema2.mutable);
|
|
2149
|
-
var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, showHeading = false, onTypenameChanged, onDelete, outerSpacing = true }) => {
|
|
2150
|
-
var _effect = _useSignals15();
|
|
2240
|
+
var listGrid = "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]";
|
|
2241
|
+
var listItemGrid = "grid grid-cols-subgrid col-span-5";
|
|
2242
|
+
var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, readonly, showHeading = false, onQueryChanged, onDelete, outerSpacing = true }, forwardedRef) => {
|
|
2243
|
+
var _effect = _useSignals14();
|
|
2151
2244
|
try {
|
|
2245
|
+
const schemaReadonly = !isMutable(schema);
|
|
2152
2246
|
const { t } = useTranslation9(translationKey);
|
|
2153
|
-
const
|
|
2247
|
+
const projectionModel = useMemo8(() => {
|
|
2154
2248
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2155
|
-
return new
|
|
2249
|
+
return new ProjectionModel(jsonSchema, view.projection);
|
|
2156
2250
|
}, [
|
|
2157
2251
|
schema,
|
|
2158
|
-
view
|
|
2252
|
+
JSON.stringify(view.projection)
|
|
2159
2253
|
]);
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
const viewValues = useMemo8(() => {
|
|
2163
|
-
return {
|
|
2164
|
-
name: view.name,
|
|
2165
|
-
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
2166
|
-
// TODO(burdon): Settings should have domain name owned by user.
|
|
2167
|
-
typename: view.query.typename
|
|
2168
|
-
};
|
|
2169
|
-
}, [
|
|
2170
|
-
view
|
|
2254
|
+
useImperativeHandle(forwardedRef, () => projectionModel, [
|
|
2255
|
+
projectionModel
|
|
2171
2256
|
]);
|
|
2172
|
-
const
|
|
2173
|
-
|
|
2174
|
-
|
|
2257
|
+
const [expandedField, setExpandedField] = useState7();
|
|
2258
|
+
const serializedQuery = Match.value(mode).pipe(Match.when("schema", () => typenameFromQuery(view.query.ast)), Match.when("query", () => {
|
|
2259
|
+
if (view.query.string) {
|
|
2260
|
+
return view.query.string;
|
|
2261
|
+
} else {
|
|
2262
|
+
return "Serializing query AST is not currently supported.";
|
|
2263
|
+
}
|
|
2264
|
+
}), Match.exhaustive);
|
|
2265
|
+
const queueTarget = Match.value(view.query.ast).pipe(Match.when({
|
|
2266
|
+
type: "options"
|
|
2267
|
+
}, ({ options }) => {
|
|
2268
|
+
return Option.fromNullable(options.queues).pipe(Option.flatMap((queues) => Array2.head(queues)), Option.getOrUndefined);
|
|
2269
|
+
}), Match.orElse(() => void 0));
|
|
2270
|
+
const viewSchema = useMemo8(() => {
|
|
2271
|
+
const base = Schema2.Struct({
|
|
2272
|
+
query: mode === "schema" ? Format.URL.annotations({
|
|
2273
|
+
title: "Record type"
|
|
2274
|
+
}) : Schema2.String.annotations({
|
|
2275
|
+
title: "Query"
|
|
2276
|
+
})
|
|
2277
|
+
});
|
|
2278
|
+
if (mode === "query") {
|
|
2279
|
+
return Schema2.Struct({
|
|
2280
|
+
name: Schema2.optional(Schema2.String.annotations({
|
|
2281
|
+
title: "Name"
|
|
2282
|
+
})),
|
|
2283
|
+
...base.fields,
|
|
2284
|
+
target: Schema2.optional(Schema2.String.annotations({
|
|
2285
|
+
title: "Target Queue"
|
|
2286
|
+
}))
|
|
2287
|
+
}).pipe(Schema2.mutable);
|
|
2175
2288
|
}
|
|
2176
|
-
|
|
2289
|
+
return base.pipe(Schema2.mutable);
|
|
2290
|
+
}, [
|
|
2291
|
+
mode
|
|
2292
|
+
]);
|
|
2293
|
+
const viewValues = useMemo8(() => ({
|
|
2294
|
+
name: view.name,
|
|
2295
|
+
query: serializedQuery,
|
|
2296
|
+
target: queueTarget
|
|
2297
|
+
}), [
|
|
2298
|
+
view.name,
|
|
2299
|
+
serializedQuery,
|
|
2300
|
+
queueTarget
|
|
2301
|
+
]);
|
|
2302
|
+
const handleToggleField = useCallback10((field) => {
|
|
2303
|
+
setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
|
|
2177
2304
|
}, [
|
|
2178
2305
|
readonly
|
|
2179
2306
|
]);
|
|
2180
2307
|
const handleAdd = useCallback10(() => {
|
|
2181
2308
|
invariant3(!readonly, void 0, {
|
|
2182
2309
|
F: __dxlog_file5,
|
|
2183
|
-
L:
|
|
2310
|
+
L: 141,
|
|
2184
2311
|
S: void 0,
|
|
2185
2312
|
A: [
|
|
2186
2313
|
"!readonly",
|
|
2187
2314
|
""
|
|
2188
2315
|
]
|
|
2189
2316
|
});
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2317
|
+
const field = projectionModel.createFieldProjection();
|
|
2318
|
+
setExpandedField(field.id);
|
|
2192
2319
|
}, [
|
|
2193
2320
|
schema,
|
|
2194
|
-
|
|
2321
|
+
projectionModel,
|
|
2195
2322
|
readonly
|
|
2196
2323
|
]);
|
|
2197
|
-
const handleUpdate = useCallback10((
|
|
2324
|
+
const handleUpdate = useCallback10((values) => {
|
|
2198
2325
|
invariant3(!readonly, void 0, {
|
|
2199
2326
|
F: __dxlog_file5,
|
|
2200
|
-
L:
|
|
2327
|
+
L: 148,
|
|
2201
2328
|
S: void 0,
|
|
2202
2329
|
A: [
|
|
2203
2330
|
"!readonly",
|
|
@@ -2205,43 +2332,46 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2205
2332
|
]
|
|
2206
2333
|
});
|
|
2207
2334
|
requestAnimationFrame(() => {
|
|
2208
|
-
if (view.name !== name) {
|
|
2209
|
-
view.name = name;
|
|
2335
|
+
if ("name" in values && view.name !== values.name) {
|
|
2336
|
+
view.name = values.name;
|
|
2210
2337
|
}
|
|
2211
|
-
|
|
2212
|
-
|
|
2338
|
+
const queryChanged = serializedQuery !== values.query;
|
|
2339
|
+
const targetValue = "target" in values ? values.target : void 0;
|
|
2340
|
+
const targetChanged = "target" in values && values.target && queueTarget !== targetValue;
|
|
2341
|
+
if ((queryChanged || targetChanged) && !readonly) {
|
|
2342
|
+
onQueryChanged?.(values.query, targetValue);
|
|
2213
2343
|
}
|
|
2214
2344
|
});
|
|
2215
2345
|
}, [
|
|
2216
|
-
|
|
2346
|
+
serializedQuery,
|
|
2347
|
+
onQueryChanged,
|
|
2348
|
+
readonly,
|
|
2217
2349
|
view,
|
|
2218
|
-
|
|
2219
|
-
readonly
|
|
2350
|
+
queueTarget
|
|
2220
2351
|
]);
|
|
2221
2352
|
const handleDelete = useCallback10((fieldId) => {
|
|
2222
2353
|
invariant3(!readonly, void 0, {
|
|
2223
2354
|
F: __dxlog_file5,
|
|
2224
|
-
L:
|
|
2355
|
+
L: 168,
|
|
2225
2356
|
S: void 0,
|
|
2226
2357
|
A: [
|
|
2227
2358
|
"!readonly",
|
|
2228
2359
|
""
|
|
2229
2360
|
]
|
|
2230
2361
|
});
|
|
2231
|
-
if (fieldId ===
|
|
2232
|
-
|
|
2362
|
+
if (fieldId === expandedField) {
|
|
2363
|
+
setExpandedField(void 0);
|
|
2233
2364
|
}
|
|
2234
2365
|
onDelete?.(fieldId);
|
|
2235
2366
|
}, [
|
|
2236
|
-
|
|
2237
|
-
field,
|
|
2367
|
+
expandedField,
|
|
2238
2368
|
onDelete,
|
|
2239
2369
|
readonly
|
|
2240
2370
|
]);
|
|
2241
2371
|
const handleMove = useCallback10((fromIndex, toIndex) => {
|
|
2242
2372
|
invariant3(!readonly, void 0, {
|
|
2243
2373
|
F: __dxlog_file5,
|
|
2244
|
-
L:
|
|
2374
|
+
L: 180,
|
|
2245
2375
|
S: void 0,
|
|
2246
2376
|
A: [
|
|
2247
2377
|
"!readonly",
|
|
@@ -2249,120 +2379,149 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly: _readonly, sho
|
|
|
2249
2379
|
]
|
|
2250
2380
|
});
|
|
2251
2381
|
const fields = [
|
|
2252
|
-
...view.fields
|
|
2382
|
+
...view.projection.fields
|
|
2253
2383
|
];
|
|
2254
2384
|
const [moved] = fields.splice(fromIndex, 1);
|
|
2255
2385
|
fields.splice(toIndex, 0, moved);
|
|
2256
|
-
view.fields = fields;
|
|
2386
|
+
view.projection.fields = fields;
|
|
2257
2387
|
}, [
|
|
2258
|
-
|
|
2259
|
-
view.fields,
|
|
2388
|
+
view.projection.fields,
|
|
2260
2389
|
readonly
|
|
2261
2390
|
]);
|
|
2262
|
-
const handleClose = useCallback10(() =>
|
|
2263
|
-
const hiddenProperties = projection.getHiddenProperties();
|
|
2391
|
+
const handleClose = useCallback10(() => setExpandedField(void 0), []);
|
|
2264
2392
|
const handleHide = useCallback10((fieldId) => {
|
|
2265
|
-
|
|
2266
|
-
|
|
2393
|
+
setExpandedField(void 0);
|
|
2394
|
+
projectionModel.hideFieldProjection(fieldId);
|
|
2267
2395
|
}, [
|
|
2268
|
-
|
|
2396
|
+
projectionModel
|
|
2269
2397
|
]);
|
|
2270
2398
|
const handleShow = useCallback10((property) => {
|
|
2271
|
-
|
|
2272
|
-
|
|
2399
|
+
setExpandedField(void 0);
|
|
2400
|
+
projectionModel.showFieldProjection(property);
|
|
2273
2401
|
}, [
|
|
2274
|
-
|
|
2402
|
+
projectionModel
|
|
2275
2403
|
]);
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2404
|
+
const custom = useMemo8(() => mode === "query" ? {
|
|
2405
|
+
["query"]: (props) => {
|
|
2406
|
+
const { themeMode } = useThemeContext();
|
|
2407
|
+
const density = useDensityContext();
|
|
2408
|
+
const elevation = useElevationContext();
|
|
2409
|
+
const handleChange = useCallback10((text) => props.onValueChange("string", text), []);
|
|
2410
|
+
const extensions = useMemo8(() => [
|
|
2411
|
+
createBasicExtensions({
|
|
2412
|
+
placeholder: t("query placeholder")
|
|
2413
|
+
}),
|
|
2414
|
+
createThemeExtensions({
|
|
2415
|
+
themeMode
|
|
2416
|
+
})
|
|
2417
|
+
], []);
|
|
2418
|
+
return /* @__PURE__ */ React14.createElement(Input8.Root, null, /* @__PURE__ */ React14.createElement(InputHeader, {
|
|
2419
|
+
label: props.label
|
|
2420
|
+
}), /* @__PURE__ */ React14.createElement(Editor, {
|
|
2421
|
+
classNames: mx7(inputTheme.input({
|
|
2422
|
+
density,
|
|
2423
|
+
elevation
|
|
2424
|
+
}), "flex items-center", "focus-within:bg-focusSurface focus-within:border-separator focus-within:hover:bg-focusSurface"),
|
|
2425
|
+
extensions,
|
|
2426
|
+
value: props.getValue(),
|
|
2427
|
+
onChange: handleChange
|
|
2428
|
+
}));
|
|
2429
|
+
}
|
|
2430
|
+
} : {}, []);
|
|
2431
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
2280
2432
|
role: "none",
|
|
2281
|
-
className:
|
|
2282
|
-
}, /* @__PURE__ */
|
|
2283
|
-
valence: "info"
|
|
2284
|
-
|
|
2433
|
+
className: mx7(classNames)
|
|
2434
|
+
}, schemaReadonly && mode === "schema" && /* @__PURE__ */ React14.createElement(Callout.Root, {
|
|
2435
|
+
valence: "info",
|
|
2436
|
+
classNames: [
|
|
2437
|
+
"mlb-cardSpacingBlock",
|
|
2438
|
+
outerSpacing && "mli-cardSpacingInline"
|
|
2439
|
+
]
|
|
2440
|
+
}, /* @__PURE__ */ React14.createElement(Callout.Title, null, t("system schema description"))), /* @__PURE__ */ React14.createElement(Form, {
|
|
2285
2441
|
autoSave: true,
|
|
2286
|
-
schema:
|
|
2442
|
+
schema: viewSchema,
|
|
2287
2443
|
values: viewValues,
|
|
2288
|
-
readonly,
|
|
2444
|
+
readonly: readonly ? "disabled-input" : false,
|
|
2289
2445
|
onSave: handleUpdate,
|
|
2290
|
-
outerSpacing
|
|
2291
|
-
|
|
2446
|
+
outerSpacing,
|
|
2447
|
+
Custom: custom
|
|
2448
|
+
}), /* @__PURE__ */ React14.createElement("div", {
|
|
2292
2449
|
role: "none",
|
|
2293
2450
|
className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
|
|
2294
|
-
}, /* @__PURE__ */
|
|
2295
|
-
className:
|
|
2296
|
-
}, t("fields label")), /* @__PURE__ */
|
|
2297
|
-
items: view.fields,
|
|
2451
|
+
}, /* @__PURE__ */ React14.createElement("h2", {
|
|
2452
|
+
className: mx7(inputTextLabel)
|
|
2453
|
+
}, t("fields label")), /* @__PURE__ */ React14.createElement(List2.Root, {
|
|
2454
|
+
items: view.projection.fields,
|
|
2298
2455
|
isItem: Schema2.is(FieldSchema),
|
|
2299
|
-
getId: (
|
|
2300
|
-
readonly,
|
|
2301
|
-
|
|
2302
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
}, /* @__PURE__ */ React15.createElement("div", null), /* @__PURE__ */ React15.createElement("div", {
|
|
2306
|
-
className: "flex items-center text-sm"
|
|
2307
|
-
}, t("field path label"))), /* @__PURE__ */ React15.createElement("div", {
|
|
2308
|
-
role: "list",
|
|
2309
|
-
className: "flex flex-col is-full"
|
|
2310
|
-
}, fields?.map((field2) => /* @__PURE__ */ React15.createElement(List2.Item, {
|
|
2311
|
-
key: field2.id,
|
|
2312
|
-
item: field2,
|
|
2313
|
-
classNames: mx9(grid, ghostHover, "overflow-hidden", !readonly && "cursor-pointer")
|
|
2314
|
-
}, /* @__PURE__ */ React15.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React15.createElement(List2.ItemTitle, {
|
|
2315
|
-
onClick: () => handleSelect(field2)
|
|
2316
|
-
}, field2.path), /* @__PURE__ */ React15.createElement(List2.ItemButton, {
|
|
2317
|
-
"data-testid": "hide-field-button",
|
|
2318
|
-
icon: "ph--eye-slash--regular",
|
|
2319
|
-
// TDOO(burdon): Is this the correct test?
|
|
2320
|
-
disabled: view.fields.length <= 1,
|
|
2321
|
-
onClick: () => handleHide(field2.id)
|
|
2322
|
-
}), !readonly && /* @__PURE__ */ React15.createElement(List2.ItemDeleteButton, {
|
|
2323
|
-
disabled: view.fields.length <= 1,
|
|
2324
|
-
onClick: () => handleDelete(field2.id)
|
|
2325
|
-
})))))), hiddenProperties.length > 0 && /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement("label", {
|
|
2326
|
-
className: mx9(inputTextLabel)
|
|
2327
|
-
}, t("hidden fields label")), /* @__PURE__ */ React15.createElement(List2.Root, {
|
|
2328
|
-
items: hiddenProperties,
|
|
2329
|
-
isItem: (item) => typeof item === "string",
|
|
2330
|
-
getId: (property) => property
|
|
2331
|
-
}, ({ items: properties }) => /* @__PURE__ */ React15.createElement("div", {
|
|
2456
|
+
getId: (field) => field.id,
|
|
2457
|
+
onMove: readonly ? void 0 : handleMove,
|
|
2458
|
+
readonly
|
|
2459
|
+
}, ({ items: fields }) => /* @__PURE__ */ React14.createElement(React14.Fragment, null, showHeading && /* @__PURE__ */ React14.createElement("h3", {
|
|
2460
|
+
className: "text-sm"
|
|
2461
|
+
}, t("field path label")), /* @__PURE__ */ React14.createElement("div", {
|
|
2332
2462
|
role: "list",
|
|
2333
|
-
className:
|
|
2334
|
-
},
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2463
|
+
className: listGrid
|
|
2464
|
+
}, fields?.map((field) => {
|
|
2465
|
+
const hidden = field.visible === false;
|
|
2466
|
+
return /* @__PURE__ */ React14.createElement(List2.Item, {
|
|
2467
|
+
key: field.id,
|
|
2468
|
+
item: field,
|
|
2469
|
+
classNames: listItemGrid,
|
|
2470
|
+
"aria-expanded": expandedField === field.id
|
|
2471
|
+
}, /* @__PURE__ */ React14.createElement("div", {
|
|
2472
|
+
role: "none",
|
|
2473
|
+
className: mx7(subtleHover2, listItemGrid, "rounded-sm cursor-pointer min-bs-10")
|
|
2474
|
+
}, /* @__PURE__ */ React14.createElement(List2.ItemDragHandle, {
|
|
2475
|
+
disabled: readonly
|
|
2476
|
+
}), /* @__PURE__ */ React14.createElement(List2.ItemTitle, {
|
|
2477
|
+
classNames: hidden && "text-subdued",
|
|
2478
|
+
onClick: () => handleToggleField(field)
|
|
2479
|
+
}, field.path), /* @__PURE__ */ React14.createElement(List2.ItemButton, {
|
|
2480
|
+
label: t(hidden ? "show field label" : "hide field label"),
|
|
2481
|
+
"data-testid": hidden ? "show-field-button" : "hide-field-button",
|
|
2482
|
+
icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
|
|
2483
|
+
autoHide: false,
|
|
2484
|
+
disabled: readonly || !hidden && projectionModel.fields.length <= 1,
|
|
2485
|
+
onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
|
|
2486
|
+
}), mode === "schema" && /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(List2.ItemDeleteButton, {
|
|
2487
|
+
label: t("delete field label"),
|
|
2488
|
+
autoHide: false,
|
|
2489
|
+
disabled: readonly || schemaReadonly || view.projection.fields.length <= 1,
|
|
2490
|
+
onClick: () => handleDelete(field.id),
|
|
2491
|
+
"data-testid": "field.delete"
|
|
2492
|
+
}), /* @__PURE__ */ React14.createElement(IconButton4, {
|
|
2493
|
+
iconOnly: true,
|
|
2494
|
+
variant: "ghost",
|
|
2495
|
+
label: t("toggle expand label", {
|
|
2496
|
+
ns: "os"
|
|
2497
|
+
}),
|
|
2498
|
+
icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
2499
|
+
onClick: () => handleToggleField(field)
|
|
2500
|
+
}))), expandedField === field.id && mode === "schema" && /* @__PURE__ */ React14.createElement("div", {
|
|
2501
|
+
role: "none",
|
|
2502
|
+
className: "col-span-5 mbs-1 mbe-1 border border-separator rounded-md"
|
|
2503
|
+
}, /* @__PURE__ */ React14.createElement(FieldEditor, {
|
|
2504
|
+
readonly: readonly || schemaReadonly ? "disabled-input" : false,
|
|
2505
|
+
projection: projectionModel,
|
|
2506
|
+
field,
|
|
2507
|
+
registry,
|
|
2508
|
+
onSave: handleClose
|
|
2509
|
+
})));
|
|
2510
|
+
}))))), !readonly && !expandedField && mode === "schema" && /* @__PURE__ */ React14.createElement("div", {
|
|
2352
2511
|
role: "none",
|
|
2353
2512
|
className: outerSpacing ? cardSpacing3 : "mlb-cardSpacingBlock"
|
|
2354
|
-
}, /* @__PURE__ */
|
|
2513
|
+
}, /* @__PURE__ */ React14.createElement(IconButton4, {
|
|
2355
2514
|
icon: "ph--plus--regular",
|
|
2356
2515
|
label: t("button add property"),
|
|
2357
2516
|
onClick: readonly ? void 0 : handleAdd,
|
|
2358
2517
|
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2359
|
-
disabled: view.fields.length >= VIEW_FIELD_LIMIT,
|
|
2360
|
-
classNames: "
|
|
2518
|
+
disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2519
|
+
classNames: "is-full"
|
|
2361
2520
|
})));
|
|
2362
2521
|
} finally {
|
|
2363
2522
|
_effect.f();
|
|
2364
2523
|
}
|
|
2365
|
-
};
|
|
2524
|
+
});
|
|
2366
2525
|
export {
|
|
2367
2526
|
BooleanInput,
|
|
2368
2527
|
ControlFrame,
|
|
@@ -2374,8 +2533,6 @@ export {
|
|
|
2374
2533
|
ControlPage,
|
|
2375
2534
|
ControlSection,
|
|
2376
2535
|
ControlSectionHeading,
|
|
2377
|
-
DeprecatedFormContainer,
|
|
2378
|
-
DeprecatedFormInput,
|
|
2379
2536
|
FieldEditor,
|
|
2380
2537
|
Form,
|
|
2381
2538
|
FormProvider,
|