@toptal/picasso-tabs 5.0.15-alpha-ff-7-tabs-2a3da7cea.16 → 5.0.15-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.7

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.
Files changed (62) hide show
  1. package/dist-package/src/Tab/Tab.d.ts +10 -7
  2. package/dist-package/src/Tab/Tab.d.ts.map +1 -1
  3. package/dist-package/src/Tab/Tab.js +26 -73
  4. package/dist-package/src/Tab/Tab.js.map +1 -1
  5. package/dist-package/src/Tab/index.d.ts +4 -1
  6. package/dist-package/src/Tab/index.d.ts.map +1 -1
  7. package/dist-package/src/Tab/index.js.map +1 -1
  8. package/dist-package/src/Tab/styles.d.ts +4 -0
  9. package/dist-package/src/Tab/styles.d.ts.map +1 -0
  10. package/dist-package/src/Tab/styles.js +95 -0
  11. package/dist-package/src/Tab/styles.js.map +1 -0
  12. package/dist-package/src/TabScrollButton/TabScrollButton.d.ts +12 -0
  13. package/dist-package/src/TabScrollButton/TabScrollButton.d.ts.map +1 -0
  14. package/dist-package/src/TabScrollButton/TabScrollButton.js +30 -0
  15. package/dist-package/src/TabScrollButton/TabScrollButton.js.map +1 -0
  16. package/dist-package/src/TabScrollButton/index.d.ts +5 -0
  17. package/dist-package/src/TabScrollButton/index.d.ts.map +1 -0
  18. package/dist-package/src/TabScrollButton/index.js +2 -0
  19. package/dist-package/src/TabScrollButton/index.js.map +1 -0
  20. package/dist-package/src/Tabs/Tabs.d.ts +12 -15
  21. package/dist-package/src/Tabs/Tabs.d.ts.map +1 -1
  22. package/dist-package/src/Tabs/Tabs.js +17 -71
  23. package/dist-package/src/Tabs/Tabs.js.map +1 -1
  24. package/dist-package/src/Tabs/index.d.ts +5 -1
  25. package/dist-package/src/Tabs/index.d.ts.map +1 -1
  26. package/dist-package/src/Tabs/index.js.map +1 -1
  27. package/dist-package/src/Tabs/styles.d.ts +4 -0
  28. package/dist-package/src/Tabs/styles.d.ts.map +1 -0
  29. package/dist-package/src/Tabs/styles.js +41 -0
  30. package/dist-package/src/Tabs/styles.js.map +1 -0
  31. package/dist-package/src/Tabs/use-tab-action.d.ts +5 -0
  32. package/dist-package/src/Tabs/use-tab-action.d.ts.map +1 -0
  33. package/dist-package/src/Tabs/use-tab-action.js +21 -0
  34. package/dist-package/src/Tabs/use-tab-action.js.map +1 -0
  35. package/dist-package/src/TabsCompound/index.d.ts +4 -6
  36. package/dist-package/src/TabsCompound/index.d.ts.map +1 -1
  37. package/dist-package/src/index.d.ts +1 -0
  38. package/dist-package/src/index.d.ts.map +1 -1
  39. package/dist-package/src/index.js +1 -0
  40. package/dist-package/src/index.js.map +1 -1
  41. package/package.json +13 -13
  42. package/src/Tab/Tab.tsx +79 -149
  43. package/src/Tab/__snapshots__/test.tsx.snap +45 -29
  44. package/src/Tab/index.ts +6 -1
  45. package/src/Tab/story/CustomValue.example.tsx +2 -2
  46. package/src/Tab/story/IconOrBadge.example.tsx +3 -3
  47. package/src/Tab/styles.ts +107 -0
  48. package/src/TabScrollButton/TabScrollButton.tsx +59 -0
  49. package/src/TabScrollButton/index.ts +6 -0
  50. package/src/Tabs/Tabs.tsx +60 -145
  51. package/src/Tabs/__snapshots__/test.tsx.snap +76 -45
  52. package/src/Tabs/index.ts +7 -1
  53. package/src/Tabs/story/Default.example.tsx +6 -7
  54. package/src/Tabs/styles.ts +45 -0
  55. package/src/Tabs/test.tsx +14 -16
  56. package/src/Tabs/use-tab-action.ts +27 -0
  57. package/src/index.ts +1 -0
  58. package/dist-package/src/Tabs/TabsContext.d.ts +0 -11
  59. package/dist-package/src/Tabs/TabsContext.d.ts.map +0 -1
  60. package/dist-package/src/Tabs/TabsContext.js +0 -16
  61. package/dist-package/src/Tabs/TabsContext.js.map +0 -1
  62. package/src/Tabs/TabsContext.tsx +0 -27
@@ -0,0 +1,5 @@
1
+ import type { Ref } from 'react';
2
+ import type { TabsActions } from '@material-ui/core';
3
+ declare const useTabAction: () => Ref<TabsActions>;
4
+ export default useTabAction;
5
+ //# sourceMappingURL=use-tab-action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tab-action.d.ts","sourceRoot":"","sources":["../../../src/Tabs/use-tab-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAOpD,QAAA,MAAM,YAAY,QAAO,IAAI,WAAW,CAevC,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { useEffect, useRef } from 'react';
2
+ /*
3
+ * MuiTabs break when the size of a tab changes without rendering with React.
4
+ * This issue happens when the font is loaded after the initial render of the component.
5
+ * To solve this issue, we imperatively update the indicator and scroll buttons when it happens.
6
+ */
7
+ const useTabAction = () => {
8
+ const ref = useRef(null);
9
+ useEffect(() => {
10
+ const listener = () => {
11
+ var _a, _b;
12
+ (_a = ref.current) === null || _a === void 0 ? void 0 : _a.updateIndicator();
13
+ (_b = ref.current) === null || _b === void 0 ? void 0 : _b.updateScrollButtons();
14
+ };
15
+ window.addEventListener('load', listener);
16
+ return () => window.removeEventListener('load', listener);
17
+ }, []);
18
+ return ref;
19
+ };
20
+ export default useTabAction;
21
+ //# sourceMappingURL=use-tab-action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tab-action.js","sourceRoot":"","sources":["../../../src/Tabs/use-tab-action.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAGzC;;;;GAIG;AACH,MAAM,YAAY,GAAG,GAAqB,EAAE;IAC1C,MAAM,GAAG,GAAG,MAAM,CAAc,IAAI,CAAC,CAAA;IAErC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,QAAQ,GAAG,GAAG,EAAE;;YACpB,MAAA,GAAG,CAAC,OAAO,0CAAE,eAAe,EAAE,CAAA;YAC9B,MAAA,GAAG,CAAC,OAAO,0CAAE,mBAAmB,EAAE,CAAA;QACpC,CAAC,CAAA;QAED,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAEzC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC3D,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -1,9 +1,7 @@
1
1
  /// <reference types="react" />
2
- export declare const TabsCompound: (<T = number>(props: import("../Tabs").TabsProps<T> & {
3
- ref?: import("react").Ref<HTMLDivElement> | undefined;
4
- }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & {
5
- Tab: <T_1 = number>(props: import("../Tab").TabProps<T_1> & {
6
- ref?: import("react").Ref<HTMLButtonElement> | undefined;
7
- }) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
2
+ export declare const TabsCompound: (<V extends import("../Tabs").TabsValueType = import("../Tabs").TabsValueType>(props: import("../Tabs/Tabs").Props<V> & {
3
+ ref?: import("react").ForwardedRef<HTMLDivElement> | undefined;
4
+ }) => JSX.Element) & {
5
+ Tab: import("react").ForwardRefExoticComponent<import("../Tab/Tab").Props & import("react").RefAttributes<HTMLDivElement>>;
8
6
  };
9
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TabsCompound/index.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;;;;;;CAEvB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TabsCompound/index.ts"],"names":[],"mappings":";AAGA,eAAO,MAAM,YAAY;;;;CAEvB,CAAA"}
@@ -1,3 +1,4 @@
1
+ export * from './TabScrollButton';
1
2
  export * from './Tabs';
2
3
  export * from './Tab';
3
4
  export * from './TabDescription';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
@@ -1,3 +1,4 @@
1
+ export * from './TabScrollButton';
1
2
  export * from './Tabs';
2
3
  export * from './Tab';
3
4
  export * from './TabDescription';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,QAAQ,CAAA;AACtB,cAAc,OAAO,CAAA;AACrB,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/picasso-tabs",
3
- "version": "5.0.15-alpha-ff-7-tabs-2a3da7cea.16+2a3da7cea",
3
+ "version": "5.0.15-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.7+04c9c3a7c",
4
4
  "description": "Toptal UI components library - Tabs",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,13 +22,13 @@
22
22
  },
23
23
  "homepage": "https://github.com/toptal/picasso/tree/master/packages/picasso#readme",
24
24
  "dependencies": {
25
- "@toptal/picasso-container": "3.1.3-alpha-ff-7-tabs-2a3da7cea.16+2a3da7cea",
26
- "@toptal/picasso-icons": "1.12.2-alpha-ff-7-tabs-2a3da7cea.16+2a3da7cea",
27
- "@toptal/picasso-shared": "15.0.1-alpha-ff-7-tabs-2a3da7cea.362+2a3da7cea",
28
- "@toptal/picasso-typography": "4.0.4-alpha-ff-7-tabs-2a3da7cea.16+2a3da7cea",
29
- "@toptal/picasso-typography-overflow": "4.0.4-alpha-ff-7-tabs-2a3da7cea.16+2a3da7cea",
30
- "@toptal/picasso-user-badge": "5.1.12-alpha-ff-7-tabs-2a3da7cea.16+2a3da7cea",
31
- "@toptal/picasso-utils": "3.1.1-alpha-ff-7-tabs-2a3da7cea.16+2a3da7cea",
25
+ "@toptal/picasso-container": "3.1.3-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.7+04c9c3a7c",
26
+ "@toptal/picasso-icons": "1.12.2-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.7+04c9c3a7c",
27
+ "@toptal/picasso-shared": "15.0.1-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.353+04c9c3a7c",
28
+ "@toptal/picasso-typography": "4.0.4-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.7+04c9c3a7c",
29
+ "@toptal/picasso-typography-overflow": "4.0.4-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.7+04c9c3a7c",
30
+ "@toptal/picasso-user-badge": "5.1.12-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.7+04c9c3a7c",
31
+ "@toptal/picasso-utils": "3.1.1-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.7+04c9c3a7c",
32
32
  "ap-style-title-case": "^1.1.2"
33
33
  },
34
34
  "sideEffects": [
@@ -36,8 +36,8 @@
36
36
  "**/styles.js"
37
37
  ],
38
38
  "peerDependencies": {
39
+ "@material-ui/core": "4.12.4",
39
40
  "@toptal/picasso-provider": "*",
40
- "@toptal/picasso-tailwind": ">=2.6",
41
41
  "@toptal/picasso-tailwind-merge": "^2.0.0",
42
42
  "react": ">=16.12.0 < 19.0.0"
43
43
  },
@@ -45,14 +45,14 @@
45
45
  ".": "./dist-package/src/index.js"
46
46
  },
47
47
  "devDependencies": {
48
- "@toptal/picasso-provider": "5.0.1-alpha-ff-7-tabs-2a3da7cea.283+2a3da7cea",
49
- "@toptal/picasso-tailwind-merge": "2.0.4-alpha-ff-7-tabs-2a3da7cea.16+2a3da7cea",
50
- "@toptal/picasso-test-utils": "1.1.2-alpha-ff-7-tabs-2a3da7cea.362+2a3da7cea"
48
+ "@material-ui/core": "4.12.4",
49
+ "@toptal/picasso-provider": "5.0.1-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.274+04c9c3a7c",
50
+ "@toptal/picasso-test-utils": "1.1.2-alpha-HG-985-prompt-modal-variant-primary-04c9c3a7c.353+04c9c3a7c"
51
51
  },
52
52
  "files": [
53
53
  "dist-package/**",
54
54
  "!dist-package/tsconfig.tsbuildinfo",
55
55
  "src"
56
56
  ],
57
- "gitHead": "2a3da7cea3ba840b0a702d9efc91380d60ee2fe6"
57
+ "gitHead": "04c9c3a7c386e0e32b8e5b426bf4d49cb2ba369a"
58
58
  }
package/src/Tab/Tab.tsx CHANGED
@@ -1,26 +1,30 @@
1
- import type { ReactNode, HTMLAttributes, ReactElement, Ref } from 'react'
2
- import React, { forwardRef } from 'react'
1
+ import type { ReactNode, HTMLAttributes, ReactElement } from 'react'
2
+ import React, { forwardRef, useContext } from 'react'
3
+ import type { Theme } from '@material-ui/core/styles'
4
+ import { makeStyles } from '@material-ui/core/styles'
5
+ import type { TabProps } from '@material-ui/core'
6
+ import { Tab as MUITab } from '@material-ui/core'
3
7
  import type { BaseProps, TextLabelProps } from '@toptal/picasso-shared'
4
8
  import { useTitleCase } from '@toptal/picasso-shared'
5
9
  import { UserBadge } from '@toptal/picasso-user-badge'
6
- import { twJoin, twMerge } from '@toptal/picasso-tailwind-merge'
7
10
 
8
- import { useTabsContext } from '../Tabs/TabsContext'
11
+ import styles from './styles'
12
+ import { TabsOrientationContext } from '../Tabs/Tabs'
9
13
  import { TabLabel } from '../TabLabel'
10
14
  import { TabDescription } from '../TabDescription'
11
15
 
12
- export interface TabProps<T = number>
16
+ export interface Props
13
17
  extends BaseProps,
14
18
  TextLabelProps,
15
- Omit<HTMLAttributes<HTMLButtonElement>, 'onChange'> {
19
+ Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
16
20
  /**
17
21
  * If true, the tab will be disabled
18
22
  * @default false
19
23
  */
20
24
  disabled?: boolean
21
25
 
22
- /** The value of the tab */
23
- value?: T
26
+ /** You can provide your own value. Otherwise, we fallback to the child position index */
27
+ value?: TabProps['value']
24
28
 
25
29
  /** The label element */
26
30
  label?: ReactNode
@@ -33,60 +37,77 @@ export interface TabProps<T = number>
33
37
 
34
38
  /** Description */
35
39
  description?: string
36
- }
37
40
 
38
- const getOpacityClass = (
39
- selected: boolean,
40
- disabled: boolean,
41
- orientation: 'horizontal' | 'vertical'
42
- ) => {
43
- if (disabled) {
44
- return 'opacity-50'
45
- }
46
- if (selected || orientation === 'vertical') {
47
- return 'opacity-100 '
48
- }
41
+ // Properties below are managed by Tabs component
49
42
 
50
- return 'opacity-70'
43
+ selected?: boolean
44
+ onChange?: TabProps['onChange']
45
+ onClick?: TabProps['onClick']
51
46
  }
52
47
 
53
- const wrapperClassesByOrientation = {
54
- horizontal: 'inline-flex flex-row items-center justify-center',
55
- vertical: 'block',
56
- }
48
+ const useStyles = makeStyles<Theme>(styles, { name: 'PicassoTab' })
49
+
50
+ export const Tab = forwardRef<HTMLDivElement, Props>(function Tab(props, ref) {
51
+ const {
52
+ disabled,
53
+ value,
54
+ label,
55
+ icon,
56
+ selected,
57
+ onChange,
58
+ onClick,
59
+ titleCase: propsTitleCase,
60
+ description,
61
+ avatar,
62
+ ...rest
63
+ } = props
64
+ const classes = useStyles()
65
+ const titleCase = useTitleCase(propsTitleCase)
66
+ const orientation = useContext(TabsOrientationContext)
67
+
68
+ const labelComponent = getLabelComponent({
69
+ avatar,
70
+ description,
71
+ disabled,
72
+ label,
73
+ orientation,
74
+ titleCase,
75
+ })
57
76
 
58
- const rootClassesByOrientation = (selected: boolean) => ({
59
- horizontal: [
60
- 'm-0 [&:not(:last-child)]:mr-8 pt-0 pb-[0.4375rem] px-0',
61
- 'text-center bg-transparent transition-shadow z-10 rounded-none',
62
- 'text-black',
63
- selected && 'shadow-blue-500 shadow-[inset_0_-2px_0]',
64
- ],
65
- vertical: [
66
- ' first:mt-4 last:mb-4 my-1 mx-0 py-2 px-4',
67
- 'text-left rounded-l-sm rounded-r-none transition-all',
68
- 'w-full overflow-hidden',
69
- selected && 'shadow-1',
70
- selected && [
71
- 'before:absolute',
72
- 'before:content-[""]',
73
- 'before:bottom-0',
74
- 'before:left-0',
75
- 'before:top-0',
76
- 'before:w-[3px]',
77
- 'before:bg-blue-500',
78
- ],
79
- selected
80
- ? 'bg-gray-50 text-black'
81
- : 'bg-gray-100 hover:bg-gray-200 text-graphite-700 hover:text-black',
82
- ],
77
+ return (
78
+ <MUITab
79
+ className=''
80
+ {...rest}
81
+ ref={ref}
82
+ tabIndex={0}
83
+ disabled={disabled}
84
+ label={labelComponent}
85
+ icon={icon}
86
+ value={value}
87
+ selected={selected}
88
+ onChange={onChange}
89
+ onClick={onClick}
90
+ classes={{
91
+ root: classes[orientation],
92
+ selected: classes.selected,
93
+ wrapper: classes.wrapper,
94
+ }}
95
+ />
96
+ )
83
97
  })
84
98
 
85
- const classesByVariant = {
86
- scrollable: 'shrink-0 max-w-[264px]',
87
- fullWidth: 'shrink flex-grow basis-0',
88
- }
99
+ Tab.defaultProps = {}
89
100
 
101
+ Tab.displayName = 'Tab'
102
+
103
+ type GetLabelComponentProps = {
104
+ avatar?: string | null
105
+ description?: string
106
+ disabled?: boolean
107
+ label?: React.ReactNode
108
+ orientation: 'horizontal' | 'vertical'
109
+ titleCase?: boolean
110
+ }
90
111
  const getLabelComponent = ({
91
112
  avatar,
92
113
  description,
@@ -94,19 +115,14 @@ const getLabelComponent = ({
94
115
  label,
95
116
  orientation,
96
117
  titleCase,
97
- }: {
98
- avatar?: string | null
99
- description?: string
100
- disabled?: boolean
101
- label?: React.ReactNode
102
- orientation: 'horizontal' | 'vertical'
103
- titleCase?: boolean
104
- }): React.ReactNode => {
118
+ }: GetLabelComponentProps): React.ReactNode => {
105
119
  if (!label) {
106
120
  return null
107
121
  }
122
+
108
123
  const isHorizontal = orientation === 'horizontal'
109
124
  const isCustomLabel = typeof label !== 'string'
125
+
110
126
  const Label = () => (
111
127
  <TabLabel titleCase={titleCase} label={label} orientation={orientation} />
112
128
  )
@@ -114,6 +130,7 @@ const getLabelComponent = ({
114
130
  if (isHorizontal || isCustomLabel) {
115
131
  return <Label />
116
132
  }
133
+
117
134
  if (typeof avatar === 'undefined') {
118
135
  return (
119
136
  <>
@@ -134,91 +151,4 @@ const getLabelComponent = ({
134
151
  )
135
152
  }
136
153
 
137
- // eslint-disable-next-line func-style
138
- function TabInner<T = number>(props: TabProps<T>, ref: Ref<HTMLButtonElement>) {
139
- const {
140
- disabled,
141
- value,
142
- label,
143
- icon,
144
- titleCase: propsTitleCase,
145
- description,
146
- avatar,
147
- className,
148
- onClick,
149
- ...rest
150
- } = props
151
- const titleCase = useTitleCase(propsTitleCase)
152
- const {
153
- value: selectedValue,
154
- onChange,
155
- orientation,
156
- variant,
157
- } = useTabsContext()
158
- const isHorizontal = orientation === 'horizontal'
159
- const selected = value === selectedValue
160
-
161
- const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
162
- if (!disabled && onChange) {
163
- onChange(event, value as T)
164
- }
165
- onClick?.(event)
166
- }
167
-
168
- const renderLabel = getLabelComponent({
169
- avatar,
170
- description,
171
- disabled,
172
- label,
173
- orientation,
174
- titleCase,
175
- })
176
-
177
- return (
178
- <button
179
- className={twMerge(
180
- getOpacityClass(selected, !!disabled, orientation),
181
- rootClassesByOrientation(selected)[orientation],
182
- classesByVariant[variant],
183
- disabled ? 'cursor-default text-gray-500' : 'cursor-pointer',
184
- disabled && 'pointer-events-none',
185
- icon && isHorizontal && 'min-h-0 pt-0 pr-6',
186
- 'min-w-0 sm:min-w-[160px] md:min-w-[auto]',
187
- 'border-0 cursor-pointer inline-flex outline-none',
188
- 'items-center select-none align-middle appearance-none',
189
- 'justify-center no-underline [-webkit-tap-highlight-color:transparent]',
190
- 'normal-case whitespace-normal leading-4',
191
- 'relative ',
192
- className
193
- )}
194
- ref={ref}
195
- tabIndex={disabled ? -1 : 0}
196
- disabled={disabled}
197
- onClick={handleClick}
198
- role='tab'
199
- aria-selected={selected}
200
- aria-disabled={disabled}
201
- type='button'
202
- {...rest}
203
- >
204
- <span
205
- className={twJoin('w-full', wrapperClassesByOrientation[orientation])}
206
- >
207
- {renderLabel}
208
- {icon && (
209
- <span className='absolute top-0 right-0 mb-0 flex items-center'>
210
- {icon}
211
- </span>
212
- )}
213
- </span>
214
- </button>
215
- )
216
- }
217
-
218
- TabInner.displayName = 'Tab'
219
-
220
- export const Tab = forwardRef(TabInner) as <T = number>(
221
- props: TabProps<T> & { ref?: Ref<HTMLButtonElement> }
222
- ) => ReactElement | null
223
-
224
154
  export default Tab
@@ -6,29 +6,31 @@ exports[`Tab Tab disabled tab 1`] = `
6
6
  class="Picasso-root"
7
7
  >
8
8
  <div
9
- aria-orientation="horizontal"
10
- class="relative min-h flex overflow-hidden overflow-x"
9
+ class="MuiTabs-root Tabs-horizontal"
11
10
  data-component-type="tabs"
12
11
  >
13
12
  <div
14
- class="after:absolute after:content-[""] after:bottom-0 after:left-0 after:right-0 after:h-[1px] after:bg-gray after:z-0 flex-auto inline-block relative whitespace-nowrap"
13
+ class="MuiTabs-scrollable"
14
+ style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
15
+ />
16
+ <div
17
+ class="MuiTabs-scroller MuiTabs-scrollable"
18
+ style="margin-bottom: 0px;"
15
19
  >
16
20
  <div
17
- class="flex"
21
+ class="MuiTabs-flexContainer"
18
22
  role="tablist"
19
- tabindex="-1"
20
23
  >
21
24
  <button
22
- aria-disabled="true"
23
25
  aria-selected="false"
24
- class="opacity-50 m-0 [&:not(:last-child)]:mr-8 pt-0 pb-[0.4375rem] px-0 text-center bg-transparent transition-shadow z-10 rounded-none shrink-0 max-w text-gray pointer-events min-w sm:min-w md:min-w border-0 cursor-pointer inline-flex outline-none items-center select-none align-middle appearance-none justify-center no-underline [-webkit-tap-highlight normal-case whitespace-normal leading-4 relative"
26
+ class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit Mui-disabled Mui-disabled"
25
27
  disabled=""
26
28
  role="tab"
27
29
  tabindex="-1"
28
30
  type="button"
29
31
  >
30
32
  <span
31
- class="w-full inline-flex flex-row items-center justify-center"
33
+ class="MuiTab-wrapper PicassoTab-wrapper"
32
34
  >
33
35
  <div
34
36
  class="m-0 text-sm text-inherit font-semibold leading-[1.1rem]"
@@ -38,6 +40,10 @@ exports[`Tab Tab disabled tab 1`] = `
38
40
  </span>
39
41
  </button>
40
42
  </div>
43
+ <span
44
+ class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
45
+ style="left: 0px; width: 0px;"
46
+ />
41
47
  </div>
42
48
  </div>
43
49
  </div>
@@ -50,27 +56,30 @@ exports[`Tab Tab renders 1`] = `
50
56
  class="Picasso-root"
51
57
  >
52
58
  <div
53
- aria-orientation="horizontal"
54
- class="relative min-h flex overflow-hidden overflow-x"
59
+ class="MuiTabs-root Tabs-horizontal"
55
60
  data-component-type="tabs"
56
61
  >
57
62
  <div
58
- class="after:absolute after:content-[""] after:bottom-0 after:left-0 after:right-0 after:h-[1px] after:bg-gray after:z-0 flex-auto inline-block relative whitespace-nowrap"
63
+ class="MuiTabs-scrollable"
64
+ style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
65
+ />
66
+ <div
67
+ class="MuiTabs-scroller MuiTabs-scrollable"
68
+ style="margin-bottom: 0px;"
59
69
  >
60
70
  <div
61
- class="flex"
71
+ class="MuiTabs-flexContainer"
62
72
  role="tablist"
63
- tabindex="-1"
64
73
  >
65
74
  <button
66
75
  aria-selected="false"
67
- class="opacity-70 m-0 [&:not(:last-child)]:mr-8 pt-0 pb-[0.4375rem] px-0 text-center bg-transparent transition-shadow z-10 rounded-none text-black shrink-0 max-w min-w sm:min-w md:min-w border-0 cursor-pointer inline-flex outline-none items-center select-none align-middle appearance-none justify-center no-underline [-webkit-tap-highlight normal-case whitespace-normal leading-4 relative"
76
+ class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit"
68
77
  role="tab"
69
78
  tabindex="0"
70
79
  type="button"
71
80
  >
72
81
  <span
73
- class="w-full inline-flex flex-row items-center justify-center"
82
+ class="MuiTab-wrapper PicassoTab-wrapper"
74
83
  >
75
84
  <div
76
85
  class="m-0 text-sm text-inherit font-semibold leading-[1.1rem]"
@@ -80,6 +89,10 @@ exports[`Tab Tab renders 1`] = `
80
89
  </span>
81
90
  </button>
82
91
  </div>
92
+ <span
93
+ class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
94
+ style="left: 0px; width: 0px;"
95
+ />
83
96
  </div>
84
97
  </div>
85
98
  </div>
@@ -92,43 +105,46 @@ exports[`Tab Tab tab with icon 1`] = `
92
105
  class="Picasso-root"
93
106
  >
94
107
  <div
95
- aria-orientation="horizontal"
96
- class="relative min-h flex overflow-hidden overflow-x"
108
+ class="MuiTabs-root Tabs-horizontal"
97
109
  data-component-type="tabs"
98
110
  >
99
111
  <div
100
- class="after:absolute after:content-[""] after:bottom-0 after:left-0 after:right-0 after:h-[1px] after:bg-gray after:z-0 flex-auto inline-block relative whitespace-nowrap"
112
+ class="MuiTabs-scrollable"
113
+ style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
114
+ />
115
+ <div
116
+ class="MuiTabs-scroller MuiTabs-scrollable"
117
+ style="margin-bottom: 0px;"
101
118
  >
102
119
  <div
103
- class="flex"
120
+ class="MuiTabs-flexContainer"
104
121
  role="tablist"
105
- tabindex="-1"
106
122
  >
107
123
  <button
108
124
  aria-selected="false"
109
- class="opacity-70 m-0 [&:not(:last-child)]:mr-8 pb-[0.4375rem] px-0 text-center bg-transparent transition-shadow z-10 rounded-none text-black shrink-0 max-w min-h pt-0 pr-6 min-w sm:min-w md:min-w border-0 cursor-pointer inline-flex outline-none items-center select-none align-middle appearance-none justify-center no-underline [-webkit-tap-highlight normal-case whitespace-normal leading-4 relative"
125
+ class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit MuiTab-labelIcon"
110
126
  role="tab"
111
127
  tabindex="0"
112
128
  type="button"
113
129
  >
114
130
  <span
115
- class="w-full inline-flex flex-row items-center justify-center"
131
+ class="MuiTab-wrapper PicassoTab-wrapper"
116
132
  >
133
+ <div
134
+ id="Icon"
135
+ />
117
136
  <div
118
137
  class="m-0 text-sm text-inherit font-semibold leading-[1.1rem]"
119
138
  >
120
139
  Tab Label
121
140
  </div>
122
- <span
123
- class="absolute top-0 right-0 mb-0 flex items-center"
124
- >
125
- <div
126
- id="Icon"
127
- />
128
- </span>
129
141
  </span>
130
142
  </button>
131
143
  </div>
144
+ <span
145
+ class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
146
+ style="left: 0px; width: 0px;"
147
+ />
132
148
  </div>
133
149
  </div>
134
150
  </div>
package/src/Tab/index.ts CHANGED
@@ -1 +1,6 @@
1
- export { default as Tab, type TabProps } from './Tab'
1
+ import type { OmitInternalProps } from '@toptal/picasso-shared'
2
+
3
+ import type { Props } from './Tab'
4
+
5
+ export { default as Tab } from './Tab'
6
+ export type TabProps = OmitInternalProps<Props>
@@ -2,10 +2,10 @@ import React from 'react'
2
2
  import { Container, Tabs } from '@toptal/picasso'
3
3
  import { SPACING_4 } from '@toptal/picasso-utils'
4
4
 
5
- type Value = 'jobs' | 'engagements' | 'interviews'
5
+ type Value = number | string | null
6
6
 
7
7
  const Example = () => {
8
- const [value, setValue] = React.useState<Value>('engagements')
8
+ const [value, setValue] = React.useState<Value>(0)
9
9
 
10
10
  const handleChange = (_: React.ChangeEvent<{}>, newValue: Value) => {
11
11
  setValue(newValue)
@@ -4,7 +4,7 @@ import { SPACING_4 } from '@toptal/picasso-utils'
4
4
  import { Exclamation16 } from '@toptal/picasso-icons'
5
5
 
6
6
  const Example = () => {
7
- const [value, setValue] = React.useState<number>(0)
7
+ const [value, setValue] = React.useState(0)
8
8
 
9
9
  const handleChange = (_: React.ChangeEvent<{}>, newValue: number) => {
10
10
  setValue(newValue)
@@ -17,9 +17,9 @@ const Example = () => {
17
17
  label='Label'
18
18
  icon={
19
19
  <Tooltip content='Some content...' placement='top'>
20
- <div>
20
+ <span>
21
21
  <Exclamation16 color='red' />
22
- </div>
22
+ </span>
23
23
  </Tooltip>
24
24
  }
25
25
  />