@indico-data/design-system 2.18.0 → 2.19.0
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/lib/index.css +0 -33
- package/lib/index.d.ts +17 -20
- package/lib/index.esm.css +0 -33
- package/lib/index.esm.js +31 -9
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +33 -11
- package/lib/index.js.map +1 -1
- package/lib/src/components/forms/input/Input.d.ts +5 -7
- package/lib/src/components/forms/passwordInput/PasswordInput.d.ts +5 -7
- package/lib/src/components/forms/subcomponents/Label.d.ts +6 -3
- package/lib/src/components/forms/textarea/Textarea.d.ts +5 -7
- package/lib/src/storybook/labelArgTypes.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/forms/input/Input.mdx +15 -2
- package/src/components/forms/input/Input.stories.tsx +10 -45
- package/src/components/forms/input/Input.tsx +22 -15
- package/src/components/forms/input/styles/Input.scss +0 -11
- package/src/components/forms/passwordInput/PasswordInput.mdx +10 -8
- package/src/components/forms/passwordInput/PasswordInput.stories.tsx +3 -44
- package/src/components/forms/passwordInput/PasswordInput.tsx +20 -15
- package/src/components/forms/passwordInput/styles/PasswordInput.scss +0 -11
- package/src/components/forms/subcomponents/Label.tsx +29 -6
- package/src/components/forms/subcomponents/__tests__/Label.test.tsx +63 -15
- package/src/components/forms/textarea/Textarea.mdx +12 -2
- package/src/components/forms/textarea/Textarea.stories.tsx +4 -46
- package/src/components/forms/textarea/Textarea.tsx +15 -13
- package/src/components/forms/textarea/styles/Textarea.scss +0 -11
- package/src/storybook/labelArgTypes.ts +50 -0
package/lib/index.js
CHANGED
|
@@ -18614,22 +18614,38 @@ const Table$1 = (props) => {
|
|
|
18614
18614
|
return (jsxRuntime.jsx("div", { className: "table-wrapper", children: jsxRuntime.jsx(Xe, Object.assign({ responsive: responsive, direction: direction, subHeaderAlign: subHeaderAlign, keyField: keyField, striped: striped, className: `${striped ? 'pf__table--striped' : ''}`, disabled: isDisabled, noDataComponent: noDataComponent, progressPending: isLoading, progressComponent: jsxRuntime.jsx(LoadingComponent, {}) }, rest)) }));
|
|
18615
18615
|
};
|
|
18616
18616
|
|
|
18617
|
-
const Label = ({ label, name, isRequired
|
|
18618
|
-
return (jsxRuntime.jsx("div", { "data-testid": `${name}-testId`, className: `form-label
|
|
18619
|
-
};
|
|
18617
|
+
const Label = ({ label, name, isRequired }) => {
|
|
18618
|
+
return (jsxRuntime.jsx("div", { "data-testid": `${name}-testId`, className: `form-label`, children: jsxRuntime.jsxs("label", { htmlFor: `${name}`, children: [label, isRequired ? jsxRuntime.jsx("span", { className: "text-error", children: " *" }) : ''] }) }));
|
|
18619
|
+
};
|
|
18620
|
+
// HOC to add common label functionality to components
|
|
18621
|
+
function withLabel(WrappedComponent) {
|
|
18622
|
+
const WithLabelComponent = (_a, ref) => {
|
|
18623
|
+
var { label, hasHiddenLabel = false, name, isRequired } = _a, rest = __rest$1(_a, ["label", "hasHiddenLabel", "name", "isRequired"]);
|
|
18624
|
+
const ariaLabel = hasHiddenLabel
|
|
18625
|
+
? { 'aria-label': isRequired ? `${label} (required)` : label }
|
|
18626
|
+
: {};
|
|
18627
|
+
return (jsxRuntime.jsxs("div", { className: "form-control", children: [!hasHiddenLabel && jsxRuntime.jsx(Label, { label: label, name: name, isRequired: isRequired }), jsxRuntime.jsx(WrappedComponent, Object.assign({}, rest, { id: name, name: name }, ariaLabel, { ref: ref }))] }));
|
|
18628
|
+
};
|
|
18629
|
+
return e.forwardRef(WithLabelComponent);
|
|
18630
|
+
}
|
|
18620
18631
|
|
|
18621
18632
|
const DisplayFormError = ({ message }) => {
|
|
18622
18633
|
return jsxRuntime.jsx("p", { className: "form-errors", children: message });
|
|
18623
18634
|
};
|
|
18624
18635
|
|
|
18625
18636
|
const Input = e__namespace.default.forwardRef((_a, ref) => {
|
|
18626
|
-
var {
|
|
18637
|
+
var { name, placeholder, onChange, isRequired, isDisabled, isClearable, errorMessage, helpText, iconName, className } = _a, rest = __rest$1(_a, ["name", "placeholder", "onChange", "isRequired", "isDisabled", "isClearable", "errorMessage", "helpText", "iconName", "className"]);
|
|
18627
18638
|
const hasErrors = errorMessage && errorMessage.length > 0;
|
|
18628
18639
|
const handleClear = () => {
|
|
18629
18640
|
onChange({ target: { value: '' } });
|
|
18630
18641
|
};
|
|
18631
|
-
|
|
18642
|
+
const inputClasses = y$1('input', {
|
|
18643
|
+
error: hasErrors,
|
|
18644
|
+
'input--has-icon': iconName,
|
|
18645
|
+
}, className);
|
|
18646
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "input-wrapper", children: [iconName && (jsxRuntime.jsx(Icon, { name: iconName, "data-testid": `${name}-embedded-icon`, className: "embedded-icon" })), jsxRuntime.jsx("input", Object.assign({ ref: ref, "data-testid": `form-input-${name}`, name: name, type: "text", disabled: isDisabled, placeholder: placeholder, onChange: onChange, className: inputClasses, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)), isClearable && (jsxRuntime.jsx(Icon, { name: "x-close", "data-testid": `${name}-clearable-icon`, size: "sm", onClick: handleClear, className: "clearable-icon" }))] }), hasErrors && jsxRuntime.jsx(DisplayFormError, { message: errorMessage }), helpText && (jsxRuntime.jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
18632
18647
|
});
|
|
18648
|
+
const LabeledInput = withLabel(Input);
|
|
18633
18649
|
|
|
18634
18650
|
const Radio$2 = e__namespace.default.forwardRef((_a, ref) => {
|
|
18635
18651
|
var { id, label, name, value, onChange, isDisabled } = _a, rest = __rest$1(_a, ["id", "label", "name", "value", "onChange", "isDisabled"]);
|
|
@@ -18649,18 +18665,24 @@ const Toggle$1 = e__namespace.default.forwardRef((_a, ref) => {
|
|
|
18649
18665
|
const Textarea = e__namespace.default.forwardRef((_a, ref) => {
|
|
18650
18666
|
var { label, name, placeholder, value, onChange, isRequired, isDisabled, errorMessage, helpText, hasHiddenLabel, rows, cols, readonly, wrap, form, maxLength, autofocus } = _a, rest = __rest$1(_a, ["label", "name", "placeholder", "value", "onChange", "isRequired", "isDisabled", "errorMessage", "helpText", "hasHiddenLabel", "rows", "cols", "readonly", "wrap", "form", "maxLength", "autofocus"]);
|
|
18651
18667
|
const hasErrors = errorMessage && errorMessage.length > 0;
|
|
18652
|
-
|
|
18668
|
+
const textareaClasses = y$1('textarea', { error: hasErrors });
|
|
18669
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "textarea-wrapper", children: jsxRuntime.jsx("textarea", Object.assign({ ref: ref, rows: rows, cols: cols, autoFocus: autofocus, wrap: wrap, form: form, maxLength: maxLength, readOnly: readonly, "data-testid": `form-textarea-${name}`, name: name, disabled: isDisabled, placeholder: placeholder, onChange: onChange, className: textareaClasses, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)) }), hasErrors && jsxRuntime.jsx(DisplayFormError, { message: errorMessage }), helpText && (jsxRuntime.jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
18653
18670
|
});
|
|
18671
|
+
const LabeledTextarea = withLabel(Textarea);
|
|
18654
18672
|
|
|
18655
18673
|
const PasswordInput = e__namespace.default.forwardRef((_a, ref) => {
|
|
18656
|
-
var {
|
|
18674
|
+
var { name, placeholder, onChange, isRequired, isDisabled, errorMessage, helpText, hasShowPassword = true } = _a, rest = __rest$1(_a, ["name", "placeholder", "onChange", "isRequired", "isDisabled", "errorMessage", "helpText", "hasShowPassword"]);
|
|
18657
18675
|
const hasErrors = errorMessage && errorMessage.length > 0;
|
|
18658
18676
|
const [showPassword, setShowPassword] = e.useState(false);
|
|
18659
18677
|
const handleShowPassword = () => {
|
|
18660
18678
|
setShowPassword((prevShowPassword) => !prevShowPassword);
|
|
18661
18679
|
};
|
|
18662
|
-
|
|
18680
|
+
const inputClasses = y$1('password-input', {
|
|
18681
|
+
error: hasErrors,
|
|
18682
|
+
}, 'password-input--has-icon');
|
|
18683
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "password-input-wrapper", children: [jsxRuntime.jsx(Icon, { name: "lock", "data-testid": `${name}-embedded-icon`, className: "embedded-icon" }), jsxRuntime.jsx("input", Object.assign({ ref: ref, "data-testid": `form-password-input-${name}`, name: name, type: showPassword ? 'text' : 'password', disabled: isDisabled, placeholder: placeholder, onChange: onChange, className: inputClasses, "aria-invalid": hasErrors ? 'true' : 'false', "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)), hasShowPassword && (jsxRuntime.jsx(Icon, { name: showPassword ? 'fa-eye-slash' : 'eye', "data-testid": `${name}-${showPassword ? 'hide' : 'show'}-password-icon`, size: "md", onClick: handleShowPassword, className: "toggle-show-password-icon" }))] }), hasErrors && jsxRuntime.jsx(DisplayFormError, { message: errorMessage }), helpText && (jsxRuntime.jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
18663
18684
|
});
|
|
18685
|
+
const LabeledPasswordInput = withLabel(PasswordInput);
|
|
18664
18686
|
|
|
18665
18687
|
const OptionComponent = (_a) => {
|
|
18666
18688
|
var _b, _c, _d;
|
|
@@ -41100,7 +41122,7 @@ exports.Form = Form;
|
|
|
41100
41122
|
exports.GlobalStyles = GlobalStyles;
|
|
41101
41123
|
exports.Icon = Icon;
|
|
41102
41124
|
exports.IconButton = IconButton;
|
|
41103
|
-
exports.Input =
|
|
41125
|
+
exports.Input = LabeledInput;
|
|
41104
41126
|
exports.LegacyButton = Button$1;
|
|
41105
41127
|
exports.ListTable = ListTable;
|
|
41106
41128
|
exports.LoadingAwareContainer = LoadingAwareContainer;
|
|
@@ -41114,7 +41136,7 @@ exports.NoInputDatePicker = NoInputDatePicker;
|
|
|
41114
41136
|
exports.NumberInput = NumberInput;
|
|
41115
41137
|
exports.PADDINGS = padding;
|
|
41116
41138
|
exports.Pagination = Pagination;
|
|
41117
|
-
exports.PasswordInput =
|
|
41139
|
+
exports.PasswordInput = LabeledPasswordInput;
|
|
41118
41140
|
exports.PercentageRing = PercentageRing;
|
|
41119
41141
|
exports.Radio = Radio;
|
|
41120
41142
|
exports.RadioGroup = RadioGroup;
|
|
@@ -41137,7 +41159,7 @@ exports.TYPOGRAPHY = typography;
|
|
|
41137
41159
|
exports.Table = Table$1;
|
|
41138
41160
|
exports.TextInput = TextInput;
|
|
41139
41161
|
exports.TextTruncate = TextTruncate;
|
|
41140
|
-
exports.Textarea =
|
|
41162
|
+
exports.Textarea = LabeledTextarea;
|
|
41141
41163
|
exports.Toggle = Toggle;
|
|
41142
41164
|
exports.ToggleInput = Toggle$1;
|
|
41143
41165
|
exports.Tooltip = Tooltip;
|