@mw-kit/mw-ui 1.7.79 → 1.7.81

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.
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TabProps, TabsProps } from '../../interfaces';
3
- declare const Close: (props: Pick<TabsProps, 'onClose'> & {
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,4 +1,3 @@
1
- import React from 'react';
2
- import { TabsProps } from './interfaces';
3
- declare const Tabs: (props: React.PropsWithChildren<TabsProps>) => JSX.Element;
1
+ import { TabsComponent } from './interfaces';
2
+ declare const Tabs: TabsComponent;
4
3
  export default Tabs;
@@ -1,29 +1,36 @@
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<{
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, event: React.MouseEvent) => void | Promise<void>;
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
@@ -19098,7 +19098,7 @@ var ProgressBar = function ProgressBar(props) {
19098
19098
  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', "%"));
19099
19099
  };
19100
19100
 
19101
- var _templateObject$17, _templateObject2$Q, _templateObject3$J, _templateObject4$w, _templateObject5$t, _templateObject6$q, _templateObject7$q, _templateObject8$n;
19101
+ var _templateObject$17, _templateObject2$Q, _templateObject3$J, _templateObject4$w, _templateObject5$t, _templateObject6$q, _templateObject7$q, _templateObject8$n, _templateObject9$k;
19102
19102
  var Container$n = styled__default.div(_templateObject$17 || (_templateObject$17 = _taggedTemplateLiteralLoose(["\n display: block;\n"])));
19103
19103
  var delimiters = {
19104
19104
  blue: ['blue'],
@@ -19138,15 +19138,18 @@ 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.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
- var theme = _ref4.theme,
19143
- active = _ref4.$active,
19144
- internal = _ref4.$internal;
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
- var theme = _ref5.theme;
19147
- return theme.useTypography('h4');
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) {
19141
+ 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) {
19142
+ var onClick = _ref4.onClick;
19143
+ return onClick && styled.css(_templateObject6$q || (_templateObject6$q = _taggedTemplateLiteralLoose(["\n cursor: pointer;\n "])));
19144
+ }, function (_ref5) {
19145
+ var theme = _ref5.theme,
19146
+ active = _ref5.$active,
19147
+ internal = _ref5.$internal;
19148
+ 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) {
19149
19149
  var theme = _ref6.theme;
19150
+ return theme.useTypography('h4');
19151
+ }) : 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) {
19152
+ var theme = _ref7.theme;
19150
19153
  return theme.useTypography('h2');
19151
19154
  }), theme.colors[active ? 'white' : 'darkBlue']);
19152
19155
  });
@@ -19229,14 +19232,16 @@ var Tabs$1 = function Tabs$1(props) {
19229
19232
  index: index,
19230
19233
  active: [active, setActive],
19231
19234
  options: [options, setOptions]
19232
- }), React__default.createElement(Tab, {
19233
- "$active": index === active,
19234
- "$internal": props.internal,
19235
+ }), React__default.createElement(Tab, Object.assign({}, index === active ? {
19236
+ $active: true
19237
+ } : {
19235
19238
  onClick: function onClick() {
19236
19239
  return setActive(index);
19237
- },
19240
+ }
19241
+ }, {
19242
+ "$internal": props.internal,
19238
19243
  children: tab.label
19239
- }));
19244
+ })));
19240
19245
  })), options.map(function (tab, index) {
19241
19246
  if (!('component' in tab)) return React__default.createElement(React__default.Fragment, {
19242
19247
  key: index
@@ -19245,10 +19250,13 @@ var Tabs$1 = function Tabs$1(props) {
19245
19250
  Provider = _tab$provider === void 0 ? VoidProvider : _tab$provider,
19246
19251
  Component = tab.component;
19247
19252
  return React__default.createElement(Provider, Object.assign({
19248
- key: index
19253
+ key: index,
19254
+ data: tab.data
19249
19255
  }, index === active ? {
19250
19256
  active: true,
19251
- children: React__default.createElement("div", null, React__default.createElement(Component, null))
19257
+ children: React__default.createElement("div", null, React__default.createElement(Component, {
19258
+ data: tab.data
19259
+ }))
19252
19260
  } : {
19253
19261
  active: false
19254
19262
  }));