@nuskin/foundation-ui-components 1.4.1 → 1.4.2-export-updates.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/common/icon/NsIcon.tsx +2 -1
- package/src/common/icon/icons/UserOutline.tsx +2 -2
- package/src/common/index.ts +33 -31
- package/src/common/select/DefaultRenderOption.tsx +6 -0
- package/src/common/select/NsSelect.tsx +16 -40
- package/src/common/select/NsSelectOption.tsx +1 -0
- package/src/common/select/constant.ts +30 -0
- package/src/common/select/specs/NsSelect.spec.tsx +2 -2
- package/src/common/select/stories/NsSelect.stories.tsx +2 -2
- package/src/common/select/types.d.ts +1 -1
- package/src/common/spinner/icons/Spinner.tsx +9 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/foundation-ui-components",
|
|
3
|
-
"version": "1.4.1",
|
|
3
|
+
"version": "1.4.2-export-updates.1",
|
|
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": {
|
|
@@ -15,6 +15,7 @@ const NsIcon = ({
|
|
|
15
15
|
className,
|
|
16
16
|
colorOverride,
|
|
17
17
|
onClick = () => {},
|
|
18
|
+
...rest
|
|
18
19
|
}: NsIconProps) => {
|
|
19
20
|
const Icon = IconVariants[name as NsIconNameType];
|
|
20
21
|
const theme = useTheme();
|
|
@@ -24,7 +25,7 @@ const NsIcon = ({
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
return (
|
|
27
|
-
<IconWrapper data-testid={testId} size={size || 'large'} className={className} onClick={onClick}>
|
|
28
|
+
<IconWrapper {...rest} data-testid={testId} size={size || 'large'} className={className} onClick={onClick}>
|
|
28
29
|
<Icon color={colorOverride ? colorOverride : (iconColor as any)} />
|
|
29
30
|
</IconWrapper>
|
|
30
31
|
);
|
|
@@ -15,8 +15,8 @@ function UserOutline(props: SvgIconProps) {
|
|
|
15
15
|
xmlns="http://www.w3.org/2000/svg"
|
|
16
16
|
>
|
|
17
17
|
<path
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
fillRule="evenodd"
|
|
19
|
+
clipRule="evenodd"
|
|
20
20
|
d="M12 1.25C6.06294 1.25 1.25 6.06294 1.25 12C1.25 17.9371 6.06294 22.75 12 22.75C17.9371 22.75 22.75 17.9371 22.75 12C22.75 6.06294 17.9371 1.25 12 1.25ZM2.75 12C2.75 6.89137 6.89137 2.75 12 2.75C17.1086 2.75 21.25 6.89137 21.25 12C21.25 14.5514 20.217 16.8615 18.5465 18.535C18.5373 18.5053 18.5278 18.4757 18.5177 18.4462C18.2909 17.7811 17.7908 17.0816 16.7743 16.861C16.1976 16.7279 15.7597 16.6249 15.4126 16.5154C15.0619 16.4048 14.8722 16.3075 14.7621 16.2197C14.6519 16.1318 14.5229 15.9893 14.534 15.3824C15.2564 14.7722 15.6208 13.9828 15.7989 13.145C15.9917 12.2377 15.9765 11.218 15.9621 10.2575L15.9618 10.2367C15.9587 8.04108 14.1928 6.25 12 6.25C9.80523 6.25 8.03818 8.04427 8.03818 10.2425L8.03818 10.2902C8.03812 11.2492 8.03807 12.2685 8.23093 13.1685C8.40828 13.9961 8.76096 14.7856 9.46415 15.382C9.47219 15.9884 9.34391 16.1319 9.23338 16.2204C9.12398 16.3079 8.93522 16.4051 8.58559 16.5155C8.23946 16.6249 7.80232 16.728 7.22572 16.861C6.20921 17.0816 5.70909 17.7811 5.48226 18.4462C5.47222 18.4757 5.46266 18.5053 5.45354 18.535C3.78298 16.8615 2.75 14.5514 2.75 12ZM6.77658 19.6351C8.26295 20.6539 10.0619 21.25 12 21.25C13.9381 21.25 15.7371 20.6539 17.2234 19.6351C17.206 19.3999 17.1779 19.1646 17.098 18.9304C16.9903 18.6146 16.822 18.4054 16.4533 18.3262L16.4423 18.3239L16.4423 18.3238C15.8787 18.1938 15.3772 18.0771 14.9615 17.946C14.5483 17.8157 14.1512 17.6513 13.8266 17.3922C13.0849 16.8004 12.9768 15.9412 13.0552 14.9385L13.0833 14.58L13.3803 14.3774C13.9081 14.0173 14.1862 13.5172 14.3317 12.8331C14.4843 12.1148 14.477 11.265 14.4619 10.2537L14.4617 10.2425H14.4618C14.4618 8.8592 13.3529 7.75 12 7.75C10.6471 7.75 9.53818 8.8592 9.53818 10.2425C9.53818 11.259 9.54149 12.1256 9.69764 12.8542C9.84777 13.5548 10.1225 14.0439 10.6148 14.3741L10.9184 14.5777L10.9451 14.9423C11.0181 15.9429 10.9092 16.8005 10.1706 17.3915C9.84647 17.6509 9.45024 17.8154 9.03756 17.9458C8.62239 18.077 8.12144 18.1938 7.55771 18.3238L7.54669 18.3263L7.54667 18.3262C7.17801 18.4054 7.00968 18.6146 6.90197 18.9304C6.8221 19.1646 6.79403 19.3999 6.77658 19.6351Z"
|
|
21
21
|
fill={props.color}
|
|
22
22
|
/>
|
package/src/common/index.ts
CHANGED
|
@@ -1,36 +1,38 @@
|
|
|
1
|
-
export * from './accordion';
|
|
2
|
-
export * from './alert';
|
|
3
|
-
export * from './auth-dropdown';
|
|
4
|
-
export * from './autocomplete';
|
|
5
|
-
export * from './banner';
|
|
6
1
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
|
|
2
|
+
export { NsAccordion } from './accordion';
|
|
3
|
+
|
|
4
|
+
export { NsAlert } from './alert';
|
|
5
|
+
export { NsAuthDropdown } from './auth-dropdown';
|
|
6
|
+
export { NsAutocomplete } from './autocomplete';
|
|
7
|
+
export { NsBanner } from './banner';
|
|
8
|
+
|
|
9
|
+
export { NsBrandComponent } from './brand-components';
|
|
10
|
+
export { NsBreadcrumb } from './breadcrumb';
|
|
11
|
+
export { NsButton } from './button';
|
|
12
|
+
export { NsBgCard } from './card';
|
|
13
|
+
export { NsCarousal } from './carousal';
|
|
14
|
+
export { NsCartIcon } from './cart-icon';
|
|
15
|
+
export { NsCheckbox } from './checkbox';
|
|
14
16
|
export * from './common.types.d';
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
17
|
+
export { NsColumnControl } from './column-control';
|
|
18
|
+
export { NsDropdown } from './dropdown';
|
|
19
|
+
export { NsEmailSimple } from './email-simple';
|
|
20
|
+
export { NsFlag } from './flag';
|
|
19
21
|
export * from './hooks';
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
22
|
+
export { NsIcon } from './icon';
|
|
23
|
+
export { NsImage } from './image';
|
|
24
|
+
export { NsInputField } from './input';
|
|
25
|
+
export { NsLabel } from './label';
|
|
26
|
+
export { NsLink } from './link';
|
|
27
|
+
export { NsModal } from './modal';
|
|
28
|
+
export { NsNavProductCard } from './nav-product-card';
|
|
29
|
+
export { NsNavTab } from './nav-tab';
|
|
30
|
+
export { NsProgress } from './progress';
|
|
31
|
+
export { NsRadioGroup } from './radiogroup';
|
|
32
|
+
export { NsSelect } from './select';
|
|
33
|
+
export { NsSpinner } from './spinner';
|
|
34
|
+
export { NsTable } from './table';
|
|
35
|
+
export { NsTextStrip } from './text-strip';
|
|
34
36
|
export * from './typography';
|
|
35
37
|
export * from './utility';
|
|
36
|
-
export
|
|
38
|
+
export { NsVideo } from './videos';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import NsSelectOption from './NsSelectOption';
|
|
2
|
+
import { RenderSelectOptionArgType } from './types';
|
|
3
|
+
|
|
4
|
+
export const DefaultRenderOption = (props: RenderSelectOptionArgType) => {
|
|
5
|
+
return <NsSelectOption {...props} key={props?.value} onClick={props.onClick} index={props.index ?? 0} />;
|
|
6
|
+
};
|
|
@@ -14,37 +14,9 @@ import {
|
|
|
14
14
|
SelectMain,
|
|
15
15
|
} from './NsSelect.styled';
|
|
16
16
|
import { LabelValueType, SelectProps } from './types.d';
|
|
17
|
+
import { arrowVisibility, factorMap } from './constant';
|
|
18
|
+
import { DefaultRenderOption } from './DefaultRenderOption';
|
|
17
19
|
|
|
18
|
-
const factorMap: any = {
|
|
19
|
-
reverse: {
|
|
20
|
-
right: -1,
|
|
21
|
-
left: 1,
|
|
22
|
-
},
|
|
23
|
-
forward: {
|
|
24
|
-
right: 1,
|
|
25
|
-
left: -1,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const arrowVisibility = (
|
|
30
|
-
total: number,
|
|
31
|
-
direction: 'left' | 'right',
|
|
32
|
-
reverse: boolean = false,
|
|
33
|
-
currentIndex: number | undefined = -1
|
|
34
|
-
) => {
|
|
35
|
-
if (direction === 'left') {
|
|
36
|
-
if (!reverse) {
|
|
37
|
-
return currentIndex < 1 ? 'hidden' : 'visible';
|
|
38
|
-
} else {
|
|
39
|
-
return currentIndex >= total - 1 ? 'hidden' : 'visible';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (!reverse) {
|
|
43
|
-
return currentIndex >= total - 1 ? 'hidden' : 'visible';
|
|
44
|
-
} else {
|
|
45
|
-
return currentIndex < 1 ? 'hidden' : 'visible';
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
20
|
const NsSelect: React.FC<SelectProps> = ({
|
|
49
21
|
selected,
|
|
50
22
|
onSelect,
|
|
@@ -61,7 +33,7 @@ const NsSelect: React.FC<SelectProps> = ({
|
|
|
61
33
|
// eslint-disable-next-line no-unused-vars
|
|
62
34
|
rules,
|
|
63
35
|
reverseArrowControls,
|
|
64
|
-
|
|
36
|
+
RenderOption = DefaultRenderOption,
|
|
65
37
|
options,
|
|
66
38
|
}) => {
|
|
67
39
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -106,7 +78,6 @@ const NsSelect: React.FC<SelectProps> = ({
|
|
|
106
78
|
handleSelect({ ...options[nextIndex], index: nextIndex });
|
|
107
79
|
}
|
|
108
80
|
};
|
|
109
|
-
|
|
110
81
|
return (
|
|
111
82
|
<SelectMain>
|
|
112
83
|
{hasArrows && (
|
|
@@ -146,14 +117,19 @@ const NsSelect: React.FC<SelectProps> = ({
|
|
|
146
117
|
className="selectList"
|
|
147
118
|
>
|
|
148
119
|
{options.map((opt, optionIndex) => {
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
120
|
+
return (
|
|
121
|
+
<RenderOption
|
|
122
|
+
key={opt.value}
|
|
123
|
+
value={opt.value}
|
|
124
|
+
label={opt.label}
|
|
125
|
+
index={optionIndex}
|
|
126
|
+
onClick={() =>
|
|
127
|
+
handleSelect({ label: opt.label, value: opt.value, index: optionIndex })
|
|
128
|
+
}
|
|
129
|
+
selected={value}
|
|
130
|
+
showListDivider={showListDivider}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
157
133
|
})}
|
|
158
134
|
</SelectList>
|
|
159
135
|
</Show>
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
};
|
|
@@ -24,7 +24,7 @@ const selectCommonProps = {
|
|
|
24
24
|
{ value: 'Option3', label: 'Option 3' },
|
|
25
25
|
],
|
|
26
26
|
onSelect: jest.fn(),
|
|
27
|
-
|
|
27
|
+
RenderOption: renderSelectOption,
|
|
28
28
|
};
|
|
29
29
|
describe('NsSelect', () => {
|
|
30
30
|
const onSelect = jest.fn();
|
|
@@ -43,7 +43,7 @@ describe('NsSelect', () => {
|
|
|
43
43
|
selected={selected}
|
|
44
44
|
onSelect={onSelect}
|
|
45
45
|
options={options}
|
|
46
|
-
|
|
46
|
+
RenderOption={renderSelectOption}
|
|
47
47
|
/>
|
|
48
48
|
);
|
|
49
49
|
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
selectBorderColor: 'primary',
|
|
42
42
|
closeOnMouseLeave: false,
|
|
43
43
|
showListDivider: true,
|
|
44
|
-
selected: { label: '', value: '' },
|
|
44
|
+
selected: { label: '', value: '', index: 0 },
|
|
45
45
|
label: 'State',
|
|
46
46
|
placeholder: '',
|
|
47
47
|
name: '',
|
|
@@ -68,7 +68,7 @@ const AppSelect = (props: SelectProps) => {
|
|
|
68
68
|
onSelect={onSelect}
|
|
69
69
|
label={props.label}
|
|
70
70
|
options={props.options}
|
|
71
|
-
|
|
71
|
+
RenderOption={(props) => {
|
|
72
72
|
return <NsSelectOption {...props} key={props?.value} onClick={props.onClick} />;
|
|
73
73
|
}}
|
|
74
74
|
/>
|
|
@@ -36,7 +36,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
36
36
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
37
37
|
opacity="0"
|
|
38
38
|
fill="none"
|
|
39
|
-
|
|
39
|
+
fillRule="evenodd"
|
|
40
40
|
stroke="rgb(249,0,156)"
|
|
41
41
|
strokeWidth="30"
|
|
42
42
|
strokeLinecap="round"
|
|
@@ -50,7 +50,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
50
50
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
51
51
|
opacity="0"
|
|
52
52
|
fill="none"
|
|
53
|
-
|
|
53
|
+
fillRule="evenodd"
|
|
54
54
|
stroke="rgb(78,0,160)"
|
|
55
55
|
strokeWidth="30"
|
|
56
56
|
strokeLinecap="round"
|
|
@@ -64,7 +64,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
64
64
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
65
65
|
opacity="0"
|
|
66
66
|
fill="none"
|
|
67
|
-
|
|
67
|
+
fillRule="evenodd"
|
|
68
68
|
stroke="rgb(255,215,0)"
|
|
69
69
|
strokeWidth="30"
|
|
70
70
|
strokeLinecap="round"
|
|
@@ -78,7 +78,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
78
78
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
79
79
|
opacity="0"
|
|
80
80
|
fill="none"
|
|
81
|
-
|
|
81
|
+
fillRule="evenodd"
|
|
82
82
|
stroke="rgb(190,217,0)"
|
|
83
83
|
strokeWidth="30"
|
|
84
84
|
strokeLinecap="round"
|
|
@@ -92,7 +92,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
92
92
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
93
93
|
opacity="0"
|
|
94
94
|
fill="none"
|
|
95
|
-
|
|
95
|
+
fillRule="evenodd"
|
|
96
96
|
stroke="rgb(190,217,0)"
|
|
97
97
|
strokeWidth="30"
|
|
98
98
|
strokeLinecap="round"
|
|
@@ -106,7 +106,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
106
106
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
107
107
|
opacity="0"
|
|
108
108
|
fill="none"
|
|
109
|
-
|
|
109
|
+
fillRule="evenodd"
|
|
110
110
|
stroke="rgb(249,0,156)"
|
|
111
111
|
strokeWidth="30"
|
|
112
112
|
strokeLinecap="round"
|
|
@@ -119,7 +119,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
119
119
|
d="M207.214206,353.714206C243.362404,353.714206,276.452762,340.622041,302.002226,318.920768C333.639565,292.048559,353.714206,251.975724,353.714206,207.214206C353.714206,126.304490,288.123922,60.714206,207.214206,60.714206C126.304490,60.714206,60.714206,126.304490,60.714206,207.214206C60.714206,237.178438,69.710103,265.041566,85.148469,288.250162C111.396930,327.709644,156.268722,353.714206,207.214206,353.714206Z"
|
|
120
120
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
121
121
|
fill="none"
|
|
122
|
-
|
|
122
|
+
fillRule="evenodd"
|
|
123
123
|
stroke="rgb(255,215,0)"
|
|
124
124
|
strokeWidth="30"
|
|
125
125
|
strokeLinecap="round"
|
|
@@ -132,7 +132,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
132
132
|
d="M207.214206,353.714206C243.362404,353.714206,276.452762,340.622041,302.002226,318.920768C333.639565,292.048559,353.714206,251.975724,353.714206,207.214206C353.714206,126.304490,288.123922,60.714206,207.214206,60.714206C126.304490,60.714206,60.714206,126.304490,60.714206,207.214206C60.714206,237.178438,69.710103,265.041566,85.148469,288.250162C111.396930,327.709644,156.268722,353.714206,207.214206,353.714206Z"
|
|
133
133
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
134
134
|
fill="none"
|
|
135
|
-
|
|
135
|
+
fillRule="evenodd"
|
|
136
136
|
stroke="rgb(255,78,0)"
|
|
137
137
|
strokeWidth="30"
|
|
138
138
|
strokeLinecap="round"
|
|
@@ -145,7 +145,7 @@ const SpinnerIcon = (props: SvgIconProps) => {
|
|
|
145
145
|
d="M207.214206,353.714206C243.362404,353.714206,276.452762,340.622041,302.002226,318.920768C333.639565,292.048559,353.714206,251.975724,353.714206,207.214206C353.714206,126.304490,288.123922,60.714206,207.214206,60.714206C126.304490,60.714206,60.714206,126.304490,60.714206,207.214206C60.714206,237.178438,69.710103,265.041566,85.148469,288.250162C111.396930,327.709644,156.268722,353.714206,207.214206,353.714206Z"
|
|
146
146
|
transform="scale(1,1) translate(-207.214206,-207.214206)"
|
|
147
147
|
fill="none"
|
|
148
|
-
|
|
148
|
+
fillRule="evenodd"
|
|
149
149
|
stroke="rgb(0,183,231)"
|
|
150
150
|
strokeWidth="30"
|
|
151
151
|
strokeLinecap="round"
|