@nuskin/foundation-ui-components 1.25.2 → 1.26.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/foundation-ui-components",
3
- "version": "1.25.2",
3
+ "version": "1.26.0",
4
4
  "description": "It is a foundation library written in react, that provides common components to all UI pages",
5
5
  "main": "src/common/index.ts",
6
6
  "repository": {
@@ -1,5 +1,6 @@
1
1
  import { styled, ColorUtils } from '@nuskin/foundation-theme';
2
2
  import { NsInputField } from '../input';
3
+ import { Popper } from '@mui/material';
3
4
  const { getGenomeColor } = ColorUtils;
4
5
 
5
6
  export const StyledTextField = styled(NsInputField)`
@@ -11,6 +12,10 @@ export const StyledTextField = styled(NsInputField)`
11
12
  color: ${({ theme }) => getGenomeColor(theme, 'N100', 'light')};
12
13
  }
13
14
  `;
14
- // .muiautocomplete-popupindicator {
15
- // display: none;
16
- // }
15
+
16
+ export const StyledPopper = styled(Popper)`
17
+ width: 100% !important;
18
+ #custom_autocomplete_dropdown-listbox{
19
+ overflow-x:hidden;
20
+ }
21
+ `
@@ -8,6 +8,7 @@ import React, {
8
8
  import {
9
9
  Autocomplete,
10
10
  AutocompleteRenderInputParams,
11
+ Popper,
11
12
  } from '@mui/material';
12
13
 
13
14
  import { LineLoader } from './helper/LineLoader';
@@ -18,7 +19,7 @@ import {
18
19
  renderOptionLabel,
19
20
  } from './helper/renderGroupName';
20
21
  import { SeeMoreButton } from './helper/SeeMoreButton';
21
- import { StyledTextField } from './NsAutocomplete.styled';
22
+ import { StyledPopper, StyledTextField } from './NsAutocomplete.styled';
22
23
  import {
23
24
  ComponentBoxProps,
24
25
  NsAutocompleteProps,
@@ -44,6 +45,7 @@ const NsAutocomplete = ({
44
45
  inputValue,
45
46
  value,
46
47
  isFilterEnabled = true,
48
+ fullWidth
47
49
  }: PropsWithChildren<NsAutocompleteProps>) => {
48
50
  const [scrollTopPosition, setScrollTopPosition] = useState(0);
49
51
  const listboxRef = useRef<HTMLUListElement | null>(null);
@@ -120,6 +122,7 @@ const NsAutocomplete = ({
120
122
  getOptionLabel={renderOptionLabel}
121
123
  renderOption={renderOption as any}
122
124
  renderInput={renderInput}
125
+ PopperComponent={fullWidth ? StyledPopper : Popper}
123
126
  ListboxComponent={renderListBoxComponent as any}
124
127
  renderGroup={renderGroupName}
125
128
  onChange={onChange}
@@ -47,6 +47,7 @@ export type NsAutocompleteProps = {
47
47
  inputValue: string;
48
48
  value: string | OptionsProps | null;
49
49
  isFilterEnabled?: boolean;
50
+ fullWidth?:boolean
50
51
  } & AdditionalProps;
51
52
 
52
53
  export type ListUiProps = {
@@ -7,6 +7,15 @@ import { NsButton } from '../';
7
7
  const { palette } = nuskinTheme;
8
8
 
9
9
  describe('<Button />', () => {
10
+ it('0. should match snapshot', () => {
11
+ const text = 'Click Me';
12
+ const { container } = render(
13
+ <NsButton color="primary" variant="contained">
14
+ {text}
15
+ </NsButton>
16
+ );
17
+ expect(container).toMatchSnapshot();
18
+ });
10
19
  it('1. should render default primary button styles ', () => {
11
20
  const text = 'Click Me';
12
21
  render(
@@ -0,0 +1,120 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<Button /> 1. should match snapshot 1`] = `
4
+ .emotion-0 {
5
+ display: -webkit-inline-box;
6
+ display: -webkit-inline-flex;
7
+ display: -ms-inline-flexbox;
8
+ display: inline-flex;
9
+ -webkit-align-items: center;
10
+ -webkit-box-align: center;
11
+ -ms-flex-align: center;
12
+ align-items: center;
13
+ -webkit-box-pack: center;
14
+ -ms-flex-pack: center;
15
+ -webkit-justify-content: center;
16
+ justify-content: center;
17
+ position: relative;
18
+ box-sizing: border-box;
19
+ -webkit-tap-highlight-color: transparent;
20
+ background-color: transparent;
21
+ outline: 0;
22
+ border: 0;
23
+ margin: 0;
24
+ border-radius: 0;
25
+ padding: 0;
26
+ cursor: pointer;
27
+ -webkit-user-select: none;
28
+ -moz-user-select: none;
29
+ -ms-user-select: none;
30
+ user-select: none;
31
+ vertical-align: middle;
32
+ -moz-appearance: none;
33
+ -webkit-appearance: none;
34
+ -webkit-text-decoration: none;
35
+ text-decoration: none;
36
+ color: inherit;
37
+ font-family: 'Inter',sans-serif;
38
+ min-width: 64px;
39
+ padding: 6px 16px;
40
+ border-radius: 4px;
41
+ -webkit-transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
42
+ transition: background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
43
+ color: #FFFFFF;
44
+ background-color: #252525;
45
+ box-shadow: 0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12);
46
+ gap: 10px;
47
+ border-radius: 0;
48
+ background-color: #252525;
49
+ color: #FFFFFF!important;
50
+ text-transform: none;
51
+ }
52
+
53
+ .emotion-0::-moz-focus-inner {
54
+ border-style: none;
55
+ }
56
+
57
+ .emotion-0.Mui-disabled {
58
+ pointer-events: none;
59
+ cursor: default;
60
+ }
61
+
62
+ @media print {
63
+ .emotion-0 {
64
+ -webkit-print-color-adjust: exact;
65
+ color-adjust: exact;
66
+ }
67
+ }
68
+
69
+ .emotion-0:hover {
70
+ -webkit-text-decoration: none;
71
+ text-decoration: none;
72
+ box-shadow: 0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12);
73
+ }
74
+
75
+ @media (hover: none) {
76
+ .emotion-0:hover {
77
+ background-color: #252525;
78
+ }
79
+ }
80
+
81
+ .emotion-0:active {
82
+ box-shadow: 0px 5px 5px -3px rgba(0,0,0,0.2),0px 8px 10px 1px rgba(0,0,0,0.14),0px 3px 14px 2px rgba(0,0,0,0.12);
83
+ }
84
+
85
+ .emotion-0.Mui-focusVisible {
86
+ box-shadow: 0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12);
87
+ }
88
+
89
+ .emotion-0.Mui-disabled {
90
+ color: rgba(0, 0, 0, 0.26);
91
+ box-shadow: none;
92
+ background-color: rgba(0, 0, 0, 0.12);
93
+ }
94
+
95
+ .emotion-0:focus {
96
+ background-color: #252525;
97
+ }
98
+
99
+ .emotion-0:hover {
100
+ background-color: #8C8C8C;
101
+ }
102
+
103
+ .emotion-0:active {
104
+ background-color: #F5F5F5;
105
+ }
106
+
107
+ <div>
108
+ <main
109
+ class="theme-wrapper light"
110
+ >
111
+ <button
112
+ class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium emotion-0"
113
+ tabindex="0"
114
+ type="button"
115
+ >
116
+ Click Me
117
+ </button>
118
+ </main>
119
+ </div>
120
+ `;
@@ -10,9 +10,20 @@ const ToastNotification = styled(MaterialDesignContent)`
10
10
  height: 46px;
11
11
  box-shadow: none;
12
12
  padding: 0 20px;
13
+
14
+ .toast-message-wrapper {
15
+ width: 440px;
16
+ text-overflow: ellipsis;
17
+ overflow: hidden;
18
+ white-space: nowrap;
19
+ }
13
20
 
14
21
  @media (max-width: ${ScreenSize.md}px) {
15
22
  width: 343px;
23
+
24
+ .toast-message-wrapper {
25
+ width: 190px;
26
+ }
16
27
  }
17
28
 
18
29
  #notistack-snackbar svg {
@@ -41,8 +41,9 @@ const useToast = () => {
41
41
  return actionButtons?.length ? actionButtons : null;
42
42
  };
43
43
  const showToast = (variant: VariantType = 'default', message?: string, options?: ToastOptions) => {
44
+
44
45
  try {
45
- return enqueueSnackbar(message, {
46
+ return enqueueSnackbar(<div className='toast-message-wrapper'>{message}</div>, {
46
47
  variant,
47
48
  ...options,
48
49
  anchorOrigin: { horizontal: 'center', vertical: 'bottom' },
@@ -1,9 +1,14 @@
1
- import React from 'react';
2
1
  import { render } from '@testing-library/react';
2
+ import React from 'react';
3
3
 
4
4
  import NsTypography from './NsTypography';
5
5
 
6
6
  describe('GlobalFontInter', () => {
7
+ it('0. should match snapshot', () => {
8
+ const text = 'Hello Typo!';
9
+ const { container } = render(<NsTypography variant={'h1'}>{text}</NsTypography>);
10
+ expect(container).toMatchSnapshot();
11
+ });
7
12
  it('1. renders without crashing', () => {
8
13
  const text = 'Hello Typo!';
9
14
  const { getByText } = render(<NsTypography variant={'h1'}>{text}</NsTypography>);
@@ -13,14 +18,7 @@ describe('GlobalFontInter', () => {
13
18
  it('2. renders without crashing with p-l variant', () => {
14
19
  const text = 'Hello Typo!';
15
20
  const { getByText } = render(
16
- <NsTypography
17
- variant="h4"
18
- weight="bold"
19
- className="mt-2"
20
- decoration="underline"
21
-
22
- color="primary"
23
- >
21
+ <NsTypography variant="h4" weight="bold" className="mt-2" decoration="underline" color="primary">
24
22
  {text}
25
23
  </NsTypography>
26
24
  );
@@ -30,13 +28,7 @@ describe('GlobalFontInter', () => {
30
28
  it('3. should not render with default color primary when color is passed', () => {
31
29
  const text = 'Hello Typo!';
32
30
  const { getByText } = render(
33
- <NsTypography
34
- variant="h4"
35
- weight="bold"
36
- className="mt-2"
37
- decoration="underline"
38
- color="accentColorA"
39
- >
31
+ <NsTypography variant="h4" weight="bold" className="mt-2" decoration="underline" color="accentColorA">
40
32
  {text}
41
33
  </NsTypography>
42
34
  );
@@ -13,7 +13,7 @@ type TypographyConfig = {
13
13
  fontWeight?: number;
14
14
  };
15
15
 
16
- const defaultFont = 'Roboto';
16
+ const defaultFont = 'Inter';
17
17
  const defaultTypographyStyles = {
18
18
  h1: {
19
19
  fontFamily: defaultFont,
@@ -0,0 +1,22 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`GlobalFontInter 0. should match snapshot 1`] = `
4
+ .emotion-0 {
5
+ font-family: Inter;
6
+ font-size: 42px;
7
+ line-height: 48px;
8
+ margin: 0;
9
+ font-weight: 400;
10
+ letter-spacing: 0;
11
+ text-decoration-line: none;
12
+ }
13
+
14
+ <div>
15
+ <div
16
+ class=" emotion-0"
17
+ color="primary"
18
+ >
19
+ Hello Typo!
20
+ </div>
21
+ </div>
22
+ `;