@codefluss/base-types 0.0.2-alpha.1 → 0.0.2-alpha.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.
@@ -1,486 +1,925 @@
1
1
  /**
2
2
  * Dependency Injection Types
3
3
  *
4
- * These types define the external dependencies that the plugin requires
5
- * from the host application. All dependencies must be injected via props.
4
+ * Defines the external dependencies that plugins require from the host
5
+ * application. All dependencies are injected via props — plugins never
6
+ * import host-application code directly.
7
+ *
8
+ * The **plugin-driven architecture** ensures plugins are self-contained:
9
+ * the host provides Design System tokens, utility functions, a renderer
10
+ * component, and optional callbacks through these interfaces.
11
+ *
12
+ * @see {@link PluginDependencies} — Top-level dependency container
13
+ * @see {@link PluginDesignSystem} — Design token access API
14
+ * @see {@link PluginUtils} — Shared utility functions
15
+ * @see {@link PluginCallbacks} — Host communication callbacks
6
16
  *
7
17
  * @package @codefluss/base-types
8
18
  * @version 1.0.0
9
19
  */
10
20
  import type { ComponentType } from 'react';
11
21
  /**
12
- * Responsive font size values for different breakpoints
22
+ * Responsive font size values for different viewport breakpoints.
23
+ *
24
+ * Each value is a CSS font-size string (e.g., `'1rem'`, `'16px'`).
25
+ *
26
+ * @see {@link DesignSystemFont.responsive}
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const sizes: ResponsiveFontSizes = {
31
+ * mobile: '1rem',
32
+ * tablet: '1.25rem',
33
+ * desktop: '1.5rem',
34
+ * };
35
+ * ```
13
36
  */
14
37
  export interface ResponsiveFontSizes {
38
+ /** Font size on mobile viewports */
15
39
  mobile: string;
40
+ /** Font size on tablet viewports */
16
41
  tablet: string;
42
+ /** Font size on desktop viewports */
17
43
  desktop: string;
18
44
  }
19
45
  /**
20
- * Responsive line height values for different breakpoints
46
+ * Responsive line height values for different viewport breakpoints.
47
+ *
48
+ * Values are unitless multipliers (e.g., `1.4` means 140% of font size).
49
+ *
50
+ * @see {@link DesignSystemFont.responsiveLineHeight}
21
51
  */
22
52
  export interface ResponsiveLineHeights {
53
+ /** Line height on mobile viewports */
23
54
  mobile: number;
55
+ /** Line height on tablet viewports */
24
56
  tablet: number;
57
+ /** Line height on desktop viewports */
25
58
  desktop: number;
26
59
  }
27
60
  /**
28
- * Design System Font Configuration
61
+ * Design System font configuration for a single typography preset.
62
+ *
63
+ * Each preset defines a complete typographic style — family, size, weight,
64
+ * line-height, and optional responsive overrides.
65
+ *
66
+ * @see {@link PluginDesignSystem.fonts}
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const heading1: DesignSystemFont = {
71
+ * family: '"Inter", sans-serif',
72
+ * size: '2.5rem',
73
+ * weight: '700',
74
+ * lineHeight: '1.2',
75
+ * element: 'h1',
76
+ * responsive: { mobile: '1.75rem', tablet: '2rem', desktop: '2.5rem' },
77
+ * };
78
+ * ```
29
79
  */
30
80
  export interface DesignSystemFont {
81
+ /** CSS `font-family` value (e.g., `'"Inter", sans-serif'`) */
31
82
  family: string;
83
+ /** CSS `font-size` value — desktop default (e.g., `'2.5rem'`) */
32
84
  size: string;
85
+ /** CSS `font-weight` value (e.g., `'700'`, `'bold'`) */
33
86
  weight: string;
87
+ /** CSS `line-height` value (e.g., `'1.2'`, `'28px'`) */
34
88
  lineHeight: string;
89
+ /**
90
+ * Recommended HTML element for this preset (e.g., `'h1'`, `'h2'`, `'p'`).
91
+ * Used by heading/paragraph plugins to pick the semantic element.
92
+ */
35
93
  element?: string;
94
+ /**
95
+ * Per-viewport font size overrides.
96
+ * When provided, the plugin should apply these sizes at each breakpoint.
97
+ * @see {@link ResponsiveFontSizes}
98
+ */
36
99
  responsive?: ResponsiveFontSizes;
100
+ /**
101
+ * Per-viewport line-height overrides.
102
+ * @see {@link ResponsiveLineHeights}
103
+ */
37
104
  responsiveLineHeight?: ResponsiveLineHeights;
38
105
  }
39
106
  /**
40
- * Design System Color Configuration
107
+ * Design System color configuration for a single color preset.
108
+ *
109
+ * @see {@link PluginDesignSystem.colors}
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const primary: DesignSystemColor = { value: '#3b82f6', label: 'Primary' };
114
+ * ```
41
115
  */
42
116
  export interface DesignSystemColor {
117
+ /** CSS color value (hex, rgb, hsl, or CSS variable) */
43
118
  value: string;
119
+ /** Human-readable label displayed in color pickers */
44
120
  label: string;
45
121
  }
46
122
  /**
47
- * Box Model Value - Single side values
123
+ * Four-sided box model value for spacing (padding / margin / gap).
124
+ *
125
+ * @see BoxModelValue in `common-types.ts` for the canonical definition.
126
+ * This is a parallel declaration required by the dependencies module.
48
127
  */
49
128
  export interface BoxModelValue {
129
+ /** Top spacing in pixels */
50
130
  top: number;
131
+ /** Right spacing in pixels */
51
132
  right: number;
133
+ /** Bottom spacing in pixels */
52
134
  bottom: number;
135
+ /** Left spacing in pixels */
53
136
  left: number;
54
137
  }
55
138
  /**
56
- * Grid Preset Values (Container-specific)
57
- * Clean camelCase naming
139
+ * Grid preset values for container grid layout configuration.
140
+ *
141
+ * Defines the complete grid parameters: columns, rows, gaps, and alignment.
142
+ * Uses clean camelCase naming.
143
+ *
144
+ * @see {@link DesignSystemGrid}
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const defaultGrid: GridPresetValues = {
149
+ * columns: 3,
150
+ * rows: 1,
151
+ * columnGap: 16,
152
+ * rowGap: 16,
153
+ * maxWidth: 1200,
154
+ * margin: 'auto',
155
+ * alignmentHorizontal: 'stretch',
156
+ * alignmentVertical: 'start',
157
+ * alignmentContent: 'start',
158
+ * };
159
+ * ```
58
160
  */
59
161
  export interface GridPresetValues {
162
+ /** Number of grid columns */
60
163
  columns: number;
164
+ /** Number of grid rows */
61
165
  rows: number;
166
+ /** Horizontal gap between columns in pixels */
62
167
  columnGap: number;
168
+ /** Vertical gap between rows in pixels */
63
169
  rowGap: number;
170
+ /** Maximum grid width in pixels */
64
171
  maxWidth: number;
172
+ /** Horizontal margin — number (px) or CSS string (e.g., `'auto'`) */
65
173
  margin: number | string;
174
+ /** CSS `justify-items` value (e.g., `'stretch'`, `'center'`) */
66
175
  alignmentHorizontal: string;
176
+ /** CSS `align-items` value (e.g., `'start'`, `'center'`, `'stretch'`) */
67
177
  alignmentVertical: string;
178
+ /** CSS `align-content` value (e.g., `'start'`, `'stretch'`) */
68
179
  alignmentContent: string;
69
180
  }
70
181
  /**
71
- * Responsive spacing values for different breakpoints
72
- * Only 3 viewports: mobile, tablet, desktop
182
+ * Responsive box model values — spacing for each viewport breakpoint.
183
+ *
184
+ * @see {@link BoxModelValue}
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * const padding: ResponsiveBoxValues = {
189
+ * mobile: { top: 8, right: 8, bottom: 8, left: 8 },
190
+ * tablet: { top: 16, right: 16, bottom: 16, left: 16 },
191
+ * desktop: { top: 24, right: 24, bottom: 24, left: 24 },
192
+ * };
193
+ * ```
73
194
  */
74
195
  export interface ResponsiveBoxValues {
196
+ /** Spacing values on mobile viewports */
75
197
  mobile: BoxModelValue;
198
+ /** Spacing values on tablet viewports */
76
199
  tablet: BoxModelValue;
200
+ /** Spacing values on desktop viewports */
77
201
  desktop: BoxModelValue;
78
202
  }
79
203
  /**
80
- * Spacing Preset - Combined margin + padding with responsive values
204
+ * Spacing preset combined margin and padding with responsive values.
205
+ *
206
+ * Presets are managed in the Design System and referenced by ID.
207
+ * Plugins use `spacingPresetId` to apply a preset, with optional per-element overrides.
208
+ *
209
+ * @see {@link DesignSystemSpacing.getPreset}
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const preset: SpacingPreset = {
214
+ * presetId: 'spacing-text-default',
215
+ * name: 'Text Default',
216
+ * margin: { mobile: { top: 0, ... }, tablet: { ... }, desktop: { ... } },
217
+ * padding: { mobile: { top: 8, ... }, tablet: { ... }, desktop: { ... } },
218
+ * };
219
+ * ```
81
220
  */
82
221
  export interface SpacingPreset {
222
+ /** Unique preset identifier (e.g., `'spacing-text-default'`, `'default'`) */
83
223
  presetId: string;
224
+ /** Human-readable preset name shown in the editor */
84
225
  name: string;
226
+ /** Responsive margin values (per-viewport) */
85
227
  margin: ResponsiveBoxValues;
228
+ /** Responsive padding values (per-viewport) */
86
229
  padding: ResponsiveBoxValues;
87
230
  }
88
231
  /**
89
- * Responsive spacing scale entry
232
+ * Responsive spacing scale entry — a single token in the spacing scale.
233
+ *
234
+ * Defines a spacing value that varies by viewport.
235
+ *
236
+ * @see {@link DesignSystemSpacing.scaleResponsive}
90
237
  */
91
238
  export interface ResponsiveSpacingScale {
239
+ /** Spacing value on mobile viewports */
92
240
  mobile: number;
241
+ /** Spacing value on tablet viewports */
93
242
  tablet: number;
243
+ /** Spacing value on desktop viewports */
94
244
  desktop: number;
245
+ /** CSS unit for this scale entry (e.g., `'px'`, `'rem'`) */
95
246
  unit: string;
96
247
  }
97
248
  /**
98
- * Design System Spacing Configuration
99
- * Clean, type-safe API
249
+ * Design System spacing configuration — provides spacing presets and scales.
250
+ *
251
+ * @see {@link PluginDesignSystem.spacing}
100
252
  */
101
253
  export interface DesignSystemSpacing {
102
- /** Spacing scale values */
254
+ /** Base spacing scale values (e.g., `[0, 4, 8, 12, 16, 24, 32, 48, 64]`) */
103
255
  scale: number[];
104
- /** Responsive spacing scales by token */
256
+ /** Responsive spacing scales keyed by design token name */
105
257
  scaleResponsive: Map<string, ResponsiveSpacingScale>;
106
258
  /**
107
- * Get a spacing preset by ID
108
- * @param presetId - The preset identifier
109
- * @returns The spacing preset (guaranteed to exist, falls back to 'default')
259
+ * Retrieve a spacing preset by ID.
260
+ *
261
+ * Guaranteed to return a valid preset falls back to `'default'`
262
+ * if the requested ID is not found.
263
+ *
264
+ * @param presetId - The preset identifier (e.g., `'spacing-text-default'`)
265
+ * @returns The spacing preset with margin and padding values
110
266
  */
111
267
  getPreset(presetId: string): SpacingPreset;
112
268
  }
113
269
  /**
114
- * Design System Grid Configuration
115
- * Clean, type-safe API
270
+ * Design System grid configuration — provides grid layout presets.
271
+ *
272
+ * @see {@link PluginDesignSystem.grid}
116
273
  */
117
274
  export interface DesignSystemGrid {
118
275
  /**
119
- * Get a grid preset by ID
120
- * @param presetId - The preset identifier
121
- * @returns The grid preset values (guaranteed to exist, falls back to 'default')
276
+ * Retrieve a grid preset by ID.
277
+ *
278
+ * Guaranteed to return valid values falls back to `'default'`
279
+ * if the requested ID is not found.
280
+ *
281
+ * @param presetId - The preset identifier (e.g., `'default'`, `'narrow'`)
282
+ * @returns Grid preset values (columns, rows, gaps, alignment)
122
283
  */
123
284
  getPreset(presetId: string): GridPresetValues;
124
285
  }
125
286
  /**
126
- * Breakpoint configuration for responsive design
287
+ * Breakpoint configuration for a single viewport.
288
+ *
289
+ * @see {@link DesignSystemBreakpoints}
127
290
  */
128
291
  export interface BreakpointConfig {
292
+ /** Minimum viewport width in pixels for this breakpoint */
129
293
  minWidth: number;
294
+ /** Breakpoint display name (e.g., `'Mobile'`, `'Tablet'`, `'Desktop'`) */
130
295
  name: string;
131
296
  }
132
297
  /**
133
- * Design System Breakpoints
298
+ * Design System breakpoint definitions for responsive design.
299
+ *
300
+ * @see {@link PluginDesignSystem.breakpoints}
301
+ *
302
+ * @example
303
+ * ```typescript
304
+ * const breakpoints: DesignSystemBreakpoints = {
305
+ * mobile: { minWidth: 0, name: 'Mobile' },
306
+ * tablet: { minWidth: 768, name: 'Tablet' },
307
+ * desktop: { minWidth: 1024, name: 'Desktop' },
308
+ * };
309
+ * ```
134
310
  */
135
311
  export interface DesignSystemBreakpoints {
312
+ /** Mobile breakpoint configuration */
136
313
  mobile: BreakpointConfig;
314
+ /** Tablet breakpoint configuration */
137
315
  tablet: BreakpointConfig;
316
+ /** Desktop breakpoint configuration */
138
317
  desktop: BreakpointConfig;
139
318
  }
140
319
  /**
141
- * Design System Layout Configuration
320
+ * Design System layout configuration — global layout defaults.
321
+ *
322
+ * @see {@link PluginDesignSystem.layout}
142
323
  */
143
324
  export interface DesignSystemLayout {
325
+ /** Maximum content width (CSS value, e.g., `'1200px'`) */
144
326
  maxWidth?: string;
327
+ /** Default gap between elements (CSS value) */
145
328
  gap?: string;
329
+ /** Default padding (CSS value) */
146
330
  padding?: string;
331
+ /** Default margin (CSS value) */
147
332
  margin?: string;
148
333
  }
149
334
  /**
150
- * Button Style Preset Configuration (Unified)
335
+ * Unified button style preset from the Design System.
336
+ *
337
+ * Contains all styling for a button variant: colors (per state),
338
+ * typography, spacing, border, effects, and animations.
339
+ * Matches the `design_system_button_styles` database table structure.
151
340
  *
152
- * Complete button style preset that replaces the separate
153
- * ButtonSizePreset and ButtonVariantPreset interfaces.
154
- * Matches design_system_button_styles table structure.
341
+ * @see {@link PluginDesignSystem.buttons}
342
+ *
343
+ * @example
344
+ * ```typescript
345
+ * const primary: ButtonStylePreset = {
346
+ * id: 'btn-1',
347
+ * presetId: 'primary',
348
+ * name: 'Primary',
349
+ * size: 'md',
350
+ * backgroundColorPresetId: 'primary',
351
+ * textColorPresetId: 'primary-foreground',
352
+ * defaultTransitionDuration: 150,
353
+ * hoverTransitionDuration: 150,
354
+ * activeTransitionDuration: 100,
355
+ * disabledOpacity: 0.5,
356
+ * isDefault: true,
357
+ * };
358
+ * ```
155
359
  */
156
360
  export interface ButtonStylePreset {
361
+ /** Database row ID */
157
362
  id: string;
363
+ /** Unique preset identifier (e.g., `'primary'`, `'secondary'`, `'ghost'`) */
158
364
  presetId: string;
365
+ /** Human-readable name shown in the editor */
159
366
  name: string;
367
+ /** Size variant (e.g., `'sm'`, `'md'`, `'lg'`) */
160
368
  size: string;
369
+ /** Design System font preset ID for button text */
161
370
  fontSizePresetId?: string;
371
+ /** CSS `font-weight` value */
162
372
  fontWeight?: string;
373
+ /** Spacing preset ID for internal padding */
163
374
  spacingPresetId?: string;
375
+ /** Border radius preset ID */
164
376
  borderRadiusPresetId?: string;
377
+ /** Box shadow preset ID */
165
378
  shadowPresetId?: string;
379
+ /** Focus ring preset ID (accessibility) */
166
380
  focusRingPresetId?: string;
381
+ /** Entry/exit animation preset ID */
167
382
  animationPresetId?: string;
383
+ /** Hover animation effect preset ID */
168
384
  hoverEffectPresetId?: string;
385
+ /** Background color preset ID (default state) */
169
386
  backgroundColorPresetId?: string;
387
+ /** Text color preset ID (default state) */
170
388
  textColorPresetId?: string;
389
+ /** Border color preset ID (default state) */
171
390
  borderColorPresetId?: string;
391
+ /** Background color preset ID on hover */
172
392
  hoverBackgroundColorPresetId?: string;
393
+ /** Text color preset ID on hover */
173
394
  hoverTextColorPresetId?: string;
395
+ /** Border color preset ID on hover */
174
396
  hoverBorderColorPresetId?: string;
397
+ /** Background color preset ID when pressed */
175
398
  activeBackgroundColorPresetId?: string;
399
+ /** Text color preset ID when pressed */
176
400
  activeTextColorPresetId?: string;
401
+ /** Border color preset ID when pressed */
177
402
  activeBorderColorPresetId?: string;
403
+ /** Default state transition duration in milliseconds */
178
404
  defaultTransitionDuration: number;
405
+ /** Hover state transition duration in milliseconds */
179
406
  hoverTransitionDuration: number;
407
+ /** Active/pressed state transition duration in milliseconds */
180
408
  activeTransitionDuration: number;
409
+ /** Opacity applied when the button is disabled (0–1) */
181
410
  disabledOpacity: number;
411
+ /** CSS `text-decoration` in default state */
182
412
  defaultTextDecoration?: string;
413
+ /** CSS `text-decoration` on hover */
183
414
  hoverTextDecoration?: string;
415
+ /** CSS `text-decoration` when active/pressed */
184
416
  activeTextDecoration?: string;
417
+ /** CSS `text-transform` in default state */
185
418
  defaultTextTransform?: string;
419
+ /** CSS `text-transform` on hover */
186
420
  hoverTextTransform?: string;
421
+ /** CSS `text-transform` when active/pressed */
187
422
  activeTextTransform?: string;
423
+ /** Description of when/where to use this preset */
188
424
  usageDescription?: string;
425
+ /** Whether this is the default preset for new button instances */
189
426
  isDefault: boolean;
190
427
  }
191
428
  /**
192
- * @deprecated Use ButtonStylePreset instead
193
- * Legacy Button Size Preset Configuration
429
+ * Legacy button size preset configuration.
430
+ *
431
+ * @deprecated Use {@link ButtonStylePreset} instead — this interface
432
+ * will be removed in a future version.
194
433
  */
195
434
  export interface ButtonSizePreset {
435
+ /** Button preset ID */
196
436
  button_id: string;
437
+ /** Preset display name */
197
438
  name: string;
439
+ /** CSS padding value */
198
440
  padding: string;
441
+ /** CSS font-size value */
199
442
  fontSize: string;
443
+ /** Icon size value */
200
444
  iconSize: string;
445
+ /** CSS min-height value */
201
446
  minHeight: string;
447
+ /** CSS border-radius value */
202
448
  borderRadius?: string;
449
+ /** CSS font-weight value */
203
450
  fontWeight?: string;
451
+ /** Description of intended usage */
204
452
  usage_description?: string;
205
453
  }
206
454
  /**
207
- * @deprecated Use ButtonStylePreset instead
208
- * Legacy Button Variant Preset Configuration
455
+ * Legacy button variant preset configuration.
456
+ *
457
+ * @deprecated Use {@link ButtonStylePreset} instead — this interface
458
+ * will be removed in a future version.
209
459
  */
210
460
  export interface ButtonVariantPreset {
461
+ /** Background color */
211
462
  background: string;
463
+ /** Background color on hover */
212
464
  hoverBackground: string;
465
+ /** Text color */
213
466
  textColor: string;
467
+ /** Border color */
214
468
  borderColor: string;
215
469
  }
216
470
  /**
217
- * Shadow Configuration
471
+ * Shadow configuration with optional dark-mode variant.
472
+ *
473
+ * @see {@link PluginDesignSystem.shadows}
474
+ *
475
+ * @example
476
+ * ```typescript
477
+ * const shadow: ShadowConfig = {
478
+ * value: '0 4px 6px rgba(0, 0, 0, 0.1)',
479
+ * dark: '0 4px 6px rgba(0, 0, 0, 0.3)',
480
+ * };
481
+ * ```
218
482
  */
219
483
  export interface ShadowConfig {
484
+ /** CSS `box-shadow` value for light mode */
220
485
  value: string;
486
+ /** CSS `box-shadow` value for dark mode (falls back to `value` if not set) */
221
487
  dark?: string;
222
488
  }
223
489
  /**
224
- * Accordion Style Preset Configuration
490
+ * Accordion style preset from the Design System.
225
491
  *
226
- * Complete accordion style preset for collapsible components.
227
- * Matches design_system_accordion_presets table structure.
492
+ * Contains all styling for collapsible accordion components: header/body
493
+ * colors, typography, spacing, animations, and state variants.
494
+ * Matches the `design_system_accordion_presets` database table structure.
495
+ *
496
+ * @see {@link PluginDesignSystem.accordions}
228
497
  */
229
498
  export interface AccordionStylePreset {
499
+ /** Database row ID */
230
500
  id: string;
501
+ /** Unique preset identifier (e.g., `'default'`, `'sm'`, `'lg'`) */
231
502
  presetId: string;
503
+ /** Human-readable preset name */
232
504
  name: string;
505
+ /** CSS height for the accordion header (e.g., `'48px'`) */
233
506
  headerHeight?: string;
507
+ /** Font preset ID for header text */
234
508
  headerFontSizePresetId?: string;
509
+ /** CSS `font-weight` for header text */
235
510
  headerFontWeight?: string;
511
+ /** Spacing preset ID for header padding */
236
512
  headerPaddingPresetId?: string;
513
+ /** Background color preset ID for header (default state) */
237
514
  headerBackgroundColorPresetId?: string;
515
+ /** Background color preset ID for header on hover */
238
516
  headerHoverBackgroundColorPresetId?: string;
517
+ /** Text color preset ID for header */
239
518
  headerTextColorPresetId?: string;
519
+ /** Border color preset ID for header */
240
520
  headerBorderColorPresetId?: string;
521
+ /** Minimum height for the accordion body (e.g., `'100px'`) */
241
522
  bodyMinHeight?: string;
523
+ /** Spacing preset ID for body padding */
242
524
  bodyPaddingPresetId?: string;
525
+ /** Background color preset ID for body */
243
526
  bodyBackgroundColorPresetId?: string;
527
+ /** Border color preset ID for body */
244
528
  bodyBorderColorPresetId?: string;
529
+ /** Border radius preset ID */
245
530
  borderRadiusPresetId?: string;
531
+ /** Box shadow preset ID */
246
532
  shadowPresetId?: string;
533
+ /** Outer spacing preset ID */
247
534
  spacingPresetId?: string;
535
+ /** Expand/collapse transition duration in milliseconds */
248
536
  transitionDuration: number;
537
+ /** CSS easing function (e.g., `'ease-in-out'`) */
249
538
  transitionEasing?: string;
539
+ /** Background color preset ID when expanded */
250
540
  expandedBackgroundColorPresetId?: string;
541
+ /** Text color preset ID when expanded */
251
542
  expandedTextColorPresetId?: string;
543
+ /** Description of when/where to use this preset */
252
544
  usageDescription?: string;
545
+ /** Whether this is the default preset for new accordion instances */
253
546
  isDefault: boolean;
254
547
  }
255
548
  /**
256
- * Form Style Preset Configuration (Unified)
549
+ * Unified form style preset from the Design System.
550
+ *
551
+ * Contains all styling for form elements: input fields, labels, descriptions,
552
+ * error states, and submit buttons. Matches the `design_system_form_styles`
553
+ * database table structure.
257
554
  *
258
- * Complete form style preset that contains all styling for form elements.
259
- * Matches design_system_form_styles table structure.
555
+ * @see {@link PluginDesignSystem.forms}
260
556
  */
261
557
  export interface FormStylePreset {
558
+ /** Database row ID */
262
559
  id: string;
560
+ /** Unique preset identifier (e.g., `'default'`, `'outlined'`) */
263
561
  presetId: string;
562
+ /** Human-readable preset name */
264
563
  name: string;
564
+ /** Visual variant (e.g., `'filled'`, `'outlined'`, `'underlined'`) */
265
565
  variant: string;
566
+ /** Size variant (e.g., `'sm'`, `'md'`, `'lg'`) */
266
567
  size: string;
568
+ /** Font preset ID for input text */
267
569
  fontSizePresetId?: string;
570
+ /** Horizontal padding in pixels */
268
571
  paddingX: number;
572
+ /** Vertical padding in pixels */
269
573
  paddingY: number;
574
+ /** Border width in pixels */
270
575
  borderWidth: number;
576
+ /** Border radius preset ID */
271
577
  borderRadiusPresetId?: string;
578
+ /** Box shadow preset ID */
272
579
  shadowPresetId?: string;
580
+ /** Focus ring preset ID */
273
581
  focusRingPresetId?: string;
582
+ /** Entry/exit animation preset ID */
274
583
  animationPresetId?: string;
584
+ /** Hover animation effect preset ID */
275
585
  hoverEffectPresetId?: string;
586
+ /** Input background color preset ID */
276
587
  backgroundColorPresetId?: string;
588
+ /** Input text color preset ID */
277
589
  textColorPresetId?: string;
590
+ /** Input border color preset ID */
278
591
  borderColorPresetId?: string;
592
+ /** Placeholder text color preset ID */
279
593
  placeholderColorPresetId?: string;
594
+ /** Focus ring color preset ID */
280
595
  focusRingColorPresetId?: string;
596
+ /** Background color preset ID on hover */
281
597
  hoverBackgroundColorPresetId?: string;
598
+ /** Border color preset ID on hover */
282
599
  hoverBorderColorPresetId?: string;
600
+ /** Opacity applied when the input is disabled (0–1) */
283
601
  disabledOpacity: number;
602
+ /** Border color preset ID in error state */
284
603
  errorBorderColorPresetId?: string;
604
+ /** Error message text color preset ID */
285
605
  errorTextColorPresetId?: string;
606
+ /** Button style preset ID for the form's submit button */
286
607
  submitButtonPresetId?: string;
608
+ /** Background color preset ID for the form container */
287
609
  containerBackgroundColorPresetId?: string;
610
+ /** Spacing preset ID for the form container */
288
611
  containerSpacingPresetId?: string;
612
+ /** Font preset ID for field labels */
289
613
  labelFontPresetId?: string;
614
+ /** Color preset ID for field labels */
290
615
  labelColorPresetId?: string;
616
+ /** Font preset ID for help/description text */
291
617
  descriptionFontPresetId?: string;
618
+ /** Color preset ID for help/description text */
292
619
  descriptionColorPresetId?: string;
620
+ /** Vertical gap between form fields in pixels */
293
621
  fieldGap?: number;
622
+ /** Description of when/where to use this preset */
294
623
  usageDescription?: string;
624
+ /** Whether this is the default preset for new form instances */
295
625
  isDefault: boolean;
296
626
  }
297
627
  /**
298
- * Design System API
628
+ * Design System API — the unified interface for accessing design tokens.
629
+ *
630
+ * Plugins receive this via {@link PluginDependencies.designSystem}.
631
+ * The host application provides an implementation backed by the database
632
+ * or configuration files.
633
+ *
634
+ * @see {@link PluginDependencies}
299
635
  *
300
- * Interface for accessing global design system values.
301
- * The host application must provide an implementation.
636
+ * @example
637
+ * ```typescript
638
+ * // Inside a plugin component
639
+ * const { designSystem } = dependencies;
640
+ * const font = designSystem.fonts.getPreset('heading-1');
641
+ * const color = designSystem.colors.getPreset('primary');
642
+ * const spacing = designSystem.spacing.getPreset('default');
643
+ * ```
302
644
  */
303
645
  export interface PluginDesignSystem {
646
+ /**
647
+ * Typography preset system.
648
+ * @see {@link DesignSystemFont}
649
+ */
304
650
  fonts: {
651
+ /**
652
+ * Get a font preset by ID.
653
+ * @param presetId - Font preset identifier (e.g., `'heading-1'`, `'body'`)
654
+ * @returns Font configuration or `undefined` if not found
655
+ */
305
656
  getPreset: (presetId: string) => DesignSystemFont | undefined;
306
657
  };
658
+ /**
659
+ * Color preset system.
660
+ * @see {@link DesignSystemColor}
661
+ */
307
662
  colors: {
663
+ /**
664
+ * Get a color preset by ID.
665
+ * @param presetId - Color preset identifier (e.g., `'primary'`, `'foreground'`)
666
+ * @returns Color configuration or `undefined` if not found
667
+ */
308
668
  getPreset: (presetId: string) => DesignSystemColor | undefined;
309
669
  };
670
+ /**
671
+ * Spacing system with presets and scales.
672
+ * @see {@link DesignSystemSpacing}
673
+ */
310
674
  spacing: DesignSystemSpacing;
675
+ /**
676
+ * Grid layout system (optional, container-specific).
677
+ * @see {@link DesignSystemGrid}
678
+ */
311
679
  grid?: DesignSystemGrid;
680
+ /**
681
+ * Layout preset system for global layout defaults.
682
+ * @see {@link DesignSystemLayout}
683
+ */
312
684
  layout: {
685
+ /**
686
+ * Get a layout preset by ID.
687
+ * @param presetId - Layout preset identifier
688
+ * @returns Layout configuration or `undefined` if not found
689
+ */
313
690
  getPreset: (presetId: string) => DesignSystemLayout | undefined;
314
691
  };
692
+ /**
693
+ * Viewport breakpoint configuration.
694
+ * @see {@link DesignSystemBreakpoints}
695
+ */
315
696
  breakpoints: {
697
+ /**
698
+ * Get all breakpoint configurations.
699
+ * @returns Mobile, tablet, and desktop breakpoint definitions
700
+ */
316
701
  getConfig: () => DesignSystemBreakpoints;
317
702
  };
318
703
  /**
319
- * Button System (optional)
320
- * Provides unified button style presets from design system database
321
- * Each preset contains colors, typography, spacing, and effects
704
+ * Button style preset system (optional).
705
+ *
706
+ * Provides unified button styling from the design system database.
707
+ * Each preset contains colors, typography, spacing, and effects.
708
+ *
709
+ * @see {@link ButtonStylePreset}
322
710
  */
323
711
  buttons?: {
324
712
  /**
325
- * Get button style preset by ID
326
- * @param presetId - Button preset identifier (e.g., 'primary', 'secondary', 'custom-1')
327
- * @returns Button style preset or undefined if not found
713
+ * Get a button style preset by ID.
714
+ * @param presetId - Button preset identifier (e.g., `'primary'`, `'secondary'`)
715
+ * @returns Button style preset or `undefined` if not found
328
716
  */
329
717
  getPreset: (presetId: string) => ButtonStylePreset | undefined;
330
718
  /**
331
- * List all available button style presets
332
- * @returns Array of button style presets sorted by sort_order
719
+ * List all available button style presets.
720
+ * @returns Array of button style presets sorted by sort order
333
721
  */
334
722
  listPresets?: () => ButtonStylePreset[];
335
723
  };
336
724
  /**
337
- * Form System (optional)
338
- * Provides unified form style presets from design system database
339
- * Each preset contains colors, typography, spacing, and effects for form elements
725
+ * Form style preset system (optional).
726
+ *
727
+ * Provides unified form element styling from the design system database.
728
+ *
729
+ * @see {@link FormStylePreset}
340
730
  */
341
731
  forms?: {
342
732
  /**
343
- * Get form style preset by ID
344
- * @param presetId - Form preset identifier (e.g., 'default', 'outlined', 'custom-1')
345
- * @returns Form style preset or undefined if not found
733
+ * Get a form style preset by ID.
734
+ * @param presetId - Form preset identifier (e.g., `'default'`, `'outlined'`)
735
+ * @returns Form style preset or `undefined` if not found
346
736
  */
347
737
  getPreset: (presetId: string) => FormStylePreset | undefined;
348
738
  /**
349
- * List all available form style presets
350
- * @returns Array of form style presets sorted by sort_order
739
+ * List all available form style presets.
740
+ * @returns Array of form style presets sorted by sort order
351
741
  */
352
742
  listPresets?: () => FormStylePreset[];
353
743
  };
354
744
  /**
355
- * Accordion System (optional)
356
- * Provides unified accordion style presets from design system database
357
- * Each preset contains colors, typography, spacing, and effects for accordion components
745
+ * Accordion style preset system (optional).
746
+ *
747
+ * Provides unified accordion styling from the design system database.
748
+ *
749
+ * @see {@link AccordionStylePreset}
358
750
  */
359
751
  accordions?: {
360
752
  /**
361
- * Get accordion style preset by ID
362
- * @param presetId - Accordion preset identifier (e.g., 'default', 'sm', 'lg', 'custom-1')
363
- * @returns Accordion style preset or undefined if not found
753
+ * Get an accordion style preset by ID.
754
+ * @param presetId - Accordion preset identifier (e.g., `'default'`, `'sm'`, `'lg'`)
755
+ * @returns Accordion style preset or `undefined` if not found
364
756
  */
365
757
  getPreset: (presetId: string) => AccordionStylePreset | undefined;
366
758
  /**
367
- * List all available accordion style presets
368
- * @returns Array of accordion style presets sorted by sort_order
759
+ * List all available accordion style presets.
760
+ * @returns Array of accordion style presets sorted by sort order
369
761
  */
370
762
  listPresets?: () => AccordionStylePreset[];
371
763
  };
372
764
  /**
373
- * Shadow System (optional)
374
- * Provides shadow presets with light and dark mode variants
765
+ * Shadow preset system (optional).
766
+ *
767
+ * Provides box-shadow values with optional dark-mode variants.
768
+ *
769
+ * @see {@link ShadowConfig}
375
770
  */
376
771
  shadows?: {
772
+ /**
773
+ * Get a shadow preset by ID.
774
+ * @param presetId - Shadow preset identifier (e.g., `'sm'`, `'md'`, `'lg'`)
775
+ * @returns Shadow configuration (guaranteed to exist)
776
+ */
377
777
  getPreset: (presetId: string) => ShadowConfig;
378
778
  };
379
779
  }
380
780
  /**
381
- * Utility Functions API
781
+ * Utility functions API injected into plugins by the host application.
382
782
  *
383
- * Interface for utility functions required by the plugin.
384
- * The host application must provide implementations.
783
+ * @see {@link PluginDependencies.utils}
385
784
  */
386
785
  export interface PluginUtils {
387
786
  /**
388
- * Class name utility (e.g., clsx, classnames, tailwind-merge)
389
- * Combines multiple class names intelligently
787
+ * Class name utility function (e.g., `clsx`, `classnames`, `tailwind-merge`).
788
+ *
789
+ * Combines and deduplicates class names intelligently.
790
+ *
791
+ * @param inputs - Class names, arrays, objects, or falsy values
792
+ * @returns Merged class name string
793
+ *
794
+ * @example
795
+ * ```typescript
796
+ * const { cn } = dependencies.utils;
797
+ * const className = cn('base', isActive && 'active', { 'selected': isSelected });
798
+ * ```
390
799
  */
391
800
  cn: (...inputs: any[]) => string;
392
801
  }
393
802
  /**
394
- * Plugin Renderer Props
803
+ * Props for the `PluginRenderer` component injected by the host application.
395
804
  *
396
- * Props interface for the PluginRenderer component.
397
- * This is injected by the host application to render child plugins.
805
+ * Container plugins use this to recursively render their child elements.
806
+ * The host provides the actual implementation that resolves plugin IDs
807
+ * to component instances.
808
+ *
809
+ * @see {@link PluginDependencies.PluginRenderer}
398
810
  */
399
811
  export interface PluginRendererProps {
400
812
  /**
401
- * Plugin ID to render (e.g., 'base-text', 'base-image')
813
+ * Plugin ID to render (e.g., `'base-text'`, `'base-image'`)
402
814
  */
403
815
  pluginId: string;
404
816
  /**
405
- * Element ID for tracking
817
+ * Unique element ID for tracking and callbacks
406
818
  */
407
819
  elementId: string;
408
820
  /**
409
- * Plugin data/configuration
821
+ * Plugin data / configuration object
410
822
  */
411
823
  data: Record<string, unknown>;
412
824
  /**
413
- * Current language code
825
+ * Current language code (ISO) for content resolution
414
826
  */
415
827
  language: string;
416
828
  /**
417
- * Is in editor mode?
829
+ * Whether the host is in editor mode (interactive editing enabled)
830
+ * @default false
418
831
  */
419
832
  isEditorMode?: boolean;
420
833
  /**
421
- * Is element selected?
834
+ * Whether this element is currently selected in the editor
835
+ * @default false
422
836
  */
423
837
  isSelected?: boolean;
424
838
  /**
425
- * Click handler
839
+ * Click handler for element selection
840
+ * @param id - Element ID that was clicked
426
841
  */
427
842
  onClick?: (id: string) => void;
428
843
  }
429
844
  /**
430
- * Plugin Callbacks
845
+ * Event callbacks for plugin-to-host communication.
846
+ *
847
+ * Plugins invoke these to notify the host application of user actions
848
+ * like content edits, child additions/removals, and layout changes.
431
849
  *
432
- * Event callbacks that plugins can use to communicate with the host application.
850
+ * @see {@link PluginDependencies.callbacks}
433
851
  */
434
852
  export interface PluginCallbacks {
435
853
  /**
436
- * Called when content changes (for text, rich-text components)
437
- * @param elementId - ID of the element
438
- * @param language - Language code
854
+ * Called when text content changes (for text, rich-text components).
855
+ *
856
+ * @param elementId - ID of the element being edited
857
+ * @param language - ISO language code of the content
439
858
  * @param content - New content value
440
859
  */
441
860
  onContentChange?: (elementId: string, language: string, content: string) => void;
442
861
  /**
443
- * Called when child element is dropped into container
444
- * @param containerId - ID of the container element
862
+ * Called when a child element is dropped into a container.
863
+ *
864
+ * @param containerId - ID of the receiving container
445
865
  * @param droppedElementId - ID of the dropped element
446
- * @param index - Optional insertion index
866
+ * @param index - Optional insertion index (append if omitted)
447
867
  */
448
868
  onChildAdded?: (containerId: string, droppedElementId: string, index?: number) => void;
449
869
  /**
450
- * Called when child element is removed from container
451
- * @param containerId - ID of the container element
870
+ * Called when a child element is removed from a container.
871
+ *
872
+ * @param containerId - ID of the container
452
873
  * @param removedElementId - ID of the removed element
453
874
  */
454
875
  onChildRemoved?: (containerId: string, removedElementId: string) => void;
455
876
  /**
456
- * Called when container layout is changed
457
- * @param containerId - ID of the container element
877
+ * Called when a container's layout mode changes.
878
+ *
879
+ * @param containerId - ID of the container
458
880
  * @param layoutMode - New layout mode
459
881
  */
460
882
  onLayoutChange?: (containerId: string, layoutMode: 'flexbox' | 'grid') => void;
461
883
  }
462
884
  /**
463
- * Complete Plugin Dependencies
885
+ * Complete plugin dependencies — everything a plugin receives from the host.
886
+ *
887
+ * This is the full dependency interface used by the `dependencies.ts` module.
888
+ * It includes the `PluginRenderer` component and optional callbacks,
889
+ * which are not present in the simplified version in `plugin-system.ts`.
890
+ *
891
+ * **Plugin-driven architecture:** Plugins never import host code directly.
892
+ * All external functionality is injected through this interface.
464
893
  *
465
- * All external dependencies that must be injected into the plugin.
466
- * PLUGIN-DRIVEN ARCHITECTURE: Plugins receive dependencies from the host app.
894
+ * @see {@link PluginDesignSystem} for design token access
895
+ * @see {@link PluginUtils} for utility functions
896
+ * @see {@link PluginRendererProps} for the renderer component props
897
+ * @see {@link PluginCallbacks} for event communication
467
898
  */
468
899
  export interface PluginDependencies {
469
900
  /**
470
901
  * Design System API for accessing global design tokens
902
+ * (fonts, colors, spacing, breakpoints, etc.).
903
+ * @see {@link PluginDesignSystem}
471
904
  */
472
905
  designSystem: PluginDesignSystem;
473
906
  /**
474
- * Utility functions (e.g., cn for classnames)
907
+ * Utility functions (e.g., `cn` for class name merging).
908
+ * @see {@link PluginUtils}
475
909
  */
476
910
  utils: PluginUtils;
477
911
  /**
478
- * PluginRenderer component for rendering child plugins
479
- * CRITICAL: Container plugins need this to render their NESTED children
912
+ * Component for recursively rendering child plugins inside containers.
913
+ *
914
+ * **Critical** for container plugins with `supportsChildren = true` —
915
+ * they use this to render their nested children.
916
+ *
917
+ * @see {@link PluginRendererProps}
480
918
  */
481
919
  PluginRenderer: ComponentType<PluginRendererProps>;
482
920
  /**
483
- * Optional callbacks for communication with host app
921
+ * Optional event callbacks for communicating with the host application.
922
+ * @see {@link PluginCallbacks}
484
923
  */
485
924
  callbacks?: PluginCallbacks;
486
925
  }