@tecsinapse/react-core 1.17.2 → 1.18.0
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 +36 -0
- package/dist/components/atoms/Switch/Switch.js.map +1 -1
- package/dist/components/molecules/Grid/functions.d.ts +3 -0
- package/dist/components/molecules/Grid/functions.js +21 -0
- package/dist/components/molecules/Grid/functions.js.map +1 -0
- package/dist/components/molecules/Grid/index.d.ts +42 -2
- package/dist/components/molecules/Grid/index.js +6 -13
- package/dist/components/molecules/Grid/index.js.map +1 -1
- package/dist/components/molecules/IconTextButton/IconComponent.d.ts +9 -0
- package/dist/components/molecules/IconTextButton/IconComponent.js +28 -0
- package/dist/components/molecules/IconTextButton/IconComponent.js.map +1 -0
- package/dist/components/molecules/IconTextButton/IconTextButton.d.ts +10 -0
- package/dist/components/molecules/IconTextButton/IconTextButton.js +4 -0
- package/dist/components/molecules/IconTextButton/IconTextButton.js.map +1 -0
- package/dist/components/molecules/IconTextButton/index.d.ts +2 -0
- package/dist/components/molecules/IconTextButton/index.js +16 -0
- package/dist/components/molecules/IconTextButton/index.js.map +1 -0
- package/dist/components/molecules/IconTextButton/styled.d.ts +4 -0
- package/dist/components/molecules/{Grid/Item/index.js → IconTextButton/styled.js} +19 -5
- package/dist/components/molecules/IconTextButton/styled.js.map +1 -0
- package/dist/components/molecules/LabeledSwitch/LabeledSwitch.d.ts +7 -0
- package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js +4 -0
- package/dist/components/molecules/LabeledSwitch/LabeledSwitch.js.map +1 -0
- package/dist/components/molecules/LabeledSwitch/index.d.ts +1 -0
- package/dist/components/molecules/LabeledSwitch/index.js +10 -0
- package/dist/components/molecules/LabeledSwitch/index.js.map +1 -0
- package/dist/hooks/useDebouncedState.js +1 -1
- package/dist/hooks/useDebouncedState.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +44 -30
- package/dist/index.js.map +1 -1
- package/dist/styles/definitions.d.ts +2 -1
- package/dist/styles/definitions.js +7 -1
- package/dist/styles/definitions.js.map +1 -1
- package/dist/styles/light.js +2 -1
- package/dist/styles/light.js.map +1 -1
- package/dist/types/defaults.d.ts +8 -2
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +28 -19
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/variantComplement.d.ts +6 -0
- package/dist/utils/variantComplement.js +35 -0
- package/dist/utils/variantComplement.js.map +1 -0
- package/package.json +5 -5
- package/src/components/atoms/Switch/Switch.tsx +38 -18
- package/src/components/molecules/Grid/functions.ts +29 -0
- package/src/components/molecules/Grid/index.ts +66 -2
- package/src/components/molecules/IconTextButton/IconComponent.tsx +31 -0
- package/src/components/molecules/IconTextButton/IconTextButton.tsx +12 -0
- package/src/components/molecules/IconTextButton/index.ts +2 -0
- package/src/components/molecules/IconTextButton/styled.ts +20 -0
- package/src/components/molecules/LabeledSwitch/LabeledSwitch.tsx +9 -0
- package/src/components/molecules/LabeledSwitch/index.ts +1 -0
- package/src/hooks/useDebouncedState.ts +1 -1
- package/src/index.ts +15 -6
- package/src/styles/definitions.ts +8 -1
- package/src/styles/light.ts +2 -0
- package/src/types/defaults.ts +11 -1
- package/src/utils/index.ts +5 -4
- package/src/utils/variantComplement.ts +36 -0
- package/dist/components/molecules/Grid/Grid.d.ts +0 -15
- package/dist/components/molecules/Grid/Grid.js +0 -55
- package/dist/components/molecules/Grid/Grid.js.map +0 -1
- package/dist/components/molecules/Grid/Item/Item.d.ts +0 -30
- package/dist/components/molecules/Grid/Item/Item.js +0 -68
- package/dist/components/molecules/Grid/Item/Item.js.map +0 -1
- package/dist/components/molecules/Grid/Item/index.d.ts +0 -1
- package/dist/components/molecules/Grid/Item/index.js.map +0 -1
- package/src/components/molecules/Grid/Grid.stories.tsx +0 -132
- package/src/components/molecules/Grid/Grid.tsx +0 -87
- package/src/components/molecules/Grid/Item/Item.tsx +0 -93
- package/src/components/molecules/Grid/Item/index.ts +0 -1
package/src/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ export {
|
|
|
25
25
|
} from './components/atoms/GroupButton';
|
|
26
26
|
export { Icon, IconProps } from './components/atoms/Icon';
|
|
27
27
|
export {
|
|
28
|
+
disabledInputStyles,
|
|
28
29
|
Hint,
|
|
29
30
|
InputContainer,
|
|
30
31
|
InputContainerProps,
|
|
@@ -39,7 +40,6 @@ export {
|
|
|
39
40
|
useInputFocus,
|
|
40
41
|
useNumberMask,
|
|
41
42
|
useStringMask,
|
|
42
|
-
disabledInputStyles,
|
|
43
43
|
} from './components/atoms/Input';
|
|
44
44
|
export { Paper, PaperProps } from './components/atoms/Paper';
|
|
45
45
|
export {
|
|
@@ -68,21 +68,30 @@ export {
|
|
|
68
68
|
DateTimeSelectorMode,
|
|
69
69
|
DateTimeSelectorProps,
|
|
70
70
|
} from './components/molecules/DateTimeSelector';
|
|
71
|
-
export
|
|
72
|
-
export { Snackbar, SnackbarProps } from './components/molecules/Snackbar';
|
|
71
|
+
export * from './components/molecules/Grid';
|
|
73
72
|
export {
|
|
74
73
|
HintInputContainer,
|
|
75
74
|
HintInputContainerProps,
|
|
76
75
|
} from './components/molecules/HintInputContainer';
|
|
76
|
+
export {
|
|
77
|
+
IconComponent,
|
|
78
|
+
IconPositionOptions,
|
|
79
|
+
IconTextButtonProps,
|
|
80
|
+
} from './components/molecules/IconTextButton';
|
|
81
|
+
export { InputPasswordIcon } from './components/molecules/InputPassword';
|
|
82
|
+
export {
|
|
83
|
+
LabeledSwitchProps,
|
|
84
|
+
LabelPositionOptions,
|
|
85
|
+
} from './components/molecules/LabeledSwitch';
|
|
86
|
+
export { Snackbar, SnackbarProps } from './components/molecules/Snackbar';
|
|
77
87
|
export {
|
|
78
88
|
TextArea,
|
|
79
|
-
TextAreaProps,
|
|
80
89
|
TextAreaInputBase,
|
|
90
|
+
TextAreaProps,
|
|
81
91
|
} from './components/molecules/TextArea';
|
|
82
|
-
export
|
|
92
|
+
export * from './hooks';
|
|
83
93
|
export * from './styles/definitions';
|
|
84
94
|
export * from './styles/light';
|
|
85
95
|
export { default as ThemeProvider } from './styles/ThemeProvider';
|
|
86
96
|
export * from './types/defaults';
|
|
87
97
|
export * from './utils';
|
|
88
|
-
export * from './hooks';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BorderRadius,
|
|
3
3
|
BorderWidth,
|
|
4
|
+
Breakpoints,
|
|
4
5
|
FontColor,
|
|
5
6
|
FontStack,
|
|
6
7
|
FontWeight,
|
|
@@ -8,7 +9,7 @@ import {
|
|
|
8
9
|
Miscellaneous,
|
|
9
10
|
Spacing,
|
|
10
11
|
TypographyVariation,
|
|
11
|
-
ZIndex
|
|
12
|
+
ZIndex,
|
|
12
13
|
} from '../types/defaults';
|
|
13
14
|
import { RFValueStr } from '../utils';
|
|
14
15
|
|
|
@@ -179,3 +180,9 @@ export type IconType =
|
|
|
179
180
|
| 'antdesign'
|
|
180
181
|
| 'font-awesome-5'
|
|
181
182
|
| string;
|
|
183
|
+
|
|
184
|
+
export const breakpoints: Breakpoints = {
|
|
185
|
+
sm: 480,
|
|
186
|
+
md: 768,
|
|
187
|
+
lg: 1366,
|
|
188
|
+
};
|
package/src/styles/light.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ThemeProp } from '../types/defaults';
|
|
|
2
2
|
import {
|
|
3
3
|
borderRadius,
|
|
4
4
|
borderWidth,
|
|
5
|
+
breakpoints,
|
|
5
6
|
fontColor,
|
|
6
7
|
fontFiles,
|
|
7
8
|
fontStack,
|
|
@@ -51,4 +52,5 @@ export const lightTheme: ThemeProp = {
|
|
|
51
52
|
files: fontFiles,
|
|
52
53
|
},
|
|
53
54
|
zIndex,
|
|
55
|
+
breakpoints,
|
|
54
56
|
};
|
package/src/types/defaults.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
1
3
|
export type Color = {
|
|
2
4
|
primary: ColorGradation;
|
|
3
5
|
secondary: ColorGradation;
|
|
@@ -107,6 +109,12 @@ export type FontWeight = {
|
|
|
107
109
|
black: string;
|
|
108
110
|
};
|
|
109
111
|
|
|
112
|
+
export type Breakpoints = {
|
|
113
|
+
sm: number;
|
|
114
|
+
md: number;
|
|
115
|
+
lg: number;
|
|
116
|
+
};
|
|
117
|
+
|
|
110
118
|
export type ThemeProp = {
|
|
111
119
|
color: Color;
|
|
112
120
|
miscellaneous: Miscellaneous;
|
|
@@ -122,10 +130,12 @@ export type ThemeProp = {
|
|
|
122
130
|
files: FontWeight;
|
|
123
131
|
};
|
|
124
132
|
zIndex: ZIndex;
|
|
133
|
+
/** Designed to web */
|
|
134
|
+
breakpoints: Breakpoints;
|
|
125
135
|
};
|
|
126
136
|
|
|
127
137
|
export interface ThemeProviderProps {
|
|
128
|
-
children?:
|
|
138
|
+
children?: ReactNode;
|
|
129
139
|
theme: ThemeProp;
|
|
130
140
|
}
|
|
131
141
|
|
package/src/utils/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { lightenDarkenColor } from './lightenDarkenColor';
|
|
2
1
|
export {
|
|
3
|
-
extractNumbersFromString,
|
|
4
2
|
extractDigitsFromString,
|
|
3
|
+
extractNumbersFromString,
|
|
5
4
|
} from './extractNumbersFromString';
|
|
5
|
+
export * from './formatWithMask';
|
|
6
6
|
export * from './IPhoneXHelper';
|
|
7
|
-
export
|
|
7
|
+
export { lightenDarkenColor } from './lightenDarkenColor';
|
|
8
8
|
export * from './masks';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './ResponsiveFontSize';
|
|
10
|
+
export * from './variantComplement';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColorGradationType,
|
|
3
|
+
ColorType,
|
|
4
|
+
FontColorType,
|
|
5
|
+
VariantType,
|
|
6
|
+
} from '../types/defaults';
|
|
7
|
+
|
|
8
|
+
export const fontColorVC: Record<VariantType, FontColorType> = {
|
|
9
|
+
filled: 'light',
|
|
10
|
+
outlined: 'orange',
|
|
11
|
+
text: 'orange',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const colorVC: Record<VariantType, ColorType> = {
|
|
15
|
+
filled: 'primary',
|
|
16
|
+
outlined: 'primary',
|
|
17
|
+
text: 'primary',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const colorGradationVC: Record<VariantType, ColorGradationType> = {
|
|
21
|
+
filled: 'dark',
|
|
22
|
+
outlined: 'dark',
|
|
23
|
+
text: 'dark',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const borderColorVC: Record<VariantType, ColorType> = {
|
|
27
|
+
filled: 'primary',
|
|
28
|
+
outlined: 'primary',
|
|
29
|
+
text: 'primary',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const borderColorGradationVC: Record<VariantType, ColorGradationType> = {
|
|
33
|
+
filled: 'dark',
|
|
34
|
+
outlined: 'dark',
|
|
35
|
+
text: 'dark',
|
|
36
|
+
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ViewProps } from 'react-native';
|
|
2
|
-
import { SpacingType } from '@tecsinapse/react-core';
|
|
3
|
-
export interface IGrid extends ViewProps {
|
|
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;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
|
|
6
|
-
var _react = _interopRequireDefault(require("react"));
|
|
7
|
-
|
|
8
|
-
var _reactNative = require("react-native");
|
|
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(_reactNative.View, _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(_reactNative.View, _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 ? void 0 : child.props),
|
|
47
|
-
columns,
|
|
48
|
-
spacing: (child == null ? void 0 : child.props.spacing) ?? spacing
|
|
49
|
-
});
|
|
50
|
-
}));
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
var _default = Grid;
|
|
54
|
-
exports.default = _default;
|
|
55
|
-
//# sourceMappingURL=Grid.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;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,6BAAC,iBAAD;AACE,MAAA,KAAK,EAAE,CACLJ,KADK,EAEL;AACEK,QAAAA,OAAO,EAAE,MADX;AAEEC,QAAAA,aAAa,EAAE,KAFjB;AAGEC,QAAAA,QAAQ,EAAE;AAHZ,OAFK;AADT,OASML,IATN,GAWGM,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,CAXH,CADF;AAuBD;;AAED,SACE,6BAAC,iBAAD;AACE,IAAA,KAAK,EAAE,CACLX,KADK,EAEL;AACEK,MAAAA,OAAO,EAAE,MADX;AAEEC,MAAAA,aAAa,EAAE,KAFjB;AAGEC,MAAAA,QAAQ,EAAE;AAHZ,KAFK;AADT,KASML,IATN,GAWGM,eAAMC,QAAN,CAAeC,GAAf,CAAmBb,QAAnB,EAA6Bc,KAAK,IAAI;AACrC,WAAOH,eAAMK,YAAN,CAAmBF,KAAnB,EAA0B,EAC/B,IAAGA,KAAH,oBAAGA,KAAK,CAAEG,KAAV,CAD+B;AAE/BhB,MAAAA,OAF+B;AAG/BG,MAAAA,OAAO,EAAE,CAAAU,KAAK,QAAL,YAAAA,KAAK,CAAEG,KAAP,CAAab,OAAb,KAAwBA;AAHF,KAA1B,CAAP;AAKD,GANA,CAXH,CADF;AAqBD,CAxDD;;eA0DeL,I","sourcesContent":["import React from 'react';\nimport { View, ViewProps } from 'react-native';\nimport { GridItem } from './Item';\nimport { SpacingType } from '@tecsinapse/react-core';\n\nexport interface IGrid extends ViewProps {\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 <View\n style={[\n style,\n {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\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 </View>\n );\n }\n\n return (\n <View\n style={[\n style,\n {\n display: 'flex',\n flexDirection: 'row',\n flexWrap: 'wrap',\n },\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 </View>\n );\n};\n\nexport default Grid;\n"],"file":"Grid.js"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SpacingType } from '../../../../types/defaults';
|
|
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;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.default = void 0;
|
|
5
|
-
|
|
6
|
-
var _react = _interopRequireDefault(require("react"));
|
|
7
|
-
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
|
|
10
|
-
var _hooks = require("../../../../hooks");
|
|
11
|
-
|
|
12
|
-
var _utils = require("../../../../utils");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
const GridItem = ({
|
|
17
|
-
children,
|
|
18
|
-
span,
|
|
19
|
-
columns = 12,
|
|
20
|
-
loadingComponent,
|
|
21
|
-
loading = false,
|
|
22
|
-
spacing: _spacing,
|
|
23
|
-
wrapper = false,
|
|
24
|
-
...rest
|
|
25
|
-
}) => {
|
|
26
|
-
const {
|
|
27
|
-
spacing
|
|
28
|
-
} = (0, _hooks.useTheme)();
|
|
29
|
-
|
|
30
|
-
if (!_react.default.Children.only(children)) {
|
|
31
|
-
throw new Error('The number of children in GridItem should be one');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (loadingComponent && loading) {
|
|
35
|
-
return loadingComponent;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const getPadding = pos => {
|
|
39
|
-
if (_spacing) {
|
|
40
|
-
if (typeof _spacing === 'string') return (0, _utils.extractNumbersFromString)(spacing[_spacing]);else if (typeof _spacing === 'object' && _spacing[pos]) {
|
|
41
|
-
return (0, _utils.extractNumbersFromString)(spacing[_spacing[pos]]);
|
|
42
|
-
} else return undefined;
|
|
43
|
-
} else return undefined;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const style = { ...rest,
|
|
47
|
-
boxSizing: 'border-box',
|
|
48
|
-
flexBasis: `${100 / (columns / span)}%`,
|
|
49
|
-
paddingTop: getPadding('top'),
|
|
50
|
-
paddingBottom: getPadding('bottom'),
|
|
51
|
-
paddingRight: getPadding('right'),
|
|
52
|
-
paddingLeft: getPadding('left')
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const clone = _react.default.cloneElement(children, { ...(children == null ? void 0 : children.props),
|
|
56
|
-
style: wrapper ? children == null ? void 0 : children.props.style : { ...style,
|
|
57
|
-
...(children == null ? void 0 : children.props.style)
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
return wrapper ? _react.default.createElement(_reactNative.View, {
|
|
62
|
-
style: style
|
|
63
|
-
}, clone) : clone;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
var _default = GridItem;
|
|
67
|
-
exports.default = _default;
|
|
68
|
-
//# sourceMappingURL=Item.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;AACA;;AAEA;;;;AAwCA,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,sBAApB;;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,qCAAyBD,OAAO,CAACC,QAAD,CAAhC,CAAP,CADF,KAEK,IAAI,OAAOA,QAAP,KAAoB,QAApB,IAAgCA,QAAQ,CAACQ,GAAD,CAA5C,EAAmD;AACtD,eAAO,qCAAyBT,OAAO,CAACC,QAAQ,CAACQ,GAAD,CAAT,CAAhC,CAAP;AACD,OAFI,MAEE,OAAOC,SAAP;AACR,KAND,MAMO,OAAOA,SAAP;AACR,GARD;;AAUA,QAAMC,KAAK,GAAG,EACZ,GAAGR,IADS;AAEZS,IAAAA,SAAS,EAAE,YAFC;AAGZC,IAAAA,SAAS,EAAG,GAAE,OAAOhB,OAAO,GAAGD,IAAjB,CAAuB,GAHzB;AAIZkB,IAAAA,UAAU,EAAEN,UAAU,CAAC,KAAD,CAJV;AAKZO,IAAAA,aAAa,EAAEP,UAAU,CAAC,QAAD,CALb;AAMZQ,IAAAA,YAAY,EAAER,UAAU,CAAC,OAAD,CANZ;AAOZS,IAAAA,WAAW,EAAET,UAAU,CAAC,MAAD;AAPX,GAAd;;AAUA,QAAMU,KAAK,GAAGd,eAAMe,YAAN,CAAmBxB,QAAnB,EAA6B,EACzC,IAAGA,QAAH,oBAAGA,QAAQ,CAAEyB,KAAb,CADyC;AAEzCT,IAAAA,KAAK,EAAET,OAAO,GACVP,QADU,oBACVA,QAAQ,CAAEyB,KAAV,CAAgBT,KADN,GAEV,EAAE,GAAGA,KAAL;AAAY,UAAGhB,QAAH,oBAAGA,QAAQ,CAAEyB,KAAV,CAAgBT,KAAnB;AAAZ;AAJqC,GAA7B,CAAd;;AAOA,SAAOT,OAAO,GAAG,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAES;AAAb,KAAqBO,KAArB,CAAH,GAAwCA,KAAtD;AACD,CA9CD;;eAgDexB,Q","sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\nimport { useTheme } from '../../../../hooks';\nimport { SpacingType } from '../../../../types/defaults';\nimport { extractNumbersFromString } from '../../../../utils';\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 = {\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 ? <View style={style}>{clone}</View> : clone;\n};\n\nexport default GridItem;\n"],"file":"Item.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as GridItem, IGridItem } from './Item';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/molecules/Grid/Item/index.ts"],"names":[],"mappings":";;;;;AAAA","sourcesContent":["export { default as GridItem, IGridItem } from './Item';\n"],"file":"index.js"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Story } from '@storybook/react';
|
|
3
|
-
import Grid, { IGrid } from './Grid';
|
|
4
|
-
import { GridItem } from './Item';
|
|
5
|
-
import { Text } from '@tecsinapse/react-core';
|
|
6
|
-
import { View } from 'react-native';
|
|
7
|
-
import styled from '@emotion/native';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: 'Hybrid/Grid',
|
|
11
|
-
component: Grid,
|
|
12
|
-
subcomponents: { GridItem },
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const Container = styled(View)`
|
|
16
|
-
background-color: orange;
|
|
17
|
-
padding: 2px;
|
|
18
|
-
border-width: 1px;
|
|
19
|
-
border-color: white;
|
|
20
|
-
border-style: solid;
|
|
21
|
-
border-radius: 8px;
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
const TemplateGrid: Story<IGrid> = args => {
|
|
25
|
-
return (
|
|
26
|
-
<Grid {...args}>
|
|
27
|
-
<GridItem span={12}>
|
|
28
|
-
<Container>
|
|
29
|
-
<Text>Box</Text>
|
|
30
|
-
</Container>
|
|
31
|
-
</GridItem>
|
|
32
|
-
|
|
33
|
-
<GridItem span={6}>
|
|
34
|
-
<Container>
|
|
35
|
-
<Text>Box</Text>
|
|
36
|
-
</Container>
|
|
37
|
-
</GridItem>
|
|
38
|
-
<GridItem span={6}>
|
|
39
|
-
<Container>
|
|
40
|
-
<Text>Box</Text>
|
|
41
|
-
</Container>
|
|
42
|
-
</GridItem>
|
|
43
|
-
|
|
44
|
-
<GridItem span={4} flexShrink={1}>
|
|
45
|
-
<Container>
|
|
46
|
-
<Text>Box</Text>
|
|
47
|
-
</Container>
|
|
48
|
-
</GridItem>
|
|
49
|
-
<GridItem span={4} flexGrow={1}>
|
|
50
|
-
<Container>
|
|
51
|
-
<Text>Box</Text>
|
|
52
|
-
</Container>
|
|
53
|
-
</GridItem>
|
|
54
|
-
<GridItem span={4} flexShrink={1}>
|
|
55
|
-
<Container>
|
|
56
|
-
<Text>Box</Text>
|
|
57
|
-
</Container>
|
|
58
|
-
</GridItem>
|
|
59
|
-
|
|
60
|
-
<GridItem span={3}>
|
|
61
|
-
<Container>
|
|
62
|
-
<Text>Box</Text>
|
|
63
|
-
</Container>
|
|
64
|
-
</GridItem>
|
|
65
|
-
<GridItem span={3}>
|
|
66
|
-
<Container>
|
|
67
|
-
<Text>Box</Text>
|
|
68
|
-
</Container>
|
|
69
|
-
</GridItem>
|
|
70
|
-
<GridItem span={3}>
|
|
71
|
-
<Container>
|
|
72
|
-
<Text>Box</Text>
|
|
73
|
-
</Container>
|
|
74
|
-
</GridItem>
|
|
75
|
-
<GridItem span={3}>
|
|
76
|
-
<Container>
|
|
77
|
-
<Text>Box</Text>
|
|
78
|
-
</Container>
|
|
79
|
-
</GridItem>
|
|
80
|
-
</Grid>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const WithGridItem = TemplateGrid.bind({});
|
|
85
|
-
|
|
86
|
-
WithGridItem.args = {
|
|
87
|
-
spacing: 'mili',
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const TemplateLayout: Story<IGrid> = args => {
|
|
91
|
-
return (
|
|
92
|
-
<Grid {...args}>
|
|
93
|
-
<Container>
|
|
94
|
-
<Text>Box</Text>
|
|
95
|
-
</Container>
|
|
96
|
-
<Container>
|
|
97
|
-
<Text>Box</Text>
|
|
98
|
-
</Container>
|
|
99
|
-
<Container>
|
|
100
|
-
<Text>Box</Text>
|
|
101
|
-
</Container>
|
|
102
|
-
<Container>
|
|
103
|
-
<Text>Box</Text>
|
|
104
|
-
</Container>
|
|
105
|
-
<Container>
|
|
106
|
-
<Text>Box</Text>
|
|
107
|
-
</Container>
|
|
108
|
-
<Container>
|
|
109
|
-
<Text>Box</Text>
|
|
110
|
-
</Container>
|
|
111
|
-
<Container>
|
|
112
|
-
<Text>Box</Text>
|
|
113
|
-
</Container>
|
|
114
|
-
<Container>
|
|
115
|
-
<Text>Box</Text>
|
|
116
|
-
</Container>
|
|
117
|
-
<Container>
|
|
118
|
-
<Text>Box</Text>
|
|
119
|
-
</Container>
|
|
120
|
-
<Container>
|
|
121
|
-
<Text>Box</Text>
|
|
122
|
-
</Container>
|
|
123
|
-
</Grid>
|
|
124
|
-
);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export const WithLayout = TemplateLayout.bind({});
|
|
128
|
-
|
|
129
|
-
WithLayout.args = {
|
|
130
|
-
layout: [[12], [6, 6], [4, 4, 4], [3, 3, 3, 3]],
|
|
131
|
-
spacing: 'mili',
|
|
132
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View, ViewProps } from 'react-native';
|
|
3
|
-
import { GridItem } from './Item';
|
|
4
|
-
import { SpacingType } from '@tecsinapse/react-core';
|
|
5
|
-
|
|
6
|
-
export interface IGrid extends ViewProps {
|
|
7
|
-
children: JSX.Element[];
|
|
8
|
-
/** Layout should represent the multiplier of columns to fill the rows properly.
|
|
9
|
-
* Example:
|
|
10
|
-
* const layout = [
|
|
11
|
-
* [6, 6], // Two elements on row
|
|
12
|
-
* [4, 4, 4], // Three elements on row
|
|
13
|
-
* [12], // One element on row
|
|
14
|
-
* ];
|
|
15
|
-
* */
|
|
16
|
-
layout?: number[][];
|
|
17
|
-
/** Number of grid columns to be considered (not the number of elements per row) */
|
|
18
|
-
columns?: number;
|
|
19
|
-
spacing?:
|
|
20
|
-
| SpacingType
|
|
21
|
-
| {
|
|
22
|
-
top?: SpacingType;
|
|
23
|
-
right?: SpacingType;
|
|
24
|
-
bottom?: SpacingType;
|
|
25
|
-
left?: SpacingType;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const Grid = ({
|
|
30
|
-
children,
|
|
31
|
-
columns = 12,
|
|
32
|
-
layout,
|
|
33
|
-
style,
|
|
34
|
-
spacing,
|
|
35
|
-
...rest
|
|
36
|
-
}: IGrid) => {
|
|
37
|
-
if (layout) {
|
|
38
|
-
const flatLayout = layout.flat();
|
|
39
|
-
return (
|
|
40
|
-
<View
|
|
41
|
-
style={[
|
|
42
|
-
style,
|
|
43
|
-
{
|
|
44
|
-
display: 'flex',
|
|
45
|
-
flexDirection: 'row',
|
|
46
|
-
flexWrap: 'wrap',
|
|
47
|
-
},
|
|
48
|
-
]}
|
|
49
|
-
{...rest}
|
|
50
|
-
>
|
|
51
|
-
{React.Children.map(children, (child, index) => (
|
|
52
|
-
<GridItem
|
|
53
|
-
columns={columns}
|
|
54
|
-
span={flatLayout[index]}
|
|
55
|
-
spacing={spacing}
|
|
56
|
-
>
|
|
57
|
-
{child}
|
|
58
|
-
</GridItem>
|
|
59
|
-
))}
|
|
60
|
-
</View>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<View
|
|
66
|
-
style={[
|
|
67
|
-
style,
|
|
68
|
-
{
|
|
69
|
-
display: 'flex',
|
|
70
|
-
flexDirection: 'row',
|
|
71
|
-
flexWrap: 'wrap',
|
|
72
|
-
},
|
|
73
|
-
]}
|
|
74
|
-
{...rest}
|
|
75
|
-
>
|
|
76
|
-
{React.Children.map(children, child => {
|
|
77
|
-
return React.cloneElement(child, {
|
|
78
|
-
...child?.props,
|
|
79
|
-
columns,
|
|
80
|
-
spacing: child?.props.spacing ?? spacing,
|
|
81
|
-
});
|
|
82
|
-
})}
|
|
83
|
-
</View>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export default Grid;
|