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