@indico-data/design-system 2.10.0 → 2.12.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 +99 -8
- package/lib/index.d.ts +47 -15
- package/lib/index.esm.css +99 -8
- package/lib/index.esm.js +61 -28
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +62 -27
- package/lib/index.js.map +1 -1
- package/lib/src/components/forms/checkbox/Checkbox.d.ts +2 -1
- package/lib/src/components/forms/form/Form.d.ts +14 -0
- package/lib/src/components/forms/form/Form.stories.d.ts +8 -0
- package/lib/src/components/forms/form/index.d.ts +1 -0
- package/lib/src/components/forms/input/Input.d.ts +4 -4
- package/lib/src/components/forms/passwordInput/PasswordInput.d.ts +4 -3
- package/lib/src/components/forms/radio/Radio.d.ts +2 -1
- package/lib/src/components/forms/select/Select.d.ts +6 -0
- package/lib/src/components/forms/select/Select.stories.d.ts +7 -0
- package/lib/src/components/forms/select/__tests__/Select.test.d.ts +1 -0
- package/lib/src/components/forms/select/index.d.ts +1 -0
- package/lib/src/components/forms/select/types.d.ts +6 -0
- package/lib/src/components/forms/subcomponents/DisplayFormError.d.ts +5 -0
- package/lib/src/components/forms/textarea/Textarea.d.ts +4 -3
- package/lib/src/components/forms/toggle/Toggle.d.ts +2 -1
- package/lib/src/components/index.d.ts +2 -0
- package/lib/src/index.d.ts +2 -0
- package/lib/src/types.d.ts +2 -0
- package/package.json +5 -2
- package/src/components/forms/checkbox/Checkbox.stories.tsx +2 -2
- package/src/components/forms/checkbox/Checkbox.tsx +32 -41
- package/src/components/forms/form/Form.mdx +134 -0
- package/src/components/forms/form/Form.stories.tsx +413 -0
- package/src/components/forms/form/Form.tsx +64 -0
- package/src/components/forms/form/__tests__/Form.test.tsx +35 -0
- package/src/components/forms/form/index.ts +1 -0
- package/src/components/forms/form/styles/Form.scss +3 -0
- package/src/components/forms/input/Input.tsx +66 -65
- package/src/components/forms/input/__tests__/Input.test.tsx +2 -13
- package/src/components/forms/input/styles/Input.scss +1 -8
- package/src/components/forms/passwordInput/PasswordInput.stories.tsx +11 -12
- package/src/components/forms/passwordInput/PasswordInput.tsx +63 -59
- package/src/components/forms/passwordInput/__tests__/PasswordInput.test.tsx +1 -1
- package/src/components/forms/radio/Radio.tsx +32 -35
- package/src/components/forms/select/Select.stories.tsx +118 -0
- package/src/components/forms/select/Select.tsx +43 -0
- package/src/components/forms/select/__tests__/Select.test.tsx +67 -0
- package/src/components/forms/select/index.ts +1 -0
- package/src/components/forms/select/styles/Select.scss +120 -0
- package/src/components/forms/select/types.ts +6 -0
- package/src/components/forms/subcomponents/DisplayFormError.tsx +7 -0
- package/src/components/forms/textarea/Textarea.stories.tsx +15 -21
- package/src/components/forms/textarea/Textarea.tsx +64 -62
- package/src/components/forms/textarea/__tests__/Textarea.test.tsx +1 -1
- package/src/components/forms/textarea/styles/Textarea.scss +1 -1
- package/src/components/forms/toggle/Toggle.tsx +30 -37
- package/src/components/index.ts +2 -0
- package/src/index.ts +2 -0
- package/src/styles/index.scss +3 -1
- package/src/types.ts +3 -0
- package/lib/src/components/forms/subcomponents/ErrorList.d.ts +0 -6
- package/src/components/forms/subcomponents/ErrorList.tsx +0 -14
- package/src/components/forms/subcomponents/__tests__/ErrorList.test.tsx +0 -16
- /package/lib/src/components/forms/{subcomponents/__tests__/ErrorList.test.d.ts → form/__tests__/Form.test.d.ts} +0 -0
package/lib/index.esm.js
CHANGED
|
@@ -18636,48 +18636,81 @@ const Label = ({ label, name, isRequired, hasHiddenLabel }) => {
|
|
|
18636
18636
|
return (jsx("div", { "data-testid": `${name}-testId`, className: `form-label ${hasHiddenLabel ? 'is-visually-hidden' : ''}`, children: jsxs("label", { htmlFor: `${name}`, children: [label, isRequired ? jsx("span", { className: "text-error", children: " *" }) : ''] }) }));
|
|
18637
18637
|
};
|
|
18638
18638
|
|
|
18639
|
-
const
|
|
18640
|
-
return
|
|
18639
|
+
const DisplayFormError = ({ message }) => {
|
|
18640
|
+
return jsx("p", { className: "form-errors", children: message });
|
|
18641
18641
|
};
|
|
18642
18642
|
|
|
18643
|
-
const Input = (_a) => {
|
|
18644
|
-
var {
|
|
18645
|
-
const hasErrors =
|
|
18643
|
+
const Input = e__default.forwardRef((_a, ref) => {
|
|
18644
|
+
var { label, name, placeholder, onChange, isRequired, isDisabled, isClearable, errorMessage, helpText, iconName, hasHiddenLabel, className } = _a, rest = __rest$1(_a, ["label", "name", "placeholder", "onChange", "isRequired", "isDisabled", "isClearable", "errorMessage", "helpText", "iconName", "hasHiddenLabel", "className"]);
|
|
18645
|
+
const hasErrors = errorMessage && errorMessage.length > 0;
|
|
18646
18646
|
const handleClear = () => {
|
|
18647
18647
|
onChange({ target: { value: '' } });
|
|
18648
18648
|
};
|
|
18649
|
-
return (jsxs("div", { className: "form-control", children: [jsx(Label, { label: label, name: name, isRequired: isRequired, hasHiddenLabel: hasHiddenLabel }), jsxs("div", { className: "input-wrapper", children: [iconName && (jsx(Icon, { name: iconName, "data-testid": `${name}-embedded-icon`, className: "embedded-icon" })), jsx("input", Object.assign({ ref: ref, "data-testid": `form-input-${name}`, name: name, type: "text", disabled: isDisabled,
|
|
18650
|
-
};
|
|
18649
|
+
return (jsxs("div", { className: "form-control", children: [jsx(Label, { label: label, name: name, isRequired: isRequired, hasHiddenLabel: hasHiddenLabel }), jsxs("div", { className: "input-wrapper", children: [iconName && (jsx(Icon, { name: iconName, "data-testid": `${name}-embedded-icon`, className: "embedded-icon" })), jsx("input", Object.assign({ ref: ref, "data-testid": `form-input-${name}`, name: name, type: "text", disabled: isDisabled, placeholder: placeholder, onChange: onChange, className: `input ${hasErrors ? 'error' : ''} ${iconName ? 'input--has-icon' : ''} ${className}`, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired, "aria-label": label }, rest)), isClearable && (jsx(Icon, { name: "x-close", "data-testid": `${name}-clearable-icon`, size: "sm", onClick: handleClear, className: "clearable-icon" }))] }), hasErrors && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
18650
|
+
});
|
|
18651
18651
|
|
|
18652
|
-
const Radio$2 = (_a) => {
|
|
18653
|
-
var {
|
|
18654
|
-
return (jsx("div", { className: "form-control", children: jsxs("div", { className: "radio-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-radio-input-${name}
|
|
18655
|
-
};
|
|
18652
|
+
const Radio$2 = e__default.forwardRef((_a, ref) => {
|
|
18653
|
+
var { id, label, name, value, onChange, isDisabled } = _a, rest = __rest$1(_a, ["id", "label", "name", "value", "onChange", "isDisabled"]);
|
|
18654
|
+
return (jsx("div", { className: "form-control", children: jsxs("div", { className: "radio-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-radio-input-${name}`, className: "radio-input", type: "radio", id: id, name: name, value: value, disabled: isDisabled, ref: ref, onChange: onChange, tabIndex: 0, "aria-describedby": id, "aria-label": label }, rest)), jsx("label", { htmlFor: id, className: "radio-input-label", "data-testid": `label-radio-input-${name}`, children: label })] }) }));
|
|
18655
|
+
});
|
|
18656
18656
|
|
|
18657
|
-
const Checkbox = (_a) => {
|
|
18658
|
-
var {
|
|
18659
|
-
return (jsx("div", { className: "form-control", children: jsxs("div", { className: "checkbox-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-checkbox-input-${name}`, className: "checkbox-input", type: "checkbox", id: id,
|
|
18660
|
-
};
|
|
18657
|
+
const Checkbox = e__default.forwardRef((_a, ref) => {
|
|
18658
|
+
var { id, label, name, value, onChange, isDisabled, isChecked = false } = _a, rest = __rest$1(_a, ["id", "label", "name", "value", "onChange", "isDisabled", "isChecked"]);
|
|
18659
|
+
return (jsx("div", { className: "form-control", children: jsxs("div", { className: "checkbox-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-checkbox-input-${name}`, className: "checkbox-input", type: "checkbox", id: id, name: name, value: value, disabled: isDisabled, ref: ref, onChange: onChange, tabIndex: 0, "aria-describedby": id, "aria-label": label }, rest)), jsx("label", { htmlFor: id, className: "checkbox-input-label", "data-testid": `label-checkbox-input-${name}`, children: label })] }) }));
|
|
18660
|
+
});
|
|
18661
18661
|
|
|
18662
|
-
const Toggle$1 = (_a) => {
|
|
18663
|
-
var {
|
|
18662
|
+
const Toggle$1 = e__default.forwardRef((_a, ref) => {
|
|
18663
|
+
var { id, label, name, value, onChange, isDisabled, isChecked } = _a, rest = __rest$1(_a, ["id", "label", "name", "value", "onChange", "isDisabled", "isChecked"]);
|
|
18664
18664
|
return (jsx("div", { className: "form-control", children: jsxs("div", { className: "toggle-wrapper", children: [jsx("input", Object.assign({ "data-testid": `form-toggle-input-${name}`, className: "toggle-input", type: "checkbox", id: id, checked: isChecked, name: name, value: value, disabled: isDisabled, ref: ref, onChange: onChange, tabIndex: 0, "aria-describedby": id, "aria-label": label }, rest)), jsx("label", { htmlFor: id, className: "switch" }), jsx("label", { className: 'toggle-label', htmlFor: id, children: label })] }) }));
|
|
18665
|
-
};
|
|
18665
|
+
});
|
|
18666
18666
|
|
|
18667
|
-
const Textarea = (_a) => {
|
|
18668
|
-
var {
|
|
18669
|
-
const hasErrors =
|
|
18670
|
-
return (jsxs("div", { className: "form-control", children: [jsx(Label, { label: label, name: name, isRequired: isRequired, hasHiddenLabel: hasHiddenLabel }), jsx("div", { className: "textarea-wrapper", children: jsx("textarea", Object.assign({ ref: ref, rows: rows, cols: cols, autoFocus: autofocus, wrap: wrap, form: form,
|
|
18671
|
-
};
|
|
18667
|
+
const Textarea = e__default.forwardRef((_a, ref) => {
|
|
18668
|
+
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"]);
|
|
18669
|
+
const hasErrors = errorMessage && errorMessage.length > 0;
|
|
18670
|
+
return (jsxs("div", { className: "form-control", children: [jsx(Label, { label: label, name: name, isRequired: isRequired, hasHiddenLabel: hasHiddenLabel }), jsx("div", { className: "textarea-wrapper", children: 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: `textarea ${hasErrors ? 'error' : ''}`, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired, "aria-label": label }, rest)) }), hasErrors && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
18671
|
+
});
|
|
18672
18672
|
|
|
18673
|
-
const PasswordInput = (_a) => {
|
|
18674
|
-
var { label, name, placeholder,
|
|
18675
|
-
const hasErrors =
|
|
18673
|
+
const PasswordInput = e__default.forwardRef((_a, ref) => {
|
|
18674
|
+
var { label, name, placeholder, onChange, isRequired, isDisabled, errorMessage, helpText, hasHiddenLabel, hasShowPassword = true } = _a, rest = __rest$1(_a, ["label", "name", "placeholder", "onChange", "isRequired", "isDisabled", "errorMessage", "helpText", "hasHiddenLabel", "hasShowPassword"]);
|
|
18675
|
+
const hasErrors = errorMessage && errorMessage.length > 0;
|
|
18676
18676
|
const [showPassword, setShowPassword] = useState(false);
|
|
18677
18677
|
const handleShowPassword = () => {
|
|
18678
18678
|
setShowPassword((prevShowPassword) => !prevShowPassword);
|
|
18679
18679
|
};
|
|
18680
|
-
return (jsxs("div", { className: "form-control", children: [jsx(Label, { label: label, name: name, isRequired: isRequired, hasHiddenLabel: hasHiddenLabel }), jsxs("div", { className: "password-input-wrapper", children: [jsx(Icon, { name: "lock", "data-testid": `${name}-embedded-icon`, className: "embedded-icon" }), jsx("input", Object.assign({ "data-testid": `form-password-input-${name}`, name: name, type: showPassword ? 'text' : 'password', disabled: isDisabled,
|
|
18680
|
+
return (jsxs("div", { className: "form-control", children: [jsx(Label, { label: label, name: name, isRequired: isRequired, hasHiddenLabel: hasHiddenLabel }), jsxs("div", { className: "password-input-wrapper", children: [jsx(Icon, { name: "lock", "data-testid": `${name}-embedded-icon`, className: "embedded-icon" }), 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: `password-input ${hasErrors ? 'error' : ''} password-input--has-icon`, "aria-invalid": hasErrors ? 'true' : 'false', "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired, "aria-label": label }, rest)), hasShowPassword && (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 && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
|
|
18681
|
+
});
|
|
18682
|
+
|
|
18683
|
+
const OptionComponent = (_a) => {
|
|
18684
|
+
var _b, _c, _d;
|
|
18685
|
+
var props = __rest$1(_a, []);
|
|
18686
|
+
return (jsx(components.Option, Object.assign({}, props, { children: jsxs("div", { className: "select__items", children: [jsx("div", { className: "select__item-value", children: (_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.label }), ((_c = props === null || props === void 0 ? void 0 : props.data) === null || _c === void 0 ? void 0 : _c.detail) && jsx("div", { className: "select__item-detail", children: (_d = props === null || props === void 0 ? void 0 : props.data) === null || _d === void 0 ? void 0 : _d.detail })] }) })));
|
|
18687
|
+
};
|
|
18688
|
+
const Select$1 = (_a) => {
|
|
18689
|
+
var { classNamePrefix = 'select', className, components: customComponents } = _a, props = __rest$1(_a, ["classNamePrefix", "className", "components"]);
|
|
18690
|
+
const defaultComponents = {
|
|
18691
|
+
Option: OptionComponent,
|
|
18692
|
+
};
|
|
18693
|
+
const mergedComponents = Object.assign(Object.assign({}, defaultComponents), customComponents);
|
|
18694
|
+
return (jsx(ReactSelect, Object.assign({ classNamePrefix: classNamePrefix, className: y$1('select-wrapper', className), components: mergedComponents }, props)));
|
|
18695
|
+
};
|
|
18696
|
+
|
|
18697
|
+
const Form = (_a) => {
|
|
18698
|
+
var { children, onSubmit, action, method, target, autocomplete, noValidate, enctype, rel } = _a, rest = __rest$1(_a, ["children", "onSubmit", "action", "method", "target", "autocomplete", "noValidate", "enctype", "rel"]);
|
|
18699
|
+
const handleSubmit = (e) => {
|
|
18700
|
+
e.preventDefault(); // Prevent the default form submission
|
|
18701
|
+
// Create a FormData object, passing in the form (e.currentTarget)
|
|
18702
|
+
const formData = new FormData(e.currentTarget);
|
|
18703
|
+
// Convert FormData into a plain object
|
|
18704
|
+
const formObject = Array.from(formData.entries()).reduce((obj, [key, value]) => {
|
|
18705
|
+
obj[key] = value.toString();
|
|
18706
|
+
return obj;
|
|
18707
|
+
}, {});
|
|
18708
|
+
// Call the onSubmit prop, if provided, passing the form object instead of the event
|
|
18709
|
+
if (onSubmit) {
|
|
18710
|
+
onSubmit(formObject); // Modified to pass formObject instead of e
|
|
18711
|
+
}
|
|
18712
|
+
};
|
|
18713
|
+
return (jsx("form", Object.assign({ onSubmit: handleSubmit, action: action, method: method, target: target, autoComplete: autocomplete, noValidate: noValidate, encType: enctype, rel: rel }, rest, { children: children })));
|
|
18681
18714
|
};
|
|
18682
18715
|
|
|
18683
18716
|
const StyledAccordion = styled.details `
|
|
@@ -41501,5 +41534,5 @@ const Tooltip = (props) => {
|
|
|
41501
41534
|
openOnClick: props.clickToShow, id: props.for, delayShow: props.delayShow, delayHide: props.delayHide, children: props.children })] }));
|
|
41502
41535
|
};
|
|
41503
41536
|
|
|
41504
|
-
export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$2 as Button, allColors as COLORS, Checkbox, CirclePulse, CircleSpinner, Col, ConfirmModal, Container, DatePicker, EditableInput, GlobalStyles, Icon, IconButton, Input, Button$1 as LegacyButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PasswordInput, PercentageRing, Radio, RadioGroup, Radio$2 as RadioInput, RandomLoadingMessage, Row$1 as Row, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Shrug, SingleCombobox, typography as TYPOGRAPHY, Table$1 as Table, TextInput, TextTruncate, Textarea, Toggle, Toggle$1 as ToggleInput, Tooltip, color as colorUtils, number as numberUtils, string as stringUtils };
|
|
41537
|
+
export { animation as ANIMATION, Radio$1 as AbstractRadio, RadioGroup$1 as AbstractRadioGroup, Accordion, breakpoints as BREAKPOINT, BarSpinner, BorderSelect, Button$2 as Button, allColors as COLORS, Checkbox, CirclePulse, CircleSpinner, Col, ConfirmModal, Container, DatePicker, EditableInput, Form, GlobalStyles, Icon, IconButton, Input, Button$1 as LegacyButton, ListTable, LoadingAwareContainer, LoadingList, margin as MARGINS, MATH, mediaQueries as MEDIA_QUERIES, ModalBase, MultiCombobox, NoInputDatePicker, NumberInput, padding as PADDINGS, Pagination, PasswordInput, PercentageRing, Radio, RadioGroup, Radio$2 as RadioInput, RandomLoadingMessage, Row$1 as Row, spacings as SPACING, SearchInput, Section, SectionBlock, SectionBody, SectionHeader, SectionTable, Select, Select$1 as SelectInput, Shrug, SingleCombobox, typography as TYPOGRAPHY, Table$1 as Table, TextInput, TextTruncate, Textarea, Toggle, Toggle$1 as ToggleInput, Tooltip, color as colorUtils, number as numberUtils, string as stringUtils };
|
|
41505
41538
|
//# sourceMappingURL=index.esm.js.map
|