@vnejs/uis.react.wrap-with-content 0.1.2

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.
@@ -0,0 +1,29 @@
1
+ import "./WrapWithContent.styl";
2
+ export declare const WrapWithContent: ({ className, imageSrc, isSelected, isRounded, withHover, width, height, borderWidth, top, right, bottom, left, transition, renderTopLeft, renderTopRight, renderBottomLeft, renderBottomRight, topLeftText, topLeftSize, topRightText, topRightSize, bottomLeftText, bottomLeftSize, onClick, value, }: {
3
+ className: any;
4
+ imageSrc?: string;
5
+ isSelected?: boolean;
6
+ isRounded?: boolean;
7
+ withHover?: boolean;
8
+ width?: number;
9
+ height?: number;
10
+ borderWidth?: number;
11
+ top?: number;
12
+ right?: number;
13
+ bottom?: number;
14
+ left?: number;
15
+ transition?: number;
16
+ renderTopLeft: any;
17
+ renderTopRight: any;
18
+ renderBottomLeft: any;
19
+ renderBottomRight: any;
20
+ topLeftText: any;
21
+ topLeftSize: any;
22
+ topRightText: any;
23
+ topRightSize: any;
24
+ bottomLeftText: any;
25
+ bottomLeftSize: any;
26
+ onClick: any;
27
+ value: any;
28
+ }) => import("react/jsx-runtime").JSX.Element;
29
+ //# sourceMappingURL=WrapWithContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WrapWithContent.d.ts","sourceRoot":"","sources":["../src/WrapWithContent.tsx"],"names":[],"mappings":"AAMA,OAAO,wBAAwB,CAAC;AAiChC,eAAO,MAAM,eAAe,GAAI;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B/B,4CAoDA,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useMemo } from "react";
3
+ import { cn, getVneLength } from "@vnejs/uis.utils";
4
+ import { Text, Wrap } from "@vnejs/uis.react";
5
+ import "./WrapWithContent.styl";
6
+ const b = cn("WrapWithContent");
7
+ const getCssPosition = (value) => () => value ? getVneLength(value) : "0";
8
+ const renderOneItem = (props, style, renderFunc) => renderFunc && (_jsx("div", { className: b("item"), style: style, children: renderFunc(props) }));
9
+ const useRenderContentCallback = (renderFunc, text, size) => {
10
+ return useCallback(({ isSelected = false }) => {
11
+ if (text)
12
+ return (_jsx(Text, { isSelected: isSelected, text: text, size: size }));
13
+ if (renderFunc)
14
+ return renderFunc();
15
+ }, [renderFunc, text, size]);
16
+ };
17
+ export const WrapWithContent = ({
18
+ //
19
+ className, imageSrc = "", isSelected = false, isRounded = false, withHover = false, width = 0, height = 0, borderWidth = 0, top = 0, right = 0, bottom = 0, left = 0, transition = 300, renderTopLeft, renderTopRight, renderBottomLeft, renderBottomRight, topLeftText, topLeftSize, topRightText, topRightSize, bottomLeftText, bottomLeftSize, onClick, value, }) => {
20
+ const realTop = useMemo(getCssPosition(top), [top]);
21
+ const realRight = useMemo(getCssPosition(right), [right]);
22
+ const realBottom = useMemo(getCssPosition(bottom), [bottom]);
23
+ const realLeft = useMemo(getCssPosition(left), [left]);
24
+ const styleTopLeft = useMemo(() => ({ top: realTop, left: realLeft }), [realTop, realLeft]);
25
+ const styleTopRight = useMemo(() => ({ top: realTop, right: realRight }), [realTop, realRight]);
26
+ const styleBottomLeft = useMemo(() => ({ bottom: realBottom, left: realLeft }), [realBottom, realLeft]);
27
+ const styleBottomRight = useMemo(() => ({ bottom: realBottom, right: realRight }), [realBottom, realRight]);
28
+ const props = useMemo(() => ({ isSelected }), [isSelected]);
29
+ const addClassNames = useMemo(() => [className, withHover && "TextHoverParent"].filter(Boolean), [className, withHover]);
30
+ const styleContent = useMemo(() => {
31
+ const result = {};
32
+ if (transition)
33
+ result.transition = `${transition}ms`;
34
+ return result;
35
+ }, [transition]);
36
+ const renderTopLeftHandler = useRenderContentCallback(renderTopLeft, topLeftText, topLeftSize);
37
+ const renderTopRightHandler = useRenderContentCallback(renderTopRight, topRightText, topRightSize);
38
+ const renderBottomLeftHandler = useRenderContentCallback(renderBottomLeft, bottomLeftText, bottomLeftSize);
39
+ return (_jsx(Wrap, { className: b({ withHover }, addClassNames), width: width, height: height, padding: 0, borderWidth: borderWidth, isSelected: isSelected, isRounded: isRounded, withHover: withHover, imageSrc: imageSrc, onClick: onClick, value: value, children: _jsxs("div", { className: b("content"), style: styleContent, children: [renderOneItem(props, styleTopLeft, renderTopLeftHandler), renderOneItem(props, styleTopRight, renderTopRightHandler), renderOneItem(props, styleBottomLeft, renderBottomLeftHandler), renderOneItem(props, styleBottomRight, renderBottomRight)] }) }));
40
+ };
41
+ //# sourceMappingURL=WrapWithContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WrapWithContent.js","sourceRoot":"","sources":["../src/WrapWithContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,wBAAwB,CAAC;AAEhC,MAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC;AAEhC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAE1E,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,CACjD,UAAU,IAAI,CACZ,cACE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,EACpB,KAAK,EAAE,KAAK,YAEX,UAAU,CAAC,KAAK,CAAC,GACd,CACP,CAAC;AAEJ,MAAM,wBAAwB,GAAG,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IAC1D,OAAO,WAAW,CAChB,CAAC,EAAE,UAAU,GAAG,KAAK,EAAE,EAAE,EAAE;QACzB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AM,qBAAqB,GAAG,wBAAwB,CAAC,cAAc,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IACnG,MAAM,uBAAuB,GAAG,wBAAwB,CAAC,gBAAgB,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAE3G,OAAO,CACL,KAAC,IAAI,IACH,SAAS,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,aAAa,CAAC,EAC1C,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,YAEZ,eACE,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,EACvB,KAAK,EAAE,YAAY,aAElB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,EACxD,aAAa,CAAC,KAAK,EAAE,aAAa,EAAE,qBAAqB,CAAC,EAC1D,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,uBAAuB,CAAC,EAC9D,aAAa,CAAC,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,IACtD,GACD,CACR,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ .WrapWithContent
2
+ display: block
3
+ position: relative
4
+
5
+ &-item
6
+ position: absolute
7
+
8
+ &-content
9
+ background: rgba(0, 0, 0, 0.3)
10
+ position: absolute
11
+ top: 0
12
+ right: 0
13
+ bottom: 0
14
+ left: 0
15
+
16
+ &_withHover &-content[vne-cursor-target]
17
+ background: transparent
@@ -0,0 +1,2 @@
1
+ export * from "./WrapWithContent";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./WrapWithContent";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@vnejs/uis.react.wrap-with-content",
3
+ "version": "0.1.2",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "scripts": {
7
+ "build": "node ../../scripts/build-package.mjs",
8
+ "publish:major:plugin": "npm run publish:major",
9
+ "publish:minor:plugin": "npm run publish:minor",
10
+ "publish:patch:plugin": "npm run publish:patch",
11
+ "publish:major": "npm run build && npm version major && npm publish --access public",
12
+ "publish:minor": "npm run build && npm version minor && npm publish --access public",
13
+ "publish:patch": "npm run build && npm version patch && npm publish --access public"
14
+ },
15
+ "peerDependencies": {
16
+ "@bem-react/classname": "1.5.12",
17
+ "@vnejs/uis.utils": "~0.1.0",
18
+ "react": "19.2.4",
19
+ "react-dom": "19.2.4",
20
+ "@vnejs/uis.react": "~0.1.0"
21
+ },
22
+ "devDependencies": {
23
+ "@vnejs/uis.react": "~0.1.0",
24
+ "typescript": "^5.7.3",
25
+ "@types/react": "^19.0.10",
26
+ "@types/react-dom": "^19.0.4"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "package.json"
31
+ ]
32
+ }