@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.
Files changed (222) hide show
  1. package/package.json +1 -1
  2. package/tests.json +1 -1
  3. package/.eslintrc.js +0 -40
  4. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  5. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  6. package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
  7. package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
  8. package/.github/workflows/beta_release.yml +0 -100
  9. package/.github/workflows/tests.yml +0 -84
  10. package/.gitpod.yml +0 -11
  11. package/.jest-test-results.json +0 -1
  12. package/.prettierrc +0 -7
  13. package/.vscode/settings.json +0 -0
  14. package/__tests__/breadcrumbs.test.tsx +0 -75
  15. package/__tests__/button.test.tsx +0 -218
  16. package/__tests__/checkbox.test.tsx +0 -45
  17. package/__tests__/collection.test.tsx +0 -243
  18. package/__tests__/containers/paging.test.tsx +0 -138
  19. package/__tests__/control_group.test.tsx +0 -32
  20. package/__tests__/drawer.test.tsx +0 -140
  21. package/__tests__/dropdown.test.tsx +0 -381
  22. package/__tests__/effect.test.tsx +0 -70
  23. package/__tests__/heading.test.tsx +0 -58
  24. package/__tests__/helpers/colors.test.tsx +0 -18
  25. package/__tests__/helpers/table.test.tsx +0 -67
  26. package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
  27. package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
  28. package/__tests__/hooks/useTheme.test.tsx +0 -31
  29. package/__tests__/icon.test.tsx +0 -53
  30. package/__tests__/input.test.tsx +0 -482
  31. package/__tests__/layout.test.tsx +0 -37
  32. package/__tests__/menu.test.tsx +0 -65
  33. package/__tests__/messages.test.tsx +0 -79
  34. package/__tests__/modal.test.tsx +0 -204
  35. package/__tests__/multiselect.test.tsx +0 -458
  36. package/__tests__/navbar.test.tsx +0 -31
  37. package/__tests__/notifications.test.tsx +0 -178
  38. package/__tests__/pagination.test.tsx +0 -437
  39. package/__tests__/panel.test.tsx +0 -243
  40. package/__tests__/popover.test.tsx +0 -282
  41. package/__tests__/radiogroup.test.tsx +0 -47
  42. package/__tests__/setup.js +0 -8
  43. package/__tests__/stories/Collection.stories.tsx +0 -0
  44. package/__tests__/table.test.tsx +0 -647
  45. package/__tests__/tabs.test.tsx +0 -321
  46. package/__tests__/tag.test.tsx +0 -160
  47. package/__tests__/textarea.test.tsx +0 -467
  48. package/__tests__/timeAgo.test.tsx +0 -27
  49. package/__tests__/tree.test.tsx +0 -58
  50. package/build-storybook.log +0 -491
  51. package/chromatic.config.json +0 -1
  52. package/icons.ts +0 -1
  53. package/migration-storybook.log +0 -56
  54. package/public/logo-dark.png +0 -0
  55. package/public/logo.png +0 -0
  56. package/public/q-symbol-small.png +0 -0
  57. package/public/q-symbol.png +0 -0
  58. package/public/qoreLogo-dark.png +0 -0
  59. package/public/qoreLogo.png +0 -0
  60. package/src/components/Breadcrumbs/index.tsx +0 -254
  61. package/src/components/Breadcrumbs/item.tsx +0 -44
  62. package/src/components/Button/index.tsx +0 -633
  63. package/src/components/Checkbox/index.tsx +0 -388
  64. package/src/components/Collection/index.tsx +0 -426
  65. package/src/components/Collection/item.tsx +0 -267
  66. package/src/components/Columns/column.tsx +0 -27
  67. package/src/components/Columns/index.tsx +0 -41
  68. package/src/components/Comment/index.tsx +0 -141
  69. package/src/components/CommentFeed/index.tsx +0 -34
  70. package/src/components/Content/index.tsx +0 -34
  71. package/src/components/Content/wrapper.tsx +0 -36
  72. package/src/components/ControlGroup/index.tsx +0 -523
  73. package/src/components/DatePicker/index.tsx +0 -347
  74. package/src/components/Drawer/backdrop.tsx +0 -54
  75. package/src/components/Drawer/index.tsx +0 -365
  76. package/src/components/Dropdown/index.tsx +0 -153
  77. package/src/components/Dropdown/item.tsx +0 -33
  78. package/src/components/Dropdown/list.tsx +0 -222
  79. package/src/components/Effect/index.tsx +0 -464
  80. package/src/components/ExportModal/index.tsx +0 -99
  81. package/src/components/Header/index.tsx +0 -81
  82. package/src/components/Icon/index.tsx +0 -184
  83. package/src/components/Input/index.tsx +0 -295
  84. package/src/components/InputClearButton/index.tsx +0 -59
  85. package/src/components/InternalPopover/index.tsx +0 -303
  86. package/src/components/KeyValueTable/index.tsx +0 -192
  87. package/src/components/Label/index.tsx +0 -10
  88. package/src/components/Layout/content.tsx +0 -31
  89. package/src/components/Layout/index.tsx +0 -55
  90. package/src/components/Menu/divider.tsx +0 -92
  91. package/src/components/Menu/index.tsx +0 -141
  92. package/src/components/Menu/item.tsx +0 -137
  93. package/src/components/Menu/section.tsx +0 -81
  94. package/src/components/Message/index.tsx +0 -220
  95. package/src/components/Modal/index.tsx +0 -26
  96. package/src/components/MultiSelect/index.tsx +0 -288
  97. package/src/components/Navbar/divider.tsx +0 -50
  98. package/src/components/Navbar/group.tsx +0 -53
  99. package/src/components/Navbar/index.tsx +0 -82
  100. package/src/components/Navbar/item.tsx +0 -92
  101. package/src/components/Notifications/index.tsx +0 -57
  102. package/src/components/Notifications/notification.tsx +0 -362
  103. package/src/components/Paging/index.tsx +0 -321
  104. package/src/components/Panel/LabelEditor.tsx +0 -67
  105. package/src/components/Panel/NonResponsiveActions.tsx +0 -79
  106. package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
  107. package/src/components/Panel/index.tsx +0 -912
  108. package/src/components/Panel/panel.screenshot.tsx +0 -29
  109. package/src/components/Paragraph/index.tsx +0 -43
  110. package/src/components/Popover/index.tsx +0 -68
  111. package/src/components/RadioGroup/index.tsx +0 -71
  112. package/src/components/Slider/index.tsx +0 -358
  113. package/src/components/Spacer/index.tsx +0 -142
  114. package/src/components/Spinner/index.tsx +0 -74
  115. package/src/components/Table/body.tsx +0 -109
  116. package/src/components/Table/cell.tsx +0 -136
  117. package/src/components/Table/header.tsx +0 -236
  118. package/src/components/Table/headerCell.tsx +0 -203
  119. package/src/components/Table/helpers.ts +0 -308
  120. package/src/components/Table/index.tsx +0 -797
  121. package/src/components/Table/row.tsx +0 -288
  122. package/src/components/Table/value.tsx +0 -28
  123. package/src/components/Tabs/content.tsx +0 -68
  124. package/src/components/Tabs/index.tsx +0 -124
  125. package/src/components/Tabs/item.tsx +0 -198
  126. package/src/components/Tabs/list.tsx +0 -381
  127. package/src/components/Tag/group.tsx +0 -73
  128. package/src/components/Tag/index.tsx +0 -463
  129. package/src/components/Textarea/index.tsx +0 -277
  130. package/src/components/TimeAgo/index.tsx +0 -15
  131. package/src/components/Tree/index.tsx +0 -271
  132. package/src/constants/animations.ts +0 -9
  133. package/src/constants/colors.ts +0 -13
  134. package/src/constants/paging.ts +0 -93
  135. package/src/constants/sizes.ts +0 -185
  136. package/src/constants/theme.ts +0 -122
  137. package/src/containers/Paging.tsx +0 -136
  138. package/src/containers/PopoverProvider.tsx +0 -124
  139. package/src/containers/ReqoreProvider.tsx +0 -289
  140. package/src/containers/ThemeProvider.tsx +0 -12
  141. package/src/containers/UIProvider.tsx +0 -101
  142. package/src/context/PopoverContext.tsx +0 -11
  143. package/src/context/ReqoreContext.tsx +0 -47
  144. package/src/context/ThemeContext.tsx +0 -4
  145. package/src/helpers/animations.ts +0 -13
  146. package/src/helpers/colors.ts +0 -335
  147. package/src/helpers/time.ts +0 -21
  148. package/src/helpers/utils.ts +0 -152
  149. package/src/hooks/useAutoFocus.ts +0 -106
  150. package/src/hooks/useCloneThroughFragments.ts +0 -39
  151. package/src/hooks/useCombinedRefs.ts +0 -26
  152. package/src/hooks/useLatestZIndex.ts +0 -13
  153. package/src/hooks/useOutsideClick.ts +0 -29
  154. package/src/hooks/usePaging.ts +0 -128
  155. package/src/hooks/usePopover.tsx +0 -220
  156. package/src/hooks/useQueryWithDelay.ts +0 -30
  157. package/src/hooks/useReqore.ts +0 -12
  158. package/src/hooks/useReqoreContext.ts +0 -16
  159. package/src/hooks/useReqoreEffect.ts +0 -49
  160. package/src/hooks/useTextareaAutoSize.ts +0 -22
  161. package/src/hooks/useTheme.ts +0 -48
  162. package/src/hooks/useTooltip.ts +0 -40
  163. package/src/hooks/useWhyDidYouUpdate.ts +0 -32
  164. package/src/icons.json +0 -2295
  165. package/src/index.tsx +0 -80
  166. package/src/mock/breadcrumbs.ts +0 -146
  167. package/src/mock/collectionData.tsx +0 -380
  168. package/src/mock/data.json +0 -11000
  169. package/src/mock/icons.ts +0 -32
  170. package/src/mock/menu.ts +0 -93
  171. package/src/mock/multiSelect.ts +0 -71
  172. package/src/mock/object.json +0 -317
  173. package/src/mock/styleMock.js +0 -1
  174. package/src/mock/tableData.ts +0 -64
  175. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
  176. package/src/stories/Button/Button.stories.tsx +0 -405
  177. package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
  178. package/src/stories/Collection/Collection.stories.tsx +0 -317
  179. package/src/stories/Columns/Columns.stories.tsx +0 -158
  180. package/src/stories/Comment/Comment.stories.tsx +0 -136
  181. package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
  182. package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
  183. package/src/stories/Drawer/Drawer.stories.tsx +0 -294
  184. package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
  185. package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
  186. package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
  187. package/src/stories/Header/Header.stories.tsx +0 -108
  188. package/src/stories/Icon/Icon.stories.tsx +0 -162
  189. package/src/stories/Input/Input.stories.tsx +0 -220
  190. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
  191. package/src/stories/Label/Label.stories.tsx +0 -33
  192. package/src/stories/Menu/Menu.stories.tsx +0 -367
  193. package/src/stories/Message/Message.stories.tsx +0 -167
  194. package/src/stories/Modal/Manager.stories.tsx +0 -192
  195. package/src/stories/Modal/Modal.stories.tsx +0 -252
  196. package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
  197. package/src/stories/Navbar/Navbar.stories.tsx +0 -119
  198. package/src/stories/Notifications/Interactive.stories.tsx +0 -117
  199. package/src/stories/Notifications/Notification.stories.tsx +0 -216
  200. package/src/stories/Notifications/Notifications.stories.tsx +0 -81
  201. package/src/stories/Paging/Paging.stories.tsx +0 -255
  202. package/src/stories/Panel/Panel.stories.tsx +0 -753
  203. package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
  204. package/src/stories/Popover/Popover.stories.tsx +0 -510
  205. package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
  206. package/src/stories/Slider/Slider.stories.tsx +0 -173
  207. package/src/stories/Spacer/Spacer.stories.tsx +0 -100
  208. package/src/stories/Spinner/Spinner.stories.tsx +0 -82
  209. package/src/stories/Table/Table.stories.tsx +0 -571
  210. package/src/stories/Tabs/Tabs.stories.tsx +0 -346
  211. package/src/stories/Tag/Tag.stories.tsx +0 -381
  212. package/src/stories/Tag/TagGroup.stories.tsx +0 -307
  213. package/src/stories/TextArea/TextArea.stories.tsx +0 -287
  214. package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
  215. package/src/stories/Tree/Tree.stories.tsx +0 -124
  216. package/src/stories/Wrapper.tsx +0 -13
  217. package/src/stories/utils/args.ts +0 -151
  218. package/src/stories/utils.ts +0 -39
  219. package/src/styles.ts +0 -124
  220. package/src/types/global.ts +0 -211
  221. package/src/types/icons.ts +0 -2272
  222. package/tsconfig.prod.json +0 -26
@@ -1,29 +0,0 @@
1
- import { noop } from 'lodash';
2
- import { ReqorePanel } from '../../index';
3
-
4
- export const SomePanel = () => (
5
- <ReqorePanel
6
- collapsible
7
- intent='danger'
8
- title='DANGER'
9
- icon='AlarmWarningLine'
10
- padded
11
- actions={[
12
- {
13
- icon: 'Settings2Line',
14
- onClick: noop,
15
- },
16
- {
17
- icon: 'UserFill',
18
- onClick: noop,
19
- label: 'Test',
20
- },
21
- ]}
22
- >
23
- I am a message a very long message - Shadowlands has mechanisms put in place for allowing
24
- players to catch up on Renown, the system of gaining favor and unlocking rewards, Campaign
25
- chapters, and soulbinds within your Covenant. This system works for main characters who have
26
- started late, for alts, for players who have switched Covenants and are starting over, and for
27
- players who have simply missed weekly quests for earning Renown due to being away from the game.
28
- </ReqorePanel>
29
- );
@@ -1,43 +0,0 @@
1
- import { memo } from 'react';
2
- import styled from 'styled-components';
3
- import { TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
4
- import { isStringSize } from '../../helpers/utils';
5
- import { useReqoreTheme } from '../../hooks/useTheme';
6
- import { IReqoreIntent, IWithReqoreCustomTheme, IWithReqoreEffect } from '../../types/global';
7
- import { StyledTextEffect } from '../Effect';
8
-
9
- export interface IReqoreParagraphProps
10
- extends React.HTMLAttributes<HTMLParagraphElement>,
11
- IWithReqoreCustomTheme,
12
- IWithReqoreEffect,
13
- IReqoreIntent {
14
- size?: TSizes | string;
15
- }
16
-
17
- export const StyledParagraph = styled(StyledTextEffect)`
18
- padding: 0;
19
- margin: 0;
20
- color: ${({ theme, intent }) =>
21
- intent ? theme.intents[intent] : theme.text?.color || 'inherit'};
22
- font-size: ${({ _size }) => (isStringSize(_size) ? `${TEXT_FROM_SIZE[_size]}px` : _size)};
23
- `;
24
-
25
- export const ReqoreP = memo(
26
- ({ size, children, customTheme, intent, className, ...props }: IReqoreParagraphProps) => {
27
- const theme = useReqoreTheme('main', customTheme, intent);
28
-
29
- return (
30
- <StyledParagraph
31
- as='p'
32
- theme={theme}
33
- color={theme.text.color}
34
- intent={intent}
35
- {...props}
36
- _size={size}
37
- className={`${className || ''} reqore-paragraph`}
38
- >
39
- {children}
40
- </StyledParagraph>
41
- );
42
- }
43
- );
@@ -1,68 +0,0 @@
1
- import React, { memo, useEffect, useState } from 'react';
2
- import styled from 'styled-components';
3
- import usePopover, { IPopoverControls, IPopoverOptions } from '../../hooks/usePopover';
4
- import { IReqoreComponent } from '../../types/global';
5
-
6
- export interface IReqorePopoverProps extends IReqoreComponent, IPopoverOptions {
7
- component: any;
8
- componentProps?: any;
9
- children?: any;
10
- isReqoreComponent?: boolean;
11
- wrapperTag?: string;
12
- wrapperStyle?: React.CSSProperties;
13
- }
14
-
15
- export const StyledPopover = styled.span`
16
- overflow: hidden;
17
- `;
18
-
19
- const Popover = memo(
20
- ({
21
- component: Component,
22
- componentProps,
23
- children,
24
- isReqoreComponent,
25
- wrapperTag = 'span',
26
- wrapperStyle = {},
27
- passPopoverData,
28
- _insidePopover,
29
- _popoverId,
30
- ...rest
31
- }: IReqorePopoverProps) => {
32
- const [ref, setRef] = useState(undefined);
33
-
34
- const popoverData: IPopoverControls = usePopover({ targetElement: ref, ...rest });
35
-
36
- useEffect(() => {
37
- passPopoverData?.(popoverData);
38
- }, [popoverData]);
39
-
40
- if (isReqoreComponent) {
41
- return (
42
- <Component
43
- {...componentProps}
44
- _insidePopover={_insidePopover}
45
- _popoverId={_popoverId}
46
- ref={setRef}
47
- >
48
- {children}
49
- </Component>
50
- );
51
- }
52
-
53
- return (
54
- <StyledPopover
55
- as={wrapperTag}
56
- className='reqore-popover-wrapper'
57
- ref={setRef}
58
- style={wrapperStyle}
59
- >
60
- <Component {...componentProps} _insidePopover={_insidePopover} _popoverId={_popoverId}>
61
- {children}
62
- </Component>
63
- </StyledPopover>
64
- );
65
- }
66
- );
67
-
68
- export default Popover;
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import { ReqoreCheckbox, ReqoreControlGroup } from '../..';
3
- import { TSizes } from '../../constants/sizes';
4
- import { IReqoreCheckboxProps } from '../Checkbox';
5
- import { IReqoreControlGroupProps } from '../ControlGroup';
6
- import ReqoreMenuDivider from '../Menu/divider';
7
-
8
- export interface IReqoreRadioGroupItem extends IReqoreCheckboxProps {
9
- value?: string;
10
- divider?: boolean;
11
- }
12
-
13
- export interface IReqoreRadioGroupProps
14
- extends Omit<IReqoreControlGroupProps, 'children'>,
15
- Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
16
- items: IReqoreRadioGroupItem[];
17
- selected?: string;
18
- onSelectClick?: (value: string) => void;
19
- size?: TSizes;
20
- disabled?: boolean;
21
- asSwitch?: boolean;
22
- onText?: string;
23
- offText?: string;
24
- margin?: 'left' | 'right' | 'both' | 'none';
25
- }
26
-
27
- const ReqoreRadioGroup = ({
28
- items = [],
29
- selected,
30
- onSelectClick,
31
- size,
32
- disabled,
33
- asSwitch,
34
- vertical = true,
35
- onText,
36
- offText,
37
- margin = 'left',
38
- ...rest
39
- }: IReqoreRadioGroupProps) => (
40
- <ReqoreControlGroup {...rest} vertical={vertical}>
41
- {items.map(({ value, divider, ...itemRest }, index) =>
42
- divider ? (
43
- <ReqoreMenuDivider
44
- {...itemRest}
45
- key={index}
46
- size={size || itemRest.size}
47
- effect={{ textAlign: 'left', ...itemRest.effect }}
48
- margin={margin}
49
- label={vertical ? itemRest.label : undefined}
50
- />
51
- ) : (
52
- <ReqoreCheckbox
53
- asSwitch={asSwitch}
54
- onText={onText}
55
- offText={offText}
56
- margin={margin}
57
- {...itemRest}
58
- key={value}
59
- checked={value === selected}
60
- size={size || itemRest.size}
61
- disabled={disabled || itemRest.disabled}
62
- onClick={() => {
63
- onSelectClick(value);
64
- }}
65
- />
66
- )
67
- )}
68
- </ReqoreControlGroup>
69
- );
70
-
71
- export default ReqoreRadioGroup;
@@ -1,358 +0,0 @@
1
- import * as Slider from '@radix-ui/react-slider';
2
- import { useCallback, useMemo, useState } from 'react';
3
- import styled, { css } from 'styled-components';
4
- import { HALF_PADDING_FROM_SIZE, ICON_FROM_SIZE, TSizes } from '../../constants/sizes';
5
- import { IReqoreCustomTheme, TReqoreIntent } from '../../constants/theme';
6
- import { changeLightness, getReadableColor } from '../../helpers/colors';
7
- import { useReqoreTheme } from '../../hooks/useTheme';
8
- import { useTooltip } from '../../hooks/useTooltip';
9
- import { TReqoreTooltipProp } from '../../types/global';
10
- import { IReqoreIconName } from '../../types/icons';
11
- import ReqoreControlGroup, { IReqoreControlGroupProps } from '../ControlGroup';
12
- import { IReqoreEffect, IReqoreTextEffectProps, StyledEffect, TReqoreEffectColor } from '../Effect';
13
- import ReqoreIcon, { IReqoreIconProps } from '../Icon';
14
- import { IReqoreParagraphProps, ReqoreP } from '../Paragraph';
15
- import ReqoreTag, { IReqoreTagProps } from '../Tag';
16
-
17
- export interface ISliderProps<T extends number | [number, number] = number>
18
- extends Omit<Slider.SliderProps, 'onChange' | 'value' | 'defaultValue' | 'onValueChange'> {
19
- value: T;
20
- onChange(values: T): void;
21
- fluid?: boolean;
22
-
23
- icon?: IReqoreIconName;
24
- iconColor?: TReqoreEffectColor;
25
- iconProps?: IReqoreIconProps;
26
-
27
- rightIcon?: IReqoreIconName;
28
- rightIconColor?: TReqoreEffectColor;
29
- rightIconProps?: IReqoreIconProps;
30
-
31
- showLabels?: boolean;
32
- size?: TSizes;
33
- labelsPosition: 'top' | 'bottom';
34
- customTheme?: IReqoreCustomTheme;
35
- intent?: TReqoreIntent;
36
- effect?: IReqoreEffect;
37
- tooltip: TReqoreTooltipProp;
38
-
39
- trackProps?: Partial<IReqoreTextEffectProps>;
40
- rangeProps?: Partial<IReqoreTextEffectProps>;
41
- thumbProps?: Partial<IReqoreTextEffectProps>;
42
-
43
- minLabelProps?: IReqoreParagraphProps;
44
- currentMinLabelProps?: IReqoreTagProps;
45
- maxLabelProps?: IReqoreParagraphProps;
46
- currentMaxLabelProps?: IReqoreTagProps;
47
- wrapperProps?: IReqoreControlGroupProps;
48
-
49
- displayCurrentValueOverThumb?: boolean;
50
- }
51
-
52
- const StyledControlGroupWrapper = styled(ReqoreControlGroup)`
53
- &[data-orientation='horizontal'] {
54
- &[data-fluid='false'] {
55
- max-width: 200px;
56
- min-width: 200px;
57
- }
58
- }
59
- &[data-orientation='vertical'] {
60
- &[data-fluid='false'] {
61
- max-height: 200px;
62
- }
63
- }
64
- `;
65
-
66
- const StyledTrack = styled(Slider.Track)`
67
- background-color: ${(props) => props.background};
68
- position: relative;
69
- border-radius: 9999px;
70
- `;
71
- const StyledRange = styled(Slider.Range)`
72
- position: absolute;
73
- background-color: ${(props) => props.background};
74
- border-radius: 9999px;
75
- `;
76
- const StyledThumb = styled(Slider.Thumb)`
77
- display: block;
78
- background-color: ${(props) => props.background};
79
- border-radius: 9999px;
80
- transition: all 0.2s ease-out;
81
-
82
- &:focus {
83
- box-shadow: 0 0 0 8px ${(props) => props.background}15;
84
- outline: none;
85
- }
86
- `;
87
- const StyledRoot = styled(Slider.Root)`
88
- position: relative;
89
- display: inline-flex;
90
- align-items: center;
91
- cursor: pointer;
92
- flex-grow: 1;
93
-
94
- &[aria-disabled='true'] {
95
- opacity: 0.5;
96
- cursor: not-allowed;
97
- pointer-events: none;
98
- }
99
-
100
- ${({ 'data-size': size }) => css`
101
- ${StyledThumb} {
102
- width: ${ICON_FROM_SIZE[size]}px;
103
- height: ${ICON_FROM_SIZE[size]}px;
104
- min-width: ${ICON_FROM_SIZE[size]}px;
105
- }
106
- `}
107
-
108
- &[data-orientation='horizontal'] {
109
- width: 100%;
110
-
111
- ${({ 'data-size': size }) => css`
112
- height: ${ICON_FROM_SIZE[size]}px;
113
-
114
- ${StyledTrack} {
115
- height: ${HALF_PADDING_FROM_SIZE[size]}px;
116
- }
117
- `}
118
-
119
- ${StyledTrack} {
120
- flex-grow: 1;
121
- }
122
- ${StyledRange} {
123
- height: 100%;
124
- }
125
- }
126
-
127
- &[data-orientation='vertical'] {
128
- flex-direction: column;
129
- justify-content: center;
130
- height: 200px;
131
-
132
- ${({ 'data-size': size }) => css`
133
- width: ${ICON_FROM_SIZE[size]}px;
134
-
135
- ${StyledTrack} {
136
- width: ${HALF_PADDING_FROM_SIZE[size]}px;
137
- }
138
- `}
139
-
140
- ${StyledTrack} {
141
- flex-grow: 1;
142
- }
143
- ${StyledRange} {
144
- width: 100%;
145
- }
146
- }
147
- `;
148
-
149
- const StyledCurrentValue = styled(ReqoreTag)`
150
- position: absolute;
151
- ${({ position, isAboveThreshold, isBelowThreshold }) =>
152
- css`
153
- ${position}: ${isAboveThreshold || isBelowThreshold ? '-5px' : '-35px'};
154
- ${position === 'left' || position === 'right' ? 'top' : 'left'}: 50%;
155
- transform: ${position === 'left' || position === 'right'
156
- ? 'translateY(-50%)'
157
- : 'translateX(-50%)'};
158
- `}
159
- `;
160
-
161
- const SliderRootWrapper = styled(ReqoreControlGroup)`
162
- align-items: center;
163
- flex-grow: 1;
164
- width: 100%;
165
- `;
166
-
167
- export function ReqoreSlider<T extends number | [number, number] = number>({
168
- value,
169
- onChange,
170
- step = 0.1,
171
- orientation = 'horizontal',
172
- fluid = true,
173
- showLabels,
174
- icon,
175
- iconColor,
176
- iconProps,
177
- rightIcon,
178
- rightIconColor,
179
- rightIconProps,
180
- customTheme,
181
- intent,
182
- effect,
183
- trackProps,
184
- rangeProps,
185
- thumbProps,
186
- minLabelProps,
187
- maxLabelProps,
188
- size = 'normal',
189
- wrapperProps,
190
- labelsPosition = 'top',
191
- tooltip,
192
- currentMaxLabelProps,
193
- currentMinLabelProps,
194
- displayCurrentValueOverThumb,
195
- ...props
196
- }: ISliderProps<T>) {
197
- const [wrapperRef, setWrapperRef] = useState<HTMLDivElement>(undefined);
198
- const theme = useReqoreTheme('main', customTheme, intent);
199
-
200
- useTooltip(wrapperRef, tooltip);
201
-
202
- const background = intent
203
- ? changeLightness(theme.main, 0.2)
204
- : getReadableColor(theme, undefined, undefined, true);
205
- const trackBackground = intent
206
- ? changeLightness(theme.main, 0.05)
207
- : changeLightness(theme.main, 0.2);
208
- const isRange = Array.isArray(value);
209
-
210
- const renderLabels = useCallback(() => {
211
- if (!showLabels) {
212
- return null;
213
- }
214
-
215
- return (
216
- <ReqoreControlGroup fluid spaceBetween vertical={orientation === 'vertical'} fill>
217
- <ReqoreControlGroup fixed vertical={orientation === 'vertical'} horizontalAlign='center'>
218
- {icon && (
219
- <ReqoreIcon icon={icon} size={size} color={iconColor} intent={intent} {...iconProps} />
220
- )}
221
- {props.min || props.min === 0 ? (
222
- <ReqoreP size={size} intent={intent} effect={effect} {...minLabelProps}>
223
- {props.min}
224
- </ReqoreP>
225
- ) : null}
226
- </ReqoreControlGroup>
227
- <ReqoreControlGroup fixed vertical={orientation === 'vertical'} horizontalAlign='center'>
228
- {props.max || props.max === 0 ? (
229
- <ReqoreP size={size} intent={intent} effect={effect} {...maxLabelProps}>
230
- {props.max}
231
- </ReqoreP>
232
- ) : null}
233
- {rightIcon && (
234
- <ReqoreIcon
235
- icon={rightIcon}
236
- size={size}
237
- color={rightIconColor}
238
- intent={intent}
239
- {...rightIconProps}
240
- />
241
- )}
242
- </ReqoreControlGroup>
243
- </ReqoreControlGroup>
244
- );
245
- }, [
246
- icon,
247
- rightIcon,
248
- iconProps,
249
- rightIconProps,
250
- minLabelProps,
251
- maxLabelProps,
252
- size,
253
- intent,
254
- props.min,
255
- props.max,
256
- showLabels,
257
- orientation,
258
- effect,
259
- ]);
260
-
261
- const currentValuePosition = useMemo(() => {
262
- return orientation === 'horizontal'
263
- ? labelsPosition === 'top'
264
- ? 'top'
265
- : 'bottom'
266
- : labelsPosition === 'top'
267
- ? 'left'
268
- : 'right';
269
- }, [orientation, labelsPosition]);
270
-
271
- const isMinValueBelowThreshold = useMemo(() => {
272
- const _value: number = isRange ? value[0] : value;
273
-
274
- return _value < props.min + step * 5;
275
- }, [value, props.min]);
276
-
277
- const isMaxValueAboveThreshold = useMemo(() => {
278
- if (!isRange) return false;
279
-
280
- const _value: number = value[1];
281
-
282
- return _value > props.max - step * 5;
283
- }, [value, props.max]);
284
-
285
- return (
286
- <StyledControlGroupWrapper
287
- ref={setWrapperRef}
288
- data-orientation={orientation}
289
- data-labels-position={labelsPosition}
290
- data-fluid={fluid}
291
- fluid={fluid}
292
- vertical={orientation === 'horizontal'}
293
- fill
294
- gapSize={orientation === 'horizontal' ? 'big' : 'normal'}
295
- {...wrapperProps}
296
- >
297
- {labelsPosition === 'top' && renderLabels()}
298
- <SliderRootWrapper vertical={orientation === 'vertical'}>
299
- <StyledRoot
300
- data-size={size}
301
- orientation={orientation}
302
- minStepsBetweenThumbs={step}
303
- inverted={orientation === 'vertical'}
304
- step={step}
305
- {...props}
306
- value={isRange ? value : [value]}
307
- onValueChange={(values) => {
308
- onChange((isRange ? values : values[0]) as T);
309
- }}
310
- >
311
- <StyledTrack background={trackBackground} asChild>
312
- <StyledEffect effect={effect} {...trackProps}>
313
- <StyledRange background={background} asChild>
314
- <StyledEffect effect={effect} {...rangeProps} />
315
- </StyledRange>
316
- </StyledEffect>
317
- </StyledTrack>
318
-
319
- <StyledThumb background={background} asChild>
320
- <StyledEffect effect={effect} {...thumbProps}>
321
- {showLabels && (
322
- <StyledCurrentValue
323
- size={size}
324
- effect={effect}
325
- intent={intent}
326
- position={currentValuePosition}
327
- label={isRange ? value[0] : value}
328
- isBelowThreshold={displayCurrentValueOverThumb || isMinValueBelowThreshold}
329
- {...currentMinLabelProps}
330
- />
331
- )}
332
- </StyledEffect>
333
- </StyledThumb>
334
- {isRange && (
335
- <StyledThumb background={background} asChild>
336
- <StyledEffect effect={effect} {...thumbProps}>
337
- {showLabels && (
338
- <StyledCurrentValue
339
- size={size}
340
- effect={effect}
341
- intent={intent}
342
- position={currentValuePosition}
343
- isAboveThreshold={displayCurrentValueOverThumb || isMaxValueAboveThreshold}
344
- label={value[1]}
345
- {...currentMaxLabelProps}
346
- />
347
- )}
348
- </StyledEffect>
349
- </StyledThumb>
350
- )}
351
- </StyledRoot>
352
- </SliderRootWrapper>
353
- {labelsPosition === 'bottom' && renderLabels()}
354
- </StyledControlGroupWrapper>
355
- );
356
- }
357
-
358
- export default ReqoreSlider;
@@ -1,142 +0,0 @@
1
- import { memo, useMemo } from 'react';
2
- import styled, { css } from 'styled-components';
3
- import { LINE_SIZE_TO_NUMBER, TEXT_FROM_SIZE, TSizes } from '../../constants/sizes';
4
- import { changeLightness } from '../../helpers/colors';
5
- import { useReqoreTheme } from '../../hooks/useTheme';
6
- import { IReqoreIntent, IWithReqoreCustomTheme, IWithReqoreEffect } from '../../types/global';
7
- import { StyledEffect } from '../Effect';
8
-
9
- export const StyledSpacer = styled.div`
10
- display: ${({ horizontal }) => (horizontal ? 'inline-flex' : 'flex')};
11
- vertical-align: middle;
12
-
13
- ${({ horizontal, vertical }) => {
14
- if (horizontal) {
15
- return css`
16
- flex-flow: row;
17
- `;
18
- }
19
-
20
- if (vertical) {
21
- return css`
22
- flex-flow: column;
23
- `;
24
- }
25
- }}
26
-
27
- flex-shrink: 0;
28
- `;
29
-
30
- export const StyledSpace = styled.div`
31
- display: inline-block;
32
- flex: 0 0 auto;
33
-
34
- ${({ horizontal, vertical, width, height, lineSize }) => {
35
- if (horizontal) {
36
- return css`
37
- width: ${width / 2 - lineSize / 2}px;
38
- height: ${height ? `${height}px` : `${TEXT_FROM_SIZE.normal}px`};
39
- `;
40
- }
41
-
42
- if (vertical) {
43
- return css`
44
- width: ${width ? `${width}px` : '100%'};
45
- height: ${height / 2 - lineSize / 2}px;
46
- `;
47
- }
48
- }}
49
- `;
50
-
51
- export const StyledLine = styled(StyledEffect)`
52
- flex-shrink: 0;
53
- background-color: ${({ theme, lineSize }) =>
54
- lineSize === 'none' ? 'transparent' : changeLightness(theme.main, 0.2)};
55
-
56
- ${({ horizontal, vertical, width, height, lineSize }) => {
57
- if (horizontal) {
58
- return css`
59
- width: ${lineSize}px;
60
- height: ${height ? `${height}px` : `${TEXT_FROM_SIZE.normal}px`};
61
- `;
62
- }
63
-
64
- if (vertical) {
65
- return css`
66
- width: ${width ? `${width}px` : '100%'};
67
- height: ${lineSize}px;
68
- `;
69
- }
70
- }}
71
- `;
72
-
73
- export interface IReqoreSpacerProps
74
- extends React.HTMLAttributes<HTMLDivElement>,
75
- IWithReqoreEffect,
76
- IWithReqoreCustomTheme,
77
- IReqoreIntent {
78
- width?: number;
79
- height?: number;
80
- lineSize?: TSizes | 'none';
81
- }
82
-
83
- export const ReqoreSpacer = memo(
84
- ({
85
- customTheme,
86
- intent,
87
- lineSize = 'none',
88
- ...rest
89
- }: IReqoreSpacerProps & { horizontal?: boolean; vertical?: boolean }) => {
90
- const theme = useReqoreTheme('main', customTheme, intent);
91
- let { horizontal, vertical } = rest;
92
-
93
- // The user is using old version of the component
94
- // We will assume that the user wants a spacer based on the width or height
95
- if (!horizontal && !vertical) {
96
- if (rest.width) {
97
- horizontal = true;
98
- }
99
-
100
- if (rest.height) {
101
- vertical = true;
102
- }
103
- }
104
-
105
- const _lineSize = useMemo(
106
- () => (lineSize === 'none' ? 0 : LINE_SIZE_TO_NUMBER[lineSize]),
107
- [lineSize]
108
- );
109
-
110
- return (
111
- <StyledSpacer
112
- as='div'
113
- {...rest}
114
- horizontal={horizontal}
115
- vertical={vertical}
116
- className='reqore-spacer'
117
- >
118
- <StyledSpace {...rest} horizontal={horizontal} vertical={vertical} lineSize={_lineSize} />
119
- <StyledLine
120
- {...rest}
121
- horizontal={horizontal}
122
- vertical={vertical}
123
- theme={theme}
124
- lineSize={_lineSize}
125
- />
126
- <StyledSpace {...rest} horizontal={horizontal} vertical={vertical} lineSize={_lineSize} />
127
- </StyledSpacer>
128
- );
129
- }
130
- );
131
-
132
- export const ReqoreHorizontalSpacer = memo(
133
- ({ width = 1, lineSize = 'none', ...rest }: IReqoreSpacerProps) => {
134
- return <ReqoreSpacer width={width} lineSize={lineSize} horizontal {...rest} />;
135
- }
136
- );
137
-
138
- export const ReqoreVerticalSpacer = memo(
139
- ({ height = 1, lineSize = 'none', ...rest }: IReqoreSpacerProps) => {
140
- return <ReqoreSpacer height={height} lineSize={lineSize} vertical {...rest} />;
141
- }
142
- );