mtrl 0.8.0 → 0.9.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 (245) hide show
  1. package/dist/components/badge/config.d.ts +2 -2
  2. package/dist/components/bottom-sheet/bottom-sheet.js +1 -1
  3. package/dist/components/bottom-sheet/config.d.ts +2 -2
  4. package/dist/components/bottom-sheet/features/drag.d.ts +2 -2
  5. package/dist/components/bottom-sheet/features/drag.js +1 -1
  6. package/dist/components/button/api.d.ts +3 -3
  7. package/dist/components/button/button.d.ts +1 -1
  8. package/dist/components/button/config.d.ts +2 -2
  9. package/dist/components/button/features/progress.d.ts +17 -5
  10. package/dist/components/button-group/config.d.ts +20 -0
  11. package/dist/components/card/api.d.ts +10 -1
  12. package/dist/components/card/api.js +6 -1
  13. package/dist/components/card/card.js +1 -1
  14. package/dist/components/card/config.d.ts +15 -9
  15. package/dist/components/card/features.d.ts +2 -1
  16. package/dist/components/card/types.d.ts +5 -4
  17. package/dist/components/carousel/config.d.ts +2 -2
  18. package/dist/components/checkbox/config.d.ts +2 -2
  19. package/dist/components/checkbox/types.d.ts +15 -16
  20. package/dist/components/chips/api.d.ts +6 -6
  21. package/dist/components/chips/chip/api.d.ts +2 -2
  22. package/dist/components/chips/chip/config.d.ts +6 -7
  23. package/dist/components/chips/config.d.ts +2 -2
  24. package/dist/components/chips/features/dom.js +0 -1
  25. package/dist/components/chips/types.d.ts +12 -1
  26. package/dist/components/datepicker/api.d.ts +5 -2
  27. package/dist/components/datepicker/config.d.ts +16 -13
  28. package/dist/components/datepicker/datepicker.js +10 -4
  29. package/dist/components/datepicker/render.d.ts +14 -6
  30. package/dist/components/datepicker/render.js +1 -1
  31. package/dist/components/datepicker/types.d.ts +51 -3
  32. package/dist/components/dialog/api.d.ts +1 -1
  33. package/dist/components/dialog/config.d.ts +3 -4
  34. package/dist/components/dialog/config.js +1 -1
  35. package/dist/components/dialog/features.js +1 -1
  36. package/dist/components/dialog/types.d.ts +1 -1
  37. package/dist/components/divider/features.js +2 -0
  38. package/dist/components/drawer/api.d.ts +3 -3
  39. package/dist/components/drawer/config.d.ts +2 -2
  40. package/dist/components/drawer/drawer.d.ts +1 -1
  41. package/dist/components/drawer/features/headline.d.ts +12 -2
  42. package/dist/components/drawer/features/items.d.ts +17 -3
  43. package/dist/components/drawer/features/state.d.ts +14 -2
  44. package/dist/components/extended-fab/api.d.ts +12 -4
  45. package/dist/components/extended-fab/api.js +12 -0
  46. package/dist/components/extended-fab/config.d.ts +10 -10
  47. package/dist/components/extended-fab/types.d.ts +4 -2
  48. package/dist/components/fab/api.d.ts +9 -2
  49. package/dist/components/fab/api.js +12 -0
  50. package/dist/components/fab/config.d.ts +8 -8
  51. package/dist/components/fab/types.d.ts +2 -1
  52. package/dist/components/icon-button/config.d.ts +2 -2
  53. package/dist/components/icon-button/features/toggle.d.ts +1 -5
  54. package/dist/components/icon-button/types.d.ts +6 -0
  55. package/dist/components/list/api.d.ts +18 -18
  56. package/dist/components/list/config.d.ts +6 -3
  57. package/dist/components/list/config.js +6 -7
  58. package/dist/components/list/features/renderer.js +2 -2
  59. package/dist/components/list/list.d.ts +20 -1
  60. package/dist/components/list/types.d.ts +32 -32
  61. package/dist/components/loading-indicator/config.d.ts +2 -2
  62. package/dist/components/loading-indicator/types.d.ts +3 -1
  63. package/dist/components/menu/api.d.ts +6 -5
  64. package/dist/components/menu/config.d.ts +2 -2
  65. package/dist/components/menu/features/keyboard.d.ts +19 -9
  66. package/dist/components/menu/types.d.ts +25 -9
  67. package/dist/components/navigation/config.d.ts +2 -2
  68. package/dist/components/navigation/features/controller.d.ts +1 -3
  69. package/dist/components/navigation/features/items.d.ts +1 -2
  70. package/dist/components/navigation/system/core.d.ts +6 -6
  71. package/dist/components/navigation/system/events.d.ts +3 -3
  72. package/dist/components/navigation/system/mobile.d.ts +6 -6
  73. package/dist/components/navigation/system/state.d.ts +3 -3
  74. package/dist/components/navigation/system/types.d.ts +43 -11
  75. package/dist/components/navigation/types.d.ts +15 -6
  76. package/dist/components/progress/api.js +0 -1
  77. package/dist/components/progress/config.d.ts +2 -2
  78. package/dist/components/progress/features/canvas.d.ts +14 -5
  79. package/dist/components/progress/features/state.d.ts +1 -2
  80. package/dist/components/progress/types.d.ts +1 -1
  81. package/dist/components/radios/config.d.ts +2 -2
  82. package/dist/components/search/api.js +4 -4
  83. package/dist/components/search/config.d.ts +2 -2
  84. package/dist/components/search/features/suggestions.d.ts +1 -3
  85. package/dist/components/search/features/suggestions.js +5 -5
  86. package/dist/components/search/search.js +1 -1
  87. package/dist/components/segmented-button/config.d.ts +1 -5
  88. package/dist/components/segmented-button/config.js +1 -1
  89. package/dist/components/select/api.d.ts +2 -2
  90. package/dist/components/select/features.d.ts +2 -2
  91. package/dist/components/select/features.js +2 -1
  92. package/dist/components/select/types.d.ts +38 -21
  93. package/dist/components/side-sheet/config.d.ts +2 -2
  94. package/dist/components/slider/api.d.ts +6 -6
  95. package/dist/components/slider/config.d.ts +2 -2
  96. package/dist/components/slider/types.d.ts +2 -2
  97. package/dist/components/snackbar/config.d.ts +2 -2
  98. package/dist/components/snackbar/features.d.ts +3 -3
  99. package/dist/components/snackbar/position.d.ts +1 -1
  100. package/dist/components/snackbar/types.d.ts +5 -6
  101. package/dist/components/split-button/api.js +1 -3
  102. package/dist/components/split-button/config.d.ts +2 -2
  103. package/dist/components/split-button/features/buttons.d.ts +3 -2
  104. package/dist/components/split-button/features/menu.d.ts +3 -2
  105. package/dist/components/split-button/types.d.ts +13 -2
  106. package/dist/components/switch/config.d.ts +2 -2
  107. package/dist/components/switch/types.d.ts +0 -1
  108. package/dist/components/tabs/api.d.ts +8 -5
  109. package/dist/components/tabs/config.d.ts +9 -1
  110. package/dist/components/tabs/features.d.ts +7 -11
  111. package/dist/components/tabs/features.js +2 -1
  112. package/dist/components/tabs/indicator.js +4 -2
  113. package/dist/components/tabs/responsive.js +2 -1
  114. package/dist/components/tabs/tab-api.d.ts +11 -5
  115. package/dist/components/tabs/tab-api.js +1 -1
  116. package/dist/components/tabs/tab.js +9 -1
  117. package/dist/components/tabs/types.d.ts +9 -2
  118. package/dist/components/tabs/utils.d.ts +14 -3
  119. package/dist/components/textfield/api.d.ts +1 -1
  120. package/dist/components/textfield/config.d.ts +2 -2
  121. package/dist/components/textfield/features/error.d.ts +1 -2
  122. package/dist/components/textfield/features/leading-icon.d.ts +1 -2
  123. package/dist/components/textfield/features/prefix-text.d.ts +1 -2
  124. package/dist/components/textfield/features/suffix-text.d.ts +1 -2
  125. package/dist/components/textfield/features/supporting-text.d.ts +1 -2
  126. package/dist/components/textfield/features/trailing-icon.d.ts +1 -2
  127. package/dist/components/textfield/types.d.ts +0 -2
  128. package/dist/components/timepicker/api.d.ts +5 -4
  129. package/dist/components/timepicker/config.d.ts +14 -11
  130. package/dist/components/tooltip/config.d.ts +2 -2
  131. package/dist/components/tooltip/tooltip.d.ts +1 -1
  132. package/dist/core/compose/base.d.ts +2 -2
  133. package/dist/core/compose/base.js +1 -1
  134. package/dist/core/compose/component.d.ts +13 -4
  135. package/dist/core/compose/component.js +1 -1
  136. package/dist/core/compose/features/badge.d.ts +3 -4
  137. package/dist/core/compose/features/badge.js +1 -1
  138. package/dist/core/compose/features/checkable.d.ts +3 -4
  139. package/dist/core/compose/features/debounce.d.ts +2 -3
  140. package/dist/core/compose/features/disabled.d.ts +1 -2
  141. package/dist/core/compose/features/events.d.ts +4 -3
  142. package/dist/core/compose/features/icon.d.ts +1 -5
  143. package/dist/core/compose/features/input.d.ts +2 -3
  144. package/dist/core/compose/features/lifecycle.d.ts +2 -2
  145. package/dist/core/compose/features/lifecycle.js +3 -3
  146. package/dist/core/compose/features/position.d.ts +1 -2
  147. package/dist/core/compose/features/ripple.d.ts +1 -2
  148. package/dist/core/compose/features/size.d.ts +1 -2
  149. package/dist/core/compose/features/style.d.ts +1 -2
  150. package/dist/core/compose/features/text.d.ts +1 -5
  151. package/dist/core/compose/features/textinput.d.ts +2 -3
  152. package/dist/core/compose/features/textlabel.d.ts +1 -2
  153. package/dist/core/compose/features/throttle.d.ts +1 -2
  154. package/dist/core/compose/features/track.d.ts +0 -1
  155. package/dist/core/compose/features/variant.d.ts +1 -2
  156. package/dist/core/compose/index.d.ts +1 -1
  157. package/dist/core/compose/pipe.d.ts +43 -3
  158. package/dist/core/compose/pipe.js +6 -2
  159. package/dist/core/compose/utils/type-guards.d.ts +4 -4
  160. package/dist/core/compose/utils/type-guards.js +1 -1
  161. package/dist/core/config/component.d.ts +12 -9
  162. package/dist/core/config/global.d.ts +12 -8
  163. package/dist/core/config.d.ts +1 -1
  164. package/dist/core/dom/attributes.d.ts +6 -6
  165. package/dist/core/dom/attributes.js +3 -2
  166. package/dist/core/dom/create.d.ts +27 -10
  167. package/dist/core/dom/create.js +0 -24
  168. package/dist/core/dom/utils.d.ts +1 -1
  169. package/dist/core/state/emitter.d.ts +2 -2
  170. package/dist/core/state/events.d.ts +3 -3
  171. package/dist/core/state/lifecycle.d.ts +0 -1
  172. package/dist/core/state/store.d.ts +3 -3
  173. package/dist/core/utils/object.d.ts +2 -2
  174. package/dist/core/utils/performance.d.ts +3 -3
  175. package/dist/core/utils/validate.d.ts +6 -6
  176. package/dist/core/utils/validate.js +13 -12
  177. package/dist/index.cjs +12 -12
  178. package/dist/package.json +1 -1
  179. package/dist/styles/badge.css +2 -2
  180. package/dist/styles/base.css +2 -2
  181. package/dist/styles/bottom-app-bar.css +2 -2
  182. package/dist/styles/bottom-sheet.css +2 -2
  183. package/dist/styles/button-group.css +2 -2
  184. package/dist/styles/button.css +2 -2
  185. package/dist/styles/card.css +2 -2
  186. package/dist/styles/carousel.css +2 -2
  187. package/dist/styles/checkbox.css +2 -2
  188. package/dist/styles/chips.css +2 -2
  189. package/dist/styles/dialog.css +2 -2
  190. package/dist/styles/divider.css +2 -2
  191. package/dist/styles/drawer.css +2 -2
  192. package/dist/styles/extended-fab.css +2 -2
  193. package/dist/styles/fab.css +2 -2
  194. package/dist/styles/icon-button.css +2 -2
  195. package/dist/styles/list.css +2 -2
  196. package/dist/styles/loading-indicator.css +2 -2
  197. package/dist/styles/menu.css +2 -2
  198. package/dist/styles/navigation-rail.css +2 -2
  199. package/dist/styles/navigation.css +2 -2
  200. package/dist/styles/progress.css +2 -2
  201. package/dist/styles/radios.css +2 -2
  202. package/dist/styles/search.css +2 -2
  203. package/dist/styles/segmented-button.css +2 -2
  204. package/dist/styles/select.css +2 -2
  205. package/dist/styles/side-sheet.css +2 -2
  206. package/dist/styles/slider.css +2 -2
  207. package/dist/styles/snackbar.css +2 -2
  208. package/dist/styles/split-button.css +2 -2
  209. package/dist/styles/switch.css +2 -2
  210. package/dist/styles/tabs.css +2 -2
  211. package/dist/styles/textfield.css +2 -2
  212. package/dist/styles/timepicker.css +2 -2
  213. package/dist/styles/tooltip.css +2 -0
  214. package/dist/styles/tooltip.d.ts +1 -0
  215. package/dist/styles/tooltip.js +2 -0
  216. package/dist/styles/top-app-bar.css +2 -2
  217. package/dist/styles/utilities.css +2 -2
  218. package/dist/styles.css +2 -2
  219. package/dist/themes/autumn.css +1 -1
  220. package/dist/themes/baseline.css +1 -1
  221. package/dist/themes/brownbeige.css +1 -1
  222. package/dist/themes/browngreen.css +1 -1
  223. package/dist/themes/desert.css +1 -1
  224. package/dist/themes/forest.css +1 -1
  225. package/dist/themes/highcontrast.css +1 -1
  226. package/dist/themes/legacy.css +1 -1
  227. package/dist/themes/material.css +1 -1
  228. package/dist/themes/ocean.css +1 -1
  229. package/dist/themes/sageivory.css +1 -1
  230. package/dist/themes/spring.css +1 -1
  231. package/dist/themes/summer.css +1 -1
  232. package/dist/themes/sunset.css +1 -1
  233. package/dist/themes/tealcaramel.css +1 -1
  234. package/dist/themes/winter.css +1 -1
  235. package/package.json +2 -2
  236. package/src/styles/abstract/_mixins.scss +5 -1
  237. package/src/styles/components/_checkbox.scss +27 -7
  238. package/src/styles/components/_chips.scss +13 -13
  239. package/src/styles/components/_datepicker.scss +5 -5
  240. package/src/styles/components/_dialog.scss +2 -2
  241. package/src/styles/components/_radios.scss +30 -30
  242. package/src/styles/components/_switch.scss +36 -26
  243. package/src/styles/components/_tabs.scss +59 -58
  244. package/src/styles/components/_timepicker.scss +3 -3
  245. package/src/styles/main.scss +1 -0
@@ -1,3 +1,6 @@
1
+ import type { DisabledComponent } from "../../core/compose/features/disabled.js";
2
+ import type { EventComponent } from "../../core/compose/features/events.js";
3
+ import type { LifecycleComponent } from "../../core/compose/features/lifecycle.js";
1
4
  import { DatePickerConfig } from "./types.js";
2
5
  /**
3
6
  * Default configuration for the DatePicker component
@@ -17,7 +20,7 @@ export declare const createBaseConfig: (config?: DatePickerConfig) => DatePicker
17
20
  export declare const getContainerConfig: (config: DatePickerConfig) => {
18
21
  tag: string;
19
22
  componentName: string;
20
- attributes: Record<string, any>;
23
+ attributes: Record<string, unknown>;
21
24
  className: string[];
22
25
  rawClass: string | string[];
23
26
  id: string;
@@ -33,7 +36,7 @@ export declare const getContainerConfig: (config: DatePickerConfig) => {
33
36
  ariaHidden: boolean;
34
37
  html: string;
35
38
  text: string;
36
- forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
39
+ forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
37
40
  interactive: boolean;
38
41
  };
39
42
  /**
@@ -44,7 +47,7 @@ export declare const getContainerConfig: (config: DatePickerConfig) => {
44
47
  export declare const getInputConfig: (config: DatePickerConfig) => {
45
48
  tag: string;
46
49
  componentName: string;
47
- attributes: Record<string, any>;
50
+ attributes: Record<string, unknown>;
48
51
  className: string[];
49
52
  rawClass: string | string[];
50
53
  id: string;
@@ -60,7 +63,7 @@ export declare const getInputConfig: (config: DatePickerConfig) => {
60
63
  ariaHidden: boolean;
61
64
  html: string;
62
65
  text: string;
63
- forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
66
+ forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
64
67
  interactive: boolean;
65
68
  };
66
69
  /**
@@ -71,7 +74,7 @@ export declare const getInputConfig: (config: DatePickerConfig) => {
71
74
  export declare const getCalendarConfig: (config: DatePickerConfig) => {
72
75
  tag: string;
73
76
  componentName: string;
74
- attributes: Record<string, any>;
77
+ attributes: Record<string, unknown>;
75
78
  className: string[];
76
79
  rawClass: string | string[];
77
80
  id: string;
@@ -87,7 +90,7 @@ export declare const getCalendarConfig: (config: DatePickerConfig) => {
87
90
  ariaHidden: boolean;
88
91
  html: string;
89
92
  text: string;
90
- forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
93
+ forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
91
94
  interactive: boolean;
92
95
  };
93
96
  /**
@@ -95,18 +98,18 @@ export declare const getCalendarConfig: (config: DatePickerConfig) => {
95
98
  * @param {Object} comp - Component with features like disabled and lifecycle
96
99
  * @returns {Object} API configuration object
97
100
  */
98
- export declare const getApiConfig: (comp: any) => {
101
+ export declare const getApiConfig: (comp: DisabledComponent & LifecycleComponent & EventComponent) => {
99
102
  disabled: {
100
- enable: () => any;
101
- disable: () => any;
103
+ enable: () => import("../../core/compose/features/disabled.js").DisabledManager;
104
+ disable: () => import("../../core/compose/features/disabled.js").DisabledManager;
102
105
  };
103
106
  lifecycle: {
104
- destroy: () => any;
107
+ destroy: () => void;
105
108
  };
106
109
  events: {
107
- on: any;
108
- off: any;
109
- emit: any;
110
+ on: (event: string, handler: import("../../index.js").EventCallback) => EventComponent;
111
+ off: (event: string, handler: import("../../index.js").EventCallback) => EventComponent;
112
+ emit: (event: string, data?: unknown) => EventComponent;
110
113
  };
111
114
  };
112
115
  export default defaultConfig;
@@ -7,6 +7,7 @@ import { createBaseConfig, getContainerConfig, getInputConfig, getCalendarConfig
7
7
  import { formatDate, parseDate } from "./utils.js";
8
8
  import { renderCalendar } from "./render.js";
9
9
  import { createElement } from "../../core/dom/create.js";
10
+ const isInputElement = (el) => el.tagName === "INPUT";
10
11
  const createDatePicker = (config = {}) => {
11
12
  const baseConfig = createBaseConfig(config);
12
13
  try {
@@ -45,7 +46,7 @@ const createDatePicker = (config = {}) => {
45
46
  if (!this.isOpen || !this.calendarElement)
46
47
  return;
47
48
  this.calendarElement.innerHTML = "";
48
- const calendar = renderCalendar(this, (event, data) => {
49
+ const calendar = renderCalendar(this, (...[event, data]) => {
49
50
  switch (event) {
50
51
  case "dateSelected":
51
52
  this.handleDateSelection(data.date);
@@ -195,7 +196,11 @@ const createDatePicker = (config = {}) => {
195
196
  }
196
197
  const component = pipe(createBase, withEvents(), withElement(getContainerConfig(baseConfig)), withDisabled(baseConfig), withLifecycle())(baseConfig);
197
198
  const inputComponent = pipe(createBase, withElement(getInputConfig(baseConfig)))(baseConfig);
198
- state.input = inputComponent.element;
199
+ const input = inputComponent.element;
200
+ if (!isInputElement(input)) {
201
+ throw new Error("Datepicker input element is not an input");
202
+ }
203
+ state.input = input;
199
204
  component.element.appendChild(state.input);
200
205
  state.updateInputValue();
201
206
  const calendarConfig = getCalendarConfig(baseConfig);
@@ -221,13 +226,14 @@ const createDatePicker = (config = {}) => {
221
226
  state.calendarElement.addEventListener("click", (event) => {
222
227
  event.stopPropagation();
223
228
  });
224
- document.addEventListener("click", (event) => {
229
+ state.outsideClickHandler = (event) => {
225
230
  if (state.isOpen && !component.element.contains(event.target)) {
226
231
  state.isOpen = false;
227
232
  state.render();
228
233
  component.emit("close", { value: state.selectedDate });
229
234
  }
230
- });
235
+ };
236
+ document.addEventListener("click", state.outsideClickHandler);
231
237
  return withAPI(state, getApiConfig(component))(component);
232
238
  }
233
239
  catch (error) {
@@ -1,9 +1,16 @@
1
+ import type { CalendarEmit, DatePickerState } from "./types.js";
2
+ /**
3
+ * State fields and the event emitter the calendar renderers read
4
+ */
5
+ type RenderParams = Pick<DatePickerState, "currentView" | "currentMonth" | "currentYear" | "selectedDate" | "rangeEndDate" | "minDate" | "maxDate" | "prefix"> & {
6
+ emit: CalendarEmit;
7
+ };
1
8
  /**
2
9
  * Renders the calendar header with navigation controls
3
10
  * @param {Object} params - Rendering parameters
4
11
  * @returns {HTMLElement} Calendar header element
5
12
  */
6
- export declare const renderHeader: ({ currentMonth, currentYear, currentView, prefix, emit, }: any) => HTMLElement;
13
+ export declare const renderHeader: ({ currentMonth, currentYear, currentView, prefix, emit, }: Pick<RenderParams, "currentMonth" | "currentYear" | "currentView" | "prefix" | "emit">) => HTMLElement;
7
14
  /**
8
15
  * Renders the days of the week (S, M, T, etc.)
9
16
  * @param {string} prefix - CSS class prefix
@@ -15,29 +22,30 @@ export declare const renderWeekdays: (prefix: string) => HTMLElement;
15
22
  * @param {Object} params - Rendering parameters
16
23
  * @returns {HTMLElement} Calendar days element
17
24
  */
18
- export declare const renderDays: ({ currentYear, currentMonth, selectedDate, rangeEndDate, minDate, maxDate, prefix, emit, }: any) => HTMLElement;
25
+ export declare const renderDays: ({ currentYear, currentMonth, selectedDate, rangeEndDate, minDate, maxDate, prefix, emit, }: Omit<RenderParams, "currentView">) => HTMLElement;
19
26
  /**
20
27
  * Renders the month selection view
21
28
  * @param {Object} params - Rendering parameters
22
29
  * @returns {HTMLElement} Month selection element
23
30
  */
24
- export declare const renderMonthSelection: ({ currentMonth, prefix, emit, }: any) => HTMLElement;
31
+ export declare const renderMonthSelection: ({ currentMonth, prefix, emit, }: Pick<RenderParams, "currentMonth" | "prefix" | "emit">) => HTMLElement;
25
32
  /**
26
33
  * Renders the year selection view
27
34
  * @param {Object} params - Rendering parameters
28
35
  * @returns {HTMLElement} Year selection element
29
36
  */
30
- export declare const renderYearSelection: ({ currentYear, prefix, emit, }: any) => HTMLElement;
37
+ export declare const renderYearSelection: ({ currentYear, prefix, emit, }: Pick<RenderParams, "currentYear" | "prefix" | "emit">) => HTMLElement;
31
38
  /**
32
39
  * Renders the footer with action buttons
33
40
  * @param {Object} params - Rendering parameters
34
41
  * @returns {HTMLElement} Footer element
35
42
  */
36
- export declare const renderFooter: ({ prefix, emit }: any) => HTMLElement;
43
+ export declare const renderFooter: ({ prefix, emit, }: Pick<RenderParams, "prefix" | "emit">) => HTMLElement;
37
44
  /**
38
45
  * Renders a complete calendar view
39
46
  * @param {Object} state - Current datepicker state
40
47
  * @param {Function} emit - Event emission function
41
48
  * @returns {HTMLElement} Rendered calendar
42
49
  */
43
- export declare const renderCalendar: (state: any, emit: Function) => HTMLElement;
50
+ export declare const renderCalendar: (state: DatePickerState, emit: CalendarEmit) => HTMLElement;
51
+ export {};
@@ -201,7 +201,7 @@ export const renderYearSelection = ({ currentYear, prefix, emit, }) => {
201
201
  });
202
202
  return yearsGrid;
203
203
  };
204
- export const renderFooter = ({ prefix, emit }) => {
204
+ export const renderFooter = ({ prefix, emit, }) => {
205
205
  const footer = createElement({
206
206
  tag: "div",
207
207
  className: `${prefix}-datepicker-footer`,
@@ -314,8 +314,56 @@ export interface ApiOptions {
314
314
  destroy: () => void;
315
315
  };
316
316
  events: {
317
- on: (event: string, handler: Function) => any;
318
- off: (event: string, handler: Function) => any;
319
- emit: (event: string, data: any) => any;
317
+ on: (event: string, handler: Function) => void;
318
+ off: (event: string, handler: Function) => void;
319
+ emit: (event: string, data: unknown) => void;
320
320
  };
321
321
  }
322
+ /**
323
+ * Internal state shared by the datepicker, its API and the calendar renderer
324
+ * @internal
325
+ */
326
+ export interface DatePickerState {
327
+ isOpen: boolean;
328
+ selectedDate: Date | null;
329
+ rangeEndDate: Date | null;
330
+ currentView: DatePickerView | string;
331
+ currentMonth: number;
332
+ currentYear: number;
333
+ minDate: Date | null;
334
+ maxDate: Date | null;
335
+ dateFormat: string;
336
+ variant: DatePickerVariant | string;
337
+ selectionMode: DatePickerSelectionMode | string;
338
+ closeOnSelect: boolean;
339
+ prefix: string;
340
+ calendarElement: HTMLElement | null;
341
+ input: HTMLInputElement | null;
342
+ outsideClickHandler?: EventListener;
343
+ updateInputValue(): void;
344
+ updateCalendar(): void;
345
+ handleDateSelection(date: Date): void;
346
+ prevMonth(): void;
347
+ nextMonth(): void;
348
+ prevYear(): void;
349
+ nextYear(): void;
350
+ render(): void;
351
+ }
352
+ /**
353
+ * Events the calendar renderer emits, each with its payload
354
+ * @internal
355
+ */
356
+ export type CalendarEventArgs = ["dateSelected", {
357
+ date: Date;
358
+ }] | ["monthSelected", {
359
+ month: number;
360
+ }] | ["yearSelected", {
361
+ year: number;
362
+ }] | ["viewChange", {
363
+ view: DatePickerView;
364
+ }] | ["prevMonth", undefined?] | ["nextMonth", undefined?] | ["prevYear", undefined?] | ["nextYear", undefined?] | ["prevYearRange", undefined?] | ["nextYearRange", undefined?] | ["cancel", undefined?] | ["confirm", undefined?];
365
+ /**
366
+ * Emits a calendar event to the datepicker
367
+ * @internal
368
+ */
369
+ export type CalendarEmit = (...args: CalendarEventArgs) => void;
@@ -37,7 +37,7 @@ interface ApiOptions {
37
37
  events: {
38
38
  on: (event: string, handler: Function) => void;
39
39
  off: (event: string, handler: Function) => void;
40
- trigger: (event: string, data: any) => void;
40
+ trigger: (event: string, data: unknown) => void;
41
41
  };
42
42
  lifecycle: {
43
43
  destroy: () => void;
@@ -17,7 +17,7 @@ export declare const createBaseConfig: (config?: DialogConfig) => DialogConfig;
17
17
  export declare const getElementConfig: (config: DialogConfig) => {
18
18
  tag: string;
19
19
  componentName: string;
20
- attributes: Record<string, any>;
20
+ attributes: Record<string, unknown>;
21
21
  className: string[];
22
22
  rawClass: string | string[];
23
23
  id: string;
@@ -33,15 +33,14 @@ export declare const getElementConfig: (config: DialogConfig) => {
33
33
  ariaHidden: boolean;
34
34
  html: string;
35
35
  text: string;
36
- forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
36
+ forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
37
37
  interactive: boolean;
38
38
  };
39
39
  /**
40
40
  * Generates element configuration for the Dialog overlay
41
- * @param {DialogConfig} config - Dialog configuration
42
41
  * @returns {Object} Element configuration object for overlay
43
42
  */
44
- export declare const getOverlayConfig: (config: DialogConfig) => {
43
+ export declare const getOverlayConfig: () => {
45
44
  tag: string;
46
45
  attributes: {};
47
46
  className: string;
@@ -30,7 +30,7 @@ export const getElementConfig = (config) => {
30
30
  className: config.class
31
31
  });
32
32
  };
33
- export const getOverlayConfig = (config) => {
33
+ export const getOverlayConfig = () => {
34
34
  return {
35
35
  tag: 'div',
36
36
  attributes: {},
@@ -15,7 +15,7 @@ export const withStructure = (config) => (component) => {
15
15
  const uid = `${component.getClass("dialog")}-${++dialogCount}`;
16
16
  const titleId = `${uid}-title`;
17
17
  const contentId = `${uid}-content`;
18
- const overlayConfig = getOverlayConfig(config);
18
+ const overlayConfig = getOverlayConfig();
19
19
  const overlay = document.createElement(overlayConfig.tag || "div");
20
20
  overlay.classList.add(component.getClass("dialog-overlay"));
21
21
  if (overlayConfig.attributes &&
@@ -234,7 +234,7 @@ export interface DialogButton {
234
234
  * Additional button attributes to pass to the button element
235
235
  * @example { 'data-id': 'save-button', 'form': 'profile-form' }
236
236
  */
237
- attributes?: Record<string, any>;
237
+ attributes?: Record<string, unknown>;
238
238
  }
239
239
  /**
240
240
  * Dialog event object
@@ -43,12 +43,14 @@ export const withInset = (config) => (component) => {
43
43
  const insetEnd = config.insetEnd !== undefined ? config.insetEnd : (variant === 'middle-inset' ? 16 : 0);
44
44
  component.element.style.marginLeft = `${insetStart}px`;
45
45
  component.element.style.marginRight = `${insetEnd}px`;
46
+ component.element.style.width = "auto";
46
47
  }
47
48
  else {
48
49
  const insetStart = config.insetStart !== undefined ? config.insetStart : 16;
49
50
  const insetEnd = config.insetEnd !== undefined ? config.insetEnd : (variant === 'middle-inset' ? 16 : 0);
50
51
  component.element.style.marginTop = `${insetStart}px`;
51
52
  component.element.style.marginBottom = `${insetEnd}px`;
53
+ component.element.style.height = "auto";
52
54
  }
53
55
  }
54
56
  return {
@@ -34,9 +34,9 @@ interface ApiOptions {
34
34
  interface ComponentWithElements {
35
35
  element: HTMLElement;
36
36
  getClass: (name: string) => string;
37
- on?: (event: string, handler: Function) => ComponentWithElements;
38
- off?: (event: string, handler: Function) => ComponentWithElements;
39
- addClass?: (...classes: string[]) => ComponentWithElements;
37
+ on?: (event: string, handler: Function) => unknown;
38
+ off?: (event: string, handler: Function) => unknown;
39
+ addClass?: (...classes: string[]) => unknown;
40
40
  }
41
41
  /**
42
42
  * Enhances a drawer component with public API methods.
@@ -30,7 +30,7 @@ export declare const createBaseConfig: (config?: DrawerConfig) => DrawerConfig;
30
30
  export declare const getElementConfig: (config: DrawerConfig) => {
31
31
  tag: string;
32
32
  componentName: string;
33
- attributes: Record<string, any>;
33
+ attributes: Record<string, unknown>;
34
34
  className: string[];
35
35
  rawClass: string | string[];
36
36
  id: string;
@@ -46,7 +46,7 @@ export declare const getElementConfig: (config: DrawerConfig) => {
46
46
  ariaHidden: boolean;
47
47
  html: string;
48
48
  text: string;
49
- forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
49
+ forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
50
50
  interactive: boolean;
51
51
  };
52
52
  /**
@@ -55,5 +55,5 @@ import { DrawerConfig } from "./types.js";
55
55
  *
56
56
  * @category Components
57
57
  */
58
- declare const createDrawer: (config?: DrawerConfig) => any;
58
+ declare const createDrawer: (config?: DrawerConfig) => import("./types.js").DrawerComponent;
59
59
  export default createDrawer;
@@ -5,7 +5,17 @@ import { DrawerConfig } from "../types.js";
5
5
  interface HeadlineBaseComponent {
6
6
  element: HTMLElement;
7
7
  getClass: (name: string) => string;
8
- [key: string]: unknown;
8
+ }
9
+ /**
10
+ * What withHeadline adds
11
+ */
12
+ export interface HeadlineFeature {
13
+ headlineElement: HTMLElement | null;
14
+ drawerHeadline: {
15
+ setHeadline: (text: string) => void;
16
+ getHeadline: () => string;
17
+ getElement: () => HTMLElement | null;
18
+ };
9
19
  }
10
20
  /**
11
21
  * Adds headline management to the drawer component
@@ -13,5 +23,5 @@ interface HeadlineBaseComponent {
13
23
  * @param config - Drawer configuration
14
24
  * @returns Component enhancer function
15
25
  */
16
- export declare const withHeadline: (config: DrawerConfig) => (component: HeadlineBaseComponent) => HeadlineBaseComponent;
26
+ export declare const withHeadline: (config: DrawerConfig) => <C extends HeadlineBaseComponent>(component: C) => C & HeadlineFeature;
17
27
  export {};
@@ -1,4 +1,4 @@
1
- import { DrawerConfig } from "../types.js";
1
+ import { DrawerConfig, DrawerItemConfig } from "../types.js";
2
2
  /**
3
3
  * Component shape expected by withItems
4
4
  */
@@ -6,7 +6,21 @@ interface ItemsBaseComponent {
6
6
  element: HTMLElement;
7
7
  getClass: (name: string) => string;
8
8
  emit: (event: string, data?: unknown) => void;
9
- [key: string]: unknown;
9
+ }
10
+ /**
11
+ * What withItems adds
12
+ */
13
+ export interface ItemsFeature {
14
+ itemsContainer: HTMLElement | null;
15
+ drawerItems: {
16
+ setActive: (id: string) => void;
17
+ getActive: () => string | null;
18
+ setItems: (items: DrawerItemConfig[]) => void;
19
+ getItems: () => DrawerItemConfig[];
20
+ setBadge: (id: string, badge: string) => void;
21
+ renderItems: () => void;
22
+ destroy: () => void;
23
+ };
10
24
  }
11
25
  /**
12
26
  * Adds item management functionality to the drawer component
@@ -14,5 +28,5 @@ interface ItemsBaseComponent {
14
28
  * @param config - Drawer configuration
15
29
  * @returns Component enhancer function
16
30
  */
17
- export declare const withItems: (config: DrawerConfig) => (component: ItemsBaseComponent) => ItemsBaseComponent;
31
+ export declare const withItems: (config: DrawerConfig) => <C extends ItemsBaseComponent>(component: C) => C & ItemsFeature;
18
32
  export {};
@@ -3,8 +3,20 @@ interface StateBaseComponent {
3
3
  element: HTMLElement;
4
4
  getClass: (name: string) => string;
5
5
  emit: (event: string, data?: unknown) => void;
6
- [key: string]: unknown;
6
+ }
7
+ /**
8
+ * What withState adds
9
+ */
10
+ export interface StateFeature {
11
+ scrimElement: HTMLElement | null;
12
+ drawerState: {
13
+ open: () => void;
14
+ close: () => void;
15
+ toggle: () => void;
16
+ isOpen: () => boolean;
17
+ };
18
+ _stateCleanup: () => void;
7
19
  }
8
20
  /** Standard drawers remain in the page; modal drawers own focus and background interaction. */
9
- export declare const withState: (config: DrawerConfig) => (component: StateBaseComponent) => StateBaseComponent;
21
+ export declare const withState: (config: DrawerConfig) => <C extends StateBaseComponent>(component: C) => C & StateFeature;
10
22
  export {};
@@ -1,4 +1,6 @@
1
1
  import { ExtendedFabComponent } from "./types.js";
2
+ import type { IconManager } from "../../core/compose/features/icon.js";
3
+ import type { TextManager } from "../../core/compose/features/text.js";
2
4
  /**
3
5
  * API configuration options for the Extended FAB component
4
6
  *
@@ -27,7 +29,7 @@ interface ApiOptions {
27
29
  */
28
30
  text: {
29
31
  /** Sets text content */
30
- setText: (text: string) => any;
32
+ setText: (text: string) => unknown;
31
33
  /** Gets text content */
32
34
  getText: () => string;
33
35
  };
@@ -42,13 +44,19 @@ interface ApiOptions {
42
44
  * @category Components
43
45
  * @internal
44
46
  */
45
- interface ComponentWithElements {
47
+ interface ComponentWithElements extends Pick<ExtendedFabComponent, 'disabled' | 'lifecycle'> {
48
+ /** Subscribes to an event; the API returns the component itself */
49
+ on: (event: string, handler: Function) => unknown;
50
+ /** Unsubscribes from an event; the API returns the component itself */
51
+ off: (event: string, handler: Function) => unknown;
52
+ /** Adds CSS classes; the API returns the component itself */
53
+ addClass: (...classes: string[]) => unknown;
46
54
  /** The DOM element */
47
55
  element: HTMLElement;
48
56
  /** Icon management */
49
57
  icon: {
50
58
  /** Sets icon HTML content */
51
- setIcon: (html: string) => any;
59
+ setIcon: (html: string) => IconManager;
52
60
  /** Gets icon HTML content */
53
61
  getIcon: () => string;
54
62
  /** Gets icon DOM element */
@@ -57,7 +65,7 @@ interface ComponentWithElements {
57
65
  /** Text management */
58
66
  text: {
59
67
  /** Sets text content */
60
- setText: (text: string) => any;
68
+ setText: (text: string) => TextManager;
61
69
  /** Gets text content */
62
70
  getText: () => string;
63
71
  /** Gets text DOM element */
@@ -71,6 +71,18 @@ export const withAPI = ({ disabled, lifecycle, text, className }) => (component)
71
71
  component.element.dispatchEvent(event);
72
72
  return this;
73
73
  },
74
+ on(event, handler) {
75
+ component.on(event, handler);
76
+ return this;
77
+ },
78
+ off(event, handler) {
79
+ component.off(event, handler);
80
+ return this;
81
+ },
82
+ addClass(...classes) {
83
+ component.addClass(...classes);
84
+ return this;
85
+ },
74
86
  destroy() {
75
87
  lifecycle.destroy();
76
88
  }
@@ -1,4 +1,4 @@
1
- import { ExtendedFabConfig } from "./types.js";
1
+ import { ExtendedFabConfig, ExtendedFabComponent } from "./types.js";
2
2
  /**
3
3
  * Default configuration for the Extended FAB component
4
4
  *
@@ -38,7 +38,7 @@ export declare const createBaseConfig: (config?: ExtendedFabConfig) => ExtendedF
38
38
  export declare const getElementConfig: (config: ExtendedFabConfig) => {
39
39
  tag: string;
40
40
  componentName: string;
41
- attributes: Record<string, any>;
41
+ attributes: Record<string, unknown>;
42
42
  className: string[];
43
43
  rawClass: string | string[];
44
44
  id: string;
@@ -54,7 +54,7 @@ export declare const getElementConfig: (config: ExtendedFabConfig) => {
54
54
  ariaHidden: boolean;
55
55
  html: string;
56
56
  text: string;
57
- forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
57
+ forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
58
58
  interactive: boolean;
59
59
  };
60
60
  /**
@@ -69,18 +69,18 @@ export declare const getElementConfig: (config: ExtendedFabConfig) => {
69
69
  * @category Components
70
70
  * @internal
71
71
  */
72
- export declare const getApiConfig: (comp: any) => {
72
+ export declare const getApiConfig: (comp: Pick<ExtendedFabComponent, "disabled" | "lifecycle" | "getClass" | "text">) => {
73
73
  disabled: {
74
- enable: () => any;
75
- disable: () => any;
74
+ enable: () => void;
75
+ disable: () => void;
76
76
  };
77
77
  lifecycle: {
78
- destroy: () => any;
78
+ destroy: () => void;
79
79
  };
80
- className: any;
80
+ className: string;
81
81
  text: {
82
- setText: (text: string) => any;
83
- getText: () => any;
82
+ setText: (text: string) => import("../../core/compose/features/text.js").TextManager;
83
+ getText: () => string;
84
84
  };
85
85
  };
86
86
  export default defaultConfig;
@@ -1,3 +1,5 @@
1
+ import type { IconManager } from "../../core/compose/features/icon.js";
2
+ import type { TextManager } from "../../core/compose/features/text.js";
1
3
  /**
2
4
  * Extended FAB variants following Material Design 3 guidelines
3
5
  *
@@ -398,7 +400,7 @@ export interface ExtendedFabComponent {
398
400
  */
399
401
  icon: {
400
402
  /** Sets the icon HTML content */
401
- setIcon: (html: string) => any;
403
+ setIcon: (html: string) => IconManager;
402
404
  /** Gets the current icon HTML content */
403
405
  getIcon: () => string;
404
406
  /** Gets the icon DOM element */
@@ -411,7 +413,7 @@ export interface ExtendedFabComponent {
411
413
  */
412
414
  text: {
413
415
  /** Sets the text content */
414
- setText: (text: string) => any;
416
+ setText: (text: string) => TextManager;
415
417
  /** Gets the current text content */
416
418
  getText: () => string;
417
419
  /** Gets the text DOM element */
@@ -1,4 +1,5 @@
1
1
  import { FabComponent } from "./types.js";
2
+ import type { IconManager } from "../../core/compose/features/icon.js";
2
3
  /**
3
4
  * API configuration options for the FAB component
4
5
  *
@@ -33,13 +34,19 @@ interface ApiOptions {
33
34
  * @category Components
34
35
  * @internal
35
36
  */
36
- interface ComponentWithElements {
37
+ interface ComponentWithElements extends Pick<FabComponent, 'disabled' | 'lifecycle'> {
38
+ /** Subscribes to an event; the API returns the component itself */
39
+ on: (event: string, handler: Function) => unknown;
40
+ /** Unsubscribes from an event; the API returns the component itself */
41
+ off: (event: string, handler: Function) => unknown;
42
+ /** Adds CSS classes; the API returns the component itself */
43
+ addClass: (...classes: string[]) => unknown;
37
44
  /** The DOM element */
38
45
  element: HTMLElement;
39
46
  /** Icon management */
40
47
  icon: {
41
48
  /** Sets icon HTML content */
42
- setIcon: (html: string) => any;
49
+ setIcon: (html: string) => IconManager;
43
50
  /** Gets icon HTML content */
44
51
  getIcon: () => string;
45
52
  /** Gets icon DOM element */
@@ -46,6 +46,18 @@ export const withAPI = ({ disabled, lifecycle, className }) => (component) => ({
46
46
  component.element.classList.remove(`${className}--lowered`);
47
47
  return this;
48
48
  },
49
+ on(event, handler) {
50
+ component.on(event, handler);
51
+ return this;
52
+ },
53
+ off(event, handler) {
54
+ component.off(event, handler);
55
+ return this;
56
+ },
57
+ addClass(...classes) {
58
+ component.addClass(...classes);
59
+ return this;
60
+ },
49
61
  destroy() {
50
62
  lifecycle.destroy();
51
63
  }