@commercetools-uikit/localized-text-field 12.2.7 → 13.0.2

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
@@ -49,35 +49,48 @@ export default Example;
49
49
 
50
50
  ## Properties
51
51
 
52
- | Props | Type | Required | Default | Description |
53
- | ------------------------------- | ----------------------------------------------------------------------------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
- | `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
55
- | `horizontalConstraint` | `enum`<br/>Possible values:<br/>`6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
56
- | `errors` | `object` | | | A map of errors. Error messages for known errors are rendered automatically.&#xA;<br />&#xA;Unknown errors will be forwarded to `renderError` |
57
- | `errors.missing` | `bool` | | | |
58
- | `renderError` | `func` | | | Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.&#xA;<br />&#xA;Signature: `(key, error) => React.node` |
59
- | `isRequired` | `bool` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
60
- | `touched` | `bool` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
61
- | `autoComplete` | `string` | | | Used as HTML `autocomplete` of the input component. property |
62
- | `name` | `string` | | | Used as HTML name of the input component. property |
63
- | `value` | `objectOf(string)` | ✅ | | Values to use.&#xA;<br />&#xA;Keyed by language, the values are the actual values, e.g. `{ en: 'Horse', de: 'Pferd' }` |
64
- | `onChange` | `custom` | | | Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.&#xA;<br />&#xA;Signature: `(event) => void` |
65
- | `selectedLanguage` | `string` | ✅ | | Specifies which language will be shown in case the `LocalizedTextInput` is collapsed. |
66
- | `onBlur` | `func` | | | Called when input is blurred |
67
- | `onFocus` | `func` | | | Called when input is focused |
68
- | `hideLanguageExpansionControls` | `bool` | | | Will hide the language expansion controls when set to `true`. All languages will be shown when set to `true`. |
69
- | `defaultExpandLanguages` | `custom` | | | Controls whether one or all languages are visible by default |
70
- | `isAutofocussed` | `bool` | | | Focus the input on initial render |
71
- | `isDisabled` | `bool` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
72
- | `isReadOnly` | `bool` | | | Indicates that the field is displaying read-only content |
73
- | `placeholder` | `objectOf(string)` | | | Placeholders for each language. Object of the same shape as `value`. |
74
- | `errorsByLanguage` | `objectOf(node)` | | | Errors for each translation. These are forwarded to the `errors` prop of `LocalizedTextInput`. |
75
- | `title` | `<string, node>` | ✅ | | Title of the label |
76
- | `hint` | `custom` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`. |
77
- | `description` | `<string, node>` | | | Provides a description for the title. |
78
- | `onInfoButtonClick` | `func` | | | Function called when info button is pressed.&#xA;<br />&#xA;Info button will only be visible when this prop is passed.&#xA;<br />&#xA;Signature: `(event) => void` |
79
- | `hintIcon` | `node` | | | Icon to be displayed beside the hint text.&#xA;<br />&#xA;Will only get rendered when `hint` is passed as well. |
80
- | `badge` | `node` | | | Badge to be displayed beside the label.&#xA;<br />&#xA;Might be used to display additional information about the content of the field (E.g verified email) |
52
+ | Props | Type | Required | Default | Description |
53
+ | ------------------------------- | -------------------------------------------------------------------------------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
+ | `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
55
+ | `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
56
+ | `errors` | `TFieldErrors` | | | A map of errors. Error messages for known errors are rendered automatically.&#xA;<br />&#xA;Unknown errors will be forwarded to `renderError` |
57
+ | `renderError` | `Function`<br/>[See signature.](#signature-renderError) | | | Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error. |
58
+ | `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
59
+ | `touched` | `boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
60
+ | `autoComplete` | `string` | | | Used as HTML `autocomplete` of the input component. property |
61
+ | `name` | `string` | | | Used as HTML name of the input component. property |
62
+ | `value` | `Record` | ✅ | | Values to use.&#xA;<br />&#xA;Keyed by language, the values are the actual values, e.g. `{ en: 'Horse', de: 'Pferd' }` |
63
+ | `onChange` | `ChangeEventHandler` | | | Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value. |
64
+ | `selectedLanguage` | `string` | ✅ | | Specifies which language will be shown in case the `LocalizedTextInput` is collapsed. |
65
+ | `onBlur` | `FocusEventHandler` | | | Called when input is blurred |
66
+ | `onFocus` | `FocusEventHandler` | | | Called when input is focused |
67
+ | `hideLanguageExpansionControls` | `boolean` | | | Will hide the language expansion controls when set to `true`. All languages will be shown when set to `true`. |
68
+ | `defaultExpandLanguages` | `boolean` | | | Controls whether one or all languages are visible by default |
69
+ | `isAutofocussed` | `boolean` | | | Focus the input on initial render |
70
+ | `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
71
+ | `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
72
+ | `placeholder` | `Record` | | | Placeholders for each language. Object of the same shape as `value`. |
73
+ | `errorsByLanguage` | `Record` | | | Errors for each translation. These are forwarded to the `errors` prop of `LocalizedTextInput`. |
74
+ | `title` | `ReactNode` | ✅ | | Title of the label |
75
+ | `hint` | `ReactNode` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`. |
76
+ | `description` | `ReactNode` | | | Provides a description for the title. |
77
+ | `onInfoButtonClick` | `Function`<br/>[See signature.](#signature-onInfoButtonClick) | | | Function called when info button is pressed.&#xA;<br />&#xA;Info button will only be visible when this prop is passed. |
78
+ | `hintIcon` | `ReactElement` | | | Icon to be displayed beside the hint text.&#xA;<br />&#xA;Will only get rendered when `hint` is passed as well. |
79
+ | `badge` | `ReactNode` | | | Badge to be displayed beside the label.&#xA;<br />&#xA;Might be used to display additional information about the content of the field (E.g verified email) |
80
+
81
+ ## Signatures
82
+
83
+ ### Signature `renderError`
84
+
85
+ ```ts
86
+ (key: string, error?: boolean) => ReactNode;
87
+ ```
88
+
89
+ ### Signature `onInfoButtonClick`
90
+
91
+ ```ts
92
+ (event: TEvent) => void
93
+ ```
81
94
 
82
95
  ## `data-*` props
83
96
 
@@ -0,0 +1,2 @@
1
+ export * from "./declarations/src/index";
2
+ export { default } from "./declarations/src/index";
@@ -11,20 +11,17 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
11
11
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
12
12
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
13
13
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
14
- var _taggedTemplateLiteral = require('@babel/runtime-corejs3/helpers/taggedTemplateLiteral');
15
14
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
16
15
  var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
17
16
  var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
18
17
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
19
18
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
20
19
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
20
+ var _pt = require('prop-types');
21
21
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
22
22
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
23
23
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
24
24
  var react = require('react');
25
- var PropTypes = require('prop-types');
26
- var requiredIf = require('react-required-if');
27
- var commonTags = require('common-tags');
28
25
  var utils = require('@commercetools-uikit/utils');
29
26
  var Constraints = require('@commercetools-uikit/constraints');
30
27
  var Spacings = require('@commercetools-uikit/spacings');
@@ -44,22 +41,19 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
44
41
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
45
42
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
46
43
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
44
+ var _pt__default = /*#__PURE__*/_interopDefault(_pt);
47
45
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
48
46
  var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
49
47
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
50
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
51
- var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
52
48
  var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
53
49
  var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
54
50
  var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
55
51
  var LocalizedTextInput__default = /*#__PURE__*/_interopDefault(LocalizedTextInput);
56
52
  var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
57
53
 
58
- var _templateObject;
54
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
59
55
 
60
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
61
-
62
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source), true)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context5; _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source))).call(_context5, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
56
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
63
57
 
64
58
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
65
59
 
@@ -101,6 +95,15 @@ var LocalizedTextField = /*#__PURE__*/function (_Component) {
101
95
  key: "render",
102
96
  value: function render() {
103
97
  var hasError = this.props.touched && hasErrors(this.props.errors);
98
+
99
+ if (this.props.hintIcon) {
100
+ process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.hint === 'string' || /*#__PURE__*/react.isValidElement(this.props.hint), 'LocalizedTextField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
101
+ }
102
+
103
+ if (this.props.hideLanguageExpansionControls) {
104
+ process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.defaultExpandLanguages !== 'boolean', 'LocalizedTextField: "defaultExpandLanguages" does not have any effect when "hideLanguageExpansionControls" is set.') : void 0;
105
+ }
106
+
104
107
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
105
108
  max: this.props.horizontalConstraint,
106
109
  children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
@@ -157,178 +160,36 @@ LocalizedTextField.getDerivedStateFromProps = function (props, state) {
157
160
  };
158
161
 
159
162
  LocalizedTextField.propTypes = process.env.NODE_ENV !== "production" ? {
160
- // LocalizedTextField
161
-
162
- /**
163
- * Used as HTML id property. An id is auto-generated when it is not specified.
164
- */
165
- id: PropTypes__default["default"].string,
166
-
167
- /**
168
- * Horizontal size limit of the input fields.
169
- */
170
- horizontalConstraint: PropTypes__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
171
-
172
- /**
173
- * A map of errors. Error messages for known errors are rendered automatically.
174
- * <br />
175
- * Unknown errors will be forwarded to `renderError`
176
- */
177
- errors: PropTypes__default["default"].shape({
178
- missing: PropTypes__default["default"].bool
179
- }),
180
-
181
- /**
182
- * Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
183
- * <br />
184
- * Signature: `(key, error) => React.node`
185
- */
186
- renderError: PropTypes__default["default"].func,
187
-
188
- /**
189
- * Indicates if the value is required. Shows an the "required asterisk" if so.
190
- */
191
- isRequired: PropTypes__default["default"].bool,
192
-
193
- /**
194
- * Indicates whether the field was touched. Errors will only be shown when the field was touched.
195
- */
196
- touched: PropTypes__default["default"].bool,
197
- // LocalizedTextInput
198
-
199
- /**
200
- * Used as HTML `autocomplete` of the input component. property
201
- */
202
- autoComplete: PropTypes__default["default"].string,
203
-
204
- /**
205
- * Used as HTML name of the input component. property
206
- */
207
- name: PropTypes__default["default"].string,
208
-
209
- /**
210
- * Values to use.
211
- * <br />
212
- Keyed by language, the values are the actual values, e.g. `{ en: 'Horse', de: 'Pferd' }`
213
- */
214
- value: PropTypes__default["default"].objectOf(PropTypes__default["default"].string).isRequired,
215
-
216
- /**
217
- * Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
218
- * <br />
219
- * Signature: `(event) => void`
220
- */
221
- onChange: requiredIf__default["default"](PropTypes__default["default"].func, function (props) {
222
- return !props.isReadOnly;
223
- }),
224
-
225
- /**
226
- * Specifies which language will be shown in case the `LocalizedTextInput` is collapsed.
227
- */
228
- selectedLanguage: PropTypes__default["default"].string.isRequired,
229
-
230
- /**
231
- * Called when input is blurred
232
- */
233
- onBlur: PropTypes__default["default"].func,
234
-
235
- /**
236
- * Called when input is focused
237
- */
238
- onFocus: PropTypes__default["default"].func,
239
-
240
- /**
241
- * Will hide the language expansion controls when set to `true`. All languages will be shown when set to `true`.
242
- */
243
- hideLanguageExpansionControls: PropTypes__default["default"].bool,
244
-
245
- /**
246
- * Controls whether one or all languages are visible by default
247
- */
248
- defaultExpandLanguages: function defaultExpandLanguages(props, propName, componentName) {
249
- var _context3;
250
-
251
- if (props.hideLanguageExpansionControls && typeof props[propName] === 'boolean') {
252
- throw new Error(commonTags.oneLine(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ": \"", "\" does not have any effect when\n \"hideLanguageExpansionControls\" is set.\n "])), componentName, propName));
253
- }
254
-
255
- for (var _len2 = arguments.length, rest = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
256
- rest[_key2 - 3] = arguments[_key2];
257
- }
258
-
259
- return PropTypes__default["default"].bool.apply(PropTypes__default["default"], _concatInstanceProperty__default["default"](_context3 = [props, propName, componentName]).call(_context3, rest));
260
- },
261
-
262
- /**
263
- * Focus the input on initial render
264
- */
265
- isAutofocussed: PropTypes__default["default"].bool,
266
-
267
- /**
268
- * Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
269
- */
270
- isDisabled: PropTypes__default["default"].bool,
271
-
272
- /**
273
- * Indicates that the field is displaying read-only content
274
- */
275
- isReadOnly: PropTypes__default["default"].bool,
276
-
277
- /**
278
- * Placeholders for each language. Object of the same shape as `value`.
279
- */
280
- placeholder: PropTypes__default["default"].objectOf(PropTypes__default["default"].string),
281
-
282
- /**
283
- * Errors for each translation. These are forwarded to the `errors` prop of `LocalizedTextInput`.
284
- */
285
- errorsByLanguage: PropTypes__default["default"].objectOf(PropTypes__default["default"].node),
286
- // LabelField
287
-
288
- /**
289
- * Title of the label
290
- */
291
- title: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]).isRequired,
292
-
293
- /**
294
- * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`.
295
- */
296
- hint: requiredIf__default["default"](PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]), function (props) {
297
- return props.hintIcon;
298
- }),
299
-
300
- /**
301
- * Provides a description for the title.
302
- */
303
- description: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]),
304
-
305
- /**
306
- * Function called when info button is pressed.
307
- * <br />
308
- * Info button will only be visible when this prop is passed.
309
- * <br />
310
- * Signature: `(event) => void`
311
- */
312
- onInfoButtonClick: PropTypes__default["default"].func,
313
-
314
- /**
315
- * Icon to be displayed beside the hint text.
316
- * <br />
317
- * Will only get rendered when `hint` is passed as well.
318
- */
319
- hintIcon: PropTypes__default["default"].node,
320
-
321
- /**
322
- * Badge to be displayed beside the label.
323
- * <br />
324
- * Might be used to display additional information about the content of the field (E.g verified email)
325
- */
326
- badge: PropTypes__default["default"].node
163
+ id: _pt__default["default"].string,
164
+ horizontalConstraint: _pt__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
165
+ errors: _pt__default["default"].any,
166
+ renderError: _pt__default["default"].func,
167
+ isRequired: _pt__default["default"].bool,
168
+ touched: _pt__default["default"].bool,
169
+ autoComplete: _pt__default["default"].string,
170
+ name: _pt__default["default"].string,
171
+ value: _pt__default["default"].objectOf(_pt__default["default"].string).isRequired,
172
+ onChange: _pt__default["default"].func,
173
+ selectedLanguage: _pt__default["default"].string.isRequired,
174
+ onBlur: _pt__default["default"].func,
175
+ onFocus: _pt__default["default"].func,
176
+ hideLanguageExpansionControls: _pt__default["default"].bool,
177
+ defaultExpandLanguages: _pt__default["default"].bool,
178
+ isAutofocussed: _pt__default["default"].bool,
179
+ isDisabled: _pt__default["default"].bool,
180
+ isReadOnly: _pt__default["default"].bool,
181
+ placeholder: _pt__default["default"].objectOf(_pt__default["default"].string),
182
+ errorsByLanguage: _pt__default["default"].objectOf(_pt__default["default"].string),
183
+ title: _pt__default["default"].node.isRequired,
184
+ hint: _pt__default["default"].node,
185
+ description: _pt__default["default"].node,
186
+ onInfoButtonClick: _pt__default["default"].func,
187
+ hintIcon: _pt__default["default"].element
327
188
  } : {};
328
189
  var LocalizedTextField$1 = LocalizedTextField;
329
190
 
330
191
  // NOTE: This string will be replaced on build time with the package version.
331
- var version = "12.2.7";
192
+ var version = "13.0.2";
332
193
 
333
194
  exports["default"] = LocalizedTextField$1;
334
195
  exports.version = version;
@@ -11,20 +11,17 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
11
11
  var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
12
12
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
13
13
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
14
- require('@babel/runtime-corejs3/helpers/taggedTemplateLiteral');
15
14
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
16
15
  var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
17
16
  var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
18
17
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
19
18
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
20
19
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
20
+ require('prop-types');
21
21
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
22
22
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
23
23
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
24
24
  var react = require('react');
25
- require('prop-types');
26
- require('react-required-if');
27
- require('common-tags');
28
25
  var utils = require('@commercetools-uikit/utils');
29
26
  var Constraints = require('@commercetools-uikit/constraints');
30
27
  var Spacings = require('@commercetools-uikit/spacings');
@@ -53,9 +50,9 @@ var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
53
50
  var LocalizedTextInput__default = /*#__PURE__*/_interopDefault(LocalizedTextInput);
54
51
  var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
55
52
 
56
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
53
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
57
54
 
58
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source), true)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context5; _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source))).call(_context5, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
55
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
59
56
 
60
57
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
61
58
 
@@ -97,6 +94,11 @@ var LocalizedTextField = /*#__PURE__*/function (_Component) {
97
94
  key: "render",
98
95
  value: function render() {
99
96
  var hasError = this.props.touched && hasErrors(this.props.errors);
97
+
98
+ if (this.props.hintIcon) ;
99
+
100
+ if (this.props.hideLanguageExpansionControls) ;
101
+
100
102
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
101
103
  max: this.props.horizontalConstraint,
102
104
  children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
@@ -156,7 +158,7 @@ LocalizedTextField.propTypes = {};
156
158
  var LocalizedTextField$1 = LocalizedTextField;
157
159
 
158
160
  // NOTE: This string will be replaced on build time with the package version.
159
- var version = "12.2.7";
161
+ var version = "13.0.2";
160
162
 
161
163
  exports["default"] = LocalizedTextField$1;
162
164
  exports.version = version;
@@ -7,21 +7,18 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
7
7
  import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
8
8
  import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
9
9
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
10
- import _taggedTemplateLiteral from '@babel/runtime-corejs3/helpers/esm/taggedTemplateLiteral';
11
10
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
12
11
  import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
13
12
  import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
14
13
  import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
15
14
  import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
16
15
  import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
16
+ import _pt from 'prop-types';
17
17
  import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
18
18
  import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
19
19
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
20
- import { Component } from 'react';
21
- import PropTypes from 'prop-types';
22
- import requiredIf from 'react-required-if';
23
- import { oneLine } from 'common-tags';
24
- import { createSequentialId, filterDataAttributes, getFieldId } from '@commercetools-uikit/utils';
20
+ import { isValidElement, Component } from 'react';
21
+ import { createSequentialId, warning, filterDataAttributes, getFieldId } from '@commercetools-uikit/utils';
25
22
  import Constraints from '@commercetools-uikit/constraints';
26
23
  import Spacings from '@commercetools-uikit/spacings';
27
24
  import FieldLabel from '@commercetools-uikit/field-label';
@@ -29,11 +26,9 @@ import LocalizedTextInput from '@commercetools-uikit/localized-text-input';
29
26
  import FieldErrors from '@commercetools-uikit/field-errors';
30
27
  import { jsx, jsxs } from '@emotion/react/jsx-runtime';
31
28
 
32
- var _templateObject;
29
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
30
 
34
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
35
-
36
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context4; _forEachInstanceProperty(_context4 = ownKeys(Object(source), true)).call(_context4, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context5; _forEachInstanceProperty(_context5 = ownKeys(Object(source))).call(_context5, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
31
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
37
32
 
38
33
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
39
34
 
@@ -75,6 +70,15 @@ var LocalizedTextField = /*#__PURE__*/function (_Component) {
75
70
  key: "render",
76
71
  value: function render() {
77
72
  var hasError = this.props.touched && hasErrors(this.props.errors);
73
+
74
+ if (this.props.hintIcon) {
75
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.hint === 'string' || /*#__PURE__*/isValidElement(this.props.hint), 'LocalizedTextField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
76
+ }
77
+
78
+ if (this.props.hideLanguageExpansionControls) {
79
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.defaultExpandLanguages !== 'boolean', 'LocalizedTextField: "defaultExpandLanguages" does not have any effect when "hideLanguageExpansionControls" is set.') : void 0;
80
+ }
81
+
78
82
  return jsx(Constraints.Horizontal, {
79
83
  max: this.props.horizontalConstraint,
80
84
  children: jsxs(Spacings.Stack, {
@@ -131,177 +135,35 @@ LocalizedTextField.getDerivedStateFromProps = function (props, state) {
131
135
  };
132
136
 
133
137
  LocalizedTextField.propTypes = process.env.NODE_ENV !== "production" ? {
134
- // LocalizedTextField
135
-
136
- /**
137
- * Used as HTML id property. An id is auto-generated when it is not specified.
138
- */
139
- id: PropTypes.string,
140
-
141
- /**
142
- * Horizontal size limit of the input fields.
143
- */
144
- horizontalConstraint: PropTypes.oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
145
-
146
- /**
147
- * A map of errors. Error messages for known errors are rendered automatically.
148
- * <br />
149
- * Unknown errors will be forwarded to `renderError`
150
- */
151
- errors: PropTypes.shape({
152
- missing: PropTypes.bool
153
- }),
154
-
155
- /**
156
- * Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
157
- * <br />
158
- * Signature: `(key, error) => React.node`
159
- */
160
- renderError: PropTypes.func,
161
-
162
- /**
163
- * Indicates if the value is required. Shows an the "required asterisk" if so.
164
- */
165
- isRequired: PropTypes.bool,
166
-
167
- /**
168
- * Indicates whether the field was touched. Errors will only be shown when the field was touched.
169
- */
170
- touched: PropTypes.bool,
171
- // LocalizedTextInput
172
-
173
- /**
174
- * Used as HTML `autocomplete` of the input component. property
175
- */
176
- autoComplete: PropTypes.string,
177
-
178
- /**
179
- * Used as HTML name of the input component. property
180
- */
181
- name: PropTypes.string,
182
-
183
- /**
184
- * Values to use.
185
- * <br />
186
- Keyed by language, the values are the actual values, e.g. `{ en: 'Horse', de: 'Pferd' }`
187
- */
188
- value: PropTypes.objectOf(PropTypes.string).isRequired,
189
-
190
- /**
191
- * Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
192
- * <br />
193
- * Signature: `(event) => void`
194
- */
195
- onChange: requiredIf(PropTypes.func, function (props) {
196
- return !props.isReadOnly;
197
- }),
198
-
199
- /**
200
- * Specifies which language will be shown in case the `LocalizedTextInput` is collapsed.
201
- */
202
- selectedLanguage: PropTypes.string.isRequired,
203
-
204
- /**
205
- * Called when input is blurred
206
- */
207
- onBlur: PropTypes.func,
208
-
209
- /**
210
- * Called when input is focused
211
- */
212
- onFocus: PropTypes.func,
213
-
214
- /**
215
- * Will hide the language expansion controls when set to `true`. All languages will be shown when set to `true`.
216
- */
217
- hideLanguageExpansionControls: PropTypes.bool,
218
-
219
- /**
220
- * Controls whether one or all languages are visible by default
221
- */
222
- defaultExpandLanguages: function defaultExpandLanguages(props, propName, componentName) {
223
- var _context3;
224
-
225
- if (props.hideLanguageExpansionControls && typeof props[propName] === 'boolean') {
226
- throw new Error(oneLine(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ": \"", "\" does not have any effect when\n \"hideLanguageExpansionControls\" is set.\n "])), componentName, propName));
227
- }
228
-
229
- for (var _len2 = arguments.length, rest = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
230
- rest[_key2 - 3] = arguments[_key2];
231
- }
232
-
233
- return PropTypes.bool.apply(PropTypes, _concatInstanceProperty(_context3 = [props, propName, componentName]).call(_context3, rest));
234
- },
235
-
236
- /**
237
- * Focus the input on initial render
238
- */
239
- isAutofocussed: PropTypes.bool,
240
-
241
- /**
242
- * Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
243
- */
244
- isDisabled: PropTypes.bool,
245
-
246
- /**
247
- * Indicates that the field is displaying read-only content
248
- */
249
- isReadOnly: PropTypes.bool,
250
-
251
- /**
252
- * Placeholders for each language. Object of the same shape as `value`.
253
- */
254
- placeholder: PropTypes.objectOf(PropTypes.string),
255
-
256
- /**
257
- * Errors for each translation. These are forwarded to the `errors` prop of `LocalizedTextInput`.
258
- */
259
- errorsByLanguage: PropTypes.objectOf(PropTypes.node),
260
- // LabelField
261
-
262
- /**
263
- * Title of the label
264
- */
265
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
266
-
267
- /**
268
- * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`.
269
- */
270
- hint: requiredIf(PropTypes.oneOfType([PropTypes.string, PropTypes.node]), function (props) {
271
- return props.hintIcon;
272
- }),
273
-
274
- /**
275
- * Provides a description for the title.
276
- */
277
- description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
278
-
279
- /**
280
- * Function called when info button is pressed.
281
- * <br />
282
- * Info button will only be visible when this prop is passed.
283
- * <br />
284
- * Signature: `(event) => void`
285
- */
286
- onInfoButtonClick: PropTypes.func,
287
-
288
- /**
289
- * Icon to be displayed beside the hint text.
290
- * <br />
291
- * Will only get rendered when `hint` is passed as well.
292
- */
293
- hintIcon: PropTypes.node,
294
-
295
- /**
296
- * Badge to be displayed beside the label.
297
- * <br />
298
- * Might be used to display additional information about the content of the field (E.g verified email)
299
- */
300
- badge: PropTypes.node
138
+ id: _pt.string,
139
+ horizontalConstraint: _pt.oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
140
+ errors: _pt.any,
141
+ renderError: _pt.func,
142
+ isRequired: _pt.bool,
143
+ touched: _pt.bool,
144
+ autoComplete: _pt.string,
145
+ name: _pt.string,
146
+ value: _pt.objectOf(_pt.string).isRequired,
147
+ onChange: _pt.func,
148
+ selectedLanguage: _pt.string.isRequired,
149
+ onBlur: _pt.func,
150
+ onFocus: _pt.func,
151
+ hideLanguageExpansionControls: _pt.bool,
152
+ defaultExpandLanguages: _pt.bool,
153
+ isAutofocussed: _pt.bool,
154
+ isDisabled: _pt.bool,
155
+ isReadOnly: _pt.bool,
156
+ placeholder: _pt.objectOf(_pt.string),
157
+ errorsByLanguage: _pt.objectOf(_pt.string),
158
+ title: _pt.node.isRequired,
159
+ hint: _pt.node,
160
+ description: _pt.node,
161
+ onInfoButtonClick: _pt.func,
162
+ hintIcon: _pt.element
301
163
  } : {};
302
164
  var LocalizedTextField$1 = LocalizedTextField;
303
165
 
304
166
  // NOTE: This string will be replaced on build time with the package version.
305
- var version = "12.2.7";
167
+ var version = "13.0.2";
306
168
 
307
169
  export { LocalizedTextField$1 as default, version };
@@ -0,0 +1,2 @@
1
+ export { default } from './localized-text-field';
2
+ export { default as version } from './version';
@@ -0,0 +1,45 @@
1
+ import { Component, type ChangeEventHandler, type FocusEventHandler, type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode } from 'react';
2
+ import { type TFieldErrors } from '@commercetools-uikit/field-errors';
3
+ declare type TEvent = MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>;
4
+ declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
5
+ declare type TLocalizedTextFieldProps = {
6
+ id?: string;
7
+ horizontalConstraint?: 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
8
+ errors?: TFieldErrors;
9
+ renderError?: TErrorRenderer;
10
+ isRequired?: boolean;
11
+ touched?: boolean;
12
+ autoComplete?: string;
13
+ name?: string;
14
+ value: Record<string, string>;
15
+ onChange?: ChangeEventHandler;
16
+ selectedLanguage: string;
17
+ onBlur?: FocusEventHandler;
18
+ onFocus?: FocusEventHandler;
19
+ hideLanguageExpansionControls?: boolean;
20
+ defaultExpandLanguages?: boolean;
21
+ isAutofocussed?: boolean;
22
+ isDisabled?: boolean;
23
+ isReadOnly?: boolean;
24
+ placeholder?: Record<string, string>;
25
+ errorsByLanguage?: Record<string, string>;
26
+ title: ReactNode;
27
+ hint?: ReactNode;
28
+ description?: ReactNode;
29
+ onInfoButtonClick?: (event: TEvent) => void;
30
+ hintIcon?: ReactElement;
31
+ badge?: ReactNode;
32
+ };
33
+ declare type TLocalizedTextFieldSTate = Pick<TLocalizedTextFieldProps, 'id'>;
34
+ declare class LocalizedTextField extends Component<TLocalizedTextFieldProps, TLocalizedTextFieldSTate> {
35
+ static displayName: string;
36
+ static defaultProps: Pick<TLocalizedTextFieldProps, 'horizontalConstraint'>;
37
+ state: {
38
+ id: string | undefined;
39
+ };
40
+ static getDerivedStateFromProps: (props: TLocalizedTextFieldProps, state: TLocalizedTextFieldSTate) => {
41
+ id: string;
42
+ };
43
+ render(): import("@emotion/react/jsx-runtime").JSX.Element;
44
+ }
45
+ export default LocalizedTextField;
@@ -0,0 +1,2 @@
1
+ declare const _default: "__@UI_KIT_PACKAGE/VERSION_OF_RELEASE__";
2
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/localized-text-field",
3
3
  "description": "A controlled text input component for localized single-line strings with validation states.",
4
- "version": "12.2.7",
4
+ "version": "13.0.2",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,19 +19,19 @@
19
19
  "module": "dist/commercetools-uikit-localized-text-field.esm.js",
20
20
  "files": ["dist"],
21
21
  "dependencies": {
22
- "@babel/runtime": "7.16.3",
23
- "@babel/runtime-corejs3": "7.16.3",
24
- "@commercetools-uikit/constraints": "12.2.5",
25
- "@commercetools-uikit/design-system": "12.2.5",
26
- "@commercetools-uikit/field-errors": "12.2.5",
27
- "@commercetools-uikit/field-label": "12.2.7",
28
- "@commercetools-uikit/localized-text-input": "12.2.7",
29
- "@commercetools-uikit/spacings": "12.2.5",
30
- "@commercetools-uikit/utils": "12.2.5",
22
+ "@babel/runtime": "7.17.2",
23
+ "@babel/runtime-corejs3": "7.17.2",
24
+ "@commercetools-uikit/constraints": "13.0.2",
25
+ "@commercetools-uikit/design-system": "13.0.0",
26
+ "@commercetools-uikit/field-errors": "13.0.2",
27
+ "@commercetools-uikit/field-label": "13.0.2",
28
+ "@commercetools-uikit/localized-text-input": "13.0.2",
29
+ "@commercetools-uikit/spacings": "13.0.2",
30
+ "@commercetools-uikit/utils": "13.0.2",
31
31
  "@emotion/react": "^11.4.0",
32
32
  "@emotion/styled": "^11.3.0",
33
33
  "common-tags": "1.8.2",
34
- "prop-types": "15.7.2",
34
+ "prop-types": "15.8.1",
35
35
  "react-required-if": "1.0.3"
36
36
  },
37
37
  "devDependencies": {