@canlooks/can-ui 0.0.5 → 0.0.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/cjs/components/flex/flex.js +23 -15
- package/dist/cjs/components/grid/grid.d.ts +1 -1
- package/dist/cjs/components/grid/grid.js +2 -1
- package/dist/cjs/components/grid/gridItem.js +2 -1
- package/dist/cjs/components/transportStyle/transportStyle.js +22 -4
- package/dist/cjs/components/waterfall/waterfall.d.ts +1 -1
- package/dist/cjs/components/waterfall/waterfall.js +2 -1
- package/dist/esm/components/flex/flex.js +23 -15
- package/dist/esm/components/grid/grid.d.ts +1 -1
- package/dist/esm/components/grid/grid.js +2 -1
- package/dist/esm/components/grid/gridItem.js +2 -1
- package/dist/esm/components/transportStyle/transportStyle.js +22 -4
- package/dist/esm/components/waterfall/waterfall.d.ts +1 -1
- package/dist/esm/components/waterfall/waterfall.js +2 -1
- package/package.json +2 -2
- package/tscup.config.ts +1 -9
|
@@ -5,23 +5,31 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const flex_style_1 = require("./flex.style");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
|
+
const transportStyle_1 = require("../transportStyle");
|
|
8
9
|
exports.Flex = (0, react_1.forwardRef)(({ inline, direction = 'row', wrap, gap = 0, columnGap, rowGap, compact, ...props }, ref) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
const renderChildren = () => {
|
|
11
|
+
if (!compact) {
|
|
12
|
+
return props.children;
|
|
13
|
+
}
|
|
14
|
+
const childrenCount = react_1.Children.count(props.children);
|
|
15
|
+
return react_1.Children.map(props.children, (child, index) => {
|
|
16
|
+
if (!(0, react_1.isValidElement)(child)) {
|
|
17
|
+
return child;
|
|
18
|
+
}
|
|
19
|
+
return (0, react_1.cloneElement)(child, {
|
|
20
|
+
...index === 0 && { 'data-first': true },
|
|
21
|
+
...index === childrenCount - 1 && { 'data-last': true },
|
|
22
|
+
...{ 'data-compact': direction.split('-')[0] }
|
|
23
|
+
});
|
|
24
|
+
});
|
|
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: {
|
|
11
27
|
display: inline ? 'inline-flex' : 'flex',
|
|
12
28
|
flexDirection: direction,
|
|
13
|
-
flexWrap: wrap,
|
|
29
|
+
flexWrap: wrap,
|
|
30
|
+
gap: gap,
|
|
31
|
+
columnGap: columnGap,
|
|
32
|
+
rowGap: rowGap,
|
|
14
33
|
...props.style
|
|
15
|
-
}, children:
|
|
16
|
-
? react_1.Children.map(props.children, (child, index) => {
|
|
17
|
-
if (!(0, react_1.isValidElement)(child)) {
|
|
18
|
-
return child;
|
|
19
|
-
}
|
|
20
|
-
return (0, react_1.cloneElement)(child, {
|
|
21
|
-
...index === 0 && { 'data-first': true },
|
|
22
|
-
...index === childrenCount - 1 && { 'data-last': true },
|
|
23
|
-
...{ 'data-compact': direction.split('-')[0] }
|
|
24
|
-
});
|
|
25
|
-
})
|
|
26
|
-
: props.children }));
|
|
34
|
+
}, children: renderChildren() }));
|
|
27
35
|
});
|
|
@@ -4,7 +4,7 @@ import { GridItem } from './gridItem';
|
|
|
4
4
|
import { TransportStyleProps } from '../transportStyle';
|
|
5
5
|
export interface GridProps extends TransportStyleProps {
|
|
6
6
|
inline?: boolean;
|
|
7
|
-
/** 网格列数,@default
|
|
7
|
+
/** 网格列数,@default xs: 12 */
|
|
8
8
|
columnCount?: ResponsiveProp;
|
|
9
9
|
gap?: ResponsiveProp;
|
|
10
10
|
columnGap?: ResponsiveProp;
|
|
@@ -6,12 +6,13 @@ const react_1 = require("react");
|
|
|
6
6
|
const grid_style_1 = require("./grid.style");
|
|
7
7
|
const gridItem_1 = require("./gridItem");
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
|
+
const transportStyle_1 = require("../transportStyle");
|
|
9
10
|
exports.Grid = (0, react_1.forwardRef)(({ inline, columnCount = { xs: 12 }, gap = { xs: 0 }, columnGap, rowGap, ...props }, ref) => {
|
|
10
11
|
columnCount = (0, utils_1.responsiveValue)(columnCount);
|
|
11
12
|
gap = (0, utils_1.responsiveValue)(gap);
|
|
12
13
|
columnGap = (0, utils_1.responsiveValue)(columnGap) ?? gap;
|
|
13
14
|
rowGap = (0, utils_1.responsiveValue)(rowGap) ?? gap;
|
|
14
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(transportStyle_1.TransportStyle, { ...props, ref: ref, css: (0, grid_style_1.containerStyle)({ columnCount, columnGap, rowGap }), className: (0, utils_1.classnames)(grid_style_1.classes.root, props.className), style: {
|
|
15
16
|
display: inline ? 'inline-flex' : 'flex',
|
|
16
17
|
...props.style
|
|
17
18
|
} }));
|
|
@@ -5,8 +5,9 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const utils_1 = require("../../utils");
|
|
7
7
|
const grid_style_1 = require("./grid.style");
|
|
8
|
+
const transportStyle_1 = require("../transportStyle");
|
|
8
9
|
exports.GridItem = (0, react_1.forwardRef)(({ span = { xs: 1 }, offset = { xs: 0 }, ...props }, ref) => {
|
|
9
10
|
span = (0, utils_1.responsiveValue)(span);
|
|
10
11
|
offset = (0, utils_1.responsiveValue)(offset);
|
|
11
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
12
|
+
return ((0, jsx_runtime_1.jsx)(transportStyle_1.TransportStyle, { ...props, ref: ref, css: (0, grid_style_1.itemStyle)({ span, offset }), className: (0, utils_1.classnames)(grid_style_1.classes.item, props.className) }));
|
|
12
13
|
});
|
|
@@ -5,10 +5,28 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
exports.TransportStyle = (0, react_1.forwardRef)(({ alignItems, justifyContent, alignSelf, justifySelf, flex, width, minWidth, maxWidth, height, minHeight, maxHeight, lineHeight, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, margin, marginTop, marginRight, marginBottom, marginLeft, ...props }, ref) => {
|
|
7
7
|
return ((0, jsx_runtime_1.jsx)("div", { ...props, ref: ref, style: {
|
|
8
|
-
alignItems
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
alignItems: alignItems,
|
|
9
|
+
justifyContent: justifyContent,
|
|
10
|
+
alignSelf: alignSelf,
|
|
11
|
+
justifySelf: justifySelf,
|
|
12
|
+
flex: flex,
|
|
13
|
+
width: width,
|
|
14
|
+
minWidth: minWidth,
|
|
15
|
+
maxWidth: maxWidth,
|
|
16
|
+
height: height,
|
|
17
|
+
minHeight: minHeight,
|
|
18
|
+
maxHeight: maxHeight,
|
|
19
|
+
lineHeight: lineHeight,
|
|
20
|
+
padding: padding,
|
|
21
|
+
paddingTop: paddingTop,
|
|
22
|
+
paddingRight: paddingRight,
|
|
23
|
+
paddingBottom: paddingBottom,
|
|
24
|
+
paddingLeft: paddingLeft,
|
|
25
|
+
margin: margin,
|
|
26
|
+
marginTop: marginTop,
|
|
27
|
+
marginRight: marginRight,
|
|
28
|
+
marginBottom: marginBottom,
|
|
29
|
+
marginLeft: marginLeft,
|
|
12
30
|
...props.style
|
|
13
31
|
} }));
|
|
14
32
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResponsiveProp } from '../../../types';
|
|
2
2
|
import { TransportStyleProps } from '../transportStyle';
|
|
3
3
|
export interface WaterfallProps extends TransportStyleProps {
|
|
4
|
-
/** 布局列数,@default
|
|
4
|
+
/** 布局列数,@default xs: 4 */
|
|
5
5
|
columnCount?: ResponsiveProp;
|
|
6
6
|
gap?: ResponsiveProp;
|
|
7
7
|
columnGap?: ResponsiveProp;
|
|
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const waterfall_style_1 = require("./waterfall.style");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
|
+
const transportStyle_1 = require("../transportStyle");
|
|
8
9
|
exports.Waterfall = (0, react_1.forwardRef)(({ columnCount = { xs: 4 }, gap = { xs: 0 }, columnGap, rowGap, ...props }, ref) => {
|
|
9
10
|
columnCount = (0, utils_1.responsiveValue)(columnCount);
|
|
10
11
|
gap = (0, utils_1.responsiveValue)(gap);
|
|
@@ -34,5 +35,5 @@ exports.Waterfall = (0, react_1.forwardRef)(({ columnCount = { xs: 4 }, gap = {
|
|
|
34
35
|
resizeObserver.disconnect();
|
|
35
36
|
};
|
|
36
37
|
}, [props.children, columnCountNum]);
|
|
37
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
38
|
+
return ((0, jsx_runtime_1.jsx)(transportStyle_1.TransportStyle, { ...props, ref: ref, css: (0, waterfall_style_1.useStyle)({ columnCount, columnGap, rowGap }), className: (0, utils_1.classnames)(waterfall_style_1.classes.root, props.className), style: containerHeight ? { height: containerHeight } : void 0, children: react_1.Children.map(props.children, (child, i) => (0, jsx_runtime_1.jsx)("div", { ref: r => r && items.current.push(r), className: waterfall_style_1.classes.item, style: { order: orders?.[i] }, children: child }, (0, react_1.isValidElement)(child) ? child.key ?? i : i)) }));
|
|
38
39
|
});
|
|
@@ -2,23 +2,31 @@ 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
4
|
import { classnames } from '../../utils';
|
|
5
|
+
import { TransportStyle } from '../transportStyle';
|
|
5
6
|
export const Flex = forwardRef(({ inline, direction = 'row', wrap, gap = 0, columnGap, rowGap, compact, ...props }, ref) => {
|
|
6
|
-
const
|
|
7
|
-
|
|
7
|
+
const renderChildren = () => {
|
|
8
|
+
if (!compact) {
|
|
9
|
+
return props.children;
|
|
10
|
+
}
|
|
11
|
+
const childrenCount = Children.count(props.children);
|
|
12
|
+
return Children.map(props.children, (child, index) => {
|
|
13
|
+
if (!isValidElement(child)) {
|
|
14
|
+
return child;
|
|
15
|
+
}
|
|
16
|
+
return cloneElement(child, {
|
|
17
|
+
...index === 0 && { 'data-first': true },
|
|
18
|
+
...index === childrenCount - 1 && { 'data-last': true },
|
|
19
|
+
...{ 'data-compact': direction.split('-')[0] }
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
return (_jsx(TransportStyle, { ...props, ref: ref, className: classnames(classes.root, props.className), style: {
|
|
8
24
|
display: inline ? 'inline-flex' : 'flex',
|
|
9
25
|
flexDirection: direction,
|
|
10
|
-
flexWrap: wrap,
|
|
26
|
+
flexWrap: wrap,
|
|
27
|
+
gap: gap,
|
|
28
|
+
columnGap: columnGap,
|
|
29
|
+
rowGap: rowGap,
|
|
11
30
|
...props.style
|
|
12
|
-
}, children:
|
|
13
|
-
? Children.map(props.children, (child, index) => {
|
|
14
|
-
if (!isValidElement(child)) {
|
|
15
|
-
return child;
|
|
16
|
-
}
|
|
17
|
-
return cloneElement(child, {
|
|
18
|
-
...index === 0 && { 'data-first': true },
|
|
19
|
-
...index === childrenCount - 1 && { 'data-last': true },
|
|
20
|
-
...{ 'data-compact': direction.split('-')[0] }
|
|
21
|
-
});
|
|
22
|
-
})
|
|
23
|
-
: props.children }));
|
|
31
|
+
}, children: renderChildren() }));
|
|
24
32
|
});
|
|
@@ -4,7 +4,7 @@ import { GridItem } from './gridItem';
|
|
|
4
4
|
import { TransportStyleProps } from '../transportStyle';
|
|
5
5
|
export interface GridProps extends TransportStyleProps {
|
|
6
6
|
inline?: boolean;
|
|
7
|
-
/** 网格列数,@default
|
|
7
|
+
/** 网格列数,@default xs: 12 */
|
|
8
8
|
columnCount?: ResponsiveProp;
|
|
9
9
|
gap?: ResponsiveProp;
|
|
10
10
|
columnGap?: ResponsiveProp;
|
|
@@ -3,12 +3,13 @@ import { forwardRef } from 'react';
|
|
|
3
3
|
import { classes, containerStyle } from './grid.style';
|
|
4
4
|
import { GridItem } from './gridItem';
|
|
5
5
|
import { classnames, responsiveValue } from '../../utils';
|
|
6
|
+
import { TransportStyle } from '../transportStyle';
|
|
6
7
|
export const Grid = forwardRef(({ inline, columnCount = { xs: 12 }, gap = { xs: 0 }, columnGap, rowGap, ...props }, ref) => {
|
|
7
8
|
columnCount = responsiveValue(columnCount);
|
|
8
9
|
gap = responsiveValue(gap);
|
|
9
10
|
columnGap = responsiveValue(columnGap) ?? gap;
|
|
10
11
|
rowGap = responsiveValue(rowGap) ?? gap;
|
|
11
|
-
return (_jsx(
|
|
12
|
+
return (_jsx(TransportStyle, { ...props, ref: ref, css: containerStyle({ columnCount, columnGap, rowGap }), className: classnames(classes.root, props.className), style: {
|
|
12
13
|
display: inline ? 'inline-flex' : 'flex',
|
|
13
14
|
...props.style
|
|
14
15
|
} }));
|
|
@@ -2,8 +2,9 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import { classnames, responsiveValue } from '../../utils';
|
|
4
4
|
import { classes, itemStyle } from './grid.style';
|
|
5
|
+
import { TransportStyle } from '../transportStyle';
|
|
5
6
|
export const GridItem = forwardRef(({ span = { xs: 1 }, offset = { xs: 0 }, ...props }, ref) => {
|
|
6
7
|
span = responsiveValue(span);
|
|
7
8
|
offset = responsiveValue(offset);
|
|
8
|
-
return (_jsx(
|
|
9
|
+
return (_jsx(TransportStyle, { ...props, ref: ref, css: itemStyle({ span, offset }), className: classnames(classes.item, props.className) }));
|
|
9
10
|
});
|
|
@@ -2,10 +2,28 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
export const TransportStyle = forwardRef(({ alignItems, justifyContent, alignSelf, justifySelf, flex, width, minWidth, maxWidth, height, minHeight, maxHeight, lineHeight, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, margin, marginTop, marginRight, marginBottom, marginLeft, ...props }, ref) => {
|
|
4
4
|
return (_jsx("div", { ...props, ref: ref, style: {
|
|
5
|
-
alignItems
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
alignItems: alignItems,
|
|
6
|
+
justifyContent: justifyContent,
|
|
7
|
+
alignSelf: alignSelf,
|
|
8
|
+
justifySelf: justifySelf,
|
|
9
|
+
flex: flex,
|
|
10
|
+
width: width,
|
|
11
|
+
minWidth: minWidth,
|
|
12
|
+
maxWidth: maxWidth,
|
|
13
|
+
height: height,
|
|
14
|
+
minHeight: minHeight,
|
|
15
|
+
maxHeight: maxHeight,
|
|
16
|
+
lineHeight: lineHeight,
|
|
17
|
+
padding: padding,
|
|
18
|
+
paddingTop: paddingTop,
|
|
19
|
+
paddingRight: paddingRight,
|
|
20
|
+
paddingBottom: paddingBottom,
|
|
21
|
+
paddingLeft: paddingLeft,
|
|
22
|
+
margin: margin,
|
|
23
|
+
marginTop: marginTop,
|
|
24
|
+
marginRight: marginRight,
|
|
25
|
+
marginBottom: marginBottom,
|
|
26
|
+
marginLeft: marginLeft,
|
|
9
27
|
...props.style
|
|
10
28
|
} }));
|
|
11
29
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResponsiveProp } from '../../../types';
|
|
2
2
|
import { TransportStyleProps } from '../transportStyle';
|
|
3
3
|
export interface WaterfallProps extends TransportStyleProps {
|
|
4
|
-
/** 布局列数,@default
|
|
4
|
+
/** 布局列数,@default xs: 4 */
|
|
5
5
|
columnCount?: ResponsiveProp;
|
|
6
6
|
gap?: ResponsiveProp;
|
|
7
7
|
columnGap?: ResponsiveProp;
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { Children, forwardRef, isValidElement, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { classes, useStyle } from './waterfall.style';
|
|
4
4
|
import { classnames, responsiveValue, useResponsiveValue } from '../../utils';
|
|
5
|
+
import { TransportStyle } from '../transportStyle';
|
|
5
6
|
export const Waterfall = forwardRef(({ columnCount = { xs: 4 }, gap = { xs: 0 }, columnGap, rowGap, ...props }, ref) => {
|
|
6
7
|
columnCount = responsiveValue(columnCount);
|
|
7
8
|
gap = responsiveValue(gap);
|
|
@@ -31,5 +32,5 @@ export const Waterfall = forwardRef(({ columnCount = { xs: 4 }, gap = { xs: 0 },
|
|
|
31
32
|
resizeObserver.disconnect();
|
|
32
33
|
};
|
|
33
34
|
}, [props.children, columnCountNum]);
|
|
34
|
-
return (_jsx(
|
|
35
|
+
return (_jsx(TransportStyle, { ...props, ref: ref, css: useStyle({ columnCount, columnGap, rowGap }), className: classnames(classes.root, props.className), style: containerHeight ? { height: containerHeight } : void 0, children: Children.map(props.children, (child, i) => _jsx("div", { ref: r => r && items.current.push(r), className: classes.item, style: { order: orders?.[i] }, children: child }, isValidElement(child) ? child.key ?? i : i)) }));
|
|
35
36
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canlooks/can-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"author": "C.CanLiang <canlooks@gmail.com>",
|
|
5
5
|
"description": "My ui framework",
|
|
6
6
|
"license": "MIT",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"tslib": "^2.8.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@canlooks/tscup": "^0.0.
|
|
57
|
+
"@canlooks/tscup": "^0.0.5",
|
|
58
58
|
"@mui/icons-material": "^6.1.5",
|
|
59
59
|
"@traptitech/markdown-it-katex": "^3.6.0",
|
|
60
60
|
"@types/color": "^3.0.6",
|
package/tscup.config.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import {defineConfig} from '@canlooks/tscup'
|
|
2
|
-
import * as path from 'path'
|
|
3
|
-
import {promises as fs} from 'fs'
|
|
4
2
|
|
|
5
3
|
export default defineConfig({
|
|
6
4
|
format: ['cjs', 'esm'],
|
|
7
5
|
clean: true,
|
|
8
|
-
|
|
9
|
-
await fs.cp(
|
|
10
|
-
path.resolve('types'),
|
|
11
|
-
path.resolve('dist/types'),
|
|
12
|
-
{recursive: true}
|
|
13
|
-
)
|
|
14
|
-
}
|
|
6
|
+
copyDir: 'types'
|
|
15
7
|
})
|