mig-schema-table 3.0.75 → 3.0.77

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.
@@ -19,6 +19,7 @@ import { endOfDay } from "date-fns";
19
19
  const FilterMenuComponent = ({ columnFilterValue, onChange, onInputKeyDown, propConfig, propIsRequired, propName, propSchema, }) => {
20
20
  const { type, format, minimum, maximum } = propSchema || {};
21
21
  const value = columnFilterValue;
22
+ const isDateTime = format === "date-time";
22
23
  switch (type) {
23
24
  case "integer":
24
25
  return (_jsx("ol", Object.assign({ className: "schema-table-menu schema-table__th-menu__filter-menu-component" }, { children: _jsx("li", { children: _jsx("input", { autoFocus: true, className: "form-control", type: "number", value: (value || ""), "data-prop-name": propName, onChange: (e) => {
@@ -59,8 +60,10 @@ const FilterMenuComponent = ({ columnFilterValue, onChange, onInputKeyDown, prop
59
60
  return (_jsx("option", Object.assign({ value: rowName }, { children: rowName }), `column-filter-select-${rowName}`));
60
61
  })] })) }) })));
61
62
  }
62
- if (format === "date-time" || format === "date") {
63
- const dateFormat = format === "date" ? DEFAULT_DATE_FORMAT : DEFAULT_DATE_TIME_FORMAT;
63
+ if (isDateTime || format === "date") {
64
+ const dateFormat = isDateTime
65
+ ? DEFAULT_DATE_TIME_FORMAT
66
+ : DEFAULT_DATE_FORMAT;
64
67
  const dateRangeValue = (columnFilterValue || {
65
68
  from: undefined,
66
69
  to: undefined,
@@ -83,17 +86,21 @@ const FilterMenuComponent = ({ columnFilterValue, onChange, onInputKeyDown, prop
83
86
  return;
84
87
  }
85
88
  onChange(Object.assign(Object.assign({}, columnFilterValue), { from: date || undefined }), true);
86
- }, placeholderText: dateFormat, isClearable: true, selectsStart: true, showTimeSelect: format === "date-time", timeIntervals: 15, shouldCloseOnSelect: format === "date" })] })), _jsxs("li", Object.assign({ style: { padding: 8 } }, { children: [_jsx("label", Object.assign({ style: { width: 120, paddingLeft: 4 } }, { children: "End date-time" })), _jsx(DatePicker, { id: "filter-date", dateFormat: dateFormat, "data-prop-name": propName, locale: nl, selectsEnd: true, selected: dateRangeValue.to, onChange: (date) => {
89
+ }, placeholderText: dateFormat, isClearable: true, selectsStart: true, showTimeSelect: isDateTime, showTimeInput: isDateTime, timeIntervals: 15, shouldCloseOnSelect: !isDateTime })] })), _jsxs("li", Object.assign({ style: { padding: 8 } }, { children: [_jsx("label", Object.assign({ style: { width: 120, paddingLeft: 4 } }, { children: "End date-time" })), _jsx(DatePicker, { id: "filter-date", dateFormat: dateFormat, "data-prop-name": propName, locale: nl, selectsEnd: true, selected: dateRangeValue.to, onChange: (date) => {
87
90
  if (!date && !dateRangeValue.from) {
88
91
  onChange(undefined, true);
89
92
  return;
90
93
  }
91
- const to = date ? endOfDay(date) : undefined;
94
+ const to = date
95
+ ? isDateTime
96
+ ? date
97
+ : endOfDay(date)
98
+ : undefined;
92
99
  if (dateRangeValue.from && to && to < dateRangeValue.from) {
93
100
  return;
94
101
  }
95
102
  onChange(Object.assign(Object.assign({}, columnFilterValue), { to }), true);
96
- }, placeholderText: dateFormat, isClearable: true, startDate: dateRangeValue.from, endDate: dateRangeValue.to, showTimeSelect: format === "date-time", timeIntervals: 15, shouldCloseOnSelect: format === "date" })] }))] })));
103
+ }, placeholderText: dateFormat, isClearable: true, startDate: dateRangeValue.from, endDate: dateRangeValue.to, showTimeInput: isDateTime, showTimeSelect: isDateTime, timeIntervals: 15, shouldCloseOnSelect: !isDateTime })] }))] })));
97
104
  }
98
105
  // falls through
99
106
  default:
@@ -23,7 +23,11 @@ import ThMenu from "./ThMenu";
23
23
  import { saveAs } from "file-saver";
24
24
  import { unparse } from "papaparse";
25
25
  const startOfTheWorldDate = new Date("1000-01-01 00:00:00Z");
26
- const intFormatter = new Intl.NumberFormat("nl-NL");
26
+ const numberFormatter = new Intl.NumberFormat("nl-NL");
27
+ const currencyFormatter = new Intl.NumberFormat("nl-NL", {
28
+ style: "currency",
29
+ currency: "EUR",
30
+ });
27
31
  function getSortByValue(propSchema, propConfig) {
28
32
  var _a;
29
33
  if ((propConfig === null || propConfig === void 0 ? void 0 : propConfig.sortByValue) !== undefined) {
@@ -149,10 +153,16 @@ function SchemaTable({ Heading = VariableSizeList, checkedIndexes, config, custo
149
153
  case "boolean":
150
154
  prev[propName] = rawValue ? "✓" : "✕";
151
155
  return prev;
156
+ case "number":
152
157
  case "integer":
153
- prev[propName] = [undefined, null].includes(rawValue)
154
- ? ""
155
- : intFormatter.format(rawValue);
158
+ if (rawValue === undefined) {
159
+ prev[propName] = "";
160
+ return prev;
161
+ }
162
+ prev[propName] =
163
+ schema.format === "currency"
164
+ ? currencyFormatter.format(rawValue)
165
+ : numberFormatter.format(rawValue);
156
166
  return prev;
157
167
  // @ts-ignore
158
168
  case "string":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mig-schema-table",
3
- "version": "3.0.75",
3
+ "version": "3.0.77",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/"
@@ -22,7 +22,7 @@
22
22
  "openapi3-ts": "^4.1.2",
23
23
  "papaparse": "^5.4.1",
24
24
  "react": "^18.2.0",
25
- "react-datepicker": "^4.14.0",
25
+ "react-datepicker": "^6.2.0",
26
26
  "react-dom": "^18.2.0",
27
27
  "react-popper": "^2.3.0",
28
28
  "react-scripts": "5.0.1",