@loadsmart/loadsmart-ui 5.9.0 → 5.10.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 (202) hide show
  1. package/dist/common/SelectionWrapper.d.ts +1 -1
  2. package/dist/components/Accordion/Accordion.d.ts +1 -1
  3. package/dist/components/Accordion/Accordion.stories.d.ts +1 -1
  4. package/dist/components/Banner/Banner.stories.d.ts +1 -1
  5. package/dist/components/Breadcrumbs/Breadcrumbs.stories.d.ts +1 -1
  6. package/dist/components/Button/Button.d.ts +4 -1
  7. package/dist/components/Button/Button.stories.d.ts +2 -1
  8. package/dist/components/Card/Card.stories.d.ts +1 -1
  9. package/dist/components/Checkbox/Checkbox.d.ts +1 -1
  10. package/dist/components/Checkbox/Checkbox.stories.d.ts +1 -1
  11. package/dist/components/Dialog/Dialog.stories.d.ts +1 -1
  12. package/dist/components/DragDropFile/DragDropFile.stories.d.ts +1 -1
  13. package/dist/components/Drawer/Drawer.stories.d.ts +1 -1
  14. package/dist/components/Dropdown/Dropdown.stories.d.ts +1 -1
  15. package/dist/components/EmptyState/EmptyState.stories.d.ts +1 -1
  16. package/dist/components/ErrorMessage/ErrorMessage.stories.d.ts +1 -1
  17. package/dist/components/HighlightMatch/HighlightMatch.stories.d.ts +1 -1
  18. package/dist/components/IconFactory/IconFactory.stories.d.ts +1 -1
  19. package/dist/components/Label/Label.d.ts +2 -2
  20. package/dist/components/Label/Label.stories.d.ts +1 -1
  21. package/dist/components/Layout/Box.d.ts +1 -1
  22. package/dist/components/Layout/Grid.d.ts +1 -1
  23. package/dist/components/Layout/Layout.stories.d.ts +1 -1
  24. package/dist/components/Layout/Sidebar.d.ts +1 -1
  25. package/dist/components/Layout/Switcher.d.ts +1 -1
  26. package/dist/components/Link/Link.stories.d.ts +1 -1
  27. package/dist/components/Link/useSafeLink.d.ts +1 -1
  28. package/dist/components/Loaders/LoadingBar.stories.d.ts +1 -1
  29. package/dist/components/Loaders/LoadingDots.stories.d.ts +1 -1
  30. package/dist/components/Loaders/Spinner.stories.d.ts +1 -1
  31. package/dist/components/Modal/Modal.stories.d.ts +1 -1
  32. package/dist/components/Pagination/Pagination.stories.d.ts +1 -1
  33. package/dist/components/Pagination/Pagination.types.d.ts +2 -2
  34. package/dist/components/Popover/Popover.stories.d.ts +1 -1
  35. package/dist/components/ProgressBar/ProgressBar.stories.d.ts +1 -1
  36. package/dist/components/Radio/Radio.d.ts +1 -1
  37. package/dist/components/Radio/Radio.stories.d.ts +1 -1
  38. package/dist/components/Section/Sections.stories.d.ts +1 -1
  39. package/dist/components/Select/Select.fixtures.d.ts +2 -2
  40. package/dist/components/Select/Select.stories.d.ts +1 -1
  41. package/dist/components/Select/Select.types.d.ts +2 -2
  42. package/dist/components/Select/SelectCreatableOption.d.ts +1 -1
  43. package/dist/components/Select/SelectEmpty.d.ts +1 -1
  44. package/dist/components/Select/components.d.ts +1 -1
  45. package/dist/components/Select/useSelectExternal.d.ts +1 -1
  46. package/dist/components/SideNavigation/SideNavigation.stories.d.ts +1 -1
  47. package/dist/components/Steps/Steps.d.ts +1 -1
  48. package/dist/components/Steps/Steps.stories.d.ts +1 -1
  49. package/dist/components/Steps/StepsStep.d.ts +1 -1
  50. package/dist/components/Switch/Switch.stories.d.ts +1 -1
  51. package/dist/components/Table/Table.stories.d.ts +1 -1
  52. package/dist/components/Table/Table.types.d.ts +3 -4
  53. package/dist/components/Table/TableSortHandle.d.ts +1 -1
  54. package/dist/components/TablePagination/RowsPerPage.d.ts +1 -1
  55. package/dist/components/TablePagination/TablePagination.stories.d.ts +1 -1
  56. package/dist/components/TablePagination/TablePagination.types.d.ts +1 -1
  57. package/dist/components/TablePagination/TablePaginationActions.d.ts +1 -1
  58. package/dist/components/Tag/Tag.stories.d.ts +1 -1
  59. package/dist/components/Text/Text.d.ts +1 -1
  60. package/dist/components/Text/Text.stories.d.ts +1 -1
  61. package/dist/components/TextField/TextField.d.ts +1 -1
  62. package/dist/components/TextField/TextField.stories.d.ts +1 -1
  63. package/dist/components/Textarea/Textarea.d.ts +1 -1
  64. package/dist/components/Textarea/Textarea.stories.d.ts +1 -1
  65. package/dist/components/Toast/Toast.stories.d.ts +1 -1
  66. package/dist/components/ToggleGroup/ToggleGroup.stories.d.ts +1 -1
  67. package/dist/components/Tooltip/Tooltip.d.ts +3 -2
  68. package/dist/components/Tooltip/Tooltip.stories.d.ts +1 -1
  69. package/dist/hooks/useFocusTrap/useFocusTrap.stories.d.ts +1 -1
  70. package/dist/hooks/useHeightExpansionToggler/useHeightExpansionToggler.d.ts +1 -1
  71. package/dist/index.js +769 -909
  72. package/dist/index.js.map +1 -1
  73. package/dist/styles/activatable.d.ts +1 -1
  74. package/dist/styles/disableable.d.ts +1 -1
  75. package/dist/styles/focusable.d.ts +1 -1
  76. package/dist/styles/hoverable.d.ts +1 -1
  77. package/dist/testing/getInterpolatedStyles/getInterpolatedStyles.d.ts +1 -1
  78. package/dist/testing/index.js.map +1 -1
  79. package/dist/theming/index.d.ts +2 -2
  80. package/dist/theming/index.js.map +1 -1
  81. package/package.json +9 -10
  82. package/src/common/CloseButton/CloseButton.tsx +7 -11
  83. package/src/common/SelectionWrapper.tsx +8 -8
  84. package/src/components/Accordion/Accordion.stories.tsx +1 -1
  85. package/src/components/Accordion/Accordion.tsx +24 -29
  86. package/src/components/Banner/Banner.stories.tsx +1 -1
  87. package/src/components/Banner/Banner.tsx +2 -2
  88. package/src/components/Breadcrumbs/Breadcrumb.tsx +3 -4
  89. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +1 -1
  90. package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
  91. package/src/components/Button/Button.stories.tsx +33 -13
  92. package/src/components/Button/Button.test.tsx +24 -8
  93. package/src/components/Button/Button.tsx +139 -46
  94. package/src/components/Calendar/Calendar.tsx +4 -8
  95. package/src/components/Calendar/PickerModeToggle.tsx +3 -6
  96. package/src/components/Calendar/Pickers/DayPicker.tsx +1 -1
  97. package/src/components/Calendar/Pickers/MonthPicker.tsx +1 -1
  98. package/src/components/Calendar/Pickers/PickerButton.tsx +29 -39
  99. package/src/components/Calendar/Pickers/YearPicker.tsx +1 -1
  100. package/src/components/Card/Card.stories.tsx +1 -1
  101. package/src/components/Card/Card.tsx +6 -9
  102. package/src/components/Card/CardTitle.tsx +3 -3
  103. package/src/components/Checkbox/Checkbox.stories.tsx +1 -1
  104. package/src/components/Checkbox/Checkbox.tsx +15 -27
  105. package/src/components/Dialog/Dialog.stories.tsx +1 -1
  106. package/src/components/Dialog/Dialog.tsx +5 -5
  107. package/src/components/DragDropFile/DragDropFile.stories.tsx +1 -1
  108. package/src/components/DragDropFile/styles.tsx +6 -11
  109. package/src/components/Drawer/Drawer.stories.tsx +1 -1
  110. package/src/components/Drawer/Drawer.tsx +6 -6
  111. package/src/components/Dropdown/Dropdown.stories.tsx +1 -1
  112. package/src/components/Dropdown/DropdownMenu.tsx +15 -28
  113. package/src/components/Dropdown/DropdownTrigger.tsx +24 -34
  114. package/src/components/EmptyState/EmptyState.stories.tsx +1 -1
  115. package/src/components/ErrorMessage/ErrorMessage.stories.tsx +1 -1
  116. package/src/components/HighlightMatch/HighlightMatch.stories.tsx +1 -1
  117. package/src/components/HighlightMatch/HighlightMatch.test.tsx +1 -1
  118. package/src/components/HighlightMatch/HighlightMatch.tsx +1 -1
  119. package/src/components/IconFactory/IconFactory.stories.tsx +1 -1
  120. package/src/components/Label/Label.stories.tsx +1 -1
  121. package/src/components/Label/Label.tsx +5 -5
  122. package/src/components/Layout/Box.tsx +1 -1
  123. package/src/components/Layout/Grid.tsx +1 -1
  124. package/src/components/Layout/Layout.stories.tsx +1 -1
  125. package/src/components/Layout/Sidebar.tsx +1 -1
  126. package/src/components/Layout/Switcher.tsx +1 -1
  127. package/src/components/Link/Link.stories.tsx +1 -1
  128. package/src/components/Link/Link.tsx +9 -13
  129. package/src/components/Link/useSafeLink.ts +1 -1
  130. package/src/components/Loaders/LoadingBar.stories.tsx +1 -1
  131. package/src/components/Loaders/LoadingBar.tsx +2 -2
  132. package/src/components/Loaders/LoadingDots.stories.tsx +1 -1
  133. package/src/components/Loaders/Spinner.stories.tsx +1 -1
  134. package/src/components/Modal/Modal.stories.tsx +1 -1
  135. package/src/components/Modal/Modal.tsx +7 -12
  136. package/src/components/Pagination/Pagination.stories.tsx +1 -1
  137. package/src/components/Pagination/Pagination.test.tsx +1 -1
  138. package/src/components/Pagination/Pagination.types.ts +2 -2
  139. package/src/components/Popover/Popover.stories.tsx +1 -1
  140. package/src/components/ProgressBar/ProgressBar.stories.tsx +1 -1
  141. package/src/components/ProgressBar/ProgressBar.tsx +4 -6
  142. package/src/components/Radio/Radio.stories.tsx +1 -1
  143. package/src/components/Radio/Radio.tsx +12 -20
  144. package/src/components/Section/Section.tsx +6 -8
  145. package/src/components/Section/Sections.stories.tsx +1 -1
  146. package/src/components/Select/Select.fixtures.ts +3 -3
  147. package/src/components/Select/Select.stories.tsx +7 -5
  148. package/src/components/Select/Select.test.tsx +20 -40
  149. package/src/components/Select/Select.types.ts +2 -2
  150. package/src/components/Select/SelectCreatableOption.tsx +1 -1
  151. package/src/components/Select/SelectEmpty.tsx +5 -6
  152. package/src/components/Select/SelectOption.test.tsx +1 -1
  153. package/src/components/Select/SelectTrigger.tsx +6 -11
  154. package/src/components/Select/components.tsx +1 -1
  155. package/src/components/Select/useSelect.ts +1 -1
  156. package/src/components/Select/useSelectExternal.ts +1 -1
  157. package/src/components/SideNavigation/Menu/Menu.test.tsx +1 -1
  158. package/src/components/SideNavigation/Menu/Menu.tsx +3 -3
  159. package/src/components/SideNavigation/Menu/MenuBaseItem.tsx +4 -5
  160. package/src/components/SideNavigation/Menu/MenuExpandable.tsx +2 -3
  161. package/src/components/SideNavigation/SideNavigation.stories.tsx +1 -1
  162. package/src/components/Steps/ProgressSteps/ProgressStep.tsx +31 -39
  163. package/src/components/Steps/Steps.stories.tsx +1 -1
  164. package/src/components/Steps/Steps.tsx +2 -1
  165. package/src/components/Steps/StepsStep.tsx +2 -1
  166. package/src/components/Switch/Switch.stories.tsx +1 -1
  167. package/src/components/Switch/Switch.tsx +6 -18
  168. package/src/components/Table/Table.stories.tsx +1 -1
  169. package/src/components/Table/Table.tsx +2 -2
  170. package/src/components/Table/Table.types.ts +9 -4
  171. package/src/components/Table/TableSortHandle.tsx +1 -1
  172. package/src/components/TablePagination/RowsPerPage.tsx +2 -2
  173. package/src/components/TablePagination/TablePagination.stories.tsx +1 -1
  174. package/src/components/TablePagination/TablePagination.test.tsx +1 -1
  175. package/src/components/TablePagination/TablePagination.types.ts +1 -1
  176. package/src/components/TablePagination/TablePaginationActions.tsx +1 -1
  177. package/src/components/Tabs/Tabs.tsx +26 -32
  178. package/src/components/Tag/Tag.stories.tsx +1 -1
  179. package/src/components/Tag/Tag.tsx +35 -44
  180. package/src/components/Text/Text.stories.tsx +1 -1
  181. package/src/components/Text/Text.tsx +1 -1
  182. package/src/components/TextField/TextField.stories.tsx +1 -1
  183. package/src/components/TextField/TextField.tsx +16 -23
  184. package/src/components/Textarea/Textarea.stories.tsx +1 -1
  185. package/src/components/Textarea/Textarea.tsx +18 -23
  186. package/src/components/Toast/Toast.stories.tsx +1 -1
  187. package/src/components/Toast/Toast.tsx +3 -3
  188. package/src/components/ToggleGroup/Toggle.tsx +7 -7
  189. package/src/components/ToggleGroup/ToggleGroup.stories.tsx +1 -1
  190. package/src/components/Tooltip/Tooltip.stories.tsx +1 -1
  191. package/src/components/Tooltip/Tooltip.tsx +23 -24
  192. package/src/components/TopNavigation/Menu/MenuItemDropdown.tsx +1 -1
  193. package/src/components/TopNavigation/OpenSideNavButton/OpenSideNavButton.tsx +1 -1
  194. package/src/hooks/useFocusTrap/useFocusTrap.stories.tsx +1 -1
  195. package/src/hooks/useHeightExpansionToggler/useHeightExpansionToggler.ts +1 -1
  196. package/src/styles/activatable.tsx +1 -1
  197. package/src/styles/disableable.tsx +1 -1
  198. package/src/styles/focusable.tsx +1 -1
  199. package/src/styles/font.tsx +3 -3
  200. package/src/styles/hoverable.tsx +1 -1
  201. package/src/testing/getInterpolatedStyles/getInterpolatedStyles.ts +1 -1
  202. package/src/theming/index.ts +3 -2
@@ -14,17 +14,23 @@ import rem from 'utils/toolset/rem'
14
14
  import transition from 'styles/transition'
15
15
  import typography from 'styles/typography'
16
16
 
17
+ import { LoadingDots } from 'components/Loaders'
18
+
17
19
  import type { ButtonHTMLAttributes, ForwardedRef, ReactNode } from 'react'
18
20
  import type { IconProps } from 'components/Icon'
19
21
  import type ColorScheme from 'utils/types/ColorScheme'
22
+ import type { LoadingDotsProps } from 'components/Loaders'
23
+
24
+ export type ButtonVariants = 'primary' | 'secondary' | 'warning' | 'icon' | 'tertiary'
20
25
 
21
26
  export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
22
27
  className?: string
23
28
  leading?: ReactNode
24
29
  scheme?: ColorScheme
25
30
  trailing?: ReactNode
26
- variant?: 'primary' | 'secondary' | 'warning' | 'icon' | 'tertiary'
31
+ variant?: ButtonVariants
27
32
  scale?: 'small' | 'default' | 'large'
33
+ loading?: boolean
28
34
  }
29
35
 
30
36
  const StyledSpan = styled.span`
@@ -44,33 +50,24 @@ const Trailing = styled(StyledSpan)`
44
50
  /* placeholder */
45
51
  `
46
52
 
47
- export const Children = styled.span`
48
- ${({ children }: ButtonProps) =>
53
+ export const Children = styled.span<ButtonProps>`
54
+ ${({ children }) =>
49
55
  typeof children === 'string'
50
- ? `
51
- ${ellipsizable()}
52
- `
56
+ ? ellipsizable()
53
57
  : `
54
- display: inline-flex;
55
- flex-flow: row nowrap;
56
- align-items: center;
57
- justify-content: center;
58
- `}
58
+ display: inline-flex;
59
+ flex-flow: row nowrap;
60
+ align-items: center;
61
+ justify-content: center;
62
+ `}
59
63
 
60
64
  padding: ${rem('6px')} 0;
61
65
  `
62
66
 
63
- const BaseStyledButton = styled.button<{ $scale: ButtonProps['scale'] }>`
64
- ${transition()}
65
-
66
- ${typography(
67
- conditional({
68
- 'button-md': whenProps({ $scale: 'default' }),
69
- 'button-sm': whenProps({ $scale: 'small' }),
70
- 'button-lg': whenProps({ $scale: 'large' }),
71
- })
72
- )}
73
-
67
+ const BaseStyledButton = styled.button<{
68
+ $scale: ButtonProps['scale']
69
+ $loading?: ButtonProps['loading']
70
+ }>`
74
71
  box-sizing: border-box;
75
72
 
76
73
  display: inline-flex;
@@ -78,16 +75,6 @@ const BaseStyledButton = styled.button<{ $scale: ButtonProps['scale'] }>`
78
75
  align-items: center;
79
76
  justify-content: center;
80
77
 
81
- text-transform: uppercase;
82
- text-align: center;
83
-
84
- cursor: pointer;
85
-
86
- border-radius: ${token('border-radius-s')};
87
- border-width: ${token('border-width-thin')};
88
- border-style: solid;
89
- border-color: ${token('color-neutral-darker')};
90
-
91
78
  height: ${conditional({
92
79
  'button-height': whenProps({ $scale: 'default' }),
93
80
  'button-small-height': whenProps({ $scale: 'small' }),
@@ -95,8 +82,27 @@ const BaseStyledButton = styled.button<{ $scale: ButtonProps['scale'] }>`
95
82
  })};
96
83
 
97
84
  padding: 0 8px;
85
+ text-align: center;
86
+ text-transform: uppercase;
87
+
88
+ cursor: pointer;
89
+
90
+ border-color: ${token('color-neutral-darker')};
91
+ border-style: solid;
92
+ border-width: ${token('border-width-thin')};
93
+ border-radius: ${token('border-radius-s')};
98
94
 
99
95
  ${disableable()}
96
+ ${transition()}
97
+ ${typography(
98
+ conditional({
99
+ 'button-md': whenProps({ $scale: 'default' }),
100
+ 'button-sm': whenProps({ $scale: 'small' }),
101
+ 'button-lg': whenProps({ $scale: 'large' }),
102
+ })
103
+ )}
104
+
105
+ ${({ $loading }) => $loading && 'pointer-events: none;'}
100
106
 
101
107
  ${Leading} {
102
108
  margin: 0 ${token('space-xs')} 0 0;
@@ -359,15 +365,86 @@ const StyledSelector = styled(StyledButton)`
359
365
  }
360
366
  `
361
367
 
362
- export const BaseButton = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
363
- { scale = 'default', children, leading, trailing, ...others }: ButtonProps,
368
+ const TextHidden = styled.span`
369
+ transform: scale(0);
370
+ `
371
+
372
+ /**
373
+ * Accessible attributes in `LoadingDots` aren't necessary
374
+ * because the `Button` will keep its content, but invisible
375
+ */
376
+ const StyledLoadingDots = styled(LoadingDots).attrs({
377
+ 'aria-label': undefined,
378
+ role: 'presentation',
379
+ })`
380
+ position: absolute;
381
+
382
+ display: flex;
383
+ align-items: center;
384
+ justify-content: center;
385
+
386
+ width: 100%;
387
+ `
388
+
389
+ const ButtonLoadingDots = ({
390
+ buttonVariant = 'secondary',
391
+ ...remainingProps
392
+ }: Omit<LoadingDotsProps, 'variant'> & { buttonVariant?: ButtonVariants }) => {
393
+ const buttonLightVariants = new Set(['secondary', 'warning', 'icon', 'tertiary'])
394
+ /**
395
+ * Change LoadingDots variant between `light` and `dark` to have contrast with Button's variant
396
+ */
397
+ const loadingDotsVariant: 'dark' | 'light' = buttonLightVariants.has(buttonVariant)
398
+ ? 'dark'
399
+ : 'light'
400
+
401
+ return <StyledLoadingDots {...remainingProps} variant={loadingDotsVariant} />
402
+ }
403
+
404
+ function ButtonChildrenWrapper({
405
+ loading,
406
+ children,
407
+ variant,
408
+ }: Pick<ButtonProps, 'loading' | 'children' | 'variant'>) {
409
+ if (loading) {
410
+ return (
411
+ <>
412
+ <ButtonLoadingDots buttonVariant={variant} />
413
+ <TextHidden>{children}</TextHidden>
414
+ </>
415
+ )
416
+ }
417
+
418
+ return <>{children}</>
419
+ }
420
+
421
+ export const BaseButton = forwardRef<HTMLButtonElement, ButtonProps>(function BaseButton(
422
+ {
423
+ scale = 'default',
424
+ children,
425
+ leading,
426
+ trailing,
427
+ loading,
428
+ disabled,
429
+ variant,
430
+ ...others
431
+ }: ButtonProps,
364
432
  ref: ForwardedRef<HTMLButtonElement>
365
433
  ) {
366
434
  return (
367
- <BaseStyledButton ref={ref} {...others} $scale={scale}>
368
- {leading && <Leading aria-hidden="true">{leading}</Leading>}
369
- <Children>{children}</Children>
370
- {trailing && <Trailing aria-hidden="true">{trailing}</Trailing>}
435
+ <BaseStyledButton
436
+ ref={ref}
437
+ {...others}
438
+ aria-disabled={loading ? 'true' : undefined}
439
+ disabled={disabled}
440
+ $scale={scale}
441
+ $loading={loading}
442
+ >
443
+ <ButtonChildrenWrapper loading={loading} variant={variant}>
444
+ {leading && <Leading aria-hidden="true">{leading}</Leading>}
445
+ <Children loading={loading}>{children}</Children>
446
+ {trailing && <Trailing aria-hidden="true">{trailing}</Trailing>}
447
+ </ButtonChildrenWrapper>
371
448
  </BaseStyledButton>
372
449
  )
373
450
  })
@@ -381,6 +458,8 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
381
458
  children,
382
459
  leading,
383
460
  trailing,
461
+ disabled,
462
+ loading,
384
463
  ...others
385
464
  }: ButtonProps,
386
465
  ref: ForwardedRef<HTMLButtonElement>
@@ -390,13 +469,18 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
390
469
  ref={ref}
391
470
  {...others}
392
471
  type={type}
472
+ aria-disabled={loading ? 'true' : undefined}
473
+ disabled={disabled}
393
474
  $scheme={scheme}
394
475
  $scale={scale}
395
476
  $variant={variant}
477
+ $loading={loading}
396
478
  >
397
- {leading && <Leading>{leading}</Leading>}
398
- <Children>{children}</Children>
399
- {trailing && <Trailing>{trailing}</Trailing>}
479
+ <ButtonChildrenWrapper loading={loading} variant={variant}>
480
+ {leading && <Leading>{leading}</Leading>}
481
+ <Children>{children}</Children>
482
+ {trailing && <Trailing>{trailing}</Trailing>}
483
+ </ButtonChildrenWrapper>
400
484
  </StyledButton>
401
485
  )
402
486
  })
@@ -405,7 +489,7 @@ export function Caret(props: Omit<IconProps, 'name'>): JSX.Element {
405
489
  return <Icon size={20} {...props} name="caret-down" />
406
490
  }
407
491
 
408
- export const SelectorButton = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
492
+ export const SelectorButton = forwardRef<HTMLButtonElement, ButtonProps>(function SelectorButton(
409
493
  {
410
494
  scheme = 'light',
411
495
  scale = 'default',
@@ -413,6 +497,8 @@ export const SelectorButton = forwardRef<HTMLButtonElement, ButtonProps>(functio
413
497
  variant = 'secondary',
414
498
  children,
415
499
  trailing,
500
+ disabled,
501
+ loading,
416
502
  ...others
417
503
  }: ButtonProps,
418
504
  ref: ForwardedRef<HTMLButtonElement>
@@ -424,18 +510,25 @@ export const SelectorButton = forwardRef<HTMLButtonElement, ButtonProps>(functio
424
510
  ref={ref}
425
511
  {...others}
426
512
  type={type}
513
+ aria-disabled={loading ? 'true' : undefined}
514
+ disabled={disabled}
515
+ $loading={loading}
427
516
  $scheme={scheme}
428
517
  $scale={scale}
429
518
  $variant={variant}
430
519
  >
431
- <Children>{children}</Children>
432
- {trailing && <Trailing>{trailing}</Trailing>}
520
+ <ButtonChildrenWrapper loading={loading} variant={variant}>
521
+ <Children>{children}</Children>
522
+ {trailing && <Trailing>{trailing}</Trailing>}
523
+ </ButtonChildrenWrapper>
433
524
  </StyledSelector>
434
525
  )
435
526
  })
436
527
 
437
- export const IconButton = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
438
- { scheme = 'light', scale = 'default', type = 'button', children, ...others }: ButtonProps,
528
+ export type IconButtonProps = Omit<ButtonProps, 'leading' | 'trailing' | 'variant' | 'loading'>
529
+
530
+ export const IconButton = forwardRef<HTMLButtonElement, ButtonProps>(function IconButton(
531
+ { scheme = 'light', scale = 'default', type = 'button', children, ...others }: IconButtonProps,
439
532
  ref: ForwardedRef<HTMLButtonElement>
440
533
  ) {
441
534
  others = omit<ButtonProps>(others, ['leading', 'trailing', 'variant'])
@@ -23,23 +23,19 @@ const Container = styled(Stack)`
23
23
  `
24
24
 
25
25
  const BorderlessButton = styled(BaseButton)`
26
- ${typography('body-bold')}
27
- border-color: transparent;
28
- background-color: transparent;
29
-
30
26
  color: ${token('color-neutral')};
31
-
32
- inline-size: 40px;
33
-
34
27
  visibility: ${conditional({
35
28
  visible: whenProps({ 'aria-hidden': false }),
36
29
  hidden: whenProps({ 'aria-hidden': true }),
37
30
  })};
31
+ background-color: transparent;
32
+ border-color: transparent;
33
+ inline-size: 40px;
38
34
 
35
+ ${typography('body-bold')}
39
36
  ${hoverable`
40
37
  color: ${token('color-neutral-dark')};
41
38
  `}
42
-
43
39
  ${focusable`
44
40
  box-shadow: ${token('button-primary-outline')};
45
41
  `}
@@ -12,7 +12,10 @@ 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')};
15
16
  user-select: none;
17
+ background-color: transparent;
18
+ border-color: transparent;
16
19
 
17
20
  ${typography(
18
21
  conditional({
@@ -20,15 +23,9 @@ const Button = styled(BaseButton)`
20
23
  body: whenProps({ 'aria-expanded': false }),
21
24
  })
22
25
  )};
23
- border-color: transparent;
24
- background-color: transparent;
25
-
26
- color: ${token('color-neutral-dark')};
27
-
28
26
  ${focusable`
29
27
  box-shadow: ${token('button-primary-outline')};
30
28
  `}
31
-
32
29
  ${disableable`
33
30
  pointer-events: none;
34
31
  opacity: 1;
@@ -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')};
57
56
  grid-template-rows: 1.25rem repeat(auto-fill, 2.5rem);
58
57
  grid-template-columns: repeat(7, 2.5rem);
58
+ grid-gap: ${token('space-2xs')};
59
59
  `
60
60
 
61
61
  /**
@@ -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);
13
14
  grid-auto-rows: 3.75rem;
14
15
  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,20 +19,8 @@ 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
-
33
22
  height: 100%;
34
-
35
- border-radius: 0;
23
+ padding: ${token('space-xs')} ${token('space-s')};
36
24
 
37
25
  color: ${conditional({
38
26
  'color-neutral-lighter': whenProps({
@@ -42,30 +30,45 @@ const PickerButton = styled(BaseButton)<{
42
30
  'color-neutral-dark': whenProps({ $status: 'next-month-day' }),
43
31
  'color-accent': whenProps({ $status: 'current-day' }),
44
32
  })};
45
-
33
+ visibility: ${conditional({
34
+ visible: whenProps({ 'aria-hidden': false }),
35
+ hidden: whenProps({ 'aria-hidden': true }),
36
+ })};
37
+ user-select: none;
46
38
  background: ${conditional({
47
39
  'color-transparent': whenProps({ $status: ['default', 'faded', 'next-month-day'] }),
48
40
  'color-neutral-darker': whenProps({ $status: ['selection-start', 'selection-end'] }),
49
41
  'color-neutral': whenProps({ $status: 'selection' }),
50
42
  'color-neutral-lightest': whenProps({ $status: 'current-day' }),
51
43
  })};
52
-
53
44
  border-color: ${conditional({
54
45
  'color-transparent': whenProps({ $status: ['default', 'faded', 'next-month-day'] }),
55
46
  'color-neutral-darker': whenProps({ $status: ['selection-start', 'selection-end'] }),
56
47
  'color-neutral': whenProps({ $status: 'selection' }),
57
48
  'color-neutral-light': whenProps({ $status: 'current-day' }),
58
49
  })};
50
+ border-radius: 0;
59
51
 
60
52
  ${conditional({
61
53
  'opacity: 0.4;': whenProps({ $status: 'faded' }),
62
54
  'opacity: 1;': whenProps({ $status: (status) => status !== 'faded' }),
63
55
  })}
64
-
65
- padding: ${token('space-xs')} ${token('space-s')};
66
-
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
+ )}
67
64
  ${hoverable`
68
- border-color: ${token('color-neutral')};
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
+ })};
69
72
  background-color: ${conditional({
70
73
  'color-transparent': whenProps({ $status: ['default', 'faded', 'next-month-day'] }),
71
74
  'color-neutral-dark': whenProps({
@@ -73,14 +76,7 @@ const PickerButton = styled(BaseButton)<{
73
76
  }),
74
77
  'color-neutral-lightest': whenProps({ $status: 'current-day' }),
75
78
  })};
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')};
79
+ border-color: ${token('color-neutral')};
84
80
  `}
85
81
 
86
82
  ${focusable`
@@ -89,31 +85,25 @@ const PickerButton = styled(BaseButton)<{
89
85
  `}
90
86
 
91
87
  ${activatable`
92
- border-color: ${token('color-neutral')};
93
- background-color: ${conditional({
94
- 'color-transparent': whenProps({ 'aria-checked': false }),
95
- 'color-neutral': whenProps({ 'aria-checked': true }),
96
- })};
97
88
  color: ${conditional({
98
89
  'color-neutral': whenProps({ 'aria-checked': false }),
99
90
  'color-neutral-white': whenProps({ 'aria-checked': true }),
100
91
  })};
92
+ background-color: ${conditional({
93
+ 'color-transparent': whenProps({ 'aria-checked': false }),
94
+ 'color-neutral': whenProps({ 'aria-checked': true }),
95
+ })};
96
+ border-color: ${token('color-neutral')};
101
97
  `}
102
98
 
103
99
  ${disableable`
100
+ color: ${token('color-neutral-darker')};
104
101
  background-color: ${token('color-transparent')};
105
102
  border-color: ${conditional({
106
103
  'color-neutral-darkest': whenProps({ 'aria-checked': true }),
107
104
  'color-transparent': whenProps({ 'aria-checked': false }),
108
105
  })};
109
-
110
- color: ${token('color-neutral-darker')};
111
106
  `}
112
-
113
- visibility: ${conditional({
114
- visible: whenProps({ 'aria-hidden': false }),
115
- hidden: whenProps({ 'aria-hidden': true }),
116
- })};
117
107
  `
118
108
 
119
109
  export default styled(PickerButton)({})
@@ -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);
12
13
  grid-auto-rows: 2.875rem;
13
14
  grid-gap: ${token('space-2xs')};
14
- grid-template-columns: repeat(4, 1fr);
15
15
  `
16
16
 
17
17
  const PickerButton = styled(DefaultPickerButton)`
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { Story, Meta } from '@storybook/react/types-6-0'
2
+ import type { Story, Meta } from '@storybook/react/types-6-0'
3
3
 
4
4
  import Card from './Card'
5
5
  import generator from '../../../tests/generator'
@@ -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')};
18
20
 
19
21
  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,12 +35,13 @@ const CardBody = styled.div`
35
35
  `
36
36
 
37
37
  const Wrapper = styled.div`
38
- ${font({})}
39
-
40
38
  display: flex;
41
39
  flex-direction: row;
42
-
43
40
  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({})}
44
45
 
45
46
  ${CardTitleWrapper} + ${CardSubtitle} {
46
47
  margin-top: ${token('space-xs')};
@@ -49,10 +50,6 @@ const Wrapper = styled.div`
49
50
  ${CardTitleWrapper} + ${CardSeparator} {
50
51
  margin-top: ${token('card-padding-y')};
51
52
  }
52
-
53
- border: 1px solid ${token('card-border-color')};
54
- border-radius: ${token('card-border-radius')};
55
- background: ${token('card-background')};
56
53
  `
57
54
 
58
55
  const Container = styled.div<{ flagged: boolean }>`
@@ -23,11 +23,11 @@ const Leading = styled(StyledSpan)`
23
23
  const Wrapper = styled.div`
24
24
 
25
25
  padding: ${token('card-padding-y')} ${token('card-padding-x')} 0;
26
-
27
- color: ${token('card-color')};
28
- font-weight: ${token('card-title-font-weight')};
29
26
  font-size: ${token('card-title-font-size')};
27
+ font-weight: ${token('card-title-font-weight')};
30
28
  line-height: ${token('card-title-font-height')};
29
+
30
+ color: ${token('card-color')};
31
31
  `
32
32
 
33
33
  function CardTitle({ children, leading, ...others }: CardTitleProps): JSX.Element {
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import Checkbox, { CheckboxProps } from './Checkbox'
3
- import { Meta } from '@storybook/react/types-6-0'
3
+ import type { Meta } from '@storybook/react/types-6-0'
4
4
 
5
5
  import Status from 'utils/types/Status'
6
6
 
@@ -2,7 +2,7 @@ import React, { Fragment, InputHTMLAttributes, ReactNode } from 'react'
2
2
  import clsx from 'clsx'
3
3
 
4
4
  import { Icon } from 'components/Icon'
5
- import ColorScheme from 'utils/types/ColorScheme'
5
+ import type ColorScheme from 'utils/types/ColorScheme'
6
6
  import conditional, { whenProps } from 'tools/conditional'
7
7
  import disableable from 'styles/disableable'
8
8
  import focusable from 'styles/focusable'
@@ -21,45 +21,32 @@ export interface CheckboxProps extends InputHTMLAttributes<HTMLInputElement>, Se
21
21
  const Check = styled(Icon)<SelectionStyleProps>`
22
22
  position: absolute;
23
23
  top: 50%;
24
-
25
24
  left: 50%;
26
-
27
- transform: translate(-50%, -50%);
28
-
29
25
  pointer-events: none;
26
+ transform: translate(-50%, -50%);
30
27
  `
31
28
 
32
29
  const Selector = styled.input<SelectionStyleProps>`
33
- ${transition()}
34
-
35
30
  display: inline-flex;
36
31
  flex-flow: row nowrap;
37
32
  align-items: center;
38
-
39
- cursor: pointer;
40
-
41
- appearance: none;
42
-
43
- outline: none;
44
-
45
- color: white;
46
-
47
- height: ${token('checkbox-selector-size')};
48
33
  width: ${token('checkbox-selector-size')};
49
-
50
- border-radius: ${token('checkbox-selector-border-radius')};
51
- border-width: ${token('button-border-width')};
52
- border-style: solid;
53
-
54
- border-color: ${conditional({
55
- 'checkbox-selector-border-color': whenProps({ scheme: 'light' }),
56
- 'checkbox-dark-selector-border-color': whenProps({ scheme: 'dark' }),
57
- })};
58
-
34
+ height: ${token('checkbox-selector-size')};
35
+ color: white;
36
+ cursor: pointer;
59
37
  background: ${conditional({
60
38
  'checkbox-selector-background': whenProps({ scheme: 'light' }),
61
39
  'checkbox-dark-selector-background': whenProps({ scheme: 'dark' }),
62
40
  })};
41
+ border-color: ${conditional({
42
+ 'checkbox-selector-border-color': whenProps({ scheme: 'light' }),
43
+ 'checkbox-dark-selector-border-color': whenProps({ scheme: 'dark' }),
44
+ })};
45
+ border-style: solid;
46
+ border-width: ${token('button-border-width')};
47
+ border-radius: ${token('checkbox-selector-border-radius')};
48
+ appearance: none;
49
+ outline: none;
63
50
 
64
51
  :checked {
65
52
  background-color: ${token('checkbox-selector-checked-background')};
@@ -129,6 +116,7 @@ const Selector = styled.input<SelectionStyleProps>`
129
116
 
130
117
  box-shadow: ${token('checkbox-selector-outline')};
131
118
  `}
119
+ ${transition()}
132
120
  `
133
121
 
134
122
  function Checkbox({
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react'
2
- import { Meta } from '@storybook/react/types-6-0'
2
+ import type { Meta } from '@storybook/react/types-6-0'
3
3
  import Dialog from './Dialog'
4
4
  import useDialog from './useDialog'
5
5
  import type { DialogProps } from './Dialog'