@ovotech/element-native 3.3.1 → 3.3.2-canary-51af19f-615

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.
@@ -0,0 +1,330 @@
1
+ import deepMerge from 'deepmerge';
2
+ var brand = {
3
+ focus: { base: '#3F64E6' },
4
+ primary: {
5
+ muted: '#E7F3EA',
6
+ lightest: '#B6D727',
7
+ lighter: '#9DC431',
8
+ light: '#6CBD27',
9
+ base: '#0D8426',
10
+ dark: '#0D8426',
11
+ darker: '#006945',
12
+ },
13
+ grey: {
14
+ lightest: '#FFFFFF',
15
+ lighter: '#F9F9F9',
16
+ light: '#F3F3F3',
17
+ base: '#D1D6DE',
18
+ dark: '#666D78',
19
+ darker: '#2F3749',
20
+ darkest: '#111111',
21
+ },
22
+ mission: {
23
+ base: '#DE1D8D',
24
+ dark: '#C6187D',
25
+ },
26
+ complementary: {
27
+ base: '#197278',
28
+ },
29
+ electricity: {
30
+ base: '#E7A234',
31
+ dark: '#D1760A',
32
+ },
33
+ gas: {
34
+ base: '#26ADE4',
35
+ dark: '#3F64E6',
36
+ },
37
+ error: {
38
+ lightest: '#FAE8EC',
39
+ base: '#C7153E',
40
+ dark: '#8C0A28',
41
+ },
42
+ };
43
+ export var defaultTokens = {
44
+ borderWidths: {
45
+ standard: '1px',
46
+ heavy: '2px',
47
+ heavier: '4px',
48
+ },
49
+ radii: {
50
+ small: '4px',
51
+ medium: '8px',
52
+ large: '12px',
53
+ },
54
+ shadows: {
55
+ standard: {
56
+ color: '#000',
57
+ offset: '1px',
58
+ opacity: 0.15,
59
+ radius: '4px',
60
+ elevation: 3,
61
+ },
62
+ },
63
+ breakpoints: { small: 576, medium: 768, large: 1200 },
64
+ space: {
65
+ 1: '4px',
66
+ 2: '8px',
67
+ 3: '12px',
68
+ 4: '16px',
69
+ 5: '20px',
70
+ 6: '24px',
71
+ 7: '28px',
72
+ 8: '32px',
73
+ 9: '36px',
74
+ 10: '40px',
75
+ 11: '44px',
76
+ 12: '48px',
77
+ },
78
+ fonts: {
79
+ body: 'OVOCircularTT-Book',
80
+ bold: 'OVOCircularTT-Bold',
81
+ heading: 'OVOCircularTT-Black',
82
+ },
83
+ lineHeights: {
84
+ standard: 1.5,
85
+ },
86
+ fontSizes: ['12px', '14px', '16px', '20px', '24px', '28px', '32px', '48px'],
87
+ colors: {
88
+ primary: brand.primary.base,
89
+ primaryAlt: brand.primary.darker,
90
+ primaryContrast: '#FFFFFF',
91
+ primaryMuted: brand.primary.muted,
92
+ error: '#C7153E',
93
+ errorAlt: '#8C0A28',
94
+ errorContrast: '#FFFFFF',
95
+ errorMuted: '#FAE8EC',
96
+ focus: '#3F64E6',
97
+ focusMuted: '#C6D1F8',
98
+ canvas: '#FFFFFF',
99
+ body: brand.grey.darker,
100
+ heading: brand.grey.darker,
101
+ border: brand.grey.dark,
102
+ canvasMuted: '#F0F2F5',
103
+ borderMuted: brand.grey.base,
104
+ info: '#3F64E6',
105
+ infoAlt: '#004CA0',
106
+ infoContrast: '#FFFFFF',
107
+ infoMuted: '#ECF0FD',
108
+ warning: '#BE5409',
109
+ warningAlt: '#8A3C05',
110
+ warningContrast: '#FFFFFF',
111
+ warningMuted: '#F7F0E7',
112
+ success: brand.primary.base,
113
+ successAlt: brand.primary.darker,
114
+ successContrast: '#FFFFFF',
115
+ successMuted: brand.primary.muted,
116
+ mission: '#DE1D8D',
117
+ missionMuted: '#FDF4F9',
118
+ missionAlt: '#C6187D',
119
+ missionContrast: '#FFFFFF',
120
+ brand: brand,
121
+ },
122
+ responsiveFontSizes: {
123
+ label: ['11px', '14px'],
124
+ small: ['14px', '14px'],
125
+ body: ['16px', '16px'],
126
+ level1: ['28px', '48px'],
127
+ level2: ['24px', '32px'],
128
+ level3: ['20px', '28px'],
129
+ level4: ['16px', '22px'],
130
+ lead: ['18px', '22px'],
131
+ },
132
+ responsiveLineHeights: {
133
+ label: ['20px', '20px'],
134
+ small: ['20px', '20px'],
135
+ body: ['24px', '24px'],
136
+ level1: ['36px', '52px'],
137
+ level2: ['32px', '40px'],
138
+ level3: ['24px', '36px'],
139
+ level4: ['20px', '28px'],
140
+ lead: ['24px', '28px'],
141
+ },
142
+ };
143
+ export function createTheme(customTheme, additional) {
144
+ var mergeOptions = { arrayMerge: function (_, source) { return source; } };
145
+ var customThemeWithAdditional = deepMerge(customTheme, additional || {}, mergeOptions);
146
+ var theme = deepMerge(defaultTokens, customThemeWithAdditional, mergeOptions);
147
+ var fontSizes = theme.fontSizes, breakpoints = theme.breakpoints, colors = theme.colors, fonts = theme.fonts, lineHeights = theme.lineHeights, space = theme.space, radii = theme.radii, shadows = theme.shadows, borderWidths = theme.borderWidths, responsiveFontSizes = theme.responsiveFontSizes, responsiveLineHeights = theme.responsiveLineHeights;
148
+ return deepMerge({
149
+ field: {
150
+ fontFamily: fonts.body,
151
+ fontSize: responsiveFontSizes.body,
152
+ lineHeight: lineHeights.standard,
153
+ dateWidth: '265px',
154
+ gap: space[2],
155
+ error: {
156
+ color: colors.error,
157
+ fontFamily: fonts.bold,
158
+ },
159
+ hint: {
160
+ color: colors.border,
161
+ },
162
+ label: {
163
+ color: colors.heading,
164
+ fontFamily: fonts.bold,
165
+ },
166
+ subLabel: {
167
+ color: colors.border,
168
+ },
169
+ legend: {
170
+ marginBottom: space[1],
171
+ },
172
+ errorIndent: {
173
+ borderWidth: space[1],
174
+ borderRadius: radii.small,
175
+ },
176
+ },
177
+ focusRing: {
178
+ color: colors.focus,
179
+ width: borderWidths.heavy,
180
+ distance: borderWidths.heavy,
181
+ },
182
+ input: {
183
+ fontFamily: fonts.body,
184
+ fontSize: responsiveFontSizes.body,
185
+ color: colors.body,
186
+ lineHeight: lineHeights.standard,
187
+ height: space[11],
188
+ borderColor: colors.border,
189
+ borderWidth: borderWidths.standard,
190
+ background: colors.canvas,
191
+ padding: space[2],
192
+ borderRadius: radii.small,
193
+ error: {
194
+ borderWidth: borderWidths.heavy,
195
+ color: colors.error,
196
+ },
197
+ icon: {
198
+ size: space[4],
199
+ },
200
+ },
201
+ card: {
202
+ background: colors.canvas,
203
+ borderWidth: borderWidths.standard,
204
+ borderColor: colors.borderMuted,
205
+ padding: [space[3], space[6], space[9]],
206
+ },
207
+ checkbox: {
208
+ touchSize: space[11],
209
+ size: space[6],
210
+ checkSize: space[5],
211
+ gap: space[2],
212
+ paddingTop: space[3],
213
+ borderWidth: borderWidths.standard,
214
+ borderColor: colors.border,
215
+ borderRadius: radii.small,
216
+ background: colors.canvas,
217
+ checkedBackground: colors.infoMuted,
218
+ checkColor: colors.info,
219
+ errorColor: colors.error,
220
+ },
221
+ text: {
222
+ fontFamily: fonts.body,
223
+ lineHeight: 1,
224
+ color: colors.body,
225
+ p: {
226
+ fontSize: responsiveFontSizes.body,
227
+ lineHeight: responsiveLineHeights.body,
228
+ marginTop: [space[3], space[3]],
229
+ marginBottom: [space[3], space[3]],
230
+ },
231
+ small: {
232
+ fontSize: responsiveFontSizes.small,
233
+ lineHeight: responsiveLineHeights.small,
234
+ },
235
+ strong: {
236
+ fontFamily: fonts.bold,
237
+ },
238
+ },
239
+ list: {
240
+ marginTop: [space[2], space[3]],
241
+ marginBottom: [space[2], space[3]],
242
+ marginLeft: space[6],
243
+ listItem: {
244
+ fontSize: responsiveFontSizes.body,
245
+ lineHeight: responsiveLineHeights.body,
246
+ marginVertical: 2,
247
+ bulletGap: space[2],
248
+ bulletWidth: space[2],
249
+ },
250
+ descriptionTerm: {
251
+ color: colors.heading,
252
+ fontFamily: fonts.bold,
253
+ marginTop: [space[3], space[4]],
254
+ marginBottom: [space[1], space[1]],
255
+ },
256
+ },
257
+ textLink: {
258
+ fontFamily: fonts.body,
259
+ color: colors.primary,
260
+ },
261
+ heading: {
262
+ fontFamily: fonts.heading,
263
+ color: colors.heading,
264
+ heading1: {
265
+ fontSize: responsiveFontSizes.level1,
266
+ lineHeight: responsiveLineHeights.level1,
267
+ marginTop: [space[8], space[12]],
268
+ marginBottom: [space[3], space[4]],
269
+ },
270
+ heading2: {
271
+ fontSize: responsiveFontSizes.level2,
272
+ lineHeight: responsiveLineHeights.level2,
273
+ marginTop: [space[6], space[8]],
274
+ marginBottom: [space[3], space[4]],
275
+ },
276
+ heading3: {
277
+ fontSize: responsiveFontSizes.level3,
278
+ lineHeight: responsiveLineHeights.level3,
279
+ marginTop: [space[4], space[6]],
280
+ marginBottom: [space[3], space[4]],
281
+ },
282
+ heading4: {
283
+ fontSize: responsiveFontSizes.level4,
284
+ lineHeight: responsiveLineHeights.level4,
285
+ marginTop: [space[3], space[4]],
286
+ marginBottom: [space[3], space[4]],
287
+ },
288
+ },
289
+ shadows: shadows,
290
+ radii: radii,
291
+ radio: {
292
+ touchSize: space[11],
293
+ size: space[8],
294
+ dotSize: space[5],
295
+ gap: space[2],
296
+ paddingTop: space[3],
297
+ borderWidth: borderWidths.standard,
298
+ borderColor: colors.border,
299
+ background: colors.canvas,
300
+ dotColor: colors.info,
301
+ checkedBackground: colors.infoMuted,
302
+ errorColor: colors.error,
303
+ },
304
+ fontSizes: fontSizes,
305
+ fonts: fonts,
306
+ responsiveFontSizes: responsiveFontSizes,
307
+ responsiveLineHeights: responsiveLineHeights,
308
+ colors: colors,
309
+ borderWidths: borderWidths,
310
+ breakpoints: breakpoints,
311
+ lineHeights: lineHeights,
312
+ space: space,
313
+ grid: {
314
+ maxWidth: breakpoints.large + 'px',
315
+ gutter: [space[4], space[8]],
316
+ },
317
+ disclosure: {
318
+ iconGap: [space[1], space[2]],
319
+ panelGap: [space[2], space[3]],
320
+ },
321
+ accordion: {
322
+ header: {
323
+ color: colors.primary,
324
+ paddingVertical: [space[3], space[5]],
325
+ iconSize: space[4],
326
+ iconGap: space[3],
327
+ },
328
+ },
329
+ }, theme, mergeOptions);
330
+ }
@@ -0,0 +1,19 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { themeNative } from '@ovotech/element-core';
13
+ import { pxToNumber } from '../utils';
14
+ import { createTheme } from './create-theme';
15
+ export * from './create-theme';
16
+ export var theme = createTheme(__assign({}, themeNative));
17
+ export var calculateLineHeight = function (size, lineHeight) {
18
+ return pxToNumber(size) * (lineHeight || 1) + 'px';
19
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { LayoutChangeEvent } from 'react-native';
2
+ export declare const useLayout: (defaultHeight?: number) => readonly [{
3
+ height: number;
4
+ width: number;
5
+ measured: boolean;
6
+ }, (e: LayoutChangeEvent) => void];
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLayout = void 0;
4
+ var react_1 = require("react");
5
+ var useLayout = function (defaultHeight) {
6
+ var _a = (0, react_1.useState)({ height: defaultHeight || 0, width: 0, measured: false }), layout = _a[0], setLayout = _a[1];
7
+ var onLayout = (0, react_1.useCallback)(function (e) {
8
+ var _a = e.nativeEvent.layout, height = _a.height, width = _a.width;
9
+ if (height === layout.height && width === layout.width) {
10
+ return;
11
+ }
12
+ setLayout({
13
+ height: height,
14
+ width: width,
15
+ measured: true,
16
+ });
17
+ }, [layout.height, layout.width]);
18
+ return [layout, onLayout];
19
+ };
20
+ exports.useLayout = useLayout;
@@ -1,5 +1,5 @@
1
1
  import { FunctionComponent } from 'react';
2
2
  import { SvgProps } from 'react-native-svg';
3
- export declare type IconName = 'arrow-down' | 'arrow-left' | 'arrow-right' | 'arrow-up' | 'caret-down' | 'caret-left' | 'caret-right' | 'caret-up' | 'chart' | 'check' | 'chevron-down' | 'chevron-left' | 'chevron-left-small' | 'chevron-left-small-first' | 'chevron-right' | 'chevron-right-small' | 'chevron-right-small-last' | 'chevron-up' | 'cross' | 'dollar' | 'download' | 'electricity' | 'euro' | 'gas' | 'help' | 'hide' | 'home' | 'info' | 'link' | 'logo' | 'minus' | 'new-window' | 'payment-card' | 'plus' | 'pound' | 'search' | 'show' | 'user';
3
+ export declare type IconName = 'address' | 'advice' | 'archive' | 'arrow-down' | 'arrow-left' | 'arrow-right' | 'arrow-up' | 'award' | 'battery' | 'cal' | 'cal-book' | 'caret-down' | 'caret-left' | 'caret-right' | 'caret-up' | 'chart' | 'chart-filled' | 'check' | 'check-circle' | 'chevron-down' | 'chevron-left' | 'chevron-left-small' | 'chevron-left-small-first' | 'chevron-right' | 'chevron-right-small' | 'chevron-right-small-last' | 'chevron-up' | 'circle' | 'close-circle' | 'cross' | 'doc' | 'dollar' | 'download' | 'eco' | 'eco-home' | 'edit' | 'electric-car' | 'electric-home' | 'electricity' | 'energy-advice' | 'equals' | 'euro' | 'gas' | 'globe-address' | 'help' | 'hide' | 'home' | 'home-filled' | 'hydro-power' | 'info' | 'link' | 'logo' | 'mail' | 'mail-open' | 'menu' | 'message' | 'message-filled' | 'minus' | 'mobile' | 'new-window' | 'payment-card' | 'phone' | 'plus' | 'pound' | 'pricing' | 'search' | 'security' | 'show' | 'smart-home' | 'smart-meter' | 'solar' | 'star' | 'sun' | 'trees' | 'tune' | 'user' | 'user-filled' | 'wallet' | 'wallet-filled' | 'warm-home' | 'warning' | 'web-address' | 'wind-power';
4
4
  export declare type IconNameExtended = IconName | string;
5
5
  export declare type IconsType = Record<string, FunctionComponent<SvgProps>>;
@@ -0,0 +1,18 @@
1
+ import { Theme } from './theme';
2
+ /**
3
+ * Use 3 level Partial instead of a Recursive Deep Partial, to avoid infinite nested recursion
4
+ * if any of the props contain recursive elements. For example logos / icons
5
+ */
6
+ declare type ThreeLevelPartial<T> = {
7
+ [P in keyof T]?: TwoLevelPartial<T[P]>;
8
+ };
9
+ declare type TwoLevelPartial<T> = {
10
+ [P in keyof T]?: OneLevelPartial<T[P]>;
11
+ };
12
+ declare type OneLevelPartial<T> = {
13
+ [P in keyof T]?: Partial<T[P]>;
14
+ };
15
+ export declare type RequiredThemeKeys = Pick<Theme, 'borderWidths' | 'radii' | 'breakpoints' | 'shadows' | 'space' | 'fonts' | 'lineHeights' | 'fontSizes' | 'responsiveFontSizes' | 'responsiveLineHeights' | 'colors'>;
16
+ export declare const defaultTokens: RequiredThemeKeys;
17
+ export declare function createTheme<T, A = object>(customTheme: ThreeLevelPartial<Theme> & T, additional?: ThreeLevelPartial<Theme> & A): Theme & T & A;
18
+ export {};