@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,54 @@
|
|
|
1
|
+
import type { BindingEditorPolicy } from './LayoutBindingEditorPolicyMetadata.js';
|
|
2
|
+
import type { BindingEditorSection } from './LayoutBindingEditorSectionMetadata.js';
|
|
3
|
+
import type { LayoutFieldUiMeta } from './LayoutFieldUiMetadata.js';
|
|
4
|
+
export type LayoutFieldAuthoringNumberValue = {
|
|
5
|
+
kind: 'number';
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
};
|
|
10
|
+
export type LayoutFieldAuthoringMeta = {
|
|
11
|
+
sourceKind: 'coreToken';
|
|
12
|
+
ops: string[];
|
|
13
|
+
surface: 'css' | 'responsive';
|
|
14
|
+
} | {
|
|
15
|
+
sourceKind: 'declaredToken';
|
|
16
|
+
designOp?: string;
|
|
17
|
+
tokenFamily?: string;
|
|
18
|
+
} | {
|
|
19
|
+
sourceKind: 'enum';
|
|
20
|
+
} | {
|
|
21
|
+
sourceKind: 'boolean';
|
|
22
|
+
} | {
|
|
23
|
+
sourceKind: 'valueBoolean';
|
|
24
|
+
} | {
|
|
25
|
+
sourceKind: 'valueString';
|
|
26
|
+
} | {
|
|
27
|
+
sourceKind: 'valueNumber';
|
|
28
|
+
designOp?: string;
|
|
29
|
+
tokenFamily?: string;
|
|
30
|
+
surface?: 'css' | 'responsive';
|
|
31
|
+
authoringValue?: LayoutFieldAuthoringNumberValue;
|
|
32
|
+
} | {
|
|
33
|
+
sourceKind: 'valueEnum';
|
|
34
|
+
designOp?: string;
|
|
35
|
+
tokenFamily?: string;
|
|
36
|
+
} | {
|
|
37
|
+
sourceKind: 'wrapper';
|
|
38
|
+
} | {
|
|
39
|
+
sourceKind: 'style';
|
|
40
|
+
};
|
|
41
|
+
export type LayoutFieldDefinitionMeta = {
|
|
42
|
+
ui?: LayoutFieldUiMeta;
|
|
43
|
+
authoring?: LayoutFieldAuthoringMeta;
|
|
44
|
+
};
|
|
45
|
+
export type LayoutBindingDefinitionMeta = {
|
|
46
|
+
editorPolicy?: BindingEditorPolicy;
|
|
47
|
+
editorSection?: BindingEditorSection;
|
|
48
|
+
collapsible?: boolean;
|
|
49
|
+
collapsed?: boolean;
|
|
50
|
+
};
|
|
51
|
+
export type LayoutDefinitionMeta = {
|
|
52
|
+
binding?: LayoutBindingDefinitionMeta;
|
|
53
|
+
fields?: Record<string, LayoutFieldDefinitionMeta>;
|
|
54
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AuthoringEffectKind } from '../authoring/index.js';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
export type LayoutFieldIntentSourceKind = 'coreToken' | 'declaredToken' | 'enum' | 'boolean' | 'valueBoolean' | 'valueString' | 'valueNumber' | 'valueEnum' | 'wrapper' | 'style';
|
|
4
|
+
export type LayoutFieldIntent = {
|
|
5
|
+
sourceKind: LayoutFieldIntentSourceKind;
|
|
6
|
+
ops?: string[];
|
|
7
|
+
tokenFamily?: string;
|
|
8
|
+
designOp?: string;
|
|
9
|
+
surface?: 'css' | 'responsive';
|
|
10
|
+
effectKinds?: AuthoringEffectKind[];
|
|
11
|
+
authoringValue?: {
|
|
12
|
+
kind: 'number';
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
step?: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type LayoutFieldIntentMap = Record<string, LayoutFieldIntent>;
|
|
19
|
+
export declare function annotateLayoutFieldIntent<TSchema extends z.ZodTypeAny>(schema: TSchema, intent: LayoutFieldIntent): TSchema;
|
|
20
|
+
export declare function annotateLayoutFieldIntents<TSchema extends z.ZodTypeAny>(schema: TSchema, intents: LayoutFieldIntentMap): TSchema;
|
|
21
|
+
export declare function getLayoutFieldIntent(schema: unknown): LayoutFieldIntent | null;
|
|
22
|
+
export declare function getLayoutFieldIntents(schema: unknown): LayoutFieldIntentMap | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const LAYOUT_FIELD_INTENT_META_KEY = Symbol.for('devtool-runtime:layout-field-intent');
|
|
2
|
+
const LAYOUT_FIELD_INTENT_MAP_META_KEY = Symbol.for('devtool-runtime:layout-field-intent-map');
|
|
3
|
+
export function annotateLayoutFieldIntent(schema, intent) {
|
|
4
|
+
const maybeDef = schema._def;
|
|
5
|
+
if (maybeDef) {
|
|
6
|
+
maybeDef[LAYOUT_FIELD_INTENT_META_KEY] = intent;
|
|
7
|
+
}
|
|
8
|
+
return schema;
|
|
9
|
+
}
|
|
10
|
+
export function annotateLayoutFieldIntents(schema, intents) {
|
|
11
|
+
const maybeDef = schema._def;
|
|
12
|
+
if (maybeDef) {
|
|
13
|
+
maybeDef[LAYOUT_FIELD_INTENT_MAP_META_KEY] = intents;
|
|
14
|
+
}
|
|
15
|
+
return schema;
|
|
16
|
+
}
|
|
17
|
+
export function getLayoutFieldIntent(schema) {
|
|
18
|
+
if (!schema || typeof schema !== 'object')
|
|
19
|
+
return null;
|
|
20
|
+
const def = schema._def;
|
|
21
|
+
if (!def)
|
|
22
|
+
return null;
|
|
23
|
+
const intent = def[LAYOUT_FIELD_INTENT_META_KEY];
|
|
24
|
+
if (!intent || typeof intent !== 'object')
|
|
25
|
+
return null;
|
|
26
|
+
return intent;
|
|
27
|
+
}
|
|
28
|
+
export function getLayoutFieldIntents(schema) {
|
|
29
|
+
if (!schema || typeof schema !== 'object')
|
|
30
|
+
return null;
|
|
31
|
+
const def = schema._def;
|
|
32
|
+
if (!def)
|
|
33
|
+
return null;
|
|
34
|
+
const intents = def[LAYOUT_FIELD_INTENT_MAP_META_KEY];
|
|
35
|
+
if (!intents || typeof intents !== 'object')
|
|
36
|
+
return null;
|
|
37
|
+
return intents;
|
|
38
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { BindingEditorSectionKey } from './LayoutBindingEditorSectionMetadata.js';
|
|
3
|
+
export type LayoutFieldUiPrimitive = string | number | boolean;
|
|
4
|
+
export type LayoutFieldUiCondition = {
|
|
5
|
+
field: string;
|
|
6
|
+
operator: 'truthy';
|
|
7
|
+
} | {
|
|
8
|
+
field: string;
|
|
9
|
+
operator: 'falsy';
|
|
10
|
+
} | {
|
|
11
|
+
field: string;
|
|
12
|
+
operator: 'equals';
|
|
13
|
+
value: LayoutFieldUiPrimitive;
|
|
14
|
+
} | {
|
|
15
|
+
field: string;
|
|
16
|
+
operator: 'notEquals';
|
|
17
|
+
value: LayoutFieldUiPrimitive;
|
|
18
|
+
} | {
|
|
19
|
+
field: string;
|
|
20
|
+
operator: 'in';
|
|
21
|
+
value: LayoutFieldUiPrimitive[];
|
|
22
|
+
};
|
|
23
|
+
export type LayoutFieldUiMeta = {
|
|
24
|
+
label?: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
dependsOn?: LayoutFieldUiCondition[];
|
|
27
|
+
section?: BindingEditorSectionKey;
|
|
28
|
+
};
|
|
29
|
+
export declare function annotateLayoutFieldUiMeta<TSchema extends z.ZodTypeAny>(schema: TSchema, uiMeta: LayoutFieldUiMeta): TSchema;
|
|
30
|
+
export declare function getLayoutFieldUiMeta(schema: unknown): LayoutFieldUiMeta | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const LAYOUT_FIELD_UI_META_KEY = Symbol.for('devtool-runtime:layout-field-ui-meta');
|
|
2
|
+
export function annotateLayoutFieldUiMeta(schema, uiMeta) {
|
|
3
|
+
const maybeDef = schema._def;
|
|
4
|
+
if (maybeDef) {
|
|
5
|
+
maybeDef[LAYOUT_FIELD_UI_META_KEY] = uiMeta;
|
|
6
|
+
}
|
|
7
|
+
return schema;
|
|
8
|
+
}
|
|
9
|
+
export function getLayoutFieldUiMeta(schema) {
|
|
10
|
+
if (!schema || typeof schema !== 'object')
|
|
11
|
+
return null;
|
|
12
|
+
const def = schema._def;
|
|
13
|
+
if (!def)
|
|
14
|
+
return null;
|
|
15
|
+
const uiMeta = def[LAYOUT_FIELD_UI_META_KEY];
|
|
16
|
+
if (!uiMeta || typeof uiMeta !== 'object')
|
|
17
|
+
return null;
|
|
18
|
+
return uiMeta;
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { LayoutDefinitionMeta } from './LayoutDefinitionMeta.js';
|
|
3
|
+
export type LayoutClassOutput = string | string[];
|
|
4
|
+
export type OneArgResolver<TProps> = (layout: TProps) => LayoutClassOutput;
|
|
5
|
+
export type LayoutResolvers<TProps> = Record<string, OneArgResolver<TProps>>;
|
|
6
|
+
export type LayoutValue = boolean | number | string;
|
|
7
|
+
export type OneArgValueResolver<TProps, TValue extends LayoutValue = LayoutValue> = (layout: TProps) => TValue;
|
|
8
|
+
export type LayoutValues<TProps> = Record<string, OneArgValueResolver<TProps, LayoutValue>>;
|
|
9
|
+
export type InferLayoutProps<T> = T extends {
|
|
10
|
+
__propsBrand?: infer P;
|
|
11
|
+
} ? P : never;
|
|
12
|
+
type ResolveAllResult<TResolvers extends Record<string, unknown>> = {
|
|
13
|
+
[K in keyof TResolvers]: string[];
|
|
14
|
+
};
|
|
15
|
+
type ResolveValuesResult<TValues extends Record<string, (...args: any[]) => unknown>> = {
|
|
16
|
+
[K in keyof TValues]: ReturnType<TValues[K]>;
|
|
17
|
+
};
|
|
18
|
+
export declare function defineLayout<TSchema extends z.ZodTypeAny, TResolvers extends LayoutResolvers<z.infer<TSchema>>, TValues extends LayoutValues<z.infer<TSchema>>>(config: {
|
|
19
|
+
schema: TSchema;
|
|
20
|
+
resolvers: TResolvers;
|
|
21
|
+
values?: TValues;
|
|
22
|
+
meta?: LayoutDefinitionMeta;
|
|
23
|
+
}): {
|
|
24
|
+
schema: TSchema;
|
|
25
|
+
resolve: TResolvers;
|
|
26
|
+
resolveAll: (layout: z.infer<TSchema>) => ResolveAllResult<TResolvers>;
|
|
27
|
+
check: (layout: z.infer<TSchema>, opts?: {
|
|
28
|
+
strict?: boolean;
|
|
29
|
+
}) => {
|
|
30
|
+
issues: string[];
|
|
31
|
+
byKey: ResolveAllResult<TResolvers>;
|
|
32
|
+
};
|
|
33
|
+
values: TValues;
|
|
34
|
+
resolveValues: (layout: z.infer<TSchema>) => ResolveValuesResult<TValues>;
|
|
35
|
+
meta?: LayoutDefinitionMeta;
|
|
36
|
+
__propsBrand: z.infer<TSchema>;
|
|
37
|
+
};
|
|
38
|
+
export { useWrapper, getWrapperMeta, useStyle, getStyleMeta } from './LayoutVariantBindings.js';
|
|
39
|
+
export type { LayoutDefinitionMeta } from './LayoutDefinitionMeta.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function defineLayout(config) {
|
|
3
|
+
const { schema, resolvers, values, meta } = config;
|
|
4
|
+
function toArray(v) {
|
|
5
|
+
return (Array.isArray(v) ? v : [v]).map((s) => s.trim()).filter(Boolean);
|
|
6
|
+
}
|
|
7
|
+
function resolveAll(layout) {
|
|
8
|
+
const out = {};
|
|
9
|
+
for (const key in resolvers) {
|
|
10
|
+
const fn = resolvers[key];
|
|
11
|
+
out[key] = toArray(fn(layout));
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
function resolveValues(layout) {
|
|
16
|
+
if (!values) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
const out = {};
|
|
20
|
+
for (const key in values) {
|
|
21
|
+
const fn = values[key];
|
|
22
|
+
out[key] = fn(layout);
|
|
23
|
+
}
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
function check(layout, opts) {
|
|
27
|
+
const { strict = false } = opts ?? {};
|
|
28
|
+
const byKey = resolveAll(layout);
|
|
29
|
+
const issues = [];
|
|
30
|
+
for (const key in byKey) {
|
|
31
|
+
for (const cls of byKey[key]) {
|
|
32
|
+
if (strict && cls === '') {
|
|
33
|
+
issues.push(`Resolver "${String(key)}" produced an empty class (strict mode).`);
|
|
34
|
+
}
|
|
35
|
+
if (/\s{2,}/.test(cls)) {
|
|
36
|
+
issues.push(`Resolver "${String(key)}" produced extra whitespace: "${cls}"`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { issues, byKey };
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
schema,
|
|
44
|
+
resolve: resolvers,
|
|
45
|
+
resolveAll,
|
|
46
|
+
check,
|
|
47
|
+
values: (values ?? {}),
|
|
48
|
+
resolveValues,
|
|
49
|
+
...(meta ? { meta } : {}),
|
|
50
|
+
__propsBrand: null,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export { useWrapper, getWrapperMeta, useStyle, getStyleMeta } from './LayoutVariantBindings.js';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z, type ZodObject, type ZodRawShape, type ZodTypeAny } from 'zod';
|
|
2
|
+
import { type BindingEditorPolicy } from './LayoutBindingEditorPolicyMetadata.js';
|
|
3
|
+
import { type BindingEditorSection } from './LayoutBindingEditorSectionMetadata.js';
|
|
4
|
+
import type { LayoutDefinitionMeta } from './LayoutDefinitionMeta.js';
|
|
5
|
+
export interface WrapperMeta<TPropsSchema extends ZodTypeAny = ZodTypeAny> {
|
|
6
|
+
name: string;
|
|
7
|
+
propsSchema: TPropsSchema;
|
|
8
|
+
layoutMeta?: LayoutDefinitionMeta;
|
|
9
|
+
editorPolicy?: BindingEditorPolicy;
|
|
10
|
+
editorSection?: BindingEditorSection;
|
|
11
|
+
collapsible?: boolean;
|
|
12
|
+
collapsed?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface StyleMeta<TPropsSchema extends ZodTypeAny = ZodTypeAny> {
|
|
15
|
+
name: string;
|
|
16
|
+
propsSchema: TPropsSchema;
|
|
17
|
+
layoutMeta?: LayoutDefinitionMeta;
|
|
18
|
+
editorPolicy?: BindingEditorPolicy;
|
|
19
|
+
editorSection?: BindingEditorSection;
|
|
20
|
+
collapsible?: boolean;
|
|
21
|
+
collapsed?: boolean;
|
|
22
|
+
}
|
|
23
|
+
type LayoutDefinitionLike<TSchema extends ZodTypeAny> = {
|
|
24
|
+
schema: TSchema;
|
|
25
|
+
meta?: LayoutDefinitionMeta;
|
|
26
|
+
};
|
|
27
|
+
export type WrapperBindingSchema<TName extends string, TShape extends ZodRawShape> = z.ZodUnion<[
|
|
28
|
+
z.ZodObject<{
|
|
29
|
+
kind: z.ZodLiteral<'wrapper'>;
|
|
30
|
+
name: z.ZodLiteral<TName>;
|
|
31
|
+
props: ZodObject<TShape>;
|
|
32
|
+
}>,
|
|
33
|
+
z.ZodObject<{
|
|
34
|
+
kind: z.ZodLiteral<'wrapper'>;
|
|
35
|
+
name: z.ZodLiteral<TName>;
|
|
36
|
+
variant: z.ZodString;
|
|
37
|
+
}>
|
|
38
|
+
]>;
|
|
39
|
+
export type StyleBindingSchema<TName extends string, TSchema extends ZodTypeAny> = z.ZodUnion<[
|
|
40
|
+
z.ZodObject<{
|
|
41
|
+
kind: z.ZodLiteral<'style'>;
|
|
42
|
+
name: z.ZodLiteral<TName>;
|
|
43
|
+
props: TSchema;
|
|
44
|
+
}>,
|
|
45
|
+
z.ZodObject<{
|
|
46
|
+
kind: z.ZodLiteral<'style'>;
|
|
47
|
+
name: z.ZodLiteral<TName>;
|
|
48
|
+
variant: z.ZodString;
|
|
49
|
+
}>
|
|
50
|
+
]>;
|
|
51
|
+
export declare function useWrapper<TName extends string, TShape extends ZodRawShape>(wrapperName: TName, propsSchemaOrDefinition: ZodObject<TShape> | LayoutDefinitionLike<ZodObject<TShape>>): WrapperBindingSchema<TName, TShape>;
|
|
52
|
+
export declare function useStyle<TName extends string, TSchema extends ZodTypeAny>(styleName: TName, stylePropsSchemaOrDefinition: TSchema | LayoutDefinitionLike<TSchema>): StyleBindingSchema<TName, TSchema>;
|
|
53
|
+
export declare function getWrapperMeta(schema: unknown): WrapperMeta | null;
|
|
54
|
+
export declare function getStyleMeta(schema: unknown): StyleMeta | null;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { getBindingEditorPolicy } from './LayoutBindingEditorPolicyMetadata.js';
|
|
3
|
+
import { getBindingEditorSection } from './LayoutBindingEditorSectionMetadata.js';
|
|
4
|
+
const WRAPPER_META_KEY = Symbol.for('devtool-runtime:wrapper');
|
|
5
|
+
const STYLE_META_KEY = Symbol.for('devtool-runtime:style');
|
|
6
|
+
export function useWrapper(wrapperName, propsSchemaOrDefinition) {
|
|
7
|
+
let definition = null;
|
|
8
|
+
let propsSchema;
|
|
9
|
+
if (isLayoutDefinitionLike(propsSchemaOrDefinition)) {
|
|
10
|
+
definition = propsSchemaOrDefinition;
|
|
11
|
+
propsSchema = definition.schema;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
propsSchema = propsSchemaOrDefinition;
|
|
15
|
+
}
|
|
16
|
+
if (!/^[A-Za-z0-9_-]+$/.test(wrapperName)) {
|
|
17
|
+
throw new Error(`[useWrapper] Invalid wrapper name: "${wrapperName}"`);
|
|
18
|
+
}
|
|
19
|
+
const localBinding = z.object({
|
|
20
|
+
kind: z.literal('wrapper'),
|
|
21
|
+
name: z.literal(wrapperName),
|
|
22
|
+
props: propsSchema,
|
|
23
|
+
});
|
|
24
|
+
const variantBinding = z.object({
|
|
25
|
+
kind: z.literal('wrapper'),
|
|
26
|
+
name: z.literal(wrapperName),
|
|
27
|
+
variant: z.string(),
|
|
28
|
+
});
|
|
29
|
+
const bindingSchema = z.union([localBinding, variantBinding]);
|
|
30
|
+
const editorPolicy = definition?.meta?.binding?.editorPolicy ?? getBindingEditorPolicy(propsSchema) ?? undefined;
|
|
31
|
+
const editorSection = definition?.meta?.binding?.editorSection ?? getBindingEditorSection(propsSchema) ?? undefined;
|
|
32
|
+
const collapsible = definition?.meta?.binding?.collapsible;
|
|
33
|
+
const collapsed = collapsible === true ? definition?.meta?.binding?.collapsed : undefined;
|
|
34
|
+
const maybeDef = bindingSchema._def;
|
|
35
|
+
if (maybeDef) {
|
|
36
|
+
maybeDef[WRAPPER_META_KEY] = {
|
|
37
|
+
name: wrapperName,
|
|
38
|
+
propsSchema,
|
|
39
|
+
...(definition?.meta ? { layoutMeta: definition.meta } : {}),
|
|
40
|
+
...(editorPolicy ? { editorPolicy } : {}),
|
|
41
|
+
...(editorSection ? { editorSection } : {}),
|
|
42
|
+
...(collapsible !== undefined ? { collapsible } : {}),
|
|
43
|
+
...(collapsed !== undefined ? { collapsed } : {}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return bindingSchema;
|
|
47
|
+
}
|
|
48
|
+
export function useStyle(styleName, stylePropsSchemaOrDefinition) {
|
|
49
|
+
let definition = null;
|
|
50
|
+
let stylePropsSchema;
|
|
51
|
+
if (isLayoutDefinitionLike(stylePropsSchemaOrDefinition)) {
|
|
52
|
+
definition = stylePropsSchemaOrDefinition;
|
|
53
|
+
stylePropsSchema = definition.schema;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
stylePropsSchema = stylePropsSchemaOrDefinition;
|
|
57
|
+
}
|
|
58
|
+
const localBinding = z.object({
|
|
59
|
+
kind: z.literal('style'),
|
|
60
|
+
name: z.literal(styleName),
|
|
61
|
+
props: stylePropsSchema,
|
|
62
|
+
});
|
|
63
|
+
const variantBinding = z.object({
|
|
64
|
+
kind: z.literal('style'),
|
|
65
|
+
name: z.literal(styleName),
|
|
66
|
+
variant: z.string(),
|
|
67
|
+
});
|
|
68
|
+
const bindingSchema = z.union([localBinding, variantBinding]);
|
|
69
|
+
const editorPolicy = definition?.meta?.binding?.editorPolicy ?? getBindingEditorPolicy(stylePropsSchema) ?? undefined;
|
|
70
|
+
const editorSection = definition?.meta?.binding?.editorSection ?? getBindingEditorSection(stylePropsSchema) ?? undefined;
|
|
71
|
+
const collapsible = definition?.meta?.binding?.collapsible;
|
|
72
|
+
const collapsed = collapsible === true ? definition?.meta?.binding?.collapsed : undefined;
|
|
73
|
+
const maybeDef = bindingSchema._def;
|
|
74
|
+
if (maybeDef) {
|
|
75
|
+
maybeDef[STYLE_META_KEY] = {
|
|
76
|
+
name: styleName,
|
|
77
|
+
propsSchema: stylePropsSchema,
|
|
78
|
+
...(definition?.meta ? { layoutMeta: definition.meta } : {}),
|
|
79
|
+
...(editorPolicy ? { editorPolicy } : {}),
|
|
80
|
+
...(editorSection ? { editorSection } : {}),
|
|
81
|
+
...(collapsible !== undefined ? { collapsible } : {}),
|
|
82
|
+
...(collapsed !== undefined ? { collapsed } : {}),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return bindingSchema;
|
|
86
|
+
}
|
|
87
|
+
export function getWrapperMeta(schema) {
|
|
88
|
+
if (!schema || typeof schema !== 'object')
|
|
89
|
+
return null;
|
|
90
|
+
const def = schema._def;
|
|
91
|
+
if (!def)
|
|
92
|
+
return null;
|
|
93
|
+
const meta = def[WRAPPER_META_KEY];
|
|
94
|
+
return meta ?? null;
|
|
95
|
+
}
|
|
96
|
+
export function getStyleMeta(schema) {
|
|
97
|
+
if (!schema || typeof schema !== 'object')
|
|
98
|
+
return null;
|
|
99
|
+
const def = schema._def;
|
|
100
|
+
if (!def)
|
|
101
|
+
return null;
|
|
102
|
+
const meta = def[STYLE_META_KEY];
|
|
103
|
+
return meta ?? null;
|
|
104
|
+
}
|
|
105
|
+
function isLayoutDefinitionLike(value) {
|
|
106
|
+
return typeof value === 'object' && value !== null && 'schema' in value;
|
|
107
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type SlotConfig = {
|
|
2
|
+
description?: string;
|
|
3
|
+
useTabs?: boolean;
|
|
4
|
+
order?: number;
|
|
5
|
+
};
|
|
6
|
+
export type SlotsSpec = Record<string, SlotConfig>;
|
|
7
|
+
export declare function defineLayoutSlots<const S extends SlotsSpec>(spec: S): S;
|
|
8
|
+
export type ToVueSlots<S extends SlotsSpec> = {
|
|
9
|
+
[K in keyof S]?: (props: {}) => unknown;
|
|
10
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
export type StyleClassValue = string | Ref<string>;
|
|
3
|
+
export type StyleClassList = string[] | ReadonlyArray<StyleClassValue>;
|
|
4
|
+
export type StyleResolverReturn = StyleClassValue | StyleClassList;
|
|
5
|
+
export type OneArgStyleResolver<TStyle> = (style: TStyle) => StyleResolverReturn;
|
|
6
|
+
export type StyleResolverLike<TStyle> = OneArgStyleResolver<TStyle>;
|
|
7
|
+
export type StyleResolvers<TStyle> = Record<string, StyleResolverLike<TStyle>>;
|
|
8
|
+
export type StyleSetupResolvers = Record<string, StyleResolverLike<any>>;
|
|
9
|
+
export type SetupStyleDefinition<TResolvers extends StyleSetupResolvers = StyleSetupResolvers> = {
|
|
10
|
+
setup: () => TResolvers;
|
|
11
|
+
__stylePropsBrand: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type InferStyleProps<T> = T extends {
|
|
14
|
+
__stylePropsBrand?: infer P;
|
|
15
|
+
} ? P : never;
|
|
16
|
+
export declare function defineStyle<TResolvers extends StyleSetupResolvers>(setup: () => TResolvers): SetupStyleDefinition<TResolvers>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './LayoutBindingEditorPolicyMetadata.js';
|
|
2
|
+
export * from './LayoutBindingEditorSectionMetadata.js';
|
|
3
|
+
export * from './LayoutDefinitionMeta.js';
|
|
4
|
+
export * from './LayoutFieldIntentMetadata.js';
|
|
5
|
+
export * from './LayoutFieldUiMetadata.js';
|
|
6
|
+
export * from './LayoutSchema.js';
|
|
7
|
+
export * from './LayoutVariantBindings.js';
|
|
8
|
+
export * from './SlotSchema.js';
|
|
9
|
+
export * from './StyleSchema.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './LayoutBindingEditorPolicyMetadata.js';
|
|
2
|
+
export * from './LayoutBindingEditorSectionMetadata.js';
|
|
3
|
+
export * from './LayoutDefinitionMeta.js';
|
|
4
|
+
export * from './LayoutFieldIntentMetadata.js';
|
|
5
|
+
export * from './LayoutFieldUiMetadata.js';
|
|
6
|
+
export * from './LayoutSchema.js';
|
|
7
|
+
export * from './LayoutVariantBindings.js';
|
|
8
|
+
export * from './SlotSchema.js';
|
|
9
|
+
export * from './StyleSchema.js';
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export declare const COMPOSITE_FIELD_SPEC_BY_FAMILY: {
|
|
2
|
+
readonly border: {
|
|
3
|
+
readonly color: {
|
|
4
|
+
readonly defaultOp: "borderColor";
|
|
5
|
+
readonly targetFamily: "color";
|
|
6
|
+
};
|
|
7
|
+
readonly width: {
|
|
8
|
+
readonly defaultOp: "borderWidth";
|
|
9
|
+
readonly targetFamily: "borderWidth";
|
|
10
|
+
};
|
|
11
|
+
readonly style: {
|
|
12
|
+
readonly defaultOp: "borderStyle";
|
|
13
|
+
readonly targetFamily: "borderStyle";
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly shadow: {
|
|
17
|
+
readonly compose: {
|
|
18
|
+
readonly defaultOp: "shadowCompose";
|
|
19
|
+
readonly targetFamily: "shadowCompose";
|
|
20
|
+
};
|
|
21
|
+
readonly offsetX1: {
|
|
22
|
+
readonly defaultOp: "shadowX1";
|
|
23
|
+
readonly targetFamily: "shadowOffset";
|
|
24
|
+
};
|
|
25
|
+
readonly offsetY1: {
|
|
26
|
+
readonly defaultOp: "shadowY1";
|
|
27
|
+
readonly targetFamily: "shadowOffset";
|
|
28
|
+
};
|
|
29
|
+
readonly blur1: {
|
|
30
|
+
readonly defaultOp: "shadowBlur1";
|
|
31
|
+
readonly targetFamily: "shadowBlur";
|
|
32
|
+
};
|
|
33
|
+
readonly spread1: {
|
|
34
|
+
readonly defaultOp: "shadowSpread1";
|
|
35
|
+
readonly targetFamily: "shadowSpread";
|
|
36
|
+
};
|
|
37
|
+
readonly opacity1: {
|
|
38
|
+
readonly defaultOp: "shadowOpacity1";
|
|
39
|
+
readonly targetFamily: "shadowOpacity";
|
|
40
|
+
};
|
|
41
|
+
readonly offsetX2: {
|
|
42
|
+
readonly defaultOp: "shadowX2";
|
|
43
|
+
readonly targetFamily: "shadowOffset";
|
|
44
|
+
};
|
|
45
|
+
readonly offsetY2: {
|
|
46
|
+
readonly defaultOp: "shadowY2";
|
|
47
|
+
readonly targetFamily: "shadowOffset";
|
|
48
|
+
};
|
|
49
|
+
readonly blur2: {
|
|
50
|
+
readonly defaultOp: "shadowBlur2";
|
|
51
|
+
readonly targetFamily: "shadowBlur";
|
|
52
|
+
};
|
|
53
|
+
readonly spread2: {
|
|
54
|
+
readonly defaultOp: "shadowSpread2";
|
|
55
|
+
readonly targetFamily: "shadowSpread";
|
|
56
|
+
};
|
|
57
|
+
readonly opacity2: {
|
|
58
|
+
readonly defaultOp: "shadowOpacity2";
|
|
59
|
+
readonly targetFamily: "shadowOpacity";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
readonly text: {
|
|
63
|
+
readonly family: {
|
|
64
|
+
readonly defaultOp: "fontFamily";
|
|
65
|
+
readonly targetFamily: "font";
|
|
66
|
+
};
|
|
67
|
+
readonly size: {
|
|
68
|
+
readonly defaultOp: "textSize";
|
|
69
|
+
readonly targetFamily: "textSize";
|
|
70
|
+
};
|
|
71
|
+
readonly weight: {
|
|
72
|
+
readonly defaultOp: "fontWeight";
|
|
73
|
+
readonly targetFamily: "fontWeight";
|
|
74
|
+
};
|
|
75
|
+
readonly leading: {
|
|
76
|
+
readonly defaultOp: "leading";
|
|
77
|
+
readonly targetFamily: "leading";
|
|
78
|
+
};
|
|
79
|
+
readonly tracking: {
|
|
80
|
+
readonly defaultOp: "tracking";
|
|
81
|
+
readonly targetFamily: "tracking";
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
readonly title: {
|
|
85
|
+
readonly family: {
|
|
86
|
+
readonly defaultOp: "fontFamily";
|
|
87
|
+
readonly targetFamily: "font";
|
|
88
|
+
};
|
|
89
|
+
readonly size: {
|
|
90
|
+
readonly defaultOp: "textSize";
|
|
91
|
+
readonly targetFamily: "textSize";
|
|
92
|
+
};
|
|
93
|
+
readonly weight: {
|
|
94
|
+
readonly defaultOp: "fontWeight";
|
|
95
|
+
readonly targetFamily: "fontWeight";
|
|
96
|
+
};
|
|
97
|
+
readonly leading: {
|
|
98
|
+
readonly defaultOp: "leading";
|
|
99
|
+
readonly targetFamily: "leading";
|
|
100
|
+
};
|
|
101
|
+
readonly tracking: {
|
|
102
|
+
readonly defaultOp: "tracking";
|
|
103
|
+
readonly targetFamily: "tracking";
|
|
104
|
+
};
|
|
105
|
+
readonly transform: {
|
|
106
|
+
readonly defaultOp: "textTransform";
|
|
107
|
+
readonly targetFamily: "textTransform";
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export declare const OPS_BY_TOKEN_FAMILY: {
|
|
112
|
+
readonly color: readonly ["borderColor", "divideColor", "bg", "textColor", "shadowColor", "ringColor"];
|
|
113
|
+
readonly borderWidth: readonly ["borderWidth", "borderWidthT", "borderWidthR", "borderWidthB", "borderWidthL", "divideWidth"];
|
|
114
|
+
readonly borderStyle: readonly ["borderStyle", "divideStyle"];
|
|
115
|
+
readonly shadowCompose: readonly ["shadowCompose"];
|
|
116
|
+
readonly shadowOffset: readonly ["shadowX1", "shadowY1", "shadowX2", "shadowY2"];
|
|
117
|
+
readonly shadowBlur: readonly ["shadowBlur1", "shadowBlur2"];
|
|
118
|
+
readonly shadowSpread: readonly ["shadowSpread1", "shadowSpread2"];
|
|
119
|
+
readonly shadowOpacity: readonly ["shadowOpacity1", "shadowOpacity2"];
|
|
120
|
+
readonly font: readonly ["fontFamily"];
|
|
121
|
+
readonly textSize: readonly ["textSize"];
|
|
122
|
+
readonly fontWeight: readonly ["fontWeight"];
|
|
123
|
+
readonly leading: readonly ["leading"];
|
|
124
|
+
readonly tracking: readonly ["tracking"];
|
|
125
|
+
readonly textTransform: readonly ["textTransform"];
|
|
126
|
+
};
|