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