@nuskin/foundation-ui-components 1.0.0-develop.1 → 1.0.0-develop.3
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 +1 -1
- package/src/common/alert/NsAlert.spec.tsx +17 -16
- package/src/common/alert/NsAlert.stories.tsx +15 -14
- package/src/common/alert/NsAlert.styled.ts +20 -20
- package/src/common/alert/NsAlert.tsx +21 -40
- package/src/common/alert/index.ts +2 -2
- package/src/common/auth-dropdown/NsAuthDropdown.spec.tsx +1 -1
- package/src/common/auth-dropdown/NsAuthDropdown.stories.tsx +1 -1
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +1 -1
- package/src/common/auth-dropdown/index.ts +1 -1
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +5 -5
- package/src/common/autocomplete/NsAutocomplete.stories.tsx +2 -2
- package/src/common/autocomplete/NsAutocomplete.tsx +1 -1
- package/src/common/autocomplete/index.ts +2 -1
- package/src/common/banner/NsBanner.spec.tsx +1 -1
- package/src/common/banner/NsBanner.stories.tsx +1 -1
- package/src/common/banner/NsBanner.styled.tsx +1 -1
- package/src/common/banner/NsBanner.tsx +1 -1
- package/src/common/banner/index.ts +1 -1
- package/src/common/brand-components/NsBrand.stories.tsx +1 -1
- package/src/common/brand-components/NsBrandComponent.tsx +1 -1
- package/src/common/brand-components/index.ts +1 -1
- package/src/common/breadcrumb/NsBreadcrumb.spec.tsx +1 -7
- package/src/common/breadcrumb/NsBreadcrumb.stories.tsx +2 -4
- package/src/common/breadcrumb/NsBreadcrumb.tsx +1 -1
- package/src/common/breadcrumb/data.ts +7 -0
- package/src/common/breadcrumb/index.ts +1 -1
- package/src/common/button/NsButton.spec.tsx +1 -1
- package/src/common/button/NsButton.stories.tsx +1 -1
- package/src/common/button/NsButton.styled.tsx +10 -13
- package/src/common/button/NsButton.tsx +1 -1
- package/src/common/button/index.ts +1 -1
- package/src/common/card/NsFfgCard.tsx +1 -1
- package/src/common/card/stories/NsBgCard.stories.tsx +1 -3
- package/src/common/card/stories/NsBrandProductCard.stories.tsx +1 -1
- package/src/common/card/stories/NsFfgCard.stories.tsx +1 -1
- package/src/common/card/stories/{data.js → data.ts} +1 -25
- package/src/common/carousal/NsScrollingCarousal.tsx +61 -0
- package/src/common/carousal/index.ts +3 -0
- package/src/common/carousal/stories/NSCarousal.stories.tsx +1 -1
- package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +52 -0
- package/src/common/carousal/tests/NsCarousal.spec.tsx +2 -2
- package/src/common/carousal/tests/NsScrollingCarousal.spec.tsx +61 -0
- package/src/common/carousal/types.d.ts +23 -0
- package/src/common/cart-icon/NsCartIcon.spec.tsx +1 -1
- package/src/common/cart-icon/NsCartIcon.stories.tsx +1 -1
- package/src/common/cart-icon/NsCartIcon.tsx +1 -1
- package/src/common/cart-icon/index.ts +1 -1
- package/src/common/checkbox/NsCheckbox.spec.tsx +2 -2
- package/src/common/checkbox/NsCheckbox.stories.tsx +1 -1
- package/src/common/checkbox/NsCheckbox.tsx +1 -1
- package/src/common/checkbox/index.ts +1 -1
- package/src/common/checkbox/types.d.ts +1 -7
- package/src/common/column-control/NsColumnControl.tsx +1 -1
- package/src/common/column-control/NsFlexColumns.tsx +22 -0
- package/src/common/column-control/NsGridColumns.tsx +22 -0
- package/src/common/column-control/index.ts +3 -1
- package/src/common/column-control/{NsColumnControl.spec.tsx → specs/NsColumnControl.spec.tsx} +3 -3
- package/src/common/column-control/specs/NsFlexColumns.spec.tsx +24 -0
- package/src/common/column-control/specs/NsGridColumns.spec.tsx +24 -0
- package/src/common/column-control/stories/DivArray.stories.tsx +18 -0
- package/src/common/column-control/stories/DivArray.tsx +63 -0
- package/src/common/column-control/{NsColumnControl.stories.tsx → stories/NsColumnControl.stories.tsx} +9 -16
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +63 -0
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +63 -0
- package/src/common/column-control/stories/common.tsx +14 -0
- package/src/common/column-control/styled/StyledFlex.tsx +45 -0
- package/src/common/column-control/styled/StyledGrid.tsx +40 -0
- package/src/common/column-control/styled/common.ts +27 -0
- package/src/common/column-control/types.d.ts +15 -16
- package/src/common/column-control/utils.ts +1 -1
- package/src/common/dropdown/NsDropdown.spec.tsx +1 -1
- package/src/common/dropdown/NsDropdown.tsx +1 -1
- package/src/common/dropdown/NsDropdownOption.tsx +1 -1
- package/src/common/dropdown/index.ts +1 -1
- package/src/common/dropdown/stories/NsDropdown.stories.tsx +1 -1
- package/src/common/dropdown/stories/NsDropdownCountry.stories.tsx +1 -1
- package/src/common/flag/NsFlag.spec.tsx +1 -1
- package/src/common/flag/NsFlag.stories.tsx +1 -1
- package/src/common/flag/NsFlag.styled.tsx +3 -5
- package/src/common/flag/NsFlag.tsx +1 -1
- package/src/common/flag/index.ts +1 -1
- package/src/common/flag/types.d.ts +0 -2
- package/src/common/icon/NsIcon.spec.tsx +1 -1
- package/src/common/icon/NsIcon.stories.tsx +1 -1
- package/src/common/icon/NsIcon.styled.tsx +1 -1
- package/src/common/icon/NsIcon.tsx +1 -1
- package/src/common/icon/NsIconVariants.ts +8 -4
- package/src/common/icon/icons/AlertErrorIcon.tsx +15 -6
- package/src/common/icon/icons/HamburgerIcon.tsx +29 -0
- package/src/common/icon/icons/UserIcon.tsx +30 -0
- package/src/common/icon/icons/WarningIcon.tsx +14 -5
- package/src/common/icon/index.ts +1 -1
- package/src/common/image/NsImage.spec.tsx +1 -1
- package/src/common/image/NsImage.stories.tsx +1 -1
- package/src/common/image/NsImage.tsx +1 -1
- package/src/common/image/NsNextImage.spec.tsx +1 -1
- package/src/common/image/NsNextImage.stories.tsx +1 -1
- package/src/common/image/NsNextImage.tsx +1 -1
- package/src/common/image/index.ts +1 -1
- package/src/common/index.ts +7 -10
- package/src/common/input/InputWrapper.tsx +1 -1
- package/src/common/input/NsInputField.stories.tsx +2 -1
- package/src/common/input/NsInputField.tsx +1 -1
- package/src/common/input/getAdornmentProps.tsx +1 -1
- package/src/common/input/index.ts +1 -1
- package/src/common/input/types.d.ts +15 -0
- package/src/common/label/NsLabel.stories.tsx +2 -0
- package/src/common/label/NsLabel.tsx +4 -4
- package/src/common/label/index.ts +1 -1
- package/src/common/link/NsLink.spec.tsx +1 -1
- package/src/common/link/NsLink.stories.tsx +1 -1
- package/src/common/link/NsLink.tsx +1 -1
- package/src/common/link/index.ts +1 -1
- package/src/common/nav-product-card/NsNavProductCard.spec.tsx +1 -1
- package/src/common/nav-product-card/NsNavProductCard.stories.tsx +1 -1
- package/src/common/nav-product-card/NsNavProductCard.tsx +1 -1
- package/src/common/nav-product-card/index.ts +1 -1
- package/src/common/nav-tab/NsNavTab.spec.tsx +2 -2
- package/src/common/nav-tab/NsNavTab.stories.tsx +1 -1
- package/src/common/nav-tab/NsNavTab.tsx +1 -1
- package/src/common/nav-tab/index.ts +1 -1
- package/src/common/search-bar/NsSeachBar.spec.tsx +1 -1
- package/src/common/table/NsTable.spec.tsx +146 -0
- package/src/common/table/NsTable.stories.tsx +123 -0
- package/src/common/table/NsTable.styled.ts +33 -0
- package/src/common/table/NsTable.tsx +161 -0
- package/src/common/table/NsTableHeader.tsx +48 -0
- package/src/common/table/NsTablePagination.tsx +20 -0
- package/src/common/table/helper.ts +33 -0
- package/src/common/table/index.ts +2 -0
- package/src/common/table/types.d.ts +44 -0
- package/src/common/text-strip/NsTextStrip.spec.tsx +30 -0
- package/src/common/text-strip/NsTextStrip.stories.tsx +33 -0
- package/src/common/text-strip/NsTextStrip.tsx +44 -0
- package/src/common/text-strip/index.ts +2 -0
- package/src/common/text-strip/types.d.ts +17 -0
- package/src/common/typography/NsTypography.stories.tsx +1 -1
- package/src/common/typography/NsTypography.tsx +1 -1
- package/src/common/typography/Typography.styled.tsx +1 -1
- package/src/common/typography/index.ts +1 -1
- package/src/common/videos/NsVideo.stories.tsx +1 -1
- package/src/common/videos/NsVideo.tsx +1 -1
- package/src/common/videos/index.ts +1 -1
- package/src/common/column-control/NDivs.story.tsx +0 -35
- /package/src/common/autocomplete/{types.ts → types.d.ts} +0 -0
- /package/src/common/{common.types.ts → common.types.d.ts} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param props {fill: color to be filled for icon, color: color of the tick icon}
|
|
6
|
+
*/
|
|
7
|
+
const HamburgerIcon = (props: SvgIconProps) => {
|
|
8
|
+
return (
|
|
9
|
+
<SvgIcon viewBox="0 0 24 24" {...props} data-testid="hamburgerIcon" xmlns="http://www.w3.org/2000/svg">
|
|
10
|
+
<path
|
|
11
|
+
fillRule="evenodd"
|
|
12
|
+
clipRule="evenodd"
|
|
13
|
+
d="M0 1C0 0.447715 0.447715 0 1 0H19C19.5523 0 20 0.447715 20 1C20 1.55228 19.5523 2 19 2H1C0.447715 2 0 1.55228 0 1Z"
|
|
14
|
+
/>
|
|
15
|
+
<path
|
|
16
|
+
fillRule="evenodd"
|
|
17
|
+
clipRule="evenodd"
|
|
18
|
+
d="M0 9C0 8.44772 0.447715 8 1 8H19C19.5523 8 20 8.44772 20 9C20 9.55228 19.5523 10 19 10H1C0.447715 10 0 9.55228 0 9Z"
|
|
19
|
+
/>
|
|
20
|
+
<path
|
|
21
|
+
fillRule="evenodd"
|
|
22
|
+
clipRule="evenodd"
|
|
23
|
+
d="M0 17C0 16.4477 0.447715 16 1 16H19C19.5523 16 20 16.4477 20 17C20 17.5523 19.5523 18 19 18H1C0.447715 18 0 17.5523 0 17Z"
|
|
24
|
+
/>
|
|
25
|
+
</SvgIcon>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default HamburgerIcon;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
import { useTheme } from '@mui/material/styles';
|
|
3
|
+
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param props {fill: color to be filled for icon, color: color of the tick icon}
|
|
7
|
+
*/
|
|
8
|
+
const UserIcon = (props: SvgIconProps) => {
|
|
9
|
+
const { palette } = useTheme();
|
|
10
|
+
const strokeColor = palette.primary.main;
|
|
11
|
+
return (
|
|
12
|
+
<SvgIcon viewBox="0 0 24 24" {...props} data-testid="userIcon" xmlns="http://www.w3.org/2000/svg">
|
|
13
|
+
<path
|
|
14
|
+
fillRule="evenodd"
|
|
15
|
+
clipRule="evenodd"
|
|
16
|
+
d="M12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23Z"
|
|
17
|
+
stroke={strokeColor}
|
|
18
|
+
strokeWidth="2"
|
|
19
|
+
/>
|
|
20
|
+
<path
|
|
21
|
+
d="M19 20C18.9425 19.3229 19 17.5669 17.3793 17.2226C14.7126 16.6144 13.931 16.4078 14.1034 14.2272C15.8046 13.0796 15.7816 11.0252 15.7471 8.74139C15.7471 6.67508 14.0695 5 12 5C9.93052 5 8.25287 6.67508 8.25287 8.74139C8.25287 11.0367 8.25287 13.137 9.89655 14.2272C10.0575 16.4078 9.28736 16.6144 6.62069 17.2226C5 17.5669 5.05747 19.3229 5 20"
|
|
22
|
+
stroke={strokeColor}
|
|
23
|
+
strokeWidth="2"
|
|
24
|
+
strokeLinecap="round"
|
|
25
|
+
/>
|
|
26
|
+
</SvgIcon>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default UserIcon;
|
|
@@ -18,15 +18,24 @@ const WarningIcon = (props: SvgIconProps) => {
|
|
|
18
18
|
>
|
|
19
19
|
<g id="💎-icon/alert/WarningFill-yellow" transform="translate(1.000000, 1.000000)">
|
|
20
20
|
<g id="Warning2" transform="translate(0.000000, 1.200000)">
|
|
21
|
-
<path
|
|
21
|
+
<path
|
|
22
|
+
d="M17.9465423,14.8670135 L9.44311247,0.246687943 C9.35049358,0.100809118 9.18936767,0.012383152 9.01617259,0.012383152 C8.84297751,0.012383152 8.68185161,
|
|
22
23
|
0.100809118 8.58923271,0.246687943 L0.0706452929,14.8670135 C-0.0142965839,15.0216954 -0.0118890438,15.2093943 0.0769925071,15.3618609 C0.165874058,
|
|
23
24
|
15.5143276 0.328282319,15.6093523 0.505163987,15.6123832 L17.5120236,15.6123832 C17.6889052,15.6093523 17.8513135,15.5143276 17.940195,15.3618609 C18.0290766,
|
|
24
|
-
15.2093943 18.0314841,15.0216954 17.9465423,14.8670135 Z"
|
|
25
|
-
|
|
25
|
+
15.2093943 18.0314841,15.0216954 17.9465423,14.8670135 Z"
|
|
26
|
+
id="Shape"
|
|
27
|
+
fill="#FEBD00"
|
|
28
|
+
fillRule="nonzero"
|
|
29
|
+
></path>
|
|
30
|
+
<path
|
|
31
|
+
d="M8.19,12.84 C8.16437588,12.6281014 8.2368299,12.4160897 8.38677958,12.2641927 C8.53672927,12.1122956 8.74778837,12.0371121 8.96,12.06 C9.16715704,
|
|
26
32
|
12.0467652 9.37034806,12.1211477 9.52,12.265 C9.65709398,12.4241339 9.72701115,12.6303 9.715,12.84 C9.72048715,13.0522748 9.64341383,13.2584012 9.5,
|
|
27
33
|
13.415 C9.35312473,13.5641498 9.1489517,13.6425377 8.94,13.63 C8.72997224,13.6424095 8.52401376,13.5683367 8.37,13.425 C8.23531653,13.2613056 8.17063593,
|
|
28
|
-
13.0510936 8.19,12.84 Z M9.415,11.195 L8.5,11.195 L8.25,5.96 L9.675,5.96 L9.415,11.195 Z"
|
|
29
|
-
|
|
34
|
+
13.0510936 8.19,12.84 Z M9.415,11.195 L8.5,11.195 L8.25,5.96 L9.675,5.96 L9.415,11.195 Z"
|
|
35
|
+
id="Shape"
|
|
36
|
+
fill="#FFFFFF"
|
|
37
|
+
fillRule="nonzero"
|
|
38
|
+
></path>
|
|
30
39
|
</g>
|
|
31
40
|
</g>
|
|
32
41
|
</SvgIcon>
|
package/src/common/icon/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
-
import { withCenterDecorator } from '
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
3
|
import { NsImage } from './';
|
|
4
4
|
|
|
5
5
|
type ComponentType = typeof NsImage;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NsNextImage } from '.';
|
|
2
|
-
import { withCenterDecorator } from '
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
3
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
4
4
|
|
|
5
5
|
type ComponentType = typeof NsNextImage;
|
package/src/common/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export * from './alert';
|
|
1
2
|
export * from './auth-dropdown';
|
|
3
|
+
export * from './autocomplete';
|
|
2
4
|
export * from './banner';
|
|
3
5
|
export * from './breadcrumb';
|
|
4
6
|
export * from './brand-components';
|
|
@@ -8,21 +10,16 @@ export * from './carousal';
|
|
|
8
10
|
export * from './cart-icon';
|
|
9
11
|
export * from './column-control';
|
|
10
12
|
export * from './checkbox';
|
|
13
|
+
export * from './common.types.d';
|
|
11
14
|
export * from './dropdown';
|
|
12
15
|
export * from './flag';
|
|
13
16
|
export * from './icon';
|
|
14
|
-
export * from './input';
|
|
15
17
|
export * from './image';
|
|
16
|
-
export * from './
|
|
18
|
+
export * from './input';
|
|
17
19
|
export * from './label';
|
|
18
|
-
export * from './
|
|
19
|
-
|
|
20
|
-
/* Dropdown Components */
|
|
21
|
-
export * from './dropdown';
|
|
22
|
-
export * from './auth-dropdown';
|
|
23
|
-
export * from './alert';
|
|
20
|
+
export * from './link';
|
|
24
21
|
export * from './nav-tab';
|
|
25
22
|
export * from './nav-product-card';
|
|
23
|
+
export * from './text-strip';
|
|
24
|
+
export * from './table';
|
|
26
25
|
export * from './typography';
|
|
27
|
-
|
|
28
|
-
export * from './common.types';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { NsInputField } from '.';
|
|
3
3
|
import { NsIcon } from '../icon';
|
|
4
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
5
|
|
|
5
6
|
type ComponentType = typeof NsInputField;
|
|
6
7
|
type Story = StoryObj<ComponentType>;
|
|
@@ -9,7 +10,7 @@ type MetaStory = Meta<ComponentType>;
|
|
|
9
10
|
export default {
|
|
10
11
|
title: 'Components/NsInputField',
|
|
11
12
|
component: NsInputField,
|
|
12
|
-
decorators: [
|
|
13
|
+
decorators: [withCenterDecorator],
|
|
13
14
|
|
|
14
15
|
args: {},
|
|
15
16
|
argTypes: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TextField, FormHelperText } from '@mui/material';
|
|
2
2
|
import InputWrapper from './InputWrapper';
|
|
3
|
-
import { NsInputFieldProps } from './types';
|
|
3
|
+
import { NsInputFieldProps } from './types.d';
|
|
4
4
|
import { NsLabel } from '../label';
|
|
5
5
|
import InputFieldWrapper from './InputFieldWrapper';
|
|
6
6
|
import { getAdornmentProps } from './getAdornmentProps';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsInputField } from './NsInputField';
|
|
2
|
-
export type { NsInputFieldProps } from './types';
|
|
2
|
+
export type { NsInputFieldProps } from './types.d';
|
|
@@ -17,11 +17,26 @@ export type NsInputFieldProps = Omit<
|
|
|
17
17
|
| 'select'
|
|
18
18
|
| 'SelectProps'
|
|
19
19
|
> & {
|
|
20
|
+
/**
|
|
21
|
+
* has default undefined value, and we can update the value to success
|
|
22
|
+
* on successful validation and update value to 'error' in case of error
|
|
23
|
+
*/
|
|
24
|
+
|
|
20
25
|
fieldState?: fieldStateType;
|
|
21
26
|
iconStart?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* assign react component for end icon
|
|
29
|
+
*/
|
|
22
30
|
iconEnd?: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* assign react component for side icon
|
|
33
|
+
*/
|
|
34
|
+
|
|
23
35
|
iconSide?: ReactNode;
|
|
24
36
|
/** purpose of showOptional props is to show additional text 'optional' in the label,
|
|
25
37
|
* if required = false and this flag is true */
|
|
26
38
|
showOptional?: boolean;
|
|
39
|
+
defaultValue?: string;
|
|
40
|
+
rows?: number;
|
|
41
|
+
id?: string;
|
|
27
42
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { NsLabel } from '.';
|
|
3
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
4
|
|
|
4
5
|
type ComponentType = typeof NsLabel;
|
|
5
6
|
type Story = StoryObj<ComponentType>;
|
|
@@ -8,6 +9,7 @@ type MetaStory = Meta<ComponentType>;
|
|
|
8
9
|
export default {
|
|
9
10
|
component: NsLabel,
|
|
10
11
|
title: 'Components/NsLabel',
|
|
12
|
+
decorators: [withCenterDecorator],
|
|
11
13
|
} as MetaStory;
|
|
12
14
|
|
|
13
15
|
export const Default: Story = {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NsLabelProps } from './types';
|
|
1
|
+
import { FormLabel } from '@mui/material';
|
|
2
|
+
import { NsLabelProps } from './types.d';
|
|
3
3
|
import { styled, nuskinTheme } from '@nuskin/foundation-theme';
|
|
4
4
|
|
|
5
5
|
const { colors } = nuskinTheme;
|
|
6
6
|
|
|
7
|
-
const StyledLabel = styled(
|
|
7
|
+
const StyledLabel = styled(FormLabel)<{ fontSize?: number }>(({ theme, fontSize }) => {
|
|
8
8
|
const isLight = theme.palette?.primary?.main === '#252525';
|
|
9
9
|
return {
|
|
10
|
-
fontSize: '14px',
|
|
10
|
+
fontSize: fontSize ? `${fontSize}px` : '14px',
|
|
11
11
|
color: theme.palette?.primary?.main ?? '#252525',
|
|
12
12
|
'.optional-label': {
|
|
13
13
|
color: isLight ? colors?.neutral?.[60] : colors?.neutral?.[50],
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsLabel } from './NsLabel';
|
|
2
|
-
export type { NsLabelProps } from './types';
|
|
2
|
+
export type { NsLabelProps } from './types.d';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
9
|
-
import { withCenterDecorator } from '
|
|
9
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
10
10
|
|
|
11
11
|
import { NsLink } from './';
|
|
12
12
|
import { NsTypography } from '../typography';
|
package/src/common/link/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as NsLink } from './NsLink';
|
|
2
|
-
export type { NsLinkProps } from './types';
|
|
2
|
+
export type { NsLinkProps } from './types.d';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
-
import { withCenterDecorator } from '
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
3
|
import { NsNavProductCard } from './';
|
|
4
4
|
|
|
5
5
|
type ComponentType = typeof NsNavProductCard;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React, { PropsWithChildren } from 'react';
|
|
3
3
|
import { NsImage, NsTypography } from '../';
|
|
4
4
|
import { ProductCardContainer } from './NsNavProductCard.styled';
|
|
5
|
-
import { NsNavProductCardProps } from './types';
|
|
5
|
+
import { NsNavProductCardProps } from './types.d';
|
|
6
6
|
|
|
7
7
|
/* TODO: can we update NsImage with NsNextImage, once storybook 7 is in place */
|
|
8
8
|
export const NsNavProductCard = ({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NsNavProductCard as NsNavProductCard } from './NsNavProductCard';
|
|
2
|
-
export type { NsNavProductCardProps } from './types';
|
|
2
|
+
export type { NsNavProductCardProps } from './types.d';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { fireEvent } from '@testing-library/react';
|
|
2
2
|
import nuskinTheme from '@nuskin/foundation-theme/src/themes/genome-foundation';
|
|
3
3
|
import { NsNavTabComponent } from './NsNavTab';
|
|
4
|
-
import { NavTabs } from './types';
|
|
5
|
-
import { render } from '
|
|
4
|
+
import { NavTabs } from './types.d';
|
|
5
|
+
import { render } from '@/test-utils/index';
|
|
6
6
|
|
|
7
7
|
const { palette } = nuskinTheme;
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
-
import { withCenterDecorator } from '
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
3
|
import { NsNavTab } from './';
|
|
4
4
|
|
|
5
5
|
type ComponentType = typeof NsNavTab;
|
|
@@ -2,7 +2,7 @@ import React, { PropsWithChildren, useState } from 'react';
|
|
|
2
2
|
import { LayoutGroup } from 'framer-motion';
|
|
3
3
|
import { NsTypography } from '../typography';
|
|
4
4
|
import { NavDrawerContainer, NavTabContainer, NavTabLine, NavTabUnderLine, NavDrawer } from './NsNavTab.styled';
|
|
5
|
-
import { NSNavTabComponentProps } from './types';
|
|
5
|
+
import { NSNavTabComponentProps } from './types.d';
|
|
6
6
|
|
|
7
7
|
export const NsNavTabComponent = (props: PropsWithChildren<NSNavTabComponentProps>) => {
|
|
8
8
|
const { tabs, className, tabTitleClassName, showDrawer = true } = props;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NsNavTabComponent as NsNavTab } from './NsNavTab';
|
|
2
|
-
export type { NSNavTabComponentProps, NavTabs } from './types';
|
|
2
|
+
export type { NSNavTabComponentProps, NavTabs } from './types.d';
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent, screen } from '@/test-utils/index';
|
|
3
|
+
import NsTable from './NsTable';
|
|
4
|
+
|
|
5
|
+
describe('NsTable', () => {
|
|
6
|
+
const headers = [
|
|
7
|
+
{ id: 'name', label: 'Name', numeric: false },
|
|
8
|
+
{ id: 'age', label: 'Age', numeric: true },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
const items = [
|
|
12
|
+
{ name: 'John', age: 26 },
|
|
13
|
+
{ name: 'Jane', age: 32 },
|
|
14
|
+
{ name: 'Maria', age: 28 },
|
|
15
|
+
{ name: 'Kevin', age: 31 },
|
|
16
|
+
{ name: 'Suzan', age: 25 },
|
|
17
|
+
{ name: 'Dan', age: 30 },
|
|
18
|
+
{ name: 'Micheal', age: 39 },
|
|
19
|
+
{ name: 'Sandy', age: 39 },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const rows = 5;
|
|
23
|
+
const isShowSelector = true;
|
|
24
|
+
const rowsPerPageOptions = [5, 10, 15];
|
|
25
|
+
const itemKey = 'name';
|
|
26
|
+
|
|
27
|
+
it('renders table with correct data', () => {
|
|
28
|
+
render(
|
|
29
|
+
<NsTable
|
|
30
|
+
headers={headers}
|
|
31
|
+
items={items}
|
|
32
|
+
rows={rows}
|
|
33
|
+
isShowSelector={isShowSelector}
|
|
34
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
35
|
+
itemKey={itemKey}
|
|
36
|
+
isPagination
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(screen.getByText('Name')).toBeInTheDocument();
|
|
41
|
+
expect(screen.getByText('Age')).toBeInTheDocument();
|
|
42
|
+
expect(screen.getByText('Kevin')).toBeInTheDocument();
|
|
43
|
+
expect(screen.getByText('Maria')).toBeInTheDocument();
|
|
44
|
+
expect(screen.getByText('28')).toBeInTheDocument();
|
|
45
|
+
expect(screen.getByText('31')).toBeInTheDocument();
|
|
46
|
+
expect(screen.getByRole('button', { name: 'Rows per page: 5' })).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('selects and deselects rows on click', () => {
|
|
50
|
+
render(
|
|
51
|
+
<NsTable
|
|
52
|
+
headers={headers}
|
|
53
|
+
items={items}
|
|
54
|
+
rows={rows}
|
|
55
|
+
isShowSelector={isShowSelector}
|
|
56
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
57
|
+
itemKey={itemKey}
|
|
58
|
+
isPagination
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
expect(screen.getByText('Kevin')).toBeInTheDocument();
|
|
63
|
+
const button = screen.getByText('Kevin');
|
|
64
|
+
fireEvent.click(button);
|
|
65
|
+
|
|
66
|
+
expect(screen.getByTestId('table-row-3')).toHaveAttribute('aria-checked', 'true');
|
|
67
|
+
fireEvent.click(button);
|
|
68
|
+
expect(screen.getByTestId('table-row-3')).toHaveAttribute('aria-checked', 'false');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('hide selectors', () => {
|
|
72
|
+
render(
|
|
73
|
+
<NsTable
|
|
74
|
+
headers={headers}
|
|
75
|
+
items={items}
|
|
76
|
+
rows={rows}
|
|
77
|
+
isShowSelector={!isShowSelector}
|
|
78
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
79
|
+
itemKey={itemKey}
|
|
80
|
+
isPagination
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('selects all rows', () => {
|
|
86
|
+
render(
|
|
87
|
+
<NsTable
|
|
88
|
+
headers={headers}
|
|
89
|
+
items={items}
|
|
90
|
+
rows={rows}
|
|
91
|
+
isShowSelector={isShowSelector}
|
|
92
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
93
|
+
itemKey={itemKey}
|
|
94
|
+
isPagination
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect(screen.getByTestId('header-checkbox')).toBeInTheDocument();
|
|
99
|
+
|
|
100
|
+
const button = screen.getByTestId('header-checkbox');
|
|
101
|
+
|
|
102
|
+
fireEvent.click(button);
|
|
103
|
+
expect(screen.getByTestId('table-checkbox-0')).toHaveClass('PrivateSwitchBase-input');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('selects all rows when click all values', async () => {
|
|
107
|
+
render(
|
|
108
|
+
<NsTable
|
|
109
|
+
headers={headers}
|
|
110
|
+
items={items}
|
|
111
|
+
rows={rows}
|
|
112
|
+
isShowSelector={isShowSelector}
|
|
113
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
114
|
+
itemKey={itemKey}
|
|
115
|
+
isPagination
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(screen.getByTestId('KeyboardArrowRightIcon')).toBeInTheDocument();
|
|
120
|
+
|
|
121
|
+
const button = screen.getByTestId('KeyboardArrowRightIcon');
|
|
122
|
+
fireEvent.click(button);
|
|
123
|
+
expect(screen.getByText('Sandy')).toBeInTheDocument();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('sort rows via age', () => {
|
|
127
|
+
render(
|
|
128
|
+
<NsTable
|
|
129
|
+
headers={headers}
|
|
130
|
+
items={items}
|
|
131
|
+
rows={rows}
|
|
132
|
+
isShowSelector={isShowSelector}
|
|
133
|
+
rowsPerPageOptions={rowsPerPageOptions}
|
|
134
|
+
itemKey={itemKey}
|
|
135
|
+
isPagination
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
expect(screen.getByText('Age')).toBeInTheDocument();
|
|
140
|
+
const button = screen.getByText('Age');
|
|
141
|
+
fireEvent.click(button);
|
|
142
|
+
|
|
143
|
+
expect(screen.getByText('John')).toBeInTheDocument();
|
|
144
|
+
fireEvent.click(button);
|
|
145
|
+
});
|
|
146
|
+
});
|