@faststore/ui 1.10.30 → 1.10.31

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
+ ## [1.10.31](https://github.com/vtex/faststore/compare/v1.10.30...v1.10.31) (2022-08-02)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add fowardRef to `ProductTitle` ([#1427](https://github.com/vtex/faststore/issues/1427)) ([5f622f3](https://github.com/vtex/faststore/commit/5f622f3a28a32228aa457c0b1bd141969f541262))
12
+
13
+
14
+
6
15
  ## 1.10.30 (2022-08-02)
7
16
 
8
17
 
@@ -1,4 +1,4 @@
1
- import { HTMLAttributes } from 'react';
1
+ import React, { HTMLAttributes } from 'react';
2
2
  import type { ReactNode } from 'react';
3
3
  export declare type ProductTitleProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
4
4
  /**
@@ -22,5 +22,26 @@ export declare type ProductTitleProps = Omit<HTMLAttributes<HTMLElement>, 'title
22
22
  */
23
23
  testId?: string;
24
24
  };
25
- declare function ProductTitle({ title, label, refTag, refNumber, testId, ...otherProps }: ProductTitleProps): JSX.Element;
25
+ declare const ProductTitle: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLElement>, "title"> & {
26
+ /**
27
+ * A react component to be used as the product title, e.g. a `h1`
28
+ */
29
+ title: ReactNode;
30
+ /**
31
+ * A react component to be used as the product label, e.g. a `DiscountBadge`
32
+ */
33
+ label?: ReactNode;
34
+ /**
35
+ * Label for reference.
36
+ */
37
+ refTag?: string | undefined;
38
+ /**
39
+ * A text to be used below the title and the label, such as the product's reference number.
40
+ */
41
+ refNumber?: string | undefined;
42
+ /**
43
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
44
+ */
45
+ testId?: string | undefined;
46
+ } & React.RefAttributes<HTMLElement>>;
26
47
  export default ProductTitle;
@@ -1,12 +1,12 @@
1
- import React from 'react';
2
- function ProductTitle({ title, label, refTag = "Ref.: ", refNumber, testId = 'store-product-title', ...otherProps }) {
3
- return (React.createElement("header", Object.assign({ "data-fs-product-title": true, "data-testid": testId }, otherProps),
1
+ import React, { forwardRef } from 'react';
2
+ const ProductTitle = forwardRef(function ProductTitle({ title, label, refTag = "Ref.: ", refNumber, testId = 'store-product-title', ...otherProps }, ref) {
3
+ return (React.createElement("header", Object.assign({ ref: ref, "data-fs-product-title": true, "data-testid": testId }, otherProps),
4
4
  React.createElement("div", { "data-fs-product-title-header": true },
5
5
  title,
6
6
  !!label && label),
7
7
  refNumber && (React.createElement("p", { "data-fs-product-title-addendum": true },
8
8
  refTag,
9
9
  refNumber))));
10
- }
10
+ });
11
11
  export default ProductTitle;
12
12
  //# sourceMappingURL=ProductTitle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProductTitle.js","sourceRoot":"","sources":["../../../src/molecules/ProductTitle/ProductTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AA0B7C,SAAS,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,QAAQ,EAAC,SAAS,EAAE,MAAM,GAAE,qBAAqB,EAAE,GAAG,UAAU,EAAqB;IACjI,OAAO,CACL,4FAA2C,MAAM,IAAM,UAAU;QAC/D;YACG,KAAK;YACL,CAAC,CAAC,KAAK,IAAI,KAAK,CACb;QAEL,SAAS,IAAI,CACZ;YACG,MAAM;YAAE,SAAS,CAChB,CACL,CACM,CACV,CAAA;AACH,CAAC;AAED,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"ProductTitle.js","sourceRoot":"","sources":["../../../src/molecules/ProductTitle/ProductTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAA;AA0BzD,MAAM,YAAY,GAAG,UAAU,CAC7B,SAAS,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,QAAQ,EAAC,SAAS,EAAE,MAAM,GAAE,qBAAqB,EAAE,GAAG,UAAU,EAAE,EAAE,GAAG;IACnH,OAAO,CACL,8CAAQ,GAAG,EAAE,GAAG,gDAAqC,MAAM,IAAM,UAAU;QACzE;YACG,KAAK;YACL,CAAC,CAAC,KAAK,IAAI,KAAK,CACb;QAEL,SAAS,IAAI,CACZ;YACG,MAAM;YAAE,SAAS,CAChB,CACL,CACM,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/ui",
3
- "version": "1.10.30",
3
+ "version": "1.10.31",
4
4
  "description": "A lightweight, framework agnostic component library for React",
5
5
  "author": "emersonlaurentino",
6
6
  "license": "MIT",
@@ -85,5 +85,5 @@
85
85
  "tsdx": "^0.14.1",
86
86
  "typescript": "^4.2.4"
87
87
  },
88
- "gitHead": "4541012c9a6b238f1082c2cb92c4d6410c663795"
88
+ "gitHead": "cd75cbdac4910c60b9ff42ab7bc830d2dc35ba49"
89
89
  }
@@ -1,4 +1,4 @@
1
- import React, { HTMLAttributes } from 'react'
1
+ import React, { forwardRef, HTMLAttributes } from 'react'
2
2
  import type { ReactNode } from 'react'
3
3
 
4
4
  export type ProductTitleProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
@@ -24,21 +24,23 @@ export type ProductTitleProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
24
24
  testId?: string
25
25
  }
26
26
 
27
- function ProductTitle({ title, label, refTag= "Ref.: ",refNumber, testId= 'store-product-title', ...otherProps }: ProductTitleProps) {
28
- return (
29
- <header data-fs-product-title data-testid={testId} {...otherProps}>
30
- <div data-fs-product-title-header>
31
- {title}
32
- {!!label && label}
33
- </div>
27
+ const ProductTitle = forwardRef<HTMLElement, ProductTitleProps>(
28
+ function ProductTitle({ title, label, refTag= "Ref.: ",refNumber, testId= 'store-product-title', ...otherProps }, ref) {
29
+ return (
30
+ <header ref={ref} data-fs-product-title data-testid={testId} {...otherProps}>
31
+ <div data-fs-product-title-header>
32
+ {title}
33
+ {!!label && label}
34
+ </div>
34
35
 
35
- {refNumber && (
36
- <p data-fs-product-title-addendum>
37
- {refTag}{refNumber}
38
- </p>
39
- )}
40
- </header>
41
- )
42
- }
36
+ {refNumber && (
37
+ <p data-fs-product-title-addendum>
38
+ {refTag}{refNumber}
39
+ </p>
40
+ )}
41
+ </header>
42
+ )
43
+ }
44
+ )
43
45
 
44
46
  export default ProductTitle