@hitachivantara/uikit-react-core 5.96.1 → 5.96.3

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,24 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const isNumeric = (num) => (
4
- // to prevent Number( <spaces> ) = 0
5
- num.trim().length > 0 && !Number.isNaN(Number(num))
6
- );
7
- const isEmail = (email) => {
8
- const regexp = /^[^\\s]+[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?[.])+[a-z0-9](?:[a-z0-9-]*[a-z0-9])$/i;
9
- return regexp.test(email);
3
+ const isTypeValidationIgnored = (type) => {
4
+ return type === "text" || type === "password";
10
5
  };
11
- const computeValidationType = (type) => {
12
- switch (type) {
13
- case "number":
14
- return "number";
15
- case "email":
16
- return "email";
17
- default:
18
- return "none";
19
- }
20
- };
21
- const hasBuiltInValidations = (required, validationType, minCharQuantity, maxCharQuantity, validation, inputProps) => required || validationType !== "none" || minCharQuantity != null || maxCharQuantity != null || validation != null || inputProps?.required != null || inputProps?.minLength != null || inputProps?.maxLength != null || inputProps?.min != null || inputProps?.max != null || inputProps?.type != null && inputProps?.type !== "text" && inputProps?.type !== "password" || inputProps?.pattern != null;
6
+ const hasBuiltInValidations = (required, inputType, minCharQuantity, maxCharQuantity, validation, inputProps) => required || !isTypeValidationIgnored(inputType) || minCharQuantity != null || maxCharQuantity != null || validation != null || inputProps?.required != null || inputProps?.minLength != null || inputProps?.maxLength != null || inputProps?.min != null || inputProps?.max != null || inputProps?.type && !isTypeValidationIgnored(inputProps.type) || inputProps?.pattern != null;
22
7
  const computeValidationState = (inputValidity, isEmptyValue) => {
23
8
  if (inputValidity.valid && isEmptyValue) {
24
9
  return "standBy";
@@ -43,19 +28,10 @@ const computeValidationMessage = (inputValidity, errorMessages) => {
43
28
  }
44
29
  return errorMessages.error;
45
30
  };
46
- const validateInput = (input, required, minCharQuantity, maxCharQuantity, validationType, validation) => {
31
+ const validateInput = (input, required, minCharQuantity, maxCharQuantity, validation) => {
47
32
  const inputValidity = {
48
- valid: input?.validity?.valid ?? true,
49
- badInput: input?.validity?.badInput,
50
- customError: input?.validity?.customError,
51
- patternMismatch: input?.validity?.patternMismatch,
52
- rangeOverflow: input?.validity?.rangeOverflow,
53
- rangeUnderflow: input?.validity?.rangeUnderflow,
54
- stepMismatch: input?.validity?.stepMismatch,
55
- tooLong: input?.validity?.tooLong,
56
- tooShort: input?.validity?.tooShort,
57
- typeMismatch: input?.validity?.typeMismatch,
58
- valueMissing: input?.validity?.valueMissing
33
+ ...input?.validity,
34
+ valid: input?.validity?.valid ?? true
59
35
  };
60
36
  const value = input?.value;
61
37
  if (!value) {
@@ -72,20 +48,6 @@ const validateInput = (input, required, minCharQuantity, maxCharQuantity, valida
72
48
  inputValidity.tooLong = true;
73
49
  inputValidity.valid = false;
74
50
  }
75
- switch (validationType) {
76
- case "number":
77
- if (!isNumeric(value)) {
78
- inputValidity.typeMismatch = true;
79
- inputValidity.valid = false;
80
- }
81
- break;
82
- case "email":
83
- if (!isEmail(value)) {
84
- inputValidity.typeMismatch = true;
85
- inputValidity.valid = false;
86
- }
87
- break;
88
- }
89
51
  if (validation != null && !validation(value)) {
90
52
  inputValidity.customError = true;
91
53
  inputValidity.valid = false;
@@ -94,15 +56,19 @@ const validateInput = (input, required, minCharQuantity, maxCharQuantity, valida
94
56
  return inputValidity;
95
57
  };
96
58
  const DEFAULT_ERROR_MESSAGES = {
59
+ /** The value when a validation fails. */
97
60
  error: "Invalid value",
98
- requiredError: "The value is required",
99
- minCharError: "The value is too short",
61
+ /** The message that appears when there are too many characters. */
100
62
  maxCharError: "The value is too long",
63
+ /** The message that appears when there are too few characters. */
64
+ minCharError: "The value is too short",
65
+ /** The message that appears when the input is empty and required. */
66
+ requiredError: "The value is required",
67
+ /** The message that appears when the input is value is incompatible with the expected type. */
101
68
  typeMismatchError: "Invalid value"
102
69
  };
103
70
  exports.DEFAULT_ERROR_MESSAGES = DEFAULT_ERROR_MESSAGES;
104
71
  exports.computeValidationMessage = computeValidationMessage;
105
72
  exports.computeValidationState = computeValidationState;
106
- exports.computeValidationType = computeValidationType;
107
73
  exports.hasBuiltInValidations = hasBuiltInValidations;
108
74
  exports.validateInput = validateInput;
@@ -115,19 +115,17 @@ const HvInput = generic.fixedForwardRef(function HvInput2(props, ref) {
115
115
  validationMessages?.typeMismatchError
116
116
  ]
117
117
  );
118
- const validationType = React.useMemo(() => validations.computeValidationType(type), [type]);
119
118
  const performValidation = React.useCallback(() => {
120
119
  const inputValidity = validations.validateInput(
121
120
  inputRef.current,
122
121
  required,
123
122
  minCharQuantity,
124
123
  maxCharQuantity,
125
- validationType,
126
124
  validation
127
125
  );
128
126
  setValidationState(validations.computeValidationState(inputValidity, isEmptyValue));
129
127
  setValidationMessage(
130
- validations.computeValidationMessage(inputValidity, errorMessages)
128
+ validations.computeValidationMessage(inputValidity, errorMessages) || ""
131
129
  );
132
130
  return inputValidity;
133
131
  }, [
@@ -138,12 +136,11 @@ const HvInput = generic.fixedForwardRef(function HvInput2(props, ref) {
138
136
  required,
139
137
  setValidationMessage,
140
138
  setValidationState,
141
- validation,
142
- validationType
139
+ validation
143
140
  ]);
144
141
  const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && validations.hasBuiltInValidations(
145
142
  required,
146
- validationType,
143
+ type,
147
144
  minCharQuantity,
148
145
  maxCharQuantity,
149
146
  validation,
@@ -157,12 +154,7 @@ const HvInput = generic.fixedForwardRef(function HvInput2(props, ref) {
157
154
  if (type === "password") {
158
155
  return revealPassword ? "text" : "password";
159
156
  }
160
- if (type === "search") {
161
- return "search";
162
- }
163
- if (type === "number") {
164
- return "number";
165
- }
157
+ if (["search", "number", "email"].includes(type)) return type;
166
158
  return "text";
167
159
  }, [revealPassword, type]);
168
160
  const [suggestionValues, setSuggestionValues] = React.useState(null);
@@ -93,7 +93,7 @@ const HvTagsInput = React.forwardRef(
93
93
  (currValue) => {
94
94
  if (maxTagsQuantity !== null && maxTagsQuantity !== void 0 && currValue.length > maxTagsQuantity) {
95
95
  setValidationState("invalid");
96
- setValidationMessage(errorMessages.maxCharError);
96
+ setValidationMessage(errorMessages.maxCharError || "");
97
97
  setStateValid(false);
98
98
  } else {
99
99
  setValidationState("valid");
@@ -83,10 +83,13 @@ const { staticClasses, useClasses } = uikitReactUtils.createClasses("HvTagsInput
83
83
  border: "none",
84
84
  margin: 0,
85
85
  padding: 0,
86
- ...uikitStyles.theme.typography.caption1,
86
+ ...uikitStyles.theme.typography.body,
87
87
  backgroundColor: "transparent",
88
88
  outline: "none",
89
- boxShadow: "none"
89
+ boxShadow: "none",
90
+ "&::placeholder": {
91
+ color: uikitStyles.theme.colors.textSubtle
92
+ }
90
93
  },
91
94
  /** @deprecated unused. use `:focus` or `:focus-visible` instead */
92
95
  tagSelected: {},
@@ -88,12 +88,11 @@ const HvTextArea = React.forwardRef(function HvTextArea2(props, ref) {
88
88
  required,
89
89
  minCharQuantity,
90
90
  maxCharQuantity,
91
- "none",
92
91
  validation
93
92
  );
94
93
  setValidationState(validations.computeValidationState(inputValidity, isEmptyValue));
95
94
  setValidationMessage(
96
- validations.computeValidationMessage(inputValidity, errorMessages)
95
+ validations.computeValidationMessage(inputValidity, errorMessages) || ""
97
96
  );
98
97
  return inputValidity;
99
98
  }, [
@@ -164,7 +163,7 @@ const HvTextArea = React.forwardRef(function HvTextArea2(props, ref) {
164
163
  }, [focused, isEmptyValue, performValidation]);
165
164
  const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && validations.hasBuiltInValidations(
166
165
  required,
167
- "none",
166
+ "text",
168
167
  minCharQuantity,
169
168
  // If blockMax is true maxCharQuantity will never produce an error
170
169
  // unless the value is controlled, so we can't prevent it to overflow maxCharQuantity
@@ -194,10 +194,22 @@ const pentahoPlus = uikitStyles.mergeTheme(uikitStyles.pentahoPlus, {
194
194
  classes: {
195
195
  tagsList: {
196
196
  backgroundColor: inputColors.bg,
197
- padding: uikitStyles.theme.space.xxs
197
+ padding: uikitStyles.theme.space.xxs,
198
+ borderColor: uikitStyles.theme.colors.textDimmed
198
199
  },
199
200
  singleLine: {
200
201
  height: 32
202
+ },
203
+ disabled: {
204
+ "& .HvTagsInput-tagsList": {
205
+ backgroundColor: uikitStyles.theme.colors.bgDisabled,
206
+ "&,:hover": {
207
+ borderColor: uikitStyles.theme.colors.textDisabled
208
+ }
209
+ },
210
+ "& .HvTagsInput-chipRoot": {
211
+ outlineColor: uikitStyles.theme.colors.textDisabled
212
+ }
201
213
  }
202
214
  }
203
215
  },
@@ -1,22 +1,7 @@
1
- const isNumeric = (num) => (
2
- // to prevent Number( <spaces> ) = 0
3
- num.trim().length > 0 && !Number.isNaN(Number(num))
4
- );
5
- const isEmail = (email) => {
6
- const regexp = /^[^\\s]+[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?[.])+[a-z0-9](?:[a-z0-9-]*[a-z0-9])$/i;
7
- return regexp.test(email);
1
+ const isTypeValidationIgnored = (type) => {
2
+ return type === "text" || type === "password";
8
3
  };
9
- const computeValidationType = (type) => {
10
- switch (type) {
11
- case "number":
12
- return "number";
13
- case "email":
14
- return "email";
15
- default:
16
- return "none";
17
- }
18
- };
19
- const hasBuiltInValidations = (required, validationType, minCharQuantity, maxCharQuantity, validation, inputProps) => required || validationType !== "none" || minCharQuantity != null || maxCharQuantity != null || validation != null || inputProps?.required != null || inputProps?.minLength != null || inputProps?.maxLength != null || inputProps?.min != null || inputProps?.max != null || inputProps?.type != null && inputProps?.type !== "text" && inputProps?.type !== "password" || inputProps?.pattern != null;
4
+ const hasBuiltInValidations = (required, inputType, minCharQuantity, maxCharQuantity, validation, inputProps) => required || !isTypeValidationIgnored(inputType) || minCharQuantity != null || maxCharQuantity != null || validation != null || inputProps?.required != null || inputProps?.minLength != null || inputProps?.maxLength != null || inputProps?.min != null || inputProps?.max != null || inputProps?.type && !isTypeValidationIgnored(inputProps.type) || inputProps?.pattern != null;
20
5
  const computeValidationState = (inputValidity, isEmptyValue) => {
21
6
  if (inputValidity.valid && isEmptyValue) {
22
7
  return "standBy";
@@ -41,19 +26,10 @@ const computeValidationMessage = (inputValidity, errorMessages) => {
41
26
  }
42
27
  return errorMessages.error;
43
28
  };
44
- const validateInput = (input, required, minCharQuantity, maxCharQuantity, validationType, validation) => {
29
+ const validateInput = (input, required, minCharQuantity, maxCharQuantity, validation) => {
45
30
  const inputValidity = {
46
- valid: input?.validity?.valid ?? true,
47
- badInput: input?.validity?.badInput,
48
- customError: input?.validity?.customError,
49
- patternMismatch: input?.validity?.patternMismatch,
50
- rangeOverflow: input?.validity?.rangeOverflow,
51
- rangeUnderflow: input?.validity?.rangeUnderflow,
52
- stepMismatch: input?.validity?.stepMismatch,
53
- tooLong: input?.validity?.tooLong,
54
- tooShort: input?.validity?.tooShort,
55
- typeMismatch: input?.validity?.typeMismatch,
56
- valueMissing: input?.validity?.valueMissing
31
+ ...input?.validity,
32
+ valid: input?.validity?.valid ?? true
57
33
  };
58
34
  const value = input?.value;
59
35
  if (!value) {
@@ -70,20 +46,6 @@ const validateInput = (input, required, minCharQuantity, maxCharQuantity, valida
70
46
  inputValidity.tooLong = true;
71
47
  inputValidity.valid = false;
72
48
  }
73
- switch (validationType) {
74
- case "number":
75
- if (!isNumeric(value)) {
76
- inputValidity.typeMismatch = true;
77
- inputValidity.valid = false;
78
- }
79
- break;
80
- case "email":
81
- if (!isEmail(value)) {
82
- inputValidity.typeMismatch = true;
83
- inputValidity.valid = false;
84
- }
85
- break;
86
- }
87
49
  if (validation != null && !validation(value)) {
88
50
  inputValidity.customError = true;
89
51
  inputValidity.valid = false;
@@ -92,17 +54,21 @@ const validateInput = (input, required, minCharQuantity, maxCharQuantity, valida
92
54
  return inputValidity;
93
55
  };
94
56
  const DEFAULT_ERROR_MESSAGES = {
57
+ /** The value when a validation fails. */
95
58
  error: "Invalid value",
96
- requiredError: "The value is required",
97
- minCharError: "The value is too short",
59
+ /** The message that appears when there are too many characters. */
98
60
  maxCharError: "The value is too long",
61
+ /** The message that appears when there are too few characters. */
62
+ minCharError: "The value is too short",
63
+ /** The message that appears when the input is empty and required. */
64
+ requiredError: "The value is required",
65
+ /** The message that appears when the input is value is incompatible with the expected type. */
99
66
  typeMismatchError: "Invalid value"
100
67
  };
101
68
  export {
102
69
  DEFAULT_ERROR_MESSAGES,
103
70
  computeValidationMessage,
104
71
  computeValidationState,
105
- computeValidationType,
106
72
  hasBuiltInValidations,
107
73
  validateInput
108
74
  };
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useRef, useState, useMemo, useCallback, useEffect } from "react";
3
3
  import { useForkRef } from "@mui/material/utils";
4
4
  import { useDefaultProps, useTheme } from "@hitachivantara/uikit-react-utils";
5
- import { DEFAULT_ERROR_MESSAGES, computeValidationType, validateInput, computeValidationState, computeValidationMessage, hasBuiltInValidations } from "../BaseInput/validations.js";
5
+ import { DEFAULT_ERROR_MESSAGES, validateInput, computeValidationState, computeValidationMessage, hasBuiltInValidations } from "../BaseInput/validations.js";
6
6
  import { HvLabelContainer } from "../FormElement/LabelContainer.js";
7
7
  import { HvSuggestions } from "../FormElement/Suggestions/Suggestions.js";
8
8
  import { useControlled } from "../hooks/useControlled.js";
@@ -114,19 +114,17 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
114
114
  validationMessages?.typeMismatchError
115
115
  ]
116
116
  );
117
- const validationType = useMemo(() => computeValidationType(type), [type]);
118
117
  const performValidation = useCallback(() => {
119
118
  const inputValidity = validateInput(
120
119
  inputRef.current,
121
120
  required,
122
121
  minCharQuantity,
123
122
  maxCharQuantity,
124
- validationType,
125
123
  validation
126
124
  );
127
125
  setValidationState(computeValidationState(inputValidity, isEmptyValue));
128
126
  setValidationMessage(
129
- computeValidationMessage(inputValidity, errorMessages)
127
+ computeValidationMessage(inputValidity, errorMessages) || ""
130
128
  );
131
129
  return inputValidity;
132
130
  }, [
@@ -137,12 +135,11 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
137
135
  required,
138
136
  setValidationMessage,
139
137
  setValidationState,
140
- validation,
141
- validationType
138
+ validation
142
139
  ]);
143
140
  const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && hasBuiltInValidations(
144
141
  required,
145
- validationType,
142
+ type,
146
143
  minCharQuantity,
147
144
  maxCharQuantity,
148
145
  validation,
@@ -156,12 +153,7 @@ const HvInput = fixedForwardRef(function HvInput2(props, ref) {
156
153
  if (type === "password") {
157
154
  return revealPassword ? "text" : "password";
158
155
  }
159
- if (type === "search") {
160
- return "search";
161
- }
162
- if (type === "number") {
163
- return "number";
164
- }
156
+ if (["search", "number", "email"].includes(type)) return type;
165
157
  return "text";
166
158
  }, [revealPassword, type]);
167
159
  const [suggestionValues, setSuggestionValues] = useState(null);
@@ -92,7 +92,7 @@ const HvTagsInput = forwardRef(
92
92
  (currValue) => {
93
93
  if (maxTagsQuantity !== null && maxTagsQuantity !== void 0 && currValue.length > maxTagsQuantity) {
94
94
  setValidationState("invalid");
95
- setValidationMessage(errorMessages.maxCharError);
95
+ setValidationMessage(errorMessages.maxCharError || "");
96
96
  setStateValid(false);
97
97
  } else {
98
98
  setValidationState("valid");
@@ -81,10 +81,13 @@ const { staticClasses, useClasses } = createClasses("HvTagsInput", {
81
81
  border: "none",
82
82
  margin: 0,
83
83
  padding: 0,
84
- ...theme.typography.caption1,
84
+ ...theme.typography.body,
85
85
  backgroundColor: "transparent",
86
86
  outline: "none",
87
- boxShadow: "none"
87
+ boxShadow: "none",
88
+ "&::placeholder": {
89
+ color: theme.colors.textSubtle
90
+ }
88
91
  },
89
92
  /** @deprecated unused. use `:focus` or `:focus-visible` instead */
90
93
  tagSelected: {},
@@ -87,12 +87,11 @@ const HvTextArea = forwardRef(function HvTextArea2(props, ref) {
87
87
  required,
88
88
  minCharQuantity,
89
89
  maxCharQuantity,
90
- "none",
91
90
  validation
92
91
  );
93
92
  setValidationState(computeValidationState(inputValidity, isEmptyValue));
94
93
  setValidationMessage(
95
- computeValidationMessage(inputValidity, errorMessages)
94
+ computeValidationMessage(inputValidity, errorMessages) || ""
96
95
  );
97
96
  return inputValidity;
98
97
  }, [
@@ -163,7 +162,7 @@ const HvTextArea = forwardRef(function HvTextArea2(props, ref) {
163
162
  }, [focused, isEmptyValue, performValidation]);
164
163
  const canShowError = ariaErrorMessage == null && (status !== void 0 && statusMessage !== void 0 || status === void 0 && hasBuiltInValidations(
165
164
  required,
166
- "none",
165
+ "text",
167
166
  minCharQuantity,
168
167
  // If blockMax is true maxCharQuantity will never produce an error
169
168
  // unless the value is controlled, so we can't prevent it to overflow maxCharQuantity
@@ -192,10 +192,22 @@ const pentahoPlus = mergeTheme(pentahoPlus$1, {
192
192
  classes: {
193
193
  tagsList: {
194
194
  backgroundColor: inputColors.bg,
195
- padding: theme.space.xxs
195
+ padding: theme.space.xxs,
196
+ borderColor: theme.colors.textDimmed
196
197
  },
197
198
  singleLine: {
198
199
  height: 32
200
+ },
201
+ disabled: {
202
+ "& .HvTagsInput-tagsList": {
203
+ backgroundColor: theme.colors.bgDisabled,
204
+ "&,:hover": {
205
+ borderColor: theme.colors.textDisabled
206
+ }
207
+ },
208
+ "& .HvTagsInput-chipRoot": {
209
+ outlineColor: theme.colors.textDisabled
210
+ }
199
211
  }
200
212
  }
201
213
  },
@@ -625,6 +625,19 @@ export declare type DeepPartial<T> = T extends {} ? Partial<{
625
625
  [P in keyof T]: DeepPartial<T[P]>;
626
626
  }> : T;
627
627
 
628
+ declare const DEFAULT_ERROR_MESSAGES: {
629
+ /** The value when a validation fails. */
630
+ error: string;
631
+ /** The message that appears when there are too many characters. */
632
+ maxCharError: string;
633
+ /** The message that appears when there are too few characters. */
634
+ minCharError: string;
635
+ /** The message that appears when the input is empty and required. */
636
+ requiredError: string;
637
+ /** The message that appears when the input is value is incompatible with the expected type. */
638
+ typeMismatchError: string;
639
+ };
640
+
628
641
  declare const DEFAULT_LABELS: {
629
642
  dropdownMenu: string;
630
643
  };
@@ -7174,18 +7187,7 @@ export declare interface HvUseTableProps extends Omit<TableProps, "role">, UseHv
7174
7187
  export declare interface HvUseTableRowProps extends Omit<TableRowProps, "role">, UseHvTableStylesTableRowProps, UseHvRowSelectionTableRowProps, UseHvRowExpandTableRowProps, HvTableRowProps {
7175
7188
  }
7176
7189
 
7177
- export declare interface HvValidationMessages {
7178
- /** The value when a validation fails. */
7179
- error?: string;
7180
- /** The message that appears when there are too many characters. */
7181
- maxCharError?: string;
7182
- /** The message that appears when there are too few characters. */
7183
- minCharError?: string;
7184
- /** The message that appears when the input is empty and required. */
7185
- requiredError?: string;
7186
- /** The message that appears when the input is value is incompatible with the expected type. */
7187
- typeMismatchError?: string;
7188
- }
7190
+ export declare type HvValidationMessages = Partial<typeof DEFAULT_ERROR_MESSAGES>;
7189
7191
 
7190
7192
  /**
7191
7193
  * Use a vertical layout for global navigation on wide screens. treeview mode provides structured hierarchy but overrides standard keyboard navigation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hitachivantara/uikit-react-core",
3
- "version": "5.96.1",
3
+ "version": "5.96.3",
4
4
  "private": false,
5
5
  "author": "Hitachi Vantara UI Kit Team",
6
6
  "description": "Core React components for the NEXT Design System.",
@@ -61,7 +61,7 @@
61
61
  "access": "public",
62
62
  "directory": "package"
63
63
  },
64
- "gitHead": "866c81403b508ea7748f7bbedeeca80144ceb8fa",
64
+ "gitHead": "e8e37e375a8b3101ac3d223d1a08ca06b53b43de",
65
65
  "exports": {
66
66
  ".": {
67
67
  "types": "./dist/types/index.d.ts",