@true-engineering/true-react-common-ui-kit 3.45.4 → 3.45.6

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/README.md CHANGED
@@ -11,6 +11,18 @@
11
11
 
12
12
  # Release Notes
13
13
 
14
+ ## 3.45.6
15
+
16
+ - **phone.ts** Изменён алгоритм определения кода страны по номеру телефона
17
+ - **phone-info.ts** Добавлены dialCode для Южной Осетии
18
+ - **phone-info.ts** Актуализированы dialCode для Казахстана
19
+
20
+ ## 3.45.5
21
+
22
+ ### Changes
23
+
24
+ - **Tooltip**: Добавлен вариант `custom` для `view`
25
+
14
26
  ## 3.45.4
15
27
 
16
28
  ### Changes
@@ -19,6 +31,8 @@
19
31
 
20
32
  ## 3.45.3
21
33
 
34
+ ### Changes
35
+
22
36
  - **Flag**: Добавлены флаги для Абхазии и Южной Осетии
23
37
  - **PhoneInput**: Добавлены PhoneInfo для Абхазии и Южной осетии.
24
38
  - **PhoneInput**: Исправлен баг с невозможностью выбора стран с одинаковыми dialCode
@@ -4,7 +4,7 @@ import { ITooltipStyles } from './Tooltip.styles';
4
4
  export interface ITooltipProps extends ICommonProps<ITooltipStyles> {
5
5
  text: ReactNode;
6
6
  /** @default 'tooltip' */
7
- view?: 'tooltip' | 'hint';
7
+ view?: 'tooltip' | 'hint' | 'custom';
8
8
  /** @default 'info' */
9
9
  type?: 'info' | 'error';
10
10
  }
@@ -1,3 +1,3 @@
1
1
  import { ITweakStyles } from '../../theme';
2
- export declare const useStyles: import("../../theme").IUseStyles<"error" | "root" | "tooltip" | "info" | "hint", unknown>;
2
+ export declare const useStyles: import("../../theme").IUseStyles<"error" | "root" | "tooltip" | "custom" | "info" | "hint", unknown>;
3
3
  export type ITooltipStyles = ITweakStyles<typeof useStyles>;
@@ -1,6 +1,6 @@
1
1
  import React, { createContext, useRef, useEffect, useCallback, useState, useMemo, useContext, createElement, Fragment as Fragment$1, forwardRef, createRef, PureComponent, memo } from "react";
2
2
  import { createUseStyles } from "react-jss";
3
- import { mergeStyles, isNotEmpty, isArrayNotEmpty, isEmpty, isString, isStringNotEmpty, mergeRefs, addDataTestId, applyAction, addDataAttributes as addDataAttributes$1, stopPropagation, isReactNodeNotEmpty, addClickHandler, getTestId, getSelectKeyHandler, getArray, createFilter, isFunction as isFunction$1, isObject as isObject$1, getTransition, indexMap, isNumberInteger, hasDuplicates, isArrayEmpty } from "@true-engineering/true-react-platform-helpers";
3
+ import { mergeStyles, isNotEmpty, isArrayNotEmpty, isStringEmpty, isString, isStringNotEmpty, isEmpty, mergeRefs, addDataTestId, applyAction, addDataAttributes as addDataAttributes$1, stopPropagation, isReactNodeNotEmpty, addClickHandler, getTestId, getSelectKeyHandler, getArray, createFilter, isFunction as isFunction$1, isObject as isObject$1, getTransition, indexMap, isNumberInteger, hasDuplicates, isArrayEmpty } from "@true-engineering/true-react-platform-helpers";
4
4
  import { CSSTransition } from "react-transition-group";
5
5
  import clsx from "clsx";
6
6
  import hexToRgba from "hex-to-rgba";
@@ -2001,15 +2001,11 @@ var phoneInfo = [
2001
2001
  countryEn: "Abkhazia",
2002
2002
  countryRu: "Абхазия",
2003
2003
  countryCode: "AB",
2004
- phoneMask: "999 999-99-99",
2004
+ phoneMask: "(999) 999-99-99",
2005
2005
  dialCode: "7",
2006
- areaCodes: [
2007
- "840",
2008
- "940"
2009
- ],
2006
+ dialCodePriority: 1,
2010
2007
  fullCodes: [
2011
- "7840",
2012
- "7940"
2008
+ "7"
2013
2009
  ]
2014
2010
  },
2015
2011
  {
@@ -3008,39 +3004,10 @@ var phoneInfo = [
3008
3004
  countryRu: "Казахстан",
3009
3005
  countryCode: "KZ",
3010
3006
  dialCode: "7",
3011
- phoneMask: "999 999-99-99",
3007
+ phoneMask: "(999) 999-99-99",
3012
3008
  dialCodePriority: 1,
3013
- areaCodes: [
3014
- "310",
3015
- "311",
3016
- "312",
3017
- "313",
3018
- "315",
3019
- "318",
3020
- "321",
3021
- "324",
3022
- "325",
3023
- "326",
3024
- "327",
3025
- "336",
3026
- "7172",
3027
- "73622"
3028
- ],
3029
3009
  fullCodes: [
3030
- "7310",
3031
- "7311",
3032
- "7312",
3033
- "7313",
3034
- "7315",
3035
- "7318",
3036
- "7321",
3037
- "7324",
3038
- "7325",
3039
- "7326",
3040
- "7327",
3041
- "7336",
3042
- "77172",
3043
- "773622"
3010
+ "7"
3044
3011
  ]
3045
3012
  },
3046
3013
  {
@@ -3813,8 +3780,9 @@ var phoneInfo = [
3813
3780
  countryCode: "OS",
3814
3781
  countryEn: "South Ossetia",
3815
3782
  countryRu: "Южная Осетия",
3816
- phoneMask: "999 999-99-99",
3783
+ phoneMask: "(999) 999-99-99",
3817
3784
  dialCode: "7",
3785
+ dialCodePriority: 1,
3818
3786
  fullCodes: [
3819
3787
  "7"
3820
3788
  ]
@@ -4776,22 +4744,25 @@ var getFullPhone = function(phone) {
4776
4744
  return ((_phone_dialCode = phone === null || phone === void 0 ? void 0 : phone.dialCode) !== null && _phone_dialCode !== void 0 ? _phone_dialCode : "") + ((_phone_phoneNumber = phone === null || phone === void 0 ? void 0 : phone.phoneNumber) !== null && _phone_phoneNumber !== void 0 ? _phone_phoneNumber : "");
4777
4745
  };
4778
4746
  var getCountryCodeFromPhone = function(phoneWithCode) {
4779
- var _phoneInfo_find;
4780
- var countryCode = (_phoneInfo_find = phoneInfo.find(function(info) {
4781
- return info.fullCodes.some(function(code) {
4782
- return phoneWithCode.startsWith(code);
4783
- });
4784
- })) === null || _phoneInfo_find === void 0 ? void 0 : _phoneInfo_find.countryCode;
4785
- if (isEmpty(countryCode) && isNotEmpty(phoneWithCode)) {
4786
- var _phoneInfo_filter_sort_;
4787
- countryCode = (_phoneInfo_filter_sort_ = phoneInfo.filter(function(info) {
4788
- return phoneWithCode.startsWith(info.dialCode);
4789
- }).sort(function(infoA, infoB) {
4790
- var _infoA_dialCodePriority, _infoB_dialCodePriority;
4791
- return ((_infoA_dialCodePriority = infoA.dialCodePriority) !== null && _infoA_dialCodePriority !== void 0 ? _infoA_dialCodePriority : 1e3) - ((_infoB_dialCodePriority = infoB.dialCodePriority) !== null && _infoB_dialCodePriority !== void 0 ? _infoB_dialCodePriority : 1e3);
4792
- })[0]) === null || _phoneInfo_filter_sort_ === void 0 ? void 0 : _phoneInfo_filter_sort_.countryCode;
4793
- }
4794
- return countryCode;
4747
+ var _highestPriorityCountries_at;
4748
+ if (isStringEmpty(phoneWithCode)) {
4749
+ return;
4750
+ }
4751
+ var matchedCountries = phoneInfo.filter(function(info) {
4752
+ return info.fullCodes.some(function(fullCode) {
4753
+ return phoneWithCode.startsWith(fullCode);
4754
+ });
4755
+ });
4756
+ if (matchedCountries.length === 1) {
4757
+ return matchedCountries[0].countryCode;
4758
+ }
4759
+ var highestPriorityCountries = phoneInfo.filter(function(info) {
4760
+ return phoneWithCode.startsWith(info.dialCode);
4761
+ }).sort(function(a, b) {
4762
+ var _a_dialCodePriority, _b_dialCodePriority;
4763
+ return ((_a_dialCodePriority = a.dialCodePriority) !== null && _a_dialCodePriority !== void 0 ? _a_dialCodePriority : 1e3) - ((_b_dialCodePriority = b.dialCodePriority) !== null && _b_dialCodePriority !== void 0 ? _b_dialCodePriority : 1e3);
4764
+ });
4765
+ return (_highestPriorityCountries_at = highestPriorityCountries.at(0)) === null || _highestPriorityCountries_at === void 0 ? void 0 : _highestPriorityCountries_at.countryCode;
4795
4766
  };
4796
4767
  var getPhoneObjFromString = function(fullPhone, countryCode) {
4797
4768
  var _findCountryByCode;
@@ -13453,6 +13424,7 @@ var useStyles$x = createThemedStyles("Tooltip", {
13453
13424
  color: colors.CLASSIC_WHITE,
13454
13425
  letterSpacing: 0.2
13455
13426
  },
13427
+ custom: {},
13456
13428
  info: {},
13457
13429
  error: {
13458
13430
  "&$tooltip": {
@@ -28806,7 +28778,7 @@ var PhoneInput = function(_param) {
28806
28778
  var handleSelect = function(newPhoneInfo, event) {
28807
28779
  if (newPhoneInfo.countryCode !== countryCode) {
28808
28780
  onChange({
28809
- phoneNumber: "",
28781
+ phoneNumber: newPhoneInfo.dialCode !== value.dialCode ? "" : getPhoneObjFromString(phoneWithCode).phoneNumber,
28810
28782
  dialCode: newPhoneInfo.dialCode,
28811
28783
  countryCode: newPhoneInfo.countryCode
28812
28784
  }, event);