@helpdice/ui 2.6.0-beta.5 → 2.6.0-beta.7

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.
@@ -81,10 +81,7 @@ function _iterableToArrayLimit(r, l) {
81
81
  f = true,
82
82
  o = false;
83
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);
84
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
88
85
  } catch (r) {
89
86
  o = true, n = r;
90
87
  } finally {
@@ -762,7 +759,7 @@ var ScalePropKeys = ['width', 'height', 'padding', 'margin', 'w', 'h', 'paddingL
762
759
  var defaultDynamicLayoutPipe = function defaultDynamicLayoutPipe(scale1x) {
763
760
  return "".concat(scale1x);
764
761
  };
765
- var defaultContext$1 = {
762
+ var defaultContext = {
766
763
  getScaleProps: function getScaleProps() {
767
764
  return undefined;
768
765
  },
@@ -788,7 +785,7 @@ var defaultContext$1 = {
788
785
  },
789
786
  unit: '16px'
790
787
  };
791
- var ScaleContext = /*#__PURE__*/React.createContext(defaultContext$1);
788
+ var ScaleContext = /*#__PURE__*/React.createContext(defaultContext);
792
789
  var useScale = function useScale() {
793
790
  return React.useContext(ScaleContext);
794
791
  };
@@ -845,7 +842,7 @@ var generateGetAllScaleProps = function generateGetAllScaleProps(props) {
845
842
  return getAllScaleProps;
846
843
  };
847
844
 
848
- var _excluded$6 = ["children"];
845
+ var _excluded$3 = ["children"];
849
846
  var reduceScaleCoefficient = function reduceScaleCoefficient(scale) {
850
847
  if (scale === 1) return scale;
851
848
  var diff = Math.abs((scale - 1) / 2);
@@ -855,7 +852,7 @@ var withScale = function withScale(Render) {
855
852
  var ScaleFC = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
856
853
  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;
857
854
  var children = _ref.children,
858
- props = _objectWithoutProperties(_ref, _excluded$6);
855
+ props = _objectWithoutProperties(_ref, _excluded$3);
859
856
  var _useTheme = theme.useTheme(),
860
857
  layout = _useTheme.layout;
861
858
  var paddingLeft = props.paddingLeft,
@@ -940,7 +937,7 @@ var withScale = function withScale(Render) {
940
937
  return ScaleFC;
941
938
  };
942
939
 
943
- var _excluded$5 = ["children", "tag", "className", "color"];
940
+ var _excluded$2 = ["children", "tag", "className", "color"];
944
941
  var getTypeColor = function getTypeColor(type, palette) {
945
942
  var colors = {
946
943
  "default": 'inherit',
@@ -958,7 +955,7 @@ var TextChild = function TextChild(_ref) {
958
955
  className = _ref$className === void 0 ? '' : _ref$className,
959
956
  _ref$color = _ref.color,
960
957
  color = _ref$color === void 0 ? 'default' : _ref$color,
961
- props = _objectWithoutProperties(_ref, _excluded$5);
958
+ props = _objectWithoutProperties(_ref, _excluded$2);
962
959
  var Component = tag;
963
960
  var theme$1 = theme.useTheme();
964
961
  var _useScale = useScale(),
@@ -1006,652 +1003,7 @@ var TextChild = function TextChild(_ref) {
1006
1003
  };
1007
1004
  TextChild.displayName = 'TextChild';
1008
1005
 
1009
- var ButtonDrip = function ButtonDrip(_ref) {
1010
- var _ref$x = _ref.x,
1011
- x = _ref$x === void 0 ? 0 : _ref$x,
1012
- _ref$y = _ref.y,
1013
- y = _ref$y === void 0 ? 0 : _ref$y,
1014
- color = _ref.color,
1015
- onCompleted = _ref.onCompleted;
1016
- var dripRef = React.useRef(null);
1017
- /* istanbul ignore next */
1018
- var top = Number.isNaN(+y) ? 0 : y - 10;
1019
- /* istanbul ignore next */
1020
- var left = Number.isNaN(+x) ? 0 : x - 10;
1021
- React.useEffect(function () {
1022
- /* istanbul ignore next */
1023
- if (!dripRef.current) return;
1024
- dripRef.current.addEventListener('animationend', onCompleted);
1025
- return function () {
1026
- /* istanbul ignore next */
1027
- if (!dripRef.current) return;
1028
- dripRef.current.removeEventListener('animationend', onCompleted);
1029
- };
1030
- });
1031
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1032
- ref: dripRef,
1033
- className: "jsx-3424889537" + " " + "drip",
1034
- children: [/*#__PURE__*/jsxRuntime.jsx("svg", {
1035
- width: "20",
1036
- height: "20",
1037
- viewBox: "0 0 20 20",
1038
- style: {
1039
- top: top,
1040
- left: left
1041
- },
1042
- className: "jsx-3424889537",
1043
- children: /*#__PURE__*/jsxRuntime.jsx("g", {
1044
- stroke: "none",
1045
- strokeWidth: "1",
1046
- fill: "none",
1047
- fillRule: "evenodd",
1048
- className: "jsx-3424889537",
1049
- children: /*#__PURE__*/jsxRuntime.jsx("g", {
1050
- fill: color,
1051
- className: "jsx-3424889537",
1052
- children: /*#__PURE__*/jsxRuntime.jsx("rect", {
1053
- width: "100%",
1054
- height: "100%",
1055
- rx: "10",
1056
- className: "jsx-3424889537"
1057
- })
1058
- })
1059
- })
1060
- }), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1061
- id: "3424889537",
1062
- 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;}}"
1063
- })]
1064
- });
1065
- };
1066
- ButtonDrip.displayName = 'ButtonDrip';
1067
-
1068
- var _excluded$4 = ["children", "type", "color", "className", "spaceRatio"];
1069
- var getIconBgColor = function getIconBgColor(type, palette, color) {
1070
- var colors = {
1071
- "default": palette.accents_6,
1072
- secondary: palette.secondary,
1073
- success: palette.success,
1074
- warning: palette.warning,
1075
- error: palette.error
1076
- };
1077
- return color ? color : colors[type];
1078
- };
1079
- var LoadingComponent = function LoadingComponent(_ref) {
1080
- var children = _ref.children,
1081
- _ref$type = _ref.type,
1082
- type = _ref$type === void 0 ? 'default' : _ref$type,
1083
- color = _ref.color,
1084
- _ref$className = _ref.className,
1085
- className = _ref$className === void 0 ? '' : _ref$className,
1086
- _ref$spaceRatio = _ref.spaceRatio,
1087
- spaceRatio = _ref$spaceRatio === void 0 ? 1 : _ref$spaceRatio,
1088
- props = _objectWithoutProperties(_ref, _excluded$4);
1089
- var theme$1 = theme.useTheme();
1090
- var _useScale = useScale(),
1091
- SCALES = _useScale.SCALES;
1092
- var classes = theme.useClasses('loading-container', className);
1093
- var bgColor = React.useMemo(function () {
1094
- return getIconBgColor(type, theme$1.palette, color);
1095
- }, [type, theme$1.palette, color]);
1096
- return /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread2(_objectSpread2({}, props), {}, {
1097
- 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 || ""),
1098
- children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
1099
- 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",
1100
- children: [children && /*#__PURE__*/jsxRuntime.jsx("label", {
1101
- 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]]]),
1102
- children: children
1103
- }), /*#__PURE__*/jsxRuntime.jsx("i", {
1104
- 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]]])
1105
- }), /*#__PURE__*/jsxRuntime.jsx("i", {
1106
- 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]]])
1107
- }), /*#__PURE__*/jsxRuntime.jsx("i", {
1108
- 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]]])
1109
- })]
1110
- }), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1111
- id: "2201634259",
1112
- 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],
1113
- 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;}}")
1114
- })]
1115
- }));
1116
- };
1117
- LoadingComponent.displayName = 'Loading';
1118
- var Loading = withScale(LoadingComponent);
1119
-
1120
- var ButtonLoading = function ButtonLoading(_ref) {
1121
- var color = _ref.color;
1122
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
1123
- className: "jsx-212623367" + " " + "btn-loading",
1124
- children: [/*#__PURE__*/jsxRuntime.jsx(Loading, {
1125
- color: color
1126
- }), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1127
- id: "212623367",
1128
- 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);}"
1129
- })]
1130
- });
1131
- };
1132
- ButtonLoading.displayName = 'ButtonLoading';
1133
-
1134
- var _excluded$3 = ["isRight", "isSingle", "children", "className"];
1135
- var ButtonIcon = function ButtonIcon(_ref) {
1136
- var _ref$isRight = _ref.isRight,
1137
- isRight = _ref$isRight === void 0 ? false : _ref$isRight,
1138
- isSingle = _ref.isSingle,
1139
- children = _ref.children,
1140
- _ref$className = _ref.className,
1141
- className = _ref$className === void 0 ? '' : _ref$className,
1142
- props = _objectWithoutProperties(_ref, _excluded$3);
1143
- var classes = theme.useClasses('icon', {
1144
- right: isRight,
1145
- single: isSingle
1146
- }, className);
1147
- return /*#__PURE__*/jsxRuntime.jsxs("span", _objectSpread2(_objectSpread2({}, props), {}, {
1148
- className: "jsx-2467502931" + " " + (props && props.className != null && props.className || classes || ""),
1149
- children: [children, /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1150
- id: "2467502931",
1151
- 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;}"
1152
- })]
1153
- }));
1154
- };
1155
- ButtonIcon.displayName = 'ButtonIcon';
1156
-
1157
- var getButtonChildrenWithIcon = function getButtonChildrenWithIcon(auto, children, icons) {
1158
- var icon = icons.icon,
1159
- iconRight = icons.iconRight;
1160
- var hasIcon = icon || iconRight;
1161
- var isRight = Boolean(iconRight);
1162
- var paddingForAutoMode = auto ? "calc(var(--helpdice-ui-button-height) / 2 + var(--helpdice-ui-button-icon-padding) * .5)" : 0;
1163
- var classes = theme.useClasses('text', isRight ? 'right' : 'left');
1164
- if (!hasIcon) return /*#__PURE__*/jsxRuntime.jsx("div", {
1165
- className: "text",
1166
- children: children
1167
- });
1168
- if (React.Children.count(children) === 0) {
1169
- return /*#__PURE__*/jsxRuntime.jsx(ButtonIcon, {
1170
- isRight: isRight,
1171
- isSingle: true,
1172
- children: hasIcon
1173
- });
1174
- }
1175
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1176
- children: [/*#__PURE__*/jsxRuntime.jsx(ButtonIcon, {
1177
- isRight: isRight,
1178
- children: hasIcon
1179
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
1180
- className: _JSXStyle.dynamic([["3568181479", [paddingForAutoMode, paddingForAutoMode]]]) + " " + (classes || ""),
1181
- children: [children, /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1182
- id: "3568181479",
1183
- dynamic: [paddingForAutoMode, paddingForAutoMode],
1184
- children: ".left.__jsx-style-dynamic-selector{padding-left:".concat(paddingForAutoMode, ";}.right.__jsx-style-dynamic-selector{padding-right:").concat(paddingForAutoMode, ";}")
1185
- })]
1186
- })]
1187
- });
1188
- };
1189
- var filterPropsWithGroup = function filterPropsWithGroup(props, config) {
1190
- if (!config.isButtonGroup) return props;
1191
- return _objectSpread2(_objectSpread2({}, props), {}, {
1192
- auto: true,
1193
- shadow: false,
1194
- ghost: config.ghost || props.ghost,
1195
- type: config.type || props.type,
1196
- disabled: config.disabled || props.disabled
1197
- });
1198
- };
1199
-
1200
- /* "use client" */
1201
-
1202
- var defaultContext = {
1203
- isButtonGroup: false,
1204
- disabled: false
1205
- };
1206
- var ButtonGroupContext = /*#__PURE__*/React.createContext(defaultContext);
1207
- var useButtonGroupContext = function useButtonGroupContext() {
1208
- return React.useContext(ButtonGroupContext);
1209
- };
1210
-
1211
- var hexToRgb = function hexToRgb(color) {
1212
- var fullReg = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
1213
- var full = color.replace(fullReg, function (_, r, g, b) {
1214
- return "".concat(r).concat(r).concat(g).concat(g).concat(b).concat(b);
1215
- });
1216
- var values = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(full);
1217
- if (!values) {
1218
- throw new Error("Helpdice UI: Unsupported ".concat(color, " color."));
1219
- }
1220
- return [Number.parseInt(values[1], 16), Number.parseInt(values[2], 16), Number.parseInt(values[3], 16)];
1221
- };
1222
- var colorToRgbValues = function colorToRgbValues(color) {
1223
- if (color.charAt(0) === '#') return hexToRgb(color);
1224
- var safeColor = color.replace(/ /g, '');
1225
- var colorType = color.substr(0, 4);
1226
- var regArray = safeColor.match(/\((.+)\)/);
1227
- if (!colorType.startsWith('rgb') || !regArray) {
1228
- console.log(color);
1229
- throw new Error("Helpdice UI: Only support [\"RGB\", \"RGBA\", \"HEX\"] color.");
1230
- }
1231
- return regArray[1].split(',').map(function (str) {
1232
- return Number.parseFloat(str);
1233
- });
1234
- };
1235
- var addColorAlpha = function addColorAlpha(color, alpha) {
1236
- if (!/^#|rgb|RGB/.test(color)) return color;
1237
- var _colorToRgbValues = colorToRgbValues(color),
1238
- _colorToRgbValues2 = _slicedToArray(_colorToRgbValues, 3),
1239
- r = _colorToRgbValues2[0],
1240
- g = _colorToRgbValues2[1],
1241
- b = _colorToRgbValues2[2];
1242
- var safeAlpha = alpha > 1 ? 1 : alpha < 0 ? 0 : alpha;
1243
- return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(safeAlpha, ")");
1244
- };
1245
-
1246
- var getButtonGhostColors = function getButtonGhostColors(palette, _color) {
1247
- var colors = {
1248
- secondary: {
1249
- bg: palette.background,
1250
- border: palette.foreground,
1251
- color: palette.foreground,
1252
- ripple: ''
1253
- },
1254
- success: {
1255
- bg: palette.background,
1256
- border: palette.success,
1257
- color: palette.success,
1258
- ripple: ''
1259
- },
1260
- warning: {
1261
- bg: palette.background,
1262
- border: palette.warning,
1263
- color: palette.warning,
1264
- ripple: ''
1265
- },
1266
- error: {
1267
- bg: palette.background,
1268
- border: palette.error,
1269
- color: palette.error,
1270
- ripple: ''
1271
- }
1272
- };
1273
- return colors[_color] || null;
1274
- };
1275
- var getButtonColors = function getButtonColors(palette, props) {
1276
- var color = props.color,
1277
- disabled = props.disabled,
1278
- ghost = props.ghost;
1279
- var colors = {
1280
- "default": {
1281
- bg: palette.background,
1282
- border: palette.border,
1283
- color: palette.accents_5,
1284
- ripple: palette.accents_1
1285
- },
1286
- secondary: {
1287
- bg: palette.foreground,
1288
- border: palette.foreground,
1289
- color: palette.background,
1290
- ripple: palette.accents_1
1291
- },
1292
- success: {
1293
- bg: palette.success,
1294
- border: palette.success,
1295
- color: '#fff',
1296
- ripple: '#1f93ffff'
1297
- },
1298
- warning: {
1299
- bg: palette.warning,
1300
- border: palette.warning,
1301
- color: '#fff',
1302
- ripple: '#ffca29ff'
1303
- },
1304
- error: {
1305
- bg: palette.error,
1306
- border: palette.error,
1307
- color: '#fff',
1308
- ripple: '#ff5a55ff'
1309
- },
1310
- abort: {
1311
- bg: 'transparent',
1312
- border: 'transparent',
1313
- color: palette.accents_5,
1314
- ripple: palette.accents_1
1315
- }
1316
- };
1317
- if (disabled) return {
1318
- bg: palette.accents_1,
1319
- border: palette.accents_2,
1320
- color: '#ccc',
1321
- ripple: ''
1322
- };
1323
-
1324
- /**
1325
- * The '-light' type is the same color as the common type,
1326
- * only hover's color is different.
1327
- * e.g.
1328
- * Color['success'] === Color['success-light']
1329
- * Color['warning'] === Color['warning-light']
1330
- */
1331
- var withoutLightType = color === null || color === void 0 ? void 0 : color.replace('-light', '');
1332
- var defaultColor = colors["default"];
1333
- if (ghost) return getButtonGhostColors(palette, withoutLightType) || defaultColor;
1334
- return colors[withoutLightType] || defaultColor;
1335
- };
1336
- var getButtonGhostHoverColors = function getButtonGhostHoverColors(palette, _color) {
1337
- var colors = {
1338
- secondary: {
1339
- bg: palette.foreground,
1340
- border: palette.background,
1341
- color: palette.background
1342
- },
1343
- success: {
1344
- bg: palette.success,
1345
- border: palette.background,
1346
- color: 'white'
1347
- },
1348
- warning: {
1349
- bg: palette.warning,
1350
- border: palette.background,
1351
- color: 'white'
1352
- },
1353
- error: {
1354
- bg: palette.error,
1355
- border: palette.background,
1356
- color: 'white'
1357
- }
1358
- };
1359
- var withoutLightType = _color === null || _color === void 0 ? void 0 : _color.replace('-light', '');
1360
- return colors[withoutLightType] || null;
1361
- };
1362
- var getButtonHoverColors = function getButtonHoverColors(palette, props) {
1363
- var color = props.color,
1364
- disabled = props.disabled,
1365
- loading = props.loading,
1366
- shadow = props.shadow,
1367
- ghost = props.ghost;
1368
- var defaultColor = getButtonColors(palette, props);
1369
- var alphaBackground = addColorAlpha(defaultColor.bg, 0.85);
1370
- var colors = {
1371
- "default": {
1372
- bg: palette.background,
1373
- border: palette.foreground
1374
- },
1375
- secondary: {
1376
- bg: palette.background,
1377
- border: palette.foreground
1378
- },
1379
- success: {
1380
- bg: palette.background,
1381
- border: palette.success
1382
- },
1383
- warning: {
1384
- bg: palette.background,
1385
- border: palette.warning
1386
- },
1387
- error: {
1388
- bg: palette.background,
1389
- border: palette.error
1390
- },
1391
- abort: {
1392
- bg: 'transparent',
1393
- border: 'transparent',
1394
- color: palette.accents_5
1395
- },
1396
- 'secondary-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1397
- bg: alphaBackground
1398
- }),
1399
- 'success-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1400
- bg: alphaBackground
1401
- }),
1402
- 'warning-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1403
- bg: alphaBackground
1404
- }),
1405
- 'error-light': _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1406
- bg: alphaBackground
1407
- })
1408
- };
1409
- if (disabled) return {
1410
- bg: palette.accents_1,
1411
- border: palette.accents_2,
1412
- color: '#ccc'
1413
- };
1414
- if (loading) return _objectSpread2(_objectSpread2({}, defaultColor), {}, {
1415
- color: 'transparent'
1416
- });
1417
- if (shadow) return defaultColor;
1418
- var hoverColor = (ghost ? getButtonGhostHoverColors(palette, color) : colors[color]) || colors["default"];
1419
- return _objectSpread2(_objectSpread2({}, hoverColor), {}, {
1420
- color: hoverColor.color || hoverColor.border
1421
- });
1422
- };
1423
- var getButtonCursor = function getButtonCursor(disabled, loading) {
1424
- if (disabled) return {
1425
- cursor: 'not-allowed',
1426
- events: 'auto'
1427
- };
1428
- if (loading) return {
1429
- cursor: 'default',
1430
- events: 'none'
1431
- };
1432
- return {
1433
- cursor: 'pointer',
1434
- events: 'auto'
1435
- };
1436
- };
1437
- var getButtonDripColor = function getButtonDripColor(palette, props) {
1438
- var type = props.type;
1439
- var isLightHover = type ? type.endsWith('light') : false;
1440
- var hoverColors = getButtonHoverColors(palette, props);
1441
- return isLightHover ? addColorAlpha(hoverColors.bg, 0.65) : addColorAlpha(palette.accents_2, 0.65);
1442
- };
1443
-
1444
- var _excluded$2 = ["children", "disabled", "color", "loading", "shadow", "ghost", "effect", "round", "relative", "replace", "a", "to", "onClick", "auto", "icon", "type", "iconRight", "className", "crossOrigin"];
1445
- var ButtonComponent = /*#__PURE__*/React.forwardRef(function (btnProps, ref) {
1446
- var theme$1 = theme.useTheme();
1447
- // const navigate = useNavigate();
1448
- var _useScale = useScale(),
1449
- SCALES = _useScale.SCALES;
1450
- var buttonRef = React.useRef(null);
1451
- React.useImperativeHandle(ref, function () {
1452
- return buttonRef.current;
1453
- }); // Changed with !
1454
-
1455
- var _useState = React.useState(false),
1456
- _useState2 = _slicedToArray(_useState, 2),
1457
- dripShow = _useState2[0],
1458
- setDripShow = _useState2[1];
1459
- var _useState3 = React.useState(0),
1460
- _useState4 = _slicedToArray(_useState3, 2),
1461
- dripX = _useState4[0],
1462
- setDripX = _useState4[1];
1463
- var _useState5 = React.useState(0),
1464
- _useState6 = _slicedToArray(_useState5, 2),
1465
- dripY = _useState6[0],
1466
- setDripY = _useState6[1];
1467
- var groupConfig = useButtonGroupContext();
1468
- var filteredProps = filterPropsWithGroup(btnProps, groupConfig);
1469
- /* eslint-disable @typescript-eslint/no-unused-vars */
1470
- var children = filteredProps.children,
1471
- _filteredProps$disabl = filteredProps.disabled,
1472
- disabled = _filteredProps$disabl === void 0 ? false : _filteredProps$disabl;
1473
- filteredProps.color;
1474
- var _filteredProps$loadin = filteredProps.loading,
1475
- loading = _filteredProps$loadin === void 0 ? false : _filteredProps$loadin,
1476
- _filteredProps$shadow = filteredProps.shadow,
1477
- shadow = _filteredProps$shadow === void 0 ? false : _filteredProps$shadow,
1478
- _filteredProps$ghost = filteredProps.ghost,
1479
- ghost = _filteredProps$ghost === void 0 ? false : _filteredProps$ghost,
1480
- _filteredProps$effect = filteredProps.effect,
1481
- effect = _filteredProps$effect === void 0 ? true : _filteredProps$effect,
1482
- _filteredProps$round = filteredProps.round,
1483
- round = _filteredProps$round === void 0 ? false : _filteredProps$round;
1484
- filteredProps.relative;
1485
- filteredProps.replace;
1486
- filteredProps.a;
1487
- var to = filteredProps.to,
1488
- onClick = filteredProps.onClick,
1489
- _filteredProps$auto = filteredProps.auto,
1490
- auto = _filteredProps$auto === void 0 ? false : _filteredProps$auto,
1491
- icon = filteredProps.icon,
1492
- _filteredProps$type = filteredProps.type,
1493
- type = _filteredProps$type === void 0 ? 'button' : _filteredProps$type,
1494
- iconRight = filteredProps.iconRight,
1495
- _filteredProps$classN = filteredProps.className,
1496
- className = _filteredProps$classN === void 0 ? '' : _filteredProps$classN;
1497
- filteredProps.crossOrigin;
1498
- var props = _objectWithoutProperties(filteredProps, _excluded$2);
1499
- /* eslint-enable @typescript-eslint/no-unused-vars */
1500
-
1501
- var _useMemo = React.useMemo(function () {
1502
- return getButtonColors(theme$1.palette, filteredProps);
1503
- }, [theme$1.palette, filteredProps]),
1504
- bg = _useMemo.bg,
1505
- border = _useMemo.border,
1506
- color = _useMemo.color,
1507
- rippleColor = _useMemo.ripple;
1508
- var hover = React.useMemo(function () {
1509
- return getButtonHoverColors(theme$1.palette, filteredProps);
1510
- }, [theme$1.palette, filteredProps]);
1511
- var _useMemo2 = React.useMemo(function () {
1512
- return getButtonCursor(disabled, loading);
1513
- }, [disabled, loading]),
1514
- cursor = _useMemo2.cursor,
1515
- events = _useMemo2.events;
1516
- var dripColor = React.useMemo(function () {
1517
- return getButtonDripColor(theme$1.palette, filteredProps);
1518
- }, [theme$1.palette, filteredProps]);
1519
-
1520
- /* istanbul ignore next */
1521
- var dripCompletedHandle = function dripCompletedHandle() {
1522
- setDripShow(false);
1523
- setDripX(0);
1524
- setDripY(0);
1525
- };
1526
- var createRipple = function createRipple(event) {
1527
- var button = buttonRef.current;
1528
- if (!button) return;
1529
- var rect = button.getBoundingClientRect();
1530
- var size = Math.max(rect.width, rect.height);
1531
- var x = event.clientX - rect.left - size / 2;
1532
- var y = event.clientY - rect.top - size / 2;
1533
- var rippleCount = 1; // number of rings
1534
- var rippleDelay = 500; // ms between each ripple
1535
- var _loop = function _loop() {
1536
- var ripple = document.createElement('span');
1537
- Object.assign(ripple.style, {
1538
- position: 'absolute',
1539
- borderRadius: '50%',
1540
- backgroundColor: rippleColor,
1541
- width: "".concat(size, "px"),
1542
- height: "".concat(size, "px"),
1543
- left: "".concat(x, "px"),
1544
- top: "".concat(y, "px"),
1545
- pointerEvents: 'none',
1546
- transform: 'scale(0)',
1547
- opacity: '1',
1548
- transition: "transform 600ms ease-out ".concat(i * rippleDelay, "ms, opacity 600ms ease-out ").concat(i * rippleDelay, "ms"),
1549
- zIndex: 1
1550
- });
1551
- button.appendChild(ripple);
1552
-
1553
- // Force reflow to start transition
1554
- window.getComputedStyle(ripple).opacity;
1555
- ripple.style.transform = 'scale(2.5)';
1556
- ripple.style.opacity = '0';
1557
- ripple.addEventListener('transitionend', function () {
1558
- ripple.remove();
1559
- });
1560
- };
1561
- for (var i = 0; i < rippleCount; i++) {
1562
- _loop();
1563
- }
1564
- };
1565
- var clickHandler = function clickHandler(event) {
1566
- if (disabled || loading) return;
1567
- var showDrip = !shadow && !ghost && effect;
1568
- /* istanbul ignore next */
1569
- if (showDrip && buttonRef.current) {
1570
- var rect = buttonRef.current.getBoundingClientRect();
1571
- setDripShow(true);
1572
- setDripX(event.clientX - rect.left);
1573
- setDripY(event.clientY - rect.top);
1574
- }
1575
- if (shadow) {
1576
- createRipple(event);
1577
- }
1578
- onClick && onClick(event);
1579
- };
1580
- var childrenWithIcon = React.useMemo(function () {
1581
- return getButtonChildrenWithIcon(auto, children, {
1582
- icon: icon,
1583
- iconRight: iconRight
1584
- });
1585
- }, [auto, children, icon, iconRight]);
1586
- var paddingLeft = auto ? SCALES.pl(1.15) : SCALES.pl(1.375),
1587
- paddingRight = auto ? SCALES.pr(1.15) : SCALES.pr(1.375);
1588
-
1589
- // If shadow provided is string then value other default
1590
- var btnShadow = typeof shadow === 'string' ? shadow : shadow ? theme$1.shadows.level.z2 : 'none';
1591
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1592
- children: [to ? /*#__PURE__*/jsxRuntime.jsxs("a", _objectSpread2(_objectSpread2({
1593
- href: to
1594
- }, props), {}, {
1595
- 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) || ""),
1596
- children: [loading && /*#__PURE__*/jsxRuntime.jsx(ButtonLoading, {
1597
- color: color
1598
- }), childrenWithIcon]
1599
- })) : /*#__PURE__*/jsxRuntime.jsxs("button", _objectSpread2(_objectSpread2({
1600
- ref: buttonRef,
1601
- type: type,
1602
- disabled: disabled,
1603
- onClick: clickHandler
1604
- }, props), {}, {
1605
- 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) || ""),
1606
- children: [loading && /*#__PURE__*/jsxRuntime.jsx(ButtonLoading, {
1607
- color: color
1608
- }), childrenWithIcon, dripShow && /*#__PURE__*/jsxRuntime.jsx(ButtonDrip, {
1609
- x: dripX,
1610
- y: dripY,
1611
- color: dripColor,
1612
- onCompleted: dripCompletedHandle
1613
- })]
1614
- })), /*#__PURE__*/jsxRuntime.jsx(_JSXStyle, {
1615
- id: "612376042",
1616
- 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'],
1617
- 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;}}")
1618
- })]
1619
- });
1620
- });
1621
- ButtonComponent.displayName = 'Button';
1622
- var Button = withScale(ButtonComponent);
1623
-
1624
- var CompactButton = function CompactButton(props) {
1625
- // const theme = useTheme();
1626
- return /*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread2(_objectSpread2({
1627
- scale: 2 / 3,
1628
- px: 0.6
1629
- }, _objectSpread2({
1630
- auto: true
1631
- }, props)), {}, {
1632
- children: props.children
1633
- }));
1634
- };
1635
- var IconButton = /*#__PURE__*/React.memo(CompactButton);
1636
-
1637
- var SmallButton = function SmallButton(props) {
1638
- // const theme = useTheme();
1639
- return /*#__PURE__*/jsxRuntime.jsx(Button, _objectSpread2(_objectSpread2({
1640
- auto: true,
1641
- scale: 2 / 3,
1642
- px: 0.6
1643
- }, props), {}, {
1644
- children: props.children
1645
- }));
1646
- };
1647
- var SmallButton$1 = /*#__PURE__*/React.memo(SmallButton);
1648
-
1649
- /* "use client" */
1650
-
1651
- Button.Icon = IconButton;
1652
- Button.Small = SmallButton$1;
1653
-
1654
- var _excluded$1 = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "b", "small", "i", "span", "del", "em", "blockquote", "noWrap", "collapse", "children", "className", "display", "alignItems", "justify"];
1006
+ var _excluded$1 = ["h1", "h2", "h3", "h4", "h5", "h6", "p", "b", "small", "i", "span", "del", "em", "blockquote", "noWrap", "children", "className", "display", "alignItems", "justify"];
1655
1007
  var _getModifierChild = function getModifierChild(tags, children) {
1656
1008
  if (!tags.length) return children;
1657
1009
  var nextTag = tags.slice(1, tags.length);
@@ -1691,8 +1043,6 @@ var TextComponent = function TextComponent(_ref) {
1691
1043
  blockquote = _ref$blockquote === void 0 ? false : _ref$blockquote,
1692
1044
  _ref$noWrap = _ref.noWrap,
1693
1045
  noWrap = _ref$noWrap === void 0 ? false : _ref$noWrap,
1694
- _ref$collapse = _ref.collapse,
1695
- collapse = _ref$collapse === void 0 ? 0 : _ref$collapse,
1696
1046
  children = _ref.children,
1697
1047
  _ref$className = _ref.className,
1698
1048
  className = _ref$className === void 0 ? '' : _ref$className,
@@ -1736,10 +1086,6 @@ var TextComponent = function TextComponent(_ref) {
1736
1086
  *
1737
1087
  */
1738
1088
 
1739
- var _useState = React.useState(false),
1740
- _useState2 = _slicedToArray(_useState, 2),
1741
- expand = _useState2[0],
1742
- setExpand = _useState2[1];
1743
1089
  var tag = React.useMemo(function () {
1744
1090
  if (names[0]) return names[0];
1745
1091
  if (inlineNames[0]) return inlineNames[0];
@@ -1762,26 +1108,7 @@ var TextComponent = function TextComponent(_ref) {
1762
1108
  className: "".concat(className, " ").concat(noWrap ? 'no-wrap' : ''),
1763
1109
  tag: tag
1764
1110
  }, props), {}, {
1765
- children: typeof children === 'string' && collapse > 50 ? /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1766
- children: [expand ? modifers : (modifers === null || modifers === void 0 ? void 0 : modifers.toString().substring(0, collapse)) + '...', /*#__PURE__*/jsxRuntime.jsx(Button, {
1767
- margin: 0,
1768
- onClick: function onClick() {
1769
- return setExpand(!expand);
1770
- },
1771
- style: {
1772
- textTransform: 'lowercase'
1773
- },
1774
- effect: false,
1775
- color: "abort",
1776
- scale: 2 / 3,
1777
- px: 0.2,
1778
- py: 0,
1779
- auto: true,
1780
- children: /*#__PURE__*/jsxRuntime.jsx("b", {
1781
- children: expand ? 'less' : 'more'
1782
- })
1783
- })]
1784
- }) : modifers
1111
+ children: modifers
1785
1112
  }));
1786
1113
  };
1787
1114
  TextComponent.displayName = 'Text';