@nuskin/foundation-ui-components 1.33.0-1253-feature.3 → 2.0.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/dist/index.d.mts +1221 -0
- package/dist/index.d.ts +1221 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -10
- package/src/common/accordion/NsAccordion.tsx +0 -82
- package/src/common/accordion/NsAccordionHeader.tsx +0 -85
- package/src/common/accordion/NsAccordionItem.tsx +0 -65
- package/src/common/accordion/NsCollapse.tsx +0 -121
- package/src/common/accordion/NsToggleSection.tsx +0 -50
- package/src/common/accordion/ToggleSection.styled.tsx +0 -32
- package/src/common/accordion/colorMap.ts +0 -60
- package/src/common/accordion/enums.ts +0 -18
- package/src/common/accordion/index.ts +0 -7
- package/src/common/accordion/specs/NsAccordion.spec.tsx +0 -183
- package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +0 -172
- package/src/common/accordion/specs/NsAccordionItem.spec.tsx +0 -79
- package/src/common/accordion/specs/NsCollapse.spec.tsx +0 -130
- package/src/common/accordion/specs/NsToggleSection.spec.tsx +0 -74
- package/src/common/accordion/stories/NsAccordion.stories.tsx +0 -65
- package/src/common/accordion/stories/NsAccordionHeader.stories.tsx +0 -44
- package/src/common/accordion/stories/NsAccordionItem.stories.tsx +0 -48
- package/src/common/accordion/stories/NsCollapse.stories.tsx +0 -53
- package/src/common/accordion/stories/NsToggleSection.stories.tsx +0 -27
- package/src/common/accordion/stories/data.tsx +0 -145
- package/src/common/accordion/types.d.ts +0 -90
- package/src/common/alert/Header.tsx +0 -29
- package/src/common/alert/NsAlert.spec.tsx +0 -167
- package/src/common/alert/NsAlert.stories.tsx +0 -45
- package/src/common/alert/NsAlert.styled.tsx +0 -114
- package/src/common/alert/NsAlert.tsx +0 -93
- package/src/common/alert/index.ts +0 -2
- package/src/common/alert/types.d.ts +0 -45
- package/src/common/auth-dropdown/NsAuthDropdown.spec.tsx +0 -54
- package/src/common/auth-dropdown/NsAuthDropdown.stories.tsx +0 -25
- package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +0 -120
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +0 -72
- package/src/common/auth-dropdown/index.ts +0 -2
- package/src/common/auth-dropdown/types.d.ts +0 -11
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +0 -91
- package/src/common/autocomplete/NsAutocomplete.styled.tsx +0 -24
- package/src/common/autocomplete/NsAutocomplete.tsx +0 -225
- package/src/common/autocomplete/helper/LineLoader.tsx +0 -38
- package/src/common/autocomplete/helper/RecentClearAll.tsx +0 -43
- package/src/common/autocomplete/helper/SeeMoreButton.tsx +0 -68
- package/src/common/autocomplete/helper/index.ts +0 -4
- package/src/common/autocomplete/helper/renderGroupName.tsx +0 -26
- package/src/common/autocomplete/index.ts +0 -2
- package/src/common/autocomplete/mock/Mock.styled.tsx +0 -23
- package/src/common/autocomplete/mock/MockData.ts +0 -89
- package/src/common/autocomplete/mock/MockUI.tsx +0 -26
- package/src/common/autocomplete/stories/NoCloseAutoComplete.tsx +0 -49
- package/src/common/autocomplete/stories/NsAutocomplete.stories.tsx +0 -78
- package/src/common/autocomplete/stories/RenderAutoComplete.tsx +0 -60
- package/src/common/autocomplete/types.d.ts +0 -67
- package/src/common/banner/NsBanner.spec.tsx +0 -28
- package/src/common/banner/NsBanner.stories.tsx +0 -47
- package/src/common/banner/NsBanner.styled.tsx +0 -24
- package/src/common/banner/NsBanner.tsx +0 -32
- package/src/common/banner/index.ts +0 -2
- package/src/common/banner/types.d.ts +0 -14
- package/src/common/brand-components/NsBrand.stories.tsx +0 -26
- package/src/common/brand-components/NsBrandComponent.spec.tsx +0 -47
- package/src/common/brand-components/NsBrandComponent.tsx +0 -33
- package/src/common/brand-components/NsBrandContainer.styled.tsx +0 -10
- package/src/common/brand-components/icons/Logo.spec.tsx +0 -84
- package/src/common/brand-components/icons/NSLogoHorizontal.tsx +0 -70
- package/src/common/brand-components/icons/NSLogoMark.tsx +0 -39
- package/src/common/brand-components/icons/NSLogoPoweredBy.tsx +0 -103
- package/src/common/brand-components/icons/NSLogoStacked.tsx +0 -57
- package/src/common/brand-components/icons/NSWordMark.tsx +0 -60
- package/src/common/brand-components/index.ts +0 -2
- package/src/common/brand-components/types.d.ts +0 -11
- package/src/common/breadcrumb/NsBreadcrumb.spec.tsx +0 -28
- package/src/common/breadcrumb/NsBreadcrumb.stories.tsx +0 -39
- package/src/common/breadcrumb/NsBreadcrumb.styled.tsx +0 -36
- package/src/common/breadcrumb/NsBreadcrumb.tsx +0 -85
- package/src/common/breadcrumb/data.ts +0 -10
- package/src/common/breadcrumb/index.ts +0 -2
- package/src/common/breadcrumb/types.d.ts +0 -14
- package/src/common/button/NsButton.spec.tsx +0 -94
- package/src/common/button/NsButton.stories.tsx +0 -118
- package/src/common/button/NsButton.styled.tsx +0 -57
- package/src/common/button/NsButton.tsx +0 -48
- package/src/common/button/__snapshots__/NsButton.spec.tsx.snap +0 -120
- package/src/common/button/helper.ts +0 -84
- package/src/common/button/index.ts +0 -2
- package/src/common/button/types.d.ts +0 -26
- package/src/common/card/CardButton.tsx +0 -58
- package/src/common/card/NsAwardCard.tsx +0 -71
- package/src/common/card/NsBgCard.tsx +0 -26
- package/src/common/card/NsBrandCard.tsx +0 -88
- package/src/common/card/NsBrandLogo.tsx +0 -16
- package/src/common/card/NsBrandWrapper.tsx +0 -25
- package/src/common/card/NsCheckoutCard.tsx +0 -107
- package/src/common/card/NsHeroCardLevel1.tsx +0 -105
- package/src/common/card/NsHeroCardLevel2.tsx +0 -95
- package/src/common/card/NsIconText.tsx +0 -165
- package/src/common/card/NsLargeCard.tsx +0 -108
- package/src/common/card/NsMediumCard.tsx +0 -110
- package/src/common/card/NsPost.tsx +0 -78
- package/src/common/card/NsSmallFullCard.tsx +0 -93
- package/src/common/card/NsXLargeCard.tsx +0 -89
- package/src/common/card/cardSizes.ts +0 -12
- package/src/common/card/fixtures/ImageData1.ts +0 -38
- package/src/common/card/fixtures/ImageData2.ts +0 -38
- package/src/common/card/index.ts +0 -15
- package/src/common/card/specs/BrandLogo.spec.tsx +0 -13
- package/src/common/card/specs/NsAwardCard.spec.tsx +0 -29
- package/src/common/card/specs/NsBgCard.spec.tsx +0 -23
- package/src/common/card/specs/NsBrandCard.spec.tsx +0 -84
- package/src/common/card/specs/NsCheckoutCard.spec.tsx +0 -39
- package/src/common/card/specs/NsHeroCardLevel1.spec.tsx +0 -39
- package/src/common/card/specs/NsHeroCardLevel2.spec.tsx +0 -49
- package/src/common/card/specs/NsIconText.spec.tsx +0 -25
- package/src/common/card/specs/NsLargeCard.spec.tsx +0 -47
- package/src/common/card/specs/NsMediumCard.spec.tsx +0 -51
- package/src/common/card/specs/NsPost.spec.tsx +0 -28
- package/src/common/card/specs/NsSmallFullCard.spec.tsx +0 -47
- package/src/common/card/specs/NsXLargeCard.spec.tsx +0 -47
- package/src/common/card/stories/NsAwardCard.stories.tsx +0 -21
- package/src/common/card/stories/NsBrandCard.stories.tsx +0 -32
- package/src/common/card/stories/NsCheckoutCard.stories.tsx +0 -23
- package/src/common/card/stories/NsHeroCardLevel1.stories.tsx +0 -30
- package/src/common/card/stories/NsHeroCardLevel2.stories.tsx +0 -29
- package/src/common/card/stories/NsIconText.stories.tsx +0 -18
- package/src/common/card/stories/NsLargeCard.stories.tsx +0 -32
- package/src/common/card/stories/NsMediumCard.stories.tsx +0 -34
- package/src/common/card/stories/NsPost.stories.tsx +0 -20
- package/src/common/card/stories/NsSmallFullCard.stories.tsx +0 -31
- package/src/common/card/stories/NsXLargeCard.stories.tsx +0 -32
- package/src/common/card/stories/data.ts +0 -43
- package/src/common/card/types.d.ts +0 -25
- package/src/common/carousal/CarousalControl.tsx +0 -47
- package/src/common/carousal/IconWrapper.tsx +0 -33
- package/src/common/carousal/NsCarousal.tsx +0 -65
- package/src/common/carousal/NsScrollingCarousal.tsx +0 -60
- package/src/common/carousal/RenderBrand.tsx +0 -20
- package/src/common/carousal/index.ts +0 -5
- package/src/common/carousal/slickSetting.ts +0 -61
- package/src/common/carousal/specs/Chevron.spec.tsx +0 -10
- package/src/common/carousal/specs/NsCarousal.spec.tsx +0 -112
- package/src/common/carousal/specs/NsScrollingCarousal.spec.tsx +0 -63
- package/src/common/carousal/specs/RenderBrand.spec.tsx +0 -22
- package/src/common/carousal/stories/NsCarousal1.stories.tsx +0 -34
- package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +0 -80
- package/src/common/carousal/types.d.ts +0 -23
- package/src/common/cart-icon/NsCartIcon.spec.tsx +0 -19
- package/src/common/cart-icon/NsCartIcon.stories.tsx +0 -28
- package/src/common/cart-icon/NsCartIcon.styled.tsx +0 -15
- package/src/common/cart-icon/NsCartIcon.tsx +0 -24
- package/src/common/cart-icon/index.ts +0 -2
- package/src/common/cart-icon/types.d.ts +0 -8
- package/src/common/checkbox/NsCheckbox.spec.tsx +0 -57
- package/src/common/checkbox/NsCheckbox.stories.tsx +0 -55
- package/src/common/checkbox/NsCheckbox.styled.tsx +0 -55
- package/src/common/checkbox/NsCheckbox.tsx +0 -68
- package/src/common/checkbox/index.ts +0 -2
- package/src/common/checkbox/types.d.ts +0 -20
- package/src/common/column-control/NsColumnControl.tsx +0 -64
- package/src/common/column-control/NsFlexColumns.tsx +0 -29
- package/src/common/column-control/NsGridColumns.tsx +0 -29
- package/src/common/column-control/index.ts +0 -4
- package/src/common/column-control/specs/NsColumnControl.spec.tsx +0 -24
- package/src/common/column-control/specs/NsFlexColumns.spec.tsx +0 -24
- package/src/common/column-control/specs/NsGridColumns.spec.tsx +0 -24
- package/src/common/column-control/stories/DivArray.stories.tsx +0 -18
- package/src/common/column-control/stories/DivArray.tsx +0 -63
- package/src/common/column-control/stories/NsColumnControl.stories.tsx +0 -65
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +0 -66
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +0 -75
- package/src/common/column-control/stories/common.tsx +0 -14
- package/src/common/column-control/styled/StyledFlex.tsx +0 -46
- package/src/common/column-control/styled/StyledGrid.tsx +0 -41
- package/src/common/column-control/styled/common.ts +0 -27
- package/src/common/column-control/types.d.ts +0 -46
- package/src/common/column-control/utils.ts +0 -66
- package/src/common/common.types.d.ts +0 -21
- package/src/common/dropdown/NsDropdown.spec.tsx +0 -126
- package/src/common/dropdown/NsDropdown.styled.tsx +0 -66
- package/src/common/dropdown/NsDropdown.tsx +0 -94
- package/src/common/dropdown/NsDropdownOption.tsx +0 -13
- package/src/common/dropdown/index.ts +0 -3
- package/src/common/dropdown/stories/NsDropdown.stories.tsx +0 -67
- package/src/common/dropdown/stories/NsDropdownCountry.stories.tsx +0 -64
- package/src/common/dropdown/types.d.ts +0 -23
- package/src/common/email-simple/NsEmailSimple.spec.tsx +0 -115
- package/src/common/email-simple/NsEmailSimple.stories.tsx +0 -61
- package/src/common/email-simple/NsEmailSimple.tsx +0 -72
- package/src/common/email-simple/index.ts +0 -2
- package/src/common/email-simple/types.d.ts +0 -14
- package/src/common/flag/NsFlag.spec.tsx +0 -27
- package/src/common/flag/NsFlag.stories.tsx +0 -22
- package/src/common/flag/NsFlag.styled.tsx +0 -73
- package/src/common/flag/NsFlag.tsx +0 -24
- package/src/common/flag/index.ts +0 -2
- package/src/common/flag/types.d.ts +0 -16
- package/src/common/hooks/index.ts +0 -2
- package/src/common/hooks/specs/useWindowSize.spec.tsx +0 -19
- package/src/common/hooks/useAccordionMap.tsx +0 -39
- package/src/common/hooks/useOnClickOutside.tsx +0 -25
- package/src/common/hooks/useWindowSize.tsx +0 -30
- package/src/common/icon/NsIcon.spec.tsx +0 -51
- package/src/common/icon/NsIcon.stories.tsx +0 -77
- package/src/common/icon/NsIcon.styled.tsx +0 -27
- package/src/common/icon/NsIcon.tsx +0 -44
- package/src/common/icon/NsIconVariants.ts +0 -56
- package/src/common/icon/icons/AlertErrorIcon.tsx +0 -48
- package/src/common/icon/icons/ArrowDown.tsx +0 -23
- package/src/common/icon/icons/ArrowLeft.tsx +0 -38
- package/src/common/icon/icons/ArrowRight.tsx +0 -39
- package/src/common/icon/icons/ArrowUp.tsx +0 -20
- package/src/common/icon/icons/Cart.tsx +0 -23
- package/src/common/icon/icons/CartBadge.tsx +0 -47
- package/src/common/icon/icons/Check.tsx +0 -30
- package/src/common/icon/icons/CheckShield.tsx +0 -24
- package/src/common/icon/icons/CheckVerified.tsx +0 -27
- package/src/common/icon/icons/ChevronRight.tsx +0 -31
- package/src/common/icon/icons/CloseIcon.tsx +0 -27
- package/src/common/icon/icons/ErrorIcon.tsx +0 -30
- package/src/common/icon/icons/HamburgerIcon.tsx +0 -35
- package/src/common/icon/icons/InfoFilled.tsx +0 -21
- package/src/common/icon/icons/InfoOutlined.tsx +0 -42
- package/src/common/icon/icons/RoundedClose.tsx +0 -31
- package/src/common/icon/icons/SearchIcon.tsx +0 -32
- package/src/common/icon/icons/SlashIcon.tsx +0 -22
- package/src/common/icon/icons/SuccessIcon.tsx +0 -40
- package/src/common/icon/icons/TrashIcon.tsx +0 -32
- package/src/common/icon/icons/UserIcon.tsx +0 -37
- package/src/common/icon/icons/UserOutline.tsx +0 -29
- package/src/common/icon/icons/WarningIcon.tsx +0 -48
- package/src/common/icon/icons/error.svg +0 -3
- package/src/common/icon/icons/home.tsx +0 -19
- package/src/common/icon/icons/search.svg +0 -3
- package/src/common/icon/icons/success.svg +0 -10
- package/src/common/icon/icons/trash.svg +0 -3
- package/src/common/icon/index.ts +0 -3
- package/src/common/icon/types.d.ts +0 -53
- package/src/common/image/BynderMedia.spec.tsx +0 -42
- package/src/common/image/BynderMedia.tsx +0 -49
- package/src/common/image/NsImage.spec.tsx +0 -60
- package/src/common/image/NsImage.stories.tsx +0 -46
- package/src/common/image/NsImage.tsx +0 -33
- package/src/common/image/NsNextImage.spec.tsx +0 -10
- package/src/common/image/NsNextImage.stories.tsx +0 -51
- package/src/common/image/NsNextImage.tsx +0 -11
- package/src/common/image/bynder-util.spec.ts +0 -187
- package/src/common/image/bynder-util.ts +0 -98
- package/src/common/image/index.ts +0 -3
- package/src/common/image/types.ts +0 -78
- package/src/common/index.ts +0 -37
- package/src/common/input/InputFieldWrapper.tsx +0 -24
- package/src/common/input/InputWrapper.tsx +0 -82
- package/src/common/input/NsInputField.spec.tsx +0 -25
- package/src/common/input/NsInputField.stories.tsx +0 -61
- package/src/common/input/NsInputField.tsx +0 -125
- package/src/common/input/getAdornmentProps.tsx +0 -50
- package/src/common/input/index.ts +0 -2
- package/src/common/input/types.d.ts +0 -45
- package/src/common/label/NsLabel.spec.tsx +0 -11
- package/src/common/label/NsLabel.stories.tsx +0 -35
- package/src/common/label/NsLabel.tsx +0 -43
- package/src/common/label/index.ts +0 -2
- package/src/common/label/types.d.ts +0 -10
- package/src/common/link/NsLink.spec.tsx +0 -106
- package/src/common/link/NsLink.stories.tsx +0 -55
- package/src/common/link/NsLink.styled.tsx +0 -100
- package/src/common/link/NsLink.tsx +0 -122
- package/src/common/link/index.ts +0 -2
- package/src/common/link/types.d.ts +0 -22
- package/src/common/modal/NsModal.spec.tsx +0 -46
- package/src/common/modal/NsModal.styled.tsx +0 -28
- package/src/common/modal/NsModal.tsx +0 -43
- package/src/common/modal/helper-component/NsModalContentBox.tsx +0 -37
- package/src/common/modal/helper-component/NsModalDefault.tsx +0 -34
- package/src/common/modal/helper-component/NsModalStatus.tsx +0 -17
- package/src/common/modal/helper-component/NsModalStatusIcon.tsx +0 -16
- package/src/common/modal/helper-component/NsModalTitle.tsx +0 -29
- package/src/common/modal/index.ts +0 -2
- package/src/common/modal/model/NsModalVariantMap.tsx +0 -24
- package/src/common/modal/stories/NsModal.stories.tsx +0 -87
- package/src/common/modal/stories/mock.tsx +0 -46
- package/src/common/modal/types.ts +0 -57
- package/src/common/nav-product-card/NsNavProductCard.spec.tsx +0 -22
- package/src/common/nav-product-card/NsNavProductCard.stories.tsx +0 -25
- package/src/common/nav-product-card/NsNavProductCard.styled.tsx +0 -24
- package/src/common/nav-product-card/NsNavProductCard.tsx +0 -27
- package/src/common/nav-product-card/index.ts +0 -2
- package/src/common/nav-product-card/types.d.ts +0 -9
- package/src/common/nav-tab/NavDrawer.tsx +0 -41
- package/src/common/nav-tab/NavTitles.tsx +0 -64
- package/src/common/nav-tab/NsNavTab.spec.tsx +0 -64
- package/src/common/nav-tab/NsNavTab.stories.tsx +0 -36
- package/src/common/nav-tab/NsNavTab.styled.tsx +0 -74
- package/src/common/nav-tab/NsNavTab.tsx +0 -43
- package/src/common/nav-tab/index.ts +0 -2
- package/src/common/nav-tab/types.d.ts +0 -21
- package/src/common/progress/NsProgress.spec.tsx +0 -47
- package/src/common/progress/NsProgress.stories.tsx +0 -45
- package/src/common/progress/NsProgress.styled.tsx +0 -56
- package/src/common/progress/NsProgress.tsx +0 -29
- package/src/common/progress/index.ts +0 -2
- package/src/common/progress/types.d.ts +0 -21
- package/src/common/radiogroup/NsRadioGroup.spec.tsx +0 -63
- package/src/common/radiogroup/NsRadioGroup.stories.tsx +0 -84
- package/src/common/radiogroup/NsRadioGroup.styled.tsx +0 -51
- package/src/common/radiogroup/NsRadioGroup.tsx +0 -65
- package/src/common/radiogroup/index.ts +0 -2
- package/src/common/radiogroup/types.d.ts +0 -19
- package/src/common/search-bar/NsSeachBar.spec.tsx +0 -9
- package/src/common/search-bar/NsSearchBar.tsx +0 -46
- package/src/common/select/DefaultRenderOption.tsx +0 -8
- package/src/common/select/NsSelect.styled.tsx +0 -102
- package/src/common/select/NsSelect.tsx +0 -166
- package/src/common/select/NsSelectOption.tsx +0 -26
- package/src/common/select/constant.ts +0 -30
- package/src/common/select/index.ts +0 -3
- package/src/common/select/specs/NsSelect.spec.tsx +0 -183
- package/src/common/select/specs/NsSelectOption.spec.tsx +0 -32
- package/src/common/select/stories/NsSelect.stories.tsx +0 -89
- package/src/common/select/stories/countries.ts +0 -53
- package/src/common/select/types.d.ts +0 -49
- package/src/common/spinner/NsSpinner.spec.tsx +0 -21
- package/src/common/spinner/NsSpinner.stories.tsx +0 -29
- package/src/common/spinner/NsSpinner.styled.tsx +0 -344
- package/src/common/spinner/NsSpinner.tsx +0 -15
- package/src/common/spinner/icons/Spinner.tsx +0 -163
- package/src/common/spinner/index.ts +0 -2
- package/src/common/spinner/types.ts +0 -5
- package/src/common/table/NsExpandableRow.tsx +0 -62
- package/src/common/table/NsTable.spec.tsx +0 -174
- package/src/common/table/NsTable.stories.tsx +0 -156
- package/src/common/table/NsTable.styled.ts +0 -127
- package/src/common/table/NsTable.tsx +0 -150
- package/src/common/table/NsTableHeader.tsx +0 -54
- package/src/common/table/NsTablePagination.tsx +0 -24
- package/src/common/table/helper.ts +0 -33
- package/src/common/table/index.ts +0 -2
- package/src/common/table/types.d.ts +0 -57
- package/src/common/text-strip/NsTextStrip.spec.tsx +0 -27
- package/src/common/text-strip/NsTextStrip.stories.tsx +0 -61
- package/src/common/text-strip/NsTextStrip.tsx +0 -61
- package/src/common/text-strip/index.ts +0 -2
- package/src/common/text-strip/types.d.ts +0 -16
- package/src/common/toast/Fade.tsx +0 -98
- package/src/common/toast/ToastProvider.tsx +0 -88
- package/src/common/toast/index.ts +0 -3
- package/src/common/toast/shared.ts +0 -124
- package/src/common/toast/specs/Toast.spec.tsx +0 -122
- package/src/common/toast/stories/Toast.stories.tsx +0 -82
- package/src/common/toast/useToast.tsx +0 -65
- package/src/common/typography/GlobalFontInter.tsx +0 -15
- package/src/common/typography/HtmlTagVariantMap.tsx +0 -24
- package/src/common/typography/NsTypography.spec.tsx +0 -37
- package/src/common/typography/NsTypography.stories.tsx +0 -27
- package/src/common/typography/NsTypography.tsx +0 -44
- package/src/common/typography/Typography.styled.tsx +0 -195
- package/src/common/typography/__snapshots__/NsTypography.spec.tsx.snap +0 -22
- package/src/common/typography/index.ts +0 -3
- package/src/common/typography/types.d.ts +0 -37
- package/src/common/util.ts +0 -3
- package/src/common/utility/Show.tsx +0 -13
- package/src/common/utility/index.ts +0 -1
- package/src/common/validations/regex.ts +0 -2
- package/src/common/videos/NsVideo.spec.tsx +0 -26
- package/src/common/videos/NsVideo.stories.tsx +0 -32
- package/src/common/videos/NsVideo.tsx +0 -28
- package/src/common/videos/index.ts +0 -2
- package/src/common/videos/types.d.ts +0 -9
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, fireEvent, screen } from '@testing-library/react';
|
|
3
|
-
import { NsRadioGroup } from './';
|
|
4
|
-
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
5
|
-
|
|
6
|
-
describe('NsRadioGroup', () => {
|
|
7
|
-
const options = [
|
|
8
|
-
{ id: 'Option1', label: 'Option 1', value: 'Option1' },
|
|
9
|
-
{ id: 'Option2', label: 'Option 2', value: 'Option2' },
|
|
10
|
-
{ id: 'Option3', label: 'Option 3', value: 'Option3' },
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
const props = {
|
|
14
|
-
disable: false,
|
|
15
|
-
items: options,
|
|
16
|
-
name: 'test',
|
|
17
|
-
label: 'I choose to signup as',
|
|
18
|
-
color: '#272525' as FoundationTheme.PaletteColors,
|
|
19
|
-
helperText: 'help text for more information',
|
|
20
|
-
size: 24,
|
|
21
|
-
labelFontSize: 16,
|
|
22
|
-
additionalProps: {
|
|
23
|
-
testid: 'radio-group',
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
const onChange = jest.fn();
|
|
27
|
-
|
|
28
|
-
it('1. renders options correctly', () => {
|
|
29
|
-
render(<NsRadioGroup {...props} onChange={onChange} />);
|
|
30
|
-
|
|
31
|
-
options.forEach((option) => {
|
|
32
|
-
const radioOption = screen.getByLabelText(option.label) as HTMLInputElement;
|
|
33
|
-
expect(radioOption).toBeInTheDocument();
|
|
34
|
-
expect(radioOption.value).toBe(option.value);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
it('2. renders options correctly without additional slot', () => {
|
|
38
|
-
render(<NsRadioGroup {...props} onChange={onChange} helperText={''} />);
|
|
39
|
-
|
|
40
|
-
options.forEach((option) => {
|
|
41
|
-
const radioOption = screen.getByLabelText(option.label) as HTMLInputElement;
|
|
42
|
-
expect(radioOption).toBeInTheDocument();
|
|
43
|
-
expect(radioOption.value).toBe(option.value);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('3. calls OnChange when selecting option', () => {
|
|
48
|
-
render(<NsRadioGroup {...props} onChange={onChange} />);
|
|
49
|
-
|
|
50
|
-
const radioOption = screen.getByLabelText('Option 2') as HTMLInputElement;
|
|
51
|
-
fireEvent.click(radioOption);
|
|
52
|
-
expect(onChange).toHaveBeenCalledTimes(1);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('4. does not call Onchange when the same option is clicked', () => {
|
|
56
|
-
const onChange = jest.fn();
|
|
57
|
-
render(<NsRadioGroup {...props} onChange={onChange} />);
|
|
58
|
-
|
|
59
|
-
const radioOption = screen.getByLabelText('Option 1') as HTMLInputElement;
|
|
60
|
-
fireEvent.click(radioOption);
|
|
61
|
-
expect(onChange).not.toHaveBeenCalled();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
-
import { within, userEvent } from '@storybook/testing-library';
|
|
3
|
-
import { expect } from '@storybook/jest';
|
|
4
|
-
import { NsRadioGroup } from './';
|
|
5
|
-
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
6
|
-
|
|
7
|
-
type ComponentType = typeof NsRadioGroup;
|
|
8
|
-
type Story = StoryObj<ComponentType>;
|
|
9
|
-
type MetaStory = Meta<ComponentType>;
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
component: NsRadioGroup,
|
|
13
|
-
title: 'Components/Inputs/NsRadioGroup',
|
|
14
|
-
argTypes: {
|
|
15
|
-
disable: {
|
|
16
|
-
description: 'Indicates whether the radio button is enabled/disabled',
|
|
17
|
-
},
|
|
18
|
-
items: {
|
|
19
|
-
description: 'Value of the component to be emitted when selected.',
|
|
20
|
-
},
|
|
21
|
-
name: {
|
|
22
|
-
description: 'Name of the component',
|
|
23
|
-
},
|
|
24
|
-
label: {
|
|
25
|
-
description: 'Label of the radio group',
|
|
26
|
-
},
|
|
27
|
-
color: {
|
|
28
|
-
description: 'Color of the radio button',
|
|
29
|
-
},
|
|
30
|
-
size: {
|
|
31
|
-
description: 'Margin Left for Additional Slot text',
|
|
32
|
-
},
|
|
33
|
-
labelFontSize: {
|
|
34
|
-
description: 'Used to change font-size of the label',
|
|
35
|
-
},
|
|
36
|
-
helperText: {
|
|
37
|
-
description: 'An additional slot allows for more text',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
} as MetaStory;
|
|
41
|
-
|
|
42
|
-
export const RadioGroup: Story = {
|
|
43
|
-
args: {
|
|
44
|
-
disable: false,
|
|
45
|
-
items: [
|
|
46
|
-
{
|
|
47
|
-
id: 'individual',
|
|
48
|
-
label: `Vendeur à domicile indépendant mandataire (The VDI mandataire
|
|
49
|
-
enters into sales or service agreements
|
|
50
|
-
with customers in the name and on behalf of the company.
|
|
51
|
-
His remuneration will be based on commissions made
|
|
52
|
-
on the sales of products to customers.)`,
|
|
53
|
-
value: 'individual',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
id: ' retailer',
|
|
57
|
-
label: `Vendeur à domicile indépendant acheteur-revendeur
|
|
58
|
-
(The VDI acheteur-revendeur sells the company's products in his own name and behalf.
|
|
59
|
-
His remuneration will be based on commissions and on the margins made on the sales of
|
|
60
|
-
products to customers.)`,
|
|
61
|
-
value: 'retailer',
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
name: 'test',
|
|
65
|
-
label: 'I choose to signup as',
|
|
66
|
-
color: '#272525' as FoundationTheme.PaletteColors,
|
|
67
|
-
helperText: 'An additional slot allows for more text',
|
|
68
|
-
size: 10,
|
|
69
|
-
labelFontSize: 16,
|
|
70
|
-
additionalProps: {
|
|
71
|
-
testid: 'radio-group',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
play: async ({ canvasElement }) => {
|
|
75
|
-
const canvas = within(canvasElement);
|
|
76
|
-
await userEvent.hover(canvas.getByTestId('radio-group'));
|
|
77
|
-
await expect(
|
|
78
|
-
canvas.getByText(
|
|
79
|
-
// eslint-disable-next-line max-len
|
|
80
|
-
'Vendeur à domicile indépendant mandataire (The VDI mandataire enters into sales or service agreements with customers in the name and on behalf of the company. His remuneration will be based on commissions made on the sales of products to customers.)'
|
|
81
|
-
)
|
|
82
|
-
).toBeInTheDocument();
|
|
83
|
-
},
|
|
84
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Radio, FormControlLabel, FormLabel, RadioGroup } from '@mui/material';
|
|
2
|
-
import { ColorUtils, FoundationTheme, styled } from '@nuskin/foundation-theme';
|
|
3
|
-
|
|
4
|
-
const { paletteColor, isDarkMode, color } = ColorUtils;
|
|
5
|
-
|
|
6
|
-
export const StyledHelperText = styled('div')`
|
|
7
|
-
margin-top :10px;
|
|
8
|
-
padding-left: 0.5em;
|
|
9
|
-
text-align: left;
|
|
10
|
-
justify-self: flex-start;
|
|
11
|
-
)`;
|
|
12
|
-
|
|
13
|
-
export const StyledSpan = styled('span')`
|
|
14
|
-
font-size: '16px';
|
|
15
|
-
font-weight: 300;
|
|
16
|
-
color: ${paletteColor('primary')};
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
export const StyledLabel = styled(FormLabel)`
|
|
20
|
-
color: ${paletteColor('primary')},
|
|
21
|
-
marginBottom: '15px',
|
|
22
|
-
backgroundColor: 'transparent',
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
export const StyledRadio = styled(Radio)`
|
|
26
|
-
color: ${(props) => color('primary', !isDarkMode(props) ? 'black' : 'white')(props)};
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
export const StyledFormControlLabel = styled(FormControlLabel)<{ darkModeEnabled?: boolean }>((props) => {
|
|
30
|
-
return {
|
|
31
|
-
color: paletteColor('primary')(props),
|
|
32
|
-
marginBottom: '10px',
|
|
33
|
-
'.MuiFormControlLabel-label.Mui-disabled': {
|
|
34
|
-
color: `${color('neutral', !isDarkMode(props) ? 60 : 20)(props)}`,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
type StyledRadioPropsType = {
|
|
40
|
-
color: FoundationTheme.PaletteColors;
|
|
41
|
-
darkModeEnabled?: boolean;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const StyledRadioGroup = styled(RadioGroup)<StyledRadioPropsType>(({ theme, color, darkModeEnabled }) => {
|
|
45
|
-
return {
|
|
46
|
-
marginTop: '10px',
|
|
47
|
-
'.MuiRadio-root.custom-radio.Mui-checked': {
|
|
48
|
-
color: paletteColor(color)({ theme, darkModeEnabled }),
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import { FormControl } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
import { NsLabel } from '../label';
|
|
6
|
-
import {
|
|
7
|
-
StyledFormControlLabel,
|
|
8
|
-
StyledHelperText,
|
|
9
|
-
StyledRadio,
|
|
10
|
-
StyledRadioGroup,
|
|
11
|
-
StyledSpan,
|
|
12
|
-
} from './NsRadioGroup.styled';
|
|
13
|
-
import { NsRadioGroupProps } from './types';
|
|
14
|
-
|
|
15
|
-
const NsRadioGroup = (props: NsRadioGroupProps): ReactElement => {
|
|
16
|
-
const {
|
|
17
|
-
items,
|
|
18
|
-
helperText,
|
|
19
|
-
label,
|
|
20
|
-
onChange,
|
|
21
|
-
color,
|
|
22
|
-
disable,
|
|
23
|
-
size,
|
|
24
|
-
additionalProps,
|
|
25
|
-
labelFontSize,
|
|
26
|
-
darkModeEnabled = true,
|
|
27
|
-
row,
|
|
28
|
-
} = props;
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<>
|
|
32
|
-
<FormControl data-testid={additionalProps?.testid}>
|
|
33
|
-
<NsLabel size={labelFontSize as any}>{label}</NsLabel>
|
|
34
|
-
<StyledRadioGroup
|
|
35
|
-
row={row}
|
|
36
|
-
aria-labelledby="radio-buttons-group-label"
|
|
37
|
-
defaultValue={items?.[0]?.value}
|
|
38
|
-
name="radio-buttons-group"
|
|
39
|
-
onChange={onChange}
|
|
40
|
-
color={color}
|
|
41
|
-
darkModeEnabled={darkModeEnabled}
|
|
42
|
-
>
|
|
43
|
-
{items?.map((item, index) => (
|
|
44
|
-
<StyledFormControlLabel
|
|
45
|
-
id={`${index} `}
|
|
46
|
-
key={item?.id}
|
|
47
|
-
value={item?.value}
|
|
48
|
-
control={<StyledRadio className="custom-radio" />}
|
|
49
|
-
label={item?.label}
|
|
50
|
-
disabled={disable}
|
|
51
|
-
darkModeEnabled={darkModeEnabled}
|
|
52
|
-
/>
|
|
53
|
-
))}
|
|
54
|
-
</StyledRadioGroup>
|
|
55
|
-
</FormControl>
|
|
56
|
-
{helperText ? (
|
|
57
|
-
<StyledHelperText className={`ml-${size}`}>
|
|
58
|
-
<StyledSpan className="text-sm">{helperText}</StyledSpan>
|
|
59
|
-
</StyledHelperText>
|
|
60
|
-
) : null}
|
|
61
|
-
</>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export default NsRadioGroup;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
2
|
-
import { RadioGroupProps } from '@mui/material';
|
|
3
|
-
import { AdditionalProps } from '../common.types';
|
|
4
|
-
|
|
5
|
-
export type NsRadioGroupProps = Pick<RadioGroupProps, 'name' | 'onChange' | 'value' | 'defaultValue' | 'row'> & {
|
|
6
|
-
disable: boolean;
|
|
7
|
-
helperText: string;
|
|
8
|
-
label: string;
|
|
9
|
-
items: RadioItems[];
|
|
10
|
-
color: FoundationTheme.PaletteColors;
|
|
11
|
-
size: number;
|
|
12
|
-
labelFontSize: number;
|
|
13
|
-
} & AdditionalProps;
|
|
14
|
-
|
|
15
|
-
export type RadioItems = {
|
|
16
|
-
label: string;
|
|
17
|
-
value: string | number;
|
|
18
|
-
id: string | number;
|
|
19
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { render } from '@/test-utils/index';
|
|
2
|
-
import NsSearchBar from './NsSearchBar';
|
|
3
|
-
|
|
4
|
-
describe('Search Bar Component', () => {
|
|
5
|
-
it('1. should render Search Bar Component', () => {
|
|
6
|
-
const { container } = render(<NsSearchBar />);
|
|
7
|
-
expect(container).toBeInTheDocument();
|
|
8
|
-
});
|
|
9
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import InputBase from '@mui/material/InputBase';
|
|
4
|
-
import { styled } from '@nuskin/foundation-theme';
|
|
5
|
-
|
|
6
|
-
const Search = styled('div')`
|
|
7
|
-
position: relative;
|
|
8
|
-
borderRadius: 0;
|
|
9
|
-
border: 1px solid;
|
|
10
|
-
margin-left: 10px;
|
|
11
|
-
display: flex;
|
|
12
|
-
width: 100%;
|
|
13
|
-
)`;
|
|
14
|
-
|
|
15
|
-
const SearchIconWrapper = styled('div')`
|
|
16
|
-
height: 100%;
|
|
17
|
-
position: absolute;
|
|
18
|
-
pointer-events: none;
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
justify-content: center;
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
const StyledInputBase = styled(InputBase)(() => ({
|
|
25
|
-
color: 'inherit',
|
|
26
|
-
'& .MuiInputBase-input': {
|
|
27
|
-
padding: '1px 1px 1px 0',
|
|
28
|
-
paddingLeft: 'calc(1em + 10px)',
|
|
29
|
-
width: '100%',
|
|
30
|
-
},
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
const NsSearchBar = (): ReactElement => {
|
|
34
|
-
return (
|
|
35
|
-
<div>
|
|
36
|
-
<Search>
|
|
37
|
-
<SearchIconWrapper>
|
|
38
|
-
<span>search</span>
|
|
39
|
-
</SearchIconWrapper>
|
|
40
|
-
<StyledInputBase placeholder="Search…" inputProps={{ 'aria-label': 'search' }} />
|
|
41
|
-
</Search>
|
|
42
|
-
</div>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default NsSearchBar;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import NsSelectOption from './NsSelectOption';
|
|
4
|
-
import { RenderSelectOptionArgType } from './types';
|
|
5
|
-
|
|
6
|
-
export const DefaultRenderOption = (props: RenderSelectOptionArgType): ReactElement => {
|
|
7
|
-
return <NsSelectOption {...props} key={props?.value} onClick={props.onClick} index={props.index ?? 0} />;
|
|
8
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { ColorUtils, FoundationTheme, styled } from '@nuskin/foundation-theme';
|
|
2
|
-
import { HTMLAttributes } from 'react';
|
|
3
|
-
|
|
4
|
-
import { getDropdownHeadBorder } from '../dropdown/NsDropdown.styled';
|
|
5
|
-
|
|
6
|
-
const { paletteColor, themeColor } = ColorUtils;
|
|
7
|
-
|
|
8
|
-
interface SelectLabelProps extends HTMLAttributes<HTMLLabelElement> {
|
|
9
|
-
errorMessage?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const SelectContainer = styled.div<{ disabled: boolean; errorMessage?: string }>`
|
|
13
|
-
position: relative;
|
|
14
|
-
display: inline-block;
|
|
15
|
-
opacity: ${({ disabled }) => (disabled ? '0.5' : '1')};
|
|
16
|
-
color: ${({ theme, errorMessage }) =>
|
|
17
|
-
errorMessage ? paletteColor('error')({ theme }) : paletteColor('primary')({ theme })};
|
|
18
|
-
`;
|
|
19
|
-
export const SelectMain = styled.div`
|
|
20
|
-
position: relative;
|
|
21
|
-
display: flex;
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
export const ErrorContainer = styled.div`
|
|
25
|
-
color: ${paletteColor('error')};
|
|
26
|
-
`;
|
|
27
|
-
|
|
28
|
-
export const SelectHead = styled.div<{ type: string; disabled: boolean }>`
|
|
29
|
-
cursor: ${({ disabled }) => (disabled ? 'inherit' : 'pointer')};
|
|
30
|
-
padding: 5px 10px;
|
|
31
|
-
display: flex;
|
|
32
|
-
justify-content: space-between;
|
|
33
|
-
align-items: center;
|
|
34
|
-
border: ${getDropdownHeadBorder};
|
|
35
|
-
background: ${paletteColor('primary', 'contrastText')};
|
|
36
|
-
color: ${paletteColor('primary')};
|
|
37
|
-
width: 207px;
|
|
38
|
-
position: relative;
|
|
39
|
-
z-index: 2;
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
export const SelectButton = styled.div`
|
|
43
|
-
padding-right: 10px;
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
export const StyledArrowContainer = styled.div`
|
|
47
|
-
display: flex;
|
|
48
|
-
align-items: center;
|
|
49
|
-
padding-top: 30px;
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
|
-
export const SelectList = styled.div<{ borderColor: FoundationTheme.PaletteColors }>`
|
|
53
|
-
position: absolute;
|
|
54
|
-
z-index: 100;
|
|
55
|
-
border: 1px solid ${({ borderColor, theme }) => paletteColor(borderColor)({ theme })};
|
|
56
|
-
padding: 0;
|
|
57
|
-
margin: 0;
|
|
58
|
-
width: -webkit-fill-available;
|
|
59
|
-
color: ${paletteColor('primary', 'main')};
|
|
60
|
-
background-color: ${paletteColor('primary', 'contrastText')};
|
|
61
|
-
max-height: 200px;
|
|
62
|
-
overflow-y: auto;
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
|
-
export const SelectLabel = styled.label<SelectLabelProps>`
|
|
66
|
-
display: block;
|
|
67
|
-
margin-bottom: 5px;
|
|
68
|
-
color: ${({ theme, errorMessage }) =>
|
|
69
|
-
errorMessage ? paletteColor('error')({ theme }) : paletteColor('primary')({ theme })};
|
|
70
|
-
}
|
|
71
|
-
`;
|
|
72
|
-
type StyledSelectOptionType = { showListDivider: boolean };
|
|
73
|
-
export const StyledSelectOption = styled('div')<StyledSelectOptionType>(({ showListDivider, theme }) => {
|
|
74
|
-
const dividerColor = themeColor(
|
|
75
|
-
{ colorType: 'neutral', variant: '30' },
|
|
76
|
-
{ colorType: 'neutral', variant: '20' }
|
|
77
|
-
)({ theme });
|
|
78
|
-
const borderBottom = showListDivider ? dividerColor : 'none';
|
|
79
|
-
const hoveredBg = themeColor(
|
|
80
|
-
{ colorType: 'accentColorB', variant: '20' },
|
|
81
|
-
{ colorType: 'accentColorB', variant: '40' }
|
|
82
|
-
)({ theme });
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
cursor: 'pointer',
|
|
86
|
-
borderBottom: `1px solid ${borderBottom}`,
|
|
87
|
-
backgroundColor: 'white',
|
|
88
|
-
color: 'black',
|
|
89
|
-
padding: '5px 10px',
|
|
90
|
-
'&.selected-option': {
|
|
91
|
-
backgroundColor: paletteColor('accentColorA')({ theme }),
|
|
92
|
-
color: 'white',
|
|
93
|
-
},
|
|
94
|
-
'&:hover': {
|
|
95
|
-
color: 'white',
|
|
96
|
-
backgroundColor: hoveredBg,
|
|
97
|
-
},
|
|
98
|
-
'&:last-child': {
|
|
99
|
-
borderBottom: 'none',
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
});
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
MouseEvent,
|
|
3
|
-
ReactElement,
|
|
4
|
-
useCallback,
|
|
5
|
-
useMemo,
|
|
6
|
-
useRef,
|
|
7
|
-
useState,
|
|
8
|
-
} from 'react';
|
|
9
|
-
|
|
10
|
-
import { useOnClickOutside } from '../hooks/useOnClickOutside';
|
|
11
|
-
import { NsIcon } from '../icon';
|
|
12
|
-
import { Show } from '../utility';
|
|
13
|
-
import {
|
|
14
|
-
arrowVisibility,
|
|
15
|
-
factorMap,
|
|
16
|
-
} from './constant';
|
|
17
|
-
import { DefaultRenderOption } from './DefaultRenderOption';
|
|
18
|
-
import {
|
|
19
|
-
ErrorContainer,
|
|
20
|
-
SelectButton,
|
|
21
|
-
SelectContainer,
|
|
22
|
-
SelectHead,
|
|
23
|
-
SelectLabel,
|
|
24
|
-
SelectList,
|
|
25
|
-
SelectMain,
|
|
26
|
-
StyledArrowContainer,
|
|
27
|
-
} from './NsSelect.styled';
|
|
28
|
-
import {
|
|
29
|
-
LabelValueType,
|
|
30
|
-
SelectProps,
|
|
31
|
-
} from './types.d';
|
|
32
|
-
|
|
33
|
-
const NsSelect: React.FC<SelectProps> = ({
|
|
34
|
-
selected,
|
|
35
|
-
onSelect,
|
|
36
|
-
disabled = false,
|
|
37
|
-
type = 'outlined',
|
|
38
|
-
placeholder = '',
|
|
39
|
-
selectBorderColor = 'accentColorB',
|
|
40
|
-
closeOnMouseLeave = false,
|
|
41
|
-
showListDivider = true,
|
|
42
|
-
label,
|
|
43
|
-
readOnly = false,
|
|
44
|
-
errorMessage,
|
|
45
|
-
hasArrows,
|
|
46
|
-
// eslint-disable-next-line no-unused-vars
|
|
47
|
-
rules,
|
|
48
|
-
reverseArrowControls,
|
|
49
|
-
RenderOption = DefaultRenderOption,
|
|
50
|
-
options,
|
|
51
|
-
}): ReactElement => {
|
|
52
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
53
|
-
const optionIndex = useMemo(() => {
|
|
54
|
-
if (typeof selected?.index === 'number') return selected.index;
|
|
55
|
-
return options.findIndex((option) => option.value === selected.value);
|
|
56
|
-
}, [options, selected]);
|
|
57
|
-
const [value, setValue] = useState<LabelValueType>({ ...selected, index: optionIndex });
|
|
58
|
-
const selectContainerRef = useRef<HTMLDivElement>(null);
|
|
59
|
-
const selectHeadRef = useRef<HTMLDivElement>(null);
|
|
60
|
-
|
|
61
|
-
const closeMenuOnMouseLeave = useCallback(() => {
|
|
62
|
-
if (closeOnMouseLeave) {
|
|
63
|
-
setIsOpen(false);
|
|
64
|
-
}
|
|
65
|
-
}, [closeOnMouseLeave]);
|
|
66
|
-
|
|
67
|
-
const handleSelect = (val: LabelValueType) => {
|
|
68
|
-
onSelect(val);
|
|
69
|
-
setIsOpen(false);
|
|
70
|
-
setValue(val);
|
|
71
|
-
};
|
|
72
|
-
const closeMenu = useCallback(() => {
|
|
73
|
-
setIsOpen(false);
|
|
74
|
-
}, []);
|
|
75
|
-
useOnClickOutside(selectContainerRef.current, closeMenu);
|
|
76
|
-
|
|
77
|
-
const handleMouseClick = () => {
|
|
78
|
-
if (disabled) return;
|
|
79
|
-
setIsOpen(!isOpen);
|
|
80
|
-
if (!isOpen) {
|
|
81
|
-
setTimeout(() => {
|
|
82
|
-
selectHeadRef.current?.focus();
|
|
83
|
-
}, 0);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
const handleArrowClick = (event: MouseEvent) => {
|
|
87
|
-
const direction = event.currentTarget?.className.includes('Right') ? 'right' : 'left';
|
|
88
|
-
const adder = factorMap[reverseArrowControls ? 'reverse' : 'forward'][direction];
|
|
89
|
-
const nextIndex = (selected?.index ?? -1) + adder;
|
|
90
|
-
if (nextIndex > -1 && nextIndex < options.length) {
|
|
91
|
-
handleSelect({ ...options[nextIndex], index: nextIndex });
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
return (
|
|
95
|
-
<SelectMain>
|
|
96
|
-
{hasArrows && (
|
|
97
|
-
<StyledArrowContainer
|
|
98
|
-
onClick={handleArrowClick}
|
|
99
|
-
className="LeftArrow"
|
|
100
|
-
style={{
|
|
101
|
-
visibility: arrowVisibility(options.length, 'left', reverseArrowControls, value?.index),
|
|
102
|
-
}}
|
|
103
|
-
>
|
|
104
|
-
<NsIcon name="arrowLeft" color="primary" />
|
|
105
|
-
</StyledArrowContainer>
|
|
106
|
-
)}
|
|
107
|
-
<SelectContainer
|
|
108
|
-
data-testid="select-container"
|
|
109
|
-
disabled={disabled || readOnly}
|
|
110
|
-
ref={selectContainerRef}
|
|
111
|
-
errorMessage={errorMessage}
|
|
112
|
-
>
|
|
113
|
-
{label && <SelectLabel errorMessage={errorMessage}>{label}</SelectLabel>}
|
|
114
|
-
<SelectHead
|
|
115
|
-
data-testid="select-head"
|
|
116
|
-
disabled={disabled || readOnly}
|
|
117
|
-
type={type}
|
|
118
|
-
onMouseDown={handleMouseClick}
|
|
119
|
-
tabIndex={0}
|
|
120
|
-
ref={selectHeadRef}
|
|
121
|
-
>
|
|
122
|
-
<SelectButton>{value?.label || placeholder}</SelectButton>
|
|
123
|
-
{!readOnly && <NsIcon name={isOpen ? 'arrowUp' : 'arrowDown'} color="primary" />}
|
|
124
|
-
</SelectHead>
|
|
125
|
-
<Show when={isOpen}>
|
|
126
|
-
<SelectList
|
|
127
|
-
data-testid="select-menu-list"
|
|
128
|
-
onMouseLeave={closeMenuOnMouseLeave}
|
|
129
|
-
borderColor={selectBorderColor}
|
|
130
|
-
className="selectList"
|
|
131
|
-
>
|
|
132
|
-
{options.map((opt, optionIndex) => {
|
|
133
|
-
return (
|
|
134
|
-
<RenderOption
|
|
135
|
-
key={opt.value}
|
|
136
|
-
value={opt.value}
|
|
137
|
-
label={opt.label}
|
|
138
|
-
index={optionIndex}
|
|
139
|
-
onClick={() =>
|
|
140
|
-
handleSelect({ label: opt.label, value: opt.value, index: optionIndex })
|
|
141
|
-
}
|
|
142
|
-
selected={value}
|
|
143
|
-
showListDivider={showListDivider}
|
|
144
|
-
/>
|
|
145
|
-
);
|
|
146
|
-
})}
|
|
147
|
-
</SelectList>
|
|
148
|
-
</Show>
|
|
149
|
-
{errorMessage && <ErrorContainer>{errorMessage}</ErrorContainer>}
|
|
150
|
-
</SelectContainer>
|
|
151
|
-
{hasArrows && (
|
|
152
|
-
<StyledArrowContainer
|
|
153
|
-
onClick={handleArrowClick}
|
|
154
|
-
className="RightArrow"
|
|
155
|
-
style={{
|
|
156
|
-
visibility: arrowVisibility(options.length, 'right', reverseArrowControls, selected?.index),
|
|
157
|
-
}}
|
|
158
|
-
>
|
|
159
|
-
<NsIcon name="arrowRight" color="primary" />
|
|
160
|
-
</StyledArrowContainer>
|
|
161
|
-
)}
|
|
162
|
-
</SelectMain>
|
|
163
|
-
);
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
export default NsSelect;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
2
|
-
|
|
3
|
-
import { StyledSelectOption } from './NsSelect.styled';
|
|
4
|
-
import { SelectOptionProps } from './types.d';
|
|
5
|
-
|
|
6
|
-
export const NsSelectOption: React.FC<SelectOptionProps> = ({
|
|
7
|
-
value,
|
|
8
|
-
label,
|
|
9
|
-
onClick,
|
|
10
|
-
selected,
|
|
11
|
-
showListDivider = true,
|
|
12
|
-
}): ReactElement => {
|
|
13
|
-
const isSelected = value === selected?.value;
|
|
14
|
-
return (
|
|
15
|
-
<StyledSelectOption
|
|
16
|
-
className={isSelected ? 'selected-option' : ''}
|
|
17
|
-
data-testid={`option-${value}`}
|
|
18
|
-
showListDivider={showListDivider}
|
|
19
|
-
onClick={onClick}
|
|
20
|
-
>
|
|
21
|
-
{label}
|
|
22
|
-
</StyledSelectOption>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
export default NsSelectOption;
|
|
26
|
-
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const factorMap: any = {
|
|
2
|
-
reverse: {
|
|
3
|
-
right: -1,
|
|
4
|
-
left: 1,
|
|
5
|
-
},
|
|
6
|
-
forward: {
|
|
7
|
-
right: 1,
|
|
8
|
-
left: -1,
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const arrowVisibility = (
|
|
13
|
-
total: number,
|
|
14
|
-
direction: 'left' | 'right',
|
|
15
|
-
reverse: boolean = false,
|
|
16
|
-
currentIndex: number | undefined = -1
|
|
17
|
-
) => {
|
|
18
|
-
if (direction === 'left') {
|
|
19
|
-
if (!reverse) {
|
|
20
|
-
return currentIndex < 1 ? 'hidden' : 'visible';
|
|
21
|
-
} else {
|
|
22
|
-
return currentIndex >= total - 1 ? 'hidden' : 'visible';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (!reverse) {
|
|
26
|
-
return currentIndex >= total - 1 ? 'hidden' : 'visible';
|
|
27
|
-
} else {
|
|
28
|
-
return currentIndex < 1 ? 'hidden' : 'visible';
|
|
29
|
-
}
|
|
30
|
-
};
|