@toptal/picasso-tabs 3.0.2-alpha-fx-null-revert-tabs-974b03420.32 → 3.0.2-alpha-FX-NULL-fix-checkbox-class-b75438bf7.34

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 (50) hide show
  1. package/dist-package/src/Tab/Tab.d.ts +3 -3
  2. package/dist-package/src/Tab/Tab.d.ts.map +1 -1
  3. package/dist-package/src/Tab/Tab.js +62 -14
  4. package/dist-package/src/Tab/Tab.js.map +1 -1
  5. package/dist-package/src/Tabs/Tabs.d.ts +11 -5
  6. package/dist-package/src/Tabs/Tabs.d.ts.map +1 -1
  7. package/dist-package/src/Tabs/Tabs.js +51 -16
  8. package/dist-package/src/Tabs/Tabs.js.map +1 -1
  9. package/dist-package/src/TabsCompound/index.d.ts +2 -2
  10. package/dist-package/src/index.d.ts +0 -1
  11. package/dist-package/src/index.d.ts.map +1 -1
  12. package/dist-package/src/index.js +0 -1
  13. package/dist-package/src/index.js.map +1 -1
  14. package/package.json +16 -16
  15. package/src/Tab/Tab.tsx +99 -21
  16. package/src/Tab/__snapshots__/test.tsx.snap +32 -47
  17. package/src/Tabs/Tabs.tsx +91 -35
  18. package/src/Tabs/__snapshots__/test.tsx.snap +61 -76
  19. package/src/Tabs/test.tsx +1 -1
  20. package/src/index.ts +0 -1
  21. package/dist-package/src/Tab/styles.d.ts +0 -4
  22. package/dist-package/src/Tab/styles.d.ts.map +0 -1
  23. package/dist-package/src/Tab/styles.js +0 -94
  24. package/dist-package/src/Tab/styles.js.map +0 -1
  25. package/dist-package/src/TabScrollButton/TabScrollButton.d.ts +0 -12
  26. package/dist-package/src/TabScrollButton/TabScrollButton.d.ts.map +0 -1
  27. package/dist-package/src/TabScrollButton/TabScrollButton.js +0 -40
  28. package/dist-package/src/TabScrollButton/TabScrollButton.js.map +0 -1
  29. package/dist-package/src/TabScrollButton/index.d.ts +0 -5
  30. package/dist-package/src/TabScrollButton/index.d.ts.map +0 -1
  31. package/dist-package/src/TabScrollButton/index.js +0 -2
  32. package/dist-package/src/TabScrollButton/index.js.map +0 -1
  33. package/dist-package/src/TabScrollButton/styles.d.ts +0 -4
  34. package/dist-package/src/TabScrollButton/styles.d.ts.map +0 -1
  35. package/dist-package/src/TabScrollButton/styles.js +0 -35
  36. package/dist-package/src/TabScrollButton/styles.js.map +0 -1
  37. package/dist-package/src/Tabs/styles.d.ts +0 -4
  38. package/dist-package/src/Tabs/styles.d.ts.map +0 -1
  39. package/dist-package/src/Tabs/styles.js +0 -41
  40. package/dist-package/src/Tabs/styles.js.map +0 -1
  41. package/dist-package/src/Tabs/use-tab-action.d.ts +0 -5
  42. package/dist-package/src/Tabs/use-tab-action.d.ts.map +0 -1
  43. package/dist-package/src/Tabs/use-tab-action.js +0 -21
  44. package/dist-package/src/Tabs/use-tab-action.js.map +0 -1
  45. package/src/Tab/styles.ts +0 -106
  46. package/src/TabScrollButton/TabScrollButton.tsx +0 -64
  47. package/src/TabScrollButton/index.ts +0 -6
  48. package/src/TabScrollButton/styles.ts +0 -37
  49. package/src/Tabs/styles.ts +0 -45
  50. package/src/Tabs/use-tab-action.ts +0 -27
@@ -6,30 +6,27 @@ exports[`Tab Tab disabled tab 1`] = `
6
6
  class="Picasso-root"
7
7
  >
8
8
  <div
9
- class="MuiTabs-root Tabs-horizontal"
9
+ class="base-Tabs base-Tabs relative min-h flex overflow-hidden overflow-x"
10
10
  >
11
11
  <div
12
- class="MuiTabs-scrollable"
13
- style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
14
- />
15
- <div
16
- class="MuiTabs-scroller MuiTabs-scrollable"
17
- style="margin-bottom: 0px;"
12
+ 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"
18
13
  >
19
14
  <div
20
- class="MuiTabs-flexContainer"
15
+ class="base-TabsList base-TabsList flex"
21
16
  role="tablist"
17
+ tabindex="-1"
22
18
  >
23
19
  <button
20
+ aria-disabled="true"
24
21
  aria-selected="false"
25
- class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit Mui-disabled Mui-disabled"
26
- disabled=""
22
+ class="base-Tab base- opacity-50 m-0 [&:not(:last-child)]:mr-8 pt-[0.5625rem] 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"
23
+ id=":r1:"
27
24
  role="tab"
28
- tabindex="-1"
25
+ tabindex="0"
29
26
  type="button"
30
27
  >
31
28
  <span
32
- class="MuiTab-wrapper PicassoTab-wrapper"
29
+ class="w-full inline-flex items-center flex-col justify-center"
33
30
  >
34
31
  <div
35
32
  class="m-0 text-sm text-inherit font-semibold"
@@ -39,10 +36,6 @@ exports[`Tab Tab disabled tab 1`] = `
39
36
  </span>
40
37
  </button>
41
38
  </div>
42
- <span
43
- class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
44
- style="left: 0px; width: 0px;"
45
- />
46
39
  </div>
47
40
  </div>
48
41
  </div>
@@ -55,29 +48,27 @@ exports[`Tab Tab renders 1`] = `
55
48
  class="Picasso-root"
56
49
  >
57
50
  <div
58
- class="MuiTabs-root Tabs-horizontal"
51
+ class="base-Tabs base-Tabs relative min-h flex overflow-hidden overflow-x"
59
52
  >
60
53
  <div
61
- class="MuiTabs-scrollable"
62
- style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
63
- />
64
- <div
65
- class="MuiTabs-scroller MuiTabs-scrollable"
66
- style="margin-bottom: 0px;"
54
+ 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"
67
55
  >
68
56
  <div
69
- class="MuiTabs-flexContainer"
57
+ class="base-TabsList base-TabsList flex"
70
58
  role="tablist"
59
+ tabindex="-1"
71
60
  >
72
61
  <button
62
+ aria-disabled="false"
73
63
  aria-selected="false"
74
- class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit"
64
+ class="base-Tab opacity-70 m-0 [&:not(:last-child)]:mr-8 pt-[0.5625rem] pb-[0.4375rem] px-0 text-center bg-transparent transition-shadow z-10 rounded-none text-inheritColor 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"
65
+ id=":r0:"
75
66
  role="tab"
76
67
  tabindex="0"
77
68
  type="button"
78
69
  >
79
70
  <span
80
- class="MuiTab-wrapper PicassoTab-wrapper"
71
+ class="w-full inline-flex items-center flex-col justify-center"
81
72
  >
82
73
  <div
83
74
  class="m-0 text-sm text-inherit font-semibold"
@@ -87,10 +78,6 @@ exports[`Tab Tab renders 1`] = `
87
78
  </span>
88
79
  </button>
89
80
  </div>
90
- <span
91
- class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
92
- style="left: 0px; width: 0px;"
93
- />
94
81
  </div>
95
82
  </div>
96
83
  </div>
@@ -103,45 +90,43 @@ exports[`Tab Tab tab with icon 1`] = `
103
90
  class="Picasso-root"
104
91
  >
105
92
  <div
106
- class="MuiTabs-root Tabs-horizontal"
93
+ class="base-Tabs base-Tabs relative min-h flex overflow-hidden overflow-x"
107
94
  >
108
95
  <div
109
- class="MuiTabs-scrollable"
110
- style="width: 99px; height: 99px; position: absolute; top: -9999px; overflow: scroll;"
111
- />
112
- <div
113
- class="MuiTabs-scroller MuiTabs-scrollable"
114
- style="margin-bottom: 0px;"
96
+ 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"
115
97
  >
116
98
  <div
117
- class="MuiTabs-flexContainer"
99
+ class="base-TabsList base-TabsList flex"
118
100
  role="tablist"
101
+ tabindex="-1"
119
102
  >
120
103
  <button
104
+ aria-disabled="false"
121
105
  aria-selected="false"
122
- class="MuiButtonBase-root MuiTab-root PicassoTab-horizontal MuiTab-textColorInherit MuiTab-labelIcon"
106
+ class="base-Tab 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-inheritColor shrink-0 max-w min-h pt-[0.5625rem] 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"
107
+ id=":r2:"
123
108
  role="tab"
124
109
  tabindex="0"
125
110
  type="button"
126
111
  >
127
112
  <span
128
- class="MuiTab-wrapper PicassoTab-wrapper"
113
+ class="w-full inline-flex items-center flex-col justify-center"
129
114
  >
130
- <div
131
- id="Icon"
132
- />
133
115
  <div
134
116
  class="m-0 text-sm text-inherit font-semibold"
135
117
  >
136
118
  Tab Label
137
119
  </div>
120
+ <span
121
+ class="absolute right-0 mb-0 h-4"
122
+ >
123
+ <div
124
+ id="Icon"
125
+ />
126
+ </span>
138
127
  </span>
139
128
  </button>
140
129
  </div>
141
- <span
142
- class="PrivateTabIndicator-root PrivateTabIndicator-colorSecondary MuiTabs-indicator"
143
- style="left: 0px; width: 0px;"
144
- />
145
130
  </div>
146
131
  </div>
147
132
  </div>
package/src/Tabs/Tabs.tsx CHANGED
@@ -1,13 +1,9 @@
1
- import type { ForwardedRef, ReactNode } from 'react'
2
- import React, { forwardRef } from 'react'
3
- import type { Theme } from '@material-ui/core/styles'
4
- import { makeStyles } from '@material-ui/core/styles'
5
- import { Tabs as MUITabs } from '@material-ui/core'
1
+ import type { ReactNode, ForwardedRef } from 'react'
2
+ import React, { forwardRef, useMemo } from 'react'
3
+ import { Tabs as MUITabs } from '@mui/base/Tabs'
4
+ import { TabsList } from '@mui/base/TabsList'
6
5
  import type { BaseProps } from '@toptal/picasso-shared'
7
-
8
- import { TabScrollButton } from '../TabScrollButton'
9
- import styles from './styles'
10
- import useTabAction from './use-tab-action'
6
+ import { twJoin, twMerge } from '@toptal/picasso-tailwind-merge'
11
7
 
12
8
  export type TabsValueType = string | number | null
13
9
 
@@ -18,7 +14,10 @@ export interface Props<V extends TabsValueType> extends BaseProps {
18
14
  /** Callback fired when the value changes. */
19
15
  onChange?: (event: React.ChangeEvent<{}> | null, value: V) => void
20
16
 
21
- /** The value of the currently selected Tab. If you don't want any selected Tab, you can set this property to false. */
17
+ /**
18
+ * The value of the currently selected Tab.
19
+ * If you don't want any selected Tab, you can set this property to null.
20
+ */
22
21
  value: V
23
22
 
24
23
  /** The tabs orientation (layout flow direction). */
@@ -28,47 +27,104 @@ export interface Props<V extends TabsValueType> extends BaseProps {
28
27
  variant?: 'scrollable' | 'fullWidth'
29
28
  }
30
29
 
31
- const useStyles = makeStyles<Theme>(styles, {
32
- name: 'Tabs',
33
- })
30
+ export const TabsContext = React.createContext<{
31
+ orientation: 'horizontal' | 'vertical'
32
+ variant: 'scrollable' | 'fullWidth'
33
+ }>({ orientation: 'horizontal', variant: 'scrollable' })
34
+
35
+ const indicatorClasses = [
36
+ 'after:absolute',
37
+ 'after:content-[""]',
38
+ 'after:bottom-0',
39
+ 'after:left-0',
40
+ 'after:right-0',
41
+ 'after:h-[1px]',
42
+ 'after:bg-gray-500',
43
+ 'after:z-0',
44
+ ]
34
45
 
35
- export const TabsOrientationContext = React.createContext<
36
- 'horizontal' | 'vertical'
37
- >('horizontal')
46
+ const classesByOrientation = {
47
+ vertical: {
48
+ root: 'w-[200px] m-0 flex-col',
49
+ scroller: 'pl-2',
50
+ },
51
+ horizontal: {
52
+ root: '',
53
+ scroller: indicatorClasses,
54
+ },
55
+ } as const
38
56
 
39
- export const Tabs = forwardRef(
57
+ const classesByVariant = {
58
+ scrollable: {
59
+ root: 'overflow-x-auto',
60
+ scroller: '',
61
+ },
62
+ fullWidth: {
63
+ root: '',
64
+ scroller: 'w-full overflow-hidden',
65
+ },
66
+ } as const
67
+
68
+ const Tabs = forwardRef(
40
69
  <V extends TabsValueType = TabsValueType>(
41
- props: Props<V>,
42
- ref: ForwardedRef<HTMLButtonElement>
43
- ) => {
44
- const {
70
+ {
45
71
  children,
46
- orientation,
72
+ orientation = 'horizontal',
47
73
  onChange,
48
74
  value,
49
75
  variant = 'scrollable',
76
+ className,
50
77
  ...rest
51
- } = props
52
- const classes = useStyles(props)
53
- const action = useTabAction()
78
+ }: Props<V>,
79
+ ref: ForwardedRef<HTMLDivElement>
80
+ ) => {
81
+ const contextValue = useMemo(
82
+ () => ({
83
+ orientation,
84
+ variant,
85
+ }),
86
+ [orientation, variant]
87
+ )
88
+
89
+ const isVertical = orientation === 'vertical'
54
90
 
55
91
  return (
56
- <TabsOrientationContext.Provider value={orientation!}>
92
+ <TabsContext.Provider value={contextValue}>
57
93
  <MUITabs
58
94
  {...rest}
59
- classes={{ root: classes[orientation!] }}
60
- ref={ref}
61
- onChange={onChange}
95
+ slotProps={{
96
+ root: {
97
+ ref,
98
+ className: twMerge(
99
+ 'relative min-h-0 flex overflow-hidden',
100
+ classesByOrientation[orientation].root,
101
+ classesByVariant[variant].root,
102
+ className
103
+ ),
104
+ },
105
+ }}
106
+ onChange={
107
+ onChange as (
108
+ event: React.ChangeEvent<{}> | null,
109
+ value: TabsValueType
110
+ ) => void
111
+ }
62
112
  value={value}
63
- action={action}
64
- scrollButtons='auto'
65
- ScrollButtonComponent={TabScrollButton}
66
113
  orientation={orientation}
67
- variant={variant}
68
114
  >
69
- {children}
115
+ <div
116
+ className={twJoin(
117
+ classesByVariant[variant].scroller,
118
+ classesByOrientation[orientation].scroller,
119
+ 'flex-auto inline-block relative whitespace-nowrap'
120
+ )}
121
+ >
122
+ <TabsList className={twJoin('flex', isVertical && 'flex-col')}>
123
+ {children}
124
+ </TabsList>
125
+ </div>
70
126
  </MUITabs>
71
- </TabsOrientationContext.Provider>
127
+ </TabsContext.Provider>
72
128
  )
73
129
  }
74
130
  ) as <V extends TabsValueType = TabsValueType>(