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.js CHANGED
@@ -1,8 +1,9 @@
1
- /*! aport-tools v4.1.29 | ISC */
1
+ /*! aport-tools v4.1.31 | ISC */
2
2
  'use strict';
3
3
 
4
4
  var React = require('react');
5
- var require$$1 = require('react-native');
5
+ var reactNative = require('react-native');
6
+ var aportThemes = require('aport-themes');
6
7
 
7
8
  /******************************************************************************
8
9
  Copyright (c) Microsoft Corporation.
@@ -142,302 +143,6 @@ var Form = function Form(_a) {
142
143
  }, children);
143
144
  };
144
145
 
145
- var dist = {};
146
-
147
- /*! aport-themes v1.0.1 | ISC */
148
-
149
- var hasRequiredDist;
150
-
151
- function requireDist () {
152
- if (hasRequiredDist) return dist;
153
- hasRequiredDist = 1;
154
-
155
- var React$1 = React;
156
- var reactNative = require$$1;
157
-
158
- // src/styles/colors.ts
159
- var lightTheme = {
160
- primary: {
161
- hex: "#1A73E8",
162
- rgb: {
163
- r: 26,
164
- g: 115,
165
- b: 232
166
- }
167
- },
168
- secondary: {
169
- hex: "#F0F6FF",
170
- rgb: {
171
- r: 240,
172
- g: 246,
173
- b: 255
174
- }
175
- },
176
- background: {
177
- hex: "#FFFFFF",
178
- rgb: {
179
- r: 255,
180
- g: 255,
181
- b: 255
182
- }
183
- },
184
- text: {
185
- hex: "#000000",
186
- rgb: {
187
- r: 0,
188
- g: 0,
189
- b: 0
190
- }
191
- },
192
- textButton: {
193
- hex: "#FFFFFF",
194
- rgb: {
195
- r: 255,
196
- g: 255,
197
- b: 255
198
- }
199
- },
200
- error: {
201
- hex: "#FF5252",
202
- rgb: {
203
- r: 255,
204
- g: 82,
205
- b: 82
206
- }
207
- },
208
- success: {
209
- hex: "#4CAF50",
210
- rgb: {
211
- r: 76,
212
- g: 175,
213
- b: 80
214
- }
215
- },
216
- warning: {
217
- hex: "#FFC107",
218
- rgb: {
219
- r: 255,
220
- g: 193,
221
- b: 7
222
- }
223
- },
224
- body: {
225
- hex: '#F5F5F5',
226
- rgb: {
227
- r: 245,
228
- g: 245,
229
- b: 245
230
- }
231
- },
232
- placeHolder: {
233
- hex: '#A8A8A8',
234
- rgb: {
235
- r: 168,
236
- g: 168,
237
- b: 168
238
- }
239
- }
240
- };
241
- var darkTheme = {
242
- primary: {
243
- hex: "#BB86FC",
244
- rgb: {
245
- r: 187,
246
- g: 134,
247
- b: 252
248
- }
249
- },
250
- secondary: {
251
- hex: "#03DAC6",
252
- rgb: {
253
- r: 3,
254
- g: 218,
255
- b: 198
256
- }
257
- },
258
- background: {
259
- hex: "#121212",
260
- rgb: {
261
- r: 18,
262
- g: 18,
263
- b: 18
264
- }
265
- },
266
- text: {
267
- hex: "#FFFFFF",
268
- rgb: {
269
- r: 255,
270
- g: 255,
271
- b: 255
272
- }
273
- },
274
- textButton: {
275
- hex: "#FFFFFF",
276
- rgb: {
277
- r: 255,
278
- g: 255,
279
- b: 255
280
- }
281
- },
282
- error: {
283
- hex: "#CF6679",
284
- rgb: {
285
- r: 207,
286
- g: 102,
287
- b: 121
288
- }
289
- },
290
- success: {
291
- hex: "#03DAC6",
292
- rgb: {
293
- r: 3,
294
- g: 218,
295
- b: 198
296
- }
297
- },
298
- warning: {
299
- hex: "#FFB74D",
300
- rgb: {
301
- r: 255,
302
- g: 183,
303
- b: 77
304
- }
305
- },
306
- body: {
307
- hex: '#1C1C1E',
308
- rgb: {
309
- r: 28,
310
- g: 28,
311
- b: 30
312
- }
313
- },
314
- placeHolder: {
315
- hex: '#6C6C6E',
316
- rgb: {
317
- r: 108,
318
- g: 108,
319
- b: 110
320
- }
321
- }
322
- };
323
-
324
- // Utility to detect if running on React Native
325
- var isReactNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
326
- // Platform-specific imports
327
- var Appearance = isReactNative ? require$$1.Appearance : null;
328
- /**
329
- * React context for managing theme-related data and functions.
330
- */
331
- var ThemeContext = /*#__PURE__*/React$1.createContext({
332
- theme: {
333
- colors: lightTheme
334
- },
335
- toggleTheme: function toggleTheme() {}
336
- });
337
- /**
338
- * ThemeProvider component that manages and provides theme data to its children.
339
- *
340
- * @param children - The child components that will consume the theme context.
341
- * @param initialTheme - Optional prop to set the initial theme.
342
- */
343
- var ThemeProvider = function ThemeProvider(_a) {
344
- var children = _a.children,
345
- initialTheme = _a.initialTheme;
346
- var _b = React$1.useState(initialTheme || null),
347
- colorScheme = _b[0],
348
- setColorScheme = _b[1];
349
- React$1.useEffect(function () {
350
- var loadTheme = function loadTheme() {
351
- if (initialTheme) {
352
- setColorScheme(initialTheme);
353
- } else {
354
- if (isReactNative) {
355
- var systemTheme = Appearance.getColorScheme();
356
- setColorScheme(systemTheme);
357
- } else {
358
- var systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
359
- setColorScheme(systemTheme);
360
- }
361
- }
362
- };
363
- loadTheme();
364
- if (isReactNative) {
365
- var subscription_1 = Appearance.addChangeListener(function (_a) {
366
- var colorScheme = _a.colorScheme;
367
- setColorScheme(colorScheme);
368
- });
369
- return function () {
370
- return subscription_1.remove();
371
- };
372
- } else {
373
- var mediaQuery_1 = window.matchMedia('(prefers-color-scheme: dark)');
374
- var mediaChangeHandler_1 = function mediaChangeHandler_1(e) {
375
- setColorScheme(e.matches ? 'dark' : 'light');
376
- };
377
- mediaQuery_1.addEventListener('change', mediaChangeHandler_1);
378
- return function () {
379
- return mediaQuery_1.removeEventListener('change', mediaChangeHandler_1);
380
- };
381
- }
382
- }, [initialTheme]);
383
- var toggleTheme = function toggleTheme() {
384
- setColorScheme(function (prevScheme) {
385
- return prevScheme === 'dark' ? 'light' : 'dark';
386
- });
387
- };
388
- var theme = {
389
- colors: colorScheme === 'dark' ? darkTheme : lightTheme
390
- };
391
- return /*#__PURE__*/React$1.createElement(ThemeContext.Provider, {
392
- value: {
393
- theme: theme,
394
- toggleTheme: toggleTheme
395
- }
396
- }, children);
397
- };
398
-
399
- var ThemeToggle = function ThemeToggle() {
400
- var _a = React$1.useContext(ThemeContext),
401
- theme = _a.theme,
402
- toggleTheme = _a.toggleTheme;
403
- var isDarkMode = theme.colors === darkTheme;
404
- return /*#__PURE__*/React$1.createElement(reactNative.View, {
405
- style: styles.container
406
- }, /*#__PURE__*/React$1.createElement(reactNative.Text, {
407
- style: [styles.text, {
408
- color: theme.colors.text.hex
409
- }]
410
- }, "Dark Mode"), /*#__PURE__*/React$1.createElement(reactNative.Switch, {
411
- value: isDarkMode,
412
- onValueChange: toggleTheme,
413
- trackColor: {
414
- "false": lightTheme.secondary.hex,
415
- "true": darkTheme.primary.hex
416
- },
417
- thumbColor: isDarkMode ? darkTheme.secondary.hex : lightTheme.primary.hex
418
- }));
419
- };
420
- var styles = reactNative.StyleSheet.create({
421
- container: {
422
- marginTop: 20,
423
- flexDirection: 'row',
424
- alignItems: 'center'
425
- },
426
- text: {
427
- marginRight: 10,
428
- fontSize: 16
429
- }
430
- });
431
-
432
- dist.ThemeContext = ThemeContext;
433
- dist.ThemeProvider = ThemeProvider;
434
- dist.ThemeToggle = ThemeToggle;
435
-
436
- return dist;
437
- }
438
-
439
- var distExports = requireDist();
440
-
441
146
  // src/fonts/Text.tsx
442
147
  /**
443
148
  * A dynamic Text component that supports HTML-like formatting.
@@ -470,7 +175,7 @@ var Text = function Text(_a) {
470
175
  _j = _a.h,
471
176
  h = _j === void 0 ? 0 : _j,
472
177
  style = _a.style;
473
- var theme = React.useContext(distExports.ThemeContext).theme;
178
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
474
179
  var colors = theme.colors;
475
180
  // Calculate header size based on 'h' prop
476
181
  var fontSize = size;
@@ -494,23 +199,23 @@ var Text = function Text(_a) {
494
199
  textAlign: textAlign,
495
200
  color: textColor
496
201
  };
497
- return /*#__PURE__*/React.createElement(require$$1.Text, {
202
+ return /*#__PURE__*/React.createElement(reactNative.Text, {
498
203
  style: [textStyles, style]
499
204
  }, children);
500
205
  };
501
- require$$1.StyleSheet.create({
206
+ reactNative.StyleSheet.create({
502
207
  // Define any default styles if needed
503
208
  });
504
209
 
505
210
  // src/forms/ErrorList.tsx
506
211
  var ErrorList = function ErrorList(_a) {
507
212
  var errors = _a.errors;
508
- var theme = React.useContext(distExports.ThemeContext).theme;
213
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
509
214
  var colors = theme.colors;
510
- return /*#__PURE__*/React.createElement(require$$1.View, {
215
+ return /*#__PURE__*/React.createElement(reactNative.View, {
511
216
  style: styles$5.container
512
217
  }, errors.map(function (error, index) {
513
- return /*#__PURE__*/React.createElement(require$$1.View, {
218
+ return /*#__PURE__*/React.createElement(reactNative.View, {
514
219
  key: index,
515
220
  style: styles$5.errorItem
516
221
  }, /*#__PURE__*/React.createElement(Text, {
@@ -524,7 +229,7 @@ var ErrorList = function ErrorList(_a) {
524
229
  }, error));
525
230
  }));
526
231
  };
527
- var styles$5 = require$$1.StyleSheet.create({
232
+ var styles$5 = reactNative.StyleSheet.create({
528
233
  container: {
529
234
  marginTop: 4
530
235
  },
@@ -568,7 +273,7 @@ var Input = function Input(_a) {
568
273
  formValues = _b.formValues,
569
274
  setFormValue = _b.setFormValue,
570
275
  formErrors = _b.errors;
571
- var theme = React.useContext(distExports.ThemeContext).theme;
276
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
572
277
  var colors = theme.colors;
573
278
  /**
574
279
  * Handles text changes in the input field, applying formatting based on the inputType.
@@ -601,13 +306,13 @@ var Input = function Input(_a) {
601
306
  }
602
307
  setFormValue(name, formattedText);
603
308
  };
604
- return /*#__PURE__*/React.createElement(require$$1.View, {
309
+ return /*#__PURE__*/React.createElement(reactNative.View, {
605
310
  style: styles$4.container
606
311
  }, /*#__PURE__*/React.createElement(Text, {
607
312
  style: [styles$4.label, {
608
313
  color: colors.text.hex
609
314
  }]
610
- }, label), /*#__PURE__*/React.createElement(require$$1.TextInput, __assign({
315
+ }, label), /*#__PURE__*/React.createElement(reactNative.TextInput, __assign({
611
316
  style: [styles$4.input, {
612
317
  backgroundColor: colors.body.hex,
613
318
  borderColor: formErrors[name] ? colors.error.hex : "#CCC",
@@ -621,7 +326,7 @@ var Input = function Input(_a) {
621
326
  errors: formErrors[name]
622
327
  })));
623
328
  };
624
- var styles$4 = require$$1.StyleSheet.create({
329
+ var styles$4 = reactNative.StyleSheet.create({
625
330
  container: {
626
331
  marginBottom: 16
627
332
  },
@@ -651,11 +356,11 @@ var TextArea = function TextArea(_a) {
651
356
  var handleChange = function handleChange(text) {
652
357
  setFormValue(name, text);
653
358
  };
654
- return /*#__PURE__*/React.createElement(require$$1.View, {
359
+ return /*#__PURE__*/React.createElement(reactNative.View, {
655
360
  style: styles$3.container
656
361
  }, /*#__PURE__*/React.createElement(Text, {
657
362
  style: styles$3.label
658
- }, label), /*#__PURE__*/React.createElement(require$$1.TextInput, __assign({
363
+ }, label), /*#__PURE__*/React.createElement(reactNative.TextInput, __assign({
659
364
  style: [styles$3.textArea, style],
660
365
  value: formValues[name] || '',
661
366
  onChangeText: handleChange,
@@ -669,7 +374,7 @@ var TextArea = function TextArea(_a) {
669
374
  errors: formErrors[name]
670
375
  })));
671
376
  };
672
- var styles$3 = require$$1.StyleSheet.create({
377
+ var styles$3 = reactNative.StyleSheet.create({
673
378
  container: {
674
379
  marginBottom: 16
675
380
  },
@@ -695,7 +400,7 @@ var styles$3 = require$$1.StyleSheet.create({
695
400
  var Label = function Label(_a) {
696
401
  var text = _a.text,
697
402
  style = _a.style;
698
- var theme = React.useContext(distExports.ThemeContext).theme;
403
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
699
404
  var colors = theme.colors;
700
405
  return /*#__PURE__*/React.createElement(Text, {
701
406
  style: [styles$2.label, style, {
@@ -703,7 +408,7 @@ var Label = function Label(_a) {
703
408
  }]
704
409
  }, text);
705
410
  };
706
- var styles$2 = require$$1.StyleSheet.create({
411
+ var styles$2 = reactNative.StyleSheet.create({
707
412
  label: {
708
413
  marginBottom: 4,
709
414
  fontWeight: '500'
@@ -770,11 +475,11 @@ var Button = function Button(_a) {
770
475
  _g = _a.loading,
771
476
  loading = _g === void 0 ? false : _g,
772
477
  onPress = _a.onPress;
773
- var theme = React.useContext(distExports.ThemeContext).theme;
478
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
774
479
  var colors = theme.colors;
775
480
  var handleSubmit = useFormContext().handleSubmit;
776
481
  var computedStyles = React.useMemo(function () {
777
- return require$$1.StyleSheet.flatten([styles$1.button, typeStyles(type, disabled, colors), rounded && {
482
+ return reactNative.StyleSheet.flatten([styles$1.button, typeStyles(type, disabled, colors), rounded && {
778
483
  borderRadius: borderRadius
779
484
  }, isFullWidth && {
780
485
  width: '100%'
@@ -794,7 +499,7 @@ var Button = function Button(_a) {
794
499
  onPress(); // Call a custom handler if needed
795
500
  }
796
501
  };
797
- return /*#__PURE__*/React.createElement(require$$1.TouchableOpacity, {
502
+ return /*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
798
503
  style: computedStyles,
799
504
  disabled: disabled || loading,
800
505
  onPress: handlePress,
@@ -802,14 +507,14 @@ var Button = function Button(_a) {
802
507
  }, loading ? (
803
508
  /*#__PURE__*/
804
509
  // Show loading spinner if loading
805
- React.createElement(require$$1.ActivityIndicator, {
510
+ React.createElement(reactNative.ActivityIndicator, {
806
511
  size: "small",
807
512
  color: colors.textButton.hex
808
- })) : (/*#__PURE__*/React.createElement(require$$1.Text, {
513
+ })) : (/*#__PURE__*/React.createElement(reactNative.Text, {
809
514
  style: textColor
810
515
  }, Array.isArray(children) ? children.join('').toUpperCase() : children === null || children === void 0 ? void 0 : children.toUpperCase())));
811
516
  };
812
- var styles$1 = require$$1.StyleSheet.create({
517
+ var styles$1 = reactNative.StyleSheet.create({
813
518
  button: {
814
519
  justifyContent: 'center',
815
520
  alignItems: 'center',
@@ -846,11 +551,11 @@ var Card = function Card(_a) {
846
551
  elevation = _d === void 0 ? 4 : _d,
847
552
  _e = _a.shadowProps,
848
553
  shadowProps = _e === void 0 ? {} : _e;
849
- var theme = React.useContext(distExports.ThemeContext).theme;
554
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
850
555
  var colors = theme.colors;
851
556
  // Animation state for pressable effect
852
557
  // Default shadow styles (improved platform-specific handling)
853
- var defaultShadow = require$$1.Platform.select({
558
+ var defaultShadow = reactNative.Platform.select({
854
559
  ios: {
855
560
  shadowColor: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowColor) || colors.text.hex,
856
561
  // Defaulting to theme text color
@@ -872,15 +577,15 @@ var Card = function Card(_a) {
872
577
  // Dynamic shadows based on platform
873
578
  style // External styles
874
579
  ];
875
- return pressable ? (/*#__PURE__*/React.createElement(require$$1.TouchableOpacity, {
580
+ return pressable ? (/*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
876
581
  activeOpacity: 0.8,
877
582
  onPress: onPress,
878
583
  style: cardStyles
879
- }, children)) : (/*#__PURE__*/React.createElement(require$$1.View, {
584
+ }, children)) : (/*#__PURE__*/React.createElement(reactNative.View, {
880
585
  style: cardStyles
881
586
  }, children));
882
587
  };
883
- var styles = require$$1.StyleSheet.create({
588
+ var styles = reactNative.StyleSheet.create({
884
589
  container: {
885
590
  padding: 16,
886
591
  borderRadius: 12