forstok-ui-lib 8.8.0 → 8.8.2
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/index.d.ts +2 -0
- package/dist/index.js +497 -486
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/radio/styles.ts +42 -29
- package/src/components/select/asyncPaginate.tsx +123 -49
- package/src/components/select/index.tsx +2 -1
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import styled, { css } from
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
2
|
|
|
3
|
-
import IconCheckTick from
|
|
3
|
+
import IconCheckTick from "../../assets/images/icons/checkmark-tick.svg";
|
|
4
4
|
|
|
5
5
|
export const RadioContainer = styled.div`
|
|
6
6
|
display: grid;
|
|
7
7
|
grid-auto-flow: column;
|
|
8
8
|
justify-self: self-start;
|
|
9
|
-
|
|
9
|
+
`;
|
|
10
10
|
|
|
11
11
|
export const RadioSpan = styled.span<{ $mode?: string }>`
|
|
12
12
|
position: relative;
|
|
13
13
|
cursor: pointer;
|
|
14
14
|
display: inline-block;
|
|
15
15
|
height: 16px;
|
|
16
|
-
transition: .28s ease;
|
|
16
|
+
transition: 0.28s ease;
|
|
17
17
|
user-select: none;
|
|
18
18
|
padding-left: 22px;
|
|
19
|
-
&:before,
|
|
19
|
+
&:before,
|
|
20
20
|
&:after {
|
|
21
|
-
content:
|
|
21
|
+
content: "";
|
|
22
22
|
position: absolute;
|
|
23
23
|
left: 0;
|
|
24
24
|
top: 0;
|
|
25
25
|
width: 10px;
|
|
26
26
|
height: 10px;
|
|
27
27
|
z-index: 0;
|
|
28
|
-
transition: .28s ease;
|
|
28
|
+
transition: 0.28s ease;
|
|
29
29
|
border: 2px solid #5a5a5a;
|
|
30
30
|
border-radius: 50%;
|
|
31
31
|
}
|
|
@@ -37,25 +37,25 @@ export const RadioSpan = styled.span<{ $mode?: string }>`
|
|
|
37
37
|
font-size: 90%;
|
|
38
38
|
color: #2d3c48;
|
|
39
39
|
}
|
|
40
|
-
${({ $mode }:{ $mode?: string }) => {
|
|
41
|
-
if ($mode ===
|
|
42
|
-
return css`
|
|
43
|
-
&:before,
|
|
40
|
+
${({ $mode }: { $mode?: string }) => {
|
|
41
|
+
if ($mode === "check") {
|
|
42
|
+
return css`
|
|
43
|
+
&:before,
|
|
44
44
|
&:after {
|
|
45
45
|
border: none;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
} else if ($mode ===
|
|
49
|
-
return css`
|
|
47
|
+
`;
|
|
48
|
+
} else if ($mode === "sort") {
|
|
49
|
+
return css`
|
|
50
50
|
padding-left: 0;
|
|
51
|
-
&:before,
|
|
51
|
+
&:before,
|
|
52
52
|
&:after {
|
|
53
53
|
border: none;
|
|
54
54
|
}
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
}}
|
|
58
|
-
|
|
55
|
+
`;
|
|
56
|
+
}
|
|
57
|
+
}}
|
|
58
|
+
`;
|
|
59
59
|
|
|
60
60
|
export const RadioInput = styled.input<{ $mode?: string }>`
|
|
61
61
|
position: absolute;
|
|
@@ -72,11 +72,11 @@ export const RadioInput = styled.input<{ $mode?: string }>`
|
|
|
72
72
|
border: 2px solid transparent;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
${({ $mode }:{ $mode?: string }) => {
|
|
76
|
-
if ($mode ===
|
|
77
|
-
return css`
|
|
75
|
+
${({ $mode }: { $mode?: string }) => {
|
|
76
|
+
if ($mode === "check") {
|
|
77
|
+
return css`
|
|
78
78
|
&:checked + ${RadioSpan} {
|
|
79
|
-
&:before,
|
|
79
|
+
&:before,
|
|
80
80
|
&:after {
|
|
81
81
|
border: none;
|
|
82
82
|
transform: none;
|
|
@@ -87,11 +87,11 @@ export const RadioInput = styled.input<{ $mode?: string }>`
|
|
|
87
87
|
width: 14px;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
} else if ($mode ===
|
|
92
|
-
return css`
|
|
90
|
+
`;
|
|
91
|
+
} else if ($mode === "sort") {
|
|
92
|
+
return css`
|
|
93
93
|
&:checked + ${RadioSpan} {
|
|
94
|
-
&:before,
|
|
94
|
+
&:before,
|
|
95
95
|
&:after {
|
|
96
96
|
border: none;
|
|
97
97
|
transform: none;
|
|
@@ -101,7 +101,20 @@ export const RadioInput = styled.input<{ $mode?: string }>`
|
|
|
101
101
|
width: 14px;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
`;
|
|
105
|
+
} else if ($mode === "blue") {
|
|
106
|
+
return css`
|
|
107
|
+
&:checked + ${RadioSpan} {
|
|
108
|
+
&:before {
|
|
109
|
+
border: 2px solid var(--pri-clr-ln__fc);
|
|
110
|
+
}
|
|
111
|
+
&:after {
|
|
112
|
+
transform: scale(0.6);
|
|
113
|
+
background-color: var(--pri-clr-ln__fc);
|
|
114
|
+
border: 2px solid transparent;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
`;
|
|
105
118
|
}
|
|
106
119
|
}}
|
|
107
|
-
|
|
120
|
+
`;
|
|
@@ -49,6 +49,8 @@ type TSelect = {
|
|
|
49
49
|
) => void;
|
|
50
50
|
id?: string;
|
|
51
51
|
isDisabled?: boolean;
|
|
52
|
+
isCreateable?: boolean;
|
|
53
|
+
evCreate?: (value: string) => void;
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
const SelectAsyncPaginateComponent = ({ loadOptions, ...props }: TSelect) => {
|
|
@@ -61,7 +63,7 @@ const SelectAsyncPaginateComponent = ({ loadOptions, ...props }: TSelect) => {
|
|
|
61
63
|
MenuList,
|
|
62
64
|
defaultValue,
|
|
63
65
|
// reset,
|
|
64
|
-
|
|
66
|
+
setReset,
|
|
65
67
|
evChange,
|
|
66
68
|
isForceUpdate,
|
|
67
69
|
setForceUpdate,
|
|
@@ -76,6 +78,8 @@ const SelectAsyncPaginateComponent = ({ loadOptions, ...props }: TSelect) => {
|
|
|
76
78
|
setMenuIsOpen,
|
|
77
79
|
id,
|
|
78
80
|
evChangeOnMenuClose,
|
|
81
|
+
isCreateable = false,
|
|
82
|
+
evCreate,
|
|
79
83
|
...rest
|
|
80
84
|
} = props;
|
|
81
85
|
|
|
@@ -132,6 +136,21 @@ const SelectAsyncPaginateComponent = ({ loadOptions, ...props }: TSelect) => {
|
|
|
132
136
|
evChange && evChange(newValue, actionMeta);
|
|
133
137
|
};
|
|
134
138
|
|
|
139
|
+
const handleCreate = (inputValue: string) => {
|
|
140
|
+
setReset?.(false);
|
|
141
|
+
if (isMulti) {
|
|
142
|
+
!Array.isArray(valueSelect)
|
|
143
|
+
? setValueSelect([{ value: inputValue, label: inputValue }])
|
|
144
|
+
: setValueSelect([
|
|
145
|
+
...valueSelect,
|
|
146
|
+
{ value: inputValue, label: inputValue },
|
|
147
|
+
]);
|
|
148
|
+
} else {
|
|
149
|
+
setValueSelect({ value: inputValue, label: inputValue });
|
|
150
|
+
}
|
|
151
|
+
evCreate?.(inputValue);
|
|
152
|
+
};
|
|
153
|
+
|
|
135
154
|
const customStyles: StylesConfig<TOption, boolean> = {
|
|
136
155
|
container: (provided: CSSObject) =>
|
|
137
156
|
({
|
|
@@ -350,57 +369,112 @@ const SelectAsyncPaginateComponent = ({ loadOptions, ...props }: TSelect) => {
|
|
|
350
369
|
evToogleSelect();
|
|
351
370
|
};
|
|
352
371
|
|
|
353
|
-
|
|
354
|
-
<
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
return value;
|
|
378
|
-
}
|
|
379
|
-
|
|
372
|
+
let SelectEl = isCreateable ? (
|
|
373
|
+
<AsyncPaginate
|
|
374
|
+
isSearchable={isSearchable}
|
|
375
|
+
placeholder={placeholder}
|
|
376
|
+
debounceTimeout={500}
|
|
377
|
+
styles={customStyles}
|
|
378
|
+
loadOptions={loadOptions}
|
|
379
|
+
menuPortalTarget={document.body}
|
|
380
|
+
menuPosition="fixed"
|
|
381
|
+
menuPlacement="auto"
|
|
382
|
+
value={valueSelect}
|
|
383
|
+
onChange={handleChange}
|
|
384
|
+
onCreateOption={handleCreate}
|
|
385
|
+
loadOptionsOnMenuOpen={loadOptionsOnMenuOpen}
|
|
386
|
+
noOptionsMessage={noOptionsMessage}
|
|
387
|
+
menuIsOpen={isMenuOpen}
|
|
388
|
+
{...(id && { id: id })}
|
|
389
|
+
{...(mode === "multi-select" && {
|
|
390
|
+
closeMenuOnSelect: false,
|
|
391
|
+
inputValue: inputValue,
|
|
392
|
+
onInputChange: (value, action) => {
|
|
393
|
+
if (action.action === "input-change") {
|
|
394
|
+
setInputValue(value);
|
|
395
|
+
setTime(new Date());
|
|
380
396
|
return value;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return value;
|
|
400
|
+
},
|
|
401
|
+
onMenuClose: () => {
|
|
402
|
+
setInputValue("");
|
|
403
|
+
evChangeOnMenuClose?.(valueSelect);
|
|
404
|
+
},
|
|
405
|
+
onMenuOpen: () => evReToogleSelect(),
|
|
406
|
+
cacheUniqs: [_time],
|
|
407
|
+
selectRef: selectRef,
|
|
408
|
+
})}
|
|
409
|
+
{...(mode !== "multi-select" && {
|
|
410
|
+
onMenuOpen: onMenuOpen,
|
|
411
|
+
onMenuClose: onMenuClose,
|
|
412
|
+
})}
|
|
413
|
+
{...(customLabel && { components: { SingleValue: customLabel } })}
|
|
414
|
+
{...(customOption && { components: { Option: customOption } })}
|
|
415
|
+
{...(customLabel &&
|
|
416
|
+
customOption && {
|
|
417
|
+
components: { SingleValue: customLabel, Option: customOption },
|
|
389
418
|
})}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
419
|
+
{...(MenuList && { components: { MenuList } })}
|
|
420
|
+
{...(isMulti && { isMulti: true })}
|
|
421
|
+
{...rest}
|
|
422
|
+
/>
|
|
423
|
+
) : (
|
|
424
|
+
<AsyncPaginate
|
|
425
|
+
isSearchable={isSearchable}
|
|
426
|
+
placeholder={placeholder}
|
|
427
|
+
debounceTimeout={500}
|
|
428
|
+
styles={customStyles}
|
|
429
|
+
loadOptions={loadOptions}
|
|
430
|
+
menuPortalTarget={document.body}
|
|
431
|
+
menuPosition="fixed"
|
|
432
|
+
menuPlacement="auto"
|
|
433
|
+
value={valueSelect}
|
|
434
|
+
onChange={handleChange}
|
|
435
|
+
loadOptionsOnMenuOpen={loadOptionsOnMenuOpen}
|
|
436
|
+
noOptionsMessage={noOptionsMessage}
|
|
437
|
+
menuIsOpen={isMenuOpen}
|
|
438
|
+
{...(id && { id: id })}
|
|
439
|
+
{...(mode === "multi-select" && {
|
|
440
|
+
closeMenuOnSelect: false,
|
|
441
|
+
inputValue: inputValue,
|
|
442
|
+
onInputChange: (value, action) => {
|
|
443
|
+
if (action.action === "input-change") {
|
|
444
|
+
setInputValue(value);
|
|
445
|
+
setTime(new Date());
|
|
446
|
+
return value;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return value;
|
|
450
|
+
},
|
|
451
|
+
onMenuClose: () => {
|
|
452
|
+
setInputValue("");
|
|
453
|
+
evChangeOnMenuClose?.(valueSelect);
|
|
454
|
+
},
|
|
455
|
+
onMenuOpen: () => evReToogleSelect(),
|
|
456
|
+
cacheUniqs: [_time],
|
|
457
|
+
selectRef: selectRef,
|
|
458
|
+
})}
|
|
459
|
+
{...(mode !== "multi-select" && {
|
|
460
|
+
onMenuOpen: onMenuOpen,
|
|
461
|
+
onMenuClose: onMenuClose,
|
|
462
|
+
})}
|
|
463
|
+
{...(customLabel && { components: { SingleValue: customLabel } })}
|
|
464
|
+
{...(customOption && { components: { Option: customOption } })}
|
|
465
|
+
{...(customLabel &&
|
|
466
|
+
customOption && {
|
|
467
|
+
components: { SingleValue: customLabel, Option: customOption },
|
|
393
468
|
})}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
/>
|
|
469
|
+
{...(MenuList && { components: { MenuList } })}
|
|
470
|
+
{...(isMulti && { isMulti: true })}
|
|
471
|
+
{...rest}
|
|
472
|
+
/>
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
return (
|
|
476
|
+
<div className="_refContainer" style={{ width: "100%", minWidth: 0 }}>
|
|
477
|
+
{SelectEl}
|
|
404
478
|
</div>
|
|
405
479
|
);
|
|
406
480
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import ReactSelect from "react-select";
|
|
3
|
+
import AsyncCreatableSelect from "react-select/async-creatable";
|
|
3
4
|
import type {
|
|
4
5
|
SingleValueProps,
|
|
5
6
|
OptionProps,
|
|
@@ -545,7 +546,7 @@ const SelectComponent = ({
|
|
|
545
546
|
};
|
|
546
547
|
|
|
547
548
|
let SelectEl = isCreateable ? (
|
|
548
|
-
<
|
|
549
|
+
<AsyncCreatableSelect
|
|
549
550
|
options={options}
|
|
550
551
|
styles={customStyles}
|
|
551
552
|
onMenuOpen={evToogleSelect}
|