aport-tools 4.1.29 → 4.1.31

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.esm.js CHANGED
@@ -1,6 +1,7 @@
1
- /*! aport-tools v4.1.29 | ISC */
1
+ /*! aport-tools v4.1.31 | ISC */
2
2
  import React, { useContext, useState, createContext, useMemo } from 'react';
3
- import require$$1, { StyleSheet, Text as Text$1, View, TextInput, TouchableOpacity, ActivityIndicator, Platform } from 'react-native';
3
+ import { StyleSheet, Text as Text$1, View, TextInput, TouchableOpacity, ActivityIndicator, Platform } from 'react-native';
4
+ import { ThemeContext } from 'aport-themes';
4
5
 
5
6
  /******************************************************************************
6
7
  Copyright (c) Microsoft Corporation.
@@ -140,302 +141,6 @@ var Form = function Form(_a) {
140
141
  }, children);
141
142
  };
142
143
 
143
- var dist = {};
144
-
145
- /*! aport-themes v1.0.1 | ISC */
146
-
147
- var hasRequiredDist;
148
-
149
- function requireDist () {
150
- if (hasRequiredDist) return dist;
151
- hasRequiredDist = 1;
152
-
153
- var React$1 = React;
154
- var reactNative = require$$1;
155
-
156
- // src/styles/colors.ts
157
- var lightTheme = {
158
- primary: {
159
- hex: "#1A73E8",
160
- rgb: {
161
- r: 26,
162
- g: 115,
163
- b: 232
164
- }
165
- },
166
- secondary: {
167
- hex: "#F0F6FF",
168
- rgb: {
169
- r: 240,
170
- g: 246,
171
- b: 255
172
- }
173
- },
174
- background: {
175
- hex: "#FFFFFF",
176
- rgb: {
177
- r: 255,
178
- g: 255,
179
- b: 255
180
- }
181
- },
182
- text: {
183
- hex: "#000000",
184
- rgb: {
185
- r: 0,
186
- g: 0,
187
- b: 0
188
- }
189
- },
190
- textButton: {
191
- hex: "#FFFFFF",
192
- rgb: {
193
- r: 255,
194
- g: 255,
195
- b: 255
196
- }
197
- },
198
- error: {
199
- hex: "#FF5252",
200
- rgb: {
201
- r: 255,
202
- g: 82,
203
- b: 82
204
- }
205
- },
206
- success: {
207
- hex: "#4CAF50",
208
- rgb: {
209
- r: 76,
210
- g: 175,
211
- b: 80
212
- }
213
- },
214
- warning: {
215
- hex: "#FFC107",
216
- rgb: {
217
- r: 255,
218
- g: 193,
219
- b: 7
220
- }
221
- },
222
- body: {
223
- hex: '#F5F5F5',
224
- rgb: {
225
- r: 245,
226
- g: 245,
227
- b: 245
228
- }
229
- },
230
- placeHolder: {
231
- hex: '#A8A8A8',
232
- rgb: {
233
- r: 168,
234
- g: 168,
235
- b: 168
236
- }
237
- }
238
- };
239
- var darkTheme = {
240
- primary: {
241
- hex: "#BB86FC",
242
- rgb: {
243
- r: 187,
244
- g: 134,
245
- b: 252
246
- }
247
- },
248
- secondary: {
249
- hex: "#03DAC6",
250
- rgb: {
251
- r: 3,
252
- g: 218,
253
- b: 198
254
- }
255
- },
256
- background: {
257
- hex: "#121212",
258
- rgb: {
259
- r: 18,
260
- g: 18,
261
- b: 18
262
- }
263
- },
264
- text: {
265
- hex: "#FFFFFF",
266
- rgb: {
267
- r: 255,
268
- g: 255,
269
- b: 255
270
- }
271
- },
272
- textButton: {
273
- hex: "#FFFFFF",
274
- rgb: {
275
- r: 255,
276
- g: 255,
277
- b: 255
278
- }
279
- },
280
- error: {
281
- hex: "#CF6679",
282
- rgb: {
283
- r: 207,
284
- g: 102,
285
- b: 121
286
- }
287
- },
288
- success: {
289
- hex: "#03DAC6",
290
- rgb: {
291
- r: 3,
292
- g: 218,
293
- b: 198
294
- }
295
- },
296
- warning: {
297
- hex: "#FFB74D",
298
- rgb: {
299
- r: 255,
300
- g: 183,
301
- b: 77
302
- }
303
- },
304
- body: {
305
- hex: '#1C1C1E',
306
- rgb: {
307
- r: 28,
308
- g: 28,
309
- b: 30
310
- }
311
- },
312
- placeHolder: {
313
- hex: '#6C6C6E',
314
- rgb: {
315
- r: 108,
316
- g: 108,
317
- b: 110
318
- }
319
- }
320
- };
321
-
322
- // Utility to detect if running on React Native
323
- var isReactNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
324
- // Platform-specific imports
325
- var Appearance = isReactNative ? require$$1.Appearance : null;
326
- /**
327
- * React context for managing theme-related data and functions.
328
- */
329
- var ThemeContext = /*#__PURE__*/React$1.createContext({
330
- theme: {
331
- colors: lightTheme
332
- },
333
- toggleTheme: function toggleTheme() {}
334
- });
335
- /**
336
- * ThemeProvider component that manages and provides theme data to its children.
337
- *
338
- * @param children - The child components that will consume the theme context.
339
- * @param initialTheme - Optional prop to set the initial theme.
340
- */
341
- var ThemeProvider = function ThemeProvider(_a) {
342
- var children = _a.children,
343
- initialTheme = _a.initialTheme;
344
- var _b = React$1.useState(initialTheme || null),
345
- colorScheme = _b[0],
346
- setColorScheme = _b[1];
347
- React$1.useEffect(function () {
348
- var loadTheme = function loadTheme() {
349
- if (initialTheme) {
350
- setColorScheme(initialTheme);
351
- } else {
352
- if (isReactNative) {
353
- var systemTheme = Appearance.getColorScheme();
354
- setColorScheme(systemTheme);
355
- } else {
356
- var systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
357
- setColorScheme(systemTheme);
358
- }
359
- }
360
- };
361
- loadTheme();
362
- if (isReactNative) {
363
- var subscription_1 = Appearance.addChangeListener(function (_a) {
364
- var colorScheme = _a.colorScheme;
365
- setColorScheme(colorScheme);
366
- });
367
- return function () {
368
- return subscription_1.remove();
369
- };
370
- } else {
371
- var mediaQuery_1 = window.matchMedia('(prefers-color-scheme: dark)');
372
- var mediaChangeHandler_1 = function mediaChangeHandler_1(e) {
373
- setColorScheme(e.matches ? 'dark' : 'light');
374
- };
375
- mediaQuery_1.addEventListener('change', mediaChangeHandler_1);
376
- return function () {
377
- return mediaQuery_1.removeEventListener('change', mediaChangeHandler_1);
378
- };
379
- }
380
- }, [initialTheme]);
381
- var toggleTheme = function toggleTheme() {
382
- setColorScheme(function (prevScheme) {
383
- return prevScheme === 'dark' ? 'light' : 'dark';
384
- });
385
- };
386
- var theme = {
387
- colors: colorScheme === 'dark' ? darkTheme : lightTheme
388
- };
389
- return /*#__PURE__*/React$1.createElement(ThemeContext.Provider, {
390
- value: {
391
- theme: theme,
392
- toggleTheme: toggleTheme
393
- }
394
- }, children);
395
- };
396
-
397
- var ThemeToggle = function ThemeToggle() {
398
- var _a = React$1.useContext(ThemeContext),
399
- theme = _a.theme,
400
- toggleTheme = _a.toggleTheme;
401
- var isDarkMode = theme.colors === darkTheme;
402
- return /*#__PURE__*/React$1.createElement(reactNative.View, {
403
- style: styles.container
404
- }, /*#__PURE__*/React$1.createElement(reactNative.Text, {
405
- style: [styles.text, {
406
- color: theme.colors.text.hex
407
- }]
408
- }, "Dark Mode"), /*#__PURE__*/React$1.createElement(reactNative.Switch, {
409
- value: isDarkMode,
410
- onValueChange: toggleTheme,
411
- trackColor: {
412
- "false": lightTheme.secondary.hex,
413
- "true": darkTheme.primary.hex
414
- },
415
- thumbColor: isDarkMode ? darkTheme.secondary.hex : lightTheme.primary.hex
416
- }));
417
- };
418
- var styles = reactNative.StyleSheet.create({
419
- container: {
420
- marginTop: 20,
421
- flexDirection: 'row',
422
- alignItems: 'center'
423
- },
424
- text: {
425
- marginRight: 10,
426
- fontSize: 16
427
- }
428
- });
429
-
430
- dist.ThemeContext = ThemeContext;
431
- dist.ThemeProvider = ThemeProvider;
432
- dist.ThemeToggle = ThemeToggle;
433
-
434
- return dist;
435
- }
436
-
437
- var distExports = requireDist();
438
-
439
144
  // src/fonts/Text.tsx
440
145
  /**
441
146
  * A dynamic Text component that supports HTML-like formatting.
@@ -468,7 +173,7 @@ var Text = function Text(_a) {
468
173
  _j = _a.h,
469
174
  h = _j === void 0 ? 0 : _j,
470
175
  style = _a.style;
471
- var theme = useContext(distExports.ThemeContext).theme;
176
+ var theme = useContext(ThemeContext).theme;
472
177
  var colors = theme.colors;
473
178
  // Calculate header size based on 'h' prop
474
179
  var fontSize = size;
@@ -503,7 +208,7 @@ StyleSheet.create({
503
208
  // src/forms/ErrorList.tsx
504
209
  var ErrorList = function ErrorList(_a) {
505
210
  var errors = _a.errors;
506
- var theme = useContext(distExports.ThemeContext).theme;
211
+ var theme = useContext(ThemeContext).theme;
507
212
  var colors = theme.colors;
508
213
  return /*#__PURE__*/React.createElement(View, {
509
214
  style: styles$5.container
@@ -566,7 +271,7 @@ var Input = function Input(_a) {
566
271
  formValues = _b.formValues,
567
272
  setFormValue = _b.setFormValue,
568
273
  formErrors = _b.errors;
569
- var theme = useContext(distExports.ThemeContext).theme;
274
+ var theme = useContext(ThemeContext).theme;
570
275
  var colors = theme.colors;
571
276
  /**
572
277
  * Handles text changes in the input field, applying formatting based on the inputType.
@@ -693,7 +398,7 @@ var styles$3 = StyleSheet.create({
693
398
  var Label = function Label(_a) {
694
399
  var text = _a.text,
695
400
  style = _a.style;
696
- var theme = useContext(distExports.ThemeContext).theme;
401
+ var theme = useContext(ThemeContext).theme;
697
402
  var colors = theme.colors;
698
403
  return /*#__PURE__*/React.createElement(Text, {
699
404
  style: [styles$2.label, style, {
@@ -768,7 +473,7 @@ var Button = function Button(_a) {
768
473
  _g = _a.loading,
769
474
  loading = _g === void 0 ? false : _g,
770
475
  onPress = _a.onPress;
771
- var theme = useContext(distExports.ThemeContext).theme;
476
+ var theme = useContext(ThemeContext).theme;
772
477
  var colors = theme.colors;
773
478
  var handleSubmit = useFormContext().handleSubmit;
774
479
  var computedStyles = useMemo(function () {
@@ -844,7 +549,7 @@ var Card = function Card(_a) {
844
549
  elevation = _d === void 0 ? 4 : _d,
845
550
  _e = _a.shadowProps,
846
551
  shadowProps = _e === void 0 ? {} : _e;
847
- var theme = useContext(distExports.ThemeContext).theme;
552
+ var theme = useContext(ThemeContext).theme;
848
553
  var colors = theme.colors;
849
554
  // Animation state for pressable effect
850
555
  // Default shadow styles (improved platform-specific handling)