forstok-ui-lib 5.0.3 → 5.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forstok-ui-lib",
3
- "version": "5.0.3",
3
+ "version": "5.1.0",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -41,6 +41,7 @@
41
41
  "react": "^19.0.0",
42
42
  "react-dom": "^19.0.0",
43
43
  "react-router-dom": "^7.1.1",
44
+ "react-select": "^5.10.0",
44
45
  "rollup-plugin-dts": "^6.1.1",
45
46
  "rollup-plugin-peer-deps-external": "^2.2.4",
46
47
  "rollup-plugin-postcss": "^4.0.2",
@@ -0,0 +1,28 @@
1
+ import { TMessageQuestion } from '../../components/message/typed';
2
+
3
+ export const formatNumber = (n?: string | number, flag?: boolean) => {
4
+ const _flag = flag === undefined ? true : flag
5
+ let result:string = ''
6
+ if (n !== '' && n !== null && n !== undefined) {
7
+ result = n?.toString().replaceAll(".", "")
8
+ if (result.length === 2 && result.substring(0, 1) === "0") {
9
+ result = parseInt(result).toString()
10
+ }
11
+ if (_flag) {
12
+ result = result.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ".")
13
+ }
14
+ }
15
+ return result
16
+ }
17
+
18
+ export const generateMessageQuestion = (type: string, title: string, subtitle: string, callback?: () => void, buttonSubmit?: string, cancelCallback?: () => void) => {
19
+ let result: TMessageQuestion = {
20
+ $type: type,
21
+ title: title,
22
+ subtitle: subtitle,
23
+ callback: callback,
24
+ buttonSubmit: buttonSubmit,
25
+ cancelCallback: cancelCallback
26
+ }
27
+ return result
28
+ }
@@ -1,9 +1,10 @@
1
1
  import { useState, useEffect, type InputHTMLAttributes, type ChangeEvent, type FocusEvent, type KeyboardEvent, type ClipboardEvent } from 'react';
2
- import { InputContainer } from './styles';
2
+ import { formatNumber } from '../../assets/javascripts/function';
3
+ import { InputContainer, InputLabel, InputWrapper } from './styles';
3
4
  import type { TEnterEvent, TKeyboadEvent, TState } from '../../typeds/base.typed';
4
5
 
5
6
  type TInput = InputHTMLAttributes<HTMLInputElement> & {
6
- mode?: string
7
+ $mode?: string
7
8
  $isError?: boolean
8
9
  $iconLeft?: boolean
9
10
  $iconRight?: boolean
@@ -17,17 +18,20 @@ type TInput = InputHTMLAttributes<HTMLInputElement> & {
17
18
  evChangeCustom? : (key: string, value: any) => void
18
19
  evEnter?: TEnterEvent
19
20
  evKeyUp?: TKeyboadEvent
20
- };
21
+ $aliasLabel?: string
22
+ }
21
23
 
22
- const InputComponent = ({ mode, $isError, $iconLeft, $iconRight, reset, setReset, isForceUpdate, setForceUpdate, evChange, evBlur, isField, evChangeCustom, evEnter, evKeyUp, ...props }: TInput) => {
24
+ const InputComponent = ({ $mode, $aliasLabel, $isError, $iconLeft, $iconRight, reset, setReset, isForceUpdate, setForceUpdate, evChange, evBlur, isField, evChangeCustom, evEnter, evKeyUp, ...props }: TInput) => {
23
25
  const { type, name, defaultValue, defaultChecked } = props;
24
- const _value = defaultValue?.toString() ?? '';
26
+
27
+ const _value = ($mode === 'currency' ? formatNumber(defaultValue?.toString() ?? '') : (defaultValue?.toString()) ?? '');
28
+
25
29
  const [inputValue, evInputValue] = useState<string>(_value);
26
30
  const [inputChecked, evInputChecked] = useState<boolean>(defaultChecked||false);
27
31
 
28
32
  useEffect(() => {
29
33
  if (isForceUpdate) {
30
- const _value = defaultValue?.toString() ?? '';
34
+ const _value = ($mode === 'currency' ? formatNumber(defaultValue?.toString() ?? '') : (defaultValue?.toString()) ?? '');
31
35
  evInputValue(_value);
32
36
  evInputChecked(defaultChecked||false);
33
37
  setForceUpdate && setForceUpdate(false);
@@ -37,62 +41,72 @@ const InputComponent = ({ mode, $isError, $iconLeft, $iconRight, reset, setReset
37
41
  evInputChecked(false);
38
42
  setReset && setReset(false);
39
43
  }
40
- }, [isForceUpdate, setForceUpdate, reset, setReset, defaultValue, defaultChecked, evInputChecked, mode]);
44
+ }, [isForceUpdate, setForceUpdate, reset, setReset, defaultValue, defaultChecked, evInputChecked, $mode])
41
45
 
42
46
  const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
43
47
  const _value = e.target.value;
44
48
  evInputValue(_value);
45
- };
49
+ }
46
50
 
47
51
  const _evKeyUp = (e: KeyboardEvent<HTMLInputElement>) => {
52
+ if ($mode === 'currency') {
53
+ e.currentTarget.value = formatNumber(e.currentTarget.value);
54
+ }
48
55
  if (e.key === 'Enter') {
49
56
  e.preventDefault();
50
- (isField && evEnter) && evEnter(e);
57
+ (isField && evEnter) && evEnter(e)
51
58
  }
52
- };
59
+ }
53
60
 
54
61
  const _evKeyPress = (e: KeyboardEvent<HTMLInputElement>) => {
55
- if (type === 'number') {
56
- if(!(!(isNaN(Number(e.key)) || typeof e.key === 'undefined' || e.key === ''))) {
62
+ const _target = e.target as HTMLInputElement;
63
+ if (type === 'number' || $mode === 'currency') {
64
+ if(!(!(isNaN(Number(e.key)) || typeof e.key === 'undefined' || e.key === ''))) e.preventDefault();
65
+ }
66
+ if ($mode === 'currency') {
67
+ if ((_target.value.length === 1 && e.key === '0' && _target.value === "0") || e.key === ' ') {
57
68
  e.preventDefault();
69
+ } else {
70
+ return true;
58
71
  }
72
+ } else {
73
+ return true;
59
74
  }
60
- return true;
61
- };
75
+ }
62
76
 
63
77
  const _evBlur = (e: FocusEvent<HTMLInputElement>) => {
64
78
  evBlur && evBlur(e);
65
79
  (isField && evEnter) && evEnter(e);
66
80
  if (isField && name) {
67
- const value = type === 'number' ? parseInt(e.target.value) : e.target.value.trim();
81
+ const value = (type === 'number') ? parseInt(e.target.value) : ($mode === 'currency' ? e.target.value ? parseInt(formatNumber(e.target.value, false)) : null : e.target.value.trim())
68
82
  evChangeCustom && evChangeCustom(name, value);
69
83
  }
70
- };
84
+ }
71
85
 
72
86
  let parseProps = {...props};
73
87
  delete parseProps.defaultValue;
74
88
  delete parseProps.defaultChecked;
75
89
 
76
90
  const inputEl = <InputContainer
77
- mode={mode}
91
+ $mode={$mode}
78
92
  $isError={$isError}
79
93
  $iconLeft={$iconLeft}
80
94
  $iconRight={$iconRight}
81
95
  checked={inputChecked}
82
96
  value={inputValue}
83
97
  onChange={(e: ChangeEvent<HTMLInputElement>) => {
84
- handleChange(e);
85
- evChange && evChange(e);
98
+ handleChange(e)
99
+ evChange && evChange(e)
86
100
  }}
87
101
  onBlur={(e: FocusEvent<HTMLInputElement>) => {
88
- handleChange(e);
89
- _evBlur(e);
102
+ handleChange(e)
103
+ _evBlur(e)
90
104
  }}
91
105
  onKeyUp={(e: KeyboardEvent<HTMLInputElement>) => {
92
- evKeyUp && evKeyUp(e);
93
- _evKeyUp(e);
106
+ evKeyUp && evKeyUp(e)
107
+ _evKeyUp(e)
94
108
  }}
95
- {...(type ==='number' && { onKeyPress: _evKeyPress } )}
109
+ {...((type ==='number' || $mode === 'currency') && { onKeyPress: _evKeyPress } )}
96
110
  {...(type ==='number' && { onPaste: (e: ClipboardEvent<HTMLInputElement>) => {
97
111
  const pasteVal = (e.clipboardData || (window as any).clipboardData).getData('text')
98
112
  const _value = pasteVal.replace(/[^0-9]/g, '')
@@ -101,9 +115,16 @@ const InputComponent = ({ mode, $isError, $iconLeft, $iconRight, reset, setReset
101
115
  } })}
102
116
  {...(type ==='number' && { onFocus: (e: FocusEvent<HTMLInputElement>) => e.target.addEventListener("wheel", function (e) { e.preventDefault() }, { passive: false })} )}
103
117
  {...(type ==='number' && { min: "0" })}
118
+ {...($aliasLabel && { $aliasLabel: $aliasLabel }) }
104
119
  {...parseProps} />
105
120
 
106
- return inputEl;
121
+ return (
122
+ $mode === 'currency' ? (
123
+ <InputWrapper>
124
+ {inputEl}
125
+ <InputLabel>{ $aliasLabel || '' }Rp</InputLabel>
126
+ </InputWrapper> ) : inputEl
127
+ )
107
128
  }
108
129
 
109
130
  export default InputComponent
@@ -0,0 +1,59 @@
1
+ import { type KeyboardEvent, type FocusEvent, type InputHTMLAttributes, type ClipboardEvent, forwardRef, useEffect } from 'react';
2
+ import { formatNumber } from '../../assets/javascripts/function';
3
+ import { InputContainer, InputLabel, InputWrapper } from './styles';
4
+
5
+ const InputWithRefComponent = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement> & { $mode?: string, $iconLeft?: boolean, $iconRight?: boolean, $isError?: boolean }>(({ $mode, $isError, $iconLeft, $iconRight, ...props }, ref) => {
6
+ const { type } = props;
7
+
8
+ const _evKeyUp = (e: KeyboardEvent<HTMLInputElement>) => {
9
+ if ($mode === 'currency') {
10
+ e.currentTarget.value = formatNumber(e.currentTarget.value);
11
+ }
12
+ }
13
+
14
+ const _evKeyPress = (e: KeyboardEvent<HTMLInputElement>) => {
15
+ const _target = e.target as HTMLInputElement;
16
+ if (type === 'number' || $mode === 'currency') {
17
+ if(!(!(isNaN(Number(e.key)) || typeof e.key === 'undefined' || e.key === ''))) e.preventDefault();
18
+ }
19
+ if ($mode === 'currency') {
20
+ if ((_target.value.length === 1 && e.key === '0' && _target.value === "0") || e.key === ' ') {
21
+ e.preventDefault();
22
+ } else {
23
+ return true;
24
+ }
25
+ } else {
26
+ return true;
27
+ }
28
+ }
29
+
30
+ const inputEl = <InputContainer
31
+ ref={ref}
32
+ $mode={$mode}
33
+ $isError={$isError}
34
+ $iconLeft={$iconLeft}
35
+ $iconRight={$iconRight}
36
+ onKeyUp={(e: KeyboardEvent<HTMLInputElement>) => {
37
+ _evKeyUp(e)
38
+ }}
39
+ {...((type ==='number' || $mode === 'currency') && { onKeyPress: _evKeyPress } )}
40
+ {...(type ==='number' && { onPaste: (e: ClipboardEvent<HTMLInputElement>) => {
41
+ const pasteVal = (e.clipboardData || (window as any).clipboardData).getData('text')
42
+ const _value = pasteVal.replace(/[^0-9]/g, '')
43
+ e.preventDefault()
44
+ document.execCommand('insertText', false, _value)
45
+ } })}
46
+ {...(type ==='number' && { onFocus: (e: FocusEvent<HTMLInputElement>) => e.target.addEventListener("wheel", function (e) { e.preventDefault() }, { passive: false })} )}
47
+ {...type ==='number' && { min: "0" }}
48
+ {...props} />
49
+
50
+ return (
51
+ $mode === 'currency' ? (
52
+ <InputWrapper>
53
+ {inputEl}
54
+ <InputLabel>Rp</InputLabel>
55
+ </InputWrapper> ) : inputEl
56
+ )
57
+ })
58
+
59
+ export default InputWithRefComponent
@@ -7,7 +7,8 @@ const SubmitStyles = css`
7
7
  color: var(--sec-clr);
8
8
  background-color: var(--act-clr-bg);
9
9
  `
10
- const getInputModifiedStyled = ({ width, height, $iconLeft, $iconRight, $isError, mode, type }:{ width?: string | number, height?: string | number, $iconLeft?: boolean, $iconRight?: boolean, $isError?: boolean, mode?: string, type?: string }) => {
10
+
11
+ const getInputModifiedStyled = ({ width, height, $iconLeft, $iconRight, $isError, $mode, type, $aliasLabel }:{ width?: string | number, height?: string | number, $iconLeft?: boolean, $iconRight?: boolean, $isError?: boolean, $mode?: string, type?: string, $aliasLabel?:string }) => {
11
12
  let style = ""
12
13
  if ($iconLeft) {
13
14
  style += `
@@ -30,7 +31,7 @@ const getInputModifiedStyled = ({ width, height, $iconLeft, $iconRight, $isError
30
31
  max-height: ${height}px
31
32
  `
32
33
  }
33
- if (mode === 'search') {
34
+ if ($mode === 'search') {
34
35
  style += `
35
36
  background-color: transparent;
36
37
  &, &:not([type="submit"]):focus, &:active, &:active:focus {
@@ -45,11 +46,16 @@ const getInputModifiedStyled = ({ width, height, $iconLeft, $iconRight, $isError
45
46
  `
46
47
  }
47
48
  }
48
- if (mode === 'transaction') {
49
+ if ($mode === 'transaction') {
49
50
  style += `
50
51
  padding-left: 45px;
51
52
  `
52
53
  }
54
+ if ($mode === 'currency') {
55
+ style += `
56
+ padding-left: ${$aliasLabel ? '38px' : '30px'} !important;
57
+ `
58
+ }
53
59
  if (width) {
54
60
  style += `
55
61
  width: ${width}px
@@ -61,10 +67,26 @@ const getInputModifiedStyled = ({ width, height, $iconLeft, $iconRight, $isError
61
67
  return style;
62
68
  }
63
69
 
64
- export const InputContainer = styled.input<{ width?: string | number, height?: string | number, $iconLeft?: boolean, $iconRight?: boolean, $isError?: boolean, mode?: string, type?: string }>`
70
+ export const InputContainer = styled.input<{ width?: string | number, height?: string | number, $iconLeft?: boolean, $iconRight?: boolean, $isError?: boolean, $mode?: string, type?: string }>`
65
71
  &._refQuantitiyInput {
66
72
  width: 55px;
67
73
  text-align: center;
68
74
  }
69
75
  ${getInputModifiedStyled}
76
+ `
77
+ export const InputWrapper = styled.div`
78
+ position: relative;
79
+ & ._refLoadingInput {
80
+ position: absolute;
81
+ top: 50%;
82
+ margin-top: -5px;
83
+ right: 10px;
84
+ }
85
+ `
86
+ export const InputLabel = styled.label`
87
+ position: absolute;
88
+ left: 10px;
89
+ top: 50%;
90
+ transform: translateY(-50%);
91
+ color: var(--mt-clr);
70
92
  `
@@ -0,0 +1,331 @@
1
+ import { useEffect, useState } from 'react';
2
+ import ReactSelect from 'react-select';
3
+ import type { SingleValueProps, OptionProps, StylesConfig, ActionMeta, ControlProps, MultiValueProps, OnChangeValue, CSSObjectWithLabel } from 'react-select';
4
+ import CreatableSelect from 'react-select/creatable';
5
+ import type { CSSObject } from '@emotion/serialize';
6
+ import { generateMessageQuestion } from '../../assets/javascripts/function';
7
+ import type { TState, TObject } from '../../typeds/base.typed';
8
+ import type { TMessageQuestionFunction } from '../message/typed';
9
+ import type { TOption } from './typed';
10
+
11
+ type TSelect = {
12
+ type?: string
13
+ mode?: string
14
+ isError?: boolean
15
+ name?: string
16
+ customOption?: (arg0: OptionProps) => void
17
+ customLabel?: (arg0: SingleValueProps) => void
18
+ MenuList?: any
19
+ isCreateable?: boolean
20
+ isClearable?: boolean
21
+ selectKey?: string
22
+ disabled?: boolean
23
+ width?: string | number
24
+ reset?: boolean
25
+ setReset?: TState<boolean>
26
+ isForceUpdate?: boolean
27
+ setForceUpdate?: TState<boolean>
28
+ isCheckAutoCopy?: boolean
29
+ isField?: boolean
30
+ isMulti?: boolean
31
+ evCreate?: (value: string) => void
32
+ evChange?: (newValue: OnChangeValue<TOption, boolean>, actionMeta?: ActionMeta<TOption>) => void
33
+ evChangeCustom? : (key: string, value: any) => void
34
+ defaultValue?: OnChangeValue<TOption, boolean>
35
+ options: TOption[] | null
36
+ isMinOption?: boolean
37
+ placeholder?: string
38
+ 'data-qa-id'?: string
39
+ removeMessage?: TObject
40
+ evCreateMessageQuestion?: TMessageQuestionFunction
41
+ }
42
+
43
+ const SelectComponent = ({ type, isError=false, mode, customOption, customLabel, MenuList, isCreateable=false, isClearable=false, selectKey, disabled, defaultValue, width, reset, setReset, isForceUpdate, setForceUpdate, isCheckAutoCopy, evChangeCustom, isField, evCreate, evChange, isMinOption, isMulti=false, options, name, placeholder, removeMessage, evCreateMessageQuestion, ...props }: TSelect) => {
44
+ const [valueState, setValue] = useState<typeof defaultValue>(defaultValue || null)
45
+
46
+ useEffect(()=> {
47
+ if (reset) {
48
+ setValue(null);
49
+ setReset && setReset(false);
50
+ }
51
+ if (isForceUpdate) {
52
+ let changeValue = defaultValue;
53
+ if (isCheckAutoCopy) {
54
+ if (changeValue) {
55
+ let isChanging = false;
56
+ if (isMulti) {
57
+ let _changeValue = changeValue as OnChangeValue<TOption, true>;
58
+ if (Array.isArray(_changeValue) && _changeValue.length) {
59
+ let newValue = [] as OnChangeValue<TOption, true>;
60
+ for (const _value of _changeValue) {
61
+ const optionFilter = options?.filter(opt => (opt.label === _value.label && opt.value === _value.value) );
62
+ if (optionFilter?.length && Array.isArray(newValue)) {
63
+ newValue.push(_value);
64
+ }
65
+ else {
66
+ !isChanging && (isChanging = true);
67
+ }
68
+ }
69
+ newValue.length && (_changeValue = newValue);
70
+ }
71
+ } else {
72
+ let _changeValue = changeValue as OnChangeValue<TOption, false>;
73
+ if (_changeValue) {
74
+ const optionFilter = options?.filter(opt => _changeValue && (opt.label === _changeValue.label && opt.value === _changeValue.value) );
75
+ if (optionFilter?.length) {
76
+ changeValue = null;
77
+ isChanging = true;
78
+ }
79
+ }
80
+ }
81
+ (isChanging && name) && evChangeCustom && evChangeCustom(name, changeValue);
82
+ }
83
+ }
84
+ setValue(changeValue);
85
+ setForceUpdate && setForceUpdate(false);
86
+ }
87
+ }, [defaultValue, evChangeCustom, isCheckAutoCopy, isForceUpdate, isMulti, name, options, reset, setForceUpdate, setReset])
88
+
89
+ const evToogleSelect = () => {
90
+ const containerRef = document.getElementsByClassName('_refContainer is-shown') as HTMLCollectionOf<HTMLElement>;
91
+ if (containerRef.length) {
92
+ for (let i = 0; i < containerRef.length; i++) {
93
+ containerRef[i].classList.remove('is-shown');
94
+ }
95
+ }
96
+ }
97
+
98
+ const handleChange = (value: OnChangeValue<TOption, typeof isMulti>, { action, removedValue, option }: any) => {
99
+ if (isMulti) {
100
+ const newValue = value as OnChangeValue<TOption, true>;
101
+ const removeCallback = () => {
102
+ setValue(newValue);
103
+ evChange && evChange(newValue, { action, removedValue, option });
104
+ }
105
+ switch (action) {
106
+ case 'remove-value':
107
+ if (isMinOption) {
108
+ if (action === 'remove-value' && (Array.isArray(valueState) && valueState.length === 1)) {
109
+ return false;
110
+ }
111
+ }
112
+ if (removedValue.isFixed) {
113
+ return;
114
+ }
115
+ break;
116
+ case 'pop-value':
117
+ if (removedValue.isFixed) {
118
+ return;
119
+ }
120
+ break;
121
+ case 'clear':
122
+ value = options?.filter((v) => v.isFixed) || [];
123
+ break;
124
+ default:
125
+ break;
126
+ }
127
+ if (removeMessage && action === 'remove-value') {
128
+ const _confirm_props = generateMessageQuestion('confirm', removeMessage?.title || '', removeMessage?.subtitle || '', removeCallback);
129
+ evCreateMessageQuestion && evCreateMessageQuestion(_confirm_props);
130
+ return false;
131
+ } else {
132
+ setValue(newValue);
133
+ evChange && evChange(newValue, { action, removedValue, option });
134
+ }
135
+ } else {
136
+ const newValue = value as OnChangeValue<TOption, false>;
137
+ mode === 'paymentReceiveStore' ? setValue(newValue ? { value: newValue.value, label : newValue.label, channel: newValue.channel } : newValue) : setValue(newValue ? { value: newValue.value, label : newValue.label } : newValue);
138
+ evChange && evChange(newValue, { action, removedValue, option });
139
+ }
140
+ (!isMulti && isField && evChangeCustom && name) && evChangeCustom(name, value);
141
+ }
142
+
143
+ const handleBlur = () => {
144
+ (isField && evChangeCustom && name && valueState) && evChangeCustom(name, valueState);
145
+ }
146
+
147
+ const handleCreate = (inputValue: string) => {
148
+ setReset && setReset(false);
149
+ if (isMulti) {
150
+ !Array.isArray(valueState) ? setValue([{ value: inputValue, label : inputValue }]) : setValue([...valueState, { value: inputValue, label : inputValue }]);
151
+ }
152
+ else {
153
+ setValue({ value: inputValue, label : inputValue });
154
+ }
155
+ evCreate && evCreate(inputValue);
156
+ }
157
+
158
+ const isValidNewOption = (inputValue: string, selectOptions: TOption[]) => {
159
+ return !(inputValue.trim().length === 0 || selectOptions.find(option => option.name === inputValue));
160
+ }
161
+
162
+ const customStyles: StylesConfig<TOption, typeof isMulti> = {
163
+ container: (provided: CSSObject) => ({
164
+ ...provided,
165
+ display: 'inline-block',
166
+ width: width ? width+'px' : '100%',
167
+ minHeight: '1px',
168
+ textAlign: 'left',
169
+ border: 'none',
170
+ } as CSSObjectWithLabel),
171
+ control: (provided: CSSObject, state:ControlProps<TOption, typeof isMulti>) => ({
172
+ ...provided,
173
+ borderRadius: mode === 'filter' ? 'var(--sec-rd)' : 'var(--ter-rd)',
174
+ minHeight: mode === 'picklist' ? '30px': '1px',
175
+ height: mode === 'orders' ? '90px' : '30px',
176
+ maxHeight: mode === 'picklist' ? '46px': 'none',
177
+ cursor: 'pointer',
178
+ borderWidth: '1px' ,
179
+ boxShadow: (state.isFocused && mode === 'filter') ? 'var(--act-shd-bx)' : 'none',
180
+ borderColor: ((state.isFocused && mode !== 'filter') && !isError) ? 'var(--pri-clr-ln__fc)' : (isError ? 'var(--err-clr-ln)' : (mode ==='filter' ? 'var(--ter-clr-ln)' : ' var(--ck-clr-ln)' )),
181
+ background: mode ==='filter' ? 'var(--ter-clr-ln)' : '',
182
+ overflow: mode === 'picklist' ? 'hidden': (mode === 'orders' ? 'auto' : 'initial'),
183
+ alignItems: mode === 'orders' ? 'start' : 'center',
184
+ padding: mode === 'orders' ? '6px 0' : 'unset',
185
+ '&:hover': {
186
+ borderColor: ((state.isFocused && mode !== 'filter') && !isError) ? 'var(--pri-clr-ln__fc)' : (isError ? 'var(--err-clr-ln)' : (mode ==='filter' ? 'var(--ter-clr-ln)' : ' var(--ck-clr-ln)' )),
187
+ }
188
+ } as CSSObjectWithLabel),
189
+ placeholder: (provided: CSSObject) => ({
190
+ ...provided,
191
+ fontStyle: 'italic'
192
+ } as CSSObjectWithLabel),
193
+ input: (provided: CSSObject) => ({
194
+ ...provided,
195
+ minHeight: '1px',
196
+ margin: '0 2px',
197
+ padding: '0',
198
+ 'input': {
199
+ boxShadow: 'none !important'
200
+ }
201
+ } as CSSObjectWithLabel),
202
+ dropdownIndicator: (provided: CSSObject) => ({
203
+ ...provided,
204
+ minHeight: '1px',
205
+ paddingTop: '0',
206
+ paddingBottom: '0',
207
+ paddingLeft: '2px',
208
+ paddingRight: '2px',
209
+ color: '#757575',
210
+ alignSelf: mode === 'orders' ? 'start' : 'unset',
211
+ } as CSSObjectWithLabel),
212
+ indicatorSeparator: (provided: CSSObject) => ({
213
+ ...provided,
214
+ minHeight: '1px',
215
+ height: '24px',
216
+ display: (type=== 'tag') ? 'block' : 'none'
217
+ } as CSSObjectWithLabel),
218
+ clearIndicator: (provided: CSSObject) => ({
219
+ ...provided,
220
+ minHeight: '1px',
221
+ marginRight: '-6px',
222
+ padding: '0'
223
+ } as CSSObjectWithLabel),
224
+ valueContainer: (provided: CSSObject) => ({
225
+ ...provided,
226
+ height: '30px',
227
+ maxHeight: mode === 'picklist' ? '46px': 'none',
228
+ minHeight: mode === 'picklist' ? '30px': '1px',
229
+ overflow: mode === 'picklist' ? 'auto': 'initial',
230
+ paddingTop: '0',
231
+ paddingBottom: '0',
232
+ paddingRight: '2px',
233
+ } as CSSObjectWithLabel),
234
+ singleValue: (provided: CSSObject) => ({
235
+ ...provided,
236
+ minHeight: '1px',
237
+ paddingBottom: '2px',
238
+ color: (disabled? '#ADADAD' : (mode === 'form' ? '#2d3c48' : 'initial')),
239
+ opacity: disabled ? '.7' : 1,
240
+ } as CSSObjectWithLabel),
241
+ option: (provided: CSSObject, state: OptionProps<TOption, typeof isMulti>) => ({
242
+ ...provided,
243
+ color: state.isSelected ? '#ffffff' : '#000000',
244
+ backgroundColor: state.isSelected || state.isFocused ? '#fc5c64' : 'transparent',
245
+ cursor: 'pointer',
246
+ '&:hover': {
247
+ backgroundColor: '#ec5b62',
248
+ color: '#ffffff'
249
+ }
250
+ } as CSSObjectWithLabel),
251
+ menu: (provided: CSSObject) => ({
252
+ ...provided,
253
+ borderRadius: mode === 'filter' ? 'var(--sec-rd)' : 'var(--ter-rd)',
254
+ } as CSSObjectWithLabel),
255
+ menuPortal: (provided: CSSObject) => ({
256
+ ...provided,
257
+ zIndex: 9999,
258
+ letterSpacing: 'normal',
259
+ lineHeight: 'normal',
260
+ } as CSSObjectWithLabel),
261
+ multiValue: (base: any, state: MultiValueProps<TOption, typeof isMulti>) => {
262
+ return state.data.isFixed ? { ...base, backgroundColor: 'gray' } : base
263
+ },
264
+ multiValueLabel: (base: any, state: MultiValueProps<TOption, typeof isMulti>) => {
265
+ return state.data.isFixed ? { ...base, fontWeight: 'bold', color: 'white', paddingRight: 6 } : base
266
+ },
267
+ multiValueRemove: (provided: CSSObject, state: MultiValueProps<TOption, typeof isMulti>) => ({
268
+ ...provided,
269
+ display: state.data.isFixed ? 'none' : 'block',
270
+ 'svg': {
271
+ position: 'relative',
272
+ top: '2px'
273
+ }
274
+ } as CSSObjectWithLabel),
275
+ }
276
+
277
+ let SelectEl = isCreateable ?
278
+ <CreatableSelect
279
+ options={options}
280
+ styles={customStyles}
281
+ onMenuOpen={evToogleSelect}
282
+ menuPortalTarget={document.body}
283
+ menuPosition='fixed'
284
+ menuPlacement='auto'
285
+ value={valueState}
286
+ onChange={handleChange}
287
+ // onInputChange={handleInputChange}
288
+ onCreateOption= {handleCreate}
289
+ isValidNewOption={isValidNewOption}
290
+ noOptionsMessage={() => null}
291
+ isClearable={isClearable ? ((Array.isArray(valueState) && valueState.length) ? valueState.some((v) => !v.isFixed) : true) : isClearable}
292
+ {...isMulti && { isMulti: true }}
293
+ {...customOption && { components: { Option: customOption } }}
294
+ {...MenuList && { components: { MenuList, Option: customOption } }}
295
+ {...selectKey && { key: selectKey }}
296
+ {...disabled && { isDisabled: disabled }}
297
+ {...isMulti && { closeMenuOnSelect: false }}
298
+ {...isMulti && { onBlur: handleBlur }}
299
+ {...placeholder && { placeholder }}
300
+ {...props} />
301
+ :
302
+ <ReactSelect
303
+ options={options}
304
+ styles={customStyles}
305
+ onMenuOpen={evToogleSelect}
306
+ menuPortalTarget={document.body}
307
+ menuPosition='fixed'
308
+ menuPlacement='auto'
309
+ value={valueState}
310
+ onChange={handleChange}
311
+ noOptionsMessage={() => null}
312
+ isClearable={isClearable ? ((Array.isArray(valueState) && valueState.length) ? valueState.some((v) => !v.isFixed) : true) : isClearable}
313
+ {...isMulti && { isMulti: true }}
314
+ {...customOption && { components: { Option: customOption } }}
315
+ {...mode === 'paymentReceiveStore' && { components: { Option: customOption, SingleValue: customLabel } }}
316
+ {...MenuList && { components: { MenuList, Option: customOption } }}
317
+ {...selectKey && { key: selectKey }}
318
+ {...disabled && { isDisabled: disabled }}
319
+ {...isMulti && { closeMenuOnSelect: false }}
320
+ {...isMulti && { onBlur: handleBlur }}
321
+ {...placeholder && { placeholder }}
322
+ {...props} />
323
+
324
+ return (
325
+ <section className='_refContainer' {...props}>
326
+ {SelectEl}
327
+ </section>
328
+ )
329
+ }
330
+
331
+ export default SelectComponent
@@ -0,0 +1,5 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const SelectCheckboxContainer = styled.section`
4
+ max-width: 530px;
5
+ `
@@ -0,0 +1,16 @@
1
+ import type { TChannel } from '../../typeds/shares.typed';
2
+
3
+ export type TOption = {
4
+ readonly value: any
5
+ readonly label: string
6
+ readonly name?: string
7
+ readonly isFixed?: boolean
8
+ readonly channel?: Omit<TChannel, 'stores'>
9
+ postalCode?: string
10
+ localId?: string
11
+ option?: {
12
+ readonly value: any
13
+ readonly label: string
14
+ localId?: string
15
+ }[]
16
+ }