mtrl 0.2.7 → 0.2.8

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 (164) hide show
  1. package/demo/build.ts +349 -0
  2. package/demo/index.html +110 -0
  3. package/demo/main.js +448 -0
  4. package/demo/styles.css +239 -0
  5. package/package.json +14 -3
  6. package/server.ts +86 -0
  7. package/src/components/badge/api.ts +23 -14
  8. package/src/components/badge/badge.ts +2 -2
  9. package/src/components/badge/config.ts +10 -11
  10. package/src/components/badge/features.ts +15 -10
  11. package/src/components/badge/index.ts +27 -2
  12. package/src/components/badge/types.ts +28 -8
  13. package/src/components/bottom-app-bar/bottom-app-bar.ts +2 -44
  14. package/src/components/bottom-app-bar/config.ts +1 -45
  15. package/src/components/bottom-app-bar/index.ts +7 -1
  16. package/src/components/bottom-app-bar/types.ts +7 -1
  17. package/src/components/button/button.ts +0 -1
  18. package/src/components/button/config.ts +1 -2
  19. package/src/components/button/index.ts +10 -2
  20. package/src/components/button/types.ts +14 -2
  21. package/src/components/card/config.ts +17 -9
  22. package/src/components/card/content.ts +8 -10
  23. package/src/components/card/features.ts +4 -6
  24. package/src/components/card/index.ts +29 -2
  25. package/src/components/card/types.ts +6 -23
  26. package/src/components/checkbox/config.ts +3 -4
  27. package/src/components/checkbox/index.ts +1 -2
  28. package/src/components/checkbox/types.ts +12 -3
  29. package/src/components/chip/api.ts +170 -221
  30. package/src/components/chip/chip.ts +34 -302
  31. package/src/components/chip/config.ts +1 -2
  32. package/src/components/chip/index.ts +10 -2
  33. package/src/components/chip/types.ts +224 -35
  34. package/src/components/datepicker/api.ts +18 -25
  35. package/src/components/datepicker/config.ts +9 -12
  36. package/src/components/datepicker/datepicker.ts +7 -12
  37. package/src/components/datepicker/index.ts +10 -7
  38. package/src/components/datepicker/render.ts +16 -18
  39. package/src/components/datepicker/types.ts +164 -35
  40. package/src/components/datepicker/utils.ts +1 -2
  41. package/src/components/dialog/api.ts +7 -8
  42. package/src/components/dialog/config.ts +3 -4
  43. package/src/components/dialog/features.ts +56 -22
  44. package/src/components/dialog/index.ts +38 -8
  45. package/src/components/dialog/types.ts +33 -10
  46. package/src/components/divider/index.ts +5 -1
  47. package/src/components/extended-fab/config.ts +6 -2
  48. package/src/components/extended-fab/index.ts +7 -2
  49. package/src/components/extended-fab/types.ts +21 -4
  50. package/src/components/fab/config.ts +3 -4
  51. package/src/components/fab/fab.ts +1 -1
  52. package/src/components/fab/index.ts +7 -2
  53. package/src/components/fab/types.ts +21 -4
  54. package/src/components/list/config.ts +4 -5
  55. package/src/components/list/features.ts +6 -7
  56. package/src/components/list/index.ts +7 -9
  57. package/src/components/list/list-item.ts +12 -13
  58. package/src/components/list/types.ts +50 -5
  59. package/src/components/list/utils.ts +30 -3
  60. package/src/components/menu/features/items-manager.ts +9 -9
  61. package/src/components/menu/features/positioning.ts +7 -7
  62. package/src/components/menu/features/visibility.ts +7 -7
  63. package/src/components/menu/index.ts +7 -9
  64. package/src/components/menu/menu-item.ts +6 -6
  65. package/src/components/menu/menu.ts +22 -0
  66. package/src/components/menu/types.ts +29 -10
  67. package/src/components/menu/utils.ts +67 -0
  68. package/src/components/navigation/config.ts +22 -10
  69. package/src/components/navigation/features/items.ts +31 -27
  70. package/src/components/navigation/index.ts +0 -6
  71. package/src/components/navigation/nav-item.ts +12 -24
  72. package/src/components/navigation/navigation.ts +4 -6
  73. package/src/components/navigation/types.ts +228 -203
  74. package/src/components/progress/api.ts +2 -3
  75. package/src/components/progress/config.ts +2 -3
  76. package/src/components/progress/index.ts +0 -1
  77. package/src/components/progress/progress.ts +1 -2
  78. package/src/components/progress/types.ts +186 -33
  79. package/src/components/radios/config.ts +1 -1
  80. package/src/components/radios/index.ts +0 -1
  81. package/src/components/radios/types.ts +0 -7
  82. package/src/components/search/config.ts +1 -2
  83. package/src/components/search/features/search.ts +14 -15
  84. package/src/components/search/features/states.ts +5 -1
  85. package/src/components/search/features/structure.ts +3 -4
  86. package/src/components/search/index.ts +0 -3
  87. package/src/components/search/types.ts +18 -6
  88. package/src/components/segmented-button/config.ts +20 -7
  89. package/src/components/segmented-button/segment.ts +6 -7
  90. package/src/components/segmented-button/segmented-button.ts +4 -5
  91. package/src/components/segmented-button/types.ts +37 -2
  92. package/src/components/slider/types.ts +34 -8
  93. package/src/components/snackbar/config.ts +2 -3
  94. package/src/components/snackbar/constants.ts +0 -32
  95. package/src/components/snackbar/index.ts +0 -1
  96. package/src/components/snackbar/position.ts +9 -1
  97. package/src/components/snackbar/types.ts +122 -46
  98. package/src/components/switch/config.ts +2 -3
  99. package/src/components/switch/index.ts +0 -1
  100. package/src/components/switch/types.ts +3 -2
  101. package/src/components/tabs/config.ts +3 -4
  102. package/src/components/tabs/index.ts +0 -15
  103. package/src/components/tabs/tab-api.ts +12 -4
  104. package/src/components/tabs/tab.ts +18 -6
  105. package/src/components/tabs/types.ts +13 -3
  106. package/src/components/textfield/config.ts +2 -3
  107. package/src/components/textfield/index.ts +0 -1
  108. package/src/components/textfield/types.ts +17 -3
  109. package/src/components/timepicker/api.ts +1 -1
  110. package/src/components/timepicker/clockdial.ts +1 -1
  111. package/src/components/timepicker/config.ts +102 -4
  112. package/src/components/timepicker/index.ts +1 -6
  113. package/src/components/timepicker/render.ts +1 -1
  114. package/src/components/timepicker/timepicker.ts +1 -1
  115. package/src/components/tooltip/api.ts +1 -1
  116. package/src/components/tooltip/config.ts +27 -6
  117. package/src/components/tooltip/index.ts +0 -1
  118. package/src/components/tooltip/types.ts +13 -3
  119. package/src/core/compose/features/textlabel.ts +0 -3
  120. package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +1 -1
  121. package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +70 -67
  122. package/src/styles/main.scss +98 -49
  123. package/src/components/badge/constants.ts +0 -40
  124. package/src/components/button/constants.ts +0 -11
  125. package/src/components/card/constants.ts +0 -84
  126. package/src/components/datepicker/constants.ts +0 -98
  127. package/src/components/dialog/constants.ts +0 -32
  128. package/src/components/extended-fab/constants.ts +0 -36
  129. package/src/components/fab/constants.ts +0 -41
  130. package/src/components/menu/constants.ts +0 -154
  131. package/src/components/navigation/constants.ts +0 -200
  132. package/src/components/progress/constants.ts +0 -29
  133. package/src/components/search/constants.ts +0 -21
  134. package/src/components/segmented-button/constants.ts +0 -42
  135. package/src/components/switch/constants.ts +0 -80
  136. package/src/components/tabs/constants.ts +0 -89
  137. package/src/components/timepicker/constants.ts +0 -138
  138. /package/src/{components/badge/_styles.scss → styles/components/_badge.scss} +0 -0
  139. /package/src/{components/bottom-app-bar/_styles.scss → styles/components/_bottom-app-bar.scss} +0 -0
  140. /package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -0
  141. /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
  142. /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
  143. /package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -0
  144. /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
  145. /package/src/{components/datepicker/_styles.scss → styles/components/_datepicker.scss} +0 -0
  146. /package/src/{components/dialog/_styles.scss → styles/components/_dialog.scss} +0 -0
  147. /package/src/{components/divider/_styles.scss → styles/components/_divider.scss} +0 -0
  148. /package/src/{components/extended-fab/_styles.scss → styles/components/_extended-fab.scss} +0 -0
  149. /package/src/{components/fab/_styles.scss → styles/components/_fab.scss} +0 -0
  150. /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
  151. /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
  152. /package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +0 -0
  153. /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
  154. /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
  155. /package/src/{components/search/_styles.scss → styles/components/_search.scss} +0 -0
  156. /package/src/{components/segmented-button/_styles.scss → styles/components/_segmented-button.scss} +0 -0
  157. /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
  158. /package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +0 -0
  159. /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
  160. /package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -0
  161. /package/src/{components/timepicker/_styles.scss → styles/components/_timepicker.scss} +0 -0
  162. /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
  163. /package/src/{components/top-app-bar/_styles.scss → styles/components/_top-app-bar.scss} +0 -0
  164. /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
@@ -8,6 +8,18 @@ import { createTabConfig } from './config';
8
8
  import createButton from '../button';
9
9
  import createBadge from '../badge';
10
10
 
11
+ /**
12
+ * Tab layout types
13
+ */
14
+ export const TAB_LAYOUT = {
15
+ /** Icon-only tab layout */
16
+ ICON_ONLY: 'icon-only',
17
+ /** Text-only tab layout */
18
+ TEXT_ONLY: 'text-only',
19
+ /** Icon and text layout */
20
+ ICON_AND_TEXT: 'icon-and-text'
21
+ };
22
+
11
23
  /**
12
24
  * Creates a new Tab component following MD3 guidelines
13
25
  * @param {TabConfig} config - Tab configuration object
@@ -49,7 +61,7 @@ export const createTab = (config: TabConfig = {}): TabComponent => {
49
61
  // Set up tab accessibility attributes
50
62
  baseComponent.element.setAttribute('role', 'tab');
51
63
  baseComponent.element.setAttribute('aria-selected',
52
- baseConfig.state === TAB_STATES.ACTIVE ? 'true' : 'false');
64
+ baseConfig.state === 'active' ? 'true' : 'false');
53
65
 
54
66
  // For better accessibility
55
67
  if (baseConfig.value) {
@@ -58,8 +70,8 @@ export const createTab = (config: TabConfig = {}): TabComponent => {
58
70
  }
59
71
 
60
72
  // Add active state if specified in config
61
- if (baseConfig.state === TAB_STATES.ACTIVE) {
62
- baseComponent.element.classList.add(`${baseComponent.getClass('tab')}--${TAB_STATES.ACTIVE}`);
73
+ if (baseConfig.state === 'active') {
74
+ baseComponent.element.classList.add(`${baseComponent.getClass('tab')}--active`);
63
75
  }
64
76
 
65
77
  // Forward button events to our component
@@ -95,7 +107,7 @@ export const createTab = (config: TabConfig = {}): TabComponent => {
95
107
  },
96
108
 
97
109
  activate() {
98
- this.element.classList.add(`${this.getClass('tab')}--${TAB_STATES.ACTIVE}`);
110
+ this.element.classList.add(`${this.getClass('tab')}--active`);
99
111
  this.element.setAttribute('aria-selected', 'true');
100
112
 
101
113
  // Dispatch event for screen readers
@@ -109,13 +121,13 @@ export const createTab = (config: TabConfig = {}): TabComponent => {
109
121
  },
110
122
 
111
123
  deactivate() {
112
- this.element.classList.remove(`${this.getClass('tab')}--${TAB_STATES.ACTIVE}`);
124
+ this.element.classList.remove(`${this.getClass('tab')}--active`);
113
125
  this.element.setAttribute('aria-selected', 'false');
114
126
  return this;
115
127
  },
116
128
 
117
129
  isActive() {
118
- return this.element.classList.contains(`${this.getClass('tab')}--${TAB_STATES.ACTIVE}`);
130
+ return this.element.classList.contains(`${this.getClass('tab')}--active`);
119
131
  },
120
132
 
121
133
  enable() {
@@ -1,8 +1,18 @@
1
1
  // src/components/tabs/types.ts
2
- import { TABS_VARIANTS, TAB_STATES, TAB_LAYOUT } from './constants';
3
2
  import { BadgeComponent } from '../badge/types';
4
3
  import { TabIndicator } from './indicator';
5
4
 
5
+ /**
6
+ * Available tabs variants
7
+ */
8
+ export type TabsVariant = 'primary' | 'secondary';
9
+
10
+ /**
11
+ * Available tabs states
12
+ */
13
+
14
+ export type TabStates = 'active' | 'inactive' | 'disabled';
15
+
6
16
  /**
7
17
  * Configuration for the tab indicator
8
18
  * @category Components
@@ -55,7 +65,7 @@ export interface TabConfig {
55
65
  * Tab state that determines if it's the active destination
56
66
  * @default 'inactive'
57
67
  */
58
- state?: keyof typeof TAB_STATES | string;
68
+ state?: TabStates | string;
59
69
 
60
70
  /**
61
71
  * Whether the tab is initially disabled
@@ -154,7 +164,7 @@ export interface TabsConfig {
154
164
  * Tabs variant (primary or secondary)
155
165
  * @default 'primary'
156
166
  */
157
- variant?: keyof typeof TABS_VARIANTS | string;
167
+ variant?: TabsVariant | string;
158
168
 
159
169
  /**
160
170
  * Initial tabs to create
@@ -5,14 +5,13 @@ import {
5
5
  BaseComponentConfig
6
6
  } from '../../core/config/component-config';
7
7
  import { TextfieldConfig, BaseComponent, ApiOptions } from './types';
8
- import { TEXTFIELD_VARIANTS, TEXTFIELD_TYPES } from './constants';
9
8
 
10
9
  /**
11
10
  * Default configuration for the Textfield component
12
11
  */
13
12
  export const defaultConfig: TextfieldConfig = {
14
- type: TEXTFIELD_TYPES.TEXT,
15
- variant: TEXTFIELD_VARIANTS.FILLED
13
+ type: 'text',
14
+ variant: 'filled'
16
15
  };
17
16
 
18
17
  /**
@@ -1,4 +1,3 @@
1
1
  // src/components/textfield/index.ts
2
2
  export { default } from './textfield'
3
- export { TEXTFIELD_VARIANTS, TEXTFIELD_TYPES } from './constants'
4
3
  export { TextfieldConfig, TextfieldComponent } from './types'
@@ -1,15 +1,29 @@
1
1
  // src/components/textfield/types.ts
2
- import { TEXTFIELD_VARIANTS, TEXTFIELD_TYPES } from './constants';
2
+
3
+ /**
4
+ * Available Textfield variants
5
+ */
6
+ export type TextfieldVariant = 'filled' | 'outlined';
7
+
8
+ /**
9
+ * Available Textfield states
10
+ */
11
+ export type TextfieldStates = 'active' | 'inactive' | 'disabled';
12
+
13
+ /**
14
+ * Available Textfield types
15
+ */
16
+ export type TextfieldTypes = 'text' | 'password' | 'email' | 'number' | 'tel' | 'url' | 'search' | 'multiline';
3
17
 
4
18
  /**
5
19
  * Configuration interface for the Textfield component
6
20
  */
7
21
  export interface TextfieldConfig {
8
22
  /** Input type (text, password, email, etc.) */
9
- type?: keyof typeof TEXTFIELD_TYPES | string;
23
+ type?: TextfieldTypes | string;
10
24
 
11
25
  /** Visual variant (filled, outlined) */
12
- variant?: keyof typeof TEXTFIELD_VARIANTS | string;
26
+ variant?: TextfieldVariant | string;
13
27
 
14
28
  /** Input name attribute */
15
29
  name?: string;
@@ -9,7 +9,7 @@ import {
9
9
  TIME_FORMAT,
10
10
  TIME_PERIOD
11
11
  } from './types';
12
- import { EVENTS, SELECTORS } from './constants';
12
+ import { EVENTS, SELECTORS } from './config';
13
13
  import { formatTime, padZero } from './utils';
14
14
  import { renderTimePicker } from './render';
15
15
  import { renderClockDial, getTimeValueFromClick } from './clockdial';
@@ -1,7 +1,7 @@
1
1
  // src/components/timepicker/clockdial.ts
2
2
 
3
3
  import { TimeValue, TIME_FORMAT, TIME_PICKER_TYPE, TIME_PERIOD } from './types';
4
- import { DIAL_CONSTANTS, TIME_CONSTANTS } from './constants';
4
+ import { DIAL_CONSTANTS, TIME_CONSTANTS } from './config';
5
5
  import { padZero } from './utils';
6
6
 
7
7
  /**
@@ -9,10 +9,108 @@ import { TimePickerConfig } from './types';
9
9
  import {
10
10
  TIME_PICKER_TYPE,
11
11
  TIME_PICKER_ORIENTATION,
12
- TIME_FORMAT,
13
- DEFAULT_CLOCK_ICON,
14
- DEFAULT_KEYBOARD_ICON
15
- } from './constants';
12
+ TIME_FORMAT
13
+ } from './types';
14
+
15
+ export const DIAL_CONSTANTS = {
16
+ DIAMETER: 256,
17
+ INNER_RADIUS: 65,
18
+ OUTER_RADIUS: 110,
19
+ NUMBER_SIZE: 40,
20
+ CENTER_SIZE: 8,
21
+ HAND_SIZE: 36,
22
+ TRACK_WIDTH: 2,
23
+ };
24
+
25
+ /**
26
+ * Time constants used in the time picker.
27
+ */
28
+ export const TIME_CONSTANTS = {
29
+ HOURS_12: Array.from({ length: 12 }, (_, i) => (i === 0 ? 12 : i)),
30
+ HOURS_24: Array.from({ length: 24 }, (_, i) => i),
31
+ MINUTES: Array.from({ length: 60 }, (_, i) => i),
32
+ SECONDS: Array.from({ length: 60 }, (_, i) => i),
33
+ };
34
+
35
+ /**
36
+ * Custom events fired by the time picker.
37
+ */
38
+ export const EVENTS = {
39
+ CHANGE: 'change',
40
+ OPEN: 'open',
41
+ CLOSE: 'close',
42
+ CONFIRM: 'confirm',
43
+ CANCEL: 'cancel',
44
+ };
45
+
46
+ /**
47
+ * Element selectors for time picker components.
48
+ * Used for DOM manipulation and event delegation.
49
+ */
50
+ export const SELECTORS = {
51
+ CONTAINER: '.mtrl-time-picker',
52
+ MODAL: '.mtrl-time-picker-modal',
53
+ DIALOG: '.mtrl-time-picker-dialog',
54
+ TITLE: '.mtrl-time-picker-title',
55
+ CONTENT: '.mtrl-time-picker-content',
56
+ DIAL: '.mtrl-time-picker-dial',
57
+ DIAL_CANVAS: '.mtrl-time-picker-dial-canvas',
58
+ DIAL_FACE: '.mtrl-time-picker-dial-face',
59
+ DIAL_HAND: '.mtrl-time-picker-dial-hand',
60
+ DIAL_CENTER: '.mtrl-time-picker-dial-center',
61
+ DIAL_NUMBERS: '.mtrl-time-picker-dial-numbers',
62
+ DIAL_NUMBER: '.mtrl-time-picker-dial-number',
63
+ INPUT_CONTAINER: '.mtrl-time-picker-input-container',
64
+ HOURS_INPUT: '.mtrl-time-picker-hours',
65
+ MINUTES_INPUT: '.mtrl-time-picker-minutes',
66
+ SECONDS_INPUT: '.mtrl-time-picker-seconds',
67
+ SEPARATOR: '.mtrl-time-picker-separator',
68
+ PERIOD_CONTAINER: '.mtrl-time-picker-period',
69
+ PERIOD_AM: '.mtrl-time-picker-period-am',
70
+ PERIOD_PM: '.mtrl-time-picker-period-pm',
71
+ ACTIONS: '.mtrl-time-picker-actions',
72
+ TOGGLE_TYPE_BUTTON: '.mtrl-time-picker-toggle-type',
73
+ CANCEL_BUTTON: '.mtrl-time-picker-cancel',
74
+ CONFIRM_BUTTON: '.mtrl-time-picker-confirm',
75
+ };
76
+
77
+ /**
78
+ * Z-index values for different parts of the time picker.
79
+ */
80
+ export const Z_INDEX = {
81
+ MODAL: 1050,
82
+ DIALOG: 1051,
83
+ };
84
+
85
+ /**
86
+ * Default clock icon for time picker.
87
+ * Simple clock SVG.
88
+ */
89
+ export const DEFAULT_CLOCK_ICON = `
90
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
91
+ <circle cx="12" cy="12" r="10"></circle>
92
+ <polyline points="12 6 12 12 16 14"></polyline>
93
+ </svg>
94
+ `
95
+
96
+ /**
97
+ * Default keyboard icon for time picker.
98
+ * Simple keyboard SVG.
99
+ */
100
+ export const DEFAULT_KEYBOARD_ICON = `
101
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
102
+ <rect x="2" y="4" width="20" height="16" rx="2" ry="2"></rect>
103
+ <line x1="6" y1="8" x2="6" y2="8"></line>
104
+ <line x1="10" y1="8" x2="10" y2="8"></line>
105
+ <line x1="14" y1="8" x2="14" y2="8"></line>
106
+ <line x1="18" y1="8" x2="18" y2="8"></line>
107
+ <line x1="6" y1="12" x2="6" y2="12"></line>
108
+ <line x1="10" y1="12" x2="10" y2="12"></line>
109
+ <line x1="14" y1="12" x2="14" y2="12"></line>
110
+ <line x1="18" y1="12" x2="18" y2="12"></line>
111
+ <line x1="6" y1="16" x2="18" y2="16"></line>
112
+ </svg>
113
+ `;
16
114
 
17
115
  /**
18
116
  * Default configuration for the TimePicker component
@@ -1,8 +1,3 @@
1
+ // src/components/timepicker/index.ts
1
2
  export { default } from './timepicker';
2
- export {
3
- TIME_PICKER_TYPE,
4
- TIME_PICKER_ORIENTATION,
5
- TIME_FORMAT,
6
- TIME_PERIOD
7
- } from './constants';
8
3
  export type { TimePickerConfig, TimePickerComponent, TimeValue } from './types';
@@ -7,7 +7,7 @@ import {
7
7
  DEFAULT_CLOCK_ICON,
8
8
  DEFAULT_KEYBOARD_ICON,
9
9
  SELECTORS
10
- } from './constants';
10
+ } from './config';
11
11
  import { padZero, convertTo12Hour } from './utils';
12
12
  import { renderClockDial, getTimeValueFromClick } from './clockdial';
13
13
 
@@ -15,7 +15,7 @@ import {
15
15
  EVENTS,
16
16
  SELECTORS,
17
17
  Z_INDEX
18
- } from './constants';
18
+ } from './config';
19
19
  import { createTimePickerAPI } from './api';
20
20
  import { renderTimePicker } from './render';
21
21
  import { parseTime, formatTime } from './utils';
@@ -1,6 +1,6 @@
1
1
  // src/components/tooltip/api.ts
2
2
  import { TooltipComponent } from './types';
3
- import { TOOLTIP_POSITIONS, DEFAULT_OFFSET, DEFAULT_ARROW_SIZE } from './constants';
3
+ import { TOOLTIP_POSITIONS, DEFAULT_OFFSET, DEFAULT_ARROW_SIZE } from './config';
4
4
 
5
5
  interface ApiOptions {
6
6
  lifecycle: {
@@ -4,12 +4,33 @@ import {
4
4
  createElementConfig
5
5
  } from '../../core/config/component-config';
6
6
  import { TooltipConfig } from './types';
7
- import {
8
- TOOLTIP_POSITIONS,
9
- TOOLTIP_VARIANTS,
10
- DEFAULT_SHOW_DELAY,
11
- DEFAULT_HIDE_DELAY
12
- } from './constants';
7
+
8
+
9
+ export const TOOLTIP_POSITIONS = {
10
+ TOP: 'top',
11
+ RIGHT: 'right',
12
+ BOTTOM: 'bottom',
13
+ LEFT: 'left',
14
+ TOP_START: 'top-start',
15
+ TOP_END: 'top-end',
16
+ RIGHT_START: 'right-start',
17
+ RIGHT_END: 'right-end',
18
+ BOTTOM_START: 'bottom-start',
19
+ BOTTOM_END: 'bottom-end',
20
+ LEFT_START: 'left-start',
21
+ LEFT_END: 'left-end'
22
+ }
23
+
24
+ export const TOOLTIP_VARIANTS = {
25
+ DEFAULT: 'default',
26
+ RICH: 'rich',
27
+ PLAIN: 'plain'
28
+ }
29
+
30
+ export const DEFAULT_SHOW_DELAY = 300
31
+ export const DEFAULT_HIDE_DELAY = 100
32
+ export const DEFAULT_OFFSET = 8
33
+ export const DEFAULT_ARROW_SIZE = 8
13
34
 
14
35
  /**
15
36
  * Default configuration for the Tooltip component
@@ -1,4 +1,3 @@
1
1
  // src/components/tooltip/index.ts
2
2
  export { default } from './tooltip';
3
- export { TOOLTIP_POSITIONS, TOOLTIP_VARIANTS } from './constants';
4
3
  export { TooltipConfig, TooltipComponent } from './types';
@@ -1,5 +1,15 @@
1
1
  // src/components/tooltip/types.ts
2
- import { TOOLTIP_POSITIONS, TOOLTIP_VARIANTS } from './constants';
2
+
3
+ /**
4
+ * Available Textfield variants
5
+ */
6
+ export type TooltipVariant = 'default' | 'rich' | 'plain';
7
+
8
+ /**
9
+ * Available Textfield states
10
+ */
11
+ export type TooltipPosition = 'top' | 'right' | 'bottom' | 'left' | 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end';
12
+
3
13
 
4
14
  /**
5
15
  * Configuration interface for the Tooltip component
@@ -22,13 +32,13 @@ export interface TooltipConfig {
22
32
  * Tooltip position relative to the target
23
33
  * @default 'bottom'
24
34
  */
25
- position?: keyof typeof TOOLTIP_POSITIONS | string;
35
+ position?: TooltipPosition | string;
26
36
 
27
37
  /**
28
38
  * Tooltip variant that determines visual styling
29
39
  * @default 'default'
30
40
  */
31
- variant?: keyof typeof TOOLTIP_VARIANTS | string;
41
+ variant?: TooltipVariants | string;
32
42
 
33
43
  /**
34
44
  * Whether the tooltip is initially visible
@@ -89,9 +89,6 @@ export const withTextLabel = <T extends TextLabelConfig>(config: T = {} as T) =>
89
89
  component.element.appendChild(labelElement);
90
90
  }
91
91
 
92
- console.log('componentName', component.componentName)
93
- console.log('position', position)
94
-
95
92
  if (position && component.componentName !== 'slider') {
96
93
  component.element.classList.add(`${config.prefix}-${config.componentName}--label-${position}`);
97
94
  }
@@ -90,7 +90,7 @@ $container: '#{base.$prefix}-tabs';
90
90
  max-width: 360px;
91
91
  padding: 0 16px;
92
92
  border: none;
93
- border-radius: 5px;
93
+ border-radius: 5px 5px 0 0;
94
94
  background-color: transparent;
95
95
  color: t.color('on-surface-variant');
96
96
  cursor: pointer;
@@ -131,14 +131,14 @@ $component: '#{base.$prefix}-textfield';
131
131
 
132
132
  // ===== FILLED VARIANT =====
133
133
  &--filled {
134
- border-bottom: 1px solid t.color('outline');
135
-
136
134
  .#{$component}-input {
137
135
  background-color: t.color('surface-container-highest');
138
136
  padding: 20px 16px 7px;
137
+ border-bottom: 1px solid t.color('outline');
139
138
  border-radius: f.get-shape('extra-small') f.get-shape('extra-small') 0 0;
140
139
  @include m.motion-transition(background-color, border-color);
141
-
140
+
141
+
142
142
  &:focus {
143
143
  padding-bottom: 6px;
144
144
  }
@@ -161,6 +161,19 @@ $component: '#{base.$prefix}-textfield';
161
161
  }
162
162
  }
163
163
 
164
+ &::before {
165
+ content: '';
166
+ position: absolute;
167
+ opacity: 0;
168
+ bottom: 0;
169
+ width: 100%;
170
+ height: 2px;
171
+ background-color: t.color('primary');
172
+ border-radius: 0;
173
+ pointer-events: none;
174
+ transition: 0.3s opacity ease;
175
+ }
176
+
164
177
  // Populated field (not empty) or focused field label position
165
178
  &:not(.#{$component}--empty) .#{$component}-label,
166
179
  &.#{$component}--focused .#{$component}-label {
@@ -168,48 +181,33 @@ $component: '#{base.$prefix}-textfield';
168
181
  }
169
182
 
170
183
  // Focus state
171
- &.#{$component}--focused {
172
- border-bottom: 2px solid t.color('primary');
173
-
184
+ &.#{$component}--focused {
174
185
  .#{$component}-label {
175
186
  color: t.color('primary');
176
187
  }
177
188
 
178
- .#{$component}-input {
179
- height: 55px;
180
- padding: 20px 16px 6px;
181
- }
182
-
183
-
184
- &:hover {
185
- border-bottom: 2px solid t.color('primary');
189
+ &::before {
190
+ opacity: 1
186
191
  }
187
192
  }
188
193
 
189
194
  // Hover state
190
- &:hover {
191
- border-bottom: 1px solid t.color('primary');
192
-
195
+ &:hover {
193
196
  .#{$component}-label {
194
197
  color: t.color('primary');
195
198
  }
196
199
  }
197
200
 
198
201
  // Error state
199
- &.#{$component}--error {
200
- border-bottom: 2px solid t.color('error');
201
-
202
+ &.#{$component}--error {
203
+ &::before {
204
+ opacity: 1;
205
+ background-color: t.color('error');
206
+ }
207
+
202
208
  .#{$component}-label {
203
209
  color: t.color('error');
204
210
  }
205
-
206
- &:hover {
207
- border-bottom: 2px solid t.color('error');
208
- }
209
-
210
- &.#{$component}--focused {
211
- border-bottom: 2px solid t.color('error');
212
- }
213
211
  }
214
212
 
215
213
  // Disabled state
@@ -233,13 +231,13 @@ $component: '#{base.$prefix}-textfield';
233
231
 
234
232
  // ===== OUTLINED VARIANT =====
235
233
  &--outlined {
236
- border: 1px solid t.color('outline');
237
234
  border-radius: f.get-shape('extra-small');
238
235
  @include m.motion-transition(border-color);
239
236
 
240
237
  .#{$component}-input {
241
238
  background-color: transparent;
242
- padding: 13px 16px 14px;
239
+ padding: 12px 15px 13px;
240
+ border: 1px solid t.color('outline');
243
241
  @include m.motion-transition(padding);
244
242
 
245
243
  // Autofill styles for outlined variant
@@ -249,8 +247,6 @@ $component: '#{base.$prefix}-textfield';
249
247
  & ~ .#{$component}-label {
250
248
  background-color: t.color('surface');
251
249
  transform: translateY(-145%) scale(0.75);
252
- left: 13px;
253
- padding: 0 4px;
254
250
  }
255
251
  }
256
252
 
@@ -258,73 +254,80 @@ $component: '#{base.$prefix}-textfield';
258
254
  & ~ .#{$component}-label {
259
255
  background-color: t.color('surface');
260
256
  transform: translateY(-145%) scale(0.75);
261
- left: 13px;
262
- padding: 0 4px;
263
257
  }
264
258
  }
265
259
  }
266
260
 
261
+ .#{$component}-label {
262
+ padding: 0 4px;
263
+ left: 12px;
264
+ top: 49%;
265
+ }
266
+
267
+ &::before {
268
+ content: '';
269
+ position: absolute;
270
+ opacity: 0;
271
+ width: 100%;
272
+ height: 100%;
273
+ border: 2px solid t.color('primary');
274
+ border-radius: f.get-shape('extra-small');
275
+ pointer-events: none;
276
+ transition: 0.2s opacity ease;
277
+ }
278
+
267
279
  // Populated field (not empty) or focused field label position
268
280
  &:not(.#{$component}--empty) .#{$component}-label,
269
281
  &.#{$component}--focused .#{$component}-label {
270
- background-color: t.color('surface');
271
- transform: translateY(-145%) scale(0.75);
272
- left: 13px;
273
282
  padding: 0 4px;
283
+ background-color: t.color('surface');
284
+ transform: translateY(-147%) scale(0.75);
285
+
274
286
  }
275
287
 
276
288
  // Focus state
277
289
  &.#{$component}--focused {
278
- border: 2px solid t.color('primary');
279
-
280
- .#{$component}-label {
281
- color: t.color('primary');
282
- border-radius: 2px;
283
- left: 12px;
290
+ &::before {
291
+ opacity: 1;
284
292
  }
285
-
286
- .#{$component}-input {
287
- height: 54px;
288
- padding: 12px 15px 13px;
289
- }
290
-
291
293
  &:hover {
292
- border: 2px solid t.color('primary');
294
+ &::before {
295
+ border-width: 2px;
296
+ }
293
297
  }
294
298
  }
295
299
 
296
300
  // Hover state
297
- &:hover {
298
- border: 1px solid t.color('primary');
299
-
301
+ &:hover {
300
302
  .#{$component}-label {
301
303
  color: t.color('primary');
302
304
  }
305
+
306
+ &::before {
307
+ opacity: 1;
308
+ border: 1px solid t.color('primary');
309
+ }
303
310
  }
304
311
 
305
312
  // Error state
306
- &.#{$component}--error {
307
- border: 2px solid t.color('error');
308
-
313
+ &.#{$component}--error {
314
+ &::before {
315
+ opacity: 1;
316
+ border: 2px solid t.color('error');
317
+ }
318
+
309
319
  .#{$component}-label {
310
320
  color: t.color('error');
311
- left: 12px;
312
- }
313
-
314
- .#{$component}-input {
315
- padding: 12px 15px 13px;
316
- }
317
-
318
- &:hover,
319
- &.#{$component}--focused {
320
- border: 2px solid t.color('error');
321
321
  }
322
322
  }
323
323
 
324
324
  // Disabled state
325
325
  &.#{$component}--disabled {
326
- border-color: t.alpha('on-surface', 0.38);
327
326
  pointer-events: none;
327
+ &::before {
328
+ opacity: 1;
329
+ border: 1px solid t.alpha('on-surface', 0.38);
330
+ }
328
331
  }
329
332
 
330
333
  // RTL support