@faststore/components 2.0.10-alpha.0 → 2.0.13-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 CHANGED
@@ -3,6 +3,15 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.13-alpha.0](https://github.com/vtex/faststore/compare/v2.0.12-alpha.0...v2.0.13-alpha.0) (2022-12-14)
7
+
8
+
9
+ ### Features
10
+
11
+ * Adds `Select` and `SelectField` components ([#1547](https://github.com/vtex/faststore/issues/1547)) ([7c4beb0](https://github.com/vtex/faststore/commit/7c4beb085c893ad540e1a4440cc7b902fa36a75c))
12
+
13
+
14
+
6
15
  ## [2.0.10-alpha.0](https://github.com/vtex/faststore/compare/v2.0.9-alpha.0...v2.0.10-alpha.0) (2022-12-12)
7
16
 
8
17
 
@@ -0,0 +1,3 @@
1
+ import type { FC } from 'react';
2
+ declare const CaretDown: FC;
3
+ export default CaretDown;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ // Icon from Phosphor Icons
3
+ const CaretDown = () => (React.createElement("svg", { id: "CaretDown", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: "0 0 256 256", strokeWidth: "16", width: 24, height: 24 },
4
+ React.createElement("rect", { width: "256", height: "256", fill: "none" }),
5
+ React.createElement("polyline", { points: "208 96 128 176 48 96", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "24" })));
6
+ export default CaretDown;
7
+ //# sourceMappingURL=CaretDown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CaretDown.js","sourceRoot":"","sources":["../../src/assets/CaretDown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,2BAA2B;AAC3B,MAAM,SAAS,GAAO,GAAG,EAAE,CAAC,CAC1B,6BACE,EAAE,EAAC,WAAW,EACd,KAAK,EAAC,4BAA4B,EAClC,IAAI,EAAC,cAAc,EACnB,OAAO,EAAC,aAAa,EACrB,WAAW,EAAC,IAAI,EAChB,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE;IAEV,8BAAM,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,GAAQ;IAClD,kCAAU,MAAM,EAAC,sBAAsB,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,GAAY,CAC/I,CACP,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -1,3 +1,4 @@
1
+ export { default as CaretDown } from './CaretDown';
1
2
  export { default as X } from './X';
2
3
  export { default as ShoppingCart } from './ShoppingCart';
3
4
  export { default as XCircle } from './XCircle';
@@ -1,3 +1,4 @@
1
+ export { default as CaretDown } from './CaretDown';
1
2
  export { default as X } from './X';
2
3
  export { default as ShoppingCart } from './ShoppingCart';
3
4
  export { default as XCircle } from './XCircle';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,KAAK,CAAA;AAClC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,KAAK,CAAA;AAClC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA"}
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import type { SelectHTMLAttributes } from 'react';
3
+ export interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
4
+ /**
5
+ * Assigns an identifier to link the UISelect component and its label.
6
+ */
7
+ id: string;
8
+ /**
9
+ * Defines the options available in the select. The SelectOptions object
10
+ * keys are the property names, while the values correspond to the text that
11
+ * will be displayed in the UI.
12
+ */
13
+ options: Record<string, string>;
14
+ /**
15
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
16
+ */
17
+ testId?: string;
18
+ }
19
+ declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLSelectElement>>;
20
+ export default Select;
@@ -0,0 +1,10 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { Icon } from '../..';
3
+ import { CaretDown } from '../../assets';
4
+ const Select = forwardRef(function Select({ options, id, testId = 'fs-select', ...otherProps }, ref) {
5
+ return (React.createElement("div", { "data-fs-select": true },
6
+ React.createElement("select", { id: id, ref: ref, "data-testid": testId, ...otherProps }, Object.keys(options).map((key) => (React.createElement("option", { key: key, value: key }, options[key])))),
7
+ React.createElement(Icon, { "data-fs-select-icon": true, component: React.createElement(CaretDown, null) })));
8
+ });
9
+ export default Select;
10
+ //# sourceMappingURL=Select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../src/atoms/Select/Select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAmBxC,MAAM,MAAM,GAAG,UAAU,CAAiC,SAAS,MAAM,CACvE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,EAAE,GAAG,UAAU,EAAe,EACjE,GAAG;IAEH,OAAO,CACL;QACE,gCAAQ,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,iBAAe,MAAM,KAAM,UAAU,IAC1D,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CACjC,gCAAQ,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IACzB,OAAO,CAAC,GAAG,CAAC,CACN,CACV,CAAC,CACK;QACT,oBAAC,IAAI,iCAAqB,SAAS,EAAE,oBAAC,SAAS,OAAG,GAAG,CACjD,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { default } from './Select';
2
+ export type { SelectProps } from './Select';
@@ -0,0 +1,2 @@
1
+ export { default } from './Select';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/atoms/Select/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA"}
package/dist/index.d.ts CHANGED
@@ -16,6 +16,8 @@ export { default as Price } from './atoms/Price';
16
16
  export type { PriceProps } from './atoms/Price';
17
17
  export { default as Radio } from './atoms/Radio';
18
18
  export type { RadioProps } from './atoms/Radio';
19
+ export { default as Select } from './atoms/Select';
20
+ export type { SelectProps } from './atoms/Select';
19
21
  export { default as BuyButton } from './molecules/BuyButton';
20
22
  export { default as CheckboxField } from './molecules/CheckboxField';
21
23
  export type { CheckboxFieldProps } from './molecules/CheckboxField';
@@ -27,5 +29,7 @@ export { default as InputField } from './molecules/InputField';
27
29
  export type { InputFieldProps } from './molecules/InputField';
28
30
  export { default as RadioField } from './molecules/RadioField';
29
31
  export type { RadioFieldProps } from './molecules/RadioField';
32
+ export { default as SelectField } from './molecules/SelectField';
33
+ export type { SelectFieldProps } from './molecules/SelectField';
30
34
  export { default as Tag } from './molecules/Tag';
31
35
  export type { TagProps } from './molecules/Tag';
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export { default as Label } from './atoms/Label';
8
8
  export { default as Overlay } from './atoms/Overlay';
9
9
  export { default as Price } from './atoms/Price';
10
10
  export { default as Radio } from './atoms/Radio';
11
+ export { default as Select } from './atoms/Select';
11
12
  // Molecules
12
13
  export { default as BuyButton } from './molecules/BuyButton';
13
14
  export { default as CheckboxField } from './molecules/CheckboxField';
@@ -15,5 +16,6 @@ export { default as IconButton } from './molecules/IconButton';
15
16
  export { default as DiscountBadge } from './molecules/DiscountBadge';
16
17
  export { default as InputField } from './molecules/InputField';
17
18
  export { default as RadioField } from './molecules/RadioField';
19
+ export { default as SelectField } from './molecules/SelectField';
18
20
  export { default as Tag } from './molecules/Tag';
19
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEpD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAGhD,YAAY;AACZ,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MA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CAAA;AAEpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAE9D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { SelectProps } from '../../atoms/Select';
3
+ export interface SelectFieldProps extends SelectProps {
4
+ /**
5
+ * Defines the text displayed in the label right next to the Select.
6
+ */
7
+ label: string;
8
+ }
9
+ declare const SelectField: React.ForwardRefExoticComponent<SelectFieldProps & {
10
+ children?: React.ReactNode;
11
+ } & React.RefAttributes<HTMLDivElement>>;
12
+ export default SelectField;
@@ -0,0 +1,10 @@
1
+ import React, { forwardRef } from 'react';
2
+ import Select from '../../atoms/Select';
3
+ import Label from '../../atoms/Label';
4
+ const SelectField = forwardRef(function SelectField({ id, label, options, testId = 'fs-select-field', ...otherProps }, ref) {
5
+ return (React.createElement("div", { ref: ref, "data-fs-select-field": true, "data-testid": testId },
6
+ React.createElement(Label, { "data-fs-select-field-label": true, htmlFor: id }, label),
7
+ React.createElement(Select, { id: id, options: options, ...otherProps })));
8
+ });
9
+ export default SelectField;
10
+ //# sourceMappingURL=SelectField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectField.js","sourceRoot":"","sources":["../../../src/molecules/SelectField/SelectField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,MAAM,MAAM,oBAAoB,CAAA;AAEvC,OAAO,KAAK,MAAM,mBAAmB,CAAA;AASrC,MAAM,WAAW,GAAG,UAAU,CAC5B,SAAS,WAAW,CAClB,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,iBAAiB,EAAE,GAAG,UAAU,EAAE,EACjE,GAAG;IAEH,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,+CAAoC,MAAM;QACrD,oBAAC,KAAK,wCAA4B,OAAO,EAAE,EAAE,IAAG,KAAK,CAAS;QAC9D,oBAAC,MAAM,IAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,KAAM,UAAU,GAAI,CAChD,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,WAAW,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { default } from './SelectField';
2
+ export type { SelectFieldProps } from './SelectField';
@@ -0,0 +1,2 @@
1
+ export { default } from './SelectField';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/SelectField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/components",
3
- "version": "2.0.10-alpha.0",
3
+ "version": "2.0.13-alpha.0",
4
4
  "module": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "author": "Emerson Laurentino @emersonlaurentino",
@@ -28,5 +28,5 @@
28
28
  "node": "16.18.0",
29
29
  "yarn": "1.19.1"
30
30
  },
31
- "gitHead": "640305492dc03e55d3df05de18bcca8587d562fc"
31
+ "gitHead": "c513c94b5b36c43355224db4c179cbe4362117ea"
32
32
  }
@@ -0,0 +1,20 @@
1
+ import React from 'react'
2
+ import type { FC } from 'react'
3
+
4
+ // Icon from Phosphor Icons
5
+ const CaretDown: FC = () => (
6
+ <svg
7
+ id="CaretDown"
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
+ <polyline points="208 96 128 176 48 96" fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="24"></polyline>
17
+ </svg>
18
+ )
19
+
20
+ export default CaretDown
@@ -1,3 +1,4 @@
1
+ export { default as CaretDown } from './CaretDown'
1
2
  export { default as X } from './X'
2
3
  export { default as ShoppingCart } from './ShoppingCart'
3
4
  export { default as XCircle } from './XCircle'
@@ -0,0 +1,41 @@
1
+ import React, { forwardRef } from 'react'
2
+ import type { SelectHTMLAttributes } from 'react'
3
+ import { Icon } from '../..'
4
+ import { CaretDown } from '../../assets'
5
+
6
+ export interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
7
+ /**
8
+ * Assigns an identifier to link the UISelect component and its label.
9
+ */
10
+ id: string
11
+ /**
12
+ * Defines the options available in the select. The SelectOptions object
13
+ * keys are the property names, while the values correspond to the text that
14
+ * will be displayed in the UI.
15
+ */
16
+ options: Record<string, string>
17
+ /**
18
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
19
+ */
20
+ testId?: string
21
+ }
22
+
23
+ const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(
24
+ { options, id, testId = 'fs-select', ...otherProps }: SelectProps,
25
+ ref
26
+ ) {
27
+ return (
28
+ <div data-fs-select>
29
+ <select id={id} ref={ref} data-testid={testId} {...otherProps}>
30
+ {Object.keys(options).map((key) => (
31
+ <option key={key} value={key}>
32
+ {options[key]}
33
+ </option>
34
+ ))}
35
+ </select>
36
+ <Icon data-fs-select-icon component={<CaretDown />}/>
37
+ </div>
38
+ )
39
+ })
40
+
41
+ export default Select
@@ -0,0 +1,2 @@
1
+ export { default } from './Select'
2
+ export type { SelectProps } from './Select'
package/src/index.ts CHANGED
@@ -17,6 +17,8 @@ export { default as Price } from './atoms/Price'
17
17
  export type { PriceProps } from './atoms/Price'
18
18
  export { default as Radio } from './atoms/Radio'
19
19
  export type { RadioProps } from './atoms/Radio'
20
+ export { default as Select } from './atoms/Select'
21
+ export type { SelectProps } from './atoms/Select'
20
22
 
21
23
  // Molecules
22
24
  export { default as BuyButton } from './molecules/BuyButton'
@@ -30,5 +32,7 @@ export { default as InputField } from './molecules/InputField'
30
32
  export type { InputFieldProps } from './molecules/InputField'
31
33
  export { default as RadioField } from './molecules/RadioField'
32
34
  export type { RadioFieldProps } from './molecules/RadioField'
35
+ export { default as SelectField } from './molecules/SelectField'
36
+ export type { SelectFieldProps } from './molecules/SelectField'
33
37
  export { default as Tag } from './molecules/Tag'
34
38
  export type { TagProps } from './molecules/Tag'
@@ -0,0 +1,28 @@
1
+ import React, { forwardRef } from 'react'
2
+ import type { PropsWithChildren } from 'react'
3
+ import Select from '../../atoms/Select'
4
+ import type {SelectProps} from '../../atoms/Select'
5
+ import Label from '../../atoms/Label'
6
+
7
+ export interface SelectFieldProps extends SelectProps {
8
+ /**
9
+ * Defines the text displayed in the label right next to the Select.
10
+ */
11
+ label: string
12
+ }
13
+
14
+ const SelectField = forwardRef<HTMLDivElement, PropsWithChildren<SelectFieldProps>>(
15
+ function SelectField(
16
+ { id, label, options, testId = 'fs-select-field', ...otherProps },
17
+ ref
18
+ ) {
19
+ return (
20
+ <div ref={ref} data-fs-select-field data-testid={testId}>
21
+ <Label data-fs-select-field-label htmlFor={id}>{label}</Label>
22
+ <Select id={id} options={options} {...otherProps} />
23
+ </div>
24
+ )
25
+ }
26
+ )
27
+
28
+ export default SelectField
@@ -0,0 +1,2 @@
1
+ export { default } from './SelectField'
2
+ export type { SelectFieldProps } from './SelectField'