sapo-components-ui-rn 1.1.88 → 1.1.89

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.
@@ -1,29 +1,9 @@
1
- import IconClose from "./icon-close.svg";
2
- import IconCheckbox from "./icon-checkbox.svg";
3
- import IconCheckboxActive from "./icon-checkbox-active.svg";
4
- import IconRadio from "./icon-radio.svg";
5
- import IconRadioActive from "./icon-radio-active.svg";
6
- import IconSearch from "./icon-search.svg";
7
- import IconInfo from "./icon-info.svg";
8
- import IconSuccess from "./icon-success.svg";
9
- import IconWarning from "./icon-warning.svg";
10
- import IconArrowDown from "./icon-arrow-down.svg";
11
- import IconError from "./icon-error.svg";
12
- import IconClearText from "./icon-clear-text.svg";
13
- import IconDelNumber from './icon-del-number.svg'
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
+ let imageDefault: number | undefined;
14
3
 
15
- export const Svg = {
16
- IconClose,
17
- IconCheckbox,
18
- IconCheckboxActive,
19
- IconRadio,
20
- IconRadioActive,
21
- IconSearch,
22
- IconInfo,
23
- IconSuccess,
24
- IconWarning,
25
- IconArrowDown,
26
- IconError,
27
- IconClearText,
28
- IconDelNumber,
4
+ export const getImageDefault = (): number => {
5
+ if (imageDefault === undefined) {
6
+ imageDefault = require("./image_default.png");
7
+ }
8
+ return imageDefault;
29
9
  };
@@ -1,10 +1,10 @@
1
- import React from 'react';
2
- import { StyleProp, TextInput as NativeTextInput, TextStyle, ViewStyle } from 'react-native';
3
- import { Props as TextInputAffixProps } from './Adornment/TextInputAffix';
4
- import type { RenderProps, TextInputLabelProp } from './types';
5
- import type { ThemeProp } from '../../types';
1
+ import React from "react";
2
+ import { StyleProp, TextInput as NativeTextInput, TextStyle, ViewStyle } from "react-native";
3
+ import { Props as TextInputAffixProps } from "./Adornment/TextInputAffix";
4
+ import type { RenderProps, TextInputLabelProp } from "./types";
5
+ import type { ThemeProp } from "../../types";
6
6
  export type Props = React.ComponentPropsWithRef<typeof NativeTextInput> & {
7
- mode?: 'flat' | 'default' | 'number';
7
+ mode?: "flat" | "default" | "number";
8
8
  left?: React.ReactNode;
9
9
  right?: React.ReactNode;
10
10
  prefix?: string;
@@ -12,7 +12,7 @@ export type Props = React.ComponentPropsWithRef<typeof NativeTextInput> & {
12
12
  textError?: string;
13
13
  maxValue?: number;
14
14
  minValue?: number;
15
- type?: 'integer' | 'float';
15
+ type?: "integer" | "float";
16
16
  keyboardStyle?: StyleProp<ViewStyle>;
17
17
  formatDecimal?: 1 | 2 | 3;
18
18
  required?: boolean;
@@ -156,7 +156,7 @@ export type Props = React.ComponentPropsWithRef<typeof NativeTextInput> & {
156
156
  interface CompoundedComponent extends React.ForwardRefExoticComponent<Props & React.RefAttributes<TextInputHandles>> {
157
157
  Affix: React.FunctionComponent<Partial<TextInputAffixProps>>;
158
158
  }
159
- type TextInputHandles = Pick<NativeTextInput, 'focus' | 'clear' | 'blur' | 'isFocused' | 'setNativeProps'>;
159
+ type TextInputHandles = Pick<NativeTextInput, "focus" | "clear" | "blur" | "isFocused" | "setNativeProps">;
160
160
  /**
161
161
  * A component to allow users to input text.
162
162
  *
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { ThemeColors } from "./styles/themes/tokens";
2
2
  export { CONSTANTS } from "./styles/themes/tokens";
3
3
  export { ThemeColors as ThemeColorsProps } from "./types";
4
4
  export { default as containerStyles } from "./theme/container-styles";
5
+ export { useTheme, ThemeProvider, DefaultTheme, adaptNavigationTheme, } from "./core/theming";
5
6
  export * from "./styles/themes";
6
7
  export { default as Switch } from "./components/Switch/Switch";
7
8
  export { default as TextInput } from "./components/TextInput/TextInput";
package/dist/index.esm.js CHANGED
@@ -723,48 +723,6 @@ var containerStyles = StyleSheet.create({
723
723
  },
724
724
  });
725
725
 
726
- function configureV3Fonts(config) {
727
- if (!config) {
728
- return typescale;
729
- }
730
- var isFlatConfig = Object.keys(config).every(function (key) { return typeof config[key] !== "object"; });
731
- if (isFlatConfig) {
732
- return Object.fromEntries(Object.entries(typescale).map(function (_a) {
733
- var variantName = _a[0], variantProperties = _a[1];
734
- return [
735
- variantName,
736
- __assign(__assign({}, variantProperties), config),
737
- ];
738
- }));
739
- }
740
- return Object.assign.apply(Object, __spreadArray([{},
741
- typescale], Object.entries(config).map(function (_a) {
742
- var _b;
743
- var variantName = _a[0], variantProperties = _a[1];
744
- return (_b = {},
745
- _b[variantName] = __assign(__assign({}, typescale[variantName]), variantProperties),
746
- _b);
747
- }), false));
748
- }
749
- // eslint-disable-next-line no-redeclare
750
- function configureFonts(params) {
751
- var config = (params || {}).config;
752
- return configureV3Fonts(config);
753
- }
754
-
755
- var LightTheme = {
756
- dark: false,
757
- roundness: 8,
758
- version: 3,
759
- colors: ThemeColors.light.colors,
760
- fonts: configureFonts(),
761
- animation: {
762
- scale: 1.0,
763
- },
764
- };
765
-
766
- var DarkTheme = __assign(__assign({}, LightTheme), { dark: true, mode: "adaptive", version: 3, colors: ThemeColors.light.colors });
767
-
768
726
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
769
727
 
770
728
  var createTheming$2 = {};
@@ -1257,7 +1215,60 @@ var createTheming = _createTheming.default;
1257
1215
 
1258
1216
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1259
1217
 
1260
- var _a = createTheming(LightTheme); _a.ThemeProvider; _a.withTheme; _a.useTheme;
1218
+ function configureV3Fonts(config) {
1219
+ if (!config) {
1220
+ return typescale;
1221
+ }
1222
+ var isFlatConfig = Object.keys(config).every(function (key) { return typeof config[key] !== "object"; });
1223
+ if (isFlatConfig) {
1224
+ return Object.fromEntries(Object.entries(typescale).map(function (_a) {
1225
+ var variantName = _a[0], variantProperties = _a[1];
1226
+ return [
1227
+ variantName,
1228
+ __assign(__assign({}, variantProperties), config),
1229
+ ];
1230
+ }));
1231
+ }
1232
+ return Object.assign.apply(Object, __spreadArray([{},
1233
+ typescale], Object.entries(config).map(function (_a) {
1234
+ var _b;
1235
+ var variantName = _a[0], variantProperties = _a[1];
1236
+ return (_b = {},
1237
+ _b[variantName] = __assign(__assign({}, typescale[variantName]), variantProperties),
1238
+ _b);
1239
+ }), false));
1240
+ }
1241
+ // eslint-disable-next-line no-redeclare
1242
+ function configureFonts(params) {
1243
+ var config = (params || {}).config;
1244
+ return configureV3Fonts(config);
1245
+ }
1246
+
1247
+ var LightTheme = {
1248
+ dark: false,
1249
+ roundness: 8,
1250
+ version: 3,
1251
+ colors: ThemeColors.light.colors,
1252
+ fonts: configureFonts(),
1253
+ animation: {
1254
+ scale: 1.0,
1255
+ },
1256
+ };
1257
+
1258
+ var DarkTheme = __assign(__assign({}, LightTheme), { dark: true, mode: "adaptive", version: 3, colors: ThemeColors.light.colors });
1259
+
1260
+ var DefaultTheme = LightTheme;
1261
+ var _a = createTheming(LightTheme), BaseThemeProvider = _a.ThemeProvider; _a.withTheme; var useAppTheme = _a.useTheme;
1262
+ var ThemeProvider = function (_a) {
1263
+ var children = _a.children;
1264
+ var colorScheme = useColorScheme();
1265
+ var isDark = colorScheme === "dark";
1266
+ var theme = isDark ? DarkTheme : LightTheme;
1267
+ return React__default.createElement(BaseThemeProvider, { theme: theme }, children);
1268
+ };
1269
+ function useTheme(overrides) {
1270
+ return useAppTheme(overrides);
1271
+ }
1261
1272
  var useInternalTheme = function () {
1262
1273
  var colorScheme = useColorScheme();
1263
1274
  var isDark = colorScheme === "dark";
@@ -1273,6 +1284,43 @@ var getTheme = function (isDark) {
1273
1284
  var scheme = isDark ? "dark" : "light";
1274
1285
  return defaultThemesByVersion[scheme];
1275
1286
  };
1287
+ // eslint-disable-next-line no-redeclare
1288
+ function adaptNavigationTheme(themes) {
1289
+ var reactNavigationLight = themes.reactNavigationLight, reactNavigationDark = themes.reactNavigationDark, materialLight = themes.materialLight, materialDark = themes.materialDark;
1290
+ var getAdaptedTheme = function (navigationTheme, AppTheme) {
1291
+ return __assign(__assign({}, navigationTheme), { colors: __assign(__assign({}, navigationTheme.colors), { primary: AppTheme.colors.surfaceBrandDefault, background: AppTheme.colors.backgroundPrimary, card: AppTheme.colors.card, text: AppTheme.colors.backgroundPrimary, border: AppTheme.colors.borderPrimaryDefault, notification: AppTheme.colors.surfaceErrorDefault }) });
1292
+ };
1293
+ var AppThemes = {
1294
+ light: materialLight || LightTheme,
1295
+ dark: materialDark || DarkTheme,
1296
+ };
1297
+ if (reactNavigationLight && reactNavigationDark) {
1298
+ var modes = ["light", "dark"];
1299
+ var NavigationThemes_1 = {
1300
+ light: reactNavigationLight,
1301
+ dark: reactNavigationDark,
1302
+ };
1303
+ var _a = modes.reduce(function (prev, curr) {
1304
+ var _a;
1305
+ return __assign(__assign({}, prev), (_a = {}, _a[curr] = getAdaptedTheme(NavigationThemes_1[curr], AppThemes[curr]), _a));
1306
+ }, {
1307
+ light: reactNavigationLight,
1308
+ dark: reactNavigationDark,
1309
+ }), adaptedLight = _a.light, adaptedDark = _a.dark;
1310
+ return {
1311
+ LightTheme: adaptedLight,
1312
+ DarkTheme: adaptedDark,
1313
+ };
1314
+ }
1315
+ if (reactNavigationDark) {
1316
+ return {
1317
+ DarkTheme: getAdaptedTheme(reactNavigationDark, AppThemes.dark),
1318
+ };
1319
+ }
1320
+ return {
1321
+ LightTheme: getAdaptedTheme(reactNavigationLight, AppThemes.light),
1322
+ };
1323
+ }
1276
1324
 
1277
1325
  var ViewCustom = forwardRef$1(function (_a, ref) {
1278
1326
  var row = _a.row, full = _a.full, justifyCenter = _a.justifyCenter, justifyBetween = _a.justifyBetween, alignCenter = _a.alignCenter, center = _a.center, color = _a.color, backgroundColor = _a.backgroundColor, width = _a.width, height = _a.height, padding = _a.padding, paddingHorizontal = _a.paddingHorizontal, paddingVertical = _a.paddingVertical, marginHorizontal = _a.marginHorizontal, marginVertical = _a.marginVertical, paddingLeft = _a.paddingLeft, paddingRight = _a.paddingRight, paddingTop = _a.paddingTop, alignEnd = _a.alignEnd, wrap = _a.wrap, borderBottomWidth = _a.borderBottomWidth, borderBottomColor = _a.borderBottomColor, borderRadius = _a.borderRadius, borderWidth = _a.borderWidth, borderColor = _a.borderColor, style = _a.style, onPress = _a.onPress, _b = _a.activeOpacity, activeOpacity = _b === void 0 ? 0.8 : _b, children = _a.children, disabled = _a.disabled, paddingBottom = _a.paddingBottom, marginTop = _a.marginTop, marginBottom = _a.marginBottom, marginLeft = _a.marginLeft, marginRight = _a.marginRight, margin = _a.margin, borderTopWidth = _a.borderTopWidth, borderTopColor = _a.borderTopColor, borderLeftWidth = _a.borderLeftWidth, borderLeftColor = _a.borderLeftColor, borderRightWidth = _a.borderRightWidth, borderRightColor = _a.borderRightColor, pointerEvents = _a.pointerEvents, gap = _a.gap,
@@ -5928,7 +5976,7 @@ var DefaultRenderer = function (props) { return React__default.createElement(Tex
5928
5976
  * @extends TextInput props https://reactnative.dev/docs/textinput#props
5929
5977
  */
5930
5978
  var TextInput = forwardRef(function (_a, ref) {
5931
- var _b = _a.mode, mode = _b === void 0 ? 'default' : _b, _c = _a.dense, dense = _c === void 0 ? false : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, errorProp = _e === void 0 ? false : _e, _f = _a.multiline, multiline = _f === void 0 ? false : _f, _g = _a.editable, editable = _g === void 0 ? true : _g, contentStyle = _a.contentStyle, _h = _a.render, render = _h === void 0 ? DefaultRenderer : _h; _a.theme; var placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, textError = _a.textError, prefix = _a.prefix, suffix = _a.suffix, maxValue = _a.maxValue, minValue = _a.minValue, type = _a.type, _j = _a.required, required = _j === void 0 ? false : _j, keyboardStyle = _a.keyboardStyle, rest = __rest(_a, ["mode", "dense", "disabled", "error", "multiline", "editable", "contentStyle", "render", "theme", "placeholderTextColor", "clearButton", "textError", "prefix", "suffix", "maxValue", "minValue", "type", "required", "keyboardStyle"]);
5979
+ var _b = _a.mode, mode = _b === void 0 ? "flat" : _b, _c = _a.dense, dense = _c === void 0 ? false : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.error, errorProp = _e === void 0 ? false : _e, _f = _a.multiline, multiline = _f === void 0 ? false : _f, _g = _a.editable, editable = _g === void 0 ? true : _g, contentStyle = _a.contentStyle, _h = _a.render, render = _h === void 0 ? DefaultRenderer : _h; _a.theme; var placeholderTextColor = _a.placeholderTextColor, clearButton = _a.clearButton, textError = _a.textError, prefix = _a.prefix, suffix = _a.suffix, maxValue = _a.maxValue, minValue = _a.minValue, type = _a.type, _j = _a.required, required = _j === void 0 ? false : _j, keyboardStyle = _a.keyboardStyle, rest = __rest(_a, ["mode", "dense", "disabled", "error", "multiline", "editable", "contentStyle", "render", "theme", "placeholderTextColor", "clearButton", "textError", "prefix", "suffix", "maxValue", "minValue", "type", "required", "keyboardStyle"]);
5932
5980
  var theme = useInternalTheme();
5933
5981
  var isControlled = rest.value !== undefined;
5934
5982
  var validInputValue = isControlled ? rest.value : rest.defaultValue;
@@ -6113,7 +6161,7 @@ var TextInput = forwardRef(function (_a, ref) {
6113
6161
  var forceFocus = React__default.useCallback(function () { var _a; return (_a = root.current) === null || _a === void 0 ? void 0 : _a.focus(); }, []);
6114
6162
  var _t = rest.maxFontSizeMultiplier, maxFontSizeMultiplier = _t === void 0 ? 1.5 : _t;
6115
6163
  var scaledLabel = !!(value || focused);
6116
- if (mode === 'default') {
6164
+ if (mode === "default") {
6117
6165
  return (React__default.createElement(TextInputDefault, __assign({ dense: dense, disabled: disabled, error: errorProp, textError: textError, required: required, multiline: multiline, editable: editable, prefix: prefix, suffix: suffix, render: render }, rest, { theme: theme, value: value, placeholderTextColor: placeholderTextColor, clearButton: clearButton, parentState: {
6118
6166
  labeled: labeled,
6119
6167
  error: error,
@@ -6129,7 +6177,7 @@ var TextInput = forwardRef(function (_a, ref) {
6129
6177
  root.current = ref;
6130
6178
  }, onFocus: handleFocus, forceFocus: forceFocus, onBlur: handleBlur, allowFontScaling: false, onChangeText: handleChangeText, onLayoutAnimatedText: handleLayoutAnimatedText, onInputLayout: handleInputContainerLayout, onLabelTextLayout: handleLabelTextLayout, onLeftAffixLayoutChange: onLeftAffixLayoutChange, onRightAffixLayoutChange: onRightAffixLayoutChange, maxFontSizeMultiplier: maxFontSizeMultiplier, contentStyle: contentStyle, scaledLabel: scaledLabel })));
6131
6179
  }
6132
- if (mode === 'number') {
6180
+ if (mode === "number") {
6133
6181
  return (React__default.createElement(TextInputNumber$1, { textError: textError, disabled: disabled, prefix: prefix, suffix: suffix, value: value, right: rest.right, left: rest.left, required: required, label: rest.label, clearButton: clearButton, onChangeText: handleChangeText, maxValue: maxValue, minValue: minValue, formatDecimal: rest.formatDecimal, type: type, keyboardStyle: keyboardStyle }));
6134
6182
  }
6135
6183
  return (React__default.createElement(TextInputFlat, __assign({ dense: dense, disabled: disabled, error: errorProp, textError: textError, editable: editable, prefix: prefix, suffix: suffix, clearButton: clearButton, required: required, render: render }, rest, { theme: theme, value: value, parentState: {
@@ -7695,5 +7743,5 @@ var ToastProvider = forwardRef$1(function (_a, ref) {
7695
7743
  renderToast()));
7696
7744
  });
7697
7745
 
7698
- export { Avatar, Badge, index$3 as Button, CONSTANTS, Checkbox, ChipBar, CountingDot, DarkTheme, index$2 as FloatingButton, Image$1 as Image, LightTheme, index as NumberKeyboard, RadioButton, SearchInput, index$1 as SelectionField, Spacer, Switch, Tag, Text$1 as Text, TextInput, ThemeColors, Toast, ToastProvider, View, containerStyles, showToast, toastRef };
7746
+ export { Avatar, Badge, index$3 as Button, CONSTANTS, Checkbox, ChipBar, CountingDot, DarkTheme, DefaultTheme, index$2 as FloatingButton, Image$1 as Image, LightTheme, index as NumberKeyboard, RadioButton, SearchInput, index$1 as SelectionField, Spacer, Switch, Tag, Text$1 as Text, TextInput, ThemeColors, ThemeProvider, Toast, ToastProvider, View, adaptNavigationTheme, containerStyles, showToast, toastRef, useTheme };
7699
7747
  //# sourceMappingURL=index.esm.js.map