@okam/directus-block 1.1.1 → 1.2.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/.eslintrc.js +21 -0
- package/.storybook/.eslintrc.js +29 -0
- package/.storybook/main.ts +33 -0
- package/.storybook/preview.ts +0 -0
- package/.storybook/tsconfig.json +17 -0
- package/CHANGELOG.md +25 -0
- package/README.md +167 -0
- package/package.json +1 -1
- package/project.json +36 -0
- package/src/blocks/BlockWysiwyg/config.tsx +10 -0
- package/src/blocks/BlockWysiwyg/index.tsx +38 -0
- package/src/blocks/BlockWysiwyg/interface.ts +13 -0
- package/src/components/BlockDispatcher/config.ts +10 -0
- package/src/components/BlockDispatcher/index.tsx +30 -0
- package/src/components/BlockDispatcher/interface.ts +17 -0
- package/src/components/BlockSerializer/index.tsx +43 -0
- package/src/components/BlockSerializer/interface.ts +51 -0
- package/src/generated/fragment-masking.ts +66 -0
- package/src/generated/graphql.ts +31 -0
- package/src/index.ts +22 -0
- package/src/server.ts +6 -0
- package/src/types/block.ts +40 -0
- package/src/utils/get-block-props.ts +81 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/merge-configs.ts +21 -0
- package/tsconfig.json +17 -0
- package/tsconfig.lib.json +23 -0
- package/vite.config.ts +51 -0
- package/blocks/BlockWysiwyg/config.d.ts +0 -3
- package/blocks/BlockWysiwyg/index.d.ts +0 -4
- package/blocks/BlockWysiwyg/interface.d.ts +0 -17
- package/components/BlockDispatcher/config.d.ts +0 -3
- package/components/BlockDispatcher/index.d.ts +0 -5
- package/components/BlockDispatcher/interface.d.ts +0 -16
- package/components/BlockSerializer/index.d.ts +0 -3
- package/components/BlockSerializer/interface.d.ts +0 -31
- package/generated/fragment-masking.d.ts +0 -15
- package/generated/graphql.d.ts +0 -64
- package/index.d.ts +0 -10
- package/index.js +0 -96
- package/index.mjs +0 -6019
- package/style.css +0 -1
- package/types/block.d.ts +0 -27
- package/utils/get-block-props.d.ts +0 -17
- package/utils/index.d.ts +0 -4
- package/utils/merge-configs.d.ts +0 -9
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Types
|
|
2
|
+
export type { TBlockDispatcherProps } from './components/BlockDispatcher/interface'
|
|
3
|
+
export type {
|
|
4
|
+
TBlockSerializerConfig,
|
|
5
|
+
TBlockSerializerProps,
|
|
6
|
+
TBlock,
|
|
7
|
+
TBlockSerializerConfigComponent,
|
|
8
|
+
} from './components/BlockSerializer/interface'
|
|
9
|
+
export type {
|
|
10
|
+
TAdditionalProps,
|
|
11
|
+
TCommonBlockFragment,
|
|
12
|
+
TBlockQuery,
|
|
13
|
+
TBlockDocument,
|
|
14
|
+
TBlockVariables,
|
|
15
|
+
} from './types/block'
|
|
16
|
+
|
|
17
|
+
// Blocks
|
|
18
|
+
export { default as BlockWysiwyg } from './blocks/BlockWysiwyg'
|
|
19
|
+
|
|
20
|
+
// Configs
|
|
21
|
+
export { default as blockWysiwygConfig } from './blocks/BlockWysiwyg/config'
|
|
22
|
+
export { default as baseConfig } from './components/BlockDispatcher/config'
|
package/src/server.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'server-only'
|
|
2
|
+
|
|
3
|
+
export { default as BlockDispatcher } from './components/BlockDispatcher'
|
|
4
|
+
export { default as BlockSerializer } from './components/BlockSerializer'
|
|
5
|
+
export { default as getBlockProps } from './utils/get-block-props'
|
|
6
|
+
export { default as mergeConfigs } from './utils/merge-configs'
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import type { DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core'
|
|
3
|
+
import type { Nullable } from '@okam/stack-ui'
|
|
4
|
+
import type { Variables } from 'graphql-request'
|
|
5
|
+
import type { FragmentType } from '../generated/fragment-masking'
|
|
6
|
+
import type { BlockSettingsFragment } from '../generated/graphql'
|
|
7
|
+
|
|
8
|
+
export type TAdditionalProps = { [key: string]: unknown }
|
|
9
|
+
|
|
10
|
+
type BlockSettings = FragmentType<DocumentTypeDecoration<BlockSettingsFragment, unknown>>
|
|
11
|
+
|
|
12
|
+
export type TCommonBlockFragment = {
|
|
13
|
+
id?: Nullable<string>
|
|
14
|
+
settings?: Nullable<BlockSettings>
|
|
15
|
+
} & Record<string, unknown>
|
|
16
|
+
|
|
17
|
+
export type TBlockQuery<BlockFragment extends TCommonBlockFragment> = {
|
|
18
|
+
__typename?: 'Query'
|
|
19
|
+
} & {
|
|
20
|
+
[blockKey: string]:
|
|
21
|
+
| {
|
|
22
|
+
' $fragmentRefs'?:
|
|
23
|
+
| {
|
|
24
|
+
[blockFragmentKey: string]: BlockFragment
|
|
25
|
+
}
|
|
26
|
+
| null
|
|
27
|
+
| undefined
|
|
28
|
+
}
|
|
29
|
+
| null
|
|
30
|
+
| undefined
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type TBlockVariables<BlockVariables extends Variables = Variables> = {
|
|
34
|
+
id: string
|
|
35
|
+
} & BlockVariables
|
|
36
|
+
|
|
37
|
+
export type TBlockDocument<
|
|
38
|
+
BlockFragment extends TCommonBlockFragment,
|
|
39
|
+
BlockVariables extends Variables = Variables,
|
|
40
|
+
> = TypedDocumentNode<TBlockQuery<BlockFragment>, TBlockVariables<BlockVariables>>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'server-only'
|
|
2
|
+
|
|
3
|
+
import { queryGql } from '@okam/directus-query'
|
|
4
|
+
import type { Nullable } from '@okam/stack-ui'
|
|
5
|
+
import type { Variables } from 'graphql-request'
|
|
6
|
+
import { isEmpty } from 'radash'
|
|
7
|
+
import type { TBlockDocument, TBlockQuery, TBlockVariables, TCommonBlockFragment } from '../types/block'
|
|
8
|
+
|
|
9
|
+
type TGetBlockPropsParams<BlockFragment extends TCommonBlockFragment, BlockVariables extends Variables = Variables> = {
|
|
10
|
+
document?: TBlockDocument<BlockFragment, BlockVariables>
|
|
11
|
+
item?: Nullable<NonNullable<NonNullable<TBlockQuery<BlockFragment>[string]>[' $fragmentRefs']>[string]>
|
|
12
|
+
blockKey?: string
|
|
13
|
+
variables?: TBlockVariables<BlockVariables>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isVariables<BlockVariables extends Variables>(
|
|
17
|
+
maybeVariables: Nullable<Variables>,
|
|
18
|
+
): maybeVariables is BlockVariables {
|
|
19
|
+
return !!maybeVariables
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isOnlyIdInItem(item: TCommonBlockFragment): item is TBlockVariables {
|
|
23
|
+
return !isEmpty(item) && Object.keys(item).length === 1 && Object.keys(item)[0] === 'id' && !!item.id
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function queryFromVariables<
|
|
27
|
+
BlockFragment extends TCommonBlockFragment,
|
|
28
|
+
BlockVariables extends Variables = Variables,
|
|
29
|
+
>(params: TGetBlockPropsParams<BlockFragment, BlockVariables>) {
|
|
30
|
+
const { document, blockKey, variables } = params
|
|
31
|
+
|
|
32
|
+
if (!document || !isVariables<BlockVariables>(variables)) return null
|
|
33
|
+
|
|
34
|
+
const queriedBlockProps = await queryGql(document, variables)
|
|
35
|
+
|
|
36
|
+
if (!queriedBlockProps || typeof queriedBlockProps !== 'object' || !blockKey) return null
|
|
37
|
+
|
|
38
|
+
const queriedBlockFragment = queriedBlockProps[blockKey]
|
|
39
|
+
|
|
40
|
+
return queriedBlockFragment as BlockFragment
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns the passed item if it is defined. Otherwise, queried its own block
|
|
45
|
+
* @param params.blockKey Key of the queried field
|
|
46
|
+
* @param params.item Item of the block. If null or only contains the block's id, the function will make a query
|
|
47
|
+
* @returns The block data
|
|
48
|
+
*/
|
|
49
|
+
export default async function getBlockProps<
|
|
50
|
+
BlockFragment extends TCommonBlockFragment,
|
|
51
|
+
BlockVariables extends Variables = Variables,
|
|
52
|
+
>(params: TGetBlockPropsParams<BlockFragment, BlockVariables>): Promise<BlockFragment | null | undefined> {
|
|
53
|
+
const { document, item, blockKey, variables } = params
|
|
54
|
+
|
|
55
|
+
if (item) {
|
|
56
|
+
// If the item actually contains the block's data, just return it
|
|
57
|
+
if (!isOnlyIdInItem(item)) {
|
|
58
|
+
return item
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Otherwise, the id necessary to make the query might be inside the item. Just in case, we have a fallback
|
|
62
|
+
const variablesWithFallback = { id: item.id, ...variables }
|
|
63
|
+
|
|
64
|
+
if (!isVariables<BlockVariables>(variablesWithFallback)) return null
|
|
65
|
+
|
|
66
|
+
return queryFromVariables({
|
|
67
|
+
...params,
|
|
68
|
+
variables: variablesWithFallback,
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!document || !isVariables(variables)) return null
|
|
73
|
+
|
|
74
|
+
const queriedBlockProps = await queryGql(document, variables)
|
|
75
|
+
|
|
76
|
+
if (!queriedBlockProps || typeof queriedBlockProps !== 'object' || !blockKey) return null
|
|
77
|
+
|
|
78
|
+
const queriedBlockFragment = queriedBlockProps[blockKey]
|
|
79
|
+
|
|
80
|
+
return queriedBlockFragment as BlockFragment
|
|
81
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Nullable } from '@okam/stack-ui'
|
|
2
|
+
import type { TBlockSerializerConfig } from '../components/BlockSerializer/interface'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Merges multiple block dispatcher configs
|
|
6
|
+
* @param baseConfig The base configuration. Other configurations will be prioritized over this one, which acts as a fallback
|
|
7
|
+
* @param configs Array of block dispatcher serializers to merge. Later elements will always be prioritized over first elements
|
|
8
|
+
* @returns Merged config
|
|
9
|
+
*/
|
|
10
|
+
export default function mergeConfigs(
|
|
11
|
+
baseConfig: TBlockSerializerConfig,
|
|
12
|
+
...configs: Nullable<TBlockSerializerConfig>[]
|
|
13
|
+
): TBlockSerializerConfig {
|
|
14
|
+
const finalConfig = configs.reduce<TBlockSerializerConfig>((mergedConfig, config) => {
|
|
15
|
+
if (!config) return mergedConfig
|
|
16
|
+
|
|
17
|
+
return { components: { ...mergedConfig.components, ...config.components } }
|
|
18
|
+
}, baseConfig)
|
|
19
|
+
|
|
20
|
+
return finalConfig
|
|
21
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"jsx": "react-jsx",
|
|
4
|
+
"allowJs": false,
|
|
5
|
+
"esModuleInterop": false,
|
|
6
|
+
"allowSyntheticDefaultImports": true,
|
|
7
|
+
"strict": true
|
|
8
|
+
},
|
|
9
|
+
"files": [],
|
|
10
|
+
"include": [],
|
|
11
|
+
"references": [
|
|
12
|
+
{
|
|
13
|
+
"path": "./tsconfig.lib.json"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"extends": "../../../tsconfig.base.json"
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../../dist/out-tsc",
|
|
5
|
+
"types": ["node", "next"]
|
|
6
|
+
},
|
|
7
|
+
"paths": { "@workspace/*": ["dist/libs/*"] },
|
|
8
|
+
"files": [
|
|
9
|
+
"../../../node_modules/@nx/react/typings/cssmodule.d.ts",
|
|
10
|
+
"../../../node_modules/@nx/react/typings/image.d.ts"
|
|
11
|
+
],
|
|
12
|
+
"exclude": [
|
|
13
|
+
"**/*.spec.ts",
|
|
14
|
+
"**/*.test.ts",
|
|
15
|
+
"**/*.spec.tsx",
|
|
16
|
+
"**/*.test.tsx",
|
|
17
|
+
"**/*.spec.js",
|
|
18
|
+
"**/*.test.js",
|
|
19
|
+
"**/*.spec.jsx",
|
|
20
|
+
"**/*.test.jsx",
|
|
21
|
+
],
|
|
22
|
+
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
|
|
23
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* eslint-disable import/no-relative-packages */
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import * as path from 'path'
|
|
4
|
+
import react from '@vitejs/plugin-react'
|
|
5
|
+
import { defineConfig } from 'vite'
|
|
6
|
+
import dts from 'vite-plugin-dts'
|
|
7
|
+
import viteTsConfigPaths from 'vite-tsconfig-paths'
|
|
8
|
+
import externalDeps from '../../../config/external-deps'
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
cacheDir: '../../../node_modules/.vite/directus-block',
|
|
12
|
+
|
|
13
|
+
plugins: [
|
|
14
|
+
dts({
|
|
15
|
+
entryRoot: 'src',
|
|
16
|
+
tsConfigFilePath: path.join(__dirname, 'tsconfig.lib.json'),
|
|
17
|
+
skipDiagnostics: true,
|
|
18
|
+
}),
|
|
19
|
+
react(),
|
|
20
|
+
viteTsConfigPaths({
|
|
21
|
+
root: '../../../',
|
|
22
|
+
}),
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
// Uncomment this if you are using workers.
|
|
26
|
+
// worker: {
|
|
27
|
+
// plugins: [
|
|
28
|
+
// viteTsConfigPaths({
|
|
29
|
+
// root: '../../../',
|
|
30
|
+
// }),
|
|
31
|
+
// ],
|
|
32
|
+
// },
|
|
33
|
+
|
|
34
|
+
// Configuration for building your library.
|
|
35
|
+
// See: https://vitejs.dev/guide/build.html#library-mode
|
|
36
|
+
build: {
|
|
37
|
+
lib: {
|
|
38
|
+
// Could also be a dictionary or array of multiple entry points.
|
|
39
|
+
entry: 'src/index.ts',
|
|
40
|
+
name: 'directus-block',
|
|
41
|
+
fileName: 'index',
|
|
42
|
+
// Change this to the formats you want to support.
|
|
43
|
+
// Don't forget to update your package.json as well.
|
|
44
|
+
formats: ['es', 'cjs'],
|
|
45
|
+
},
|
|
46
|
+
rollupOptions: {
|
|
47
|
+
// External packages that should not be bundled into your library.
|
|
48
|
+
external: externalDeps,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
})
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TBlockSerializerProps } from '../../components/BlockSerializer/interface';
|
|
2
|
-
import type { BlockWysiwygFragment } from './interface';
|
|
3
|
-
declare const BlockWysiwyg: (props: TBlockSerializerProps<BlockWysiwygFragment>) => Promise<import("react/jsx-runtime").JSX.Element | null>;
|
|
4
|
-
export default BlockWysiwyg;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { BlockSettingsFragment } from '../../generated/graphql';
|
|
2
|
-
export type BlockWysiwygFragment = {
|
|
3
|
-
__typename?: 'block_wysiwyg';
|
|
4
|
-
title?: string | null;
|
|
5
|
-
content?: string | null;
|
|
6
|
-
level?: string | null;
|
|
7
|
-
variant?: string | null;
|
|
8
|
-
settings?: ({
|
|
9
|
-
__typename?: 'block_settings';
|
|
10
|
-
} & {
|
|
11
|
-
' $fragmentRefs'?: {
|
|
12
|
-
BlockSettingsFragment: BlockSettingsFragment;
|
|
13
|
-
};
|
|
14
|
-
}) | null;
|
|
15
|
-
} & {
|
|
16
|
-
' $fragmentName'?: 'BlockWysiwygFragment';
|
|
17
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react/experimental" />
|
|
3
|
-
import type { TBlockDispatcherProps } from './interface';
|
|
4
|
-
declare const BlockDispatcher: (props: TBlockDispatcherProps) => string | number | boolean | Iterable<import("react").ReactNode> | import("react").PromiseLikeOfReactNode | import("react/jsx-runtime").JSX.Element | (string | number | boolean | Iterable<import("react").ReactNode> | import("react").PromiseLikeOfReactNode | import("react/jsx-runtime").JSX.Element | null | undefined)[] | null | undefined;
|
|
5
|
-
export default BlockDispatcher;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { TDefaultComponent, Nullable } from '@okam/stack-ui';
|
|
2
|
-
import type React from 'react';
|
|
3
|
-
import type { TAdditionalProps } from '../../types/block';
|
|
4
|
-
import type { TBlockSerializerProps, TBlockSerializerConfig } from '../BlockSerializer/interface';
|
|
5
|
-
interface TBaseBlockDispatcherProps<AdditionalProps extends TAdditionalProps = TAdditionalProps> extends Omit<TDefaultComponent, 'children'> {
|
|
6
|
-
config?: TBlockSerializerConfig;
|
|
7
|
-
defaultVariant?: string;
|
|
8
|
-
additionalProps?: AdditionalProps;
|
|
9
|
-
children?: (props: TBlockSerializerProps) => React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
export type TBlockDispatcherProps<AdditionalProps extends TAdditionalProps = TAdditionalProps> = (TBaseBlockDispatcherProps<AdditionalProps> & {
|
|
12
|
-
block: Nullable<TBlockSerializerProps>;
|
|
13
|
-
}) | (TBaseBlockDispatcherProps<AdditionalProps> & {
|
|
14
|
-
blocks: Nullable<TBlockSerializerProps>[];
|
|
15
|
-
});
|
|
16
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
-
import type { Nullable, TDefaultComponent } from '@okam/stack-ui';
|
|
3
|
-
import type { Variables } from 'graphql-request';
|
|
4
|
-
import type { FunctionComponent } from 'react';
|
|
5
|
-
import type { TCommonBlockFragment, TAdditionalProps, TBlockQuery, TBlockVariables, TBlockDocument } from '../../types/block';
|
|
6
|
-
export interface TBlock<BlockFragment extends TCommonBlockFragment = TCommonBlockFragment, BlockVariables extends Variables = Variables> {
|
|
7
|
-
collection?: Nullable<string>;
|
|
8
|
-
item?: Nullable<BlockFragment>;
|
|
9
|
-
variables?: TBlockVariables<BlockVariables>;
|
|
10
|
-
document?: TypedDocumentNode<TBlockQuery<BlockFragment>, BlockVariables>;
|
|
11
|
-
}
|
|
12
|
-
export type TBlockSerializerProps<BlockFragment extends TCommonBlockFragment = TCommonBlockFragment, BlockVariables extends Variables = TBlockVariables, AdditionalProps extends TAdditionalProps = TAdditionalProps> = TBlock<BlockFragment, BlockVariables> & TDefaultComponent & {
|
|
13
|
-
config?: TBlockSerializerConfig;
|
|
14
|
-
defaultVariant?: string;
|
|
15
|
-
additionalProps?: AdditionalProps;
|
|
16
|
-
};
|
|
17
|
-
export type TBlockFunctionComponent<BlockFragment extends TCommonBlockFragment = TCommonBlockFragment> = FunctionComponent<TBlockSerializerProps<BlockFragment>>;
|
|
18
|
-
export type TBlockSerializerConfigComponent<BlockFragment extends TCommonBlockFragment = TCommonBlockFragment> = {
|
|
19
|
-
[blockKey: string]: {
|
|
20
|
-
default: TBlockFunctionComponent<BlockFragment>;
|
|
21
|
-
document?: TBlockDocument<BlockFragment>;
|
|
22
|
-
defaultVariant?: string;
|
|
23
|
-
getVariant?: (props: TBlockSerializerProps<BlockFragment>) => Nullable<string>;
|
|
24
|
-
variants?: {
|
|
25
|
-
[blockVariant: string]: TBlockFunctionComponent<BlockFragment>;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export interface TBlockSerializerConfig {
|
|
30
|
-
components: TBlockSerializerConfigComponent;
|
|
31
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
-
import { Incremental } from './graphql';
|
|
3
|
-
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<infer TType, any> ? [TType] extends [{
|
|
4
|
-
' $fragmentName'?: infer TKey;
|
|
5
|
-
}] ? TKey extends string ? {
|
|
6
|
-
' $fragmentRefs'?: {
|
|
7
|
-
[key in TKey]: TType;
|
|
8
|
-
};
|
|
9
|
-
} : never : never : never;
|
|
10
|
-
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>): TType;
|
|
11
|
-
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined): TType | null | undefined;
|
|
12
|
-
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>): ReadonlyArray<TType>;
|
|
13
|
-
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): ReadonlyArray<TType> | null | undefined;
|
|
14
|
-
export declare function makeFragmentData<F extends DocumentTypeDecoration<any, any>, FT extends ResultOf<F>>(data: FT, _fragment: F): FragmentType<F>;
|
|
15
|
-
export declare function isFragmentReady<TQuery, TFrag>(queryNode: DocumentTypeDecoration<TQuery, any>, fragmentNode: TypedDocumentNode<TFrag>, data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined): data is FragmentType<typeof fragmentNode>;
|
package/generated/graphql.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
-
export type Exact<T extends {
|
|
3
|
-
[key: string]: unknown;
|
|
4
|
-
}> = {
|
|
5
|
-
[K in keyof T]: T[K];
|
|
6
|
-
};
|
|
7
|
-
export type Incremental<T> = T | {
|
|
8
|
-
[P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
|
|
9
|
-
};
|
|
10
|
-
export type Scalars = {
|
|
11
|
-
ID: {
|
|
12
|
-
input: string;
|
|
13
|
-
output: string;
|
|
14
|
-
};
|
|
15
|
-
String: {
|
|
16
|
-
input: string;
|
|
17
|
-
output: string;
|
|
18
|
-
};
|
|
19
|
-
Boolean: {
|
|
20
|
-
input: boolean;
|
|
21
|
-
output: boolean;
|
|
22
|
-
};
|
|
23
|
-
Int: {
|
|
24
|
-
input: number;
|
|
25
|
-
output: number;
|
|
26
|
-
};
|
|
27
|
-
Float: {
|
|
28
|
-
input: number;
|
|
29
|
-
output: number;
|
|
30
|
-
};
|
|
31
|
-
/** ISO8601 Date values */
|
|
32
|
-
Date: {
|
|
33
|
-
input: any;
|
|
34
|
-
output: any;
|
|
35
|
-
};
|
|
36
|
-
/** BigInt value */
|
|
37
|
-
GraphQLBigInt: {
|
|
38
|
-
input: any;
|
|
39
|
-
output: any;
|
|
40
|
-
};
|
|
41
|
-
/** A Float or a String */
|
|
42
|
-
GraphQLStringOrFloat: {
|
|
43
|
-
input: any;
|
|
44
|
-
output: any;
|
|
45
|
-
};
|
|
46
|
-
/** Hashed string values */
|
|
47
|
-
Hash: {
|
|
48
|
-
input: any;
|
|
49
|
-
output: any;
|
|
50
|
-
};
|
|
51
|
-
/** The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
|
|
52
|
-
JSON: {
|
|
53
|
-
input: any;
|
|
54
|
-
output: any;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
export type BlockSettingsFragment = {
|
|
58
|
-
__typename?: 'block_settings';
|
|
59
|
-
tokens?: any | null;
|
|
60
|
-
variant?: string | null;
|
|
61
|
-
} & {
|
|
62
|
-
' $fragmentName'?: 'BlockSettingsFragment';
|
|
63
|
-
};
|
|
64
|
-
export declare const BlockSettingsFragmentDoc: DocumentNode<BlockSettingsFragment, unknown>;
|
package/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { default as BlockDispatcher } from './components/BlockDispatcher';
|
|
2
|
-
export { default as BlockSerializer } from './components/BlockSerializer';
|
|
3
|
-
export type { TBlockDispatcherProps } from './components/BlockDispatcher/interface';
|
|
4
|
-
export type { TBlockSerializerConfig, TBlockSerializerProps, TBlock, TBlockSerializerConfigComponent, } from './components/BlockSerializer/interface';
|
|
5
|
-
export type { TAdditionalProps, TCommonBlockFragment, TBlockQuery, TBlockDocument, TBlockVariables, } from './types/block';
|
|
6
|
-
export { default as BlockWysiwyg } from './blocks/BlockWysiwyg';
|
|
7
|
-
export { default as getBlockProps } from './utils/get-block-props';
|
|
8
|
-
export { default as mergeConfigs } from './utils/merge-configs';
|
|
9
|
-
export { default as blockWysiwygConfig } from './blocks/BlockWysiwyg/config';
|
|
10
|
-
export { default as baseConfig } from './components/BlockDispatcher/config';
|