@udixio/ui-react 2.5.2 → 2.7.0

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 (134) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/index.cjs +2 -2
  3. package/dist/index.js +2566 -2264
  4. package/dist/lib/components/Button.d.ts.map +1 -1
  5. package/dist/lib/components/Card.d.ts.map +1 -1
  6. package/dist/lib/components/Carousel.d.ts +0 -2
  7. package/dist/lib/components/Carousel.d.ts.map +1 -1
  8. package/dist/lib/components/Fab.d.ts +1 -1
  9. package/dist/lib/components/Fab.d.ts.map +1 -1
  10. package/dist/lib/components/FabMenu.d.ts +9 -0
  11. package/dist/lib/components/FabMenu.d.ts.map +1 -0
  12. package/dist/lib/components/IconButton.d.ts.map +1 -1
  13. package/dist/lib/components/NavigationRail.d.ts.map +1 -1
  14. package/dist/lib/components/NavigationRailItem.d.ts.map +1 -1
  15. package/dist/lib/components/Tab.d.ts.map +1 -1
  16. package/dist/lib/components/ToolTip.d.ts.map +1 -1
  17. package/dist/lib/components/index.d.ts +1 -0
  18. package/dist/lib/components/index.d.ts.map +1 -1
  19. package/dist/lib/effects/AnimateOnScroll.d.ts.map +1 -1
  20. package/dist/lib/effects/State.d.ts +26 -0
  21. package/dist/lib/effects/State.d.ts.map +1 -0
  22. package/dist/lib/effects/index.d.ts +1 -0
  23. package/dist/lib/effects/index.d.ts.map +1 -1
  24. package/dist/lib/effects/ripple/RippleEffect.d.ts.map +1 -1
  25. package/dist/lib/interfaces/button.interface.d.ts +4 -1
  26. package/dist/lib/interfaces/button.interface.d.ts.map +1 -1
  27. package/dist/lib/interfaces/fab-menu.interface.d.ts +12 -0
  28. package/dist/lib/interfaces/fab-menu.interface.d.ts.map +1 -0
  29. package/dist/lib/interfaces/fab.interface.d.ts +2 -2
  30. package/dist/lib/interfaces/fab.interface.d.ts.map +1 -1
  31. package/dist/lib/interfaces/index.d.ts +1 -0
  32. package/dist/lib/interfaces/index.d.ts.map +1 -1
  33. package/dist/lib/interfaces/side-sheet.interface.d.ts +1 -1
  34. package/dist/lib/interfaces/side-sheet.interface.d.ts.map +1 -1
  35. package/dist/lib/styles/button.style.d.ts +43 -3
  36. package/dist/lib/styles/button.style.d.ts.map +1 -1
  37. package/dist/lib/styles/card.style.d.ts +9 -1
  38. package/dist/lib/styles/card.style.d.ts.map +1 -1
  39. package/dist/lib/styles/carousel-item.style.d.ts +11 -1
  40. package/dist/lib/styles/carousel-item.style.d.ts.map +1 -1
  41. package/dist/lib/styles/carousel.style.d.ts +16 -1
  42. package/dist/lib/styles/carousel.style.d.ts.map +1 -1
  43. package/dist/lib/styles/divider.style.d.ts +8 -2
  44. package/dist/lib/styles/divider.style.d.ts.map +1 -1
  45. package/dist/lib/styles/fab-menu.style.d.ts +83 -0
  46. package/dist/lib/styles/fab-menu.style.d.ts.map +1 -0
  47. package/dist/lib/styles/fab.style.d.ts +29 -5
  48. package/dist/lib/styles/fab.style.d.ts.map +1 -1
  49. package/dist/lib/styles/icon-button.style.d.ts +37 -1
  50. package/dist/lib/styles/icon-button.style.d.ts.map +1 -1
  51. package/dist/lib/styles/index.d.ts +2 -0
  52. package/dist/lib/styles/index.d.ts.map +1 -1
  53. package/dist/lib/styles/navigation-rail-item.style.d.ts +11 -1
  54. package/dist/lib/styles/navigation-rail-item.style.d.ts.map +1 -1
  55. package/dist/lib/styles/navigation-rail.style.d.ts +31 -1
  56. package/dist/lib/styles/navigation-rail.style.d.ts.map +1 -1
  57. package/dist/lib/styles/progress-indicator.style.d.ts +12 -1
  58. package/dist/lib/styles/progress-indicator.style.d.ts.map +1 -1
  59. package/dist/lib/styles/side-sheet.style.d.ts +20 -3
  60. package/dist/lib/styles/side-sheet.style.d.ts.map +1 -1
  61. package/dist/lib/styles/slider.style.d.ts +21 -2
  62. package/dist/lib/styles/slider.style.d.ts.map +1 -1
  63. package/dist/lib/styles/snackbar.style.d.ts +14 -3
  64. package/dist/lib/styles/snackbar.style.d.ts.map +1 -1
  65. package/dist/lib/styles/switch.style.d.ts +14 -2
  66. package/dist/lib/styles/switch.style.d.ts.map +1 -1
  67. package/dist/lib/styles/tab.style.d.ts +12 -2
  68. package/dist/lib/styles/tab.style.d.ts.map +1 -1
  69. package/dist/lib/styles/tabs.style.d.ts +17 -2
  70. package/dist/lib/styles/tabs.style.d.ts.map +1 -1
  71. package/dist/lib/styles/text-field.style.d.ts +23 -2
  72. package/dist/lib/styles/text-field.style.d.ts.map +1 -1
  73. package/dist/lib/styles/tooltip.style.d.ts +20 -3
  74. package/dist/lib/styles/tooltip.style.d.ts.map +1 -1
  75. package/dist/lib/utils/styles/get-classname.d.ts +3 -0
  76. package/dist/lib/utils/styles/get-classname.d.ts.map +1 -1
  77. package/dist/lib/utils/styles/index.d.ts +1 -0
  78. package/dist/lib/utils/styles/index.d.ts.map +1 -1
  79. package/dist/lib/utils/styles/use-classnames.d.ts +6 -0
  80. package/dist/lib/utils/styles/use-classnames.d.ts.map +1 -0
  81. package/package.json +3 -3
  82. package/src/lib/components/Button.tsx +54 -20
  83. package/src/lib/components/Card.tsx +11 -9
  84. package/src/lib/components/Carousel.tsx +70 -205
  85. package/src/lib/components/CarouselItem.tsx +2 -2
  86. package/src/lib/components/Divider.tsx +2 -2
  87. package/src/lib/components/Fab.tsx +22 -21
  88. package/src/lib/components/FabMenu.tsx +229 -0
  89. package/src/lib/components/IconButton.tsx +24 -30
  90. package/src/lib/components/NavigationRail.tsx +7 -4
  91. package/src/lib/components/NavigationRailItem.tsx +13 -4
  92. package/src/lib/components/ProgressIndicator.tsx +2 -2
  93. package/src/lib/components/SideSheet.tsx +2 -2
  94. package/src/lib/components/Slider.tsx +2 -2
  95. package/src/lib/components/Snackbar.tsx +2 -2
  96. package/src/lib/components/Switch.tsx +2 -2
  97. package/src/lib/components/Tab.tsx +11 -11
  98. package/src/lib/components/Tabs.tsx +2 -2
  99. package/src/lib/components/TextField.tsx +2 -2
  100. package/src/lib/components/ToolTip.tsx +9 -3
  101. package/src/lib/components/index.ts +1 -0
  102. package/src/lib/effects/AnimateOnScroll.ts +51 -18
  103. package/src/lib/effects/State.tsx +83 -0
  104. package/src/lib/effects/index.ts +1 -0
  105. package/src/lib/effects/ripple/RippleEffect.tsx +40 -27
  106. package/src/lib/interfaces/button.interface.ts +5 -1
  107. package/src/lib/interfaces/fab-menu.interface.ts +12 -0
  108. package/src/lib/interfaces/fab.interface.ts +8 -2
  109. package/src/lib/interfaces/index.ts +1 -0
  110. package/src/lib/interfaces/side-sheet.interface.tsx +1 -1
  111. package/src/lib/styles/button.style.ts +127 -136
  112. package/src/lib/styles/card.style.ts +22 -17
  113. package/src/lib/styles/carousel-item.style.ts +23 -9
  114. package/src/lib/styles/carousel.style.ts +17 -5
  115. package/src/lib/styles/divider.style.ts +27 -13
  116. package/src/lib/styles/fab-menu.style.ts +28 -0
  117. package/src/lib/styles/fab.style.ts +41 -43
  118. package/src/lib/styles/icon-button.style.ts +160 -149
  119. package/src/lib/styles/index.ts +2 -0
  120. package/src/lib/styles/navigation-rail-item.style.ts +49 -40
  121. package/src/lib/styles/navigation-rail.style.ts +31 -15
  122. package/src/lib/styles/progress-indicator.style.ts +49 -36
  123. package/src/lib/styles/side-sheet.style.ts +41 -27
  124. package/src/lib/styles/slider.style.ts +37 -23
  125. package/src/lib/styles/snackbar.style.ts +22 -10
  126. package/src/lib/styles/switch.style.ts +61 -45
  127. package/src/lib/styles/tab.style.ts +76 -66
  128. package/src/lib/styles/tabs.style.ts +19 -10
  129. package/src/lib/styles/text-field.style.ts +108 -97
  130. package/src/lib/styles/tooltip.style.ts +42 -33
  131. package/src/lib/utils/styles/get-classname.ts +23 -0
  132. package/src/lib/utils/styles/index.ts +1 -0
  133. package/src/lib/utils/styles/use-classnames.ts +25 -0
  134. package/src/tests/useClassNames.spec.tsx +82 -0
@@ -1,27 +1,41 @@
1
- import { classNames, defaultClassNames } from '../utils';
2
- import { SliderInterface } from '../interfaces/slider.interface';
1
+ import {
2
+ type ClassNameComponent,
3
+ classNames,
4
+ createUseClassNames,
5
+ defaultClassNames,
6
+ } from '../utils';
7
+ import { SliderInterface } from '../interfaces';
8
+
9
+ export const sliderConfig: ClassNameComponent<SliderInterface> = ({
10
+ isChanging,
11
+ }) => ({
12
+ slider: classNames([
13
+ 'relative w-full h-11 flex items-center rounded gap-x-1.5 cursor-pointer min-w-32',
14
+ ]),
15
+ activeTrack: classNames([
16
+ 'h-4 relative transition-all duration-100 bg-primary overflow-hidden rounded-l-full ',
17
+ ]),
18
+ inactiveTrack: classNames([
19
+ 'h-4 relative transition-all duration-100 bg-primary-container rounded-r-full overflow-hidden',
20
+ ]),
21
+ handle: classNames([
22
+ 'transform relative transition-all duration-100 bg-primary h-full rounded-full ',
23
+ { 'w-0.5': isChanging, 'w-1': !isChanging },
24
+ ]),
25
+ valueIndicator: classNames([
26
+ 'absolute select-none bg-inverse-surface text-inverse-on-surface py-3 px-4 text-label-large rounded-full bottom-[calc(100%+4px)] transform left-1/2 -translate-x-1/2',
27
+ ]),
28
+ dot: classNames([
29
+ 'h-1 w-1 absolute transform -translate-y-1/2 -translate-x-1/2 top-1/2 rounded-full',
30
+ ]),
31
+ });
3
32
 
4
33
  export const sliderStyle = defaultClassNames<SliderInterface>(
5
34
  'slider',
6
- ({ isChanging }) => ({
7
- slider: classNames([
8
- 'relative w-full h-11 flex items-center rounded gap-x-1.5 cursor-pointer min-w-32',
9
- ]),
10
- activeTrack: classNames([
11
- 'h-4 relative transition-all duration-100 bg-primary overflow-hidden rounded-l-full ',
12
- ]),
13
- inactiveTrack: classNames([
14
- 'h-4 relative transition-all duration-100 bg-primary-container rounded-r-full overflow-hidden',
15
- ]),
16
- handle: classNames([
17
- 'transform relative transition-all duration-100 bg-primary h-full rounded-full ',
18
- { 'w-0.5': isChanging, 'w-1': !isChanging },
19
- ]),
20
- valueIndicator: classNames([
21
- 'absolute select-none bg-inverse-surface text-inverse-on-surface py-3 px-4 text-label-large rounded-full bottom-[calc(100%+4px)] transform left-1/2 -translate-x-1/2',
22
- ]),
23
- dot: classNames([
24
- 'h-1 w-1 absolute transform -translate-y-1/2 -translate-x-1/2 top-1/2 rounded-full',
25
- ]),
26
- }),
35
+ sliderConfig,
36
+ );
37
+
38
+ export const useSliderStyle = createUseClassNames<SliderInterface>(
39
+ 'slider',
40
+ sliderConfig,
27
41
  );
@@ -1,14 +1,26 @@
1
- import { classNames, defaultClassNames } from '../utils';
2
- import { SnackbarInterface } from '../interfaces/snackbar.interface';
1
+ import {
2
+ type ClassNameComponent,
3
+ classNames,
4
+ createUseClassNames,
5
+ defaultClassNames,
6
+ } from '../utils';
7
+ import { SnackbarInterface } from '../interfaces';
8
+
9
+ const snackbarConfig: ClassNameComponent<SnackbarInterface> = () => ({
10
+ snackbar: classNames(' rounded bg-inverse-surface '),
11
+ container: classNames(
12
+ 'pl-4 pr-2 max-w-full py-1 flex items-center flex-wrap',
13
+ ),
14
+ supportingText: classNames('text-body-medium text-inverse-on-surface '),
15
+ icon: classNames(' ml-auto mr-0 text-inverse-on-surface block dark'),
16
+ });
3
17
 
4
18
  export const snackbarStyle = defaultClassNames<SnackbarInterface>(
5
19
  'snackbar',
6
- () => ({
7
- snackbar: classNames(' rounded bg-inverse-surface '),
8
- container: classNames(
9
- 'pl-4 pr-2 max-w-full py-1 flex items-center flex-wrap',
10
- ),
11
- supportingText: classNames('text-body-medium text-inverse-on-surface '),
12
- icon: classNames(' ml-auto mr-0 text-inverse-on-surface block dark'),
13
- }),
20
+ snackbarConfig,
21
+ );
22
+
23
+ export const useSnackbarStyle = createUseClassNames<SnackbarInterface>(
24
+ 'snackbar',
25
+ snackbarConfig,
14
26
  );
@@ -1,51 +1,67 @@
1
- import { classNames, defaultClassNames } from '../utils';
2
- import { SwitchInterface } from '../interfaces/switch.interface';
1
+ import {
2
+ type ClassNameComponent,
3
+ classNames,
4
+ createUseClassNames,
5
+ defaultClassNames,
6
+ } from '../utils';
7
+ import { SwitchInterface } from '../interfaces';
3
8
 
4
- export const switchStyle = defaultClassNames<SwitchInterface>(
5
- 'switch',
6
- ({ isSelected, disabled, inactiveIcon }) => ({
7
- switch: classNames(
8
- 'group w-[52px] h-[32px] outline-none rounded-full border-2 flex items-center',
9
+ const switchConfig: ClassNameComponent<SwitchInterface> = ({
10
+ isSelected,
11
+ disabled,
12
+ inactiveIcon,
13
+ }) => ({
14
+ switch: classNames(
15
+ 'group/switch w-[52px] h-[32px] outline-none rounded-full border-2 flex items-center',
16
+
17
+ { 'bg-on-surface/[0.12] border-transparent': disabled },
18
+ !disabled && [
19
+ 'cursor-pointer ',
20
+ { 'bg-primary border-primary': isSelected },
21
+ { 'bg-surface-container border-outline': !isSelected },
22
+ ],
23
+
24
+ // { 'justify-start': !isSelected },
25
+ // { 'justify-end': isSelected },
26
+ ),
27
+ handleContainer: classNames(
28
+ 'flex items-center justify-center absolute',
29
+ { 'left-[14px]': !isSelected },
30
+ { 'right-[14px]': isSelected },
31
+ ),
32
+ handle: classNames(
33
+ 'transition-all duration-100 z-10 rounded-full flex items-center justify-center',
34
+ { 'w-[16px] h-[16px]': !isSelected && !inactiveIcon },
35
+ { 'w-[24px] h-[24px]': !(!isSelected && !inactiveIcon) },
36
+ !disabled && [
37
+ 'cursor-pointer group-active/switch:h-[28px] group-active/switch:w-[28px]',
38
+ { 'bg-on-primary group-hover/switch:bg-primary-container': isSelected },
39
+ { 'bg-outline group-hover/switch:bg-on-surface-variant': !isSelected },
40
+ ],
9
41
 
10
- { 'bg-on-surface/[0.12] border-transparent': disabled },
11
- !disabled && [
12
- 'cursor-pointer ',
13
- { 'bg-primary border-primary': isSelected },
14
- { 'bg-surface-container border-outline': !isSelected },
15
- ]
42
+ { 'bg-surface': disabled },
43
+ ),
44
+ handleStateLayer: classNames(
45
+ 'w-[40px] h-[40px] -z-10 rounded-full absolute',
46
+ { 'group-state-primary': !disabled },
47
+ ),
48
+ icon: classNames(
49
+ 'w-[16px] h-[16px]',
50
+ !disabled && [
51
+ { 'text-on-primary-container': isSelected },
52
+ { 'text-on-primary': !isSelected },
53
+ ],
16
54
 
17
- // { 'justify-start': !isSelected },
18
- // { 'justify-end': isSelected },
19
- ),
20
- handleContainer: classNames(
21
- 'flex items-center justify-center absolute',
22
- { 'left-[14px]': !isSelected },
23
- { 'right-[14px]': isSelected }
24
- ),
25
- handle: classNames(
26
- 'transition-all duration-100 z-10 rounded-full flex items-center justify-center',
27
- { 'w-[16px] h-[16px]': !isSelected && !inactiveIcon },
28
- { 'w-[24px] h-[24px]': !(!isSelected && !inactiveIcon) },
29
- !disabled && [
30
- 'cursor-pointer group-active:h-[28px] group-active:w-[28px]',
31
- { 'bg-on-primary group-hover:bg-primary-container': isSelected },
32
- { 'bg-outline group-hover:bg-on-surface-variant': !isSelected },
33
- ],
55
+ { 'text-on-surface/[0.38]': disabled },
56
+ ),
57
+ });
34
58
 
35
- { 'bg-surface': disabled }
36
- ),
37
- handleStateLayer: classNames(
38
- 'w-[40px] h-[40px] -z-10 rounded-full absolute',
39
- { 'group-state-primary': !disabled }
40
- ),
41
- icon: classNames(
42
- 'w-[16px] h-[16px]',
43
- !disabled && [
44
- { 'text-on-primary-container': isSelected },
45
- { 'text-on-primary': !isSelected },
46
- ],
59
+ export const switchStyle = defaultClassNames<SwitchInterface>(
60
+ 'switch',
61
+ switchConfig,
62
+ );
47
63
 
48
- { 'text-on-surface/[0.38]': disabled }
49
- ),
50
- })
64
+ export const useSwitchStyle = createUseClassNames<SwitchInterface>(
65
+ 'switch',
66
+ switchConfig,
51
67
  );
@@ -1,68 +1,78 @@
1
- import { classNames } from '../utils';
2
- import { TabInterface } from '../interfaces/tab.interface';
3
- import { defaultClassNames } from '../utils/styles/get-classname';
1
+ import {
2
+ type ClassNameComponent,
3
+ classNames,
4
+ createUseClassNames,
5
+ defaultClassNames,
6
+ } from '../utils';
7
+ import { TabInterface } from '../interfaces';
4
8
 
5
- export const tabStyle = defaultClassNames<TabInterface>(
6
- 'tab',
7
- ({ isSelected, icon, label, variant }) => ({
8
- tab: classNames(
9
- 'flex-1 group outline-none flex px-4 justify-center items-center cursor-pointer',
10
- { 'z-10': isSelected },
11
- Boolean(icon && label) && variant === 'primary' && 'h-16',
12
- !(Boolean(icon && label) && variant === 'primary') && 'h-12',
13
- ),
14
- stateLayer: classNames(
15
- 'absolute w-full h-full overflow-hidden left-1/2 top-1/2 transform -translate-y-1/2 -translate-x-1/2',
16
- variant === 'primary' && {
17
- 'group-hover:hover-state-on-surface group-focus-visible:focus-state-on-surface':
18
- !isSelected,
19
- 'group-hover:hover-state-primary group-focus-visible:focus-state-primary':
20
- isSelected,
21
- },
22
- variant === 'secondary' &&
23
- 'group-hover:hover-state-on-surface group-focus-visible:focus-state-on-surface',
24
- ),
25
- content: classNames(
26
- 'flex gap-0.5 h-full justify-center',
27
- {
28
- relative: variant == 'primary',
29
- },
30
- {
31
- '': Boolean(label && !icon),
32
- },
9
+ const tabConfig: ClassNameComponent<TabInterface> = ({
10
+ isSelected,
11
+ icon,
12
+ label,
13
+ variant,
14
+ }) => ({
15
+ tab: classNames(
16
+ 'flex-1 group/tab outline-none flex px-4 justify-center items-center cursor-pointer',
17
+ { 'z-10': isSelected },
18
+ Boolean(icon && label) && variant === 'primary' && 'h-16',
19
+ !(Boolean(icon && label) && variant === 'primary') && 'h-12',
20
+ ),
21
+ stateLayer: classNames(
22
+ 'absolute w-full h-full overflow-hidden left-1/2 top-1/2 transform -translate-y-1/2 -translate-x-1/2',
23
+ variant === 'primary' && {
24
+ 'group-hover/tab:hover-state-on-surface group-focus-visible/tab:focus-state-on-surface':
25
+ !isSelected,
26
+ 'group-hover/tab:hover-state-primary group-focus-visible/tab:focus-state-primary':
27
+ isSelected,
28
+ },
29
+ variant === 'secondary' &&
30
+ 'group-hover/tab:hover-state-on-surface group-focus-visible/tab:focus-state-on-surface',
31
+ ),
32
+ content: classNames(
33
+ 'flex gap-0.5 h-full justify-center',
34
+ {
35
+ relative: variant == 'primary',
36
+ },
37
+ {
38
+ '': Boolean(label && !icon),
39
+ },
33
40
 
34
- variant === 'primary' && 'flex-col items-center',
35
- variant === 'secondary' && {
36
- 'flex-col items-center': Boolean(!(label && icon)),
37
- 'flex-row items-center gap-2': Boolean(label && icon),
38
- },
39
- ),
40
- icon: classNames(
41
- 'h-6 w-6 p-0.5 !box-border',
42
- variant === 'primary' && {
43
- 'text-on-surface-variant': !isSelected,
44
- 'text-primary': isSelected,
45
- },
46
- variant === 'secondary' && {
47
- 'text-on-surface-variant': !isSelected,
48
- 'text-on-surface': isSelected,
49
- },
50
- ),
51
- label: classNames(
52
- 'text-title-small text-nowrap',
53
- variant === 'primary' && {
54
- 'text-on-surface-variant': !isSelected,
55
- 'text-primary': isSelected,
56
- },
57
- variant === 'secondary' && {
58
- 'text-on-surface-variant': !isSelected,
59
- 'text-on-surface': isSelected,
60
- },
61
- ),
62
- underline: classNames(
63
- 'bg-primary absolute w-full left-0 bottom-0',
64
- variant === 'primary' && 'h-[3px] rounded-t',
65
- variant === 'secondary' && 'h-0.5',
66
- ),
67
- }),
68
- );
41
+ variant === 'primary' && 'flex-col items-center',
42
+ variant === 'secondary' && {
43
+ 'flex-col items-center': Boolean(!(label && icon)),
44
+ 'flex-row items-center gap-2': Boolean(label && icon),
45
+ },
46
+ ),
47
+ icon: classNames(
48
+ 'h-6 w-6 p-0.5 !box-border',
49
+ variant === 'primary' && {
50
+ 'text-on-surface-variant': !isSelected,
51
+ 'text-primary': isSelected,
52
+ },
53
+ variant === 'secondary' && {
54
+ 'text-on-surface-variant': !isSelected,
55
+ 'text-on-surface': isSelected,
56
+ },
57
+ ),
58
+ label: classNames(
59
+ 'text-title-small text-nowrap',
60
+ variant === 'primary' && {
61
+ 'text-on-surface-variant': !isSelected,
62
+ 'text-primary': isSelected,
63
+ },
64
+ variant === 'secondary' && {
65
+ 'text-on-surface-variant': !isSelected,
66
+ 'text-on-surface': isSelected,
67
+ },
68
+ ),
69
+ underline: classNames(
70
+ 'bg-primary absolute w-full left-0 bottom-0',
71
+ variant === 'primary' && 'h-[3px] rounded-t',
72
+ variant === 'secondary' && 'h-0.5',
73
+ ),
74
+ });
75
+
76
+ export const tabStyle = defaultClassNames<TabInterface>('tab', tabConfig);
77
+
78
+ export const useTabStyle = createUseClassNames<TabInterface>('tab', tabConfig);
@@ -1,13 +1,22 @@
1
- import { TabsInterface } from '../interfaces/tabs.interface';
2
- import { classNames, defaultClassNames } from '../utils';
1
+ import { TabsInterface } from '../interfaces';
2
+ import {
3
+ type ClassNameComponent,
4
+ classNames,
5
+ createUseClassNames,
6
+ defaultClassNames,
7
+ } from '../utils';
3
8
 
4
- export const tabsStyle = defaultClassNames<TabsInterface>(
9
+ const tabsConfig: ClassNameComponent<TabsInterface> = ({ scrollable }) => ({
10
+ tabs: classNames(
11
+ 'border-b border-surface-container-highest bg-surface',
12
+ 'flex relative ',
13
+ { 'overflow-x-auto': scrollable },
14
+ ),
15
+ });
16
+
17
+ export const tabsStyle = defaultClassNames<TabsInterface>('tabs', tabsConfig);
18
+
19
+ export const useTabsStyle = createUseClassNames<TabsInterface>(
5
20
  'tabs',
6
- ({ scrollable }) => ({
7
- tabs: classNames(
8
- 'border-b border-surface-container-highest bg-surface',
9
- 'flex relative ',
10
- { 'overflow-x-auto': scrollable },
11
- ),
12
- }),
21
+ tabsConfig,
13
22
  );
@@ -1,104 +1,115 @@
1
1
  import React from 'react';
2
- import { classNames } from '../utils';
3
- import { TextFieldInterface } from '../interfaces/text-field.interface';
4
- import { defaultClassNames } from '../utils/styles/get-classname';
2
+ import {
3
+ type ClassNameComponent,
4
+ classNames,
5
+ createUseClassNames,
6
+ defaultClassNames,
7
+ } from '../utils';
8
+ import { TextFieldInterface } from '../interfaces';
5
9
 
6
- export const textFieldStyle = defaultClassNames<TextFieldInterface>(
7
- 'textField',
8
- ({
9
- disabled,
10
- leadingIcon,
11
- trailingIcon,
12
- variant,
13
- errorText,
14
- isFocused,
15
- value,
16
- suffix,
17
- textLine,
18
- }) => ({
19
- textField: classNames({
20
- 'opacity-[.38]': disabled,
21
- }),
22
- content: classNames(
23
- 'group transition-border duration-200 relative flex items-center ',
24
- { 'h-14': textLine == 'singleLine' },
25
- {
26
- 'border-on-surface-variant':
27
- !errorText?.length && !isFocused && variant == 'filled',
28
- 'border-outline':
29
- !errorText?.length && !isFocused && variant == 'outlined',
30
- 'border-primary': !errorText?.length && isFocused,
31
- 'border-error': !!errorText?.length,
32
- },
33
- { 'bg-on-surface/[0.04]': disabled },
34
- variant == 'filled' && [
35
- 'rounded-t overflow-hidden border-b',
36
- { 'bg-surface-container-highest': !disabled },
37
- ],
10
+ const textFieldConfig: ClassNameComponent<TextFieldInterface> = ({
11
+ disabled,
12
+ leadingIcon,
13
+ trailingIcon,
14
+ variant,
15
+ errorText,
16
+ isFocused,
17
+ value,
18
+ suffix,
19
+ textLine,
20
+ }) => ({
21
+ textField: classNames({
22
+ 'opacity-[.38]': disabled,
23
+ }),
24
+ content: classNames(
25
+ 'group/text-field transition-border duration-200 relative flex items-center ',
26
+ { 'h-14': textLine == 'singleLine' },
27
+ {
28
+ 'border-on-surface-variant':
29
+ !errorText?.length && !isFocused && variant == 'filled',
30
+ 'border-outline':
31
+ !errorText?.length && !isFocused && variant == 'outlined',
32
+ 'border-primary': !errorText?.length && isFocused,
33
+ 'border-error': !!errorText?.length,
34
+ },
35
+ { 'bg-on-surface/[0.04]': disabled },
36
+ variant == 'filled' && [
37
+ 'rounded-t overflow-hidden border-b',
38
+ { 'bg-surface-container-highest': !disabled },
39
+ ],
38
40
 
39
- variant == 'outlined' && [
40
- 'border rounded box-border',
41
- {
42
- 'border-[3px]': isFocused,
43
- },
44
- ]
45
- ),
46
- stateLayer: classNames(
47
- 'absolute -z-10 w-full h-full top-0 left-0',
41
+ variant == 'outlined' && [
42
+ 'border rounded box-border',
48
43
  {
49
- hidden: variant == 'outlined',
44
+ 'border-[3px]': isFocused,
50
45
  },
51
- {
52
- 'group-state-on-surface': !disabled,
53
- 'focus-state-on-surface': isFocused,
54
- }
55
- ),
56
- label: classNames(
57
- 'inline-flex outline-none whitespace-nowrap',
58
- { 'text-on-surface-variant': !disabled && !errorText?.length },
59
- { 'text-on-surface': disabled },
60
- { 'text-error': !!errorText?.length },
61
- { 'text-primary': !errorText?.length && isFocused }
62
- ),
63
- input: classNames(
64
- 'w-full resize-none px-4 text-body-large bg-[inherit] outline-none autofill:transition-colors autofill:duration-[5000000ms]',
65
- {
66
- ' text-on-surface placeholder:text-on-surface-variant': !disabled,
67
- 'placeholder:text-on-surface text-on-surface': disabled,
68
- },
69
- {
70
- 'pr-0': !!suffix,
71
- },
72
- variant == 'filled' && ' pb-2 pt-6',
73
- variant == 'outlined' && 'py-4 relative z-10'
74
- ),
75
- activeIndicator: classNames(
76
- 'absolute w-0 inset-x-0 border-rounded mx-auto bottom-0',
77
- variant == 'filled' && [
78
- 'h-[2px] transition-all duration-300',
79
- { 'bg-primary': !errorText?.length },
80
- { 'bg-error': !!errorText?.length },
81
- { '!w-full': isFocused },
82
- ]
83
- ),
84
- supportingText: classNames(
85
- ' text-body-small px-4 pt-1',
86
- { 'text-on-surface-variant': !disabled && !errorText?.length },
87
- { 'text-on-surface': disabled },
46
+ ],
47
+ ),
48
+ stateLayer: classNames(
49
+ 'absolute -z-10 w-full h-full top-0 left-0',
50
+ {
51
+ hidden: variant == 'outlined',
52
+ },
53
+ {
54
+ 'group-state-on-surface': !disabled,
55
+ 'focus-state-on-surface': isFocused,
56
+ },
57
+ ),
58
+ label: classNames(
59
+ 'inline-flex outline-none whitespace-nowrap',
60
+ { 'text-on-surface-variant': !disabled && !errorText?.length },
61
+ { 'text-on-surface': disabled },
62
+ { 'text-error': !!errorText?.length },
63
+ { 'text-primary': !errorText?.length && isFocused },
64
+ ),
65
+ input: classNames(
66
+ 'w-full resize-none px-4 text-body-large bg-[inherit] outline-none autofill:transition-colors autofill:duration-[5000000ms]',
67
+ {
68
+ ' text-on-surface placeholder:text-on-surface-variant': !disabled,
69
+ 'placeholder:text-on-surface text-on-surface': disabled,
70
+ },
71
+ {
72
+ 'pr-0': !!suffix,
73
+ },
74
+ variant == 'filled' && ' pb-2 pt-6',
75
+ variant == 'outlined' && 'py-4 relative z-10',
76
+ ),
77
+ activeIndicator: classNames(
78
+ 'absolute w-0 inset-x-0 border-rounded mx-auto bottom-0',
79
+ variant == 'filled' && [
80
+ 'h-[2px] transition-all duration-300',
81
+ { 'bg-primary': !errorText?.length },
82
+ { 'bg-error': !!errorText?.length },
88
83
  { '!w-full': isFocused },
89
- { 'text-error': !!errorText?.length }
90
- ),
91
- leadingIcon: classNames([
92
- 'h-12 ml-3 flex items-center justify-center',
93
- { 'cursor-text': !React.isValidElement(leadingIcon) },
94
- ]),
95
- trailingIcon: classNames('h-12 w-12 flex items-center justify-center', {
96
- 'cursor-text': !React.isValidElement(trailingIcon),
97
- }),
98
- suffix: classNames(
99
- 'text-on-surface-variant pl-0 pr-4',
100
- variant == 'filled' && ' pb-2 pt-6',
101
- variant == 'outlined' && 'py-4 relative z-10'
102
- ),
103
- })
84
+ ],
85
+ ),
86
+ supportingText: classNames(
87
+ ' text-body-small px-4 pt-1',
88
+ { 'text-on-surface-variant': !disabled && !errorText?.length },
89
+ { 'text-on-surface': disabled },
90
+ { '!w-full': isFocused },
91
+ { 'text-error': !!errorText?.length },
92
+ ),
93
+ leadingIcon: classNames([
94
+ 'h-12 ml-3 flex items-center justify-center',
95
+ { 'cursor-text': !React.isValidElement(leadingIcon) },
96
+ ]),
97
+ trailingIcon: classNames('h-12 w-12 flex items-center justify-center', {
98
+ 'cursor-text': !React.isValidElement(trailingIcon),
99
+ }),
100
+ suffix: classNames(
101
+ 'text-on-surface-variant pl-0 pr-4',
102
+ variant == 'filled' && ' pb-2 pt-6',
103
+ variant == 'outlined' && 'py-4 relative z-10',
104
+ ),
105
+ });
106
+
107
+ export const textFieldStyle = defaultClassNames<TextFieldInterface>(
108
+ 'textField',
109
+ textFieldConfig,
110
+ );
111
+
112
+ export const useTextFieldStyle = createUseClassNames<TextFieldInterface>(
113
+ 'textField',
114
+ textFieldConfig,
104
115
  );