@qoretechnologies/reqore 0.44.0 → 0.46.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 (226) hide show
  1. package/dist/constants/theme.d.ts +8 -1
  2. package/dist/constants/theme.d.ts.map +1 -1
  3. package/dist/constants/theme.js +16 -2
  4. package/dist/constants/theme.js.map +1 -1
  5. package/package.json +1 -1
  6. package/tests.json +1 -1
  7. package/.eslintrc.js +0 -40
  8. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  9. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  10. package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
  11. package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
  12. package/.github/workflows/beta_release.yml +0 -100
  13. package/.github/workflows/tests.yml +0 -84
  14. package/.gitpod.yml +0 -11
  15. package/.jest-test-results.json +0 -1
  16. package/.prettierrc +0 -7
  17. package/.vscode/settings.json +0 -0
  18. package/__tests__/breadcrumbs.test.tsx +0 -75
  19. package/__tests__/button.test.tsx +0 -218
  20. package/__tests__/checkbox.test.tsx +0 -45
  21. package/__tests__/collection.test.tsx +0 -243
  22. package/__tests__/containers/paging.test.tsx +0 -138
  23. package/__tests__/control_group.test.tsx +0 -32
  24. package/__tests__/drawer.test.tsx +0 -140
  25. package/__tests__/dropdown.test.tsx +0 -381
  26. package/__tests__/effect.test.tsx +0 -70
  27. package/__tests__/heading.test.tsx +0 -58
  28. package/__tests__/helpers/colors.test.tsx +0 -18
  29. package/__tests__/helpers/table.test.tsx +0 -67
  30. package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
  31. package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
  32. package/__tests__/hooks/useTheme.test.tsx +0 -31
  33. package/__tests__/icon.test.tsx +0 -53
  34. package/__tests__/input.test.tsx +0 -482
  35. package/__tests__/layout.test.tsx +0 -37
  36. package/__tests__/menu.test.tsx +0 -65
  37. package/__tests__/messages.test.tsx +0 -79
  38. package/__tests__/modal.test.tsx +0 -204
  39. package/__tests__/multiselect.test.tsx +0 -458
  40. package/__tests__/navbar.test.tsx +0 -31
  41. package/__tests__/notifications.test.tsx +0 -178
  42. package/__tests__/pagination.test.tsx +0 -437
  43. package/__tests__/panel.test.tsx +0 -243
  44. package/__tests__/popover.test.tsx +0 -282
  45. package/__tests__/radiogroup.test.tsx +0 -47
  46. package/__tests__/setup.js +0 -8
  47. package/__tests__/stories/Collection.stories.tsx +0 -0
  48. package/__tests__/table.test.tsx +0 -647
  49. package/__tests__/tabs.test.tsx +0 -321
  50. package/__tests__/tag.test.tsx +0 -160
  51. package/__tests__/textarea.test.tsx +0 -467
  52. package/__tests__/timeAgo.test.tsx +0 -27
  53. package/__tests__/tree.test.tsx +0 -58
  54. package/build-storybook.log +0 -491
  55. package/chromatic.config.json +0 -1
  56. package/icons.ts +0 -1
  57. package/migration-storybook.log +0 -56
  58. package/public/logo-dark.png +0 -0
  59. package/public/logo.png +0 -0
  60. package/public/q-symbol-small.png +0 -0
  61. package/public/q-symbol.png +0 -0
  62. package/public/qoreLogo-dark.png +0 -0
  63. package/public/qoreLogo.png +0 -0
  64. package/src/components/Breadcrumbs/index.tsx +0 -254
  65. package/src/components/Breadcrumbs/item.tsx +0 -44
  66. package/src/components/Button/index.tsx +0 -633
  67. package/src/components/Checkbox/index.tsx +0 -388
  68. package/src/components/Collection/index.tsx +0 -426
  69. package/src/components/Collection/item.tsx +0 -267
  70. package/src/components/Columns/column.tsx +0 -27
  71. package/src/components/Columns/index.tsx +0 -41
  72. package/src/components/Comment/index.tsx +0 -141
  73. package/src/components/CommentFeed/index.tsx +0 -34
  74. package/src/components/Content/index.tsx +0 -34
  75. package/src/components/Content/wrapper.tsx +0 -36
  76. package/src/components/ControlGroup/index.tsx +0 -523
  77. package/src/components/DatePicker/index.tsx +0 -347
  78. package/src/components/Drawer/backdrop.tsx +0 -54
  79. package/src/components/Drawer/index.tsx +0 -365
  80. package/src/components/Dropdown/index.tsx +0 -153
  81. package/src/components/Dropdown/item.tsx +0 -33
  82. package/src/components/Dropdown/list.tsx +0 -222
  83. package/src/components/Effect/index.tsx +0 -464
  84. package/src/components/ExportModal/index.tsx +0 -99
  85. package/src/components/Header/index.tsx +0 -81
  86. package/src/components/Icon/index.tsx +0 -184
  87. package/src/components/Input/index.tsx +0 -295
  88. package/src/components/InputClearButton/index.tsx +0 -59
  89. package/src/components/InternalPopover/index.tsx +0 -303
  90. package/src/components/KeyValueTable/index.tsx +0 -192
  91. package/src/components/Label/index.tsx +0 -10
  92. package/src/components/Layout/content.tsx +0 -31
  93. package/src/components/Layout/index.tsx +0 -55
  94. package/src/components/Menu/divider.tsx +0 -92
  95. package/src/components/Menu/index.tsx +0 -141
  96. package/src/components/Menu/item.tsx +0 -137
  97. package/src/components/Menu/section.tsx +0 -81
  98. package/src/components/Message/index.tsx +0 -220
  99. package/src/components/Modal/index.tsx +0 -26
  100. package/src/components/MultiSelect/index.tsx +0 -288
  101. package/src/components/Navbar/divider.tsx +0 -50
  102. package/src/components/Navbar/group.tsx +0 -53
  103. package/src/components/Navbar/index.tsx +0 -82
  104. package/src/components/Navbar/item.tsx +0 -92
  105. package/src/components/Notifications/index.tsx +0 -57
  106. package/src/components/Notifications/notification.tsx +0 -362
  107. package/src/components/Paging/index.tsx +0 -321
  108. package/src/components/Panel/LabelEditor.tsx +0 -67
  109. package/src/components/Panel/NonResponsiveActions.tsx +0 -79
  110. package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
  111. package/src/components/Panel/index.tsx +0 -912
  112. package/src/components/Panel/panel.screenshot.tsx +0 -29
  113. package/src/components/Paragraph/index.tsx +0 -43
  114. package/src/components/Popover/index.tsx +0 -68
  115. package/src/components/RadioGroup/index.tsx +0 -71
  116. package/src/components/Slider/index.tsx +0 -358
  117. package/src/components/Spacer/index.tsx +0 -142
  118. package/src/components/Spinner/index.tsx +0 -74
  119. package/src/components/Table/body.tsx +0 -109
  120. package/src/components/Table/cell.tsx +0 -136
  121. package/src/components/Table/header.tsx +0 -236
  122. package/src/components/Table/headerCell.tsx +0 -203
  123. package/src/components/Table/helpers.ts +0 -308
  124. package/src/components/Table/index.tsx +0 -797
  125. package/src/components/Table/row.tsx +0 -288
  126. package/src/components/Table/value.tsx +0 -28
  127. package/src/components/Tabs/content.tsx +0 -68
  128. package/src/components/Tabs/index.tsx +0 -124
  129. package/src/components/Tabs/item.tsx +0 -198
  130. package/src/components/Tabs/list.tsx +0 -381
  131. package/src/components/Tag/group.tsx +0 -73
  132. package/src/components/Tag/index.tsx +0 -463
  133. package/src/components/Textarea/index.tsx +0 -277
  134. package/src/components/TimeAgo/index.tsx +0 -15
  135. package/src/components/Tree/index.tsx +0 -271
  136. package/src/constants/animations.ts +0 -9
  137. package/src/constants/colors.ts +0 -13
  138. package/src/constants/paging.ts +0 -93
  139. package/src/constants/sizes.ts +0 -185
  140. package/src/constants/theme.ts +0 -122
  141. package/src/containers/Paging.tsx +0 -136
  142. package/src/containers/PopoverProvider.tsx +0 -124
  143. package/src/containers/ReqoreProvider.tsx +0 -289
  144. package/src/containers/ThemeProvider.tsx +0 -12
  145. package/src/containers/UIProvider.tsx +0 -101
  146. package/src/context/PopoverContext.tsx +0 -11
  147. package/src/context/ReqoreContext.tsx +0 -47
  148. package/src/context/ThemeContext.tsx +0 -4
  149. package/src/helpers/animations.ts +0 -13
  150. package/src/helpers/colors.ts +0 -335
  151. package/src/helpers/time.ts +0 -21
  152. package/src/helpers/utils.ts +0 -152
  153. package/src/hooks/useAutoFocus.ts +0 -106
  154. package/src/hooks/useCloneThroughFragments.ts +0 -39
  155. package/src/hooks/useCombinedRefs.ts +0 -26
  156. package/src/hooks/useLatestZIndex.ts +0 -13
  157. package/src/hooks/useOutsideClick.ts +0 -29
  158. package/src/hooks/usePaging.ts +0 -128
  159. package/src/hooks/usePopover.tsx +0 -220
  160. package/src/hooks/useQueryWithDelay.ts +0 -30
  161. package/src/hooks/useReqore.ts +0 -12
  162. package/src/hooks/useReqoreContext.ts +0 -16
  163. package/src/hooks/useReqoreEffect.ts +0 -49
  164. package/src/hooks/useTextareaAutoSize.ts +0 -22
  165. package/src/hooks/useTheme.ts +0 -48
  166. package/src/hooks/useTooltip.ts +0 -40
  167. package/src/hooks/useWhyDidYouUpdate.ts +0 -32
  168. package/src/icons.json +0 -2295
  169. package/src/index.tsx +0 -80
  170. package/src/mock/breadcrumbs.ts +0 -146
  171. package/src/mock/collectionData.tsx +0 -380
  172. package/src/mock/data.json +0 -11000
  173. package/src/mock/icons.ts +0 -32
  174. package/src/mock/menu.ts +0 -93
  175. package/src/mock/multiSelect.ts +0 -71
  176. package/src/mock/object.json +0 -317
  177. package/src/mock/styleMock.js +0 -1
  178. package/src/mock/tableData.ts +0 -64
  179. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
  180. package/src/stories/Button/Button.stories.tsx +0 -405
  181. package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
  182. package/src/stories/Collection/Collection.stories.tsx +0 -317
  183. package/src/stories/Columns/Columns.stories.tsx +0 -158
  184. package/src/stories/Comment/Comment.stories.tsx +0 -136
  185. package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
  186. package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
  187. package/src/stories/Drawer/Drawer.stories.tsx +0 -294
  188. package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
  189. package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
  190. package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
  191. package/src/stories/Header/Header.stories.tsx +0 -108
  192. package/src/stories/Icon/Icon.stories.tsx +0 -162
  193. package/src/stories/Input/Input.stories.tsx +0 -220
  194. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
  195. package/src/stories/Label/Label.stories.tsx +0 -33
  196. package/src/stories/Menu/Menu.stories.tsx +0 -367
  197. package/src/stories/Message/Message.stories.tsx +0 -167
  198. package/src/stories/Modal/Manager.stories.tsx +0 -192
  199. package/src/stories/Modal/Modal.stories.tsx +0 -252
  200. package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
  201. package/src/stories/Navbar/Navbar.stories.tsx +0 -119
  202. package/src/stories/Notifications/Interactive.stories.tsx +0 -117
  203. package/src/stories/Notifications/Notification.stories.tsx +0 -216
  204. package/src/stories/Notifications/Notifications.stories.tsx +0 -81
  205. package/src/stories/Paging/Paging.stories.tsx +0 -255
  206. package/src/stories/Panel/Panel.stories.tsx +0 -753
  207. package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
  208. package/src/stories/Popover/Popover.stories.tsx +0 -510
  209. package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
  210. package/src/stories/Slider/Slider.stories.tsx +0 -173
  211. package/src/stories/Spacer/Spacer.stories.tsx +0 -100
  212. package/src/stories/Spinner/Spinner.stories.tsx +0 -82
  213. package/src/stories/Table/Table.stories.tsx +0 -571
  214. package/src/stories/Tabs/Tabs.stories.tsx +0 -346
  215. package/src/stories/Tag/Tag.stories.tsx +0 -381
  216. package/src/stories/Tag/TagGroup.stories.tsx +0 -307
  217. package/src/stories/TextArea/TextArea.stories.tsx +0 -287
  218. package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
  219. package/src/stories/Tree/Tree.stories.tsx +0 -124
  220. package/src/stories/Wrapper.tsx +0 -13
  221. package/src/stories/utils/args.ts +0 -151
  222. package/src/stories/utils.ts +0 -39
  223. package/src/styles.ts +0 -124
  224. package/src/types/global.ts +0 -211
  225. package/src/types/icons.ts +0 -2272
  226. 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
- );