@simplybusiness/mobius 6.3.2 → 6.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8f5b73a: pass in filters record to LoqateAddressLookupService to support US state filtering
8
+
9
+ ## 6.3.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 73eef9e: Fix: Update address field mapping for US street
14
+ - 5229bb9: Expandable test component dangerously sets inner html
15
+
3
16
  ## 6.3.2
4
17
 
5
18
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -1888,14 +1888,21 @@ var LoqateAddressLookupService = class {
1888
1888
  * 2 or 3 character ISO country codes
1889
1889
  */
1890
1890
  #countries;
1891
+ /**
1892
+ * Optional filters for the Loqate API
1893
+ * E.g., { AdministrativeArea: "CA", PostalCode: "90210" }
1894
+ */
1895
+ #filters;
1891
1896
  constructor({
1892
1897
  baseUrl,
1893
1898
  apiKey,
1894
- countries
1899
+ countries,
1900
+ filters
1895
1901
  }) {
1896
1902
  this.#apiKey = apiKey;
1897
1903
  this.#baseUrl = baseUrl || LOQATE_BASE_URL;
1898
1904
  this.#countries = countries || DEFAULT_COUNTRIES;
1905
+ this.#filters = filters;
1899
1906
  }
1900
1907
  fetchFromApi(url) {
1901
1908
  return fetch(`${this.#baseUrl}${url}`).then((response) => response.json()).then((json) => {
@@ -1905,12 +1912,28 @@ var LoqateAddressLookupService = class {
1905
1912
  return json;
1906
1913
  });
1907
1914
  }
1915
+ /**
1916
+ * Builds the Filters query parameter for Loqate API requests.
1917
+ * - Filter keys (e.g., "AdministrativeArea", "PostalCode") are predefined by Loqate API (no need to encode)
1918
+ * - Filter values (e.g., "New York", "90210") contain user input that may have special characters (need encoding)
1919
+ *
1920
+ * @returns Empty string if no filters, otherwise "&Filters=key1:value1&key2:value2" (Loqate's expected format for Filters)
1921
+ */
1922
+ buildFiltersQuery() {
1923
+ if (!this.#filters || Object.keys(this.#filters).length === 0) {
1924
+ return "";
1925
+ }
1926
+ const encodedFilters = Object.entries(this.#filters).map(([key, value]) => `${key}:${encodeURIComponent(value)}`).join("&");
1927
+ return `&Filters=${encodedFilters}`;
1928
+ }
1908
1929
  search(searchTerm) {
1909
- const url = `${LOQATE_FIND_URL}?Key=${this.#apiKey}&Text=${searchTerm}&Countries=${this.#countries?.join(",")}`;
1930
+ let url = `${LOQATE_FIND_URL}?Key=${this.#apiKey}&Text=${searchTerm}&Countries=${this.#countries?.join(",")}`;
1931
+ url += this.buildFiltersQuery();
1910
1932
  return this.fetchFromApi(url);
1911
1933
  }
1912
1934
  findById(id) {
1913
- const url = `${LOQATE_FIND_URL}?Key=${this.#apiKey}&Container=${id}&Countries=${this.#countries?.join(",")}`;
1935
+ let url = `${LOQATE_FIND_URL}?Key=${this.#apiKey}&Container=${id}&Countries=${this.#countries?.join(",")}`;
1936
+ url += this.buildFiltersQuery();
1914
1937
  return this.fetchFromApi(url);
1915
1938
  }
1916
1939
  async get(id) {
@@ -4496,7 +4519,7 @@ var ExpandableText = (0, import_react82.forwardRef)((props, ref) => {
4496
4519
  setIsCollapsed(isOverflowing);
4497
4520
  }, [text, shouldCollapse, maxLines]);
4498
4521
  if (breakpoint && !shouldCollapse) {
4499
- return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { ref, className, ...otherProps, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Text, { ...textProps, children: text }) });
4522
+ return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { ref, className, ...otherProps, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Text, { ...textProps, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { dangerouslySetInnerHTML: { __html: text } }) }) });
4500
4523
  }
4501
4524
  const handleAccordionChange = (expanded) => {
4502
4525
  setIsExpanded(expanded);
@@ -4525,7 +4548,7 @@ var ExpandableText = (0, import_react82.forwardRef)((props, ref) => {
4525
4548
  style: textContainerStyle,
4526
4549
  "data-testid": "expandable-text-content",
4527
4550
  "aria-describedby": isCollapsed ? expandButtonId : void 0,
4528
- children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Text, { elementType: "span", ...textProps, children: text })
4551
+ children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Text, { elementType: "span", ...textProps, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { dangerouslySetInnerHTML: { __html: text } }) })
4529
4552
  }
4530
4553
  ),
4531
4554
  isCollapsed && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
@@ -4584,10 +4607,17 @@ var MaskedField = (0, import_react83.forwardRef)((props, ref) => {
4584
4607
  const {
4585
4608
  ref: maskRef,
4586
4609
  value: maskedValue,
4587
- unmaskedValue
4610
+ unmaskedValue,
4611
+ setValue
4588
4612
  } = (0, import_react_imask.useIMask)(mask, {
4589
- defaultValue
4613
+ defaultValue: value || defaultValue
4590
4614
  });
4615
+ (0, import_react83.useEffect)(() => {
4616
+ const valueToCompare = useMaskedValue ? maskedValue : unmaskedValue;
4617
+ if (value !== void 0 && value !== valueToCompare) {
4618
+ setValue(value);
4619
+ }
4620
+ }, [value, setValue]);
4591
4621
  const handleChange = (event) => {
4592
4622
  if (onChange) {
4593
4623
  onChange(