aport-tools 4.1.28 → 4.1.31

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -12,6 +12,12 @@ To install the latest version of aport-tools, run the following command:
12
12
  npm i aport-tools
13
13
  ```
14
14
 
15
+ requires:
16
+
17
+ ```bash
18
+ npm i aport-themes
19
+ ```
20
+
15
21
  Happy to receive help and advice; siixsixer@gmail.com
16
22
 
17
23
  License
@@ -1,6 +1,6 @@
1
+ import { ThemeColors } from 'aport-themes';
1
2
  import React from 'react';
2
3
  import { TextProps, TextStyle } from 'react-native';
3
- import { ThemeColors } from '../styles/colors';
4
4
  interface CustomTextProps extends TextProps {
5
5
  /**
6
6
  * Content to be displayed inside the Text component.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './theme';
2
1
  export * from './buttons';
3
2
  export * from './cards';
4
3
  export * from './fonts';
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- /*! aport-tools v4.1.28 | ISC */
2
- import React, { createContext, useState, useEffect, useContext, useMemo } from 'react';
3
- import { Appearance, StyleSheet, View, Text as Text$1, Switch, TextInput, TouchableOpacity, ActivityIndicator, Platform } from 'react-native';
4
- import { useAsyncStorage } from '@react-native-async-storage/async-storage';
1
+ /*! aport-tools v4.1.31 | ISC */
2
+ import React, { useContext, useState, createContext, useMemo } from 'react';
3
+ import { StyleSheet, Text as Text$1, View, TextInput, TouchableOpacity, ActivityIndicator, Platform } from 'react-native';
4
+ import { ThemeContext } from 'aport-themes';
5
5
 
6
6
  /******************************************************************************
7
7
  Copyright (c) Microsoft Corporation.
@@ -86,283 +86,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
86
86
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
87
87
  };
88
88
 
89
- // src/styles/colors.ts
90
- var lightTheme = {
91
- primary: {
92
- hex: "#1A73E8",
93
- rgb: {
94
- r: 26,
95
- g: 115,
96
- b: 232
97
- }
98
- },
99
- secondary: {
100
- hex: "#F0F6FF",
101
- rgb: {
102
- r: 240,
103
- g: 246,
104
- b: 255
105
- }
106
- },
107
- background: {
108
- hex: "#FFFFFF",
109
- rgb: {
110
- r: 255,
111
- g: 255,
112
- b: 255
113
- }
114
- },
115
- text: {
116
- hex: "#000000",
117
- rgb: {
118
- r: 0,
119
- g: 0,
120
- b: 0
121
- }
122
- },
123
- textButton: {
124
- hex: "#FFFFFF",
125
- rgb: {
126
- r: 255,
127
- g: 255,
128
- b: 255
129
- }
130
- },
131
- error: {
132
- hex: "#FF5252",
133
- rgb: {
134
- r: 255,
135
- g: 82,
136
- b: 82
137
- }
138
- },
139
- success: {
140
- hex: "#4CAF50",
141
- rgb: {
142
- r: 76,
143
- g: 175,
144
- b: 80
145
- }
146
- },
147
- warning: {
148
- hex: "#FFC107",
149
- rgb: {
150
- r: 255,
151
- g: 193,
152
- b: 7
153
- }
154
- },
155
- body: {
156
- // Body color is the same as background in the light theme
157
- hex: '#FFFFFF',
158
- rgb: {
159
- r: 255,
160
- g: 255,
161
- b: 255
162
- }
163
- }
164
- };
165
- var darkTheme = {
166
- primary: {
167
- hex: "#BB86FC",
168
- rgb: {
169
- r: 187,
170
- g: 134,
171
- b: 252
172
- }
173
- },
174
- secondary: {
175
- hex: "#03DAC6",
176
- rgb: {
177
- r: 3,
178
- g: 218,
179
- b: 198
180
- }
181
- },
182
- background: {
183
- hex: "#121212",
184
- rgb: {
185
- r: 18,
186
- g: 18,
187
- b: 18
188
- }
189
- },
190
- text: {
191
- hex: "#FFFFFF",
192
- rgb: {
193
- r: 255,
194
- g: 255,
195
- b: 255
196
- }
197
- },
198
- textButton: {
199
- hex: "#FFFFFF",
200
- rgb: {
201
- r: 255,
202
- g: 255,
203
- b: 255
204
- }
205
- },
206
- error: {
207
- hex: "#CF6679",
208
- rgb: {
209
- r: 207,
210
- g: 102,
211
- b: 121
212
- }
213
- },
214
- success: {
215
- hex: "#03DAC6",
216
- rgb: {
217
- r: 3,
218
- g: 218,
219
- b: 198
220
- }
221
- },
222
- warning: {
223
- hex: "#FFB74D",
224
- rgb: {
225
- r: 255,
226
- g: 183,
227
- b: 77
228
- }
229
- },
230
- body: {
231
- hex: '#1C1C1E',
232
- rgb: {
233
- r: 28,
234
- g: 28,
235
- b: 30
236
- }
237
- }
238
- };
239
-
240
- /**
241
- * React context for managing theme-related data and functions.
242
- */
243
- var ThemeContext = /*#__PURE__*/createContext({
244
- theme: {
245
- colors: lightTheme
246
- },
247
- toggleTheme: function toggleTheme() {}
248
- });
249
- /**
250
- * ThemeProvider component that manages and provides theme data to its children.
251
- *
252
- * @param children - The child components that will consume the theme context.
253
- * @param initialTheme - Optional prop to set the initial theme.
254
- */
255
- var ThemeProvider = function ThemeProvider(_a) {
256
- var children = _a.children,
257
- initialTheme = _a.initialTheme;
258
- var _b = useState(null),
259
- colorScheme = _b[0],
260
- setColorScheme = _b[1];
261
- // Use useAsyncStorage hook for managing the theme storage
262
- var _c = useAsyncStorage('theme'),
263
- getItem = _c.getItem,
264
- setItem = _c.setItem;
265
- useEffect(function () {
266
- var loadTheme = function loadTheme() {
267
- return __awaiter(void 0, void 0, void 0, function () {
268
- var systemTheme;
269
- return __generator(this, function (_a) {
270
- try {
271
- // const storedTheme = await getItem();
272
- // if (storedTheme === 'dark' || storedTheme === 'light') {
273
- // setColorScheme(storedTheme);
274
- //}
275
- if (initialTheme) {
276
- setColorScheme(initialTheme);
277
- } else {
278
- systemTheme = Appearance.getColorScheme();
279
- setColorScheme(systemTheme);
280
- }
281
- } catch (error) {
282
- console.error('Failed to load theme.', error);
283
- setColorScheme(Appearance.getColorScheme());
284
- }
285
- return [2 /*return*/];
286
- });
287
- });
288
- };
289
- loadTheme();
290
- var subscription = Appearance.addChangeListener(function (_a) {
291
- var colorScheme = _a.colorScheme;
292
- if (!colorScheme) return; // Prevent setting null
293
- setColorScheme(colorScheme);
294
- });
295
- return function () {
296
- return subscription.remove();
297
- };
298
- }, [initialTheme, getItem]);
299
- var toggleTheme = function toggleTheme() {
300
- return __awaiter(void 0, void 0, void 0, function () {
301
- var newTheme, error_1;
302
- return __generator(this, function (_a) {
303
- switch (_a.label) {
304
- case 0:
305
- _a.trys.push([0, 2,, 3]);
306
- newTheme = colorScheme === 'dark' ? 'light' : 'dark';
307
- setColorScheme(newTheme);
308
- return [4 /*yield*/, setItem(newTheme)];
309
- case 1:
310
- _a.sent(); // Use setItem from useAsyncStorage
311
- return [3 /*break*/, 3];
312
- case 2:
313
- error_1 = _a.sent();
314
- console.error('Failed to toggle theme.', error_1);
315
- return [3 /*break*/, 3];
316
- case 3:
317
- return [2 /*return*/];
318
- }
319
- });
320
- });
321
- };
322
- var theme = {
323
- colors: colorScheme === 'dark' ? darkTheme : lightTheme
324
- };
325
- return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
326
- value: {
327
- theme: theme,
328
- toggleTheme: toggleTheme
329
- }
330
- }, children);
331
- };
332
-
333
- var ThemeToggle = function ThemeToggle() {
334
- var _a = useContext(ThemeContext),
335
- theme = _a.theme,
336
- toggleTheme = _a.toggleTheme;
337
- var isDarkMode = theme.colors === darkTheme;
338
- return /*#__PURE__*/React.createElement(View, {
339
- style: styles$6.container
340
- }, /*#__PURE__*/React.createElement(Text$1, {
341
- style: [styles$6.text, {
342
- color: theme.colors.text.hex
343
- }]
344
- }, "Dark Mode"), /*#__PURE__*/React.createElement(Switch, {
345
- value: isDarkMode,
346
- onValueChange: toggleTheme,
347
- trackColor: {
348
- "false": lightTheme.secondary.hex,
349
- "true": darkTheme.primary.hex
350
- },
351
- thumbColor: isDarkMode ? darkTheme.secondary.hex : lightTheme.primary.hex
352
- }));
353
- };
354
- var styles$6 = StyleSheet.create({
355
- container: {
356
- marginTop: 20,
357
- flexDirection: 'row',
358
- alignItems: 'center'
359
- },
360
- text: {
361
- marginRight: 10,
362
- fontSize: 16
363
- }
364
- });
365
-
366
89
  // src/forms/FormContext.tsx
367
90
  var FormContext = /*#__PURE__*/createContext(undefined);
368
91
  var useFormContext = function useFormContext() {
@@ -596,7 +319,7 @@ var Input = function Input(_a) {
596
319
  value: formValues[name] || "",
597
320
  onChangeText: handleChange,
598
321
  placeholder: label,
599
- placeholderTextColor: colors.text.hex
322
+ placeholderTextColor: colors.placeHolder.hex
600
323
  }, rest)), formErrors[name] && formErrors[name].length > 0 && (/*#__PURE__*/React.createElement(ErrorList, {
601
324
  errors: formErrors[name]
602
325
  })));
@@ -761,7 +484,9 @@ var Button = function Button(_a) {
761
484
  }, (disabled || loading) && styles$1.disabled]);
762
485
  }, [type, disabled, loading, rounded, borderRadius, isFullWidth, colors]);
763
486
  var textColor = useMemo(function () {
764
- return {
487
+ return type === "cancel" ? {
488
+ color: colors.text.hex
489
+ } : {
765
490
  color: colors.textButton.hex
766
491
  };
767
492
  }, [type, colors]);
@@ -845,7 +570,7 @@ var Card = function Card(_a) {
845
570
  });
846
571
  var cardStyles = [styles.container, {
847
572
  borderRadius: borderRadius,
848
- backgroundColor: colors.body.hex
573
+ backgroundColor: colors.background.hex
849
574
  }, defaultShadow,
850
575
  // Dynamic shadows based on platform
851
576
  style // External styles
@@ -866,5 +591,5 @@ var styles = StyleSheet.create({
866
591
  }
867
592
  });
868
593
 
869
- export { Button, Card, ErrorList, Form, Input, Label, Text, TextArea, ThemeContext, ThemeProvider, ThemeToggle, useFormContext };
594
+ export { Button, Card, ErrorList, Form, Input, Label, Text, TextArea, useFormContext };
870
595
  //# sourceMappingURL=index.esm.js.map