@mw-kit/mw-ui 1.7.78 → 1.7.80
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 +2 -2
- package/dist/components/Tabs/index.d.ts +2 -3
- package/dist/components/Tabs/interfaces.d.ts +16 -8
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +16 -15
- package/dist/index.modern.js.map +1 -1
- package/dist/interfaces.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TabProps, TabsProps } from '../../interfaces';
|
|
3
|
-
declare const Close: (props: Pick<TabsProps
|
|
3
|
+
declare const Close: <T>(props: Pick<TabsProps<T>, "onClose"> & {
|
|
4
4
|
index: number;
|
|
5
5
|
active: [number, React.Dispatch<React.SetStateAction<number>>];
|
|
6
|
-
options: [TabProps[], React.Dispatch<React.SetStateAction<TabProps[]>>];
|
|
6
|
+
options: [TabProps<T>[], React.Dispatch<React.SetStateAction<TabProps<T>[]>>];
|
|
7
7
|
}) => JSX.Element;
|
|
8
8
|
export default Close;
|
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SpacingOrZero, Spacings } from '../../interfaces';
|
|
3
|
-
export declare type TabComponent = React.FunctionComponent
|
|
4
|
-
|
|
3
|
+
export declare type TabComponent<T = {}> = React.FunctionComponent<{
|
|
4
|
+
data: T;
|
|
5
|
+
}>;
|
|
6
|
+
export declare type TabProvider<T = {}> = React.FunctionComponent<React.PropsWithChildren<{
|
|
5
7
|
active: boolean;
|
|
8
|
+
data: T;
|
|
6
9
|
}>>;
|
|
7
|
-
export declare type TabProps = {
|
|
10
|
+
export declare type TabProps<T = {}> = {
|
|
8
11
|
/**
|
|
9
12
|
* Define the tab label.
|
|
10
13
|
*/
|
|
11
14
|
label: string;
|
|
15
|
+
/**
|
|
16
|
+
* Define the tab data.
|
|
17
|
+
*/
|
|
18
|
+
data: T;
|
|
12
19
|
} & ({
|
|
13
20
|
/**
|
|
14
21
|
* Specifies which component, will mount/unmount everytime the tab is ACTIVATED/INACTIVATED
|
|
15
22
|
*/
|
|
16
|
-
component: TabComponent
|
|
23
|
+
component: TabComponent<T>;
|
|
17
24
|
/**
|
|
18
25
|
* Specifies the component provider, will mount/unmount when the tab is CREATED/REMOVED
|
|
19
26
|
*/
|
|
20
|
-
provider?: TabProvider
|
|
27
|
+
provider?: TabProvider<T>;
|
|
21
28
|
} | {});
|
|
22
|
-
export interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
29
|
+
export interface TabsProps<T = {}> extends React.HTMLAttributes<HTMLDivElement> {
|
|
23
30
|
/**
|
|
24
31
|
* Array with available tabs.
|
|
25
32
|
*/
|
|
26
|
-
options: TabProps[] | [TabProps[], React.Dispatch<React.SetStateAction<TabProps[]>>];
|
|
33
|
+
options: TabProps<T>[] | [TabProps<T>[], React.Dispatch<React.SetStateAction<TabProps<T>[]>>];
|
|
27
34
|
/**
|
|
28
35
|
* React state to control which tab is active.
|
|
29
36
|
*/
|
|
@@ -55,7 +62,7 @@ export interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
55
62
|
/**
|
|
56
63
|
* callback when closing a tab
|
|
57
64
|
*/
|
|
58
|
-
onClose?: (index: number, tab: TabProps
|
|
65
|
+
onClose?: (index: number, tab: TabProps<T>, event: React.MouseEvent) => void | Promise<void>;
|
|
59
66
|
}
|
|
60
67
|
export interface StyledTabsProps {
|
|
61
68
|
/**
|
|
@@ -67,3 +74,4 @@ export interface StyledTabsProps {
|
|
|
67
74
|
*/
|
|
68
75
|
$active?: boolean;
|
|
69
76
|
}
|
|
77
|
+
export declare type TabsComponent = <T = {}>(props: React.PropsWithChildren<TabsProps<T>>) => JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -19201,10 +19201,6 @@ var VoidClose = function VoidClose() {
|
|
|
19201
19201
|
return React__default.createElement(React__default.Fragment, null);
|
|
19202
19202
|
};
|
|
19203
19203
|
|
|
19204
|
-
var VoidComponent = function VoidComponent() {
|
|
19205
|
-
return React__default.createElement(React__default.Fragment, null);
|
|
19206
|
-
};
|
|
19207
|
-
|
|
19208
19204
|
var VoidProvider = function VoidProvider(props) {
|
|
19209
19205
|
return React__default.createElement(React__default.Fragment, {
|
|
19210
19206
|
children: props.children
|
|
@@ -19242,18 +19238,23 @@ var Tabs$1 = function Tabs$1(props) {
|
|
|
19242
19238
|
children: tab.label
|
|
19243
19239
|
}));
|
|
19244
19240
|
})), options.map(function (tab, index) {
|
|
19245
|
-
|
|
19246
|
-
|
|
19247
|
-
Component = _ref3$component === void 0 ? VoidComponent : _ref3$component,
|
|
19248
|
-
_ref3$provider = _ref3.provider,
|
|
19249
|
-
Provider = _ref3$provider === void 0 ? VoidProvider : _ref3$provider;
|
|
19250
|
-
|
|
19251
|
-
var isActive = index === active;
|
|
19252
|
-
return React__default.createElement(Provider, {
|
|
19253
|
-
key: index,
|
|
19254
|
-
active: isActive,
|
|
19255
|
-
children: isActive ? React__default.createElement("div", null, React__default.createElement(Component, null)) : undefined
|
|
19241
|
+
if (!('component' in tab)) return React__default.createElement(React__default.Fragment, {
|
|
19242
|
+
key: index
|
|
19256
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
|
+
data: tab.data
|
|
19250
|
+
}, index === active ? {
|
|
19251
|
+
active: true,
|
|
19252
|
+
children: React__default.createElement("div", null, React__default.createElement(Component, {
|
|
19253
|
+
data: tab.data
|
|
19254
|
+
}))
|
|
19255
|
+
} : {
|
|
19256
|
+
active: false
|
|
19257
|
+
}));
|
|
19257
19258
|
}));
|
|
19258
19259
|
};
|
|
19259
19260
|
|