@you-agent-factory/components 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +38 -7
  3. package/dist/category-paths.d.ts +3 -0
  4. package/dist/charts/chart-state-panel.d.ts +11 -0
  5. package/dist/charts/chart.d.ts +35 -0
  6. package/dist/charts/index.d.ts +5 -0
  7. package/dist/charts/index.js +287 -0
  8. package/dist/chunks/action-row.js +39 -0
  9. package/dist/chunks/alert-panel.js +182 -0
  10. package/dist/chunks/button.js +193 -0
  11. package/dist/chunks/cn.js +6 -0
  12. package/dist/chunks/factory-emulator-controls.js +123 -0
  13. package/dist/chunks/package-form-field.js +546 -0
  14. package/dist/chunks/scroll-area.js +261 -0
  15. package/dist/chunks/surface-panel.js +73 -0
  16. package/dist/chunks/table-layout.js +292 -0
  17. package/dist/chunks/typography-roles.js +26 -0
  18. package/dist/chunks/typography.js +129 -0
  19. package/dist/chunks/widget-frame.js +344 -0
  20. package/dist/data-display/code-panel.d.ts +12 -0
  21. package/dist/data-display/data-table.d.ts +27 -0
  22. package/dist/data-display/description-list.d.ts +4 -0
  23. package/{src/data-display/index.ts → dist/data-display/index.d.ts} +4 -26
  24. package/dist/data-display/index.js +20 -0
  25. package/dist/data-display/table-layout.d.ts +8 -0
  26. package/dist/data-display/table.d.ts +14 -0
  27. package/dist/factory-emulator/factory-emulator-controls.d.ts +23 -0
  28. package/dist/factory-emulator/index.d.ts +6 -0
  29. package/dist/factory-emulator/index.js +6 -0
  30. package/dist/feedback/alert-panel-semantics.d.ts +11 -0
  31. package/dist/feedback/alert-panel.d.ts +29 -0
  32. package/dist/feedback/index.d.ts +6 -0
  33. package/dist/feedback/index.js +10 -0
  34. package/dist/feedback/skeleton.d.ts +2 -0
  35. package/dist/forms/index.d.ts +19 -0
  36. package/dist/forms/index.js +37 -0
  37. package/dist/forms/package-checkbox.d.ts +3 -0
  38. package/dist/forms/package-enum-select.d.ts +42 -0
  39. package/dist/forms/package-file-input.d.ts +3 -0
  40. package/dist/forms/package-form-field.d.ts +49 -0
  41. package/dist/forms/package-input.d.ts +6 -0
  42. package/dist/forms/package-native-select.d.ts +3 -0
  43. package/dist/forms/package-select.d.ts +32 -0
  44. package/dist/forms/package-textarea.d.ts +10 -0
  45. package/dist/forms/select-icons.d.ts +3 -0
  46. package/dist/graphs/graph-edge-path.d.ts +18 -0
  47. package/dist/graphs/graph-edge.d.ts +15 -0
  48. package/dist/graphs/graph-node-button.d.ts +11 -0
  49. package/dist/graphs/graph-node-handle-badge.d.ts +5 -0
  50. package/dist/graphs/graph-node-handle.d.ts +18 -0
  51. package/dist/graphs/graph-node-shell.d.ts +13 -0
  52. package/dist/graphs/graph-node-state-indicator.d.ts +6 -0
  53. package/dist/graphs/graph-node-state.d.ts +23 -0
  54. package/dist/graphs/graph-viewport-surface.d.ts +5 -0
  55. package/dist/graphs/index.d.ts +13 -0
  56. package/dist/graphs/index.js +614 -0
  57. package/{src/icons/index.ts → dist/icons/index.d.ts} +1 -2
  58. package/dist/icons/index.js +4 -0
  59. package/dist/index.d.ts +26 -0
  60. package/dist/index.js +145 -0
  61. package/dist/layout/action-row.d.ts +8 -0
  62. package/{src/layout/index.ts → dist/layout/index.d.ts} +1 -3
  63. package/dist/layout/index.js +9 -0
  64. package/dist/layout/surface-panel.d.ts +15 -0
  65. package/{src/navigation/index.ts → dist/navigation/index.d.ts} +1 -2
  66. package/dist/navigation/index.js +4 -0
  67. package/dist/overlays/collapsible.d.ts +5 -0
  68. package/dist/overlays/dialog.d.ts +16 -0
  69. package/dist/overlays/index.d.ts +10 -0
  70. package/dist/overlays/index.js +27 -0
  71. package/dist/overlays/overlay-layout.d.ts +6 -0
  72. package/dist/overlays/popover.d.ts +6 -0
  73. package/dist/overlays/scroll-area.d.ts +9 -0
  74. package/dist/primitives/button-link.d.ts +5 -0
  75. package/dist/primitives/button.d.ts +9 -0
  76. package/dist/primitives/icon-button-shell.d.ts +10 -0
  77. package/{src/primitives/index.ts → dist/primitives/index.d.ts} +2 -19
  78. package/dist/primitives/index.js +49 -0
  79. package/dist/primitives/package-text.d.ts +6 -0
  80. package/dist/primitives/typography-roles.d.ts +12 -0
  81. package/dist/primitives/typography.d.ts +36 -0
  82. package/dist/recipes/index.d.ts +14 -0
  83. package/dist/recipes/index.js +32 -0
  84. package/dist/recipes/widget-frame-content.d.ts +24 -0
  85. package/dist/recipes/widget-frame-disclosure.d.ts +33 -0
  86. package/dist/recipes/widget-frame-layout.d.ts +12 -0
  87. package/dist/recipes/widget-frame-skeleton.d.ts +2 -0
  88. package/dist/recipes/widget-frame-states.d.ts +15 -0
  89. package/dist/recipes/widget-frame-typography.d.ts +10 -0
  90. package/dist/recipes/widget-frame.d.ts +12 -0
  91. package/{src → dist}/styles.css +36 -0
  92. package/dist/testing/index.d.ts +4 -0
  93. package/dist/testing/index.js +16 -0
  94. package/dist/testing/render.d.ts +5 -0
  95. package/{src/tokens/index.ts → dist/tokens/index.d.ts} +1 -2
  96. package/dist/tokens/index.js +4 -0
  97. package/dist/utilities/cn.d.ts +1 -0
  98. package/{src/utilities/index.ts → dist/utilities/index.d.ts} +1 -3
  99. package/dist/utilities/index.js +6 -0
  100. package/package.json +65 -64
  101. package/docs/README.md +0 -83
  102. package/docs/button.md +0 -119
  103. package/docs/charts.md +0 -325
  104. package/docs/data-display-code-panel.md +0 -120
  105. package/docs/feedback-alert-panel.md +0 -117
  106. package/docs/feedback-skeleton.md +0 -54
  107. package/docs/forms-form-field.md +0 -490
  108. package/docs/forms-input-primitives.md +0 -311
  109. package/docs/forms-select-primitives.md +0 -362
  110. package/docs/graphs.md +0 -250
  111. package/docs/layout-display-primitives.md +0 -211
  112. package/docs/overlays.md +0 -414
  113. package/docs/table-data-table.md +0 -331
  114. package/docs/typography-roles.md +0 -182
  115. package/docs/widget-frame-recipes.md +0 -273
  116. package/src/category-paths.ts +0 -20
  117. package/src/charts/chart-state-panel.tsx +0 -103
  118. package/src/charts/chart.tsx +0 -287
  119. package/src/charts/index.ts +0 -21
  120. package/src/data-display/code-panel.tsx +0 -67
  121. package/src/data-display/data-table.tsx +0 -180
  122. package/src/data-display/description-list.tsx +0 -24
  123. package/src/data-display/table-layout.ts +0 -12
  124. package/src/data-display/table.tsx +0 -131
  125. package/src/feedback/alert-panel-semantics.ts +0 -75
  126. package/src/feedback/alert-panel.tsx +0 -187
  127. package/src/feedback/index.ts +0 -21
  128. package/src/feedback/skeleton.tsx +0 -16
  129. package/src/forms/index.ts +0 -73
  130. package/src/forms/package-checkbox.tsx +0 -50
  131. package/src/forms/package-enum-select.tsx +0 -185
  132. package/src/forms/package-file-input.tsx +0 -25
  133. package/src/forms/package-form-field.tsx +0 -202
  134. package/src/forms/package-input.tsx +0 -25
  135. package/src/forms/package-native-select.tsx +0 -25
  136. package/src/forms/package-select.tsx +0 -209
  137. package/src/forms/package-textarea.tsx +0 -35
  138. package/src/forms/select-icons.tsx +0 -35
  139. package/src/graphs/graph-edge-path.ts +0 -241
  140. package/src/graphs/graph-edge.tsx +0 -130
  141. package/src/graphs/graph-interactive-example.tsx +0 -187
  142. package/src/graphs/graph-node-button.tsx +0 -51
  143. package/src/graphs/graph-node-handle-badge.tsx +0 -108
  144. package/src/graphs/graph-node-handle.ts +0 -28
  145. package/src/graphs/graph-node-shell.tsx +0 -111
  146. package/src/graphs/graph-node-state-indicator.tsx +0 -47
  147. package/src/graphs/graph-node-state.ts +0 -111
  148. package/src/graphs/graph-viewport-surface.tsx +0 -27
  149. package/src/graphs/index.ts +0 -41
  150. package/src/index.ts +0 -209
  151. package/src/layout/action-row.tsx +0 -53
  152. package/src/layout/surface-panel.tsx +0 -91
  153. package/src/overlays/collapsible.tsx +0 -22
  154. package/src/overlays/dialog.tsx +0 -148
  155. package/src/overlays/index.ts +0 -31
  156. package/src/overlays/overlay-layout.ts +0 -9
  157. package/src/overlays/popover.tsx +0 -29
  158. package/src/overlays/scroll-area.tsx +0 -78
  159. package/src/primitives/button-link.tsx +0 -22
  160. package/src/primitives/button.tsx +0 -258
  161. package/src/primitives/icon-button-shell.tsx +0 -49
  162. package/src/primitives/package-text.tsx +0 -29
  163. package/src/primitives/typography-roles.ts +0 -12
  164. package/src/primitives/typography.tsx +0 -165
  165. package/src/recipes/index.ts +0 -61
  166. package/src/recipes/widget-frame-content.tsx +0 -114
  167. package/src/recipes/widget-frame-disclosure.tsx +0 -161
  168. package/src/recipes/widget-frame-layout.ts +0 -40
  169. package/src/recipes/widget-frame-skeleton.tsx +0 -16
  170. package/src/recipes/widget-frame-states.tsx +0 -99
  171. package/src/recipes/widget-frame-typography.ts +0 -19
  172. package/src/recipes/widget-frame.tsx +0 -84
  173. package/src/testing/index.ts +0 -13
  174. package/src/testing/render.tsx +0 -16
  175. package/src/utilities/cn.ts +0 -5
  176. /package/{src → dist}/styles/color-palette-presets.css +0 -0
  177. /package/{src → dist}/styles/color-role-tokens.css +0 -0
  178. /package/{src → dist}/styles/layout-role-tokens.css +0 -0
  179. /package/{src → dist}/styles/text-color-role-tokens.css +0 -0
  180. /package/{src → dist}/styles/typography-role-tokens.css +0 -0
  181. /package/{src → dist}/styles/typography-role-utilities.css +0 -0
  182. /package/{src → dist}/styles/typography-roles.css +0 -0
@@ -0,0 +1,614 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { forwardRef, useRef, useState, useEffect } from "react";
3
+ import { c as cn } from "../chunks/cn.js";
4
+ import { Position, Handle, getBezierPath, BaseEdge } from "@xyflow/react";
5
+ const GRAPH_NODE_CONTENT_MIN_HEIGHT_CLASS = "min-h-12";
6
+ const GRAPH_NODE_STATE_INDICATOR_HEIGHT_CLASS = "min-h-5";
7
+ function graphNodeShellStateClassName(state) {
8
+ switch (state) {
9
+ case "selected":
10
+ return cn(
11
+ "border-2 border-primary bg-primary-container",
12
+ "shadow-[0_0_0_1px_rgb(from_var(--color-primary)_r_g_b_/_0.28),0_0_0_4px_rgb(from_var(--color-primary)_r_g_b_/_0.08)]"
13
+ );
14
+ case "error":
15
+ return cn(
16
+ "border-2 border-dashed border-error bg-error-container",
17
+ "shadow-[0_0_0_3px_var(--color-error-container)]"
18
+ );
19
+ case "disabled":
20
+ return "border-outline-variant bg-surface-container text-on-surface";
21
+ case "loading":
22
+ return "border-outline bg-surface";
23
+ default:
24
+ return "";
25
+ }
26
+ }
27
+ function graphNodeButtonStateClassName(state) {
28
+ switch (state) {
29
+ case "selected":
30
+ return "ring-2 ring-primary/30";
31
+ case "error":
32
+ return "ring-2 ring-error/40";
33
+ case "disabled":
34
+ case "loading":
35
+ return "cursor-not-allowed";
36
+ default:
37
+ return "";
38
+ }
39
+ }
40
+ function graphNodeShellStateAttributes(state, stateLabel) {
41
+ return {
42
+ "aria-busy": state === "loading" ? true : void 0,
43
+ "aria-disabled": state === "disabled" ? true : void 0,
44
+ "aria-invalid": state === "error" ? true : void 0,
45
+ "aria-label": stateLabel,
46
+ "aria-selected": state === "selected" ? true : void 0,
47
+ "data-graph-node-state": state === "default" ? void 0 : state
48
+ };
49
+ }
50
+ function graphNodeButtonStateAttributes(state, stateLabel) {
51
+ return {
52
+ "aria-busy": state === "loading" ? true : void 0,
53
+ "aria-disabled": state === "disabled" ? true : void 0,
54
+ "aria-invalid": state === "error" ? true : void 0,
55
+ "aria-label": stateLabel,
56
+ "aria-pressed": state === "selected" ? true : void 0,
57
+ "data-graph-node-state": state === "default" ? void 0 : state
58
+ };
59
+ }
60
+ function graphNodeButtonIsDisabled(state, disabled) {
61
+ return disabled === true || state === "disabled" || state === "loading";
62
+ }
63
+ function defaultGraphNodeStateLabel(state) {
64
+ switch (state) {
65
+ case "selected":
66
+ return "Selected node";
67
+ case "disabled":
68
+ return "Disabled node";
69
+ case "loading":
70
+ return "Loading node";
71
+ case "error":
72
+ return "Error node";
73
+ default:
74
+ return void 0;
75
+ }
76
+ }
77
+ const GRAPH_NODE_BUTTON_BASE_CLASS = "nodrag nopan cursor-pointer border-0 bg-transparent p-0 text-left text-inherit focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-af-focus-ring disabled:cursor-not-allowed disabled:opacity-100";
78
+ const GraphNodeButton = forwardRef(function GraphNodeButton2({
79
+ className,
80
+ disabled,
81
+ graphState = "default",
82
+ onClick,
83
+ stateLabel,
84
+ type = "button",
85
+ ...props
86
+ }, ref) {
87
+ const isDisabled = graphNodeButtonIsDisabled(graphState, disabled);
88
+ return /* @__PURE__ */ jsx(
89
+ "button",
90
+ {
91
+ className: cn(
92
+ GRAPH_NODE_BUTTON_BASE_CLASS,
93
+ graphNodeButtonStateClassName(graphState),
94
+ className
95
+ ),
96
+ disabled: isDisabled,
97
+ onClick: isDisabled ? void 0 : onClick,
98
+ ref,
99
+ type,
100
+ ...graphNodeButtonStateAttributes(graphState, stateLabel),
101
+ ...props
102
+ }
103
+ );
104
+ });
105
+ const GraphViewportSurface = forwardRef(function GraphViewportSurface2({ children, className, role, ...props }, ref) {
106
+ return /* @__PURE__ */ jsx(
107
+ "section",
108
+ {
109
+ className: cn(
110
+ "relative min-h-0 overflow-hidden rounded-3xl border shadow-none transition-colors",
111
+ className
112
+ ),
113
+ "data-graph-viewport-surface": "true",
114
+ ref,
115
+ role: role ?? "region",
116
+ ...props,
117
+ children
118
+ }
119
+ );
120
+ });
121
+ function GraphNodeHandleBadge({ handle }) {
122
+ const position = handle.side === "left" ? Position.Left : Position.Right;
123
+ const overlayHandleStyle = anchoredHandleStyle(handle.side);
124
+ const isButton = handle.onButtonClick !== void 0;
125
+ if (handle.hidden) {
126
+ return /* @__PURE__ */ jsx(
127
+ Handle,
128
+ {
129
+ className: "pointer-events-none !top-1/2 opacity-0",
130
+ id: handle.id,
131
+ isConnectable: handle.connectable ?? false,
132
+ position,
133
+ style: overlayHandleStyle,
134
+ type: handle.type
135
+ }
136
+ );
137
+ }
138
+ const tone = handle.tone ?? "default";
139
+ return /* @__PURE__ */ jsx(
140
+ "div",
141
+ {
142
+ className: "pointer-events-none relative flex h-5 w-5 items-center justify-center",
143
+ "data-node-handle-badge": handle.id,
144
+ "data-node-handle-invalid": handle.validationError ? "true" : void 0,
145
+ "data-node-handle-tone": tone,
146
+ children: /* @__PURE__ */ jsx(
147
+ Handle,
148
+ {
149
+ "aria-disabled": isButton && handle.buttonDisabled ? true : void 0,
150
+ "aria-invalid": handle.validationError ? true : void 0,
151
+ "aria-label": handle.buttonAriaLabel ?? handle.label,
152
+ "aria-pressed": isButton ? handle.buttonPressed : void 0,
153
+ className: cn(
154
+ "pointer-events-auto absolute !top-1/2 !h-5 !w-5 !border-0 !bg-transparent",
155
+ "before:pointer-events-none before:absolute before:top-1/2 before:h-2.5 before:w-2.5 before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:border before:border-surface before:bg-[var(--node-handle-background)] before:shadow-sm before:transition before:content-['']",
156
+ handle.side === "left" ? "before:left-0" : "before:left-full",
157
+ handle.buttonPressed && "before:scale-125 before:shadow-[0_0_0_3px_var(--color-primary-container)]",
158
+ handle.variant === "valid-target" && "before:scale-125 before:shadow-[0_0_0_3px_var(--color-success-container)]",
159
+ handle.variant === "error" && "before:border-af-danger-border before:shadow-[0_0_0_3px_var(--color-error-container)] motion-safe:before:animate-pulse",
160
+ handle.validationError && "before:ring-2 before:ring-af-danger-border motion-safe:before:animate-pulse"
161
+ ),
162
+ id: handle.id,
163
+ isConnectable: handle.connectable ?? true,
164
+ onClick: handle.buttonDisabled ? void 0 : handle.onButtonClick,
165
+ onKeyDown: isButton && !handle.buttonDisabled ? (event) => {
166
+ if (event.key !== "Enter" && event.key !== " ") return;
167
+ event.preventDefault();
168
+ handle.onButtonClick?.();
169
+ } : void 0,
170
+ position,
171
+ role: isButton ? "button" : "img",
172
+ style: {
173
+ ...overlayHandleStyle,
174
+ "--node-handle-background": handleDotColor(tone),
175
+ opacity: handle.buttonDisabled ? 0.45 : void 0
176
+ },
177
+ title: handle.buttonTitle ?? handle.validationMessage,
178
+ tabIndex: isButton && !handle.buttonDisabled ? 0 : void 0,
179
+ type: handle.type
180
+ }
181
+ )
182
+ }
183
+ );
184
+ }
185
+ function handleDotColor(tone) {
186
+ switch (tone) {
187
+ case "assignment":
188
+ return "var(--color-success)";
189
+ case "continue":
190
+ return "var(--color-secondary)";
191
+ case "failure":
192
+ return "var(--color-error)";
193
+ case "input":
194
+ return "var(--color-success)";
195
+ case "output":
196
+ return "var(--color-success)";
197
+ case "rejection":
198
+ return "var(--color-warning)";
199
+ case "resource":
200
+ return "var(--color-black)";
201
+ case "worker":
202
+ return "var(--color-purple-500)";
203
+ default:
204
+ return "var(--color-success)";
205
+ }
206
+ }
207
+ function anchoredHandleStyle(side) {
208
+ return side === "left" ? {
209
+ left: "50%",
210
+ top: "50%",
211
+ transform: "translateY(-50%)"
212
+ } : {
213
+ left: "50%",
214
+ top: "50%",
215
+ transform: "translate(-100%, -50%)"
216
+ };
217
+ }
218
+ function GraphNodeStateIndicator({
219
+ state,
220
+ stateLabel
221
+ }) {
222
+ const label = stateLabel ?? defaultGraphNodeStateLabel(state);
223
+ const showIndicator = state === "loading" || state === "error";
224
+ return /* @__PURE__ */ jsx(
225
+ "div",
226
+ {
227
+ "aria-hidden": showIndicator ? void 0 : true,
228
+ className: cn(
229
+ GRAPH_NODE_STATE_INDICATOR_HEIGHT_CLASS,
230
+ "flex items-center gap-2 text-[0.65rem] font-semibold uppercase tracking-[0.08em]",
231
+ state === "error" ? "text-on-error-container" : "text-on-surface-variant",
232
+ !showIndicator && "invisible"
233
+ ),
234
+ "data-graph-node-state-indicator": showIndicator ? state : void 0,
235
+ children: state === "loading" ? /* @__PURE__ */ jsxs(Fragment, { children: [
236
+ /* @__PURE__ */ jsx(
237
+ "span",
238
+ {
239
+ "aria-hidden": "true",
240
+ className: "inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-outline border-t-primary",
241
+ "data-graph-node-loading-spinner": "true"
242
+ }
243
+ ),
244
+ /* @__PURE__ */ jsx("span", { children: label ?? "Loading" })
245
+ ] }) : state === "error" ? /* @__PURE__ */ jsx("span", { role: "alert", children: label ?? "Error" }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " " })
246
+ }
247
+ );
248
+ }
249
+ function GraphNodeShell({
250
+ children,
251
+ className = "",
252
+ handles,
253
+ nodeKind,
254
+ showStateIndicator = true,
255
+ state = "default",
256
+ stateLabel,
257
+ ...articleProps
258
+ }) {
259
+ const leftHandles = handles.filter((handle) => handle.side === "left");
260
+ const rightHandles = handles.filter((handle) => handle.side === "right");
261
+ return /* @__PURE__ */ jsxs(
262
+ "article",
263
+ {
264
+ className: cn(
265
+ "relative flex h-full min-w-0 w-full overflow-visible rounded-lg border border-outline bg-surface text-on-surface",
266
+ graphNodeShellStateClassName(state),
267
+ className
268
+ ),
269
+ "data-graph-node-kind": nodeKind,
270
+ ...graphNodeShellStateAttributes(state, stateLabel),
271
+ ...articleProps,
272
+ children: [
273
+ /* @__PURE__ */ jsx(NodeHandleRail, { handles: leftHandles, side: "left" }),
274
+ /* @__PURE__ */ jsx(NodeHandleRail, { handles: rightHandles, side: "right" }),
275
+ /* @__PURE__ */ jsxs(
276
+ "div",
277
+ {
278
+ className: cn(
279
+ "flex h-full min-w-0 w-full flex-col gap-1 py-3",
280
+ showStateIndicator && GRAPH_NODE_CONTENT_MIN_HEIGHT_CLASS,
281
+ leftHandles.length > 0 ? "pl-6 pr-3" : "px-3",
282
+ rightHandles.length > 0 && leftHandles.length > 0 ? "pr-6" : rightHandles.length > 0 ? "pl-3 pr-6" : null
283
+ ),
284
+ children: [
285
+ showStateIndicator ? /* @__PURE__ */ jsx(GraphNodeStateIndicator, { state, stateLabel }) : null,
286
+ children
287
+ ]
288
+ }
289
+ )
290
+ ]
291
+ }
292
+ );
293
+ }
294
+ function NodeHandleRail({
295
+ handles,
296
+ side
297
+ }) {
298
+ if (handles.length === 0) {
299
+ return null;
300
+ }
301
+ return /* @__PURE__ */ jsx(
302
+ "div",
303
+ {
304
+ className: cn(
305
+ "pointer-events-none absolute inset-y-0 z-20 w-6",
306
+ side === "left" ? "left-0" : "right-0"
307
+ ),
308
+ "data-node-handle-rail": side,
309
+ children: handles.map((handle, index) => /* @__PURE__ */ jsx(
310
+ "div",
311
+ {
312
+ className: cn(
313
+ "absolute top-0 flex -translate-y-1/2",
314
+ side === "left" ? "left-0 -translate-x-1/2" : "right-0 translate-x-1/2"
315
+ ),
316
+ style: { top: handlePosition(index, handles.length) },
317
+ children: /* @__PURE__ */ jsx(GraphNodeHandleBadge, { handle })
318
+ },
319
+ handle.id
320
+ ))
321
+ }
322
+ );
323
+ }
324
+ function handlePosition(index, count) {
325
+ return `${(index + 1) * 100 / (count + 1)}%`;
326
+ }
327
+ const CATMULL_ROM_ALPHA = 0.5;
328
+ const MIN_PARAMETER_DISTANCE = 1e-4;
329
+ const VIRTUAL_ENDPOINT_DISTANCE = 96;
330
+ function positionVector(position) {
331
+ switch (position) {
332
+ case Position.Left:
333
+ return { x: -1, y: 0 };
334
+ case Position.Right:
335
+ return { x: 1, y: 0 };
336
+ case Position.Top:
337
+ return { x: 0, y: -1 };
338
+ case Position.Bottom:
339
+ return { x: 0, y: 1 };
340
+ }
341
+ }
342
+ function pointDistance(first, second) {
343
+ return Math.hypot(second.x - first.x, second.y - first.y);
344
+ }
345
+ function catmullRomParameterDistance(first, second) {
346
+ return Math.max(
347
+ MIN_PARAMETER_DISTANCE,
348
+ pointDistance(first, second) ** CATMULL_ROM_ALPHA
349
+ );
350
+ }
351
+ function formatPathNumber(value) {
352
+ if (Object.is(value, -0)) {
353
+ return "0";
354
+ }
355
+ return Number.isInteger(value) ? `${value}` : value.toFixed(3);
356
+ }
357
+ function compactConsecutiveRoutePoints(routePoints) {
358
+ const compacted = [];
359
+ for (const point of routePoints) {
360
+ const previous = compacted.at(-1);
361
+ if (previous && previous.x === point.x && previous.y === point.y) {
362
+ continue;
363
+ }
364
+ compacted.push(point);
365
+ }
366
+ return compacted;
367
+ }
368
+ function virtualEndpoint(input) {
369
+ const distance = Math.max(
370
+ VIRTUAL_ENDPOINT_DISTANCE,
371
+ pointDistance(input.from, input.neighbor)
372
+ );
373
+ const scalar = input.mode === "before" ? -distance : distance;
374
+ return {
375
+ x: input.from.x + input.direction.x * scalar,
376
+ y: input.from.y + input.direction.y * scalar
377
+ };
378
+ }
379
+ function catmullRomTangent(input) {
380
+ const previousSpan = input.tCurrent - input.tPrevious;
381
+ const nextSpan = input.tNext - input.tCurrent;
382
+ const totalSpan = input.tNext - input.tPrevious;
383
+ return {
384
+ x: nextSpan * ((input.current.x - input.previous.x) / previousSpan - (input.next.x - input.previous.x) / totalSpan + (input.next.x - input.current.x) / nextSpan),
385
+ y: nextSpan * ((input.current.y - input.previous.y) / previousSpan - (input.next.y - input.previous.y) / totalSpan + (input.next.y - input.current.y) / nextSpan)
386
+ };
387
+ }
388
+ function buildWaypointCatmullRomPath(input) {
389
+ const routePoints = compactConsecutiveRoutePoints(input.routePoints);
390
+ if (routePoints.length <= 1) {
391
+ const [point] = routePoints;
392
+ return point ? `M ${formatPathNumber(point.x)} ${formatPathNumber(point.y)}` : "";
393
+ }
394
+ const lastPointIndex = routePoints.length - 1;
395
+ const [source] = routePoints;
396
+ const points = [
397
+ virtualEndpoint({
398
+ direction: positionVector(input.sourcePosition),
399
+ from: source,
400
+ mode: "before",
401
+ neighbor: routePoints[1]
402
+ }),
403
+ ...routePoints,
404
+ virtualEndpoint({
405
+ direction: {
406
+ x: -positionVector(input.targetPosition).x,
407
+ y: -positionVector(input.targetPosition).y
408
+ },
409
+ from: routePoints[lastPointIndex],
410
+ mode: "after",
411
+ neighbor: routePoints[lastPointIndex - 1]
412
+ })
413
+ ];
414
+ const segments = [
415
+ `M ${formatPathNumber(source.x)} ${formatPathNumber(source.y)}`
416
+ ];
417
+ for (let index = 1; index <= lastPointIndex; index += 1) {
418
+ const previous = points[index - 1];
419
+ const start = points[index];
420
+ const end = points[index + 1];
421
+ const next = points[index + 2];
422
+ const tPrevious = 0;
423
+ const tStart = tPrevious + catmullRomParameterDistance(previous, start);
424
+ const tEnd = tStart + catmullRomParameterDistance(start, end);
425
+ const tNext = tEnd + catmullRomParameterDistance(end, next);
426
+ const startTangent = catmullRomTangent({
427
+ current: start,
428
+ next: end,
429
+ previous,
430
+ tCurrent: tStart,
431
+ tNext: tEnd,
432
+ tPrevious
433
+ });
434
+ const endTangent = catmullRomTangent({
435
+ current: end,
436
+ next,
437
+ previous: start,
438
+ tCurrent: tEnd,
439
+ tNext,
440
+ tPrevious: tStart
441
+ });
442
+ const firstControl = {
443
+ x: start.x + startTangent.x / 3,
444
+ y: start.y + startTangent.y / 3
445
+ };
446
+ const secondControl = {
447
+ x: end.x - endTangent.x / 3,
448
+ y: end.y - endTangent.y / 3
449
+ };
450
+ segments.push(
451
+ [
452
+ "C",
453
+ formatPathNumber(firstControl.x),
454
+ formatPathNumber(firstControl.y),
455
+ `${formatPathNumber(secondControl.x)},`,
456
+ formatPathNumber(secondControl.y),
457
+ `${formatPathNumber(end.x)},`,
458
+ formatPathNumber(end.y)
459
+ ].join(" ")
460
+ );
461
+ }
462
+ return segments.join(" ");
463
+ }
464
+ function buildGraphEdgePathThroughWaypoints(input) {
465
+ const routePoints = [
466
+ { x: input.sourceX, y: input.sourceY },
467
+ ...input.waypoints ?? [],
468
+ { x: input.targetX, y: input.targetY }
469
+ ];
470
+ if (routePoints.length <= 2) {
471
+ const [path2, labelX, labelY] = getBezierPath({
472
+ sourcePosition: input.sourcePosition,
473
+ sourceX: input.sourceX,
474
+ sourceY: input.sourceY,
475
+ targetPosition: input.targetPosition,
476
+ targetX: input.targetX,
477
+ targetY: input.targetY
478
+ });
479
+ return { labelX, labelY, path: path2 };
480
+ }
481
+ const path = buildWaypointCatmullRomPath({
482
+ routePoints,
483
+ sourcePosition: input.sourcePosition,
484
+ targetPosition: input.targetPosition
485
+ });
486
+ const midpointIndex = Math.floor((routePoints.length - 1) / 2);
487
+ const labelPoint = routePoints[midpointIndex];
488
+ return {
489
+ labelX: labelPoint.x,
490
+ labelY: labelPoint.y,
491
+ path
492
+ };
493
+ }
494
+ const GRAPH_EDGE_TYPES = {
495
+ graphEdge: GraphEdge
496
+ };
497
+ function GraphEdge({
498
+ data,
499
+ edgeClassName = "graph-edge",
500
+ id,
501
+ interactionWidth,
502
+ labelClassName = "graph-edge-label pointer-events-none fill-on-surface-subtle text-[11px] font-semibold",
503
+ markerEnd,
504
+ selected,
505
+ sourcePosition,
506
+ sourceX,
507
+ sourceY,
508
+ style,
509
+ targetPosition,
510
+ targetX,
511
+ targetY
512
+ }) {
513
+ const edgeRef = useRef(null);
514
+ const [inspected, setInspected] = useState(false);
515
+ const edgeData = data ?? {};
516
+ const routedPath = buildGraphEdgePathThroughWaypoints({
517
+ sourcePosition,
518
+ sourceX,
519
+ sourceY,
520
+ targetPosition,
521
+ targetX,
522
+ targetY,
523
+ waypoints: edgeData.waypoints
524
+ });
525
+ const [fallbackPath, fallbackLabelX, fallbackLabelY] = getBezierPath({
526
+ sourcePosition,
527
+ sourceX,
528
+ sourceY,
529
+ targetPosition,
530
+ targetX,
531
+ targetY
532
+ });
533
+ const edgePath = edgeData.waypoints && edgeData.waypoints.length > 0 ? routedPath.path : fallbackPath;
534
+ const labelX = edgeData.waypoints && edgeData.waypoints.length > 0 ? routedPath.labelX : fallbackLabelX;
535
+ const labelY = edgeData.waypoints && edgeData.waypoints.length > 0 ? routedPath.labelY : fallbackLabelY;
536
+ useEffect(() => {
537
+ const edgeElement = edgeRef.current?.parentElement;
538
+ if (!edgeElement) {
539
+ return;
540
+ }
541
+ const show = () => setInspected(true);
542
+ const hide = () => setInspected(false);
543
+ edgeElement.addEventListener("mouseenter", show);
544
+ edgeElement.addEventListener("mouseleave", hide);
545
+ edgeElement.addEventListener("focusin", show);
546
+ edgeElement.addEventListener("focusout", hide);
547
+ return () => {
548
+ edgeElement.removeEventListener("mouseenter", show);
549
+ edgeElement.removeEventListener("mouseleave", hide);
550
+ edgeElement.removeEventListener("focusin", show);
551
+ edgeElement.removeEventListener("focusout", hide);
552
+ };
553
+ }, []);
554
+ const revealLabel = Boolean(
555
+ edgeData.label && (edgeData.alwaysShowLabel || inspected || selected)
556
+ );
557
+ return /* @__PURE__ */ jsxs(
558
+ "g",
559
+ {
560
+ className: edgeClassName,
561
+ "data-edge-id": id,
562
+ "data-label-visible": revealLabel ? "true" : "false",
563
+ ref: edgeRef,
564
+ children: [
565
+ /* @__PURE__ */ jsx(
566
+ BaseEdge,
567
+ {
568
+ interactionWidth,
569
+ markerEnd,
570
+ path: edgePath,
571
+ style
572
+ }
573
+ ),
574
+ edgeData.label ? /* @__PURE__ */ jsx(
575
+ "text",
576
+ {
577
+ className: labelClassName,
578
+ style: {
579
+ paintOrder: "stroke",
580
+ stroke: "var(--color-surface)",
581
+ strokeLinejoin: "round",
582
+ strokeWidth: 8
583
+ },
584
+ textAnchor: "middle",
585
+ x: labelX,
586
+ y: labelY,
587
+ children: edgeData.label
588
+ }
589
+ ) : null
590
+ ]
591
+ }
592
+ );
593
+ }
594
+ const COMPONENTS_CATEGORY = "graphs";
595
+ export {
596
+ COMPONENTS_CATEGORY,
597
+ GRAPH_EDGE_TYPES,
598
+ GRAPH_NODE_BUTTON_BASE_CLASS,
599
+ GRAPH_NODE_CONTENT_MIN_HEIGHT_CLASS,
600
+ GRAPH_NODE_STATE_INDICATOR_HEIGHT_CLASS,
601
+ GraphEdge,
602
+ GraphNodeButton,
603
+ GraphNodeHandleBadge,
604
+ GraphNodeShell,
605
+ GraphNodeStateIndicator,
606
+ GraphViewportSurface,
607
+ buildGraphEdgePathThroughWaypoints,
608
+ defaultGraphNodeStateLabel,
609
+ graphNodeButtonIsDisabled,
610
+ graphNodeButtonStateAttributes,
611
+ graphNodeButtonStateClassName,
612
+ graphNodeShellStateAttributes,
613
+ graphNodeShellStateClassName
614
+ };
@@ -1,4 +1,3 @@
1
1
  /** Stable category path for `@you-agent-factory/components/icons`. */
2
- export const COMPONENTS_CATEGORY = "icons" as const;
3
-
2
+ export declare const COMPONENTS_CATEGORY: "icons";
4
3
  export type ComponentsCategory = typeof COMPONENTS_CATEGORY;
@@ -0,0 +1,4 @@
1
+ const COMPONENTS_CATEGORY = "icons";
2
+ export {
3
+ COMPONENTS_CATEGORY
4
+ };
@@ -0,0 +1,26 @@
1
+ /** Stable package identifier for `@you-agent-factory/components` consumers. */
2
+ export declare const COMPONENTS_PACKAGE_NAME: "@you-agent-factory/components";
3
+ export type ComponentsPackageName = typeof COMPONENTS_PACKAGE_NAME;
4
+ export { COMPONENT_CATEGORY_EXPORT_PATHS, type ComponentCategoryExportPath, } from "./category-paths";
5
+ export { Button, ButtonLink, buttonVariants, IconButtonShell } from "./primitives";
6
+ export type { ButtonLinkProps, ButtonProps, IconButtonShellProps, } from "./primitives";
7
+ export { DescriptionList } from "./data-display/description-list";
8
+ export type { DescriptionListProps } from "./data-display/description-list";
9
+ export { AlertPanel, AlertPanelStatusLabel, AlertPanelText, AlertPanelTitle, Skeleton, } from "./feedback";
10
+ export type { AlertPanelProps, AlertPanelSemanticVariant, AlertPanelStatusLabelProps, AlertPanelTextProps, AlertPanelTitleProps, AlertPanelTone, AlertPanelVariant, } from "./feedback";
11
+ export { CodePanel, DataTable, Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow, codePanelVariants, tableCellTruncateClassName, tableCellWrapClassName, tableMinWidthWideClassName, tableNarrowContainerClassName, } from "./data-display";
12
+ export type { CodePanelProps, DataTableColumn, DataTableProps, DataTableState, TableProps, TableSize, } from "./data-display";
13
+ export { WidgetDetailCopy, WidgetEmptyState, WidgetEmptyStateText, WidgetEmptyStateTitle, WidgetErrorState, WidgetFrame, WidgetFrameDisclosure, WidgetFrameDisclosureIcon, WidgetFrameDisclosurePanel, WidgetFrameDisclosureTrigger, WidgetFrameSkeleton, WidgetLoadingState, WidgetSubtitle, WidgetSuccessState, WIDGET_FRAME_BODY_TEXT_CLASS, WIDGET_FRAME_MIN_WIDTH_CLASS, WIDGET_FRAME_OVERFLOW_TOLERANCE_PX, WIDGET_FRAME_RESPONSIVE_SHELL_CLASS, WIDGET_FRAME_SECTION_HEADING_CLASS, WIDGET_FRAME_STORY_SHELL_DATA_ATTR, WIDGET_FRAME_SUBTITLE_CLASS, WIDGET_FRAME_SUPPORTING_LABEL_CLASS, WIDGET_FRAME_SUPPORTING_LABELS_CLASS, WIDGET_FRAME_WIDE_BODY_CLASS, widgetFrameDetailCardClass, widgetFrameHasNoHorizontalOverflow, widgetFrameStoryShellStyle, } from "./recipes";
14
+ export type { WidgetDetailCopyProps, WidgetEmptyStateProps, WidgetEmptyStateTextProps, WidgetEmptyStateTitleProps, WidgetErrorStateProps, WidgetFrameDisclosureIconProps, WidgetFrameDisclosurePanelProps, WidgetFrameDisclosureProps, WidgetFrameDisclosureTriggerProps, WidgetFrameProps, WidgetLoadingStateProps, WidgetSubtitleProps, WidgetSuccessStateProps, } from "./recipes";
15
+ export { buildFormFieldAriaDescribedBy, EnumSelect, ENUM_SELECT_EMPTY_VALUE, FormDescription, FormError, FormField, FormFieldGroup, FormFieldGroupLabel, FormHelperText, FormLabel, FormSuccess, FormWarning, NativeSelect, OptionalEnumSelect, PackageCheckbox, PackageFileInput, PackageInput, PackageTextarea, ResetEnumSelect, Select, SELECT_EMPTY_STATE_VALUE, SelectContent, SelectEmpty, SelectField, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue, inputVariants, textareaVariants, } from "./forms";
16
+ export { FactoryEmulatorControls } from "./factory-emulator";
17
+ export type { FactoryEmulatorAction, FactoryEmulatorControlsProps, FactoryEmulatorRuntimeStatus, FactoryEmulatorSpeed, } from "./factory-emulator";
18
+ export type { EnumSelectOption, EnumSelectProps, FormDescriptionProps, FormErrorProps, FormFieldGroupLabelProps, FormFieldGroupProps, FormFieldMessageIds, FormFieldProps, FormHelperTextProps, FormLabelProps, FormSuccessProps, FormWarningProps, NativeSelectProps, OptionalEnumSelectProps, PackageCheckboxProps, PackageFileInputProps, PackageInputProps, PackageTextareaProps, ResetEnumSelectProps, SelectContentProps, SelectEmptyProps, SelectFieldProps, SelectItemProps, SelectLabelProps, SelectSeparatorProps, SelectTriggerProps, } from "./forms";
19
+ export { ActionRow } from "./layout/action-row";
20
+ export type { ActionRowProps } from "./layout/action-row";
21
+ export { SurfacePanel, surfacePanelVariants } from "./layout/surface-panel";
22
+ export type { SurfacePanelProps } from "./layout/surface-panel";
23
+ export { Code, Heading, Label, Text } from "./primitives/typography";
24
+ export type { CodeProps, HeadingProps, LabelProps, TextProps, TextVariant, } from "./primitives/typography";
25
+ export { Collapsible, CollapsibleContent, CollapsibleTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, OVERLAY_DIALOG_BODY_CLASS, OVERLAY_DIALOG_CONTENT_SHELL_CLASS, OVERLAY_FORM_GROUP_CLASS, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, } from "./overlays";
26
+ export type { DialogContentProps, ScrollAreaProps, ScrollBarProps, } from "./overlays";