@faststore/components 2.0.3-alpha.0 → 2.0.4-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.
Files changed (98) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/assets/ShoppingCart.d.ts +3 -0
  3. package/dist/assets/ShoppingCart.js +10 -0
  4. package/dist/assets/ShoppingCart.js.map +1 -0
  5. package/dist/assets/X.d.ts +3 -0
  6. package/dist/assets/X.js +8 -0
  7. package/dist/assets/X.js.map +1 -0
  8. package/dist/assets/index.d.ts +2 -0
  9. package/dist/assets/index.js +3 -0
  10. package/dist/assets/index.js.map +1 -0
  11. package/dist/atoms/Badge/Badge.d.ts +28 -0
  12. package/dist/atoms/Badge/Badge.js +7 -0
  13. package/dist/atoms/Badge/Badge.js.map +1 -0
  14. package/dist/atoms/Badge/index.d.ts +2 -0
  15. package/dist/atoms/Badge/index.js +2 -0
  16. package/dist/atoms/Badge/index.js.map +1 -0
  17. package/dist/atoms/Button/Button.d.ts +37 -0
  18. package/dist/atoms/Button/Button.js +10 -0
  19. package/dist/atoms/Button/Button.js.map +1 -0
  20. package/dist/atoms/Button/index.d.ts +2 -0
  21. package/dist/atoms/Button/index.js +2 -0
  22. package/dist/atoms/Button/index.js.map +1 -0
  23. package/dist/atoms/Checkbox/Checkbox.d.ts +14 -0
  24. package/dist/atoms/Checkbox/Checkbox.js +6 -0
  25. package/dist/atoms/Checkbox/Checkbox.js.map +1 -0
  26. package/dist/atoms/Checkbox/index.d.ts +2 -0
  27. package/dist/atoms/Checkbox/index.js +2 -0
  28. package/dist/atoms/Checkbox/index.js.map +1 -0
  29. package/dist/atoms/Icon/Icon.d.ts +14 -0
  30. package/dist/atoms/Icon/Icon.js +6 -0
  31. package/dist/atoms/Icon/Icon.js.map +1 -0
  32. package/dist/atoms/Icon/index.d.ts +2 -0
  33. package/dist/atoms/Icon/index.js +2 -0
  34. package/dist/atoms/Icon/index.js.map +1 -0
  35. package/dist/atoms/Label/Label.d.ts +10 -0
  36. package/dist/atoms/Label/Label.js +6 -0
  37. package/dist/atoms/Label/Label.js.map +1 -0
  38. package/dist/atoms/Label/index.d.ts +2 -0
  39. package/dist/atoms/Label/index.js +2 -0
  40. package/dist/atoms/Label/index.js.map +1 -0
  41. package/dist/atoms/Radio/Radio.d.ts +10 -0
  42. package/dist/atoms/Radio/Radio.js +6 -0
  43. package/dist/atoms/Radio/Radio.js.map +1 -0
  44. package/dist/atoms/Radio/index.d.ts +2 -0
  45. package/dist/atoms/Radio/index.js +2 -0
  46. package/dist/atoms/Radio/index.js.map +1 -0
  47. package/dist/index.d.ts +20 -0
  48. package/dist/index.js +13 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/molecules/CheckboxField/CheckboxField.d.ts +25 -0
  51. package/dist/molecules/CheckboxField/CheckboxField.js +10 -0
  52. package/dist/molecules/CheckboxField/CheckboxField.js.map +1 -0
  53. package/dist/molecules/CheckboxField/index.d.ts +2 -0
  54. package/dist/molecules/CheckboxField/index.js +2 -0
  55. package/dist/molecules/CheckboxField/index.js.map +1 -0
  56. package/dist/molecules/IconButton/IconButton.d.ts +19 -0
  57. package/dist/molecules/IconButton/IconButton.js +9 -0
  58. package/dist/molecules/IconButton/IconButton.js.map +1 -0
  59. package/dist/molecules/IconButton/index.d.ts +2 -0
  60. package/dist/molecules/IconButton/index.js +2 -0
  61. package/dist/molecules/IconButton/index.js.map +1 -0
  62. package/dist/molecules/RadioField/RadioField.d.ts +25 -0
  63. package/dist/molecules/RadioField/RadioField.js +10 -0
  64. package/dist/molecules/RadioField/RadioField.js.map +1 -0
  65. package/dist/molecules/RadioField/index.d.ts +2 -0
  66. package/dist/molecules/RadioField/index.js +2 -0
  67. package/dist/molecules/RadioField/index.js.map +1 -0
  68. package/dist/molecules/Tag/Tag.d.ts +27 -0
  69. package/dist/molecules/Tag/Tag.js +12 -0
  70. package/dist/molecules/Tag/Tag.js.map +1 -0
  71. package/dist/molecules/Tag/index.d.ts +2 -0
  72. package/dist/molecules/Tag/index.js +2 -0
  73. package/dist/molecules/Tag/index.js.map +1 -0
  74. package/package.json +27 -3
  75. package/src/assets/ShoppingCart.tsx +51 -0
  76. package/src/assets/X.tsx +39 -0
  77. package/src/assets/index.ts +2 -0
  78. package/src/atoms/Badge/Badge.tsx +64 -0
  79. package/src/atoms/Badge/index.ts +2 -0
  80. package/src/atoms/Button/Button.tsx +72 -0
  81. package/src/atoms/Button/index.ts +2 -0
  82. package/src/atoms/Checkbox/Checkbox.tsx +32 -0
  83. package/src/atoms/Checkbox/index.ts +2 -0
  84. package/src/atoms/Icon/Icon.tsx +26 -0
  85. package/src/atoms/Icon/index.ts +2 -0
  86. package/src/atoms/Label/Label.tsx +22 -0
  87. package/src/atoms/Label/index.ts +2 -0
  88. package/src/atoms/Radio/Radio.tsx +27 -0
  89. package/src/atoms/Radio/index.ts +2 -0
  90. package/src/index.ts +23 -0
  91. package/src/molecules/CheckboxField/CheckboxField.tsx +42 -0
  92. package/src/molecules/CheckboxField/index.ts +2 -0
  93. package/src/molecules/IconButton/IconButton.tsx +51 -0
  94. package/src/molecules/IconButton/index.ts +2 -0
  95. package/src/molecules/RadioField/RadioField.tsx +42 -0
  96. package/src/molecules/RadioField/index.ts +2 -0
  97. package/src/molecules/Tag/Tag.tsx +54 -0
  98. package/src/molecules/Tag/index.ts +2 -0
package/package.json CHANGED
@@ -1,8 +1,32 @@
1
1
  {
2
2
  "name": "@faststore/components",
3
- "version": "2.0.3-alpha.0",
4
- "main": "index.js",
3
+ "version": "2.0.4-alpha.0",
4
+ "module": "dist/index.js",
5
+ "typings": "dist/index.d.ts",
5
6
  "author": "Emerson Laurentino @emersonlaurentino",
6
7
  "license": "MIT",
7
- "gitHead": "6743690f41d38a7f6a1060f541775c8a6f82e2f5"
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": "e15f55dc806232292a13e286bf91fe527fcc3a32"
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
@@ -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,2 @@
1
+ export { default as X } from './X'
2
+ export { default as ShoppingCart } from './ShoppingCart'
@@ -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,2 @@
1
+ export { default } from './Badge'
2
+ export type { BadgeProps } from './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,2 @@
1
+ export { default } from './Button'
2
+ export type { ButtonProps } from './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,2 @@
1
+ export { default } from './Checkbox'
2
+ export type { CheckboxProps } from './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,2 @@
1
+ export { default } from './Icon'
2
+ export type { IconProps } from './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,2 @@
1
+ export { default } from './Label'
2
+ export type { LabelProps } from './Label'
@@ -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
@@ -0,0 +1,2 @@
1
+ export { default } from './Radio'
2
+ export type { RadioProps } from './Radio'
package/src/index.ts ADDED
@@ -0,0 +1,23 @@
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 Radio } from './atoms/Radio'
13
+ export type { RadioProps } from './atoms/Radio'
14
+
15
+ // Molecules
16
+ export { default as CheckboxField } from './molecules/CheckboxField'
17
+ export type { CheckboxFieldProps } from './molecules/CheckboxField'
18
+ export { default as IconButton } from './molecules/IconButton'
19
+ export type { IconButtonProps } from './molecules/IconButton'
20
+ export { default as RadioField } from './molecules/RadioField'
21
+ export type { RadioFieldProps } from './molecules/RadioField'
22
+ export { default as Tag } from './molecules/Tag'
23
+ 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,2 @@
1
+ export { default } from './CheckboxField'
2
+ export type { CheckboxFieldProps } from './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,2 @@
1
+ export { default } from './IconButton'
2
+ export type { IconButtonProps } from './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
@@ -0,0 +1,2 @@
1
+ export { default } from './RadioField'
2
+ export type { RadioFieldProps } from './RadioField'
@@ -0,0 +1,54 @@
1
+ import React, { forwardRef } from 'react'
2
+ import type { ReactNode } from 'react'
3
+ import { Icon } from '../..'
4
+ import { Badge, BadgeProps } from '../..'
5
+ import { X } from '../../assets'
6
+
7
+ export interface TagProps extends BadgeProps {
8
+ /**
9
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
10
+ */
11
+ testId?: string
12
+ /**
13
+ * The text displayed inside the tag.
14
+ */
15
+ label: string
16
+ /**
17
+ * A React component that will be rendered as an icon.
18
+ */
19
+ icon?: ReactNode
20
+ /**
21
+ * For accessibility purposes, provide an ARIA label to the Icon button
22
+ */
23
+ iconButtonLabel?: string
24
+ /**
25
+ * Function called when Icon button is clicked.
26
+ */
27
+ onClose: () => void
28
+ }
29
+
30
+ const Tag = forwardRef<HTMLDivElement, TagProps>(function Tag(
31
+ { testId = 'fs-tag', label, icon, iconButtonLabel, onClose, ...otherProps },
32
+ ref
33
+ ) {
34
+ return (
35
+ <Badge
36
+ ref={ref}
37
+ data-fs-tag
38
+ data-testid={testId}
39
+ size="big"
40
+ {...otherProps}
41
+ >
42
+ <span data-fs-tag-label>{label}</span>
43
+ <button
44
+ data-fs-tag-icon-button
45
+ aria-label={iconButtonLabel ? iconButtonLabel : 'remove'}
46
+ onClick={onClose}
47
+ >
48
+ <Icon component={icon ? icon : <X />} />
49
+ </button>
50
+ </Badge>
51
+ )
52
+ })
53
+
54
+ export default Tag
@@ -0,0 +1,2 @@
1
+ export { default } from './Tag'
2
+ export type { TagProps } from './Tag'