@trackunit/react-form-components 0.0.509 → 0.1.1
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 +5 -5
- package/index.esm.js +6 -7
- package/package.json +1 -1
- package/src/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -646,9 +646,8 @@ const isValidHEXColor = (value) => {
|
|
|
646
646
|
*
|
|
647
647
|
*/
|
|
648
648
|
const ColorField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value: propValue, onChange, isInvalid = false, ...rest }, ref) => {
|
|
649
|
-
const htmlForId = id ? id : "colorField-" + uuid.v4();
|
|
649
|
+
const htmlForId = React.useMemo(() => (id ? id : "colorField-" + uuid.v4()), [id]);
|
|
650
650
|
const innerRef = React.useRef(null);
|
|
651
|
-
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
652
651
|
React.useImperativeHandle(ref, () => innerRef.current, []);
|
|
653
652
|
// Internal state for color value
|
|
654
653
|
const [value, setValue] = React.useState(propValue || defaultValue || "");
|
|
@@ -664,7 +663,7 @@ const ColorField = React.forwardRef(({ label, id, tip, helpText, errorMessage, h
|
|
|
664
663
|
disabled: false,
|
|
665
664
|
invalid: false,
|
|
666
665
|
className,
|
|
667
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, children: [jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label
|
|
666
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, children: [jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label", className: "ml-2 h-[30px] w-[40px] self-center rounded-full bg-inherit", "data-testid": dataTestId, defaultValue: defaultValue, id: htmlForId, onChange: handleChange, ref: innerRef, type: "color", value: value }), jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputField({ disabled: false }), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, onChange: handleChange, type: "text", value: value }), jsxRuntime.jsx(reactComponents.IconButton, { className: "mr-1 self-center", icon: jsxRuntime.jsx(reactComponents.Icon, { name: "Pencil", type: "outline" }), onClick: () => {
|
|
668
667
|
if (innerRef.current) {
|
|
669
668
|
innerRef.current.click();
|
|
670
669
|
}
|
|
@@ -801,12 +800,12 @@ const DropZone = ({ className, dataTestId, filesSelected, label = jsxRuntime.jsx
|
|
|
801
800
|
}
|
|
802
801
|
(_a = inputLabelRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
803
802
|
};
|
|
804
|
-
return (jsxRuntime.
|
|
803
|
+
return (jsxRuntime.jsx("div", { className: cvaDropZone({ size, dropComplete: fileDropped, dragActive, disabled, invalid: isInvalid, className }), "data-testid": dataTestId, onClick: e => {
|
|
805
804
|
if (disabled) {
|
|
806
805
|
e.preventDefault();
|
|
807
806
|
e.stopPropagation();
|
|
808
807
|
}
|
|
809
|
-
}, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop, ...rest, children:
|
|
808
|
+
}, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop, ...rest, children: jsxRuntime.jsxs("label", { className: cvaDropZoneLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : null, ref: inputLabelRef, children: [jsxRuntime.jsx("input", { accept: accept, className: "hidden", onChange: handleChange, title: t("dropzone.input.title"), type: "file" }), jsxRuntime.jsx("div", { className: cvaDropZoneIconBackground({ invalid: isInvalid }), children: jsxRuntime.jsx(reactComponents.Icon, { className: !isInvalid ? "text-gray-400" : "", color: isInvalid ? "danger" : "neutral", name: "ArrowUpCircle", type: "solid" }) }), jsxRuntime.jsx("button", { disabled: disabled, onClick: handleButtonClick, children: label })] }) }));
|
|
810
809
|
};
|
|
811
810
|
|
|
812
811
|
// Doing the same check as we do on the backend
|
|
@@ -2602,6 +2601,7 @@ exports.CreatableSelectField = CreatableSelectField;
|
|
|
2602
2601
|
exports.DateField = DateField;
|
|
2603
2602
|
exports.DateInput = DateInput;
|
|
2604
2603
|
exports.DropZone = DropZone;
|
|
2604
|
+
exports.DropZoneDefaultLabel = DropZoneDefaultLabel;
|
|
2605
2605
|
exports.EMAIL_REGEX = EMAIL_REGEX;
|
|
2606
2606
|
exports.EmailField = EmailField;
|
|
2607
2607
|
exports.EmailInput = EmailInput;
|
package/index.esm.js
CHANGED
|
@@ -4,7 +4,7 @@ import { IconButton, Icon, Tooltip, Heading, Text, MenuItem, Tag, Spinner, useIs
|
|
|
4
4
|
import { useCopyToClipboard } from 'react-use';
|
|
5
5
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
6
6
|
import * as React from 'react';
|
|
7
|
-
import React__default, { isValidElement, forwardRef, useState, useCallback, useRef, cloneElement, useEffect,
|
|
7
|
+
import React__default, { isValidElement, forwardRef, useMemo, useState, useCallback, useRef, cloneElement, useEffect, useImperativeHandle } from 'react';
|
|
8
8
|
import { v4 } from 'uuid';
|
|
9
9
|
import { format } from 'date-fns';
|
|
10
10
|
import parsePhoneNumberFromString, { isSupportedCountry, getCountries, getCountryCallingCode, AsYouType, parseIncompletePhoneNumber, isValidPhoneNumber } from 'libphonenumber-js';
|
|
@@ -627,9 +627,8 @@ const isValidHEXColor = (value) => {
|
|
|
627
627
|
*
|
|
628
628
|
*/
|
|
629
629
|
const ColorField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value: propValue, onChange, isInvalid = false, ...rest }, ref) => {
|
|
630
|
-
const htmlForId = id ? id : "colorField-" + v4();
|
|
630
|
+
const htmlForId = useMemo(() => (id ? id : "colorField-" + v4()), [id]);
|
|
631
631
|
const innerRef = React__default.useRef(null);
|
|
632
|
-
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
633
632
|
React__default.useImperativeHandle(ref, () => innerRef.current, []);
|
|
634
633
|
// Internal state for color value
|
|
635
634
|
const [value, setValue] = useState(propValue || defaultValue || "");
|
|
@@ -645,7 +644,7 @@ const ColorField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAdd
|
|
|
645
644
|
disabled: false,
|
|
646
645
|
invalid: false,
|
|
647
646
|
className,
|
|
648
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, children: [jsx("input", { "aria-labelledby": htmlForId + "-label
|
|
647
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, children: [jsx("input", { "aria-labelledby": htmlForId + "-label", className: "ml-2 h-[30px] w-[40px] self-center rounded-full bg-inherit", "data-testid": dataTestId, defaultValue: defaultValue, id: htmlForId, onChange: handleChange, ref: innerRef, type: "color", value: value }), jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputField({ disabled: false }), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, onChange: handleChange, type: "text", value: value }), jsx(IconButton, { className: "mr-1 self-center", icon: jsx(Icon, { name: "Pencil", type: "outline" }), onClick: () => {
|
|
649
648
|
if (innerRef.current) {
|
|
650
649
|
innerRef.current.click();
|
|
651
650
|
}
|
|
@@ -782,12 +781,12 @@ const DropZone = ({ className, dataTestId, filesSelected, label = jsx(DropZoneDe
|
|
|
782
781
|
}
|
|
783
782
|
(_a = inputLabelRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
784
783
|
};
|
|
785
|
-
return (
|
|
784
|
+
return (jsx("div", { className: cvaDropZone({ size, dropComplete: fileDropped, dragActive, disabled, invalid: isInvalid, className }), "data-testid": dataTestId, onClick: e => {
|
|
786
785
|
if (disabled) {
|
|
787
786
|
e.preventDefault();
|
|
788
787
|
e.stopPropagation();
|
|
789
788
|
}
|
|
790
|
-
}, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop, ...rest, children: [jsx("input", { accept: accept, className: "hidden",
|
|
789
|
+
}, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop, ...rest, children: jsxs("label", { className: cvaDropZoneLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : null, ref: inputLabelRef, children: [jsx("input", { accept: accept, className: "hidden", onChange: handleChange, title: t("dropzone.input.title"), type: "file" }), jsx("div", { className: cvaDropZoneIconBackground({ invalid: isInvalid }), children: jsx(Icon, { className: !isInvalid ? "text-gray-400" : "", color: isInvalid ? "danger" : "neutral", name: "ArrowUpCircle", type: "solid" }) }), jsx("button", { disabled: disabled, onClick: handleButtonClick, children: label })] }) }));
|
|
791
790
|
};
|
|
792
791
|
|
|
793
792
|
// Doing the same check as we do on the backend
|
|
@@ -2572,4 +2571,4 @@ const useZodValidators = () => {
|
|
|
2572
2571
|
*/
|
|
2573
2572
|
setupLibraryTranslations();
|
|
2574
2573
|
|
|
2575
|
-
export { ActionButton, BaseInput, Checkbox, CheckboxField, ColorField, CreatableSelect, CreatableSelectField, DateField, DateInput, DropZone, EMAIL_REGEX, EmailField, EmailInput, FormFieldSelectAdapter, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PasswordField, PasswordInput, PhoneField, PhoneFieldWithController, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SelectField, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, UrlField, UrlInput, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaActionButton, cvaActionContainer, cvaInput, cvaInputAction, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectControl, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefixSuffix, cvaSelectXIcon, getCountryAbbreviation, getOrderedOptions, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, isValidHEXColor, parseSchedule, serializeSchedule, useCustomComponents, useGetPhoneValidationRules, usePhoneInput, useZodValidators, validateEmailAddress, validatePhoneNumber, weekDay };
|
|
2574
|
+
export { ActionButton, BaseInput, Checkbox, CheckboxField, ColorField, CreatableSelect, CreatableSelectField, DateField, DateInput, DropZone, DropZoneDefaultLabel, EMAIL_REGEX, EmailField, EmailInput, FormFieldSelectAdapter, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PasswordField, PasswordInput, PhoneField, PhoneFieldWithController, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SelectField, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, UrlField, UrlInput, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaActionButton, cvaActionContainer, cvaInput, cvaInputAction, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectControl, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefixSuffix, cvaSelectXIcon, getCountryAbbreviation, getOrderedOptions, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, isValidHEXColor, parseSchedule, serializeSchedule, useCustomComponents, useGetPhoneValidationRules, usePhoneInput, useZodValidators, validateEmailAddress, validatePhoneNumber, weekDay };
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./components/ColorField/ColorField";
|
|
|
6
6
|
export * from "./components/DateField/DateField";
|
|
7
7
|
export * from "./components/DateInput/DateInput";
|
|
8
8
|
export * from "./components/DropZone/DropZone";
|
|
9
|
+
export * from "./components/DropZone/DropZoneDefaultLabel";
|
|
9
10
|
export * from "./components/EmailField/EmailField";
|
|
10
11
|
export * from "./components/EmailInput";
|
|
11
12
|
export * from "./components/FormGroup/FormGroup";
|