@longline/aqua-ui 1.0.322 → 1.0.324

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.
@@ -16,6 +16,8 @@ import { getCountries } from '../../formatters/CountryFormatter/CountryLocales';
16
16
  import { CountryFormatter } from '../../formatters/CountryFormatter';
17
17
  // Get country keys ("NL", "PT", "ZW"..) only once. They never change.
18
18
  var countryKeys = Object.keys(Countries);
19
+ // Strip diacritics for search matching (e.g. "pai" matches "Países").
20
+ var stripDiacritics = function (s) { return s.normalize('NFD').replace(/[\u0300-\u036F]/g, ''); };
19
21
  /**
20
22
  * A dropdown preconfigured for country selection. Shows country flags.
21
23
  * By default, this will show all countries. A pre-filtered list of country
@@ -29,7 +31,7 @@ var CountryDropdown = function (props) {
29
31
  }, [localizedNames]);
30
32
  var data = sortedKeys
31
33
  .filter(function (c) { return !props.countries || props.countries.includes(c.toUpperCase()); })
32
- .filter(function (c) { return localizedNames[c].toLocaleLowerCase().includes((q || "").toLocaleLowerCase()); });
34
+ .filter(function (c) { return stripDiacritics(localizedNames[c]).toLocaleLowerCase().includes(stripDiacritics(q || "").toLocaleLowerCase()); });
33
35
  return (React.createElement(Dropdown, __assign({ data: data, onSearch: setQ, placeholder: props.placeholder || "Country", label: function (item) { return React.createElement(CountryFormatter, { type: 'both', value: item, locale: props.locale }); } }, props),
34
36
  React.createElement(Dropdown.Column, null, function (item) { return React.createElement(CountryFormatter, { type: 'both', value: item, locale: props.locale }); })));
35
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longline/aqua-ui",
3
- "version": "1.0.322",
3
+ "version": "1.0.324",
4
4
  "description": "AquaUI",
5
5
  "author": "Alexander van Oostenrijk / Longline Environment",
6
6
  "license": "Commercial",
@@ -40,7 +40,7 @@ interface IXhrDialogProps {
40
40
  * A `Dialog.Xhr` is a preset dialog that takes an `error` object from an
41
41
  * Axios request. It then displays a human-readable version of this error.
42
42
  * An "OK" button is present that calls `onClose`, and, if `onRetry` is set,
43
- * a "Retry" button.
43
+ * a "RETRY" button.
44
44
  */
45
45
  declare const XhrDialog: {
46
46
  ({ open, title, ...props }: IXhrDialogProps): React.JSX.Element;
@@ -18,10 +18,11 @@ import { HttpStatusFormatter } from '../../formatters/HttpStatusFormatter/HttpSt
18
18
  * A `Dialog.Xhr` is a preset dialog that takes an `error` object from an
19
19
  * Axios request. It then displays a human-readable version of this error.
20
20
  * An "OK" button is present that calls `onClose`, and, if `onRetry` is set,
21
- * a "Retry" button.
21
+ * a "RETRY" button.
22
22
  */
23
23
  var XhrDialog = function (_a) {
24
- var _b = _a.open, open = _b === void 0 ? false : _b, _c = _a.title, title = _c === void 0 ? "Network error" : _c, props = __rest(_a, ["open", "title"]);
24
+ var _b, _c, _d, _e, _f, _g, _h;
25
+ var _j = _a.open, open = _j === void 0 ? false : _j, _k = _a.title, title = _k === void 0 ? "Server error" : _k, props = __rest(_a, ["open", "title"]);
25
26
  var getStatusHeader = function () {
26
27
  if (props.error.response) {
27
28
  var status_1 = React.createElement(HttpStatusFormatter, { type: "title", status: props.error.response.status });
@@ -49,14 +50,24 @@ var XhrDialog = function (_a) {
49
50
  return (React.createElement(Dialog, { inverted: props.inverted, open: open, width: props.width, onClose: props.onClose },
50
51
  React.createElement(Dialog.Header, null, title),
51
52
  React.createElement(Dialog.Content, null,
52
- props.error && React.createElement("p", { style: { fontWeight: 700 } }, getStatusHeader()),
53
+ props.error && React.createElement("p", { style: { fontWeight: 700 } },
54
+ getStatusHeader(),
55
+ ((_b = props.error.response) === null || _b === void 0 ? void 0 : _b.status) && " (".concat(props.error.response.status, ")")),
53
56
  props.error && React.createElement("p", null, getStatusText()),
54
- props.error && props.error.response && props.error.response.status === 422 && props.error.response.data &&
57
+ (((_e = (_d = (_c = props.error) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.message) || ((_h = (_g = (_f = props.error) === null || _f === void 0 ? void 0 : _f.response) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.errors)) &&
55
58
  React.createElement(React.Fragment, null,
56
- React.createElement("div", null, "Details"),
57
- React.createElement("div", null, props.error.response.data.message))),
59
+ React.createElement("p", null,
60
+ React.createElement("strong", null, "Details")),
61
+ props.error.response.data.errors
62
+ ? Object.entries(props.error.response.data.errors).map(function (_a) {
63
+ var field = _a[0], messages = _a[1];
64
+ return React.createElement("ul", { key: field, style: { margin: '0 0', paddingLeft: '20px' } }, messages.map(function (msg, i) {
65
+ return React.createElement("li", { key: i }, msg);
66
+ }));
67
+ })
68
+ : React.createElement("div", null, props.error.response.data.message))),
58
69
  React.createElement(Dialog.Footer, null,
59
- props.onRetry && React.createElement(PrimaryButton, { onClick: props.onRetry }, "Retry"),
70
+ props.onRetry && React.createElement(PrimaryButton, { onClick: props.onRetry }, "RETRY"),
60
71
  React.createElement(PrimaryButton, { onClick: props.onClose }, "OK"))));
61
72
  };
62
73
  XhrDialog.displayName = "Dialog.Xhr";