@faststore/components 2.0.3-alpha.0 → 2.0.5-alpha.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/CHANGELOG.md +18 -0
- package/dist/assets/ShoppingCart.d.ts +3 -0
- package/dist/assets/ShoppingCart.js +10 -0
- package/dist/assets/ShoppingCart.js.map +1 -0
- package/dist/assets/X.d.ts +3 -0
- package/dist/assets/X.js +8 -0
- package/dist/assets/X.js.map +1 -0
- package/dist/assets/index.d.ts +2 -0
- package/dist/assets/index.js +3 -0
- package/dist/assets/index.js.map +1 -0
- package/dist/atoms/Badge/Badge.d.ts +28 -0
- package/dist/atoms/Badge/Badge.js +7 -0
- package/dist/atoms/Badge/Badge.js.map +1 -0
- package/dist/atoms/Badge/index.d.ts +2 -0
- package/dist/atoms/Badge/index.js +2 -0
- package/dist/atoms/Badge/index.js.map +1 -0
- package/dist/atoms/Button/Button.d.ts +37 -0
- package/dist/atoms/Button/Button.js +10 -0
- package/dist/atoms/Button/Button.js.map +1 -0
- package/dist/atoms/Button/index.d.ts +2 -0
- package/dist/atoms/Button/index.js +2 -0
- package/dist/atoms/Button/index.js.map +1 -0
- package/dist/atoms/Checkbox/Checkbox.d.ts +14 -0
- package/dist/atoms/Checkbox/Checkbox.js +6 -0
- package/dist/atoms/Checkbox/Checkbox.js.map +1 -0
- package/dist/atoms/Checkbox/index.d.ts +2 -0
- package/dist/atoms/Checkbox/index.js +2 -0
- package/dist/atoms/Checkbox/index.js.map +1 -0
- package/dist/atoms/Icon/Icon.d.ts +14 -0
- package/dist/atoms/Icon/Icon.js +6 -0
- package/dist/atoms/Icon/Icon.js.map +1 -0
- package/dist/atoms/Icon/index.d.ts +2 -0
- package/dist/atoms/Icon/index.js +2 -0
- package/dist/atoms/Icon/index.js.map +1 -0
- package/dist/atoms/Label/Label.d.ts +10 -0
- package/dist/atoms/Label/Label.js +6 -0
- package/dist/atoms/Label/Label.js.map +1 -0
- package/dist/atoms/Label/index.d.ts +2 -0
- package/dist/atoms/Label/index.js +2 -0
- package/dist/atoms/Label/index.js.map +1 -0
- package/dist/atoms/Overlay/Overlay.d.ts +10 -0
- package/dist/atoms/Overlay/Overlay.js +6 -0
- package/dist/atoms/Overlay/Overlay.js.map +1 -0
- package/dist/atoms/Overlay/index.d.ts +2 -0
- package/dist/atoms/Overlay/index.js +2 -0
- package/dist/atoms/Overlay/index.js.map +1 -0
- package/dist/atoms/Radio/Radio.d.ts +10 -0
- package/dist/atoms/Radio/Radio.js +6 -0
- package/dist/atoms/Radio/Radio.js.map +1 -0
- package/dist/atoms/Radio/index.d.ts +2 -0
- package/dist/atoms/Radio/index.js +2 -0
- package/dist/atoms/Radio/index.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/molecules/CheckboxField/CheckboxField.d.ts +25 -0
- package/dist/molecules/CheckboxField/CheckboxField.js +10 -0
- package/dist/molecules/CheckboxField/CheckboxField.js.map +1 -0
- package/dist/molecules/CheckboxField/index.d.ts +2 -0
- package/dist/molecules/CheckboxField/index.js +2 -0
- package/dist/molecules/CheckboxField/index.js.map +1 -0
- package/dist/molecules/IconButton/IconButton.d.ts +19 -0
- package/dist/molecules/IconButton/IconButton.js +9 -0
- package/dist/molecules/IconButton/IconButton.js.map +1 -0
- package/dist/molecules/IconButton/index.d.ts +2 -0
- package/dist/molecules/IconButton/index.js +2 -0
- package/dist/molecules/IconButton/index.js.map +1 -0
- package/dist/molecules/RadioField/RadioField.d.ts +25 -0
- package/dist/molecules/RadioField/RadioField.js +10 -0
- package/dist/molecules/RadioField/RadioField.js.map +1 -0
- package/dist/molecules/RadioField/index.d.ts +2 -0
- package/dist/molecules/RadioField/index.js +2 -0
- package/dist/molecules/RadioField/index.js.map +1 -0
- package/dist/molecules/Tag/Tag.d.ts +27 -0
- package/dist/molecules/Tag/Tag.js +12 -0
- package/dist/molecules/Tag/Tag.js.map +1 -0
- package/dist/molecules/Tag/index.d.ts +2 -0
- package/dist/molecules/Tag/index.js +2 -0
- package/dist/molecules/Tag/index.js.map +1 -0
- package/package.json +27 -3
- package/src/assets/ShoppingCart.tsx +51 -0
- package/src/assets/X.tsx +39 -0
- package/src/assets/index.ts +2 -0
- package/src/atoms/Badge/Badge.tsx +64 -0
- package/src/atoms/Badge/index.ts +2 -0
- package/src/atoms/Button/Button.tsx +72 -0
- package/src/atoms/Button/index.ts +2 -0
- package/src/atoms/Checkbox/Checkbox.tsx +32 -0
- package/src/atoms/Checkbox/index.ts +2 -0
- package/src/atoms/Icon/Icon.tsx +26 -0
- package/src/atoms/Icon/index.ts +2 -0
- package/src/atoms/Label/Label.tsx +22 -0
- package/src/atoms/Label/index.ts +2 -0
- package/src/atoms/Overlay/Overlay.tsx +26 -0
- package/src/atoms/Overlay/index.ts +2 -0
- package/src/atoms/Radio/Radio.tsx +27 -0
- package/src/atoms/Radio/index.ts +2 -0
- package/src/index.ts +25 -0
- package/src/molecules/CheckboxField/CheckboxField.tsx +42 -0
- package/src/molecules/CheckboxField/index.ts +2 -0
- package/src/molecules/IconButton/IconButton.tsx +51 -0
- package/src/molecules/IconButton/index.ts +2 -0
- package/src/molecules/RadioField/RadioField.tsx +42 -0
- package/src/molecules/RadioField/index.ts +2 -0
- package/src/molecules/Tag/Tag.tsx +54 -0
- package/src/molecules/Tag/index.ts +2 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { BadgeProps } from '../..';
|
|
4
|
+
export interface TagProps extends BadgeProps {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The text displayed inside the tag.
|
|
11
|
+
*/
|
|
12
|
+
label: string;
|
|
13
|
+
/**
|
|
14
|
+
* A React component that will be rendered as an icon.
|
|
15
|
+
*/
|
|
16
|
+
icon?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* For accessibility purposes, provide an ARIA label to the Icon button
|
|
19
|
+
*/
|
|
20
|
+
iconButtonLabel?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Function called when Icon button is clicked.
|
|
23
|
+
*/
|
|
24
|
+
onClose: () => void;
|
|
25
|
+
}
|
|
26
|
+
declare const Tag: React.ForwardRefExoticComponent<TagProps & React.RefAttributes<HTMLDivElement>>;
|
|
27
|
+
export default Tag;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { Icon } from '../..';
|
|
3
|
+
import { Badge } from '../..';
|
|
4
|
+
import { X } from '../../assets';
|
|
5
|
+
const Tag = forwardRef(function Tag({ testId = 'fs-tag', label, icon, iconButtonLabel, onClose, ...otherProps }, ref) {
|
|
6
|
+
return (React.createElement(Badge, { ref: ref, "data-fs-tag": true, "data-testid": testId, size: "big", ...otherProps },
|
|
7
|
+
React.createElement("span", { "data-fs-tag-label": true }, label),
|
|
8
|
+
React.createElement("button", { "data-fs-tag-icon-button": true, "aria-label": iconButtonLabel ? iconButtonLabel : 'remove', onClick: onClose },
|
|
9
|
+
React.createElement(Icon, { component: icon ? icon : React.createElement(X, null) }))));
|
|
10
|
+
});
|
|
11
|
+
export default Tag;
|
|
12
|
+
//# sourceMappingURL=Tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../../src/molecules/Tag/Tag.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAc,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAA;AAyBhC,MAAM,GAAG,GAAG,UAAU,CAA2B,SAAS,GAAG,CAC3D,EAAE,MAAM,GAAG,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,EAC3E,GAAG;IAEH,OAAO,CACL,oBAAC,KAAK,IACJ,GAAG,EAAE,GAAG,sCAEK,MAAM,EACnB,IAAI,EAAC,KAAK,KACN,UAAU;QAEd,2DAAyB,KAAK,CAAQ;QACtC,+EAEc,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,EACxD,OAAO,EAAE,OAAO;YAEhB,oBAAC,IAAI,IAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAC,CAAC,OAAG,GAAI,CACjC,CACH,CACT,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,GAAG,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/Tag/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/components",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"
|
|
3
|
+
"version": "2.0.5-alpha.0",
|
|
4
|
+
"module": "dist/index.js",
|
|
5
|
+
"typings": "dist/index.d.ts",
|
|
5
6
|
"author": "Emerson Laurentino @emersonlaurentino",
|
|
6
7
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"lint": "eslint src/**/*.{ts,tsx}"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/vtex/faststore",
|
|
16
|
+
"directory": "packages/components"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"src"
|
|
22
|
+
],
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@faststore/shared": "^2.0.3-alpha.0",
|
|
25
|
+
"typescript": "^4.8.4"
|
|
26
|
+
},
|
|
27
|
+
"volta": {
|
|
28
|
+
"node": "16.18.0",
|
|
29
|
+
"yarn": "1.19.1"
|
|
30
|
+
},
|
|
31
|
+
"gitHead": "7ac374bab91528184e27381e7dc3be8bf5524e76"
|
|
8
32
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { FC } from 'react'
|
|
3
|
+
|
|
4
|
+
// Icon from Phosphor Icons
|
|
5
|
+
const ShoppingCart: FC = () => (
|
|
6
|
+
<svg
|
|
7
|
+
id="ShoppingCart"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
viewBox="0 0 256 256"
|
|
11
|
+
strokeWidth="16"
|
|
12
|
+
width={24}
|
|
13
|
+
height={24}
|
|
14
|
+
>
|
|
15
|
+
<rect width="256" height="256" fill="none"></rect>
|
|
16
|
+
<path
|
|
17
|
+
d="M184,184H69.81818L41.92162,30.56892A8,8,0,0,0,34.05066,24H16"
|
|
18
|
+
fill="none"
|
|
19
|
+
stroke="currentColor"
|
|
20
|
+
strokeLinecap="round"
|
|
21
|
+
strokeLinejoin="round"
|
|
22
|
+
></path>
|
|
23
|
+
<circle
|
|
24
|
+
cx="80"
|
|
25
|
+
cy="204"
|
|
26
|
+
r="20"
|
|
27
|
+
fill="none"
|
|
28
|
+
stroke="currentColor"
|
|
29
|
+
strokeLinecap="round"
|
|
30
|
+
strokeLinejoin="round"
|
|
31
|
+
></circle>
|
|
32
|
+
<circle
|
|
33
|
+
cx="184"
|
|
34
|
+
cy="204"
|
|
35
|
+
r="20"
|
|
36
|
+
fill="none"
|
|
37
|
+
stroke="currentColor"
|
|
38
|
+
strokeLinecap="round"
|
|
39
|
+
strokeLinejoin="round"
|
|
40
|
+
></circle>
|
|
41
|
+
<path
|
|
42
|
+
d="M62.54543,144H188.10132a16,16,0,0,0,15.74192-13.13783L216,64H48"
|
|
43
|
+
fill="none"
|
|
44
|
+
stroke="currentColor"
|
|
45
|
+
strokeLinecap="round"
|
|
46
|
+
strokeLinejoin="round"
|
|
47
|
+
></path>
|
|
48
|
+
</svg>
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
export default ShoppingCart
|
package/src/assets/X.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { FC } from 'react'
|
|
3
|
+
|
|
4
|
+
// Icon from Phosphor Icons
|
|
5
|
+
const X: FC = () => (
|
|
6
|
+
<svg
|
|
7
|
+
id="X"
|
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
viewBox="0 0 256 256"
|
|
11
|
+
strokeWidth="16"
|
|
12
|
+
width={24}
|
|
13
|
+
height={24}
|
|
14
|
+
>
|
|
15
|
+
<rect width="256" height="256" fill="none"></rect>
|
|
16
|
+
<line
|
|
17
|
+
x1="200"
|
|
18
|
+
y1="56"
|
|
19
|
+
x2="56"
|
|
20
|
+
y2="200"
|
|
21
|
+
fill="none"
|
|
22
|
+
stroke="currentColor"
|
|
23
|
+
strokeLinecap="round"
|
|
24
|
+
strokeLinejoin="round"
|
|
25
|
+
></line>
|
|
26
|
+
<line
|
|
27
|
+
x1="200"
|
|
28
|
+
y1="200"
|
|
29
|
+
x2="56"
|
|
30
|
+
y2="56"
|
|
31
|
+
fill="none"
|
|
32
|
+
stroke="currentColor"
|
|
33
|
+
strokeLinecap="round"
|
|
34
|
+
strokeLinejoin="round"
|
|
35
|
+
></line>
|
|
36
|
+
</svg>
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
export default X
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ReactNode, HTMLAttributes, AriaAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export type BadgeVariants =
|
|
5
|
+
| 'info'
|
|
6
|
+
| 'highlighted'
|
|
7
|
+
| 'success'
|
|
8
|
+
| 'neutral'
|
|
9
|
+
| 'warning'
|
|
10
|
+
| 'danger'
|
|
11
|
+
|
|
12
|
+
export interface BadgeProps extends HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
/**
|
|
14
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
15
|
+
*/
|
|
16
|
+
testId?: string
|
|
17
|
+
/**
|
|
18
|
+
* Sets the component's size.
|
|
19
|
+
*/
|
|
20
|
+
size?: 'small' | 'big'
|
|
21
|
+
/**
|
|
22
|
+
* Specifies the component variant.
|
|
23
|
+
*/
|
|
24
|
+
variant?: BadgeVariants
|
|
25
|
+
/**
|
|
26
|
+
* Enables counter badge.
|
|
27
|
+
*/
|
|
28
|
+
counter?: boolean
|
|
29
|
+
/**
|
|
30
|
+
* For accessibility purposes, adds an ARIA label to the element when `counter` is set to `true`.
|
|
31
|
+
*/
|
|
32
|
+
'aria-label'?: AriaAttributes['aria-label']
|
|
33
|
+
children?: ReactNode
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const Badge = forwardRef<HTMLDivElement, BadgeProps>(function Badge(
|
|
37
|
+
{
|
|
38
|
+
testId = 'fs-badge',
|
|
39
|
+
size = 'small',
|
|
40
|
+
variant = 'neutral',
|
|
41
|
+
counter = false,
|
|
42
|
+
'aria-label': ariaLabel,
|
|
43
|
+
children,
|
|
44
|
+
...otherProps
|
|
45
|
+
}: BadgeProps,
|
|
46
|
+
ref
|
|
47
|
+
) {
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
ref={ref}
|
|
51
|
+
data-fs-badge
|
|
52
|
+
data-testid={testId}
|
|
53
|
+
aria-label={ariaLabel}
|
|
54
|
+
data-fs-badge-variant={counter ? null : variant}
|
|
55
|
+
data-fs-badge-size={size}
|
|
56
|
+
data-fs-badge-counter={counter}
|
|
57
|
+
{...otherProps}
|
|
58
|
+
>
|
|
59
|
+
<div data-fs-badge-wrapper>{children}</div>
|
|
60
|
+
</div>
|
|
61
|
+
)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
export default Badge
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ReactNode, ButtonHTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
import { Icon } from '../../index'
|
|
4
|
+
|
|
5
|
+
export type Variant = 'primary' | 'secondary' | 'tertiary'
|
|
6
|
+
export type Size = 'small' | 'regular'
|
|
7
|
+
export type IconPosition = 'left' | 'right'
|
|
8
|
+
|
|
9
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
10
|
+
/**
|
|
11
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
12
|
+
*/
|
|
13
|
+
testId?: string
|
|
14
|
+
/**
|
|
15
|
+
* Specifies the component color variant.
|
|
16
|
+
*/
|
|
17
|
+
variant?: Variant
|
|
18
|
+
/**
|
|
19
|
+
* Specifies the size variant.
|
|
20
|
+
*/
|
|
21
|
+
size?: Size
|
|
22
|
+
/**
|
|
23
|
+
* Defines the use of inverted colors.
|
|
24
|
+
*/
|
|
25
|
+
inverse?: boolean
|
|
26
|
+
/**
|
|
27
|
+
* Specifies that this button should be disabled
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean
|
|
30
|
+
/**
|
|
31
|
+
* A React component that will be rendered as an icon.
|
|
32
|
+
*/
|
|
33
|
+
icon?: ReactNode
|
|
34
|
+
/**
|
|
35
|
+
* Specifies where the icon should be positioned
|
|
36
|
+
*/
|
|
37
|
+
iconPosition?: IconPosition
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
|
|
41
|
+
{
|
|
42
|
+
children,
|
|
43
|
+
variant,
|
|
44
|
+
inverse,
|
|
45
|
+
size = 'regular',
|
|
46
|
+
testId = 'fs-button',
|
|
47
|
+
icon,
|
|
48
|
+
iconPosition = 'left',
|
|
49
|
+
disabled,
|
|
50
|
+
...otherProps
|
|
51
|
+
},
|
|
52
|
+
ref
|
|
53
|
+
) {
|
|
54
|
+
return (
|
|
55
|
+
<button
|
|
56
|
+
ref={ref}
|
|
57
|
+
data-testid={testId}
|
|
58
|
+
data-fs-button
|
|
59
|
+
data-fs-button-inverse={inverse}
|
|
60
|
+
data-fs-button-size={size}
|
|
61
|
+
data-fs-button-variant={variant}
|
|
62
|
+
disabled={disabled}
|
|
63
|
+
{...otherProps}
|
|
64
|
+
>
|
|
65
|
+
{icon && iconPosition === 'left' && <Icon component={icon} />}
|
|
66
|
+
{children}
|
|
67
|
+
{icon && iconPosition === 'right' && <Icon component={icon} />}
|
|
68
|
+
</button>
|
|
69
|
+
)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
export default Button
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { InputHTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface CheckboxProps
|
|
5
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
6
|
+
/**
|
|
7
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
/**
|
|
11
|
+
* Boolean that represents a partial state.
|
|
12
|
+
*/
|
|
13
|
+
partial?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(
|
|
17
|
+
{ testId = 'fs-checkbox', partial, ...otherProps }: CheckboxProps,
|
|
18
|
+
ref
|
|
19
|
+
) {
|
|
20
|
+
return (
|
|
21
|
+
<input
|
|
22
|
+
ref={ref}
|
|
23
|
+
data-fs-checkbox
|
|
24
|
+
data-testid={testId}
|
|
25
|
+
data-fs-checkbox-partial={partial}
|
|
26
|
+
type="checkbox"
|
|
27
|
+
{...otherProps}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
export default Checkbox
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface IconProps extends HTMLAttributes<HTMLSpanElement> {
|
|
5
|
+
/**
|
|
6
|
+
* A React component that will be rendered as an icon.
|
|
7
|
+
*/
|
|
8
|
+
component: ReactNode
|
|
9
|
+
/**
|
|
10
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
11
|
+
*/
|
|
12
|
+
testId?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Icon = forwardRef<HTMLSpanElement, IconProps>(function Button(
|
|
16
|
+
{ component, testId = 'fs-icon', ...otherProps }: IconProps,
|
|
17
|
+
ref
|
|
18
|
+
) {
|
|
19
|
+
return (
|
|
20
|
+
<span ref={ref} data-fs-icon data-testid={testId} {...otherProps}>
|
|
21
|
+
{component}
|
|
22
|
+
</span>
|
|
23
|
+
)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
export default Icon
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import type { LabelHTMLAttributes } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface LabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Label = forwardRef<HTMLLabelElement, LabelProps>(function Label(
|
|
12
|
+
{ testId = 'fs-label', children, ...otherProps }: LabelProps,
|
|
13
|
+
ref
|
|
14
|
+
) {
|
|
15
|
+
return (
|
|
16
|
+
<label ref={ref} data-fs-label data-testid={testId} {...otherProps}>
|
|
17
|
+
{children}
|
|
18
|
+
</label>
|
|
19
|
+
)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export default Label
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Overlay = forwardRef<HTMLDivElement, Props>(function Overlay(
|
|
12
|
+
{ testId = 'fs-overlay', ...otherProps },
|
|
13
|
+
ref
|
|
14
|
+
) {
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
role="presentation"
|
|
18
|
+
data-fs-overlay
|
|
19
|
+
data-testid={testId}
|
|
20
|
+
ref={ref}
|
|
21
|
+
{...otherProps}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
export default Overlay
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import type { InputHTMLAttributes } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface RadioProps
|
|
5
|
+
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
6
|
+
/**
|
|
7
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Radio = forwardRef<HTMLInputElement, RadioProps>(function Radio(
|
|
13
|
+
{ testId = 'fs-radio', ...otherProps }: RadioProps,
|
|
14
|
+
ref
|
|
15
|
+
) {
|
|
16
|
+
return (
|
|
17
|
+
<input
|
|
18
|
+
ref={ref}
|
|
19
|
+
data-fs-radio
|
|
20
|
+
data-testid={testId}
|
|
21
|
+
type="radio"
|
|
22
|
+
{...otherProps}
|
|
23
|
+
/>
|
|
24
|
+
)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export default Radio
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Atoms
|
|
2
|
+
export { default as Badge } from './atoms/Badge'
|
|
3
|
+
export type { BadgeProps } from './atoms/Badge'
|
|
4
|
+
export { default as Button } from './atoms/Button'
|
|
5
|
+
export type { ButtonProps } from './atoms/Button'
|
|
6
|
+
export { default as Checkbox } from './atoms/Checkbox'
|
|
7
|
+
export type { CheckboxProps } from './atoms/Checkbox'
|
|
8
|
+
export { default as Icon } from './atoms/Icon'
|
|
9
|
+
export type { IconProps } from './atoms/Icon'
|
|
10
|
+
export { default as Label } from './atoms/Label'
|
|
11
|
+
export type { LabelProps } from './atoms/Label'
|
|
12
|
+
export { default as Overlay } from './atoms/Overlay'
|
|
13
|
+
export type { OverlayProps } from './atoms/Overlay'
|
|
14
|
+
export { default as Radio } from './atoms/Radio'
|
|
15
|
+
export type { RadioProps } from './atoms/Radio'
|
|
16
|
+
|
|
17
|
+
// Molecules
|
|
18
|
+
export { default as CheckboxField } from './molecules/CheckboxField'
|
|
19
|
+
export type { CheckboxFieldProps } from './molecules/CheckboxField'
|
|
20
|
+
export { default as IconButton } from './molecules/IconButton'
|
|
21
|
+
export type { IconButtonProps } from './molecules/IconButton'
|
|
22
|
+
export { default as RadioField } from './molecules/RadioField'
|
|
23
|
+
export type { RadioFieldProps } from './molecules/RadioField'
|
|
24
|
+
export { default as Tag } from './molecules/Tag'
|
|
25
|
+
export type { TagProps } from './molecules/Tag'
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import Checkbox from '../../atoms/Checkbox'
|
|
3
|
+
import Label from '../../atoms/Label'
|
|
4
|
+
|
|
5
|
+
export type CheckboxFieldProps = {
|
|
6
|
+
/**
|
|
7
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
/**
|
|
11
|
+
* ID to identify input and corresponding label.
|
|
12
|
+
*/
|
|
13
|
+
id: string
|
|
14
|
+
/**
|
|
15
|
+
* The text displayed to identify the input checkbox.
|
|
16
|
+
*/
|
|
17
|
+
label: string
|
|
18
|
+
/**
|
|
19
|
+
* The value to identify the input checkbox.
|
|
20
|
+
*/
|
|
21
|
+
value?: string
|
|
22
|
+
/**
|
|
23
|
+
* Identify checkbox in the same group.
|
|
24
|
+
*/
|
|
25
|
+
name?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const CheckboxField = forwardRef<HTMLDivElement, CheckboxFieldProps>(
|
|
29
|
+
function CheckboxField(
|
|
30
|
+
{ testId = 'fs-checkbox-field', id, label, value, name, ...otherProps },
|
|
31
|
+
ref
|
|
32
|
+
) {
|
|
33
|
+
return (
|
|
34
|
+
<div ref={ref} data-fs-checkbox-field data-testid={testId}>
|
|
35
|
+
<Checkbox id={id} value={value ?? label} name={name} {...otherProps} />
|
|
36
|
+
<Label htmlFor={id}>{label}</Label>
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
export default CheckboxField
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReactNode, AriaAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
import { Icon, Button } from '../../index'
|
|
5
|
+
import type { ButtonProps } from '../../index'
|
|
6
|
+
|
|
7
|
+
export interface IconButtonProps extends Omit<ButtonProps, 'aria-label'> {
|
|
8
|
+
/**
|
|
9
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
10
|
+
*/
|
|
11
|
+
testId?: string
|
|
12
|
+
/**
|
|
13
|
+
* A React component that will be rendered as an icon.
|
|
14
|
+
*/
|
|
15
|
+
icon: ReactNode
|
|
16
|
+
/**
|
|
17
|
+
* A Label should be provided.
|
|
18
|
+
*/
|
|
19
|
+
'aria-label': AriaAttributes['aria-label']
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
23
|
+
function IconButton(
|
|
24
|
+
{
|
|
25
|
+
icon,
|
|
26
|
+
children,
|
|
27
|
+
testId = 'fs-icon-button',
|
|
28
|
+
'aria-label': ariaLabel,
|
|
29
|
+
variant,
|
|
30
|
+
...otherProps
|
|
31
|
+
},
|
|
32
|
+
ref
|
|
33
|
+
) {
|
|
34
|
+
return (
|
|
35
|
+
<Button
|
|
36
|
+
ref={ref}
|
|
37
|
+
data-fs-button
|
|
38
|
+
data-fs-icon-button
|
|
39
|
+
testId={testId}
|
|
40
|
+
variant={variant ?? 'tertiary'}
|
|
41
|
+
aria-label={ariaLabel}
|
|
42
|
+
{...otherProps}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
<Icon component={icon} />
|
|
46
|
+
</Button>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
export default IconButton
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import Label from '../../atoms/Label'
|
|
2
|
+
import Radio from '../../atoms/Radio'
|
|
3
|
+
import React, { forwardRef } from 'react'
|
|
4
|
+
|
|
5
|
+
export type RadioFieldProps = {
|
|
6
|
+
/**
|
|
7
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
/**
|
|
11
|
+
* ID to identify input and corresponding label.
|
|
12
|
+
*/
|
|
13
|
+
id: string
|
|
14
|
+
/**
|
|
15
|
+
* The text displayed to identify the input radio.
|
|
16
|
+
*/
|
|
17
|
+
label: string
|
|
18
|
+
/**
|
|
19
|
+
* The value to identify the input radio.
|
|
20
|
+
*/
|
|
21
|
+
value?: string
|
|
22
|
+
/**
|
|
23
|
+
* Identify radio in the same group.
|
|
24
|
+
*/
|
|
25
|
+
name?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const RadioField = forwardRef<HTMLDivElement, RadioFieldProps>(
|
|
29
|
+
function RadioField(
|
|
30
|
+
{ testId = 'fs-radio-field', id, label, value, name, ...otherProps },
|
|
31
|
+
ref
|
|
32
|
+
) {
|
|
33
|
+
return (
|
|
34
|
+
<div ref={ref} data-fs-radio-field data-testid={testId}>
|
|
35
|
+
<Radio id={id} value={value ?? label} name={name} {...otherProps} />
|
|
36
|
+
<Label htmlFor={id}>{label}</Label>
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
export default RadioField
|