@qoretechnologies/reqore 0.44.0 → 0.45.0
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/package.json +1 -1
- package/tests.json +1 -1
- package/.eslintrc.js +0 -40
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
- package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
- package/.github/workflows/beta_release.yml +0 -100
- package/.github/workflows/tests.yml +0 -84
- package/.gitpod.yml +0 -11
- package/.jest-test-results.json +0 -1
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -0
- package/__tests__/breadcrumbs.test.tsx +0 -75
- package/__tests__/button.test.tsx +0 -218
- package/__tests__/checkbox.test.tsx +0 -45
- package/__tests__/collection.test.tsx +0 -243
- package/__tests__/containers/paging.test.tsx +0 -138
- package/__tests__/control_group.test.tsx +0 -32
- package/__tests__/drawer.test.tsx +0 -140
- package/__tests__/dropdown.test.tsx +0 -381
- package/__tests__/effect.test.tsx +0 -70
- package/__tests__/heading.test.tsx +0 -58
- package/__tests__/helpers/colors.test.tsx +0 -18
- package/__tests__/helpers/table.test.tsx +0 -67
- package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
- package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
- package/__tests__/hooks/useTheme.test.tsx +0 -31
- package/__tests__/icon.test.tsx +0 -53
- package/__tests__/input.test.tsx +0 -482
- package/__tests__/layout.test.tsx +0 -37
- package/__tests__/menu.test.tsx +0 -65
- package/__tests__/messages.test.tsx +0 -79
- package/__tests__/modal.test.tsx +0 -204
- package/__tests__/multiselect.test.tsx +0 -458
- package/__tests__/navbar.test.tsx +0 -31
- package/__tests__/notifications.test.tsx +0 -178
- package/__tests__/pagination.test.tsx +0 -437
- package/__tests__/panel.test.tsx +0 -243
- package/__tests__/popover.test.tsx +0 -282
- package/__tests__/radiogroup.test.tsx +0 -47
- package/__tests__/setup.js +0 -8
- package/__tests__/stories/Collection.stories.tsx +0 -0
- package/__tests__/table.test.tsx +0 -647
- package/__tests__/tabs.test.tsx +0 -321
- package/__tests__/tag.test.tsx +0 -160
- package/__tests__/textarea.test.tsx +0 -467
- package/__tests__/timeAgo.test.tsx +0 -27
- package/__tests__/tree.test.tsx +0 -58
- package/build-storybook.log +0 -491
- package/chromatic.config.json +0 -1
- package/icons.ts +0 -1
- package/migration-storybook.log +0 -56
- package/public/logo-dark.png +0 -0
- package/public/logo.png +0 -0
- package/public/q-symbol-small.png +0 -0
- package/public/q-symbol.png +0 -0
- package/public/qoreLogo-dark.png +0 -0
- package/public/qoreLogo.png +0 -0
- package/src/components/Breadcrumbs/index.tsx +0 -254
- package/src/components/Breadcrumbs/item.tsx +0 -44
- package/src/components/Button/index.tsx +0 -633
- package/src/components/Checkbox/index.tsx +0 -388
- package/src/components/Collection/index.tsx +0 -426
- package/src/components/Collection/item.tsx +0 -267
- package/src/components/Columns/column.tsx +0 -27
- package/src/components/Columns/index.tsx +0 -41
- package/src/components/Comment/index.tsx +0 -141
- package/src/components/CommentFeed/index.tsx +0 -34
- package/src/components/Content/index.tsx +0 -34
- package/src/components/Content/wrapper.tsx +0 -36
- package/src/components/ControlGroup/index.tsx +0 -523
- package/src/components/DatePicker/index.tsx +0 -347
- package/src/components/Drawer/backdrop.tsx +0 -54
- package/src/components/Drawer/index.tsx +0 -365
- package/src/components/Dropdown/index.tsx +0 -153
- package/src/components/Dropdown/item.tsx +0 -33
- package/src/components/Dropdown/list.tsx +0 -222
- package/src/components/Effect/index.tsx +0 -464
- package/src/components/ExportModal/index.tsx +0 -99
- package/src/components/Header/index.tsx +0 -81
- package/src/components/Icon/index.tsx +0 -184
- package/src/components/Input/index.tsx +0 -295
- package/src/components/InputClearButton/index.tsx +0 -59
- package/src/components/InternalPopover/index.tsx +0 -303
- package/src/components/KeyValueTable/index.tsx +0 -192
- package/src/components/Label/index.tsx +0 -10
- package/src/components/Layout/content.tsx +0 -31
- package/src/components/Layout/index.tsx +0 -55
- package/src/components/Menu/divider.tsx +0 -92
- package/src/components/Menu/index.tsx +0 -141
- package/src/components/Menu/item.tsx +0 -137
- package/src/components/Menu/section.tsx +0 -81
- package/src/components/Message/index.tsx +0 -220
- package/src/components/Modal/index.tsx +0 -26
- package/src/components/MultiSelect/index.tsx +0 -288
- package/src/components/Navbar/divider.tsx +0 -50
- package/src/components/Navbar/group.tsx +0 -53
- package/src/components/Navbar/index.tsx +0 -82
- package/src/components/Navbar/item.tsx +0 -92
- package/src/components/Notifications/index.tsx +0 -57
- package/src/components/Notifications/notification.tsx +0 -362
- package/src/components/Paging/index.tsx +0 -321
- package/src/components/Panel/LabelEditor.tsx +0 -67
- package/src/components/Panel/NonResponsiveActions.tsx +0 -79
- package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
- package/src/components/Panel/index.tsx +0 -912
- package/src/components/Panel/panel.screenshot.tsx +0 -29
- package/src/components/Paragraph/index.tsx +0 -43
- package/src/components/Popover/index.tsx +0 -68
- package/src/components/RadioGroup/index.tsx +0 -71
- package/src/components/Slider/index.tsx +0 -358
- package/src/components/Spacer/index.tsx +0 -142
- package/src/components/Spinner/index.tsx +0 -74
- package/src/components/Table/body.tsx +0 -109
- package/src/components/Table/cell.tsx +0 -136
- package/src/components/Table/header.tsx +0 -236
- package/src/components/Table/headerCell.tsx +0 -203
- package/src/components/Table/helpers.ts +0 -308
- package/src/components/Table/index.tsx +0 -797
- package/src/components/Table/row.tsx +0 -288
- package/src/components/Table/value.tsx +0 -28
- package/src/components/Tabs/content.tsx +0 -68
- package/src/components/Tabs/index.tsx +0 -124
- package/src/components/Tabs/item.tsx +0 -198
- package/src/components/Tabs/list.tsx +0 -381
- package/src/components/Tag/group.tsx +0 -73
- package/src/components/Tag/index.tsx +0 -463
- package/src/components/Textarea/index.tsx +0 -277
- package/src/components/TimeAgo/index.tsx +0 -15
- package/src/components/Tree/index.tsx +0 -271
- package/src/constants/animations.ts +0 -9
- package/src/constants/colors.ts +0 -13
- package/src/constants/paging.ts +0 -93
- package/src/constants/sizes.ts +0 -185
- package/src/constants/theme.ts +0 -122
- package/src/containers/Paging.tsx +0 -136
- package/src/containers/PopoverProvider.tsx +0 -124
- package/src/containers/ReqoreProvider.tsx +0 -289
- package/src/containers/ThemeProvider.tsx +0 -12
- package/src/containers/UIProvider.tsx +0 -101
- package/src/context/PopoverContext.tsx +0 -11
- package/src/context/ReqoreContext.tsx +0 -47
- package/src/context/ThemeContext.tsx +0 -4
- package/src/helpers/animations.ts +0 -13
- package/src/helpers/colors.ts +0 -335
- package/src/helpers/time.ts +0 -21
- package/src/helpers/utils.ts +0 -152
- package/src/hooks/useAutoFocus.ts +0 -106
- package/src/hooks/useCloneThroughFragments.ts +0 -39
- package/src/hooks/useCombinedRefs.ts +0 -26
- package/src/hooks/useLatestZIndex.ts +0 -13
- package/src/hooks/useOutsideClick.ts +0 -29
- package/src/hooks/usePaging.ts +0 -128
- package/src/hooks/usePopover.tsx +0 -220
- package/src/hooks/useQueryWithDelay.ts +0 -30
- package/src/hooks/useReqore.ts +0 -12
- package/src/hooks/useReqoreContext.ts +0 -16
- package/src/hooks/useReqoreEffect.ts +0 -49
- package/src/hooks/useTextareaAutoSize.ts +0 -22
- package/src/hooks/useTheme.ts +0 -48
- package/src/hooks/useTooltip.ts +0 -40
- package/src/hooks/useWhyDidYouUpdate.ts +0 -32
- package/src/icons.json +0 -2295
- package/src/index.tsx +0 -80
- package/src/mock/breadcrumbs.ts +0 -146
- package/src/mock/collectionData.tsx +0 -380
- package/src/mock/data.json +0 -11000
- package/src/mock/icons.ts +0 -32
- package/src/mock/menu.ts +0 -93
- package/src/mock/multiSelect.ts +0 -71
- package/src/mock/object.json +0 -317
- package/src/mock/styleMock.js +0 -1
- package/src/mock/tableData.ts +0 -64
- package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
- package/src/stories/Button/Button.stories.tsx +0 -405
- package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
- package/src/stories/Collection/Collection.stories.tsx +0 -317
- package/src/stories/Columns/Columns.stories.tsx +0 -158
- package/src/stories/Comment/Comment.stories.tsx +0 -136
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
- package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
- package/src/stories/Drawer/Drawer.stories.tsx +0 -294
- package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
- package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
- package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
- package/src/stories/Header/Header.stories.tsx +0 -108
- package/src/stories/Icon/Icon.stories.tsx +0 -162
- package/src/stories/Input/Input.stories.tsx +0 -220
- package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
- package/src/stories/Label/Label.stories.tsx +0 -33
- package/src/stories/Menu/Menu.stories.tsx +0 -367
- package/src/stories/Message/Message.stories.tsx +0 -167
- package/src/stories/Modal/Manager.stories.tsx +0 -192
- package/src/stories/Modal/Modal.stories.tsx +0 -252
- package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
- package/src/stories/Navbar/Navbar.stories.tsx +0 -119
- package/src/stories/Notifications/Interactive.stories.tsx +0 -117
- package/src/stories/Notifications/Notification.stories.tsx +0 -216
- package/src/stories/Notifications/Notifications.stories.tsx +0 -81
- package/src/stories/Paging/Paging.stories.tsx +0 -255
- package/src/stories/Panel/Panel.stories.tsx +0 -753
- package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
- package/src/stories/Popover/Popover.stories.tsx +0 -510
- package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
- package/src/stories/Slider/Slider.stories.tsx +0 -173
- package/src/stories/Spacer/Spacer.stories.tsx +0 -100
- package/src/stories/Spinner/Spinner.stories.tsx +0 -82
- package/src/stories/Table/Table.stories.tsx +0 -571
- package/src/stories/Tabs/Tabs.stories.tsx +0 -346
- package/src/stories/Tag/Tag.stories.tsx +0 -381
- package/src/stories/Tag/TagGroup.stories.tsx +0 -307
- package/src/stories/TextArea/TextArea.stories.tsx +0 -287
- package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
- package/src/stories/Tree/Tree.stories.tsx +0 -124
- package/src/stories/Wrapper.tsx +0 -13
- package/src/stories/utils/args.ts +0 -151
- package/src/stories/utils.ts +0 -39
- package/src/styles.ts +0 -124
- package/src/types/global.ts +0 -211
- package/src/types/icons.ts +0 -2272
- package/tsconfig.prod.json +0 -26
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
-
import { stringify } from 'yaml';
|
|
3
|
-
import { ReqoreTextarea, useReqoreProperty } from '../..';
|
|
4
|
-
import { convertToCSV } from '../../helpers/utils';
|
|
5
|
-
import { IReqoreModalProps, ReqoreModal } from '../Modal';
|
|
6
|
-
import ReqoreTabs, { IReqoreTabsProps } from '../Tabs';
|
|
7
|
-
import ReqoreTabsContent from '../Tabs/content';
|
|
8
|
-
|
|
9
|
-
export interface IReqoreExportModalProps extends IReqoreModalProps {
|
|
10
|
-
data: { [key: string]: unknown } | unknown[];
|
|
11
|
-
sendNotificationOnCopy?: boolean;
|
|
12
|
-
tabsOptions?: Omit<IReqoreTabsProps, 'tabs'>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const ReqoreExportModal = ({
|
|
16
|
-
data,
|
|
17
|
-
sendNotificationOnCopy = true,
|
|
18
|
-
tabsOptions = {},
|
|
19
|
-
...rest
|
|
20
|
-
}: IReqoreExportModalProps) => {
|
|
21
|
-
const addNotification = useReqoreProperty('addNotification');
|
|
22
|
-
const isArray = Array.isArray(data);
|
|
23
|
-
const [tab, setTab] = useState<string>(isArray ? 'csv' : 'json');
|
|
24
|
-
const tabs: IReqoreTabsProps['tabs'] = [
|
|
25
|
-
{ label: 'CSV', id: 'csv', disabled: !isArray },
|
|
26
|
-
{ label: 'JSON', id: 'json' },
|
|
27
|
-
{ label: 'YAML', id: 'yaml' },
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
const dataToExport = useMemo(() => {
|
|
31
|
-
switch (tab) {
|
|
32
|
-
case 'csv':
|
|
33
|
-
return convertToCSV(data as any[]);
|
|
34
|
-
case 'json':
|
|
35
|
-
return JSON.stringify(data, null, 2);
|
|
36
|
-
case 'yaml':
|
|
37
|
-
return stringify(data, null, 2);
|
|
38
|
-
default:
|
|
39
|
-
return '';
|
|
40
|
-
}
|
|
41
|
-
}, [data, tab, isArray]);
|
|
42
|
-
|
|
43
|
-
const handleCopyClick = useCallback(() => {
|
|
44
|
-
navigator.clipboard.writeText(dataToExport);
|
|
45
|
-
|
|
46
|
-
if (sendNotificationOnCopy) {
|
|
47
|
-
addNotification({
|
|
48
|
-
content: 'Data copied to clipboard',
|
|
49
|
-
intent: 'success',
|
|
50
|
-
duration: 3000,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}, [sendNotificationOnCopy, dataToExport]);
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<ReqoreModal
|
|
57
|
-
label='Export data'
|
|
58
|
-
icon='DownloadLine'
|
|
59
|
-
{...rest}
|
|
60
|
-
isOpen
|
|
61
|
-
bottomActions={[
|
|
62
|
-
{
|
|
63
|
-
position: 'right',
|
|
64
|
-
label: 'Copy',
|
|
65
|
-
icon: 'ClipboardLine',
|
|
66
|
-
onClick: () => {
|
|
67
|
-
handleCopyClick();
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
position: 'right',
|
|
72
|
-
label: 'Copy and close',
|
|
73
|
-
icon: 'ClipboardFill',
|
|
74
|
-
onClick: () => {
|
|
75
|
-
handleCopyClick();
|
|
76
|
-
rest.onClose?.();
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
]}
|
|
80
|
-
>
|
|
81
|
-
<ReqoreTabs
|
|
82
|
-
fillParent
|
|
83
|
-
activeTabIntent='info'
|
|
84
|
-
activeTab={isArray ? 'csv' : 'json'}
|
|
85
|
-
padded={false}
|
|
86
|
-
flat={false}
|
|
87
|
-
{...tabsOptions}
|
|
88
|
-
onTabChange={(tabId) => setTab(tabId.toString())}
|
|
89
|
-
tabs={tabs}
|
|
90
|
-
>
|
|
91
|
-
{tabs.map((tab) => (
|
|
92
|
-
<ReqoreTabsContent tabId={tab.id} key={tab.id} padded='none'>
|
|
93
|
-
<ReqoreTextarea readOnly value={dataToExport} scaleWithContent minimal />
|
|
94
|
-
</ReqoreTabsContent>
|
|
95
|
-
))}
|
|
96
|
-
</ReqoreTabs>
|
|
97
|
-
</ReqoreModal>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { memo, useMemo, useState } from 'react';
|
|
2
|
-
import styled from 'styled-components';
|
|
3
|
-
import { HEADER_SIZE_TO_NUMBER, TSizes } from '../../constants/sizes';
|
|
4
|
-
import { IReqoreTheme, TReqoreIntent } from '../../constants/theme';
|
|
5
|
-
import { isStringSize } from '../../helpers/utils';
|
|
6
|
-
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
7
|
-
import { useTooltip } from '../../hooks/useTooltip';
|
|
8
|
-
import { IWithReqoreEffect, IWithReqoreTooltip } from '../../types/global';
|
|
9
|
-
import { StyledTextEffect } from '../Effect';
|
|
10
|
-
|
|
11
|
-
export interface IReqoreHeadingProps
|
|
12
|
-
extends IWithReqoreEffect,
|
|
13
|
-
IWithReqoreTooltip,
|
|
14
|
-
React.HTMLAttributes<HTMLHeadingElement> {
|
|
15
|
-
intent?: TReqoreIntent;
|
|
16
|
-
size?: 1 | 2 | 3 | 4 | 5 | 6 | TSizes;
|
|
17
|
-
customTheme?: Partial<IReqoreTheme>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface IReqoreHeadingStyle extends IReqoreHeadingProps {
|
|
21
|
-
theme: IReqoreTheme;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const StyledHeader = styled(StyledTextEffect)`
|
|
25
|
-
margin: 0;
|
|
26
|
-
padding: 0;
|
|
27
|
-
color: ${({ theme, intent }) => (intent ? theme.intents[intent] : 'inherit')};
|
|
28
|
-
|
|
29
|
-
font-size: ${({ _size }) => {
|
|
30
|
-
switch (_size) {
|
|
31
|
-
case 1:
|
|
32
|
-
return '30px';
|
|
33
|
-
case 2:
|
|
34
|
-
return '24px';
|
|
35
|
-
case 3:
|
|
36
|
-
return '19px';
|
|
37
|
-
case 4:
|
|
38
|
-
return '14px';
|
|
39
|
-
case 5:
|
|
40
|
-
return '11px';
|
|
41
|
-
case 6:
|
|
42
|
-
return '8px';
|
|
43
|
-
default:
|
|
44
|
-
return 'inherit';
|
|
45
|
-
}
|
|
46
|
-
}};
|
|
47
|
-
`;
|
|
48
|
-
|
|
49
|
-
export const ReqoreHeading = memo(
|
|
50
|
-
({ size, children, customTheme, intent, className, tooltip, ...rest }: IReqoreHeadingProps) => {
|
|
51
|
-
const [ref, setRef] = useState<HTMLHeadingElement>(undefined);
|
|
52
|
-
const theme = useReqoreTheme('main', customTheme, intent);
|
|
53
|
-
const _size: number = isStringSize(size) ? HEADER_SIZE_TO_NUMBER[size] : size;
|
|
54
|
-
const HTMLheaderElement = useMemo(() => {
|
|
55
|
-
return `h${_size}` as 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
56
|
-
}, [_size]);
|
|
57
|
-
|
|
58
|
-
useTooltip(ref, tooltip);
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<StyledHeader
|
|
62
|
-
as={HTMLheaderElement}
|
|
63
|
-
theme={theme}
|
|
64
|
-
intent={intent}
|
|
65
|
-
ref={setRef}
|
|
66
|
-
{...rest}
|
|
67
|
-
_size={_size}
|
|
68
|
-
className={`${className || ''} reqore-heading`}
|
|
69
|
-
>
|
|
70
|
-
{children}
|
|
71
|
-
</StyledHeader>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
export const ReqoreH1 = (props: IReqoreHeadingProps) => <ReqoreHeading size={1} {...props} />;
|
|
77
|
-
export const ReqoreH2 = (props: IReqoreHeadingProps) => <ReqoreHeading size={2} {...props} />;
|
|
78
|
-
export const ReqoreH3 = (props: IReqoreHeadingProps) => <ReqoreHeading size={3} {...props} />;
|
|
79
|
-
export const ReqoreH4 = (props: IReqoreHeadingProps) => <ReqoreHeading size={4} {...props} />;
|
|
80
|
-
export const ReqoreH5 = (props: IReqoreHeadingProps) => <ReqoreHeading size={5} {...props} />;
|
|
81
|
-
export const ReqoreH6 = (props: IReqoreHeadingProps) => <ReqoreHeading size={6} {...props} />;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, memo } from 'react';
|
|
2
|
-
import { IconContext } from 'react-icons';
|
|
3
|
-
import { IconBaseProps, IconType } from 'react-icons/lib';
|
|
4
|
-
import * as RemixIcons from 'react-icons/ri';
|
|
5
|
-
import styled, { css, keyframes } from 'styled-components';
|
|
6
|
-
import { useReqoreTheme } from '../..';
|
|
7
|
-
import { ICON_FROM_SIZE, PADDING_FROM_SIZE, TSizes } from '../../constants/sizes';
|
|
8
|
-
import { getColorFromMaybeString } from '../../helpers/colors';
|
|
9
|
-
import { isStringSize } from '../../helpers/utils';
|
|
10
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
11
|
-
import { useTooltip } from '../../hooks/useTooltip';
|
|
12
|
-
import { IReqoreIntent, IWithReqoreEffect, IWithReqoreTooltip } from '../../types/global';
|
|
13
|
-
import { IReqoreIconName } from '../../types/icons';
|
|
14
|
-
import { StyledEffect, TReqoreEffectColor } from '../Effect';
|
|
15
|
-
|
|
16
|
-
export interface IReqoreIconProps
|
|
17
|
-
extends React.HTMLAttributes<HTMLSpanElement>,
|
|
18
|
-
IWithReqoreEffect,
|
|
19
|
-
IWithReqoreTooltip,
|
|
20
|
-
IReqoreIntent {
|
|
21
|
-
icon?: IReqoreIconName;
|
|
22
|
-
color?: TReqoreEffectColor;
|
|
23
|
-
size?: TSizes | string;
|
|
24
|
-
wrapperSize?: TSizes | string;
|
|
25
|
-
wrapperElement?: any;
|
|
26
|
-
iconProps?: IconBaseProps;
|
|
27
|
-
margin?: 'right' | 'left' | 'both';
|
|
28
|
-
image?: string;
|
|
29
|
-
rounded?: boolean;
|
|
30
|
-
rotation?: number;
|
|
31
|
-
animation?: 'spin' | 'heartbeat';
|
|
32
|
-
interactive?: boolean;
|
|
33
|
-
compact?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const SpinKeyframes = keyframes`
|
|
37
|
-
0% {
|
|
38
|
-
rotate: 0deg;
|
|
39
|
-
}
|
|
40
|
-
100% {
|
|
41
|
-
rotate: 360deg;
|
|
42
|
-
}
|
|
43
|
-
`;
|
|
44
|
-
|
|
45
|
-
export const StyledIconWrapper = styled(StyledEffect)<{ margin: 'right' | 'left' | 'both' }>`
|
|
46
|
-
display: inline-flex;
|
|
47
|
-
flex: 0 0 auto;
|
|
48
|
-
justify-content: center;
|
|
49
|
-
align-items: center;
|
|
50
|
-
vertical-align: text-bottom;
|
|
51
|
-
transition: all 0.2s ease-out;
|
|
52
|
-
overflow: hidden;
|
|
53
|
-
|
|
54
|
-
border-radius: ${({ rounded }) => (rounded ? '50%' : undefined)};
|
|
55
|
-
rotate: ${({ rotation }) => (rotation ? `${rotation}deg` : undefined)};
|
|
56
|
-
cursor: ${({ interactive }) => (interactive ? 'pointer' : undefined)};
|
|
57
|
-
|
|
58
|
-
${({ margin, size, compact }) =>
|
|
59
|
-
margin &&
|
|
60
|
-
css`
|
|
61
|
-
margin-left: ${margin === 'left' || margin === 'both'
|
|
62
|
-
? isStringSize(size)
|
|
63
|
-
? `${PADDING_FROM_SIZE[size] / (compact ? 2 : 1)}px`
|
|
64
|
-
: compact
|
|
65
|
-
? '3px'
|
|
66
|
-
: '10px'
|
|
67
|
-
: undefined};
|
|
68
|
-
margin-right: ${margin === 'right' || margin === 'both'
|
|
69
|
-
? isStringSize(size)
|
|
70
|
-
? `${PADDING_FROM_SIZE[size] / (compact ? 2 : 1)}px`
|
|
71
|
-
: compact
|
|
72
|
-
? '3px'
|
|
73
|
-
: '10px'
|
|
74
|
-
: undefined};
|
|
75
|
-
`}
|
|
76
|
-
|
|
77
|
-
img {
|
|
78
|
-
width: 100%;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
${({ animation }) =>
|
|
82
|
-
animation === 'spin' &&
|
|
83
|
-
css`
|
|
84
|
-
animation: ${SpinKeyframes} 1s linear infinite;
|
|
85
|
-
`}
|
|
86
|
-
`;
|
|
87
|
-
|
|
88
|
-
const ReqoreIcon = memo(
|
|
89
|
-
forwardRef<HTMLSpanElement, IReqoreIconProps>(
|
|
90
|
-
(
|
|
91
|
-
{
|
|
92
|
-
icon,
|
|
93
|
-
size = 'normal',
|
|
94
|
-
wrapperSize,
|
|
95
|
-
wrapperElement,
|
|
96
|
-
className,
|
|
97
|
-
color,
|
|
98
|
-
margin,
|
|
99
|
-
style = {},
|
|
100
|
-
iconProps,
|
|
101
|
-
intent,
|
|
102
|
-
image,
|
|
103
|
-
tooltip,
|
|
104
|
-
...rest
|
|
105
|
-
}: IReqoreIconProps,
|
|
106
|
-
ref
|
|
107
|
-
) => {
|
|
108
|
-
const { targetRef } = useCombinedRefs(ref);
|
|
109
|
-
const [iconRef, setIconRef] = React.useState<HTMLSpanElement>(undefined);
|
|
110
|
-
const theme = useReqoreTheme();
|
|
111
|
-
const Icon: IconType = RemixIcons[`Ri${icon}`];
|
|
112
|
-
const finalColor: string | undefined = intent
|
|
113
|
-
? theme.intents[intent]
|
|
114
|
-
: getColorFromMaybeString(theme, color);
|
|
115
|
-
const finalSize: string = isStringSize(size) ? ICON_FROM_SIZE[size] : size;
|
|
116
|
-
const finalWrapperSize: string = wrapperSize
|
|
117
|
-
? isStringSize(wrapperSize)
|
|
118
|
-
? ICON_FROM_SIZE[wrapperSize]
|
|
119
|
-
: wrapperSize
|
|
120
|
-
: finalSize;
|
|
121
|
-
|
|
122
|
-
useTooltip(iconRef, tooltip);
|
|
123
|
-
|
|
124
|
-
if (image) {
|
|
125
|
-
return (
|
|
126
|
-
<StyledIconWrapper
|
|
127
|
-
{...rest}
|
|
128
|
-
as={wrapperElement}
|
|
129
|
-
ref={targetRef}
|
|
130
|
-
size={size}
|
|
131
|
-
margin={margin}
|
|
132
|
-
className={`${className || ''} reqore-icon`}
|
|
133
|
-
style={{ width: finalWrapperSize, height: finalWrapperSize, ...style }}
|
|
134
|
-
>
|
|
135
|
-
<img src={image} alt='' />
|
|
136
|
-
</StyledIconWrapper>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (!Icon) {
|
|
141
|
-
return (
|
|
142
|
-
<StyledIconWrapper
|
|
143
|
-
{...rest}
|
|
144
|
-
as={wrapperElement}
|
|
145
|
-
ref={targetRef}
|
|
146
|
-
size={size}
|
|
147
|
-
margin={margin}
|
|
148
|
-
className={`${className || ''} reqore-icon`}
|
|
149
|
-
style={{ width: finalWrapperSize, height: finalWrapperSize, ...style }}
|
|
150
|
-
/>
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return (
|
|
155
|
-
<StyledIconWrapper
|
|
156
|
-
{...rest}
|
|
157
|
-
as={wrapperElement}
|
|
158
|
-
ref={(ref) => {
|
|
159
|
-
targetRef.current = ref;
|
|
160
|
-
setIconRef(ref);
|
|
161
|
-
}}
|
|
162
|
-
margin={margin}
|
|
163
|
-
size={size}
|
|
164
|
-
style={{ width: finalWrapperSize, height: finalWrapperSize, ...style }}
|
|
165
|
-
className={`${className || ''} reqore-icon`}
|
|
166
|
-
>
|
|
167
|
-
<IconContext.Provider
|
|
168
|
-
value={{
|
|
169
|
-
color: finalColor || 'inherit',
|
|
170
|
-
size: finalSize,
|
|
171
|
-
style: {
|
|
172
|
-
verticalAlign: 'super',
|
|
173
|
-
},
|
|
174
|
-
}}
|
|
175
|
-
>
|
|
176
|
-
<Icon {...iconProps} />
|
|
177
|
-
</IconContext.Provider>
|
|
178
|
-
</StyledIconWrapper>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
)
|
|
182
|
-
);
|
|
183
|
-
|
|
184
|
-
export default ReqoreIcon;
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import { omit } from 'lodash';
|
|
2
|
-
import { rgba } from 'polished';
|
|
3
|
-
import React, { forwardRef, useState } from 'react';
|
|
4
|
-
import styled, { css } from 'styled-components';
|
|
5
|
-
import {
|
|
6
|
-
CONTROL_TEXT_FROM_SIZE,
|
|
7
|
-
PADDING_FROM_SIZE,
|
|
8
|
-
PILL_RADIUS_MODIFIER,
|
|
9
|
-
RADIUS_FROM_SIZE,
|
|
10
|
-
SIZE_TO_PX,
|
|
11
|
-
TSizes,
|
|
12
|
-
} from '../../constants/sizes';
|
|
13
|
-
import { IReqoreTheme } from '../../constants/theme';
|
|
14
|
-
import { changeLightness, getReadableColor } from '../../helpers/colors';
|
|
15
|
-
import { IReqoreAutoFocusRules, useAutoFocus } from '../../hooks/useAutoFocus';
|
|
16
|
-
import { useCombinedRefs } from '../../hooks/useCombinedRefs';
|
|
17
|
-
import { useReqoreTheme } from '../../hooks/useTheme';
|
|
18
|
-
import { useTooltip } from '../../hooks/useTooltip';
|
|
19
|
-
import { DisabledElement, ReadOnlyElement } from '../../styles';
|
|
20
|
-
import {
|
|
21
|
-
IReqoreDisabled,
|
|
22
|
-
IReqoreIntent,
|
|
23
|
-
IReqoreReadOnly,
|
|
24
|
-
IWithReqoreCustomTheme,
|
|
25
|
-
IWithReqoreEffect,
|
|
26
|
-
IWithReqoreTooltip,
|
|
27
|
-
} from '../../types/global';
|
|
28
|
-
import { IReqoreIconName } from '../../types/icons';
|
|
29
|
-
import { StyledEffect, TReqoreEffectColor } from '../Effect';
|
|
30
|
-
import ReqoreIcon, { IReqoreIconProps } from '../Icon';
|
|
31
|
-
import ReqoreInputClearButton from '../InputClearButton';
|
|
32
|
-
|
|
33
|
-
export interface IReqoreInputProps
|
|
34
|
-
extends Omit<React.ComponentPropsWithoutRef<'input'>, 'size' | 'children'>,
|
|
35
|
-
IReqoreDisabled,
|
|
36
|
-
IReqoreReadOnly,
|
|
37
|
-
IReqoreIntent,
|
|
38
|
-
IWithReqoreCustomTheme,
|
|
39
|
-
IWithReqoreEffect,
|
|
40
|
-
IWithReqoreTooltip {
|
|
41
|
-
autoFocus?: boolean;
|
|
42
|
-
placeholder?: string;
|
|
43
|
-
width?: number;
|
|
44
|
-
size?: TSizes;
|
|
45
|
-
minimal?: boolean;
|
|
46
|
-
fluid?: boolean;
|
|
47
|
-
fixed?: boolean;
|
|
48
|
-
value?: string | number;
|
|
49
|
-
onClearClick?: () => void;
|
|
50
|
-
maxLength?: number;
|
|
51
|
-
icon?: IReqoreIconName;
|
|
52
|
-
rightIcon?: IReqoreIconName;
|
|
53
|
-
flat?: boolean;
|
|
54
|
-
rounded?: boolean;
|
|
55
|
-
type?: 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
|
|
56
|
-
step?: number;
|
|
57
|
-
wrapperStyle?: React.CSSProperties;
|
|
58
|
-
iconColor?: TReqoreEffectColor;
|
|
59
|
-
rightIconColor?: TReqoreEffectColor;
|
|
60
|
-
focusRules?: IReqoreAutoFocusRules;
|
|
61
|
-
|
|
62
|
-
leftIconProps?: IReqoreIconProps;
|
|
63
|
-
rightIconProps?: IReqoreIconProps;
|
|
64
|
-
|
|
65
|
-
pill?: boolean;
|
|
66
|
-
|
|
67
|
-
children?: React.ReactNode | ((props: any) => React.ReactNode);
|
|
68
|
-
as?: string | React.ElementType;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface IReqoreInputStyle extends IReqoreInputProps {
|
|
72
|
-
theme: IReqoreTheme;
|
|
73
|
-
_size?: TSizes;
|
|
74
|
-
clearable?: boolean;
|
|
75
|
-
hasIcon?: boolean;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const StyledInputWrapper = styled.div<IReqoreInputStyle>`
|
|
79
|
-
height: ${({ _size }) => SIZE_TO_PX[_size]}px;
|
|
80
|
-
width: ${({ width }) => (width ? `${width}px` : 'auto')};
|
|
81
|
-
max-width: ${({ fluid, fixed }) => (fluid && !fixed ? '100%' : undefined)};
|
|
82
|
-
min-width: 60px;
|
|
83
|
-
flex: ${({ fluid, fixed }) => (fixed ? '0 auto' : fluid ? '1 auto' : '0 1 auto')};
|
|
84
|
-
align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
|
|
85
|
-
font-size: ${({ _size }) => CONTROL_TEXT_FROM_SIZE[_size]}px;
|
|
86
|
-
position: relative;
|
|
87
|
-
overflow: hidden;
|
|
88
|
-
border-radius: ${({ minimal, rounded, _size, pill }) =>
|
|
89
|
-
minimal || rounded === false
|
|
90
|
-
? 0
|
|
91
|
-
: RADIUS_FROM_SIZE[_size] * (pill ? PILL_RADIUS_MODIFIER : 1)}px;
|
|
92
|
-
|
|
93
|
-
&:focus-within {
|
|
94
|
-
.reqore-clear-input-button {
|
|
95
|
-
display: flex;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
|
|
100
|
-
const StyledIconWrapper = styled.div<IReqoreInputStyle>`
|
|
101
|
-
position: absolute;
|
|
102
|
-
height: ${({ _size }) => SIZE_TO_PX[_size]}px;
|
|
103
|
-
width: ${({ _size }) => SIZE_TO_PX[_size]}px;
|
|
104
|
-
right: ${({ position }) => (position === 'right' ? 0 : undefined)};
|
|
105
|
-
top: 0;
|
|
106
|
-
display: flex;
|
|
107
|
-
justify-content: center;
|
|
108
|
-
align-items: center;
|
|
109
|
-
`;
|
|
110
|
-
|
|
111
|
-
export const StyledInput = styled(StyledEffect)<IReqoreInputStyle>`
|
|
112
|
-
height: 100%;
|
|
113
|
-
width: 100%;
|
|
114
|
-
flex: 1;
|
|
115
|
-
margin: 0;
|
|
116
|
-
padding: ${({ _size }) => PADDING_FROM_SIZE[_size] / 2}px 7px;
|
|
117
|
-
padding-right: ${({ clearable, hasRightIcon, _size }) => {
|
|
118
|
-
let padding = 7;
|
|
119
|
-
|
|
120
|
-
if (clearable || hasRightIcon) {
|
|
121
|
-
padding = 0;
|
|
122
|
-
padding += clearable ? SIZE_TO_PX[_size] : 0;
|
|
123
|
-
padding += hasRightIcon ? SIZE_TO_PX[_size] : 0;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return padding;
|
|
127
|
-
}}px;
|
|
128
|
-
|
|
129
|
-
padding-left: ${({ hasIcon, _size }) => (hasIcon ? SIZE_TO_PX[_size] : 7)}px;
|
|
130
|
-
font-size: ${({ _size }) => CONTROL_TEXT_FROM_SIZE[_size]}px;
|
|
131
|
-
transition: all 0.2s ease-out;
|
|
132
|
-
border-radius: ${({ minimal, rounded, _size, pill }) =>
|
|
133
|
-
minimal || rounded === false
|
|
134
|
-
? 0
|
|
135
|
-
: RADIUS_FROM_SIZE[_size] * (pill ? PILL_RADIUS_MODIFIER : 1)}px;
|
|
136
|
-
border: ${({ minimal, theme, flat }) =>
|
|
137
|
-
!minimal && !flat ? `1px solid ${changeLightness(theme.main, 0.2)}` : 0};
|
|
138
|
-
border-bottom: ${({ minimal, theme, flat }) =>
|
|
139
|
-
minimal && !flat ? `0.5px solid ${changeLightness(theme.main, 0.2)}` : undefined};
|
|
140
|
-
|
|
141
|
-
${({ disabled, readOnly }) =>
|
|
142
|
-
!disabled && !readOnly
|
|
143
|
-
? css`
|
|
144
|
-
&:active,
|
|
145
|
-
&:focus,
|
|
146
|
-
&:hover {
|
|
147
|
-
outline: none;
|
|
148
|
-
border-color: ${({ theme }) => changeLightness(theme.main, 0.35)};
|
|
149
|
-
}
|
|
150
|
-
`
|
|
151
|
-
: undefined}
|
|
152
|
-
|
|
153
|
-
background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
|
|
154
|
-
minimal ? 'transparent' : rgba(theme.main, 0.1)};
|
|
155
|
-
color: ${({ theme }: IReqoreInputStyle) =>
|
|
156
|
-
getReadableColor(theme, undefined, undefined, true, theme.originalMain)};
|
|
157
|
-
|
|
158
|
-
transition: all 0.2s ease-out;
|
|
159
|
-
|
|
160
|
-
&:active,
|
|
161
|
-
&:focus {
|
|
162
|
-
background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
|
|
163
|
-
minimal ? 'transparent' : rgba(theme.main, 0.15)};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
&::placeholder {
|
|
167
|
-
transition: all 0.2s ease-out;
|
|
168
|
-
color: ${({ theme }) =>
|
|
169
|
-
rgba(getReadableColor(theme, undefined, undefined, true, theme.originalMain), 0.3)};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
&:focus {
|
|
173
|
-
&::placeholder {
|
|
174
|
-
color: ${({ theme }) =>
|
|
175
|
-
rgba(getReadableColor(theme, undefined, undefined, true, theme.originalMain), 0.5)};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
${({ readOnly }) => readOnly && ReadOnlyElement};
|
|
180
|
-
|
|
181
|
-
&:disabled {
|
|
182
|
-
${DisabledElement};
|
|
183
|
-
}
|
|
184
|
-
`;
|
|
185
|
-
|
|
186
|
-
const ReqoreInput = forwardRef<HTMLDivElement, IReqoreInputProps>(
|
|
187
|
-
(
|
|
188
|
-
{
|
|
189
|
-
tooltip,
|
|
190
|
-
width,
|
|
191
|
-
size = 'normal',
|
|
192
|
-
fluid,
|
|
193
|
-
fixed,
|
|
194
|
-
className,
|
|
195
|
-
onClearClick,
|
|
196
|
-
icon,
|
|
197
|
-
rightIcon,
|
|
198
|
-
iconColor,
|
|
199
|
-
rightIconColor,
|
|
200
|
-
flat,
|
|
201
|
-
rounded,
|
|
202
|
-
minimal,
|
|
203
|
-
readOnly,
|
|
204
|
-
customTheme,
|
|
205
|
-
intent,
|
|
206
|
-
wrapperStyle,
|
|
207
|
-
focusRules,
|
|
208
|
-
leftIconProps = {},
|
|
209
|
-
rightIconProps = {},
|
|
210
|
-
pill,
|
|
211
|
-
...rest
|
|
212
|
-
}: IReqoreInputProps,
|
|
213
|
-
ref
|
|
214
|
-
) => {
|
|
215
|
-
const { targetRef } = useCombinedRefs(ref);
|
|
216
|
-
const [inputRef, setInputRef] = useState<HTMLInputElement>(null);
|
|
217
|
-
const theme = useReqoreTheme('main', customTheme, intent);
|
|
218
|
-
|
|
219
|
-
useTooltip(inputRef, tooltip);
|
|
220
|
-
useAutoFocus(inputRef, readOnly || rest.disabled ? undefined : focusRules, rest.onChange);
|
|
221
|
-
|
|
222
|
-
const hasLeftIcon = icon || leftIconProps?.image;
|
|
223
|
-
const hasRightIcon = rightIcon || rightIconProps?.image;
|
|
224
|
-
|
|
225
|
-
return (
|
|
226
|
-
<StyledInputWrapper
|
|
227
|
-
className='reqore-control-wrapper'
|
|
228
|
-
fluid={fluid}
|
|
229
|
-
fixed={fixed}
|
|
230
|
-
width={width}
|
|
231
|
-
flat={flat}
|
|
232
|
-
theme={theme}
|
|
233
|
-
rounded={rounded}
|
|
234
|
-
minimal={minimal}
|
|
235
|
-
_size={size}
|
|
236
|
-
ref={targetRef}
|
|
237
|
-
readOnly={readOnly}
|
|
238
|
-
disabled={rest.disabled}
|
|
239
|
-
style={wrapperStyle}
|
|
240
|
-
pill={pill}
|
|
241
|
-
>
|
|
242
|
-
{hasLeftIcon && (
|
|
243
|
-
<StyledIconWrapper _size={size}>
|
|
244
|
-
<ReqoreIcon size={size} icon={icon} color={iconColor} {...leftIconProps} />
|
|
245
|
-
</StyledIconWrapper>
|
|
246
|
-
)}
|
|
247
|
-
<StyledInput
|
|
248
|
-
as='input'
|
|
249
|
-
{...omit(rest, ['children'])}
|
|
250
|
-
effect={{
|
|
251
|
-
interactive: !rest?.disabled && !readOnly,
|
|
252
|
-
...rest?.effect,
|
|
253
|
-
}}
|
|
254
|
-
onChange={!readOnly && !rest?.disabled ? rest?.onChange : undefined}
|
|
255
|
-
ref={(ref) => setInputRef(ref)}
|
|
256
|
-
theme={theme}
|
|
257
|
-
_size={size}
|
|
258
|
-
minimal={minimal}
|
|
259
|
-
flat={flat}
|
|
260
|
-
rounded={rounded}
|
|
261
|
-
hasIcon={!!icon}
|
|
262
|
-
hasRightIcon={!!rightIcon}
|
|
263
|
-
clearable={
|
|
264
|
-
!rest?.disabled &&
|
|
265
|
-
!readOnly &&
|
|
266
|
-
!!(onClearClick && (rest.as || rest.children || rest?.onChange))
|
|
267
|
-
}
|
|
268
|
-
className={`${className || ''} reqore-control reqore-input`}
|
|
269
|
-
readOnly={readOnly}
|
|
270
|
-
pill={pill}
|
|
271
|
-
>
|
|
272
|
-
{rest?.children}
|
|
273
|
-
</StyledInput>
|
|
274
|
-
<ReqoreInputClearButton
|
|
275
|
-
enabled={
|
|
276
|
-
!readOnly &&
|
|
277
|
-
!rest?.disabled &&
|
|
278
|
-
!!(onClearClick && (rest.as || rest.children || rest?.onChange))
|
|
279
|
-
}
|
|
280
|
-
onClick={onClearClick}
|
|
281
|
-
hasRightIcon={!!rightIcon}
|
|
282
|
-
size={size}
|
|
283
|
-
show={rest?.value && rest.value !== '' ? true : false}
|
|
284
|
-
/>
|
|
285
|
-
{hasRightIcon && (
|
|
286
|
-
<StyledIconWrapper _size={size} position='right'>
|
|
287
|
-
<ReqoreIcon size={size} icon={rightIcon} color={rightIconColor} {...rightIconProps} />
|
|
288
|
-
</StyledIconWrapper>
|
|
289
|
-
)}
|
|
290
|
-
</StyledInputWrapper>
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
export default ReqoreInput;
|