@loadsmart/loadsmart-ui 5.10.1 → 5.11.1

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 (141) hide show
  1. package/dist/components/Calendar/Calendar.stories.d.ts +2 -7
  2. package/dist/components/Calendar/Date.helper.d.ts +47 -12
  3. package/dist/components/Dropdown/Dropdown.stories.d.ts +4 -1
  4. package/dist/components/Loaders/LoadingBar.stories.d.ts +1 -1
  5. package/dist/index.js +445 -295
  6. package/dist/index.js.map +1 -1
  7. package/dist/testing/SelectEvent/SelectEvent.d.ts +2 -0
  8. package/dist/testing/index.js +1 -1
  9. package/dist/testing/index.js.map +1 -1
  10. package/dist/tests/generator.d.ts +35 -0
  11. package/dist/tests/renderer.d.ts +10 -0
  12. package/package.json +8 -7
  13. package/src/common/CloseButton/CloseButton.tsx +11 -7
  14. package/src/common/SelectionWrapper.tsx +7 -7
  15. package/src/components/Accordion/Accordion.stories.tsx +1 -1
  16. package/src/components/Accordion/Accordion.test.tsx +2 -2
  17. package/src/components/Accordion/Accordion.tsx +28 -22
  18. package/src/components/Banner/Banner.test.tsx +2 -2
  19. package/src/components/Banner/Banner.tsx +2 -2
  20. package/src/components/Breadcrumbs/Breadbrumbs.test.tsx +2 -2
  21. package/src/components/Breadcrumbs/Breadcrumb.tsx +3 -2
  22. package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
  23. package/src/components/Button/Button.test.tsx +2 -2
  24. package/src/components/Button/Button.tsx +20 -17
  25. package/src/components/Calendar/Calendar.stories.tsx +4 -2
  26. package/src/components/Calendar/Calendar.test.tsx +3 -3
  27. package/src/components/Calendar/Calendar.tsx +8 -4
  28. package/src/components/Calendar/Date.helper.test.ts +463 -15
  29. package/src/components/Calendar/Date.helper.ts +106 -45
  30. package/src/components/Calendar/PickerModeToggle.tsx +6 -3
  31. package/src/components/Calendar/Pickers/DayPicker.test.tsx +2 -2
  32. package/src/components/Calendar/Pickers/DayPicker.tsx +1 -1
  33. package/src/components/Calendar/Pickers/MonthPicker.test.tsx +2 -2
  34. package/src/components/Calendar/Pickers/MonthPicker.tsx +1 -1
  35. package/src/components/Calendar/Pickers/PickerButton.tsx +39 -29
  36. package/src/components/Calendar/Pickers/YearPicker.test.tsx +9 -7
  37. package/src/components/Calendar/Pickers/YearPicker.tsx +1 -1
  38. package/src/components/Card/Card.stories.tsx +1 -1
  39. package/src/components/Card/Card.test.tsx +2 -2
  40. package/src/components/Card/Card.tsx +9 -6
  41. package/src/components/Card/CardTitle.tsx +3 -4
  42. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  43. package/src/components/Checkbox/Checkbox.tsx +26 -14
  44. package/src/components/DatePicker/DatePicker.test.tsx +2 -2
  45. package/src/components/DatePicker/DateRangePicker.stories.tsx +6 -1
  46. package/src/components/DatePicker/DateRangePicker.test.tsx +2 -2
  47. package/src/components/Dialog/Dialog.test.tsx +2 -2
  48. package/src/components/Dialog/Dialog.tsx +5 -5
  49. package/src/components/DragDropFile/components/DropZone.test.tsx +1 -1
  50. package/src/components/DragDropFile/styles.tsx +11 -6
  51. package/src/components/Drawer/Drawer.test.tsx +1 -1
  52. package/src/components/Drawer/Drawer.tsx +6 -6
  53. package/src/components/Dropdown/Dropdown.stories.tsx +10 -5
  54. package/src/components/Dropdown/Dropdown.test.tsx +14 -16
  55. package/src/components/Dropdown/DropdownMenu.tsx +28 -15
  56. package/src/components/Dropdown/DropdownTrigger.tsx +34 -24
  57. package/src/components/EmptyState/EmptyState.test.tsx +1 -1
  58. package/src/components/ErrorMessage/ErrorMessage.test.tsx +1 -1
  59. package/src/components/HighlightMatch/HighlightMatch.test.tsx +1 -1
  60. package/src/components/HighlightMatch/HighlightMatch.tsx +1 -2
  61. package/src/components/IconFactory/IconFactory.test.tsx +2 -2
  62. package/src/components/Label/Label.test.tsx +2 -2
  63. package/src/components/Label/Label.tsx +3 -3
  64. package/src/components/Link/Link.test.tsx +2 -2
  65. package/src/components/Link/Link.tsx +13 -9
  66. package/src/components/Loaders/LoadingBar.stories.tsx +2 -2
  67. package/src/components/Loaders/LoadingBar.test.tsx +1 -1
  68. package/src/components/Loaders/LoadingBar.tsx +2 -2
  69. package/src/components/Loaders/LoadingDots.test.tsx +1 -1
  70. package/src/components/Loaders/Spinner.test.tsx +2 -2
  71. package/src/components/Modal/Modal.test.tsx +2 -2
  72. package/src/components/Modal/Modal.tsx +12 -7
  73. package/src/components/Pagination/Pagination.test.tsx +1 -1
  74. package/src/components/Popover/Popover.test.tsx +2 -2
  75. package/src/components/ProgressBar/ProgressBar.test.tsx +1 -1
  76. package/src/components/ProgressBar/ProgressBar.tsx +6 -4
  77. package/src/components/Radio/Radio.test.tsx +2 -2
  78. package/src/components/Radio/Radio.tsx +19 -11
  79. package/src/components/Section/Section.test.tsx +2 -2
  80. package/src/components/Section/Section.tsx +8 -6
  81. package/src/components/Section/Sections.stories.tsx +1 -1
  82. package/src/components/Select/Select.fixtures.ts +1 -1
  83. package/src/components/Select/Select.stories.tsx +2 -2
  84. package/src/components/Select/Select.test.tsx +162 -155
  85. package/src/components/Select/SelectEmpty.tsx +5 -4
  86. package/src/components/Select/SelectTrigger.tsx +11 -6
  87. package/src/components/Select/useSelect.helpers.test.ts +1 -1
  88. package/src/components/SideNavigation/Logo/Logo.test.tsx +2 -2
  89. package/src/components/SideNavigation/Menu/Menu.test.tsx +2 -2
  90. package/src/components/SideNavigation/Menu/Menu.tsx +3 -3
  91. package/src/components/SideNavigation/Menu/MenuBaseItem.tsx +5 -4
  92. package/src/components/SideNavigation/Menu/MenuExpandable.tsx +3 -2
  93. package/src/components/SideNavigation/Separator/Separator.test.tsx +1 -1
  94. package/src/components/SideNavigation/SideNavigation.test.tsx +2 -2
  95. package/src/components/Steps/ProgressSteps/ProgressStep.tsx +39 -31
  96. package/src/components/Steps/Steps.fixtures.ts +1 -1
  97. package/src/components/Steps/Steps.test.tsx +2 -2
  98. package/src/components/Steps/useStep.test.tsx +1 -1
  99. package/src/components/Switch/Switch.test.tsx +1 -1
  100. package/src/components/Switch/Switch.tsx +18 -6
  101. package/src/components/Table/Table.fixtures.ts +1 -1
  102. package/src/components/Table/Table.test.tsx +1 -1
  103. package/src/components/Table/Table.tsx +2 -2
  104. package/src/components/TablePagination/TablePagination.test.tsx +1 -1
  105. package/src/components/Tabs/Tabs.test.tsx +1 -1
  106. package/src/components/Tabs/Tabs.tsx +32 -26
  107. package/src/components/Tag/Tag.stories.tsx +1 -1
  108. package/src/components/Tag/Tag.test.tsx +2 -2
  109. package/src/components/Tag/Tag.tsx +44 -35
  110. package/src/components/Text/Text.test.tsx +2 -2
  111. package/src/components/TextField/TextField.test.tsx +1 -1
  112. package/src/components/TextField/TextField.tsx +22 -15
  113. package/src/components/Textarea/Textarea.test.tsx +1 -1
  114. package/src/components/Textarea/Textarea.tsx +22 -17
  115. package/src/components/Toast/Toast.test.tsx +2 -2
  116. package/src/components/Toast/Toast.tsx +3 -3
  117. package/src/components/ToggleGroup/Toggle.test.tsx +2 -2
  118. package/src/components/ToggleGroup/Toggle.tsx +7 -7
  119. package/src/components/ToggleGroup/ToggleGroup.stories.tsx +14 -12
  120. package/src/components/ToggleGroup/ToggleGroup.test.tsx +2 -2
  121. package/src/components/Tooltip/Tooltip.test.tsx +2 -2
  122. package/src/components/Tooltip/Tooltip.tsx +22 -20
  123. package/src/components/TopNavigation/Logo/Logo.test.tsx +2 -2
  124. package/src/components/TopNavigation/Menu/Menu.test.tsx +1 -1
  125. package/src/components/TopNavigation/Menu/MenuItemDropdown.tsx +1 -1
  126. package/src/components/TopNavigation/OpenSideNavButton/OpenSideNavButton.tsx +1 -1
  127. package/src/components/VisuallyHidden/VisuallyHidden.test.tsx +1 -1
  128. package/src/hooks/useClickOutside/useClickOutside.test.tsx +1 -1
  129. package/src/hooks/useDidMount/useDidMount.test.tsx +1 -1
  130. package/src/hooks/useFocusTrap/useFocusTrap.test.tsx +1 -1
  131. package/src/hooks/useFocusWithin/useFocusWithin.test.tsx +1 -1
  132. package/src/hooks/useHeightExpansionToggler/useHeightExpansionToggler.test.tsx +1 -1
  133. package/src/hooks/useSelectable/SelectableStrategy.test.ts +1 -1
  134. package/src/hooks/useSelectable/useSelectable.test.ts +1 -1
  135. package/src/styles/font.tsx +3 -3
  136. package/src/testing/SelectEvent/SelectEvent.test.tsx +2 -2
  137. package/src/testing/SelectEvent/SelectEvent.ts +87 -45
  138. package/src/tests/generator.ts +127 -0
  139. package/src/tests/renderer.tsx +39 -0
  140. package/src/tools/conditional.test.ts +1 -1
  141. package/src/utils/toolset/interleave.test.ts +1 -1
@@ -1,15 +1,10 @@
1
1
  /// <reference types="react" />
2
- import type { Meta } from '@storybook/react/types-6-0';
2
+ import type { Story, Meta } from '@storybook/react/types-6-0';
3
3
  import type { CalendarDate } from './Date.helper';
4
4
  import type { CalendarProps } from './Calendar.types';
5
5
  declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
6
6
  export default _default;
7
- export declare function Playground(args: CalendarProps): JSX.Element;
8
- export declare namespace Playground {
9
- var args: {
10
- mode: string;
11
- };
12
- }
7
+ export declare const Playground: Story<CalendarProps>;
13
8
  export declare function Selection(): JSX.Element;
14
9
  declare function isWeekend(date: CalendarDate): boolean;
15
10
  export declare function CalendarConstraints(args: CalendarProps): JSX.Element;
@@ -3,6 +3,8 @@ export declare type DateHelperOptions = {
3
3
  };
4
4
  export declare const DEFAULT_OPTIONS: DateHelperOptions;
5
5
  export declare type InputDate = string | number | Date;
6
+ declare type Unit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
7
+ declare type Operator = '>=' | '>' | '=' | '<' | '<=';
6
8
  export declare type DateConstraint = InputDate | [InputDate, InputDate] | [null, InputDate] | [InputDate, null];
7
9
  export declare type FunctionConstraint = (day: CalendarDate) => boolean;
8
10
  export declare type CalendarConstraint = DateConstraint | FunctionConstraint;
@@ -72,42 +74,58 @@ export interface CalendarDate {
72
74
  * @returns {number}
73
75
  */
74
76
  getSeconds(): number;
77
+ /**
78
+ * Get the milliseconds value.
79
+ *
80
+ * [!] Be aware that it might be normalized to 12:00:00 (UTC), if you did not call the helper with
81
+ * `options.normalize: false`.
82
+ *
83
+ * @returns {number}
84
+ */
85
+ getMilliseconds(): number;
75
86
  /**
76
87
  * Check if the current date matches **at least one** of the provided constraints.
88
+ *
89
+ * [!] Be aware that all dates in this comparison will be normalized to 12:00:00 (UTC).
90
+ *
77
91
  * @param {...CalendarConstraint[]} constraintsArg
78
92
  * @returns {boolean}
79
93
  */
80
94
  matches(...constraints: CalendarConstraint[]): boolean;
81
95
  /**
82
- * Set the given `value` to the `key` property of this instance.
96
+ * Set the given `value` to the `unit` property of this instance.
83
97
  * This function mutates the internal date instance.
84
- * @param {('year' | 'month' | 'day')} key
98
+ * @param {Unit} unit
85
99
  * @param {number} value
86
100
  * @returns {CalendarDate}
87
101
  */
88
- set(key: 'year' | 'month' | 'day', value: number): CalendarDate;
102
+ set(unit: Unit, value: number): CalendarDate;
89
103
  /**
90
- * Return a copy of this instance, adding the given `value` to the `key` property.
91
- * @param {('year' | 'month' | 'day')} key
104
+ * Return a copy of this instance, adding the given `value` to the `unit` property.
105
+ * @param {Unit} unit
92
106
  * @param {number} value
93
107
  * @returns {CalendarDate}
94
108
  */
95
- add(key: 'year' | 'month' | 'day', value: number): CalendarDate;
109
+ add(unit: Unit, value: number): CalendarDate;
96
110
  /**
97
- * Return a copy of this instance, subtracting the given `value` from the `key` property.
98
- * @param {('year' | 'month' | 'day')} key
111
+ * Return a copy of this instance, subtracting the given `value` from the `unit` property.
112
+ * @param {Unit} unit
99
113
  * @param {number} value
100
114
  * @returns {CalendarDate}
101
115
  */
102
- subtract(key: 'year' | 'month' | 'day', value: number): CalendarDate;
116
+ subtract(unit: Unit, value: number): CalendarDate;
103
117
  /**
104
118
  * Compare this date with the given `other`.
105
- * @param {('>=' | '>' | '=' | '<' | '<=')} operator - type of comparison to be performed.
119
+ *
120
+ * [!] Be aware that it might be normalized to 12:00:00 (UTC), if you did not call the helper with
121
+ * `options.normalize: false`.
122
+ *
123
+ * @param {Operator} operator - type of comparison to be performed.
106
124
  * @param {CalendarDate} other - Other `CalendarDate` to compare with.
107
- * @param {('year' | 'month' | 'day')} [precision] - notice that the precision increases with the evaluated period, so year < month < day < hour < minute < second < millisecond. Default is 'day'.
125
+ * @param {Unit} [precision] - notice that the precision increases with the evaluated period, so year < month < day < hour < minute < second < millisecond. Default is 'day'.
108
126
  * @return {boolean} comparison result
109
127
  */
110
- is(operator: '>=' | '>' | '=' | '<' | '<=', other: CalendarDate, precision?: string): boolean;
128
+ is(operator: Operator, other: CalendarDate, precision?: string): boolean;
111
129
  /**
112
130
  * Return this date as a string value in ISO format.
113
131
  * @returns {string}
@@ -131,6 +149,23 @@ export declare type CalendarDateRange = [CalendarDate | null, CalendarDate | nul
131
149
  * @return {CalendarDate}
132
150
  */
133
151
  declare function DateHelper(dateArg?: InputDate, optionsArg?: DateHelperOptions): CalendarDate;
152
+ /**
153
+ * This method takes a date and a unit of precision and then normalizes the given date based on that precision.
154
+ * The return will be the timestamp of the normalized date
155
+ *
156
+ * @example
157
+ * ```js
158
+ * getComparableDate(new Date('2022-10-13T17:42:19.948Z'), 'hour')) // returns 1665680400000
159
+ *
160
+ * // '2022-10-13T17:42:19.948Z' will be normalized to '2022-10-13T17:00:00.000Z'
161
+ * // 1665680400000 is equal to: new Date('2022-10-13T17:00:00.000Z').getTime()
162
+ * ```
163
+ *
164
+ * @param {Date} date
165
+ * @param {Unit} precision
166
+ * @returns {number}
167
+ */
168
+ export declare function getComparableDate(date: Date, precision?: Unit): number;
134
169
  /**
135
170
  * Constraints represent ranges of dates, inclusive in both ends.
136
171
  * Returns an array representing the initial and final timestamps (after the transformations applied by `DateHelper`).
@@ -2,7 +2,10 @@ import type { Story, Meta } from '@storybook/react/types-6-0';
2
2
  import type { DropdownProps, DropdownMenuProps, DropdownTriggerProps } from './Dropdown.types';
3
3
  declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
4
  export default _default;
5
- declare type DropdownStoryProps = DropdownProps & DropdownMenuProps & DropdownTriggerProps;
5
+ export declare type DropdownStoryProps = DropdownProps & {
6
+ align?: DropdownMenuProps['align'];
7
+ outlined?: DropdownTriggerProps['outlined'];
8
+ };
6
9
  export declare const Playground: Story<DropdownStoryProps>;
7
10
  export declare const WithSections: Story<DropdownStoryProps>;
8
11
  export declare const Extended: Story<DropdownStoryProps>;
@@ -1,5 +1,5 @@
1
1
  import type { Story, Meta } from '@storybook/react/types-6-0';
2
- import { LoadingBarProps } from './LoadingBar';
2
+ import type { LoadingBarProps } from './LoadingBar';
3
3
  declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
4
4
  export default _default;
5
5
  export declare const Playground: Story<LoadingBarProps>;