@constructive-io/schema-builder 0.7.1 → 0.9.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 (66) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/{create-table-card-COzwEhdq.js → create-table-card-Cp96Mwkr.js} +13 -13
  3. package/dist/{create-table-card-COzwEhdq.js.map → create-table-card-Cp96Mwkr.js.map} +1 -1
  4. package/dist/{create-table-card--0VzN5yH.cjs → create-table-card-DXN0SCsn.cjs} +13 -13
  5. package/dist/{create-table-card--0VzN5yH.cjs.map → create-table-card-DXN0SCsn.cjs.map} +1 -1
  6. package/dist/editor-view-C5z6x0St.js +100 -0
  7. package/dist/editor-view-C5z6x0St.js.map +1 -0
  8. package/dist/editor-view-CKrOtZX_.cjs +141 -0
  9. package/dist/editor-view-CKrOtZX_.cjs.map +1 -0
  10. package/dist/{empty-state-card-5t7LygTB.cjs → empty-state-card-CV7DnIsA.cjs} +25 -17
  11. package/dist/empty-state-card-CV7DnIsA.cjs.map +1 -0
  12. package/dist/{empty-state-card-C-Nylatg.js → empty-state-card-sYoB01xr.js} +25 -17
  13. package/dist/empty-state-card-sYoB01xr.js.map +1 -0
  14. package/dist/fields.cjs +1 -1
  15. package/dist/fields.js +1 -1
  16. package/dist/index.cjs +70 -47
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.js +71 -48
  19. package/dist/index.js.map +1 -1
  20. package/dist/{indexes-view-CVZLjX89.cjs → indexes-view-BhRQc36j.cjs} +96 -125
  21. package/dist/indexes-view-BhRQc36j.cjs.map +1 -0
  22. package/dist/{indexes-view-C459lTHp.js → indexes-view-BkRtR8bd.js} +97 -126
  23. package/dist/indexes-view-BkRtR8bd.js.map +1 -0
  24. package/dist/indexes.cjs +1 -1
  25. package/dist/indexes.js +1 -1
  26. package/dist/{policies-view-CQP9A-ag.cjs → policies-view-DJTfKoYr.cjs} +192 -175
  27. package/dist/policies-view-DJTfKoYr.cjs.map +1 -0
  28. package/dist/{policies-view-A-FmHKS3.js → policies-view-OPigTnq3.js} +195 -178
  29. package/dist/policies-view-OPigTnq3.js.map +1 -0
  30. package/dist/policies.cjs +3 -3
  31. package/dist/policies.js +3 -3
  32. package/dist/{policy-config-form-BdbAHY7a.cjs → policy-config-form-CvHIN2iR.cjs} +5 -5
  33. package/dist/{policy-config-form-BdbAHY7a.cjs.map → policy-config-form-CvHIN2iR.cjs.map} +1 -1
  34. package/dist/{policy-config-form-Bx7TWk3Q.js → policy-config-form-PuVpbmcl.js} +5 -5
  35. package/dist/{policy-config-form-Bx7TWk3Q.js.map → policy-config-form-PuVpbmcl.js.map} +1 -1
  36. package/dist/{relationships-view-BQc_AHUo.cjs → relationships-view-CtPwFiIi.cjs} +210 -267
  37. package/dist/relationships-view-CtPwFiIi.cjs.map +1 -0
  38. package/dist/{relationships-view-QhPgBPiK.js → relationships-view-Db7zZAyz.js} +211 -268
  39. package/dist/relationships-view-Db7zZAyz.js.map +1 -0
  40. package/dist/relationships.cjs +1 -1
  41. package/dist/relationships.js +1 -1
  42. package/dist/{schema-builder-sidebar-Dv99hNGo.cjs → schema-builder-sidebar-BwpMkqyr.cjs} +135 -94
  43. package/dist/schema-builder-sidebar-BwpMkqyr.cjs.map +1 -0
  44. package/dist/{schema-builder-sidebar-CRwUC03L.js → schema-builder-sidebar-C3MMtjfg.js} +136 -95
  45. package/dist/schema-builder-sidebar-C3MMtjfg.js.map +1 -0
  46. package/dist/{table-editor-tS9seYfW.cjs → table-editor-CruD2mZQ.cjs} +414 -477
  47. package/dist/table-editor-CruD2mZQ.cjs.map +1 -0
  48. package/dist/{table-editor-5bkA0pji.js → table-editor-D80Qu4QF.js} +415 -478
  49. package/dist/table-editor-D80Qu4QF.js.map +1 -0
  50. package/dist/tables.cjs +1 -1
  51. package/dist/tables.d.cts +3 -1
  52. package/dist/tables.d.ts +3 -1
  53. package/dist/tables.js +1 -1
  54. package/package.json +8 -8
  55. package/dist/empty-state-card-5t7LygTB.cjs.map +0 -1
  56. package/dist/empty-state-card-C-Nylatg.js.map +0 -1
  57. package/dist/indexes-view-C459lTHp.js.map +0 -1
  58. package/dist/indexes-view-CVZLjX89.cjs.map +0 -1
  59. package/dist/policies-view-A-FmHKS3.js.map +0 -1
  60. package/dist/policies-view-CQP9A-ag.cjs.map +0 -1
  61. package/dist/relationships-view-BQc_AHUo.cjs.map +0 -1
  62. package/dist/relationships-view-QhPgBPiK.js.map +0 -1
  63. package/dist/schema-builder-sidebar-CRwUC03L.js.map +0 -1
  64. package/dist/schema-builder-sidebar-Dv99hNGo.cjs.map +0 -1
  65. package/dist/table-editor-5bkA0pji.js.map +0 -1
  66. package/dist/table-editor-tS9seYfW.cjs.map +0 -1
@@ -3,8 +3,8 @@ const require_invalidate_database_entities = require('./invalidate-database-enti
3
3
  const require_use_update_table = require('./use-update-table-vcoHVolI.cjs');
4
4
  const require_card_widths = require('./card-widths-CmIxkRfh.cjs');
5
5
  const require_keyboard_activation = require('./keyboard-activation-D-L0IU6Y.cjs');
6
- const require_empty_state_card = require('./empty-state-card-5t7LygTB.cjs');
7
- const require_create_table_card = require('./create-table-card--0VzN5yH.cjs');
6
+ const require_empty_state_card = require('./empty-state-card-CV7DnIsA.cjs');
7
+ const require_create_table_card = require('./create-table-card-DXN0SCsn.cjs');
8
8
  let _constructive_io_ui_stack = require("@constructive-io/ui/stack");
9
9
  let motion_react = require("motion/react");
10
10
  let react = require("react");
@@ -19,9 +19,9 @@ let _dnd_kit_utilities = require("@dnd-kit/utilities");
19
19
  let _constructive_io_ui_toast = require("@constructive-io/ui/toast");
20
20
  let _constructive_io_ui_combobox = require("@constructive-io/ui/combobox");
21
21
  let _constructive_io_ui_input = require("@constructive-io/ui/input");
22
- let _constructive_io_ui_label = require("@constructive-io/ui/label");
23
22
  let _constructive_io_ui_scroll_area = require("@constructive-io/ui/scroll-area");
24
23
  let _constructive_io_ui_checkbox = require("@constructive-io/ui/checkbox");
24
+ let _constructive_io_ui_label = require("@constructive-io/ui/label");
25
25
  let _constructive_io_ui_collapsible = require("@constructive-io/ui/collapsible");
26
26
  let _constructive_io_ui_input_group = require("@constructive-io/ui/input-group");
27
27
 
@@ -61,32 +61,32 @@ const DraggableFieldType = (0, react.memo)(function DraggableFieldType({ typeInf
61
61
  style,
62
62
  ...listeners,
63
63
  ...attributes,
64
- className: require_invalidate_database_entities.cn(`group hover:bg-accent flex cursor-grab items-center gap-3 rounded-lg border border-transparent px-2.5 py-2
65
- transition-[background-color,border-color,box-shadow,opacity] duration-150 ease-out active:cursor-grabbing`, "touch-none select-none", "hover:border-border/60 hover:shadow-sm", {
64
+ title: typeInfo.description,
65
+ className: require_invalidate_database_entities.cn("group flex h-9 cursor-grab items-center gap-2.5 rounded-lg px-2 active:cursor-grabbing", "touch-none select-none hover:bg-overlay-hover outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50", {
66
66
  "opacity-50": isBeingDragged && !isDragging,
67
- "border-primary/30 bg-primary/5 shadow-md": isDragging
67
+ "bg-card shadow-card-lg": isDragging
68
68
  }, className),
69
69
  children: [
70
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
71
- className: "bg-muted/60 text-muted-foreground flex h-8 w-8 flex-shrink-0 items-center justify-center\n rounded-md",
72
- children: IconComponent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconComponent, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
73
- className: "font-mono text-xs font-medium",
70
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
71
+ className: "bg-muted text-muted-foreground group-hover:text-foreground grid size-6 shrink-0 place-items-center rounded-md",
72
+ children: IconComponent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconComponent, { className: "size-3.5" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
73
+ className: "font-mono text-[11px] font-medium",
74
74
  children: typeInfo.type.charAt(0).toUpperCase()
75
75
  })
76
76
  }),
77
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
78
- className: "min-w-0 flex-1",
77
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
78
+ className: "flex min-w-0 flex-1 items-baseline gap-2",
79
79
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
80
- className: "text-foreground block truncate text-sm font-medium",
80
+ className: "text-foreground shrink-0 text-[13px]",
81
81
  children: typeInfo.label
82
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
83
- className: "text-muted-foreground truncate text-xs",
82
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
83
+ className: "text-muted-foreground min-w-0 truncate text-xs",
84
84
  children: typeInfo.description
85
85
  })]
86
86
  }),
87
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
88
- className: "flex-shrink-0 opacity-0 transition-opacity group-hover:opacity-100",
89
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_remixicon_react.RiDragDropLine, { className: "text-muted-foreground h-4 w-4" })
87
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_remixicon_react.RiDragDropLine, {
88
+ "aria-hidden": "true",
89
+ className: "text-muted-foreground size-3.5 shrink-0 opacity-0 group-hover:opacity-100"
90
90
  })
91
91
  ]
92
92
  });
@@ -113,18 +113,16 @@ function DraggableFieldTypeIcon({ typeInfo, isDragging = false, className }) {
113
113
  ...listeners,
114
114
  ...attributes,
115
115
  "aria-label": `Drag ${typeInfo.label} field type`,
116
- className: require_invalidate_database_entities.cn(`group bg-background hover:bg-accent relative aspect-square w-10 cursor-grab rounded-lg border
117
- transition-[background-color,border-color,box-shadow,opacity] duration-150 ease-out active:cursor-grabbing`, "flex items-center justify-center", "touch-none select-none", {
116
+ className: require_invalidate_database_entities.cn("group bg-card shadow-card hover:bg-muted relative flex aspect-square w-10 cursor-grab items-center justify-center rounded-lg active:cursor-grabbing", "touch-none select-none outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50", {
118
117
  "opacity-50": isBeingDragged && !isDragging,
119
- "border-primary/30 bg-primary/5 shadow-lg": isDragging,
120
- "hover:border-primary/40 hover:shadow-sm": !isBeingDragged
118
+ "shadow-card-lg": isDragging
121
119
  }, className),
122
120
  type: "button",
123
- children: [IconComponent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconComponent, { className: require_invalidate_database_entities.cn("text-muted-foreground h-4 w-4 transition-colors", "group-hover:text-foreground") }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
124
- className: "text-muted-foreground group-hover:text-foreground font-mono text-xs font-medium",
121
+ children: [IconComponent ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(IconComponent, { className: require_invalidate_database_entities.cn("text-foreground/70 size-4", "group-hover:text-foreground") }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
122
+ className: "text-foreground/70 group-hover:text-foreground font-mono text-xs font-medium",
125
123
  children: typeInfo.type.charAt(0).toUpperCase()
126
124
  }), badge && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
127
- className: require_invalidate_database_entities.cn("absolute inset-x-0 bottom-0.5", "flex items-center justify-center", "text-muted-foreground/60 group-hover:text-muted-foreground", "font-mono text-[7px] font-medium uppercase leading-none tracking-wide", "transition-colors"),
125
+ className: require_invalidate_database_entities.cn("absolute inset-x-0 bottom-0.5", "flex items-center justify-center", "text-muted-foreground group-hover:text-foreground/70", "font-mono text-[7px] font-medium uppercase leading-none tracking-wide"),
128
126
  children: badge
129
127
  })]
130
128
  })
@@ -414,233 +412,188 @@ function useUpdateFieldOrder() {
414
412
  //#region src/schema/schema-builder-fields/components/table-editor/constraint-card.tsx
415
413
  const CONSTRAINT_CONFIG = {
416
414
  primaryKey: {
417
- label: "Primary Key",
415
+ label: "Primary key",
418
416
  description: "Uniquely identifies each row (automatically sets UNIQUE + NOT NULL)",
419
- badge: "PK",
420
417
  icon: lucide_react.Key,
421
- colors: {
422
- selected: "ring-2 ring-blue-500/50 bg-blue-500/5",
423
- badge: "bg-blue-500/10 text-blue-600 border-blue-500/20",
424
- icon: "text-blue-500"
425
- }
418
+ tint: "text-blue-600 dark:text-blue-400"
426
419
  },
427
420
  unique: {
428
421
  label: "Unique",
429
422
  description: "All values in this column must be different",
430
- badge: "UNIQUE",
431
423
  icon: lucide_react.Fingerprint,
432
- colors: {
433
- selected: "ring-2 ring-purple-500/50 bg-purple-500/5",
434
- badge: "bg-purple-500/10 text-purple-600 border-purple-500/20",
435
- icon: "text-purple-500"
436
- }
424
+ tint: "text-purple-600 dark:text-purple-400"
437
425
  },
438
426
  nullable: {
439
427
  label: "Nullable",
440
428
  description: "Allow NULL values in this column",
441
- badge: "NULLABLE",
442
429
  icon: lucide_react.CircleDot,
443
- colors: {
444
- selected: "ring-2 ring-green-500/50 bg-green-500/5",
445
- badge: "bg-green-500/10 text-green-600 border-green-500/20",
446
- icon: "text-green-500"
447
- }
430
+ tint: "text-green-600 dark:text-green-400"
448
431
  }
449
432
  };
433
+ /**
434
+ * A checkbox with room for an explanation. The whole card is the checkbox's
435
+ * label, so it toggles like one: no press animation, just the tick and a
436
+ * quiet selected surface.
437
+ */
450
438
  function ConstraintCard({ type, selected, disabled, disabledReason, onToggle }) {
451
- const config = CONSTRAINT_CONFIG[type];
452
- const Icon = config.icon;
453
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
454
- className: require_invalidate_database_entities.cn(`flex items-center justify-between gap-4 rounded-lg border p-4 transition-[background-color,border-color,box-shadow,scale]
455
- duration-150 ease-out motion-safe:active:scale-[0.96]`, disabled ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:border-border", selected && !disabled ? config.colors.selected : "bg-card border-border/50"),
456
- onClick: () => !disabled && onToggle(),
457
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
458
- className: "flex items-start gap-3",
459
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
460
- className: require_invalidate_database_entities.cn("mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-md", selected && !disabled ? config.colors.icon : "text-muted-foreground", selected && !disabled ? "bg-background" : "bg-muted/50"),
461
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { className: "size-4" })
462
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
463
- className: "flex-1 space-y-1",
464
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
465
- className: "flex items-center gap-2",
466
- children: [
467
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
468
- className: require_invalidate_database_entities.cn("text-sm font-medium", selected && !disabled ? config.colors.icon : "text-foreground"),
469
- children: config.label
470
- }),
471
- selected && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
472
- className: require_invalidate_database_entities.cn("rounded border px-1.5 py-0.5 text-[10px] font-medium", config.colors.badge),
473
- children: config.badge
474
- }),
475
- disabled && disabledReason && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
476
- className: "text-muted-foreground text-xs",
477
- children: [
478
- "(",
479
- disabledReason,
480
- ")"
481
- ]
482
- })
483
- ]
484
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
485
- className: "text-muted-foreground text-xs leading-relaxed",
486
- children: config.description
439
+ const { label, description, icon: Icon, tint } = CONSTRAINT_CONFIG[type];
440
+ const active = selected && !disabled;
441
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
442
+ className: require_invalidate_database_entities.cn("flex items-center gap-3 rounded-lg border px-3 py-2.5", disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer", active ? "border-primary/35 bg-primary/[0.04]" : require_invalidate_database_entities.cn("border-border bg-card", !disabled && "hover:bg-overlay-hover")),
443
+ children: [
444
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
445
+ className: require_invalidate_database_entities.cn("grid size-7 shrink-0 place-items-center rounded-md", active ? require_invalidate_database_entities.cn("bg-background", tint) : "bg-muted text-muted-foreground"),
446
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
447
+ "aria-hidden": "true",
448
+ className: "size-3.5"
449
+ })
450
+ }),
451
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
452
+ className: "flex min-w-0 flex-1 flex-col gap-0.5",
453
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
454
+ className: "flex items-baseline gap-1.5",
455
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
456
+ className: "text-foreground text-[13px] font-medium",
457
+ children: label
458
+ }), disabled && disabledReason ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
459
+ className: "text-muted-foreground text-xs",
460
+ children: [
461
+ "(",
462
+ disabledReason,
463
+ ")"
464
+ ]
465
+ }) : null]
466
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
467
+ className: "text-muted-foreground text-xs",
468
+ children: description
487
469
  })]
488
- })]
489
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_checkbox.Checkbox, {
490
- checked: selected,
491
- disabled,
492
- onCheckedChange: () => !disabled && onToggle(),
493
- onClick: (e) => e.stopPropagation(),
494
- className: "shrink-0"
470
+ }),
471
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_checkbox.Checkbox, {
472
+ checked: selected,
473
+ className: "shrink-0",
474
+ disabled,
475
+ onCheckedChange: () => onToggle()
476
+ })
477
+ ]
478
+ });
479
+ }
480
+
481
+ //#endregion
482
+ //#region src/schema/schema-builder-fields/components/table-editor/form-field.tsx
483
+ /**
484
+ * One labelled control with an optional hint. Every field in the field
485
+ * editor uses it, so the rhythm stays the same everywhere: 8px from label to
486
+ * control, 6px from control to hint.
487
+ */
488
+ function FormField({ label, htmlFor, hint, subtle = false, children, className }) {
489
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
490
+ className: require_invalidate_database_entities.cn("flex min-w-0 flex-col gap-2", className),
491
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
492
+ className: subtle ? "text-muted-foreground text-xs" : void 0,
493
+ htmlFor,
494
+ children: label
495
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
496
+ className: "flex flex-col gap-1.5",
497
+ children: [children, hint ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
498
+ className: "text-muted-foreground text-xs",
499
+ children: hint
500
+ }) : null]
495
501
  })]
496
502
  });
497
503
  }
504
+ /** A titled group of fields, such as Constraints or Validation rules. */
505
+ function FormSection({ title, children }) {
506
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
507
+ className: "flex flex-col gap-2",
508
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, { children: title }), children]
509
+ });
510
+ }
498
511
 
499
512
  //#endregion
500
513
  //#region src/schema/schema-builder-fields/components/table-editor/validation-rules-section.tsx
514
+ const LENGTH_RULES = [{
515
+ key: "minLength",
516
+ label: "Min length",
517
+ placeholder: "e.g., 3"
518
+ }, {
519
+ key: "maxLength",
520
+ label: "Max length",
521
+ placeholder: "e.g., 255"
522
+ }];
523
+ const RANGE_RULES = [{
524
+ key: "minValue",
525
+ label: "Min value",
526
+ placeholder: "e.g., 0",
527
+ decimal: true
528
+ }, {
529
+ key: "maxValue",
530
+ label: "Max value",
531
+ placeholder: "e.g., 100",
532
+ decimal: true
533
+ }];
534
+ const PRECISION_RULE = {
535
+ key: "precision",
536
+ label: "Precision",
537
+ placeholder: "e.g., 10",
538
+ hint: "Total digits"
539
+ };
540
+ const SCALE_RULE = {
541
+ key: "scale",
542
+ label: "Scale",
543
+ placeholder: "e.g., 2",
544
+ hint: "Decimal places"
545
+ };
501
546
  function ValidationRulesSection({ dataType, values, onChange, disabled }) {
502
547
  const configurable = require_invalidate_database_entities.getFieldTypeInfo(dataType)?.configurable;
503
- if (!(configurable && (configurable.length || configurable.pattern || configurable.range || configurable.precision || configurable.scale))) return null;
504
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
505
- className: "space-y-4",
506
- children: [
507
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_label.Label, { children: ["Validation Rules ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
508
- className: "text-muted-foreground",
509
- children: "(optional)"
510
- })] }),
511
- configurable.length && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
512
- className: "grid grid-cols-2 gap-4",
513
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
514
- className: "space-y-2",
515
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
516
- htmlFor: "minLength",
517
- className: "text-muted-foreground text-xs",
518
- children: "Min Length"
519
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
520
- id: "minLength",
521
- type: "number",
522
- placeholder: "e.g., 3",
523
- value: values.minLength ?? "",
524
- onChange: (e) => onChange("minLength", e.target.value ? parseInt(e.target.value) : void 0),
525
- disabled
526
- })]
527
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
528
- className: "space-y-2",
529
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
530
- htmlFor: "maxLength",
531
- className: "text-muted-foreground text-xs",
532
- children: "Max Length"
533
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
534
- id: "maxLength",
535
- type: "number",
536
- placeholder: "e.g., 255",
537
- value: values.maxLength ?? "",
538
- onChange: (e) => onChange("maxLength", e.target.value ? parseInt(e.target.value) : void 0),
539
- disabled
540
- })]
541
- })]
542
- }),
543
- configurable.pattern && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
544
- className: "space-y-2",
545
- children: [
546
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
547
- htmlFor: "pattern",
548
- className: "text-muted-foreground text-xs",
549
- children: "Regex Pattern"
550
- }),
551
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
548
+ if (!configurable) return null;
549
+ const numericRows = [[...configurable.precision ? [PRECISION_RULE] : [], ...configurable.scale ? [SCALE_RULE] : []], configurable.range ? RANGE_RULES : []].filter((row) => row.length > 0);
550
+ if (!configurable.length && !configurable.pattern && numericRows.length === 0) return null;
551
+ const numberField = ({ key, label, placeholder, hint, decimal }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
552
+ hint,
553
+ htmlFor: key,
554
+ label,
555
+ subtle: true,
556
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
557
+ disabled,
558
+ id: key,
559
+ onChange: (e) => onChange(key, e.target.value ? (decimal ? parseFloat : parseInt)(e.target.value) : void 0),
560
+ placeholder,
561
+ type: "number",
562
+ value: values[key] ?? ""
563
+ })
564
+ }, key);
565
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormSection, {
566
+ title: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: ["Validation rules ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
567
+ className: "text-muted-foreground",
568
+ children: "(optional)"
569
+ })] }),
570
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
571
+ className: "flex flex-col gap-4",
572
+ children: [
573
+ configurable.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
574
+ className: "grid grid-cols-2 gap-4",
575
+ children: LENGTH_RULES.map(numberField)
576
+ }) : null,
577
+ configurable.pattern ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
578
+ hint: "Validate values with a regular expression",
579
+ htmlFor: "pattern",
580
+ label: "Regex pattern",
581
+ subtle: true,
582
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
583
+ className: "font-mono text-sm",
584
+ disabled,
552
585
  id: "pattern",
553
- placeholder: "e.g., ^[a-z]+$",
554
- value: values.pattern ?? "",
555
586
  onChange: (e) => onChange("pattern", e.target.value || void 0),
556
- disabled,
557
- className: "font-mono text-sm"
558
- }),
559
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
560
- className: "text-muted-foreground text-xs",
561
- children: "Validate values with a regular expression"
587
+ placeholder: "e.g., ^[a-z]+$",
588
+ value: values.pattern ?? ""
562
589
  })
563
- ]
564
- }),
565
- (configurable.precision || configurable.scale) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
566
- className: "grid grid-cols-2 gap-4",
567
- children: [configurable.precision && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
568
- className: "space-y-2",
569
- children: [
570
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
571
- htmlFor: "precision",
572
- className: "text-muted-foreground text-xs",
573
- children: "Precision"
574
- }),
575
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
576
- id: "precision",
577
- type: "number",
578
- placeholder: "e.g., 10",
579
- value: values.precision ?? "",
580
- onChange: (e) => onChange("precision", e.target.value ? parseInt(e.target.value) : void 0),
581
- disabled
582
- }),
583
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
584
- className: "text-muted-foreground text-xs",
585
- children: "Total digits"
586
- })
587
- ]
588
- }), configurable.scale && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
589
- className: "space-y-2",
590
- children: [
591
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
592
- htmlFor: "scale",
593
- className: "text-muted-foreground text-xs",
594
- children: "Scale"
595
- }),
596
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
597
- id: "scale",
598
- type: "number",
599
- placeholder: "e.g., 2",
600
- value: values.scale ?? "",
601
- onChange: (e) => onChange("scale", e.target.value ? parseInt(e.target.value) : void 0),
602
- disabled
603
- }),
604
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
605
- className: "text-muted-foreground text-xs",
606
- children: "Decimal places"
607
- })
608
- ]
609
- })]
610
- }),
611
- configurable.range && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
612
- className: "grid grid-cols-2 gap-4",
613
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
614
- className: "space-y-2",
615
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
616
- htmlFor: "minValue",
617
- className: "text-muted-foreground text-xs",
618
- children: "Min Value"
619
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
620
- id: "minValue",
621
- type: "number",
622
- placeholder: "e.g., 0",
623
- value: values.minValue ?? "",
624
- onChange: (e) => onChange("minValue", e.target.value ? parseFloat(e.target.value) : void 0),
625
- disabled
626
- })]
627
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
628
- className: "space-y-2",
629
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
630
- htmlFor: "maxValue",
631
- className: "text-muted-foreground text-xs",
632
- children: "Max Value"
633
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
634
- id: "maxValue",
635
- type: "number",
636
- placeholder: "e.g., 100",
637
- value: values.maxValue ?? "",
638
- onChange: (e) => onChange("maxValue", e.target.value ? parseFloat(e.target.value) : void 0),
639
- disabled
640
- })]
641
- })]
642
- })
643
- ]
590
+ }) : null,
591
+ numericRows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
592
+ className: "grid grid-cols-2 gap-4",
593
+ children: row.map(numberField)
594
+ }, row[0].key))
595
+ ]
596
+ })
644
597
  });
645
598
  }
646
599
 
@@ -846,12 +799,10 @@ const AddFieldCard = ({ editingField: initialEditingField, preSelectedType, prim
846
799
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
847
800
  className: "space-y-6 p-6",
848
801
  children: [
849
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
850
- className: "space-y-2",
851
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, {
852
- htmlFor: "columnName",
853
- children: "Field Name"
854
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
802
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
803
+ htmlFor: "columnName",
804
+ label: "Field name",
805
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
855
806
  id: "columnName",
856
807
  ref: fieldNameInputRef,
857
808
  placeholder: "e.g., user_email",
@@ -859,11 +810,11 @@ const AddFieldCard = ({ editingField: initialEditingField, preSelectedType, prim
859
810
  onChange: (e) => setColumnName(e.target.value),
860
811
  disabled: isPending,
861
812
  autoComplete: "off"
862
- })]
813
+ })
863
814
  }),
864
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
865
- className: "space-y-2",
866
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, { children: "Data Type" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_combobox.Combobox, {
815
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
816
+ label: "Data type",
817
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_combobox.Combobox, {
867
818
  items: fieldTypeOptions,
868
819
  value: selectedFieldTypeOption,
869
820
  onValueChange: (next) => {
@@ -923,12 +874,12 @@ const AddFieldCard = ({ editingField: initialEditingField, preSelectedType, prim
923
874
  } })
924
875
  ]
925
876
  })]
926
- })]
877
+ })
927
878
  }),
928
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
929
- className: "space-y-3",
930
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_label.Label, { children: "Constraints" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
931
- className: "space-y-3",
879
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormSection, {
880
+ title: "Constraints",
881
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
882
+ className: "flex flex-col gap-2",
932
883
  children: [
933
884
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConstraintCard, {
934
885
  type: "primaryKey",
@@ -938,7 +889,7 @@ const AddFieldCard = ({ editingField: initialEditingField, preSelectedType, prim
938
889
  }),
939
890
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConstraintCard, {
940
891
  type: "unique",
941
- selected: constraints.unique ?? false,
892
+ selected: Boolean(constraints.unique || constraints.primaryKey),
942
893
  onToggle: () => handleConstraintToggle("unique"),
943
894
  disabled: isPending || constraints.primaryKey,
944
895
  disabledReason: constraints.primaryKey ? "set by PK" : void 0
@@ -951,30 +902,22 @@ const AddFieldCard = ({ editingField: initialEditingField, preSelectedType, prim
951
902
  disabledReason: constraints.primaryKey ? "disabled by PK" : void 0
952
903
  })
953
904
  ]
954
- })]
905
+ })
955
906
  }),
956
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
957
- className: "space-y-2",
958
- children: [
959
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_label.Label, {
960
- htmlFor: "defaultValue",
961
- children: ["Default Value ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
962
- className: "text-muted-foreground",
963
- children: "(optional)"
964
- })]
965
- }),
966
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
967
- id: "defaultValue",
968
- placeholder: "e.g., 0, true, now()",
969
- value: defaultValue,
970
- onChange: (e) => setDefaultValue(e.target.value),
971
- disabled: isPending
972
- }),
973
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
974
- className: "text-muted-foreground text-xs",
975
- children: "SQL functions or static values"
976
- })
977
- ]
907
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormField, {
908
+ hint: "SQL functions or static values",
909
+ htmlFor: "defaultValue",
910
+ label: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: ["Default value ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
911
+ className: "text-muted-foreground",
912
+ children: "(optional)"
913
+ })] }),
914
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_input.Input, {
915
+ id: "defaultValue",
916
+ placeholder: "e.g., 0, true, now()",
917
+ value: defaultValue,
918
+ onChange: (e) => setDefaultValue(e.target.value),
919
+ disabled: isPending
920
+ })
978
921
  }),
979
922
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValidationRulesSection, {
980
923
  dataType,
@@ -1003,52 +946,60 @@ const AddFieldCard = ({ editingField: initialEditingField, preSelectedType, prim
1003
946
 
1004
947
  //#endregion
1005
948
  //#region src/schema/schema-builder-fields/components/table-editor/fields-list-view.tsx
1006
- function ConstraintIndicator({ type, label }) {
1007
- const styles = {
1008
- pk: "bg-amber-500/10 text-amber-600 dark:text-amber-400 border-amber-500/20",
1009
- unique: "bg-violet-500/10 text-violet-600 dark:text-violet-400 border-violet-500/20",
1010
- nullable: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/20",
1011
- required: "bg-rose-500/10 text-rose-600 dark:text-rose-400 border-rose-500/20"
1012
- };
1013
- const Icon = {
1014
- pk: _remixicon_react.RiKey2Line,
1015
- unique: _remixicon_react.RiFingerprintLine,
1016
- nullable: null,
1017
- required: _remixicon_react.RiShieldCheckLine
1018
- }[type];
949
+ const CONSTRAINT_STYLE = {
950
+ pk: {
951
+ className: "bg-amber-500/10 text-amber-700 dark:text-amber-300",
952
+ icon: _remixicon_react.RiKey2Line,
953
+ label: "Primary key"
954
+ },
955
+ unique: {
956
+ className: "bg-violet-500/10 text-violet-700 dark:text-violet-300",
957
+ icon: _remixicon_react.RiFingerprintLine,
958
+ label: "Unique"
959
+ }
960
+ };
961
+ /** Keys stand out as tinted labels; required and nullable read as plain words, since every column is one or the other. */
962
+ function ConstraintIndicator({ type }) {
963
+ const { className, icon: Icon, label } = CONSTRAINT_STYLE[type];
1019
964
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1020
- className: require_invalidate_database_entities.cn(`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 text-[10px] font-semibold tracking-wide
1021
- uppercase`, "transition-[background-color,border-color,color] duration-150 ease-out", styles[type]),
1022
- children: [Icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { className: "size-2.5" }), label]
965
+ className: require_invalidate_database_entities.cn("inline-flex h-5 items-center gap-1 rounded-md px-1.5 text-[11px] font-medium whitespace-nowrap", className),
966
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
967
+ "aria-hidden": "true",
968
+ className: "size-3"
969
+ }), label]
1023
970
  });
1024
971
  }
972
+ const GRID = "grid grid-cols-[36px_minmax(0,1.3fr)_minmax(0,1fr)_minmax(0,1.1fr)_minmax(0,1fr)] items-center gap-3";
1025
973
  function FieldsListView({ fields, constraints, selectedFieldIds, onSelectionChange, onFieldClick, disabled }) {
1026
- const pkConstraint = (0, react.useMemo)(() => constraints.find((c) => c.type === "primary_key"), [constraints]);
1027
- const handleSelectAll = (0, react.useCallback)((checked) => {
1028
- if (checked) onSelectionChange(new Set(fields.map((f) => f.id)));
1029
- else onSelectionChange(/* @__PURE__ */ new Set());
1030
- }, [fields, onSelectionChange]);
974
+ const { primaryKeyIds, uniqueIds } = (0, react.useMemo)(() => {
975
+ const primaryKey = constraints.find((c) => c.type === "primary_key");
976
+ return {
977
+ primaryKeyIds: new Set(primaryKey?.fields ?? []),
978
+ uniqueIds: new Set(constraints.flatMap((c) => c.type === "unique" && c.fields.length === 1 ? c.fields : []))
979
+ };
980
+ }, [constraints]);
981
+ const handleSelectAll = (0, react.useCallback)((checked) => onSelectionChange(checked ? new Set(fields.map((f) => f.id)) : /* @__PURE__ */ new Set()), [fields, onSelectionChange]);
1031
982
  const handleSelectRow = (0, react.useCallback)((fieldId, checked) => {
1032
- const newSelected = new Set(selectedFieldIds);
1033
- if (checked) newSelected.add(fieldId);
1034
- else newSelected.delete(fieldId);
1035
- onSelectionChange(newSelected);
983
+ const next = new Set(selectedFieldIds);
984
+ if (checked) next.add(fieldId);
985
+ else next.delete(fieldId);
986
+ onSelectionChange(next);
1036
987
  }, [selectedFieldIds, onSelectionChange]);
1037
988
  const allSelected = fields.length > 0 && selectedFieldIds.size === fields.length;
1038
989
  const someSelected = selectedFieldIds.size > 0 && selectedFieldIds.size < fields.length;
1039
990
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1040
- className: "min-w-[720px]",
991
+ className: "min-w-[640px]",
1041
992
  children: [
1042
993
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1043
- className: require_invalidate_database_entities.cn(`bg-muted/30 border-border/50 grid
1044
- grid-cols-[40px_minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1.2fr)] gap-3 border-b px-3 py-2`, "text-muted-foreground/70 text-[10px] font-semibold tracking-widest uppercase"),
994
+ className: require_invalidate_database_entities.cn(GRID, "bg-muted/60 text-muted-foreground px-3 py-2 text-xs"),
1045
995
  children: [
1046
996
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1047
997
  className: "flex items-center justify-center",
1048
998
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_checkbox.Checkbox, {
1049
999
  checked: allSelected,
1050
1000
  indeterminate: someSelected,
1051
- onCheckedChange: (checked) => handleSelectAll(checked),
1001
+ "aria-label": "Select all fields",
1002
+ onCheckedChange: (checked) => handleSelectAll(checked === true),
1052
1003
  disabled: disabled || fields.length === 0
1053
1004
  })
1054
1005
  }),
@@ -1059,123 +1010,112 @@ function FieldsListView({ fields, constraints, selectedFieldIds, onSelectionChan
1059
1010
  ]
1060
1011
  }),
1061
1012
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1062
- className: "divide-border/30 divide-y",
1063
- children: fields.map((field, index) => {
1064
- const isSelected = selectedFieldIds.has(field.id);
1065
- const fieldTypeInfo = require_invalidate_database_entities.getFieldTypeInfo(field.type);
1066
- const isPartOfPrimaryKey = pkConstraint?.fields.includes(field.id) || false;
1067
- const isUnique = (constraints.find((c) => c.type === "unique" && c.fields.length === 1 && c.fields[0] === field.id) !== void 0 || isPartOfPrimaryKey) && !isPartOfPrimaryKey;
1068
- const isNullable = field.constraints.nullable && !isPartOfPrimaryKey;
1069
- const isRequired = !field.constraints.nullable && !isPartOfPrimaryKey;
1070
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1071
- role: "button",
1072
- tabIndex: disabled ? -1 : 0,
1073
- "aria-disabled": disabled || void 0,
1074
- "data-chat-component": "field-row",
1075
- "data-chat-field-name": field.name,
1076
- "data-chat-field-type": field.type,
1077
- "data-chat-nullable": String(field.constraints.nullable),
1078
- className: require_invalidate_database_entities.cn(`group grid grid-cols-[40px_minmax(0,1.2fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1.2fr)] gap-3 px-3
1079
- py-2.5`, "cursor-pointer transition-colors duration-150 ease-out", "hover:bg-muted/40", isSelected && "bg-primary/5"),
1080
- style: { animationDelay: `${index * 30}ms` },
1081
- onClick: () => {
1082
- if (!disabled) onFieldClick(field);
1083
- },
1084
- onKeyDown: (event) => {
1085
- require_keyboard_activation.handleActivationKeyDown(event, () => onFieldClick(field), disabled);
1086
- },
1087
- children: [
1088
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1089
- className: "flex items-center justify-center",
1090
- onClick: (e) => e.stopPropagation(),
1091
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_checkbox.Checkbox, {
1092
- checked: isSelected,
1093
- onCheckedChange: (checked) => handleSelectRow(field.id, checked),
1094
- disabled
1095
- })
1096
- }),
1097
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1098
- className: "flex items-center gap-2",
1099
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1100
- className: require_invalidate_database_entities.cn("truncate font-mono text-[13px] font-medium tracking-tight", "text-foreground/90 group-hover:text-foreground", "transition-colors duration-200"),
1101
- children: field.name
1102
- })
1103
- }),
1104
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1105
- className: "flex items-center",
1106
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1107
- className: require_invalidate_database_entities.cn("inline-flex items-center gap-1.5 rounded-md px-2 py-1", "bg-muted/60 group-hover:bg-muted/80", "border-border/40 border", "transition-[background-color,border-color] duration-150 ease-out"),
1108
- children: [fieldTypeInfo?.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1109
- className: "text-muted-foreground/70 flex items-center",
1110
- children: typeof fieldTypeInfo.icon === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1111
- className: "text-xs",
1112
- children: fieldTypeInfo.icon
1113
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(fieldTypeInfo.icon, { className: "size-3.5" })
1114
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1115
- className: "text-foreground/70 font-mono text-[11px] font-medium",
1116
- children: fieldTypeInfo?.label || field.type
1117
- })]
1118
- })
1119
- }),
1120
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1121
- className: "flex flex-wrap items-center gap-1",
1122
- children: [
1123
- isPartOfPrimaryKey && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConstraintIndicator, {
1124
- type: "pk",
1125
- label: "PK"
1126
- }),
1127
- isUnique && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConstraintIndicator, {
1128
- type: "unique",
1129
- label: "Unique"
1130
- }),
1131
- isNullable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConstraintIndicator, {
1132
- type: "nullable",
1133
- label: "Null"
1134
- }),
1135
- isRequired && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConstraintIndicator, {
1136
- type: "required",
1137
- label: "Req"
1138
- }),
1139
- !isPartOfPrimaryKey && !isNullable && !isUnique && !isRequired && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1140
- className: "text-muted-foreground/30 text-xs",
1141
- children: "—"
1142
- })
1143
- ]
1144
- }),
1145
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1146
- className: "flex items-center",
1147
- children: field.constraints.defaultValue ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
1148
- className: require_invalidate_database_entities.cn("text-muted-foreground truncate rounded px-1.5 py-0.5 font-mono text-[11px]", "bg-muted/40 group-hover:bg-muted/60", "transition-colors duration-200"),
1149
- children: field.constraints.defaultValue.toString()
1150
- }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1151
- className: "text-muted-foreground/30 text-[11px] italic",
1152
- children: "null"
1153
- })
1154
- })
1155
- ]
1156
- }, field.id);
1157
- })
1013
+ className: "divide-border divide-y",
1014
+ children: fields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldRow, {
1015
+ disabled,
1016
+ field,
1017
+ isPrimaryKey: primaryKeyIds.has(field.id),
1018
+ isSelected: selectedFieldIds.has(field.id),
1019
+ isUnique: uniqueIds.has(field.id),
1020
+ onOpen: onFieldClick,
1021
+ onSelect: handleSelectRow
1022
+ }, field.id))
1158
1023
  }),
1159
1024
  fields.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1160
- className: "flex flex-col items-center justify-center py-12",
1161
- children: [
1162
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1163
- className: require_invalidate_database_entities.cn("bg-muted/30 mb-3 flex size-12 items-center justify-center rounded-xl", "border-border/50 border border-dashed"),
1164
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_remixicon_react.RiSparklingLine, { className: "text-muted-foreground/40 size-5" })
1165
- }),
1166
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1167
- className: "text-muted-foreground/60 text-sm font-medium",
1168
- children: "No fields defined"
1169
- }),
1170
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1171
- className: "text-muted-foreground/40 mt-1 text-xs",
1172
- children: "Add your first field to start building the schema"
1025
+ className: "flex flex-col items-center justify-center gap-2 py-10",
1026
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1027
+ className: "bg-muted text-muted-foreground grid size-9 place-items-center rounded-xl",
1028
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_remixicon_react.RiSparklingLine, {
1029
+ "aria-hidden": "true",
1030
+ className: "size-4"
1173
1031
  })
1174
- ]
1032
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1033
+ className: "text-center",
1034
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1035
+ className: "text-foreground text-[13px] font-medium",
1036
+ children: "No fields yet"
1037
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1038
+ className: "text-muted-foreground mt-0.5 text-xs",
1039
+ children: "Add a field, or drop a type from the library."
1040
+ })]
1041
+ })]
1175
1042
  })
1176
1043
  ]
1177
1044
  });
1178
1045
  }
1046
+ /** One field. Memoized so a selection change re-renders only the rows it touches. */
1047
+ const FieldRow = (0, react.memo)(function FieldRow({ field, isSelected, isPrimaryKey, isUnique, disabled, onSelect, onOpen }) {
1048
+ const typeInfo = require_invalidate_database_entities.getFieldTypeInfo(field.type);
1049
+ const TypeIcon = typeInfo?.icon;
1050
+ const isRequired = !field.constraints.nullable;
1051
+ const defaultValue = field.constraints.defaultValue;
1052
+ const hasDefault = defaultValue !== void 0 && defaultValue !== null && defaultValue !== "";
1053
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1054
+ role: "button",
1055
+ tabIndex: disabled ? -1 : 0,
1056
+ "aria-disabled": disabled || void 0,
1057
+ "data-chat-component": "field-row",
1058
+ "data-chat-field-name": field.name,
1059
+ "data-chat-field-type": field.type,
1060
+ "data-chat-nullable": String(field.constraints.nullable),
1061
+ className: require_invalidate_database_entities.cn(GRID, "group hover:bg-overlay-hover cursor-pointer px-3 py-2 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:ring-inset", isSelected && "bg-primary/[0.05]"),
1062
+ onClick: () => {
1063
+ if (!disabled) onOpen(field);
1064
+ },
1065
+ onKeyDown: (event) => require_keyboard_activation.handleActivationKeyDown(event, () => onOpen(field), disabled),
1066
+ children: [
1067
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1068
+ className: "flex items-center justify-center",
1069
+ onClick: (e) => e.stopPropagation(),
1070
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_checkbox.Checkbox, {
1071
+ "aria-label": `Select ${field.name}`,
1072
+ checked: isSelected,
1073
+ disabled,
1074
+ onCheckedChange: (checked) => onSelect(field.id, checked === true)
1075
+ })
1076
+ }),
1077
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1078
+ className: "text-foreground min-w-0 truncate font-mono text-[13px]",
1079
+ title: field.name,
1080
+ children: field.name
1081
+ }),
1082
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1083
+ className: "flex min-w-0 items-center",
1084
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1085
+ className: "bg-muted/50 inline-flex h-6 min-w-0 items-center gap-1.5 rounded-md px-2 text-xs ring-1 ring-foreground/[0.07] ring-inset",
1086
+ children: [TypeIcon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1087
+ className: "text-muted-foreground flex items-center",
1088
+ children: typeof TypeIcon === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1089
+ className: "text-xs",
1090
+ children: TypeIcon
1091
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypeIcon, { className: "size-3.5" })
1092
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1093
+ className: "text-foreground/80 truncate",
1094
+ children: typeInfo?.label || field.type
1095
+ })]
1096
+ })
1097
+ }),
1098
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1099
+ className: "flex min-w-0 flex-wrap items-center gap-1.5",
1100
+ children: isPrimaryKey ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConstraintIndicator, { type: "pk" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [isUnique ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConstraintIndicator, { type: "unique" }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1101
+ className: require_invalidate_database_entities.cn("text-xs", isRequired ? "text-foreground/75" : "text-muted-foreground"),
1102
+ children: isRequired ? "Required" : "Nullable"
1103
+ })] })
1104
+ }),
1105
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1106
+ className: "flex min-w-0 items-center",
1107
+ children: hasDefault ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
1108
+ className: "bg-muted/60 text-foreground/75 truncate rounded px-1.5 py-0.5 font-mono text-xs",
1109
+ children: String(defaultValue)
1110
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1111
+ "aria-label": "No default",
1112
+ className: "text-subtle-foreground text-xs",
1113
+ children: "—"
1114
+ })
1115
+ })
1116
+ ]
1117
+ });
1118
+ });
1179
1119
 
1180
1120
  //#endregion
1181
1121
  //#region src/schema/schema-builder-fields/components/table-editor/fields-section.tsx
@@ -1199,15 +1139,14 @@ function FieldsSection({ onAddFieldRef } = {}) {
1199
1139
  (0, react.useEffect)(() => {
1200
1140
  setSelectedFieldIds(/* @__PURE__ */ new Set());
1201
1141
  }, [currentTable?.id]);
1202
- const getFieldConstraintInfo = (0, react.useCallback)((field) => {
1203
- if (!field) return {};
1142
+ const constraintInfoFor = (0, react.useCallback)((field) => {
1204
1143
  const pkConstraint = constraints.find((c) => c.type === "primary_key");
1205
1144
  const uniqueConstraint = constraints.find((c) => c.type === "unique" && c.fields.length === 1 && c.fields[0] === field.id);
1206
1145
  return {
1207
1146
  primaryKeyConstraintId: pkConstraint?.id,
1208
1147
  uniqueConstraintId: uniqueConstraint?.id,
1209
- allPrimaryKeyFieldIds: pkConstraint?.fields || [],
1210
- isPartOfPrimaryKey: pkConstraint?.fields.includes(field.id) || false
1148
+ allPrimaryKeyFieldIds: pkConstraint?.fields ?? [],
1149
+ isPartOfPrimaryKey: pkConstraint?.fields.includes(field.id) ?? false
1211
1150
  };
1212
1151
  }, [constraints]);
1213
1152
  const handleAddField = (0, react.useCallback)(() => {
@@ -1224,7 +1163,7 @@ function FieldsSection({ onAddFieldRef } = {}) {
1224
1163
  });
1225
1164
  }, [stack, remoteFields]);
1226
1165
  const handleFieldClick = (0, react.useCallback)((field) => {
1227
- const constraintInfo = getFieldConstraintInfo(field);
1166
+ const constraintInfo = constraintInfoFor(field);
1228
1167
  stack.push({
1229
1168
  id: `edit-field-${field.id}`,
1230
1169
  title: "Edit Field",
@@ -1242,7 +1181,7 @@ function FieldsSection({ onAddFieldRef } = {}) {
1242
1181
  });
1243
1182
  }, [
1244
1183
  stack,
1245
- getFieldConstraintInfo,
1184
+ constraintInfoFor,
1246
1185
  remoteFields
1247
1186
  ]);
1248
1187
  const handleFieldDrop = (0, react.useCallback)((field) => {
@@ -1266,16 +1205,12 @@ function FieldsSection({ onAddFieldRef } = {}) {
1266
1205
  if (selectedFieldIds.size === 0) return;
1267
1206
  const fieldsToDelete = sortedFields.filter((f) => selectedFieldIds.has(f.id));
1268
1207
  if (fieldsToDelete.length === 0) return;
1269
- const pkConstraint = constraints.find((c) => c.type === "primary_key");
1270
1208
  setIsDeleting(true);
1271
1209
  const results = await Promise.allSettled(fieldsToDelete.map((field) => {
1272
- const isPartOfPrimaryKey = pkConstraint?.fields.includes(field.id) || false;
1273
- const uniqueConstraint = constraints.find((c) => c.type === "unique" && c.fields.length === 1 && c.fields[0] === field.id);
1210
+ const { isPartOfPrimaryKey, ...keys } = constraintInfoFor(field);
1274
1211
  return deleteFieldMutation.mutateAsync({
1275
1212
  id: field.id,
1276
- primaryKeyConstraintId: pkConstraint?.id,
1277
- uniqueConstraintId: uniqueConstraint?.id,
1278
- allPrimaryKeyFieldIds: pkConstraint?.fields || [],
1213
+ ...keys,
1279
1214
  wasPartOfPrimaryKey: isPartOfPrimaryKey
1280
1215
  });
1281
1216
  }));
@@ -1303,30 +1238,42 @@ function FieldsSection({ onAddFieldRef } = {}) {
1303
1238
  }, [
1304
1239
  selectedFieldIds,
1305
1240
  sortedFields,
1306
- constraints,
1241
+ constraintInfoFor,
1307
1242
  deleteFieldMutation
1308
1243
  ]);
1309
1244
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1310
1245
  "data-chat-component": "fields-section",
1311
1246
  "data-chat-table-name": currentTable?.name ?? "",
1312
1247
  "data-chat-field-count": String(remoteFields.length),
1313
- className: "space-y-3",
1248
+ className: "flex flex-col gap-2.5",
1314
1249
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1315
- className: "flex items-center justify-between",
1316
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
1317
- className: "text-balance text-sm font-medium",
1318
- children: "Fields"
1319
- }), selectedFieldIds.size > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_button.Button, {
1320
- variant: "outline",
1250
+ className: "flex h-7 items-center justify-between gap-2",
1251
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
1252
+ className: "text-foreground text-[13px] font-medium",
1253
+ children: ["Fields", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1254
+ className: "text-subtle-foreground ml-1.5 font-normal tabular-nums",
1255
+ children: remoteFields.length
1256
+ })]
1257
+ }), selectedFieldIds.size > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_button.Button, {
1258
+ variant: "ghost",
1321
1259
  size: "sm",
1322
- className: "text-destructive hover:bg-destructive/10 hover:text-destructive border-destructive/30 gap-1.5",
1260
+ className: "text-destructive hover:bg-destructive/10 hover:text-destructive h-7 gap-1.5 px-2 text-xs",
1323
1261
  onClick: handleBulkDelete,
1324
1262
  disabled: isDeleting,
1325
- children: [isDeleting ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, { className: "size-3.5" }), isDeleting ? "Deleting..." : `Delete (${selectedFieldIds.size})`]
1263
+ children: [isDeleting ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Trash2, { className: "size-3.5" }), isDeleting ? "Deleting…" : `Delete ${selectedFieldIds.size}`]
1264
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_button.Button, {
1265
+ className: "h-7 gap-1.5 px-2 text-xs",
1266
+ onClick: handleAddField,
1267
+ size: "sm",
1268
+ variant: "ghost",
1269
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Plus, {
1270
+ "aria-hidden": "true",
1271
+ className: "size-3.5"
1272
+ }), "Add field"]
1326
1273
  })]
1327
1274
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1328
1275
  ref: setDropZoneRef,
1329
- className: require_invalidate_database_entities.cn("bg-card/50 border-border/50 overflow-hidden rounded-lg border transition-colors", isOverDropZone ? "border-primary bg-primary/5" : null),
1276
+ className: require_invalidate_database_entities.cn("bg-card overflow-hidden rounded-xl shadow-card ring-inset", isOverDropZone ? "ring-primary/50 ring-2" : null),
1330
1277
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1331
1278
  className: "overflow-x-auto",
1332
1279
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldsListView, {
@@ -1338,17 +1285,13 @@ function FieldsSection({ onAddFieldRef } = {}) {
1338
1285
  disabled: isDeleting
1339
1286
  })
1340
1287
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1341
- className: require_invalidate_database_entities.cn("flex items-center justify-center gap-3 border-t border-dashed p-4", "border-border/40 bg-muted/20", "transition-[background-color,border-color] duration-150 ease-out", isOverDropZone && "border-primary/50 bg-primary/5"),
1342
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_button.Button, {
1343
- variant: "outline",
1344
- size: "sm",
1345
- className: require_invalidate_database_entities.cn("gap-1.5 px-3 text-xs font-medium", "hover:bg-primary/10 hover:text-primary hover:border-primary/30", "transition-[background-color,border-color,color,scale] duration-150 ease-out motion-safe:active:scale-[0.96]"),
1288
+ className: require_invalidate_database_entities.cn("text-muted-foreground flex items-center justify-center gap-1.5 border-t border-dashed border-foreground/10 px-4 py-2.5 text-xs", isOverDropZone && "bg-primary/[0.06] text-primary"),
1289
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1290
+ className: "text-foreground/80 hover:text-foreground cursor-pointer rounded font-medium outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
1346
1291
  onClick: handleAddField,
1347
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Plus, { className: "size-3.5" }), "Add Field"]
1348
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1349
- className: "text-muted-foreground/80 text-xs",
1350
- children: "or drag field types here"
1351
- })]
1292
+ type: "button",
1293
+ children: "Add a field"
1294
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "or drop a type from the library here" })]
1352
1295
  })]
1353
1296
  })]
1354
1297
  });
@@ -1421,22 +1364,19 @@ function NoTableSelectedView({ className }) {
1421
1364
 
1422
1365
  //#endregion
1423
1366
  //#region src/schema/schema-builder-tables/components/table-editor/table-metadata-section.tsx
1424
- function TableMetadataReadOnly({ tableName }) {
1425
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1426
- className: "flex min-w-0 flex-wrap items-center justify-between gap-3",
1427
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h2", {
1428
- className: "min-w-0",
1367
+ function TableMetadataReadOnly({ tableName, description }) {
1368
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1369
+ className: "min-w-0",
1370
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h2", {
1371
+ className: "text-foreground truncate text-base font-medium tracking-tight",
1429
1372
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1430
1373
  className: "sr-only",
1431
- children: "Table"
1432
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1433
- className: "border-border/60 bg-muted/40 text-foreground inline-flex max-w-full items-center rounded-md border\n px-2 py-1 font-mono text-base font-semibold tracking-tight",
1434
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1435
- className: "truncate",
1436
- children: tableName
1437
- })
1438
- })]
1439
- })
1374
+ children: "Table "
1375
+ }), tableName]
1376
+ }), description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1377
+ className: "text-muted-foreground mt-0.5 text-pretty text-[13px]",
1378
+ children: description
1379
+ }) : null]
1440
1380
  });
1441
1381
  }
1442
1382
  function TableMetadataEditable({ currentTable }) {
@@ -1481,8 +1421,8 @@ function TableMetadataEditable({ currentTable }) {
1481
1421
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1482
1422
  className: "flex flex-wrap items-center justify-between gap-3",
1483
1423
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
1484
- className: "text-foreground text-balance text-lg font-semibold tracking-tight",
1485
- children: "Edit Table"
1424
+ className: "text-foreground text-balance text-base font-medium tracking-tight",
1425
+ children: "Edit table"
1486
1426
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
1487
1427
  onSubmit: handleFormSubmit,
1488
1428
  className: "flex min-w-0 items-center gap-2",
@@ -1529,7 +1469,10 @@ function TableMetadataEditable({ currentTable }) {
1529
1469
  function TableMetadataSection({ isEditable = false }) {
1530
1470
  const { currentTable } = require_invalidate_database_entities.useSchemaBuilderSelectors();
1531
1471
  if (!currentTable?.name || !currentTable?.id) return null;
1532
- if (!isEditable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableMetadataReadOnly, { tableName: currentTable.name });
1472
+ if (!isEditable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableMetadataReadOnly, {
1473
+ description: currentTable.description,
1474
+ tableName: currentTable.name
1475
+ });
1533
1476
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableMetadataEditable, { currentTable: {
1534
1477
  id: currentTable.id,
1535
1478
  name: currentTable.name
@@ -1589,7 +1532,7 @@ function TypesLibrary() {
1589
1532
  })]
1590
1533
  }),
1591
1534
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1592
- className: "scrollbar-neutral-thin min-h-0 flex-1 space-y-2 overflow-auto px-2 pb-2",
1535
+ className: "scrollbar-neutral-thin min-h-0 flex-1 space-y-3 overflow-auto px-2 pb-2",
1593
1536
  children: totalFilteredCount === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1594
1537
  className: "text-muted-foreground p-4 text-center text-sm",
1595
1538
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", { children: [
@@ -1610,7 +1553,7 @@ function TypesLibrary() {
1610
1553
  })] })
1611
1554
  }),
1612
1555
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1613
- className: "text-muted-foreground/70 flex items-center gap-1.5 border-t px-3 py-2 text-xs",
1556
+ className: "text-muted-foreground flex items-center gap-1.5 border-t border-dashed border-foreground/10 px-3 py-2 text-xs",
1614
1557
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_remixicon_react.RiDragDropLine, { className: "h-3 w-3" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Drag or use the keyboard to add fields." })]
1615
1558
  })
1616
1559
  ]
@@ -1622,7 +1565,7 @@ function TypesSection({ title, types, isExpanded, onToggleExpand }) {
1622
1565
  onOpenChange: onToggleExpand,
1623
1566
  className: "flex min-h-0 shrink-0 flex-col",
1624
1567
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_constructive_io_ui_collapsible.CollapsibleTrigger, {
1625
- className: "group flex w-full cursor-pointer items-center gap-2 rounded-lg py-1.5 pr-2 pl-1 transition-colors\n duration-150 bg-card hover:bg-muted/50 data-[state=open]:bg-muted/50",
1568
+ className: "group text-muted-foreground hover:text-foreground flex h-7 w-full cursor-pointer items-center gap-1.5 rounded-md px-1.5 text-xs outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",
1626
1569
  children: [
1627
1570
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.motion.div, {
1628
1571
  animate: { rotate: isExpanded ? 90 : 0 },
@@ -1632,14 +1575,11 @@ function TypesSection({ title, types, isExpanded, onToggleExpand }) {
1632
1575
  damping: 25
1633
1576
  },
1634
1577
  className: "flex shrink-0 items-center justify-center",
1635
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "text-muted-foreground/60 h-3.5 w-3.5" })
1578
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronRight, { className: "size-3 opacity-70" })
1636
1579
  }),
1580
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: title }),
1637
1581
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1638
- className: "text-muted-foreground text-xs font-medium",
1639
- children: title
1640
- }),
1641
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1642
- className: "text-muted-foreground/70 ml-auto text-[10px] tabular-nums",
1582
+ className: "text-subtle-foreground ml-auto tabular-nums",
1643
1583
  children: types.length
1644
1584
  })
1645
1585
  ]
@@ -1667,7 +1607,7 @@ function TypesSection({ title, types, isExpanded, onToggleExpand }) {
1667
1607
  },
1668
1608
  className: "min-h-0 overflow-hidden",
1669
1609
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1670
- className: "mt-1.5 space-y-1",
1610
+ className: "mt-0.5 flex flex-col gap-px",
1671
1611
  children: types.map((typeInfo) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DraggableFieldType, {
1672
1612
  typeInfo,
1673
1613
  className: "w-full"
@@ -1763,7 +1703,7 @@ function useFieldDnD(currentTable) {
1763
1703
 
1764
1704
  //#endregion
1765
1705
  //#region src/schema/schema-builder-fields/components/table-editor/table-editor.tsx
1766
- const PANEL_WIDTH_EXPANDED = 380;
1706
+ const PANEL_WIDTH_EXPANDED = 320;
1767
1707
  const PANEL_WIDTH_COLLAPSED = 56;
1768
1708
  const tweenConfig = {
1769
1709
  duration: require_use_update_table.durations.normal,
@@ -1772,14 +1712,11 @@ const tweenConfig = {
1772
1712
  const totalTypesCount = require_invalidate_database_entities.FIELD_TYPE_CATEGORIES.reduce((sum, cat) => sum + cat.types.length, 0);
1773
1713
  function TypesLibraryHeader({ isExpanded, onToggle }) {
1774
1714
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1775
- className: "flex items-center justify-between border-b px-3 py-2",
1776
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1777
- className: "flex items-center gap-2",
1778
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
1779
- className: "text-balance text-sm font-medium",
1780
- children: "Types Library"
1781
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1782
- className: "text-muted-foreground bg-muted rounded-md px-1.5 py-0.5 text-xs tabular-nums",
1715
+ className: "flex h-12 shrink-0 items-center justify-between px-3",
1716
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("h3", {
1717
+ className: "text-foreground text-[13px] font-medium",
1718
+ children: ["Types library", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1719
+ className: "text-subtle-foreground ml-1.5 font-normal tabular-nums",
1783
1720
  children: totalTypesCount
1784
1721
  })]
1785
1722
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_button.Button, {
@@ -1794,7 +1731,7 @@ function TypesLibraryHeader({ isExpanded, onToggle }) {
1794
1731
  }
1795
1732
  function CollapsedHeader({ onToggle }) {
1796
1733
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1797
- className: "flex items-center justify-center border-b py-2",
1734
+ className: "flex h-12 shrink-0 items-center justify-center",
1798
1735
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_constructive_io_ui_button.Button, {
1799
1736
  variant: "ghost",
1800
1737
  size: "sm",
@@ -1823,10 +1760,10 @@ function TableEditor() {
1823
1760
  "data-chat-table-name": currentTable?.name ?? "",
1824
1761
  className: "relative flex min-h-0 min-w-0 flex-1 overflow-hidden",
1825
1762
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1826
- className: require_invalidate_database_entities.cn("scrollbar-neutral-thin relative min-h-0 w-full min-w-0 flex-1 overflow-auto !pr-0", currentTable && (panelExpanded ? "sm:!pr-[380px]" : "sm:!pr-14")),
1763
+ className: require_invalidate_database_entities.cn("scrollbar-neutral-thin relative min-h-0 w-full min-w-0 flex-1 overflow-auto !pr-0", currentTable && (panelExpanded ? "sm:!pr-[320px]" : "sm:!pr-14")),
1827
1764
  style: { paddingRight: currentTable ? panelExpanded ? PANEL_WIDTH_EXPANDED : PANEL_WIDTH_COLLAPSED : 0 },
1828
1765
  children: currentTable ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1829
- className: "min-h-full min-w-full space-y-8 p-3 pb-8 sm:p-6 sm:pb-12",
1766
+ className: "mx-auto flex min-h-full w-full max-w-4xl min-w-0 flex-col gap-5 px-3 py-5 pb-10 sm:px-6",
1830
1767
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableMetadataSection, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldsSection, { onAddFieldRef: handleAddFieldRef })]
1831
1768
  }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1832
1769
  className: "flex min-h-full min-w-full items-start justify-center p-6 pb-12",
@@ -1834,7 +1771,7 @@ function TableEditor() {
1834
1771
  })
1835
1772
  }), currentTable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1836
1773
  "data-state": panelExpanded ? "expanded" : "collapsed",
1837
- className: "bg-background border-border/60 absolute top-0 right-0 z-10 hidden h-full flex-col border-l sm:flex",
1774
+ className: "bg-sidebar border-sidebar-border absolute top-0 right-0 z-10 hidden h-full flex-col border-l sm:flex",
1838
1775
  style: { width: panelExpanded ? PANEL_WIDTH_EXPANDED : PANEL_WIDTH_COLLAPSED },
1839
1776
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1840
1777
  className: "relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",
@@ -1932,4 +1869,4 @@ Object.defineProperty(exports, 'useUpdateFieldOrder', {
1932
1869
  return useUpdateFieldOrder;
1933
1870
  }
1934
1871
  });
1935
- //# sourceMappingURL=table-editor-tS9seYfW.cjs.map
1872
+ //# sourceMappingURL=table-editor-CruD2mZQ.cjs.map