@vnejs/uis.react.wrap-with-content 0.1.5 → 0.1.7
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/WrapWithContent.d.ts +2 -27
- package/dist/WrapWithContent.d.ts.map +1 -1
- package/dist/WrapWithContent.js +3 -5
- package/dist/WrapWithContent.js.map +1 -1
- package/dist/WrapWithContent.styles.d.ts +1 -1
- package/dist/WrapWithContent.styles.d.ts.map +1 -1
- package/dist/WrapWithContent.types.d.ts +33 -0
- package/dist/WrapWithContent.types.d.ts.map +1 -0
- package/dist/WrapWithContent.types.js +2 -0
- package/dist/WrapWithContent.types.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/WrapWithContent.tsx +19 -9
- package/src/WrapWithContent.types.tsx +35 -0
- package/src/index.ts +2 -1
- package/tsconfig.json +1 -2
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
imageSrc?: string;
|
|
4
|
-
isSelected?: boolean;
|
|
5
|
-
isRounded?: boolean;
|
|
6
|
-
withHover?: boolean;
|
|
7
|
-
width?: number;
|
|
8
|
-
height?: number;
|
|
9
|
-
borderWidth?: number;
|
|
10
|
-
top?: number;
|
|
11
|
-
right?: number;
|
|
12
|
-
bottom?: number;
|
|
13
|
-
left?: number;
|
|
14
|
-
transition?: number;
|
|
15
|
-
renderTopLeft: any;
|
|
16
|
-
renderTopRight: any;
|
|
17
|
-
renderBottomLeft: any;
|
|
18
|
-
renderBottomRight: any;
|
|
19
|
-
topLeftText: any;
|
|
20
|
-
topLeftSize: any;
|
|
21
|
-
topRightText: any;
|
|
22
|
-
topRightSize: any;
|
|
23
|
-
bottomLeftText: any;
|
|
24
|
-
bottomLeftSize: any;
|
|
25
|
-
onClick: any;
|
|
26
|
-
value: any;
|
|
27
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { type WrapWithContentProps } from "./WrapWithContent.types.js";
|
|
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, }: WrapWithContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
3
|
//# sourceMappingURL=WrapWithContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WrapWithContent.d.ts","sourceRoot":"","sources":["../src/WrapWithContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WrapWithContent.d.ts","sourceRoot":"","sources":["../src/WrapWithContent.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,oBAAoB,EAG1B,MAAM,4BAA4B,CAAC;AAqCpC,eAAO,MAAM,eAAe,GAAI,wSA0B7B,oBAAoB,4CAoDtB,CAAC"}
|
package/dist/WrapWithContent.js
CHANGED
|
@@ -3,19 +3,17 @@ import { useCallback, useMemo } from "react";
|
|
|
3
3
|
import { getVneLength } from "@vnejs/uis.utils";
|
|
4
4
|
import { Text, Wrap } from "@vnejs/uis.react";
|
|
5
5
|
import { b } from "./WrapWithContent.styles.js";
|
|
6
|
-
const getCssPosition = (value) => () => value ? getVneLength(value) : "0";
|
|
6
|
+
const getCssPosition = (value) => () => (value ? getVneLength(value) : "0");
|
|
7
7
|
const renderOneItem = (props, style, renderFunc) => renderFunc && (_jsx("div", { className: b("item"), style: style, children: renderFunc(props) }));
|
|
8
8
|
const useRenderContentCallback = (renderFunc, text, size) => {
|
|
9
9
|
return useCallback(({ isSelected = false }) => {
|
|
10
10
|
if (text)
|
|
11
11
|
return (_jsx(Text, { isSelected: isSelected, text: text, size: size }));
|
|
12
12
|
if (renderFunc)
|
|
13
|
-
return renderFunc();
|
|
13
|
+
return renderFunc({ isSelected });
|
|
14
14
|
}, [renderFunc, text, size]);
|
|
15
15
|
};
|
|
16
|
-
export const WrapWithContent = ({
|
|
17
|
-
//
|
|
18
|
-
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, }) => {
|
|
16
|
+
export const WrapWithContent = ({ 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, }) => {
|
|
19
17
|
const realTop = useMemo(getCssPosition(top), [top]);
|
|
20
18
|
const realRight = useMemo(getCssPosition(right), [right]);
|
|
21
19
|
const realBottom = useMemo(getCssPosition(bottom), [bottom]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WrapWithContent.js","sourceRoot":"","sources":["../src/WrapWithContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"WrapWithContent.js","sourceRoot":"","sources":["../src/WrapWithContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAQ9C,OAAO,EAAE,CAAC,EAAE,MAAM,6BAA6B,CAAC;AAEhD,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAA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AiB,CAAC,IACtD,GACD,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const b:
|
|
1
|
+
export declare const b: any;
|
|
2
2
|
//# sourceMappingURL=WrapWithContent.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WrapWithContent.styles.d.ts","sourceRoot":"","sources":["../src/WrapWithContent.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"WrapWithContent.styles.d.ts","sourceRoot":"","sources":["../src/WrapWithContent.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,CAAC,KAAwB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type WrapWithContentRenderProps = {
|
|
3
|
+
isSelected?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type WrapWithContentRenderFunc = (props: WrapWithContentRenderProps) => ReactNode;
|
|
6
|
+
export type WrapWithContentProps<T = unknown> = {
|
|
7
|
+
className?: string;
|
|
8
|
+
imageSrc?: string;
|
|
9
|
+
isSelected?: boolean;
|
|
10
|
+
isRounded?: boolean;
|
|
11
|
+
withHover?: boolean;
|
|
12
|
+
width?: number;
|
|
13
|
+
height?: number;
|
|
14
|
+
borderWidth?: number;
|
|
15
|
+
top?: number;
|
|
16
|
+
right?: number;
|
|
17
|
+
bottom?: number;
|
|
18
|
+
left?: number;
|
|
19
|
+
transition?: number;
|
|
20
|
+
renderTopLeft?: WrapWithContentRenderFunc;
|
|
21
|
+
renderTopRight?: WrapWithContentRenderFunc;
|
|
22
|
+
renderBottomLeft?: WrapWithContentRenderFunc;
|
|
23
|
+
renderBottomRight?: WrapWithContentRenderFunc;
|
|
24
|
+
topLeftText?: string;
|
|
25
|
+
topLeftSize?: number;
|
|
26
|
+
topRightText?: string;
|
|
27
|
+
topRightSize?: number;
|
|
28
|
+
bottomLeftText?: string;
|
|
29
|
+
bottomLeftSize?: number;
|
|
30
|
+
onClick?: (value?: T) => void;
|
|
31
|
+
value?: T;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=WrapWithContent.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WrapWithContent.types.d.ts","sourceRoot":"","sources":["../src/WrapWithContent.types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG,CAAC,KAAK,EAAE,0BAA0B,KAAK,SAAS,CAAC;AAEzF,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAAI;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,cAAc,CAAC,EAAE,yBAAyB,CAAC;IAC3C,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IAC7C,iBAAiB,CAAC,EAAE,yBAAyB,CAAC;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,CAAC,CAAC;CACX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WrapWithContent.types.js","sourceRoot":"","sources":["../src/WrapWithContent.types.tsx"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
|
package/package.json
CHANGED
package/src/WrapWithContent.tsx
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
|
2
|
+
import type { CSSProperties } from "react";
|
|
2
3
|
|
|
3
4
|
import { getVneLength } from "@vnejs/uis.utils";
|
|
4
5
|
|
|
5
6
|
import { Text, Wrap } from "@vnejs/uis.react";
|
|
6
7
|
|
|
8
|
+
import {
|
|
9
|
+
type WrapWithContentProps,
|
|
10
|
+
type WrapWithContentRenderFunc,
|
|
11
|
+
type WrapWithContentRenderProps,
|
|
12
|
+
} from "./WrapWithContent.types.js";
|
|
13
|
+
|
|
7
14
|
import { b } from "./WrapWithContent.styles.js";
|
|
8
15
|
|
|
9
|
-
const getCssPosition = (value) => () => value ? getVneLength(value) : "0";
|
|
16
|
+
const getCssPosition = (value: number) => () => (value ? getVneLength(value) : "0");
|
|
10
17
|
|
|
11
|
-
const renderOneItem = (
|
|
18
|
+
const renderOneItem = (
|
|
19
|
+
props: WrapWithContentRenderProps,
|
|
20
|
+
style: CSSProperties,
|
|
21
|
+
renderFunc?: WrapWithContentRenderFunc,
|
|
22
|
+
) =>
|
|
12
23
|
renderFunc && (
|
|
13
24
|
<div
|
|
14
25
|
className={b("item")}
|
|
@@ -18,9 +29,9 @@ const renderOneItem = (props, style, renderFunc) =>
|
|
|
18
29
|
</div>
|
|
19
30
|
);
|
|
20
31
|
|
|
21
|
-
const useRenderContentCallback = (renderFunc, text, size) => {
|
|
32
|
+
const useRenderContentCallback = (renderFunc: WrapWithContentRenderFunc | undefined, text?: string, size?: number) => {
|
|
22
33
|
return useCallback(
|
|
23
|
-
({ isSelected = false }) => {
|
|
34
|
+
({ isSelected = false }: WrapWithContentRenderProps) => {
|
|
24
35
|
if (text)
|
|
25
36
|
return (
|
|
26
37
|
<Text
|
|
@@ -29,14 +40,13 @@ const useRenderContentCallback = (renderFunc, text, size) => {
|
|
|
29
40
|
size={size}
|
|
30
41
|
/>
|
|
31
42
|
);
|
|
32
|
-
if (renderFunc) return renderFunc();
|
|
43
|
+
if (renderFunc) return renderFunc({ isSelected });
|
|
33
44
|
},
|
|
34
45
|
[renderFunc, text, size],
|
|
35
46
|
);
|
|
36
47
|
};
|
|
37
48
|
|
|
38
49
|
export const WrapWithContent = ({
|
|
39
|
-
//
|
|
40
50
|
className,
|
|
41
51
|
imageSrc = "",
|
|
42
52
|
isSelected = false,
|
|
@@ -62,7 +72,7 @@ export const WrapWithContent = ({
|
|
|
62
72
|
bottomLeftSize,
|
|
63
73
|
onClick,
|
|
64
74
|
value,
|
|
65
|
-
}) => {
|
|
75
|
+
}: WrapWithContentProps) => {
|
|
66
76
|
const realTop = useMemo(getCssPosition(top), [top]);
|
|
67
77
|
const realRight = useMemo(getCssPosition(right), [right]);
|
|
68
78
|
const realBottom = useMemo(getCssPosition(bottom), [bottom]);
|
|
@@ -75,10 +85,10 @@ export const WrapWithContent = ({
|
|
|
75
85
|
|
|
76
86
|
const props = useMemo(() => ({ isSelected }), [isSelected]);
|
|
77
87
|
|
|
78
|
-
const addClassNames = useMemo(() => [className, withHover && "TextHoverParent"].filter(Boolean), [className, withHover]);
|
|
88
|
+
const addClassNames = useMemo(() => [className, withHover && "TextHoverParent"].filter(Boolean) as string[], [className, withHover]);
|
|
79
89
|
|
|
80
90
|
const styleContent = useMemo(() => {
|
|
81
|
-
const result: Record<string,
|
|
91
|
+
const result: Record<string, string> = {};
|
|
82
92
|
|
|
83
93
|
if (transition) result.transition = `${transition}ms`;
|
|
84
94
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export type WrapWithContentRenderProps = {
|
|
4
|
+
isSelected?: boolean;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type WrapWithContentRenderFunc = (props: WrapWithContentRenderProps) => ReactNode;
|
|
8
|
+
|
|
9
|
+
export type WrapWithContentProps<T = unknown> = {
|
|
10
|
+
className?: string;
|
|
11
|
+
imageSrc?: string;
|
|
12
|
+
isSelected?: boolean;
|
|
13
|
+
isRounded?: boolean;
|
|
14
|
+
withHover?: boolean;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
borderWidth?: number;
|
|
18
|
+
top?: number;
|
|
19
|
+
right?: number;
|
|
20
|
+
bottom?: number;
|
|
21
|
+
left?: number;
|
|
22
|
+
transition?: number;
|
|
23
|
+
renderTopLeft?: WrapWithContentRenderFunc;
|
|
24
|
+
renderTopRight?: WrapWithContentRenderFunc;
|
|
25
|
+
renderBottomLeft?: WrapWithContentRenderFunc;
|
|
26
|
+
renderBottomRight?: WrapWithContentRenderFunc;
|
|
27
|
+
topLeftText?: string;
|
|
28
|
+
topLeftSize?: number;
|
|
29
|
+
topRightText?: string;
|
|
30
|
+
topRightSize?: number;
|
|
31
|
+
bottomLeftText?: string;
|
|
32
|
+
bottomLeftSize?: number;
|
|
33
|
+
onClick?: (value?: T) => void;
|
|
34
|
+
value?: T;
|
|
35
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./WrapWithContent";
|
|
1
|
+
export * from "./WrapWithContent.types.js";
|
|
2
|
+
export * from "./WrapWithContent.js";
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "
|
|
2
|
+
"extends": "../../tsconfig.react.base.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "dist",
|
|
5
5
|
"rootDir": "src"
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"src/**/*.ts",
|
|
9
9
|
"src/**/*.tsx",
|
|
10
10
|
"../../../globals.d.ts",
|
|
11
|
-
"../../../peer-modules.d.ts"
|
|
12
11
|
],
|
|
13
12
|
"exclude": [
|
|
14
13
|
"dist",
|