@iota/apps-ui-kit 0.0.0-dev-20251015065834

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 (243) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/LICENSE +201 -0
  3. package/README.md +16 -0
  4. package/dist/index.d.ts +1911 -0
  5. package/dist/index.es.js +6486 -0
  6. package/dist/index.es.js.map +1 -0
  7. package/dist/index.umd.js +66 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/style.css +1 -0
  10. package/package.json +80 -0
  11. package/src/lib/components/atoms/badge/Badge.tsx +37 -0
  12. package/src/lib/components/atoms/badge/badge.classes.ts +33 -0
  13. package/src/lib/components/atoms/badge/badge.enums.ts +11 -0
  14. package/src/lib/components/atoms/badge/index.ts +6 -0
  15. package/src/lib/components/atoms/button/Button.tsx +110 -0
  16. package/src/lib/components/atoms/button/button-variants/ButtonPill.tsx +23 -0
  17. package/src/lib/components/atoms/button/button-variants/ButtonUnstyled.tsx +27 -0
  18. package/src/lib/components/atoms/button/button-variants/buttonVariants.types.ts +11 -0
  19. package/src/lib/components/atoms/button/button-variants/index.ts +5 -0
  20. package/src/lib/components/atoms/button/button.classes.ts +53 -0
  21. package/src/lib/components/atoms/button/button.enums.ts +21 -0
  22. package/src/lib/components/atoms/button/index.ts +7 -0
  23. package/src/lib/components/atoms/button-segment/ButtonSegment.tsx +98 -0
  24. package/src/lib/components/atoms/button-segment/buttonSegment.classes.ts +24 -0
  25. package/src/lib/components/atoms/button-segment/buttonSegment.enums.ts +7 -0
  26. package/src/lib/components/atoms/button-segment/index.ts +5 -0
  27. package/src/lib/components/atoms/checkbox/Checkbox.tsx +124 -0
  28. package/src/lib/components/atoms/checkbox/index.ts +4 -0
  29. package/src/lib/components/atoms/divider/Divider.tsx +48 -0
  30. package/src/lib/components/atoms/divider/divider.classes.ts +11 -0
  31. package/src/lib/components/atoms/divider/divider.enums.ts +7 -0
  32. package/src/lib/components/atoms/divider/index.ts +6 -0
  33. package/src/lib/components/atoms/header/Header.tsx +73 -0
  34. package/src/lib/components/atoms/header/index.ts +4 -0
  35. package/src/lib/components/atoms/image/Image.tsx +32 -0
  36. package/src/lib/components/atoms/image/index.ts +4 -0
  37. package/src/lib/components/atoms/index.ts +26 -0
  38. package/src/lib/components/atoms/info-box/InfoBox.tsx +68 -0
  39. package/src/lib/components/atoms/info-box/index.ts +5 -0
  40. package/src/lib/components/atoms/info-box/infoBox.classes.ts +18 -0
  41. package/src/lib/components/atoms/info-box/infoBox.enums.ts +14 -0
  42. package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +157 -0
  43. package/src/lib/components/atoms/key-value-info/index.ts +6 -0
  44. package/src/lib/components/atoms/key-value-info/keyValue.enums.ts +7 -0
  45. package/src/lib/components/atoms/label-text/LabelText.tsx +92 -0
  46. package/src/lib/components/atoms/label-text/index.ts +5 -0
  47. package/src/lib/components/atoms/label-text/labelText.classes.ts +22 -0
  48. package/src/lib/components/atoms/label-text/labelText.enums.ts +8 -0
  49. package/src/lib/components/atoms/list-item/ListItem.tsx +88 -0
  50. package/src/lib/components/atoms/list-item/index.ts +4 -0
  51. package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +38 -0
  52. package/src/lib/components/atoms/loading-indicator/index.ts +4 -0
  53. package/src/lib/components/atoms/media-fallback/MediaFallback.tsx +12 -0
  54. package/src/lib/components/atoms/media-fallback/index.ts +4 -0
  55. package/src/lib/components/atoms/panel/Panel.tsx +28 -0
  56. package/src/lib/components/atoms/panel/index.ts +4 -0
  57. package/src/lib/components/atoms/placeholder/Placeholder.tsx +27 -0
  58. package/src/lib/components/atoms/placeholder/index.ts +4 -0
  59. package/src/lib/components/atoms/radio-button/RadioButton.tsx +64 -0
  60. package/src/lib/components/atoms/radio-button/index.ts +4 -0
  61. package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +29 -0
  62. package/src/lib/components/atoms/secondary-text/index.ts +4 -0
  63. package/src/lib/components/atoms/skeleton/Skeleton.tsx +30 -0
  64. package/src/lib/components/atoms/skeleton/index.ts +4 -0
  65. package/src/lib/components/atoms/snackbar/Snackbar.tsx +69 -0
  66. package/src/lib/components/atoms/snackbar/index.ts +5 -0
  67. package/src/lib/components/atoms/snackbar/snackbar.classes.ts +18 -0
  68. package/src/lib/components/atoms/snackbar/snackbar.enums.tsx +9 -0
  69. package/src/lib/components/atoms/toggle/Toggle.tsx +140 -0
  70. package/src/lib/components/atoms/toggle/index.ts +6 -0
  71. package/src/lib/components/atoms/toggle/toggle.classes.ts +41 -0
  72. package/src/lib/components/atoms/toggle/toggle.enums.ts +12 -0
  73. package/src/lib/components/atoms/tooltip/Tooltip.tsx +139 -0
  74. package/src/lib/components/atoms/tooltip/index.ts +5 -0
  75. package/src/lib/components/atoms/tooltip/tooltip.classes.ts +11 -0
  76. package/src/lib/components/atoms/tooltip/tooltip.enums.ts +9 -0
  77. package/src/lib/components/atoms/video/Video.tsx +33 -0
  78. package/src/lib/components/atoms/video/index.ts +4 -0
  79. package/src/lib/components/atoms/video/video.constants.ts +31 -0
  80. package/src/lib/components/index.ts +6 -0
  81. package/src/lib/components/molecules/account/Account.tsx +195 -0
  82. package/src/lib/components/molecules/account/index.ts +4 -0
  83. package/src/lib/components/molecules/address/Address.tsx +101 -0
  84. package/src/lib/components/molecules/address/index.ts +4 -0
  85. package/src/lib/components/molecules/asset-media-renderer/AssetMediaRenderer.tsx +50 -0
  86. package/src/lib/components/molecules/asset-media-renderer/index.ts +4 -0
  87. package/src/lib/components/molecules/card/Card.tsx +70 -0
  88. package/src/lib/components/molecules/card/CardAction.tsx +78 -0
  89. package/src/lib/components/molecules/card/CardBody.tsx +73 -0
  90. package/src/lib/components/molecules/card/CardImage.tsx +43 -0
  91. package/src/lib/components/molecules/card/CardImagePlaceholder.tsx +146 -0
  92. package/src/lib/components/molecules/card/card.classes.ts +27 -0
  93. package/src/lib/components/molecules/card/card.enums.ts +26 -0
  94. package/src/lib/components/molecules/card/index.ts +8 -0
  95. package/src/lib/components/molecules/chip/Chip.tsx +146 -0
  96. package/src/lib/components/molecules/chip/chip.classes.ts +54 -0
  97. package/src/lib/components/molecules/chip/chip.enums.ts +15 -0
  98. package/src/lib/components/molecules/chip/index.ts +5 -0
  99. package/src/lib/components/molecules/display-stats/DisplayStats.tsx +142 -0
  100. package/src/lib/components/molecules/display-stats/displayStats.classes.ts +36 -0
  101. package/src/lib/components/molecules/display-stats/displayStats.enums.ts +13 -0
  102. package/src/lib/components/molecules/display-stats/index.ts +5 -0
  103. package/src/lib/components/molecules/dropdown/Dropdown.tsx +10 -0
  104. package/src/lib/components/molecules/dropdown/dropdownPosition.enums.ts +7 -0
  105. package/src/lib/components/molecules/dropdown/index.ts +5 -0
  106. package/src/lib/components/molecules/index.ts +19 -0
  107. package/src/lib/components/molecules/input/Input.tsx +261 -0
  108. package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
  109. package/src/lib/components/molecules/input/TextArea.tsx +148 -0
  110. package/src/lib/components/molecules/input/index.ts +8 -0
  111. package/src/lib/components/molecules/input/input.classes.ts +13 -0
  112. package/src/lib/components/molecules/input/input.enums.ts +14 -0
  113. package/src/lib/components/molecules/input/input.types.ts +29 -0
  114. package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +47 -0
  115. package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +65 -0
  116. package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +54 -0
  117. package/src/lib/components/molecules/navbar-item/index.ts +5 -0
  118. package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +16 -0
  119. package/src/lib/components/molecules/navbar-item/navbarItem.enums.ts +7 -0
  120. package/src/lib/components/molecules/search/Search.tsx +219 -0
  121. package/src/lib/components/molecules/search/index.ts +5 -0
  122. package/src/lib/components/molecules/search/search.classes.ts +20 -0
  123. package/src/lib/components/molecules/search/search.enums.ts +7 -0
  124. package/src/lib/components/molecules/segmented-button/SegmentedButton.tsx +38 -0
  125. package/src/lib/components/molecules/segmented-button/index.ts +6 -0
  126. package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +12 -0
  127. package/src/lib/components/molecules/segmented-button/segmentedButton.enums.ts +8 -0
  128. package/src/lib/components/molecules/select/Select.tsx +235 -0
  129. package/src/lib/components/molecules/select/index.ts +5 -0
  130. package/src/lib/components/molecules/select/select.enums.ts +7 -0
  131. package/src/lib/components/molecules/table-cell/TableCell.tsx +62 -0
  132. package/src/lib/components/molecules/table-cell/index.ts +4 -0
  133. package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +140 -0
  134. package/src/lib/components/molecules/table-header-cell/index.ts +5 -0
  135. package/src/lib/components/molecules/table-header-cell/tableHeaderCell.enums.ts +7 -0
  136. package/src/lib/components/molecules/title/Title.tsx +78 -0
  137. package/src/lib/components/molecules/title/index.ts +5 -0
  138. package/src/lib/components/molecules/title/titleClasses.constants.ts +14 -0
  139. package/src/lib/components/molecules/title/titleSize.enums.ts +7 -0
  140. package/src/lib/components/molecules/visual-asset-card/VisualAssetCard.tsx +89 -0
  141. package/src/lib/components/molecules/visual-asset-card/index.ts +5 -0
  142. package/src/lib/components/molecules/visual-asset-card/visualAssetCard.enums.ts +7 -0
  143. package/src/lib/components/organisms/accordion/Accordion.tsx +108 -0
  144. package/src/lib/components/organisms/accordion/accordion.classes.ts +4 -0
  145. package/src/lib/components/organisms/accordion/index.ts +4 -0
  146. package/src/lib/components/organisms/dialog/Dialog.tsx +157 -0
  147. package/src/lib/components/organisms/dialog/dialog.enums.ts +7 -0
  148. package/src/lib/components/organisms/dialog/index.ts +5 -0
  149. package/src/lib/components/organisms/index.ts +7 -0
  150. package/src/lib/components/organisms/navbar/Navbar.tsx +101 -0
  151. package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +59 -0
  152. package/src/lib/components/organisms/navbar/index.ts +5 -0
  153. package/src/lib/components/organisms/table/Table.tsx +234 -0
  154. package/src/lib/components/organisms/table/TableContext.tsx +56 -0
  155. package/src/lib/components/organisms/table/index.ts +4 -0
  156. package/src/lib/constants/colors.constants.ts +239 -0
  157. package/src/lib/constants/index.ts +4 -0
  158. package/src/lib/enums/index.ts +5 -0
  159. package/src/lib/enums/screenSize.enums.ts +9 -0
  160. package/src/lib/enums/theme.enums.ts +8 -0
  161. package/src/lib/index.ts +10 -0
  162. package/src/lib/styles/base.css +144 -0
  163. package/src/lib/styles/components.css +735 -0
  164. package/src/lib/styles/fonts.css +7 -0
  165. package/src/lib/styles/index.css +18 -0
  166. package/src/lib/styles/utilities.css +61 -0
  167. package/src/lib/styles/variables/dark-variables.css +262 -0
  168. package/src/lib/styles/variables/general-variables.css +9 -0
  169. package/src/lib/styles/variables/light-variables.css +276 -0
  170. package/src/lib/styles/variables/names-variables.css +270 -0
  171. package/src/lib/tailwind/base.presets.ts +58 -0
  172. package/src/lib/tailwind/constants/customColors.constants.ts +13 -0
  173. package/src/lib/tailwind/constants/fontFamily.constants.ts +8 -0
  174. package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
  175. package/src/lib/tailwind/constants/gradients.constants.ts +6 -0
  176. package/src/lib/tailwind/constants/index.ts +7 -0
  177. package/src/lib/tailwind/constants/scaling.constants.ts +41 -0
  178. package/src/lib/tailwind/constants/variableSpacing.constants.ts +66 -0
  179. package/src/lib/tailwind/helpers.ts +20 -0
  180. package/src/lib/tailwind/index.ts +5 -0
  181. package/src/lib/tailwind/plugins.ts +12 -0
  182. package/src/lib/tailwind/responsive.presets.ts +36 -0
  183. package/src/lib/tailwind/static.presets.ts +25 -0
  184. package/src/lib/tailwind/types.ts +6 -0
  185. package/src/lib/utils/format.ts +8 -0
  186. package/src/lib/utils/index.ts +4 -0
  187. package/src/storybook/blocks/Showcase.tsx +20 -0
  188. package/src/storybook/blocks/TypeSet.tsx +34 -0
  189. package/src/storybook/blocks/TypeSetItem.tsx +74 -0
  190. package/src/storybook/blocks/index.ts +6 -0
  191. package/src/storybook/constants/gradients.constants.ts +8 -0
  192. package/src/storybook/constants/index.ts +5 -0
  193. package/src/storybook/constants/typeset.constants.ts +39 -0
  194. package/src/storybook/constants/variableSpacing.constants.ts +6 -0
  195. package/src/storybook/helpers/formatGradientNames.ts +15 -0
  196. package/src/storybook/helpers/getFontSizeLabel.ts +15 -0
  197. package/src/storybook/helpers/index.ts +4 -0
  198. package/src/storybook/stories/atoms/Badge.stories.tsx +32 -0
  199. package/src/storybook/stories/atoms/Button.stories.tsx +45 -0
  200. package/src/storybook/stories/atoms/ButtonSegment.stories.tsx +45 -0
  201. package/src/storybook/stories/atoms/Checkbox.stories.tsx +34 -0
  202. package/src/storybook/stories/atoms/CustomScrollbar.stories.tsx +22 -0
  203. package/src/storybook/stories/atoms/Divider.stories.tsx +41 -0
  204. package/src/storybook/stories/atoms/Header.stories.tsx +58 -0
  205. package/src/storybook/stories/atoms/InfoBox.stories.tsx +67 -0
  206. package/src/storybook/stories/atoms/KeyValueInfo.stories.tsx +59 -0
  207. package/src/storybook/stories/atoms/LabelText.stories.tsx +55 -0
  208. package/src/storybook/stories/atoms/ListItem.stories.tsx +41 -0
  209. package/src/storybook/stories/atoms/LoadingIndicator.stories.tsx +32 -0
  210. package/src/storybook/stories/atoms/Panel.stories.tsx +36 -0
  211. package/src/storybook/stories/atoms/Placeholder.stories.tsx +33 -0
  212. package/src/storybook/stories/atoms/RadioButton.stories.tsx +51 -0
  213. package/src/storybook/stories/atoms/Skeleton.stories.tsx +33 -0
  214. package/src/storybook/stories/atoms/Snackbar.stories.tsx +43 -0
  215. package/src/storybook/stories/atoms/Toggle.stories.tsx +59 -0
  216. package/src/storybook/stories/atoms/Tooltip.stories.tsx +59 -0
  217. package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +57 -0
  218. package/src/storybook/stories/components/DocsSyncTheme.tsx +20 -0
  219. package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
  220. package/src/storybook/stories/components/index.ts +5 -0
  221. package/src/storybook/stories/design-tokens/colors.stories.mdx +44 -0
  222. package/src/storybook/stories/design-tokens/icons.stories.mdx +19 -0
  223. package/src/storybook/stories/design-tokens/typeset.stories.mdx +17 -0
  224. package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +11 -0
  225. package/src/storybook/stories/molecules/Account.stories.tsx +71 -0
  226. package/src/storybook/stories/molecules/Address.stories.tsx +39 -0
  227. package/src/storybook/stories/molecules/Card.stories.tsx +112 -0
  228. package/src/storybook/stories/molecules/Chip.stories.tsx +127 -0
  229. package/src/storybook/stories/molecules/DisplayStats.stories.tsx +63 -0
  230. package/src/storybook/stories/molecules/Dropdown.stories.tsx +38 -0
  231. package/src/storybook/stories/molecules/Input.stories.tsx +239 -0
  232. package/src/storybook/stories/molecules/NavbarItem.stories.tsx +45 -0
  233. package/src/storybook/stories/molecules/Search.stories.tsx +101 -0
  234. package/src/storybook/stories/molecules/SegmentedButton.stories.tsx +108 -0
  235. package/src/storybook/stories/molecules/Select.stories.tsx +103 -0
  236. package/src/storybook/stories/molecules/TableCell.stories.tsx +46 -0
  237. package/src/storybook/stories/molecules/TableHeaderCell.stories.tsx +34 -0
  238. package/src/storybook/stories/molecules/TextArea.stories.tsx +80 -0
  239. package/src/storybook/stories/molecules/Title.stories.tsx +76 -0
  240. package/src/storybook/stories/organisms/Accordion.stories.tsx +70 -0
  241. package/src/storybook/stories/organisms/Dialog.stories.tsx +129 -0
  242. package/src/storybook/stories/organisms/Navbar.stories.tsx +78 -0
  243. package/src/storybook/stories/organisms/Table.stories.tsx +154 -0
@@ -0,0 +1,239 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+
6
+ import { Input, InputType } from '@/lib/components/molecules/input';
7
+ import { CheckmarkFilled, Close, Loader2, PlaceholderReplace } from '@iota/apps-ui-icons';
8
+ import type { ComponentProps } from 'react';
9
+ import { useCallback, useEffect, useState } from 'react';
10
+ import { ButtonPill, ButtonUnstyled } from '@/lib/components/atoms/button';
11
+ import classNames from 'classnames';
12
+
13
+ type CustomStoryProps = {
14
+ withLeadingIcon?: boolean;
15
+ };
16
+
17
+ function InputStory({
18
+ withLeadingIcon,
19
+ value,
20
+ onClearInput,
21
+ type,
22
+ ...props
23
+ }: ComponentProps<typeof Input> & CustomStoryProps): JSX.Element {
24
+ const [inputValue, setInputValue] = useState(value ?? '');
25
+
26
+ useEffect(() => {
27
+ setInputValue(value ?? '');
28
+ }, [value]);
29
+
30
+ return (
31
+ <Input
32
+ {...props}
33
+ onChange={(e) => setInputValue(e.target.value)}
34
+ value={inputValue}
35
+ onClearInput={() => setInputValue('')}
36
+ leadingIcon={withLeadingIcon ? <PlaceholderReplace /> : undefined}
37
+ type={type}
38
+ />
39
+ );
40
+ }
41
+
42
+ const meta = {
43
+ component: Input,
44
+ tags: ['autodocs'],
45
+ } satisfies Meta<typeof Input>;
46
+
47
+ export default meta;
48
+
49
+ type Story = StoryObj<typeof meta>;
50
+
51
+ export const Default: Story = {
52
+ args: {
53
+ label: 'Label',
54
+ caption: 'Caption',
55
+ type: InputType.Text,
56
+ },
57
+ argTypes: {
58
+ amountCounter: {
59
+ control: {
60
+ type: 'text',
61
+ },
62
+ },
63
+ type: {
64
+ control: {
65
+ type: 'select',
66
+ options: Object.values(InputType),
67
+ },
68
+ },
69
+ onValueChange: {
70
+ control: {
71
+ type: 'none',
72
+ },
73
+ },
74
+ },
75
+ render: (props) => <InputStory {...props} />,
76
+ };
77
+
78
+ export const WithLeadingElement: Story = {
79
+ args: {
80
+ type: InputType.Text,
81
+ placeholder: 'Placeholder',
82
+ amountCounter: '10',
83
+ caption: 'Caption',
84
+ },
85
+ render: (props) => <InputStory {...props} withLeadingIcon />,
86
+ };
87
+
88
+ export const WithMaxTrailingButton: Story = {
89
+ args: {
90
+ type: InputType.Number,
91
+ placeholder: 'Send IOTAs',
92
+ amountCounter: 'Max 10 IOTA',
93
+ caption: 'Enter token amount',
94
+ supportingText: 'IOTA',
95
+ trailingElement: <PlaceholderReplace />,
96
+ },
97
+ render: ({ value, ...props }) => {
98
+ const [inputValue, setInputValue] = useState<string>('');
99
+ const [error, setError] = useState<string | undefined>();
100
+
101
+ function onMaxClick() {
102
+ setInputValue('10');
103
+ checkInputValidity(inputValue);
104
+ }
105
+
106
+ const onChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
107
+ setInputValue(e.target.value);
108
+ }, []);
109
+
110
+ function checkInputValidity(value: string) {
111
+ if (Number(value) < 0) {
112
+ setError('Value must be greater than 0');
113
+ } else if (Number(value) > 10) {
114
+ setError('Value must be less than 10');
115
+ } else {
116
+ setError(undefined);
117
+ }
118
+ }
119
+
120
+ useEffect(() => {
121
+ checkInputValidity(inputValue);
122
+ }, [inputValue]);
123
+
124
+ return (
125
+ <Input
126
+ {...props}
127
+ required
128
+ label="Send Tokens"
129
+ value={inputValue}
130
+ trailingElement={<ButtonPill onClick={onMaxClick}>Max</ButtonPill>}
131
+ errorMessage={error}
132
+ onChange={onChange}
133
+ onClearInput={() => setInputValue('')}
134
+ />
135
+ );
136
+ },
137
+ };
138
+
139
+ export const NumericFormatInput: Story = {
140
+ args: {
141
+ type: InputType.NumericFormat,
142
+ placeholder: 'Enter the IOTA Amount',
143
+ amountCounter: '10',
144
+ caption: 'Caption',
145
+ suffix: ' IOTA',
146
+ prefix: '~ ',
147
+ },
148
+ render: (props) => {
149
+ const [inputValue, setInputValue] = useState<string>('');
150
+
151
+ function onMaxClick() {
152
+ setInputValue('10');
153
+ }
154
+
155
+ return (
156
+ <InputStory
157
+ {...props}
158
+ value={inputValue}
159
+ trailingElement={<ButtonPill onClick={onMaxClick}>Max</ButtonPill>}
160
+ />
161
+ );
162
+ },
163
+ };
164
+
165
+ export const NameResolverInput: Story = {
166
+ args: {
167
+ type: InputType.Text,
168
+ },
169
+ render: ({ type }) => {
170
+ const [value, setValue] = useState<string>('');
171
+ const { address, isLoading, error } = useNameResolver(value);
172
+
173
+ const ICON_COLORS =
174
+ 'text-iota-primary-30 dark:text-iota-primary-70 names:text-names-primary-70';
175
+
176
+ return (
177
+ <Input
178
+ type={type}
179
+ placeholder="@name"
180
+ label="Name Resolver"
181
+ caption="Enter the name to resolve"
182
+ value={value}
183
+ onInput={(e) => setValue(e.currentTarget.value)}
184
+ supportingValue={address}
185
+ errorMessage={error || undefined}
186
+ trailingElement={
187
+ <>
188
+ {value.length > 0 && (
189
+ <ButtonUnstyled
190
+ className="input-icon-color"
191
+ onClick={() => setValue('')}
192
+ tabIndex={-1}
193
+ >
194
+ <Close className="h-5 w-5" />
195
+ </ButtonUnstyled>
196
+ )}
197
+ {isLoading ? (
198
+ <Loader2 className={classNames('h-5 w-5 animate-spin', ICON_COLORS)} />
199
+ ) : address ? (
200
+ <CheckmarkFilled className={classNames('h-5 w-5', ICON_COLORS)} />
201
+ ) : null}
202
+ </>
203
+ }
204
+ />
205
+ );
206
+ },
207
+ };
208
+
209
+ function useNameResolver(name: string) {
210
+ const [address, setAddress] = useState<string | null>(null);
211
+ const [isLoading, setIsLoading] = useState<boolean>(true);
212
+ const [error, setError] = useState<string | null>(null);
213
+
214
+ useEffect(() => {
215
+ setAddress(null);
216
+ setError(null);
217
+
218
+ if (!name) {
219
+ setIsLoading(false);
220
+ return;
221
+ }
222
+
223
+ setIsLoading(true);
224
+
225
+ const id = setTimeout(() => {
226
+ if (name.includes('@')) {
227
+ setAddress(`0x3c14…187b`);
228
+ } else {
229
+ setError("Only names with '@' are supported");
230
+ setAddress(null);
231
+ }
232
+ setIsLoading(false);
233
+ }, 1500);
234
+
235
+ return () => clearTimeout(id);
236
+ }, [name]);
237
+
238
+ return { address, isLoading, error };
239
+ }
@@ -0,0 +1,45 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import { NavbarItem, NavbarItemType } from '@/components';
6
+ import { Home } from '@iota/apps-ui-icons';
7
+
8
+ const meta: Meta<typeof NavbarItem> = {
9
+ component: NavbarItem,
10
+ tags: ['autodocs'],
11
+ render: (props) => {
12
+ return <NavbarItem {...props} />;
13
+ },
14
+ } satisfies Meta<typeof NavbarItem>;
15
+
16
+ export default meta;
17
+
18
+ type Story = StoryObj<typeof meta>;
19
+
20
+ export const Default: Story = {
21
+ args: {
22
+ icon: <Home />,
23
+ },
24
+ argTypes: {
25
+ text: {
26
+ control: 'text',
27
+ },
28
+ icon: {
29
+ control: 'none',
30
+ },
31
+ hasBadge: {
32
+ control: 'boolean',
33
+ },
34
+ isSelected: {
35
+ control: 'boolean',
36
+ },
37
+ type: {
38
+ control: 'select',
39
+ options: Object.values(NavbarItemType),
40
+ },
41
+ isDisabled: {
42
+ control: 'boolean',
43
+ },
44
+ },
45
+ };
@@ -0,0 +1,101 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { useState } from 'react';
5
+ import type { Meta, StoryObj } from '@storybook/react';
6
+ import type { Suggestion } from '@/components';
7
+ import { ListItem, Search, SearchBarType } from '@/components';
8
+ import cx from 'classnames';
9
+
10
+ const meta: Meta<typeof Search> = {
11
+ component: Search,
12
+ tags: ['autodocs'],
13
+ render: (props) => {
14
+ const [searchValue, setSearchValue] = useState<string>('');
15
+ const [filteredSuggestions, setFilteredSuggestions] = useState<Suggestion[]>([]);
16
+
17
+ const handleSearchValueChange = (value: string) => {
18
+ setSearchValue(value);
19
+ const filtered =
20
+ props.suggestions?.filter((suggestion) =>
21
+ suggestion.label.toLowerCase().includes(value.toLowerCase()),
22
+ ) || [];
23
+ setFilteredSuggestions(filtered);
24
+ };
25
+
26
+ const handleSuggestionClick = (suggestion: Suggestion) => {
27
+ setSearchValue(suggestion.label);
28
+ setFilteredSuggestions([]);
29
+ };
30
+
31
+ return (
32
+ <div className="h-60">
33
+ <Search
34
+ {...props}
35
+ searchValue={searchValue}
36
+ suggestions={filteredSuggestions}
37
+ onSearchValueChange={handleSearchValueChange}
38
+ onSuggestionClick={handleSuggestionClick}
39
+ renderSuggestion={(suggestion) => (
40
+ <ListItem
41
+ key={suggestion.id}
42
+ showRightIcon={false}
43
+ onClick={() => handleSuggestionClick(suggestion)}
44
+ hideBottomBorder
45
+ >
46
+ <div
47
+ className={cx(
48
+ 'flex w-full flex-row items-center gap-xs',
49
+ suggestion.supportingText ? 'justify-between' : 'justify-start',
50
+ )}
51
+ >
52
+ <span className="text-body-lg text-iota-neutral-10 names:text-names-neutral-92 dark:text-iota-neutral-92">
53
+ {suggestion.label}
54
+ </span>
55
+ <span className="text-body-md text-iota-neutral-40 names:text-names-neutral-60 dark:text-iota-neutral-60">
56
+ {suggestion.supportingText}
57
+ </span>
58
+ </div>
59
+ </ListItem>
60
+ )}
61
+ />
62
+ </div>
63
+ );
64
+ },
65
+ };
66
+
67
+ export default meta;
68
+
69
+ type Story = StoryObj<typeof meta>;
70
+
71
+ export const Default: Story = {
72
+ args: {
73
+ suggestions: [
74
+ { id: '1', label: 'Dashboard', supportingText: 'Caption' },
75
+ { id: '2', label: 'Wallet' },
76
+ { id: '3', label: 'Explorer' },
77
+ { id: '4', label: 'SDK' },
78
+ ],
79
+ placeholder: 'Search for tooling apps',
80
+ },
81
+ argTypes: {
82
+ suggestions: {
83
+ control: 'object',
84
+ },
85
+ onSuggestionClick: {
86
+ action: 'suggestionClicked',
87
+ },
88
+ placeholder: {
89
+ control: 'text',
90
+ },
91
+ onSearchValueChange: {
92
+ action: 'searchValueChanged',
93
+ },
94
+ type: {
95
+ control: {
96
+ type: 'select',
97
+ options: Object.values(SearchBarType),
98
+ },
99
+ },
100
+ },
101
+ };
@@ -0,0 +1,108 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+
6
+ import {
7
+ ButtonSegment,
8
+ ButtonSegmentType,
9
+ SegmentedButton,
10
+ SegmentedButtonType,
11
+ } from '@/components';
12
+ import type { ComponentProps } from 'react';
13
+ import { useState } from 'react';
14
+ import { PlaceholderReplace } from '@iota/apps-ui-icons';
15
+
16
+ const meta: Meta<typeof SegmentedButton> = {
17
+ component: SegmentedButton,
18
+ tags: ['autodocs'],
19
+ render: (props) => {
20
+ const [elements, setElements] = useState<ComponentProps<typeof ButtonSegment>[]>([
21
+ { label: 'Label 1', selected: true },
22
+ { label: 'Label 2', icon: <PlaceholderReplace /> },
23
+ { label: 'Label 3', disabled: true },
24
+ { label: 'Label 4' },
25
+ ]);
26
+
27
+ const handleElementClick = (clickedIndex: number) => {
28
+ const updatedElements = elements.map((element, index) => ({
29
+ ...element,
30
+ selected: index === clickedIndex,
31
+ }));
32
+ setElements(updatedElements);
33
+ };
34
+
35
+ return (
36
+ <div className="flex flex-col items-start">
37
+ <SegmentedButton type={props.type} shape={props.shape}>
38
+ {elements.map((element, index) => (
39
+ <ButtonSegment
40
+ key={element.label}
41
+ type={props.shape}
42
+ onClick={() => handleElementClick(index)}
43
+ {...element}
44
+ />
45
+ ))}
46
+ </SegmentedButton>
47
+ </div>
48
+ );
49
+ },
50
+ } satisfies Meta<typeof SegmentedButton>;
51
+
52
+ export default meta;
53
+
54
+ type Story = StoryObj<typeof meta>;
55
+
56
+ export const Default: Story = {
57
+ argTypes: {
58
+ type: {
59
+ control: {
60
+ type: 'select',
61
+ options: Object.values(SegmentedButtonType),
62
+ },
63
+ },
64
+ shape: {
65
+ control: {
66
+ type: 'select',
67
+ options: Object.values(ButtonSegmentType),
68
+ },
69
+ },
70
+ },
71
+ };
72
+
73
+ export const Underlined: Story = {
74
+ args: {
75
+ type: SegmentedButtonType.Transparent,
76
+ shape: ButtonSegmentType.Underlined,
77
+ },
78
+ render: (props) => {
79
+ const [elements, setElements] = useState<ComponentProps<typeof ButtonSegment>[]>([
80
+ { label: 'Label 1', selected: true, type: ButtonSegmentType.Underlined },
81
+ { label: 'Label 2', icon: <PlaceholderReplace />, type: ButtonSegmentType.Underlined },
82
+ { label: 'Label 3', type: ButtonSegmentType.Underlined },
83
+ { label: 'Label 4', disabled: true, type: ButtonSegmentType.Underlined },
84
+ ]);
85
+
86
+ const handleElementClick = (clickedIndex: number) => {
87
+ const updatedElements = elements.map((element, index) => ({
88
+ ...element,
89
+ selected: index === clickedIndex,
90
+ }));
91
+ setElements(updatedElements);
92
+ };
93
+
94
+ return (
95
+ <div className="flex flex-col items-start">
96
+ <SegmentedButton type={props.type} shape={props.shape}>
97
+ {elements.map((element, index) => (
98
+ <ButtonSegment
99
+ key={element.label}
100
+ onClick={() => handleElementClick(index)}
101
+ {...element}
102
+ />
103
+ ))}
104
+ </SegmentedButton>
105
+ </div>
106
+ );
107
+ },
108
+ };
@@ -0,0 +1,103 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import type { SelectOption } from '@/components/molecules/select/Select';
6
+ import { Select } from '@/components/molecules/select/Select';
7
+ import { useState } from 'react';
8
+ import { IotaLogoMark, PlaceholderReplace } from '@iota/apps-ui-icons';
9
+
10
+ const meta: Meta<typeof Select> = {
11
+ component: Select,
12
+ tags: ['autodocs'],
13
+ } satisfies Meta<typeof Select>;
14
+
15
+ export default meta;
16
+
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ const dropdownOptions: SelectOption[] = ['Option 1', 'Option 2', 'Option 3', 'Invalid Option'];
20
+
21
+ export const Default: Story = {
22
+ args: {
23
+ label: 'Select Input',
24
+ supportingText: 'Info',
25
+ caption: 'Caption',
26
+ placeholder: 'Placeholder',
27
+ options: dropdownOptions,
28
+ },
29
+ argTypes: {
30
+ placeholder: {
31
+ control: {
32
+ type: 'text',
33
+ },
34
+ },
35
+ },
36
+ render: (args) => {
37
+ const [selected, setSelected] = useState('Option 1');
38
+ const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);
39
+
40
+ const onChange = (id: string) => {
41
+ if (id === 'Invalid Option') {
42
+ setErrorMessage('Invalid Option Selected');
43
+ } else {
44
+ setSelected(id);
45
+ setErrorMessage(undefined);
46
+ }
47
+ };
48
+
49
+ return (
50
+ <div className="h-60">
51
+ <Select
52
+ {...args}
53
+ value={selected}
54
+ onValueChange={onChange}
55
+ errorMessage={errorMessage}
56
+ />
57
+ </div>
58
+ );
59
+ },
60
+ };
61
+
62
+ export const CustomOptions: Story = {
63
+ args: {
64
+ label: 'Send Coins',
65
+ placeholder: 'Select a coin',
66
+ options: [],
67
+ },
68
+ render: ({ options, ...args }) => {
69
+ const [selected, setSelected] = useState('iota');
70
+
71
+ const customOptions: SelectOption[] = [
72
+ {
73
+ id: 'iota',
74
+ renderLabel: () => (
75
+ <div className="flex items-center gap-2">
76
+ <IotaLogoMark />
77
+ IOTA
78
+ </div>
79
+ ),
80
+ },
81
+ {
82
+ id: 'other coin',
83
+ renderLabel: () => (
84
+ <div className="flex items-center gap-2">
85
+ <PlaceholderReplace />
86
+ Other Coin
87
+ </div>
88
+ ),
89
+ },
90
+ ];
91
+
92
+ return (
93
+ <div className="h-60">
94
+ <Select
95
+ {...args}
96
+ value={selected}
97
+ onValueChange={setSelected}
98
+ options={customOptions}
99
+ />
100
+ </div>
101
+ );
102
+ },
103
+ };
@@ -0,0 +1,46 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import { TableCellBase, TableCellText } from '@/components';
6
+
7
+ const meta = {
8
+ component: TableCellText,
9
+ tags: ['autodocs'],
10
+ render: (props) => {
11
+ return (
12
+ <table>
13
+ <thead>
14
+ <tr>
15
+ <TableCellBase>
16
+ <Avatar />
17
+ </TableCellBase>
18
+ <TableCellBase>
19
+ <TableCellText>Mr. Crab</TableCellText>
20
+ </TableCellBase>
21
+ </tr>
22
+ </thead>
23
+ </table>
24
+ );
25
+ },
26
+ } satisfies Meta<typeof TableCellText>;
27
+
28
+ export default meta;
29
+
30
+ type Story = StoryObj<typeof meta>;
31
+
32
+ const Avatar = () => {
33
+ return (
34
+ <svg
35
+ xmlns="http://www.w3.org/2000/svg"
36
+ width="33"
37
+ height="32"
38
+ viewBox="0 0 33 32"
39
+ fill="none"
40
+ >
41
+ <circle cx="16.5" cy="16" r="16" className="fill-iota-primary-40" />
42
+ </svg>
43
+ );
44
+ };
45
+
46
+ export const Default: Story = {};
@@ -0,0 +1,34 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import { TableHeaderCell } from '@/components';
6
+
7
+ const meta = {
8
+ component: TableHeaderCell,
9
+ tags: ['autodocs'],
10
+ render: (props) => {
11
+ return (
12
+ <div className="w-56">
13
+ <table>
14
+ <thead>
15
+ <tr>
16
+ <TableHeaderCell {...props} />
17
+ </tr>
18
+ </thead>
19
+ </table>
20
+ </div>
21
+ );
22
+ },
23
+ } satisfies Meta<typeof TableHeaderCell>;
24
+
25
+ export default meta;
26
+
27
+ type Story = StoryObj<typeof meta>;
28
+
29
+ export const Default: Story = {
30
+ args: {
31
+ label: 'Label',
32
+ columnKey: '1',
33
+ },
34
+ };