@mw-kit/mw-ui 1.7.100 → 1.7.102
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/components/Tabs/interfaces.d.ts +3 -1
- package/dist/index.js +98 -58
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +98 -58
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -16,10 +16,12 @@ declare type Tab<T = {}> = {
|
|
|
16
16
|
};
|
|
17
17
|
export declare type TabComponent<T = {}> = React.FunctionComponent<{
|
|
18
18
|
data: T;
|
|
19
|
+
setLabel: React.Dispatch<React.SetStateAction<string>>;
|
|
19
20
|
}>;
|
|
20
21
|
export declare type TabProvider<T = {}> = React.FunctionComponent<React.PropsWithChildren<{
|
|
21
22
|
active: boolean;
|
|
22
23
|
setTab: React.Dispatch<React.SetStateAction<Tab<T>>>;
|
|
24
|
+
setLabel: React.Dispatch<React.SetStateAction<string>>;
|
|
23
25
|
} & Tab<T>>>;
|
|
24
26
|
export declare type TabProps<T = {}> = Tab<T> & ({
|
|
25
27
|
/**
|
|
@@ -67,7 +69,7 @@ export interface TabsProps<T = {}> extends React.HTMLAttributes<HTMLDivElement>
|
|
|
67
69
|
/**
|
|
68
70
|
* callback when closing a tab
|
|
69
71
|
*/
|
|
70
|
-
onClose?: (index: number, tab: TabProps<T>, event: React.MouseEvent) =>
|
|
72
|
+
onClose?: (index: number, tab: TabProps<T>, event: React.MouseEvent) => boolean | Promise<boolean>;
|
|
71
73
|
}
|
|
72
74
|
export interface StyledTabsProps {
|
|
73
75
|
/**
|
package/dist/index.js
CHANGED
|
@@ -19350,13 +19350,74 @@ var ProgressBar = function ProgressBar(props) {
|
|
|
19350
19350
|
return React__default.createElement(Container$m, null, React__default.createElement(Progress, Object.assign({}, props), React__default.createElement("div", null)), React__default.createElement("span", null, " ", props.value || '0', "%"));
|
|
19351
19351
|
};
|
|
19352
19352
|
|
|
19353
|
-
var _templateObject$17
|
|
19354
|
-
var
|
|
19353
|
+
var _templateObject$17;
|
|
19354
|
+
var Close = styled__default.div(_templateObject$17 || (_templateObject$17 = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: calc(50% - ", " / 2);\n right: ", ";\n\n + div {\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) {
|
|
19355
|
+
var theme = _ref.theme;
|
|
19356
|
+
return theme.spacings.s3;
|
|
19357
|
+
}, function (_ref2) {
|
|
19358
|
+
var theme = _ref2.theme;
|
|
19359
|
+
return theme.spacings.s3;
|
|
19360
|
+
}, function (_ref3) {
|
|
19361
|
+
var theme = _ref3.theme;
|
|
19362
|
+
return "calc(" + theme.spacings.s3 + " + " + theme.spacings.s3 + " + " + theme.spacings.s3 + ")";
|
|
19363
|
+
});
|
|
19364
|
+
|
|
19365
|
+
var Close$1 = function Close$1(props) {
|
|
19366
|
+
var index = props.index,
|
|
19367
|
+
_props$active = props.active,
|
|
19368
|
+
active = _props$active[0],
|
|
19369
|
+
setActive = _props$active[1],
|
|
19370
|
+
_props$options = props.options,
|
|
19371
|
+
options = _props$options[0],
|
|
19372
|
+
setOptions = _props$options[1];
|
|
19373
|
+
|
|
19374
|
+
var onClose = props.onClose || function () {
|
|
19375
|
+
return true;
|
|
19376
|
+
};
|
|
19377
|
+
|
|
19378
|
+
var onClickClose = React.useCallback(function (event) {
|
|
19379
|
+
try {
|
|
19380
|
+
var _exit2 = false;
|
|
19381
|
+
if (options.length === 1) return Promise.resolve();
|
|
19382
|
+
var newOptions = [].concat(options);
|
|
19383
|
+
newOptions.splice(index, 1);
|
|
19384
|
+
return Promise.resolve(onClose(index, options[index], event)).then(function (_onClose) {
|
|
19385
|
+
if (!_onClose) {
|
|
19386
|
+
_exit2 = true;
|
|
19387
|
+
return;
|
|
19388
|
+
}
|
|
19389
|
+
|
|
19390
|
+
if (index < active) {
|
|
19391
|
+
setActive(active - 1, newOptions[active - 1].data);
|
|
19392
|
+
} else if (active === index) {
|
|
19393
|
+
var newactive = active > 0 ? active - 1 : active;
|
|
19394
|
+
setActive(newactive, newOptions[newactive].data);
|
|
19395
|
+
}
|
|
19396
|
+
|
|
19397
|
+
setOptions(newOptions);
|
|
19398
|
+
});
|
|
19399
|
+
} catch (e) {
|
|
19400
|
+
return Promise.reject(e);
|
|
19401
|
+
}
|
|
19402
|
+
}, [options, active, index]);
|
|
19403
|
+
return React__default.createElement(Close, null, React__default.createElement(Icon, {
|
|
19404
|
+
type: 'feather',
|
|
19405
|
+
icon: 'x',
|
|
19406
|
+
onClick: onClickClose,
|
|
19407
|
+
width: '14px',
|
|
19408
|
+
height: '14px',
|
|
19409
|
+
strokeWidth: '3px',
|
|
19410
|
+
color: active === index ? 'white' : 'darkBlue'
|
|
19411
|
+
}));
|
|
19412
|
+
};
|
|
19413
|
+
|
|
19414
|
+
var _templateObject$18, _templateObject2$Q, _templateObject3$J, _templateObject4$x, _templateObject5$t, _templateObject6$q, _templateObject7$q, _templateObject8$n, _templateObject9$k;
|
|
19415
|
+
var Container$n = styled__default.div(_templateObject$18 || (_templateObject$18 = _taggedTemplateLiteralLoose(["\n display: block;\n"])));
|
|
19355
19416
|
var delimiters = {
|
|
19356
19417
|
blue: ['blue'],
|
|
19357
19418
|
grey: ['warningGray']
|
|
19358
19419
|
};
|
|
19359
|
-
var Tabs = styled__default.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) {
|
|
19420
|
+
var Tabs = styled__default.ul(_templateObject2$Q || (_templateObject2$Q = _taggedTemplateLiteralLoose(["\n user-select: none;\n list-style: none;\n display: inline-flex;\n width: 100%;\n\n overflow-x: auto;\n scrollbar-width: none;\n\n ", "\n\n ", ";\n\n gap: ", ";\n\n > li {\n position: relative;\n }\n"])), function (_ref) {
|
|
19360
19421
|
var spacing = _ref.$spacing;
|
|
19361
19422
|
|
|
19362
19423
|
var _getSpacings$split = getSpacings(spacing || {}, {
|
|
@@ -19390,14 +19451,14 @@ var Tabs = styled__default.ul(_templateObject2$Q || (_templateObject2$Q = _tagge
|
|
|
19390
19451
|
internal = _ref3.$internal;
|
|
19391
19452
|
return internal ? theme.spacings.s6 : 0;
|
|
19392
19453
|
});
|
|
19393
|
-
var Tab = styled__default.div(_templateObject5$t || (_templateObject5$t = _taggedTemplateLiteralLoose(["\n ", "\n\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) {
|
|
19454
|
+
var Tab = styled__default.div(_templateObject5$t || (_templateObject5$t = _taggedTemplateLiteralLoose(["\n ", "\n\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n white-space: nowrap;\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) {
|
|
19394
19455
|
var onClick = _ref4.onClick;
|
|
19395
19456
|
return onClick && styled.css(_templateObject6$q || (_templateObject6$q = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n "])));
|
|
19396
19457
|
}, function (_ref5) {
|
|
19397
19458
|
var theme = _ref5.theme,
|
|
19398
19459
|
active = _ref5.$active,
|
|
19399
19460
|
internal = _ref5.$internal;
|
|
19400
|
-
return styled.css(_templateObject7$q || (_templateObject7$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 ? styled.css(_templateObject8$n || (_templateObject8$n = _taggedTemplateLiteralLoose(["\n border-radius: 4px 4px 0 0;\n\n ", "\n line-height: 17px;\n "])), function (_ref6) {
|
|
19461
|
+
return styled.css(_templateObject7$q || (_templateObject7$q = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n padding: calc(", " * 1.5) ", ";\n gap: ", ";\n\n ", "\n\n color: ", ";\n "])), theme.colors[active ? 'blue' : 'white'], theme.spacings.s1, theme.spacings.s3, theme.spacings.s3, internal ? styled.css(_templateObject8$n || (_templateObject8$n = _taggedTemplateLiteralLoose(["\n border-radius: 4px 4px 0 0;\n\n ", "\n line-height: 17px;\n "])), function (_ref6) {
|
|
19401
19462
|
var theme = _ref6.theme;
|
|
19402
19463
|
return theme.useTypography('h4');
|
|
19403
19464
|
}) : styled.css(_templateObject9$k || (_templateObject9$k = _taggedTemplateLiteralLoose(["\n box-shadow: 0px 3px 6px ", ";\n\n ", "\n line-height: 19px;\n "])), theme.getColor('black', 15), function (_ref7) {
|
|
@@ -19406,55 +19467,6 @@ var Tab = styled__default.div(_templateObject5$t || (_templateObject5$t = _tagge
|
|
|
19406
19467
|
}), theme.colors[active ? 'white' : 'darkBlue']);
|
|
19407
19468
|
});
|
|
19408
19469
|
|
|
19409
|
-
var _templateObject$18;
|
|
19410
|
-
var Close = styled__default.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) {
|
|
19411
|
-
var theme = _ref.theme;
|
|
19412
|
-
return theme.spacings.s3;
|
|
19413
|
-
}, function (_ref2) {
|
|
19414
|
-
var theme = _ref2.theme;
|
|
19415
|
-
return theme.spacings.s3;
|
|
19416
|
-
}, Tab, function (_ref3) {
|
|
19417
|
-
var theme = _ref3.theme;
|
|
19418
|
-
return "calc(" + theme.spacings.s3 + " + " + theme.spacings.s3 + " + " + theme.spacings.s3 + ")";
|
|
19419
|
-
});
|
|
19420
|
-
|
|
19421
|
-
var Close$1 = function Close$1(props) {
|
|
19422
|
-
var index = props.index,
|
|
19423
|
-
_props$active = props.active,
|
|
19424
|
-
active = _props$active[0],
|
|
19425
|
-
setActive = _props$active[1],
|
|
19426
|
-
_props$options = props.options,
|
|
19427
|
-
options = _props$options[0],
|
|
19428
|
-
setOptions = _props$options[1];
|
|
19429
|
-
|
|
19430
|
-
var onClose = props.onClose || function () {};
|
|
19431
|
-
|
|
19432
|
-
var onClickClose = React.useCallback(function (event) {
|
|
19433
|
-
if (options.length === 1) return;
|
|
19434
|
-
var newOptions = [].concat(options);
|
|
19435
|
-
newOptions.splice(index, 1);
|
|
19436
|
-
onClose(index, options[index], event);
|
|
19437
|
-
|
|
19438
|
-
if (index < active) {
|
|
19439
|
-
setActive(active - 1, newOptions[active - 1].data);
|
|
19440
|
-
} else if (active === index) {
|
|
19441
|
-
var newactive = active > 0 ? active - 1 : active;
|
|
19442
|
-
setActive(newactive, newOptions[newactive].data);
|
|
19443
|
-
}
|
|
19444
|
-
|
|
19445
|
-
setOptions(newOptions);
|
|
19446
|
-
}, [options, active, index]);
|
|
19447
|
-
return React__default.createElement(Close, null, React__default.createElement(Icon, {
|
|
19448
|
-
type: 'feather',
|
|
19449
|
-
icon: 'x',
|
|
19450
|
-
onClick: onClickClose,
|
|
19451
|
-
width: '14px',
|
|
19452
|
-
height: '14px',
|
|
19453
|
-
strokeWidth: '3px',
|
|
19454
|
-
color: active === index ? 'white' : 'darkBlue'
|
|
19455
|
-
}));
|
|
19456
|
-
};
|
|
19457
|
-
|
|
19458
19470
|
var VoidClose = function VoidClose() {
|
|
19459
19471
|
return React__default.createElement(React__default.Fragment, null);
|
|
19460
19472
|
};
|
|
@@ -19479,14 +19491,31 @@ var Tabs$1 = function Tabs$1(props) {
|
|
|
19479
19491
|
return React__default.createElement(Container$n, Object.assign({}, divProps), React__default.createElement(Tabs, {
|
|
19480
19492
|
"$internal": props.internal,
|
|
19481
19493
|
"$delimiter": props.delimiter,
|
|
19482
|
-
"$spacing": props.spacing
|
|
19494
|
+
"$spacing": props.spacing,
|
|
19495
|
+
onWheel: function onWheel(e) {
|
|
19496
|
+
var target = function () {
|
|
19497
|
+
var target = e.target;
|
|
19498
|
+
|
|
19499
|
+
while (target && target.tagName !== 'UL') {
|
|
19500
|
+
target = target.parentElement;
|
|
19501
|
+
}
|
|
19502
|
+
|
|
19503
|
+
return target;
|
|
19504
|
+
}();
|
|
19505
|
+
|
|
19506
|
+
if (!target) return;
|
|
19507
|
+
var x = target.offsetWidth * 100 / target.scrollWidth;
|
|
19508
|
+
target.scrollLeft += x * (e.deltaY > 0 ? 1 : -1) * 2;
|
|
19509
|
+
e.preventDefault();
|
|
19510
|
+
}
|
|
19483
19511
|
}, options.map(function (tab, index) {
|
|
19484
19512
|
return React__default.createElement("li", {
|
|
19485
19513
|
key: index
|
|
19486
19514
|
}, React__default.createElement(CloseComponent, {
|
|
19487
19515
|
index: index,
|
|
19488
19516
|
active: [active, setActive],
|
|
19489
|
-
options: [options, setOptions]
|
|
19517
|
+
options: [options, setOptions],
|
|
19518
|
+
onClose: props.onClose
|
|
19490
19519
|
}), React__default.createElement(Tab, Object.assign({}, index === active ? {
|
|
19491
19520
|
$active: true
|
|
19492
19521
|
} : {
|
|
@@ -19516,15 +19545,26 @@ var Tabs$1 = function Tabs$1(props) {
|
|
|
19516
19545
|
});
|
|
19517
19546
|
};
|
|
19518
19547
|
|
|
19548
|
+
var setLabel = function setLabel(s) {
|
|
19549
|
+
setTab(function (prev) {
|
|
19550
|
+
var label = typeof s === 'function' ? s(prev.label) : s;
|
|
19551
|
+
return s === label ? prev : _extends({}, prev, {
|
|
19552
|
+
label: label
|
|
19553
|
+
});
|
|
19554
|
+
});
|
|
19555
|
+
};
|
|
19556
|
+
|
|
19519
19557
|
return React__default.createElement(Provider, Object.assign({
|
|
19520
19558
|
key: tab.key !== undefined ? tab.key : index,
|
|
19521
19559
|
label: tab.label,
|
|
19522
19560
|
data: tab.data,
|
|
19523
|
-
setTab: setTab
|
|
19561
|
+
setTab: setTab,
|
|
19562
|
+
setLabel: setLabel
|
|
19524
19563
|
}, index === active ? {
|
|
19525
19564
|
active: true,
|
|
19526
19565
|
children: React__default.createElement("div", null, React__default.createElement(Component, {
|
|
19527
|
-
data: tab.data
|
|
19566
|
+
data: tab.data,
|
|
19567
|
+
setLabel: setLabel
|
|
19528
19568
|
}))
|
|
19529
19569
|
} : {
|
|
19530
19570
|
active: false
|