@tecsinapse/react-core 1.10.4 → 1.12.1
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 +50 -0
- package/dist/components/atoms/GroupButton/GroupButton.d.ts +1 -0
- package/dist/components/atoms/GroupButton/GroupButton.js +4 -1
- package/dist/components/atoms/GroupButton/GroupButton.js.map +1 -1
- package/dist/components/atoms/Switch/Switch.js +3 -1
- package/dist/components/atoms/Switch/Switch.js.map +1 -1
- package/dist/components/atoms/Switch/animation.js +4 -4
- package/dist/components/atoms/Switch/animation.js.map +1 -1
- package/dist/components/molecules/DatePicker/DatePicker.js +10 -2
- package/dist/components/molecules/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/molecules/DatePicker/Modal.js +4 -2
- package/dist/components/molecules/DatePicker/Modal.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/DateTimePicker.js +3 -1
- package/dist/components/molecules/DateTimePicker/DateTimePicker.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js +3 -1
- package/dist/components/molecules/DateTimeSelector/DateTimeSelector.js.map +1 -1
- package/dist/components/molecules/Grid/Grid.d.ts +10 -0
- package/dist/components/molecules/Grid/Grid.js +57 -0
- package/dist/components/molecules/Grid/Grid.js.map +1 -0
- package/dist/components/molecules/Grid/Item/Item.d.ts +25 -0
- package/dist/components/molecules/Grid/Item/Item.js +57 -0
- package/dist/components/molecules/Grid/Item/Item.js.map +1 -0
- package/dist/components/molecules/Grid/Item/index.d.ts +1 -0
- package/dist/components/molecules/Grid/Item/index.js +24 -0
- package/dist/components/molecules/Grid/Item/index.js.map +1 -0
- package/dist/components/molecules/Grid/index.d.ts +2 -0
- package/dist/components/molecules/Grid/index.js +38 -0
- package/dist/components/molecules/Grid/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/atoms/GroupButton/GroupButton.tsx +3 -1
- package/src/components/atoms/Switch/Switch.tsx +6 -3
- package/src/components/atoms/Switch/animation.ts +4 -4
- package/src/components/molecules/DatePicker/DatePicker.tsx +5 -3
- package/src/components/molecules/DatePicker/Modal.tsx +14 -11
- package/src/components/molecules/DateTimePicker/DateTimePicker.tsx +3 -1
- package/src/components/molecules/DateTimeSelector/DateTimeSelector.tsx +1 -1
- package/src/components/molecules/Grid/Grid.stories.tsx +132 -0
- package/src/components/molecules/Grid/Grid.tsx +80 -0
- package/src/components/molecules/Grid/Item/Item.tsx +73 -0
- package/src/components/molecules/Grid/Item/index.ts +1 -0
- package/src/components/molecules/Grid/index.ts +2 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
var _reactNative = require("react-native");
|
|
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, _reactCore.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 style = { ...rest,
|
|
39
|
+
boxSizing: 'border-box',
|
|
40
|
+
flexBasis: `${100 / (columns / span)}%`,
|
|
41
|
+
padding: _spacing ? (0, _reactCore.extractNumbersFromString)(spacing[_spacing]) : undefined
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const clone = _react.default.cloneElement(children, { ...(children === null || children === void 0 ? void 0 : children.props),
|
|
45
|
+
style: wrapper ? children === null || children === void 0 ? void 0 : children.props.style : { ...style,
|
|
46
|
+
...(children === null || children === void 0 ? void 0 : children.props.style)
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return wrapper ? _react.default.createElement(_reactNative.View, {
|
|
51
|
+
style: style
|
|
52
|
+
}, clone) : clone;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var _default = GridItem;
|
|
56
|
+
exports.default = _default;
|
|
57
|
+
//# 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","style","boxSizing","flexBasis","padding","undefined","clone","cloneElement","props"],"mappings":";;;;;;;AAAA;;AACA;;AAKA;;;;AA+BA,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,KAAK,GAAG,EACZ,GAAGL,IADS;AAEZM,IAAAA,SAAS,EAAE,YAFC;AAGZC,IAAAA,SAAS,EAAG,GAAE,OAAOb,OAAO,GAAGD,IAAjB,CAAuB,GAHzB;AAIZe,IAAAA,OAAO,EAAEV,QAAQ,GAAG,yCAAyBD,OAAO,CAACC,QAAD,CAAhC,CAAH,GAAiDW;AAJtD,GAAd;;AAOA,QAAMC,KAAK,GAAGT,eAAMU,YAAN,CAAmBnB,QAAnB,EAA6B,EACzC,IAAGA,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEoB,KAAb,CADyC;AAEzCP,IAAAA,KAAK,EAAEN,OAAO,GACVP,QADU,aACVA,QADU,uBACVA,QAAQ,CAAEoB,KAAV,CAAgBP,KADN,GAEV,EAAE,GAAGA,KAAL;AAAY,UAAGb,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEoB,KAAV,CAAgBP,KAAnB;AAAZ;AAJqC,GAA7B,CAAd;;AAOA,SAAON,OAAO,GAAG,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAEM;AAAb,KAAqBK,KAArB,CAAH,GAAwCA,KAAtD;AACD,CAjCD;;eAmCenB,Q","sourcesContent":["import React from 'react';\nimport {\n extractNumbersFromString,\n SpacingType,\n useTheme,\n} from '@tecsinapse/react-core';\nimport { View } from 'react-native';\n\ntype FlexPositioning = 'flex-start' | 'flex-end' | 'center';\ntype FlexAlignBase = FlexPositioning | 'stretch';\ntype FlexAlignType = FlexAlignBase | 'baseline';\ntype FlexSpacing = 'space-between' | 'space-around';\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?: SpacingType;\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 style = {\n ...rest,\n boxSizing: 'border-box',\n flexBasis: `${100 / (columns / span)}%`,\n padding: _spacing ? extractNumbersFromString(spacing[_spacing]) : undefined,\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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as GridItem, IGridItem } from './Item';
|
|
@@ -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.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "IGridItem", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Item.IGridItem;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _Item = _interopRequireWildcard(require("./Item"));
|
|
20
|
+
|
|
21
|
+
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); }
|
|
22
|
+
|
|
23
|
+
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; }
|
|
24
|
+
//# 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, IGridItem } from './Item';\n"],"file":"index.js"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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, "IGridItem", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _Item.IGridItem;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Grid", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _Grid.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "IGrid", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _Grid.IGrid;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
var _Item = require("./Item");
|
|
32
|
+
|
|
33
|
+
var _Grid = _interopRequireWildcard(require("./Grid"));
|
|
34
|
+
|
|
35
|
+
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); }
|
|
36
|
+
|
|
37
|
+
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; }
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/molecules/Grid/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { GridItem, IGridItem } from './Item';\nexport { default as Grid, IGrid } from './Grid';\n"],"file":"index.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export { InputPasswordIcon } from './components/molecules/InputPassword';
|
|
|
25
25
|
export { Snackbar, SnackbarProps } from './components/molecules/Snackbar';
|
|
26
26
|
export { HintInputContainer, HintInputContainerProps, } from './components/molecules/HintInputContainer';
|
|
27
27
|
export { TextArea, TextAreaProps, TextAreaInputBase, } from './components/molecules/TextArea';
|
|
28
|
+
export { GridItem, Grid, IGridItem, IGrid } from './components/molecules/Grid';
|
|
28
29
|
export * from './styles/definitions';
|
|
29
30
|
export * from './styles/light';
|
|
30
31
|
export { default as ThemeProvider } from './styles/ThemeProvider';
|
package/dist/index.js
CHANGED
|
@@ -84,6 +84,10 @@ var _exportNames = {
|
|
|
84
84
|
TextArea: true,
|
|
85
85
|
TextAreaProps: true,
|
|
86
86
|
TextAreaInputBase: true,
|
|
87
|
+
GridItem: true,
|
|
88
|
+
Grid: true,
|
|
89
|
+
IGridItem: true,
|
|
90
|
+
IGrid: true,
|
|
87
91
|
ThemeProvider: true
|
|
88
92
|
};
|
|
89
93
|
Object.defineProperty(exports, "Avatar", {
|
|
@@ -566,6 +570,30 @@ Object.defineProperty(exports, "TextAreaInputBase", {
|
|
|
566
570
|
return _TextArea.TextAreaInputBase;
|
|
567
571
|
}
|
|
568
572
|
});
|
|
573
|
+
Object.defineProperty(exports, "GridItem", {
|
|
574
|
+
enumerable: true,
|
|
575
|
+
get: function () {
|
|
576
|
+
return _Grid.GridItem;
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
Object.defineProperty(exports, "Grid", {
|
|
580
|
+
enumerable: true,
|
|
581
|
+
get: function () {
|
|
582
|
+
return _Grid.Grid;
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
Object.defineProperty(exports, "IGridItem", {
|
|
586
|
+
enumerable: true,
|
|
587
|
+
get: function () {
|
|
588
|
+
return _Grid.IGridItem;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
Object.defineProperty(exports, "IGrid", {
|
|
592
|
+
enumerable: true,
|
|
593
|
+
get: function () {
|
|
594
|
+
return _Grid.IGrid;
|
|
595
|
+
}
|
|
596
|
+
});
|
|
569
597
|
Object.defineProperty(exports, "ThemeProvider", {
|
|
570
598
|
enumerable: true,
|
|
571
599
|
get: function () {
|
|
@@ -627,6 +655,8 @@ var _HintInputContainer = require("./components/molecules/HintInputContainer");
|
|
|
627
655
|
|
|
628
656
|
var _TextArea = require("./components/molecules/TextArea");
|
|
629
657
|
|
|
658
|
+
var _Grid = require("./components/molecules/Grid");
|
|
659
|
+
|
|
630
660
|
var _definitions = require("./styles/definitions");
|
|
631
661
|
|
|
632
662
|
Object.keys(_definitions).forEach(function (key) {
|
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;;AACA;;AACA;;AACA;;AAUA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAkBA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAIA;;AAKA;;AACA;;AACA;;AAIA;;AAKA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export { Avatar, AvatarProps } from './components/atoms/Avatar';\nexport { Badge, BadgeProps } from './components/atoms/Badge';\nexport { BoxContent, BoxContentProps } from './components/atoms/BoxContent';\nexport {\n Button,\n ButtonProps,\n ButtonSizeType,\n ButtonStateProps,\n ButtonStateType,\n Error,\n Loading,\n Success,\n} from './components/atoms/Button';\nexport { Card, CardProps } from './components/atoms/Card';\nexport { Footer, FooterProps } from './components/atoms/Card/Footer';\nexport { Header, HeaderProps } from './components/atoms/Card/Header';\nexport { Checkbox, CheckboxProps } from './components/atoms/Checkbox';\nexport { Divider, DividerProps } from './components/atoms/Divider';\nexport {\n GroupButton,\n GroupButtonOption,\n GroupButtonOptionProps,\n GroupButtonProps,\n GroupButtonValue,\n} from './components/atoms/GroupButton';\nexport { Icon, IconProps } from './components/atoms/Icon';\nexport {\n Hint,\n InputContainer,\n InputContainerProps,\n InputElement,\n InputElementProps,\n InputVariantType,\n Masks,\n PressableInputContainer,\n PressableInputContainerProps,\n StyledBorderKeeper,\n useCurrencyMask,\n useInputFocus,\n useMask,\n disabledInputStyles,\n IMask,\n IMaskValue,\n} from './components/atoms/Input';\nexport { Paper, PaperProps } from './components/atoms/Paper';\nexport {\n PressableSurface,\n PressableSurfaceProps,\n} from './components/atoms/PressableSurface';\nexport { ProgressBar, ProgressBarProps } from './components/atoms/ProgressBar';\nexport { RadioButton, RadioButtonProps } from './components/atoms/RadioButton';\nexport { Switch, SwitchProps } from './components/atoms/Switch';\nexport { Tag, TagProps } from './components/atoms/Tag';\nexport { Text, TextProps } from './components/atoms/Text';\nexport {\n Calendar,\n CalendarProps,\n DateRange,\n SelectionType,\n} from './components/molecules/Calendar';\nexport { DatePicker, DatePickerProps } from './components/molecules/DatePicker';\nexport {\n DateTimePicker,\n DateTimePickerProps,\n} from './components/molecules/DateTimePicker';\nexport {\n DateTimeSelector,\n DateTimeSelectorMode,\n DateTimeSelectorProps,\n} from './components/molecules/DateTimeSelector';\nexport { InputPasswordIcon } from './components/molecules/InputPassword';\nexport { Snackbar, SnackbarProps } from './components/molecules/Snackbar';\nexport {\n HintInputContainer,\n HintInputContainerProps,\n} from './components/molecules/HintInputContainer';\nexport {\n TextArea,\n TextAreaProps,\n TextAreaInputBase,\n} from './components/molecules/TextArea';\nexport { GridItem, Grid, IGridItem, IGrid } from './components/molecules/Grid';\nexport * from './styles/definitions';\nexport * from './styles/light';\nexport { default as ThemeProvider } from './styles/ThemeProvider';\nexport * from './types/defaults';\nexport * from './utils';\nexport * from './hooks';\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tecsinapse/react-core",
|
|
3
3
|
"description": "TecSinapse hybrid React components",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.12.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"react-native": ">=0.64.0",
|
|
32
32
|
"react-native-vector-icons": ">=8.1.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "50b3fc522e7726e43f9dd16d9681faf0a1e5a4d6"
|
|
35
35
|
}
|
|
@@ -41,6 +41,7 @@ export interface GroupButtonProps<T> {
|
|
|
41
41
|
onChange: (option: T) => void;
|
|
42
42
|
buttonSize?: ButtonSizeType;
|
|
43
43
|
style?: StyleProp<ViewStyle>;
|
|
44
|
+
disableAllOptions?: boolean;
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
const GroupButton = <T extends unknown>({
|
|
@@ -58,6 +59,7 @@ const groupOptions = <T extends unknown>({
|
|
|
58
59
|
renderKey,
|
|
59
60
|
onChange,
|
|
60
61
|
value,
|
|
62
|
+
disableAllOptions,
|
|
61
63
|
...rest
|
|
62
64
|
}: Partial<GroupButtonProps<T>>) => {
|
|
63
65
|
const theme = useTheme() as ThemeProp;
|
|
@@ -71,7 +73,7 @@ const groupOptions = <T extends unknown>({
|
|
|
71
73
|
activeBackgroundColorTone,
|
|
72
74
|
inactiveBackgroundColor,
|
|
73
75
|
inactiveBackgroundColorTone,
|
|
74
|
-
disabled,
|
|
76
|
+
disabled = disableAllOptions || option.options?.disabled,
|
|
75
77
|
} = {},
|
|
76
78
|
} = option;
|
|
77
79
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useTheme } from '@emotion/react';
|
|
2
|
-
import React, { FC, useCallback } from 'react';
|
|
3
|
-
import { Animated, StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
import React, { FC, useCallback, useEffect } from 'react';
|
|
3
|
+
import { Animated, StyleProp, ViewStyle, Text } from 'react-native';
|
|
4
4
|
import {
|
|
5
5
|
ColorGradationType,
|
|
6
6
|
ColorType,
|
|
@@ -58,9 +58,12 @@ const Switch: FC<SwitchProps> = ({
|
|
|
58
58
|
backgroundColor: interpolateColor,
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
transitionSwitch(!active, transitionValue, animatedColor);
|
|
63
|
+
}, [active]);
|
|
64
|
+
|
|
61
65
|
const handleChange = useCallback(() => {
|
|
62
66
|
onChange(!active);
|
|
63
|
-
transitionSwitch(active, transitionValue, animatedColor);
|
|
64
67
|
}, [active, onChange]);
|
|
65
68
|
|
|
66
69
|
const stylesDefault: ViewStyle = {
|
|
@@ -8,23 +8,23 @@ export const transitionSwitch = (
|
|
|
8
8
|
if (active) {
|
|
9
9
|
Animated.timing(transitionValue, {
|
|
10
10
|
toValue: 0,
|
|
11
|
-
duration:
|
|
11
|
+
duration: 150,
|
|
12
12
|
useNativeDriver: true,
|
|
13
13
|
}).start();
|
|
14
14
|
Animated.timing(animatedColor, {
|
|
15
15
|
toValue: 0,
|
|
16
|
-
duration:
|
|
16
|
+
duration: 150,
|
|
17
17
|
useNativeDriver: false,
|
|
18
18
|
}).start();
|
|
19
19
|
} else {
|
|
20
20
|
Animated.timing(transitionValue, {
|
|
21
21
|
toValue: 16.5,
|
|
22
|
-
duration:
|
|
22
|
+
duration: 150,
|
|
23
23
|
useNativeDriver: true,
|
|
24
24
|
}).start();
|
|
25
25
|
Animated.timing(animatedColor, {
|
|
26
26
|
toValue: 1,
|
|
27
|
-
duration:
|
|
27
|
+
duration: 150,
|
|
28
28
|
useNativeDriver: false,
|
|
29
29
|
}).start();
|
|
30
30
|
}
|
|
@@ -74,12 +74,14 @@ function DatePicker<T extends SelectionType>({
|
|
|
74
74
|
const getDisplayValue = () => {
|
|
75
75
|
if (!value) return placeholder;
|
|
76
76
|
if (type === 'day') {
|
|
77
|
-
return formatDate(value as Date, format);
|
|
77
|
+
return formatDate(value as Date, format, { locale: locale });
|
|
78
78
|
} else {
|
|
79
79
|
const { lowest, highest } = value as DateRange;
|
|
80
80
|
if (highest)
|
|
81
|
-
return `${formatDate(lowest, format
|
|
82
|
-
|
|
81
|
+
return `${formatDate(lowest, format, {
|
|
82
|
+
locale: locale,
|
|
83
|
+
})} - ${formatDate(highest, format, { locale: locale })}`;
|
|
84
|
+
else return formatDate(lowest, format, { locale: locale });
|
|
83
85
|
}
|
|
84
86
|
};
|
|
85
87
|
|
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Modal as RNModal, ModalProps } from 'react-native';
|
|
3
3
|
import { Calendar, CalendarProps, SelectionType } from '../Calendar';
|
|
4
4
|
import { Backdrop, ModalContent } from './styled';
|
|
5
|
+
import { PressableSurface } from '@tecsinapse/react-core';
|
|
5
6
|
|
|
6
7
|
export interface DatePickerModalProps<T extends SelectionType> {
|
|
7
8
|
CalendarComponent?: React.FC<CalendarProps<T>>;
|
|
@@ -29,17 +30,19 @@ const Component = <T extends SelectionType>({
|
|
|
29
30
|
onRequestClose={onRequestClose}
|
|
30
31
|
>
|
|
31
32
|
<Backdrop onPress={onRequestClose} effect="none">
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
<PressableSurface>
|
|
34
|
+
<ModalContent offset={bottomOffset}>
|
|
35
|
+
<CalendarComponent
|
|
36
|
+
pointerEvents={'box-none'}
|
|
37
|
+
type={type}
|
|
38
|
+
value={value}
|
|
39
|
+
month={month}
|
|
40
|
+
year={year}
|
|
41
|
+
onChange={onChange}
|
|
42
|
+
locale={locale}
|
|
43
|
+
/>
|
|
44
|
+
</ModalContent>
|
|
45
|
+
</PressableSurface>
|
|
43
46
|
</Backdrop>
|
|
44
47
|
</RNModal>
|
|
45
48
|
);
|
|
@@ -80,7 +80,9 @@ const DateTimePicker: React.FC<DateTimePickerProps> = ({
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
const StyledText = getStyledTextComponent(TextComponent);
|
|
83
|
-
const displayValue =
|
|
83
|
+
const displayValue =
|
|
84
|
+
(value ? formatDate(value, format, { locale: locale }) : placeholder) ||
|
|
85
|
+
' ';
|
|
84
86
|
|
|
85
87
|
return (
|
|
86
88
|
<>
|
|
@@ -180,7 +180,7 @@ const DateTimeSelector: React.FC<DateTimeSelectorProps> = ({
|
|
|
180
180
|
|
|
181
181
|
const getDisplayedValue = (granularity: Granularity) => (value: number) => {
|
|
182
182
|
return granularity === 'month'
|
|
183
|
-
? formatDate(date, 'MMM').slice(0, 3)
|
|
183
|
+
? formatDate(date, 'MMM', { locale: locale }).slice(0, 3)
|
|
184
184
|
: value.toString().padStart(2, '0');
|
|
185
185
|
};
|
|
186
186
|
|
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
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?: SpacingType;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const Grid = ({
|
|
23
|
+
children,
|
|
24
|
+
columns = 12,
|
|
25
|
+
layout,
|
|
26
|
+
style,
|
|
27
|
+
spacing,
|
|
28
|
+
...rest
|
|
29
|
+
}: IGrid) => {
|
|
30
|
+
if (layout) {
|
|
31
|
+
const flatLayout = layout.flat();
|
|
32
|
+
return (
|
|
33
|
+
<View
|
|
34
|
+
style={[
|
|
35
|
+
style,
|
|
36
|
+
{
|
|
37
|
+
display: 'flex',
|
|
38
|
+
flexDirection: 'row',
|
|
39
|
+
flexWrap: 'wrap',
|
|
40
|
+
},
|
|
41
|
+
]}
|
|
42
|
+
{...rest}
|
|
43
|
+
>
|
|
44
|
+
{React.Children.map(children, (child, index) => (
|
|
45
|
+
<GridItem
|
|
46
|
+
columns={columns}
|
|
47
|
+
span={flatLayout[index]}
|
|
48
|
+
spacing={spacing}
|
|
49
|
+
>
|
|
50
|
+
{child}
|
|
51
|
+
</GridItem>
|
|
52
|
+
))}
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<View
|
|
59
|
+
style={[
|
|
60
|
+
style,
|
|
61
|
+
{
|
|
62
|
+
display: 'flex',
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
flexWrap: 'wrap',
|
|
65
|
+
},
|
|
66
|
+
]}
|
|
67
|
+
{...rest}
|
|
68
|
+
>
|
|
69
|
+
{React.Children.map(children, child => {
|
|
70
|
+
return React.cloneElement(child, {
|
|
71
|
+
...child?.props,
|
|
72
|
+
columns,
|
|
73
|
+
spacing,
|
|
74
|
+
});
|
|
75
|
+
})}
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default Grid;
|