@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
@@ -11,6 +11,9 @@ export const DEFAULT_OPTIONS: DateHelperOptions = {
11
11
 
12
12
  export type InputDate = string | number | Date
13
13
 
14
+ type Unit = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond'
15
+ type Operator = '>=' | '>' | '=' | '<' | '<='
16
+
14
17
  export type DateConstraint =
15
18
  | InputDate
16
19
  | [InputDate, InputDate]
@@ -87,42 +90,58 @@ export interface CalendarDate {
87
90
  * @returns {number}
88
91
  */
89
92
  getSeconds(): number
93
+ /**
94
+ * Get the milliseconds value.
95
+ *
96
+ * [!] Be aware that it might be normalized to 12:00:00 (UTC), if you did not call the helper with
97
+ * `options.normalize: false`.
98
+ *
99
+ * @returns {number}
100
+ */
101
+ getMilliseconds(): number
90
102
  /**
91
103
  * Check if the current date matches **at least one** of the provided constraints.
104
+ *
105
+ * [!] Be aware that all dates in this comparison will be normalized to 12:00:00 (UTC).
106
+ *
92
107
  * @param {...CalendarConstraint[]} constraintsArg
93
108
  * @returns {boolean}
94
109
  */
95
110
  matches(...constraints: CalendarConstraint[]): boolean
96
111
  /**
97
- * Set the given `value` to the `key` property of this instance.
112
+ * Set the given `value` to the `unit` property of this instance.
98
113
  * This function mutates the internal date instance.
99
- * @param {('year' | 'month' | 'day')} key
114
+ * @param {Unit} unit
100
115
  * @param {number} value
101
116
  * @returns {CalendarDate}
102
117
  */
103
- set(key: 'year' | 'month' | 'day', value: number): CalendarDate
118
+ set(unit: Unit, value: number): CalendarDate
104
119
  /**
105
- * Return a copy of this instance, adding the given `value` to the `key` property.
106
- * @param {('year' | 'month' | 'day')} key
120
+ * Return a copy of this instance, adding the given `value` to the `unit` property.
121
+ * @param {Unit} unit
107
122
  * @param {number} value
108
123
  * @returns {CalendarDate}
109
124
  */
110
- add(key: 'year' | 'month' | 'day', value: number): CalendarDate
125
+ add(unit: Unit, value: number): CalendarDate
111
126
  /**
112
- * Return a copy of this instance, subtracting the given `value` from the `key` property.
113
- * @param {('year' | 'month' | 'day')} key
127
+ * Return a copy of this instance, subtracting the given `value` from the `unit` property.
128
+ * @param {Unit} unit
114
129
  * @param {number} value
115
130
  * @returns {CalendarDate}
116
131
  */
117
- subtract(key: 'year' | 'month' | 'day', value: number): CalendarDate
132
+ subtract(unit: Unit, value: number): CalendarDate
118
133
  /**
119
134
  * Compare this date with the given `other`.
120
- * @param {('>=' | '>' | '=' | '<' | '<=')} operator - type of comparison to be performed.
135
+ *
136
+ * [!] Be aware that it might be normalized to 12:00:00 (UTC), if you did not call the helper with
137
+ * `options.normalize: false`.
138
+ *
139
+ * @param {Operator} operator - type of comparison to be performed.
121
140
  * @param {CalendarDate} other - Other `CalendarDate` to compare with.
122
- * @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'.
141
+ * @param {Unit} [precision] - notice that the precision increases with the evaluated period, so year < month < day < hour < minute < second < millisecond. Default is 'day'.
123
142
  * @return {boolean} comparison result
124
143
  */
125
- is(operator: '>=' | '>' | '=' | '<' | '<=', other: CalendarDate, precision?: string): boolean
144
+ is(operator: Operator, other: CalendarDate, precision?: string): boolean
126
145
  /**
127
146
  * Return this date as a string value in ISO format.
128
147
  * @returns {string}
@@ -200,6 +219,9 @@ function DateHelper(dateArg?: InputDate, optionsArg = DEFAULT_OPTIONS): Calendar
200
219
  getSeconds() {
201
220
  return utcDate.getUTCSeconds()
202
221
  },
222
+ getMilliseconds() {
223
+ return utcDate.getUTCMilliseconds()
224
+ },
203
225
  matches(...constraints: CalendarConstraint[]): boolean {
204
226
  if (isEmpty(constraints)) {
205
227
  return false
@@ -212,31 +234,35 @@ function DateHelper(dateArg?: InputDate, optionsArg = DEFAULT_OPTIONS): Calendar
212
234
  return evaluator(date)
213
235
  })
214
236
  },
215
- add(key: 'year' | 'month' | 'day', value: number) {
216
- return add(utcDate, key, value)
237
+ add(unit: Unit, value: number) {
238
+ return add(utcDate, unit, value)
217
239
  },
218
- subtract(key: 'year' | 'month' | 'day', value: number) {
219
- return add(utcDate, key, -1 * value)
240
+ subtract(unit: Unit, value: number) {
241
+ return add(utcDate, unit, -1 * value)
220
242
  },
221
- set(key: 'year' | 'month' | 'day', value: number) {
243
+ set(unit: Unit, value: number) {
222
244
  const newValue = {
223
245
  year: utcDate.getUTCFullYear(),
224
246
  month: utcDate.getUTCMonth(),
225
247
  day: utcDate.getUTCDate(),
226
- [key]: value,
248
+ hour: utcDate.getUTCHours(),
249
+ minute: utcDate.getUTCMinutes(),
250
+ second: utcDate.getUTCSeconds(),
251
+ millisecond: utcDate.getUTCMilliseconds(),
252
+ [unit]: value,
227
253
  }
228
254
 
229
255
  utcDate.setUTCFullYear(newValue.year)
230
256
  utcDate.setUTCMonth(newValue.month)
231
257
  utcDate.setUTCDate(newValue.day)
258
+ utcDate.setUTCHours(newValue.hour)
259
+ utcDate.setUTCMinutes(newValue.minute)
260
+ utcDate.setUTCSeconds(newValue.second)
261
+ utcDate.setUTCMilliseconds(newValue.millisecond)
232
262
 
233
263
  return this
234
264
  },
235
- is(
236
- operator: '>=' | '>' | '=' | '<' | '<=',
237
- other: CalendarDate,
238
- precision?: 'year' | 'month' | 'day'
239
- ): boolean {
265
+ is(operator: Operator, other: CalendarDate, precision?: Unit): boolean {
240
266
  function compare(a: number, b: number) {
241
267
  let result
242
268
 
@@ -262,8 +288,8 @@ function DateHelper(dateArg?: InputDate, optionsArg = DEFAULT_OPTIONS): Calendar
262
288
  }
263
289
 
264
290
  return compare(
265
- Number(getComparableDate(utcDate, precision)),
266
- Number(getComparableDate(other.get(), precision))
291
+ getComparableDate(utcDate, precision),
292
+ getComparableDate(other.get(), precision)
267
293
  )
268
294
  },
269
295
  toString(): string {
@@ -272,16 +298,44 @@ function DateHelper(dateArg?: InputDate, optionsArg = DEFAULT_OPTIONS): Calendar
272
298
  }
273
299
  }
274
300
 
275
- function getComparableDate(date: Date, precision: 'year' | 'month' | 'day' = 'day') {
301
+ /**
302
+ * This method takes a date and a unit of precision and then normalizes the given date based on that precision.
303
+ * The return will be the timestamp of the normalized date
304
+ *
305
+ * @example
306
+ * ```js
307
+ * getComparableDate(new Date('2022-10-13T17:42:19.948Z'), 'hour')) // returns 1665680400000
308
+ *
309
+ * // '2022-10-13T17:42:19.948Z' will be normalized to '2022-10-13T17:00:00.000Z'
310
+ * // 1665680400000 is equal to: new Date('2022-10-13T17:00:00.000Z').getTime()
311
+ * ```
312
+ *
313
+ * @param {Date} date
314
+ * @param {Unit} precision
315
+ * @returns {number}
316
+ */
317
+ export function getComparableDate(date: Date, precision: Unit = 'day'): number {
318
+ const DATE_ZERO = MIN_SUPPORTED_DATE.toString()
276
319
  const COMPARE_TO = {
277
- year: 1,
278
- month: 2,
279
- day: 3,
320
+ year: 4,
321
+ month: 7,
322
+ day: 10,
323
+ hour: 13,
324
+ minute: 16,
325
+ second: 19,
326
+ millisecond: 24,
327
+ }
328
+ const sliceIndex = COMPARE_TO[precision]
329
+
330
+ if (sliceIndex == null) {
331
+ throw new Error(`precision ${precision} is not supported`)
280
332
  }
281
333
 
282
- return [date.getUTCFullYear(), padded(date.getUTCMonth()), padded(date.getUTCDate())]
283
- .slice(0, COMPARE_TO[precision])
284
- .join('')
334
+ const normalizedPart = DATE_ZERO.slice(sliceIndex)
335
+ const datePart = date.toISOString().slice(0, sliceIndex)
336
+ const normalizedDate = `${datePart}${normalizedPart}`
337
+
338
+ return new Date(normalizedDate).getTime()
285
339
  }
286
340
 
287
341
  /**
@@ -328,31 +382,38 @@ export function getConstraintRange(rangeArg: DateConstraint): [number, number] {
328
382
  }
329
383
 
330
384
  /**
331
- * Add the given `value` to the provided `key` of the provided `date`.
385
+ * Add the given `value` to the provided `unit` of the provided `date`.
332
386
  * @param {Date} date - Date where the operation should be performed.
333
- * @param {('year' | 'month' | 'day')} key - period
387
+ * @param {Unit} unit - period
334
388
  * @param {number} value - value to be added
335
389
  * @returns {Date} new date after the operation.
336
390
  */
337
- function add(date: Date, key: 'year' | 'month' | 'day', value: number): CalendarDate {
391
+ function add(date: Date, unit: Unit, value: number): CalendarDate {
338
392
  const increment = {
339
393
  year: 0,
340
394
  month: 0,
341
395
  day: 0,
342
- [key]: value,
396
+ hour: 0,
397
+ minute: 0,
398
+ second: 0,
399
+ millisecond: 0,
400
+ [unit]: value,
343
401
  }
344
402
 
345
403
  const newDate = new Date(
346
- date.getUTCFullYear() + increment.year,
347
- date.getUTCMonth() + increment.month,
348
- date.getUTCDate() + increment.day,
349
- date.getUTCHours(),
350
- date.getUTCMinutes(),
351
- date.getUTCSeconds(),
352
- date.getUTCMilliseconds()
404
+ Date.UTC(
405
+ date.getUTCFullYear() + increment.year,
406
+ date.getUTCMonth() + increment.month,
407
+ date.getUTCDate() + increment.day,
408
+ date.getUTCHours() + increment.hour,
409
+ date.getUTCMinutes() + increment.minute,
410
+ date.getUTCSeconds() + increment.second,
411
+ date.getUTCMilliseconds() + increment.millisecond
412
+ )
353
413
  )
354
414
 
355
- return DateHelper(newDate)
415
+ // Do not normalize the clone since all units must be preserved.
416
+ return DateHelper(newDate, { normalize: false })
356
417
  }
357
418
 
358
419
  /**
@@ -394,7 +455,7 @@ export const TODAY = DateHelper()
394
455
  * Maximum and minimum supported `Date`.
395
456
  * Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_ecmascript_epoch_and_timestamps
396
457
  */
397
- export const MIN_SUPPORTED_DATE = DateHelper(0)
458
+ export const MIN_SUPPORTED_DATE = DateHelper(0, { normalize: false })
398
459
  export const MAX_SUPPORTED_DATE = DateHelper(8.64e15 - 1)
399
460
 
400
461
  export default DateHelper
@@ -12,10 +12,7 @@ import typography from 'styles/typography'
12
12
  import type { ButtonProps } from 'components/Button'
13
13
 
14
14
  const Button = styled(BaseButton)`
15
- color: ${token('color-neutral-dark')};
16
15
  user-select: none;
17
- background-color: transparent;
18
- border-color: transparent;
19
16
 
20
17
  ${typography(
21
18
  conditional({
@@ -23,9 +20,15 @@ const Button = styled(BaseButton)`
23
20
  body: whenProps({ 'aria-expanded': false }),
24
21
  })
25
22
  )};
23
+ border-color: transparent;
24
+ background-color: transparent;
25
+
26
+ color: ${token('color-neutral-dark')};
27
+
26
28
  ${focusable`
27
29
  box-shadow: ${token('button-primary-outline')};
28
30
  `}
31
+
29
32
  ${disableable`
30
33
  pointer-events: none;
31
34
  opacity: 1;
@@ -2,8 +2,8 @@ import React from 'react'
2
2
 
3
3
  import DateHelper from '../Date.helper'
4
4
  import DayPicker, { WEEKDAYS } from './DayPicker'
5
- import generator from '../../../../tests/generator'
6
- import renderer, { screen, fire } from '../../../../tests/renderer'
5
+ import generator from '../../../tests/generator'
6
+ import renderer, { screen, fire } from '../../../tests/renderer'
7
7
 
8
8
  import type { useCalendarReturn, CalendarPickerProps, usePickerModeReturn } from '../Calendar.types'
9
9
 
@@ -53,9 +53,9 @@ const Text = styled(DefaultText)`
53
53
 
54
54
  const Grid = styled.div`
55
55
  display: grid;
56
+ grid-gap: ${token('space-2xs')};
56
57
  grid-template-rows: 1.25rem repeat(auto-fill, 2.5rem);
57
58
  grid-template-columns: repeat(7, 2.5rem);
58
- grid-gap: ${token('space-2xs')};
59
59
  `
60
60
 
61
61
  /**
@@ -1,11 +1,11 @@
1
1
  import React from 'react'
2
2
 
3
3
  import DateHelper from '../Date.helper'
4
- import generator from '../../../../tests/generator'
4
+ import generator from '../../../tests/generator'
5
5
  import MonthHelper from '../Month.helper'
6
6
  import MonthPicker from './MonthPicker'
7
7
  import range from 'utils/toolset/range'
8
- import renderer, { screen, fire } from '../../../../tests/renderer'
8
+ import renderer, { screen, fire } from '../../../tests/renderer'
9
9
 
10
10
  import type { useCalendarReturn, CalendarPickerProps, usePickerModeReturn } from '../Calendar.types'
11
11
  import type { CalendarMonthAlias } from '../Month.helper'
@@ -10,9 +10,9 @@ import type { CalendarMonth, CalendarMonthAlias } from '../Month.helper'
10
10
 
11
11
  const Container = styled.div`
12
12
  display: grid;
13
- grid-template-columns: repeat(3, 1fr);
14
13
  grid-auto-rows: 3.75rem;
15
14
  grid-gap: ${token('space-2xs')};
15
+ grid-template-columns: repeat(3, 1fr);
16
16
  `
17
17
 
18
18
  function getStatus(calendar: useCalendarReturn, month: CalendarMonth) {
@@ -19,8 +19,20 @@ const PickerButton = styled(BaseButton)<{
19
19
  | 'selection'
20
20
  | 'next-month-day'
21
21
  }>`
22
+ ${typography(
23
+ conditional({
24
+ body: whenProps({ $status: ['default', 'faded'] }),
25
+ 'body-bold': whenProps({
26
+ $status: ['current-day', 'selection-start', 'selection', 'selection-end'],
27
+ }),
28
+ })
29
+ )}
30
+
31
+ user-select: none;
32
+
22
33
  height: 100%;
23
- padding: ${token('space-xs')} ${token('space-s')};
34
+
35
+ border-radius: 0;
24
36
 
25
37
  color: ${conditional({
26
38
  'color-neutral-lighter': whenProps({
@@ -30,45 +42,30 @@ const PickerButton = styled(BaseButton)<{
30
42
  'color-neutral-dark': whenProps({ $status: 'next-month-day' }),
31
43
  'color-accent': whenProps({ $status: 'current-day' }),
32
44
  })};
33
- visibility: ${conditional({
34
- visible: whenProps({ 'aria-hidden': false }),
35
- hidden: whenProps({ 'aria-hidden': true }),
36
- })};
37
- user-select: none;
45
+
38
46
  background: ${conditional({
39
47
  'color-transparent': whenProps({ $status: ['default', 'faded', 'next-month-day'] }),
40
48
  'color-neutral-darker': whenProps({ $status: ['selection-start', 'selection-end'] }),
41
49
  'color-neutral': whenProps({ $status: 'selection' }),
42
50
  'color-neutral-lightest': whenProps({ $status: 'current-day' }),
43
51
  })};
52
+
44
53
  border-color: ${conditional({
45
54
  'color-transparent': whenProps({ $status: ['default', 'faded', 'next-month-day'] }),
46
55
  'color-neutral-darker': whenProps({ $status: ['selection-start', 'selection-end'] }),
47
56
  'color-neutral': whenProps({ $status: 'selection' }),
48
57
  'color-neutral-light': whenProps({ $status: 'current-day' }),
49
58
  })};
50
- border-radius: 0;
51
59
 
52
60
  ${conditional({
53
61
  'opacity: 0.4;': whenProps({ $status: 'faded' }),
54
62
  'opacity: 1;': whenProps({ $status: (status) => status !== 'faded' }),
55
63
  })}
56
- ${typography(
57
- conditional({
58
- body: whenProps({ $status: ['default', 'faded'] }),
59
- 'body-bold': whenProps({
60
- $status: ['current-day', 'selection-start', 'selection', 'selection-end'],
61
- }),
62
- })
63
- )}
64
+
65
+ padding: ${token('space-xs')} ${token('space-s')};
66
+
64
67
  ${hoverable`
65
- font-weight: ${token('font-weight-bold')};
66
- color: ${conditional({
67
- 'color-neutral-dark': whenProps({ $status: ['default', 'faded'] }),
68
- 'color-neutral-lightest': whenProps({
69
- $status: ['selection-start', 'selection', 'selection-end'],
70
- }),
71
- })};
68
+ border-color: ${token('color-neutral')};
72
69
  background-color: ${conditional({
73
70
  'color-transparent': whenProps({ $status: ['default', 'faded', 'next-month-day'] }),
74
71
  'color-neutral-dark': whenProps({
@@ -76,7 +73,14 @@ const PickerButton = styled(BaseButton)<{
76
73
  }),
77
74
  'color-neutral-lightest': whenProps({ $status: 'current-day' }),
78
75
  })};
79
- border-color: ${token('color-neutral')};
76
+ color: ${conditional({
77
+ 'color-neutral-dark': whenProps({ $status: ['default', 'faded'] }),
78
+ 'color-neutral-lightest': whenProps({
79
+ $status: ['selection-start', 'selection', 'selection-end'],
80
+ }),
81
+ })};
82
+
83
+ font-weight: ${token('font-weight-bold')};
80
84
  `}
81
85
 
82
86
  ${focusable`
@@ -85,25 +89,31 @@ const PickerButton = styled(BaseButton)<{
85
89
  `}
86
90
 
87
91
  ${activatable`
88
- color: ${conditional({
89
- 'color-neutral': whenProps({ 'aria-checked': false }),
90
- 'color-neutral-white': whenProps({ 'aria-checked': true }),
91
- })};
92
+ border-color: ${token('color-neutral')};
92
93
  background-color: ${conditional({
93
94
  'color-transparent': whenProps({ 'aria-checked': false }),
94
95
  'color-neutral': whenProps({ 'aria-checked': true }),
95
96
  })};
96
- border-color: ${token('color-neutral')};
97
+ color: ${conditional({
98
+ 'color-neutral': whenProps({ 'aria-checked': false }),
99
+ 'color-neutral-white': whenProps({ 'aria-checked': true }),
100
+ })};
97
101
  `}
98
102
 
99
103
  ${disableable`
100
- color: ${token('color-neutral-darker')};
101
104
  background-color: ${token('color-transparent')};
102
105
  border-color: ${conditional({
103
106
  'color-neutral-darkest': whenProps({ 'aria-checked': true }),
104
107
  'color-transparent': whenProps({ 'aria-checked': false }),
105
108
  })};
109
+
110
+ color: ${token('color-neutral-darker')};
106
111
  `}
112
+
113
+ visibility: ${conditional({
114
+ visible: whenProps({ 'aria-hidden': false }),
115
+ hidden: whenProps({ 'aria-hidden': true }),
116
+ })};
107
117
  `
108
118
 
109
119
  export default styled(PickerButton)({})
@@ -1,9 +1,10 @@
1
1
  import React from 'react'
2
2
 
3
- import generator from '../../../../tests/generator'
3
+ import generator from '../../../tests/generator'
4
4
  import range from 'utils/toolset/range'
5
- import renderer, { screen, fire } from '../../../../tests/renderer'
5
+ import renderer, { screen, fire } from '../../../tests/renderer'
6
6
  import YearPicker from './YearPicker'
7
+ import DateHelper from '../Date.helper'
7
8
 
8
9
  import type { useCalendarReturn, CalendarPickerProps, usePickerModeReturn } from '../Calendar.types'
9
10
 
@@ -15,16 +16,17 @@ function getYearRange() {
15
16
 
16
17
  describe('YearPicker', () => {
17
18
  const mockedCalendar: useCalendarReturn = {
19
+ mode: 'single',
18
20
  months: [
19
21
  {
20
22
  month: 10,
21
23
  year: 2021,
22
24
  days: [
23
- { date: 1, month: 10, year: 2021, timestamp: 1635735600000, format: jest.fn() },
24
- { date: 2, month: 10, year: 2021, timestamp: 1635822000000, format: jest.fn() },
25
- { date: 3, month: 10, year: 2021, timestamp: 1635908400000, format: jest.fn() },
26
- { date: 4, month: 10, year: 2021, timestamp: 1635994800000, format: jest.fn() },
27
- { date: 5, month: 10, year: 2021, timestamp: 1636081200000, format: jest.fn() },
25
+ DateHelper('2021-11-01T12:00:00.000Z'),
26
+ DateHelper('2021-11-02T12:00:00.000Z'),
27
+ DateHelper('2021-11-03T12:00:00.000Z'),
28
+ DateHelper('2021-11-04T12:00:00.000Z'),
29
+ DateHelper('2021-11-05T12:00:00.000Z'),
28
30
  ],
29
31
  },
30
32
  ],
@@ -9,9 +9,9 @@ import type { useCalendarReturn, CalendarPickerProps } from '../Calendar.types'
9
9
 
10
10
  const Container = styled.div`
11
11
  display: grid;
12
- grid-template-columns: repeat(4, 1fr);
13
12
  grid-auto-rows: 2.875rem;
14
13
  grid-gap: ${token('space-2xs')};
14
+ grid-template-columns: repeat(4, 1fr);
15
15
  `
16
16
 
17
17
  const PickerButton = styled(DefaultPickerButton)`
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import type { Story, Meta } from '@storybook/react/types-6-0'
3
3
 
4
4
  import Card from './Card'
5
- import generator from '../../../tests/generator'
5
+ import generator from '../../tests/generator'
6
6
  import Status from 'utils/types/Status'
7
7
 
8
8
  import type { CardProps } from './Card'
@@ -3,8 +3,8 @@ import { composeStories } from '@storybook/testing-react'
3
3
 
4
4
  import * as stories from './Card.stories'
5
5
  import Card from './Card'
6
- import generator from '../../../tests/generator'
7
- import renderer, { screen } from '../../../tests/renderer'
6
+ import generator from '../../tests/generator'
7
+ import renderer, { screen } from '../../tests/renderer'
8
8
  import Status from 'utils/types/Status'
9
9
 
10
10
  import type { CardProps } from './Card'
@@ -15,10 +15,10 @@ export interface CardProps extends HTMLAttributes<HTMLElement> {
15
15
 
16
16
  const CardSubtitle = styled.div`
17
17
  padding: 0 ${token('card-padding-x')} ${token('card-padding-y')};
18
- font-size: ${token('card-subtitle-font-size')};
19
- font-weight: ${token('card-subtitle-font-weight')};
20
18
 
21
19
  color: ${token('card-color')};
20
+ font-weight: ${token('card-subtitle-font-weight')};
21
+ font-size: ${token('card-subtitle-font-size')};
22
22
  `
23
23
 
24
24
  const CardSeparator = styled.hr`
@@ -35,13 +35,12 @@ const CardBody = styled.div`
35
35
  `
36
36
 
37
37
  const Wrapper = styled.div`
38
+ ${font({})}
39
+
38
40
  display: flex;
39
41
  flex-direction: row;
42
+
40
43
  color: ${token('card-color')};
41
- background: ${token('card-background')};
42
- border: 1px solid ${token('card-border-color')};
43
- border-radius: ${token('card-border-radius')};
44
- ${font({})}
45
44
 
46
45
  ${CardTitleWrapper} + ${CardSubtitle} {
47
46
  margin-top: ${token('space-xs')};
@@ -50,6 +49,10 @@ const Wrapper = styled.div`
50
49
  ${CardTitleWrapper} + ${CardSeparator} {
51
50
  margin-top: ${token('card-padding-y')};
52
51
  }
52
+
53
+ border: 1px solid ${token('card-border-color')};
54
+ border-radius: ${token('card-border-radius')};
55
+ background: ${token('card-background')};
53
56
  `
54
57
 
55
58
  const Container = styled.div<{ flagged: boolean }>`
@@ -21,13 +21,12 @@ const Leading = styled(StyledSpan)`
21
21
  `
22
22
 
23
23
  const Wrapper = styled.div`
24
-
25
24
  padding: ${token('card-padding-y')} ${token('card-padding-x')} 0;
26
- font-size: ${token('card-title-font-size')};
27
- font-weight: ${token('card-title-font-weight')};
28
- line-height: ${token('card-title-font-height')};
29
25
 
30
26
  color: ${token('card-color')};
27
+ font-weight: ${token('card-title-font-weight')};
28
+ font-size: ${token('card-title-font-size')};
29
+ line-height: ${token('card-title-font-height')};
31
30
  `
32
31
 
33
32
  function CardTitle({ children, leading, ...others }: CardTitleProps): JSX.Element {
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
2
 
3
3
  import Checkbox from './Checkbox'
4
- import generator from '../../../tests/generator'
5
- import renderer, { fire } from '../../../tests/renderer'
4
+ import generator from '../../tests/generator'
5
+ import renderer, { fire } from '../../tests/renderer'
6
6
 
7
7
  const setup = ({ ...overrides }) => renderer(<Checkbox {...overrides} />).render()
8
8