@canlooks/can-ui 0.0.11 → 0.0.13
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/cjs/components/flex/flex.js +2 -2
- package/dist/cjs/components/transportStyle/transportStyle.d.ts +5 -2
- package/dist/cjs/components/transportStyle/transportStyle.js +7 -5
- package/dist/cjs/utils/utils.d.ts +6 -0
- package/dist/cjs/utils/utils.js +14 -0
- package/dist/esm/components/flex/flex.js +3 -3
- package/dist/esm/components/transportStyle/transportStyle.d.ts +5 -2
- package/dist/esm/components/transportStyle/transportStyle.js +7 -5
- package/dist/esm/utils/utils.d.ts +6 -0
- package/dist/esm/utils/utils.js +13 -0
- package/package.json +1 -1
|
@@ -23,10 +23,10 @@ exports.Flex = (0, react_1.forwardRef)(({ inline, direction = 'row', wrap, gap =
|
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
return ((0, jsx_runtime_1.jsx)(transportStyle_1.TransportStyle, { ...props, ref: ref, className: (0, utils_1.classnames)(flex_style_1.classes.root, props.className), style: {
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(transportStyle_1.TransportStyle, { ...props, ref: ref, className: (0, utils_1.classnames)(flex_style_1.classes.root, props.className), style: (0, utils_1.filterProperties)({
|
|
27
27
|
display: inline ? 'inline-flex' : 'flex',
|
|
28
28
|
flexDirection: direction,
|
|
29
29
|
flexWrap: wrap, columnGap, rowGap, gap,
|
|
30
30
|
...props.style
|
|
31
|
-
}, children: renderChildren() }));
|
|
31
|
+
}), children: renderChildren() }));
|
|
32
32
|
});
|
|
@@ -16,15 +16,18 @@ export interface TransportStyleProps extends DIVProps {
|
|
|
16
16
|
minHeight?: CSSProperties['minHeight'];
|
|
17
17
|
maxHeight?: CSSProperties['maxHeight'];
|
|
18
18
|
lineHeight?: CSSProperties['lineHeight'];
|
|
19
|
-
padding?: CSSProperties['padding'];
|
|
20
19
|
paddingTop?: CSSProperties['paddingTop'];
|
|
21
20
|
paddingRight?: CSSProperties['paddingRight'];
|
|
22
21
|
paddingBottom?: CSSProperties['paddingBottom'];
|
|
23
22
|
paddingLeft?: CSSProperties['paddingLeft'];
|
|
24
|
-
|
|
23
|
+
padding?: CSSProperties['padding'];
|
|
25
24
|
marginTop?: CSSProperties['marginTop'];
|
|
26
25
|
marginRight?: CSSProperties['marginRight'];
|
|
27
26
|
marginBottom?: CSSProperties['marginBottom'];
|
|
28
27
|
marginLeft?: CSSProperties['marginLeft'];
|
|
28
|
+
margin?: CSSProperties['margin'];
|
|
29
|
+
overflowX?: CSSProperties['overflowX'];
|
|
30
|
+
overflowY?: CSSProperties['overflowY'];
|
|
31
|
+
overflow?: CSSProperties['overflow'];
|
|
29
32
|
}
|
|
30
33
|
export declare const TransportStyle: import("react").ForwardRefExoticComponent<Omit<TransportStyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TransportStyle = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
exports.TransportStyle = (0, react_1.forwardRef)(({ alignItems, justifyContent, alignSelf, justifySelf, flex, width, minWidth, maxWidth, height, minHeight, maxHeight, lineHeight, paddingTop, paddingRight, paddingBottom, paddingLeft, padding, marginTop, marginRight, marginBottom, marginLeft, margin, overflowX, overflowY, overflow, ...props }, ref) => {
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)("div", { ...props, ref: ref, style: (0, utils_1.filterProperties)({
|
|
8
9
|
alignItems, justifyContent, alignSelf, justifySelf, flex,
|
|
9
10
|
width, minWidth, maxWidth, height, minHeight, maxHeight, lineHeight,
|
|
10
|
-
paddingTop, paddingRight, paddingBottom, paddingLeft,
|
|
11
|
-
marginTop, marginRight, marginBottom, marginLeft,
|
|
11
|
+
padding, paddingTop, paddingRight, paddingBottom, paddingLeft,
|
|
12
|
+
margin, marginTop, marginRight, marginBottom, marginLeft,
|
|
13
|
+
overflow, overflowX, overflowY,
|
|
12
14
|
...props.style
|
|
13
|
-
} }));
|
|
15
|
+
}) }));
|
|
14
16
|
});
|
|
@@ -121,3 +121,9 @@ export declare function range(value: number, min?: number, max?: number): number
|
|
|
121
121
|
* @param separator
|
|
122
122
|
*/
|
|
123
123
|
export declare function queryDeep<T extends object = any, U = any>(obj: T, keyPath: Id | Id[], setValue?: (oldValue: any) => U, separator?: string): U;
|
|
124
|
+
/**
|
|
125
|
+
* 过滤对象中值为undefined属性
|
|
126
|
+
* @param obj
|
|
127
|
+
* @param undefinedValue 可传入该值,用于替换undefined以删除其他属性
|
|
128
|
+
*/
|
|
129
|
+
export declare function filterProperties<T extends Record<string, any>>(obj: T, undefinedValue?: any): T;
|
package/dist/cjs/utils/utils.js
CHANGED
|
@@ -20,6 +20,7 @@ exports.isChildOf = isChildOf;
|
|
|
20
20
|
exports.fineParent = fineParent;
|
|
21
21
|
exports.range = range;
|
|
22
22
|
exports.queryDeep = queryDeep;
|
|
23
|
+
exports.filterProperties = filterProperties;
|
|
23
24
|
/**
|
|
24
25
|
* 生成最简易的随机ID
|
|
25
26
|
* @param namespace
|
|
@@ -302,3 +303,16 @@ function queryDeep(obj, keyPath, setValue, separator = '.') {
|
|
|
302
303
|
}
|
|
303
304
|
return obj[keyPath];
|
|
304
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* 过滤对象中值为undefined属性
|
|
308
|
+
* @param obj
|
|
309
|
+
* @param undefinedValue 可传入该值,用于替换undefined以删除其他属性
|
|
310
|
+
*/
|
|
311
|
+
function filterProperties(obj, undefinedValue) {
|
|
312
|
+
for (const k in obj) {
|
|
313
|
+
if (obj[k] === undefinedValue) {
|
|
314
|
+
delete obj[k];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return obj;
|
|
318
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { Children, cloneElement, forwardRef, isValidElement } from 'react';
|
|
3
3
|
import { classes } from './flex.style';
|
|
4
|
-
import { classnames } from '../../utils';
|
|
4
|
+
import { classnames, filterProperties } from '../../utils';
|
|
5
5
|
import { TransportStyle } from '../transportStyle';
|
|
6
6
|
export const Flex = forwardRef(({ inline, direction = 'row', wrap, gap = 0, columnGap, rowGap, compact, ...props }, ref) => {
|
|
7
7
|
const renderChildren = () => {
|
|
@@ -20,10 +20,10 @@ export const Flex = forwardRef(({ inline, direction = 'row', wrap, gap = 0, colu
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
-
return (_jsx(TransportStyle, { ...props, ref: ref, className: classnames(classes.root, props.className), style: {
|
|
23
|
+
return (_jsx(TransportStyle, { ...props, ref: ref, className: classnames(classes.root, props.className), style: filterProperties({
|
|
24
24
|
display: inline ? 'inline-flex' : 'flex',
|
|
25
25
|
flexDirection: direction,
|
|
26
26
|
flexWrap: wrap, columnGap, rowGap, gap,
|
|
27
27
|
...props.style
|
|
28
|
-
}, children: renderChildren() }));
|
|
28
|
+
}), children: renderChildren() }));
|
|
29
29
|
});
|
|
@@ -16,15 +16,18 @@ export interface TransportStyleProps extends DIVProps {
|
|
|
16
16
|
minHeight?: CSSProperties['minHeight'];
|
|
17
17
|
maxHeight?: CSSProperties['maxHeight'];
|
|
18
18
|
lineHeight?: CSSProperties['lineHeight'];
|
|
19
|
-
padding?: CSSProperties['padding'];
|
|
20
19
|
paddingTop?: CSSProperties['paddingTop'];
|
|
21
20
|
paddingRight?: CSSProperties['paddingRight'];
|
|
22
21
|
paddingBottom?: CSSProperties['paddingBottom'];
|
|
23
22
|
paddingLeft?: CSSProperties['paddingLeft'];
|
|
24
|
-
|
|
23
|
+
padding?: CSSProperties['padding'];
|
|
25
24
|
marginTop?: CSSProperties['marginTop'];
|
|
26
25
|
marginRight?: CSSProperties['marginRight'];
|
|
27
26
|
marginBottom?: CSSProperties['marginBottom'];
|
|
28
27
|
marginLeft?: CSSProperties['marginLeft'];
|
|
28
|
+
margin?: CSSProperties['margin'];
|
|
29
|
+
overflowX?: CSSProperties['overflowX'];
|
|
30
|
+
overflowY?: CSSProperties['overflowY'];
|
|
31
|
+
overflow?: CSSProperties['overflow'];
|
|
29
32
|
}
|
|
30
33
|
export declare const TransportStyle: import("react").ForwardRefExoticComponent<Omit<TransportStyleProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { filterProperties } from '../../utils';
|
|
4
|
+
export const TransportStyle = forwardRef(({ alignItems, justifyContent, alignSelf, justifySelf, flex, width, minWidth, maxWidth, height, minHeight, maxHeight, lineHeight, paddingTop, paddingRight, paddingBottom, paddingLeft, padding, marginTop, marginRight, marginBottom, marginLeft, margin, overflowX, overflowY, overflow, ...props }, ref) => {
|
|
5
|
+
return (_jsx("div", { ...props, ref: ref, style: filterProperties({
|
|
5
6
|
alignItems, justifyContent, alignSelf, justifySelf, flex,
|
|
6
7
|
width, minWidth, maxWidth, height, minHeight, maxHeight, lineHeight,
|
|
7
|
-
paddingTop, paddingRight, paddingBottom, paddingLeft,
|
|
8
|
-
marginTop, marginRight, marginBottom, marginLeft,
|
|
8
|
+
padding, paddingTop, paddingRight, paddingBottom, paddingLeft,
|
|
9
|
+
margin, marginTop, marginRight, marginBottom, marginLeft,
|
|
10
|
+
overflow, overflowX, overflowY,
|
|
9
11
|
...props.style
|
|
10
|
-
} }));
|
|
12
|
+
}) }));
|
|
11
13
|
});
|
|
@@ -121,3 +121,9 @@ export declare function range(value: number, min?: number, max?: number): number
|
|
|
121
121
|
* @param separator
|
|
122
122
|
*/
|
|
123
123
|
export declare function queryDeep<T extends object = any, U = any>(obj: T, keyPath: Id | Id[], setValue?: (oldValue: any) => U, separator?: string): U;
|
|
124
|
+
/**
|
|
125
|
+
* 过滤对象中值为undefined属性
|
|
126
|
+
* @param obj
|
|
127
|
+
* @param undefinedValue 可传入该值,用于替换undefined以删除其他属性
|
|
128
|
+
*/
|
|
129
|
+
export declare function filterProperties<T extends Record<string, any>>(obj: T, undefinedValue?: any): T;
|
package/dist/esm/utils/utils.js
CHANGED
|
@@ -280,3 +280,16 @@ export function queryDeep(obj, keyPath, setValue, separator = '.') {
|
|
|
280
280
|
}
|
|
281
281
|
return obj[keyPath];
|
|
282
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* 过滤对象中值为undefined属性
|
|
285
|
+
* @param obj
|
|
286
|
+
* @param undefinedValue 可传入该值,用于替换undefined以删除其他属性
|
|
287
|
+
*/
|
|
288
|
+
export function filterProperties(obj, undefinedValue) {
|
|
289
|
+
for (const k in obj) {
|
|
290
|
+
if (obj[k] === undefinedValue) {
|
|
291
|
+
delete obj[k];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return obj;
|
|
295
|
+
}
|