@pedidopago/ui 1.7.25 → 1.8.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/components/Alert/alert.test.js +1 -85
- package/dist/components/Alert/index.js +1 -63
- package/dist/components/Alert/styles.js +1 -32
- package/dist/components/Avatar/avatar.test.js +1 -67
- package/dist/components/Avatar/index.js +1 -94
- package/dist/components/Avatar/styles.js +1 -51
- package/dist/components/Badge/badge.test.js +1 -71
- package/dist/components/Badge/index.js +2 -43
- package/dist/components/Badge/styles.js +1 -33
- package/dist/components/Button/Button.test.js +1 -154
- package/dist/components/Button/index.js +1 -87
- package/dist/components/Button/styles.js +1 -112
- package/dist/components/Card/card.test.js +1 -30
- package/dist/components/Card/index.js +1 -44
- package/dist/components/Card/styles.js +1 -16
- package/dist/components/CheckboxInput/checkbox-input.test.js +1 -170
- package/dist/components/CheckboxInput/components/MultipleCheckbox.js +1 -205
- package/dist/components/CheckboxInput/index.js +1 -94
- package/dist/components/CheckboxInput/styles.js +1 -34
- package/dist/components/ChoiceList/index.d.ts +6 -0
- package/dist/components/ChoiceList/index.d.ts.map +1 -0
- package/dist/components/ChoiceList/index.js +1 -0
- package/dist/components/ChoiceList/styles.d.ts +22 -0
- package/dist/components/ChoiceList/styles.d.ts.map +1 -0
- package/dist/components/ChoiceList/styles.js +1 -0
- package/dist/components/ChoiceList/types.d.ts +24 -0
- package/dist/components/ChoiceList/types.d.ts.map +1 -0
- package/dist/components/ChoiceList/types.js +1 -0
- package/dist/components/CollapseCard/ExpandButton/index.js +1 -40
- package/dist/components/CollapseCard/ExpandButton/styles.js +1 -16
- package/dist/components/CollapseCard/expand-button.test.js +1 -161
- package/dist/components/CollapseCard/index.js +1 -98
- package/dist/components/CollapseCard/styles.js +1 -26
- package/dist/components/ColorPicker/colorpicker.test.js +1 -64
- package/dist/components/ColorPicker/components/ColorHue.js +1 -44
- package/dist/components/ColorPicker/components/ColorInput.js +1 -63
- package/dist/components/ColorPicker/components/ColorPickerBox.js +1 -52
- package/dist/components/ColorPicker/components/ColorPointer.js +1 -25
- package/dist/components/ColorPicker/components/ColorSelector.js +1 -107
- package/dist/components/ColorPicker/hooks/useCachedCallback.js +1 -16
- package/dist/components/ColorPicker/hooks/useHsva.js +1 -53
- package/dist/components/ColorPicker/index.js +1 -93
- package/dist/components/ColorPicker/styles.js +1 -46
- package/dist/components/ColorPicker/utils/checkers.js +1 -55
- package/dist/components/ColorPicker/utils/conversors.js +2 -243
- package/dist/components/ColorPicker/utils/parsers.js +10 -108
- package/dist/components/ComposeIcon/index.js +2 -48
- package/dist/components/ComposeIcon/styles.js +1 -53
- package/dist/components/DateInput/DateInput-example.js +7 -45
- package/dist/components/DateInput/components/ModalWrapper/index.js +1 -35
- package/dist/components/DateInput/components/ModalWrapper/styles.js +1 -21
- package/dist/components/DateInput/dateInput.test.js +2 -43
- package/dist/components/DateInput/index.js +2 -104
- package/dist/components/DateInput/styles.js +1 -18
- package/dist/components/DatePicker/components/DatePickerContent.js +2 -222
- package/dist/components/DatePicker/components/DateYearPicker.js +1 -102
- package/dist/components/DatePicker/datepicker.test.js +1 -120
- package/dist/components/DatePicker/index.js +1 -236
- package/dist/components/DatePicker/styles.js +1 -88
- package/dist/components/DatePicker/utils/getMonthName.js +1 -11
- package/dist/components/Dialog/dialog-example.js +1 -46
- package/dist/components/Dialog/dialog.test.js +1 -68
- package/dist/components/Dialog/index.js +2 -100
- package/dist/components/Dialog/styles.js +1 -31
- package/dist/components/Dropzone/dropzone.test.js +1 -69
- package/dist/components/Dropzone/index.js +1 -289
- package/dist/components/Dropzone/styles.js +1 -75
- package/dist/components/Dropzone/utils/accepts.js +2 -27
- package/dist/components/EmojiPicker/Emote/index.js +2 -24
- package/dist/components/EmojiPicker/Emote/styles.js +1 -27
- package/dist/components/EmojiPicker/EmotePickerData/constants.js +1 -51
- package/dist/components/EmojiPicker/EmotePickerData/index.js +2 -159
- package/dist/components/EmojiPicker/EmotePickerData/styles.js +1 -57
- package/dist/components/EmojiPicker/EmotePickerData/utils.js +1 -41
- package/dist/components/EmojiPicker/Example/EmotePickerExample.js +1 -43
- package/dist/components/EmojiPicker/animation.js +1 -43
- package/dist/components/EmojiPicker/index.js +1 -169
- package/dist/components/EmojiPicker/styles.js +1 -21
- package/dist/components/Flex/flex.test.js +1 -336
- package/dist/components/Flex/index.js +1 -49
- package/dist/components/Flex/styles.js +1 -25
- package/dist/components/Grid/grid.test.js +1 -134
- package/dist/components/Grid/index.js +1 -51
- package/dist/components/Grid/styles.js +1 -48
- package/dist/components/Icon/data/beauty.js +2 -206
- package/dist/components/Icon/data/dash.js +2 -2
- package/dist/components/Icon/data/ecommerce.js +2 -94
- package/dist/components/Icon/data/form.js +2 -248
- package/dist/components/Icon/data/health.js +2 -255
- package/dist/components/Icon/data/illustrations.js +2 -318
- package/dist/components/Icon/data/men.js +2 -52
- package/dist/components/Icon/data/payment.js +2 -94
- package/dist/components/Icon/data/pedidoPago.js +2 -45
- package/dist/components/Icon/data/physicalPerfomance.js +2 -283
- package/dist/components/Icon/data/social.js +2 -24
- package/dist/components/Icon/data/status.js +2 -115
- package/dist/components/Icon/data/summer.js +2 -52
- package/dist/components/Icon/data/woman.js +2 -80
- package/dist/components/Icon/icon.test.js +1 -57
- package/dist/components/Icon/index.js +1 -53
- package/dist/components/Icon/scripts/build.js +9 -104
- package/dist/components/Icon/scripts/extractor.js +2 -33
- package/dist/components/Icon/scripts/run-build.js +2 -7
- package/dist/components/Icon/scripts/writers.js +3 -34
- package/dist/components/Icon/styles.js +1 -22
- package/dist/components/Icon/utils/allIcons.js +1 -28
- package/dist/components/Icon/utils/iconExists.js +1 -13
- package/dist/components/IconItem/IconItem.test.js +1 -58
- package/dist/components/IconItem/index.js +1 -52
- package/dist/components/IconItem/styles.js +1 -43
- package/dist/components/Illustration/illustration.test.js +4 -50
- package/dist/components/Illustration/index.js +2 -65
- package/dist/components/Illustration/styles.js +1 -65
- package/dist/components/ImageItem/imageFake.js +1 -25
- package/dist/components/ImageItem/index.js +2 -66
- package/dist/components/ImageItem/input.test.js +1 -85
- package/dist/components/ImageItem/styles.js +1 -61
- package/dist/components/Input/index.js +1 -163
- package/dist/components/Input/input.test.js +1 -120
- package/dist/components/Input/styles.js +1 -177
- package/dist/components/Label/index.js +1 -45
- package/dist/components/Label/label.test.js +1 -83
- package/dist/components/Label/styles.js +1 -21
- package/dist/components/List/index.js +1 -39
- package/dist/components/List/list.test.js +1 -64
- package/dist/components/List/styles.js +1 -23
- package/dist/components/Modal/ModalExample.js +1 -70
- package/dist/components/Modal/index.js +1 -145
- package/dist/components/Modal/modal.test.js +1 -179
- package/dist/components/Modal/styles.js +1 -33
- package/dist/components/MultipleSelect/MultipleSelect.test.js +1 -334
- package/dist/components/MultipleSelect/animations.js +1 -25
- package/dist/components/MultipleSelect/components/InputWrapper/index.js +1 -26
- package/dist/components/MultipleSelect/components/OptionsArea/index.js +1 -244
- package/dist/components/MultipleSelect/components/OptionsArea/styles.js +1 -68
- package/dist/components/MultipleSelect/components/SelectArea/ButtonsArea.js +1 -27
- package/dist/components/MultipleSelect/components/SelectArea/SelectAreaWrapper.js +1 -37
- package/dist/components/MultipleSelect/components/SelectArea/SelectedOptionsArea.js +1 -49
- package/dist/components/MultipleSelect/components/SelectArea/index.js +1 -100
- package/dist/components/MultipleSelect/components/SelectArea/styles.js +1 -36
- package/dist/components/MultipleSelect/components/index.js +1 -38
- package/dist/components/MultipleSelect/index.js +1 -209
- package/dist/components/NewSelect/Examples/constants.js +1 -56
- package/dist/components/NewSelect/Examples/index.js +1 -161
- package/dist/components/NewSelect/components/Chip/index.js +1 -36
- package/dist/components/NewSelect/components/Chip/styles.js +1 -24
- package/dist/components/NewSelect/components/OptionsSelect/styles.js +1 -21
- package/dist/components/NewSelect/components/SelectInputSearch/index.js +1 -24
- package/dist/components/NewSelect/components/SelectItem/index.js +1 -22
- package/dist/components/NewSelect/components/SelectItem/styles.js +1 -24
- package/dist/components/NewSelect/index.js +1 -18
- package/dist/components/NewSelect/multiple/index.d.ts.map +1 -1
- package/dist/components/NewSelect/multiple/index.js +1 -247
- package/dist/components/NewSelect/newSelect.test.js +1 -108
- package/dist/components/NewSelect/single/index.js +1 -183
- package/dist/components/NewSelect/styles.js +1 -44
- package/dist/components/Observer/index.js +1 -59
- package/dist/components/Observer/observer.test.js +2 -43
- package/dist/components/Pagination/hooks/usePagination.js +1 -57
- package/dist/components/Pagination/index.js +1 -174
- package/dist/components/Pagination/pagination.test.js +1 -118
- package/dist/components/Pagination/styles.js +1 -78
- package/dist/components/Progress/Circle/index.js +1 -102
- package/dist/components/Progress/Circle/styles.js +1 -69
- package/dist/components/Progress/Linear/index.js +1 -62
- package/dist/components/Progress/Linear/styles.js +1 -66
- package/dist/components/Progress/getSteps.js +1 -17
- package/dist/components/Progress/index.js +1 -39
- package/dist/components/Progress/progress.test.js +1 -109
- package/dist/components/Radio/components/RadioGroup/index.d.ts +5 -0
- package/dist/components/Radio/components/RadioGroup/index.d.ts.map +1 -0
- package/dist/components/Radio/components/RadioGroup/index.js +1 -0
- package/dist/components/Radio/components/RadioGroup/styles.d.ts +19 -0
- package/dist/components/Radio/components/RadioGroup/styles.d.ts.map +1 -0
- package/dist/components/Radio/components/RadioGroup/styles.js +1 -0
- package/dist/components/Radio/components/RadioGroup/types.d.ts +17 -0
- package/dist/components/Radio/components/RadioGroup/types.d.ts.map +1 -0
- package/dist/components/Radio/components/RadioGroup/types.js +1 -0
- package/dist/components/Radio/index.d.ts +5 -0
- package/dist/components/Radio/index.d.ts.map +1 -0
- package/dist/components/Radio/index.js +1 -0
- package/dist/components/Radio/styles.d.ts +10 -0
- package/dist/components/Radio/styles.d.ts.map +1 -0
- package/dist/components/Radio/styles.js +1 -0
- package/dist/components/Radio/types.d.ts +6 -0
- package/dist/components/Radio/types.d.ts.map +1 -0
- package/dist/components/Radio/types.js +1 -0
- package/dist/components/Rating/index.js +1 -133
- package/dist/components/Rating/rating.test.js +1 -63
- package/dist/components/Rating/styles.js +1 -27
- package/dist/components/ReactPortal/index.js +1 -43
- package/dist/components/ReactPortal/reactPortal.test.js +1 -21
- package/dist/components/ReactPortal/utils/createWrapperAndApprendToBody.js +1 -12
- package/dist/components/Select/components/OptionsSelect/index.js +1 -73
- package/dist/components/Select/components/OptionsSelect/styles.js +1 -21
- package/dist/components/Select/index.js +4 -247
- package/dist/components/Select/select.test.js +1 -58
- package/dist/components/Select/styles.js +1 -46
- package/dist/components/Skeleton/index.js +1 -28
- package/dist/components/Skeleton/skeleton.test.js +1 -90
- package/dist/components/Skeleton/styles.js +1 -27
- package/dist/components/Slider/SliderExample.js +1 -52
- package/dist/components/Slider/components/SliderPointer.js +1 -39
- package/dist/components/Slider/components/SliderRail.js +1 -116
- package/dist/components/Slider/components/SliderSelector.js +1 -173
- package/dist/components/Slider/hooks/useEventCallback.js +1 -16
- package/dist/components/Slider/index.js +1 -137
- package/dist/components/Slider/slider.test.js +1 -121
- package/dist/components/Slider/styles.js +1 -69
- package/dist/components/Spinner/index.js +1 -26
- package/dist/components/Spinner/spinner.test.js +1 -45
- package/dist/components/Spinner/styles.js +1 -23
- package/dist/components/Steps/components/StepIcon/index.js +1 -50
- package/dist/components/Steps/components/StepIcon/styles.js +1 -42
- package/dist/components/Steps/components/StepIcon/utils.js +1 -22
- package/dist/components/Steps/index.js +1 -116
- package/dist/components/Steps/steps.test.js +1 -53
- package/dist/components/Steps/styles.js +1 -96
- package/dist/components/Steps/utils.js +1 -15
- package/dist/components/Switch/index.js +1 -73
- package/dist/components/Switch/styles.js +1 -58
- package/dist/components/Switch/switch.test.js +2 -115
- package/dist/components/Table/components/MenuItem.js +1 -59
- package/dist/components/Table/components/TableSkeleton.js +1 -39
- package/dist/components/Table/components/animations.js +1 -24
- package/dist/components/Table/index.js +2 -253
- package/dist/components/Table/styles.js +1 -49
- package/dist/components/Table/table.test.js +1 -114
- package/dist/components/Tabs/TabsExample.js +1 -64
- package/dist/components/Tabs/components/Tab.js +1 -49
- package/dist/components/Tabs/components/TabPanel.js +1 -25
- package/dist/components/Tabs/components/Tabs.js +1 -107
- package/dist/components/Tabs/index.js +1 -26
- package/dist/components/Tabs/styles.js +1 -61
- package/dist/components/Tabs/tabs.test.js +1 -146
- package/dist/components/Tag/index.js +1 -53
- package/dist/components/Tag/styles.js +1 -34
- package/dist/components/Tag/tag.test.js +1 -64
- package/dist/components/TextAreaInput/index.js +1 -74
- package/dist/components/TextAreaInput/styles.js +1 -53
- package/dist/components/TextAreaInput/text-area-input.test.js +1 -81
- package/dist/components/Thumbnail/index.js +1 -125
- package/dist/components/Thumbnail/styles.js +1 -47
- package/dist/components/Thumbnail/thumbnail.test.js +1 -66
- package/dist/components/Thumbnail/utils/index.js +1 -27
- package/dist/components/Thumbnail/utils/validate-file-size.js +1 -10
- package/dist/components/Thumbnail/utils/validate-file-type.js +1 -9
- package/dist/components/TimeInput/constants.js +1 -29
- package/dist/components/TimeInput/index.js +1 -288
- package/dist/components/TimeInput/styles.js +1 -34
- package/dist/components/TimeInput/utils.js +1 -94
- package/dist/components/Timeline/components/Timeline.js +1 -17
- package/dist/components/Timeline/components/TimelineContent.js +1 -61
- package/dist/components/Timeline/components/TimelineItem.js +1 -25
- package/dist/components/Timeline/components/TimelineSeparator.js +1 -20
- package/dist/components/Timeline/index.js +1 -33
- package/dist/components/Timeline/styles.js +1 -37
- package/dist/components/Timeline/timeline.test.js +1 -138
- package/dist/components/Toast/button-example.js +1 -31
- package/dist/components/Toast/components/Toast.js +1 -79
- package/dist/components/Toast/contexts/ToastProvider.js +1 -72
- package/dist/components/Toast/hooks/useToast.js +1 -18
- package/dist/components/Toast/index.js +1 -111
- package/dist/components/Toast/styles.js +1 -36
- package/dist/components/Toast/toast.test.js +1 -129
- package/dist/components/Tooltip/components/TooltipLabel.js +1 -71
- package/dist/components/Tooltip/example.js +1 -27
- package/dist/components/Tooltip/index.js +1 -187
- package/dist/components/Tooltip/styles.js +1 -20
- package/dist/components/Typography/index.js +1 -37
- package/dist/components/Typography/styles.js +1 -15
- package/dist/components/Typography/typography.test.js +1 -288
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -548
- package/dist/shared/animations/opacityAnimation.js +1 -21
- package/dist/shared/assets/emotes.js +1 -1
- package/dist/shared/components/FocusLock/index.js +5 -86
- package/dist/shared/formatters/format-number.js +5 -41
- package/dist/shared/global.js +1 -8
- package/dist/shared/hooks/devices.js +1 -14
- package/dist/shared/hooks/useBreakpoints.js +2 -95
- package/dist/shared/hooks/useDebounce.js +1 -35
- package/dist/shared/hooks/useDevices.js +2 -42
- package/dist/shared/hooks/useDisableBodyScroll.js +5 -52
- package/dist/shared/hooks/useDraggableScroll/index.js +5 -65
- package/dist/shared/hooks/useKeyPress.js +1 -18
- package/dist/shared/hooks/useObserver.js +2 -29
- package/dist/shared/hooks/useOnClickOutside.js +1 -30
- package/dist/shared/hooks/useReposition/index.js +2 -53
- package/dist/shared/hooks/useSystemTheme.js +1 -38
- package/dist/shared/hooks/useWindowSize.js +1 -36
- package/dist/shared/tests/test-utils.js +1 -31
- package/dist/shared/theme/button-example.js +1 -31
- package/dist/shared/theme/contexts/ThemeContext.js +1 -90
- package/dist/shared/theme/hooks/useColorMode.js +1 -18
- package/dist/shared/theme/hooks/useColorModeValue.js +1 -13
- package/dist/shared/theme/hooks/useTheme.js +1 -17
- package/dist/shared/theme/index.js +1 -67
- package/dist/shared/theme/objects/breakpoints.js +1 -15
- package/dist/shared/theme/objects/colors.js +1 -177
- package/dist/shared/theme/objects/shadows.js +1 -19
- package/dist/shared/theme/objects/sizes.js +6 -33
- package/dist/shared/theme/objects/spaces.js +1 -75
- package/dist/shared/theme/objects/transitions.js +1 -10
- package/dist/shared/theme/objects/typography.js +1 -20
- package/dist/shared/theme/objects/z-indexes.js +1 -20
- package/dist/shared/theme/theme.js +1 -36
- package/dist/shared/theme/theme.test.js +1 -94
- package/dist/shared/theme/utils/extendTheme.js +1 -25
- package/dist/shared/theme/utils/localStorageController.js +1 -21
- package/dist/styled.d.js +1 -3
- package/dist/utils/GenerateKey.js +3 -18
- package/dist/utils/brightnessColorChange.js +2 -17
- package/dist/utils/colorCheck.js +6 -64
- package/dist/utils/colorFunctions.js +1 -39
- package/dist/utils/colorToGray.js +2 -64
- package/dist/utils/customColorMode.js +1 -11
- package/dist/utils/file.js +5 -124
- package/dist/utils/formatters/bytes.js +2 -17
- package/dist/utils/formatters/capitalize.js +2 -11
- package/dist/utils/formatters/cep.js +3 -18
- package/dist/utils/formatters/cnpj.js +4 -38
- package/dist/utils/formatters/color.js +12 -101
- package/dist/utils/formatters/cpf.js +16 -85
- package/dist/utils/formatters/credit-card.js +5 -54
- package/dist/utils/formatters/email.js +1 -8
- package/dist/utils/formatters/index.js +1 -170
- package/dist/utils/formatters/name.js +4 -31
- package/dist/utils/formatters/number.js +5 -14
- package/dist/utils/formatters/passport.js +5 -33
- package/dist/utils/formatters/phone.js +17 -214
- package/dist/utils/formatters/price.js +3 -21
- package/dist/utils/formatters/rg.js +3 -18
- package/dist/utils/formatters/strings.js +4 -27
- package/dist/utils/fuctionsColors.js +1 -39
- package/dist/utils/generateUUID.js +1 -13
- package/dist/utils/getColorValue.js +2 -23
- package/dist/utils/getSvg.js +1 -17
- package/dist/utils/getValuesBySize.js +1 -9
- package/dist/utils/invertColor.js +4 -40
- package/package.json +2 -1
|
@@ -1,248 +1,51 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formatGuestPhone = formatGuestPhone;
|
|
7
|
-
exports.formatPhone = formatPhone;
|
|
8
|
-
exports.formatPhoneWithPrefix = formatPhoneWithPrefix;
|
|
9
|
-
exports.formatedPhone = formatedPhone;
|
|
10
|
-
exports.getDDI = getDDI;
|
|
11
|
-
exports.phoneNineDigitParser = phoneNineDigitParser;
|
|
12
|
-
exports.phoneValidator = phoneValidator;
|
|
13
|
-
exports.sanitizePhone = sanitizePhone;
|
|
14
|
-
exports.validatePhone = validatePhone;
|
|
15
|
-
exports.verifyNineDigit = verifyNineDigit;
|
|
16
|
-
var _phone = _interopRequireDefault(require("phone"));
|
|
17
|
-
var _max = require("libphonenumber-js/max");
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
24
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
25
|
-
/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatGuestPhone=formatGuestPhone,exports.formatPhone=formatPhone,exports.formatPhoneWithPrefix=formatPhoneWithPrefix,exports.formatedPhone=formatedPhone,exports.getDDI=getDDI,exports.phoneNineDigitParser=phoneNineDigitParser,exports.phoneValidator=phoneValidator,exports.sanitizePhone=sanitizePhone,exports.validatePhone=validatePhone,exports.verifyNineDigit=verifyNineDigit;var _phone=_interopRequireDefault(require("phone")),_max=require("libphonenumber-js/max");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _typeof(obj){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_typeof(obj)}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var source,i=1;i<arguments.length;i++)source=null==arguments[i]?{}:arguments[i],i%2?ownKeys(Object(source),!0).forEach(function(key){_defineProperty(target,key,source[key])}):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))});return target}function _defineProperty(obj,key,value){return key=_toPropertyKey(key),key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return"symbol"===_typeof(key)?key:key+""}function _toPrimitive(input,hint){if("object"!==_typeof(input)||null===input)return input;var prim=input[Symbol.toPrimitive];if(prim!==void 0){var res=prim.call(input,hint||"default");if("object"!==_typeof(res))return res;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===hint?String:Number)(input)}/**
|
|
26
2
|
* Formats phone numbers with a default ddi of +55 and adds a country prefix if needed.
|
|
27
3
|
* @param {string} phone - The phone number to be formatted.
|
|
28
4
|
* @param {string} [ddi='+55'] - The default ddi to use.
|
|
29
5
|
* @returns {string} The formatted phone number with prefix.
|
|
30
|
-
*/
|
|
31
|
-
function formatPhoneWithPrefix(phone) {
|
|
32
|
-
var ddi = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '+55';
|
|
33
|
-
if (phone) {
|
|
34
|
-
var sanitizedPhone = phone.replace(/[^\d]/g, '').replace(/^0/, '');
|
|
35
|
-
switch (ddi) {
|
|
36
|
-
case '+55':
|
|
37
|
-
switch (sanitizedPhone.length) {
|
|
38
|
-
case 13:
|
|
39
|
-
{
|
|
40
|
-
return sanitizedPhone.replace(/^(\d{2}|\d{2})\B/, '+$1 ').replace(/(\d{2}|\d{2})?(\d{2}|\d{2})(\d{1}|\d{1})(\d{4}|\d{4})(\d{4}|\d{4})/, '$1 $2 $3 $4-$5');
|
|
41
|
-
}
|
|
42
|
-
case 12:
|
|
43
|
-
{
|
|
44
|
-
return sanitizedPhone.replace(/^(\d{2}|\d{2})\B/, '+$1 ').replace(/(\d{2}|\d{2})?(\d{2}|\d{2})(\d{4}|\d{4})(\d{4}|\d{4})/, '$1 $2 $3-$4');
|
|
45
|
-
}
|
|
46
|
-
case 11:
|
|
47
|
-
{
|
|
48
|
-
return sanitizedPhone.replace(/^(\d{2}|\d{2})\B/, '+$1 ').replace(/(\d{2}|\d{2})?(\d{1}|\d{1})(\d{4}|\d{4})(\d{4}|\d{4})/, '$1 $2 $3-$4');
|
|
49
|
-
}
|
|
50
|
-
default:
|
|
51
|
-
return sanitizedPhone;
|
|
52
|
-
}
|
|
53
|
-
default:
|
|
54
|
-
return sanitizedPhone;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return '';
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
6
|
+
*/function formatPhoneWithPrefix(phone){var ddi=1<arguments.length&&arguments[1]!==void 0?arguments[1]:"+55";if(phone){var sanitizedPhone=phone.replace(/[^\d]/g,"").replace(/^0/,"");switch(ddi){case"+55":switch(sanitizedPhone.length){case 13:return sanitizedPhone.replace(/^(\d{2}|\d{2})\B/,"+$1 ").replace(/(\d{2}|\d{2})?(\d{2}|\d{2})(\d{1}|\d{1})(\d{4}|\d{4})(\d{4}|\d{4})/,"$1 $2 $3 $4-$5");case 12:return sanitizedPhone.replace(/^(\d{2}|\d{2})\B/,"+$1 ").replace(/(\d{2}|\d{2})?(\d{2}|\d{2})(\d{4}|\d{4})(\d{4}|\d{4})/,"$1 $2 $3-$4");case 11:return sanitizedPhone.replace(/^(\d{2}|\d{2})\B/,"+$1 ").replace(/(\d{2}|\d{2})?(\d{1}|\d{1})(\d{4}|\d{4})(\d{4}|\d{4})/,"$1 $2 $3-$4");default:return sanitizedPhone;}default:return sanitizedPhone;}}return""}/**
|
|
61
7
|
* Sanitizes phone numbers by removing all non-digit characters and leading zeroes.
|
|
62
8
|
* @param {string} phone - The phone number to be sanitized.
|
|
63
9
|
* @returns {string} The sanitized phone number.
|
|
64
|
-
*/
|
|
65
|
-
function sanitizePhone(phone) {
|
|
66
|
-
return phone ? phone.replace(/\D/g, '').replace(/^0/, '') : '';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
10
|
+
*/function sanitizePhone(phone){return phone?phone.replace(/\D/g,"").replace(/^0/,""):""}/**
|
|
70
11
|
* Validates if a phone number is valid according to Brazilian phone number rules.
|
|
71
12
|
* @param {string} phone - The phone number to be validated.
|
|
72
13
|
* @returns {boolean} - Returns true if the phone number is valid or false otherwise.
|
|
73
|
-
*/
|
|
74
|
-
function phoneValidator(phone) {
|
|
75
|
-
var ddi = Number(phone.slice(0, 2));
|
|
76
|
-
var ddd = Number(phone.slice(2, 4));
|
|
77
|
-
var firstDigit = Number(phone.slice(4, 5));
|
|
78
|
-
var digits = phone.slice(4);
|
|
79
|
-
var allowed = [9, 8, 7, 6];
|
|
80
|
-
if (ddi === 55) {
|
|
81
|
-
return digits.length <= 9 ? allowed.includes(firstDigit) : ddd >= 30 ? allowed.includes(Number(phone.slice(5, 6))) : true;
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
14
|
+
*/function phoneValidator(phone){var ddi=+phone.slice(0,2),ddd=+phone.slice(2,4),firstDigit=+phone.slice(4,5),digits=phone.slice(4),allowed=[9,8,7,6];return 55!=ddi||(9>=digits.length?allowed.includes(firstDigit):!(30<=ddd)||allowed.includes(+phone.slice(5,6)))}/**
|
|
87
15
|
* Parses a Brazilian phone number to add the ninth digit if needed or removes it if specified.
|
|
88
16
|
* @param {string} phone - The phone number to be parsed.
|
|
89
17
|
* @param {boolean} [remove] - If true, removes the ninth digit from the phone number. Defaults to false.
|
|
90
18
|
* @returns {string} - Returns the parsed phone number.
|
|
91
|
-
*/
|
|
92
|
-
function phoneNineDigitParser(phone) {
|
|
93
|
-
var remove = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
94
|
-
if (phone) {
|
|
95
|
-
var replacedPhone = phone.replace(/[^0-9]/g, '');
|
|
96
|
-
var phoneWith9Number = replacedPhone.split('');
|
|
97
|
-
var phoneDdi = Number(phoneWith9Number.slice(0, 2).join(''));
|
|
98
|
-
var phoneDdd = Number(phoneWith9Number.slice(2, 4).join(''));
|
|
99
|
-
var phoneDigits = phoneWith9Number.slice(4).join('');
|
|
100
|
-
if (remove) {
|
|
101
|
-
return phoneDigits.length >= 9 && phoneDdi === 55 && phoneDdd > 30 ? phoneWith9Number.slice(0, 4).join('') + phoneWith9Number.slice(5).join('') : replacedPhone;
|
|
102
|
-
}
|
|
103
|
-
return phoneDigits.length === 8 && phoneDdi === 55 ? phoneWith9Number.slice(0, 4).join('') + '9' + phoneWith9Number.slice(4).join('') : replacedPhone;
|
|
104
|
-
}
|
|
105
|
-
return '';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
19
|
+
*/function phoneNineDigitParser(phone){var remove=!!(1<arguments.length&&arguments[1]!==void 0)&&arguments[1];if(phone){var replacedPhone=phone.replace(/[^0-9]/g,""),phoneWith9Number=replacedPhone.split(""),phoneDdi=+phoneWith9Number.slice(0,2).join(""),phoneDdd=+phoneWith9Number.slice(2,4).join(""),phoneDigits=phoneWith9Number.slice(4).join("");return remove?9<=phoneDigits.length&&55===phoneDdi&&30<phoneDdd?phoneWith9Number.slice(0,4).join("")+phoneWith9Number.slice(5).join(""):replacedPhone:8===phoneDigits.length&&55===phoneDdi?phoneWith9Number.slice(0,4).join("")+"9"+phoneWith9Number.slice(4).join(""):replacedPhone}return""}/**
|
|
109
20
|
* Verifies if a Brazilian phone number has the ninth digit added.
|
|
110
21
|
* @param {string} phone - The phone number to be verified.
|
|
111
22
|
* @param {object} [options] - The options to customize the error message. Default values: { errorMessage: 'Please include the digit "9" at the beginning of the number' }.
|
|
112
23
|
* @returns {boolean|string} - Returns true if first digit is nine, or an error message if the phone number is invalid.
|
|
113
|
-
*/
|
|
114
|
-
function verifyNineDigit(phone, _ref) {
|
|
115
|
-
var _ref$errorMessage = _ref.errorMessage,
|
|
116
|
-
errorMessage = _ref$errorMessage === void 0 ? 'Please include the digit "9" at the beginning of the number' : _ref$errorMessage;
|
|
117
|
-
if (phone.length < 10) {
|
|
118
|
-
return 'Please enter a valid phone number';
|
|
119
|
-
}
|
|
120
|
-
var phoneWithoutDDD = phone.substring(2);
|
|
121
|
-
var firstDigitIsNineNumber = phoneWithoutDDD[0] === '9';
|
|
122
|
-
return firstDigitIsNineNumber || errorMessage;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
24
|
+
*/function verifyNineDigit(phone,_ref){var _ref$errorMessage=_ref.errorMessage,errorMessage=void 0===_ref$errorMessage?"Please include the digit \"9\" at the beginning of the number":_ref$errorMessage;if(10>phone.length)return"Please enter a valid phone number";var phoneWithoutDDD=phone.substring(2),firstDigitIsNineNumber="9"===phoneWithoutDDD[0];return firstDigitIsNineNumber||errorMessage}/**
|
|
126
25
|
* Returns the DDI (international dialing code) of a phone number.
|
|
127
26
|
* @param {string} number - The phone number to get the DDI from.
|
|
128
27
|
* @returns {string|null} The DDI.
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// Removes everything except digits from the phone number.
|
|
133
|
-
var phone = number.replace(/\D/g, '');
|
|
134
|
-
// Gets the DDI using the phoneLib library.
|
|
135
|
-
var ddi = (0, _phone.default)('+' + phone);
|
|
136
|
-
return ddi.countryCode || undefined;
|
|
137
|
-
}
|
|
138
|
-
return undefined;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
28
|
+
*/function getDDI(number){if(number){// Removes everything except digits from the phone number.
|
|
29
|
+
var phone=number.replace(/\D/g,""),ddi=(0,_phone.default)("+"+phone);// Gets the DDI using the phoneLib library.
|
|
30
|
+
return ddi.countryCode||void 0}}/**
|
|
142
31
|
* Returns a formatted phone number based on provided options.
|
|
143
32
|
* @param {string} phone - The phone number to be formatted.
|
|
144
33
|
* @param {object} options - The options to customize the format. Default values: { ddi: undefined, withDDI: false, keepDDI: false }.
|
|
145
34
|
* @returns {string} The formatted phone number.
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
var result = '';
|
|
150
|
-
// If phone is provided.
|
|
151
|
-
if (phone) {
|
|
152
|
-
// If withDDI option is enabled, gets the DDI from the phone number.
|
|
153
|
-
if (options.withDDI) {
|
|
154
|
-
options.ddi = getDDI(phone.replaceAll('*', '0'));
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Removes everything except digits and asterisks from the phone number and removes leading zeroes.
|
|
158
|
-
result = phone.replace(/[^\d*]/g, '').replace(/^0*/, '');
|
|
159
|
-
|
|
160
|
-
// Formats the phone number based on the DDI.
|
|
161
|
-
if (options.ddi && options.ddi.replace('+', '') === '55' && !options.keepDDI) {
|
|
162
|
-
result = result.substring(2);
|
|
163
|
-
}
|
|
164
|
-
if (options.ddi && options.ddi.replace('+', '') === '55') {
|
|
165
|
-
result = result.replace(/^(\d{2}|\*{2})\B/, '($1) ').replace(/(\d{1}|\*{1})?(\d{4}|\*{4})(\d{4}|\*{4})/, '$1$2-$3');
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// If keepDDI option is enabled, returns the formatted phone number with the DDI.
|
|
170
|
-
return options.keepDDI ? "".concat(options.ddi, " ").concat(result) : result;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
35
|
+
*/function formatedPhone(phone){var options=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},result="";// If phone is provided.
|
|
36
|
+
// If keepDDI option is enabled, returns the formatted phone number with the DDI.
|
|
37
|
+
return phone&&(options.withDDI&&(options.ddi=getDDI(phone.replaceAll("*","0"))),result=phone.replace(/[^\d*]/g,"").replace(/^0*/,""),options.ddi&&"55"===options.ddi.replace("+","")&&!options.keepDDI&&(result=result.substring(2)),options.ddi&&"55"===options.ddi.replace("+","")&&(result=result.replace(/^(\d{2}|\*{2})\B/,"($1) ").replace(/(\d{1}|\*{1})?(\d{4}|\*{4})(\d{4}|\*{4})/,"$1$2-$3"))),options.keepDDI?"".concat(options.ddi," ").concat(result):result}/**
|
|
174
38
|
* Returns an object containing various formatted representations of a phone number.
|
|
175
39
|
* @param {string} phoneNumberWithDDI - The phone number to be formatted with +DDI.
|
|
176
40
|
* @returns {FormatPhoneProps} - An object containing different formats of the phone number or null if the number cannot be parsed.
|
|
177
|
-
*/
|
|
178
|
-
|
|
179
|
-
if (phoneNumberWithDDI !== null && phoneNumberWithDDI !== void 0 && phoneNumberWithDDI.includes('*')) return formatGuestPhone(phoneNumberWithDDI);
|
|
180
|
-
|
|
181
|
-
// Parses the phone number
|
|
182
|
-
var parsedNumber = (0, _max.parsePhoneNumberFromString)(phoneNumberWithDDI || '');
|
|
183
|
-
if (!parsedNumber) {
|
|
184
|
-
return {
|
|
185
|
-
formattedNumber: phoneNumberWithDDI,
|
|
186
|
-
formattedNumberWithDDI: phoneNumberWithDDI,
|
|
187
|
-
unformattedNumber: phoneNumberWithDDI,
|
|
188
|
-
unformattedNumberWithDDI: phoneNumberWithDDI
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
var hasDDI = parsedNumber.countryCallingCode !== undefined;
|
|
192
|
-
var isInternational = hasDDI && parsedNumber.countryCallingCode !== '55';
|
|
193
|
-
var formattedNumber = isInternational ? parsedNumber.formatInternational().replace("+".concat(parsedNumber.countryCallingCode, " "), '') : parsedNumber.formatNational();
|
|
194
|
-
return {
|
|
195
|
-
formattedNumber: formattedNumber,
|
|
196
|
-
ddi: hasDDI ? "+".concat(parsedNumber.countryCallingCode) : undefined,
|
|
197
|
-
formattedNumberWithDDI: hasDDI ? "+".concat(parsedNumber.countryCallingCode, " ").concat(formattedNumber) : formattedNumber,
|
|
198
|
-
unformattedNumber: parsedNumber.nationalNumber,
|
|
199
|
-
unformattedNumberWithDDI: hasDDI ? "+".concat(parsedNumber.countryCallingCode).concat(parsedNumber.nationalNumber) : parsedNumber.nationalNumber
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
41
|
+
*/function formatPhone(phoneNumberWithDDI){if(null!==phoneNumberWithDDI&&void 0!==phoneNumberWithDDI&&phoneNumberWithDDI.includes("*"))return formatGuestPhone(phoneNumberWithDDI);// Parses the phone number
|
|
42
|
+
var parsedNumber=(0,_max.parsePhoneNumberFromString)(phoneNumberWithDDI||"");if(!parsedNumber)return{formattedNumber:phoneNumberWithDDI,formattedNumberWithDDI:phoneNumberWithDDI,unformattedNumber:phoneNumberWithDDI,unformattedNumberWithDDI:phoneNumberWithDDI};var hasDDI=parsedNumber.countryCallingCode!==void 0,isInternational=hasDDI&&"55"!==parsedNumber.countryCallingCode,formattedNumber=isInternational?parsedNumber.formatInternational().replace("+".concat(parsedNumber.countryCallingCode," "),""):parsedNumber.formatNational();return{formattedNumber:formattedNumber,ddi:hasDDI?"+".concat(parsedNumber.countryCallingCode):void 0,formattedNumberWithDDI:hasDDI?"+".concat(parsedNumber.countryCallingCode," ").concat(formattedNumber):formattedNumber,unformattedNumber:parsedNumber.nationalNumber,unformattedNumberWithDDI:hasDDI?"+".concat(parsedNumber.countryCallingCode).concat(parsedNumber.nationalNumber):parsedNumber.nationalNumber}}/**
|
|
204
43
|
* Formats a guest phone number by masking digits except the last four digits for each format.
|
|
205
44
|
* @param phoneNumberWithDDI - The phone number to be formatted with +DDI.
|
|
206
45
|
* @returns The formatted phone number object, or null if the formatting is not possible.
|
|
207
|
-
*/
|
|
208
|
-
function formatGuestPhone(phoneNumberWithDDI) {
|
|
209
|
-
var phone = phoneNumberWithDDI === null || phoneNumberWithDDI === void 0 ? void 0 : phoneNumberWithDDI.replace(/\*/g, '9');
|
|
210
|
-
var phoneFormatter = formatPhone(phone);
|
|
211
|
-
if (!phoneFormatter) {
|
|
212
|
-
return {
|
|
213
|
-
formattedNumber: phone,
|
|
214
|
-
formattedNumberWithDDI: phone,
|
|
215
|
-
unformattedNumber: phone,
|
|
216
|
-
unformattedNumberWithDDI: phone
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
return Object.keys(phoneFormatter).reduce(function (acc, key) {
|
|
220
|
-
var currentKey = key;
|
|
221
|
-
if (currentKey === 'ddi') {
|
|
222
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, currentKey, phoneFormatter[currentKey]));
|
|
223
|
-
}
|
|
224
|
-
var hasDdi = phoneFormatter[currentKey].startsWith((phoneFormatter === null || phoneFormatter === void 0 ? void 0 : phoneFormatter.ddi) || '');
|
|
225
|
-
var lastFourDigits = phoneFormatter[currentKey].slice(-4);
|
|
226
|
-
if (hasDdi) {
|
|
227
|
-
var _phoneFormatter$ddi;
|
|
228
|
-
var numberPart = phoneFormatter[currentKey].slice(phoneFormatter === null || phoneFormatter === void 0 ? void 0 : (_phoneFormatter$ddi = phoneFormatter.ddi) === null || _phoneFormatter$ddi === void 0 ? void 0 : _phoneFormatter$ddi.length, -4);
|
|
229
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, currentKey, (phoneFormatter === null || phoneFormatter === void 0 ? void 0 : phoneFormatter.ddi) + numberPart.replace(/\d/g, '*') + lastFourDigits));
|
|
230
|
-
}
|
|
231
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, currentKey, phoneFormatter[currentKey].replace(/\d/g, '*').slice(0, -4) + lastFourDigits));
|
|
232
|
-
}, {});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
46
|
+
*/function formatGuestPhone(phoneNumberWithDDI){var phone=null===phoneNumberWithDDI||void 0===phoneNumberWithDDI?void 0:phoneNumberWithDDI.replace(/\*/g,"9"),phoneFormatter=formatPhone(phone);return phoneFormatter?Object.keys(phoneFormatter).reduce(function(acc,key){var currentKey=key;if("ddi"===currentKey)return _objectSpread(_objectSpread({},acc),{},_defineProperty({},currentKey,phoneFormatter[currentKey]));var hasDdi=phoneFormatter[currentKey].startsWith((null===phoneFormatter||void 0===phoneFormatter?void 0:phoneFormatter.ddi)||""),lastFourDigits=phoneFormatter[currentKey].slice(-4);if(hasDdi){var _phoneFormatter$ddi,numberPart=phoneFormatter[currentKey].slice(null===phoneFormatter||void 0===phoneFormatter||null===(_phoneFormatter$ddi=phoneFormatter.ddi)||void 0===_phoneFormatter$ddi?void 0:_phoneFormatter$ddi.length,-4);return _objectSpread(_objectSpread({},acc),{},_defineProperty({},currentKey,(null===phoneFormatter||void 0===phoneFormatter?void 0:phoneFormatter.ddi)+numberPart.replace(/\d/g,"*")+lastFourDigits))}return _objectSpread(_objectSpread({},acc),{},_defineProperty({},currentKey,phoneFormatter[currentKey].replace(/\d/g,"*").slice(0,-4)+lastFourDigits))},{}):{formattedNumber:phone,formattedNumberWithDDI:phone,unformattedNumber:phone,unformattedNumberWithDDI:phone}}/**
|
|
236
47
|
* Validates if a phone number is valid.
|
|
237
48
|
* @param {string | undefined} phoneNumber - The phone number to be validated.
|
|
238
49
|
* @returns {boolean} - A boolean indicating whether the phone number is valid or not.
|
|
239
|
-
*/
|
|
240
|
-
|
|
241
|
-
if (!phoneNumber) return false;
|
|
242
|
-
// Parses the phone number
|
|
243
|
-
var parsedNumber = (0, _max.parsePhoneNumberFromString)(phoneNumber);
|
|
244
|
-
if (!parsedNumber) {
|
|
245
|
-
return false;
|
|
246
|
-
}
|
|
247
|
-
return parsedNumber.isValid();
|
|
248
|
-
}
|
|
50
|
+
*/function validatePhone(phoneNumber){if(!phoneNumber)return!1;// Parses the phone number
|
|
51
|
+
var parsedNumber=(0,_max.parsePhoneNumberFromString)(phoneNumber);return!!parsedNumber&&parsedNumber.isValid()}
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formatPrice = formatPrice;
|
|
7
|
-
exports.localeCents = localeCents;
|
|
8
|
-
/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatPrice=formatPrice,exports.localeCents=localeCents;/**
|
|
9
2
|
* Formats a number or string into Brazilian Real currency format.
|
|
10
3
|
* @param {number | string} value - The value to format.
|
|
11
4
|
* @returns {string} The formatted value in BRL currency format.
|
|
12
|
-
*/
|
|
13
|
-
function formatPrice(value) {
|
|
14
|
-
return value.toLocaleString('pt-BR', {
|
|
15
|
-
style: 'currency',
|
|
16
|
-
currency: 'BRL'
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
5
|
+
*/function formatPrice(value){return value.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}/**
|
|
21
6
|
* Converts a number of cents to a string representation of a price with the Brazilian Real currency symbol and format.
|
|
22
7
|
* @param {number} cents - The amount of cents to format.
|
|
23
|
-
*/
|
|
24
|
-
function localeCents(cents) {
|
|
25
|
-
return formatPrice(cents / 100);
|
|
26
|
-
}
|
|
8
|
+
*/function localeCents(cents){return formatPrice(cents/100)}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.formatRG = formatRG;
|
|
7
|
-
exports.sanitizeRG = sanitizeRG;
|
|
8
|
-
/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatRG=formatRG,exports.sanitizeRG=sanitizeRG;/**
|
|
9
2
|
* Formats the given RG string by removing any character that is not a number, comma, dot or space.
|
|
10
3
|
* @param {string} rg - The RG string to be formatted.
|
|
11
4
|
* @returns {string} - The formatted RG string.
|
|
12
|
-
*/
|
|
13
|
-
function formatRG(rg) {
|
|
14
|
-
return rg.replace(/[^\dA-z.-]/g, '');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
5
|
+
*/function formatRG(rg){return rg.replace(/[^\dA-z.-]/g,"")}/**
|
|
18
6
|
* Sanitizes the given RG string by removing dots and dashes and converting all characters to uppercase.
|
|
19
7
|
* @param {string} rg - The RG string to be sanitized.
|
|
20
8
|
* @returns {string} - The sanitized RG string.
|
|
21
|
-
*/
|
|
22
|
-
function sanitizeRG(rg) {
|
|
23
|
-
return rg.replaceAll('.', '').replaceAll('-', '').toUpperCase();
|
|
24
|
-
}
|
|
9
|
+
*/function sanitizeRG(rg){return rg.replaceAll(".","").replaceAll("-","").toUpperCase()}
|
|
@@ -1,37 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.removeLineBreaks = removeLineBreaks;
|
|
7
|
-
exports.replaceUnecessarySpaces = replaceUnecessarySpaces;
|
|
8
|
-
exports.truncateString = truncateString;
|
|
9
|
-
/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.removeLineBreaks=removeLineBreaks,exports.replaceUnecessarySpaces=replaceUnecessarySpaces,exports.truncateString=truncateString;/**
|
|
10
2
|
* Truncates a string to a given character limit and adds ellipses at the end if necessary.
|
|
11
3
|
* @param {string} data - The string to truncate.
|
|
12
4
|
* @param {number} limit - The maximum number of characters the string can have.
|
|
13
5
|
* @returns {string} The truncated string.
|
|
14
|
-
*/
|
|
15
|
-
function truncateString(data, limit) {
|
|
16
|
-
if (data.length > limit) {
|
|
17
|
-
return data.substring(0, limit) + '...';
|
|
18
|
-
} else {
|
|
19
|
-
return data;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
6
|
+
*/function truncateString(data,limit){return data.length>limit?data.substring(0,limit)+"...":data}/**
|
|
23
7
|
* Removes line breaks from a given string.
|
|
24
8
|
* @param {string} lineBreaks - The string to remove line breaks from.
|
|
25
9
|
* @returns {string} The string without line breaks.
|
|
26
|
-
*/
|
|
27
|
-
function removeLineBreaks(lineBreaks) {
|
|
28
|
-
return lineBreaks.replace(/\r?\n|\r|\n/g, ' ');
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
10
|
+
*/function removeLineBreaks(lineBreaks){return lineBreaks.replace(/\r?\n|\r|\n/g," ")}/**
|
|
31
11
|
* Replaces multiple consecutive spaces in a string with a single space and trims the string.
|
|
32
12
|
* @param {string} string - The string to replace unnecessary spaces in.
|
|
33
13
|
* @returns {string} The string without unnecessary spaces.
|
|
34
|
-
*/
|
|
35
|
-
function replaceUnecessarySpaces(string) {
|
|
36
|
-
return string.replace(/ +/g, ' ').trim();
|
|
37
|
-
}
|
|
14
|
+
*/function replaceUnecessarySpaces(string){return string.replace(/ +/g," ").trim()}
|
|
@@ -1,39 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.focusFunction = focusFunction;
|
|
7
|
-
exports.hoverFunction = hoverFunction;
|
|
8
|
-
function hoverFunction(col) {
|
|
9
|
-
var amt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -20;
|
|
10
|
-
var usePound = false;
|
|
11
|
-
if (col[0] === '#') {
|
|
12
|
-
col = col.slice(1);
|
|
13
|
-
usePound = true;
|
|
14
|
-
}
|
|
15
|
-
var num = parseInt(col, 16);
|
|
16
|
-
var r = (num >> 16) + amt;
|
|
17
|
-
if (r > 255) r = 255;else if (r < 0) r = 0;
|
|
18
|
-
var b = (num >> 8 & 0x00ff) + amt;
|
|
19
|
-
if (b > 255) b = 255;else if (b < 0) b = 0;
|
|
20
|
-
var g = (num & 0x0000ff) + amt;
|
|
21
|
-
if (g > 255) g = 255;else if (g < 0) g = 0;
|
|
22
|
-
return (usePound ? '#' : '') + (g | b << 8 | r << 16).toString(16);
|
|
23
|
-
}
|
|
24
|
-
function focusFunction(col) {
|
|
25
|
-
var amt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -35;
|
|
26
|
-
var usePound = false;
|
|
27
|
-
if (col[0] === '#') {
|
|
28
|
-
col = col.slice(1);
|
|
29
|
-
usePound = true;
|
|
30
|
-
}
|
|
31
|
-
var num = parseInt(col, 16);
|
|
32
|
-
var r = (num >> 16) + amt;
|
|
33
|
-
if (r > 255) r = 255;else if (r < 0) r = 0;
|
|
34
|
-
var b = (num >> 8 & 0x00ff) + amt;
|
|
35
|
-
if (b > 255) b = 255;else if (b < 0) b = 0;
|
|
36
|
-
var g = (num & 0x0000ff) + amt;
|
|
37
|
-
if (g > 255) g = 255;else if (g < 0) g = 0;
|
|
38
|
-
return (usePound ? '#' : '') + (g | b << 8 | r << 16).toString(16);
|
|
39
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.focusFunction=focusFunction,exports.hoverFunction=hoverFunction;function hoverFunction(col){var amt=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-20,usePound=!1;"#"===col[0]&&(col=col.slice(1),usePound=!0);var num=parseInt(col,16),r=(num>>16)+amt;255<r?r=255:0>r&&(r=0);var b=(255&num>>8)+amt;255<b?b=255:0>b&&(b=0);var g=(255&num)+amt;return 255<g?g=255:0>g&&(g=0),(usePound?"#":"")+(g|b<<8|r<<16).toString(16)}function focusFunction(col){var amt=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-35,usePound=!1;"#"===col[0]&&(col=col.slice(1),usePound=!0);var num=parseInt(col,16),r=(num>>16)+amt;255<r?r=255:0>r&&(r=0);var b=(255&num>>8)+amt;255<b?b=255:0>b&&(b=0);var g=(255&num)+amt;return 255<g?g=255:0>g&&(g=0),(usePound?"#":"")+(g|b<<8|r<<16).toString(16)}
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateUUID = generateUUID;
|
|
7
|
-
function generateUUID() {
|
|
8
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
9
|
-
var r = Math.random() * 16 | 0;
|
|
10
|
-
var v = c === 'x' ? r : r & 0x3 | 0x8;
|
|
11
|
-
return v.toString(16);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateUUID=generateUUID;function generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(c){var r=0|16*Math.random(),v="x"===c?r:8|3&r;return v.toString(16)})}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getThemeHex = exports.getColorValue = void 0;
|
|
7
|
-
var _colorCheck = require("../utils/colorCheck");
|
|
8
|
-
/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getThemeHex=exports.getColorValue=void 0;var _colorCheck=require("../utils/colorCheck"),getColorValue=function(color,theme,defaultValue){if((0,_colorCheck.isHexColor)(color)||(0,_colorCheck.isRgbHslColor)(color))return color;var colorIsThemeColor=theme&&(0,_colorCheck.stripThemeColors)(color,theme.colors);return colorIsThemeColor||color||defaultValue||"inherit"};/**
|
|
9
2
|
* This function takes a color string and returns the color value related to the theme or the original color string
|
|
10
3
|
* @param color : color value;
|
|
11
4
|
* @param theme : theme object;
|
|
@@ -13,18 +6,4 @@ var _colorCheck = require("../utils/colorCheck");
|
|
|
13
6
|
* @returns color value;
|
|
14
7
|
* @example
|
|
15
8
|
* getColorValue('primary.default', props.theme); // returns '#22E0A1'
|
|
16
|
-
*/
|
|
17
|
-
var getColorValue = function getColorValue(color, theme, defaultValue) {
|
|
18
|
-
if ((0, _colorCheck.isHexColor)(color) || (0, _colorCheck.isRgbHslColor)(color)) return color;
|
|
19
|
-
var colorIsThemeColor = theme && (0, _colorCheck.stripThemeColors)(color, theme.colors);
|
|
20
|
-
return colorIsThemeColor || color || defaultValue || 'inherit';
|
|
21
|
-
};
|
|
22
|
-
exports.getColorValue = getColorValue;
|
|
23
|
-
var getThemeHex = function getThemeHex(path, obj) {
|
|
24
|
-
var separator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
25
|
-
var properties = path.split(separator);
|
|
26
|
-
return properties.reduce(function (prev, curr) {
|
|
27
|
-
return prev && prev[curr];
|
|
28
|
-
}, obj);
|
|
29
|
-
};
|
|
30
|
-
exports.getThemeHex = getThemeHex;
|
|
9
|
+
*/exports.getColorValue=getColorValue;var getThemeHex=function(path,obj){var separator=2<arguments.length&&arguments[2]!==void 0?arguments[2]:".",properties=path.split(separator);return properties.reduce(function(prev,curr){return prev&&prev[curr]},obj)};exports.getThemeHex=getThemeHex;
|
package/dist/utils/getSvg.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getSvg = void 0;
|
|
7
|
-
var getSvg = function getSvg(name, allIcons) {
|
|
8
|
-
var filterIcon = allIcons.find(function (icon) {
|
|
9
|
-
return icon.name === name;
|
|
10
|
-
});
|
|
11
|
-
if (!filterIcon) {
|
|
12
|
-
return allIcons[0];
|
|
13
|
-
} else {
|
|
14
|
-
return filterIcon;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
exports.getSvg = getSvg;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSvg=void 0;var getSvg=function(name,allIcons){var filterIcon=allIcons.find(function(icon){return icon.name===name});return filterIcon?filterIcon:allIcons[0]};exports.getSvg=getSvg;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getValuesBySize = getValuesBySize;
|
|
7
|
-
function getValuesBySize(sizes, conditional) {
|
|
8
|
-
return sizes[conditional] || 16;
|
|
9
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getValuesBySize=getValuesBySize;function getValuesBySize(sizes,conditional){return sizes[conditional]||16}
|
|
@@ -1,44 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.invertColor = void 0;
|
|
7
|
-
var padZero = function padZero(str) {
|
|
8
|
-
var len = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
9
|
-
len = len || 2;
|
|
10
|
-
var zeros = new Array(len).join('0');
|
|
11
|
-
return (zeros + str).slice(-len);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.invertColor=void 0;var padZero=function(str){var len=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0;len=len||2;var zeros=Array(len).join("0");return(zeros+str).slice(-len)},invertColor=function(hex,bw){if(0===hex.indexOf("#")&&(hex=hex.slice(1)),3===hex.length&&(hex=hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]),6!==hex.length)throw new Error("Invalid HEX color.");var r=parseInt(hex.slice(0,2),16),g=parseInt(hex.slice(2,4),16),b=parseInt(hex.slice(4,6),16);return bw?186<.299*r+.587*g+.114*b?"#000000":"#FFFFFF":(r=(255-r).toString(16),g=(255-g).toString(16),b=(255-b).toString(16),"#"+padZero(r)+padZero(g)+padZero(b));// invert color components
|
|
2
|
+
// pad each with zeros and return
|
|
3
|
+
};/**
|
|
15
4
|
* Invert the provided color or return black or white if the color is darken or lighten
|
|
16
5
|
* @param hex : hex color
|
|
17
6
|
* @param bw : black or white
|
|
18
7
|
* @returns : hex color
|
|
19
|
-
*/
|
|
20
|
-
var invertColor = function invertColor(hex, bw) {
|
|
21
|
-
if (hex.indexOf('#') === 0) {
|
|
22
|
-
hex = hex.slice(1);
|
|
23
|
-
}
|
|
24
|
-
// convert 3-digit hex to 6-digits.
|
|
25
|
-
if (hex.length === 3) {
|
|
26
|
-
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
27
|
-
}
|
|
28
|
-
if (hex.length !== 6) {
|
|
29
|
-
throw new Error('Invalid HEX color.');
|
|
30
|
-
}
|
|
31
|
-
var r = parseInt(hex.slice(0, 2), 16);
|
|
32
|
-
var g = parseInt(hex.slice(2, 4), 16);
|
|
33
|
-
var b = parseInt(hex.slice(4, 6), 16);
|
|
34
|
-
if (bw) {
|
|
35
|
-
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#FFFFFF';
|
|
36
|
-
}
|
|
37
|
-
// invert color components
|
|
38
|
-
r = (255 - r).toString(16);
|
|
39
|
-
g = (255 - g).toString(16);
|
|
40
|
-
b = (255 - b).toString(16);
|
|
41
|
-
// pad each with zeros and return
|
|
42
|
-
return '#' + padZero(r) + padZero(g) + padZero(b);
|
|
43
|
-
};
|
|
44
|
-
exports.invertColor = invertColor;
|
|
8
|
+
*/exports.invertColor=invertColor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pedidopago/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Quick build beatiful Pedido Pago apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"@types/react-dom": "^18.0.4",
|
|
102
102
|
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
103
103
|
"@typescript-eslint/parser": "^5.3.0",
|
|
104
|
+
"babel-preset-minify": "^0.5.2",
|
|
104
105
|
"chromatic": "^5.9.2",
|
|
105
106
|
"eslint": "^7.32.0",
|
|
106
107
|
"eslint-config-prettier": "^8.3.0",
|