@handylib/kai-code 0.1.1 → 0.1.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.
package/README.md CHANGED
@@ -42,9 +42,10 @@ export function Playground() {
42
42
  }
43
43
  ```
44
44
 
45
- KaiCode fills its parent by default at `640px` high; set the `height` prop or
46
- give the component a sized parent. Monaco's worker configuration may need to be
47
- set up by your bundler, as with any application using Monaco Editor. See the
45
+ KaiCode uses a viewport-responsive height by default. Set the `height` prop or
46
+ give the component a sized parent to control its dimensions. Monaco's worker
47
+ configuration may need to be set up by your bundler, as with any application
48
+ using Monaco Editor. See the
48
49
  [`@monaco-editor/react` documentation](https://github.com/suren-atoyan/monaco-react)
49
50
  for bundler-specific worker setup.
50
51
 
@@ -147,8 +148,13 @@ the failure in the workbench instead of treating it as success.
147
148
  | `initialFiles` | `Record<string, string>` | Demo files | Initial paths and contents for the built-in in-memory filesystem. Ignored when `fileSystem` is provided. |
148
149
  | `initialActiveFile` | `string` | First file in the tree | File path selected after loading. |
149
150
  | `theme` | `string` | `"vs-dark"` | Monaco theme name, such as `"vs-dark"` or `"light"`. |
151
+ | `workspaceName` | `string` | `"Workspace"` | Name shown in the title bar and Explorer. |
150
152
  | `options` | `editor.IStandaloneEditorConstructionOptions` | KaiCode defaults | Additional Monaco editor options. |
151
- | `height` | `string \| number` | `640` | Height of the workbench. |
153
+ | `height` | `CSSProperties["height"]` | `min(80dvh, 760px)` | Workbench height. Accepts a CSS length, percentage, or expression. |
154
+ | `colors` | `KaiCodeColors` | Theme palette | Optional workbench color overrides. |
155
+ | `rounded` | `boolean` | `true` | Set `false` for flat, square outer corners. |
156
+ | `icons` | `Partial<Record<KaiCodeIconName, ReactNode>>` | Built-in glyphs | Override action, folder, and Explorer icons with React elements, SVGs, or emoji. |
157
+ | `fileIcons` | `Record<string, ReactNode>` | Built-in file glyphs | Override file icons by lowercase extension (for example `tsx`) or `default`. |
152
158
  | `readOnly` | `boolean` | `false` | Prevent editing and saving. |
153
159
  | `className` | `string` | — | Class added to the outer workbench element. |
154
160
  | `onFileChange` | `(path, contents) => void` | — | Called when the active document changes in the editor. |
@@ -158,6 +164,61 @@ Documents are saved on **Save** or `Ctrl+S` / `Cmd+S`; editing does not write
158
164
  through to the adapter until a save succeeds. The in-memory filesystem can also
159
165
  be created directly with `createMemoryFileSystem(initialFiles)`.
160
166
 
167
+ ### Responsive size and appearance
168
+
169
+ KaiCode's default height tracks the viewport (`min(80dvh, 760px)`). Set
170
+ `height="100%"` to fill a parent with an explicit height, or pass any valid CSS
171
+ height value such as `"70vh"` or `"clamp(360px, 75dvh, 900px)"`. The workbench
172
+ uses a responsive Explorer layout when embedded in narrower containers.
173
+
174
+ ```tsx
175
+ import { KaiCode } from "@handylib/kai-code";
176
+
177
+ export function BrandedEditor() {
178
+ return (
179
+ <div style={{ height: "min(90dvh, 1000px)" }}>
180
+ <KaiCode
181
+ height="100%"
182
+ workspaceName="Acme Dashboard"
183
+ rounded={false}
184
+ colors={{
185
+ background: "#111827",
186
+ sidebarBackground: "#0b1220",
187
+ titlebarBackground: "#0b1220",
188
+ panelBackground: "#1f2937",
189
+ foreground: "#e5e7eb",
190
+ mutedForeground: "#9ca3af",
191
+ border: "#374151",
192
+ accent: "#8b5cf6",
193
+ statusBarBackground: "#6d28d9",
194
+ statusBarForeground: "#ffffff",
195
+ fileSelectionBackground: "#312e81",
196
+ }}
197
+ icons={{
198
+ brand: "🚀",
199
+ folder: "📁",
200
+ newFile: "+",
201
+ newFolder: "📂",
202
+ collapseAll: "⊟",
203
+ delete: "🗑️",
204
+ }}
205
+ fileIcons={{
206
+ tsx: "⚛️",
207
+ ts: "🔷",
208
+ default: "📄",
209
+ }}
210
+ />
211
+ </div>
212
+ );
213
+ }
214
+ ```
215
+
216
+ Icon values are `ReactNode`s, so icon components from packages such as
217
+ `lucide-react`, inline SVG elements, and emoji are supported. For example, pass
218
+ `folder: <Folder size={16} />` after importing the icon from your chosen icon
219
+ library. `colors` customizes the KaiCode workbench; `theme` still controls
220
+ Monaco's editor theme independently.
221
+
161
222
  ## Explorer controls
162
223
 
163
224
  - Right-click a file or folder to open its context menu. Available create and
@@ -185,9 +246,9 @@ import "@handylib/kai-code/style.css";
185
246
  ```
186
247
 
187
248
  The default workbench uses a dark VS Code-inspired palette. Set `theme="light"`
188
- for the matching light workbench, or pass any Monaco theme name. The layout is
189
- scoped under `.kai-code`; `className` can be used to set a width or add
190
- application-specific styling.
249
+ for the matching light workbench, or pass any Monaco theme name. Use `colors`
250
+ for workbench color overrides. The layout is scoped under `.kai-code`;
251
+ `className` can be used to set a width or add application-specific styling.
191
252
 
192
253
  ## Development
193
254
 
package/dist/index.cjs CHANGED
@@ -294,6 +294,13 @@ function getFileGlyph(path) {
294
294
  if (extension === "css" || extension === "scss") return "#";
295
295
  return "\xB7";
296
296
  }
297
+ function getFileIcon(path, fileIcons, icons) {
298
+ const extension = path.split(".").pop()?.toLowerCase() ?? "";
299
+ return fileIcons?.[extension] ?? fileIcons?.default ?? icons?.file ?? getFileGlyph(path);
300
+ }
301
+ function getIcon(icons, name, fallback) {
302
+ return icons?.[name] ?? fallback;
303
+ }
297
304
  function errorMessage(error) {
298
305
  return error instanceof Error ? error.message : String(error);
299
306
  }
@@ -355,6 +362,8 @@ function FileTree({
355
362
  collapsedFolders,
356
363
  onToggleDirectory,
357
364
  onContextMenu,
365
+ icons,
366
+ fileIcons,
358
367
  depth = 0
359
368
  }) {
360
369
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: nodes.map(
@@ -372,7 +381,7 @@ function FileTree({
372
381
  style: { "--tree-depth": depth },
373
382
  children: [
374
383
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__chevron", "aria-hidden": "true", children: "\u25B8" }),
375
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__folder-icon", "aria-hidden": "true", children: "\u25B0" }),
384
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__folder-icon", "aria-hidden": "true", children: getIcon(icons, "folder", "\u25B0") }),
376
385
  node.name
377
386
  ]
378
387
  }
@@ -386,6 +395,8 @@ function FileTree({
386
395
  collapsedFolders,
387
396
  onToggleDirectory,
388
397
  onContextMenu,
398
+ icons,
399
+ fileIcons,
389
400
  depth: depth + 1
390
401
  }
391
402
  )
@@ -401,7 +412,7 @@ function FileTree({
401
412
  style: { "--tree-depth": depth },
402
413
  type: "button",
403
414
  children: [
404
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__file-icon", "aria-hidden": "true", children: getFileGlyph(node.path) }),
415
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__file-icon", "aria-hidden": "true", children: getFileIcon(node.path, fileIcons, icons) }),
405
416
  node.name
406
417
  ]
407
418
  },
@@ -414,8 +425,13 @@ function KaiCode({
414
425
  initialFiles,
415
426
  initialActiveFile,
416
427
  theme = "vs-dark",
428
+ workspaceName = "Workspace",
417
429
  options,
418
- height = 640,
430
+ height = "min(80dvh, 760px)",
431
+ colors,
432
+ rounded = true,
433
+ icons,
434
+ fileIcons,
419
435
  readOnly = false,
420
436
  className,
421
437
  onFileChange,
@@ -800,18 +816,33 @@ function KaiCode({
800
816
  [options, readOnly]
801
817
  );
802
818
  const activeLanguage = activeFile ? findFileEntry(tree, activeFile)?.language ?? getLanguage(activeFile) : null;
819
+ const rootStyle = {
820
+ height,
821
+ borderRadius: rounded ? 6 : 0,
822
+ "--kc-background": colors?.background,
823
+ "--kc-sidebar": colors?.sidebarBackground,
824
+ "--kc-titlebar": colors?.titlebarBackground,
825
+ "--kc-panel": colors?.panelBackground,
826
+ "--kc-text": colors?.foreground,
827
+ "--kc-muted": colors?.mutedForeground,
828
+ "--kc-border": colors?.border,
829
+ "--kc-accent": colors?.accent,
830
+ "--kc-status-background": colors?.statusBarBackground,
831
+ "--kc-status-foreground": colors?.statusBarForeground,
832
+ "--kc-selection": colors?.fileSelectionBackground
833
+ };
803
834
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
804
835
  "section",
805
836
  {
806
837
  className: `kai-code${isLight ? " kai-code--light" : ""}${className ? ` ${className}` : ""}`,
807
- style: { height },
838
+ style: rootStyle,
808
839
  "aria-label": "KaiCode editor",
809
840
  children: [
810
841
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "kai-code__titlebar", children: [
811
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__brand-mark", "aria-hidden": "true", children: "K" }),
842
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__brand-mark", "aria-hidden": "true", children: getIcon(icons, "brand", "K") }),
812
843
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__brand", children: "KaiCode" }),
813
844
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__title-divider" }),
814
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__workspace-title", children: "Workspace" }),
845
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__workspace-title", children: workspaceName }),
815
846
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__title-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
816
847
  "button",
817
848
  {
@@ -839,10 +870,18 @@ function KaiCode({
839
870
  title: "Explorer (Ctrl+B)",
840
871
  onClick: () => setExplorerVisible((visible) => !visible),
841
872
  type: "button",
842
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [
843
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 5.5h6l2 2h9v11h-17z" }),
844
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 8h17" })
845
- ] })
873
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__activity-icon", "aria-hidden": "true", children: icons?.explorer ?? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
874
+ "svg",
875
+ {
876
+ className: "kai-code__default-explorer-icon",
877
+ viewBox: "0 0 24 24",
878
+ "aria-hidden": "true",
879
+ children: [
880
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 5.5h6l2 2h9v11h-17z" }),
881
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 8h17" })
882
+ ]
883
+ }
884
+ ) })
846
885
  }
847
886
  ),
848
887
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__activity-spacer" }),
@@ -866,7 +905,7 @@ function KaiCode({
866
905
  title: "New File",
867
906
  onClick: () => beginCreate("file", ""),
868
907
  type: "button",
869
- children: "+"
908
+ children: getIcon(icons, "newFile", "+")
870
909
  }
871
910
  ),
872
911
  fs.createDirectory && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -877,7 +916,7 @@ function KaiCode({
877
916
  title: "New Folder",
878
917
  onClick: () => beginCreate("directory", ""),
879
918
  type: "button",
880
- children: "\u25B0+"
919
+ children: getIcon(icons, "newFolder", "\u25B0+")
881
920
  }
882
921
  ),
883
922
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -888,14 +927,14 @@ function KaiCode({
888
927
  title: "Collapse All (Ctrl+K Ctrl+0)",
889
928
  onClick: collapseAll,
890
929
  type: "button",
891
- children: "\u229F"
930
+ children: getIcon(icons, "collapseAll", "\u229F")
892
931
  }
893
932
  )
894
933
  ] })
895
934
  ] }),
896
935
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "kai-code__workspace-row", children: [
897
936
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__chevron", "aria-hidden": "true", children: "\u25BE" }),
898
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "WORKSPACE" })
937
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: workspaceName })
899
938
  ] }),
900
939
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__file-tree", children: loadingTree && tree.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__empty", children: "Loading files\u2026" }) : tree.length ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
901
940
  FileTree,
@@ -905,7 +944,9 @@ function KaiCode({
905
944
  onOpen: openFile,
906
945
  collapsedFolders,
907
946
  onToggleDirectory: toggleDirectory,
908
- onContextMenu: openContextMenu
947
+ onContextMenu: openContextMenu,
948
+ icons,
949
+ fileIcons
909
950
  }
910
951
  ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__empty", children: "No files in this workspace" }) })
911
952
  ]
@@ -967,7 +1008,7 @@ function KaiCode({
967
1008
  onClick: (event) => event.stopPropagation(),
968
1009
  onContextMenu: (event) => event.preventDefault(),
969
1010
  children: [
970
- fs.createFile && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1011
+ fs.createFile && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
971
1012
  "button",
972
1013
  {
973
1014
  role: "menuitem",
@@ -976,10 +1017,13 @@ function KaiCode({
976
1017
  contextMenu.entry.type === "directory" ? contextMenu.entry.path : parentDirectory(contextMenu.entry.path)
977
1018
  ),
978
1019
  type: "button",
979
- children: "New File"
1020
+ children: [
1021
+ getIcon(icons, "newFile", "\uFF0B"),
1022
+ " New File"
1023
+ ]
980
1024
  }
981
1025
  ),
982
- fs.createDirectory && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1026
+ fs.createDirectory && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
983
1027
  "button",
984
1028
  {
985
1029
  role: "menuitem",
@@ -988,10 +1032,13 @@ function KaiCode({
988
1032
  contextMenu.entry.type === "directory" ? contextMenu.entry.path : parentDirectory(contextMenu.entry.path)
989
1033
  ),
990
1034
  type: "button",
991
- children: "New Folder"
1035
+ children: [
1036
+ getIcon(icons, "newFolder", "\u25B0"),
1037
+ " New Folder"
1038
+ ]
992
1039
  }
993
1040
  ),
994
- (contextMenu.entry.type === "file" && (fs.moveFile || fs.renameFile) || contextMenu.entry.type === "directory" && fs.moveDirectory) && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1041
+ (contextMenu.entry.type === "file" && (fs.moveFile || fs.renameFile) || contextMenu.entry.type === "directory" && fs.moveDirectory) && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
995
1042
  "button",
996
1043
  {
997
1044
  role: "menuitem",
@@ -1002,12 +1049,15 @@ function KaiCode({
1002
1049
  setContextMenu(null);
1003
1050
  },
1004
1051
  type: "button",
1005
- children: "Move\u2026"
1052
+ children: [
1053
+ getIcon(icons, "move", "\u2197"),
1054
+ " Move\u2026"
1055
+ ]
1006
1056
  }
1007
1057
  ),
1008
1058
  (contextMenu.entry.type === "file" && fs.deleteFile || contextMenu.entry.type === "directory" && fs.deleteDirectory) && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1009
1059
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__context-divider" }),
1010
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1060
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1011
1061
  "button",
1012
1062
  {
1013
1063
  className: "is-danger",
@@ -1018,7 +1068,10 @@ function KaiCode({
1018
1068
  setContextMenu(null);
1019
1069
  },
1020
1070
  type: "button",
1021
- children: "Delete"
1071
+ children: [
1072
+ getIcon(icons, "delete", "\u232B"),
1073
+ " Delete"
1074
+ ]
1022
1075
  }
1023
1076
  )
1024
1077
  ] })
@@ -1043,7 +1096,7 @@ function KaiCode({
1043
1096
  "aria-selected": activeFile === path,
1044
1097
  type: "button",
1045
1098
  children: [
1046
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__file-icon", "aria-hidden": "true", children: getFileGlyph(path) }),
1099
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__file-icon", "aria-hidden": "true", children: getFileIcon(path, fileIcons, icons) }),
1047
1100
  fileName,
1048
1101
  dirtyFiles.has(path) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "kai-code__dirty-dot", "aria-label": "Unsaved" })
1049
1102
  ]
@@ -1056,7 +1109,7 @@ function KaiCode({
1056
1109
  "aria-label": `Close ${fileName}`,
1057
1110
  onClick: () => closeFile(path),
1058
1111
  type: "button",
1059
- children: "\xD7"
1112
+ children: getIcon(icons, "close", "\xD7")
1060
1113
  }
1061
1114
  )
1062
1115
  ]
@@ -1116,7 +1169,7 @@ function KaiCode({
1116
1169
  },
1117
1170
  activeFile
1118
1171
  ) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "kai-code__welcome", children: [
1119
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__welcome-mark", children: "K" }),
1172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "kai-code__welcome-mark", children: getIcon(icons, "brand", "K") }),
1120
1173
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { children: "KaiCode" }),
1121
1174
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Select a file from the Explorer to start editing." })
1122
1175
  ] }) })
package/dist/index.css CHANGED
@@ -7,15 +7,22 @@
7
7
  --kc-muted: #858585;
8
8
  --kc-text: #cccccc;
9
9
  --kc-accent: #007acc;
10
+ --kc-titlebar: #181818;
11
+ --kc-status-background: #007acc;
12
+ --kc-status-foreground: #ffffff;
13
+ --kc-selection: #37373d;
10
14
  position: relative;
15
+ container-type: inline-size;
11
16
  display: flex;
12
17
  flex-direction: column;
13
- min-width: 520px;
18
+ min-width: 0;
19
+ max-width: 100%;
20
+ min-height: 0;
21
+ max-height: 100dvh;
14
22
  overflow: hidden;
15
23
  color: var(--kc-text);
16
24
  background: var(--kc-background);
17
- border: 1px solid #111;
18
- border-radius: 6px;
25
+ border: 1px solid var(--kc-border);
19
26
  font-family:
20
27
  -apple-system,
21
28
  BlinkMacSystemFont,
@@ -40,8 +47,8 @@
40
47
  align-items: center;
41
48
  gap: 9px;
42
49
  padding: 0 12px;
43
- background: #181818;
44
- border-bottom: 1px solid #111;
50
+ background: var(--kc-titlebar);
51
+ border-bottom: 1px solid var(--kc-border);
45
52
  user-select: none;
46
53
  }
47
54
  .kai-code__brand-mark,
@@ -49,7 +56,7 @@
49
56
  display: grid;
50
57
  place-items: center;
51
58
  color: white;
52
- background: #0877c9;
59
+ background: var(--kc-accent);
53
60
  border-radius: 5px;
54
61
  font-weight: 700;
55
62
  }
@@ -59,17 +66,17 @@
59
66
  font-size: 13px;
60
67
  }
61
68
  .kai-code__brand {
62
- color: #e6e6e6;
69
+ color: var(--kc-text);
63
70
  font-weight: 600;
64
71
  }
65
72
  .kai-code__title-divider {
66
73
  width: 1px;
67
74
  height: 17px;
68
75
  margin: 0 3px;
69
- background: #3b3b3b;
76
+ background: var(--kc-border);
70
77
  }
71
78
  .kai-code__workspace-title {
72
- color: #bcbcbc;
79
+ color: var(--kc-muted);
73
80
  }
74
81
  .kai-code__title-actions {
75
82
  display: flex;
@@ -78,9 +85,9 @@
78
85
  }
79
86
  .kai-code__title-button {
80
87
  padding: 3px 9px;
81
- color: #ddd;
82
- background: #333;
83
- border: 1px solid #454545;
88
+ color: var(--kc-text);
89
+ background: var(--kc-panel);
90
+ border: 1px solid var(--kc-border);
84
91
  border-radius: 3px;
85
92
  cursor: pointer;
86
93
  }
@@ -99,8 +106,8 @@
99
106
  flex-direction: column;
100
107
  align-items: center;
101
108
  padding: 5px 0;
102
- background: #181818;
103
- border-right: 1px solid #242424;
109
+ background: var(--kc-titlebar);
110
+ border-right: 1px solid var(--kc-border);
104
111
  }
105
112
  .kai-code__activity-button {
106
113
  position: relative;
@@ -108,19 +115,27 @@
108
115
  width: 47px;
109
116
  height: 48px;
110
117
  place-items: center;
111
- color: #858585;
118
+ color: var(--kc-muted);
112
119
  background: transparent;
113
120
  border: 0;
114
121
  border-left: 2px solid transparent;
115
122
  cursor: pointer;
116
123
  }
117
124
  .kai-code__activity-button.is-active {
118
- color: #e7e7e7;
119
- border-left-color: #e7e7e7;
125
+ color: var(--kc-text);
126
+ border-left-color: var(--kc-text);
127
+ }
128
+ .kai-code__activity-icon {
129
+ display: grid;
130
+ width: 23px;
131
+ height: 23px;
132
+ place-items: center;
120
133
  }
121
- .kai-code__activity-button svg {
134
+ .kai-code__activity-icon svg {
122
135
  width: 23px;
123
136
  height: 23px;
137
+ }
138
+ .kai-code__activity-icon .kai-code__default-explorer-icon {
124
139
  fill: none;
125
140
  stroke: currentColor;
126
141
  stroke-linecap: round;
@@ -136,8 +151,8 @@
136
151
  height: 24px;
137
152
  place-items: center;
138
153
  margin-bottom: 7px;
139
- color: #ddd;
140
- background: #454545;
154
+ color: var(--kc-text);
155
+ background: var(--kc-panel);
141
156
  border-radius: 50%;
142
157
  font-size: 11px;
143
158
  }
@@ -161,7 +176,7 @@
161
176
  align-items: center;
162
177
  justify-content: space-between;
163
178
  padding: 0 12px 0 18px;
164
- color: #bbb;
179
+ color: var(--kc-muted);
165
180
  font-size: 11px;
166
181
  letter-spacing: 0.7px;
167
182
  }
@@ -169,15 +184,15 @@
169
184
  min-width: 24px;
170
185
  height: 24px;
171
186
  padding: 0 3px;
172
- color: #bcbcbc;
187
+ color: var(--kc-muted);
173
188
  background: transparent;
174
189
  border: 0;
175
190
  font-size: 17px !important;
176
191
  cursor: pointer;
177
192
  }
178
193
  .kai-code__icon-button:hover {
179
- color: #fff;
180
- background: #333;
194
+ color: var(--kc-text);
195
+ background: var(--kc-panel);
181
196
  }
182
197
  .kai-code__resizer {
183
198
  z-index: 1;
@@ -196,7 +211,7 @@
196
211
  align-items: center;
197
212
  gap: 6px;
198
213
  padding: 0 9px;
199
- color: #ddd;
214
+ color: var(--kc-text);
200
215
  font-size: 11px;
201
216
  font-weight: 700;
202
217
  letter-spacing: 0.35px;
@@ -213,7 +228,7 @@
213
228
  gap: 6px;
214
229
  padding: 0 8px 0 calc(9px + var(--tree-depth, 0) * 13px);
215
230
  overflow: hidden;
216
- color: #ccc;
231
+ color: var(--kc-text);
217
232
  background: transparent;
218
233
  border: 0;
219
234
  cursor: pointer;
@@ -226,16 +241,16 @@
226
241
  }
227
242
  .kai-code__directory summary:hover,
228
243
  .kai-code__file:hover {
229
- background: #2a2d2e;
244
+ background: var(--kc-panel);
230
245
  }
231
246
  .kai-code__file.is-active {
232
- color: #fff;
233
- background: #37373d;
247
+ color: var(--kc-text);
248
+ background: var(--kc-selection);
234
249
  }
235
250
  .kai-code__chevron {
236
251
  display: inline-block;
237
252
  width: 10px;
238
- color: #aaa;
253
+ color: var(--kc-muted);
239
254
  font-size: 10px;
240
255
  transition: transform 100ms ease;
241
256
  }
@@ -243,7 +258,7 @@
243
258
  transform: rotate(90deg);
244
259
  }
245
260
  .kai-code__folder-icon {
246
- color: #dcb67a;
261
+ color: var(--kc-accent);
247
262
  font-size: 12px;
248
263
  }
249
264
  .kai-code__file-icon {
@@ -251,7 +266,7 @@
251
266
  width: 15px;
252
267
  flex: 0 0 15px;
253
268
  place-items: center;
254
- color: #8cacf2;
269
+ color: var(--kc-accent);
255
270
  font-size: 11px;
256
271
  }
257
272
  .kai-code__editor-area {
@@ -265,7 +280,7 @@
265
280
  display: flex;
266
281
  flex: 0 0 35px;
267
282
  overflow: auto hidden;
268
- background: #181818;
283
+ background: var(--kc-titlebar);
269
284
  scrollbar-width: none;
270
285
  }
271
286
  .kai-code__tabs::-webkit-scrollbar {
@@ -276,8 +291,8 @@
276
291
  min-width: 120px;
277
292
  max-width: 200px;
278
293
  align-items: center;
279
- background: #2d2d2d;
280
- border-right: 1px solid #252525;
294
+ background: var(--kc-panel);
295
+ border-right: 1px solid var(--kc-border);
281
296
  }
282
297
  .kai-code__tab.is-active {
283
298
  background: var(--kc-background);
@@ -292,7 +307,7 @@
292
307
  gap: 6px;
293
308
  padding: 0 5px 0 12px;
294
309
  overflow: hidden;
295
- color: #aaa;
310
+ color: var(--kc-muted);
296
311
  background: transparent;
297
312
  border: 0;
298
313
  cursor: pointer;
@@ -300,7 +315,7 @@
300
315
  white-space: nowrap;
301
316
  }
302
317
  .kai-code__tab.is-active .kai-code__tab-label {
303
- color: #e4e4e4;
318
+ color: var(--kc-text);
304
319
  }
305
320
  .kai-code__tab-close {
306
321
  display: grid;
@@ -308,7 +323,7 @@
308
323
  height: 25px;
309
324
  flex: 0 0 25px;
310
325
  place-items: center;
311
- color: #aaa;
326
+ color: var(--kc-muted);
312
327
  background: transparent;
313
328
  border: 0;
314
329
  border-radius: 4px;
@@ -316,7 +331,7 @@
316
331
  font-size: 17px !important;
317
332
  }
318
333
  .kai-code__tab-close:hover {
319
- background: #444;
334
+ background: var(--kc-border);
320
335
  }
321
336
  .kai-code__dirty-dot {
322
337
  width: 7px;
@@ -331,7 +346,7 @@
331
346
  align-items: center;
332
347
  gap: 4px;
333
348
  padding: 0 15px;
334
- color: #aaa;
349
+ color: var(--kc-muted);
335
350
  font-size: 11px;
336
351
  }
337
352
  .kai-code__breadcrumb-separator {
@@ -352,8 +367,8 @@
352
367
  align-items: center;
353
368
  justify-content: space-between;
354
369
  padding: 0 9px;
355
- color: white;
356
- background: #007acc;
370
+ background: var(--kc-status-background);
371
+ color: var(--kc-status-foreground);
357
372
  font-size: 11px;
358
373
  user-select: none;
359
374
  }
@@ -389,7 +404,7 @@
389
404
  flex-direction: column;
390
405
  align-items: center;
391
406
  justify-content: center;
392
- color: #858585;
407
+ color: var(--kc-muted);
393
408
  text-align: center;
394
409
  }
395
410
  .kai-code__welcome-mark {
@@ -399,7 +414,7 @@
399
414
  }
400
415
  .kai-code__welcome h1 {
401
416
  margin: 14px 0 2px;
402
- color: #ccc;
417
+ color: var(--kc-text);
403
418
  font-size: 20px;
404
419
  font-weight: 500;
405
420
  }
@@ -414,9 +429,9 @@
414
429
  justify-content: space-between;
415
430
  gap: 12px;
416
431
  padding: 4px 10px;
417
- color: #f0caca;
418
- background: #5a2727;
419
- border-bottom: 1px solid #7d3939;
432
+ color: var(--kc-text);
433
+ background: var(--kc-panel);
434
+ border-bottom: 1px solid var(--kc-border);
420
435
  }
421
436
  .kai-code__error button {
422
437
  color: inherit;
@@ -430,9 +445,9 @@
430
445
  z-index: 20;
431
446
  min-width: 170px;
432
447
  padding: 4px;
433
- color: #ddd;
434
- background: #252526;
435
- border: 1px solid #454545;
448
+ color: var(--kc-text);
449
+ background: var(--kc-panel);
450
+ border: 1px solid var(--kc-border);
436
451
  border-radius: 5px;
437
452
  box-shadow: 0 8px 24px rgb(0 0 0 / 35%);
438
453
  }
@@ -448,7 +463,7 @@
448
463
  text-align: left;
449
464
  }
450
465
  .kai-code__context-menu button:hover {
451
- background: #094771;
466
+ background: var(--kc-accent);
452
467
  }
453
468
  .kai-code__context-menu button.is-danger:hover {
454
469
  background: #5a2727;
@@ -456,7 +471,7 @@
456
471
  .kai-code__context-divider {
457
472
  height: 1px;
458
473
  margin: 4px 5px;
459
- background: #454545;
474
+ background: var(--kc-border);
460
475
  }
461
476
  .kai-code__dialog-backdrop {
462
477
  position: absolute;
@@ -470,21 +485,21 @@
470
485
  .kai-code__dialog {
471
486
  width: min(360px, 100%);
472
487
  padding: 18px;
473
- color: #ddd;
474
- background: #252526;
475
- border: 1px solid #454545;
488
+ color: var(--kc-text);
489
+ background: var(--kc-panel);
490
+ border: 1px solid var(--kc-border);
476
491
  border-radius: 6px;
477
492
  box-shadow: 0 12px 36px rgb(0 0 0 / 40%);
478
493
  }
479
494
  .kai-code__dialog h2 {
480
495
  margin: 0 0 8px;
481
- color: #f0f0f0;
496
+ color: var(--kc-text);
482
497
  font-size: 15px;
483
498
  font-weight: 600;
484
499
  }
485
500
  .kai-code__dialog p {
486
501
  margin: 0 0 14px;
487
- color: #a9a9a9;
502
+ color: var(--kc-muted);
488
503
  overflow-wrap: anywhere;
489
504
  }
490
505
  .kai-code__dialog p.kai-code__dialog-error {
@@ -494,14 +509,14 @@
494
509
  .kai-code__dialog label {
495
510
  display: block;
496
511
  margin-bottom: 5px;
497
- color: #c8c8c8;
512
+ color: var(--kc-text);
498
513
  }
499
514
  .kai-code__dialog input {
500
515
  width: 100%;
501
516
  padding: 7px 8px;
502
- color: #eee;
503
- background: #3c3c3c;
504
- border: 1px solid #007fd4;
517
+ color: var(--kc-text);
518
+ background: var(--kc-background);
519
+ border: 1px solid var(--kc-accent);
505
520
  border-radius: 3px;
506
521
  font: inherit;
507
522
  outline: 0;
@@ -515,9 +530,9 @@
515
530
  .kai-code__dialog-actions button {
516
531
  min-width: 70px;
517
532
  padding: 5px 10px;
518
- color: #ddd;
519
- background: #3a3d41;
520
- border: 1px solid #555;
533
+ color: var(--kc-text);
534
+ background: var(--kc-background);
535
+ border: 1px solid var(--kc-border);
521
536
  border-radius: 3px;
522
537
  cursor: pointer;
523
538
  }
@@ -539,12 +554,16 @@
539
554
  --kc-muted: #777;
540
555
  --kc-text: #333;
541
556
  --kc-accent: #007acc;
542
- border-color: #d0d0d0;
557
+ --kc-titlebar: #f3f3f3;
558
+ --kc-status-background: #007acc;
559
+ --kc-status-foreground: #ffffff;
560
+ --kc-selection: #cce8ff;
561
+ border-color: var(--kc-border);
543
562
  }
544
563
  .kai-code--light .kai-code__titlebar,
545
564
  .kai-code--light .kai-code__activity-bar,
546
565
  .kai-code--light .kai-code__tabs {
547
- background: #f3f3f3;
566
+ background: var(--kc-titlebar);
548
567
  }
549
568
  .kai-code--light .kai-code__brand,
550
569
  .kai-code--light .kai-code__workspace-title,
@@ -553,42 +572,51 @@
553
572
  .kai-code--light .kai-code__directory summary,
554
573
  .kai-code--light .kai-code__file,
555
574
  .kai-code--light .kai-code__tab.is-active .kai-code__tab-label {
556
- color: #333;
575
+ color: var(--kc-text);
557
576
  }
558
577
  .kai-code--light .kai-code__tab {
559
- background: #ececec;
578
+ background: var(--kc-panel);
560
579
  }
561
580
  .kai-code--light .kai-code__tab.is-active {
562
- background: #fff;
581
+ background: var(--kc-background);
563
582
  }
564
583
  .kai-code--light .kai-code__file.is-active {
565
- color: #111;
566
- background: #cce8ff;
584
+ color: var(--kc-text);
585
+ background: var(--kc-selection);
567
586
  }
568
587
  .kai-code--light .kai-code__context-menu,
569
588
  .kai-code--light .kai-code__dialog {
570
- color: #333;
571
- background: #f3f3f3;
572
- border-color: #ccc;
589
+ color: var(--kc-text);
590
+ background: var(--kc-panel);
591
+ border-color: var(--kc-border);
573
592
  }
574
593
  .kai-code--light .kai-code__dialog h2,
575
594
  .kai-code--light .kai-code__dialog label {
576
- color: #222;
595
+ color: var(--kc-text);
577
596
  }
578
597
  .kai-code--light .kai-code__dialog p {
579
- color: #666;
598
+ color: var(--kc-muted);
580
599
  }
581
600
  .kai-code--light .kai-code__dialog input {
582
- color: #222;
583
- background: white;
584
- border-color: #007acc;
601
+ color: var(--kc-text);
602
+ background: var(--kc-background);
603
+ border-color: var(--kc-accent);
604
+ }
605
+ .kai-code__brand-mark svg,
606
+ .kai-code__welcome-mark svg,
607
+ .kai-code__file-icon svg,
608
+ .kai-code__folder-icon svg,
609
+ .kai-code__icon-button svg,
610
+ .kai-code__context-menu svg,
611
+ .kai-code__tab-close svg {
612
+ display: block;
613
+ width: 1em;
614
+ height: 1em;
585
615
  }
586
616
  @media (max-width: 760px) {
587
- .kai-code {
588
- min-width: 360px;
589
- }
590
617
  .kai-code__sidebar {
591
- flex-basis: 185px;
618
+ flex-basis: min(38vw, 185px) !important;
619
+ min-width: 125px;
592
620
  }
593
621
  .kai-code__activity-bar {
594
622
  flex-basis: 40px;
@@ -597,3 +625,30 @@
597
625
  width: 39px;
598
626
  }
599
627
  }
628
+ @container (max-width: 560px) {
629
+ .kai-code__activity-bar {
630
+ flex-basis: 38px;
631
+ }
632
+ .kai-code__activity-button {
633
+ width: 37px;
634
+ }
635
+ .kai-code__sidebar {
636
+ flex-basis: 38% !important;
637
+ min-width: 112px;
638
+ }
639
+ .kai-code__sidebar-heading {
640
+ padding-right: 5px;
641
+ padding-left: 9px;
642
+ }
643
+ .kai-code__sidebar-actions {
644
+ gap: 0;
645
+ }
646
+ }
647
+ @container (max-height: 480px) {
648
+ .kai-code__titlebar {
649
+ flex-basis: 32px;
650
+ }
651
+ .kai-code__statusbar {
652
+ flex-basis: 18px;
653
+ }
654
+ }
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as react from 'react';
2
+ import { CSSProperties, ReactNode } from 'react';
2
3
  import { editor } from 'monaco-editor';
3
4
 
4
5
  interface KaiCodeFile {
@@ -51,10 +52,20 @@ interface KaiCodeProps {
51
52
  initialActiveFile?: string;
52
53
  /** Monaco theme name. Defaults to `vs-dark`. */
53
54
  theme?: string;
55
+ /** Name shown in the title bar and Explorer. Defaults to `Workspace`. */
56
+ workspaceName?: string;
54
57
  /** Additional Monaco editor options. */
55
58
  options?: editor.IStandaloneEditorConstructionOptions;
56
- /** Component height. Defaults to 640px. */
57
- height?: string | number;
59
+ /** Height, CSS length, or CSS expression. Defaults to a viewport-responsive height. */
60
+ height?: CSSProperties["height"];
61
+ /** Workbench color overrides. Unspecified colors follow the selected theme. */
62
+ colors?: KaiCodeColors;
63
+ /** Use rounded outer corners by default, or set false for a flat edge-to-edge surface. */
64
+ rounded?: boolean;
65
+ /** Override built-in interface icons with React elements, SVGs, or emoji. */
66
+ icons?: Partial<Record<KaiCodeIconName, ReactNode>>;
67
+ /** Override file icons by lowercase extension (for example `tsx`) or `default`. */
68
+ fileIcons?: Record<string, ReactNode>;
58
69
  /** Makes the editor read-only. */
59
70
  readOnly?: boolean;
60
71
  /** Optional class applied to the outermost element. */
@@ -64,6 +75,20 @@ interface KaiCodeProps {
64
75
  /** Called after a document is successfully saved to the filesystem. */
65
76
  onSave?: (path: string, contents: string) => void;
66
77
  }
67
- declare function KaiCode({ fileSystem, initialFiles, initialActiveFile, theme, options, height, readOnly, className, onFileChange, onSave, }: KaiCodeProps): react.JSX.Element;
78
+ interface KaiCodeColors {
79
+ background?: string;
80
+ sidebarBackground?: string;
81
+ titlebarBackground?: string;
82
+ panelBackground?: string;
83
+ foreground?: string;
84
+ mutedForeground?: string;
85
+ border?: string;
86
+ accent?: string;
87
+ statusBarBackground?: string;
88
+ statusBarForeground?: string;
89
+ fileSelectionBackground?: string;
90
+ }
91
+ type KaiCodeIconName = "brand" | "explorer" | "folder" | "file" | "newFile" | "newFolder" | "collapseAll" | "close" | "delete" | "move";
92
+ declare function KaiCode({ fileSystem, initialFiles, initialActiveFile, theme, workspaceName, options, height, colors, rounded, icons, fileIcons, readOnly, className, onFileChange, onSave, }: KaiCodeProps): react.JSX.Element;
68
93
 
69
- export { KaiCode, type KaiCodeDirectory, type KaiCodeEntry, type KaiCodeFile, type KaiCodeFileSystem, type KaiCodeProps, createMemoryFileSystem, KaiCode as default, normalizePath };
94
+ export { KaiCode, type KaiCodeColors, type KaiCodeDirectory, type KaiCodeEntry, type KaiCodeFile, type KaiCodeFileSystem, type KaiCodeIconName, type KaiCodeProps, createMemoryFileSystem, KaiCode as default, normalizePath };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as react from 'react';
2
+ import { CSSProperties, ReactNode } from 'react';
2
3
  import { editor } from 'monaco-editor';
3
4
 
4
5
  interface KaiCodeFile {
@@ -51,10 +52,20 @@ interface KaiCodeProps {
51
52
  initialActiveFile?: string;
52
53
  /** Monaco theme name. Defaults to `vs-dark`. */
53
54
  theme?: string;
55
+ /** Name shown in the title bar and Explorer. Defaults to `Workspace`. */
56
+ workspaceName?: string;
54
57
  /** Additional Monaco editor options. */
55
58
  options?: editor.IStandaloneEditorConstructionOptions;
56
- /** Component height. Defaults to 640px. */
57
- height?: string | number;
59
+ /** Height, CSS length, or CSS expression. Defaults to a viewport-responsive height. */
60
+ height?: CSSProperties["height"];
61
+ /** Workbench color overrides. Unspecified colors follow the selected theme. */
62
+ colors?: KaiCodeColors;
63
+ /** Use rounded outer corners by default, or set false for a flat edge-to-edge surface. */
64
+ rounded?: boolean;
65
+ /** Override built-in interface icons with React elements, SVGs, or emoji. */
66
+ icons?: Partial<Record<KaiCodeIconName, ReactNode>>;
67
+ /** Override file icons by lowercase extension (for example `tsx`) or `default`. */
68
+ fileIcons?: Record<string, ReactNode>;
58
69
  /** Makes the editor read-only. */
59
70
  readOnly?: boolean;
60
71
  /** Optional class applied to the outermost element. */
@@ -64,6 +75,20 @@ interface KaiCodeProps {
64
75
  /** Called after a document is successfully saved to the filesystem. */
65
76
  onSave?: (path: string, contents: string) => void;
66
77
  }
67
- declare function KaiCode({ fileSystem, initialFiles, initialActiveFile, theme, options, height, readOnly, className, onFileChange, onSave, }: KaiCodeProps): react.JSX.Element;
78
+ interface KaiCodeColors {
79
+ background?: string;
80
+ sidebarBackground?: string;
81
+ titlebarBackground?: string;
82
+ panelBackground?: string;
83
+ foreground?: string;
84
+ mutedForeground?: string;
85
+ border?: string;
86
+ accent?: string;
87
+ statusBarBackground?: string;
88
+ statusBarForeground?: string;
89
+ fileSelectionBackground?: string;
90
+ }
91
+ type KaiCodeIconName = "brand" | "explorer" | "folder" | "file" | "newFile" | "newFolder" | "collapseAll" | "close" | "delete" | "move";
92
+ declare function KaiCode({ fileSystem, initialFiles, initialActiveFile, theme, workspaceName, options, height, colors, rounded, icons, fileIcons, readOnly, className, onFileChange, onSave, }: KaiCodeProps): react.JSX.Element;
68
93
 
69
- export { KaiCode, type KaiCodeDirectory, type KaiCodeEntry, type KaiCodeFile, type KaiCodeFileSystem, type KaiCodeProps, createMemoryFileSystem, KaiCode as default, normalizePath };
94
+ export { KaiCode, type KaiCodeColors, type KaiCodeDirectory, type KaiCodeEntry, type KaiCodeFile, type KaiCodeFileSystem, type KaiCodeIconName, type KaiCodeProps, createMemoryFileSystem, KaiCode as default, normalizePath };
package/dist/index.js CHANGED
@@ -262,6 +262,13 @@ function getFileGlyph(path) {
262
262
  if (extension === "css" || extension === "scss") return "#";
263
263
  return "\xB7";
264
264
  }
265
+ function getFileIcon(path, fileIcons, icons) {
266
+ const extension = path.split(".").pop()?.toLowerCase() ?? "";
267
+ return fileIcons?.[extension] ?? fileIcons?.default ?? icons?.file ?? getFileGlyph(path);
268
+ }
269
+ function getIcon(icons, name, fallback) {
270
+ return icons?.[name] ?? fallback;
271
+ }
265
272
  function errorMessage(error) {
266
273
  return error instanceof Error ? error.message : String(error);
267
274
  }
@@ -323,6 +330,8 @@ function FileTree({
323
330
  collapsedFolders,
324
331
  onToggleDirectory,
325
332
  onContextMenu,
333
+ icons,
334
+ fileIcons,
326
335
  depth = 0
327
336
  }) {
328
337
  return /* @__PURE__ */ jsx(Fragment, { children: nodes.map(
@@ -340,7 +349,7 @@ function FileTree({
340
349
  style: { "--tree-depth": depth },
341
350
  children: [
342
351
  /* @__PURE__ */ jsx("span", { className: "kai-code__chevron", "aria-hidden": "true", children: "\u25B8" }),
343
- /* @__PURE__ */ jsx("span", { className: "kai-code__folder-icon", "aria-hidden": "true", children: "\u25B0" }),
352
+ /* @__PURE__ */ jsx("span", { className: "kai-code__folder-icon", "aria-hidden": "true", children: getIcon(icons, "folder", "\u25B0") }),
344
353
  node.name
345
354
  ]
346
355
  }
@@ -354,6 +363,8 @@ function FileTree({
354
363
  collapsedFolders,
355
364
  onToggleDirectory,
356
365
  onContextMenu,
366
+ icons,
367
+ fileIcons,
357
368
  depth: depth + 1
358
369
  }
359
370
  )
@@ -369,7 +380,7 @@ function FileTree({
369
380
  style: { "--tree-depth": depth },
370
381
  type: "button",
371
382
  children: [
372
- /* @__PURE__ */ jsx("span", { className: "kai-code__file-icon", "aria-hidden": "true", children: getFileGlyph(node.path) }),
383
+ /* @__PURE__ */ jsx("span", { className: "kai-code__file-icon", "aria-hidden": "true", children: getFileIcon(node.path, fileIcons, icons) }),
373
384
  node.name
374
385
  ]
375
386
  },
@@ -382,8 +393,13 @@ function KaiCode({
382
393
  initialFiles,
383
394
  initialActiveFile,
384
395
  theme = "vs-dark",
396
+ workspaceName = "Workspace",
385
397
  options,
386
- height = 640,
398
+ height = "min(80dvh, 760px)",
399
+ colors,
400
+ rounded = true,
401
+ icons,
402
+ fileIcons,
387
403
  readOnly = false,
388
404
  className,
389
405
  onFileChange,
@@ -768,18 +784,33 @@ function KaiCode({
768
784
  [options, readOnly]
769
785
  );
770
786
  const activeLanguage = activeFile ? findFileEntry(tree, activeFile)?.language ?? getLanguage(activeFile) : null;
787
+ const rootStyle = {
788
+ height,
789
+ borderRadius: rounded ? 6 : 0,
790
+ "--kc-background": colors?.background,
791
+ "--kc-sidebar": colors?.sidebarBackground,
792
+ "--kc-titlebar": colors?.titlebarBackground,
793
+ "--kc-panel": colors?.panelBackground,
794
+ "--kc-text": colors?.foreground,
795
+ "--kc-muted": colors?.mutedForeground,
796
+ "--kc-border": colors?.border,
797
+ "--kc-accent": colors?.accent,
798
+ "--kc-status-background": colors?.statusBarBackground,
799
+ "--kc-status-foreground": colors?.statusBarForeground,
800
+ "--kc-selection": colors?.fileSelectionBackground
801
+ };
771
802
  return /* @__PURE__ */ jsxs(
772
803
  "section",
773
804
  {
774
805
  className: `kai-code${isLight ? " kai-code--light" : ""}${className ? ` ${className}` : ""}`,
775
- style: { height },
806
+ style: rootStyle,
776
807
  "aria-label": "KaiCode editor",
777
808
  children: [
778
809
  /* @__PURE__ */ jsxs("header", { className: "kai-code__titlebar", children: [
779
- /* @__PURE__ */ jsx("div", { className: "kai-code__brand-mark", "aria-hidden": "true", children: "K" }),
810
+ /* @__PURE__ */ jsx("div", { className: "kai-code__brand-mark", "aria-hidden": "true", children: getIcon(icons, "brand", "K") }),
780
811
  /* @__PURE__ */ jsx("span", { className: "kai-code__brand", children: "KaiCode" }),
781
812
  /* @__PURE__ */ jsx("span", { className: "kai-code__title-divider" }),
782
- /* @__PURE__ */ jsx("span", { className: "kai-code__workspace-title", children: "Workspace" }),
813
+ /* @__PURE__ */ jsx("span", { className: "kai-code__workspace-title", children: workspaceName }),
783
814
  /* @__PURE__ */ jsx("div", { className: "kai-code__title-actions", children: /* @__PURE__ */ jsx(
784
815
  "button",
785
816
  {
@@ -807,10 +838,18 @@ function KaiCode({
807
838
  title: "Explorer (Ctrl+B)",
808
839
  onClick: () => setExplorerVisible((visible) => !visible),
809
840
  type: "button",
810
- children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: [
811
- /* @__PURE__ */ jsx("path", { d: "M3.5 5.5h6l2 2h9v11h-17z" }),
812
- /* @__PURE__ */ jsx("path", { d: "M3.5 8h17" })
813
- ] })
841
+ children: /* @__PURE__ */ jsx("span", { className: "kai-code__activity-icon", "aria-hidden": "true", children: icons?.explorer ?? /* @__PURE__ */ jsxs(
842
+ "svg",
843
+ {
844
+ className: "kai-code__default-explorer-icon",
845
+ viewBox: "0 0 24 24",
846
+ "aria-hidden": "true",
847
+ children: [
848
+ /* @__PURE__ */ jsx("path", { d: "M3.5 5.5h6l2 2h9v11h-17z" }),
849
+ /* @__PURE__ */ jsx("path", { d: "M3.5 8h17" })
850
+ ]
851
+ }
852
+ ) })
814
853
  }
815
854
  ),
816
855
  /* @__PURE__ */ jsx("div", { className: "kai-code__activity-spacer" }),
@@ -834,7 +873,7 @@ function KaiCode({
834
873
  title: "New File",
835
874
  onClick: () => beginCreate("file", ""),
836
875
  type: "button",
837
- children: "+"
876
+ children: getIcon(icons, "newFile", "+")
838
877
  }
839
878
  ),
840
879
  fs.createDirectory && !readOnly && /* @__PURE__ */ jsx(
@@ -845,7 +884,7 @@ function KaiCode({
845
884
  title: "New Folder",
846
885
  onClick: () => beginCreate("directory", ""),
847
886
  type: "button",
848
- children: "\u25B0+"
887
+ children: getIcon(icons, "newFolder", "\u25B0+")
849
888
  }
850
889
  ),
851
890
  /* @__PURE__ */ jsx(
@@ -856,14 +895,14 @@ function KaiCode({
856
895
  title: "Collapse All (Ctrl+K Ctrl+0)",
857
896
  onClick: collapseAll,
858
897
  type: "button",
859
- children: "\u229F"
898
+ children: getIcon(icons, "collapseAll", "\u229F")
860
899
  }
861
900
  )
862
901
  ] })
863
902
  ] }),
864
903
  /* @__PURE__ */ jsxs("div", { className: "kai-code__workspace-row", children: [
865
904
  /* @__PURE__ */ jsx("span", { className: "kai-code__chevron", "aria-hidden": "true", children: "\u25BE" }),
866
- /* @__PURE__ */ jsx("span", { children: "WORKSPACE" })
905
+ /* @__PURE__ */ jsx("span", { children: workspaceName })
867
906
  ] }),
868
907
  /* @__PURE__ */ jsx("div", { className: "kai-code__file-tree", children: loadingTree && tree.length === 0 ? /* @__PURE__ */ jsx("div", { className: "kai-code__empty", children: "Loading files\u2026" }) : tree.length ? /* @__PURE__ */ jsx(
869
908
  FileTree,
@@ -873,7 +912,9 @@ function KaiCode({
873
912
  onOpen: openFile,
874
913
  collapsedFolders,
875
914
  onToggleDirectory: toggleDirectory,
876
- onContextMenu: openContextMenu
915
+ onContextMenu: openContextMenu,
916
+ icons,
917
+ fileIcons
877
918
  }
878
919
  ) : /* @__PURE__ */ jsx("div", { className: "kai-code__empty", children: "No files in this workspace" }) })
879
920
  ]
@@ -935,7 +976,7 @@ function KaiCode({
935
976
  onClick: (event) => event.stopPropagation(),
936
977
  onContextMenu: (event) => event.preventDefault(),
937
978
  children: [
938
- fs.createFile && !readOnly && /* @__PURE__ */ jsx(
979
+ fs.createFile && !readOnly && /* @__PURE__ */ jsxs(
939
980
  "button",
940
981
  {
941
982
  role: "menuitem",
@@ -944,10 +985,13 @@ function KaiCode({
944
985
  contextMenu.entry.type === "directory" ? contextMenu.entry.path : parentDirectory(contextMenu.entry.path)
945
986
  ),
946
987
  type: "button",
947
- children: "New File"
988
+ children: [
989
+ getIcon(icons, "newFile", "\uFF0B"),
990
+ " New File"
991
+ ]
948
992
  }
949
993
  ),
950
- fs.createDirectory && !readOnly && /* @__PURE__ */ jsx(
994
+ fs.createDirectory && !readOnly && /* @__PURE__ */ jsxs(
951
995
  "button",
952
996
  {
953
997
  role: "menuitem",
@@ -956,10 +1000,13 @@ function KaiCode({
956
1000
  contextMenu.entry.type === "directory" ? contextMenu.entry.path : parentDirectory(contextMenu.entry.path)
957
1001
  ),
958
1002
  type: "button",
959
- children: "New Folder"
1003
+ children: [
1004
+ getIcon(icons, "newFolder", "\u25B0"),
1005
+ " New Folder"
1006
+ ]
960
1007
  }
961
1008
  ),
962
- (contextMenu.entry.type === "file" && (fs.moveFile || fs.renameFile) || contextMenu.entry.type === "directory" && fs.moveDirectory) && !readOnly && /* @__PURE__ */ jsx(
1009
+ (contextMenu.entry.type === "file" && (fs.moveFile || fs.renameFile) || contextMenu.entry.type === "directory" && fs.moveDirectory) && !readOnly && /* @__PURE__ */ jsxs(
963
1010
  "button",
964
1011
  {
965
1012
  role: "menuitem",
@@ -970,12 +1017,15 @@ function KaiCode({
970
1017
  setContextMenu(null);
971
1018
  },
972
1019
  type: "button",
973
- children: "Move\u2026"
1020
+ children: [
1021
+ getIcon(icons, "move", "\u2197"),
1022
+ " Move\u2026"
1023
+ ]
974
1024
  }
975
1025
  ),
976
1026
  (contextMenu.entry.type === "file" && fs.deleteFile || contextMenu.entry.type === "directory" && fs.deleteDirectory) && !readOnly && /* @__PURE__ */ jsxs(Fragment, { children: [
977
1027
  /* @__PURE__ */ jsx("div", { className: "kai-code__context-divider" }),
978
- /* @__PURE__ */ jsx(
1028
+ /* @__PURE__ */ jsxs(
979
1029
  "button",
980
1030
  {
981
1031
  className: "is-danger",
@@ -986,7 +1036,10 @@ function KaiCode({
986
1036
  setContextMenu(null);
987
1037
  },
988
1038
  type: "button",
989
- children: "Delete"
1039
+ children: [
1040
+ getIcon(icons, "delete", "\u232B"),
1041
+ " Delete"
1042
+ ]
990
1043
  }
991
1044
  )
992
1045
  ] })
@@ -1011,7 +1064,7 @@ function KaiCode({
1011
1064
  "aria-selected": activeFile === path,
1012
1065
  type: "button",
1013
1066
  children: [
1014
- /* @__PURE__ */ jsx("span", { className: "kai-code__file-icon", "aria-hidden": "true", children: getFileGlyph(path) }),
1067
+ /* @__PURE__ */ jsx("span", { className: "kai-code__file-icon", "aria-hidden": "true", children: getFileIcon(path, fileIcons, icons) }),
1015
1068
  fileName,
1016
1069
  dirtyFiles.has(path) && /* @__PURE__ */ jsx("span", { className: "kai-code__dirty-dot", "aria-label": "Unsaved" })
1017
1070
  ]
@@ -1024,7 +1077,7 @@ function KaiCode({
1024
1077
  "aria-label": `Close ${fileName}`,
1025
1078
  onClick: () => closeFile(path),
1026
1079
  type: "button",
1027
- children: "\xD7"
1080
+ children: getIcon(icons, "close", "\xD7")
1028
1081
  }
1029
1082
  )
1030
1083
  ]
@@ -1084,7 +1137,7 @@ function KaiCode({
1084
1137
  },
1085
1138
  activeFile
1086
1139
  ) : /* @__PURE__ */ jsxs("div", { className: "kai-code__welcome", children: [
1087
- /* @__PURE__ */ jsx("div", { className: "kai-code__welcome-mark", children: "K" }),
1140
+ /* @__PURE__ */ jsx("div", { className: "kai-code__welcome-mark", children: getIcon(icons, "brand", "K") }),
1088
1141
  /* @__PURE__ */ jsx("h1", { children: "KaiCode" }),
1089
1142
  /* @__PURE__ */ jsx("p", { children: "Select a file from the Explorer to start editing." })
1090
1143
  ] }) })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handylib/kai-code",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {