forstok-ui-lib 6.18.2 → 6.19.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/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/assets/images/navs/left/price-active.svg +5 -0
- package/src/assets/images/navs/left/price.svg +5 -0
- package/src/components/icon/styles.ts +16 -0
- package/src/components/select/all.tsx +189 -0
package/package.json
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="100%" height="100%" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M3.04591 11.603C1.88716 10.4435 1.3074 9.86449 1.09215 9.11224C0.876149 8.35998 1.06065 7.56123 1.42965 5.96447L1.6419 5.04346C1.95166 3.69945 2.10691 3.02745 2.56666 2.56694C3.02641 2.10644 3.69917 1.95194 5.04318 1.64219L5.96418 1.42919C7.56169 1.06093 8.3597 0.876433 9.11195 1.09168C9.86421 1.30769 10.4432 1.88744 11.602 3.0462L12.9745 4.41871C14.9927 6.43622 16 7.44423 16 8.69674C16 9.94999 14.992 10.958 12.9752 12.9748C10.9577 14.9923 9.94971 16.0003 8.69645 16.0003C7.44394 16.0003 6.43519 14.9923 4.41842 12.9755L3.04591 11.603Z" stroke="#086de0"/>
|
|
3
|
+
<path d="M11.0423 11.0434C11.4811 10.6031 11.5403 9.9506 11.1743 9.58384C10.8083 9.21709 10.1551 9.27709 9.71556 9.7166C9.27681 10.1561 8.62355 10.2153 8.25755 9.84935C7.89155 9.48334 7.9508 8.83009 8.3903 8.39134M8.3903 8.39134L8.1248 8.12583M8.3903 8.39134C8.63855 8.14233 8.95505 8.01633 9.2498 8.01858M11.3071 11.3081L11.0416 11.0426C10.7416 11.3434 10.3403 11.4664 9.99981 11.3959" stroke="#086de0" stroke-linecap="round"/>
|
|
4
|
+
<path d="M7.01599 7.21985C7.60178 6.63406 7.60178 5.6843 7.01599 5.09851C6.4302 4.51272 5.48044 4.51272 4.89465 5.09851C4.30886 5.6843 4.30886 6.63406 4.89465 7.21985C5.48044 7.80564 6.4302 7.80564 7.01599 7.21985Z" stroke="#086de0"/>
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="100%" height="100%" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M3.04591 11.603C1.88716 10.4435 1.3074 9.86449 1.09215 9.11224C0.876149 8.35998 1.06065 7.56123 1.42965 5.96447L1.6419 5.04346C1.95166 3.69945 2.10691 3.02745 2.56666 2.56694C3.02641 2.10644 3.69917 1.95194 5.04318 1.64219L5.96418 1.42919C7.56169 1.06093 8.3597 0.876433 9.11195 1.09168C9.86421 1.30769 10.4432 1.88744 11.602 3.0462L12.9745 4.41871C14.9927 6.43622 16 7.44423 16 8.69674C16 9.94999 14.992 10.958 12.9752 12.9748C10.9577 14.9923 9.94971 16.0003 8.69645 16.0003C7.44394 16.0003 6.43519 14.9923 4.41842 12.9755L3.04591 11.603Z" stroke="black"/>
|
|
3
|
+
<path d="M11.0423 11.0434C11.4811 10.6031 11.5403 9.9506 11.1743 9.58384C10.8083 9.21709 10.1551 9.27709 9.71556 9.7166C9.27681 10.1561 8.62355 10.2153 8.25755 9.84935C7.89155 9.48334 7.9508 8.83009 8.3903 8.39134M8.3903 8.39134L8.1248 8.12583M8.3903 8.39134C8.63855 8.14233 8.95505 8.01633 9.2498 8.01858M11.3071 11.3081L11.0416 11.0426C10.7416 11.3434 10.3403 11.4664 9.99981 11.3959" stroke="black" stroke-linecap="round"/>
|
|
4
|
+
<path d="M7.01599 7.21985C7.60178 6.63406 7.60178 5.6843 7.01599 5.09851C6.4302 4.51272 5.48044 4.51272 4.89465 5.09851C4.30886 5.6843 4.30886 6.63406 4.89465 7.21985C5.48044 7.80564 6.4302 7.80564 7.01599 7.21985Z" stroke="black"/>
|
|
5
|
+
</svg>
|
|
@@ -60,6 +60,8 @@ import IconOrderLeftNav from '../../assets/images/navs/left/order.svg'
|
|
|
60
60
|
import IconProductActiveLeftNav from '../../assets/images/navs/left/products-active.svg'
|
|
61
61
|
import IconInventoryActiveLeftNav from '../../assets/images/navs/left/inventory-active.svg'
|
|
62
62
|
import IconOrderActiveLeftNav from '../../assets/images/navs/left/order-active.svg'
|
|
63
|
+
import IconPriceLeftNav from '../../assets/images/navs/left/price.svg';
|
|
64
|
+
import IconPriceActiveLeftNav from '../../assets/images/navs/left/price-active.svg';
|
|
63
65
|
import IconWarningChat from '../../assets/images/icons/warning-agent.svg';
|
|
64
66
|
import IconCheckChat from '../../assets/images/icons/check.svg';
|
|
65
67
|
import IconCheckChatBlue from '../../assets/images/icons/check-blue.svg';
|
|
@@ -527,6 +529,20 @@ const getIconContainerStyled = ({ $mode, $name, $width, onClick }:{ $mode?: stri
|
|
|
527
529
|
}
|
|
528
530
|
`
|
|
529
531
|
break;
|
|
532
|
+
case 'price-left-nav':
|
|
533
|
+
style += `
|
|
534
|
+
&:before {
|
|
535
|
+
content: url(${IconPriceLeftNav});
|
|
536
|
+
}
|
|
537
|
+
`
|
|
538
|
+
break;
|
|
539
|
+
case 'price-active-left-nav':
|
|
540
|
+
style += `
|
|
541
|
+
&:before {
|
|
542
|
+
content: url(${IconPriceActiveLeftNav});
|
|
543
|
+
}
|
|
544
|
+
`
|
|
545
|
+
break;
|
|
530
546
|
case 'warning-chat':
|
|
531
547
|
style += `
|
|
532
548
|
&:before {
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { useRef } from 'react'
|
|
2
|
+
import ReactSelect, { ActionMeta, MultiValue, CSSObjectWithLabel, ControlProps, GroupBase } from 'react-select'
|
|
3
|
+
import type { CSSObject } from '@emotion/serialize'
|
|
4
|
+
|
|
5
|
+
import { TOption } from './typed'
|
|
6
|
+
|
|
7
|
+
type TSelect = {
|
|
8
|
+
mode?: string
|
|
9
|
+
isError?: boolean
|
|
10
|
+
'data-qa-id'?: string
|
|
11
|
+
value: MultiValue<any>
|
|
12
|
+
options: TOption[] | null
|
|
13
|
+
evChange: (newValue: any[], actionMeta: ActionMeta<any>) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const SelectAll = (props: TSelect) => {
|
|
17
|
+
const {
|
|
18
|
+
isError=false,
|
|
19
|
+
value,
|
|
20
|
+
options,
|
|
21
|
+
mode,
|
|
22
|
+
evChange,
|
|
23
|
+
...rest
|
|
24
|
+
} = props
|
|
25
|
+
|
|
26
|
+
const valueRef = useRef(value as MultiValue<any> | null)
|
|
27
|
+
valueRef.current = value
|
|
28
|
+
|
|
29
|
+
const placeholder = mode === 'store' ? 'Stores' : 'Categories'
|
|
30
|
+
const selectAllOption = {
|
|
31
|
+
value: "*",
|
|
32
|
+
label: "All "+placeholder
|
|
33
|
+
};
|
|
34
|
+
const isSelectAllSelected = () => valueRef.current?.length === options?.length
|
|
35
|
+
const getOptions = () => options ? [selectAllOption, ...options] : [selectAllOption]
|
|
36
|
+
|
|
37
|
+
const isOptionSelected = (option: { value: string }) => {
|
|
38
|
+
return valueRef.current?.some(({ value }: { value: string }) => value === option.value) || isSelectAllSelected()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const getValue = () => (valueRef.current && valueRef.current.length >= 5) ? [{
|
|
42
|
+
value: value,
|
|
43
|
+
label: `${valueRef.current?.length} ${placeholder}`}
|
|
44
|
+
] : isSelectAllSelected() ? [selectAllOption] : value
|
|
45
|
+
|
|
46
|
+
const handleChange = (newValue: MultiValue<any>, actionMeta: ActionMeta<any>) => {
|
|
47
|
+
if (!options) {
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
const { action, option, removedValue } = actionMeta
|
|
51
|
+
let _newValue = newValue ? [...newValue] : null
|
|
52
|
+
const mergeVal = (newValue && newValue.length && Array.isArray(newValue[0].value)) ? newValue[0].value : null
|
|
53
|
+
let result: any[] = []
|
|
54
|
+
if (action === "select-option" && option.value === selectAllOption.value) {
|
|
55
|
+
result = options
|
|
56
|
+
} else if ((action === "deselect-option" &&
|
|
57
|
+
option.value === selectAllOption.value) ||
|
|
58
|
+
(action === "remove-value" && removedValue.value === selectAllOption.value)) {
|
|
59
|
+
result = []
|
|
60
|
+
} else if (actionMeta.action === "deselect-option" && isSelectAllSelected()) {
|
|
61
|
+
result = options.filter(({ value }: { value: string }) => value !== option.value)
|
|
62
|
+
} else if (actionMeta.action === "remove-value" && mergeVal) {
|
|
63
|
+
valueRef.current = null
|
|
64
|
+
result = []
|
|
65
|
+
} else if (actionMeta.action === "deselect-option") {
|
|
66
|
+
if (mergeVal) {
|
|
67
|
+
_newValue = mergeVal.filter(({ value }: { value: string }) => value !== option.value)
|
|
68
|
+
valueRef.current = _newValue
|
|
69
|
+
} else {
|
|
70
|
+
_newValue = newValue.filter(({ value }: { value: string }) => value !== option.value)
|
|
71
|
+
}
|
|
72
|
+
result = _newValue || []
|
|
73
|
+
} else {
|
|
74
|
+
if (mergeVal) {
|
|
75
|
+
_newValue = [...mergeVal, newValue[1]]
|
|
76
|
+
valueRef.current = _newValue
|
|
77
|
+
}
|
|
78
|
+
result = _newValue || []
|
|
79
|
+
}
|
|
80
|
+
evChange(result, actionMeta)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const customStyles = {
|
|
84
|
+
container: (provided: CSSObject) => ({
|
|
85
|
+
...provided,
|
|
86
|
+
display: 'inline-block',
|
|
87
|
+
minHeight: '1px',
|
|
88
|
+
textAlign: 'left',
|
|
89
|
+
border: 'none',
|
|
90
|
+
} as CSSObjectWithLabel),
|
|
91
|
+
control: (provided: CSSObjectWithLabel, state:ControlProps<{ value: string; }, true, GroupBase<TOption>>) => ({
|
|
92
|
+
...provided,
|
|
93
|
+
borderRadius: '.5rem',
|
|
94
|
+
cursor: 'pointer',
|
|
95
|
+
minHeight: mode === 'store' ? '30px': '38px',
|
|
96
|
+
borderWidth: isError ? '1px' : '0',
|
|
97
|
+
boxShadow: (state.isFocused) ? '-.0625rem 0rem .0625rem 0rem rgba(26, 26, 26, .122) inset, .0625rem 0rem .0625rem 0rem rgba(26, 26, 26, .122) inset, 0rem .125rem .0625rem 0rem rgba(26, 26, 26, .2) inset' : '0rem -.0625rem 0rem 0rem #b5b5b5 inset,0rem 0rem 0rem .0625rem rgba(0, 0, 0, .1) inset,0rem .03125rem 0rem .09375rem #FFF inset',
|
|
98
|
+
borderColor: ((state.isFocused && mode !== 'filter') && !isError) ? 'var(--pri-clr-ln__fc)' : (isError ? 'var(--err-clr-ln)' : (mode ==='filter' ? '#ffffff' : ' var(--ck-clr-ln)' )),
|
|
99
|
+
background: state.isFocused ? 'rgba(247, 247, 247, 1)' : '#ffffff',
|
|
100
|
+
'&:hover': {
|
|
101
|
+
borderColor: ((state.isFocused && mode !== 'filter') && !isError) ? 'var(--pri-clr-ln__fc)' : (isError ? 'var(--err-clr-ln)' : (mode ==='filter' ? '#ffffff' : ' var(--ck-clr-ln)' )),
|
|
102
|
+
background: 'rgba(250, 250, 250, 1)',
|
|
103
|
+
color: 'rgba(48, 48, 48, 1)'
|
|
104
|
+
}
|
|
105
|
+
} as CSSObjectWithLabel),
|
|
106
|
+
placeholder: (provided: CSSObject) => ({
|
|
107
|
+
...provided,
|
|
108
|
+
fontStyle: 'italic'
|
|
109
|
+
} as CSSObjectWithLabel),
|
|
110
|
+
input: (provided: CSSObject) => ({
|
|
111
|
+
...provided,
|
|
112
|
+
minHeight: '1px',
|
|
113
|
+
margin: '0 2px',
|
|
114
|
+
padding: '0',
|
|
115
|
+
'input': {
|
|
116
|
+
boxShadow: 'none !important'
|
|
117
|
+
}
|
|
118
|
+
} as CSSObjectWithLabel),
|
|
119
|
+
dropdownIndicator: (provided: CSSObject) => ({
|
|
120
|
+
...provided,
|
|
121
|
+
minHeight: '1px',
|
|
122
|
+
paddingTop: '0',
|
|
123
|
+
paddingBottom: '0',
|
|
124
|
+
paddingLeft: '2px',
|
|
125
|
+
paddingRight: '2px',
|
|
126
|
+
color: '#757575',
|
|
127
|
+
} as CSSObjectWithLabel),
|
|
128
|
+
indicatorSeparator: (provided: CSSObject) => ({
|
|
129
|
+
...provided,
|
|
130
|
+
minHeight: '1px',
|
|
131
|
+
height: '24px',
|
|
132
|
+
display: 'none'
|
|
133
|
+
} as CSSObjectWithLabel),
|
|
134
|
+
clearIndicator: (provided: CSSObject) => ({
|
|
135
|
+
...provided,
|
|
136
|
+
minHeight: '1px',
|
|
137
|
+
marginRight: '-6px',
|
|
138
|
+
padding: '0'
|
|
139
|
+
} as CSSObjectWithLabel),
|
|
140
|
+
valueContainer: (provided: CSSObject) => ({
|
|
141
|
+
...provided,
|
|
142
|
+
height: '30px',
|
|
143
|
+
overflow: 'auto',
|
|
144
|
+
paddingTop: '0',
|
|
145
|
+
paddingBottom: '0',
|
|
146
|
+
paddingRight: '2px',
|
|
147
|
+
} as CSSObjectWithLabel),
|
|
148
|
+
menuPortal: (provided: CSSObject) => ({
|
|
149
|
+
...provided,
|
|
150
|
+
zIndex: 9999,
|
|
151
|
+
letterSpacing: 'normal',
|
|
152
|
+
lineHeight: 'normal',
|
|
153
|
+
} as CSSObjectWithLabel),
|
|
154
|
+
option: (provided: CSSObject, state: { isSelected: any }) => ({
|
|
155
|
+
...provided,
|
|
156
|
+
color: state.isSelected ? '#ffffff' : '#000000',
|
|
157
|
+
backgroundColor: state.isSelected ? '#fc5c64' : 'transparent',
|
|
158
|
+
cursor: 'pointer',
|
|
159
|
+
'&:hover': {
|
|
160
|
+
backgroundColor: '#ec5b62',
|
|
161
|
+
color: '#ffffff'
|
|
162
|
+
}
|
|
163
|
+
} as CSSObjectWithLabel),
|
|
164
|
+
menu: (provided: CSSObject) => ({
|
|
165
|
+
...provided,
|
|
166
|
+
borderRadius: '.75rem',
|
|
167
|
+
boxShadow: '0rem .5rem 1.5rem -.5rem rgba(0, 0, 0, .05), 0rem .5rem 1rem -.25rem rgba(0, 0, 0, .05), 0rem .1875rem .375rem 0rem rgba(0, 0, 0, .05), 0rem .125rem .25rem 0rem rgba(0, 0, 0, .05), 0rem .0625rem .125rem 0rem rgba(0, 0, 0, .05), 0rem 0rem 0rem .0625rem rgba(0, 0, 0, .06)',
|
|
168
|
+
border: 'none'
|
|
169
|
+
} as CSSObjectWithLabel)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div className='_refContainer' {...rest['data-qa-id'] && {'data-qa-id': rest['data-qa-id']}}>
|
|
174
|
+
<ReactSelect
|
|
175
|
+
isOptionSelected={isOptionSelected}
|
|
176
|
+
styles={customStyles}
|
|
177
|
+
menuPortalTarget={document.body}
|
|
178
|
+
options={getOptions()}
|
|
179
|
+
value={getValue()}
|
|
180
|
+
onChange={handleChange}
|
|
181
|
+
hideSelectedOptions={false}
|
|
182
|
+
closeMenuOnSelect={false}
|
|
183
|
+
isMulti
|
|
184
|
+
/>
|
|
185
|
+
</div>
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export default SelectAll
|