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