@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,1024 @@
|
|
|
1
|
+
import { FieldElementSchema as e, field as t } from "./gen/dtkt/protoform/v1beta1/protoform_pb.js";
|
|
2
|
+
import { FieldBehavior as n, field_behavior as r } from "./gen/google/api/field_behavior_pb.js";
|
|
3
|
+
import i, { createContext as a, useContext as o } from "react";
|
|
4
|
+
import { ScalarType as s, create as c, createMutableRegistry as l, equals as u, fromJson as d, getOption as f, hasOption as p, isFieldSet as m, merge as ee, toJson as te, toJsonString as ne } from "@bufbuild/protobuf";
|
|
5
|
+
import { createConnectTransport as re } from "@connectrpc/connect-web";
|
|
6
|
+
import { createValidator as ie } from "@bufbuild/protovalidate";
|
|
7
|
+
import { DescriptorProtoSchema as h, EnumDescriptorProtoSchema as ae, FileDescriptorProtoSchema as g, SourceCodeInfo_LocationSchema as oe, file_google_protobuf_any as se, file_google_protobuf_api as ce, file_google_protobuf_compiler_plugin as le, file_google_protobuf_cpp_features as ue, file_google_protobuf_descriptor as de, file_google_protobuf_duration as fe, file_google_protobuf_empty as pe, file_google_protobuf_field_mask as me, file_google_protobuf_go_features as he, file_google_protobuf_java_features as ge, file_google_protobuf_source_context as _e, file_google_protobuf_struct as ve, file_google_protobuf_timestamp as ye, file_google_protobuf_type as be, file_google_protobuf_wrappers as xe } from "@bufbuild/protobuf/wkt";
|
|
8
|
+
import { field as Se } from "@bufbuild/protovalidate/gen/buf/validate/validate_pb.js";
|
|
9
|
+
import { reflect as _ } from "@bufbuild/protobuf/reflect";
|
|
10
|
+
import { base64Decode as Ce, base64Encode as we } from "@bufbuild/protobuf/wire";
|
|
11
|
+
import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
12
|
+
// lib/env.ts
|
|
13
|
+
var x = l(se, ce, ue, de, fe, pe, me, he, ge, _e, ve, ye, be, xe, le), Te = S(x);
|
|
14
|
+
function S(e = x) {
|
|
15
|
+
return ie({ registry: e });
|
|
16
|
+
}
|
|
17
|
+
function Ee(e = x) {
|
|
18
|
+
return re({
|
|
19
|
+
baseUrl: "http://localhost:9900",
|
|
20
|
+
jsonOptions: { registry: e }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
var C = class {
|
|
24
|
+
registry;
|
|
25
|
+
anyTypeFilter;
|
|
26
|
+
_transport;
|
|
27
|
+
_validator;
|
|
28
|
+
constructor({ registry: e, validator: t, transport: n, anyTypeFilter: r } = {}) {
|
|
29
|
+
this.registry = e ?? x, this.anyTypeFilter = r ?? (() => !0), this._transport = n, this._validator = t;
|
|
30
|
+
}
|
|
31
|
+
get transport() {
|
|
32
|
+
return this._transport ??= Ee(this.registry), this._transport;
|
|
33
|
+
}
|
|
34
|
+
get validator() {
|
|
35
|
+
return this._validator ??= S(this.registry), this._validator;
|
|
36
|
+
}
|
|
37
|
+
}, w = i.createContext(new C()), De = () => i.useContext(w);
|
|
38
|
+
// lib/comments.ts
|
|
39
|
+
function Oe(e) {
|
|
40
|
+
return Ae(ke(e).proto, T(e));
|
|
41
|
+
}
|
|
42
|
+
function ke(e) {
|
|
43
|
+
switch (e.kind) {
|
|
44
|
+
case "message":
|
|
45
|
+
case "enum": return e.file;
|
|
46
|
+
case "enum_value":
|
|
47
|
+
case "field":
|
|
48
|
+
case "oneof": return e.parent.file;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function T(e) {
|
|
52
|
+
switch (e.kind) {
|
|
53
|
+
case "message": return e.parent ? [
|
|
54
|
+
...T(e.parent),
|
|
55
|
+
h.field.nestedType.number,
|
|
56
|
+
e.parent.proto.nestedType.indexOf(e.proto)
|
|
57
|
+
] : [g.field.messageType.number, e.file.proto.messageType.indexOf(e.proto)];
|
|
58
|
+
case "enum": return e.parent ? [
|
|
59
|
+
...T(e.parent),
|
|
60
|
+
h.field.enumType.number,
|
|
61
|
+
e.parent.proto.enumType.indexOf(e.proto)
|
|
62
|
+
] : [g.field.enumType.number, e.file.proto.enumType.indexOf(e.proto)];
|
|
63
|
+
case "enum_value": return [
|
|
64
|
+
...T(e.parent),
|
|
65
|
+
ae.field.value.number,
|
|
66
|
+
e.parent.proto.value.indexOf(e.proto)
|
|
67
|
+
];
|
|
68
|
+
case "field": return [
|
|
69
|
+
...T(e.parent),
|
|
70
|
+
h.field.field.number,
|
|
71
|
+
e.parent.proto.field.indexOf(e.proto)
|
|
72
|
+
];
|
|
73
|
+
case "oneof": return [
|
|
74
|
+
...T(e.parent),
|
|
75
|
+
h.field.oneofDecl.number,
|
|
76
|
+
e.parent.proto.oneofDecl.indexOf(e.proto)
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function Ae(e, t) {
|
|
81
|
+
let n = e.sourceCodeInfo?.location.find((e) => e.path.length === t.length && e.path.every((e, n) => e === t[n]));
|
|
82
|
+
return n ? {
|
|
83
|
+
leadingDetached: n.leadingDetachedComments,
|
|
84
|
+
leading: m(n, oe.field.leadingComments) ? n.leadingComments : void 0,
|
|
85
|
+
trailing: m(n, oe.field.trailingComments) ? n.trailingComments : void 0
|
|
86
|
+
} : { leadingDetached: [] };
|
|
87
|
+
}
|
|
88
|
+
// lib/element.ts
|
|
89
|
+
var E = class {
|
|
90
|
+
proto;
|
|
91
|
+
valid;
|
|
92
|
+
hidden;
|
|
93
|
+
required;
|
|
94
|
+
documented;
|
|
95
|
+
constructor(n) {
|
|
96
|
+
this.proto = n.kind === "field" && p(n, t) ? f(n, t) : c(e), this.required = n.kind === "field" && je(n), this.documented = this.proto.description || k(n), n.kind === "field" ? (this.proto.title = this.proto.title ?? n.jsonName, this.proto.description = this.proto.description ?? Pe(n)) : (this.proto.title = this.proto.title ?? n.localName, this.proto.description = this.proto.description ?? k(n)), this.valid = !!this.proto.type.case, this.hidden = this.proto.hidden ?? !1;
|
|
97
|
+
}
|
|
98
|
+
type() {
|
|
99
|
+
return this.proto.type;
|
|
100
|
+
}
|
|
101
|
+
title() {
|
|
102
|
+
return this.proto.title;
|
|
103
|
+
}
|
|
104
|
+
description() {
|
|
105
|
+
return this.proto.description;
|
|
106
|
+
}
|
|
107
|
+
}, D = /* @__PURE__ */ new WeakMap();
|
|
108
|
+
function je(e) {
|
|
109
|
+
return p(e, Se) && f(e, Se).required || p(e, r) && f(e, r).includes(n.REQUIRED);
|
|
110
|
+
}
|
|
111
|
+
function Me(e) {
|
|
112
|
+
return p(e, r) && f(e, r).includes(n.IDENTIFIER);
|
|
113
|
+
}
|
|
114
|
+
function Ne(e) {
|
|
115
|
+
return p(e, r) && f(e, r).includes(n.OUTPUT_ONLY);
|
|
116
|
+
}
|
|
117
|
+
function O(e) {
|
|
118
|
+
let t = D.get(e);
|
|
119
|
+
return t || (t = new E(e), D.set(e, t)), t;
|
|
120
|
+
}
|
|
121
|
+
function Pe(e) {
|
|
122
|
+
let t = k(e);
|
|
123
|
+
if (t) return t;
|
|
124
|
+
if (e.fieldKind == "map") {
|
|
125
|
+
let n;
|
|
126
|
+
n = e.enum ? e.enum.typeName : e.message ? e.message.typeName : A(e.scalar), t = `map<${A(e.mapKey)}, ${n}>`;
|
|
127
|
+
} else t = e.message ? e.message.typeName : e.enum ? e.enum.typeName : A(e.scalar);
|
|
128
|
+
return e.fieldKind == "list" && (t = `list<${t}>`), t;
|
|
129
|
+
}
|
|
130
|
+
function k(e, t) {
|
|
131
|
+
let n = Oe(e), r = n.leadingDetached.map((e) => e.trim());
|
|
132
|
+
return n.leading && r.push(n.leading.trim()), n.trailing && r.push(n.trailing.trim()), t ? r.join("\n") : r.join(" ");
|
|
133
|
+
}
|
|
134
|
+
function A(e) {
|
|
135
|
+
switch (e) {
|
|
136
|
+
case s.DOUBLE: return "double";
|
|
137
|
+
case s.FLOAT: return "float";
|
|
138
|
+
case s.INT64: return "int64";
|
|
139
|
+
case s.UINT64: return "uint64";
|
|
140
|
+
case s.INT32: return "int32";
|
|
141
|
+
case s.FIXED64: return "fixed64";
|
|
142
|
+
case s.FIXED32: return "fixed32";
|
|
143
|
+
case s.BOOL: return "bool";
|
|
144
|
+
case s.STRING: return "string";
|
|
145
|
+
case s.BYTES: return "bytes";
|
|
146
|
+
case s.UINT32: return "uint32";
|
|
147
|
+
case s.SFIXED32: return "sfixed32";
|
|
148
|
+
case s.SFIXED64: return "sfixed64";
|
|
149
|
+
case s.SINT32: return "sint32";
|
|
150
|
+
case s.SINT64: return "sint64";
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// lib/path.ts
|
|
154
|
+
function j(e, t) {
|
|
155
|
+
return e ? `${e}.${t.name}` : t.name;
|
|
156
|
+
}
|
|
157
|
+
function M(e, t) {
|
|
158
|
+
return `${e}[${t}]`;
|
|
159
|
+
}
|
|
160
|
+
function N(e, t) {
|
|
161
|
+
return `${e}[${String(t)}]`;
|
|
162
|
+
}
|
|
163
|
+
function P(e) {
|
|
164
|
+
let t = "";
|
|
165
|
+
for (let n of e) switch (n.kind) {
|
|
166
|
+
case "field":
|
|
167
|
+
case "oneof":
|
|
168
|
+
t = j(t, n);
|
|
169
|
+
break;
|
|
170
|
+
case "extension": break;
|
|
171
|
+
case "list_sub":
|
|
172
|
+
t = M(t, n.index);
|
|
173
|
+
break;
|
|
174
|
+
case "map_sub": t = N(t, n.key);
|
|
175
|
+
}
|
|
176
|
+
return t;
|
|
177
|
+
}
|
|
178
|
+
// lib/store.ts
|
|
179
|
+
var F = class {
|
|
180
|
+
revision = 0;
|
|
181
|
+
dataRevision = 0;
|
|
182
|
+
listeners = /* @__PURE__ */ new Set();
|
|
183
|
+
violations = [];
|
|
184
|
+
byPath = /* @__PURE__ */ new Map();
|
|
185
|
+
localErrors = /* @__PURE__ */ new Map();
|
|
186
|
+
submitted = !1;
|
|
187
|
+
markSubmitted() {
|
|
188
|
+
this.submitted = !0;
|
|
189
|
+
}
|
|
190
|
+
subscribe = (e) => (this.listeners.add(e), () => {
|
|
191
|
+
this.listeners.delete(e);
|
|
192
|
+
});
|
|
193
|
+
snapshot = () => this.revision;
|
|
194
|
+
dataSnapshot = () => this.dataRevision;
|
|
195
|
+
dataChanged() {
|
|
196
|
+
this.dataRevision++, this.revision++, this.emit();
|
|
197
|
+
}
|
|
198
|
+
setViolations(e) {
|
|
199
|
+
this.violations = e, this.byPath = /* @__PURE__ */ new Map();
|
|
200
|
+
for (let t of e) {
|
|
201
|
+
let e = P(t.field), n = this.byPath.get(e);
|
|
202
|
+
n ? n.push(t) : this.byPath.set(e, [t]);
|
|
203
|
+
}
|
|
204
|
+
this.revision++, this.emit();
|
|
205
|
+
}
|
|
206
|
+
violationsAt(e) {
|
|
207
|
+
return this.byPath.get(e) ?? [];
|
|
208
|
+
}
|
|
209
|
+
setLocalError(e, t) {
|
|
210
|
+
this.localErrors.get(e) !== t && (t === void 0 ? this.localErrors.delete(e) : this.localErrors.set(e, t), this.revision++, this.emit());
|
|
211
|
+
}
|
|
212
|
+
localError(e) {
|
|
213
|
+
return this.localErrors.get(e);
|
|
214
|
+
}
|
|
215
|
+
hasLocalErrors() {
|
|
216
|
+
return this.localErrors.size > 0;
|
|
217
|
+
}
|
|
218
|
+
emit() {
|
|
219
|
+
for (let e of [...this.listeners]) e();
|
|
220
|
+
}
|
|
221
|
+
}, I = class {
|
|
222
|
+
value;
|
|
223
|
+
path;
|
|
224
|
+
store;
|
|
225
|
+
owner;
|
|
226
|
+
onChange;
|
|
227
|
+
constructor(e, t, n = {}) {
|
|
228
|
+
this.value = _(e, c(e, t)), this.owner = n.owner, this.path = n.path ?? "", this.onChange = n.onChange, this.store = n.owner?.store ?? n.store ?? new F();
|
|
229
|
+
}
|
|
230
|
+
fields() {
|
|
231
|
+
return this.value.desc.members.map((e) => e.kind === "oneof" ? new X(this, e) : Y(this, e));
|
|
232
|
+
}
|
|
233
|
+
fieldPath(e) {
|
|
234
|
+
return j(this.path, e);
|
|
235
|
+
}
|
|
236
|
+
get errors() {
|
|
237
|
+
return this.store.violationsAt(this.path);
|
|
238
|
+
}
|
|
239
|
+
errorMessages() {
|
|
240
|
+
return this.errorMessagesAt(this.path);
|
|
241
|
+
}
|
|
242
|
+
errorMessagesAt(e) {
|
|
243
|
+
let t = [], n = this.store.localError(e);
|
|
244
|
+
n && t.push(n);
|
|
245
|
+
for (let n of this.store.violationsAt(e)) t.push(n.message);
|
|
246
|
+
return t;
|
|
247
|
+
}
|
|
248
|
+
validate(e) {
|
|
249
|
+
if (this.owner) return this.owner.validate(e);
|
|
250
|
+
e ??= Te;
|
|
251
|
+
let t = e.validate(this.value.desc, this.value.message);
|
|
252
|
+
return this.store.setViolations(t.kind === "invalid" ? t.violations : []), this.store.setLocalError("", t.kind === "error" ? String(t.error) : void 0), t;
|
|
253
|
+
}
|
|
254
|
+
get() {
|
|
255
|
+
return this.value.message;
|
|
256
|
+
}
|
|
257
|
+
set(e) {
|
|
258
|
+
u(this.value.desc, this.value.message, e) || (this.reset(), ee(this.value.desc, this.value.message, e), this.notify());
|
|
259
|
+
}
|
|
260
|
+
clear() {
|
|
261
|
+
this.reset(), this.notify();
|
|
262
|
+
}
|
|
263
|
+
notify() {
|
|
264
|
+
this.attach(), this.onChange?.(), this.owner ? this.owner.notify() : this.store.dataChanged();
|
|
265
|
+
}
|
|
266
|
+
attach() {}
|
|
267
|
+
reset() {
|
|
268
|
+
for (let e of this.value.desc.fields) this.value.clear(e);
|
|
269
|
+
}
|
|
270
|
+
}, L = class extends I {
|
|
271
|
+
parent;
|
|
272
|
+
desc;
|
|
273
|
+
elem;
|
|
274
|
+
constructor(e, t) {
|
|
275
|
+
super(t.message, e.value.get(t).message, {
|
|
276
|
+
owner: e,
|
|
277
|
+
path: j(e.path, t)
|
|
278
|
+
}), this.parent = e, this.desc = t, this.elem = O(t);
|
|
279
|
+
}
|
|
280
|
+
isSet() {
|
|
281
|
+
return this.parent.value.isSet(this.desc);
|
|
282
|
+
}
|
|
283
|
+
ensure() {
|
|
284
|
+
this.isSet() || this.notify();
|
|
285
|
+
}
|
|
286
|
+
clear() {
|
|
287
|
+
this.reset(), this.parent.value.clear(this.desc), this.parent.notify();
|
|
288
|
+
}
|
|
289
|
+
toString() {
|
|
290
|
+
return ne(this.value.desc, this.get());
|
|
291
|
+
}
|
|
292
|
+
parse(e) {
|
|
293
|
+
this.set(d(this.value.desc, JSON.parse(e)));
|
|
294
|
+
}
|
|
295
|
+
attach() {
|
|
296
|
+
this.parent.value.isSet(this.desc) || this.parent.value.set(this.desc, this.value);
|
|
297
|
+
}
|
|
298
|
+
}, R = class {
|
|
299
|
+
parent;
|
|
300
|
+
desc;
|
|
301
|
+
path;
|
|
302
|
+
elem;
|
|
303
|
+
constructor(e, t) {
|
|
304
|
+
this.parent = e, this.desc = t, this.path = j(e.path, t), this.elem = O(t);
|
|
305
|
+
}
|
|
306
|
+
get errors() {
|
|
307
|
+
return this.parent.store.violationsAt(this.path);
|
|
308
|
+
}
|
|
309
|
+
errorMessages() {
|
|
310
|
+
return this.parent.errorMessagesAt(this.path);
|
|
311
|
+
}
|
|
312
|
+
changed() {
|
|
313
|
+
this.parent.notify();
|
|
314
|
+
}
|
|
315
|
+
}, z = class extends R {
|
|
316
|
+
get() {
|
|
317
|
+
return this.parent.value.get(this.desc);
|
|
318
|
+
}
|
|
319
|
+
set(e) {
|
|
320
|
+
this.parent.value.set(this.desc, e), this.changed();
|
|
321
|
+
}
|
|
322
|
+
parse(e) {
|
|
323
|
+
let t = e.trim(), n = this.desc.enum.values.find((e) => e.name === t);
|
|
324
|
+
if (n) this.set(n.number);
|
|
325
|
+
else if (/^-?\d+$/.test(t)) this.set(Number(t));
|
|
326
|
+
else throw Error(`unknown value "${e}" for enum ${this.desc.enum.typeName}`);
|
|
327
|
+
}
|
|
328
|
+
toString() {
|
|
329
|
+
let e = this.get();
|
|
330
|
+
return this.desc.enum.value[e]?.name ?? String(e);
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
function B(e, t) {
|
|
334
|
+
for (let n of e.values) if (n.name === t) return n.proto.number;
|
|
335
|
+
}
|
|
336
|
+
function V(e, t, n) {
|
|
337
|
+
let r = e.value[t]?.name ?? String(t);
|
|
338
|
+
if (n) {
|
|
339
|
+
let t = Fe(e);
|
|
340
|
+
return r.startsWith(t) ? r.slice(t.length) : r;
|
|
341
|
+
}
|
|
342
|
+
return r;
|
|
343
|
+
}
|
|
344
|
+
function Fe(e) {
|
|
345
|
+
return e.name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase() + "_";
|
|
346
|
+
}
|
|
347
|
+
function Ie(e, t) {
|
|
348
|
+
let n = V(e, t, !0).toLowerCase().replaceAll("_", " ");
|
|
349
|
+
return n.charAt(0).toUpperCase() + n.slice(1);
|
|
350
|
+
}
|
|
351
|
+
function Le(e) {
|
|
352
|
+
return e.values.slice(1).map((e) => e.proto.number);
|
|
353
|
+
}
|
|
354
|
+
// lib/scalar.ts
|
|
355
|
+
var H = class extends R {
|
|
356
|
+
get() {
|
|
357
|
+
return this.parent.value.get(this.desc);
|
|
358
|
+
}
|
|
359
|
+
set(e) {
|
|
360
|
+
this.parent.value.set(this.desc, e), this.changed();
|
|
361
|
+
}
|
|
362
|
+
parse(e) {
|
|
363
|
+
this.set(K(this.desc.scalar, e));
|
|
364
|
+
}
|
|
365
|
+
toString() {
|
|
366
|
+
return q(this.desc.scalar, this.get());
|
|
367
|
+
}
|
|
368
|
+
}, Re = 34028234663852886e22, U = {
|
|
369
|
+
[s.INT32]: [-(2n ** 31n), 2n ** 31n - 1n],
|
|
370
|
+
[s.SINT32]: [-(2n ** 31n), 2n ** 31n - 1n],
|
|
371
|
+
[s.SFIXED32]: [-(2n ** 31n), 2n ** 31n - 1n],
|
|
372
|
+
[s.UINT32]: [0n, 2n ** 32n - 1n],
|
|
373
|
+
[s.FIXED32]: [0n, 2n ** 32n - 1n],
|
|
374
|
+
[s.INT64]: [-(2n ** 63n), 2n ** 63n - 1n],
|
|
375
|
+
[s.SINT64]: [-(2n ** 63n), 2n ** 63n - 1n],
|
|
376
|
+
[s.SFIXED64]: [-(2n ** 63n), 2n ** 63n - 1n],
|
|
377
|
+
[s.UINT64]: [0n, 2n ** 64n - 1n],
|
|
378
|
+
[s.FIXED64]: [0n, 2n ** 64n - 1n]
|
|
379
|
+
}, ze = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/, Be = /^[+-]?\d+$/;
|
|
380
|
+
function W(e) {
|
|
381
|
+
return e in U;
|
|
382
|
+
}
|
|
383
|
+
function Ve(e) {
|
|
384
|
+
return W(e) || e === s.FLOAT || e === s.DOUBLE;
|
|
385
|
+
}
|
|
386
|
+
function G(e, t) {
|
|
387
|
+
let n = t.trim();
|
|
388
|
+
switch (e) {
|
|
389
|
+
case s.STRING: return {
|
|
390
|
+
ok: !0,
|
|
391
|
+
value: t
|
|
392
|
+
};
|
|
393
|
+
case s.BOOL: {
|
|
394
|
+
let e = n.toLowerCase();
|
|
395
|
+
return e === "" || e === "false" || e === "0" ? {
|
|
396
|
+
ok: !0,
|
|
397
|
+
value: !1
|
|
398
|
+
} : e === "true" || e === "1" ? {
|
|
399
|
+
ok: !0,
|
|
400
|
+
value: !0
|
|
401
|
+
} : {
|
|
402
|
+
ok: !1,
|
|
403
|
+
error: "Enter true or false"
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
case s.BYTES:
|
|
407
|
+
if (n === "") return {
|
|
408
|
+
ok: !0,
|
|
409
|
+
value: /* @__PURE__ */ new Uint8Array()
|
|
410
|
+
};
|
|
411
|
+
try {
|
|
412
|
+
return {
|
|
413
|
+
ok: !0,
|
|
414
|
+
value: Ce(n)
|
|
415
|
+
};
|
|
416
|
+
} catch {
|
|
417
|
+
return {
|
|
418
|
+
ok: !1,
|
|
419
|
+
error: "Enter valid base64"
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
case s.DOUBLE:
|
|
423
|
+
case s.FLOAT: {
|
|
424
|
+
if (n === "") return {
|
|
425
|
+
ok: !0,
|
|
426
|
+
value: 0
|
|
427
|
+
};
|
|
428
|
+
let t = He(n);
|
|
429
|
+
if (t !== void 0) return {
|
|
430
|
+
ok: !0,
|
|
431
|
+
value: t
|
|
432
|
+
};
|
|
433
|
+
if (!ze.test(n)) return {
|
|
434
|
+
ok: !1,
|
|
435
|
+
error: "Enter a number"
|
|
436
|
+
};
|
|
437
|
+
let r = Number(n);
|
|
438
|
+
return !Number.isFinite(r) || e === s.FLOAT && Math.abs(r) > Re ? {
|
|
439
|
+
ok: !1,
|
|
440
|
+
error: "Number is out of range"
|
|
441
|
+
} : {
|
|
442
|
+
ok: !0,
|
|
443
|
+
value: r
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
default: {
|
|
447
|
+
let t = U[e];
|
|
448
|
+
if (!t) return {
|
|
449
|
+
ok: !1,
|
|
450
|
+
error: "Unsupported type"
|
|
451
|
+
};
|
|
452
|
+
if (n === "") return {
|
|
453
|
+
ok: !0,
|
|
454
|
+
value: J(e) ? 0n : 0
|
|
455
|
+
};
|
|
456
|
+
if (!Be.test(n)) return {
|
|
457
|
+
ok: !1,
|
|
458
|
+
error: "Enter a whole number"
|
|
459
|
+
};
|
|
460
|
+
let r = BigInt(n);
|
|
461
|
+
return r < t[0] || r > t[1] ? {
|
|
462
|
+
ok: !1,
|
|
463
|
+
error: `Value must be between ${t[0]} and ${t[1]}`
|
|
464
|
+
} : {
|
|
465
|
+
ok: !0,
|
|
466
|
+
value: J(e) ? r : Number(r)
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
function K(e, t) {
|
|
472
|
+
let n = G(e, t);
|
|
473
|
+
if (!n.ok) throw Error(n.error);
|
|
474
|
+
return n.value;
|
|
475
|
+
}
|
|
476
|
+
function q(e, t) {
|
|
477
|
+
return e === s.BYTES ? we(t) : String(t);
|
|
478
|
+
}
|
|
479
|
+
function He(e) {
|
|
480
|
+
switch (e.toLowerCase()) {
|
|
481
|
+
case "nan": return NaN;
|
|
482
|
+
case "inf":
|
|
483
|
+
case "+inf":
|
|
484
|
+
case "infinity":
|
|
485
|
+
case "+infinity": return Infinity;
|
|
486
|
+
case "-inf":
|
|
487
|
+
case "-infinity": return -Infinity;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function J(e) {
|
|
491
|
+
switch (e) {
|
|
492
|
+
case s.INT64:
|
|
493
|
+
case s.UINT64:
|
|
494
|
+
case s.SINT64:
|
|
495
|
+
case s.FIXED64:
|
|
496
|
+
case s.SFIXED64: return !0;
|
|
497
|
+
}
|
|
498
|
+
return !1;
|
|
499
|
+
}
|
|
500
|
+
// lib/list.ts
|
|
501
|
+
var Ue = class extends R {
|
|
502
|
+
get() {
|
|
503
|
+
return this.parent.value.get(this.desc);
|
|
504
|
+
}
|
|
505
|
+
set(e) {
|
|
506
|
+
this.parent.value.set(this.desc, e), this.changed();
|
|
507
|
+
}
|
|
508
|
+
get size() {
|
|
509
|
+
return this.get().size;
|
|
510
|
+
}
|
|
511
|
+
items() {
|
|
512
|
+
return Array.from(this.get());
|
|
513
|
+
}
|
|
514
|
+
messages() {
|
|
515
|
+
return this.items().map((e, t) => new I(e.desc, e.message, {
|
|
516
|
+
owner: this.parent,
|
|
517
|
+
path: M(this.path, t)
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
add(e) {
|
|
521
|
+
this.get().add(e ?? this.zeroItem()), this.changed();
|
|
522
|
+
}
|
|
523
|
+
removeAt(e) {
|
|
524
|
+
this.replace(this.items().filter((t, n) => n !== e));
|
|
525
|
+
}
|
|
526
|
+
move(e, t) {
|
|
527
|
+
let n = this.items();
|
|
528
|
+
if (e === t || e < 0 || t < 0 || e >= n.length || t >= n.length) return;
|
|
529
|
+
let [r] = n.splice(e, 1);
|
|
530
|
+
n.splice(t, 0, r), this.replace(n);
|
|
531
|
+
}
|
|
532
|
+
setAt(e, t) {
|
|
533
|
+
this.get().set(e, t), this.changed();
|
|
534
|
+
}
|
|
535
|
+
clear() {
|
|
536
|
+
this.get().clear(), this.changed();
|
|
537
|
+
}
|
|
538
|
+
toString() {
|
|
539
|
+
return JSON.stringify(this.items().map((e) => this.itemToJson(e)));
|
|
540
|
+
}
|
|
541
|
+
parse(e) {
|
|
542
|
+
let t = JSON.parse(e);
|
|
543
|
+
if (!Array.isArray(t)) throw Error(`expected array for list field: ${this.desc.name}`);
|
|
544
|
+
let n = t.map((e) => this.itemFromJson(e));
|
|
545
|
+
this.replace(n);
|
|
546
|
+
}
|
|
547
|
+
replace(e) {
|
|
548
|
+
let t = this.get();
|
|
549
|
+
t.clear();
|
|
550
|
+
for (let n of e) t.add(n);
|
|
551
|
+
this.changed();
|
|
552
|
+
}
|
|
553
|
+
zeroItem() {
|
|
554
|
+
switch (this.desc.listKind) {
|
|
555
|
+
case "message": return _(this.desc.message, c(this.desc.message));
|
|
556
|
+
case "enum": return this.desc.enum.values[0]?.number ?? 0;
|
|
557
|
+
case "scalar": return K(this.desc.scalar, "");
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
itemToJson(e) {
|
|
561
|
+
switch (this.desc.listKind) {
|
|
562
|
+
case "message": return te(this.desc.message, e.message);
|
|
563
|
+
case "enum": return this.desc.enum.value[e]?.name ?? e;
|
|
564
|
+
case "scalar": return q(this.desc.scalar, e);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
itemFromJson(e) {
|
|
568
|
+
switch (this.desc.listKind) {
|
|
569
|
+
case "message": return _(this.desc.message, d(this.desc.message, e));
|
|
570
|
+
case "enum": return typeof e == "number" ? e : B(this.desc.enum, String(e)) ?? 0;
|
|
571
|
+
case "scalar": return K(this.desc.scalar, String(e));
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}, We = class extends R {
|
|
575
|
+
get() {
|
|
576
|
+
return this.parent.value.get(this.desc);
|
|
577
|
+
}
|
|
578
|
+
set(e) {
|
|
579
|
+
this.parent.value.set(this.desc, e), this.changed();
|
|
580
|
+
}
|
|
581
|
+
get size() {
|
|
582
|
+
return this.get().size;
|
|
583
|
+
}
|
|
584
|
+
entries() {
|
|
585
|
+
return Array.from(this.get().entries());
|
|
586
|
+
}
|
|
587
|
+
formatKey(e) {
|
|
588
|
+
return q(this.desc.mapKey, e);
|
|
589
|
+
}
|
|
590
|
+
parseKey(e) {
|
|
591
|
+
return K(this.desc.mapKey, e);
|
|
592
|
+
}
|
|
593
|
+
has(e) {
|
|
594
|
+
return this.get().has(e);
|
|
595
|
+
}
|
|
596
|
+
messages() {
|
|
597
|
+
return this.entries().map(([e, t]) => [e, new I(t.desc, t.message, {
|
|
598
|
+
owner: this.parent,
|
|
599
|
+
path: N(this.path, e)
|
|
600
|
+
})]);
|
|
601
|
+
}
|
|
602
|
+
add(e, t) {
|
|
603
|
+
return !this.has(e) && (this.get().set(e, t ?? this.zeroValue()), this.changed(), !0);
|
|
604
|
+
}
|
|
605
|
+
setValue(e, t) {
|
|
606
|
+
this.get().set(e, t), this.changed();
|
|
607
|
+
}
|
|
608
|
+
delete(e) {
|
|
609
|
+
this.get().delete(e), this.changed();
|
|
610
|
+
}
|
|
611
|
+
rename(e, t) {
|
|
612
|
+
return e === t || !this.has(t) && (this.replace(this.entries().map(([n, r]) => [n === e ? t : n, r])), !0);
|
|
613
|
+
}
|
|
614
|
+
clear() {
|
|
615
|
+
this.get().clear(), this.changed();
|
|
616
|
+
}
|
|
617
|
+
toString() {
|
|
618
|
+
let e = {};
|
|
619
|
+
for (let [t, n] of this.entries()) e[this.formatKey(t)] = this.valueToJson(n);
|
|
620
|
+
return JSON.stringify(e);
|
|
621
|
+
}
|
|
622
|
+
parse(e) {
|
|
623
|
+
let t = JSON.parse(e);
|
|
624
|
+
if (typeof t != "object" || !t || Array.isArray(t)) throw Error(`expected object for map field: ${this.desc.name}`);
|
|
625
|
+
this.replace(Object.entries(t).map(([e, t]) => [this.parseKey(e), this.valueFromJson(t)]));
|
|
626
|
+
}
|
|
627
|
+
replace(e) {
|
|
628
|
+
let t = this.get();
|
|
629
|
+
t.clear();
|
|
630
|
+
for (let [n, r] of e) t.set(n, r);
|
|
631
|
+
this.changed();
|
|
632
|
+
}
|
|
633
|
+
zeroValue() {
|
|
634
|
+
switch (this.desc.mapKind) {
|
|
635
|
+
case "message": return _(this.desc.message, c(this.desc.message));
|
|
636
|
+
case "enum": return this.desc.enum.values[0]?.number ?? 0;
|
|
637
|
+
case "scalar": return K(this.desc.scalar, "");
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
valueToJson(e) {
|
|
641
|
+
switch (this.desc.mapKind) {
|
|
642
|
+
case "message": return te(this.desc.message, e.message);
|
|
643
|
+
case "enum": return this.desc.enum.value[e]?.name ?? e;
|
|
644
|
+
case "scalar": return q(this.desc.scalar, e);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
valueFromJson(e) {
|
|
648
|
+
switch (this.desc.mapKind) {
|
|
649
|
+
case "message": return _(this.desc.message, d(this.desc.message, e));
|
|
650
|
+
case "enum": return typeof e == "number" ? e : B(this.desc.enum, String(e)) ?? 0;
|
|
651
|
+
case "scalar": return K(this.desc.scalar, String(e));
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
// lib/field.ts
|
|
656
|
+
function Y(e, t) {
|
|
657
|
+
switch (t.fieldKind) {
|
|
658
|
+
case "list": return new Ue(e, t);
|
|
659
|
+
case "map": return new We(e, t);
|
|
660
|
+
case "message": return new L(e, t);
|
|
661
|
+
case "scalar": return new H(e, t);
|
|
662
|
+
case "enum": return new z(e, t);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
// lib/oneof.ts
|
|
666
|
+
var X = class {
|
|
667
|
+
parent;
|
|
668
|
+
oneOf;
|
|
669
|
+
elem;
|
|
670
|
+
path;
|
|
671
|
+
constructor(e, t) {
|
|
672
|
+
this.parent = e, this.oneOf = t, this.elem = O(t), this.path = j(e.path, t);
|
|
673
|
+
}
|
|
674
|
+
get desc() {
|
|
675
|
+
return this.parent.value.oneofCase(this.oneOf) ?? this.oneOf.fields[0];
|
|
676
|
+
}
|
|
677
|
+
get errors() {
|
|
678
|
+
return [...this.parent.store.violationsAt(this.path), ...this.active()?.errors ?? []];
|
|
679
|
+
}
|
|
680
|
+
errorMessages() {
|
|
681
|
+
return [...this.parent.errorMessagesAt(this.path), ...this.active()?.errorMessages() ?? []];
|
|
682
|
+
}
|
|
683
|
+
fields() {
|
|
684
|
+
return this.oneOf.fields.map((e) => Y(this.parent, e));
|
|
685
|
+
}
|
|
686
|
+
active() {
|
|
687
|
+
let e = this.parent.value.oneofCase(this.oneOf);
|
|
688
|
+
return e ? Y(this.parent, e) : void 0;
|
|
689
|
+
}
|
|
690
|
+
isSet() {
|
|
691
|
+
return this.parent.value.oneofCase(this.oneOf) !== void 0;
|
|
692
|
+
}
|
|
693
|
+
select(e) {
|
|
694
|
+
let t = this.parent.value.oneofCase(this.oneOf);
|
|
695
|
+
if (t?.name !== e) {
|
|
696
|
+
if (t && this.parent.value.clear(t), e !== void 0) {
|
|
697
|
+
let t = this.oneOf.fields.find((t) => t.name === e);
|
|
698
|
+
if (!t) throw Error(`field "${e}" is not part of oneof "${this.oneOf.name}"`);
|
|
699
|
+
this.parent.value.set(t, this.parent.value.get(t));
|
|
700
|
+
}
|
|
701
|
+
this.parent.notify();
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
clear() {
|
|
705
|
+
this.select(void 0);
|
|
706
|
+
}
|
|
707
|
+
toString() {
|
|
708
|
+
return this.active()?.toString() ?? "";
|
|
709
|
+
}
|
|
710
|
+
parse(e) {
|
|
711
|
+
this.active()?.parse(e);
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
// lib/kit/bare.tsx
|
|
715
|
+
function Ge({ onSubmit: e, children: t }) {
|
|
716
|
+
return /* @__PURE__ */ y("form", {
|
|
717
|
+
"data-pf": "form",
|
|
718
|
+
noValidate: !0,
|
|
719
|
+
onSubmit: e,
|
|
720
|
+
children: t
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
function Ke({ children: e }) {
|
|
724
|
+
return /* @__PURE__ */ y("div", {
|
|
725
|
+
"data-pf": "stack",
|
|
726
|
+
children: e
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
function qe({ id: e, children: t, actions: n, errors: r = [] }) {
|
|
730
|
+
return /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ b("div", {
|
|
731
|
+
"data-pf": "row",
|
|
732
|
+
children: [/* @__PURE__ */ y("div", {
|
|
733
|
+
"data-pf": "row-content",
|
|
734
|
+
children: t
|
|
735
|
+
}), n && /* @__PURE__ */ y("div", {
|
|
736
|
+
"data-pf": "row-actions",
|
|
737
|
+
children: n
|
|
738
|
+
})]
|
|
739
|
+
}), /* @__PURE__ */ y(Z, {
|
|
740
|
+
id: `${e}-errors`,
|
|
741
|
+
errors: r
|
|
742
|
+
})] });
|
|
743
|
+
}
|
|
744
|
+
function Je({ id: e, label: t, description: n, errors: r, required: i, children: a }) {
|
|
745
|
+
return /* @__PURE__ */ b("div", {
|
|
746
|
+
"data-pf": "field",
|
|
747
|
+
"data-invalid": r.length > 0 || void 0,
|
|
748
|
+
children: [
|
|
749
|
+
/* @__PURE__ */ b("label", {
|
|
750
|
+
"data-pf": "label",
|
|
751
|
+
id: `${e}-label`,
|
|
752
|
+
htmlFor: e,
|
|
753
|
+
children: [t, i && /* @__PURE__ */ y("span", {
|
|
754
|
+
"aria-hidden": "true",
|
|
755
|
+
children: " *"
|
|
756
|
+
})]
|
|
757
|
+
}),
|
|
758
|
+
n && /* @__PURE__ */ y("p", {
|
|
759
|
+
"data-pf": "description",
|
|
760
|
+
id: `${e}-description`,
|
|
761
|
+
children: n
|
|
762
|
+
}),
|
|
763
|
+
a,
|
|
764
|
+
/* @__PURE__ */ y(Z, {
|
|
765
|
+
id: `${e}-errors`,
|
|
766
|
+
errors: r
|
|
767
|
+
})
|
|
768
|
+
]
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
function Ye({ id: e, title: t, description: n, errors: r, depth: i, actions: a, collapsible: o, children: s }) {
|
|
772
|
+
let c = /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("span", {
|
|
773
|
+
"data-pf": "section-title",
|
|
774
|
+
id: `${e}-title`,
|
|
775
|
+
children: t
|
|
776
|
+
}), a && /* @__PURE__ */ y("span", {
|
|
777
|
+
"data-pf": "section-actions",
|
|
778
|
+
children: a
|
|
779
|
+
})] }), l = /* @__PURE__ */ b(v, { children: [
|
|
780
|
+
n && /* @__PURE__ */ y("p", {
|
|
781
|
+
"data-pf": "description",
|
|
782
|
+
id: `${e}-description`,
|
|
783
|
+
children: n
|
|
784
|
+
}),
|
|
785
|
+
/* @__PURE__ */ y(Z, {
|
|
786
|
+
id: `${e}-errors`,
|
|
787
|
+
errors: r
|
|
788
|
+
}),
|
|
789
|
+
s
|
|
790
|
+
] }), u = {
|
|
791
|
+
"aria-labelledby": `${e}-title`,
|
|
792
|
+
"aria-describedby": n ? `${e}-description` : void 0
|
|
793
|
+
};
|
|
794
|
+
return o ? /* @__PURE__ */ b("details", {
|
|
795
|
+
"data-pf": "section",
|
|
796
|
+
"data-depth": i,
|
|
797
|
+
open: !0,
|
|
798
|
+
...u,
|
|
799
|
+
children: [/* @__PURE__ */ y("summary", {
|
|
800
|
+
"data-pf": "section-summary",
|
|
801
|
+
children: c
|
|
802
|
+
}), l]
|
|
803
|
+
}) : /* @__PURE__ */ b("fieldset", {
|
|
804
|
+
"data-pf": "section",
|
|
805
|
+
"data-depth": i,
|
|
806
|
+
...u,
|
|
807
|
+
children: [/* @__PURE__ */ y("legend", {
|
|
808
|
+
"data-pf": "section-legend",
|
|
809
|
+
children: c
|
|
810
|
+
}), l]
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
function Z({ id: e, errors: t }) {
|
|
814
|
+
return t.length === 0 ? null : /* @__PURE__ */ y("ul", {
|
|
815
|
+
"data-pf": "errors",
|
|
816
|
+
id: e,
|
|
817
|
+
"aria-live": "polite",
|
|
818
|
+
children: t.map((e) => /* @__PURE__ */ y("li", { children: e }, e))
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
function Xe({ value: e, onChange: t, onBlur: n, onEnter: r, type: i = "text", inputMode: a, placeholder: o, mono: s, invalid: c, describedBy: l, ...u }) {
|
|
822
|
+
return /* @__PURE__ */ y("input", {
|
|
823
|
+
"data-pf": "input",
|
|
824
|
+
"data-mono": s || void 0,
|
|
825
|
+
type: i,
|
|
826
|
+
inputMode: a,
|
|
827
|
+
id: u.id,
|
|
828
|
+
name: u.name,
|
|
829
|
+
value: e,
|
|
830
|
+
placeholder: o,
|
|
831
|
+
disabled: u.disabled,
|
|
832
|
+
readOnly: u.readOnly,
|
|
833
|
+
required: u.required,
|
|
834
|
+
"aria-label": u["aria-label"],
|
|
835
|
+
"aria-invalid": c || void 0,
|
|
836
|
+
"aria-describedby": l,
|
|
837
|
+
onChange: (e) => t(e.target.value),
|
|
838
|
+
onBlur: n,
|
|
839
|
+
onKeyDown: r && ((e) => {
|
|
840
|
+
e.key === "Enter" && (e.preventDefault(), r());
|
|
841
|
+
})
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
function Ze({ value: e, onChange: t, onBlur: n, rows: r = 4, placeholder: i, mono: a, invalid: o, describedBy: s, ...c }) {
|
|
845
|
+
return /* @__PURE__ */ y("textarea", {
|
|
846
|
+
"data-pf": "textarea",
|
|
847
|
+
"data-mono": a || void 0,
|
|
848
|
+
id: c.id,
|
|
849
|
+
name: c.name,
|
|
850
|
+
rows: r,
|
|
851
|
+
value: e,
|
|
852
|
+
placeholder: i,
|
|
853
|
+
disabled: c.disabled,
|
|
854
|
+
readOnly: c.readOnly,
|
|
855
|
+
required: c.required,
|
|
856
|
+
"aria-label": c["aria-label"],
|
|
857
|
+
"aria-invalid": o || void 0,
|
|
858
|
+
"aria-describedby": s,
|
|
859
|
+
onChange: (e) => t(e.target.value),
|
|
860
|
+
onBlur: n
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
function Qe({ checked: e, onChange: t, label: n, variant: r = "checkbox", invalid: i, describedBy: a, ...o }) {
|
|
864
|
+
let s = /* @__PURE__ */ y("input", {
|
|
865
|
+
"data-pf": "checkbox",
|
|
866
|
+
type: "checkbox",
|
|
867
|
+
role: r === "switch" ? "switch" : void 0,
|
|
868
|
+
id: o.id,
|
|
869
|
+
name: o.name,
|
|
870
|
+
checked: e,
|
|
871
|
+
disabled: o.disabled || o.readOnly,
|
|
872
|
+
"aria-label": o["aria-label"],
|
|
873
|
+
"aria-invalid": i || void 0,
|
|
874
|
+
"aria-describedby": a,
|
|
875
|
+
onChange: (e) => t(e.target.checked)
|
|
876
|
+
});
|
|
877
|
+
return n === void 0 ? s : /* @__PURE__ */ b("label", {
|
|
878
|
+
"data-pf": "checkbox-label",
|
|
879
|
+
children: [s, /* @__PURE__ */ y("span", { children: n })]
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
function $e({ value: e, onChange: t, options: n, placeholder: r, invalid: i, describedBy: a, ...o }) {
|
|
883
|
+
return /* @__PURE__ */ b("select", {
|
|
884
|
+
"data-pf": "select",
|
|
885
|
+
id: o.id,
|
|
886
|
+
name: o.name,
|
|
887
|
+
value: e,
|
|
888
|
+
disabled: o.disabled || o.readOnly,
|
|
889
|
+
required: o.required,
|
|
890
|
+
"aria-label": o["aria-label"],
|
|
891
|
+
"aria-invalid": i || void 0,
|
|
892
|
+
"aria-describedby": a,
|
|
893
|
+
onChange: (e) => t(e.target.value),
|
|
894
|
+
children: [r !== void 0 && /* @__PURE__ */ y("option", {
|
|
895
|
+
value: "",
|
|
896
|
+
disabled: !0,
|
|
897
|
+
children: r
|
|
898
|
+
}), n.map((e) => /* @__PURE__ */ y("option", {
|
|
899
|
+
value: e.value,
|
|
900
|
+
disabled: e.disabled,
|
|
901
|
+
children: e.label
|
|
902
|
+
}, e.value))]
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
function et({ value: e, onChange: t, options: n, invalid: r, describedBy: i, ...a }) {
|
|
906
|
+
let o = a.name ?? a.id;
|
|
907
|
+
return /* @__PURE__ */ y("div", {
|
|
908
|
+
"data-pf": "radiogroup",
|
|
909
|
+
role: "radiogroup",
|
|
910
|
+
id: a.id,
|
|
911
|
+
"aria-label": a["aria-label"],
|
|
912
|
+
"aria-labelledby": a.id && !a["aria-label"] ? `${a.id}-label` : void 0,
|
|
913
|
+
"aria-invalid": r || void 0,
|
|
914
|
+
"aria-describedby": i,
|
|
915
|
+
children: n.map((n) => /* @__PURE__ */ b("label", {
|
|
916
|
+
"data-pf": "radio-label",
|
|
917
|
+
children: [/* @__PURE__ */ y("input", {
|
|
918
|
+
"data-pf": "radio",
|
|
919
|
+
type: "radio",
|
|
920
|
+
name: o,
|
|
921
|
+
value: n.value,
|
|
922
|
+
checked: e === n.value,
|
|
923
|
+
disabled: a.disabled || a.readOnly || n.disabled,
|
|
924
|
+
onChange: () => t(n.value)
|
|
925
|
+
}), /* @__PURE__ */ y("span", { children: n.label })]
|
|
926
|
+
}, n.value))
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
function tt({ accept: e, fileName: t, onFile: n, invalid: r, describedBy: i, ...a }) {
|
|
930
|
+
return /* @__PURE__ */ b("div", {
|
|
931
|
+
"data-pf": "file",
|
|
932
|
+
children: [/* @__PURE__ */ y("input", {
|
|
933
|
+
"data-pf": "file-input",
|
|
934
|
+
type: "file",
|
|
935
|
+
id: a.id,
|
|
936
|
+
name: a.name,
|
|
937
|
+
accept: e?.length ? e.join(",") : void 0,
|
|
938
|
+
disabled: a.disabled || a.readOnly,
|
|
939
|
+
"aria-label": a["aria-label"],
|
|
940
|
+
"aria-invalid": r || void 0,
|
|
941
|
+
"aria-describedby": i,
|
|
942
|
+
onChange: (e) => n(e.target.files?.[0])
|
|
943
|
+
}), t && /* @__PURE__ */ y("span", {
|
|
944
|
+
"data-pf": "file-name",
|
|
945
|
+
children: t
|
|
946
|
+
})]
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
function nt({ variant: e = "secondary", size: t = "md", type: n = "button", disabled: r, onClick: i, children: a, ...o }) {
|
|
950
|
+
return /* @__PURE__ */ y("button", {
|
|
951
|
+
"data-pf": "button",
|
|
952
|
+
"data-variant": e,
|
|
953
|
+
"data-size": t,
|
|
954
|
+
type: n,
|
|
955
|
+
disabled: r,
|
|
956
|
+
"aria-label": o["aria-label"],
|
|
957
|
+
onClick: i,
|
|
958
|
+
children: a
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
var Q = {
|
|
962
|
+
Form: Ge,
|
|
963
|
+
Stack: Ke,
|
|
964
|
+
Row: qe,
|
|
965
|
+
Field: Je,
|
|
966
|
+
Section: Ye,
|
|
967
|
+
TextInput: Xe,
|
|
968
|
+
TextArea: Ze,
|
|
969
|
+
Checkbox: Qe,
|
|
970
|
+
Select: $e,
|
|
971
|
+
RadioGroup: et,
|
|
972
|
+
FileInput: tt,
|
|
973
|
+
Button: nt
|
|
974
|
+
}, rt = {
|
|
975
|
+
edit: "Edit",
|
|
976
|
+
clear: "Clear",
|
|
977
|
+
addItem: "Add item",
|
|
978
|
+
addEntry: "Add",
|
|
979
|
+
key: "Key",
|
|
980
|
+
value: "Value",
|
|
981
|
+
noItems: "No items",
|
|
982
|
+
notSet: "Not set",
|
|
983
|
+
select: "Select…",
|
|
984
|
+
selectType: "Select type…",
|
|
985
|
+
selectCase: "None",
|
|
986
|
+
now: "Now",
|
|
987
|
+
duplicateKey: "Key already exists",
|
|
988
|
+
item: (e) => `Item ${e}`,
|
|
989
|
+
entry: (e) => e,
|
|
990
|
+
entryKey: (e) => `Key ${e}`,
|
|
991
|
+
entryValue: (e) => `Value for ${e}`,
|
|
992
|
+
removeItem: (e) => `Remove item ${e}`,
|
|
993
|
+
moveItemUp: (e) => `Move item ${e} up`,
|
|
994
|
+
moveItemDown: (e) => `Move item ${e} down`,
|
|
995
|
+
removeEntry: (e) => `Remove entry ${e}`
|
|
996
|
+
}, $ = a({
|
|
997
|
+
kit: Q,
|
|
998
|
+
renderers: {},
|
|
999
|
+
messages: rt
|
|
1000
|
+
});
|
|
1001
|
+
function it() {
|
|
1002
|
+
return o($);
|
|
1003
|
+
}
|
|
1004
|
+
function at() {
|
|
1005
|
+
return o($).kit;
|
|
1006
|
+
}
|
|
1007
|
+
function ot() {
|
|
1008
|
+
return o($).messages;
|
|
1009
|
+
}
|
|
1010
|
+
function st(e, t) {
|
|
1011
|
+
let n = e.resolve?.(t);
|
|
1012
|
+
if (n) return n;
|
|
1013
|
+
let r = [];
|
|
1014
|
+
if (t instanceof X) r.push(`${t.parent.value.desc.typeName}.${t.oneOf.name}`);
|
|
1015
|
+
else {
|
|
1016
|
+
let { desc: e } = t;
|
|
1017
|
+
r.push(`${e.parent.typeName}.${e.name}`), e.message ? r.push(e.message.typeName) : e.enum && r.push(e.enum.typeName);
|
|
1018
|
+
}
|
|
1019
|
+
for (let t of r) if (e.renderers[t]) return e.renderers[t];
|
|
1020
|
+
}
|
|
1021
|
+
function ct(...e) {
|
|
1022
|
+
return Object.assign({}, Q, ...e);
|
|
1023
|
+
}
|
|
1024
|
+
export { P as A, Ee as B, B as C, j as D, F as E, A as F, x as H, Me as I, Ne as L, O as M, Pe as N, M as O, k as P, C as R, V as S, L as T, Te as U, S as V, De as W, K as _, at as a, Le as b, Q as c, We as d, Ue as f, Ve as g, W as h, st as i, E as j, N as k, X as l, q as m, rt as n, ot as o, H as p, ct as r, it as s, $ as t, Y as u, G as v, I as w, Ie as x, z as y, w as z };
|