@griddo/ax 11.11.5 → 11.11.7-rc.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.
Files changed (36) hide show
  1. package/README.md +0 -5
  2. package/package.json +2 -2
  3. package/src/__tests__/components/Browser/Browser.test.tsx +1 -87
  4. package/src/__tests__/helpers/shareToken.test.ts +91 -0
  5. package/src/api/index.tsx +4 -0
  6. package/src/api/pages.tsx +21 -18
  7. package/src/api/shareToken.tsx +62 -0
  8. package/src/api/utils.tsx +13 -0
  9. package/src/components/Browser/index.tsx +77 -31
  10. package/src/components/Browser/style.tsx +15 -8
  11. package/src/components/BrowserContent/index.tsx +20 -5
  12. package/src/components/ErrorPage/index.tsx +28 -14
  13. package/src/components/Fields/TextField/index.tsx +18 -4
  14. package/src/components/Icon/components/GriddoLogo.js +16 -0
  15. package/src/components/Icon/index.tsx +1 -0
  16. package/src/components/Icon/svgs/GriddoLogo.svg +9 -0
  17. package/src/components/Modal/index.tsx +3 -1
  18. package/src/components/Modal/style.tsx +19 -10
  19. package/src/components/PageInfoBanner/index.tsx +38 -0
  20. package/src/components/PageInfoBanner/styles.tsx +40 -0
  21. package/src/components/SearchField/index.tsx +10 -6
  22. package/src/components/SearchField/style.tsx +48 -27
  23. package/src/components/SharePageModal/index.tsx +187 -0
  24. package/src/components/SharePageModal/style.tsx +41 -0
  25. package/src/components/StatusTile/index.tsx +28 -0
  26. package/src/components/StatusTile/styles.ts +63 -0
  27. package/src/components/index.tsx +103 -102
  28. package/src/global.d.ts +8 -0
  29. package/src/helpers/dates.tsx +14 -8
  30. package/src/helpers/index.tsx +5 -0
  31. package/src/helpers/shareToken.ts +25 -0
  32. package/src/locales/en-US.ts +1 -0
  33. package/src/locales/es-ES.ts +1 -0
  34. package/src/modules/PublicPreview/index.tsx +35 -13
  35. package/src/routes/publicRoutes.tsx +2 -2
  36. package/src/themes/theme.json +4 -0
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import { RouteComponentProps, useHistory, withRouter } from "react-router-dom";
1
+ import { type RouteComponentProps, useHistory, withRouter } from "react-router-dom";
2
+
3
3
  import { Button, Circle, Icon } from "@ax/components";
4
4
 
5
5
  import * as S from "./style";
@@ -61,6 +61,16 @@ const ErrorPage = (props: IProps): JSX.Element => {
61
61
  buttonText: "Go to sites",
62
62
  buttonAction: () => history.push("/sites"),
63
63
  },
64
+ linkExpired: {
65
+ icon: "lock",
66
+ title: "This preview link has Expired",
67
+ description: (
68
+ <>
69
+ For security, Griddo drafts have a 15-day validity period to protect unspublished content. The access
70
+ associated with this URL is no longer active. <strong>Please request a new link.</strong>
71
+ </>
72
+ ),
73
+ },
64
74
  };
65
75
 
66
76
  return (
@@ -75,11 +85,13 @@ const ErrorPage = (props: IProps): JSX.Element => {
75
85
  <S.ErrorNumber>{type}</S.ErrorNumber>
76
86
  <S.ErrorTitle>{errorTexts[type].title}</S.ErrorTitle>
77
87
  <S.ErrorDescription>{errorTexts[type].description}</S.ErrorDescription>
78
- <S.ErrorAction>
79
- <Button className="button" type="button" onClick={errorTexts[type].buttonAction}>
80
- {errorTexts[type].buttonText}
81
- </Button>
82
- </S.ErrorAction>
88
+ {errorTexts[type].buttonText && (
89
+ <S.ErrorAction>
90
+ <Button className="button" type="button" onClick={errorTexts[type].buttonAction}>
91
+ {errorTexts[type].buttonText!}
92
+ </Button>
93
+ </S.ErrorAction>
94
+ )}
83
95
  </S.ContentNumber>
84
96
  )}
85
97
  {errorTexts[type].icon && (
@@ -89,11 +101,13 @@ const ErrorPage = (props: IProps): JSX.Element => {
89
101
  </S.IconWrapper>
90
102
  <S.ErrorTitleWrong>{errorTexts[type].title}</S.ErrorTitleWrong>
91
103
  <S.ErrorDescriptionWrong>{errorTexts[type].description}</S.ErrorDescriptionWrong>
92
- <S.ErrorAction>
93
- <Button className="button" type="button" onClick={errorTexts[type].buttonAction}>
94
- {errorTexts[type].buttonText}
95
- </Button>
96
- </S.ErrorAction>
104
+ {errorTexts[type].buttonText && (
105
+ <S.ErrorAction>
106
+ <Button className="button" type="button" onClick={errorTexts[type].buttonAction}>
107
+ {errorTexts[type].buttonText!}
108
+ </Button>
109
+ </S.ErrorAction>
110
+ )}
97
111
  </S.ContentWrong>
98
112
  )}
99
113
  </S.Content>
@@ -110,8 +124,8 @@ interface IErrorText {
110
124
  title: string;
111
125
  icon?: string;
112
126
  description: JSX.Element;
113
- buttonText: string;
114
- buttonAction: () => void;
127
+ buttonText?: string;
128
+ buttonAction?: () => void;
115
129
  }
116
130
 
117
131
  type IProps = IErrorPateProps & RouteComponentProps;
@@ -1,4 +1,6 @@
1
- import React, { useRef, useEffect, useState } from "react";
1
+ import type React from "react";
2
+ import { useEffect, useRef, useState } from "react";
3
+
2
4
  import { Icon, IconAction } from "@ax/components";
3
5
 
4
6
  import * as S from "./style";
@@ -26,6 +28,8 @@ const TextField = (props: ITextFieldProps): JSX.Element => {
26
28
  editorID,
27
29
  focus,
28
30
  inversed = false,
31
+ noeditable = false,
32
+ selectOnFocus = false,
29
33
  } = props;
30
34
 
31
35
  const [width, setWidth] = useState(0);
@@ -55,18 +59,25 @@ const TextField = (props: ITextFieldProps): JSX.Element => {
55
59
  }, [editorID, value]);
56
60
 
57
61
  const handleOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
62
+ if (noeditable) return;
58
63
  !autoComplete ? setState(e.target.value) : delayedChange(e.target.value);
59
64
  };
60
65
 
61
66
  const delayedChange = (newValue: string) => {
62
- onChange && onChange(newValue);
67
+ onChange?.(newValue);
63
68
  error && handleValidation && handleValidation(newValue, validators);
64
69
  };
65
70
 
71
+ const handleOnFocus = (e: React.FocusEvent<HTMLInputElement>) => {
72
+ if (!selectOnFocus) return;
73
+ const target = e.target;
74
+ requestAnimationFrame(() => target.select());
75
+ };
76
+
66
77
  const handleOnBlur = (e: React.FocusEvent<HTMLInputElement>) => {
67
78
  const newValue = e.target.value;
68
- onBlur && onBlur(newValue);
69
- handleValidation && handleValidation(newValue, validators);
79
+ onBlur?.(newValue);
80
+ handleValidation?.(newValue, validators);
70
81
  };
71
82
 
72
83
  const hasBackgroundIcon = !!icon && iconPosition === "in";
@@ -89,6 +100,7 @@ const TextField = (props: ITextFieldProps): JSX.Element => {
89
100
  value={inputValue}
90
101
  name={name}
91
102
  onChange={handleOnChange}
103
+ onFocus={handleOnFocus}
92
104
  onBlur={handleOnBlur}
93
105
  onKeyDown={onKeyDown}
94
106
  placeholder={placeholder}
@@ -140,6 +152,8 @@ interface ITextFieldProps {
140
152
  editorID?: number;
141
153
  focus?: boolean;
142
154
  inversed?: boolean;
155
+ noeditable?: boolean;
156
+ selectOnFocus?: boolean;
143
157
  }
144
158
 
145
159
  export default TextField;
@@ -0,0 +1,16 @@
1
+ function SvgCollapsed(props) {
2
+ return (
3
+ <svg width="111" height="45" viewBox="0 0 111 45" fill="none" xmlns="http://www.w3.org/2000/svg">
4
+ <title>Logo</title>
5
+ <path d="M21.4533 16.5551H19.7821C19.3303 16.5554 18.9641 16.9244 18.9638 17.3795V20.8694L18.9571 20.8654C18.9569 21.8381 18.8119 22.8233 18.5066 23.7872C17.25 27.7546 13.6059 30.442 9.48279 30.442L9.48012 30.4407C9.43512 30.4537 7.17042 30.4541 6.03371 30.4541C5.57736 30.4545 5.21176 30.8231 5.21142 31.2839C5.21177 31.7448 5.57737 32.1147 6.03371 32.1151H12.9319C16.2669 32.1151 18.9634 34.8368 18.9638 38.2046C18.9634 41.5723 16.2669 44.2954 12.9319 44.2954H6.87865V39.0358H12.9319C13.3885 39.0358 13.7538 38.6657 13.7542 38.2046C13.7538 37.7435 13.3885 37.3748 12.9319 37.3748H6.03371C3.53266 37.3745 1.29258 35.8172 0.401631 33.4646C-0.489026 31.1006 0.140005 28.4361 2.0009 26.7521C-0.226235 23.8687 -0.625805 19.9577 0.961374 16.6705C2.5604 13.3834 5.86218 11.3077 9.48279 11.3075C11.4587 11.296 13.3892 11.9185 14.9883 13.0719L14.9936 13.0746C15.0712 12.985 15.1515 12.8956 15.2401 12.806C16.1994 11.8376 17.5018 11.2956 18.8491 11.2954H21.4533V16.5551ZM9.48279 16.5551C7.11867 16.5554 5.21009 18.482 5.21009 20.8694C5.21064 23.2563 7.13042 25.182 9.48279 25.1824L9.47346 25.1945H9.48279C11.8469 25.1944 13.7538 23.2559 13.7542 20.8801V20.8694L13.7488 20.6465C13.6347 18.3629 11.7732 16.5552 9.48279 16.5551Z" />
6
+ <path d="M29.7295 11.517C30.3362 11.3555 30.955 11.2753 31.5846 11.2753C33.4629 11.2753 35.2612 12.0256 36.5783 13.3525L32.8907 17.0801C32.3638 16.5492 31.573 16.3874 30.8743 16.6759C30.1762 16.9647 29.7295 17.6463 29.7295 18.396V30.4554H24.5065V11.2753H29.7295V11.517Z" />
7
+ <path d="M66.4619 30.4434H61.239V29.4135L61.2283 29.4282C57.7121 31.2051 53.473 30.6281 50.5639 27.974C47.6553 25.3084 46.6587 21.1189 48.0784 17.4265C49.4986 13.7339 53.0273 11.2984 56.9556 11.2981C58.4444 11.2866 59.9113 11.6446 61.2283 12.3253L61.239 12.3374V0H66.4619V30.4434ZM56.9436 16.5604C54.5734 16.5611 52.6605 18.4879 52.6603 20.8761C52.6603 23.2645 54.5733 25.1924 56.9436 25.1931C59.3146 25.1931 61.2283 23.2534 61.2283 20.8761L61.239 20.8922V20.8627L61.2283 20.8761C61.2281 18.4874 59.303 16.5604 56.9436 16.5604Z" />
8
+ <path d="M88.4878 30.4434H83.2649V29.4135L83.2542 29.4282C79.738 31.205 75.4989 30.6281 72.5898 27.974C69.6811 25.3085 68.6847 21.1189 70.1042 17.4265C71.5244 13.7339 75.0531 11.2984 78.9815 11.2981C80.4704 11.2866 81.9371 11.6446 83.2542 12.3253L83.2649 12.3374V0H88.4878V30.4434ZM78.9695 16.5604C76.5993 16.5611 74.6863 18.4879 74.6861 20.8761C74.6863 23.2643 76.5993 25.1924 78.9695 25.1931C81.3403 25.1931 83.254 23.2532 83.2542 20.8761L83.2649 20.8922V20.8627L83.2542 20.8761C83.254 18.4874 81.3289 16.5604 78.9695 16.5604Z" />
9
+ <path d="M44.3787 30.4313H39.1438V11.3102H44.3787V30.4313Z" />
10
+ <path d="M101.019 11.286C106.265 11.2862 110.515 15.5679 110.515 20.8533C110.515 24.7308 108.2 28.2277 104.65 29.7048C101.099 31.1818 97.0103 30.3624 94.2958 27.6276C91.5813 24.8926 90.7682 20.7729 92.2341 17.1956C93.7116 13.6181 97.1709 11.286 101.019 11.286ZM102.657 16.8719C101.065 16.2026 99.221 16.5718 97.9954 17.8065C96.7699 19.0413 96.4035 20.8879 97.0678 22.5035C97.7208 24.1191 99.2899 25.1689 101.019 25.1689C103.379 25.1688 105.291 23.242 105.303 20.8533C105.303 19.1108 104.261 17.5413 102.657 16.8719Z" />
11
+ <path d="M44.4254 5.64368H39.1918V0.0805664H44.4254V5.64368Z" />
12
+ </svg>
13
+ );
14
+ }
15
+
16
+ export default SvgCollapsed;
@@ -2,6 +2,7 @@ const getImage = (name: string) => {
2
2
  try {
3
3
  return require(`./components/${name}`).default;
4
4
  } catch (err) {
5
+ console.log(name);
5
6
  return null;
6
7
  }
7
8
  };
@@ -0,0 +1,9 @@
1
+ <svg width="111" height="45" viewBox="0 0 111 45" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M21.4533 16.5551H19.7821C19.3303 16.5554 18.9641 16.9244 18.9638 17.3795V20.8694L18.9571 20.8654C18.9569 21.8381 18.8119 22.8233 18.5066 23.7872C17.25 27.7546 13.6059 30.442 9.48279 30.442L9.48012 30.4407C9.43512 30.4537 7.17042 30.4541 6.03371 30.4541C5.57736 30.4545 5.21176 30.8231 5.21142 31.2839C5.21177 31.7448 5.57737 32.1147 6.03371 32.1151H12.9319C16.2669 32.1151 18.9634 34.8368 18.9638 38.2046C18.9634 41.5723 16.2669 44.2954 12.9319 44.2954H6.87865V39.0358H12.9319C13.3885 39.0358 13.7538 38.6657 13.7542 38.2046C13.7538 37.7435 13.3885 37.3748 12.9319 37.3748H6.03371C3.53266 37.3745 1.29258 35.8172 0.401631 33.4646C-0.489026 31.1006 0.140005 28.4361 2.0009 26.7521C-0.226235 23.8687 -0.625805 19.9577 0.961374 16.6705C2.5604 13.3834 5.86218 11.3077 9.48279 11.3075C11.4587 11.296 13.3892 11.9185 14.9883 13.0719L14.9936 13.0746C15.0712 12.985 15.1515 12.8956 15.2401 12.806C16.1994 11.8376 17.5018 11.2956 18.8491 11.2954H21.4533V16.5551ZM9.48279 16.5551C7.11867 16.5554 5.21009 18.482 5.21009 20.8694C5.21064 23.2563 7.13042 25.182 9.48279 25.1824L9.47346 25.1945H9.48279C11.8469 25.1944 13.7538 23.2559 13.7542 20.8801V20.8694L13.7488 20.6465C13.6347 18.3629 11.7732 16.5552 9.48279 16.5551Z" fill="white"/>
3
+ <path d="M29.7295 11.517C30.3362 11.3555 30.955 11.2753 31.5846 11.2753C33.4629 11.2753 35.2612 12.0256 36.5783 13.3525L32.8907 17.0801C32.3638 16.5492 31.573 16.3874 30.8743 16.6759C30.1762 16.9647 29.7295 17.6463 29.7295 18.396V30.4554H24.5065V11.2753H29.7295V11.517Z" fill="white"/>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M66.4619 30.4434H61.239V29.4135L61.2283 29.4282C57.7121 31.2051 53.473 30.6281 50.5639 27.974C47.6553 25.3084 46.6587 21.1189 48.0784 17.4265C49.4986 13.7339 53.0273 11.2984 56.9556 11.2981C58.4444 11.2866 59.9113 11.6446 61.2283 12.3253L61.239 12.3374V0H66.4619V30.4434ZM56.9436 16.5604C54.5734 16.5611 52.6605 18.4879 52.6603 20.8761C52.6603 23.2645 54.5733 25.1924 56.9436 25.1931C59.3146 25.1931 61.2283 23.2534 61.2283 20.8761L61.239 20.8922V20.8627L61.2283 20.8761C61.2281 18.4874 59.303 16.5604 56.9436 16.5604Z" fill="white"/>
5
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M88.4878 30.4434H83.2649V29.4135L83.2542 29.4282C79.738 31.205 75.4989 30.6281 72.5898 27.974C69.6811 25.3085 68.6847 21.1189 70.1042 17.4265C71.5244 13.7339 75.0531 11.2984 78.9815 11.2981C80.4704 11.2866 81.9371 11.6446 83.2542 12.3253L83.2649 12.3374V0H88.4878V30.4434ZM78.9695 16.5604C76.5993 16.5611 74.6863 18.4879 74.6861 20.8761C74.6863 23.2643 76.5993 25.1924 78.9695 25.1931C81.3403 25.1931 83.254 23.2532 83.2542 20.8761L83.2649 20.8922V20.8627L83.2542 20.8761C83.254 18.4874 81.3289 16.5604 78.9695 16.5604Z" fill="white"/>
6
+ <path d="M44.3787 30.4313H39.1438V11.3102H44.3787V30.4313Z" fill="white"/>
7
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M101.019 11.286C106.265 11.2862 110.515 15.5679 110.515 20.8533C110.515 24.7308 108.2 28.2277 104.65 29.7048C101.099 31.1818 97.0103 30.3624 94.2958 27.6276C91.5813 24.8926 90.7682 20.7729 92.2341 17.1956C93.7116 13.6181 97.1709 11.286 101.019 11.286ZM102.657 16.8719C101.065 16.2026 99.221 16.5718 97.9954 17.8065C96.7699 19.0413 96.4035 20.8879 97.0678 22.5035C97.7208 24.1191 99.2899 25.1689 101.019 25.1689C103.379 25.1688 105.291 23.242 105.303 20.8533C105.303 19.1108 104.261 17.5413 102.657 16.8719Z" fill="white"/>
8
+ <path d="M44.4254 5.64368H39.1918V0.0805664H44.4254V5.64368Z" fill="white"/>
9
+ </svg>
@@ -1,6 +1,8 @@
1
1
  import { memo, useEffect, useRef } from "react";
2
2
  import { createPortal } from "react-dom";
3
+
3
4
  import { IconAction, SearchField } from "@ax/components";
5
+
4
6
  import Button from "../Button";
5
7
 
6
8
  import * as S from "./style";
@@ -124,7 +126,7 @@ export interface IModalProps {
124
126
  overflow?: string;
125
127
  mainAction?: IAction;
126
128
  secondaryAction?: IAction;
127
- height?: number;
129
+ height?: number | string;
128
130
  isChild?: boolean;
129
131
  searchAction?(query: string): void;
130
132
  searchValue?: string;
@@ -51,7 +51,12 @@ const ModalWrapper = styled.div<{ isChild?: boolean }>`
51
51
  outline: 0;
52
52
  `;
53
53
 
54
- const Modal = styled.div<{ size?: string; height?: number }>`
54
+ function getModalHeight(height?: number | string, size?: string) {
55
+ const heightProp = typeof height === "number" ? `${height}px` : height;
56
+ return height !== undefined ? heightProp : getHeight(size);
57
+ }
58
+
59
+ const Modal = styled.div<{ size?: string; height?: number | string }>`
55
60
  z-index: 100;
56
61
  display: flex;
57
62
  flex-flow: column nowrap;
@@ -60,7 +65,8 @@ const Modal = styled.div<{ size?: string; height?: number }>`
60
65
  margin: auto;
61
66
  border-radius: 4px;
62
67
  width: ${(p) => getWidth(p.size)};
63
- height: ${(p) => (p.height ? `${p.height}px` : getHeight(p.size))};
68
+ height: ${(p) => getModalHeight(p.height, p.size)};
69
+ max-height: 80vh;
64
70
  box-shadow: ${(p) => p.theme.shadow.shadowXL};
65
71
  top: 50%;
66
72
  transform: translateY(-50%);
@@ -111,8 +117,11 @@ const SearchWrapper = styled.div`
111
117
  margin-right: ${(p) => p.theme.spacing.xs};
112
118
 
113
119
  & > div {
114
- margin-top: -8px;
115
- margin-bottom: -8px;
120
+ margin-top: -9px;
121
+ margin-bottom: -9px;
122
+ display: flex
123
+ justify-content: center;
124
+ align-items: center;
116
125
  }
117
126
  `;
118
127
 
@@ -121,14 +130,14 @@ const IconWrapper = styled.div`
121
130
  `;
122
131
 
123
132
  export {
124
- ModalOverlay,
125
- ModalWrapper,
133
+ ButtonWrapper,
134
+ IconWrapper,
126
135
  Modal,
127
- ModalHeader,
128
136
  ModalContent,
129
- Title,
130
- ButtonWrapper,
131
137
  ModalFooter,
138
+ ModalHeader,
139
+ ModalOverlay,
140
+ ModalWrapper,
132
141
  SearchWrapper,
133
- IconWrapper,
142
+ Title,
134
143
  };
@@ -0,0 +1,38 @@
1
+ import { Icon } from "@ax/components";
2
+
3
+ import * as S from "./styles";
4
+
5
+ const PageInfoBanner = (props: PageInfoBannerProps) => {
6
+ const { message, actionLabel, onAction, onDismiss, icon = "view" } = props;
7
+
8
+ return (
9
+ <S.Container>
10
+ <S.Header>
11
+ <S.Info>
12
+ <Icon name={icon} size="16px" />
13
+ {message}{" "}
14
+ {onAction && (
15
+ <button type="button" onClick={onAction}>
16
+ <strong style={{ textDecoration: "underline" }}>{actionLabel}</strong>
17
+ </button>
18
+ )}
19
+ {onDismiss && (
20
+ <S.DismissButton type="button" onClick={onDismiss}>
21
+ <Icon name="close" size="16px" />
22
+ </S.DismissButton>
23
+ )}
24
+ </S.Info>
25
+ </S.Header>
26
+ </S.Container>
27
+ );
28
+ };
29
+
30
+ interface PageInfoBannerProps {
31
+ message: string;
32
+ actionLabel?: string;
33
+ onAction?: () => void;
34
+ onDismiss?: () => void;
35
+ icon?: string;
36
+ }
37
+
38
+ export default PageInfoBanner;
@@ -0,0 +1,40 @@
1
+ import styled from "styled-components";
2
+
3
+ const Container = styled.div`
4
+ left: 0px;
5
+ bottom: ${(p) => p.theme.spacing.s};
6
+ width: 100vw;
7
+ display: flex;
8
+ position: fixed;
9
+ z-index: 100;
10
+ justify-content: center;
11
+ align-items: center;
12
+ `;
13
+
14
+ const Header = styled.span`
15
+ ${({ theme }) => theme.textStyle.uiS}
16
+ border-radius: ${(p) => p.theme.radii.s};
17
+ background-color: ${(p) => p.theme.color.uiBackground04};
18
+ color: ${(p) => p.theme.color.textHighEmphasisInverse};
19
+ padding: ${(p) => p.theme.spacing.s};
20
+ svg {
21
+ path {
22
+ fill: ${(p) => p.theme.color.textHighEmphasisInverse};
23
+ }
24
+ }
25
+ `;
26
+
27
+ const Info = styled.div`
28
+ display: flex;
29
+ align-items: center;
30
+ column-gap: ${(p) => p.theme.spacing.xs};
31
+ `;
32
+
33
+ const DismissButton = styled.button`
34
+ background: none;
35
+ border: none;
36
+ color: inherit;
37
+ cursor: pointer;
38
+ `;
39
+
40
+ export { Container, DismissButton, Header, Info };
@@ -1,5 +1,8 @@
1
- import { Button, Icon } from "@ax/components";
2
1
  import { useEffect, useRef, useState } from "react";
2
+
3
+ import { Button, Icon } from "@ax/components";
4
+ import { LOCALE } from "@ax/locales";
5
+
3
6
  import { Select } from "../Fields";
4
7
 
5
8
  import * as S from "./style";
@@ -98,7 +101,7 @@ const SearchField = (props: ISearchFieldProps): JSX.Element => {
98
101
  value={inputValue}
99
102
  onChange={handleChange}
100
103
  onKeyDown={handleKeyDown}
101
- placeholder={placeholder}
104
+ placeholder={placeholder || LOCALE.common.typeSomething}
102
105
  closeOnInactive={closeOnInactive}
103
106
  disabled={disabled}
104
107
  data-testid="search-input"
@@ -107,12 +110,13 @@ const SearchField = (props: ISearchFieldProps): JSX.Element => {
107
110
  inputSize={size}
108
111
  name="searchInput"
109
112
  />
110
- {inputValue.trim() !== "" && searchOnEnter && <S.HelpText>Press ENTER</S.HelpText>}
113
+
114
+ {searchOnEnter && <S.HelpText hide={!inputValue.trim()}>Press ENTER</S.HelpText>}
111
115
  {closeOnInactive || inputValue.length > 0 ? (
112
116
  <S.CloseWrapper data-testid="icon-close-wrapper">
113
- <Button type="button" onClick={handleClick} buttonStyle="minimal">
114
- cerrar
115
- </Button>
117
+ <S.CloseButton type="button" onClick={handleClick} buttonStyle="minimal">
118
+ {LOCALE.common.close}
119
+ </S.CloseButton>
116
120
  </S.CloseWrapper>
117
121
  ) : (
118
122
  <S.IconSearchWrapper disabled={disabled} data-testid="icon-search-wrapper-2">
@@ -1,6 +1,9 @@
1
+ import { Button } from "@ax/components";
2
+
1
3
  import styled from "styled-components";
2
4
 
3
5
  const Wrapper = styled.div`
6
+ display: flex;
4
7
  position: relative;
5
8
  width: 100%;
6
9
  `;
@@ -8,15 +11,20 @@ const Wrapper = styled.div`
8
11
  const FieldWrapper = styled.div<{ closeOnInactive: boolean; disabled: boolean }>`
9
12
  display: flex;
10
13
  align-items: center;
14
+ justify-content: center;
15
+ background-color: white;
16
+ width: 100%;
17
+ column-gap: ${(p) => p.theme.spacing.xs};
18
+ padding-inline: ${(p) => p.theme.spacing.s};
11
19
  border-color: ${(p) =>
12
20
  p.disabled
13
21
  ? p.theme.color.interactiveDisabled
14
22
  : p.closeOnInactive
15
23
  ? p.theme.color.interactive01
16
24
  : p.theme.color.uiLine};
17
- border-width: ${(p) => (p.closeOnInactive ? "0 0 1px" : "1px")};
25
+ border-width: 1px;
18
26
  border-style: solid;
19
- border-radius: ${(p) => (p.closeOnInactive ? 0 : p.theme.radii.s)};
27
+ border-radius: ${(p) => p.theme.radii.s};
20
28
  &:focus-within {
21
29
  border-color: ${(p) => (p.disabled ? p.theme.color.interactiveDisabled : p.theme.color.interactive01)};
22
30
  }
@@ -31,33 +39,33 @@ const Input = styled.input<{
31
39
  ${(p) => p.theme.textStyle.fieldContent};
32
40
  color: ${(p) => p.theme.color.textHighEmphasis};
33
41
  background-color: ${(p) => p.theme.color.interactiveBackground};
34
- flex: 1 1 auto;
35
42
  height: ${(p) => (p.inputSize === "XXS" ? "32px" : p.inputSize === "XS" ? "40px" : p.theme.spacing.l)};
36
- padding-left: ${(p) => p.theme.spacing.s};
37
- padding-right: ${(p) => (p.closeOnInactive ? p.theme.spacing.xl : "0")};
38
43
  border: none;
39
- border-radius: ${(p) => (p.closeOnInactive ? 0 : p.theme.radii.s)};
44
+ border-radius: ${(p) => p.theme.radii.s};
45
+ margin-right: auto;
46
+ flex: 1 1 auto;
47
+ min-width: unset;
48
+ max-width: unset;
49
+ width: 100%;
50
+ &:active,
51
+ &:focus {
52
+ outline: none;
53
+ }
54
+
55
+ /*
40
56
  width: ${(p) =>
41
57
  p.small || ["S", "XS", "XXS"].includes(p.inputSize)
42
58
  ? `calc(${p.theme.spacing.xl} * 2)`
43
59
  : p.inputSize === "L"
44
60
  ? `calc(${p.theme.spacing.xl} * 6)`
45
61
  : `calc(${p.theme.spacing.xl} * 4)`};
46
-
47
- &:active,
48
- &:focus {
49
- outline: none;
50
- }
62
+ */
51
63
  `;
52
64
 
53
65
  const IconSearchWrapper = styled.div<{ onClick?: () => void; disabled: boolean }>`
54
- position: absolute;
55
- right: ${(p) => p.theme.spacing.s};
56
- top: 50%;
57
- width: ${(p) => p.theme.spacing.m};
66
+ margin-left: auto;
58
67
  height: ${(p) => p.theme.spacing.m};
59
68
  cursor: ${(p) => (p.onClick ? "pointer" : "default")};
60
- transform: translateY(-50%);
61
69
  svg {
62
70
  path {
63
71
  fill: ${(p) => (p.disabled ? p.theme.color.interactiveDisabled : p.theme.color.interactive01)};
@@ -65,25 +73,28 @@ const IconSearchWrapper = styled.div<{ onClick?: () => void; disabled: boolean }
65
73
  }
66
74
  `;
67
75
 
68
- const HelpText = styled.div`
76
+ const HelpText = styled.div<{ hide?: boolean }>`
77
+ display: ${(p) => (p.hide ? "none" : "block")};
78
+ visibility: ${(p) => (p.hide ? "hidden" : "visible")};
79
+ min-width: fit-content;
69
80
  ${(p) => p.theme.textStyle.uiXS};
70
81
  color: ${(p) => p.theme.color.textLowEmphasis};
71
82
  font-style: italic;
72
- position: absolute;
73
- right: 64px;
74
- top: 50%;
75
- transform: translateY(-50%);
76
83
  `;
77
84
 
78
85
  const CloseWrapper = styled.div`
79
- position: absolute;
80
- right: ${(p) => p.theme.spacing.xxs};
81
- top: 50%;
82
86
  cursor: pointer;
83
- transform: translateY(-50%);
87
+ display: flex;
88
+ min-width: fit-content;
84
89
  `;
85
90
 
86
- const FilterWrapper = styled.div``;
91
+ const CloseButton = styled(Button)`
92
+ margin: 0 !important;
93
+ `;
94
+
95
+ const FilterWrapper = styled.div`
96
+ min-width: fit-content;
97
+ `;
87
98
 
88
99
  const Separator = styled.div`
89
100
  border-right: 1px solid ${(p) => p.theme.color.uiLine};
@@ -92,4 +103,14 @@ const Separator = styled.div`
92
103
  margin-left: ${(p) => p.theme.spacing.s};
93
104
  `;
94
105
 
95
- export { Wrapper, IconSearchWrapper, FieldWrapper, Input, HelpText, CloseWrapper, FilterWrapper, Separator };
106
+ export {
107
+ CloseButton,
108
+ CloseWrapper,
109
+ FieldWrapper,
110
+ FilterWrapper,
111
+ HelpText,
112
+ IconSearchWrapper,
113
+ Input,
114
+ Separator,
115
+ Wrapper,
116
+ };