@yoamigo.com/core 0.4.6 → 0.4.8
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.js +42 -11
- package/dist/prod.js +8 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1124,7 +1124,7 @@ function ContentStoreProvider({
|
|
|
1124
1124
|
const defaultContent = initialContent ?? getAllContent2();
|
|
1125
1125
|
const defaultMode = initialMode ?? (isBuilderPreview() ? "inline-edit" : "read-only");
|
|
1126
1126
|
const [content, setContent] = useState(
|
|
1127
|
-
new Map(Object.entries(defaultContent))
|
|
1127
|
+
() => new Map(Object.entries(defaultContent))
|
|
1128
1128
|
);
|
|
1129
1129
|
const [mode, setModeState] = useState(defaultMode);
|
|
1130
1130
|
const [listeners, setListeners] = useState(/* @__PURE__ */ new Set());
|
|
@@ -1264,21 +1264,49 @@ function ContentStoreProvider({
|
|
|
1264
1264
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
1265
1265
|
};
|
|
1266
1266
|
}, [activeFieldId]);
|
|
1267
|
+
const getValueRef = useRef(getValue);
|
|
1268
|
+
const setValueRef = useRef(setValue);
|
|
1269
|
+
const getChangeSourceRef = useRef(getChangeSource);
|
|
1270
|
+
const setModeRef = useRef(setMode);
|
|
1271
|
+
const subscribeRef = useRef(subscribe);
|
|
1272
|
+
const saveToWorkerRef = useRef(saveToWorker);
|
|
1273
|
+
const modeRef = useRef(mode);
|
|
1274
|
+
useEffect(() => {
|
|
1275
|
+
getValueRef.current = getValue;
|
|
1276
|
+
}, [getValue]);
|
|
1277
|
+
useEffect(() => {
|
|
1278
|
+
setValueRef.current = setValue;
|
|
1279
|
+
}, [setValue]);
|
|
1280
|
+
useEffect(() => {
|
|
1281
|
+
getChangeSourceRef.current = getChangeSource;
|
|
1282
|
+
}, [getChangeSource]);
|
|
1283
|
+
useEffect(() => {
|
|
1284
|
+
setModeRef.current = setMode;
|
|
1285
|
+
}, [setMode]);
|
|
1286
|
+
useEffect(() => {
|
|
1287
|
+
subscribeRef.current = subscribe;
|
|
1288
|
+
}, [subscribe]);
|
|
1289
|
+
useEffect(() => {
|
|
1290
|
+
saveToWorkerRef.current = saveToWorker;
|
|
1291
|
+
}, [saveToWorker]);
|
|
1292
|
+
useEffect(() => {
|
|
1293
|
+
modeRef.current = mode;
|
|
1294
|
+
}, [mode]);
|
|
1267
1295
|
useEffect(() => {
|
|
1268
1296
|
;
|
|
1269
|
-
window.
|
|
1270
|
-
getValue,
|
|
1271
|
-
setValue,
|
|
1272
|
-
getChangeSource,
|
|
1273
|
-
getMode: () =>
|
|
1274
|
-
setMode,
|
|
1275
|
-
subscribe,
|
|
1276
|
-
saveToWorker
|
|
1297
|
+
window.yaContentStore = {
|
|
1298
|
+
getValue: (fieldId) => getValueRef.current(fieldId),
|
|
1299
|
+
setValue: (fieldId, value2, source) => setValueRef.current(fieldId, value2, source),
|
|
1300
|
+
getChangeSource: (fieldId) => getChangeSourceRef.current(fieldId),
|
|
1301
|
+
getMode: () => modeRef.current,
|
|
1302
|
+
setMode: (mode2) => setModeRef.current(mode2),
|
|
1303
|
+
subscribe: (listener) => subscribeRef.current(listener),
|
|
1304
|
+
saveToWorker: saveToWorkerRef.current ? (fieldId, value2) => saveToWorkerRef.current?.(fieldId, value2) : void 0
|
|
1277
1305
|
};
|
|
1278
1306
|
return () => {
|
|
1279
|
-
delete window.
|
|
1307
|
+
delete window.yaContentStore;
|
|
1280
1308
|
};
|
|
1281
|
-
}, [
|
|
1309
|
+
}, []);
|
|
1282
1310
|
const getPages = useCallback(() => pages, [pages]);
|
|
1283
1311
|
const value = {
|
|
1284
1312
|
getValue,
|
|
@@ -1902,6 +1930,9 @@ function useAIEditAnimation(fieldId, value, options) {
|
|
|
1902
1930
|
if (!strategy.canAnimate(oldValue, newValue)) {
|
|
1903
1931
|
setDisplayValue(newValue);
|
|
1904
1932
|
previousValueRef.current = newValue;
|
|
1933
|
+
if (phase === "animating") {
|
|
1934
|
+
setPhase("idle");
|
|
1935
|
+
}
|
|
1905
1936
|
return;
|
|
1906
1937
|
}
|
|
1907
1938
|
if (animationFrameRef.current !== null) {
|
package/dist/prod.js
CHANGED
|
@@ -197,9 +197,9 @@ function StaticLink({ fieldId, href: defaultHref = "#", className, style, as: Co
|
|
|
197
197
|
const storeText = getValue(textFieldId);
|
|
198
198
|
const storeHref = getValue(hrefFieldId);
|
|
199
199
|
const href = storeHref || defaultHref;
|
|
200
|
+
const isIconMode = children != null && typeof children !== "string";
|
|
200
201
|
const hasStoreText = Boolean(storeText);
|
|
201
202
|
const hasStringChildren = typeof children === "string";
|
|
202
|
-
const hasReactChildren = children && !hasStringChildren;
|
|
203
203
|
const handleClick = (e) => {
|
|
204
204
|
if (href.startsWith("#")) {
|
|
205
205
|
e.preventDefault();
|
|
@@ -233,7 +233,13 @@ function StaticLink({ fieldId, href: defaultHref = "#", className, style, as: Co
|
|
|
233
233
|
style,
|
|
234
234
|
"data-ya-restricted": "true",
|
|
235
235
|
"data-field-id": fieldId,
|
|
236
|
-
children:
|
|
236
|
+
children: isIconMode ? (
|
|
237
|
+
// Icon mode: render React children directly (SVGs, icons, etc.)
|
|
238
|
+
children
|
|
239
|
+
) : hasStoreText || hasStringChildren ? (
|
|
240
|
+
// Text mode: render store text or string children via SafeHtml
|
|
241
|
+
/* @__PURE__ */ jsx5(SafeHtml, { content: storeText || children || "", mode })
|
|
242
|
+
) : null
|
|
237
243
|
}
|
|
238
244
|
);
|
|
239
245
|
}
|