@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,224 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { PropsWithChildren, ReactNode } from 'react';
5
+ import cx from 'classnames';
6
+ import { TableProvider, useTableContext } from './TableContext';
7
+ import {
8
+ Button,
9
+ ButtonProps,
10
+ ButtonSize,
11
+ ButtonType,
12
+ Checkbox,
13
+ TableCellBase,
14
+ TableHeaderCell,
15
+ } from '@/lib';
16
+ import { ArrowLeft, DoubleArrowLeft, ArrowRight, DoubleArrowRight } from '@iota/apps-ui-icons';
17
+
18
+ export interface TablePaginationOptions {
19
+ /**
20
+ * On Next page button click.
21
+ */
22
+ onNext?: () => void;
23
+ /**
24
+ * On Previous page button click.
25
+ */
26
+ onPrev?: () => void;
27
+ /**
28
+ * On First page button click.
29
+ */
30
+ onFirst?: () => void;
31
+ /**
32
+ * On Last page button click.
33
+ */
34
+ onLast?: () => void;
35
+ /**
36
+ * Has Next button.
37
+ */
38
+ hasNext?: boolean;
39
+ /**
40
+ * Has Previous button.
41
+ */
42
+ hasPrev?: boolean;
43
+ /**
44
+ * Has First button.
45
+ */
46
+ hasFirst?: boolean;
47
+ /**
48
+ * Has Last button.
49
+ */
50
+ hasLast?: boolean;
51
+ }
52
+
53
+ export type TableProps = {
54
+ /**
55
+ * Options for the table pagination.
56
+ */
57
+ paginationOptions?: TablePaginationOptions;
58
+ /**
59
+ * The action component.
60
+ */
61
+ action?: ReactNode;
62
+ /**
63
+ * The supporting label of the table.
64
+ */
65
+ supportingLabel?: string;
66
+ /**
67
+ * Numeric indexes of the selected rows.
68
+ */
69
+ selectedRowIndexes?: Set<number>;
70
+ /**
71
+ * Numeric indexes of all the rows.
72
+ */
73
+ rowIndexes: number[];
74
+ /**
75
+ * The page size selector component.
76
+ */
77
+ pageSizeSelector?: ReactNode;
78
+ };
79
+
80
+ export function Table({
81
+ paginationOptions,
82
+ action,
83
+ supportingLabel,
84
+ selectedRowIndexes = new Set(),
85
+ rowIndexes,
86
+ children,
87
+ pageSizeSelector,
88
+ }: PropsWithChildren<TableProps>): JSX.Element {
89
+ return (
90
+ <TableProvider selectedRowIndexes={selectedRowIndexes} rowIndexes={rowIndexes}>
91
+ <div className="w-full">
92
+ <div className="overflow-auto">
93
+ <table className="w-full table-auto">{children}</table>
94
+ </div>
95
+ <div
96
+ className={cx('flex w-full items-center gap-2 pt-md', {
97
+ hidden: !supportingLabel && !paginationOptions && !action,
98
+ 'justify-between': paginationOptions,
99
+ 'justify-end': !paginationOptions && action,
100
+ })}
101
+ >
102
+ {(paginationOptions || action) && (
103
+ <div className="flex gap-2">
104
+ {paginationOptions && (
105
+ <>
106
+ <Button
107
+ type={ButtonType.Secondary}
108
+ size={ButtonSize.Small}
109
+ icon={<DoubleArrowLeft />}
110
+ disabled={!paginationOptions.hasFirst}
111
+ onClick={paginationOptions.onFirst}
112
+ />
113
+ <Button
114
+ type={ButtonType.Secondary}
115
+ size={ButtonSize.Small}
116
+ icon={<ArrowLeft />}
117
+ disabled={!paginationOptions.hasPrev}
118
+ onClick={paginationOptions.onPrev}
119
+ />
120
+ <Button
121
+ type={ButtonType.Secondary}
122
+ size={ButtonSize.Small}
123
+ icon={<ArrowRight />}
124
+ disabled={!paginationOptions.hasNext}
125
+ onClick={paginationOptions.onNext}
126
+ />
127
+ <Button
128
+ type={ButtonType.Secondary}
129
+ size={ButtonSize.Small}
130
+ icon={<DoubleArrowRight />}
131
+ disabled={!paginationOptions.hasLast}
132
+ onClick={paginationOptions.onLast}
133
+ />
134
+ </>
135
+ )}
136
+ {action && action}
137
+ </div>
138
+ )}
139
+ {supportingLabel || pageSizeSelector ? (
140
+ <div className="flex flex-row items-center gap-x-sm">
141
+ {supportingLabel && (
142
+ <span className=" text-label-md text-neutral-40 dark:text-neutral-60">
143
+ {supportingLabel}
144
+ </span>
145
+ )}
146
+ {pageSizeSelector && <div className="ml-2">{pageSizeSelector}</div>}
147
+ </div>
148
+ ) : null}
149
+ </div>
150
+ </div>
151
+ </TableProvider>
152
+ );
153
+ }
154
+
155
+ export function TableActionButton(props: PropsWithChildren<ButtonProps>) {
156
+ return <Button type={ButtonType.Secondary} size={ButtonSize.Small} {...props} />;
157
+ }
158
+
159
+ export function TableHeader({ children }: PropsWithChildren): JSX.Element {
160
+ return <thead>{children}</thead>;
161
+ }
162
+
163
+ export function TableRow({
164
+ children,
165
+ leading,
166
+ }: PropsWithChildren<{ leading?: React.ReactNode }>): JSX.Element {
167
+ return (
168
+ <tr>
169
+ {leading}
170
+ {children}
171
+ </tr>
172
+ );
173
+ }
174
+
175
+ const TEXT_COLOR_CLASS = 'text-neutral-40 dark:text-neutral-60';
176
+ const TEXT_SIZE_CLASS = 'text-body-md';
177
+
178
+ export function TableBody({ children }: PropsWithChildren): JSX.Element {
179
+ return <tbody className={cx(TEXT_COLOR_CLASS, TEXT_SIZE_CLASS)}>{children}</tbody>;
180
+ }
181
+
182
+ export interface TableRowCheckboxProps {
183
+ rowIndex: number;
184
+ onCheckboxChange: (checked: boolean) => void;
185
+ }
186
+
187
+ export function TableRowCheckbox({
188
+ rowIndex,
189
+ onCheckboxChange,
190
+ }: TableRowCheckboxProps): React.JSX.Element {
191
+ const { selectedRowIndexes } = useTableContext();
192
+
193
+ return (
194
+ <TableCellBase isContentCentered>
195
+ <Checkbox
196
+ onCheckedChange={(event) => {
197
+ onCheckboxChange(event.target.checked);
198
+ }}
199
+ isChecked={selectedRowIndexes.has(rowIndex)}
200
+ />
201
+ </TableCellBase>
202
+ );
203
+ }
204
+
205
+ export interface TableHeaderCheckboxProps {
206
+ onCheckboxChange: (checked: boolean) => void;
207
+ }
208
+
209
+ export function TableHeaderCheckbox({ onCheckboxChange }: TableHeaderCheckboxProps): JSX.Element {
210
+ const { isHeaderChecked, isHeaderIndeterminate } = useTableContext();
211
+
212
+ return (
213
+ <TableHeaderCell
214
+ isContentCentered
215
+ hasCheckbox
216
+ onCheckboxChange={(event) => {
217
+ onCheckboxChange(event.target.checked);
218
+ }}
219
+ isChecked={isHeaderChecked}
220
+ columnKey={1}
221
+ isIndeterminate={isHeaderIndeterminate}
222
+ />
223
+ );
224
+ }
@@ -0,0 +1,55 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { createContext, PropsWithChildren, useContext } from 'react';
5
+
6
+ export interface TableProviderProps {
7
+ /**
8
+ * Numeric indexes of the selected rows.
9
+ */
10
+ selectedRowIndexes: Set<number>;
11
+ /**
12
+ * Numeric indexes of all the rows.
13
+ */
14
+ rowIndexes: number[];
15
+ }
16
+
17
+ type TableContextProps = {
18
+ isHeaderChecked: boolean;
19
+ selectedRowIndexes: Set<number>;
20
+ isHeaderIndeterminate: boolean;
21
+ };
22
+
23
+ export const TableContext = createContext<TableContextProps>({
24
+ isHeaderChecked: false,
25
+ selectedRowIndexes: new Set(),
26
+ isHeaderIndeterminate: false,
27
+ });
28
+
29
+ export const useTableContext = () => {
30
+ const context = useContext(TableContext);
31
+ return context;
32
+ };
33
+
34
+ export function TableProvider({
35
+ children,
36
+ selectedRowIndexes,
37
+ rowIndexes,
38
+ ...props
39
+ }: PropsWithChildren<TableProviderProps>) {
40
+ const isHeaderChecked = rowIndexes.length === selectedRowIndexes.size;
41
+ const isHeaderIndeterminate = !isHeaderChecked && selectedRowIndexes.size > 0;
42
+
43
+ return (
44
+ <TableContext.Provider
45
+ value={{
46
+ ...props,
47
+ isHeaderChecked,
48
+ selectedRowIndexes,
49
+ isHeaderIndeterminate,
50
+ }}
51
+ >
52
+ {children}
53
+ </TableContext.Provider>
54
+ );
55
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './Table';
@@ -0,0 +1,127 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const IOTA_PRIMITIVES_COLOR_PALETTE = {
5
+ primary: {
6
+ '0': '#000000',
7
+ '10': '#061244',
8
+ '20': '#182b8a',
9
+ '30': '#3131ff',
10
+ '40': '#2563f5',
11
+ '50': '#3f80f0',
12
+ '60': '#5b9cfe',
13
+ '70': '#85b5fb',
14
+ '80': '#adceff',
15
+ '90': '#d5e8ff',
16
+ '100': '#ffffff',
17
+ },
18
+ secondary: {
19
+ '0': '#000000',
20
+ '10': '#051631',
21
+ '20': '#17345f',
22
+ '30': '#2d4c7a',
23
+ '40': '#4b648a',
24
+ '50': '#637ca2',
25
+ '60': '#7e97bd',
26
+ '70': '#96b3d5',
27
+ '80': '#b6cde8',
28
+ '90': '#dde9f7',
29
+ '100': '#ffffff',
30
+ },
31
+ tertiary: {
32
+ '0': '#000000',
33
+ '10': '#071f22',
34
+ '20': '#18393b',
35
+ '30': '#185b60',
36
+ '40': '#317479',
37
+ '50': '#498c91',
38
+ '60': '#64a7ac',
39
+ '70': '#7fc2c7',
40
+ '80': '#9adde2',
41
+ '90': '#c2f1f4',
42
+ '100': '#ffffff',
43
+ },
44
+ error: {
45
+ '0': '#000000',
46
+ '10': '#330009',
47
+ '20': '#610012',
48
+ '30': '#b51431',
49
+ '40': '#ce2d4a',
50
+ '50': '#e64562',
51
+ '60': '#ff607d',
52
+ '70': '#ff889e',
53
+ '80': '#ffb0be',
54
+ '90': '#ffd9e0',
55
+ '100': '#ffffff',
56
+ },
57
+ neutral: {
58
+ '0': '#000000',
59
+ '4': '#0a0f17',
60
+ '6': '#0f141c',
61
+ '10': '#171d26',
62
+ '12': '#1c212b',
63
+ '20': '#253041',
64
+ '30': '#3c4656',
65
+ '40': '#545e6e',
66
+ '50': '#6e7787',
67
+ '60': '#8892a1',
68
+ '70': '#a8b2c0',
69
+ '80': '#cad4e2',
70
+ '90': '#dde4f0',
71
+ '92': '#e3eaf6',
72
+ '96': '#eff4fa',
73
+ '98': '#f8fafc',
74
+ '100': '#ffffff',
75
+ },
76
+ };
77
+
78
+ export const SHADER_COLOR_PALETTE = {
79
+ 'shader-primary-dark': {
80
+ '0': '#bed8ff00',
81
+ '8': '#bed8ff14',
82
+ '12': '#bed8ff1e',
83
+ '16': '#bed8ff28',
84
+ '48': '#bed8ff7a',
85
+ '72': '#bed8ffb7',
86
+ },
87
+ 'shader-inverted-dark': {
88
+ '0': '#002f6d00',
89
+ '8': '#002f6d14',
90
+ '12': '#002f6d1e',
91
+ '16': '#002f6d28',
92
+ '48': '#002f6d7a',
93
+ '72': '#002f6db7',
94
+ },
95
+ 'shader-neutral-dark': {
96
+ '0': '#bed8ff00',
97
+ '8': '#bed8ff14',
98
+ '12': '#bed8ff1e',
99
+ '16': '#bed8ff28',
100
+ '48': '#bed8ff7a',
101
+ '72': '#bed8ffb7',
102
+ },
103
+ 'shader-primary-light': {
104
+ 0: '#0067ee00',
105
+ 8: '#0067ee14',
106
+ 12: '#0067ee1e',
107
+ 16: '#0067ee28',
108
+ 48: '#0067ee7a',
109
+ 72: '#0067eeb7',
110
+ },
111
+ 'shader-inverted-light': {
112
+ 0: '#bed8ff00',
113
+ 8: '#bed8ff14',
114
+ 12: '#bed8ff1e',
115
+ 16: '#bed8ff28',
116
+ 48: '#bed8ff7a',
117
+ 72: '#bed8ffb7',
118
+ },
119
+ 'shader-neutral-light': {
120
+ 0: '#002f6d00',
121
+ 8: '#002f6d14',
122
+ 12: '#002f6d1e',
123
+ 16: '#002f6d28',
124
+ 48: '#002f6d7a',
125
+ 72: '#002f6db7',
126
+ },
127
+ };
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './colors.constants';
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './screenSize.enums';
@@ -0,0 +1,9 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum ScreenSize {
5
+ Sm = 'sm',
6
+ Md = 'md',
7
+ Lg = 'lg',
8
+ Xl = 'xl',
9
+ }
@@ -0,0 +1,8 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './tailwind';
5
+ export * from './components';
6
+ export * from './constants';
7
+ export * from './enums';
8
+ export * from './utils';
@@ -0,0 +1,5 @@
1
+ /* Copyright (c) 2024 IOTA Stiftung
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
4
+ @import '@fontsource/inter/400.css';
5
+ @import '@fontsource/inter/500.css';
@@ -0,0 +1,136 @@
1
+ /* Copyright (c) 2024 IOTA Stiftung
2
+ SPDX-License-Identifier: Apache-2.0 */
3
+
4
+ @import './fonts.css';
5
+
6
+ @tailwind base;
7
+ @tailwind components;
8
+ @tailwind utilities;
9
+
10
+ @layer base {
11
+ .text-display-lg,
12
+ .text-display-md,
13
+ .text-display-sm,
14
+ .text-headline-lg,
15
+ .text-headline-md,
16
+ .text-headline-sm {
17
+ @apply font-alliance-no2;
18
+ }
19
+
20
+ .text-title-lg,
21
+ .text-title-md,
22
+ .text-title-sm,
23
+ .text-body-lg,
24
+ .text-body-md,
25
+ .text-body-sm,
26
+ .text-body-ds-lg,
27
+ .text-body-ds-md,
28
+ .text-body-ds-sm,
29
+ .text-label-lg,
30
+ .text-label-md,
31
+ .text-label-sm {
32
+ @apply font-inter;
33
+ }
34
+
35
+ .text-display-lg,
36
+ .text-display-md,
37
+ .text-display-sm,
38
+ .text-headline-lg,
39
+ .text-headline-md,
40
+ .text-headline-sm,
41
+ .text-body-ds-lg {
42
+ font-variant-alternates: 'ss02';
43
+ }
44
+
45
+ .text-label-md {
46
+ font-variant-alternates: 'ss01';
47
+ }
48
+
49
+ input:-webkit-autofill,
50
+ input:-webkit-autofill:enabled,
51
+ input:-webkit-autofill:hover,
52
+ input:-webkit-autofill:focus {
53
+ @apply appearance-none !bg-transparent !bg-none;
54
+ @apply !text-neutral-92 dark:!text-neutral-10;
55
+ transition: background-color 5000s ease-in-out 0s;
56
+ -webkit-text-fill-color: theme('colors.neutral.92') !important;
57
+ }
58
+
59
+ :root:not(.dark) {
60
+ input:-webkit-autofill,
61
+ input:-webkit-autofill:enabled,
62
+ input:-webkit-autofill:hover,
63
+ input:-webkit-autofill:focus {
64
+ -webkit-text-fill-color: theme('colors.neutral.10') !important;
65
+ }
66
+ }
67
+ }
68
+
69
+ @layer utilities {
70
+ .state-layer,
71
+ .state-layer-inverted,
72
+ .state-active {
73
+ &::after {
74
+ content: '';
75
+ border-radius: inherit;
76
+ @apply absolute;
77
+ @apply h-full w-full;
78
+ @apply left-0 top-0;
79
+ @apply transition-opacity duration-75;
80
+ @apply pointer-events-none;
81
+ }
82
+ }
83
+
84
+ .state-layer,
85
+ .state-layer-inverted {
86
+ &::after {
87
+ @apply opacity-0;
88
+ }
89
+
90
+ &:hover::after {
91
+ @apply opacity-8;
92
+ }
93
+
94
+ &:active::after {
95
+ @apply opacity-12;
96
+ }
97
+
98
+ &:disabled::after {
99
+ @apply opacity-0;
100
+ }
101
+ }
102
+
103
+ .state-active,
104
+ .state-layer {
105
+ &::after {
106
+ @apply bg-primary-60;
107
+ }
108
+ }
109
+
110
+ .state-layer-inverted {
111
+ &::after {
112
+ @apply bg-primary-80;
113
+ }
114
+ }
115
+
116
+ .state-active {
117
+ &::after {
118
+ @apply opacity-12;
119
+ }
120
+ }
121
+ }
122
+
123
+ @supports selector(::-webkit-scrollbar) {
124
+ *::-webkit-scrollbar {
125
+ @apply w-3.5;
126
+ }
127
+
128
+ *::-webkit-scrollbar-track {
129
+ @apply rounded-xl bg-transparent;
130
+ }
131
+
132
+ *::-webkit-scrollbar-thumb {
133
+ @apply shadow-[inset_0_0_10px_10px] shadow-neutral-80 dark:shadow-neutral-30;
134
+ @apply rounded-xl border-4 border-solid border-transparent;
135
+ }
136
+ }
@@ -0,0 +1,47 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { Config } from 'tailwindcss';
5
+ import { IOTA_PRIMITIVES_COLOR_PALETTE, SHADER_COLOR_PALETTE } from '../constants/colors.constants';
6
+ import {
7
+ CUSTOM_FONT_SIZES,
8
+ BORDER_RADIUS,
9
+ CUSTOM_SPACING,
10
+ OPACITY,
11
+ generateVariableSpacing,
12
+ } from './constants';
13
+
14
+ export const BASE_CONFIG: Config = {
15
+ content: ['./src/**/*.{html,js,jsx,ts,tsx}'],
16
+ darkMode: 'class',
17
+ theme: {
18
+ extend: {
19
+ fontSize: {
20
+ ...CUSTOM_FONT_SIZES,
21
+ },
22
+ borderRadius: {
23
+ ...BORDER_RADIUS,
24
+ },
25
+ spacing: (utils) => {
26
+ const screens = utils.theme('screens');
27
+ const variableSpacing = generateVariableSpacing(screens);
28
+ return {
29
+ ...CUSTOM_SPACING,
30
+ ...variableSpacing,
31
+ };
32
+ },
33
+ opacity: {
34
+ ...OPACITY,
35
+ 30: '0.3',
36
+ },
37
+ colors: {
38
+ ...IOTA_PRIMITIVES_COLOR_PALETTE,
39
+ ...SHADER_COLOR_PALETTE,
40
+ },
41
+ fontFamily: {
42
+ 'alliance-no2': ['AllianceNo2', 'sans-serif'],
43
+ inter: ['Inter', 'sans-serif'],
44
+ },
45
+ },
46
+ },
47
+ };