@kris701/ez-ui 0.0.2 → 0.0.4

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.
@@ -1,110 +1,110 @@
1
- import { FilterHelpers } from "../helpers/floattable.filterhelpers";
2
- import { FloatTableFilter } from "../models/FloatTableFilter";
3
- import { FloatTableFilterMethod } from "../models/FloatTableFilterMethod";
4
- import { FloatTableSort } from "../models/FloatTableSort";
5
- import { FloatTableSortMethod } from "../models/FloatTableSortMethod";
6
-
7
- export class FloatTableFilterService {
8
- public sortMethods : FloatTableSortMethod[] = [
9
- {
10
- state: 'asc',
11
- sort: (a: any, b: any, column : string) => {
12
- if (a[column] < b[column])
13
- return 1;
14
- if (a[column] > b[column])
15
- return -1;
16
- return 0;
17
- }
18
- } as FloatTableSortMethod,
19
- {
20
- state: 'desc',
21
- sort: (a: any, b: any, column : string) => {
22
- if (a[column] < b[column])
23
- return -1;
24
- if (a[column] > b[column])
25
- return 1;
26
- return 0;
27
- }
28
- } as FloatTableSortMethod
29
- ]
30
-
31
- public filterMethods : FloatTableFilterMethod[] = [
32
- // Text filters
33
- {
34
- key: 'str',
35
- action: 'con',
36
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.includes(value), column)
37
- },
38
- {
39
- key: 'str',
40
- action: 'ncon',
41
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => !i.includes(value), column)
42
- },
43
- {
44
- key: 'str',
45
- action: 'sta',
46
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.startsWith(value), column)
47
- },
48
- {
49
- key: 'str',
50
- action: 'end',
51
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.endsWith(value), column)
52
- },
53
-
54
- // Select filters
55
- {
56
- key: 'sel',
57
- action: 'con',
58
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => value.includes(i), column)
59
- },
60
- {
61
- key: 'sel',
62
- action: 'ncon',
63
- filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => !value.includes(i), column)
64
- },
65
-
66
- // Date filters
67
- {
68
- key: 'dat',
69
- action: 'bef',
70
- filter: (values : any[], column : string, value : any) =>
71
- FilterHelpers.dateFilter(
72
- values,
73
- (i : Date) => {
74
- var normal = value[0].toLocalNativeDate()
75
- normal.setMilliseconds(value[1].toAbsoluteMilliseconds());
76
- return i.getTime() < normal.getTime()
77
- },
78
- column)
79
- },
80
- {
81
- key: 'dat',
82
- action: 'aft',
83
- filter: (values : any[], column : string, value : any) =>
84
- FilterHelpers.dateFilter(
85
- values,
86
- (i : Date) => {
87
- var normal = value[0].toLocalNativeDate()
88
- normal.setMilliseconds(value[1].toAbsoluteMilliseconds());
89
- return i.getTime() > normal.getTime()
90
- },
91
- column)
92
- },
93
- ]
94
-
95
- public sort(values : any[], sort : FloatTableSort) : any[]{
96
- var target = this.sortMethods.find(x => x.state == sort.state);
97
- if (target)
98
- return values.sort((a : any, b: any) => target!.sort(a,b,sort.column));
99
- return values;
100
- }
101
-
102
- public filter(values : any[], filter : FloatTableFilter) : any[]{
103
- var split = filter.expression.split(';');
104
- var target = this.filterMethods.find(x => split[0] == x.key && split[1] == x.action);
105
- if (target)
106
- return target!.filter(values, filter.column, filter.value);
107
- return values;
108
- }
109
- }
110
-
1
+ import { FilterHelpers } from "../helpers/floattable.filterhelpers";
2
+ import { FloatTableFilter } from "../models/FloatTableFilter";
3
+ import { FloatTableFilterMethod } from "../models/FloatTableFilterMethod";
4
+ import { FloatTableSort } from "../models/FloatTableSort";
5
+ import { FloatTableSortMethod } from "../models/FloatTableSortMethod";
6
+
7
+ export class FloatTableFilterService {
8
+ public sortMethods : FloatTableSortMethod[] = [
9
+ {
10
+ state: 'asc',
11
+ sort: (a: any, b: any, column : string) => {
12
+ if (a[column] < b[column])
13
+ return 1;
14
+ if (a[column] > b[column])
15
+ return -1;
16
+ return 0;
17
+ }
18
+ } as FloatTableSortMethod,
19
+ {
20
+ state: 'desc',
21
+ sort: (a: any, b: any, column : string) => {
22
+ if (a[column] < b[column])
23
+ return -1;
24
+ if (a[column] > b[column])
25
+ return 1;
26
+ return 0;
27
+ }
28
+ } as FloatTableSortMethod
29
+ ]
30
+
31
+ public filterMethods : FloatTableFilterMethod[] = [
32
+ // Text filters
33
+ {
34
+ key: 'str',
35
+ action: 'con',
36
+ filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.includes(value), column)
37
+ },
38
+ {
39
+ key: 'str',
40
+ action: 'ncon',
41
+ filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => !i.includes(value), column)
42
+ },
43
+ {
44
+ key: 'str',
45
+ action: 'sta',
46
+ filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.startsWith(value), column)
47
+ },
48
+ {
49
+ key: 'str',
50
+ action: 'end',
51
+ filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => i.endsWith(value), column)
52
+ },
53
+
54
+ // Select filters
55
+ {
56
+ key: 'sel',
57
+ action: 'con',
58
+ filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => value.includes(i), column)
59
+ },
60
+ {
61
+ key: 'sel',
62
+ action: 'ncon',
63
+ filter: (values : any[], column : string, value : any) => FilterHelpers.textFilter(values, (i : string) => !value.includes(i), column)
64
+ },
65
+
66
+ // Date filters
67
+ {
68
+ key: 'dat',
69
+ action: 'bef',
70
+ filter: (values : any[], column : string, value : any) =>
71
+ FilterHelpers.dateFilter(
72
+ values,
73
+ (i : Date) => {
74
+ var normal = value[0].toLocalNativeDate()
75
+ normal.setMilliseconds(value[1].toAbsoluteMilliseconds());
76
+ return i.getTime() < normal.getTime()
77
+ },
78
+ column)
79
+ },
80
+ {
81
+ key: 'dat',
82
+ action: 'aft',
83
+ filter: (values : any[], column : string, value : any) =>
84
+ FilterHelpers.dateFilter(
85
+ values,
86
+ (i : Date) => {
87
+ var normal = value[0].toLocalNativeDate()
88
+ normal.setMilliseconds(value[1].toAbsoluteMilliseconds());
89
+ return i.getTime() > normal.getTime()
90
+ },
91
+ column)
92
+ },
93
+ ]
94
+
95
+ public sort(values : any[], sort : FloatTableSort) : any[]{
96
+ var target = this.sortMethods.find(x => x.state == sort.state);
97
+ if (target)
98
+ return values.sort((a : any, b: any) => target!.sort(a,b,sort.column));
99
+ return values;
100
+ }
101
+
102
+ public filter(values : any[], filter : FloatTableFilter) : any[]{
103
+ var split = filter.expression.split(';');
104
+ var target = this.filterMethods.find(x => split[0] == x.key && split[1] == x.action);
105
+ if (target)
106
+ return target!.filter(values, filter.column, filter.value);
107
+ return values;
108
+ }
109
+ }
110
+
package/src/public-api.ts CHANGED
@@ -1,15 +1,15 @@
1
- // Components
2
- export * from './components/dateinput';
3
- export * from './components/markdowneditor';
4
- export * from './components/multiselect';
5
- export * from './components/numberinput';
6
- export * from './components/passwordinput';
7
- export * from './components/textinput';
8
-
9
- // Helpers
10
- export * from './helpers/compressImage';
11
-
12
- // Interfaces
13
- export * from './interfaces/baseCRUDInterface';
14
- export * from './interfaces/baseListService';
15
-
1
+ // Components
2
+ export * from './components/dateinput';
3
+ export * from './components/markdowneditor';
4
+ export * from './components/multiselect';
5
+ export * from './components/numberinput';
6
+ export * from './components/passwordinput';
7
+ export * from './components/textinput';
8
+
9
+ // Helpers
10
+ export * from './helpers/compressImage';
11
+
12
+ // Interfaces
13
+ export * from './interfaces/baseCRUDInterface';
14
+ export * from './interfaces/baseListService';
15
+