allaw-ui 4.4.7 → 4.4.9

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.
@@ -30,12 +30,13 @@ var CountrySelect = function (_a) {
30
30
  setSearch("");
31
31
  }, [isOpen]);
32
32
  useEffect(function () {
33
+ if (disablePortal)
34
+ return;
33
35
  if (isOpen && buttonRef.current) {
34
36
  var rect = buttonRef.current.getBoundingClientRect();
35
37
  var btnW = typeof buttonWidth === "number" ? buttonWidth : rect.width;
36
38
  var lstW = typeof listWidth === "number" ? listWidth : rect.width;
37
39
  var left = rect.left + window.scrollX + (btnW - lstW) / 2;
38
- // Décalage intelligent si la liste sort de l'écran
39
40
  var minMargin = 8;
40
41
  if (left < minMargin)
41
42
  left = minMargin;
@@ -47,7 +48,7 @@ var CountrySelect = function (_a) {
47
48
  width: lstW,
48
49
  });
49
50
  }
50
- }, [isOpen, listWidth, buttonWidth]);
51
+ }, [isOpen, listWidth, buttonWidth, disablePortal]);
51
52
  useEffect(function () {
52
53
  if (!isOpen)
53
54
  return;
@@ -99,14 +100,19 @@ var CountrySelect = function (_a) {
99
100
  }
100
101
  };
101
102
  var selectedItem = items.find(function (i) { return i.value === selected; });
102
- // Liste en portal, position fixed, centrée sous le bouton, décalée si besoin
103
- var dropdown = (React.createElement("div", { className: selectStyles.selectList + " " + styles.listOpen, style: {
104
- position: disablePortal ? "absolute" : "fixed",
105
- top: listPos.top,
106
- left: listPos.left,
107
- width: listPos.width,
108
- zIndex: 9999,
109
- }, role: "listbox", tabIndex: -1, onKeyDown: handleKeyDown },
103
+ var dropdown = (React.createElement("div", { className: selectStyles.selectList + " " + styles.listOpen, style: disablePortal
104
+ ? {
105
+ position: "absolute",
106
+ width: listPos.width,
107
+ zIndex: 9999,
108
+ }
109
+ : {
110
+ position: "fixed",
111
+ top: listPos.top,
112
+ left: listPos.left,
113
+ width: listPos.width,
114
+ zIndex: 9999,
115
+ }, onKeyDown: handleKeyDown },
110
116
  React.createElement("div", { className: styles.searchWrapper },
111
117
  React.createElement("i", { className: "allaw-icon-search" }),
112
118
  React.createElement("input", __assign({ className: styles.search, placeholder: "Rechercher...", value: search, onChange: function (e) { return setSearch(e.target.value); }, autoFocus: true, "aria-label": "Rechercher un pays", onBlur: handleBlur }, (disableAutofill && {
@@ -20,6 +20,7 @@ export interface PhoneNumberFieldProps {
20
20
  onChange?: (country: string, number: string, isValid: boolean) => void;
21
21
  onError?: (msg: string) => void;
22
22
  title?: string;
23
+ disablePortal?: boolean;
23
24
  }
24
25
  declare const PhoneNumberField: React.FC<PhoneNumberFieldProps>;
25
26
  export default PhoneNumberField;
@@ -1,11 +1,11 @@
1
1
  import React, { useState } from "react";
2
- import styles from "./PhoneNumberField.module.css";
3
- import CountrySelect from "./CountrySelect";
4
- import PhoneInput from "./PhoneInput";
5
2
  import Paragraph from "../../atoms/typography/Paragraph";
6
3
  import TinyInfo from "../../atoms/typography/TinyInfo";
4
+ import CountrySelect from "./CountrySelect";
5
+ import PhoneInput from "./PhoneInput";
6
+ import styles from "./PhoneNumberField.module.css";
7
7
  var PhoneNumberField = function (_a) {
8
- var countryItems = _a.countryItems, defaultCountry = _a.defaultCountry, defaultNumber = _a.defaultNumber, numberPlaceholder = _a.numberPlaceholder, validationPattern = _a.validationPattern, isRequired = _a.isRequired, disabled = _a.disabled, selectButtonWidth = _a.selectButtonWidth, selectListWidth = _a.selectListWidth, onChange = _a.onChange, onError = _a.onError, title = _a.title;
8
+ var countryItems = _a.countryItems, defaultCountry = _a.defaultCountry, defaultNumber = _a.defaultNumber, numberPlaceholder = _a.numberPlaceholder, validationPattern = _a.validationPattern, isRequired = _a.isRequired, disabled = _a.disabled, selectButtonWidth = _a.selectButtonWidth, selectListWidth = _a.selectListWidth, onChange = _a.onChange, onError = _a.onError, title = _a.title, disablePortal = _a.disablePortal;
9
9
  var _b = useState(defaultCountry || ""), country = _b[0], setCountry = _b[1];
10
10
  var _c = useState(defaultNumber || ""), number = _c[0], setNumber = _c[1];
11
11
  var _d = useState(""), error = _d[0], setError = _d[1];
@@ -54,7 +54,7 @@ var PhoneNumberField = function (_a) {
54
54
  isRequired && React.createElement("span", { className: styles.required }, "*")) })),
55
55
  React.createElement("div", { className: styles.phoneNumberField },
56
56
  React.createElement("div", { className: styles.selectWrapper },
57
- React.createElement(CountrySelect, { items: countryItems, defaultCountry: defaultCountry, buttonWidth: selectButtonWidth, listWidth: selectListWidth, isRequired: isRequired, disabled: disabled, onSelect: handleCountry, onError: setErrorMsg })),
57
+ React.createElement(CountrySelect, { items: countryItems, defaultCountry: defaultCountry, buttonWidth: selectButtonWidth, listWidth: selectListWidth, isRequired: isRequired, disabled: disabled, onSelect: handleCountry, onError: setErrorMsg, disablePortal: disablePortal })),
58
58
  React.createElement("div", { className: styles.inputWrapper },
59
59
  React.createElement(PhoneInput, { defaultValue: defaultNumber, placeholder: numberPlaceholder, validationPattern: effectivePattern, isRequired: isRequired, disabled: disabled, onChange: handleNumber, onError: setErrorMsg, onBlur: handleInputBlur, isValid: isValid }))),
60
60
  isTouched && error && (React.createElement("div", { className: styles.errorMessage },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allaw-ui",
3
- "version": "4.4.7",
3
+ "version": "4.4.9",
4
4
  "description": "Composants UI pour l'application Allaw",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",