@mw-kit/mw-ui 1.7.77 → 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.
@@ -19101,7 +19101,7 @@ var delimiters = {
19101
19101
  blue: ['blue'],
19102
19102
  grey: ['warningGray']
19103
19103
  };
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"])), 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) {
19105
19105
  var spacing = _ref.$spacing;
19106
19106
 
19107
19107
  var _getSpacings$split = getSpacings(spacing || {}, {
@@ -19135,148 +19135,127 @@ var Tabs = styled.ul(_templateObject2$Q || (_templateObject2$Q = _taggedTemplate
19135
19135
  internal = _ref3.$internal;
19136
19136
  return internal ? theme.spacings.s6 : 0;
19137
19137
  });
19138
- 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) {
19139
19139
  var theme = _ref4.theme,
19140
19140
  active = _ref4.$active,
19141
19141
  internal = _ref4.$internal;
19142
- 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) {
19143
19143
  var theme = _ref5.theme;
19144
19144
  return theme.useTypography('h4');
19145
- }) : 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) {
19146
19146
  var theme = _ref6.theme;
19147
19147
  return theme.useTypography('h2');
19148
19148
  }), theme.colors[active ? 'white' : 'darkBlue']);
19149
19149
  });
19150
19150
 
19151
- var initialStatus = function initialStatus(active, length) {
19152
- var status = Array(length).fill('open');
19153
- status[active] = 'active';
19154
- return status;
19155
- };
19156
-
19157
- var Tabs$1 = function Tabs$1(props) {
19158
- var options = props.options,
19159
- activeState = props.activeState;
19160
- var active = activeState[0],
19161
- 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
+ });
19162
19162
 
19163
- var _useState = useState(initialStatus(active, options.length)),
19164
- status = _useState[0],
19165
- 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];
19166
19171
 
19167
19172
  var onClose = props.onClose || function () {};
19168
19173
 
19169
- var activate = function activate(active, length) {
19170
- setStatus(function (prev) {
19171
- if (length !== undefined && length !== prev.length) {
19172
- return initialStatus(active, length);
19173
- }
19174
-
19175
- var current = prev.findIndex(function (e) {
19176
- return e === 'active';
19177
- });
19178
-
19179
- if (current !== active && current > -1 && active > -1 && active < prev.length) {
19180
- var _status = [].concat(prev);
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);
19181
19179
 
19182
- _status[current] = 'open';
19183
- _status[active] = 'active';
19184
- return [].concat(_status);
19185
- }
19186
-
19187
- return prev;
19188
- });
19189
- };
19190
-
19191
- useEffect(function () {
19192
- activate(active, options.length);
19193
- }, [active, options.length]);
19194
- useEffect(function () {
19195
- var current = status.findIndex(function (e) {
19196
- return e === 'active';
19197
- });
19198
- setActive(current);
19199
- }, [status]);
19200
-
19201
- var onClickActivate = function onClickActivate(index, event) {
19202
- var element = event.target;
19203
-
19204
- while (element) {
19205
- if (element.tagName === 'svg') return;
19206
- element = element.parentElement;
19180
+ if (index < active || active === index && active > 0) {
19181
+ setActive(active - 1);
19207
19182
  }
19208
19183
 
19209
- activate(index);
19210
- };
19211
-
19212
- var onClickClose = function onClickClose(index, tab, event) {
19213
- var getActive = function getActive(removed, prev) {
19214
- for (var i = index - 1; i > -1; i--) {
19215
- if (removed[i] !== 'closed') {
19216
- return i;
19217
- }
19218
- }
19219
-
19220
- for (var _i = index + 1; _i < removed.length; _i++) {
19221
- if (removed[_i] !== 'closed') {
19222
- return _i;
19223
- }
19224
- }
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
+ };
19225
19196
 
19226
- return prev;
19227
- };
19197
+ var VoidClose = function VoidClose() {
19198
+ return React__default.createElement(React__default.Fragment, null);
19199
+ };
19228
19200
 
19229
- setStatus(function (prev) {
19230
- if (prev[index] === 'closed') return prev;
19231
- var active = prev.findIndex(function (e) {
19232
- return e === 'active';
19233
- });
19234
- var status = [].concat(prev);
19235
- status[index] = 'closed';
19201
+ var VoidComponent = function VoidComponent() {
19202
+ return React__default.createElement(React__default.Fragment, null);
19203
+ };
19236
19204
 
19237
- if (active === index) {
19238
- 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
+ };
19239
19210
 
19240
- status[_active] = 'active';
19241
- }
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];
19242
19215
 
19243
- return status;
19244
- });
19245
- onClose(index, tab, event);
19246
- };
19216
+ var _ref2 = typeof props.options[1] === 'function' ? props.options : useState(props.options),
19217
+ options = _ref2[0],
19218
+ setOptions = _ref2[1];
19247
19219
 
19248
- 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;
19249
19222
  return React__default.createElement(Container$n, Object.assign({}, divProps), React__default.createElement(Tabs, {
19250
19223
  "$internal": props.internal,
19251
19224
  "$delimiter": props.delimiter,
19252
19225
  "$spacing": props.spacing
19253
- }, options.reduce(function (elements, tab, index) {
19254
- if (status[index] === 'closed') return elements;
19255
- return [].concat(elements, [React__default.createElement(Tab, {
19256
- key: index,
19257
- "$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,
19258
19235
  "$internal": props.internal,
19259
- onClick: function onClick(event) {
19260
- return onClickActivate(index, event);
19261
- }
19262
- }, React__default.createElement("span", null, tab.label), !props.alwaysOpen && React__default.createElement(Icon, {
19263
- type: 'feather',
19264
- icon: 'x',
19265
- onClick: function onClick(e) {
19266
- return onClickClose(index, tab, e);
19236
+ onClick: function onClick() {
19237
+ return setActive(index);
19267
19238
  },
19268
- width: '14px',
19269
- height: '14px',
19270
- strokeWidth: '3px',
19271
- color: status[index] === 'active' ? 'white' : 'darkBlue'
19272
- }))]);
19273
- }, [])), props.children && React__default.createElement("div", {
19274
- 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
+ });
19275
19254
  }));
19276
19255
  };
19277
19256
 
19278
- var _templateObject$18;
19279
- 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) {
19280
19259
  return "" + props.width;
19281
19260
  }, function (props) {
19282
19261
  return "" + props.height;
@@ -19286,8 +19265,8 @@ var TextArea = function TextArea(props) {
19286
19265
  return React__default.createElement(Container$o, Object.assign({}, props));
19287
19266
  };
19288
19267
 
19289
- var _templateObject$19, _templateObject2$R, _templateObject3$K, _templateObject4$x, _templateObject5$u, _templateObject6$r;
19290
- 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) {
19291
19270
  return props.size === 'large' ? '837px' : '460px';
19292
19271
  }, function (props) {
19293
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 "])));
@@ -19309,8 +19288,8 @@ var Toast = function Toast(props) {
19309
19288
  })), React__default.createElement(IconContent, null, React__default.createElement("h4", null, props.title), React__default.createElement("p", null, " ", props.description)));
19310
19289
  };
19311
19290
 
19312
- var _templateObject$1a, _templateObject2$S, _templateObject3$L, _templateObject4$y, _templateObject5$v;
19313
- 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"])));
19314
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) {
19315
19294
  var width = _ref.width;
19316
19295