react-intlayer 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/UI/ContentSelector.cjs +126 -0
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -0
- package/dist/cjs/client/IntlayerProvider.cjs +5 -1
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/{utils/PoweredByMeta/index.cjs → client/PoweredByMeta.cjs} +10 -5
- package/dist/cjs/client/PoweredByMeta.cjs.map +1 -0
- package/dist/cjs/editor/ContentSelectorWrapper.cjs +51 -2
- package/dist/cjs/editor/ContentSelectorWrapper.cjs.map +1 -1
- package/dist/cjs/editor/IntlayerEditorProvider.cjs +41 -6
- package/dist/cjs/editor/IntlayerEditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/index.cjs +0 -2
- package/dist/cjs/editor/index.cjs.map +1 -1
- package/dist/cjs/editor/renderContentEditor.cjs +4 -24
- package/dist/cjs/editor/renderContentEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +4 -31
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +2 -2
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/getIntlayerAsync.cjs +2 -2
- package/dist/cjs/getIntlayerAsync.cjs.map +1 -1
- package/dist/cjs/recursiveTransformContent.cjs +54 -0
- package/dist/cjs/recursiveTransformContent.cjs.map +1 -0
- package/dist/esm/UI/ContentSelector.mjs +107 -0
- package/dist/esm/UI/ContentSelector.mjs.map +1 -0
- package/dist/esm/client/IntlayerProvider.mjs +6 -2
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/PoweredByMeta.mjs +21 -0
- package/dist/esm/client/PoweredByMeta.mjs.map +1 -0
- package/dist/esm/editor/ContentSelectorWrapper.mjs +60 -2
- package/dist/esm/editor/ContentSelectorWrapper.mjs.map +1 -1
- package/dist/esm/editor/IntlayerEditorProvider.mjs +38 -7
- package/dist/esm/editor/IntlayerEditorProvider.mjs.map +1 -1
- package/dist/esm/editor/index.mjs +0 -1
- package/dist/esm/editor/index.mjs.map +1 -1
- package/dist/esm/editor/renderContentEditor.mjs +6 -24
- package/dist/esm/editor/renderContentEditor.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs +4 -30
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs +2 -2
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/getIntlayerAsync.mjs +1 -1
- package/dist/esm/getIntlayerAsync.mjs.map +1 -1
- package/dist/esm/recursiveTransformContent.mjs +32 -0
- package/dist/esm/recursiveTransformContent.mjs.map +1 -0
- package/dist/types/UI/ContentSelector.d.ts +10 -0
- package/dist/types/UI/ContentSelector.d.ts.map +1 -0
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/{utils/PoweredByMeta/index.d.ts → client/PoweredByMeta.d.ts} +1 -1
- package/dist/types/client/PoweredByMeta.d.ts.map +1 -0
- package/dist/types/editor/ContentSelectorWrapper.d.ts +5 -3
- package/dist/types/editor/ContentSelectorWrapper.d.ts.map +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts +1 -1
- package/dist/types/editor/IntlayerEditorProvider.d.ts.map +1 -1
- package/dist/types/editor/index.d.ts +0 -1
- package/dist/types/editor/index.d.ts.map +1 -1
- package/dist/types/editor/renderContentEditor.d.ts +5 -9
- package/dist/types/editor/renderContentEditor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +3 -25
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +3 -3
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/getIntlayerAsync.d.ts.map +1 -1
- package/dist/types/recursiveTransformContent.d.ts +27 -0
- package/dist/types/recursiveTransformContent.d.ts.map +1 -0
- package/package.json +16 -13
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs +0 -59
- package/dist/cjs/distantDictionary/fetchDistantDictionary.cjs.map +0 -1
- package/dist/cjs/editor/ContentSelectorConnector.cjs +0 -58
- package/dist/cjs/editor/ContentSelectorConnector.cjs.map +0 -1
- package/dist/cjs/utils/PoweredByMeta/index.cjs.map +0 -1
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs +0 -35
- package/dist/esm/distantDictionary/fetchDistantDictionary.mjs.map +0 -1
- package/dist/esm/editor/ContentSelectorConnector.mjs +0 -38
- package/dist/esm/editor/ContentSelectorConnector.mjs.map +0 -1
- package/dist/esm/utils/PoweredByMeta/index.mjs +0 -16
- package/dist/esm/utils/PoweredByMeta/index.mjs.map +0 -1
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts +0 -6
- package/dist/types/distantDictionary/fetchDistantDictionary.d.ts.map +0 -1
- package/dist/types/editor/ContentSelectorConnector.d.ts +0 -14
- package/dist/types/editor/ContentSelectorConnector.d.ts.map +0 -1
- package/dist/types/utils/PoweredByMeta/index.d.ts.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var recursiveTransformContent_exports = {};
|
|
20
|
+
__export(recursiveTransformContent_exports, {
|
|
21
|
+
recursiveTransformContent: () => recursiveTransformContent
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(recursiveTransformContent_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
var import_renderContentEditor = require('./editor/renderContentEditor.cjs');
|
|
26
|
+
const recursiveTransformContent = (value, isRenderEditor = false) => {
|
|
27
|
+
if (typeof value === "function") {
|
|
28
|
+
return (props) => recursiveTransformContent(value(props), isRenderEditor);
|
|
29
|
+
} else if (typeof value === "object") {
|
|
30
|
+
if (typeof value.dictionaryKey !== "undefined") {
|
|
31
|
+
if (isRenderEditor) {
|
|
32
|
+
return (0, import_renderContentEditor.renderIntlayerEditor)(value);
|
|
33
|
+
}
|
|
34
|
+
return value.content;
|
|
35
|
+
} else if (Array.isArray(value)) {
|
|
36
|
+
return value.map((el) => recursiveTransformContent(el, isRenderEditor));
|
|
37
|
+
} else if ((0, import_react.isValidElement)(value)) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
return Object.entries(value).reduce(
|
|
41
|
+
(acc, [key, value2]) => ({
|
|
42
|
+
...acc,
|
|
43
|
+
[key]: recursiveTransformContent(value2, isRenderEditor)
|
|
44
|
+
}),
|
|
45
|
+
{}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
recursiveTransformContent
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=recursiveTransformContent.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/recursiveTransformContent.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type { NodeType } from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport {\n type IntlayerNode,\n renderIntlayerEditor,\n} from './editor/renderContentEditor';\n\ntype TransformNodeType<T, L extends Locales, R extends boolean> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (\n quantity: number\n ) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L, R>\n : never\n : T;\n\nexport type DeepTransformContent<\n T,\n L extends Locales,\n R extends boolean,\n> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L, R>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L, R>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L, R>;\n }\n : T extends undefined\n ? never\n : R extends true\n ? IntlayerNode<T>\n : T;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isRenderEditor = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isRenderEditor);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryKey !== 'undefined') {\n if (isRenderEditor) {\n return renderIntlayerEditor(value);\n }\n return value.content;\n } else if (Array.isArray(value)) {\n return value.map((el) => recursiveTransformContent(el, isRenderEditor));\n } else if (isValidElement(value)) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value, isRenderEditor),\n }),\n {} as object\n );\n }\n\n return value;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAA+C;AAC/C,iCAGO;AAyCA,MAAM,4BAA4B,CACvC,OACA,iBAAiB,UACN;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,cAAc;AAAA,EAC1D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,kBAAkB,aAAa;AAC9C,UAAI,gBAAgB;AAClB,mBAAO,iDAAqB,KAAK;AAAA,MACnC;AACA,aAAO,MAAM;AAAA,IACf,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM,IAAI,CAAC,OAAO,0BAA0B,IAAI,cAAc,CAAC;AAAA,IACxE,eAAW,6BAAe,KAAK,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,QAAO,cAAc;AAAA,MACxD;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":["value"]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useState,
|
|
6
|
+
useRef,
|
|
7
|
+
useCallback
|
|
8
|
+
} from "react";
|
|
9
|
+
const DEFAULT_PRESS_DETECT_DURATION = 400;
|
|
10
|
+
const ContentSelector = ({
|
|
11
|
+
children,
|
|
12
|
+
onPress: onSelect,
|
|
13
|
+
onClickOutside: onUnselect,
|
|
14
|
+
pressDuration = DEFAULT_PRESS_DETECT_DURATION,
|
|
15
|
+
isSelecting: isSelectingProp,
|
|
16
|
+
...props
|
|
17
|
+
}) => {
|
|
18
|
+
const divRef = useRef(null);
|
|
19
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
20
|
+
const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);
|
|
21
|
+
const pressTimerRef = useRef(null);
|
|
22
|
+
const handleOnLongPress = () => {
|
|
23
|
+
setIsSelectingState(true);
|
|
24
|
+
onSelect();
|
|
25
|
+
};
|
|
26
|
+
const startPressTimer = () => {
|
|
27
|
+
pressTimerRef.current = setTimeout(() => {
|
|
28
|
+
handleOnLongPress();
|
|
29
|
+
}, pressDuration);
|
|
30
|
+
};
|
|
31
|
+
const clearPressTimer = () => {
|
|
32
|
+
if (pressTimerRef.current) {
|
|
33
|
+
clearTimeout(pressTimerRef.current);
|
|
34
|
+
pressTimerRef.current = null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const handleMouseDown = () => {
|
|
38
|
+
clearPressTimer();
|
|
39
|
+
startPressTimer();
|
|
40
|
+
};
|
|
41
|
+
const handleMouseEnter = () => {
|
|
42
|
+
setIsHovered(true);
|
|
43
|
+
};
|
|
44
|
+
const handleMouseUp = () => {
|
|
45
|
+
setIsHovered(false);
|
|
46
|
+
clearPressTimer();
|
|
47
|
+
};
|
|
48
|
+
const handleClickOutside = useCallback(
|
|
49
|
+
(event) => {
|
|
50
|
+
if (divRef.current && !divRef.current.contains(event.target)) {
|
|
51
|
+
setIsSelectingState(false);
|
|
52
|
+
onUnselect?.();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
[onUnselect]
|
|
56
|
+
);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
59
|
+
return () => {
|
|
60
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
61
|
+
};
|
|
62
|
+
}, [handleClickOutside]);
|
|
63
|
+
const handleOnClick = (e) => {
|
|
64
|
+
if (isSelectingState) {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
e.stopPropagation();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const handleOnBlur = () => {
|
|
70
|
+
setIsSelectingState(false);
|
|
71
|
+
};
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
|
+
"span",
|
|
74
|
+
{
|
|
75
|
+
style: {
|
|
76
|
+
display: "inline",
|
|
77
|
+
cursor: "pointer",
|
|
78
|
+
userSelect: "none",
|
|
79
|
+
borderRadius: "0.375rem",
|
|
80
|
+
outlineWidth: "2px",
|
|
81
|
+
outlineOffset: "4px",
|
|
82
|
+
outlineStyle: "solid",
|
|
83
|
+
outlineColor: isSelectingProp || isSelectingState || isHovered ? "inherit" : "transparent",
|
|
84
|
+
transition: "all 200ms 100ms ease-in-out"
|
|
85
|
+
},
|
|
86
|
+
role: "button",
|
|
87
|
+
tabIndex: 0,
|
|
88
|
+
onKeyUp: () => null,
|
|
89
|
+
onClick: handleOnClick,
|
|
90
|
+
onMouseDown: handleMouseDown,
|
|
91
|
+
onMouseUp: handleMouseUp,
|
|
92
|
+
onMouseLeave: handleMouseUp,
|
|
93
|
+
onTouchStart: handleMouseDown,
|
|
94
|
+
onTouchEnd: handleMouseUp,
|
|
95
|
+
onTouchCancel: handleMouseUp,
|
|
96
|
+
onBlur: handleOnBlur,
|
|
97
|
+
onMouseEnter: handleMouseEnter,
|
|
98
|
+
ref: divRef,
|
|
99
|
+
...props,
|
|
100
|
+
children
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
export {
|
|
105
|
+
ContentSelector
|
|
106
|
+
};
|
|
107
|
+
//# sourceMappingURL=ContentSelector.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 400;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelector: FC<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n };\n\n const handleMouseUp = () => {\n setIsHovered(false);\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: 'inline',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 200ms 100ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";AAqGI;AAnGJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEP,MAAM,gCAAgC;AAS/B,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACJ,QAAM,SAAS,OAAuB,IAAI;AAC1C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,eAAe;AACxE,QAAM,gBAAgB,OAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACxB,aAAS;AAAA,EACX;AAEA,QAAM,kBAAkB,MAAM;AAC5B,kBAAc,UAAU,WAAW,MAAM;AACvC,wBAAkB;AAAA,IACpB,GAAG,aAAa;AAAA,EAClB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,kBAAkB,MAAM;AAC5B,oBAAgB;AAChB,oBAAgB;AAAA,EAClB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,iBAAa,IAAI;AAAA,EACnB;AAEA,QAAM,gBAAgB,MAAM;AAC1B,iBAAa,KAAK;AAClB,oBAAgB;AAAA,EAClB;AAGA,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAAsB;AACrB,UAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,4BAAoB,KAAK;AACzB,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,YAAU,MAAM;AAEd,aAAS,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAE9D;AAAA,EACF,GAAG,CAAC,kBAAkB,CAAC;AAEvB,QAAM,gBAAmD,CAAC,MAAM;AAC9D,QAAI,kBAAkB;AACpB,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IACpB;AAAA,EACF;AAEA,QAAM,eAAe,MAAM;AAEzB,wBAAoB,KAAK;AAAA,EAC3B;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,cAAc;AAAA,QACd,eAAe;AAAA,QACf,cAAc;AAAA,QACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;AAAA,QACN,YAAY;AAAA,MACd;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,cAAc;AAAA,MACd,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { getConfiguration } from "@intlayer/config/client";
|
|
4
4
|
import {
|
|
5
5
|
createContext,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "react";
|
|
11
11
|
import { localeCookie, setLocaleCookie } from './useLocaleCookie.mjs';
|
|
12
12
|
import { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider.mjs';
|
|
13
|
+
import { PoweredByMeta } from './PoweredByMeta.mjs';
|
|
13
14
|
const IntlayerClientContext = createContext({
|
|
14
15
|
locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,
|
|
15
16
|
setLocale: () => null
|
|
@@ -42,7 +43,10 @@ const IntlayerProvider = ({
|
|
|
42
43
|
() => ({ locale: currentLocale, setLocale }),
|
|
43
44
|
[currentLocale, setLocale]
|
|
44
45
|
);
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
+
return /* @__PURE__ */ jsxs(IntlayerClientContext.Provider, { value, children: [
|
|
47
|
+
/* @__PURE__ */ jsx(PoweredByMeta, {}),
|
|
48
|
+
/* @__PURE__ */ jsx(IntlayerEditorProvider, { children })
|
|
49
|
+
] });
|
|
46
50
|
};
|
|
47
51
|
export {
|
|
48
52
|
IntlayerClientContext,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n}) => {\n const { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale: setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <IntlayerEditorProvider>{children}</IntlayerEditorProvider>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration, type Locales } from '@intlayer/config/client';\nimport {\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n type FC,\n useState,\n useCallback,\n} from 'react';\nimport { localeCookie, setLocaleCookie } from './useLocaleCookie';\nimport { IntlayerEditorProvider } from '../editor/IntlayerEditorProvider';\nimport { PoweredByMeta } from './PoweredByMeta';\n\ntype IntlayerValue = {\n locale: Locales;\n setLocale: (newLocale: Locales) => void;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeCookie ?? getConfiguration().internationalization.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext);\n\nexport type IntlayerProviderProps = PropsWithChildren & {\n locale?: Locales;\n setLocale?: (locale: Locales) => void;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProvider: FC<IntlayerProviderProps> = ({\n locale,\n children,\n setLocale: setLocaleProp,\n}) => {\n const { internationalization } = getConfiguration();\n const { defaultLocale, locales: availableLocales } = internationalization;\n\n const [currentLocale, setCurrentLocale] = useState(\n locale ?? localeCookie ?? defaultLocale\n );\n\n const setLocaleBase = useCallback(\n (newLocale: Locales) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales.includes(newLocale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleCookie(newLocale); // Optionally set cookie for persistence\n },\n [availableLocales, currentLocale, locale]\n );\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const value: IntlayerValue = useMemo<IntlayerValue>(\n () => ({ locale: currentLocale, setLocale: setLocale }),\n [currentLocale, setLocale]\n );\n\n return (\n <IntlayerClientContext.Provider value={value}>\n <PoweredByMeta />\n <IntlayerEditorProvider>{children}</IntlayerEditorProvider>\n </IntlayerClientContext.Provider>\n );\n};\n"],"mappings":";AA6EI,SACE,KADF;AA3EJ,SAAS,wBAAsC;AAC/C;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc,uBAAuB;AAC9C,SAAS,8BAA8B;AACvC,SAAS,qBAAqB;AAUvB,MAAM,wBAAwB,cAA6B;AAAA,EAChE,QAAQ,gBAAgB,iBAAiB,EAAE,qBAAqB;AAAA,EAChE,WAAW,MAAM;AACnB,CAAC;AAKM,MAAM,qBAAqB,MAAM,WAAW,qBAAqB;AAUjE,MAAM,mBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,qBAAqB,IAAI,iBAAiB;AAClD,QAAM,EAAE,eAAe,SAAS,iBAAiB,IAAI;AAErD,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC,UAAU,gBAAgB;AAAA,EAC5B;AAEA,QAAM,gBAAgB;AAAA,IACpB,CAAC,cAAuB;AACtB,UAAI,cAAc,SAAS,MAAM,UAAU,SAAS,EAAG;AAEvD,UAAI,CAAC,iBAAiB,SAAS,SAAS,GAAG;AACzC,gBAAQ,MAAM,UAAU,MAAM,mBAAmB;AACjD;AAAA,MACF;AAEA,uBAAiB,SAAS;AAC1B,sBAAgB,SAAS;AAAA,IAC3B;AAAA,IACA,CAAC,kBAAkB,eAAe,MAAM;AAAA,EAC1C;AAEA,QAAM,YAAY,iBAAiB;AAEnC,QAAM,QAAuB;AAAA,IAC3B,OAAO,EAAE,QAAQ,eAAe,UAAqB;AAAA,IACrD,CAAC,eAAe,SAAS;AAAA,EAC3B;AAEA,SACE,qBAAC,sBAAsB,UAAtB,EAA+B,OAC9B;AAAA,wBAAC,iBAAc;AAAA,IACf,oBAAC,0BAAwB,UAAS;AAAA,KACpC;AAEJ;","names":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
const PoweredByMeta = () => {
|
|
4
|
+
if (process.env.NODE_ENV !== "production") return null;
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const existingMeta = document.head.querySelector(
|
|
7
|
+
'meta[name="content-powered-by"]'
|
|
8
|
+
);
|
|
9
|
+
if (!existingMeta) {
|
|
10
|
+
const metaTag = document.createElement("meta");
|
|
11
|
+
metaTag.name = "content-powered-by";
|
|
12
|
+
metaTag.content = "Intlayer - https://intlayer.org";
|
|
13
|
+
document.head.appendChild(metaTag);
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
return null;
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
PoweredByMeta
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=PoweredByMeta.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/client/PoweredByMeta.ts"],"sourcesContent":["'use client';\n\nimport { type FC, useEffect } from 'react';\n\nexport const PoweredByMeta: FC = () => {\n if (process.env.NODE_ENV !== 'production') return null;\n\n useEffect(() => {\n // Check if the meta tag already exists\n const existingMeta = document.head.querySelector(\n 'meta[name=\"content-powered-by\"]'\n );\n\n if (!existingMeta) {\n const metaTag = document.createElement('meta');\n metaTag.name = 'content-powered-by';\n metaTag.content = 'Intlayer - https://intlayer.org';\n document.head.appendChild(metaTag);\n }\n }, []);\n\n return null; // This component does not render anything visible\n};\n"],"mappings":";AAEA,SAAkB,iBAAiB;AAE5B,MAAM,gBAAoB,MAAM;AACrC,MAAI,QAAQ,IAAI,aAAa,aAAc,QAAO;AAElD,YAAU,MAAM;AAEd,UAAM,eAAe,SAAS,KAAK;AAAA,MACjC;AAAA,IACF;AAEA,QAAI,CAAC,cAAc;AACjB,YAAM,UAAU,SAAS,cAAc,MAAM;AAC7C,cAAQ,OAAO;AACf,cAAQ,UAAU;AAClB,eAAS,KAAK,YAAY,OAAO;AAAA,IACnC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":[]}
|
|
@@ -1,7 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isSameKeyPath } from "@intlayer/core";
|
|
4
|
+
import {
|
|
5
|
+
useFocusDictionary,
|
|
6
|
+
useEditedContentActions,
|
|
7
|
+
useEditorEnabled
|
|
8
|
+
} from "@intlayer/editor-react";
|
|
9
|
+
import {
|
|
10
|
+
useCallback,
|
|
11
|
+
useEffect,
|
|
12
|
+
useState,
|
|
13
|
+
useMemo
|
|
14
|
+
} from "react";
|
|
15
|
+
import { ContentSelector } from '../UI/ContentSelector.mjs';
|
|
2
16
|
const ContentSelectorWrapper = ({
|
|
3
|
-
children
|
|
4
|
-
|
|
17
|
+
children,
|
|
18
|
+
dictionaryKey,
|
|
19
|
+
dictionaryPath,
|
|
20
|
+
keyPath,
|
|
21
|
+
...props
|
|
22
|
+
}) => {
|
|
23
|
+
const { enabled } = useEditorEnabled();
|
|
24
|
+
const { focusedContent, setFocusedContent } = useFocusDictionary();
|
|
25
|
+
const { getEditedContentValue } = useEditedContentActions();
|
|
26
|
+
const editedValue = useMemo(
|
|
27
|
+
() => getEditedContentValue(dictionaryKey, keyPath),
|
|
28
|
+
[dictionaryKey, keyPath, getEditedContentValue]
|
|
29
|
+
);
|
|
30
|
+
const [displayedChildren, setDisplayedChildren] = useState(children);
|
|
31
|
+
const handleSelect = useCallback(
|
|
32
|
+
() => setFocusedContent({
|
|
33
|
+
dictionaryKey,
|
|
34
|
+
dictionaryPath,
|
|
35
|
+
keyPath
|
|
36
|
+
}),
|
|
37
|
+
[dictionaryKey, dictionaryPath, keyPath, setFocusedContent]
|
|
38
|
+
);
|
|
39
|
+
const isSelected = useMemo(
|
|
40
|
+
() => (focusedContent?.dictionaryKey === dictionaryKey && (focusedContent?.keyPath?.length ?? 0) > 0 && isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ?? false,
|
|
41
|
+
[focusedContent, keyPath]
|
|
42
|
+
);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (editedValue && typeof editedValue === "string") {
|
|
45
|
+
setDisplayedChildren(editedValue);
|
|
46
|
+
} else {
|
|
47
|
+
setDisplayedChildren(children);
|
|
48
|
+
}
|
|
49
|
+
}, [editedValue, focusedContent, children]);
|
|
50
|
+
if (enabled) {
|
|
51
|
+
return /* @__PURE__ */ jsx(
|
|
52
|
+
ContentSelector,
|
|
53
|
+
{
|
|
54
|
+
onPress: handleSelect,
|
|
55
|
+
isSelecting: isSelected,
|
|
56
|
+
...props,
|
|
57
|
+
children: displayedChildren
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
62
|
+
};
|
|
5
63
|
export {
|
|
6
64
|
ContentSelectorWrapper
|
|
7
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/ContentSelectorWrapper.tsx"],"sourcesContent":["'use client';\n\nimport { isSameKeyPath, type KeyPath } from '@intlayer/core';\nimport {\n useFocusDictionary,\n useEditedContentActions,\n useEditorEnabled,\n} from '@intlayer/editor-react';\nimport {\n useCallback,\n useEffect,\n useState,\n useMemo,\n type FC,\n type ReactNode,\n HTMLAttributes,\n} from 'react';\nimport { ContentSelector } from '../UI/ContentSelector';\n\ntype ContentData = {\n dictionaryKey: string;\n dictionaryPath: string;\n keyPath: KeyPath[];\n};\n\nexport type ContentSelectorWrapperProps = ContentData &\n HTMLAttributes<HTMLDivElement>;\n\nexport const ContentSelectorWrapper: FC<ContentSelectorWrapperProps> = ({\n children,\n dictionaryKey,\n dictionaryPath,\n keyPath,\n ...props\n}) => {\n const { enabled } = useEditorEnabled();\n const { focusedContent, setFocusedContent } = useFocusDictionary();\n const { getEditedContentValue } = useEditedContentActions();\n\n const editedValue = useMemo(\n () => getEditedContentValue(dictionaryKey, keyPath),\n [dictionaryKey, keyPath, getEditedContentValue]\n );\n\n const [displayedChildren, setDisplayedChildren] =\n useState<ReactNode>(children);\n\n const handleSelect = useCallback(\n () =>\n setFocusedContent({\n dictionaryKey,\n dictionaryPath,\n keyPath,\n }),\n [dictionaryKey, dictionaryPath, keyPath, setFocusedContent]\n );\n\n const isSelected = useMemo(\n () =>\n (focusedContent?.dictionaryKey === dictionaryKey &&\n (focusedContent?.keyPath?.length ?? 0) > 0 &&\n isSameKeyPath(focusedContent?.keyPath ?? [], keyPath)) ??\n false,\n [focusedContent, keyPath]\n );\n\n useEffect(() => {\n // Use useEffect to avoid 'Text content does not match server-rendered HTML' error\n if (editedValue && typeof editedValue === 'string') {\n setDisplayedChildren(editedValue);\n } else {\n setDisplayedChildren(children);\n }\n }, [editedValue, focusedContent, children]);\n\n if (enabled) {\n return (\n <ContentSelector\n onPress={handleSelect}\n isSelecting={isSelected}\n {...props}\n >\n {displayedChildren}\n </ContentSelector>\n );\n }\n\n return <>{children}</>;\n};\n"],"mappings":";AA6EM,SAUG,UAVH;AA3EN,SAAS,qBAAmC;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,uBAAuB;AAWzB,MAAM,yBAA0D,CAAC;AAAA,EACtE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,QAAM,EAAE,gBAAgB,kBAAkB,IAAI,mBAAmB;AACjE,QAAM,EAAE,sBAAsB,IAAI,wBAAwB;AAE1D,QAAM,cAAc;AAAA,IAClB,MAAM,sBAAsB,eAAe,OAAO;AAAA,IAClD,CAAC,eAAe,SAAS,qBAAqB;AAAA,EAChD;AAEA,QAAM,CAAC,mBAAmB,oBAAoB,IAC5C,SAAoB,QAAQ;AAE9B,QAAM,eAAe;AAAA,IACnB,MACE,kBAAkB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACH,CAAC,eAAe,gBAAgB,SAAS,iBAAiB;AAAA,EAC5D;AAEA,QAAM,aAAa;AAAA,IACjB,OACG,gBAAgB,kBAAkB,kBAChC,gBAAgB,SAAS,UAAU,KAAK,KACzC,cAAc,gBAAgB,WAAW,CAAC,GAAG,OAAO,MACtD;AAAA,IACF,CAAC,gBAAgB,OAAO;AAAA,EAC1B;AAEA,YAAU,MAAM;AAEd,QAAI,eAAe,OAAO,gBAAgB,UAAU;AAClD,2BAAqB,WAAW;AAAA,IAClC,OAAO;AACL,2BAAqB,QAAQ;AAAA,IAC/B;AAAA,EACF,GAAG,CAAC,aAAa,gBAAgB,QAAQ,CAAC;AAE1C,MAAI,SAAS;AACX,WACE;AAAA,MAAC;AAAA;AAAA,QACC,SAAS;AAAA,QACT,aAAa;AAAA,QACZ,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SAAO,gCAAG,UAAS;AACrB;","names":[]}
|
|
@@ -1,10 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { getConfiguration } from "@intlayer/config/client";
|
|
4
|
+
import dictionaries from "@intlayer/dictionaries-entry";
|
|
5
|
+
import {
|
|
6
|
+
EditorProvider,
|
|
7
|
+
useCrossURLPathState,
|
|
8
|
+
useDictionariesRecordActions,
|
|
9
|
+
useConfigurationActions,
|
|
10
|
+
useIframeClickInterceptor
|
|
11
|
+
} from "@intlayer/editor-react";
|
|
12
|
+
import { useEffect } from "react";
|
|
13
|
+
const IntlayerEditorProviderEnabled = () => {
|
|
14
|
+
useCrossURLPathState(void 0, {
|
|
15
|
+
receive: false,
|
|
16
|
+
emit: true
|
|
17
|
+
});
|
|
18
|
+
const { setConfiguration } = useConfigurationActions();
|
|
19
|
+
const { setLocaleDictionaries } = useDictionariesRecordActions();
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setLocaleDictionaries(dictionaries);
|
|
22
|
+
const config = getConfiguration();
|
|
23
|
+
setConfiguration(config);
|
|
24
|
+
}, [setLocaleDictionaries]);
|
|
25
|
+
useIframeClickInterceptor();
|
|
26
|
+
return /* @__PURE__ */ jsx(Fragment, {});
|
|
27
|
+
};
|
|
28
|
+
const IntlayerEditorProvider = ({ children }) => /* @__PURE__ */ jsxs(
|
|
29
|
+
EditorProvider,
|
|
30
|
+
{
|
|
31
|
+
postMessage: (data) => window.parent?.postMessage(data, "*"),
|
|
32
|
+
allowedOrigins: ["*"],
|
|
33
|
+
children: [
|
|
34
|
+
/* @__PURE__ */ jsx(IntlayerEditorProviderEnabled, {}),
|
|
35
|
+
children
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
);
|
|
8
39
|
export {
|
|
9
40
|
IntlayerEditorProvider
|
|
10
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/IntlayerEditorProvider.tsx"],"sourcesContent":["'use client';\n\nimport { getConfiguration } from '@intlayer/config/client';\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport {\n EditorProvider,\n useCrossURLPathState,\n useDictionariesRecordActions,\n useConfigurationActions,\n useIframeClickInterceptor,\n} from '@intlayer/editor-react';\nimport { useEffect, type FC, type PropsWithChildren } from 'react';\n\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nconst IntlayerEditorProviderEnabled: FC = () => {\n /**\n * URL Messages\n */\n useCrossURLPathState(undefined, {\n receive: false,\n emit: true,\n });\n\n /**\n * Configuration Messages\n */\n const { setConfiguration } = useConfigurationActions();\n const { setLocaleDictionaries } = useDictionariesRecordActions();\n\n useEffect(() => {\n setLocaleDictionaries(dictionaries);\n\n const config = getConfiguration();\n setConfiguration(config);\n }, [setLocaleDictionaries]);\n\n /**\n * Click Messages\n */\n useIframeClickInterceptor();\n\n return <></>;\n};\n\nexport const IntlayerEditorProvider: FC<PropsWithChildren> = ({ children }) => (\n <EditorProvider\n postMessage={(data) => window.parent?.postMessage(data, '*')}\n allowedOrigins={['*']}\n >\n <IntlayerEditorProviderEnabled />\n {children}\n </EditorProvider>\n);\n"],"mappings":";AA6CS,wBAIP,YAJO;AA3CT,SAAS,wBAAwB;AACjC,OAAO,kBAAkB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAkD;AAO3D,MAAM,gCAAoC,MAAM;AAI9C,uBAAqB,QAAW;AAAA,IAC9B,SAAS;AAAA,IACT,MAAM;AAAA,EACR,CAAC;AAKD,QAAM,EAAE,iBAAiB,IAAI,wBAAwB;AACrD,QAAM,EAAE,sBAAsB,IAAI,6BAA6B;AAE/D,YAAU,MAAM;AACd,0BAAsB,YAAY;AAElC,UAAM,SAAS,iBAAiB;AAChC,qBAAiB,MAAM;AAAA,EACzB,GAAG,CAAC,qBAAqB,CAAC;AAK1B,4BAA0B;AAE1B,SAAO,gCAAE;AACX;AAEO,MAAM,yBAAgD,CAAC,EAAE,SAAS,MACvE;AAAA,EAAC;AAAA;AAAA,IACC,aAAa,CAAC,SAAS,OAAO,QAAQ,YAAY,MAAM,GAAG;AAAA,IAC3D,gBAAgB,CAAC,GAAG;AAAA,IAEpB;AAAA,0BAAC,iCAA8B;AAAA,MAC9B;AAAA;AAAA;AACH;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export * from './ContentSelectorWrapper';\nexport * from './
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/index.ts"],"sourcesContent":["export * from './ContentSelectorWrapper';\nexport * from './renderContentEditor';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
content,
|
|
9
|
-
isContentSelectable,
|
|
10
|
-
...props
|
|
11
|
-
}) => {
|
|
12
|
-
if (enabled && isContentSelectable) {
|
|
13
|
-
return /* @__PURE__ */ jsx(ContentSelectorConnector, { ...props, children: content });
|
|
14
|
-
}
|
|
15
|
-
return content;
|
|
16
|
-
};
|
|
17
|
-
const renderIntlayerEditor = (data, isContentSelectable = true) => {
|
|
18
|
-
const Result = /* @__PURE__ */ jsx(
|
|
19
|
-
IntlayerEditorElement,
|
|
20
|
-
{
|
|
21
|
-
...data,
|
|
22
|
-
isContentSelectable
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
return { ...Result, value: data.content };
|
|
2
|
+
import {
|
|
3
|
+
ContentSelectorWrapper
|
|
4
|
+
} from './ContentSelectorWrapper.mjs';
|
|
5
|
+
const renderIntlayerEditor = (props) => {
|
|
6
|
+
const Result = /* @__PURE__ */ jsx(ContentSelectorWrapper, { ...props, children: props.content });
|
|
7
|
+
return { ...Result, value: props.content };
|
|
26
8
|
};
|
|
27
9
|
export {
|
|
28
10
|
renderIntlayerEditor
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/editor/renderContentEditor.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport {\n ContentSelectorWrapper,\n type ContentSelectorWrapperProps,\n} from './ContentSelectorWrapper';\n\nexport type IntlayerNode<T = string> = ReactNode & {\n value: T;\n};\n\nexport type RenderIntlayerEditorProps = Omit<\n ContentSelectorWrapperProps,\n 'children'\n> & {\n content: string;\n};\n\nexport const renderIntlayerEditor = (\n props: RenderIntlayerEditorProps\n): IntlayerNode => {\n const Result = (\n <ContentSelectorWrapper {...props}>{props.content}</ContentSelectorWrapper>\n );\n\n return { ...Result, value: props.content };\n};\n"],"mappings":"AAqBI;AApBJ;AAAA,EACE;AAAA,OAEK;AAaA,MAAM,uBAAuB,CAClC,UACiB;AACjB,QAAM,SACJ,oBAAC,0BAAwB,GAAG,OAAQ,gBAAM,SAAQ;AAGpD,SAAO,EAAE,GAAG,QAAQ,OAAO,MAAM,QAAQ;AAC3C;","names":[]}
|
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import { isValidElement } from "react";
|
|
2
|
-
import {
|
|
3
|
-
renderIntlayerEditor
|
|
4
|
-
} from './editor/renderContentEditor.mjs';
|
|
5
1
|
import { processDictionary } from './processDictionary/index.mjs';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} else if (typeof value === "object") {
|
|
10
|
-
if (typeof value.dictionaryKey !== "undefined") {
|
|
11
|
-
if (isRenderEditor) {
|
|
12
|
-
return renderIntlayerEditor(value);
|
|
13
|
-
}
|
|
14
|
-
return value.content;
|
|
15
|
-
} else if (Array.isArray(value)) {
|
|
16
|
-
return value.map((el) => recursiveTransformContent(el, isRenderEditor));
|
|
17
|
-
} else if (isValidElement(value)) {
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
return Object.entries(value).reduce(
|
|
21
|
-
(acc, [key, value2]) => ({
|
|
22
|
-
...acc,
|
|
23
|
-
[key]: recursiveTransformContent(value2, isRenderEditor)
|
|
24
|
-
}),
|
|
25
|
-
{}
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
};
|
|
2
|
+
import {
|
|
3
|
+
recursiveTransformContent
|
|
4
|
+
} from './recursiveTransformContent.mjs';
|
|
30
5
|
const getDictionary = (dictionary, locale, isRenderEditor = false) => {
|
|
31
6
|
const result = processDictionary(
|
|
32
7
|
dictionary.content,
|
|
@@ -41,7 +16,6 @@ const getDictionary = (dictionary, locale, isRenderEditor = false) => {
|
|
|
41
16
|
);
|
|
42
17
|
};
|
|
43
18
|
export {
|
|
44
|
-
getDictionary
|
|
45
|
-
recursiveTransformContent
|
|
19
|
+
getDictionary
|
|
46
20
|
};
|
|
47
21
|
//# sourceMappingURL=getDictionary.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/getDictionary.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { DeclarationContent, DictionaryValue } from '@intlayer/core';\nimport { processDictionary } from './processDictionary/index';\nimport {\n DeepTransformContent,\n recursiveTransformContent,\n} from './recursiveTransformContent';\n\ntype DataFromDictionary<\n T extends DeclarationContent,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<T['content'], K, R>;\n\nexport type UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionary<T, L, R>;\n\n/**\n * Hook that picks one dictionary by its id and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getDictionary: UseDictionary = <\n T extends DeclarationContent,\n L extends Locales,\n R extends boolean = false,\n>(\n dictionary: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const result = processDictionary(\n dictionary.content as DictionaryValue,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionary<T, L, R>;\n};\n"],"mappings":"AAEA,SAAS,yBAAyB;AAClC;AAAA,EAEE;AAAA,OACK;AAwBA,MAAM,gBAA+B,CAK1C,YACA,QACA,iBAAoB,UACjB;AACH,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/dist/esm/getIntlayer.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import dictionaries from "@intlayer/dictionaries-entry";
|
|
2
|
+
import { processDictionary } from './processDictionary/index.mjs';
|
|
2
3
|
import {
|
|
3
4
|
recursiveTransformContent
|
|
4
|
-
} from './
|
|
5
|
-
import { processDictionary } from './processDictionary/index.mjs';
|
|
5
|
+
} from './recursiveTransformContent.mjs';
|
|
6
6
|
const getIntlayer = (key, locale, isRenderEditor = false) => {
|
|
7
7
|
const dictionary = dictionaries[key];
|
|
8
8
|
if (!dictionary) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import type { Locales } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\n/**\n * @intlayer/dictionaries-entry is a package that only returns the dictionary entry path.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n * The alias allow hot reload the app (such as nextjs) on any dictionary change.\n */\nimport dictionaries from '@intlayer/dictionaries-entry';\nimport type { IntlayerDictionaryTypesConnector } from 'intlayer';\nimport { processDictionary } from './processDictionary/index';\nimport {\n type DeepTransformContent,\n recursiveTransformContent,\n} from './recursiveTransformContent';\n\n/**\n * Provides a fallback to string type if the generic type T is never,\n * otherwise returns T. This is useful for handling cases where no keys are found.\n * Example: StringFallback<never> -> string; StringFallback<'key'> -> 'key'\n */\nexport type StringFallback<T> = T extends never ? string : T; // If no keys are found, return string to disable error, and accept any string as dictionary key\n\n/**\n * Represents the keys of the IntlayerDictionaryTypesConnector,\n * ensuring they are valid dictionary keys or fallback to string if none exist.\n *\n * Example:\n * ```ts\n * DictionaryKeys -> 'key1' | 'key2'\n * // or if IntlayerDictionaryTypesConnector is not defined,\n * DictionaryKeys -> string\n * ```\n */\nexport type DictionaryKeys = StringFallback<\n keyof IntlayerDictionaryTypesConnector\n>;\n\n/**\n * Represents the data type returned by the useIntlayer hook,\n * excluding the 'id' and 'filePath' keys from the dictionary content.\n */\nexport type DataFromDictionaryKey<\n T extends DictionaryKeys,\n K extends Locales,\n R extends boolean = false,\n> = DeepTransformContent<IntlayerDictionaryTypesConnector[T]['content'], K, R>;\n\n/**\n * Type definition for the useIntlayer hook, which takes a dictionary ID and an optional locale,\n * and returns the deeply transformed dictionary content.\n *\n */\nexport type UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionaryKey<T, L, R>;\n\nexport type UseIntlayerEditable = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R,\n isContentSelectable?: boolean\n) => DataFromDictionaryKey<T, L, R>;\n\nexport const getIntlayer: UseIntlayer = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = false,\n>(\n key: T,\n locale?: L,\n isRenderEditor: R = false as R\n) => {\n const dictionary: Dictionary = dictionaries[key as keyof typeof dictionaries];\n\n if (!dictionary) {\n throw new Error(`Dictionary ${key} not found`, dictionaries);\n }\n\n const result = processDictionary(\n dictionary.content,\n dictionary.key,\n dictionary.filePath,\n [],\n locale\n );\n\n return recursiveTransformContent(\n result,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n};\n"],"mappings":"AAOA,OAAO,kBAAkB;AAEzB,SAAS,yBAAyB;AAClC;AAAA,EAEE;AAAA,OACK;AA6DA,MAAM,cAA2B,CAKtC,KACA,QACA,iBAAoB,UACjB;AACH,QAAM,aAAyB,aAAa,GAAgC;AAE5E,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,cAAc,GAAG,cAAc,YAAY;AAAA,EAC7D;AAEA,QAAM,SAAS;AAAA,IACb,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,CAAC;AAAA,IACD;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { fetchDistantDictionary } from
|
|
2
|
+
import { fetchDistantDictionary } from "@intlayer/api";
|
|
3
3
|
import { getDictionary } from './getDictionary.mjs';
|
|
4
4
|
const getIntlayerAsync = async (key, locale, isRenderEditor = true) => {
|
|
5
5
|
const jsonDistantDictionary = await fetchDistantDictionary(key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/getIntlayerAsync.ts"],"sourcesContent":["'use client';\n\nimport { fetchDistantDictionary } from '@intlayer/api';\nimport type { Locales } from '@intlayer/config/client';\nimport { DeclarationContent } from 'intlayer';\nimport { getDictionary } from './getDictionary';\nimport { DictionaryKeys, DataFromDictionaryKey } from './getIntlayer';\n\nexport type GetIntlayerAsync = <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor?: R\n) => Promise<DataFromDictionaryKey<T, L, R> | null>;\n\n/**\n * On the client side, Hook that picking one dictionary by its key and return the content\n *\n * This hook will prerender the locale dictionary and fetch simultaneously the distant dictionaries to hydrate it.\n *\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const getIntlayerAsync: GetIntlayerAsync = async <\n T extends DictionaryKeys,\n L extends Locales,\n R extends boolean = true,\n>(\n key: T,\n locale?: L,\n isRenderEditor = true as R\n) => {\n const jsonDistantDictionary = await fetchDistantDictionary(key);\n\n if (jsonDistantDictionary) {\n return getDictionary(\n jsonDistantDictionary as unknown as DeclarationContent,\n locale,\n isRenderEditor\n ) as DataFromDictionaryKey<T, L, R>;\n }\n\n return null;\n};\n"],"mappings":";AAEA,SAAS,8BAA8B;AAGvC,SAAS,qBAAqB;AAqBvB,MAAM,mBAAqC,OAKhD,KACA,QACA,iBAAiB,SACd;AACH,QAAM,wBAAwB,MAAM,uBAAuB,GAAG;AAE9D,MAAI,uBAAuB;AACzB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isValidElement } from "react";
|
|
2
|
+
import {
|
|
3
|
+
renderIntlayerEditor
|
|
4
|
+
} from './editor/renderContentEditor.mjs';
|
|
5
|
+
const recursiveTransformContent = (value, isRenderEditor = false) => {
|
|
6
|
+
if (typeof value === "function") {
|
|
7
|
+
return (props) => recursiveTransformContent(value(props), isRenderEditor);
|
|
8
|
+
} else if (typeof value === "object") {
|
|
9
|
+
if (typeof value.dictionaryKey !== "undefined") {
|
|
10
|
+
if (isRenderEditor) {
|
|
11
|
+
return renderIntlayerEditor(value);
|
|
12
|
+
}
|
|
13
|
+
return value.content;
|
|
14
|
+
} else if (Array.isArray(value)) {
|
|
15
|
+
return value.map((el) => recursiveTransformContent(el, isRenderEditor));
|
|
16
|
+
} else if (isValidElement(value)) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
return Object.entries(value).reduce(
|
|
20
|
+
(acc, [key, value2]) => ({
|
|
21
|
+
...acc,
|
|
22
|
+
[key]: recursiveTransformContent(value2, isRenderEditor)
|
|
23
|
+
}),
|
|
24
|
+
{}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
recursiveTransformContent
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=recursiveTransformContent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/recursiveTransformContent.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Locales } from '@intlayer/config';\nimport type { NodeType } from '@intlayer/core';\nimport { isValidElement, type ReactNode } from 'react';\nimport {\n type IntlayerNode,\n renderIntlayerEditor,\n} from './editor/renderContentEditor';\n\ntype TransformNodeType<T, L extends Locales, R extends boolean> = T extends {\n [NodeType.Enumeration]: { '1': any };\n}\n ? (\n quantity: number\n ) => DeepTransformContent<T[NodeType.Enumeration]['1'], L, R>\n : T extends {\n [NodeType.Translation]: object;\n }\n ? L extends keyof T[NodeType.Translation]\n ? DeepTransformContent<T[NodeType.Translation][L], L, R>\n : never\n : T;\n\nexport type DeepTransformContent<\n T,\n L extends Locales,\n R extends boolean,\n> = T extends object // Check if the property is an object\n ? T extends (infer U)[] // If it's an array, infer the type of array elements\n ? DeepTransformContent<U, L, R>[] // Apply DeepTransformContent recursively to each element of the array\n : T extends {\n nodeType: NodeType | string;\n }\n ? TransformNodeType<T, L, R>\n : T extends { _owner: any; key: any; props: any; ref: any }\n ? ReactNode\n : {\n [K in keyof T]: DeepTransformContent<T[K], L, R>;\n }\n : T extends undefined\n ? never\n : R extends true\n ? IntlayerNode<T>\n : T;\n\n/**\n * Go through the object. If a object has a keyPath, render the intlayer editor if editor enabled.\n */\nexport const recursiveTransformContent = (\n value: any,\n isRenderEditor = false\n): object => {\n if (typeof value === 'function') {\n return (props: any) =>\n recursiveTransformContent(value(props), isRenderEditor);\n } else if (typeof value === 'object') {\n if (typeof value.dictionaryKey !== 'undefined') {\n if (isRenderEditor) {\n return renderIntlayerEditor(value);\n }\n return value.content;\n } else if (Array.isArray(value)) {\n return value.map((el) => recursiveTransformContent(el, isRenderEditor));\n } else if (isValidElement(value)) {\n return value;\n }\n\n return Object.entries(value).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: recursiveTransformContent(value, isRenderEditor),\n }),\n {} as object\n );\n }\n\n return value;\n};\n"],"mappings":"AAGA,SAAS,sBAAsC;AAC/C;AAAA,EAEE;AAAA,OACK;AAyCA,MAAM,4BAA4B,CACvC,OACA,iBAAiB,UACN;AACX,MAAI,OAAO,UAAU,YAAY;AAC/B,WAAO,CAAC,UACN,0BAA0B,MAAM,KAAK,GAAG,cAAc;AAAA,EAC1D,WAAW,OAAO,UAAU,UAAU;AACpC,QAAI,OAAO,MAAM,kBAAkB,aAAa;AAC9C,UAAI,gBAAgB;AAClB,eAAO,qBAAqB,KAAK;AAAA,MACnC;AACA,aAAO,MAAM;AAAA,IACf,WAAW,MAAM,QAAQ,KAAK,GAAG;AAC/B,aAAO,MAAM,IAAI,CAAC,OAAO,0BAA0B,IAAI,cAAc,CAAC;AAAA,IACxE,WAAW,eAAe,KAAK,GAAG;AAChC,aAAO;AAAA,IACT;AAEA,WAAO,OAAO,QAAQ,KAAK,EAAE;AAAA,MAC3B,CAAC,KAAK,CAAC,KAAKA,MAAK,OAAO;AAAA,QACtB,GAAG;AAAA,QACH,CAAC,GAAG,GAAG,0BAA0BA,QAAO,cAAc;AAAA,MACxD;AAAA,MACA,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":["value"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type FC, type HTMLAttributes } from 'react';
|
|
2
|
+
type ContentSelectorProps = {
|
|
3
|
+
onPress: () => void;
|
|
4
|
+
onClickOutside?: () => void;
|
|
5
|
+
pressDuration?: number;
|
|
6
|
+
isSelecting?: boolean;
|
|
7
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
8
|
+
export declare const ContentSelector: FC<ContentSelectorProps>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=ContentSelector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","sourceRoot":"","sources":["../../../src/UI/ContentSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,EAAE,EAEP,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAIf,KAAK,oBAAoB,GAAG;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEnC,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAiHpD,CAAC"}
|