@tecsinapse/react-web-kit 1.17.3 → 1.17.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.
- package/CHANGELOG.md +30 -0
- package/dist/components/molecules/Grid/Grid.d.ts +15 -0
- package/dist/components/molecules/Grid/Grid.js +55 -0
- package/dist/components/molecules/Grid/Grid.js.map +1 -0
- package/dist/components/molecules/Grid/Item/Item.d.ts +30 -0
- package/dist/components/molecules/Grid/Item/Item.js +66 -0
- package/dist/components/molecules/Grid/Item/Item.js.map +1 -0
- package/dist/components/molecules/Grid/Item/index.d.ts +2 -0
- package/dist/components/molecules/Grid/Item/index.js +16 -0
- package/dist/components/molecules/Grid/Item/index.js.map +1 -0
- package/dist/components/molecules/Grid/index.d.ts +4 -0
- package/dist/components/molecules/Grid/index.js +24 -0
- package/dist/components/molecules/Grid/index.js.map +1 -0
- package/dist/components/organisms/DataGrid/utils.js +1 -1
- package/dist/components/organisms/DataGrid/utils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/molecules/Grid/Grid.tsx +82 -0
- package/src/components/molecules/Grid/Item/Item.tsx +94 -0
- package/src/components/molecules/Grid/Item/index.ts +2 -0
- package/src/components/molecules/Grid/index.ts +4 -0
- package/src/components/organisms/DataGrid/utils.ts +1 -1
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.17.6](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.17.5...@tecsinapse/react-web-kit@1.17.6) (2022-06-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @tecsinapse/react-web-kit
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [1.17.5](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.17.4...@tecsinapse/react-web-kit@1.17.5) (2022-06-13)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* shallow copy on remove datagrid index ([3c4d087](https://github.com/tecsinapse/design-system/commit/3c4d087f04e57f4c0d20d2cfd93c776c0a217052))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [1.17.4](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.17.3...@tecsinapse/react-web-kit@1.17.4) (2022-06-08)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
* add grid for web based on div ([f44bc76](https://github.com/tecsinapse/design-system/commit/f44bc76f8e34ac7f918c21478002f04b3ff52ff8))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
## [1.17.3](https://github.com/tecsinapse/design-system/compare/@tecsinapse/react-web-kit@1.17.2...@tecsinapse/react-web-kit@1.17.3) (2022-05-24)
|
|
7
37
|
|
|
8
38
|
**Note:** Version bump only for package @tecsinapse/react-web-kit
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SpacingType } from '@tecsinapse/react-core';
|
|
3
|
+
export interface IGrid extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children: JSX.Element[];
|
|
5
|
+
layout?: number[][];
|
|
6
|
+
columns?: number;
|
|
7
|
+
spacing?: SpacingType | {
|
|
8
|
+
top?: SpacingType;
|
|
9
|
+
right?: SpacingType;
|
|
10
|
+
bottom?: SpacingType;
|
|
11
|
+
left?: SpacingType;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
declare const Grid: ({ children, columns, layout, style, spacing, ...rest }: IGrid) => JSX.Element;
|
|
15
|
+
export default Grid;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _Item = require("./Item");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
+
|
|
16
|
+
const Grid = ({
|
|
17
|
+
children,
|
|
18
|
+
columns = 12,
|
|
19
|
+
layout,
|
|
20
|
+
style,
|
|
21
|
+
spacing,
|
|
22
|
+
...rest
|
|
23
|
+
}) => {
|
|
24
|
+
if (layout) {
|
|
25
|
+
const flatLayout = layout.flat();
|
|
26
|
+
return _react.default.createElement("div", _extends({
|
|
27
|
+
style: { ...style,
|
|
28
|
+
display: 'flex',
|
|
29
|
+
flexDirection: 'row',
|
|
30
|
+
flexWrap: 'wrap'
|
|
31
|
+
}
|
|
32
|
+
}, rest), _react.default.Children.map(children, (child, index) => _react.default.createElement(_Item.GridItem, {
|
|
33
|
+
columns: columns,
|
|
34
|
+
span: flatLayout[index],
|
|
35
|
+
spacing: spacing
|
|
36
|
+
}, child)));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return _react.default.createElement("div", _extends({
|
|
40
|
+
style: { ...style,
|
|
41
|
+
display: 'flex',
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
flexWrap: 'wrap'
|
|
44
|
+
}
|
|
45
|
+
}, rest), _react.default.Children.map(children, child => {
|
|
46
|
+
return _react.default.cloneElement(child, { ...(child === null || child === void 0 ? void 0 : child.props),
|
|
47
|
+
columns,
|
|
48
|
+
spacing: (child === null || child === void 0 ? void 0 : child.props.spacing) ?? spacing
|
|
49
|
+
});
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var _default = Grid;
|
|
54
|
+
exports.default = _default;
|
|
55
|
+
//# sourceMappingURL=Grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/molecules/Grid/Grid.tsx"],"names":["Grid","children","columns","layout","style","spacing","rest","flatLayout","flat","display","flexDirection","flexWrap","React","Children","map","child","index","cloneElement","props"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AA0BA,MAAMA,IAAI,GAAG,CAAC;AACZC,EAAAA,QADY;AAEZC,EAAAA,OAAO,GAAG,EAFE;AAGZC,EAAAA,MAHY;AAIZC,EAAAA,KAJY;AAKZC,EAAAA,OALY;AAMZ,KAAGC;AANS,CAAD,KAOA;AACX,MAAIH,MAAJ,EAAY;AACV,UAAMI,UAAU,GAAGJ,MAAM,CAACK,IAAP,EAAnB;AACA,WACE;AACE,MAAA,KAAK,EAAE,EACL,GAAGJ,KADE;AAELK,QAAAA,OAAO,EAAE,MAFJ;AAGLC,QAAAA,aAAa,EAAE,KAHV;AAILC,QAAAA,QAAQ,EAAE;AAJL;AADT,OAOML,IAPN,GASGM,eAAMC,QAAN,CAAeC,GAAf,CAAmBb,QAAnB,EAA6B,CAACc,KAAD,EAAQC,KAAR,KAC5B,6BAAC,cAAD;AACE,MAAA,OAAO,EAAEd,OADX;AAEE,MAAA,IAAI,EAAEK,UAAU,CAACS,KAAD,CAFlB;AAGE,MAAA,OAAO,EAAEX;AAHX,OAKGU,KALH,CADD,CATH,CADF;AAqBD;;AAED,SACE;AACE,IAAA,KAAK,EAAE,EACL,GAAGX,KADE;AAELK,MAAAA,OAAO,EAAE,MAFJ;AAGLC,MAAAA,aAAa,EAAE,KAHV;AAILC,MAAAA,QAAQ,EAAE;AAJL;AADT,KAOML,IAPN,GASGM,eAAMC,QAAN,CAAeC,GAAf,CAAmBb,QAAnB,EAA6Bc,KAAK,IAAI;AACrC,WAAOH,eAAMK,YAAN,CAAmBF,KAAnB,EAA0B,EAC/B,IAAGA,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEG,KAAV,CAD+B;AAE/BhB,MAAAA,OAF+B;AAG/BG,MAAAA,OAAO,EAAE,CAAAU,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEG,KAAP,CAAab,OAAb,KAAwBA;AAHF,KAA1B,CAAP;AAKD,GANA,CATH,CADF;AAmBD,CApDD;;eAsDeL,I","sourcesContent":["import React from 'react';\nimport { GridItem } from './Item';\nimport { SpacingType } from '@tecsinapse/react-core';\n\nexport interface IGrid extends React.HTMLAttributes<HTMLDivElement> {\n children: JSX.Element[];\n /** Layout should represent the multiplier of columns to fill the rows properly.\n * Example:\n * const layout = [\n * [6, 6], // Two elements on row\n * [4, 4, 4], // Three elements on row\n * [12], // One element on row\n * ];\n * */\n layout?: number[][];\n /** Number of grid columns to be considered (not the number of elements per row) */\n columns?: number;\n spacing?:\n | SpacingType\n | {\n top?: SpacingType;\n right?: SpacingType;\n bottom?: SpacingType;\n left?: SpacingType;\n };\n}\n\nconst Grid = ({\n children,\n columns = 12,\n layout,\n style,\n spacing,\n ...rest\n}: IGrid) => {\n if (layout) {\n const flatLayout = layout.flat();\n return (\n <div\n style={{\n ...style,\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n }}\n {...rest}\n >\n {React.Children.map(children, (child, index) => (\n <GridItem\n columns={columns}\n span={flatLayout[index]}\n spacing={spacing}\n >\n {child}\n </GridItem>\n ))}\n </div>\n );\n }\n\n return (\n <div\n style={{\n ...style,\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n }}\n {...rest}\n >\n {React.Children.map(children, child => {\n return React.cloneElement(child, {\n ...child?.props,\n columns,\n spacing: child?.props.spacing ?? spacing,\n });\n })}\n </div>\n );\n};\n\nexport default Grid;\n"],"file":"Grid.js"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SpacingType } from '@tecsinapse/react-core';
|
|
3
|
+
declare type FlexPositioning = 'flex-start' | 'flex-end' | 'center';
|
|
4
|
+
declare type FlexAlignBase = FlexPositioning | 'stretch';
|
|
5
|
+
declare type FlexAlignType = FlexAlignBase | 'baseline';
|
|
6
|
+
declare type FlexSpacing = 'space-between' | 'space-around';
|
|
7
|
+
export interface IGridItem {
|
|
8
|
+
children: React.ReactElement;
|
|
9
|
+
span: number;
|
|
10
|
+
columns?: number;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
loadingComponent?: React.ReactElement;
|
|
13
|
+
alignContent?: FlexAlignBase | FlexSpacing;
|
|
14
|
+
alignItems?: FlexAlignType;
|
|
15
|
+
alignSelf?: 'auto' | FlexAlignType;
|
|
16
|
+
flex?: number;
|
|
17
|
+
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
18
|
+
flexGrow?: number;
|
|
19
|
+
flexShrink?: number;
|
|
20
|
+
justifyContent?: FlexPositioning | FlexSpacing | 'space-evenly';
|
|
21
|
+
spacing?: SpacingType | {
|
|
22
|
+
top?: SpacingType;
|
|
23
|
+
right?: SpacingType;
|
|
24
|
+
bottom?: SpacingType;
|
|
25
|
+
left?: SpacingType;
|
|
26
|
+
};
|
|
27
|
+
wrapper?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const GridItem: ({ children, span, columns, loadingComponent, loading, spacing: _spacing, wrapper, ...rest }: IGridItem) => JSX.Element;
|
|
30
|
+
export default GridItem;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _reactCore = require("@tecsinapse/react-core");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
const GridItem = ({
|
|
15
|
+
children,
|
|
16
|
+
span,
|
|
17
|
+
columns = 12,
|
|
18
|
+
loadingComponent,
|
|
19
|
+
loading = false,
|
|
20
|
+
spacing: _spacing,
|
|
21
|
+
wrapper = false,
|
|
22
|
+
...rest
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
spacing
|
|
26
|
+
} = (0, _reactCore.useTheme)();
|
|
27
|
+
|
|
28
|
+
if (!_react.default.Children.only(children)) {
|
|
29
|
+
throw new Error('The number of children in GridItem should be one');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (loadingComponent && loading) {
|
|
33
|
+
return loadingComponent;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const getPadding = pos => {
|
|
37
|
+
if (_spacing) {
|
|
38
|
+
if (typeof _spacing === 'string') return (0, _reactCore.extractNumbersFromString)(spacing[_spacing]);else if (typeof _spacing === 'object' && _spacing[pos]) {
|
|
39
|
+
return (0, _reactCore.extractNumbersFromString)(spacing[_spacing[pos]]);
|
|
40
|
+
} else return undefined;
|
|
41
|
+
} else return undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const style = { ...rest,
|
|
45
|
+
boxSizing: 'border-box',
|
|
46
|
+
flexBasis: `${100 / (columns / span)}%`,
|
|
47
|
+
paddingTop: getPadding('top'),
|
|
48
|
+
paddingBottom: getPadding('bottom'),
|
|
49
|
+
paddingRight: getPadding('right'),
|
|
50
|
+
paddingLeft: getPadding('left')
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const clone = _react.default.cloneElement(children, { ...(children === null || children === void 0 ? void 0 : children.props),
|
|
54
|
+
style: wrapper ? children === null || children === void 0 ? void 0 : children.props.style : { ...style,
|
|
55
|
+
...(children === null || children === void 0 ? void 0 : children.props.style)
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return wrapper ? _react.default.createElement("div", {
|
|
60
|
+
style: style
|
|
61
|
+
}, clone) : clone;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var _default = GridItem;
|
|
65
|
+
exports.default = _default;
|
|
66
|
+
//# sourceMappingURL=Item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/molecules/Grid/Item/Item.tsx"],"names":["GridItem","children","span","columns","loadingComponent","loading","spacing","_spacing","wrapper","rest","React","Children","only","Error","getPadding","pos","undefined","style","boxSizing","flexBasis","paddingTop","paddingBottom","paddingRight","paddingLeft","clone","cloneElement","props"],"mappings":";;;;;;;AAAA;;AACA;;;;AA4CA,MAAMA,QAAQ,GAAG,CAAC;AAChBC,EAAAA,QADgB;AAEhBC,EAAAA,IAFgB;AAGhBC,EAAAA,OAAO,GAAG,EAHM;AAIhBC,EAAAA,gBAJgB;AAKhBC,EAAAA,OAAO,GAAG,KALM;AAMhBC,EAAAA,OAAO,EAAEC,QANO;AAOhBC,EAAAA,OAAO,GAAG,KAPM;AAQhB,KAAGC;AARa,CAAD,KASA;AACf,QAAM;AAAEH,IAAAA;AAAF,MAAc,0BAApB;;AACA,MAAI,CAACI,eAAMC,QAAN,CAAeC,IAAf,CAAoBX,QAApB,CAAL,EAAoC;AAClC,UAAM,IAAIY,KAAJ,CAAU,kDAAV,CAAN;AACD;;AACD,MAAIT,gBAAgB,IAAIC,OAAxB,EAAiC;AAC/B,WAAOD,gBAAP;AACD;;AAED,QAAMU,UAAU,GAAIC,GAAD,IAA0B;AAC3C,QAAIR,QAAJ,EAAc;AACZ,UAAI,OAAOA,QAAP,KAAoB,QAAxB,EACE,OAAO,yCAAyBD,OAAO,CAACC,QAAD,CAAhC,CAAP,CADF,KAEK,IAAI,OAAOA,QAAP,KAAoB,QAApB,IAAgCA,QAAQ,CAACQ,GAAD,CAA5C,EAAmD;AACtD,eAAO,yCAAyBT,OAAO,CAACC,QAAQ,CAACQ,GAAD,CAAT,CAAhC,CAAP;AACD,OAFI,MAEE,OAAOC,SAAP;AACR,KAND,MAMO,OAAOA,SAAP;AACR,GARD;;AAUA,QAAMC,KAA0B,GAAG,EACjC,GAAGR,IAD8B;AAEjCS,IAAAA,SAAS,EAAE,YAFsB;AAGjCC,IAAAA,SAAS,EAAG,GAAE,OAAOhB,OAAO,GAAGD,IAAjB,CAAuB,GAHJ;AAIjCkB,IAAAA,UAAU,EAAEN,UAAU,CAAC,KAAD,CAJW;AAKjCO,IAAAA,aAAa,EAAEP,UAAU,CAAC,QAAD,CALQ;AAMjCQ,IAAAA,YAAY,EAAER,UAAU,CAAC,OAAD,CANS;AAOjCS,IAAAA,WAAW,EAAET,UAAU,CAAC,MAAD;AAPU,GAAnC;;AAUA,QAAMU,KAAK,GAAGd,eAAMe,YAAN,CAAmBxB,QAAnB,EAA6B,EACzC,IAAGA,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEyB,KAAb,CADyC;AAEzCT,IAAAA,KAAK,EAAET,OAAO,GACVP,QADU,aACVA,QADU,uBACVA,QAAQ,CAAEyB,KAAV,CAAgBT,KADN,GAEV,EAAE,GAAGA,KAAL;AAAY,UAAGhB,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEyB,KAAV,CAAgBT,KAAnB;AAAZ;AAJqC,GAA7B,CAAd;;AAOA,SAAOT,OAAO,GAAG;AAAK,IAAA,KAAK,EAAES;AAAZ,KAAoBO,KAApB,CAAH,GAAsCA,KAApD;AACD,CA9CD;;eAgDexB,Q","sourcesContent":["import React from 'react';\nimport {\n extractNumbersFromString,\n SpacingType,\n useTheme,\n} from '@tecsinapse/react-core';\n\ntype FlexPositioning = 'flex-start' | 'flex-end' | 'center';\ntype FlexAlignBase = FlexPositioning | 'stretch';\ntype FlexAlignType = FlexAlignBase | 'baseline';\ntype FlexSpacing = 'space-between' | 'space-around';\n\ntype PaddingPosition = 'top' | 'right' | 'bottom' | 'left';\n\nexport interface IGridItem {\n children: React.ReactElement;\n /** Number of columns to fill */\n span: number;\n /** You don't have to give this property since is inherited from Grid */\n columns?: number;\n loading?: boolean;\n /** If your GridItem has a loading state, specify the component here (Skeleton) */\n loadingComponent?: React.ReactElement;\n /** Flex properties below */\n alignContent?: FlexAlignBase | FlexSpacing;\n alignItems?: FlexAlignType;\n alignSelf?: 'auto' | FlexAlignType;\n flex?: number;\n flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';\n flexGrow?: number;\n flexShrink?: number;\n justifyContent?: FlexPositioning | FlexSpacing | 'space-evenly';\n /** You don't have to give this property since is inherited from Grid */\n spacing?:\n | SpacingType\n | {\n top?: SpacingType;\n right?: SpacingType;\n bottom?: SpacingType;\n left?: SpacingType;\n };\n /** Used to wrap children in a View when its style extrapolates the dimensions*/\n wrapper?: boolean;\n}\n\nconst GridItem = ({\n children,\n span,\n columns = 12,\n loadingComponent,\n loading = false,\n spacing: _spacing,\n wrapper = false,\n ...rest\n}: IGridItem) => {\n const { spacing } = useTheme();\n if (!React.Children.only(children)) {\n throw new Error('The number of children in GridItem should be one');\n }\n if (loadingComponent && loading) {\n return loadingComponent;\n }\n\n const getPadding = (pos: PaddingPosition) => {\n if (_spacing) {\n if (typeof _spacing === 'string')\n return extractNumbersFromString(spacing[_spacing]);\n else if (typeof _spacing === 'object' && _spacing[pos]) {\n return extractNumbersFromString(spacing[_spacing[pos]!]);\n } else return undefined;\n } else return undefined;\n };\n\n const style: React.CSSProperties = {\n ...rest,\n boxSizing: 'border-box',\n flexBasis: `${100 / (columns / span)}%`,\n paddingTop: getPadding('top'),\n paddingBottom: getPadding('bottom'),\n paddingRight: getPadding('right'),\n paddingLeft: getPadding('left'),\n };\n\n const clone = React.cloneElement(children, {\n ...children?.props,\n style: wrapper\n ? children?.props.style\n : { ...style, ...children?.props.style },\n });\n\n return wrapper ? <div style={style}>{clone}</div> : clone;\n};\n\nexport default GridItem;\n"],"file":"Item.js"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "GridItem", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Item.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _Item = _interopRequireDefault(require("./Item"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/molecules/Grid/Item/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA","sourcesContent":["export { default as GridItem } from './Item';\nexport type { IGridItem } from './Item';\n"],"file":"index.js"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "GridItem", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Item.GridItem;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "Grid", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Grid.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _Item = require("./Item");
|
|
20
|
+
|
|
21
|
+
var _Grid = _interopRequireDefault(require("./Grid"));
|
|
22
|
+
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/molecules/Grid/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA","sourcesContent":["export { GridItem } from './Item';\nexport type { IGridItem } from './Item';\nexport { default as Grid } from './Grid';\nexport type { IGrid } from './Grid';\n"],"file":"index.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/organisms/DataGrid/utils.ts"],"names":["removeElement","arr","index","data","splice","getData","rowsCount","page","rowsPerPage","pagination","slice"],"mappings":";;;;;;;;AAAO,SAASA,aAAT,CAA0BC,GAA1B,EAAoCC,KAApC,EAAwD;AAC7D,QAAMC,IAAI,GAAGF,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/organisms/DataGrid/utils.ts"],"names":["removeElement","arr","index","data","splice","getData","rowsCount","page","rowsPerPage","pagination","slice"],"mappings":";;;;;;;;AAAO,SAASA,aAAT,CAA0BC,GAA1B,EAAoCC,KAApC,EAAwD;AAC7D,QAAMC,IAAI,GAAG,CAAC,GAAGF,GAAJ,CAAb;AACAE,EAAAA,IAAI,CAACC,MAAL,CAAYF,KAAZ,EAAmB,CAAnB;AACA,SAAOC,IAAP;AACD;;AAEM,MAAME,OAAO,GAAG,CACrBF,IADqB,EAErBG,SAFqB,EAGrBC,IAHqB,EAIrBC,WAJqB,EAKrBC,UALqB,KAOrBH,SAAS,IAAI,CAACG,UAAd,GACIN,IADJ,GAEIA,IAAI,CAACO,KAAL,CAAWH,IAAI,GAAGC,WAAlB,EAA+BD,IAAI,GAAGC,WAAP,GAAqBA,WAApD,CATC","sourcesContent":["export function removeElement<T>(arr: T[], index: number): T[] {\n const data = [...arr]; // Sometimes looks like the data is removed from table, check if this is a bug. I'm copying the arr to a new variable for security reasons\n data.splice(index, 1);\n return data;\n}\n\nexport const getData = <Data>(\n data: Data[],\n rowsCount: number | undefined,\n page: number,\n rowsPerPage: number,\n pagination: boolean\n): Data[] =>\n rowsCount || !pagination\n ? data\n : data.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage);\n"],"file":"utils.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,3 +19,4 @@ export { Tooltip, ITooltip } from './components/atoms/Tooltip';
|
|
|
19
19
|
export * from './hooks';
|
|
20
20
|
export { DatePicker, WebDatePickerProps, } from './components/molecules/DatePicker';
|
|
21
21
|
export { DateTimePicker, WebDateTimePickerProps, } from './components/molecules/DateTimePicker';
|
|
22
|
+
export { Grid, GridItem, IGrid, IGridItem } from './components/molecules/Grid';
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,11 @@ var _exportNames = {
|
|
|
47
47
|
DatePicker: true,
|
|
48
48
|
WebDatePickerProps: true,
|
|
49
49
|
DateTimePicker: true,
|
|
50
|
-
WebDateTimePickerProps: true
|
|
50
|
+
WebDateTimePickerProps: true,
|
|
51
|
+
Grid: true,
|
|
52
|
+
GridItem: true,
|
|
53
|
+
IGrid: true,
|
|
54
|
+
IGridItem: true
|
|
51
55
|
};
|
|
52
56
|
Object.defineProperty(exports, "Badge", {
|
|
53
57
|
enumerable: true,
|
|
@@ -313,6 +317,30 @@ Object.defineProperty(exports, "WebDateTimePickerProps", {
|
|
|
313
317
|
return _DateTimePicker.WebDateTimePickerProps;
|
|
314
318
|
}
|
|
315
319
|
});
|
|
320
|
+
Object.defineProperty(exports, "Grid", {
|
|
321
|
+
enumerable: true,
|
|
322
|
+
get: function () {
|
|
323
|
+
return _Grid.Grid;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
Object.defineProperty(exports, "GridItem", {
|
|
327
|
+
enumerable: true,
|
|
328
|
+
get: function () {
|
|
329
|
+
return _Grid.GridItem;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
Object.defineProperty(exports, "IGrid", {
|
|
333
|
+
enumerable: true,
|
|
334
|
+
get: function () {
|
|
335
|
+
return _Grid.IGrid;
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
Object.defineProperty(exports, "IGridItem", {
|
|
339
|
+
enumerable: true,
|
|
340
|
+
get: function () {
|
|
341
|
+
return _Grid.IGridItem;
|
|
342
|
+
}
|
|
343
|
+
});
|
|
316
344
|
|
|
317
345
|
var _reactCore = require("@tecsinapse/react-core");
|
|
318
346
|
|
|
@@ -380,6 +408,8 @@ var _DatePicker = require("./components/molecules/DatePicker");
|
|
|
380
408
|
|
|
381
409
|
var _DateTimePicker = require("./components/molecules/DateTimePicker");
|
|
382
410
|
|
|
411
|
+
var _Grid = require("./components/molecules/Grid");
|
|
412
|
+
|
|
383
413
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
384
414
|
|
|
385
415
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AAOA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAIA;;AAIA","sourcesContent":["export * from '@tecsinapse/react-core';\nexport {\n default as Badge,\n BadgeWebProps,\n} from './components/atoms/Badge/Badge';\nexport {\n Button,\n useMouseHover,\n WebButtonProps,\n} from './components/atoms/Button';\nexport { Input, InputWebProps } from './components/atoms/Input';\nexport { Tag, TagProps } from './components/atoms/Tag';\nexport {\n InputPassword,\n InputPasswordWebProps,\n} from './components/molecules/InputPassword';\nexport { InputMask, InputMaskWebProps } from './components/atoms/InputMask';\nexport {\n Menubar,\n MenubarProps,\n MenubarOptionsType,\n MenubarItemsOptions,\n MenubarMostUsedType,\n} from './components/molecules/Menubar';\nexport { Drawer, DrawerProps } from './components/molecules/Drawer';\nexport { Select, SelectProps } from './components/molecules/Select';\nexport { Snackbar, SnackbarWebProps } from './components/molecules/Snackbar';\nexport {\n Breadcrumbs,\n BreadcrumbsProps,\n BreadcrumbType,\n} from './components/molecules/Breadcrumbs';\nexport { Skeleton, SkeletonProps } from './components/atoms/Skeleton';\nexport { Accordion, AccordionProps } from './components/atoms/Accordion';\nexport {\n DataGrid,\n DataGridProps,\n HeadersType,\n} from './components/organisms/DataGrid';\nexport { Modal, ModalProps } from './components/atoms/Modal';\nexport { TextArea, TextAreaProps } from './components/molecules/TextArea';\nexport { Tooltip, ITooltip } from './components/atoms/Tooltip';\nexport * from './hooks';\nexport {\n DatePicker,\n WebDatePickerProps,\n} from './components/molecules/DatePicker';\nexport {\n DateTimePicker,\n WebDateTimePickerProps,\n} from './components/molecules/DateTimePicker';\nexport { Grid, GridItem, IGrid, IGridItem } from './components/molecules/Grid';\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/react-web-kit",
|
|
3
3
|
"description": "TecSinapse React components",
|
|
4
|
-
"version": "1.17.
|
|
4
|
+
"version": "1.17.6",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@emotion/native": "^11.0.0",
|
|
15
15
|
"@emotion/react": "^11.4.1",
|
|
16
16
|
"@emotion/styled": "^11.3.0",
|
|
17
|
-
"@tecsinapse/react-core": "^1.16.
|
|
17
|
+
"@tecsinapse/react-core": "^1.16.2",
|
|
18
18
|
"@types/react-native": "^0.64.4",
|
|
19
19
|
"react-native-vector-icons": "^9.1.0",
|
|
20
20
|
"react-transition-group": "^4.4.2"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
34
34
|
"react-native-web": "^0.17.1"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "0935a2a1210e341648136e3247ec54c41815142f"
|
|
37
37
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GridItem } from './Item';
|
|
3
|
+
import { SpacingType } from '@tecsinapse/react-core';
|
|
4
|
+
|
|
5
|
+
export interface IGrid extends React.HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
children: JSX.Element[];
|
|
7
|
+
/** Layout should represent the multiplier of columns to fill the rows properly.
|
|
8
|
+
* Example:
|
|
9
|
+
* const layout = [
|
|
10
|
+
* [6, 6], // Two elements on row
|
|
11
|
+
* [4, 4, 4], // Three elements on row
|
|
12
|
+
* [12], // One element on row
|
|
13
|
+
* ];
|
|
14
|
+
* */
|
|
15
|
+
layout?: number[][];
|
|
16
|
+
/** Number of grid columns to be considered (not the number of elements per row) */
|
|
17
|
+
columns?: number;
|
|
18
|
+
spacing?:
|
|
19
|
+
| SpacingType
|
|
20
|
+
| {
|
|
21
|
+
top?: SpacingType;
|
|
22
|
+
right?: SpacingType;
|
|
23
|
+
bottom?: SpacingType;
|
|
24
|
+
left?: SpacingType;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const Grid = ({
|
|
29
|
+
children,
|
|
30
|
+
columns = 12,
|
|
31
|
+
layout,
|
|
32
|
+
style,
|
|
33
|
+
spacing,
|
|
34
|
+
...rest
|
|
35
|
+
}: IGrid) => {
|
|
36
|
+
if (layout) {
|
|
37
|
+
const flatLayout = layout.flat();
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
style={{
|
|
41
|
+
...style,
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
flexWrap: 'wrap',
|
|
45
|
+
}}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
{React.Children.map(children, (child, index) => (
|
|
49
|
+
<GridItem
|
|
50
|
+
columns={columns}
|
|
51
|
+
span={flatLayout[index]}
|
|
52
|
+
spacing={spacing}
|
|
53
|
+
>
|
|
54
|
+
{child}
|
|
55
|
+
</GridItem>
|
|
56
|
+
))}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div
|
|
63
|
+
style={{
|
|
64
|
+
...style,
|
|
65
|
+
display: 'flex',
|
|
66
|
+
flexDirection: 'row',
|
|
67
|
+
flexWrap: 'wrap',
|
|
68
|
+
}}
|
|
69
|
+
{...rest}
|
|
70
|
+
>
|
|
71
|
+
{React.Children.map(children, child => {
|
|
72
|
+
return React.cloneElement(child, {
|
|
73
|
+
...child?.props,
|
|
74
|
+
columns,
|
|
75
|
+
spacing: child?.props.spacing ?? spacing,
|
|
76
|
+
});
|
|
77
|
+
})}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default Grid;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
extractNumbersFromString,
|
|
4
|
+
SpacingType,
|
|
5
|
+
useTheme,
|
|
6
|
+
} from '@tecsinapse/react-core';
|
|
7
|
+
|
|
8
|
+
type FlexPositioning = 'flex-start' | 'flex-end' | 'center';
|
|
9
|
+
type FlexAlignBase = FlexPositioning | 'stretch';
|
|
10
|
+
type FlexAlignType = FlexAlignBase | 'baseline';
|
|
11
|
+
type FlexSpacing = 'space-between' | 'space-around';
|
|
12
|
+
|
|
13
|
+
type PaddingPosition = 'top' | 'right' | 'bottom' | 'left';
|
|
14
|
+
|
|
15
|
+
export interface IGridItem {
|
|
16
|
+
children: React.ReactElement;
|
|
17
|
+
/** Number of columns to fill */
|
|
18
|
+
span: number;
|
|
19
|
+
/** You don't have to give this property since is inherited from Grid */
|
|
20
|
+
columns?: number;
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
/** If your GridItem has a loading state, specify the component here (Skeleton) */
|
|
23
|
+
loadingComponent?: React.ReactElement;
|
|
24
|
+
/** Flex properties below */
|
|
25
|
+
alignContent?: FlexAlignBase | FlexSpacing;
|
|
26
|
+
alignItems?: FlexAlignType;
|
|
27
|
+
alignSelf?: 'auto' | FlexAlignType;
|
|
28
|
+
flex?: number;
|
|
29
|
+
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
30
|
+
flexGrow?: number;
|
|
31
|
+
flexShrink?: number;
|
|
32
|
+
justifyContent?: FlexPositioning | FlexSpacing | 'space-evenly';
|
|
33
|
+
/** You don't have to give this property since is inherited from Grid */
|
|
34
|
+
spacing?:
|
|
35
|
+
| SpacingType
|
|
36
|
+
| {
|
|
37
|
+
top?: SpacingType;
|
|
38
|
+
right?: SpacingType;
|
|
39
|
+
bottom?: SpacingType;
|
|
40
|
+
left?: SpacingType;
|
|
41
|
+
};
|
|
42
|
+
/** Used to wrap children in a View when its style extrapolates the dimensions*/
|
|
43
|
+
wrapper?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const GridItem = ({
|
|
47
|
+
children,
|
|
48
|
+
span,
|
|
49
|
+
columns = 12,
|
|
50
|
+
loadingComponent,
|
|
51
|
+
loading = false,
|
|
52
|
+
spacing: _spacing,
|
|
53
|
+
wrapper = false,
|
|
54
|
+
...rest
|
|
55
|
+
}: IGridItem) => {
|
|
56
|
+
const { spacing } = useTheme();
|
|
57
|
+
if (!React.Children.only(children)) {
|
|
58
|
+
throw new Error('The number of children in GridItem should be one');
|
|
59
|
+
}
|
|
60
|
+
if (loadingComponent && loading) {
|
|
61
|
+
return loadingComponent;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const getPadding = (pos: PaddingPosition) => {
|
|
65
|
+
if (_spacing) {
|
|
66
|
+
if (typeof _spacing === 'string')
|
|
67
|
+
return extractNumbersFromString(spacing[_spacing]);
|
|
68
|
+
else if (typeof _spacing === 'object' && _spacing[pos]) {
|
|
69
|
+
return extractNumbersFromString(spacing[_spacing[pos]!]);
|
|
70
|
+
} else return undefined;
|
|
71
|
+
} else return undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const style: React.CSSProperties = {
|
|
75
|
+
...rest,
|
|
76
|
+
boxSizing: 'border-box',
|
|
77
|
+
flexBasis: `${100 / (columns / span)}%`,
|
|
78
|
+
paddingTop: getPadding('top'),
|
|
79
|
+
paddingBottom: getPadding('bottom'),
|
|
80
|
+
paddingRight: getPadding('right'),
|
|
81
|
+
paddingLeft: getPadding('left'),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const clone = React.cloneElement(children, {
|
|
85
|
+
...children?.props,
|
|
86
|
+
style: wrapper
|
|
87
|
+
? children?.props.style
|
|
88
|
+
: { ...style, ...children?.props.style },
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return wrapper ? <div style={style}>{clone}</div> : clone;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default GridItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function removeElement<T>(arr: T[], index: number): T[] {
|
|
2
|
-
const data = arr; // Sometimes looks like the data is removed from table, check if this is a bug. I'm copying the arr to a new variable for security reasons
|
|
2
|
+
const data = [...arr]; // Sometimes looks like the data is removed from table, check if this is a bug. I'm copying the arr to a new variable for security reasons
|
|
3
3
|
data.splice(index, 1);
|
|
4
4
|
return data;
|
|
5
5
|
}
|
package/src/index.ts
CHANGED