@carto/meridian-ds 2.1.1-alpha-copiable-input-text.4 → 2.1.1-alpha-copiable-input-text.5

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.
@@ -2026,10 +2026,12 @@ const _CopiableComponent = ({
2026
2026
  ] });
2027
2027
  };
2028
2028
  const CopiableComponent = React.forwardRef(_CopiableComponent);
2029
- const StyledTextField = material.styled(material.TextField)(() => ({
2029
+ const StyledTextField = material.styled(material.TextField, {
2030
+ shouldForwardProp: (prop) => !["isInputFocused"].includes(prop)
2031
+ })(({ isInputFocused }) => ({
2030
2032
  "& input": {
2031
- textOverflow: "unset"
2032
- // This is needed to avoid scrolling issues in the input
2033
+ pointerEvents: isInputFocused ? "auto" : "none"
2034
+ // Disable pointer events when not focused https://issues.chromium.org/issues/41245282
2033
2035
  }
2034
2036
  }));
2035
2037
  const AdornmentWrapper = material.styled(material.Box, {
@@ -2058,15 +2060,26 @@ function _CopiableInputText({
2058
2060
  onCopied,
2059
2061
  password,
2060
2062
  size = "small",
2063
+ onFocus,
2064
+ onBlur,
2061
2065
  ...rest
2062
2066
  }, ref) {
2063
2067
  const intl = reactIntl.useIntl();
2064
2068
  const intlConfig = TablePaginationActions.useImperativeIntl(intl);
2065
2069
  const [showText, setShowText] = React.useState(false);
2070
+ const [isInputFocused, setIsInputFocused] = React.useState(false);
2066
2071
  const inputType = !password ? "text" : showText ? "text" : "password";
2067
2072
  const showTextLabel = intlConfig.formatMessage({
2068
2073
  id: showText ? "c4r.button.hide" : "c4r.button.show"
2069
2074
  });
2075
+ const handleFocus = (event) => {
2076
+ setIsInputFocused(true);
2077
+ onFocus == null ? void 0 : onFocus(event);
2078
+ };
2079
+ const handleBlur = (event) => {
2080
+ setIsInputFocused(false);
2081
+ onBlur == null ? void 0 : onBlur(event);
2082
+ };
2070
2083
  const passwordAdornment = /* @__PURE__ */ jsxRuntime.jsx(material.InputAdornment, { position: "end", children: /* @__PURE__ */ jsxRuntime.jsx(
2071
2084
  Link.IconButton,
2072
2085
  {
@@ -2082,11 +2095,14 @@ function _CopiableInputText({
2082
2095
  StyledTextField,
2083
2096
  {
2084
2097
  ...rest,
2098
+ isInputFocused,
2085
2099
  size,
2086
2100
  value,
2087
2101
  variant,
2088
2102
  InputProps: {
2089
2103
  readOnly: true,
2104
+ onFocus: handleFocus,
2105
+ onBlur: handleBlur,
2090
2106
  endAdornment: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2091
2107
  password ? passwordAdornment : extraEndAdornment,
2092
2108
  /* @__PURE__ */ jsxRuntime.jsx(material.InputAdornment, { position: "end", children: /* @__PURE__ */ jsxRuntime.jsx(AdornmentWrapper, { size, variant, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2026,10 +2026,12 @@ const _CopiableComponent = ({
2026
2026
  ] });
2027
2027
  };
2028
2028
  const CopiableComponent = forwardRef(_CopiableComponent);
2029
- const StyledTextField = styled(TextField)(() => ({
2029
+ const StyledTextField = styled(TextField, {
2030
+ shouldForwardProp: (prop) => !["isInputFocused"].includes(prop)
2031
+ })(({ isInputFocused }) => ({
2030
2032
  "& input": {
2031
- textOverflow: "unset"
2032
- // This is needed to avoid scrolling issues in the input
2033
+ pointerEvents: isInputFocused ? "auto" : "none"
2034
+ // Disable pointer events when not focused https://issues.chromium.org/issues/41245282
2033
2035
  }
2034
2036
  }));
2035
2037
  const AdornmentWrapper = styled(Box, {
@@ -2058,15 +2060,26 @@ function _CopiableInputText({
2058
2060
  onCopied,
2059
2061
  password,
2060
2062
  size = "small",
2063
+ onFocus,
2064
+ onBlur,
2061
2065
  ...rest
2062
2066
  }, ref) {
2063
2067
  const intl = useIntl();
2064
2068
  const intlConfig = useImperativeIntl(intl);
2065
2069
  const [showText, setShowText] = useState(false);
2070
+ const [isInputFocused, setIsInputFocused] = useState(false);
2066
2071
  const inputType = !password ? "text" : showText ? "text" : "password";
2067
2072
  const showTextLabel = intlConfig.formatMessage({
2068
2073
  id: showText ? "c4r.button.hide" : "c4r.button.show"
2069
2074
  });
2075
+ const handleFocus = (event) => {
2076
+ setIsInputFocused(true);
2077
+ onFocus == null ? void 0 : onFocus(event);
2078
+ };
2079
+ const handleBlur = (event) => {
2080
+ setIsInputFocused(false);
2081
+ onBlur == null ? void 0 : onBlur(event);
2082
+ };
2070
2083
  const passwordAdornment = /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(
2071
2084
  IconButton$1,
2072
2085
  {
@@ -2082,11 +2095,14 @@ function _CopiableInputText({
2082
2095
  StyledTextField,
2083
2096
  {
2084
2097
  ...rest,
2098
+ isInputFocused,
2085
2099
  size,
2086
2100
  value,
2087
2101
  variant,
2088
2102
  InputProps: {
2089
2103
  readOnly: true,
2104
+ onFocus: handleFocus,
2105
+ onBlur: handleBlur,
2090
2106
  endAdornment: /* @__PURE__ */ jsxs(Fragment, { children: [
2091
2107
  password ? passwordAdornment : extraEndAdornment,
2092
2108
  /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(AdornmentWrapper, { size, variant, children: /* @__PURE__ */ jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"CopiableInputText.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Copy/CopiableInputText.tsx"],"names":[],"mappings":"AA+HA,QAAA,MAAM,iBAAiB;;8BAtGS,SAAS;;;;;8BAAT,SAAS;;;;;8BAAT,SAAS;;;2DAsGe,CAAA;AACxD,eAAe,iBAAiB,CAAA"}
1
+ {"version":3,"file":"CopiableInputText.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Copy/CopiableInputText.tsx"],"names":[],"mappings":"AAoJA,QAAA,MAAM,iBAAiB;;8BA9Hc,SAAS;;;;;8BAAT,SAAS;;;;;8BAAT,SAAS;;;2DA8HU,CAAA;AACxD,eAAe,iBAAiB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carto/meridian-ds",
3
- "version": "2.1.1-alpha-copiable-input-text.4",
3
+ "version": "2.1.1-alpha-copiable-input-text.5",
4
4
  "description": "CARTO Meridian Design System",
5
5
  "type": "module",
6
6
  "scripts": {