@trackunit/react-form-components 0.0.104-alpha-895cee4b43.0 → 0.0.104
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/index.cjs.js +8 -12
- package/index.esm.js +9 -13
- package/package.json +5 -5
package/index.cjs.js
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
|
|
7
|
+
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
7
8
|
var reactComponents = require('@trackunit/react-components');
|
|
8
9
|
var tailwindStyledComponents = require('@trackunit/tailwind-styled-components');
|
|
9
10
|
var React = require('react');
|
|
10
11
|
var reactDom = require('react-dom');
|
|
11
|
-
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
14
|
|
|
@@ -107,15 +107,9 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled }) => {
|
|
|
107
107
|
return window.open(`tel:${value}`);
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
-
return (jsxRuntime.jsx(
|
|
110
|
+
return (jsxRuntime.jsx("div", { className: "flex p-1", children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton(), disabled: disabled, dataTestId: dataTestId || "testIconButtonId", size: "small", color: "tertiary", icon: jsxRuntime.jsx(reactComponents.Icon, { size: "small", name: getIconName() }), onClick: ButtonAction }) }));
|
|
111
111
|
};
|
|
112
|
-
const
|
|
113
|
-
tu-action-container
|
|
114
|
-
`;
|
|
115
|
-
const StyledIconButton = tailwindStyledComponents.twx(reactComponents.IconButton) `
|
|
116
|
-
tu-action-button
|
|
117
|
-
${({ $fieldSize }) => $fieldSize === "small" && tailwindStyledComponents.tws `tu-action-button--small`}
|
|
118
|
-
`;
|
|
112
|
+
const cvaActionButton = cssClassVarianceUtilities.cvaMerge(["drop-shadow-none", "rounded-md"]);
|
|
119
113
|
|
|
120
114
|
/******************************************************************************
|
|
121
115
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2849,14 +2843,16 @@ const EmailInput = React__namespace.forwardRef((_a, ref) => {
|
|
|
2849
2843
|
*/
|
|
2850
2844
|
const EmailField = React.forwardRef((_a, ref) => {
|
|
2851
2845
|
var { label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId"]);
|
|
2852
|
-
const [value, setValue] = React.useState(defaultValue);
|
|
2846
|
+
const [value, setValue] = React.useState(defaultValue || "");
|
|
2853
2847
|
const htmlForId = id ? id : "emailField-" + v4();
|
|
2854
2848
|
// Type guard to check if value is a string
|
|
2855
2849
|
function isString(inputValue) {
|
|
2856
2850
|
return typeof inputValue === "string";
|
|
2857
2851
|
}
|
|
2858
|
-
//
|
|
2859
|
-
|
|
2852
|
+
// Doing the same check as we do on the backend
|
|
2853
|
+
// Using OWASP pattern from: https://owasp.org/www-community/OWASP_Validation_Regex_Repository
|
|
2854
|
+
const emailValidationPattern = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
2855
|
+
const renderAsInvalid = !!errorMessage || (isString(value) && emailValidationPattern.test(value));
|
|
2860
2856
|
return (jsxRuntime.jsx(FormGroup, { htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup`, children: jsxRuntime.jsx(EmailInput, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", ref: ref, value: value, onChange: e => setValue(e.target.value), isInvalid: renderAsInvalid, disabled: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
2861
2857
|
});
|
|
2862
2858
|
|
package/index.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as jsx$1, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations } from '@trackunit/i18n-library-translation';
|
|
3
|
+
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
3
4
|
import { IconButton, Icon, Tip, Heading, Text, MenuItem, Tag, Spinner } from '@trackunit/react-components';
|
|
4
|
-
import { tw, twx
|
|
5
|
+
import { tws, tw, twx } from '@trackunit/tailwind-styled-components';
|
|
5
6
|
import * as React from 'react';
|
|
6
7
|
import React__default, { useMemo, forwardRef, useState, cloneElement, useEffect, useCallback, useLayoutEffect, useContext, createElement, Fragment, createContext, useRef, Component } from 'react';
|
|
7
8
|
import { createPortal } from 'react-dom';
|
|
8
|
-
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
9
9
|
|
|
10
10
|
var defaultTranslations = {
|
|
11
11
|
|
|
@@ -81,15 +81,9 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled }) => {
|
|
|
81
81
|
return window.open(`tel:${value}`);
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
return (jsx$1(
|
|
84
|
+
return (jsx$1("div", { className: "flex p-1", children: jsx$1(IconButton, { className: cvaActionButton(), disabled: disabled, dataTestId: dataTestId || "testIconButtonId", size: "small", color: "tertiary", icon: jsx$1(Icon, { size: "small", name: getIconName() }), onClick: ButtonAction }) }));
|
|
85
85
|
};
|
|
86
|
-
const
|
|
87
|
-
tu-action-container
|
|
88
|
-
`;
|
|
89
|
-
const StyledIconButton = twx(IconButton) `
|
|
90
|
-
tu-action-button
|
|
91
|
-
${({ $fieldSize }) => $fieldSize === "small" && tws `tu-action-button--small`}
|
|
92
|
-
`;
|
|
86
|
+
const cvaActionButton = cvaMerge(["drop-shadow-none", "rounded-md"]);
|
|
93
87
|
|
|
94
88
|
/******************************************************************************
|
|
95
89
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2823,14 +2817,16 @@ const EmailInput = React.forwardRef((_a, ref) => {
|
|
|
2823
2817
|
*/
|
|
2824
2818
|
const EmailField = forwardRef((_a, ref) => {
|
|
2825
2819
|
var { label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId"]);
|
|
2826
|
-
const [value, setValue] = useState(defaultValue);
|
|
2820
|
+
const [value, setValue] = useState(defaultValue || "");
|
|
2827
2821
|
const htmlForId = id ? id : "emailField-" + v4();
|
|
2828
2822
|
// Type guard to check if value is a string
|
|
2829
2823
|
function isString(inputValue) {
|
|
2830
2824
|
return typeof inputValue === "string";
|
|
2831
2825
|
}
|
|
2832
|
-
//
|
|
2833
|
-
|
|
2826
|
+
// Doing the same check as we do on the backend
|
|
2827
|
+
// Using OWASP pattern from: https://owasp.org/www-community/OWASP_Validation_Regex_Repository
|
|
2828
|
+
const emailValidationPattern = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
2829
|
+
const renderAsInvalid = !!errorMessage || (isString(value) && emailValidationPattern.test(value));
|
|
2834
2830
|
return (jsx$1(FormGroup, { htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: (renderAsInvalid && errorMessage) || helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup`, children: jsx$1(EmailInput, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", ref: ref, value: value, onChange: e => setValue(e.target.value), isInvalid: renderAsInvalid, disabled: renderAsInvalid }, rest, { className: className, dataTestId: dataTestId })) }));
|
|
2835
2831
|
});
|
|
2836
2832
|
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "0.0.104
|
|
3
|
+
"version": "0.0.104",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=18.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/css-class-variance-utilities": "0.0.
|
|
11
|
-
"@trackunit/i18n-library-translation": "0.0.
|
|
12
|
-
"@trackunit/react-components": "0.1.
|
|
13
|
-
"@trackunit/tailwind-styled-components": "0.0.
|
|
10
|
+
"@trackunit/css-class-variance-utilities": "0.0.11",
|
|
11
|
+
"@trackunit/i18n-library-translation": "0.0.67",
|
|
12
|
+
"@trackunit/react-components": "0.1.139",
|
|
13
|
+
"@trackunit/tailwind-styled-components": "0.0.60",
|
|
14
14
|
"date-fns": "2.29.3",
|
|
15
15
|
"libphonenumber-js": "1.10.36",
|
|
16
16
|
"react": "18.2.0",
|