@smart-react-components/ui 2.0.0-alpha-40 → 2.0.0-alpha-42
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/Button/ButtonGroup.js +4 -1
- package/Button/index.js +1 -1
- package/Table/TableContainer.d.ts +1 -1
- package/Table/TableContainer.js +6 -4
- package/Table/index.js +2 -1
- package/Tooltip/index.d.ts +1 -1
- package/Tooltip/index.js +4 -4
- package/components/Button/ButtonElement.d.ts +1 -0
- package/components/Button/ButtonElement.js +23 -8
- package/components/Button/ButtonGroupElement.js +9 -21
- package/components/Button/ButtonListElement.d.ts +3 -1
- package/package.json +1 -1
- package/types/button.d.ts +1 -0
package/Button/ButtonGroup.js
CHANGED
|
@@ -6,5 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const ButtonGroupElement_1 = __importDefault(require("../components/Button/ButtonGroupElement"));
|
|
8
8
|
const ButtonList_1 = __importDefault(require("./ButtonList"));
|
|
9
|
-
const ButtonGroup = props => (react_1.default.createElement(ButtonList_1.default, Object.assign({}, props, { hasSpace: false, template: react_1.default.createElement(ButtonGroupElement_1.default,
|
|
9
|
+
const ButtonGroup = props => (react_1.default.createElement(ButtonList_1.default, Object.assign({}, props, { hasSpace: false, template: react_1.default.createElement(ButtonGroupElement_1.default, { shape: props.shape }) }), props.children));
|
|
10
|
+
ButtonGroup.defaultProps = {
|
|
11
|
+
shape: 'rounded',
|
|
12
|
+
};
|
|
10
13
|
exports.default = ButtonGroup;
|
package/Button/index.js
CHANGED
|
@@ -62,7 +62,7 @@ const Button = react_1.default.forwardRef((props, forwardRef) => {
|
|
|
62
62
|
}, [props.loading, props.isLoading]);
|
|
63
63
|
const applyIntrinsicStyledProps = () => (Object.assign(Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default])), (props.hasSpace && Object.assign(Object.assign(Object.assign(Object.assign({ margin: `$size.button.${props.size}.margin.y $size.button.${props.size}.margin.x` }, (props.sizeSm && { marginSm: `$size.button.${props.sizeSm}.margin.y $size.button.${props.sizeSm}.margin.x` })), (props.sizeMd && { marginMd: `$size.button.${props.sizeMd}.margin.y $size.button.${props.sizeMd}.margin.x` })), (props.sizeLg && { marginLg: `$size.button.${props.sizeLg}.margin.y $size.button.${props.sizeLg}.margin.x` })), (props.sizeXl && { marginXl: `$size.button.${props.sizeXl}.margin.y $size.button.${props.sizeXl}.margin.x` })))));
|
|
64
64
|
const hasButtonContainer = ((_a = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _a === void 0 ? void 0 : _a.isSeparated) || ((_b = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _b === void 0 ? void 0 : _b.isSeparated);
|
|
65
|
-
let Element = (react_1.default.createElement(ButtonElement_1.default, Object.assign({}, props.elementProps, ((!props.isDisabled && !props.isLoading) && (0, element_props_1.default)(props, [click_events_1.default])), (!hasButtonContainer && applyIntrinsicStyledProps()), (props.as && { as: props.as }), { buttonSize: props.size, buttonSizeSm: props.sizeSm, buttonSizeMd: props.sizeMd, buttonSizeLg: props.sizeLg, buttonSizeXl: props.sizeXl, hasButtonContainer: hasButtonContainer, hasHover: props.hasHover, hasLeftAddon: !!leftAddon, hasRightAddon: !!rightAddon, hasSeparatedLeftAddon: !!((_c = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _c === void 0 ? void 0 : _c.isSeparated), hasSeparatedRightAddon: !!((_d = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _d === void 0 ? void 0 : _d.isSeparated), isBlock: props.isBlock, isDisabled: props.isDisabled, isFixedSize: props.isFixedSize, isLink: props.isLink, isLoading: props.isLoading, isSoft: props.isSoft, isOutline: props.isOutline, palette: props.palette, ref: forwardRef, shape: props.shape }),
|
|
65
|
+
let Element = (react_1.default.createElement(ButtonElement_1.default, Object.assign({}, props.elementProps, ((!props.isDisabled && !props.isLoading) && (0, element_props_1.default)(props, [click_events_1.default])), (!hasButtonContainer && applyIntrinsicStyledProps()), (props.as && { as: props.as }), { buttonSize: props.size, buttonSizeSm: props.sizeSm, buttonSizeMd: props.sizeMd, buttonSizeLg: props.sizeLg, buttonSizeXl: props.sizeXl, hasButtonContainer: hasButtonContainer, hasHover: props.hasHover, hasLeftAddon: !!leftAddon, hasRightAddon: !!rightAddon, hasSeparatedLeftAddon: !!((_c = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _c === void 0 ? void 0 : _c.isSeparated), hasSeparatedRightAddon: !!((_d = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _d === void 0 ? void 0 : _d.isSeparated), isActive: props.isActive, isBlock: props.isBlock, isDisabled: props.isDisabled, isFixedSize: props.isFixedSize, isLink: props.isLink, isLoading: props.isLoading, isSoft: props.isSoft, isOutline: props.isOutline, palette: props.palette, ref: forwardRef, shape: props.shape }),
|
|
66
66
|
loadingEl && loadingEl,
|
|
67
67
|
(leftAddon && !leftAddon.props.isSeparated) && leftAddon,
|
|
68
68
|
react_1.default.createElement(ButtonContent_1.default, null, props.children),
|
|
@@ -6,5 +6,5 @@ export interface Props extends IntrinsicStyledProps, Partial<ResponsiveProp<'sti
|
|
|
6
6
|
elementProps?: JSXElementProps;
|
|
7
7
|
hasInternalScroll?: boolean;
|
|
8
8
|
}
|
|
9
|
-
declare const TableContainer: React.
|
|
9
|
+
declare const TableContainer: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLElement>>;
|
|
10
10
|
export default TableContainer;
|
package/Table/TableContainer.js
CHANGED
|
@@ -11,10 +11,11 @@ const react_1 = __importDefault(require("react"));
|
|
|
11
11
|
const styled_components_1 = require("styled-components");
|
|
12
12
|
const TableContainerElement_1 = __importDefault(require("../components/Table/TableContainerElement"));
|
|
13
13
|
const table_1 = require("../util/table");
|
|
14
|
-
const TableContainer = props => {
|
|
14
|
+
const TableContainer = react_1.default.forwardRef((props, forwardRef) => {
|
|
15
15
|
const theme = react_1.default.useContext(styled_components_1.ThemeContext);
|
|
16
|
-
const
|
|
16
|
+
const ref = react_1.default.useRef(null);
|
|
17
17
|
const [styled, setStyled] = react_1.default.useState(() => '');
|
|
18
|
+
const getRef = () => (forwardRef !== null && forwardRef !== void 0 ? forwardRef : ref);
|
|
18
19
|
const handleResize = () => {
|
|
19
20
|
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);
|
|
20
21
|
let styled = `
|
|
@@ -24,6 +25,7 @@ const TableContainer = props => {
|
|
|
24
25
|
`;
|
|
25
26
|
let left = 0;
|
|
26
27
|
let leftZIndex = x + 1;
|
|
28
|
+
const el = getRef();
|
|
27
29
|
const xEls = el.current.querySelectorAll('table:first-child > * > tr > *');
|
|
28
30
|
const yEls = el.current.querySelectorAll('table:first-child > thead > tr');
|
|
29
31
|
if (x > 0 && xEls.length > 0) {
|
|
@@ -85,8 +87,8 @@ const TableContainer = props => {
|
|
|
85
87
|
(0, useChangeEffect_1.default)(() => {
|
|
86
88
|
handleResize();
|
|
87
89
|
}, [props.children]);
|
|
88
|
-
return (react_1.default.createElement(TableContainerElement_1.default, Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), props.elementProps, { ref:
|
|
89
|
-
};
|
|
90
|
+
return (react_1.default.createElement(TableContainerElement_1.default, Object.assign({}, (0, element_props_1.default)(props, [intrinsic_styled_props_1.default]), props.elementProps, { ref: getRef(), styled: styled }), props.children));
|
|
91
|
+
});
|
|
90
92
|
TableContainer.defaultProps = {
|
|
91
93
|
elementProps: {},
|
|
92
94
|
flex: '1 1 auto',
|
package/Table/index.js
CHANGED
|
@@ -11,9 +11,10 @@ const TableElement_1 = __importDefault(require("../components/Table/TableElement
|
|
|
11
11
|
const Table = react_1.default.forwardRef((props, forwardRef) => {
|
|
12
12
|
var _a;
|
|
13
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));
|
|
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.elementProps), props.children));
|
|
15
15
|
});
|
|
16
16
|
Table.defaultProps = {
|
|
17
|
+
elementProps: {},
|
|
17
18
|
hasBorderY: true,
|
|
18
19
|
hasInternalScroll: true,
|
|
19
20
|
isBlock: true,
|
package/Tooltip/index.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export interface Props extends Partial<ResponsiveProp<'size', SizeProp>> {
|
|
|
23
23
|
transitionDuration?: number;
|
|
24
24
|
triggerInteraction?: TriggerInteraction;
|
|
25
25
|
}
|
|
26
|
-
declare const Tooltip: React.
|
|
26
|
+
declare const Tooltip: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLElement>>;
|
|
27
27
|
export default Tooltip;
|
package/Tooltip/index.js
CHANGED
|
@@ -17,13 +17,13 @@ const popover_1 = require("../util/popover");
|
|
|
17
17
|
var types_2 = require("../types");
|
|
18
18
|
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return types_2.Position; } });
|
|
19
19
|
Object.defineProperty(exports, "TriggerInteraction", { enumerable: true, get: function () { return types_2.TriggerInteraction; } });
|
|
20
|
-
const Tooltip = ({ afterHide, afterShow, beforeHide, beforeShow, children, hasHideAnimation = true, hasShowAnimation = true, hoverDelay, isDismissible, isSoft, palette = '!dynamic', position = types_1.Position.TOP, setStatus, size = 'medium', sizeSm, sizeMd, sizeLg, sizeXl, space = 0, status, transitionClassName, transitionDuration, triggerInteraction = types_1.TriggerInteraction.CLICK | types_1.TriggerInteraction.HOVER }) => {
|
|
20
|
+
const Tooltip = react_1.default.forwardRef(({ afterHide, afterShow, beforeHide, beforeShow, children, hasHideAnimation = true, hasShowAnimation = true, hoverDelay, isDismissible, isSoft, palette = '!dynamic', position = types_1.Position.TOP, setStatus, size = 'medium', sizeSm, sizeMd, sizeLg, sizeXl, space = 0, status, transitionClassName, transitionDuration, triggerInteraction = types_1.TriggerInteraction.CLICK | types_1.TriggerInteraction.HOVER }, forwardRef) => {
|
|
21
21
|
var _a;
|
|
22
22
|
const theme = react_1.default.useContext(styled_components_1.ThemeContext);
|
|
23
23
|
const triggerEl = react_1.default.useRef(null);
|
|
24
24
|
const boxEl = react_1.default.useRef(null);
|
|
25
25
|
const arrowEl = react_1.default.useRef(null);
|
|
26
|
-
const getTriggerEl = () => { var _a; return ((_a = children[0].ref) !== null && _a !== void 0 ? _a : triggerEl).current; };
|
|
26
|
+
const getTriggerEl = () => { var _a; return ((_a = forwardRef !== null && forwardRef !== void 0 ? forwardRef : children[0].ref) !== null && _a !== void 0 ? _a : triggerEl).current; };
|
|
27
27
|
const getTransitionDuration = () => transitionDuration !== null && transitionDuration !== void 0 ? transitionDuration : theme.$.transition.tooltipDuration;
|
|
28
28
|
const handlePosition = () => (0, popover_1.calculatePosition)(getTriggerEl(), boxEl.current, null, arrowEl.current, position, space);
|
|
29
29
|
const { getStatus, handleBeforeShow, } = (0, useFixedBoxMethods_1.default)({ beforeShow, boxEl, getTriggerEl, handlePosition, hoverDelay, isDismissible, key: 'tooltip', setStatus, status, triggerInteraction });
|
|
@@ -32,7 +32,7 @@ const Tooltip = ({ afterHide, afterShow, beforeHide, beforeShow, children, hasHi
|
|
|
32
32
|
children[1],
|
|
33
33
|
react_1.default.createElement(PopoverArrow_1.default, { ref: arrowEl }))));
|
|
34
34
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
35
|
-
react_1.default.cloneElement(children[0], { ref: (_a = children[0].ref) !== null && _a !== void 0 ? _a : triggerEl }),
|
|
35
|
+
react_1.default.cloneElement(children[0], { ref: (_a = forwardRef !== null && forwardRef !== void 0 ? forwardRef : children[0].ref) !== null && _a !== void 0 ? _a : triggerEl }),
|
|
36
36
|
(0, dom_1.canBeRenderedInPortal)() ? (0, react_dom_1.createPortal)(content, document.body) : content));
|
|
37
|
-
};
|
|
37
|
+
});
|
|
38
38
|
exports.default = Tooltip;
|
|
@@ -45,7 +45,7 @@ exports.default = (0, styled_components_1.default)(Button_1.default).attrs(({ ha
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
`,
|
|
48
|
-
}))(({ theme, hasButtonContainer, hasHover, hasLeftAddon, hasRightAddon, hasSeparatedLeftAddon, hasSeparatedRightAddon, isBlock, isDisabled, isFixedSize, isLink, isLoading, isSoft, isOutline, palette, shape }) => `
|
|
48
|
+
}))(({ theme, hasButtonContainer, hasHover, hasLeftAddon, hasRightAddon, hasSeparatedLeftAddon, hasSeparatedRightAddon, isActive, isBlock, isDisabled, isFixedSize, isLink, isLoading, isSoft, isOutline, palette, shape }) => `
|
|
49
49
|
align-items: stretch;
|
|
50
50
|
background: transparent;
|
|
51
51
|
border: 0;
|
|
@@ -124,12 +124,20 @@ exports.default = (0, styled_components_1.default)(Button_1.default).attrs(({ ha
|
|
|
124
124
|
${!isSoft
|
|
125
125
|
? `
|
|
126
126
|
${ButtonContent_1.default} {
|
|
127
|
-
background: ${theme.$.palette[palette].main};
|
|
128
|
-
border-color: ${theme.$.palette[palette].main};
|
|
129
127
|
color: ${theme.$.palette[palette].font};
|
|
128
|
+
|
|
129
|
+
${!isActive
|
|
130
|
+
? `
|
|
131
|
+
background: ${theme.$.palette[palette].main};
|
|
132
|
+
border-color: ${theme.$.palette[palette].main};
|
|
133
|
+
`
|
|
134
|
+
: `
|
|
135
|
+
background: ${theme.$.palette[palette].dynamicer};
|
|
136
|
+
border-color: ${theme.$.palette[palette].dynamicer};
|
|
137
|
+
`}
|
|
130
138
|
}
|
|
131
139
|
|
|
132
|
-
${hasHover
|
|
140
|
+
${(!isActive && hasHover)
|
|
133
141
|
? `
|
|
134
142
|
&:hover {
|
|
135
143
|
${ButtonContent_1.default} {
|
|
@@ -147,13 +155,20 @@ exports.default = (0, styled_components_1.default)(Button_1.default).attrs(({ ha
|
|
|
147
155
|
`
|
|
148
156
|
: `
|
|
149
157
|
${ButtonContent_1.default} {
|
|
150
|
-
background: ${theme.$.palette[palette].soft};
|
|
151
|
-
border-color: ${theme.$.palette[palette].soft};
|
|
152
158
|
color: ${theme.$.palette[palette].softFont};
|
|
153
|
-
}
|
|
154
159
|
|
|
160
|
+
${!isActive
|
|
161
|
+
? `
|
|
162
|
+
background: ${theme.$.palette[palette].soft};
|
|
163
|
+
border-color: ${theme.$.palette[palette].soft};
|
|
164
|
+
`
|
|
165
|
+
: `
|
|
166
|
+
background: ${theme.$.palette[palette].softDarker};
|
|
167
|
+
border-color: ${theme.$.palette[palette].softDarker};
|
|
168
|
+
`}
|
|
169
|
+
}
|
|
155
170
|
|
|
156
|
-
${hasHover
|
|
171
|
+
${(!isActive && hasHover)
|
|
157
172
|
? `
|
|
158
173
|
&:hover {
|
|
159
174
|
${ButtonContent_1.default} {
|
|
@@ -8,34 +8,22 @@ const ButtonElement_1 = __importDefault(require("./ButtonElement"));
|
|
|
8
8
|
const ButtonAddonElement_1 = __importDefault(require("./ButtonAddonElement"));
|
|
9
9
|
const ButtonContent_1 = __importDefault(require("./ButtonContent"));
|
|
10
10
|
const ButtonListElement_1 = __importDefault(require("./ButtonListElement"));
|
|
11
|
-
exports.default = (0, styled_components_1.default)(ButtonListElement_1.default) `
|
|
11
|
+
exports.default = (0, styled_components_1.default)(ButtonListElement_1.default)(({ theme, shape }) => `
|
|
12
12
|
align-items: stretch;
|
|
13
|
+
border-radius: ${theme.$.radius.button[shape]};
|
|
13
14
|
flex-wrap: nowrap;
|
|
15
|
+
overflow: hidden;
|
|
14
16
|
|
|
15
17
|
> * {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
border-left: 0;
|
|
22
|
-
border-top-left-radius: 0;
|
|
23
|
-
border-bottom-left-radius: 0;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
:not(:last-child) {
|
|
28
|
-
&,
|
|
29
|
-
${ButtonElement_1.default},
|
|
30
|
-
${ButtonAddonElement_1.default},
|
|
31
|
-
${ButtonContent_1.default} {
|
|
32
|
-
border-top-right-radius: 0;
|
|
33
|
-
border-bottom-right-radius: 0;
|
|
34
|
-
}
|
|
18
|
+
&,
|
|
19
|
+
${ButtonElement_1.default},
|
|
20
|
+
${ButtonAddonElement_1.default},
|
|
21
|
+
${ButtonContent_1.default} {
|
|
22
|
+
border-radius: 0;
|
|
35
23
|
}
|
|
36
24
|
|
|
37
25
|
&:focus {
|
|
38
26
|
box-shadow: none;
|
|
39
27
|
}
|
|
40
28
|
}
|
|
41
|
-
|
|
29
|
+
`);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { StyledProps } from '@smart-react-components/core/styled-props';
|
|
2
|
-
import { Partial, ResponsiveProp, SizeProp } from '@smart-react-components/core/types';
|
|
2
|
+
import { Partial, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
|
|
3
3
|
export interface Props extends StyledProps, Partial<ResponsiveProp<'buttonSize', SizeProp>> {
|
|
4
4
|
hasSpace?: boolean;
|
|
5
5
|
isBlock?: boolean;
|
|
6
|
+
isFixedSize?: boolean;
|
|
6
7
|
length?: number;
|
|
8
|
+
shape?: ShapeProp;
|
|
7
9
|
}
|
|
8
10
|
declare const _default: import("styled-components").StyledComponent<"div", any, StyledProps & Props, never>;
|
|
9
11
|
export default _default;
|
package/package.json
CHANGED
package/types/button.d.ts
CHANGED