@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,162 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
import { Input, InputType } from '@/lib/components/molecules/input';
|
|
7
|
+
import { PlaceholderReplace } from '@iota/apps-ui-icons';
|
|
8
|
+
import type { ComponentProps } from 'react';
|
|
9
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
10
|
+
import { ButtonPill } from '@/lib/components/atoms/button';
|
|
11
|
+
|
|
12
|
+
type CustomStoryProps = {
|
|
13
|
+
withLeadingIcon?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function InputStory({
|
|
17
|
+
withLeadingIcon,
|
|
18
|
+
value,
|
|
19
|
+
onClearInput,
|
|
20
|
+
type,
|
|
21
|
+
...props
|
|
22
|
+
}: ComponentProps<typeof Input> & CustomStoryProps): JSX.Element {
|
|
23
|
+
const [inputValue, setInputValue] = useState(value ?? '');
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
setInputValue(value ?? '');
|
|
27
|
+
}, [value]);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Input
|
|
31
|
+
{...props}
|
|
32
|
+
onChange={(e) => setInputValue(e.target.value)}
|
|
33
|
+
value={inputValue}
|
|
34
|
+
onClearInput={() => setInputValue('')}
|
|
35
|
+
leadingIcon={withLeadingIcon ? <PlaceholderReplace /> : undefined}
|
|
36
|
+
type={type}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const meta = {
|
|
42
|
+
component: Input,
|
|
43
|
+
tags: ['autodocs'],
|
|
44
|
+
} satisfies Meta<typeof Input>;
|
|
45
|
+
|
|
46
|
+
export default meta;
|
|
47
|
+
|
|
48
|
+
type Story = StoryObj<typeof meta>;
|
|
49
|
+
|
|
50
|
+
export const Default: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
label: 'Label',
|
|
53
|
+
caption: 'Caption',
|
|
54
|
+
type: InputType.Text,
|
|
55
|
+
},
|
|
56
|
+
argTypes: {
|
|
57
|
+
amountCounter: {
|
|
58
|
+
control: {
|
|
59
|
+
type: 'text',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
type: {
|
|
63
|
+
control: {
|
|
64
|
+
type: 'select',
|
|
65
|
+
options: Object.values(InputType),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
onValueChange: {
|
|
69
|
+
control: {
|
|
70
|
+
type: 'none',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
render: (props) => <InputStory {...props} />,
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const WithLeadingElement: Story = {
|
|
78
|
+
args: {
|
|
79
|
+
type: InputType.Text,
|
|
80
|
+
placeholder: 'Placeholder',
|
|
81
|
+
amountCounter: '10',
|
|
82
|
+
caption: 'Caption',
|
|
83
|
+
},
|
|
84
|
+
render: (props) => <InputStory {...props} withLeadingIcon />,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const WithMaxTrailingButton: Story = {
|
|
88
|
+
args: {
|
|
89
|
+
type: InputType.Number,
|
|
90
|
+
placeholder: 'Send IOTAs',
|
|
91
|
+
amountCounter: 'Max 10 IOTA',
|
|
92
|
+
caption: 'Enter token amount',
|
|
93
|
+
supportingText: 'IOTA',
|
|
94
|
+
trailingElement: <PlaceholderReplace />,
|
|
95
|
+
},
|
|
96
|
+
render: ({ value, ...props }) => {
|
|
97
|
+
const [inputValue, setInputValue] = useState<string>('');
|
|
98
|
+
const [error, setError] = useState<string | undefined>();
|
|
99
|
+
|
|
100
|
+
function onMaxClick() {
|
|
101
|
+
setInputValue('10');
|
|
102
|
+
checkInputValidity(inputValue);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const onChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
106
|
+
setInputValue(e.target.value);
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
function checkInputValidity(value: string) {
|
|
110
|
+
if (Number(value) < 0) {
|
|
111
|
+
setError('Value must be greater than 0');
|
|
112
|
+
} else if (Number(value) > 10) {
|
|
113
|
+
setError('Value must be less than 10');
|
|
114
|
+
} else {
|
|
115
|
+
setError(undefined);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
checkInputValidity(inputValue);
|
|
121
|
+
}, [inputValue]);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<Input
|
|
125
|
+
{...props}
|
|
126
|
+
required
|
|
127
|
+
label="Send Tokens"
|
|
128
|
+
value={inputValue}
|
|
129
|
+
trailingElement={<ButtonPill onClick={onMaxClick}>Max</ButtonPill>}
|
|
130
|
+
errorMessage={error}
|
|
131
|
+
onChange={onChange}
|
|
132
|
+
onClearInput={() => setInputValue('')}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const NumericFormatInput: Story = {
|
|
139
|
+
args: {
|
|
140
|
+
type: InputType.NumericFormat,
|
|
141
|
+
placeholder: 'Enter the IOTA Amount',
|
|
142
|
+
amountCounter: '10',
|
|
143
|
+
caption: 'Caption',
|
|
144
|
+
suffix: ' IOTA',
|
|
145
|
+
prefix: '~ ',
|
|
146
|
+
},
|
|
147
|
+
render: (props) => {
|
|
148
|
+
const [inputValue, setInputValue] = useState<string>('');
|
|
149
|
+
|
|
150
|
+
function onMaxClick() {
|
|
151
|
+
setInputValue('10');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<InputStory
|
|
156
|
+
{...props}
|
|
157
|
+
value={inputValue}
|
|
158
|
+
trailingElement={<ButtonPill onClick={onMaxClick}>Max</ButtonPill>}
|
|
159
|
+
/>
|
|
160
|
+
);
|
|
161
|
+
},
|
|
162
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import { NavbarItem, NavbarItemType } from '@/components';
|
|
6
|
+
import { Home } from '@iota/apps-ui-icons';
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof NavbarItem> = {
|
|
9
|
+
component: NavbarItem,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
render: (props) => {
|
|
12
|
+
return <NavbarItem {...props} />;
|
|
13
|
+
},
|
|
14
|
+
} satisfies Meta<typeof NavbarItem>;
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
icon: <Home />,
|
|
23
|
+
},
|
|
24
|
+
argTypes: {
|
|
25
|
+
text: {
|
|
26
|
+
control: 'text',
|
|
27
|
+
},
|
|
28
|
+
icon: {
|
|
29
|
+
control: 'none',
|
|
30
|
+
},
|
|
31
|
+
hasBadge: {
|
|
32
|
+
control: 'boolean',
|
|
33
|
+
},
|
|
34
|
+
isSelected: {
|
|
35
|
+
control: 'boolean',
|
|
36
|
+
},
|
|
37
|
+
type: {
|
|
38
|
+
control: 'select',
|
|
39
|
+
options: Object.values(NavbarItemType),
|
|
40
|
+
},
|
|
41
|
+
isDisabled: {
|
|
42
|
+
control: 'boolean',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
6
|
+
import type { Suggestion } from '@/components';
|
|
7
|
+
import { ListItem, Search, SearchBarType } from '@/components';
|
|
8
|
+
import cx from 'classnames';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Search> = {
|
|
11
|
+
component: Search,
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
render: (props) => {
|
|
14
|
+
const [searchValue, setSearchValue] = useState<string>('');
|
|
15
|
+
const [filteredSuggestions, setFilteredSuggestions] = useState<Suggestion[]>([]);
|
|
16
|
+
|
|
17
|
+
const handleSearchValueChange = (value: string) => {
|
|
18
|
+
setSearchValue(value);
|
|
19
|
+
const filtered =
|
|
20
|
+
props.suggestions?.filter((suggestion) =>
|
|
21
|
+
suggestion.label.toLowerCase().includes(value.toLowerCase()),
|
|
22
|
+
) || [];
|
|
23
|
+
setFilteredSuggestions(filtered);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const handleSuggestionClick = (suggestion: Suggestion) => {
|
|
27
|
+
setSearchValue(suggestion.label);
|
|
28
|
+
setFilteredSuggestions([]);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className="h-60">
|
|
33
|
+
<Search
|
|
34
|
+
{...props}
|
|
35
|
+
searchValue={searchValue}
|
|
36
|
+
suggestions={filteredSuggestions}
|
|
37
|
+
onSearchValueChange={handleSearchValueChange}
|
|
38
|
+
onSuggestionClick={handleSuggestionClick}
|
|
39
|
+
renderSuggestion={(suggestion) => (
|
|
40
|
+
<ListItem
|
|
41
|
+
key={suggestion.id}
|
|
42
|
+
showRightIcon={false}
|
|
43
|
+
onClick={() => handleSuggestionClick(suggestion)}
|
|
44
|
+
hideBottomBorder
|
|
45
|
+
>
|
|
46
|
+
<div
|
|
47
|
+
className={cx(
|
|
48
|
+
'flex w-full flex-row items-center gap-xs',
|
|
49
|
+
suggestion.supportingText ? 'justify-between' : 'justify-start',
|
|
50
|
+
)}
|
|
51
|
+
>
|
|
52
|
+
<span className="text-body-lg text-neutral-10 dark:text-neutral-92">
|
|
53
|
+
{suggestion.label}
|
|
54
|
+
</span>
|
|
55
|
+
<span className="text-body-md text-neutral-40 dark:text-neutral-60">
|
|
56
|
+
{suggestion.supportingText}
|
|
57
|
+
</span>
|
|
58
|
+
</div>
|
|
59
|
+
</ListItem>
|
|
60
|
+
)}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default meta;
|
|
68
|
+
|
|
69
|
+
type Story = StoryObj<typeof meta>;
|
|
70
|
+
|
|
71
|
+
export const Default: Story = {
|
|
72
|
+
args: {
|
|
73
|
+
suggestions: [
|
|
74
|
+
{ id: '1', label: 'Dashboard', supportingText: 'Caption' },
|
|
75
|
+
{ id: '2', label: 'Wallet' },
|
|
76
|
+
{ id: '3', label: 'Explorer' },
|
|
77
|
+
{ id: '4', label: 'SDK' },
|
|
78
|
+
],
|
|
79
|
+
placeholder: 'Search for tooling apps',
|
|
80
|
+
},
|
|
81
|
+
argTypes: {
|
|
82
|
+
suggestions: {
|
|
83
|
+
control: 'object',
|
|
84
|
+
},
|
|
85
|
+
onSuggestionClick: {
|
|
86
|
+
action: 'suggestionClicked',
|
|
87
|
+
},
|
|
88
|
+
placeholder: {
|
|
89
|
+
control: 'text',
|
|
90
|
+
},
|
|
91
|
+
onSearchValueChange: {
|
|
92
|
+
action: 'searchValueChanged',
|
|
93
|
+
},
|
|
94
|
+
type: {
|
|
95
|
+
control: {
|
|
96
|
+
type: 'select',
|
|
97
|
+
options: Object.values(SearchBarType),
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
ButtonSegment,
|
|
8
|
+
ButtonSegmentType,
|
|
9
|
+
SegmentedButton,
|
|
10
|
+
SegmentedButtonType,
|
|
11
|
+
} from '@/components';
|
|
12
|
+
import type { ComponentProps } from 'react';
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { PlaceholderReplace } from '@iota/apps-ui-icons';
|
|
15
|
+
|
|
16
|
+
const meta: Meta<typeof SegmentedButton> = {
|
|
17
|
+
component: SegmentedButton,
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
render: (props) => {
|
|
20
|
+
const [elements, setElements] = useState<ComponentProps<typeof ButtonSegment>[]>([
|
|
21
|
+
{ label: 'Label 1', selected: true },
|
|
22
|
+
{ label: 'Label 2', icon: <PlaceholderReplace /> },
|
|
23
|
+
{ label: 'Label 3', disabled: true },
|
|
24
|
+
{ label: 'Label 4' },
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const handleElementClick = (clickedIndex: number) => {
|
|
28
|
+
const updatedElements = elements.map((element, index) => ({
|
|
29
|
+
...element,
|
|
30
|
+
selected: index === clickedIndex,
|
|
31
|
+
}));
|
|
32
|
+
setElements(updatedElements);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="flex flex-col items-start">
|
|
37
|
+
<SegmentedButton type={props.type} shape={props.shape}>
|
|
38
|
+
{elements.map((element, index) => (
|
|
39
|
+
<ButtonSegment
|
|
40
|
+
key={element.label}
|
|
41
|
+
type={props.shape}
|
|
42
|
+
onClick={() => handleElementClick(index)}
|
|
43
|
+
{...element}
|
|
44
|
+
/>
|
|
45
|
+
))}
|
|
46
|
+
</SegmentedButton>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
} satisfies Meta<typeof SegmentedButton>;
|
|
51
|
+
|
|
52
|
+
export default meta;
|
|
53
|
+
|
|
54
|
+
type Story = StoryObj<typeof meta>;
|
|
55
|
+
|
|
56
|
+
export const Default: Story = {
|
|
57
|
+
argTypes: {
|
|
58
|
+
type: {
|
|
59
|
+
control: {
|
|
60
|
+
type: 'select',
|
|
61
|
+
options: Object.values(SegmentedButtonType),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
shape: {
|
|
65
|
+
control: {
|
|
66
|
+
type: 'select',
|
|
67
|
+
options: Object.values(ButtonSegmentType),
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const Underlined: Story = {
|
|
74
|
+
args: {
|
|
75
|
+
type: SegmentedButtonType.Transparent,
|
|
76
|
+
shape: ButtonSegmentType.Underlined,
|
|
77
|
+
},
|
|
78
|
+
render: (props) => {
|
|
79
|
+
const [elements, setElements] = useState<ComponentProps<typeof ButtonSegment>[]>([
|
|
80
|
+
{ label: 'Label 1', selected: true, type: ButtonSegmentType.Underlined },
|
|
81
|
+
{ label: 'Label 2', icon: <PlaceholderReplace />, type: ButtonSegmentType.Underlined },
|
|
82
|
+
{ label: 'Label 3', type: ButtonSegmentType.Underlined },
|
|
83
|
+
{ label: 'Label 4', disabled: true, type: ButtonSegmentType.Underlined },
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
const handleElementClick = (clickedIndex: number) => {
|
|
87
|
+
const updatedElements = elements.map((element, index) => ({
|
|
88
|
+
...element,
|
|
89
|
+
selected: index === clickedIndex,
|
|
90
|
+
}));
|
|
91
|
+
setElements(updatedElements);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="flex flex-col items-start">
|
|
96
|
+
<SegmentedButton type={props.type} shape={props.shape}>
|
|
97
|
+
{elements.map((element, index) => (
|
|
98
|
+
<ButtonSegment
|
|
99
|
+
key={element.label}
|
|
100
|
+
onClick={() => handleElementClick(index)}
|
|
101
|
+
{...element}
|
|
102
|
+
/>
|
|
103
|
+
))}
|
|
104
|
+
</SegmentedButton>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import type { SelectOption } from '@/components/molecules/select/Select';
|
|
6
|
+
import { Select } from '@/components/molecules/select/Select';
|
|
7
|
+
import { useState } from 'react';
|
|
8
|
+
import { IotaLogoMark, PlaceholderReplace } from '@iota/apps-ui-icons';
|
|
9
|
+
|
|
10
|
+
const meta: Meta<typeof Select> = {
|
|
11
|
+
component: Select,
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
} satisfies Meta<typeof Select>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
const dropdownOptions: SelectOption[] = ['Option 1', 'Option 2', 'Option 3', 'Invalid Option'];
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
label: 'Select Input',
|
|
24
|
+
supportingText: 'Info',
|
|
25
|
+
caption: 'Caption',
|
|
26
|
+
placeholder: 'Placeholder',
|
|
27
|
+
options: dropdownOptions,
|
|
28
|
+
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
placeholder: {
|
|
31
|
+
control: {
|
|
32
|
+
type: 'text',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
render: (args) => {
|
|
37
|
+
const [selected, setSelected] = useState('Option 1');
|
|
38
|
+
const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined);
|
|
39
|
+
|
|
40
|
+
const onChange = (id: string) => {
|
|
41
|
+
if (id === 'Invalid Option') {
|
|
42
|
+
setErrorMessage('Invalid Option Selected');
|
|
43
|
+
} else {
|
|
44
|
+
setSelected(id);
|
|
45
|
+
setErrorMessage(undefined);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className="h-60">
|
|
51
|
+
<Select
|
|
52
|
+
{...args}
|
|
53
|
+
value={selected}
|
|
54
|
+
onValueChange={onChange}
|
|
55
|
+
errorMessage={errorMessage}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const CustomOptions: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
label: 'Send Coins',
|
|
65
|
+
placeholder: 'Select a coin',
|
|
66
|
+
options: [],
|
|
67
|
+
},
|
|
68
|
+
render: ({ options, ...args }) => {
|
|
69
|
+
const [selected, setSelected] = useState('iota');
|
|
70
|
+
|
|
71
|
+
const customOptions: SelectOption[] = [
|
|
72
|
+
{
|
|
73
|
+
id: 'iota',
|
|
74
|
+
renderLabel: () => (
|
|
75
|
+
<div className="flex items-center gap-2">
|
|
76
|
+
<IotaLogoMark />
|
|
77
|
+
IOTA
|
|
78
|
+
</div>
|
|
79
|
+
),
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: 'other coin',
|
|
83
|
+
renderLabel: () => (
|
|
84
|
+
<div className="flex items-center gap-2">
|
|
85
|
+
<PlaceholderReplace />
|
|
86
|
+
Other Coin
|
|
87
|
+
</div>
|
|
88
|
+
),
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div className="h-60">
|
|
94
|
+
<Select
|
|
95
|
+
{...args}
|
|
96
|
+
value={selected}
|
|
97
|
+
onValueChange={setSelected}
|
|
98
|
+
options={customOptions}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import { TableCellBase, TableCellText } from '@/components';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: TableCellText,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
render: (props) => {
|
|
11
|
+
return (
|
|
12
|
+
<table>
|
|
13
|
+
<thead>
|
|
14
|
+
<tr>
|
|
15
|
+
<TableCellBase>
|
|
16
|
+
<Avatar />
|
|
17
|
+
</TableCellBase>
|
|
18
|
+
<TableCellBase>
|
|
19
|
+
<TableCellText>Mr. Crab</TableCellText>
|
|
20
|
+
</TableCellBase>
|
|
21
|
+
</tr>
|
|
22
|
+
</thead>
|
|
23
|
+
</table>
|
|
24
|
+
);
|
|
25
|
+
},
|
|
26
|
+
} satisfies Meta<typeof TableCellText>;
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
|
|
30
|
+
type Story = StoryObj<typeof meta>;
|
|
31
|
+
|
|
32
|
+
const Avatar = () => {
|
|
33
|
+
return (
|
|
34
|
+
<svg
|
|
35
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
36
|
+
width="33"
|
|
37
|
+
height="32"
|
|
38
|
+
viewBox="0 0 33 32"
|
|
39
|
+
fill="none"
|
|
40
|
+
>
|
|
41
|
+
<circle cx="16.5" cy="16" r="16" className="fill-primary-40" />
|
|
42
|
+
</svg>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import { TableHeaderCell } from '@/components';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
component: TableHeaderCell,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
render: (props) => {
|
|
11
|
+
return (
|
|
12
|
+
<div className="w-56">
|
|
13
|
+
<table>
|
|
14
|
+
<thead>
|
|
15
|
+
<tr>
|
|
16
|
+
<TableHeaderCell {...props} />
|
|
17
|
+
</tr>
|
|
18
|
+
</thead>
|
|
19
|
+
</table>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
},
|
|
23
|
+
} satisfies Meta<typeof TableHeaderCell>;
|
|
24
|
+
|
|
25
|
+
export default meta;
|
|
26
|
+
|
|
27
|
+
type Story = StoryObj<typeof meta>;
|
|
28
|
+
|
|
29
|
+
export const Default: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
label: 'Label',
|
|
32
|
+
columnKey: '1',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import { TextArea } from '@/lib/components/molecules/input';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
|
+
import { Button } from '@/lib';
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof TextArea> = {
|
|
10
|
+
component: TextArea,
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
} satisfies Meta<typeof TextArea>;
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
label: 'Label',
|
|
21
|
+
caption: 'Caption',
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
amountCounter: {
|
|
25
|
+
control: {
|
|
26
|
+
type: 'text',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
rows: {
|
|
30
|
+
control: {
|
|
31
|
+
type: 'number',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
maxLength: {
|
|
35
|
+
control: {
|
|
36
|
+
type: 'number',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
minLength: {
|
|
40
|
+
control: {
|
|
41
|
+
type: 'number',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
autoFocus: {
|
|
45
|
+
control: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
render: (props) => {
|
|
51
|
+
const { onChange, value, ...storyProps } = props;
|
|
52
|
+
const [inputValue, setInputValue] = useState(props.value ?? '');
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
setInputValue(props.value ?? '');
|
|
56
|
+
}, [props.value]);
|
|
57
|
+
|
|
58
|
+
function onSubmit() {
|
|
59
|
+
alert(inputValue);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function handleOnChange(e: React.ChangeEvent<HTMLTextAreaElement>) {
|
|
63
|
+
setInputValue(e.target.value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div className="w-[300px]">
|
|
68
|
+
<TextArea
|
|
69
|
+
onChange={handleOnChange}
|
|
70
|
+
value={inputValue}
|
|
71
|
+
isVisibilityToggleEnabled
|
|
72
|
+
{...storyProps}
|
|
73
|
+
/>
|
|
74
|
+
<div className="flex w-full justify-end">
|
|
75
|
+
<Button onClick={() => onSubmit()} text="Submit" />
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
};
|