@roblawn/devtool-runtime 0.1.0-alpha.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.md +11 -0
- package/README.md +7 -0
- package/dist/ak/ak.cssState.transform.d.ts +2 -0
- package/dist/ak/ak.cssState.transform.js +60 -0
- package/dist/ak/ak.cssState.types.d.ts +2 -0
- package/dist/ak/ak.cssState.types.js +1 -0
- package/dist/ak/ak.responsive.types.d.ts +18 -0
- package/dist/ak/ak.responsive.types.js +1 -0
- package/dist/ak/ak.tokens.d.ts +10 -0
- package/dist/ak/ak.tokens.js +10 -0
- package/dist/ak/ak.tokens.registry.d.ts +10 -0
- package/dist/ak/ak.tokens.registry.js +45 -0
- package/dist/ak/authoring-surface.shared.d.ts +31 -0
- package/dist/ak/authoring-surface.shared.js +185 -0
- package/dist/ak/configured-core.shared.d.ts +7 -0
- package/dist/ak/configured-core.shared.js +16 -0
- package/dist/ak/configured-surfaces.shared.d.ts +67 -0
- package/dist/ak/configured-surfaces.shared.js +144 -0
- package/dist/ak/index.d.ts +16 -0
- package/dist/ak/index.js +16 -0
- package/dist/ak/project-entry.d.ts +57 -0
- package/dist/ak/project-entry.js +260 -0
- package/dist/ak/project-surface-adapters.shared.d.ts +33 -0
- package/dist/ak/project-surface-adapters.shared.js +83 -0
- package/dist/ak/public-entry.shared.d.ts +16 -0
- package/dist/ak/public-entry.shared.js +18 -0
- package/dist/ak/resolved-layout-marker.shared.d.ts +3 -0
- package/dist/ak/resolved-layout-marker.shared.js +19 -0
- package/dist/ak/runtime-surface.shared.d.ts +31 -0
- package/dist/ak/runtime-surface.shared.js +221 -0
- package/dist/ak/style-execution.d.ts +13 -0
- package/dist/ak/style-execution.js +91 -0
- package/dist/ak/style-schema.d.ts +16 -0
- package/dist/ak/style-schema.js +6 -0
- package/dist/ak/useAk.shared.d.ts +3 -0
- package/dist/ak/useAk.shared.js +36 -0
- package/dist/authoring/authoringEffectKinds.d.ts +2 -0
- package/dist/authoring/authoringEffectKinds.js +48 -0
- package/dist/authoring/index.d.ts +1 -0
- package/dist/authoring/index.js +1 -0
- package/dist/cms/CMSPresenterSchemaTypes.d.ts +108 -0
- package/dist/cms/CMSPresenterSchemaTypes.js +6 -0
- package/dist/cms/CMSSchema.d.ts +27 -0
- package/dist/cms/CMSSchema.js +89 -0
- package/dist/cms/CMSSchemaTypes.d.ts +141 -0
- package/dist/cms/CMSSchemaTypes.js +1 -0
- package/dist/cms/index.d.ts +3 -0
- package/dist/cms/index.js +1 -0
- package/dist/design-system/DesignSystemSnapshotFactory.d.ts +34 -0
- package/dist/design-system/DesignSystemSnapshotFactory.js +38 -0
- package/dist/design-system/ProjectDesignSystemFactory.d.ts +39 -0
- package/dist/design-system/ProjectDesignSystemFactory.js +32 -0
- package/dist/design-system/index.d.ts +8 -0
- package/dist/design-system/index.js +7 -0
- package/dist/design-system/ops/ops.types.d.ts +22 -0
- package/dist/design-system/ops/ops.types.js +1 -0
- package/dist/design-system/resolvers/ds.resolvers.d.ts +3 -0
- package/dist/design-system/resolvers/ds.resolvers.js +24 -0
- package/dist/design-system/resolvers/ds.responsive.d.ts +12 -0
- package/dist/design-system/resolvers/ds.responsive.js +28 -0
- package/dist/design-system/tokens/TokenSchemas.types.d.ts +48 -0
- package/dist/design-system/tokens/TokenSchemas.types.js +3 -0
- package/dist/design-system/tokens/coreTokenFamilies.types.d.ts +2 -0
- package/dist/design-system/tokens/coreTokenFamilies.types.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/layoutRuntime.d.ts +12 -0
- package/dist/layout/layoutRuntime.js +88 -0
- package/dist/schema/LayoutBindingEditorPolicyMetadata.d.ts +7 -0
- package/dist/schema/LayoutBindingEditorPolicyMetadata.js +19 -0
- package/dist/schema/LayoutBindingEditorSectionMetadata.d.ts +7 -0
- package/dist/schema/LayoutBindingEditorSectionMetadata.js +19 -0
- package/dist/schema/LayoutDefinitionMeta.d.ts +54 -0
- package/dist/schema/LayoutDefinitionMeta.js +1 -0
- package/dist/schema/LayoutFieldIntentMetadata.d.ts +22 -0
- package/dist/schema/LayoutFieldIntentMetadata.js +38 -0
- package/dist/schema/LayoutFieldUiMetadata.d.ts +30 -0
- package/dist/schema/LayoutFieldUiMetadata.js +19 -0
- package/dist/schema/LayoutSchema.d.ts +39 -0
- package/dist/schema/LayoutSchema.js +53 -0
- package/dist/schema/LayoutVariantBindings.d.ts +55 -0
- package/dist/schema/LayoutVariantBindings.js +107 -0
- package/dist/schema/SlotSchema.d.ts +10 -0
- package/dist/schema/SlotSchema.js +3 -0
- package/dist/schema/StyleSchema.d.ts +16 -0
- package/dist/schema/StyleSchema.js +6 -0
- package/dist/schema/index.d.ts +9 -0
- package/dist/schema/index.js +9 -0
- package/dist/theme-contract/CompositeFieldOpByFamily.d.ts +126 -0
- package/dist/theme-contract/CompositeFieldOpByFamily.js +126 -0
- package/dist/theme-contract/index.d.ts +7 -0
- package/dist/theme-contract/index.js +7 -0
- package/dist/theme-contract/ops/coreOps.d.ts +697 -0
- package/dist/theme-contract/ops/coreOps.js +748 -0
- package/dist/theme-contract/ops/delegateValidation.types.d.ts +46 -0
- package/dist/theme-contract/ops/delegateValidation.types.js +4 -0
- package/dist/theme-contract/ops/emitters.d.ts +24 -0
- package/dist/theme-contract/ops/emitters.js +151 -0
- package/dist/theme-contract/ops/op.config.d.ts +711 -0
- package/dist/theme-contract/ops/op.config.js +15 -0
- package/dist/theme-contract/tokens/coreTokenFamilies.d.ts +9 -0
- package/dist/theme-contract/tokens/coreTokenFamilies.js +6 -0
- package/dist/theme-contract/tokens/cssLengthConversion.d.ts +2 -0
- package/dist/theme-contract/tokens/cssLengthConversion.js +39 -0
- package/dist/theme-contract/tokens/defineProjectTokenFamilySchema.d.ts +1 -0
- package/dist/theme-contract/tokens/defineProjectTokenFamilySchema.js +1 -0
- package/dist/theme-contract/tokens/defineTokenFamilySchema.d.ts +3 -0
- package/dist/theme-contract/tokens/defineTokenFamilySchema.js +5 -0
- package/dist/theme-contract/tokens/runtimeTokenFamilies.types.d.ts +5 -0
- package/dist/theme-contract/tokens/runtimeTokenFamilies.types.js +1 -0
- package/dist/theme-contract/tokens/schemas/aspect.token.schema.d.ts +20 -0
- package/dist/theme-contract/tokens/schemas/aspect.token.schema.js +19 -0
- package/dist/theme-contract/tokens/schemas/blur.token.schema.d.ts +21 -0
- package/dist/theme-contract/tokens/schemas/blur.token.schema.js +19 -0
- package/dist/theme-contract/tokens/schemas/border.token.schema.d.ts +54 -0
- package/dist/theme-contract/tokens/schemas/border.token.schema.js +43 -0
- package/dist/theme-contract/tokens/schemas/breakpoint.token.schema.d.ts +19 -0
- package/dist/theme-contract/tokens/schemas/breakpoint.token.schema.js +18 -0
- package/dist/theme-contract/tokens/schemas/color.token.schema.d.ts +24 -0
- package/dist/theme-contract/tokens/schemas/color.token.schema.js +23 -0
- package/dist/theme-contract/tokens/schemas/container.token.schema.d.ts +26 -0
- package/dist/theme-contract/tokens/schemas/container.token.schema.js +30 -0
- package/dist/theme-contract/tokens/schemas/font.token.schema.d.ts +17 -0
- package/dist/theme-contract/tokens/schemas/font.token.schema.js +15 -0
- package/dist/theme-contract/tokens/schemas/fontWeight.token.schema.d.ts +24 -0
- package/dist/theme-contract/tokens/schemas/fontWeight.token.schema.js +22 -0
- package/dist/theme-contract/tokens/schemas/leading.token.schema.d.ts +20 -0
- package/dist/theme-contract/tokens/schemas/leading.token.schema.js +18 -0
- package/dist/theme-contract/tokens/schemas/radius.token.schema.d.ts +23 -0
- package/dist/theme-contract/tokens/schemas/radius.token.schema.js +22 -0
- package/dist/theme-contract/tokens/schemas/shadow.token.schema.d.ts +108 -0
- package/dist/theme-contract/tokens/schemas/shadow.token.schema.js +73 -0
- package/dist/theme-contract/tokens/schemas/size.token.schema.d.ts +20 -0
- package/dist/theme-contract/tokens/schemas/size.token.schema.js +19 -0
- package/dist/theme-contract/tokens/schemas/spacing.token.schema.d.ts +21 -0
- package/dist/theme-contract/tokens/schemas/spacing.token.schema.js +20 -0
- package/dist/theme-contract/tokens/schemas/text.token.schema.d.ts +87 -0
- package/dist/theme-contract/tokens/schemas/text.token.schema.js +30 -0
- package/dist/theme-contract/tokens/schemas/textSize.token.schema.d.ts +28 -0
- package/dist/theme-contract/tokens/schemas/textSize.token.schema.js +27 -0
- package/dist/theme-contract/tokens/schemas/title.token.schema.d.ts +85 -0
- package/dist/theme-contract/tokens/schemas/title.token.schema.js +30 -0
- package/dist/theme-contract/tokens/schemas/tracking.token.schema.d.ts +20 -0
- package/dist/theme-contract/tokens/schemas/tracking.token.schema.js +18 -0
- package/dist/theme-contract/tokens/schemas/zIndex.token.schema.d.ts +18 -0
- package/dist/theme-contract/tokens/schemas/zIndex.token.schema.js +17 -0
- package/dist/theme-contract/tokens/tokens.schema.d.ts +531 -0
- package/dist/theme-contract/tokens/tokens.schema.js +32 -0
- package/dist/types/LayoutResolvedTs.types.d.ts +18 -0
- package/dist/types/LayoutResolvedTs.types.js +1 -0
- package/dist/types/authoredTree.types.d.ts +112 -0
- package/dist/types/authoredTree.types.js +1 -0
- package/dist/types/blockRegistry.types.d.ts +37 -0
- package/dist/types/blockRegistry.types.js +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +1 -0
- package/dist/types/layout.types.d.ts +30 -0
- package/dist/types/layout.types.js +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export type CMSFieldPrimitiveType = 'text' | 'textarea' | 'richtext' | 'number' | 'checkbox' | 'select' | 'multiselect' | 'group' | 'array' | 'text-array' | 'number-array' | 'image' | 'icon' | 'link';
|
|
2
|
+
export type CMSSimpleValidation = {
|
|
3
|
+
kind: 'required';
|
|
4
|
+
message?: string;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'minLength';
|
|
7
|
+
value: number;
|
|
8
|
+
message?: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'maxLength';
|
|
11
|
+
value: number;
|
|
12
|
+
message?: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'regex';
|
|
15
|
+
pattern: string;
|
|
16
|
+
flags?: string;
|
|
17
|
+
message?: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'min';
|
|
20
|
+
value: number;
|
|
21
|
+
message?: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'max';
|
|
24
|
+
value: number;
|
|
25
|
+
message?: string;
|
|
26
|
+
};
|
|
27
|
+
export interface BaseCMSField {
|
|
28
|
+
type: string;
|
|
29
|
+
label: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
required?: boolean;
|
|
32
|
+
setDefaultValue?: boolean;
|
|
33
|
+
defaultValue?: unknown;
|
|
34
|
+
hardCoded?: boolean;
|
|
35
|
+
hidden?: boolean;
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
group?: string;
|
|
38
|
+
preview?: CMSFieldPreview;
|
|
39
|
+
omit?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface CMSFieldPreview {
|
|
42
|
+
isTitle?: boolean;
|
|
43
|
+
isSubtitle?: boolean;
|
|
44
|
+
isMedia?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export interface TextCMSField extends BaseCMSField {
|
|
47
|
+
type: 'text';
|
|
48
|
+
input?: 'text' | 'textarea' | 'email' | 'code';
|
|
49
|
+
validations?: CMSSimpleValidation[];
|
|
50
|
+
defaultValue?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface NumberCMSField extends BaseCMSField {
|
|
53
|
+
type: 'number';
|
|
54
|
+
validations?: CMSSimpleValidation[];
|
|
55
|
+
defaultValue?: number;
|
|
56
|
+
}
|
|
57
|
+
export interface CheckboxCMSField extends BaseCMSField {
|
|
58
|
+
type: 'checkbox';
|
|
59
|
+
defaultValue?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface SelectCMSField extends BaseCMSField {
|
|
62
|
+
type: 'select';
|
|
63
|
+
options: {
|
|
64
|
+
label: string;
|
|
65
|
+
value: string;
|
|
66
|
+
}[];
|
|
67
|
+
display?: 'select' | 'radio';
|
|
68
|
+
defaultValue?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface MultiSelectCMSField extends BaseCMSField {
|
|
71
|
+
type: 'multiselect';
|
|
72
|
+
options: {
|
|
73
|
+
label: string;
|
|
74
|
+
value: string;
|
|
75
|
+
}[];
|
|
76
|
+
defaultValue?: string[];
|
|
77
|
+
}
|
|
78
|
+
export interface GroupCMSField extends BaseCMSField {
|
|
79
|
+
type: 'group';
|
|
80
|
+
fields: Record<string, CMSSchemaField>;
|
|
81
|
+
defaultValue?: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
export type CMSPrimitiveArrayItemType = 'image' | 'link' | 'richtext';
|
|
84
|
+
export interface ArrayCMSField extends BaseCMSField {
|
|
85
|
+
type: 'array';
|
|
86
|
+
fields: Record<string, CMSSchemaField>;
|
|
87
|
+
itemType?: CMSPrimitiveArrayItemType;
|
|
88
|
+
minRows?: number;
|
|
89
|
+
maxRows?: number;
|
|
90
|
+
defaultValue?: Record<string, unknown>[];
|
|
91
|
+
}
|
|
92
|
+
export interface TextArrayCMSField extends BaseCMSField {
|
|
93
|
+
type: 'text-array';
|
|
94
|
+
minRows?: number;
|
|
95
|
+
maxRows?: number;
|
|
96
|
+
defaultValue?: string[];
|
|
97
|
+
}
|
|
98
|
+
export interface NumberArrayCMSField extends BaseCMSField {
|
|
99
|
+
type: 'number-array';
|
|
100
|
+
minRows?: number;
|
|
101
|
+
maxRows?: number;
|
|
102
|
+
defaultValue?: number[];
|
|
103
|
+
}
|
|
104
|
+
export interface ImageCMSField extends BaseCMSField {
|
|
105
|
+
type: 'image';
|
|
106
|
+
allowExternalUrl?: boolean;
|
|
107
|
+
defaultValue?: {
|
|
108
|
+
asset?: {
|
|
109
|
+
_ref: string;
|
|
110
|
+
};
|
|
111
|
+
url?: string;
|
|
112
|
+
alt?: string;
|
|
113
|
+
} | string;
|
|
114
|
+
}
|
|
115
|
+
export interface RichTextField extends BaseCMSField {
|
|
116
|
+
type: 'richtext';
|
|
117
|
+
defaultValue?: Record<string, unknown>[];
|
|
118
|
+
}
|
|
119
|
+
export interface IconCMSField extends BaseCMSField {
|
|
120
|
+
type: 'icon';
|
|
121
|
+
defaultValue?: string;
|
|
122
|
+
}
|
|
123
|
+
export interface LinkCMSField extends BaseCMSField {
|
|
124
|
+
type: 'link';
|
|
125
|
+
defaultValue?: {
|
|
126
|
+
href: string;
|
|
127
|
+
label?: string;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export type CMSSchemaField = TextCMSField | NumberCMSField | CheckboxCMSField | SelectCMSField | MultiSelectCMSField | GroupCMSField | ArrayCMSField | TextArrayCMSField | NumberArrayCMSField | ImageCMSField | IconCMSField | LinkCMSField | RichTextField;
|
|
131
|
+
export interface CMSSchemaMeta {
|
|
132
|
+
title: string;
|
|
133
|
+
subtitle?: string;
|
|
134
|
+
}
|
|
135
|
+
export interface CMSSchema {
|
|
136
|
+
name: string;
|
|
137
|
+
meta: CMSSchemaMeta;
|
|
138
|
+
fields: Record<string, CMSSchemaField>;
|
|
139
|
+
omit?: boolean;
|
|
140
|
+
__deprecated?: Record<string, CMSSchemaField>;
|
|
141
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CMSSchema.js';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CompositeTokenLeafValue, TokenFamilySchema } from './tokens/TokenSchemas.types.js';
|
|
2
|
+
import type { CoreTokenFamilies } from './tokens/coreTokenFamilies.types.js';
|
|
3
|
+
import type { DesignOpConfigBase } from './ops/ops.types.js';
|
|
4
|
+
export type TokenValue = string | Record<string, CompositeTokenLeafValue>;
|
|
5
|
+
export interface TokenRegistryRuntime<TTokens extends Record<string, Record<string, TokenValue>>> {
|
|
6
|
+
readonly TOKENS: TTokens;
|
|
7
|
+
readonly TOKEN_FAMILIES: {
|
|
8
|
+
[family: string]: {
|
|
9
|
+
description: string;
|
|
10
|
+
semanticType: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface RuntimeDesignSystemSnapshot<TFamily extends string = string, TOp extends string = string> {
|
|
15
|
+
readonly tokenFamilies: Record<TFamily, readonly string[]>;
|
|
16
|
+
readonly ops: readonly TOp[];
|
|
17
|
+
getTokensForFamily(family: TFamily): readonly string[];
|
|
18
|
+
getTokensForOp(op: TOp): readonly string[];
|
|
19
|
+
resolve(op: TOp, value: string | number): string;
|
|
20
|
+
}
|
|
21
|
+
type FamilyName<TRegistry extends Record<string, Record<string, TokenValue>>, TCore extends CoreTokenFamilies> = (keyof TRegistry & string) | (keyof TCore & string);
|
|
22
|
+
export interface DesignSystemWiring<TRegistryTokens extends Record<string, Record<string, TokenValue>>, TCore extends CoreTokenFamilies, TOpConfig extends Record<string, DesignOpConfigBase<string>>> {
|
|
23
|
+
readonly registry: TokenRegistryRuntime<TRegistryTokens>;
|
|
24
|
+
readonly coreFamilies: TCore;
|
|
25
|
+
readonly tokenSchemas: readonly TokenFamilySchema[];
|
|
26
|
+
readonly opConfig: TOpConfig;
|
|
27
|
+
}
|
|
28
|
+
export interface FullDesignSystemSnapshot<TRegistryTokens extends Record<string, Record<string, TokenValue>>, TCore extends CoreTokenFamilies, TOpConfig extends Record<string, DesignOpConfigBase<string>>> extends RuntimeDesignSystemSnapshot<FamilyName<TRegistryTokens, TCore>, keyof TOpConfig & string> {
|
|
29
|
+
readonly tokenSchemasMeta: TokenRegistryRuntime<TRegistryTokens>['TOKEN_FAMILIES'];
|
|
30
|
+
readonly opConfig: TOpConfig;
|
|
31
|
+
readonly tokenSchemasRaw: readonly TokenFamilySchema[];
|
|
32
|
+
}
|
|
33
|
+
export declare function createDesignSystemSnapshot<TRegistryTokens extends Record<string, Record<string, TokenValue>>, TCore extends CoreTokenFamilies, TOpConfig extends Record<string, DesignOpConfigBase<string>>>(wiring: DesignSystemWiring<TRegistryTokens, TCore, TOpConfig>): FullDesignSystemSnapshot<TRegistryTokens, TCore, TOpConfig>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { resolveOp } from './resolvers/ds.resolvers.js';
|
|
2
|
+
function buildTokenFamiliesMap(registry, coreFamilies) {
|
|
3
|
+
const result = {};
|
|
4
|
+
for (const family of Object.keys(registry.TOKENS)) {
|
|
5
|
+
const record = registry.TOKENS[family];
|
|
6
|
+
result[family] = Object.keys(record);
|
|
7
|
+
}
|
|
8
|
+
for (const family of Object.keys(coreFamilies)) {
|
|
9
|
+
const values = coreFamilies[family];
|
|
10
|
+
result[family] = values.map((v) => String(v));
|
|
11
|
+
}
|
|
12
|
+
return result;
|
|
13
|
+
}
|
|
14
|
+
export function createDesignSystemSnapshot(wiring) {
|
|
15
|
+
const { registry, coreFamilies, tokenSchemas, opConfig } = wiring;
|
|
16
|
+
const tokenFamiliesMap = buildTokenFamiliesMap(registry, coreFamilies);
|
|
17
|
+
const ops = Object.keys(opConfig);
|
|
18
|
+
const snapshot = {
|
|
19
|
+
tokenFamilies: tokenFamiliesMap,
|
|
20
|
+
tokenSchemasMeta: registry.TOKEN_FAMILIES,
|
|
21
|
+
tokenSchemasRaw: tokenSchemas,
|
|
22
|
+
ops,
|
|
23
|
+
opConfig,
|
|
24
|
+
getTokensForFamily(family) {
|
|
25
|
+
return tokenFamiliesMap[family] ?? [];
|
|
26
|
+
},
|
|
27
|
+
getTokensForOp(op) {
|
|
28
|
+
const config = opConfig[op];
|
|
29
|
+
if (!config)
|
|
30
|
+
return [];
|
|
31
|
+
return this.getTokensForFamily(config.tokenFamily);
|
|
32
|
+
},
|
|
33
|
+
resolve(op, value) {
|
|
34
|
+
return resolveOp(opConfig, op, value);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
return snapshot;
|
|
38
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type FullDesignSystemSnapshot } from './DesignSystemSnapshotFactory.js';
|
|
2
|
+
import type { CompositeTokenLeafValue, TokenFamilySchema } from './tokens/TokenSchemas.types.js';
|
|
3
|
+
import type { DesignOpConfigBase } from './ops/ops.types.js';
|
|
4
|
+
import type { CoreTokenFamilies } from './tokens/coreTokenFamilies.types.js';
|
|
5
|
+
export type TokenValue = string | Record<string, CompositeTokenLeafValue>;
|
|
6
|
+
export type ProjectTokenRegistryTokens = Record<string, Record<string, TokenValue>>;
|
|
7
|
+
export interface ProjectTokenRegistryConfig<TTokens extends ProjectTokenRegistryTokens, TFamilies extends Record<string, {
|
|
8
|
+
description: string;
|
|
9
|
+
semanticType: string;
|
|
10
|
+
}>, TCore extends CoreTokenFamilies, TOpConfig extends Record<string, DesignOpConfigBase<string>>> {
|
|
11
|
+
readonly TOKENS: TTokens;
|
|
12
|
+
readonly TOKEN_FAMILIES: TFamilies;
|
|
13
|
+
readonly TOKEN_SCHEMAS: readonly TokenFamilySchema[];
|
|
14
|
+
readonly CORE_TOKEN_FAMILIES: TCore;
|
|
15
|
+
readonly OP_CONFIG: TOpConfig;
|
|
16
|
+
}
|
|
17
|
+
export type DesignOp<TOpConfig extends Record<string, DesignOpConfigBase<string>>> = keyof TOpConfig & string;
|
|
18
|
+
export interface BaseDesignSystemApi<TTokens extends ProjectTokenRegistryTokens, TFamilies extends Record<string, {
|
|
19
|
+
description: string;
|
|
20
|
+
semanticType: string;
|
|
21
|
+
}>, TCore extends CoreTokenFamilies, TOpConfig extends Record<string, DesignOpConfigBase<string>>> {
|
|
22
|
+
readonly ops: readonly DesignOp<TOpConfig>[];
|
|
23
|
+
readonly opConfig: TOpConfig;
|
|
24
|
+
readonly tokenSchemas: readonly TokenFamilySchema[];
|
|
25
|
+
readonly coreFamilies: TCore;
|
|
26
|
+
readonly registryTokens: TTokens;
|
|
27
|
+
readonly registryFamilies: TFamilies;
|
|
28
|
+
resolve(op: DesignOp<TOpConfig>, value: string | number): string;
|
|
29
|
+
getTokensForFamily(family: string): readonly string[];
|
|
30
|
+
getTokensForOp(op: DesignOp<TOpConfig>): readonly string[];
|
|
31
|
+
}
|
|
32
|
+
export declare function createProjectDesignSystem<TTokens extends ProjectTokenRegistryTokens, TFamilies extends Record<string, {
|
|
33
|
+
description: string;
|
|
34
|
+
semanticType: string;
|
|
35
|
+
}>, TCore extends CoreTokenFamilies, TOpConfig extends Record<string, DesignOpConfigBase<string>>>(config: ProjectTokenRegistryConfig<TTokens, TFamilies, TCore, TOpConfig>): {
|
|
36
|
+
readonly DESIGN_SYSTEM_SNAPSHOT: FullDesignSystemSnapshot<TTokens, TCore, TOpConfig>;
|
|
37
|
+
readonly DesignSystem: BaseDesignSystemApi<TTokens, TFamilies, TCore, TOpConfig>;
|
|
38
|
+
};
|
|
39
|
+
export type { FullDesignSystemSnapshot };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createDesignSystemSnapshot } from './DesignSystemSnapshotFactory.js';
|
|
2
|
+
export function createProjectDesignSystem(config) {
|
|
3
|
+
const wiring = {
|
|
4
|
+
registry: {
|
|
5
|
+
TOKENS: config.TOKENS,
|
|
6
|
+
TOKEN_FAMILIES: config.TOKEN_FAMILIES,
|
|
7
|
+
},
|
|
8
|
+
coreFamilies: config.CORE_TOKEN_FAMILIES,
|
|
9
|
+
tokenSchemas: config.TOKEN_SCHEMAS,
|
|
10
|
+
opConfig: config.OP_CONFIG,
|
|
11
|
+
};
|
|
12
|
+
const snapshot = createDesignSystemSnapshot(wiring);
|
|
13
|
+
const ops = Object.keys(config.OP_CONFIG);
|
|
14
|
+
const DesignSystem = {
|
|
15
|
+
ops,
|
|
16
|
+
opConfig: config.OP_CONFIG,
|
|
17
|
+
tokenSchemas: config.TOKEN_SCHEMAS,
|
|
18
|
+
coreFamilies: config.CORE_TOKEN_FAMILIES,
|
|
19
|
+
registryTokens: config.TOKENS,
|
|
20
|
+
registryFamilies: config.TOKEN_FAMILIES,
|
|
21
|
+
getTokensForFamily(family) {
|
|
22
|
+
return snapshot.getTokensForFamily(family);
|
|
23
|
+
},
|
|
24
|
+
getTokensForOp(op) {
|
|
25
|
+
return snapshot.getTokensForOp(op);
|
|
26
|
+
},
|
|
27
|
+
resolve(op, value) {
|
|
28
|
+
return snapshot.resolve(op, value);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
return { DESIGN_SYSTEM_SNAPSHOT: snapshot, DesignSystem };
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './DesignSystemSnapshotFactory.js';
|
|
2
|
+
export { createProjectDesignSystem, } from './ProjectDesignSystemFactory.js';
|
|
3
|
+
export type { BaseDesignSystemApi, DesignOp, FullDesignSystemSnapshot, ProjectTokenRegistryConfig, ProjectTokenRegistryTokens, } from './ProjectDesignSystemFactory.js';
|
|
4
|
+
export * from './ops/ops.types.js';
|
|
5
|
+
export * from './tokens/TokenSchemas.types.js';
|
|
6
|
+
export * from './tokens/coreTokenFamilies.types.js';
|
|
7
|
+
export * from './resolvers/ds.resolvers.js';
|
|
8
|
+
export * from './resolvers/ds.responsive.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './DesignSystemSnapshotFactory.js';
|
|
2
|
+
export { createProjectDesignSystem, } from './ProjectDesignSystemFactory.js';
|
|
3
|
+
export * from './ops/ops.types.js';
|
|
4
|
+
export * from './tokens/TokenSchemas.types.js';
|
|
5
|
+
export * from './tokens/coreTokenFamilies.types.js';
|
|
6
|
+
export * from './resolvers/ds.resolvers.js';
|
|
7
|
+
export * from './resolvers/ds.responsive.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CoreTokenFamilyName } from '../tokens/coreTokenFamilies.types.js';
|
|
2
|
+
export type AuthoringEffectKind = 'element' | 'text' | 'text-style' | 'title-style' | 'text-alignment' | 'divide' | 'divide-x' | 'divide-y' | 'margin' | 'margin-top' | 'margin-right' | 'margin-bottom' | 'margin-left' | 'margin-x' | 'margin-y' | 'padding' | 'padding-top' | 'padding-right' | 'padding-bottom' | 'padding-left' | 'padding-x' | 'padding-y' | 'gap' | 'gap-x' | 'gap-y' | 'background' | 'color' | 'border' | 'border-top' | 'border-right' | 'border-bottom' | 'border-left' | 'ring' | 'shadow' | 'radius' | 'radius-top' | 'radius-right' | 'radius-bottom' | 'radius-left' | 'width' | 'height' | 'min-width' | 'min-height' | 'max-width' | 'max-height' | 'alignment';
|
|
3
|
+
export type TokenFamilyName = CoreTokenFamilyName | string;
|
|
4
|
+
export type NoneBehavior = 'empty' | 'passThrough';
|
|
5
|
+
export interface NumberAuthoringValueSpec {
|
|
6
|
+
kind: 'number';
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
9
|
+
step?: number;
|
|
10
|
+
}
|
|
11
|
+
export type DesignOpAuthoringValue = NumberAuthoringValueSpec;
|
|
12
|
+
export interface DesignOpConfigBase<TFamily extends string = TokenFamilyName, TDelegateField extends string = string, TDelegateOp extends string = string> {
|
|
13
|
+
tokenFamily: TFamily;
|
|
14
|
+
authoringEffect?: AuthoringEffectKind;
|
|
15
|
+
authoringValue?: DesignOpAuthoringValue;
|
|
16
|
+
responsive?: boolean;
|
|
17
|
+
addNoneasOmit?: boolean;
|
|
18
|
+
resolve?: (value: string) => string;
|
|
19
|
+
useAlias?: (value: string) => string;
|
|
20
|
+
private?: boolean;
|
|
21
|
+
delegate?: Partial<Record<TDelegateField, TDelegateOp>>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DesignOpConfigBase } from '../ops/ops.types.js';
|
|
2
|
+
export declare function normalizeNone<Op extends string>(opConfig: Record<Op, DesignOpConfigBase<string>>, op: Op, value: string | number): string;
|
|
3
|
+
export declare function resolveOp<Op extends string>(opConfig: Record<Op, DesignOpConfigBase<string>>, op: Op, value: string | number): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function normalizeNone(opConfig, op, value) {
|
|
2
|
+
if (value !== 'none')
|
|
3
|
+
return String(value);
|
|
4
|
+
const cfg = opConfig[op];
|
|
5
|
+
return cfg?.addNoneasOmit === true ? '' : value;
|
|
6
|
+
}
|
|
7
|
+
export function resolveOp(opConfig, op, value) {
|
|
8
|
+
const normalized = normalizeNone(opConfig, op, value);
|
|
9
|
+
if (normalized.length === 0)
|
|
10
|
+
return '';
|
|
11
|
+
const cfg = opConfig[op];
|
|
12
|
+
if (!cfg || typeof cfg.resolve !== 'function')
|
|
13
|
+
return '';
|
|
14
|
+
try {
|
|
15
|
+
return cfg.resolve(normalized) ?? '';
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error instanceof Error)
|
|
19
|
+
console.log(error.message);
|
|
20
|
+
else
|
|
21
|
+
console.log('An unknown error occurred');
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type BreakpointOrder = readonly string[];
|
|
2
|
+
export type ResponsiveOverrides<TokenKey extends string> = Readonly<Record<string, TokenKey | undefined>>;
|
|
3
|
+
export type TokenToClassResolver<TOp extends string, TokenKey extends string> = (op: TOp, token: TokenKey) => string;
|
|
4
|
+
export declare function prefixClasses(prefix: string, classString: string): string;
|
|
5
|
+
export declare function cx(...parts: Array<string | false | null | undefined>): string;
|
|
6
|
+
export declare function buildResponsiveClassString<TOp extends string, TokenKey extends string>(args: {
|
|
7
|
+
readonly op: TOp;
|
|
8
|
+
readonly baseToken: TokenKey;
|
|
9
|
+
readonly breakpointOrder: BreakpointOrder;
|
|
10
|
+
readonly overrides: ResponsiveOverrides<TokenKey>;
|
|
11
|
+
readonly resolveTokenToClasses: TokenToClassResolver<TOp, TokenKey>;
|
|
12
|
+
}): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function prefixClasses(prefix, classString) {
|
|
2
|
+
const trimmed = classString.trim();
|
|
3
|
+
if (trimmed.length === 0)
|
|
4
|
+
return '';
|
|
5
|
+
const parts = trimmed.split(/\s+/).filter((p) => p.length > 0);
|
|
6
|
+
return parts.map((p) => `${prefix}:${p}`).join(' ');
|
|
7
|
+
}
|
|
8
|
+
export function cx(...parts) {
|
|
9
|
+
return parts.filter((p) => typeof p === 'string' && p.length > 0).join(' ');
|
|
10
|
+
}
|
|
11
|
+
export function buildResponsiveClassString(args) {
|
|
12
|
+
const base = args.resolveTokenToClasses(args.op, args.baseToken) ?? '';
|
|
13
|
+
const overrideKeys = Object.keys(args.overrides);
|
|
14
|
+
if (overrideKeys.length === 0) {
|
|
15
|
+
return base;
|
|
16
|
+
}
|
|
17
|
+
const responsiveParts = [];
|
|
18
|
+
for (const bp of args.breakpointOrder) {
|
|
19
|
+
const tokenAtBp = args.overrides[bp];
|
|
20
|
+
if (!tokenAtBp)
|
|
21
|
+
continue;
|
|
22
|
+
const resolved = args.resolveTokenToClasses(args.op, tokenAtBp) ?? '';
|
|
23
|
+
if (resolved.trim().length === 0)
|
|
24
|
+
continue;
|
|
25
|
+
responsiveParts.push(prefixClasses(bp, resolved));
|
|
26
|
+
}
|
|
27
|
+
return cx(base, ...responsiveParts);
|
|
28
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type TokenSemanticType = 'css-color' | 'rem' | 'number' | 'string' | 'aspect-ratio' | 'px' | 'em' | 'composite';
|
|
2
|
+
export type TokenOrderMode = {
|
|
3
|
+
type: 'custom';
|
|
4
|
+
} | {
|
|
5
|
+
type: 'alpha';
|
|
6
|
+
direction?: 'asc' | 'desc';
|
|
7
|
+
} | {
|
|
8
|
+
type: 'numeric';
|
|
9
|
+
direction?: 'asc' | 'desc';
|
|
10
|
+
};
|
|
11
|
+
export type CompositeTokenOrderMode = {
|
|
12
|
+
type: 'custom';
|
|
13
|
+
} | {
|
|
14
|
+
type: 'alpha';
|
|
15
|
+
direction?: 'asc' | 'desc';
|
|
16
|
+
};
|
|
17
|
+
export type CompositeTokenField<Key extends string = string, Op extends string = string> = {
|
|
18
|
+
readonly key: Key;
|
|
19
|
+
readonly op: Op;
|
|
20
|
+
readonly description?: string;
|
|
21
|
+
};
|
|
22
|
+
export interface TokenFamilySchemaBase<Name extends string = string, Order extends TokenOrderMode = TokenOrderMode> {
|
|
23
|
+
readonly name: Name;
|
|
24
|
+
readonly description: string;
|
|
25
|
+
readonly responsive?: boolean;
|
|
26
|
+
readonly editorVisible?: boolean;
|
|
27
|
+
readonly tokenDescriptions?: boolean;
|
|
28
|
+
readonly order: Order;
|
|
29
|
+
readonly semanticType: TokenSemanticType;
|
|
30
|
+
}
|
|
31
|
+
export interface PrimitiveTokenFamilySchema<Name extends string = string> extends TokenFamilySchemaBase<Name, TokenOrderMode> {
|
|
32
|
+
readonly semanticType: Exclude<TokenSemanticType, 'composite'>;
|
|
33
|
+
readonly initialTokens?: Record<string, string>;
|
|
34
|
+
readonly toCssVarName: (tokenKey: string) => string | null;
|
|
35
|
+
readonly toCssVarAliases?: (tokenKey: string, cssVarName: string) => readonly string[];
|
|
36
|
+
readonly toCssVarValue: (tokenKey: string, tokenValue: string) => string;
|
|
37
|
+
}
|
|
38
|
+
export type CompositeFieldKeys<Fields extends readonly CompositeTokenField[]> = Fields[number]['key'] & string;
|
|
39
|
+
export type CompositeTokenLeafValue = string | number;
|
|
40
|
+
export type CompositeTokenValue<Fields extends readonly CompositeTokenField[]> = Partial<Record<CompositeFieldKeys<Fields>, CompositeTokenLeafValue>>;
|
|
41
|
+
export interface CompositeTokenFamilySchema<Name extends string = string, Fields extends readonly CompositeTokenField[] = readonly CompositeTokenField[]> extends TokenFamilySchemaBase<Name, CompositeTokenOrderMode> {
|
|
42
|
+
readonly semanticType: 'composite';
|
|
43
|
+
readonly fields: Fields;
|
|
44
|
+
readonly defaults?: Partial<Record<CompositeFieldKeys<Fields>, CompositeTokenLeafValue>>;
|
|
45
|
+
readonly initialTokens?: Record<string, CompositeTokenValue<Fields>>;
|
|
46
|
+
}
|
|
47
|
+
export type TokenFamilySchema<Name extends string = string> = PrimitiveTokenFamilySchema<Name> | CompositeTokenFamilySchema<Name, readonly CompositeTokenField[]>;
|
|
48
|
+
export declare function defineTokenFamilySchema<const T extends TokenFamilySchema>(schema: T): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './design-system/index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './design-system/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './layoutRuntime.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './layoutRuntime.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LayoutBindingValue, LayoutProps, LayoutVariantRegistry, RootLayoutBinding } from '../types/layout.types.js';
|
|
2
|
+
export interface LayoutRuntimeContext {
|
|
3
|
+
layout: LayoutProps;
|
|
4
|
+
variants: LayoutVariantRegistry;
|
|
5
|
+
}
|
|
6
|
+
export type LayoutSource = LayoutProps | RootLayoutBinding | null | undefined;
|
|
7
|
+
export declare function resolveRootLayoutProps(binding: RootLayoutBinding | null | undefined, registry: LayoutVariantRegistry): LayoutProps;
|
|
8
|
+
export declare function normaliseLayoutSource(source: LayoutSource, registry: LayoutVariantRegistry): LayoutProps;
|
|
9
|
+
export declare function makeLayoutRuntimeContext(layout: LayoutSource, variants: LayoutVariantRegistry | null | undefined): LayoutRuntimeContext;
|
|
10
|
+
export declare function resolveLayoutBinding(binding: LayoutBindingValue, registry: LayoutVariantRegistry): Record<string, unknown> | null;
|
|
11
|
+
export declare function getLayoutField(ctx: LayoutRuntimeContext, field: string): unknown;
|
|
12
|
+
export declare function getWrapperProps<TProps extends Record<string, unknown>>(ctx: LayoutRuntimeContext, field: string, wrapperName: string): TProps | null;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
function isRootLayoutBinding(value) {
|
|
2
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
const candidate = value;
|
|
6
|
+
if (typeof candidate.kind !== 'string' || typeof candidate.name !== 'string') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const hasProps = candidate.props !== undefined;
|
|
10
|
+
const hasVariant = typeof candidate.variant === 'string';
|
|
11
|
+
if (!hasProps && !hasVariant) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
export function resolveRootLayoutProps(binding, registry) {
|
|
17
|
+
if (!binding) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
if ('props' in binding && binding.props && typeof binding.props === 'object') {
|
|
21
|
+
return binding.props;
|
|
22
|
+
}
|
|
23
|
+
const hasVariant = 'variant' in binding && typeof binding.variant === 'string';
|
|
24
|
+
if (!hasVariant) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
const match = registry.find((record) => record.key.kind === binding.kind && record.key.name === binding.name && record.key.variant === binding.variant);
|
|
28
|
+
if (!match) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
return match.props;
|
|
32
|
+
}
|
|
33
|
+
export function normaliseLayoutSource(source, registry) {
|
|
34
|
+
if (!source) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
if (isRootLayoutBinding(source)) {
|
|
38
|
+
return resolveRootLayoutProps(source, registry);
|
|
39
|
+
}
|
|
40
|
+
return source;
|
|
41
|
+
}
|
|
42
|
+
export function makeLayoutRuntimeContext(layout, variants) {
|
|
43
|
+
const safeVariants = Array.isArray(variants) ? variants : [];
|
|
44
|
+
const safeLayout = normaliseLayoutSource(layout, safeVariants);
|
|
45
|
+
return {
|
|
46
|
+
layout: safeLayout,
|
|
47
|
+
variants: safeVariants,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function resolveLayoutBinding(binding, registry) {
|
|
51
|
+
if ('props' in binding && binding.props) {
|
|
52
|
+
return binding.props;
|
|
53
|
+
}
|
|
54
|
+
const { kind, name } = binding;
|
|
55
|
+
const variant = binding.variant;
|
|
56
|
+
if (typeof variant !== 'string' || variant.length === 0) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const match = registry.find((record) => record.key.kind === kind && record.key.name === name && record.key.variant === variant);
|
|
60
|
+
return match?.props ?? null;
|
|
61
|
+
}
|
|
62
|
+
export function getLayoutField(ctx, field) {
|
|
63
|
+
const raw = ctx.layout[field];
|
|
64
|
+
if (typeof raw !== 'object' || raw === null) {
|
|
65
|
+
return raw;
|
|
66
|
+
}
|
|
67
|
+
const maybeBinding = raw;
|
|
68
|
+
if (typeof maybeBinding.kind !== 'string' || typeof maybeBinding.name !== 'string') {
|
|
69
|
+
return raw;
|
|
70
|
+
}
|
|
71
|
+
const resolved = resolveLayoutBinding(maybeBinding, ctx.variants);
|
|
72
|
+
return resolved ?? raw;
|
|
73
|
+
}
|
|
74
|
+
export function getWrapperProps(ctx, field, wrapperName) {
|
|
75
|
+
const raw = ctx.layout[field];
|
|
76
|
+
if (typeof raw !== 'object' || raw === null) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const maybeBinding = raw;
|
|
80
|
+
if (maybeBinding.kind !== 'wrapper' || maybeBinding.name !== wrapperName) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const resolved = resolveLayoutBinding(maybeBinding, ctx.variants);
|
|
84
|
+
if (!resolved) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return resolved;
|
|
88
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export type BindingEditorPolicyVariants = 'primary' | 'optional' | 'none';
|
|
3
|
+
export type BindingEditorPolicy = {
|
|
4
|
+
variants: BindingEditorPolicyVariants;
|
|
5
|
+
};
|
|
6
|
+
export declare function annotateBindingEditorPolicy<TSchema extends z.ZodTypeAny>(schema: TSchema, policy: BindingEditorPolicy): TSchema;
|
|
7
|
+
export declare function getBindingEditorPolicy(schema: unknown): BindingEditorPolicy | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const LAYOUT_BINDING_EDITOR_POLICY_META_KEY = Symbol.for('devtool-runtime:layout-binding-editor-policy');
|
|
2
|
+
export function annotateBindingEditorPolicy(schema, policy) {
|
|
3
|
+
const maybeDef = schema._def;
|
|
4
|
+
if (maybeDef) {
|
|
5
|
+
maybeDef[LAYOUT_BINDING_EDITOR_POLICY_META_KEY] = policy;
|
|
6
|
+
}
|
|
7
|
+
return schema;
|
|
8
|
+
}
|
|
9
|
+
export function getBindingEditorPolicy(schema) {
|
|
10
|
+
if (!schema || typeof schema !== 'object')
|
|
11
|
+
return null;
|
|
12
|
+
const def = schema._def;
|
|
13
|
+
if (!def)
|
|
14
|
+
return null;
|
|
15
|
+
const policy = def[LAYOUT_BINDING_EDITOR_POLICY_META_KEY];
|
|
16
|
+
if (!policy || typeof policy !== 'object')
|
|
17
|
+
return null;
|
|
18
|
+
return policy;
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
export type BindingEditorSectionKey = 'general' | 'margin' | 'backgroundBorder' | 'widthAlignment' | 'spacing' | 'typography' | 'images' | 'buttons' | 'grid' | 'effects' | 'position' | 'dividers';
|
|
3
|
+
export type BindingEditorSection = {
|
|
4
|
+
section: BindingEditorSectionKey;
|
|
5
|
+
};
|
|
6
|
+
export declare function annotateBindingEditorSection<TSchema extends z.ZodTypeAny>(schema: TSchema, section: BindingEditorSection): TSchema;
|
|
7
|
+
export declare function getBindingEditorSection(schema: unknown): BindingEditorSection | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const LAYOUT_BINDING_EDITOR_SECTION_META_KEY = Symbol.for('devtool-runtime:layout-binding-editor-section');
|
|
2
|
+
export function annotateBindingEditorSection(schema, section) {
|
|
3
|
+
const maybeDef = schema._def;
|
|
4
|
+
if (maybeDef) {
|
|
5
|
+
maybeDef[LAYOUT_BINDING_EDITOR_SECTION_META_KEY] = section;
|
|
6
|
+
}
|
|
7
|
+
return schema;
|
|
8
|
+
}
|
|
9
|
+
export function getBindingEditorSection(schema) {
|
|
10
|
+
if (!schema || typeof schema !== 'object')
|
|
11
|
+
return null;
|
|
12
|
+
const def = schema._def;
|
|
13
|
+
if (!def)
|
|
14
|
+
return null;
|
|
15
|
+
const section = def[LAYOUT_BINDING_EDITOR_SECTION_META_KEY];
|
|
16
|
+
if (!section || typeof section !== 'object')
|
|
17
|
+
return null;
|
|
18
|
+
return section;
|
|
19
|
+
}
|