@via-profit/ui-kit 0.1.0-rc.86 → 0.1.0-rc.88

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,14 +1,23 @@
1
1
  import React from 'react';
2
2
  import { TextFieldProps } from '../TextField';
3
- import type { CountryCode, CountryFlag, PhoneTemplate } from './templates';
3
+ import type { CountryFlag, PhoneTemplate } from './templates';
4
4
  export interface PhoneFieldProps extends Omit<TextFieldProps, 'value' | 'onChange'> {
5
5
  /**
6
6
  * Phone string format 79876543210 or +7 (987) 654-32-10
7
7
  */
8
8
  readonly value: string;
9
- readonly defaultCountry?: CountryCode | null;
9
+ /**
10
+ * On input change event
11
+ */
10
12
  readonly onChange: (event: React.ChangeEvent<HTMLInputElement>, payload: PhonePayload) => void;
13
+ /**
14
+ * Supported RegExp templates
15
+ */
11
16
  readonly templates: readonly PhoneTemplate[];
17
+ /**
18
+ * If truethen CountryFalg component will be hidden
19
+ */
20
+ readonly withoutCountryFlag?: boolean;
12
21
  }
13
22
  export interface PhonePayload {
14
23
  /**
@@ -33,7 +33,7 @@ const TextField_1 = __importDefault(require("../TextField"));
33
33
  const usePhoneUtils_1 = require("./usePhoneUtils");
34
34
  const CountryFlagComponent_1 = __importDefault(require("./CountryFlagComponent"));
35
35
  const PhoneField = (props, ref) => {
36
- const { value, defaultCountry, templates, inputRef, onChange } = props, textFieldProps = __rest(props, ["value", "defaultCountry", "templates", "inputRef", "onChange"]);
36
+ const { value, templates, inputRef, withoutCountryFlag, onChange } = props, textFieldProps = __rest(props, ["value", "templates", "inputRef", "withoutCountryFlag", "onChange"]);
37
37
  const { formatParsedInput, parseInput, parseAndFormat } = (0, usePhoneUtils_1.usePhoneUtils)({ templates });
38
38
  const textInputRef = react_1.default.useRef(null);
39
39
  const initialValue = react_1.default.useRef(value);
@@ -80,12 +80,12 @@ const PhoneField = (props, ref) => {
80
80
  (_a = textInputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange(caret, caret);
81
81
  }, 15);
82
82
  };
83
- return (react_1.default.createElement(TextField_1.default, Object.assign({ ref: ref }, textFieldProps, { startIcon: react_1.default.useMemo(() => (react_1.default.createElement(CountryFlagComponent_1.default, { flag: CountryFlag, onClick: () => {
83
+ return (react_1.default.createElement(TextField_1.default, Object.assign({ ref: ref, startIcon: react_1.default.useMemo(() => withoutCountryFlag ? undefined : (react_1.default.createElement(CountryFlagComponent_1.default, { flag: CountryFlag, onClick: () => {
84
84
  if (textInputRef.current) {
85
85
  textInputRef.current.select();
86
86
  textInputRef.current.focus();
87
87
  }
88
- } })), [CountryFlag]), value: currentValue, placeholder: placeholder, onChange: handleChange, inputRef: input => {
88
+ } })), [CountryFlag, withoutCountryFlag]) }, textFieldProps, { value: currentValue, placeholder: placeholder, onChange: handleChange, inputRef: input => {
89
89
  textInputRef.current = input;
90
90
  if (typeof inputRef === 'function') {
91
91
  inputRef(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@via-profit/ui-kit",
3
- "version": "0.1.0-rc.86",
3
+ "version": "0.1.0-rc.88",
4
4
  "description": "UI Kit",
5
5
  "repository": {
6
6
  "type": "git",