@qoretechnologies/reqore 0.43.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 (243) hide show
  1. package/dist/components/Button/index.d.ts +1 -0
  2. package/dist/components/Button/index.d.ts.map +1 -1
  3. package/dist/components/Button/index.js +6 -2
  4. package/dist/components/Button/index.js.map +1 -1
  5. package/dist/components/DatePicker/index.d.ts +29 -0
  6. package/dist/components/DatePicker/index.d.ts.map +1 -0
  7. package/dist/components/DatePicker/index.js +147 -0
  8. package/dist/components/DatePicker/index.js.map +1 -0
  9. package/dist/components/Effect/index.d.ts +1 -1
  10. package/dist/components/Effect/index.d.ts.map +1 -1
  11. package/dist/components/Effect/index.js.map +1 -1
  12. package/dist/components/Input/index.d.ts +3 -1
  13. package/dist/components/Input/index.d.ts.map +1 -1
  14. package/dist/components/Input/index.js +5 -1
  15. package/dist/components/Input/index.js.map +1 -1
  16. package/dist/components/InternalPopover/index.d.ts +2 -0
  17. package/dist/components/InternalPopover/index.d.ts.map +1 -1
  18. package/dist/components/InternalPopover/index.js +5 -4
  19. package/dist/components/InternalPopover/index.js.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +1 -0
  23. package/dist/index.js.map +1 -1
  24. package/package.json +4 -1
  25. package/tests.json +1 -1
  26. package/.eslintrc.js +0 -40
  27. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  28. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
  29. package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
  30. package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
  31. package/.github/workflows/beta_release.yml +0 -100
  32. package/.github/workflows/tests.yml +0 -84
  33. package/.gitpod.yml +0 -11
  34. package/.jest-test-results.json +0 -1
  35. package/.prettierrc +0 -7
  36. package/.vscode/settings.json +0 -0
  37. package/__tests__/breadcrumbs.test.tsx +0 -75
  38. package/__tests__/button.test.tsx +0 -218
  39. package/__tests__/checkbox.test.tsx +0 -45
  40. package/__tests__/collection.test.tsx +0 -243
  41. package/__tests__/containers/paging.test.tsx +0 -138
  42. package/__tests__/control_group.test.tsx +0 -32
  43. package/__tests__/drawer.test.tsx +0 -140
  44. package/__tests__/dropdown.test.tsx +0 -381
  45. package/__tests__/effect.test.tsx +0 -70
  46. package/__tests__/heading.test.tsx +0 -58
  47. package/__tests__/helpers/colors.test.tsx +0 -18
  48. package/__tests__/helpers/table.test.tsx +0 -67
  49. package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
  50. package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
  51. package/__tests__/hooks/useTheme.test.tsx +0 -31
  52. package/__tests__/icon.test.tsx +0 -53
  53. package/__tests__/input.test.tsx +0 -482
  54. package/__tests__/layout.test.tsx +0 -37
  55. package/__tests__/menu.test.tsx +0 -65
  56. package/__tests__/messages.test.tsx +0 -79
  57. package/__tests__/modal.test.tsx +0 -204
  58. package/__tests__/multiselect.test.tsx +0 -458
  59. package/__tests__/navbar.test.tsx +0 -31
  60. package/__tests__/notifications.test.tsx +0 -178
  61. package/__tests__/pagination.test.tsx +0 -437
  62. package/__tests__/panel.test.tsx +0 -243
  63. package/__tests__/popover.test.tsx +0 -282
  64. package/__tests__/radiogroup.test.tsx +0 -47
  65. package/__tests__/setup.js +0 -8
  66. package/__tests__/stories/Collection.stories.tsx +0 -0
  67. package/__tests__/table.test.tsx +0 -647
  68. package/__tests__/tabs.test.tsx +0 -321
  69. package/__tests__/tag.test.tsx +0 -160
  70. package/__tests__/textarea.test.tsx +0 -467
  71. package/__tests__/timeAgo.test.tsx +0 -27
  72. package/__tests__/tree.test.tsx +0 -58
  73. package/build-storybook.log +0 -491
  74. package/chromatic.config.json +0 -1
  75. package/icons.ts +0 -1
  76. package/migration-storybook.log +0 -56
  77. package/public/logo-dark.png +0 -0
  78. package/public/logo.png +0 -0
  79. package/public/q-symbol-small.png +0 -0
  80. package/public/q-symbol.png +0 -0
  81. package/public/qoreLogo-dark.png +0 -0
  82. package/public/qoreLogo.png +0 -0
  83. package/src/components/Breadcrumbs/index.tsx +0 -254
  84. package/src/components/Breadcrumbs/item.tsx +0 -44
  85. package/src/components/Button/index.tsx +0 -628
  86. package/src/components/Checkbox/index.tsx +0 -388
  87. package/src/components/Collection/index.tsx +0 -426
  88. package/src/components/Collection/item.tsx +0 -267
  89. package/src/components/Columns/column.tsx +0 -27
  90. package/src/components/Columns/index.tsx +0 -41
  91. package/src/components/Comment/index.tsx +0 -141
  92. package/src/components/CommentFeed/index.tsx +0 -34
  93. package/src/components/Content/index.tsx +0 -34
  94. package/src/components/Content/wrapper.tsx +0 -36
  95. package/src/components/ControlGroup/index.tsx +0 -523
  96. package/src/components/Drawer/backdrop.tsx +0 -54
  97. package/src/components/Drawer/index.tsx +0 -365
  98. package/src/components/Dropdown/index.tsx +0 -153
  99. package/src/components/Dropdown/item.tsx +0 -33
  100. package/src/components/Dropdown/list.tsx +0 -222
  101. package/src/components/Effect/index.tsx +0 -463
  102. package/src/components/ExportModal/index.tsx +0 -99
  103. package/src/components/Header/index.tsx +0 -81
  104. package/src/components/Icon/index.tsx +0 -184
  105. package/src/components/Input/index.tsx +0 -282
  106. package/src/components/InputClearButton/index.tsx +0 -59
  107. package/src/components/InternalPopover/index.tsx +0 -303
  108. package/src/components/KeyValueTable/index.tsx +0 -192
  109. package/src/components/Label/index.tsx +0 -10
  110. package/src/components/Layout/content.tsx +0 -31
  111. package/src/components/Layout/index.tsx +0 -55
  112. package/src/components/Menu/divider.tsx +0 -92
  113. package/src/components/Menu/index.tsx +0 -141
  114. package/src/components/Menu/item.tsx +0 -137
  115. package/src/components/Menu/section.tsx +0 -81
  116. package/src/components/Message/index.tsx +0 -220
  117. package/src/components/Modal/index.tsx +0 -26
  118. package/src/components/MultiSelect/index.tsx +0 -288
  119. package/src/components/Navbar/divider.tsx +0 -50
  120. package/src/components/Navbar/group.tsx +0 -53
  121. package/src/components/Navbar/index.tsx +0 -82
  122. package/src/components/Navbar/item.tsx +0 -92
  123. package/src/components/Notifications/index.tsx +0 -57
  124. package/src/components/Notifications/notification.tsx +0 -362
  125. package/src/components/Paging/index.tsx +0 -321
  126. package/src/components/Panel/LabelEditor.tsx +0 -67
  127. package/src/components/Panel/NonResponsiveActions.tsx +0 -79
  128. package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
  129. package/src/components/Panel/index.tsx +0 -912
  130. package/src/components/Panel/panel.screenshot.tsx +0 -29
  131. package/src/components/Paragraph/index.tsx +0 -43
  132. package/src/components/Popover/index.tsx +0 -68
  133. package/src/components/RadioGroup/index.tsx +0 -71
  134. package/src/components/Slider/index.tsx +0 -358
  135. package/src/components/Spacer/index.tsx +0 -142
  136. package/src/components/Spinner/index.tsx +0 -74
  137. package/src/components/Table/body.tsx +0 -109
  138. package/src/components/Table/cell.tsx +0 -136
  139. package/src/components/Table/header.tsx +0 -236
  140. package/src/components/Table/headerCell.tsx +0 -203
  141. package/src/components/Table/helpers.ts +0 -308
  142. package/src/components/Table/index.tsx +0 -797
  143. package/src/components/Table/row.tsx +0 -288
  144. package/src/components/Table/value.tsx +0 -28
  145. package/src/components/Tabs/content.tsx +0 -68
  146. package/src/components/Tabs/index.tsx +0 -124
  147. package/src/components/Tabs/item.tsx +0 -198
  148. package/src/components/Tabs/list.tsx +0 -381
  149. package/src/components/Tag/group.tsx +0 -73
  150. package/src/components/Tag/index.tsx +0 -463
  151. package/src/components/Textarea/index.tsx +0 -277
  152. package/src/components/TimeAgo/index.tsx +0 -15
  153. package/src/components/Tree/index.tsx +0 -271
  154. package/src/constants/animations.ts +0 -9
  155. package/src/constants/colors.ts +0 -13
  156. package/src/constants/paging.ts +0 -93
  157. package/src/constants/sizes.ts +0 -185
  158. package/src/constants/theme.ts +0 -122
  159. package/src/containers/Paging.tsx +0 -136
  160. package/src/containers/PopoverProvider.tsx +0 -124
  161. package/src/containers/ReqoreProvider.tsx +0 -289
  162. package/src/containers/ThemeProvider.tsx +0 -12
  163. package/src/containers/UIProvider.tsx +0 -101
  164. package/src/context/PopoverContext.tsx +0 -11
  165. package/src/context/ReqoreContext.tsx +0 -47
  166. package/src/context/ThemeContext.tsx +0 -4
  167. package/src/helpers/animations.ts +0 -13
  168. package/src/helpers/colors.ts +0 -335
  169. package/src/helpers/time.ts +0 -21
  170. package/src/helpers/utils.ts +0 -152
  171. package/src/hooks/useAutoFocus.ts +0 -106
  172. package/src/hooks/useCloneThroughFragments.ts +0 -39
  173. package/src/hooks/useCombinedRefs.ts +0 -26
  174. package/src/hooks/useLatestZIndex.ts +0 -13
  175. package/src/hooks/useOutsideClick.ts +0 -29
  176. package/src/hooks/usePaging.ts +0 -128
  177. package/src/hooks/usePopover.tsx +0 -220
  178. package/src/hooks/useQueryWithDelay.ts +0 -30
  179. package/src/hooks/useReqore.ts +0 -12
  180. package/src/hooks/useReqoreContext.ts +0 -16
  181. package/src/hooks/useReqoreEffect.ts +0 -49
  182. package/src/hooks/useTextareaAutoSize.ts +0 -22
  183. package/src/hooks/useTheme.ts +0 -48
  184. package/src/hooks/useTooltip.ts +0 -40
  185. package/src/hooks/useWhyDidYouUpdate.ts +0 -32
  186. package/src/icons.json +0 -2295
  187. package/src/index.tsx +0 -79
  188. package/src/mock/breadcrumbs.ts +0 -146
  189. package/src/mock/collectionData.tsx +0 -380
  190. package/src/mock/data.json +0 -11000
  191. package/src/mock/icons.ts +0 -32
  192. package/src/mock/menu.ts +0 -93
  193. package/src/mock/multiSelect.ts +0 -71
  194. package/src/mock/object.json +0 -317
  195. package/src/mock/styleMock.js +0 -1
  196. package/src/mock/tableData.ts +0 -64
  197. package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
  198. package/src/stories/Button/Button.stories.tsx +0 -405
  199. package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
  200. package/src/stories/Collection/Collection.stories.tsx +0 -317
  201. package/src/stories/Columns/Columns.stories.tsx +0 -158
  202. package/src/stories/Comment/Comment.stories.tsx +0 -136
  203. package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
  204. package/src/stories/Drawer/Drawer.stories.tsx +0 -294
  205. package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
  206. package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
  207. package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
  208. package/src/stories/Header/Header.stories.tsx +0 -108
  209. package/src/stories/Icon/Icon.stories.tsx +0 -162
  210. package/src/stories/Input/Input.stories.tsx +0 -220
  211. package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
  212. package/src/stories/Label/Label.stories.tsx +0 -33
  213. package/src/stories/Menu/Menu.stories.tsx +0 -367
  214. package/src/stories/Message/Message.stories.tsx +0 -167
  215. package/src/stories/Modal/Manager.stories.tsx +0 -192
  216. package/src/stories/Modal/Modal.stories.tsx +0 -252
  217. package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
  218. package/src/stories/Navbar/Navbar.stories.tsx +0 -119
  219. package/src/stories/Notifications/Interactive.stories.tsx +0 -117
  220. package/src/stories/Notifications/Notification.stories.tsx +0 -216
  221. package/src/stories/Notifications/Notifications.stories.tsx +0 -81
  222. package/src/stories/Paging/Paging.stories.tsx +0 -255
  223. package/src/stories/Panel/Panel.stories.tsx +0 -753
  224. package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
  225. package/src/stories/Popover/Popover.stories.tsx +0 -510
  226. package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
  227. package/src/stories/Slider/Slider.stories.tsx +0 -173
  228. package/src/stories/Spacer/Spacer.stories.tsx +0 -100
  229. package/src/stories/Spinner/Spinner.stories.tsx +0 -82
  230. package/src/stories/Table/Table.stories.tsx +0 -571
  231. package/src/stories/Tabs/Tabs.stories.tsx +0 -346
  232. package/src/stories/Tag/Tag.stories.tsx +0 -381
  233. package/src/stories/Tag/TagGroup.stories.tsx +0 -307
  234. package/src/stories/TextArea/TextArea.stories.tsx +0 -287
  235. package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
  236. package/src/stories/Tree/Tree.stories.tsx +0 -124
  237. package/src/stories/Wrapper.tsx +0 -13
  238. package/src/stories/utils/args.ts +0 -151
  239. package/src/stories/utils.ts +0 -39
  240. package/src/styles.ts +0 -124
  241. package/src/types/global.ts +0 -211
  242. package/src/types/icons.ts +0 -2272
  243. package/tsconfig.prod.json +0 -26
@@ -1,277 +0,0 @@
1
- import { rgba } from 'polished';
2
- import React, { forwardRef, useCallback, useEffect, useState } from 'react';
3
- import styled, { css } from 'styled-components';
4
- import { ReqoreDropdown } from '../..';
5
- import {
6
- CONTROL_TEXT_FROM_SIZE,
7
- PADDING_FROM_SIZE,
8
- RADIUS_FROM_SIZE,
9
- SIZE_TO_PX,
10
- TSizes,
11
- } from '../../constants/sizes';
12
- import { IReqoreTheme } from '../../constants/theme';
13
- import { changeLightness, getReadableColor } from '../../helpers/colors';
14
- import { IReqoreAutoFocusRules, useAutoFocus } from '../../hooks/useAutoFocus';
15
- import { useCombinedRefs } from '../../hooks/useCombinedRefs';
16
- import useAutosizeTextArea from '../../hooks/useTextareaAutoSize';
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 { IReqoreDropdownProps } from '../Dropdown';
29
- import { StyledEffect } from '../Effect';
30
- import { IReqoreInputStyle } from '../Input';
31
- import ReqoreInputClearButton from '../InputClearButton';
32
-
33
- export interface IReqoreFormTemplates extends IReqoreDropdownProps {}
34
-
35
- export interface IReqoreTextareaProps
36
- extends React.HTMLAttributes<HTMLTextAreaElement>,
37
- IReqoreReadOnly,
38
- IReqoreDisabled,
39
- IWithReqoreCustomTheme,
40
- IWithReqoreTooltip,
41
- IReqoreIntent,
42
- IWithReqoreEffect {
43
- autoFocus?: boolean;
44
- placeholder?: string;
45
- width?: number;
46
- height?: number;
47
- scaleWithContent?: boolean;
48
- size?: TSizes;
49
- minimal?: boolean;
50
- fluid?: boolean;
51
- value?: string;
52
- rows?: number;
53
- cols?: number;
54
- rounded?: boolean;
55
- flat?: boolean;
56
- fixed?: boolean;
57
- onClearClick?: () => any;
58
- wrapperStyle?: React.CSSProperties;
59
- focusRules?: IReqoreAutoFocusRules;
60
- templates?: IReqoreFormTemplates;
61
- }
62
-
63
- export interface IReqoreTextareaStyle extends IReqoreTextareaProps {
64
- theme: IReqoreTheme;
65
- hasClearButton?: boolean;
66
- _size?: TSizes;
67
- }
68
-
69
- export const StyledTextareaWrapper = styled.div<IReqoreTextareaStyle>`
70
- height: ${({ height }) => (height ? `${height}px` : undefined)};
71
- min-height: ${({ _size }) => SIZE_TO_PX[_size]}px;
72
- max-height: 100%;
73
- width: ${({ width, fluid }) => (fluid ? '100%' : width ? `${width}px` : 'auto')};
74
- flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? '1 auto' : '0 0 auto')};
75
- align-self: ${({ fixed, fluid }) => (fixed ? 'flex-start' : fluid ? 'stretch' : undefined)};
76
- position: relative;
77
- overflow: hidden;
78
-
79
- &:focus-within {
80
- .reqore-clear-input-button {
81
- display: flex;
82
- }
83
- }
84
- `;
85
-
86
- export const StyledTextarea = styled(StyledEffect)<IReqoreTextareaStyle>`
87
- width: 100%;
88
- max-width: 100%;
89
- max-height: 100%;
90
- font-size: ${({ _size }) => CONTROL_TEXT_FROM_SIZE[_size]}px;
91
- margin: 0;
92
- padding: ${({ _size }) => PADDING_FROM_SIZE[_size] / 2}px;
93
- padding-right: ${({ hasClearButton, _size }) =>
94
- hasClearButton ? `${SIZE_TO_PX[_size]}px` : undefined};
95
- min-height: ${({ _size }) => SIZE_TO_PX[_size]}px;
96
- line-height: ${({ _size }) => SIZE_TO_PX[_size] - CONTROL_TEXT_FROM_SIZE[_size]}px;
97
- vertical-align: middle;
98
-
99
- background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
100
- minimal ? 'transparent' : rgba(theme.main, 0.1)};
101
- color: ${({ theme }: IReqoreInputStyle) =>
102
- getReadableColor(theme, undefined, undefined, true, theme.originalMain)};
103
-
104
- &:active,
105
- &:focus {
106
- background-color: ${({ theme, minimal }: IReqoreInputStyle) =>
107
- minimal ? 'transparent' : rgba(theme.main, 0.15)};
108
- }
109
-
110
- border-radius: ${({ minimal, rounded, _size }) =>
111
- minimal || !rounded ? 0 : RADIUS_FROM_SIZE[_size]}px;
112
- border: ${({ minimal, theme, flat }) =>
113
- !minimal && !flat ? `1px solid ${changeLightness(theme.main, 0.2)}` : 0};
114
- border-bottom: ${({ minimal, theme, flat }) =>
115
- minimal && !flat ? `0.5px solid ${changeLightness(theme.main, 0.2)}` : undefined};
116
-
117
- ${({ disabled, readOnly }) =>
118
- !disabled && !readOnly
119
- ? css`
120
- &:active,
121
- &:focus,
122
- &:hover {
123
- outline: none;
124
- border-color: ${({ theme }) => changeLightness(theme.main, 0.35)};
125
- }
126
- `
127
- : undefined}
128
-
129
- &::placeholder {
130
- color: ${({ theme }) =>
131
- rgba(getReadableColor(theme, undefined, undefined, true, theme.originalMain), 0.3)};
132
- }
133
-
134
- &:focus {
135
- &::placeholder {
136
- color: ${({ theme }) =>
137
- rgba(getReadableColor(theme, undefined, undefined, true, theme.originalMain), 0.5)};
138
- }
139
- }
140
-
141
- ${({ readOnly }) => readOnly && ReadOnlyElement};
142
-
143
- &:disabled {
144
- ${DisabledElement};
145
- }
146
- `;
147
-
148
- const ReqoreInput = forwardRef<HTMLTextAreaElement, IReqoreTextareaProps>(
149
- (
150
- {
151
- width,
152
- height,
153
- scaleWithContent,
154
- size = 'normal',
155
- className,
156
- onClearClick,
157
- fluid,
158
- tooltip,
159
- customTheme,
160
- intent,
161
- rounded = true,
162
- wrapperStyle,
163
- value,
164
- onChange,
165
- fixed,
166
- focusRules,
167
- templates,
168
- ...rest
169
- }: IReqoreTextareaProps,
170
- ref
171
- ) => {
172
- const { targetRef }: any = useCombinedRefs(ref);
173
- const [inputRef, setInputRef] = useState<HTMLTextAreaElement>(null);
174
- const theme = useReqoreTheme('main', customTheme, intent);
175
- const [_value, setValue] = useState(value || '');
176
-
177
- useEffect(() => {
178
- setValue(value || '');
179
- }, [value]);
180
-
181
- useTooltip(inputRef, tooltip);
182
- useAutosizeTextArea(inputRef, _value, scaleWithContent);
183
- useAutoFocus(inputRef, rest.readOnly || rest.disabled ? undefined : focusRules, onChange);
184
-
185
- const handleItemSelect = useCallback(
186
- (item) => {
187
- if (!inputRef || !item || !item.value) {
188
- return;
189
- }
190
- // Add the value of the selected item to the current value at the cursor position
191
- const value = `${_value.slice(0, inputRef.selectionStart)}${item.value}${_value.slice(
192
- inputRef.selectionEnd
193
- )}`;
194
-
195
- setValue(value);
196
- // Trigger the onChange event
197
- onChange?.({ target: { value } } as any);
198
- },
199
- [inputRef, _value]
200
- );
201
-
202
- const renderChildren = () => {
203
- return (
204
- <>
205
- <StyledTextarea
206
- {...rest}
207
- effect={{
208
- interactive: !rest?.disabled && !rest.readOnly,
209
- ...rest?.effect,
210
- }}
211
- onChange={(e) => {
212
- setValue(e.target.value);
213
- onChange?.(e);
214
- }}
215
- as='textarea'
216
- className={`${className || ''} reqore-control reqore-textarea`}
217
- _size={size}
218
- ref={(ref) => setInputRef(ref)}
219
- theme={theme}
220
- rounded={rounded}
221
- rows={1}
222
- value={_value}
223
- readonly={rest?.readOnly}
224
- tabIndex={rest?.disabled ? -1 : 0}
225
- hasClearButton={!rest?.readOnly && !rest?.disabled && !!(onClearClick && onChange)}
226
- />
227
- <ReqoreInputClearButton
228
- enabled={!rest?.readOnly && !rest?.disabled && !!(onClearClick && onChange)}
229
- show={_value && _value !== ''}
230
- onClick={onClearClick}
231
- size={size}
232
- />
233
- </>
234
- );
235
- };
236
-
237
- if (templates) {
238
- return (
239
- <ReqoreDropdown<Omit<IReqoreTextareaStyle & { ref: any }, 'content'>>
240
- component={StyledTextareaWrapper}
241
- className={`${className || ''} reqore-control-wrapper`}
242
- width={width}
243
- filterable
244
- height={height}
245
- fluid={fluid}
246
- fixed={fixed}
247
- _size={size}
248
- theme={theme}
249
- style={wrapperStyle}
250
- ref={targetRef}
251
- onItemSelect={handleItemSelect}
252
- {...templates}
253
- >
254
- {renderChildren()}
255
- </ReqoreDropdown>
256
- );
257
- }
258
-
259
- return (
260
- <StyledTextareaWrapper
261
- className={`${className || ''} reqore-control-wrapper`}
262
- width={width}
263
- height={height}
264
- fluid={fluid}
265
- fixed={fixed}
266
- _size={size}
267
- theme={theme}
268
- style={wrapperStyle}
269
- ref={targetRef}
270
- >
271
- {renderChildren()}
272
- </StyledTextareaWrapper>
273
- );
274
- }
275
- );
276
-
277
- export default ReqoreInput;
@@ -1,15 +0,0 @@
1
- import timeago from 'epoch-timeago';
2
- import { useState } from 'react';
3
- import { useInterval } from 'react-use';
4
- import { getTimeAgoIntervalDelay } from '../../helpers/time';
5
-
6
- export const TimeAgo = ({ time }: { time: number | string }) => {
7
- const setUpdate = useState<number>(Date.now());
8
- const _time = typeof time === 'number' ? time : Date.parse(time);
9
-
10
- useInterval(() => {
11
- setUpdate[1](Date.now());
12
- }, getTimeAgoIntervalDelay(_time));
13
-
14
- return timeago(_time);
15
- };
@@ -1,271 +0,0 @@
1
- import { cloneDeep, size as lodashSize } from 'lodash';
2
- import { useMemo, useState } from 'react';
3
- import styled from 'styled-components';
4
- import { ReqoreHorizontalSpacer, ReqoreIcon, ReqoreP, ReqorePanel, useReqoreProperty } from '../..';
5
- import { GAP_FROM_SIZE, TSizes } from '../../constants/sizes';
6
- import { IReqoreTheme } from '../../constants/theme';
7
- import { getOneLessSize, getTypeFromValue } from '../../helpers/utils';
8
- import { IWithReqoreSize } from '../../types/global';
9
- import ReqoreButton, { IReqoreButtonProps } from '../Button';
10
- import ReqoreControlGroup from '../ControlGroup';
11
- import { ReqoreExportModal } from '../ExportModal';
12
- import { IReqorePanelAction, IReqorePanelProps } from '../Panel';
13
- import { getExportActions, getZoomActions, sizeToZoom, zoomToSize } from '../Table/helpers';
14
-
15
- export interface IReqoreTreeProps extends IReqorePanelProps, IWithReqoreSize {
16
- data: Record<string, unknown> | Array<any>;
17
- mode?: 'tree' | 'copy';
18
- expanded?: boolean;
19
- showTypes?: boolean;
20
- onItemClick?: (value: any, path?: string[]) => void;
21
- withLabelCopy?: boolean;
22
- showControls?: boolean;
23
- zoomable?: boolean;
24
- exportable?: boolean;
25
- defaultZoom?: 0 | 0.5 | 1 | 1.5 | 2;
26
- }
27
-
28
- export interface ITreeStyle {
29
- interactive?: boolean;
30
- theme: IReqoreTheme;
31
- level?: number;
32
- size?: TSizes;
33
- }
34
-
35
- export const StyledTreeLabel = styled(ReqoreP)`
36
- flex-shrink: 1;
37
-
38
- cursor: ${({ onClick }) => (onClick ? 'pointer' : 'default')};
39
- `;
40
-
41
- export const StyledTreeWrapper = styled.div<ITreeStyle>`
42
- display: flex;
43
- flex-flow: column;
44
- gap: ${({ size }) => GAP_FROM_SIZE[size]}px;
45
- margin-left: ${({ level, size }) => (level ? level * GAP_FROM_SIZE[size] : 0)}px;
46
- `;
47
-
48
- export const ReqoreTree = ({
49
- data,
50
- size = 'normal',
51
- expanded,
52
- showTypes,
53
- onItemClick,
54
- withLabelCopy,
55
- showControls = true,
56
-
57
- exportable,
58
- zoomable,
59
- defaultZoom,
60
- ...rest
61
- }: IReqoreTreeProps) => {
62
- const [items, setItems] = useState({});
63
- const [allExpanded, setAllExpanded] = useState(expanded || !showControls);
64
- const [_showTypes, setShowTypes] = useState(showTypes);
65
- const addNotification = useReqoreProperty('addNotification');
66
- const [zoom, setZoom] = useState(defaultZoom || sizeToZoom[size]);
67
- const [showExportModal, setShowExportModal] = useState<'full' | 'current' | undefined>(undefined);
68
-
69
- const handleTypesClick = () => {
70
- setShowTypes(!_showTypes);
71
- };
72
-
73
- const handleExpandClick = () => {
74
- setItems({});
75
- setAllExpanded(true);
76
- };
77
-
78
- const handleCollapseClick = () => {
79
- setItems({});
80
- setAllExpanded(false);
81
- };
82
-
83
- const handleItemClick = (key: string, currentState?: boolean) => {
84
- const newItems = cloneDeep(items);
85
-
86
- newItems[key] = !currentState;
87
-
88
- setItems(newItems);
89
- };
90
-
91
- const isDeep = () =>
92
- Object.keys(data).some((key: string): boolean => typeof data[key] === 'object');
93
-
94
- const renderTree = (data, k?: any, level = 1, path: string[] = []) => {
95
- return Object.keys(data).map((key, index) => {
96
- const dataType: string = getTypeFromValue(data[key]);
97
- const displayKey: string = key;
98
- const stateKey = k ? `${k}_${key}` : key;
99
-
100
- let isObject = typeof data[key] === 'object' && data[key] !== null;
101
- let isExpandable =
102
- typeof data[key] !== 'object' ||
103
- items[stateKey] ||
104
- (allExpanded && items[stateKey] !== false);
105
-
106
- if (isObject && lodashSize(data[key]) === 0) {
107
- isObject = false;
108
- isExpandable = false;
109
- }
110
-
111
- const badges: IReqoreButtonProps['badge'] = [`{...} ${lodashSize(data[key])} items`];
112
-
113
- if (_showTypes) {
114
- badges.push({
115
- icon: 'CodeBoxFill',
116
- label: dataType,
117
- });
118
- }
119
-
120
- return (
121
- <StyledTreeWrapper key={index} size={zoomToSize[zoom]} level={level}>
122
- {isObject ? (
123
- <ReqoreControlGroup size={zoomToSize[zoom]}>
124
- {level !== 1 && <ReqoreHorizontalSpacer width={5} />}
125
- <ReqoreButton
126
- compact
127
- minimal
128
- className='reqore-tree-toggle'
129
- icon={isExpandable ? 'ArrowDownSFill' : 'ArrowRightSFill'}
130
- intent={isExpandable ? 'info' : undefined}
131
- onClick={() => handleItemClick(stateKey, isExpandable)}
132
- flat={false}
133
- badge={badges}
134
- >
135
- {displayKey}
136
- </ReqoreButton>
137
- </ReqoreControlGroup>
138
- ) : (
139
- <ReqoreControlGroup verticalAlign='flex-start'>
140
- {level !== 1 && <ReqoreHorizontalSpacer width={5} />}
141
- <ReqoreP
142
- customTheme={{ text: { color: 'info:lighten:3' } }}
143
- style={{ flexShrink: 0 }}
144
- size={zoomToSize[zoom]}
145
- >
146
- {displayKey}:
147
- </ReqoreP>
148
- {withLabelCopy && (
149
- <ReqoreIcon
150
- interactive
151
- icon='ClipboardLine'
152
- size={getOneLessSize(zoomToSize[zoom])}
153
- onClick={() => {
154
- try {
155
- navigator.clipboard.writeText(JSON.stringify(data[key]));
156
- addNotification({
157
- content: 'Successfuly copied to clipboard',
158
- id: Date.now().toString(),
159
- type: 'success',
160
- duration: 3000,
161
- });
162
- } catch (e) {
163
- console.error(e);
164
- }
165
- }}
166
- />
167
- )}
168
- <StyledTreeLabel
169
- flat
170
- onClick={() => onItemClick?.(data[key], [...path, key])}
171
- className='reqore-tree-label'
172
- size={zoomToSize[zoom]}
173
- >
174
- {JSON.stringify(data[key])}
175
- </StyledTreeLabel>
176
- </ReqoreControlGroup>
177
- )}
178
- {isExpandable && isObject
179
- ? renderTree(data[key], stateKey, level + 1, [...path, key])
180
- : null}
181
- </StyledTreeWrapper>
182
- );
183
- });
184
- };
185
-
186
- const actions = useMemo(() => {
187
- let _actions: IReqorePanelAction[] = [];
188
-
189
- if (showControls) {
190
- _actions = [
191
- {
192
- className: 'reqore-tree-expand-all',
193
- icon: 'ArrowDownFill',
194
- onClick: handleExpandClick,
195
- show: !!(isDeep() && !allExpanded),
196
- label: 'Expand all',
197
- },
198
- {
199
- show: !!(isDeep() && (allExpanded || lodashSize(items) > 0)),
200
- className: 'reqore-tree-collapse-all',
201
- icon: 'ArrowUpFill',
202
- onClick: handleCollapseClick,
203
-
204
- label: 'Collapse all',
205
- },
206
- {
207
- className: 'reqore-tree-show-types',
208
- icon: 'CodeBoxFill',
209
- active: _showTypes,
210
- onClick: handleTypesClick,
211
- label: 'Show types',
212
- },
213
- ];
214
- }
215
-
216
- if (zoomable || exportable) {
217
- const moreActions: IReqorePanelAction = {
218
- className: 'reqore-tree-more',
219
- icon: 'MoreLine',
220
- actions: [],
221
- };
222
-
223
- if (zoomable) {
224
- moreActions.actions = [
225
- ...moreActions.actions,
226
- ...getZoomActions('reqore-tree', zoom, setZoom, true),
227
- ];
228
- }
229
-
230
- if (exportable) {
231
- moreActions.actions = [
232
- ...moreActions.actions,
233
- { divider: true, line: true },
234
- ...getExportActions((type) => setShowExportModal(type)),
235
- ];
236
- }
237
-
238
- _actions = [..._actions, moreActions];
239
- }
240
-
241
- return _actions;
242
- }, [allExpanded, items, showControls, _showTypes, isDeep(), zoom]);
243
-
244
- if (!data || !Object.keys(data).length) {
245
- return <p>No data</p>;
246
- }
247
-
248
- return (
249
- <>
250
- {showExportModal && (
251
- <ReqoreExportModal data={data} onClose={() => setShowExportModal(undefined)} />
252
- )}
253
- <ReqorePanel
254
- className='reqore-tree'
255
- minimal
256
- flat
257
- transparent
258
- size={size}
259
- contentStyle={{
260
- display: 'flex',
261
- flexFlow: 'column',
262
- gap: `${GAP_FROM_SIZE[size]}px`,
263
- }}
264
- {...rest}
265
- actions={actions}
266
- >
267
- {renderTree(data, true)}
268
- </ReqorePanel>
269
- </>
270
- );
271
- };
@@ -1,9 +0,0 @@
1
- export const SPRING_CONFIG = {
2
- tension: 180,
3
- friction: 20,
4
- };
5
-
6
- export const SPRING_CONFIG_NO_ANIMATIONS = {
7
- tension: 0,
8
- friction: 0,
9
- };
@@ -1,13 +0,0 @@
1
- import { TReqoreHexColor } from '../components/Effect';
2
-
3
- export const Colors: Record<string, TReqoreHexColor> = {
4
- DARK: '#000000',
5
- DARK_THEME: '#333333',
6
- LIGHT: '#ffffff',
7
- BLUE: '#0776CB',
8
- GREEN: '#0A6640',
9
- YELLOW: '#d1a036',
10
- ORANGE: '#A66321',
11
- RED: '#A82A2A',
12
- GRAY: '#44444450',
13
- };
@@ -1,93 +0,0 @@
1
- import { IReqorePaginationComponentProps, IReqorePaginationProps } from '../components/Paging';
2
- import { IReqorePagingOptions } from '../hooks/usePaging';
3
-
4
- export type TReqorePaginationType<T> =
5
- | 'buttons'
6
- | 'list'
7
- | 'infinite'
8
- | 'auto-load'
9
- | IReqoreComponentPagingOptions<T>;
10
-
11
- export interface IReqoreComponentPagingOptions<T>
12
- extends Omit<IReqorePagingOptions<T>, 'items'>,
13
- IReqorePaginationComponentProps {
14
- pageControlsPosition?: 'top' | 'bottom' | 'both';
15
- includeTopControls?: boolean;
16
- includeBottomControls?: boolean;
17
- }
18
-
19
- export type TReqorePaginationTypeResult<T> = {
20
- pagingOptions?: Omit<IReqorePagingOptions<T>, 'items'>;
21
- componentOptions?: Partial<Omit<IReqorePaginationProps<T>, 'items'>>;
22
- pageControlsPosition?: 'top' | 'bottom' | 'both';
23
- includeTopControls?: boolean;
24
- includeBottomControls?: boolean;
25
- };
26
-
27
- export function getPagingObjectFromType<T>(
28
- type: TReqorePaginationType<T>
29
- ): IReqoreComponentPagingOptions<T> {
30
- if (typeof type === 'object') {
31
- return type;
32
- }
33
-
34
- switch (type) {
35
- case 'buttons':
36
- return {};
37
- case 'list':
38
- return {
39
- showPagesAs: 'list',
40
- };
41
- case 'infinite':
42
- case 'auto-load':
43
- return { infinite: true };
44
- default:
45
- return {};
46
- }
47
- }
48
-
49
- export function getPaginationOptionsFromType<T>(
50
- type: TReqorePaginationType<T>
51
- ): TReqorePaginationTypeResult<T> {
52
- if (!type) return {};
53
-
54
- if (typeof type === 'object') {
55
- const {
56
- infinite,
57
- itemsPerPage,
58
- pagesToShow,
59
- startPage,
60
- enabled,
61
- onPageChange,
62
- pageControlsPosition = 'bottom',
63
- includeBottomControls,
64
- includeTopControls,
65
-
66
- ...componentOptions
67
- } = type;
68
-
69
- return {
70
- pagingOptions: { infinite, itemsPerPage, pagesToShow, startPage, enabled, onPageChange },
71
- pageControlsPosition,
72
- componentOptions,
73
- includeBottomControls,
74
- includeTopControls,
75
- };
76
- }
77
-
78
- switch (type) {
79
- case 'buttons':
80
- return {};
81
- case 'list':
82
- return {
83
- componentOptions: {
84
- showPagesAs: 'list',
85
- },
86
- };
87
- case 'infinite':
88
- case 'auto-load':
89
- return { pagingOptions: { infinite: true } };
90
- default:
91
- return {};
92
- }
93
- }