@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,61 @@
|
|
|
1
|
+
import { DescField, DescMessage, Message as ProtoMessage, MessageInitShape, MessageValidType } from '@bufbuild/protobuf';
|
|
2
|
+
import { ReflectMessage } from '@bufbuild/protobuf/reflect';
|
|
3
|
+
import { ValidationResult, Validator, Violation } from '@bufbuild/protovalidate';
|
|
4
|
+
import { Element } from './element';
|
|
5
|
+
import { Field } from './field';
|
|
6
|
+
import { FormStore } from './store';
|
|
7
|
+
export type MessageOptions = {
|
|
8
|
+
/** The message that contains this one; changes and validation bubble up to it. */
|
|
9
|
+
owner?: Message;
|
|
10
|
+
/** Location of this message inside the root message, e.g. `items[0]`. */
|
|
11
|
+
path?: string;
|
|
12
|
+
/** Called after this message changes (before the owner is notified). */
|
|
13
|
+
onChange?: () => void;
|
|
14
|
+
store?: FormStore;
|
|
15
|
+
};
|
|
16
|
+
export declare class Message {
|
|
17
|
+
readonly value: ReflectMessage;
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly store: FormStore;
|
|
20
|
+
protected readonly owner?: Message;
|
|
21
|
+
private readonly onChange?;
|
|
22
|
+
constructor(desc: DescMessage, init?: MessageInitShape<DescMessage>, options?: MessageOptions);
|
|
23
|
+
/** Fields in declaration order; each oneof group is a single `OneOfField`. */
|
|
24
|
+
fields(): Field[];
|
|
25
|
+
fieldPath(desc: Pick<DescField, "name">): string;
|
|
26
|
+
/** Violations reported for this message as a whole. */
|
|
27
|
+
get errors(): Violation[];
|
|
28
|
+
errorMessages(): string[];
|
|
29
|
+
errorMessagesAt(path: string): string[];
|
|
30
|
+
/**
|
|
31
|
+
* Validates the whole message tree (delegating to the root message) and
|
|
32
|
+
* records the violations so fields can display them.
|
|
33
|
+
*/
|
|
34
|
+
validate(validator?: Validator): ValidationResult<MessageValidType<DescMessage>, ProtoMessage>;
|
|
35
|
+
get(): ProtoMessage;
|
|
36
|
+
/** Replaces the contents of this message with `value`. */
|
|
37
|
+
set(value: ProtoMessage): void;
|
|
38
|
+
/** Resets every field to its zero value. */
|
|
39
|
+
clear(): void;
|
|
40
|
+
/** Signals that this message changed; subscribed UI re-renders. */
|
|
41
|
+
notify(): void;
|
|
42
|
+
protected attach(): void;
|
|
43
|
+
protected reset(): void;
|
|
44
|
+
}
|
|
45
|
+
export type MessageFieldDesc = Extract<DescField, {
|
|
46
|
+
fieldKind: "message";
|
|
47
|
+
}>;
|
|
48
|
+
export declare class MessageField extends Message implements Field {
|
|
49
|
+
readonly parent: Message;
|
|
50
|
+
readonly desc: MessageFieldDesc;
|
|
51
|
+
readonly elem: Element;
|
|
52
|
+
constructor(parent: Message, desc: MessageFieldDesc);
|
|
53
|
+
isSet(): boolean;
|
|
54
|
+
/** Marks the field as present, creating an empty message if it was unset. */
|
|
55
|
+
ensure(): void;
|
|
56
|
+
/** Unsets the field. */
|
|
57
|
+
clear(): void;
|
|
58
|
+
toString(): string;
|
|
59
|
+
parse(value: string): void;
|
|
60
|
+
protected attach(): void;
|
|
61
|
+
}
|
package/dist/oneof.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DescField, DescOneof } from '@bufbuild/protobuf';
|
|
2
|
+
import { Violation } from '@bufbuild/protovalidate';
|
|
3
|
+
import { Element } from './element';
|
|
4
|
+
import { Field } from './field';
|
|
5
|
+
import { Message } from './message';
|
|
6
|
+
/** A oneof group: at most one of its member fields is set at a time. */
|
|
7
|
+
export declare class OneOfField implements Field {
|
|
8
|
+
readonly parent: Message;
|
|
9
|
+
readonly oneOf: DescOneof;
|
|
10
|
+
readonly elem: Element;
|
|
11
|
+
readonly path: string;
|
|
12
|
+
constructor(parent: Message, oneOf: DescOneof);
|
|
13
|
+
/** The selected member, or the first member when nothing is selected. */
|
|
14
|
+
get desc(): DescField;
|
|
15
|
+
get errors(): Violation[];
|
|
16
|
+
errorMessages(): string[];
|
|
17
|
+
/** All members, e.g. to offer them as choices. */
|
|
18
|
+
fields(): Field[];
|
|
19
|
+
/** The selected member, if any. */
|
|
20
|
+
active(): Field | undefined;
|
|
21
|
+
isSet(): boolean;
|
|
22
|
+
/** Selects the member named `name` (resetting it), or unsets the group if `undefined`. */
|
|
23
|
+
select(name: string | undefined): void;
|
|
24
|
+
clear(): void;
|
|
25
|
+
toString(): string;
|
|
26
|
+
parse(value: string): void;
|
|
27
|
+
}
|
package/dist/path.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DescField } from '@bufbuild/protobuf';
|
|
2
|
+
import { Path } from '@bufbuild/protobuf/reflect';
|
|
3
|
+
/** Joins a parent path and a field into a path such as `items[0].name`. */
|
|
4
|
+
export declare function fieldPath(base: string, desc: Pick<DescField, "name">): string;
|
|
5
|
+
export declare function indexPath(base: string, index: number): string;
|
|
6
|
+
export declare function keyPath(base: string, key: string | number | bigint | boolean): string;
|
|
7
|
+
/** Converts a protovalidate violation path into the same notation as `fieldPath`. */
|
|
8
|
+
export declare function pathToString(path: Path): string;
|