@protobase/ui 0.21.0 → 0.21.1
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/app/create/create-page.js +12 -4
- package/dist/app/create/create-record-form.js +3 -1
- package/dist/app/create/form.d.ts +3 -2
- package/dist/app/create/form.js +3 -1
- package/dist/app/field-editor.js +5 -1
- package/dist/app/field-errors.js +70 -0
- package/dist/app/pages/blocks/modal-form.js +13 -4
- package/dist/app/record-page.js +9 -2
- package/dist/app/use-focus-first-invalid.js +16 -0
- package/dist/app/use-live-save.js +4 -2
- package/dist/app/use-record-editor.js +11 -3
- package/dist/data-grid/grid-header.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/package.js +1 -1
- package/dist/primitives/checkbox.js +2 -1
- package/dist/primitives/field-control.d.ts +19 -0
- package/dist/primitives/field-control.js +21 -0
- package/dist/primitives/input.js +17 -11
- package/dist/primitives/switch.js +15 -9
- package/dist/primitives/textarea.js +4 -0
- package/dist/record-view/field.d.ts +7 -1
- package/dist/record-view/field.js +83 -56
- package/dist/shell/assets/app-DGVgRtZo.js +69 -0
- package/dist/shell/assets/{index-iXIDNHEm.js → index-CW037BBI.js} +1 -1
- package/dist/shell/assets/{maplibre-DxWag0Wp.js → maplibre-Ck9abcyu.js} +2 -2
- package/dist/shell/assets/{markdown-content-Bco0XDqw.js → markdown-content-BDjSKrC7.js} +1 -1
- package/dist/shell/assets/{record-map-Ca1fz02Q.js → record-map-CKPZ2KJs.js} +1 -1
- package/dist/shell/assets/{records-map-JooppeKw.js → records-map-DadV3GNO.js} +1 -1
- package/dist/shell/assets/shared-protobase-ui-tJCYxj7E.js +1 -0
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +1 -1
- package/package.json +4 -4
- package/dist/shell/assets/app-BBx2Bkop.js +0 -69
- package/dist/shell/assets/shared-protobase-ui-BZs06oKf.js +0 -1
|
@@ -1,65 +1,92 @@
|
|
|
1
1
|
import { Avatar } from "../primitives/avatar.js";
|
|
2
|
+
import { FieldControlContext } from "../primitives/field-control.js";
|
|
2
3
|
import { Button } from "../primitives/button.js";
|
|
4
|
+
import { useId } from "react";
|
|
3
5
|
import { TriangleAlert } from "lucide-react";
|
|
4
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
7
|
//#region src/record-view/field.tsx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A labelled form field. The `Input` or `Textarea` inside takes its label, its name, the help and error that describe
|
|
10
|
+
* it and whether it is invalid or required from the field; another control uses `useFieldControl`.
|
|
11
|
+
*/
|
|
12
|
+
const Field = ({ name, label, required, help, example, error, conflict, wide, children }) => {
|
|
13
|
+
const id = useId();
|
|
14
|
+
const describedBy = [
|
|
15
|
+
help && `${id}-help`,
|
|
16
|
+
example && `${id}-example`,
|
|
17
|
+
error && `${id}-error`
|
|
18
|
+
].filter(Boolean).join(" ") || void 0;
|
|
19
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: wide ? "sm:col-span-2" : void 0,
|
|
21
|
+
children: [
|
|
22
|
+
/* @__PURE__ */ jsxs("div", {
|
|
23
|
+
className: "mb-1.5 flex items-center gap-2",
|
|
24
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
25
|
+
htmlFor: id,
|
|
26
|
+
className: "font-medium text-foreground",
|
|
27
|
+
children: [label, required && /* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: "ml-0.5 text-danger-text",
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
children: "*"
|
|
31
|
+
})]
|
|
32
|
+
}), conflict && /* @__PURE__ */ jsxs("span", {
|
|
33
|
+
className: "inline-flex items-center gap-1.5 text-warning-text",
|
|
34
|
+
title: `${conflict.user.name} saved a different value`,
|
|
35
|
+
children: [/* @__PURE__ */ jsx(TriangleAlert, { className: "size-3.5" }), /* @__PURE__ */ jsx(Avatar, {
|
|
36
|
+
initials: conflict.user.initials,
|
|
37
|
+
hue: conflict.user.hue,
|
|
38
|
+
size: "xs"
|
|
39
|
+
})]
|
|
17
40
|
})]
|
|
18
|
-
}),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ jsx(FieldControlContext, {
|
|
43
|
+
value: {
|
|
44
|
+
id,
|
|
45
|
+
name,
|
|
46
|
+
describedBy,
|
|
47
|
+
invalid: Boolean(error),
|
|
48
|
+
required: Boolean(required)
|
|
49
|
+
},
|
|
50
|
+
children
|
|
51
|
+
}),
|
|
52
|
+
help && /* @__PURE__ */ jsx("p", {
|
|
53
|
+
id: `${id}-help`,
|
|
54
|
+
className: "mt-1.5 text-xs text-muted-foreground",
|
|
55
|
+
children: help
|
|
56
|
+
}),
|
|
57
|
+
example && /* @__PURE__ */ jsxs("p", {
|
|
58
|
+
id: `${id}-example`,
|
|
59
|
+
className: "mt-0.5 text-xs text-faint-foreground",
|
|
60
|
+
children: ["Example: ", example]
|
|
61
|
+
}),
|
|
62
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
63
|
+
id: `${id}-error`,
|
|
64
|
+
className: "mt-1.5 text-xs font-medium text-danger-text",
|
|
65
|
+
children: error
|
|
66
|
+
}),
|
|
67
|
+
conflict && /* @__PURE__ */ jsxs("div", {
|
|
68
|
+
className: "mt-2 flex items-center justify-between gap-3 rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning-text",
|
|
69
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
70
|
+
/* @__PURE__ */ jsx("strong", { children: conflict.user.name }),
|
|
71
|
+
" saved this ",
|
|
72
|
+
conflict.ago,
|
|
73
|
+
": ",
|
|
74
|
+
/* @__PURE__ */ jsx("strong", { children: conflict.theirValue })
|
|
75
|
+
] }), /* @__PURE__ */ jsxs("span", {
|
|
76
|
+
className: "flex gap-1.5",
|
|
77
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
78
|
+
size: "sm",
|
|
79
|
+
onClick: conflict.onKeepMine,
|
|
80
|
+
children: "Keep mine"
|
|
81
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
82
|
+
size: "sm",
|
|
83
|
+
onClick: conflict.onUseTheirs,
|
|
84
|
+
children: "Use theirs"
|
|
85
|
+
})]
|
|
25
86
|
})]
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
className: "mt-1.5 text-xs text-muted-foreground",
|
|
31
|
-
children: help
|
|
32
|
-
}),
|
|
33
|
-
example && /* @__PURE__ */ jsxs("p", {
|
|
34
|
-
className: "mt-0.5 text-xs text-faint-foreground",
|
|
35
|
-
children: ["Example: ", example]
|
|
36
|
-
}),
|
|
37
|
-
error && /* @__PURE__ */ jsx("p", {
|
|
38
|
-
className: "mt-1.5 text-xs font-medium text-danger-text",
|
|
39
|
-
children: error
|
|
40
|
-
}),
|
|
41
|
-
conflict && /* @__PURE__ */ jsxs("div", {
|
|
42
|
-
className: "mt-2 flex items-center justify-between gap-3 rounded-md border border-warning/30 bg-warning-soft px-3 py-2 text-xs text-warning-text",
|
|
43
|
-
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
44
|
-
/* @__PURE__ */ jsx("strong", { children: conflict.user.name }),
|
|
45
|
-
" saved this ",
|
|
46
|
-
conflict.ago,
|
|
47
|
-
": ",
|
|
48
|
-
/* @__PURE__ */ jsx("strong", { children: conflict.theirValue })
|
|
49
|
-
] }), /* @__PURE__ */ jsxs("span", {
|
|
50
|
-
className: "flex gap-1.5",
|
|
51
|
-
children: [/* @__PURE__ */ jsx(Button, {
|
|
52
|
-
size: "sm",
|
|
53
|
-
onClick: conflict.onKeepMine,
|
|
54
|
-
children: "Keep mine"
|
|
55
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
56
|
-
size: "sm",
|
|
57
|
-
onClick: conflict.onUseTheirs,
|
|
58
|
-
children: "Use theirs"
|
|
59
|
-
})]
|
|
60
|
-
})]
|
|
61
|
-
})
|
|
62
|
-
]
|
|
63
|
-
});
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
};
|
|
64
91
|
//#endregion
|
|
65
92
|
export { Field };
|