@axinom/mosaic-ui 0.32.0-rc.13 → 0.32.0-rc.15
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/components/Filters/Filter/Filter.d.ts.map +1 -1
- package/dist/components/Filters/Filters.model.d.ts +7 -2
- package/dist/components/Filters/Filters.model.d.ts.map +1 -1
- package/dist/components/Filters/SelectionTypes/MultiOptionFilter/MultiOptionFilter.d.ts +13 -0
- package/dist/components/Filters/SelectionTypes/MultiOptionFilter/MultiOptionFilter.d.ts.map +1 -0
- package/dist/index.es.js +3 -3
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Filters/Filter/Filter.tsx +24 -0
- package/src/components/Filters/Filters.model.ts +7 -1
- package/src/components/Filters/Filters.stories.tsx +20 -0
- package/src/components/Filters/SelectionTypes/MultiOptionFilter/MultiOptionFilter.scss +40 -0
- package/src/components/Filters/SelectionTypes/MultiOptionFilter/MultiOptionFilter.tsx +71 -0
- package/src/components/LandingPageTiles/TileLarge/TileLarge.scss +3 -3
- package/src/components/LandingPageTiles/TileSmall/TileSmall.scss +3 -3
- package/src/styles/variables.scss +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-ui",
|
|
3
|
-
"version": "0.32.0-rc.
|
|
3
|
+
"version": "0.32.0-rc.15",
|
|
4
4
|
"description": "UI components for building Axinom Mosaic applications",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "e1f5310d68f51c69b2c2191644e16bee0068d9df"
|
|
106
106
|
}
|
|
@@ -14,6 +14,7 @@ import { formatDate, formatDateTime } from '../../Utils/Transformers/DateTime';
|
|
|
14
14
|
import { FilterType, FilterTypes, FilterValue } from '../Filters.model';
|
|
15
15
|
import { DateTimeFilter } from '../SelectionTypes/DateTimeFilter/DateTimeFilter';
|
|
16
16
|
import { FreeTextFilter } from '../SelectionTypes/FreeTextFilter/FreeTextFilter';
|
|
17
|
+
import { MultiOptionsFilter } from '../SelectionTypes/MultiOptionFilter/MultiOptionFilter';
|
|
17
18
|
import { NumericTextFilter } from '../SelectionTypes/NumericTextFilter/NumericTextFilter';
|
|
18
19
|
import { OptionsFilter } from '../SelectionTypes/OptionsFilter/OptionsFilter';
|
|
19
20
|
import { SearcheableOptionsFilter } from '../SelectionTypes/SearcheableOptionsFilter/SearcheableOptionsFilter';
|
|
@@ -78,6 +79,19 @@ export const Filter = <T extends Data>({
|
|
|
78
79
|
return formatDateTime(String(value));
|
|
79
80
|
case FilterTypes.Options:
|
|
80
81
|
return options.options.find((option) => option.value === value)?.label;
|
|
82
|
+
case FilterTypes.MultipleOptions: {
|
|
83
|
+
const selectedVal: string[] = [];
|
|
84
|
+
String(value)
|
|
85
|
+
.split(',')
|
|
86
|
+
.map((item: string) =>
|
|
87
|
+
selectedVal.push(
|
|
88
|
+
options?.options.find(
|
|
89
|
+
(option) => option.value.toString() === item,
|
|
90
|
+
)?.label ?? '',
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
return selectedVal.join(', ');
|
|
94
|
+
}
|
|
81
95
|
case FilterTypes.SearcheableOptions:
|
|
82
96
|
return stringValue;
|
|
83
97
|
default:
|
|
@@ -122,6 +136,16 @@ export const Filter = <T extends Data>({
|
|
|
122
136
|
/>
|
|
123
137
|
);
|
|
124
138
|
|
|
139
|
+
case FilterTypes.MultipleOptions:
|
|
140
|
+
return (
|
|
141
|
+
<MultiOptionsFilter
|
|
142
|
+
value={value as string}
|
|
143
|
+
options={options.options}
|
|
144
|
+
onSelect={(value: FilterValue) =>
|
|
145
|
+
onFilterValueChange(options.property, value?.toString())
|
|
146
|
+
}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
125
149
|
case FilterTypes.SearcheableOptions:
|
|
126
150
|
return (
|
|
127
151
|
<SearcheableOptionsFilter
|
|
@@ -8,6 +8,7 @@ export enum FilterTypes {
|
|
|
8
8
|
Date,
|
|
9
9
|
DateTime,
|
|
10
10
|
Custom,
|
|
11
|
+
MultipleOptions,
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export interface FilterConfig<T extends Data> {
|
|
@@ -36,6 +37,10 @@ export interface OptionsFilter<T extends Data> extends FilterConfig<T> {
|
|
|
36
37
|
options: Option[];
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
export interface MultipleOptions<T extends Data> extends FilterConfig<T> {
|
|
41
|
+
type: FilterTypes.MultipleOptions;
|
|
42
|
+
options: Option[];
|
|
43
|
+
}
|
|
39
44
|
export interface SearcheableOptionsFilter<T extends Data>
|
|
40
45
|
extends FilterConfig<T> {
|
|
41
46
|
type: FilterTypes.SearcheableOptions;
|
|
@@ -87,7 +92,8 @@ export type FilterType<T extends Data> =
|
|
|
87
92
|
| SearcheableOptionsFilter<T>
|
|
88
93
|
| DateFilter<T>
|
|
89
94
|
| DateTimeFilter<T>
|
|
90
|
-
| CustomFilter<T
|
|
95
|
+
| CustomFilter<T>
|
|
96
|
+
| MultipleOptions<T>;
|
|
91
97
|
|
|
92
98
|
export type FilterValues<T> = {
|
|
93
99
|
[K in keyof T]?: FilterValue;
|
|
@@ -43,6 +43,7 @@ interface FilterStoryData {
|
|
|
43
43
|
datetime: Date;
|
|
44
44
|
id: number;
|
|
45
45
|
holderType: string;
|
|
46
|
+
roleTypes: string;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
const options: Option[] = generateItemArray(10, (index) => ({
|
|
@@ -55,6 +56,11 @@ const searcheableOptions: Option[] = generateItemArray(10, (index) => ({
|
|
|
55
56
|
value: index,
|
|
56
57
|
}));
|
|
57
58
|
|
|
59
|
+
const multipleOptions: Option[] = generateItemArray(10, (index) => ({
|
|
60
|
+
label: faker.lorem.words(),
|
|
61
|
+
value: index,
|
|
62
|
+
}));
|
|
63
|
+
|
|
58
64
|
const textFilter: FilterType<FilterStoryData> = {
|
|
59
65
|
label: 'Title',
|
|
60
66
|
property: 'title',
|
|
@@ -76,6 +82,13 @@ const searcheableOptionFilter: FilterType<FilterStoryData> = {
|
|
|
76
82
|
searcheableOptions.filter((option) => option.label.includes(searchText)),
|
|
77
83
|
};
|
|
78
84
|
|
|
85
|
+
const multipleOptionFilter: FilterType<FilterStoryData> = {
|
|
86
|
+
label: 'Role Types',
|
|
87
|
+
property: 'roleTypes',
|
|
88
|
+
type: FilterTypes.MultipleOptions,
|
|
89
|
+
options: multipleOptions,
|
|
90
|
+
};
|
|
91
|
+
|
|
79
92
|
const numberFilter: FilterType<FilterStoryData> = {
|
|
80
93
|
label: 'ID',
|
|
81
94
|
property: 'id',
|
|
@@ -167,6 +180,12 @@ export const searchableOptionsFilter: StoryObj<typeof Filters> = {
|
|
|
167
180
|
},
|
|
168
181
|
};
|
|
169
182
|
|
|
183
|
+
export const multiOptionFilter: StoryObj<typeof Filters> = {
|
|
184
|
+
args: {
|
|
185
|
+
options: [multipleOptionFilter],
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
|
|
170
189
|
export const DateFilter: StoryObj<typeof Filters> = {
|
|
171
190
|
args: {
|
|
172
191
|
options: [dateFilter, dateTimeFilter],
|
|
@@ -196,6 +215,7 @@ export const MultipleFilters: StoryObj<typeof Filters> = {
|
|
|
196
215
|
dateTimeFilter,
|
|
197
216
|
customFilter,
|
|
198
217
|
searcheableOptionFilter,
|
|
218
|
+
multipleOptionFilter,
|
|
199
219
|
]}
|
|
200
220
|
defaultValues={filters}
|
|
201
221
|
onFiltersChange={(filters) => {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@import '../../../../styles/common.scss';
|
|
2
|
+
|
|
3
|
+
.multiFilterContainer {
|
|
4
|
+
padding: 0;
|
|
5
|
+
.Checkbox {
|
|
6
|
+
padding-left: 20px;
|
|
7
|
+
padding-right: 20px;
|
|
8
|
+
grid-template-columns: auto 30px;
|
|
9
|
+
label {
|
|
10
|
+
color: var(--multi-option-label-colorr, $multi-option-label-color);
|
|
11
|
+
font-weight: normal;
|
|
12
|
+
}
|
|
13
|
+
input {
|
|
14
|
+
border-color: var(
|
|
15
|
+
--multi-option-checbox-border,
|
|
16
|
+
$multi-option-checbox-border
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
&:hover {
|
|
20
|
+
background-color: var(
|
|
21
|
+
--filter-background-selected-color,
|
|
22
|
+
$filter-background-selected-color
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
&.selected {
|
|
26
|
+
background-color: var(
|
|
27
|
+
--filter-background-selected-color,
|
|
28
|
+
$filter-background-selected-color
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.applyButtonContainer {
|
|
35
|
+
display: grid;
|
|
36
|
+
|
|
37
|
+
.applyButton {
|
|
38
|
+
height: 50px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { ButtonContext } from '../../../Buttons';
|
|
4
|
+
import { TextButton } from '../../../Buttons/TextButton/TextButton';
|
|
5
|
+
import { Checkbox } from '../../../FormElements';
|
|
6
|
+
import { Option } from '../../Filters.model';
|
|
7
|
+
import classes from './MultiOptionFilter.scss';
|
|
8
|
+
|
|
9
|
+
export interface MultiOptionFilterProps {
|
|
10
|
+
value?: string;
|
|
11
|
+
|
|
12
|
+
/** Array of Options to be displayed */
|
|
13
|
+
options: Option[];
|
|
14
|
+
|
|
15
|
+
/** Callback triggered when a new filter value is selected */
|
|
16
|
+
onSelect: (text: string[]) => void;
|
|
17
|
+
|
|
18
|
+
/** CSS Class name for additional styles */
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const MultiOptionsFilter: React.FC<MultiOptionFilterProps> = ({
|
|
23
|
+
value,
|
|
24
|
+
options,
|
|
25
|
+
onSelect,
|
|
26
|
+
}) => {
|
|
27
|
+
const [selectedOptionList, setSelectedOptionList] = useState<string[]>(
|
|
28
|
+
value ? value.split(',') : [],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className={clsx(classes.multiFilterContainer)}>
|
|
33
|
+
{options?.map((option: Option) => (
|
|
34
|
+
<Checkbox
|
|
35
|
+
className={clsx(
|
|
36
|
+
classes.Checkbox,
|
|
37
|
+
selectedOptionList.includes(option.value.toString()) &&
|
|
38
|
+
classes.selected,
|
|
39
|
+
)}
|
|
40
|
+
key={option.value}
|
|
41
|
+
name={option.label}
|
|
42
|
+
value={selectedOptionList.includes(option.value.toString())}
|
|
43
|
+
label={option.label}
|
|
44
|
+
onChange={(value) => {
|
|
45
|
+
if (value) {
|
|
46
|
+
setSelectedOptionList([
|
|
47
|
+
...selectedOptionList,
|
|
48
|
+
option.value.toString(),
|
|
49
|
+
]);
|
|
50
|
+
} else {
|
|
51
|
+
setSelectedOptionList(
|
|
52
|
+
[...selectedOptionList].filter(
|
|
53
|
+
(i) => i !== option.value.toString(),
|
|
54
|
+
),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
))}
|
|
60
|
+
<div className={clsx(classes.applyButtonContainer)}>
|
|
61
|
+
<TextButton
|
|
62
|
+
className={clsx(classes.applyButton)}
|
|
63
|
+
text="Apply"
|
|
64
|
+
buttonContext={ButtonContext.Active}
|
|
65
|
+
onButtonClicked={() => onSelect(selectedOptionList)}
|
|
66
|
+
disabled={selectedOptionList.length === 0}
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
|
|
34
34
|
.icon {
|
|
35
35
|
align-self: center;
|
|
36
|
-
width:
|
|
37
|
-
height:
|
|
36
|
+
width: 100px;
|
|
37
|
+
height: 100px;
|
|
38
38
|
svg * {
|
|
39
39
|
stroke: var(
|
|
40
40
|
--landingpage-largetile-stroke-color,
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
text-align: center;
|
|
54
54
|
|
|
55
55
|
.label {
|
|
56
|
-
font-size:
|
|
56
|
+
font-size: 26px;
|
|
57
57
|
font-weight: regular;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
|
|
47
47
|
.icon {
|
|
48
48
|
align-self: center;
|
|
49
|
-
width:
|
|
50
|
-
height:
|
|
49
|
+
width: 40px;
|
|
50
|
+
height: 40px;
|
|
51
51
|
svg * {
|
|
52
52
|
stroke: var(
|
|
53
53
|
--landingpage-smalltile-stroke-color,
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
.label {
|
|
60
60
|
text-align: center;
|
|
61
61
|
align-self: center;
|
|
62
|
-
font-size:
|
|
62
|
+
font-size: 15px;
|
|
63
63
|
color: var(--landingpage-smalltile-color, $landingpage-smalltile-color);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -71,6 +71,8 @@ $filter-font-size: 16px;
|
|
|
71
71
|
$filter-width: 360px;
|
|
72
72
|
$filter-controller-background-color: $light-gray-2;
|
|
73
73
|
$filter-border-color: $blue;
|
|
74
|
+
$multi-option-checbox-border: $blue;
|
|
75
|
+
$multi-option-label-color: $dark-gray;
|
|
74
76
|
|
|
75
77
|
/* Details vars */
|
|
76
78
|
$details-background-color: #ffffff;
|