@qoretechnologies/reqore 0.41.1 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ControlGroup/index.d.ts +1 -0
- package/dist/components/ControlGroup/index.d.ts.map +1 -1
- package/dist/components/ControlGroup/index.js +18 -4
- package/dist/components/ControlGroup/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +1 -0
- package/dist/components/Input/index.d.ts.map +1 -1
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Label/index.d.ts +6 -0
- package/dist/components/Label/index.d.ts.map +1 -0
- package/dist/components/Label/index.js +24 -0
- package/dist/components/Label/index.js.map +1 -0
- package/dist/components/Slider/index.d.ts +40 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/Slider/index.js +148 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/Tag/index.d.ts +4 -2
- package/dist/components/Tag/index.d.ts.map +1 -1
- package/dist/components/Tag/index.js +1 -1
- package/dist/components/Tag/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/ControlGroup/index.tsx +19 -3
- package/src/components/Input/index.tsx +1 -0
- package/src/components/Label/index.tsx +10 -0
- package/src/components/Slider/index.tsx +358 -0
- package/src/components/Tag/index.tsx +19 -18
- package/src/index.tsx +2 -0
- package/src/stories/Label/Label.stories.tsx +33 -0
- package/src/stories/Slider/Slider.stories.tsx +173 -0
- package/tests.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,6 +10,9 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
13
16
|
exports.__esModule = true;
|
|
14
17
|
exports.ReqoreHorizontalSpacer = exports.ReqoreRadioGroup = exports.ReqorePopover = exports.ReqoreParagraph = exports.ReqoreP = exports.ReqorePanel = exports.ReqorePagination = exports.ReqoreNotification = exports.ReqoreNotificationsWrapper = exports.ReqoreNavbarItem = exports.ReqoreNavbarGroup = exports.ReqoreNavbarDivider = exports.ReqoreHeader = exports.ReqoreFooter = exports.ReqoreMultiSelect = exports.ReqoreModal = exports.ReqoreMessage = exports.ReqoreMenuSection = exports.ReqoreMenuItem = exports.ReqoreMenuDivider = exports.ReqoreMenu = exports.ReqoreLayoutContent = exports.ReqoreKeyValueTable = exports.ReqoreInput = exports.ReqoreIcon = exports.ReqoreHeading = exports.ReqoreH6 = exports.ReqoreH5 = exports.ReqoreH4 = exports.ReqoreH3 = exports.ReqoreH2 = exports.ReqoreH1 = exports.ReqoreTextEffect = exports.ReqoreEffect = exports.ReqoreDropdownItem = exports.ReqoreDropdownDivider = exports.ReqoreDropdown = exports.ReqoreBackdrop = exports.ReqoreDrawer = exports.ReqoreControlGroup = exports.ReqoreContent = exports.ReqoreCommentFeed = exports.ReqoreComment = exports.ReqoreColumn = exports.ReqoreColumns = exports.ReqoreCollection = exports.ReqoreCheckbox = exports.ReqoreButton = exports.ReqoreBreadcrumbsItem = exports.ReqoreBreadcrumbs = void 0;
|
|
15
18
|
exports.useReqoreTheme = exports.useReqoreProperty = exports.useReqore = exports.useReqorePaging = exports.useLatestZIndex = exports.useCloneThroughFragments = exports.ReqoreThemeContext = exports.ReqoreContext = exports.ReqoreUIProvider = exports.ReqoreNotifications = exports.ReqorePaginationContainer = exports.ReqoreIntents = exports.ReqoreSizes = exports.ReqoreColors = exports.ReqoreTree = exports.ReqoreTimeAgo = exports.ReqoreTextarea = exports.ReqoreTagGroup = exports.ReqoreTag = exports.ReqoreTabsList = exports.ReqoreTabsListItem = exports.ReqoreTabsContent = exports.ReqoreTabs = exports.ReqoreTableValue = exports.ReqoreTableRow = exports.ReqoreTableHeaderCell = exports.ReqoreTableBodyCell = exports.ReqoreTable = exports.ReqoreSpinner = exports.ReqoreVerticalSpacer = exports.ReqoreSpacer = void 0;
|
|
@@ -61,6 +64,7 @@ var Input_1 = require("./components/Input");
|
|
|
61
64
|
__createBinding(exports, Input_1, "default", "ReqoreInput");
|
|
62
65
|
var KeyValueTable_1 = require("./components/KeyValueTable");
|
|
63
66
|
__createBinding(exports, KeyValueTable_1, "ReqoreKeyValueTable");
|
|
67
|
+
__exportStar(require("./components/Label"), exports);
|
|
64
68
|
var content_1 = require("./components/Layout/content");
|
|
65
69
|
__createBinding(exports, content_1, "default", "ReqoreLayoutContent");
|
|
66
70
|
var Menu_1 = require("./components/Menu");
|
|
@@ -101,6 +105,7 @@ var Popover_1 = require("./components/Popover");
|
|
|
101
105
|
__createBinding(exports, Popover_1, "default", "ReqorePopover");
|
|
102
106
|
var RadioGroup_1 = require("./components/RadioGroup");
|
|
103
107
|
__createBinding(exports, RadioGroup_1, "default", "ReqoreRadioGroup");
|
|
108
|
+
__exportStar(require("./components/Slider"), exports);
|
|
104
109
|
var Spacer_1 = require("./components/Spacer");
|
|
105
110
|
__createBinding(exports, Spacer_1, "ReqoreHorizontalSpacer");
|
|
106
111
|
__createBinding(exports, Spacer_1, "ReqoreSpacer");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,wDAAwE;AAA/D,wEAA4B;AACrC,sDAAiF;AAAxE,qEAAgC;AACzC,8CAA8D;AAArD,8DAAuB;AAChC,kDAAkE;AAAzD,kEAAyB;AAClC,sDAA2D;AAAlD,2DAAgB;AACzB,gDAAqD;AAA5C,qDAAa;AACtB,sDAA2D;AAAlD,mDAAY;AACrB,gDAAqD;AAA5C,qDAAa;AACtB,wDAA6D;AAApD,6DAAiB;AAC1B,gDAAgE;AAAvD,gEAAwB;AACjC,0DAA0E;AAAjE,0EAA6B;AACtC,8CAAmD;AAA1C,mDAAY;AACrB,yDAA8D;AAArD,uDAAc;AACvB,kDAAkE;AAAzD,kEAAyB;AAClC,mDAAuF;AAA9E,0DAAqB;AAAE,uDAAkB;AAClD,8CAAqE;AAA5D,mDAAY;AAAE,uDAAgB;AACvC,8CAQ6B;AAP3B,+CAAQ;AACR,+CAAQ;AACR,+CAAQ;AACR,+CAAQ;AACR,+CAAQ;AACR,+CAAQ;AACR,oDAAa;AAEf,0CAA0D;AAAjD,0DAAqB;AAC9B,4CAA4D;AAAnD,4DAAsB;AAC/B,4DAAiE;AAAxD,iEAAmB;AAC5B,qDAAmC;AACnC,uDAA6E;AAApE,sEAA8B;AACvC,0CAA0D;AAAjD,0DAAqB;AAC9B,qDAAyE;AAAhE,oEAA4B;AACrC,+CAAmE;AAA1D,8DAAyB;AAClC,qDAA8D;AAArD,yDAAiB;AAC1B,gDAAgE;AAAvD,gEAAwB;AACjC,4CAAiD;AAAxC,iDAAW;AACpB,wDAA6D;AAApD,6DAAiB;AAC1B,8CAAiE;AAAxD,mDAAY;AAAE,mDAAY;AACnC,uDAA6E;AAApE,sEAA8B;AACvC,mDAAyE;AAAhE,kEAA4B;AACrC,iDAAuE;AAA9D,gEAA2B;AACpC,4DAAmF;AAA1E,mFAAqC;AAC9C,wEAAwF;AAA/E,0EAA6B;AACtC,8CAAuD;AAA9C,uDAAgB;AACzB,4CAAiD;AAAxC,iDAAW;AACpB,oDAA6E;AAApE,iDAAO;AAAE,oEAA0B;AAC5C,gDAAgE;AAAvD,gEAAwB;AACjC,sDAAsE;AAA7D,sEAA2B;AACpC,sDAAoC;AACpC,8CAAiG;AAAxF,6DAAsB;AAAE,mDAAY;AAAE,2DAAoB;AACnE,gDAAqD;AAA5C,qDAAa;AACtB,4CAA4D;AAAnD,4DAAsB;AAC/B,gDAA8D;AAArD,wDAAmB;AAC5B,4DAAsE;AAA7D,gEAAqB;AAC9B,8CAAmE;AAA1D,6DAAyB;AAClC,kDAA4D;AAAnD,sDAAgB;AACzB,0CAA0D;AAAjD,0DAAqB;AAC9B,qDAAyE;AAAhE,oEAA4B;AACrC,+CAAuE;AAA9D,kEAA6B;AACtC,+CAAmE;AAA1D,8DAAyB;AAClC,wCAAwD;AAA/C,wDAAoB;AAC7B,gDAAmE;AAA1D,+DAAyB;AAClC,kDAAkE;AAAzD,kEAAyB;AAClC,gDAAgE;AAAvD,gEAAwB;AACjC,0CAA+C;AAAtC,+CAAU;AACnB,6CAA4D;AAAnD,6DAAsB;AAC/B,2CAAgD;AAAvC,iDAAW;AACpB,2CAAkD;AAAzC,mDAAa;AACtB,8CAAgE;AAAvD,gEAAyB;AAClC,8DAA6E;AAApE,6EAA8B;AACvC,sDAAsE;AAA7D,sEAA2B;AACpC,yDAAmE;AAA1D,sEAAwB;AACjC,uDAAuE;AAA9D,0EAA6B;AACtC,6EAA4E;AAAnE,iFAAwB;AACjC,2DAAqE;AAA5D,0EAA0B;AACnC,+CAAoD;AAA3C,yDAAe;AACxB,+CAA8C;AAArC,mDAAS;AAClB,6DAA6D;AAApD,kEAAiB;AAC1B,6CAAkD;AAAzC,uDAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qoretechnologies/reqore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.0",
|
|
4
4
|
"description": "ReQore is a highly theme-able and modular UI library for React",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"react"
|
|
29
29
|
],
|
|
30
30
|
"pre-push": [
|
|
31
|
-
"source",
|
|
32
31
|
"build:test:prod",
|
|
33
32
|
"lint",
|
|
34
33
|
"test"
|
|
@@ -96,6 +95,7 @@
|
|
|
96
95
|
},
|
|
97
96
|
"dependencies": {
|
|
98
97
|
"@popperjs/core": "^2.11.6",
|
|
98
|
+
"@radix-ui/react-slider": "^1.1.2",
|
|
99
99
|
"@react-spring/web": "^9.6.1",
|
|
100
100
|
"classnames": "^2.2.6",
|
|
101
101
|
"epoch-timeago": "^1.1.9",
|
|
@@ -36,6 +36,7 @@ export interface IReqoreControlGroupComponentProps
|
|
|
36
36
|
vertical?: boolean;
|
|
37
37
|
verticalAlign?: 'flex-start' | 'center' | 'flex-end';
|
|
38
38
|
horizontalAlign?: 'flex-start' | 'center' | 'flex-end';
|
|
39
|
+
spaceBetween?: boolean;
|
|
39
40
|
wrap?: boolean;
|
|
40
41
|
isInsideStackGroup?: boolean;
|
|
41
42
|
isInsideVerticalGroup?: boolean;
|
|
@@ -67,9 +68,24 @@ export const StyledReqoreControlGroup = styled(StyledEffect)<IReqoreControlGroup
|
|
|
67
68
|
display: flex;
|
|
68
69
|
flex: ${({ fluid, fixed }) => (fixed ? '0 0 auto' : fluid ? undefined : '0 0 auto')};
|
|
69
70
|
width: ${({ fluid, fixed }) => (fluid && !fixed ? '100%' : undefined)};
|
|
70
|
-
justify-content: ${({ fluid, vertical }) =>
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
justify-content: ${({ fluid, vertical, spaceBetween }) =>
|
|
72
|
+
vertical && fluid
|
|
73
|
+
? spaceBetween
|
|
74
|
+
? 'space-between'
|
|
75
|
+
: 'stretch'
|
|
76
|
+
: !vertical && spaceBetween
|
|
77
|
+
? 'space-between'
|
|
78
|
+
: undefined};
|
|
79
|
+
align-items: ${({ vertical, fluid, horizontalAlign, spaceBetween }) =>
|
|
80
|
+
vertical
|
|
81
|
+
? fluid
|
|
82
|
+
? spaceBetween
|
|
83
|
+
? 'space-between'
|
|
84
|
+
: 'stretch'
|
|
85
|
+
: horizontalAlign
|
|
86
|
+
: vertical && spaceBetween
|
|
87
|
+
? 'space-between'
|
|
88
|
+
: undefined};
|
|
73
89
|
flex-flow: ${({ vertical }) => (vertical ? 'column' : 'row')};
|
|
74
90
|
gap: ${({ gapSize, stack }) => (!stack ? `${GAP_FROM_SIZE[gapSize]}px` : undefined)};
|
|
75
91
|
flex-wrap: ${({ wrap }) => (wrap ? 'wrap' : 'nowrap')};
|
|
@@ -53,6 +53,7 @@ export interface IReqoreInputProps
|
|
|
53
53
|
flat?: boolean;
|
|
54
54
|
rounded?: boolean;
|
|
55
55
|
type?: 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';
|
|
56
|
+
step?: number;
|
|
56
57
|
wrapperStyle?: React.CSSProperties;
|
|
57
58
|
iconColor?: TReqoreEffectColor;
|
|
58
59
|
rightIconColor?: TReqoreEffectColor;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { forwardRef, Ref } from 'react';
|
|
2
|
+
import ReqoreTag, { IReqoreCustomTagProps } from '../Tag';
|
|
3
|
+
|
|
4
|
+
export interface IReqoreLabelProps
|
|
5
|
+
extends IReqoreCustomTagProps,
|
|
6
|
+
Omit<React.ComponentPropsWithoutRef<'label'>, 'color'> {}
|
|
7
|
+
|
|
8
|
+
export const ReqoreLabel = forwardRef((props: IReqoreLabelProps, ref: Ref<HTMLLabelElement>) => {
|
|
9
|
+
return <ReqoreTag as='label' color='transparent' {...props} ref={ref} />;
|
|
10
|
+
});
|
|
@@ -0,0 +1,358 @@
|
|
|
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;
|
|
@@ -51,9 +51,8 @@ export interface IReqoreTagAction
|
|
|
51
51
|
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export interface
|
|
55
|
-
extends
|
|
56
|
-
IWithReqoreTooltip,
|
|
54
|
+
export interface IReqoreCustomTagProps
|
|
55
|
+
extends IWithReqoreTooltip,
|
|
57
56
|
IReqoreDisabled,
|
|
58
57
|
IWithReqoreMinimal,
|
|
59
58
|
IWithReqoreFluid,
|
|
@@ -65,7 +64,6 @@ export interface IReqoreTagProps
|
|
|
65
64
|
label?: string | number;
|
|
66
65
|
labelKey?: string | number;
|
|
67
66
|
onRemoveClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
68
|
-
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
69
67
|
icon?: IReqoreIconName;
|
|
70
68
|
leftIconProps?: IReqoreIconProps;
|
|
71
69
|
rightIcon?: IReqoreIconName;
|
|
@@ -81,7 +79,11 @@ export interface IReqoreTagProps
|
|
|
81
79
|
wrap?: boolean;
|
|
82
80
|
labelEffect?: IReqoreEffect;
|
|
83
81
|
labelKeyEffect?: IReqoreEffect;
|
|
82
|
+
as?: string | React.ElementType;
|
|
84
83
|
}
|
|
84
|
+
export interface IReqoreTagProps
|
|
85
|
+
extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children' | 'color'>,
|
|
86
|
+
IReqoreCustomTagProps {}
|
|
85
87
|
|
|
86
88
|
export interface IReqoreTagStyle extends IReqoreTagProps {
|
|
87
89
|
theme: IReqoreTheme;
|
|
@@ -247,22 +249,21 @@ const StyledButtonWrapper = styled.span<IReqoreTagStyle>`
|
|
|
247
249
|
align-items: center;
|
|
248
250
|
transition: all 0.2s ease-out;
|
|
249
251
|
|
|
250
|
-
${({ color, effect }) =>
|
|
251
|
-
|
|
252
|
+
${({ color, effect }) => css`
|
|
253
|
+
.reqore-icon {
|
|
254
|
+
transform: scale(0.85);
|
|
255
|
+
}
|
|
256
|
+
&:hover {
|
|
257
|
+
cursor: pointer;
|
|
258
|
+
background-color: ${color && !effect?.gradient
|
|
259
|
+
? changeLightness(color, 0.09)
|
|
260
|
+
: rgba('#000000', 0.2)};
|
|
261
|
+
|
|
252
262
|
.reqore-icon {
|
|
253
|
-
transform: scale(
|
|
254
|
-
}
|
|
255
|
-
&:hover {
|
|
256
|
-
cursor: pointer;
|
|
257
|
-
background-color: ${color && !effect?.gradient
|
|
258
|
-
? changeLightness(color, 0.09)
|
|
259
|
-
: rgba('#000000', 0.2)};
|
|
260
|
-
|
|
261
|
-
.reqore-icon {
|
|
262
|
-
transform: scale(1);
|
|
263
|
-
}
|
|
263
|
+
transform: scale(1);
|
|
264
264
|
}
|
|
265
|
-
|
|
265
|
+
}
|
|
266
|
+
`}
|
|
266
267
|
`;
|
|
267
268
|
|
|
268
269
|
const ReqoreTag = forwardRef<HTMLSpanElement, IReqoreTagProps>(
|
package/src/index.tsx
CHANGED
|
@@ -26,6 +26,7 @@ export {
|
|
|
26
26
|
export { default as ReqoreIcon } from './components/Icon';
|
|
27
27
|
export { default as ReqoreInput } from './components/Input';
|
|
28
28
|
export { ReqoreKeyValueTable } from './components/KeyValueTable';
|
|
29
|
+
export * from './components/Label';
|
|
29
30
|
export { default as ReqoreLayoutContent } from './components/Layout/content';
|
|
30
31
|
export { default as ReqoreMenu } from './components/Menu';
|
|
31
32
|
export { default as ReqoreMenuDivider } from './components/Menu/divider';
|
|
@@ -45,6 +46,7 @@ export { ReqorePanel } from './components/Panel';
|
|
|
45
46
|
export { ReqoreP, ReqoreP as ReqoreParagraph } from './components/Paragraph';
|
|
46
47
|
export { default as ReqorePopover } from './components/Popover';
|
|
47
48
|
export { default as ReqoreRadioGroup } from './components/RadioGroup';
|
|
49
|
+
export * from './components/Slider';
|
|
48
50
|
export { ReqoreHorizontalSpacer, ReqoreSpacer, ReqoreVerticalSpacer } from './components/Spacer';
|
|
49
51
|
export { ReqoreSpinner } from './components/Spinner';
|
|
50
52
|
export { default as ReqoreTable } from './components/Table';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react';
|
|
2
|
+
import ReqoreControlGroup from '../../components/ControlGroup';
|
|
3
|
+
import ReqoreInput from '../../components/Input';
|
|
4
|
+
import { ReqoreLabel } from '../../components/Label';
|
|
5
|
+
import { StoryMeta } from '../utils';
|
|
6
|
+
import { FlatArg, IconArg, MinimalArg, SizeArg } from '../utils/args';
|
|
7
|
+
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Form/Label/Stories',
|
|
10
|
+
component: ReqoreLabel,
|
|
11
|
+
argTypes: {
|
|
12
|
+
...MinimalArg,
|
|
13
|
+
...FlatArg,
|
|
14
|
+
...SizeArg,
|
|
15
|
+
...IconArg('icon', 'Icon'),
|
|
16
|
+
},
|
|
17
|
+
args: {
|
|
18
|
+
icon: 'SearchLine',
|
|
19
|
+
label: 'Search',
|
|
20
|
+
},
|
|
21
|
+
render(args) {
|
|
22
|
+
return (
|
|
23
|
+
<ReqoreControlGroup vertical>
|
|
24
|
+
<ReqoreLabel htmlFor='search' {...args} />
|
|
25
|
+
<ReqoreInput id='search' placeholder='Search' />
|
|
26
|
+
</ReqoreControlGroup>
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
} as StoryMeta<typeof ReqoreLabel>;
|
|
30
|
+
type Story = StoryObj<typeof meta>;
|
|
31
|
+
|
|
32
|
+
export default meta;
|
|
33
|
+
export const Default: Story = {};
|