@gympass/yoga 7.127.4 → 7.128.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.
@@ -97,6 +97,7 @@ const Phone = import_react.default.forwardRef(
97
97
  label = "",
98
98
  placeholder = "+55 (11) 999999999",
99
99
  value = "",
100
+ countries = phoneBaseSettings.onlyCountries,
100
101
  onChange = noop,
101
102
  cleanable = true
102
103
  } = _b, rest = __objRest(_b, [
@@ -109,6 +110,7 @@ const Phone = import_react.default.forwardRef(
109
110
  "label",
110
111
  "placeholder",
111
112
  "value",
113
+ "countries",
112
114
  "onChange",
113
115
  "cleanable"
114
116
  ]);
@@ -120,6 +122,9 @@ const Phone = import_react.default.forwardRef(
120
122
  currentCountry.current = countryCode;
121
123
  }
122
124
  }, []);
125
+ const availableCountries = {
126
+ onlyCountries: (countries == null ? void 0 : countries.length) > 0 ? countries : phoneBaseSettings.onlyCountries
127
+ };
123
128
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
124
129
  import_Input.default,
125
130
  __spreadProps(__spreadValues({}, __spreadValues({
@@ -136,7 +141,7 @@ const Phone = import_react.default.forwardRef(
136
141
  onClean: (phoneNumber) => onChange(phoneNumber),
137
142
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(S.Container, { error, disabled, full, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
138
143
  import_react_phone_input_2.default,
139
- __spreadProps(__spreadValues({}, phoneBaseSettings), {
144
+ __spreadProps(__spreadValues({}, availableCountries), {
140
145
  ref: (phoneRef) => {
141
146
  inputRef.current = phoneRef == null ? void 0 : phoneRef.numberInputRef;
142
147
  },
@@ -180,6 +185,8 @@ Phone.propTypes = {
180
185
  /** callback invoked when value changes, either by typing of selecting a country */
181
186
  onChange: import_prop_types.func,
182
187
  /** placeholder to show when the input is cleared */
183
- placeholder: import_prop_types.string
188
+ placeholder: import_prop_types.string,
189
+ /** countries for mask field and dropdown, make sure to use ISO 3166-1 alpha-2 lowercase */
190
+ countries: import_prop_types.default.arrayOf(import_prop_types.string)
184
191
  };
185
192
  var Phone_default = Phone;
@@ -98,6 +98,21 @@ describe("<Input.Phone />", () => {
98
98
  expect(getByDisplayValue(spec.expected)).toBeInTheDocument();
99
99
  });
100
100
  });
101
+ it(`Should only format and show countries numbers when props is given`, () => {
102
+ const USPhone = numbersFormats[1];
103
+ const { queryByDisplayValue } = (0, import_react2.render)(
104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input.Phone, { countries: ["br", "pt"], value: USPhone.base }) })
105
+ );
106
+ expect(queryByDisplayValue(USPhone.expected)).not.toBeInTheDocument();
107
+ });
108
+ it(`Should return all countries validation if countries equals to empty array`, () => {
109
+ const USPhone = numbersFormats[1];
110
+ const { getAllByRole } = (0, import_react2.render)(
111
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input.Phone, { countries: [], value: USPhone.base }) })
112
+ );
113
+ import_react2.fireEvent.click(getAllByRole("button")[0]);
114
+ expect(getAllByRole("option").length).toBe(12);
115
+ });
101
116
  it("should prefix the phone number with newly selected country dial code", () => __async(exports, null, function* () {
102
117
  const { getByRole, getByText, getByDisplayValue } = (0, import_react2.render)(
103
118
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input.Phone, { defaultCountry: "us" }) })
@@ -66,6 +66,7 @@ const Phone = React.forwardRef(
66
66
  label = "",
67
67
  placeholder = "+55 (11) 999999999",
68
68
  value = "",
69
+ countries = phoneBaseSettings.onlyCountries,
69
70
  onChange = noop,
70
71
  cleanable = true
71
72
  } = _b, rest = __objRest(_b, [
@@ -78,6 +79,7 @@ const Phone = React.forwardRef(
78
79
  "label",
79
80
  "placeholder",
80
81
  "value",
82
+ "countries",
81
83
  "onChange",
82
84
  "cleanable"
83
85
  ]);
@@ -89,6 +91,9 @@ const Phone = React.forwardRef(
89
91
  currentCountry.current = countryCode;
90
92
  }
91
93
  }, []);
94
+ const availableCountries = {
95
+ onlyCountries: (countries == null ? void 0 : countries.length) > 0 ? countries : phoneBaseSettings.onlyCountries
96
+ };
92
97
  return /* @__PURE__ */ jsx(
93
98
  Input,
94
99
  __spreadProps(__spreadValues({}, __spreadValues({
@@ -105,7 +110,7 @@ const Phone = React.forwardRef(
105
110
  onClean: (phoneNumber) => onChange(phoneNumber),
106
111
  children: /* @__PURE__ */ jsx(S.Container, { error, disabled, full, children: /* @__PURE__ */ jsx(
107
112
  BasePhoneInput,
108
- __spreadProps(__spreadValues({}, phoneBaseSettings), {
113
+ __spreadProps(__spreadValues({}, availableCountries), {
109
114
  ref: (phoneRef) => {
110
115
  inputRef.current = phoneRef == null ? void 0 : phoneRef.numberInputRef;
111
116
  },
@@ -149,7 +154,9 @@ Phone.propTypes = {
149
154
  /** callback invoked when value changes, either by typing of selecting a country */
150
155
  onChange: func,
151
156
  /** placeholder to show when the input is cleared */
152
- placeholder: string
157
+ placeholder: string,
158
+ /** countries for mask field and dropdown, make sure to use ISO 3166-1 alpha-2 lowercase */
159
+ countries: PropTypes.arrayOf(string)
153
160
  };
154
161
  var Phone_default = Phone;
155
162
  export {
@@ -81,6 +81,21 @@ var require_Phone_test = __commonJS({
81
81
  expect(getByDisplayValue(spec.expected)).toBeInTheDocument();
82
82
  });
83
83
  });
84
+ it(`Should only format and show countries numbers when props is given`, () => {
85
+ const USPhone = numbersFormats[1];
86
+ const { queryByDisplayValue } = render(
87
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input.Phone, { countries: ["br", "pt"], value: USPhone.base }) })
88
+ );
89
+ expect(queryByDisplayValue(USPhone.expected)).not.toBeInTheDocument();
90
+ });
91
+ it(`Should return all countries validation if countries equals to empty array`, () => {
92
+ const USPhone = numbersFormats[1];
93
+ const { getAllByRole } = render(
94
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input.Phone, { countries: [], value: USPhone.base }) })
95
+ );
96
+ fireEvent.click(getAllByRole("button")[0]);
97
+ expect(getAllByRole("option").length).toBe(12);
98
+ });
84
99
  it("should prefix the phone number with newly selected country dial code", () => __async(exports, null, function* () {
85
100
  const { getByRole, getByText, getByDisplayValue } = render(
86
101
  /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input.Phone, { defaultCountry: "us" }) })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gympass/yoga",
3
- "version": "7.127.4",
3
+ "version": "7.128.0",
4
4
  "description": "Gympass component library",
5
5
  "main": "./cjs",
6
6
  "types": "./typings/index.d.ts",
@@ -58,7 +58,7 @@
58
58
  "react-native": "0.72.3",
59
59
  "styled-components": "^4.4.0"
60
60
  },
61
- "gitHead": "3bb60c107e1ad8945f71e3e0a73dc1622af9dd11",
61
+ "gitHead": "d3904daa0d594a33c0687a0f6ad8baa3df9d156b",
62
62
  "module": "./esm",
63
63
  "private": false,
64
64
  "react-native": "./cjs/index.native.js"