@canlooks/can-ui 0.0.5 → 0.0.6

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.
@@ -5,23 +5,28 @@ 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 childrenCount = react_1.Children.count(props.children);
10
- return ((0, jsx_runtime_1.jsx)("div", { ...props, ref: ref, className: (0, utils_1.classnames)(flex_style_1.classes.root, props.className), style: {
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
29
  flexWrap: wrap, gap, columnGap, rowGap,
14
30
  ...props.style
15
- }, children: compact
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 }));
31
+ }, children: renderChildren() }));
27
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 {xs: 12} */
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)("div", { ...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
+ 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)("div", { ...props, ref: ref, css: (0, grid_style_1.itemStyle)({ span, offset }), className: (0, utils_1.classnames)(grid_style_1.classes.item, props.className) }));
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
  });
@@ -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 {xs: 4} */
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)("div", { ...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
+ 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,28 @@ 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 childrenCount = Children.count(props.children);
7
- return (_jsx("div", { ...props, ref: ref, className: classnames(classes.root, props.className), style: {
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
26
  flexWrap: wrap, gap, columnGap, rowGap,
11
27
  ...props.style
12
- }, children: compact
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 }));
28
+ }, children: renderChildren() }));
24
29
  });
@@ -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 {xs: 12} */
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("div", { ...props, ref: ref, css: containerStyle({ columnCount, columnGap, rowGap }), className: classnames(classes.root, props.className), style: {
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("div", { ...props, ref: ref, css: itemStyle({ span, offset }), className: classnames(classes.item, props.className) }));
9
+ return (_jsx(TransportStyle, { ...props, ref: ref, css: itemStyle({ span, offset }), className: classnames(classes.item, props.className) }));
9
10
  });
@@ -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 {xs: 4} */
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("div", { ...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
+ 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.5",
3
+ "version": "0.0.6",
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.4",
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
- async onFinish() {
9
- await fs.cp(
10
- path.resolve('types'),
11
- path.resolve('dist/types'),
12
- {recursive: true}
13
- )
14
- }
6
+ copyDir: 'types'
15
7
  })