@indico-data/design-system 2.60.9 → 2.60.11

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.js CHANGED
@@ -19118,7 +19118,7 @@ function SingleInputDatePicker(props) {
19118
19118
  }
19119
19119
 
19120
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"]);
19121
+ const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, month, id, onSelect, selected, isOpen, setIsOpen, inputPlaceholder, inputIconName, toErrorMessage, fromErrorMessage, gutterWidth, fromLabel, toLabel, closeOnSelect, clearOnClose } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "month", "id", "onSelect", "selected", "isOpen", "setIsOpen", "inputPlaceholder", "inputIconName", "toErrorMessage", "fromErrorMessage", "gutterWidth", "fromLabel", "toLabel", "closeOnSelect", "clearOnClose"]);
19122
19122
  const inputId = React.useId();
19123
19123
  // Hold the input values in state
19124
19124
  const [localTextValueFrom, setLocalTextValueFrom] = React.useState((selected === null || selected === void 0 ? void 0 : selected.from) ? formatDateAsString(selected.from) : '');
@@ -19135,6 +19135,15 @@ function InputDateRangePicker(props) {
19135
19135
  setLocalTextValueFrom(date.from ? formatDateAsString(date.from) : '');
19136
19136
  setLocalTextValueTo(date.to ? formatDateAsString(date.to) : '');
19137
19137
  onSelect(date);
19138
+ // Close the picker ONLY when a complete range is selected (from and to are different dates)
19139
+ if (closeOnSelect &&
19140
+ date.from &&
19141
+ date.to &&
19142
+ setIsOpen &&
19143
+ date.from.getTime() !== date.to.getTime() // Ensure from and to are different dates
19144
+ ) {
19145
+ setIsOpen(false);
19146
+ }
19138
19147
  }
19139
19148
  };
19140
19149
  // When the text input is changed, update the selected date.
@@ -19162,13 +19171,13 @@ function InputDateRangePicker(props) {
19162
19171
  };
19163
19172
  // clear selection if clear on close is true
19164
19173
  React.useEffect(() => {
19165
- if (!isOpen) {
19174
+ if (!isOpen && clearOnClose) {
19166
19175
  onSelect(undefined);
19167
19176
  setLocalTextValueFrom('');
19168
19177
  setLocalTextValueTo('');
19169
19178
  }
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))] }));
19179
+ }, [isOpen, clearOnClose]);
19180
+ return (jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, setIsOpen: setIsOpen, 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
19181
  }
19173
19182
 
19174
19183
  const Form = (_a) => {
@@ -23994,6 +24003,92 @@ function getCoreRowModel() {
23994
24003
  }, getMemoOptions(table.options, 'debugTable', 'getRowModel', () => table._autoResetPageIndex()));
23995
24004
  }
23996
24005
 
24006
+ function getSortedRowModel() {
24007
+ return table => memo(() => [table.getState().sorting, table.getPreSortedRowModel()], (sorting, rowModel) => {
24008
+ if (!rowModel.rows.length || !(sorting != null && sorting.length)) {
24009
+ return rowModel;
24010
+ }
24011
+ const sortingState = table.getState().sorting;
24012
+ const sortedFlatRows = [];
24013
+
24014
+ // Filter out sortings that correspond to non existing columns
24015
+ const availableSorting = sortingState.filter(sort => {
24016
+ var _table$getColumn;
24017
+ return (_table$getColumn = table.getColumn(sort.id)) == null ? void 0 : _table$getColumn.getCanSort();
24018
+ });
24019
+ const columnInfoById = {};
24020
+ availableSorting.forEach(sortEntry => {
24021
+ const column = table.getColumn(sortEntry.id);
24022
+ if (!column) return;
24023
+ columnInfoById[sortEntry.id] = {
24024
+ sortUndefined: column.columnDef.sortUndefined,
24025
+ invertSorting: column.columnDef.invertSorting,
24026
+ sortingFn: column.getSortingFn()
24027
+ };
24028
+ });
24029
+ const sortData = rows => {
24030
+ // This will also perform a stable sorting using the row index
24031
+ // if needed.
24032
+ const sortedData = rows.map(row => ({
24033
+ ...row
24034
+ }));
24035
+ sortedData.sort((rowA, rowB) => {
24036
+ for (let i = 0; i < availableSorting.length; i += 1) {
24037
+ var _sortEntry$desc;
24038
+ const sortEntry = availableSorting[i];
24039
+ const columnInfo = columnInfoById[sortEntry.id];
24040
+ const sortUndefined = columnInfo.sortUndefined;
24041
+ const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
24042
+ let sortInt = 0;
24043
+
24044
+ // All sorting ints should always return in ascending order
24045
+ if (sortUndefined) {
24046
+ const aValue = rowA.getValue(sortEntry.id);
24047
+ const bValue = rowB.getValue(sortEntry.id);
24048
+ const aUndefined = aValue === undefined;
24049
+ const bUndefined = bValue === undefined;
24050
+ if (aUndefined || bUndefined) {
24051
+ if (sortUndefined === 'first') return aUndefined ? -1 : 1;
24052
+ if (sortUndefined === 'last') return aUndefined ? 1 : -1;
24053
+ sortInt = aUndefined && bUndefined ? 0 : aUndefined ? sortUndefined : -sortUndefined;
24054
+ }
24055
+ }
24056
+ if (sortInt === 0) {
24057
+ sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id);
24058
+ }
24059
+
24060
+ // If sorting is non-zero, take care of desc and inversion
24061
+ if (sortInt !== 0) {
24062
+ if (isDesc) {
24063
+ sortInt *= -1;
24064
+ }
24065
+ if (columnInfo.invertSorting) {
24066
+ sortInt *= -1;
24067
+ }
24068
+ return sortInt;
24069
+ }
24070
+ }
24071
+ return rowA.index - rowB.index;
24072
+ });
24073
+
24074
+ // If there are sub-rows, sort them
24075
+ sortedData.forEach(row => {
24076
+ var _row$subRows;
24077
+ sortedFlatRows.push(row);
24078
+ if ((_row$subRows = row.subRows) != null && _row$subRows.length) {
24079
+ row.subRows = sortData(row.subRows);
24080
+ }
24081
+ });
24082
+ return sortedData;
24083
+ };
24084
+ return {
24085
+ rows: sortData(rowModel.rows),
24086
+ flatRows: sortedFlatRows,
24087
+ rowsById: rowModel.rowsById
24088
+ };
24089
+ }, getMemoOptions(table.options, 'debugTable', 'getSortedRowModel', () => table._autoResetPageIndex()));
24090
+ }
24091
+
23997
24092
  /**
23998
24093
  * react-table
23999
24094
  *
@@ -43148,8 +43243,11 @@ exports.autoPlacement = autoPlacement;
43148
43243
  exports.autoUpdate = autoUpdate$1;
43149
43244
  exports.computePosition = computePosition$2;
43150
43245
  exports.detectOverflow = detectOverflow$1;
43246
+ exports.flexRender = flexRender;
43151
43247
  exports.flip = flip$2;
43248
+ exports.getCoreRowModel = getCoreRowModel;
43152
43249
  exports.getOverflowAncestors = getOverflowAncestors$1;
43250
+ exports.getSortedRowModel = getSortedRowModel;
43153
43251
  exports.hide = hide$1;
43154
43252
  exports.inline = inline;
43155
43253
  exports.limitShift = limitShift;
@@ -43160,4 +43258,5 @@ exports.shift = shift$2;
43160
43258
  exports.size = size;
43161
43259
  exports.toast = y;
43162
43260
  exports.useFloating = useFloating$1;
43261
+ exports.useReactTable = useReactTable;
43163
43262
  //# sourceMappingURL=index.js.map