@alpaca-editor/core 1.0.3897 → 1.0.3899

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 (95) hide show
  1. package/dist/components/ui/CardConnector.d.ts +3 -0
  2. package/dist/components/ui/CardConnector.js +6 -0
  3. package/dist/components/ui/CardConnector.js.map +1 -0
  4. package/dist/components/ui/button.js +1 -1
  5. package/dist/components/ui/button.js.map +1 -1
  6. package/dist/components/ui/card.d.ts +12 -0
  7. package/dist/components/ui/card.js +10 -0
  8. package/dist/components/ui/card.js.map +1 -0
  9. package/dist/config/config.js +7 -0
  10. package/dist/config/config.js.map +1 -1
  11. package/dist/editor/MobileLayout.js +15 -4
  12. package/dist/editor/MobileLayout.js.map +1 -1
  13. package/dist/editor/Titlebar.js +1 -1
  14. package/dist/editor/Titlebar.js.map +1 -1
  15. package/dist/editor/client/EditorClient.d.ts +13 -4
  16. package/dist/editor/client/EditorClient.js +34 -11
  17. package/dist/editor/client/EditorClient.js.map +1 -1
  18. package/dist/editor/client/editContext.d.ts +3 -1
  19. package/dist/editor/client/editContext.js.map +1 -1
  20. package/dist/editor/control-center/QuotaInfo.js +76 -26
  21. package/dist/editor/control-center/QuotaInfo.js.map +1 -1
  22. package/dist/editor/control-center/WebSocketMessages.d.ts +1 -0
  23. package/dist/editor/control-center/WebSocketMessages.js +66 -0
  24. package/dist/editor/control-center/WebSocketMessages.js.map +1 -0
  25. package/dist/editor/services/aiService.d.ts +1 -0
  26. package/dist/editor/services/aiService.js +4 -1
  27. package/dist/editor/services/aiService.js.map +1 -1
  28. package/dist/editor/sidebar/SidebarView.js +14 -14
  29. package/dist/editor/sidebar/SidebarView.js.map +1 -1
  30. package/dist/editor/ui/Icons.d.ts +3 -1
  31. package/dist/editor/ui/Icons.js +2 -2
  32. package/dist/editor/ui/Icons.js.map +1 -1
  33. package/dist/editor/ui/SimpleTabs.js +1 -1
  34. package/dist/editor/ui/SimpleTabs.js.map +1 -1
  35. package/dist/editor/ui/Splitter.d.ts +1 -0
  36. package/dist/editor/ui/Splitter.js +119 -58
  37. package/dist/editor/ui/Splitter.js.map +1 -1
  38. package/dist/fonts/index.d.ts +4 -0
  39. package/dist/fonts/index.js +9 -0
  40. package/dist/fonts/index.js.map +1 -0
  41. package/dist/index.d.ts +3 -1
  42. package/dist/index.js +2 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/page-wizard/WizardBox.d.ts +2 -8
  45. package/dist/page-wizard/WizardBox.js +3 -5
  46. package/dist/page-wizard/WizardBox.js.map +1 -1
  47. package/dist/page-wizard/WizardSteps.d.ts +4 -2
  48. package/dist/page-wizard/WizardSteps.js +41 -62
  49. package/dist/page-wizard/WizardSteps.js.map +1 -1
  50. package/dist/page-wizard/steps/CollectStep.js +10 -10
  51. package/dist/page-wizard/steps/CollectStep.js.map +1 -1
  52. package/dist/page-wizard/steps/CreatePage.js +6 -3
  53. package/dist/page-wizard/steps/CreatePage.js.map +1 -1
  54. package/dist/page-wizard/steps/Generate.js +27 -5
  55. package/dist/page-wizard/steps/Generate.js.map +1 -1
  56. package/dist/page-wizard/steps/ImagesStep.js +46 -44
  57. package/dist/page-wizard/steps/ImagesStep.js.map +1 -1
  58. package/dist/page-wizard/steps/SelectStep.js +11 -19
  59. package/dist/page-wizard/steps/SelectStep.js.map +1 -1
  60. package/dist/revision.d.ts +2 -2
  61. package/dist/revision.js +2 -2
  62. package/dist/splash-screen/NewPage.js +12 -11
  63. package/dist/splash-screen/NewPage.js.map +1 -1
  64. package/dist/splash-screen/SplashScreen.js +8 -7
  65. package/dist/splash-screen/SplashScreen.js.map +1 -1
  66. package/dist/styles.css +179 -104
  67. package/package.json +1 -1
  68. package/src/components/ui/CardConnector.tsx +21 -0
  69. package/src/components/ui/button.tsx +1 -1
  70. package/src/components/ui/card.tsx +44 -0
  71. package/src/config/config.tsx +7 -0
  72. package/src/editor/MobileLayout.tsx +20 -7
  73. package/src/editor/Titlebar.tsx +1 -1
  74. package/src/editor/client/EditorClient.tsx +53 -15
  75. package/src/editor/client/editContext.ts +9 -1
  76. package/src/editor/control-center/QuotaInfo.tsx +225 -95
  77. package/src/editor/control-center/WebSocketMessages.tsx +155 -0
  78. package/src/editor/services/aiService.ts +4 -1
  79. package/src/editor/sidebar/SidebarView.tsx +46 -44
  80. package/src/editor/ui/Icons.tsx +2 -3
  81. package/src/editor/ui/SimpleTabs.tsx +1 -1
  82. package/src/editor/ui/Splitter.tsx +152 -80
  83. package/src/fonts/index.ts +10 -0
  84. package/src/index.ts +9 -1
  85. package/src/page-wizard/WizardBox.tsx +3 -39
  86. package/src/page-wizard/WizardSteps.tsx +231 -161
  87. package/src/page-wizard/steps/CollectStep.tsx +10 -11
  88. package/src/page-wizard/steps/CreatePage.tsx +130 -84
  89. package/src/page-wizard/steps/Generate.tsx +45 -17
  90. package/src/page-wizard/steps/ImagesStep.tsx +161 -141
  91. package/src/page-wizard/steps/SelectStep.tsx +92 -76
  92. package/src/revision.ts +2 -2
  93. package/src/splash-screen/NewPage.tsx +107 -80
  94. package/src/splash-screen/SplashScreen.tsx +49 -33
  95. package/styles.css +38 -0
@@ -649,14 +649,13 @@ export function SparkleIconSmall() {
649
649
  );
650
650
  }
651
651
 
652
- export function Logo() {
652
+ export function Logo({ className }: { className?: string }) {
653
653
  return (
654
654
  <svg
655
- width="24"
656
- height="20"
657
655
  viewBox="0 0 24 20"
658
656
  fill="none"
659
657
  xmlns="http://www.w3.org/2000/svg"
658
+ className={className}
660
659
  >
661
660
  <path
662
661
  d="M7.71353 0C7.73963 0.00378493 7.76608 0.00642148 7.79201 0.0113365C7.86015 0.024234 7.95193 0.0488096 7.998 0.109835C8.21766 0.400198 8.38583 1.46152 8.49531 1.8789C8.79625 3.0269 9.23224 4.23342 9.98756 5.15412C11.0528 6.45252 12.6475 7.04661 14.2042 7.46575C14.5871 7.56885 15.0161 7.6151 15.3852 7.75313C15.4998 7.79595 15.566 7.84973 15.6318 7.95303C15.6283 8.09636 15.6446 8.13548 15.5229 8.22926C15.2738 8.4212 14.166 8.62279 13.7938 8.73221C12.8975 8.9957 11.9165 9.31878 11.1416 9.86464C9.58345 10.9624 8.8537 12.6603 8.40842 14.4905C8.2837 15.003 8.20996 15.6192 7.93599 16.0676L7.7342 16.0256C7.61999 15.9408 7.58356 15.8477 7.54257 15.7141C7.45183 15.4172 7.4133 15.1006 7.3357 14.7987C7.04597 13.6713 6.70631 12.5076 6.0934 11.5164C4.88351 9.55969 2.77887 8.93227 0.701726 8.42803C0.453688 8.36782 0.142061 8.30641 0 8.06956C0.0136631 7.91174 0.050277 7.90952 0.187784 7.84447C0.61607 7.64192 1.11302 7.54975 1.5681 7.42643C2.59441 7.1483 3.72075 6.77163 4.59974 6.14502C6.14245 5.0454 6.83664 3.2587 7.28157 1.45485C7.39683 0.987436 7.45078 0.408109 7.71353 0Z"
@@ -30,7 +30,7 @@ export function SimpleTabs({
30
30
 
31
31
  return (
32
32
  <>
33
- <div className={twMerge("flex gap-4 pb-3", className)}>
33
+ <div className={twMerge("flex gap-4 pb-1 md:pb-3", className)}>
34
34
  {tabs.map((tab, index) => (
35
35
  <button
36
36
  id={tab.id}
@@ -1,5 +1,6 @@
1
1
  import React, { useState, useRef, useEffect, useCallback } from "react";
2
2
  import { flushSync } from "react-dom";
3
+
3
4
  export type SplitterPanel = {
4
5
  defaultSize: number | "auto";
5
6
  name: string;
@@ -13,6 +14,7 @@ interface SplitterProps {
13
14
  localStorageKey?: string;
14
15
  expandLabel?: React.ReactNode;
15
16
  growablePanelIndex?: number; // Index of the panel that grows/shrinks
17
+ direction?: "horizontal" | "vertical"; // New prop for direction
16
18
  }
17
19
 
18
20
  type StoredSizes = { panels: PanelSizes; lastCollapsed: boolean };
@@ -22,6 +24,7 @@ export const Splitter: React.FC<SplitterProps> = ({
22
24
  panels,
23
25
  localStorageKey = "splitter-sizes",
24
26
  expandLabel = "Expand",
27
+ direction = "horizontal", // Default to horizontal for backward compatibility
25
28
  }) => {
26
29
  const totalPanels = panels.length;
27
30
 
@@ -86,79 +89,6 @@ export const Splitter: React.FC<SplitterProps> = ({
86
89
  }
87
90
  };
88
91
 
89
- const handleResize = useCallback(
90
- (index: number, event: React.MouseEvent<HTMLDivElement>) => {
91
- event.preventDefault();
92
-
93
- const iframes = splitterRef.current?.querySelectorAll("iframe");
94
- iframes?.forEach((iframe) => {
95
- iframe.classList.add("pointer-events-none");
96
- });
97
-
98
- const startX = event.clientX;
99
- // create a copy with the panel name
100
- const initialSizes = panelSizes ? { ...panelSizes } : {};
101
-
102
- const panelElement = panelRefs.current[index];
103
- const nextPanelElement = panelRefs.current[index + 1];
104
-
105
- if (!panelElement || !nextPanelElement || !splitterRef.current) {
106
- return;
107
- }
108
-
109
- const panelWidth = panelElement.offsetWidth;
110
- const nextPanelWidth = nextPanelElement.offsetWidth;
111
-
112
- setIsResizing(true);
113
-
114
- const onMouseMove = (moveEvent: MouseEvent) => {
115
- const delta = moveEvent.clientX - startX;
116
- const newPanelWidth = panelWidth + delta;
117
- const newNextPanelWidth = nextPanelWidth - delta;
118
-
119
- const minPanelWidth = 50;
120
- const minNextPanelWidth = 50;
121
-
122
- if (
123
- newNextPanelWidth < minPanelWidth &&
124
- index == panels.length - 2 &&
125
- lastPanelCollapsible
126
- ) {
127
- setIsLastPanelCollapsed(true);
128
- setPanelSizes(initialSizes);
129
- }
130
-
131
- if (
132
- newPanelWidth < minPanelWidth ||
133
- newNextPanelWidth < minNextPanelWidth
134
- ) {
135
- return;
136
- }
137
-
138
- const updatedSizes: PanelSizes = { ...initialSizes };
139
- updatedSizes[panels[index]!.name] = newPanelWidth;
140
- updatedSizes[panels[index + 1]!.name] = newNextPanelWidth;
141
- setPanelSizes(updatedSizes);
142
- };
143
-
144
- const onMouseUp = () => {
145
- setTimeout(() => {
146
- setIsResizing(false);
147
- }, 100);
148
- iframes?.forEach((iframe) => {
149
- iframe.classList.remove("pointer-events-none");
150
- });
151
-
152
- document.removeEventListener("mousemove", onMouseMove);
153
- document.removeEventListener("mouseup", onMouseUp, true);
154
- };
155
-
156
- document.addEventListener("mousemove", onMouseMove);
157
- document.addEventListener("mouseup", onMouseUp, true);
158
- },
159
- [panels, panelSizes],
160
- );
161
-
162
92
  const isLastResizer = (index: number) => index === panels.length - 2;
163
93
 
164
94
  const getFlexBasis = (index: number): string => {
@@ -182,11 +112,16 @@ export const Splitter: React.FC<SplitterProps> = ({
182
112
  };
183
113
 
184
114
  const getExpandButton = () => {
115
+ const isHorizontal = direction === "horizontal";
116
+
185
117
  return (
186
118
  <div
187
119
  onClick={!isResizing ? toggleLastPanelCollapse : undefined}
188
120
  className="flex cursor-pointer items-center justify-center bg-gray-200 p-1 text-gray-500 select-none hover:bg-blue-700 hover:text-white"
189
- style={{ writingMode: "vertical-rl", userSelect: "none" }}
121
+ style={{
122
+ writingMode: isHorizontal ? "vertical-rl" : "horizontal-tb",
123
+ userSelect: "none",
124
+ }}
190
125
  >
191
126
  {expandLabel}
192
127
  </div>
@@ -194,27 +129,162 @@ export const Splitter: React.FC<SplitterProps> = ({
194
129
  };
195
130
 
196
131
  const getSplitter = (index: number) => {
132
+ const isHorizontal = direction === "horizontal";
133
+
134
+ const handleDragStart = (
135
+ clientX: number,
136
+ clientY: number,
137
+ event: React.MouseEvent | React.TouchEvent,
138
+ ) => {
139
+ const rect = (event.target as HTMLElement).getBoundingClientRect();
140
+ const relativeY = clientY - rect.top;
141
+
142
+ event.stopPropagation();
143
+ event.preventDefault();
144
+
145
+ const isHorizontal = direction === "horizontal";
146
+ const startCoord = isHorizontal ? clientX : clientY;
147
+ const initialSizes = panelSizes ? { ...panelSizes } : {};
148
+
149
+ const panelElement = panelRefs.current[index];
150
+ const nextPanelElement = panelRefs.current[index + 1];
151
+
152
+ if (!panelElement || !nextPanelElement) {
153
+ return;
154
+ }
155
+
156
+ const panelSize = isHorizontal
157
+ ? panelElement.offsetWidth
158
+ : panelElement.offsetHeight;
159
+ const nextPanelSize = isHorizontal
160
+ ? nextPanelElement.offsetWidth
161
+ : nextPanelElement.offsetHeight;
162
+
163
+ setIsResizing(true);
164
+
165
+ // Disable pointer events on panel content during drag
166
+ const allPanels = splitterRef.current?.querySelectorAll(".relative");
167
+ allPanels?.forEach((panel) => {
168
+ (panel as HTMLElement).style.pointerEvents = "none";
169
+ // Also disable on all child elements that might capture events
170
+ const childElements = panel.querySelectorAll("*");
171
+ childElements.forEach((child) => {
172
+ (child as HTMLElement).style.pointerEvents = "none";
173
+ });
174
+ });
175
+
176
+ let isDragging = true;
177
+
178
+ const handleMove = (moveClientX: number, moveClientY: number) => {
179
+ if (!isDragging) return;
180
+
181
+ const currentCoord = isHorizontal ? moveClientX : moveClientY;
182
+ const delta = currentCoord - startCoord;
183
+ const newPanelSize = panelSize + delta;
184
+ const newNextPanelSize = nextPanelSize - delta;
185
+
186
+ const minPanelSize = 50;
187
+ if (newPanelSize < minPanelSize || newNextPanelSize < minPanelSize) {
188
+ return;
189
+ }
190
+
191
+ const updatedSizes: PanelSizes = { ...initialSizes };
192
+ updatedSizes[panels[index]!.name] = newPanelSize;
193
+ updatedSizes[panels[index + 1]!.name] = newNextPanelSize;
194
+ setPanelSizes(updatedSizes);
195
+ };
196
+
197
+ const handleEnd = () => {
198
+ isDragging = false;
199
+ setIsResizing(false);
200
+
201
+ // Re-enable pointer events on panel content
202
+ allPanels?.forEach((panel) => {
203
+ (panel as HTMLElement).style.pointerEvents = "";
204
+ // Also re-enable on all child elements
205
+ const childElements = panel.querySelectorAll("*");
206
+ childElements.forEach((child) => {
207
+ (child as HTMLElement).style.pointerEvents = "";
208
+ });
209
+ });
210
+
211
+ // Remove all event listeners
212
+ window.removeEventListener("mousemove", onMouseMove);
213
+ window.removeEventListener("mouseup", onMouseUp);
214
+ window.removeEventListener("touchmove", onTouchMove);
215
+ window.removeEventListener("touchend", onTouchEnd);
216
+ };
217
+
218
+ const onMouseMove = (moveEvent: MouseEvent) => {
219
+ handleMove(moveEvent.clientX, moveEvent.clientY);
220
+ };
221
+
222
+ const onMouseUp = () => {
223
+ handleEnd();
224
+ };
225
+
226
+ const onTouchMove = (moveEvent: TouchEvent) => {
227
+ if (moveEvent.touches.length === 1) {
228
+ const touch = moveEvent.touches[0];
229
+ if (touch) {
230
+ handleMove(touch.clientX, touch.clientY);
231
+ }
232
+ }
233
+ };
234
+
235
+ const onTouchEnd = () => {
236
+ handleEnd();
237
+ };
238
+
239
+ // Add both mouse and touch event listeners
240
+ window.addEventListener("mousemove", onMouseMove);
241
+ window.addEventListener("mouseup", onMouseUp);
242
+ window.addEventListener("touchmove", onTouchMove, { passive: false });
243
+ window.addEventListener("touchend", onTouchEnd);
244
+ };
245
+
197
246
  if (lastPanelCollapsible && isLastPanelCollapsed && isLastResizer(index)) {
198
247
  return getExpandButton();
199
248
  }
200
249
 
201
250
  return (
202
251
  <div
203
- className={
204
- "relative z-1000 flex w-[4px] cursor-ew-resize items-center justify-center bg-gray-200 select-none hover:bg-blue-700"
205
- }
252
+ className={`relative flex ${
253
+ isHorizontal
254
+ ? "h-full w-[4px] w-[12px] cursor-ew-resize md:w-[4px]"
255
+ : "h-[12px] h-[20px] w-full cursor-ns-resize md:h-[12px]"
256
+ } shrink-0 items-center justify-center bg-gray-300 select-none hover:bg-gray-400`}
257
+ style={{
258
+ touchAction: "none",
259
+ minHeight: isHorizontal ? undefined : "12px",
260
+ minWidth: isHorizontal ? "4px" : undefined,
261
+ boxSizing: "border-box",
262
+ userSelect: "none",
263
+ zIndex: 9999, // Ensure we're above any nested splitters
264
+ }}
206
265
  onDoubleClick={
207
266
  isLastResizer(index) ? toggleLastPanelCollapse : undefined
208
267
  }
209
268
  onMouseDown={(event) => {
210
- handleResize(index, event);
269
+ handleDragStart(event.clientX, event.clientY, event);
270
+ }}
271
+ onTouchStart={(event) => {
272
+ if (event.touches.length === 1) {
273
+ const touch = event.touches[0];
274
+ if (touch) {
275
+ handleDragStart(touch.clientX, touch.clientY, event);
276
+ }
277
+ }
211
278
  }}
212
279
  ></div>
213
280
  );
214
281
  };
215
282
 
216
283
  return (
217
- <div className="flex h-full w-full overflow-hidden" ref={splitterRef}>
284
+ <div
285
+ className={`flex ${direction === "horizontal" ? "flex-row" : "flex-col"} h-full w-full overflow-hidden`}
286
+ ref={splitterRef}
287
+ >
218
288
  {panels.map((panel, index) => (
219
289
  <React.Fragment key={panel.name}>
220
290
  <div
@@ -227,7 +297,8 @@ export const Splitter: React.FC<SplitterProps> = ({
227
297
  index,
228
298
  )}`,
229
299
 
230
- minWidth: 0,
300
+ minWidth: direction === "horizontal" ? 0 : undefined,
301
+ minHeight: direction === "vertical" ? 0 : undefined,
231
302
  display:
232
303
  (panel.collapsible &&
233
304
  isLastPanelCollapsed &&
@@ -241,6 +312,7 @@ export const Splitter: React.FC<SplitterProps> = ({
241
312
  </div>
242
313
  {index < panels.length - 1 &&
243
314
  !panels[index]?.hidden &&
315
+ !panels[index + 1]?.hidden &&
244
316
  getSplitter(index)}
245
317
  </React.Fragment>
246
318
  ))}
@@ -0,0 +1,10 @@
1
+ import { Inter } from "next/font/google";
2
+
3
+ export const inter = Inter({
4
+ subsets: ["latin"],
5
+ variable: "--font-inter",
6
+ });
7
+
8
+ export const fonts = {
9
+ inter,
10
+ };
package/src/index.ts CHANGED
@@ -8,8 +8,16 @@ export { configureForUser } from "./config/config";
8
8
 
9
9
  export type { DialogProps } from "./editor/client/editContext";
10
10
 
11
- export type { LocalizeItemCommand, LocalizeItemCommandContext, LocalizeItemCommandData } from "./editor/commands/itemCommands";
11
+ export type {
12
+ LocalizeItemCommand,
13
+ LocalizeItemCommandContext,
14
+ LocalizeItemCommandData,
15
+ } from "./editor/commands/itemCommands";
12
16
 
13
17
  export { requestTranslation } from "./editor/services/translationService";
14
18
 
15
19
  export { defaultTranslateAll } from "./editor/commands/localizeItem/LocalizeItemUtils";
20
+
21
+ export * from "./fonts";
22
+
23
+ export { Card } from "./components/ui/card";
@@ -1,40 +1,4 @@
1
- import { cn } from "../lib/utils";
1
+ import { Card } from "../components/ui/card";
2
2
 
3
- export function WizardBox({
4
- children,
5
- icon,
6
- title,
7
- description,
8
- className,
9
- noPadding,
10
- }: {
11
- children: React.ReactNode;
12
- icon: React.ReactNode;
13
- title: string;
14
- description: string;
15
- className?: string;
16
- noPadding?: boolean;
17
- }) {
18
- return (
19
- <div
20
- className={cn(
21
- "flex h-full flex-col gap-2 rounded-md bg-white",
22
- className,
23
- )}
24
- >
25
- <div className="flex flex-col justify-between gap-1 p-6">
26
- <div className="flex items-center gap-2">
27
- <div className="text-theme-secondary flex h-4 w-4 items-center justify-center rounded-full">
28
- {icon}
29
- </div>
30
- <div className="text-base font-bold text-neutral-800">{title}</div>
31
- </div>
32
- <div className="mb-2 text-xs text-neutral-500">{description}</div>
33
- </div>
34
-
35
- <div className={cn("flex-1", noPadding ? "" : "p-6 pt-0", className)}>
36
- {children}
37
- </div>
38
- </div>
39
- );
40
- }
3
+ // Re-export Card as WizardBox for backward compatibility
4
+ export const WizardBox = Card;