@indico-data/design-system 2.60.7 → 2.60.9
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/components/forms/date/inputDateRangePicker/InputDateRangePicker.d.ts +3 -0
- package/lib/components/forms/select/Select.d.ts +6 -1
- package/lib/components/forms/select/Select.stories.d.ts +2 -1
- package/lib/components/forms/subcomponents/Label.d.ts +1 -1
- package/lib/index.d.ts +31 -3
- package/lib/index.esm.js +57 -2
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +58 -2
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.tsx +23 -0
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.tsx +9 -3
- package/src/components/forms/select/Select.stories.tsx +38 -1
- package/src/components/forms/select/Select.tsx +12 -1
- package/src/components/forms/subcomponents/Label.tsx +1 -1
- package/src/index.ts +3 -0
package/lib/index.js
CHANGED
|
@@ -5841,13 +5841,14 @@ const OptionComponent = (_a) => {
|
|
|
5841
5841
|
return (jsxRuntime.jsx(ReactSelect.components.Option, Object.assign({}, props, { children: jsxRuntime.jsxs("div", { className: "select__items", children: [jsxRuntime.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) && jsxRuntime.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 })] }) })));
|
|
5842
5842
|
};
|
|
5843
5843
|
const Select$1 = (_a) => {
|
|
5844
|
-
var { classNamePrefix = 'select', className, components: customComponents } = _a, props = __rest(_a, ["classNamePrefix", "className", "components"]);
|
|
5844
|
+
var { classNamePrefix = 'select', className, components: customComponents, label, hasHiddenLabel, name } = _a, props = __rest(_a, ["classNamePrefix", "className", "components", "label", "hasHiddenLabel", "name"]);
|
|
5845
5845
|
const defaultComponents = {
|
|
5846
5846
|
Option: OptionComponent,
|
|
5847
5847
|
};
|
|
5848
5848
|
const mergedComponents = Object.assign(Object.assign({}, defaultComponents), customComponents);
|
|
5849
5849
|
return (jsxRuntime.jsx(ReactSelect__default.default, Object.assign({ classNamePrefix: classNamePrefix, className: classNames('select-wrapper', className), components: mergedComponents }, props)));
|
|
5850
5850
|
};
|
|
5851
|
+
const LabeledSelect = withLabel(Select$1);
|
|
5851
5852
|
|
|
5852
5853
|
/**
|
|
5853
5854
|
* The UI elements composing DayPicker. These elements are mapped to
|
|
@@ -19116,6 +19117,60 @@ function SingleInputDatePicker(props) {
|
|
|
19116
19117
|
return (jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [jsxRuntime.jsx(LabeledInput, { id: inputId, value: localTextValue, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, isClearable: isClearable, onChange: handleInputChange, errorMessage: errorMessage, label: 'Single Date Picker', name: 'Date Picker' }), jsxRuntime.jsx(DatePicker, Object.assign({ captionLayout: captionLayout, mode: "single", selected: selected, onSelect: handleDayPickerSelect, month: localMonth, onMonthChange: setLocalMonth }, rest))] }));
|
|
19117
19118
|
}
|
|
19118
19119
|
|
|
19120
|
+
function InputDateRangePicker(props) {
|
|
19121
|
+
const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, month, id, onSelect, selected, isOpen, inputPlaceholder, inputIconName, toErrorMessage, fromErrorMessage, gutterWidth, fromLabel, toLabel } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "month", "id", "onSelect", "selected", "isOpen", "inputPlaceholder", "inputIconName", "toErrorMessage", "fromErrorMessage", "gutterWidth", "fromLabel", "toLabel"]);
|
|
19122
|
+
const inputId = React.useId();
|
|
19123
|
+
// Hold the input values in state
|
|
19124
|
+
const [localTextValueFrom, setLocalTextValueFrom] = React.useState((selected === null || selected === void 0 ? void 0 : selected.from) ? formatDateAsString(selected.from) : '');
|
|
19125
|
+
const [localTextValueTo, setLocalTextValueTo] = React.useState((selected === null || selected === void 0 ? void 0 : selected.to) ? formatDateAsString(selected.to) : '');
|
|
19126
|
+
const [localMonth, setLocalMonth] = React.useState((selected === null || selected === void 0 ? void 0 : selected.from) || new Date());
|
|
19127
|
+
// When the day picker is selected, update the text values.
|
|
19128
|
+
const handleDayPickerSelect = (date) => {
|
|
19129
|
+
if (!date) {
|
|
19130
|
+
setLocalTextValueFrom('');
|
|
19131
|
+
setLocalTextValueTo('');
|
|
19132
|
+
onSelect(undefined);
|
|
19133
|
+
}
|
|
19134
|
+
else {
|
|
19135
|
+
setLocalTextValueFrom(date.from ? formatDateAsString(date.from) : '');
|
|
19136
|
+
setLocalTextValueTo(date.to ? formatDateAsString(date.to) : '');
|
|
19137
|
+
onSelect(date);
|
|
19138
|
+
}
|
|
19139
|
+
};
|
|
19140
|
+
// When the text input is changed, update the selected date.
|
|
19141
|
+
const handleInputChange = (e, type) => {
|
|
19142
|
+
const value = e.target.value;
|
|
19143
|
+
if (type === 'from') {
|
|
19144
|
+
setLocalTextValueFrom(value);
|
|
19145
|
+
}
|
|
19146
|
+
else {
|
|
19147
|
+
setLocalTextValueTo(value);
|
|
19148
|
+
}
|
|
19149
|
+
const parsedDate = parse(value, 'MM/dd/yyyy', new Date());
|
|
19150
|
+
if (isValid(parsedDate)) {
|
|
19151
|
+
onSelect({
|
|
19152
|
+
from: type === 'from' ? parsedDate : selected === null || selected === void 0 ? void 0 : selected.from,
|
|
19153
|
+
to: type === 'to' ? parsedDate : selected === null || selected === void 0 ? void 0 : selected.to,
|
|
19154
|
+
});
|
|
19155
|
+
}
|
|
19156
|
+
else {
|
|
19157
|
+
onSelect({
|
|
19158
|
+
from: type === 'from' ? undefined : selected === null || selected === void 0 ? void 0 : selected.from,
|
|
19159
|
+
to: type === 'to' ? undefined : selected === null || selected === void 0 ? void 0 : selected.to,
|
|
19160
|
+
});
|
|
19161
|
+
}
|
|
19162
|
+
};
|
|
19163
|
+
// clear selection if clear on close is true
|
|
19164
|
+
React.useEffect(() => {
|
|
19165
|
+
if (!isOpen) {
|
|
19166
|
+
onSelect(undefined);
|
|
19167
|
+
setLocalTextValueFrom('');
|
|
19168
|
+
setLocalTextValueTo('');
|
|
19169
|
+
}
|
|
19170
|
+
}, [isOpen]);
|
|
19171
|
+
return (jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [jsxRuntime.jsxs(Row, { gutterWidth: gutterWidth, children: [jsxRuntime.jsx(Col, { children: jsxRuntime.jsx(LabeledInput, { id: `${inputId}-from`, value: localTextValueFrom, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, onChange: (e) => handleInputChange(e, 'from'), errorMessage: fromErrorMessage, label: fromLabel, name: 'From Date', "data-testid": "date-picker-from" }) }), jsxRuntime.jsx(Col, { children: jsxRuntime.jsx(LabeledInput, { id: `${inputId}-to`, value: localTextValueTo, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, onChange: (e) => handleInputChange(e, 'to'), errorMessage: toErrorMessage, label: toLabel, name: 'To Date', "data-testid": "date-picker-to" }) })] }), jsxRuntime.jsx(DatePicker, Object.assign({ captionLayout: captionLayout, month: localMonth, onMonthChange: (date) => setLocalMonth(date), mode: "range", selected: selected, onSelect: handleDayPickerSelect }, rest))] }));
|
|
19172
|
+
}
|
|
19173
|
+
|
|
19119
19174
|
const Form = (_a) => {
|
|
19120
19175
|
var { children, onSubmit, action, method, target, autocomplete, noValidate, enctype, rel } = _a, rest = __rest(_a, ["children", "onSubmit", "action", "method", "target", "autocomplete", "noValidate", "enctype", "rel"]);
|
|
19121
19176
|
const handleSubmit = (e) => {
|
|
@@ -43068,6 +43123,7 @@ exports.Form = Form;
|
|
|
43068
43123
|
exports.Icon = Icon;
|
|
43069
43124
|
exports.IconTriggerDatePicker = IconTriggerDatePicker;
|
|
43070
43125
|
exports.Input = LabeledInput;
|
|
43126
|
+
exports.InputDateRangePicker = InputDateRangePicker;
|
|
43071
43127
|
exports.Menu = Menu;
|
|
43072
43128
|
exports.Modal = Modal;
|
|
43073
43129
|
exports.Pagination = Pagination;
|
|
@@ -43075,7 +43131,7 @@ exports.PasswordInput = LabeledPasswordInput;
|
|
|
43075
43131
|
exports.Pill = Pill;
|
|
43076
43132
|
exports.RadioInput = Radio;
|
|
43077
43133
|
exports.Row = Row;
|
|
43078
|
-
exports.SelectInput =
|
|
43134
|
+
exports.SelectInput = LabeledSelect;
|
|
43079
43135
|
exports.SingleInputDatePicker = SingleInputDatePicker;
|
|
43080
43136
|
exports.Skeleton = Skeleton;
|
|
43081
43137
|
exports.Stepper = Stepper;
|