react-native-unistyles 1.0.0-beta.5 → 1.0.0-rc.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -588
- package/lib/commonjs/createUnistyles.js +0 -9
- package/lib/commonjs/createUnistyles.js.map +1 -1
- package/lib/commonjs/types/breakpoints.js +6 -0
- package/lib/commonjs/types/breakpoints.js.map +1 -0
- package/lib/commonjs/{types.js → types/core.js} +1 -1
- package/lib/commonjs/types/core.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/mediaQueries.js.map +1 -0
- package/lib/commonjs/utils/index.js +43 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/createUnistyles.js +0 -9
- package/lib/module/createUnistyles.js.map +1 -1
- package/lib/module/types/breakpoints.js +2 -0
- package/lib/module/types/breakpoints.js.map +1 -0
- package/lib/module/types/core.js +2 -0
- package/lib/module/types/core.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/mediaQueries.js.map +1 -0
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/src/createUnistyles.d.ts +1 -5
- package/lib/typescript/src/createUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +19 -0
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -0
- package/lib/typescript/src/types/core.d.ts +32 -0
- package/lib/typescript/src/types/core.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +3 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/mediaQueries.d.ts +2 -0
- package/lib/typescript/src/types/mediaQueries.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -1
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/package.json +13 -10
- package/src/__tests__/createUnistyles.spec.tsx +158 -0
- package/src/createUnistyles.ts +0 -10
- package/src/types/breakpoints.ts +33 -0
- package/src/types/core.ts +73 -0
- package/src/types/index.ts +9 -0
- package/src/types/mediaQueries.ts +69 -0
- package/src/utils/index.ts +9 -1
- package/lib/commonjs/mediaQueries.js.map +0 -1
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/breakpoints.spec.js +0 -154
- package/lib/commonjs/utils/breakpoints.spec.js.map +0 -1
- package/lib/commonjs/utils/mediaQueries.spec.js +0 -220
- package/lib/commonjs/utils/mediaQueries.spec.js.map +0 -1
- package/lib/commonjs/utils/styles.spec.js +0 -174
- package/lib/commonjs/utils/styles.spec.js.map +0 -1
- package/lib/module/mediaQueries.js.map +0 -1
- package/lib/module/types.js +0 -2
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/breakpoints.spec.js +0 -152
- package/lib/module/utils/breakpoints.spec.js.map +0 -1
- package/lib/module/utils/mediaQueries.spec.js +0 -218
- package/lib/module/utils/mediaQueries.spec.js.map +0 -1
- package/lib/module/utils/styles.spec.js +0 -172
- package/lib/module/utils/styles.spec.js.map +0 -1
- package/lib/typescript/src/mediaQueries.d.ts +0 -2
- package/lib/typescript/src/mediaQueries.d.ts.map +0 -1
- package/lib/typescript/src/types.d.ts +0 -67
- package/lib/typescript/src/types.d.ts.map +0 -1
- package/lib/typescript/src/utils/breakpoints.spec.d.ts +0 -2
- package/lib/typescript/src/utils/breakpoints.spec.d.ts.map +0 -1
- package/lib/typescript/src/utils/mediaQueries.spec.d.ts +0 -2
- package/lib/typescript/src/utils/mediaQueries.spec.d.ts.map +0 -1
- package/lib/typescript/src/utils/styles.spec.d.ts +0 -2
- package/lib/typescript/src/utils/styles.spec.d.ts.map +0 -1
- package/src/mediaQueries.ts +0 -33
- package/src/types.ts +0 -123
- /package/lib/commonjs/{mediaQueries.js → types/mediaQueries.js} +0 -0
- /package/lib/module/{mediaQueries.js → types/mediaQueries.js} +0 -0
package/lib/module/types.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":""}
|
@@ -1,152 +0,0 @@
|
|
1
|
-
import { getBreakpointFromScreenWidth, getValueForBreakpoint, sortAndValidateBreakpoints } from './breakpoints';
|
2
|
-
describe('breakpoints', () => {
|
3
|
-
describe('sortAndValidateBreakpoints', () => {
|
4
|
-
it('should throw error for empty breakpoints', () => {
|
5
|
-
const breakpoints = {};
|
6
|
-
expect(() => sortAndValidateBreakpoints(breakpoints)).toThrow();
|
7
|
-
});
|
8
|
-
it('should throw error for breakpoints that don\'t start with 0', () => {
|
9
|
-
const breakpoints = {
|
10
|
-
sm: -1
|
11
|
-
};
|
12
|
-
expect(() => sortAndValidateBreakpoints(breakpoints)).toThrow();
|
13
|
-
});
|
14
|
-
it('should return same order for sorted elements', () => {
|
15
|
-
const breakpoints = {
|
16
|
-
sm: 0,
|
17
|
-
md: 200,
|
18
|
-
lg: 300,
|
19
|
-
xl: 500
|
20
|
-
};
|
21
|
-
expect(sortAndValidateBreakpoints(breakpoints)).toEqual(breakpoints);
|
22
|
-
});
|
23
|
-
it('should sort the order of breakpoints', () => {
|
24
|
-
const breakpoints = {
|
25
|
-
md: 200,
|
26
|
-
sm: 0,
|
27
|
-
lg: 300,
|
28
|
-
xl: 500
|
29
|
-
};
|
30
|
-
expect(sortAndValidateBreakpoints(breakpoints)).toEqual({
|
31
|
-
sm: 0,
|
32
|
-
md: 200,
|
33
|
-
lg: 300,
|
34
|
-
xl: 500
|
35
|
-
});
|
36
|
-
});
|
37
|
-
it('should throw errors for duplicated values', () => {
|
38
|
-
const breakpoints = {
|
39
|
-
md: 200,
|
40
|
-
sm: 0,
|
41
|
-
lg: 300,
|
42
|
-
xl: 300
|
43
|
-
};
|
44
|
-
expect(() => sortAndValidateBreakpoints(breakpoints)).toThrow();
|
45
|
-
});
|
46
|
-
});
|
47
|
-
describe('getBreakpointFromScreenWidth', () => {
|
48
|
-
it('should return correct breakpoints based on screen width', () => {
|
49
|
-
const breakpoints = {
|
50
|
-
xs: 0,
|
51
|
-
sm: 300,
|
52
|
-
md: 500,
|
53
|
-
xl: 1200
|
54
|
-
};
|
55
|
-
const breakpointPairs = Object.entries(breakpoints);
|
56
|
-
expect(getBreakpointFromScreenWidth(0, breakpointPairs)).toEqual('xs');
|
57
|
-
expect(getBreakpointFromScreenWidth(20, breakpointPairs)).toEqual('xs');
|
58
|
-
expect(getBreakpointFromScreenWidth(100, breakpointPairs)).toEqual('xs');
|
59
|
-
expect(getBreakpointFromScreenWidth(101, breakpointPairs)).toEqual('xs');
|
60
|
-
expect(getBreakpointFromScreenWidth(250, breakpointPairs)).toEqual('xs');
|
61
|
-
expect(getBreakpointFromScreenWidth(300, breakpointPairs)).toEqual('sm');
|
62
|
-
expect(getBreakpointFromScreenWidth(499, breakpointPairs)).toEqual('sm');
|
63
|
-
expect(getBreakpointFromScreenWidth(500, breakpointPairs)).toEqual('md');
|
64
|
-
expect(getBreakpointFromScreenWidth(799, breakpointPairs)).toEqual('md');
|
65
|
-
expect(getBreakpointFromScreenWidth(1200, breakpointPairs)).toEqual('xl');
|
66
|
-
expect(getBreakpointFromScreenWidth(2000, breakpointPairs)).toEqual('xl');
|
67
|
-
});
|
68
|
-
});
|
69
|
-
describe('getValueForBreakpoint', () => {
|
70
|
-
it('should prioritize custom media query', () => {
|
71
|
-
const breakpoint = 'sm';
|
72
|
-
const breakpoints = {
|
73
|
-
xs: 0,
|
74
|
-
sm: 200,
|
75
|
-
md: 500
|
76
|
-
};
|
77
|
-
const breakpointPairs = Object.entries(breakpoints);
|
78
|
-
const style = {
|
79
|
-
':w[, 200]': 'green',
|
80
|
-
':w[201]': 'orange',
|
81
|
-
sm: 'pink'
|
82
|
-
};
|
83
|
-
const screenSize = {
|
84
|
-
width: 200,
|
85
|
-
height: 800
|
86
|
-
};
|
87
|
-
expect(getValueForBreakpoint(style, breakpoint, screenSize, breakpointPairs)).toEqual('green');
|
88
|
-
});
|
89
|
-
});
|
90
|
-
it('should match breakpoint if media query doesnt exist', () => {
|
91
|
-
const breakpoint = 'md';
|
92
|
-
const breakpoints = {
|
93
|
-
xs: 0,
|
94
|
-
sm: 200,
|
95
|
-
md: 500
|
96
|
-
};
|
97
|
-
const breakpointPairs = Object.entries(breakpoints);
|
98
|
-
const style = {
|
99
|
-
':w[, 200]': 'green',
|
100
|
-
':w[201, 499]': 'orange',
|
101
|
-
sm: 'pink',
|
102
|
-
md: 'red'
|
103
|
-
};
|
104
|
-
const screenSize = {
|
105
|
-
width: 500,
|
106
|
-
height: 1200
|
107
|
-
};
|
108
|
-
expect(getValueForBreakpoint(style, breakpoint, screenSize, breakpointPairs)).toEqual('red');
|
109
|
-
});
|
110
|
-
it('should match breakpoint even if value is undefined', () => {
|
111
|
-
const breakpoint = 'md';
|
112
|
-
const breakpoints = {
|
113
|
-
xs: 0,
|
114
|
-
sm: 200,
|
115
|
-
md: 500
|
116
|
-
};
|
117
|
-
const breakpointPairs = Object.entries(breakpoints);
|
118
|
-
const style = {
|
119
|
-
':w[, 200]': 'green',
|
120
|
-
':w[201, 499]': 'orange',
|
121
|
-
sm: 'pink',
|
122
|
-
md: undefined
|
123
|
-
};
|
124
|
-
const screenSize = {
|
125
|
-
width: 500,
|
126
|
-
height: 1200
|
127
|
-
};
|
128
|
-
expect(getValueForBreakpoint(style, breakpoint, screenSize, breakpointPairs)).toEqual(undefined);
|
129
|
-
});
|
130
|
-
it('should match lower breakpoint to match css cascading', () => {
|
131
|
-
const breakpoint = 'xl';
|
132
|
-
const breakpoints = {
|
133
|
-
xs: 0,
|
134
|
-
sm: 200,
|
135
|
-
md: 500,
|
136
|
-
xl: 600
|
137
|
-
};
|
138
|
-
const breakpointPairs = Object.entries(breakpoints);
|
139
|
-
const style = {
|
140
|
-
':w[, 200]': 'green',
|
141
|
-
':w[201, 499]': 'orange',
|
142
|
-
sm: 'pink',
|
143
|
-
md: 'red'
|
144
|
-
};
|
145
|
-
const screenSize = {
|
146
|
-
width: 500,
|
147
|
-
height: 1200
|
148
|
-
};
|
149
|
-
expect(getValueForBreakpoint(style, breakpoint, screenSize, breakpointPairs)).toEqual('red');
|
150
|
-
});
|
151
|
-
});
|
152
|
-
//# sourceMappingURL=breakpoints.spec.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["getBreakpointFromScreenWidth","getValueForBreakpoint","sortAndValidateBreakpoints","describe","it","breakpoints","expect","toThrow","sm","md","lg","xl","toEqual","xs","breakpointPairs","Object","entries","breakpoint","style","screenSize","width","height","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.spec.ts"],"mappings":"AAAA,SAASA,4BAA4B,EAAEC,qBAAqB,EAAEC,0BAA0B,QAAQ,eAAe;AAG/GC,QAAQ,CAAC,aAAa,EAAE,MAAM;EAC1BA,QAAQ,CAAC,4BAA4B,EAAE,MAAM;IACzCC,EAAE,CAAC,0CAA0C,EAAE,MAAM;MACjD,MAAMC,WAAW,GAAG,CAAC,CAAC;MAEtBC,MAAM,CAAC,MAAMJ,0BAA0B,CAACG,WAAW,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC;IAEFH,EAAE,CAAC,6DAA6D,EAAE,MAAM;MACpE,MAAMC,WAAW,GAAG;QAChBG,EAAE,EAAE,CAAC;MACT,CAAC;MAEDF,MAAM,CAAC,MAAMJ,0BAA0B,CAACG,WAAW,CAAC,CAAC,CAACE,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC;IAEFH,EAAE,CAAC,8CAA8C,EAAE,MAAM;MACrD,MAAMC,WAAW,GAAG;QAChBG,EAAE,EAAE,CAAC;QACLC,EAAE,EAAE,GAAG;QACPC,EAAE,EAAE,GAAG;QACPC,EAAE,EAAE;MACR,CAAC;MAEDL,MAAM,CAACJ,0BAA0B,CAACG,WAAW,CAAC,CAAC,CAACO,OAAO,CAACP,WAAW,CAAC;IACxE,CAAC,CAAC;IAEFD,EAAE,CAAC,sCAAsC,EAAE,MAAM;MAC7C,MAAMC,WAAW,GAAG;QAChBI,EAAE,EAAE,GAAG;QACPD,EAAE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S,CAAC;EACpG,CAAC,CAAC;EAEFlB,EAAE,CAAC,sDAAsD,EAAE,MAAM;IAC7D,MAAMa,UAAU,GAAG,IAAI;IACvB,MAAMZ,WAAW,GAAG;MAChBQ,EAAE,EAAE,CAAC;MACLL,EAAE,EAAE,GAAG;MACPC,EAAE,EAAE,GAAG;MACPE,EAAE,EAAE;IACR,CAAC;IACD,MAAMG,eAAe,GAAGC,MAAM,CACzBC,OAAO,CAACX,WAAW,CAAgD;IACxE,MAAMa,KAAyC,GAAG;MAC9C,WAAW,EAAE,OAAO;MACpB,cAAc,EAAE,QAAQ;MACxBV,EAAE,EAAE,MAAM;MACVC,EAAE,EAAE;IACR,CAAC;IACD,MAAMU,UAAsB,GAAG;MAC3BC,KAAK,EAAE,GAAG;MACVC,MAAM,EAAE;IACZ,CAAC;IAEDf,MAAM,CAACL,qBAAqB,CAACiB,KAAK,EAAED,UAAU,EAAEE,UAAU,EAAEL,eAAe,CAAC,CAAC,CAACF,OAAO,CAAC,KAAK,CAAC;EAChG,CAAC,CAAC;AACN,CAAC,CAAC"}
|
@@ -1,218 +0,0 @@
|
|
1
|
-
import { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
|
2
|
-
describe('utils', () => {
|
3
|
-
describe('extractValues', () => {
|
4
|
-
it('should correctly extract a width with both bounds', () => {
|
5
|
-
const mediaQuery = 'w[100, 600]';
|
6
|
-
expect(extractValues(mediaQuery)).toEqual([100, 600]);
|
7
|
-
});
|
8
|
-
it('should correctly extract a width with lower bound equal to 0', () => {
|
9
|
-
const mediaQuery = 'w[0, 400]';
|
10
|
-
expect(extractValues(mediaQuery)).toEqual([0, 400]);
|
11
|
-
});
|
12
|
-
it('should correctly extract a height with single value', () => {
|
13
|
-
const mediaQuery = 'h[700]';
|
14
|
-
expect(extractValues(mediaQuery)).toEqual([700]);
|
15
|
-
});
|
16
|
-
it('should correctly extract a height with lower bound equal to 0', () => {
|
17
|
-
const mediaQuery = 'h[0,]';
|
18
|
-
expect(extractValues(mediaQuery)).toEqual([0]);
|
19
|
-
});
|
20
|
-
it('should correctly extract a width with no lower bound', () => {
|
21
|
-
const mediaQuery = 'w[,100]';
|
22
|
-
expect(extractValues(mediaQuery)).toEqual([0, 100]);
|
23
|
-
});
|
24
|
-
});
|
25
|
-
describe('isWithinTheWidth', () => {
|
26
|
-
it('should return true if the screen width is within the media query', () => {
|
27
|
-
const pairs = [{
|
28
|
-
width: 200,
|
29
|
-
query: 'w[120]'
|
30
|
-
}, {
|
31
|
-
width: 100,
|
32
|
-
query: 'w[,500]'
|
33
|
-
}, {
|
34
|
-
width: 0,
|
35
|
-
query: 'w[,500]'
|
36
|
-
}, {
|
37
|
-
width: 300,
|
38
|
-
query: 'w[300,500]'
|
39
|
-
}];
|
40
|
-
pairs.forEach(_ref => {
|
41
|
-
let {
|
42
|
-
width,
|
43
|
-
query
|
44
|
-
} = _ref;
|
45
|
-
expect(isWithinTheWidth(query, width)).toEqual(true);
|
46
|
-
});
|
47
|
-
});
|
48
|
-
it('should return false if the screen width is outside the media query', () => {
|
49
|
-
const pairs = [{
|
50
|
-
width: 120,
|
51
|
-
query: 'w[200]'
|
52
|
-
}, {
|
53
|
-
width: 501,
|
54
|
-
query: 'w[,500]'
|
55
|
-
}, {
|
56
|
-
width: 700,
|
57
|
-
query: 'w[200,500]'
|
58
|
-
}];
|
59
|
-
pairs.forEach(_ref2 => {
|
60
|
-
let {
|
61
|
-
width,
|
62
|
-
query
|
63
|
-
} = _ref2;
|
64
|
-
expect(isWithinTheWidth(query, width)).toEqual(false);
|
65
|
-
});
|
66
|
-
});
|
67
|
-
});
|
68
|
-
describe('isWithinTheHeight', () => {
|
69
|
-
it('should return true if the screen height is within the media query', () => {
|
70
|
-
const pairs = [{
|
71
|
-
height: 200,
|
72
|
-
query: 'h[120]'
|
73
|
-
}, {
|
74
|
-
height: 100,
|
75
|
-
query: 'h[,500]'
|
76
|
-
}, {
|
77
|
-
height: 0,
|
78
|
-
query: 'h[,500]'
|
79
|
-
}, {
|
80
|
-
height: 300,
|
81
|
-
query: 'h[300,500]'
|
82
|
-
}];
|
83
|
-
pairs.forEach(_ref3 => {
|
84
|
-
let {
|
85
|
-
height,
|
86
|
-
query
|
87
|
-
} = _ref3;
|
88
|
-
expect(isWithinTheHeight(query, height)).toEqual(true);
|
89
|
-
});
|
90
|
-
});
|
91
|
-
it('should return false if the screen height is outside the media query', () => {
|
92
|
-
const pairs = [{
|
93
|
-
height: 120,
|
94
|
-
query: 'h[200]'
|
95
|
-
}, {
|
96
|
-
height: 501,
|
97
|
-
query: 'h[,500]'
|
98
|
-
}, {
|
99
|
-
height: 700,
|
100
|
-
query: 'h[200,500]'
|
101
|
-
}];
|
102
|
-
pairs.forEach(_ref4 => {
|
103
|
-
let {
|
104
|
-
height,
|
105
|
-
query
|
106
|
-
} = _ref4;
|
107
|
-
expect(isWithinTheHeight(query, height)).toEqual(false);
|
108
|
-
});
|
109
|
-
});
|
110
|
-
});
|
111
|
-
describe('isWithinTheWidthAndHeight', () => {
|
112
|
-
it('should return true if the screen width and height are within the media query', () => {
|
113
|
-
const pairs = [{
|
114
|
-
screenSize: {
|
115
|
-
width: 200,
|
116
|
-
height: 600
|
117
|
-
},
|
118
|
-
query: 'w[, 200]:h[600]'
|
119
|
-
}, {
|
120
|
-
screenSize: {
|
121
|
-
width: 200,
|
122
|
-
height: 600
|
123
|
-
},
|
124
|
-
query: 'w[110]:h[400]'
|
125
|
-
}, {
|
126
|
-
screenSize: {
|
127
|
-
width: 400,
|
128
|
-
height: 800
|
129
|
-
},
|
130
|
-
query: 'w[400, 800]:h[400, 800]'
|
131
|
-
}];
|
132
|
-
pairs.forEach(_ref5 => {
|
133
|
-
let {
|
134
|
-
screenSize,
|
135
|
-
query
|
136
|
-
} = _ref5;
|
137
|
-
expect(isWithinTheWidthAndHeight(query, screenSize)).toEqual(true);
|
138
|
-
});
|
139
|
-
});
|
140
|
-
it('should return false if the screen width and height are outside the media query', () => {
|
141
|
-
const pairs = [{
|
142
|
-
screenSize: {
|
143
|
-
width: 200,
|
144
|
-
height: 600
|
145
|
-
},
|
146
|
-
query: 'w[, 220]:h[620]'
|
147
|
-
}, {
|
148
|
-
screenSize: {
|
149
|
-
width: 200,
|
150
|
-
height: 600
|
151
|
-
},
|
152
|
-
query: 'w[290]:h[400]'
|
153
|
-
}, {
|
154
|
-
screenSize: {
|
155
|
-
width: 400,
|
156
|
-
height: 800
|
157
|
-
},
|
158
|
-
query: 'w[, 800]:h[, 700]'
|
159
|
-
}];
|
160
|
-
pairs.forEach(_ref6 => {
|
161
|
-
let {
|
162
|
-
screenSize,
|
163
|
-
query
|
164
|
-
} = _ref6;
|
165
|
-
expect(isWithinTheWidthAndHeight(query, screenSize)).toEqual(false);
|
166
|
-
});
|
167
|
-
});
|
168
|
-
});
|
169
|
-
describe('isMediaQuery', () => {
|
170
|
-
it('should detect correct media queries', () => {
|
171
|
-
const correctMediaQueries = [':w[100]', ':w[100, 200]', ':w[, 300]', ':h[200]', ':h[0, 500]', ':h[, 750]', ':w[100]:h[200]', ':h[100]:w[200]', ':h[100, 200]:w[,400]', ':w[200]:h[200, 400]'];
|
172
|
-
correctMediaQueries.forEach(query => {
|
173
|
-
expect(isMediaQuery(query)).toEqual(true);
|
174
|
-
});
|
175
|
-
});
|
176
|
-
it('should detect incorrect media queries', () => {
|
177
|
-
const incorrectMediaQueries = [':w100]', ':w[100, 200', ':p[, 300]', ':&[200]', ':h[0 500]', ':h[p, 750]', ':w[0]:l[200]', ':[100]:w[200]', ':h(100, 200):w[400]', ':w[2OO]:h[200, 400]', '', 'x', '>300', ']]w200[[', ':w[ 100]', ':w[ , 300]', ':w[ , 200]:h[ 200 , 400]'];
|
178
|
-
incorrectMediaQueries.forEach(query => {
|
179
|
-
expect(isMediaQuery(query)).toEqual(false);
|
180
|
-
});
|
181
|
-
});
|
182
|
-
});
|
183
|
-
describe('getKeyForCustomMediaQuery', () => {
|
184
|
-
it('should return a key for string value based on media query', () => {
|
185
|
-
const mediaQueries = [['w[,200]', 'orange'], ['w[300, 400]', 'pink'], ['w[500, 600]', 'red']];
|
186
|
-
const screenSize = {
|
187
|
-
width: 300,
|
188
|
-
height: 700
|
189
|
-
};
|
190
|
-
expect(getKeyForCustomMediaQuery(mediaQueries, screenSize)).toEqual('w[300, 400]');
|
191
|
-
});
|
192
|
-
it('should return a key for number value based on media query', () => {
|
193
|
-
const mediaQueries = [['w[,200]', 200], ['w[250]', 300]];
|
194
|
-
const screenSize = {
|
195
|
-
width: 300,
|
196
|
-
height: 700
|
197
|
-
};
|
198
|
-
expect(getKeyForCustomMediaQuery(mediaQueries, screenSize)).toEqual('w[250]');
|
199
|
-
});
|
200
|
-
it('should return undefined for no match', () => {
|
201
|
-
const mediaQueries = [['w[,400]', 'green'], ['w[500, 999]', 'olive'], ['w[1000]', 'red']];
|
202
|
-
const screenSize = {
|
203
|
-
width: 450,
|
204
|
-
height: 1000
|
205
|
-
};
|
206
|
-
expect(getKeyForCustomMediaQuery(mediaQueries, screenSize)).toEqual(undefined);
|
207
|
-
});
|
208
|
-
it('should handle correctly complex media queries', () => {
|
209
|
-
const mediaQueries = [['w[,300]:h[200,700]', 200], ['w[250]:h[701]', 300], ['w[200]', 500]];
|
210
|
-
const screenSize = {
|
211
|
-
width: 300,
|
212
|
-
height: 700
|
213
|
-
};
|
214
|
-
expect(getKeyForCustomMediaQuery(mediaQueries, screenSize)).toEqual('w[,300]:h[200,700]');
|
215
|
-
});
|
216
|
-
});
|
217
|
-
});
|
218
|
-
//# sourceMappingURL=mediaQueries.spec.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["extractValues","getKeyForCustomMediaQuery","isMediaQuery","isWithinTheHeight","isWithinTheWidth","isWithinTheWidthAndHeight","describe","it","mediaQuery","expect","toEqual","pairs","width","query","forEach","_ref","_ref2","height","_ref3","_ref4","screenSize","_ref5","_ref6","correctMediaQueries","incorrectMediaQueries","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G;QACVK,MAAM,EAAE;MACZ,CAAC;MAEDR,MAAM,CAACR,yBAAyB,CAACwB,YAAY,EAAEL,UAAU,CAAC,CAAC,CAACV,OAAO,CAAC,QAAQ,CAAC;IACjF,CAAC,CAAC;IAEFH,EAAE,CAAC,sCAAsC,EAAE,MAAM;MAC7C,MAAMkB,YAAY,GAAG,CACjB,CAAC,SAAS,EAAE,OAAO,CAAC,EACpB,CAAC,aAAa,EAAE,OAAO,CAAC,EACxB,CAAC,SAAS,EAAE,KAAK,CAAC,CACe;MACrC,MAAML,UAAsB,GAAG;QAC3BR,KAAK,EAAE,GAAG;QACVK,MAAM,EAAE;MACZ,CAAC;MAEDR,MAAM,CAACR,yBAAyB,CAACwB,YAAY,EAAEL,UAAU,CAAC,CAAC,CAACV,OAAO,CAACgB,SAAS,CAAC;IAClF,CAAC,CAAC;IAEFnB,EAAE,CAAC,+CAA+C,EAAE,MAAM;MACtD,MAAMkB,YAAY,GAAG,CACjB,CAAC,oBAAoB,EAAE,GAAG,CAAC,EAC3B,CAAC,eAAe,EAAE,GAAG,CAAC,EACtB,CAAC,QAAQ,EAAE,GAAG,CAAC,CACkB;MACrC,MAAML,UAAsB,GAAG;QAC3BR,KAAK,EAAE,GAAG;QACVK,MAAM,EAAE;MACZ,CAAC;MAEDR,MAAM,CAACR,yBAAyB,CAACwB,YAAY,EAAEL,UAAU,CAAC,CAAC,CAACV,OAAO,CAAC,oBAAoB,CAAC;IAC7F,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC"}
|
@@ -1,172 +0,0 @@
|
|
1
|
-
import { parseStyle, proxifyFunction } from './styles';
|
2
|
-
describe('styles', () => {
|
3
|
-
describe('proxifyFunction', () => {
|
4
|
-
it('should parse style for dynamic function', () => {
|
5
|
-
const screenSize = {
|
6
|
-
width: 400,
|
7
|
-
height: 800
|
8
|
-
};
|
9
|
-
const breakpoint = 'sm';
|
10
|
-
const breakpoints = {
|
11
|
-
xs: 0,
|
12
|
-
sm: 400,
|
13
|
-
md: 800
|
14
|
-
};
|
15
|
-
const breakpointPairs = Object.entries(breakpoints);
|
16
|
-
const dynamicFunction = isEven => ({
|
17
|
-
backgroundColor: {
|
18
|
-
sm: isEven ? 'green' : 'red',
|
19
|
-
md: isEven ? 'orange' : 'pink'
|
20
|
-
}
|
21
|
-
});
|
22
|
-
expect(proxifyFunction(dynamicFunction, breakpoint, screenSize, breakpointPairs)(true)).toEqual({
|
23
|
-
backgroundColor: 'green'
|
24
|
-
});
|
25
|
-
});
|
26
|
-
it('should return proxified function for custom media query', () => {
|
27
|
-
const screenSize = {
|
28
|
-
width: 400,
|
29
|
-
height: 800
|
30
|
-
};
|
31
|
-
const breakpoint = 'sm';
|
32
|
-
const breakpoints = {
|
33
|
-
xs: 0,
|
34
|
-
sm: 400,
|
35
|
-
md: 800
|
36
|
-
};
|
37
|
-
const breakpointPairs = Object.entries(breakpoints);
|
38
|
-
const dynamicFunction = isEven => ({
|
39
|
-
backgroundColor: {
|
40
|
-
':w[,399]': isEven ? 'green' : 'red',
|
41
|
-
':w[400]': isEven ? 'orange' : 'pink'
|
42
|
-
}
|
43
|
-
});
|
44
|
-
expect(proxifyFunction(dynamicFunction, breakpoint, screenSize, breakpointPairs)(false)).toEqual({
|
45
|
-
backgroundColor: 'pink'
|
46
|
-
});
|
47
|
-
});
|
48
|
-
it('should return same function for no breakpoints nor media queries', () => {
|
49
|
-
const screenSize = {
|
50
|
-
width: 400,
|
51
|
-
height: 800
|
52
|
-
};
|
53
|
-
const breakpoint = 'sm';
|
54
|
-
const breakpoints = {
|
55
|
-
xs: 0,
|
56
|
-
sm: 400,
|
57
|
-
md: 800
|
58
|
-
};
|
59
|
-
const breakpointPairs = Object.entries(breakpoints);
|
60
|
-
const dynamicFunction = isEven => ({
|
61
|
-
backgroundColor: isEven ? 'pink' : 'purple'
|
62
|
-
});
|
63
|
-
expect(proxifyFunction(dynamicFunction, breakpoint, screenSize, breakpointPairs)(false)).toEqual({
|
64
|
-
backgroundColor: 'purple'
|
65
|
-
});
|
66
|
-
});
|
67
|
-
});
|
68
|
-
describe('parseStyle', () => {
|
69
|
-
it('should correctly parse styles', () => {
|
70
|
-
const screenSize = {
|
71
|
-
width: 400,
|
72
|
-
height: 800
|
73
|
-
};
|
74
|
-
const breakpoint = 'sm';
|
75
|
-
const breakpoints = {
|
76
|
-
xs: 0,
|
77
|
-
sm: 400,
|
78
|
-
md: 800
|
79
|
-
};
|
80
|
-
const breakpointPairs = Object.entries(breakpoints);
|
81
|
-
const style = {
|
82
|
-
fontSize: {
|
83
|
-
sm: 12,
|
84
|
-
md: 20
|
85
|
-
},
|
86
|
-
backgroundColor: {
|
87
|
-
xs: 'pink',
|
88
|
-
md: 'orange'
|
89
|
-
},
|
90
|
-
fontWeight: 'bold'
|
91
|
-
};
|
92
|
-
const parsedStyles = parseStyle(style, breakpoint, screenSize, breakpointPairs);
|
93
|
-
expect(parsedStyles).toEqual({
|
94
|
-
fontSize: 12,
|
95
|
-
backgroundColor: 'pink',
|
96
|
-
fontWeight: 'bold'
|
97
|
-
});
|
98
|
-
});
|
99
|
-
it('should correctly parse transform styles', () => {
|
100
|
-
const screenSize = {
|
101
|
-
width: 400,
|
102
|
-
height: 800
|
103
|
-
};
|
104
|
-
const breakpoint = 'sm';
|
105
|
-
const breakpoints = {
|
106
|
-
xs: 0,
|
107
|
-
sm: 400,
|
108
|
-
md: 800
|
109
|
-
};
|
110
|
-
const breakpointPairs = Object.entries(breakpoints);
|
111
|
-
const style = {
|
112
|
-
transform: [{
|
113
|
-
translateX: {
|
114
|
-
sm: 120,
|
115
|
-
md: 200
|
116
|
-
},
|
117
|
-
translateY: 200
|
118
|
-
}]
|
119
|
-
};
|
120
|
-
const parsedStyles = parseStyle(style, breakpoint, screenSize, breakpointPairs);
|
121
|
-
expect(parsedStyles).toEqual({
|
122
|
-
transform: [{
|
123
|
-
translateX: 120,
|
124
|
-
translateY: 200
|
125
|
-
}]
|
126
|
-
});
|
127
|
-
});
|
128
|
-
it('should correctly parse shadowOffset styles', () => {
|
129
|
-
const screenSize = {
|
130
|
-
width: 400,
|
131
|
-
height: 800
|
132
|
-
};
|
133
|
-
const breakpoint = 'sm';
|
134
|
-
const breakpoints = {
|
135
|
-
xs: 0,
|
136
|
-
sm: 400,
|
137
|
-
md: 800
|
138
|
-
};
|
139
|
-
const breakpointPairs = Object.entries(breakpoints);
|
140
|
-
const style = {
|
141
|
-
shadowOffset: {
|
142
|
-
width: 0,
|
143
|
-
height: 4
|
144
|
-
}
|
145
|
-
};
|
146
|
-
const styleWithBreakpoints = {
|
147
|
-
shadowOffset: {
|
148
|
-
width: 0,
|
149
|
-
height: {
|
150
|
-
sm: 10,
|
151
|
-
md: 20
|
152
|
-
}
|
153
|
-
}
|
154
|
-
};
|
155
|
-
const parsedStyles = parseStyle(style, breakpoint, screenSize, breakpointPairs);
|
156
|
-
const parsedStylesWithBreakpoints = parseStyle(styleWithBreakpoints, breakpoint, screenSize, breakpointPairs);
|
157
|
-
expect(parsedStyles).toEqual({
|
158
|
-
shadowOffset: {
|
159
|
-
width: 0,
|
160
|
-
height: 4
|
161
|
-
}
|
162
|
-
});
|
163
|
-
expect(parsedStylesWithBreakpoints).toEqual({
|
164
|
-
shadowOffset: {
|
165
|
-
width: 0,
|
166
|
-
height: 10
|
167
|
-
}
|
168
|
-
});
|
169
|
-
});
|
170
|
-
});
|
171
|
-
});
|
172
|
-
//# sourceMappingURL=styles.spec.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["parseStyle","proxifyFunction","describe","it","screenSize","width","height","breakpoint","breakpoints","xs","sm","md","breakpointPairs","Object","entries","dynamicFunction","isEven","backgroundColor","expect","toEqual","style","fontSize","fontWeight","parsedStyles","transform","translateX","translateY","shadowOffset","styleWithBreakpoints","parsedStylesWithBreakpoints"],"sourceRoot":"../../../src","sources":["utils/styles.spec.ts"],"mappings":"AAAA,SAASA,UAAU,EAAEC,eAAe,QAAQ,UAAU;AAItDC,QAAQ,CAAC,Q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C,UAAU,GAAG,IAAI;MACvB,MAAMC,WAAW,GAAG;QAChBC,EAAE,EAAE,CAAC;QACLC,EAAE,EAAE,GAAG;QACPC,EAAE,EAAE;MACR,CAAC;MACD,MAAMC,eAAe,GAAGC,MAAM,CACzBC,OAAO,CAACN,WAAW,CAAgD;MACxE,MAAMY,KAAK,GAAG;QACVO,YAAY,EAAE;UACVtB,KAAK,EAAE,CAAC;UACRC,MAAM,EAAE;QACZ;MACJ,CAAC;MACD,MAAMsB,oBAAoB,GAAG;QACzBD,YAAY,EAAE;UACVtB,KAAK,EAAE,CAAC;UACRC,MAAM,EAAE;YACJI,EAAE,EAAE,EAAE;YACNC,EAAE,EAAE;UACR;QACJ;MACJ,CAAC;MAED,MAAMY,YAAY,GAAGvB,UAAU,CAC3BoB,KAAK,EACLb,UAAU,EACVH,UAAU,EACVQ,eACJ,CAAC;MACD,MAAMiB,2BAA2B,GAAG7B,UAAU,CAC1C4B,oBAAoB,EACpBrB,UAAU,EACVH,UAAU,EACVQ,eACJ,CAAC;MAEDM,MAAM,CAACK,YAAY,CAAC,CAACJ,OAAO,CAAC;QACzBQ,YAAY,EAAE;UACVtB,KAAK,EAAE,CAAC;UACRC,MAAM,EAAE;QACZ;MACJ,CAAC,CAAC;MACFY,MAAM,CAACW,2BAA2B,CAAC,CAACV,OAAO,CAAC;QACxCQ,YAAY,EAAE;UACVtB,KAAK,EAAE,CAAC;UACRC,MAAM,EAAE;QACZ;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC,CAAC"}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
export type MediaQueries = `:w[${bigint}]` | `:w[,${bigint}]` | `:w[${bigint},${bigint}]` | `:h[${bigint}]` | `:h[,${bigint}]` | `:h[${bigint},${bigint}]` | `:w[${bigint}]:h[${bigint}]` | `:w[${bigint},${bigint}]:h[${bigint}]` | `:w[${bigint}]:h[${bigint},${bigint}]` | `:w[${bigint},${bigint}]:h[${bigint},${bigint}]` | `:w[,${bigint}]:h[,${bigint}]` | `:w[,${bigint}]:h[${bigint}]` | `:w[${bigint}]:h[,${bigint}]` | `:w[,${bigint}]:h[${bigint},${bigint}]` | `:w[${bigint},${bigint}]:h[,${bigint}]` | `:h[${bigint}]:w[${bigint}]` | `:h[${bigint},${bigint}]:w[${bigint}]` | `:h[${bigint}]:w[${bigint},${bigint}]` | `:h[${bigint},${bigint}]:w[${bigint},${bigint}]` | `:h[,${bigint}]:w[,${bigint}]` | `:h[,${bigint}]:w[${bigint}]` | `:h[${bigint}]:w[,${bigint}]` | `:h[,${bigint}]:w[${bigint},${bigint}]` | `:h[${bigint},${bigint}]:w[,${bigint}]`;
|
2
|
-
//# sourceMappingURL=mediaQueries.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"mediaQueries.d.ts","sourceRoot":"","sources":["../../../src/mediaQueries.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,YAAY,GAExB,MAAM,MAAM,GAAG,GACf,OAAO,MAAM,GAAG,GAChB,MAAM,MAAM,IAAI,MAAM,GAAG,GAGzB,MAAM,MAAM,GAAG,GACf,OAAO,MAAM,GAAG,GAChB,MAAM,MAAM,IAAI,MAAM,GAAG,GAGzB,MAAM,MAAM,OAAO,MAAM,GAAG,GAC5B,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,GAAG,GACtC,MAAM,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GACtC,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GAChD,OAAO,MAAM,QAAQ,MAAM,GAAG,GAC9B,OAAO,MAAM,OAAO,MAAM,GAAG,GAC7B,MAAM,MAAM,QAAQ,MAAM,GAAG,GAC7B,OAAO,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GACvC,MAAM,MAAM,IAAI,MAAM,QAAQ,MAAM,GAAG,GAGvC,MAAM,MAAM,OAAO,MAAM,GAAG,GAC5B,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,GAAG,GACtC,MAAM,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GACtC,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GAChD,OAAO,MAAM,QAAQ,MAAM,GAAG,GAC9B,OAAO,MAAM,OAAO,MAAM,GAAG,GAC7B,MAAM,MAAM,QAAQ,MAAM,GAAG,GAC7B,OAAO,MAAM,OAAO,MAAM,IAAI,MAAM,GAAG,GACvC,MAAM,MAAM,IAAI,MAAM,QAAQ,MAAM,GAAG,CAAA"}
|
@@ -1,67 +0,0 @@
|
|
1
|
-
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
2
|
-
import type { MatrixTransform, PerpectiveTransform, RotateTransform, RotateXTransform, RotateYTransform, RotateZTransform, ScaleTransform, ScaleXTransform, ScaleYTransform, SkewXTransform, SkewYTransform, TranslateXTransform, TranslateYTransform } from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
|
3
|
-
import type { MediaQueries } from './mediaQueries';
|
4
|
-
export type Breakpoints = Record<string, number>;
|
5
|
-
export type SortedBreakpointEntries<B extends Breakpoints> = [[keyof B & string, number]];
|
6
|
-
export type ScreenSize = {
|
7
|
-
width: number;
|
8
|
-
height: number;
|
9
|
-
};
|
10
|
-
export type CreateStylesFactory<ST, Theme> = (theme: Theme) => ST;
|
11
|
-
type StyleProperty<T, B extends Breakpoints> = {
|
12
|
-
[K in keyof T]: {
|
13
|
-
[innerKey in keyof B]?: T[K];
|
14
|
-
} | {
|
15
|
-
[innerKey in MediaQueries]?: T[K];
|
16
|
-
} | T[K];
|
17
|
-
};
|
18
|
-
type ShadowOffsetProps<B> = {
|
19
|
-
shadowOffset: {
|
20
|
-
width: number | {
|
21
|
-
[innerKey in keyof B]?: number;
|
22
|
-
} | {
|
23
|
-
[innerKey in MediaQueries]: number;
|
24
|
-
};
|
25
|
-
height: number | {
|
26
|
-
[innerKey in keyof B]?: number;
|
27
|
-
} | {
|
28
|
-
[innerKey in MediaQueries]: number;
|
29
|
-
};
|
30
|
-
};
|
31
|
-
};
|
32
|
-
type TextShadowOffsetProps<B> = {
|
33
|
-
textShadowOffset: {
|
34
|
-
width: number | {
|
35
|
-
[innerKey in keyof B]?: number;
|
36
|
-
} | {
|
37
|
-
[innerKey in MediaQueries]: number;
|
38
|
-
};
|
39
|
-
height: number | {
|
40
|
-
[innerKey in keyof B]?: number;
|
41
|
-
} | {
|
42
|
-
[innerKey in MediaQueries]: number;
|
43
|
-
};
|
44
|
-
};
|
45
|
-
};
|
46
|
-
type TransformStyles<B extends Breakpoints> = PerpectiveTransform | StyleProperty<PerpectiveTransform, B> | RotateTransform | StyleProperty<RotateTransform, B> | RotateXTransform | StyleProperty<RotateXTransform, B> | RotateYTransform | StyleProperty<RotateYTransform, B> | RotateZTransform | StyleProperty<RotateZTransform, B> | ScaleTransform | StyleProperty<ScaleTransform, B> | ScaleXTransform | StyleProperty<ScaleXTransform, B> | ScaleYTransform | StyleProperty<ScaleYTransform, B> | TranslateXTransform | StyleProperty<TranslateXTransform, B> | TranslateYTransform | StyleProperty<TranslateYTransform, B> | SkewXTransform | StyleProperty<SkewXTransform, B> | SkewYTransform | StyleProperty<SkewYTransform, B> | MatrixTransform | StyleProperty<MatrixTransform, B>;
|
47
|
-
type TransformProps<B extends Breakpoints> = {
|
48
|
-
transform: Array<TransformStyles<B>>;
|
49
|
-
};
|
50
|
-
type UnistyleView = Omit<Omit<Omit<ViewStyle, 'shadowOffset'>, 'transform'>, 'textShadowOffset'>;
|
51
|
-
type UnistyleText = Omit<Omit<Omit<TextStyle, 'shadowOffset'>, 'transform'>, 'textShadowOffset'>;
|
52
|
-
type UnistyleImage = Omit<Omit<Omit<ImageStyle, 'shadowOffset'>, 'transform'>, 'textShadowOffset'>;
|
53
|
-
export type StaticStyles<B extends Breakpoints> = (UnistyleView | StyleProperty<UnistyleView, B>) | (UnistyleText | StyleProperty<UnistyleText, B>) | (UnistyleImage | StyleProperty<UnistyleImage, B>) & TransformProps<B> & ShadowOffsetProps<B> & TextShadowOffsetProps<B>;
|
54
|
-
export type CustomNamedStyles<T, B extends Breakpoints> = {
|
55
|
-
[K in keyof T]: T[K] extends (...args: infer A) => unknown ? (...args: A) => StaticStyles<B> : StaticStyles<B>;
|
56
|
-
};
|
57
|
-
type WithEmptyObject<V> = keyof V extends never ? {} : V;
|
58
|
-
export type ExtractBreakpoints<T, B extends Breakpoints> = T extends Partial<Record<keyof B & string, infer V>> ? WithEmptyObject<V> : T extends (...args: infer A) => infer R ? (...args: A) => ExtractBreakpoints<R, B> : {
|
59
|
-
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => ExtractBreakpoints<R, B> : T[K] extends object ? ExtractBreakpoints<T[K], B> : T[K];
|
60
|
-
};
|
61
|
-
export type RemoveKeysWithPrefix<T, B extends Breakpoints> = T extends (...args: Array<any>) => infer R ? (...args: Parameters<T>) => RemoveKeysWithPrefix<R, B> : T extends object ? T extends Record<string, infer _V> ? {
|
62
|
-
[K in keyof T as K extends MediaQueries ? keyof B & string : K]: RemoveKeysWithPrefix<T[K], B>;
|
63
|
-
} : {
|
64
|
-
[K in keyof T]: RemoveKeysWithPrefix<T[K], B>;
|
65
|
-
} : T;
|
66
|
-
export {};
|
67
|
-
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,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