@dxos/react-ui-form 0.8.1-staging.5be625a → 0.8.1-staging.9eaf14f
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 +228 -159
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +311 -237
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +228 -159
- 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.d.ts +20 -0
- package/dist/types/src/components/ControlSection.d.ts.map +1 -0
- package/dist/types/src/components/Form/Form.stories.d.ts +2 -2
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Input.d.ts +1 -1
- package/dist/types/src/components/Form/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/util/field.d.ts +0 -1
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/components/ControlSection.tsx +113 -0
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
- package/src/components/Form/Form.stories.tsx +2 -2
- package/src/components/Form/Input.tsx +1 -1
- package/src/components/Form/custom/SelectOptionsInput.tsx +5 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +1 -1
- package/src/components/ViewEditor/ViewEditor.tsx +1 -1
- package/src/components/index.ts +1 -1
- package/src/util/field.ts +3 -4
- package/src/util/formatting.ts +9 -10
|
@@ -99,41 +99,105 @@ var DeprecatedFormInput = ({ label, description, secondary, children }) => {
|
|
|
99
99
|
return primary;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
+
// packages/ui/react-ui-form/src/components/ControlSection.tsx
|
|
103
|
+
import React2 from "react";
|
|
104
|
+
import { toLocalizedString, useTranslation, Input as Input2 } from "@dxos/react-ui";
|
|
105
|
+
var ControlSectionHeading = ({ title, description }) => {
|
|
106
|
+
const { t } = useTranslation(translationKey);
|
|
107
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("h2", {
|
|
108
|
+
className: "pli-4 container-max-width text-xl mbs-6 mbe-4"
|
|
109
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
|
|
110
|
+
className: "pli-4 mlb-4 container-max-width text-description"
|
|
111
|
+
}, toLocalizedString(description, t)));
|
|
112
|
+
};
|
|
113
|
+
var ControlSection = ({ title, description, children }) => {
|
|
114
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(ControlSectionHeading, {
|
|
115
|
+
title,
|
|
116
|
+
description
|
|
117
|
+
}), children);
|
|
118
|
+
};
|
|
119
|
+
var ControlGroup = ({ children }) => /* @__PURE__ */ React2.createElement("div", {
|
|
120
|
+
role: "none",
|
|
121
|
+
className: "group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4"
|
|
122
|
+
}, children);
|
|
123
|
+
var ControlFrame = ({ children }) => /* @__PURE__ */ React2.createElement("div", {
|
|
124
|
+
role: "none",
|
|
125
|
+
className: "p-4 border border-separator rounded-lg container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-2 md:gap-8"
|
|
126
|
+
}, children);
|
|
127
|
+
var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center";
|
|
128
|
+
var controlItemTitleClasses = "text-lg font-normal mbe-2";
|
|
129
|
+
var controlItemDescriptionClasses = "text-base mlb-2 md:mbe-0 text-description";
|
|
130
|
+
var ControlItem = ({ title, description, children }) => {
|
|
131
|
+
const { t } = useTranslation(translationKey);
|
|
132
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
133
|
+
className: controlItemClasses
|
|
134
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
135
|
+
role: "none"
|
|
136
|
+
}, /* @__PURE__ */ React2.createElement("h3", {
|
|
137
|
+
className: controlItemTitleClasses
|
|
138
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
|
|
139
|
+
className: controlItemDescriptionClasses
|
|
140
|
+
}, toLocalizedString(description, t))), children);
|
|
141
|
+
};
|
|
142
|
+
var ControlItemInput = ({ title, description, children }) => {
|
|
143
|
+
const { t } = useTranslation(translationKey);
|
|
144
|
+
return /* @__PURE__ */ React2.createElement(Input2.Root, null, /* @__PURE__ */ React2.createElement("div", {
|
|
145
|
+
className: controlItemClasses
|
|
146
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
147
|
+
role: "none"
|
|
148
|
+
}, /* @__PURE__ */ React2.createElement(Input2.Label, {
|
|
149
|
+
classNames: controlItemTitleClasses
|
|
150
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement(Input2.DescriptionAndValidation, null, /* @__PURE__ */ React2.createElement(Input2.Description, {
|
|
151
|
+
classNames: controlItemDescriptionClasses
|
|
152
|
+
}, toLocalizedString(description, t)))), children));
|
|
153
|
+
};
|
|
154
|
+
var ControlFrameItem = ({ title, description, children }) => {
|
|
155
|
+
const { t } = useTranslation(translationKey);
|
|
156
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
157
|
+
role: "group",
|
|
158
|
+
className: "min-is-0"
|
|
159
|
+
}, /* @__PURE__ */ React2.createElement("h3", {
|
|
160
|
+
className: "text-lg mbe-2"
|
|
161
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React2.createElement("p", {
|
|
162
|
+
className: "mlb-2 md:mbe-0 text-description"
|
|
163
|
+
}, toLocalizedString(description, t)), children);
|
|
164
|
+
};
|
|
165
|
+
|
|
102
166
|
// packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx
|
|
103
|
-
import
|
|
167
|
+
import React13, { useCallback as useCallback6, useEffect as useEffect7, useMemo as useMemo7, useState as useState4 } from "react";
|
|
104
168
|
import { FormatEnum as FormatEnum2, FormatEnums, formatToType } from "@dxos/echo-schema";
|
|
105
169
|
import { log as log2 } from "@dxos/log";
|
|
106
|
-
import { useTranslation as
|
|
170
|
+
import { useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
107
171
|
import { getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
|
|
108
172
|
|
|
109
173
|
// packages/ui/react-ui-form/src/components/Form/custom/GeoPointInput.tsx
|
|
110
|
-
import
|
|
174
|
+
import React4, { useCallback, useState, useEffect, useMemo } from "react";
|
|
111
175
|
import { GeoLocation } from "@dxos/echo-schema";
|
|
112
|
-
import { Input as
|
|
176
|
+
import { Input as Input3, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
113
177
|
import { safeParseFloat } from "@dxos/util";
|
|
114
178
|
|
|
115
179
|
// packages/ui/react-ui-form/src/components/Form/Input.tsx
|
|
116
|
-
import
|
|
180
|
+
import React3 from "react";
|
|
117
181
|
import { Icon, Tooltip } from "@dxos/react-ui";
|
|
118
182
|
import { errorText } from "@dxos/react-ui-theme";
|
|
119
183
|
var InputHeader = ({ children, error }) => {
|
|
120
|
-
return /* @__PURE__ */
|
|
184
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
121
185
|
role: "none",
|
|
122
186
|
className: "flex justify-between items-center mb-1"
|
|
123
|
-
}, children, error && /* @__PURE__ */
|
|
187
|
+
}, children, error && /* @__PURE__ */ React3.createElement(Tooltip.Root, null, /* @__PURE__ */ React3.createElement(Tooltip.Trigger, {
|
|
124
188
|
asChild: true
|
|
125
|
-
}, /* @__PURE__ */
|
|
189
|
+
}, /* @__PURE__ */ React3.createElement(Icon, {
|
|
126
190
|
icon: "ph--warning--regular",
|
|
127
191
|
size: 4,
|
|
128
192
|
classNames: errorText
|
|
129
|
-
})), /* @__PURE__ */
|
|
193
|
+
})), /* @__PURE__ */ React3.createElement(Tooltip.Content, {
|
|
130
194
|
side: "bottom"
|
|
131
|
-
}, /* @__PURE__ */
|
|
195
|
+
}, /* @__PURE__ */ React3.createElement(Tooltip.Arrow, null), error)));
|
|
132
196
|
};
|
|
133
197
|
|
|
134
198
|
// packages/ui/react-ui-form/src/components/Form/custom/GeoPointInput.tsx
|
|
135
199
|
var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
136
|
-
const { t } =
|
|
200
|
+
const { t } = useTranslation2(translationKey);
|
|
137
201
|
const { status, error } = getStatus();
|
|
138
202
|
const geoPoint = useMemo(() => getValue3() ?? [
|
|
139
203
|
0,
|
|
@@ -176,14 +240,14 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
176
240
|
onValueChange,
|
|
177
241
|
type
|
|
178
242
|
]);
|
|
179
|
-
return /* @__PURE__ */
|
|
243
|
+
return /* @__PURE__ */ React4.createElement(Input3.Root, {
|
|
180
244
|
validationValence: status
|
|
181
|
-
}, /* @__PURE__ */
|
|
245
|
+
}, /* @__PURE__ */ React4.createElement(InputHeader, {
|
|
182
246
|
error
|
|
183
|
-
}, /* @__PURE__ */
|
|
247
|
+
}, /* @__PURE__ */ React4.createElement(Input3.Label, null, label)), /* @__PURE__ */ React4.createElement("div", {
|
|
184
248
|
role: "none",
|
|
185
249
|
className: "grid grid-cols-2 gap-2"
|
|
186
|
-
}, /* @__PURE__ */
|
|
250
|
+
}, /* @__PURE__ */ React4.createElement(Input3.TextInput, {
|
|
187
251
|
type: "text",
|
|
188
252
|
pattern: "^-?[0-9]*\\.?[0-9]*$",
|
|
189
253
|
disabled,
|
|
@@ -191,7 +255,7 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
191
255
|
value: latitudeText,
|
|
192
256
|
onChange: handleCoordinateChange("latitude", setLatitudeText),
|
|
193
257
|
onBlur
|
|
194
|
-
}), /* @__PURE__ */
|
|
258
|
+
}), /* @__PURE__ */ React4.createElement(Input3.TextInput, {
|
|
195
259
|
type: "text",
|
|
196
260
|
pattern: "^-?[0-9]*\\.?[0-9]*$",
|
|
197
261
|
disabled,
|
|
@@ -203,9 +267,9 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
203
267
|
};
|
|
204
268
|
|
|
205
269
|
// packages/ui/react-ui-form/src/components/Form/custom/SelectOptionsInput.tsx
|
|
206
|
-
import
|
|
270
|
+
import React5, { useCallback as useCallback2, useEffect as useEffect2, useState as useState2, useRef } from "react";
|
|
207
271
|
import { PublicKey } from "@dxos/keys";
|
|
208
|
-
import { Icon as Icon2, IconButton, Input as
|
|
272
|
+
import { Icon as Icon2, IconButton, Input as Input4, Tag, Toolbar, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
209
273
|
import { List } from "@dxos/react-ui-list";
|
|
210
274
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
211
275
|
import { hues, mx as mx2 } from "@dxos/react-ui-theme";
|
|
@@ -213,7 +277,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
213
277
|
const [selected, setSelectedId] = useState2(null);
|
|
214
278
|
const [isNewOption, setIsNewOption] = useState2(false);
|
|
215
279
|
const inputRef = useRef(null);
|
|
216
|
-
const { t } =
|
|
280
|
+
const { t } = useTranslation3(translationKey);
|
|
217
281
|
const { status, error } = getStatus();
|
|
218
282
|
const options = getValue3();
|
|
219
283
|
useEffect2(() => {
|
|
@@ -316,43 +380,43 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
316
380
|
selected,
|
|
317
381
|
isNewOption
|
|
318
382
|
]);
|
|
319
|
-
return /* @__PURE__ */
|
|
383
|
+
return /* @__PURE__ */ React5.createElement(Input4.Root, {
|
|
320
384
|
validationValence: status
|
|
321
|
-
}, /* @__PURE__ */
|
|
385
|
+
}, /* @__PURE__ */ React5.createElement(InputHeader, {
|
|
322
386
|
error
|
|
323
|
-
}, /* @__PURE__ */
|
|
387
|
+
}, /* @__PURE__ */ React5.createElement(Input4.Label, null, label)), /* @__PURE__ */ React5.createElement("div", {
|
|
324
388
|
role: "none"
|
|
325
|
-
}, options && /* @__PURE__ */
|
|
389
|
+
}, options && /* @__PURE__ */ React5.createElement(List.Root, {
|
|
326
390
|
items: options,
|
|
327
391
|
isItem: (item) => true,
|
|
328
392
|
onMove: handleMove
|
|
329
|
-
}, ({ items }) => /* @__PURE__ */
|
|
393
|
+
}, ({ items }) => /* @__PURE__ */ React5.createElement("div", {
|
|
330
394
|
role: "list",
|
|
331
395
|
className: "w-full overflow-auto"
|
|
332
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
396
|
+
}, items?.map((item) => /* @__PURE__ */ React5.createElement("div", {
|
|
333
397
|
key: item.id
|
|
334
|
-
}, /* @__PURE__ */
|
|
398
|
+
}, /* @__PURE__ */ React5.createElement(List.Item, {
|
|
335
399
|
role: "button",
|
|
336
400
|
item,
|
|
337
401
|
classNames: mx2("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
338
402
|
"aria-expanded": selected === item.id
|
|
339
|
-
}, /* @__PURE__ */
|
|
403
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
340
404
|
className: "flex items-center"
|
|
341
|
-
}, /* @__PURE__ */
|
|
405
|
+
}, /* @__PURE__ */ React5.createElement(List.ItemDragHandle, null), /* @__PURE__ */ React5.createElement(List.ItemTitle, {
|
|
342
406
|
onClick: () => handleClick(item.id),
|
|
343
407
|
classNames: "flex-1"
|
|
344
|
-
}, /* @__PURE__ */
|
|
408
|
+
}, /* @__PURE__ */ React5.createElement(Tag, {
|
|
345
409
|
palette: item.color
|
|
346
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
410
|
+
}, item.title || "\u200B")), /* @__PURE__ */ React5.createElement(Icon2, {
|
|
347
411
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
348
412
|
onClick: () => handleClick(item.id)
|
|
349
|
-
})), selected === item.id && /* @__PURE__ */
|
|
413
|
+
})), selected === item.id && /* @__PURE__ */ React5.createElement("div", {
|
|
350
414
|
className: "mis-4 mbs-2 flex flex-col gap-1"
|
|
351
|
-
}, /* @__PURE__ */
|
|
415
|
+
}, /* @__PURE__ */ React5.createElement(Input4.Label, {
|
|
352
416
|
classNames: "text-xs"
|
|
353
|
-
}, t("select option label")), /* @__PURE__ */
|
|
417
|
+
}, t("select option label")), /* @__PURE__ */ React5.createElement("div", {
|
|
354
418
|
className: "flex flex-row items-center gap-1"
|
|
355
|
-
}, /* @__PURE__ */
|
|
419
|
+
}, /* @__PURE__ */ React5.createElement(Input4.TextInput, {
|
|
356
420
|
placeholder: t("select option label placeholder"),
|
|
357
421
|
ref: selected === item.id ? inputRef : void 0,
|
|
358
422
|
value: item.title,
|
|
@@ -360,34 +424,35 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
360
424
|
onKeyDown: handleKeyDown,
|
|
361
425
|
classNames: "flex-1",
|
|
362
426
|
"data-no-submit": true
|
|
363
|
-
}), /* @__PURE__ */
|
|
427
|
+
}), /* @__PURE__ */ React5.createElement(Toolbar.Root, {
|
|
364
428
|
classNames: "p-0 m-0 !is-auto"
|
|
365
|
-
}, /* @__PURE__ */
|
|
429
|
+
}, /* @__PURE__ */ React5.createElement(HuePicker, {
|
|
366
430
|
value: item.color,
|
|
367
|
-
onChange: handleColorChange(item.id)
|
|
368
|
-
|
|
431
|
+
onChange: handleColorChange(item.id),
|
|
432
|
+
rootVariant: "toolbar-button"
|
|
433
|
+
})), /* @__PURE__ */ React5.createElement(IconButton, {
|
|
369
434
|
icon: "ph--trash--fill",
|
|
370
435
|
iconOnly: true,
|
|
371
436
|
label: t("select option delete"),
|
|
372
437
|
onClick: () => handleDelete(item.id)
|
|
373
|
-
})))))), /* @__PURE__ */
|
|
438
|
+
})))))), /* @__PURE__ */ React5.createElement("div", {
|
|
374
439
|
role: "listitem"
|
|
375
|
-
}, /* @__PURE__ */
|
|
440
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
376
441
|
role: "button",
|
|
377
442
|
className: mx2("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
378
443
|
onClick: handleAdd
|
|
379
|
-
}, /* @__PURE__ */
|
|
444
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
380
445
|
className: "flex items-center gap-1"
|
|
381
|
-
}, /* @__PURE__ */
|
|
446
|
+
}, /* @__PURE__ */ React5.createElement(Icon2, {
|
|
382
447
|
icon: "ph--plus--regular"
|
|
383
|
-
}), /* @__PURE__ */
|
|
448
|
+
}), /* @__PURE__ */ React5.createElement("span", {
|
|
384
449
|
className: "text-sm"
|
|
385
450
|
}, t("select option add")))))))));
|
|
386
451
|
};
|
|
387
452
|
|
|
388
453
|
// packages/ui/react-ui-form/src/components/Form/custom/TupleInput.tsx
|
|
389
|
-
import
|
|
390
|
-
import { Input as
|
|
454
|
+
import React6 from "react";
|
|
455
|
+
import { Input as Input5 } from "@dxos/react-ui";
|
|
391
456
|
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
392
457
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
393
458
|
var gridCols = [
|
|
@@ -399,13 +464,13 @@ var gridCols = [
|
|
|
399
464
|
var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
400
465
|
const { status, error } = getStatus();
|
|
401
466
|
const values = getValue3() ?? {};
|
|
402
|
-
return /* @__PURE__ */
|
|
467
|
+
return /* @__PURE__ */ React6.createElement(Input5.Root, {
|
|
403
468
|
validationValence: status
|
|
404
|
-
}, /* @__PURE__ */
|
|
469
|
+
}, /* @__PURE__ */ React6.createElement(InputHeader, {
|
|
405
470
|
error
|
|
406
|
-
}, /* @__PURE__ */
|
|
471
|
+
}, /* @__PURE__ */ React6.createElement(Input5.Label, null, label)), /* @__PURE__ */ React6.createElement("div", {
|
|
407
472
|
className: mx3("grid gap-2", gridCols[binding.length - 1])
|
|
408
|
-
}, binding.map((prop) => /* @__PURE__ */
|
|
473
|
+
}, binding.map((prop) => /* @__PURE__ */ React6.createElement(Input5.TextInput, {
|
|
409
474
|
key: prop,
|
|
410
475
|
type: "number",
|
|
411
476
|
disabled,
|
|
@@ -419,69 +484,69 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
|
|
|
419
484
|
};
|
|
420
485
|
|
|
421
486
|
// packages/ui/react-ui-form/src/components/Form/Defaults.tsx
|
|
422
|
-
import
|
|
423
|
-
import { Input as
|
|
487
|
+
import React7, { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2 } from "react";
|
|
488
|
+
import { Input as Input6, Select } from "@dxos/react-ui";
|
|
424
489
|
var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
425
490
|
const { status, error } = getStatus();
|
|
426
|
-
return /* @__PURE__ */
|
|
491
|
+
return /* @__PURE__ */ React7.createElement(Input6.Root, {
|
|
427
492
|
validationValence: status
|
|
428
|
-
}, !inputOnly && /* @__PURE__ */
|
|
493
|
+
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
429
494
|
error
|
|
430
|
-
}, /* @__PURE__ */
|
|
495
|
+
}, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Input6.TextInput, {
|
|
431
496
|
disabled,
|
|
432
497
|
placeholder,
|
|
433
498
|
value: getValue3() ?? "",
|
|
434
499
|
onChange: (event) => onValueChange(type, event.target.value),
|
|
435
500
|
onBlur
|
|
436
|
-
}), inputOnly && /* @__PURE__ */
|
|
501
|
+
}), inputOnly && /* @__PURE__ */ React7.createElement(Input6.Validation, null, error));
|
|
437
502
|
};
|
|
438
503
|
var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
439
504
|
const { status, error } = getStatus();
|
|
440
|
-
return /* @__PURE__ */
|
|
505
|
+
return /* @__PURE__ */ React7.createElement(Input6.Root, {
|
|
441
506
|
validationValence: status
|
|
442
|
-
}, !inputOnly && /* @__PURE__ */
|
|
507
|
+
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
443
508
|
error
|
|
444
|
-
}, /* @__PURE__ */
|
|
509
|
+
}, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Input6.TextInput, {
|
|
445
510
|
type: "number",
|
|
446
511
|
disabled,
|
|
447
512
|
placeholder,
|
|
448
513
|
value: getValue3() ?? 0,
|
|
449
514
|
onChange: (event) => onValueChange(type, event.target.value),
|
|
450
515
|
onBlur
|
|
451
|
-
}), inputOnly && /* @__PURE__ */
|
|
516
|
+
}), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
|
|
452
517
|
};
|
|
453
518
|
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange }) => {
|
|
454
519
|
const { status, error } = getStatus();
|
|
455
520
|
const checked = Boolean(getValue3());
|
|
456
|
-
return /* @__PURE__ */
|
|
521
|
+
return /* @__PURE__ */ React7.createElement(Input6.Root, {
|
|
457
522
|
validationValence: status
|
|
458
|
-
}, !inputOnly && /* @__PURE__ */
|
|
523
|
+
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
459
524
|
error
|
|
460
|
-
}, /* @__PURE__ */
|
|
525
|
+
}, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Input6.Switch, {
|
|
461
526
|
checked,
|
|
462
527
|
onCheckedChange: (value) => onValueChange(type, value)
|
|
463
|
-
}), inputOnly && /* @__PURE__ */
|
|
528
|
+
}), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
|
|
464
529
|
};
|
|
465
530
|
var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
466
531
|
const { status, error } = getStatus();
|
|
467
|
-
return /* @__PURE__ */
|
|
532
|
+
return /* @__PURE__ */ React7.createElement(Input6.Root, {
|
|
468
533
|
validationValence: status
|
|
469
|
-
}, !inputOnly && /* @__PURE__ */
|
|
534
|
+
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
470
535
|
error
|
|
471
|
-
}, /* @__PURE__ */
|
|
536
|
+
}, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Select.Root, {
|
|
472
537
|
value: getValue3(),
|
|
473
538
|
onValueChange: (value) => onValueChange(type, value)
|
|
474
|
-
}, /* @__PURE__ */
|
|
539
|
+
}, /* @__PURE__ */ React7.createElement(Select.TriggerButton, {
|
|
475
540
|
classNames: "is-full",
|
|
476
541
|
disabled,
|
|
477
542
|
placeholder
|
|
478
|
-
}), /* @__PURE__ */
|
|
543
|
+
}), /* @__PURE__ */ React7.createElement(Select.Portal, null, /* @__PURE__ */ React7.createElement(Select.Content, null, /* @__PURE__ */ React7.createElement(Select.Viewport, null, options?.map(({ value, label: label2 }) => (
|
|
479
544
|
// NOTE: Numeric values are converted to and from strings.
|
|
480
|
-
/* @__PURE__ */
|
|
545
|
+
/* @__PURE__ */ React7.createElement(Select.Option, {
|
|
481
546
|
key: String(value),
|
|
482
547
|
value: String(value)
|
|
483
548
|
}, label2 ?? String(value))
|
|
484
|
-
)))))), inputOnly && /* @__PURE__ */
|
|
549
|
+
)))))), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
|
|
485
550
|
};
|
|
486
551
|
var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
487
552
|
const { status, error } = getStatus();
|
|
@@ -504,11 +569,11 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
504
569
|
getValue3(),
|
|
505
570
|
adjustHeight
|
|
506
571
|
]);
|
|
507
|
-
return /* @__PURE__ */
|
|
572
|
+
return /* @__PURE__ */ React7.createElement(Input6.Root, {
|
|
508
573
|
validationValence: status
|
|
509
|
-
}, !inputOnly && /* @__PURE__ */
|
|
574
|
+
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
510
575
|
error
|
|
511
|
-
}, /* @__PURE__ */
|
|
576
|
+
}, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Input6.TextArea, {
|
|
512
577
|
ref: textareaRef,
|
|
513
578
|
disabled,
|
|
514
579
|
placeholder,
|
|
@@ -520,20 +585,20 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
520
585
|
resize: "none"
|
|
521
586
|
},
|
|
522
587
|
spellCheck: false
|
|
523
|
-
}), inputOnly && /* @__PURE__ */
|
|
588
|
+
}), inputOnly && /* @__PURE__ */ React7.createElement(Input6.Validation, null, error));
|
|
524
589
|
};
|
|
525
590
|
|
|
526
591
|
// packages/ui/react-ui-form/src/components/Form/Form.tsx
|
|
527
|
-
import
|
|
592
|
+
import React12, { useEffect as useEffect6, useMemo as useMemo6, useRef as useRef3 } from "react";
|
|
528
593
|
import { mx as mx7 } from "@dxos/react-ui-theme";
|
|
529
594
|
|
|
530
595
|
// packages/ui/react-ui-form/src/components/Form/FormActions.tsx
|
|
531
|
-
import
|
|
532
|
-
import { IconButton as IconButton2, useTranslation as
|
|
596
|
+
import React9 from "react";
|
|
597
|
+
import { IconButton as IconButton2, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
533
598
|
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
534
599
|
|
|
535
600
|
// packages/ui/react-ui-form/src/components/Form/FormContext.tsx
|
|
536
|
-
import
|
|
601
|
+
import React8, { createContext, useContext, useEffect as useEffect5, useMemo as useMemo3 } from "react";
|
|
537
602
|
import { raise } from "@dxos/debug";
|
|
538
603
|
import { getValue as getValue2 } from "@dxos/echo-schema";
|
|
539
604
|
import { createJsonPath as createJsonPath2 } from "@dxos/effect";
|
|
@@ -807,27 +872,27 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
807
872
|
form.handleSave,
|
|
808
873
|
autoSave
|
|
809
874
|
]);
|
|
810
|
-
return /* @__PURE__ */
|
|
875
|
+
return /* @__PURE__ */ React8.createElement(FormContext.Provider, {
|
|
811
876
|
value: form
|
|
812
877
|
}, children);
|
|
813
878
|
};
|
|
814
879
|
|
|
815
880
|
// packages/ui/react-ui-form/src/components/Form/FormActions.tsx
|
|
816
881
|
var FormActions = ({ onCancel, readonly }) => {
|
|
817
|
-
const { t } =
|
|
882
|
+
const { t } = useTranslation4(translationKey);
|
|
818
883
|
const { canSave, handleSave } = useFormContext();
|
|
819
|
-
return /* @__PURE__ */
|
|
884
|
+
return /* @__PURE__ */ React9.createElement("div", {
|
|
820
885
|
role: "none",
|
|
821
886
|
className: "mt-2 flex justify-center"
|
|
822
|
-
}, /* @__PURE__ */
|
|
887
|
+
}, /* @__PURE__ */ React9.createElement("div", {
|
|
823
888
|
role: "none",
|
|
824
889
|
className: mx4(onCancel && !readonly && "grid grid-cols-2 gap-2")
|
|
825
|
-
}, onCancel && !readonly && /* @__PURE__ */
|
|
890
|
+
}, onCancel && !readonly && /* @__PURE__ */ React9.createElement(IconButton2, {
|
|
826
891
|
"data-testid": "cancel-button",
|
|
827
892
|
icon: "ph--x--regular",
|
|
828
893
|
label: t("button cancel"),
|
|
829
894
|
onClick: onCancel
|
|
830
|
-
}), handleSave && /* @__PURE__ */
|
|
895
|
+
}), handleSave && /* @__PURE__ */ React9.createElement(IconButton2, {
|
|
831
896
|
type: "submit",
|
|
832
897
|
"data-testid": "save-button",
|
|
833
898
|
disabled: !canSave,
|
|
@@ -840,7 +905,7 @@ var FormActions = ({ onCancel, readonly }) => {
|
|
|
840
905
|
// packages/ui/react-ui-form/src/components/Form/FormContent.tsx
|
|
841
906
|
import { pipe as pipe2 } from "effect";
|
|
842
907
|
import { capitalize as capitalize2 } from "effect/String";
|
|
843
|
-
import
|
|
908
|
+
import React11, { useMemo as useMemo5 } from "react";
|
|
844
909
|
import { AST as AST3, S } from "@dxos/echo-schema";
|
|
845
910
|
import { createJsonPath as createJsonPath3, findNode as findNode2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
|
|
846
911
|
import { mx as mx6 } from "@dxos/react-ui-theme";
|
|
@@ -850,17 +915,17 @@ import { isNotFalsy } from "@dxos/util";
|
|
|
850
915
|
// packages/ui/react-ui-form/src/components/Form/ArrayField.tsx
|
|
851
916
|
import { pipe } from "effect";
|
|
852
917
|
import { capitalize } from "effect/String";
|
|
853
|
-
import
|
|
918
|
+
import React10, { useCallback as useCallback5, useMemo as useMemo4 } from "react";
|
|
854
919
|
import { AST as AST2 } from "@dxos/echo-schema";
|
|
855
920
|
import { findNode, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from "@dxos/effect";
|
|
856
921
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
857
|
-
import { IconButton as IconButton3, useTranslation as
|
|
922
|
+
import { IconButton as IconButton3, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
858
923
|
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
859
924
|
import { getSchemaProperties } from "@dxos/schema";
|
|
860
925
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
861
926
|
var padding = "px-2";
|
|
862
927
|
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
863
|
-
const { t } =
|
|
928
|
+
const { t } = useTranslation5(translationKey);
|
|
864
929
|
const { ast, name, type, title } = property;
|
|
865
930
|
const values = useFormValues(path ?? []);
|
|
866
931
|
invariant2(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
@@ -919,20 +984,20 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
919
984
|
if (!elementType) {
|
|
920
985
|
return null;
|
|
921
986
|
}
|
|
922
|
-
return /* @__PURE__ */
|
|
987
|
+
return /* @__PURE__ */ React10.createElement("div", {
|
|
923
988
|
role: "none",
|
|
924
989
|
className: mx5(padding)
|
|
925
|
-
}, /* @__PURE__ */
|
|
990
|
+
}, /* @__PURE__ */ React10.createElement(InputHeader, null, label), /* @__PURE__ */ React10.createElement("div", {
|
|
926
991
|
role: "none",
|
|
927
992
|
className: "flex flex-col gap-1"
|
|
928
|
-
}, values.map((_value, index) => /* @__PURE__ */
|
|
993
|
+
}, values.map((_value, index) => /* @__PURE__ */ React10.createElement("div", {
|
|
929
994
|
key: index,
|
|
930
995
|
role: "none",
|
|
931
996
|
className: "flex items-center gap-1"
|
|
932
|
-
}, /* @__PURE__ */
|
|
997
|
+
}, /* @__PURE__ */ React10.createElement("div", {
|
|
933
998
|
role: "none",
|
|
934
999
|
className: "flex-1"
|
|
935
|
-
}, /* @__PURE__ */
|
|
1000
|
+
}, /* @__PURE__ */ React10.createElement(FormField, {
|
|
936
1001
|
property: {
|
|
937
1002
|
...property,
|
|
938
1003
|
array: false,
|
|
@@ -946,15 +1011,15 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
946
1011
|
inline: true,
|
|
947
1012
|
Custom,
|
|
948
1013
|
lookupComponent
|
|
949
|
-
})), /* @__PURE__ */
|
|
1014
|
+
})), /* @__PURE__ */ React10.createElement(IconButton3, {
|
|
950
1015
|
icon: "ph--trash--regular",
|
|
951
1016
|
iconOnly: true,
|
|
952
1017
|
label: t("button remove"),
|
|
953
1018
|
onClick: () => handleRemove(index)
|
|
954
|
-
})))), /* @__PURE__ */
|
|
1019
|
+
})))), /* @__PURE__ */ React10.createElement("div", {
|
|
955
1020
|
role: "none",
|
|
956
1021
|
className: "flex justify-between items-center plb-1"
|
|
957
|
-
}, /* @__PURE__ */
|
|
1022
|
+
}, /* @__PURE__ */ React10.createElement(IconButton3, {
|
|
958
1023
|
icon: "ph--plus--regular",
|
|
959
1024
|
iconOnly: true,
|
|
960
1025
|
label: t("button add"),
|
|
@@ -1006,14 +1071,14 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1006
1071
|
}
|
|
1007
1072
|
});
|
|
1008
1073
|
if (FoundComponent) {
|
|
1009
|
-
return /* @__PURE__ */
|
|
1074
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1010
1075
|
role: "none"
|
|
1011
1076
|
}, FoundComponent);
|
|
1012
1077
|
}
|
|
1013
1078
|
const jsonPath = createJsonPath3(path ?? []);
|
|
1014
1079
|
const CustomComponent = Custom?.[jsonPath];
|
|
1015
1080
|
if (CustomComponent) {
|
|
1016
|
-
return /* @__PURE__ */
|
|
1081
|
+
return /* @__PURE__ */ React11.createElement(CustomComponent, {
|
|
1017
1082
|
type,
|
|
1018
1083
|
format,
|
|
1019
1084
|
label,
|
|
@@ -1024,7 +1089,7 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1024
1089
|
});
|
|
1025
1090
|
}
|
|
1026
1091
|
if (array) {
|
|
1027
|
-
return /* @__PURE__ */
|
|
1092
|
+
return /* @__PURE__ */ React11.createElement(ArrayField, {
|
|
1028
1093
|
property,
|
|
1029
1094
|
path,
|
|
1030
1095
|
inputProps,
|
|
@@ -1034,9 +1099,9 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1034
1099
|
}
|
|
1035
1100
|
const InputComponent = getInputComponent(type, format);
|
|
1036
1101
|
if (InputComponent) {
|
|
1037
|
-
return /* @__PURE__ */
|
|
1102
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1038
1103
|
role: "none"
|
|
1039
|
-
}, /* @__PURE__ */
|
|
1104
|
+
}, /* @__PURE__ */ React11.createElement(InputComponent, {
|
|
1040
1105
|
type,
|
|
1041
1106
|
format,
|
|
1042
1107
|
label,
|
|
@@ -1047,9 +1112,9 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1047
1112
|
}));
|
|
1048
1113
|
}
|
|
1049
1114
|
if (options) {
|
|
1050
|
-
return /* @__PURE__ */
|
|
1115
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1051
1116
|
role: "none"
|
|
1052
|
-
}, /* @__PURE__ */
|
|
1117
|
+
}, /* @__PURE__ */ React11.createElement(SelectInput, {
|
|
1053
1118
|
type,
|
|
1054
1119
|
format,
|
|
1055
1120
|
disabled: readonly,
|
|
@@ -1067,9 +1132,9 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1067
1132
|
const baseNode = findNode2(ast, isDiscriminatedUnion2);
|
|
1068
1133
|
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode2(ast, AST3.isTypeLiteral);
|
|
1069
1134
|
if (typeLiteral) {
|
|
1070
|
-
return /* @__PURE__ */
|
|
1135
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1071
1136
|
role: "none"
|
|
1072
|
-
}, !inline && /* @__PURE__ */
|
|
1137
|
+
}, !inline && /* @__PURE__ */ React11.createElement("div", null, label), /* @__PURE__ */ React11.createElement(FormFields, {
|
|
1073
1138
|
schema: S.make(typeLiteral),
|
|
1074
1139
|
path,
|
|
1075
1140
|
readonly,
|
|
@@ -1091,11 +1156,11 @@ var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custo
|
|
|
1091
1156
|
filter,
|
|
1092
1157
|
sort
|
|
1093
1158
|
]);
|
|
1094
|
-
return /* @__PURE__ */
|
|
1159
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1095
1160
|
role: "form",
|
|
1096
1161
|
className: mx6("flex flex-col w-full gap-2")
|
|
1097
1162
|
}, properties.map((property) => {
|
|
1098
|
-
return /* @__PURE__ */
|
|
1163
|
+
return /* @__PURE__ */ React11.createElement(FormField, {
|
|
1099
1164
|
key: property.name,
|
|
1100
1165
|
property,
|
|
1101
1166
|
path: [
|
|
@@ -1126,7 +1191,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1126
1191
|
}, [
|
|
1127
1192
|
autoFocus
|
|
1128
1193
|
]);
|
|
1129
|
-
return /* @__PURE__ */
|
|
1194
|
+
return /* @__PURE__ */ React12.createElement(FormProvider, {
|
|
1130
1195
|
formRef,
|
|
1131
1196
|
schema,
|
|
1132
1197
|
autoSave,
|
|
@@ -1135,12 +1200,12 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1135
1200
|
onValidate,
|
|
1136
1201
|
onValid,
|
|
1137
1202
|
onSave
|
|
1138
|
-
}, /* @__PURE__ */
|
|
1203
|
+
}, /* @__PURE__ */ React12.createElement("div", {
|
|
1139
1204
|
ref: formRef,
|
|
1140
1205
|
role: "none",
|
|
1141
1206
|
className: mx7("p-2", classNames),
|
|
1142
1207
|
"data-testid": testId
|
|
1143
|
-
}, /* @__PURE__ */
|
|
1208
|
+
}, /* @__PURE__ */ React12.createElement(FormFields, {
|
|
1144
1209
|
schema,
|
|
1145
1210
|
path,
|
|
1146
1211
|
readonly,
|
|
@@ -1148,7 +1213,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1148
1213
|
sort,
|
|
1149
1214
|
lookupComponent,
|
|
1150
1215
|
Custom
|
|
1151
|
-
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */
|
|
1216
|
+
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React12.createElement(FormActions, {
|
|
1152
1217
|
onCancel,
|
|
1153
1218
|
readonly
|
|
1154
1219
|
})));
|
|
@@ -1157,7 +1222,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1157
1222
|
// packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx
|
|
1158
1223
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1159
1224
|
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1160
|
-
const { t } =
|
|
1225
|
+
const { t } = useTranslation6(translationKey);
|
|
1161
1226
|
const [props, setProps] = useState4(projection.getFieldProjection(field.id).props);
|
|
1162
1227
|
useEffect7(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
1163
1228
|
field,
|
|
@@ -1258,26 +1323,26 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1258
1323
|
onSave
|
|
1259
1324
|
]);
|
|
1260
1325
|
const Custom = useMemo7(() => ({
|
|
1261
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
1326
|
+
["format"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
1262
1327
|
...props2,
|
|
1263
1328
|
options: FormatEnums.filter((value) => value !== FormatEnum2.None).map((value) => ({
|
|
1264
1329
|
value,
|
|
1265
1330
|
label: t(`format ${value}`)
|
|
1266
1331
|
}))
|
|
1267
1332
|
}),
|
|
1268
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
1333
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
1269
1334
|
...props2,
|
|
1270
1335
|
options: schemas.map((schema) => ({
|
|
1271
1336
|
value: schema.typename
|
|
1272
1337
|
}))
|
|
1273
1338
|
}),
|
|
1274
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
1339
|
+
["referencePath"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
1275
1340
|
...props2,
|
|
1276
1341
|
options: referenceSchema ? getSchemaProperties3(referenceSchema.ast).sort(sortProperties).map((p) => ({
|
|
1277
1342
|
value: p.name
|
|
1278
1343
|
})) : []
|
|
1279
1344
|
}),
|
|
1280
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
1345
|
+
["options"]: (props2) => /* @__PURE__ */ React13.createElement(SelectOptionInput, props2)
|
|
1281
1346
|
}), [
|
|
1282
1347
|
t,
|
|
1283
1348
|
schemas,
|
|
@@ -1295,7 +1360,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1295
1360
|
});
|
|
1296
1361
|
return null;
|
|
1297
1362
|
}
|
|
1298
|
-
return /* @__PURE__ */
|
|
1363
|
+
return /* @__PURE__ */ React13.createElement(Form, {
|
|
1299
1364
|
key: field.id,
|
|
1300
1365
|
autoFocus: true,
|
|
1301
1366
|
values: props,
|
|
@@ -1314,10 +1379,10 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1314
1379
|
};
|
|
1315
1380
|
|
|
1316
1381
|
// packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx
|
|
1317
|
-
import
|
|
1382
|
+
import React14, { useCallback as useCallback7, useMemo as useMemo8, useState as useState5 } from "react";
|
|
1318
1383
|
import { AST as AST4, Format, S as S2 } from "@dxos/echo-schema";
|
|
1319
1384
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1320
|
-
import { IconButton as IconButton4, useTranslation as
|
|
1385
|
+
import { IconButton as IconButton4, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1321
1386
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
1322
1387
|
import { ghostHover, inputTextLabel, mx as mx8 } from "@dxos/react-ui-theme";
|
|
1323
1388
|
import { FieldSchema, ViewProjection, VIEW_FIELD_LIMIT } from "@dxos/schema";
|
|
@@ -1332,8 +1397,8 @@ var ViewMetaSchema = S2.Struct({
|
|
|
1332
1397
|
})
|
|
1333
1398
|
}).pipe(S2.mutable);
|
|
1334
1399
|
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1335
|
-
const { t } =
|
|
1336
|
-
const projection = useMemo8(() => new ViewProjection(schema, view), [
|
|
1400
|
+
const { t } = useTranslation7(translationKey);
|
|
1401
|
+
const projection = useMemo8(() => new ViewProjection(schema.jsonSchema, view), [
|
|
1337
1402
|
schema,
|
|
1338
1403
|
view
|
|
1339
1404
|
]);
|
|
@@ -1443,77 +1508,77 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1443
1508
|
}, [
|
|
1444
1509
|
projection
|
|
1445
1510
|
]);
|
|
1446
|
-
return /* @__PURE__ */
|
|
1511
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
1447
1512
|
role: "none",
|
|
1448
1513
|
className: mx8("flex flex-col w-full divide-y divide-separator", classNames)
|
|
1449
|
-
}, /* @__PURE__ */
|
|
1514
|
+
}, /* @__PURE__ */ React14.createElement(Form, {
|
|
1450
1515
|
autoSave: true,
|
|
1451
1516
|
schema: ViewMetaSchema,
|
|
1452
1517
|
values: viewValues,
|
|
1453
1518
|
onSave: schema.readonly ? void 0 : handleUpdate
|
|
1454
|
-
}), /* @__PURE__ */
|
|
1519
|
+
}), /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("div", {
|
|
1455
1520
|
role: "none",
|
|
1456
1521
|
className: "p-2"
|
|
1457
|
-
}, /* @__PURE__ */
|
|
1522
|
+
}, /* @__PURE__ */ React14.createElement("label", {
|
|
1458
1523
|
className: mx8(inputTextLabel)
|
|
1459
|
-
}, t("fields label"))), /* @__PURE__ */
|
|
1524
|
+
}, t("fields label"))), /* @__PURE__ */ React14.createElement(List2.Root, {
|
|
1460
1525
|
items: view.fields,
|
|
1461
1526
|
isItem: S2.is(FieldSchema),
|
|
1462
1527
|
getId: (field2) => field2.id,
|
|
1463
1528
|
onMove: schema.readonly ? void 0 : handleMove
|
|
1464
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
1529
|
+
}, ({ items: fields }) => /* @__PURE__ */ React14.createElement(React14.Fragment, null, showHeading && /* @__PURE__ */ React14.createElement("div", {
|
|
1465
1530
|
role: "heading",
|
|
1466
1531
|
className: grid
|
|
1467
|
-
}, /* @__PURE__ */
|
|
1532
|
+
}, /* @__PURE__ */ React14.createElement("div", null), /* @__PURE__ */ React14.createElement("div", {
|
|
1468
1533
|
className: "flex items-center text-sm"
|
|
1469
|
-
}, t("field path label"))), /* @__PURE__ */
|
|
1534
|
+
}, t("field path label"))), /* @__PURE__ */ React14.createElement("div", {
|
|
1470
1535
|
role: "list",
|
|
1471
1536
|
className: "flex flex-col w-full"
|
|
1472
|
-
}, fields?.map((field2) => /* @__PURE__ */
|
|
1537
|
+
}, fields?.map((field2) => /* @__PURE__ */ React14.createElement(List2.Item, {
|
|
1473
1538
|
key: field2.id,
|
|
1474
1539
|
item: field2,
|
|
1475
1540
|
classNames: mx8(grid, ghostHover, "cursor-pointer")
|
|
1476
|
-
}, /* @__PURE__ */
|
|
1541
|
+
}, /* @__PURE__ */ React14.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React14.createElement(List2.ItemTitle, {
|
|
1477
1542
|
onClick: () => handleSelect(field2)
|
|
1478
|
-
}, field2.path), /* @__PURE__ */
|
|
1543
|
+
}, field2.path), /* @__PURE__ */ React14.createElement("div", {
|
|
1479
1544
|
className: "flex items-center gap-2 -ml-4"
|
|
1480
|
-
}, /* @__PURE__ */
|
|
1545
|
+
}, /* @__PURE__ */ React14.createElement(List2.ItemButton, {
|
|
1481
1546
|
icon: "ph--eye-slash--regular",
|
|
1482
1547
|
disabled: view.fields.length <= 1,
|
|
1483
1548
|
onClick: () => handleHide(field2.id)
|
|
1484
|
-
}), !schema.readonly && /* @__PURE__ */
|
|
1549
|
+
}), !schema.readonly && /* @__PURE__ */ React14.createElement(List2.ItemDeleteButton, {
|
|
1485
1550
|
icon: "ph--trash--regular",
|
|
1486
1551
|
disabled: view.fields.length <= 1,
|
|
1487
1552
|
onClick: () => handleDelete(field2.id)
|
|
1488
|
-
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */
|
|
1553
|
+
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("div", {
|
|
1489
1554
|
role: "none",
|
|
1490
1555
|
className: "p-2"
|
|
1491
|
-
}, /* @__PURE__ */
|
|
1556
|
+
}, /* @__PURE__ */ React14.createElement("label", {
|
|
1492
1557
|
className: mx8(inputTextLabel)
|
|
1493
|
-
}, t("hidden fields label"))), /* @__PURE__ */
|
|
1558
|
+
}, t("hidden fields label"))), /* @__PURE__ */ React14.createElement(List2.Root, {
|
|
1494
1559
|
items: hiddenProperties,
|
|
1495
1560
|
isItem: (item) => typeof item === "string",
|
|
1496
1561
|
getId: (property) => property
|
|
1497
|
-
}, ({ items: properties }) => /* @__PURE__ */
|
|
1562
|
+
}, ({ items: properties }) => /* @__PURE__ */ React14.createElement("div", {
|
|
1498
1563
|
role: "list",
|
|
1499
1564
|
className: "flex flex-col w-full"
|
|
1500
|
-
}, properties?.map((property) => /* @__PURE__ */
|
|
1565
|
+
}, properties?.map((property) => /* @__PURE__ */ React14.createElement(List2.Item, {
|
|
1501
1566
|
key: property,
|
|
1502
1567
|
item: property,
|
|
1503
1568
|
classNames: mx8(grid, ghostHover, "cursor-pointer")
|
|
1504
|
-
}, /* @__PURE__ */
|
|
1569
|
+
}, /* @__PURE__ */ React14.createElement("div", null), /* @__PURE__ */ React14.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React14.createElement(List2.ItemButton, {
|
|
1505
1570
|
icon: "ph--eye--regular",
|
|
1506
1571
|
onClick: () => handleShow(property)
|
|
1507
|
-
}))))))), field && /* @__PURE__ */
|
|
1572
|
+
}))))))), field && /* @__PURE__ */ React14.createElement(FieldEditor, {
|
|
1508
1573
|
key: field.id,
|
|
1509
1574
|
view,
|
|
1510
1575
|
projection,
|
|
1511
1576
|
field,
|
|
1512
1577
|
registry,
|
|
1513
1578
|
onSave: handleClose
|
|
1514
|
-
}), !readonly && !field && /* @__PURE__ */
|
|
1579
|
+
}), !readonly && !field && /* @__PURE__ */ React14.createElement("div", {
|
|
1515
1580
|
className: "flex p-2 justify-center"
|
|
1516
|
-
}, /* @__PURE__ */
|
|
1581
|
+
}, /* @__PURE__ */ React14.createElement(IconButton4, {
|
|
1517
1582
|
icon: "ph--plus--regular",
|
|
1518
1583
|
label: t("button add property"),
|
|
1519
1584
|
onClick: schema.readonly ? void 0 : handleAdd,
|
|
@@ -1627,12 +1692,14 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1627
1692
|
switch (format) {
|
|
1628
1693
|
case FormatEnum3.Markdown:
|
|
1629
1694
|
return void 0;
|
|
1695
|
+
case FormatEnum3.Time:
|
|
1630
1696
|
case FormatEnum3.Timestamp:
|
|
1631
1697
|
case FormatEnum3.DateTime:
|
|
1632
1698
|
case FormatEnum3.Date:
|
|
1633
|
-
case FormatEnum3.
|
|
1699
|
+
case FormatEnum3.Duration:
|
|
1634
1700
|
return [
|
|
1635
|
-
"font-mono"
|
|
1701
|
+
"font-mono",
|
|
1702
|
+
"text-right"
|
|
1636
1703
|
];
|
|
1637
1704
|
case FormatEnum3.Currency:
|
|
1638
1705
|
return [
|
|
@@ -1647,15 +1714,13 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1647
1714
|
return void 0;
|
|
1648
1715
|
}
|
|
1649
1716
|
};
|
|
1650
|
-
var cellClassesForRowSelection = (selected) => selected ? [
|
|
1651
|
-
"!bg-gridCellSelected"
|
|
1652
|
-
] : void 0;
|
|
1653
1717
|
var pathNotUniqueError = (path) => ({
|
|
1654
1718
|
path: "path",
|
|
1655
1719
|
message: `'${path}' is already present`
|
|
1656
1720
|
});
|
|
1657
1721
|
|
|
1658
1722
|
// packages/ui/react-ui-form/src/util/formatting.ts
|
|
1723
|
+
import { format as formatDate } from "date-fns/format";
|
|
1659
1724
|
import { FormatEnum as FormatEnum4, GeoLocation as GeoLocation3, TypeEnum as TypeEnum2 } from "@dxos/echo-schema";
|
|
1660
1725
|
var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
1661
1726
|
const formatScalar = (type2) => {
|
|
@@ -1697,17 +1762,14 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1697
1762
|
maximumFractionDigits: 2
|
|
1698
1763
|
});
|
|
1699
1764
|
}
|
|
1700
|
-
case FormatEnum4.
|
|
1701
|
-
|
|
1765
|
+
case FormatEnum4.Date: {
|
|
1766
|
+
return formatDate(new Date(value), "yyyy-MM-dd");
|
|
1767
|
+
}
|
|
1702
1768
|
case FormatEnum4.Time: {
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
return date.toLocaleDateString(locale);
|
|
1708
|
-
} else {
|
|
1709
|
-
return date.toLocaleTimeString(locale);
|
|
1710
|
-
}
|
|
1769
|
+
return formatDate(new Date(value), "HH:mm:ss");
|
|
1770
|
+
}
|
|
1771
|
+
case FormatEnum4.DateTime: {
|
|
1772
|
+
return formatDate(new Date(value), "yyyy-MM-dd HH:mm:ss");
|
|
1711
1773
|
}
|
|
1712
1774
|
case FormatEnum4.GeoPoint: {
|
|
1713
1775
|
if (value === null || value === void 0) {
|
|
@@ -1784,6 +1846,13 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
1784
1846
|
};
|
|
1785
1847
|
export {
|
|
1786
1848
|
BooleanInput,
|
|
1849
|
+
ControlFrame,
|
|
1850
|
+
ControlFrameItem,
|
|
1851
|
+
ControlGroup,
|
|
1852
|
+
ControlItem,
|
|
1853
|
+
ControlItemInput,
|
|
1854
|
+
ControlSection,
|
|
1855
|
+
ControlSectionHeading,
|
|
1787
1856
|
DeprecatedFormContainer,
|
|
1788
1857
|
DeprecatedFormInput,
|
|
1789
1858
|
FieldEditor,
|
|
@@ -1799,7 +1868,7 @@ export {
|
|
|
1799
1868
|
TupleInput,
|
|
1800
1869
|
ViewEditor,
|
|
1801
1870
|
cellClassesForFieldType,
|
|
1802
|
-
|
|
1871
|
+
controlItemClasses,
|
|
1803
1872
|
formatForDisplay,
|
|
1804
1873
|
formatForEditing,
|
|
1805
1874
|
parseValue,
|