@reallygoodwork/design-ui-react 0.0.0-stage → 0.1.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.
Files changed (172) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +14 -2
  3. package/dist/assets/icons/AlignItemsBaseline.d.ts +4 -0
  4. package/dist/assets/icons/AlignItemsCenter.d.ts +4 -0
  5. package/dist/assets/icons/AlignItemsFlexEnd.d.ts +4 -0
  6. package/dist/assets/icons/AlignItemsFlexStart.d.ts +4 -0
  7. package/dist/assets/icons/AlignItemsStretch.d.ts +4 -0
  8. package/dist/assets/icons/FlexDirectionColumn.d.ts +4 -0
  9. package/dist/assets/icons/FlexDirectionColumnReverse.d.ts +4 -0
  10. package/dist/assets/icons/FlexDirectionRow.d.ts +4 -0
  11. package/dist/assets/icons/FlexDirectionRowReverse.d.ts +4 -0
  12. package/dist/assets/icons/FlexWrapNoWrap.d.ts +4 -0
  13. package/dist/assets/icons/FlexWrapWrap.d.ts +4 -0
  14. package/dist/assets/icons/JustifyContentCenter.d.ts +4 -0
  15. package/dist/assets/icons/JustifyContentFlexEnd.d.ts +4 -0
  16. package/dist/assets/icons/JustifyContentFlexStart.d.ts +4 -0
  17. package/dist/assets/icons/JustifyContentSpaceAround.d.ts +4 -0
  18. package/dist/assets/icons/JustifyContentSpaceBetween.d.ts +4 -0
  19. package/dist/assets/icons/JustifyContentSpaceEvenly.d.ts +4 -0
  20. package/dist/assets/icons/index.d.ts +17 -0
  21. package/dist/components/AddLayerDialog.d.ts +2 -0
  22. package/dist/components/BreakpointFrame.d.ts +12 -0
  23. package/dist/components/BreakpointHeader.d.ts +10 -0
  24. package/dist/components/BreakpointPropertiesPanel.d.ts +5 -0
  25. package/dist/components/BreakpointSwitcher.d.ts +8 -0
  26. package/dist/components/CSSPanel.d.ts +2 -0
  27. package/dist/components/DesignAction.d.ts +16 -0
  28. package/dist/components/DesignActionPanel.d.ts +1 -0
  29. package/dist/components/DesignToolbarContainer.d.ts +1 -0
  30. package/dist/components/DesignView.d.ts +14 -0
  31. package/dist/components/Designer.d.ts +81 -0
  32. package/dist/components/DesignerCanvas.d.ts +4 -0
  33. package/dist/components/DesignerContent.d.ts +4 -0
  34. package/dist/components/DesignerFrame.d.ts +5 -0
  35. package/dist/components/DesignerHeader.d.ts +3 -0
  36. package/dist/components/DesignerPane.d.ts +14 -0
  37. package/dist/components/DesignerPanel.d.ts +3 -0
  38. package/dist/components/DesignerToolbar.d.ts +4 -0
  39. package/dist/components/DesignerToolbarButton.d.ts +9 -0
  40. package/dist/components/DesignerToolbarGroup.d.ts +4 -0
  41. package/dist/components/DesignerToolbarSeparator.d.ts +1 -0
  42. package/dist/components/EditorPreviewToggle.d.ts +5 -0
  43. package/dist/components/ExportMenu.d.ts +2 -0
  44. package/dist/components/FontLoader.d.ts +4 -0
  45. package/dist/components/FrameStylesPanel.d.ts +5 -0
  46. package/dist/components/PaneLayerTree.d.ts +9 -0
  47. package/dist/components/RuleNotice.d.ts +5 -0
  48. package/dist/components/RulesPanel.d.ts +6 -0
  49. package/dist/components/ZoomControl.d.ts +1 -0
  50. package/dist/components/ables/DimensionAble.d.ts +13 -0
  51. package/dist/components/ables/StructureAble.d.ts +18 -0
  52. package/dist/components/actions/ActionAlignItems.d.ts +1 -0
  53. package/dist/components/actions/ActionBackgroundColor.d.ts +1 -0
  54. package/dist/components/actions/ActionBorder.d.ts +1 -0
  55. package/dist/components/actions/ActionBorderRadius.d.ts +1 -0
  56. package/dist/components/actions/ActionColor.d.ts +1 -0
  57. package/dist/components/actions/ActionDisplay.d.ts +1 -0
  58. package/dist/components/actions/ActionElementType.d.ts +1 -0
  59. package/dist/components/actions/ActionFill.d.ts +1 -0
  60. package/dist/components/actions/ActionFlexDirection.d.ts +1 -0
  61. package/dist/components/actions/ActionFlexWrap.d.ts +1 -0
  62. package/dist/components/actions/ActionFontFamily.d.ts +1 -0
  63. package/dist/components/actions/ActionFontSize.d.ts +1 -0
  64. package/dist/components/actions/ActionFontWeight.d.ts +1 -0
  65. package/dist/components/actions/ActionFontWidth.d.ts +1 -0
  66. package/dist/components/actions/ActionGap.d.ts +1 -0
  67. package/dist/components/actions/ActionGridLayout.d.ts +1 -0
  68. package/dist/components/actions/ActionImage.d.ts +2 -0
  69. package/dist/components/actions/ActionJustifyContent.d.ts +1 -0
  70. package/dist/components/actions/ActionLayout/GridCanvas.d.ts +7 -0
  71. package/dist/components/actions/ActionLayout.d.ts +1 -0
  72. package/dist/components/actions/ActionLetterSpacing.d.ts +1 -0
  73. package/dist/components/actions/ActionLineHeight.d.ts +1 -0
  74. package/dist/components/actions/ActionMargin.d.ts +1 -0
  75. package/dist/components/actions/ActionOpacity.d.ts +1 -0
  76. package/dist/components/actions/ActionPadding.d.ts +1 -0
  77. package/dist/components/actions/ActionPopover.d.ts +21 -0
  78. package/dist/components/actions/ActionPosition.d.ts +1 -0
  79. package/dist/components/actions/ActionSize.d.ts +5 -0
  80. package/dist/components/actions/ActionTextAlign.d.ts +1 -0
  81. package/dist/components/actions/ActionTextContent.d.ts +1 -0
  82. package/dist/components/actions/ActionTextDecoration.d.ts +1 -0
  83. package/dist/components/actions/ActionTextShadow.d.ts +1 -0
  84. package/dist/components/actions/ActionTextStyle.d.ts +1 -0
  85. package/dist/components/actions/ActionTextTransform.d.ts +1 -0
  86. package/dist/components/actions/ActionTransition.d.ts +5 -0
  87. package/dist/components/actions/BoxModel.d.ts +1 -0
  88. package/dist/components/actions/ColorActionPopover.d.ts +10 -0
  89. package/dist/components/actions/LinkedValuesControl.d.ts +33 -0
  90. package/dist/components/actions/NumberFieldActionControl.d.ts +17 -0
  91. package/dist/components/actions/NumericActionControl.d.ts +20 -0
  92. package/dist/components/actions/RadiusPreview.d.ts +9 -0
  93. package/dist/components/actions/SelectActionControl.d.ts +16 -0
  94. package/dist/components/actions/SliderActionControl.d.ts +13 -0
  95. package/dist/components/actions/ToggleGroupControl.d.ts +15 -0
  96. package/dist/components/actions/TransitionCharts.d.ts +10 -0
  97. package/dist/components/activity/ActivityPane.d.ts +6 -0
  98. package/dist/components/activity/AnnotationLayer.d.ts +6 -0
  99. package/dist/components/activity/AnnotationThread.d.ts +30 -0
  100. package/dist/components/common/CategoryChip.d.ts +8 -0
  101. package/dist/components/common/ClearButton.d.ts +7 -0
  102. package/dist/components/common/ColorPicker.d.ts +8 -0
  103. package/dist/components/common/InputGroup.d.ts +23 -0
  104. package/dist/components/common/RowLabel.d.ts +6 -0
  105. package/dist/components/common/ScrubField.d.ts +31 -0
  106. package/dist/components/common/Select.d.ts +15 -0
  107. package/dist/components/common/Tabs.d.ts +13 -0
  108. package/dist/components/common/Tooltip.d.ts +11 -0
  109. package/dist/components/common/UnitField.d.ts +71 -0
  110. package/dist/components/design-pane.d.ts +9 -0
  111. package/dist/components/help/ConnectAgentDialog.d.ts +5 -0
  112. package/dist/components/help/HelpMenu.d.ts +4 -0
  113. package/dist/components/help/HelpProvider.d.ts +11 -0
  114. package/dist/components/help/WelcomeDialog.d.ts +6 -0
  115. package/dist/components/theme-provider.d.ts +13 -0
  116. package/dist/components/tokens/ImportCssDialog.d.ts +8 -0
  117. package/dist/components/tokens/NewTokenForm.d.ts +9 -0
  118. package/dist/components/tokens/TokenComposer.d.ts +26 -0
  119. package/dist/components/tokens/TokenEditor.d.ts +22 -0
  120. package/dist/components/tokens/TokenGraph.d.ts +3 -0
  121. package/dist/components/tokens/TokenIcon.d.ts +7 -0
  122. package/dist/components/tokens/TokenList.d.ts +27 -0
  123. package/dist/components/tokens/TokenPicker.d.ts +32 -0
  124. package/dist/components/tokens/TokenSlot.d.ts +22 -0
  125. package/dist/components/tokens/TokenStyles.d.ts +11 -0
  126. package/dist/components/tokens/TokenTable.d.ts +6 -0
  127. package/dist/components/tokens/TokenValueField.d.ts +24 -0
  128. package/dist/components/tokens/TokensPane.d.ts +10 -0
  129. package/dist/components/tokens/suggest.d.ts +6 -0
  130. package/dist/components/tokens/useDrawerSize.d.ts +23 -0
  131. package/dist/context/DesignerContext.d.ts +22 -0
  132. package/dist/hooks/useActiveBreakpoint.d.ts +12 -0
  133. package/dist/hooks/useAgentLink.d.ts +21 -0
  134. package/dist/hooks/useAllowed.d.ts +28 -0
  135. package/dist/hooks/useAnnotations.d.ts +51 -0
  136. package/dist/hooks/useBreakpointCss.d.ts +72 -0
  137. package/dist/hooks/useBreakpointStyles.d.ts +15 -0
  138. package/dist/hooks/useChangeLog.d.ts +29 -0
  139. package/dist/hooks/useDesigner.d.ts +41 -0
  140. package/dist/hooks/useDesignerAction.d.ts +6 -0
  141. package/dist/hooks/useDesignerApi.d.ts +14 -0
  142. package/dist/hooks/useDesignerContext.d.ts +9 -0
  143. package/dist/hooks/useDesignerSelector.d.ts +8 -0
  144. package/dist/hooks/useFrameRegistry.d.ts +33 -0
  145. package/dist/hooks/useFrameStyles.d.ts +31 -0
  146. package/dist/hooks/useGoogleFonts.d.ts +20 -0
  147. package/dist/hooks/useHistory.d.ts +6 -0
  148. package/dist/hooks/useKeybindings.d.ts +1 -0
  149. package/dist/hooks/useLayer.d.ts +7 -0
  150. package/dist/hooks/useLayerDimensions.d.ts +15 -0
  151. package/dist/hooks/useLayerTypes.d.ts +7 -0
  152. package/dist/hooks/useLayers.d.ts +5 -0
  153. package/dist/hooks/useSelectedLayers.d.ts +6 -0
  154. package/dist/hooks/useTokenEditing.d.ts +24 -0
  155. package/dist/hooks/useTokens.d.ts +60 -0
  156. package/dist/hooks/useZoom.d.ts +4 -0
  157. package/dist/index.d.ts +147 -0
  158. package/dist/index.js +13791 -0
  159. package/dist/lib/Types.d.ts +12 -0
  160. package/dist/lib/canvasCentering.d.ts +29 -0
  161. package/dist/lib/cn.d.ts +1 -0
  162. package/dist/lib/cssPropertyMapping.d.ts +5 -0
  163. package/dist/lib/cssValueHelpers.d.ts +36 -0
  164. package/dist/lib/cursors.d.ts +17 -0
  165. package/dist/lib/fontFamily.d.ts +6 -0
  166. package/dist/lib/keyboardTargets.d.ts +9 -0
  167. package/dist/lib/layers/frame.d.ts +47 -0
  168. package/dist/lib/layers/image.d.ts +38 -0
  169. package/dist/lib/layers/input.d.ts +21 -0
  170. package/dist/lib/layers/text.d.ts +84 -0
  171. package/package.json +57 -5
  172. package/styles.css +4055 -0
@@ -0,0 +1,32 @@
1
+ import { type TokenType } from "@reallygoodwork/design-ui-core";
2
+ import { type ReactNode } from "react";
3
+ export type TokenBinding = {
4
+ type: TokenType;
5
+ /** The property, for previewing a token on the canvas. Several, comma-separated, preview together. */
6
+ cssProperty: string;
7
+ /** Not a layer property (like frame styles), so there's nothing to preview on. */
8
+ noPreview?: boolean;
9
+ /** The value the layer holds: `var(--token)` or a raw value. */
10
+ value: string | undefined;
11
+ /** Writes a new value: `var(--token)` to apply one, a raw value to detach. */
12
+ onChange: (value: string) => void;
13
+ };
14
+ /** What a token-aware field shows: the token it uses and that token's value here. */
15
+ export declare const useBinding: (binding: TokenBinding | undefined) => {
16
+ token: import("@reallygoodwork/design-ui-core").Token | undefined;
17
+ resolved: string | undefined;
18
+ broken: boolean;
19
+ match: import("@reallygoodwork/design-ui-core").Token | undefined;
20
+ hasTokens: boolean;
21
+ };
22
+ /**
23
+ * The inside of a value popover with tokens: Custom | Tokens tabs, a note when
24
+ * a token is in use with a way to detach it, and the list of tokens that fit.
25
+ * It opens on Tokens when the value is a token or matches one.
26
+ */
27
+ export declare const TokenPicker: ({ binding, custom, onDone, }: {
28
+ binding: TokenBinding;
29
+ /** The ordinary editor for a raw value. Without it there are no tabs. */
30
+ custom?: ReactNode;
31
+ onDone: () => void;
32
+ }) => import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from "react";
2
+ import { type TokenBinding } from "./TokenPicker";
3
+ /**
4
+ * Lets any field take a design token. With a token applied, the field becomes
5
+ * a pill naming it, which opens the token list. Without one, a link button
6
+ * offers the list: beside the field in a panel row, or over the field's
7
+ * letter in narrow cells like W and H. Fields with no tokens of their type
8
+ * render unchanged.
9
+ */
10
+ export declare const TokenSlot: ({ binding, title, variant, prefix, inherited, trailing, children, }: {
11
+ binding: TokenBinding;
12
+ title: string;
13
+ /** A panel row with its label inside the field, or a narrow cell. */
14
+ variant?: "row" | "cell";
15
+ /** The cell's letter or icon, kept on the pill. */
16
+ prefix?: ReactNode;
17
+ /** The token comes from a smaller breakpoint. */
18
+ inherited?: boolean;
19
+ /** Controls kept at the end of the pill, like an expand toggle. */
20
+ trailing?: ReactNode;
21
+ children: ReactNode;
22
+ }) => import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Puts each token's value on each breakpoint frame as a custom property, so
3
+ * layers can use `var(--token)`.
4
+ */
5
+ export declare const TokenStyles: () => import("react").JSX.Element | null;
6
+ /**
7
+ * Outlines the layers using a hovered token, and shows a token on one
8
+ * property before it's applied. Frames render this inside their shadow root,
9
+ * since document styles can't reach design content.
10
+ */
11
+ export declare const useTokenOverlayCss: () => string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Every token against every value of one mode set, under the canvas. Each
3
+ * cell is that token's value in that mode; an empty cell uses the default.
4
+ * The header is where themes and other mode sets are added and renamed.
5
+ */
6
+ export declare const TokenTable: () => import("react").JSX.Element | null;
@@ -0,0 +1,24 @@
1
+ import { type TokenType } from "@reallygoodwork/design-ui-core";
2
+ /**
3
+ * One token value: a raw value typed in (colors also through the picker, in
4
+ * Hex, OKLCH or Display P3), or an alias to another token of the same type.
5
+ */
6
+ export declare const TokenValueField: ({ type, value, onCommit, exclude, label, placeholder, live, compact, onClear, previewValue, noCompose, }: {
7
+ type: TokenType;
8
+ value: string;
9
+ onCommit: (value: string) => void;
10
+ /** The token being edited, which can't alias itself. */
11
+ exclude?: string;
12
+ label: string;
13
+ placeholder?: string;
14
+ /** Report every keystroke, for forms that save later. Otherwise on blur or Enter. */
15
+ live?: boolean;
16
+ /** A table cell: no background until hovered or focused. */
17
+ compact?: boolean;
18
+ /** Emptying the field calls this, e.g. to drop a mode's own value. */
19
+ onClear?: () => void;
20
+ /** What the glyph shows when the field is empty, like an inherited value. */
21
+ previewValue?: string;
22
+ /** Hide the fx button, e.g. inside the composer itself. */
23
+ noCompose?: boolean;
24
+ }) => import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { type TokenIssue } from "@reallygoodwork/design-ui-core";
2
+ export declare const IssueIcon: ({ severity, }: {
3
+ severity: TokenIssue["severity"];
4
+ }) => import("react").JSX.Element;
5
+ /**
6
+ * The token library: every token by tier and type, searchable. Hover one to
7
+ * outline the layers using it; open one to edit it. Problems collect at the
8
+ * bottom, with a fix where there's an obvious one.
9
+ */
10
+ export declare const TokensPane: () => import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export type Suggestion = {
2
+ label: string;
3
+ matches: (path: string) => boolean;
4
+ };
5
+ /** What to list first for a property (or comma-separated properties), if anything. */
6
+ export declare function suggestionFor(cssProperty: string): Suggestion | null;
@@ -0,0 +1,23 @@
1
+ import { type KeyboardEvent, type PointerEvent, type RefObject } from "react";
2
+ /**
3
+ * Height for the bottom token panel: dragged by its top edge, stepped with
4
+ * the arrow keys, snapped to full view near the top and closed near the
5
+ * bottom. Selecting a layer brings the canvas back from full view.
6
+ */
7
+ export declare const useDrawerSize: (panelRef: RefObject<HTMLElement | null>) => {
8
+ maximized: boolean;
9
+ toggleMaximized: () => void;
10
+ dragging: boolean;
11
+ pending: "close" | "full" | null;
12
+ /** For `role="separator"`: how much of the column the panel takes. */
13
+ percent: number;
14
+ style: {
15
+ height: string;
16
+ maxHeight: string;
17
+ };
18
+ handleProps: {
19
+ onPointerDown: (event: PointerEvent<HTMLElement>) => void;
20
+ onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
21
+ onDoubleClick: () => void;
22
+ };
23
+ };
@@ -0,0 +1,22 @@
1
+ import type { Role, Rule } from "@reallygoodwork/design-ui-core";
2
+ import { type ReactNode } from "react";
3
+ import { type DesignerStore } from "../hooks/useDesigner";
4
+ import type { Breakpoint, CSSVars, Layer, LayerType } from "../lib/Types";
5
+ /**
6
+ * The context value is the stable store, so it never changes and never
7
+ * re-renders consumers. Components subscribe through `useDesignerSelector`.
8
+ */
9
+ export declare const DesignerContext: import("react").Context<DesignerStore | null>;
10
+ type DesignerProviderProps = {
11
+ children: ReactNode;
12
+ defaultLayers?: Layer[];
13
+ layers?: Layer[];
14
+ onLayersChange?: (layers: Layer[]) => void;
15
+ defaultLayerTypes?: LayerType[];
16
+ breakpoints?: Breakpoint[];
17
+ frameStyles?: CSSVars;
18
+ rules?: Rule[];
19
+ role?: Role;
20
+ };
21
+ export declare const DesignerProvider: ({ children, defaultLayers, layers, onLayersChange, defaultLayerTypes, breakpoints, frameStyles, rules, role, }: DesignerProviderProps) => import("react").JSX.Element;
22
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Hook to get the currently active breakpoint.
3
+ */
4
+ export declare const useActiveBreakpoint: () => import("@reallygoodwork/design-ui-core").Breakpoint | null;
5
+ /**
6
+ * Hook to get all breakpoints.
7
+ */
8
+ export declare const useBreakpoints: () => import("@reallygoodwork/design-ui-core").Breakpoint[];
9
+ /**
10
+ * Hook to get the selected breakpoint (when frame itself is selected).
11
+ */
12
+ export declare const useSelectedBreakpoint: () => import("@reallygoodwork/design-ui-core").Breakpoint | null;
@@ -0,0 +1,21 @@
1
+ import { type ReactNode } from "react";
2
+ export type AgentStatus = "off" | "connecting" | "connected" | "disconnected";
3
+ type AgentLink = {
4
+ status: AgentStatus;
5
+ url?: string;
6
+ /** Tries to reach the agent again, e.g. after starting its server. */
7
+ connect: () => void;
8
+ };
9
+ /**
10
+ * Connects the editor to an agent's server over a WebSocket and answers its
11
+ * requests: read the design and tasks, claim a task, make changes with a
12
+ * reason, reply, resolve. Tasks assigned to the agent are pushed to it.
13
+ * It tries once on load, then only when asked (or when a task is assigned),
14
+ * so a missing agent doesn't fill the console with errors.
15
+ */
16
+ export declare const AgentLinkProvider: ({ url, children, }: {
17
+ url?: string;
18
+ children: ReactNode;
19
+ }) => import("react").JSX.Element;
20
+ export declare const useAgentLink: () => AgentLink;
21
+ export {};
@@ -0,0 +1,28 @@
1
+ import { type Action, type Allowed, type Rejection } from "@reallygoodwork/design-ui-core";
2
+ export declare const EVERYTHING: Allowed;
3
+ /** The role the person here works as, counting the editor preview. */
4
+ export declare const useRole: () => import("@reallygoodwork/design-ui-core").Role;
5
+ /** Whether the person here can set rules: a builder, not previewing. */
6
+ export declare const useCanSetRules: () => boolean;
7
+ /** What the current role may change on a layer, from the editing rules. */
8
+ export declare const useAllowed: (layerId: string | undefined) => Allowed;
9
+ /** Why the rules would block `action`, or null. For explaining a locked control. */
10
+ export declare const useWhyBlocked: (action: Action | null) => Rejection | null;
11
+ /**
12
+ * The selected layer's limits, provided once by the styles panel so each
13
+ * row doesn't subscribe to the store. Outside a panel, everything is allowed.
14
+ */
15
+ export declare const AllowedContext: import("react").Context<Allowed>;
16
+ export type PropertyAccess = {
17
+ editable: boolean;
18
+ /** Only a token can be used. */
19
+ tokensOnly: boolean;
20
+ min?: number;
21
+ max?: number;
22
+ unit?: string;
23
+ oneOf?: string[];
24
+ };
25
+ /** Whether any of `properties` can be edited on the selected layer. */
26
+ export declare const useAnyEditable: (properties: readonly string[]) => boolean;
27
+ /** Whether `property` can be edited on the selected layer, and within what limits. */
28
+ export declare const usePropertyAccess: (property: string | undefined) => PropertyAccess;
@@ -0,0 +1,51 @@
1
+ import type { Annotation, AnnotationKind, AnnotationTarget } from "@reallygoodwork/design-ui-core";
2
+ import { type Actor } from "@reallygoodwork/design-ui-core";
3
+ import { type ReactNode } from "react";
4
+ export type NewAnnotation = {
5
+ kind?: AnnotationKind;
6
+ target: AnnotationTarget;
7
+ body: string;
8
+ author?: Actor;
9
+ entryId?: string;
10
+ };
11
+ /** Where a new comment is being written: a target and, from the canvas, a point. */
12
+ export type Draft = {
13
+ target: AnnotationTarget;
14
+ at?: {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ };
19
+ type AnnotationsStore = {
20
+ annotations: Annotation[];
21
+ add: (annotation: NewAnnotation) => string;
22
+ reply: (id: string, body: string, author?: Actor) => void;
23
+ setStatus: (id: string, status: Annotation["status"]) => void;
24
+ /** Hands a task to someone, like the agent, or takes it back with undefined. */
25
+ assign: (id: string, to: Actor | undefined) => void;
26
+ /** Marks a task as being worked on. */
27
+ claim: (id: string, by: Actor) => void;
28
+ /** Replaces every annotation with saved ones, e.g. when a design loads. */
29
+ replaceAll: (annotations: Annotation[]) => void;
30
+ remove: (id: string) => void;
31
+ /** Clicking the canvas picks a layer to comment on. */
32
+ commentMode: boolean;
33
+ setCommentMode: (on: boolean) => void;
34
+ draft: Draft | null;
35
+ setDraft: (draft: Draft | null) => void;
36
+ /** The thread shown open, from a pin or the feed. */
37
+ openId: string | null;
38
+ setOpenId: (id: string | null) => void;
39
+ };
40
+ /**
41
+ * Comments, notes, decisions and tasks, anchored to layers, properties,
42
+ * tokens or changes. An agent change that gives a reason becomes a note on
43
+ * the layer it touched, so its intent shows up where the change did.
44
+ */
45
+ export declare const AnnotationsProvider: ({ initialAnnotations, onChange, children, }: {
46
+ initialAnnotations?: Annotation[];
47
+ onChange?: (annotations: Annotation[]) => void;
48
+ children: ReactNode;
49
+ }) => import("react").JSX.Element;
50
+ export declare const useAnnotations: () => AnnotationsStore;
51
+ export {};
@@ -0,0 +1,72 @@
1
+ import type { CSSVars } from "../lib/Types";
2
+ export type BreakpointCssValue = {
3
+ /**
4
+ * The current effective value for display.
5
+ */
6
+ value: string | undefined;
7
+ /**
8
+ * The inherited value (from smaller breakpoint) for placeholder display.
9
+ */
10
+ inheritedValue: string | undefined;
11
+ /**
12
+ * Whether this value is explicitly set at this breakpoint (not inherited).
13
+ */
14
+ isExplicit: boolean;
15
+ /**
16
+ * Which breakpoint the value comes from (for "Inherited from X" display).
17
+ */
18
+ fromBreakpointId: string | null;
19
+ /**
20
+ * The name of the breakpoint the value comes from.
21
+ */
22
+ fromBreakpointName: string | null;
23
+ /**
24
+ * Whether we're at the primary (smallest) breakpoint.
25
+ */
26
+ isPrimary: boolean;
27
+ /**
28
+ * Whether this breakpoint overrides a value from a smaller one.
29
+ */
30
+ isOverride: boolean;
31
+ /**
32
+ * Set the value at the current breakpoint.
33
+ */
34
+ setValue: (value: string) => void;
35
+ /**
36
+ * Clear the value at the current breakpoint.
37
+ * On primary: removes value entirely.
38
+ * On non-primary: removes override, reverts to inherited.
39
+ */
40
+ clearValue: () => void;
41
+ };
42
+ /**
43
+ * Hook for action controls to read/write CSS values with breakpoint awareness.
44
+ * Handles the mobile-first cascade and inherited value logic.
45
+ *
46
+ * @param cssProperty - The CSS property to manage (e.g., "--font-size")
47
+ * @returns Object with value, inheritance info, and setter functions
48
+ */
49
+ export declare const useBreakpointCss: (cssProperty: string) => BreakpointCssValue;
50
+ /**
51
+ * The selected layer's styles as they apply at the active breakpoint.
52
+ */
53
+ export declare const useEffectiveCss: () => CSSVars;
54
+ /**
55
+ * Read and write several related properties at the active breakpoint, for
56
+ * controls that edit them together (padding sides, width and height).
57
+ */
58
+ export declare const useBreakpointCssGroup: (properties: readonly string[]) => {
59
+ entries: {
60
+ value: string | undefined;
61
+ isExplicit: boolean;
62
+ }[];
63
+ hasExplicit: boolean;
64
+ /** Showing values from a smaller breakpoint, none set here */
65
+ isInherited: boolean;
66
+ isPrimary: boolean;
67
+ isOverride: boolean;
68
+ setAll: (value: string) => void;
69
+ setOne: (property: string, value: string) => void;
70
+ write: (css: CSSVars) => void;
71
+ clearAll: () => void;
72
+ };
@@ -0,0 +1,15 @@
1
+ import type { CSSVars, Layer } from "../lib/Types";
2
+ /**
3
+ * Hook to compute effective styles for a layer at a specific breakpoint.
4
+ * Used for rendering layers with proper style cascade.
5
+ *
6
+ * @param layer - The layer to get styles for
7
+ * @param breakpointId - The breakpoint ID to compute styles for
8
+ * @returns The computed CSS variables for rendering
9
+ */
10
+ export declare const useBreakpointStyles: (layer: Layer, breakpointId: string) => CSSVars;
11
+ /**
12
+ * Hook to get the frame styles (document-level styles).
13
+ * These are shared across all breakpoints.
14
+ */
15
+ export declare const useFrameStylesRead: () => CSSVars;
@@ -0,0 +1,29 @@
1
+ import type { Token, TokenDimensions } from "@reallygoodwork/design-ui-core";
2
+ import { type ActionMeta, type ChangeEntry } from "@reallygoodwork/design-ui-core";
3
+ import { type ReactNode } from "react";
4
+ type ChangeLogStore = {
5
+ /** Oldest first. */
6
+ entries: ChangeEntry[];
7
+ /** Records a token edit, which happens outside the layer store. */
8
+ logTokens: (before: readonly Token[], after: readonly Token[]) => void;
9
+ /** Credits the next token edit to someone else, like an agent, with a reason. */
10
+ attributeNextTokenEdit: (meta: ActionMeta) => void;
11
+ /** Replaces the log with a saved one, e.g. when a design loads. Undo starts fresh. */
12
+ replaceAll: (entries: ChangeEntry[]) => void;
13
+ /** Records a change to themes or other mode sets. */
14
+ logDimensions: (before: TokenDimensions, after: TokenDimensions) => void;
15
+ /** Called with each new entry, e.g. to turn an agent's reason into a note. */
16
+ onEntry: (listener: (entry: ChangeEntry) => void) => () => void;
17
+ };
18
+ /**
19
+ * Keeps a readable history of every change: who made it, why, and the values
20
+ * before and after. It follows undo and redo, marking entries undone and
21
+ * back, and records token and theme edits too.
22
+ */
23
+ export declare const ChangeLogProvider: ({ initialEntries, onChange, children, }: {
24
+ initialEntries?: ChangeEntry[];
25
+ onChange?: (entries: ChangeEntry[]) => void;
26
+ children: ReactNode;
27
+ }) => import("react").JSX.Element;
28
+ export declare const useChangeLog: () => ChangeLogStore;
29
+ export {};
@@ -0,0 +1,41 @@
1
+ import { type Action, type DesignerStore, type Role, type Rule, type State } from "@reallygoodwork/design-ui-core";
2
+ import type { Breakpoint, CSSVars, Layer, LayerType } from "../lib/Types";
3
+ export type { Action, DesignerStore, State };
4
+ type UseDesignerProps = {
5
+ /**
6
+ * The initial layers for uncontrolled mode.
7
+ */
8
+ defaultLayers?: Layer[];
9
+ /**
10
+ * The current layers for controlled mode.
11
+ */
12
+ layers?: Layer[];
13
+ /**
14
+ * The default layer types for the designer.
15
+ */
16
+ layerTypes?: LayerType[];
17
+ /**
18
+ * Callback for when the layers change in controlled mode.
19
+ */
20
+ onLayersChange?: (layers: Layer[]) => void;
21
+ /**
22
+ * The initial breakpoints (responsive frames).
23
+ */
24
+ breakpoints?: Breakpoint[];
25
+ /**
26
+ * Shared document-level styles.
27
+ */
28
+ frameStyles?: CSSVars;
29
+ /** The editing rules to start with. */
30
+ rules?: Rule[];
31
+ /** Who is editing. Builders aren't limited by rules. Defaults to builder. */
32
+ role?: Role;
33
+ };
34
+ /**
35
+ * The core hook for the designer state management.
36
+ */
37
+ export declare const useDesigner: ({ defaultLayers, layers, onLayersChange, layerTypes, breakpoints, frameStyles, rules, role, }: UseDesignerProps) => {
38
+ state: State;
39
+ dispatch: (action: Action) => void;
40
+ store: DesignerStore;
41
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Hook to get a function to dispatch actions to the designer state.
3
+ * Returns the stable `dispatch` and never subscribes to state, so callers
4
+ * don't re-render on state changes.
5
+ */
6
+ export declare const useDesignerAction: () => (action: import("@reallygoodwork/design-ui-core").Action) => void;
@@ -0,0 +1,14 @@
1
+ import { type ActionMeta, type DesignDocument } from "@reallygoodwork/design-ui-core";
2
+ import { type NewAnnotation } from "./useAnnotations";
3
+ import type { Action } from "./useDesigner";
4
+ /** Everything about a design, as JSON: what an agent reads, or what a link would load. */
5
+ export type { DesignDocument } from "@reallygoodwork/design-ui-core";
6
+ /**
7
+ * The editor for hosts and agents: make changes that say who and why, leave
8
+ * annotations, and read the whole design out as one JSON document.
9
+ */
10
+ export declare const useDesignerApi: () => {
11
+ dispatch: (action: Action, meta?: ActionMeta) => import("@reallygoodwork/design-ui-core").Rejection | null | undefined;
12
+ annotate: (annotation: NewAnnotation) => string;
13
+ exportDocument: () => DesignDocument;
14
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Hook to access the designer state and dispatch. Subscribes to the whole
3
+ * state, so prefer `useDesignerSelector` or a slice hook where possible.
4
+ * Throws an error if used outside of a `DesignerProvider`.
5
+ */
6
+ export declare const useDesignerContext: () => {
7
+ state: import("@reallygoodwork/design-ui-core").State;
8
+ dispatch: (action: import("@reallygoodwork/design-ui-core").Action) => void;
9
+ };
@@ -0,0 +1,8 @@
1
+ import type { State } from "./useDesigner";
2
+ /**
3
+ * Subscribe to a slice of the designer state. The component re-renders only
4
+ * when the selected value changes according to `isEqual` (default `Object.is`).
5
+ * Selectors may return derived objects: pass a structural `isEqual` so equal
6
+ * results keep their previous reference.
7
+ */
8
+ export declare const useDesignerSelector: <T>(selector: (state: State) => T, isEqual?: (a: T, b: T) => boolean) => T;
@@ -0,0 +1,33 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * Maps breakpoint ids to their frame root element (today `.breakpoint-content`)
4
+ * and answers every query about the design DOM. Nothing else should call
5
+ * `document.querySelector` / `document.elementsFromPoint` on design nodes, so
6
+ * the frame root can later move into a shadow root without touching callers.
7
+ */
8
+ export type FrameRegistry = {
9
+ register: (breakpointId: string, el: HTMLElement) => void;
10
+ unregister: (breakpointId: string, el?: HTMLElement) => void;
11
+ getFrameRoot: (breakpointId: string) => HTMLElement | null;
12
+ /**
13
+ * A layer's element inside one breakpoint's frame. With no breakpoint id (or
14
+ * an unregistered one), the first registered frame that contains it.
15
+ */
16
+ queryLayer: (breakpointId: string | null, layerId: string) => HTMLElement | null;
17
+ /** Every layer element in every registered frame. */
18
+ getAllLayerElements: () => HTMLElement[];
19
+ /**
20
+ * Layer ids under a point, shallowest (parent) first and unfiltered, plus the
21
+ * breakpoint that was hit.
22
+ */
23
+ layersAtPoint: (x: number, y: number) => {
24
+ layerIds: string[];
25
+ breakpointId: string | null;
26
+ };
27
+ };
28
+ export declare const createFrameRegistry: () => FrameRegistry;
29
+ /** One registry per Designer instance. */
30
+ export declare const FrameRegistryProvider: ({ children, }: {
31
+ children: ReactNode;
32
+ }) => import("react").JSX.Element;
33
+ export declare const useFrameRegistry: () => FrameRegistry;
@@ -0,0 +1,31 @@
1
+ import type { CSSVars } from "../lib/Types";
2
+ export type FrameStyleValue = {
3
+ /**
4
+ * The current value for this CSS property.
5
+ */
6
+ value: string | undefined;
7
+ /**
8
+ * Set the value for this frame style.
9
+ */
10
+ setValue: (value: string) => void;
11
+ /**
12
+ * Clear the value for this frame style.
13
+ */
14
+ clearValue: () => void;
15
+ };
16
+ /**
17
+ * Hook to get and set frame-level styles (document-level styles).
18
+ * These are shared across all breakpoints, like body styles.
19
+ *
20
+ * @param cssProperty - The CSS property to manage (e.g., "--font-family")
21
+ * @returns Object with value and setter functions
22
+ */
23
+ export declare const useFrameStyle: (cssProperty: string) => FrameStyleValue;
24
+ /**
25
+ * Hook to get all frame styles.
26
+ */
27
+ export declare const useFrameStyles: () => CSSVars;
28
+ /**
29
+ * Hook to update multiple frame styles at once.
30
+ */
31
+ export declare const useUpdateFrameStyles: () => (css: Record<string, string>) => void;
@@ -0,0 +1,20 @@
1
+ /** Installed fonts, which Google Fonts rejects with a 400. */
2
+ export declare const SYSTEM_FONTS: string[];
3
+ interface UseGoogleFontsOptions {
4
+ weights?: number[];
5
+ display?: "auto" | "block" | "swap" | "fallback" | "optional";
6
+ }
7
+ /**
8
+ * Hook to dynamically load Google Fonts
9
+ */
10
+ export declare const useGoogleFonts: () => {
11
+ loadFont: (rawFontFamily: string, options?: UseGoogleFontsOptions) => void;
12
+ unloadFont: (fontFamily: string) => void;
13
+ preloadFont: (fontFamily: string) => void;
14
+ isLoaded: (fontFamily: string) => boolean;
15
+ };
16
+ /**
17
+ * Hook to auto-load a font when a component mounts
18
+ */
19
+ export declare const useLoadFont: (fontFamily: string | undefined, options?: UseGoogleFontsOptions) => void;
20
+ export {};
@@ -0,0 +1,6 @@
1
+ type HistoryFlags = {
2
+ canUndo: boolean;
3
+ canRedo: boolean;
4
+ };
5
+ export declare const useHistory: () => HistoryFlags;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare const useKeybindings: () => void;
@@ -0,0 +1,7 @@
1
+ import type { Layer } from "../lib/Types";
2
+ /**
3
+ * Select one layer by id, nested with its children. The returned object keeps
4
+ * its identity while that layer and its subtree are unchanged, so consumers
5
+ * only re-render when it is edited.
6
+ */
7
+ export declare const useLayer: (id: string) => Layer | null;
@@ -0,0 +1,15 @@
1
+ import type { Layer } from "../lib/Types";
2
+ type Dimensions = {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ /**
7
+ * Hook to get the layout dimensions of a layer element in the active
8
+ * breakpoint's frame, in unzoomed CSS pixels. Kept current with a
9
+ * `ResizeObserver`.
10
+ *
11
+ * @param layer - The layer to get dimensions for
12
+ * @returns Object with width and height in pixels, or null if element not found
13
+ */
14
+ export declare const useLayerDimensions: (layer: Layer | undefined) => Dimensions | null;
15
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { LayerType } from "../lib/Types";
2
+ /**
3
+ * The registered layer types. Core stores them as definitions; the editor
4
+ * only ever registers full layer types (`Designer` and `DesignerProvider`
5
+ * take `LayerType[]`), so they carry a renderer and an icon.
6
+ */
7
+ export declare const useLayerTypes: () => LayerType[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Hook to get the current layers, nested, from the designer state.
3
+ * The array is memoised: it keeps its identity while the layers are unchanged.
4
+ */
5
+ export declare const useLayers: () => import("@reallygoodwork/design-ui-core").Layer[];
@@ -0,0 +1,6 @@
1
+ import type { Layer } from "../lib/Types";
2
+ /**
3
+ * Hook to get the currently selected layers from the designer state.
4
+ * Uses the id index so nested layers can be selected too.
5
+ */
6
+ export declare const useSelectedLayers: () => Layer[];