@alpaca-editor/core 1.0.4190 → 1.0.4191

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 (102) hide show
  1. package/dist/agents-view/AgentCard.js +1 -1
  2. package/dist/agents-view/AgentCard.js.map +1 -1
  3. package/dist/agents-view/AgentsView.js +5 -7
  4. package/dist/agents-view/AgentsView.js.map +1 -1
  5. package/dist/config/config.js +14 -7
  6. package/dist/config/config.js.map +1 -1
  7. package/dist/editor/ItemInfo.js +3 -3
  8. package/dist/editor/ItemInfo.js.map +1 -1
  9. package/dist/editor/QuickItemSwitcher.js +1 -1
  10. package/dist/editor/QuickItemSwitcher.js.map +1 -1
  11. package/dist/editor/ai/AgentTerminal.d.ts +1 -7
  12. package/dist/editor/ai/AgentTerminal.js +382 -256
  13. package/dist/editor/ai/AgentTerminal.js.map +1 -1
  14. package/dist/editor/ai/Agents.js +84 -198
  15. package/dist/editor/ai/Agents.js.map +1 -1
  16. package/dist/editor/ai/AiResponseMessage.d.ts +1 -3
  17. package/dist/editor/ai/AiResponseMessage.js +12 -63
  18. package/dist/editor/ai/AiResponseMessage.js.map +1 -1
  19. package/dist/editor/ai/ToolCallDisplay.d.ts +1 -2
  20. package/dist/editor/ai/ToolCallDisplay.js +5 -13
  21. package/dist/editor/ai/ToolCallDisplay.js.map +1 -1
  22. package/dist/editor/client/EditorShell.js +5 -6
  23. package/dist/editor/client/EditorShell.js.map +1 -1
  24. package/dist/editor/client/hooks/useSocketMessageHandler.js +4 -6
  25. package/dist/editor/client/hooks/useSocketMessageHandler.js.map +1 -1
  26. package/dist/editor/commands/componentCommands.js +0 -2
  27. package/dist/editor/commands/componentCommands.js.map +1 -1
  28. package/dist/editor/control-center/About.js +1 -1
  29. package/dist/editor/control-center/About.js.map +1 -1
  30. package/dist/editor/control-center/AllAgentsPanel.js +1 -1
  31. package/dist/editor/field-types/MultiLineText.js +1 -1
  32. package/dist/editor/field-types/MultiLineText.js.map +1 -1
  33. package/dist/editor/services/aiService.d.ts +0 -1
  34. package/dist/editor/services/aiService.js.map +1 -1
  35. package/dist/editor/sidebar/Validation.js +1 -1
  36. package/dist/editor/sidebar/Validation.js.map +1 -1
  37. package/dist/index.d.ts +0 -3
  38. package/dist/index.js +0 -4
  39. package/dist/index.js.map +1 -1
  40. package/dist/page-wizard/PageWizard.js +3 -3
  41. package/dist/page-wizard/PageWizard.js.map +1 -1
  42. package/dist/page-wizard/WizardSteps.js +1 -1
  43. package/dist/page-wizard/WizardSteps.js.map +1 -1
  44. package/dist/revision.d.ts +2 -2
  45. package/dist/revision.js +2 -2
  46. package/dist/splash-screen/OpenPage.js +6 -10
  47. package/dist/splash-screen/OpenPage.js.map +1 -1
  48. package/dist/splash-screen/RecentPages.js +2 -2
  49. package/dist/splash-screen/RecentPages.js.map +1 -1
  50. package/dist/splash-screen/SplashScreen.js +1 -1
  51. package/dist/splash-screen/SplashScreen.js.map +1 -1
  52. package/dist/styles.css +12 -241
  53. package/package.json +1 -1
  54. package/src/agents-view/AgentCard.tsx +6 -1
  55. package/src/agents-view/AgentsView.tsx +30 -18
  56. package/src/config/config.tsx +17 -8
  57. package/src/editor/ItemInfo.tsx +2 -3
  58. package/src/editor/QuickItemSwitcher.tsx +1 -1
  59. package/src/editor/ai/AgentTerminal.tsx +649 -544
  60. package/src/editor/ai/Agents.tsx +250 -464
  61. package/src/editor/ai/AiResponseMessage.tsx +29 -154
  62. package/src/editor/ai/ToolCallDisplay.tsx +4 -18
  63. package/src/editor/client/EditorShell.tsx +6 -9
  64. package/src/editor/client/hooks/useSocketMessageHandler.ts +7 -6
  65. package/src/editor/commands/componentCommands.tsx +0 -1
  66. package/src/editor/control-center/About.tsx +2 -2
  67. package/src/editor/control-center/AllAgentsPanel.tsx +1 -1
  68. package/src/editor/field-types/MultiLineText.tsx +1 -1
  69. package/src/editor/services/aiService.ts +0 -2
  70. package/src/editor/sidebar/Validation.tsx +1 -1
  71. package/src/index.ts +0 -5
  72. package/src/page-wizard/PageWizard.tsx +3 -3
  73. package/src/page-wizard/WizardSteps.tsx +1 -1
  74. package/src/revision.ts +2 -2
  75. package/src/splash-screen/OpenPage.tsx +4 -12
  76. package/src/splash-screen/RecentPages.tsx +61 -58
  77. package/src/splash-screen/SplashScreen.tsx +1 -1
  78. package/styles.css +0 -20
  79. package/dist/components/ui/PlaceholderInput.d.ts +0 -41
  80. package/dist/components/ui/PlaceholderInput.js +0 -160
  81. package/dist/components/ui/PlaceholderInput.js.map +0 -1
  82. package/dist/components/ui/PlaceholderInputTypes.d.ts +0 -41
  83. package/dist/components/ui/PlaceholderInputTypes.js +0 -48
  84. package/dist/components/ui/PlaceholderInputTypes.js.map +0 -1
  85. package/dist/components/ui/PlaceholderItemSelector.d.ts +0 -7
  86. package/dist/components/ui/PlaceholderItemSelector.js +0 -154
  87. package/dist/components/ui/PlaceholderItemSelector.js.map +0 -1
  88. package/dist/splash-screen/ModernSplashScreen.d.ts +0 -8
  89. package/dist/splash-screen/ModernSplashScreen.js +0 -36
  90. package/dist/splash-screen/ModernSplashScreen.js.map +0 -1
  91. package/dist/splash-screen/ParheliaAssistantChat.d.ts +0 -8
  92. package/dist/splash-screen/ParheliaAssistantChat.js +0 -155
  93. package/dist/splash-screen/ParheliaAssistantChat.js.map +0 -1
  94. package/dist/splash-screen/RecentAgents.d.ts +0 -7
  95. package/dist/splash-screen/RecentAgents.js +0 -76
  96. package/dist/splash-screen/RecentAgents.js.map +0 -1
  97. package/src/components/ui/PlaceholderInput.tsx +0 -290
  98. package/src/components/ui/PlaceholderInputTypes.tsx +0 -97
  99. package/src/components/ui/PlaceholderItemSelector.tsx +0 -253
  100. package/src/splash-screen/ModernSplashScreen.tsx +0 -158
  101. package/src/splash-screen/ParheliaAssistantChat.tsx +0 -273
  102. package/src/splash-screen/RecentAgents.tsx +0 -151
@@ -46,7 +46,7 @@ export function RecentPages() {
46
46
  editContext.switchView(
47
47
  editContext.contentEditorItem?.hasLayout
48
48
  ? "page-editor"
49
- : "content-tree",
49
+ : "content-editor",
50
50
  );
51
51
  });
52
52
  }
@@ -54,69 +54,72 @@ export function RecentPages() {
54
54
 
55
55
  return (
56
56
  <Card
57
- collapsible="no"
58
- defaultCollapsed="no"
59
57
  icon={<History className="h-4 w-4" />}
60
58
  title="Recent Pages/Items"
61
59
  description="Quick access to your recently viewed pages"
60
+ className="flex h-full flex-col"
62
61
  >
63
- {isLoading ? (
64
- <div className="flex flex-col items-center justify-center p-6 text-center">
65
- <Loader2 className="h-5 w-5 animate-spin text-gray-400" />
66
- <div className="mt-2 text-xs text-gray-500">
67
- Loading recent pages...
68
- </div>
69
- </div>
70
- ) : !history || history.length === 0 ? (
71
- <div className="p-6 text-center text-xs text-gray-500">
72
- No recent pages found
73
- </div>
74
- ) : (
75
- <table className="w-full text-xs">
76
- <tbody>
77
- {history.map((page, index) => (
78
- <tr
79
- key={page.id || index}
80
- onClick={() => handlePageLoad(page)}
81
- className="cursor-pointer border-b border-gray-100 hover:bg-gray-50"
82
- >
83
- <td className="px-1.5 py-3">
84
- <div className="flex items-center gap-2">
85
- {/* {page.icon && (
86
- <img
87
- src={page.icon}
88
- width="16"
89
- height="16"
90
- alt=""
91
- className="flex-shrink-0"
92
- />
93
- )} */}
94
- <div className="min-w-0 flex-1 pl-1">
95
- <div className="font-medium text-gray-900">
96
- {page.name}
97
- </div>
98
- <div className="break-all text-xs text-gray-500">
99
- {page.path}
62
+ <div className="relative flex min-h-0 flex-1 flex-col">
63
+ <div className="absolute inset-0 overflow-auto">
64
+ <table className="w-full text-xs">
65
+ <tbody>
66
+ {history?.map((page, index) => (
67
+ <tr
68
+ key={page.id || index}
69
+ onClick={() => handlePageLoad(page)}
70
+ className="cursor-pointer border-b border-gray-100 hover:bg-gray-50"
71
+ >
72
+ <td className="px-1.5 py-3">
73
+ <div className="flex items-center gap-2">
74
+ {/* {page.icon && (
75
+ <img
76
+ src={page.icon}
77
+ width="16"
78
+ height="16"
79
+ alt=""
80
+ className="flex-shrink-0"
81
+ />
82
+ )} */}
83
+ <div className="min-w-0 flex-1 pl-1">
84
+ <div className="font-medium text-gray-900">
85
+ {page.name}
86
+ </div>
87
+ <div className="text-xs break-all text-gray-500">
88
+ {page.path}
89
+ </div>
100
90
  </div>
101
91
  </div>
102
- </div>
103
- </td>
104
- <td className="hidden p-3 text-gray-700 md:table-cell">
105
- <div className="truncate">{page.templateName || "—"}</div>
106
- </td>
107
- <td className="p-3">
108
- <span className="inline-flex items-center truncate rounded-full bg-blue-100 px-2 py-1 text-xs font-medium text-blue-800">
109
- {page.workflowState || "Draft"}
110
- </span>
111
- </td>
112
- <td className="hidden p-3 text-gray-700 md:table-cell">
113
- {page.versions || 0}
114
- </td>
115
- </tr>
116
- ))}
117
- </tbody>
118
- </table>
119
- )}
92
+ </td>
93
+ <td className="hidden p-3 text-gray-700 md:table-cell">
94
+ <div className="truncate">{page.templateName || "—"}</div>
95
+ </td>
96
+ <td className="p-3">
97
+ <span className="inline-flex items-center truncate rounded-full bg-blue-100 px-2 py-1 text-xs font-medium text-blue-800">
98
+ {page.workflowState || "Draft"}
99
+ </span>
100
+ </td>
101
+ <td className="hidden p-3 text-gray-700 md:table-cell">
102
+ {page.versions || 0}
103
+ </td>
104
+ </tr>
105
+ ))}
106
+ </tbody>
107
+ </table>
108
+ {isLoading && (
109
+ <div className="flex h-full flex-col items-center justify-center p-6 text-center">
110
+ <Loader2 className="h-5 w-5 animate-spin text-gray-400" />
111
+ <div className="mt-2 text-xs text-gray-500">
112
+ Loading recent pages...
113
+ </div>
114
+ </div>
115
+ )}
116
+ {!isLoading && (!history || history.length === 0) && (
117
+ <div className="p-6 text-center text-xs text-gray-500">
118
+ No recent pages found
119
+ </div>
120
+ )}
121
+ </div>
122
+ </div>
120
123
  </Card>
121
124
  );
122
125
  }
@@ -174,7 +174,7 @@ export function SplashScreen() {
174
174
  title=<span className="tracking-wides text-2xl font-extralight">
175
175
  parhelia
176
176
  </span>
177
- description="Where brilliant ideas become brilliant content"
177
+ description="The easiest way to create and manage your content"
178
178
  icon={<AnimatedSunIcon />}
179
179
  className="flex-1"
180
180
  >
package/styles.css CHANGED
@@ -1064,23 +1064,3 @@ body {
1064
1064
  [data-side="right"].slide-in-from-left-2 {
1065
1065
  animation-name: slide-in-from-left;
1066
1066
  }
1067
-
1068
- /* ViewTransition animations for Parhelia Assistant Chat */
1069
- ::view-transition-old(.slide-fade-in) {
1070
- animation: 200ms cubic-bezier(0.4, 0, 0.2, 1) both fade-out;
1071
- }
1072
-
1073
- ::view-transition-new(.slide-fade-in) {
1074
- animation: 400ms cubic-bezier(0.4, 0, 0.2, 1) both slide-fade-in-animation;
1075
- }
1076
-
1077
- @keyframes slide-fade-in-animation {
1078
- from {
1079
- opacity: 0;
1080
- transform: translateY(20px);
1081
- }
1082
- to {
1083
- opacity: 1;
1084
- transform: translateY(0);
1085
- }
1086
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * PlaceholderInput component for AI Agent quick actions.
3
- *
4
- * Allows users to fill in placeholders in text templates with tab navigation.
5
- *
6
- * Example usage for AI Agents:
7
- * ```json
8
- * {
9
- * "label": "Create Component",
10
- * "prompt": "Create a {component_type} component named {component_name}",
11
- * "behavior": "submit"
12
- * }
13
- * ```
14
- *
15
- * Supported placeholder formats:
16
- * - Curly braces: {placeholder_name} or {0}, {1}, {2}
17
- * - Angle brackets: <placeholder_name> or <0>, <1>, <2>
18
- *
19
- * Keyboard navigation:
20
- * - Tab: Move to next placeholder (wraps to first)
21
- * - Shift+Tab: Move to previous placeholder (wraps to last)
22
- * - Enter: Submit with filled values
23
- * - Escape: Cancel
24
- */
25
- export type Placeholder = {
26
- name: string;
27
- type: string;
28
- parameters: Record<string, string>;
29
- index: number;
30
- startPos: number;
31
- endPos: number;
32
- };
33
- type PlaceholderInputProps = {
34
- text: string;
35
- onComplete: (filledText: string) => void;
36
- onCancel?: () => void;
37
- className?: string;
38
- showButtons?: boolean;
39
- };
40
- export declare function PlaceholderInput({ text, onComplete, onCancel, className, showButtons, }: PlaceholderInputProps): import("react/jsx-runtime").JSX.Element;
41
- export {};
@@ -1,160 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { cn } from "../../lib/utils";
4
- import { Button } from "./button";
5
- import { X } from "lucide-react";
6
- import { placeholderInputTypeRegistry } from "./PlaceholderInputTypes";
7
- function parsePlaceholders(text) {
8
- const placeholders = [];
9
- // Match both {placeholder} and <placeholder> formats
10
- const regex = /\{([^}]+)\}|<([^>]+)>/g;
11
- let match;
12
- let index = 0;
13
- while ((match = regex.exec(text)) !== null) {
14
- // match[1] is for {placeholder}, match[2] is for <placeholder>
15
- const placeholderContent = match[1] || match[2];
16
- if (placeholderContent) {
17
- // Parse the content: {label|type|param=value|param2=value2}
18
- const parts = placeholderContent.split("|");
19
- const label = parts[0]?.trim() || "";
20
- const type = parts[1]?.trim() || "text"; // Default to "text" type
21
- // Parse parameters from remaining parts (format: key=value)
22
- const parameters = {};
23
- for (let i = 2; i < parts.length; i++) {
24
- const part = parts[i]?.trim() || "";
25
- if (!part)
26
- continue;
27
- const eqIndex = part.indexOf("=");
28
- if (eqIndex !== -1) {
29
- const key = part.substring(0, eqIndex).trim();
30
- const value = part.substring(eqIndex + 1).trim();
31
- if (key) {
32
- parameters[key] = value;
33
- }
34
- }
35
- }
36
- placeholders.push({
37
- name: label,
38
- type,
39
- parameters,
40
- index: index++,
41
- startPos: match.index,
42
- endPos: match.index + match[0].length,
43
- });
44
- }
45
- }
46
- return placeholders;
47
- }
48
- export function PlaceholderInput({ text, onComplete, onCancel, className, showButtons = true, }) {
49
- const placeholders = React.useMemo(() => parsePlaceholders(text), [text]);
50
- const [values, setValues] = React.useState({});
51
- // Create refs for each placeholder using useRef to avoid the null issue
52
- const inputRefs = React.useRef({});
53
- // Auto-focus first placeholder on mount
54
- React.useEffect(() => {
55
- if (placeholders.length > 0) {
56
- const firstInput = inputRefs.current[0];
57
- if (firstInput) {
58
- setTimeout(() => firstInput.focus(), 0);
59
- }
60
- }
61
- }, [placeholders.length]);
62
- const handleValueChange = (index, value) => {
63
- setValues((prev) => ({ ...prev, [index]: value }));
64
- };
65
- const handleKeyDown = (e, index) => {
66
- if (e.key === "Tab") {
67
- e.preventDefault();
68
- if (e.shiftKey) {
69
- // Shift+Tab: go to previous input (wrap to last if at first)
70
- const prevIndex = index - 1;
71
- if (prevIndex >= 0) {
72
- inputRefs.current[prevIndex]?.focus();
73
- }
74
- else {
75
- // Wrap to last placeholder
76
- inputRefs.current[placeholders.length - 1]?.focus();
77
- }
78
- }
79
- else {
80
- // Tab: go to next input (wrap to first if at last)
81
- const nextIndex = index + 1;
82
- if (nextIndex < placeholders.length) {
83
- inputRefs.current[nextIndex]?.focus();
84
- }
85
- else {
86
- // Wrap to first placeholder
87
- inputRefs.current[0]?.focus();
88
- }
89
- }
90
- }
91
- else if (e.key === "Enter") {
92
- e.preventDefault();
93
- handleSubmit();
94
- }
95
- else if (e.key === "Escape") {
96
- e.preventDefault();
97
- onCancel?.();
98
- }
99
- };
100
- const handleSubmit = () => {
101
- // Build the filled text by replacing placeholders with values
102
- let filledText = text;
103
- // Replace in reverse order to maintain correct positions
104
- for (let i = placeholders.length - 1; i >= 0; i--) {
105
- const placeholder = placeholders[i];
106
- if (!placeholder)
107
- continue;
108
- const value = values[i] || "";
109
- // Format the value based on placeholder type and parameters
110
- let formattedValue = value;
111
- if (placeholder.type === "item" && value.includes("|")) {
112
- // Parse item value format: "id|path"
113
- const parts = value.split("|");
114
- const id = parts[0] || "";
115
- const path = parts[1] || "";
116
- const name = path.split("/").pop() || "";
117
- // For item placeholders, output both ID and name
118
- formattedValue = `{${id}} (${name})`;
119
- }
120
- filledText =
121
- filledText.substring(0, placeholder.startPos) +
122
- formattedValue +
123
- filledText.substring(placeholder.endPos);
124
- }
125
- onComplete(filledText);
126
- };
127
- if (placeholders.length === 0) {
128
- // No placeholders, just display text
129
- return _jsx("div", { className: cn("text-xs", className), children: text });
130
- }
131
- // Build segments: text and placeholder inputs
132
- const segments = [];
133
- let lastPos = 0;
134
- placeholders.forEach((placeholder, idx) => {
135
- // Add text before this placeholder
136
- if (placeholder.startPos > lastPos) {
137
- segments.push(_jsx("span", { className: "whitespace-pre-wrap", children: text.substring(lastPos, placeholder.startPos) }, `text-${idx}`));
138
- }
139
- // Add input for this placeholder
140
- // Look up the component for this placeholder type
141
- const typeConfig = placeholderInputTypeRegistry.get(placeholder.type);
142
- const InputComponent = typeConfig?.component;
143
- if (InputComponent) {
144
- segments.push(_jsx(InputComponent, { placeholder: placeholder, value: values[idx] || "", onChange: (value) => handleValueChange(idx, value), onKeyDown: (e) => handleKeyDown(e, idx), inputRef: (el) => {
145
- inputRefs.current[idx] = el;
146
- }, autoFocus: idx === 0 }, `input-${idx}`));
147
- }
148
- lastPos = placeholder.endPos;
149
- });
150
- // Add remaining text after last placeholder
151
- if (lastPos < text.length) {
152
- segments.push(_jsx("span", { className: "whitespace-pre-wrap", children: text.substring(lastPos) }, "text-end"));
153
- }
154
- const allFilled = placeholders.every((_, idx) => {
155
- const value = values[idx];
156
- return value !== undefined && value.trim() !== "";
157
- });
158
- return (_jsxs("div", { className: cn("space-y-2", className), children: [_jsxs("div", { className: cn("relative flex flex-wrap items-center gap-1 rounded-lg border border-blue-200 bg-blue-50/50 p-3 text-xs h-[80px] overflow-y-auto", onCancel && "pr-8"), children: [segments, onCancel && (_jsx("button", { onClick: onCancel, className: "absolute right-2 top-2 rounded p-0.5 text-gray-400 hover:bg-blue-100 hover:text-gray-600 transition-colors", title: "Cancel (Esc)", "aria-label": "Cancel", children: _jsx(X, { size: 14, strokeWidth: 2 }) }))] }), showButtons && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { size: "sm", onClick: handleSubmit, disabled: !allFilled, className: "h-7", children: "Submit" }), onCancel && (_jsx(Button, { size: "sm", variant: "ghost", onClick: onCancel, className: "h-7", children: "Cancel" })), !allFilled && (_jsx("span", { className: "text-xs text-gray-500", children: "Fill all fields (use Tab to navigate)" }))] }))] }));
159
- }
160
- //# sourceMappingURL=PlaceholderInput.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlaceholderInput.js","sourceRoot":"","sources":["../../../src/components/ui/PlaceholderInput.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AA4CvE,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,qDAAqD;IACrD,MAAM,KAAK,GAAG,wBAAwB,CAAC;IACvC,IAAI,KAAK,CAAC;IACV,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC3C,+DAA+D;QAC/D,MAAM,kBAAkB,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC;QAChD,IAAI,kBAAkB,EAAE,CAAC;YACvB,4DAA4D;YAC5D,MAAM,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,MAAM,CAAC,CAAC,yBAAyB;YAElE,4DAA4D;YAC5D,MAAM,UAAU,GAA2B,EAAE,CAAC;YAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC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AQ,EACjB,SAAS,EAAC,4GAA4G,EACtH,KAAK,EAAC,cAAc,gBACT,QAAQ,YAEnB,KAAC,CAAC,IAAC,IAAI,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,GAAI,GACxB,CACV,IACG,EACL,WAAW,IAAI,CACd,eAAK,SAAS,EAAC,yBAAyB,aACtC,KAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,CAAC,SAAS,EACpB,SAAS,EAAC,KAAK,uBAGR,EACR,QAAQ,IAAI,CACX,KAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,OAAO,EACf,OAAO,EAAE,QAAQ,EACjB,SAAS,EAAC,KAAK,uBAGR,CACV,EACA,CAAC,SAAS,IAAI,CACb,eAAM,SAAS,EAAC,uBAAuB,sDAEhC,CACR,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -1,41 +0,0 @@
1
- import * as React from "react";
2
- import { Placeholder } from "./PlaceholderInput";
3
- /**
4
- * Props interface that all placeholder input type components must implement
5
- */
6
- export interface PlaceholderInputComponentProps {
7
- placeholder: Placeholder;
8
- value: string;
9
- onChange: (value: string) => void;
10
- onKeyDown: (e: React.KeyboardEvent) => void;
11
- inputRef: React.Ref<HTMLInputElement | HTMLTextAreaElement>;
12
- autoFocus?: boolean;
13
- }
14
- /**
15
- * Configuration for a placeholder input type
16
- */
17
- export interface PlaceholderInputTypeConfig {
18
- type: string;
19
- component: React.ComponentType<PlaceholderInputComponentProps>;
20
- validator?: (value: string) => boolean;
21
- }
22
- /**
23
- * Registry for placeholder input types
24
- */
25
- declare class PlaceholderInputTypeRegistry {
26
- private types;
27
- /**
28
- * Register a new placeholder input type
29
- */
30
- register(config: PlaceholderInputTypeConfig): void;
31
- /**
32
- * Get a registered placeholder input type configuration
33
- */
34
- get(type: string): PlaceholderInputTypeConfig | undefined;
35
- /**
36
- * Check if a type is registered
37
- */
38
- has(type: string): boolean;
39
- }
40
- export declare const placeholderInputTypeRegistry: PlaceholderInputTypeRegistry;
41
- export {};
@@ -1,48 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- /**
3
- * Registry for placeholder input types
4
- */
5
- class PlaceholderInputTypeRegistry {
6
- types = new Map();
7
- /**
8
- * Register a new placeholder input type
9
- */
10
- register(config) {
11
- this.types.set(config.type.toLowerCase(), config);
12
- }
13
- /**
14
- * Get a registered placeholder input type configuration
15
- */
16
- get(type) {
17
- return this.types.get(type.toLowerCase());
18
- }
19
- /**
20
- * Check if a type is registered
21
- */
22
- has(type) {
23
- return this.types.has(type.toLowerCase());
24
- }
25
- }
26
- // Create singleton instance
27
- export const placeholderInputTypeRegistry = new PlaceholderInputTypeRegistry();
28
- /**
29
- * Default text input component for placeholders
30
- */
31
- const TextInput = ({ placeholder, value, onChange, onKeyDown, inputRef, autoFocus, }) => {
32
- return (_jsx("input", { ref: inputRef, type: "text", value: value, onChange: (e) => onChange(e.target.value), onKeyDown: onKeyDown, placeholder: placeholder.name, autoFocus: autoFocus, className: "inline-flex min-w-[80px] max-w-[200px] rounded border border-blue-400 bg-blue-50 px-2 py-0.5 text-xs outline-none transition-all focus:border-blue-600 focus:bg-blue-100 focus:ring-2 focus:ring-blue-500/30 placeholder:text-blue-400", style: {
33
- width: `${Math.max(80, (value?.length || placeholder.name.length) * 7 + 20)}px`,
34
- } }));
35
- };
36
- // Register default text type
37
- placeholderInputTypeRegistry.register({
38
- type: "text",
39
- component: TextInput,
40
- });
41
- // Import and register item selector (dynamic import to avoid circular dependencies)
42
- import("./PlaceholderItemSelector").then((module) => {
43
- placeholderInputTypeRegistry.register({
44
- type: "item",
45
- component: module.PlaceholderItemSelector,
46
- });
47
- });
48
- //# sourceMappingURL=PlaceholderInputTypes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlaceholderInputTypes.js","sourceRoot":"","sources":["../../../src/components/ui/PlaceholderInputTypes.tsx"],"names":[],"mappings":";AAwBA;;G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AAC7B,4BAA4B,CAAC,QAAQ,CAAC;IACpC,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,SAAS;CACrB,CAAC,CAAC;AAEH,oFAAoF;AACpF,MAAM,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;IAClD,4BAA4B,CAAC,QAAQ,CAAC;QACpC,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,MAAM,CAAC,uBAAuB;KAC1C,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import { PlaceholderInputComponentProps } from "./PlaceholderInputTypes";
3
- /**
4
- * Item selector component for placeholder inputs
5
- * Allows selecting a Sitecore item via search or tree browsing
6
- */
7
- export declare const PlaceholderItemSelector: React.FC<PlaceholderInputComponentProps>;
@@ -1,154 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { cn } from "../../lib/utils";
4
- import { Popover, PopoverContent, PopoverTrigger } from "./popover";
5
- import { ItemSearch } from "../../editor/ui/ItemSearch";
6
- import ContentTree from "../../editor/ContentTree";
7
- import { useEditContext } from "../../editor/client/editContext";
8
- import { X, ChevronDown } from "lucide-react";
9
- import { Splitter } from "../../editor/ui/Splitter";
10
- /**
11
- * Item selector component for placeholder inputs
12
- * Allows selecting a Sitecore item via search or tree browsing
13
- */
14
- export const PlaceholderItemSelector = ({ placeholder, value, onChange, onKeyDown, inputRef, autoFocus, }) => {
15
- const [isOpen, setIsOpen] = React.useState(false);
16
- const [selectedItem, setSelectedItem] = React.useState(null);
17
- const [rootItemId, setRootItemId] = React.useState(null);
18
- const [isLoadingRoot, setIsLoadingRoot] = React.useState(false);
19
- const editContext = useEditContext();
20
- // Parse root parameter from placeholder.parameters
21
- const rootPathOrId = placeholder.parameters.root || "/sitecore/content";
22
- // Helper to check if a string is a GUID
23
- const isGuid = (str) => {
24
- const guidPattern = /^[{]?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}[}]?$/;
25
- return guidPattern.test(str);
26
- };
27
- // Resolve root path/ID to an item ID on mount
28
- React.useEffect(() => {
29
- const resolveRootItem = async () => {
30
- if (!editContext)
31
- return;
32
- // If it's already a GUID, use it directly
33
- if (isGuid(rootPathOrId)) {
34
- setRootItemId(rootPathOrId.replace(/[{}]/g, ""));
35
- return;
36
- }
37
- // Otherwise, resolve the path to an ID
38
- setIsLoadingRoot(true);
39
- try {
40
- const item = await editContext.itemsRepository.getItem({
41
- id: rootPathOrId, // Try as ID first
42
- language: "en",
43
- version: 0,
44
- });
45
- if (item?.id) {
46
- setRootItemId(item.id);
47
- }
48
- else {
49
- // If not found by ID, it might be a path - we need to search for it
50
- console.error("Could not resolve root item:", rootPathOrId);
51
- // Fallback to Sitecore content root
52
- setRootItemId("0DE95AE4-41AB-4D01-9EB0-67441B7C2450");
53
- }
54
- }
55
- catch (error) {
56
- console.error("Error resolving root item:", error);
57
- // Fallback to Sitecore content root
58
- setRootItemId("0DE95AE4-41AB-4D01-9EB0-67441B7C2450");
59
- }
60
- finally {
61
- setIsLoadingRoot(false);
62
- }
63
- };
64
- resolveRootItem();
65
- }, [editContext, rootPathOrId]);
66
- const loadItemByIdOrPath = React.useCallback(async (idOrPath) => {
67
- if (!editContext)
68
- return;
69
- try {
70
- const item = await editContext.itemsRepository.getItem({
71
- id: idOrPath,
72
- language: "en",
73
- version: 0,
74
- });
75
- if (item) {
76
- setSelectedItem({
77
- id: item.id,
78
- path: item.path || item.name,
79
- name: item.name,
80
- language: "en",
81
- icon: item.icon,
82
- });
83
- const newValue = `${item.id}|${item.path || item.name}`;
84
- onChange(newValue);
85
- }
86
- }
87
- catch (error) {
88
- console.error("Failed to load item:", error);
89
- }
90
- }, [editContext, onChange]);
91
- // Parse existing value (format: "id|path")
92
- React.useEffect(() => {
93
- if (!value || !editContext)
94
- return;
95
- if (value.includes("|")) {
96
- const [id, path] = value.split("|");
97
- const name = path?.split("/").pop() || "";
98
- setSelectedItem({ id: id || "", path: path || "", name, language: "en" });
99
- }
100
- else {
101
- // Try to load item by ID or path
102
- loadItemByIdOrPath(value);
103
- }
104
- }, [value, editContext, loadItemByIdOrPath]);
105
- const handleItemSelected = (item) => {
106
- const resultItem = {
107
- id: item.id,
108
- name: item.name || "",
109
- path: item.path || "",
110
- language: item.language || "en",
111
- icon: item.icon,
112
- idPath: item.idPath,
113
- };
114
- setSelectedItem(resultItem);
115
- const newValue = `${resultItem.id}|${resultItem.path}`;
116
- onChange(newValue);
117
- setIsOpen(false);
118
- };
119
- const handleClear = (e) => {
120
- e.stopPropagation();
121
- setSelectedItem(null);
122
- onChange("");
123
- };
124
- const displayValue = selectedItem ? selectedItem.path : "";
125
- // Don't render until root is resolved
126
- if (isLoadingRoot || !rootItemId) {
127
- return (_jsx("div", { ref: inputRef, className: "inline-flex min-w-[150px] max-w-[300px] items-center gap-1 rounded border border-gray-300 bg-gray-50 px-2 py-0.5 text-xs", children: _jsx("span", { className: "flex-1 text-gray-400", children: "Loading..." }) }));
128
- }
129
- return (_jsxs(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("div", { ref: inputRef, tabIndex: 0, onKeyDown: onKeyDown, className: cn("inline-flex min-w-[150px] max-w-[300px] cursor-pointer items-center gap-1 rounded border border-blue-400 bg-blue-50 px-2 py-0.5 text-xs outline-none transition-all", "hover:border-blue-500 hover:bg-blue-100", "focus:border-blue-600 focus:bg-blue-100 focus:ring-2 focus:ring-blue-500/30"), children: selectedItem ? (_jsxs(_Fragment, { children: [selectedItem.icon && (_jsx("img", { src: selectedItem.icon, alt: "", className: "h-3 w-3 flex-shrink-0" })), _jsx("span", { className: "flex-1 truncate", children: displayValue }), _jsx("button", { onClick: handleClear, className: "rounded p-0.5 hover:bg-blue-200", title: "Clear selection", children: _jsx(X, { size: 12 }) })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "flex-1 text-blue-400", children: placeholder.name }), _jsx(ChevronDown, { size: 12, className: "text-blue-400" })] })) }) }), _jsx(PopoverContent, { className: "w-[700px] p-0", align: "start", onOpenAutoFocus: (e) => e.preventDefault(), children: _jsx("div", { className: "flex h-[450px]", children: _jsx(Splitter, { direction: "horizontal", localStorageKey: "placeholder-item-selector-split", panels: [
130
- {
131
- name: "tree",
132
- defaultSize: 300,
133
- content: (_jsx("div", { className: "h-full overflow-auto border-r border-gray-200 p-2", children: _jsx(ContentTree, { rootItemIds: [rootItemId], selectionMode: "single", selectedItemIds: selectedItem ? [selectedItem.id] : [], onSelectionChange: (selection) => {
134
- const node = selection[0];
135
- if (node) {
136
- handleItemSelected({
137
- id: node.id,
138
- name: node.name,
139
- path: node.path || node.name,
140
- language: "en",
141
- version: 0,
142
- icon: node.icon,
143
- });
144
- }
145
- }, language: "en" }) })),
146
- },
147
- {
148
- name: "search",
149
- defaultSize: "auto",
150
- content: (_jsx("div", { className: "flex h-full flex-col p-4", children: _jsx(ItemSearch, { rootItemIds: rootItemId ? [rootItemId] : undefined, itemSelected: handleItemSelected, language: "en", autoFocus: true }) })),
151
- },
152
- ] }) }) })] }));
153
- };
154
- //# sourceMappingURL=PlaceholderItemSelector.js.map