@fixefy/fixefy-ui-components 0.0.42 → 0.0.44
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 +7 -7
- package/.prettierrc.json +0 -10
- package/.swcrc +0 -20
- package/src/FxActionsTray/FxActionsTray.tsx +0 -293
- package/src/FxActionsTray/actions_tray_types.d.ts +0 -15
- package/src/FxActionsTray/index.ts +0 -3
- package/src/FxActionsTray/styles/actions_tray.styles.tsx +0 -90
- package/src/FxAggregationsBar/FxAggregations.tsx +0 -32
- package/src/FxAggregationsBar/aggregations_types.d.ts +0 -21
- package/src/FxAggregationsBar/helpers/structureReader.tsx +0 -66
- package/src/FxAggregationsBar/index.ts +0 -2
- package/src/FxAggregationsBar/operations/query.ts +0 -64
- package/src/FxAsyncDropdown/FxAsyncDropdown.tsx +0 -362
- package/src/FxAsyncDropdown/async_dropdown_types.d.ts +0 -40
- package/src/FxAsyncDropdown/helpers/helpers.ts +0 -105
- package/src/FxAsyncDropdown/index.ts +0 -2
- package/src/FxAsyncDropdown/styles/dropdown.styles.tsx +0 -162
- package/src/FxAvatar/FxAvatar.tsx +0 -50
- package/src/FxAvatar/avatar_types.d.ts +0 -11
- package/src/FxAvatar/helpers/stringToColor.ts +0 -16
- package/src/FxAvatar/index.ts +0 -2
- package/src/FxAvatar/styles/avatar.styles.tsx +0 -82
- package/src/FxButton/FxButton.tsx +0 -11
- package/src/FxButton/index.ts +0 -2
- package/src/FxButton/styles/button.styles.jsx +0 -16
- package/src/FxButton/styles/button.styles.tsx +0 -14
- package/src/FxChip/FxChip.tsx +0 -14
- package/src/FxChip/chip_types.d.ts +0 -34
- package/src/FxChip/index.ts +0 -2
- package/src/FxChip/styles/chip.styles.tsx +0 -51
- package/src/FxIcon/FxIcon.tsx +0 -34
- package/src/FxIcon/content/dynamic_icon.tsx +0 -3
- package/src/FxIcon/content/index.ts +0 -2
- package/src/FxIcon/content/lazy_icon.tsx +0 -48
- package/src/FxIcon/icon_types.d.ts +0 -10
- package/src/FxIcon/index.ts +0 -2
- package/src/FxModal/FxModal.tsx +0 -44
- package/src/FxModal/index.ts +0 -2
- package/src/FxModal/modal_types.d.ts +0 -10
- package/src/FxModal/styles/modal.style.tsx +0 -40
- package/src/FxNotes/FxNotes.tsx +0 -165
- package/src/FxNotes/helpers/stringToColor.ts +0 -19
- package/src/FxNotes/index.ts +0 -2
- package/src/FxNotes/note_types.d.ts +0 -12
- package/src/FxNotes/operations/queries.ts +0 -21
- package/src/FxNotes/styles/notes.styles.tsx +0 -135
- package/src/FxNumberField/FxNumberField.tsx +0 -37
- package/src/FxNumberField/index.ts +0 -2
- package/src/FxNumberField/number_field_types.d.ts +0 -7
- package/src/FxNumberField/styles/number_field.styles.ts +0 -85
- package/src/FxProgressCircle/FxProgressCircle.tsx +0 -40
- package/src/FxProgressCircle/index.ts +0 -2
- package/src/FxProgressCircle/progress_circle_types.d.ts +0 -9
- package/src/FxProgressCircle/styles/progress_circle.styles.tsx +0 -33
- package/src/FxProgressCounter/ProgressCounter.tsx +0 -81
- package/src/FxProgressCounter/index.ts +0 -2
- package/src/FxProgressCounter/progress_counter_types.d.ts +0 -10
- package/src/FxProgressCounter/styles/progress_counter.styles.ts +0 -40
- package/src/FxScore/FxScore.tsx +0 -75
- package/src/FxScore/index.ts +0 -2
- package/src/FxScore/score_types.d.ts +0 -16
- package/src/FxScore/styles/score.styles.ts +0 -42
- package/src/FxShowMore/FxShowMore.tsx +0 -60
- package/src/FxShowMore/index.ts +0 -2
- package/src/FxShowMore/show_more_types.d.ts +0 -8
- package/src/FxShowMore/styles/show_more.styles.ts +0 -67
- package/src/FxSlider/FxSlider.tsx +0 -8
- package/src/FxSlider/index.ts +0 -2
- package/src/FxSlider/slider_types.d.ts +0 -3
- package/src/FxStatisticsBar/FxStatisticsBar.tsx +0 -112
- package/src/FxStatisticsBar/index.ts +0 -2
- package/src/FxStatisticsBar/statistics_bar_types.d.ts +0 -8
- package/src/FxStatisticsBar/styles/statistics.styles.ts +0 -41
- package/src/FxStatusBar/FxStatusBar.tsx +0 -66
- package/src/FxStatusBar/helpers/constants.ts +0 -12
- package/src/FxStatusBar/index.ts +0 -2
- package/src/FxStatusBar/status_bar_types.d.ts +0 -14
- package/src/FxStatusBar/styles/statusBar.styles.tsx +0 -67
- package/src/FxStyledComponents/index.tsx +0 -196
- package/src/FxTag/FxTag.tsx +0 -14
- package/src/FxTag/fxtag_types.d.ts +0 -4
- package/src/FxTag/index.ts +0 -2
- package/src/FxTag/styles/tag.styles.tsx +0 -24
- package/src/FxTextField/FxTextField.tsx +0 -117
- package/src/FxTextField/index.ts +0 -2
- package/src/FxTextField/text_field_types.d.ts +0 -20
- package/src/FxTodo/FxTodo.tsx +0 -58
- package/src/FxTodo/index.ts +0 -2
- package/src/FxTodo/styles/todo.styles.tsx +0 -113
- package/src/FxTodo/todo_types.d.ts +0 -19
- package/src/FxWizard/FxWizard.tsx +0 -56
- package/src/FxWizard/WizardContext.tsx +0 -108
- package/src/FxWizard/index.ts +0 -3
- package/src/FxWizard/styles/wizard.styles.tsx +0 -22
- package/src/FxWizard/wizard_types.d.ts +0 -37
- package/src/index.ts +0 -23
- package/tsconfig.json +0 -22
- package/webpack.config.js +0 -35
- package/yarn-error.log +0 -95
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
// @ts-ignore
|
|
2
|
-
import _ from 'lodash'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
Close as CloseIcon,
|
|
6
|
-
CheckBox as CheckBoxIcon,
|
|
7
|
-
CheckBoxOutlineBlank as CheckBoxOutlineBlankIcon,
|
|
8
|
-
KeyboardArrowDown as ArrowIcon,
|
|
9
|
-
} from '@mui/icons-material'
|
|
10
|
-
|
|
11
|
-
import { gql } from 'graphql-tag'
|
|
12
|
-
// import { getJPart } from './helpers/helpers'
|
|
13
|
-
import { useLazyQuery } from '@apollo/client'
|
|
14
|
-
import { titleCase } from '@fixefy/fixefy-ui-utils'
|
|
15
|
-
import React, { useEffect, useState, useRef, useImperativeHandle } from 'react'
|
|
16
|
-
import { Button, Checkbox, CircularProgress, useAutocomplete, useTheme, Typography } from '@mui/material'
|
|
17
|
-
|
|
18
|
-
import { Root, InputWrapper, Listbox, StyledClose, StyledListBox, Loading } from './styles/dropdown.styles'
|
|
19
|
-
|
|
20
|
-
import { AsyncDropdownPropsType, Option } from './async_dropdown_types'
|
|
21
|
-
|
|
22
|
-
const icon = <CheckBoxOutlineBlankIcon fontSize='small' />
|
|
23
|
-
const checkedIcon = <CheckBoxIcon fontSize='small' />
|
|
24
|
-
|
|
25
|
-
export const FxAsyncDropdown = React.forwardRef((props: AsyncDropdownPropsType, parentRef) => {
|
|
26
|
-
const ref = useRef(null)
|
|
27
|
-
const theme = useTheme()
|
|
28
|
-
|
|
29
|
-
const [options, setOptions] = useState<Option[]>([])
|
|
30
|
-
const [loadingData, setLoadingData] = useState(false)
|
|
31
|
-
const [isLastPage, setIsLastPage] = useState(false)
|
|
32
|
-
const [searchValue, setSearchValue] = useState<string | null>(null)
|
|
33
|
-
const [hasClearBtn, setHasClearBtn] = useState(false)
|
|
34
|
-
const [page, setPage] = useState(1)
|
|
35
|
-
const [prevPage, setPrevPage] = useState(0)
|
|
36
|
-
const [pageSize] = useState(20)
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
debug,
|
|
40
|
-
structure,
|
|
41
|
-
onChange,
|
|
42
|
-
onClear,
|
|
43
|
-
renderOptions,
|
|
44
|
-
fetcher,
|
|
45
|
-
initialValue = {},
|
|
46
|
-
multiple,
|
|
47
|
-
disabled,
|
|
48
|
-
type = 'text',
|
|
49
|
-
showSelectedValue,
|
|
50
|
-
...rest
|
|
51
|
-
} = props
|
|
52
|
-
|
|
53
|
-
const { name, extended, children } = structure
|
|
54
|
-
|
|
55
|
-
const { search_path, variables } = extended
|
|
56
|
-
const { method_name } = variables
|
|
57
|
-
|
|
58
|
-
const [fetch, { data, loading }] = useLazyQuery(gql(fetcher.query), {
|
|
59
|
-
...fetcher.queryOptions,
|
|
60
|
-
variables: {
|
|
61
|
-
...fetcher.queryOptions.variables,
|
|
62
|
-
where: searchValue
|
|
63
|
-
? {
|
|
64
|
-
...fetcher.queryOptions.variables.where,
|
|
65
|
-
[search_path]: searchValue,
|
|
66
|
-
}
|
|
67
|
-
: {
|
|
68
|
-
...fetcher.queryOptions.variables.where,
|
|
69
|
-
},
|
|
70
|
-
skip: page * pageSize - pageSize,
|
|
71
|
-
limit: pageSize,
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const labelOption = structure?.extended?.title_path ?? ('title' as keyof Option)
|
|
76
|
-
|
|
77
|
-
const {
|
|
78
|
-
getRootProps,
|
|
79
|
-
getInputProps,
|
|
80
|
-
getClearProps,
|
|
81
|
-
getListboxProps,
|
|
82
|
-
getOptionProps,
|
|
83
|
-
groupedOptions,
|
|
84
|
-
value,
|
|
85
|
-
popupOpen,
|
|
86
|
-
focused,
|
|
87
|
-
setAnchorEl,
|
|
88
|
-
} = useAutocomplete({
|
|
89
|
-
...rest,
|
|
90
|
-
defaultValue: initialValue,
|
|
91
|
-
options: options,
|
|
92
|
-
disableCloseOnSelect: !!multiple,
|
|
93
|
-
multiple,
|
|
94
|
-
disabled: disabled,
|
|
95
|
-
isOptionEqualToValue: (option: any, value: any) => {
|
|
96
|
-
return option._id === value._id
|
|
97
|
-
},
|
|
98
|
-
getOptionLabel: (option: Option) => titleCase(option[labelOption] ?? (option.title as any)),
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
const onPopupScroll = _.debounce(() => {
|
|
102
|
-
if (ref && ref.current) {
|
|
103
|
-
//@ts-ignore
|
|
104
|
-
const threshHold = ref.current.scrollHeight / 2
|
|
105
|
-
|
|
106
|
-
//@ts-ignore
|
|
107
|
-
if (ref.current.scrollTop > threshHold && !loadingData && !isLastPage) {
|
|
108
|
-
setLoadingData(true)
|
|
109
|
-
setPage((prevPage) => prevPage + 1)
|
|
110
|
-
setPrevPage((prevPage) => prevPage + 1)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}, 800)
|
|
114
|
-
|
|
115
|
-
const createTitle = () => {
|
|
116
|
-
if (Array.isArray(value)) {
|
|
117
|
-
if (value && value.length) {
|
|
118
|
-
return `${titleCase(name)} (${value.length})`
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return titleCase(name)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const handleSearch = _.debounce((e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => {
|
|
125
|
-
setSearchValue(e.target.value)
|
|
126
|
-
setPage(1)
|
|
127
|
-
}, 300)
|
|
128
|
-
|
|
129
|
-
const handleChildrens = ({ structure, ...rest }: { structure: any; onClick: (e: any) => void; startIcon: any }) => {
|
|
130
|
-
let rv = null
|
|
131
|
-
const { type, children } = structure
|
|
132
|
-
debug === true && console.log('handleChildrens', structure)
|
|
133
|
-
switch (type) {
|
|
134
|
-
case 'dropdownOptions':
|
|
135
|
-
case 'dropdown_options': {
|
|
136
|
-
rv = children.map((child: any) =>
|
|
137
|
-
handleChildrens({
|
|
138
|
-
structure: child,
|
|
139
|
-
...rest,
|
|
140
|
-
}),
|
|
141
|
-
)
|
|
142
|
-
break
|
|
143
|
-
}
|
|
144
|
-
case 'clear': {
|
|
145
|
-
if (!hasClearBtn) {
|
|
146
|
-
setHasClearBtn(true)
|
|
147
|
-
}
|
|
148
|
-
rv = <Button {...rest}>{structure.title}</Button>
|
|
149
|
-
break
|
|
150
|
-
}
|
|
151
|
-
default: {
|
|
152
|
-
break
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return rv
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const handleRenderOptions = () => {
|
|
160
|
-
debug === true && console.log('renderOptions: ', renderOptions)
|
|
161
|
-
|
|
162
|
-
if (renderOptions) {
|
|
163
|
-
return (groupedOptions as typeof options).map((option: Option, index: number) => {
|
|
164
|
-
const CustomeComponent = renderOptions(option, index)
|
|
165
|
-
//@ts-ignore
|
|
166
|
-
return React.cloneElement(CustomeComponent, {
|
|
167
|
-
...getOptionProps({ option, index }),
|
|
168
|
-
})
|
|
169
|
-
})
|
|
170
|
-
} else {
|
|
171
|
-
switch (type) {
|
|
172
|
-
case 'checkbox': {
|
|
173
|
-
return (groupedOptions as typeof options).map((option: Option, index: number) => {
|
|
174
|
-
const isSelected = getOptionProps({
|
|
175
|
-
option,
|
|
176
|
-
index,
|
|
177
|
-
})['aria-selected']
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<li {...getOptionProps({ option, index })}>
|
|
181
|
-
<Checkbox
|
|
182
|
-
icon={icon}
|
|
183
|
-
checked={Boolean(isSelected)}
|
|
184
|
-
checkedIcon={checkedIcon}
|
|
185
|
-
sx={{
|
|
186
|
-
mr: 1,
|
|
187
|
-
minWidth: 24,
|
|
188
|
-
minHeight: 24,
|
|
189
|
-
p: 0,
|
|
190
|
-
['& svg']: { fill: theme.palette.primary.light },
|
|
191
|
-
}}
|
|
192
|
-
/>
|
|
193
|
-
<Typography variant='table' color={theme.palette.typography.title}>
|
|
194
|
-
{titleCase(option?.title)}
|
|
195
|
-
</Typography>
|
|
196
|
-
</li>
|
|
197
|
-
)
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
case 'text': {
|
|
202
|
-
return (groupedOptions as typeof options).map((option: Option, index: number) => {
|
|
203
|
-
debug === true &&
|
|
204
|
-
console.log(
|
|
205
|
-
'renderOptions: ',
|
|
206
|
-
structure?.extended?.title_path,
|
|
207
|
-
option[structure?.extended?.title_path],
|
|
208
|
-
options,
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
return (
|
|
212
|
-
<li {...getOptionProps({ option, index })}>
|
|
213
|
-
<Typography variant='table' color={theme.palette.typography.title}>
|
|
214
|
-
{titleCase(option[structure?.extended?.title_path] ?? option.title)}
|
|
215
|
-
</Typography>
|
|
216
|
-
</li>
|
|
217
|
-
)
|
|
218
|
-
})
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
default: {
|
|
222
|
-
return (groupedOptions as typeof options).map((option: Option, index: number) => {
|
|
223
|
-
debug === true &&
|
|
224
|
-
console.log(
|
|
225
|
-
'renderOptions: ',
|
|
226
|
-
structure?.extended?.title_path,
|
|
227
|
-
option[structure?.extended?.title_path],
|
|
228
|
-
options,
|
|
229
|
-
)
|
|
230
|
-
return (
|
|
231
|
-
<li {...getOptionProps({ option, index })}>
|
|
232
|
-
<Typography variant='table' color={theme.palette.typography.title}>
|
|
233
|
-
{titleCase(option[structure?.extended?.title_path] ?? option.title)}
|
|
234
|
-
</Typography>
|
|
235
|
-
</li>
|
|
236
|
-
)
|
|
237
|
-
})
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
useImperativeHandle(parentRef, () => ({
|
|
244
|
-
clearDDL: () => {
|
|
245
|
-
//@ts-ignore
|
|
246
|
-
getClearProps()?.onClick(null)
|
|
247
|
-
},
|
|
248
|
-
}))
|
|
249
|
-
|
|
250
|
-
useEffect(() => {
|
|
251
|
-
if (ref && ref.current) {
|
|
252
|
-
//@ts-ignore
|
|
253
|
-
ref.current.addEventListener('scroll', () => onPopupScroll())
|
|
254
|
-
}
|
|
255
|
-
return () => {
|
|
256
|
-
if (ref && ref.current) {
|
|
257
|
-
//@ts-ignore
|
|
258
|
-
ref.current.removeEventListener('scroll', () => onPopupScroll())
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}, [groupedOptions])
|
|
262
|
-
|
|
263
|
-
useEffect(() => {
|
|
264
|
-
onChange && onChange(value, name)
|
|
265
|
-
}, [value])
|
|
266
|
-
|
|
267
|
-
useEffect(() => {
|
|
268
|
-
if (popupOpen && !isLastPage && prevPage < page && !disabled) {
|
|
269
|
-
fetch()
|
|
270
|
-
}
|
|
271
|
-
}, [popupOpen])
|
|
272
|
-
|
|
273
|
-
useEffect(() => {
|
|
274
|
-
if (!disabled) {
|
|
275
|
-
fetch()
|
|
276
|
-
}
|
|
277
|
-
}, [])
|
|
278
|
-
|
|
279
|
-
useEffect(() => {
|
|
280
|
-
if (data && !isLastPage && prevPage < page) {
|
|
281
|
-
const newOptions: Option[] = data[method_name]
|
|
282
|
-
|
|
283
|
-
if (newOptions.length === 0 || newOptions.length < pageSize) {
|
|
284
|
-
setIsLastPage(true)
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
setOptions([...newOptions, ...options])
|
|
288
|
-
setLoadingData(false)
|
|
289
|
-
}
|
|
290
|
-
}, [data])
|
|
291
|
-
|
|
292
|
-
return (
|
|
293
|
-
<Root>
|
|
294
|
-
<InputWrapper
|
|
295
|
-
hasValue={!!(value && Object.keys(value).length)}
|
|
296
|
-
disabled={disabled}
|
|
297
|
-
sx={{
|
|
298
|
-
width: props.styles?.width ?? 180,
|
|
299
|
-
maxWidth: props.styles?.maxWidth ?? 300,
|
|
300
|
-
}}
|
|
301
|
-
{...getRootProps()}
|
|
302
|
-
ref={setAnchorEl}
|
|
303
|
-
className={focused ? 'focused' : ''}
|
|
304
|
-
>
|
|
305
|
-
<input
|
|
306
|
-
{...getInputProps()}
|
|
307
|
-
readOnly
|
|
308
|
-
onChange={(e) => {
|
|
309
|
-
//@ts-ignore
|
|
310
|
-
getInputProps()?.onChange(e)
|
|
311
|
-
handleSearch(e)
|
|
312
|
-
}}
|
|
313
|
-
placeholder={createTitle()}
|
|
314
|
-
value={showSelectedValue ? titleCase(value.title) : undefined}
|
|
315
|
-
/>
|
|
316
|
-
{loading ? (
|
|
317
|
-
<Loading>
|
|
318
|
-
<CircularProgress />
|
|
319
|
-
</Loading>
|
|
320
|
-
) : (
|
|
321
|
-
<ArrowIcon />
|
|
322
|
-
)}
|
|
323
|
-
</InputWrapper>
|
|
324
|
-
|
|
325
|
-
{groupedOptions.length > 0 && !disabled ? (
|
|
326
|
-
<Listbox
|
|
327
|
-
// sx={{
|
|
328
|
-
// width: props.styles?.width ?? 300,
|
|
329
|
-
// maxWidth: props.styles?.maxWidth ?? 300,
|
|
330
|
-
// minWidth: props.styles?.width ?? 300,
|
|
331
|
-
// }}
|
|
332
|
-
{...getListboxProps()}
|
|
333
|
-
>
|
|
334
|
-
<StyledListBox
|
|
335
|
-
sx={{
|
|
336
|
-
...props.styles?.menuSx,
|
|
337
|
-
// width: props.styles?.width ?? 300,
|
|
338
|
-
}}
|
|
339
|
-
hasClearBtn={children?.length}
|
|
340
|
-
ref={ref}
|
|
341
|
-
>
|
|
342
|
-
{handleRenderOptions()}
|
|
343
|
-
</StyledListBox>
|
|
344
|
-
|
|
345
|
-
{children && children.length ? (
|
|
346
|
-
<StyledClose>
|
|
347
|
-
{handleChildrens({
|
|
348
|
-
structure: children[0],
|
|
349
|
-
onClick: (e: any) => {
|
|
350
|
-
onClear && onClear()
|
|
351
|
-
//@ts-ignore
|
|
352
|
-
getClearProps()?.onClick(e)
|
|
353
|
-
},
|
|
354
|
-
startIcon: <CloseIcon />,
|
|
355
|
-
})}
|
|
356
|
-
</StyledClose>
|
|
357
|
-
) : null}
|
|
358
|
-
</Listbox>
|
|
359
|
-
) : null}
|
|
360
|
-
</Root>
|
|
361
|
-
)
|
|
362
|
-
})
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
interface Option {
|
|
2
|
-
title: string
|
|
3
|
-
value: string | number | boolean
|
|
4
|
-
[key: string]: any
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface StylesOptions {
|
|
8
|
-
width?: string | number
|
|
9
|
-
maxWidth?: string | number
|
|
10
|
-
inputSx?: object
|
|
11
|
-
menuSx?: object
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type AsyncDropdownPropsType = {
|
|
15
|
-
debug?: boolean
|
|
16
|
-
initialValue?: Option | any
|
|
17
|
-
styles?: StylesOptions
|
|
18
|
-
structure: {
|
|
19
|
-
name: string
|
|
20
|
-
extended: {
|
|
21
|
-
title: string
|
|
22
|
-
title_path: string
|
|
23
|
-
search_path: string
|
|
24
|
-
variables: {
|
|
25
|
-
method_name: string
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
children: any
|
|
29
|
-
}
|
|
30
|
-
fetcher: {
|
|
31
|
-
query: any
|
|
32
|
-
queryOptions: any
|
|
33
|
-
}
|
|
34
|
-
multiple?: boolean
|
|
35
|
-
onChange?: (value: any, name: string) => void
|
|
36
|
-
type?: 'checkbox' | 'text'
|
|
37
|
-
renderOptions?: (option: Option, index: number) => void
|
|
38
|
-
[x: string]: any
|
|
39
|
-
showSelectedValue?: boolean
|
|
40
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
export const getJPart = (j: any, jsonPath: string, defaultValue?: any): any => {
|
|
2
|
-
// input check - if key is invalid - return error
|
|
3
|
-
if (isObjectValid(j) === false) return defaultValue
|
|
4
|
-
|
|
5
|
-
// convert indexes to properties
|
|
6
|
-
jsonPath = jsonPath.replace(/\[(\w+)\]/g, '.$1')
|
|
7
|
-
|
|
8
|
-
// strip a leading dot
|
|
9
|
-
jsonPath = jsonPath.replace(/^\./, '')
|
|
10
|
-
|
|
11
|
-
// split path by '.'
|
|
12
|
-
let _isArrayValid = false
|
|
13
|
-
let _isStringValid = false
|
|
14
|
-
let currentPathPart: any
|
|
15
|
-
let isLoop = true
|
|
16
|
-
|
|
17
|
-
const pathParts = jsonPath.split('.')
|
|
18
|
-
|
|
19
|
-
for (let i = 0, n = pathParts.length; isLoop && i < n; ++i) {
|
|
20
|
-
currentPathPart = pathParts[i]
|
|
21
|
-
_isStringValid = isStringValid(j)
|
|
22
|
-
_isArrayValid = isArrayValid(j)
|
|
23
|
-
|
|
24
|
-
if (_isStringValid === true || _isArrayValid === true) {
|
|
25
|
-
if (_isStringValid === true) {
|
|
26
|
-
j = JSON.parse(j)
|
|
27
|
-
} else {
|
|
28
|
-
j = j.reduce((acc: Array<any>, cur: any) => {
|
|
29
|
-
const innerJ = getJPart(
|
|
30
|
-
cur,
|
|
31
|
-
pathParts.slice(i).join("."),
|
|
32
|
-
defaultValue,
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
if (isArrayValid(innerJ)) {
|
|
36
|
-
acc.push(...innerJ)
|
|
37
|
-
} else {
|
|
38
|
-
acc.push({
|
|
39
|
-
...innerJ,
|
|
40
|
-
value: innerJ._id,
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return acc
|
|
45
|
-
}, [])
|
|
46
|
-
|
|
47
|
-
isLoop = false
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
if (currentPathPart in j) {
|
|
51
|
-
j = j[currentPathPart]
|
|
52
|
-
} else {
|
|
53
|
-
// if something in the process failed:
|
|
54
|
-
// 1. set the rv as the default value
|
|
55
|
-
// 2. stop the loop`
|
|
56
|
-
j = defaultValue
|
|
57
|
-
isLoop = false
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return j
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const isArrayValid = (arr: any[], minLength: number = 1, maxLength: number = 0): boolean => {
|
|
66
|
-
let rv: boolean =
|
|
67
|
-
isObjectValid(arr) &&
|
|
68
|
-
arr.length >= minLength &&
|
|
69
|
-
//arr instanceof Array
|
|
70
|
-
Object.prototype.toString.call(arr) == '[object Array]'
|
|
71
|
-
|
|
72
|
-
if (maxLength > 0) {
|
|
73
|
-
rv = rv && arr.length <= maxLength
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return rv
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export const isObjectValid = (obj: any, isCheckKeys: boolean = false): boolean => {
|
|
80
|
-
let rv: boolean = typeof obj !== 'undefined' && obj !== null
|
|
81
|
-
|
|
82
|
-
if (isCheckKeys) {
|
|
83
|
-
rv = rv && Object.keys(obj).length > 0
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return rv
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const isStringValid = (str: string, minLength: number | null = null, maxLength: number | null = null, isValidateType: boolean = true): boolean => {
|
|
90
|
-
let rv = isObjectValid(str) && str.toString().length > 0 && (isValidateType ? typeof str === 'string' : true)
|
|
91
|
-
|
|
92
|
-
if (rv === false) return false
|
|
93
|
-
|
|
94
|
-
if (minLength && isNaN(minLength) === false && minLength > 0) {
|
|
95
|
-
rv = rv && str.toString().length >= minLength
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (rv === false) return false
|
|
99
|
-
|
|
100
|
-
if (maxLength && isNaN(maxLength) === false && maxLength > 0) {
|
|
101
|
-
rv = rv && str.toString().length <= maxLength
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return rv
|
|
105
|
-
}
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { styled } from '@mui/material/styles'
|
|
2
|
-
|
|
3
|
-
export const Root: any = styled('div')(() => ({
|
|
4
|
-
color: 'rgba(0,0,0,.85)',
|
|
5
|
-
fontSize: 14,
|
|
6
|
-
}))
|
|
7
|
-
|
|
8
|
-
export const Label: any = styled('label')(() => ({
|
|
9
|
-
padding: '0 0 4px',
|
|
10
|
-
lineHeight: '1.5',
|
|
11
|
-
display: 'block',
|
|
12
|
-
}))
|
|
13
|
-
|
|
14
|
-
export const Loading: any = styled('div')(() => ({
|
|
15
|
-
width: 30,
|
|
16
|
-
height: 30,
|
|
17
|
-
display: 'flex',
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
justifyContent: 'center',
|
|
20
|
-
['& span']: {
|
|
21
|
-
width: '20px !important',
|
|
22
|
-
height: '20px !important',
|
|
23
|
-
},
|
|
24
|
-
}))
|
|
25
|
-
|
|
26
|
-
export const InputWrapper: any = styled('div')<any>(({ theme, hasValue, disabled }) => {
|
|
27
|
-
const defaultBorder = `1px solid ${theme.palette.greyscale[200]}`
|
|
28
|
-
const hasValueBorder = `1px solid ${theme.palette.primary[500]}`
|
|
29
|
-
const disabledBorder = `1px solid ${theme.palette.greyscale[200]}`
|
|
30
|
-
const activeBorder = `1px solid ${theme.palette.primary[500]}`
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
border: disabled ? disabledBorder : hasValue ? hasValueBorder : defaultBorder,
|
|
34
|
-
backgroundColor: theme.palette.common.white,
|
|
35
|
-
borderRadius: 4,
|
|
36
|
-
padding: 1,
|
|
37
|
-
display: 'flex',
|
|
38
|
-
alignItems: 'center',
|
|
39
|
-
flexWrap: 'wrap',
|
|
40
|
-
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
41
|
-
|
|
42
|
-
['&:hover']: {
|
|
43
|
-
border: disabled ? disabledBorder : activeBorder,
|
|
44
|
-
borderRadius: 4,
|
|
45
|
-
},
|
|
46
|
-
['&:focus']: {
|
|
47
|
-
border: disabled ? disabledBorder : activeBorder,
|
|
48
|
-
borderRadius: 4,
|
|
49
|
-
},
|
|
50
|
-
['& > svg']: {
|
|
51
|
-
color: disabled ? theme.palette.greyscale[300] : theme.palette.primary['500'],
|
|
52
|
-
marginRight: 8,
|
|
53
|
-
},
|
|
54
|
-
['& input']: {
|
|
55
|
-
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
56
|
-
backgroundColor: theme.palette.common.white,
|
|
57
|
-
color: theme.palette.typography.title,
|
|
58
|
-
height: 36,
|
|
59
|
-
boxSizing: 'border-box',
|
|
60
|
-
padding: '4px 6px 4px 16px',
|
|
61
|
-
width: 0,
|
|
62
|
-
minWidth: 30,
|
|
63
|
-
flexGrow: 1,
|
|
64
|
-
border: 0,
|
|
65
|
-
margin: 0,
|
|
66
|
-
outline: 0,
|
|
67
|
-
|
|
68
|
-
...theme.typography.body1,
|
|
69
|
-
lineHeight: '20px',
|
|
70
|
-
|
|
71
|
-
['& ::placeholder']: {
|
|
72
|
-
color: hasValue ? theme.palette.typography.title : theme.palette.greyscale[400],
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
export const Listbox: any = styled('ul')(({ theme }) => ({
|
|
79
|
-
margin: 0,
|
|
80
|
-
padding: 0,
|
|
81
|
-
position: 'absolute',
|
|
82
|
-
listStyle: 'none',
|
|
83
|
-
backgroundColor: theme.palette.common.white,
|
|
84
|
-
overflow: 'auto',
|
|
85
|
-
maxHeight: 250,
|
|
86
|
-
minHeight: 250,
|
|
87
|
-
borderRadius: 4,
|
|
88
|
-
boxShadow: '0px 0px 10px rgba(86, 135, 147, 0.2)',
|
|
89
|
-
zIndex: 1,
|
|
90
|
-
maxWidth: 270,
|
|
91
|
-
minWidth: 270,
|
|
92
|
-
top: 48,
|
|
93
|
-
left: -42,
|
|
94
|
-
|
|
95
|
-
['& div']: {
|
|
96
|
-
textOverflow: 'ellipsis',
|
|
97
|
-
whiteSpace: 'nowrap',
|
|
98
|
-
overflow: 'hidden',
|
|
99
|
-
},
|
|
100
|
-
}))
|
|
101
|
-
|
|
102
|
-
export const StyledClose: any = styled('div')(() => ({
|
|
103
|
-
position: 'absolute',
|
|
104
|
-
bottom: 0,
|
|
105
|
-
}))
|
|
106
|
-
|
|
107
|
-
export const StyledListBox: any = styled('ul')(({ theme, hasClearBtn }: any) => ({
|
|
108
|
-
// width: 300,
|
|
109
|
-
margin: 0,
|
|
110
|
-
padding: 0,
|
|
111
|
-
// position: 'absolute',
|
|
112
|
-
listStyle: 'none',
|
|
113
|
-
backgroundColor: theme.palette.common.white,
|
|
114
|
-
overflow: 'auto',
|
|
115
|
-
maxHeight: hasClearBtn ? 190 : 230,
|
|
116
|
-
zIndex: 1,
|
|
117
|
-
textOverflow: 'ellipsis',
|
|
118
|
-
whiteSpace: 'nowrap',
|
|
119
|
-
overflowX: 'hidden',
|
|
120
|
-
paddingTop: 8,
|
|
121
|
-
paddingBottom: 8,
|
|
122
|
-
maxWidth: 270,
|
|
123
|
-
minWidth: 270,
|
|
124
|
-
|
|
125
|
-
['& div']: {
|
|
126
|
-
textOverflow: 'ellipsis',
|
|
127
|
-
whiteSpace: 'nowrap',
|
|
128
|
-
overflow: 'hidden',
|
|
129
|
-
},
|
|
130
|
-
['& li']: {
|
|
131
|
-
paddingRight: 16,
|
|
132
|
-
paddingLeft: 16,
|
|
133
|
-
display: 'flex',
|
|
134
|
-
alignItems: 'center',
|
|
135
|
-
justifyContent: 'flex-start',
|
|
136
|
-
height: 40,
|
|
137
|
-
cursor: 'pointer',
|
|
138
|
-
textOverflow: 'ellipsis',
|
|
139
|
-
whiteSpace: 'nowrap',
|
|
140
|
-
overflow: 'hidden',
|
|
141
|
-
maxWidth: 270,
|
|
142
|
-
minWidth: 270,
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
['& li:hover']: {
|
|
146
|
-
backgroundColor: '#F6F9FA',
|
|
147
|
-
},
|
|
148
|
-
|
|
149
|
-
["& li[aria-selected='true']"]: {
|
|
150
|
-
fontWeight: 900,
|
|
151
|
-
backgroundColor: '#F6F9FA',
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
["& li[data-focus='true']"]: {
|
|
155
|
-
backgroundColor: '#F6F9FA',
|
|
156
|
-
cursor: 'pointer',
|
|
157
|
-
|
|
158
|
-
['& svg ']: {
|
|
159
|
-
color: 'currentColor',
|
|
160
|
-
},
|
|
161
|
-
},
|
|
162
|
-
}))
|