@true-engineering/true-react-common-ui-kit 4.0.0-alpha5 → 4.0.0-alpha6

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.
Files changed (40) hide show
  1. package/README.md +53 -0
  2. package/dist/components/FiltersPane/types.d.ts +15 -5
  3. package/dist/components/Flag/customFlags/customFlags.d.ts +10 -0
  4. package/dist/components/Flag/customFlags/index.d.ts +1 -0
  5. package/dist/components/FlexibleTable/FlexibleTable.d.ts +1 -1
  6. package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +5 -4
  7. package/dist/components/FlexibleTable/constants.d.ts +18 -2
  8. package/dist/components/FlexibleTable/types.d.ts +1 -1
  9. package/dist/components/SearchInput/SearchInput.d.ts +2 -2
  10. package/dist/components/SearchInput/SearchInput.stories.d.ts +3 -2
  11. package/dist/components/Select/Select.d.ts +5 -3
  12. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  13. package/dist/components/Tooltip/Tooltip.styles.d.ts +1 -1
  14. package/dist/true-react-common-ui-kit.js +112 -78
  15. package/dist/true-react-common-ui-kit.js.map +1 -1
  16. package/dist/true-react-common-ui-kit.umd.cjs +111 -77
  17. package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
  18. package/package.json +1 -1
  19. package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +19 -17
  20. package/src/components/FiltersPane/types.ts +23 -5
  21. package/src/components/Flag/Flag.stories.tsx +2 -1
  22. package/src/components/Flag/Flag.styles.ts +4 -0
  23. package/src/components/Flag/Flag.tsx +23 -9
  24. package/src/components/Flag/customFlags/AB.svg +1 -0
  25. package/src/components/Flag/customFlags/OS.svg +1 -0
  26. package/src/components/Flag/customFlags/augment.d.ts +1 -0
  27. package/src/components/Flag/customFlags/customFlags.ts +13 -0
  28. package/src/components/Flag/customFlags/index.ts +1 -0
  29. package/src/components/FlexibleTable/FlexibleTable.tsx +1 -0
  30. package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +6 -3
  31. package/src/components/FlexibleTable/constants.ts +6 -3
  32. package/src/components/FlexibleTable/types.ts +1 -5
  33. package/src/components/PhoneInput/PhoneInput.stories.tsx +2 -1
  34. package/src/components/PhoneInput/PhoneInput.tsx +5 -2
  35. package/src/components/SearchInput/SearchInput.tsx +23 -28
  36. package/src/components/Select/Select.tsx +11 -2
  37. package/src/components/Tooltip/Tooltip.styles.ts +2 -0
  38. package/src/components/Tooltip/Tooltip.tsx +1 -1
  39. package/src/constants/phone-info.ts +20 -33
  40. package/src/helpers/phone.ts +19 -15
@@ -1995,6 +1995,17 @@
1995
1995
  }
1996
1996
  };
1997
1997
  var phoneInfo = [
1998
+ {
1999
+ countryEn: "Abkhazia",
2000
+ countryRu: "Абхазия",
2001
+ countryCode: "AB",
2002
+ phoneMask: "(999) 999-99-99",
2003
+ dialCode: "7",
2004
+ dialCodePriority: 1,
2005
+ fullCodes: [
2006
+ "7"
2007
+ ]
2008
+ },
1998
2009
  {
1999
2010
  countryEn: "Afghanistan",
2000
2011
  countryRu: "Афганистан",
@@ -2991,39 +3002,10 @@
2991
3002
  countryRu: "Казахстан",
2992
3003
  countryCode: "KZ",
2993
3004
  dialCode: "7",
2994
- phoneMask: "999 999-99-99",
3005
+ phoneMask: "(999) 999-99-99",
2995
3006
  dialCodePriority: 1,
2996
- areaCodes: [
2997
- "310",
2998
- "311",
2999
- "312",
3000
- "313",
3001
- "315",
3002
- "318",
3003
- "321",
3004
- "324",
3005
- "325",
3006
- "326",
3007
- "327",
3008
- "336",
3009
- "7172",
3010
- "73622"
3011
- ],
3012
3007
  fullCodes: [
3013
- "7310",
3014
- "7311",
3015
- "7312",
3016
- "7313",
3017
- "7315",
3018
- "7318",
3019
- "7321",
3020
- "7324",
3021
- "7325",
3022
- "7326",
3023
- "7327",
3024
- "7336",
3025
- "77172",
3026
- "773622"
3008
+ "7"
3027
3009
  ]
3028
3010
  },
3029
3011
  {
@@ -3792,6 +3774,17 @@
3792
3774
  "82"
3793
3775
  ]
3794
3776
  },
3777
+ {
3778
+ countryCode: "OS",
3779
+ countryEn: "South Ossetia",
3780
+ countryRu: "Южная Осетия",
3781
+ phoneMask: "(999) 999-99-99",
3782
+ dialCode: "7",
3783
+ dialCodePriority: 1,
3784
+ fullCodes: [
3785
+ "7"
3786
+ ]
3787
+ },
3795
3788
  {
3796
3789
  countryEn: "South Sudan",
3797
3790
  countryRu: "Южный Судан",
@@ -4749,22 +4742,25 @@
4749
4742
  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 : "");
4750
4743
  };
4751
4744
  var getCountryCodeFromPhone = function(phoneWithCode) {
4752
- var _phoneInfo_find;
4753
- var countryCode = (_phoneInfo_find = phoneInfo.find(function(info) {
4754
- return info.fullCodes.some(function(code) {
4755
- return phoneWithCode.startsWith(code);
4756
- });
4757
- })) === null || _phoneInfo_find === void 0 ? void 0 : _phoneInfo_find.countryCode;
4758
- if (trueReactPlatformHelpers.isEmpty(countryCode) && trueReactPlatformHelpers.isNotEmpty(phoneWithCode)) {
4759
- var _phoneInfo_filter_sort_;
4760
- countryCode = (_phoneInfo_filter_sort_ = phoneInfo.filter(function(info) {
4761
- return phoneWithCode.startsWith(info.dialCode);
4762
- }).sort(function(infoA, infoB) {
4763
- var _infoA_dialCodePriority, _infoB_dialCodePriority;
4764
- 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);
4765
- })[0]) === null || _phoneInfo_filter_sort_ === void 0 ? void 0 : _phoneInfo_filter_sort_.countryCode;
4766
- }
4767
- return countryCode;
4745
+ var _highestPriorityCountries_at;
4746
+ if (trueReactPlatformHelpers.isStringEmpty(phoneWithCode)) {
4747
+ return;
4748
+ }
4749
+ var matchedCountries = phoneInfo.filter(function(info) {
4750
+ return info.fullCodes.some(function(fullCode) {
4751
+ return phoneWithCode.startsWith(fullCode);
4752
+ });
4753
+ });
4754
+ if (matchedCountries.length === 1) {
4755
+ return matchedCountries[0].countryCode;
4756
+ }
4757
+ var highestPriorityCountries = phoneInfo.filter(function(info) {
4758
+ return phoneWithCode.startsWith(info.dialCode);
4759
+ }).sort(function(a, b) {
4760
+ var _a_dialCodePriority, _b_dialCodePriority;
4761
+ 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);
4762
+ });
4763
+ return (_highestPriorityCountries_at = highestPriorityCountries.at(0)) === null || _highestPriorityCountries_at === void 0 ? void 0 : _highestPriorityCountries_at.countryCode;
4768
4764
  };
4769
4765
  var getPhoneObjFromString = function(fullPhone, countryCode) {
4770
4766
  var _findCountryByCode;
@@ -10881,7 +10877,7 @@
10881
10877
  }
10882
10878
  return target;
10883
10879
  }
10884
- var SearchInput = function(_param) {
10880
+ var SearchInput = /* @__PURE__ */ React.forwardRef(function(_param, ref) {
10885
10881
  var _param_isClearable = _param.isClearable, isClearable = _param_isClearable === void 0 ? true : _param_isClearable, placeholder = _param.placeholder, value = _param.value, testId = _param.testId, tweakStyles = _param.tweakStyles;
10886
10882
  _param.data;
10887
10883
  var props = _object_without_properties$f(_param, [
@@ -10899,6 +10895,7 @@
10899
10895
  currentComponentName: "SearchInput"
10900
10896
  });
10901
10897
  return /* @__PURE__ */ jsx(Input, _object_spread$N({
10898
+ ref,
10902
10899
  value,
10903
10900
  placeholder,
10904
10901
  icon: "search",
@@ -10906,7 +10903,7 @@
10906
10903
  testId: trueReactPlatformHelpers.getTestId(testId, "input"),
10907
10904
  tweakStyles: tweakInputStyles
10908
10905
  }, props));
10909
- };
10906
+ });
10910
10907
  var ScrollIntoViewIfNeededDefaultElementType = "div";
10911
10908
  var ScrollIntoViewIfNeededDefaultProps = {
10912
10909
  active: true,
@@ -12010,9 +12007,13 @@
12010
12007
  dropdownOptions === null || dropdownOptions === void 0 ? void 0 : dropdownOptions.shouldUsePopper
12011
12008
  ]);
12012
12009
  var handleListClose = React.useCallback(function(event) {
12010
+ if (!isListOpen) {
12011
+ return;
12012
+ }
12013
12013
  closeList();
12014
12014
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
12015
12015
  }, [
12016
+ isListOpen,
12016
12017
  closeList,
12017
12018
  onBlur
12018
12019
  ]);
@@ -13580,6 +13581,7 @@
13580
13581
  color: colors.CLASSIC_WHITE,
13581
13582
  letterSpacing: 0.2
13582
13583
  },
13584
+ custom: {},
13583
13585
  info: {},
13584
13586
  error: {
13585
13587
  "&$tooltip": {
@@ -19215,7 +19217,7 @@
19215
19217
  if (trueReactPlatformHelpers.isEmpty(value)) {
19216
19218
  return /* @__PURE__ */ jsx(Fragment, {});
19217
19219
  }
19218
- if (filter.getSelectedValueView !== void 0) {
19220
+ if (trueReactPlatformHelpers.isNotEmpty(filter.getSelectedValueView)) {
19219
19221
  return /* @__PURE__ */ jsx("span", {
19220
19222
  className: classes.text,
19221
19223
  children: filter.getSelectedValueView(value)
@@ -19284,22 +19286,6 @@
19284
19286
  children: intervals.join(" ")
19285
19287
  });
19286
19288
  }
19287
- if (isMultiple) {
19288
- return /* @__PURE__ */ jsx(Fragment, {
19289
- children: Array.isArray(value) && value.length > 0 && /* @__PURE__ */ jsxs(Fragment, {
19290
- children: [
19291
- /* @__PURE__ */ jsx("span", {
19292
- className: classes.text,
19293
- children: displayValue(value[0])
19294
- }),
19295
- /* @__PURE__ */ jsx("span", {
19296
- className: classes.count,
19297
- children: value.length > 1 && " (+".concat(value.length - 1, ")")
19298
- })
19299
- ]
19300
- })
19301
- });
19302
- }
19303
19289
  if (isDate) {
19304
19290
  var from = value.from, to = value.to, periodType = value.periodType, label = value.label;
19305
19291
  var hasFrom = from !== void 0 && from !== null;
@@ -19330,6 +19316,24 @@
19330
19316
  children: range.join(" ")
19331
19317
  });
19332
19318
  }
19319
+ if (isMultiple) {
19320
+ var _filter_getSelectedValue;
19321
+ var convertValue = (_filter_getSelectedValue = filter.getSelectedValue) !== null && _filter_getSelectedValue !== void 0 ? _filter_getSelectedValue : displayValue;
19322
+ return /* @__PURE__ */ jsx(Fragment, {
19323
+ children: Array.isArray(value) && value.length > 0 && /* @__PURE__ */ jsxs(Fragment, {
19324
+ children: [
19325
+ /* @__PURE__ */ jsx("span", {
19326
+ className: classes.text,
19327
+ children: convertValue(value[0])
19328
+ }),
19329
+ /* @__PURE__ */ jsx("span", {
19330
+ className: classes.count,
19331
+ children: value.length > 1 && " (+".concat(value.length - 1, ")")
19332
+ })
19333
+ ]
19334
+ })
19335
+ });
19336
+ }
19333
19337
  if (isRange && Array.isArray(value)) {
19334
19338
  var rangeValue = value;
19335
19339
  var rangeValueFrom = rangeValue[0];
@@ -25877,8 +25881,24 @@
25877
25881
  ZM,
25878
25882
  ZW
25879
25883
  };
25884
+ const AB = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 341.3"><path fill="#FFF" d="M0 0h512v341.3H0z"/><g fill="#6DA544"><path d="M0 0h512v48.8H0zM0 97.5h512v48.8H0zM0 195h512v48.8H0zM0 292.6h512v48.8H0z"/></g><path fill="#D80027" d="M0 0h256v146.3H0z"/><path fill="#FFF" d="m116.9 114.4-7.5-14.8V69.9L128 59l18.6 10.9v22.3l7.4-7.4 4.2 3-4.2 11.8-14.9 14.8z"/><circle fill="#FFF" cx="82" cy="82.8" r="5.4"/><circle fill="#FFF" cx="90.8" cy="61.7" r="5.4"/><circle fill="#FFF" cx="106.6" cy="46.2" r="5.4"/><circle fill="#FFF" cx="128" cy="40.8" r="5.4"/><circle fill="#FFF" cx="149.4" cy="46.2" r="5.4"/><circle fill="#FFF" cx="165.2" cy="61.7" r="5.4"/><circle fill="#FFF" cx="174" cy="82.8" r="5.4"/></svg>';
25885
+ const OS = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 450 300"><path fill="#FFF" d="M0 0h450v300H0z"/><path fill="red" d="M0 100h450v200H0z"/><path fill="#FFDF00" d="M0 200h450v100H0z"/></svg>';
25886
+ var customFlags = {
25887
+ /**
25888
+ * Абхазия
25889
+ */
25890
+ AB,
25891
+ /**
25892
+ * Южная осетия
25893
+ */
25894
+ OS
25895
+ };
25880
25896
  var useStyles$l = createThemedStyles("Flag", {
25881
25897
  root: {
25898
+ display: "flex",
25899
+ width: "100%",
25900
+ height: "100%",
25901
+ boxSizing: "border-box",
25882
25902
  // приходится хардкодить в компоненте, тк либа Flags выдает флаги с 2-3 пиксельным отступом снизу
25883
25903
  // если будет нужно, то можно вынести border на уровень пропсов
25884
25904
  border: [
@@ -25898,17 +25918,29 @@
25898
25918
  var classes = useStyles$l({
25899
25919
  theme: tweakStyles
25900
25920
  });
25901
- var CC2 = countryCode.toUpperCase();
25902
- var TheFlag = countryFlagIcons.hasFlag(CC2) ? Flags[CC2] : function() {
25921
+ var countryFlagKey = countryCode.toUpperCase();
25922
+ var hasFlagInLibrary = countryFlagIcons.hasFlag(countryFlagKey);
25923
+ if (hasFlagInLibrary) {
25924
+ var FlagComponent = Flags[countryFlagKey];
25903
25925
  return /* @__PURE__ */ jsx("div", {
25904
- className: classes.noFlag,
25905
- children: /* @__PURE__ */ jsx(Icon, {
25906
- type: "minus"
25907
- })
25926
+ className: classes.root,
25927
+ children: /* @__PURE__ */ jsx(FlagComponent, {})
25908
25928
  });
25909
- };
25910
- return /* @__PURE__ */ jsx(TheFlag, {
25911
- className: classes.root
25929
+ }
25930
+ var CustomFlag = customFlags[countryFlagKey];
25931
+ if (CustomFlag !== void 0) {
25932
+ return /* @__PURE__ */ jsx("div", {
25933
+ className: classes.root,
25934
+ dangerouslySetInnerHTML: {
25935
+ __html: CustomFlag
25936
+ }
25937
+ });
25938
+ }
25939
+ return /* @__PURE__ */ jsx("div", {
25940
+ className: classes.noFlag,
25941
+ children: /* @__PURE__ */ jsx(Icon, {
25942
+ type: "minus"
25943
+ })
25912
25944
  });
25913
25945
  };
25914
25946
  var DEFAULT_DATE_FORMAT = "dd.MM.yyyy";
@@ -26423,7 +26455,7 @@
26423
26455
  return _array_like_to_array$7(o, minLen);
26424
26456
  }
26425
26457
  function FlexibleTableRowInner(param) {
26426
- var item = param.item, index = param.index, config = param.config, columns = param.columns, uniqueField = param.uniqueField, renderMode = param.renderMode, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isFocusable = param.isFocusable, isFocusable = _param_isFocusable === void 0 ? false : _param_isFocusable, _param_isFirstColumnSticky = param.isFirstColumnSticky, isFirstColumnSticky = _param_isFirstColumnSticky === void 0 ? false : _param_isFirstColumnSticky, _param_isLoading = param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, rowAttributes = param.rowAttributes, _param_isExpandableRowComponentInitiallyOpen = param.isExpandableRowComponentInitiallyOpen, isExpandableRowComponentInitiallyOpen = _param_isExpandableRowComponentInitiallyOpen === void 0 ? false : _param_isExpandableRowComponentInitiallyOpen, tweakStyles = param.tweakStyles, expandableRowComponent = param.expandableRowComponent, onRowHover = param.onRowHover, onRowClick = param.onRowClick;
26458
+ var item = param.item, index = param.index, config = param.config, columns = param.columns, uniqueField = param.uniqueField, renderMode = param.renderMode, _param_isActive = param.isActive, isActive = _param_isActive === void 0 ? false : _param_isActive, _param_isFocusable = param.isFocusable, isFocusable = _param_isFocusable === void 0 ? false : _param_isFocusable, _param_isFirstColumnSticky = param.isFirstColumnSticky, isFirstColumnSticky = _param_isFirstColumnSticky === void 0 ? false : _param_isFirstColumnSticky, _param_isLoading = param.isLoading, isLoading = _param_isLoading === void 0 ? false : _param_isLoading, rowAttributes = param.rowAttributes, _param_isExpandableRowComponentInitiallyOpen = param.isExpandableRowComponentInitiallyOpen, isExpandableRowComponentInitiallyOpen = _param_isExpandableRowComponentInitiallyOpen === void 0 ? false : _param_isExpandableRowComponentInitiallyOpen, rowRef = param.rowRef, tweakStyles = param.tweakStyles, expandableRowComponent = param.expandableRowComponent, onRowHover = param.onRowHover, onRowClick = param.onRowClick;
26427
26459
  var classes = useStyles$h({
26428
26460
  theme: tweakStyles
26429
26461
  });
@@ -26500,6 +26532,7 @@
26500
26532
  return /* @__PURE__ */ jsxs(Fragment, {
26501
26533
  children: [
26502
26534
  /* @__PURE__ */ jsx(Table.Row, _object_spread_props$k(_object_spread$l({
26535
+ ref: rowRef,
26503
26536
  className: clsx(classes.root, (_obj2 = {}, _define_property$m(_obj2, classes.active, isActive), _define_property$m(_obj2, classes.editable, isEditable), _define_property$m(_obj2, classes.clickable, isClickable), _obj2))
26504
26537
  }, !isLoading && {
26505
26538
  onClick: handleRowClick,
@@ -28881,6 +28914,7 @@
28881
28914
  var _value_countryCode;
28882
28915
  return (_value_countryCode = value === null || value === void 0 ? void 0 : value.countryCode) !== null && _value_countryCode !== void 0 ? _value_countryCode : getCountryCodeFromPhone(phoneWithCode);
28883
28916
  }, [
28917
+ value.countryCode,
28884
28918
  value.dialCode,
28885
28919
  value.phoneNumber
28886
28920
  ]);
@@ -28911,7 +28945,7 @@
28911
28945
  var handleSelect = function(newPhoneInfo, event) {
28912
28946
  if (newPhoneInfo.countryCode !== countryCode) {
28913
28947
  onChange({
28914
- phoneNumber: "",
28948
+ phoneNumber: newPhoneInfo.dialCode !== value.dialCode ? "" : getPhoneObjFromString(phoneWithCode).phoneNumber,
28915
28949
  dialCode: newPhoneInfo.dialCode,
28916
28950
  countryCode: newPhoneInfo.countryCode
28917
28951
  }, event);