@nuskin/foundation-ui-components 1.0.0-develop.1 → 1.0.0-develop.11

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.
Files changed (250) hide show
  1. package/package.json +21 -11
  2. package/src/common/accordion/NsAccordion.tsx +69 -0
  3. package/src/common/accordion/NsAccordionHeader.tsx +77 -0
  4. package/src/common/accordion/NsAccordionItem.tsx +59 -0
  5. package/src/common/accordion/NsCollapse.tsx +117 -0
  6. package/src/common/accordion/NsToggleSection.tsx +43 -0
  7. package/src/common/accordion/ToggleSection.styled.tsx +32 -0
  8. package/src/common/accordion/colorMap.ts +117 -0
  9. package/src/common/accordion/enums.ts +18 -0
  10. package/src/common/accordion/index.ts +7 -0
  11. package/src/common/accordion/specs/NsAccordion.spec.tsx +163 -0
  12. package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +130 -0
  13. package/src/common/accordion/specs/NsAccordionItem.spec.tsx +79 -0
  14. package/src/common/accordion/specs/NsCollapse.spec.tsx +129 -0
  15. package/src/common/accordion/specs/NsToggleSection.spec.tsx +74 -0
  16. package/src/common/accordion/stories/NsAccordion.stories.tsx +65 -0
  17. package/src/common/accordion/stories/NsAccordionHeader.stories.tsx +44 -0
  18. package/src/common/accordion/stories/NsAccordionItem.stories.tsx +45 -0
  19. package/src/common/accordion/stories/NsCollapse.stories.tsx +50 -0
  20. package/src/common/accordion/stories/NsToggleSection.stories.tsx +26 -0
  21. package/src/common/accordion/stories/data.tsx +143 -0
  22. package/src/common/accordion/types.d.ts +81 -0
  23. package/src/common/alert/Header.tsx +29 -0
  24. package/src/common/alert/NsAlert.spec.tsx +62 -29
  25. package/src/common/alert/NsAlert.stories.tsx +18 -17
  26. package/src/common/alert/NsAlert.styled.tsx +124 -0
  27. package/src/common/alert/NsAlert.tsx +27 -110
  28. package/src/common/alert/index.ts +2 -2
  29. package/src/common/alert/types.d.ts +23 -23
  30. package/src/common/auth-dropdown/NsAuthDropdown.spec.tsx +24 -6
  31. package/src/common/auth-dropdown/NsAuthDropdown.stories.tsx +2 -2
  32. package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +21 -16
  33. package/src/common/auth-dropdown/NsAuthDropdown.tsx +7 -6
  34. package/src/common/auth-dropdown/index.ts +1 -1
  35. package/src/common/auth-dropdown/types.d.ts +3 -1
  36. package/src/common/autocomplete/NsAutocomplete.spec.tsx +69 -24
  37. package/src/common/autocomplete/NsAutocomplete.stories.tsx +64 -7
  38. package/src/common/autocomplete/NsAutocomplete.styled.tsx +12 -0
  39. package/src/common/autocomplete/NsAutocomplete.tsx +100 -46
  40. package/src/common/autocomplete/index.ts +2 -1
  41. package/src/common/autocomplete/mock/MockData.ts +50 -7
  42. package/src/common/autocomplete/mock/MockUI.tsx +2 -1
  43. package/src/common/autocomplete/{types.ts → types.d.ts} +18 -8
  44. package/src/common/banner/NsBanner.spec.tsx +13 -4
  45. package/src/common/banner/NsBanner.stories.tsx +2 -2
  46. package/src/common/banner/NsBanner.styled.tsx +1 -1
  47. package/src/common/banner/NsBanner.tsx +1 -1
  48. package/src/common/banner/index.ts +1 -1
  49. package/src/common/brand-components/NsBrand.stories.tsx +2 -2
  50. package/src/common/brand-components/NsBrandComponent.tsx +6 -3
  51. package/src/common/brand-components/index.ts +1 -1
  52. package/src/common/breadcrumb/NsBreadcrumb.spec.tsx +8 -9
  53. package/src/common/breadcrumb/NsBreadcrumb.stories.tsx +3 -5
  54. package/src/common/breadcrumb/NsBreadcrumb.tsx +5 -3
  55. package/src/common/breadcrumb/data.ts +10 -0
  56. package/src/common/breadcrumb/index.ts +1 -1
  57. package/src/common/button/NsButton.spec.tsx +66 -51
  58. package/src/common/button/NsButton.stories.tsx +61 -4
  59. package/src/common/button/NsButton.styled.tsx +54 -72
  60. package/src/common/button/NsButton.tsx +9 -3
  61. package/src/common/button/helper.ts +82 -0
  62. package/src/common/button/index.ts +1 -1
  63. package/src/common/button/types.d.ts +3 -0
  64. package/src/common/card/NsFfgCard.tsx +14 -8
  65. package/src/common/card/specs/NsFfgCard.spec.tsx +33 -0
  66. package/src/common/card/stories/NsBgCard.stories.tsx +2 -4
  67. package/src/common/card/stories/NsBrandProductCard.stories.tsx +2 -2
  68. package/src/common/card/stories/NsFfgCard.stories.tsx +49 -16
  69. package/src/common/card/stories/{data.js → data.ts} +1 -25
  70. package/src/common/card/styled/NsFfgStyled.tsx +9 -7
  71. package/src/common/card/types.d.ts +7 -4
  72. package/src/common/carousal/NsScrollingCarousal.tsx +61 -0
  73. package/src/common/carousal/index.ts +3 -0
  74. package/src/common/carousal/{tests → specs}/NsCarousal.spec.tsx +2 -2
  75. package/src/common/carousal/specs/NsScrollingCarousal.spec.tsx +61 -0
  76. package/src/common/carousal/stories/NSCarousal.stories.tsx +2 -2
  77. package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +52 -0
  78. package/src/common/carousal/types.d.ts +23 -0
  79. package/src/common/cart-icon/NsCartIcon.spec.tsx +6 -17
  80. package/src/common/cart-icon/NsCartIcon.stories.tsx +3 -3
  81. package/src/common/cart-icon/NsCartIcon.styled.ts +7 -33
  82. package/src/common/cart-icon/NsCartIcon.tsx +6 -15
  83. package/src/common/cart-icon/index.ts +1 -1
  84. package/src/common/cart-icon/types.d.ts +1 -0
  85. package/src/common/checkbox/NsCheckbox.spec.tsx +2 -2
  86. package/src/common/checkbox/NsCheckbox.stories.tsx +2 -2
  87. package/src/common/checkbox/NsCheckbox.styled.tsx +15 -16
  88. package/src/common/checkbox/NsCheckbox.tsx +2 -2
  89. package/src/common/checkbox/index.ts +1 -1
  90. package/src/common/checkbox/types.d.ts +1 -7
  91. package/src/common/column-control/NsColumnControl.tsx +1 -1
  92. package/src/common/column-control/NsFlexColumns.tsx +22 -0
  93. package/src/common/column-control/NsGridColumns.tsx +22 -0
  94. package/src/common/column-control/index.ts +3 -1
  95. package/src/common/column-control/{NsColumnControl.spec.tsx → specs/NsColumnControl.spec.tsx} +3 -3
  96. package/src/common/column-control/specs/NsFlexColumns.spec.tsx +24 -0
  97. package/src/common/column-control/specs/NsGridColumns.spec.tsx +24 -0
  98. package/src/common/column-control/stories/DivArray.stories.tsx +18 -0
  99. package/src/common/column-control/stories/DivArray.tsx +63 -0
  100. package/src/common/column-control/{NsColumnControl.stories.tsx → stories/NsColumnControl.stories.tsx} +9 -16
  101. package/src/common/column-control/stories/NsFlexColumns.stories.tsx +63 -0
  102. package/src/common/column-control/stories/NsGridColumns.stories.tsx +63 -0
  103. package/src/common/column-control/stories/common.tsx +14 -0
  104. package/src/common/column-control/styled/StyledFlex.tsx +45 -0
  105. package/src/common/column-control/styled/StyledGrid.tsx +40 -0
  106. package/src/common/column-control/styled/common.ts +27 -0
  107. package/src/common/column-control/types.d.ts +15 -16
  108. package/src/common/column-control/utils.ts +5 -5
  109. package/src/common/common.types.d.ts +21 -0
  110. package/src/common/dropdown/NsDropdown.spec.tsx +1 -1
  111. package/src/common/dropdown/NsDropdown.styled.tsx +23 -18
  112. package/src/common/dropdown/NsDropdown.tsx +1 -1
  113. package/src/common/dropdown/NsDropdownOption.tsx +1 -1
  114. package/src/common/dropdown/index.ts +1 -1
  115. package/src/common/dropdown/stories/NsDropdown.stories.tsx +2 -2
  116. package/src/common/dropdown/stories/NsDropdownCountry.stories.tsx +2 -2
  117. package/src/common/dropdown/types.d.ts +3 -1
  118. package/src/common/email-simple/NsEmailSimple.spec.tsx +145 -0
  119. package/src/common/email-simple/NsEmailSimple.stories.tsx +61 -0
  120. package/src/common/email-simple/NsEmailSimple.tsx +71 -0
  121. package/src/common/email-simple/index.ts +2 -0
  122. package/src/common/email-simple/types.d.ts +14 -0
  123. package/src/common/flag/NsFlag.spec.tsx +5 -25
  124. package/src/common/flag/NsFlag.stories.tsx +2 -2
  125. package/src/common/flag/NsFlag.styled.tsx +7 -9
  126. package/src/common/flag/NsFlag.tsx +1 -3
  127. package/src/common/flag/index.ts +1 -1
  128. package/src/common/flag/types.d.ts +0 -2
  129. package/src/common/hooks/index.ts +2 -0
  130. package/src/common/hooks/specs/useWindowSize.spec.tsx +19 -0
  131. package/src/common/hooks/useAccordionMap.tsx +39 -0
  132. package/src/common/hooks/useWindowSize.tsx +30 -0
  133. package/src/common/icon/NsIcon.spec.tsx +1 -1
  134. package/src/common/icon/NsIcon.stories.tsx +2 -2
  135. package/src/common/icon/NsIcon.styled.tsx +1 -1
  136. package/src/common/icon/NsIcon.tsx +1 -1
  137. package/src/common/icon/NsIconVariants.ts +9 -4
  138. package/src/common/icon/icons/AlertErrorIcon.tsx +15 -6
  139. package/src/common/icon/icons/Cart.tsx +7 -32
  140. package/src/common/icon/icons/HamburgerIcon.tsx +29 -0
  141. package/src/common/icon/icons/UserIcon.tsx +30 -0
  142. package/src/common/icon/icons/WarningIcon.tsx +14 -5
  143. package/src/common/icon/index.ts +1 -1
  144. package/src/common/icon/types.d.ts +1 -0
  145. package/src/common/image/NsImage.spec.tsx +57 -7
  146. package/src/common/image/NsImage.stories.tsx +2 -2
  147. package/src/common/image/NsImage.tsx +24 -12
  148. package/src/common/image/NsNextImage.spec.tsx +1 -1
  149. package/src/common/image/NsNextImage.stories.tsx +2 -2
  150. package/src/common/image/NsNextImage.tsx +1 -1
  151. package/src/common/image/index.ts +1 -1
  152. package/src/common/image/types.d.ts +1 -0
  153. package/src/common/index.ts +14 -10
  154. package/src/common/input/InputFieldWrapper.tsx +4 -4
  155. package/src/common/input/InputWrapper.tsx +12 -7
  156. package/src/common/input/NsInputField.stories.tsx +13 -10
  157. package/src/common/input/NsInputField.tsx +13 -6
  158. package/src/common/input/getAdornmentProps.tsx +5 -1
  159. package/src/common/input/index.ts +1 -1
  160. package/src/common/input/types.d.ts +18 -1
  161. package/src/common/label/NsLabel.stories.tsx +6 -1
  162. package/src/common/label/NsLabel.tsx +21 -20
  163. package/src/common/label/index.ts +1 -1
  164. package/src/common/label/types.d.ts +2 -1
  165. package/src/common/link/NsLink.spec.tsx +1 -1
  166. package/src/common/link/NsLink.stories.tsx +2 -2
  167. package/src/common/link/NsLink.tsx +1 -1
  168. package/src/common/link/index.ts +1 -1
  169. package/src/common/modal/NsModal.spec.tsx +46 -0
  170. package/src/common/modal/NsModal.styled.tsx +28 -0
  171. package/src/common/modal/NsModal.tsx +37 -0
  172. package/src/common/modal/helper-component/NsModalContentBox.tsx +32 -0
  173. package/src/common/modal/helper-component/NsModalDefault.tsx +25 -0
  174. package/src/common/modal/helper-component/NsModalStatus.tsx +15 -0
  175. package/src/common/modal/helper-component/NsModalStatusIcon.tsx +14 -0
  176. package/src/common/modal/helper-component/NsModalTitle.tsx +26 -0
  177. package/src/common/modal/index.ts +2 -0
  178. package/src/common/modal/model/NsModalVariantMap.tsx +24 -0
  179. package/src/common/modal/stories/NsModal.stories.tsx +86 -0
  180. package/src/common/modal/stories/mock.tsx +46 -0
  181. package/src/common/modal/types.ts +56 -0
  182. package/src/common/nav-product-card/NsNavProductCard.spec.tsx +1 -1
  183. package/src/common/nav-product-card/NsNavProductCard.stories.tsx +2 -2
  184. package/src/common/nav-product-card/NsNavProductCard.tsx +1 -1
  185. package/src/common/nav-product-card/index.ts +1 -1
  186. package/src/common/nav-tab/NsNavTab.spec.tsx +2 -7
  187. package/src/common/nav-tab/NsNavTab.stories.tsx +2 -2
  188. package/src/common/nav-tab/NsNavTab.styled.tsx +7 -4
  189. package/src/common/nav-tab/NsNavTab.tsx +1 -1
  190. package/src/common/nav-tab/index.ts +1 -1
  191. package/src/common/nav-tab/types.d.ts +2 -2
  192. package/src/common/radiogroup/NsRadioGroup.spec.tsx +63 -0
  193. package/src/common/radiogroup/NsRadioGroup.stories.tsx +84 -0
  194. package/src/common/radiogroup/NsRadioGroup.styled.tsx +52 -0
  195. package/src/common/radiogroup/NsRadioGroup.tsx +62 -0
  196. package/src/common/radiogroup/index.ts +2 -0
  197. package/src/common/radiogroup/types.d.ts +20 -0
  198. package/src/common/search-bar/NsSeachBar.spec.tsx +1 -1
  199. package/src/common/search-bar/NsSearchBar.tsx +1 -3
  200. package/src/common/select/NsSelect.spec.tsx +193 -0
  201. package/src/common/select/NsSelect.styled.tsx +104 -0
  202. package/src/common/select/NsSelect.tsx +117 -0
  203. package/src/common/select/NsSelectOption.tsx +30 -0
  204. package/src/common/select/index.ts +3 -0
  205. package/src/common/select/stories/NsSelect.stories.tsx +134 -0
  206. package/src/common/select/types.d.ts +34 -0
  207. package/src/common/spinner/NsSpinner.spec.tsx +21 -0
  208. package/src/common/spinner/NsSpinner.stories.tsx +26 -0
  209. package/src/common/spinner/NsSpinner.styled.tsx +344 -0
  210. package/src/common/spinner/NsSpinner.tsx +14 -0
  211. package/src/common/spinner/icons/Spinner.tsx +161 -0
  212. package/src/common/spinner/index.ts +2 -0
  213. package/src/common/spinner/types.ts +5 -0
  214. package/src/common/table/NsExpandableRow.tsx +68 -0
  215. package/src/common/table/NsTable.spec.tsx +174 -0
  216. package/src/common/table/NsTable.stories.tsx +161 -0
  217. package/src/common/table/NsTable.styled.ts +127 -0
  218. package/src/common/table/NsTable.tsx +133 -0
  219. package/src/common/table/NsTableHeader.tsx +41 -0
  220. package/src/common/table/NsTablePagination.tsx +28 -0
  221. package/src/common/table/helper.ts +33 -0
  222. package/src/common/table/index.ts +2 -0
  223. package/src/common/table/types.d.ts +57 -0
  224. package/src/common/text-strip/NsTextStrip.spec.tsx +30 -0
  225. package/src/common/text-strip/NsTextStrip.stories.tsx +33 -0
  226. package/src/common/text-strip/NsTextStrip.tsx +47 -0
  227. package/src/common/text-strip/index.ts +2 -0
  228. package/src/common/text-strip/types.d.ts +17 -0
  229. package/src/common/typography/NsTypography.stories.tsx +2 -2
  230. package/src/common/typography/NsTypography.tsx +1 -1
  231. package/src/common/typography/Typography.styled.tsx +4 -4
  232. package/src/common/typography/index.ts +1 -1
  233. package/src/common/util.ts +1 -0
  234. package/src/common/utility/Show.tsx +13 -0
  235. package/src/common/utility/index.ts +1 -0
  236. package/src/common/validations/regex.ts +3 -0
  237. package/src/common/videos/NsVideo.stories.tsx +2 -2
  238. package/src/common/videos/NsVideo.tsx +1 -1
  239. package/src/common/videos/index.ts +1 -1
  240. package/src/common/videos/types.d.ts +1 -1
  241. package/src/common/alert/NsAlert.styled.ts +0 -124
  242. package/src/common/card/tests/NsFfgCard.spec.tsx +0 -23
  243. package/src/common/column-control/NDivs.story.tsx +0 -35
  244. package/src/common/common.types.ts +0 -10
  245. /package/src/common/brand-components/{NsBrandContanier.styled.tsx → NsBrandContainer.styled.tsx} +0 -0
  246. /package/src/common/card/{tests → specs}/BrandLogo.spec.tsx +0 -0
  247. /package/src/common/card/{tests → specs}/NsBgCard.spec.tsx +0 -0
  248. /package/src/common/card/{tests → specs}/NsBrandProductCard.spec.tsx +0 -0
  249. /package/src/common/carousal/{tests → specs}/Chevron.spec.tsx +0 -0
  250. /package/src/common/carousal/{tests → specs}/RenderBrand.spec.tsx +0 -0
@@ -1,29 +1,18 @@
1
1
  import { NsCartIcon } from './';
2
- import { render, screen } from '../../../test-utils';
2
+ import { render, screen } from '@/test-utils/index';
3
3
 
4
4
  const { getByTestId } = screen;
5
5
  describe('NsCartIcon', () => {
6
6
  it('renders Cart icon when item count is 0', () => {
7
7
  render(<NsCartIcon itemCount={0} color="primary" size="large" />);
8
- const cartIcon = getByTestId('cart-icon');
8
+ const cartIcon = getByTestId('cart-badge-icon');
9
9
  expect(cartIcon).toBeInTheDocument();
10
10
  });
11
- it('renders Cart icon with optional values', () => {
12
- render(<NsCartIcon itemCount={0} />);
13
- const cartIcon = getByTestId('cart-icon');
14
- expect(cartIcon).toBeInTheDocument();
15
- });
16
-
17
- it('renders Cart Badge icon when item count is greater than 0', () => {
18
- render(<NsCartIcon itemCount={5} color="primary" size="large" />);
19
- const cartBadgeIcon = getByTestId('cart-badge-icon');
20
- expect(cartBadgeIcon).toBeInTheDocument();
21
- });
22
11
 
23
12
  it('renders item count badge when item count is greater than 0', () => {
24
- render(<NsCartIcon itemCount={5} color="primary" size="large" />);
25
- const itemCountBadge = getByTestId('item-count-badge');
26
- expect(itemCountBadge).toBeInTheDocument();
27
- expect(itemCountBadge.textContent).toBe('5');
13
+ const itemCount = 5;
14
+ const { getByText } = render(<NsCartIcon itemCount={5} color="primary" size="large" />);
15
+ const badgeContentElement = getByText(itemCount.toString());
16
+ expect(badgeContentElement).toHaveTextContent('5'); // Adjust the value as per your badge content
28
17
  });
29
18
  });
@@ -1,5 +1,5 @@
1
1
  import type { StoryObj, Meta } from '@storybook/react';
2
- import { withCenterDecorator } from '../../stories/decorators/withCenterDecorator';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
3
  import { NsCartIcon } from './';
4
4
 
5
5
  type ComponentType = typeof NsCartIcon;
@@ -7,7 +7,7 @@ type Story = StoryObj<ComponentType>;
7
7
  type MetaStory = Meta<ComponentType>;
8
8
 
9
9
  export default {
10
- title: 'Components/NsCartIcon',
10
+ title: 'Components/Data Display/NsCartIcon',
11
11
  component: NsCartIcon,
12
12
  decorators: [withCenterDecorator],
13
13
  argTypes: {
@@ -19,7 +19,7 @@ export default {
19
19
  },
20
20
  },
21
21
  args: {
22
- itemCount: 1,
22
+ itemCount: 5,
23
23
  color: 'primary',
24
24
  size: 'large',
25
25
  },
@@ -1,40 +1,14 @@
1
- import { Theme } from '@mui/material';
1
+ import { Badge, Theme } from '@mui/material';
2
2
  import { styled, FoundationTheme } from '@nuskin/foundation-theme';
3
- import { NsIconSizeType } from '../icon/types';
4
3
 
5
4
  type ItemCountParams = {
6
- size: NsIconSizeType;
7
- color: FoundationTheme.PaletteColors;
8
5
  theme?: Theme;
6
+ bgcolor: FoundationTheme.PaletteColors;
9
7
  };
10
8
 
11
- export const CartIconContainer = styled.div`
12
- position: relative;
13
- display: inline-block;
14
- `;
15
-
16
- const BadgeFontSizeMap = {
17
- small: '8px',
18
- medium: '10px',
19
- large: '12px',
20
- xLarge: '14px',
21
- };
22
-
23
- const BadgePosMap = {
24
- small: '-8px',
25
- medium: '-6px',
26
- large: '-4px',
27
- xLarge: '-1px',
28
- };
29
-
30
- export const ItemCount = styled.span<ItemCountParams>`
31
- color: ${({ color, theme }) => theme?.palette?.[color]?.main};
32
- font-size: ${({ size }) => BadgeFontSizeMap[size]};
33
- right: ${({ size }) => BadgePosMap[size]};
34
- text-align: center;
35
- font-weight: 600;
36
- position: absolute;
37
- width: 32px;
38
- height: auto;
39
- top: -4px;
9
+ export const StyledBadge = styled(Badge) <ItemCountParams>`
10
+ & .MuiBadge-badge {
11
+ background-color: ${({ bgcolor, theme }) => theme?.palette?.[bgcolor]?.main};
12
+ color: ${({ bgcolor, theme }) => theme?.palette?.[bgcolor]?.contrastText};
13
+ }
40
14
  `;
@@ -1,21 +1,12 @@
1
1
  import { NsIcon } from '../icon';
2
- import { CartIconContainer, ItemCount } from './NsCartIcon.styled';
3
- import { NsCartIconProps } from './types';
2
+ import { StyledBadge } from './NsCartIcon.styled';
3
+ import { NsCartIconProps } from './types.d';
4
4
 
5
- const NsCartIcon = ({ itemCount, size = 'large', color = 'primary' }: NsCartIconProps) => {
5
+ const NsCartIcon = ({ itemCount = 0, size = 'large', color = 'primary', maxItemCount = 999 }: NsCartIconProps) => {
6
6
  return (
7
- <CartIconContainer>
8
- {itemCount > 0 ? (
9
- <NsIcon testId="cart-badge-icon" name="cartBadge" color={color} size={size} />
10
- ) : (
11
- <NsIcon testId="cart-icon" name="cart" color={color} size={size} />
12
- )}
13
- {itemCount > 0 && (
14
- <ItemCount data-testid="item-count-badge" color={color} size={size}>
15
- {itemCount}
16
- </ItemCount>
17
- )}
18
- </CartIconContainer>
7
+ <StyledBadge badgeContent={itemCount} max={maxItemCount} bgcolor={color}>
8
+ <NsIcon testId="cart-badge-icon" name="cart" size={size} color={color} />
9
+ </StyledBadge>
19
10
  );
20
11
  };
21
12
 
@@ -1,2 +1,2 @@
1
1
  export { default as NsCartIcon } from './NsCartIcon';
2
- export type { NsCartIconProps } from './types';
2
+ export type { NsCartIconProps } from './types.d';
@@ -4,4 +4,5 @@ export type NsCartIconProps = {
4
4
  itemCount: number;
5
5
  size?: 'small' | 'medium' | 'large' | 'xLarge';
6
6
  color?: FoundationTheme.PaletteColors;
7
+ maxItemCount?:number;
7
8
  };
@@ -6,7 +6,7 @@
6
6
 
7
7
  import React from 'react';
8
8
 
9
- import { render, fireEvent, noop } from '../../../test-utils';
9
+ import { render, fireEvent, noop } from '@/test-utils/index';
10
10
  import NsCheckbox from './NsCheckbox';
11
11
 
12
12
  // Test suite for CustomCheckbox
@@ -54,4 +54,4 @@ describe('CustomCheckbox', () => {
54
54
  // Assert that the handleChange function has been called
55
55
  expect(handleChange).toHaveBeenCalled();
56
56
  });
57
- });
57
+ });
@@ -1,6 +1,6 @@
1
1
  import React, { useState } from 'react';
2
2
  import { within } from '@testing-library/react';
3
- import { withCenterDecorator } from '../../stories/decorators/withCenterDecorator';
3
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
4
4
  import type { StoryObj, Meta } from '@storybook/react';
5
5
  import { expect } from '@storybook/jest';
6
6
 
@@ -13,7 +13,7 @@ type MetaStory = Meta<ComponentType>;
13
13
  const labelText = 'Checkbox Label';
14
14
  // In this case, we're only passing the label prop.
15
15
  export default {
16
- title: 'Components/NsCheckbox',
16
+ title: 'Components/Inputs/NsCheckbox',
17
17
  component: NsCheckbox,
18
18
  decorators: [withCenterDecorator],
19
19
  argTypes: {
@@ -1,19 +1,18 @@
1
1
  /**
2
2
  * @author [vijayaprathap Kumar] (vpkumar@nuskin.com)
3
- * checkbox.tsx
4
3
  * @description Styled Components for Checkbox
5
4
  */
6
5
  import DoneIcon from '@mui/icons-material/Done';
7
6
 
8
- import { styled } from '@nuskin/foundation-theme';
7
+ import { styled, ColorUtils } from '@nuskin/foundation-theme';
9
8
  import { NsFlag } from '../flag';
10
-
9
+ const { paletteColor, buttonColor } = ColorUtils;
11
10
  /**
12
11
  * Wrapper BpIcon for checkbox.tsx
13
12
  * @params ( theme: { palette }) / Provide the color's to contaier from @nuskin/foundation-theme
14
13
  */
15
14
 
16
- export const BpIcon = styled(DoneIcon)(({ theme: { palette } }) => ({
15
+ export const BpIcon = styled(DoneIcon)(({ theme }) => ({
17
16
  border: '1px solid #8C8C8C',
18
17
  path: {
19
18
  display: 'none',
@@ -25,31 +24,31 @@ export const BpIcon = styled(DoneIcon)(({ theme: { palette } }) => ({
25
24
  outline: '3px solid #94D6E9',
26
25
  },
27
26
  'input:disabled ~ &': {
28
- background: palette?.primary?.buttonState?.hovered,
27
+ background: buttonColor('primary', 'hovered')({ theme }),
29
28
  },
30
29
  }));
31
30
 
32
31
  /**
33
32
  * Wrapper BpCheckedIcon for checkbox.tsx
34
- * @params ( theme: { palette }) / Provide the color's to contaier from @nuskin/foundation-theme
33
+ * @params ( theme: { palette }) / Provide the color's to container from @nuskin/foundation-theme
35
34
  */
36
35
 
37
- export const BpCheckedIcon = styled(BpIcon)(({ theme: { palette } }) => ({
36
+ export const BpCheckedIcon = styled(BpIcon)(({ theme }) => ({
38
37
  path: {
39
38
  display: 'block',
40
39
  },
41
- background: palette.primary.main,
42
- color: palette.primary.contrastText,
40
+ background: paletteColor('primary', 'main')({ theme }),
41
+ color: paletteColor('primary', 'contrastText')({ theme }),
43
42
  }));
44
43
 
45
- export const StyledLabel = styled('span')<{ $hasDisabled: boolean }>`
46
- ${({ $hasDisabled, theme: { palette } }) =>
47
- $hasDisabled &&
48
- `
49
- color: ${palette?.primary?.buttonState?.hovered};
50
- `}
51
- `;
44
+ const getLabelColor = (isDisabled: boolean, color: string) => (!isDisabled ? '' : `color: ${color}`);
52
45
 
46
+ export const StyledLabel = styled('span')<{ isDisabled: boolean }>`
47
+ ${({ isDisabled, theme }) => {
48
+ const color = buttonColor('primary', 'hovered')({ theme });
49
+ return getLabelColor(isDisabled, color);
50
+ }}
51
+ `;
53
52
  export const StyledFlagLabel = styled(NsFlag)`
54
53
  margin-right: 16px;
55
54
  `;
@@ -9,7 +9,7 @@ import FormControlLabel from '@mui/material/FormControlLabel';
9
9
  import { default as MUICheckbox } from '@mui/material/Checkbox';
10
10
 
11
11
  import { BpCheckedIcon, BpIcon, StyledLabel, StyledFlagLabel } from './NsCheckbox.styled';
12
- import { NsCheckboxProps } from './types';
12
+ import { NsCheckboxProps } from './types.d';
13
13
 
14
14
  import { NsTypography } from '../';
15
15
 
@@ -54,7 +54,7 @@ const NsCheckbox = (props: PropsWithChildren<NsCheckboxProps>) => {
54
54
  () => (
55
55
  <NsTypography variant="p-l">
56
56
  <StyledFlagLabel {...flag} size={size} testId={`${name}-flag-label`} />
57
- <StyledLabel className="checkbox-label-text" $hasDisabled={disabled}>
57
+ <StyledLabel className="checkbox-label-text" isDisabled={disabled}>
58
58
  {label}
59
59
  </StyledLabel>
60
60
  </NsTypography>
@@ -1,2 +1,2 @@
1
1
  export { default as NsCheckbox } from './NsCheckbox';
2
- export type { NsCheckboxProps } from './types';
2
+ export type { NsCheckboxProps } from './types.d';
@@ -1,15 +1,9 @@
1
- /**
2
- * @author [vijayaprathap Kumar] (vpkumar@nuskin.com)
3
- * types.d.ts
4
- * @description NsCheckbox Props extending Mui CheckboxProps interface.
5
- */
6
-
7
1
  import { CheckboxProps as MUICheckboxProps } from '@material-ui/core/Checkbox';
8
2
 
9
3
  import { NsFlagProps } from '../flag';
10
4
 
11
5
  // Define the props for the custom checkbox component
12
- export type NsCheckboxProps = Pick<MUICheckboxProps, 'label' | 'onChange'> & {
6
+ export type NsCheckboxProps = Partial<Pick<MUICheckboxProps, 'label' | 'onChange'>> & {
13
7
  name: string;
14
8
  className?: string;
15
9
  checked: boolean;
@@ -1,7 +1,7 @@
1
1
  import { useMemo } from 'react';
2
2
  import { Box } from '@mui/material';
3
3
  import { styled } from '@nuskin/foundation-theme';
4
- import { NsColumnControlProps, sizeObjectType } from './types';
4
+ import { NsColumnControlProps, sizeObjectType } from './types.d';
5
5
  import { getColumnSizes } from './utils';
6
6
 
7
7
  const options = {
@@ -0,0 +1,22 @@
1
+ import { useMemo } from 'react';
2
+ import { getColumnSizes } from './utils';
3
+ import { StyledFlex } from './styled/StyledFlex';
4
+ import { NsFlexColumnsProps } from './types';
5
+
6
+ const NsFlexColumns = ({ columnClass, children, gap, additionalProps, isFullWidth }: NsFlexColumnsProps) => {
7
+ const sizes = useMemo(() => {
8
+ return getColumnSizes(columnClass ?? 'ns-col-lg-1-1');
9
+ }, [columnClass]);
10
+ return (
11
+ <StyledFlex
12
+ isFullWidth={isFullWidth || false}
13
+ gap={gap}
14
+ sizes={sizes}
15
+ className="ns-flex-columns"
16
+ data-testid={additionalProps?.testid ?? 'ns-flex-columns'}
17
+ >
18
+ {children}
19
+ </StyledFlex>
20
+ );
21
+ };
22
+ export default NsFlexColumns;
@@ -0,0 +1,22 @@
1
+ import { useMemo } from 'react';
2
+ import { getColumnSizes } from './utils';
3
+ import { StyledGrid } from './styled/StyledGrid';
4
+ import { NsGridColumnsProps } from './types';
5
+
6
+ const NsGridColumns = ({ columnClass, children, gap, isFullWidth, additionalProps }: NsGridColumnsProps) => {
7
+ const sizes = useMemo(() => {
8
+ return getColumnSizes(columnClass ?? 'ns-col-lg-1-1');
9
+ }, [columnClass]);
10
+ return (
11
+ <StyledGrid
12
+ isFullWidth={isFullWidth || false}
13
+ gap={gap}
14
+ sizes={sizes}
15
+ className="ns-grid-columns"
16
+ data-testid={additionalProps?.testid ?? 'ns-grid-columns'}
17
+ >
18
+ {children}
19
+ </StyledGrid>
20
+ );
21
+ };
22
+ export default NsGridColumns;
@@ -1,2 +1,4 @@
1
1
  export { default as NsColumnControl } from './NsColumnControl';
2
- export type { NsColumnControlProps } from './types';
2
+ export { default as NsFlexColumns } from './NsFlexColumns';
3
+ export { default as NsGridColumns } from './NsGridColumns';
4
+ export type { NsColumnControlProps } from './types.d';
@@ -1,6 +1,6 @@
1
- import { render, screen } from '../../../test-utils';
2
- import { NsColumnControl } from './';
3
- import { DivArray } from './NDivs.story';
1
+ import { NsColumnControl } from '@/common/index';
2
+ import { render, screen } from '@/test-utils/index';
3
+ import { DivArray } from '../stories/DivArray';
4
4
 
5
5
  describe('NsColumnControl component', () => {
6
6
  it('renders an column with proper grid value for tablet', () => {
@@ -0,0 +1,24 @@
1
+ import { render, screen } from '../../../../test-utils';
2
+ import { NsFlexColumns } from '@/common/index';
3
+ import { DivArray } from '../stories/DivArray';
4
+
5
+ describe('NsFlexColumns component', () => {
6
+ it('renders an column with proper grid value for tablet', () => {
7
+ render(
8
+ <NsFlexColumns columnClass="ns-col-lg-1-1-1" gap={16}>
9
+ <DivArray elementsCount={4} />
10
+ </NsFlexColumns>
11
+ );
12
+ const element = screen.getByTestId('ns-flex-columns');
13
+ expect(element).toBeInTheDocument();
14
+ });
15
+ it('renders an column with proper grid value', () => {
16
+ console.warn = jest.fn();
17
+ render(
18
+ <NsFlexColumns columnClass="" gap={16}>
19
+ <DivArray elementsCount={4} />
20
+ </NsFlexColumns>
21
+ );
22
+ expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('Received invalid className'));
23
+ });
24
+ });
@@ -0,0 +1,24 @@
1
+ import { render, screen } from '../../../../test-utils';
2
+ import { NsGridColumns } from '@/common/index';
3
+ import { DivArray } from '../stories/DivArray';
4
+
5
+ describe('NsGridColumns component', () => {
6
+ it('renders an column with proper grid value for tablet', () => {
7
+ render(
8
+ <NsGridColumns columnClass="ns-col-lg-1-1-1" gap={16}>
9
+ <DivArray elementsCount={4} />
10
+ </NsGridColumns>
11
+ );
12
+ const element = screen.getByTestId('ns-grid-columns');
13
+ expect(element).toBeInTheDocument();
14
+ });
15
+ it('renders an column with proper grid value', () => {
16
+ console.warn = jest.fn();
17
+ render(
18
+ <NsGridColumns columnClass="" gap={16}>
19
+ <DivArray elementsCount={4} />
20
+ </NsGridColumns>
21
+ );
22
+ expect(console.warn).toHaveBeenCalledWith(expect.stringContaining('Received invalid className'));
23
+ });
24
+ });
@@ -0,0 +1,18 @@
1
+ import type { StoryObj, Meta } from '@storybook/react';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
+ import {DivArray} from './DivArray';
4
+
5
+ type ComponentType = typeof DivArray;
6
+ type Story = StoryObj<ComponentType>;
7
+ type MetaStory = Meta<ComponentType>;
8
+
9
+ export default {
10
+ title: 'Components/Data Display/Column/NDivs',
11
+ component: DivArray,
12
+ decorators: [withCenterDecorator],
13
+ args: {
14
+ elementsCount: 2,
15
+ },
16
+ } as MetaStory;
17
+
18
+ export const Basic: Story = {};
@@ -0,0 +1,63 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ type DivArrayProps = {
4
+ elementsCount: number;
5
+ };
6
+
7
+ const getRandom = (n: number) => (Math.random() * n).toFixed(0);
8
+
9
+ type DivComponentProps = PropsWithChildren<{ style: Record<string, any>; index: number }>;
10
+ export const DivComponent = ({ style, index, children }: DivComponentProps) => {
11
+ const borderWidth = `${getRandom(5)}px`;
12
+ const padding = `${getRandom(20)}px`;
13
+ return (
14
+ <div
15
+ style={{
16
+ padding,
17
+ border: `${borderWidth} solid`,
18
+ borderColor: `hsl(${getRandom(359)},100%, 50%)`,
19
+ background: `hsla(${getRandom(359)},100%, 50%,0.3)`,
20
+ ...style,
21
+ }}
22
+ >
23
+ {index}
24
+ {children}
25
+ </div>
26
+ );
27
+ };
28
+ /**
29
+ * this component return a fragment containing n number of div, with each div numbered as per its index
30
+ * @param n: number of div to render
31
+ * @returns
32
+ */
33
+ export const DivArray = ({ elementsCount }: DivArrayProps) => (
34
+ <>
35
+ {Array(elementsCount)
36
+ .fill(0)
37
+ .map((_, index) => (
38
+ <DivComponent key={index} index={index + 1} style={{}} />
39
+ ))}
40
+ </>
41
+ );
42
+ export const DivArrayRandom = ({ elementsCount }: DivArrayProps) => (
43
+ <>
44
+ {Array(elementsCount)
45
+ .fill(0)
46
+ .map((_, index) => {
47
+ const width = `${getRandom(700)}px`;
48
+ const height = `${getRandom(400)}px`;
49
+ return (
50
+ <DivComponent
51
+ key={index}
52
+ index={index + 1}
53
+ style={{
54
+ width,
55
+ height,
56
+ }}
57
+ >
58
+ item no = {index + 1} with width = {width} and height = {height}
59
+ </DivComponent>
60
+ );
61
+ })}
62
+ </>
63
+ );
@@ -1,25 +1,15 @@
1
1
  import type { StoryObj, Meta } from '@storybook/react';
2
- import { withCenterDecorator } from '../../stories/decorators/withCenterDecorator';
3
- import { NsColumnControl } from '.';
4
- import { DivArray } from './NDivs.story';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
+ import { NsColumnControl } from '@/common/index';
4
+ import { DivArray } from './DivArray';
5
+ import { childrenMapping, selectDivOptions } from './common';
5
6
 
6
7
  type ComponentType = typeof NsColumnControl;
7
8
  type Story = StoryObj<ComponentType>;
8
9
  type MetaStory = Meta<ComponentType>;
9
10
 
10
- /* an array from 1 to n */
11
- const selectDivOptions = Array(16)
12
- .fill(0)
13
- .map((e, i) => i + 1);
14
- const childrenMapping = selectDivOptions.reduce((a, c) => {
15
- return {
16
- ...a,
17
- [c]: <DivArray elementsCount={c} />,
18
- };
19
- }, {});
20
-
21
11
  export default {
22
- title: 'Components/NsColumnControl',
12
+ title: 'Components/Data Display/Column/NsColumnControl',
23
13
  component: NsColumnControl,
24
14
  decorators: [withCenterDecorator],
25
15
  argTypes: {
@@ -42,7 +32,10 @@ export default {
42
32
  },
43
33
  } as MetaStory;
44
34
 
45
- export const SingleColumnControl: Story = {};
35
+ export const ResponsiveColumnControl: Story = {};
36
+ export const SingleColumnControl: Story = {
37
+ args: { columnClass: '' },
38
+ };
46
39
  export const TwoColumn11: Story = {
47
40
  args: { columnClass: 'ns-col-lg-1-1' },
48
41
  };
@@ -0,0 +1,63 @@
1
+ import type { StoryObj, Meta } from '@storybook/react';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
+ import { NsFlexColumns } from '..';
4
+ import { DivArray, DivArrayRandom } from './DivArray';
5
+ import { childrenMapping, selectDivOptions } from './common';
6
+
7
+ type ComponentType = typeof NsFlexColumns;
8
+ type Story = StoryObj<ComponentType>;
9
+ type MetaStory = Meta<ComponentType>;
10
+
11
+ export default {
12
+ title: 'Components/Data Display/Column/NsFlexColumns',
13
+ component: NsFlexColumns,
14
+ decorators: [withCenterDecorator],
15
+ argTypes: {
16
+ columnClass: {
17
+ control: 'text',
18
+ defaultValue: 'ns-col-lg-1-1-1 ns-col-md-1-1 ns-col-sm-1',
19
+ },
20
+ gap: {
21
+ control: 'number',
22
+ defaultValue: 16,
23
+ },
24
+ children: {
25
+ control: {
26
+ type: 'select',
27
+ options: selectDivOptions,
28
+ },
29
+ defaultValue: <DivArrayRandom elementsCount={8} />,
30
+ mapping: childrenMapping,
31
+ },
32
+ },
33
+ args: {
34
+ columnClass: '',
35
+ children: <DivArrayRandom elementsCount={12} />,
36
+ },
37
+ } as MetaStory;
38
+
39
+ export const DefaultColumnControl: Story = {
40
+ args: {
41
+ children: <DivArray elementsCount={8} />,
42
+ },
43
+ };
44
+ export const TwoColumn11: Story = {
45
+ args: { columnClass: 'ns-col-lg-1-1' },
46
+ };
47
+ export const TwoColumn21: Story = {
48
+ args: { columnClass: 'ns-col-lg-2-1' },
49
+ };
50
+
51
+ export const ThreeColumn211: Story = {
52
+ args: { columnClass: 'ns-col-lg-2-1-1' },
53
+ };
54
+ export const ThreeColumn121: Story = {
55
+ args: { columnClass: 'ns-col-lg-1-2-1' },
56
+ };
57
+ export const ThreeColumn111: Story = {
58
+ args: { columnClass: 'ns-col-lg-1-1-1' },
59
+ };
60
+
61
+ export const FourColumn1111: Story = {
62
+ args: { columnClass: 'ns-col-lg-1-1-1-1' },
63
+ };