@longline/aqua-ui 1.0.257 → 1.0.258

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.
@@ -1,7 +1,15 @@
1
1
  import * as React from 'react';
2
2
  import { IDropdownProps } from '../../inputs/Dropdown';
3
+ interface IProps {
4
+ /**
5
+ * If set, list is restricted to these countries.
6
+ */
7
+ countries?: string[];
8
+ }
3
9
  /**
4
10
  * A dropdown preconfigured for country selection. Shows country flags.
11
+ * By default, this will show all countries. A pre-filtered list of country
12
+ * codes may be passed in to limit the country selection.
5
13
  */
6
- declare const CountryDropdown: (props: IDropdownProps) => React.JSX.Element;
14
+ declare const CountryDropdown: (props: IProps & IDropdownProps) => React.JSX.Element;
7
15
  export { CountryDropdown };
@@ -13,12 +13,21 @@ import * as React from 'react';
13
13
  import { Dropdown } from '../../inputs/Dropdown';
14
14
  import { Countries } from '../../formatters/CountryFormatter/Countries';
15
15
  import { CountryFormatter } from '../../formatters/CountryFormatter';
16
+ /**
17
+ * Pre-sort country keys by country name. This is done only once, outside
18
+ * the component, since the countries never change.
19
+ */
20
+ var sortedCountryKeys = Object.keys(Countries)
21
+ .sort(function (a, b) { return Countries[a][0].localeCompare(Countries[b][0]); });
16
22
  /**
17
23
  * A dropdown preconfigured for country selection. Shows country flags.
24
+ * By default, this will show all countries. A pre-filtered list of country
25
+ * codes may be passed in to limit the country selection.
18
26
  */
19
27
  var CountryDropdown = function (props) {
20
28
  var _a = React.useState(null), q = _a[0], setQ = _a[1];
21
- var data = Object.keys(Countries)
29
+ var data = sortedCountryKeys
30
+ .filter(function (c) { return !props.countries || props.countries.includes(c.toUpperCase()); })
22
31
  .filter(function (c) { return Countries[c][0].toLocaleLowerCase().includes((q || "").toLocaleLowerCase()); });
23
32
  return (React.createElement(Dropdown, __assign({ data: data, onSearch: setQ, placeholder: props.placeholder || "Country", label: function (item) { return React.createElement(CountryFormatter, { type: 'both', value: item }); } }, props),
24
33
  React.createElement(Dropdown.Column, null, function (item) { return React.createElement(CountryFormatter, { type: 'both', value: item }); })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longline/aqua-ui",
3
- "version": "1.0.257",
3
+ "version": "1.0.258",
4
4
  "description": "AquaUI",
5
5
  "author": "Alexander van Oostenrijk / Longline Environment",
6
6
  "license": "Commercial",