@redsift/design-system 11.6.0-muiv5-alpha.5 → 11.6.0-muiv5-alpha.6

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 (269) hide show
  1. package/_internal/Alert.d2.ts +54 -0
  2. package/_internal/Alert2.js +182 -39
  3. package/_internal/AppBar.d.ts +37 -0
  4. package/_internal/AppBar.js +240 -29
  5. package/_internal/AppContainer.d.ts +96 -0
  6. package/_internal/AppContainer.js +132 -86
  7. package/_internal/AppContent.d.ts +25 -0
  8. package/_internal/AppContent.js +84 -17
  9. package/_internal/Badge.d2.ts +9 -0
  10. package/_internal/Badge2.js +137 -4
  11. package/_internal/BreadcrumbItem.d.ts +9 -0
  12. package/_internal/BreadcrumbItem.js +85 -3
  13. package/_internal/Breadcrumbs.d2.ts +29 -0
  14. package/_internal/Breadcrumbs2.js +86 -21
  15. package/_internal/Button.d2.ts +30 -0
  16. package/_internal/Button2.js +81 -20
  17. package/_internal/ButtonGroup.d.ts +41 -0
  18. package/_internal/ButtonGroup.js +165 -25
  19. package/_internal/ButtonLink.d.ts +28 -0
  20. package/_internal/ButtonLink.js +74 -18
  21. package/_internal/Card.d2.ts +35 -0
  22. package/_internal/Card2.js +151 -29
  23. package/_internal/CardActions.d.ts +9 -0
  24. package/_internal/CardActions.js +38 -3
  25. package/_internal/CardBody.d.ts +9 -0
  26. package/_internal/CardBody.js +36 -3
  27. package/_internal/CardHeader.d.ts +9 -0
  28. package/_internal/CardHeader.js +77 -3
  29. package/_internal/Checkbox.d2.ts +68 -0
  30. package/_internal/Checkbox2.js +234 -58
  31. package/_internal/CheckboxGroup.d.ts +10 -0
  32. package/_internal/CheckboxGroup.js +182 -4
  33. package/_internal/ConditionalWrapper.d.ts +14 -0
  34. package/_internal/ConditionalWrapper.js +11 -12
  35. package/_internal/DetailedCard.d.ts +52 -0
  36. package/_internal/DetailedCard.js +6912 -48
  37. package/_internal/DetailedCardCollapsibleSectionItems.d.ts +9 -0
  38. package/_internal/DetailedCardCollapsibleSectionItems.js +58 -3
  39. package/_internal/DetailedCardHeader.d.ts +9 -0
  40. package/_internal/DetailedCardHeader.js +61 -3
  41. package/_internal/DetailedCardSection.d.ts +9 -0
  42. package/_internal/DetailedCardSection.js +166 -3
  43. package/_internal/DetailedCardSectionItem.d.ts +9 -0
  44. package/_internal/DetailedCardSectionItem.js +88 -3
  45. package/_internal/Flexbox.d2.ts +30 -0
  46. package/_internal/Flexbox2.js +85 -22
  47. package/_internal/Grid.d2.ts +32 -0
  48. package/_internal/Grid2.js +87 -24
  49. package/_internal/GridItem.d.ts +9 -0
  50. package/_internal/GridItem.js +34 -3
  51. package/_internal/Heading.d2.ts +9 -0
  52. package/_internal/Heading2.js +107 -3
  53. package/_internal/Icon.d2.ts +10 -0
  54. package/_internal/Icon2.js +206 -5
  55. package/_internal/IconButton.d.ts +12 -0
  56. package/_internal/IconButton.js +71 -3
  57. package/_internal/IconButtonLink.d.ts +28 -0
  58. package/_internal/IconButtonLink.js +65 -18
  59. package/_internal/Item.d2.ts +82 -0
  60. package/_internal/Item2.js +390 -73
  61. package/_internal/Link.d2.ts +26 -0
  62. package/_internal/Link2.js +56 -15
  63. package/_internal/LinkButton.d.ts +23 -0
  64. package/_internal/LinkButton.js +56 -13
  65. package/_internal/Number.d2.ts +69 -0
  66. package/_internal/Number2.js +103 -61
  67. package/_internal/NumberField.d.ts +80 -0
  68. package/_internal/NumberField.js +3959 -65
  69. package/_internal/Pill.d2.ts +9 -0
  70. package/_internal/Pill2.js +400 -4
  71. package/_internal/ProgressBar.d.ts +26 -0
  72. package/_internal/ProgressBar.js +61 -18
  73. package/_internal/Radio.d2.ts +66 -0
  74. package/_internal/Radio2.js +227 -56
  75. package/_internal/RadioGroup.d.ts +10 -0
  76. package/_internal/RadioGroup.js +170 -4
  77. package/_internal/Shield.d2.ts +9 -0
  78. package/_internal/Shield2.js +220 -4
  79. package/_internal/SideNavigationMenu.d.ts +9 -0
  80. package/_internal/SideNavigationMenu.js +586 -4
  81. package/_internal/{SideNavigationMenuBar.js → SideNavigationMenuBar.d.ts} +1 -1
  82. package/_internal/SideNavigationMenuItem.d.ts +9 -0
  83. package/_internal/SideNavigationMenuItem.js +299 -4
  84. package/_internal/Skeleton.d2.ts +15 -0
  85. package/_internal/Skeleton2.js +36 -9
  86. package/_internal/SkeletonCircle.d.ts +9 -0
  87. package/_internal/SkeletonCircle.js +52 -3
  88. package/_internal/SkeletonText.d.ts +9 -0
  89. package/_internal/SkeletonText.js +71 -3
  90. package/_internal/Spinner.d2.ts +43 -0
  91. package/_internal/Spinner2.js +319 -29
  92. package/_internal/Switch.d2.ts +66 -0
  93. package/_internal/Switch2.js +310 -56
  94. package/_internal/SwitchGroup.d.ts +10 -0
  95. package/_internal/SwitchGroup.js +182 -4
  96. package/_internal/Text.d2.ts +9 -0
  97. package/_internal/Text2.js +45 -3
  98. package/_internal/TextArea.d.ts +34 -0
  99. package/_internal/TextArea.js +430 -20
  100. package/_internal/TextField.d.ts +29 -0
  101. package/_internal/TextField.js +463 -19
  102. package/_internal/alert.d.ts +5 -0
  103. package/_internal/alert.js +2 -5
  104. package/_internal/app-bar.d.ts +8 -0
  105. package/_internal/app-bar.js +2 -8
  106. package/_internal/app-container.d.ts +9 -0
  107. package/_internal/app-container.js +3 -9
  108. package/_internal/app-content.d.ts +5 -0
  109. package/_internal/app-content.js +2 -5
  110. package/_internal/app-side-panel.d.ts +11 -0
  111. package/_internal/app-side-panel.js +3 -11
  112. package/_internal/badge.d.ts +6 -0
  113. package/_internal/badge.js +2 -6
  114. package/_internal/breadcrumb-item.d.ts +5 -0
  115. package/_internal/breadcrumb-item.js +1 -4
  116. package/_internal/breadcrumbs.d.ts +6 -0
  117. package/_internal/breadcrumbs.js +2 -6
  118. package/_internal/button-group.d.ts +5 -0
  119. package/_internal/button-group.js +2 -5
  120. package/_internal/button-link.d.ts +8 -0
  121. package/_internal/button-link.js +2 -8
  122. package/_internal/button.d.ts +8 -0
  123. package/_internal/button.js +3 -8
  124. package/_internal/card-actions.d.ts +5 -0
  125. package/_internal/card-actions.js +1 -4
  126. package/_internal/card-body.d.ts +5 -0
  127. package/_internal/card-body.js +1 -4
  128. package/_internal/card-header.d.ts +9 -0
  129. package/_internal/card-header.js +1 -8
  130. package/_internal/card.d.ts +11 -0
  131. package/_internal/card.js +2 -11
  132. package/_internal/checkbox-group.d.ts +6 -0
  133. package/_internal/checkbox-group.js +2 -6
  134. package/_internal/checkbox.d.ts +6 -0
  135. package/_internal/checkbox.js +2 -6
  136. package/_internal/colors.d.ts +102 -0
  137. package/_internal/colors.js +87 -91
  138. package/_internal/conditional-wrapper.d.ts +2 -0
  139. package/_internal/conditional-wrapper.js +2 -2
  140. package/_internal/detailed-card-collapsible-section-items.d.ts +4 -0
  141. package/_internal/detailed-card-collapsible-section-items.js +1 -3
  142. package/_internal/detailed-card-header.d.ts +8 -0
  143. package/_internal/detailed-card-header.js +1 -7
  144. package/_internal/detailed-card-section-item.d.ts +11 -0
  145. package/_internal/detailed-card-section-item.js +1 -10
  146. package/_internal/detailed-card-section.d.ts +7 -0
  147. package/_internal/detailed-card-section.js +1 -6
  148. package/_internal/detailed-card.d.ts +16 -0
  149. package/_internal/detailed-card.js +2 -16
  150. package/_internal/flexbox.d.ts +5 -0
  151. package/_internal/flexbox.js +2 -5
  152. package/_internal/focus-within-group.d.ts +3 -0
  153. package/_internal/focus-within-group.js +3 -3
  154. package/_internal/fonts.d.ts +12 -0
  155. package/_internal/fonts.js +4 -6
  156. package/_internal/gradient-border.d.ts +19 -0
  157. package/_internal/gradient-border.js +35 -16
  158. package/_internal/grid-item.d.ts +5 -0
  159. package/_internal/grid-item.js +1 -4
  160. package/_internal/grid.d.ts +6 -0
  161. package/_internal/grid.js +2 -6
  162. package/_internal/heading.d.ts +7 -0
  163. package/_internal/heading.js +2 -6
  164. package/_internal/icon-button-link.d.ts +8 -0
  165. package/_internal/icon-button-link.js +2 -8
  166. package/_internal/icon-button.d.ts +7 -0
  167. package/_internal/icon-button.js +2 -6
  168. package/_internal/icon.d.ts +6 -0
  169. package/_internal/icon.js +2 -6
  170. package/_internal/item.d.ts +8 -0
  171. package/_internal/item.js +2 -8
  172. package/_internal/link-button.d.ts +8 -0
  173. package/_internal/link-button.js +2 -8
  174. package/_internal/link.d.ts +8 -0
  175. package/_internal/link.js +3 -8
  176. package/_internal/listbox.d.ts +6 -0
  177. package/_internal/listbox.js +3 -6
  178. package/_internal/number-field.d.ts +9 -0
  179. package/_internal/number-field.js +2 -9
  180. package/_internal/number.d.ts +7 -0
  181. package/_internal/number.js +2 -7
  182. package/_internal/pill.d.ts +6 -0
  183. package/_internal/pill.js +2 -6
  184. package/_internal/progress-bar.d.ts +5 -0
  185. package/_internal/progress-bar.js +2 -5
  186. package/_internal/radio-group.d.ts +6 -0
  187. package/_internal/radio-group.js +2 -6
  188. package/_internal/radio.d.ts +6 -0
  189. package/_internal/radio.js +2 -6
  190. package/_internal/shared.d.ts +5 -0
  191. package/_internal/shared.js +2 -5
  192. package/_internal/shield.d.ts +6 -0
  193. package/_internal/shield.js +2 -6
  194. package/_internal/side-navigation-menu-bar.d.ts +9 -0
  195. package/_internal/side-navigation-menu-bar.js +3 -9
  196. package/_internal/side-navigation-menu-item.d.ts +8 -0
  197. package/_internal/side-navigation-menu-item.js +2 -8
  198. package/_internal/side-navigation-menu.d.ts +8 -0
  199. package/_internal/side-navigation-menu.js +2 -8
  200. package/_internal/skeleton-circle.d.ts +7 -0
  201. package/_internal/skeleton-circle.js +1 -6
  202. package/_internal/skeleton-text.d.ts +7 -0
  203. package/_internal/skeleton-text.js +2 -6
  204. package/_internal/skeleton.d.ts +8 -0
  205. package/_internal/skeleton.js +1 -7
  206. package/_internal/spinner.d.ts +5 -0
  207. package/_internal/spinner.js +2 -5
  208. package/_internal/styles.d.ts +17 -0
  209. package/_internal/styles.d2.ts +283 -0
  210. package/_internal/styles.js +235 -17
  211. package/_internal/styles2.js +44 -280
  212. package/_internal/switch-group.d.ts +6 -0
  213. package/_internal/switch-group.js +2 -6
  214. package/_internal/switch.d.ts +6 -0
  215. package/_internal/switch.js +2 -6
  216. package/_internal/text-area.d.ts +9 -0
  217. package/_internal/text-area.js +2 -9
  218. package/_internal/text-field.d.ts +10 -0
  219. package/_internal/text-field.js +2 -10
  220. package/_internal/text.d.ts +7 -0
  221. package/_internal/text.js +2 -6
  222. package/_internal/theme.d.ts +4 -0
  223. package/_internal/theme.js +1 -3
  224. package/_internal/types.d.ts +39 -0
  225. package/_internal/{types10.js → types.d10.ts} +1 -1
  226. package/_internal/{types11.js → types.d11.ts} +1 -1
  227. package/_internal/{types12.js → types.d12.ts} +4 -4
  228. package/_internal/{types14.js → types.d14.ts} +1 -1
  229. package/_internal/{types15.js → types.d15.ts} +1 -1
  230. package/_internal/{types16.js → types.d16.ts} +2 -2
  231. package/_internal/{types17.js → types.d17.ts} +1 -1
  232. package/_internal/{types18.js → types.d18.ts} +2 -2
  233. package/_internal/{types19.js → types.d19.ts} +2 -2
  234. package/_internal/types.d2.ts +37 -0
  235. package/_internal/{types20.js → types.d20.ts} +1 -1
  236. package/_internal/{types21.js → types.d21.ts} +1 -1
  237. package/_internal/{types22.js → types.d22.ts} +1 -1
  238. package/_internal/{types23.js → types.d23.ts} +2 -2
  239. package/_internal/{types24.js → types.d24.ts} +1 -1
  240. package/_internal/{types25.js → types.d25.ts} +1 -1
  241. package/_internal/{types26.js → types.d26.ts} +1 -1
  242. package/_internal/{types27.js → types.d27.ts} +1 -1
  243. package/_internal/{types28.js → types.d28.ts} +1 -1
  244. package/_internal/{types29.js → types.d29.ts} +4 -4
  245. package/_internal/types.d3.ts +23 -0
  246. package/_internal/{types4.js → types.d4.ts} +2 -2
  247. package/_internal/{types5.js → types.d5.ts} +1 -1
  248. package/_internal/{types6.js → types.d6.ts} +1 -1
  249. package/_internal/{types7.js → types.d7.ts} +3 -3
  250. package/_internal/{types8.js → types.d8.ts} +1 -1
  251. package/_internal/types.js +7 -31
  252. package/_internal/types2.js +18 -29
  253. package/_internal/types3.js +15 -18
  254. package/_internal/useAppSidePanel.d.ts +12 -0
  255. package/_internal/useAppSidePanel.js +331 -6
  256. package/_internal/useFocusOnList.d.ts +83 -0
  257. package/_internal/useFocusOnList.js +502 -44
  258. package/_internal/useListboxItem.d.ts +32 -0
  259. package/_internal/useListboxItem.js +120 -23
  260. package/_internal/useSideNavigationMenuBar.d.ts +9 -0
  261. package/_internal/useSideNavigationMenuBar.js +371 -7
  262. package/_internal/useTheme.d.ts +13 -0
  263. package/_internal/useTheme.js +10 -8
  264. package/index.d.ts +1738 -0
  265. package/index.js +523 -1674
  266. package/package.json +2 -2
  267. /package/_internal/{helpers.js → helpers.d.ts} +0 -0
  268. /package/_internal/{types13.js → types.d13.ts} +0 -0
  269. /package/_internal/{types9.js → types.d9.ts} +0 -0
@@ -1,20 +1,16 @@
1
- import { b as IconButtonProps } from './types16.js';
2
- import { L as LinkProps } from './types18.js';
3
- import { C as Comp } from './helpers.js';
1
+ import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
2
+ import React__default, { forwardRef } from 'react';
3
+ import classNames from 'classnames';
4
+ import { StyledGradientBorder } from './gradient-border.js';
5
+ import { I as IconButtonVariant, S as StyledIconButton } from './styles2.js';
6
+ import { u as useTheme } from './useTheme.js';
7
+ import { B as ButtonsColorPalette } from './colors.js';
8
+ import { C as ConditionalWrapper } from './ConditionalWrapper.js';
9
+ import { a as Icon } from './Icon2.js';
4
10
 
5
- /**
6
- * Component props.
7
- */
8
- interface IconButtonLinkProps extends Omit<LinkProps, 'color'>, Pick<IconButtonProps, 'icon' | 'iconProps' | 'color' | 'isActive' | 'isDisabled' | 'isHovered' | 'variant' | 'theme'> {
9
- }
10
- type StyledIconButtonLinkProps = Omit<IconButtonLinkProps, 'isActive' | 'isDisabled' | 'variant' | 'color' | 'size'> & {
11
- $isActive: IconButtonLinkProps['isActive'];
12
- $isDisabled: IconButtonLinkProps['isDisabled'];
13
- $isHovered: IconButtonLinkProps['isHovered'];
14
- $variant: IconButtonLinkProps['variant'];
15
- $theme: IconButtonLinkProps['theme'];
16
- $color: IconButtonLinkProps['color'];
17
- };
11
+ const _excluded = ["as", "className", "color", "href", "icon", "iconProps", "isActive", "isDisabled", "isHovered", "target", "theme", "variant"];
12
+ const COMPONENT_NAME = 'IconButtonLink';
13
+ const CLASSNAME = 'redsift-icon-button-link';
18
14
 
19
15
  /**
20
16
  * The IconButtonLink is a semantic link that looks like an icon button.
@@ -23,6 +19,57 @@ type StyledIconButtonLinkProps = Omit<IconButtonLinkProps, 'isActive' | 'isDisab
23
19
  * For a semantic link that looks like a link, please use the Link component.
24
20
  * For a semantic button that looks like a link, please use the LinkButton component.
25
21
  */
26
- declare const IconButtonLink: Comp<IconButtonLinkProps, HTMLAnchorElement>;
22
+ const IconButtonLink = /*#__PURE__*/forwardRef((props, ref) => {
23
+ const {
24
+ as,
25
+ className,
26
+ color: propsColor,
27
+ href,
28
+ icon,
29
+ iconProps,
30
+ isActive,
31
+ isDisabled,
32
+ isHovered,
33
+ target,
34
+ theme: propsTheme,
35
+ variant: propsVariant
36
+ } = props,
37
+ forwardedProps = _objectWithoutProperties(props, _excluded);
38
+ const theme = useTheme(propsTheme);
39
+ const color = Object.values(ButtonsColorPalette).includes(propsColor) ? propsColor : 'primary';
40
+ const variant = Object.values(IconButtonVariant).includes(propsVariant) ? propsVariant : 'unstyled';
41
+ const isGradient = color === ButtonsColorPalette.radar;
42
+ return /*#__PURE__*/React__default.createElement(ConditionalWrapper, {
43
+ condition: isGradient && variant === IconButtonVariant.secondary,
44
+ wrapper: children => /*#__PURE__*/React__default.createElement(StyledGradientBorder, {
45
+ $color: color,
46
+ $isActive: isActive,
47
+ $isDisabled: isDisabled,
48
+ $isHovered: isHovered,
49
+ $theme: theme
50
+ }, children)
51
+ }, /*#__PURE__*/React__default.createElement(StyledIconButton, _extends({
52
+ as: as || 'a',
53
+ role: "link",
54
+ tabIndex: !isDisabled ? 0 : undefined
55
+ }, forwardedProps, {
56
+ $color: color,
57
+ $isActive: isActive,
58
+ $isDisabled: isDisabled,
59
+ $isGradient: isGradient,
60
+ $isHovered: isHovered,
61
+ $theme: theme,
62
+ $variant: variant,
63
+ className: classNames(IconButtonLink.className, className),
64
+ href: !isDisabled ? href : undefined,
65
+ ref: ref,
66
+ target: target
67
+ }), /*#__PURE__*/React__default.createElement(Icon, _extends({}, iconProps, {
68
+ icon: icon
69
+ }))));
70
+ });
71
+ IconButtonLink.className = CLASSNAME;
72
+ IconButtonLink.displayName = COMPONENT_NAME;
27
73
 
28
- export { IconButtonLinkProps as I, StyledIconButtonLinkProps as S, IconButtonLink as a };
74
+ export { IconButtonLink as I };
75
+ //# sourceMappingURL=IconButtonLink.js.map
@@ -0,0 +1,82 @@
1
+ import * as styled_components from 'styled-components';
2
+ import { B as ButtonsColorPalette, T as Theme } from './colors.js';
3
+ import { ComponentProps, MouseEvent } from 'react';
4
+ import { d as ListboxContextProps } from './types.d19.ts';
5
+ import { C as ContainerProps } from './styles.d2.ts';
6
+ import { C as Comp } from './helpers.js';
7
+
8
+ /**
9
+ * Component color.
10
+ */
11
+ type ItemColor = ButtonsColorPalette;
12
+ /**
13
+ * Component props.
14
+ */
15
+ interface ItemProps extends Omit<ComponentProps<any>, 'onClick'>, ContainerProps {
16
+ /** Border radius, only if hasBorder is true. */
17
+ borderRadius?: string;
18
+ /** Color variant. */
19
+ color?: ItemColor;
20
+ /**
21
+ * Default select status.
22
+ * Used for uncontrolled version.
23
+ */
24
+ defaultSelected?: boolean;
25
+ /** Whether the component is active or not. */
26
+ isActive?: boolean;
27
+ /** Whether the component is disabled or not. */
28
+ isDisabled?: boolean;
29
+ /** Whether the component is focused or not. */
30
+ isFocused?: boolean;
31
+ /** Whether the component is hovered or not. */
32
+ isHovered?: boolean;
33
+ /** Whether the Item has borders or not. */
34
+ hasBorder?: boolean;
35
+ /** Whether the Item is selectable within a group of multiple selectable Items. */
36
+ hasCheckbox?: boolean;
37
+ /**
38
+ * Whether the component is selected or not.
39
+ * Used for controlled version.
40
+ */
41
+ isSelected?: boolean;
42
+ /** Method to handle component change. */
43
+ onClick?: (isSelected: boolean, value?: string, event?: MouseEvent<HTMLElement>, state?: ListboxContextProps) => void | ComponentProps<'div'>['onClick'];
44
+ /** Theme. */
45
+ theme?: Theme;
46
+ /** Value. */
47
+ value?: string;
48
+ }
49
+ type StyledItemProps = Omit<ItemProps, 'color' | 'onClick' | 'value'> & {
50
+ $borderRadius: ItemProps['borderRadius'];
51
+ $color: ItemProps['color'];
52
+ $hasBorder: ItemProps['hasBorder'];
53
+ $hasCheckbox: ItemProps['hasCheckbox'];
54
+ $isActive: ItemProps['isActive'];
55
+ $isDisabled: ItemProps['isDisabled'];
56
+ $isGradient: boolean;
57
+ $isHovered: ItemProps['isHovered'];
58
+ $theme: ItemProps['theme'];
59
+ };
60
+
61
+ /**
62
+ * Component style.
63
+ */
64
+ declare const StyledItem: styled_components.StyledComponent<"div", any, Omit<ItemProps, "color" | "onClick" | "value"> & {
65
+ $borderRadius: string | undefined;
66
+ $color: string | undefined;
67
+ $hasBorder: boolean | undefined;
68
+ $hasCheckbox: boolean | undefined;
69
+ $isActive: boolean | undefined;
70
+ $isDisabled: boolean | undefined;
71
+ $isGradient: boolean;
72
+ $isHovered: boolean | undefined;
73
+ $theme: Theme | undefined;
74
+ }, never>;
75
+
76
+ declare const RenderedListboxItem: Comp<Omit<ItemProps, 'value'> & Required<Pick<ItemProps, 'value'>>, HTMLElement>;
77
+ /**
78
+ * The Item component.
79
+ */
80
+ declare const Item: Comp<ItemProps, HTMLElement>;
81
+
82
+ export { ItemColor as I, RenderedListboxItem as R, StyledItemProps as S, ItemProps as a, StyledItem as b, Item as c };
@@ -1,82 +1,399 @@
1
- import * as styled_components from 'styled-components';
2
- import { B as ButtonsColorPalette, T as Theme } from './colors.js';
3
- import { ComponentProps, MouseEvent } from 'react';
4
- import { d as ListboxContextProps } from './types19.js';
5
- import { C as ContainerProps } from './styles2.js';
6
- import { C as Comp } from './helpers.js';
1
+ import { b as _objectWithoutProperties, c as _extends } from './_rollupPluginBabelHelpers.js';
2
+ import React__default, { useCallback, useEffect, forwardRef, useRef, useContext } from 'react';
3
+ import classNames from 'classnames';
4
+ import styled, { css } from 'styled-components';
5
+ import { j as baseContainer } from './styles4.js';
6
+ import { u as useListboxItem } from './useListboxItem.js';
7
+ import { c as useFocusOnListItem, b as FocusWithinGroupContext } from './useFocusOnListItem.js';
8
+ import { mdiCheckboxMarked, mdiCheckboxBlankOutline } from '@redsift/icons';
9
+ import { StyledGradientBorder } from './gradient-border.js';
10
+ import { u as useTheme } from './useTheme.js';
11
+ import { B as ButtonsColorPalette } from './colors.js';
12
+ import { C as ConditionalWrapper } from './ConditionalWrapper.js';
13
+ import { F as Flexbox } from './Flexbox2.js';
14
+ import { a as Icon } from './Icon2.js';
15
+ import { T as Text } from './Text2.js';
16
+ import { u as useId } from './useId.js';
17
+ import { i as isComponent } from './isComponent.js';
7
18
 
8
19
  /**
9
- * Component color.
10
- */
11
- type ItemColor = ButtonsColorPalette;
12
- /**
13
- * Component props.
20
+ * Component style.
14
21
  */
15
- interface ItemProps extends Omit<ComponentProps<any>, 'onClick'>, ContainerProps {
16
- /** Border radius, only if hasBorder is true. */
17
- borderRadius?: string;
18
- /** Color variant. */
19
- color?: ItemColor;
20
- /**
21
- * Default select status.
22
- * Used for uncontrolled version.
23
- */
24
- defaultSelected?: boolean;
25
- /** Whether the component is active or not. */
26
- isActive?: boolean;
27
- /** Whether the component is disabled or not. */
28
- isDisabled?: boolean;
29
- /** Whether the component is focused or not. */
30
- isFocused?: boolean;
31
- /** Whether the component is hovered or not. */
32
- isHovered?: boolean;
33
- /** Whether the Item has borders or not. */
34
- hasBorder?: boolean;
35
- /** Whether the Item is selectable within a group of multiple selectable Items. */
36
- hasCheckbox?: boolean;
37
- /**
38
- * Whether the component is selected or not.
39
- * Used for controlled version.
40
- */
41
- isSelected?: boolean;
42
- /** Method to handle component change. */
43
- onClick?: (isSelected: boolean, value?: string, event?: MouseEvent<HTMLElement>, state?: ListboxContextProps) => void | ComponentProps<'div'>['onClick'];
44
- /** Theme. */
45
- theme?: Theme;
46
- /** Value. */
47
- value?: string;
22
+ const StyledItem = styled.div`
23
+ min-height: 36px;
24
+ position: relative;
25
+ width: 100%;
26
+ padding: 8px 16px;
27
+
28
+ ${baseContainer}
29
+
30
+ align-items: center;
31
+ background: none;
32
+ border: none;
33
+ box-sizing: border-box;
34
+ display: inline-flex;
35
+
36
+ > a {
37
+ display: inline-flex;
38
+ align-items: center;
39
+ text-decoration: none;
40
+ color: inherit;
41
+ }
42
+
43
+ ${_ref => {
44
+ let {
45
+ $color,
46
+ $isActive,
47
+ $isDisabled,
48
+ $isGradient,
49
+ $isHovered,
50
+ $hasBorder,
51
+ $theme
52
+ } = _ref;
53
+ return css`
54
+ ${!$isGradient ? css`
55
+ background-color: var(
56
+ --redsift-color-${$theme}-components-buttons-secondary-button-${$isDisabled ? 'grey' : $color}-background-${$isActive ? 'active' : $isHovered || $isDisabled ? 'hover' : 'default'}
57
+ );
58
+ ` : css`
59
+ background: var(
60
+ --redsift-color-${$theme}-components-buttons-secondary-button-${$isDisabled ? 'grey' : $color}-background-${$isActive ? 'active' : $isHovered || $isDisabled ? 'hover' : 'default'}
61
+ );
62
+ `}
63
+
64
+ ${$hasBorder ? css`
65
+ border: 1px solid
66
+ var(
67
+ --redsift-color-${$theme}-components-buttons-secondary-button-${$isDisabled ? 'grey' : $color}-text-${$isActive ? 'active' : $isHovered || $isDisabled ? 'hover' : 'default'}
68
+ );
69
+ ` : ''}
70
+ `;
71
+ }}
72
+
73
+ &:hover {
74
+ outline: none;
75
+
76
+ ${_ref2 => {
77
+ let {
78
+ $color,
79
+ $isDisabled,
80
+ $isGradient,
81
+ $hasBorder,
82
+ $theme
83
+ } = _ref2;
84
+ return css`
85
+ cursor: ${$isDisabled ? 'default' : 'pointer'};
86
+
87
+ ${!$isDisabled ? css`
88
+ ${!$isGradient ? css`
89
+ background-color: var(
90
+ --redsift-color-${$theme}-components-buttons-secondary-button-${$color}-background-hover
91
+ );
92
+
93
+ ${$hasBorder ? css`
94
+ border: 1px solid
95
+ var(--redsift-color-${$theme}-components-buttons-secondary-button-${$color}-text-hover);
96
+ ` : ''}
97
+ ` : css`
98
+ background: var(
99
+ --redsift-color-${$theme}-components-buttons-secondary-button-${$color}-background-hover
100
+ );
101
+ `}
102
+ ` : ''}
103
+ `;
104
+ }};
105
+ }
106
+
107
+ &:active {
108
+ outline: none;
109
+
110
+ ${_ref3 => {
111
+ let {
112
+ $color,
113
+ $hasBorder,
114
+ $isHovered,
115
+ $isDisabled,
116
+ $isGradient,
117
+ $theme
118
+ } = _ref3;
119
+ return css`
120
+ ${!$isDisabled ? css`
121
+ ${!$isGradient ? css`
122
+ background-color: var(
123
+ --redsift-color-${$theme}-components-buttons-secondary-button-${$isDisabled ? 'grey' : $color}-background-${$isHovered ? 'hover' : 'active'}
124
+ );
125
+
126
+ ${$hasBorder ? css`
127
+ border: 1px solid
128
+ var(
129
+ --redsift-color-${$theme}-components-buttons-secondary-button-${$isDisabled ? 'grey' : $color}-text-${$isHovered ? 'hover' : 'active'}
130
+ );
131
+ ` : ''}
132
+ ` : css`
133
+ background: var(
134
+ --redsift-color-${$theme}-components-buttons-secondary-button-${$isDisabled ? 'grey' : $color}-background-${$isHovered ? 'hover' : 'active'}
135
+ );
136
+ `}
137
+ ` : ''}
138
+ `;
139
+ }};
140
+ }
141
+ `;
142
+
143
+ function useMenuItem(props) {
144
+ const {
145
+ domElementRef,
146
+ id,
147
+ isDisabled,
148
+ onClick,
149
+ isLinkMenuItem,
150
+ linkRef
151
+ } = props;
152
+ const {
153
+ tabIndex,
154
+ isFocused,
155
+ handleKeyDown: handleFocusKeyDown,
156
+ handleClick: handleFocusClick
157
+ } = useFocusOnListItem({
158
+ domElementRef,
159
+ isDisabled: isDisabled,
160
+ id
161
+ });
162
+ const handleKeyDown = useCallback(event => {
163
+ const code = event.code;
164
+ if (code === 'Enter' || code === 'Space') {
165
+ if (isLinkMenuItem) {
166
+ var _linkRef$current;
167
+ linkRef === null || linkRef === void 0 ? void 0 : (_linkRef$current = linkRef.current) === null || _linkRef$current === void 0 ? void 0 : _linkRef$current.click();
168
+ } else {
169
+ onClick === null || onClick === void 0 ? void 0 : onClick();
170
+ }
171
+ }
172
+ handleFocusKeyDown(event);
173
+ }, []);
174
+ const handleClick = useCallback(() => {
175
+ handleFocusClick();
176
+ onClick === null || onClick === void 0 ? void 0 : onClick();
177
+ }, []);
178
+ useEffect(() => {
179
+ if (isFocused && domElementRef.current) {
180
+ var _current;
181
+ (_current = domElementRef.current) === null || _current === void 0 ? void 0 : _current.focus();
182
+ }
183
+ }, [isFocused]);
184
+ return {
185
+ tabIndex,
186
+ isFocused,
187
+ isDisabled,
188
+ handleKeyDown,
189
+ handleClick
190
+ };
48
191
  }
49
- type StyledItemProps = Omit<ItemProps, 'color' | 'onClick' | 'value'> & {
50
- $borderRadius: ItemProps['borderRadius'];
51
- $color: ItemProps['color'];
52
- $hasBorder: ItemProps['hasBorder'];
53
- $hasCheckbox: ItemProps['hasCheckbox'];
54
- $isActive: ItemProps['isActive'];
55
- $isDisabled: ItemProps['isDisabled'];
56
- $isGradient: boolean;
57
- $isHovered: ItemProps['isHovered'];
58
- $theme: ItemProps['theme'];
59
- };
60
192
 
61
- /**
62
- * Component style.
63
- */
64
- declare const StyledItem: styled_components.StyledComponent<"div", any, Omit<ItemProps, "color" | "onClick" | "value"> & {
65
- $borderRadius: string | undefined;
66
- $color: string | undefined;
67
- $hasBorder: boolean | undefined;
68
- $hasCheckbox: boolean | undefined;
69
- $isActive: boolean | undefined;
70
- $isDisabled: boolean | undefined;
71
- $isGradient: boolean;
72
- $isHovered: boolean | undefined;
73
- $theme: Theme | undefined;
74
- }, never>;
75
-
76
- declare const RenderedListboxItem: Comp<Omit<ItemProps, 'value'> & Required<Pick<ItemProps, 'value'>>, HTMLElement>;
193
+ const _excluded = ["borderRadius", "children", "className", "color", "defaultSelected", "id", "isActive", "isDisabled", "isHovered", "isSelected", "hasBorder", "hasCheckbox", "theme", "value"],
194
+ _excluded2 = ["borderRadius", "children", "className", "color", "hasBorder", "id", "isActive", "isDisabled", "isHovered", "theme", "onClick"];
195
+ const COMPONENT_NAME = 'Item';
196
+ const CLASSNAME = 'redsift-item';
197
+ const RenderedListboxItem = /*#__PURE__*/forwardRef((props, ref) => {
198
+ const {
199
+ borderRadius = '0',
200
+ children,
201
+ className,
202
+ color: propsColor,
203
+ defaultSelected,
204
+ id: propsId,
205
+ isActive,
206
+ isDisabled: propsIsDisabled,
207
+ isHovered,
208
+ isSelected: propsIsSelected,
209
+ hasBorder,
210
+ hasCheckbox,
211
+ theme: propsTheme,
212
+ value
213
+ } = props,
214
+ forwardedProps = _objectWithoutProperties(props, _excluded);
215
+ const id = propsId !== null && propsId !== void 0 ? propsId : value;
216
+ const _ref = useRef();
217
+ const divRef = ref !== null && ref !== void 0 ? ref : _ref;
218
+ const {
219
+ tabIndex,
220
+ isFocused,
221
+ isSelected,
222
+ isDisabled,
223
+ handleKeyDown,
224
+ handleClick
225
+ } = useListboxItem({
226
+ domElementRef: divRef,
227
+ value,
228
+ id,
229
+ isDisabled: propsIsDisabled,
230
+ propsIsSelected: propsIsSelected !== null && propsIsSelected !== void 0 ? propsIsSelected : defaultSelected
231
+ });
232
+ const theme = useTheme(propsTheme);
233
+ const color = Object.values(ButtonsColorPalette).includes(propsColor) ? propsColor : 'primary';
234
+ const isGradient = color === ButtonsColorPalette.radar;
235
+ return /*#__PURE__*/React__default.createElement(ConditionalWrapper, {
236
+ condition: isGradient,
237
+ wrapper: children => /*#__PURE__*/React__default.createElement(StyledGradientBorder, {
238
+ $borderRadius: borderRadius,
239
+ $color: color,
240
+ $isActive: isActive,
241
+ $isDisabled: isDisabled,
242
+ $isHovered: isHovered,
243
+ $theme: theme,
244
+ width: "auto"
245
+ }, children)
246
+ }, /*#__PURE__*/React__default.createElement(StyledItem, _extends({
247
+ role: "option"
248
+ }, forwardedProps, {
249
+ id: id,
250
+ $borderRadius: borderRadius,
251
+ $color: color,
252
+ $hasBorder: hasBorder,
253
+ $hasCheckbox: hasCheckbox,
254
+ $isActive: isActive || isSelected,
255
+ $isDisabled: isDisabled,
256
+ $isGradient: isGradient,
257
+ $isHovered: isHovered || isFocused,
258
+ $theme: theme,
259
+ "aria-selected": isSelected,
260
+ "aria-disabled": isDisabled,
261
+ className: classNames(Item.className, className),
262
+ onClick: isDisabled ? undefined : handleClick,
263
+ ref: divRef,
264
+ onKeyDown: handleKeyDown,
265
+ tabIndex: tabIndex
266
+ }), hasCheckbox ? /*#__PURE__*/React__default.createElement(Flexbox, null, isSelected ? /*#__PURE__*/React__default.createElement(Icon, {
267
+ color: isDisabled ? 'grey' : color,
268
+ icon: mdiCheckboxMarked
269
+ }) : /*#__PURE__*/React__default.createElement(Icon, {
270
+ color: "question",
271
+ icon: mdiCheckboxBlankOutline
272
+ }), children ? children : /*#__PURE__*/React__default.createElement(Text, null, value)) : children !== null && children !== void 0 ? children : value));
273
+ });
274
+ const RenderedMenuItem = /*#__PURE__*/forwardRef((props, ref) => {
275
+ const {
276
+ borderRadius = '0',
277
+ children,
278
+ className,
279
+ color: propsColor,
280
+ hasBorder,
281
+ id: propsId,
282
+ isActive,
283
+ isDisabled: propsIsDisabled,
284
+ isHovered,
285
+ theme: propsTheme,
286
+ onClick
287
+ } = props,
288
+ forwardedProps = _objectWithoutProperties(props, _excluded2);
289
+ const [_id] = useId();
290
+ const id = propsId !== null && propsId !== void 0 ? propsId : _id;
291
+ const _ref = useRef();
292
+ const divRef = ref !== null && ref !== void 0 ? ref : _ref;
293
+ const linkRef = useRef(null);
294
+ const isLinkMenuItem = isComponent('Link')(children);
295
+ const {
296
+ tabIndex,
297
+ isFocused,
298
+ isDisabled,
299
+ handleKeyDown,
300
+ handleClick
301
+ } = useMenuItem({
302
+ domElementRef: divRef,
303
+ id,
304
+ isDisabled: propsIsDisabled,
305
+ onClick: onClick,
306
+ isLinkMenuItem,
307
+ linkRef
308
+ });
309
+ const theme = useTheme(propsTheme);
310
+ const color = Object.values(ButtonsColorPalette).includes(propsColor) ? propsColor : 'primary';
311
+ const isGradient = color === ButtonsColorPalette.radar;
312
+ return /*#__PURE__*/React__default.createElement(ConditionalWrapper, {
313
+ condition: isGradient,
314
+ wrapper: children => /*#__PURE__*/React__default.createElement(StyledGradientBorder, {
315
+ $borderRadius: borderRadius,
316
+ $color: color,
317
+ $isActive: isActive,
318
+ $isDisabled: isDisabled,
319
+ $isHovered: isHovered,
320
+ $theme: theme,
321
+ width: "auto"
322
+ }, children)
323
+ }, /*#__PURE__*/React__default.createElement(StyledItem, _extends({
324
+ as: "li",
325
+ role: isLinkMenuItem ? 'none' : 'menuitem'
326
+ }, forwardedProps, {
327
+ id: id,
328
+ $borderRadius: borderRadius,
329
+ $color: color,
330
+ $hasBorder: hasBorder,
331
+ $hasCheckbox: false,
332
+ $isActive: isActive,
333
+ $isDisabled: isDisabled,
334
+ $isGradient: isGradient,
335
+ $isHovered: isHovered || isFocused,
336
+ $theme: theme,
337
+ "aria-disabled": isDisabled,
338
+ className: classNames(Item.className, className),
339
+ onClick: isDisabled ? undefined : handleClick,
340
+ ref: divRef,
341
+ onKeyDown: handleKeyDown,
342
+ tabIndex: tabIndex
343
+ }), isLinkMenuItem ? /*#__PURE__*/React__default.cloneElement(children, {
344
+ role: 'menuitem',
345
+ ref: linkRef
346
+ }) : children));
347
+ });
348
+
77
349
  /**
78
350
  * The Item component.
79
351
  */
80
- declare const Item: Comp<ItemProps, HTMLElement>;
352
+ const Item = /*#__PURE__*/forwardRef((props, ref) => {
353
+ const {
354
+ value
355
+ } = props;
356
+ const focusContext = useContext(FocusWithinGroupContext);
357
+ const isListbox = focusContext.state.listRole === 'listbox';
358
+ if (!focusContext.state.filter) {
359
+ return isListbox ? /*#__PURE__*/React__default.createElement(RenderedListboxItem, _extends({}, props, {
360
+ value: props.value,
361
+ ref: ref
362
+ })) : /*#__PURE__*/React__default.createElement(RenderedMenuItem, _extends({}, props, {
363
+ ref: ref
364
+ }));
365
+ }
366
+ const {
367
+ value: filterValue,
368
+ type,
369
+ caseSensitive
370
+ } = focusContext.state.filter;
371
+ if (!filterValue) {
372
+ return isListbox ? /*#__PURE__*/React__default.createElement(RenderedListboxItem, _extends({}, props, {
373
+ value: props.value,
374
+ ref: ref
375
+ })) : /*#__PURE__*/React__default.createElement(RenderedMenuItem, _extends({}, props, {
376
+ ref: ref
377
+ }));
378
+ } else if (caseSensitive && (type === 'startsWith' && value.startsWith(filterValue) || type === 'contains' && value.includes(filterValue) || type === 'endsWith' && value.endsWith(filterValue))) {
379
+ return isListbox ? /*#__PURE__*/React__default.createElement(RenderedListboxItem, _extends({}, props, {
380
+ value: props.value,
381
+ ref: ref
382
+ })) : /*#__PURE__*/React__default.createElement(RenderedMenuItem, _extends({}, props, {
383
+ ref: ref
384
+ }));
385
+ } else if (!caseSensitive && (type === 'startsWith' && value.toLowerCase().startsWith(filterValue.toLowerCase()) || type === 'contains' && value.toLowerCase().includes(filterValue.toLowerCase()) || type === 'endsWith' && value.toLowerCase().endsWith(filterValue.toLowerCase()))) {
386
+ return isListbox ? /*#__PURE__*/React__default.createElement(RenderedListboxItem, _extends({}, props, {
387
+ value: props.value,
388
+ ref: ref
389
+ })) : /*#__PURE__*/React__default.createElement(RenderedMenuItem, _extends({}, props, {
390
+ ref: ref
391
+ }));
392
+ }
393
+ return null;
394
+ });
395
+ Item.className = CLASSNAME;
396
+ Item.displayName = COMPONENT_NAME;
81
397
 
82
- export { ItemColor as I, RenderedListboxItem as R, StyledItemProps as S, ItemProps as a, StyledItem as b, Item as c };
398
+ export { Item as I, RenderedListboxItem as R, StyledItem as S };
399
+ //# sourceMappingURL=Item2.js.map
@@ -0,0 +1,26 @@
1
+ import * as styled_components from 'styled-components';
2
+ import { L as LinkProps } from './types.d18.ts';
3
+ import { N as NotificationsColorPalette, d as NeutralColorPalette, T as Theme } from './colors.js';
4
+ import { C as Comp } from './helpers.js';
5
+
6
+ /**
7
+ * Component style.
8
+ */
9
+ declare const StyledLink: styled_components.StyledComponent<"a", any, Omit<LinkProps, "isDisabled"> & {
10
+ $isDisabled: boolean | undefined;
11
+ $color: (string & {}) | "radar" | NotificationsColorPalette | NeutralColorPalette | undefined;
12
+ $theme: Theme | undefined;
13
+ $hasIcons: boolean;
14
+ }, never>;
15
+
16
+ /**
17
+ * The Link is a semantic link that looks like a link.
18
+ * Shoud be used for internal and external navigation only.
19
+ *
20
+ * For a semantic link that looks like a button, please use the ButtonLink component.
21
+ * For a semantic button that looks like a button, please use the Button component.
22
+ * For a semantic button that looks like a link, please use the LinkButton component.
23
+ */
24
+ declare const Link: Comp<LinkProps, HTMLAnchorElement>;
25
+
26
+ export { Link as L, StyledLink as S };