@smart-react-components/ui 2.0.0-alpha-41 → 2.0.0-alpha-43
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/Input/index.d.ts +2 -1
- package/Input/index.js +2 -1
- package/Tooltip/index.d.ts +1 -1
- package/Tooltip/index.js +4 -4
- package/package.json +1 -1
package/Input/index.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { ChangeEvents } from '@smart-react-components/core/element-props/change-
|
|
|
2
2
|
import { FocusEvents } from '@smart-react-components/core/element-props/focus-events';
|
|
3
3
|
import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
|
|
4
4
|
import { KeyboardEvents } from '@smart-react-components/core/element-props/keyboard-events';
|
|
5
|
-
import { ContentElement, PaletteProp, Partial, ResponsiveProp, SetState, ShapeProp, SizeProp } from '@smart-react-components/core/types';
|
|
5
|
+
import { ContentElement, JSXElementProps, PaletteProp, Partial, ResponsiveProp, SetState, ShapeProp, SizeProp } from '@smart-react-components/core/types';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { InputType } from '../types';
|
|
8
8
|
export interface Props extends Partial<ResponsiveProp<'size', SizeProp>>, IntrinsicStyledProps, ChangeEvents, FocusEvents, KeyboardEvents {
|
|
9
9
|
defaultValue?: string;
|
|
10
10
|
hasBorder?: boolean;
|
|
11
11
|
hasSpellCheck?: boolean;
|
|
12
|
+
inputProps?: JSXElementProps;
|
|
12
13
|
isBlock?: boolean;
|
|
13
14
|
isDisabled?: boolean;
|
|
14
15
|
isOutline?: boolean;
|
package/Input/index.js
CHANGED
|
@@ -52,12 +52,13 @@ const Input = react_1.default.forwardRef((props, forwardRef) => {
|
|
|
52
52
|
((_a = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _a === void 0 ? void 0 : _a.isExcluded) && leftAddon,
|
|
53
53
|
react_1.default.createElement(InputWrapper_1.default, { hasBorder: props.hasBorder, hasExcludedLeftAddon: (_b = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _b === void 0 ? void 0 : _b.isExcluded, hasExcludedRightAddon: (_c = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _c === void 0 ? void 0 : _c.isExcluded, isDisabled: props.isDisabled, isFocused: isFocused, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape },
|
|
54
54
|
(leftAddon && !((_d = leftAddon === null || leftAddon === void 0 ? void 0 : leftAddon.props) === null || _d === void 0 ? void 0 : _d.isExcluded)) && leftAddon,
|
|
55
|
-
react_1.default.cloneElement(props.template, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, element_props_1.default)(props, [change_events_1.default, focus_events_1.default, keyboard_events_1.default])), (typeof props.defaultValue !== 'undefined' && { defaultValue: props.defaultValue })), (typeof props.hasSpellCheck !== 'undefined' && { spellCheck: props.hasSpellCheck })), (props.isDisabled && { disabled: true })), (props.isReadOnly && { readOnly: true })), (props.isRequired && { required: true })), (typeof props.placeholder !== 'undefined' && { placeholder: props.placeholder })), (typeof props.value !== 'undefined' && { value: props.value })), { hasBorder: props.hasBorder, hasLeftAddon: !!leftAddon, hasRightAddon: !!rightAddon, inputSize: props.size, inputSizeSm: props.sizeSm, inputSizeMd: props.sizeMd, inputSizeLg: props.sizeLg, inputSizeXl: props.sizeXl, isDisabled: props.isDisabled, isFocused, isOutline: props.isOutline, isSoft: props.isSoft, onBlur: handleOnBlur, onChange: handleOnChange, onFocus: handleOnFocus, palette: props.palette, ref: forwardRef, shape: props.shape, type: props.type })),
|
|
55
|
+
react_1.default.cloneElement(props.template, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, element_props_1.default)(props, [change_events_1.default, focus_events_1.default, keyboard_events_1.default])), (typeof props.defaultValue !== 'undefined' && { defaultValue: props.defaultValue })), (typeof props.hasSpellCheck !== 'undefined' && { spellCheck: props.hasSpellCheck })), (props.isDisabled && { disabled: true })), (props.isReadOnly && { readOnly: true })), (props.isRequired && { required: true })), (typeof props.placeholder !== 'undefined' && { placeholder: props.placeholder })), (typeof props.value !== 'undefined' && { value: props.value })), props.inputProps), { hasBorder: props.hasBorder, hasLeftAddon: !!leftAddon, hasRightAddon: !!rightAddon, inputSize: props.size, inputSizeSm: props.sizeSm, inputSizeMd: props.sizeMd, inputSizeLg: props.sizeLg, inputSizeXl: props.sizeXl, isDisabled: props.isDisabled, isFocused, isOutline: props.isOutline, isSoft: props.isSoft, onBlur: handleOnBlur, onChange: handleOnChange, onFocus: handleOnFocus, palette: props.palette, ref: forwardRef, shape: props.shape, type: props.type })),
|
|
56
56
|
(rightAddon && !((_e = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _e === void 0 ? void 0 : _e.isExcluded)) && rightAddon),
|
|
57
57
|
((_f = rightAddon === null || rightAddon === void 0 ? void 0 : rightAddon.props) === null || _f === void 0 ? void 0 : _f.isExcluded) && rightAddon)));
|
|
58
58
|
});
|
|
59
59
|
Input.defaultProps = {
|
|
60
60
|
hasBorder: true,
|
|
61
|
+
inputProps: {},
|
|
61
62
|
isBlock: true,
|
|
62
63
|
isOutline: true,
|
|
63
64
|
palette: 'primary',
|
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;
|