@commercetools-uikit/number-field 19.9.0 → 19.11.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.
@@ -241,7 +241,7 @@ NumberField.propTypes = process.env.NODE_ENV !== "production" ? {
241
241
  var NumberField$1 = NumberField;
242
242
 
243
243
  // NOTE: This string will be replaced on build time with the package version.
244
- var version = "19.9.0";
244
+ var version = "19.11.0";
245
245
 
246
246
  exports["default"] = NumberField$1;
247
247
  exports.version = version;
@@ -210,7 +210,7 @@ NumberField.propTypes = {};
210
210
  var NumberField$1 = NumberField;
211
211
 
212
212
  // NOTE: This string will be replaced on build time with the package version.
213
- var version = "19.9.0";
213
+ var version = "19.11.0";
214
214
 
215
215
  exports["default"] = NumberField$1;
216
216
  exports.version = version;
@@ -216,6 +216,6 @@ NumberField.propTypes = process.env.NODE_ENV !== "production" ? {
216
216
  var NumberField$1 = NumberField;
217
217
 
218
218
  // NOTE: This string will be replaced on build time with the package version.
219
- var version = "19.9.0";
219
+ var version = "19.11.0";
220
220
 
221
221
  export { NumberField$1 as default, version };
@@ -6,32 +6,127 @@ type TCustomFormErrors<Values> = {
6
6
  [K in keyof Values]?: TFieldErrors;
7
7
  };
8
8
  export type TNumberFieldProps = {
9
+ /**
10
+ * Used as HTML id property. An id is auto-generated when it is not specified.
11
+ */
9
12
  id?: string;
13
+ /**
14
+ * Horizontal size limit of the input fields.
15
+ */
10
16
  horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
17
+ /**
18
+ * A map of errors. Error messages for known errors are rendered automatically.
19
+ * <br />
20
+ * Unknown errors will be forwarded to `renderError`
21
+ */
11
22
  errors?: TFieldErrors;
23
+ /**
24
+ * A map of warnings. Warning messages for known warnings are rendered automatically.
25
+ * <br/>
26
+ * Unknown warnings will be forwarded to renderWarning.
27
+ */
12
28
  warnings?: TFieldWarnings;
29
+ /**
30
+ * 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.
31
+ */
13
32
  renderError?: TErrorRenderer;
33
+ /**
34
+ * Called with custom warnings, as renderWarning(key, warning). This function can return a message which will be wrapped in a WarningMessage.
35
+ * <br />
36
+ * It can also return null to show no warning.
37
+ */
14
38
  renderWarning?: (key: string, warning?: boolean) => ReactNode;
39
+ /**
40
+ * Indicates if the value is required. Shows an the "required asterisk" if so.
41
+ */
15
42
  isRequired?: boolean;
43
+ /**
44
+ * Indicates whether the field was touched. Errors will only be shown when the field was touched.
45
+ */
16
46
  touched?: boolean;
47
+ /**
48
+ * Used as HTML name of the input component. property
49
+ */
17
50
  name?: string;
51
+ /**
52
+ * Value of the input component.
53
+ */
18
54
  value: string | number;
55
+ /**
56
+ * Used as HTML `autocomplete` of the input component. property
57
+ */
19
58
  autoComplete?: string;
59
+ /**
60
+ * Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
61
+ */
20
62
  onChange?: ChangeEventHandler<HTMLInputElement>;
63
+ /**
64
+ * Called when input is blurred
65
+ */
21
66
  onBlur?: FocusEventHandler<HTMLInputElement>;
67
+ /**
68
+ * Called when input is focused
69
+ */
22
70
  onFocus?: FocusEventHandler<HTMLInputElement>;
71
+ /**
72
+ * Focus the input on initial render
73
+ */
23
74
  isAutofocussed?: boolean;
75
+ /**
76
+ * Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
77
+ */
24
78
  isDisabled?: boolean;
79
+ /**
80
+ * Indicates that the field is displaying read-only content
81
+ */
25
82
  isReadOnly?: boolean;
83
+ /**
84
+ * Placeholder text for the input
85
+ */
26
86
  placeholder?: string;
87
+ /**
88
+ * Value is used as `min` property on input field
89
+ */
27
90
  min?: number;
91
+ /**
92
+ * Value is used as `max` property on input field
93
+ */
28
94
  max?: number;
95
+ /**
96
+ * Value is used as `step` property on input field.
97
+ * <br />
98
+ * Use the value `any` for inputs which accept an unpredictable amount of decimals.
99
+ */
29
100
  step?: number | 'any';
101
+ /**
102
+ * Title of the label
103
+ */
30
104
  title: string | ReactNode;
105
+ /**
106
+ * 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`.
107
+ */
31
108
  hint?: string | ReactNode;
109
+ /**
110
+ * Provides a description for the title.
111
+ */
32
112
  description?: string | ReactNode;
113
+ /**
114
+ * Function called when info button is pressed.
115
+ * <br />
116
+ * Info button will only be visible when this prop is passed.
117
+ */
33
118
  onInfoButtonClick?: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
119
+ /**
120
+ * Icon to be displayed beside the hint text.
121
+ * <br />
122
+ * Will only get rendered when `hint` is passed as well.
123
+ */
34
124
  hintIcon?: ReactElement;
125
+ /**
126
+ * Badge to be displayed beside the label.
127
+ * <br />
128
+ * Might be used to display additional information about the content of the field (E.g verified email)
129
+ */
35
130
  badge?: ReactNode;
36
131
  };
37
132
  type TNumberFieldState = Pick<TNumberFieldProps, 'id'>;
@@ -44,6 +139,11 @@ declare class NumberField extends Component<TNumberFieldProps, TNumberFieldState
44
139
  static getDerivedStateFromProps: (props: TNumberFieldProps, state: TNumberFieldState) => {
45
140
  id: string;
46
141
  };
142
+ /**
143
+ * Use this function to convert the Formik `errors` object type to
144
+ * our custom field errors type.
145
+ * This is primarly useful when using TypeScript.
146
+ */
47
147
  static toFieldErrors<FormValues>(errors: unknown): TCustomFormErrors<FormValues>;
48
148
  renderError(key?: string): ReactNode | null;
49
149
  render(): import("@emotion/react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/number-field",
3
3
  "description": "A controlled input component for numbers with validation states and a label.",
4
- "version": "19.9.0",
4
+ "version": "19.11.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,14 +21,14 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/constraints": "19.9.0",
25
- "@commercetools-uikit/design-system": "19.9.0",
26
- "@commercetools-uikit/field-errors": "19.9.0",
27
- "@commercetools-uikit/field-label": "19.9.0",
28
- "@commercetools-uikit/field-warnings": "19.9.0",
29
- "@commercetools-uikit/number-input": "19.9.0",
30
- "@commercetools-uikit/spacings-stack": "19.9.0",
31
- "@commercetools-uikit/utils": "19.9.0",
24
+ "@commercetools-uikit/constraints": "19.11.0",
25
+ "@commercetools-uikit/design-system": "19.11.0",
26
+ "@commercetools-uikit/field-errors": "19.11.0",
27
+ "@commercetools-uikit/field-label": "19.11.0",
28
+ "@commercetools-uikit/field-warnings": "19.11.0",
29
+ "@commercetools-uikit/number-input": "19.11.0",
30
+ "@commercetools-uikit/spacings-stack": "19.11.0",
31
+ "@commercetools-uikit/utils": "19.11.0",
32
32
  "@emotion/react": "^11.10.5",
33
33
  "@emotion/styled": "^11.10.5",
34
34
  "prop-types": "15.8.1",