@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.
- package/CHANGELOG.md +145 -0
- package/LICENSE +201 -0
- package/README.md +16 -0
- package/dist/index.d.ts +1911 -0
- package/dist/index.es.js +6486 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +66 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +80 -0
- package/src/lib/components/atoms/badge/Badge.tsx +37 -0
- package/src/lib/components/atoms/badge/badge.classes.ts +33 -0
- package/src/lib/components/atoms/badge/badge.enums.ts +11 -0
- package/src/lib/components/atoms/badge/index.ts +6 -0
- package/src/lib/components/atoms/button/Button.tsx +110 -0
- package/src/lib/components/atoms/button/button-variants/ButtonPill.tsx +23 -0
- package/src/lib/components/atoms/button/button-variants/ButtonUnstyled.tsx +27 -0
- package/src/lib/components/atoms/button/button-variants/buttonVariants.types.ts +11 -0
- package/src/lib/components/atoms/button/button-variants/index.ts +5 -0
- package/src/lib/components/atoms/button/button.classes.ts +53 -0
- package/src/lib/components/atoms/button/button.enums.ts +21 -0
- package/src/lib/components/atoms/button/index.ts +7 -0
- package/src/lib/components/atoms/button-segment/ButtonSegment.tsx +98 -0
- package/src/lib/components/atoms/button-segment/buttonSegment.classes.ts +24 -0
- package/src/lib/components/atoms/button-segment/buttonSegment.enums.ts +7 -0
- package/src/lib/components/atoms/button-segment/index.ts +5 -0
- package/src/lib/components/atoms/checkbox/Checkbox.tsx +124 -0
- package/src/lib/components/atoms/checkbox/index.ts +4 -0
- package/src/lib/components/atoms/divider/Divider.tsx +48 -0
- package/src/lib/components/atoms/divider/divider.classes.ts +11 -0
- package/src/lib/components/atoms/divider/divider.enums.ts +7 -0
- package/src/lib/components/atoms/divider/index.ts +6 -0
- package/src/lib/components/atoms/header/Header.tsx +73 -0
- package/src/lib/components/atoms/header/index.ts +4 -0
- package/src/lib/components/atoms/image/Image.tsx +32 -0
- package/src/lib/components/atoms/image/index.ts +4 -0
- package/src/lib/components/atoms/index.ts +26 -0
- package/src/lib/components/atoms/info-box/InfoBox.tsx +68 -0
- package/src/lib/components/atoms/info-box/index.ts +5 -0
- package/src/lib/components/atoms/info-box/infoBox.classes.ts +18 -0
- package/src/lib/components/atoms/info-box/infoBox.enums.ts +14 -0
- package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +157 -0
- package/src/lib/components/atoms/key-value-info/index.ts +6 -0
- package/src/lib/components/atoms/key-value-info/keyValue.enums.ts +7 -0
- package/src/lib/components/atoms/label-text/LabelText.tsx +92 -0
- package/src/lib/components/atoms/label-text/index.ts +5 -0
- package/src/lib/components/atoms/label-text/labelText.classes.ts +22 -0
- package/src/lib/components/atoms/label-text/labelText.enums.ts +8 -0
- package/src/lib/components/atoms/list-item/ListItem.tsx +88 -0
- package/src/lib/components/atoms/list-item/index.ts +4 -0
- package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +38 -0
- package/src/lib/components/atoms/loading-indicator/index.ts +4 -0
- package/src/lib/components/atoms/media-fallback/MediaFallback.tsx +12 -0
- package/src/lib/components/atoms/media-fallback/index.ts +4 -0
- package/src/lib/components/atoms/panel/Panel.tsx +28 -0
- package/src/lib/components/atoms/panel/index.ts +4 -0
- package/src/lib/components/atoms/placeholder/Placeholder.tsx +27 -0
- package/src/lib/components/atoms/placeholder/index.ts +4 -0
- package/src/lib/components/atoms/radio-button/RadioButton.tsx +64 -0
- package/src/lib/components/atoms/radio-button/index.ts +4 -0
- package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +29 -0
- package/src/lib/components/atoms/secondary-text/index.ts +4 -0
- package/src/lib/components/atoms/skeleton/Skeleton.tsx +30 -0
- package/src/lib/components/atoms/skeleton/index.ts +4 -0
- package/src/lib/components/atoms/snackbar/Snackbar.tsx +69 -0
- package/src/lib/components/atoms/snackbar/index.ts +5 -0
- package/src/lib/components/atoms/snackbar/snackbar.classes.ts +18 -0
- package/src/lib/components/atoms/snackbar/snackbar.enums.tsx +9 -0
- package/src/lib/components/atoms/toggle/Toggle.tsx +140 -0
- package/src/lib/components/atoms/toggle/index.ts +6 -0
- package/src/lib/components/atoms/toggle/toggle.classes.ts +41 -0
- package/src/lib/components/atoms/toggle/toggle.enums.ts +12 -0
- package/src/lib/components/atoms/tooltip/Tooltip.tsx +139 -0
- package/src/lib/components/atoms/tooltip/index.ts +5 -0
- package/src/lib/components/atoms/tooltip/tooltip.classes.ts +11 -0
- package/src/lib/components/atoms/tooltip/tooltip.enums.ts +9 -0
- package/src/lib/components/atoms/video/Video.tsx +33 -0
- package/src/lib/components/atoms/video/index.ts +4 -0
- package/src/lib/components/atoms/video/video.constants.ts +31 -0
- package/src/lib/components/index.ts +6 -0
- package/src/lib/components/molecules/account/Account.tsx +195 -0
- package/src/lib/components/molecules/account/index.ts +4 -0
- package/src/lib/components/molecules/address/Address.tsx +101 -0
- package/src/lib/components/molecules/address/index.ts +4 -0
- package/src/lib/components/molecules/asset-media-renderer/AssetMediaRenderer.tsx +50 -0
- package/src/lib/components/molecules/asset-media-renderer/index.ts +4 -0
- package/src/lib/components/molecules/card/Card.tsx +70 -0
- package/src/lib/components/molecules/card/CardAction.tsx +78 -0
- package/src/lib/components/molecules/card/CardBody.tsx +73 -0
- package/src/lib/components/molecules/card/CardImage.tsx +43 -0
- package/src/lib/components/molecules/card/CardImagePlaceholder.tsx +146 -0
- package/src/lib/components/molecules/card/card.classes.ts +27 -0
- package/src/lib/components/molecules/card/card.enums.ts +26 -0
- package/src/lib/components/molecules/card/index.ts +8 -0
- package/src/lib/components/molecules/chip/Chip.tsx +146 -0
- package/src/lib/components/molecules/chip/chip.classes.ts +54 -0
- package/src/lib/components/molecules/chip/chip.enums.ts +15 -0
- package/src/lib/components/molecules/chip/index.ts +5 -0
- package/src/lib/components/molecules/display-stats/DisplayStats.tsx +142 -0
- package/src/lib/components/molecules/display-stats/displayStats.classes.ts +36 -0
- package/src/lib/components/molecules/display-stats/displayStats.enums.ts +13 -0
- package/src/lib/components/molecules/display-stats/index.ts +5 -0
- package/src/lib/components/molecules/dropdown/Dropdown.tsx +10 -0
- package/src/lib/components/molecules/dropdown/dropdownPosition.enums.ts +7 -0
- package/src/lib/components/molecules/dropdown/index.ts +5 -0
- package/src/lib/components/molecules/index.ts +19 -0
- package/src/lib/components/molecules/input/Input.tsx +261 -0
- package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
- package/src/lib/components/molecules/input/TextArea.tsx +148 -0
- package/src/lib/components/molecules/input/index.ts +8 -0
- package/src/lib/components/molecules/input/input.classes.ts +13 -0
- package/src/lib/components/molecules/input/input.enums.ts +14 -0
- package/src/lib/components/molecules/input/input.types.ts +29 -0
- package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +47 -0
- package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +65 -0
- package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +54 -0
- package/src/lib/components/molecules/navbar-item/index.ts +5 -0
- package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +16 -0
- package/src/lib/components/molecules/navbar-item/navbarItem.enums.ts +7 -0
- package/src/lib/components/molecules/search/Search.tsx +219 -0
- package/src/lib/components/molecules/search/index.ts +5 -0
- package/src/lib/components/molecules/search/search.classes.ts +20 -0
- package/src/lib/components/molecules/search/search.enums.ts +7 -0
- package/src/lib/components/molecules/segmented-button/SegmentedButton.tsx +38 -0
- package/src/lib/components/molecules/segmented-button/index.ts +6 -0
- package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +12 -0
- package/src/lib/components/molecules/segmented-button/segmentedButton.enums.ts +8 -0
- package/src/lib/components/molecules/select/Select.tsx +235 -0
- package/src/lib/components/molecules/select/index.ts +5 -0
- package/src/lib/components/molecules/select/select.enums.ts +7 -0
- package/src/lib/components/molecules/table-cell/TableCell.tsx +62 -0
- package/src/lib/components/molecules/table-cell/index.ts +4 -0
- package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +140 -0
- package/src/lib/components/molecules/table-header-cell/index.ts +5 -0
- package/src/lib/components/molecules/table-header-cell/tableHeaderCell.enums.ts +7 -0
- package/src/lib/components/molecules/title/Title.tsx +78 -0
- package/src/lib/components/molecules/title/index.ts +5 -0
- package/src/lib/components/molecules/title/titleClasses.constants.ts +14 -0
- package/src/lib/components/molecules/title/titleSize.enums.ts +7 -0
- package/src/lib/components/molecules/visual-asset-card/VisualAssetCard.tsx +89 -0
- package/src/lib/components/molecules/visual-asset-card/index.ts +5 -0
- package/src/lib/components/molecules/visual-asset-card/visualAssetCard.enums.ts +7 -0
- package/src/lib/components/organisms/accordion/Accordion.tsx +108 -0
- package/src/lib/components/organisms/accordion/accordion.classes.ts +4 -0
- package/src/lib/components/organisms/accordion/index.ts +4 -0
- package/src/lib/components/organisms/dialog/Dialog.tsx +157 -0
- package/src/lib/components/organisms/dialog/dialog.enums.ts +7 -0
- package/src/lib/components/organisms/dialog/index.ts +5 -0
- package/src/lib/components/organisms/index.ts +7 -0
- package/src/lib/components/organisms/navbar/Navbar.tsx +101 -0
- package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +59 -0
- package/src/lib/components/organisms/navbar/index.ts +5 -0
- package/src/lib/components/organisms/table/Table.tsx +234 -0
- package/src/lib/components/organisms/table/TableContext.tsx +56 -0
- package/src/lib/components/organisms/table/index.ts +4 -0
- package/src/lib/constants/colors.constants.ts +239 -0
- package/src/lib/constants/index.ts +4 -0
- package/src/lib/enums/index.ts +5 -0
- package/src/lib/enums/screenSize.enums.ts +9 -0
- package/src/lib/enums/theme.enums.ts +8 -0
- package/src/lib/index.ts +10 -0
- package/src/lib/styles/base.css +144 -0
- package/src/lib/styles/components.css +735 -0
- package/src/lib/styles/fonts.css +7 -0
- package/src/lib/styles/index.css +18 -0
- package/src/lib/styles/utilities.css +61 -0
- package/src/lib/styles/variables/dark-variables.css +262 -0
- package/src/lib/styles/variables/general-variables.css +9 -0
- package/src/lib/styles/variables/light-variables.css +276 -0
- package/src/lib/styles/variables/names-variables.css +270 -0
- package/src/lib/tailwind/base.presets.ts +58 -0
- package/src/lib/tailwind/constants/customColors.constants.ts +13 -0
- package/src/lib/tailwind/constants/fontFamily.constants.ts +8 -0
- package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
- package/src/lib/tailwind/constants/gradients.constants.ts +6 -0
- package/src/lib/tailwind/constants/index.ts +7 -0
- package/src/lib/tailwind/constants/scaling.constants.ts +41 -0
- package/src/lib/tailwind/constants/variableSpacing.constants.ts +66 -0
- package/src/lib/tailwind/helpers.ts +20 -0
- package/src/lib/tailwind/index.ts +5 -0
- package/src/lib/tailwind/plugins.ts +12 -0
- package/src/lib/tailwind/responsive.presets.ts +36 -0
- package/src/lib/tailwind/static.presets.ts +25 -0
- package/src/lib/tailwind/types.ts +6 -0
- package/src/lib/utils/format.ts +8 -0
- package/src/lib/utils/index.ts +4 -0
- package/src/storybook/blocks/Showcase.tsx +20 -0
- package/src/storybook/blocks/TypeSet.tsx +34 -0
- package/src/storybook/blocks/TypeSetItem.tsx +74 -0
- package/src/storybook/blocks/index.ts +6 -0
- package/src/storybook/constants/gradients.constants.ts +8 -0
- package/src/storybook/constants/index.ts +5 -0
- package/src/storybook/constants/typeset.constants.ts +39 -0
- package/src/storybook/constants/variableSpacing.constants.ts +6 -0
- package/src/storybook/helpers/formatGradientNames.ts +15 -0
- package/src/storybook/helpers/getFontSizeLabel.ts +15 -0
- package/src/storybook/helpers/index.ts +4 -0
- package/src/storybook/stories/atoms/Badge.stories.tsx +32 -0
- package/src/storybook/stories/atoms/Button.stories.tsx +45 -0
- package/src/storybook/stories/atoms/ButtonSegment.stories.tsx +45 -0
- package/src/storybook/stories/atoms/Checkbox.stories.tsx +34 -0
- package/src/storybook/stories/atoms/CustomScrollbar.stories.tsx +22 -0
- package/src/storybook/stories/atoms/Divider.stories.tsx +41 -0
- package/src/storybook/stories/atoms/Header.stories.tsx +58 -0
- package/src/storybook/stories/atoms/InfoBox.stories.tsx +67 -0
- package/src/storybook/stories/atoms/KeyValueInfo.stories.tsx +59 -0
- package/src/storybook/stories/atoms/LabelText.stories.tsx +55 -0
- package/src/storybook/stories/atoms/ListItem.stories.tsx +41 -0
- package/src/storybook/stories/atoms/LoadingIndicator.stories.tsx +32 -0
- package/src/storybook/stories/atoms/Panel.stories.tsx +36 -0
- package/src/storybook/stories/atoms/Placeholder.stories.tsx +33 -0
- package/src/storybook/stories/atoms/RadioButton.stories.tsx +51 -0
- package/src/storybook/stories/atoms/Skeleton.stories.tsx +33 -0
- package/src/storybook/stories/atoms/Snackbar.stories.tsx +43 -0
- package/src/storybook/stories/atoms/Toggle.stories.tsx +59 -0
- package/src/storybook/stories/atoms/Tooltip.stories.tsx +59 -0
- package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +57 -0
- package/src/storybook/stories/components/DocsSyncTheme.tsx +20 -0
- package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
- package/src/storybook/stories/components/index.ts +5 -0
- package/src/storybook/stories/design-tokens/colors.stories.mdx +44 -0
- package/src/storybook/stories/design-tokens/icons.stories.mdx +19 -0
- package/src/storybook/stories/design-tokens/typeset.stories.mdx +17 -0
- package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +11 -0
- package/src/storybook/stories/molecules/Account.stories.tsx +71 -0
- package/src/storybook/stories/molecules/Address.stories.tsx +39 -0
- package/src/storybook/stories/molecules/Card.stories.tsx +112 -0
- package/src/storybook/stories/molecules/Chip.stories.tsx +127 -0
- package/src/storybook/stories/molecules/DisplayStats.stories.tsx +63 -0
- package/src/storybook/stories/molecules/Dropdown.stories.tsx +38 -0
- package/src/storybook/stories/molecules/Input.stories.tsx +239 -0
- package/src/storybook/stories/molecules/NavbarItem.stories.tsx +45 -0
- package/src/storybook/stories/molecules/Search.stories.tsx +101 -0
- package/src/storybook/stories/molecules/SegmentedButton.stories.tsx +108 -0
- package/src/storybook/stories/molecules/Select.stories.tsx +103 -0
- package/src/storybook/stories/molecules/TableCell.stories.tsx +46 -0
- package/src/storybook/stories/molecules/TableHeaderCell.stories.tsx +34 -0
- package/src/storybook/stories/molecules/TextArea.stories.tsx +80 -0
- package/src/storybook/stories/molecules/Title.stories.tsx +76 -0
- package/src/storybook/stories/organisms/Accordion.stories.tsx +70 -0
- package/src/storybook/stories/organisms/Dialog.stories.tsx +129 -0
- package/src/storybook/stories/organisms/Navbar.stories.tsx +78 -0
- package/src/storybook/stories/organisms/Table.stories.tsx +154 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import type { PropsWithChildren } from 'react';
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import { Placeholder } from '@/components/atoms';
|
|
6
|
+
|
|
7
|
+
interface TableCellBaseProps {
|
|
8
|
+
/**
|
|
9
|
+
* The label of the cell.
|
|
10
|
+
*/
|
|
11
|
+
label?: string;
|
|
12
|
+
/**
|
|
13
|
+
* If the cell is the last in the row and should not have a border.
|
|
14
|
+
*/
|
|
15
|
+
hasLastBorderNoneClass?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the cell content should be centered.
|
|
18
|
+
*/
|
|
19
|
+
isContentCentered?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function TableCellBase({
|
|
23
|
+
children,
|
|
24
|
+
hasLastBorderNoneClass,
|
|
25
|
+
isContentCentered,
|
|
26
|
+
}: PropsWithChildren<TableCellBaseProps>) {
|
|
27
|
+
return (
|
|
28
|
+
<td
|
|
29
|
+
className={cx(
|
|
30
|
+
'table-cell-border-color h-14 border-b px-md',
|
|
31
|
+
{ 'last:border-none': hasLastBorderNoneClass },
|
|
32
|
+
{ 'flex items-center justify-center': isContentCentered },
|
|
33
|
+
)}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</td>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface TableCellTextProps {
|
|
41
|
+
supportingLabel?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function TableCellText({
|
|
45
|
+
children,
|
|
46
|
+
supportingLabel,
|
|
47
|
+
}: PropsWithChildren<TableCellTextProps>) {
|
|
48
|
+
return (
|
|
49
|
+
<div className="flex flex-row items-baseline gap-1">
|
|
50
|
+
<span>{children}</span>
|
|
51
|
+
{supportingLabel && (
|
|
52
|
+
<span className="table-cell-supporting-label-color text-body-sm">
|
|
53
|
+
{supportingLabel}
|
|
54
|
+
</span>
|
|
55
|
+
)}
|
|
56
|
+
</div>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function TableCellPlaceholder() {
|
|
61
|
+
return <Placeholder />;
|
|
62
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { SortByDown, SortByUp } from '@iota/apps-ui-icons';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { Checkbox } from '@/components/atoms/checkbox';
|
|
7
|
+
import { TableHeaderCellSortOrder } from './tableHeaderCell.enums';
|
|
8
|
+
|
|
9
|
+
export interface TableHeaderCellProps {
|
|
10
|
+
/**
|
|
11
|
+
* The column key.
|
|
12
|
+
*/
|
|
13
|
+
columnKey: string | number;
|
|
14
|
+
/**
|
|
15
|
+
* The label of the Header cell.
|
|
16
|
+
*/
|
|
17
|
+
label?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Action component to be rendered on the left side.
|
|
20
|
+
*/
|
|
21
|
+
actionLeft?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* Action component to be rendered on the right side.
|
|
24
|
+
*/
|
|
25
|
+
actionRight?: React.ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Has Sort icon.
|
|
28
|
+
*/
|
|
29
|
+
hasSort?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* On Sort icon click.
|
|
32
|
+
*/
|
|
33
|
+
onSortClick?: (columnKey: string | number, sortOrder: TableHeaderCellSortOrder) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Has Checkbox.
|
|
36
|
+
*/
|
|
37
|
+
hasCheckbox?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Is Checkbox checked.
|
|
40
|
+
*/
|
|
41
|
+
isChecked?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Is Checkbox indeterminate.
|
|
44
|
+
*/
|
|
45
|
+
isIndeterminate?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* On Checkbox change.
|
|
48
|
+
*/
|
|
49
|
+
onCheckboxChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the cell content should be centered.
|
|
52
|
+
*/
|
|
53
|
+
isContentCentered?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Sort order when cell is initialized
|
|
56
|
+
*/
|
|
57
|
+
sortOrder?: TableHeaderCellSortOrder;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function TableHeaderCell({
|
|
61
|
+
label,
|
|
62
|
+
columnKey,
|
|
63
|
+
hasSort,
|
|
64
|
+
hasCheckbox,
|
|
65
|
+
isChecked,
|
|
66
|
+
isIndeterminate,
|
|
67
|
+
isContentCentered,
|
|
68
|
+
onSortClick,
|
|
69
|
+
onCheckboxChange,
|
|
70
|
+
sortOrder,
|
|
71
|
+
}: TableHeaderCellProps): JSX.Element {
|
|
72
|
+
const handleSort = () => {
|
|
73
|
+
const newSortOrder =
|
|
74
|
+
sortOrder === TableHeaderCellSortOrder.Asc
|
|
75
|
+
? TableHeaderCellSortOrder.Desc
|
|
76
|
+
: TableHeaderCellSortOrder.Asc;
|
|
77
|
+
if (onSortClick) {
|
|
78
|
+
onSortClick(columnKey, newSortOrder);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const textColorClass = 'table-header-text-color';
|
|
83
|
+
const textSizeClass = 'text-label-lg';
|
|
84
|
+
|
|
85
|
+
const sortElement = (() => {
|
|
86
|
+
if (!hasSort) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (sortOrder === TableHeaderCellSortOrder.Asc) {
|
|
91
|
+
return <SortByUp className="shrink-0" />;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (sortOrder === TableHeaderCellSortOrder.Desc) {
|
|
95
|
+
return <SortByDown className="shrink-0" />;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return <SortByUp className="invisible shrink-0 group-hover:visible" />;
|
|
99
|
+
})();
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<th
|
|
103
|
+
onClick={hasSort ? handleSort : undefined}
|
|
104
|
+
className={cx(
|
|
105
|
+
'state-layer table-cell-border-color group relative h-14 border-b px-md after:pointer-events-none',
|
|
106
|
+
{
|
|
107
|
+
'cursor-pointer': hasSort,
|
|
108
|
+
},
|
|
109
|
+
)}
|
|
110
|
+
>
|
|
111
|
+
<div
|
|
112
|
+
className={cx(
|
|
113
|
+
'flex flex-row items-center gap-1 [&_svg]:h-4 [&_svg]:w-4',
|
|
114
|
+
textColorClass,
|
|
115
|
+
textSizeClass,
|
|
116
|
+
{
|
|
117
|
+
'justify-center': isContentCentered,
|
|
118
|
+
},
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{hasCheckbox ? (
|
|
122
|
+
<Checkbox
|
|
123
|
+
isChecked={isChecked}
|
|
124
|
+
isIndeterminate={isIndeterminate}
|
|
125
|
+
onCheckedChange={onCheckboxChange}
|
|
126
|
+
/>
|
|
127
|
+
) : (
|
|
128
|
+
<span
|
|
129
|
+
className={cx({
|
|
130
|
+
'text-left': !isContentCentered,
|
|
131
|
+
})}
|
|
132
|
+
>
|
|
133
|
+
{label}
|
|
134
|
+
</span>
|
|
135
|
+
)}
|
|
136
|
+
{sortElement}
|
|
137
|
+
</div>
|
|
138
|
+
</th>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { TooltipPosition } from '@/components/atoms';
|
|
5
|
+
import { Tooltip } from '@/components/atoms';
|
|
6
|
+
import { Info } from '@iota/apps-ui-icons';
|
|
7
|
+
import { TitleSize } from './titleSize.enums';
|
|
8
|
+
import cx from 'classnames';
|
|
9
|
+
import { TITLE_PADDINGS, TITLE_SIZE } from './titleClasses.constants';
|
|
10
|
+
|
|
11
|
+
interface TitleProps {
|
|
12
|
+
/**
|
|
13
|
+
* The title of the component.
|
|
14
|
+
*/
|
|
15
|
+
title: string;
|
|
16
|
+
/**
|
|
17
|
+
* The subtitle of the component.
|
|
18
|
+
*/
|
|
19
|
+
subtitle?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The trailing element.
|
|
22
|
+
*/
|
|
23
|
+
trailingElement?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* The tooltip position.
|
|
26
|
+
*/
|
|
27
|
+
tooltipPosition?: TooltipPosition;
|
|
28
|
+
/**
|
|
29
|
+
* The tooltip text.
|
|
30
|
+
*/
|
|
31
|
+
tooltipText?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Supporting Element
|
|
34
|
+
*/
|
|
35
|
+
supportingElement?: React.ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* The size of the component
|
|
38
|
+
*/
|
|
39
|
+
size?: TitleSize;
|
|
40
|
+
/**
|
|
41
|
+
* The 'data-testid' attribute value (used in e2e tests)
|
|
42
|
+
*/
|
|
43
|
+
testId?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function Title({
|
|
47
|
+
title,
|
|
48
|
+
subtitle,
|
|
49
|
+
trailingElement,
|
|
50
|
+
tooltipText,
|
|
51
|
+
supportingElement,
|
|
52
|
+
tooltipPosition,
|
|
53
|
+
size = TitleSize.Medium,
|
|
54
|
+
testId,
|
|
55
|
+
}: TitleProps) {
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
className={cx('flex flex-row items-center justify-between', TITLE_PADDINGS[size])}
|
|
59
|
+
data-testid={testId}
|
|
60
|
+
>
|
|
61
|
+
<div className="flex flex-row items-center gap-x-xxxs">
|
|
62
|
+
<div className="flex flex-col justify-start">
|
|
63
|
+
<div className="title-main-color flex flex-row items-center gap-x-0.5">
|
|
64
|
+
<h4 className={cx(TITLE_SIZE[size])}>{title}</h4>
|
|
65
|
+
{tooltipText && (
|
|
66
|
+
<Tooltip text={tooltipText} position={tooltipPosition}>
|
|
67
|
+
<Info className="title-icon-color" />
|
|
68
|
+
</Tooltip>
|
|
69
|
+
)}
|
|
70
|
+
</div>
|
|
71
|
+
<p className="title-subtitle-color text-label-md">{subtitle}</p>
|
|
72
|
+
</div>
|
|
73
|
+
{supportingElement}
|
|
74
|
+
</div>
|
|
75
|
+
{trailingElement}
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { TitleSize } from './titleSize.enums';
|
|
5
|
+
|
|
6
|
+
export const TITLE_PADDINGS: Record<TitleSize, string> = {
|
|
7
|
+
[TitleSize.Small]: 'px-md py-sm--rs',
|
|
8
|
+
[TitleSize.Medium]: 'px-md--rs py-sm--rs',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const TITLE_SIZE: Record<TitleSize, string> = {
|
|
12
|
+
[TitleSize.Small]: 'text-title-md',
|
|
13
|
+
[TitleSize.Medium]: 'text-title-lg',
|
|
14
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonUnstyled } from '../../atoms/button';
|
|
5
|
+
import { MoreHoriz } from '@iota/apps-ui-icons';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
import { AssetMediaRenderer } from '../../molecules/asset-media-renderer';
|
|
8
|
+
import type { AssetMediaRendererProps } from '../../molecules/asset-media-renderer';
|
|
9
|
+
|
|
10
|
+
interface VisualAssetBaseProps {
|
|
11
|
+
/**
|
|
12
|
+
* The onClick event for the icon.
|
|
13
|
+
*/
|
|
14
|
+
onIconClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
15
|
+
/**
|
|
16
|
+
* The onClick event for the card.
|
|
17
|
+
*/
|
|
18
|
+
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
19
|
+
/**
|
|
20
|
+
* The icon to be displayed.
|
|
21
|
+
*/
|
|
22
|
+
icon?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The title text to be displayed on hover.
|
|
25
|
+
*/
|
|
26
|
+
assetTitle?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the card is hoverable.
|
|
29
|
+
*/
|
|
30
|
+
isHoverable?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface CustomAssetDisplayProps {
|
|
34
|
+
/**
|
|
35
|
+
* The media to be displayed inside the card.
|
|
36
|
+
*/
|
|
37
|
+
renderAsset?: React.ReactNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type VisualAssetCardProps = VisualAssetBaseProps &
|
|
41
|
+
(AssetMediaRendererProps | CustomAssetDisplayProps);
|
|
42
|
+
|
|
43
|
+
export function VisualAssetCard({
|
|
44
|
+
onIconClick,
|
|
45
|
+
onClick,
|
|
46
|
+
icon = <MoreHoriz />,
|
|
47
|
+
assetTitle,
|
|
48
|
+
isHoverable = true,
|
|
49
|
+
...assetProps
|
|
50
|
+
}: VisualAssetBaseProps & (AssetMediaRendererProps | CustomAssetDisplayProps)): React.JSX.Element {
|
|
51
|
+
const handleIconClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
52
|
+
onIconClick?.(event);
|
|
53
|
+
event?.stopPropagation();
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const isCustomAsset = !('src' in assetProps);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
className={cx('relative aspect-square w-full overflow-hidden rounded-xl', {
|
|
61
|
+
'group cursor-pointer': isHoverable,
|
|
62
|
+
})}
|
|
63
|
+
onClick={onClick}
|
|
64
|
+
>
|
|
65
|
+
{!isCustomAsset && <AssetMediaRenderer {...assetProps} />}
|
|
66
|
+
|
|
67
|
+
{isCustomAsset && assetProps.renderAsset}
|
|
68
|
+
|
|
69
|
+
{isHoverable && (
|
|
70
|
+
<div className="absolute left-0 top-0 h-full w-full bg-cover bg-center bg-no-repeat group-hover:bg-shader-neutral-light-48 group-hover:transition group-hover:duration-300 group-hover:ease-in-out group-hover:names:bg-shader-inverted-light-48 group-hover:dark:bg-shader-primary-dark-48" />
|
|
71
|
+
)}
|
|
72
|
+
{isHoverable && onIconClick && (
|
|
73
|
+
<ButtonUnstyled
|
|
74
|
+
className="visual-asset-icon-color absolute right-2 top-2 z-10 h-9 w-9 cursor-pointer rounded-full p-xs opacity-0 transition-opacity duration-300 group-hover:bg-shader-neutral-light-72 group-hover:opacity-100 [&_svg]:h-5 [&_svg]:w-5"
|
|
75
|
+
onClick={handleIconClick}
|
|
76
|
+
>
|
|
77
|
+
{icon}
|
|
78
|
+
</ButtonUnstyled>
|
|
79
|
+
)}
|
|
80
|
+
{isHoverable && assetTitle && (
|
|
81
|
+
<div className="absolute bottom-0 w-full p-xs opacity-0 transition-opacity duration-300 group-hover:opacity-100">
|
|
82
|
+
<span className="visual-asset-title-color break-words text-title-md">
|
|
83
|
+
{assetTitle}
|
|
84
|
+
</span>
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { PropsWithChildren } from 'react';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { ArrowDown } from '@iota/apps-ui-icons';
|
|
7
|
+
import { Button, ButtonType } from '@/components/atoms';
|
|
8
|
+
import { ICON_STYLE } from './accordion.classes';
|
|
9
|
+
|
|
10
|
+
export interface AccordionHeaderProps {
|
|
11
|
+
/**
|
|
12
|
+
* Flag for show/hide content
|
|
13
|
+
*/
|
|
14
|
+
isExpanded: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Action on toggle show/hide content
|
|
18
|
+
*/
|
|
19
|
+
onToggle: () => void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The type of the badge.
|
|
23
|
+
*/
|
|
24
|
+
badge?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Flag for hiding arrow.
|
|
27
|
+
*/
|
|
28
|
+
hideArrow?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Flag for hiding border.
|
|
31
|
+
*/
|
|
32
|
+
hideBorder?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface AccordionContentProps {
|
|
36
|
+
/**
|
|
37
|
+
* Flag for show/hide content
|
|
38
|
+
*/
|
|
39
|
+
isExpanded: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function AccordionHeader({
|
|
43
|
+
onToggle,
|
|
44
|
+
children,
|
|
45
|
+
isExpanded,
|
|
46
|
+
hideArrow,
|
|
47
|
+
}: PropsWithChildren<AccordionHeaderProps>) {
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
onClick={onToggle}
|
|
51
|
+
className={cx(
|
|
52
|
+
'state-layer relative flex cursor-pointer items-center justify-between gap-md overflow-hidden rounded-xl py-sm--rs',
|
|
53
|
+
{
|
|
54
|
+
'pr-md--rs': !hideArrow,
|
|
55
|
+
},
|
|
56
|
+
)}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
{!hideArrow && (
|
|
60
|
+
<div className="[&_svg]:h-5 [&_svg]:w-5">
|
|
61
|
+
<Button
|
|
62
|
+
type={ButtonType.Ghost}
|
|
63
|
+
icon={
|
|
64
|
+
<ArrowDown
|
|
65
|
+
className={cx(ICON_STYLE, {
|
|
66
|
+
'rotate-180': isExpanded,
|
|
67
|
+
})}
|
|
68
|
+
/>
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function AccordionContent({
|
|
78
|
+
isExpanded,
|
|
79
|
+
children,
|
|
80
|
+
}: PropsWithChildren<AccordionContentProps>) {
|
|
81
|
+
return (
|
|
82
|
+
<div
|
|
83
|
+
className={cx({
|
|
84
|
+
hidden: !isExpanded,
|
|
85
|
+
})}
|
|
86
|
+
>
|
|
87
|
+
{children}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function Accordion({
|
|
93
|
+
children,
|
|
94
|
+
hideBorder,
|
|
95
|
+
}: {
|
|
96
|
+
children: React.ReactNode;
|
|
97
|
+
hideBorder?: boolean;
|
|
98
|
+
}): React.JSX.Element {
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
className={cx('accordion-bg rounded-xl', {
|
|
102
|
+
'accordion-border-color border': !hideBorder,
|
|
103
|
+
})}
|
|
104
|
+
>
|
|
105
|
+
{children}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|