datastake-daf 0.6.597 → 0.6.598

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.
@@ -5678,7 +5678,7 @@ const MOBILE_W$1 = 850;
5678
5678
  const MOBILE_WIDTH$1 = `max-width: ${MOBILE_W$1}px`;
5679
5679
 
5680
5680
  /* eslint-disable react/prop-types */
5681
- const Style$4 = dt.div`
5681
+ const Style$5 = dt.div`
5682
5682
  display: flex;
5683
5683
  cursor: pointer;
5684
5684
 
@@ -5741,7 +5741,7 @@ function UserIcon({
5741
5741
  companyLogo
5742
5742
  }) {
5743
5743
  if (companyLogo) {
5744
- return /*#__PURE__*/jsxRuntime.jsx(Style$4, {
5744
+ return /*#__PURE__*/jsxRuntime.jsx(Style$5, {
5745
5745
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5746
5746
  className: "flex",
5747
5747
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
@@ -5759,7 +5759,7 @@ function UserIcon({
5759
5759
  })
5760
5760
  });
5761
5761
  }
5762
- return /*#__PURE__*/jsxRuntime.jsx(Style$4, {
5762
+ return /*#__PURE__*/jsxRuntime.jsx(Style$5, {
5763
5763
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
5764
5764
  className: "flex",
5765
5765
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
@@ -5776,7 +5776,7 @@ function UserIcon({
5776
5776
  });
5777
5777
  }
5778
5778
 
5779
- const Style$3 = dt.div`
5779
+ const Style$4 = dt.div`
5780
5780
  position: fixed;
5781
5781
  background: rgba(0, 0, 0, 0.4);
5782
5782
  width: 100dvw;
@@ -5976,7 +5976,7 @@ function MobileDrawer({
5976
5976
  }
5977
5977
  });
5978
5978
  };
5979
- return /*#__PURE__*/jsxRuntime.jsx(Style$3, {
5979
+ return /*#__PURE__*/jsxRuntime.jsx(Style$4, {
5980
5980
  className: formatClassname([!drawerOpened && 'closed', isUserDropdown && 'user-dropdown']),
5981
5981
  children: /*#__PURE__*/jsxRuntime.jsx("div", {
5982
5982
  className: "drawer",
@@ -6531,7 +6531,7 @@ function Notifications({
6531
6531
  });
6532
6532
  }
6533
6533
 
6534
- var Style$2 = dt.div`
6534
+ var Style$3 = dt.div`
6535
6535
  &.popup {
6536
6536
  h2 {
6537
6537
  margin-bottom: 8px;
@@ -6556,7 +6556,7 @@ var Style$2 = dt.div`
6556
6556
  }
6557
6557
  `;
6558
6558
 
6559
- const Style$1 = dt.div`
6559
+ const Style$2 = dt.div`
6560
6560
  .ant-btn {
6561
6561
  border-radius: 100px 100px 100px 0;
6562
6562
  padding: 10px;
@@ -6615,7 +6615,7 @@ const BorderedButton = ({
6615
6615
  children,
6616
6616
  ...props
6617
6617
  }) => {
6618
- return /*#__PURE__*/jsxRuntime.jsx(Style$1, {
6618
+ return /*#__PURE__*/jsxRuntime.jsx(Style$2, {
6619
6619
  className: "d-btn-cont",
6620
6620
  children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
6621
6621
  ...props,
@@ -6665,7 +6665,7 @@ function LoginPopup({
6665
6665
  open: true,
6666
6666
  footer: null,
6667
6667
  closable: false,
6668
- children: /*#__PURE__*/jsxRuntime.jsxs(Style$2, {
6668
+ children: /*#__PURE__*/jsxRuntime.jsxs(Style$3, {
6669
6669
  className: "popup",
6670
6670
  children: [/*#__PURE__*/jsxRuntime.jsx("h2", {
6671
6671
  children: t('Log back in')
@@ -7296,7 +7296,7 @@ const MOBILE_WIDTH = `max-width: ${MOBILE_W}px`;
7296
7296
  const TABLET_WIDTH = `max-width: ${TABLET_W}px`;
7297
7297
 
7298
7298
  // Global styles for portaled elements (dropdowns, modals, etc.)
7299
- const GlobalNavbarStyles = ft`
7299
+ ft`
7300
7300
  .language-select-popup {
7301
7301
  .ant-select-dropdown {
7302
7302
  padding: 4px;
@@ -7429,7 +7429,7 @@ const style = dt.div`
7429
7429
 
7430
7430
  .navbar-logo {
7431
7431
  cursor: pointer;
7432
- height: 40px;
7432
+ height: 30px;
7433
7433
  width: auto;
7434
7434
  object-fit: contain;
7435
7435
 
@@ -7500,28 +7500,6 @@ const style = dt.div`
7500
7500
  }
7501
7501
  }
7502
7502
 
7503
- .back-btn {
7504
- background: transparent;
7505
- border: 1px solid #D0D5DD;
7506
- border-radius: 8px;
7507
- padding: 8px 16px;
7508
- font-size: 14px;
7509
- font-weight: 500;
7510
- color: #344054;
7511
- cursor: pointer;
7512
- transition: all 0.2s ease;
7513
- box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05);
7514
-
7515
- &:hover {
7516
- background: #F9FAFB;
7517
- border-color: #98A2B3;
7518
- }
7519
-
7520
- &:active {
7521
- transform: scale(0.98);
7522
- }
7523
- }
7524
-
7525
7503
  .ant-btn {
7526
7504
  font-size: 14px;
7527
7505
  padding: 6px 0;
@@ -7563,21 +7541,6 @@ const style = dt.div`
7563
7541
  }
7564
7542
  }
7565
7543
 
7566
- .ant-btn {
7567
- width: 90px !important;
7568
- display: flex;
7569
- flex-direction: column;
7570
- justify-content: center;
7571
-
7572
- &.w-100 {
7573
- width: 100% !important;
7574
- }
7575
-
7576
- span {
7577
- margin: 0 auto;
7578
- }
7579
- }
7580
-
7581
7544
  .nav-extra {
7582
7545
  position: fixed;
7583
7546
  top: 0;
@@ -7595,6 +7558,278 @@ const style = dt.div`
7595
7558
  }
7596
7559
  `;
7597
7560
 
7561
+ const languages = [{
7562
+ value: 'en',
7563
+ label: '🇬🇧 EN'
7564
+ }, {
7565
+ value: 'fr',
7566
+ label: '🇫🇷 FR'
7567
+ }, {
7568
+ value: 'sp',
7569
+ label: '🇪🇸 ES'
7570
+ }];
7571
+
7572
+ const Style$1 = dt.div`
7573
+ display: flex;
7574
+ flex-direction: column;
7575
+ justify-content: center;
7576
+ position: relative;
7577
+
7578
+ .flex-r {
7579
+ display: flex;
7580
+ }
7581
+
7582
+ .flex-c {
7583
+ display: flex;
7584
+ flex-direction: column;
7585
+
7586
+ img {
7587
+ border-radius: 50%;
7588
+ margin-top: -2px;
7589
+ }
7590
+ }
7591
+
7592
+ .justify-center {
7593
+ justify-content: center;
7594
+ }
7595
+
7596
+ .select-navbar {
7597
+ padding: 0 .75rem;
7598
+
7599
+ div {
7600
+ width: 4.625rem;
7601
+ user-select: none;
7602
+ font-size: .875rem;
7603
+ font-weight: 500;
7604
+ text-align: center;
7605
+ color: #193E61;
7606
+ cursor: pointer;
7607
+ }
7608
+
7609
+ .country-cont {
7610
+ justify-content: center;
7611
+ gap: 0.6rem;
7612
+
7613
+ .flex-c {
7614
+ width: fit-content;
7615
+ }
7616
+
7617
+ img {
7618
+ width: 18px;
7619
+ height: 18px;
7620
+ }
7621
+
7622
+ span {
7623
+ color: $gray-100;
7624
+ font-size: 14px;
7625
+ }
7626
+ }
7627
+
7628
+ &.bordered {
7629
+ .country-cont {
7630
+ img {
7631
+ width: 14px;
7632
+ height: 14px;
7633
+ border-radius: 100%;
7634
+ }
7635
+ }
7636
+ }
7637
+ }
7638
+
7639
+ .select-options {
7640
+ position: absolute;
7641
+ width: 100%;
7642
+ top: 55px;
7643
+ left: 0;
7644
+ background-color: white;
7645
+ border-radius: 8px;
7646
+ box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
7647
+ padding: .75rem 0;
7648
+ z-index: 100;
7649
+ animation: .3s fade forwards;
7650
+
7651
+ &.not-toggled {
7652
+ animation: .3s fadeOut forwards;
7653
+ }
7654
+
7655
+ @media (${TABLET_WIDTH}) {
7656
+ top: 50px;
7657
+ }
7658
+
7659
+ @media (${MOBILE_WIDTH}) {
7660
+ top: 3.5rem;
7661
+ }
7662
+
7663
+ .value {
7664
+ padding: .75rem 0rem;
7665
+ margin: 0 .75rem;
7666
+ text-align: center;
7667
+ font-size: 1rem;
7668
+ font-weight: 500;
7669
+ cursor: pointer;
7670
+ user-select: none;
7671
+
7672
+ &.active-value {
7673
+ background-color: #265A80;
7674
+ color: white;
7675
+ }
7676
+ }
7677
+ }
7678
+
7679
+ @keyframes fade {
7680
+ 0% { opacity: 0; }
7681
+ 100% { opacity: 1; }
7682
+ }
7683
+
7684
+ @keyframes fadeOut {
7685
+ 0% { opacity: 1; }
7686
+ 100% { opacity: 0; }
7687
+ }
7688
+ `;
7689
+
7690
+ /* eslint-disable react/prop-types */
7691
+ function useOutsideAlerter({
7692
+ ref,
7693
+ secondRef,
7694
+ onOutside = () => {}
7695
+ }) {
7696
+ o.useEffect(() => {
7697
+ function handleClickOutside(event) {
7698
+ if (ref.current && !ref.current.contains(event.target) && secondRef.current && !secondRef.current.contains(event.target)) {
7699
+ onOutside();
7700
+ }
7701
+ }
7702
+ document.addEventListener("mousedown", handleClickOutside);
7703
+ return () => {
7704
+ document.removeEventListener("mousedown", handleClickOutside);
7705
+ };
7706
+ }, [ref]);
7707
+ }
7708
+ const Options = ({
7709
+ values = [],
7710
+ onChange = () => {},
7711
+ value = '',
7712
+ setToggled = () => {},
7713
+ toggled = false,
7714
+ secondRef = {}
7715
+ }) => {
7716
+ const ref = o.useRef();
7717
+ useOutsideAlerter({
7718
+ ref,
7719
+ secondRef,
7720
+ onOutside: () => setToggled(false)
7721
+ });
7722
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
7723
+ className: formatClassname(['select-options', !toggled && 'not-toggled']),
7724
+ ref: ref,
7725
+ children: values.map(val => /*#__PURE__*/jsxRuntime.jsx("div", {
7726
+ className: formatClassname(['value', val.value === value && 'active-value']),
7727
+ onClick: () => onChange(val.value),
7728
+ children: val.label
7729
+ }, val.value))
7730
+ });
7731
+ };
7732
+ let timeout = null;
7733
+ const Select = ({
7734
+ bordered,
7735
+ values = [],
7736
+ defaultValue = '',
7737
+ onChange = () => {}
7738
+ }) => {
7739
+ const ref = o.useRef();
7740
+ const [value, setValue] = o.useState(defaultValue);
7741
+ const [toggled, setToggled] = o.useState(false);
7742
+ const [visible, setVisible] = o.useState(false);
7743
+ o.useEffect(() => {
7744
+ setValue(defaultValue);
7745
+ }, [defaultValue]);
7746
+ const valueLabel = o.useMemo(() => {
7747
+ if (value === 'en') {
7748
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
7749
+ className: "country-cont flex-r",
7750
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
7751
+ className: "flex-c jus-c",
7752
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
7753
+ src: "/assets/images/countries/gb.png",
7754
+ alt: ""
7755
+ })
7756
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
7757
+ className: "flex-c jus-c",
7758
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
7759
+ children: "EN"
7760
+ })
7761
+ })]
7762
+ });
7763
+ }
7764
+ if (value === 'sp') {
7765
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
7766
+ className: "country-cont flex-r",
7767
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
7768
+ className: "flex-c jus-c",
7769
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
7770
+ src: "/assets/images/countries/sp.png",
7771
+ alt: ""
7772
+ })
7773
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
7774
+ className: "flex-c jus-c",
7775
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
7776
+ children: "ES"
7777
+ })
7778
+ })]
7779
+ });
7780
+ }
7781
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
7782
+ className: "country-cont flex-r",
7783
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
7784
+ className: "flex-c jus-c",
7785
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
7786
+ src: "/assets/images/countries/fr.png",
7787
+ alt: ""
7788
+ })
7789
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
7790
+ className: "flex-c jus-c",
7791
+ children: /*#__PURE__*/jsxRuntime.jsx("span", {
7792
+ children: "FR"
7793
+ })
7794
+ })]
7795
+ });
7796
+ }, [values, value]);
7797
+ o.useEffect(() => {
7798
+ if (toggled) {
7799
+ setVisible(true);
7800
+ } else {
7801
+ timeout = setTimeout(() => setVisible(false), 300);
7802
+ }
7803
+ return () => {
7804
+ if (timeout) {
7805
+ clearTimeout(timeout);
7806
+ timeout = null;
7807
+ }
7808
+ };
7809
+ }, [toggled]);
7810
+ return /*#__PURE__*/jsxRuntime.jsxs(Style$1, {
7811
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
7812
+ className: formatClassname(['select-navbar', bordered && 'bordered']),
7813
+ onClick: () => setToggled(p => !p),
7814
+ ref: ref,
7815
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
7816
+ children: valueLabel
7817
+ })
7818
+ }), visible && /*#__PURE__*/jsxRuntime.jsx(Options, {
7819
+ value: value,
7820
+ secondRef: ref,
7821
+ values: values,
7822
+ toggled: toggled,
7823
+ onChange: val => {
7824
+ setValue(val);
7825
+ setToggled(false);
7826
+ onChange(val);
7827
+ },
7828
+ setToggled: setToggled
7829
+ })]
7830
+ });
7831
+ };
7832
+
7598
7833
  const AuthNavbar = ({
7599
7834
  logo,
7600
7835
  appName = "default",
@@ -7615,65 +7850,48 @@ const AuthNavbar = ({
7615
7850
  }],
7616
7851
  showBack = false,
7617
7852
  backLabel = "Back",
7618
- onBack
7853
+ onBack,
7854
+ defaultValue = "en",
7855
+ onClose
7619
7856
  }) => {
7620
- return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
7621
- children: [/*#__PURE__*/jsxRuntime.jsx(GlobalNavbarStyles, {}), /*#__PURE__*/jsxRuntime.jsx(style, {
7622
- className: formatClassname([showBack && 'bordered']),
7623
- children: /*#__PURE__*/jsxRuntime.jsx("div", {
7624
- className: "d-navbar",
7625
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
7626
- className: "main-cont d-container",
7627
- children: [/*#__PURE__*/jsxRuntime.jsx("div", {
7628
- className: "left",
7629
- children: logo && /*#__PURE__*/jsxRuntime.jsx("img", {
7630
- className: "navbar-logo",
7631
- src: logo,
7632
- alt: `${appName} logo`
7857
+ return /*#__PURE__*/jsxRuntime.jsx(style, {
7858
+ className: formatClassname([typeof onClose === 'function' && 'bordered']),
7859
+ children: /*#__PURE__*/jsxRuntime.jsx("div", {
7860
+ className: "d-navbar flex-c jus-c",
7861
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
7862
+ className: "main-cont d-container",
7863
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
7864
+ className: "left flex-c jus-c",
7865
+ children: /*#__PURE__*/jsxRuntime.jsx("img", {
7866
+ src: logo,
7867
+ alt: appName
7868
+ })
7869
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
7870
+ className: "right",
7871
+ children: [typeof onClose === 'function' ? /*#__PURE__*/jsxRuntime.jsx("div", {
7872
+ className: "cursor-pointer",
7873
+ onClick: onClose,
7874
+ children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
7875
+ name: "Close",
7876
+ width: 10,
7877
+ height: 10
7633
7878
  })
7634
- }), /*#__PURE__*/jsxRuntime.jsxs("div", {
7635
- className: "right",
7636
- children: [showLanguageSelector && updateLanguage && /*#__PURE__*/jsxRuntime.jsx(antd.Select, {
7637
- className: "language-select",
7638
- defaultValue: localStorage.getItem("datastakeLng") || "en",
7639
- onChange: lng => updateLanguage(lng),
7640
- popupClassName: formatClassname(["language-select-popup", appName]),
7641
- suffixIcon: /*#__PURE__*/jsxRuntime.jsx("svg", {
7642
- width: "20",
7643
- height: "20",
7644
- viewBox: "0 0 20 20",
7645
- fill: "none",
7646
- xmlns: "http://www.w3.org/2000/svg",
7647
- children: /*#__PURE__*/jsxRuntime.jsx("path", {
7648
- d: "M5 7.5L10 12.5L15 7.5",
7649
- stroke: "#667085",
7650
- strokeWidth: "1.66667",
7651
- strokeLinecap: "round",
7652
- strokeLinejoin: "round"
7653
- })
7654
- }),
7655
- children: languageConfig.map(lang => /*#__PURE__*/jsxRuntime.jsx(antd.Select.Option, {
7656
- value: lang.value,
7657
- children: /*#__PURE__*/jsxRuntime.jsxs("div", {
7658
- className: "language-option",
7659
- children: [/*#__PURE__*/jsxRuntime.jsx("img", {
7660
- src: lang.flagUrl,
7661
- alt: lang.label,
7662
- className: "flag-icon"
7663
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
7664
- children: lang.label
7665
- })]
7666
- })
7667
- }, lang.value))
7668
- }), showBack && /*#__PURE__*/jsxRuntime.jsx("button", {
7669
- className: "back-btn",
7670
- onClick: onBack,
7671
- children: backLabel
7672
- })]
7673
- })]
7674
- })
7879
+ }) : /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
7880
+ children: /*#__PURE__*/jsxRuntime.jsx(Select, {
7881
+ values: languages,
7882
+ defaultValue: defaultValue,
7883
+ onChange: val => {
7884
+ updateLanguage(val);
7885
+ }
7886
+ })
7887
+ }), showBack ? /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
7888
+ className: "cursor-pointer",
7889
+ onClick: onBack,
7890
+ children: backLabel
7891
+ }) : null]
7892
+ })]
7675
7893
  })
7676
- })]
7894
+ })
7677
7895
  });
7678
7896
  };
7679
7897
 
@@ -8092,7 +8310,8 @@ const AuthLayout = ({
8092
8310
  updateLanguage,
8093
8311
  showBack = false,
8094
8312
  onBack,
8095
- backLabel = "Back"
8313
+ backLabel = "Back",
8314
+ defaultValue = "en"
8096
8315
  }) => {
8097
8316
  formatClassname(["auth-layout", appName, containerClassName]);
8098
8317
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
@@ -8103,7 +8322,8 @@ const AuthLayout = ({
8103
8322
  updateLanguage: updateLanguage,
8104
8323
  showBack: showBack,
8105
8324
  onBack: onBack,
8106
- backLabel: backLabel
8325
+ backLabel: backLabel,
8326
+ defaultValue: defaultValue
8107
8327
  }), /*#__PURE__*/jsxRuntime.jsx(Style, {
8108
8328
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
8109
8329
  className: "main-cont",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.597",
3
+ "version": "0.6.598",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -451,6 +451,9 @@ export const CustomRightImage = {
451
451
  showTopHeader={true}
452
452
  showLanguageSelector={true}
453
453
  updateLanguage={(lng) => console.log("Language changed to:", lng)}
454
+ showBack={true}
455
+ onBack={() => console.log("Back clicked")}
456
+ backLabel="Back"
454
457
  >
455
458
  <LoginForm />
456
459
  </AuthLayout>
@@ -1,7 +1,10 @@
1
1
  import React from "react";
2
- import { Select } from "antd";
2
+ import { Button } from "antd";
3
3
  import { formatClassname } from "../../../../../helpers/ClassesHelper.js";
4
4
  import Style, { GlobalNavbarStyles } from './style';
5
+ import { languages } from "./config";
6
+ import { Select } from "../Select/index.jsx";
7
+ import CustomIcon from "../../../../core/components/Icon/CustomIcon.jsx";
5
8
 
6
9
  const AuthNavbar = ({
7
10
  logo,
@@ -16,60 +19,41 @@ const AuthNavbar = ({
16
19
  showBack = false,
17
20
  backLabel = "Back",
18
21
  onBack,
22
+ defaultValue = "en",
23
+ onClose
19
24
  }) => {
20
25
  return (
21
- <>
22
- <GlobalNavbarStyles />
23
- <Style className={formatClassname([showBack && 'bordered'])}>
24
- <div className="d-navbar">
25
- <div className="main-cont d-container">
26
- <div className="left">
27
- {logo && (
28
- <img className="navbar-logo" src={logo} alt={`${appName} logo`} />
29
- )}
30
- </div>
31
-
32
- <div className="right">
33
- {showLanguageSelector && updateLanguage && (
34
- <Select
35
- className="language-select"
36
- defaultValue={localStorage.getItem("datastakeLng") || "en"}
37
- onChange={(lng) => updateLanguage(lng)}
38
- popupClassName={formatClassname([
39
- "language-select-popup",
40
- appName,
41
- ])}
42
- suffixIcon={
43
- <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
44
- <path d="M5 7.5L10 12.5L15 7.5" stroke="#667085" strokeWidth="1.66667" strokeLinecap="round" strokeLinejoin="round"/>
45
- </svg>
46
- }
47
- >
48
- {languageConfig.map((lang) => (
49
- <Select.Option key={lang.value} value={lang.value}>
50
- <div className="language-option">
51
- <img
52
- src={lang.flagUrl}
53
- alt={lang.label}
54
- className="flag-icon"
55
- />
56
- <span>{lang.label}</span>
57
- </div>
58
- </Select.Option>
59
- ))}
60
- </Select>
61
- )}
62
-
63
- {showBack && (
64
- <button className="back-btn" onClick={onBack}>
65
- {backLabel}
66
- </button>
67
- )}
26
+ <Style className={formatClassname([typeof onClose === 'function' && 'bordered'])}>
27
+ <div className="d-navbar flex-c jus-c">
28
+ <div className="main-cont d-container">
29
+ <div className="left flex-c jus-c">
30
+ <img src={logo} alt={appName} />
31
+ </div>
32
+ <div className="right">
33
+ {typeof onClose === 'function' ? (
34
+ <div className="cursor-pointer" onClick={onClose}>
35
+ <CustomIcon name="Close" width={10} height={10} />
68
36
  </div>
69
- </div>
37
+ ) : (
38
+ <>
39
+ <Select
40
+ values={languages}
41
+ defaultValue={defaultValue}
42
+ onChange={(val) => {
43
+ updateLanguage(val);
44
+ }}
45
+ />
46
+ </>
47
+ )}
48
+ {showBack ? (
49
+ <Button className="cursor-pointer" onClick={onBack}>
50
+ {backLabel}
51
+ </Button>
52
+ ) : null}
70
53
  </div>
71
- </Style>
72
- </>
54
+ </div>
55
+ </div>
56
+ </Style >
73
57
  );
74
58
  };
75
59
 
@@ -136,7 +136,7 @@ const style = styled.div`
136
136
 
137
137
  .navbar-logo {
138
138
  cursor: pointer;
139
- height: 40px;
139
+ height: 30px;
140
140
  width: auto;
141
141
  object-fit: contain;
142
142
 
@@ -207,28 +207,6 @@ const style = styled.div`
207
207
  }
208
208
  }
209
209
 
210
- .back-btn {
211
- background: transparent;
212
- border: 1px solid #D0D5DD;
213
- border-radius: 8px;
214
- padding: 8px 16px;
215
- font-size: 14px;
216
- font-weight: 500;
217
- color: #344054;
218
- cursor: pointer;
219
- transition: all 0.2s ease;
220
- box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05);
221
-
222
- &:hover {
223
- background: #F9FAFB;
224
- border-color: #98A2B3;
225
- }
226
-
227
- &:active {
228
- transform: scale(0.98);
229
- }
230
- }
231
-
232
210
  .ant-btn {
233
211
  font-size: 14px;
234
212
  padding: 6px 0;
@@ -270,21 +248,6 @@ const style = styled.div`
270
248
  }
271
249
  }
272
250
 
273
- .ant-btn {
274
- width: 90px !important;
275
- display: flex;
276
- flex-direction: column;
277
- justify-content: center;
278
-
279
- &.w-100 {
280
- width: 100% !important;
281
- }
282
-
283
- span {
284
- margin: 0 auto;
285
- }
286
- }
287
-
288
251
  .nav-extra {
289
252
  position: fixed;
290
253
  top: 0;
@@ -0,0 +1,146 @@
1
+ /* eslint-disable react/prop-types */
2
+ import React, { useEffect, useMemo, useRef, useState } from "react"
3
+ import { formatClassname } from '../../../../../helpers/ClassesHelper.js';
4
+ import Style from "./style";
5
+
6
+ function useOutsideAlerter({ ref, secondRef, onOutside = () => { } }) {
7
+ useEffect(() => {
8
+ function handleClickOutside(event) {
9
+ if (ref.current && !ref.current.contains(event.target)
10
+ && secondRef.current && !secondRef.current.contains(event.target)) {
11
+ onOutside();
12
+ }
13
+ }
14
+
15
+ document.addEventListener("mousedown", handleClickOutside);
16
+ return () => {
17
+ document.removeEventListener("mousedown", handleClickOutside);
18
+ };
19
+ }, [ref]);
20
+ }
21
+
22
+ const Options = ({
23
+ values = [],
24
+ onChange = () => { },
25
+ value = '',
26
+ setToggled = () => { },
27
+ toggled = false,
28
+ secondRef = {},
29
+ }) => {
30
+ const ref = useRef();
31
+ useOutsideAlerter({ ref, secondRef, onOutside: () => setToggled(false) });
32
+
33
+ return (
34
+ <div
35
+ className={formatClassname(['select-options', !toggled && 'not-toggled'])}
36
+ ref={ref}
37
+ >
38
+ {values.map((val) => (
39
+ <div
40
+ className={formatClassname(['value', val.value === value && 'active-value'])}
41
+ key={val.value}
42
+ onClick={() => onChange(val.value)}
43
+ >
44
+ {val.label}
45
+ </div>
46
+ ))}
47
+ </div>
48
+ );
49
+ }
50
+
51
+ let timeout = null;
52
+
53
+ export const Select = ({
54
+ bordered,
55
+ values = [],
56
+ defaultValue = '',
57
+ onChange = () => { },
58
+ }) => {
59
+ const ref = useRef();
60
+ const [value, setValue] = useState(defaultValue);
61
+ const [toggled, setToggled] = useState(false);
62
+ const [visible, setVisible] = useState(false);
63
+
64
+ useEffect(() => {
65
+ setValue(defaultValue);
66
+ }, [defaultValue]);
67
+
68
+ const valueLabel = useMemo(() => {
69
+ if (value === 'en') {
70
+ return (
71
+ <div className="country-cont flex-r">
72
+ <div className="flex-c jus-c">
73
+ <img src="/assets/images/countries/gb.png" alt="" />
74
+ </div>
75
+ <div className="flex-c jus-c">
76
+ <span>EN</span>
77
+ </div>
78
+ </div>
79
+ );
80
+ }
81
+
82
+ if (value === 'sp') {
83
+ return (
84
+ <div className="country-cont flex-r">
85
+ <div className="flex-c jus-c">
86
+ <img src="/assets/images/countries/sp.png" alt="" />
87
+ </div>
88
+ <div className="flex-c jus-c">
89
+ <span>ES</span>
90
+ </div>
91
+ </div>
92
+ );
93
+ }
94
+
95
+ return (
96
+ <div className="country-cont flex-r">
97
+ <div className="flex-c jus-c">
98
+ <img src="/assets/images/countries/fr.png" alt="" />
99
+ </div>
100
+ <div className="flex-c jus-c">
101
+ <span>FR</span>
102
+ </div>
103
+ </div>
104
+ );
105
+ }, [values, value]);
106
+
107
+ useEffect(() => {
108
+ if (toggled) {
109
+ setVisible(true);
110
+ } else {
111
+ timeout = setTimeout(() => setVisible(false), 300);
112
+ }
113
+ return () => {
114
+ if (timeout) {
115
+ clearTimeout(timeout);
116
+ timeout = null;
117
+ }
118
+ }
119
+ }, [toggled]);
120
+
121
+ return (
122
+ <Style>
123
+ <div
124
+ className={formatClassname(['select-navbar', bordered && 'bordered'])}
125
+ onClick={() => setToggled((p) => !p)}
126
+ ref={ref}
127
+ >
128
+ <div>{valueLabel}</div>
129
+ </div>
130
+ {visible && (
131
+ <Options
132
+ value={value}
133
+ secondRef={ref}
134
+ values={values}
135
+ toggled={toggled}
136
+ onChange={(val) => {
137
+ setValue(val);
138
+ setToggled(false);
139
+ onChange(val);
140
+ }}
141
+ setToggled={setToggled}
142
+ />
143
+ )}
144
+ </Style>
145
+ );
146
+ }
@@ -0,0 +1,122 @@
1
+ import styled from "styled-components";
2
+ import { MOBILE_WIDTH, TABLET_WIDTH } from "datastake-daf/src/constants/Style";
3
+
4
+ const Style = styled.div`
5
+ display: flex;
6
+ flex-direction: column;
7
+ justify-content: center;
8
+ position: relative;
9
+
10
+ .flex-r {
11
+ display: flex;
12
+ }
13
+
14
+ .flex-c {
15
+ display: flex;
16
+ flex-direction: column;
17
+
18
+ img {
19
+ border-radius: 50%;
20
+ margin-top: -2px;
21
+ }
22
+ }
23
+
24
+ .justify-center {
25
+ justify-content: center;
26
+ }
27
+
28
+ .select-navbar {
29
+ padding: 0 .75rem;
30
+
31
+ div {
32
+ width: 4.625rem;
33
+ user-select: none;
34
+ font-size: .875rem;
35
+ font-weight: 500;
36
+ text-align: center;
37
+ color: #193E61;
38
+ cursor: pointer;
39
+ }
40
+
41
+ .country-cont {
42
+ justify-content: center;
43
+ gap: 0.6rem;
44
+
45
+ .flex-c {
46
+ width: fit-content;
47
+ }
48
+
49
+ img {
50
+ width: 18px;
51
+ height: 18px;
52
+ }
53
+
54
+ span {
55
+ color: $gray-100;
56
+ font-size: 14px;
57
+ }
58
+ }
59
+
60
+ &.bordered {
61
+ .country-cont {
62
+ img {
63
+ width: 14px;
64
+ height: 14px;
65
+ border-radius: 100%;
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ .select-options {
72
+ position: absolute;
73
+ width: 100%;
74
+ top: 55px;
75
+ left: 0;
76
+ background-color: white;
77
+ border-radius: 8px;
78
+ box-shadow: 0px 12px 16px -4px rgba(16, 24, 40, 0.08), 0px 4px 6px -2px rgba(16, 24, 40, 0.03);
79
+ padding: .75rem 0;
80
+ z-index: 100;
81
+ animation: .3s fade forwards;
82
+
83
+ &.not-toggled {
84
+ animation: .3s fadeOut forwards;
85
+ }
86
+
87
+ @media (${TABLET_WIDTH}) {
88
+ top: 50px;
89
+ }
90
+
91
+ @media (${MOBILE_WIDTH}) {
92
+ top: 3.5rem;
93
+ }
94
+
95
+ .value {
96
+ padding: .75rem 0rem;
97
+ margin: 0 .75rem;
98
+ text-align: center;
99
+ font-size: 1rem;
100
+ font-weight: 500;
101
+ cursor: pointer;
102
+ user-select: none;
103
+
104
+ &.active-value {
105
+ background-color: #265A80;
106
+ color: white;
107
+ }
108
+ }
109
+ }
110
+
111
+ @keyframes fade {
112
+ 0% { opacity: 0; }
113
+ 100% { opacity: 1; }
114
+ }
115
+
116
+ @keyframes fadeOut {
117
+ 0% { opacity: 1; }
118
+ 100% { opacity: 0; }
119
+ }
120
+ `;
121
+
122
+ export default Style;
@@ -23,6 +23,7 @@ const AuthLayout = ({
23
23
  showBack = false,
24
24
  onBack,
25
25
  backLabel = "Back",
26
+ defaultValue = "en",
26
27
  }) => {
27
28
  const Wrapper = StyleComponent || "div";
28
29
  const wrapperClassName = formatClassname([
@@ -44,9 +45,10 @@ const AuthLayout = ({
44
45
  showBack={showBack}
45
46
  onBack={onBack}
46
47
  backLabel={backLabel}
48
+ defaultValue={defaultValue}
47
49
  />
48
50
  )}
49
- <Style>
51
+ <Style>
50
52
  <div className="main-cont">
51
53
  <div className={formatClassname(["d-cont left", leftClassName])}>
52
54
  <div className="main">