@iota/apps-ui-kit 0.2.0 → 0.2.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 (212) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/index.d.ts +1622 -0
  3. package/dist/index.es.js +8805 -0
  4. package/dist/index.es.js.map +1 -0
  5. package/dist/index.umd.js +198 -0
  6. package/dist/index.umd.js.map +1 -0
  7. package/dist/style.css +1 -0
  8. package/package.json +5 -2
  9. package/src/lib/components/atoms/badge/Badge.tsx +37 -0
  10. package/src/lib/components/atoms/badge/badge.classes.ts +24 -0
  11. package/src/lib/components/atoms/badge/badge.enums.ts +8 -0
  12. package/src/lib/components/atoms/badge/index.ts +6 -0
  13. package/src/lib/components/atoms/button/Button.tsx +99 -0
  14. package/src/lib/components/atoms/button/button-variants/ButtonPill.tsx +23 -0
  15. package/src/lib/components/atoms/button/button-variants/ButtonUnstyled.tsx +27 -0
  16. package/src/lib/components/atoms/button/button-variants/buttonVariants.types.ts +11 -0
  17. package/src/lib/components/atoms/button/button-variants/index.ts +5 -0
  18. package/src/lib/components/atoms/button/button.classes.ts +53 -0
  19. package/src/lib/components/atoms/button/button.enums.ts +21 -0
  20. package/src/lib/components/atoms/button/index.ts +7 -0
  21. package/src/lib/components/atoms/button-segment/ButtonSegment.tsx +86 -0
  22. package/src/lib/components/atoms/button-segment/buttonSegment.classes.ts +45 -0
  23. package/src/lib/components/atoms/button-segment/buttonSegment.enums.ts +7 -0
  24. package/src/lib/components/atoms/button-segment/index.ts +5 -0
  25. package/src/lib/components/atoms/checkbox/Checkbox.tsx +114 -0
  26. package/src/lib/components/atoms/checkbox/index.ts +4 -0
  27. package/src/lib/components/atoms/divider/Divider.tsx +48 -0
  28. package/src/lib/components/atoms/divider/divider.classes.ts +11 -0
  29. package/src/lib/components/atoms/divider/divider.enums.ts +7 -0
  30. package/src/lib/components/atoms/divider/index.ts +6 -0
  31. package/src/lib/components/atoms/header/Header.tsx +73 -0
  32. package/src/lib/components/atoms/header/index.ts +4 -0
  33. package/src/lib/components/atoms/index.ts +22 -0
  34. package/src/lib/components/atoms/info-box/InfoBox.tsx +73 -0
  35. package/src/lib/components/atoms/info-box/index.ts +5 -0
  36. package/src/lib/components/atoms/info-box/infoBox.classes.ts +14 -0
  37. package/src/lib/components/atoms/info-box/infoBox.enums.ts +12 -0
  38. package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +156 -0
  39. package/src/lib/components/atoms/key-value-info/index.ts +6 -0
  40. package/src/lib/components/atoms/key-value-info/keyValue.enums.ts +7 -0
  41. package/src/lib/components/atoms/label-text/LabelText.tsx +93 -0
  42. package/src/lib/components/atoms/label-text/index.ts +5 -0
  43. package/src/lib/components/atoms/label-text/labelText.classes.ts +22 -0
  44. package/src/lib/components/atoms/label-text/labelText.enums.ts +8 -0
  45. package/src/lib/components/atoms/list-item/ListItem.tsx +89 -0
  46. package/src/lib/components/atoms/list-item/index.ts +4 -0
  47. package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +38 -0
  48. package/src/lib/components/atoms/loading-indicator/index.ts +4 -0
  49. package/src/lib/components/atoms/panel/Panel.tsx +30 -0
  50. package/src/lib/components/atoms/panel/index.ts +4 -0
  51. package/src/lib/components/atoms/placeholder/Placeholder.tsx +27 -0
  52. package/src/lib/components/atoms/placeholder/index.ts +4 -0
  53. package/src/lib/components/atoms/radio-button/RadioButton.tsx +68 -0
  54. package/src/lib/components/atoms/radio-button/index.ts +4 -0
  55. package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +28 -0
  56. package/src/lib/components/atoms/secondary-text/index.ts +4 -0
  57. package/src/lib/components/atoms/skeleton/Skeleton.tsx +47 -0
  58. package/src/lib/components/atoms/skeleton/index.ts +4 -0
  59. package/src/lib/components/atoms/snackbar/Snackbar.tsx +69 -0
  60. package/src/lib/components/atoms/snackbar/index.ts +5 -0
  61. package/src/lib/components/atoms/snackbar/snackbar.classes.ts +14 -0
  62. package/src/lib/components/atoms/snackbar/snackbar.enums.tsx +7 -0
  63. package/src/lib/components/atoms/tooltip/Tooltip.tsx +34 -0
  64. package/src/lib/components/atoms/tooltip/index.ts +5 -0
  65. package/src/lib/components/atoms/tooltip/tooltip.classes.ts +11 -0
  66. package/src/lib/components/atoms/tooltip/tooltip.enums.ts +9 -0
  67. package/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx +93 -0
  68. package/src/lib/components/atoms/visual-asset-card/index.ts +5 -0
  69. package/src/lib/components/atoms/visual-asset-card/visualAssetCard.enums.ts +7 -0
  70. package/src/lib/components/index.ts +8 -0
  71. package/src/lib/components/molecules/account/Account.tsx +174 -0
  72. package/src/lib/components/molecules/account/index.ts +4 -0
  73. package/src/lib/components/molecules/address/Address.tsx +101 -0
  74. package/src/lib/components/molecules/address/index.ts +4 -0
  75. package/src/lib/components/molecules/card/Card.tsx +70 -0
  76. package/src/lib/components/molecules/card/CardAction.tsx +78 -0
  77. package/src/lib/components/molecules/card/CardBody.tsx +61 -0
  78. package/src/lib/components/molecules/card/CardImage.tsx +43 -0
  79. package/src/lib/components/molecules/card/CardImagePlaceholder.tsx +146 -0
  80. package/src/lib/components/molecules/card/card.classes.ts +26 -0
  81. package/src/lib/components/molecules/card/card.enums.ts +25 -0
  82. package/src/lib/components/molecules/card/index.ts +8 -0
  83. package/src/lib/components/molecules/chip/Chip.tsx +105 -0
  84. package/src/lib/components/molecules/chip/chip.classes.ts +32 -0
  85. package/src/lib/components/molecules/chip/chip.enums.ts +7 -0
  86. package/src/lib/components/molecules/chip/index.ts +4 -0
  87. package/src/lib/components/molecules/display-stats/DisplayStats.tsx +104 -0
  88. package/src/lib/components/molecules/display-stats/displayStats.classes.ts +36 -0
  89. package/src/lib/components/molecules/display-stats/displayStats.enums.ts +13 -0
  90. package/src/lib/components/molecules/display-stats/index.ts +5 -0
  91. package/src/lib/components/molecules/dropdown/Dropdown.tsx +10 -0
  92. package/src/lib/components/molecules/dropdown/dropdownPosition.enums.ts +7 -0
  93. package/src/lib/components/molecules/dropdown/index.ts +5 -0
  94. package/src/lib/components/molecules/index.ts +17 -0
  95. package/src/lib/components/molecules/input/Input.tsx +245 -0
  96. package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
  97. package/src/lib/components/molecules/input/TextArea.tsx +149 -0
  98. package/src/lib/components/molecules/input/index.ts +8 -0
  99. package/src/lib/components/molecules/input/input.classes.ts +14 -0
  100. package/src/lib/components/molecules/input/input.enums.ts +14 -0
  101. package/src/lib/components/molecules/input/input.types.ts +29 -0
  102. package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +48 -0
  103. package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +65 -0
  104. package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +54 -0
  105. package/src/lib/components/molecules/navbar-item/index.ts +5 -0
  106. package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +16 -0
  107. package/src/lib/components/molecules/navbar-item/navbarItem.enums.ts +7 -0
  108. package/src/lib/components/molecules/search/Search.tsx +189 -0
  109. package/src/lib/components/molecules/search/index.ts +5 -0
  110. package/src/lib/components/molecules/search/search.classes.ts +20 -0
  111. package/src/lib/components/molecules/search/search.enums.ts +7 -0
  112. package/src/lib/components/molecules/segmented-button/SegmentedButton.tsx +34 -0
  113. package/src/lib/components/molecules/segmented-button/index.ts +6 -0
  114. package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +12 -0
  115. package/src/lib/components/molecules/segmented-button/segmentedButton.enums.ts +8 -0
  116. package/src/lib/components/molecules/select/Select.tsx +223 -0
  117. package/src/lib/components/molecules/select/index.ts +5 -0
  118. package/src/lib/components/molecules/select/select.enums.ts +7 -0
  119. package/src/lib/components/molecules/table-cell/TableCell.tsx +62 -0
  120. package/src/lib/components/molecules/table-cell/index.ts +4 -0
  121. package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +126 -0
  122. package/src/lib/components/molecules/table-header-cell/index.ts +5 -0
  123. package/src/lib/components/molecules/table-header-cell/tableHeaderCell.enums.ts +7 -0
  124. package/src/lib/components/molecules/title/Title.tsx +69 -0
  125. package/src/lib/components/molecules/title/index.ts +5 -0
  126. package/src/lib/components/molecules/title/titleClasses.constants.ts +14 -0
  127. package/src/lib/components/molecules/title/titleSize.enums.ts +7 -0
  128. package/src/lib/components/organisms/accordion/Accordion.tsx +111 -0
  129. package/src/lib/components/organisms/accordion/accordion.classes.ts +4 -0
  130. package/src/lib/components/organisms/accordion/index.ts +4 -0
  131. package/src/lib/components/organisms/dialog/Dialog.tsx +122 -0
  132. package/src/lib/components/organisms/dialog/dialog.enums.ts +7 -0
  133. package/src/lib/components/organisms/dialog/index.ts +5 -0
  134. package/src/lib/components/organisms/index.ts +7 -0
  135. package/src/lib/components/organisms/navbar/Navbar.tsx +100 -0
  136. package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +58 -0
  137. package/src/lib/components/organisms/navbar/index.ts +5 -0
  138. package/src/lib/components/organisms/table/Table.tsx +224 -0
  139. package/src/lib/components/organisms/table/TableContext.tsx +55 -0
  140. package/src/lib/components/organisms/table/index.ts +4 -0
  141. package/src/lib/constants/colors.constants.ts +127 -0
  142. package/src/lib/constants/index.ts +4 -0
  143. package/src/lib/enums/index.ts +4 -0
  144. package/src/lib/enums/screenSize.enums.ts +9 -0
  145. package/src/lib/index.ts +8 -0
  146. package/src/lib/styles/fonts.css +5 -0
  147. package/src/lib/styles/index.css +136 -0
  148. package/src/lib/tailwind/base.presets.ts +47 -0
  149. package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
  150. package/src/lib/tailwind/constants/index.ts +6 -0
  151. package/src/lib/tailwind/constants/scaling.constants.ts +41 -0
  152. package/src/lib/tailwind/constants/variableSpacing.constants.ts +66 -0
  153. package/src/lib/tailwind/helpers.ts +20 -0
  154. package/src/lib/tailwind/index.ts +5 -0
  155. package/src/lib/tailwind/responsive.presets.ts +36 -0
  156. package/src/lib/tailwind/static.presets.ts +25 -0
  157. package/src/lib/tailwind/types.ts +6 -0
  158. package/src/lib/utils/format.ts +8 -0
  159. package/src/lib/utils/index.ts +4 -0
  160. package/src/storybook/blocks/Showcase.tsx +20 -0
  161. package/src/storybook/blocks/TypeSet.tsx +34 -0
  162. package/src/storybook/blocks/TypeSetItem.tsx +74 -0
  163. package/src/storybook/blocks/index.ts +6 -0
  164. package/src/storybook/constants/index.ts +5 -0
  165. package/src/storybook/constants/typeset.constants.ts +39 -0
  166. package/src/storybook/constants/variableSpacing.constants.ts +6 -0
  167. package/src/storybook/helpers/getFontSizeLabel.ts +15 -0
  168. package/src/storybook/helpers/index.ts +4 -0
  169. package/src/storybook/stories/atoms/Badge.stories.tsx +32 -0
  170. package/src/storybook/stories/atoms/Button.stories.tsx +45 -0
  171. package/src/storybook/stories/atoms/ButtonSegment.stories.tsx +45 -0
  172. package/src/storybook/stories/atoms/Checkbox.stories.tsx +34 -0
  173. package/src/storybook/stories/atoms/CustomScrollbar.stories.tsx +22 -0
  174. package/src/storybook/stories/atoms/Divider.stories.tsx +41 -0
  175. package/src/storybook/stories/atoms/Header.stories.tsx +58 -0
  176. package/src/storybook/stories/atoms/InfoBox.stories.tsx +67 -0
  177. package/src/storybook/stories/atoms/KeyValueInfo.stories.tsx +59 -0
  178. package/src/storybook/stories/atoms/LabelText.stories.tsx +55 -0
  179. package/src/storybook/stories/atoms/ListItem.stories.tsx +41 -0
  180. package/src/storybook/stories/atoms/LoadingIndicator.stories.tsx +32 -0
  181. package/src/storybook/stories/atoms/Panel.stories.tsx +36 -0
  182. package/src/storybook/stories/atoms/Placeholder.stories.tsx +33 -0
  183. package/src/storybook/stories/atoms/RadioButton.stories.tsx +51 -0
  184. package/src/storybook/stories/atoms/Skeleton.stories.tsx +33 -0
  185. package/src/storybook/stories/atoms/Snackbar.stories.tsx +42 -0
  186. package/src/storybook/stories/atoms/Tooltip.stories.tsx +57 -0
  187. package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +56 -0
  188. package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
  189. package/src/storybook/stories/components/index.ts +4 -0
  190. package/src/storybook/stories/design-tokens/colors.stories.mdx +23 -0
  191. package/src/storybook/stories/design-tokens/icons.stories.mdx +17 -0
  192. package/src/storybook/stories/design-tokens/typeset.stories.mdx +15 -0
  193. package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +10 -0
  194. package/src/storybook/stories/molecules/Account.stories.tsx +69 -0
  195. package/src/storybook/stories/molecules/Address.stories.tsx +39 -0
  196. package/src/storybook/stories/molecules/Card.stories.tsx +115 -0
  197. package/src/storybook/stories/molecules/Chip.stories.tsx +122 -0
  198. package/src/storybook/stories/molecules/DisplayStats.stories.tsx +63 -0
  199. package/src/storybook/stories/molecules/Dropdown.stories.tsx +38 -0
  200. package/src/storybook/stories/molecules/Input.stories.tsx +161 -0
  201. package/src/storybook/stories/molecules/NavbarItem.stories.tsx +45 -0
  202. package/src/storybook/stories/molecules/Search.stories.tsx +100 -0
  203. package/src/storybook/stories/molecules/SegmentedButton.stories.tsx +107 -0
  204. package/src/storybook/stories/molecules/Select.stories.tsx +102 -0
  205. package/src/storybook/stories/molecules/TableCell.stories.tsx +46 -0
  206. package/src/storybook/stories/molecules/TableHeaderCell.stories.tsx +34 -0
  207. package/src/storybook/stories/molecules/TextArea.stories.tsx +80 -0
  208. package/src/storybook/stories/molecules/Title.stories.tsx +76 -0
  209. package/src/storybook/stories/organisms/Accordion.stories.tsx +70 -0
  210. package/src/storybook/stories/organisms/Dialog.stories.tsx +103 -0
  211. package/src/storybook/stories/organisms/Navbar.stories.tsx +77 -0
  212. package/src/storybook/stories/organisms/Table.stories.tsx +154 -0
@@ -0,0 +1,11 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { DividerType } from './divider.enums';
5
+
6
+ export const BACKGROUND_COLORS = 'bg-shader-neutral-light-8 dark:bg-shader-neutral-dark-8';
7
+
8
+ export const DIVIDER_FULL_WIDTH: Record<DividerType, string> = {
9
+ [DividerType.Horizontal]: 'w-full',
10
+ [DividerType.Vertical]: 'h-full',
11
+ };
@@ -0,0 +1,7 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum DividerType {
5
+ Vertical = 'vertical',
6
+ Horizontal = 'horizontal',
7
+ }
@@ -0,0 +1,6 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './Divider';
5
+
6
+ export * from './divider.enums';
@@ -0,0 +1,73 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import cx from 'classnames';
5
+ import { Button, ButtonSize, ButtonType } from '../button';
6
+ import { ArrowBack, Close } from '@iota/apps-ui-icons';
7
+
8
+ interface HeaderProps {
9
+ /**
10
+ * Header title.
11
+ */
12
+ title: string;
13
+ /**
14
+ * Title alignment (optional).
15
+ */
16
+ titleCentered?: boolean;
17
+ /**
18
+ * On back click handler (optional). If provided, a back button will be displayed.
19
+ */
20
+ onBack?: () => void;
21
+ /**
22
+ * On close click handler (optional). If provided, a close button will be displayed.
23
+ */
24
+ onClose?: (() => void) | ((e: React.MouseEvent<HTMLElement>) => void);
25
+ /**
26
+ * The 'data-testid' attribute value (used in e2e tests)
27
+ */
28
+ testId?: string;
29
+ }
30
+
31
+ export function Header({
32
+ title,
33
+ titleCentered,
34
+ onBack,
35
+ onClose,
36
+ testId,
37
+ }: HeaderProps): JSX.Element {
38
+ const titleCenteredClasses = titleCentered ? 'text-center' : onBack ? 'ml-1' : '';
39
+ const keepSpaceForIcon = titleCentered && (!onBack || !onClose);
40
+
41
+ return (
42
+ <div className="flex min-h-[56px] w-full items-center bg-neutral-100 px-md--rs pb-xs pt-sm text-neutral-10 dark:bg-neutral-6 dark:text-neutral-92 [&_svg]:h-5 [&_svg]:w-5">
43
+ {onBack ? (
44
+ <Button
45
+ size={ButtonSize.Small}
46
+ type={ButtonType.Ghost}
47
+ onClick={onBack}
48
+ icon={<ArrowBack />}
49
+ />
50
+ ) : (
51
+ keepSpaceForIcon && <div className="w-9" />
52
+ )}
53
+
54
+ <div className={cx('flex-grow', titleCenteredClasses)}>
55
+ <span className="font-inter text-title-lg" data-testid={testId}>
56
+ {title}
57
+ </span>
58
+ </div>
59
+
60
+ {onClose ? (
61
+ <Button
62
+ size={ButtonSize.Small}
63
+ type={ButtonType.Ghost}
64
+ onClick={onClose}
65
+ icon={<Close />}
66
+ testId={`close-icon`}
67
+ />
68
+ ) : (
69
+ keepSpaceForIcon && <div className="w-9" />
70
+ )}
71
+ </div>
72
+ );
73
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './Header';
@@ -0,0 +1,22 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './badge';
5
+ export * from './button';
6
+ export * from './radio-button';
7
+ export * from './button-segment';
8
+ export * from './button';
9
+ export * from './checkbox';
10
+ export * from './divider';
11
+ export * from './key-value-info';
12
+ export * from './label-text';
13
+ export * from './list-item';
14
+ export * from './header';
15
+ export * from './panel';
16
+ export * from './tooltip';
17
+ export * from './info-box';
18
+ export * from './snackbar';
19
+ export * from './visual-asset-card';
20
+ export * from './loading-indicator';
21
+ export * from './placeholder';
22
+ export * from './skeleton';
@@ -0,0 +1,73 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import cx from 'classnames';
5
+ import { InfoBoxStyle, InfoBoxType } from './infoBox.enums';
6
+ import { BACKGROUND_COLORS, ICON_COLORS } from './infoBox.classes';
7
+
8
+ export interface InfoBoxProps {
9
+ /**
10
+ * The icon of the info box (optional).
11
+ */
12
+ icon?: React.ReactNode;
13
+ /**
14
+ * The title of the info box (optional).
15
+ */
16
+ title?: string;
17
+ /**
18
+ * The supporting text of the info box (optional).
19
+ */
20
+ supportingText?: string;
21
+ /**
22
+ * The type of the info box.
23
+ */
24
+ type: InfoBoxType;
25
+ /**
26
+ * The style of the info box.
27
+ */
28
+ style?: InfoBoxStyle;
29
+ }
30
+
31
+ export function InfoBox({
32
+ icon,
33
+ title,
34
+ supportingText,
35
+ type,
36
+ style,
37
+ }: InfoBoxProps): React.JSX.Element {
38
+ const iconColorClass = ICON_COLORS[type];
39
+ const backgroundClass = style === InfoBoxStyle.Elevated ? BACKGROUND_COLORS[type] : '';
40
+ return (
41
+ <div
42
+ className={cx('flex flex-row items-start gap-4 py-xs pr-lg', backgroundClass, {
43
+ 'rounded-lg pl-xs': style === InfoBoxStyle.Elevated,
44
+ })}
45
+ >
46
+ {icon && (
47
+ <span
48
+ className={cx(
49
+ 'flex items-center justify-center rounded-lg [&_svg]:h-4 [&_svg]:w-4',
50
+ iconColorClass,
51
+ {
52
+ 'p-xs': style === InfoBoxStyle.Default,
53
+ },
54
+ )}
55
+ >
56
+ {icon}
57
+ </span>
58
+ )}
59
+ <div className="flex flex-col gap-1">
60
+ {title && (
61
+ <span className="text-title-sm text-neutral-10 dark:text-neutral-92">
62
+ {title}
63
+ </span>
64
+ )}
65
+ {supportingText && (
66
+ <span className="text-body-sm text-neutral-40 dark:text-neutral-60">
67
+ {supportingText}
68
+ </span>
69
+ )}
70
+ </div>
71
+ </div>
72
+ );
73
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './InfoBox';
5
+ export * from './infoBox.enums';
@@ -0,0 +1,14 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { InfoBoxType } from './infoBox.enums';
5
+
6
+ export const ICON_COLORS: Record<InfoBoxType, string> = {
7
+ [InfoBoxType.Default]: 'bg-neutral-96 dark:bg-neutral-12 text-neutral-10 dark:text-neutral-92',
8
+ [InfoBoxType.Error]: 'bg-error-90 dark:bg-error-10 text-error-20 dark:text-error-90',
9
+ };
10
+
11
+ export const BACKGROUND_COLORS: Record<InfoBoxType, string> = {
12
+ [InfoBoxType.Default]: 'bg-neutral-96 dark:bg-neutral-12',
13
+ [InfoBoxType.Error]: 'bg-error-90 dark:bg-error-10',
14
+ };
@@ -0,0 +1,12 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum InfoBoxType {
5
+ Default = 'default',
6
+ Error = 'error',
7
+ }
8
+
9
+ export enum InfoBoxStyle {
10
+ Default = 'default',
11
+ Elevated = 'elevated',
12
+ }
@@ -0,0 +1,156 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ReactNode } from 'react';
5
+ import cx from 'classnames';
6
+ import { Copy, Info } from '@iota/apps-ui-icons';
7
+ import { ValueSize } from './keyValue.enums';
8
+ import { Tooltip, TooltipPosition } from '../tooltip';
9
+ import { ButtonUnstyled } from '../button';
10
+
11
+ interface KeyValueProps {
12
+ /**
13
+ * The key of the KeyValue.
14
+ */
15
+ keyText: string;
16
+ /**
17
+ * The value of the KeyValue.
18
+ */
19
+ value: ReactNode;
20
+ /**
21
+ * The tooltip position.
22
+ */
23
+ tooltipPosition?: TooltipPosition;
24
+ /**
25
+ * The tooltip text.
26
+ */
27
+ tooltipText?: string;
28
+ /**
29
+ * The supporting label of the KeyValue (optional).
30
+ */
31
+ supportingLabel?: string;
32
+ /**
33
+ * The size of the value (optional).
34
+ */
35
+ size?: ValueSize;
36
+ /**
37
+ * The flag to truncate the value text.
38
+ */
39
+ isTruncated?: boolean;
40
+ /**
41
+ * Text that need to be copied (optional).
42
+ */
43
+ copyText?: string;
44
+ /**
45
+ * The onCopySuccess event of the KeyValue (optional).
46
+ */
47
+ onCopySuccess?: (e: React.MouseEvent<HTMLButtonElement>, text: string) => void;
48
+ /**
49
+ * The onCopyError event of the KeyValue (optional).
50
+ */
51
+ onCopyError?: (e: unknown, text: string) => void;
52
+ /**
53
+ * Full width KeyValue (optional).
54
+ */
55
+ fullwidth?: boolean;
56
+ /**
57
+ * Reverse the KeyValue (optional).
58
+ */
59
+ isReverse?: boolean;
60
+ /**
61
+ * Text shown on value hover.
62
+ */
63
+ valueHoverTitle?: string;
64
+ }
65
+
66
+ export function KeyValueInfo({
67
+ keyText,
68
+ value,
69
+ tooltipPosition,
70
+ tooltipText,
71
+ supportingLabel,
72
+ size = ValueSize.Small,
73
+ isTruncated = false,
74
+ copyText,
75
+ onCopySuccess,
76
+ onCopyError,
77
+ fullwidth,
78
+ isReverse = false,
79
+ valueHoverTitle,
80
+ }: KeyValueProps): React.JSX.Element {
81
+ const flexDirectionClass = isReverse ? 'flex-row-reverse' : 'flex-row';
82
+ async function handleCopyClick(event: React.MouseEvent<HTMLButtonElement>) {
83
+ if (!navigator.clipboard) {
84
+ return;
85
+ }
86
+
87
+ if (copyText) {
88
+ try {
89
+ await navigator.clipboard.writeText(copyText);
90
+ onCopySuccess?.(event, copyText);
91
+ } catch (error) {
92
+ console.error('Failed to copy:', error);
93
+ onCopyError?.(error, copyText);
94
+ }
95
+ }
96
+ }
97
+
98
+ return (
99
+ <div
100
+ className={cx(
101
+ 'flex w-full items-baseline gap-xs py-xxs font-inter',
102
+ flexDirectionClass,
103
+ {
104
+ 'justify-between': fullwidth,
105
+ },
106
+ )}
107
+ >
108
+ <div
109
+ className={cx('flex shrink-0 flex-row items-center gap-x-0.5', {
110
+ 'w-1/4': !fullwidth,
111
+ })}
112
+ >
113
+ <span className="text-body-md text-neutral-40 dark:text-neutral-60">{keyText}</span>
114
+ {tooltipText && (
115
+ <Tooltip text={tooltipText} position={tooltipPosition}>
116
+ <Info className="text-neutral-60 dark:text-neutral-40" />
117
+ </Tooltip>
118
+ )}
119
+ </div>
120
+ <div
121
+ className={cx('flex flex-row items-baseline gap-1 break-all', {
122
+ 'w-3/4': !fullwidth,
123
+ truncate: isTruncated,
124
+ })}
125
+ >
126
+ <span
127
+ title={valueHoverTitle}
128
+ className={cx(
129
+ 'text-neutral-10 dark:text-neutral-92',
130
+ size === ValueSize.Medium ? 'text-body-lg' : 'text-body-md',
131
+ { truncate: isTruncated },
132
+ )}
133
+ >
134
+ {value}
135
+ </span>
136
+ {supportingLabel && (
137
+ <span
138
+ className={cx(
139
+ 'text-neutral-60 dark:text-neutral-40',
140
+ size === ValueSize.Medium ? 'text-body-md' : 'text-body-sm',
141
+ )}
142
+ >
143
+ {supportingLabel}
144
+ </span>
145
+ )}
146
+ <div className="self-center">
147
+ {copyText && (
148
+ <ButtonUnstyled onClick={handleCopyClick}>
149
+ <Copy className="text-neutral-60 dark:text-neutral-40" />
150
+ </ButtonUnstyled>
151
+ )}
152
+ </div>
153
+ </div>
154
+ </div>
155
+ );
156
+ }
@@ -0,0 +1,6 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './KeyValueInfo';
5
+
6
+ export * from './keyValue.enums';
@@ -0,0 +1,7 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum ValueSize {
5
+ Small = 'small',
6
+ Medium = 'medium',
7
+ }
@@ -0,0 +1,93 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import cx from 'classnames';
5
+ import { LabelTextSize } from './labelText.enums';
6
+ import { LABEL_TEXT_SIZE, SUPPORTING_TEXT_SIZE, TEXT_SIZE } from './labelText.classes';
7
+ import { Info } from '@iota/apps-ui-icons';
8
+ import { TooltipPosition, Tooltip } from '../tooltip';
9
+
10
+ interface LabelTextProps {
11
+ /**
12
+ * The size of the LabelText.
13
+ */
14
+ size?: LabelTextSize;
15
+ /**
16
+ * The position of the LabelText.
17
+ */
18
+ isCentered?: boolean;
19
+ /**
20
+ * The supporting label of the LabelText.
21
+ */
22
+ supportingLabel?: string;
23
+ /**
24
+ * The text of the LabelText.
25
+ */
26
+ label: string;
27
+ /**
28
+ * The text of the LabelText.
29
+ */
30
+ text: string;
31
+ /**
32
+ * The tooltip position.
33
+ */
34
+ tooltipPosition?: TooltipPosition;
35
+ /**
36
+ * The tooltip text.
37
+ */
38
+ tooltipText?: string;
39
+ }
40
+
41
+ export function LabelText({
42
+ size = LabelTextSize.Medium,
43
+ isCentered,
44
+ supportingLabel,
45
+ label,
46
+ text,
47
+ tooltipPosition,
48
+ tooltipText,
49
+ }: LabelTextProps): React.JSX.Element {
50
+ const textClasses = TEXT_SIZE[size];
51
+ const supportingLabelClasses = SUPPORTING_TEXT_SIZE[size];
52
+ const labelTextClasses = LABEL_TEXT_SIZE[size];
53
+ const centeredClasses = isCentered ? 'items-center' : 'items-start';
54
+ const gapClass = size === LabelTextSize.Small ? 'gap-0.5' : 'gap-1';
55
+ return (
56
+ <div className={cx('flex flex-col', centeredClasses, gapClass)}>
57
+ <div className="flex flex-row flex-wrap items-center gap-0.5">
58
+ <span
59
+ className={cx('font-inter text-neutral-10 dark:text-neutral-92', textClasses)}
60
+ >
61
+ {text}
62
+ </span>
63
+ {supportingLabel && (
64
+ <span
65
+ className={cx(
66
+ 'font-inter text-neutral-60 dark:text-neutral-40',
67
+ supportingLabelClasses,
68
+ )}
69
+ >
70
+ {supportingLabel}
71
+ </span>
72
+ )}
73
+ </div>
74
+ <div className="flex flex-row items-center gap-x-0.5">
75
+ <span
76
+ className={cx(
77
+ 'flex items-center font-inter text-neutral-60 dark:text-neutral-40',
78
+ labelTextClasses,
79
+ )}
80
+ >
81
+ {label}
82
+ {tooltipText && (
83
+ <div className="ml-xxxs flex items-center">
84
+ <Tooltip text={tooltipText} position={tooltipPosition}>
85
+ <Info className="text-neutral-60 dark:text-neutral-40" />
86
+ </Tooltip>
87
+ </div>
88
+ )}
89
+ </span>
90
+ </div>
91
+ </div>
92
+ );
93
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './LabelText';
5
+ export * from './labelText.enums';
@@ -0,0 +1,22 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { LabelTextSize } from './labelText.enums';
5
+
6
+ export const TEXT_SIZE = {
7
+ [LabelTextSize.Small]: 'text-title-sm',
8
+ [LabelTextSize.Medium]: 'text-title-md',
9
+ [LabelTextSize.Large]: 'text-title-lg',
10
+ };
11
+
12
+ export const SUPPORTING_TEXT_SIZE = {
13
+ [LabelTextSize.Small]: 'text-label-md',
14
+ [LabelTextSize.Medium]: 'text-label-md',
15
+ [LabelTextSize.Large]: 'text-label-lg',
16
+ };
17
+
18
+ export const LABEL_TEXT_SIZE = {
19
+ [LabelTextSize.Small]: 'text-label-md',
20
+ [LabelTextSize.Medium]: 'text-label-md',
21
+ [LabelTextSize.Large]: 'text-label-lg',
22
+ };
@@ -0,0 +1,8 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum LabelTextSize {
5
+ Small = 'small',
6
+ Medium = 'medium',
7
+ Large = 'large',
8
+ }
@@ -0,0 +1,89 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { PropsWithChildren } from 'react';
5
+ import cx from 'classnames';
6
+ import { ArrowRight } from '@iota/apps-ui-icons';
7
+ import { Button, ButtonSize, ButtonType } from '@/components';
8
+
9
+ export interface ListItemProps {
10
+ /**
11
+ * Has right icon (optional).
12
+ */
13
+ showRightIcon?: boolean;
14
+ /**
15
+ * Hide bottom border (optional).
16
+ */
17
+ hideBottomBorder?: boolean;
18
+ /**
19
+ * On click handler (optional).
20
+ */
21
+ onClick?: () => void;
22
+ /**
23
+ * The list item is disabled or not.
24
+ */
25
+ isDisabled?: boolean;
26
+ /**
27
+ * The list item is highlighted.
28
+ */
29
+ isHighlighted?: boolean;
30
+ }
31
+
32
+ export function ListItem({
33
+ showRightIcon,
34
+ hideBottomBorder,
35
+ onClick,
36
+ isDisabled,
37
+ children,
38
+ isHighlighted,
39
+ }: PropsWithChildren<ListItemProps>): React.JSX.Element {
40
+ function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {
41
+ if ((event.key === 'Enter' || event.key === ' ') && !isDisabled && onClick) {
42
+ onClick();
43
+ }
44
+ }
45
+
46
+ function handleClick() {
47
+ if (!isDisabled && onClick) {
48
+ onClick();
49
+ }
50
+ }
51
+
52
+ return (
53
+ <div
54
+ className={cx(
55
+ 'w-full',
56
+ {
57
+ 'border-b border-shader-neutral-light-8 pb-xs dark:border-shader-neutral-dark-8':
58
+ !hideBottomBorder,
59
+ },
60
+ { 'opacity-40': isDisabled },
61
+ )}
62
+ >
63
+ <div
64
+ onClick={handleClick}
65
+ role="button"
66
+ tabIndex={0}
67
+ onKeyDown={handleKeyDown}
68
+ className={cx(
69
+ 'relative flex flex-row items-center justify-between px-md py-sm text-neutral-10 dark:text-neutral-92',
70
+ !isDisabled && onClick ? 'cursor-pointer' : 'cursor-default',
71
+ {
72
+ 'bg-shader-primary-dark-16 dark:bg-shader-inverted-dark-16': isHighlighted,
73
+ 'state-layer': !isDisabled,
74
+ },
75
+ )}
76
+ >
77
+ {children}
78
+ {showRightIcon && (
79
+ <Button
80
+ size={ButtonSize.Small}
81
+ type={ButtonType.Ghost}
82
+ disabled={isDisabled}
83
+ icon={<ArrowRight />}
84
+ />
85
+ )}
86
+ </div>
87
+ </div>
88
+ );
89
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './ListItem';
@@ -0,0 +1,38 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import cx from 'classnames';
5
+ import { Loader } from '@iota/apps-ui-icons';
6
+
7
+ export interface LoadingIndicatorProps {
8
+ /**
9
+ * The color of the loading indicator.
10
+ */
11
+ color?: string;
12
+ /**
13
+ * The size of the loading indicator.
14
+ */
15
+ size?: string;
16
+ /**
17
+ * The text to display next to the loading indicator.
18
+ */
19
+ text?: string;
20
+ /**
21
+ * The 'data-testid' attribute value (used in e2e tests)
22
+ */
23
+ testId?: string;
24
+ }
25
+
26
+ export function LoadingIndicator({
27
+ color = 'text-primary-30 dark:text-primary-80',
28
+ size = 'w-5 h-5',
29
+ text,
30
+ testId,
31
+ }: LoadingIndicatorProps): React.JSX.Element {
32
+ return (
33
+ <div className="flex items-center justify-center gap-xs">
34
+ <Loader className={cx('animate-spin', color, size)} data-testid={testId} />
35
+ {text && <span className={cx('text-body-sm', color)}>{text}</span>}
36
+ </div>
37
+ );
38
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './LoadingIndicator';