@mw-kit/mw-ui 1.7.77 → 1.7.79
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/components/Close/index.d.ts +8 -0
- package/dist/components/Tabs/components/Close/styles.d.ts +1 -0
- package/dist/components/Tabs/components/index.d.ts +1 -0
- package/dist/components/Tabs/interfaces.d.ts +14 -5
- package/dist/components/Tabs/styles.d.ts +1 -1
- package/dist/index.js +93 -116
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +93 -116
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TabProps, TabsProps } from '../../interfaces';
|
|
3
|
+
declare const Close: (props: Pick<TabsProps, 'onClose'> & {
|
|
4
|
+
index: number;
|
|
5
|
+
active: [number, React.Dispatch<React.SetStateAction<number>>];
|
|
6
|
+
options: [TabProps[], React.Dispatch<React.SetStateAction<TabProps[]>>];
|
|
7
|
+
}) => JSX.Element;
|
|
8
|
+
export default Close;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Close: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Close } from './Close';
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SpacingOrZero, Spacings } from '../../interfaces';
|
|
3
|
+
export declare type TabComponent = React.FunctionComponent;
|
|
4
|
+
export declare type TabProvider = React.FunctionComponent<React.PropsWithChildren<{
|
|
5
|
+
active: boolean;
|
|
6
|
+
}>>;
|
|
3
7
|
export declare type TabProps = {
|
|
4
8
|
/**
|
|
5
9
|
* Define the tab label.
|
|
6
10
|
*/
|
|
7
11
|
label: string;
|
|
12
|
+
} & ({
|
|
8
13
|
/**
|
|
9
|
-
* Specifies which component will
|
|
14
|
+
* Specifies which component, will mount/unmount everytime the tab is ACTIVATED/INACTIVATED
|
|
10
15
|
*/
|
|
11
|
-
component
|
|
12
|
-
|
|
16
|
+
component: TabComponent;
|
|
17
|
+
/**
|
|
18
|
+
* Specifies the component provider, will mount/unmount when the tab is CREATED/REMOVED
|
|
19
|
+
*/
|
|
20
|
+
provider?: TabProvider;
|
|
21
|
+
} | {});
|
|
13
22
|
export interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
23
|
/**
|
|
15
24
|
* Array with available tabs.
|
|
16
25
|
*/
|
|
17
|
-
options: TabProps[];
|
|
26
|
+
options: TabProps[] | [TabProps[], React.Dispatch<React.SetStateAction<TabProps[]>>];
|
|
18
27
|
/**
|
|
19
28
|
* React state to control which tab is active.
|
|
20
29
|
*/
|
|
21
|
-
|
|
30
|
+
active: number | [number, React.Dispatch<React.SetStateAction<number>>];
|
|
22
31
|
/**
|
|
23
32
|
* Sets the style of the tabs to internal.
|
|
24
33
|
*/
|
|
@@ -6,5 +6,5 @@ declare type TabsContainerProps = {
|
|
|
6
6
|
$spacing?: TabsProps['spacing'];
|
|
7
7
|
};
|
|
8
8
|
export declare const Tabs: import("styled-components").StyledComponent<"ul", import("styled-components").DefaultTheme, TabsContainerProps, never>;
|
|
9
|
-
export declare const Tab: import("styled-components").StyledComponent<"
|
|
9
|
+
export declare const Tab: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, StyledTabsProps, never>;
|
|
10
10
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -19104,7 +19104,7 @@ var delimiters = {
|
|
|
19104
19104
|
blue: ['blue'],
|
|
19105
19105
|
grey: ['warningGray']
|
|
19106
19106
|
};
|
|
19107
|
-
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"])), function (_ref) {
|
|
19107
|
+
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) {
|
|
19108
19108
|
var spacing = _ref.$spacing;
|
|
19109
19109
|
|
|
19110
19110
|
var _getSpacings$split = getSpacings(spacing || {}, {
|
|
@@ -19138,148 +19138,125 @@ var Tabs = styled__default.ul(_templateObject2$Q || (_templateObject2$Q = _tagge
|
|
|
19138
19138
|
internal = _ref3.$internal;
|
|
19139
19139
|
return internal ? theme.spacings.s6 : 0;
|
|
19140
19140
|
});
|
|
19141
|
-
var Tab = styled__default.
|
|
19141
|
+
var Tab = styled__default.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) {
|
|
19142
19142
|
var theme = _ref4.theme,
|
|
19143
19143
|
active = _ref4.$active,
|
|
19144
19144
|
internal = _ref4.$internal;
|
|
19145
|
-
return styled.css(_templateObject6$q || (_templateObject6$q = _taggedTemplateLiteralLoose(["\n background-color: ", ";\n padding: ", ";\n gap: ", ";\n\n ", "\n\n
|
|
19145
|
+
return styled.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 ? styled.css(_templateObject7$q || (_templateObject7$q = _taggedTemplateLiteralLoose(["\n border-radius: 4px 4px 0 0;\n\n ", "\n line-height: 17px;\n "])), function (_ref5) {
|
|
19146
19146
|
var theme = _ref5.theme;
|
|
19147
19147
|
return theme.useTypography('h4');
|
|
19148
|
-
}) : styled.css(_templateObject8$n || (_templateObject8$n = _taggedTemplateLiteralLoose(["\n box-shadow: 0px 3px 6px ", ";\n\n
|
|
19148
|
+
}) : styled.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) {
|
|
19149
19149
|
var theme = _ref6.theme;
|
|
19150
19150
|
return theme.useTypography('h2');
|
|
19151
19151
|
}), theme.colors[active ? 'white' : 'darkBlue']);
|
|
19152
19152
|
});
|
|
19153
19153
|
|
|
19154
|
-
var
|
|
19155
|
-
|
|
19156
|
-
|
|
19157
|
-
return
|
|
19158
|
-
}
|
|
19159
|
-
|
|
19160
|
-
|
|
19161
|
-
|
|
19162
|
-
|
|
19163
|
-
|
|
19164
|
-
|
|
19154
|
+
var _templateObject$18;
|
|
19155
|
+
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) {
|
|
19156
|
+
var theme = _ref.theme;
|
|
19157
|
+
return theme.spacings.s3;
|
|
19158
|
+
}, function (_ref2) {
|
|
19159
|
+
var theme = _ref2.theme;
|
|
19160
|
+
return theme.spacings.s3;
|
|
19161
|
+
}, Tab, function (_ref3) {
|
|
19162
|
+
var theme = _ref3.theme;
|
|
19163
|
+
return "calc(" + theme.spacings.s3 + " + " + theme.spacings.s3 + " + " + theme.spacings.s3 + ")";
|
|
19164
|
+
});
|
|
19165
19165
|
|
|
19166
|
-
|
|
19167
|
-
|
|
19168
|
-
|
|
19166
|
+
var Close$1 = function Close$1(props) {
|
|
19167
|
+
var index = props.index,
|
|
19168
|
+
_props$active = props.active,
|
|
19169
|
+
active = _props$active[0],
|
|
19170
|
+
setActive = _props$active[1],
|
|
19171
|
+
_props$options = props.options,
|
|
19172
|
+
options = _props$options[0],
|
|
19173
|
+
setOptions = _props$options[1];
|
|
19169
19174
|
|
|
19170
19175
|
var onClose = props.onClose || function () {};
|
|
19171
19176
|
|
|
19172
|
-
var
|
|
19173
|
-
|
|
19174
|
-
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
|
|
19178
|
-
var current = prev.findIndex(function (e) {
|
|
19179
|
-
return e === 'active';
|
|
19180
|
-
});
|
|
19181
|
-
|
|
19182
|
-
if (current !== active && current > -1 && active > -1 && active < prev.length) {
|
|
19183
|
-
var _status = [].concat(prev);
|
|
19177
|
+
var onClickClose = React.useCallback(function (event) {
|
|
19178
|
+
if (options.length === 1) return;
|
|
19179
|
+
var newOptions = [].concat(options);
|
|
19180
|
+
newOptions.splice(index, 1);
|
|
19181
|
+
onClose(index, options[index], event);
|
|
19184
19182
|
|
|
19185
|
-
|
|
19186
|
-
|
|
19187
|
-
return [].concat(_status);
|
|
19188
|
-
}
|
|
19189
|
-
|
|
19190
|
-
return prev;
|
|
19191
|
-
});
|
|
19192
|
-
};
|
|
19193
|
-
|
|
19194
|
-
React.useEffect(function () {
|
|
19195
|
-
activate(active, options.length);
|
|
19196
|
-
}, [active, options.length]);
|
|
19197
|
-
React.useEffect(function () {
|
|
19198
|
-
var current = status.findIndex(function (e) {
|
|
19199
|
-
return e === 'active';
|
|
19200
|
-
});
|
|
19201
|
-
setActive(current);
|
|
19202
|
-
}, [status]);
|
|
19203
|
-
|
|
19204
|
-
var onClickActivate = function onClickActivate(index, event) {
|
|
19205
|
-
var element = event.target;
|
|
19206
|
-
|
|
19207
|
-
while (element) {
|
|
19208
|
-
if (element.tagName === 'svg') return;
|
|
19209
|
-
element = element.parentElement;
|
|
19183
|
+
if (index < active || active === index && active > 0) {
|
|
19184
|
+
setActive(active - 1);
|
|
19210
19185
|
}
|
|
19211
19186
|
|
|
19212
|
-
|
|
19213
|
-
};
|
|
19214
|
-
|
|
19215
|
-
|
|
19216
|
-
|
|
19217
|
-
|
|
19218
|
-
|
|
19219
|
-
|
|
19220
|
-
|
|
19221
|
-
|
|
19222
|
-
|
|
19223
|
-
|
|
19224
|
-
if (removed[_i] !== 'closed') {
|
|
19225
|
-
return _i;
|
|
19226
|
-
}
|
|
19227
|
-
}
|
|
19228
|
-
|
|
19229
|
-
return prev;
|
|
19230
|
-
};
|
|
19187
|
+
setOptions(newOptions);
|
|
19188
|
+
}, [options, active, index]);
|
|
19189
|
+
return React__default.createElement(Close, null, React__default.createElement(Icon, {
|
|
19190
|
+
type: 'feather',
|
|
19191
|
+
icon: 'x',
|
|
19192
|
+
onClick: onClickClose,
|
|
19193
|
+
width: '14px',
|
|
19194
|
+
height: '14px',
|
|
19195
|
+
strokeWidth: '3px',
|
|
19196
|
+
color: active === index ? 'white' : 'darkBlue'
|
|
19197
|
+
}));
|
|
19198
|
+
};
|
|
19231
19199
|
|
|
19232
|
-
|
|
19233
|
-
|
|
19234
|
-
|
|
19235
|
-
return e === 'active';
|
|
19236
|
-
});
|
|
19237
|
-
var status = [].concat(prev);
|
|
19238
|
-
status[index] = 'closed';
|
|
19200
|
+
var VoidClose = function VoidClose() {
|
|
19201
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
19202
|
+
};
|
|
19239
19203
|
|
|
19240
|
-
|
|
19241
|
-
|
|
19204
|
+
var VoidProvider = function VoidProvider(props) {
|
|
19205
|
+
return React__default.createElement(React__default.Fragment, {
|
|
19206
|
+
children: props.children
|
|
19207
|
+
});
|
|
19208
|
+
};
|
|
19242
19209
|
|
|
19243
|
-
|
|
19244
|
-
|
|
19210
|
+
var Tabs$1 = function Tabs$1(props) {
|
|
19211
|
+
var _ref = Array.isArray(props.active) ? props.active : React.useState(props.active),
|
|
19212
|
+
active = _ref[0],
|
|
19213
|
+
setActive = _ref[1];
|
|
19245
19214
|
|
|
19246
|
-
|
|
19247
|
-
|
|
19248
|
-
|
|
19249
|
-
};
|
|
19215
|
+
var _ref2 = typeof props.options[1] === 'function' ? props.options : React.useState(props.options),
|
|
19216
|
+
options = _ref2[0],
|
|
19217
|
+
setOptions = _ref2[1];
|
|
19250
19218
|
|
|
19251
|
-
var divProps = filterObject(props, ['options', '
|
|
19219
|
+
var divProps = filterObject(props, ['options', 'active', 'internal', 'maxTabs', 'onMaxTabsExceeded', 'onClose', 'alwaysOpen', 'delimiter', 'spacing']);
|
|
19220
|
+
var CloseComponent = props.alwaysOpen || options.length < 2 ? VoidClose : Close$1;
|
|
19252
19221
|
return React__default.createElement(Container$n, Object.assign({}, divProps), React__default.createElement(Tabs, {
|
|
19253
19222
|
"$internal": props.internal,
|
|
19254
19223
|
"$delimiter": props.delimiter,
|
|
19255
19224
|
"$spacing": props.spacing
|
|
19256
|
-
}, options.
|
|
19257
|
-
|
|
19258
|
-
|
|
19259
|
-
|
|
19260
|
-
|
|
19225
|
+
}, options.map(function (tab, index) {
|
|
19226
|
+
return React__default.createElement("li", {
|
|
19227
|
+
key: index
|
|
19228
|
+
}, React__default.createElement(CloseComponent, {
|
|
19229
|
+
index: index,
|
|
19230
|
+
active: [active, setActive],
|
|
19231
|
+
options: [options, setOptions]
|
|
19232
|
+
}), React__default.createElement(Tab, {
|
|
19233
|
+
"$active": index === active,
|
|
19261
19234
|
"$internal": props.internal,
|
|
19262
|
-
onClick: function onClick(
|
|
19263
|
-
return
|
|
19264
|
-
}
|
|
19265
|
-
}, React__default.createElement("span", null, tab.label), !props.alwaysOpen && React__default.createElement(Icon, {
|
|
19266
|
-
type: 'feather',
|
|
19267
|
-
icon: 'x',
|
|
19268
|
-
onClick: function onClick(e) {
|
|
19269
|
-
return onClickClose(index, tab, e);
|
|
19235
|
+
onClick: function onClick() {
|
|
19236
|
+
return setActive(index);
|
|
19270
19237
|
},
|
|
19271
|
-
|
|
19272
|
-
|
|
19273
|
-
|
|
19274
|
-
|
|
19275
|
-
|
|
19276
|
-
|
|
19277
|
-
|
|
19238
|
+
children: tab.label
|
|
19239
|
+
}));
|
|
19240
|
+
})), options.map(function (tab, index) {
|
|
19241
|
+
if (!('component' in tab)) return React__default.createElement(React__default.Fragment, {
|
|
19242
|
+
key: index
|
|
19243
|
+
});
|
|
19244
|
+
var _tab$provider = tab.provider,
|
|
19245
|
+
Provider = _tab$provider === void 0 ? VoidProvider : _tab$provider,
|
|
19246
|
+
Component = tab.component;
|
|
19247
|
+
return React__default.createElement(Provider, Object.assign({
|
|
19248
|
+
key: index
|
|
19249
|
+
}, index === active ? {
|
|
19250
|
+
active: true,
|
|
19251
|
+
children: React__default.createElement("div", null, React__default.createElement(Component, null))
|
|
19252
|
+
} : {
|
|
19253
|
+
active: false
|
|
19254
|
+
}));
|
|
19278
19255
|
}));
|
|
19279
19256
|
};
|
|
19280
19257
|
|
|
19281
|
-
var _templateObject$
|
|
19282
|
-
var Container$o = styled__default.textarea(_templateObject$
|
|
19258
|
+
var _templateObject$19;
|
|
19259
|
+
var Container$o = styled__default.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) {
|
|
19283
19260
|
return "" + props.width;
|
|
19284
19261
|
}, function (props) {
|
|
19285
19262
|
return "" + props.height;
|
|
@@ -19289,8 +19266,8 @@ var TextArea = function TextArea(props) {
|
|
|
19289
19266
|
return React__default.createElement(Container$o, Object.assign({}, props));
|
|
19290
19267
|
};
|
|
19291
19268
|
|
|
19292
|
-
var _templateObject$
|
|
19293
|
-
var Container$p = styled__default.div(_templateObject$
|
|
19269
|
+
var _templateObject$1a, _templateObject2$R, _templateObject3$K, _templateObject4$x, _templateObject5$u, _templateObject6$r;
|
|
19270
|
+
var Container$p = styled__default.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) {
|
|
19294
19271
|
return props.size === 'large' ? '837px' : '460px';
|
|
19295
19272
|
}, function (props) {
|
|
19296
19273
|
return props.color === 'success' && styled.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 "])));
|
|
@@ -19312,8 +19289,8 @@ var Toast = function Toast(props) {
|
|
|
19312
19289
|
})), React__default.createElement(IconContent, null, React__default.createElement("h4", null, props.title), React__default.createElement("p", null, " ", props.description)));
|
|
19313
19290
|
};
|
|
19314
19291
|
|
|
19315
|
-
var _templateObject$
|
|
19316
|
-
var Image = styled__default.img(_templateObject$
|
|
19292
|
+
var _templateObject$1b, _templateObject2$S, _templateObject3$L, _templateObject4$y, _templateObject5$v;
|
|
19293
|
+
var Image = styled__default.img(_templateObject$1b || (_templateObject$1b = _taggedTemplateLiteralLoose(["\n max-width: 100%;\n max-height: 100%;\n"])));
|
|
19317
19294
|
var Container$q = styled__default.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) {
|
|
19318
19295
|
var width = _ref.width;
|
|
19319
19296
|
|