@puckeditor/plugin-ai 0.9.0-canary.be7eccfe → 0.9.0-canary.bf40b813
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +816 -1733
- package/dist/index.js +978 -1294
- package/dist/index.mjs +695 -1011
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -430,8 +430,8 @@ var toCamelCase = (string) => string.replace(
|
|
|
430
430
|
(match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
|
|
431
431
|
);
|
|
432
432
|
var toPascalCase = (string) => {
|
|
433
|
-
const
|
|
434
|
-
return
|
|
433
|
+
const camelCase = toCamelCase(string);
|
|
434
|
+
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
435
435
|
};
|
|
436
436
|
var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
437
437
|
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
@@ -993,12 +993,12 @@ function useChat({
|
|
|
993
993
|
}
|
|
994
994
|
|
|
995
995
|
// src/components/Chat/index.tsx
|
|
996
|
-
var
|
|
996
|
+
var import_core4 = require("@puckeditor/core");
|
|
997
997
|
var import_ai5 = require("ai");
|
|
998
|
-
var
|
|
998
|
+
var import_react17 = require("react");
|
|
999
999
|
var import_ulid = require("ulid");
|
|
1000
1000
|
|
|
1001
|
-
// ../
|
|
1001
|
+
// ../platform-client/lib/get-class-name-factory.ts
|
|
1002
1002
|
init_react_import();
|
|
1003
1003
|
var import_classnames = __toESM(require_classnames());
|
|
1004
1004
|
var getClassNameFactory = (rootClass, styles, { baseClass = "" } = {}) => (options = {}) => {
|
|
@@ -1034,118 +1034,38 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
|
1034
1034
|
|
|
1035
1035
|
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/Chat/styles.module.css#css-module
|
|
1036
1036
|
init_react_import();
|
|
1037
|
-
var styles_module_default = { "Chat": "
|
|
1037
|
+
var styles_module_default = { "Chat": "_Chat_gflib_1", "Chat-header": "_Chat-header_gflib_9", "Chat-placeholder": "_Chat-placeholder_gflib_24", "Chat-placeholderIcon": "_Chat-placeholderIcon_gflib_43", "Chat-placeholderTitle": "_Chat-placeholderTitle_gflib_57", "Chat-placeholderDescription": "_Chat-placeholderDescription_gflib_62", "Chat-actions": "_Chat-actions_gflib_68", "Chat-action": "_Chat-action_gflib_68", "Chat-actionOutlined": "_Chat-actionOutlined_gflib_77", "Chat-attachmentControls": "_Chat-attachmentControls_gflib_140", "Chat-attachmentInput": "_Chat-attachmentInput_gflib_147", "Chat-attachmentButton": "_Chat-attachmentButton_gflib_151" };
|
|
1038
1038
|
|
|
1039
1039
|
// src/components/ChatBody/index.tsx
|
|
1040
1040
|
init_react_import();
|
|
1041
|
-
var
|
|
1041
|
+
var import_react11 = require("react");
|
|
1042
1042
|
var import_use_stick_to_bottom = require("use-stick-to-bottom");
|
|
1043
1043
|
var import_react_markdown = __toESM(require("react-markdown"));
|
|
1044
1044
|
|
|
1045
|
-
// ../platform-client/index.ts
|
|
1046
|
-
init_react_import();
|
|
1047
|
-
|
|
1048
|
-
// ../platform-client/components/ActionModal/index.ts
|
|
1049
|
-
init_react_import();
|
|
1050
|
-
|
|
1051
|
-
// ../platform-client/components/ActionModal/ActionModal.tsx
|
|
1052
|
-
init_react_import();
|
|
1053
|
-
|
|
1054
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/ActionModal/ActionModal.module.css#css-module
|
|
1055
|
-
init_react_import();
|
|
1056
|
-
var ActionModal_module_default = { "ActionModal": "_ActionModal_1g44k_1", "ActionModal-header": "_ActionModal-header_1g44k_6", "ActionModal-body": "_ActionModal-body_1g44k_17", "ActionModal-footer": "_ActionModal-footer_1g44k_25" };
|
|
1057
|
-
|
|
1058
|
-
// ../platform-client/lib/index.ts
|
|
1059
|
-
init_react_import();
|
|
1060
|
-
|
|
1061
|
-
// ../platform-client/lib/get-class-name-factory.ts
|
|
1062
|
-
init_react_import();
|
|
1063
|
-
var import_classnames2 = __toESM(require_classnames());
|
|
1064
|
-
var getClassNameFactory2 = (rootClass, styles, { baseClass = "" } = {}) => (options = {}) => {
|
|
1065
|
-
let descendant = false;
|
|
1066
|
-
let modifiers = false;
|
|
1067
|
-
if (typeof options === "string") {
|
|
1068
|
-
descendant = options;
|
|
1069
|
-
} else if (typeof options === "object") {
|
|
1070
|
-
modifiers = options;
|
|
1071
|
-
}
|
|
1072
|
-
if (descendant) {
|
|
1073
|
-
const style = styles[`${rootClass}-${descendant}`];
|
|
1074
|
-
if (style) {
|
|
1075
|
-
return baseClass + styles[`${rootClass}-${descendant}`] || "";
|
|
1076
|
-
}
|
|
1077
|
-
return "";
|
|
1078
|
-
} else if (modifiers) {
|
|
1079
|
-
const prefixedModifiers = {};
|
|
1080
|
-
for (let modifier in modifiers) {
|
|
1081
|
-
prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
|
|
1082
|
-
}
|
|
1083
|
-
const c = styles[rootClass];
|
|
1084
|
-
return baseClass + (0, import_classnames2.default)({
|
|
1085
|
-
[c]: !!c,
|
|
1086
|
-
// only apply the class if it exists
|
|
1087
|
-
...prefixedModifiers
|
|
1088
|
-
});
|
|
1089
|
-
} else {
|
|
1090
|
-
return baseClass + styles[rootClass] || "";
|
|
1091
|
-
}
|
|
1092
|
-
};
|
|
1093
|
-
var get_class_name_factory_default2 = getClassNameFactory2;
|
|
1094
|
-
|
|
1095
|
-
// ../platform-client/components/Modal/Modal.tsx
|
|
1096
|
-
init_react_import();
|
|
1097
|
-
|
|
1098
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Modal/Modal.module.css#css-module
|
|
1045
|
+
// ../platform-client/components/IconButton/index.ts
|
|
1099
1046
|
init_react_import();
|
|
1100
|
-
var Modal_module_default = { "Modal-background": "_Modal-background_mocy5_1", "Modal--visible": "_Modal--visible_mocy5_16", "Modal-modal": "_Modal-modal_mocy5_22" };
|
|
1101
|
-
|
|
1102
|
-
// ../platform-client/components/Modal/Modal.tsx
|
|
1103
|
-
var import_react9 = require("react");
|
|
1104
1047
|
|
|
1105
|
-
// ../platform-client/
|
|
1048
|
+
// ../platform-client/components/IconButton/IconButton.tsx
|
|
1106
1049
|
init_react_import();
|
|
1107
1050
|
var import_react7 = require("react");
|
|
1108
|
-
var useModalVisible = (defaultVisible) => {
|
|
1109
|
-
const [visible, setVisible] = (0, import_react7.useState)(defaultVisible ?? false);
|
|
1110
|
-
const ref = (0, import_react7.useRef)(null);
|
|
1111
|
-
(0, import_react7.useEffect)(() => {
|
|
1112
|
-
if (!visible) {
|
|
1113
|
-
return;
|
|
1114
|
-
}
|
|
1115
|
-
const handler = (e) => {
|
|
1116
|
-
if (ref.current && !ref.current.contains(e.target)) {
|
|
1117
|
-
setVisible(false);
|
|
1118
|
-
}
|
|
1119
|
-
};
|
|
1120
|
-
document.body.addEventListener("click", handler);
|
|
1121
|
-
return () => {
|
|
1122
|
-
document.body.removeEventListener("click", handler);
|
|
1123
|
-
};
|
|
1124
|
-
}, [visible]);
|
|
1125
|
-
return [visible, setVisible, ref];
|
|
1126
|
-
};
|
|
1127
1051
|
|
|
1128
|
-
//
|
|
1129
|
-
init_react_import();
|
|
1130
|
-
|
|
1131
|
-
// ../platform-client/components/Button/Button.tsx
|
|
1052
|
+
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/IconButton/IconButton.module.css#css-module
|
|
1132
1053
|
init_react_import();
|
|
1133
|
-
var
|
|
1054
|
+
var IconButton_module_default = { "IconButton": "_IconButton_voaix_1", "IconButton--disabled": "_IconButton--disabled_voaix_30", "IconButton--dark": "_IconButton--dark_voaix_40", "IconButton-title": "_IconButton-title_voaix_61" };
|
|
1134
1055
|
|
|
1135
|
-
//
|
|
1056
|
+
// ../platform-client/components/Loader/index.tsx
|
|
1136
1057
|
init_react_import();
|
|
1137
|
-
var Button_module_default = { "Button": "_Button_16or4_1", "Button--tiny": "_Button--tiny_16or4_34", "Button--small": "_Button--small_16or4_39", "Button--medium": "_Button--medium_16or4_44", "Button--large": "_Button--large_16or4_52", "Button--brand": "_Button--brand_16or4_59", "Button--primary": "_Button--primary_16or4_79", "Button--secondary": "_Button--secondary_16or4_93", "Button--danger": "_Button--danger_16or4_111", "Button--flush": "_Button--flush_16or4_125", "Button--ghost": "_Button--ghost_16or4_129", "Button--disabled": "_Button--disabled_16or4_146", "Button--fullWidth": "_Button--fullWidth_16or4_156", "Button-spinner": "_Button-spinner_16or4_161" };
|
|
1138
1058
|
|
|
1139
|
-
// ../platform-client/
|
|
1059
|
+
// ../platform-client/lib/index.ts
|
|
1140
1060
|
init_react_import();
|
|
1141
1061
|
|
|
1142
1062
|
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Loader/styles.module.css#css-module
|
|
1143
1063
|
init_react_import();
|
|
1144
|
-
var styles_module_default2 = { "Loader": "
|
|
1064
|
+
var styles_module_default2 = { "Loader": "_Loader_68nru_13", "loader-animation": "_loader-animation_68nru_1" };
|
|
1145
1065
|
|
|
1146
1066
|
// ../platform-client/components/Loader/index.tsx
|
|
1147
1067
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1148
|
-
var getClassName =
|
|
1068
|
+
var getClassName = getClassNameFactory("Loader", styles_module_default2);
|
|
1149
1069
|
var Loader = ({
|
|
1150
1070
|
color,
|
|
1151
1071
|
size = 16,
|
|
@@ -1166,10 +1086,10 @@ var Loader = ({
|
|
|
1166
1086
|
);
|
|
1167
1087
|
};
|
|
1168
1088
|
|
|
1169
|
-
// ../platform-client/components/
|
|
1089
|
+
// ../platform-client/components/IconButton/IconButton.tsx
|
|
1170
1090
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1171
|
-
var getClassName2 =
|
|
1172
|
-
var
|
|
1091
|
+
var getClassName2 = get_class_name_factory_default("IconButton", IconButton_module_default);
|
|
1092
|
+
var IconButton = ({
|
|
1173
1093
|
children,
|
|
1174
1094
|
href,
|
|
1175
1095
|
onClick,
|
|
@@ -1179,37 +1099,22 @@ var Button = ({
|
|
|
1179
1099
|
tabIndex,
|
|
1180
1100
|
newTab,
|
|
1181
1101
|
fullWidth,
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
loading: loadingProp = false
|
|
1102
|
+
title,
|
|
1103
|
+
dark
|
|
1185
1104
|
}) => {
|
|
1186
|
-
const [loading, setLoading] = (0,
|
|
1187
|
-
|
|
1188
|
-
const resetLoading = () => setLoading(loadingProp);
|
|
1189
|
-
resetLoading();
|
|
1190
|
-
window.addEventListener("pageshow", resetLoading);
|
|
1191
|
-
return () => window.removeEventListener("pageshow", resetLoading);
|
|
1192
|
-
}, [loadingProp]);
|
|
1193
|
-
const ElementType = href ? "a" : type ? "button" : "span";
|
|
1105
|
+
const [loading, setLoading] = (0, import_react7.useState)(false);
|
|
1106
|
+
const ElementType = href ? "a" : onClick ? "button" : "div";
|
|
1194
1107
|
const el = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1195
1108
|
ElementType,
|
|
1196
1109
|
{
|
|
1197
1110
|
className: getClassName2({
|
|
1198
|
-
brand: variant === "brand",
|
|
1199
1111
|
primary: variant === "primary",
|
|
1200
1112
|
secondary: variant === "secondary",
|
|
1201
|
-
|
|
1202
|
-
ghost: variant === "ghost",
|
|
1203
|
-
// Disabled while its click is still running, too.
|
|
1204
|
-
disabled: disabled || loading,
|
|
1113
|
+
disabled,
|
|
1205
1114
|
fullWidth,
|
|
1206
|
-
|
|
1115
|
+
dark
|
|
1207
1116
|
}),
|
|
1208
1117
|
onClick: (e) => {
|
|
1209
|
-
if (disabled || loading) {
|
|
1210
|
-
e.preventDefault();
|
|
1211
|
-
return;
|
|
1212
|
-
}
|
|
1213
1118
|
if (!onClick) return;
|
|
1214
1119
|
setLoading(true);
|
|
1215
1120
|
Promise.resolve(onClick(e)).then(() => {
|
|
@@ -1222,599 +1127,80 @@ var Button = ({
|
|
|
1222
1127
|
target: newTab ? "_blank" : void 0,
|
|
1223
1128
|
rel: newTab ? "noreferrer" : void 0,
|
|
1224
1129
|
href,
|
|
1130
|
+
title,
|
|
1225
1131
|
children: [
|
|
1226
|
-
|
|
1132
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: getClassName2("title"), children: title }),
|
|
1227
1133
|
children,
|
|
1228
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime2.
|
|
1134
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1135
|
+
"\xA0\xA0",
|
|
1136
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loader, { size: 14 })
|
|
1137
|
+
] })
|
|
1229
1138
|
]
|
|
1230
1139
|
}
|
|
1231
1140
|
);
|
|
1232
1141
|
return el;
|
|
1233
1142
|
};
|
|
1234
1143
|
|
|
1235
|
-
//
|
|
1236
|
-
|
|
1237
|
-
var
|
|
1238
|
-
var modalContext = (0, import_react9.createContext)({
|
|
1239
|
-
buttonVariant: "primary",
|
|
1240
|
-
buttonSize: "medium",
|
|
1241
|
-
visible: false,
|
|
1242
|
-
setVisible: () => {
|
|
1243
|
-
},
|
|
1244
|
-
ref: null
|
|
1245
|
-
});
|
|
1246
|
-
var ModalProvider = ({
|
|
1247
|
-
children,
|
|
1248
|
-
defaultVisible,
|
|
1249
|
-
buttonVariant = "primary",
|
|
1250
|
-
buttonSize = "medium"
|
|
1251
|
-
}) => {
|
|
1252
|
-
const [visible, setVisible, ref] = useModalVisible(defaultVisible);
|
|
1253
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1254
|
-
modalContext.Provider,
|
|
1255
|
-
{
|
|
1256
|
-
value: { buttonVariant, buttonSize, visible, setVisible, ref },
|
|
1257
|
-
children
|
|
1258
|
-
}
|
|
1259
|
-
);
|
|
1260
|
-
};
|
|
1261
|
-
var useModal = () => {
|
|
1262
|
-
const { visible, setVisible } = (0, import_react9.useContext)(modalContext);
|
|
1263
|
-
return { visible, setVisible };
|
|
1264
|
-
};
|
|
1265
|
-
var Modal = ({
|
|
1266
|
-
actionLabel = "Open",
|
|
1267
|
-
children,
|
|
1268
|
-
hideButton = false
|
|
1269
|
-
}) => {
|
|
1270
|
-
const { visible, setVisible, buttonVariant, buttonSize, ref } = (0, import_react9.useContext)(modalContext);
|
|
1271
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: getClassName3({ visible }), children: [
|
|
1272
|
-
!hideButton && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("button"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1273
|
-
Button,
|
|
1274
|
-
{
|
|
1275
|
-
type: "button",
|
|
1276
|
-
variant: buttonVariant,
|
|
1277
|
-
size: buttonSize,
|
|
1278
|
-
onClick: (e) => {
|
|
1279
|
-
e.stopPropagation();
|
|
1280
|
-
setVisible(!visible);
|
|
1281
|
-
},
|
|
1282
|
-
children: actionLabel
|
|
1283
|
-
}
|
|
1284
|
-
) }),
|
|
1285
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("background"), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: getClassName3("modal"), ref, children }) })
|
|
1286
|
-
] });
|
|
1287
|
-
};
|
|
1144
|
+
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
|
|
1145
|
+
init_react_import();
|
|
1146
|
+
var styles_module_default3 = { "Chat": "_Chat_epa47_1", "Chat--hasMessages": "_Chat--hasMessages_epa47_23", "Chat-inner": "_Chat-inner_epa47_34", "Chat--hasChildren": "_Chat--hasChildren_epa47_46", "Chat-body": "_Chat-body_epa47_51", "Chat--isLoading": "_Chat--isLoading_epa47_58", "Chat-messages": "_Chat-messages_epa47_62", "Chat-form": "_Chat-form_epa47_69", "Chat--hideInput": "_Chat--hideInput_epa47_74", "Chat-formHelper": "_Chat-formHelper_epa47_88", "Chat-examplePrompts": "_Chat-examplePrompts_epa47_104", "Chat-examplePrompt": "_Chat-examplePrompt_epa47_104", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_epa47_145", "Chat-default": "_Chat-default_epa47_150", "ChatMessage": "_ChatMessage_epa47_167", "ChatMessage--userRole": "_ChatMessage--userRole_epa47_176", "ChatMessage-userBubble": "_ChatMessage-userBubble_epa47_176", "ChatMessage-userAttachments": "_ChatMessage-userAttachments_epa47_187", "ChatMessage-thumbnail": "_ChatMessage-thumbnail_epa47_193", "ChatMessage-thumbnailLabel": "_ChatMessage-thumbnailLabel_epa47_224", "ChatMessage-text": "_ChatMessage-text_epa47_298", "ChatMessage-event": "_ChatMessage-event_epa47_334", "ChatMessage-eventBody": "_ChatMessage-eventBody_epa47_338", "ChatMessage-eventCollapse": "_ChatMessage-eventCollapse_epa47_347", "ChatMessage-eventHeader": "_ChatMessage-eventHeader_epa47_351", "ChatMessage-eventExpand": "_ChatMessage-eventExpand_epa47_351", "ChatMessage-eventHeader--static": "_ChatMessage-eventHeader--static_epa47_377", "ChatMessage-eventIcon": "_ChatMessage-eventIcon_epa47_383", "ChatMessage-eventLabel": "_ChatMessage-eventLabel_epa47_387", "ChatMessage-attachmentImage": "_ChatMessage-attachmentImage_epa47_401", "ChatMessage-attachmentFile": "_ChatMessage-attachmentFile_epa47_419", "Chat-loader": "_Chat-loader_epa47_443", "Chat-loaderIcon": "_Chat-loaderIcon_epa47_453", "Chat-error": "_Chat-error_epa47_457", "Chat-errorLabel": "_Chat-errorLabel_epa47_466", "Chat-errorAction": "_Chat-errorAction_epa47_470", "Chat-userError": "_Chat-userError_epa47_474", "Chat-userErrorDismiss": "_Chat-userErrorDismiss_epa47_484" };
|
|
1288
1147
|
|
|
1289
|
-
//
|
|
1148
|
+
// src/components/PromptForm/index.tsx
|
|
1290
1149
|
init_react_import();
|
|
1150
|
+
var import_react8 = require("react");
|
|
1291
1151
|
|
|
1292
|
-
// ../platform-client/components/
|
|
1152
|
+
// ../platform-client/components/Textarea/index.tsx
|
|
1293
1153
|
init_react_import();
|
|
1154
|
+
var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
|
|
1294
1155
|
|
|
1295
|
-
// css-module:/home/runner/work/platform/platform/packages/
|
|
1156
|
+
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/PromptForm/styles.module.css#css-module
|
|
1296
1157
|
init_react_import();
|
|
1297
|
-
var
|
|
1158
|
+
var styles_module_default4 = { "PromptForm": "_PromptForm_1p0vz_1", "PromptForm-dropOverlay": "_PromptForm-dropOverlay_1p0vz_15", "PromptForm-inner": "_PromptForm-inner_1p0vz_43", "PromptForm--glow": "_PromptForm--glow_1p0vz_52", "PromptForm-glow": "_PromptForm-glow_1p0vz_52", "loop": "_loop_1p0vz_1", "PromptForm-formInner": "_PromptForm-formInner_1p0vz_85", "PromptForm-input": "_PromptForm-input_1p0vz_94", "PromptForm--isDisabled": "_PromptForm--isDisabled_1p0vz_133", "PromptForm-helper": "_PromptForm-helper_1p0vz_152", "PromptForm-actions": "_PromptForm-actions_1p0vz_162", "PromptForm-actionsLeft": "_PromptForm-actionsLeft_1p0vz_173", "PromptForm-actionsRight": "_PromptForm-actionsRight_1p0vz_182", "PromptForm-actionSubmit": "_PromptForm-actionSubmit_1p0vz_187", "PromptForm--userCta": "_PromptForm--userCta_1p0vz_211", "PromptForm--isLoading": "_PromptForm--isLoading_1p0vz_241", "PromptForm-attachments": "_PromptForm-attachments_1p0vz_247", "PromptForm-attachmentChip": "_PromptForm-attachmentChip_1p0vz_255", "PromptForm-attachmentChipUploading": "_PromptForm-attachmentChipUploading_1p0vz_271", "PromptForm-attachmentChipFailed": "_PromptForm-attachmentChipFailed_1p0vz_275", "PromptForm-attachmentError": "_PromptForm-attachmentError_1p0vz_280", "PromptForm-attachmentSpinner": "_PromptForm-attachmentSpinner_1p0vz_285", "PromptForm-attachmentSpin": "_PromptForm-attachmentSpin_1p0vz_285", "PromptForm-attachmentRemove": "_PromptForm-attachmentRemove_1p0vz_289" };
|
|
1298
1159
|
|
|
1299
|
-
//
|
|
1300
|
-
|
|
1301
|
-
var
|
|
1302
|
-
var
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1160
|
+
// src/lib/attachments.ts
|
|
1161
|
+
init_react_import();
|
|
1162
|
+
var INTERNAL_MESSAGE_PREFIX = "[puck-internal";
|
|
1163
|
+
var defaultAttachmentAccept = [
|
|
1164
|
+
"image/*",
|
|
1165
|
+
".pdf",
|
|
1166
|
+
".doc",
|
|
1167
|
+
".docx",
|
|
1168
|
+
".txt",
|
|
1169
|
+
".md"
|
|
1170
|
+
];
|
|
1171
|
+
var defaultAttachmentConfig = {
|
|
1172
|
+
maxFiles: 5,
|
|
1173
|
+
maxSizeBytes: 10 * 1024 * 1024
|
|
1174
|
+
};
|
|
1175
|
+
var getExtension = (filename) => {
|
|
1176
|
+
const parts = filename.toLowerCase().split(".");
|
|
1177
|
+
if (parts.length < 2) {
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
1180
|
+
return `.${parts.pop()}`;
|
|
1181
|
+
};
|
|
1182
|
+
var matchesAccept = (file, accept) => {
|
|
1183
|
+
if (accept.length === 0) {
|
|
1184
|
+
return true;
|
|
1185
|
+
}
|
|
1186
|
+
const extension = getExtension(file.name);
|
|
1187
|
+
return accept.some((entry) => {
|
|
1188
|
+
if (entry.endsWith("/*")) {
|
|
1189
|
+
const prefix = entry.slice(0, -1);
|
|
1190
|
+
return file.type.startsWith(prefix);
|
|
1317
1191
|
}
|
|
1318
|
-
|
|
1192
|
+
if (entry.startsWith(".")) {
|
|
1193
|
+
return extension === entry.toLowerCase();
|
|
1194
|
+
}
|
|
1195
|
+
return file.type === entry;
|
|
1196
|
+
});
|
|
1319
1197
|
};
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
actionLabel = "Open",
|
|
1327
|
-
children,
|
|
1328
|
-
title,
|
|
1329
|
-
description,
|
|
1330
|
-
actions,
|
|
1331
|
-
hideButton
|
|
1332
|
-
}) => {
|
|
1333
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Modal, { actionLabel, hideButton, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName5(), children: [
|
|
1334
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: getClassName5("header"), children: [
|
|
1335
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Heading, { size: "s", children: title }),
|
|
1336
|
-
description && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("small", { children: description })
|
|
1337
|
-
] }),
|
|
1338
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName5("body"), children }),
|
|
1339
|
-
actions && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ActionModalFooter, { children: actions })
|
|
1340
|
-
] }) });
|
|
1341
|
-
};
|
|
1342
|
-
ActionModal.Footer = ActionModalFooter;
|
|
1343
|
-
|
|
1344
|
-
// ../platform-client/components/AIAction/index.tsx
|
|
1345
|
-
init_react_import();
|
|
1346
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1347
|
-
|
|
1348
|
-
// ../platform-client/components/Align/index.ts
|
|
1349
|
-
init_react_import();
|
|
1350
|
-
|
|
1351
|
-
// ../platform-client/components/Align/Align.tsx
|
|
1352
|
-
init_react_import();
|
|
1353
|
-
var import_react10 = __toESM(require("react"));
|
|
1354
|
-
|
|
1355
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Align/Align.module.css#css-module
|
|
1356
|
-
init_react_import();
|
|
1357
|
-
var Align_module_default = { "Align": "_Align_oewlu_1", "Align--horizontalCenter": "_Align--horizontalCenter_oewlu_7", "Align--horizontalRight": "_Align--horizontalRight_oewlu_11", "Align--verticalBottom": "_Align--verticalBottom_oewlu_15", "Align--verticalCenter": "_Align--verticalCenter_oewlu_20", "Align-item": "_Align-item_oewlu_25" };
|
|
1358
|
-
|
|
1359
|
-
// ../../node_modules/.pnpm/camelcase@8.0.0/node_modules/camelcase/index.js
|
|
1360
|
-
init_react_import();
|
|
1361
|
-
var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
|
|
1362
|
-
var SEPARATORS = /[_.\- ]+/;
|
|
1363
|
-
var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
|
|
1364
|
-
var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
|
|
1365
|
-
var NUMBERS_AND_IDENTIFIER = new RegExp("\\d+" + IDENTIFIER.source, "gu");
|
|
1366
|
-
|
|
1367
|
-
// ../platform-client/components/Align/Align.tsx
|
|
1368
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1369
|
-
var getClassName6 = get_class_name_factory_default2("Align", Align_module_default);
|
|
1370
|
-
|
|
1371
|
-
// ../platform-client/components/AutoForm/index.ts
|
|
1372
|
-
init_react_import();
|
|
1373
|
-
|
|
1374
|
-
// ../platform-client/components/AutoForm/AutoForm.tsx
|
|
1375
|
-
init_react_import();
|
|
1376
|
-
var import_core = require("@puckeditor/core");
|
|
1377
|
-
var import_react11 = require("react");
|
|
1378
|
-
|
|
1379
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/AutoForm/AutoForm.module.css#css-module
|
|
1380
|
-
init_react_import();
|
|
1381
|
-
var AutoForm_module_default = { "AutoForm": "_AutoForm_1vmh9_1" };
|
|
1382
|
-
|
|
1383
|
-
// ../platform-client/components/AutoForm/AutoForm.tsx
|
|
1384
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1385
|
-
var getClassName7 = getClassNameFactory2("AutoForm", AutoForm_module_default);
|
|
1386
|
-
|
|
1387
|
-
// ../platform-client/components/Card/index.ts
|
|
1388
|
-
init_react_import();
|
|
1389
|
-
|
|
1390
|
-
// ../platform-client/components/Card/Card.tsx
|
|
1391
|
-
init_react_import();
|
|
1392
|
-
|
|
1393
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Card/Card.module.css#css-module
|
|
1394
|
-
init_react_import();
|
|
1395
|
-
var Card_module_default = { "Card": "_Card_rpnal_1", "Card-body": "_Card-body_rpnal_17", "Card-title": "_Card-title_rpnal_23", "Card-subtitle": "_Card-subtitle_rpnal_27", "Card-chevron": "_Card-chevron_rpnal_32", "Card--showChevron": "_Card--showChevron_rpnal_38", "Card--isActive": "_Card--isActive_rpnal_42" };
|
|
1396
|
-
|
|
1397
|
-
// ../platform-client/components/Card/Card.tsx
|
|
1398
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1399
|
-
var getClassName8 = get_class_name_factory_default2("Card", Card_module_default);
|
|
1400
|
-
|
|
1401
|
-
// ../platform-client/components/CardSelector/index.tsx
|
|
1402
|
-
init_react_import();
|
|
1403
|
-
|
|
1404
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/CardSelector/styles.module.css#css-module
|
|
1405
|
-
init_react_import();
|
|
1406
|
-
var styles_module_default3 = { "CardSelector": "_CardSelector_1ogry_1", "CardSelectorOption": "_CardSelectorOption_1ogry_12", "CardSelectorOption--isSelected": "_CardSelectorOption--isSelected_1ogry_23", "CardSelectorOption--disabled": "_CardSelectorOption--disabled_1ogry_27", "CardSelectorOption-description": "_CardSelectorOption-description_1ogry_31", "CardSelectorOption-body": "_CardSelectorOption-body_1ogry_35" };
|
|
1407
|
-
|
|
1408
|
-
// ../platform-client/components/CardSelector/index.tsx
|
|
1409
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1410
|
-
var cx = get_class_name_factory_default("CardSelector", styles_module_default3);
|
|
1411
|
-
var cxOption = get_class_name_factory_default("CardSelectorOption", styles_module_default3);
|
|
1412
|
-
|
|
1413
|
-
// ../platform-client/components/Code/index.ts
|
|
1414
|
-
init_react_import();
|
|
1415
|
-
|
|
1416
|
-
// ../platform-client/components/Code/Code.tsx
|
|
1417
|
-
init_react_import();
|
|
1418
|
-
|
|
1419
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Code/Code.module.css#css-module
|
|
1420
|
-
init_react_import();
|
|
1421
|
-
var Code_module_default = { "Code": "_Code_d4378_1", "Code-body": "_Code-body_d4378_8", "Code--light": "_Code--light_d4378_19", "Code-header": "_Code-header_d4378_34", "Code-corner": "_Code-corner_d4378_51", "Code-actions": "_Code-actions_d4378_71", "Code--lineNumbers": "_Code--lineNumbers_d4378_76", "Code-tabs": "_Code-tabs_d4378_91", "Tab": "_Tab_d4378_99", "Tab--isActive": "_Tab--isActive_d4378_104", "Tab--light": "_Tab--light_d4378_108", "Tab-button": "_Tab-button_d4378_112" };
|
|
1422
|
-
|
|
1423
|
-
// ../platform-client/components/Code/CopyAction.tsx
|
|
1424
|
-
init_react_import();
|
|
1425
|
-
var import_react12 = require("react");
|
|
1426
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1427
|
-
|
|
1428
|
-
// ../platform-client/components/Code/Code.tsx
|
|
1429
|
-
var import_react13 = require("react");
|
|
1430
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1431
|
-
var getClassName9 = get_class_name_factory_default("Code", Code_module_default);
|
|
1432
|
-
var getClassNameTab = get_class_name_factory_default("Tab", Code_module_default);
|
|
1433
|
-
|
|
1434
|
-
// ../platform-client/components/IconButton/index.ts
|
|
1435
|
-
init_react_import();
|
|
1436
|
-
|
|
1437
|
-
// ../platform-client/components/IconButton/IconButton.tsx
|
|
1438
|
-
init_react_import();
|
|
1439
|
-
var import_react14 = require("react");
|
|
1440
|
-
|
|
1441
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/IconButton/IconButton.module.css#css-module
|
|
1442
|
-
init_react_import();
|
|
1443
|
-
var IconButton_module_default = { "IconButton": "_IconButton_thegm_1", "IconButton--disabled": "_IconButton--disabled_thegm_20", "IconButton--dark": "_IconButton--dark_thegm_26", "IconButton-title": "_IconButton-title_thegm_37" };
|
|
1444
|
-
|
|
1445
|
-
// ../platform-client/components/IconButton/IconButton.tsx
|
|
1446
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1447
|
-
var getClassName10 = get_class_name_factory_default2("IconButton", IconButton_module_default);
|
|
1448
|
-
var IconButton = ({
|
|
1449
|
-
children,
|
|
1450
|
-
href,
|
|
1451
|
-
onClick,
|
|
1452
|
-
variant = "primary",
|
|
1453
|
-
type,
|
|
1454
|
-
disabled,
|
|
1455
|
-
tabIndex,
|
|
1456
|
-
newTab,
|
|
1457
|
-
fullWidth,
|
|
1458
|
-
title,
|
|
1459
|
-
dark
|
|
1460
|
-
}) => {
|
|
1461
|
-
const [loading, setLoading] = (0, import_react14.useState)(false);
|
|
1462
|
-
const ElementType = href ? "a" : onClick ? "button" : "div";
|
|
1463
|
-
const el = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1464
|
-
ElementType,
|
|
1465
|
-
{
|
|
1466
|
-
className: getClassName10({
|
|
1467
|
-
primary: variant === "primary",
|
|
1468
|
-
secondary: variant === "secondary",
|
|
1469
|
-
disabled,
|
|
1470
|
-
fullWidth,
|
|
1471
|
-
dark
|
|
1472
|
-
}),
|
|
1473
|
-
onClick: (e) => {
|
|
1474
|
-
if (!onClick) return;
|
|
1475
|
-
setLoading(true);
|
|
1476
|
-
Promise.resolve(onClick(e)).then(() => {
|
|
1477
|
-
setLoading(false);
|
|
1478
|
-
});
|
|
1479
|
-
},
|
|
1480
|
-
type,
|
|
1481
|
-
disabled: disabled || loading,
|
|
1482
|
-
tabIndex,
|
|
1483
|
-
target: newTab ? "_blank" : void 0,
|
|
1484
|
-
rel: newTab ? "noreferrer" : void 0,
|
|
1485
|
-
href,
|
|
1486
|
-
title,
|
|
1487
|
-
children: [
|
|
1488
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: getClassName10("title"), children: title }),
|
|
1489
|
-
children,
|
|
1490
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
|
|
1491
|
-
"\xA0\xA0",
|
|
1492
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 14 })
|
|
1493
|
-
] })
|
|
1494
|
-
]
|
|
1495
|
-
}
|
|
1496
|
-
);
|
|
1497
|
-
return el;
|
|
1498
|
-
};
|
|
1499
|
-
|
|
1500
|
-
// ../platform-client/components/InfoBar/index.tsx
|
|
1501
|
-
init_react_import();
|
|
1502
|
-
|
|
1503
|
-
// ../platform-client/components/InfoBar/InfoBar.tsx
|
|
1504
|
-
init_react_import();
|
|
1505
|
-
|
|
1506
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/InfoBar/InfoBar.module.css#css-module
|
|
1507
|
-
init_react_import();
|
|
1508
|
-
var InfoBar_module_default = { "InfoBar": "_InfoBar_kchdj_1", "Info": "_Info_kchdj_1", "Info-title": "_Info-title_kchdj_21" };
|
|
1509
|
-
|
|
1510
|
-
// ../platform-client/components/InfoBar/InfoBar.tsx
|
|
1511
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1512
|
-
var cx2 = getClassNameFactory2("InfoBar", InfoBar_module_default);
|
|
1513
|
-
var cxInfo = getClassNameFactory2("Info", InfoBar_module_default);
|
|
1514
|
-
var Info = ({ title, children }) => {
|
|
1515
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: cxInfo(), children: [
|
|
1516
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cxInfo("title"), children: title }),
|
|
1517
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cxInfo("children"), children })
|
|
1518
|
-
] });
|
|
1519
|
-
};
|
|
1520
|
-
var InfoBar = ({ children }) => {
|
|
1521
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: cx2(), children });
|
|
1522
|
-
};
|
|
1523
|
-
InfoBar.Info = Info;
|
|
1524
|
-
|
|
1525
|
-
// ../platform-client/components/Inline/index.ts
|
|
1526
|
-
init_react_import();
|
|
1527
|
-
|
|
1528
|
-
// ../platform-client/components/Inline/Inline.tsx
|
|
1529
|
-
init_react_import();
|
|
1530
|
-
|
|
1531
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Inline/Inline.module.css#css-module
|
|
1532
|
-
init_react_import();
|
|
1533
|
-
var Inline_module_default = { "Inline": "_Inline_6o5on_3", "Inline-inner": "_Inline-inner_6o5on_7", "Inline--noWrap": "_Inline--noWrap_6o5on_12", "Inline--sizeNONE": "_Inline--sizeNONE_6o5on_16", "Inline--sizeXXS": "_Inline--sizeXXS_6o5on_20", "Inline--sizeXS": "_Inline--sizeXS_6o5on_24", "Inline--sizeS": "_Inline--sizeS_6o5on_28", "Inline--sizeM": "_Inline--sizeM_6o5on_32", "Inline--sizeL": "_Inline--sizeL_6o5on_36", "Inline--center": "_Inline--center_6o5on_40", "Inline--centerH": "_Inline--centerH_6o5on_44", "Inline--grow": "_Inline--grow_6o5on_48" };
|
|
1534
|
-
|
|
1535
|
-
// ../platform-client/components/Inline/Inline.tsx
|
|
1536
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1537
|
-
var getClassName11 = get_class_name_factory_default2("Inline", Inline_module_default);
|
|
1538
|
-
var Inline = ({
|
|
1539
|
-
children,
|
|
1540
|
-
grow,
|
|
1541
|
-
center,
|
|
1542
|
-
size = "m",
|
|
1543
|
-
noWrap,
|
|
1544
|
-
centerH
|
|
1545
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1546
|
-
"div",
|
|
1547
|
-
{
|
|
1548
|
-
className: getClassName11({
|
|
1549
|
-
grow,
|
|
1550
|
-
center,
|
|
1551
|
-
centerH,
|
|
1552
|
-
noWrap,
|
|
1553
|
-
[`size${size.toUpperCase()}`]: size
|
|
1554
|
-
}),
|
|
1555
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName11("inner"), children })
|
|
1556
|
-
}
|
|
1557
|
-
);
|
|
1558
|
-
var InlineItem = ({
|
|
1559
|
-
children,
|
|
1560
|
-
grow,
|
|
1561
|
-
push,
|
|
1562
|
-
shrink
|
|
1563
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1564
|
-
"div",
|
|
1565
|
-
{
|
|
1566
|
-
style: {
|
|
1567
|
-
flexGrow: grow ? typeof grow === "number" ? grow : "1" : "0",
|
|
1568
|
-
flexShrink: shrink ? "1" : "0",
|
|
1569
|
-
marginLeft: push ? "auto" : 0,
|
|
1570
|
-
maxWidth: "100%"
|
|
1571
|
-
},
|
|
1572
|
-
children
|
|
1573
|
-
}
|
|
1574
|
-
);
|
|
1575
|
-
Inline.Item = InlineItem;
|
|
1576
|
-
|
|
1577
|
-
// ../platform-client/components/Link/index.ts
|
|
1578
|
-
init_react_import();
|
|
1579
|
-
|
|
1580
|
-
// ../platform-client/components/Link/Link.tsx
|
|
1581
|
-
init_react_import();
|
|
1582
|
-
|
|
1583
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Link/Link.module.css#css-module
|
|
1584
|
-
init_react_import();
|
|
1585
|
-
var Link_module_default = { "Link": "_Link_1j70m_1" };
|
|
1586
|
-
|
|
1587
|
-
// ../platform-client/components/Link/Link.tsx
|
|
1588
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1589
|
-
var getClassName12 = get_class_name_factory_default2("Link", Link_module_default);
|
|
1590
|
-
|
|
1591
|
-
// ../platform-client/components/Menu/index.tsx
|
|
1592
|
-
init_react_import();
|
|
1593
|
-
var import_react15 = require("react");
|
|
1594
|
-
|
|
1595
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Menu/styles.module.css#css-module
|
|
1596
|
-
init_react_import();
|
|
1597
|
-
var styles_module_default4 = { "Menu": "_Menu_1jr57_1", "Menu-content": "_Menu-content_1jr57_6", "Menu-sections": "_Menu-sections_1jr57_11", "Menu-action": "_Menu-action_1jr57_22", "Menu-list": "_Menu-list_1jr57_44", "Menu-item": "_Menu-item_1jr57_55", "Menu-item--disabled": "_Menu-item--disabled_1jr57_84" };
|
|
1598
|
-
|
|
1599
|
-
// ../platform-client/components/Menu/index.tsx
|
|
1600
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1601
|
-
var getClassName13 = get_class_name_factory_default2("Menu", styles_module_default4);
|
|
1602
|
-
var itemClassName = get_class_name_factory_default2("Menu-item", styles_module_default4);
|
|
1603
|
-
|
|
1604
|
-
// ../platform-client/components/Modal/index.ts
|
|
1605
|
-
init_react_import();
|
|
1606
|
-
|
|
1607
|
-
// ../platform-client/components/Page/index.ts
|
|
1608
|
-
init_react_import();
|
|
1609
|
-
|
|
1610
|
-
// ../platform-client/components/Page/Page.tsx
|
|
1611
|
-
init_react_import();
|
|
1612
|
-
|
|
1613
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Page/Page.module.css#css-module
|
|
1614
|
-
init_react_import();
|
|
1615
|
-
var Page_module_default = { "Page": "_Page_nkzj9_1", "Page-masthead": "_Page-masthead_nkzj9_8", "Page-crumbs": "_Page-crumbs_nkzj9_18", "Page-crumb": "_Page-crumb_nkzj9_18", "Page-crumbLink": "_Page-crumbLink_nkzj9_29", "Page-actions": "_Page-actions_nkzj9_61", "Page-footer": "_Page-footer_nkzj9_65" };
|
|
1616
|
-
|
|
1617
|
-
// ../platform-client/components/Page/Page.tsx
|
|
1618
|
-
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1619
|
-
var cx3 = getClassNameFactory2("Page", Page_module_default);
|
|
1620
|
-
|
|
1621
|
-
// ../platform-client/components/Pagination/index.ts
|
|
1622
|
-
init_react_import();
|
|
1623
|
-
|
|
1624
|
-
// ../platform-client/components/Pagination/Pagination.tsx
|
|
1625
|
-
init_react_import();
|
|
1626
|
-
var import_react16 = require("react");
|
|
1627
|
-
|
|
1628
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Pagination/Pagination.module.css#css-module
|
|
1629
|
-
init_react_import();
|
|
1630
|
-
var Pagination_module_default = { "Pagination": "_Pagination_1okv2_1", "PaginationButton": "_PaginationButton_1okv2_8", "PaginationButton--isActive": "_PaginationButton--isActive_1okv2_20", "Pagination-ellipsis": "_Pagination-ellipsis_1okv2_30" };
|
|
1631
|
-
|
|
1632
|
-
// ../platform-client/components/Pagination/Pagination.tsx
|
|
1633
|
-
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1634
|
-
var cx4 = getClassNameFactory2("Pagination", Pagination_module_default);
|
|
1635
|
-
var cxButton = getClassNameFactory2("PaginationButton", Pagination_module_default);
|
|
1636
|
-
|
|
1637
|
-
// ../platform-client/components/PlanGrid/index.tsx
|
|
1638
|
-
init_react_import();
|
|
1639
|
-
|
|
1640
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/PlanGrid/styles.module.css#css-module
|
|
1641
|
-
init_react_import();
|
|
1642
|
-
var styles_module_default5 = { "PlanGrid": "_PlanGrid_1ar8g_1", "PlanGrid-billingNote": "_PlanGrid-billingNote_1ar8g_8", "PlanGrid-planKicker": "_PlanGrid-planKicker_1ar8g_9", "PlanGrid-tableWrapper": "_PlanGrid-tableWrapper_1ar8g_18", "PlanGrid-table": "_PlanGrid-table_1ar8g_18", "PlanGrid-caption": "_PlanGrid-caption_1ar8g_33", "PlanGrid-featureHeader": "_PlanGrid-featureHeader_1ar8g_43", "PlanGrid-featureName": "_PlanGrid-featureName_1ar8g_44", "PlanGrid-planHeader": "_PlanGrid-planHeader_1ar8g_45", "PlanGrid-featureValue": "_PlanGrid-featureValue_1ar8g_46", "PlanGrid-planHeaderInner": "_PlanGrid-planHeaderInner_1ar8g_76", "PlanGrid-planTitle": "_PlanGrid-planTitle_1ar8g_91", "PlanGrid-planDescription": "_PlanGrid-planDescription_1ar8g_97", "PlanGrid-priceBlock": "_PlanGrid-priceBlock_1ar8g_105", "PlanGrid-price": "_PlanGrid-price_1ar8g_105", "PlanGrid-standardPrice": "_PlanGrid-standardPrice_1ar8g_117", "PlanGrid-priceValue": "_PlanGrid-priceValue_1ar8g_124", "PlanGrid-priceInterval": "_PlanGrid-priceInterval_1ar8g_130", "PlanGrid-priceNote": "_PlanGrid-priceNote_1ar8g_136", "PlanGrid-action": "_PlanGrid-action_1ar8g_143", "PlanGrid-included": "_PlanGrid-included_1ar8g_168", "PlanGrid-unavailable": "_PlanGrid-unavailable_1ar8g_179", "PlanGrid-highlightCell": "_PlanGrid-highlightCell_1ar8g_183", "PlanGrid-enterprise": "_PlanGrid-enterprise_1ar8g_201" };
|
|
1643
|
-
|
|
1644
|
-
// ../utils/lib/format-currency.ts
|
|
1645
|
-
init_react_import();
|
|
1646
|
-
|
|
1647
|
-
// ../platform-client/lib/plan-ids.ts
|
|
1648
|
-
init_react_import();
|
|
1649
|
-
var PAYG_PLAN_ID = "pay-as-you-go_v2";
|
|
1650
|
-
var LAUNCH_PLAN_ID = "launch_monthly_v2";
|
|
1651
|
-
var GROWTH_PLAN_ID = "growth_monthly_v2";
|
|
1652
|
-
var PLAN_RANK = {
|
|
1653
|
-
[PAYG_PLAN_ID]: 0,
|
|
1654
|
-
[LAUNCH_PLAN_ID]: 1,
|
|
1655
|
-
[GROWTH_PLAN_ID]: 2
|
|
1656
|
-
};
|
|
1657
|
-
var LEGACY_PLAN_IDS = [
|
|
1658
|
-
"pro_monthly",
|
|
1659
|
-
"business_monthly",
|
|
1660
|
-
"growth_monthly",
|
|
1661
|
-
"pro_annual",
|
|
1662
|
-
"business_annual",
|
|
1663
|
-
"growth_annual",
|
|
1664
|
-
"pro50_monthly",
|
|
1665
|
-
"business200_monthly",
|
|
1666
|
-
"pro_unlimited_monthly",
|
|
1667
|
-
"business_unlimited_monthly"
|
|
1668
|
-
];
|
|
1669
|
-
var VALID_PLAN_IDS = [
|
|
1670
|
-
...LEGACY_PLAN_IDS,
|
|
1671
|
-
"pay-as-you-go_v2",
|
|
1672
|
-
"launch_monthly_v2",
|
|
1673
|
-
"growth_monthly_v2"
|
|
1674
|
-
];
|
|
1675
|
-
|
|
1676
|
-
// ../platform-client/components/PlanGrid/index.tsx
|
|
1677
|
-
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1678
|
-
var cx5 = get_class_name_factory_default("PlanGrid", styles_module_default5);
|
|
1679
|
-
|
|
1680
|
-
// ../platform-client/components/Section/index.ts
|
|
1681
|
-
init_react_import();
|
|
1682
|
-
|
|
1683
|
-
// ../platform-client/components/Section/Section.tsx
|
|
1684
|
-
init_react_import();
|
|
1685
|
-
|
|
1686
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Section/Section.module.css#css-module
|
|
1687
|
-
init_react_import();
|
|
1688
|
-
var Section_module_default = { "Section-inner": "_Section-inner_1uwo0_1", "Section--flush": "_Section--flush_1uwo0_8", "Section": "_Section_1uwo0_1", "Section--full": "_Section--full_1uwo0_17" };
|
|
1689
|
-
|
|
1690
|
-
// ../platform-client/components/Section/Section.tsx
|
|
1691
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1692
|
-
var getClassName14 = getClassNameFactory2("Section", Section_module_default);
|
|
1693
|
-
|
|
1694
|
-
// ../platform-client/components/StatusTag/index.ts
|
|
1695
|
-
init_react_import();
|
|
1696
|
-
|
|
1697
|
-
// ../platform-client/components/StatusTag/StatusTag.tsx
|
|
1698
|
-
init_react_import();
|
|
1699
|
-
|
|
1700
|
-
// ../platform-client/components/Tag/index.ts
|
|
1701
|
-
init_react_import();
|
|
1702
|
-
|
|
1703
|
-
// ../platform-client/components/Tag/Tag.tsx
|
|
1704
|
-
init_react_import();
|
|
1705
|
-
|
|
1706
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Tag/Tag.module.css#css-module
|
|
1707
|
-
init_react_import();
|
|
1708
|
-
var Tag_module_default = { "Tag": "_Tag_162k8_1", "Tag--borderless": "_Tag--borderless_162k8_21", "Tag--colorBlue": "_Tag--colorBlue_162k8_25", "Tag--colorGreen": "_Tag--colorGreen_162k8_30", "Tag--colorRed": "_Tag--colorRed_162k8_34", "Tag--colorMuted": "_Tag--colorMuted_162k8_38", "Tag-sprite": "_Tag-sprite_162k8_42", "Tag--pulse": "_Tag--pulse_162k8_46", "pulse": "_pulse_162k8_1", "Tag-label": "_Tag-label_162k8_80" };
|
|
1709
|
-
|
|
1710
|
-
// ../platform-client/components/Tag/Tag.tsx
|
|
1711
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1712
|
-
var getClassName15 = getClassNameFactory2("Tag", Tag_module_default);
|
|
1713
|
-
|
|
1714
|
-
// ../platform-client/components/StatusTag/StatusTag.tsx
|
|
1715
|
-
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1716
|
-
|
|
1717
|
-
// ../platform-client/components/Table/index.ts
|
|
1718
|
-
init_react_import();
|
|
1719
|
-
|
|
1720
|
-
// ../platform-client/components/Table/Table.tsx
|
|
1721
|
-
init_react_import();
|
|
1722
|
-
var import_react17 = require("react");
|
|
1723
|
-
|
|
1724
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Table/Table.module.css#css-module
|
|
1725
|
-
init_react_import();
|
|
1726
|
-
var Table_module_default = { "Table": "_Table_o345u_1", "Table-filters": "_Table-filters_o345u_9", "Table-inner": "_Table-inner_o345u_13", "Table-table": "_Table-table_o345u_17", "Table--hideHeader": "_Table--hideHeader_o345u_41", "Table-footer": "_Table-footer_o345u_89", "Table--clickableRows": "_Table--clickableRows_o345u_93", "Table-placeholder": "_Table-placeholder_o345u_98", "Table-loader": "_Table-loader_o345u_110", "TableRow--highlightRow": "_TableRow--highlightRow_o345u_114" };
|
|
1727
|
-
|
|
1728
|
-
// ../platform-client/components/Table/Table.tsx
|
|
1729
|
-
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1730
|
-
var getClassName16 = get_class_name_factory_default2("Table", Table_module_default);
|
|
1731
|
-
var getRowClassName = get_class_name_factory_default2("TableRow", Table_module_default);
|
|
1732
|
-
|
|
1733
|
-
// ../platform-client/components/Textarea/index.tsx
|
|
1734
|
-
init_react_import();
|
|
1735
|
-
var import_react_textarea_autosize = __toESM(require("react-textarea-autosize"));
|
|
1736
|
-
|
|
1737
|
-
// ../platform-client/components/VerticalSpace/index.ts
|
|
1738
|
-
init_react_import();
|
|
1739
|
-
|
|
1740
|
-
// ../platform-client/components/VerticalSpace/VerticalSpace.tsx
|
|
1741
|
-
init_react_import();
|
|
1742
|
-
|
|
1743
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/VerticalSpace/VerticalSpace.module.css#css-module
|
|
1744
|
-
init_react_import();
|
|
1745
|
-
var VerticalSpace_module_default = { "VerticalSpace": "_VerticalSpace_16t6j_1", "VerticalSpace--size4": "_VerticalSpace--size4_16t6j_5", "VerticalSpace--size8": "_VerticalSpace--size8_16t6j_9", "VerticalSpace--size16": "_VerticalSpace--size16_16t6j_13", "VerticalSpace--size32": "_VerticalSpace--size32_16t6j_17", "VerticalSpace--size40": "_VerticalSpace--size40_16t6j_21", "VerticalSpace--size48": "_VerticalSpace--size48_16t6j_25", "VerticalSpace--size56": "_VerticalSpace--size56_16t6j_29", "VerticalSpace--size96": "_VerticalSpace--size96_16t6j_33", "VerticalSpace--size128": "_VerticalSpace--size128_16t6j_37" };
|
|
1746
|
-
|
|
1747
|
-
// ../platform-client/components/VerticalSpace/VerticalSpace.tsx
|
|
1748
|
-
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
1749
|
-
var getClassName17 = get_class_name_factory_default2("VerticalSpace", VerticalSpace_module_default);
|
|
1750
|
-
|
|
1751
|
-
// ../platform-client/components/Viewport/index.tsx
|
|
1752
|
-
init_react_import();
|
|
1753
|
-
|
|
1754
|
-
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Viewport/styles.module.css#css-module
|
|
1755
|
-
init_react_import();
|
|
1756
|
-
var styles_module_default6 = { "Viewport": "_Viewport_1vvhm_3", "Viewport--standard": "_Viewport--standard_1vvhm_6", "Viewport--inline": "_Viewport--inline_1vvhm_7", "Viewport--narrow": "_Viewport--narrow_1vvhm_11", "Viewport--flex": "_Viewport--flex_1vvhm_19" };
|
|
1757
|
-
|
|
1758
|
-
// ../platform-client/components/Viewport/index.tsx
|
|
1759
|
-
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1760
|
-
var cx6 = getClassNameFactory("Viewport", styles_module_default6);
|
|
1761
|
-
|
|
1762
|
-
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/ChatBody/styles.module.css#css-module
|
|
1763
|
-
init_react_import();
|
|
1764
|
-
var styles_module_default7 = { "Chat": "_Chat_5z5yi_1", "Chat--hasMessages": "_Chat--hasMessages_5z5yi_17", "Chat-inner": "_Chat-inner_5z5yi_28", "Chat--hasChildren": "_Chat--hasChildren_5z5yi_40", "Chat-body": "_Chat-body_5z5yi_45", "Chat--isLoading": "_Chat--isLoading_5z5yi_52", "Chat-messages": "_Chat-messages_5z5yi_56", "Chat-form": "_Chat-form_5z5yi_63", "Chat--hideInput": "_Chat--hideInput_5z5yi_68", "Chat-formHelper": "_Chat-formHelper_5z5yi_82", "Chat-examplePrompts": "_Chat-examplePrompts_5z5yi_97", "Chat-examplePrompt": "_Chat-examplePrompt_5z5yi_97", "Chat-examplePromptArrow": "_Chat-examplePromptArrow_5z5yi_134", "Chat-default": "_Chat-default_5z5yi_139", "ChatMessage": "_ChatMessage_5z5yi_155", "ChatMessage--userRole": "_ChatMessage--userRole_5z5yi_164", "ChatMessage-userBubble": "_ChatMessage-userBubble_5z5yi_164", "ChatMessage-userAttachments": "_ChatMessage-userAttachments_5z5yi_175", "ChatMessage-thumbnail": "_ChatMessage-thumbnail_5z5yi_181", "ChatMessage-thumbnailLabel": "_ChatMessage-thumbnailLabel_5z5yi_211", "ChatMessage-text": "_ChatMessage-text_5z5yi_284", "ChatMessage-event": "_ChatMessage-event_5z5yi_319", "ChatMessage-eventBody": "_ChatMessage-eventBody_5z5yi_323", "ChatMessage-eventCollapse": "_ChatMessage-eventCollapse_5z5yi_332", "ChatMessage-eventHeader": "_ChatMessage-eventHeader_5z5yi_336", "ChatMessage-eventExpand": "_ChatMessage-eventExpand_5z5yi_336", "ChatMessage-eventIcon": "_ChatMessage-eventIcon_5z5yi_362", "ChatMessage-eventLabel": "_ChatMessage-eventLabel_5z5yi_366", "ChatMessage-attachmentImage": "_ChatMessage-attachmentImage_5z5yi_380", "ChatMessage-attachmentFile": "_ChatMessage-attachmentFile_5z5yi_397", "Chat-loader": "_Chat-loader_5z5yi_420", "Chat-loaderIcon": "_Chat-loaderIcon_5z5yi_430", "Chat-error": "_Chat-error_5z5yi_434", "Chat-errorLabel": "_Chat-errorLabel_5z5yi_443", "Chat-errorAction": "_Chat-errorAction_5z5yi_447", "Chat-userError": "_Chat-userError_5z5yi_451", "Chat-userErrorDismiss": "_Chat-userErrorDismiss_5z5yi_461" };
|
|
1765
|
-
|
|
1766
|
-
// src/components/PromptForm/index.tsx
|
|
1767
|
-
init_react_import();
|
|
1768
|
-
var import_react18 = require("react");
|
|
1769
|
-
|
|
1770
|
-
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/PromptForm/styles.module.css#css-module
|
|
1771
|
-
init_react_import();
|
|
1772
|
-
var styles_module_default8 = { "PromptForm": "_PromptForm_16e09_1", "PromptForm-dropOverlay": "_PromptForm-dropOverlay_16e09_9", "PromptForm-inner": "_PromptForm-inner_16e09_27", "PromptForm--dark": "_PromptForm--dark_16e09_33", "PromptForm--glow": "_PromptForm--glow_16e09_38", "PromptForm-glow": "_PromptForm-glow_16e09_38", "loop": "_loop_16e09_1", "PromptForm-formInner": "_PromptForm-formInner_16e09_79", "PromptForm-input": "_PromptForm-input_16e09_85", "PromptForm--disabled": "_PromptForm--disabled_16e09_122", "PromptForm-helper": "_PromptForm-helper_16e09_127", "PromptForm-actions": "_PromptForm-actions_16e09_137", "PromptForm-actionsLeft": "_PromptForm-actionsLeft_16e09_148", "PromptForm-actionsRight": "_PromptForm-actionsRight_16e09_157", "PromptForm-actionSubmit": "_PromptForm-actionSubmit_16e09_162", "PromptForm--userCta": "_PromptForm--userCta_16e09_179", "PromptForm--isDisabled": "_PromptForm--isDisabled_16e09_192", "PromptForm--isLoading": "_PromptForm--isLoading_16e09_197", "PromptForm-attachments": "_PromptForm-attachments_16e09_202", "PromptForm-attachmentChip": "_PromptForm-attachmentChip_16e09_210", "PromptForm-attachmentChipUploading": "_PromptForm-attachmentChipUploading_16e09_225", "PromptForm-attachmentChipFailed": "_PromptForm-attachmentChipFailed_16e09_229", "PromptForm-attachmentError": "_PromptForm-attachmentError_16e09_234", "PromptForm-attachmentSpinner": "_PromptForm-attachmentSpinner_16e09_239", "PromptForm-attachmentSpin": "_PromptForm-attachmentSpin_16e09_239", "PromptForm-attachmentRemove": "_PromptForm-attachmentRemove_16e09_243" };
|
|
1773
|
-
|
|
1774
|
-
// src/lib/attachments.ts
|
|
1775
|
-
init_react_import();
|
|
1776
|
-
var INTERNAL_MESSAGE_PREFIX = "[puck-internal";
|
|
1777
|
-
var defaultAttachmentAccept = [
|
|
1778
|
-
"image/*",
|
|
1779
|
-
".pdf",
|
|
1780
|
-
".doc",
|
|
1781
|
-
".docx",
|
|
1782
|
-
".txt",
|
|
1783
|
-
".md"
|
|
1784
|
-
];
|
|
1785
|
-
var defaultAttachmentConfig = {
|
|
1786
|
-
maxFiles: 5,
|
|
1787
|
-
maxSizeBytes: 10 * 1024 * 1024
|
|
1788
|
-
};
|
|
1789
|
-
var getExtension = (filename) => {
|
|
1790
|
-
const parts = filename.toLowerCase().split(".");
|
|
1791
|
-
if (parts.length < 2) {
|
|
1792
|
-
return null;
|
|
1793
|
-
}
|
|
1794
|
-
return `.${parts.pop()}`;
|
|
1795
|
-
};
|
|
1796
|
-
var matchesAccept = (file, accept) => {
|
|
1797
|
-
if (accept.length === 0) {
|
|
1798
|
-
return true;
|
|
1799
|
-
}
|
|
1800
|
-
const extension = getExtension(file.name);
|
|
1801
|
-
return accept.some((entry) => {
|
|
1802
|
-
if (entry.endsWith("/*")) {
|
|
1803
|
-
const prefix = entry.slice(0, -1);
|
|
1804
|
-
return file.type.startsWith(prefix);
|
|
1805
|
-
}
|
|
1806
|
-
if (entry.startsWith(".")) {
|
|
1807
|
-
return extension === entry.toLowerCase();
|
|
1808
|
-
}
|
|
1809
|
-
return file.type === entry;
|
|
1810
|
-
});
|
|
1811
|
-
};
|
|
1812
|
-
var documentExtensionByMediaType = {
|
|
1813
|
-
"application/msword": "doc",
|
|
1814
|
-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
1815
|
-
"text/markdown": "md",
|
|
1816
|
-
"application/pdf": "pdf",
|
|
1817
|
-
"text/plain": "txt"
|
|
1198
|
+
var documentExtensionByMediaType = {
|
|
1199
|
+
"application/msword": "doc",
|
|
1200
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
|
|
1201
|
+
"text/markdown": "md",
|
|
1202
|
+
"application/pdf": "pdf",
|
|
1203
|
+
"text/plain": "txt"
|
|
1818
1204
|
};
|
|
1819
1205
|
var mediaTypeToExtension = (mediaType) => {
|
|
1820
1206
|
const mapped = documentExtensionByMediaType[mediaType];
|
|
@@ -1881,14 +1267,13 @@ var truncateFilename = (name, max = 25) => {
|
|
|
1881
1267
|
};
|
|
1882
1268
|
|
|
1883
1269
|
// src/components/PromptForm/index.tsx
|
|
1884
|
-
var
|
|
1885
|
-
var
|
|
1270
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1271
|
+
var cx = getClassNameFactory("PromptForm", styles_module_default4);
|
|
1886
1272
|
function PromptForm({
|
|
1887
1273
|
actions,
|
|
1888
1274
|
attachments,
|
|
1889
1275
|
onFileDrop,
|
|
1890
1276
|
onRemoveAttachment,
|
|
1891
|
-
colorScheme = "light",
|
|
1892
1277
|
glow,
|
|
1893
1278
|
handleSubmit,
|
|
1894
1279
|
helperText,
|
|
@@ -1901,13 +1286,13 @@ function PromptForm({
|
|
|
1901
1286
|
maxRows = 5,
|
|
1902
1287
|
value = ""
|
|
1903
1288
|
}) {
|
|
1904
|
-
const hasSetInitialPrompt = (0,
|
|
1905
|
-
const [prompt, setPrompt] = (0,
|
|
1906
|
-
const internalRef = (0,
|
|
1907
|
-
const [isDragOver, setIsDragOver] = (0,
|
|
1908
|
-
const dragCounterRef = (0,
|
|
1289
|
+
const hasSetInitialPrompt = (0, import_react8.useRef)(false);
|
|
1290
|
+
const [prompt, setPrompt] = (0, import_react8.useState)(value);
|
|
1291
|
+
const internalRef = (0, import_react8.useRef)(null);
|
|
1292
|
+
const [isDragOver, setIsDragOver] = (0, import_react8.useState)(false);
|
|
1293
|
+
const dragCounterRef = (0, import_react8.useRef)(0);
|
|
1909
1294
|
const canDrop = !!onFileDrop && !isDisabled && !isLoading;
|
|
1910
|
-
const handleDragEnter = (0,
|
|
1295
|
+
const handleDragEnter = (0, import_react8.useCallback)(
|
|
1911
1296
|
(e) => {
|
|
1912
1297
|
e.preventDefault();
|
|
1913
1298
|
dragCounterRef.current++;
|
|
@@ -1917,17 +1302,17 @@ function PromptForm({
|
|
|
1917
1302
|
},
|
|
1918
1303
|
[canDrop]
|
|
1919
1304
|
);
|
|
1920
|
-
const handleDragLeave = (0,
|
|
1305
|
+
const handleDragLeave = (0, import_react8.useCallback)((e) => {
|
|
1921
1306
|
e.preventDefault();
|
|
1922
1307
|
dragCounterRef.current--;
|
|
1923
1308
|
if (dragCounterRef.current === 0) {
|
|
1924
1309
|
setIsDragOver(false);
|
|
1925
1310
|
}
|
|
1926
1311
|
}, []);
|
|
1927
|
-
const handleDragOver = (0,
|
|
1312
|
+
const handleDragOver = (0, import_react8.useCallback)((e) => {
|
|
1928
1313
|
e.preventDefault();
|
|
1929
1314
|
}, []);
|
|
1930
|
-
const handleDrop = (0,
|
|
1315
|
+
const handleDrop = (0, import_react8.useCallback)(
|
|
1931
1316
|
(e) => {
|
|
1932
1317
|
e.preventDefault();
|
|
1933
1318
|
dragCounterRef.current = 0;
|
|
@@ -1941,7 +1326,7 @@ function PromptForm({
|
|
|
1941
1326
|
},
|
|
1942
1327
|
[canDrop, onFileDrop]
|
|
1943
1328
|
);
|
|
1944
|
-
const handlePaste = (0,
|
|
1329
|
+
const handlePaste = (0, import_react8.useCallback)(
|
|
1945
1330
|
(e) => {
|
|
1946
1331
|
if (!canDrop) return;
|
|
1947
1332
|
const files = getFilesFromClipboard(e.clipboardData);
|
|
@@ -1951,7 +1336,7 @@ function PromptForm({
|
|
|
1951
1336
|
},
|
|
1952
1337
|
[canDrop, onFileDrop]
|
|
1953
1338
|
);
|
|
1954
|
-
(0,
|
|
1339
|
+
(0, import_react8.useEffect)(() => {
|
|
1955
1340
|
setPrompt(value);
|
|
1956
1341
|
}, [setPrompt, value]);
|
|
1957
1342
|
const sendPrompt = async () => {
|
|
@@ -1966,7 +1351,7 @@ function PromptForm({
|
|
|
1966
1351
|
setPrompt("");
|
|
1967
1352
|
}
|
|
1968
1353
|
};
|
|
1969
|
-
(0,
|
|
1354
|
+
(0, import_react8.useEffect)(() => {
|
|
1970
1355
|
const currentUrl = new URL(location.href);
|
|
1971
1356
|
const initialPrompt = currentUrl.searchParams.get("initialPrompt");
|
|
1972
1357
|
if (!hasSetInitialPrompt.current && initialPrompt && prompt === "") {
|
|
@@ -1974,13 +1359,12 @@ function PromptForm({
|
|
|
1974
1359
|
setPrompt(initialPrompt);
|
|
1975
1360
|
}
|
|
1976
1361
|
}, [setPrompt]);
|
|
1977
|
-
return /* @__PURE__ */ (0,
|
|
1362
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
1978
1363
|
"div",
|
|
1979
1364
|
{
|
|
1980
|
-
className:
|
|
1365
|
+
className: cx({
|
|
1981
1366
|
isDisabled,
|
|
1982
1367
|
isLoading,
|
|
1983
|
-
dark: colorScheme === "dark",
|
|
1984
1368
|
glow,
|
|
1985
1369
|
userCta: !!cta
|
|
1986
1370
|
}),
|
|
@@ -1989,56 +1373,56 @@ function PromptForm({
|
|
|
1989
1373
|
onDragOver: onFileDrop ? handleDragOver : void 0,
|
|
1990
1374
|
onDrop: onFileDrop ? handleDrop : void 0,
|
|
1991
1375
|
children: [
|
|
1992
|
-
isDragOver ? /* @__PURE__ */ (0,
|
|
1993
|
-
/* @__PURE__ */ (0,
|
|
1994
|
-
/* @__PURE__ */ (0,
|
|
1376
|
+
isDragOver ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: cx("dropOverlay"), children: [
|
|
1377
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Paperclip, { size: 20 }),
|
|
1378
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Attach file" })
|
|
1995
1379
|
] }) : null,
|
|
1996
|
-
helperText ? /* @__PURE__ */ (0,
|
|
1997
|
-
/* @__PURE__ */ (0,
|
|
1998
|
-
/* @__PURE__ */ (0,
|
|
1999
|
-
/* @__PURE__ */ (0,
|
|
1380
|
+
helperText ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: cx("helper"), children: helperText }) : null,
|
|
1381
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: cx("inner"), children: [
|
|
1382
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: cx("glow") }),
|
|
1383
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2000
1384
|
"form",
|
|
2001
1385
|
{
|
|
2002
1386
|
onSubmit: (e) => {
|
|
2003
1387
|
e.preventDefault();
|
|
2004
1388
|
void sendPrompt();
|
|
2005
1389
|
},
|
|
2006
|
-
children: /* @__PURE__ */ (0,
|
|
2007
|
-
attachments && attachments.length > 0 ? /* @__PURE__ */ (0,
|
|
1390
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: cx("formInner"), children: [
|
|
1391
|
+
attachments && attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: cx("attachments"), children: attachments.map((attachment) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2008
1392
|
"div",
|
|
2009
1393
|
{
|
|
2010
1394
|
className: [
|
|
2011
|
-
|
|
2012
|
-
attachment.status === "uploading" ?
|
|
2013
|
-
attachment.status === "failed" ?
|
|
1395
|
+
cx("attachmentChip"),
|
|
1396
|
+
attachment.status === "uploading" ? cx("attachmentChipUploading") : "",
|
|
1397
|
+
attachment.status === "failed" ? cx("attachmentChipFailed") : ""
|
|
2014
1398
|
].filter(Boolean).join(" "),
|
|
2015
1399
|
children: [
|
|
2016
|
-
attachment.status === "uploading" ? /* @__PURE__ */ (0,
|
|
1400
|
+
attachment.status === "uploading" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2017
1401
|
LoaderCircle,
|
|
2018
1402
|
{
|
|
2019
|
-
className:
|
|
1403
|
+
className: cx("attachmentSpinner"),
|
|
2020
1404
|
size: 14
|
|
2021
1405
|
}
|
|
2022
1406
|
) : null,
|
|
2023
|
-
/* @__PURE__ */ (0,
|
|
2024
|
-
attachment.status === "failed" ? /* @__PURE__ */ (0,
|
|
2025
|
-
onRemoveAttachment ? /* @__PURE__ */ (0,
|
|
1407
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { title: attachment.filename, children: truncateFilename(attachment.filename) }),
|
|
1408
|
+
attachment.status === "failed" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: cx("attachmentError"), children: "Failed" }) : null,
|
|
1409
|
+
onRemoveAttachment ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2026
1410
|
"button",
|
|
2027
1411
|
{
|
|
2028
|
-
className:
|
|
1412
|
+
className: cx("attachmentRemove"),
|
|
2029
1413
|
onClick: () => onRemoveAttachment(attachment.clientId),
|
|
2030
1414
|
type: "button",
|
|
2031
|
-
children: /* @__PURE__ */ (0,
|
|
1415
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(X, { size: 12 })
|
|
2032
1416
|
}
|
|
2033
1417
|
) : null
|
|
2034
1418
|
]
|
|
2035
1419
|
},
|
|
2036
1420
|
attachment.clientId
|
|
2037
1421
|
)) }) : null,
|
|
2038
|
-
/* @__PURE__ */ (0,
|
|
1422
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2039
1423
|
import_react_textarea_autosize.default,
|
|
2040
1424
|
{
|
|
2041
|
-
className:
|
|
1425
|
+
className: cx("input"),
|
|
2042
1426
|
name: "prompt",
|
|
2043
1427
|
minRows,
|
|
2044
1428
|
maxRows,
|
|
@@ -2066,34 +1450,34 @@ function PromptForm({
|
|
|
2066
1450
|
}
|
|
2067
1451
|
}
|
|
2068
1452
|
),
|
|
2069
|
-
/* @__PURE__ */ (0,
|
|
1453
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2070
1454
|
"div",
|
|
2071
1455
|
{
|
|
2072
|
-
className:
|
|
1456
|
+
className: cx("actions"),
|
|
2073
1457
|
onClick: () => {
|
|
2074
1458
|
internalRef?.current?.focus();
|
|
2075
1459
|
},
|
|
2076
1460
|
children: [
|
|
2077
|
-
/* @__PURE__ */ (0,
|
|
1461
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2078
1462
|
"div",
|
|
2079
1463
|
{
|
|
2080
|
-
className:
|
|
1464
|
+
className: cx("actionsLeft"),
|
|
2081
1465
|
onClick: (e) => e.stopPropagation(),
|
|
2082
1466
|
children: actions
|
|
2083
1467
|
}
|
|
2084
1468
|
),
|
|
2085
|
-
/* @__PURE__ */ (0,
|
|
1469
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2086
1470
|
"div",
|
|
2087
1471
|
{
|
|
2088
|
-
className:
|
|
1472
|
+
className: cx("actionsRight"),
|
|
2089
1473
|
onClick: (e) => e.stopPropagation(),
|
|
2090
|
-
children: /* @__PURE__ */ (0,
|
|
1474
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2091
1475
|
"button",
|
|
2092
1476
|
{
|
|
2093
|
-
className:
|
|
1477
|
+
className: cx("actionSubmit"),
|
|
2094
1478
|
type: "submit",
|
|
2095
1479
|
disabled: isLoading,
|
|
2096
|
-
children: isLoading ? /* @__PURE__ */ (0,
|
|
1480
|
+
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 18 }) : cta ?? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ArrowUp, { size: 24 })
|
|
2097
1481
|
}
|
|
2098
1482
|
)
|
|
2099
1483
|
}
|
|
@@ -2112,21 +1496,21 @@ function PromptForm({
|
|
|
2112
1496
|
|
|
2113
1497
|
// src/lib/context.ts
|
|
2114
1498
|
init_react_import();
|
|
2115
|
-
var
|
|
2116
|
-
var toolStatusContext = (0,
|
|
1499
|
+
var import_react9 = require("react");
|
|
1500
|
+
var toolStatusContext = (0, import_react9.createContext)({});
|
|
2117
1501
|
var ToolStatusProvider = toolStatusContext.Provider;
|
|
2118
|
-
var hostContext = (0,
|
|
1502
|
+
var hostContext = (0, import_react9.createContext)(void 0);
|
|
2119
1503
|
var HostProvider = hostContext.Provider;
|
|
2120
|
-
var subagentStateContext = (0,
|
|
1504
|
+
var subagentStateContext = (0, import_react9.createContext)({});
|
|
2121
1505
|
var SubagentStateProvider = subagentStateContext.Provider;
|
|
2122
1506
|
|
|
2123
1507
|
// src/lib/use-attachment-url.ts
|
|
2124
1508
|
init_react_import();
|
|
2125
|
-
var
|
|
1509
|
+
var import_react10 = require("react");
|
|
2126
1510
|
function useAttachmentUrl(url, endpoint) {
|
|
2127
1511
|
const isRef = getAttachmentIdFromRef(url) !== null;
|
|
2128
|
-
const [fetched, setFetched] = (0,
|
|
2129
|
-
(0,
|
|
1512
|
+
const [fetched, setFetched] = (0, import_react10.useState)();
|
|
1513
|
+
(0, import_react10.useEffect)(() => {
|
|
2130
1514
|
if (!isRef) return;
|
|
2131
1515
|
const controller = new AbortController();
|
|
2132
1516
|
const loadUrl = async () => {
|
|
@@ -2150,9 +1534,9 @@ function useAttachmentUrl(url, endpoint) {
|
|
|
2150
1534
|
}
|
|
2151
1535
|
|
|
2152
1536
|
// src/components/ChatBody/index.tsx
|
|
2153
|
-
var
|
|
2154
|
-
var
|
|
2155
|
-
var cxMessage =
|
|
1537
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1538
|
+
var cx2 = getClassNameFactory("Chat", styles_module_default3);
|
|
1539
|
+
var cxMessage = getClassNameFactory("ChatMessage", styles_module_default3);
|
|
2156
1540
|
function ChatBody({
|
|
2157
1541
|
actions,
|
|
2158
1542
|
attachments,
|
|
@@ -2175,45 +1559,45 @@ function ChatBody({
|
|
|
2175
1559
|
const lastMessage = hasMessages ? messages[messages.length - 1] : null;
|
|
2176
1560
|
const lastPart = lastMessage ? lastMessage.parts[lastMessage.parts.length - 1] : null;
|
|
2177
1561
|
const isLoading = status === "submitted" || status === "streaming" && !lastPart;
|
|
2178
|
-
return /* @__PURE__ */ (0,
|
|
1562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2179
1563
|
"div",
|
|
2180
1564
|
{
|
|
2181
|
-
className:
|
|
1565
|
+
className: cx2({
|
|
2182
1566
|
hasMessages,
|
|
2183
1567
|
hasChildren: !!children,
|
|
2184
1568
|
hideInput,
|
|
2185
1569
|
isLoading
|
|
2186
1570
|
}),
|
|
2187
1571
|
children: [
|
|
2188
|
-
children ? /* @__PURE__ */ (0,
|
|
2189
|
-
/* @__PURE__ */ (0,
|
|
2190
|
-
/* @__PURE__ */ (0,
|
|
2191
|
-
/* @__PURE__ */ (0,
|
|
2192
|
-
isLoading && /* @__PURE__ */ (0,
|
|
2193
|
-
/* @__PURE__ */ (0,
|
|
2194
|
-
/* @__PURE__ */ (0,
|
|
1572
|
+
children ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cx2("default"), children }) : null,
|
|
1573
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cx2("inner"), children: [
|
|
1574
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cx2("body"), ref: scrollRef, children: [
|
|
1575
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cx2("messages"), ref: contentRef, children: messages.toReversed().filter((message) => !shouldHideMessage(message)).map((message) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChatMessage, { message }, message.id)) }),
|
|
1576
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cx2("loader"), children: [
|
|
1577
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cx2("loaderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Loader, { size: 16 }) }),
|
|
1578
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: "Thinking..." })
|
|
2195
1579
|
] })
|
|
2196
1580
|
] }),
|
|
2197
|
-
error && /* @__PURE__ */ (0,
|
|
2198
|
-
/* @__PURE__ */ (0,
|
|
2199
|
-
handleRetry && /* @__PURE__ */ (0,
|
|
1581
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cx2("error"), children: [
|
|
1582
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cx2("errorLabel"), children: "Something went wrong." }),
|
|
1583
|
+
handleRetry && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cx2("errorAction"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconButton, { title: "Retry", onClick: handleRetry, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RotateCcw, { size: "14" }) }) })
|
|
2200
1584
|
] }),
|
|
2201
|
-
userError && /* @__PURE__ */ (0,
|
|
2202
|
-
/* @__PURE__ */ (0,
|
|
2203
|
-
onDismissUserError && /* @__PURE__ */ (0,
|
|
1585
|
+
userError && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cx2("userError"), children: [
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: userError }),
|
|
1587
|
+
onDismissUserError && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2204
1588
|
"button",
|
|
2205
1589
|
{
|
|
2206
1590
|
"aria-label": "Dismiss",
|
|
2207
1591
|
title: "Dismiss",
|
|
2208
|
-
className:
|
|
1592
|
+
className: cx2("userErrorDismiss"),
|
|
2209
1593
|
onClick: onDismissUserError,
|
|
2210
1594
|
type: "button",
|
|
2211
|
-
children: /* @__PURE__ */ (0,
|
|
1595
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(X, { size: 14 })
|
|
2212
1596
|
}
|
|
2213
1597
|
)
|
|
2214
1598
|
] }),
|
|
2215
|
-
/* @__PURE__ */ (0,
|
|
2216
|
-
/* @__PURE__ */ (0,
|
|
1599
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cx2("form"), children: [
|
|
1600
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2217
1601
|
PromptForm,
|
|
2218
1602
|
{
|
|
2219
1603
|
actions,
|
|
@@ -2227,7 +1611,7 @@ function ChatBody({
|
|
|
2227
1611
|
placeholder: "What do you want to build?"
|
|
2228
1612
|
}
|
|
2229
1613
|
),
|
|
2230
|
-
examplePrompts ? /* @__PURE__ */ (0,
|
|
1614
|
+
examplePrompts ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cx2("examplePrompts"), children: examplePrompts }) : null
|
|
2231
1615
|
] })
|
|
2232
1616
|
] })
|
|
2233
1617
|
]
|
|
@@ -2252,17 +1636,17 @@ function mergeReasoningParts(parts) {
|
|
|
2252
1636
|
}
|
|
2253
1637
|
function ChatMessage({ message }) {
|
|
2254
1638
|
const { role, parts: rawParts } = message;
|
|
2255
|
-
const parts = (0,
|
|
1639
|
+
const parts = (0, import_react11.useMemo)(() => mergeReasoningParts(rawParts), [rawParts]);
|
|
2256
1640
|
if (role === "user") {
|
|
2257
1641
|
const attachmentParts = parts.filter((part) => part.type === "file");
|
|
2258
1642
|
const otherParts = parts.filter((part) => part.type !== "file");
|
|
2259
|
-
return /* @__PURE__ */ (0,
|
|
1643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2260
1644
|
"div",
|
|
2261
1645
|
{
|
|
2262
1646
|
className: cxMessage({ userRole: true }),
|
|
2263
1647
|
"data-message-id": message.id,
|
|
2264
|
-
children: /* @__PURE__ */ (0,
|
|
2265
|
-
otherParts.map((part, i) => /* @__PURE__ */ (0,
|
|
1648
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: cxMessage("userBubble"), children: [
|
|
1649
|
+
otherParts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2266
1650
|
ChatMessagePart,
|
|
2267
1651
|
{
|
|
2268
1652
|
part,
|
|
@@ -2270,7 +1654,7 @@ function ChatMessage({ message }) {
|
|
|
2270
1654
|
},
|
|
2271
1655
|
`${message.id}-${part.type}-${i}`
|
|
2272
1656
|
)),
|
|
2273
|
-
attachmentParts.length > 0 ? /* @__PURE__ */ (0,
|
|
1657
|
+
attachmentParts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("userAttachments"), children: attachmentParts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2274
1658
|
ChatAttachmentThumbnail,
|
|
2275
1659
|
{
|
|
2276
1660
|
filename: part.filename,
|
|
@@ -2283,12 +1667,12 @@ function ChatMessage({ message }) {
|
|
|
2283
1667
|
}
|
|
2284
1668
|
);
|
|
2285
1669
|
}
|
|
2286
|
-
return /* @__PURE__ */ (0,
|
|
1670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2287
1671
|
"div",
|
|
2288
1672
|
{
|
|
2289
1673
|
className: cxMessage({ [`${role}Role`]: true }),
|
|
2290
1674
|
"data-message-id": message.id,
|
|
2291
|
-
children: parts.map((part, i) => /* @__PURE__ */ (0,
|
|
1675
|
+
children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2292
1676
|
ChatMessagePart,
|
|
2293
1677
|
{
|
|
2294
1678
|
part,
|
|
@@ -2304,13 +1688,13 @@ function ChatAttachmentThumbnail({
|
|
|
2304
1688
|
mediaType,
|
|
2305
1689
|
url
|
|
2306
1690
|
}) {
|
|
2307
|
-
const host = (0,
|
|
1691
|
+
const host = (0, import_react11.useContext)(hostContext);
|
|
2308
1692
|
const endpoint = host ? `${host.replace(/\/$/, "")}/attachments` : "/api/puck/chat/attachments";
|
|
2309
1693
|
const resolvedUrl = useAttachmentUrl(url, endpoint);
|
|
2310
1694
|
const attachmentId = getAttachmentIdFromRef(url);
|
|
2311
1695
|
const label = filename || attachmentId || "Attachment";
|
|
2312
1696
|
const isImage = mediaType.startsWith("image/");
|
|
2313
|
-
return /* @__PURE__ */ (0,
|
|
1697
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2314
1698
|
"a",
|
|
2315
1699
|
{
|
|
2316
1700
|
"aria-label": label,
|
|
@@ -2320,8 +1704,8 @@ function ChatAttachmentThumbnail({
|
|
|
2320
1704
|
target: "_blank",
|
|
2321
1705
|
title: label,
|
|
2322
1706
|
children: [
|
|
2323
|
-
isImage ? resolvedUrl && /* @__PURE__ */ (0,
|
|
2324
|
-
/* @__PURE__ */ (0,
|
|
1707
|
+
isImage ? resolvedUrl && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { alt: label, src: resolvedUrl }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FileText, { size: 20 }),
|
|
1708
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: cxMessage("thumbnailLabel"), children: label })
|
|
2325
1709
|
]
|
|
2326
1710
|
}
|
|
2327
1711
|
);
|
|
@@ -2336,24 +1720,24 @@ function ChatMessageWrapper({
|
|
|
2336
1720
|
role
|
|
2337
1721
|
}) {
|
|
2338
1722
|
if (role === "assistant" || role === "user") {
|
|
2339
|
-
return /* @__PURE__ */ (0,
|
|
1723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_markdown.default, { children });
|
|
2340
1724
|
}
|
|
2341
|
-
return /* @__PURE__ */ (0,
|
|
1725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children });
|
|
2342
1726
|
}
|
|
2343
1727
|
function ReasoningBlock({ part }) {
|
|
2344
|
-
const startTimeRef = (0,
|
|
2345
|
-
const [durationSecs, setDurationSecs] = (0,
|
|
1728
|
+
const startTimeRef = (0, import_react11.useRef)(null);
|
|
1729
|
+
const [durationSecs, setDurationSecs] = (0, import_react11.useState)(null);
|
|
2346
1730
|
if (part.state !== "done" && startTimeRef.current === null) {
|
|
2347
1731
|
startTimeRef.current = Date.now();
|
|
2348
1732
|
}
|
|
2349
|
-
(0,
|
|
1733
|
+
(0, import_react11.useEffect)(() => {
|
|
2350
1734
|
if (part.state === "done" && startTimeRef.current !== null) {
|
|
2351
1735
|
setDurationSecs(Math.round((Date.now() - startTimeRef.current) / 1e3));
|
|
2352
1736
|
}
|
|
2353
1737
|
}, [part.state]);
|
|
2354
1738
|
const loading = part.state ? part.state !== "done" : false;
|
|
2355
1739
|
const label = durationSecs !== null ? `Thought for ${durationSecs}s` : !loading ? "Thought for a while" : "Thinking...";
|
|
2356
|
-
return /* @__PURE__ */ (0,
|
|
1740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2357
1741
|
ChatEvent,
|
|
2358
1742
|
{
|
|
2359
1743
|
status: {
|
|
@@ -2361,7 +1745,7 @@ function ReasoningBlock({ part }) {
|
|
|
2361
1745
|
loading,
|
|
2362
1746
|
summary: part.text
|
|
2363
1747
|
},
|
|
2364
|
-
icon: /* @__PURE__ */ (0,
|
|
1748
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Brain, { size: 18 })
|
|
2365
1749
|
}
|
|
2366
1750
|
);
|
|
2367
1751
|
}
|
|
@@ -2370,19 +1754,19 @@ function ChatMessagePart({
|
|
|
2370
1754
|
role
|
|
2371
1755
|
}) {
|
|
2372
1756
|
if (part.type === "text") {
|
|
2373
|
-
return /* @__PURE__ */ (0,
|
|
1757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("text"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChatMessageWrapper, { role, children: part.text }) });
|
|
2374
1758
|
}
|
|
2375
1759
|
if (part.type === "reasoning") {
|
|
2376
|
-
return /* @__PURE__ */ (0,
|
|
1760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ReasoningBlock, { part });
|
|
2377
1761
|
}
|
|
2378
1762
|
if (part.type === "tool-subagent") {
|
|
2379
|
-
return /* @__PURE__ */ (0,
|
|
1763
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SubagentBlock, { toolCallId: part.toolCallId });
|
|
2380
1764
|
}
|
|
2381
1765
|
if (part.type.startsWith("tool-")) {
|
|
2382
|
-
return /* @__PURE__ */ (0,
|
|
1766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PuckTool, { ...part });
|
|
2383
1767
|
}
|
|
2384
1768
|
if (part.type === "file") {
|
|
2385
|
-
return /* @__PURE__ */ (0,
|
|
1769
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2386
1770
|
ChatAttachment,
|
|
2387
1771
|
{
|
|
2388
1772
|
filename: part.filename,
|
|
@@ -2398,17 +1782,17 @@ function ChatAttachment({
|
|
|
2398
1782
|
mediaType,
|
|
2399
1783
|
url
|
|
2400
1784
|
}) {
|
|
2401
|
-
const host = (0,
|
|
1785
|
+
const host = (0, import_react11.useContext)(hostContext);
|
|
2402
1786
|
const endpoint = host ? `${host.replace(/\/$/, "")}/attachments` : "/api/puck/chat/attachments";
|
|
2403
1787
|
const resolvedUrl = useAttachmentUrl(url, endpoint);
|
|
2404
1788
|
const attachmentId = getAttachmentIdFromRef(url);
|
|
2405
1789
|
const label = filename || attachmentId || "Attachment";
|
|
2406
1790
|
if (mediaType.startsWith("image/")) {
|
|
2407
|
-
return /* @__PURE__ */ (0,
|
|
1791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("attachmentImage"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: resolvedUrl, target: "_blank", rel: "noreferrer", children: resolvedUrl && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("img", { alt: label, src: resolvedUrl }) }) });
|
|
2408
1792
|
}
|
|
2409
|
-
return /* @__PURE__ */ (0,
|
|
2410
|
-
/* @__PURE__ */ (0,
|
|
2411
|
-
/* @__PURE__ */ (0,
|
|
1793
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("attachmentFile"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("a", { href: resolvedUrl, target: "_blank", rel: "noreferrer", children: [
|
|
1794
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FileText, { size: 16 }),
|
|
1795
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: label })
|
|
2412
1796
|
] }) });
|
|
2413
1797
|
}
|
|
2414
1798
|
function PuckTool({
|
|
@@ -2417,68 +1801,67 @@ function PuckTool({
|
|
|
2417
1801
|
defaultLabel = "Thinking...",
|
|
2418
1802
|
type
|
|
2419
1803
|
}) {
|
|
2420
|
-
const toolStatus = (0,
|
|
1804
|
+
const toolStatus = (0, import_react11.useContext)(toolStatusContext)[toolCallId];
|
|
2421
1805
|
const outputObj = output;
|
|
2422
1806
|
const status = outputObj && "status" in outputObj ? outputObj.status : toolStatus ?? { loading: true, label: defaultLabel };
|
|
2423
|
-
let icon = (0,
|
|
1807
|
+
let icon = (0, import_react11.useMemo)(() => {
|
|
2424
1808
|
if (type === "tool-write") {
|
|
2425
|
-
return /* @__PURE__ */ (0,
|
|
1809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Pen, { size: 18 });
|
|
2426
1810
|
} else if (type === "tool-refreshPageData") {
|
|
2427
|
-
return /* @__PURE__ */ (0,
|
|
1811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GitPullRequest, { size: 18 });
|
|
2428
1812
|
} else if (type === "tool-takeScreenshot") {
|
|
2429
|
-
return /* @__PURE__ */ (0,
|
|
1813
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Camera, { size: 18 });
|
|
2430
1814
|
} else if (type === "tool-fetchUrl") {
|
|
2431
|
-
return /* @__PURE__ */ (0,
|
|
1815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CloudDownload, { size: 18 });
|
|
2432
1816
|
} else if (type === "tool-screenshotUrl") {
|
|
2433
|
-
return /* @__PURE__ */ (0,
|
|
1817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Camera, { size: 18 });
|
|
2434
1818
|
}
|
|
2435
|
-
return /* @__PURE__ */ (0,
|
|
1819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Check, { size: 18 });
|
|
2436
1820
|
}, [type]);
|
|
2437
|
-
return /* @__PURE__ */ (0,
|
|
1821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChatEvent, { status, icon });
|
|
2438
1822
|
}
|
|
2439
1823
|
function SubagentBlock({ toolCallId }) {
|
|
2440
|
-
const subagentState = (0,
|
|
1824
|
+
const subagentState = (0, import_react11.useContext)(subagentStateContext);
|
|
2441
1825
|
const state = subagentState[toolCallId];
|
|
2442
|
-
const toolStatusMap = (0,
|
|
1826
|
+
const toolStatusMap = (0, import_react11.useContext)(toolStatusContext);
|
|
2443
1827
|
const toolStatus = toolStatusMap[toolCallId];
|
|
2444
1828
|
const fallbackLabel = toolStatus?.label ?? "Running subagent";
|
|
2445
1829
|
const label = state?.label ? state.state === "done" ? `${state.agentType} subagent complete` : state.label : fallbackLabel;
|
|
2446
1830
|
const loading = state ? state.state !== "done" : toolStatus?.loading ?? true;
|
|
2447
1831
|
const hasBody = !!state && state.parts.length > 0;
|
|
2448
1832
|
const parts = state?.parts ?? [];
|
|
2449
|
-
const [isOpen, setIsOpen] = (0,
|
|
2450
|
-
return /* @__PURE__ */ (0,
|
|
1833
|
+
const [isOpen, setIsOpen] = (0, import_react11.useState)(false);
|
|
1834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2451
1835
|
"details",
|
|
2452
1836
|
{
|
|
2453
1837
|
className: cxMessage("event"),
|
|
2454
1838
|
onToggle: (e) => setIsOpen(e.currentTarget.open),
|
|
2455
1839
|
children: [
|
|
2456
|
-
/* @__PURE__ */ (0,
|
|
1840
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2457
1841
|
"summary",
|
|
2458
1842
|
{
|
|
2459
|
-
className: cxMessage("eventHeader")
|
|
2460
|
-
style: hasBody ? {} : { color: "var(--puck-color-grey-05) !important", cursor: "unset" },
|
|
1843
|
+
className: `${cxMessage("eventHeader")} ${hasBody ? "" : cxMessage("eventHeader--static")}`,
|
|
2461
1844
|
children: [
|
|
2462
|
-
/* @__PURE__ */ (0,
|
|
2463
|
-
/* @__PURE__ */ (0,
|
|
2464
|
-
hasBody && /* @__PURE__ */ (0,
|
|
2465
|
-
/* @__PURE__ */ (0,
|
|
2466
|
-
/* @__PURE__ */ (0,
|
|
1845
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventIcon"), children: loading ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Loader, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Bot, { size: 18 }) }),
|
|
1846
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventLabel"), children: label }),
|
|
1847
|
+
hasBody && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1848
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventExpand"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Plus, { size: 12 }) }),
|
|
1849
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventCollapse"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Minus, { size: 12 }) })
|
|
2467
1850
|
] })
|
|
2468
1851
|
]
|
|
2469
1852
|
}
|
|
2470
1853
|
),
|
|
2471
|
-
hasBody && isOpen && /* @__PURE__ */ (0,
|
|
1854
|
+
hasBody && isOpen && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventBody"), children: parts.map((part, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SubagentChildPartRenderer, { part }, `${toolCallId}-${i}`)) })
|
|
2472
1855
|
]
|
|
2473
1856
|
}
|
|
2474
1857
|
);
|
|
2475
1858
|
}
|
|
2476
1859
|
function SubagentChildPartRenderer({ part }) {
|
|
2477
1860
|
if (part.kind === "text") {
|
|
2478
|
-
return /* @__PURE__ */ (0,
|
|
1861
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("text"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_markdown.default, { children: part.text }) });
|
|
2479
1862
|
}
|
|
2480
1863
|
if (part.kind === "reasoning") {
|
|
2481
|
-
return /* @__PURE__ */ (0,
|
|
1864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2482
1865
|
ReasoningBlock,
|
|
2483
1866
|
{
|
|
2484
1867
|
part: {
|
|
@@ -2490,7 +1873,7 @@ function SubagentChildPartRenderer({ part }) {
|
|
|
2490
1873
|
);
|
|
2491
1874
|
}
|
|
2492
1875
|
if (part.toolName === "subagent") {
|
|
2493
|
-
return /* @__PURE__ */ (0,
|
|
1876
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SubagentBlock, { toolCallId: part.childToolCallId });
|
|
2494
1877
|
}
|
|
2495
1878
|
const synthesized = {
|
|
2496
1879
|
toolCallId: part.childToolCallId,
|
|
@@ -2499,35 +1882,34 @@ function SubagentChildPartRenderer({ part }) {
|
|
|
2499
1882
|
input: part.input,
|
|
2500
1883
|
output: part.output
|
|
2501
1884
|
};
|
|
2502
|
-
return /* @__PURE__ */ (0,
|
|
1885
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PuckTool, { ...synthesized });
|
|
2503
1886
|
}
|
|
2504
1887
|
function ChatEvent({
|
|
2505
1888
|
status,
|
|
2506
|
-
icon = /* @__PURE__ */ (0,
|
|
1889
|
+
icon = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Check, { size: 18 })
|
|
2507
1890
|
}) {
|
|
2508
|
-
const [isOpen, setIsOpen] = (0,
|
|
2509
|
-
return /* @__PURE__ */ (0,
|
|
1891
|
+
const [isOpen, setIsOpen] = (0, import_react11.useState)(false);
|
|
1892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2510
1893
|
"details",
|
|
2511
1894
|
{
|
|
2512
1895
|
className: cxMessage("event"),
|
|
2513
1896
|
onToggle: (e) => setIsOpen(e.currentTarget.open),
|
|
2514
1897
|
children: [
|
|
2515
|
-
/* @__PURE__ */ (0,
|
|
1898
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
2516
1899
|
"summary",
|
|
2517
1900
|
{
|
|
2518
|
-
className: cxMessage("eventHeader")
|
|
2519
|
-
style: status.summary ? {} : { color: "var(--puck-color-grey-05) !important", cursor: "unset" },
|
|
1901
|
+
className: `${cxMessage("eventHeader")} ${status.summary ? "" : cxMessage("eventHeader--static")}`,
|
|
2520
1902
|
children: [
|
|
2521
|
-
/* @__PURE__ */ (0,
|
|
2522
|
-
/* @__PURE__ */ (0,
|
|
2523
|
-
status.summary && /* @__PURE__ */ (0,
|
|
2524
|
-
/* @__PURE__ */ (0,
|
|
2525
|
-
/* @__PURE__ */ (0,
|
|
1903
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventIcon"), children: status.error ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TriangleAlert, { size: 18 }) : status.loading ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Loader, { size: 16 }) : icon }),
|
|
1904
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: status.label }),
|
|
1905
|
+
status.summary && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1906
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventExpand"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Plus, { size: 12 }) }),
|
|
1907
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventCollapse"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Minus, { size: 12 }) })
|
|
2526
1908
|
] })
|
|
2527
1909
|
]
|
|
2528
1910
|
}
|
|
2529
1911
|
),
|
|
2530
|
-
status.summary && isOpen && /* @__PURE__ */ (0,
|
|
1912
|
+
status.summary && isOpen && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cxMessage("eventBody"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_markdown.default, { children: status.summary }) })
|
|
2531
1913
|
]
|
|
2532
1914
|
}
|
|
2533
1915
|
);
|
|
@@ -2538,15 +1920,15 @@ function ExamplePrompt({
|
|
|
2538
1920
|
onClick,
|
|
2539
1921
|
disabled
|
|
2540
1922
|
}) {
|
|
2541
|
-
const content = /* @__PURE__ */ (0,
|
|
2542
|
-
/* @__PURE__ */ (0,
|
|
2543
|
-
/* @__PURE__ */ (0,
|
|
1923
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1924
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: label }),
|
|
1925
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: cx2("examplePromptArrow"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ArrowUp, { size: "16" }) })
|
|
2544
1926
|
] });
|
|
2545
1927
|
if (href) {
|
|
2546
|
-
return /* @__PURE__ */ (0,
|
|
1928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2547
1929
|
"a",
|
|
2548
1930
|
{
|
|
2549
|
-
className:
|
|
1931
|
+
className: cx2("examplePrompt"),
|
|
2550
1932
|
href: disabled ? void 0 : href,
|
|
2551
1933
|
"aria-disabled": disabled || void 0,
|
|
2552
1934
|
onClick: (e) => {
|
|
@@ -2560,10 +1942,10 @@ function ExamplePrompt({
|
|
|
2560
1942
|
}
|
|
2561
1943
|
);
|
|
2562
1944
|
}
|
|
2563
|
-
return /* @__PURE__ */ (0,
|
|
1945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2564
1946
|
"button",
|
|
2565
1947
|
{
|
|
2566
|
-
className:
|
|
1948
|
+
className: cx2("examplePrompt"),
|
|
2567
1949
|
type: "button",
|
|
2568
1950
|
disabled,
|
|
2569
1951
|
onClick,
|
|
@@ -2597,26 +1979,26 @@ init_react_import();
|
|
|
2597
1979
|
|
|
2598
1980
|
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/DesignModeToggle/styles.module.css#css-module
|
|
2599
1981
|
init_react_import();
|
|
2600
|
-
var
|
|
1982
|
+
var styles_module_default5 = { "DesignModeToggle": "_DesignModeToggle_vng7q_1", "DesignModeToggle-button": "_DesignModeToggle-button_vng7q_8", "DesignModeToggle-button--active": "_DesignModeToggle-button--active_vng7q_32" };
|
|
2601
1983
|
|
|
2602
1984
|
// src/components/DesignModeToggle/index.tsx
|
|
2603
|
-
var
|
|
2604
|
-
var
|
|
1985
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1986
|
+
var cx3 = getClassNameFactory("DesignModeToggle", styles_module_default5);
|
|
2605
1987
|
function DesignModeToggle({
|
|
2606
1988
|
active,
|
|
2607
1989
|
onToggle,
|
|
2608
1990
|
disabled
|
|
2609
1991
|
}) {
|
|
2610
|
-
return /* @__PURE__ */ (0,
|
|
1992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: cx3(), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2611
1993
|
"button",
|
|
2612
1994
|
{
|
|
2613
|
-
className: `${
|
|
1995
|
+
className: `${cx3("button")} ${active ? cx3("button--active") : ""}`,
|
|
2614
1996
|
onClick: onToggle,
|
|
2615
1997
|
disabled,
|
|
2616
1998
|
type: "button",
|
|
2617
1999
|
title: active ? "Disable design mode" : "Enable design mode",
|
|
2618
2000
|
children: [
|
|
2619
|
-
/* @__PURE__ */ (0,
|
|
2001
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(WandSparkles, { size: 12 }),
|
|
2620
2002
|
"Design"
|
|
2621
2003
|
]
|
|
2622
2004
|
}
|
|
@@ -2625,12 +2007,12 @@ function DesignModeToggle({
|
|
|
2625
2007
|
|
|
2626
2008
|
// src/lib/design/runtime.tsx
|
|
2627
2009
|
init_react_import();
|
|
2628
|
-
var
|
|
2010
|
+
var import_core3 = require("@puckeditor/core");
|
|
2629
2011
|
|
|
2630
2012
|
// src/lib/design/component.tsx
|
|
2631
2013
|
init_react_import();
|
|
2632
|
-
var
|
|
2633
|
-
var
|
|
2014
|
+
var import_core2 = require("@puckeditor/core");
|
|
2015
|
+
var import_react14 = require("react");
|
|
2634
2016
|
|
|
2635
2017
|
// src/lib/morph-html.ts
|
|
2636
2018
|
init_react_import();
|
|
@@ -3492,7 +2874,7 @@ var registrationStore = new RegistrationStore();
|
|
|
3492
2874
|
|
|
3493
2875
|
// src/lib/design/inline-editing.ts
|
|
3494
2876
|
init_react_import();
|
|
3495
|
-
var
|
|
2877
|
+
var import_core = require("@puckeditor/core");
|
|
3496
2878
|
var CONTENT_EDITABLE_ATTR = "data-puck-content-editable";
|
|
3497
2879
|
var isInlineEditingDisabled = (el) => el.closest(`[${CONTENT_EDITABLE_ATTR}="false"]`) !== null;
|
|
3498
2880
|
var cssEscape = (value) => typeof CSS !== "undefined" && CSS.escape ? CSS.escape(value) : value.replace(/["\\]/g, "\\$&");
|
|
@@ -3573,7 +2955,7 @@ var attachInlineEditing = (el, {
|
|
|
3573
2955
|
mode,
|
|
3574
2956
|
getPuck
|
|
3575
2957
|
}) => {
|
|
3576
|
-
const cleanupPortal = (0,
|
|
2958
|
+
const cleanupPortal = (0, import_core.registerOverlayPortal)(el);
|
|
3577
2959
|
let hovering = false;
|
|
3578
2960
|
let focused = false;
|
|
3579
2961
|
const syncEditable = () => {
|
|
@@ -3598,7 +2980,7 @@ var attachInlineEditing = (el, {
|
|
|
3598
2980
|
type: "replace",
|
|
3599
2981
|
destinationIndex: selector.index,
|
|
3600
2982
|
destinationZone: selector.zone,
|
|
3601
|
-
data: { ...item, props: (0,
|
|
2983
|
+
data: { ...item, props: (0, import_core.setDeep)(item.props, propPath, nextValue) }
|
|
3602
2984
|
});
|
|
3603
2985
|
resolveDataById(componentId, "replace");
|
|
3604
2986
|
};
|
|
@@ -3743,7 +3125,7 @@ var wireArrayItemEditing = ({
|
|
|
3743
3125
|
// src/lib/design/render-html.tsx
|
|
3744
3126
|
init_react_import();
|
|
3745
3127
|
var import_htmlparser22 = require("htmlparser2");
|
|
3746
|
-
var
|
|
3128
|
+
var import_react12 = require("react");
|
|
3747
3129
|
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
3748
3130
|
"area",
|
|
3749
3131
|
"base",
|
|
@@ -3806,7 +3188,7 @@ var nodeToReact = (node, slots, key) => {
|
|
|
3806
3188
|
if (isEventHandlerAttr2(name)) continue;
|
|
3807
3189
|
props2[REACT_PROP_NAMES[name] || name] = value;
|
|
3808
3190
|
}
|
|
3809
|
-
return (0,
|
|
3191
|
+
return (0, import_react12.createElement)(tag, props2, slots[slotName]);
|
|
3810
3192
|
}
|
|
3811
3193
|
const props = { key };
|
|
3812
3194
|
for (const [name, value] of Object.entries(attribs)) {
|
|
@@ -3818,10 +3200,10 @@ var nodeToReact = (node, slots, key) => {
|
|
|
3818
3200
|
}
|
|
3819
3201
|
}
|
|
3820
3202
|
if (VOID_ELEMENTS.has(tag)) {
|
|
3821
|
-
return (0,
|
|
3203
|
+
return (0, import_react12.createElement)(tag, props);
|
|
3822
3204
|
}
|
|
3823
3205
|
const children = el.children.map((child, i) => nodeToReact(child, slots, i)).filter((c) => c !== null);
|
|
3824
|
-
return (0,
|
|
3206
|
+
return (0, import_react12.createElement)(tag, props, ...children);
|
|
3825
3207
|
};
|
|
3826
3208
|
var htmlToReactTree = (html, slots) => {
|
|
3827
3209
|
if (!html) return null;
|
|
@@ -3829,14 +3211,14 @@ var htmlToReactTree = (html, slots) => {
|
|
|
3829
3211
|
const children = doc.children.map((child, i) => nodeToReact(child, slots, i)).filter((c) => c !== null);
|
|
3830
3212
|
if (children.length === 0) return null;
|
|
3831
3213
|
if (children.length === 1) return children[0];
|
|
3832
|
-
return (0,
|
|
3214
|
+
return (0, import_react12.createElement)(import_react12.Fragment, null, ...children);
|
|
3833
3215
|
};
|
|
3834
3216
|
|
|
3835
3217
|
// src/lib/design/slot-portal.tsx
|
|
3836
3218
|
init_react_import();
|
|
3837
|
-
var
|
|
3219
|
+
var import_react13 = require("react");
|
|
3838
3220
|
var import_react_dom = require("react-dom");
|
|
3839
|
-
var
|
|
3221
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
3840
3222
|
var parseInlineStyle = (cssText) => {
|
|
3841
3223
|
const style = {};
|
|
3842
3224
|
for (const declaration of cssText.split(";")) {
|
|
@@ -3858,13 +3240,13 @@ var SlotPortal = ({
|
|
|
3858
3240
|
slotClassName,
|
|
3859
3241
|
SlotContent
|
|
3860
3242
|
}) => {
|
|
3861
|
-
const [target, setTarget] = (0,
|
|
3862
|
-
const lastTarget = (0,
|
|
3863
|
-
const style = (0,
|
|
3243
|
+
const [target, setTarget] = (0, import_react13.useState)(null);
|
|
3244
|
+
const lastTarget = (0, import_react13.useRef)(null);
|
|
3245
|
+
const style = (0, import_react13.useMemo)(
|
|
3864
3246
|
() => slotStyle ? parseInlineStyle(slotStyle) : void 0,
|
|
3865
3247
|
[slotStyle]
|
|
3866
3248
|
);
|
|
3867
|
-
(0,
|
|
3249
|
+
(0, import_react13.useEffect)(() => {
|
|
3868
3250
|
const el = entry.querySelector(`[data-puck-slot="${cssEscape(slotName)}"]`);
|
|
3869
3251
|
if (el !== lastTarget.current) {
|
|
3870
3252
|
el?.replaceChildren();
|
|
@@ -3878,13 +3260,13 @@ var SlotPortal = ({
|
|
|
3878
3260
|
}, [entry, html, slotName]);
|
|
3879
3261
|
if (!target || typeof SlotContent !== "function") return null;
|
|
3880
3262
|
return (0, import_react_dom.createPortal)(
|
|
3881
|
-
/* @__PURE__ */ (0,
|
|
3263
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SlotContent, { style, className: slotClassName || void 0 }),
|
|
3882
3264
|
target
|
|
3883
3265
|
);
|
|
3884
3266
|
};
|
|
3885
3267
|
|
|
3886
3268
|
// src/lib/design/component.tsx
|
|
3887
|
-
var
|
|
3269
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3888
3270
|
var DESIGN_COMPONENT = Symbol("puck-ai.designComponent");
|
|
3889
3271
|
var isDesignComponent = (config) => !!config?.[DESIGN_COMPONENT];
|
|
3890
3272
|
var streamingValues = /* @__PURE__ */ new Map();
|
|
@@ -3970,13 +3352,13 @@ function createDesignComponentConfig(registration) {
|
|
|
3970
3352
|
}
|
|
3971
3353
|
return resolvedFields;
|
|
3972
3354
|
},
|
|
3973
|
-
render: (renderProps) => renderProps.puck?.isEditing ? /* @__PURE__ */ (0,
|
|
3355
|
+
render: (renderProps) => renderProps.puck?.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditorEntry, { ...renderProps }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Entry, { ...renderProps, getPuck: null })
|
|
3974
3356
|
};
|
|
3975
3357
|
componentConfig[DESIGN_COMPONENT] = true;
|
|
3976
3358
|
return componentConfig;
|
|
3977
3359
|
function EditorEntry(renderProps) {
|
|
3978
|
-
const getPuck = (0,
|
|
3979
|
-
return /* @__PURE__ */ (0,
|
|
3360
|
+
const getPuck = (0, import_core2.useGetPuck)();
|
|
3361
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Entry, { ...renderProps, getPuck });
|
|
3980
3362
|
}
|
|
3981
3363
|
function Entry({
|
|
3982
3364
|
getPuck,
|
|
@@ -3985,11 +3367,11 @@ function createDesignComponentConfig(registration) {
|
|
|
3985
3367
|
style,
|
|
3986
3368
|
...props
|
|
3987
3369
|
}) {
|
|
3988
|
-
const getSnapshot = (0,
|
|
3370
|
+
const getSnapshot = (0, import_react14.useCallback)(
|
|
3989
3371
|
() => registrationStore.get(name) ?? registration,
|
|
3990
3372
|
[]
|
|
3991
3373
|
);
|
|
3992
|
-
const reg = (0,
|
|
3374
|
+
const reg = (0, import_react14.useSyncExternalStore)(
|
|
3993
3375
|
registrationStore.subscribe,
|
|
3994
3376
|
getSnapshot,
|
|
3995
3377
|
getSnapshot
|
|
@@ -3997,10 +3379,10 @@ function createDesignComponentConfig(registration) {
|
|
|
3997
3379
|
const html = reg.html ?? "";
|
|
3998
3380
|
const styles = reg.styles;
|
|
3999
3381
|
const script = reg.script;
|
|
4000
|
-
const [entryEl, setEntryEl] = (0,
|
|
4001
|
-
const scriptRef = (0,
|
|
4002
|
-
const annotations = (0,
|
|
4003
|
-
const { attrFields, arrayFields, attrSig, arraySig } = (0,
|
|
3382
|
+
const [entryEl, setEntryEl] = (0, import_react14.useState)(null);
|
|
3383
|
+
const scriptRef = (0, import_react14.useRef)(null);
|
|
3384
|
+
const annotations = (0, import_react14.useMemo)(() => getAnnotations(html), [html]);
|
|
3385
|
+
const { attrFields, arrayFields, attrSig, arraySig } = (0, import_react14.useMemo)(() => {
|
|
4004
3386
|
const attr = [];
|
|
4005
3387
|
const arrays = [];
|
|
4006
3388
|
for (const field of annotations.fields) {
|
|
@@ -4022,11 +3404,11 @@ function createDesignComponentConfig(registration) {
|
|
|
4022
3404
|
arraySig: JSON.stringify(arrays)
|
|
4023
3405
|
};
|
|
4024
3406
|
}, [props, annotations]);
|
|
4025
|
-
const patchedHtml = (0,
|
|
3407
|
+
const patchedHtml = (0, import_react14.useMemo)(() => {
|
|
4026
3408
|
if (puck.isEditing) return html;
|
|
4027
3409
|
return patchHtmlAnnotations(html, props);
|
|
4028
3410
|
}, [html, props, puck.isEditing]);
|
|
4029
|
-
const fieldValueAttrs = (0,
|
|
3411
|
+
const fieldValueAttrs = (0, import_react14.useMemo)(() => {
|
|
4030
3412
|
const attrs = {};
|
|
4031
3413
|
attrs["data-puck-design"] = name;
|
|
4032
3414
|
for (const field of annotations.fields) {
|
|
@@ -4037,17 +3419,17 @@ function createDesignComponentConfig(registration) {
|
|
|
4037
3419
|
}
|
|
4038
3420
|
return attrs;
|
|
4039
3421
|
}, [annotations, props, puck.isEditing]);
|
|
4040
|
-
const editorEntryNode = (0,
|
|
4041
|
-
() => puck.isEditing ? /* @__PURE__ */ (0,
|
|
3422
|
+
const editorEntryNode = (0, import_react14.useMemo)(
|
|
3423
|
+
() => puck.isEditing ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: setEntryEl }) : null,
|
|
4042
3424
|
[puck.isEditing]
|
|
4043
3425
|
);
|
|
4044
|
-
(0,
|
|
3426
|
+
(0, import_react14.useEffect)(() => {
|
|
4045
3427
|
if (!puck.isEditing || !getPuck) return;
|
|
4046
3428
|
getPuck().resolveDataById(id, "force");
|
|
4047
3429
|
}, [reg, puck.isEditing, getPuck, id]);
|
|
4048
|
-
const fieldWiring = (0,
|
|
4049
|
-
const morphed = (0,
|
|
4050
|
-
(0,
|
|
3430
|
+
const fieldWiring = (0, import_react14.useRef)(/* @__PURE__ */ new Map());
|
|
3431
|
+
const morphed = (0, import_react14.useRef)(null);
|
|
3432
|
+
(0, import_react14.useLayoutEffect)(() => {
|
|
4051
3433
|
if (!puck.isEditing || !entryEl) return;
|
|
4052
3434
|
if (morphed.current?.el !== entryEl || morphed.current?.html !== html || morphed.current?.attrSig !== attrSig) {
|
|
4053
3435
|
morphed.current = { el: entryEl, html, attrSig };
|
|
@@ -4064,14 +3446,14 @@ function createDesignComponentConfig(registration) {
|
|
|
4064
3446
|
});
|
|
4065
3447
|
}
|
|
4066
3448
|
});
|
|
4067
|
-
(0,
|
|
3449
|
+
(0, import_react14.useEffect)(
|
|
4068
3450
|
() => () => {
|
|
4069
3451
|
fieldWiring.current.forEach((cleanup) => cleanup());
|
|
4070
3452
|
fieldWiring.current.clear();
|
|
4071
3453
|
},
|
|
4072
3454
|
[]
|
|
4073
3455
|
);
|
|
4074
|
-
(0,
|
|
3456
|
+
(0, import_react14.useEffect)(() => {
|
|
4075
3457
|
if (!entryEl || !puck.isEditing) return;
|
|
4076
3458
|
for (const attr of Array.from(entryEl.attributes)) {
|
|
4077
3459
|
if ((attr.name === "data-puck-design" || attr.name.startsWith("data-puck-field-value-")) && !(attr.name in fieldValueAttrs)) {
|
|
@@ -4084,10 +3466,10 @@ function createDesignComponentConfig(registration) {
|
|
|
4084
3466
|
}
|
|
4085
3467
|
}
|
|
4086
3468
|
}, [entryEl, fieldValueAttrs]);
|
|
4087
|
-
const appliedArrayHtml = (0,
|
|
4088
|
-
const arrayItemWiring = (0,
|
|
4089
|
-
const appliedArrays = (0,
|
|
4090
|
-
(0,
|
|
3469
|
+
const appliedArrayHtml = (0, import_react14.useRef)(/* @__PURE__ */ new WeakMap());
|
|
3470
|
+
const arrayItemWiring = (0, import_react14.useRef)({});
|
|
3471
|
+
const appliedArrays = (0, import_react14.useRef)(null);
|
|
3472
|
+
(0, import_react14.useEffect)(() => {
|
|
4091
3473
|
if (!puck.isEditing || !entryEl || !getPuck) return;
|
|
4092
3474
|
if (appliedArrays.current?.el === entryEl && appliedArrays.current?.html === html && appliedArrays.current?.sig === arraySig) {
|
|
4093
3475
|
return;
|
|
@@ -4139,7 +3521,7 @@ function createDesignComponentConfig(registration) {
|
|
|
4139
3521
|
id,
|
|
4140
3522
|
getPuck
|
|
4141
3523
|
]);
|
|
4142
|
-
(0,
|
|
3524
|
+
(0, import_react14.useEffect)(
|
|
4143
3525
|
() => () => {
|
|
4144
3526
|
Object.values(arrayItemWiring.current).forEach(
|
|
4145
3527
|
(wiring) => wiring.forEach(({ cleanup }) => cleanup())
|
|
@@ -4147,7 +3529,7 @@ function createDesignComponentConfig(registration) {
|
|
|
4147
3529
|
},
|
|
4148
3530
|
[]
|
|
4149
3531
|
);
|
|
4150
|
-
(0,
|
|
3532
|
+
(0, import_react14.useEffect)(() => {
|
|
4151
3533
|
if (!script || !entryEl) return;
|
|
4152
3534
|
scriptRef.current?.remove();
|
|
4153
3535
|
const doc = entryEl.ownerDocument;
|
|
@@ -4165,7 +3547,7 @@ function createDesignComponentConfig(registration) {
|
|
|
4165
3547
|
for (const slot of annotations.slots) {
|
|
4166
3548
|
const Slot = props[slot.name];
|
|
4167
3549
|
if (typeof Slot === "function") {
|
|
4168
|
-
slotContent[slot.name] = /* @__PURE__ */ (0,
|
|
3550
|
+
slotContent[slot.name] = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4169
3551
|
Slot,
|
|
4170
3552
|
{
|
|
4171
3553
|
style: slot.style ? parseStyleString(slot.style) : void 0,
|
|
@@ -4174,17 +3556,17 @@ function createDesignComponentConfig(registration) {
|
|
|
4174
3556
|
);
|
|
4175
3557
|
}
|
|
4176
3558
|
}
|
|
4177
|
-
return /* @__PURE__ */ (0,
|
|
4178
|
-
styles && /* @__PURE__ */ (0,
|
|
4179
|
-
style && /* @__PURE__ */ (0,
|
|
4180
|
-
/* @__PURE__ */ (0,
|
|
3559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
3560
|
+
styles && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: styles }),
|
|
3561
|
+
style && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: style }),
|
|
3562
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: setEntryEl, ...fieldValueAttrs, children: htmlToReactTree(patchedHtml, slotContent) })
|
|
4181
3563
|
] });
|
|
4182
3564
|
}
|
|
4183
|
-
return /* @__PURE__ */ (0,
|
|
4184
|
-
styles && /* @__PURE__ */ (0,
|
|
4185
|
-
style && /* @__PURE__ */ (0,
|
|
3565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
3566
|
+
styles && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: styles }),
|
|
3567
|
+
style && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: style }),
|
|
4186
3568
|
editorEntryNode,
|
|
4187
|
-
entryEl && annotations.slots.map((slot) => /* @__PURE__ */ (0,
|
|
3569
|
+
entryEl && annotations.slots.map((slot) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
4188
3570
|
SlotPortal,
|
|
4189
3571
|
{
|
|
4190
3572
|
entry: entryEl,
|
|
@@ -4202,8 +3584,8 @@ function createDesignComponentConfig(registration) {
|
|
|
4202
3584
|
|
|
4203
3585
|
// src/lib/design/globals.tsx
|
|
4204
3586
|
init_react_import();
|
|
4205
|
-
var
|
|
4206
|
-
var
|
|
3587
|
+
var import_react15 = require("react");
|
|
3588
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
4207
3589
|
function getDynamicConfigGlobals(dynamicConfig) {
|
|
4208
3590
|
if (typeof dynamicConfig !== "object" || dynamicConfig === null) return {};
|
|
4209
3591
|
const { styles, script } = dynamicConfig;
|
|
@@ -4218,9 +3600,9 @@ function DesignGlobals({
|
|
|
4218
3600
|
script,
|
|
4219
3601
|
isEditing
|
|
4220
3602
|
}) {
|
|
4221
|
-
const scriptRef = (0,
|
|
4222
|
-
const hostRef = (0,
|
|
4223
|
-
(0,
|
|
3603
|
+
const scriptRef = (0, import_react15.useRef)(null);
|
|
3604
|
+
const hostRef = (0, import_react15.useRef)(null);
|
|
3605
|
+
(0, import_react15.useEffect)(() => {
|
|
4224
3606
|
if (!script) return;
|
|
4225
3607
|
scriptRef.current?.remove();
|
|
4226
3608
|
const doc = hostRef.current?.ownerDocument ?? document;
|
|
@@ -4233,10 +3615,10 @@ function DesignGlobals({
|
|
|
4233
3615
|
scriptRef.current = null;
|
|
4234
3616
|
};
|
|
4235
3617
|
}, [script]);
|
|
4236
|
-
return /* @__PURE__ */ (0,
|
|
4237
|
-
isEditing && /* @__PURE__ */ (0,
|
|
4238
|
-
styles && /* @__PURE__ */ (0,
|
|
4239
|
-
script && /* @__PURE__ */ (0,
|
|
3618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3619
|
+
isEditing && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("style", { children: INLINE_EDIT_RESET }),
|
|
3620
|
+
styles && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("style", { children: styles }),
|
|
3621
|
+
script && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: hostRef, style: { display: "none" } })
|
|
4240
3622
|
] });
|
|
4241
3623
|
}
|
|
4242
3624
|
var WRAPPED = "__puckAiDesignGlobals";
|
|
@@ -4246,8 +3628,8 @@ function withDesignGlobals(root) {
|
|
|
4246
3628
|
const userRender = root?.render;
|
|
4247
3629
|
const render = (props) => {
|
|
4248
3630
|
const { styles, script } = getDynamicConfigGlobals(props._dynamicConfig);
|
|
4249
|
-
return /* @__PURE__ */ (0,
|
|
4250
|
-
/* @__PURE__ */ (0,
|
|
3631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3632
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4251
3633
|
DesignGlobals,
|
|
4252
3634
|
{
|
|
4253
3635
|
styles,
|
|
@@ -4269,7 +3651,7 @@ function ensureDesignGlobalsRoot(config) {
|
|
|
4269
3651
|
}
|
|
4270
3652
|
|
|
4271
3653
|
// src/lib/design/runtime.tsx
|
|
4272
|
-
var
|
|
3654
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
4273
3655
|
var cachedFieldMetadata;
|
|
4274
3656
|
function detectFieldMetadata(config) {
|
|
4275
3657
|
for (const comp of Object.values(config.components)) {
|
|
@@ -4308,7 +3690,7 @@ function applyConfigFieldMetadata(config, dynamicComponents) {
|
|
|
4308
3690
|
var DESIGNED_CATEGORY = "dynamic";
|
|
4309
3691
|
var dynamicConfigRootField = {
|
|
4310
3692
|
type: "custom",
|
|
4311
|
-
render: () => /* @__PURE__ */ (0,
|
|
3693
|
+
render: () => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {}),
|
|
4312
3694
|
ai: {
|
|
4313
3695
|
exclude: true
|
|
4314
3696
|
}
|
|
@@ -4415,7 +3797,7 @@ function syncDesignComponents(getPuck) {
|
|
|
4415
3797
|
}
|
|
4416
3798
|
function deleteDesignComponent(getPuck, name) {
|
|
4417
3799
|
const { appState, config, dispatch } = getPuck();
|
|
4418
|
-
const filtered = (0,
|
|
3800
|
+
const filtered = (0, import_core3.walkTree)(
|
|
4419
3801
|
appState.data,
|
|
4420
3802
|
config,
|
|
4421
3803
|
(content) => content.filter((item) => item.type !== name)
|
|
@@ -4688,17 +4070,28 @@ function toSerializable(value, ancestors = []) {
|
|
|
4688
4070
|
return copy;
|
|
4689
4071
|
}
|
|
4690
4072
|
|
|
4073
|
+
// src/components/PluginTheme/index.ts
|
|
4074
|
+
init_react_import();
|
|
4075
|
+
|
|
4076
|
+
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/PluginTheme/styles.module.css#css-module
|
|
4077
|
+
init_react_import();
|
|
4078
|
+
var styles_module_default6 = { "PluginTheme": "_PluginTheme_u3emj_8" };
|
|
4079
|
+
|
|
4080
|
+
// src/components/PluginTheme/index.ts
|
|
4081
|
+
var cx4 = getClassNameFactory("PluginTheme", styles_module_default6);
|
|
4082
|
+
var pluginThemeClassName = cx4();
|
|
4083
|
+
|
|
4691
4084
|
// src/components/Chat/index.tsx
|
|
4692
|
-
var
|
|
4085
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
4693
4086
|
var q = (0, import_qler.default)();
|
|
4694
4087
|
var DEFAULT_API_VERSION = "v2";
|
|
4695
4088
|
var BUILD_OP_DEBOUNCE_MS = 1e3 / 60;
|
|
4696
4089
|
var CLIENT_TOOL_ENDPOINT_UNAVAILABLE_ERROR_MESSAGE = "Unable to verify the page data. Please enable the `/chat/tool` endpoint on the server and try again.";
|
|
4697
|
-
var PLUGIN_AI_VERSION = true ? "0.9.0-canary.
|
|
4090
|
+
var PLUGIN_AI_VERSION = true ? "0.9.0-canary.bf40b813" : "unknown";
|
|
4698
4091
|
var BENCHMARK = false;
|
|
4699
4092
|
var prefixedUlid = (prefix = "") => `${prefix ? `${prefix}_` : ""}${(0, import_ulid.ulid)()}`;
|
|
4700
|
-
var
|
|
4701
|
-
var usePuck = (0,
|
|
4093
|
+
var getClassName3 = getClassNameFactory("Chat", styles_module_default);
|
|
4094
|
+
var usePuck = (0, import_core4.createUsePuck)();
|
|
4702
4095
|
function Chat2(props) {
|
|
4703
4096
|
const {
|
|
4704
4097
|
apiVersion = DEFAULT_API_VERSION,
|
|
@@ -4716,33 +4109,33 @@ function Chat2(props) {
|
|
|
4716
4109
|
placeholder
|
|
4717
4110
|
} = chat ?? {};
|
|
4718
4111
|
const puckDispatch = usePuck((s) => s.dispatch);
|
|
4719
|
-
const getPuck = (0,
|
|
4720
|
-
const localChatId = (0,
|
|
4721
|
-
const inputRef = (0,
|
|
4722
|
-
const pluginRef = (0,
|
|
4723
|
-
const [mode, setMode] = (0,
|
|
4724
|
-
const modeRef = (0,
|
|
4112
|
+
const getPuck = (0, import_core4.useGetPuck)();
|
|
4113
|
+
const localChatId = (0, import_react17.useRef)("");
|
|
4114
|
+
const inputRef = (0, import_react17.useRef)(null);
|
|
4115
|
+
const pluginRef = (0, import_react17.useRef)(null);
|
|
4116
|
+
const [mode, setMode] = (0, import_react17.useState)(defaultMode);
|
|
4117
|
+
const modeRef = (0, import_react17.useRef)(mode);
|
|
4725
4118
|
const designModeVisible = typeof designMode === "boolean" ? designMode : designMode.visible ?? false;
|
|
4726
|
-
(0,
|
|
4119
|
+
(0, import_react17.useEffect)(() => {
|
|
4727
4120
|
modeRef.current = mode;
|
|
4728
4121
|
}, [mode]);
|
|
4729
4122
|
const puckData = usePuck((s) => s.appState.data);
|
|
4730
|
-
(0,
|
|
4123
|
+
(0, import_react17.useEffect)(() => {
|
|
4731
4124
|
syncDesignComponents(getPuck);
|
|
4732
4125
|
}, [puckData, getPuck]);
|
|
4733
|
-
const [error, setError] = (0,
|
|
4734
|
-
const [userError, setUserError] = (0,
|
|
4735
|
-
const clientToolEndpointUnavailableRef = (0,
|
|
4736
|
-
const stopChatRef = (0,
|
|
4737
|
-
const [composerAttachments, setComposerAttachments] = (0,
|
|
4738
|
-
const removedAttachmentClientIdsRef = (0,
|
|
4739
|
-
const uploadControllersRef = (0,
|
|
4740
|
-
const pendingBuildOpsRef = (0,
|
|
4741
|
-
const lastStreamActivityRef = (0,
|
|
4742
|
-
const hiddenSinceRef = (0,
|
|
4743
|
-
const [toolStatus, setToolStatus] = (0,
|
|
4744
|
-
const [subagentState, setSubagentState] = (0,
|
|
4745
|
-
const attachmentConfig = (0,
|
|
4126
|
+
const [error, setError] = (0, import_react17.useState)();
|
|
4127
|
+
const [userError, setUserError] = (0, import_react17.useState)();
|
|
4128
|
+
const clientToolEndpointUnavailableRef = (0, import_react17.useRef)(false);
|
|
4129
|
+
const stopChatRef = (0, import_react17.useRef)(null);
|
|
4130
|
+
const [composerAttachments, setComposerAttachments] = (0, import_react17.useState)([]);
|
|
4131
|
+
const removedAttachmentClientIdsRef = (0, import_react17.useRef)(/* @__PURE__ */ new Set());
|
|
4132
|
+
const uploadControllersRef = (0, import_react17.useRef)(/* @__PURE__ */ new Map());
|
|
4133
|
+
const pendingBuildOpsRef = (0, import_react17.useRef)([]);
|
|
4134
|
+
const lastStreamActivityRef = (0, import_react17.useRef)(0);
|
|
4135
|
+
const hiddenSinceRef = (0, import_react17.useRef)(null);
|
|
4136
|
+
const [toolStatus, setToolStatus] = (0, import_react17.useState)({});
|
|
4137
|
+
const [subagentState, setSubagentState] = (0, import_react17.useState)({});
|
|
4138
|
+
const attachmentConfig = (0, import_react17.useMemo)(
|
|
4746
4139
|
() => ({
|
|
4747
4140
|
accept: attachments?.accept ?? defaultAttachmentAccept,
|
|
4748
4141
|
enabled: attachments?.enabled ?? true,
|
|
@@ -4752,14 +4145,14 @@ function Chat2(props) {
|
|
|
4752
4145
|
}),
|
|
4753
4146
|
[attachments, host]
|
|
4754
4147
|
);
|
|
4755
|
-
(0,
|
|
4148
|
+
(0, import_react17.useEffect)(
|
|
4756
4149
|
() => () => {
|
|
4757
4150
|
uploadControllersRef.current.forEach((controller) => controller.abort());
|
|
4758
4151
|
uploadControllersRef.current.clear();
|
|
4759
4152
|
},
|
|
4760
4153
|
[]
|
|
4761
4154
|
);
|
|
4762
|
-
const deleteAttachment = (0,
|
|
4155
|
+
const deleteAttachment = (0, import_react17.useCallback)(
|
|
4763
4156
|
async (attachmentId) => {
|
|
4764
4157
|
try {
|
|
4765
4158
|
await fetch(`${attachmentConfig.endpoint}/${attachmentId}`, {
|
|
@@ -4771,7 +4164,7 @@ function Chat2(props) {
|
|
|
4771
4164
|
},
|
|
4772
4165
|
[attachmentConfig.endpoint]
|
|
4773
4166
|
);
|
|
4774
|
-
const uploadScreenshot = (0,
|
|
4167
|
+
const uploadScreenshot = (0, import_react17.useCallback)(
|
|
4775
4168
|
async (width, bucketUrl) => {
|
|
4776
4169
|
try {
|
|
4777
4170
|
const iframeDocument = document?.getElementById("preview-frame")?.contentDocument?.documentElement ?? null;
|
|
@@ -4826,14 +4219,14 @@ function Chat2(props) {
|
|
|
4826
4219
|
BUILD_OP_DEBOUNCE_MS,
|
|
4827
4220
|
{ maxWait: BUILD_OP_DEBOUNCE_MS }
|
|
4828
4221
|
);
|
|
4829
|
-
const queueBuildOp = (0,
|
|
4222
|
+
const queueBuildOp = (0, import_react17.useCallback)(
|
|
4830
4223
|
(operation) => {
|
|
4831
4224
|
pendingBuildOpsRef.current.push(operation);
|
|
4832
4225
|
debouncedFlushBuildOps();
|
|
4833
4226
|
},
|
|
4834
4227
|
[debouncedFlushBuildOps]
|
|
4835
4228
|
);
|
|
4836
|
-
const handleClientToolEndpointUnavailable = (0,
|
|
4229
|
+
const handleClientToolEndpointUnavailable = (0, import_react17.useCallback)(() => {
|
|
4837
4230
|
if (clientToolEndpointUnavailableRef.current) return;
|
|
4838
4231
|
clientToolEndpointUnavailableRef.current = true;
|
|
4839
4232
|
setError(CLIENT_TOOL_ENDPOINT_UNAVAILABLE_ERROR_MESSAGE);
|
|
@@ -4857,7 +4250,7 @@ function Chat2(props) {
|
|
|
4857
4250
|
});
|
|
4858
4251
|
stopChatRef.current?.();
|
|
4859
4252
|
}, []);
|
|
4860
|
-
const sendClientToolResponse = (0,
|
|
4253
|
+
const sendClientToolResponse = (0, import_react17.useCallback)(
|
|
4861
4254
|
async (body) => {
|
|
4862
4255
|
try {
|
|
4863
4256
|
await postClientToolResponse(host, body);
|
|
@@ -4867,7 +4260,7 @@ function Chat2(props) {
|
|
|
4867
4260
|
},
|
|
4868
4261
|
[handleClientToolEndpointUnavailable, host]
|
|
4869
4262
|
);
|
|
4870
|
-
const processData = (0,
|
|
4263
|
+
const processData = (0, import_react17.useCallback)(
|
|
4871
4264
|
(dataPart) => {
|
|
4872
4265
|
lastStreamActivityRef.current = Date.now();
|
|
4873
4266
|
switch (dataPart.type) {
|
|
@@ -5078,21 +4471,21 @@ function Chat2(props) {
|
|
|
5078
4471
|
});
|
|
5079
4472
|
}
|
|
5080
4473
|
});
|
|
5081
|
-
(0,
|
|
4474
|
+
(0, import_react17.useEffect)(() => {
|
|
5082
4475
|
stopChatRef.current = stop;
|
|
5083
4476
|
return () => {
|
|
5084
4477
|
stopChatRef.current = null;
|
|
5085
4478
|
stop();
|
|
5086
4479
|
};
|
|
5087
4480
|
}, [stop]);
|
|
5088
|
-
const statusRef = (0,
|
|
5089
|
-
(0,
|
|
4481
|
+
const statusRef = (0, import_react17.useRef)(status);
|
|
4482
|
+
(0, import_react17.useEffect)(() => {
|
|
5090
4483
|
statusRef.current = status;
|
|
5091
4484
|
}, [status]);
|
|
5092
|
-
(0,
|
|
4485
|
+
(0, import_react17.useEffect)(() => {
|
|
5093
4486
|
lastStreamActivityRef.current = Date.now();
|
|
5094
4487
|
}, [messages]);
|
|
5095
|
-
(0,
|
|
4488
|
+
(0, import_react17.useEffect)(() => {
|
|
5096
4489
|
const FROZEN_HIDDEN_MS = 3 * 6e4;
|
|
5097
4490
|
const RESUME_GRACE_MS = 12e3;
|
|
5098
4491
|
const isStreaming = () => statusRef.current === "streaming" || statusRef.current === "submitted";
|
|
@@ -5135,12 +4528,12 @@ function Chat2(props) {
|
|
|
5135
4528
|
if (graceTimer) clearTimeout(graceTimer);
|
|
5136
4529
|
};
|
|
5137
4530
|
}, [stop]);
|
|
5138
|
-
const [forcedStatus, setForcedStatus] = (0,
|
|
5139
|
-
const resolvedStatus = (0,
|
|
4531
|
+
const [forcedStatus, setForcedStatus] = (0, import_react17.useState)();
|
|
4532
|
+
const resolvedStatus = (0, import_react17.useMemo)(
|
|
5140
4533
|
() => forcedStatus ?? status,
|
|
5141
4534
|
[status, forcedStatus]
|
|
5142
4535
|
);
|
|
5143
|
-
(0,
|
|
4536
|
+
(0, import_react17.useEffect)(() => {
|
|
5144
4537
|
if (!scrollTrackingId) return;
|
|
5145
4538
|
dispatchScrollTrackingEvent({
|
|
5146
4539
|
id: scrollTrackingId,
|
|
@@ -5153,7 +4546,7 @@ function Chat2(props) {
|
|
|
5153
4546
|
});
|
|
5154
4547
|
};
|
|
5155
4548
|
}, [resolvedStatus, scrollTrackingId]);
|
|
5156
|
-
(0,
|
|
4549
|
+
(0, import_react17.useEffect)(() => {
|
|
5157
4550
|
window.__PUCK_AI = {
|
|
5158
4551
|
processData,
|
|
5159
4552
|
setMessages,
|
|
@@ -5364,7 +4757,7 @@ function Chat2(props) {
|
|
|
5364
4757
|
if (!target?.attachmentId) return;
|
|
5365
4758
|
await deleteAttachment(target.attachmentId);
|
|
5366
4759
|
};
|
|
5367
|
-
const messagesWithStatuses = (0,
|
|
4760
|
+
const messagesWithStatuses = (0, import_react17.useMemo)(() => {
|
|
5368
4761
|
return messages.map((msg) => {
|
|
5369
4762
|
return {
|
|
5370
4763
|
...msg,
|
|
@@ -5377,71 +4770,78 @@ function Chat2(props) {
|
|
|
5377
4770
|
};
|
|
5378
4771
|
});
|
|
5379
4772
|
}, [messages, toolStatus]);
|
|
5380
|
-
return /* @__PURE__ */ (0,
|
|
5381
|
-
|
|
4773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4774
|
+
"div",
|
|
5382
4775
|
{
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
AttachmentComposer,
|
|
5388
|
-
{
|
|
5389
|
-
accept: attachmentConfig.accept,
|
|
5390
|
-
attachments: composerAttachments,
|
|
5391
|
-
disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming",
|
|
5392
|
-
maxFiles: attachmentConfig.maxFiles,
|
|
5393
|
-
onChange: handleAttachmentChange
|
|
5394
|
-
}
|
|
5395
|
-
) : null,
|
|
5396
|
-
typeof chatActions === "function" ? chatActions({
|
|
5397
|
-
disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming"
|
|
5398
|
-
}) : chatActions,
|
|
5399
|
-
designModeVisible ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5400
|
-
DesignModeToggle,
|
|
5401
|
-
{
|
|
5402
|
-
active: mode === "design",
|
|
5403
|
-
onToggle: () => setMode(
|
|
5404
|
-
(mode2) => mode2 === "design" ? "assembly" : "design"
|
|
5405
|
-
),
|
|
5406
|
-
disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming"
|
|
5407
|
-
}
|
|
5408
|
-
) : null
|
|
5409
|
-
] }),
|
|
5410
|
-
attachments: composerAttachments,
|
|
5411
|
-
onRemoveAttachment: removeAttachment,
|
|
5412
|
-
handleSubmit,
|
|
5413
|
-
inputRef,
|
|
5414
|
-
status: resolvedStatus,
|
|
5415
|
-
examplePrompts: examplePrompts?.map(
|
|
5416
|
-
({ label, href, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5417
|
-
ExamplePrompt,
|
|
5418
|
-
{
|
|
5419
|
-
label,
|
|
5420
|
-
href,
|
|
5421
|
-
onClick,
|
|
5422
|
-
disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming"
|
|
5423
|
-
},
|
|
5424
|
-
label
|
|
5425
|
-
)
|
|
5426
|
-
),
|
|
5427
|
-
error,
|
|
5428
|
-
handleRetry: () => {
|
|
5429
|
-
clientToolEndpointUnavailableRef.current = false;
|
|
5430
|
-
setError("");
|
|
5431
|
-
regenerate();
|
|
5432
|
-
},
|
|
5433
|
-
userError,
|
|
5434
|
-
onDismissUserError: () => setUserError(""),
|
|
5435
|
-
children: placeholder ?? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5436
|
-
Placeholder,
|
|
4776
|
+
className: `${getClassName3()} ${pluginThemeClassName}`,
|
|
4777
|
+
ref: pluginRef,
|
|
4778
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HostProvider, { value: host, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ToolStatusProvider, { value: toolStatus, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SubagentStateProvider, { value: subagentState, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4779
|
+
ChatBody,
|
|
5437
4780
|
{
|
|
5438
|
-
|
|
4781
|
+
messages: messagesWithStatuses,
|
|
4782
|
+
onFileDrop: attachmentConfig.enabled ? handleFiles : void 0,
|
|
4783
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
4784
|
+
attachmentConfig.enabled ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4785
|
+
AttachmentComposer,
|
|
4786
|
+
{
|
|
4787
|
+
accept: attachmentConfig.accept,
|
|
4788
|
+
attachments: composerAttachments,
|
|
4789
|
+
disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming",
|
|
4790
|
+
maxFiles: attachmentConfig.maxFiles,
|
|
4791
|
+
onChange: handleAttachmentChange
|
|
4792
|
+
}
|
|
4793
|
+
) : null,
|
|
4794
|
+
typeof chatActions === "function" ? chatActions({
|
|
4795
|
+
disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming"
|
|
4796
|
+
}) : chatActions,
|
|
4797
|
+
designModeVisible ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4798
|
+
DesignModeToggle,
|
|
4799
|
+
{
|
|
4800
|
+
active: mode === "design",
|
|
4801
|
+
onToggle: () => setMode(
|
|
4802
|
+
(mode2) => mode2 === "design" ? "assembly" : "design"
|
|
4803
|
+
),
|
|
4804
|
+
disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming"
|
|
4805
|
+
}
|
|
4806
|
+
) : null
|
|
4807
|
+
] }),
|
|
4808
|
+
attachments: composerAttachments,
|
|
4809
|
+
onRemoveAttachment: removeAttachment,
|
|
4810
|
+
handleSubmit,
|
|
5439
4811
|
inputRef,
|
|
5440
|
-
|
|
4812
|
+
status: resolvedStatus,
|
|
4813
|
+
examplePrompts: examplePrompts?.map(
|
|
4814
|
+
({ label, href, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4815
|
+
ExamplePrompt,
|
|
4816
|
+
{
|
|
4817
|
+
label,
|
|
4818
|
+
href,
|
|
4819
|
+
onClick,
|
|
4820
|
+
disabled: resolvedStatus === "submitted" || resolvedStatus === "streaming"
|
|
4821
|
+
},
|
|
4822
|
+
label
|
|
4823
|
+
)
|
|
4824
|
+
),
|
|
4825
|
+
error,
|
|
4826
|
+
handleRetry: () => {
|
|
4827
|
+
clientToolEndpointUnavailableRef.current = false;
|
|
4828
|
+
setError("");
|
|
4829
|
+
regenerate();
|
|
4830
|
+
},
|
|
4831
|
+
userError,
|
|
4832
|
+
onDismissUserError: () => setUserError(""),
|
|
4833
|
+
children: placeholder ?? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4834
|
+
Placeholder,
|
|
4835
|
+
{
|
|
4836
|
+
dispatch: puckDispatch,
|
|
4837
|
+
inputRef,
|
|
4838
|
+
pluginRef
|
|
4839
|
+
}
|
|
4840
|
+
)
|
|
5441
4841
|
}
|
|
5442
|
-
)
|
|
4842
|
+
) }) }) })
|
|
5443
4843
|
}
|
|
5444
|
-
)
|
|
4844
|
+
);
|
|
5445
4845
|
}
|
|
5446
4846
|
function finalizeReasoningParts(parts) {
|
|
5447
4847
|
return parts.map(
|
|
@@ -5493,287 +4893,571 @@ function reduceSubagentEvent(current, event) {
|
|
|
5493
4893
|
text: event.text,
|
|
5494
4894
|
state: "streaming"
|
|
5495
4895
|
});
|
|
5496
|
-
}
|
|
5497
|
-
return {
|
|
5498
|
-
...current,
|
|
5499
|
-
[event.toolCallId]: { ...existing, parts }
|
|
4896
|
+
}
|
|
4897
|
+
return {
|
|
4898
|
+
...current,
|
|
4899
|
+
[event.toolCallId]: { ...existing, parts }
|
|
4900
|
+
};
|
|
4901
|
+
}
|
|
4902
|
+
if (event.kind === "text-delta") {
|
|
4903
|
+
const parts = finalizeReasoningParts(existing.parts);
|
|
4904
|
+
const last = parts[parts.length - 1];
|
|
4905
|
+
if (last && last.kind === "text" && last.blockId === event.blockId) {
|
|
4906
|
+
parts[parts.length - 1] = { ...last, text: last.text + event.text };
|
|
4907
|
+
} else {
|
|
4908
|
+
parts.push({ kind: "text", blockId: event.blockId, text: event.text });
|
|
4909
|
+
}
|
|
4910
|
+
return {
|
|
4911
|
+
...current,
|
|
4912
|
+
[event.toolCallId]: { ...existing, parts }
|
|
4913
|
+
};
|
|
4914
|
+
}
|
|
4915
|
+
if (event.kind === "tool-call") {
|
|
4916
|
+
return {
|
|
4917
|
+
...current,
|
|
4918
|
+
[event.toolCallId]: {
|
|
4919
|
+
...existing,
|
|
4920
|
+
parts: [
|
|
4921
|
+
...finalizeReasoningParts(existing.parts),
|
|
4922
|
+
{
|
|
4923
|
+
kind: "tool",
|
|
4924
|
+
childToolCallId: event.childToolCallId,
|
|
4925
|
+
toolName: event.toolName,
|
|
4926
|
+
input: event.input
|
|
4927
|
+
}
|
|
4928
|
+
]
|
|
4929
|
+
}
|
|
4930
|
+
};
|
|
4931
|
+
}
|
|
4932
|
+
if (event.kind === "tool-result") {
|
|
4933
|
+
return {
|
|
4934
|
+
...current,
|
|
4935
|
+
[event.toolCallId]: {
|
|
4936
|
+
...existing,
|
|
4937
|
+
parts: existing.parts.map(
|
|
4938
|
+
(part) => part.kind === "tool" && part.childToolCallId === event.childToolCallId ? { ...part, output: event.output } : part
|
|
4939
|
+
)
|
|
4940
|
+
}
|
|
4941
|
+
};
|
|
4942
|
+
}
|
|
4943
|
+
return current;
|
|
4944
|
+
}
|
|
4945
|
+
function AttachmentComposer({
|
|
4946
|
+
accept,
|
|
4947
|
+
attachments,
|
|
4948
|
+
disabled,
|
|
4949
|
+
maxFiles,
|
|
4950
|
+
onChange
|
|
4951
|
+
}) {
|
|
4952
|
+
const id = (0, import_react17.useId)();
|
|
4953
|
+
const inputId = (0, import_react17.useMemo)(() => `attachment-input-${id}`, []);
|
|
4954
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: getClassName3("attachmentControls"), children: [
|
|
4955
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4956
|
+
"input",
|
|
4957
|
+
{
|
|
4958
|
+
accept: accept.join(","),
|
|
4959
|
+
className: getClassName3("attachmentInput"),
|
|
4960
|
+
disabled: disabled || attachments.length >= maxFiles,
|
|
4961
|
+
id: inputId,
|
|
4962
|
+
multiple: true,
|
|
4963
|
+
onChange,
|
|
4964
|
+
type: "file"
|
|
4965
|
+
}
|
|
4966
|
+
),
|
|
4967
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
4968
|
+
"button",
|
|
4969
|
+
{
|
|
4970
|
+
"aria-label": "Attach files",
|
|
4971
|
+
className: getClassName3("attachmentButton"),
|
|
4972
|
+
disabled: disabled || attachments.length >= maxFiles,
|
|
4973
|
+
onClick: () => document.getElementById(inputId)?.click(),
|
|
4974
|
+
title: "Attach files",
|
|
4975
|
+
type: "button",
|
|
4976
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Paperclip, { size: 14 })
|
|
4977
|
+
}
|
|
4978
|
+
)
|
|
4979
|
+
] });
|
|
4980
|
+
}
|
|
4981
|
+
function Placeholder({
|
|
4982
|
+
dispatch,
|
|
4983
|
+
inputRef,
|
|
4984
|
+
pluginRef
|
|
4985
|
+
}) {
|
|
4986
|
+
const handleEnterPromptClick = () => {
|
|
4987
|
+
inputRef.current?.focus({ preventScroll: true });
|
|
4988
|
+
setTimeout(() => {
|
|
4989
|
+
if (pluginRef.current && inputRef.current && !isScrolledIntoView(inputRef.current)) {
|
|
4990
|
+
const box = pluginRef.current.getBoundingClientRect();
|
|
4991
|
+
const top = box.top - (window.innerHeight - box.height) / 2;
|
|
4992
|
+
window.scrollTo({
|
|
4993
|
+
behavior: "smooth",
|
|
4994
|
+
top
|
|
4995
|
+
});
|
|
4996
|
+
}
|
|
4997
|
+
}, 10);
|
|
4998
|
+
};
|
|
4999
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: getClassName3("placeholder"), children: [
|
|
5000
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: getClassName3("placeholderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Sparkles, { "aria-hidden": "true", size: 28 }) }),
|
|
5001
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("strong", { className: getClassName3("placeholderTitle"), children: "Build with AI" }),
|
|
5002
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: getClassName3("placeholderDescription"), children: "Describe what you want to create or change." }),
|
|
5003
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: getClassName3("actions"), children: [
|
|
5004
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
5005
|
+
"button",
|
|
5006
|
+
{
|
|
5007
|
+
className: getClassName3("action"),
|
|
5008
|
+
onClick: handleEnterPromptClick,
|
|
5009
|
+
type: "button",
|
|
5010
|
+
children: "Write a prompt"
|
|
5011
|
+
}
|
|
5012
|
+
),
|
|
5013
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
5014
|
+
"button",
|
|
5015
|
+
{
|
|
5016
|
+
className: getClassName3("actionOutlined"),
|
|
5017
|
+
onClick: () => {
|
|
5018
|
+
dispatch({
|
|
5019
|
+
type: "setUi",
|
|
5020
|
+
ui: { plugin: { current: "blocks" } }
|
|
5021
|
+
});
|
|
5022
|
+
},
|
|
5023
|
+
type: "button",
|
|
5024
|
+
children: "Browse"
|
|
5025
|
+
}
|
|
5026
|
+
)
|
|
5027
|
+
] })
|
|
5028
|
+
] });
|
|
5029
|
+
}
|
|
5030
|
+
function nextFrame(cb) {
|
|
5031
|
+
let ran = false;
|
|
5032
|
+
const run = () => {
|
|
5033
|
+
if (ran) return;
|
|
5034
|
+
ran = true;
|
|
5035
|
+
cb();
|
|
5036
|
+
};
|
|
5037
|
+
if (typeof document !== "undefined" && document.hidden) {
|
|
5038
|
+
queueMicrotask(run);
|
|
5039
|
+
return;
|
|
5040
|
+
}
|
|
5041
|
+
requestAnimationFrame(run);
|
|
5042
|
+
setTimeout(run, 100);
|
|
5043
|
+
}
|
|
5044
|
+
function isScrolledIntoView(el) {
|
|
5045
|
+
const rect = el.getBoundingClientRect();
|
|
5046
|
+
const elemTop = rect.top;
|
|
5047
|
+
const elemBottom = rect.bottom;
|
|
5048
|
+
return elemTop >= 0 && elemBottom <= window.innerHeight;
|
|
5049
|
+
}
|
|
5050
|
+
|
|
5051
|
+
// src/components/ScrollTracking/ScrollTracking.tsx
|
|
5052
|
+
init_react_import();
|
|
5053
|
+
var import_react19 = require("react");
|
|
5054
|
+
|
|
5055
|
+
// src/lib/scroll-into-view-local.ts
|
|
5056
|
+
init_react_import();
|
|
5057
|
+
function scrollIntoViewLocal(el, win, behavior = "smooth") {
|
|
5058
|
+
const scroller = el.ownerDocument?.scrollingElement || el.ownerDocument?.documentElement;
|
|
5059
|
+
const rect = el.getBoundingClientRect();
|
|
5060
|
+
const vpH = win.innerHeight;
|
|
5061
|
+
const current = scroller.scrollTop;
|
|
5062
|
+
const offset = win.innerHeight / 2;
|
|
5063
|
+
let targetTop = current;
|
|
5064
|
+
if (rect.top < 0) {
|
|
5065
|
+
targetTop = current + rect.top;
|
|
5066
|
+
} else if (rect.bottom > vpH) {
|
|
5067
|
+
targetTop = current + (rect.bottom - vpH);
|
|
5068
|
+
}
|
|
5069
|
+
if (targetTop !== current) {
|
|
5070
|
+
scroller.scrollTo({ top: targetTop + offset, behavior });
|
|
5071
|
+
}
|
|
5072
|
+
}
|
|
5073
|
+
|
|
5074
|
+
// src/lib/use-frame-mutation-observer.ts
|
|
5075
|
+
init_react_import();
|
|
5076
|
+
var import_react18 = require("react");
|
|
5077
|
+
function useFrameMutationObserver(callback) {
|
|
5078
|
+
return (0, import_react18.useCallback)(() => {
|
|
5079
|
+
const frame = document?.getElementById(
|
|
5080
|
+
"preview-frame"
|
|
5081
|
+
);
|
|
5082
|
+
if (!frame) return;
|
|
5083
|
+
let observer = null;
|
|
5084
|
+
const win = frame.contentWindow;
|
|
5085
|
+
let enabled = true;
|
|
5086
|
+
const disable = () => {
|
|
5087
|
+
enabled = false;
|
|
5088
|
+
};
|
|
5089
|
+
const attachObserver = () => {
|
|
5090
|
+
const win2 = frame.contentWindow;
|
|
5091
|
+
const doc = frame.contentDocument || win2?.document;
|
|
5092
|
+
if (!win2 || !doc) return;
|
|
5093
|
+
const target = doc.querySelector("#frame-root > div");
|
|
5094
|
+
if (!target) return;
|
|
5095
|
+
observer = new MutationObserver((entries) => {
|
|
5096
|
+
if (enabled) {
|
|
5097
|
+
callback(entries, win2);
|
|
5098
|
+
}
|
|
5099
|
+
});
|
|
5100
|
+
observer?.observe(target, { childList: true, subtree: true });
|
|
5101
|
+
win2.addEventListener("pointerdown", disable);
|
|
5102
|
+
win2.addEventListener("mousewheel", disable);
|
|
5500
5103
|
};
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
const parts = finalizeReasoningParts(existing.parts);
|
|
5504
|
-
const last = parts[parts.length - 1];
|
|
5505
|
-
if (last && last.kind === "text" && last.blockId === event.blockId) {
|
|
5506
|
-
parts[parts.length - 1] = { ...last, text: last.text + event.text };
|
|
5104
|
+
if (frame.contentDocument?.readyState === "complete") {
|
|
5105
|
+
attachObserver();
|
|
5507
5106
|
} else {
|
|
5508
|
-
|
|
5107
|
+
frame.addEventListener("load", attachObserver, { once: true });
|
|
5509
5108
|
}
|
|
5510
|
-
return {
|
|
5511
|
-
|
|
5512
|
-
|
|
5109
|
+
return () => {
|
|
5110
|
+
frame.removeEventListener("load", attachObserver);
|
|
5111
|
+
win?.removeEventListener("pointerdown", disable);
|
|
5112
|
+
win?.removeEventListener("mousewheel", disable);
|
|
5113
|
+
observer?.disconnect();
|
|
5513
5114
|
};
|
|
5514
|
-
}
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5115
|
+
}, [callback]);
|
|
5116
|
+
}
|
|
5117
|
+
|
|
5118
|
+
// src/components/ScrollTracking/ScrollTracking.tsx
|
|
5119
|
+
var ScrollTracking = ({
|
|
5120
|
+
children,
|
|
5121
|
+
trackingId
|
|
5122
|
+
}) => {
|
|
5123
|
+
const followedRefs = (0, import_react19.useRef)([]);
|
|
5124
|
+
const enabledRef = (0, import_react19.useRef)(false);
|
|
5125
|
+
(0, import_react19.useEffect)(() => {
|
|
5126
|
+
return subscribeToScrollTrackingEvents(({ id, enabled }) => {
|
|
5127
|
+
if (id !== trackingId) return;
|
|
5128
|
+
enabledRef.current = enabled;
|
|
5129
|
+
followedRefs.current = [];
|
|
5130
|
+
});
|
|
5131
|
+
}, [trackingId]);
|
|
5132
|
+
const follow = useFrameMutationObserver((records, win) => {
|
|
5133
|
+
if (!enabledRef.current) return;
|
|
5134
|
+
if (records.length > 0) {
|
|
5135
|
+
const lastRecord = records[records.length - 1];
|
|
5136
|
+
if (followedRefs.current.includes(lastRecord.target)) return;
|
|
5137
|
+
followedRefs.current.push(lastRecord.target);
|
|
5138
|
+
requestAnimationFrame(() => {
|
|
5139
|
+
const el = lastRecord.target;
|
|
5140
|
+
scrollIntoViewLocal(el, win);
|
|
5141
|
+
});
|
|
5142
|
+
}
|
|
5143
|
+
});
|
|
5144
|
+
(0, import_react19.useEffect)(() => {
|
|
5145
|
+
follow();
|
|
5146
|
+
}, [follow]);
|
|
5147
|
+
return children;
|
|
5148
|
+
};
|
|
5149
|
+
|
|
5150
|
+
// src/components/Drawer/index.tsx
|
|
5151
|
+
init_react_import();
|
|
5152
|
+
var import_core6 = require("@puckeditor/core");
|
|
5153
|
+
|
|
5154
|
+
// src/components/ManageComponents/index.tsx
|
|
5155
|
+
init_react_import();
|
|
5156
|
+
var import_core5 = require("@puckeditor/core");
|
|
5157
|
+
var import_react23 = require("react");
|
|
5158
|
+
|
|
5159
|
+
// ../platform-client/components/ActionModal/index.ts
|
|
5160
|
+
init_react_import();
|
|
5161
|
+
|
|
5162
|
+
// ../platform-client/components/ActionModal/ActionModal.tsx
|
|
5163
|
+
init_react_import();
|
|
5164
|
+
|
|
5165
|
+
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/ActionModal/ActionModal.module.css#css-module
|
|
5166
|
+
init_react_import();
|
|
5167
|
+
var ActionModal_module_default = { "ActionModal": "_ActionModal_10j8y_1", "ActionModal-header": "_ActionModal-header_10j8y_6", "ActionModal-body": "_ActionModal-body_10j8y_20", "ActionModal-footer": "_ActionModal-footer_10j8y_28" };
|
|
5168
|
+
|
|
5169
|
+
// ../platform-client/components/Modal/Modal.tsx
|
|
5170
|
+
init_react_import();
|
|
5171
|
+
|
|
5172
|
+
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Modal/Modal.module.css#css-module
|
|
5173
|
+
init_react_import();
|
|
5174
|
+
var Modal_module_default = { "Modal-background": "_Modal-background_10jdm_1", "Modal--visible": "_Modal--visible_10jdm_16", "Modal-modal": "_Modal-modal_10jdm_22" };
|
|
5175
|
+
|
|
5176
|
+
// ../platform-client/components/Modal/Modal.tsx
|
|
5177
|
+
var import_react22 = require("react");
|
|
5178
|
+
|
|
5179
|
+
// ../platform-client/lib/use-modal-visible.ts
|
|
5180
|
+
init_react_import();
|
|
5181
|
+
var import_react20 = require("react");
|
|
5182
|
+
var useModalVisible = (defaultVisible) => {
|
|
5183
|
+
const [visible, setVisible] = (0, import_react20.useState)(defaultVisible ?? false);
|
|
5184
|
+
const ref = (0, import_react20.useRef)(null);
|
|
5185
|
+
(0, import_react20.useEffect)(() => {
|
|
5186
|
+
if (!visible) {
|
|
5187
|
+
return;
|
|
5188
|
+
}
|
|
5189
|
+
const handler = (e) => {
|
|
5190
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
5191
|
+
setVisible(false);
|
|
5529
5192
|
}
|
|
5530
5193
|
};
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
...current,
|
|
5535
|
-
[event.toolCallId]: {
|
|
5536
|
-
...existing,
|
|
5537
|
-
parts: existing.parts.map(
|
|
5538
|
-
(part) => part.kind === "tool" && part.childToolCallId === event.childToolCallId ? { ...part, output: event.output } : part
|
|
5539
|
-
)
|
|
5540
|
-
}
|
|
5194
|
+
document.body.addEventListener("click", handler);
|
|
5195
|
+
return () => {
|
|
5196
|
+
document.body.removeEventListener("click", handler);
|
|
5541
5197
|
};
|
|
5542
|
-
}
|
|
5543
|
-
return
|
|
5544
|
-
}
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5198
|
+
}, [visible]);
|
|
5199
|
+
return [visible, setVisible, ref];
|
|
5200
|
+
};
|
|
5201
|
+
|
|
5202
|
+
// ../platform-client/components/Button/index.ts
|
|
5203
|
+
init_react_import();
|
|
5204
|
+
|
|
5205
|
+
// ../platform-client/components/Button/Button.tsx
|
|
5206
|
+
init_react_import();
|
|
5207
|
+
var import_react21 = require("react");
|
|
5208
|
+
|
|
5209
|
+
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Button/Button.module.css#css-module
|
|
5210
|
+
init_react_import();
|
|
5211
|
+
var Button_module_default = { "Button": "_Button_z2rgr_1", "Button--tiny": "_Button--tiny_z2rgr_43", "Button--small": "_Button--small_z2rgr_51", "Button--medium": "_Button--medium_z2rgr_59", "Button--large": "_Button--large_z2rgr_69", "Button--brand": "_Button--brand_z2rgr_78", "Button--primary": "_Button--primary_z2rgr_101", "Button--secondary": "_Button--secondary_z2rgr_129", "Button--danger": "_Button--danger_z2rgr_163", "Button--flush": "_Button--flush_z2rgr_186", "Button--ghost": "_Button--ghost_z2rgr_190", "Button--disabled": "_Button--disabled_z2rgr_216", "Button--fullWidth": "_Button--fullWidth_z2rgr_267", "Button-spinner": "_Button-spinner_z2rgr_272" };
|
|
5212
|
+
|
|
5213
|
+
// ../platform-client/components/Button/Button.tsx
|
|
5214
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
5215
|
+
var getClassName4 = get_class_name_factory_default("Button", Button_module_default);
|
|
5216
|
+
var Button = ({
|
|
5217
|
+
children,
|
|
5218
|
+
href,
|
|
5219
|
+
onClick,
|
|
5220
|
+
variant = "primary",
|
|
5221
|
+
type,
|
|
5548
5222
|
disabled,
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5223
|
+
tabIndex,
|
|
5224
|
+
newTab,
|
|
5225
|
+
fullWidth,
|
|
5226
|
+
icon,
|
|
5227
|
+
size = "medium",
|
|
5228
|
+
loading: loadingProp = false
|
|
5229
|
+
}) => {
|
|
5230
|
+
const [loading, setLoading] = (0, import_react21.useState)(loadingProp);
|
|
5231
|
+
(0, import_react21.useEffect)(() => {
|
|
5232
|
+
const resetLoading = () => setLoading(loadingProp);
|
|
5233
|
+
resetLoading();
|
|
5234
|
+
window.addEventListener("pageshow", resetLoading);
|
|
5235
|
+
return () => window.removeEventListener("pageshow", resetLoading);
|
|
5236
|
+
}, [loadingProp]);
|
|
5237
|
+
const ElementType = href ? "a" : type ? "button" : "span";
|
|
5238
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
5239
|
+
ElementType,
|
|
5240
|
+
{
|
|
5241
|
+
className: getClassName4({
|
|
5242
|
+
brand: variant === "brand",
|
|
5243
|
+
primary: variant === "primary",
|
|
5244
|
+
secondary: variant === "secondary",
|
|
5245
|
+
danger: variant === "danger",
|
|
5246
|
+
ghost: variant === "ghost",
|
|
5247
|
+
// Disabled while its click is still running, too.
|
|
5248
|
+
disabled: disabled || loading,
|
|
5249
|
+
fullWidth,
|
|
5250
|
+
[size]: true
|
|
5251
|
+
}),
|
|
5252
|
+
onClick: (e) => {
|
|
5253
|
+
if (disabled || loading) {
|
|
5254
|
+
e.preventDefault();
|
|
5255
|
+
return;
|
|
5256
|
+
}
|
|
5257
|
+
if (!onClick) return;
|
|
5258
|
+
setLoading(true);
|
|
5259
|
+
Promise.resolve(onClick(e)).then(() => {
|
|
5260
|
+
setLoading(false);
|
|
5261
|
+
});
|
|
5262
|
+
},
|
|
5263
|
+
type,
|
|
5264
|
+
disabled: disabled || loading,
|
|
5265
|
+
tabIndex,
|
|
5266
|
+
target: newTab ? "_blank" : void 0,
|
|
5267
|
+
rel: newTab ? "noreferrer" : void 0,
|
|
5268
|
+
href,
|
|
5269
|
+
children: [
|
|
5270
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName4("icon"), children: icon }),
|
|
5271
|
+
children,
|
|
5272
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName4("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Loader, { size: 12 }) })
|
|
5273
|
+
]
|
|
5274
|
+
}
|
|
5275
|
+
);
|
|
5276
|
+
return el;
|
|
5277
|
+
};
|
|
5278
|
+
|
|
5279
|
+
// ../platform-client/components/Modal/Modal.tsx
|
|
5280
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
5281
|
+
var getClassName5 = getClassNameFactory("Modal", Modal_module_default);
|
|
5282
|
+
var modalContext = (0, import_react22.createContext)({
|
|
5283
|
+
buttonVariant: "primary",
|
|
5284
|
+
buttonSize: "medium",
|
|
5285
|
+
visible: false,
|
|
5286
|
+
setVisible: () => {
|
|
5287
|
+
},
|
|
5288
|
+
ref: null
|
|
5289
|
+
});
|
|
5290
|
+
var ModalProvider = ({
|
|
5291
|
+
children,
|
|
5292
|
+
defaultVisible,
|
|
5293
|
+
buttonVariant = "primary",
|
|
5294
|
+
buttonSize = "medium"
|
|
5295
|
+
}) => {
|
|
5296
|
+
const [visible, setVisible, ref] = useModalVisible(defaultVisible);
|
|
5297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5298
|
+
modalContext.Provider,
|
|
5299
|
+
{
|
|
5300
|
+
value: { buttonVariant, buttonSize, visible, setVisible, ref },
|
|
5301
|
+
children
|
|
5302
|
+
}
|
|
5303
|
+
);
|
|
5304
|
+
};
|
|
5305
|
+
var useModal = () => {
|
|
5306
|
+
const { visible, setVisible } = (0, import_react22.useContext)(modalContext);
|
|
5307
|
+
return { visible, setVisible };
|
|
5308
|
+
};
|
|
5309
|
+
var Modal = ({
|
|
5310
|
+
actionLabel = "Open",
|
|
5311
|
+
children,
|
|
5312
|
+
hideButton = false
|
|
5313
|
+
}) => {
|
|
5314
|
+
const { visible, setVisible, buttonVariant, buttonSize, ref } = (0, import_react22.useContext)(modalContext);
|
|
5315
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName5({ visible }), children: [
|
|
5316
|
+
!hideButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName5("button"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
5317
|
+
Button,
|
|
5569
5318
|
{
|
|
5570
|
-
"aria-label": "Attach files",
|
|
5571
|
-
className: getClassName18("attachmentButton"),
|
|
5572
|
-
disabled: disabled || attachments.length >= maxFiles,
|
|
5573
|
-
onClick: () => document.getElementById(inputId)?.click(),
|
|
5574
|
-
title: "Attach files",
|
|
5575
5319
|
type: "button",
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
inputRef,
|
|
5584
|
-
pluginRef
|
|
5585
|
-
}) {
|
|
5586
|
-
const handleEnterPromptClick = () => {
|
|
5587
|
-
inputRef.current?.focus({ preventScroll: true });
|
|
5588
|
-
setTimeout(() => {
|
|
5589
|
-
if (pluginRef.current && inputRef.current && !isScrolledIntoView(inputRef.current)) {
|
|
5590
|
-
const box = pluginRef.current.getBoundingClientRect();
|
|
5591
|
-
const top = box.top - (window.innerHeight - box.height) / 2;
|
|
5592
|
-
window.scrollTo({
|
|
5593
|
-
behavior: "smooth",
|
|
5594
|
-
top
|
|
5595
|
-
});
|
|
5320
|
+
variant: buttonVariant,
|
|
5321
|
+
size: buttonSize,
|
|
5322
|
+
onClick: (e) => {
|
|
5323
|
+
e.stopPropagation();
|
|
5324
|
+
setVisible(!visible);
|
|
5325
|
+
},
|
|
5326
|
+
children: actionLabel
|
|
5596
5327
|
}
|
|
5597
|
-
},
|
|
5598
|
-
|
|
5599
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName18("placeholder"), children: [
|
|
5600
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: getClassName18("placeholderIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Sparkles, { "aria-hidden": "true", size: 28 }) }),
|
|
5601
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("strong", { className: getClassName18("placeholderTitle"), children: "Build with AI" }),
|
|
5602
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: getClassName18("placeholderDescription"), children: "Describe what you want to create or change." }),
|
|
5603
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsxs)("div", { className: getClassName18("actions"), children: [
|
|
5604
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5605
|
-
"button",
|
|
5606
|
-
{
|
|
5607
|
-
className: getClassName18("action"),
|
|
5608
|
-
onClick: handleEnterPromptClick,
|
|
5609
|
-
type: "button",
|
|
5610
|
-
children: "Write a prompt"
|
|
5611
|
-
}
|
|
5612
|
-
),
|
|
5613
|
-
/* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
5614
|
-
"button",
|
|
5615
|
-
{
|
|
5616
|
-
className: getClassName18("actionOutlined"),
|
|
5617
|
-
onClick: () => {
|
|
5618
|
-
dispatch({
|
|
5619
|
-
type: "setUi",
|
|
5620
|
-
ui: { plugin: { current: "blocks" } }
|
|
5621
|
-
});
|
|
5622
|
-
},
|
|
5623
|
-
type: "button",
|
|
5624
|
-
children: "Browse"
|
|
5625
|
-
}
|
|
5626
|
-
)
|
|
5627
|
-
] })
|
|
5328
|
+
) }),
|
|
5329
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName5("background"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassName5("modal"), ref, children }) })
|
|
5628
5330
|
] });
|
|
5629
|
-
}
|
|
5630
|
-
function nextFrame(cb) {
|
|
5631
|
-
let ran = false;
|
|
5632
|
-
const run = () => {
|
|
5633
|
-
if (ran) return;
|
|
5634
|
-
ran = true;
|
|
5635
|
-
cb();
|
|
5636
|
-
};
|
|
5637
|
-
if (typeof document !== "undefined" && document.hidden) {
|
|
5638
|
-
queueMicrotask(run);
|
|
5639
|
-
return;
|
|
5640
|
-
}
|
|
5641
|
-
requestAnimationFrame(run);
|
|
5642
|
-
setTimeout(run, 100);
|
|
5643
|
-
}
|
|
5644
|
-
function isScrolledIntoView(el) {
|
|
5645
|
-
const rect = el.getBoundingClientRect();
|
|
5646
|
-
const elemTop = rect.top;
|
|
5647
|
-
const elemBottom = rect.bottom;
|
|
5648
|
-
return elemTop >= 0 && elemBottom <= window.innerHeight;
|
|
5649
|
-
}
|
|
5331
|
+
};
|
|
5650
5332
|
|
|
5651
|
-
//
|
|
5333
|
+
// ../platform-client/components/Heading/index.ts
|
|
5652
5334
|
init_react_import();
|
|
5653
|
-
var import_react29 = require("react");
|
|
5654
5335
|
|
|
5655
|
-
//
|
|
5336
|
+
// ../platform-client/components/Heading/Heading.tsx
|
|
5656
5337
|
init_react_import();
|
|
5657
|
-
function scrollIntoViewLocal(el, win, behavior = "smooth") {
|
|
5658
|
-
const scroller = el.ownerDocument?.scrollingElement || el.ownerDocument?.documentElement;
|
|
5659
|
-
const rect = el.getBoundingClientRect();
|
|
5660
|
-
const vpH = win.innerHeight;
|
|
5661
|
-
const current = scroller.scrollTop;
|
|
5662
|
-
const offset = win.innerHeight / 2;
|
|
5663
|
-
let targetTop = current;
|
|
5664
|
-
if (rect.top < 0) {
|
|
5665
|
-
targetTop = current + rect.top;
|
|
5666
|
-
} else if (rect.bottom > vpH) {
|
|
5667
|
-
targetTop = current + (rect.bottom - vpH);
|
|
5668
|
-
}
|
|
5669
|
-
if (targetTop !== current) {
|
|
5670
|
-
scroller.scrollTo({ top: targetTop + offset, behavior });
|
|
5671
|
-
}
|
|
5672
|
-
}
|
|
5673
5338
|
|
|
5674
|
-
//
|
|
5339
|
+
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Heading/Heading.module.css#css-module
|
|
5675
5340
|
init_react_import();
|
|
5676
|
-
var
|
|
5677
|
-
function useFrameMutationObserver(callback) {
|
|
5678
|
-
return (0, import_react28.useCallback)(() => {
|
|
5679
|
-
const frame = document?.getElementById(
|
|
5680
|
-
"preview-frame"
|
|
5681
|
-
);
|
|
5682
|
-
if (!frame) return;
|
|
5683
|
-
let observer = null;
|
|
5684
|
-
const win = frame.contentWindow;
|
|
5685
|
-
let enabled = true;
|
|
5686
|
-
const disable = () => {
|
|
5687
|
-
enabled = false;
|
|
5688
|
-
};
|
|
5689
|
-
const attachObserver = () => {
|
|
5690
|
-
const win2 = frame.contentWindow;
|
|
5691
|
-
const doc = frame.contentDocument || win2?.document;
|
|
5692
|
-
if (!win2 || !doc) return;
|
|
5693
|
-
const target = doc.querySelector("#frame-root > div");
|
|
5694
|
-
if (!target) return;
|
|
5695
|
-
observer = new MutationObserver((entries) => {
|
|
5696
|
-
if (enabled) {
|
|
5697
|
-
callback(entries, win2);
|
|
5698
|
-
}
|
|
5699
|
-
});
|
|
5700
|
-
observer?.observe(target, { childList: true, subtree: true });
|
|
5701
|
-
win2.addEventListener("pointerdown", disable);
|
|
5702
|
-
win2.addEventListener("mousewheel", disable);
|
|
5703
|
-
};
|
|
5704
|
-
if (frame.contentDocument?.readyState === "complete") {
|
|
5705
|
-
attachObserver();
|
|
5706
|
-
} else {
|
|
5707
|
-
frame.addEventListener("load", attachObserver, { once: true });
|
|
5708
|
-
}
|
|
5709
|
-
return () => {
|
|
5710
|
-
frame.removeEventListener("load", attachObserver);
|
|
5711
|
-
win?.removeEventListener("pointerdown", disable);
|
|
5712
|
-
win?.removeEventListener("mousewheel", disable);
|
|
5713
|
-
observer?.disconnect();
|
|
5714
|
-
};
|
|
5715
|
-
}, [callback]);
|
|
5716
|
-
}
|
|
5341
|
+
var Heading_module_default = { "Heading": "_Heading_l89dy_1", "Heading--brand": "_Heading--brand_l89dy_15", "Heading--xxxxl": "_Heading--xxxxl_l89dy_26", "Heading--xxxl": "_Heading--xxxl_l89dy_33", "Heading--xxl": "_Heading--xxl_l89dy_40", "Heading--xl": "_Heading--xl_l89dy_47", "Heading--l": "_Heading--l_l89dy_54", "Heading--m": "_Heading--m_l89dy_58", "Heading--s": "_Heading--s_l89dy_62", "Heading--xs": "_Heading--xs_l89dy_69", "Heading--xxs": "_Heading--xxs_l89dy_76" };
|
|
5717
5342
|
|
|
5718
|
-
//
|
|
5719
|
-
var
|
|
5343
|
+
// ../platform-client/components/Heading/Heading.tsx
|
|
5344
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
5345
|
+
var getClassName6 = get_class_name_factory_default("Heading", Heading_module_default);
|
|
5346
|
+
var Heading = ({
|
|
5720
5347
|
children,
|
|
5721
|
-
|
|
5348
|
+
rank,
|
|
5349
|
+
size = "m",
|
|
5350
|
+
variant = "default"
|
|
5722
5351
|
}) => {
|
|
5723
|
-
const
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
const follow = useFrameMutationObserver((records, win) => {
|
|
5733
|
-
if (!enabledRef.current) return;
|
|
5734
|
-
if (records.length > 0) {
|
|
5735
|
-
const lastRecord = records[records.length - 1];
|
|
5736
|
-
if (followedRefs.current.includes(lastRecord.target)) return;
|
|
5737
|
-
followedRefs.current.push(lastRecord.target);
|
|
5738
|
-
requestAnimationFrame(() => {
|
|
5739
|
-
const el = lastRecord.target;
|
|
5740
|
-
scrollIntoViewLocal(el, win);
|
|
5741
|
-
});
|
|
5352
|
+
const Tag = rank ? `h${rank}` : "span";
|
|
5353
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5354
|
+
Tag,
|
|
5355
|
+
{
|
|
5356
|
+
className: getClassName6({
|
|
5357
|
+
[size]: true,
|
|
5358
|
+
brand: variant === "brand"
|
|
5359
|
+
}),
|
|
5360
|
+
children
|
|
5742
5361
|
}
|
|
5743
|
-
|
|
5744
|
-
(0, import_react29.useEffect)(() => {
|
|
5745
|
-
follow();
|
|
5746
|
-
}, [follow]);
|
|
5747
|
-
return children;
|
|
5362
|
+
);
|
|
5748
5363
|
};
|
|
5749
5364
|
|
|
5750
|
-
//
|
|
5365
|
+
// ../platform-client/components/ActionModal/ActionModal.tsx
|
|
5366
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
5367
|
+
var getClassName7 = getClassNameFactory("ActionModal", ActionModal_module_default);
|
|
5368
|
+
var ActionModalFooter = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName7("footer"), children });
|
|
5369
|
+
var ActionModal = ({
|
|
5370
|
+
actionLabel = "Open",
|
|
5371
|
+
children,
|
|
5372
|
+
title,
|
|
5373
|
+
description,
|
|
5374
|
+
actions,
|
|
5375
|
+
hideButton
|
|
5376
|
+
}) => {
|
|
5377
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Modal, { actionLabel, hideButton, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassName7(), children: [
|
|
5378
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassName7("header"), children: [
|
|
5379
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Heading, { size: "s", children: title }),
|
|
5380
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("small", { children: description })
|
|
5381
|
+
] }),
|
|
5382
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName7("body"), children }),
|
|
5383
|
+
actions && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(ActionModalFooter, { children: actions })
|
|
5384
|
+
] }) });
|
|
5385
|
+
};
|
|
5386
|
+
ActionModal.Footer = ActionModalFooter;
|
|
5387
|
+
|
|
5388
|
+
// ../platform-client/components/Inline/index.ts
|
|
5751
5389
|
init_react_import();
|
|
5752
|
-
var import_core7 = require("@puckeditor/core");
|
|
5753
5390
|
|
|
5754
|
-
//
|
|
5391
|
+
// ../platform-client/components/Inline/Inline.tsx
|
|
5392
|
+
init_react_import();
|
|
5393
|
+
|
|
5394
|
+
// css-module:/home/runner/work/platform/platform/packages/platform-client/components/Inline/Inline.module.css#css-module
|
|
5395
|
+
init_react_import();
|
|
5396
|
+
var Inline_module_default = { "Inline": "_Inline_6o5on_3", "Inline-inner": "_Inline-inner_6o5on_7", "Inline--noWrap": "_Inline--noWrap_6o5on_12", "Inline--sizeNONE": "_Inline--sizeNONE_6o5on_16", "Inline--sizeXXS": "_Inline--sizeXXS_6o5on_20", "Inline--sizeXS": "_Inline--sizeXS_6o5on_24", "Inline--sizeS": "_Inline--sizeS_6o5on_28", "Inline--sizeM": "_Inline--sizeM_6o5on_32", "Inline--sizeL": "_Inline--sizeL_6o5on_36", "Inline--center": "_Inline--center_6o5on_40", "Inline--centerH": "_Inline--centerH_6o5on_44", "Inline--grow": "_Inline--grow_6o5on_48" };
|
|
5397
|
+
|
|
5398
|
+
// ../platform-client/components/Inline/Inline.tsx
|
|
5399
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5400
|
+
var getClassName8 = get_class_name_factory_default("Inline", Inline_module_default);
|
|
5401
|
+
var Inline = ({
|
|
5402
|
+
children,
|
|
5403
|
+
grow,
|
|
5404
|
+
center,
|
|
5405
|
+
size = "m",
|
|
5406
|
+
noWrap,
|
|
5407
|
+
centerH
|
|
5408
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5409
|
+
"div",
|
|
5410
|
+
{
|
|
5411
|
+
className: getClassName8({
|
|
5412
|
+
grow,
|
|
5413
|
+
center,
|
|
5414
|
+
centerH,
|
|
5415
|
+
noWrap,
|
|
5416
|
+
[`size${size.toUpperCase()}`]: size
|
|
5417
|
+
}),
|
|
5418
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassName8("inner"), children })
|
|
5419
|
+
}
|
|
5420
|
+
);
|
|
5421
|
+
var InlineItem = ({
|
|
5422
|
+
children,
|
|
5423
|
+
grow,
|
|
5424
|
+
push,
|
|
5425
|
+
shrink
|
|
5426
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
5427
|
+
"div",
|
|
5428
|
+
{
|
|
5429
|
+
style: {
|
|
5430
|
+
flexGrow: grow ? typeof grow === "number" ? grow : "1" : "0",
|
|
5431
|
+
flexShrink: shrink ? "1" : "0",
|
|
5432
|
+
marginLeft: push ? "auto" : 0,
|
|
5433
|
+
maxWidth: "100%"
|
|
5434
|
+
},
|
|
5435
|
+
children
|
|
5436
|
+
}
|
|
5437
|
+
);
|
|
5438
|
+
Inline.Item = InlineItem;
|
|
5439
|
+
|
|
5440
|
+
// ../platform-client/components/Modal/index.ts
|
|
5755
5441
|
init_react_import();
|
|
5756
|
-
var import_core6 = require("@puckeditor/core");
|
|
5757
|
-
var import_react30 = require("react");
|
|
5758
5442
|
|
|
5759
5443
|
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/ManageComponents/styles.module.css#css-module
|
|
5760
5444
|
init_react_import();
|
|
5761
|
-
var
|
|
5445
|
+
var styles_module_default7 = { "ManageComponents-cta": "_ManageComponents-cta_iejpb_1", "ManageComponents-list": "_ManageComponents-list_iejpb_25", "ManageComponents-item": "_ManageComponents-item_iejpb_32", "ManageComponents-delete": "_ManageComponents-delete_iejpb_47", "ManageComponents-empty": "_ManageComponents-empty_iejpb_70", "ManageComponents-confirmation": "_ManageComponents-confirmation_iejpb_75" };
|
|
5762
5446
|
|
|
5763
5447
|
// src/components/ManageComponents/index.tsx
|
|
5764
|
-
var
|
|
5765
|
-
var
|
|
5766
|
-
var useRegistrations = () => (0,
|
|
5448
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
5449
|
+
var cx5 = getClassNameFactory("ManageComponents", styles_module_default7);
|
|
5450
|
+
var useRegistrations = () => (0, import_react23.useSyncExternalStore)(
|
|
5767
5451
|
registrationStore.subscribe,
|
|
5768
5452
|
() => registrationStore.getAll(),
|
|
5769
5453
|
() => registrationStore.getAll()
|
|
5770
5454
|
);
|
|
5771
5455
|
function ManageModalContent({ onClose }) {
|
|
5772
|
-
const getPuck = (0,
|
|
5456
|
+
const getPuck = (0, import_core5.useGetPuck)();
|
|
5773
5457
|
const { visible, setVisible } = useModal();
|
|
5774
|
-
const [confirmTarget, setConfirmTarget] = (0,
|
|
5458
|
+
const [confirmTarget, setConfirmTarget] = (0, import_react23.useState)(null);
|
|
5775
5459
|
const entries = useRegistrations();
|
|
5776
|
-
(0,
|
|
5460
|
+
(0, import_react23.useEffect)(() => {
|
|
5777
5461
|
if (!visible) onClose();
|
|
5778
5462
|
}, [visible, onClose]);
|
|
5779
5463
|
const handleDelete = (name) => {
|
|
@@ -5784,14 +5468,14 @@ function ManageModalContent({ onClose }) {
|
|
|
5784
5468
|
}
|
|
5785
5469
|
};
|
|
5786
5470
|
if (confirmTarget) {
|
|
5787
|
-
return /* @__PURE__ */ (0,
|
|
5471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5788
5472
|
ActionModal,
|
|
5789
5473
|
{
|
|
5790
5474
|
title: "Delete component",
|
|
5791
5475
|
hideButton: true,
|
|
5792
|
-
actions: /* @__PURE__ */ (0,
|
|
5793
|
-
/* @__PURE__ */ (0,
|
|
5794
|
-
/* @__PURE__ */ (0,
|
|
5476
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Inline, { children: [
|
|
5477
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, { variant: "secondary", onClick: () => setConfirmTarget(null), children: "Cancel" }),
|
|
5478
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
5795
5479
|
Button,
|
|
5796
5480
|
{
|
|
5797
5481
|
variant: "danger",
|
|
@@ -5800,68 +5484,68 @@ function ManageModalContent({ onClose }) {
|
|
|
5800
5484
|
}
|
|
5801
5485
|
)
|
|
5802
5486
|
] }),
|
|
5803
|
-
children: /* @__PURE__ */ (0,
|
|
5487
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("p", { className: cx5("confirmation"), children: [
|
|
5804
5488
|
"Are you sure you want to delete ",
|
|
5805
|
-
/* @__PURE__ */ (0,
|
|
5489
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("b", { children: confirmTarget.label }),
|
|
5806
5490
|
"?"
|
|
5807
5491
|
] })
|
|
5808
5492
|
}
|
|
5809
5493
|
);
|
|
5810
5494
|
}
|
|
5811
|
-
return /* @__PURE__ */ (0,
|
|
5812
|
-
entries.map(([name, reg]) => /* @__PURE__ */ (0,
|
|
5813
|
-
/* @__PURE__ */ (0,
|
|
5814
|
-
/* @__PURE__ */ (0,
|
|
5495
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ActionModal, { title: "Manage components", hideButton: true, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: cx5("list"), children: [
|
|
5496
|
+
entries.map(([name, reg]) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: cx5("item"), children: [
|
|
5497
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: cx5("itemName"), children: reg.label || name }),
|
|
5498
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
5815
5499
|
"button",
|
|
5816
5500
|
{
|
|
5817
|
-
className:
|
|
5501
|
+
className: cx5("delete"),
|
|
5818
5502
|
onClick: () => setConfirmTarget({ name, label: reg.label || name }),
|
|
5819
5503
|
type: "button",
|
|
5820
5504
|
children: [
|
|
5821
|
-
/* @__PURE__ */ (0,
|
|
5505
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Trash2, { size: 12 }),
|
|
5822
5506
|
"Delete"
|
|
5823
5507
|
]
|
|
5824
5508
|
}
|
|
5825
5509
|
)
|
|
5826
5510
|
] }, name)),
|
|
5827
|
-
entries.length === 0 && /* @__PURE__ */ (0,
|
|
5511
|
+
entries.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: cx5("empty"), children: "No dynamic components" })
|
|
5828
5512
|
] }) });
|
|
5829
5513
|
}
|
|
5830
5514
|
function ManageComponentsCta() {
|
|
5831
|
-
const [open, setOpen] = (0,
|
|
5515
|
+
const [open, setOpen] = (0, import_react23.useState)(false);
|
|
5832
5516
|
const entries = useRegistrations();
|
|
5833
|
-
const handleClose = (0,
|
|
5517
|
+
const handleClose = (0, import_react23.useCallback)(() => setOpen(false), []);
|
|
5834
5518
|
if (entries.length === 0) return null;
|
|
5835
|
-
return /* @__PURE__ */ (0,
|
|
5836
|
-
/* @__PURE__ */ (0,
|
|
5837
|
-
/* @__PURE__ */ (0,
|
|
5519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
5520
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("button", { className: cx5("cta"), onClick: () => setOpen(true), type: "button", children: [
|
|
5521
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Settings, { size: 14 }),
|
|
5838
5522
|
"Manage components"
|
|
5839
5523
|
] }),
|
|
5840
|
-
open && /* @__PURE__ */ (0,
|
|
5524
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ModalProvider, { defaultVisible: true, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ManageModalContent, { onClose: handleClose }) })
|
|
5841
5525
|
] });
|
|
5842
5526
|
}
|
|
5843
5527
|
|
|
5844
5528
|
// css-module:/home/runner/work/platform/platform/packages/plugin-ai/src/components/Drawer/styles.module.css#css-module
|
|
5845
5529
|
init_react_import();
|
|
5846
|
-
var
|
|
5530
|
+
var styles_module_default8 = { "Drawer": "_Drawer_1mu8g_1", "Drawer--empty": "_Drawer--empty_1mu8g_5" };
|
|
5847
5531
|
|
|
5848
5532
|
// src/components/Drawer/index.tsx
|
|
5849
|
-
var
|
|
5850
|
-
var usePuck2 = (0,
|
|
5851
|
-
var
|
|
5533
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
5534
|
+
var usePuck2 = (0, import_core6.createUsePuck)();
|
|
5535
|
+
var cx6 = getClassNameFactory("Drawer", styles_module_default8);
|
|
5852
5536
|
var createDrawer = (designModeVisible) => function Drawer({ children }) {
|
|
5853
5537
|
const config = usePuck2((s) => s.config);
|
|
5854
5538
|
if (Object.keys(config.components).length === 0) {
|
|
5855
|
-
return /* @__PURE__ */ (0,
|
|
5539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `${cx6({ empty: true })} ${pluginThemeClassName}`, children: "No blocks" });
|
|
5856
5540
|
}
|
|
5857
|
-
return /* @__PURE__ */ (0,
|
|
5541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: `${cx6()} ${pluginThemeClassName}`, children: [
|
|
5858
5542
|
children,
|
|
5859
|
-
designModeVisible && /* @__PURE__ */ (0,
|
|
5543
|
+
designModeVisible && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ManageComponentsCta, {})
|
|
5860
5544
|
] });
|
|
5861
5545
|
};
|
|
5862
5546
|
|
|
5863
5547
|
// src/index.tsx
|
|
5864
|
-
var
|
|
5548
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
5865
5549
|
function withDynamicConfig(config, data) {
|
|
5866
5550
|
const registrations = getPersistedRegistrations(data);
|
|
5867
5551
|
const dynamicConfig = {};
|
|
@@ -5898,16 +5582,16 @@ function createAiPlugin(opts) {
|
|
|
5898
5582
|
return {
|
|
5899
5583
|
label: "AI",
|
|
5900
5584
|
name: "ai",
|
|
5901
|
-
render: () => /* @__PURE__ */ (0,
|
|
5902
|
-
icon: /* @__PURE__ */ (0,
|
|
5585
|
+
render: () => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Chat2, { ...rest, scrollTrackingId }),
|
|
5586
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Bot, {}),
|
|
5903
5587
|
mobilePanelHeight: "min-content",
|
|
5904
5588
|
overrides: {
|
|
5905
5589
|
drawer: createDrawer(designModeVisible),
|
|
5906
5590
|
preview: ({ children }) => {
|
|
5907
5591
|
if (scrollTracking) {
|
|
5908
|
-
return /* @__PURE__ */ (0,
|
|
5592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ScrollTracking, { trackingId: scrollTrackingId, children });
|
|
5909
5593
|
}
|
|
5910
|
-
return /* @__PURE__ */ (0,
|
|
5594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
|
|
5911
5595
|
}
|
|
5912
5596
|
}
|
|
5913
5597
|
};
|