@smart-react-components/ui 2.0.0-alpha-10 → 2.0.0-alpha-12
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/Grid/Container.js +1 -1
- package/Modal/index.d.ts +1 -0
- package/Modal/index.js +2 -2
- package/Table/TableContainer.d.ts +10 -0
- package/Table/TableContainer.js +78 -0
- package/Table/Tbody.d.ts +2 -0
- package/Table/Tbody.js +7 -0
- package/Table/Td.d.ts +2 -0
- package/Table/Td.js +7 -0
- package/Table/Tfoot.d.ts +2 -0
- package/Table/Tfoot.js +7 -0
- package/Table/Th.d.ts +2 -0
- package/Table/Th.js +7 -0
- package/Table/Thead.d.ts +2 -0
- package/Table/Thead.js +7 -0
- package/Table/Tr.d.ts +11 -0
- package/Table/Tr.js +34 -0
- package/Table/index.d.ts +22 -0
- package/Table/index.js +26 -0
- package/components/Input/InputElement.js +3 -3
- package/components/Modal/ModalElement.d.ts +1 -0
- package/components/Modal/ModalElement.js +17 -2
- package/components/Table/TableContainerElement.d.ts +6 -0
- package/components/Table/TableContainerElement.js +12 -0
- package/components/Table/TableElement.d.ts +16 -0
- package/components/Table/TableElement.js +153 -0
- package/package.json +7 -7
- package/util/table.d.ts +9 -0
- package/util/table.js +32 -0
package/Grid/Container.js
CHANGED
|
@@ -7,11 +7,11 @@ const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"
|
|
|
7
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
8
|
exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ marginHorizontal = 'auto' }) => ({
|
|
9
9
|
marginHorizontal,
|
|
10
|
+
maxWidth: '100%',
|
|
10
11
|
maxWidthSm: '{length.grid.containerWidth.small}px',
|
|
11
12
|
maxWidthMd: '{length.grid.containerWidth.medium}px',
|
|
12
13
|
maxWidthLg: '{length.grid.containerWidth.large}px',
|
|
13
14
|
maxWidthXl: '{length.grid.containerWidth.xlarge}px',
|
|
14
15
|
})) `
|
|
15
16
|
box-sizing: border-box;
|
|
16
|
-
max-width: 100%;
|
|
17
17
|
`;
|
package/Modal/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, Intrin
|
|
|
8
8
|
beforeHide?: TransitionBeforeCallback;
|
|
9
9
|
beforeShow?: TransitionBeforeCallback;
|
|
10
10
|
children: ContentElement | ContentElement[];
|
|
11
|
+
hasBorder?: boolean;
|
|
11
12
|
hasHideAnimation?: boolean;
|
|
12
13
|
hasShowAnimation?: boolean;
|
|
13
14
|
hasOverlayBackground?: boolean;
|
package/Modal/index.js
CHANGED
|
@@ -9,10 +9,10 @@ const styled_components_1 = require("styled-components");
|
|
|
9
9
|
const ModalElement_1 = __importDefault(require("../components/Modal/ModalElement"));
|
|
10
10
|
const OverlayElement_1 = __importDefault(require("../components/Modal/OverlayElement"));
|
|
11
11
|
const Overlay_1 = __importDefault(require("../Overlay"));
|
|
12
|
-
const Modal = ({ afterHide, afterShow, beforeHide, beforeShow, children, hasHideAnimation = true, hasShowAnimation = true, hasOverlayBackground = true, hasOverlayBlurEffect, isBlock, isCentered, isDismissible = true, isStretched, isFullScreen, setStatus, size = 'medium', sizeSm, sizeMd, sizeLg, sizeXl, shape = 'rectangle', status = true, transitionClassName, transitionDuration }) => {
|
|
12
|
+
const Modal = ({ afterHide, afterShow, beforeHide, beforeShow, children, hasBorder = true, hasHideAnimation = true, hasShowAnimation = true, hasOverlayBackground = true, hasOverlayBlurEffect, isBlock, isCentered, isDismissible = true, isStretched, isFullScreen, setStatus, size = 'medium', sizeSm, sizeMd, sizeLg, sizeXl, shape = 'rectangle', status = true, transitionClassName, transitionDuration }) => {
|
|
13
13
|
const theme = react_1.default.useContext(styled_components_1.ThemeContext);
|
|
14
14
|
return (react_1.default.createElement(CSSTransition_1.default, { afterHide: afterHide, afterShow: afterShow, beforeHide: beforeHide, beforeShow: beforeShow, className: transitionClassName !== null && transitionClassName !== void 0 ? transitionClassName : 'src-modal', duration: transitionDuration !== null && transitionDuration !== void 0 ? transitionDuration : theme.$.transition.modalDuration, hasHideAnimation: hasHideAnimation, hasShowAnimation: hasShowAnimation, status: status },
|
|
15
15
|
react_1.default.createElement(Overlay_1.default, Object.assign({ hasBackground: hasOverlayBackground, hasBlurEffect: hasOverlayBlurEffect, template: react_1.default.createElement(OverlayElement_1.default, { duration: transitionDuration !== null && transitionDuration !== void 0 ? transitionDuration : theme.$.transition.modalDuration, isFullScreen: isFullScreen }) }, (isDismissible && { onClick: () => setStatus(false) })),
|
|
16
|
-
react_1.default.createElement(ModalElement_1.default, { isBlock: isBlock, isCentered: isCentered, isStretched: isStretched, isFullScreen: isFullScreen, modalSize: size, modalSizeSm: sizeSm, modalSizeMd: sizeMd, modalSizeLg: sizeLg, modalSizeXl: sizeXl, shape: shape }, children))));
|
|
16
|
+
react_1.default.createElement(ModalElement_1.default, { isBlock: isBlock, isCentered: isCentered, isStretched: isStretched, isFullScreen: isFullScreen, hasBorder: hasBorder, modalSize: size, modalSizeSm: sizeSm, modalSizeMd: sizeMd, modalSizeLg: sizeLg, modalSizeXl: sizeXl, shape: shape }, children))));
|
|
17
17
|
};
|
|
18
18
|
exports.default = Modal;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
|
|
2
|
+
import { JSXElementProps, Partial, ResponsiveProp } from '@smart-react-components/core/types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface Props extends IntrinsicStyledProps, Partial<ResponsiveProp<'stickyX', number>>, Partial<ResponsiveProp<'stickyY', number>> {
|
|
5
|
+
children: JSX.Element;
|
|
6
|
+
elementProps?: JSXElementProps;
|
|
7
|
+
hasInternalScroll?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const TableContainer: React.FC<Props>;
|
|
10
|
+
export default TableContainer;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const element_props_1 = __importDefault(require("@smart-react-components/core/element-props"));
|
|
7
|
+
const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
|
|
8
|
+
const dom_1 = require("@smart-react-components/core/util/dom");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const styled_components_1 = require("styled-components");
|
|
11
|
+
const TableContainerElement_1 = __importDefault(require("../components/Table/TableContainerElement"));
|
|
12
|
+
const table_1 = require("../util/table");
|
|
13
|
+
const TableContainer = props => {
|
|
14
|
+
const theme = react_1.default.useContext(styled_components_1.ThemeContext);
|
|
15
|
+
const el = react_1.default.useRef(null);
|
|
16
|
+
const [styled, setStyled] = react_1.default.useState(() => '');
|
|
17
|
+
const handleResize = () => {
|
|
18
|
+
const { x, y } = (0, table_1.getBreakpointValue)([props.stickyX, props.stickyXSm, props.stickyXMd, props.stickyXLg, props.stickyXXl], [props.stickyY, props.stickyYSm, props.stickyYMd, props.stickyYLg, props.stickyYXl], theme);
|
|
19
|
+
let styled = `
|
|
20
|
+
> table > * > tr > * {
|
|
21
|
+
position: sticky;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
let left = 0;
|
|
25
|
+
let leftZIndex = x + 1;
|
|
26
|
+
const xEls = el.current.querySelectorAll('table > * > tr > *');
|
|
27
|
+
if (x > 0 && xEls.length > 0) {
|
|
28
|
+
if (props.hasInternalScroll) {
|
|
29
|
+
styled += 'overflow-x: auto;';
|
|
30
|
+
}
|
|
31
|
+
for (let i = 0; i < x; i++) {
|
|
32
|
+
styled += `
|
|
33
|
+
> table > * > tr > *:nth-child(${i + 1}) {
|
|
34
|
+
left: ${left}px;
|
|
35
|
+
z-index: ${leftZIndex--};
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
left += xEls[i].offsetWidth;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const yEls = el.current.querySelectorAll('table > thead > tr');
|
|
42
|
+
console.log(x, y, yEls);
|
|
43
|
+
if (y > 0 && yEls.length > 0) {
|
|
44
|
+
if (props.hasInternalScroll) {
|
|
45
|
+
styled += 'overflow-y: auto;';
|
|
46
|
+
}
|
|
47
|
+
styled += `
|
|
48
|
+
> table > thead {
|
|
49
|
+
position: relative;
|
|
50
|
+
z-index: ${(x !== null && x !== void 0 ? x : 0) + 1 + 1};
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
53
|
+
for (let i = yEls.length - 1; i > yEls.length - 1 - y; i--) {
|
|
54
|
+
const top = yEls[i].offsetTop;
|
|
55
|
+
styled += `
|
|
56
|
+
> table > thead > tr:nth-of-type(${i + 1}) > * {
|
|
57
|
+
top: ${top}px;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
console.log(styled);
|
|
63
|
+
setStyled(styled);
|
|
64
|
+
};
|
|
65
|
+
react_1.default.useEffect(() => {
|
|
66
|
+
(0, dom_1.addEventListener)(window, ['resize'], handleResize);
|
|
67
|
+
handleResize();
|
|
68
|
+
return () => {
|
|
69
|
+
(0, dom_1.removeEventListener)(window, ['resize'], handleResize);
|
|
70
|
+
};
|
|
71
|
+
}, []);
|
|
72
|
+
return (react_1.default.createElement(TableContainerElement_1.default, Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), props.elementProps, { ref: el, styled: styled }), props.children));
|
|
73
|
+
};
|
|
74
|
+
TableContainer.defaultProps = {
|
|
75
|
+
elementProps: {},
|
|
76
|
+
hasInternalScroll: true,
|
|
77
|
+
};
|
|
78
|
+
exports.default = TableContainer;
|
package/Table/Tbody.d.ts
ADDED
package/Table/Tbody.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Tbody_1 = __importDefault(require("@smart-react-components/core/Element/Tbody"));
|
|
7
|
+
exports.default = Tbody_1.default;
|
package/Table/Td.d.ts
ADDED
package/Table/Td.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Td_1 = __importDefault(require("@smart-react-components/core/Element/Td"));
|
|
7
|
+
exports.default = Td_1.default;
|
package/Table/Tfoot.d.ts
ADDED
package/Table/Tfoot.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Tfoot_1 = __importDefault(require("@smart-react-components/core/Element/Tfoot"));
|
|
7
|
+
exports.default = Tfoot_1.default;
|
package/Table/Th.d.ts
ADDED
package/Table/Th.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Th_1 = __importDefault(require("@smart-react-components/core/Element/Th"));
|
|
7
|
+
exports.default = Th_1.default;
|
package/Table/Thead.d.ts
ADDED
package/Table/Thead.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Thead_1 = __importDefault(require("@smart-react-components/core/Element/Thead"));
|
|
7
|
+
exports.default = Thead_1.default;
|
package/Table/Tr.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StyledProps } from '@smart-react-components/core/styled-props';
|
|
2
|
+
import { PaletteProp } from '@smart-react-components/core/types';
|
|
3
|
+
export interface Props extends StyledProps {
|
|
4
|
+
hasHover?: boolean;
|
|
5
|
+
isEven?: boolean;
|
|
6
|
+
isSoft?: boolean;
|
|
7
|
+
palette?: PaletteProp;
|
|
8
|
+
startIndex?: number;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: import("styled-components").StyledComponent<"tr", any, StyledProps & Props, never>;
|
|
11
|
+
export default _default;
|
package/Table/Tr.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Tr_1 = __importDefault(require("@smart-react-components/core/Element/Tr"));
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
exports.default = (0, styled_components_1.default)(Tr_1.default)(({ theme, hasHover, isEven, isSoft, palette, startIndex = 0 }) => `
|
|
9
|
+
${palette
|
|
10
|
+
? `
|
|
11
|
+
> *:nth-child(n+${startIndex}) {
|
|
12
|
+
${!isSoft
|
|
13
|
+
? `
|
|
14
|
+
background: ${!isEven ? theme.$.palette[palette].background : theme.$.palette[palette].dynamic};
|
|
15
|
+
border-color: ${theme.$.palette[palette].dynamicest};
|
|
16
|
+
color: ${theme.$.palette[palette].font};
|
|
17
|
+
`
|
|
18
|
+
: `
|
|
19
|
+
background: ${!isEven ? theme.$.palette[palette].softBackground : theme.$.palette[palette].softDark};
|
|
20
|
+
border-color: ${theme.$.palette[palette].softDarkest};
|
|
21
|
+
color: ${theme.$.palette[palette].softFont};
|
|
22
|
+
`}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
${hasHover
|
|
26
|
+
? `
|
|
27
|
+
&:hover > *:nth-child(n+${startIndex}) {
|
|
28
|
+
background: ${!isSoft ? theme.$.palette[palette].dynamicer : theme.$.palette[palette].softDarker};
|
|
29
|
+
}
|
|
30
|
+
`
|
|
31
|
+
: ''}
|
|
32
|
+
`
|
|
33
|
+
: ''}
|
|
34
|
+
`);
|
package/Table/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
|
|
2
|
+
import { JSXElementProps, PaletteProp, Partial, ResponsiveProp, ShapeProp, SizeProp, TableStripedOrientation } from '@smart-react-components/core/types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
export interface Props extends IntrinsicStyledProps, Partial<ResponsiveProp<'size', SizeProp>> {
|
|
5
|
+
children: JSX.Element | JSX.Element[];
|
|
6
|
+
elementProps?: JSXElementProps;
|
|
7
|
+
hasBorderX?: boolean;
|
|
8
|
+
hasBorderY?: boolean;
|
|
9
|
+
hasHeadBackground?: boolean;
|
|
10
|
+
hasHover?: boolean;
|
|
11
|
+
hasInternalScroll?: boolean;
|
|
12
|
+
isBlock?: boolean;
|
|
13
|
+
isSoft?: boolean;
|
|
14
|
+
isStriped?: boolean;
|
|
15
|
+
palette?: PaletteProp;
|
|
16
|
+
shape?: ShapeProp;
|
|
17
|
+
stickyX?: number;
|
|
18
|
+
stickyY?: number;
|
|
19
|
+
stripedOrientation?: TableStripedOrientation;
|
|
20
|
+
}
|
|
21
|
+
declare const Table: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLTableElement>>;
|
|
22
|
+
export default Table;
|
package/Table/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const element_props_1 = __importDefault(require("@smart-react-components/core/element-props"));
|
|
7
|
+
const intrinsic_styled_props_1 = __importDefault(require("@smart-react-components/core/element-props/intrinsic-styled-props"));
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const styled_components_1 = require("styled-components");
|
|
10
|
+
const TableElement_1 = __importDefault(require("../components/Table/TableElement"));
|
|
11
|
+
const Table = react_1.default.forwardRef((props, forwardRef) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const theme = react_1.default.useContext(styled_components_1.ThemeContext);
|
|
14
|
+
return (react_1.default.createElement(TableElement_1.default, Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), { hasBorderX: props.hasBorderX, hasBorderY: props.hasBorderY, hasHeadBackground: props.hasHeadBackground, hasHover: props.hasHover, isBlock: props.isBlock, isSoft: props.isSoft, isStriped: props.isStriped, palette: props.palette, ref: forwardRef, shape: props.shape, stripedOrientation: (_a = props.stripedOrientation) !== null && _a !== void 0 ? _a : theme.$.vars.tableStripedOrientation, tableSize: props.size, tableSizeSm: props.sizeSm, tableSizeMd: props.sizeMd, tableSizeLg: props.sizeLg, tableSizeXl: props.sizeXl }), props.children));
|
|
15
|
+
});
|
|
16
|
+
Table.defaultProps = {
|
|
17
|
+
hasBorderY: true,
|
|
18
|
+
hasInternalScroll: true,
|
|
19
|
+
isBlock: true,
|
|
20
|
+
palette: 'dynamic',
|
|
21
|
+
shape: 'rectangle',
|
|
22
|
+
size: 'medium',
|
|
23
|
+
stickyX: 1,
|
|
24
|
+
stickyY: 1,
|
|
25
|
+
};
|
|
26
|
+
exports.default = Table;
|
|
@@ -12,19 +12,19 @@ const styled_components_1 = __importDefault(require("styled-components"));
|
|
|
12
12
|
const css_1 = require("../../util/css");
|
|
13
13
|
const dom_1 = require("../../util/dom");
|
|
14
14
|
exports.InputPlaceholder = (0, styled_components_1.default)(Div_1.default).attrs(({ children }) => (Object.assign({}, (!children && { children: react_1.default.createElement(react_1.default.Fragment, null, "\u00A0"), userSelect: 'none' })))) ``;
|
|
15
|
-
exports.default = (0, styled_components_1.default)(Input_1.default).attrs(({ hasLeftAddon, hasRightAddon,
|
|
15
|
+
exports.default = (0, styled_components_1.default)(Input_1.default).attrs(({ hasLeftAddon, hasRightAddon, isInput = true }) => (Object.assign(Object.assign({}, (!isInput && { as: 'div' })), { getInputSize: (v, t) => `
|
|
16
16
|
font-size: ${t.$.size.input[v].fontSize};
|
|
17
17
|
padding: ${t.$.size.input[v].padding.y} ${t.$.size.input[v].padding.x};
|
|
18
18
|
|
|
19
19
|
${hasLeftAddon
|
|
20
20
|
? `
|
|
21
|
-
padding-left: ${
|
|
21
|
+
padding-left: ${(0, css_1.toCSSValue)(t.$.size.input[v].padding.x)(v => v / 2)};
|
|
22
22
|
`
|
|
23
23
|
: ''}
|
|
24
24
|
|
|
25
25
|
${hasRightAddon
|
|
26
26
|
? `
|
|
27
|
-
padding-right: ${
|
|
27
|
+
padding-right: ${(0, css_1.toCSSValue)(t.$.size.input[v].padding.x)(v => v / 2)};
|
|
28
28
|
`
|
|
29
29
|
: ''}
|
|
30
30
|
`, isInput })))(({ theme, hasBorder, hasLeftAddon, hasRightAddon, isDisabled, isFocused, isInput, isOutline, isSoft, palette, shape }) => `
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StyledProps } from '@smart-react-components/core/styled-props';
|
|
2
2
|
import { ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
|
|
3
3
|
interface Props extends StyledProps, ResponsiveProp<'modalSize', SizeProp> {
|
|
4
|
+
hasBorder: boolean;
|
|
4
5
|
isBlock: boolean;
|
|
5
6
|
isCentered: boolean;
|
|
6
7
|
isFullScreen: boolean;
|
|
@@ -33,7 +33,7 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ isBlo
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
`,
|
|
36
|
-
}))(({ theme, isBlock, isCentered, isFullScreen, isStretched, shape }) => `
|
|
36
|
+
}))(({ theme, hasBorder, isBlock, isCentered, isFullScreen, isStretched, shape }) => `
|
|
37
37
|
background: ${theme.$.color.dynamic.background};
|
|
38
38
|
box-sizing: border-box;
|
|
39
39
|
color: ${theme.$.color.dynamic.font};
|
|
@@ -58,8 +58,23 @@ exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ isBlo
|
|
|
58
58
|
|
|
59
59
|
${!isFullScreen
|
|
60
60
|
? `
|
|
61
|
-
border: solid 1px ${theme.$.color.dynamic.accent};
|
|
62
61
|
border-radius: ${theme.$.radius.modal[shape]};
|
|
62
|
+
|
|
63
|
+
${hasBorder
|
|
64
|
+
? `
|
|
65
|
+
border: solid 1px ${theme.$.color.dynamic.accent};
|
|
66
|
+
`
|
|
67
|
+
: ''}
|
|
68
|
+
|
|
69
|
+
> *:first-child {
|
|
70
|
+
border-top-left-radius: ${theme.$.radius.modal[shape]};
|
|
71
|
+
border-top-right-radius: ${theme.$.radius.modal[shape]};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
> *:last-child {
|
|
75
|
+
border-bottom-left-radius: ${theme.$.radius.modal[shape]};
|
|
76
|
+
border-bottom-right-radius: ${theme.$.radius.modal[shape]};
|
|
77
|
+
}
|
|
63
78
|
`
|
|
64
79
|
: ''}
|
|
65
80
|
`);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { StyledProps } from '@smart-react-components/core/styled-props';
|
|
2
|
+
interface Props extends StyledProps {
|
|
3
|
+
styled: string;
|
|
4
|
+
}
|
|
5
|
+
declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps & Props, never>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
exports.default = (0, styled_components_1.default)(Div_1.default)(({ styled }) => `
|
|
9
|
+
position: relative;
|
|
10
|
+
|
|
11
|
+
${styled}
|
|
12
|
+
`);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StyledProps } from '@smart-react-components/core/styled-props';
|
|
2
|
+
import { PaletteProp, ResponsiveProp, ShapeProp, SizeProp, TableStripedOrientation } from '@smart-react-components/core/types';
|
|
3
|
+
export interface Props extends StyledProps, Partial<ResponsiveProp<'tableSize', SizeProp>> {
|
|
4
|
+
hasBorderX: boolean;
|
|
5
|
+
hasBorderY: boolean;
|
|
6
|
+
hasHeadBackground: boolean;
|
|
7
|
+
hasHover: boolean;
|
|
8
|
+
isBlock: boolean;
|
|
9
|
+
isSoft: boolean;
|
|
10
|
+
isStriped: boolean;
|
|
11
|
+
palette: PaletteProp;
|
|
12
|
+
shape: ShapeProp;
|
|
13
|
+
stripedOrientation: TableStripedOrientation;
|
|
14
|
+
}
|
|
15
|
+
declare const _default: import("styled-components").StyledComponent<"table", any, StyledProps & Props, never>;
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Table_1 = __importDefault(require("@smart-react-components/core/Element/Table"));
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
exports.default = (0, styled_components_1.default)(Table_1.default).attrs({
|
|
9
|
+
getTableSize: (v, t) => `
|
|
10
|
+
font-size: ${t.$.size.table[v].fontSize};
|
|
11
|
+
|
|
12
|
+
> * > tr > * {
|
|
13
|
+
padding: ${t.$.size.table[v].padding.y} ${t.$.size.table[v].padding.x};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
> thead {
|
|
17
|
+
font-size: ${t.$.size.table[v].headFontSize};
|
|
18
|
+
}
|
|
19
|
+
`,
|
|
20
|
+
})(({ theme, hasBorderX, hasBorderY, hasHeadBackground, hasHover, isBlock, isSoft, isStriped, palette, shape, stripedOrientation }) => `
|
|
21
|
+
border-collapse: separate;
|
|
22
|
+
border-spacing: 0;
|
|
23
|
+
empty-cells: hide;
|
|
24
|
+
font-family: ${theme.$.fontFamily.table};
|
|
25
|
+
|
|
26
|
+
> thead {
|
|
27
|
+
font-family: ${theme.$.fontFamily.tableHead};
|
|
28
|
+
font-weight: ${theme.$.fontWeight.tableHead};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
${isBlock
|
|
32
|
+
? `
|
|
33
|
+
width: 100%;
|
|
34
|
+
`
|
|
35
|
+
: ''}
|
|
36
|
+
|
|
37
|
+
> * > tr > * {
|
|
38
|
+
border: solid 0;
|
|
39
|
+
box-sizing: border-box;
|
|
40
|
+
fill: currentcolor;
|
|
41
|
+
transition: background 150ms 0s ease-in-out;
|
|
42
|
+
word-break: break-word;
|
|
43
|
+
word-wrap: break-word;
|
|
44
|
+
|
|
45
|
+
${hasBorderX
|
|
46
|
+
? `
|
|
47
|
+
border-right-width: ${theme.$.length.table.border};
|
|
48
|
+
|
|
49
|
+
&:first-child {
|
|
50
|
+
border-left-width: ${theme.$.length.table.border};
|
|
51
|
+
}
|
|
52
|
+
`
|
|
53
|
+
: ''}
|
|
54
|
+
|
|
55
|
+
${hasBorderY
|
|
56
|
+
? `
|
|
57
|
+
border-bottom-width: ${theme.$.length.table.border};
|
|
58
|
+
`
|
|
59
|
+
: ''}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
${hasBorderY
|
|
63
|
+
? `
|
|
64
|
+
> thead > tr > * {
|
|
65
|
+
border-bottom-width: ${theme.$.length.table.headBorder};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
> *:first-child > tr:first-child > * {
|
|
69
|
+
border-top-width: ${theme.$.length.table.border};
|
|
70
|
+
}
|
|
71
|
+
`
|
|
72
|
+
: ''}
|
|
73
|
+
|
|
74
|
+
> *:first-child > tr:first-child > * {
|
|
75
|
+
border-top-left-radius: ${theme.$.radius.table[shape]};
|
|
76
|
+
border-top-right-radius: ${theme.$.radius.table[shape]};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
> *:last-child > tr:last-child > * {
|
|
80
|
+
border-bottom-left-radius: ${theme.$.radius.table[shape]};
|
|
81
|
+
border-bottom-right-radius: ${theme.$.radius.table[shape]};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
${!isSoft
|
|
85
|
+
? `
|
|
86
|
+
> * > tr > * {
|
|
87
|
+
background: ${theme.$.palette[palette].background};
|
|
88
|
+
border-color: ${theme.$.palette[palette].dynamicest};
|
|
89
|
+
color: ${theme.$.palette[palette].font};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
${hasHeadBackground
|
|
93
|
+
? `
|
|
94
|
+
> thead > tr > * {
|
|
95
|
+
background: ${theme.$.palette[palette].dynamic};
|
|
96
|
+
}
|
|
97
|
+
`
|
|
98
|
+
: ''}
|
|
99
|
+
|
|
100
|
+
${isStriped
|
|
101
|
+
? `
|
|
102
|
+
> tbody > tr:nth-child(${stripedOrientation}) > * {
|
|
103
|
+
background: ${theme.$.palette[palette].dynamic};
|
|
104
|
+
}
|
|
105
|
+
`
|
|
106
|
+
: ''}
|
|
107
|
+
|
|
108
|
+
${hasHover
|
|
109
|
+
? `
|
|
110
|
+
> tbody > tr {
|
|
111
|
+
> * {
|
|
112
|
+
transition: background 150ms 0 ease-in-out;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&:hover > * {
|
|
116
|
+
background: ${theme.$.palette[palette].dynamicer};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
`
|
|
120
|
+
: ''}
|
|
121
|
+
`
|
|
122
|
+
: `
|
|
123
|
+
> * > tr > * {
|
|
124
|
+
background: ${theme.$.palette[palette].softBackground};
|
|
125
|
+
border-color: ${theme.$.palette[palette].softDarkest};
|
|
126
|
+
color: ${theme.$.palette[palette].softFont};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
${hasHeadBackground
|
|
130
|
+
? `
|
|
131
|
+
> thead > tr > * {
|
|
132
|
+
background: ${theme.$.palette[palette].softDark};
|
|
133
|
+
}
|
|
134
|
+
`
|
|
135
|
+
: ''}
|
|
136
|
+
|
|
137
|
+
${isStriped
|
|
138
|
+
? `
|
|
139
|
+
> tbody > tr:nth-child(${stripedOrientation}) > * {
|
|
140
|
+
background: ${theme.$.palette[palette].softDark};
|
|
141
|
+
}
|
|
142
|
+
`
|
|
143
|
+
: ''}
|
|
144
|
+
|
|
145
|
+
${hasHover
|
|
146
|
+
? `
|
|
147
|
+
> tbody > tr:hover > * {
|
|
148
|
+
background: ${theme.$.palette[palette].softDarker};
|
|
149
|
+
}
|
|
150
|
+
`
|
|
151
|
+
: ''}
|
|
152
|
+
`}
|
|
153
|
+
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart-react-components/ui",
|
|
3
|
-
"version": "2.0.0-alpha-
|
|
3
|
+
"version": "2.0.0-alpha-12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"description": "SRC UI includes React and Styled components.",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"test": "jest"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@smart-react-components/core": "2.0.0-alpha-
|
|
68
|
-
"@smart-react-components/router": "2.0.0-alpha-
|
|
69
|
-
"@smart-react-components/transition": "2.0.0-alpha-
|
|
67
|
+
"@smart-react-components/core": "2.0.0-alpha-17",
|
|
68
|
+
"@smart-react-components/router": "2.0.0-alpha-13",
|
|
69
|
+
"@smart-react-components/transition": "2.0.0-alpha-13",
|
|
70
70
|
"@testing-library/react": "13.4.0",
|
|
71
71
|
"@types/jest": "29.0.1",
|
|
72
72
|
"@types/react": "18.0.19",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"typescript": "4.8.3"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@smart-react-components/core": "^2.0.0-alpha-
|
|
87
|
-
"@smart-react-components/router": "^2.0.0-alpha-
|
|
88
|
-
"@smart-react-components/transition": "^2.0.0-alpha-
|
|
86
|
+
"@smart-react-components/core": "^2.0.0-alpha-17",
|
|
87
|
+
"@smart-react-components/router": "^2.0.0-alpha-13",
|
|
88
|
+
"@smart-react-components/transition": "^2.0.0-alpha-13",
|
|
89
89
|
"react": "^18.2.0",
|
|
90
90
|
"react-dom": "^18.2.0",
|
|
91
91
|
"styled-components": "^5.3.5"
|
package/util/table.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Theme } from '@smart-react-components/core/theme';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the breakpoint value according to the given breakpoints and the window size.
|
|
4
|
+
* Breakpoints are given as an array from small to large - [xs, sm, md, lg, xl]
|
|
5
|
+
*/
|
|
6
|
+
export declare const getBreakpointValue: (xProps: number[], yProps: number[], theme: Theme) => {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
package/util/table.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBreakpointValue = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Gets the breakpoint value according to the given breakpoints and the window size.
|
|
6
|
+
* Breakpoints are given as an array from small to large - [xs, sm, md, lg, xl]
|
|
7
|
+
*/
|
|
8
|
+
const getBreakpointValue = (xProps, yProps, theme) => {
|
|
9
|
+
let x;
|
|
10
|
+
let y;
|
|
11
|
+
const width = window.innerWidth;
|
|
12
|
+
if (width > theme.$.length.breakpoint.xlarge) {
|
|
13
|
+
x = xProps[4];
|
|
14
|
+
y = yProps[4];
|
|
15
|
+
}
|
|
16
|
+
if (width > theme.$.length.breakpoint.large) {
|
|
17
|
+
x !== null && x !== void 0 ? x : (x = xProps[3]);
|
|
18
|
+
y !== null && y !== void 0 ? y : (y = yProps[3]);
|
|
19
|
+
}
|
|
20
|
+
if (width > theme.$.length.breakpoint.medium) {
|
|
21
|
+
x !== null && x !== void 0 ? x : (x = xProps[2]);
|
|
22
|
+
y !== null && y !== void 0 ? y : (y = yProps[2]);
|
|
23
|
+
}
|
|
24
|
+
if (width > theme.$.length.breakpoint.small) {
|
|
25
|
+
x !== null && x !== void 0 ? x : (x = xProps[1]);
|
|
26
|
+
y !== null && y !== void 0 ? y : (y = yProps[1]);
|
|
27
|
+
}
|
|
28
|
+
x !== null && x !== void 0 ? x : (x = xProps[0]);
|
|
29
|
+
y !== null && y !== void 0 ? y : (y = yProps[0]);
|
|
30
|
+
return { x, y };
|
|
31
|
+
};
|
|
32
|
+
exports.getBreakpointValue = getBreakpointValue;
|