tycho-components 0.0.17-SNAPSHOT-21 → 0.0.17-SNAPSHOT-23
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/functions/FilterUtils.d.ts +13 -0
- package/dist/functions/FilterUtils.js +61 -0
- package/dist/functions/FormUtils.js +1 -1
- package/dist/index.d.ts +23 -25
- package/dist/index.js +13 -12
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
+
export type DefaultOption = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: any;
|
|
5
|
+
};
|
|
6
|
+
declare const FilterUtils: {
|
|
7
|
+
apply: (form: UseFormReturn<any>, setFilter: any, onClose: () => void) => void;
|
|
8
|
+
clear: (form: UseFormReturn<any>, setFilter: (f: any) => void, onClose: () => void) => void;
|
|
9
|
+
isSelected: (filter: any) => "" | "selected";
|
|
10
|
+
reset: (form: UseFormReturn<any>, setFilter: (p: any) => void) => void;
|
|
11
|
+
enter: (form: UseFormReturn<any>, setFilter: any, event: React.KeyboardEvent<HTMLDivElement>, onClose: () => void) => void;
|
|
12
|
+
};
|
|
13
|
+
export default FilterUtils;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { EMPTY_PAGEABLE } from '../AppTable/types/AppPageable';
|
|
2
|
+
import DateUtils from './DateUtils';
|
|
3
|
+
const enter = (form, setFilter, event, onClose) => {
|
|
4
|
+
// 'keypress' event misbehaves on mobile so we track 'Enter' key via 'keydown' event
|
|
5
|
+
if (event.key === 'Enter') {
|
|
6
|
+
event.preventDefault();
|
|
7
|
+
event.stopPropagation();
|
|
8
|
+
apply(form, setFilter, onClose);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const apply = (form, setFilter, onClose) => {
|
|
12
|
+
setFilter({ ...form.getValues(), ...EMPTY_PAGEABLE });
|
|
13
|
+
onClose();
|
|
14
|
+
};
|
|
15
|
+
const clear = (form, setFilter, onClose) => {
|
|
16
|
+
reset(form, setFilter);
|
|
17
|
+
form.reset();
|
|
18
|
+
onClose();
|
|
19
|
+
};
|
|
20
|
+
const reset = (form, setFilter) => {
|
|
21
|
+
setFilter({
|
|
22
|
+
...form.formState.defaultValues,
|
|
23
|
+
...EMPTY_PAGEABLE,
|
|
24
|
+
seed: DateUtils.millis(),
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const isSelected = (filter) => {
|
|
28
|
+
const clone = JSON.parse(JSON.stringify(filter));
|
|
29
|
+
delete clone.page;
|
|
30
|
+
delete clone.size;
|
|
31
|
+
delete clone.sort;
|
|
32
|
+
delete clone.seed;
|
|
33
|
+
return isObjectEmpty(clone) ? '' : 'selected';
|
|
34
|
+
};
|
|
35
|
+
const isObjectEmpty = (filter) => {
|
|
36
|
+
if (!filter || Object.keys(filter).length === 0)
|
|
37
|
+
return true;
|
|
38
|
+
let empty = false;
|
|
39
|
+
Object.keys(filter).forEach((key) => {
|
|
40
|
+
if (Array.isArray(filter[key])) {
|
|
41
|
+
if (filter[key].length === 0)
|
|
42
|
+
empty = true;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (!filter[key])
|
|
46
|
+
empty = true;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return empty;
|
|
50
|
+
};
|
|
51
|
+
function isString(value) {
|
|
52
|
+
return typeof value === 'string' || value instanceof String;
|
|
53
|
+
}
|
|
54
|
+
const FilterUtils = {
|
|
55
|
+
apply,
|
|
56
|
+
clear,
|
|
57
|
+
isSelected,
|
|
58
|
+
reset,
|
|
59
|
+
enter,
|
|
60
|
+
};
|
|
61
|
+
export default FilterUtils;
|
|
@@ -6,7 +6,7 @@ const convertEnum = (values, t, prefix) => {
|
|
|
6
6
|
}));
|
|
7
7
|
return Object.entries(values).map(([key, label]) => ({
|
|
8
8
|
value: key,
|
|
9
|
-
label: t(`${prefix ? `${prefix}
|
|
9
|
+
label: t(`${prefix ? `${prefix}:` : ''}${label}`),
|
|
10
10
|
}));
|
|
11
11
|
};
|
|
12
12
|
const sortByLabel = (items) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export { default as AppAnalytics } from './AppAnalytics';
|
|
2
2
|
export { default as AppColorpicker } from './AppColorpicker';
|
|
3
3
|
export { default as AppDropzone } from './AppDropzone';
|
|
4
|
+
export type { UploadedFile } from './AppDropzone/UploadedFile';
|
|
4
5
|
export { default as AppEditable } from './AppEditable';
|
|
6
|
+
export type { AppEditableField } from './AppEditable/AppEditableField';
|
|
7
|
+
export { validateFormField } from './AppEditable/FormField';
|
|
8
|
+
export type { FieldOperations, FormField } from './AppEditable/FormField';
|
|
9
|
+
export { convertEnum, convertList } from './AppEditable/FormFieldOption';
|
|
10
|
+
export type { FormFieldOption } from './AppEditable/FormFieldOption';
|
|
5
11
|
export { default as AppLoading } from './AppLoading';
|
|
6
12
|
export { default as AppModal } from './AppModal';
|
|
7
13
|
export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
|
|
@@ -12,41 +18,33 @@ export { default as AppPlaceholder } from './AppPlaceholder';
|
|
|
12
18
|
export { default as AppSelect } from './AppSelect';
|
|
13
19
|
export { default as AppTable } from './AppTable';
|
|
14
20
|
export { default as AppListTable } from './AppTable/AppListTable';
|
|
21
|
+
export { EMPTY_GRID_PAGE, EMPTY_PAGE } from './AppTable/types/AppPage';
|
|
22
|
+
export type { AppPage } from './AppTable/types/AppPage';
|
|
23
|
+
export { convertPageable, EMPTY_GRID_PAGEABLE, EMPTY_PAGEABLE, } from './AppTable/types/AppPageable';
|
|
24
|
+
export type { AppPageable } from './AppTable/types/AppPageable';
|
|
15
25
|
export { default as AppToast } from './AppToast';
|
|
16
26
|
export { default as CommentComponent } from './Comments';
|
|
17
|
-
export { default as Header } from './Header';
|
|
18
27
|
export { default as HeaderNotifications } from './Comments/HeaderNotifications';
|
|
19
|
-
export {
|
|
20
|
-
export { default as Participants } from './Participants';
|
|
21
|
-
export { default as VirtualKeyboard } from './VirtualKeyboard';
|
|
28
|
+
export type { Comment } from './Comments/types/Comment';
|
|
22
29
|
export { CommonProvider } from './configs/CommonContext';
|
|
30
|
+
export type { Corpus, Github } from './configs/Corpus';
|
|
31
|
+
export { CorpusImageTypeNames } from './configs/CorpusImage';
|
|
32
|
+
export type { CorpusImage, CorpusImageType } from './configs/CorpusImage';
|
|
33
|
+
export { commonResources } from './configs/Localization';
|
|
23
34
|
export { useCorpusUtils } from './configs/useCorpusUtils';
|
|
24
|
-
export { useMessageUtils } from './configs/useMessageUtils';
|
|
25
35
|
export { useLoggedUtils } from './configs/useLoggedUtils';
|
|
26
|
-
export {
|
|
27
|
-
export { convertEnum, convertList } from './AppEditable/FormFieldOption';
|
|
28
|
-
export { commonResources } from './configs/Localization';
|
|
29
|
-
export { KeyboardCustomLayouts } from './VirtualKeyboard/KeyboardCustomLayout';
|
|
30
|
-
export { CorpusImageTypeNames } from './configs/CorpusImage';
|
|
36
|
+
export { useMessageUtils } from './configs/useMessageUtils';
|
|
31
37
|
export { UserStatusNames } from './configs/User';
|
|
38
|
+
export type { User, UserStatus } from './configs/User';
|
|
32
39
|
export { default as DateUtils } from './functions/DateUtils';
|
|
40
|
+
export { default as FilterUtils } from './functions/FilterUtils';
|
|
33
41
|
export { default as FormUtils } from './functions/FormUtils';
|
|
34
42
|
export { default as ImageUtils } from './functions/ImageUtils';
|
|
35
43
|
export { default as SecurityUtils } from './functions/SecurityUtils';
|
|
36
44
|
export { default as UsabilityUtils } from './functions/UsabilityUtils';
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export type { CorpusImage } from './configs/CorpusImage';
|
|
43
|
-
export type { CorpusImageType } from './configs/CorpusImage';
|
|
44
|
-
export type { Github } from './configs/Corpus';
|
|
45
|
-
export type { FormFieldOption } from './AppEditable/FormFieldOption';
|
|
46
|
-
export type { FieldOperations, FormField } from './AppEditable/FormField';
|
|
45
|
+
export { default as Header } from './Header';
|
|
46
|
+
export { default as LanguageSelector } from './LanguageSelector';
|
|
47
|
+
export { default as Participants } from './Participants';
|
|
48
|
+
export { default as VirtualKeyboard } from './VirtualKeyboard';
|
|
49
|
+
export { KeyboardCustomLayouts } from './VirtualKeyboard/KeyboardCustomLayout';
|
|
47
50
|
export type { KeyboardLayout } from './VirtualKeyboard/KeyboardCustomLayout';
|
|
48
|
-
export type { UploadedFile } from './AppDropzone/UploadedFile';
|
|
49
|
-
export type { User } from './configs/User';
|
|
50
|
-
export type { UserStatus } from './configs/User';
|
|
51
|
-
export { convertPageable, EMPTY_PAGEABLE, EMPTY_GRID_PAGEABLE, } from './AppTable/types/AppPageable';
|
|
52
|
-
export { EMPTY_PAGE, EMPTY_GRID_PAGE } from './AppTable/types/AppPage';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@ export { default as AppAnalytics } from './AppAnalytics';
|
|
|
2
2
|
export { default as AppColorpicker } from './AppColorpicker';
|
|
3
3
|
export { default as AppDropzone } from './AppDropzone';
|
|
4
4
|
export { default as AppEditable } from './AppEditable';
|
|
5
|
+
export { validateFormField } from './AppEditable/FormField';
|
|
6
|
+
export { convertEnum, convertList } from './AppEditable/FormFieldOption';
|
|
5
7
|
export { default as AppLoading } from './AppLoading';
|
|
6
8
|
export { default as AppModal } from './AppModal';
|
|
7
9
|
export { default as AppModalConfirm } from './AppModal/AppModalConfirm';
|
|
@@ -12,27 +14,26 @@ export { default as AppPlaceholder } from './AppPlaceholder';
|
|
|
12
14
|
export { default as AppSelect } from './AppSelect';
|
|
13
15
|
export { default as AppTable } from './AppTable';
|
|
14
16
|
export { default as AppListTable } from './AppTable/AppListTable';
|
|
17
|
+
export { EMPTY_GRID_PAGE, EMPTY_PAGE } from './AppTable/types/AppPage';
|
|
18
|
+
export { convertPageable, EMPTY_GRID_PAGEABLE, EMPTY_PAGEABLE, } from './AppTable/types/AppPageable';
|
|
15
19
|
export { default as AppToast } from './AppToast';
|
|
16
20
|
export { default as CommentComponent } from './Comments';
|
|
17
|
-
export { default as Header } from './Header';
|
|
18
21
|
export { default as HeaderNotifications } from './Comments/HeaderNotifications';
|
|
19
|
-
export { default as LanguageSelector } from './LanguageSelector';
|
|
20
|
-
export { default as Participants } from './Participants';
|
|
21
|
-
export { default as VirtualKeyboard } from './VirtualKeyboard';
|
|
22
22
|
export { CommonProvider } from './configs/CommonContext';
|
|
23
|
+
export { CorpusImageTypeNames } from './configs/CorpusImage';
|
|
24
|
+
export { commonResources } from './configs/Localization';
|
|
23
25
|
export { useCorpusUtils } from './configs/useCorpusUtils';
|
|
24
|
-
export { useMessageUtils } from './configs/useMessageUtils';
|
|
25
26
|
export { useLoggedUtils } from './configs/useLoggedUtils';
|
|
26
|
-
export {
|
|
27
|
-
export { convertEnum, convertList } from './AppEditable/FormFieldOption';
|
|
28
|
-
export { commonResources } from './configs/Localization';
|
|
29
|
-
export { KeyboardCustomLayouts } from './VirtualKeyboard/KeyboardCustomLayout';
|
|
30
|
-
export { CorpusImageTypeNames } from './configs/CorpusImage';
|
|
27
|
+
export { useMessageUtils } from './configs/useMessageUtils';
|
|
31
28
|
export { UserStatusNames } from './configs/User';
|
|
32
29
|
export { default as DateUtils } from './functions/DateUtils';
|
|
30
|
+
export { default as FilterUtils } from './functions/FilterUtils';
|
|
33
31
|
export { default as FormUtils } from './functions/FormUtils';
|
|
34
32
|
export { default as ImageUtils } from './functions/ImageUtils';
|
|
35
33
|
export { default as SecurityUtils } from './functions/SecurityUtils';
|
|
36
34
|
export { default as UsabilityUtils } from './functions/UsabilityUtils';
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
35
|
+
export { default as Header } from './Header';
|
|
36
|
+
export { default as LanguageSelector } from './LanguageSelector';
|
|
37
|
+
export { default as Participants } from './Participants';
|
|
38
|
+
export { default as VirtualKeyboard } from './VirtualKeyboard';
|
|
39
|
+
export { KeyboardCustomLayouts } from './VirtualKeyboard/KeyboardCustomLayout';
|