@faststore/core 2.1.16 → 2.1.17

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.
@@ -33,23 +33,23 @@ Route (pages) Size First Load JS
33
33
  ┌ ● / 3.21 kB 197 kB
34
34
  ├ └ css/0d62ff2d64099b84.css 6.47 kB
35
35
  ├ /_app 0 B 77.9 kB
36
- ├ ● /[...slug] 8.8 kB 134 kB
36
+ ├ ● /[...slug] 8.8 kB 135 kB
37
37
  ├ └ css/6e41f1b6078c14c1.css 7.9 kB
38
- ├ ● /[slug]/p 11 kB 204 kB
38
+ ├ ● /[slug]/p 11 kB 205 kB
39
39
  ├ └ css/0f8ce5203de8ae6f.css 11.2 kB
40
- ├ ○ /404 1.09 kB 113 kB
41
- ├ ● /500 1.11 kB 113 kB
42
- ├ ● /account 668 B 113 kB
40
+ ├ ○ /404 1.27 kB 114 kB
41
+ ├ ● /500 1.29 kB 114 kB
42
+ ├ ● /account 669 B 113 kB
43
43
  ├ λ /api/graphql 0 B 77.9 kB
44
44
  ├ λ /api/preview 0 B 77.9 kB
45
- ├ ● /checkout 657 B 113 kB
46
- ├ ● /login 1.01 kB 113 kB
47
- └ ● /s 1.11 kB 126 kB
45
+ ├ ● /checkout 656 B 113 kB
46
+ ├ ● /login 1.19 kB 114 kB
47
+ └ ● /s 1.11 kB 127 kB
48
48
  + First Load JS shared by all 80.6 kB
49
49
  ├ chunks/framework-dfd14d7ce6600b03.js 45.3 kB
50
50
  ├ chunks/main-fd466221927468fd.js 23.9 kB
51
51
  ├ chunks/pages/_app-79d333aa6001a806.js 6.38 kB
52
- ├ chunks/webpack-3eefca84f4c29194.js 2.28 kB
52
+ ├ chunks/webpack-ad7791015d101142.js 2.28 kB
53
53
  └ css/104f0f3ce3be32c6.css 2.79 kB
54
54
 
55
55
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "2.1.16",
3
+ "version": "2.1.17",
4
4
  "license": "MIT",
5
5
  "browserslist": "supports es6-module and not dead",
6
6
  "scripts": {
@@ -110,5 +110,5 @@
110
110
  "msw": {
111
111
  "workerDirectory": "public"
112
112
  },
113
- "gitHead": "a1b180b75407f3e4064b4637e8595e8aab130a2e"
113
+ "gitHead": "fcb109880652472f2a72cebdb79f550075c23ecb"
114
114
  }
@@ -7,10 +7,16 @@ import { mark } from 'src/sdk/tests/mark'
7
7
  import Section from 'src/components/sections/Section/Section'
8
8
  import styles from './section.module.scss'
9
9
 
10
+ import { Components, Props } from 'src/components/sections/Alert/Overrides'
11
+
12
+ const { Alert: AlertWrapper } = Components
13
+
10
14
  export interface AlertProps extends UIAlertProps {
11
15
  /**
12
16
  * For CMS integration purposes, should be used to pass content through it
13
17
  * instead pass through children
18
+ *
19
+ * TODO: Remove it? It's not being used
14
20
  */
15
21
  content?: ReactNode
16
22
  }
@@ -32,9 +38,15 @@ function Alert({
32
38
 
33
39
  return (
34
40
  <Section className={`${styles.section} section-alert`}>
35
- <UIAlert onClose={onAlertClose} {...otherProps}>
41
+ <AlertWrapper
42
+ {...Props['Alert']}
43
+ // Dynamic props, shouldn't be overridable
44
+ // This decision can be reviewed later if needed
45
+ onClose={onAlertClose}
46
+ {...otherProps}
47
+ >
36
48
  {content ?? children}
37
- </UIAlert>
49
+ </AlertWrapper>
38
50
  </Section>
39
51
  )
40
52
  }
@@ -1,9 +1,12 @@
1
1
  import type { RegionBarProps as UIRegionBarProps } from '@faststore/ui'
2
- import { Icon, RegionBar as UIRegionBar } from '@faststore/ui'
3
2
 
4
3
  import { useUI } from '@faststore/ui'
5
4
  import { useSession } from 'src/sdk/session'
6
5
 
6
+ import { Components, Props } from 'src/components/sections/RegionBar/Overrides'
7
+
8
+ const { RegionBar: RegionBarWrapper, LocationIcon, ButtonIcon } = Components
9
+
7
10
  export interface RegionBarProps {
8
11
  /**
9
12
  * A React component that will be rendered as an icon.
@@ -30,19 +33,32 @@ export interface RegionBarProps {
30
33
  }
31
34
 
32
35
  function RegionBar({
33
- icon: { icon: locationIcon, alt: locationIconAlt },
34
- buttonIcon: { icon: buttonIcon, alt: buttonIconAlt },
36
+ icon: {
37
+ icon: locationIcon = Props['LocationIcon'].name,
38
+ alt: locationIconAlt = Props['LocationIcon']['aria-label'],
39
+ },
40
+ buttonIcon: {
41
+ icon: buttonIcon = Props['ButtonIcon'].name,
42
+ alt: buttonIconAlt = Props['ButtonIcon']['aria-label'],
43
+ },
44
+ label = Props['RegionBar'].label,
45
+ editLabel = Props['RegionBar'].editLabel,
35
46
  ...otherProps
36
47
  }: RegionBarProps) {
37
48
  const { openModal } = useUI()
38
49
  const { postalCode } = useSession()
39
50
 
40
51
  return (
41
- <UIRegionBar
52
+ <RegionBarWrapper
53
+ icon={<LocationIcon name={locationIcon} aria-label={locationIconAlt} />}
54
+ buttonIcon={<ButtonIcon name={buttonIcon} aria-label={buttonIconAlt} />}
55
+ {...Props['RegionBar']}
56
+ label={label}
57
+ editLabel={editLabel}
58
+ // Dynamic props shouldn't be overridable
59
+ // This decision can be reviewed later if needed
42
60
  onButtonClick={openModal}
43
61
  postalCode={postalCode}
44
- icon={<Icon name={locationIcon} aria-label={locationIconAlt} />}
45
- buttonIcon={<Icon name={buttonIcon} aria-label={buttonIconAlt} />}
46
62
  {...otherProps}
47
63
  />
48
64
  )
@@ -1,5 +1,8 @@
1
- import { Icon as UIIcon } from '@faststore/ui'
2
- import UIAlert from 'src/components/common/Alert'
1
+ import CommonAlert from 'src/components/common/Alert'
2
+
3
+ import { Components, Props } from 'src/components/sections/Alert/Overrides'
4
+
5
+ const { Icon } = Components
3
6
 
4
7
  export interface AlertProps {
5
8
  icon: string
@@ -12,15 +15,28 @@ export interface AlertProps {
12
15
  }
13
16
 
14
17
  // TODO: Change actionPath and actionLabel with Link
15
- function Alert({ icon, content, link, dismissible }: AlertProps) {
18
+ function Alert({
19
+ icon = Props['Icon'].name,
20
+ content,
21
+ link: {
22
+ text = Props['Alert'].link?.text,
23
+ to = Props['Alert'].link?.to,
24
+ } = Props['Alert'].link,
25
+ dismissible = Props['Alert'].dismissible,
26
+ }: AlertProps) {
16
27
  return (
17
- <UIAlert
18
- icon={<UIIcon name={icon} />}
19
- link={{ children: link?.text, href: link?.to, target: '_self' }}
28
+ <CommonAlert
29
+ icon={<Icon {...Props['Icon']} name={icon} />}
30
+ link={{
31
+ ...(Props['Alert'].link ?? {}),
32
+ children: text,
33
+ href: to,
34
+ target: Props['Alert'].link?.target ?? '_self',
35
+ }}
20
36
  dismissible={dismissible}
21
37
  >
22
38
  {content}
23
- </UIAlert>
39
+ </CommonAlert>
24
40
  )
25
41
  }
26
42
 
@@ -0,0 +1,27 @@
1
+ import { Alert as UIAlert, Icon as UIIcon } from '@faststore/ui'
2
+
3
+ import AlertCustomizations from 'src/customizations/components/overrides/Alert'
4
+
5
+ const alertComponentsCustomization = {}
6
+
7
+ const alertPropsCustomization = {} as any
8
+
9
+ Object.entries(AlertCustomizations.components).forEach(([key, value]) => {
10
+ if (value.Component) {
11
+ alertComponentsCustomization[key] = value.Component
12
+ }
13
+ })
14
+
15
+ Object.entries(AlertCustomizations.components).forEach(([key, value]) => {
16
+ if (value.props) {
17
+ alertPropsCustomization[key] = value.props
18
+ }
19
+ })
20
+
21
+ const Components = {
22
+ Alert: UIAlert,
23
+ Icon: UIIcon,
24
+ ...alertComponentsCustomization,
25
+ }
26
+
27
+ export { Components, alertPropsCustomization as Props }
@@ -4,7 +4,9 @@ import type { PropsWithChildren } from 'react'
4
4
  import Section from '../Section'
5
5
  import styles from './section.module.scss'
6
6
 
7
- import { EmptyState as UIEmptyState } from '@faststore/ui'
7
+ import { Components, Props } from 'src/components/sections/EmptyState/Overrides'
8
+
9
+ const { EmptyState: EmptyStateWrapper } = Components
8
10
 
9
11
  export interface EmptyStateProps {
10
12
  title: string
@@ -12,15 +14,20 @@ export interface EmptyStateProps {
12
14
  }
13
15
 
14
16
  function EmptyState({
15
- title,
16
- titleIcon,
17
+ title = Props['EmptyState'].title,
18
+ titleIcon = Props['EmptyState'].titleIcon,
17
19
  children,
18
20
  }: PropsWithChildren<EmptyStateProps>) {
19
21
  return (
20
22
  <Section className={`${styles.section} section-empty-state`}>
21
- <UIEmptyState title={title} titleIcon={titleIcon} bkgColor="light">
23
+ <EmptyStateWrapper
24
+ bkgColor="light"
25
+ {...Props['EmptyState']}
26
+ title={title}
27
+ titleIcon={titleIcon}
28
+ >
22
29
  {children}
23
- </UIEmptyState>
30
+ </EmptyStateWrapper>
24
31
  </Section>
25
32
  )
26
33
  }
@@ -0,0 +1,26 @@
1
+ import { EmptyState as UIEmptyState } from '@faststore/ui'
2
+
3
+ import EmptyStateCustomizations from 'src/customizations/components/overrides/EmptyState'
4
+
5
+ const emptyStateComponentsCustomization = {}
6
+
7
+ const emptyStatePropsCustomization = {} as any
8
+
9
+ Object.entries(EmptyStateCustomizations.components).forEach(([key, value]) => {
10
+ if (value.Component) {
11
+ emptyStateComponentsCustomization[key] = value.Component
12
+ }
13
+ })
14
+
15
+ Object.entries(EmptyStateCustomizations.components).forEach(([key, value]) => {
16
+ if (value.props) {
17
+ emptyStatePropsCustomization[key] = value.props
18
+ }
19
+ })
20
+
21
+ const Components = {
22
+ EmptyState: UIEmptyState,
23
+ ...emptyStateComponentsCustomization,
24
+ }
25
+
26
+ export { Components, emptyStatePropsCustomization as Props }
@@ -0,0 +1,35 @@
1
+ import {
2
+ Button as UIButton,
3
+ InputField as UIInputField,
4
+ Icon as UIIcon,
5
+ } from '@faststore/ui'
6
+
7
+ import NewsletterCustomizations from 'src/customizations/components/overrides/Newsletter'
8
+
9
+ const newsletterComponentsCustomization = {}
10
+
11
+ const newsletterPropsCustomization = {} as any
12
+
13
+ Object.entries(NewsletterCustomizations.components).forEach(([key, value]) => {
14
+ if (value.Component) {
15
+ newsletterComponentsCustomization[key] = value.Component
16
+ }
17
+ })
18
+
19
+ Object.entries(NewsletterCustomizations.components).forEach(([key, value]) => {
20
+ if (value.props) {
21
+ newsletterPropsCustomization[key] = value.props
22
+ }
23
+ })
24
+
25
+ const Components = {
26
+ ToastIconSuccess: UIIcon,
27
+ ToastIconError: UIIcon,
28
+ HeaderIcon: UIIcon,
29
+ InputFieldName: UIInputField,
30
+ InputFieldEmail: UIInputField,
31
+ Button: UIButton,
32
+ ...newsletterComponentsCustomization,
33
+ }
34
+
35
+ export { Components, newsletterPropsCustomization as Props }
@@ -0,0 +1,28 @@
1
+ import { RegionBar as UIRegionBar, Icon as UIIcon } from '@faststore/ui'
2
+
3
+ import RegionBarCustomizations from 'src/customizations/components/overrides/RegionBar'
4
+
5
+ const regionBarComponentsCustomization = {}
6
+
7
+ const regionBarPropsCustomization = {} as any
8
+
9
+ Object.entries(RegionBarCustomizations.components).forEach(([key, value]) => {
10
+ if (value.Component) {
11
+ regionBarComponentsCustomization[key] = value.Component
12
+ }
13
+ })
14
+
15
+ Object.entries(RegionBarCustomizations.components).forEach(([key, value]) => {
16
+ if (value.props) {
17
+ regionBarPropsCustomization[key] = value.props
18
+ }
19
+ })
20
+
21
+ const Components = {
22
+ RegionBar: UIRegionBar,
23
+ LocationIcon: UIIcon,
24
+ ButtonIcon: UIIcon,
25
+ ...regionBarComponentsCustomization,
26
+ }
27
+
28
+ export { Components, regionBarPropsCustomization as Props }
@@ -1,11 +1,21 @@
1
- import { Button as UIButton, InputField as UIInputField } from '@faststore/ui'
2
1
  import { ComponentPropsWithRef, FormEvent, useMemo } from 'react'
3
2
  import { forwardRef, useRef } from 'react'
4
3
  import { convertFromRaw } from 'draft-js'
5
4
  import { stateToHTML } from 'draft-js-export-html'
6
- import { Icon, useUI } from '@faststore/ui'
5
+ import { useUI } from '@faststore/ui'
7
6
  import { useNewsletter } from 'src/sdk/newsletter/useNewsletter'
8
7
 
8
+ import { Components, Props } from 'src/components/sections/Newsletter/Overrides'
9
+
10
+ const {
11
+ ToastIconSuccess,
12
+ ToastIconError,
13
+ HeaderIcon,
14
+ InputFieldEmail,
15
+ InputFieldName,
16
+ Button,
17
+ } = Components
18
+
9
19
  const cmsToHtml = (content) => {
10
20
  if (!content) {
11
21
  return ''
@@ -135,14 +145,26 @@ const Newsletter = forwardRef<HTMLFormElement, NewsletterProps>(
135
145
  pushToast({
136
146
  ...toastSubscribe,
137
147
  status: 'INFO',
138
- icon: <Icon name={toastSubscribe?.icon} width={30} height={30} />,
148
+ icon: (
149
+ <ToastIconSuccess
150
+ width={30}
151
+ height={30}
152
+ {...Props['ToastIconSuccess']}
153
+ name={toastSubscribe.icon ?? Props['ToastIconSuccess'].name}
154
+ />
155
+ ),
139
156
  })
140
157
  } else {
141
158
  pushToast({
142
159
  ...toastSubscribeError,
143
160
  status: 'ERROR',
144
161
  icon: (
145
- <Icon name={toastSubscribeError?.icon} width={30} height={30} />
162
+ <ToastIconError
163
+ width={30}
164
+ height={30}
165
+ {...Props['ToastIconError']}
166
+ name={toastSubscribe.icon ?? Props['ToastIconError'].name}
167
+ />
146
168
  ),
147
169
  })
148
170
  }
@@ -162,65 +184,55 @@ const Newsletter = forwardRef<HTMLFormElement, NewsletterProps>(
162
184
  >
163
185
  <header data-fs-newsletter-header>
164
186
  <h3>
165
- <Icon name={icon?.icon} width={32} height={32} />
187
+ <HeaderIcon
188
+ width={32}
189
+ height={32}
190
+ {...Props['HeaderIcon']}
191
+ name={icon?.icon ?? Props['HeaderIcon'].name}
192
+ />
166
193
  {title}
167
194
  </h3>
168
195
  {description && <span> {description}</span>}
169
196
  </header>
170
197
 
171
198
  <div data-fs-newsletter-controls>
172
- {displayNameInput ? (
173
- <>
174
- <UIInputField
175
- required
199
+ <>
200
+ {displayNameInput ? (
201
+ <InputFieldName
176
202
  id="newsletter-name"
177
- label={nameInputLabel}
178
- inputRef={nameInputRef}
179
- />
180
- <UIInputField
181
- required
182
- type="email"
183
- id="newsletter-email"
184
- label={emailInputLabel}
185
- inputRef={emailInputRef}
186
- />
187
- <span
188
- data-fs-newsletter-addendum
189
- dangerouslySetInnerHTML={{
190
- __html: cmsToHtml(privacyPolicy),
191
- }}
192
- />
193
- <UIButton
194
- variant="secondary"
195
- inverse
196
- type="submit"
197
- aria-label={subscriptionButtonLabel}
198
- >
199
- {subscriptionButtonLabel}
200
- </UIButton>
201
- </>
202
- ) : (
203
- <>
204
- <UIInputField
205
203
  required
206
- actionable
207
- type="email"
208
- id="newsletter-email"
209
- label={emailInputLabel}
210
- inputRef={emailInputRef}
211
- onClear={() => null}
212
- onSubmit={() => null}
213
- displayClearButton={false}
214
- buttonActionText={subscriptionButtonLabel}
215
- />
216
- <span
217
- data-fs-newsletter-addendum
218
- dangerouslySetInnerHTML={{
219
- __html: cmsToHtml(privacyPolicy),
220
- }}
204
+ {...Props['InputFieldName']}
205
+ label={nameInputLabel ?? Props['InputFieldName'].label}
206
+ // Dynamic props shouldn't be overridable
207
+ // This decision can be reviewed later if needed
208
+ inputRef={nameInputRef}
221
209
  />
222
- </>
223
- )}
210
+ ) : null}
211
+ <InputFieldEmail
212
+ id="newsletter-email"
213
+ type="email"
214
+ required
215
+ {...Props['InputFieldEmail']}
216
+ label={emailInputLabel ?? Props['InputFieldEmail'].label}
217
+ // Dynamic props shouldn't be overridable
218
+ // This decision can be reviewed later if needed
219
+ inputRef={emailInputRef}
220
+ />
221
+ <span
222
+ data-fs-newsletter-addendum
223
+ dangerouslySetInnerHTML={{
224
+ __html: cmsToHtml(privacyPolicy),
225
+ }}
226
+ ></span>
227
+ <Button
228
+ variant="secondary"
229
+ inverse
230
+ type="submit"
231
+ {...Props['Button']}
232
+ >
233
+ {loading ? subscribeButtonLoadingLabel : subscribeButtonLabel}
234
+ </Button>
235
+ </>
224
236
  </div>
225
237
  </form>
226
238
  </div>
@@ -0,0 +1,15 @@
1
+ // This is an example of how it can be used on the starter.
2
+
3
+ import { SectionOverride } from 'src/typings/overrides'
4
+
5
+ const SECTION = 'Alert' as const
6
+
7
+ const overrides: SectionOverride[typeof SECTION] = {
8
+ name: SECTION,
9
+ components: {
10
+ Alert: { props: {} },
11
+ Icon: { props: {} },
12
+ },
13
+ }
14
+
15
+ export default overrides
@@ -0,0 +1,13 @@
1
+ // This is an example of how it can be used on the starter.
2
+ import { SectionOverride } from 'src/typings/overrides'
3
+
4
+ const SECTION = 'EmptyState' as const
5
+
6
+ const overrides: SectionOverride[typeof SECTION] = {
7
+ name: SECTION,
8
+ components: {
9
+ EmptyState: { props: {} },
10
+ },
11
+ }
12
+
13
+ export default overrides
@@ -0,0 +1,19 @@
1
+ // This is an example of how it can be used on the starter.
2
+
3
+ import { SectionOverride } from 'src/typings/overrides'
4
+
5
+ const SECTION = 'Newsletter' as const
6
+
7
+ const overrides: SectionOverride[typeof SECTION] = {
8
+ name: SECTION,
9
+ components: {
10
+ ToastIconSuccess: { props: {} },
11
+ ToastIconError: { props: {} },
12
+ HeaderIcon: { props: {} },
13
+ InputFieldName: { props: {} },
14
+ InputFieldEmail: { props: {} },
15
+ Button: { props: {} },
16
+ },
17
+ }
18
+
19
+ export default overrides
@@ -0,0 +1,16 @@
1
+ // This is an example of how it can be used on the starter.
2
+
3
+ import { SectionOverride } from 'src/typings/overrides'
4
+
5
+ const SECTION = 'RegionBar' as const
6
+
7
+ const overrides: SectionOverride[typeof SECTION] = {
8
+ name: SECTION,
9
+ components: {
10
+ RegionBar: { props: {} },
11
+ LocationIcon: { props: {} },
12
+ ButtonIcon: { props: {} },
13
+ },
14
+ }
15
+
16
+ export default overrides
@@ -62,6 +62,25 @@ export const SECTIONS = {
62
62
  '__experimentalProductCard',
63
63
  ],
64
64
  },
65
+ Alert: {
66
+ components: ['Alert', 'Icon'],
67
+ },
68
+ EmptyState: {
69
+ components: ['EmptyState'],
70
+ },
71
+ RegionBar: {
72
+ components: ['RegionBar', 'LocationIcon', 'ButtonIcon'],
73
+ },
74
+ Newsletter: {
75
+ components: [
76
+ 'ToastIconSuccess',
77
+ 'ToastIconError',
78
+ 'HeaderIcon',
79
+ 'InputFieldName',
80
+ 'InputFieldEmail',
81
+ 'Button',
82
+ ],
83
+ },
65
84
  } as const
66
85
 
67
86
  // export type ComponentOrProps =