view-contracts 0.3.5 → 0.4.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.
Files changed (45) hide show
  1. package/README.md +10 -3
  2. package/cli-contract.yaml +40 -0
  3. package/dist/preview-style-helpers.js +2 -0
  4. package/dist/preview-style-helpers.js.map +7 -0
  5. package/dist/preview.mjs +152 -0
  6. package/dist/preview.mjs.map +7 -0
  7. package/dist/view-contracts.bundle.mjs +457 -248
  8. package/dist/view-contracts.bundle.mjs.map +4 -4
  9. package/docs/cli-reference.md +36 -0
  10. package/package.json +28 -1
  11. package/renderers/compose/renderRuntime.ts +40 -0
  12. package/renderers/react/defaults/theme.yaml +52 -0
  13. package/renderers/react/defaults/tokens.yaml +76 -1
  14. package/renderers/react/elementMap.ts +30 -6
  15. package/renderers/react/elements.yaml +17 -5
  16. package/renderers/react/lowering/foldStyle.ts +13 -1
  17. package/renderers/react/lowering/lowerToJsx.ts +21 -40
  18. package/renderers/react/paths.ts +5 -10
  19. package/renderers/react/preview/components.ts +23 -0
  20. package/renderers/react/preview/index.ts +3 -0
  21. package/renderers/react/preview/start.tsx +42 -0
  22. package/renderers/react/preview/style-helpers.ts +5 -0
  23. package/renderers/react/preview/vocabulary.tsx +75 -0
  24. package/renderers/react/runtime/structural.css +38 -0
  25. package/renderers/react/style/foldLiterals.ts +25 -4
  26. package/renderers/swiftui/README.md +48 -10
  27. package/renderers/swiftui/elementMap.ts +45 -0
  28. package/renderers/swiftui/elements.yaml +82 -0
  29. package/renderers/swiftui/index.ts +5 -0
  30. package/renderers/swiftui/lowering/lowerToSwiftUI.ts +761 -0
  31. package/renderers/swiftui/lowering/modifiers.ts +221 -0
  32. package/renderers/swiftui/renderComponents.ts +79 -0
  33. package/renderers/swiftui/renderRuntime.ts +139 -0
  34. package/renderers/swiftui/renderTheme.ts +274 -0
  35. package/spec/ui-dsl.linter-rules.json +0 -7
  36. package/spec/ui-dsl.meta.json +5 -0
  37. package/spec/ui-dsl.schema.json +333 -259
  38. package/renderers/react/runtime/theme.css +0 -65
  39. package/src/generated/schema/allowed-components.ts +0 -36
  40. package/src/generated/schema/dsl-enums.ts +0 -19
  41. package/src/generated/schema/dsl-properties.ts +0 -64
  42. package/src/generated/schema/index.ts +0 -4
  43. package/src/generated/schema/lowering-style-properties.ts +0 -35
  44. package/src/generated/schema/react-renderer-element-config.ts +0 -27
  45. package/src/generated/schema/schema-document.ts +0 -33
@@ -1,65 +0,0 @@
1
- * { box-sizing: border-box; }
2
- body { margin: 0; background: var(--ui-bg); color: var(--ui-text); font-family: var(--ui-font); }
3
- button, input, textarea, select { font: inherit; }
4
-
5
- .vc-page { min-height: 100vh; }
6
- .vc-box { display: block; }
7
- .vc-column { display: flex; flex-direction: column; }
8
- .vc-stack { display: flex; flex-direction: column; }
9
- .vc-row { display: flex; flex-direction: row; }
10
- .vc-wrap { flex-wrap: wrap; }
11
- .vc-spacer { min-width: 0; min-height: 0; }
12
- .vc-divider { border: 0; border-top: 1px solid var(--ui-border); width: 100%; }
13
-
14
- .vc-heading { margin: 0; line-height: 1.2; letter-spacing: -0.02em; }
15
- .vc-heading-1 { font-size: 32px; }
16
- .vc-heading-2 { font-size: 22px; }
17
- .vc-heading-3 { font-size: 18px; }
18
- .vc-heading-4 { font-size: 15px; }
19
- .vc-text { margin: 0; line-height: 1.6; }
20
- .vc-link { color: var(--ui-primary); text-decoration: none; }
21
- .vc-link:hover { text-decoration: underline; }
22
-
23
- .ui-tone-default { color: var(--ui-text); }
24
- .ui-tone-muted { color: var(--ui-text-muted); }
25
- .ui-tone-primary { color: var(--ui-primary); }
26
- .ui-tone-success { color: var(--ui-success); }
27
- .ui-tone-warning { color: var(--ui-warning); }
28
- .ui-tone-danger { color: var(--ui-danger); }
29
-
30
- .vc-button { border: 0; cursor: pointer; }
31
-
32
- .vc-form { display: flex; flex-direction: column; }
33
- .vc-field { display: flex; flex-direction: column; gap: 6px; }
34
- .vc-field-label { font-size: 13px; font-weight: 700; color: var(--ui-text); }
35
- .vc-field-help { font-size: 12px; color: var(--ui-text-muted); }
36
- .vc-field-error { font-size: 12px; color: var(--ui-danger); }
37
- .vc-text-input, .vc-text-area { width: 100%; border: 1px solid var(--ui-border); border-radius: 10px; background: #fff; color: var(--ui-text); outline: none; }
38
- .vc-text-input:focus, .vc-text-area:focus { border-color: var(--ui-primary); box-shadow: 0 0 0 3px var(--ui-primary-weak); }
39
- .vc-field-sm { min-height: 34px; padding: 6px 10px; }
40
- .vc-field-md, .vc-text-input { min-height: 42px; padding: 9px 12px; }
41
- .vc-field-lg { min-height: 50px; padding: 12px 14px; }
42
- .vc-select {
43
- width: 100%;
44
- min-height: 42px;
45
- padding: 9px 36px 9px 12px;
46
- border: 1px solid var(--ui-border);
47
- border-radius: 10px;
48
- background-color: #fff;
49
- color: var(--ui-text);
50
- outline: none;
51
- appearance: none;
52
- -webkit-appearance: none;
53
- -moz-appearance: none;
54
- cursor: pointer;
55
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
56
- background-repeat: no-repeat;
57
- background-position: right 12px center;
58
- background-size: 16px;
59
- }
60
- .vc-select:focus { border-color: var(--ui-primary); box-shadow: 0 0 0 3px var(--ui-primary-weak); }
61
- .vc-field-lg { min-height: 50px; padding: 12px 14px; }
62
- .vc-text-area { padding: 10px 12px; resize: vertical; }
63
- .vc-checkbox { display: inline-flex; align-items: center; gap: 8px; }
64
- .vc-list { margin: 0; padding-left: 20px; }
65
- .vc-list-item { margin: 0; padding: 2px 0; }
@@ -1,36 +0,0 @@
1
- /** Auto-generated from spec/ui-dsl.schema.json — view-contracts v0.3.3 — DO NOT EDIT */
2
- export const ALLOWED_COMPONENTS = new Set([
3
- 'App',
4
- 'Box',
5
- 'Button',
6
- 'Checkbox',
7
- 'Column',
8
- 'Divider',
9
- 'Drawer',
10
- 'Field',
11
- 'Form',
12
- 'Heading',
13
- 'Icon',
14
- 'IconButton',
15
- 'Image',
16
- 'Link',
17
- 'List',
18
- 'ListItem',
19
- 'Modal',
20
- 'Page',
21
- 'Popover',
22
- 'Progress',
23
- 'Radio',
24
- 'Row',
25
- 'SafeArea',
26
- 'ScrollArea',
27
- 'Select',
28
- 'Spacer',
29
- 'Spinner',
30
- 'Stack',
31
- 'Switch',
32
- 'Text',
33
- 'TextArea',
34
- 'TextInput',
35
- 'Tooltip',
36
- ]);
@@ -1,19 +0,0 @@
1
- /** Auto-generated from spec/ui-dsl.schema.json — view-contracts v0.3.3 — DO NOT EDIT */
2
- export type Role = "button" | "link" | "heading" | "list" | "listitem" | "main" | "dialog" | "status";
3
- export type WidthSize = "wrap" | "fill";
4
- export type HeightSize = "wrap" | "fill";
5
- export type Align = "start" | "center" | "end" | "stretch";
6
- export type Justify = "start" | "center" | "end" | "spaceBetween" | "spaceAround" | "spaceEvenly";
7
- export type ContentAlign = "topStart" | "top" | "topEnd" | "start" | "center" | "end" | "bottomStart" | "bottom" | "bottomEnd";
8
- export type Axis = "vertical" | "horizontal";
9
- export type Direction = "ltr" | "rtl" | "system";
10
- export type Scroll = "none" | "vertical" | "horizontal" | "both";
11
- export type Border = "none";
12
- export type Shadow = "none" | "sm" | "md" | "lg";
13
- export type TextAlign = "start" | "center" | "end";
14
- export type LineLimit = "none";
15
- export type TextOverflow = "clip" | "ellipsis";
16
- export type FontWeight = "regular" | "medium" | "bold";
17
- export type ImageFit = "contain" | "cover" | "fill" | "none";
18
- export type KeyboardType = "text" | "number" | "email" | "url" | "password" | "tel";
19
- export type Clip = "none" | "bounds" | "shape";
@@ -1,64 +0,0 @@
1
- /** Auto-generated from spec/ui-dsl.schema.json — view-contracts v0.3.3 — DO NOT EDIT */
2
- export interface ViewAction { name: string; params?: Record<string, unknown> }
3
- import type { Role, WidthSize, HeightSize, Align, Justify, ContentAlign, Axis, Direction, Scroll, Border, Shadow, TextAlign, LineLimit, TextOverflow, FontWeight, ImageFit, KeyboardType, Clip } from './dsl-enums.js';
4
-
5
- /** Shared DSL attributes from $defs.properties / properties catalog */
6
- export interface DslProperties {
7
- id?: string;
8
- role?: Role;
9
- label?: string;
10
- visible?: boolean;
11
- enabled?: boolean;
12
- selected?: boolean;
13
- checked?: boolean;
14
- readonly?: boolean;
15
- required?: boolean;
16
- width?: WidthSize;
17
- height?: HeightSize;
18
- minWidth?: number;
19
- maxWidth?: string | number;
20
- minHeight?: number;
21
- maxHeight?: string | number;
22
- aspectRatio?: number;
23
- weight?: number;
24
- padding?: string | number;
25
- gap?: string | number;
26
- align?: Align;
27
- justify?: Justify;
28
- selfAlign?: Align;
29
- contentAlign?: ContentAlign;
30
- axis?: Axis;
31
- direction?: Direction;
32
- scroll?: Scroll;
33
- background?: string;
34
- foreground?: string;
35
- border?: Border;
36
- radius?: string;
37
- shadow?: Shadow;
38
- opacity?: number;
39
- clip?: Clip;
40
- textStyle?: string;
41
- textAlign?: TextAlign;
42
- lineLimit?: LineLimit;
43
- textOverflow?: TextOverflow;
44
- fontWeight?: FontWeight;
45
- headingLevel?: number;
46
- fit?: ImageFit;
47
- src?: string;
48
- alt?: string;
49
- name?: string;
50
- onClick?: ViewAction;
51
- onSubmit?: ViewAction;
52
- onChange?: ViewAction;
53
- focusable?: boolean;
54
- autoFocus?: boolean;
55
- keyboardType?: KeyboardType;
56
- value?: string | number | boolean;
57
- binding?: string;
58
- placeholder?: string;
59
- options?: unknown[];
60
- error?: string | null;
61
- help?: string | null;
62
- variant?: string;
63
- theme?: string;
64
- }
@@ -1,4 +0,0 @@
1
- /** Auto-generated from spec/ui-dsl.schema.json — view-contracts v0.3.3 — DO NOT EDIT */
2
- export * from './dsl-enums.js';
3
- export * from './dsl-properties.js';
4
- export * from './schema-document.js';
@@ -1,35 +0,0 @@
1
- /** Auto-generated from spec/ui-dsl.schema.json — view-contracts v0.3.3 — DO NOT EDIT */
2
- /** Property names folded to compile-time inline CSS during React HTML lowering. */
3
- export const LOWERING_STYLE_PROPERTIES = new Set<string>([
4
- "align",
5
- "aspectRatio",
6
- "axis",
7
- "background",
8
- "border",
9
- "clip",
10
- "contentAlign",
11
- "direction",
12
- "fontWeight",
13
- "foreground",
14
- "gap",
15
- "headingLevel",
16
- "height",
17
- "justify",
18
- "lineLimit",
19
- "maxHeight",
20
- "maxWidth",
21
- "minHeight",
22
- "minWidth",
23
- "opacity",
24
- "padding",
25
- "radius",
26
- "scroll",
27
- "selfAlign",
28
- "shadow",
29
- "textAlign",
30
- "textOverflow",
31
- "textStyle",
32
- "weight",
33
- "width",
34
- "size",
35
- ]);
@@ -1,27 +0,0 @@
1
- /** Auto-generated from renderers/react/element-config.meta.json — view-contracts v0.3.3 — DO NOT EDIT */
2
- /** Shape of entries in renderers/react/elements.yaml (target-specific HTML map, not DSL vocabulary). */
3
- export interface ReactRendererElementConfig {
4
- tag: string;
5
- className?: string;
6
- ariaLabel?: boolean;
7
- ariaHidden?: boolean;
8
- flex?: "row" | "column";
9
- wrapProp?: string;
10
- flexGrowProp?: string;
11
- void?: boolean;
12
- levelProp?: string;
13
- defaultLevel?: number;
14
- actionEvent?: "onClick" | "onSubmit";
15
- fieldWrap?: boolean;
16
- inputType?: string;
17
- sizeClass?: string;
18
- optionsProp?: string;
19
- checkbox?: boolean;
20
- fieldContainer?: boolean;
21
- scrollContainer?: boolean;
22
- defaultRole?: string;
23
- }
24
-
25
- export interface ReactElementMapFile {
26
- elements: Record<string, ReactRendererElementConfig>;
27
- }
@@ -1,33 +0,0 @@
1
- /** Auto-generated from spec/ui-dsl.meta.json + ui-dsl.schema.json — view-contracts v0.3.3 — DO NOT EDIT */
2
- import type { Role, WidthSize, HeightSize, Align, Justify, ContentAlign, Axis, Direction, Scroll, Border, Shadow, TextAlign, LineLimit, TextOverflow, FontWeight, ImageFit, KeyboardType, Clip } from './dsl-enums.js';
3
-
4
- export type PropertyType = 'string' | 'number' | 'boolean' | 'array' | 'action' | 'object' | 'null' | string | string[];
5
-
6
- export interface PropertyDef {
7
- type: PropertyType;
8
- enum?: string;
9
- description?: string;
10
- 'x-category': string;
11
- 'x-appliesTo'?: string[];
12
- 'x-notes'?: string;
13
- $ref?: string;
14
- }
15
-
16
- export interface ChildrenConstraint {
17
- 'x-kind': 'any' | 'none' | 'single' | 'text' | 'list';
18
- 'x-items'?: string[];
19
- }
20
-
21
- export interface ElementDef {
22
- description: string;
23
- 'x-category': string;
24
- 'x-notes'?: string;
25
- properties: Record<string, PropertyDef | { $ref: string }>;
26
- _children: ChildrenConstraint;
27
- }
28
-
29
- export interface UiDslSchema {
30
- tokens: Record<string, string[]>;
31
- properties: Record<string, PropertyDef>;
32
- elements: Record<string, ElementDef>;
33
- }