@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/foundation-ui-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.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": {
|
|
@@ -100,12 +100,6 @@
|
|
|
100
100
|
"jest-environment-jsdom": "^29.7.0",
|
|
101
101
|
"storybook": "^7.5.1"
|
|
102
102
|
},
|
|
103
|
-
"peerDependencies": {
|
|
104
|
-
"@mui/material": "5.14.16",
|
|
105
|
-
"@nuskin/foundation-theme": "1.6.0",
|
|
106
|
-
"react": "^18.2.0",
|
|
107
|
-
"react-dom": "^18.2.0"
|
|
108
|
-
},
|
|
109
103
|
"files": [
|
|
110
104
|
"src/common"
|
|
111
105
|
],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { ReactElement, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { AccordionItem, NsAccordionItem, NsAccordionProps, NsTypography, useAccordionMap } from '../';
|
|
4
4
|
import { StyledAccordionWrapper } from './ToggleSection.styled';
|
|
@@ -26,7 +26,7 @@ const NsAccordion = ({
|
|
|
26
26
|
additionalProps,
|
|
27
27
|
isChild = false,
|
|
28
28
|
showEndIconWhenEmpty = false,
|
|
29
|
-
}: NsAccordionProps) => {
|
|
29
|
+
}: NsAccordionProps): ReactElement => {
|
|
30
30
|
const defaultOpenIds = useMemo(() => {
|
|
31
31
|
return items
|
|
32
32
|
?.map?.((content, index) => (content?.isDefaultOpen ? createKey(content, index) : null))
|
|
@@ -2,14 +2,7 @@ import { ReactElement } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { styled } from '@nuskin/foundation-theme';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
AccordionVariant,
|
|
7
|
-
AccordionVariantType,
|
|
8
|
-
NsAccordionHeaderProps,
|
|
9
|
-
NsIcon,
|
|
10
|
-
NsIconProps,
|
|
11
|
-
NsTypography,
|
|
12
|
-
} from '../';
|
|
5
|
+
import { AccordionVariant, AccordionVariantType, NsAccordionHeaderProps, NsIcon, NsIconProps, NsTypography } from '../';
|
|
13
6
|
import { isValidIconName } from '../icon/NsIconVariants';
|
|
14
7
|
import { getAccordionColor } from './colorMap';
|
|
15
8
|
|
|
@@ -54,7 +47,7 @@ const NsAccordionHeader = ({
|
|
|
54
47
|
cslp,
|
|
55
48
|
showEndIconWhenEmpty,
|
|
56
49
|
content,
|
|
57
|
-
}: NsAccordionHeaderProps) => {
|
|
50
|
+
}: NsAccordionHeaderProps): ReactElement => {
|
|
58
51
|
return (
|
|
59
52
|
<StyledHeader
|
|
60
53
|
invert={invert}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
import { NsAccordionItemProps, NsCollapse } from '../';
|
|
3
4
|
import NsAccordionHeader from './NsAccordionHeader';
|
|
4
5
|
import { StyledToggleSection } from './ToggleSection.styled';
|
|
5
6
|
|
|
@@ -26,7 +27,7 @@ const NsAccordionItem = ({
|
|
|
26
27
|
cslp,
|
|
27
28
|
allowMultipleExpanded,
|
|
28
29
|
showEndIconWhenEmpty,
|
|
29
|
-
}: NsAccordionItemProps) => {
|
|
30
|
+
}: NsAccordionItemProps): ReactElement => {
|
|
30
31
|
return (
|
|
31
32
|
<StyledToggleSection variant={variant}>
|
|
32
33
|
<NsAccordionHeader
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
ReactElement,
|
|
3
|
+
useState,
|
|
4
|
+
} from 'react';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
NsAccordionItem,
|
|
8
|
+
NsToggleSectionProps,
|
|
9
|
+
} from '../';
|
|
3
10
|
|
|
4
11
|
/**
|
|
5
12
|
* NsToggleSection takes prop `title` and prop `children` and toggles
|
|
@@ -18,7 +25,7 @@ const NsToggleSection = ({
|
|
|
18
25
|
invert,
|
|
19
26
|
isChild,
|
|
20
27
|
type,
|
|
21
|
-
}: NsToggleSectionProps) => {
|
|
28
|
+
}: NsToggleSectionProps): ReactElement => {
|
|
22
29
|
const [isExpanded, setIsExpanded] = useState(defaultOpen ?? false);
|
|
23
30
|
|
|
24
31
|
const toggleAccordion = () => {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
2
3
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
3
6
|
import { AccordionVariant, NsAccordionItem } from '../../';
|
|
4
7
|
import NsAccordionStory from './NsAccordion.stories';
|
|
5
|
-
import { ReactElement } from 'react';
|
|
6
8
|
|
|
7
9
|
type ComponentType = typeof NsAccordionItem;
|
|
8
10
|
type Story = StoryObj<ComponentType>;
|
|
@@ -40,7 +42,7 @@ export const ClosedSection: Story = {
|
|
|
40
42
|
args: {
|
|
41
43
|
variant: AccordionVariant.Compact,
|
|
42
44
|
isOpen: false,
|
|
43
|
-
content: <div className="p-2">Nuskin Description</div
|
|
45
|
+
content: (<div className="p-2">Nuskin Description</div>) as ReactElement,
|
|
44
46
|
title: 'Nuskin',
|
|
45
47
|
},
|
|
46
48
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
2
3
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
3
6
|
import { AccordionContentTypeObject, AccordionVariant, NsCollapse } from '../';
|
|
4
7
|
import NsAccordionStory from './NsAccordion.stories';
|
|
5
|
-
import { ReactElement } from 'react';
|
|
6
8
|
|
|
7
9
|
type ComponentType = typeof NsCollapse;
|
|
8
10
|
type Story = StoryObj<ComponentType>;
|
|
@@ -46,6 +48,6 @@ export const Closed: Story = {
|
|
|
46
48
|
export const Open: Story = {
|
|
47
49
|
args: {
|
|
48
50
|
isOpen: true,
|
|
49
|
-
content: <div className="p-2">Nuskin Description</div
|
|
51
|
+
content: (<div className="p-2">Nuskin Description</div>) as ReactElement,
|
|
50
52
|
},
|
|
51
53
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
2
4
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
3
6
|
import NsAlert from './NsAlert';
|
|
4
|
-
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
5
7
|
|
|
6
8
|
type ComponentType = typeof NsAlert;
|
|
7
9
|
type Story = StoryObj<ComponentType>;
|
|
@@ -35,8 +37,8 @@ export default {
|
|
|
35
37
|
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
36
38
|
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
|
|
37
39
|
qui officia deserunt mollit anim id est laborum.`}</span>
|
|
38
|
-
),
|
|
39
|
-
foot: <span>Some message goes here.</span
|
|
40
|
+
) as ReactElement,
|
|
41
|
+
foot: (<span>Some message goes here.</span>) as ReactElement,
|
|
40
42
|
},
|
|
41
43
|
} as MetaStory;
|
|
42
44
|
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ReactElement,
|
|
3
|
+
useEffect,
|
|
4
|
+
useState,
|
|
5
|
+
} from 'react';
|
|
2
6
|
|
|
7
|
+
import useWindowSize from '../hooks/useWindowSize';
|
|
8
|
+
import { NsIcon } from '../icon';
|
|
9
|
+
import { NsTypography } from '../typography';
|
|
10
|
+
import Header, {
|
|
11
|
+
colorMap,
|
|
12
|
+
iconMap,
|
|
13
|
+
} from './Header';
|
|
3
14
|
import {
|
|
4
15
|
Alert,
|
|
5
16
|
AlertBody,
|
|
@@ -10,12 +21,11 @@ import {
|
|
|
10
21
|
AlertHead,
|
|
11
22
|
AlertIcon,
|
|
12
23
|
} from './NsAlert.styled';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import { NsTypography } from '../typography';
|
|
24
|
+
import type {
|
|
25
|
+
AlertType,
|
|
26
|
+
ContextType,
|
|
27
|
+
NsAlertProps,
|
|
28
|
+
} from './types.d';
|
|
19
29
|
|
|
20
30
|
export default function NsAlert({
|
|
21
31
|
context = 'info',
|
|
@@ -27,7 +37,7 @@ export default function NsAlert({
|
|
|
27
37
|
body,
|
|
28
38
|
foot,
|
|
29
39
|
onDismiss = undefined,
|
|
30
|
-
}: NsAlertProps) {
|
|
40
|
+
}: NsAlertProps): ReactElement {
|
|
31
41
|
const [alertType, setAlertType] = useState('banner');
|
|
32
42
|
const windowSize = useWindowSize();
|
|
33
43
|
|
|
@@ -58,11 +68,15 @@ export default function NsAlert({
|
|
|
58
68
|
/>
|
|
59
69
|
</AlertIcon>
|
|
60
70
|
<AlertHead>
|
|
61
|
-
<Header
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
<Header
|
|
72
|
+
head={
|
|
73
|
+
<NsTypography variant="body-xl" className="alert-head-title" weight="bold" noSpacing>
|
|
74
|
+
{title}
|
|
75
|
+
</NsTypography>
|
|
76
|
+
}
|
|
77
|
+
>
|
|
78
|
+
{head}
|
|
79
|
+
</Header>
|
|
66
80
|
</AlertHead>
|
|
67
81
|
{hasDismissListener && (
|
|
68
82
|
<AlertCloseButton data-testid="alert-close-button" onClick={onDismiss}>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { useCallback, useRef, useState } from 'react';
|
|
1
|
+
import { ReactElement, useCallback, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
|
+
import { useOnClickOutside } from '../hooks/useOnClickOutside';
|
|
3
4
|
import { NsIcon } from '../icon';
|
|
4
5
|
import {
|
|
6
|
+
AuthDropdown,
|
|
5
7
|
AuthDropdownContainer,
|
|
6
8
|
AuthHead,
|
|
7
9
|
Button,
|
|
8
|
-
AuthDropdown,
|
|
9
|
-
Triangle,
|
|
10
10
|
SignInButton,
|
|
11
|
-
SignUpLinkContainer,
|
|
12
11
|
SignUpLink,
|
|
12
|
+
SignUpLinkContainer,
|
|
13
|
+
Triangle,
|
|
13
14
|
} from './NsAuthDropdown.styled';
|
|
14
15
|
import { NsAuthDropdownProps } from './types.d';
|
|
15
|
-
import { useOnClickOutside } from '../hooks/useOnClickOutside';
|
|
16
16
|
|
|
17
17
|
const NsAuthDropdown = ({
|
|
18
18
|
signInRedirectLink,
|
|
@@ -23,7 +23,7 @@ const NsAuthDropdown = ({
|
|
|
23
23
|
titleText,
|
|
24
24
|
closeOnMouseLeave = false,
|
|
25
25
|
darkModeEnabled = true,
|
|
26
|
-
}: NsAuthDropdownProps) => {
|
|
26
|
+
}: NsAuthDropdownProps): ReactElement => {
|
|
27
27
|
const [isOpen, setIsOpen] = useState(false);
|
|
28
28
|
const dropdownRef = useRef<HTMLDivElement | null>(null);
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ const NsAuthDropdown = ({
|
|
|
33
33
|
|
|
34
34
|
const handleClose = useCallback(() => {
|
|
35
35
|
setIsOpen(false);
|
|
36
|
-
},[]);
|
|
36
|
+
}, []);
|
|
37
37
|
|
|
38
38
|
useOnClickOutside(dropdownRef?.current, handleClose);
|
|
39
39
|
|
|
@@ -56,7 +56,7 @@ describe('CustomAutocomplete', () => {
|
|
|
56
56
|
await userEvent.click(optionLi);
|
|
57
57
|
});
|
|
58
58
|
expect(onChangeMock).toHaveBeenCalled();
|
|
59
|
-
},
|
|
59
|
+
}, 90000000);
|
|
60
60
|
|
|
61
61
|
it('5. should load more options when clicking load more button', async () => {
|
|
62
62
|
const seeMore = {
|
|
@@ -72,7 +72,7 @@ describe('CustomAutocomplete', () => {
|
|
|
72
72
|
await userEvent.click(loadMoreButton);
|
|
73
73
|
});
|
|
74
74
|
expect(seeMore.onSeeMore).toHaveBeenCalled();
|
|
75
|
-
},
|
|
75
|
+
}, 9000000);
|
|
76
76
|
|
|
77
77
|
it('6. should clear options when clicking clear button', async () => {
|
|
78
78
|
const clear = {
|
|
@@ -87,5 +87,5 @@ describe('CustomAutocomplete', () => {
|
|
|
87
87
|
const clearButton = screen.getByText(clear.text);
|
|
88
88
|
await userEvent.click(clearButton);
|
|
89
89
|
});
|
|
90
|
-
},
|
|
90
|
+
}, 90000000);
|
|
91
91
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
PropsWithChildren,
|
|
3
|
+
ReactElement,
|
|
3
4
|
useEffect,
|
|
4
5
|
useRef,
|
|
5
6
|
useState,
|
|
@@ -49,7 +50,7 @@ const NsAutocomplete = ({
|
|
|
49
50
|
value,
|
|
50
51
|
isFilterEnabled = true,
|
|
51
52
|
fullWidth,
|
|
52
|
-
}: PropsWithChildren<NsAutocompleteProps>) => {
|
|
53
|
+
}: PropsWithChildren<NsAutocompleteProps>):ReactElement => {
|
|
53
54
|
const [scrollTopPosition, setScrollTopPosition] = useState(0);
|
|
54
55
|
const listboxRef = useRef<HTMLUListElement | null>(null);
|
|
55
56
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dispatch, MutableRefObject, SetStateAction, useCallback } from 'react';
|
|
1
|
+
import { Dispatch, MutableRefObject, ReactElement, SetStateAction, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import { ColorUtils, styled } from '@nuskin/foundation-theme';
|
|
4
4
|
|
|
@@ -28,7 +28,7 @@ type SeeMoreButtonProps = {
|
|
|
28
28
|
listboxRef: MutableRefObject<HTMLUListElement | null>;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export const SeeMoreButton = (props: SeeMoreButtonProps) => {
|
|
31
|
+
export const SeeMoreButton = (props: SeeMoreButtonProps): ReactElement | null => {
|
|
32
32
|
const {
|
|
33
33
|
show = false,
|
|
34
34
|
text = 'See More Results',
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
import { AutocompleteRenderGroupParams } from '@mui/material';
|
|
2
4
|
import { styled } from '@nuskin/foundation-theme';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
5
|
|
|
5
6
|
import { OptionsProps } from '../../autocomplete';
|
|
6
7
|
import { NsTypography } from '../../typography';
|
|
@@ -8,7 +9,7 @@ import { NsTypography } from '../../typography';
|
|
|
8
9
|
const GroupNameTypography = styled(NsTypography)`
|
|
9
10
|
margin: 4px 8px;
|
|
10
11
|
`;
|
|
11
|
-
export const renderGroupName = ({ key, group, children }: AutocompleteRenderGroupParams):
|
|
12
|
+
export const renderGroupName = ({ key, group, children }: AutocompleteRenderGroupParams): ReactElement => (
|
|
12
13
|
<li key={key}>
|
|
13
14
|
{group ? (
|
|
14
15
|
<GroupNameTypography variant="body-m" weight="bold" className="p-0 m-0 border-solid">
|
|
@@ -19,7 +20,7 @@ export const renderGroupName = ({ key, group, children }: AutocompleteRenderGrou
|
|
|
19
20
|
</li>
|
|
20
21
|
);
|
|
21
22
|
|
|
22
|
-
export const renderOptionLabel = (option: string | OptionsProps) =>
|
|
23
|
+
export const renderOptionLabel = (option: string | OptionsProps): string =>
|
|
23
24
|
typeof option === 'string' ? option : option?.value ?? '';
|
|
24
25
|
|
|
25
26
|
export const renderGroupBy = (option: OptionsProps) => (option?.group ?? '') as string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
4
2
|
|
|
5
3
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
6
|
-
import {
|
|
7
|
-
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
|
|
6
|
+
import { NsAutocomplete } from '../';
|
|
8
7
|
import { NsIcon } from '../../icon';
|
|
9
|
-
import {
|
|
8
|
+
import { AutocompleteMockList } from '../mock/MockData';
|
|
10
9
|
import { NoCloseAutoComplete } from './NoCloseAutoComplete';
|
|
10
|
+
import { RenderAutoComplete } from './RenderAutoComplete';
|
|
11
11
|
|
|
12
12
|
type ComponentType = typeof NsAutocomplete;
|
|
13
13
|
type Story = StoryObj<ComponentType>;
|
|
@@ -61,10 +61,10 @@ export default {
|
|
|
61
61
|
throw new Error('Function not implemented.');
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
|
-
iconStart: <NsIcon name="search"
|
|
65
|
-
iconEnd: <NsIcon name="roundedClose" size="small" colorOverride="#F5F5F5"
|
|
64
|
+
iconStart: (<NsIcon name="search" />) as ReactElement,
|
|
65
|
+
iconEnd: (<NsIcon name="roundedClose" size="small" colorOverride="#F5F5F5" />) as ReactElement,
|
|
66
66
|
placeholder: 'Search',
|
|
67
|
-
fullWidth:false
|
|
67
|
+
fullWidth: false,
|
|
68
68
|
},
|
|
69
69
|
} as MetaStory;
|
|
70
70
|
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { NsBanner } from '@/common/';
|
|
4
|
+
import { ImageData1 } from '../card/fixtures/ImageData1';
|
|
4
5
|
|
|
5
6
|
describe('Hero component', () => {
|
|
6
7
|
const childText = 'Welcome to My Website';
|
|
7
|
-
const imageURL = 'https://example.com/banner.jpg';
|
|
8
8
|
it('1. renders banner image and title', () => {
|
|
9
9
|
const { getByAltText, getByText } = render(
|
|
10
|
-
<NsBanner
|
|
10
|
+
<NsBanner image={ImageData1}>
|
|
11
11
|
<h1>{childText}</h1>
|
|
12
12
|
</NsBanner>
|
|
13
13
|
);
|
|
14
14
|
const childElement = getByText(childText);
|
|
15
|
-
const imageElement = getByAltText(
|
|
15
|
+
const imageElement = getByAltText(ImageData1.selected?.altText || '');
|
|
16
16
|
expect(childElement).toBeInTheDocument();
|
|
17
17
|
expect(imageElement).toBeInTheDocument();
|
|
18
18
|
});
|
|
19
19
|
it('2. renders banner image and title without altText', () => {
|
|
20
20
|
const { getByAltText } = render(
|
|
21
|
-
<NsBanner
|
|
21
|
+
<NsBanner image={ImageData1}>
|
|
22
22
|
<h1>{childText}</h1>
|
|
23
23
|
</NsBanner>
|
|
24
24
|
);
|
|
25
|
-
const imageElement = getByAltText('
|
|
25
|
+
const imageElement = getByAltText(ImageData1.selected?.altText || '');
|
|
26
26
|
expect(imageElement).toBeInTheDocument();
|
|
27
27
|
});
|
|
28
28
|
});
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* @description NsBanner component.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
import { NsBanner, NsTypography, NsButton } from '../';
|
|
7
|
+
import React, { ReactElement } from 'react';
|
|
8
|
+
|
|
10
9
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
10
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
11
|
+
|
|
12
|
+
import { NsBanner, NsButton, NsTypography } from '../';
|
|
13
|
+
import { ImageData1 } from '../card/fixtures/ImageData1';
|
|
11
14
|
|
|
12
15
|
type ComponentType = typeof NsBanner;
|
|
13
16
|
type Story = StoryObj<ComponentType>;
|
|
@@ -23,7 +26,7 @@ export default {
|
|
|
23
26
|
},
|
|
24
27
|
},
|
|
25
28
|
args: {
|
|
26
|
-
|
|
29
|
+
image: ImageData1,
|
|
27
30
|
altText: 'NsBanner',
|
|
28
31
|
alignment: 'center',
|
|
29
32
|
justify: 'start',
|
|
@@ -37,7 +40,7 @@ export default {
|
|
|
37
40
|
</NsTypography>
|
|
38
41
|
<NsButton variant="contained">Contact me</NsButton>
|
|
39
42
|
</div>
|
|
40
|
-
),
|
|
43
|
+
) as ReactElement,
|
|
41
44
|
},
|
|
42
45
|
} as MetaStory;
|
|
43
46
|
|
|
@@ -4,33 +4,23 @@
|
|
|
4
4
|
* @description NsBanner component with a image background
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import React, { PropsWithChildren } from 'react';
|
|
7
|
+
import React, { PropsWithChildren, ReactElement } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { getBasicDATWidthHeight } from '../image/bynder-util';
|
|
10
|
+
import { BynderMedia } from '../image/BynderMedia';
|
|
10
11
|
import { StyledBanner, StyledHeroText } from './NsBanner.styled';
|
|
11
|
-
import {
|
|
12
|
+
import { NsBannerProps } from './types.d';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const {
|
|
16
|
-
children,
|
|
17
|
-
imageUrl,
|
|
18
|
-
altText,
|
|
19
|
-
alignment = 'center',
|
|
20
|
-
justify = 'start',
|
|
21
|
-
className = '',
|
|
22
|
-
additionalProps = {},
|
|
23
|
-
} = props;
|
|
14
|
+
const NsBanner = (props: PropsWithChildren<NsBannerProps>): ReactElement => {
|
|
15
|
+
const { children, image, alignment = 'center', justify = 'start', className = '', additionalProps = {} } = props;
|
|
24
16
|
|
|
25
17
|
return (
|
|
26
18
|
<StyledBanner className={className}>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
id="bgImage"
|
|
31
|
-
width={0}
|
|
32
|
-
height={0}
|
|
19
|
+
<BynderMedia
|
|
20
|
+
className="image"
|
|
21
|
+
imageDetail={image}
|
|
33
22
|
{...additionalProps}
|
|
23
|
+
suffix={getBasicDATWidthHeight(1100, 600, 'scale')}
|
|
34
24
|
/>
|
|
35
25
|
<StyledHeroText $alignment={alignment} $justify={justify}>
|
|
36
26
|
<div className="mx-14">{children}</div>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { AdditionalProps } from '../common.types';
|
|
4
|
+
import { BynderImageDataType } from '../image/types';
|
|
4
5
|
|
|
5
6
|
export type AlignmentType = 'start' | 'center' | 'end';
|
|
6
7
|
|
|
7
8
|
export type NsBannerProps = {
|
|
8
9
|
children: React.ReactNode;
|
|
9
|
-
|
|
10
|
-
altText?: string;
|
|
10
|
+
image: BynderImageDataType;
|
|
11
11
|
alignment?: AlignmentType;
|
|
12
12
|
justify?: AlignmentType;
|
|
13
13
|
className?: string;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
PropsWithChildren,
|
|
3
|
+
ReactElement,
|
|
4
|
+
useCallback,
|
|
5
|
+
} from 'react';
|
|
2
6
|
|
|
3
7
|
import NSLogoHorizontal from './icons/NSLogoHorizontal';
|
|
4
8
|
import NSLogoMark from './icons/NSLogoMark';
|
|
@@ -6,7 +10,6 @@ import NSLogoPoweredBy from './icons/NSLogoPoweredBy';
|
|
|
6
10
|
import NSLogoStacked from './icons/NSLogoStacked';
|
|
7
11
|
import NSLogoWordMark from './icons/NSWordMark';
|
|
8
12
|
import LogoContainer from './NsBrandContainer.styled';
|
|
9
|
-
|
|
10
13
|
import { NsBrandComponentProps } from './types.d';
|
|
11
14
|
|
|
12
15
|
const VariantMap = {
|
|
@@ -17,7 +20,7 @@ const VariantMap = {
|
|
|
17
20
|
poweredBy: NSLogoPoweredBy,
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
const NsBrandComponent = (props: PropsWithChildren<NsBrandComponentProps>) => {
|
|
23
|
+
const NsBrandComponent = (props: PropsWithChildren<NsBrandComponentProps>):ReactElement => {
|
|
21
24
|
const { variant = 'stacked', size = '108px', color = 'primary' } = props;
|
|
22
25
|
const renderBrand = useCallback(() => {
|
|
23
26
|
const BrandComponent = VariantMap[variant];
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ReactElement } from 'react';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import {
|
|
6
|
+
SvgIcon,
|
|
7
|
+
SvgIconProps,
|
|
8
|
+
} from '@mui/material';
|
|
9
|
+
|
|
10
|
+
const NSLogoHorizontal = (props: SvgIconProps):ReactElement => {
|
|
6
11
|
return (
|
|
7
12
|
<SvgIcon
|
|
8
13
|
viewBox="0 0 135 30"
|
|
@@ -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 NSLogoMark = (props: SvgIconProps) => {
|
|
6
|
+
const NSLogoMark = (props: SvgIconProps):ReactElement => {
|
|
5
7
|
return (
|
|
6
8
|
<SvgIcon
|
|
7
9
|
viewBox="0 0 51 52"
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
/* eslint-disable max-len */
|
|
2
|
-
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon'
|
|
4
|
+
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
5
|
|
|
4
|
-
const NSLogoPoweredBy = (props: SvgIconProps) => {
|
|
6
|
+
const NSLogoPoweredBy = (props: SvgIconProps):ReactElement => {
|
|
5
7
|
const { color } = props
|
|
6
8
|
return (
|
|
7
9
|
<SvgIcon
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
/* eslint-disable max-len */
|
|
2
|
-
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon'
|
|
4
|
+
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
5
|
|
|
4
|
-
const NSLogoStacked = (props: SvgIconProps) => {
|
|
6
|
+
const NSLogoStacked = (props: SvgIconProps):ReactElement => {
|
|
5
7
|
return (
|
|
6
8
|
<SvgIcon
|
|
7
9
|
viewBox="0 0 155 108"
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
|
|
1
3
|
/* eslint-disable max-len */
|
|
2
|
-
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon'
|
|
4
|
+
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
5
|
|
|
4
|
-
const NSLogoWordMark = (props: SvgIconProps) => {
|
|
6
|
+
const NSLogoWordMark = (props: SvgIconProps):ReactElement => {
|
|
5
7
|
return (
|
|
6
8
|
<SvgIcon
|
|
7
9
|
viewBox="0 0 98 20"
|