@mw-kit/mw-ui 1.7.76 → 1.7.78

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.
@@ -653,14 +653,18 @@ var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef)
653
653
  setRef = _useState[1];
654
654
 
655
655
  var getPosition = useCallback(function () {
656
+ if (props.position) return props.position;
656
657
  if (!ref) return null;
657
658
 
658
- var _ref = boundRef ? {
659
- offsetTop: boundRef.offsetTop,
660
- offsetLeft: boundRef.offsetLeft,
661
- width: boundRef.offsetWidth,
662
- height: boundRef.offsetHeight
663
- } : {
659
+ var _ref = boundRef ? function () {
660
+ var rect = boundRef.getBoundingClientRect();
661
+ return {
662
+ offsetTop: rect.top,
663
+ offsetLeft: rect.left,
664
+ width: boundRef.offsetWidth,
665
+ height: boundRef.offsetHeight
666
+ };
667
+ }() : {
664
668
  offsetTop: 0,
665
669
  offsetLeft: 0,
666
670
  width: window.innerWidth,
@@ -691,9 +695,9 @@ var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef)
691
695
 
692
696
  return _newPosition;
693
697
  }
694
- }, [ref, boundRef]);
698
+ }, [ref, boundRef, props.position]);
695
699
 
696
- var _useState2 = useState(props.position || getPosition),
700
+ var _useState2 = useState(getPosition),
697
701
  position = _useState2[0],
698
702
  setPosition = _useState2[1];
699
703
 
@@ -701,7 +705,6 @@ var AbsoluteContainer = React__default.forwardRef(function (props, fowardedRef)
701
705
  return ref;
702
706
  });
703
707
  useEffect(function () {
704
- if (props.position) return;
705
708
  setPosition(getPosition);
706
709
  }, [getPosition]);
707
710
  var htmlProps = filterObject(props, ['center', 'position', 'children', 'content']);
@@ -19098,7 +19101,7 @@ var delimiters = {
19098
19101
  blue: ['blue'],
19099
19102
  grey: ['warningGray']
19100
19103
  };
19101
- var Tabs = styled.ul(_templateObject2$Q || (_templateObject2$Q = _taggedTemplateLiteralLoose(["\n user-select: none;\n list-style: none;\n display: inline-flex;\n width: 100%;\n\n ", "\n\n ", ";\n\n gap: ", ";\n"])), function (_ref) {
19104
+ var Tabs = styled.ul(_templateObject2$Q || (_templateObject2$Q = _taggedTemplateLiteralLoose(["\n user-select: none;\n list-style: none;\n display: inline-flex;\n width: 100%;\n\n ", "\n\n ", ";\n\n gap: ", ";\n\n > li {\n position: relative;\n }\n"])), function (_ref) {
19102
19105
  var spacing = _ref.$spacing;
19103
19106
 
19104
19107
  var _getSpacings$split = getSpacings(spacing || {}, {
@@ -19132,148 +19135,127 @@ var Tabs = styled.ul(_templateObject2$Q || (_templateObject2$Q = _taggedTemplate
19132
19135
  internal = _ref3.$internal;
19133
19136
  return internal ? theme.spacings.s6 : 0;
19134
19137
  });
19135
- var Tab = styled.li(_templateObject5$t || (_templateObject5$t = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n ", "\n"])), function (_ref4) {
19138
+ var Tab = styled.div(_templateObject5$t || (_templateObject5$t = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n ", "\n\n transition-property: padding-right, background-color, color;\n transition-duration: 0.25s;\n transition-timing-function: ease-in-out;\n"])), function (_ref4) {
19136
19139
  var theme = _ref4.theme,
19137
19140
  active = _ref4.$active,
19138
19141
  internal = _ref4.$internal;
19139
- return css(_templateObject6$q || (_templateObject6$q = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n padding: ", ";\n gap: ", ";\n\n ", "\n\n span {\n color: ", ";\n }\n "])), theme.colors[active ? 'blue' : 'white'], theme.spacings.s3, theme.spacings.s3, internal ? css(_templateObject7$q || (_templateObject7$q = _taggedTemplateLiteralLoose(["\n border-radius: 4px 4px 0 0;\n\n > span {\n ", "\n line-height: 17px;\n }\n "])), function (_ref5) {
19142
+ return css(_templateObject6$q || (_templateObject6$q = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n padding: ", ";\n gap: ", ";\n\n ", "\n\n color: ", ";\n "])), theme.colors[active ? 'blue' : 'white'], theme.spacings.s3, theme.spacings.s3, internal ? css(_templateObject7$q || (_templateObject7$q = _taggedTemplateLiteralLoose(["\n border-radius: 4px 4px 0 0;\n\n ", "\n line-height: 17px;\n "])), function (_ref5) {
19140
19143
  var theme = _ref5.theme;
19141
19144
  return theme.useTypography('h4');
19142
- }) : css(_templateObject8$n || (_templateObject8$n = _taggedTemplateLiteralLoose(["\n box-shadow: 0px 3px 6px ", ";\n\n > span {\n ", "\n line-height: 19px;\n }\n "])), theme.getColor('black', 15), function (_ref6) {
19145
+ }) : css(_templateObject8$n || (_templateObject8$n = _taggedTemplateLiteralLoose(["\n box-shadow: 0px 3px 6px ", ";\n\n ", "\n line-height: 19px;\n "])), theme.getColor('black', 15), function (_ref6) {
19143
19146
  var theme = _ref6.theme;
19144
19147
  return theme.useTypography('h2');
19145
19148
  }), theme.colors[active ? 'white' : 'darkBlue']);
19146
19149
  });
19147
19150
 
19148
- var initialStatus = function initialStatus(active, length) {
19149
- var status = Array(length).fill('open');
19150
- status[active] = 'active';
19151
- return status;
19152
- };
19153
-
19154
- var Tabs$1 = function Tabs$1(props) {
19155
- var options = props.options,
19156
- activeState = props.activeState;
19157
- var active = activeState[0],
19158
- setActive = activeState[1];
19151
+ var _templateObject$18;
19152
+ var Close = styled.div(_templateObject$18 || (_templateObject$18 = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: calc(50% - ", " / 2);\n right: ", ";\n\n + ", " {\n /** icon width + tab gap + tab right padding */\n padding-right: ", ";\n }\n\n svg > * {\n transition-property: stroke;\n transition-duration: 0.25s;\n transition-timing-function: ease-in-out;\n }\n"])), function (_ref) {
19153
+ var theme = _ref.theme;
19154
+ return theme.spacings.s3;
19155
+ }, function (_ref2) {
19156
+ var theme = _ref2.theme;
19157
+ return theme.spacings.s3;
19158
+ }, Tab, function (_ref3) {
19159
+ var theme = _ref3.theme;
19160
+ return "calc(" + theme.spacings.s3 + " + " + theme.spacings.s3 + " + " + theme.spacings.s3 + ")";
19161
+ });
19159
19162
 
19160
- var _useState = useState(initialStatus(active, options.length)),
19161
- status = _useState[0],
19162
- setStatus = _useState[1];
19163
+ var Close$1 = function Close$1(props) {
19164
+ var index = props.index,
19165
+ _props$active = props.active,
19166
+ active = _props$active[0],
19167
+ setActive = _props$active[1],
19168
+ _props$options = props.options,
19169
+ options = _props$options[0],
19170
+ setOptions = _props$options[1];
19163
19171
 
19164
19172
  var onClose = props.onClose || function () {};
19165
19173
 
19166
- var activate = function activate(active, length) {
19167
- setStatus(function (prev) {
19168
- if (length !== undefined && length !== prev.length) {
19169
- return initialStatus(active, length);
19170
- }
19171
-
19172
- var current = prev.findIndex(function (e) {
19173
- return e === 'active';
19174
- });
19174
+ var onClickClose = useCallback(function (event) {
19175
+ if (options.length === 1) return;
19176
+ var newOptions = [].concat(options);
19177
+ newOptions.splice(index, 1);
19178
+ onClose(index, options[index], event);
19175
19179
 
19176
- if (current !== active && current > -1 && active > -1 && active < prev.length) {
19177
- var _status = [].concat(prev);
19178
-
19179
- _status[current] = 'open';
19180
- _status[active] = 'active';
19181
- return [].concat(_status);
19182
- }
19183
-
19184
- return prev;
19185
- });
19186
- };
19187
-
19188
- useEffect(function () {
19189
- activate(active, options.length);
19190
- }, [active, options.length]);
19191
- useEffect(function () {
19192
- var current = status.findIndex(function (e) {
19193
- return e === 'active';
19194
- });
19195
- setActive(current);
19196
- }, [status]);
19197
-
19198
- var onClickActivate = function onClickActivate(index, event) {
19199
- var element = event.target;
19200
-
19201
- while (element) {
19202
- if (element.tagName === 'svg') return;
19203
- element = element.parentElement;
19180
+ if (index < active || active === index && active > 0) {
19181
+ setActive(active - 1);
19204
19182
  }
19205
19183
 
19206
- activate(index);
19207
- };
19208
-
19209
- var onClickClose = function onClickClose(index, tab, event) {
19210
- var getActive = function getActive(removed, prev) {
19211
- for (var i = index - 1; i > -1; i--) {
19212
- if (removed[i] !== 'closed') {
19213
- return i;
19214
- }
19215
- }
19216
-
19217
- for (var _i = index + 1; _i < removed.length; _i++) {
19218
- if (removed[_i] !== 'closed') {
19219
- return _i;
19220
- }
19221
- }
19184
+ setOptions(newOptions);
19185
+ }, [options, active, index]);
19186
+ return React__default.createElement(Close, null, React__default.createElement(Icon, {
19187
+ type: 'feather',
19188
+ icon: 'x',
19189
+ onClick: onClickClose,
19190
+ width: '14px',
19191
+ height: '14px',
19192
+ strokeWidth: '3px',
19193
+ color: active === index ? 'white' : 'darkBlue'
19194
+ }));
19195
+ };
19222
19196
 
19223
- return prev;
19224
- };
19197
+ var VoidClose = function VoidClose() {
19198
+ return React__default.createElement(React__default.Fragment, null);
19199
+ };
19225
19200
 
19226
- setStatus(function (prev) {
19227
- if (prev[index] === 'closed') return prev;
19228
- var active = prev.findIndex(function (e) {
19229
- return e === 'active';
19230
- });
19231
- var status = [].concat(prev);
19232
- status[index] = 'closed';
19201
+ var VoidComponent = function VoidComponent() {
19202
+ return React__default.createElement(React__default.Fragment, null);
19203
+ };
19233
19204
 
19234
- if (active === index) {
19235
- var _active = getActive(status, index);
19205
+ var VoidProvider = function VoidProvider(props) {
19206
+ return React__default.createElement(React__default.Fragment, {
19207
+ children: props.children
19208
+ });
19209
+ };
19236
19210
 
19237
- status[_active] = 'active';
19238
- }
19211
+ var Tabs$1 = function Tabs$1(props) {
19212
+ var _ref = Array.isArray(props.active) ? props.active : useState(props.active),
19213
+ active = _ref[0],
19214
+ setActive = _ref[1];
19239
19215
 
19240
- return status;
19241
- });
19242
- onClose(index, tab, event);
19243
- };
19216
+ var _ref2 = typeof props.options[1] === 'function' ? props.options : useState(props.options),
19217
+ options = _ref2[0],
19218
+ setOptions = _ref2[1];
19244
19219
 
19245
- var divProps = filterObject(props, ['options', 'activeState', 'internal', 'maxTabs', 'onMaxTabsExceeded', 'onClose', 'alwaysOpen', 'delimiter', 'spacing']);
19220
+ var divProps = filterObject(props, ['options', 'active', 'internal', 'maxTabs', 'onMaxTabsExceeded', 'onClose', 'alwaysOpen', 'delimiter', 'spacing']);
19221
+ var CloseComponent = props.alwaysOpen || options.length < 2 ? VoidClose : Close$1;
19246
19222
  return React__default.createElement(Container$n, Object.assign({}, divProps), React__default.createElement(Tabs, {
19247
19223
  "$internal": props.internal,
19248
19224
  "$delimiter": props.delimiter,
19249
19225
  "$spacing": props.spacing
19250
- }, options.reduce(function (elements, tab, index) {
19251
- if (status[index] === 'closed') return elements;
19252
- return [].concat(elements, [React__default.createElement(Tab, {
19253
- key: index,
19254
- "$active": status[index] === 'active',
19226
+ }, options.map(function (tab, index) {
19227
+ return React__default.createElement("li", {
19228
+ key: index
19229
+ }, React__default.createElement(CloseComponent, {
19230
+ index: index,
19231
+ active: [active, setActive],
19232
+ options: [options, setOptions]
19233
+ }), React__default.createElement(Tab, {
19234
+ "$active": index === active,
19255
19235
  "$internal": props.internal,
19256
- onClick: function onClick(event) {
19257
- return onClickActivate(index, event);
19258
- }
19259
- }, React__default.createElement("span", null, tab.label), !props.alwaysOpen && React__default.createElement(Icon, {
19260
- type: 'feather',
19261
- icon: 'x',
19262
- onClick: function onClick(e) {
19263
- return onClickClose(index, tab, e);
19236
+ onClick: function onClick() {
19237
+ return setActive(index);
19264
19238
  },
19265
- width: '14px',
19266
- height: '14px',
19267
- strokeWidth: '3px',
19268
- color: status[index] === 'active' ? 'white' : 'darkBlue'
19269
- }))]);
19270
- }, [])), props.children && React__default.createElement("div", {
19271
- children: props.children
19239
+ children: tab.label
19240
+ }));
19241
+ })), options.map(function (tab, index) {
19242
+ var _ref3 = 'component' in tab ? tab : {},
19243
+ _ref3$component = _ref3.component,
19244
+ Component = _ref3$component === void 0 ? VoidComponent : _ref3$component,
19245
+ _ref3$provider = _ref3.provider,
19246
+ Provider = _ref3$provider === void 0 ? VoidProvider : _ref3$provider;
19247
+
19248
+ var isActive = index === active;
19249
+ return React__default.createElement(Provider, {
19250
+ key: index,
19251
+ active: isActive,
19252
+ children: isActive ? React__default.createElement("div", null, React__default.createElement(Component, null)) : undefined
19253
+ });
19272
19254
  }));
19273
19255
  };
19274
19256
 
19275
- var _templateObject$18;
19276
- var Container$o = styled.textarea(_templateObject$18 || (_templateObject$18 = _taggedTemplateLiteralLoose(["\n width: ", ";\n height: ", ";\n resize: none;\n outline: 0;\n border: 1px solid #c8c8c8;\n padding: 14px;\n border-radius: 4px;\n color: #192338;\n"])), function (props) {
19257
+ var _templateObject$19;
19258
+ var Container$o = styled.textarea(_templateObject$19 || (_templateObject$19 = _taggedTemplateLiteralLoose(["\n width: ", ";\n height: ", ";\n resize: none;\n outline: 0;\n border: 1px solid #c8c8c8;\n padding: 14px;\n border-radius: 4px;\n color: #192338;\n"])), function (props) {
19277
19259
  return "" + props.width;
19278
19260
  }, function (props) {
19279
19261
  return "" + props.height;
@@ -19283,8 +19265,8 @@ var TextArea = function TextArea(props) {
19283
19265
  return React__default.createElement(Container$o, Object.assign({}, props));
19284
19266
  };
19285
19267
 
19286
- var _templateObject$19, _templateObject2$R, _templateObject3$K, _templateObject4$x, _templateObject5$u, _templateObject6$r;
19287
- var Container$p = styled.div(_templateObject$19 || (_templateObject$19 = _taggedTemplateLiteralLoose(["\n border-radius: 4px;\n width: ", ";\n height: 88px;\n border: 1px solid transparent;\n position: relative;\n\n ", "\n\n ", "\n\n ", "\n\n svg {\n cursor: pointer;\n position: absolute;\n top: 14px;\n right: 14px;\n width: 13px;\n height: 13px;\n }\n"])), function (props) {
19268
+ var _templateObject$1a, _templateObject2$R, _templateObject3$K, _templateObject4$x, _templateObject5$u, _templateObject6$r;
19269
+ var Container$p = styled.div(_templateObject$1a || (_templateObject$1a = _taggedTemplateLiteralLoose(["\n border-radius: 4px;\n width: ", ";\n height: 88px;\n border: 1px solid transparent;\n position: relative;\n\n ", "\n\n ", "\n\n ", "\n\n svg {\n cursor: pointer;\n position: absolute;\n top: 14px;\n right: 14px;\n width: 13px;\n height: 13px;\n }\n"])), function (props) {
19288
19270
  return props.size === 'large' ? '837px' : '460px';
19289
19271
  }, function (props) {
19290
19272
  return props.color === 'success' && css(_templateObject2$R || (_templateObject2$R = _taggedTemplateLiteralLoose(["\n background-color: #fcfff5;\n opacity: 1;\n border-color: #a8c599;\n h4 {\n color: #1e561f;\n }\n p {\n color: #1e561fcc;\n }\n "])));
@@ -19306,8 +19288,8 @@ var Toast = function Toast(props) {
19306
19288
  })), React__default.createElement(IconContent, null, React__default.createElement("h4", null, props.title), React__default.createElement("p", null, " ", props.description)));
19307
19289
  };
19308
19290
 
19309
- var _templateObject$1a, _templateObject2$S, _templateObject3$L, _templateObject4$y, _templateObject5$v;
19310
- var Image = styled.img(_templateObject$1a || (_templateObject$1a = _taggedTemplateLiteralLoose(["\n max-width: 100%;\n max-height: 100%;\n"])));
19291
+ var _templateObject$1b, _templateObject2$S, _templateObject3$L, _templateObject4$y, _templateObject5$v;
19292
+ var Image = styled.img(_templateObject$1b || (_templateObject$1b = _taggedTemplateLiteralLoose(["\n max-width: 100%;\n max-height: 100%;\n"])));
19311
19293
  var Container$q = styled.div(_templateObject2$S || (_templateObject2$S = _taggedTemplateLiteralLoose(["\n position: relative;\n display: inline-flex;\n\n &,\n ", " {\n width: ", ";\n\n height: ", ";\n }\n"])), Image, function (_ref) {
19312
19294
  var width = _ref.width;
19313
19295