@toptal/picasso-tabs 5.0.15-alpha-ff-7-tabs-2a3da7cea.16 → 5.0.15-alpha-bill-root-ref-context-42c3d2541.6
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-package/src/Tab/Tab.d.ts +10 -7
- package/dist-package/src/Tab/Tab.d.ts.map +1 -1
- package/dist-package/src/Tab/Tab.js +26 -73
- package/dist-package/src/Tab/Tab.js.map +1 -1
- package/dist-package/src/Tab/index.d.ts +4 -1
- package/dist-package/src/Tab/index.d.ts.map +1 -1
- package/dist-package/src/Tab/index.js.map +1 -1
- package/dist-package/src/Tab/styles.d.ts +4 -0
- package/dist-package/src/Tab/styles.d.ts.map +1 -0
- package/dist-package/src/Tab/styles.js +95 -0
- package/dist-package/src/Tab/styles.js.map +1 -0
- package/dist-package/src/TabScrollButton/TabScrollButton.d.ts +12 -0
- package/dist-package/src/TabScrollButton/TabScrollButton.d.ts.map +1 -0
- package/dist-package/src/TabScrollButton/TabScrollButton.js +30 -0
- package/dist-package/src/TabScrollButton/TabScrollButton.js.map +1 -0
- package/dist-package/src/TabScrollButton/index.d.ts +5 -0
- package/dist-package/src/TabScrollButton/index.d.ts.map +1 -0
- package/dist-package/src/TabScrollButton/index.js +2 -0
- package/dist-package/src/TabScrollButton/index.js.map +1 -0
- package/dist-package/src/Tabs/Tabs.d.ts +12 -15
- package/dist-package/src/Tabs/Tabs.d.ts.map +1 -1
- package/dist-package/src/Tabs/Tabs.js +17 -71
- package/dist-package/src/Tabs/Tabs.js.map +1 -1
- package/dist-package/src/Tabs/index.d.ts +5 -1
- package/dist-package/src/Tabs/index.d.ts.map +1 -1
- package/dist-package/src/Tabs/index.js.map +1 -1
- package/dist-package/src/Tabs/styles.d.ts +4 -0
- package/dist-package/src/Tabs/styles.d.ts.map +1 -0
- package/dist-package/src/Tabs/styles.js +41 -0
- package/dist-package/src/Tabs/styles.js.map +1 -0
- package/dist-package/src/Tabs/use-tab-action.d.ts +5 -0
- package/dist-package/src/Tabs/use-tab-action.d.ts.map +1 -0
- package/dist-package/src/Tabs/use-tab-action.js +21 -0
- package/dist-package/src/Tabs/use-tab-action.js.map +1 -0
- package/dist-package/src/TabsCompound/index.d.ts +4 -6
- package/dist-package/src/TabsCompound/index.d.ts.map +1 -1
- package/dist-package/src/index.d.ts +1 -0
- package/dist-package/src/index.d.ts.map +1 -1
- package/dist-package/src/index.js +1 -0
- package/dist-package/src/index.js.map +1 -1
- package/package.json +13 -13
- package/src/Tab/Tab.tsx +79 -149
- package/src/Tab/__snapshots__/test.tsx.snap +45 -29
- package/src/Tab/index.ts +6 -1
- package/src/Tab/story/CustomValue.example.tsx +2 -2
- package/src/Tab/story/IconOrBadge.example.tsx +3 -3
- package/src/Tab/styles.ts +107 -0
- package/src/TabScrollButton/TabScrollButton.tsx +59 -0
- package/src/TabScrollButton/index.ts +6 -0
- package/src/Tabs/Tabs.tsx +60 -145
- package/src/Tabs/__snapshots__/test.tsx.snap +76 -45
- package/src/Tabs/index.ts +7 -1
- package/src/Tabs/story/Default.example.tsx +6 -7
- package/src/Tabs/styles.ts +45 -0
- package/src/Tabs/test.tsx +14 -16
- package/src/Tabs/use-tab-action.ts +27 -0
- package/src/index.ts +1 -0
- package/dist-package/src/Tabs/TabsContext.d.ts +0 -11
- package/dist-package/src/Tabs/TabsContext.d.ts.map +0 -1
- package/dist-package/src/Tabs/TabsContext.js +0 -16
- package/dist-package/src/Tabs/TabsContext.js.map +0 -1
- package/src/Tabs/TabsContext.tsx +0 -27
@@ -1,13 +1,15 @@
|
|
1
|
-
import type { ReactNode, HTMLAttributes, ReactElement
|
1
|
+
import type { ReactNode, HTMLAttributes, ReactElement } from 'react';
|
2
|
+
import React from 'react';
|
3
|
+
import type { TabProps } from '@material-ui/core';
|
2
4
|
import type { BaseProps, TextLabelProps } from '@toptal/picasso-shared';
|
3
|
-
export interface
|
5
|
+
export interface Props extends BaseProps, TextLabelProps, Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
4
6
|
/**
|
5
7
|
* If true, the tab will be disabled
|
6
8
|
* @default false
|
7
9
|
*/
|
8
10
|
disabled?: boolean;
|
9
|
-
/**
|
10
|
-
value?:
|
11
|
+
/** You can provide your own value. Otherwise, we fallback to the child position index */
|
12
|
+
value?: TabProps['value'];
|
11
13
|
/** The label element */
|
12
14
|
label?: ReactNode;
|
13
15
|
/** The Icon element */
|
@@ -16,9 +18,10 @@ export interface TabProps<T = number> extends BaseProps, TextLabelProps, Omit<HT
|
|
16
18
|
avatar?: string | null;
|
17
19
|
/** Description */
|
18
20
|
description?: string;
|
21
|
+
selected?: boolean;
|
22
|
+
onChange?: TabProps['onChange'];
|
23
|
+
onClick?: TabProps['onClick'];
|
19
24
|
}
|
20
|
-
export declare const Tab: <
|
21
|
-
ref?: Ref<HTMLButtonElement> | undefined;
|
22
|
-
}) => ReactElement | null;
|
25
|
+
export declare const Tab: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
23
26
|
export default Tab;
|
24
27
|
//# sourceMappingURL=Tab.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/Tab/Tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,
|
1
|
+
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/Tab/Tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AACpE,OAAO,KAAiC,MAAM,OAAO,CAAA;AAGrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AASvE,MAAM,WAAW,KACf,SAAQ,SAAS,EACf,cAAc,EACd,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IAClD;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB,yFAAyF;IACzF,KAAK,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAEzB,wBAAwB;IACxB,KAAK,CAAC,EAAE,SAAS,CAAA;IAEjB,uBAAuB;IACvB,IAAI,CAAC,EAAE,YAAY,CAAA;IAEnB,gBAAgB;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAEtB,kBAAkB;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IAIpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;IAC/B,OAAO,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;CAC9B;AAID,eAAO,MAAM,GAAG,8EA+Cd,CAAA;AAyDF,eAAe,GAAG,CAAA"}
|
@@ -9,56 +9,37 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
9
9
|
}
|
10
10
|
return t;
|
11
11
|
};
|
12
|
-
import React, { forwardRef } from 'react';
|
12
|
+
import React, { forwardRef, useContext } from 'react';
|
13
|
+
import { makeStyles } from '@material-ui/core/styles';
|
14
|
+
import { Tab as MUITab } from '@material-ui/core';
|
13
15
|
import { useTitleCase } from '@toptal/picasso-shared';
|
14
16
|
import { UserBadge } from '@toptal/picasso-user-badge';
|
15
|
-
import
|
16
|
-
import {
|
17
|
+
import styles from './styles';
|
18
|
+
import { TabsOrientationContext } from '../Tabs/Tabs';
|
17
19
|
import { TabLabel } from '../TabLabel';
|
18
20
|
import { TabDescription } from '../TabDescription';
|
19
|
-
const
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
],
|
39
|
-
vertical: [
|
40
|
-
' first:mt-4 last:mb-4 my-1 mx-0 py-2 px-4',
|
41
|
-
'text-left rounded-l-sm rounded-r-none transition-all',
|
42
|
-
'w-full overflow-hidden',
|
43
|
-
selected && 'shadow-1',
|
44
|
-
selected && [
|
45
|
-
'before:absolute',
|
46
|
-
'before:content-[""]',
|
47
|
-
'before:bottom-0',
|
48
|
-
'before:left-0',
|
49
|
-
'before:top-0',
|
50
|
-
'before:w-[3px]',
|
51
|
-
'before:bg-blue-500',
|
52
|
-
],
|
53
|
-
selected
|
54
|
-
? 'bg-gray-50 text-black'
|
55
|
-
: 'bg-gray-100 hover:bg-gray-200 text-graphite-700 hover:text-black',
|
56
|
-
],
|
21
|
+
const useStyles = makeStyles(styles, { name: 'PicassoTab' });
|
22
|
+
export const Tab = forwardRef(function Tab(props, ref) {
|
23
|
+
const { disabled, value, label, icon, selected, onChange, onClick, titleCase: propsTitleCase, description, avatar } = props, rest = __rest(props, ["disabled", "value", "label", "icon", "selected", "onChange", "onClick", "titleCase", "description", "avatar"]);
|
24
|
+
const classes = useStyles();
|
25
|
+
const titleCase = useTitleCase(propsTitleCase);
|
26
|
+
const orientation = useContext(TabsOrientationContext);
|
27
|
+
const labelComponent = getLabelComponent({
|
28
|
+
avatar,
|
29
|
+
description,
|
30
|
+
disabled,
|
31
|
+
label,
|
32
|
+
orientation,
|
33
|
+
titleCase,
|
34
|
+
});
|
35
|
+
return (React.createElement(MUITab, Object.assign({ className: '' }, rest, { ref: ref, tabIndex: 0, disabled: disabled, label: labelComponent, icon: icon, value: value, selected: selected, onChange: onChange, onClick: onClick, classes: {
|
36
|
+
root: classes[orientation],
|
37
|
+
selected: classes.selected,
|
38
|
+
wrapper: classes.wrapper,
|
39
|
+
} })));
|
57
40
|
});
|
58
|
-
|
59
|
-
|
60
|
-
fullWidth: 'shrink flex-grow basis-0',
|
61
|
-
};
|
41
|
+
Tab.defaultProps = {};
|
42
|
+
Tab.displayName = 'Tab';
|
62
43
|
const getLabelComponent = ({ avatar, description, disabled, label, orientation, titleCase, }) => {
|
63
44
|
if (!label) {
|
64
45
|
return null;
|
@@ -76,33 +57,5 @@ const getLabelComponent = ({ avatar, description, disabled, label, orientation,
|
|
76
57
|
}
|
77
58
|
return (React.createElement(UserBadge, { renderName: Label, name: label, avatar: avatar }, description && (React.createElement(TabDescription, { disabled: disabled }, description))));
|
78
59
|
};
|
79
|
-
// eslint-disable-next-line func-style
|
80
|
-
function TabInner(props, ref) {
|
81
|
-
const { disabled, value, label, icon, titleCase: propsTitleCase, description, avatar, className, onClick } = props, rest = __rest(props, ["disabled", "value", "label", "icon", "titleCase", "description", "avatar", "className", "onClick"]);
|
82
|
-
const titleCase = useTitleCase(propsTitleCase);
|
83
|
-
const { value: selectedValue, onChange, orientation, variant, } = useTabsContext();
|
84
|
-
const isHorizontal = orientation === 'horizontal';
|
85
|
-
const selected = value === selectedValue;
|
86
|
-
const handleClick = (event) => {
|
87
|
-
if (!disabled && onChange) {
|
88
|
-
onChange(event, value);
|
89
|
-
}
|
90
|
-
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
91
|
-
};
|
92
|
-
const renderLabel = getLabelComponent({
|
93
|
-
avatar,
|
94
|
-
description,
|
95
|
-
disabled,
|
96
|
-
label,
|
97
|
-
orientation,
|
98
|
-
titleCase,
|
99
|
-
});
|
100
|
-
return (React.createElement("button", Object.assign({ className: twMerge(getOpacityClass(selected, !!disabled, orientation), rootClassesByOrientation(selected)[orientation], classesByVariant[variant], disabled ? 'cursor-default text-gray-500' : 'cursor-pointer', disabled && 'pointer-events-none', icon && isHorizontal && 'min-h-0 pt-0 pr-6', 'min-w-0 sm:min-w-[160px] md:min-w-[auto]', 'border-0 cursor-pointer inline-flex outline-none', 'items-center select-none align-middle appearance-none', 'justify-center no-underline [-webkit-tap-highlight-color:transparent]', 'normal-case whitespace-normal leading-4', 'relative ', className), ref: ref, tabIndex: disabled ? -1 : 0, disabled: disabled, onClick: handleClick, role: 'tab', "aria-selected": selected, "aria-disabled": disabled, type: 'button' }, rest),
|
101
|
-
React.createElement("span", { className: twJoin('w-full', wrapperClassesByOrientation[orientation]) },
|
102
|
-
renderLabel,
|
103
|
-
icon && (React.createElement("span", { className: 'absolute top-0 right-0 mb-0 flex items-center' }, icon)))));
|
104
|
-
}
|
105
|
-
TabInner.displayName = 'Tab';
|
106
|
-
export const Tab = forwardRef(TabInner);
|
107
60
|
export default Tab;
|
108
61
|
//# sourceMappingURL=Tab.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tab.js","sourceRoot":"","sources":["../../../src/Tab/Tab.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;
|
1
|
+
{"version":3,"file":"Tab.js","sourceRoot":"","sources":["../../../src/Tab/Tab.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAErD,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAEtD,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAkClD,MAAM,SAAS,GAAG,UAAU,CAAQ,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAA;AAEnE,MAAM,CAAC,MAAM,GAAG,GAAG,UAAU,CAAwB,SAAS,GAAG,CAAC,KAAK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M,YAAY,GAAG,WAAW,KAAK,YAAY,CAAA;IACjD,MAAM,aAAa,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAA;IAE/C,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,CAClB,oBAAC,QAAQ,IAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,GAAI,CAC3E,CAAA;IAED,IAAI,YAAY,IAAI,aAAa,EAAE;QACjC,OAAO,oBAAC,KAAK,OAAG,CAAA;KACjB;IAED,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,CACL;YACE,oBAAC,KAAK,OAAG;YACR,WAAW,IAAI,CACd,oBAAC,cAAc,IAAC,QAAQ,EAAE,QAAQ,IAAG,WAAW,CAAkB,CACnE,CACA,CACJ,CAAA;KACF;IAED,OAAO,CACL,oBAAC,SAAS,IAAC,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,IACtD,WAAW,IAAI,CACd,oBAAC,cAAc,IAAC,QAAQ,EAAE,QAAQ,IAAG,WAAW,CAAkB,CACnE,CACS,CACb,CAAA;AACH,CAAC,CAAA;AAED,eAAe,GAAG,CAAA"}
|
@@ -1,2 +1,5 @@
|
|
1
|
-
|
1
|
+
import type { OmitInternalProps } from '@toptal/picasso-shared';
|
2
|
+
import type { Props } from './Tab';
|
3
|
+
export { default as Tab } from './Tab';
|
4
|
+
export declare type TabProps = OmitInternalProps<Props>;
|
2
5
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tab/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tab/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAElC,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAA;AACtC,oBAAY,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Tab/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Tab/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAA"}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import type { Theme } from '@material-ui/core/styles';
|
2
|
+
declare const _default: ({ sizes, palette, shadows, transitions }: Theme) => import("@material-ui/styles").StyleRules<{}, "selected" | "horizontal" | "vertical" | "wrapper">;
|
3
|
+
export default _default;
|
4
|
+
//# sourceMappingURL=styles.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Tab/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;mEAgDK,KAAK;AAA/D,wBA0DI"}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import { createStyles } from '@material-ui/core/styles';
|
2
|
+
import { rem } from '@toptal/picasso-shared';
|
3
|
+
import { PicassoProvider } from '@toptal/picasso-provider';
|
4
|
+
PicassoProvider.override(({ breakpoints, palette }) => ({
|
5
|
+
MuiTab: {
|
6
|
+
root: {
|
7
|
+
minHeight: 0,
|
8
|
+
minWidth: 0,
|
9
|
+
lineHeight: 1,
|
10
|
+
textTransform: 'none',
|
11
|
+
padding: `${rem('9px')} 0 ${rem('7px')}`,
|
12
|
+
overflow: 'initial',
|
13
|
+
[breakpoints.up('md')]: {
|
14
|
+
padding: undefined,
|
15
|
+
},
|
16
|
+
color: palette.grey.dark,
|
17
|
+
[breakpoints.up('md')]: {
|
18
|
+
minWidth: 'auto',
|
19
|
+
fontSize: '1rem',
|
20
|
+
},
|
21
|
+
},
|
22
|
+
labelIcon: {
|
23
|
+
minHeight: 0,
|
24
|
+
paddingRight: '1.5rem',
|
25
|
+
paddingTop: rem('9px'),
|
26
|
+
'& $wrapper > *:first-child': {
|
27
|
+
position: 'absolute',
|
28
|
+
right: 0,
|
29
|
+
marginBottom: 0,
|
30
|
+
},
|
31
|
+
},
|
32
|
+
selected: {
|
33
|
+
color: palette.common.black,
|
34
|
+
},
|
35
|
+
textColorInherit: {
|
36
|
+
'&$disabled': {
|
37
|
+
color: palette.grey.main,
|
38
|
+
},
|
39
|
+
},
|
40
|
+
disabled: {},
|
41
|
+
},
|
42
|
+
}));
|
43
|
+
export default ({ sizes, palette, shadows, transitions }) => createStyles({
|
44
|
+
horizontal: {
|
45
|
+
paddingTop: 0,
|
46
|
+
'&:not(:last-child)': {
|
47
|
+
marginRight: '2em',
|
48
|
+
},
|
49
|
+
},
|
50
|
+
vertical: {
|
51
|
+
width: '100%',
|
52
|
+
borderRadius: `${sizes.borderRadius.small} 0 0 ${sizes.borderRadius.small}`,
|
53
|
+
margin: '0.25rem 0',
|
54
|
+
overflow: 'hidden',
|
55
|
+
padding: '0.5rem 1rem',
|
56
|
+
transition: `all ${transitions.duration.short}ms ${transitions.easing.easeInOut}`,
|
57
|
+
textAlign: 'left',
|
58
|
+
backgroundColor: palette.grey.lighter,
|
59
|
+
opacity: 1,
|
60
|
+
color: palette.grey.dark,
|
61
|
+
'&:first-child': {
|
62
|
+
marginTop: '1rem',
|
63
|
+
},
|
64
|
+
'&:last-child': {
|
65
|
+
marginBottom: '1rem',
|
66
|
+
},
|
67
|
+
'&:hover': {
|
68
|
+
color: palette.common.black,
|
69
|
+
},
|
70
|
+
'&:hover:not($selected)': {
|
71
|
+
backgroundColor: palette.grey.lighter2,
|
72
|
+
},
|
73
|
+
'& $wrapper': {
|
74
|
+
display: 'block',
|
75
|
+
},
|
76
|
+
},
|
77
|
+
selected: {
|
78
|
+
'&$vertical': {
|
79
|
+
color: palette.common.black,
|
80
|
+
boxShadow: shadows[1],
|
81
|
+
backgroundColor: palette.grey.lightest,
|
82
|
+
'&::before': {
|
83
|
+
content: '""',
|
84
|
+
background: palette.blue.main,
|
85
|
+
position: 'absolute',
|
86
|
+
left: 0,
|
87
|
+
top: 0,
|
88
|
+
bottom: 0,
|
89
|
+
width: '3px',
|
90
|
+
},
|
91
|
+
},
|
92
|
+
},
|
93
|
+
wrapper: {},
|
94
|
+
});
|
95
|
+
//# sourceMappingURL=styles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/Tab/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAS,EAAE,EAAE,CAAC,CAAC;IAC7D,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,CAAC;YACX,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,MAAM;YACrB,OAAO,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;YACxC,QAAQ,EAAE,SAAS;YAEnB,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE;gBACtB,OAAO,EAAE,SAAS;aACnB;YAED,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YAExB,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE;gBACtB,QAAQ,EAAE,MAAM;gBAChB,QAAQ,EAAE,MAAM;aACjB;S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M,CAAC,KAAK;SAC5B;QAED,wBAAwB,EAAE;YACxB,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ;SACvC;QAED,YAAY,EAAE;YACZ,OAAO,EAAE,OAAO;SACjB;KACF;IACD,QAAQ,EAAE;QACR,YAAY,EAAE;YACZ,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;YAC3B,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;YACrB,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ;YAEtC,WAAW,EAAE;gBACX,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;gBAC7B,QAAQ,EAAE,UAAU;gBACpB,IAAI,EAAE,CAAC;gBACP,GAAG,EAAE,CAAC;gBACN,MAAM,EAAE,CAAC;gBACT,KAAK,EAAE,KAAK;aACb;SACF;KACF;IACD,OAAO,EAAE,EAAE;CACZ,CAAC,CAAA"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import type { BaseProps } from '@toptal/picasso-shared';
|
3
|
+
declare type DirectionType = 'left' | 'right';
|
4
|
+
export interface Props extends BaseProps {
|
5
|
+
/** The direction the button should indicate. */
|
6
|
+
direction: DirectionType;
|
7
|
+
/** If `true`, the component is disabled. */
|
8
|
+
disabled?: boolean;
|
9
|
+
}
|
10
|
+
export declare const TabScrollButton: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
11
|
+
export default TabScrollButton;
|
12
|
+
//# sourceMappingURL=TabScrollButton.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TabScrollButton.d.ts","sourceRoot":"","sources":["../../../src/TabScrollButton/TabScrollButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAKvD,aAAK,aAAa,GAAG,MAAM,GAAG,OAAO,CAAA;AAErC,MAAM,WAAW,KAAM,SAAQ,SAAS;IACtC,gDAAgD;IAChD,SAAS,EAAE,aAAa,CAAA;IACxB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,eAAO,MAAM,eAAe,8EAsC3B,CAAA;AAID,eAAe,eAAe,CAAA"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
2
|
+
var t = {};
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
4
|
+
t[p] = s[p];
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
8
|
+
t[p[i]] = s[p[i]];
|
9
|
+
}
|
10
|
+
return t;
|
11
|
+
};
|
12
|
+
import React, { forwardRef } from 'react';
|
13
|
+
import { ButtonBase } from '@material-ui/core';
|
14
|
+
import { BackMinor16, ChevronMinor16 } from '@toptal/picasso-icons';
|
15
|
+
import { Container } from '@toptal/picasso-container';
|
16
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge';
|
17
|
+
export const TabScrollButton = forwardRef(function TabScrollButton(props, ref) {
|
18
|
+
const { className, style, direction, disabled } = props, rest = __rest(props, ["className", "style", "direction", "disabled"]);
|
19
|
+
if (disabled) {
|
20
|
+
return null;
|
21
|
+
}
|
22
|
+
return (React.createElement(Container, Object.assign({}, rest, { ref: ref, className: twMerge('relative', className), style: style }),
|
23
|
+
React.createElement(Container, { className: twMerge('absolute w-10 h-full z-10', direction === 'left'
|
24
|
+
? 'bg-gradient-to-r from-white via-white to-transparent'
|
25
|
+
: 'bg-gradient-to-l from-white via-white to-transparent', direction === 'left' ? 'left-0' : 'right-0') },
|
26
|
+
React.createElement(ButtonBase, { className: twMerge('absolute w-4 h-full', direction === 'left' ? 'left-0' : 'right-0'), "aria-label": `${direction} button`, "data-testid": `tab-scroll-button-${direction}` }, direction === 'left' ? React.createElement(BackMinor16, null) : React.createElement(ChevronMinor16, null)))));
|
27
|
+
});
|
28
|
+
TabScrollButton.displayName = 'TabScrollButton';
|
29
|
+
export default TabScrollButton;
|
30
|
+
//# sourceMappingURL=TabScrollButton.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"TabScrollButton.js","sourceRoot":"","sources":["../../../src/TabScrollButton/TabScrollButton.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AAWxD,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CACvC,SAAS,eAAe,CAAC,KAAK,EAAE,GAAG;IACjC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,KAAc,KAAK,EAAd,IAAI,UAAK,KAAK,EAA1D,+CAAkD,CAAQ,CAAA;IAEhE,IAAI,QAAQ,EAAE;QACZ,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,EACzC,KAAK,EAAE,KAAK;QAEZ,oBAAC,SAAS,IACR,SAAS,EAAE,OAAO,CAChB,2BAA2B,EAC3B,SAAS,KAAK,MAAM;gBAClB,CAAC,CAAC,sDAAsD;gBACxD,CAAC,CAAC,sDAAsD,EAC1D,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAC5C;YAED,oBAAC,UAAU,IACT,SAAS,EAAE,OAAO,CAChB,qBAAqB,EACrB,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAC5C,gBACW,GAAG,SAAS,SAAS,iBACpB,qBAAqB,SAAS,EAAE,IAE5C,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,oBAAC,WAAW,OAAG,CAAC,CAAC,CAAC,oBAAC,cAAc,OAAG,CACjD,CACH,CACF,CACb,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB,CAAA;AAE/C,eAAe,eAAe,CAAA"}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { OmitInternalProps } from '@toptal/picasso-shared';
|
2
|
+
import type { Props } from './TabScrollButton';
|
3
|
+
export { default as TabScrollButton } from './TabScrollButton';
|
4
|
+
export declare type TabScrollButtonProps = OmitInternalProps<Props>;
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TabScrollButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC9D,oBAAY,oBAAoB,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/TabScrollButton/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
|
@@ -1,26 +1,23 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ForwardedRef, ReactNode } from 'react';
|
2
|
+
import React from 'react';
|
3
|
+
import { Tabs as MUITabs } from '@material-ui/core';
|
2
4
|
import type { BaseProps } from '@toptal/picasso-shared';
|
3
|
-
export
|
5
|
+
export declare type TabsValueType = string | number | false;
|
6
|
+
export interface Props<V extends TabsValueType> extends BaseProps {
|
4
7
|
/** Tabs content containing Tab components */
|
5
8
|
children: ReactNode;
|
6
9
|
/** Callback fired when the value changes. */
|
7
|
-
onChange?: (event: ChangeEvent<{}
|
8
|
-
/**
|
9
|
-
|
10
|
-
* If you don't want any selected Tab, you can set this property to null.
|
11
|
-
*/
|
12
|
-
value: T;
|
10
|
+
onChange?: (event: React.ChangeEvent<{}> | null, value: V) => void;
|
11
|
+
/** The value of the currently selected Tab. If you don't want any selected Tab, you can set this property to false. */
|
12
|
+
value: V;
|
13
13
|
/** The tabs orientation (layout flow direction). */
|
14
14
|
orientation?: 'horizontal' | 'vertical';
|
15
15
|
/** Determines additional display behavior of the tabs */
|
16
16
|
variant?: 'scrollable' | 'fullWidth';
|
17
|
-
/** The default value. Use when the component is not controlled. */
|
18
|
-
defaultValue?: T;
|
19
|
-
/** The direction of the text. */
|
20
|
-
direction?: 'ltr' | 'rtl';
|
21
17
|
}
|
22
|
-
export declare const
|
23
|
-
|
24
|
-
|
18
|
+
export declare const TabsOrientationContext: React.Context<"horizontal" | "vertical">;
|
19
|
+
export declare const Tabs: <V extends TabsValueType = TabsValueType>(props: Props<V> & {
|
20
|
+
ref?: ForwardedRef<HTMLDivElement> | undefined;
|
21
|
+
}) => ReturnType<typeof MUITabs>;
|
25
22
|
export default Tabs;
|
26
23
|
//# sourceMappingURL=Tabs.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,KAAqB,MAAM,OAAO,CAAA;AAGzC,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAMvD,oBAAY,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAA;AAEnD,MAAM,WAAW,KAAK,CAAC,CAAC,SAAS,aAAa,CAAE,SAAQ,SAAS;IAC/D,6CAA6C;IAC7C,QAAQ,EAAE,SAAS,CAAA;IAEnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IAElE,uHAAuH;IACvH,KAAK,EAAE,CAAC,CAAA;IAER,oDAAoD;IACpD,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;IAEvC,yDAAyD;IACzD,OAAO,CAAC,EAAE,YAAY,GAAG,WAAW,CAAA;CACrC;AAMD,eAAO,MAAM,sBAAsB,0CAEpB,CAAA;AAEf,eAAO,MAAM,IAAI;;MAsCZ,WAAW,cAAc,CAAC,CAAA;AAE/B,eAAe,IAAI,CAAA"}
|
@@ -9,76 +9,22 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
9
9
|
}
|
10
10
|
return t;
|
11
11
|
};
|
12
|
-
import React, { forwardRef
|
13
|
-
import {
|
14
|
-
import {
|
15
|
-
import {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
'
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
scroller: 'pl-2',
|
30
|
-
},
|
31
|
-
horizontal: {
|
32
|
-
root: '',
|
33
|
-
scroller: indicatorClasses,
|
34
|
-
},
|
35
|
-
};
|
36
|
-
const classesByVariant = {
|
37
|
-
scrollable: {
|
38
|
-
root: 'overflow-x-auto',
|
39
|
-
scroller: '',
|
40
|
-
},
|
41
|
-
fullWidth: {
|
42
|
-
root: '',
|
43
|
-
scroller: 'w-full overflow-hidden',
|
44
|
-
},
|
45
|
-
};
|
46
|
-
// eslint-disable-next-line func-style
|
47
|
-
function TabsInner(props, ref) {
|
48
|
-
const { children, orientation = 'horizontal', onChange, value: valueProp, defaultValue, variant = 'scrollable', direction = 'ltr', className } = props, rest = __rest(props, ["children", "orientation", "onChange", "value", "defaultValue", "variant", "direction", "className"]);
|
49
|
-
const [value, setValue] = React.useState(defaultValue);
|
50
|
-
const isControlled = valueProp !== undefined;
|
51
|
-
const currentValue = isControlled ? valueProp : value;
|
52
|
-
const handleChange = useCallback((event, newValue) => {
|
53
|
-
if (!isControlled) {
|
54
|
-
setValue(newValue);
|
55
|
-
}
|
56
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event, newValue);
|
57
|
-
}, [isControlled, onChange]);
|
58
|
-
const contextValue = useMemo(() => ({
|
59
|
-
value: currentValue,
|
60
|
-
onChange: handleChange,
|
61
|
-
orientation,
|
62
|
-
variant,
|
63
|
-
direction,
|
64
|
-
}), [currentValue, handleChange, orientation, variant, direction]);
|
65
|
-
const isVertical = orientation === 'vertical';
|
66
|
-
const childrenWithIndex = React.Children.map(children, (child, idx) => {
|
67
|
-
if (React.isValidElement(child) &&
|
68
|
-
child.type === Tab &&
|
69
|
-
child.props.value === undefined) {
|
70
|
-
return React.cloneElement(child, {
|
71
|
-
value: idx,
|
72
|
-
});
|
73
|
-
}
|
74
|
-
return child;
|
75
|
-
});
|
76
|
-
return (React.createElement(TabsContext.Provider, { value: contextValue },
|
77
|
-
React.createElement("div", Object.assign({}, rest, { ref: ref, "data-component-type": 'tabs', className: twMerge('relative min-h-0 flex overflow-hidden', classesByOrientation[orientation].root, classesByVariant[variant].root, className), "aria-orientation": orientation }),
|
78
|
-
React.createElement("div", { className: twJoin(classesByVariant[variant].scroller, classesByOrientation[orientation].scroller, 'flex-auto inline-block relative whitespace-nowrap') },
|
79
|
-
React.createElement("div", { className: twJoin('flex', isVertical && 'flex-col'), role: 'tablist', tabIndex: -1 }, childrenWithIndex)))));
|
80
|
-
}
|
81
|
-
TabsInner.displayName = 'Tabs';
|
82
|
-
export const Tabs = forwardRef(TabsInner);
|
12
|
+
import React, { forwardRef } from 'react';
|
13
|
+
import { makeStyles } from '@material-ui/core/styles';
|
14
|
+
import { Tabs as MUITabs } from '@material-ui/core';
|
15
|
+
import { TabScrollButton } from '../TabScrollButton';
|
16
|
+
import styles from './styles';
|
17
|
+
import useTabAction from './use-tab-action';
|
18
|
+
const useStyles = makeStyles(styles, {
|
19
|
+
name: 'Tabs',
|
20
|
+
});
|
21
|
+
export const TabsOrientationContext = React.createContext('horizontal');
|
22
|
+
export const Tabs = forwardRef((props, ref) => {
|
23
|
+
const { children, orientation = 'horizontal', onChange, value, variant = 'scrollable' } = props, rest = __rest(props, ["children", "orientation", "onChange", "value", "variant"]);
|
24
|
+
const classes = useStyles(props);
|
25
|
+
const action = useTabAction();
|
26
|
+
return (React.createElement(TabsOrientationContext.Provider, { value: orientation },
|
27
|
+
React.createElement(MUITabs, Object.assign({}, rest, { classes: { root: classes[orientation] }, ref: ref, onChange: onChange, value: value, action: action, scrollButtons: 'auto', ScrollButtonComponent: TabScrollButton, orientation: orientation, variant: variant, "data-component-type": 'tabs' }), children)));
|
28
|
+
});
|
83
29
|
export default Tabs;
|
84
30
|
//# sourceMappingURL=Tabs.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/Tabs/Tabs.tsx"],"names":[],"mappings":";;;;;;;;;;;AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,
|
1
|
+
{"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../src/Tabs/Tabs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,CACD,CACsB,CACnC,CAAA;AACH,CAAC,CAG4B,CAAA;AAE/B,eAAe,IAAI,CAAA"}
|
@@ -1,2 +1,6 @@
|
|
1
|
-
|
1
|
+
import type { OmitInternalProps } from '@toptal/picasso-shared';
|
2
|
+
import type { Props, TabsValueType } from './Tabs';
|
3
|
+
export { default as Tabs } from './Tabs';
|
4
|
+
export declare type TabsProps = OmitInternalProps<Props<TabsValueType>>;
|
5
|
+
export type { TabsValueType } from './Tabs';
|
2
6
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Tabs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA;AACxC,oBAAY,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAA;AAC/D,YAAY,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Tabs/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Tabs/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Tabs/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAA;sCA6BxB,KAAK;AAAlC,wBAeI"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { createStyles } from '@material-ui/core/styles';
|
2
|
+
import { PicassoProvider } from '@toptal/picasso-provider';
|
3
|
+
PicassoProvider.override(({ palette }) => ({
|
4
|
+
MuiTabs: {
|
5
|
+
root: {
|
6
|
+
position: 'relative',
|
7
|
+
minHeight: 0,
|
8
|
+
},
|
9
|
+
vertical: {
|
10
|
+
width: 200,
|
11
|
+
margin: 0,
|
12
|
+
'& $scroller': {
|
13
|
+
// We need a bit of padding to allow active tab's shadow to be visible
|
14
|
+
paddingLeft: '0.5em',
|
15
|
+
},
|
16
|
+
'& $indicator': {
|
17
|
+
display: 'none',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
indicator: {
|
21
|
+
backgroundColor: palette.blue.main,
|
22
|
+
zIndex: 1,
|
23
|
+
},
|
24
|
+
},
|
25
|
+
}));
|
26
|
+
export default ({ palette }) => createStyles({
|
27
|
+
horizontal: {
|
28
|
+
'&::after': {
|
29
|
+
position: 'absolute',
|
30
|
+
content: '""',
|
31
|
+
bottom: 0,
|
32
|
+
left: 0,
|
33
|
+
right: 0,
|
34
|
+
height: 1,
|
35
|
+
backgroundColor: palette.grey.main,
|
36
|
+
zIndex: 0,
|
37
|
+
},
|
38
|
+
},
|
39
|
+
vertical: {},
|
40
|
+
});
|
41
|
+
//# sourceMappingURL=styles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/Tabs/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAS,EAAE,EAAE,CAAC,CAAC;IAChD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE,UAAU;YACpB,SAAS,EAAE,CAAC;SACb;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,CAAC;YACT,aAAa,EAAE;gBACb,sEAAsE;gBACtE,WAAW,EAAE,OAAO;aACrB;YAED,cAAc,EAAE;gBACd,OAAO,EAAE,MAAM;aAChB;SACF;QACD,SAAS,EAAE;YACT,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YAClC,MAAM,EAAE,CAAC;SACV;KACF;CACF,CAAC,CAAC,CAAA;AAEH,eAAe,CAAC,EAAE,OAAO,EAAS,EAAE,EAAE,CACpC,YAAY,CAAC;IACX,UAAU,EAAE;QACV,UAAU,EAAE;YACV,QAAQ,EAAE,UAAU;YACpB,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI;YAClC,MAAM,EAAE,CAAC;SACV;KACF;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAA"}
|