@okam/directus-block 1.2.1 → 1.2.2
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/blocks/BlockWysiwyg/config.d.ts +4 -0
- package/blocks/BlockWysiwyg/index.d.ts +4 -0
- package/blocks/BlockWysiwyg/interface.d.ts +17 -0
- package/components/BlockDispatcher/config.d.ts +3 -0
- package/components/BlockDispatcher/interface.d.ts +16 -0
- package/components/BlockSerializer/interface.d.ts +31 -0
- package/generated/fragment-masking.d.ts +15 -0
- package/generated/graphql.d.ts +64 -0
- package/index.d.ts +6 -0
- package/index.js +96 -0
- package/index.mjs +5966 -0
- package/package.json +1 -1
- package/style.css +1 -0
- package/types/block.d.ts +27 -0
- package/utils/get-block-props.d.ts +17 -0
- package/utils/index.d.ts +4 -0
- package/utils/merge-configs.d.ts +9 -0
- package/.eslintrc.js +0 -21
- package/.storybook/.eslintrc.js +0 -29
- package/.storybook/main.ts +0 -33
- package/.storybook/preview.ts +0 -0
- package/.storybook/tsconfig.json +0 -17
- package/CHANGELOG.md +0 -25
- package/README.md +0 -167
- package/project.json +0 -36
- package/src/blocks/BlockWysiwyg/config.tsx +0 -10
- package/src/blocks/BlockWysiwyg/index.tsx +0 -38
- package/src/blocks/BlockWysiwyg/interface.ts +0 -13
- package/src/components/BlockDispatcher/config.ts +0 -10
- package/src/components/BlockDispatcher/index.tsx +0 -30
- package/src/components/BlockDispatcher/interface.ts +0 -17
- package/src/components/BlockSerializer/index.tsx +0 -43
- package/src/components/BlockSerializer/interface.ts +0 -51
- package/src/generated/fragment-masking.ts +0 -66
- package/src/generated/graphql.ts +0 -31
- package/src/index.ts +0 -22
- package/src/server.ts +0 -6
- package/src/types/block.ts +0 -40
- package/src/utils/get-block-props.ts +0 -81
- package/src/utils/index.ts +0 -5
- package/src/utils/merge-configs.ts +0 -21
- package/tsconfig.json +0 -17
- package/tsconfig.lib.json +0 -23
- package/vite.config.ts +0 -51
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TBlockSerializerConfigComponent } from '../../components/BlockSerializer/interface';
|
|
2
|
+
import type { BlockWysiwygFragment } from './interface';
|
|
3
|
+
declare const blockWysiwygConfig: TBlockSerializerConfigComponent<BlockWysiwygFragment>;
|
|
4
|
+
export default blockWysiwygConfig;
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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>;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { TBlockDispatcherProps } from './components/BlockDispatcher/interface';
|
|
2
|
+
export type { TBlockSerializerConfig, TBlockSerializerProps, TBlock, TBlockSerializerConfigComponent, } from './components/BlockSerializer/interface';
|
|
3
|
+
export type { TAdditionalProps, TCommonBlockFragment, TBlockQuery, TBlockDocument, TBlockVariables, } from './types/block';
|
|
4
|
+
export { default as BlockWysiwyg } from './blocks/BlockWysiwyg';
|
|
5
|
+
export { default as blockWysiwygConfig } from './blocks/BlockWysiwyg/config';
|
|
6
|
+
export { default as baseConfig } from './components/BlockDispatcher/config';
|