@trackunit/react-form-components 1.14.51 → 1.14.54
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 +17 -15
- package/index.esm.js +19 -17
- package/package.json +7 -7
- package/src/components/ActionButton/ActionButton.d.ts +3 -3
- package/src/components/BaseInput/BaseInput.d.ts +3 -7
- package/src/components/BaseInput/components/PrefixRenderer.d.ts +6 -2
- package/src/components/Checkbox/Checkbox.d.ts +3 -7
- package/src/components/CheckboxField/CheckboxField.d.ts +1 -5
- package/src/components/ColorField/ColorField.d.ts +4 -1
- package/src/components/DateField/DateField.d.ts +0 -5
- package/src/components/MultiSelectField/FormFieldSelectAdapterMulti.d.ts +4 -6
- package/src/components/NumberField/NumberBaseInput/NumberBaseInput.d.ts +1 -3
- package/src/components/NumberField/NumberField.d.ts +0 -5
- package/src/components/OptionCard/OptionCard.d.ts +3 -7
- package/src/components/PasswordField/PasswordField.d.ts +0 -5
- package/src/components/PhoneField/PhoneField.d.ts +0 -5
- package/src/components/PhoneFieldWithController/PhoneFieldWithController.d.ts +0 -5
- package/src/components/Search/Search.d.ts +1 -5
- package/src/components/SelectField/FormFieldSelectAdapter.d.ts +4 -8
- package/src/components/TextAreaField/TextArea/TextAreaBaseInput.d.ts +3 -7
- package/src/components/TextAreaField/TextAreaField.d.ts +0 -5
- package/src/components/TextField/TextBaseInput/TextBaseInput.d.ts +1 -3
- package/src/components/ToggleSwitch/ToggleSwitch.d.ts +7 -4
- package/src/components/ToggleSwitchOption/ToggleSwitchOption.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -319,7 +319,7 @@ const cvaActionContainer = cssClassVarianceUtilities.cvaMerge(["flex", "items-ce
|
|
|
319
319
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
320
320
|
* @returns {ReactElement} ActionButton component
|
|
321
321
|
*/
|
|
322
|
-
const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, }) => {
|
|
322
|
+
const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, ref, }) => {
|
|
323
323
|
const [, copyToClipboard] = usehooksTs.useCopyToClipboard();
|
|
324
324
|
const getIconName = () => {
|
|
325
325
|
switch (type) {
|
|
@@ -358,7 +358,7 @@ const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled,
|
|
|
358
358
|
}
|
|
359
359
|
};
|
|
360
360
|
const adjustedIconSize = size === "large" ? "medium" : size;
|
|
361
|
-
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className, size }), 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" }) }));
|
|
361
|
+
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" }) }));
|
|
362
362
|
};
|
|
363
363
|
|
|
364
364
|
const GenericActionsRenderer = ({ genericAction, disabled, fieldSize, innerRef, tooltipLabel, }) => {
|
|
@@ -396,8 +396,10 @@ const LockReasonRenderer = ({ lockReason, "data-testid": dataTestId, }) => {
|
|
|
396
396
|
return (jsxRuntime.jsx("div", { className: cvaInputSuffix({ disabled: false }), "data-testid": dataTestId ? `${dataTestId}-locked` : undefined, children: jsxRuntime.jsx(InputLockReasonTooltip, { ...lockReason }) }));
|
|
397
397
|
};
|
|
398
398
|
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
/**
|
|
400
|
+
* Renders the prefix element or falls back to a default prefix for certain types.
|
|
401
|
+
*/
|
|
402
|
+
const PrefixRenderer = ({ prefix, type, "data-testid": dataTestId, disabled, ref }) => {
|
|
401
403
|
// Default icons for specific input types
|
|
402
404
|
const defaultPrefixMap = {
|
|
403
405
|
email: jsxRuntime.jsx(reactComponents.Icon, { name: "AtSymbol", size: "small" }),
|
|
@@ -410,7 +412,7 @@ const PrefixRenderer = react.forwardRef(({ prefix, type, "data-testid": dataTest
|
|
|
410
412
|
return null;
|
|
411
413
|
}
|
|
412
414
|
return (jsxRuntime.jsx("div", { className: cvaInputPrefix({ disabled }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, ref: ref, children: resolvedPrefix }));
|
|
413
|
-
}
|
|
415
|
+
};
|
|
414
416
|
|
|
415
417
|
// Renders the suffix element or shows an icon if invalid/warning
|
|
416
418
|
const SuffixRenderer = ({ suffix, isInvalid, isWarning, "data-testid": dataTestId, disabled, }) => {
|
|
@@ -2230,12 +2232,12 @@ const isValidHEXColor = (value) => {
|
|
|
2230
2232
|
* />
|
|
2231
2233
|
* ```
|
|
2232
2234
|
*/
|
|
2233
|
-
const ColorField =
|
|
2235
|
+
const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid, onBlur, fieldSize = "medium", style, disabled, readOnly, isWarning, inputClassName, ref, ...inputProps }) => {
|
|
2234
2236
|
const renderAsDisabled = Boolean(disabled);
|
|
2235
2237
|
const renderAsReadonly = Boolean(readOnly);
|
|
2236
2238
|
const htmlForId = react.useMemo(() => (id ? id : "colorField-" + sharedUtils.uuidv4()), [id]);
|
|
2237
2239
|
const innerRef = react.useRef(null);
|
|
2238
|
-
|
|
2240
|
+
const mergedRef = reactComponents.useMergeRefs([ref, innerRef]);
|
|
2239
2241
|
const [t] = useTranslation();
|
|
2240
2242
|
// Internal state for color value
|
|
2241
2243
|
const [innerValue, setInnerValue] = react.useState(propValue ?? defaultValue ?? "");
|
|
@@ -2280,10 +2282,10 @@ const ColorField = react.forwardRef(({ label, id, tip, helpText, errorMessage, h
|
|
|
2280
2282
|
readOnly: renderAsReadonly,
|
|
2281
2283
|
isWarning,
|
|
2282
2284
|
className,
|
|
2283
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label", className: cvaInputColorField({ readOnly: renderAsReadonly }), "data-testid": dataTestId, defaultValue: defaultValue, disabled: renderAsDisabled, id: htmlForId, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, ref:
|
|
2285
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label", className: cvaInputColorField({ readOnly: renderAsReadonly }), "data-testid": dataTestId, defaultValue: defaultValue, disabled: renderAsDisabled, id: htmlForId, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, ref: mergedRef, type: "color", value: innerValue }), jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputElement({
|
|
2284
2286
|
className: tailwindMerge.twMerge("focus-visible:outline-hidden px-1", inputClassName),
|
|
2285
2287
|
}), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, disabled: renderAsDisabled, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, type: "text", value: innerValue, ...inputProps }), jsxRuntime.jsx(GenericActionsRenderer, { disabled: renderAsDisabled || renderAsReadonly, fieldSize: fieldSize, genericAction: "edit", innerRef: innerRef, tooltipLabel: t("colorField.tooltip") })] }) }));
|
|
2286
|
-
}
|
|
2288
|
+
};
|
|
2287
2289
|
ColorField.displayName = "ColorField";
|
|
2288
2290
|
|
|
2289
2291
|
/**
|
|
@@ -4245,9 +4247,9 @@ const cvaToggleSwitchThumb = cssClassVarianceUtilities.cvaMerge(["block", "round
|
|
|
4245
4247
|
* @param {ToggleSwitchProps} props - The props for the ToggleSwitch component
|
|
4246
4248
|
* @returns {ReactElement} ToggleSwitch component
|
|
4247
4249
|
*/
|
|
4248
|
-
const ToggleSwitch =
|
|
4250
|
+
const ToggleSwitch = ({ onChange, onClick, preventDefaultOnClick, className, "data-testid": dataTestId = "toggle-switch", showInputFocus, toggled, size = "medium", tabIndex = 0, readOnly, disabled, ref, ...rest }) => {
|
|
4249
4251
|
const localInputRef = react.useRef(null);
|
|
4250
|
-
const
|
|
4252
|
+
const mergedRef = reactComponents.useMergeRefs([ref, localInputRef]);
|
|
4251
4253
|
// Extract data attributes to apply to wrapper
|
|
4252
4254
|
const dataAttributes = react.useMemo(() => Object.keys(rest).reduce((acc, key) => {
|
|
4253
4255
|
if (key.startsWith("data-")) {
|
|
@@ -4260,7 +4262,7 @@ const ToggleSwitch = react.forwardRef(({ onChange, onClick, preventDefaultOnClic
|
|
|
4260
4262
|
// Prevents double-toggling when wrapped in a label or if preventDefaultOnClick is true
|
|
4261
4263
|
const isFromLabel = e.target instanceof Element && e.target.closest("label");
|
|
4262
4264
|
if (!isFromLabel && !preventDefaultOnClick && !disabled && !readOnly) {
|
|
4263
|
-
|
|
4265
|
+
localInputRef.current?.click();
|
|
4264
4266
|
}
|
|
4265
4267
|
onClick?.(e);
|
|
4266
4268
|
};
|
|
@@ -4268,7 +4270,7 @@ const ToggleSwitch = react.forwardRef(({ onChange, onClick, preventDefaultOnClic
|
|
|
4268
4270
|
if (e.code === "Enter") {
|
|
4269
4271
|
e.preventDefault();
|
|
4270
4272
|
if (!readOnly) {
|
|
4271
|
-
|
|
4273
|
+
localInputRef.current?.click();
|
|
4272
4274
|
}
|
|
4273
4275
|
}
|
|
4274
4276
|
// Space key is already supported natively by the input element
|
|
@@ -4285,8 +4287,8 @@ const ToggleSwitch = react.forwardRef(({ onChange, onClick, preventDefaultOnClic
|
|
|
4285
4287
|
disabled: disabled || readOnly,
|
|
4286
4288
|
size,
|
|
4287
4289
|
focused: showInputFocus,
|
|
4288
|
-
}), "data-testid": `${dataTestId}-track`, children: [jsxRuntime.jsx("span", { className: cvaToggleSwitchThumb({ toggled, size }), "data-testid": `${dataTestId}-thumb` }), jsxRuntime.jsx("input", { "aria-disabled": disabled || readOnly, checked: toggled, className: cvaToggleSwitchInput(), "data-testid": `${dataTestId}-input`, disabled: disabled, onChange: handleInputChange, onClick: e => e.stopPropagation(), ref:
|
|
4289
|
-
}
|
|
4290
|
+
}), "data-testid": `${dataTestId}-track`, children: [jsxRuntime.jsx("span", { className: cvaToggleSwitchThumb({ toggled, size }), "data-testid": `${dataTestId}-thumb` }), jsxRuntime.jsx("input", { "aria-disabled": disabled || readOnly, checked: toggled, className: cvaToggleSwitchInput(), "data-testid": `${dataTestId}-input`, disabled: disabled, onChange: handleInputChange, onClick: e => e.stopPropagation(), ref: mergedRef, role: "switch", tabIndex: tabIndex, type: "checkbox", ...rest })] }) }));
|
|
4291
|
+
};
|
|
4290
4292
|
ToggleSwitch.displayName = "ToggleSwitch";
|
|
4291
4293
|
|
|
4292
4294
|
/**
|
package/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { registerTranslations, useNamespaceTranslation, NamespaceTrans } from '@trackunit/i18n-library-translation';
|
|
3
3
|
import { Temporal } from '@js-temporal/polyfill';
|
|
4
4
|
import { IconButton, Icon, Tooltip, cvaMenu, cvaMenuList, Tag, useIsTextTruncated, ZStack, MenuItem, useMeasure, useDebounce, useMergeRefs, Spinner, useScrollBlock, Text, Heading, useIsFirstRender } from '@trackunit/react-components';
|
|
5
5
|
import { themeSpacing } from '@trackunit/ui-design-tokens';
|
|
6
|
-
import {
|
|
6
|
+
import { useRef, useEffect, useImperativeHandle, useCallback, useState, cloneElement, isValidElement, useLayoutEffect, useReducer, useMemo, createContext, useContext, useId } from 'react';
|
|
7
7
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
8
8
|
import { titleCase } from 'string-ts';
|
|
9
9
|
import { useCopyToClipboard } from 'usehooks-ts';
|
|
@@ -318,7 +318,7 @@ const cvaActionContainer = cvaMerge(["flex", "items-center"], {
|
|
|
318
318
|
* @param {ActionButtonProps} props - The props for the ActionButton component
|
|
319
319
|
* @returns {ReactElement} ActionButton component
|
|
320
320
|
*/
|
|
321
|
-
const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, }) => {
|
|
321
|
+
const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, ref, }) => {
|
|
322
322
|
const [, copyToClipboard] = useCopyToClipboard();
|
|
323
323
|
const getIconName = () => {
|
|
324
324
|
switch (type) {
|
|
@@ -357,7 +357,7 @@ const ActionButton = ({ type, value, "data-testid": dataTestId, size, disabled,
|
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
const adjustedIconSize = size === "large" ? "medium" : size;
|
|
360
|
-
return (jsx("div", { className: cvaActionContainer({ className, size }), 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" }) }));
|
|
360
|
+
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" }) }));
|
|
361
361
|
};
|
|
362
362
|
|
|
363
363
|
const GenericActionsRenderer = ({ genericAction, disabled, fieldSize, innerRef, tooltipLabel, }) => {
|
|
@@ -395,8 +395,10 @@ const LockReasonRenderer = ({ lockReason, "data-testid": dataTestId, }) => {
|
|
|
395
395
|
return (jsx("div", { className: cvaInputSuffix({ disabled: false }), "data-testid": dataTestId ? `${dataTestId}-locked` : undefined, children: jsx(InputLockReasonTooltip, { ...lockReason }) }));
|
|
396
396
|
};
|
|
397
397
|
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
/**
|
|
399
|
+
* Renders the prefix element or falls back to a default prefix for certain types.
|
|
400
|
+
*/
|
|
401
|
+
const PrefixRenderer = ({ prefix, type, "data-testid": dataTestId, disabled, ref }) => {
|
|
400
402
|
// Default icons for specific input types
|
|
401
403
|
const defaultPrefixMap = {
|
|
402
404
|
email: jsx(Icon, { name: "AtSymbol", size: "small" }),
|
|
@@ -409,7 +411,7 @@ const PrefixRenderer = forwardRef(({ prefix, type, "data-testid": dataTestId, di
|
|
|
409
411
|
return null;
|
|
410
412
|
}
|
|
411
413
|
return (jsx("div", { className: cvaInputPrefix({ disabled }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, ref: ref, children: resolvedPrefix }));
|
|
412
|
-
}
|
|
414
|
+
};
|
|
413
415
|
|
|
414
416
|
// Renders the suffix element or shows an icon if invalid/warning
|
|
415
417
|
const SuffixRenderer = ({ suffix, isInvalid, isWarning, "data-testid": dataTestId, disabled, }) => {
|
|
@@ -2229,12 +2231,12 @@ const isValidHEXColor = (value) => {
|
|
|
2229
2231
|
* />
|
|
2230
2232
|
* ```
|
|
2231
2233
|
*/
|
|
2232
|
-
const ColorField =
|
|
2234
|
+
const ColorField = ({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid, onBlur, fieldSize = "medium", style, disabled, readOnly, isWarning, inputClassName, ref, ...inputProps }) => {
|
|
2233
2235
|
const renderAsDisabled = Boolean(disabled);
|
|
2234
2236
|
const renderAsReadonly = Boolean(readOnly);
|
|
2235
2237
|
const htmlForId = useMemo(() => (id ? id : "colorField-" + uuidv4()), [id]);
|
|
2236
2238
|
const innerRef = useRef(null);
|
|
2237
|
-
|
|
2239
|
+
const mergedRef = useMergeRefs([ref, innerRef]);
|
|
2238
2240
|
const [t] = useTranslation();
|
|
2239
2241
|
// Internal state for color value
|
|
2240
2242
|
const [innerValue, setInnerValue] = useState(propValue ?? defaultValue ?? "");
|
|
@@ -2279,10 +2281,10 @@ const ColorField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAdd
|
|
|
2279
2281
|
readOnly: renderAsReadonly,
|
|
2280
2282
|
isWarning,
|
|
2281
2283
|
className,
|
|
2282
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsx("input", { "aria-labelledby": htmlForId + "-label", className: cvaInputColorField({ readOnly: renderAsReadonly }), "data-testid": dataTestId, defaultValue: defaultValue, disabled: renderAsDisabled, id: htmlForId, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, ref:
|
|
2284
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsx("input", { "aria-labelledby": htmlForId + "-label", className: cvaInputColorField({ readOnly: renderAsReadonly }), "data-testid": dataTestId, defaultValue: defaultValue, disabled: renderAsDisabled, id: htmlForId, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, ref: mergedRef, type: "color", value: innerValue }), jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputElement({
|
|
2283
2285
|
className: twMerge("focus-visible:outline-hidden px-1", inputClassName),
|
|
2284
2286
|
}), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, disabled: renderAsDisabled, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, type: "text", value: innerValue, ...inputProps }), jsx(GenericActionsRenderer, { disabled: renderAsDisabled || renderAsReadonly, fieldSize: fieldSize, genericAction: "edit", innerRef: innerRef, tooltipLabel: t("colorField.tooltip") })] }) }));
|
|
2285
|
-
}
|
|
2287
|
+
};
|
|
2286
2288
|
ColorField.displayName = "ColorField";
|
|
2287
2289
|
|
|
2288
2290
|
/**
|
|
@@ -4244,9 +4246,9 @@ const cvaToggleSwitchThumb = cvaMerge(["block", "rounded-full", "bg-white", "asp
|
|
|
4244
4246
|
* @param {ToggleSwitchProps} props - The props for the ToggleSwitch component
|
|
4245
4247
|
* @returns {ReactElement} ToggleSwitch component
|
|
4246
4248
|
*/
|
|
4247
|
-
const ToggleSwitch =
|
|
4249
|
+
const ToggleSwitch = ({ onChange, onClick, preventDefaultOnClick, className, "data-testid": dataTestId = "toggle-switch", showInputFocus, toggled, size = "medium", tabIndex = 0, readOnly, disabled, ref, ...rest }) => {
|
|
4248
4250
|
const localInputRef = useRef(null);
|
|
4249
|
-
const
|
|
4251
|
+
const mergedRef = useMergeRefs([ref, localInputRef]);
|
|
4250
4252
|
// Extract data attributes to apply to wrapper
|
|
4251
4253
|
const dataAttributes = useMemo(() => Object.keys(rest).reduce((acc, key) => {
|
|
4252
4254
|
if (key.startsWith("data-")) {
|
|
@@ -4259,7 +4261,7 @@ const ToggleSwitch = forwardRef(({ onChange, onClick, preventDefaultOnClick, cla
|
|
|
4259
4261
|
// Prevents double-toggling when wrapped in a label or if preventDefaultOnClick is true
|
|
4260
4262
|
const isFromLabel = e.target instanceof Element && e.target.closest("label");
|
|
4261
4263
|
if (!isFromLabel && !preventDefaultOnClick && !disabled && !readOnly) {
|
|
4262
|
-
|
|
4264
|
+
localInputRef.current?.click();
|
|
4263
4265
|
}
|
|
4264
4266
|
onClick?.(e);
|
|
4265
4267
|
};
|
|
@@ -4267,7 +4269,7 @@ const ToggleSwitch = forwardRef(({ onChange, onClick, preventDefaultOnClick, cla
|
|
|
4267
4269
|
if (e.code === "Enter") {
|
|
4268
4270
|
e.preventDefault();
|
|
4269
4271
|
if (!readOnly) {
|
|
4270
|
-
|
|
4272
|
+
localInputRef.current?.click();
|
|
4271
4273
|
}
|
|
4272
4274
|
}
|
|
4273
4275
|
// Space key is already supported natively by the input element
|
|
@@ -4284,8 +4286,8 @@ const ToggleSwitch = forwardRef(({ onChange, onClick, preventDefaultOnClick, cla
|
|
|
4284
4286
|
disabled: disabled || readOnly,
|
|
4285
4287
|
size,
|
|
4286
4288
|
focused: showInputFocus,
|
|
4287
|
-
}), "data-testid": `${dataTestId}-track`, children: [jsx("span", { className: cvaToggleSwitchThumb({ toggled, size }), "data-testid": `${dataTestId}-thumb` }), jsx("input", { "aria-disabled": disabled || readOnly, checked: toggled, className: cvaToggleSwitchInput(), "data-testid": `${dataTestId}-input`, disabled: disabled, onChange: handleInputChange, onClick: e => e.stopPropagation(), ref:
|
|
4288
|
-
}
|
|
4289
|
+
}), "data-testid": `${dataTestId}-track`, children: [jsx("span", { className: cvaToggleSwitchThumb({ toggled, size }), "data-testid": `${dataTestId}-thumb` }), jsx("input", { "aria-disabled": disabled || readOnly, checked: toggled, className: cvaToggleSwitchInput(), "data-testid": `${dataTestId}-input`, disabled: disabled, onChange: handleInputChange, onClick: e => e.stopPropagation(), ref: mergedRef, role: "switch", tabIndex: tabIndex, type: "checkbox", ...rest })] }) }));
|
|
4290
|
+
};
|
|
4289
4291
|
ToggleSwitch.displayName = "ToggleSwitch";
|
|
4290
4292
|
|
|
4291
4293
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.54",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"zod": "^3.23.8",
|
|
15
15
|
"react-hook-form": "7.62.0",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/css-class-variance-utilities": "1.11.
|
|
18
|
-
"@trackunit/react-components": "1.17.
|
|
19
|
-
"@trackunit/ui-icons": "1.11.
|
|
20
|
-
"@trackunit/shared-utils": "1.13.
|
|
21
|
-
"@trackunit/ui-design-tokens": "1.11.
|
|
22
|
-
"@trackunit/i18n-library-translation": "1.12.
|
|
17
|
+
"@trackunit/css-class-variance-utilities": "1.11.60",
|
|
18
|
+
"@trackunit/react-components": "1.17.48",
|
|
19
|
+
"@trackunit/ui-icons": "1.11.58",
|
|
20
|
+
"@trackunit/shared-utils": "1.13.60",
|
|
21
|
+
"@trackunit/ui-design-tokens": "1.11.59",
|
|
22
|
+
"@trackunit/i18n-library-translation": "1.12.51",
|
|
23
23
|
"string-ts": "^2.0.0",
|
|
24
24
|
"@js-temporal/polyfill": "^0.5.1",
|
|
25
25
|
"es-toolkit": "^1.39.10"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ButtonCommonProps, CommonProps } from "@trackunit/react-components";
|
|
1
|
+
import { ButtonCommonProps, CommonProps, Refable } 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 {
|
|
4
|
+
interface AbstractActionButtonProps extends ButtonCommonProps, CommonProps, Refable<HTMLDivElement> {
|
|
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, }: ActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export declare const ActionButton: ({ type, value, "data-testid": dataTestId, size, disabled, className, onClick, ref, }: ActionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
52
52
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { CommonProps } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
2
2
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
3
|
-
import { InputHTMLAttributes, ReactElement, ReactNode
|
|
3
|
+
import { InputHTMLAttributes, ReactElement, ReactNode } from "react";
|
|
4
4
|
import { FormComponentSizes } from "../../types";
|
|
5
5
|
import { LockedForReasons } from "./InputLockReasonTooltip";
|
|
6
6
|
import { BaseInputActionTypes } from "./components/GenericActionsRenderer";
|
|
7
7
|
type FilteredInputProps = MappedOmit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "disabled" | "readOnly">;
|
|
8
|
-
export interface BaseInputProps extends FilteredInputProps, CommonProps {
|
|
8
|
+
export interface BaseInputProps extends FilteredInputProps, CommonProps, Refable<HTMLInputElement> {
|
|
9
9
|
/**
|
|
10
10
|
* A React element to render before the text in the input.
|
|
11
11
|
*/
|
|
@@ -58,10 +58,6 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
|
|
|
58
58
|
* Flag or object to set the input as readOnly. If an object, shows a tooltip with the reason.
|
|
59
59
|
*/
|
|
60
60
|
readOnly?: boolean | LockedForReasons;
|
|
61
|
-
/**
|
|
62
|
-
* A ref for the component
|
|
63
|
-
*/
|
|
64
|
-
ref?: Ref<HTMLInputElement>;
|
|
65
61
|
}
|
|
66
62
|
/**
|
|
67
63
|
* A base input component that can be used for text inputs, password inputs, etc.
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { Refable } from "@trackunit/react-components";
|
|
1
2
|
import { HTMLInputTypeAttribute, ReactNode } from "react";
|
|
2
|
-
type PrefixRendererProps = {
|
|
3
|
+
type PrefixRendererProps = Refable<HTMLDivElement> & {
|
|
3
4
|
prefix?: ReactNode;
|
|
4
5
|
type?: HTMLInputTypeAttribute;
|
|
5
6
|
"data-testid"?: string;
|
|
6
7
|
disabled: boolean;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Renders the prefix element or falls back to a default prefix for certain types.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PrefixRenderer: ({ prefix, type, "data-testid": dataTestId, disabled, ref }: PrefixRendererProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
13
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CommonProps } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
2
2
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
3
|
-
import { InputHTMLAttributes, ReactNode
|
|
4
|
-
export interface CheckboxProps extends CommonProps, MappedOmit<InputHTMLAttributes<HTMLInputElement>, "prefix"> {
|
|
3
|
+
import { InputHTMLAttributes, ReactNode } from "react";
|
|
4
|
+
export interface CheckboxProps extends CommonProps, MappedOmit<InputHTMLAttributes<HTMLInputElement>, "prefix">, Refable<HTMLInputElement> {
|
|
5
5
|
/**
|
|
6
6
|
* A string element to be displayed as a label
|
|
7
7
|
*/
|
|
@@ -35,10 +35,6 @@ export interface CheckboxProps extends CommonProps, MappedOmit<InputHTMLAttribut
|
|
|
35
35
|
* An boolean flag to stop propagation of the click event
|
|
36
36
|
*/
|
|
37
37
|
stopPropagation?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* A ref for the component
|
|
40
|
-
*/
|
|
41
|
-
ref?: Ref<HTMLInputElement>;
|
|
42
38
|
}
|
|
43
39
|
/**
|
|
44
40
|
* Checkboxes are used when there are multiple items to select in a list. Users can select zero, one, or any number of items.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
import { CheckboxProps } from "../Checkbox/Checkbox";
|
|
3
3
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
4
4
|
type FormGroupExposedProps = Pick<FormGroupProps, "tip" | "helpText" | "helpAddon">;
|
|
@@ -8,10 +8,6 @@ export interface CheckboxFieldProps extends CheckboxProps, FormGroupExposedProps
|
|
|
8
8
|
* (distinct from the `label` prop which labels the overall form group).
|
|
9
9
|
*/
|
|
10
10
|
checkboxLabel?: string | ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
* A ref for the component.
|
|
13
|
-
*/
|
|
14
|
-
ref?: Ref<HTMLInputElement>;
|
|
15
11
|
}
|
|
16
12
|
/**
|
|
17
13
|
* CheckboxField is a form-ready checkbox that wraps a `Checkbox` inside a `FormGroup`.
|
|
@@ -53,5 +53,8 @@ export interface ColorFieldProps extends FormGroupExposedProps, ColorFieldBaseIn
|
|
|
53
53
|
* />
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
export declare const ColorField:
|
|
56
|
+
export declare const ColorField: {
|
|
57
|
+
({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, "data-testid": dataTestId, value: propValue, onChange, isInvalid, onBlur, fieldSize, style, disabled, readOnly, isWarning, inputClassName, ref, ...inputProps }: ColorFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
displayName: string;
|
|
59
|
+
};
|
|
57
60
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Ref } from "react";
|
|
2
1
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
3
2
|
import { DateBaseInputProps } from "./DateBaseInput/DateBaseInput";
|
|
4
3
|
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
|
|
@@ -7,10 +6,6 @@ export interface DateFieldProps extends DateBaseInputProps, FormGroupExposedProp
|
|
|
7
6
|
* If a value is set, the field is rendered in its invalid state.
|
|
8
7
|
*/
|
|
9
8
|
errorMessage?: string;
|
|
10
|
-
/**
|
|
11
|
-
* A ref for the component
|
|
12
|
-
*/
|
|
13
|
-
ref?: Ref<HTMLInputElement>;
|
|
14
9
|
}
|
|
15
10
|
/**
|
|
16
11
|
* The date field component is used for entering date values with a native date picker.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonProps } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
2
2
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
3
|
-
import { FocusEvent, ReactElement, ReactNode
|
|
3
|
+
import { FocusEvent, ReactElement, ReactNode } from "react";
|
|
4
4
|
import { GroupBase, InputActionMeta, MultiValue } from "react-select";
|
|
5
5
|
import { SelectProps } from "../BaseSelect/useSelect";
|
|
6
6
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
@@ -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
|
|
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> {
|
|
23
23
|
/** RHF/native-friendly blur signature */
|
|
24
24
|
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
25
25
|
/** Options to render (same shape as BaseSelect) */
|
|
@@ -34,15 +34,13 @@ export type MultiSelectFieldProps<TOption extends BaseOptionType = BaseOptionTyp
|
|
|
34
34
|
errorMessage?: string;
|
|
35
35
|
/** The htmlFor attribute for the label. If not provided, falls back to id or generates a unique value. */
|
|
36
36
|
htmlFor?: string;
|
|
37
|
-
/** External ref target (points to the hidden <select /> below) */
|
|
38
|
-
ref?: Ref<HTMLSelectElement>;
|
|
39
37
|
/** Name used for optional hidden inputs when `getOptionValue` is provided */
|
|
40
38
|
name?: string;
|
|
41
39
|
/** Field id; also propagated to BaseSelect via child props */
|
|
42
40
|
id?: string;
|
|
43
41
|
/** Optional passthrough onInputChange (will be called in addition to internal logic) */
|
|
44
42
|
onInputChange?: (value: string, meta: InputActionMeta) => void;
|
|
45
|
-
}
|
|
43
|
+
}
|
|
46
44
|
interface FormFieldSelectAdapterMultiProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false, TGroup extends GroupBase<TOption> = GroupBase<TOption>> extends MultiSelectFieldProps<TOption, TIsAsync, TGroup> {
|
|
47
45
|
/**
|
|
48
46
|
* Child render-prop receives exact BaseSelect props specialized for multi.
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { BaseInputProps } from "../../BaseInput/BaseInput";
|
|
2
|
-
type
|
|
3
|
-
export type NumberBaseInputProps = BaseInputExposedProps;
|
|
2
|
+
export type NumberBaseInputProps = Omit<BaseInputProps, "type">;
|
|
4
3
|
/**
|
|
5
4
|
* A thin wrapper around the `BaseInput` component for number input fields.
|
|
6
5
|
*
|
|
7
6
|
* NOTE: If shown with a label, please use the `NumberField` component instead.
|
|
8
7
|
*/
|
|
9
8
|
export declare const NumberBaseInput: ({ ref, ...rest }: NumberBaseInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Ref } from "react";
|
|
2
1
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
3
2
|
import { NumberBaseInputProps } from "./NumberBaseInput/NumberBaseInput";
|
|
4
3
|
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
|
|
@@ -7,10 +6,6 @@ export interface NumberFieldProps extends NumberBaseInputProps, FormGroupExposed
|
|
|
7
6
|
* If a value is set, the field is rendered in its invalid state.
|
|
8
7
|
*/
|
|
9
8
|
errorMessage?: string;
|
|
10
|
-
/**
|
|
11
|
-
* A ref for the component
|
|
12
|
-
*/
|
|
13
|
-
ref?: Ref<HTMLInputElement>;
|
|
14
9
|
}
|
|
15
10
|
/**
|
|
16
11
|
* The number field component is used for entering numeric values and includes controls for incrementally increasing or decreasing the value.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonProps, IconProps, TagProps } from "@trackunit/react-components";
|
|
2
|
-
import { InputHTMLAttributes, ReactElement, ReactNode
|
|
3
|
-
export interface OptionCardProps extends InputHTMLAttributes<HTMLInputElement>, CommonProps {
|
|
1
|
+
import { CommonProps, IconProps, Refable, TagProps } from "@trackunit/react-components";
|
|
2
|
+
import { InputHTMLAttributes, ReactElement, ReactNode } from "react";
|
|
3
|
+
export interface OptionCardProps extends InputHTMLAttributes<HTMLInputElement>, CommonProps, Refable<HTMLInputElement> {
|
|
4
4
|
/**
|
|
5
5
|
* Icon displayed at the top inside the OptionCard.
|
|
6
6
|
*/
|
|
@@ -25,10 +25,6 @@ export interface OptionCardProps extends InputHTMLAttributes<HTMLInputElement>,
|
|
|
25
25
|
* Styles for the OptionCard content.
|
|
26
26
|
*/
|
|
27
27
|
contentClassName?: string;
|
|
28
|
-
/**
|
|
29
|
-
* A ref for the component
|
|
30
|
-
*/
|
|
31
|
-
ref?: Ref<HTMLInputElement>;
|
|
32
28
|
/**
|
|
33
29
|
* The layout of the component.
|
|
34
30
|
*/
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Ref } from "react";
|
|
2
1
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
3
2
|
import { PasswordBaseInputProps } from "./PasswordBaseInput/PasswordBaseInput";
|
|
4
3
|
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
|
|
@@ -7,10 +6,6 @@ export interface PasswordFieldProps extends Omit<PasswordBaseInputProps, "obfusc
|
|
|
7
6
|
* If a value is set, the field is rendered in its invalid state.
|
|
8
7
|
*/
|
|
9
8
|
errorMessage?: string;
|
|
10
|
-
/**
|
|
11
|
-
* A ref for the component
|
|
12
|
-
*/
|
|
13
|
-
ref?: Ref<HTMLInputElement>;
|
|
14
9
|
}
|
|
15
10
|
/**
|
|
16
11
|
* The `<PasswordField>` component is used to enter passwords or other confidential information.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Ref } from "react";
|
|
2
1
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
3
2
|
import { PhoneBaseInputProps } from "./PhoneBaseInput/PhoneBaseInput";
|
|
4
3
|
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon" | "name">;
|
|
@@ -7,10 +6,6 @@ export interface PhoneFieldProps extends FormGroupExposedProps, PhoneBaseInputPr
|
|
|
7
6
|
* If a value is set, the field is rendered in its invalid state.
|
|
8
7
|
*/
|
|
9
8
|
errorMessage?: string;
|
|
10
|
-
/**
|
|
11
|
-
* A ref for the component
|
|
12
|
-
*/
|
|
13
|
-
ref?: Ref<HTMLInputElement>;
|
|
14
9
|
}
|
|
15
10
|
/**
|
|
16
11
|
* The `<PhoneField>` component is used to enter and validate phone numbers.
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Ref } from "react";
|
|
2
1
|
import { Control, ControllerProps } from "react-hook-form";
|
|
3
2
|
import { PhoneFieldProps } from "../PhoneField/PhoneField";
|
|
4
3
|
export interface PhoneFieldWithControllerProps extends PhoneFieldProps {
|
|
@@ -14,10 +13,6 @@ export interface PhoneFieldWithControllerProps extends PhoneFieldProps {
|
|
|
14
13
|
* Used to overwrite controller props.
|
|
15
14
|
*/
|
|
16
15
|
controllerProps?: Partial<Omit<ControllerProps<any>, "render">>;
|
|
17
|
-
/**
|
|
18
|
-
* A ref for the component
|
|
19
|
-
*/
|
|
20
|
-
ref?: Ref<HTMLInputElement>;
|
|
21
16
|
}
|
|
22
17
|
/**
|
|
23
18
|
* PhoneFieldWithController wraps `PhoneField` with a `react-hook-form` `Controller`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
2
|
import { IconName } from "@trackunit/ui-icons";
|
|
3
|
-
import { CSSProperties, ChangeEvent, FocusEvent, KeyboardEvent, ReactElement
|
|
3
|
+
import { CSSProperties, ChangeEvent, FocusEvent, KeyboardEvent, ReactElement } from "react";
|
|
4
4
|
import { TextBaseInputProps } from "../TextField/TextBaseInput/TextBaseInput";
|
|
5
5
|
export interface SearchProps extends CommonProps, TextBaseInputProps {
|
|
6
6
|
/**
|
|
@@ -60,10 +60,6 @@ export interface SearchProps extends CommonProps, TextBaseInputProps {
|
|
|
60
60
|
* Indicates whether a loading spinner should be displayed in the search box.
|
|
61
61
|
*/
|
|
62
62
|
loading?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* A ref for the component
|
|
65
|
-
*/
|
|
66
|
-
ref?: Ref<HTMLInputElement>;
|
|
67
63
|
/**
|
|
68
64
|
* A custom icon to be displayed in the search box.
|
|
69
65
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CommonProps } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
2
2
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
3
|
-
import { FocusEvent, ReactElement, ReactNode
|
|
3
|
+
import { FocusEvent, ReactElement, ReactNode } from "react";
|
|
4
4
|
import { GroupBase } from "react-select";
|
|
5
5
|
import { SelectProps } from "../BaseSelect/useSelect";
|
|
6
6
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
@@ -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
|
|
13
|
+
export interface SelectFieldProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false> extends CommonProps, FormGroupExposedProps, SelectExposedProps<TOption, TIsAsync>, Refable<HTMLSelectElement> {
|
|
14
14
|
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
|
15
15
|
/**
|
|
16
16
|
* The options available for the SelectField.
|
|
@@ -40,11 +40,7 @@ export type SelectFieldProps<TOption extends BaseOptionType = BaseOptionType, TI
|
|
|
40
40
|
* The htmlFor attribute for the label. If not provided, falls back to id or generates a unique value.
|
|
41
41
|
*/
|
|
42
42
|
htmlFor?: string;
|
|
43
|
-
|
|
44
|
-
* A ref for the component
|
|
45
|
-
*/
|
|
46
|
-
ref?: Ref<HTMLSelectElement>;
|
|
47
|
-
};
|
|
43
|
+
}
|
|
48
44
|
interface FormFieldSelectAdapterProps<TOption extends BaseOptionType = BaseOptionType, TIsAsync extends boolean = false> extends SelectFieldProps<TOption, TIsAsync> {
|
|
49
45
|
children: (props: SelectProps<TOption, TIsAsync, false, GroupBase<TOption>>) => ReactNode;
|
|
50
46
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
-
import { InputHTMLAttributes
|
|
1
|
+
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
2
|
+
import { InputHTMLAttributes } from "react";
|
|
3
3
|
export type TextAreaResize = "none" | "vertical" | "horizontal" | "both";
|
|
4
4
|
type FilteredInputProps = Omit<InputHTMLAttributes<HTMLTextAreaElement>, "prefix" | "suffix">;
|
|
5
|
-
export interface TextAreaBaseInputProps extends FilteredInputProps, CommonProps {
|
|
5
|
+
export interface TextAreaBaseInputProps extends FilteredInputProps, CommonProps, Refable<HTMLTextAreaElement> {
|
|
6
6
|
/**
|
|
7
7
|
* Number of rows in the text area.
|
|
8
8
|
*/
|
|
@@ -21,10 +21,6 @@ export interface TextAreaBaseInputProps extends FilteredInputProps, CommonProps
|
|
|
21
21
|
* If true the field is rendered in its invalid state.
|
|
22
22
|
*/
|
|
23
23
|
isInvalid?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* A ref for the component
|
|
26
|
-
*/
|
|
27
|
-
ref?: Ref<HTMLTextAreaElement>;
|
|
28
24
|
}
|
|
29
25
|
/**
|
|
30
26
|
* The TextArea is a base component, and should not be used very often.
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
-
import { Ref } from "react";
|
|
3
2
|
import { FormGroupProps } from "../FormGroup/FormGroup";
|
|
4
3
|
import { TextAreaBaseInputProps } from "./TextArea/TextAreaBaseInput";
|
|
5
4
|
type FormGroupExposedProps = Pick<FormGroupProps, "label" | "tip" | "helpText" | "helpAddon">;
|
|
@@ -13,10 +12,6 @@ export interface TextAreaFieldProps extends TextAreaBaseInputProps, FormGroupExp
|
|
|
13
12
|
* If a value is set, the field is rendered in its invalid state.
|
|
14
13
|
*/
|
|
15
14
|
errorMessage?: string;
|
|
16
|
-
/**
|
|
17
|
-
* A ref for the component
|
|
18
|
-
*/
|
|
19
|
-
ref?: Ref<HTMLTextAreaElement>;
|
|
20
15
|
}
|
|
21
16
|
/**
|
|
22
17
|
* The `<TextAreaField>` component is used for multi-line text input.
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { BaseInputProps } from "../../BaseInput/BaseInput";
|
|
2
|
-
type
|
|
3
|
-
export type TextBaseInputProps = BaseInputExposedProps;
|
|
2
|
+
export type TextBaseInputProps = Omit<BaseInputProps, "type">;
|
|
4
3
|
/**
|
|
5
4
|
* A thin wrapper around the `BaseInput` component for text input fields.
|
|
6
5
|
*
|
|
7
6
|
* NOTE: If shown with a label, please use the `TextField` component instead.
|
|
8
7
|
*/
|
|
9
8
|
export declare const TextBaseInput: ({ ref, ...rest }: TextBaseInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CommonProps } from "@trackunit/react-components";
|
|
1
|
+
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
2
2
|
import { MappedOmit, Size } from "@trackunit/shared-utils";
|
|
3
|
-
import { ChangeEvent, InputHTMLAttributes, MouseEventHandler } from "react";
|
|
4
|
-
export interface ToggleSwitchProps extends CommonProps, MappedOmit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "onChange" | "size" | "children"> {
|
|
3
|
+
import { ChangeEvent, InputHTMLAttributes, MouseEventHandler, ReactElement } from "react";
|
|
4
|
+
export interface ToggleSwitchProps extends CommonProps, MappedOmit<InputHTMLAttributes<HTMLInputElement>, "prefix" | "onChange" | "size" | "children">, Refable<HTMLInputElement> {
|
|
5
5
|
/**
|
|
6
6
|
* custom onChange event handler.
|
|
7
7
|
*/
|
|
@@ -92,4 +92,7 @@ export interface ToggleSwitchProps extends CommonProps, MappedOmit<InputHTMLAttr
|
|
|
92
92
|
* @param {ToggleSwitchProps} props - The props for the ToggleSwitch component
|
|
93
93
|
* @returns {ReactElement} ToggleSwitch component
|
|
94
94
|
*/
|
|
95
|
-
export declare const ToggleSwitch:
|
|
95
|
+
export declare const ToggleSwitch: {
|
|
96
|
+
({ onChange, onClick, preventDefaultOnClick, className, "data-testid": dataTestId, showInputFocus, toggled, size, tabIndex, readOnly, disabled, ref, ...rest }: ToggleSwitchProps): ReactElement;
|
|
97
|
+
displayName: string;
|
|
98
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Refable } from "@trackunit/react-components";
|
|
2
2
|
import { ReactElement } from "react";
|
|
3
3
|
import { ToggleSwitchProps } from "../ToggleSwitch/ToggleSwitch";
|
|
4
|
-
export interface ToggleSwitchOptionProps extends ToggleSwitchProps, Refable<HTMLLabelElement> {
|
|
4
|
+
export interface ToggleSwitchOptionProps extends Omit<ToggleSwitchProps, "ref">, Refable<HTMLLabelElement> {
|
|
5
5
|
/**
|
|
6
6
|
* The label of the toggle.
|
|
7
7
|
*/
|