@smart-react-components/ui 2.0.0-alpha-5 → 2.0.0-alpha-7
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/Badge/index.d.ts +2 -1
- package/Badge/index.js +2 -1
- package/Button/ButtonAddon/index.d.ts +14 -0
- package/Button/ButtonAddon/index.js +17 -0
- package/Button/ButtonLink/index.d.ts +7 -0
- package/Button/ButtonLink/index.js +26 -0
- package/Button/ButtonLoading/index.d.ts +7 -0
- package/Button/ButtonLoading/index.js +18 -0
- package/Button/index.d.ts +10 -0
- package/Button/index.js +89 -0
- package/Dropdown/DropdownCategory/index.d.ts +2 -1
- package/Dropdown/DropdownCategory/index.js +15 -1
- package/Dropdown/DropdownItem/DropdownItemElement.d.ts +1 -1
- package/Dropdown/DropdownItem/DropdownItemElement.js +5 -5
- package/Dropdown/DropdownItem/index.d.ts +10 -1
- package/Dropdown/DropdownItem/index.js +2 -2
- package/Dropdown/DropdownList/DropdownListElement.d.ts +1 -1
- package/Dropdown/DropdownList/DropdownListElement.js +7 -7
- package/Dropdown/DropdownList/index.d.ts +4 -4
- package/Dropdown/DropdownList/index.js +2 -2
- package/Input/InputAddon/index.js +1 -1
- package/Input/InputElement.d.ts +1 -1
- package/Input/InputElement.js +3 -0
- package/Input/InputFile/index.js +18 -14
- package/Input/InputNumber/index.js +18 -14
- package/Input/index.js +18 -14
- package/Select/Option/index.d.ts +22 -0
- package/Select/Option/index.js +30 -0
- package/Select/OptionGroup/index.d.ts +8 -0
- package/Select/OptionGroup/index.js +22 -0
- package/Select/SelectAddon/index.d.ts +2 -0
- package/Select/SelectAddon/index.js +7 -0
- package/Select/SelectBox/index.d.ts +7 -0
- package/Select/SelectBox/index.js +157 -0
- package/Select/SelectElement.d.ts +3 -0
- package/Select/SelectElement.js +20 -0
- package/Select/index.d.ts +5 -0
- package/Select/index.js +60 -0
- package/components/Button/ButtonAddon/index.d.ts +15 -0
- package/components/Button/ButtonAddon/index.js +110 -0
- package/components/Button/ButtonContent/index.d.ts +2 -0
- package/components/Button/ButtonContent/index.js +20 -0
- package/components/Button/ButtonLoading/index.d.ts +6 -0
- package/components/Button/ButtonLoading/index.js +45 -0
- package/components/Button/index.d.ts +21 -0
- package/components/Button/index.js +268 -0
- package/hooks/useAddons.d.ts +16 -0
- package/hooks/{useInputAddons.js → useAddons.js} +8 -22
- package/index.d.ts +8 -0
- package/index.js +17 -1
- package/package.json +7 -7
- package/types/button.d.ts +26 -0
- package/types/button.js +9 -0
- package/types/form.d.ts +22 -0
- package/types/form.js +2 -0
- package/util/fixed-box.js +1 -1
- package/util/form.d.ts +5 -0
- package/util/form.js +9 -1
- package/util/props.d.ts +16 -0
- package/util/props.js +6 -1
- package/util/wave-effect.d.ts +21 -0
- package/util/wave-effect.js +43 -0
- package/hooks/useInputAddons.d.ts +0 -18
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Button_1 = __importDefault(require("@smart-react-components/core/Element/Button"));
|
|
7
|
+
const Svg_1 = __importDefault(require("@smart-react-components/core/Element/Svg"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const css_1 = require("../../util/css");
|
|
10
|
+
const ButtonAddon_1 = __importDefault(require("./ButtonAddon"));
|
|
11
|
+
const ButtonContent_1 = __importDefault(require("./ButtonContent"));
|
|
12
|
+
exports.default = (0, styled_components_1.default)(Button_1.default).attrs(({ hasLeftAddon, hasRightAddon, isFixedSize }) => ({
|
|
13
|
+
getButtonSize: (v, t) => `
|
|
14
|
+
${ButtonContent_1.default} {
|
|
15
|
+
font-size: ${t.$.size.button[v].fontSize};
|
|
16
|
+
|
|
17
|
+
> ${Svg_1.default} {
|
|
18
|
+
height: ${t.$.size.button[v].iconSize};
|
|
19
|
+
width: ${t.$.size.button[v].iconSize};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
${!isFixedSize
|
|
23
|
+
? `
|
|
24
|
+
padding: ${t.$.size.button[v].padding.y} ${t.$.size.button[v].padding.x};
|
|
25
|
+
|
|
26
|
+
${hasLeftAddon
|
|
27
|
+
? `
|
|
28
|
+
padding-left: ${(0, css_1.toCSSValue)(t.$.size.button[v].padding.x)(val => val / 2)};
|
|
29
|
+
`
|
|
30
|
+
: ''}
|
|
31
|
+
|
|
32
|
+
${hasRightAddon
|
|
33
|
+
? `
|
|
34
|
+
padding-right: ${(0, css_1.toCSSValue)(t.$.size.button[v].padding.x)(val => val / 2)};
|
|
35
|
+
`
|
|
36
|
+
: ''}
|
|
37
|
+
`
|
|
38
|
+
: `
|
|
39
|
+
height: ${t.$.size.button[v].fixedSize};
|
|
40
|
+
width: ${t.$.size.button[v].fixedSize};
|
|
41
|
+
`}
|
|
42
|
+
|
|
43
|
+
> :not(:last-child) {
|
|
44
|
+
margin-right: ${(0, css_1.toCSSValue)(t.$.size.button[v].padding.x)(val => val / 4)};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`,
|
|
48
|
+
}))(({ theme, hasButtonContainer, hasHover, hasLeftAddon, hasRightAddon, hasSeparatedLeftAddon, hasSeparatedRightAddon, isBlock, isDisabled, isFixedSize, isLink, isLoading, isSoft, isOutline, palette, shape }) => `
|
|
49
|
+
align-items: stretch;
|
|
50
|
+
background: transparent;
|
|
51
|
+
border: 0;
|
|
52
|
+
font-family: ${theme.$.fontFamily.button};
|
|
53
|
+
position: relative;
|
|
54
|
+
transition: box-shadow 300ms 0s ease-in-out;
|
|
55
|
+
|
|
56
|
+
&,
|
|
57
|
+
${ButtonContent_1.default} {
|
|
58
|
+
border-radius: ${(isFixedSize && shape === 'rounded') ? '100%' : theme.$.radius.button[shape]};
|
|
59
|
+
|
|
60
|
+
${hasSeparatedLeftAddon
|
|
61
|
+
? `
|
|
62
|
+
border-top-left-radius: 0;
|
|
63
|
+
border-bottom-left-radius: 0;
|
|
64
|
+
`
|
|
65
|
+
: ''}
|
|
66
|
+
|
|
67
|
+
${hasSeparatedRightAddon
|
|
68
|
+
? `
|
|
69
|
+
border-top-right-radius: 0;
|
|
70
|
+
border-bottom-right-radius: 0;
|
|
71
|
+
`
|
|
72
|
+
: ''}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
${ButtonContent_1.default} {
|
|
76
|
+
${hasLeftAddon
|
|
77
|
+
? `
|
|
78
|
+
border-left: 0;
|
|
79
|
+
border-top-left-radius: 0;
|
|
80
|
+
border-bottom-left-radius: 0;
|
|
81
|
+
`
|
|
82
|
+
: ''}
|
|
83
|
+
|
|
84
|
+
${hasRightAddon
|
|
85
|
+
? `
|
|
86
|
+
border-right: 0;
|
|
87
|
+
border-top-right-radius: 0;
|
|
88
|
+
border-bottom-right-radius: 0;
|
|
89
|
+
`
|
|
90
|
+
: ''}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&:active {
|
|
94
|
+
outline: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
${!isFixedSize
|
|
98
|
+
? `
|
|
99
|
+
${(!isBlock)
|
|
100
|
+
? `
|
|
101
|
+
display: inline-flex;
|
|
102
|
+
flex: 0 1 auto;
|
|
103
|
+
`
|
|
104
|
+
: `
|
|
105
|
+
display: flex;
|
|
106
|
+
flex: 1 1 auto;
|
|
107
|
+
`}
|
|
108
|
+
`
|
|
109
|
+
: ''}
|
|
110
|
+
|
|
111
|
+
${(isBlock || isFixedSize)
|
|
112
|
+
? `
|
|
113
|
+
${ButtonContent_1.default} {
|
|
114
|
+
justify-content: center;
|
|
115
|
+
}
|
|
116
|
+
`
|
|
117
|
+
: ''}
|
|
118
|
+
|
|
119
|
+
${!isLink
|
|
120
|
+
? `
|
|
121
|
+
${!isOutline
|
|
122
|
+
? `
|
|
123
|
+
${!isSoft
|
|
124
|
+
? `
|
|
125
|
+
${ButtonContent_1.default} {
|
|
126
|
+
background: ${theme.$.palette[palette].main};
|
|
127
|
+
border-color: ${theme.$.palette[palette].main};
|
|
128
|
+
color: ${theme.$.palette[palette].font};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
${hasHover
|
|
132
|
+
? `
|
|
133
|
+
&:hover {
|
|
134
|
+
${ButtonContent_1.default} {
|
|
135
|
+
background: ${theme.$.palette[palette].dynamic};
|
|
136
|
+
border-color: ${theme.$.palette[palette].dynamic};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
${ButtonAddon_1.default} {
|
|
140
|
+
background: ${theme.$.palette[palette].dynamicest};
|
|
141
|
+
border-color: ${theme.$.palette[palette].dynamicest};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`
|
|
145
|
+
: ''}
|
|
146
|
+
`
|
|
147
|
+
: `
|
|
148
|
+
${ButtonContent_1.default} {
|
|
149
|
+
background: ${theme.$.palette[palette].soft};
|
|
150
|
+
border-color: ${theme.$.palette[palette].soft};
|
|
151
|
+
color: ${theme.$.palette[palette].softFont};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
${hasHover
|
|
156
|
+
? `
|
|
157
|
+
&:hover {
|
|
158
|
+
${ButtonContent_1.default} {
|
|
159
|
+
background: ${theme.$.palette[palette].softDark};
|
|
160
|
+
border-color: ${theme.$.palette[palette].softDark};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
${ButtonAddon_1.default} {
|
|
164
|
+
background: ${theme.$.palette[palette].softDarkest};
|
|
165
|
+
border-color: ${theme.$.palette[palette].softDarkest};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`
|
|
169
|
+
: ''}
|
|
170
|
+
`}
|
|
171
|
+
`
|
|
172
|
+
: `
|
|
173
|
+
${!isSoft
|
|
174
|
+
? `
|
|
175
|
+
${ButtonContent_1.default} {
|
|
176
|
+
border-color: ${theme.$.palette[palette].main};
|
|
177
|
+
color: ${theme.$.palette[palette].main};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
${hasHover
|
|
181
|
+
? `
|
|
182
|
+
&:hover {
|
|
183
|
+
${ButtonContent_1.default} {
|
|
184
|
+
background: ${theme.$.palette[palette].main};
|
|
185
|
+
color: ${theme.$.palette[palette].font};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
${ButtonAddon_1.default} {
|
|
189
|
+
background: ${theme.$.palette[palette].dynamicer};
|
|
190
|
+
color: ${theme.$.palette[palette].font};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
`
|
|
194
|
+
: ''}
|
|
195
|
+
`
|
|
196
|
+
: `
|
|
197
|
+
${ButtonContent_1.default} {
|
|
198
|
+
border-color: ${theme.$.palette[palette].soft};
|
|
199
|
+
color: ${theme.$.palette[palette].soft};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
${hasHover
|
|
203
|
+
? `
|
|
204
|
+
&:hover {
|
|
205
|
+
${ButtonContent_1.default} {
|
|
206
|
+
background: ${theme.$.palette[palette].soft};
|
|
207
|
+
color: ${theme.$.palette[palette].softFont};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
${ButtonAddon_1.default} {
|
|
211
|
+
background: ${theme.$.palette[palette].softDarker};
|
|
212
|
+
color: ${theme.$.palette[palette].softFont};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
`
|
|
216
|
+
: ''}
|
|
217
|
+
`}
|
|
218
|
+
`}
|
|
219
|
+
`
|
|
220
|
+
: `
|
|
221
|
+
${ButtonContent_1.default} {
|
|
222
|
+
border-color: transparent;
|
|
223
|
+
color: ${theme.$.palette[palette].main};
|
|
224
|
+
fill: ${theme.$.palette[palette].main};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
${hasHover
|
|
228
|
+
? `
|
|
229
|
+
&:hover {
|
|
230
|
+
${ButtonContent_1.default} {
|
|
231
|
+
color: ${theme.$.palette[palette].dynamicest};
|
|
232
|
+
text-decoration: underline;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
`
|
|
236
|
+
: ''}
|
|
237
|
+
`}
|
|
238
|
+
|
|
239
|
+
${!hasButtonContainer
|
|
240
|
+
? `
|
|
241
|
+
&:focus {
|
|
242
|
+
box-shadow: 0 0 0 .15rem ${theme.$.palette[palette].shadow};
|
|
243
|
+
}
|
|
244
|
+
`
|
|
245
|
+
: ''}
|
|
246
|
+
|
|
247
|
+
${isDisabled
|
|
248
|
+
? `
|
|
249
|
+
opacity: ${theme.$.opacity.buttonDisabled};
|
|
250
|
+
pointer-events: none;
|
|
251
|
+
`
|
|
252
|
+
: ''}
|
|
253
|
+
|
|
254
|
+
${isLoading
|
|
255
|
+
? `
|
|
256
|
+
pointer-events: none;
|
|
257
|
+
|
|
258
|
+
${ButtonContent_1.default},
|
|
259
|
+
${ButtonAddon_1.default} {
|
|
260
|
+
color: transparent;
|
|
261
|
+
|
|
262
|
+
> * {
|
|
263
|
+
visibility: hidden;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
`
|
|
267
|
+
: ''}
|
|
268
|
+
`);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ContentElement, Nullable } from '@smart-react-components/core/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface Props {
|
|
4
|
+
Component: React.ElementType;
|
|
5
|
+
leftAddon: Nullable<ContentElement>;
|
|
6
|
+
rightAddon: Nullable<ContentElement>;
|
|
7
|
+
props: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
interface Return {
|
|
12
|
+
leftAddon: Nullable<JSX.Element>;
|
|
13
|
+
rightAddon: Nullable<JSX.Element>;
|
|
14
|
+
}
|
|
15
|
+
declare const useAddons: ({ Component, leftAddon, rightAddon, props }: Props) => Return;
|
|
16
|
+
export default useAddons;
|
|
@@ -5,43 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const useChangeEffect_1 = __importDefault(require("@smart-react-components/core/hooks/useChangeEffect"));
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const InputAddon_1 = __importDefault(require("../Input/InputAddon"));
|
|
9
8
|
const types_1 = require("../types");
|
|
10
|
-
const
|
|
9
|
+
const useAddons = ({ Component, leftAddon, rightAddon, props }) => {
|
|
11
10
|
const generateAddonEl = (item, position) => {
|
|
11
|
+
var _a;
|
|
12
12
|
if (!item) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
isFocused,
|
|
18
|
-
isOutline,
|
|
19
|
-
isSoft,
|
|
20
|
-
palette,
|
|
21
|
-
position,
|
|
22
|
-
shape,
|
|
23
|
-
size,
|
|
24
|
-
sizeSm,
|
|
25
|
-
sizeMd,
|
|
26
|
-
sizeLg,
|
|
27
|
-
sizeXl,
|
|
28
|
-
};
|
|
29
|
-
if ((item === null || item === void 0 ? void 0 : item.displayName) === 'SRCInputAddon') {
|
|
30
|
-
return react_1.default.cloneElement(item, Object.assign(Object.assign({}, props), item.props));
|
|
15
|
+
if (((_a = item === null || item === void 0 ? void 0 : item.type) === null || _a === void 0 ? void 0 : _a.displayName) === 'SRCAddon') {
|
|
16
|
+
return react_1.default.cloneElement(item, Object.assign(Object.assign(Object.assign({}, props), item.props), { position }));
|
|
31
17
|
}
|
|
32
|
-
return (react_1.default.createElement(
|
|
18
|
+
return (react_1.default.createElement(Component, Object.assign({}, props, { position: position }), item));
|
|
33
19
|
};
|
|
34
20
|
const [leftAddonEl, setLeftAddonEl] = react_1.default.useState(() => generateAddonEl(leftAddon, types_1.OrderPosition.LEFT));
|
|
35
21
|
const [rightAddonEl, setRightAddonEl] = react_1.default.useState(() => generateAddonEl(rightAddon, types_1.OrderPosition.RIGHT));
|
|
36
22
|
(0, useChangeEffect_1.default)(() => {
|
|
37
23
|
setLeftAddonEl(generateAddonEl(leftAddon, types_1.OrderPosition.LEFT));
|
|
38
|
-
}, [leftAddon, isDisabled, isFocused]);
|
|
24
|
+
}, [leftAddon, props.isDisabled, props.isFocused]);
|
|
39
25
|
(0, useChangeEffect_1.default)(() => {
|
|
40
26
|
setRightAddonEl(generateAddonEl(rightAddon, types_1.OrderPosition.RIGHT));
|
|
41
|
-
}, [rightAddon, isDisabled, isFocused]);
|
|
27
|
+
}, [rightAddon, props.isDisabled, props.isFocused]);
|
|
42
28
|
return {
|
|
43
29
|
leftAddon: leftAddonEl,
|
|
44
30
|
rightAddon: rightAddonEl,
|
|
45
31
|
};
|
|
46
32
|
};
|
|
47
|
-
exports.default =
|
|
33
|
+
exports.default = useAddons;
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ export { default as Badge } from './Badge';
|
|
|
5
5
|
export { default as BadgeIcon } from './Badge/BadgeIcon';
|
|
6
6
|
export { default as BadgeList } from './Badge/BadgeList';
|
|
7
7
|
export * from './Breadcrumb';
|
|
8
|
+
export { default as Button } from './Button';
|
|
9
|
+
export { default as ButtonAddon } from './Button/ButtonAddon';
|
|
10
|
+
export { default as ButtonLink } from './Button/ButtonLink';
|
|
11
|
+
export { default as ButtonLoading } from './Button/ButtonLoading';
|
|
8
12
|
export { default as Checkbox } from './Checkbox';
|
|
9
13
|
export { default as CheckboxGroup } from './Checkbox/CheckboxGroup';
|
|
10
14
|
export { default as Dropdown } from './Dropdown';
|
|
@@ -25,6 +29,10 @@ export { default as Popover } from './Popover';
|
|
|
25
29
|
export { default as ProgressBar } from './ProgressBar';
|
|
26
30
|
export { default as Radio } from './Radio';
|
|
27
31
|
export { default as RadioGroup } from './Radio/RadioGroup';
|
|
32
|
+
export { default as Select } from './Select';
|
|
33
|
+
export { default as SelectAddon } from './Select/SelectAddon';
|
|
34
|
+
export { default as Option } from './Select/Option';
|
|
35
|
+
export { default as OptionGroup } from './Select/OptionGroup';
|
|
28
36
|
export { default as Switch } from './Switch';
|
|
29
37
|
export { default as SwitchGroup } from './Switch/SwitchGroup';
|
|
30
38
|
export { default as Textarea } from './Textarea';
|
package/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.WaveEffect = exports.Tooltip = exports.Textarea = exports.SwitchGroup = exports.Switch = exports.RadioGroup = exports.Radio = exports.ProgressBar = exports.Popover = exports.Overlay = exports.Loading = exports.InputNumber = exports.InputFile = exports.InputAddon = exports.Input = exports.FixedBox = exports.DropdownList = exports.DropdownItem = exports.DropdownCategory = exports.DropdownArrowIcon = exports.Dropdown = exports.CheckboxGroup = exports.Checkbox = exports.BadgeList = exports.BadgeIcon = exports.Badge = exports.AlertIcon = exports.AlertCloseIcon = exports.Alert = void 0;
|
|
20
|
+
exports.WaveEffect = exports.Tooltip = exports.Textarea = exports.SwitchGroup = exports.Switch = exports.OptionGroup = exports.Option = exports.SelectAddon = exports.Select = exports.RadioGroup = exports.Radio = exports.ProgressBar = exports.Popover = exports.Overlay = exports.Loading = exports.InputNumber = exports.InputFile = exports.InputAddon = exports.Input = exports.FixedBox = exports.DropdownList = exports.DropdownItem = exports.DropdownCategory = exports.DropdownArrowIcon = exports.Dropdown = exports.CheckboxGroup = exports.Checkbox = exports.ButtonLoading = exports.ButtonLink = exports.ButtonAddon = exports.Button = exports.BadgeList = exports.BadgeIcon = exports.Badge = exports.AlertIcon = exports.AlertCloseIcon = exports.Alert = void 0;
|
|
21
21
|
var Alert_1 = require("./Alert");
|
|
22
22
|
Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return __importDefault(Alert_1).default; } });
|
|
23
23
|
var AlertCloseIcon_1 = require("./Alert/AlertCloseIcon");
|
|
@@ -31,6 +31,14 @@ Object.defineProperty(exports, "BadgeIcon", { enumerable: true, get: function ()
|
|
|
31
31
|
var BadgeList_1 = require("./Badge/BadgeList");
|
|
32
32
|
Object.defineProperty(exports, "BadgeList", { enumerable: true, get: function () { return __importDefault(BadgeList_1).default; } });
|
|
33
33
|
__exportStar(require("./Breadcrumb"), exports);
|
|
34
|
+
var Button_1 = require("./Button");
|
|
35
|
+
Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return __importDefault(Button_1).default; } });
|
|
36
|
+
var ButtonAddon_1 = require("./Button/ButtonAddon");
|
|
37
|
+
Object.defineProperty(exports, "ButtonAddon", { enumerable: true, get: function () { return __importDefault(ButtonAddon_1).default; } });
|
|
38
|
+
var ButtonLink_1 = require("./Button/ButtonLink");
|
|
39
|
+
Object.defineProperty(exports, "ButtonLink", { enumerable: true, get: function () { return __importDefault(ButtonLink_1).default; } });
|
|
40
|
+
var ButtonLoading_1 = require("./Button/ButtonLoading");
|
|
41
|
+
Object.defineProperty(exports, "ButtonLoading", { enumerable: true, get: function () { return __importDefault(ButtonLoading_1).default; } });
|
|
34
42
|
var Checkbox_1 = require("./Checkbox");
|
|
35
43
|
Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return __importDefault(Checkbox_1).default; } });
|
|
36
44
|
var CheckboxGroup_1 = require("./Checkbox/CheckboxGroup");
|
|
@@ -69,6 +77,14 @@ var Radio_1 = require("./Radio");
|
|
|
69
77
|
Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { return __importDefault(Radio_1).default; } });
|
|
70
78
|
var RadioGroup_1 = require("./Radio/RadioGroup");
|
|
71
79
|
Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return __importDefault(RadioGroup_1).default; } });
|
|
80
|
+
var Select_1 = require("./Select");
|
|
81
|
+
Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(Select_1).default; } });
|
|
82
|
+
var SelectAddon_1 = require("./Select/SelectAddon");
|
|
83
|
+
Object.defineProperty(exports, "SelectAddon", { enumerable: true, get: function () { return __importDefault(SelectAddon_1).default; } });
|
|
84
|
+
var Option_1 = require("./Select/Option");
|
|
85
|
+
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return __importDefault(Option_1).default; } });
|
|
86
|
+
var OptionGroup_1 = require("./Select/OptionGroup");
|
|
87
|
+
Object.defineProperty(exports, "OptionGroup", { enumerable: true, get: function () { return __importDefault(OptionGroup_1).default; } });
|
|
72
88
|
var Switch_1 = require("./Switch");
|
|
73
89
|
Object.defineProperty(exports, "Switch", { enumerable: true, get: function () { return __importDefault(Switch_1).default; } });
|
|
74
90
|
var SwitchGroup_1 = require("./Switch/SwitchGroup");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smart-react-components/ui",
|
|
3
|
-
"version": "2.0.0-alpha-
|
|
3
|
+
"version": "2.0.0-alpha-7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"description": "SRC UI includes React and Styled components.",
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"test": "jest"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@smart-react-components/core": "2.0.0-alpha-
|
|
68
|
-
"@smart-react-components/router": "2.0.0-alpha-
|
|
69
|
-
"@smart-react-components/transition": "2.0.0-alpha-
|
|
67
|
+
"@smart-react-components/core": "2.0.0-alpha-13",
|
|
68
|
+
"@smart-react-components/router": "2.0.0-alpha-9",
|
|
69
|
+
"@smart-react-components/transition": "2.0.0-alpha-9",
|
|
70
70
|
"@testing-library/react": "13.4.0",
|
|
71
71
|
"@types/jest": "29.0.1",
|
|
72
72
|
"@types/react": "18.0.19",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"typescript": "4.8.3"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@smart-react-components/core": "^2.0.0-alpha-
|
|
87
|
-
"@smart-react-components/router": "^2.0.0-alpha-
|
|
88
|
-
"@smart-react-components/transition": "^2.0.0-alpha-
|
|
86
|
+
"@smart-react-components/core": "^2.0.0-alpha-13",
|
|
87
|
+
"@smart-react-components/router": "^2.0.0-alpha-9",
|
|
88
|
+
"@smart-react-components/transition": "^2.0.0-alpha-9",
|
|
89
89
|
"react": "^18.2.0",
|
|
90
90
|
"react-dom": "^18.2.0",
|
|
91
91
|
"styled-components": "^5.3.5"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
|
|
2
|
+
import { ContentElement, JSXElementProps, PaletteProp, Partial, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
|
|
3
|
+
export interface ButtonGenericProps extends IntrinsicStyledProps, Partial<ResponsiveProp<'size', SizeProp>> {
|
|
4
|
+
children: ContentElement | ContentElement[];
|
|
5
|
+
elementProps?: JSXElementProps;
|
|
6
|
+
hasHover?: boolean;
|
|
7
|
+
hasWaveEffect?: boolean;
|
|
8
|
+
isBlock?: boolean;
|
|
9
|
+
isDisabled?: boolean;
|
|
10
|
+
isFixedSize?: boolean;
|
|
11
|
+
isLink?: boolean;
|
|
12
|
+
isLoading?: boolean;
|
|
13
|
+
isSoft?: boolean;
|
|
14
|
+
isOutline?: boolean;
|
|
15
|
+
leftAddon?: JSX.Element;
|
|
16
|
+
loading?: JSX.Element;
|
|
17
|
+
palette?: PaletteProp;
|
|
18
|
+
rightAddon?: JSX.Element;
|
|
19
|
+
shape?: ShapeProp;
|
|
20
|
+
waveEffectPalette?: PaletteProp;
|
|
21
|
+
}
|
|
22
|
+
export declare enum ButtonType {
|
|
23
|
+
BUTTON = "button",
|
|
24
|
+
RESET = "reset",
|
|
25
|
+
SUBMIT = "submit"
|
|
26
|
+
}
|
package/types/button.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ButtonType = void 0;
|
|
4
|
+
var ButtonType;
|
|
5
|
+
(function (ButtonType) {
|
|
6
|
+
ButtonType["BUTTON"] = "button";
|
|
7
|
+
ButtonType["RESET"] = "reset";
|
|
8
|
+
ButtonType["SUBMIT"] = "submit";
|
|
9
|
+
})(ButtonType = exports.ButtonType || (exports.ButtonType = {}));
|
package/types/form.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IntrinsicStyledProps } from '@smart-react-components/core/element-props/intrinsic-styled-props';
|
|
2
|
+
import { ContentElement, PaletteProp, Partial, ResponsiveProp, SetState, ShapeProp, SizeProp } from '@smart-react-components/core/types';
|
|
3
|
+
import { FormValue } from '../types';
|
|
4
|
+
export interface GenericProps extends Partial<ResponsiveProp<'size', SizeProp>>, IntrinsicStyledProps {
|
|
5
|
+
active: FormValue | FormValue[];
|
|
6
|
+
children: JSX.Element | JSX.Element[];
|
|
7
|
+
hasBorder?: boolean;
|
|
8
|
+
hasHover?: boolean;
|
|
9
|
+
hasWaveEffect?: boolean;
|
|
10
|
+
isBlock?: boolean;
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
isRequired?: boolean;
|
|
13
|
+
isOutline?: boolean;
|
|
14
|
+
isSoft?: boolean;
|
|
15
|
+
label?: ContentElement;
|
|
16
|
+
leftAddon?: ContentElement;
|
|
17
|
+
palette?: PaletteProp;
|
|
18
|
+
rightAddon?: ContentElement;
|
|
19
|
+
shape?: ShapeProp;
|
|
20
|
+
setActive: SetState<FormValue | FormValue[]>;
|
|
21
|
+
waveEffectPalette?: PaletteProp;
|
|
22
|
+
}
|
package/types/form.js
ADDED
package/util/fixed-box.js
CHANGED
|
@@ -18,7 +18,7 @@ const calculatePosition = (triggerEl, boxEl, position, maxWidth, minWidth, space
|
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
boxEl.removeAttribute('style');
|
|
21
|
-
let width = boxEl.offsetWidth;
|
|
21
|
+
let width = Math.max(boxEl.offsetWidth, position & (types_1.Position.TOP | types_1.Position.BOTTOM) ? triggerEl.offsetWidth : 0);
|
|
22
22
|
if (minWidth && minWidth > width) {
|
|
23
23
|
width = minWidth;
|
|
24
24
|
}
|
package/util/form.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { FormValue } from '../types';
|
|
1
2
|
/**
|
|
2
3
|
* Calculates margin X value of the form label.
|
|
3
4
|
*/
|
|
4
5
|
export declare const calculateFormLabelMarginX: (value: number) => string;
|
|
6
|
+
/**
|
|
7
|
+
* Returns input value depending on active.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getInputValue: (active: FormValue | FormValue[] | null) => string;
|
package/util/form.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateFormLabelMarginX = void 0;
|
|
3
|
+
exports.getInputValue = exports.calculateFormLabelMarginX = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Calculates margin X value of the form label.
|
|
6
6
|
*/
|
|
7
7
|
const calculateFormLabelMarginX = (value) => (value / 1.0667).toFixed(5);
|
|
8
8
|
exports.calculateFormLabelMarginX = calculateFormLabelMarginX;
|
|
9
|
+
/**
|
|
10
|
+
* Returns input value depending on active.
|
|
11
|
+
*/
|
|
12
|
+
const getInputValue = (active) => ((!Array.isArray(active) && typeof active !== 'undefined' && active !== null)
|
|
13
|
+
|| (Array.isArray(active) && active.length > 0))
|
|
14
|
+
? String(active)
|
|
15
|
+
: '';
|
|
16
|
+
exports.getInputValue = getInputValue;
|
package/util/props.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
import { Nullable, SizeProp } from '@smart-react-components/core/types';
|
|
1
2
|
import { OrderPosition } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Gets icon size based on the given generic size props
|
|
5
|
+
*/
|
|
6
|
+
export declare const getIconSizeProps: (size: SizeProp, sizeSm?: Nullable<SizeProp>, sizeMd?: Nullable<SizeProp>, sizeLg?: Nullable<SizeProp>, sizeXl?: Nullable<SizeProp>) => {
|
|
7
|
+
heightXl: string;
|
|
8
|
+
widthXl: string;
|
|
9
|
+
heightLg: string;
|
|
10
|
+
widthLg: string;
|
|
11
|
+
heightMd: string;
|
|
12
|
+
widthMd: string;
|
|
13
|
+
heightSm: string;
|
|
14
|
+
widthSm: string;
|
|
15
|
+
height: string;
|
|
16
|
+
width: string;
|
|
17
|
+
};
|
|
2
18
|
/**
|
|
3
19
|
* Returns reverse value of the order position.
|
|
4
20
|
* If value is left, returns right.
|
package/util/props.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getReverseOrderPosition = void 0;
|
|
3
|
+
exports.getReverseOrderPosition = exports.getIconSizeProps = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
|
+
/**
|
|
6
|
+
* Gets icon size based on the given generic size props
|
|
7
|
+
*/
|
|
8
|
+
const getIconSizeProps = (size, sizeSm, sizeMd, sizeLg, sizeXl) => (Object.assign(Object.assign(Object.assign(Object.assign({ height: `$size.icon.${size}`, width: `$size.icon.${size}` }, (sizeSm && { heightSm: `$size.icon.${sizeSm}`, widthSm: `$size.icon.${sizeSm}` })), (sizeMd && { heightMd: `$size.icon.${sizeMd}`, widthMd: `$size.icon.${sizeMd}` })), (sizeLg && { heightLg: `$size.icon.${sizeLg}`, widthLg: `$size.icon.${sizeLg}` })), (sizeXl && { heightXl: `$size.icon.${sizeXl}`, widthXl: `$size.icon.${sizeXl}` })));
|
|
9
|
+
exports.getIconSizeProps = getIconSizeProps;
|
|
5
10
|
/**
|
|
6
11
|
* Returns reverse value of the order position.
|
|
7
12
|
* If value is left, returns right.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Nullable, PaletteProp } from '@smart-react-components/core/types';
|
|
2
|
+
/**
|
|
3
|
+
* If waveEffectPalette is given returns it however if not, generates a default palette for the wave effect.
|
|
4
|
+
*
|
|
5
|
+
* If the background is transparent, considered the body element uses the general background color in the color attributes.
|
|
6
|
+
* If palette is light and the dark mode is disabled, both the body background and the effect will be light color
|
|
7
|
+
* so defaults the wave palette to dark.
|
|
8
|
+
* The same goes for vice-versa. If the palette is dark and the dark mode is enabled, both the body background and the effect will be dark color
|
|
9
|
+
* then defaults the wave palette to light.
|
|
10
|
+
*
|
|
11
|
+
* If the background is transparent except from the above condition or uses the soft colors, defaults to the palette value to emphasize the palette color during the effect.
|
|
12
|
+
*
|
|
13
|
+
* If none of the above conditions are met, defaults to light since most of the default palette main colors are harmonious with the light effect color.
|
|
14
|
+
*
|
|
15
|
+
* @params waveEffectPalette indicates the given prop value. If given, always uses it.
|
|
16
|
+
* @params palette indicates the container element prop value.
|
|
17
|
+
* @params isSoft indicates if the container elements uses the soft colors.
|
|
18
|
+
* @params isTransparent indicates if the container element has a transparent background.
|
|
19
|
+
* @params isDark indicates if the dark mode is enabled.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getWaveEffectPalette: (waveEffectPalette: Nullable<PaletteProp>, palette: PaletteProp, isSoft: boolean, isTransparentBackground?: boolean, isDark?: boolean) => PaletteProp;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWaveEffectPalette = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* If waveEffectPalette is given returns it however if not, generates a default palette for the wave effect.
|
|
6
|
+
*
|
|
7
|
+
* If the background is transparent, considered the body element uses the general background color in the color attributes.
|
|
8
|
+
* If palette is light and the dark mode is disabled, both the body background and the effect will be light color
|
|
9
|
+
* so defaults the wave palette to dark.
|
|
10
|
+
* The same goes for vice-versa. If the palette is dark and the dark mode is enabled, both the body background and the effect will be dark color
|
|
11
|
+
* then defaults the wave palette to light.
|
|
12
|
+
*
|
|
13
|
+
* If the background is transparent except from the above condition or uses the soft colors, defaults to the palette value to emphasize the palette color during the effect.
|
|
14
|
+
*
|
|
15
|
+
* If none of the above conditions are met, defaults to light since most of the default palette main colors are harmonious with the light effect color.
|
|
16
|
+
*
|
|
17
|
+
* @params waveEffectPalette indicates the given prop value. If given, always uses it.
|
|
18
|
+
* @params palette indicates the container element prop value.
|
|
19
|
+
* @params isSoft indicates if the container elements uses the soft colors.
|
|
20
|
+
* @params isTransparent indicates if the container element has a transparent background.
|
|
21
|
+
* @params isDark indicates if the dark mode is enabled.
|
|
22
|
+
*/
|
|
23
|
+
const getWaveEffectPalette = (waveEffectPalette, palette, isSoft, isTransparentBackground = false, isDark = false) => {
|
|
24
|
+
if (waveEffectPalette) {
|
|
25
|
+
return waveEffectPalette;
|
|
26
|
+
}
|
|
27
|
+
if (isTransparentBackground && ['dynamic', '!dynamic', 'light', 'dark'].includes(palette)) {
|
|
28
|
+
return isDark ? 'light' : 'dark';
|
|
29
|
+
}
|
|
30
|
+
switch (palette) {
|
|
31
|
+
case 'dynamic':
|
|
32
|
+
return '!dynamic';
|
|
33
|
+
case '!dynamic':
|
|
34
|
+
return 'dynamic';
|
|
35
|
+
case 'light':
|
|
36
|
+
return 'dark';
|
|
37
|
+
case 'dark':
|
|
38
|
+
return 'light';
|
|
39
|
+
default:
|
|
40
|
+
return (isSoft || isTransparentBackground) ? palette : 'light';
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.getWaveEffectPalette = getWaveEffectPalette;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ContentElement, PaletteProp, ResponsiveProp, ShapeProp, SizeProp } from '@smart-react-components/core/types';
|
|
2
|
-
interface Props extends ResponsiveProp<'size', SizeProp> {
|
|
3
|
-
hasBorder: boolean;
|
|
4
|
-
isDisabled: boolean;
|
|
5
|
-
isFocused: boolean;
|
|
6
|
-
isOutline: boolean;
|
|
7
|
-
isSoft: boolean;
|
|
8
|
-
leftAddon: ContentElement | null;
|
|
9
|
-
rightAddon: ContentElement | null;
|
|
10
|
-
palette: PaletteProp;
|
|
11
|
-
shape: ShapeProp;
|
|
12
|
-
}
|
|
13
|
-
interface Return {
|
|
14
|
-
leftAddon: JSX.Element | null;
|
|
15
|
-
rightAddon: JSX.Element | null;
|
|
16
|
-
}
|
|
17
|
-
declare const useInputAddons: ({ hasBorder, isDisabled, isFocused, isOutline, isSoft, leftAddon, rightAddon, palette, shape, size, sizeSm, sizeMd, sizeLg, sizeXl }: Props) => Return;
|
|
18
|
-
export default useInputAddons;
|