@trackunit/react-form-components 1.8.65 → 1.8.67
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
CHANGED
|
@@ -108,10 +108,28 @@ const cvaInputBase = cssClassVarianceUtilities.cvaMerge([
|
|
|
108
108
|
"hover:bg-neutral-50",
|
|
109
109
|
"transition",
|
|
110
110
|
]);
|
|
111
|
-
const cvaInputBaseDisabled = cssClassVarianceUtilities.cvaMerge([
|
|
111
|
+
const cvaInputBaseDisabled = cssClassVarianceUtilities.cvaMerge([
|
|
112
|
+
"bg-neutral-100",
|
|
113
|
+
"hover:bg-neutral-100",
|
|
114
|
+
"hover:border-neutral-300",
|
|
115
|
+
"text-neutral-400",
|
|
116
|
+
]);
|
|
112
117
|
const cvaInputBaseInvalid = cssClassVarianceUtilities.cvaMerge(["border-danger-600"]);
|
|
118
|
+
const cvaInputBaseReadOnly = cssClassVarianceUtilities.cvaMerge(["text-neutral-500"]);
|
|
119
|
+
const cvaInputBaseSize = cssClassVarianceUtilities.cvaMerge("", {
|
|
120
|
+
variants: {
|
|
121
|
+
size: {
|
|
122
|
+
small: ["h-7", "text-xs"],
|
|
123
|
+
medium: ["h-8", "text-sm"],
|
|
124
|
+
large: ["h-10", "text-sm"],
|
|
125
|
+
},
|
|
126
|
+
defaultVariants: {
|
|
127
|
+
size: "medium",
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
});
|
|
113
131
|
const cvaInput$1 = cssClassVarianceUtilities.cvaMerge([
|
|
114
|
-
"overflow-
|
|
132
|
+
"overflow-clip",
|
|
115
133
|
"grid",
|
|
116
134
|
// ! The layout of the grid is critical to the functioning of the cvaInputItemPlacementManager 👇
|
|
117
135
|
// The min restriction of the middle column (--spacing-20) is
|
|
@@ -120,17 +138,22 @@ const cvaInput$1 = cssClassVarianceUtilities.cvaMerge([
|
|
|
120
138
|
"grid-rows-1",
|
|
121
139
|
cvaInputBase(),
|
|
122
140
|
"focus-within:outline-native",
|
|
141
|
+
"text-neutral-900",
|
|
123
142
|
], {
|
|
124
143
|
variants: {
|
|
125
144
|
size: {
|
|
126
|
-
small:
|
|
127
|
-
medium:
|
|
128
|
-
large:
|
|
145
|
+
small: cvaInputBaseSize({ size: "small" }),
|
|
146
|
+
medium: cvaInputBaseSize({ size: "medium" }),
|
|
147
|
+
large: cvaInputBaseSize({ size: "large" }),
|
|
129
148
|
},
|
|
130
149
|
disabled: {
|
|
131
150
|
true: cvaInputBaseDisabled(),
|
|
132
151
|
false: [""],
|
|
133
152
|
},
|
|
153
|
+
readOnly: {
|
|
154
|
+
true: cvaInputBaseReadOnly(),
|
|
155
|
+
false: [""],
|
|
156
|
+
},
|
|
134
157
|
invalid: {
|
|
135
158
|
true: cvaInputBaseInvalid(),
|
|
136
159
|
false: [""],
|
|
@@ -146,6 +169,11 @@ const cvaInput$1 = cssClassVarianceUtilities.cvaMerge([
|
|
|
146
169
|
isWarning: true,
|
|
147
170
|
className: ["border-danger-600"], // Ensures that 'invalid' takes precedence
|
|
148
171
|
},
|
|
172
|
+
{
|
|
173
|
+
disabled: true,
|
|
174
|
+
readOnly: true,
|
|
175
|
+
className: "text-neutral-400",
|
|
176
|
+
},
|
|
149
177
|
],
|
|
150
178
|
defaultVariants: {
|
|
151
179
|
size: "medium",
|
|
@@ -172,42 +200,19 @@ const cvaInputItemPlacementManager = cssClassVarianceUtilities.cvaMerge([], {
|
|
|
172
200
|
},
|
|
173
201
|
});
|
|
174
202
|
const cvaAccessoriesContainer = cssClassVarianceUtilities.cvaMerge(["grid", "h-full", "w-min", "auto-cols-min", "grid-flow-col"]);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
"bg-transparent",
|
|
180
|
-
"text-neutral-900",
|
|
181
|
-
"placeholder-neutral-400",
|
|
182
|
-
"text-sm",
|
|
183
|
-
"truncate",
|
|
184
|
-
], {
|
|
203
|
+
/**
|
|
204
|
+
* Text size and color is handled by cvaInput
|
|
205
|
+
*/
|
|
206
|
+
const cvaInputElement = cssClassVarianceUtilities.cvaMerge(["w-full", "px-3", "border-0", "bg-transparent", "placeholder-neutral-400", "truncate"], {
|
|
185
207
|
variants: {
|
|
186
208
|
size: {
|
|
187
|
-
small: ["py-0.5"
|
|
209
|
+
small: ["py-0.5"],
|
|
188
210
|
medium: ["py-1"],
|
|
189
211
|
large: ["py-2"],
|
|
190
212
|
},
|
|
191
|
-
disabled: {
|
|
192
|
-
true: ["text-neutral-400"],
|
|
193
|
-
false: [""],
|
|
194
|
-
},
|
|
195
|
-
readOnly: {
|
|
196
|
-
true: ["text-neutral-500"],
|
|
197
|
-
false: [""],
|
|
198
|
-
},
|
|
199
213
|
},
|
|
200
|
-
compoundVariants: [
|
|
201
|
-
{
|
|
202
|
-
disabled: true,
|
|
203
|
-
readOnly: true,
|
|
204
|
-
className: "text-neutral-400",
|
|
205
|
-
},
|
|
206
|
-
],
|
|
207
214
|
defaultVariants: {
|
|
208
215
|
size: "medium",
|
|
209
|
-
disabled: false,
|
|
210
|
-
readOnly: false,
|
|
211
216
|
},
|
|
212
217
|
});
|
|
213
218
|
const cvaInputAddon = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -371,7 +376,7 @@ const GenericActionsRenderer = ({ genericAction, disabled, fieldSize, innerRef,
|
|
|
371
376
|
*/
|
|
372
377
|
const InputLockReasonTooltip = ({ reasons, kind }) => {
|
|
373
378
|
const [t] = useTranslation();
|
|
374
|
-
if (
|
|
379
|
+
if (reasons === undefined || reasons.length === 0) {
|
|
375
380
|
return (jsxRuntime.jsx(reactComponents.Tooltip, { label: t("field.notEditable.tooltip"), children: jsxRuntime.jsx(reactComponents.Icon, { name: kind === "disabled" ? "QuestionMarkCircle" : "LockClosed", size: "small" }) }));
|
|
376
381
|
}
|
|
377
382
|
return (jsxRuntime.jsx(reactComponents.Tooltip, { label: jsxRuntime.jsx("ul", { className: typeof reasons === "string" ? "list-none !pl-0" : "list-disc", children: typeof reasons === "string" ? jsxRuntime.jsx("li", { children: reasons }) : reasons.map(reason => jsxRuntime.jsx("li", { children: reason }, reason)) }), placement: "top", children: jsxRuntime.jsx(reactComponents.Icon, { name: "LockClosed", size: "small" }) }));
|
|
@@ -429,7 +434,7 @@ const SuffixRenderer = ({ suffix, isInvalid, isWarning, dataTestId, disabled, })
|
|
|
429
434
|
* For specific input types make sure to use the corresponding input component.
|
|
430
435
|
* This is a base used by our other input components such as TextBaseInput, NumberBaseInput, PasswordBaseInput, etc.
|
|
431
436
|
*/
|
|
432
|
-
const BaseInput = ({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, inputClassName, placeholder, isWarning, type, genericAction, style, ref, ...rest }) => {
|
|
437
|
+
const BaseInput = ({ className, isInvalid = false, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, inputClassName, placeholder, isWarning = false, type, genericAction, style, ref, required = false, ...rest }) => {
|
|
433
438
|
// Derive final flags
|
|
434
439
|
const renderAsDisabled = Boolean(rest.disabled);
|
|
435
440
|
const renderAsReadonly = Boolean(rest.readOnly);
|
|
@@ -463,19 +468,18 @@ const BaseInput = ({ className, isInvalid, dataTestId, prefix, suffix, addonBefo
|
|
|
463
468
|
react.useImperativeHandle(ref, () => innerRef.current, []);
|
|
464
469
|
return (jsxRuntime.jsxs("div", { className: cvaInput$1({
|
|
465
470
|
disabled: renderAsDisabled,
|
|
471
|
+
readOnly: renderAsReadonly,
|
|
466
472
|
invalid: isInvalid,
|
|
467
473
|
isWarning,
|
|
468
474
|
size: fieldSize,
|
|
469
475
|
className,
|
|
470
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxRuntime.jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "before" }) }), "data-testid": dataTestId ? `${dataTestId}-before-container` : undefined, ref: beforeContainerRef, children: [jsxRuntime.jsx(AddonRenderer, { addon: addonBefore, dataTestId: dataTestId, fieldSize: fieldSize, position: "before" }), jsxRuntime.jsx(PrefixRenderer, { dataTestId: dataTestId, disabled: renderAsDisabled, prefix: prefix, type: type })] }), jsxRuntime.jsx("input", { "aria-required":
|
|
471
|
-
readOnly: renderAsReadonly,
|
|
476
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxRuntime.jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "before" }) }), "data-testid": dataTestId ? `${dataTestId}-before-container` : undefined, ref: beforeContainerRef, children: [jsxRuntime.jsx(AddonRenderer, { addon: addonBefore, dataTestId: dataTestId, fieldSize: fieldSize, position: "before" }), jsxRuntime.jsx(PrefixRenderer, { dataTestId: dataTestId, disabled: renderAsDisabled, prefix: prefix, type: type })] }), jsxRuntime.jsx("input", { "aria-required": required, className: cvaInputElement({
|
|
472
477
|
size: fieldSize,
|
|
473
|
-
disabled: renderAsDisabled,
|
|
474
478
|
className: cvaInputItemPlacementManager({ position: "span", className: inputClassName }),
|
|
475
|
-
}), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef, style: {
|
|
479
|
+
}), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef, required: required, style: {
|
|
476
480
|
paddingLeft: `calc(var(--before-width, 0px) + ${uiDesignTokens.themeSpacing[2]})`,
|
|
477
481
|
paddingRight: `calc(var(--after-width, 0px) + ${uiDesignTokens.themeSpacing[2]})`,
|
|
478
|
-
}, type: type, ...rest, disabled: renderAsDisabled, readOnly: renderAsReadonly || nonInteractive }), jsxRuntime.jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "after" }) }), "data-testid": dataTestId ? `${dataTestId}-after-container` : undefined, ref: afterContainerRef, children: [jsxRuntime.jsx(LockReasonRenderer, { dataTestId: dataTestId + "-disabled", lockReason: rest.disabled }), jsxRuntime.jsx(LockReasonRenderer, { dataTestId: dataTestId + "-readonly", lockReason: rest.readOnly && !rest.disabled ? rest.readOnly : undefined }), jsxRuntime.jsx(GenericActionsRenderer, { fieldSize: fieldSize, genericAction: genericAction, innerRef: innerRef }), jsxRuntime.jsx(SuffixRenderer, { dataTestId: dataTestId, disabled: renderAsDisabled, isInvalid: isInvalid, isWarning: isWarning, suffix: suffix }), actions, jsxRuntime.jsx(AddonRenderer, { addon: addonAfter, dataTestId: dataTestId, fieldSize: fieldSize, position: "after" })] })] }));
|
|
482
|
+
}, type: type, ...rest, disabled: renderAsDisabled, readOnly: renderAsReadonly || nonInteractive }), jsxRuntime.jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "after" }) }), "data-testid": dataTestId ? `${dataTestId}-after-container` : undefined, ref: afterContainerRef, children: [jsxRuntime.jsx(LockReasonRenderer, { dataTestId: dataTestId + "-disabled", lockReason: rest.disabled }), jsxRuntime.jsx(LockReasonRenderer, { dataTestId: dataTestId + "-readonly", lockReason: Boolean(rest.readOnly) && !Boolean(rest.disabled) ? rest.readOnly : undefined }), jsxRuntime.jsx(GenericActionsRenderer, { fieldSize: fieldSize, genericAction: genericAction, innerRef: innerRef }), jsxRuntime.jsx(SuffixRenderer, { dataTestId: dataTestId, disabled: renderAsDisabled, isInvalid: isInvalid, isWarning: isWarning, suffix: suffix }), actions, jsxRuntime.jsx(AddonRenderer, { addon: addonAfter, dataTestId: dataTestId, fieldSize: fieldSize, position: "after" })] })] }));
|
|
479
483
|
};
|
|
480
484
|
BaseInput.displayName = "BaseInput";
|
|
481
485
|
|
|
@@ -1756,10 +1760,9 @@ const ColorField = react.forwardRef(({ label, id, tip, helpText, errorMessage, h
|
|
|
1756
1760
|
size: fieldSize,
|
|
1757
1761
|
disabled: renderAsDisabled,
|
|
1758
1762
|
invalid: renderAsInvalid,
|
|
1763
|
+
readOnly: renderAsReadonly,
|
|
1759
1764
|
className,
|
|
1760
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, 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: innerRef, type: "color", value: innerValue }), jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label-text", className:
|
|
1761
|
-
readOnly: renderAsReadonly,
|
|
1762
|
-
disabled: renderAsDisabled,
|
|
1765
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, 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: innerRef, type: "color", value: innerValue }), jsxRuntime.jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputElement({
|
|
1763
1766
|
className: "px-1 focus-visible:outline-none",
|
|
1764
1767
|
}), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, disabled: renderAsDisabled, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, type: "text", value: innerValue }), jsxRuntime.jsx(GenericActionsRenderer, { disabled: renderAsDisabled || renderAsReadonly, fieldSize: fieldSize, genericAction: "edit", innerRef: innerRef, tooltipLabel: t("colorField.tooltip") })] }) }));
|
|
1765
1768
|
});
|
|
@@ -3301,7 +3304,9 @@ exports.cvaInputAddon = cvaInputAddon;
|
|
|
3301
3304
|
exports.cvaInputBase = cvaInputBase;
|
|
3302
3305
|
exports.cvaInputBaseDisabled = cvaInputBaseDisabled;
|
|
3303
3306
|
exports.cvaInputBaseInvalid = cvaInputBaseInvalid;
|
|
3304
|
-
exports.
|
|
3307
|
+
exports.cvaInputBaseReadOnly = cvaInputBaseReadOnly;
|
|
3308
|
+
exports.cvaInputBaseSize = cvaInputBaseSize;
|
|
3309
|
+
exports.cvaInputElement = cvaInputElement;
|
|
3305
3310
|
exports.cvaInputItemPlacementManager = cvaInputItemPlacementManager;
|
|
3306
3311
|
exports.cvaInputPrefix = cvaInputPrefix;
|
|
3307
3312
|
exports.cvaInputSuffix = cvaInputSuffix;
|
package/index.esm.js
CHANGED
|
@@ -107,10 +107,28 @@ const cvaInputBase = cvaMerge([
|
|
|
107
107
|
"hover:bg-neutral-50",
|
|
108
108
|
"transition",
|
|
109
109
|
]);
|
|
110
|
-
const cvaInputBaseDisabled = cvaMerge([
|
|
110
|
+
const cvaInputBaseDisabled = cvaMerge([
|
|
111
|
+
"bg-neutral-100",
|
|
112
|
+
"hover:bg-neutral-100",
|
|
113
|
+
"hover:border-neutral-300",
|
|
114
|
+
"text-neutral-400",
|
|
115
|
+
]);
|
|
111
116
|
const cvaInputBaseInvalid = cvaMerge(["border-danger-600"]);
|
|
117
|
+
const cvaInputBaseReadOnly = cvaMerge(["text-neutral-500"]);
|
|
118
|
+
const cvaInputBaseSize = cvaMerge("", {
|
|
119
|
+
variants: {
|
|
120
|
+
size: {
|
|
121
|
+
small: ["h-7", "text-xs"],
|
|
122
|
+
medium: ["h-8", "text-sm"],
|
|
123
|
+
large: ["h-10", "text-sm"],
|
|
124
|
+
},
|
|
125
|
+
defaultVariants: {
|
|
126
|
+
size: "medium",
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
});
|
|
112
130
|
const cvaInput$1 = cvaMerge([
|
|
113
|
-
"overflow-
|
|
131
|
+
"overflow-clip",
|
|
114
132
|
"grid",
|
|
115
133
|
// ! The layout of the grid is critical to the functioning of the cvaInputItemPlacementManager 👇
|
|
116
134
|
// The min restriction of the middle column (--spacing-20) is
|
|
@@ -119,17 +137,22 @@ const cvaInput$1 = cvaMerge([
|
|
|
119
137
|
"grid-rows-1",
|
|
120
138
|
cvaInputBase(),
|
|
121
139
|
"focus-within:outline-native",
|
|
140
|
+
"text-neutral-900",
|
|
122
141
|
], {
|
|
123
142
|
variants: {
|
|
124
143
|
size: {
|
|
125
|
-
small:
|
|
126
|
-
medium:
|
|
127
|
-
large:
|
|
144
|
+
small: cvaInputBaseSize({ size: "small" }),
|
|
145
|
+
medium: cvaInputBaseSize({ size: "medium" }),
|
|
146
|
+
large: cvaInputBaseSize({ size: "large" }),
|
|
128
147
|
},
|
|
129
148
|
disabled: {
|
|
130
149
|
true: cvaInputBaseDisabled(),
|
|
131
150
|
false: [""],
|
|
132
151
|
},
|
|
152
|
+
readOnly: {
|
|
153
|
+
true: cvaInputBaseReadOnly(),
|
|
154
|
+
false: [""],
|
|
155
|
+
},
|
|
133
156
|
invalid: {
|
|
134
157
|
true: cvaInputBaseInvalid(),
|
|
135
158
|
false: [""],
|
|
@@ -145,6 +168,11 @@ const cvaInput$1 = cvaMerge([
|
|
|
145
168
|
isWarning: true,
|
|
146
169
|
className: ["border-danger-600"], // Ensures that 'invalid' takes precedence
|
|
147
170
|
},
|
|
171
|
+
{
|
|
172
|
+
disabled: true,
|
|
173
|
+
readOnly: true,
|
|
174
|
+
className: "text-neutral-400",
|
|
175
|
+
},
|
|
148
176
|
],
|
|
149
177
|
defaultVariants: {
|
|
150
178
|
size: "medium",
|
|
@@ -171,42 +199,19 @@ const cvaInputItemPlacementManager = cvaMerge([], {
|
|
|
171
199
|
},
|
|
172
200
|
});
|
|
173
201
|
const cvaAccessoriesContainer = cvaMerge(["grid", "h-full", "w-min", "auto-cols-min", "grid-flow-col"]);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
"bg-transparent",
|
|
179
|
-
"text-neutral-900",
|
|
180
|
-
"placeholder-neutral-400",
|
|
181
|
-
"text-sm",
|
|
182
|
-
"truncate",
|
|
183
|
-
], {
|
|
202
|
+
/**
|
|
203
|
+
* Text size and color is handled by cvaInput
|
|
204
|
+
*/
|
|
205
|
+
const cvaInputElement = cvaMerge(["w-full", "px-3", "border-0", "bg-transparent", "placeholder-neutral-400", "truncate"], {
|
|
184
206
|
variants: {
|
|
185
207
|
size: {
|
|
186
|
-
small: ["py-0.5"
|
|
208
|
+
small: ["py-0.5"],
|
|
187
209
|
medium: ["py-1"],
|
|
188
210
|
large: ["py-2"],
|
|
189
211
|
},
|
|
190
|
-
disabled: {
|
|
191
|
-
true: ["text-neutral-400"],
|
|
192
|
-
false: [""],
|
|
193
|
-
},
|
|
194
|
-
readOnly: {
|
|
195
|
-
true: ["text-neutral-500"],
|
|
196
|
-
false: [""],
|
|
197
|
-
},
|
|
198
212
|
},
|
|
199
|
-
compoundVariants: [
|
|
200
|
-
{
|
|
201
|
-
disabled: true,
|
|
202
|
-
readOnly: true,
|
|
203
|
-
className: "text-neutral-400",
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
213
|
defaultVariants: {
|
|
207
214
|
size: "medium",
|
|
208
|
-
disabled: false,
|
|
209
|
-
readOnly: false,
|
|
210
215
|
},
|
|
211
216
|
});
|
|
212
217
|
const cvaInputAddon = cvaMerge([
|
|
@@ -370,7 +375,7 @@ const GenericActionsRenderer = ({ genericAction, disabled, fieldSize, innerRef,
|
|
|
370
375
|
*/
|
|
371
376
|
const InputLockReasonTooltip = ({ reasons, kind }) => {
|
|
372
377
|
const [t] = useTranslation();
|
|
373
|
-
if (
|
|
378
|
+
if (reasons === undefined || reasons.length === 0) {
|
|
374
379
|
return (jsx(Tooltip, { label: t("field.notEditable.tooltip"), children: jsx(Icon, { name: kind === "disabled" ? "QuestionMarkCircle" : "LockClosed", size: "small" }) }));
|
|
375
380
|
}
|
|
376
381
|
return (jsx(Tooltip, { label: jsx("ul", { className: typeof reasons === "string" ? "list-none !pl-0" : "list-disc", children: typeof reasons === "string" ? jsx("li", { children: reasons }) : reasons.map(reason => jsx("li", { children: reason }, reason)) }), placement: "top", children: jsx(Icon, { name: "LockClosed", size: "small" }) }));
|
|
@@ -428,7 +433,7 @@ const SuffixRenderer = ({ suffix, isInvalid, isWarning, dataTestId, disabled, })
|
|
|
428
433
|
* For specific input types make sure to use the corresponding input component.
|
|
429
434
|
* This is a base used by our other input components such as TextBaseInput, NumberBaseInput, PasswordBaseInput, etc.
|
|
430
435
|
*/
|
|
431
|
-
const BaseInput = ({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, inputClassName, placeholder, isWarning, type, genericAction, style, ref, ...rest }) => {
|
|
436
|
+
const BaseInput = ({ className, isInvalid = false, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, inputClassName, placeholder, isWarning = false, type, genericAction, style, ref, required = false, ...rest }) => {
|
|
432
437
|
// Derive final flags
|
|
433
438
|
const renderAsDisabled = Boolean(rest.disabled);
|
|
434
439
|
const renderAsReadonly = Boolean(rest.readOnly);
|
|
@@ -462,19 +467,18 @@ const BaseInput = ({ className, isInvalid, dataTestId, prefix, suffix, addonBefo
|
|
|
462
467
|
useImperativeHandle(ref, () => innerRef.current, []);
|
|
463
468
|
return (jsxs("div", { className: cvaInput$1({
|
|
464
469
|
disabled: renderAsDisabled,
|
|
470
|
+
readOnly: renderAsReadonly,
|
|
465
471
|
invalid: isInvalid,
|
|
466
472
|
isWarning,
|
|
467
473
|
size: fieldSize,
|
|
468
474
|
className,
|
|
469
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "before" }) }), "data-testid": dataTestId ? `${dataTestId}-before-container` : undefined, ref: beforeContainerRef, children: [jsx(AddonRenderer, { addon: addonBefore, dataTestId: dataTestId, fieldSize: fieldSize, position: "before" }), jsx(PrefixRenderer, { dataTestId: dataTestId, disabled: renderAsDisabled, prefix: prefix, type: type })] }), jsx("input", { "aria-required":
|
|
470
|
-
readOnly: renderAsReadonly,
|
|
475
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, style: style, children: [jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "before" }) }), "data-testid": dataTestId ? `${dataTestId}-before-container` : undefined, ref: beforeContainerRef, children: [jsx(AddonRenderer, { addon: addonBefore, dataTestId: dataTestId, fieldSize: fieldSize, position: "before" }), jsx(PrefixRenderer, { dataTestId: dataTestId, disabled: renderAsDisabled, prefix: prefix, type: type })] }), jsx("input", { "aria-required": required, className: cvaInputElement({
|
|
471
476
|
size: fieldSize,
|
|
472
|
-
disabled: renderAsDisabled,
|
|
473
477
|
className: cvaInputItemPlacementManager({ position: "span", className: inputClassName }),
|
|
474
|
-
}), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef, style: {
|
|
478
|
+
}), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef, required: required, style: {
|
|
475
479
|
paddingLeft: `calc(var(--before-width, 0px) + ${themeSpacing[2]})`,
|
|
476
480
|
paddingRight: `calc(var(--after-width, 0px) + ${themeSpacing[2]})`,
|
|
477
|
-
}, type: type, ...rest, disabled: renderAsDisabled, readOnly: renderAsReadonly || nonInteractive }), jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "after" }) }), "data-testid": dataTestId ? `${dataTestId}-after-container` : undefined, ref: afterContainerRef, children: [jsx(LockReasonRenderer, { dataTestId: dataTestId + "-disabled", lockReason: rest.disabled }), jsx(LockReasonRenderer, { dataTestId: dataTestId + "-readonly", lockReason: rest.readOnly && !rest.disabled ? rest.readOnly : undefined }), jsx(GenericActionsRenderer, { fieldSize: fieldSize, genericAction: genericAction, innerRef: innerRef }), jsx(SuffixRenderer, { dataTestId: dataTestId, disabled: renderAsDisabled, isInvalid: isInvalid, isWarning: isWarning, suffix: suffix }), actions, jsx(AddonRenderer, { addon: addonAfter, dataTestId: dataTestId, fieldSize: fieldSize, position: "after" })] })] }));
|
|
481
|
+
}, type: type, ...rest, disabled: renderAsDisabled, readOnly: renderAsReadonly || nonInteractive }), jsxs("div", { className: cvaAccessoriesContainer({ className: cvaInputItemPlacementManager({ position: "after" }) }), "data-testid": dataTestId ? `${dataTestId}-after-container` : undefined, ref: afterContainerRef, children: [jsx(LockReasonRenderer, { dataTestId: dataTestId + "-disabled", lockReason: rest.disabled }), jsx(LockReasonRenderer, { dataTestId: dataTestId + "-readonly", lockReason: Boolean(rest.readOnly) && !Boolean(rest.disabled) ? rest.readOnly : undefined }), jsx(GenericActionsRenderer, { fieldSize: fieldSize, genericAction: genericAction, innerRef: innerRef }), jsx(SuffixRenderer, { dataTestId: dataTestId, disabled: renderAsDisabled, isInvalid: isInvalid, isWarning: isWarning, suffix: suffix }), actions, jsx(AddonRenderer, { addon: addonAfter, dataTestId: dataTestId, fieldSize: fieldSize, position: "after" })] })] }));
|
|
478
482
|
};
|
|
479
483
|
BaseInput.displayName = "BaseInput";
|
|
480
484
|
|
|
@@ -1755,10 +1759,9 @@ const ColorField = forwardRef(({ label, id, tip, helpText, errorMessage, helpAdd
|
|
|
1755
1759
|
size: fieldSize,
|
|
1756
1760
|
disabled: renderAsDisabled,
|
|
1757
1761
|
invalid: renderAsInvalid,
|
|
1762
|
+
readOnly: renderAsReadonly,
|
|
1758
1763
|
className,
|
|
1759
|
-
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, 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: innerRef, type: "color", value: innerValue }), jsx("input", { "aria-labelledby": htmlForId + "-label-text", className:
|
|
1760
|
-
readOnly: renderAsReadonly,
|
|
1761
|
-
disabled: renderAsDisabled,
|
|
1764
|
+
}), "data-testid": dataTestId ? `${dataTestId}-container` : undefined, 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: innerRef, type: "color", value: innerValue }), jsx("input", { "aria-labelledby": htmlForId + "-label-text", className: cvaInputElement({
|
|
1762
1765
|
className: "px-1 focus-visible:outline-none",
|
|
1763
1766
|
}), "data-testid": dataTestId ? `${dataTestId}-textField` : undefined, disabled: renderAsDisabled, onBlur: handleBlur, onChange: handleInputChange, readOnly: renderAsReadonly, type: "text", value: innerValue }), jsx(GenericActionsRenderer, { disabled: renderAsDisabled || renderAsReadonly, fieldSize: fieldSize, genericAction: "edit", innerRef: innerRef, tooltipLabel: t("colorField.tooltip") })] }) }));
|
|
1764
1767
|
});
|
|
@@ -3244,4 +3247,4 @@ const useZodValidators = () => {
|
|
|
3244
3247
|
*/
|
|
3245
3248
|
setupLibraryTranslations();
|
|
3246
3249
|
|
|
3247
|
-
export { ActionButton, BaseInput, BaseSelect, Checkbox, CheckboxField, ColorField, CreatableSelect, CreatableSelectField, DEFAULT_TIME, DateBaseInput, DateField, DropZone, DropZoneDefaultLabel, EMAIL_REGEX, EmailField, FormFieldSelectAdapter, FormGroup, Label, MultiSelectField, MultiSelectMenuItem, NumberBaseInput, NumberField, OptionCard, PasswordBaseInput, PasswordField, PhoneBaseInput, PhoneField, PhoneFieldWithController, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, SelectField, SingleSelectMenuItem, TextAreaBaseInput, TextAreaField, TextBaseInput, TextField, TimeRange, TimeRangeField, ToggleSwitch, ToggleSwitchOption, UploadField, UploadInput, UrlField, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaAccessoriesContainer, cvaActionButton, cvaActionContainer, cvaInput$1 as cvaInput, cvaInputAddon, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid,
|
|
3250
|
+
export { ActionButton, BaseInput, BaseSelect, Checkbox, CheckboxField, ColorField, CreatableSelect, CreatableSelectField, DEFAULT_TIME, DateBaseInput, DateField, DropZone, DropZoneDefaultLabel, EMAIL_REGEX, EmailField, FormFieldSelectAdapter, FormGroup, Label, MultiSelectField, MultiSelectMenuItem, NumberBaseInput, NumberField, OptionCard, PasswordBaseInput, PasswordField, PhoneBaseInput, PhoneField, PhoneFieldWithController, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, SelectField, SingleSelectMenuItem, TextAreaBaseInput, TextAreaField, TextBaseInput, TextField, TimeRange, TimeRangeField, ToggleSwitch, ToggleSwitchOption, UploadField, UploadInput, UrlField, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaAccessoriesContainer, cvaActionButton, cvaActionContainer, cvaInput$1 as cvaInput, cvaInputAddon, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputBaseReadOnly, cvaInputBaseSize, cvaInputElement, cvaInputItemPlacementManager, cvaInputPrefix, cvaInputSuffix, cvaLabel, cvaSelect, cvaSelectControl, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefixSuffix, cvaSelectXIcon, getCountryAbbreviation, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isValidHEXColor, parseSchedule, phoneErrorMessage, serializeSchedule, useCustomComponents, useGetPhoneValidationRules, usePhoneInput, useZodValidators, validateEmailAddress, validatePhoneNumber, weekDay };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-components",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.67",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"zod": "^3.23.8",
|
|
17
17
|
"react-hook-form": "7.62.0",
|
|
18
18
|
"tailwind-merge": "^2.0.0",
|
|
19
|
-
"@trackunit/css-class-variance-utilities": "1.7.
|
|
20
|
-
"@trackunit/react-components": "1.10.
|
|
21
|
-
"@trackunit/ui-icons": "1.7.
|
|
22
|
-
"@trackunit/shared-utils": "1.9.
|
|
23
|
-
"@trackunit/ui-design-tokens": "1.7.
|
|
24
|
-
"@trackunit/i18n-library-translation": "1.7.
|
|
19
|
+
"@trackunit/css-class-variance-utilities": "1.7.44",
|
|
20
|
+
"@trackunit/react-components": "1.10.5",
|
|
21
|
+
"@trackunit/ui-icons": "1.7.45",
|
|
22
|
+
"@trackunit/shared-utils": "1.9.44",
|
|
23
|
+
"@trackunit/ui-design-tokens": "1.7.44",
|
|
24
|
+
"@trackunit/i18n-library-translation": "1.7.53",
|
|
25
25
|
"string-ts": "^2.0.0",
|
|
26
|
-
"@trackunit/react-test-setup": "1.4.
|
|
26
|
+
"@trackunit/react-test-setup": "1.4.44",
|
|
27
27
|
"@js-temporal/polyfill": "^0.5.1"
|
|
28
28
|
},
|
|
29
29
|
"module": "./index.esm.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
2
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
3
|
-
import { InputHTMLAttributes, ReactNode, Ref } from "react";
|
|
3
|
+
import { InputHTMLAttributes, ReactElement, ReactNode, Ref } from "react";
|
|
4
4
|
import { FormComponentSizes } from "../../types";
|
|
5
5
|
import { LockedForReasons } from "./InputLockReasonTooltip";
|
|
6
6
|
import { BaseInputActionTypes } from "./components";
|
|
@@ -76,7 +76,7 @@ export interface BaseInputProps extends FilteredInputProps, CommonProps {
|
|
|
76
76
|
* This is a base used by our other input components such as TextBaseInput, NumberBaseInput, PasswordBaseInput, etc.
|
|
77
77
|
*/
|
|
78
78
|
export declare const BaseInput: {
|
|
79
|
-
({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize, nonInteractive, inputClassName, placeholder, isWarning, type, genericAction, style, ref, ...rest }: BaseInputProps):
|
|
79
|
+
({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize, nonInteractive, inputClassName, placeholder, isWarning, type, genericAction, style, ref, required, ...rest }: BaseInputProps): ReactElement;
|
|
80
80
|
displayName: string;
|
|
81
81
|
};
|
|
82
82
|
export {};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export declare const cvaInputBase: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
2
2
|
export declare const cvaInputBaseDisabled: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
3
3
|
export declare const cvaInputBaseInvalid: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
4
|
+
export declare const cvaInputBaseReadOnly: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
5
|
+
export declare const cvaInputBaseSize: (props?: ({
|
|
6
|
+
size?: "small" | "medium" | "large" | null | undefined;
|
|
7
|
+
defaultVariants?: "size" | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
4
9
|
export declare const cvaInput: (props?: ({
|
|
5
10
|
size?: "small" | "medium" | "large" | null | undefined;
|
|
6
11
|
disabled?: boolean | null | undefined;
|
|
12
|
+
readOnly?: boolean | null | undefined;
|
|
7
13
|
invalid?: boolean | null | undefined;
|
|
8
14
|
isWarning?: boolean | null | undefined;
|
|
9
15
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
@@ -16,10 +22,11 @@ export declare const cvaInputItemPlacementManager: (props?: ({
|
|
|
16
22
|
position?: "before" | "after" | "span" | null | undefined;
|
|
17
23
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
18
24
|
export declare const cvaAccessoriesContainer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
|
19
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Text size and color is handled by cvaInput
|
|
27
|
+
*/
|
|
28
|
+
export declare const cvaInputElement: (props?: ({
|
|
20
29
|
size?: "small" | "medium" | "large" | null | undefined;
|
|
21
|
-
disabled?: boolean | null | undefined;
|
|
22
|
-
readOnly?: boolean | null | undefined;
|
|
23
30
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
24
31
|
export declare const cvaInputAddon: (props?: ({
|
|
25
32
|
size?: "small" | "medium" | "large" | null | undefined;
|