@trackunit/react-form-components 1.25.0 → 1.25.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/index.cjs.js +20 -19
- package/index.esm.js +20 -19
- package/package.json +8 -8
- package/src/components/ActionButton/ActionButton.d.ts +3 -3
- package/src/components/FormGroup/FormGroup.d.ts +3 -3
- package/src/components/Label/Label.d.ts +3 -3
- package/src/components/MultiSelectField/FormFieldSelectAdapterMulti.d.ts +2 -2
- package/src/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/src/components/Schedule/Schedule.d.ts +3 -3
- package/src/components/SelectField/FormFieldSelectAdapter.d.ts +3 -3
- package/src/components/TimeRange/TimeRange.d.ts +3 -3
- package/src/components/TimeRangeField/TimeRangeField.d.ts +3 -3
package/index.cjs.js
CHANGED
|
@@ -433,7 +433,7 @@ const cvaActionContainer = cssClassVarianceUtilities.cvaMerge(["flex", "items-ce
|
|
|
433
433
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
434
434
|
* @returns {ReactElement} ActionButton component
|
|
435
435
|
*/
|
|
436
|
-
const ActionButton = ({ type, value, "data-testid": dataTestId, size = "medium", disabled, className, onClick, ref, }) => {
|
|
436
|
+
const ActionButton = ({ type, value, "data-testid": dataTestId, size = "medium", disabled, className, onClick, style, ref, }) => {
|
|
437
437
|
const [, copyToClipboard] = usehooksTs.useCopyToClipboard();
|
|
438
438
|
const getIconName = () => {
|
|
439
439
|
switch (type) {
|
|
@@ -472,7 +472,7 @@ const ActionButton = ({ type, value, "data-testid": dataTestId, size = "medium",
|
|
|
472
472
|
}
|
|
473
473
|
};
|
|
474
474
|
const adjustedIconSize = size === "large" ? "medium" : size;
|
|
475
|
-
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className, size }), ref: ref, children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: adjustedIconSize }), "data-testid": dataTestId || "testIconButtonId", disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: getIconName(), size: adjustedIconSize }), onClick: buttonAction, size: "small", variant: "ghost-neutral" }) }));
|
|
475
|
+
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className, size }), ref: ref, style: style, children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: adjustedIconSize }), "data-testid": dataTestId || "testIconButtonId", disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: getIconName(), size: adjustedIconSize }), onClick: buttonAction, size: "small", variant: "ghost-neutral" }) }));
|
|
476
476
|
};
|
|
477
477
|
|
|
478
478
|
const GenericActionsRenderer = ({ genericAction = undefined, disabled, fieldSize = undefined, innerRef, tooltipLabel, }) => {
|
|
@@ -2262,8 +2262,8 @@ const CreatableSelect = (props) => {
|
|
|
2262
2262
|
* @param {LabelProps} props - The props for the Label component
|
|
2263
2263
|
* @returns {ReactElement} Label component
|
|
2264
2264
|
*/
|
|
2265
|
-
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled = false, isInvalid = false, ref, }) => {
|
|
2266
|
-
return (jsxRuntime.jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", ref: ref, children: children }));
|
|
2265
|
+
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled = false, isInvalid = false, style, ref, }) => {
|
|
2266
|
+
return (jsxRuntime.jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", ref: ref, style: style, children: children }));
|
|
2267
2267
|
};
|
|
2268
2268
|
|
|
2269
2269
|
const cvaFormGroup = cssClassVarianceUtilities.cvaMerge(["component-formGroup-gap", "group", "form-group"]);
|
|
@@ -2314,13 +2314,13 @@ const cvaHelpAddon = cssClassVarianceUtilities.cvaMerge(["ml-auto"]);
|
|
|
2314
2314
|
* @param {FormGroupProps} props - The props for the FormGroup component
|
|
2315
2315
|
* @returns {ReactElement} FormGroup component
|
|
2316
2316
|
*/
|
|
2317
|
-
const FormGroup = ({ isInvalid = false, isWarning = false, helpText, helpAddon, tip, className, "data-testid": dataTestId, label, htmlFor, children, required = false, ref, }) => {
|
|
2317
|
+
const FormGroup = ({ isInvalid = false, isWarning = false, helpText, helpAddon, tip, className, "data-testid": dataTestId, label, htmlFor, children, required = false, style, ref, }) => {
|
|
2318
2318
|
const [t] = useTranslation();
|
|
2319
2319
|
const validationStateIcon = react.useMemo(() => {
|
|
2320
2320
|
const color = isInvalid ? "danger" : isWarning ? "warning" : null;
|
|
2321
2321
|
return color ? jsxRuntime.jsx(reactComponents.Icon, { color: color, name: "ExclamationTriangle", size: "small" }) : null;
|
|
2322
2322
|
}, [isInvalid, isWarning]);
|
|
2323
|
-
return (jsxRuntime.jsxs("div", { className: cvaFormGroup({ className }), "data-testid": dataTestId, ref: ref, children: [label !== undefined && label !== null ? (jsxRuntime.jsxs("div", { className: cvaFormGroupContainerBefore(), children: [jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Label, { className: "component-formGroup-font", "data-testid": dataTestId ? `${dataTestId}-label` : undefined, htmlFor: htmlFor, id: htmlFor + "-label", children: label }), required ? (jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": "required-asterisk", label: t("field.required.asterisk.tooltip"), children: jsxRuntime.jsx("span", { children: "*" }) })) : null] }), tip !== undefined && tip !== null ? (jsxRuntime.jsx("span", { className: "ml-1", children: jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, label: tip, placement: "bottom" }) })) : null] })) : null, children, (
|
|
2323
|
+
return (jsxRuntime.jsxs("div", { className: cvaFormGroup({ className }), "data-testid": dataTestId, ref: ref, style: style, children: [label !== undefined && label !== null ? (jsxRuntime.jsxs("div", { className: cvaFormGroupContainerBefore(), children: [jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Label, { className: "component-formGroup-font", "data-testid": dataTestId ? `${dataTestId}-label` : undefined, htmlFor: htmlFor, id: htmlFor + "-label", children: label }), required ? (jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": "required-asterisk", label: t("field.required.asterisk.tooltip"), children: jsxRuntime.jsx("span", { children: "*" }) })) : null] }), tip !== undefined && tip !== null ? (jsxRuntime.jsx("span", { className: "ml-1", children: jsxRuntime.jsx(reactComponents.Tooltip, { "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, label: tip, placement: "bottom" }) })) : null] })) : null, children, (helpText !== undefined && helpText !== null) || (helpAddon !== undefined && helpAddon !== null) ? (jsxRuntime.jsxs("div", { className: cvaFormGroupContainerAfter({ invalid: isInvalid, isWarning: isWarning }), children: [helpText ? (jsxRuntime.jsxs("div", { className: "flex gap-1", children: [validationStateIcon, jsxRuntime.jsx("span", { "data-testid": dataTestId ? `${dataTestId}-helpText` : undefined, children: helpText })] })) : undefined, helpAddon !== undefined && helpAddon !== null ? (jsxRuntime.jsx("span", { className: cvaHelpAddon(), "data-testid": dataTestId ? `${dataTestId}-helpAddon` : null, children: helpAddon })) : null] })) : null] }));
|
|
2324
2324
|
};
|
|
2325
2325
|
|
|
2326
2326
|
/**
|
|
@@ -2893,7 +2893,7 @@ const IGNORED_RS_ACTIONS = new Set(["set-value", "input-blur", "menu-close"]);
|
|
|
2893
2893
|
* @returns {ReactElement} FormFieldSelectAdapterMulti component
|
|
2894
2894
|
*/
|
|
2895
2895
|
const FormFieldSelectAdapterMulti = (props) => {
|
|
2896
|
-
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = undefined, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, onInputChange, ...selectProps } = props;
|
|
2896
|
+
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = undefined, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, style, ref, onInputChange, ...selectProps } = props;
|
|
2897
2897
|
const [inputValue, setInputValue] = react.useState("");
|
|
2898
2898
|
// Hidden select for a stable DOM ref target (API parity with single adapter)
|
|
2899
2899
|
const innerRef = react.useRef(null);
|
|
@@ -2950,7 +2950,7 @@ const FormFieldSelectAdapterMulti = (props) => {
|
|
|
2950
2950
|
return (jsxRuntime.jsxs(FormGroup, { className: className, "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: controlId, isInvalid: renderAsInvalid, label: label, required: "required" in selectProps && selectProps.required
|
|
2951
2951
|
? !(("disabled" in selectProps && Boolean(selectProps.disabled)) ||
|
|
2952
2952
|
("readOnly" in selectProps && Boolean(selectProps.readOnly)))
|
|
2953
|
-
: false, tip: tip, children: [jsxRuntime.jsx("select", { "aria-hidden": "true", defaultValue: "", hidden: true, name: name, ref: innerRef }), typeof getOptionValue === "function" &&
|
|
2953
|
+
: false, style: style, tip: tip, children: [jsxRuntime.jsx("select", { "aria-hidden": "true", defaultValue: "", hidden: true, name: name, ref: innerRef }), typeof getOptionValue === "function" &&
|
|
2954
2954
|
selectedOptions.map((opt, idx) => {
|
|
2955
2955
|
const primitiveValue = getOptionValue(opt);
|
|
2956
2956
|
return typeof primitiveValue === "string" ? (jsxRuntime.jsx("input", { name: name, type: "hidden", value: primitiveValue }, `${primitiveValue}-${idx}`)) : null;
|
|
@@ -3632,8 +3632,8 @@ const RadioGroupContext = react.createContext(null);
|
|
|
3632
3632
|
* @param {RadioGroupProps} props - The props for the RadioGroup component
|
|
3633
3633
|
* @returns {ReactElement} RadioGroup component
|
|
3634
3634
|
*/
|
|
3635
|
-
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline = false, className, "data-testid": dataTestId, isInvalid, ref, }) => {
|
|
3636
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, label: label, children: jsxRuntime.jsx("div", { className: cvaInputGroup({ layout: inline ? "inline" : null, className }), "data-testid": dataTestId, ref: ref, role: "radiogroup", children: jsxRuntime.jsx(RadioGroupContext.Provider, { value: {
|
|
3635
|
+
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline = false, className, "data-testid": dataTestId, isInvalid, style, ref, }) => {
|
|
3636
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, label: label, children: jsxRuntime.jsx("div", { className: cvaInputGroup({ layout: inline ? "inline" : null, className }), "data-testid": dataTestId, ref: ref, role: "radiogroup", style: style, children: jsxRuntime.jsx(RadioGroupContext.Provider, { value: {
|
|
3637
3637
|
id,
|
|
3638
3638
|
value,
|
|
3639
3639
|
name: name || id,
|
|
@@ -3731,7 +3731,7 @@ const cvaTimeRange = cssClassVarianceUtilities.cvaMerge([
|
|
|
3731
3731
|
* @param {TimeRangeProps} props - The props for the TimeRange component
|
|
3732
3732
|
* @returns {ReactElement} TimeRange component
|
|
3733
3733
|
*/
|
|
3734
|
-
const TimeRange = ({ id, className, "data-testid": dataTestId, children, range, onChange, disabled, isInvalid, ref, }) => {
|
|
3734
|
+
const TimeRange = ({ id, className, "data-testid": dataTestId, children, range, onChange, disabled, isInvalid, style, ref, }) => {
|
|
3735
3735
|
const [timeRange, setTimeRange] = react.useState(range ?? {
|
|
3736
3736
|
timeFrom: DEFAULT_TIME,
|
|
3737
3737
|
timeTo: DEFAULT_TIME,
|
|
@@ -3743,7 +3743,7 @@ const TimeRange = ({ id, className, "data-testid": dataTestId, children, range,
|
|
|
3743
3743
|
setTimeRange(prev => ({ ...prev, timeTo }));
|
|
3744
3744
|
};
|
|
3745
3745
|
const onRangeChange = () => onChange(timeRange);
|
|
3746
|
-
return (jsxRuntime.jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, ref: ref, children: [jsxRuntime.jsx(BaseInput, { "data-testid": `${dataTestId}-from`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeFrom(time.currentTarget.value), type: "time", value: timeRange.timeFrom === "" ? DEFAULT_TIME : timeRange.timeFrom }), children ?? jsxRuntime.jsx("div", { "data-testid": `${dataTestId}-separator`, children: "-" }), jsxRuntime.jsx(BaseInput, { "data-testid": `${dataTestId}-to`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeTo(time.currentTarget.value), type: "time", value: timeRange.timeTo === "" ? DEFAULT_TIME : timeRange.timeTo })] }));
|
|
3746
|
+
return (jsxRuntime.jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, ref: ref, style: style, children: [jsxRuntime.jsx(BaseInput, { "data-testid": `${dataTestId}-from`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeFrom(time.currentTarget.value), type: "time", value: timeRange.timeFrom === "" ? DEFAULT_TIME : timeRange.timeFrom }), children ?? jsxRuntime.jsx("div", { "data-testid": `${dataTestId}-separator`, children: "-" }), jsxRuntime.jsx(BaseInput, { "data-testid": `${dataTestId}-to`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeTo(time.currentTarget.value), type: "time", value: timeRange.timeTo === "" ? DEFAULT_TIME : timeRange.timeTo })] }));
|
|
3747
3747
|
};
|
|
3748
3748
|
const DEFAULT_TIME = "12:00";
|
|
3749
3749
|
|
|
@@ -3785,7 +3785,7 @@ const cvaScheduleItemText = cssClassVarianceUtilities.cvaMerge(["flex", "font-bo
|
|
|
3785
3785
|
* @param {ScheduleProps} props - The props for the Schedule component
|
|
3786
3786
|
* @returns {ReactElement} Schedule component
|
|
3787
3787
|
*/
|
|
3788
|
-
const Schedule = ({ className, "data-testid": dataTestId, schedule, onChange, invalidKeys = [], ref, }) => {
|
|
3788
|
+
const Schedule = ({ className, "data-testid": dataTestId, schedule, onChange, invalidKeys = [], style, ref, }) => {
|
|
3789
3789
|
const [t] = useTranslation();
|
|
3790
3790
|
const onRangeChange = (range, index) => {
|
|
3791
3791
|
const newSchedule = schedule.map((day, dayIndex) => (index === dayIndex ? { ...day, range: { ...range } } : day));
|
|
@@ -3817,7 +3817,7 @@ const Schedule = ({ className, "data-testid": dataTestId, schedule, onChange, in
|
|
|
3817
3817
|
: day);
|
|
3818
3818
|
onChange(newSchedule);
|
|
3819
3819
|
};
|
|
3820
|
-
return (jsxRuntime.jsx("div", { className: className, "data-testid": dataTestId, ref: ref, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDay }, index) => {
|
|
3820
|
+
return (jsxRuntime.jsx("div", { className: className, "data-testid": dataTestId, ref: ref, style: style, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDay }, index) => {
|
|
3821
3821
|
return (jsxRuntime.jsxs("div", { className: cvaScheduleItem(), children: [jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4 sm:hidden", children: [jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.day") }), jsxRuntime.jsx(reactComponents.Text, { className: cvaScheduleItemText(), size: "medium", subtle: !isActive, children: label }), jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.active") }), jsxRuntime.jsx(Checkbox, { checked: isActive, label: checkboxLabel, onChange: (event) => onActiveChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(reactComponents.Text, { className: "font-medium text-neutral-500", children: t("schedule.label.allDay") }), jsxRuntime.jsx(Checkbox, { checked: isAllDay ? isActive : undefined, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(TimeRange, { disabled: !isActive || isAllDay, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: range })] }), jsxRuntime.jsxs("div", { className: "max-sm:hidden sm:grid sm:grid-cols-[100px_200px_60px_250px_250px] sm:gap-2", children: [jsxRuntime.jsx(Checkbox, { checked: isActive, "data-testid": `${dataTestId}-${key}-checkbox`, label: checkboxLabel, onChange: (event) => onActiveChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(reactComponents.Text, { className: cvaScheduleItemText(), size: "medium", subtle: !isActive, children: label }), jsxRuntime.jsx(Checkbox, { checked: isAllDay ? isActive : undefined, "data-testid": `${dataTestId}-${key}-allday-checkbox`, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsxRuntime.jsx(TimeRange, { "data-testid": `${dataTestId}-${key}-range`, disabled: !isActive || isAllDay, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: isAllDay ? undefined : range })] })] }, key + label));
|
|
3822
3822
|
}) }));
|
|
3823
3823
|
};
|
|
@@ -4014,7 +4014,7 @@ const Search = ({ className, placeholder, value, widenInputOnFocus = false, hide
|
|
|
4014
4014
|
const { t } = useTranslation();
|
|
4015
4015
|
const generatedId = react.useId();
|
|
4016
4016
|
const inputId = id ?? `search-${generatedId}`;
|
|
4017
|
-
return (jsxRuntime.jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, id: inputId, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", containerClassName: "!p-0", size: fieldSize })) : (jsxRuntime.jsx(reactComponents.Icon, { name: iconName, size: fieldSize })), ref: ref, suffix:
|
|
4017
|
+
return (jsxRuntime.jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, id: inputId, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", containerClassName: "!p-0", size: fieldSize })) : (jsxRuntime.jsx(reactComponents.Icon, { name: iconName, size: fieldSize })), ref: ref, style: style, suffix:
|
|
4018
4018
|
//only show the clear button if there is a value and the onClear function is provided
|
|
4019
4019
|
onClear && value ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
|
|
4020
4020
|
onClear();
|
|
@@ -4025,7 +4025,7 @@ Search.displayName = "Search";
|
|
|
4025
4025
|
/**
|
|
4026
4026
|
*
|
|
4027
4027
|
*/
|
|
4028
|
-
const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = false, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, required = false, ...rest }) => {
|
|
4028
|
+
const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = false, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, style, ref, required = false, ...rest }) => {
|
|
4029
4029
|
const isFirstRender = reactComponents.useIsFirstRender();
|
|
4030
4030
|
const [innerValue, setInnerValue] = react.useState(value ?? defaultValue);
|
|
4031
4031
|
const onChangeRef = react.useRef(onChange);
|
|
@@ -4079,7 +4079,8 @@ const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText
|
|
|
4079
4079
|
helpAddon,
|
|
4080
4080
|
tip,
|
|
4081
4081
|
label,
|
|
4082
|
-
required: required ? !Boolean(rest.disabled ?? rest.readOnly) : false,
|
|
4082
|
+
required: required ? !Boolean(rest.disabled ?? rest.readOnly) : false,
|
|
4083
|
+
style, children: [jsxRuntime.jsx("select", { onChange, ref: innerRef, name, value: innerValue, hidden: true, children: optionsWithCurrentSelectionBackupOption.map(option => {
|
|
4083
4084
|
return (jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value));
|
|
4084
4085
|
}) }), children({
|
|
4085
4086
|
...rest,
|
|
@@ -4379,10 +4380,10 @@ TextField.displayName = "TextField";
|
|
|
4379
4380
|
* @param {TimeRangeFieldProps} props - The props for the TimeRangeField component
|
|
4380
4381
|
* @returns {ReactElement} TimeRangeField component
|
|
4381
4382
|
*/
|
|
4382
|
-
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid = undefined, errorMessage, label, tip, children, helpText, id, ref, ...rest }) => {
|
|
4383
|
+
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid = undefined, errorMessage, label, tip, children, helpText, id, style, ref, ...rest }) => {
|
|
4383
4384
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
4384
4385
|
const htmlFor = id ? id : "timeRangeField-" + sharedUtils.uuidv4();
|
|
4385
|
-
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, ref: ref, tip: tip, children: jsxRuntime.jsx(TimeRange, { className: className, "data-testid": dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
4386
|
+
return (jsxRuntime.jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, ref: ref, style: style, tip: tip, children: jsxRuntime.jsx(TimeRange, { className: className, "data-testid": dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
4386
4387
|
};
|
|
4387
4388
|
|
|
4388
4389
|
const cvaToggleSwitchWrapper = cssClassVarianceUtilities.cvaMerge(["grid", "grid-cols-[auto]", "items-center"]);
|
package/index.esm.js
CHANGED
|
@@ -432,7 +432,7 @@ const cvaActionContainer = cvaMerge(["flex", "items-center"], {
|
|
|
432
432
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
433
433
|
* @returns {ReactElement} ActionButton component
|
|
434
434
|
*/
|
|
435
|
-
const ActionButton = ({ type, value, "data-testid": dataTestId, size = "medium", disabled, className, onClick, ref, }) => {
|
|
435
|
+
const ActionButton = ({ type, value, "data-testid": dataTestId, size = "medium", disabled, className, onClick, style, ref, }) => {
|
|
436
436
|
const [, copyToClipboard] = useCopyToClipboard();
|
|
437
437
|
const getIconName = () => {
|
|
438
438
|
switch (type) {
|
|
@@ -471,7 +471,7 @@ const ActionButton = ({ type, value, "data-testid": dataTestId, size = "medium",
|
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
473
|
const adjustedIconSize = size === "large" ? "medium" : size;
|
|
474
|
-
return (jsx("div", { className: cvaActionContainer({ className, size }), ref: ref, children: jsx(IconButton, { className: cvaActionButton({ size: adjustedIconSize }), "data-testid": dataTestId || "testIconButtonId", disabled: disabled, icon: jsx(Icon, { name: getIconName(), size: adjustedIconSize }), onClick: buttonAction, size: "small", variant: "ghost-neutral" }) }));
|
|
474
|
+
return (jsx("div", { className: cvaActionContainer({ className, size }), ref: ref, style: style, children: jsx(IconButton, { className: cvaActionButton({ size: adjustedIconSize }), "data-testid": dataTestId || "testIconButtonId", disabled: disabled, icon: jsx(Icon, { name: getIconName(), size: adjustedIconSize }), onClick: buttonAction, size: "small", variant: "ghost-neutral" }) }));
|
|
475
475
|
};
|
|
476
476
|
|
|
477
477
|
const GenericActionsRenderer = ({ genericAction = undefined, disabled, fieldSize = undefined, innerRef, tooltipLabel, }) => {
|
|
@@ -2261,8 +2261,8 @@ const CreatableSelect = (props) => {
|
|
|
2261
2261
|
* @param {LabelProps} props - The props for the Label component
|
|
2262
2262
|
* @returns {ReactElement} Label component
|
|
2263
2263
|
*/
|
|
2264
|
-
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled = false, isInvalid = false, ref, }) => {
|
|
2265
|
-
return (jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", ref: ref, children: children }));
|
|
2264
|
+
const Label = ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled = false, isInvalid = false, style, ref, }) => {
|
|
2265
|
+
return (jsx("label", { className: cvaLabel({ invalid: isInvalid, disabled, className }), "data-testid": dataTestId, htmlFor: htmlFor || "", id: id || "", ref: ref, style: style, children: children }));
|
|
2266
2266
|
};
|
|
2267
2267
|
|
|
2268
2268
|
const cvaFormGroup = cvaMerge(["component-formGroup-gap", "group", "form-group"]);
|
|
@@ -2313,13 +2313,13 @@ const cvaHelpAddon = cvaMerge(["ml-auto"]);
|
|
|
2313
2313
|
* @param {FormGroupProps} props - The props for the FormGroup component
|
|
2314
2314
|
* @returns {ReactElement} FormGroup component
|
|
2315
2315
|
*/
|
|
2316
|
-
const FormGroup = ({ isInvalid = false, isWarning = false, helpText, helpAddon, tip, className, "data-testid": dataTestId, label, htmlFor, children, required = false, ref, }) => {
|
|
2316
|
+
const FormGroup = ({ isInvalid = false, isWarning = false, helpText, helpAddon, tip, className, "data-testid": dataTestId, label, htmlFor, children, required = false, style, ref, }) => {
|
|
2317
2317
|
const [t] = useTranslation();
|
|
2318
2318
|
const validationStateIcon = useMemo(() => {
|
|
2319
2319
|
const color = isInvalid ? "danger" : isWarning ? "warning" : null;
|
|
2320
2320
|
return color ? jsx(Icon, { color: color, name: "ExclamationTriangle", size: "small" }) : null;
|
|
2321
2321
|
}, [isInvalid, isWarning]);
|
|
2322
|
-
return (jsxs("div", { className: cvaFormGroup({ className }), "data-testid": dataTestId, ref: ref, children: [label !== undefined && label !== null ? (jsxs("div", { className: cvaFormGroupContainerBefore(), children: [jsxs(Fragment, { children: [jsx(Label, { className: "component-formGroup-font", "data-testid": dataTestId ? `${dataTestId}-label` : undefined, htmlFor: htmlFor, id: htmlFor + "-label", children: label }), required ? (jsx(Tooltip, { "data-testid": "required-asterisk", label: t("field.required.asterisk.tooltip"), children: jsx("span", { children: "*" }) })) : null] }), tip !== undefined && tip !== null ? (jsx("span", { className: "ml-1", children: jsx(Tooltip, { "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, label: tip, placement: "bottom" }) })) : null] })) : null, children, (
|
|
2322
|
+
return (jsxs("div", { className: cvaFormGroup({ className }), "data-testid": dataTestId, ref: ref, style: style, children: [label !== undefined && label !== null ? (jsxs("div", { className: cvaFormGroupContainerBefore(), children: [jsxs(Fragment, { children: [jsx(Label, { className: "component-formGroup-font", "data-testid": dataTestId ? `${dataTestId}-label` : undefined, htmlFor: htmlFor, id: htmlFor + "-label", children: label }), required ? (jsx(Tooltip, { "data-testid": "required-asterisk", label: t("field.required.asterisk.tooltip"), children: jsx("span", { children: "*" }) })) : null] }), tip !== undefined && tip !== null ? (jsx("span", { className: "ml-1", children: jsx(Tooltip, { "data-testid": dataTestId ? `${dataTestId}-tooltip` : undefined, label: tip, placement: "bottom" }) })) : null] })) : null, children, (helpText !== undefined && helpText !== null) || (helpAddon !== undefined && helpAddon !== null) ? (jsxs("div", { className: cvaFormGroupContainerAfter({ invalid: isInvalid, isWarning: isWarning }), children: [helpText ? (jsxs("div", { className: "flex gap-1", children: [validationStateIcon, jsx("span", { "data-testid": dataTestId ? `${dataTestId}-helpText` : undefined, children: helpText })] })) : undefined, helpAddon !== undefined && helpAddon !== null ? (jsx("span", { className: cvaHelpAddon(), "data-testid": dataTestId ? `${dataTestId}-helpAddon` : null, children: helpAddon })) : null] })) : null] }));
|
|
2323
2323
|
};
|
|
2324
2324
|
|
|
2325
2325
|
/**
|
|
@@ -2892,7 +2892,7 @@ const IGNORED_RS_ACTIONS = new Set(["set-value", "input-blur", "menu-close"]);
|
|
|
2892
2892
|
* @returns {ReactElement} FormFieldSelectAdapterMulti component
|
|
2893
2893
|
*/
|
|
2894
2894
|
const FormFieldSelectAdapterMulti = (props) => {
|
|
2895
|
-
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = undefined, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, onInputChange, ...selectProps } = props;
|
|
2895
|
+
const { className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = undefined, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, style, ref, onInputChange, ...selectProps } = props;
|
|
2896
2896
|
const [inputValue, setInputValue] = useState("");
|
|
2897
2897
|
// Hidden select for a stable DOM ref target (API parity with single adapter)
|
|
2898
2898
|
const innerRef = useRef(null);
|
|
@@ -2949,7 +2949,7 @@ const FormFieldSelectAdapterMulti = (props) => {
|
|
|
2949
2949
|
return (jsxs(FormGroup, { className: className, "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: controlId, isInvalid: renderAsInvalid, label: label, required: "required" in selectProps && selectProps.required
|
|
2950
2950
|
? !(("disabled" in selectProps && Boolean(selectProps.disabled)) ||
|
|
2951
2951
|
("readOnly" in selectProps && Boolean(selectProps.readOnly)))
|
|
2952
|
-
: false, tip: tip, children: [jsx("select", { "aria-hidden": "true", defaultValue: "", hidden: true, name: name, ref: innerRef }), typeof getOptionValue === "function" &&
|
|
2952
|
+
: false, style: style, tip: tip, children: [jsx("select", { "aria-hidden": "true", defaultValue: "", hidden: true, name: name, ref: innerRef }), typeof getOptionValue === "function" &&
|
|
2953
2953
|
selectedOptions.map((opt, idx) => {
|
|
2954
2954
|
const primitiveValue = getOptionValue(opt);
|
|
2955
2955
|
return typeof primitiveValue === "string" ? (jsx("input", { name: name, type: "hidden", value: primitiveValue }, `${primitiveValue}-${idx}`)) : null;
|
|
@@ -3631,8 +3631,8 @@ const RadioGroupContext = createContext(null);
|
|
|
3631
3631
|
* @param {RadioGroupProps} props - The props for the RadioGroup component
|
|
3632
3632
|
* @returns {ReactElement} RadioGroup component
|
|
3633
3633
|
*/
|
|
3634
|
-
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline = false, className, "data-testid": dataTestId, isInvalid, ref, }) => {
|
|
3635
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, label: label, children: jsx("div", { className: cvaInputGroup({ layout: inline ? "inline" : null, className }), "data-testid": dataTestId, ref: ref, role: "radiogroup", children: jsx(RadioGroupContext.Provider, { value: {
|
|
3634
|
+
const RadioGroup = ({ children, id, name, value, disabled, onChange, label, inline = false, className, "data-testid": dataTestId, isInvalid, style, ref, }) => {
|
|
3635
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, label: label, children: jsx("div", { className: cvaInputGroup({ layout: inline ? "inline" : null, className }), "data-testid": dataTestId, ref: ref, role: "radiogroup", style: style, children: jsx(RadioGroupContext.Provider, { value: {
|
|
3636
3636
|
id,
|
|
3637
3637
|
value,
|
|
3638
3638
|
name: name || id,
|
|
@@ -3730,7 +3730,7 @@ const cvaTimeRange = cvaMerge([
|
|
|
3730
3730
|
* @param {TimeRangeProps} props - The props for the TimeRange component
|
|
3731
3731
|
* @returns {ReactElement} TimeRange component
|
|
3732
3732
|
*/
|
|
3733
|
-
const TimeRange = ({ id, className, "data-testid": dataTestId, children, range, onChange, disabled, isInvalid, ref, }) => {
|
|
3733
|
+
const TimeRange = ({ id, className, "data-testid": dataTestId, children, range, onChange, disabled, isInvalid, style, ref, }) => {
|
|
3734
3734
|
const [timeRange, setTimeRange] = useState(range ?? {
|
|
3735
3735
|
timeFrom: DEFAULT_TIME,
|
|
3736
3736
|
timeTo: DEFAULT_TIME,
|
|
@@ -3742,7 +3742,7 @@ const TimeRange = ({ id, className, "data-testid": dataTestId, children, range,
|
|
|
3742
3742
|
setTimeRange(prev => ({ ...prev, timeTo }));
|
|
3743
3743
|
};
|
|
3744
3744
|
const onRangeChange = () => onChange(timeRange);
|
|
3745
|
-
return (jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, ref: ref, children: [jsx(BaseInput, { "data-testid": `${dataTestId}-from`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeFrom(time.currentTarget.value), type: "time", value: timeRange.timeFrom === "" ? DEFAULT_TIME : timeRange.timeFrom }), children ?? jsx("div", { "data-testid": `${dataTestId}-separator`, children: "-" }), jsx(BaseInput, { "data-testid": `${dataTestId}-to`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeTo(time.currentTarget.value), type: "time", value: timeRange.timeTo === "" ? DEFAULT_TIME : timeRange.timeTo })] }));
|
|
3745
|
+
return (jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, ref: ref, style: style, children: [jsx(BaseInput, { "data-testid": `${dataTestId}-from`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeFrom(time.currentTarget.value), type: "time", value: timeRange.timeFrom === "" ? DEFAULT_TIME : timeRange.timeFrom }), children ?? jsx("div", { "data-testid": `${dataTestId}-separator`, children: "-" }), jsx(BaseInput, { "data-testid": `${dataTestId}-to`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeTo(time.currentTarget.value), type: "time", value: timeRange.timeTo === "" ? DEFAULT_TIME : timeRange.timeTo })] }));
|
|
3746
3746
|
};
|
|
3747
3747
|
const DEFAULT_TIME = "12:00";
|
|
3748
3748
|
|
|
@@ -3784,7 +3784,7 @@ const cvaScheduleItemText = cvaMerge(["flex", "font-bold", "self-center"]);
|
|
|
3784
3784
|
* @param {ScheduleProps} props - The props for the Schedule component
|
|
3785
3785
|
* @returns {ReactElement} Schedule component
|
|
3786
3786
|
*/
|
|
3787
|
-
const Schedule = ({ className, "data-testid": dataTestId, schedule, onChange, invalidKeys = [], ref, }) => {
|
|
3787
|
+
const Schedule = ({ className, "data-testid": dataTestId, schedule, onChange, invalidKeys = [], style, ref, }) => {
|
|
3788
3788
|
const [t] = useTranslation();
|
|
3789
3789
|
const onRangeChange = (range, index) => {
|
|
3790
3790
|
const newSchedule = schedule.map((day, dayIndex) => (index === dayIndex ? { ...day, range: { ...range } } : day));
|
|
@@ -3816,7 +3816,7 @@ const Schedule = ({ className, "data-testid": dataTestId, schedule, onChange, in
|
|
|
3816
3816
|
: day);
|
|
3817
3817
|
onChange(newSchedule);
|
|
3818
3818
|
};
|
|
3819
|
-
return (jsx("div", { className: className, "data-testid": dataTestId, ref: ref, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDay }, index) => {
|
|
3819
|
+
return (jsx("div", { className: className, "data-testid": dataTestId, ref: ref, style: style, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDay }, index) => {
|
|
3820
3820
|
return (jsxs("div", { className: cvaScheduleItem(), children: [jsxs("div", { className: "grid grid-cols-2 gap-4 sm:hidden", children: [jsx(Text, { className: "font-medium text-neutral-500", children: t("schedule.label.day") }), jsx(Text, { className: cvaScheduleItemText(), size: "medium", subtle: !isActive, children: label }), jsx(Text, { className: "font-medium text-neutral-500", children: t("schedule.label.active") }), jsx(Checkbox, { checked: isActive, label: checkboxLabel, onChange: (event) => onActiveChange(Boolean(event.currentTarget.checked), index) }), jsx(Text, { className: "font-medium text-neutral-500", children: t("schedule.label.allDay") }), jsx(Checkbox, { checked: isAllDay ? isActive : undefined, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsx(TimeRange, { disabled: !isActive || isAllDay, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: range })] }), jsxs("div", { className: "max-sm:hidden sm:grid sm:grid-cols-[100px_200px_60px_250px_250px] sm:gap-2", children: [jsx(Checkbox, { checked: isActive, "data-testid": `${dataTestId}-${key}-checkbox`, label: checkboxLabel, onChange: (event) => onActiveChange(Boolean(event.currentTarget.checked), index) }), jsx(Text, { className: cvaScheduleItemText(), size: "medium", subtle: !isActive, children: label }), jsx(Checkbox, { checked: isAllDay ? isActive : undefined, "data-testid": `${dataTestId}-${key}-allday-checkbox`, disabled: !isActive, onChange: (event) => onAllDayChange(Boolean(event.currentTarget.checked), index) }), jsx(TimeRange, { "data-testid": `${dataTestId}-${key}-range`, disabled: !isActive || isAllDay, isInvalid: !!invalidKeys.find((invalidKey) => invalidKey === key), onChange: (newRange) => onRangeChange(newRange, index), range: isAllDay ? undefined : range })] })] }, key + label));
|
|
3821
3821
|
}) }));
|
|
3822
3822
|
};
|
|
@@ -4013,7 +4013,7 @@ const Search = ({ className, placeholder, value, widenInputOnFocus = false, hide
|
|
|
4013
4013
|
const { t } = useTranslation();
|
|
4014
4014
|
const generatedId = useId();
|
|
4015
4015
|
const inputId = id ?? `search-${generatedId}`;
|
|
4016
|
-
return (jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, id: inputId, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsx(Spinner, { centering: "centered", containerClassName: "!p-0", size: fieldSize })) : (jsx(Icon, { name: iconName, size: fieldSize })), ref: ref, suffix:
|
|
4016
|
+
return (jsx(TextBaseInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), "data-testid": dataTestId, disabled: disabled, fieldSize: fieldSize, id: inputId, inputClassName: inputClassName, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder ?? t("search.placeholder"), prefix: loading ? (jsx(Spinner, { centering: "centered", containerClassName: "!p-0", size: fieldSize })) : (jsx(Icon, { name: iconName, size: fieldSize })), ref: ref, style: style, suffix:
|
|
4017
4017
|
//only show the clear button if there is a value and the onClear function is provided
|
|
4018
4018
|
onClear && value ? (jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
|
|
4019
4019
|
onClear();
|
|
@@ -4024,7 +4024,7 @@ Search.displayName = "Search";
|
|
|
4024
4024
|
/**
|
|
4025
4025
|
*
|
|
4026
4026
|
*/
|
|
4027
|
-
const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = false, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, required = false, ...rest }) => {
|
|
4027
|
+
const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid = false, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, style, ref, required = false, ...rest }) => {
|
|
4028
4028
|
const isFirstRender = useIsFirstRender();
|
|
4029
4029
|
const [innerValue, setInnerValue] = useState(value ?? defaultValue);
|
|
4030
4030
|
const onChangeRef = useRef(onChange);
|
|
@@ -4078,7 +4078,8 @@ const FormFieldSelectAdapter = ({ className, "data-testid": dataTestId, helpText
|
|
|
4078
4078
|
helpAddon,
|
|
4079
4079
|
tip,
|
|
4080
4080
|
label,
|
|
4081
|
-
required: required ? !Boolean(rest.disabled ?? rest.readOnly) : false,
|
|
4081
|
+
required: required ? !Boolean(rest.disabled ?? rest.readOnly) : false,
|
|
4082
|
+
style, children: [jsx("select", { onChange, ref: innerRef, name, value: innerValue, hidden: true, children: optionsWithCurrentSelectionBackupOption.map(option => {
|
|
4082
4083
|
return (jsx("option", { value: option.value, children: option.label }, option.value));
|
|
4083
4084
|
}) }), children({
|
|
4084
4085
|
...rest,
|
|
@@ -4378,10 +4379,10 @@ TextField.displayName = "TextField";
|
|
|
4378
4379
|
* @param {TimeRangeFieldProps} props - The props for the TimeRangeField component
|
|
4379
4380
|
* @returns {ReactElement} TimeRangeField component
|
|
4380
4381
|
*/
|
|
4381
|
-
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid = undefined, errorMessage, label, tip, children, helpText, id, ref, ...rest }) => {
|
|
4382
|
+
const TimeRangeField = ({ className, "data-testid": dataTestId, onChange, isInvalid = undefined, errorMessage, label, tip, children, helpText, id, style, ref, ...rest }) => {
|
|
4382
4383
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
4383
4384
|
const htmlFor = id ? id : "timeRangeField-" + uuidv4();
|
|
4384
|
-
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, ref: ref, tip: tip, children: jsx(TimeRange, { className: className, "data-testid": dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
4385
|
+
return (jsx(FormGroup, { "data-testid": dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, ref: ref, style: style, tip: tip, children: jsx(TimeRange, { className: className, "data-testid": dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
4385
4386
|
};
|
|
4386
4387
|
|
|
4387
4388
|
const cvaToggleSwitchWrapper = cvaMerge(["grid", "grid-cols-[auto]", "items-center"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.2",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react-calendar": "^6.0.0",
|
|
11
11
|
"react-select": "^5.10.2",
|
|
12
|
-
"@trackunit/date-and-time-utils": "1.13.
|
|
12
|
+
"@trackunit/date-and-time-utils": "1.13.1",
|
|
13
13
|
"usehooks-ts": "^3.1.0",
|
|
14
14
|
"libphonenumber-js": "^1.12.22",
|
|
15
15
|
"zod": "^3.25.76",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/css-class-variance-utilities": "1.13.
|
|
18
|
-
"@trackunit/react-components": "1.24.
|
|
19
|
-
"@trackunit/ui-icons": "1.13.
|
|
20
|
-
"@trackunit/shared-utils": "1.15.
|
|
21
|
-
"@trackunit/ui-design-tokens": "1.13.
|
|
22
|
-
"@trackunit/i18n-library-translation": "1.21.
|
|
17
|
+
"@trackunit/css-class-variance-utilities": "1.13.1",
|
|
18
|
+
"@trackunit/react-components": "1.24.1",
|
|
19
|
+
"@trackunit/ui-icons": "1.13.1",
|
|
20
|
+
"@trackunit/shared-utils": "1.15.1",
|
|
21
|
+
"@trackunit/ui-design-tokens": "1.13.1",
|
|
22
|
+
"@trackunit/i18n-library-translation": "1.21.1",
|
|
23
23
|
"string-ts": "^2.0.0",
|
|
24
24
|
"es-toolkit": "^1.39.10"
|
|
25
25
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ButtonCommonProps, CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { ButtonCommonProps, CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { RefObject } from "react";
|
|
3
3
|
export type ActionType = "PHONE_NUMBER" | "WEB_ADDRESS" | "EMAIL" | "COPY" | "EDIT";
|
|
4
|
-
interface AbstractActionButtonProps extends ButtonCommonProps, CommonProps, Refable<HTMLDivElement
|
|
4
|
+
interface AbstractActionButtonProps extends ButtonCommonProps, CommonProps, Refable<HTMLDivElement>, Styleable {
|
|
5
5
|
/**
|
|
6
6
|
* The type of action performed when clicking the button.
|
|
7
7
|
*/
|
|
@@ -48,5 +48,5 @@ type ActionButtonProps = CopyActionButtonProps | GenericActionButtonProps | Edit
|
|
|
48
48
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
49
49
|
* @returns {ReactElement} ActionButton component
|
|
50
50
|
*/
|
|
51
|
-
export declare const ActionButton: ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, ref, }: ActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export declare const ActionButton: ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, style, ref, }: ActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
52
52
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
export interface FormGroupProps extends CommonProps, Refable<HTMLDivElement
|
|
3
|
+
export interface FormGroupProps extends CommonProps, Refable<HTMLDivElement>, Styleable {
|
|
4
4
|
/**
|
|
5
5
|
* The label for the form group.
|
|
6
6
|
*/
|
|
@@ -69,4 +69,4 @@ export interface FormGroupProps extends CommonProps, Refable<HTMLDivElement> {
|
|
|
69
69
|
* @param {FormGroupProps} props - The props for the FormGroup component
|
|
70
70
|
* @returns {ReactElement} FormGroup component
|
|
71
71
|
*/
|
|
72
|
-
export declare const FormGroup: ({ isInvalid, isWarning, helpText, helpAddon, tip, className, "data-testid": dataTestId, label, htmlFor, children, required, ref, }: FormGroupProps) => ReactElement;
|
|
72
|
+
export declare const FormGroup: ({ isInvalid, isWarning, helpText, helpAddon, tip, className, "data-testid": dataTestId, label, htmlFor, children, required, style, ref, }: FormGroupProps) => ReactElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
export interface LabelProps extends CommonProps, Refable<HTMLLabelElement
|
|
3
|
+
export interface LabelProps extends CommonProps, Refable<HTMLLabelElement>, Styleable {
|
|
4
4
|
/**
|
|
5
5
|
* ID of the label.
|
|
6
6
|
*/
|
|
@@ -38,4 +38,4 @@ export interface LabelProps extends CommonProps, Refable<HTMLLabelElement> {
|
|
|
38
38
|
* @param {LabelProps} props - The props for the Label component
|
|
39
39
|
* @returns {ReactElement} Label component
|
|
40
40
|
*/
|
|
41
|
-
export declare const Label: ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled, isInvalid, ref, }: LabelProps) => ReactElement;
|
|
41
|
+
export declare const Label: ({ id, htmlFor, children, className, "data-testid": dataTestId, disabled, isInvalid, style, ref, }: LabelProps) => ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
3
3
|
import { FocusEvent, ReactElement, ReactNode } from "react";
|
|
4
4
|
import { GroupBase, InputActionMeta, MultiValue } from "react-select";
|
|
@@ -19,7 +19,7 @@ import { BaseOptionType } from "../SelectField/FormFieldSelectAdapter";
|
|
|
19
19
|
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon" | "isInvalid">;
|
|
20
20
|
/** Allow all BaseSelect props except those we adapt/wrap here */
|
|
21
21
|
type SelectExposedProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false, TGroup extends GroupBase<TOption> = GroupBase<TOption>> = MappedOmit<SelectProps<TOption, TIsAsync, true, TGroup>, "label" | "hasError" | "onBlur" | "options" | "value" | "defaultValue" | "onChange" | "isMulti" | "id">;
|
|
22
|
-
export interface MultiSelectFieldProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false, TGroup extends GroupBase<TOption> = GroupBase<TOption>> extends CommonProps, FormGroupExposedProps, SelectExposedProps<TOption, TIsAsync, TGroup>, Refable<HTMLSelectElement
|
|
22
|
+
export interface MultiSelectFieldProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false, TGroup extends GroupBase<TOption> = GroupBase<TOption>> extends CommonProps, FormGroupExposedProps, SelectExposedProps<TOption, TIsAsync, TGroup>, Refable<HTMLSelectElement>, Styleable {
|
|
23
23
|
/** RHF/native-friendly blur signature */
|
|
24
24
|
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
25
25
|
/** Options to render (same shape as BaseSelect) */
|
|
@@ -98,6 +98,6 @@ export interface RadioGroupProps<TValue extends string | number> extends CommonP
|
|
|
98
98
|
* @returns {ReactElement} RadioGroup component
|
|
99
99
|
*/
|
|
100
100
|
export declare const RadioGroup: {
|
|
101
|
-
<TValue extends string | number = string>({ children, id, name, value, disabled, onChange, label, inline, className, "data-testid": dataTestId, isInvalid, ref, }: RadioGroupProps<TValue>): ReactElement;
|
|
101
|
+
<TValue extends string | number = string>({ children, id, name, value, disabled, onChange, label, inline, className, "data-testid": dataTestId, isInvalid, style, ref, }: RadioGroupProps<TValue>): ReactElement;
|
|
102
102
|
displayName: string;
|
|
103
103
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { TimeRangeInput } from "../TimeRange/TimeRange";
|
|
3
3
|
export interface ScheduleItem {
|
|
4
4
|
/**
|
|
@@ -26,7 +26,7 @@ export interface ScheduleItem {
|
|
|
26
26
|
*/
|
|
27
27
|
checkboxLabel?: string;
|
|
28
28
|
}
|
|
29
|
-
export interface ScheduleProps extends CommonProps, Refable<HTMLDivElement
|
|
29
|
+
export interface ScheduleProps extends CommonProps, Refable<HTMLDivElement>, Styleable {
|
|
30
30
|
/**
|
|
31
31
|
* List of schedule rows.
|
|
32
32
|
*/
|
|
@@ -72,4 +72,4 @@ export interface ScheduleProps extends CommonProps, Refable<HTMLDivElement> {
|
|
|
72
72
|
* @param {ScheduleProps} props - The props for the Schedule component
|
|
73
73
|
* @returns {ReactElement} Schedule component
|
|
74
74
|
*/
|
|
75
|
-
export declare const Schedule: ({ className, "data-testid": dataTestId, schedule, onChange, invalidKeys, ref, }: ScheduleProps) => import("react/jsx-runtime").JSX.Element;
|
|
75
|
+
export declare const Schedule: ({ className, "data-testid": dataTestId, schedule, onChange, invalidKeys, style, ref, }: ScheduleProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
3
3
|
import { FocusEvent, ReactElement, ReactNode } from "react";
|
|
4
4
|
import { GroupBase } from "react-select";
|
|
@@ -10,7 +10,7 @@ export type BaseOptionType = {
|
|
|
10
10
|
};
|
|
11
11
|
type SelectExposedProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false> = MappedOmit<SelectProps<TOption, TIsAsync, false, GroupBase<TOption>>, "value" | "label" | "onChange" | "defaultValue" | "onBlur" | "options">;
|
|
12
12
|
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon" | "isInvalid">;
|
|
13
|
-
export interface SelectFieldProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false> extends CommonProps, FormGroupExposedProps, SelectExposedProps<TOption, TIsAsync>, Refable<HTMLSelectElement
|
|
13
|
+
export interface SelectFieldProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false> extends CommonProps, FormGroupExposedProps, SelectExposedProps<TOption, TIsAsync>, Refable<HTMLSelectElement>, Styleable {
|
|
14
14
|
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
15
15
|
/**
|
|
16
16
|
* The options available for the SelectField.
|
|
@@ -48,7 +48,7 @@ interface FormFieldSelectAdapterProps<TOption extends BaseOptionType = BaseOptio
|
|
|
48
48
|
*
|
|
49
49
|
*/
|
|
50
50
|
export declare const FormFieldSelectAdapter: {
|
|
51
|
-
<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false>({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, ref, required, ...rest }: FormFieldSelectAdapterProps<TOption, TIsAsync>): ReactElement;
|
|
51
|
+
<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false>({ className, "data-testid": dataTestId, helpText, helpAddon, tip, label, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, htmlFor: htmlForProp, onChange, children, style, ref, required, ...rest }: FormFieldSelectAdapterProps<TOption, TIsAsync>): ReactElement;
|
|
52
52
|
displayName: string;
|
|
53
53
|
};
|
|
54
54
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
3
|
export interface TimeRangeInput {
|
|
4
4
|
/**
|
|
@@ -10,7 +10,7 @@ export interface TimeRangeInput {
|
|
|
10
10
|
*/
|
|
11
11
|
timeTo: string;
|
|
12
12
|
}
|
|
13
|
-
export interface TimeRangeProps extends CommonProps, Refable<HTMLDivElement
|
|
13
|
+
export interface TimeRangeProps extends CommonProps, Refable<HTMLDivElement>, Styleable {
|
|
14
14
|
/**
|
|
15
15
|
* Unique element identifier.
|
|
16
16
|
*/
|
|
@@ -67,5 +67,5 @@ export interface TimeRangeProps extends CommonProps, Refable<HTMLDivElement> {
|
|
|
67
67
|
* @param {TimeRangeProps} props - The props for the TimeRange component
|
|
68
68
|
* @returns {ReactElement} TimeRange component
|
|
69
69
|
*/
|
|
70
|
-
export declare const TimeRange: ({ id, className, "data-testid": dataTestId, children, range, onChange, disabled, isInvalid, ref, }: TimeRangeProps) => import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
export declare const TimeRange: ({ id, className, "data-testid": dataTestId, children, range, onChange, disabled, isInvalid, style, ref, }: TimeRangeProps) => import("react/jsx-runtime").JSX.Element;
|
|
71
71
|
export declare const DEFAULT_TIME = "12:00";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Refable } from "@trackunit/react-components";
|
|
1
|
+
import { Refable, type Styleable } from "@trackunit/react-components";
|
|
2
2
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
3
3
|
import { TimeRangeProps } from "../TimeRange/TimeRange";
|
|
4
4
|
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
|
|
5
|
-
export interface TimeRangeFieldProps extends TimeRangeProps, FormGroupExposedProps, Refable<HTMLDivElement
|
|
5
|
+
export interface TimeRangeFieldProps extends TimeRangeProps, FormGroupExposedProps, Refable<HTMLDivElement>, Styleable {
|
|
6
6
|
/**
|
|
7
7
|
* If a value is set, the field is rendered in its invalid state.
|
|
8
8
|
*/
|
|
@@ -47,5 +47,5 @@ export interface TimeRangeFieldProps extends TimeRangeProps, FormGroupExposedPro
|
|
|
47
47
|
* @param {TimeRangeFieldProps} props - The props for the TimeRangeField component
|
|
48
48
|
* @returns {ReactElement} TimeRangeField component
|
|
49
49
|
*/
|
|
50
|
-
export declare const TimeRangeField: ({ className, "data-testid": dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, ref, ...rest }: TimeRangeFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare const TimeRangeField: ({ className, "data-testid": dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, style, ref, ...rest }: TimeRangeFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
51
51
|
export {};
|