@graphcommerce/next-ui 8.1.0-canary.9 → 9.0.0-canary.55
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/ActionCard/ActionCard.tsx +60 -36
- package/ActionCard/ActionCardAccordion.tsx +2 -1
- package/ActionCard/ActionCardList.tsx +3 -2
- package/ActionCard/ActionCardListForm.tsx +1 -1
- package/Blog/BlogAuthor/BlogAuthor.tsx +2 -4
- package/Blog/BlogListItem/BlogListItem.tsx +2 -4
- package/Breadcrumbs/Breadcrumbs.tsx +195 -0
- package/Breadcrumbs/BreadcrumbsJsonLd.tsx +13 -0
- package/Breadcrumbs/BreadcrumbsList.tsx +101 -0
- package/Breadcrumbs/BreadcrumbsPopper.tsx +48 -0
- package/Breadcrumbs/index.ts +4 -0
- package/Breadcrumbs/jsonLdBreadcrumb.tsx +19 -0
- package/Breadcrumbs/types.ts +11 -0
- package/CHANGELOG.md +162 -0
- package/Config.graphqls +5 -0
- package/Document/DocumentBodyEnd.tsx +7 -0
- package/Document/DocumentBodyStart.tsx +7 -0
- package/Document/DocumentHeadEnd.tsx +7 -0
- package/Document/DocumentHeadStart.tsx +7 -0
- package/Document/index.ts +4 -0
- package/Footer/Footer.tsx +1 -1
- package/FramerScroller/SidebarGallery.tsx +54 -27
- package/Intl/DateTimeFormat/DateFormat.tsx +10 -0
- package/Intl/DateTimeFormat/DateTimeFormat.tsx +25 -0
- package/Intl/DateTimeFormat/TimeFormat.tsx +10 -0
- package/Intl/DateTimeFormat/index.ts +3 -0
- package/Intl/DisplayNames/DisplayNames.tsx +22 -0
- package/Intl/DisplayNames/index.ts +1 -0
- package/Intl/ListFormat.tsx +32 -0
- package/Intl/NumberFormat/CurrencyFormat.tsx +191 -0
- package/Intl/NumberFormat/NumberFormat.tsx +24 -0
- package/Intl/NumberFormat/PercentFormat.tsx +5 -0
- package/Intl/NumberFormat/UnitFormat.tsx +59 -0
- package/Intl/NumberFormat/index.ts +4 -0
- package/Intl/index.ts +11 -0
- package/JsonLd/JsonLd.tsx +3 -2
- package/Layout/components/LayoutHeader.tsx +17 -3
- package/Layout/components/LayoutHeaderBack.tsx +9 -1
- package/Layout/components/LayoutTitle.tsx +0 -5
- package/LazyHydrate/LazyHydrate.tsx +19 -3
- package/PageLoadIndicator/PageLoadIndicator.tsx +25 -14
- package/PageMeta/PageMeta.tsx +1 -76
- package/PageMeta/canonicalize.ts +78 -0
- package/Pagination/PaginationExtended.tsx +103 -0
- package/Snackbar/MessageSnackbarImpl.tsx +60 -19
- package/Styles/responsiveVal.tsx +4 -5
- package/Styles/withEmotionCache.tsx +2 -2
- package/Theme/DarkLightModeThemeProvider.tsx +41 -19
- package/hooks/index.ts +1 -1
- package/hooks/useDateTimeFormat.ts +4 -4
- package/hooks/{useSsr.ts → useIsSsr.ts} +3 -0
- package/hooks/useLocale.ts +2 -2
- package/hooks/useNumberFormat.ts +4 -3
- package/hooks/useStorefrontConfig.ts +1 -9
- package/hooks/useUrlQuery.ts +6 -4
- package/icons.ts +55 -0
- package/index.ts +10 -3
- package/package.json +8 -9
- package/server.ts +8 -0
- package/utils/cssFlags.tsx +53 -0
- package/utils/getCssFlagInitScript.tsx +20 -0
- package/utils/normalizeLocale.ts +26 -0
- package/utils/sitemap.ts +1 -1
- package/utils/storefrontConfig.ts +8 -0
- package/icons/index.ts +0 -48
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/next-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "9.0.0-canary.55",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -26,14 +26,13 @@
|
|
|
26
26
|
"typescript": "5.3.3"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@graphcommerce/eslint-config-pwa": "^
|
|
30
|
-
"@graphcommerce/framer-next-pages": "^
|
|
31
|
-
"@graphcommerce/framer-scroller": "^
|
|
32
|
-
"@graphcommerce/framer-utils": "^
|
|
33
|
-
"@graphcommerce/image": "^
|
|
34
|
-
"@graphcommerce/
|
|
35
|
-
"@graphcommerce/
|
|
36
|
-
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.9",
|
|
29
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.55",
|
|
30
|
+
"@graphcommerce/framer-next-pages": "^9.0.0-canary.55",
|
|
31
|
+
"@graphcommerce/framer-scroller": "^9.0.0-canary.55",
|
|
32
|
+
"@graphcommerce/framer-utils": "^9.0.0-canary.55",
|
|
33
|
+
"@graphcommerce/image": "^9.0.0-canary.55",
|
|
34
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.55",
|
|
35
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.55",
|
|
37
36
|
"@lingui/core": "^4.2.1",
|
|
38
37
|
"@lingui/macro": "^4.2.1",
|
|
39
38
|
"@lingui/react": "^4.2.1",
|
package/server.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './Styles/withEmotionCache'
|
|
2
|
+
export * from './utils/getCssFlagInitScript'
|
|
3
|
+
export * from './utils/normalizeLocale'
|
|
4
|
+
export * from './utils/robots'
|
|
5
|
+
export * from './utils/sitemap'
|
|
6
|
+
export * from './utils/storefrontConfig'
|
|
7
|
+
export * from './PageMeta/canonicalize'
|
|
8
|
+
export * from './Document'
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { FLAGS_STORAGE_KEY } from './getCssFlagInitScript'
|
|
2
|
+
|
|
3
|
+
function loadFlags() {
|
|
4
|
+
const flags = JSON.parse(localStorage.getItem(FLAGS_STORAGE_KEY) || '{}')
|
|
5
|
+
if (typeof flags !== 'object' && flags !== null) return {}
|
|
6
|
+
return flags as Record<string, true | string>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function saveFlags(flags: Record<string, true | string>) {
|
|
10
|
+
window.localStorage?.setItem(FLAGS_STORAGE_KEY, JSON.stringify(flags))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function removeCssFlag(flagName: string) {
|
|
14
|
+
const flags = loadFlags()
|
|
15
|
+
delete flags[flagName]
|
|
16
|
+
document.documentElement.removeAttribute(`data-${flagName}`)
|
|
17
|
+
saveFlags(flags)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function setCssFlag(flagName: string, val: true | string) {
|
|
21
|
+
document.documentElement.setAttribute(`data-${flagName}`, typeof val === 'boolean' ? '' : val)
|
|
22
|
+
|
|
23
|
+
const flags = loadFlags()
|
|
24
|
+
flags[flagName] = val
|
|
25
|
+
saveFlags(flags)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getCssFlag(flagName: string) {
|
|
29
|
+
return loadFlags()[flagName]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Easily create a CSS selector that only applies when a flag is set.
|
|
34
|
+
*
|
|
35
|
+
* Example:
|
|
36
|
+
*
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <Box sx={{ [cssFlagSelector('dark')]: { color: 'white' } }} />
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export const cssFlag = <T extends string>(flagName: T) => `html[data-${flagName}] &` as const
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Easily create a CSS selector that only applies when a flag is not set.
|
|
45
|
+
*
|
|
46
|
+
* Example:
|
|
47
|
+
*
|
|
48
|
+
* ```tsx
|
|
49
|
+
* <Box sx={{ [cssNotFlagSelector('dark')]: { color: 'black' } }} />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export const cssNotFlag = <T extends string>(flagName: T) =>
|
|
53
|
+
`html:not([data-${flagName}]) &` as const
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const FLAGS_STORAGE_KEY = 'gc-flags'
|
|
2
|
+
|
|
3
|
+
export function getCssFlagsInitScript() {
|
|
4
|
+
return (
|
|
5
|
+
<script
|
|
6
|
+
id='init-gc-flags'
|
|
7
|
+
key='mui-color-scheme-init'
|
|
8
|
+
// eslint-disable-next-line react/no-danger
|
|
9
|
+
dangerouslySetInnerHTML={{
|
|
10
|
+
__html: `(function() {
|
|
11
|
+
try {
|
|
12
|
+
const flags = JSON.parse(localStorage.getItem('${FLAGS_STORAGE_KEY}') || '{}')
|
|
13
|
+
Object.entries(flags).forEach(([key, val]) => {
|
|
14
|
+
document.documentElement.setAttribute('data-' +key, typeof val === 'boolean' ? '' : val)
|
|
15
|
+
})
|
|
16
|
+
} catch(e){}})();`,
|
|
17
|
+
}}
|
|
18
|
+
/>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { storefrontConfig, storefrontConfigDefault } from './storefrontConfig'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* To support using multiple storefronts using the same language locale (which
|
|
5
|
+
* next.js does not support), we use an additional 'tag' in the locale code in
|
|
6
|
+
* which we specify a unique string (i.e. a Magento store code).
|
|
7
|
+
*
|
|
8
|
+
* This makes next.js happy, as it still follows the BCP47 spec. However, the
|
|
9
|
+
* Intl API and other places may not accept this as a valid locale.
|
|
10
|
+
*
|
|
11
|
+
* Use this method to get a 'normalized' locale that can safely be used in such
|
|
12
|
+
* places.
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeLocale(locale: string | undefined = storefrontConfigDefault().locale) {
|
|
15
|
+
const linguiLocale = storefrontConfig(locale)?.linguiLocale
|
|
16
|
+
if (linguiLocale) return linguiLocale
|
|
17
|
+
|
|
18
|
+
// Specifically match the xx-yy-storecode format, so we don't accidently 'fix'
|
|
19
|
+
// valid locales such as he-Hebr-IL or zh-Hans-CN. This this isn't perfect and
|
|
20
|
+
// we should consider a more formalized way to use such pseudo-locales, which
|
|
21
|
+
// can be matched more precisely.
|
|
22
|
+
|
|
23
|
+
const matches = locale?.match(/([a-z]{2})-([a-z]{2})-([a-z]+)/i)
|
|
24
|
+
if (matches) return `${matches[1]}-${matches[2]}`
|
|
25
|
+
return locale
|
|
26
|
+
}
|
package/utils/sitemap.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetServerSidePropsContext, GetStaticPathsResult } from 'next'
|
|
2
2
|
import { getServerSideSitemapLegacy, ISitemapField } from 'next-sitemap'
|
|
3
|
-
import { canonicalize } from '../PageMeta/
|
|
3
|
+
import { canonicalize } from '../PageMeta/canonicalize'
|
|
4
4
|
|
|
5
5
|
export function excludeSitemap(excludes: string[]) {
|
|
6
6
|
const regexp = excludes.map((exclude) => new RegExp(exclude.replace(/\*/g, '.*?')))
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const storefrontAll = import.meta.graphCommerce.storefront
|
|
2
|
+
|
|
3
|
+
/** Get the current storefront config based on the provided locale */
|
|
4
|
+
export const storefrontConfig = (locale?: string | undefined) =>
|
|
5
|
+
storefrontAll.find((l) => l.locale === locale)
|
|
6
|
+
|
|
7
|
+
export const storefrontConfigDefault = () =>
|
|
8
|
+
storefrontAll.find((l) => l.defaultLocale) ?? storefrontAll[0]
|
package/icons/index.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export { default as iconArrowBack } from './arrow-left.svg'
|
|
2
|
-
export { default as iconArrowForward } from './arrow-right.svg'
|
|
3
|
-
export { default as iconShoppingBag } from './bag.svg'
|
|
4
|
-
export { default as iconInvoice } from './box-alt.svg'
|
|
5
|
-
export { default as iconBox } from './box.svg'
|
|
6
|
-
export { default as iconOrderBefore } from './calendar.svg'
|
|
7
|
-
export { default as iconCancelAlt } from './cancel-alt.svg'
|
|
8
|
-
export { default as iconCartAdd } from './cart-add.svg'
|
|
9
|
-
export { default as iconCart } from './cart.svg'
|
|
10
|
-
export { default as iconChat } from './chat-alt.svg'
|
|
11
|
-
export { default as iconCustomerService } from './chat.svg'
|
|
12
|
-
export { default as iconChevronDown } from './chevron-down.svg'
|
|
13
|
-
export { default as iconChevronBack, default as iconChevronLeft } from './chevron-left.svg'
|
|
14
|
-
export { default as iconChevronRight } from './chevron-right.svg'
|
|
15
|
-
export { default as iconChevronUp } from './chevron-up.svg'
|
|
16
|
-
export { default as iconCirle } from './circle.svg'
|
|
17
|
-
export { default as iconClose } from './close.svg'
|
|
18
|
-
export { default as iconCreditCard, default as iconId } from './credit-card.svg'
|
|
19
|
-
export { default as iconEllypsis } from './ellypsis.svg'
|
|
20
|
-
export { default as iconEmail, default as iconEmailOutline } from './envelope-alt.svg'
|
|
21
|
-
export { default as icon404 } from './explore.svg'
|
|
22
|
-
export { default as iconEyeClosed } from './eye-closed.svg'
|
|
23
|
-
export { default as iconEyeCrossed } from './eye-crossed.svg'
|
|
24
|
-
export { default as iconEye } from './eye.svg'
|
|
25
|
-
export { default as iconHeart } from './favourite.svg'
|
|
26
|
-
export { default as iconMenu } from './hamburger.svg'
|
|
27
|
-
export { default as iconParty } from './happy-face.svg'
|
|
28
|
-
export { default as iconAddresses, default as iconHome } from './home-alt.svg'
|
|
29
|
-
export { default as iconLanguage } from './language.svg'
|
|
30
|
-
export { default as iconLocation } from './location.svg'
|
|
31
|
-
export { default as iconLock } from './lock.svg'
|
|
32
|
-
export { default as iconFullscreen } from './maximise.svg'
|
|
33
|
-
export { default as iconFullscreenExit } from './minimise.svg'
|
|
34
|
-
export { default as iconMin } from './minus.svg'
|
|
35
|
-
export { default as iconMoon } from './moon.svg'
|
|
36
|
-
export { default as iconNewspaper } from './news.svg'
|
|
37
|
-
export { default as iconCheckmark } from './ok.svg'
|
|
38
|
-
export { default as iconPerson } from './person-alt.svg'
|
|
39
|
-
export { default as iconPlay } from './play.svg'
|
|
40
|
-
export { default as iconPlus } from './plus.svg'
|
|
41
|
-
export { default as iconShutdown } from './power.svg'
|
|
42
|
-
export { default as iconRefresh } from './refresh.svg'
|
|
43
|
-
export { default as iconSadFace } from './sad-face.svg'
|
|
44
|
-
export { default as iconSearch } from './search.svg'
|
|
45
|
-
export { default as iconPhone } from './smartphone.svg'
|
|
46
|
-
export { default as iconStar } from './star.svg'
|
|
47
|
-
export { default as iconSun } from './sun.svg'
|
|
48
|
-
export { default as iconCompare } from './compare-arrows.svg'
|