@mirror-physics/fractal-ui 0.2.0-next.1 → 0.2.0-next.10

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.
package/dist/index.cjs CHANGED
@@ -45,6 +45,7 @@ __export(index_exports, {
45
45
  Disclosure: () => Disclosure,
46
46
  Dropdown: () => Dropdown,
47
47
  FeatureCard: () => FeatureCard,
48
+ FileDropzone: () => FileDropzone,
48
49
  FolderCard: () => FolderCard,
49
50
  Input: () => Input,
50
51
  Label: () => Label,
@@ -52,6 +53,7 @@ __export(index_exports, {
52
53
  Modal: () => Modal,
53
54
  PromptCard: () => PromptCard,
54
55
  PromptGrid: () => PromptGrid,
56
+ SidePanel: () => SidePanel,
55
57
  Sidebar: () => Sidebar,
56
58
  SidebarBrand: () => SidebarBrand,
57
59
  SidebarFooter: () => SidebarFooter,
@@ -61,6 +63,7 @@ __export(index_exports, {
61
63
  SidebarSection: () => SidebarSection,
62
64
  SortableTable: () => SortableTable,
63
65
  Tabs: () => Tabs,
66
+ Textarea: () => Textarea,
64
67
  Toggle: () => Toggle,
65
68
  cn: () => cn,
66
69
  useEscapeDismiss: () => useEscapeDismiss
@@ -119,7 +122,7 @@ var colorPalette = {
119
122
  var sizeConfig = {
120
123
  xs: { height: "28px", padding: "4px 8px", iconOnly: "28px", fontSize: "0.75rem" },
121
124
  sm: { height: "32px", padding: "6px 12px", iconOnly: "32px", fontSize: "0.75rem" },
122
- md: { height: "38px", padding: "8px 16px", iconOnly: "38px", fontSize: "0.875rem" },
125
+ md: { height: "40px", padding: "8px 16px", iconOnly: "40px", fontSize: "0.875rem" },
123
126
  lg: { height: "44px", padding: "10px 20px", iconOnly: "44px", fontSize: "1rem" },
124
127
  xl: { height: "56px", padding: "14px 28px", iconOnly: "56px", fontSize: "1rem" }
125
128
  };
@@ -749,7 +752,8 @@ function SortableTable({
749
752
  sortKey: controlledKey,
750
753
  sortDirection: controlledDirection,
751
754
  onSortChange,
752
- highlightRow
755
+ highlightRow,
756
+ onRowClick
753
757
  }) {
754
758
  const [internalKey, setInternalKey] = (0, import_react2.useState)(defaultSortKey ?? null);
755
759
  const [internalDirection, setInternalDirection] = (0, import_react2.useState)(defaultSortDirection);
@@ -850,8 +854,18 @@ function SortableTable({
850
854
  {
851
855
  className: cn(
852
856
  "fractal-sortable-table-row",
853
- highlighted && "fractal-sortable-table-row--highlighted"
857
+ highlighted && "fractal-sortable-table-row--highlighted",
858
+ onRowClick && "fractal-sortable-table-row--interactive"
854
859
  ),
860
+ onClick: onRowClick ? () => onRowClick(row, rowIndex) : void 0,
861
+ onKeyDown: onRowClick ? (event) => {
862
+ if (event.key === "Enter" || event.key === " ") {
863
+ event.preventDefault();
864
+ onRowClick(row, rowIndex);
865
+ }
866
+ } : void 0,
867
+ role: onRowClick ? "button" : void 0,
868
+ tabIndex: onRowClick ? 0 : void 0,
855
869
  children: columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
856
870
  "td",
857
871
  {
@@ -1096,6 +1110,141 @@ var SidebarFooter = React10.forwardRef(
1096
1110
  ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { ref, className: cn("fractal-sidebar__footer", className), ...props })
1097
1111
  );
1098
1112
  SidebarFooter.displayName = "SidebarFooter";
1113
+
1114
+ // src/components/SidePanel/SidePanel.tsx
1115
+ var import_react_dom2 = require("react-dom");
1116
+ var import_fractal_icons5 = require("@mirror-physics/fractal-icons");
1117
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1118
+ function SidePanel({ open, onClose, title, description, children, footer, size = "md", className }) {
1119
+ useEscapeDismiss(80, onClose, open);
1120
+ if (!open) return null;
1121
+ return (0, import_react_dom2.createPortal)(
1122
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "fractal-side-panel-overlay", onMouseDown: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1123
+ "aside",
1124
+ {
1125
+ className: cn("fractal-side-panel", `fractal-side-panel--${size}`, className),
1126
+ "aria-modal": "true",
1127
+ "aria-label": typeof title === "string" ? title : "Side panel",
1128
+ role: "dialog",
1129
+ onMouseDown: (event) => event.stopPropagation(),
1130
+ children: [
1131
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("header", { className: "fractal-side-panel__header", children: [
1132
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "fractal-side-panel__heading", children: [
1133
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h2", { className: "fractal-side-panel__title", children: title }),
1134
+ description && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "fractal-side-panel__description", children: description })
1135
+ ] }),
1136
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { type: "button", className: "fractal-side-panel__close", "aria-label": "Close panel", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_fractal_icons5.Close, { size: 18 }) })
1137
+ ] }),
1138
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "fractal-side-panel__body", children }),
1139
+ footer && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "fractal-side-panel__footer", children: footer })
1140
+ ]
1141
+ }
1142
+ ) }),
1143
+ document.body
1144
+ );
1145
+ }
1146
+
1147
+ // src/components/Textarea/Textarea.tsx
1148
+ var React11 = __toESM(require("react"), 1);
1149
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1150
+ var Textarea = React11.forwardRef(
1151
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("textarea", { ref, className: cn("fractal-textarea", className), ...props })
1152
+ );
1153
+ Textarea.displayName = "Textarea";
1154
+
1155
+ // src/components/FileDropzone/FileDropzone.tsx
1156
+ var React12 = __toESM(require("react"), 1);
1157
+ var import_fractal_icons6 = require("@mirror-physics/fractal-icons");
1158
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1159
+ function FileDropzone({
1160
+ files,
1161
+ onFilesChange,
1162
+ accept,
1163
+ multiple = true,
1164
+ disabled = false,
1165
+ title = "Drop files here or click to browse",
1166
+ description = "Files stay attached to this record.",
1167
+ className
1168
+ }) {
1169
+ const inputId = React12.useId();
1170
+ const inputRef = React12.useRef(null);
1171
+ const [isDragging, setIsDragging] = React12.useState(false);
1172
+ const addFiles = (nextFiles) => {
1173
+ if (disabled) return;
1174
+ const additions = Array.from(nextFiles);
1175
+ if (additions.length === 0) return;
1176
+ onFilesChange(multiple ? [...files, ...additions] : additions.slice(0, 1));
1177
+ };
1178
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: cn("fractal-file-dropzone", className), children: [
1179
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1180
+ "input",
1181
+ {
1182
+ ref: inputRef,
1183
+ id: inputId,
1184
+ className: "fractal-file-dropzone__input",
1185
+ type: "file",
1186
+ accept,
1187
+ multiple,
1188
+ disabled,
1189
+ onChange: (event) => {
1190
+ if (event.target.files) addFiles(event.target.files);
1191
+ event.target.value = "";
1192
+ }
1193
+ }
1194
+ ),
1195
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1196
+ "button",
1197
+ {
1198
+ className: "fractal-file-dropzone__target",
1199
+ "data-dragging": isDragging || void 0,
1200
+ type: "button",
1201
+ disabled,
1202
+ onClick: () => inputRef.current?.click(),
1203
+ onDragEnter: (event) => {
1204
+ event.preventDefault();
1205
+ if (!disabled) setIsDragging(true);
1206
+ },
1207
+ onDragOver: (event) => event.preventDefault(),
1208
+ onDragLeave: (event) => {
1209
+ event.preventDefault();
1210
+ setIsDragging(false);
1211
+ },
1212
+ onDrop: (event) => {
1213
+ event.preventDefault();
1214
+ setIsDragging(false);
1215
+ addFiles(event.dataTransfer.files);
1216
+ },
1217
+ children: [
1218
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_fractal_icons6.FileArrowUp, { "aria-hidden": "true", size: 20 }),
1219
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "fractal-file-dropzone__copy", children: [
1220
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "fractal-file-dropzone__title", children: title }),
1221
+ description && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "fractal-file-dropzone__description", children: description })
1222
+ ] })
1223
+ ]
1224
+ }
1225
+ ),
1226
+ files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("ul", { className: "fractal-file-dropzone__files", "aria-label": "Attached files", children: files.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("li", { className: "fractal-file-dropzone__file", children: [
1227
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "fractal-file-dropzone__file-name", children: file.name }),
1228
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "fractal-file-dropzone__file-meta", children: formatFileSize(file.size) }),
1229
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1230
+ "button",
1231
+ {
1232
+ className: "fractal-file-dropzone__remove",
1233
+ type: "button",
1234
+ "aria-label": `Remove ${file.name}`,
1235
+ disabled,
1236
+ onClick: () => onFilesChange(files.filter((_, fileIndex) => fileIndex !== index)),
1237
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_fractal_icons6.Close, { "aria-hidden": "true", size: 14 })
1238
+ }
1239
+ )
1240
+ ] }, `${file.name}-${file.size}-${index}`)) })
1241
+ ] });
1242
+ }
1243
+ function formatFileSize(bytes) {
1244
+ if (bytes < 1024) return `${bytes} B`;
1245
+ if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
1246
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
1247
+ }
1099
1248
  // Annotate the CommonJS export names for ESM import in node:
1100
1249
  0 && (module.exports = {
1101
1250
  Alert,
@@ -1113,6 +1262,7 @@ SidebarFooter.displayName = "SidebarFooter";
1113
1262
  Disclosure,
1114
1263
  Dropdown,
1115
1264
  FeatureCard,
1265
+ FileDropzone,
1116
1266
  FolderCard,
1117
1267
  Input,
1118
1268
  Label,
@@ -1120,6 +1270,7 @@ SidebarFooter.displayName = "SidebarFooter";
1120
1270
  Modal,
1121
1271
  PromptCard,
1122
1272
  PromptGrid,
1273
+ SidePanel,
1123
1274
  Sidebar,
1124
1275
  SidebarBrand,
1125
1276
  SidebarFooter,
@@ -1129,6 +1280,7 @@ SidebarFooter.displayName = "SidebarFooter";
1129
1280
  SidebarSection,
1130
1281
  SortableTable,
1131
1282
  Tabs,
1283
+ Textarea,
1132
1284
  Toggle,
1133
1285
  cn,
1134
1286
  useEscapeDismiss