@faststore/components 2.0.10-alpha.0 → 2.0.14-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/CaretDown.d.ts +3 -0
- package/dist/assets/CaretDown.js +7 -0
- package/dist/assets/CaretDown.js.map +1 -0
- package/dist/assets/index.d.ts +1 -0
- package/dist/assets/index.js +1 -0
- package/dist/assets/index.js.map +1 -1
- package/dist/atoms/Link/Link.d.ts +25 -0
- package/dist/atoms/Link/Link.js +7 -0
- package/dist/atoms/Link/Link.js.map +1 -0
- package/dist/atoms/Link/index.d.ts +2 -0
- package/dist/atoms/Link/index.js +2 -0
- package/dist/atoms/Link/index.js.map +1 -0
- package/dist/atoms/Select/Select.d.ts +20 -0
- package/dist/atoms/Select/Select.js +10 -0
- package/dist/atoms/Select/Select.js.map +1 -0
- package/dist/atoms/Select/index.d.ts +2 -0
- package/dist/atoms/Select/index.js +2 -0
- package/dist/atoms/Select/index.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/molecules/SelectField/SelectField.d.ts +12 -0
- package/dist/molecules/SelectField/SelectField.js +10 -0
- package/dist/molecules/SelectField/SelectField.js.map +1 -0
- package/dist/molecules/SelectField/index.d.ts +2 -0
- package/dist/molecules/SelectField/index.js +2 -0
- package/dist/molecules/SelectField/index.js.map +1 -0
- package/dist/typings/PolymorphicGenerics.d.ts +28 -0
- package/dist/typings/PolymorphicGenerics.js +8 -0
- package/dist/typings/PolymorphicGenerics.js.map +1 -0
- package/dist/typings/index.d.ts +1 -0
- package/dist/typings/index.js +2 -0
- package/dist/typings/index.js.map +1 -0
- package/package.json +2 -2
- package/src/assets/CaretDown.tsx +20 -0
- package/src/assets/index.ts +1 -0
- package/src/atoms/Link/Link.tsx +59 -0
- package/src/atoms/Link/index.ts +2 -0
- package/src/atoms/Select/Select.tsx +41 -0
- package/src/atoms/Select/index.ts +2 -0
- package/src/index.ts +9 -0
- package/src/molecules/SelectField/SelectField.tsx +28 -0
- package/src/molecules/SelectField/index.ts +2 -0
- package/src/typings/PolymorphicGenerics.ts +50 -0
- package/src/typings/index.ts +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.14-alpha.0](https://github.com/vtex/faststore/compare/v2.0.13-alpha.0...v2.0.14-alpha.0) (2022-12-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Adds `Link` component ([#1543](https://github.com/vtex/faststore/issues/1543)) ([9c219eb](https://github.com/vtex/faststore/commit/9c219eba996fc6fec90edd1383a4abf8dbe0a7ef))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [2.0.13-alpha.0](https://github.com/vtex/faststore/compare/v2.0.12-alpha.0...v2.0.13-alpha.0) (2022-12-14)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* Adds `Select` and `SelectField` components ([#1547](https://github.com/vtex/faststore/issues/1547)) ([7c4beb0](https://github.com/vtex/faststore/commit/7c4beb085c893ad540e1a4440cc7b902fa36a75c))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [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
25
|
|
|
8
26
|
|
|
@@ -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"}
|
package/dist/assets/index.d.ts
CHANGED
package/dist/assets/index.js
CHANGED
package/dist/assets/index.js.map
CHANGED
|
@@ -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,25 @@
|
|
|
1
|
+
import type { ElementType, ReactElement } from 'react';
|
|
2
|
+
import { PolymorphicComponentPropsWithRef } from '../../typings';
|
|
3
|
+
declare type LinkBaseProps = {
|
|
4
|
+
/**
|
|
5
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
6
|
+
*/
|
|
7
|
+
testId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Specifies the component variant.
|
|
10
|
+
*/
|
|
11
|
+
variant?: 'default' | 'display' | 'inline';
|
|
12
|
+
/**
|
|
13
|
+
* Defines use of inverted color.
|
|
14
|
+
*/
|
|
15
|
+
inverse?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Defines size os element
|
|
18
|
+
*/
|
|
19
|
+
size?: 'small' | 'regular';
|
|
20
|
+
};
|
|
21
|
+
export declare type LinkElementType = ElementType;
|
|
22
|
+
export declare type LinkProps<C extends LinkElementType = 'a'> = PolymorphicComponentPropsWithRef<C, LinkBaseProps>;
|
|
23
|
+
declare type LinkComponent = <C extends LinkElementType = 'a'>(props: LinkProps<C>) => ReactElement | null;
|
|
24
|
+
declare const Link: LinkComponent;
|
|
25
|
+
export default Link;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
const Link = forwardRef(function Link({ as, children, variant = 'default', size = "regular", inverse, testId = 'fs-link', ...otherProps }, ref) {
|
|
3
|
+
const Component = as ?? 'a';
|
|
4
|
+
return (React.createElement(Component, { ref: ref, "data-fs-link": true, "data-fs-link-variant": variant, "data-fs-link-inverse": inverse, "data-fs-link-size": size, "data-testid": testId, ...otherProps }, children));
|
|
5
|
+
});
|
|
6
|
+
export default Link;
|
|
7
|
+
//# sourceMappingURL=Link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/atoms/Link/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAkCzC,MAAM,IAAI,GAAkB,UAAU,CAAC,SAAS,IAAI,CAGlD,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,GAAG,SAAS,EAAE,IAAI,GAAC,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,UAAU,EAAgB,EAC/G,GAAuB;IAGvB,MAAM,SAAS,GAAG,EAAE,IAAI,GAAG,CAAA;IAE3B,OAAO,CACL,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,gDAEc,OAAO,0BACP,OAAO,uBACV,IAAI,iBACV,MAAM,KACf,UAAU,IAEb,QAAQ,CACC,CACb,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/atoms/Link/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,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 @@
|
|
|
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './assets';
|
|
1
2
|
export { default as Badge } from './atoms/Badge';
|
|
2
3
|
export type { BadgeProps } from './atoms/Badge';
|
|
3
4
|
export { default as Button } from './atoms/Button';
|
|
@@ -10,12 +11,16 @@ export { default as Input } from './atoms/Input';
|
|
|
10
11
|
export type { InputProps } from './atoms/Input';
|
|
11
12
|
export { default as Label } from './atoms/Label';
|
|
12
13
|
export type { LabelProps } from './atoms/Label';
|
|
14
|
+
export { default as Link } from './atoms/Link';
|
|
15
|
+
export type { LinkProps, LinkElementType } from './atoms/Link';
|
|
13
16
|
export { default as Overlay } from './atoms/Overlay';
|
|
14
17
|
export type { OverlayProps } from './atoms/Overlay';
|
|
15
18
|
export { default as Price } from './atoms/Price';
|
|
16
19
|
export type { PriceProps } from './atoms/Price';
|
|
17
20
|
export { default as Radio } from './atoms/Radio';
|
|
18
21
|
export type { RadioProps } from './atoms/Radio';
|
|
22
|
+
export { default as Select } from './atoms/Select';
|
|
23
|
+
export type { SelectProps } from './atoms/Select';
|
|
19
24
|
export { default as BuyButton } from './molecules/BuyButton';
|
|
20
25
|
export { default as CheckboxField } from './molecules/CheckboxField';
|
|
21
26
|
export type { CheckboxFieldProps } from './molecules/CheckboxField';
|
|
@@ -27,5 +32,7 @@ export { default as InputField } from './molecules/InputField';
|
|
|
27
32
|
export type { InputFieldProps } from './molecules/InputField';
|
|
28
33
|
export { default as RadioField } from './molecules/RadioField';
|
|
29
34
|
export type { RadioFieldProps } from './molecules/RadioField';
|
|
35
|
+
export { default as SelectField } from './molecules/SelectField';
|
|
36
|
+
export type { SelectFieldProps } from './molecules/SelectField';
|
|
30
37
|
export { default as Tag } from './molecules/Tag';
|
|
31
38
|
export type { TagProps } from './molecules/Tag';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Assets
|
|
2
|
+
export * from './assets';
|
|
1
3
|
// Atoms
|
|
2
4
|
export { default as Badge } from './atoms/Badge';
|
|
3
5
|
export { default as Button } from './atoms/Button';
|
|
@@ -5,9 +7,11 @@ export { default as Checkbox } from './atoms/Checkbox';
|
|
|
5
7
|
export { default as Icon } from './atoms/Icon';
|
|
6
8
|
export { default as Input } from './atoms/Input';
|
|
7
9
|
export { default as Label } from './atoms/Label';
|
|
10
|
+
export { default as Link } from './atoms/Link';
|
|
8
11
|
export { default as Overlay } from './atoms/Overlay';
|
|
9
12
|
export { default as Price } from './atoms/Price';
|
|
10
13
|
export { default as Radio } from './atoms/Radio';
|
|
14
|
+
export { default as Select } from './atoms/Select';
|
|
11
15
|
// Molecules
|
|
12
16
|
export { default as BuyButton } from './molecules/BuyButton';
|
|
13
17
|
export { default as CheckboxField } from './molecules/CheckboxField';
|
|
@@ -15,5 +19,6 @@ export { default as IconButton } from './molecules/IconButton';
|
|
|
15
19
|
export { default as DiscountBadge } from './molecules/DiscountBadge';
|
|
16
20
|
export { default as InputField } from './molecules/InputField';
|
|
17
21
|
export { default as RadioField } from './molecules/RadioField';
|
|
22
|
+
export { default as SelectField } from './molecules/SelectField';
|
|
18
23
|
export { default as Tag } from './molecules/Tag';
|
|
19
24
|
//# 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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,cAAc,UAAU,CAAA;AAExB,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,IAAI,EAAE,MAAM,cAAc,CAAA;AAE9C,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;AAEhD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGlD,YAAY;AACZ,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,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 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/SelectField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These were heavily inspired by "Forwarding refs for a polymorphic React
|
|
3
|
+
* component in TypeScript", written by Ben Ilegbodu.
|
|
4
|
+
*
|
|
5
|
+
* Article link: https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
|
|
6
|
+
*/
|
|
7
|
+
import type { ComponentPropsWithoutRef, ComponentPropsWithRef, ElementType } from 'react';
|
|
8
|
+
declare type AsProp<C extends ElementType> = {
|
|
9
|
+
as?: C;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
|
|
13
|
+
* (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
|
|
14
|
+
* set of props.
|
|
15
|
+
*/
|
|
16
|
+
declare type ExtendableProps<ExtendedProps = Record<string, never>, OverrideProps = Record<string, never>> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>;
|
|
17
|
+
/**
|
|
18
|
+
* Allows for inheriting the props from the specified element type so that
|
|
19
|
+
* props like children, className & style work, as well as element-specific
|
|
20
|
+
* attributes like aria roles. The component (`C`) must be passed in.
|
|
21
|
+
*/
|
|
22
|
+
declare type InheritableElementProps<C extends ElementType, Props = Record<string, never>> = ExtendableProps<ComponentPropsWithoutRef<C>, Props>;
|
|
23
|
+
export declare type PolymorphicComponentProps<C extends ElementType, Props = Record<string, never>> = InheritableElementProps<C, Props & AsProp<C>>;
|
|
24
|
+
export declare type PolymorphicComponentPropsWithRef<C extends ElementType, P = Record<string, never>> = PolymorphicComponentProps<C, P> & {
|
|
25
|
+
ref?: ComponentPropsWithRef<C>['ref'];
|
|
26
|
+
};
|
|
27
|
+
export declare type PolymorphicRef<C extends ElementType> = PolymorphicComponentPropsWithRef<C>['ref'];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These were heavily inspired by "Forwarding refs for a polymorphic React
|
|
3
|
+
* component in TypeScript", written by Ben Ilegbodu.
|
|
4
|
+
*
|
|
5
|
+
* Article link: https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=PolymorphicGenerics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolymorphicGenerics.js","sourceRoot":"","sources":["../../src/typings/PolymorphicGenerics.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { PolymorphicComponentProps, PolymorphicComponentPropsWithRef, PolymorphicRef, } from './PolymorphicGenerics';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/typings/index.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14-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": "
|
|
31
|
+
"gitHead": "a8f4ca0ddc690e24df31abee9e4a4bbdb2d1a03b"
|
|
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
|
package/src/assets/index.ts
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import type { ElementType, ReactElement } from 'react'
|
|
3
|
+
import { PolymorphicComponentPropsWithRef, PolymorphicRef } from '../../typings'
|
|
4
|
+
|
|
5
|
+
type LinkBaseProps = {
|
|
6
|
+
/**
|
|
7
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
/**
|
|
11
|
+
* Specifies the component variant.
|
|
12
|
+
*/
|
|
13
|
+
variant?: 'default' | 'display' | 'inline'
|
|
14
|
+
/**
|
|
15
|
+
* Defines use of inverted color.
|
|
16
|
+
*/
|
|
17
|
+
inverse?: boolean
|
|
18
|
+
/**
|
|
19
|
+
* Defines size os element
|
|
20
|
+
*/
|
|
21
|
+
size?: 'small' | 'regular'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type LinkElementType = ElementType
|
|
25
|
+
|
|
26
|
+
export type LinkProps<C extends LinkElementType = 'a'> = PolymorphicComponentPropsWithRef<
|
|
27
|
+
C,
|
|
28
|
+
LinkBaseProps
|
|
29
|
+
>
|
|
30
|
+
|
|
31
|
+
type LinkComponent = <C extends LinkElementType = 'a'>(
|
|
32
|
+
props: LinkProps<C>
|
|
33
|
+
) => ReactElement | null
|
|
34
|
+
|
|
35
|
+
const Link: LinkComponent = forwardRef(function Link<
|
|
36
|
+
C extends LinkElementType = 'a'
|
|
37
|
+
>(
|
|
38
|
+
{ as, children, variant = 'default', size="regular", inverse, testId = 'fs-link', ...otherProps }: LinkProps<C>,
|
|
39
|
+
ref?: PolymorphicRef<C>
|
|
40
|
+
) {
|
|
41
|
+
|
|
42
|
+
const Component = as ?? 'a'
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Component
|
|
46
|
+
ref={ref}
|
|
47
|
+
data-fs-link
|
|
48
|
+
data-fs-link-variant={variant}
|
|
49
|
+
data-fs-link-inverse={inverse}
|
|
50
|
+
data-fs-link-size={size}
|
|
51
|
+
data-testid={testId}
|
|
52
|
+
{...otherProps}
|
|
53
|
+
>
|
|
54
|
+
{children}
|
|
55
|
+
</Component>
|
|
56
|
+
)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
export default Link
|
|
@@ -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
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// Assets
|
|
2
|
+
export * from './assets'
|
|
3
|
+
|
|
1
4
|
// Atoms
|
|
2
5
|
export { default as Badge } from './atoms/Badge'
|
|
3
6
|
export type { BadgeProps } from './atoms/Badge'
|
|
@@ -11,12 +14,16 @@ export { default as Input } from './atoms/Input'
|
|
|
11
14
|
export type { InputProps } from './atoms/Input'
|
|
12
15
|
export { default as Label } from './atoms/Label'
|
|
13
16
|
export type { LabelProps } from './atoms/Label'
|
|
17
|
+
export { default as Link } from './atoms/Link'
|
|
18
|
+
export type { LinkProps, LinkElementType } from './atoms/Link'
|
|
14
19
|
export { default as Overlay } from './atoms/Overlay'
|
|
15
20
|
export type { OverlayProps } from './atoms/Overlay'
|
|
16
21
|
export { default as Price } from './atoms/Price'
|
|
17
22
|
export type { PriceProps } from './atoms/Price'
|
|
18
23
|
export { default as Radio } from './atoms/Radio'
|
|
19
24
|
export type { RadioProps } from './atoms/Radio'
|
|
25
|
+
export { default as Select } from './atoms/Select'
|
|
26
|
+
export type { SelectProps } from './atoms/Select'
|
|
20
27
|
|
|
21
28
|
// Molecules
|
|
22
29
|
export { default as BuyButton } from './molecules/BuyButton'
|
|
@@ -30,5 +37,7 @@ export { default as InputField } from './molecules/InputField'
|
|
|
30
37
|
export type { InputFieldProps } from './molecules/InputField'
|
|
31
38
|
export { default as RadioField } from './molecules/RadioField'
|
|
32
39
|
export type { RadioFieldProps } from './molecules/RadioField'
|
|
40
|
+
export { default as SelectField } from './molecules/SelectField'
|
|
41
|
+
export type { SelectFieldProps } from './molecules/SelectField'
|
|
33
42
|
export { default as Tag } from './molecules/Tag'
|
|
34
43
|
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,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* These were heavily inspired by "Forwarding refs for a polymorphic React
|
|
3
|
+
* component in TypeScript", written by Ben Ilegbodu.
|
|
4
|
+
*
|
|
5
|
+
* Article link: https://www.benmvp.com/blog/forwarding-refs-polymorphic-react-component-typescript/
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
ComponentPropsWithoutRef,
|
|
10
|
+
ComponentPropsWithRef,
|
|
11
|
+
ElementType,
|
|
12
|
+
} from 'react'
|
|
13
|
+
|
|
14
|
+
type AsProp<C extends ElementType> = {
|
|
15
|
+
as?: C
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Allows for extending a set of props (`ExtendedProps`) by an overriding set of props
|
|
20
|
+
* (`OverrideProps`), ensuring that any duplicates are overridden by the overriding
|
|
21
|
+
* set of props.
|
|
22
|
+
*/
|
|
23
|
+
type ExtendableProps<
|
|
24
|
+
ExtendedProps = Record<string, never>,
|
|
25
|
+
OverrideProps = Record<string, never>
|
|
26
|
+
> = OverrideProps & Omit<ExtendedProps, keyof OverrideProps>
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Allows for inheriting the props from the specified element type so that
|
|
30
|
+
* props like children, className & style work, as well as element-specific
|
|
31
|
+
* attributes like aria roles. The component (`C`) must be passed in.
|
|
32
|
+
*/
|
|
33
|
+
type InheritableElementProps<
|
|
34
|
+
C extends ElementType,
|
|
35
|
+
Props = Record<string, never>
|
|
36
|
+
> = ExtendableProps<ComponentPropsWithoutRef<C>, Props>
|
|
37
|
+
|
|
38
|
+
export type PolymorphicComponentProps<
|
|
39
|
+
C extends ElementType,
|
|
40
|
+
Props = Record<string, never>
|
|
41
|
+
> = InheritableElementProps<C, Props & AsProp<C>>
|
|
42
|
+
|
|
43
|
+
export type PolymorphicComponentPropsWithRef<
|
|
44
|
+
C extends ElementType,
|
|
45
|
+
P = Record<string, never>
|
|
46
|
+
> = PolymorphicComponentProps<C, P> & { ref?: ComponentPropsWithRef<C>['ref'] }
|
|
47
|
+
|
|
48
|
+
// Extract the `ref` prop from a polymorphic component
|
|
49
|
+
export type PolymorphicRef<C extends ElementType> =
|
|
50
|
+
PolymorphicComponentPropsWithRef<C>['ref']
|