@faststore/core 3.0.38 → 3.0.40

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.
Files changed (75) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +3 -3
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/eslint/.cache_1gneedd +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/server-production/0.pack +0 -0
  9. package/.next/cache/webpack/server-production/index.pack +0 -0
  10. package/.next/next-minimal-server.js.nft.json +1 -1
  11. package/.next/next-server.js.nft.json +1 -1
  12. package/.next/prerender-manifest.js +1 -1
  13. package/.next/prerender-manifest.json +1 -1
  14. package/.next/routes-manifest.json +1 -1
  15. package/.next/server/chunks/242.js +1 -1
  16. package/.next/server/chunks/404.js +1 -0
  17. package/.next/server/chunks/498.js +1 -1
  18. package/.next/server/chunks/57.js +1 -0
  19. package/.next/server/chunks/997.js +1 -1
  20. package/.next/server/middleware-build-manifest.js +1 -1
  21. package/.next/server/pages/404.js.nft.json +1 -1
  22. package/.next/server/pages/500.js.nft.json +1 -1
  23. package/.next/server/pages/[...slug].js +1 -1
  24. package/.next/server/pages/[...slug].js.nft.json +1 -1
  25. package/.next/server/pages/[slug]/p.js +1 -1
  26. package/.next/server/pages/[slug]/p.js.nft.json +1 -1
  27. package/.next/server/pages/_app.js.nft.json +1 -1
  28. package/.next/server/pages/_document.js.nft.json +1 -1
  29. package/.next/server/pages/_error.js.nft.json +1 -1
  30. package/.next/server/pages/account.js.nft.json +1 -1
  31. package/.next/server/pages/api/graphql.js +1 -1
  32. package/.next/server/pages/api/graphql.js.nft.json +1 -1
  33. package/.next/server/pages/api/health/live.js.nft.json +1 -1
  34. package/.next/server/pages/api/health/ready.js.nft.json +1 -1
  35. package/.next/server/pages/api/preview.js.nft.json +1 -1
  36. package/.next/server/pages/checkout.js.nft.json +1 -1
  37. package/.next/server/pages/en-US/404.html +2 -2
  38. package/.next/server/pages/en-US/404.json +1 -1
  39. package/.next/server/pages/en-US/500.html +2 -2
  40. package/.next/server/pages/en-US/500.json +1 -1
  41. package/.next/server/pages/en-US/account.html +2 -2
  42. package/.next/server/pages/en-US/account.json +1 -1
  43. package/.next/server/pages/en-US/checkout.html +2 -2
  44. package/.next/server/pages/en-US/checkout.json +1 -1
  45. package/.next/server/pages/en-US/login.html +2 -2
  46. package/.next/server/pages/en-US/login.json +1 -1
  47. package/.next/server/pages/en-US/s.html +2 -2
  48. package/.next/server/pages/en-US/s.json +1 -1
  49. package/.next/server/pages/en-US.html +2 -2
  50. package/.next/server/pages/en-US.json +1 -1
  51. package/.next/server/pages/index.js.nft.json +1 -1
  52. package/.next/server/pages/login.js.nft.json +1 -1
  53. package/.next/server/pages/s.js.nft.json +1 -1
  54. package/.next/static/chunks/pages/{_app-4df2b21628950d8a.js → _app-ec0d2e833bd9cea0.js} +1 -1
  55. package/.next/trace +91 -91
  56. package/.turbo/turbo-build.log +6 -6
  57. package/.turbo/turbo-test.log +10 -10
  58. package/faststore.config.default.js +2 -1
  59. package/package.json +9 -13
  60. package/pull_request_template.md +0 -1
  61. package/src/components/auth/ProfileChallenge/ProfileChallenge.tsx +17 -0
  62. package/src/components/auth/ProfileChallenge/index.ts +1 -0
  63. package/src/experimental/index.ts +2 -0
  64. package/src/sdk/auth/index.ts +19 -0
  65. package/tsconfig.json +1 -1
  66. package/.next/server/chunks/257.js +0 -6
  67. package/.next/server/chunks/981.js +0 -6
  68. package/src/components/product/ProductCard/ProductCard.stories.mdx +0 -413
  69. package/src/components/search/searchMock.ts +0 -48
  70. package/src/components/ui/Breadcrumb/Breadcrumb.stories.mdx +0 -197
  71. package/src/components/ui/Link/Link.stories.mdx +0 -272
  72. package/src/components/ui/ProductDescription/ProductDescription.stories.mdx +0 -66
  73. package/src/components/ui/SkuSelector/Selectors.stories.mdx +0 -86
  74. /package/.next/static/{eU9NSkrfATHvVghBMZcAI → qNZTpBDkQaWkLQfUrkXy7}/_buildManifest.js +0 -0
  75. /package/.next/static/{eU9NSkrfATHvVghBMZcAI → qNZTpBDkQaWkLQfUrkXy7}/_ssgManifest.js +0 -0
@@ -35,7 +35,7 @@ Browserslist: caniuse-lite is outdated. Please run:
35
35
  Route (pages) Size First Load JS
36
36
  ┌ ● / 3.36 kB 143 kB
37
37
  ├ └ css/d586715f4f707df4.css 6.56 kB
38
- ├ /_app 0 B 93.4 kB
38
+ ├ /_app 0 B 93.5 kB
39
39
  ├ ● /[...slug] 4.47 kB 156 kB
40
40
  ├ └ css/4c4d90eb8cb1d2b7.css 7 kB
41
41
  ├ ● /[slug]/p 11.1 kB 151 kB
@@ -43,17 +43,17 @@ Route (pages) Size First Load JS
43
43
  ├ ○ /404 1.47 kB 127 kB
44
44
  ├ ● /500 1.47 kB 127 kB
45
45
  ├ ● /account 676 B 126 kB
46
- ├ λ /api/graphql 0 B 93.4 kB
47
- ├ λ /api/health/live 0 B 93.4 kB
48
- ├ λ /api/health/ready 0 B 93.4 kB
49
- ├ λ /api/preview 0 B 93.4 kB
46
+ ├ λ /api/graphql 0 B 93.5 kB
47
+ ├ λ /api/health/live 0 B 93.5 kB
48
+ ├ λ /api/health/ready 0 B 93.5 kB
49
+ ├ λ /api/preview 0 B 93.5 kB
50
50
  ├ ● /checkout 662 B 126 kB
51
51
  ├ ● /login 1.58 kB 127 kB
52
52
  └ ● /s 4.66 kB 141 kB
53
53
  + First Load JS shared by all 96.5 kB
54
54
  ├ chunks/framework-8e279965036b6169.js 45.4 kB
55
55
  ├ chunks/main-6f63f6746cc029db.js 33.1 kB
56
- ├ chunks/pages/_app-4df2b21628950d8a.js 12.6 kB
56
+ ├ chunks/pages/_app-ec0d2e833bd9cea0.js 12.6 kB
57
57
  ├ chunks/webpack-b4a2fdf4ef127bb7.js 2.45 kB
58
58
  └ css/5d1f64b61ea581f4.css 3.05 kB
59
59
 
@@ -1,23 +1,23 @@
1
1
  $ jest
2
- PASS test/server/index.test.ts (26.203 s)
2
+ PASS test/server/index.test.ts (26.365 s)
3
3
  FastStore GraphQL Layer
4
4
  @faststore/api
5
- ✓ should return a valid GraphQL schema (9 ms)
6
- ✓ should return a valid GraphQL schema contain all expected types (26 ms)
5
+ ✓ should return a valid GraphQL schema (8 ms)
6
+ ✓ should return a valid GraphQL schema contain all expected types (10 ms)
7
7
  ✓ should return a valid GraphQL schema contain all expected queries (2 ms)
8
- ✓ should return a valid GraphQL schema contain all expected mutations (1 ms)
8
+ ✓ should return a valid GraphQL schema contain all expected mutations
9
9
  VTEX API Extension
10
- ✓ getTypeDefsFromFolder function should return an Array (8 ms)
10
+ ✓ getTypeDefsFromFolder function should return an Array (9 ms)
11
11
  Third Party API Extension
12
- ✓ getTypeDefsFromFolder function should return an Array (8 ms)
12
+ ✓ getTypeDefsFromFolder function should return an Array (18 ms)
13
13
  Final Schema after merging
14
- ✓ should return a valid merged GraphQL schema (42 ms)
14
+ ✓ should return a valid merged GraphQL schema (59 ms)
15
15
  Envelop
16
- ✓ should exist with its plugins (45 ms)
17
- ✓ should handle options and execute (549 ms)
16
+ ✓ should exist with its plugins (53 ms)
17
+ ✓ should handle options and execute (237 ms)
18
18
 
19
19
  Test Suites: 1 passed, 1 total
20
20
  Tests: 9 passed, 9 total
21
21
  Snapshots: 0 total
22
- Time: 26.246 s
22
+ Time: 26.461 s
23
23
  Ran all test suites.
@@ -29,7 +29,8 @@ module.exports = {
29
29
  symbol: '$',
30
30
  },
31
31
  locale: 'en-US',
32
- channel: '{"salesChannel":"1","regionId":""}',
32
+ channel:
33
+ '{"salesChannel":"1","regionId":"","hasOnlyDefaultSalesChannel":"true"}',
33
34
  country: 'USA',
34
35
  deliveryMode: null,
35
36
  addressType: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.0.38",
3
+ "version": "3.0.40",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -39,11 +39,11 @@
39
39
  "@envelop/graphql-jit": "^1.1.1",
40
40
  "@envelop/parser-cache": "^2.2.0",
41
41
  "@envelop/validation-cache": "^2.2.0",
42
- "@faststore/api": "^3.0.37",
43
- "@faststore/components": "^3.0.38",
44
- "@faststore/graphql-utils": "^3.0.24",
45
- "@faststore/sdk": "^3.0.34",
46
- "@faststore/ui": "^3.0.38",
42
+ "@faststore/api": "^3.0.40",
43
+ "@faststore/components": "^3.0.40",
44
+ "@faststore/graphql-utils": "^3.0.40",
45
+ "@faststore/sdk": "^3.0.40",
46
+ "@faststore/ui": "^3.0.40",
47
47
  "@graphql-codegen/cli": "^3.3.1",
48
48
  "@graphql-codegen/client-preset": "^4.1.0",
49
49
  "@graphql-codegen/typescript": "^3.0.4",
@@ -63,7 +63,6 @@
63
63
  "draftjs-to-html": "^0.9.1",
64
64
  "graphql": "^15.0.0",
65
65
  "include-media": "^1.4.10",
66
- "msw": "^0.43.1",
67
66
  "next": "^13.5.6",
68
67
  "next-seo": "^6.4.0",
69
68
  "nextjs-progressbar": "^0.0.14",
@@ -83,8 +82,8 @@
83
82
  "devDependencies": {
84
83
  "@cypress/code-coverage": "^3.12.1",
85
84
  "@envelop/testing": "^6.0.0",
86
- "@faststore/cli": "^3.0.35",
87
- "@faststore/eslint-config": "^3.0.24",
85
+ "@faststore/cli": "^3.0.40",
86
+ "@faststore/eslint-config": "^3.0.40",
88
87
  "@faststore/lighthouse": "^1.12.32",
89
88
  "@lhci/cli": "^0.9.0",
90
89
  "@testing-library/cypress": "^10.0.1",
@@ -121,12 +120,9 @@
121
120
  "stylelint --fix"
122
121
  ]
123
122
  },
124
- "msw": {
125
- "workerDirectory": "public"
126
- },
127
123
  "volta": {
128
124
  "node": "18.19.0",
129
125
  "yarn": "1.19.1"
130
126
  },
131
- "gitHead": "ea1f9b69ed525c7f4ff5fac3a7ecf974786b3d4e"
127
+ "gitHead": "0c9cf2d2306ff21a626c3073a54e2ee69aaac919"
132
128
  }
@@ -33,5 +33,4 @@
33
33
 
34
34
  **Documentation**
35
35
  - [ ] PR description
36
- - [ ] Added to/Updated the Storybook - *if applicable*
37
36
  - [ ] For documentation changes, ping `@carolinamenezes` or `@PedroAntunesCosta` to review and update
@@ -0,0 +1,17 @@
1
+ import { PropsWithChildren, ReactNode } from 'react'
2
+ import { useAuth } from 'src/sdk/auth'
3
+
4
+ export type ProfileChallengeProps = {
5
+ fallback?: ReactNode
6
+ }
7
+
8
+ const ProfileChallenge = ({
9
+ fallback = null,
10
+ children,
11
+ }: PropsWithChildren<ProfileChallengeProps>) => {
12
+ const { isAutenticated } = useAuth()
13
+
14
+ return <>{isAutenticated ? children : fallback}</>
15
+ }
16
+
17
+ export default ProfileChallenge
@@ -0,0 +1 @@
1
+ export { default as ProfileChallenge } from './ProfileChallenge'
@@ -4,6 +4,7 @@ export {
4
4
  sessionStore as sessionStore_unstable,
5
5
  validateSession as validateSession_unstable,
6
6
  } from '../../src/sdk/session'
7
+ export { useAuth as useAuth_unstable } from '../../src/sdk/auth'
7
8
  export {
8
9
  useCart as useCart_unstable,
9
10
  cartStore as cartStore_unstable,
@@ -34,3 +35,4 @@ export { useShippingSimulation as useShippingSimulation_unstable } from '../../s
34
35
 
35
36
  // Components
36
37
  export { Image as Image_unstable } from '../../src/components/ui/Image'
38
+ export { ProfileChallenge as ProfileChallenge_unstable } from '../../src/components/auth/ProfileChallenge'
@@ -0,0 +1,19 @@
1
+ import { useSession } from '../session'
2
+
3
+ export const useAuth = () => {
4
+ const { person, isValidating, channel: channelJson } = useSession()
5
+
6
+ const channel = JSON.parse(channelJson) as {
7
+ salesChannel: number
8
+ regionId: string
9
+ hasOnlyDefaultSalesChannel?: boolean
10
+ }
11
+
12
+ const hasSalesChannel =
13
+ Boolean(channel.salesChannel) &&
14
+ channel.hasOnlyDefaultSalesChannel === false
15
+
16
+ const isAutenticated = hasSalesChannel && person
17
+
18
+ return { isAutenticated, profile: person, channel, isValidating }
19
+ }
package/tsconfig.json CHANGED
@@ -28,5 +28,5 @@
28
28
  "esModuleInterop": true
29
29
  },
30
30
  "include": ["*.d.ts", "src/**/*.ts", "src/**/*.tsx", "@generated/**/*.ts"],
31
- "exclude": ["node_modules", "public", "src/components/search/searchMock.ts"]
31
+ "exclude": ["node_modules", "public"]
32
32
  }
@@ -1,6 +0,0 @@
1
- "use strict";exports.id=257,exports.ids=[257],exports.modules={3421:(e,t)=>{function decode(e){return -1!==e.indexOf("%")?decodeURIComponent(e):e}/*!
2
- * cookie
3
- * Copyright(c) 2012-2014 Roman Shtylman
4
- * Copyright(c) 2015 Douglas Christopher Wilson
5
- * MIT Licensed
6
- */t.Q=function(e,t){if("string"!=typeof e)throw TypeError("argument str must be a string");for(var r={},n=(t||{}).decode||decode,a=0;a<e.length;){var c=e.indexOf("=",a);if(-1===c)break;var i=e.indexOf(";",a);if(-1===i)i=e.length;else if(i<c){a=e.lastIndexOf(";",c-1)+1;continue}var o=e.slice(a,c).trim();if(void 0===r[o]){var s=e.slice(c+1,i).trim();34===s.charCodeAt(0)&&(s=s.slice(1,-1)),r[o]=function(e,t){try{return t(e)}catch(t){return e}}(s,n)}a=i+1}return r},Object.prototype.toString},3404:e=>{var t,r=function(){function DataLoader(e,t){if("function"!=typeof e)throw TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: "+e+".");this._batchLoadFn=e,this._maxBatchSize=function(e){if(!(!e||!1!==e.batch))return 1;var t=e&&e.maxBatchSize;if(void 0===t)return 1/0;if("number"!=typeof t||t<1)throw TypeError("maxBatchSize must be a positive number: "+t);return t}(t),this._batchScheduleFn=function(e){var t=e&&e.batchScheduleFn;if(void 0===t)return n;if("function"!=typeof t)throw TypeError("batchScheduleFn must be a function: "+t);return t}(t),this._cacheKeyFn=function(e){var t=e&&e.cacheKeyFn;if(void 0===t)return function(e){return e};if("function"!=typeof t)throw TypeError("cacheKeyFn must be a function: "+t);return t}(t),this._cacheMap=function(e){if(!(!e||!1!==e.cache))return null;var t=e&&e.cacheMap;if(void 0===t)return new Map;if(null!==t){var r=["get","set","delete","clear"].filter(function(e){return t&&"function"!=typeof t[e]});if(0!==r.length)throw TypeError("Custom cacheMap missing methods: "+r.join(", "))}return t}(t),this._batch=null}var e=DataLoader.prototype;return e.load=function(e){if(null==e)throw TypeError("The loader.load() function must be called with a value, but got: "+String(e)+".");var t=function(e){var t=e._batch;if(null!==t&&!t.hasDispatched&&t.keys.length<e._maxBatchSize&&(!t.cacheHits||t.cacheHits.length<e._maxBatchSize))return t;var r={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=r,e._batchScheduleFn(function(){(function(e,t){if(t.hasDispatched=!0,0===t.keys.length){resolveCacheHits(t);return}var r=e._batchLoadFn(t.keys);if(!r||"function"!=typeof r.then)return failedDispatch(e,t,TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: "+String(r)+"."));r.then(function(e){if(!isArrayLike(e))throw TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: "+String(e)+".");if(e.length!==t.keys.length)throw TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.\n\nKeys:\n"+String(t.keys)+"\n\nValues:\n"+String(e));resolveCacheHits(t);for(var r=0;r<t.callbacks.length;r++){var n=e[r];n instanceof Error?t.callbacks[r].reject(n):t.callbacks[r].resolve(n)}}).catch(function(r){failedDispatch(e,t,r)})})(e,r)}),r}(this),r=this._cacheMap,n=this._cacheKeyFn(e);if(r){var a=r.get(n);if(a){var c=t.cacheHits||(t.cacheHits=[]);return new Promise(function(e){c.push(function(){e(a)})})}}t.keys.push(e);var i=new Promise(function(e,r){t.callbacks.push({resolve:e,reject:r})});return r&&r.set(n,i),i},e.loadMany=function(e){if(!isArrayLike(e))throw TypeError("The loader.loadMany() function must be called with Array<key> but got: "+e+".");for(var t=[],r=0;r<e.length;r++)t.push(this.load(e[r]).catch(function(e){return e}));return Promise.all(t)},e.clear=function(e){var t=this._cacheMap;if(t){var r=this._cacheKeyFn(e);t.delete(r)}return this},e.clearAll=function(){var e=this._cacheMap;return e&&e.clear(),this},e.prime=function(e,t){var r=this._cacheMap;if(r){var n,a=this._cacheKeyFn(e);void 0===r.get(a)&&(t instanceof Error?(n=Promise.reject(t)).catch(function(){}):n=Promise.resolve(t),r.set(a,n))}return this},DataLoader}(),n="object"==typeof process&&"function"==typeof process.nextTick?function(e){t||(t=Promise.resolve()),t.then(function(){process.nextTick(e)})}:"function"==typeof setImmediate?function(e){setImmediate(e)}:function(e){setTimeout(e)};function failedDispatch(e,t,r){resolveCacheHits(t);for(var n=0;n<t.keys.length;n++)e.clear(t.keys[n]),t.callbacks[n].reject(r)}function resolveCacheHits(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}function isArrayLike(e){return"object"==typeof e&&null!==e&&"number"==typeof e.length&&(0===e.length||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}e.exports=r}};
@@ -1,6 +0,0 @@
1
- "use strict";exports.id=981,exports.ids=[981],exports.modules={7679:(e,t)=>{function decode(e){return -1!==e.indexOf("%")?decodeURIComponent(e):e}/*!
2
- * cookie
3
- * Copyright(c) 2012-2014 Roman Shtylman
4
- * Copyright(c) 2015 Douglas Christopher Wilson
5
- * MIT Licensed
6
- */t.Q=function(e,t){if("string"!=typeof e)throw TypeError("argument str must be a string");for(var r={},n=(t||{}).decode||decode,a=0;a<e.length;){var c=e.indexOf("=",a);if(-1===c)break;var i=e.indexOf(";",a);if(-1===i)i=e.length;else if(i<c){a=e.lastIndexOf(";",c-1)+1;continue}var o=e.slice(a,c).trim();if(void 0===r[o]){var s=e.slice(c+1,i).trim();34===s.charCodeAt(0)&&(s=s.slice(1,-1)),r[o]=function(e,t){try{return t(e)}catch(t){return e}}(s,n)}a=i+1}return r},Object.prototype.toString},3057:e=>{var t,r=function(){function DataLoader(e,t){if("function"!=typeof e)throw TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: "+e+".");this._batchLoadFn=e,this._maxBatchSize=function(e){if(!(!e||!1!==e.batch))return 1;var t=e&&e.maxBatchSize;if(void 0===t)return 1/0;if("number"!=typeof t||t<1)throw TypeError("maxBatchSize must be a positive number: "+t);return t}(t),this._batchScheduleFn=function(e){var t=e&&e.batchScheduleFn;if(void 0===t)return n;if("function"!=typeof t)throw TypeError("batchScheduleFn must be a function: "+t);return t}(t),this._cacheKeyFn=function(e){var t=e&&e.cacheKeyFn;if(void 0===t)return function(e){return e};if("function"!=typeof t)throw TypeError("cacheKeyFn must be a function: "+t);return t}(t),this._cacheMap=function(e){if(!(!e||!1!==e.cache))return null;var t=e&&e.cacheMap;if(void 0===t)return new Map;if(null!==t){var r=["get","set","delete","clear"].filter(function(e){return t&&"function"!=typeof t[e]});if(0!==r.length)throw TypeError("Custom cacheMap missing methods: "+r.join(", "))}return t}(t),this._batch=null}var e=DataLoader.prototype;return e.load=function(e){if(null==e)throw TypeError("The loader.load() function must be called with a value, but got: "+String(e)+".");var t=function(e){var t=e._batch;if(null!==t&&!t.hasDispatched&&t.keys.length<e._maxBatchSize&&(!t.cacheHits||t.cacheHits.length<e._maxBatchSize))return t;var r={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=r,e._batchScheduleFn(function(){(function(e,t){if(t.hasDispatched=!0,0===t.keys.length){resolveCacheHits(t);return}var r=e._batchLoadFn(t.keys);if(!r||"function"!=typeof r.then)return failedDispatch(e,t,TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: "+String(r)+"."));r.then(function(e){if(!isArrayLike(e))throw TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: "+String(e)+".");if(e.length!==t.keys.length)throw TypeError("DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.\n\nKeys:\n"+String(t.keys)+"\n\nValues:\n"+String(e));resolveCacheHits(t);for(var r=0;r<t.callbacks.length;r++){var n=e[r];n instanceof Error?t.callbacks[r].reject(n):t.callbacks[r].resolve(n)}}).catch(function(r){failedDispatch(e,t,r)})})(e,r)}),r}(this),r=this._cacheMap,n=this._cacheKeyFn(e);if(r){var a=r.get(n);if(a){var c=t.cacheHits||(t.cacheHits=[]);return new Promise(function(e){c.push(function(){e(a)})})}}t.keys.push(e);var i=new Promise(function(e,r){t.callbacks.push({resolve:e,reject:r})});return r&&r.set(n,i),i},e.loadMany=function(e){if(!isArrayLike(e))throw TypeError("The loader.loadMany() function must be called with Array<key> but got: "+e+".");for(var t=[],r=0;r<e.length;r++)t.push(this.load(e[r]).catch(function(e){return e}));return Promise.all(t)},e.clear=function(e){var t=this._cacheMap;if(t){var r=this._cacheKeyFn(e);t.delete(r)}return this},e.clearAll=function(){var e=this._cacheMap;return e&&e.clear(),this},e.prime=function(e,t){var r=this._cacheMap;if(r){var n,a=this._cacheKeyFn(e);void 0===r.get(a)&&(t instanceof Error?(n=Promise.reject(t)).catch(function(){}):n=Promise.resolve(t),r.set(a,n))}return this},DataLoader}(),n="object"==typeof process&&"function"==typeof process.nextTick?function(e){t||(t=Promise.resolve()),t.then(function(){process.nextTick(e)})}:"function"==typeof setImmediate?function(e){setImmediate(e)}:function(e){setTimeout(e)};function failedDispatch(e,t,r){resolveCacheHits(t);for(var n=0;n<t.keys.length;n++)e.clear(t.keys[n]),t.callbacks[n].reject(r)}function resolveCacheHits(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}function isArrayLike(e){return"object"==typeof e&&null!==e&&"number"==typeof e.length&&(0===e.length||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}e.exports=r}};
@@ -1,413 +0,0 @@
1
- import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
2
-
3
- import { Button } from '@faststore/ui'
4
-
5
- import Icon from '../../ui/Icon'
6
- import ProductCard from '.'
7
-
8
- import {
9
- TokenTable,
10
- TokenRow,
11
- TokenDivider,
12
- } from 'src/../.storybook/components'
13
-
14
- <Meta
15
- title="Molecules/ProductCard"
16
- component={ProductCard}
17
- argTypes={{
18
- variant: {
19
- defaultValue: 'default',
20
- table: { defaultValue: 'default' },
21
- },
22
- product: { table: { disable: true } },
23
- index: { table: { disable: true } },
24
- aspectRatio: {
25
- options: [0.75, 1.5, 1],
26
- control: { type: 'radio' },
27
- table: { defaultValue: '1' },
28
- },
29
- BuyButton: {
30
- control: 'boolean',
31
- table: { defaultValue: false },
32
- },
33
- }}
34
- />
35
-
36
- export const product = {
37
- id: '15503951',
38
- slug: 'handmade-steel-towels-practical-15503951',
39
- sku: '15503951',
40
- brand: { brandName: 'Brand', name: 'Brand' },
41
- name: 'red',
42
- gtin: '5595633577807',
43
- isVariantOf: {
44
- productGroupID: '130742',
45
- name: 'Handmade Steel Towels Practical',
46
- },
47
- image: [
48
- {
49
- url: 'http://storeframework.vtexassets.com/arquivos/ids/190191/numquam.jpg?v=637755599170100000',
50
- alternateName: 'est',
51
- },
52
- ],
53
- offers: {
54
- lowPrice: 181.71,
55
- offers: [
56
- {
57
- availability: 'https://schema.org/InStock',
58
- price: 181.71,
59
- listPrice: 208.72,
60
- quantity: 1,
61
- seller: { identifier: '1' },
62
- },
63
- ],
64
- },
65
- }
66
-
67
- export const Template = ({ BuyButton, ...args }) => {
68
- const button = BuyButton ? (
69
- <Button
70
- variant="primary"
71
- data-fs-button-size="small"
72
- icon={<Icon name="ShoppingCart" width={18} height={18} />}
73
- iconPosition="left"
74
- >
75
- Add
76
- </Button>
77
- ) : null
78
- return (
79
- <div style={{ width: 300 }}>
80
- <ProductCard BuyButton={button} {...args} />
81
- </div>
82
- )
83
- }
84
-
85
- export const TemplateWide = ({ BuyButton, ...args }) => {
86
- const button = BuyButton ? (
87
- <Button
88
- variant="primary"
89
- data-fs-button-size="small"
90
- icon={<Icon name="ShoppingCart" width={18} height={18} />}
91
- iconPosition="left"
92
- >
93
- Add
94
- </Button>
95
- ) : null
96
- return (
97
- <div style={{ width: 400 }}>
98
- <ProductCard BuyButton={button} {...args} />
99
- </div>
100
- )
101
- }
102
-
103
- <header>
104
-
105
- # Product Card
106
-
107
- ProductCard displays summarized information about a product. They usually present a call-to-action button, as well as the product's name, price, and image.
108
-
109
- </header>
110
-
111
- ## Overview
112
-
113
- The `ProductCard` component uses [FastStore UI ProductCard](https://www.faststore.dev/reference/ui/molecules/ProductCard).
114
-
115
- <Canvas className="sbdocs-vertically-center">
116
- <Story
117
- name="overview-default"
118
- args={{
119
- product: product,
120
- index: 1,
121
- variant: 'default',
122
- bordered: false,
123
- aspectRatio: 1,
124
- BuyButton: false,
125
- }}
126
- >
127
- {Template.bind({})}
128
- </Story>
129
- <Story
130
- name="overview-bordered"
131
- args={{
132
- product: product,
133
- index: 1,
134
- variant: 'default',
135
- bordered: true,
136
- aspectRatio: 1,
137
- BuyButton: false,
138
- }}
139
- >
140
- {Template.bind({})}
141
- </Story>
142
- <Story
143
- name="overview-wide"
144
- args={{
145
- product: product,
146
- index: 1,
147
- variant: 'wide',
148
- bordered: false,
149
- aspectRatio: 1.5,
150
- BuyButton: false,
151
- }}
152
- >
153
- {TemplateWide.bind({})}
154
- </Story>
155
- </Canvas>
156
-
157
- ---
158
-
159
- ## Usage
160
-
161
- <Canvas>
162
- <Story
163
- name="default"
164
- args={{
165
- product: product,
166
- index: 1,
167
- variant: 'default',
168
- bordered: false,
169
- aspectRatio: 1,
170
- BuyButton: false,
171
- }}
172
- >
173
- {Template.bind({})}
174
- </Story>
175
- </Canvas>
176
-
177
- <ArgsTable story="default" />
178
-
179
- <TokenTable>
180
- <TokenRow
181
- token="--fs-product-card-padding"
182
- value="var(--fs-spacing-1) var(--fs-spacing-1) var(--fs-spacing-2) var(--fs-spacing-1)"
183
- />
184
- <TokenRow token="--fs-product-card-gap" value="var(--fs-grid-gap-2)" />
185
- <TokenRow token="--fs-product-card-min-width" value="10rem" />
186
- <TokenDivider />
187
- <TokenRow token="--fs-product-card-shadow" value="var(--fs-shadow)" />
188
- <TokenRow
189
- token="--fs-product-card-shadow-hover"
190
- value="var(--fs-shadow-hover)"
191
- />
192
- <TokenDivider />
193
- <TokenRow
194
- token="--fs-product-card-bkg-color"
195
- value="var(--fs-color-body-bkg)"
196
- isColor
197
- />
198
- <TokenRow
199
- token="--fs-product-card-bkg-color-hover"
200
- value="var(--fs-product-card-bkg-color)"
201
- globalValue="var(--fs-color-body-bkg)"
202
- isColor
203
- />
204
- <TokenRow
205
- token="--fs-product-card-bkg-color-focus"
206
- value="var(--fs-product-card-bkg-color-hover)"
207
- globalValue="var(--fs-color-body-bkg)"
208
- isColor
209
- />
210
- <TokenDivider />
211
- <TokenRow
212
- token="--fs-product-card-border-radius"
213
- value="var(--fs-border-radius)"
214
- />
215
- <TokenRow
216
- token="--fs-product-card-border-color-hover"
217
- value="var(--fs-border-color-hover)"
218
- isColor
219
- />
220
- <TokenDivider />
221
- <TokenRow
222
- token="--fs-product-card-transition-function"
223
- value="var(--fs-transition-function)"
224
- />
225
- <TokenRow
226
- token="--fs-product-card-transition-property"
227
- value="var(--fs-transition-property)"
228
- />
229
- <TokenRow
230
- token="--fs-product-card-transition-timing"
231
- value="var(--fs-transition-timing)"
232
- />
233
- </TokenTable>
234
-
235
- ---
236
-
237
- ## Nested Elements
238
-
239
- ### Content
240
-
241
- <TokenTable>
242
- <TokenRow
243
- token="--fs-product-card-content-padding"
244
- value="var(--fs-spacing-2) 0 0 0"
245
- />
246
- </TokenTable>
247
-
248
- ### Image
249
-
250
- <TokenTable>
251
- <TokenRow
252
- token="--fs-product-card-img-radius"
253
- value="var(--fs-product-card-border-radius)"
254
- />
255
- <TokenRow token="--fs-product-card-img-scale-hover" value="1" />
256
- </TokenTable>
257
-
258
- ### Title
259
-
260
- <TokenTable>
261
- <TokenRow
262
- token="--fs-product-card-title-color"
263
- value="var(--fs-color-text)"
264
- isColor
265
- />
266
- <TokenRow
267
- token="--fs-product-card-title-size"
268
- value="var(--fs-text-size-base)"
269
- />
270
- <TokenRow
271
- token="--fs-product-card-title-weight"
272
- value="var(--fs-text-weight-regular)"
273
- />
274
- <TokenRow
275
- token="--fs-product-card-title-max-lines"
276
- value="var(--fs-text-max-lines)"
277
- />
278
- </TokenTable>
279
-
280
- ### Price
281
-
282
- <TokenTable>
283
- <TokenRow
284
- token="--fs-product-card-price-color"
285
- value="var(--fs-color-text)"
286
- isColor
287
- />
288
- <TokenRow
289
- token="--fs-product-card-price-size"
290
- value="var(--fs-text-size-base)"
291
- />
292
- <TokenRow
293
- token="--fs-product-card-price-listing-color"
294
- value="var(--fs-color-text-light)"
295
- isColor
296
- />
297
- <TokenRow
298
- token="--fs-product-card-price-listing-size"
299
- value="var(--fs-text-size-legend)"
300
- />
301
- </TokenTable>
302
-
303
- ### Description
304
-
305
- <TokenTable>
306
- <TokenRow
307
- token="--fs-product-card-description-color"
308
- value="var(--fs-color-text)"
309
- isColor
310
- />
311
- <TokenRow
312
- token="--fs-product-card-description-size"
313
- value="var(--fs-text-size-legend)"
314
- />
315
- </TokenTable>
316
-
317
- ### Subtitle
318
-
319
- <TokenTable>
320
- <TokenRow
321
- token="--fs-product-card-subtitle-color"
322
- value="var(--fs-color-text-light)"
323
- isColor
324
- />
325
- <TokenRow
326
- token="--fs-product-card-subtitle-size"
327
- value="var(--fs-text-size-tiny)"
328
- />
329
- </TokenTable>
330
-
331
- ---
332
-
333
- ## Variants
334
-
335
- ### Default
336
-
337
- <Canvas>
338
- <Story
339
- name="product-card-default"
340
- args={{
341
- product: product,
342
- index: 1,
343
- variant: 'default',
344
- bordered: false,
345
- aspectRatio: 1,
346
- BuyButton: false,
347
- }}
348
- >
349
- {Template.bind({})}
350
- </Story>
351
- </Canvas>
352
-
353
- ### Bordered
354
-
355
- <Canvas>
356
- <Story
357
- name="product-card-bordered"
358
- args={{
359
- product: product,
360
- index: 1,
361
- variant: 'default',
362
- bordered: true,
363
- aspectRatio: 1,
364
- BuyButton: false,
365
- }}
366
- >
367
- {Template.bind({})}
368
- </Story>
369
- </Canvas>
370
-
371
- <TokenTable>
372
- <TokenRow
373
- token="--fs-product-card-border-width"
374
- value="var(--fs-border-width)"
375
- />
376
- <TokenRow
377
- token="--fs-product-card-border-color"
378
- value="var(--fs-border-color-light)"
379
- isColor
380
- />
381
- </TokenTable>
382
-
383
- ### Wide
384
-
385
- <Canvas>
386
- <Story
387
- name="product-card-wide"
388
- args={{
389
- product: product,
390
- index: 1,
391
- variant: 'wide',
392
- bordered: false,
393
- aspectRatio: 1.5,
394
- BuyButton: false,
395
- }}
396
- >
397
- {TemplateWide.bind({})}
398
- </Story>
399
- </Canvas>
400
-
401
- <TokenTable>
402
- <TokenRow token="--fs-product-card-wide-padding" value="0" />
403
- <TokenRow
404
- token="--fs-product-card-wide-content-padding"
405
- value="var(--fs-spacing-2)"
406
- />
407
- <TokenRow
408
- token="--fs-product-card-wide-bkg-color"
409
- value="var(--fs-color-neutral-bkg)"
410
- isColor
411
- />
412
- <TokenRow token="--fs-product-card-wide-min-width" value="9rem" />
413
- </TokenTable>