@dtkt/protoform 0.0.0-stage → 0.1.0
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/LICENSE +202 -0
- package/README.md +221 -2
- package/dist/base.d.ts +19 -0
- package/dist/comments.d.ts +9 -0
- package/dist/components/enum.d.ts +24 -0
- package/dist/components/field.d.ts +16 -0
- package/dist/components/frame.d.ts +6 -0
- package/dist/components/group.d.ts +25 -0
- package/dist/components/hooks.d.ts +18 -0
- package/dist/components/index.d.ts +13 -0
- package/dist/components/index.js +14 -0
- package/dist/components/list.d.ts +7 -0
- package/dist/components/map.d.ts +7 -0
- package/dist/components/message.d.ts +17 -0
- package/dist/components/oneof.d.ts +8 -0
- package/dist/components/protoform.d.ts +20 -0
- package/dist/components/scalar.d.ts +34 -0
- package/dist/components/select.d.ts +1 -0
- package/dist/components/submit.d.ts +8 -0
- package/dist/components/wkt.d.ts +20 -0
- package/dist/context-DSrebuNf.js +1024 -0
- package/dist/element.d.ts +23 -0
- package/dist/enum.d.ts +17 -0
- package/dist/env.d.ts +28 -0
- package/dist/favicon.ico +0 -0
- package/dist/field.d.ts +17 -0
- package/dist/gen/dtkt/protoform/v1beta1/protoform_pb.d.ts +463 -0
- package/dist/gen/dtkt/protoform/v1beta1/protoform_pb.js +6 -0
- package/dist/gen/google/api/field_behavior_pb.d.ts +133 -0
- package/dist/gen/google/api/field_behavior_pb.js +5 -0
- package/dist/icons.svg +24 -0
- package/dist/kit/bare.d.ts +3 -0
- package/dist/kit/context.d.ts +56 -0
- package/dist/kit/index.d.ts +4 -0
- package/dist/kit/index.js +1 -0
- package/dist/kit/tailwind/index.d.ts +7 -0
- package/dist/kit/tailwind/index.js +327 -0
- package/dist/kit/types.d.ts +126 -0
- package/dist/list.d.ts +29 -0
- package/dist/main.d.ts +13 -0
- package/dist/main.js +3 -0
- package/dist/map.d.ts +36 -0
- package/dist/message.d.ts +61 -0
- package/dist/oneof.d.ts +27 -0
- package/dist/path.d.ts +8 -0
- package/dist/protoform-DmMJ7LSw.js +835 -0
- package/dist/providers/env.d.ts +4 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +11 -0
- package/dist/providers/ui.d.ts +13 -0
- package/dist/scalar.d.ts +30 -0
- package/dist/store.d.ts +29 -0
- package/dist/styles.css +2 -0
- package/dist/ui-DGND0oTu.js +32 -0
- package/dist/wellknown.d.ts +10 -0
- package/package.json +141 -4
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { file_google_protobuf_descriptor as e } from "@bufbuild/protobuf/wkt";
|
|
2
|
+
import { enumDesc as t, extDesc as n, fileDesc as r, tsEnum as i } from "@bufbuild/protobuf/codegenv2";
|
|
3
|
+
// lib/gen/google/api/field_behavior_pb.js
|
|
4
|
+
var a = /*@__PURE__*/ r("Ch9nb29nbGUvYXBpL2ZpZWxkX2JlaGF2aW9yLnByb3RvEgpnb29nbGUuYXBpKrYBCg1GaWVsZEJlaGF2aW9yEh4KGkZJRUxEX0JFSEFWSU9SX1VOU1BFQ0lGSUVEEAASDAoIT1BUSU9OQUwQARIMCghSRVFVSVJFRBACEg8KC09VVFBVVF9PTkxZEAMSDgoKSU5QVVRfT05MWRAEEg0KCUlNTVVUQUJMRRAFEhIKDlVOT1JERVJFRF9MSVNUEAYSFQoRTk9OX0VNUFRZX0RFRkFVTFQQBxIOCgpJREVOVElGSUVSEAg6YAoOZmllbGRfYmVoYXZpb3ISHS5nb29nbGUucHJvdG9idWYuRmllbGRPcHRpb25zGJwIIAMoDjIZLmdvb2dsZS5hcGkuRmllbGRCZWhhdmlvclINZmllbGRCZWhhdmlvckJwCg5jb20uZ29vZ2xlLmFwaUISRmllbGRCZWhhdmlvclByb3RvUAFaQWdvb2dsZS5nb2xhbmcub3JnL2dlbnByb3RvL2dvb2dsZWFwaXMvYXBpL2Fubm90YXRpb25zO2Fubm90YXRpb25zogIER0FQSWIGcHJvdG8z", [e]), o = /*@__PURE__*/ t(a, 0), s = /*@__PURE__*/ i(o), c = /*@__PURE__*/ n(a, 0);
|
|
5
|
+
export { s as FieldBehavior, o as FieldBehaviorSchema, c as field_behavior, a as file_google_api_field_behavior };
|
package/dist/icons.svg
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
|
3
|
+
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
|
4
|
+
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
|
5
|
+
</symbol>
|
|
6
|
+
<symbol id="discord-icon" viewBox="0 0 20 19">
|
|
7
|
+
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
|
8
|
+
</symbol>
|
|
9
|
+
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
|
10
|
+
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
|
11
|
+
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
|
12
|
+
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
|
13
|
+
</symbol>
|
|
14
|
+
<symbol id="github-icon" viewBox="0 0 19 19">
|
|
15
|
+
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
|
16
|
+
</symbol>
|
|
17
|
+
<symbol id="social-icon" viewBox="0 0 20 20">
|
|
18
|
+
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
|
19
|
+
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
|
20
|
+
</symbol>
|
|
21
|
+
<symbol id="x-icon" viewBox="0 0 19 19">
|
|
22
|
+
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
|
23
|
+
</symbol>
|
|
24
|
+
</svg>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { FieldElementProps } from '../components/field';
|
|
3
|
+
import { Field } from '../field';
|
|
4
|
+
import { UIKit } from './types';
|
|
5
|
+
export declare const defaultMessages: {
|
|
6
|
+
edit: string;
|
|
7
|
+
clear: string;
|
|
8
|
+
addItem: string;
|
|
9
|
+
addEntry: string;
|
|
10
|
+
key: string;
|
|
11
|
+
value: string;
|
|
12
|
+
noItems: string;
|
|
13
|
+
notSet: string;
|
|
14
|
+
select: string;
|
|
15
|
+
selectType: string;
|
|
16
|
+
selectCase: string;
|
|
17
|
+
now: string;
|
|
18
|
+
duplicateKey: string;
|
|
19
|
+
item: (n: number) => string;
|
|
20
|
+
entry: (key: string) => string;
|
|
21
|
+
entryKey: (key: string) => string;
|
|
22
|
+
entryValue: (key: string) => string;
|
|
23
|
+
removeItem: (n: number) => string;
|
|
24
|
+
moveItemUp: (n: number) => string;
|
|
25
|
+
moveItemDown: (n: number) => string;
|
|
26
|
+
removeEntry: (key: string) => string;
|
|
27
|
+
};
|
|
28
|
+
/** Strings used by the built-in components; override any of them for i18n. */
|
|
29
|
+
export type UIMessages = typeof defaultMessages;
|
|
30
|
+
/** Renders a field. Receives the same props as the built-in element. */
|
|
31
|
+
export type FieldRenderer = ComponentType<FieldElementProps> & {
|
|
32
|
+
/**
|
|
33
|
+
* `"field"` (default) wraps the renderer in a labelled field frame;
|
|
34
|
+
* `"none"` lets it draw its own frame (see `FieldSection`).
|
|
35
|
+
*/
|
|
36
|
+
frame?: "field" | "none";
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Custom renderers keyed by field full name (`pkg.Message.field`) or by the
|
|
40
|
+
* type name of the field's message/enum (`google.protobuf.Timestamp`).
|
|
41
|
+
*/
|
|
42
|
+
export type Renderers = Record<string, FieldRenderer>;
|
|
43
|
+
export type UIContextValue = {
|
|
44
|
+
kit: UIKit;
|
|
45
|
+
renderers: Renderers;
|
|
46
|
+
/** Called first; return a renderer to take over a field, or undefined to continue. */
|
|
47
|
+
resolve?: (field: Field) => FieldRenderer | undefined;
|
|
48
|
+
messages: UIMessages;
|
|
49
|
+
};
|
|
50
|
+
export declare const UIContext: import('react').Context<UIContextValue>;
|
|
51
|
+
export declare function useUI(): UIContextValue;
|
|
52
|
+
export declare function useKit(): UIKit;
|
|
53
|
+
export declare function useMessages(): UIMessages;
|
|
54
|
+
export declare function resolveRenderer(ui: UIContextValue, field: Field): FieldRenderer | undefined;
|
|
55
|
+
/** Combines kits over the bare kit; later kits win. */
|
|
56
|
+
export declare function defineKit(...kits: Partial<UIKit>[]): UIKit;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { c as bareKit, n as defaultMessages, r as defineKit, i as resolveRenderer, a as useKit, o as useMessages, s as useUI } from "../context-DSrebuNf.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UIKit } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Tailwind-styled primitives built on Headless UI. Import
|
|
4
|
+
* `@dtkt/protoform/styles.css` for the styles; dark mode follows the OS
|
|
5
|
+
* (override with `.dark`/`.light` or `data-theme` on an ancestor).
|
|
6
|
+
*/
|
|
7
|
+
export declare const tailwindKit: UIKit;
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
2
|
+
import { Button as r, Checkbox as i, Description as a, Disclosure as o, DisclosureButton as s, DisclosurePanel as c, Field as l, Input as u, Label as d, Radio as f, RadioGroup as p, Select as m, Switch as h, Textarea as g } from "@headlessui/react";
|
|
3
|
+
// lib/kit/tailwind/index.tsx
|
|
4
|
+
function _({ onSubmit: e, children: n }) {
|
|
5
|
+
return /* @__PURE__ */ t("form", {
|
|
6
|
+
className: "pf-form",
|
|
7
|
+
noValidate: !0,
|
|
8
|
+
onSubmit: e,
|
|
9
|
+
children: n
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function v({ children: e }) {
|
|
13
|
+
return /* @__PURE__ */ t("div", {
|
|
14
|
+
className: "pf-stack",
|
|
15
|
+
children: e
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function y({ id: r, children: i, actions: a, errors: o = [] }) {
|
|
19
|
+
return /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ n("div", {
|
|
20
|
+
className: "pf-row",
|
|
21
|
+
children: [/* @__PURE__ */ t("div", {
|
|
22
|
+
className: "pf-row-content",
|
|
23
|
+
children: i
|
|
24
|
+
}), a && /* @__PURE__ */ t("div", {
|
|
25
|
+
className: "pf-row-actions",
|
|
26
|
+
children: a
|
|
27
|
+
})]
|
|
28
|
+
}), /* @__PURE__ */ t(b, {
|
|
29
|
+
id: `${r}-errors`,
|
|
30
|
+
errors: o
|
|
31
|
+
})] });
|
|
32
|
+
}
|
|
33
|
+
function b({ id: e, errors: n }) {
|
|
34
|
+
return n.length === 0 ? null : /* @__PURE__ */ t("ul", {
|
|
35
|
+
className: "pf-errors",
|
|
36
|
+
id: e,
|
|
37
|
+
"aria-live": "polite",
|
|
38
|
+
children: n.map((e) => /* @__PURE__ */ t("li", { children: e }, e))
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function x({ id: e, label: r, description: i, errors: o, required: s, children: c }) {
|
|
42
|
+
return /* @__PURE__ */ n(l, {
|
|
43
|
+
className: "pf-field",
|
|
44
|
+
"data-invalid": o.length > 0 || void 0,
|
|
45
|
+
children: [/* @__PURE__ */ n(d, {
|
|
46
|
+
className: "pf-label",
|
|
47
|
+
id: `${e}-label`,
|
|
48
|
+
children: [r, s && /* @__PURE__ */ t("span", {
|
|
49
|
+
className: "pf-required",
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
children: " *"
|
|
52
|
+
})]
|
|
53
|
+
}), /* @__PURE__ */ n("div", {
|
|
54
|
+
className: "pf-field-body",
|
|
55
|
+
children: [
|
|
56
|
+
i && /* @__PURE__ */ t(a, {
|
|
57
|
+
className: "pf-description",
|
|
58
|
+
id: `${e}-description`,
|
|
59
|
+
children: i
|
|
60
|
+
}),
|
|
61
|
+
c,
|
|
62
|
+
o.length > 0 && /* @__PURE__ */ t(a, {
|
|
63
|
+
as: "ul",
|
|
64
|
+
className: "pf-errors",
|
|
65
|
+
id: `${e}-errors`,
|
|
66
|
+
"aria-live": "polite",
|
|
67
|
+
children: o.map((e) => /* @__PURE__ */ t("li", { children: e }, e))
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function S() {
|
|
74
|
+
return /* @__PURE__ */ t("svg", {
|
|
75
|
+
className: "pf-chevron",
|
|
76
|
+
viewBox: "0 0 20 20",
|
|
77
|
+
fill: "none",
|
|
78
|
+
"aria-hidden": "true",
|
|
79
|
+
children: /* @__PURE__ */ t("path", {
|
|
80
|
+
d: "m6 8 4 4 4-4",
|
|
81
|
+
stroke: "currentColor",
|
|
82
|
+
strokeWidth: "1.5",
|
|
83
|
+
strokeLinecap: "round",
|
|
84
|
+
strokeLinejoin: "round"
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function C({ id: e, title: r, description: i, errors: a, depth: l, actions: u, collapsible: d, children: f }) {
|
|
89
|
+
let p = i && /* @__PURE__ */ t("p", {
|
|
90
|
+
className: "pf-description",
|
|
91
|
+
id: `${e}-description`,
|
|
92
|
+
children: i
|
|
93
|
+
}), m = /* @__PURE__ */ t(b, {
|
|
94
|
+
id: `${e}-errors`,
|
|
95
|
+
errors: a
|
|
96
|
+
});
|
|
97
|
+
return d ? /* @__PURE__ */ n(o, {
|
|
98
|
+
as: "div",
|
|
99
|
+
className: "pf-section",
|
|
100
|
+
role: "group",
|
|
101
|
+
"aria-labelledby": `${e}-title`,
|
|
102
|
+
"data-depth": l,
|
|
103
|
+
defaultOpen: !0,
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ n("div", {
|
|
106
|
+
className: "pf-section-header",
|
|
107
|
+
children: [/* @__PURE__ */ n(s, {
|
|
108
|
+
className: "pf-section-toggle",
|
|
109
|
+
children: [/* @__PURE__ */ t(S, {}), /* @__PURE__ */ t("span", {
|
|
110
|
+
className: "pf-section-title",
|
|
111
|
+
id: `${e}-title`,
|
|
112
|
+
children: r
|
|
113
|
+
})]
|
|
114
|
+
}), u && /* @__PURE__ */ t("div", {
|
|
115
|
+
className: "pf-section-actions",
|
|
116
|
+
children: u
|
|
117
|
+
})]
|
|
118
|
+
}),
|
|
119
|
+
m,
|
|
120
|
+
/* @__PURE__ */ n(c, {
|
|
121
|
+
className: "pf-section-body",
|
|
122
|
+
unmount: !1,
|
|
123
|
+
children: [p, f]
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
}) : /* @__PURE__ */ n("div", {
|
|
127
|
+
className: "pf-section",
|
|
128
|
+
role: "group",
|
|
129
|
+
"data-depth": l,
|
|
130
|
+
"aria-labelledby": `${e}-title`,
|
|
131
|
+
"aria-describedby": i ? `${e}-description` : void 0,
|
|
132
|
+
children: [
|
|
133
|
+
/* @__PURE__ */ n("div", {
|
|
134
|
+
className: "pf-section-header",
|
|
135
|
+
children: [/* @__PURE__ */ t("span", {
|
|
136
|
+
className: "pf-section-title",
|
|
137
|
+
id: `${e}-title`,
|
|
138
|
+
children: r
|
|
139
|
+
}), u && /* @__PURE__ */ t("div", {
|
|
140
|
+
className: "pf-section-actions",
|
|
141
|
+
children: u
|
|
142
|
+
})]
|
|
143
|
+
}),
|
|
144
|
+
p,
|
|
145
|
+
m,
|
|
146
|
+
/* @__PURE__ */ t("div", {
|
|
147
|
+
className: "pf-section-body",
|
|
148
|
+
children: f
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function w({ value: e, onChange: n, onBlur: r, onEnter: i, type: a = "text", inputMode: o, placeholder: s, mono: c, invalid: l, ...d }) {
|
|
154
|
+
return /* @__PURE__ */ t(u, {
|
|
155
|
+
className: "pf-input",
|
|
156
|
+
"data-mono": c || void 0,
|
|
157
|
+
type: a,
|
|
158
|
+
inputMode: o,
|
|
159
|
+
name: d.name,
|
|
160
|
+
value: e,
|
|
161
|
+
placeholder: s,
|
|
162
|
+
disabled: d.disabled,
|
|
163
|
+
readOnly: d.readOnly,
|
|
164
|
+
required: d.required,
|
|
165
|
+
invalid: l,
|
|
166
|
+
"aria-label": d["aria-label"],
|
|
167
|
+
onChange: (e) => n(e.target.value),
|
|
168
|
+
onBlur: r,
|
|
169
|
+
onKeyDown: i && ((e) => {
|
|
170
|
+
e.key === "Enter" && (e.preventDefault(), i());
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function T({ value: e, onChange: n, onBlur: r, rows: i = 4, placeholder: a, mono: o, invalid: s, ...c }) {
|
|
175
|
+
return /* @__PURE__ */ t(g, {
|
|
176
|
+
className: "pf-textarea",
|
|
177
|
+
"data-mono": o || void 0,
|
|
178
|
+
name: c.name,
|
|
179
|
+
rows: i,
|
|
180
|
+
value: e,
|
|
181
|
+
placeholder: a,
|
|
182
|
+
disabled: c.disabled,
|
|
183
|
+
readOnly: c.readOnly,
|
|
184
|
+
required: c.required,
|
|
185
|
+
invalid: s,
|
|
186
|
+
"aria-label": c["aria-label"],
|
|
187
|
+
onChange: (e) => n(e.target.value),
|
|
188
|
+
onBlur: r
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function E({ checked: e, onChange: r, label: a, variant: o = "checkbox", invalid: s, ...c }) {
|
|
192
|
+
let u = {
|
|
193
|
+
name: c.name,
|
|
194
|
+
checked: e,
|
|
195
|
+
onChange: r,
|
|
196
|
+
disabled: c.disabled || c.readOnly,
|
|
197
|
+
"aria-label": c["aria-label"],
|
|
198
|
+
"aria-invalid": s || void 0,
|
|
199
|
+
"data-invalid": s || void 0
|
|
200
|
+
}, f = o === "switch" ? /* @__PURE__ */ t(h, {
|
|
201
|
+
...u,
|
|
202
|
+
className: "pf-switch",
|
|
203
|
+
children: /* @__PURE__ */ t("span", {
|
|
204
|
+
className: "pf-switch-thumb",
|
|
205
|
+
"aria-hidden": "true"
|
|
206
|
+
})
|
|
207
|
+
}) : /* @__PURE__ */ t(i, {
|
|
208
|
+
...u,
|
|
209
|
+
className: "pf-checkbox",
|
|
210
|
+
children: /* @__PURE__ */ t("svg", {
|
|
211
|
+
className: "pf-checkbox-mark",
|
|
212
|
+
viewBox: "0 0 14 14",
|
|
213
|
+
fill: "none",
|
|
214
|
+
"aria-hidden": "true",
|
|
215
|
+
children: /* @__PURE__ */ t("path", {
|
|
216
|
+
d: "M3 8l3 3 5-6",
|
|
217
|
+
stroke: "currentColor",
|
|
218
|
+
strokeWidth: "2",
|
|
219
|
+
strokeLinecap: "round",
|
|
220
|
+
strokeLinejoin: "round"
|
|
221
|
+
})
|
|
222
|
+
})
|
|
223
|
+
});
|
|
224
|
+
return a === void 0 ? f : /* @__PURE__ */ n(l, {
|
|
225
|
+
className: "pf-check-label",
|
|
226
|
+
children: [f, /* @__PURE__ */ t(d, { children: a })]
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function D({ value: e, onChange: r, options: i, placeholder: a, invalid: o, ...s }) {
|
|
230
|
+
return /* @__PURE__ */ n("div", {
|
|
231
|
+
className: "pf-select-wrap",
|
|
232
|
+
children: [/* @__PURE__ */ n(m, {
|
|
233
|
+
className: "pf-select",
|
|
234
|
+
name: s.name,
|
|
235
|
+
value: e,
|
|
236
|
+
disabled: s.disabled || s.readOnly,
|
|
237
|
+
required: s.required,
|
|
238
|
+
invalid: o,
|
|
239
|
+
"aria-label": s["aria-label"],
|
|
240
|
+
onChange: (e) => r(e.target.value),
|
|
241
|
+
children: [a !== void 0 && /* @__PURE__ */ t("option", {
|
|
242
|
+
value: "",
|
|
243
|
+
disabled: !0,
|
|
244
|
+
children: a
|
|
245
|
+
}), i.map((e) => /* @__PURE__ */ t("option", {
|
|
246
|
+
value: e.value,
|
|
247
|
+
disabled: e.disabled,
|
|
248
|
+
children: e.label
|
|
249
|
+
}, e.value))]
|
|
250
|
+
}), /* @__PURE__ */ t(S, {})]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function O({ value: e, onChange: r, options: i, invalid: a, describedBy: o, ...s }) {
|
|
254
|
+
return /* @__PURE__ */ t("div", {
|
|
255
|
+
role: "group",
|
|
256
|
+
id: s.id,
|
|
257
|
+
"aria-label": s["aria-label"],
|
|
258
|
+
"aria-labelledby": s.id && !s["aria-label"] ? `${s.id}-label` : void 0,
|
|
259
|
+
"aria-describedby": o,
|
|
260
|
+
"aria-invalid": a || void 0,
|
|
261
|
+
children: /* @__PURE__ */ t(p, {
|
|
262
|
+
className: "pf-radiogroup",
|
|
263
|
+
name: s.name ?? s.id,
|
|
264
|
+
value: e,
|
|
265
|
+
onChange: r,
|
|
266
|
+
disabled: s.disabled || s.readOnly,
|
|
267
|
+
children: i.map((e) => /* @__PURE__ */ n(l, {
|
|
268
|
+
className: "pf-radio-option",
|
|
269
|
+
disabled: e.disabled,
|
|
270
|
+
children: [/* @__PURE__ */ t(f, {
|
|
271
|
+
value: e.value,
|
|
272
|
+
className: "pf-radio",
|
|
273
|
+
children: /* @__PURE__ */ t("span", {
|
|
274
|
+
className: "pf-radio-dot",
|
|
275
|
+
"aria-hidden": "true"
|
|
276
|
+
})
|
|
277
|
+
}), /* @__PURE__ */ t(d, {
|
|
278
|
+
className: "pf-radio-label",
|
|
279
|
+
children: e.label
|
|
280
|
+
})]
|
|
281
|
+
}, e.value))
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
function k({ accept: e, onFile: n, invalid: r, describedBy: i, ...a }) {
|
|
286
|
+
return /* @__PURE__ */ t("input", {
|
|
287
|
+
className: "pf-file-input",
|
|
288
|
+
type: "file",
|
|
289
|
+
id: a.id,
|
|
290
|
+
name: a.name,
|
|
291
|
+
accept: e?.length ? e.join(",") : void 0,
|
|
292
|
+
disabled: a.disabled || a.readOnly,
|
|
293
|
+
"aria-label": a["aria-label"],
|
|
294
|
+
"aria-labelledby": a.id && !a["aria-label"] ? `${a.id}-label` : void 0,
|
|
295
|
+
"aria-invalid": r || void 0,
|
|
296
|
+
"aria-describedby": i,
|
|
297
|
+
"data-invalid": r || void 0,
|
|
298
|
+
onChange: (e) => n(e.target.files?.[0])
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function A({ variant: e = "secondary", size: n = "md", type: i = "button", disabled: a, onClick: o, children: s, ...c }) {
|
|
302
|
+
return /* @__PURE__ */ t(r, {
|
|
303
|
+
className: "pf-button",
|
|
304
|
+
"data-variant": e,
|
|
305
|
+
"data-size": n,
|
|
306
|
+
type: i,
|
|
307
|
+
disabled: a,
|
|
308
|
+
"aria-label": c["aria-label"],
|
|
309
|
+
onClick: o,
|
|
310
|
+
children: s
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
var j = {
|
|
314
|
+
Form: _,
|
|
315
|
+
Stack: v,
|
|
316
|
+
Row: y,
|
|
317
|
+
Field: x,
|
|
318
|
+
Section: C,
|
|
319
|
+
TextInput: w,
|
|
320
|
+
TextArea: T,
|
|
321
|
+
Checkbox: E,
|
|
322
|
+
Select: D,
|
|
323
|
+
RadioGroup: O,
|
|
324
|
+
FileInput: k,
|
|
325
|
+
Button: A
|
|
326
|
+
};
|
|
327
|
+
export { j as tailwindKit };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ReactNode, SubmitEvent } from 'react';
|
|
2
|
+
export type Option = {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
type ControlProps = {
|
|
8
|
+
id?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
invalid?: boolean;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
/** Id(s) of the elements describing this control (description and errors). */
|
|
15
|
+
describedBy?: string;
|
|
16
|
+
"aria-label"?: string;
|
|
17
|
+
};
|
|
18
|
+
export type TextInputProps = ControlProps & {
|
|
19
|
+
value: string;
|
|
20
|
+
onChange: (value: string) => void;
|
|
21
|
+
onBlur?: () => void;
|
|
22
|
+
/** Called when Enter is pressed; suppresses the form's implicit submit. */
|
|
23
|
+
onEnter?: () => void;
|
|
24
|
+
type?: "text" | "password" | "url" | "email";
|
|
25
|
+
inputMode?: "text" | "numeric" | "decimal" | "url" | "email";
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
/** Render in a monospace font (identifiers, base64, timestamps, JSON). */
|
|
28
|
+
mono?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type TextAreaProps = ControlProps & {
|
|
31
|
+
value: string;
|
|
32
|
+
onChange: (value: string) => void;
|
|
33
|
+
onBlur?: () => void;
|
|
34
|
+
rows?: number;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
mono?: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type CheckboxProps = ControlProps & {
|
|
39
|
+
checked: boolean;
|
|
40
|
+
onChange: (checked: boolean) => void;
|
|
41
|
+
/** Inline label. Omit when an outer `Field` already labels the control. */
|
|
42
|
+
label?: ReactNode;
|
|
43
|
+
variant?: "checkbox" | "switch";
|
|
44
|
+
};
|
|
45
|
+
export type SelectProps = ControlProps & {
|
|
46
|
+
value: string;
|
|
47
|
+
onChange: (value: string) => void;
|
|
48
|
+
options: Option[];
|
|
49
|
+
/** Shown while `value` is empty. */
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
};
|
|
52
|
+
export type RadioGroupProps = ControlProps & {
|
|
53
|
+
value: string;
|
|
54
|
+
onChange: (value: string) => void;
|
|
55
|
+
options: Option[];
|
|
56
|
+
};
|
|
57
|
+
export type FileInputProps = ControlProps & {
|
|
58
|
+
accept?: string[];
|
|
59
|
+
fileName?: string;
|
|
60
|
+
onFile: (file: File | undefined) => void;
|
|
61
|
+
};
|
|
62
|
+
export type ButtonProps = {
|
|
63
|
+
variant?: "primary" | "secondary" | "danger" | "ghost";
|
|
64
|
+
size?: "sm" | "md";
|
|
65
|
+
type?: "button" | "submit";
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
onClick?: () => void;
|
|
68
|
+
"aria-label"?: string;
|
|
69
|
+
children: ReactNode;
|
|
70
|
+
};
|
|
71
|
+
export type FormProps = {
|
|
72
|
+
onSubmit: (event: SubmitEvent<HTMLFormElement>) => void;
|
|
73
|
+
children?: ReactNode;
|
|
74
|
+
};
|
|
75
|
+
export type StackProps = {
|
|
76
|
+
children?: ReactNode;
|
|
77
|
+
};
|
|
78
|
+
/** A horizontal row: growing content with optional trailing actions and errors underneath. */
|
|
79
|
+
export type RowProps = {
|
|
80
|
+
/** Used to build the id (`${id}-errors`) controls can reference in `describedBy`. */
|
|
81
|
+
id?: string;
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
actions?: ReactNode;
|
|
84
|
+
errors?: string[];
|
|
85
|
+
};
|
|
86
|
+
/** Frames a single control with its label, description and errors. */
|
|
87
|
+
export type FieldFrameProps = {
|
|
88
|
+
id: string;
|
|
89
|
+
label: ReactNode;
|
|
90
|
+
description?: string;
|
|
91
|
+
errors: string[];
|
|
92
|
+
required?: boolean;
|
|
93
|
+
children?: ReactNode;
|
|
94
|
+
};
|
|
95
|
+
/** Frames a group of controls (nested messages, lists, maps, oneofs). */
|
|
96
|
+
export type SectionProps = {
|
|
97
|
+
id: string;
|
|
98
|
+
title: ReactNode;
|
|
99
|
+
description?: string;
|
|
100
|
+
errors: string[];
|
|
101
|
+
depth: number;
|
|
102
|
+
/** Trailing controls, e.g. a remove button. */
|
|
103
|
+
actions?: ReactNode;
|
|
104
|
+
collapsible?: boolean;
|
|
105
|
+
children?: ReactNode;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* The set of primitives protoform renders with. Provide your own to use
|
|
109
|
+
* another component library; any primitive you leave out falls back to the
|
|
110
|
+
* unstyled default.
|
|
111
|
+
*/
|
|
112
|
+
export type UIKit = {
|
|
113
|
+
Form: (props: FormProps) => ReactNode;
|
|
114
|
+
Stack: (props: StackProps) => ReactNode;
|
|
115
|
+
Row: (props: RowProps) => ReactNode;
|
|
116
|
+
Field: (props: FieldFrameProps) => ReactNode;
|
|
117
|
+
Section: (props: SectionProps) => ReactNode;
|
|
118
|
+
TextInput: (props: TextInputProps) => ReactNode;
|
|
119
|
+
TextArea: (props: TextAreaProps) => ReactNode;
|
|
120
|
+
Checkbox: (props: CheckboxProps) => ReactNode;
|
|
121
|
+
Select: (props: SelectProps) => ReactNode;
|
|
122
|
+
RadioGroup: (props: RadioGroupProps) => ReactNode;
|
|
123
|
+
FileInput: (props: FileInputProps) => ReactNode;
|
|
124
|
+
Button: (props: ButtonProps) => ReactNode;
|
|
125
|
+
};
|
|
126
|
+
export {};
|
package/dist/list.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { DescField } from '@bufbuild/protobuf';
|
|
2
|
+
import { ReflectList } from '@bufbuild/protobuf/reflect';
|
|
3
|
+
import { BaseField } from './base';
|
|
4
|
+
import { Message } from './message';
|
|
5
|
+
export type ListFieldDesc = Extract<DescField, {
|
|
6
|
+
fieldKind: "list";
|
|
7
|
+
}>;
|
|
8
|
+
export declare class ListField extends BaseField<ListFieldDesc> {
|
|
9
|
+
get(): ReflectList;
|
|
10
|
+
set(value: ReflectList): void;
|
|
11
|
+
get size(): number;
|
|
12
|
+
/** The raw items: scalars, enum numbers, or `ReflectMessage`s. */
|
|
13
|
+
items(): unknown[];
|
|
14
|
+
/** Items of a message list, wrapped so they can be edited and validated. */
|
|
15
|
+
messages(): Message[];
|
|
16
|
+
/** Appends a new zero-valued item (or `value`, if given). */
|
|
17
|
+
add(value?: unknown): void;
|
|
18
|
+
removeAt(index: number): void;
|
|
19
|
+
/** Moves the item at `from` so it ends up at `to`. */
|
|
20
|
+
move(from: number, to: number): void;
|
|
21
|
+
setAt(index: number, value: unknown): void;
|
|
22
|
+
clear(): void;
|
|
23
|
+
toString(): string;
|
|
24
|
+
parse(value: string): void;
|
|
25
|
+
private replace;
|
|
26
|
+
private zeroItem;
|
|
27
|
+
private itemToJson;
|
|
28
|
+
private itemFromJson;
|
|
29
|
+
}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { Protoform } from './components/protoform';
|
|
2
|
+
export * from './element';
|
|
3
|
+
export * from './enum';
|
|
4
|
+
export * from './env';
|
|
5
|
+
export * from './field';
|
|
6
|
+
export * from './list';
|
|
7
|
+
export * from './map';
|
|
8
|
+
export * from './message';
|
|
9
|
+
export * from './oneof';
|
|
10
|
+
export * from './path';
|
|
11
|
+
export * from './scalar';
|
|
12
|
+
export * from './store';
|
|
13
|
+
export * from './wellknown';
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, U as g, V as _, W as v, _ as y, b, d as x, f as S, g as C, h as w, j as T, k as E, l as D, m as O, p as k, u as A, v as j, w as M, x as N, y as P, z as F } from "./context-DSrebuNf.js";
|
|
2
|
+
import { S as I, b as L, t as R, x as z, y as B } from "./protoform-DmMJ7LSw.js";
|
|
3
|
+
export { B as ANY_TYPE_NAME, T as Element, P as EnumField, p as Env, F as EnvContext, i as FormStore, S as ListField, x as MapField, M as Message, h as MessageField, D as OneOfField, R as Protoform, k as ScalarField, b as allEnumValues, t as createDefaultTransport, _ as createDefaultValidator, A as createField, o as defaultRegistry, g as defaultValidator, l as elementFor, N as enumLabel, r as fieldPath, m as formatEnum, O as formatScalar, u as getFieldDescription, f as getProtoDescription, a as getScalarTypeName, d as indexPath, s as isIdentifier, L as isInlineWellKnown, w as isIntegerScalar, z as isJsonWellKnown, C as isNumericScalar, c as isOutputOnly, I as isTextWellKnown, E as keyPath, n as parseEnum, y as parseScalar, e as pathToString, j as tryParseScalar, v as useEnv };
|
package/dist/map.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DescField } from '@bufbuild/protobuf';
|
|
2
|
+
import { ReflectMap } from '@bufbuild/protobuf/reflect';
|
|
3
|
+
import { BaseField } from './base';
|
|
4
|
+
import { Message } from './message';
|
|
5
|
+
export type MapFieldDesc = Extract<DescField, {
|
|
6
|
+
fieldKind: "map";
|
|
7
|
+
}>;
|
|
8
|
+
export type MapKey = string | number | bigint | boolean;
|
|
9
|
+
export declare class MapField extends BaseField<MapFieldDesc> {
|
|
10
|
+
get(): ReflectMap;
|
|
11
|
+
set(value: ReflectMap): void;
|
|
12
|
+
get size(): number;
|
|
13
|
+
/** Entries in insertion order. Values are scalars, enum numbers, or `ReflectMessage`s. */
|
|
14
|
+
entries(): [MapKey, unknown][];
|
|
15
|
+
/** The map key as shown to (and typed by) the user. */
|
|
16
|
+
formatKey(key: MapKey): string;
|
|
17
|
+
/** Parses user input into a key; throws with a user-facing message if invalid. */
|
|
18
|
+
parseKey(input: string): MapKey;
|
|
19
|
+
has(key: MapKey): boolean;
|
|
20
|
+
/** Message values of a message map, wrapped so they can be edited and validated. */
|
|
21
|
+
messages(): [MapKey, Message][];
|
|
22
|
+
/** Adds `key` with a zero value (or `value`); returns false if the key exists. */
|
|
23
|
+
add(key: MapKey, value?: unknown): boolean;
|
|
24
|
+
setValue(key: MapKey, value: unknown): void;
|
|
25
|
+
delete(key: MapKey): void;
|
|
26
|
+
/** Changes a key, keeping the entry's position; returns false if `to` is taken. */
|
|
27
|
+
rename(from: MapKey, to: MapKey): boolean;
|
|
28
|
+
clear(): void;
|
|
29
|
+
toString(): string;
|
|
30
|
+
parse(value: string): void;
|
|
31
|
+
private replace;
|
|
32
|
+
/** A zero value for new entries: "" / 0 / false, or the enum's first value. */
|
|
33
|
+
zeroValue(): unknown;
|
|
34
|
+
private valueToJson;
|
|
35
|
+
private valueFromJson;
|
|
36
|
+
}
|