@iota/apps-ui-kit 0.0.0-experimental-20250613144451
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 +106 -0
- package/LICENSE +201 -0
- package/README.md +16 -0
- package/dist/index.d.ts +1726 -0
- package/dist/index.es.js +6923 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +118 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +75 -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 +99 -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 +45 -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 +114 -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/index.ts +23 -0
- package/src/lib/components/atoms/info-box/InfoBox.tsx +74 -0
- package/src/lib/components/atoms/info-box/index.ts +5 -0
- package/src/lib/components/atoms/info-box/infoBox.classes.ts +19 -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 +94 -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 +89 -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/panel/Panel.tsx +30 -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 +68 -0
- package/src/lib/components/atoms/radio-button/index.ts +4 -0
- package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +28 -0
- package/src/lib/components/atoms/secondary-text/index.ts +4 -0
- package/src/lib/components/atoms/skeleton/Skeleton.tsx +47 -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 +138 -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/visual-asset-card/VisualAssetCard.tsx +101 -0
- package/src/lib/components/atoms/visual-asset-card/index.ts +5 -0
- package/src/lib/components/atoms/visual-asset-card/visualAssetCard.enums.ts +7 -0
- package/src/lib/components/index.ts +8 -0
- package/src/lib/components/molecules/account/Account.tsx +192 -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/card/Card.tsx +70 -0
- package/src/lib/components/molecules/card/CardAction.tsx +80 -0
- package/src/lib/components/molecules/card/CardBody.tsx +72 -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 +105 -0
- package/src/lib/components/molecules/chip/chip.classes.ts +32 -0
- package/src/lib/components/molecules/chip/chip.enums.ts +7 -0
- package/src/lib/components/molecules/chip/index.ts +4 -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 +17 -0
- package/src/lib/components/molecules/input/Input.tsx +246 -0
- package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
- package/src/lib/components/molecules/input/TextArea.tsx +150 -0
- package/src/lib/components/molecules/input/index.ts +8 -0
- package/src/lib/components/molecules/input/input.classes.ts +14 -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 +48 -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 +216 -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 +222 -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/organisms/accordion/Accordion.tsx +109 -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 +142 -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 +133 -0
- package/src/lib/constants/index.ts +4 -0
- package/src/lib/enums/index.ts +4 -0
- package/src/lib/enums/screenSize.enums.ts +9 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/styles/fonts.css +5 -0
- package/src/lib/styles/index.css +149 -0
- package/src/lib/tailwind/base.presets.ts +49 -0
- package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
- package/src/lib/tailwind/constants/index.ts +6 -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 +8 -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/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/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 +57 -0
- package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +56 -0
- package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
- package/src/storybook/stories/components/index.ts +4 -0
- package/src/storybook/stories/design-tokens/colors.stories.mdx +23 -0
- package/src/storybook/stories/design-tokens/icons.stories.mdx +17 -0
- package/src/storybook/stories/design-tokens/typeset.stories.mdx +15 -0
- package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +10 -0
- package/src/storybook/stories/molecules/Account.stories.tsx +69 -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 +122 -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 +162 -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 +103 -0
- package/src/storybook/stories/organisms/Navbar.stories.tsx +78 -0
- package/src/storybook/stories/organisms/Table.stories.tsx +154 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { Dash, Checkmark } from '@iota/apps-ui-icons';
|
|
7
|
+
|
|
8
|
+
interface CheckboxProps {
|
|
9
|
+
/**
|
|
10
|
+
* The label of the checkbox.
|
|
11
|
+
*/
|
|
12
|
+
label?: string | React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* The state of the checkbox.
|
|
15
|
+
*/
|
|
16
|
+
isChecked?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* If true the checkbox will override the styles to show an indeterminate state.
|
|
19
|
+
*/
|
|
20
|
+
isIndeterminate?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the label should be placed before the checkbox.
|
|
23
|
+
*/
|
|
24
|
+
isLabelFirst?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* If true the checkbox will be disabled.
|
|
27
|
+
*/
|
|
28
|
+
isDisabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The callback to call when the checkbox is clicked.
|
|
31
|
+
*/
|
|
32
|
+
onCheckedChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
33
|
+
/**
|
|
34
|
+
* The name of the checkbox.
|
|
35
|
+
*/
|
|
36
|
+
name?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
|
|
40
|
+
(
|
|
41
|
+
{
|
|
42
|
+
isChecked,
|
|
43
|
+
isIndeterminate,
|
|
44
|
+
label,
|
|
45
|
+
isLabelFirst,
|
|
46
|
+
isDisabled,
|
|
47
|
+
onCheckedChange,
|
|
48
|
+
name,
|
|
49
|
+
}: CheckboxProps,
|
|
50
|
+
ref,
|
|
51
|
+
) => {
|
|
52
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (inputRef.current) {
|
|
56
|
+
inputRef.current.indeterminate = isIndeterminate ?? false;
|
|
57
|
+
}
|
|
58
|
+
}, [isIndeterminate, inputRef]);
|
|
59
|
+
|
|
60
|
+
const CheckmarkIcon = isIndeterminate ? Dash : Checkmark;
|
|
61
|
+
|
|
62
|
+
function assignRefs(element: HTMLInputElement) {
|
|
63
|
+
if (ref) {
|
|
64
|
+
if (typeof ref === 'function') {
|
|
65
|
+
ref(element);
|
|
66
|
+
} else {
|
|
67
|
+
ref.current = element;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
inputRef.current = element;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div
|
|
75
|
+
className={cx('group inline-flex', isLabelFirst ? 'flex-row-reverse' : 'flex-row', {
|
|
76
|
+
disabled: isDisabled,
|
|
77
|
+
'gap-x-2': label,
|
|
78
|
+
})}
|
|
79
|
+
>
|
|
80
|
+
<input
|
|
81
|
+
id={name}
|
|
82
|
+
name={name}
|
|
83
|
+
type="checkbox"
|
|
84
|
+
className="peer hidden appearance-none"
|
|
85
|
+
checked={isChecked}
|
|
86
|
+
ref={assignRefs}
|
|
87
|
+
disabled={isDisabled}
|
|
88
|
+
onChange={(e) => {
|
|
89
|
+
onCheckedChange?.(e);
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
<span
|
|
93
|
+
onClick={() => inputRef.current?.click()}
|
|
94
|
+
className="peer-enabled:state-layer relative inset-0 flex h-5 w-5 items-center justify-center rounded border border-neutral-80 text-neutral-40 group-[.disabled]:cursor-not-allowed peer-disabled:text-neutral-70 peer-disabled:text-opacity-40 peer-disabled:opacity-40 peer-[&:is(:checked,:indeterminate)]:border-primary-30 peer-[&:is(:checked,:indeterminate)]:bg-primary-30 peer-[&:is(:checked,:indeterminate)]:text-white peer-[&:not(:checked,:indeterminate)]:text-opacity-40 disabled:peer-[&:not(:checked,:indeterminate)]:border-neutral-70 dark:border-neutral-20 dark:text-neutral-60 dark:peer-disabled:text-neutral-30 dark:peer-disabled:text-opacity-40 dark:peer-disabled:peer-[&:not(:checked,:indeterminate)]:border-neutral-30 dark:peer-disabled:peer-[&:is(:checked,:indeterminate)]:bg-neutral-40 peer-disabled:[&:is(:checked,:indeterminate)]:border-neutral-60 peer-disabled:[&:is(:checked,:indeterminate)]:bg-neutral-60 dark:peer-disabled:[&:is(:checked,:indeterminate)]:border-neutral-40 [&_svg]:h-4 [&_svg]:w-4 peer-[&:not(:checked,:indeterminate)]:[&_svg]:hidden"
|
|
95
|
+
>
|
|
96
|
+
<CheckmarkIcon />
|
|
97
|
+
</span>
|
|
98
|
+
|
|
99
|
+
<LabelText label={label} name={name} />
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
function LabelText({ label, name }: Pick<CheckboxProps, 'label' | 'name'>) {
|
|
106
|
+
return (
|
|
107
|
+
<label
|
|
108
|
+
htmlFor={name}
|
|
109
|
+
className="text-label-lg text-neutral-40 group-[.disabled]:cursor-not-allowed group-[.disabled]:text-opacity-40 dark:text-neutral-60 group-[.disabled]:dark:text-opacity-40"
|
|
110
|
+
>
|
|
111
|
+
{label}
|
|
112
|
+
</label>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { DividerType } from './divider.enums';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { BACKGROUND_COLORS, DIVIDER_FULL_WIDTH } from './divider.classes';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_LINE_HEIGHT = '1px';
|
|
9
|
+
|
|
10
|
+
interface DividerProps {
|
|
11
|
+
/**
|
|
12
|
+
* The type of the divider
|
|
13
|
+
*/
|
|
14
|
+
type?: DividerType;
|
|
15
|
+
/**
|
|
16
|
+
* The width of the divider.
|
|
17
|
+
*/
|
|
18
|
+
width?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The height of the divider.
|
|
21
|
+
*/
|
|
22
|
+
height?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The line height of the divider.
|
|
25
|
+
*/
|
|
26
|
+
lineHeight?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function Divider({
|
|
30
|
+
type = DividerType.Horizontal,
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
lineHeight = DEFAULT_LINE_HEIGHT,
|
|
34
|
+
}: DividerProps): React.JSX.Element {
|
|
35
|
+
// Set height and width of divider line based on type
|
|
36
|
+
const lineStyle = {
|
|
37
|
+
...(type === DividerType.Horizontal ? { height: lineHeight } : { width: lineHeight }),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let dividerSize = DIVIDER_FULL_WIDTH[type];
|
|
41
|
+
if (width && type === DividerType.Horizontal) {
|
|
42
|
+
dividerSize = width;
|
|
43
|
+
} else if (height && type === DividerType.Vertical) {
|
|
44
|
+
dividerSize = height;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return <div className={cx(BACKGROUND_COLORS, dividerSize)} style={lineStyle} />;
|
|
48
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { DividerType } from './divider.enums';
|
|
5
|
+
|
|
6
|
+
export const BACKGROUND_COLORS = 'bg-shader-neutral-light-8 dark:bg-shader-neutral-dark-8';
|
|
7
|
+
|
|
8
|
+
export const DIVIDER_FULL_WIDTH: Record<DividerType, string> = {
|
|
9
|
+
[DividerType.Horizontal]: 'w-full',
|
|
10
|
+
[DividerType.Vertical]: 'h-full',
|
|
11
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import { Button, ButtonSize, ButtonType } from '../button';
|
|
6
|
+
import { ArrowBack, Close } from '@iota/apps-ui-icons';
|
|
7
|
+
|
|
8
|
+
interface HeaderProps {
|
|
9
|
+
/**
|
|
10
|
+
* Header title.
|
|
11
|
+
*/
|
|
12
|
+
title: string;
|
|
13
|
+
/**
|
|
14
|
+
* Title alignment (optional).
|
|
15
|
+
*/
|
|
16
|
+
titleCentered?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* On back click handler (optional). If provided, a back button will be displayed.
|
|
19
|
+
*/
|
|
20
|
+
onBack?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* On close click handler (optional). If provided, a close button will be displayed.
|
|
23
|
+
*/
|
|
24
|
+
onClose?: (() => void) | ((e: React.MouseEvent<HTMLElement>) => void);
|
|
25
|
+
/**
|
|
26
|
+
* The 'data-testid' attribute value (used in e2e tests)
|
|
27
|
+
*/
|
|
28
|
+
testId?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function Header({
|
|
32
|
+
title,
|
|
33
|
+
titleCentered,
|
|
34
|
+
onBack,
|
|
35
|
+
onClose,
|
|
36
|
+
testId,
|
|
37
|
+
}: HeaderProps): JSX.Element {
|
|
38
|
+
const titleCenteredClasses = titleCentered ? 'text-center' : onBack ? 'ml-1' : '';
|
|
39
|
+
const keepSpaceForIcon = titleCentered && (!onBack || !onClose);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div className="flex min-h-[56px] w-full items-center bg-neutral-100 px-md--rs pb-xs pt-sm text-neutral-10 dark:bg-neutral-6 dark:text-neutral-92 [&_svg]:h-5 [&_svg]:w-5">
|
|
43
|
+
{onBack ? (
|
|
44
|
+
<Button
|
|
45
|
+
size={ButtonSize.Small}
|
|
46
|
+
type={ButtonType.Ghost}
|
|
47
|
+
onClick={onBack}
|
|
48
|
+
icon={<ArrowBack />}
|
|
49
|
+
/>
|
|
50
|
+
) : (
|
|
51
|
+
keepSpaceForIcon && <div className="w-9" />
|
|
52
|
+
)}
|
|
53
|
+
|
|
54
|
+
<div className={cx('flex-grow', titleCenteredClasses)}>
|
|
55
|
+
<span className="font-inter text-title-lg" data-testid={testId}>
|
|
56
|
+
{title}
|
|
57
|
+
</span>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{onClose ? (
|
|
61
|
+
<Button
|
|
62
|
+
size={ButtonSize.Small}
|
|
63
|
+
type={ButtonType.Ghost}
|
|
64
|
+
onClick={onClose}
|
|
65
|
+
icon={<Close />}
|
|
66
|
+
testId={`close-icon`}
|
|
67
|
+
/>
|
|
68
|
+
) : (
|
|
69
|
+
keepSpaceForIcon && <div className="w-9" />
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export * from './badge';
|
|
5
|
+
export * from './button';
|
|
6
|
+
export * from './radio-button';
|
|
7
|
+
export * from './button-segment';
|
|
8
|
+
export * from './button';
|
|
9
|
+
export * from './checkbox';
|
|
10
|
+
export * from './divider';
|
|
11
|
+
export * from './key-value-info';
|
|
12
|
+
export * from './label-text';
|
|
13
|
+
export * from './list-item';
|
|
14
|
+
export * from './header';
|
|
15
|
+
export * from './panel';
|
|
16
|
+
export * from './tooltip';
|
|
17
|
+
export * from './info-box';
|
|
18
|
+
export * from './snackbar';
|
|
19
|
+
export * from './visual-asset-card';
|
|
20
|
+
export * from './loading-indicator';
|
|
21
|
+
export * from './placeholder';
|
|
22
|
+
export * from './skeleton';
|
|
23
|
+
export * from './toggle';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import type { InfoBoxType } from './infoBox.enums';
|
|
6
|
+
import { InfoBoxStyle } from './infoBox.enums';
|
|
7
|
+
import { BACKGROUND_COLORS, ICON_COLORS } from './infoBox.classes';
|
|
8
|
+
|
|
9
|
+
export interface InfoBoxProps {
|
|
10
|
+
/**
|
|
11
|
+
* The icon of the info box (optional).
|
|
12
|
+
*/
|
|
13
|
+
icon?: React.ReactNode;
|
|
14
|
+
/**
|
|
15
|
+
* The title of the info box (optional).
|
|
16
|
+
*/
|
|
17
|
+
title?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The supporting text of the info box (optional).
|
|
20
|
+
*/
|
|
21
|
+
supportingText?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* The type of the info box.
|
|
24
|
+
*/
|
|
25
|
+
type: InfoBoxType;
|
|
26
|
+
/**
|
|
27
|
+
* The style of the info box.
|
|
28
|
+
*/
|
|
29
|
+
style?: InfoBoxStyle;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function InfoBox({
|
|
33
|
+
icon,
|
|
34
|
+
title,
|
|
35
|
+
supportingText,
|
|
36
|
+
type,
|
|
37
|
+
style,
|
|
38
|
+
}: InfoBoxProps): React.JSX.Element {
|
|
39
|
+
const iconColorClass = ICON_COLORS[type];
|
|
40
|
+
const backgroundClass = style === InfoBoxStyle.Elevated ? BACKGROUND_COLORS[type] : '';
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
className={cx('flex flex-row items-start gap-4 py-xs pr-lg', backgroundClass, {
|
|
44
|
+
'rounded-lg pl-xs': style === InfoBoxStyle.Elevated,
|
|
45
|
+
})}
|
|
46
|
+
>
|
|
47
|
+
{icon && (
|
|
48
|
+
<span
|
|
49
|
+
className={cx(
|
|
50
|
+
'flex items-center justify-center rounded-lg [&_svg]:h-4 [&_svg]:w-4',
|
|
51
|
+
iconColorClass,
|
|
52
|
+
{
|
|
53
|
+
'p-xs': style === InfoBoxStyle.Default,
|
|
54
|
+
},
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
{icon}
|
|
58
|
+
</span>
|
|
59
|
+
)}
|
|
60
|
+
<div className="flex flex-col gap-1">
|
|
61
|
+
{title && (
|
|
62
|
+
<span className="text-title-sm text-neutral-10 dark:text-neutral-92">
|
|
63
|
+
{title}
|
|
64
|
+
</span>
|
|
65
|
+
)}
|
|
66
|
+
{supportingText && (
|
|
67
|
+
<span className="text-body-sm text-neutral-40 dark:text-neutral-60">
|
|
68
|
+
{supportingText}
|
|
69
|
+
</span>
|
|
70
|
+
)}
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { InfoBoxType } from './infoBox.enums';
|
|
5
|
+
|
|
6
|
+
export const ICON_COLORS: Record<InfoBoxType, string> = {
|
|
7
|
+
[InfoBoxType.Default]: 'bg-primary-90 dark:bg-primary-10 text-primary-20 dark:text-primary-90',
|
|
8
|
+
[InfoBoxType.Error]: 'bg-error-90 dark:bg-error-10 text-error-20 dark:text-error-90',
|
|
9
|
+
[InfoBoxType.Success]:
|
|
10
|
+
'bg-tertiary-90 dark:bg-tertiary-10 text-tertiary-20 dark:text-tertiary-90',
|
|
11
|
+
[InfoBoxType.Warning]: 'bg-warning-90 dark:bg-warning-20 text-warning-10 dark:text-warning-90',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const BACKGROUND_COLORS: Record<InfoBoxType, string> = {
|
|
15
|
+
[InfoBoxType.Default]: 'bg-primary-90 dark:bg-primary-10',
|
|
16
|
+
[InfoBoxType.Error]: 'bg-error-90 dark:bg-error-10',
|
|
17
|
+
[InfoBoxType.Success]: 'bg-tertiary-90 dark:bg-tertiary-10',
|
|
18
|
+
[InfoBoxType.Warning]: 'bg-warning-90 dark:bg-warning-20',
|
|
19
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export enum InfoBoxType {
|
|
5
|
+
Default = 'default',
|
|
6
|
+
Error = 'error',
|
|
7
|
+
Success = 'success',
|
|
8
|
+
Warning = 'warning',
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export enum InfoBoxStyle {
|
|
12
|
+
Default = 'default',
|
|
13
|
+
Elevated = 'elevated',
|
|
14
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import cx from 'classnames';
|
|
6
|
+
import { Copy, Info } from '@iota/apps-ui-icons';
|
|
7
|
+
import { ValueSize } from './keyValue.enums';
|
|
8
|
+
import type { TooltipPosition } from '../tooltip';
|
|
9
|
+
import { Tooltip } from '../tooltip';
|
|
10
|
+
import { ButtonUnstyled } from '../button';
|
|
11
|
+
|
|
12
|
+
interface KeyValueProps {
|
|
13
|
+
/**
|
|
14
|
+
* The key of the KeyValue.
|
|
15
|
+
*/
|
|
16
|
+
keyText: string;
|
|
17
|
+
/**
|
|
18
|
+
* The value of the KeyValue.
|
|
19
|
+
*/
|
|
20
|
+
value: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The tooltip position.
|
|
23
|
+
*/
|
|
24
|
+
tooltipPosition?: TooltipPosition;
|
|
25
|
+
/**
|
|
26
|
+
* The tooltip text.
|
|
27
|
+
*/
|
|
28
|
+
tooltipText?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The supporting label of the KeyValue (optional).
|
|
31
|
+
*/
|
|
32
|
+
supportingLabel?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The size of the value (optional).
|
|
35
|
+
*/
|
|
36
|
+
size?: ValueSize;
|
|
37
|
+
/**
|
|
38
|
+
* The flag to truncate the value text.
|
|
39
|
+
*/
|
|
40
|
+
isTruncated?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Text that need to be copied (optional).
|
|
43
|
+
*/
|
|
44
|
+
copyText?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The onCopySuccess event of the KeyValue (optional).
|
|
47
|
+
*/
|
|
48
|
+
onCopySuccess?: (e: React.MouseEvent<HTMLButtonElement>, text: string) => void;
|
|
49
|
+
/**
|
|
50
|
+
* The onCopyError event of the KeyValue (optional).
|
|
51
|
+
*/
|
|
52
|
+
onCopyError?: (e: unknown, text: string) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Full width KeyValue (optional).
|
|
55
|
+
*/
|
|
56
|
+
fullwidth?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Reverse the KeyValue (optional).
|
|
59
|
+
*/
|
|
60
|
+
isReverse?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Text shown on value hover.
|
|
63
|
+
*/
|
|
64
|
+
valueHoverTitle?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function KeyValueInfo({
|
|
68
|
+
keyText,
|
|
69
|
+
value,
|
|
70
|
+
tooltipPosition,
|
|
71
|
+
tooltipText,
|
|
72
|
+
supportingLabel,
|
|
73
|
+
size = ValueSize.Small,
|
|
74
|
+
isTruncated = false,
|
|
75
|
+
copyText,
|
|
76
|
+
onCopySuccess,
|
|
77
|
+
onCopyError,
|
|
78
|
+
fullwidth,
|
|
79
|
+
isReverse = false,
|
|
80
|
+
valueHoverTitle,
|
|
81
|
+
}: KeyValueProps): React.JSX.Element {
|
|
82
|
+
const flexDirectionClass = isReverse ? 'flex-row-reverse' : 'flex-row';
|
|
83
|
+
async function handleCopyClick(event: React.MouseEvent<HTMLButtonElement>) {
|
|
84
|
+
if (!navigator.clipboard) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (copyText) {
|
|
89
|
+
try {
|
|
90
|
+
await navigator.clipboard.writeText(copyText);
|
|
91
|
+
onCopySuccess?.(event, copyText);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('Failed to copy:', error);
|
|
94
|
+
onCopyError?.(error, copyText);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div
|
|
101
|
+
className={cx(
|
|
102
|
+
'flex w-full items-baseline gap-xs py-xxs font-inter',
|
|
103
|
+
flexDirectionClass,
|
|
104
|
+
{
|
|
105
|
+
'justify-between': fullwidth,
|
|
106
|
+
},
|
|
107
|
+
)}
|
|
108
|
+
>
|
|
109
|
+
<div
|
|
110
|
+
className={cx('flex shrink-0 flex-row items-center gap-x-0.5', {
|
|
111
|
+
'w-1/4': !fullwidth,
|
|
112
|
+
})}
|
|
113
|
+
>
|
|
114
|
+
<span className="text-body-md text-neutral-40 dark:text-neutral-60">{keyText}</span>
|
|
115
|
+
{tooltipText && (
|
|
116
|
+
<Tooltip text={tooltipText} position={tooltipPosition}>
|
|
117
|
+
<Info className="text-neutral-60 dark:text-neutral-40" />
|
|
118
|
+
</Tooltip>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
<div
|
|
122
|
+
className={cx('flex flex-row items-baseline gap-1 break-all', {
|
|
123
|
+
'w-3/4': !fullwidth,
|
|
124
|
+
truncate: isTruncated,
|
|
125
|
+
})}
|
|
126
|
+
>
|
|
127
|
+
<span
|
|
128
|
+
title={valueHoverTitle}
|
|
129
|
+
className={cx(
|
|
130
|
+
'text-neutral-10 dark:text-neutral-92',
|
|
131
|
+
size === ValueSize.Medium ? 'text-body-lg' : 'text-body-md',
|
|
132
|
+
{ truncate: isTruncated },
|
|
133
|
+
)}
|
|
134
|
+
>
|
|
135
|
+
{value}
|
|
136
|
+
</span>
|
|
137
|
+
{supportingLabel && (
|
|
138
|
+
<span
|
|
139
|
+
className={cx(
|
|
140
|
+
'text-neutral-60 dark:text-neutral-40',
|
|
141
|
+
size === ValueSize.Medium ? 'text-body-md' : 'text-body-sm',
|
|
142
|
+
)}
|
|
143
|
+
>
|
|
144
|
+
{supportingLabel}
|
|
145
|
+
</span>
|
|
146
|
+
)}
|
|
147
|
+
<div className="self-center">
|
|
148
|
+
{copyText && (
|
|
149
|
+
<ButtonUnstyled onClick={handleCopyClick}>
|
|
150
|
+
<Copy className="text-neutral-60 dark:text-neutral-40" />
|
|
151
|
+
</ButtonUnstyled>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import { LabelTextSize } from './labelText.enums';
|
|
6
|
+
import { LABEL_TEXT_SIZE, SUPPORTING_TEXT_SIZE, TEXT_SIZE } from './labelText.classes';
|
|
7
|
+
import { Info } from '@iota/apps-ui-icons';
|
|
8
|
+
import type { TooltipPosition } from '../tooltip';
|
|
9
|
+
import { Tooltip } from '../tooltip';
|
|
10
|
+
|
|
11
|
+
interface LabelTextProps {
|
|
12
|
+
/**
|
|
13
|
+
* The size of the LabelText.
|
|
14
|
+
*/
|
|
15
|
+
size?: LabelTextSize;
|
|
16
|
+
/**
|
|
17
|
+
* The position of the LabelText.
|
|
18
|
+
*/
|
|
19
|
+
isCentered?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The supporting label of the LabelText.
|
|
22
|
+
*/
|
|
23
|
+
supportingLabel?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The text of the LabelText.
|
|
26
|
+
*/
|
|
27
|
+
label: string;
|
|
28
|
+
/**
|
|
29
|
+
* The text of the LabelText.
|
|
30
|
+
*/
|
|
31
|
+
text: string;
|
|
32
|
+
/**
|
|
33
|
+
* The tooltip position.
|
|
34
|
+
*/
|
|
35
|
+
tooltipPosition?: TooltipPosition;
|
|
36
|
+
/**
|
|
37
|
+
* The tooltip text.
|
|
38
|
+
*/
|
|
39
|
+
tooltipText?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function LabelText({
|
|
43
|
+
size = LabelTextSize.Medium,
|
|
44
|
+
isCentered,
|
|
45
|
+
supportingLabel,
|
|
46
|
+
label,
|
|
47
|
+
text,
|
|
48
|
+
tooltipPosition,
|
|
49
|
+
tooltipText,
|
|
50
|
+
}: LabelTextProps): React.JSX.Element {
|
|
51
|
+
const textClasses = TEXT_SIZE[size];
|
|
52
|
+
const supportingLabelClasses = SUPPORTING_TEXT_SIZE[size];
|
|
53
|
+
const labelTextClasses = LABEL_TEXT_SIZE[size];
|
|
54
|
+
const centeredClasses = isCentered ? 'items-center' : 'items-start';
|
|
55
|
+
const gapClass = size === LabelTextSize.Small ? 'gap-0.5' : 'gap-1';
|
|
56
|
+
return (
|
|
57
|
+
<div className={cx('flex flex-col', centeredClasses, gapClass)}>
|
|
58
|
+
<div className="flex flex-row flex-wrap items-center gap-0.5">
|
|
59
|
+
<span
|
|
60
|
+
className={cx('font-inter text-neutral-10 dark:text-neutral-92', textClasses)}
|
|
61
|
+
>
|
|
62
|
+
{text}
|
|
63
|
+
</span>
|
|
64
|
+
{supportingLabel && (
|
|
65
|
+
<span
|
|
66
|
+
className={cx(
|
|
67
|
+
'font-inter text-neutral-60 dark:text-neutral-40',
|
|
68
|
+
supportingLabelClasses,
|
|
69
|
+
)}
|
|
70
|
+
>
|
|
71
|
+
{supportingLabel}
|
|
72
|
+
</span>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
<div className="flex flex-row items-center gap-x-0.5">
|
|
76
|
+
<span
|
|
77
|
+
className={cx(
|
|
78
|
+
'flex items-center font-inter text-neutral-60 dark:text-neutral-40',
|
|
79
|
+
labelTextClasses,
|
|
80
|
+
)}
|
|
81
|
+
>
|
|
82
|
+
{label}
|
|
83
|
+
{tooltipText && (
|
|
84
|
+
<div className="ml-xxxs flex items-center">
|
|
85
|
+
<Tooltip text={tooltipText} position={tooltipPosition}>
|
|
86
|
+
<Info className="text-neutral-60 dark:text-neutral-40" />
|
|
87
|
+
</Tooltip>
|
|
88
|
+
</div>
|
|
89
|
+
)}
|
|
90
|
+
</span>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|