@nuskin/foundation-ui-components 1.29.1 → 1.30.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 +1 -7
- package/src/common/accordion/NsAccordion.tsx +2 -2
- package/src/common/accordion/NsAccordionHeader.tsx +2 -9
- package/src/common/accordion/NsAccordionItem.tsx +4 -3
- package/src/common/accordion/NsCollapse.tsx +1 -1
- package/src/common/accordion/NsToggleSection.tsx +10 -3
- package/src/common/accordion/stories/NsAccordionItem.stories.tsx +5 -3
- package/src/common/accordion/stories/NsCollapse.stories.tsx +5 -3
- package/src/common/alert/NsAlert.stories.tsx +6 -4
- package/src/common/alert/NsAlert.tsx +27 -13
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +7 -7
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +3 -3
- package/src/common/autocomplete/NsAutocomplete.tsx +2 -1
- package/src/common/autocomplete/helper/SeeMoreButton.tsx +2 -2
- package/src/common/autocomplete/helper/renderGroupName.tsx +4 -3
- package/src/common/autocomplete/stories/NsAutocomplete.stories.tsx +9 -9
- package/src/common/banner/NsBanner.spec.tsx +5 -5
- package/src/common/banner/NsBanner.stories.tsx +8 -5
- package/src/common/banner/NsBanner.tsx +10 -20
- package/src/common/banner/types.d.ts +2 -2
- package/src/common/brand-components/NsBrandComponent.tsx +6 -3
- package/src/common/brand-components/icons/NSLogoHorizontal.tsx +7 -2
- package/src/common/brand-components/icons/NSLogoMark.tsx +3 -1
- package/src/common/brand-components/icons/NSLogoPoweredBy.tsx +4 -2
- package/src/common/brand-components/icons/NSLogoStacked.tsx +4 -2
- package/src/common/brand-components/icons/NSWordMark.tsx +4 -2
- package/src/common/breadcrumb/NsBreadcrumb.tsx +20 -5
- package/src/common/button/NsButton.stories.tsx +14 -8
- package/src/common/button/NsButton.tsx +7 -4
- package/src/common/card/CardButton.tsx +4 -3
- package/src/common/card/NsAwardCard.tsx +9 -8
- package/src/common/card/NsBgCard.tsx +1 -0
- package/src/common/card/NsBrandCard.tsx +8 -5
- package/src/common/card/NsBrandWrapper.tsx +3 -2
- package/src/common/card/NsCheckoutCard.tsx +4 -2
- package/src/common/card/NsHeroCardLevel1.tsx +9 -9
- package/src/common/card/NsHeroCardLevel2.tsx +9 -9
- package/src/common/card/NsIconText.tsx +3 -2
- package/src/common/card/NsLargeCard.tsx +9 -9
- package/src/common/card/NsMediumCard.tsx +10 -9
- package/src/common/card/NsPost.tsx +7 -8
- package/src/common/card/NsSmallFullCard.tsx +9 -9
- package/src/common/card/NsXLargeCard.tsx +9 -9
- package/src/common/card/fixtures/ImageData1.ts +38 -0
- package/src/common/card/fixtures/ImageData2.ts +38 -0
- package/src/common/card/specs/NsAwardCard.spec.tsx +2 -2
- package/src/common/card/specs/NsHeroCardLevel1.spec.tsx +2 -3
- package/src/common/card/specs/NsHeroCardLevel2.spec.tsx +2 -2
- package/src/common/card/specs/NsLargeCard.spec.tsx +2 -3
- package/src/common/card/specs/NsMediumCard.spec.tsx +3 -3
- package/src/common/card/specs/NsPost.spec.tsx +3 -3
- package/src/common/card/specs/NsSmallFullCard.spec.tsx +3 -3
- package/src/common/card/specs/NsXLargeCard.spec.tsx +3 -3
- package/src/common/card/stories/NsAwardCard.stories.tsx +2 -4
- package/src/common/card/stories/NsHeroCardLevel1.stories.tsx +2 -4
- package/src/common/card/stories/NsHeroCardLevel2.stories.tsx +2 -4
- package/src/common/card/stories/NsLargeCard.stories.tsx +2 -4
- package/src/common/card/stories/NsMediumCard.stories.tsx +2 -4
- package/src/common/card/stories/NsPost.stories.tsx +2 -4
- package/src/common/card/stories/NsSmallFullCard.stories.tsx +2 -4
- package/src/common/card/stories/NsXLargeCard.stories.tsx +4 -5
- package/src/common/carousal/CarousalControl.tsx +5 -2
- package/src/common/carousal/IconWrapper.tsx +4 -3
- package/src/common/carousal/NsCarousal.tsx +8 -6
- package/src/common/carousal/NsScrollingCarousal.tsx +2 -2
- package/src/common/carousal/RenderBrand.tsx +3 -1
- package/src/common/carousal/specs/NsScrollingCarousal.spec.tsx +4 -2
- package/src/common/carousal/stories/{NSCarousal.stories.tsx → NsCarousal1.stories.tsx} +5 -2
- package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +4 -2
- package/src/common/cart-icon/NsCartIcon.tsx +9 -1
- package/src/common/checkbox/NsCheckbox.stories.tsx +5 -4
- package/src/common/checkbox/NsCheckbox.tsx +6 -6
- package/src/common/column-control/NsColumnControl.tsx +5 -3
- package/src/common/column-control/NsFlexColumns.tsx +10 -3
- package/src/common/column-control/NsGridColumns.tsx +10 -3
- package/src/common/column-control/stories/NsColumnControl.stories.tsx +8 -5
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +9 -6
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +19 -7
- package/src/common/column-control/styled/common.ts +1 -1
- package/src/common/dropdown/NsDropdown.tsx +6 -6
- package/src/common/dropdown/NsDropdownOption.tsx +4 -3
- package/src/common/dropdown/stories/NsDropdown.stories.tsx +5 -3
- package/src/common/email-simple/NsEmailSimple.tsx +4 -3
- package/src/common/flag/NsFlag.tsx +3 -2
- package/src/common/hooks/useAccordionMap.tsx +1 -1
- package/src/common/icon/NsIcon.tsx +2 -5
- package/src/common/icon/icons/AlertErrorIcon.tsx +3 -1
- package/src/common/icon/icons/ArrowDown.tsx +7 -2
- package/src/common/icon/icons/ArrowLeft.tsx +7 -2
- package/src/common/icon/icons/ArrowRight.tsx +7 -2
- package/src/common/icon/icons/ArrowUp.tsx +4 -2
- package/src/common/icon/icons/Cart.tsx +7 -2
- package/src/common/icon/icons/CartBadge.tsx +7 -2
- package/src/common/icon/icons/Check.tsx +7 -2
- package/src/common/icon/icons/CheckShield.tsx +4 -2
- package/src/common/icon/icons/CheckVerified.tsx +7 -2
- package/src/common/icon/icons/ChevronRight.tsx +9 -4
- package/src/common/icon/icons/CloseIcon.tsx +7 -2
- package/src/common/icon/icons/ErrorIcon.tsx +3 -1
- package/src/common/icon/icons/HamburgerIcon.tsx +4 -1
- package/src/common/icon/icons/InfoFilled.tsx +7 -2
- package/src/common/icon/icons/InfoOutlined.tsx +7 -2
- package/src/common/icon/icons/RoundedClose.tsx +7 -2
- package/src/common/icon/icons/SearchIcon.tsx +3 -1
- package/src/common/icon/icons/SlashIcon.tsx +7 -2
- package/src/common/icon/icons/SuccessIcon.tsx +3 -1
- package/src/common/icon/icons/TrashIcon.tsx +3 -1
- package/src/common/icon/icons/UserIcon.tsx +4 -1
- package/src/common/icon/icons/UserOutline.tsx +3 -1
- package/src/common/icon/icons/WarningIcon.tsx +3 -1
- package/src/common/icon/icons/home.tsx +4 -2
- package/src/common/image/BynderMedia.spec.tsx +42 -0
- package/src/common/image/BynderMedia.tsx +48 -0
- package/src/common/image/NsImage.tsx +3 -3
- package/src/common/image/NsNextImage.tsx +5 -2
- package/src/common/image/bynder-util.spec.ts +187 -0
- package/src/common/image/bynder-util.ts +98 -0
- package/src/common/image/index.ts +1 -1
- package/src/common/image/types.ts +78 -0
- package/src/common/input/InputWrapper.tsx +2 -1
- package/src/common/input/NsInputField.tsx +11 -3
- package/src/common/label/NsLabel.tsx +9 -4
- package/src/common/link/NsLink.stories.tsx +9 -5
- package/src/common/link/NsLink.tsx +9 -3
- package/src/common/modal/NsModal.tsx +2 -2
- package/src/common/modal/helper-component/NsModalContentBox.tsx +8 -3
- package/src/common/modal/helper-component/NsModalDefault.tsx +9 -2
- package/src/common/modal/helper-component/NsModalStatus.tsx +3 -1
- package/src/common/modal/helper-component/NsModalStatusIcon.tsx +2 -2
- package/src/common/modal/helper-component/NsModalTitle.tsx +6 -3
- package/src/common/modal/stories/NsModal.stories.tsx +9 -7
- package/src/common/nav-product-card/NsNavProductCard.spec.tsx +3 -5
- package/src/common/nav-product-card/NsNavProductCard.stories.tsx +4 -4
- package/src/common/nav-product-card/NsNavProductCard.tsx +6 -6
- package/src/common/nav-product-card/types.d.ts +2 -1
- package/src/common/nav-tab/NavDrawer.tsx +10 -3
- package/src/common/nav-tab/NavTitles.tsx +2 -2
- package/src/common/nav-tab/NsNavTab.tsx +10 -4
- package/src/common/progress/NsProgress.stories.tsx +6 -3
- package/src/common/progress/NsProgress.tsx +3 -3
- package/src/common/radiogroup/NsRadioGroup.tsx +4 -2
- package/src/common/search-bar/NsSearchBar.tsx +3 -2
- package/src/common/select/DefaultRenderOption.tsx +3 -1
- package/src/common/select/NsSelect.tsx +19 -6
- package/src/common/select/NsSelectOption.tsx +2 -2
- package/src/common/select/stories/NsSelect.stories.tsx +5 -4
- package/src/common/spinner/NsSpinner.stories.tsx +5 -2
- package/src/common/spinner/NsSpinner.tsx +3 -2
- package/src/common/spinner/icons/Spinner.tsx +3 -1
- package/src/common/table/NsExpandableRow.tsx +35 -41
- package/src/common/table/NsTable.stories.tsx +17 -23
- package/src/common/table/NsTable.tsx +27 -10
- package/src/common/table/NsTableHeader.tsx +18 -5
- package/src/common/table/NsTablePagination.tsx +7 -11
- package/src/common/text-strip/NsTextStrip.tsx +6 -3
- package/src/common/toast/Fade.tsx +5 -8
- package/src/common/toast/ToastProvider.tsx +18 -17
- package/src/common/toast/specs/Toast.spec.tsx +56 -64
- package/src/common/toast/stories/Toast.stories.tsx +12 -11
- package/src/common/typography/GlobalFontInter.tsx +7 -2
- package/src/common/typography/NsTypography.tsx +11 -4
- package/src/common/videos/NsVideo.tsx +5 -2
- package/src/common/image/types.d.ts +0 -30
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { DialogContent } from '@mui/material';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
4
|
|
|
4
5
|
import { Show } from '../../utility';
|
|
5
6
|
import { ModalFooter } from '../NsModal.styled';
|
|
6
7
|
import { NsModalComponentProps } from '../types';
|
|
7
8
|
import NsModalTitle from './NsModalTitle';
|
|
8
9
|
|
|
9
|
-
const NsDefaultModal = ({
|
|
10
|
+
const NsDefaultModal = ({
|
|
11
|
+
header,
|
|
12
|
+
handleClose,
|
|
13
|
+
body,
|
|
14
|
+
footer,
|
|
15
|
+
additionalProps,
|
|
16
|
+
}: NsModalComponentProps): ReactElement => {
|
|
10
17
|
const { dividers } = additionalProps || {};
|
|
11
18
|
|
|
12
19
|
return (
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { NsInfoWrapper } from '../NsModal.styled';
|
|
2
4
|
import { NsModalComponentProps } from '../types';
|
|
3
5
|
import NsModalContentBox from './NsModalContentBox';
|
|
4
6
|
import NsModalStatusIcon from './NsModalStatusIcon';
|
|
5
7
|
|
|
6
|
-
const NsStatusModal = ({ handleClose, statusInfo, variant }: NsModalComponentProps) => {
|
|
8
|
+
const NsStatusModal = ({ handleClose, statusInfo, variant }: NsModalComponentProps): ReactElement => {
|
|
7
9
|
return (
|
|
8
10
|
<NsInfoWrapper data-testid="modal-status">
|
|
9
11
|
<NsModalStatusIcon {...{ variant }} />
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import { NsIcon, NsIconNameType } from '../../';
|
|
4
4
|
import { StatusIconMap } from '../model/NsModalVariantMap';
|
|
5
5
|
import { NsModalComponentProps, NsModalVariant } from '../types';
|
|
6
6
|
|
|
7
|
-
const NsModalStatusIcon = ({ variant }: NsModalComponentProps):
|
|
7
|
+
const NsModalStatusIcon = ({ variant }: NsModalComponentProps): ReactElement => {
|
|
8
8
|
const iconName = variant ? StatusIconMap[variant] : null;
|
|
9
9
|
return (
|
|
10
10
|
<div className="status-icon">
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
2
3
|
import { DialogTitle } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
import { NsIcon } from '../../';
|
|
6
|
+
import { Show } from '../../utility';
|
|
3
7
|
import { CloseButton, NsInfoWrapper } from '../NsModal.styled';
|
|
4
8
|
import { NsModalComponentProps } from '../types';
|
|
5
|
-
import { Show } from '../../utility';
|
|
6
9
|
|
|
7
|
-
const NsModalTitle = ({ header, handleClose }: NsModalComponentProps) => {
|
|
10
|
+
const NsModalTitle = ({ header, handleClose }: NsModalComponentProps): ReactElement => {
|
|
8
11
|
const { show, children, isCloseIcon, iconName } = header || {};
|
|
9
12
|
return (
|
|
10
13
|
<Show when={show}>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ReactElement, useState } from 'react';
|
|
2
|
+
|
|
3
3
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
|
-
import NsModal from '../NsModal';
|
|
5
|
-
import { NsButton } from '../../button';
|
|
6
4
|
import { Grid, Typography } from '@mui/material';
|
|
7
|
-
|
|
5
|
+
/* eslint-disable @next/next/no-img-element */
|
|
6
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
7
|
+
|
|
8
|
+
import { NsButton } from '../../button';
|
|
9
|
+
import NsModal from '../NsModal';
|
|
8
10
|
import { NsModalProps } from '../types';
|
|
9
11
|
import { NsModalData } from './mock';
|
|
10
12
|
|
|
@@ -22,7 +24,7 @@ export default {
|
|
|
22
24
|
},
|
|
23
25
|
} as MetaStory;
|
|
24
26
|
|
|
25
|
-
const RenderNsModal = (args: NsModalProps) => {
|
|
27
|
+
const RenderNsModal = (args: NsModalProps): ReactElement => {
|
|
26
28
|
const [isOpen, setOpen] = useState(false);
|
|
27
29
|
|
|
28
30
|
const onModalHandler = () => {
|
|
@@ -75,7 +77,7 @@ export const ImageWidthText: Story = {
|
|
|
75
77
|
</Typography>
|
|
76
78
|
</Grid>
|
|
77
79
|
</Grid>
|
|
78
|
-
),
|
|
80
|
+
) as ReactElement,
|
|
79
81
|
},
|
|
80
82
|
footer: {
|
|
81
83
|
show: false,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { NsNavProductCard } from '.';
|
|
2
1
|
import { render } from '@/test-utils/index';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`;
|
|
3
|
+
import { ImageData1 } from '../card/fixtures/ImageData1';
|
|
4
|
+
import { NsNavProductCard } from './';
|
|
7
5
|
|
|
8
6
|
describe('Product Card Component', () => {
|
|
9
7
|
it('1. should render Product Card Component', () => {
|
|
@@ -15,7 +13,7 @@ describe('Product Card Component', () => {
|
|
|
15
13
|
}}
|
|
16
14
|
productDescription="ageLOC LumiSpa iO pairs an intelligent"
|
|
17
15
|
productName="ageLOC® LumiSpa® iO"
|
|
18
|
-
productImg={
|
|
16
|
+
productImg={ImageData1}
|
|
19
17
|
/>
|
|
20
18
|
);
|
|
21
19
|
expect(container).toBeInTheDocument();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
1
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { ImageData1 } from '../card/fixtures/ImageData1';
|
|
3
5
|
import { NsNavProductCard } from './';
|
|
4
6
|
|
|
5
7
|
type ComponentType = typeof NsNavProductCard;
|
|
@@ -16,9 +18,7 @@ export default {
|
|
|
16
18
|
productName: 'ageLOC® LumiSpa® iO',
|
|
17
19
|
className: 'justify-center',
|
|
18
20
|
// eslint-disable-next-line max-len -- disabling for links
|
|
19
|
-
productImg:
|
|
20
|
-
// eslint-disable-next-line max-len
|
|
21
|
-
'https://media.nuskin.com/m/471880e8f6e689f4/webimage-Nuskin-Ageloc-Lumi-IO-normal-combo-cleansing-device-and-cleanser.png',
|
|
21
|
+
productImg: ImageData1,
|
|
22
22
|
},
|
|
23
23
|
} as MetaStory;
|
|
24
24
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
import { NsTypography } from '../';
|
|
4
|
+
import { BynderMedia } from '../image/BynderMedia';
|
|
4
5
|
import { ProductCardContainer } from './NsNavProductCard.styled';
|
|
5
6
|
import { NsNavProductCardProps } from './types.d';
|
|
6
7
|
|
|
7
|
-
/* TODO: can we update NsImage with NsNextImage, once storybook 7 is in place */
|
|
8
8
|
export const NsNavProductCard = ({
|
|
9
9
|
productImg,
|
|
10
10
|
productDescription,
|
|
11
11
|
productName,
|
|
12
12
|
className = '',
|
|
13
|
-
}:
|
|
13
|
+
}: NsNavProductCardProps): ReactElement => {
|
|
14
14
|
return (
|
|
15
15
|
<ProductCardContainer className={className}>
|
|
16
|
-
<
|
|
16
|
+
<BynderMedia imageDetail={productImg} />
|
|
17
17
|
<div className="text-container">
|
|
18
18
|
<NsTypography variant="h5" color="primary" className="mt-11 mb-3.5 underline-hover" weight="bold">
|
|
19
19
|
{productName}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AdditionalProps } from '../common.types';
|
|
2
|
+
import { BynderImageDataType } from '../image/types';
|
|
2
3
|
|
|
3
4
|
export interface NsNavProductCardProps extends AdditionalProps {
|
|
4
|
-
productImg:
|
|
5
|
+
productImg: BynderImageDataType;
|
|
5
6
|
productName: string;
|
|
6
7
|
className?: string;
|
|
7
8
|
productDescription: string;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ReactElement,
|
|
3
|
+
ReactNode,
|
|
4
|
+
} from 'react';
|
|
5
|
+
|
|
2
6
|
import { Show } from '../utility';
|
|
3
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
NavDrawerContainer,
|
|
9
|
+
NavDrawerStyled,
|
|
10
|
+
} from './NsNavTab.styled';
|
|
4
11
|
|
|
5
12
|
type NavDrawerProps = {
|
|
6
13
|
active: string | null;
|
|
7
14
|
showDrawer: boolean;
|
|
8
15
|
content: ReactNode;
|
|
9
16
|
};
|
|
10
|
-
export const NavDrawer = ({ active, showDrawer, content }: NavDrawerProps) => {
|
|
17
|
+
export const NavDrawer = ({ active, showDrawer, content }: NavDrawerProps): ReactElement => {
|
|
11
18
|
return (
|
|
12
19
|
<NavDrawerStyled data-testid="nav-drawer-container" className="nav-drawer">
|
|
13
20
|
<Show when={Boolean(active) && showDrawer}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import { NavTabs, NsLink, NsTypography } from '../';
|
|
4
4
|
import { Show } from '../utility';
|
|
@@ -11,7 +11,7 @@ type NavTitlesProps = {
|
|
|
11
11
|
tabTitleClassName?: string;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export const NavTitles = ({ tabs, setActive, active, tabTitleClassName }: NavTitlesProps):
|
|
14
|
+
export const NavTitles = ({ tabs, setActive, active, tabTitleClassName }: NavTitlesProps): ReactElement => {
|
|
15
15
|
const NavTitleTypography = (tab: NavTabs) => (
|
|
16
16
|
<NsTypography
|
|
17
17
|
variant={tab.textVariant}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ReactElement,
|
|
3
|
+
useCallback,
|
|
4
|
+
useState,
|
|
5
|
+
} from 'react';
|
|
6
|
+
|
|
2
7
|
import { LayoutGroup } from 'framer-motion';
|
|
3
|
-
|
|
8
|
+
|
|
4
9
|
import { NavDrawer } from './NavDrawer';
|
|
5
|
-
import { NsNavTabComponentProps } from './types.d';
|
|
6
10
|
import { NavTitles } from './NavTitles';
|
|
11
|
+
import { NavTabContainer } from './NsNavTab.styled';
|
|
12
|
+
import { NsNavTabComponentProps } from './types.d';
|
|
7
13
|
|
|
8
14
|
export const NsNavTabComponent = ({
|
|
9
15
|
tabs,
|
|
10
16
|
className,
|
|
11
17
|
tabTitleClassName,
|
|
12
18
|
showDrawer = true,
|
|
13
|
-
}: NsNavTabComponentProps) => {
|
|
19
|
+
}: NsNavTabComponentProps): ReactElement => {
|
|
14
20
|
const [active, setActive] = useState<string | null>(null);
|
|
15
21
|
|
|
16
22
|
const activeTab = tabs?.find((tab) => tab.tabName === active);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
2
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
|
3
|
-
import NsProgress from './NsProgress';
|
|
4
4
|
import { PaletteColors } from '@nuskin/foundation-theme';
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
6
|
+
|
|
7
|
+
import NsProgress from './NsProgress';
|
|
5
8
|
|
|
6
9
|
type ComponentType = typeof NsProgress;
|
|
7
10
|
type Story = StoryObj<ComponentType>;
|
|
@@ -37,6 +40,6 @@ export const ProgressBar: Story = {
|
|
|
37
40
|
backgroundColor: 'secondary',
|
|
38
41
|
value: 40,
|
|
39
42
|
height: '10px',
|
|
40
|
-
body: <span>{'% Complete'}</span
|
|
43
|
+
body: (<span>{'% Complete'}</span>) as ReactElement,
|
|
41
44
|
},
|
|
42
45
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
|
|
3
|
+
import { ProgressInfo, StyledCheckCircle, StyledLinearProgress, StyledProgress } from './NsProgress.styled';
|
|
3
4
|
import { NsProgressProps } from './types';
|
|
4
|
-
import { StyledLinearProgress, ProgressInfo, StyledCheckCircle, StyledProgress } from './NsProgress.styled';
|
|
5
5
|
|
|
6
|
-
const NsProgress = (props: NsProgressProps) => {
|
|
6
|
+
const NsProgress = (props: NsProgressProps): ReactElement => {
|
|
7
7
|
const { barColor, backgroundColor, height, value, body } = props;
|
|
8
8
|
return (
|
|
9
9
|
<StyledProgress className="ns-progress">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
2
3
|
import { FormControl } from '@mui/material';
|
|
3
4
|
|
|
4
5
|
import { NsLabel } from '../label';
|
|
@@ -9,8 +10,9 @@ import {
|
|
|
9
10
|
StyledRadioGroup,
|
|
10
11
|
StyledSpan,
|
|
11
12
|
} from './NsRadioGroup.styled';
|
|
13
|
+
import { NsRadioGroupProps } from './types';
|
|
12
14
|
|
|
13
|
-
const NsRadioGroup = (props: NsRadioGroupProps) => {
|
|
15
|
+
const NsRadioGroup = (props: NsRadioGroupProps): ReactElement => {
|
|
14
16
|
const {
|
|
15
17
|
items,
|
|
16
18
|
helperText,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
|
|
2
3
|
import InputBase from '@mui/material/InputBase';
|
|
3
4
|
import { styled } from '@nuskin/foundation-theme';
|
|
4
5
|
|
|
@@ -29,7 +30,7 @@ const StyledInputBase = styled(InputBase)(() => ({
|
|
|
29
30
|
},
|
|
30
31
|
}));
|
|
31
32
|
|
|
32
|
-
const NsSearchBar
|
|
33
|
+
const NsSearchBar = (): ReactElement => {
|
|
33
34
|
return (
|
|
34
35
|
<div>
|
|
35
36
|
<Search>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import NsSelectOption from './NsSelectOption';
|
|
2
4
|
import { RenderSelectOptionArgType } from './types';
|
|
3
5
|
|
|
4
|
-
export const DefaultRenderOption = (props: RenderSelectOptionArgType) => {
|
|
6
|
+
export const DefaultRenderOption = (props: RenderSelectOptionArgType): ReactElement => {
|
|
5
7
|
return <NsSelectOption {...props} key={props?.value} onClick={props.onClick} index={props.index ?? 0} />;
|
|
6
8
|
};
|
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
MouseEvent,
|
|
3
|
+
ReactElement,
|
|
4
|
+
useCallback,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
2
9
|
|
|
3
10
|
import { useOnClickOutside } from '../hooks/useOnClickOutside';
|
|
4
11
|
import { NsIcon } from '../icon';
|
|
5
12
|
import { Show } from '../utility';
|
|
13
|
+
import {
|
|
14
|
+
arrowVisibility,
|
|
15
|
+
factorMap,
|
|
16
|
+
} from './constant';
|
|
17
|
+
import { DefaultRenderOption } from './DefaultRenderOption';
|
|
6
18
|
import {
|
|
7
19
|
ErrorContainer,
|
|
8
|
-
StyledArrowContainer,
|
|
9
20
|
SelectButton,
|
|
10
21
|
SelectContainer,
|
|
11
22
|
SelectHead,
|
|
12
23
|
SelectLabel,
|
|
13
24
|
SelectList,
|
|
14
25
|
SelectMain,
|
|
26
|
+
StyledArrowContainer,
|
|
15
27
|
} from './NsSelect.styled';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
import {
|
|
29
|
+
LabelValueType,
|
|
30
|
+
SelectProps,
|
|
31
|
+
} from './types.d';
|
|
19
32
|
|
|
20
33
|
const NsSelect: React.FC<SelectProps> = ({
|
|
21
34
|
selected,
|
|
@@ -35,7 +48,7 @@ const NsSelect: React.FC<SelectProps> = ({
|
|
|
35
48
|
reverseArrowControls,
|
|
36
49
|
RenderOption = DefaultRenderOption,
|
|
37
50
|
options,
|
|
38
|
-
}) => {
|
|
51
|
+
}): ReactElement => {
|
|
39
52
|
const [isOpen, setIsOpen] = useState(false);
|
|
40
53
|
const optionIndex = useMemo(() => {
|
|
41
54
|
if (typeof selected?.index === 'number') return selected.index;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import { StyledSelectOption } from './NsSelect.styled';
|
|
4
4
|
import { SelectOptionProps } from './types.d';
|
|
@@ -9,7 +9,7 @@ export const NsSelectOption: React.FC<SelectOptionProps> = ({
|
|
|
9
9
|
onClick,
|
|
10
10
|
selected,
|
|
11
11
|
showListDivider = true,
|
|
12
|
-
}) => {
|
|
12
|
+
}): ReactElement => {
|
|
13
13
|
const isSelected = value === selected?.value;
|
|
14
14
|
return (
|
|
15
15
|
<StyledSelectOption
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { ReactElement, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
-
import { NsSelectOption, NsSelect, SelectProps } from '../';
|
|
5
3
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
import { NsSelect, NsSelectOption, SelectProps } from '../';
|
|
6
7
|
import { countries } from './countries';
|
|
7
8
|
|
|
8
9
|
type ComponentType = typeof NsSelect;
|
|
@@ -54,7 +55,7 @@ export default {
|
|
|
54
55
|
},
|
|
55
56
|
} as MetaStory;
|
|
56
57
|
|
|
57
|
-
const AppSelect = (props: SelectProps) => {
|
|
58
|
+
const AppSelect = (props: SelectProps): ReactElement => {
|
|
58
59
|
const { selected } = props;
|
|
59
60
|
|
|
60
61
|
const [data, setData] = useState(selected);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
1
4
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
2
6
|
import NsSpinner from './NsSpinner';
|
|
3
|
-
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
7
|
|
|
5
8
|
type ComponentType = typeof NsSpinner;
|
|
6
9
|
type Story = StoryObj<ComponentType>;
|
|
@@ -10,7 +13,7 @@ export default {
|
|
|
10
13
|
title: 'Components/Feedback/NsSpinner',
|
|
11
14
|
component: NsSpinner,
|
|
12
15
|
decorators: [
|
|
13
|
-
(Story) => (
|
|
16
|
+
(Story): ReactElement => (
|
|
14
17
|
<div className="flex place-content-center">
|
|
15
18
|
<Story />
|
|
16
19
|
</div>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
|
|
2
3
|
import SpinnerIcon from './icons/Spinner';
|
|
3
4
|
import { SpinnerContainer } from './NsSpinner.styled';
|
|
4
5
|
import { NsSpinnerProps } from './types';
|
|
5
6
|
|
|
6
|
-
const NsSpinner: React.FC<NsSpinnerProps> = ({ size = 100, additionalProps }) => {
|
|
7
|
+
const NsSpinner: React.FC<NsSpinnerProps> = ({ size = 100, additionalProps }): ReactElement => {
|
|
7
8
|
return (
|
|
8
9
|
<SpinnerContainer size={size} className="spinner" {...additionalProps}>
|
|
9
10
|
<SpinnerIcon />
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
/* eslint-disable max-len */
|
|
2
4
|
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
5
|
|
|
4
|
-
const SpinnerIcon = (props: SvgIconProps) => {
|
|
6
|
+
const SpinnerIcon = (props: SvgIconProps): ReactElement => {
|
|
5
7
|
return (
|
|
6
8
|
<SvgIcon
|
|
7
9
|
id="ns-spinner-1"
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
|
|
2
3
|
import { TableRow } from '@mui/material';
|
|
3
|
-
import {
|
|
4
|
-
StyledTableRow,
|
|
5
|
-
StyledTableLastCell,
|
|
6
|
-
StyledExpandCell,
|
|
7
|
-
StyledOriginalTableCell
|
|
8
|
-
} from './NsTable.styled'
|
|
9
|
-
import type {
|
|
10
|
-
NsTableRowProps
|
|
11
|
-
} from './types'
|
|
12
4
|
import Box from '@mui/material/Box';
|
|
13
5
|
import Collapse from '@mui/material/Collapse';
|
|
14
6
|
|
|
7
|
+
import {
|
|
8
|
+
StyledExpandCell,
|
|
9
|
+
StyledOriginalTableCell,
|
|
10
|
+
StyledTableLastCell,
|
|
11
|
+
StyledTableRow,
|
|
12
|
+
} from './NsTable.styled';
|
|
13
|
+
import type { NsTableRowProps } from './types';
|
|
14
|
+
|
|
15
15
|
export default function ExpandableRow({
|
|
16
16
|
expandableContent,
|
|
17
17
|
isExpand,
|
|
@@ -21,8 +21,8 @@ export default function ExpandableRow({
|
|
|
21
21
|
index,
|
|
22
22
|
showActions,
|
|
23
23
|
showExpandedContent,
|
|
24
|
-
actionClick
|
|
25
|
-
}: NsTableRowProps) {
|
|
24
|
+
actionClick,
|
|
25
|
+
}: NsTableRowProps): ReactElement {
|
|
26
26
|
const tableRowTestId = `table-row-${index}`;
|
|
27
27
|
|
|
28
28
|
return (
|
|
@@ -32,37 +32,31 @@ export default function ExpandableRow({
|
|
|
32
32
|
onClick={() => handleClick(index)}
|
|
33
33
|
tabIndex={-1}
|
|
34
34
|
key={index}
|
|
35
|
-
className=
|
|
35
|
+
className="cursor-pointer"
|
|
36
36
|
data-testid={tableRowTestId}
|
|
37
37
|
>
|
|
38
|
-
{
|
|
39
|
-
itemKeyList.
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
38
|
+
{itemKeyList.map((id, i) => {
|
|
39
|
+
return i === itemKeyList.length - 1 && showActions ? (
|
|
40
|
+
<StyledTableLastCell align="justify" key={id}>
|
|
41
|
+
<span>{row[id]}</span>
|
|
42
|
+
<span className="action">{actionClick(row)}</span>
|
|
43
|
+
</StyledTableLastCell>
|
|
44
|
+
) : (
|
|
45
|
+
<StyledOriginalTableCell align="left" key={id}>
|
|
46
|
+
{row[id]}
|
|
47
|
+
</StyledOriginalTableCell>
|
|
48
|
+
);
|
|
49
|
+
})}
|
|
50
50
|
</StyledTableRow>
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
<
|
|
54
|
-
<
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
</Box>
|
|
61
|
-
</Collapse>
|
|
62
|
-
</StyledExpandCell>
|
|
63
|
-
</TableRow>
|
|
64
|
-
) : null
|
|
65
|
-
}
|
|
51
|
+
{showExpandedContent ? (
|
|
52
|
+
<TableRow>
|
|
53
|
+
<StyledExpandCell colSpan={itemKeyList.length} className={!isExpand ? 'remove' : ''}>
|
|
54
|
+
<Collapse in={isExpand} unmountOnExit>
|
|
55
|
+
<Box className="m-px">{expandableContent(row, index)}</Box>
|
|
56
|
+
</Collapse>
|
|
57
|
+
</StyledExpandCell>
|
|
58
|
+
</TableRow>
|
|
59
|
+
) : null}
|
|
66
60
|
</React.Fragment>
|
|
67
|
-
)
|
|
61
|
+
);
|
|
68
62
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import { withCenterDecorator } from '../../stories/decorators/withCenterDecorator';
|
|
6
|
-
import { Item } from './types';
|
|
7
6
|
import { NsIcon } from '../icon';
|
|
7
|
+
import NsTable from './NsTable';
|
|
8
|
+
import { Item } from './types';
|
|
8
9
|
|
|
9
10
|
type ComponentType = typeof NsTable;
|
|
10
11
|
type Story = StoryObj<ComponentType>;
|
|
@@ -14,9 +15,9 @@ const headers = [
|
|
|
14
15
|
label: 'Dessert (100g serving)',
|
|
15
16
|
id: 'name',
|
|
16
17
|
numeric: false,
|
|
17
|
-
sortable: false
|
|
18
|
+
sortable: false,
|
|
18
19
|
},
|
|
19
|
-
{ label: 'Calories', id: 'calories'
|
|
20
|
+
{ label: 'Calories', id: 'calories', numeric: true, sortable: true },
|
|
20
21
|
{ label: 'Fat (g)', id: 'fat', numeric: true, sortable: true },
|
|
21
22
|
{ label: 'Carbs (g)', id: 'carbs', numeric: true, sortable: true },
|
|
22
23
|
{ label: 'Protein (g)', id: 'protein', numeric: true, sortable: true },
|
|
@@ -126,37 +127,30 @@ export default {
|
|
|
126
127
|
showActions: true,
|
|
127
128
|
showExpandedContent: true,
|
|
128
129
|
loading: false,
|
|
129
|
-
expandableContent: (selectedItem: Item, index: number) => {
|
|
130
|
+
expandableContent: (selectedItem: Item, index: number): ReactElement => {
|
|
130
131
|
return (
|
|
131
132
|
<div key={index}>
|
|
132
133
|
<p>
|
|
133
134
|
Data: {selectedItem.name} , {selectedItem.calories}
|
|
134
135
|
</p>
|
|
135
|
-
<p>
|
|
136
|
-
|
|
137
|
-
</p>
|
|
138
|
-
<p>
|
|
139
|
-
Expandable: True
|
|
140
|
-
</p>
|
|
136
|
+
<p>Index: {index}</p>
|
|
137
|
+
<p>Expandable: True</p>
|
|
141
138
|
</div>
|
|
142
|
-
)
|
|
139
|
+
);
|
|
143
140
|
},
|
|
144
|
-
actionClick: (row: Item) => {
|
|
141
|
+
actionClick: (row: Item): ReactElement => {
|
|
145
142
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
146
143
|
event.stopPropagation();
|
|
147
|
-
console.log(row)
|
|
148
|
-
}
|
|
144
|
+
console.log(row);
|
|
145
|
+
};
|
|
149
146
|
|
|
150
147
|
return (
|
|
151
148
|
<button onClick={handleClick}>
|
|
152
|
-
<NsIcon
|
|
153
|
-
name='cart'
|
|
154
|
-
size='medium'
|
|
155
|
-
/>
|
|
149
|
+
<NsIcon name="cart" size="medium" />
|
|
156
150
|
</button>
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
151
|
+
);
|
|
152
|
+
},
|
|
153
|
+
},
|
|
160
154
|
} as MetaStory;
|
|
161
155
|
|
|
162
156
|
export const NasTable: Story = {};
|