tinacms 1.2.2 → 1.3.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.
@@ -1,139 +0,0 @@
1
- /**
2
-
3
- */
4
- import { Form, Field, TinaCMS } from '@tinacms/toolkit';
5
- import type { DocumentBlueprint, FieldBlueprint, FormifiedDocumentNode, OnChangeEvent, FormNode, State, ChangeSet, BlueprintPath } from './types';
6
- import { formifyCallback, onSubmitArgs } from '../use-graphql-forms';
7
- interface RecursiveFormifiedDocumentNode<T extends object> extends Array<RecursiveFormifiedDocumentNode<T> | T> {
8
- }
9
- /**
10
- * Gets the value from an object for a given blueprint for _all_ possible values.
11
- * eg. If the blueprint is `getCollection.documents.edges.[].node` and the value is:
12
- * ```
13
- * {
14
- * getCollection: {
15
- * documents: {
16
- * edges: [{
17
- * node: valueA
18
- * },
19
- * {
20
- * node: valueB
21
- * }]
22
- * }
23
- * }
24
- * }
25
- * ```
26
- * The response would be an array containing `valueA` and `valueB`
27
- *
28
- */
29
- export declare const getValueForBlueprint: <T extends object>(state: object, path: string) => T | RecursiveFormifiedDocumentNode<T>;
30
- /**
31
- * Returns the name of the field. In the example query, `title` and `t` would both be blueprint fields
32
- *
33
- * ```graphql
34
- * {
35
- * getPostDocument(relativePath: $relativePath) {
36
- * data {
37
- * title,
38
- * t: title # here `t` is an alias for title
39
- * }
40
- * }
41
- * }
42
- * ```
43
- */
44
- export declare const getFieldNameOrAlias: (fieldBlueprint: FieldBlueprint) => string;
45
- export declare const buildForm: (doc: FormifiedDocumentNode, cms: TinaCMS, formify: formifyCallback, showInSidebar?: boolean, onSubmit?: (args: onSubmitArgs) => void) => Form;
46
- export declare const formNodeId: (formNode: FormNode) => string;
47
- export declare const formNodePath: (formNode: FormNode) => string;
48
- export declare const formNodeNotIn: (formNode: FormNode, formNodes: FormNode[]) => boolean;
49
- export declare const sequential: <A, B>(items: A[], callback: (args: A, idx: number) => Promise<B>) => Promise<B[]>;
50
- export declare const getFormNodesForField: (fieldBlueprint: FieldBlueprint, formNode: FormNode, event: OnChangeEvent, state: State) => {
51
- pathToChange: string;
52
- formNodes: FormNode[];
53
- eventLocation: any[];
54
- existing: any;
55
- };
56
- export declare const getBlueprintAliasPath: (blueprint: DocumentBlueprint) => string;
57
- export declare const getFieldAliasForBlueprint: (path: BlueprintPath[]) => string;
58
- /**
59
- *
60
- * Determines the appropriate fields which should recieve an update from a form change
61
- *
62
- * In cases where there's polymorphic blocks, it's possible that an update would affect
63
- * multiple locations that it shouldn't.
64
- *
65
- * An OnChange event name can look like: `blocks.2.title`, but if there are 2 block elements
66
- * with a field of the same name, an event name it wouldn't be enough information for us.
67
- *
68
- * To get around this, the event sends the current `typename` along with it, and we use that
69
- * to determine where in our blueprint the value should be updated.
70
- *
71
- */
72
- export declare const getBlueprintFieldsForEvent: (blueprint: DocumentBlueprint, event: OnChangeEvent) => FieldBlueprint[];
73
- export declare const filterFieldBlueprintsByParentTypename: (fbp: FieldBlueprint, typename: any) => boolean;
74
- /**
75
- *
76
- * Returns the human-readable path to a blueprint or blueprint field.
77
- * Optionally, appends a disambiguator to the string where necessary.
78
- *
79
- * eg. if a blocks field is polymporphic, specifying `true` for the disambiguator
80
- *
81
- * ```
82
- * getPageDocument.data.blocks[].PageBlocksCta.title
83
- * ```
84
- */
85
- export declare const getBlueprintNamePath: (blueprint: Pick<DocumentBlueprint, 'path'>, disambiguator?: boolean) => string;
86
- export declare const stripIndices: (string: any) => any[];
87
- export declare const replaceRealNum: (string: any) => any;
88
- export declare const getMatchName: ({ field, prefix, blueprint }: {
89
- field: any;
90
- prefix: any;
91
- blueprint: any;
92
- }) => {
93
- matchName: string;
94
- fieldName: any;
95
- };
96
- export declare const getFormNodesFromEvent: (state: State, event: OnChangeEvent) => FormNode[];
97
- export declare const printState: (state: State) => string;
98
- export declare const printEvent: (event: OnChangeEvent) => {
99
- type: "forms:fields:onChange" | "forms:reset";
100
- value: unknown;
101
- previousValue: unknown;
102
- mutationType: import("./types").ChangeMutation | import("./types").ReferenceChangeMutation | import("./types").InsertMutation | import("./types").MoveMutation | import("./types").RemoveMutation | import("./types").ResetMutation | import("./types").GlobalMutation;
103
- formId: string;
104
- field: {
105
- data: {
106
- tinaField: {
107
- name: string;
108
- type: "string" | "object" | "reference";
109
- list?: boolean;
110
- parentTypename: string;
111
- };
112
- };
113
- name: string;
114
- };
115
- };
116
- export declare const getFormNodeBlueprint: (formNode: FormNode, state: State) => DocumentBlueprint;
117
- export declare const getMoveMapping: (existing: any, from: any, to: any) => {
118
- [key: number]: number;
119
- };
120
- export declare const matchLocation: (eventLocation: number[], formNode: FormNode) => boolean;
121
- export declare const bumpLocation: (location: number[]) => number[];
122
- export declare const maybeLowerLocation: (location: number[], at: number) => number[];
123
- export declare const matchesAt: (location: number[], at: number) => boolean;
124
- export declare const swapLocation: (location: number[], mapping: {
125
- [key: number]: number;
126
- }) => number[];
127
- /**
128
- *
129
- * Gets the sub-fields for an object field, if it's a polymorphic
130
- * object then we also need to get the __typename, though
131
- * we should probably supply that regardless. The current downside
132
- * of this is that it needs to come from the server because we
133
- * have no way of knowing what it would be from the client-side
134
- */
135
- export declare const getSubFields: (changeSet: ChangeSet) => {
136
- fields: Field[];
137
- __typename: string;
138
- };
139
- export {};