@helpdice/ui 2.6.0-beta.8 → 2.6.0
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/dist/container/index.js +796 -7
- package/dist/expandable/index.js +1496 -10
- package/dist/index.js +110 -112
- package/esm/container/box.js +1 -1
- package/esm/expandable/expand.js +1 -1
- package/package.json +1 -1
package/dist/container/index.js
CHANGED
|
@@ -5,13 +5,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var theme = require('@helpdice/theme');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
-
var Expandable = require('components/expandable');
|
|
9
8
|
|
|
10
9
|
function _arrayLikeToArray(r, a) {
|
|
11
10
|
(null == a || a > r.length) && (a = r.length);
|
|
12
11
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
13
12
|
return n;
|
|
14
13
|
}
|
|
14
|
+
function _arrayWithHoles(r) {
|
|
15
|
+
if (Array.isArray(r)) return r;
|
|
16
|
+
}
|
|
15
17
|
function _createForOfIteratorHelper(r, e) {
|
|
16
18
|
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
17
19
|
if (!t) {
|
|
@@ -68,6 +70,36 @@ function _defineProperty(e, r, t) {
|
|
|
68
70
|
writable: true
|
|
69
71
|
}) : e[r] = t, e;
|
|
70
72
|
}
|
|
73
|
+
function _iterableToArrayLimit(r, l) {
|
|
74
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
75
|
+
if (null != t) {
|
|
76
|
+
var e,
|
|
77
|
+
n,
|
|
78
|
+
i,
|
|
79
|
+
u,
|
|
80
|
+
a = [],
|
|
81
|
+
f = true,
|
|
82
|
+
o = false;
|
|
83
|
+
try {
|
|
84
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
85
|
+
if (Object(t) !== t) return;
|
|
86
|
+
f = !1;
|
|
87
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
88
|
+
} catch (r) {
|
|
89
|
+
o = true, n = r;
|
|
90
|
+
} finally {
|
|
91
|
+
try {
|
|
92
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
93
|
+
} finally {
|
|
94
|
+
if (o) throw n;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return a;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function _nonIterableRest() {
|
|
101
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
102
|
+
}
|
|
71
103
|
function ownKeys(e, r) {
|
|
72
104
|
var t = Object.keys(e);
|
|
73
105
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -109,6 +141,9 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
109
141
|
}
|
|
110
142
|
return t;
|
|
111
143
|
}
|
|
144
|
+
function _slicedToArray(r, e) {
|
|
145
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
146
|
+
}
|
|
112
147
|
function _toPrimitive(t, r) {
|
|
113
148
|
if ("object" != typeof t || !t) return t;
|
|
114
149
|
var e = t[Symbol.toPrimitive];
|
|
@@ -680,7 +715,7 @@ var ScalePropKeys = ['width', 'height', 'padding', 'margin', 'w', 'h', 'paddingL
|
|
|
680
715
|
var defaultDynamicLayoutPipe = function defaultDynamicLayoutPipe(scale1x) {
|
|
681
716
|
return "".concat(scale1x);
|
|
682
717
|
};
|
|
683
|
-
var defaultContext = {
|
|
718
|
+
var defaultContext$1 = {
|
|
684
719
|
getScaleProps: function getScaleProps() {
|
|
685
720
|
return undefined;
|
|
686
721
|
},
|
|
@@ -706,7 +741,7 @@ var defaultContext = {
|
|
|
706
741
|
},
|
|
707
742
|
unit: '16px'
|
|
708
743
|
};
|
|
709
|
-
var ScaleContext = /*#__PURE__*/React.createContext(defaultContext);
|
|
744
|
+
var ScaleContext = /*#__PURE__*/React.createContext(defaultContext$1);
|
|
710
745
|
var useScale = function useScale() {
|
|
711
746
|
return React.useContext(ScaleContext);
|
|
712
747
|
};
|
|
@@ -763,7 +798,7 @@ var generateGetAllScaleProps = function generateGetAllScaleProps(props) {
|
|
|
763
798
|
return getAllScaleProps;
|
|
764
799
|
};
|
|
765
800
|
|
|
766
|
-
var _excluded$
|
|
801
|
+
var _excluded$5 = ["children"];
|
|
767
802
|
var reduceScaleCoefficient = function reduceScaleCoefficient(scale) {
|
|
768
803
|
if (scale === 1) return scale;
|
|
769
804
|
var diff = Math.abs((scale - 1) / 2);
|
|
@@ -773,7 +808,7 @@ var withScale = function withScale(Render) {
|
|
|
773
808
|
var ScaleFC = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
774
809
|
var _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref0, _ref1, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26, _ref27, _ref28, _ref29, _ref30, _ref31;
|
|
775
810
|
var children = _ref.children,
|
|
776
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
811
|
+
props = _objectWithoutProperties(_ref, _excluded$5);
|
|
777
812
|
var _useTheme = theme.useTheme(),
|
|
778
813
|
layout = _useTheme.layout;
|
|
779
814
|
var paddingLeft = props.paddingLeft,
|
|
@@ -858,7 +893,7 @@ var withScale = function withScale(Render) {
|
|
|
858
893
|
return ScaleFC;
|
|
859
894
|
};
|
|
860
895
|
|
|
861
|
-
var _excluded$
|
|
896
|
+
var _excluded$4 = ["xs", "sm", "md", "lg", "xl", "justify", "direction", "alignItems", "alignContent", "children", "className"];
|
|
862
897
|
var getItemLayout = function getItemLayout(val) {
|
|
863
898
|
var display = val === 0 ? 'display: none;' : 'display: inherit;';
|
|
864
899
|
if (typeof val === 'number') {
|
|
@@ -896,7 +931,7 @@ var GridBasicItem = function GridBasicItem(_ref) {
|
|
|
896
931
|
children = _ref.children,
|
|
897
932
|
_ref$className = _ref.className,
|
|
898
933
|
className = _ref$className === void 0 ? '' : _ref$className,
|
|
899
|
-
props = _objectWithoutProperties(_ref, _excluded$
|
|
934
|
+
props = _objectWithoutProperties(_ref, _excluded$4);
|
|
900
935
|
var theme$1 = theme.useTheme();
|
|
901
936
|
var _useScale = useScale(),
|
|
902
937
|
SCALES = _useScale.SCALES;
|
|
@@ -953,6 +988,760 @@ tuple('hover', 'click');
|
|
|
953
988
|
tuple('top', 'topStart', 'topEnd', 'left', 'leftStart', 'leftEnd', 'bottom', 'bottomStart', 'bottomEnd', 'right', 'rightStart', 'rightEnd');
|
|
954
989
|
tuple('start', 'center', 'end', 'left', 'right');
|
|
955
990
|
|
|
991
|
+
var ButtonDrip = function ButtonDrip(_ref) {
|
|
992
|
+
var _ref$x = _ref.x,
|
|
993
|
+
x = _ref$x === void 0 ? 0 : _ref$x,
|
|
994
|
+
_ref$y = _ref.y,
|
|
995
|
+
y = _ref$y === void 0 ? 0 : _ref$y,
|
|
996
|
+
color = _ref.color,
|
|
997
|
+
onCompleted = _ref.onCompleted;
|
|
998
|
+
var dripRef = React.useRef(null);
|
|
999
|
+
/* istanbul ignore next */
|
|
1000
|
+
var top = Number.isNaN(+y) ? 0 : y - 10;
|
|
1001
|
+
/* istanbul ignore next */
|
|
1002
|
+
var left = Number.isNaN(+x) ? 0 : x - 10;
|
|
1003
|
+
React.useEffect(function () {
|
|
1004
|
+
/* istanbul ignore next */
|
|
1005
|
+
if (!dripRef.current) return;
|
|
1006
|
+
dripRef.current.addEventListener('animationend', onCompleted);
|
|
1007
|
+
return function () {
|
|
1008
|
+
/* istanbul ignore next */
|
|
1009
|
+
if (!dripRef.current) return;
|
|
1010
|
+
dripRef.current.removeEventListener('animationend', onCompleted);
|
|
1011
|
+
};
|
|
1012
|
+
});
|
|
1013
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1014
|
+
ref: dripRef,
|
|
1015
|
+
className: "jsx-3424889537" + " " + "drip",
|
|
1016
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("svg", {
|
|
1017
|
+
width: "20",
|
|
1018
|
+
height: "20",
|
|
1019
|
+
viewBox: "0 0 20 20",
|
|
1020
|
+
style: {
|
|
1021
|
+
top: top,
|
|
1022
|
+
left: left
|
|
1023
|
+
},
|
|
1024
|
+
className: "jsx-3424889537",
|
|
1025
|
+
children: /*#__PURE__*/jsxRuntime.jsx("g", {
|
|
1026
|
+
stroke: "none",
|
|
1027
|
+
strokeWidth: "1",
|
|
1028
|
+
fill: "none",
|
|
1029
|
+
fillRule: "evenodd",
|
|
1030
|
+
className: "jsx-3424889537",
|
|
1031
|
+
children: /*#__PURE__*/jsxRuntime.jsx("g", {
|
|
1032
|
+
fill: color,
|
|
1033
|
+
className: "jsx-3424889537",
|
|
1034
|
+
children: /*#__PURE__*/jsxRuntime.jsx("rect", {
|
|
1035
|
+
width: "100%",
|
|
1036
|
+
height: "100%",
|
|
1037
|
+
rx: "10",
|
|
1038
|
+
className: "jsx-3424889537"
|
|
1039
|
+
})
|
|
1040
|
+
})
|
|
1041
|
+
})
|
|
1042
|
+
}), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
|
|
1043
|
+
id: "3424889537",
|
|
1044
|
+
children: ".drip.jsx-3424889537{position:absolute;left:0;right:0;top:0;bottom:0;}svg.jsx-3424889537{position:absolute;-webkit-animation:350ms ease-in expand-jsx-3424889537;animation:350ms ease-in expand-jsx-3424889537;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;width:1rem;height:1rem;}@-webkit-keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}@keyframes expand-jsx-3424889537{0%{opacity:0;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1);}30%{opacity:1;}80%{opacity:0.5;}100%{-webkit-transform:scale(28);-ms-transform:scale(28);transform:scale(28);opacity:0;}}"
|
|
1045
|
+
})]
|
|
1046
|
+
});
|
|
1047
|
+
};
|
|
1048
|
+
ButtonDrip.displayName = 'ButtonDrip';
|
|
1049
|
+
|
|
1050
|
+
var _excluded$3 = ["children", "type", "color", "className", "spaceRatio"];
|
|
1051
|
+
var getIconBgColor = function getIconBgColor(type, palette, color) {
|
|
1052
|
+
var colors = {
|
|
1053
|
+
"default": palette.accents_6,
|
|
1054
|
+
secondary: palette.secondary,
|
|
1055
|
+
success: palette.success,
|
|
1056
|
+
warning: palette.warning,
|
|
1057
|
+
error: palette.error
|
|
1058
|
+
};
|
|
1059
|
+
return color ? color : colors[type];
|
|
1060
|
+
};
|
|
1061
|
+
var LoadingComponent = function LoadingComponent(_ref) {
|
|
1062
|
+
var children = _ref.children,
|
|
1063
|
+
_ref$type = _ref.type,
|
|
1064
|
+
type = _ref$type === void 0 ? 'default' : _ref$type,
|
|
1065
|
+
color = _ref.color,
|
|
1066
|
+
_ref$className = _ref.className,
|
|
1067
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1068
|
+
_ref$spaceRatio = _ref.spaceRatio,
|
|
1069
|
+
spaceRatio = _ref$spaceRatio === void 0 ? 1 : _ref$spaceRatio,
|
|
1070
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
1071
|
+
var theme$1 = theme.useTheme();
|
|
1072
|
+
var _useScale = useScale(),
|
|
1073
|
+
SCALES = _useScale.SCALES;
|
|
1074
|
+
var classes = theme.useClasses('loading-container', className);
|
|
1075
|
+
var bgColor = React.useMemo(function () {
|
|
1076
|
+
return getIconBgColor(type, theme$1.palette, color);
|
|
1077
|
+
}, [type, theme$1.palette, color]);
|
|
1078
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread2(_objectSpread2({}, props), {}, {
|
|
1079
|
+
className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]]) + " " + (props && props.className != null && props.className || classes || ""),
|
|
1080
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
1081
|
+
className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]]) + " " + "loading",
|
|
1082
|
+
children: [children && /*#__PURE__*/jsxRuntime.jsx("label", {
|
|
1083
|
+
className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]]),
|
|
1084
|
+
children: children
|
|
1085
|
+
}), /*#__PURE__*/jsxRuntime.jsx("i", {
|
|
1086
|
+
className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
|
|
1087
|
+
}), /*#__PURE__*/jsxRuntime.jsx("i", {
|
|
1088
|
+
className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
|
|
1089
|
+
}), /*#__PURE__*/jsxRuntime.jsx("i", {
|
|
1090
|
+
className: _JSXStyle.dynamic([["2201634259", [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio]]])
|
|
1091
|
+
})]
|
|
1092
|
+
}), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
|
|
1093
|
+
id: "2201634259",
|
|
1094
|
+
dynamic: [SCALES.font(1), SCALES.width(1, '100%'), SCALES.height(1, '100%'), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), theme$1.palette.accents_5, bgColor, spaceRatio],
|
|
1095
|
+
children: ".loading-container.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:relative;font-size:".concat(SCALES.font(1), ";width:").concat(SCALES.width(1, '100%'), ";height:").concat(SCALES.height(1, '100%'), ";min-height:1em;padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}label.__jsx-style-dynamic-selector{margin-right:0.5em;color:").concat(theme$1.palette.accents_5, ";line-height:1;}label.__jsx-style-dynamic-selector *{margin:0;}.loading.__jsx-style-dynamic-selector{position:absolute;top:50%;left:50%;width:100%;height:100%;-webkit-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);transform:translate(-50%,-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background-color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}i.__jsx-style-dynamic-selector{width:0.25em;height:0.25em;border-radius:50%;background-color:").concat(bgColor, ";margin:0 calc(0.25em / 2 * ").concat(spaceRatio, ");display:inline-block;-webkit-animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;animation:loading-blink-__jsx-style-dynamic-selector 1.4s infinite both;}i.__jsx-style-dynamic-selector:nth-child(2){-webkit-animation-delay:0.2s;animation-delay:0.2s;}i.__jsx-style-dynamic-selector:nth-child(3){-webkit-animation-delay:0.4s;animation-delay:0.4s;}@-webkit-keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}@keyframes loading-blink-__jsx-style-dynamic-selector{0%{opacity:0.2;}20%{opacity:1;}100%{opacity:0.2;}}")
|
|
1096
|
+
})]
|
|
1097
|
+
}));
|
|
1098
|
+
};
|
|
1099
|
+
LoadingComponent.displayName = 'Loading';
|
|
1100
|
+
var Loading = withScale(LoadingComponent);
|
|
1101
|
+
|
|
1102
|
+
var ButtonLoading = function ButtonLoading(_ref) {
|
|
1103
|
+
var color = _ref.color;
|
|
1104
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1105
|
+
className: "jsx-212623367" + " " + "btn-loading",
|
|
1106
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Loading, {
|
|
1107
|
+
color: color
|
|
1108
|
+
}), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
|
|
1109
|
+
id: "212623367",
|
|
1110
|
+
children: ".btn-loading.jsx-212623367{position:absolute;top:0;left:0;right:0;bottom:0;z-index:2;background-color:var(--helpdice-ui-button-bg);}"
|
|
1111
|
+
})]
|
|
1112
|
+
});
|
|
1113
|
+
};
|
|
1114
|
+
ButtonLoading.displayName = 'ButtonLoading';
|
|
1115
|
+
|
|
1116
|
+
var _excluded$2 = ["isRight", "isSingle", "children", "className"];
|
|
1117
|
+
var ButtonIcon = function ButtonIcon(_ref) {
|
|
1118
|
+
var _ref$isRight = _ref.isRight,
|
|
1119
|
+
isRight = _ref$isRight === void 0 ? false : _ref$isRight,
|
|
1120
|
+
isSingle = _ref.isSingle,
|
|
1121
|
+
children = _ref.children,
|
|
1122
|
+
_ref$className = _ref.className,
|
|
1123
|
+
className = _ref$className === void 0 ? '' : _ref$className,
|
|
1124
|
+
props = _objectWithoutProperties(_ref, _excluded$2);
|
|
1125
|
+
var classes = theme.useClasses('icon', {
|
|
1126
|
+
right: isRight,
|
|
1127
|
+
single: isSingle
|
|
1128
|
+
}, className);
|
|
1129
|
+
return /*#__PURE__*/jsxRuntime.jsxs("span", _objectSpread2(_objectSpread2({}, props), {}, {
|
|
1130
|
+
className: "jsx-2467502931" + " " + (props && props.className != null && props.className || classes || ""),
|
|
1131
|
+
children: [children, /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
|
|
1132
|
+
id: "2467502931",
|
|
1133
|
+
children: ".icon.jsx-2467502931{position:absolute;left:var(--helpdice-ui-button-icon-padding);right:auto;top:50%;-webkit-transform:translateY(-50%);-ms-transform:translateY(-50%);transform:translateY(-50%);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;color:var(--helpdice-ui-button-color);z-index:1;}.right.jsx-2467502931{right:var(--helpdice-ui-button-icon-padding);left:auto;}.icon.jsx-2467502931 svg{background:transparent;height:calc(var(--helpdice-ui-button-height) / 2.35);width:calc(var(--helpdice-ui-button-height) / 2.35);}.single.jsx-2467502931{position:static;-webkit-transform:none;-ms-transform:none;transform:none;}"
|
|
1134
|
+
})]
|
|
1135
|
+
}));
|
|
1136
|
+
};
|
|
1137
|
+
ButtonIcon.displayName = 'ButtonIcon';
|
|
1138
|
+
|
|
1139
|
+
var getButtonChildrenWithIcon = function getButtonChildrenWithIcon(auto, children, icons) {
|
|
1140
|
+
var icon = icons.icon,
|
|
1141
|
+
iconRight = icons.iconRight;
|
|
1142
|
+
var hasIcon = icon || iconRight;
|
|
1143
|
+
var isRight = Boolean(iconRight);
|
|
1144
|
+
var paddingForAutoMode = auto ? "calc(var(--helpdice-ui-button-height) / 2 + var(--helpdice-ui-button-icon-padding) * .5)" : 0;
|
|
1145
|
+
var classes = theme.useClasses('text', isRight ? 'right' : 'left');
|
|
1146
|
+
if (!hasIcon) return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1147
|
+
className: "text",
|
|
1148
|
+
children: children
|
|
1149
|
+
});
|
|
1150
|
+
if (React.Children.count(children) === 0) {
|
|
1151
|
+
return /*#__PURE__*/jsxRuntime.jsx(ButtonIcon, {
|
|
1152
|
+
isRight: isRight,
|
|
1153
|
+
isSingle: true,
|
|
1154
|
+
children: hasIcon
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1158
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(ButtonIcon, {
|
|
1159
|
+
isRight: isRight,
|
|
1160
|
+
children: hasIcon
|
|
1161
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1162
|
+
className: _JSXStyle.dynamic([["3568181479", [paddingForAutoMode, paddingForAutoMode]]]) + " " + (classes || ""),
|
|
1163
|
+
children: [children, /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
|
|
1164
|
+
id: "3568181479",
|
|
1165
|
+
dynamic: [paddingForAutoMode, paddingForAutoMode],
|
|
1166
|
+
children: ".left.__jsx-style-dynamic-selector{padding-left:".concat(paddingForAutoMode, ";}.right.__jsx-style-dynamic-selector{padding-right:").concat(paddingForAutoMode, ";}")
|
|
1167
|
+
})]
|
|
1168
|
+
})]
|
|
1169
|
+
});
|
|
1170
|
+
};
|
|
1171
|
+
var filterPropsWithGroup = function filterPropsWithGroup(props, config) {
|
|
1172
|
+
if (!config.isButtonGroup) return props;
|
|
1173
|
+
return _objectSpread2(_objectSpread2({}, props), {}, {
|
|
1174
|
+
auto: true,
|
|
1175
|
+
shadow: false,
|
|
1176
|
+
ghost: config.ghost || props.ghost,
|
|
1177
|
+
type: config.type || props.type,
|
|
1178
|
+
disabled: config.disabled || props.disabled
|
|
1179
|
+
});
|
|
1180
|
+
};
|
|
1181
|
+
|
|
1182
|
+
/* "use client" */
|
|
1183
|
+
|
|
1184
|
+
var defaultContext = {
|
|
1185
|
+
isButtonGroup: false,
|
|
1186
|
+
disabled: false
|
|
1187
|
+
};
|
|
1188
|
+
var ButtonGroupContext = /*#__PURE__*/React.createContext(defaultContext);
|
|
1189
|
+
var useButtonGroupContext = function useButtonGroupContext() {
|
|
1190
|
+
return React.useContext(ButtonGroupContext);
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
var hexToRgb = function hexToRgb(color) {
|
|
1194
|
+
var fullReg = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
1195
|
+
var full = color.replace(fullReg, function (_, r, g, b) {
|
|
1196
|
+
return "".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b);
|
|
1197
|
+
});
|
|
1198
|
+
var values = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(full);
|
|
1199
|
+
if (!values) {
|
|
1200
|
+
throw new Error("Helpdice UI: Unsupported ".concat(color, " color."));
|
|
1201
|
+
}
|
|
1202
|
+
return [Number.parseInt(values[1], 16), Number.parseInt(values[2], 16), Number.parseInt(values[3], 16)];
|
|
1203
|
+
};
|
|
1204
|
+
var colorToRgbValues = function colorToRgbValues(color) {
|
|
1205
|
+
if (color.charAt(0) === '#') return hexToRgb(color);
|
|
1206
|
+
var safeColor = color.replace(/ /g, '');
|
|
1207
|
+
var colorType = color.substr(0, 4);
|
|
1208
|
+
var regArray = safeColor.match(/\((.+)\)/);
|
|
1209
|
+
if (!colorType.startsWith('rgb') || !regArray) {
|
|
1210
|
+
console.log(color);
|
|
1211
|
+
throw new Error("Helpdice UI: Only support [\"RGB\", \"RGBA\", \"HEX\"] color.");
|
|
1212
|
+
}
|
|
1213
|
+
return regArray[1].split(',').map(function (str) {
|
|
1214
|
+
return Number.parseFloat(str);
|
|
1215
|
+
});
|
|
1216
|
+
};
|
|
1217
|
+
var addColorAlpha = function addColorAlpha(color, alpha) {
|
|
1218
|
+
if (!/^#|rgb|RGB/.test(color)) return color;
|
|
1219
|
+
var _colorToRgbValues = colorToRgbValues(color),
|
|
1220
|
+
_colorToRgbValues2 = _slicedToArray(_colorToRgbValues, 3),
|
|
1221
|
+
r = _colorToRgbValues2[0],
|
|
1222
|
+
g = _colorToRgbValues2[1],
|
|
1223
|
+
b = _colorToRgbValues2[2];
|
|
1224
|
+
var safeAlpha = alpha > 1 ? 1 : alpha < 0 ? 0 : alpha;
|
|
1225
|
+
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(safeAlpha, ")");
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
var getButtonGhostColors = function getButtonGhostColors(palette, _color) {
|
|
1229
|
+
var colors = {
|
|
1230
|
+
secondary: {
|
|
1231
|
+
bg: palette.background,
|
|
1232
|
+
border: palette.foreground,
|
|
1233
|
+
color: palette.foreground,
|
|
1234
|
+
ripple: ''
|
|
1235
|
+
},
|
|
1236
|
+
success: {
|
|
1237
|
+
bg: palette.background,
|
|
1238
|
+
border: palette.success,
|
|
1239
|
+
color: palette.success,
|
|
1240
|
+
ripple: ''
|
|
1241
|
+
},
|
|
1242
|
+
warning: {
|
|
1243
|
+
bg: palette.background,
|
|
1244
|
+
border: palette.warning,
|
|
1245
|
+
color: palette.warning,
|
|
1246
|
+
ripple: ''
|
|
1247
|
+
},
|
|
1248
|
+
error: {
|
|
1249
|
+
bg: palette.background,
|
|
1250
|
+
border: palette.error,
|
|
1251
|
+
color: palette.error,
|
|
1252
|
+
ripple: ''
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
return colors[_color] || null;
|
|
1256
|
+
};
|
|
1257
|
+
var getButtonColors = function getButtonColors(palette, props) {
|
|
1258
|
+
var color = props.color,
|
|
1259
|
+
disabled = props.disabled,
|
|
1260
|
+
ghost = props.ghost;
|
|
1261
|
+
var colors = {
|
|
1262
|
+
"default": {
|
|
1263
|
+
bg: palette.background,
|
|
1264
|
+
border: palette.border,
|
|
1265
|
+
color: palette.accents_5,
|
|
1266
|
+
ripple: palette.accents_1
|
|
1267
|
+
},
|
|
1268
|
+
secondary: {
|
|
1269
|
+
bg: palette.foreground,
|
|
1270
|
+
border: palette.foreground,
|
|
1271
|
+
color: palette.background,
|
|
1272
|
+
ripple: palette.accents_1
|
|
1273
|
+
},
|
|
1274
|
+
success: {
|
|
1275
|
+
bg: palette.success,
|
|
1276
|
+
border: palette.success,
|
|
1277
|
+
color: '#fff',
|
|
1278
|
+
ripple: '#1f93ffff'
|
|
1279
|
+
},
|
|
1280
|
+
warning: {
|
|
1281
|
+
bg: palette.warning,
|
|
1282
|
+
border: palette.warning,
|
|
1283
|
+
color: '#fff',
|
|
1284
|
+
ripple: '#ffca29ff'
|
|
1285
|
+
},
|
|
1286
|
+
error: {
|
|
1287
|
+
bg: palette.error,
|
|
1288
|
+
border: palette.error,
|
|
1289
|
+
color: '#fff',
|
|
1290
|
+
ripple: '#ff5a55ff'
|
|
1291
|
+
},
|
|
1292
|
+
abort: {
|
|
1293
|
+
bg: 'transparent',
|
|
1294
|
+
border: 'transparent',
|
|
1295
|
+
color: palette.accents_5,
|
|
1296
|
+
ripple: palette.accents_1
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
if (disabled) return {
|
|
1300
|
+
bg: palette.accents_1,
|
|
1301
|
+
border: palette.accents_2,
|
|
1302
|
+
color: '#ccc',
|
|
1303
|
+
ripple: ''
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* The '-light' type is the same color as the common type,
|
|
1308
|
+
* only hover's color is different.
|
|
1309
|
+
* e.g.
|
|
1310
|
+
* Color['success'] === Color['success-light']
|
|
1311
|
+
* Color['warning'] === Color['warning-light']
|
|
1312
|
+
*/
|
|
1313
|
+
var withoutLightType = color === null || color === void 0 ? void 0 : color.replace('-light', '');
|
|
1314
|
+
var defaultColor = colors["default"];
|
|
1315
|
+
if (ghost) return getButtonGhostColors(palette, withoutLightType) || defaultColor;
|
|
1316
|
+
return colors[withoutLightType] || defaultColor;
|
|
1317
|
+
};
|
|
1318
|
+
var getButtonGhostHoverColors = function getButtonGhostHoverColors(palette, _color) {
|
|
1319
|
+
var colors = {
|
|
1320
|
+
secondary: {
|
|
1321
|
+
bg: palette.foreground,
|
|
1322
|
+
border: palette.background,
|
|
1323
|
+
color: palette.background
|
|
1324
|
+
},
|
|
1325
|
+
success: {
|
|
1326
|
+
bg: palette.success,
|
|
1327
|
+
border: palette.background,
|
|
1328
|
+
color: 'white'
|
|
1329
|
+
},
|
|
1330
|
+
warning: {
|
|
1331
|
+
bg: palette.warning,
|
|
1332
|
+
border: palette.background,
|
|
1333
|
+
color: 'white'
|
|
1334
|
+
},
|
|
1335
|
+
error: {
|
|
1336
|
+
bg: palette.error,
|
|
1337
|
+
border: palette.background,
|
|
1338
|
+
color: 'white'
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
var withoutLightType = _color === null || _color === void 0 ? void 0 : _color.replace('-light', '');
|
|
1342
|
+
return colors[withoutLightType] || null;
|
|
1343
|
+
};
|
|
1344
|
+
var getButtonHoverColors = function getButtonHoverColors(palette, props) {
|
|
1345
|
+
var color = props.color,
|
|
1346
|
+
disabled = props.disabled,
|
|
1347
|
+
loading = props.loading,
|
|
1348
|
+
shadow = props.shadow,
|
|
1349
|
+
ghost = props.ghost;
|
|
1350
|
+
var defaultColor = getButtonColors(palette, props);
|
|
1351
|
+
var alphaBackground = addColorAlpha(defaultColor.bg, 0.85);
|
|
1352
|
+
var colors = {
|
|
1353
|
+
"default": {
|
|
1354
|
+
bg: palette.background,
|
|
1355
|
+
border: palette.foreground
|
|
1356
|
+
},
|
|
1357
|
+
secondary: {
|
|
1358
|
+
bg: palette.background,
|
|
1359
|
+
border: palette.foreground
|
|
1360
|
+
},
|
|
1361
|
+
success: {
|
|
1362
|
+
bg: palette.background,
|
|
1363
|
+
border: palette.success
|
|
1364
|
+
},
|
|
1365
|
+
warning: {
|
|
1366
|
+
bg: palette.background,
|
|
1367
|
+
border: palette.warning
|
|
1368
|
+
},
|
|
1369
|
+
error: {
|
|
1370
|
+
bg: palette.background,
|
|
1371
|
+
border: palette.error
|
|
1372
|
+
},
|
|
1373
|
+
abort: {
|
|
1374
|
+
bg: 'transparent',
|
|
1375
|
+
border: 'transparent',
|
|
1376
|
+
color: palette.accents_5
|
|
1377
|
+
},
|
|
1378
|
+
'secondary-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
|
|
1379
|
+
bg: alphaBackground
|
|
1380
|
+
}),
|
|
1381
|
+
'success-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
|
|
1382
|
+
bg: alphaBackground
|
|
1383
|
+
}),
|
|
1384
|
+
'warning-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
|
|
1385
|
+
bg: alphaBackground
|
|
1386
|
+
}),
|
|
1387
|
+
'error-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
|
|
1388
|
+
bg: alphaBackground
|
|
1389
|
+
})
|
|
1390
|
+
};
|
|
1391
|
+
if (disabled) return {
|
|
1392
|
+
bg: palette.accents_1,
|
|
1393
|
+
border: palette.accents_2,
|
|
1394
|
+
color: '#ccc'
|
|
1395
|
+
};
|
|
1396
|
+
if (loading) return _objectSpread2(_objectSpread2({}, defaultColor), {}, {
|
|
1397
|
+
color: 'transparent'
|
|
1398
|
+
});
|
|
1399
|
+
if (shadow) return defaultColor;
|
|
1400
|
+
var hoverColor = (ghost ? getButtonGhostHoverColors(palette, color) : colors[color]) || colors["default"];
|
|
1401
|
+
return _objectSpread2(_objectSpread2({}, hoverColor), {}, {
|
|
1402
|
+
color: hoverColor.color || hoverColor.border
|
|
1403
|
+
});
|
|
1404
|
+
};
|
|
1405
|
+
var getButtonCursor = function getButtonCursor(disabled, loading) {
|
|
1406
|
+
if (disabled) return {
|
|
1407
|
+
cursor: 'not-allowed',
|
|
1408
|
+
events: 'auto'
|
|
1409
|
+
};
|
|
1410
|
+
if (loading) return {
|
|
1411
|
+
cursor: 'default',
|
|
1412
|
+
events: 'none'
|
|
1413
|
+
};
|
|
1414
|
+
return {
|
|
1415
|
+
cursor: 'pointer',
|
|
1416
|
+
events: 'auto'
|
|
1417
|
+
};
|
|
1418
|
+
};
|
|
1419
|
+
var getButtonDripColor = function getButtonDripColor(palette, props) {
|
|
1420
|
+
var type = props.type;
|
|
1421
|
+
var isLightHover = type ? type.endsWith('light') : false;
|
|
1422
|
+
var hoverColors = getButtonHoverColors(palette, props);
|
|
1423
|
+
return isLightHover ? addColorAlpha(hoverColors.bg, 0.65) : addColorAlpha(palette.accents_2, 0.65);
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1426
|
+
var _excluded$1 = ["children", "disabled", "color", "loading", "shadow", "ghost", "effect", "round", "relative", "replace", "a", "to", "onClick", "auto", "icon", "type", "iconRight", "className", "crossOrigin"];
|
|
1427
|
+
var ButtonComponent = /*#__PURE__*/React.forwardRef(function (btnProps, ref) {
|
|
1428
|
+
var theme$1 = theme.useTheme();
|
|
1429
|
+
// const navigate = useNavigate();
|
|
1430
|
+
var _useScale = useScale(),
|
|
1431
|
+
SCALES = _useScale.SCALES;
|
|
1432
|
+
var buttonRef = React.useRef(null);
|
|
1433
|
+
React.useImperativeHandle(ref, function () {
|
|
1434
|
+
return buttonRef.current;
|
|
1435
|
+
}); // Changed with !
|
|
1436
|
+
|
|
1437
|
+
var _useState = React.useState(false),
|
|
1438
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1439
|
+
dripShow = _useState2[0],
|
|
1440
|
+
setDripShow = _useState2[1];
|
|
1441
|
+
var _useState3 = React.useState(0),
|
|
1442
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1443
|
+
dripX = _useState4[0],
|
|
1444
|
+
setDripX = _useState4[1];
|
|
1445
|
+
var _useState5 = React.useState(0),
|
|
1446
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1447
|
+
dripY = _useState6[0],
|
|
1448
|
+
setDripY = _useState6[1];
|
|
1449
|
+
var groupConfig = useButtonGroupContext();
|
|
1450
|
+
var filteredProps = filterPropsWithGroup(btnProps, groupConfig);
|
|
1451
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1452
|
+
var children = filteredProps.children,
|
|
1453
|
+
_filteredProps$disabl = filteredProps.disabled,
|
|
1454
|
+
disabled = _filteredProps$disabl === void 0 ? false : _filteredProps$disabl;
|
|
1455
|
+
filteredProps.color;
|
|
1456
|
+
var _filteredProps$loadin = filteredProps.loading,
|
|
1457
|
+
loading = _filteredProps$loadin === void 0 ? false : _filteredProps$loadin,
|
|
1458
|
+
_filteredProps$shadow = filteredProps.shadow,
|
|
1459
|
+
shadow = _filteredProps$shadow === void 0 ? false : _filteredProps$shadow,
|
|
1460
|
+
_filteredProps$ghost = filteredProps.ghost,
|
|
1461
|
+
ghost = _filteredProps$ghost === void 0 ? false : _filteredProps$ghost,
|
|
1462
|
+
_filteredProps$effect = filteredProps.effect,
|
|
1463
|
+
effect = _filteredProps$effect === void 0 ? true : _filteredProps$effect,
|
|
1464
|
+
_filteredProps$round = filteredProps.round,
|
|
1465
|
+
round = _filteredProps$round === void 0 ? false : _filteredProps$round;
|
|
1466
|
+
filteredProps.relative;
|
|
1467
|
+
filteredProps.replace;
|
|
1468
|
+
filteredProps.a;
|
|
1469
|
+
var to = filteredProps.to,
|
|
1470
|
+
onClick = filteredProps.onClick,
|
|
1471
|
+
_filteredProps$auto = filteredProps.auto,
|
|
1472
|
+
auto = _filteredProps$auto === void 0 ? false : _filteredProps$auto,
|
|
1473
|
+
icon = filteredProps.icon,
|
|
1474
|
+
_filteredProps$type = filteredProps.type,
|
|
1475
|
+
type = _filteredProps$type === void 0 ? 'button' : _filteredProps$type,
|
|
1476
|
+
iconRight = filteredProps.iconRight,
|
|
1477
|
+
_filteredProps$classN = filteredProps.className,
|
|
1478
|
+
className = _filteredProps$classN === void 0 ? '' : _filteredProps$classN;
|
|
1479
|
+
filteredProps.crossOrigin;
|
|
1480
|
+
var props = _objectWithoutProperties(filteredProps, _excluded$1);
|
|
1481
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
1482
|
+
|
|
1483
|
+
var _useMemo = React.useMemo(function () {
|
|
1484
|
+
return getButtonColors(theme$1.palette, filteredProps);
|
|
1485
|
+
}, [theme$1.palette, filteredProps]),
|
|
1486
|
+
bg = _useMemo.bg,
|
|
1487
|
+
border = _useMemo.border,
|
|
1488
|
+
color = _useMemo.color,
|
|
1489
|
+
rippleColor = _useMemo.ripple;
|
|
1490
|
+
var hover = React.useMemo(function () {
|
|
1491
|
+
return getButtonHoverColors(theme$1.palette, filteredProps);
|
|
1492
|
+
}, [theme$1.palette, filteredProps]);
|
|
1493
|
+
var _useMemo2 = React.useMemo(function () {
|
|
1494
|
+
return getButtonCursor(disabled, loading);
|
|
1495
|
+
}, [disabled, loading]),
|
|
1496
|
+
cursor = _useMemo2.cursor,
|
|
1497
|
+
events = _useMemo2.events;
|
|
1498
|
+
var dripColor = React.useMemo(function () {
|
|
1499
|
+
return getButtonDripColor(theme$1.palette, filteredProps);
|
|
1500
|
+
}, [theme$1.palette, filteredProps]);
|
|
1501
|
+
|
|
1502
|
+
/* istanbul ignore next */
|
|
1503
|
+
var dripCompletedHandle = function dripCompletedHandle() {
|
|
1504
|
+
setDripShow(false);
|
|
1505
|
+
setDripX(0);
|
|
1506
|
+
setDripY(0);
|
|
1507
|
+
};
|
|
1508
|
+
var createRipple = function createRipple(event) {
|
|
1509
|
+
var button = buttonRef.current;
|
|
1510
|
+
if (!button) return;
|
|
1511
|
+
var rect = button.getBoundingClientRect();
|
|
1512
|
+
var size = Math.max(rect.width, rect.height);
|
|
1513
|
+
var x = event.clientX - rect.left - size / 2;
|
|
1514
|
+
var y = event.clientY - rect.top - size / 2;
|
|
1515
|
+
var rippleCount = 1; // number of rings
|
|
1516
|
+
var rippleDelay = 500; // ms between each ripple
|
|
1517
|
+
var _loop = function _loop() {
|
|
1518
|
+
var ripple = document.createElement('span');
|
|
1519
|
+
Object.assign(ripple.style, {
|
|
1520
|
+
position: 'absolute',
|
|
1521
|
+
borderRadius: '50%',
|
|
1522
|
+
backgroundColor: rippleColor,
|
|
1523
|
+
width: "".concat(size, "px"),
|
|
1524
|
+
height: "".concat(size, "px"),
|
|
1525
|
+
left: "".concat(x, "px"),
|
|
1526
|
+
top: "".concat(y, "px"),
|
|
1527
|
+
pointerEvents: 'none',
|
|
1528
|
+
transform: 'scale(0)',
|
|
1529
|
+
opacity: '1',
|
|
1530
|
+
transition: "transform 600ms ease-out ".concat(i * rippleDelay, "ms, opacity 600ms ease-out ").concat(i * rippleDelay, "ms"),
|
|
1531
|
+
zIndex: 1
|
|
1532
|
+
});
|
|
1533
|
+
button.appendChild(ripple);
|
|
1534
|
+
|
|
1535
|
+
// Force reflow to start transition
|
|
1536
|
+
window.getComputedStyle(ripple).opacity;
|
|
1537
|
+
ripple.style.transform = 'scale(2.5)';
|
|
1538
|
+
ripple.style.opacity = '0';
|
|
1539
|
+
ripple.addEventListener('transitionend', function () {
|
|
1540
|
+
ripple.remove();
|
|
1541
|
+
});
|
|
1542
|
+
};
|
|
1543
|
+
for (var i = 0; i < rippleCount; i++) {
|
|
1544
|
+
_loop();
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
var clickHandler = function clickHandler(event) {
|
|
1548
|
+
if (disabled || loading) return;
|
|
1549
|
+
var showDrip = !shadow && !ghost && effect;
|
|
1550
|
+
/* istanbul ignore next */
|
|
1551
|
+
if (showDrip && buttonRef.current) {
|
|
1552
|
+
var rect = buttonRef.current.getBoundingClientRect();
|
|
1553
|
+
setDripShow(true);
|
|
1554
|
+
setDripX(event.clientX - rect.left);
|
|
1555
|
+
setDripY(event.clientY - rect.top);
|
|
1556
|
+
}
|
|
1557
|
+
if (shadow) {
|
|
1558
|
+
createRipple(event);
|
|
1559
|
+
}
|
|
1560
|
+
onClick && onClick(event);
|
|
1561
|
+
};
|
|
1562
|
+
var childrenWithIcon = React.useMemo(function () {
|
|
1563
|
+
return getButtonChildrenWithIcon(auto, children, {
|
|
1564
|
+
icon: icon,
|
|
1565
|
+
iconRight: iconRight
|
|
1566
|
+
});
|
|
1567
|
+
}, [auto, children, icon, iconRight]);
|
|
1568
|
+
var paddingLeft = auto ? SCALES.pl(1.15) : SCALES.pl(1.375),
|
|
1569
|
+
paddingRight = auto ? SCALES.pr(1.15) : SCALES.pr(1.375);
|
|
1570
|
+
|
|
1571
|
+
// If shadow provided is string then value other default
|
|
1572
|
+
var btnShadow = typeof shadow === 'string' ? shadow : shadow ? theme$1.shadows.level.z2 : 'none';
|
|
1573
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1574
|
+
children: [to ? /*#__PURE__*/jsxRuntime.jsxs("a", _objectSpread2(_objectSpread2({
|
|
1575
|
+
href: to
|
|
1576
|
+
}, props), {}, {
|
|
1577
|
+
className: _JSXStyle.dynamic([["612376042", [SCALES.height(2.5), round ? '50%' : theme$1.layout.radius, SCALES.font(0.875), color, bg, shadow ? 'transparent' : border, cursor !== null && cursor !== void 0 ? cursor : 'pointer', events, shadow ? btnShadow : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, btnShadow, shadow ? '-1px' : '0px']]]) + " " + (props && props.className != null && props.className || theme.useClasses('btn', 'btn-link', className) || ""),
|
|
1578
|
+
children: [loading && /*#__PURE__*/jsxRuntime.jsx(ButtonLoading, {
|
|
1579
|
+
color: color
|
|
1580
|
+
}), childrenWithIcon]
|
|
1581
|
+
})) : /*#__PURE__*/jsxRuntime.jsxs("button", _objectSpread2(_objectSpread2({
|
|
1582
|
+
ref: buttonRef,
|
|
1583
|
+
type: type,
|
|
1584
|
+
disabled: disabled,
|
|
1585
|
+
onClick: clickHandler
|
|
1586
|
+
}, props), {}, {
|
|
1587
|
+
className: _JSXStyle.dynamic([["612376042", [SCALES.height(2.5), round ? '50%' : theme$1.layout.radius, SCALES.font(0.875), color, bg, shadow ? 'transparent' : border, cursor !== null && cursor !== void 0 ? cursor : 'pointer', events, shadow ? btnShadow : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, btnShadow, shadow ? '-1px' : '0px']]]) + " " + (props && props.className != null && props.className || theme.useClasses('btn', className) || ""),
|
|
1588
|
+
children: [loading && /*#__PURE__*/jsxRuntime.jsx(ButtonLoading, {
|
|
1589
|
+
color: color
|
|
1590
|
+
}), childrenWithIcon, dripShow && /*#__PURE__*/jsxRuntime.jsx(ButtonDrip, {
|
|
1591
|
+
x: dripX,
|
|
1592
|
+
y: dripY,
|
|
1593
|
+
color: dripColor,
|
|
1594
|
+
onCompleted: dripCompletedHandle
|
|
1595
|
+
})]
|
|
1596
|
+
})), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
|
|
1597
|
+
id: "612376042",
|
|
1598
|
+
dynamic: [SCALES.height(2.5), round ? '50%' : theme$1.layout.radius, SCALES.font(0.875), color, bg, shadow ? 'transparent' : border, cursor !== null && cursor !== void 0 ? cursor : 'pointer', events, shadow ? btnShadow : 'none', SCALES.pl(0.727), SCALES.height(2.5), color, bg, auto ? 'min-content' : SCALES.width(10.5), auto ? 'auto' : 'initial', SCALES.height(2.5), SCALES.pt(0), paddingRight, SCALES.pb(0), paddingLeft, SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), hover.color, hover.color, hover.bg, hover.border, cursor, events, btnShadow, shadow ? '-1px' : '0px'],
|
|
1599
|
+
children: ".btn.__jsx-style-dynamic-selector{box-sizing:border-box;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;line-height:".concat(SCALES.height(2.5), ";border-radius:").concat(round ? '50%' : theme$1.layout.radius, ";font-weight:400;font-size:").concat(SCALES.font(0.875), ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;outline:none;text-transform:capitalize;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;text-align:center;white-space:nowrap;-webkit-transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;transition:background-color 200ms ease 0ms,box-shadow 200ms ease 0ms, border 200ms ease 0ms,color 200ms ease 0ms;position:relative;overflow:hidden;color:").concat(color, ";background-color:").concat(bg, ";border:1px solid ").concat(shadow ? 'transparent' : border, ";cursor:").concat(cursor !== null && cursor !== void 0 ? cursor : 'pointer', ";pointer-events:").concat(events, ";box-shadow:").concat(shadow ? btnShadow : 'none', ";--helpdice-ui-button-icon-padding:").concat(SCALES.pl(0.727), ";--helpdice-ui-button-height:").concat(SCALES.height(2.5), ";--helpdice-ui-button-color:").concat(color, ";--helpdice-ui-button-bg:").concat(bg, ";min-width:").concat(auto ? 'min-content' : SCALES.width(10.5), ";width:").concat(auto ? 'auto' : 'initial', ";height:").concat(SCALES.height(2.5), ";padding:").concat(SCALES.pt(0), " ").concat(paddingRight, " ").concat(SCALES.pb(0), " ").concat(paddingLeft, ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";}.btn.__jsx-style-dynamic-selector:hover,.btn.__jsx-style-dynamic-selector:focus{color:").concat(hover.color, ";--helpdice-ui-button-color:").concat(hover.color, ";background-color:").concat(hover.bg, ";border-color:").concat(hover.border, ";cursor:").concat(cursor, ";pointer-events:").concat(events, ";box-shadow:").concat(btnShadow, ";}.btn-link.__jsx-style-dynamic-selector{-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.btn.__jsx-style-dynamic-selector .text{position:relative;z-index:1;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;text-align:center;line-height:inherit;top:-1px;}.btn.__jsx-style-dynamic-selector .text p,.btn.__jsx-style-dynamic-selector .text pre,.btn.__jsx-style-dynamic-selector .text div{margin:0;}.ripple.__jsx-style-dynamic-selector{position:absolute;border-radius:50%;-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0);-webkit-animation:ripple-animation-__jsx-style-dynamic-selector 600ms ease-out;animation:ripple-animation-__jsx-style-dynamic-selector 600ms ease-out;background-color:rgba(0,0,0,0.3);pointer-events:none;z-index:1;}@-webkit-keyframes ripple-animation-__jsx-style-dynamic-selector{to{-webkit-transform:scale(2.5);-ms-transform:scale(2.5);transform:scale(2.5);opacity:0;}}@keyframes ripple-animation-__jsx-style-dynamic-selector{to{-webkit-transform:scale(2.5);-ms-transform:scale(2.5);transform:scale(2.5);opacity:0;}}")
|
|
1600
|
+
})]
|
|
1601
|
+
});
|
|
1602
|
+
});
|
|
1603
|
+
ButtonComponent.displayName = 'Button';
|
|
1604
|
+
var Button = withScale(ButtonComponent);
|
|
1605
|
+
|
|
1606
|
+
var CompactButton = function CompactButton(props) {
|
|
1607
|
+
// const theme = useTheme();
|
|
1608
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread2(_objectSpread2({
|
|
1609
|
+
scale: 2 / 3,
|
|
1610
|
+
px: 0.6
|
|
1611
|
+
}, _objectSpread2({
|
|
1612
|
+
auto: true
|
|
1613
|
+
}, props)), {}, {
|
|
1614
|
+
children: props.children
|
|
1615
|
+
}));
|
|
1616
|
+
};
|
|
1617
|
+
var IconButton = /*#__PURE__*/React.memo(CompactButton);
|
|
1618
|
+
|
|
1619
|
+
var SmallButton = function SmallButton(props) {
|
|
1620
|
+
// const theme = useTheme();
|
|
1621
|
+
return /*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread2(_objectSpread2({
|
|
1622
|
+
auto: true,
|
|
1623
|
+
scale: 2 / 3,
|
|
1624
|
+
px: 0.6
|
|
1625
|
+
}, props), {}, {
|
|
1626
|
+
children: props.children
|
|
1627
|
+
}));
|
|
1628
|
+
};
|
|
1629
|
+
var SmallButton$1 = /*#__PURE__*/React.memo(SmallButton);
|
|
1630
|
+
|
|
1631
|
+
/* "use client" */
|
|
1632
|
+
|
|
1633
|
+
Button.Icon = IconButton;
|
|
1634
|
+
Button.Small = SmallButton$1;
|
|
1635
|
+
|
|
1636
|
+
var Expandable = function Expandable(_ref) {
|
|
1637
|
+
var children = _ref.children,
|
|
1638
|
+
_ref$collapsedHeight = _ref.collapsedHeight,
|
|
1639
|
+
collapsedHeight = _ref$collapsedHeight === void 0 ? 150 : _ref$collapsedHeight,
|
|
1640
|
+
_ref$fadeHeight = _ref.fadeHeight,
|
|
1641
|
+
fadeHeight = _ref$fadeHeight === void 0 ? 40 : _ref$fadeHeight,
|
|
1642
|
+
className = _ref.className,
|
|
1643
|
+
_ref$transitionDurati = _ref.transitionDuration,
|
|
1644
|
+
transitionDuration = _ref$transitionDurati === void 0 ? 300 : _ref$transitionDurati;
|
|
1645
|
+
var contentRef = React.useRef(null);
|
|
1646
|
+
var containerRef = React.useRef(null);
|
|
1647
|
+
var _useState = React.useState(false),
|
|
1648
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1649
|
+
expanded = _useState2[0],
|
|
1650
|
+
setExpanded = _useState2[1];
|
|
1651
|
+
var _useState3 = React.useState(false),
|
|
1652
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1653
|
+
isOverflowing = _useState4[0],
|
|
1654
|
+
setIsOverflowing = _useState4[1];
|
|
1655
|
+
var _useState5 = React.useState(0),
|
|
1656
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1657
|
+
contentHeight = _useState6[0],
|
|
1658
|
+
setContentHeight = _useState6[1];
|
|
1659
|
+
var _useState7 = React.useState("#fff"),
|
|
1660
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1661
|
+
fadeColor = _useState8[0],
|
|
1662
|
+
setFadeColor = _useState8[1];
|
|
1663
|
+
|
|
1664
|
+
// Measure content height and detect overflow
|
|
1665
|
+
React.useEffect(function () {
|
|
1666
|
+
var el = contentRef.current;
|
|
1667
|
+
if (!el) return;
|
|
1668
|
+
var updateHeight = function updateHeight() {
|
|
1669
|
+
var _containerRef$current;
|
|
1670
|
+
var scrollHeight = el.scrollHeight;
|
|
1671
|
+
setContentHeight(scrollHeight);
|
|
1672
|
+
setIsOverflowing(scrollHeight > collapsedHeight);
|
|
1673
|
+
|
|
1674
|
+
// Detect background color dynamically
|
|
1675
|
+
var parentBg = window.getComputedStyle((_containerRef$current = containerRef.current) !== null && _containerRef$current !== void 0 ? _containerRef$current : el).backgroundColor;
|
|
1676
|
+
setFadeColor(parentBg || "#fff");
|
|
1677
|
+
};
|
|
1678
|
+
updateHeight();
|
|
1679
|
+
var observer = new ResizeObserver(updateHeight);
|
|
1680
|
+
observer.observe(el);
|
|
1681
|
+
return function () {
|
|
1682
|
+
return observer.disconnect();
|
|
1683
|
+
};
|
|
1684
|
+
}, [children, collapsedHeight]);
|
|
1685
|
+
var containerHeight = !isOverflowing ? contentHeight : expanded ? contentHeight : collapsedHeight;
|
|
1686
|
+
var fadeStyle = {
|
|
1687
|
+
position: "absolute",
|
|
1688
|
+
bottom: 0,
|
|
1689
|
+
left: 0,
|
|
1690
|
+
right: 0,
|
|
1691
|
+
height: fadeHeight,
|
|
1692
|
+
background: "linear-gradient(to bottom, rgba(255,255,255,0), ".concat(fadeColor, ")"),
|
|
1693
|
+
pointerEvents: "none",
|
|
1694
|
+
transition: "opacity ".concat(transitionDuration, "ms ease"),
|
|
1695
|
+
opacity: !expanded && isOverflowing ? 1 : 0
|
|
1696
|
+
};
|
|
1697
|
+
var toggleExpanded = function toggleExpanded() {
|
|
1698
|
+
return setExpanded(function (prev) {
|
|
1699
|
+
return !prev;
|
|
1700
|
+
});
|
|
1701
|
+
};
|
|
1702
|
+
var handleKey = function handleKey(e) {
|
|
1703
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1704
|
+
e.preventDefault();
|
|
1705
|
+
toggleExpanded();
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1709
|
+
ref: containerRef,
|
|
1710
|
+
className: className,
|
|
1711
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1712
|
+
style: {
|
|
1713
|
+
height: containerHeight,
|
|
1714
|
+
overflow: "hidden",
|
|
1715
|
+
transition: "height ".concat(transitionDuration, "ms ease"),
|
|
1716
|
+
position: "relative"
|
|
1717
|
+
},
|
|
1718
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1719
|
+
ref: contentRef,
|
|
1720
|
+
children: children
|
|
1721
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1722
|
+
style: fadeStyle
|
|
1723
|
+
})]
|
|
1724
|
+
}), isOverflowing && /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1725
|
+
"aria-expanded": expanded,
|
|
1726
|
+
onKeyDown: handleKey,
|
|
1727
|
+
margin: 0,
|
|
1728
|
+
padding: 0,
|
|
1729
|
+
onClick: function onClick() {
|
|
1730
|
+
return setExpanded(function (prev) {
|
|
1731
|
+
return !prev;
|
|
1732
|
+
});
|
|
1733
|
+
},
|
|
1734
|
+
effect: false,
|
|
1735
|
+
color: "abort",
|
|
1736
|
+
scale: 2 / 3,
|
|
1737
|
+
auto: true,
|
|
1738
|
+
children: /*#__PURE__*/jsxRuntime.jsx("b", {
|
|
1739
|
+
children: expanded ? 'Show less' : 'Show more'
|
|
1740
|
+
})
|
|
1741
|
+
})]
|
|
1742
|
+
});
|
|
1743
|
+
};
|
|
1744
|
+
|
|
956
1745
|
var _excluded = ["gap", "children", "direction", "justify", "alignItems", "alignContent", "collapse", "className"];
|
|
957
1746
|
var wrap = tuple('nowrap', 'wrap', 'wrap-reverse');
|
|
958
1747
|
var Container = function Container(_ref) {
|