forstok-ui-lib 7.1.0 → 7.2.1
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 +107 -6
- package/dist/index.js +651 -444
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +632 -425
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
- package/rollup.config.js +21 -1
- package/src/components/date/range.tsx +138 -0
- package/src/components/date/ref.tsx +109 -0
- package/src/components/date/{styles.tsx → styles.ts} +65 -1
- package/src/components/date/typed.ts +3 -0
- package/src/components/index.ts +6 -0
- package/src/components/select/all.tsx +2 -2
- package/src/components/select/asyncPaginate.tsx +273 -0
- package/src/components/select/function.ts +8 -0
- package/src/components/table/index.tsx +120 -0
- package/src/components/table/style.ts +178 -0
- package/src/components/table/type.ts +15 -0
- package/src/maps/common.ts +8 -2
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
|
+
import { AsyncPaginate } from 'react-select-async-paginate'
|
|
3
|
+
import type { LoadOptions } from 'react-select-async-paginate'
|
|
4
|
+
import { ActionMeta, ControlProps, CSSObjectWithLabel, GroupBase, OnChangeValue, OptionProps, StylesConfig } from 'react-select'
|
|
5
|
+
|
|
6
|
+
import type { CSSObject } from '@emotion/serialize'
|
|
7
|
+
import type { TState } from '../../typeds/base.typed'
|
|
8
|
+
import type { TLoadOption, TOption } from './typed'
|
|
9
|
+
|
|
10
|
+
type TSelect = {
|
|
11
|
+
type?: string
|
|
12
|
+
mode?: string
|
|
13
|
+
isError?: boolean
|
|
14
|
+
customOption?: (arg0: OptionProps) => void
|
|
15
|
+
MenuList?: any
|
|
16
|
+
reset?: boolean
|
|
17
|
+
setReset?: TState<boolean>
|
|
18
|
+
evChange?: (newValue: OnChangeValue<TOption, boolean>, actionMeta?: ActionMeta<TOption>) => void
|
|
19
|
+
defaultValue?: OnChangeValue<TOption, boolean>
|
|
20
|
+
loadOptions: LoadOptions<unknown, GroupBase<unknown>, unknown> | TLoadOption
|
|
21
|
+
loadOptionsOnMenuOpen?: boolean
|
|
22
|
+
noOptionsMessage?: ((obj: {
|
|
23
|
+
inputValue: string
|
|
24
|
+
}) => React.ReactNode)
|
|
25
|
+
isSearchable?: boolean
|
|
26
|
+
isClearable?: boolean
|
|
27
|
+
placeholder?: string
|
|
28
|
+
isMenuOpen?: boolean
|
|
29
|
+
setMenuIsOpen?: TState<boolean | undefined>
|
|
30
|
+
isForceUpdate?: boolean
|
|
31
|
+
setForceUpdate?: TState<boolean>
|
|
32
|
+
isMulti?: boolean
|
|
33
|
+
iconLeft?: boolean | string
|
|
34
|
+
loadedOptions?: TOption[]
|
|
35
|
+
'data-qa-id'?: string
|
|
36
|
+
evChangeOnMenuClose?: (value: OnChangeValue<TOption, boolean> | undefined) => void
|
|
37
|
+
id?: string
|
|
38
|
+
isDisabled?: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const SelectAsyncPaginateComponent = ({ loadOptions, ...props }: TSelect) => {
|
|
42
|
+
const {
|
|
43
|
+
isError=false,
|
|
44
|
+
mode,
|
|
45
|
+
type,
|
|
46
|
+
customOption,
|
|
47
|
+
MenuList,
|
|
48
|
+
defaultValue,
|
|
49
|
+
reset,
|
|
50
|
+
setReset,
|
|
51
|
+
evChange,
|
|
52
|
+
isForceUpdate,
|
|
53
|
+
setForceUpdate,
|
|
54
|
+
loadOptionsOnMenuOpen,
|
|
55
|
+
noOptionsMessage,
|
|
56
|
+
iconLeft,
|
|
57
|
+
isSearchable,
|
|
58
|
+
placeholder,
|
|
59
|
+
isMulti,
|
|
60
|
+
loadedOptions,
|
|
61
|
+
isMenuOpen,
|
|
62
|
+
setMenuIsOpen,
|
|
63
|
+
id,
|
|
64
|
+
evChangeOnMenuClose,
|
|
65
|
+
...rest
|
|
66
|
+
} = props
|
|
67
|
+
|
|
68
|
+
const [valueSelect, setValueSelect] = useState<typeof defaultValue>(defaultValue || null)
|
|
69
|
+
const [inputValue, setInputValue] = useState<string>("")
|
|
70
|
+
const [_time, setTime] = useState<Date>(new Date())
|
|
71
|
+
|
|
72
|
+
const selectRef = useRef<HTMLElement | null>(null)
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (isForceUpdate) {
|
|
76
|
+
setValueSelect(defaultValue || null)
|
|
77
|
+
setForceUpdate && setForceUpdate(false)
|
|
78
|
+
}
|
|
79
|
+
}, [defaultValue, isForceUpdate, setForceUpdate, setValueSelect])
|
|
80
|
+
|
|
81
|
+
const handleChange = (value: OnChangeValue<TOption, boolean>, actionMeta?: ActionMeta<TOption>) => {
|
|
82
|
+
const newValue = value as OnChangeValue<TOption, false>
|
|
83
|
+
if (actionMeta) {
|
|
84
|
+
const { action, option } = actionMeta
|
|
85
|
+
if (action === "select-option" && option?.value === '*') {
|
|
86
|
+
const newValueSelect = valueSelect as OnChangeValue<TOption, true>
|
|
87
|
+
if(newValueSelect?.length) {
|
|
88
|
+
let _newValue = loadedOptions ? [...newValueSelect, ...loadedOptions] : [...newValueSelect]
|
|
89
|
+
_newValue = _newValue.filter((_value, idx, self) => idx === self.findIndex((t) => (t.sku === _value.sku)))
|
|
90
|
+
setValueSelect(_newValue)
|
|
91
|
+
evChange && evChange(_newValue, actionMeta)
|
|
92
|
+
} else if (loadedOptions) {
|
|
93
|
+
setValueSelect(loadedOptions)
|
|
94
|
+
evChange && evChange(loadedOptions, actionMeta)
|
|
95
|
+
}
|
|
96
|
+
selectRef.current?.blur()
|
|
97
|
+
return false
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
setValueSelect(newValue)
|
|
101
|
+
evChange && evChange(newValue, actionMeta)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const customStyles: StylesConfig<TOption, boolean> = {
|
|
105
|
+
container: (provided: CSSObject) => ({
|
|
106
|
+
...provided,
|
|
107
|
+
display: 'inline-block',
|
|
108
|
+
width: '100%',
|
|
109
|
+
minHeight: '1px',
|
|
110
|
+
textAlign: 'left',
|
|
111
|
+
border: 'none',
|
|
112
|
+
} as CSSObjectWithLabel),
|
|
113
|
+
control: (provided: CSSObject, state: ControlProps<TOption, boolean>) => ({
|
|
114
|
+
...provided,
|
|
115
|
+
width: '100%',
|
|
116
|
+
borderRadius: '.5rem',
|
|
117
|
+
minHeight: '1px',
|
|
118
|
+
height: isMulti ? 'auto' : mode === 'small' ? '30px' : '32px',
|
|
119
|
+
cursor: 'pointer',
|
|
120
|
+
borderWidth: isError ? '1px' : '0',
|
|
121
|
+
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',
|
|
122
|
+
borderColor: ((state.isFocused && mode !== 'filter') && !isError) ? 'var(--pri-clr-ln__fc)' : (isError ? 'var(--err-clr-ln)' : (mode ==='filter' ? '#ffffff' : ' var(--ck-clr-ln)' )),
|
|
123
|
+
background: state.isFocused ? 'rgba(247, 247, 247, 1)' : '#ffffff',
|
|
124
|
+
overflow: mode === 'picklist' ? 'hidden': 'initial',
|
|
125
|
+
'&:hover': {
|
|
126
|
+
borderColor: ((state.isFocused && mode !== 'filter') && !isError) ? 'var(--pri-clr-ln__fc)' : (isError ? 'var(--err-clr-ln)' : (mode ==='filter' ? '#ffffff' : ' var(--ck-clr-ln)' )),
|
|
127
|
+
background: 'rgba(250, 250, 250, 1)',
|
|
128
|
+
color: 'rgba(48, 48, 48, 1)'
|
|
129
|
+
}
|
|
130
|
+
} as CSSObjectWithLabel),
|
|
131
|
+
placeholder: (provided: CSSObject) => ({
|
|
132
|
+
...provided,
|
|
133
|
+
fontStyle: 'italic'
|
|
134
|
+
} as CSSObjectWithLabel),
|
|
135
|
+
input: (provided: CSSObject) => ({
|
|
136
|
+
...provided,
|
|
137
|
+
minHeight: '1px',
|
|
138
|
+
margin: '0 2px',
|
|
139
|
+
padding: '0',
|
|
140
|
+
'input': {
|
|
141
|
+
boxShadow: 'none !important'
|
|
142
|
+
}
|
|
143
|
+
} as CSSObjectWithLabel),
|
|
144
|
+
singleValue: (provided: CSSObject) => ({
|
|
145
|
+
...provided,
|
|
146
|
+
minHeight: '1px',
|
|
147
|
+
paddingBottom: '2px',
|
|
148
|
+
color: 'initial',
|
|
149
|
+
} as CSSObjectWithLabel),
|
|
150
|
+
dropdownIndicator: (provided: CSSObject) => ({
|
|
151
|
+
...provided,
|
|
152
|
+
minHeight: '1px',
|
|
153
|
+
paddingTop: '0',
|
|
154
|
+
paddingBottom: '0',
|
|
155
|
+
paddingLeft: '2px',
|
|
156
|
+
paddingRight: '2px',
|
|
157
|
+
color: '#757575',
|
|
158
|
+
} as CSSObjectWithLabel),
|
|
159
|
+
indicatorSeparator: (provided: CSSObject) => ({
|
|
160
|
+
...provided,
|
|
161
|
+
minHeight: '1px',
|
|
162
|
+
height: '24px',
|
|
163
|
+
display: (type=== 'tag') ? 'block' : 'none'
|
|
164
|
+
} as CSSObjectWithLabel),
|
|
165
|
+
clearIndicator: (provided: CSSObject) => ({
|
|
166
|
+
...provided,
|
|
167
|
+
minHeight: '1px',
|
|
168
|
+
marginRight: '-6px',
|
|
169
|
+
padding: '0'
|
|
170
|
+
} as CSSObjectWithLabel),
|
|
171
|
+
valueContainer: (provided: CSSObject) => ({
|
|
172
|
+
...provided,
|
|
173
|
+
minHeight: '1px',
|
|
174
|
+
height: mode === 'multi-select' ? '70px' : mode === 'small' ? '30px' : '32px',
|
|
175
|
+
paddingTop: isMulti ? '4px' : '0',
|
|
176
|
+
paddingBottom: isMulti ? '4px' : '0',
|
|
177
|
+
paddingLeft: iconLeft ? '28px' : '8px',
|
|
178
|
+
paddingRight: '2px',
|
|
179
|
+
maxHeight: isMulti ? '60px' : 'unset',
|
|
180
|
+
overflow: isMulti ? 'auto' : 'initial',
|
|
181
|
+
alignContent: isMulti ? 'flex-start' : 'initial'
|
|
182
|
+
} as CSSObjectWithLabel),
|
|
183
|
+
option: (provided: CSSObject, state: OptionProps<TOption, boolean>) => ({
|
|
184
|
+
...provided,
|
|
185
|
+
color: state.isSelected ? '#ffffff' : '#000000',
|
|
186
|
+
backgroundColor: state.isSelected || state.isFocused ? '#fc5c64' : 'transparent',
|
|
187
|
+
cursor: 'pointer',
|
|
188
|
+
'&:hover': {
|
|
189
|
+
backgroundColor: '#ec5b62',
|
|
190
|
+
color: '#ffffff'
|
|
191
|
+
}
|
|
192
|
+
} as CSSObjectWithLabel),
|
|
193
|
+
menu: (provided: CSSObject) => ({
|
|
194
|
+
...provided,
|
|
195
|
+
borderRadius: '.75rem',
|
|
196
|
+
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)',
|
|
197
|
+
border: 'none'
|
|
198
|
+
} as CSSObjectWithLabel),
|
|
199
|
+
menuPortal: (provided: CSSObject) => ({
|
|
200
|
+
...provided,
|
|
201
|
+
zIndex: 9999,
|
|
202
|
+
letterSpacing: 'normal',
|
|
203
|
+
lineHeight: 'normal',
|
|
204
|
+
} as CSSObjectWithLabel)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const onMenuOpen = useCallback(() => {
|
|
208
|
+
setMenuIsOpen && setMenuIsOpen(true)
|
|
209
|
+
}, [setMenuIsOpen])
|
|
210
|
+
|
|
211
|
+
const onMenuClose = useCallback(() => {
|
|
212
|
+
setMenuIsOpen && setMenuIsOpen(false)
|
|
213
|
+
}, [setMenuIsOpen])
|
|
214
|
+
|
|
215
|
+
const evToogleSelect = () => {
|
|
216
|
+
const containerRef = document.getElementsByClassName('_refSelectContainer is-shown') as HTMLCollectionOf<HTMLElement>;
|
|
217
|
+
if (containerRef.length) {
|
|
218
|
+
for (let i = 0; i < containerRef.length; i++) {
|
|
219
|
+
containerRef[i].classList.remove('is-shown');
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const evReToogleSelect = () => {
|
|
225
|
+
setTime(new Date())
|
|
226
|
+
evToogleSelect()
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return <div className='_refContainer'>
|
|
230
|
+
<AsyncPaginate
|
|
231
|
+
isSearchable={isSearchable}
|
|
232
|
+
placeholder={placeholder}
|
|
233
|
+
debounceTimeout={500}
|
|
234
|
+
styles={customStyles}
|
|
235
|
+
loadOptions={loadOptions}
|
|
236
|
+
menuPortalTarget={document.body}
|
|
237
|
+
menuPosition='fixed'
|
|
238
|
+
menuPlacement='auto'
|
|
239
|
+
value={valueSelect}
|
|
240
|
+
onChange={handleChange}
|
|
241
|
+
loadOptionsOnMenuOpen={loadOptionsOnMenuOpen}
|
|
242
|
+
noOptionsMessage={noOptionsMessage}
|
|
243
|
+
menuIsOpen={isMenuOpen}
|
|
244
|
+
{...id && {id: id}}
|
|
245
|
+
{...mode === 'multi-select' && {
|
|
246
|
+
closeMenuOnSelect: false,
|
|
247
|
+
inputValue: inputValue,
|
|
248
|
+
onInputChange: (value, action) => {
|
|
249
|
+
if (action.action === "input-change") {
|
|
250
|
+
setInputValue(value)
|
|
251
|
+
setTime(new Date())
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
onMenuClose: () => {
|
|
255
|
+
setInputValue('');
|
|
256
|
+
evChangeOnMenuClose?.(valueSelect);
|
|
257
|
+
},
|
|
258
|
+
onMenuOpen: () => evReToogleSelect(),
|
|
259
|
+
cacheUniqs: [_time],
|
|
260
|
+
selectRef: selectRef
|
|
261
|
+
}}
|
|
262
|
+
{...mode !== 'multi-select' && {
|
|
263
|
+
onMenuOpen: onMenuOpen,
|
|
264
|
+
onMenuClose: onMenuClose
|
|
265
|
+
}}
|
|
266
|
+
{...customOption && { components: { Option: customOption } }}
|
|
267
|
+
{...MenuList && { components: { MenuList } }}
|
|
268
|
+
{...isMulti && { isMulti: true }}
|
|
269
|
+
{...rest} />
|
|
270
|
+
</div>
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export default SelectAsyncPaginateComponent
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const evToogleSelect = () => {
|
|
2
|
+
const containerRef = document.getElementsByClassName('_refContainer is-shown') as HTMLCollectionOf<HTMLElement>
|
|
3
|
+
if (containerRef.length) {
|
|
4
|
+
for (let i = 0; i < containerRef.length; i++) {
|
|
5
|
+
containerRef[i].classList.remove('is-shown')
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { isValidElement, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { TableContainer, TableHeadRow, TableHeadColumn, TableBodyRow, TableBodyColumn, TableFootRow, TableFootColumn, TableFinalRow, TableFinalColumn, TableBoldFootRow, TableBoldFootColumn } from './style'
|
|
4
|
+
|
|
5
|
+
import type { TTable } from './type'
|
|
6
|
+
|
|
7
|
+
const nameDefValue = `table_${new Date().getTime()}`
|
|
8
|
+
|
|
9
|
+
const TableComponent = (props: TTable) => {
|
|
10
|
+
const {
|
|
11
|
+
children,
|
|
12
|
+
$mode,
|
|
13
|
+
$name=nameDefValue,
|
|
14
|
+
$template,
|
|
15
|
+
isForceUpdate,
|
|
16
|
+
setForceUpdate
|
|
17
|
+
} = props
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (isForceUpdate) {
|
|
21
|
+
setForceUpdate && setForceUpdate(false)
|
|
22
|
+
}
|
|
23
|
+
}, [isForceUpdate, setForceUpdate])
|
|
24
|
+
|
|
25
|
+
const evGenerateEl = (part: string) => {
|
|
26
|
+
return children.filter(child => {
|
|
27
|
+
if (isValidElement(child)) {
|
|
28
|
+
return (child.props as any)['aria-label'] === part
|
|
29
|
+
} else {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const evGenerateChildrenArrEl = (childrenFilter: any) => {
|
|
36
|
+
let childrenArray: any[] = []
|
|
37
|
+
if (childrenFilter.length) {
|
|
38
|
+
if (childrenFilter[0].props.children.length > 1) {
|
|
39
|
+
let newArrayBodyChildren: any[] = []
|
|
40
|
+
childrenFilter[0].props.children.forEach((body: any) => {
|
|
41
|
+
let _bodyArray = Array.isArray(body) ? body : [].concat(body)
|
|
42
|
+
_bodyArray.forEach((_body: any) => {
|
|
43
|
+
newArrayBodyChildren.push(_body)
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
childrenArray = newArrayBodyChildren
|
|
47
|
+
} else {
|
|
48
|
+
childrenArray = Array.isArray(childrenFilter[0].props.children) ? childrenFilter[0].props.children : [].concat(childrenFilter[0].props.children)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return childrenArray
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const HeadChildrenFilter = evGenerateEl('head')
|
|
55
|
+
const TableHeadEl = (HeadChildrenFilter && isValidElement(HeadChildrenFilter[0])) ? (HeadChildrenFilter[0] as any).props.children.filter((head: any) => head !== null).map((head: any, index: number) =>
|
|
56
|
+
<TableHeadColumn
|
|
57
|
+
key={index}
|
|
58
|
+
role='columnheader'
|
|
59
|
+
{...head.props.style && {style: head.props.style}}
|
|
60
|
+
{...head.props.className && {className: head.props.className}}
|
|
61
|
+
{...head.props}
|
|
62
|
+
>{head.props.children}</TableHeadColumn>) : null
|
|
63
|
+
|
|
64
|
+
const BodyChildrenFilter = evGenerateEl('body')
|
|
65
|
+
const BodyChildrenArray = BodyChildrenFilter.length ? evGenerateChildrenArrEl(BodyChildrenFilter) : null
|
|
66
|
+
const TableBodyEl = BodyChildrenArray ? BodyChildrenArray.map((body: any, index: number) =>
|
|
67
|
+
<TableBodyRow
|
|
68
|
+
key={index}
|
|
69
|
+
role='row'
|
|
70
|
+
{...body.props?.id && {id: body.props.id}}
|
|
71
|
+
{...body.props?.className && {className: body.props.className}}
|
|
72
|
+
>
|
|
73
|
+
{body.props.children.filter((child: any) => child !== null).map((child: any, indexChild: number) =>
|
|
74
|
+
<TableBodyColumn key={indexChild} {...child.props}>{child.props.children}</TableBodyColumn>
|
|
75
|
+
)}
|
|
76
|
+
</TableBodyRow>) : null
|
|
77
|
+
|
|
78
|
+
const FootChildrenFilter = evGenerateEl('foot')
|
|
79
|
+
const FootChildrenArray = FootChildrenFilter.length ? evGenerateChildrenArrEl(FootChildrenFilter) : null
|
|
80
|
+
const TableFootEl = FootChildrenArray ? FootChildrenArray.map((foot: any, index: number) =>
|
|
81
|
+
<TableFootRow key={index} role='row'>
|
|
82
|
+
{foot.props.children.filter((child: any) => child !== null).map((child: any, indexChild: number) =>
|
|
83
|
+
<TableFootColumn key={indexChild} {...child.props}>{child.props.children}</TableFootColumn>
|
|
84
|
+
)}
|
|
85
|
+
</TableFootRow>) : null
|
|
86
|
+
|
|
87
|
+
const BoldFootChildrenFilter = evGenerateEl('boldFoot')
|
|
88
|
+
const BoldFootChildrenArray = BoldFootChildrenFilter.length ? evGenerateChildrenArrEl(BoldFootChildrenFilter) : null
|
|
89
|
+
const TableBoldFootEl = BoldFootChildrenArray ? BoldFootChildrenArray.map((boldFoot: any, index: number) =>
|
|
90
|
+
<TableBoldFootRow key={index} role='row'>
|
|
91
|
+
{boldFoot.props.children.filter((child: any) => child !== null).map((child: any, indexChild: number) =>
|
|
92
|
+
<TableBoldFootColumn key={indexChild} {...child.props}>{child.props.children}</TableBoldFootColumn>
|
|
93
|
+
)}
|
|
94
|
+
</TableBoldFootRow>) : null
|
|
95
|
+
|
|
96
|
+
const FinalChildrenFilter = evGenerateEl('final')
|
|
97
|
+
const FinalChildrenArray = FinalChildrenFilter.length ? evGenerateChildrenArrEl(FinalChildrenFilter) : null
|
|
98
|
+
const TableFinalEl = (FinalChildrenArray) ? FinalChildrenArray.map((finalFoot: any, index: number) =>
|
|
99
|
+
<TableFinalRow key={index} role='row'>
|
|
100
|
+
{finalFoot.props.children.filter((child: any) => child !== null).map((child: any, indexChild: number) =>
|
|
101
|
+
<TableFinalColumn key={indexChild} {...child.props}>{child.props.children}</TableFinalColumn>)}
|
|
102
|
+
</TableFinalRow>) : null
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<TableContainer
|
|
106
|
+
$mode={$mode}
|
|
107
|
+
$name={$name}
|
|
108
|
+
$template={$template}
|
|
109
|
+
role='table'
|
|
110
|
+
>
|
|
111
|
+
<TableHeadRow role='rowheader'>{TableHeadEl}</TableHeadRow>
|
|
112
|
+
{TableBodyEl}
|
|
113
|
+
{TableFootEl && TableFootEl}
|
|
114
|
+
{TableBoldFootEl && TableBoldFootEl}
|
|
115
|
+
{TableFinalEl && TableFinalEl}
|
|
116
|
+
</TableContainer>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export default TableComponent
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
|
|
3
|
+
import type { TableMode, TTable } from './type'
|
|
4
|
+
|
|
5
|
+
type TTableStyle = Omit<TTable, 'children'>
|
|
6
|
+
|
|
7
|
+
const TableBaseStyles = css`
|
|
8
|
+
display: grid;
|
|
9
|
+
justify-items: start;
|
|
10
|
+
`
|
|
11
|
+
export const TableHeadRow = styled.section`
|
|
12
|
+
${TableBaseStyles}
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
font-weight: 600;
|
|
15
|
+
letter-spacing: 0.3px;
|
|
16
|
+
background-color: var(--sec-clr-bg);
|
|
17
|
+
border: 1px solid var(--sec-clr-ln);
|
|
18
|
+
border-left: 0;
|
|
19
|
+
border-right: 0;
|
|
20
|
+
border-top: 0;
|
|
21
|
+
align-items: end;
|
|
22
|
+
color: var(--mt-clr);
|
|
23
|
+
> div {
|
|
24
|
+
padding-top: 8px !important;
|
|
25
|
+
padding-bottom: 8px !important;
|
|
26
|
+
}
|
|
27
|
+
`
|
|
28
|
+
|
|
29
|
+
export const TableHeadColumn = styled.div``
|
|
30
|
+
|
|
31
|
+
export const TableBodyRow = styled.section`
|
|
32
|
+
${TableBaseStyles}
|
|
33
|
+
border-bottom: 1px solid var(--pri-clr-ln);
|
|
34
|
+
`
|
|
35
|
+
|
|
36
|
+
const TableColumnStyles = css`
|
|
37
|
+
display: inline-grid;
|
|
38
|
+
grid-auto-flow: column;
|
|
39
|
+
align-items: center;
|
|
40
|
+
grid-gap: 6px;
|
|
41
|
+
padding: 12px 15px;
|
|
42
|
+
width: 100%;
|
|
43
|
+
justify-content: left;
|
|
44
|
+
b {
|
|
45
|
+
display: inline;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
text-overflow: ellipsis;
|
|
49
|
+
text-transform: capitalize;
|
|
50
|
+
font-weight: 400;
|
|
51
|
+
}
|
|
52
|
+
`
|
|
53
|
+
export const TableBodyColumn = styled.div`
|
|
54
|
+
${TableColumnStyles}
|
|
55
|
+
`
|
|
56
|
+
|
|
57
|
+
export const TableFootRow = styled.section`
|
|
58
|
+
${TableBaseStyles}
|
|
59
|
+
`
|
|
60
|
+
|
|
61
|
+
export const TableFootColumn = styled.div`
|
|
62
|
+
${TableColumnStyles}
|
|
63
|
+
`
|
|
64
|
+
|
|
65
|
+
export const TableBoldFootRow = styled.section`
|
|
66
|
+
${TableBaseStyles}
|
|
67
|
+
&, span {
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
}
|
|
70
|
+
`
|
|
71
|
+
|
|
72
|
+
export const TableBoldFootColumn = styled.div`
|
|
73
|
+
${TableColumnStyles}
|
|
74
|
+
`
|
|
75
|
+
|
|
76
|
+
export const TableFinalRow = styled.section`
|
|
77
|
+
${TableBaseStyles}
|
|
78
|
+
`
|
|
79
|
+
|
|
80
|
+
export const TableFinalColumn = styled.div`
|
|
81
|
+
${TableColumnStyles}
|
|
82
|
+
`
|
|
83
|
+
|
|
84
|
+
const modeStyles = {
|
|
85
|
+
widersmall: css`
|
|
86
|
+
${TableHeadRow},
|
|
87
|
+
${TableBodyRow},
|
|
88
|
+
${TableBoldFootRow},
|
|
89
|
+
${TableFootRow} {
|
|
90
|
+
grid-template-columns: auto max-content;
|
|
91
|
+
}
|
|
92
|
+
`,
|
|
93
|
+
custom: css`
|
|
94
|
+
${TableBodyColumn} {
|
|
95
|
+
grid-auto-flow: column;
|
|
96
|
+
}
|
|
97
|
+
${TableFootColumn},
|
|
98
|
+
${TableBoldFootColumn} {
|
|
99
|
+
span {
|
|
100
|
+
overflow-wrap: anywhere;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
${TableFootRow} {
|
|
104
|
+
&:last-child {
|
|
105
|
+
& ${TableFootColumn} {
|
|
106
|
+
padding-bottom: 12px;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`
|
|
111
|
+
} as const
|
|
112
|
+
const getTableModifiedStyled = ({ $mode, $template }: TTableStyle) => css`
|
|
113
|
+
${$mode && modeStyles[$mode]}
|
|
114
|
+
|
|
115
|
+
${($mode === 'custom' && $template) && css`
|
|
116
|
+
${TableHeadRow},
|
|
117
|
+
${TableBodyRow},
|
|
118
|
+
${TableFootRow},
|
|
119
|
+
${TableBoldFootRow},
|
|
120
|
+
${TableFinalRow} {
|
|
121
|
+
grid-template-columns: ${$template};
|
|
122
|
+
justify-content: space-between;
|
|
123
|
+
grid-gap: 5px;
|
|
124
|
+
> div {
|
|
125
|
+
padding: 10px 0;
|
|
126
|
+
&:first-child {
|
|
127
|
+
padding-left: 5px;
|
|
128
|
+
}
|
|
129
|
+
&:last-child {
|
|
130
|
+
padding-right: 5px;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
@media only screen and (min-width: 1280px) {
|
|
134
|
+
grid-gap: 10px;
|
|
135
|
+
> div {
|
|
136
|
+
&:first-child {
|
|
137
|
+
padding-left: 10px;
|
|
138
|
+
}
|
|
139
|
+
&:last-child {
|
|
140
|
+
padding-right: 10px;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
`}
|
|
146
|
+
`
|
|
147
|
+
export const TableContainer = styled.section<{ $mode: TableMode, $name: string, $template?: string }>`
|
|
148
|
+
display: inline-grid;
|
|
149
|
+
width: 100%;
|
|
150
|
+
${TableHeadRow},
|
|
151
|
+
${TableBodyRow},
|
|
152
|
+
${TableFootRow},
|
|
153
|
+
${TableBoldFootRow},
|
|
154
|
+
${TableFinalRow} {
|
|
155
|
+
grid-gap: 5px;
|
|
156
|
+
> div {
|
|
157
|
+
padding: 10px 0;
|
|
158
|
+
&:first-child {
|
|
159
|
+
padding-left: 5px;
|
|
160
|
+
}
|
|
161
|
+
&:last-child {
|
|
162
|
+
padding-right: 5px;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
@media only screen and (min-width: 1280px) {
|
|
166
|
+
grid-gap: 10px;
|
|
167
|
+
> div {
|
|
168
|
+
&:first-child {
|
|
169
|
+
padding-left: 10px;
|
|
170
|
+
}
|
|
171
|
+
&:last-child {
|
|
172
|
+
padding-right: 10px;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
${getTableModifiedStyled}
|
|
178
|
+
`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react'
|
|
2
|
+
import { TState } from '../../typeds/base.typed'
|
|
3
|
+
|
|
4
|
+
export type TableMode =
|
|
5
|
+
| 'widersmall'
|
|
6
|
+
| 'custom'
|
|
7
|
+
|
|
8
|
+
export type TTable = HTMLAttributes<HTMLElement> & {
|
|
9
|
+
children: ReactNode[]
|
|
10
|
+
$mode: TableMode
|
|
11
|
+
$name?: string
|
|
12
|
+
$template?: string
|
|
13
|
+
isForceUpdate?: boolean
|
|
14
|
+
setForceUpdate?: TState<boolean>
|
|
15
|
+
}
|
package/src/maps/common.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
1
|
+
import moment, { Moment } from 'moment';
|
|
2
2
|
|
|
3
3
|
export const configDateRange = {
|
|
4
4
|
rangeDate: 'lastsecondweek',
|
|
@@ -6,4 +6,10 @@ export const configDateRange = {
|
|
|
6
6
|
endDate: moment().clone().format('YYYY-MM-DD') as string,
|
|
7
7
|
placeholder: 'Last 14 days',
|
|
8
8
|
minDate: moment().clone().subtract(89, 'days').format('YYYY-MM-DD') as string
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const configDateRangeAnt = {
|
|
12
|
+
startDate: moment().clone().subtract(13, 'days') as Moment,
|
|
13
|
+
endDate: moment().clone() as Moment,
|
|
14
|
+
minDate: moment().clone().subtract(89, 'days') as Moment
|
|
15
|
+
};
|