@fattureincloud/fic-design-system 0.3.16-alpha.0 → 0.3.16
Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,7 @@ export declare type DropdownProps = {
|
|
17
17
|
fullWidth?: boolean;
|
18
18
|
placement?: Placement;
|
19
19
|
minWidthAsTrigger?: boolean;
|
20
|
+
forceOpen?: boolean;
|
20
21
|
alignRight?: boolean;
|
21
22
|
};
|
22
23
|
export declare type DropdownItemType = 'default' | 'danger' | 'success' | 'warning' | 'link';
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { DropdownItemProps } from 'components/dropdown';
|
2
|
-
import { IconProps } from 'components/icon';
|
3
1
|
import { MouseEventHandler } from 'react';
|
2
|
+
import { DropdownItemProps } from '../../dropdown';
|
3
|
+
import { IconProps } from './../../icon';
|
4
4
|
interface Props {
|
5
5
|
icon?: IconProps;
|
6
6
|
title: string;
|
@@ -1,2 +1,5 @@
|
|
1
|
-
|
1
|
+
import { tooltipTypes } from './tooltipPalette';
|
2
|
+
export declare const Arrow: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
3
|
+
type: tooltipTypes;
|
4
|
+
}, never>;
|
2
5
|
export declare const arrowStyle: import("styled-components").FlattenSimpleInterpolation;
|
package/dist/index.esm.js
CHANGED
@@ -1166,22 +1166,25 @@ var DefaultTrigger = function (_a) {
|
|
1166
1166
|
};
|
1167
1167
|
|
1168
1168
|
var DropdownImpl = function (props) {
|
1169
|
-
var alignRight = props.alignRight, className = props.className, content = props.content, fullWidth = props.fullWidth, maxWidth = props.maxWidth, _a = props.minWidthAsTrigger, minWidthAsTrigger = _a === void 0 ? false : _a, placement = props.placement, renderContent = props.renderContent, renderTrigger = props.renderTrigger, triggerStyles = props.triggerStyles, title = props.title;
|
1170
|
-
var
|
1169
|
+
var alignRight = props.alignRight, className = props.className, content = props.content, fullWidth = props.fullWidth, maxWidth = props.maxWidth, _a = props.minWidthAsTrigger, minWidthAsTrigger = _a === void 0 ? false : _a, placement = props.placement, renderContent = props.renderContent, renderTrigger = props.renderTrigger, triggerStyles = props.triggerStyles, title = props.title, _b = props.forceOpen, forceOpen = _b === void 0 ? false : _b;
|
1170
|
+
var _c = useState(false), isOpen = _c[0], setIsOpen = _c[1];
|
1171
1171
|
var toggleDropdown = useCallback(function (e) {
|
1172
1172
|
setIsOpen(function (isOpen) { return !isOpen; });
|
1173
1173
|
e.stopPropagation();
|
1174
1174
|
}, []);
|
1175
1175
|
var closeDropdown = useCallback(function () { return setIsOpen(false); }, []);
|
1176
|
+
useEffect(function () {
|
1177
|
+
setIsOpen(forceOpen);
|
1178
|
+
}, [forceOpen]);
|
1176
1179
|
// Close Dropdown on click outside
|
1177
1180
|
var wrapperRef = useRef(null);
|
1178
1181
|
useClickAway(wrapperRef, function () { return closeDropdown(); });
|
1179
1182
|
var popperRef = useRef(null);
|
1180
1183
|
var buttonRef = useRef(null);
|
1181
|
-
var
|
1184
|
+
var _d = useState(null), arrowRef = _d[0], setArrowRef = _d[1];
|
1182
1185
|
// alignRight left for compatibility
|
1183
1186
|
var popperPlacement = placement ? placement : alignRight ? 'bottom-end' : 'bottom-start';
|
1184
|
-
var
|
1187
|
+
var _e = usePopper(buttonRef.current, popperRef.current, {
|
1185
1188
|
placement: popperPlacement,
|
1186
1189
|
strategy: 'fixed',
|
1187
1190
|
modifiers: useMemo(function () { return [
|
@@ -1214,12 +1217,12 @@ var DropdownImpl = function (props) {
|
|
1214
1217
|
},
|
1215
1218
|
},
|
1216
1219
|
]; }, [minWidthAsTrigger, arrowRef]),
|
1217
|
-
}), attributes =
|
1220
|
+
}), attributes = _e.attributes, styles = _e.styles;
|
1218
1221
|
return (React.createElement(Wrapper$3, { className: className, ref: wrapperRef },
|
1219
1222
|
React.createElement("div", { style: triggerStyles, ref: buttonRef, onClick: toggleDropdown },
|
1220
1223
|
title && React.createElement(DefaultTrigger, { title: title }),
|
1221
1224
|
!title && renderTrigger && renderTrigger()),
|
1222
|
-
React.createElement(CSSTransition, { in: isOpen, timeout: 200, unmountOnExit: true, appear: true },
|
1225
|
+
React.createElement(CSSTransition, { in: forceOpen || isOpen, timeout: 200, unmountOnExit: true, appear: true },
|
1223
1226
|
React.createElement(BodyAnimationWrapper, null,
|
1224
1227
|
React.createElement(PopperContainer, __assign({ ref: popperRef, style: styles.popper }, attributes.popper),
|
1225
1228
|
React.createElement("div", { ref: setArrowRef, style: styles.arrow }),
|
@@ -2002,9 +2005,9 @@ var tagPalette = {
|
|
2002
2005
|
},
|
2003
2006
|
};
|
2004
2007
|
|
2005
|
-
var Arrow = styled.div(templateObject_1$D || (templateObject_1$D = __makeTemplateObject(["\n position: absolute;\n width: 10px;\n height: 10px;\n\n &:after {\n content: '';\n position: absolute;\n transform: rotate(45deg);\n width: 10px;\n height: 10px;\n background-color: ", ";\n box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n }\n"], ["\n position: absolute;\n width: 10px;\n height: 10px;\n\n &:after {\n content: '';\n position: absolute;\n transform: rotate(45deg);\n width: 10px;\n height: 10px;\n background-color: ", ";\n box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n }\n"])), function (_a) {
|
2006
|
-
var theme = _a.theme;
|
2007
|
-
return theme.
|
2008
|
+
var Arrow = styled.div(templateObject_1$D || (templateObject_1$D = __makeTemplateObject(["\n position: absolute;\n width: 10px;\n height: 10px;\n\n &:after {\n content: '';\n position: absolute;\n transform: rotate(45deg);\n width: 10px;\n height: 10px;\n background-color: ", ";\n box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n clip-path: polygon(100% 0, 0% 100%, 100% 100%);\n }\n"], ["\n position: absolute;\n width: 10px;\n height: 10px;\n\n &:after {\n content: '';\n position: absolute;\n transform: rotate(45deg);\n width: 10px;\n height: 10px;\n background-color: ", ";\n box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n clip-path: polygon(100% 0, 0% 100%, 100% 100%);\n }\n"])), function (_a) {
|
2009
|
+
var theme = _a.theme, type = _a.type;
|
2010
|
+
return theme.components.tooltip[type].background;
|
2008
2011
|
});
|
2009
2012
|
var arrowStyle = css(templateObject_2$k || (templateObject_2$k = __makeTemplateObject(["\n &[data-popper-placement^='top'] > ", " {\n bottom: -5px;\n &:after {\n border-bottom-right-radius: 3px;\n }\n }\n\n &[data-popper-placement^='bottom'] > ", " {\n top: -5px;\n &:after {\n border-top-left-radius: 3px;\n }\n }\n\n &[data-popper-placement^='left'] > ", " {\n right: -5px;\n &:after {\n border-top-right-radius: 3px;\n }\n }\n\n &[data-popper-placement^='right'] > ", " {\n left: -5px;\n &:after {\n border-bottom-left-radius: 3px;\n }\n }\n"], ["\n &[data-popper-placement^='top'] > ", " {\n bottom: -5px;\n &:after {\n border-bottom-right-radius: 3px;\n }\n }\n\n &[data-popper-placement^='bottom'] > ", " {\n top: -5px;\n &:after {\n border-top-left-radius: 3px;\n }\n }\n\n &[data-popper-placement^='left'] > ", " {\n right: -5px;\n &:after {\n border-top-right-radius: 3px;\n }\n }\n\n &[data-popper-placement^='right'] > ", " {\n left: -5px;\n &:after {\n border-bottom-left-radius: 3px;\n }\n }\n"])), Arrow, Arrow, Arrow, Arrow);
|
2010
2013
|
var templateObject_1$D, templateObject_2$k;
|
@@ -2065,7 +2068,7 @@ var Tooltip = function (_a) {
|
|
2065
2068
|
React.createElement(CSSTransition, { in: isOpen, timeout: 200, unmountOnExit: true, appear: true },
|
2066
2069
|
React.createElement(BodyAnimationWrapper$1, null,
|
2067
2070
|
React.createElement(TooltipContainer, __assign({ ref: popperRef, style: styles.popper }, attributes.popper),
|
2068
|
-
React.createElement(Arrow, { ref: setArrowRef, style: styles.arrow }),
|
2071
|
+
React.createElement(Arrow, { type: type, ref: setArrowRef, style: styles.arrow }),
|
2069
2072
|
React.createElement(Message, { type: type, style: styles.offset }, message))))));
|
2070
2073
|
};
|
2071
2074
|
var Wrapper$6 = styled.div(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
|
package/dist/index.js
CHANGED
@@ -1174,22 +1174,25 @@ var DefaultTrigger = function (_a) {
|
|
1174
1174
|
};
|
1175
1175
|
|
1176
1176
|
var DropdownImpl = function (props) {
|
1177
|
-
var alignRight = props.alignRight, className = props.className, content = props.content, fullWidth = props.fullWidth, maxWidth = props.maxWidth, _a = props.minWidthAsTrigger, minWidthAsTrigger = _a === void 0 ? false : _a, placement = props.placement, renderContent = props.renderContent, renderTrigger = props.renderTrigger, triggerStyles = props.triggerStyles, title = props.title;
|
1178
|
-
var
|
1177
|
+
var alignRight = props.alignRight, className = props.className, content = props.content, fullWidth = props.fullWidth, maxWidth = props.maxWidth, _a = props.minWidthAsTrigger, minWidthAsTrigger = _a === void 0 ? false : _a, placement = props.placement, renderContent = props.renderContent, renderTrigger = props.renderTrigger, triggerStyles = props.triggerStyles, title = props.title, _b = props.forceOpen, forceOpen = _b === void 0 ? false : _b;
|
1178
|
+
var _c = React.useState(false), isOpen = _c[0], setIsOpen = _c[1];
|
1179
1179
|
var toggleDropdown = React.useCallback(function (e) {
|
1180
1180
|
setIsOpen(function (isOpen) { return !isOpen; });
|
1181
1181
|
e.stopPropagation();
|
1182
1182
|
}, []);
|
1183
1183
|
var closeDropdown = React.useCallback(function () { return setIsOpen(false); }, []);
|
1184
|
+
React.useEffect(function () {
|
1185
|
+
setIsOpen(forceOpen);
|
1186
|
+
}, [forceOpen]);
|
1184
1187
|
// Close Dropdown on click outside
|
1185
1188
|
var wrapperRef = React.useRef(null);
|
1186
1189
|
reactUse.useClickAway(wrapperRef, function () { return closeDropdown(); });
|
1187
1190
|
var popperRef = React.useRef(null);
|
1188
1191
|
var buttonRef = React.useRef(null);
|
1189
|
-
var
|
1192
|
+
var _d = React.useState(null), arrowRef = _d[0], setArrowRef = _d[1];
|
1190
1193
|
// alignRight left for compatibility
|
1191
1194
|
var popperPlacement = placement ? placement : alignRight ? 'bottom-end' : 'bottom-start';
|
1192
|
-
var
|
1195
|
+
var _e = reactPopper.usePopper(buttonRef.current, popperRef.current, {
|
1193
1196
|
placement: popperPlacement,
|
1194
1197
|
strategy: 'fixed',
|
1195
1198
|
modifiers: React.useMemo(function () { return [
|
@@ -1222,12 +1225,12 @@ var DropdownImpl = function (props) {
|
|
1222
1225
|
},
|
1223
1226
|
},
|
1224
1227
|
]; }, [minWidthAsTrigger, arrowRef]),
|
1225
|
-
}), attributes =
|
1228
|
+
}), attributes = _e.attributes, styles = _e.styles;
|
1226
1229
|
return (React__default.createElement(Wrapper$3, { className: className, ref: wrapperRef },
|
1227
1230
|
React__default.createElement("div", { style: triggerStyles, ref: buttonRef, onClick: toggleDropdown },
|
1228
1231
|
title && React__default.createElement(DefaultTrigger, { title: title }),
|
1229
1232
|
!title && renderTrigger && renderTrigger()),
|
1230
|
-
React__default.createElement(reactTransitionGroup.CSSTransition, { in: isOpen, timeout: 200, unmountOnExit: true, appear: true },
|
1233
|
+
React__default.createElement(reactTransitionGroup.CSSTransition, { in: forceOpen || isOpen, timeout: 200, unmountOnExit: true, appear: true },
|
1231
1234
|
React__default.createElement(BodyAnimationWrapper, null,
|
1232
1235
|
React__default.createElement(PopperContainer, __assign({ ref: popperRef, style: styles.popper }, attributes.popper),
|
1233
1236
|
React__default.createElement("div", { ref: setArrowRef, style: styles.arrow }),
|
@@ -2006,9 +2009,9 @@ var tagPalette = {
|
|
2006
2009
|
},
|
2007
2010
|
};
|
2008
2011
|
|
2009
|
-
var Arrow = styled__default.div(templateObject_1$D || (templateObject_1$D = __makeTemplateObject(["\n position: absolute;\n width: 10px;\n height: 10px;\n\n &:after {\n content: '';\n position: absolute;\n transform: rotate(45deg);\n width: 10px;\n height: 10px;\n background-color: ", ";\n box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n }\n"], ["\n position: absolute;\n width: 10px;\n height: 10px;\n\n &:after {\n content: '';\n position: absolute;\n transform: rotate(45deg);\n width: 10px;\n height: 10px;\n background-color: ", ";\n box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n }\n"])), function (_a) {
|
2010
|
-
var theme = _a.theme;
|
2011
|
-
return theme.
|
2012
|
+
var Arrow = styled__default.div(templateObject_1$D || (templateObject_1$D = __makeTemplateObject(["\n position: absolute;\n width: 10px;\n height: 10px;\n\n &:after {\n content: '';\n position: absolute;\n transform: rotate(45deg);\n width: 10px;\n height: 10px;\n background-color: ", ";\n box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n clip-path: polygon(100% 0, 0% 100%, 100% 100%);\n }\n"], ["\n position: absolute;\n width: 10px;\n height: 10px;\n\n &:after {\n content: '';\n position: absolute;\n transform: rotate(45deg);\n width: 10px;\n height: 10px;\n background-color: ", ";\n box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.1);\n clip-path: polygon(100% 0, 0% 100%, 100% 100%);\n }\n"])), function (_a) {
|
2013
|
+
var theme = _a.theme, type = _a.type;
|
2014
|
+
return theme.components.tooltip[type].background;
|
2012
2015
|
});
|
2013
2016
|
var arrowStyle = styled.css(templateObject_2$k || (templateObject_2$k = __makeTemplateObject(["\n &[data-popper-placement^='top'] > ", " {\n bottom: -5px;\n &:after {\n border-bottom-right-radius: 3px;\n }\n }\n\n &[data-popper-placement^='bottom'] > ", " {\n top: -5px;\n &:after {\n border-top-left-radius: 3px;\n }\n }\n\n &[data-popper-placement^='left'] > ", " {\n right: -5px;\n &:after {\n border-top-right-radius: 3px;\n }\n }\n\n &[data-popper-placement^='right'] > ", " {\n left: -5px;\n &:after {\n border-bottom-left-radius: 3px;\n }\n }\n"], ["\n &[data-popper-placement^='top'] > ", " {\n bottom: -5px;\n &:after {\n border-bottom-right-radius: 3px;\n }\n }\n\n &[data-popper-placement^='bottom'] > ", " {\n top: -5px;\n &:after {\n border-top-left-radius: 3px;\n }\n }\n\n &[data-popper-placement^='left'] > ", " {\n right: -5px;\n &:after {\n border-top-right-radius: 3px;\n }\n }\n\n &[data-popper-placement^='right'] > ", " {\n left: -5px;\n &:after {\n border-bottom-left-radius: 3px;\n }\n }\n"])), Arrow, Arrow, Arrow, Arrow);
|
2014
2017
|
var templateObject_1$D, templateObject_2$k;
|
@@ -2069,7 +2072,7 @@ var Tooltip = function (_a) {
|
|
2069
2072
|
React__default.createElement(reactTransitionGroup.CSSTransition, { in: isOpen, timeout: 200, unmountOnExit: true, appear: true },
|
2070
2073
|
React__default.createElement(BodyAnimationWrapper$1, null,
|
2071
2074
|
React__default.createElement(TooltipContainer, __assign({ ref: popperRef, style: styles.popper }, attributes.popper),
|
2072
|
-
React__default.createElement(Arrow, { ref: setArrowRef, style: styles.arrow }),
|
2075
|
+
React__default.createElement(Arrow, { type: type, ref: setArrowRef, style: styles.arrow }),
|
2073
2076
|
React__default.createElement(Message, { type: type, style: styles.offset }, message))))));
|
2074
2077
|
};
|
2075
2078
|
var Wrapper$6 = styled__default.div(templateObject_1$G || (templateObject_1$G = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
|
package/package.json
CHANGED