@faststore/components 2.0.160-alpha.0 → 2.0.168-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.
@@ -1,4 +1,4 @@
1
- import type { HTMLAttributes } from 'react';
1
+ import type { HTMLAttributes, ReactNode } from 'react';
2
2
  import React from 'react';
3
3
  export interface RegionBarProps extends HTMLAttributes<HTMLDivElement> {
4
4
  /**
@@ -9,6 +9,22 @@ export interface RegionBarProps extends HTMLAttributes<HTMLDivElement> {
9
9
  * Function called when button is clicked.
10
10
  */
11
11
  onButtonClick?: () => void;
12
+ /**
13
+ * A React component that will be rendered as an icon.
14
+ */
15
+ icon?: ReactNode;
16
+ /**
17
+ * Specifies a label for the location text.
18
+ */
19
+ label: string;
20
+ /**
21
+ * Specifies a label for the edit text.
22
+ */
23
+ editLabel?: string;
24
+ /**
25
+ * A React component that will be rendered as an icon.
26
+ */
27
+ buttonIcon?: ReactNode;
12
28
  }
13
29
  declare const RegionBar: React.ForwardRefExoticComponent<RegionBarProps & React.RefAttributes<HTMLDivElement>>;
14
30
  export default RegionBar;
@@ -1,12 +1,12 @@
1
1
  import React, { forwardRef } from 'react';
2
- import { Button, Icon } from '../../';
3
- const RegionBar = forwardRef(function RegionBar({ postalCode, onButtonClick, ...otherProps }, ref) {
2
+ import { Button } from '../../';
3
+ const RegionBar = forwardRef(function RegionBar({ postalCode, icon, label, editLabel, buttonIcon, onButtonClick, ...otherProps }, ref) {
4
4
  return (React.createElement("div", { ref: ref, "data-fs-region-bar": true, ...otherProps },
5
- React.createElement(Button, { variant: "tertiary", iconPosition: "right", onClick: onButtonClick, icon: React.createElement(Icon, { name: "CaretRight" }) },
6
- React.createElement(Icon, { name: "MapPin" }),
5
+ React.createElement(Button, { variant: "tertiary", iconPosition: "right", onClick: onButtonClick, icon: buttonIcon },
6
+ !!icon && icon,
7
7
  postalCode ? (React.createElement(React.Fragment, null,
8
8
  React.createElement("span", { "data-fs-region-bar-postal-code": true }, postalCode),
9
- React.createElement("span", { "data-fs-region-bar-cta": true }, "Edit"))) : (React.createElement("span", { "data-fs-region-bar-message": true }, "Set your location")))));
9
+ !!editLabel && React.createElement("span", { "data-fs-region-bar-cta": true }, editLabel))) : (React.createElement("span", { "data-fs-region-bar-message": true }, label)))));
10
10
  });
11
11
  export default RegionBar;
12
12
  //# sourceMappingURL=RegionBar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegionBar.js","sourceRoot":"","sources":["../../../src/molecules/RegionBar/RegionBar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAarC,MAAM,SAAS,GAAG,UAAU,CAAiC,SAAS,SAAS,CAC7E,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,UAAU,EAAE,EAC5C,GAAG;IAEH,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,iCAAyB,UAAU;QAC9C,oBAAC,MAAM,IACL,OAAO,EAAC,UAAU,EAClB,YAAY,EAAC,OAAO,EACpB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,oBAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG;YAEhC,oBAAC,IAAI,IAAC,IAAI,EAAC,QAAQ,GAAG;YACrB,UAAU,CAAC,CAAC,CAAC,CACZ;gBACE,wEAAsC,UAAU,CAAQ;gBACxD,uEAAwC,CACvC,CACJ,CAAC,CAAC,CAAC,CACF,wFAAyD,CAC1D,CACM,CACL,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"RegionBar.js","sourceRoot":"","sources":["../../../src/molecules/RegionBar/RegionBar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AA6B/B,MAAM,SAAS,GAAG,UAAU,CAAiC,SAAS,SAAS,CAC7E,EACE,UAAU,EACV,IAAI,EACJ,KAAK,EACL,SAAS,EACT,UAAU,EACV,aAAa,EACb,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,6BAAK,GAAG,EAAE,GAAG,iCAAyB,UAAU;QAC9C,oBAAC,MAAM,IACL,OAAO,EAAC,UAAU,EAClB,YAAY,EAAC,OAAO,EACpB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,UAAU;YAEf,CAAC,CAAC,IAAI,IAAI,IAAI;YACd,UAAU,CAAC,CAAC,CAAC,CACZ;gBACE,wEAAsC,UAAU,CAAQ;gBACvD,CAAC,CAAC,SAAS,IAAI,gEAA8B,SAAS,CAAQ,CAC9D,CACJ,CAAC,CAAC,CAAC,CACF,oEAAkC,KAAK,CAAQ,CAChD,CACM,CACL,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,SAAS,CAAA"}
@@ -15,6 +15,10 @@ export interface RegionModalProps extends Omit<ModalProps, 'children'> {
15
15
  * Description for region modal.
16
16
  */
17
17
  description?: string;
18
+ /**
19
+ * Close button aria-label.
20
+ */
21
+ closeButtonAriaLabel?: string;
18
22
  /**
19
23
  * Props for the link `I don't know my Postal Code`.
20
24
  */
@@ -35,6 +39,10 @@ export interface RegionModalProps extends Omit<ModalProps, 'children'> {
35
39
  * Postal code input's value.
36
40
  */
37
41
  inputValue?: string;
42
+ /**
43
+ * Postal code input's label.
44
+ */
45
+ inputLabel?: string;
38
46
  /**
39
47
  * Enables fadeOut effect on modal after onSubmit function
40
48
  */
@@ -60,5 +68,5 @@ export interface RegionModalProps extends Omit<ModalProps, 'children'> {
60
68
  */
61
69
  onClear?: () => void;
62
70
  }
63
- declare function RegionModal({ testId, title, description, idkPostalCodeLinkProps, errorMessage, inputRef, inputValue, fadeOutOnSubmit, overlayProps, onClose, onInput, onSubmit, onClear, ...otherProps }: RegionModalProps): JSX.Element;
71
+ declare function RegionModal({ testId, title, description, closeButtonAriaLabel, idkPostalCodeLinkProps, errorMessage, inputRef, inputValue, inputLabel, fadeOutOnSubmit, overlayProps, onClose, onInput, onSubmit, onClear, ...otherProps }: RegionModalProps): JSX.Element;
64
72
  export default RegionModal;
@@ -1,21 +1,19 @@
1
1
  import React from 'react';
2
- import { Icon, InputField, Link, Modal, ModalBody, ModalHeader } from '../..';
3
- function RegionModal({ testId = 'fs-region-modal', title = 'Set your location', description = 'Prices, offers and availability may vary according to your location.', idkPostalCodeLinkProps, errorMessage, inputRef, inputValue, fadeOutOnSubmit, overlayProps, onClose, onInput, onSubmit, onClear, ...otherProps }) {
2
+ import { InputField, Link, Modal, ModalBody, ModalHeader } from '../..';
3
+ function RegionModal({ testId = 'fs-region-modal', title = 'Set your location', description = 'Prices, offers and availability may vary according to your location.', closeButtonAriaLabel = 'Close Region Modal', idkPostalCodeLinkProps, errorMessage, inputRef, inputValue, inputLabel = 'Postal Code', fadeOutOnSubmit, overlayProps, onClose, onInput, onSubmit, onClear, ...otherProps }) {
4
4
  return (React.createElement(Modal, { "data-fs-region-modal": true, testId: testId, overlayProps: overlayProps, title: "Region modal", "aria-label": "Region modal", ...otherProps }, ({ fadeOut }) => (React.createElement(React.Fragment, null,
5
5
  React.createElement(ModalHeader, { onClose: () => {
6
6
  fadeOut();
7
7
  onClose?.();
8
8
  }, title: title, description: description, closeBtnProps: {
9
- 'aria-label': 'Close Region Modal',
9
+ 'aria-label': closeButtonAriaLabel,
10
10
  } }),
11
11
  React.createElement(ModalBody, null,
12
- React.createElement(InputField, { "data-fs-region-modal-input": true, id: `${testId}-input-field`, inputRef: inputRef, label: "Postal Code", actionable: true, value: inputValue, onInput: (event) => onInput?.(event), onSubmit: () => {
12
+ React.createElement(InputField, { "data-fs-region-modal-input": true, id: `${testId}-input-field`, inputRef: inputRef, label: inputLabel, actionable: true, value: inputValue, onInput: (event) => onInput?.(event), onSubmit: () => {
13
13
  onSubmit?.();
14
14
  fadeOutOnSubmit ? fadeOut() : null;
15
15
  }, onClear: () => onClear?.(), error: errorMessage }),
16
- React.createElement(Link, { "data-fs-region-modal-link": true, ...idkPostalCodeLinkProps }, idkPostalCodeLinkProps?.children ?? (React.createElement(React.Fragment, null,
17
- "I don't know my Postal Code",
18
- React.createElement(Icon, { name: "ArrowSquareOut", width: 20, height: 20 })))))))));
16
+ React.createElement(Link, { "data-fs-region-modal-link": true, ...idkPostalCodeLinkProps }))))));
19
17
  }
20
18
  export default RegionModal;
21
19
  //# sourceMappingURL=RegionModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegionModal.js","sourceRoot":"","sources":["../../../src/organisms/RegionModal/RegionModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAoE7E,SAAS,WAAW,CAAC,EACnB,MAAM,GAAG,iBAAiB,EAC1B,KAAK,GAAG,mBAAmB,EAC3B,WAAW,GAAG,sEAAsE,EACpF,sBAAsB,EACtB,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,eAAe,EACf,YAAY,EACZ,OAAO,EACP,OAAO,EACP,QAAQ,EACR,OAAO,EACP,GAAG,UAAU,EACI;IACjB,OAAO,CACL,oBAAC,KAAK,kCAEJ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAC,cAAc,gBACT,cAAc,KACrB,UAAU,IAEb,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAChB;QACE,oBAAC,WAAW,IACV,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,EAAE,CAAA;gBACT,OAAO,EAAE,EAAE,CAAA;YACb,CAAC,EACD,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE;gBACb,YAAY,EAAE,oBAAoB;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AAO,EACP,QAAQ,EACR,OAAO,EACP,GAAG,UAAU,EACI;IACjB,OAAO,CACL,oBAAC,KAAK,kCAEJ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAC,cAAc,gBACT,cAAc,KACrB,UAAU,IAEb,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAChB;QACE,oBAAC,WAAW,IACV,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,EAAE,CAAA;gBACT,OAAO,EAAE,EAAE,CAAA;YACb,CAAC,EACD,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE;gBACb,YAAY,EAAE,oBAAoB;aACnC,GACD;QACF,oBAAC,SAAS;YACR,oBAAC,UAAU,wCAET,EAAE,EAAE,GAAG,MAAM,cAAc,EAC3B,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,UAAU,EACjB,UAAU,QACV,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,EACpC,QAAQ,EAAE,GAAG,EAAE;oBACb,QAAQ,EAAE,EAAE,CAAA;oBACZ,eAAe,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;gBACpC,CAAC,EACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,EAC1B,KAAK,EAAE,YAAY,GACnB;YAEF,oBAAC,IAAI,0CAA+B,sBAAsB,GAAI,CACpD,CACX,CACJ,CACK,CACT,CAAA;AACH,CAAC;AAED,eAAe,WAAW,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/components",
3
- "version": "2.0.160-alpha.0",
3
+ "version": "2.0.168-alpha.0",
4
4
  "module": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "author": "Emerson Laurentino @emersonlaurentino",
@@ -30,5 +30,5 @@
30
30
  "node": "16.18.0",
31
31
  "yarn": "1.19.1"
32
32
  },
33
- "gitHead": "d42bb6e77de062523931bfb3095807d5a0ecc3eb"
33
+ "gitHead": "83716a775545aa6ed10a478113408de4a094f792"
34
34
  }
@@ -1,7 +1,7 @@
1
- import type { HTMLAttributes } from 'react'
1
+ import type { HTMLAttributes, ReactNode } from 'react'
2
2
  import React, { forwardRef } from 'react'
3
3
 
4
- import { Button, Icon } from '../../'
4
+ import { Button } from '../../'
5
5
 
6
6
  export interface RegionBarProps extends HTMLAttributes<HTMLDivElement> {
7
7
  /**
@@ -12,10 +12,34 @@ export interface RegionBarProps extends HTMLAttributes<HTMLDivElement> {
12
12
  * Function called when button is clicked.
13
13
  */
14
14
  onButtonClick?: () => void
15
+ /**
16
+ * A React component that will be rendered as an icon.
17
+ */
18
+ icon?: ReactNode
19
+ /**
20
+ * Specifies a label for the location text.
21
+ */
22
+ label: string
23
+ /**
24
+ * Specifies a label for the edit text.
25
+ */
26
+ editLabel?: string
27
+ /**
28
+ * A React component that will be rendered as an icon.
29
+ */
30
+ buttonIcon?: ReactNode
15
31
  }
16
32
 
17
33
  const RegionBar = forwardRef<HTMLDivElement, RegionBarProps>(function RegionBar(
18
- { postalCode, onButtonClick, ...otherProps },
34
+ {
35
+ postalCode,
36
+ icon,
37
+ label,
38
+ editLabel,
39
+ buttonIcon,
40
+ onButtonClick,
41
+ ...otherProps
42
+ },
19
43
  ref
20
44
  ) {
21
45
  return (
@@ -24,16 +48,16 @@ const RegionBar = forwardRef<HTMLDivElement, RegionBarProps>(function RegionBar(
24
48
  variant="tertiary"
25
49
  iconPosition="right"
26
50
  onClick={onButtonClick}
27
- icon={<Icon name="CaretRight" />}
51
+ icon={buttonIcon}
28
52
  >
29
- <Icon name="MapPin" />
53
+ {!!icon && icon}
30
54
  {postalCode ? (
31
55
  <>
32
56
  <span data-fs-region-bar-postal-code>{postalCode}</span>
33
- <span data-fs-region-bar-cta>Edit</span>
57
+ {!!editLabel && <span data-fs-region-bar-cta>{editLabel}</span>}
34
58
  </>
35
59
  ) : (
36
- <span data-fs-region-bar-message>Set your location</span>
60
+ <span data-fs-region-bar-message>{label}</span>
37
61
  )}
38
62
  </Button>
39
63
  </div>
@@ -1,7 +1,7 @@
1
1
  import React from 'react'
2
2
 
3
3
  import type { MutableRefObject } from 'react'
4
- import { Icon, InputField, Link, Modal, ModalBody, ModalHeader } from '../..'
4
+ import { InputField, Link, Modal, ModalBody, ModalHeader } from '../..'
5
5
  import type {
6
6
  LinkElementType,
7
7
  LinkProps,
@@ -23,6 +23,10 @@ export interface RegionModalProps extends Omit<ModalProps, 'children'> {
23
23
  * Description for region modal.
24
24
  */
25
25
  description?: string
26
+ /**
27
+ * Close button aria-label.
28
+ */
29
+ closeButtonAriaLabel?: string
26
30
  /**
27
31
  * Props for the link `I don't know my Postal Code`.
28
32
  */
@@ -43,6 +47,10 @@ export interface RegionModalProps extends Omit<ModalProps, 'children'> {
43
47
  * Postal code input's value.
44
48
  */
45
49
  inputValue?: string
50
+ /**
51
+ * Postal code input's label.
52
+ */
53
+ inputLabel?: string
46
54
  /**
47
55
  * Enables fadeOut effect on modal after onSubmit function
48
56
  */
@@ -73,10 +81,12 @@ function RegionModal({
73
81
  testId = 'fs-region-modal',
74
82
  title = 'Set your location',
75
83
  description = 'Prices, offers and availability may vary according to your location.',
84
+ closeButtonAriaLabel = 'Close Region Modal',
76
85
  idkPostalCodeLinkProps,
77
86
  errorMessage,
78
87
  inputRef,
79
88
  inputValue,
89
+ inputLabel = 'Postal Code',
80
90
  fadeOutOnSubmit,
81
91
  overlayProps,
82
92
  onClose,
@@ -104,7 +114,7 @@ function RegionModal({
104
114
  title={title}
105
115
  description={description}
106
116
  closeBtnProps={{
107
- 'aria-label': 'Close Region Modal',
117
+ 'aria-label': closeButtonAriaLabel,
108
118
  }}
109
119
  />
110
120
  <ModalBody>
@@ -112,7 +122,7 @@ function RegionModal({
112
122
  data-fs-region-modal-input
113
123
  id={`${testId}-input-field`}
114
124
  inputRef={inputRef}
115
- label="Postal Code"
125
+ label={inputLabel}
116
126
  actionable
117
127
  value={inputValue}
118
128
  onInput={(event) => onInput?.(event)}
@@ -124,14 +134,7 @@ function RegionModal({
124
134
  error={errorMessage}
125
135
  />
126
136
 
127
- <Link data-fs-region-modal-link {...idkPostalCodeLinkProps}>
128
- {idkPostalCodeLinkProps?.children ?? (
129
- <>
130
- {"I don't know my Postal Code"}
131
- <Icon name="ArrowSquareOut" width={20} height={20} />
132
- </>
133
- )}
134
- </Link>
137
+ <Link data-fs-region-modal-link {...idkPostalCodeLinkProps} />
135
138
  </ModalBody>
136
139
  </>
137
140
  )}