aport-tools 4.1.29 → 4.2.0

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.
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
- /*! aport-tools v4.1.29 | ISC */
1
+ /*! aport-tools v4.2.0 | 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.
@@ -447,6 +152,8 @@ var distExports = requireDist();
447
152
  * @param size - Size of the text. Defaults to 'medium'.
448
153
  * @param b - If true, applies bold styling.
449
154
  * @param i - If true, applies italic styling.
155
+ * @param type - Type of Text component. Defaults to 'text'.
156
+ * @param typeFont - Type of Font component. Defaults to 'body'.
450
157
  * @param u - If true, applies underline styling.
451
158
  * @param align - Paragraph alignment. Defaults to 'left'.
452
159
  * @param h - Header level. Accepts 0 (none), 1, 2, or 3. Defaults to 0.
@@ -467,16 +174,22 @@ var Text = function Text(_a) {
467
174
  align = _g === void 0 ? 'left' : _g,
468
175
  _h = _a.type,
469
176
  type = _h === void 0 ? 'text' : _h,
470
- _j = _a.h,
471
- h = _j === void 0 ? 0 : _j,
177
+ _j = _a.typeFont,
178
+ typeFont = _j === void 0 ? 'body' : _j,
179
+ _k = _a.h,
180
+ h = _k === void 0 ? 0 : _k,
472
181
  style = _a.style;
473
- var theme = React.useContext(distExports.ThemeContext).theme;
474
- var colors = theme.colors;
182
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
183
+ var colors = theme.colors,
184
+ fonts = theme.fonts;
185
+ // Determine font family and size based on 'typeFont'
186
+ var fontSettings = fonts[typeFont] || fonts.body;
187
+ var fontFamily = fontSettings.fontFamily;
188
+ var fontSize = fontSettings.fontSize || size;
475
189
  // Calculate header size based on 'h' prop
476
- var fontSize = size;
477
190
  if (h === 1) fontSize = 32;else if (h === 2) fontSize = 24;else if (h === 3) fontSize = 18;
478
191
  // Define font weight based on bold prop
479
- var fontWeight = b ? '700' : '400';
192
+ var fontWeight = b ? '700' : fontSettings.fontWeight || '400';
480
193
  // Define font style based on italic prop
481
194
  var fontStyle = i ? 'italic' : 'normal';
482
195
  // Define text decoration based on underline prop
@@ -489,28 +202,29 @@ var Text = function Text(_a) {
489
202
  var textStyles = {
490
203
  fontSize: fontSize,
491
204
  fontWeight: fontWeight,
205
+ fontFamily: fontFamily,
492
206
  fontStyle: fontStyle,
493
207
  textDecorationLine: textDecorationLine,
494
208
  textAlign: textAlign,
495
209
  color: textColor
496
210
  };
497
- return /*#__PURE__*/React.createElement(require$$1.Text, {
211
+ return /*#__PURE__*/React.createElement(reactNative.Text, {
498
212
  style: [textStyles, style]
499
213
  }, children);
500
214
  };
501
- require$$1.StyleSheet.create({
215
+ reactNative.StyleSheet.create({
502
216
  // Define any default styles if needed
503
217
  });
504
218
 
505
219
  // src/forms/ErrorList.tsx
506
220
  var ErrorList = function ErrorList(_a) {
507
221
  var errors = _a.errors;
508
- var theme = React.useContext(distExports.ThemeContext).theme;
222
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
509
223
  var colors = theme.colors;
510
- return /*#__PURE__*/React.createElement(require$$1.View, {
224
+ return /*#__PURE__*/React.createElement(reactNative.View, {
511
225
  style: styles$5.container
512
226
  }, errors.map(function (error, index) {
513
- return /*#__PURE__*/React.createElement(require$$1.View, {
227
+ return /*#__PURE__*/React.createElement(reactNative.View, {
514
228
  key: index,
515
229
  style: styles$5.errorItem
516
230
  }, /*#__PURE__*/React.createElement(Text, {
@@ -524,7 +238,7 @@ var ErrorList = function ErrorList(_a) {
524
238
  }, error));
525
239
  }));
526
240
  };
527
- var styles$5 = require$$1.StyleSheet.create({
241
+ var styles$5 = reactNative.StyleSheet.create({
528
242
  container: {
529
243
  marginTop: 4
530
244
  },
@@ -568,7 +282,7 @@ var Input = function Input(_a) {
568
282
  formValues = _b.formValues,
569
283
  setFormValue = _b.setFormValue,
570
284
  formErrors = _b.errors;
571
- var theme = React.useContext(distExports.ThemeContext).theme;
285
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
572
286
  var colors = theme.colors;
573
287
  /**
574
288
  * Handles text changes in the input field, applying formatting based on the inputType.
@@ -601,13 +315,13 @@ var Input = function Input(_a) {
601
315
  }
602
316
  setFormValue(name, formattedText);
603
317
  };
604
- return /*#__PURE__*/React.createElement(require$$1.View, {
318
+ return /*#__PURE__*/React.createElement(reactNative.View, {
605
319
  style: styles$4.container
606
320
  }, /*#__PURE__*/React.createElement(Text, {
607
321
  style: [styles$4.label, {
608
322
  color: colors.text.hex
609
323
  }]
610
- }, label), /*#__PURE__*/React.createElement(require$$1.TextInput, __assign({
324
+ }, label), /*#__PURE__*/React.createElement(reactNative.TextInput, __assign({
611
325
  style: [styles$4.input, {
612
326
  backgroundColor: colors.body.hex,
613
327
  borderColor: formErrors[name] ? colors.error.hex : "#CCC",
@@ -621,7 +335,7 @@ var Input = function Input(_a) {
621
335
  errors: formErrors[name]
622
336
  })));
623
337
  };
624
- var styles$4 = require$$1.StyleSheet.create({
338
+ var styles$4 = reactNative.StyleSheet.create({
625
339
  container: {
626
340
  marginBottom: 16
627
341
  },
@@ -651,11 +365,11 @@ var TextArea = function TextArea(_a) {
651
365
  var handleChange = function handleChange(text) {
652
366
  setFormValue(name, text);
653
367
  };
654
- return /*#__PURE__*/React.createElement(require$$1.View, {
368
+ return /*#__PURE__*/React.createElement(reactNative.View, {
655
369
  style: styles$3.container
656
370
  }, /*#__PURE__*/React.createElement(Text, {
657
371
  style: styles$3.label
658
- }, label), /*#__PURE__*/React.createElement(require$$1.TextInput, __assign({
372
+ }, label), /*#__PURE__*/React.createElement(reactNative.TextInput, __assign({
659
373
  style: [styles$3.textArea, style],
660
374
  value: formValues[name] || '',
661
375
  onChangeText: handleChange,
@@ -669,7 +383,7 @@ var TextArea = function TextArea(_a) {
669
383
  errors: formErrors[name]
670
384
  })));
671
385
  };
672
- var styles$3 = require$$1.StyleSheet.create({
386
+ var styles$3 = reactNative.StyleSheet.create({
673
387
  container: {
674
388
  marginBottom: 16
675
389
  },
@@ -695,7 +409,7 @@ var styles$3 = require$$1.StyleSheet.create({
695
409
  var Label = function Label(_a) {
696
410
  var text = _a.text,
697
411
  style = _a.style;
698
- var theme = React.useContext(distExports.ThemeContext).theme;
412
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
699
413
  var colors = theme.colors;
700
414
  return /*#__PURE__*/React.createElement(Text, {
701
415
  style: [styles$2.label, style, {
@@ -703,7 +417,7 @@ var Label = function Label(_a) {
703
417
  }]
704
418
  }, text);
705
419
  };
706
- var styles$2 = require$$1.StyleSheet.create({
420
+ var styles$2 = reactNative.StyleSheet.create({
707
421
  label: {
708
422
  marginBottom: 4,
709
423
  fontWeight: '500'
@@ -770,11 +484,11 @@ var Button = function Button(_a) {
770
484
  _g = _a.loading,
771
485
  loading = _g === void 0 ? false : _g,
772
486
  onPress = _a.onPress;
773
- var theme = React.useContext(distExports.ThemeContext).theme;
487
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
774
488
  var colors = theme.colors;
775
489
  var handleSubmit = useFormContext().handleSubmit;
776
490
  var computedStyles = React.useMemo(function () {
777
- return require$$1.StyleSheet.flatten([styles$1.button, typeStyles(type, disabled, colors), rounded && {
491
+ return reactNative.StyleSheet.flatten([styles$1.button, typeStyles(type, disabled, colors), rounded && {
778
492
  borderRadius: borderRadius
779
493
  }, isFullWidth && {
780
494
  width: '100%'
@@ -794,7 +508,7 @@ var Button = function Button(_a) {
794
508
  onPress(); // Call a custom handler if needed
795
509
  }
796
510
  };
797
- return /*#__PURE__*/React.createElement(require$$1.TouchableOpacity, {
511
+ return /*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
798
512
  style: computedStyles,
799
513
  disabled: disabled || loading,
800
514
  onPress: handlePress,
@@ -802,14 +516,14 @@ var Button = function Button(_a) {
802
516
  }, loading ? (
803
517
  /*#__PURE__*/
804
518
  // Show loading spinner if loading
805
- React.createElement(require$$1.ActivityIndicator, {
519
+ React.createElement(reactNative.ActivityIndicator, {
806
520
  size: "small",
807
521
  color: colors.textButton.hex
808
- })) : (/*#__PURE__*/React.createElement(require$$1.Text, {
522
+ })) : (/*#__PURE__*/React.createElement(reactNative.Text, {
809
523
  style: textColor
810
524
  }, Array.isArray(children) ? children.join('').toUpperCase() : children === null || children === void 0 ? void 0 : children.toUpperCase())));
811
525
  };
812
- var styles$1 = require$$1.StyleSheet.create({
526
+ var styles$1 = reactNative.StyleSheet.create({
813
527
  button: {
814
528
  justifyContent: 'center',
815
529
  alignItems: 'center',
@@ -846,11 +560,11 @@ var Card = function Card(_a) {
846
560
  elevation = _d === void 0 ? 4 : _d,
847
561
  _e = _a.shadowProps,
848
562
  shadowProps = _e === void 0 ? {} : _e;
849
- var theme = React.useContext(distExports.ThemeContext).theme;
563
+ var theme = React.useContext(aportThemes.ThemeContext).theme;
850
564
  var colors = theme.colors;
851
565
  // Animation state for pressable effect
852
566
  // Default shadow styles (improved platform-specific handling)
853
- var defaultShadow = require$$1.Platform.select({
567
+ var defaultShadow = reactNative.Platform.select({
854
568
  ios: {
855
569
  shadowColor: (shadowProps === null || shadowProps === void 0 ? void 0 : shadowProps.shadowColor) || colors.text.hex,
856
570
  // Defaulting to theme text color
@@ -872,15 +586,15 @@ var Card = function Card(_a) {
872
586
  // Dynamic shadows based on platform
873
587
  style // External styles
874
588
  ];
875
- return pressable ? (/*#__PURE__*/React.createElement(require$$1.TouchableOpacity, {
589
+ return pressable ? (/*#__PURE__*/React.createElement(reactNative.TouchableOpacity, {
876
590
  activeOpacity: 0.8,
877
591
  onPress: onPress,
878
592
  style: cardStyles
879
- }, children)) : (/*#__PURE__*/React.createElement(require$$1.View, {
593
+ }, children)) : (/*#__PURE__*/React.createElement(reactNative.View, {
880
594
  style: cardStyles
881
595
  }, children));
882
596
  };
883
- var styles = require$$1.StyleSheet.create({
597
+ var styles = reactNative.StyleSheet.create({
884
598
  container: {
885
599
  padding: 16,
886
600
  borderRadius: 12