@artisanpack-ui/ecommerce-storefront-react 0.0.0-stage → 1.0.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.
- package/LICENSE +21 -0
- package/README.md +67 -2
- package/dist/Addresses-D3ESHG3L.mjs +27 -0
- package/dist/Addresses-D3ESHG3L.mjs.map +1 -0
- package/dist/CategoryShow-OAGROEMA.mjs +12 -0
- package/dist/CategoryShow-OAGROEMA.mjs.map +1 -0
- package/dist/Claim-CJ4UOAUD.mjs +22 -0
- package/dist/Claim-CJ4UOAUD.mjs.map +1 -0
- package/dist/Confirmation-TLMMBPWS.mjs +20 -0
- package/dist/Confirmation-TLMMBPWS.mjs.map +1 -0
- package/dist/Dashboard-ARXORMTL.mjs +24 -0
- package/dist/Dashboard-ARXORMTL.mjs.map +1 -0
- package/dist/Downloads-CEQBY7JO.mjs +25 -0
- package/dist/Downloads-CEQBY7JO.mjs.map +1 -0
- package/dist/Index-KRR3Q7EJ.mjs +12 -0
- package/dist/Index-KRR3Q7EJ.mjs.map +1 -0
- package/dist/Index-RLQFEBTX.mjs +22 -0
- package/dist/Index-RLQFEBTX.mjs.map +1 -0
- package/dist/Index-WDJYGR5Q.mjs +12 -0
- package/dist/Index-WDJYGR5Q.mjs.map +1 -0
- package/dist/Index-XYU5QLUT.mjs +23 -0
- package/dist/Index-XYU5QLUT.mjs.map +1 -0
- package/dist/Lookup-QNUQKUID.mjs +19 -0
- package/dist/Lookup-QNUQKUID.mjs.map +1 -0
- package/dist/OrderShow-RYTP62YA.mjs +27 -0
- package/dist/OrderShow-RYTP62YA.mjs.map +1 -0
- package/dist/Orders-LZW57GE6.mjs +25 -0
- package/dist/Orders-LZW57GE6.mjs.map +1 -0
- package/dist/Profile-ZAAWFCAL.mjs +25 -0
- package/dist/Profile-ZAAWFCAL.mjs.map +1 -0
- package/dist/Show-LFWUO3KR.mjs +14 -0
- package/dist/Show-LFWUO3KR.mjs.map +1 -0
- package/dist/TagShow-FXKXRGY2.mjs +12 -0
- package/dist/TagShow-FXKXRGY2.mjs.map +1 -0
- package/dist/chunk-5UUNH3EH.mjs +1888 -0
- package/dist/chunk-5UUNH3EH.mjs.map +1 -0
- package/dist/chunk-A3MMQ2RY.mjs +183 -0
- package/dist/chunk-A3MMQ2RY.mjs.map +1 -0
- package/dist/chunk-ABGPTZ3Q.mjs +198 -0
- package/dist/chunk-ABGPTZ3Q.mjs.map +1 -0
- package/dist/chunk-BJ3FJFZQ.mjs +32 -0
- package/dist/chunk-BJ3FJFZQ.mjs.map +1 -0
- package/dist/chunk-BSASRFQ7.mjs +89 -0
- package/dist/chunk-BSASRFQ7.mjs.map +1 -0
- package/dist/chunk-CGCW3555.mjs +148 -0
- package/dist/chunk-CGCW3555.mjs.map +1 -0
- package/dist/chunk-DWR23FJD.mjs +643 -0
- package/dist/chunk-DWR23FJD.mjs.map +1 -0
- package/dist/chunk-ENY3MH2W.mjs +148 -0
- package/dist/chunk-ENY3MH2W.mjs.map +1 -0
- package/dist/chunk-EWJLRWPO.mjs +280 -0
- package/dist/chunk-EWJLRWPO.mjs.map +1 -0
- package/dist/chunk-FL5XL3ET.mjs +212 -0
- package/dist/chunk-FL5XL3ET.mjs.map +1 -0
- package/dist/chunk-FOOP6UK3.mjs +218 -0
- package/dist/chunk-FOOP6UK3.mjs.map +1 -0
- package/dist/chunk-HCC7GTVO.mjs +115 -0
- package/dist/chunk-HCC7GTVO.mjs.map +1 -0
- package/dist/chunk-HXZMY3GE.mjs +2331 -0
- package/dist/chunk-HXZMY3GE.mjs.map +1 -0
- package/dist/chunk-IOL2YQ62.mjs +109 -0
- package/dist/chunk-IOL2YQ62.mjs.map +1 -0
- package/dist/chunk-JH7SFSZA.mjs +104 -0
- package/dist/chunk-JH7SFSZA.mjs.map +1 -0
- package/dist/chunk-JJOPX4PI.mjs +205 -0
- package/dist/chunk-JJOPX4PI.mjs.map +1 -0
- package/dist/chunk-LT3GG7YQ.mjs +32 -0
- package/dist/chunk-LT3GG7YQ.mjs.map +1 -0
- package/dist/chunk-MZFULGDI.mjs +267 -0
- package/dist/chunk-MZFULGDI.mjs.map +1 -0
- package/dist/chunk-O4WPMMSH.mjs +58 -0
- package/dist/chunk-O4WPMMSH.mjs.map +1 -0
- package/dist/chunk-OU3WYFIH.mjs +397 -0
- package/dist/chunk-OU3WYFIH.mjs.map +1 -0
- package/dist/chunk-P3NIV4YG.mjs +998 -0
- package/dist/chunk-P3NIV4YG.mjs.map +1 -0
- package/dist/chunk-PEBBSZ5R.mjs +201 -0
- package/dist/chunk-PEBBSZ5R.mjs.map +1 -0
- package/dist/chunk-T5OWL6EG.mjs +73 -0
- package/dist/chunk-T5OWL6EG.mjs.map +1 -0
- package/dist/chunk-THPUK35U.mjs +132 -0
- package/dist/chunk-THPUK35U.mjs.map +1 -0
- package/dist/chunk-TPOKMH5E.mjs +142 -0
- package/dist/chunk-TPOKMH5E.mjs.map +1 -0
- package/dist/chunk-VX5TEJNU.mjs +1898 -0
- package/dist/chunk-VX5TEJNU.mjs.map +1 -0
- package/dist/chunk-WUL34MB2.mjs +268 -0
- package/dist/chunk-WUL34MB2.mjs.map +1 -0
- package/dist/chunk-WYGOMIZK.mjs +140 -0
- package/dist/chunk-WYGOMIZK.mjs.map +1 -0
- package/dist/chunk-Y2IOBBN7.mjs +127 -0
- package/dist/chunk-Y2IOBBN7.mjs.map +1 -0
- package/dist/chunk-Y5BRPEHA.mjs +54 -0
- package/dist/chunk-Y5BRPEHA.mjs.map +1 -0
- package/dist/index.d.ts +4607 -0
- package/dist/index.mjs +1515 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +112 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/PriceRange.tsx","../src/catalog/listingState.ts","../src/catalog/CatalogFilters.tsx","../src/catalog/useQuickAdd.ts","../src/catalog/CatalogListing.tsx","../src/catalog/StorefrontBreadcrumbs.tsx"],"sourcesContent":["/**\n * `ec-price-range`: the catalog's price filter, a two-thumb slider with a\n * lowest and highest amount input.\n *\n * Mirrors ecommerce-storefront-livewire's `<x-artisanpack-ec-price-range>`.\n * Amounts are in minor units; the inputs show major units. A thumb or input\n * at its bound clears that end (null). Typing settles on blur or Enter and\n * snaps to the step; changes reach `onValueChange` 400ms after the last one,\n * as the Livewire filter refreshes.\n *\n * @since 1.0.0\n */\n\nimport { __, type StorefrontPriceRange } from '@artisanpack-ui/ecommerce-storefront-core';\nimport { Input, Range } from '@artisanpack-ui/react';\nimport { useEffect, useRef, useState, type ReactElement } from 'react';\n\nimport { cx } from '../internal/classes';\n\n/**\n * The chosen bounds, in minor units; null leaves that end open.\n *\n * @since 1.0.0\n */\nexport interface PriceRangeValue {\n from: number | null;\n to: number | null;\n}\n\n/**\n * Props for {@link PriceRange}.\n *\n * @since 1.0.0\n */\nexport interface PriceRangeProps {\n range: StorefrontPriceRange;\n /** The legend, or null for none. */\n label?: string | null;\n /** The parts' id prefix. Default `ec-price-range`. */\n idPrefix?: string;\n /** Called with the new bounds, 400ms after the last change. */\n onValueChange?: (value: PriceRangeValue) => void;\n /** The delay before `onValueChange`, in ms. Default 400. */\n debounce?: number;\n className?: string;\n}\n\n/**\n * A price range filter.\n *\n * @since 1.0.0\n *\n * @param props - The range and handlers.\n * @returns The fieldset.\n */\nexport function PriceRange({\n range,\n label = null,\n idPrefix = 'ec-price-range',\n onValueChange,\n debounce = 400,\n className,\n}: PriceRangeProps): ReactElement {\n const { min, max, step, divisor, decimals, currency, symbol } = range;\n const [bounds, setBounds] = useState<PriceRangeValue>({ from: range.from, to: range.to });\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const root = useRef<HTMLFieldSetElement>(null);\n // The debounced call reaches the latest callback, not the one from the\n // render that scheduled it (which would see stale state in the parent).\n const latestOnValueChange = useRef(onValueChange);\n\n useEffect(() => {\n latestOnValueChange.current = onValueChange;\n });\n const [typed, setTyped] = useState<{ from: string | null; to: string | null }>({\n from: null,\n to: null,\n });\n\n const [given, setGiven] = useState<PriceRangeValue>({ from: range.from, to: range.to });\n\n // New bounds from the server (a reload, another filter) replace local ones.\n if (given.from !== range.from || given.to !== range.to) {\n setGiven({ from: range.from, to: range.to });\n setBounds({ from: range.from, to: range.to });\n }\n\n useEffect(() => () => clearTimeout(timer.current), []);\n\n const low = Math.min(max, Math.max(min, bounds.from ?? min));\n const high = Math.max(low, Math.min(max, bounds.to ?? max));\n\n const major = (amount: number): string => (amount / divisor).toFixed(decimals);\n const money = (amount: number): string => {\n try {\n return new Intl.NumberFormat(document.documentElement.lang || undefined, {\n style: 'currency',\n currency,\n }).format(amount / divisor);\n } catch {\n return String(amount / divisor);\n }\n };\n\n // The design-system Range takes a text template for aria-valuetext; the\n // thumbs read the amount as money instead.\n useEffect(() => {\n root.current?.querySelectorAll<HTMLInputElement>('input[data-thumb]').forEach((thumb) => {\n thumb.setAttribute('aria-valuetext', money('start' === thumb.dataset.thumb ? low : high));\n });\n });\n\n const send = (next: PriceRangeValue): void => {\n clearTimeout(timer.current);\n timer.current = setTimeout(() => latestOnValueChange.current?.(next), debounce);\n };\n\n const update = (next: PriceRangeValue): void => {\n setBounds(next);\n send(next);\n };\n\n const fromValue = (value: number): number | null => {\n const clamped = Math.max(min, Math.min(value, high));\n\n return clamped <= min ? null : clamped;\n };\n\n const toValue = (value: number): number | null => {\n const clamped = Math.min(max, Math.max(value, low));\n\n return clamped >= max ? null : clamped;\n };\n\n const settle = (bound: 'from' | 'to'): void => {\n const raw = typed[bound];\n\n setTyped((current) => ({ ...current, [bound]: null }));\n\n if (null === raw) {\n return;\n }\n\n const amount = Number.parseFloat(raw.replace(',', '.'));\n\n if (!Number.isFinite(amount)) {\n return;\n }\n\n const minor = min + Math.round((amount * divisor - min) / step) * step;\n\n update(\n 'from' === bound\n ? { from: fromValue(minor), to: bounds.to }\n : { from: bounds.from, to: toValue(minor) },\n );\n };\n\n const input = (bound: 'from' | 'to'): ReactElement => (\n <Input\n id={`${idPrefix}-${'from' === bound ? 'min' : 'max'}`}\n type=\"number\"\n inputMode=\"decimal\"\n size=\"sm\"\n prefix={symbol}\n min={min / divisor}\n max={max / divisor}\n step={step / divisor}\n aria-label={'from' === bound ? __('Lowest price') : __('Highest price')}\n value={typed[bound] ?? major('from' === bound ? low : high)}\n className=\"ec-price-range__input\"\n onValueChange={(value) => setTyped((current) => ({ ...current, [bound]: value }))}\n onBlur={() => settle(bound)}\n onKeyDown={(event) => {\n if ('Enter' === event.key) {\n event.preventDefault();\n settle(bound);\n }\n }}\n {...('from' === bound ? { 'data-price-min': '' } : { 'data-price-max': '' })}\n />\n );\n\n return (\n <fieldset ref={root} className={cx('ec-price-range', className)} data-price-range=\"\">\n {null !== label ? (\n <legend id={`${idPrefix}-legend`} className=\"ec-price-range__legend\">\n {label}\n </legend>\n ) : null}\n\n <Range\n dual\n showValue=\"never\"\n min={min}\n max={max}\n step={step}\n value={[low, high]}\n thumbLabels={{ start: __('Lowest price'), end: __('Highest price') }}\n aria-labelledby={null !== label ? `${idPrefix}-legend` : undefined}\n id={`${idPrefix}-range`}\n className=\"ec-price-range__slider\"\n onValueChange={(value) => {\n const [start, end] = Array.isArray(value) ? value : [min, value];\n\n update({ from: fromValue(start ?? min), to: toValue(end ?? max) });\n }}\n data-price-slider=\"\"\n />\n\n <div className=\"ec-price-range__inputs\">\n {input('from')}\n <span className=\"ec-price-range__to\" aria-hidden=\"true\">\n {__('to')}\n </span>\n {input('to')}\n </div>\n </fieldset>\n );\n}\n","/**\n * Listing URLs and filter state.\n *\n * The server sends a listing's normalised query-string `state` (defaults\n * left out) and its `urls.base`. Changing the sort, the page size or a\n * filter starts over at page 1, so these helpers build the next URL from\n * the state without `page`, as ecommerce-storefront-inertia's\n * `CatalogListing::url()` does (PHP's `http_build_query()`).\n *\n * @since 1.0.0\n */\n\nimport type {\n StorefrontFilterGroup,\n StorefrontListingState,\n} from '@artisanpack-ui/ecommerce-storefront-core';\n\n/**\n * A listing's state, plus the page.\n *\n * @since 1.0.0\n */\nexport type ListingQuery = StorefrontListingState & { page?: number };\n\n/**\n * Appends one value, or each value of an array or object, as PHP's\n * `http_build_query()` does (`attr[colour][0]=blue`).\n *\n * @param pairs - The pairs so far.\n * @param key - The key.\n * @param value - The value.\n */\nfunction append(pairs: string[], key: string, value: unknown): void {\n if (null === value || undefined === value) {\n return;\n }\n\n if (Array.isArray(value)) {\n value.forEach((item, index) => append(pairs, `${key}[${index}]`, item));\n\n return;\n }\n\n if ('object' === typeof value) {\n for (const [child, item] of Object.entries(value as Record<string, unknown>)) {\n append(pairs, `${key}[${child}]`, item);\n }\n\n return;\n }\n\n pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);\n}\n\n/**\n * The query string for a state.\n *\n * @since 1.0.0\n *\n * @param query - The state.\n * @returns The query string, without `?`.\n */\nexport function buildQuery(query: ListingQuery): string {\n const pairs: string[] = [];\n\n for (const [key, value] of Object.entries(query)) {\n append(pairs, key, value);\n }\n\n return pairs.join('&');\n}\n\n/**\n * A listing URL.\n *\n * @since 1.0.0\n *\n * @param base - The page's URL without a query string.\n * @param query - The state.\n * @returns The URL.\n */\nexport function listingUrl(base: string, query: ListingQuery): string {\n const search = buildQuery(query);\n\n return '' === search ? base : `${base}?${search}`;\n}\n\n/**\n * The value a single-choice filter group has in the state.\n *\n * @since 1.0.0\n *\n * @param state - The state.\n * @param group - The group.\n * @returns The chosen value; `''` (or `'0'` for the rating) for \"All\".\n */\nexport function choiceValue(state: StorefrontListingState, group: StorefrontFilterGroup): string {\n switch (group.type) {\n case 'category':\n return state.category ?? '';\n case 'tag':\n return state.tag ?? '';\n case 'rating':\n return String(state.rating ?? 0);\n default:\n return '';\n }\n}\n\n/**\n * The values a multi-choice filter group has in the state.\n *\n * @since 1.0.0\n *\n * @param state - The state.\n * @param group - The group.\n * @returns The chosen values.\n */\nexport function optionValues(\n state: StorefrontListingState,\n group: StorefrontFilterGroup,\n): string[] {\n if ('attribute' === group.type) {\n return state.attr?.[group.attribute ?? group.key.replace(/^attr\\./, '')] ?? [];\n }\n\n if ('custom-options' === group.type) {\n const value = state.f?.[group.key];\n\n return Array.isArray(value) ? value : [];\n }\n\n return [];\n}\n\n/**\n * Whether a toggle filter group is on in the state.\n *\n * @since 1.0.0\n *\n * @param state - The state.\n * @param group - The group.\n * @returns True when on.\n */\nexport function toggleValue(state: StorefrontListingState, group: StorefrontFilterGroup): boolean {\n if ('toggle' === group.type) {\n return '1' === (state as Record<string, unknown>)[group.key];\n }\n\n if ('custom-toggle' === group.type) {\n return '1' === state.f?.[group.key];\n }\n\n return false;\n}\n\n/**\n * Drops empty nested maps so the URL leaves them out.\n *\n * @param state - The state.\n * @returns The tidied state.\n */\nfunction tidy(state: StorefrontListingState): StorefrontListingState {\n const next = { ...state };\n\n if (undefined !== next.attr && 0 === Object.keys(next.attr).length) {\n delete next.attr;\n }\n\n if (undefined !== next.f && 0 === Object.keys(next.f).length) {\n delete next.f;\n }\n\n return next;\n}\n\n/**\n * The state with a single-choice group set (`''` or `'0'` clears it).\n *\n * @since 1.0.0\n *\n * @param state - The state.\n * @param group - The group.\n * @param value - The chosen value.\n * @returns The new state.\n */\nexport function withChoice(\n state: StorefrontListingState,\n group: StorefrontFilterGroup,\n value: string,\n): StorefrontListingState {\n const next: StorefrontListingState = { ...state };\n\n if ('category' === group.type || 'tag' === group.type) {\n if ('' === value) {\n delete next[group.type];\n } else {\n next[group.type] = value;\n }\n } else if ('rating' === group.type) {\n const stars = Number.parseInt(value, 10);\n\n if (Number.isFinite(stars) && stars > 0) {\n next.rating = stars;\n } else {\n delete next.rating;\n }\n }\n\n return next;\n}\n\n/**\n * The state with one option of a multi-choice group turned on or off.\n *\n * @since 1.0.0\n *\n * @param state - The state.\n * @param group - The group.\n * @param value - The option.\n * @param checked - Whether it is now on.\n * @returns The new state.\n */\nexport function withOption(\n state: StorefrontListingState,\n group: StorefrontFilterGroup,\n value: string,\n checked: boolean,\n): StorefrontListingState {\n const current = optionValues(state, group).filter((item) => item !== value);\n const values = checked ? [...current, value] : current;\n\n if ('attribute' === group.type) {\n const key = group.attribute ?? group.key.replace(/^attr\\./, '');\n const attr = { ...(state.attr ?? {}) };\n\n if (0 === values.length) {\n delete attr[key];\n } else {\n attr[key] = values;\n }\n\n return tidy({ ...state, attr });\n }\n\n if ('custom-options' === group.type) {\n const f = { ...(state.f ?? {}) };\n\n if (0 === values.length) {\n delete f[group.key];\n } else {\n f[group.key] = values;\n }\n\n return tidy({ ...state, f });\n }\n\n return state;\n}\n\n/**\n * The state with a toggle group turned on or off.\n *\n * @since 1.0.0\n *\n * @param state - The state.\n * @param group - The group.\n * @param on - Whether it is now on.\n * @returns The new state.\n */\nexport function withToggle(\n state: StorefrontListingState,\n group: StorefrontFilterGroup,\n on: boolean,\n): StorefrontListingState {\n if ('toggle' === group.type) {\n const next = { ...state } as Record<string, unknown>;\n\n if (on) {\n next[group.key] = '1';\n } else {\n delete next[group.key];\n }\n\n return next as StorefrontListingState;\n }\n\n if ('custom-toggle' === group.type) {\n const f = { ...(state.f ?? {}) };\n\n if (on) {\n f[group.key] = '1';\n } else {\n delete f[group.key];\n }\n\n return tidy({ ...state, f });\n }\n\n return state;\n}\n\n/**\n * The state with the price bounds set (minor units; null leaves an end open).\n *\n * @since 1.0.0\n *\n * @param state - The state.\n * @param from - The lowest price, or null.\n * @param to - The highest price, or null.\n * @param currency - The listing's currency.\n * @returns The new state.\n */\nexport function withPrice(\n state: StorefrontListingState,\n from: number | null,\n to: number | null,\n currency: string,\n): StorefrontListingState {\n const next: StorefrontListingState = { ...state };\n\n delete next.price_min;\n delete next.price_max;\n delete next.price_currency;\n\n if (null !== from) {\n next.price_min = from;\n }\n\n if (null !== to) {\n next.price_max = to;\n }\n\n if (null !== from || null !== to) {\n next.price_currency = currency;\n }\n\n return next;\n}\n","/**\n * The catalog filter groups.\n *\n * Mirrors ecommerce-storefront-livewire's `livewire/catalog/partials/filters`,\n * drawn in the desktop sidebar and again in the mobile drawer (`idPrefix`\n * keeps their ids apart). The groups stack between dividers:\n *\n * - Category, tag and rating: the design-system RadioGroup markup, written\n * out so each option carries its depth and count. \"All\" first; options\n * with no products are disabled.\n * - Price: the price range (two thumbs and two amount fields).\n * - Attributes and custom option groups: the swatches.\n * - In stock, on sale and custom toggles: a design-system Toggle, the label\n * followed by the count.\n *\n * The groups draw the state they're given; changes go to the handlers.\n *\n * @since 1.0.0\n */\n\nimport {\n __,\n subunit,\n type StorefrontFilterGroup,\n type StorefrontFilterOption,\n type StorefrontListingState,\n type StorefrontPriceFilterGroup,\n type StorefrontPriceRange,\n type StorefrontSwatchOption,\n} from '@artisanpack-ui/ecommerce-storefront-core';\nimport { Toggle } from '@artisanpack-ui/react';\nimport type { ReactElement } from 'react';\n\nimport { PriceRange, type PriceRangeValue } from '../components/PriceRange';\nimport { useStorefront } from '../useStorefront';\nimport { Swatches } from '../components/Swatches';\nimport { choiceValue, optionValues, toggleValue } from './listingState';\n\n/**\n * Props for {@link CatalogFilters}.\n *\n * @since 1.0.0\n */\nexport interface CatalogFiltersProps {\n groups: StorefrontFilterGroup[];\n /** The state the controls show (the shopper's latest choices). */\n state: StorefrontListingState;\n /** Keeps the sidebar's and the drawer's ids apart. */\n idPrefix: string;\n /** A category, tag or rating was chosen. */\n onChoice: (group: StorefrontFilterGroup, value: string) => void;\n /** An attribute or custom option was turned on or off. */\n onOption: (group: StorefrontFilterGroup, value: string, checked: boolean) => void;\n /** A toggle was turned on or off. */\n onToggle: (group: StorefrontFilterGroup, on: boolean) => void;\n /** The price bounds changed. */\n onPrice: (group: StorefrontPriceFilterGroup, value: PriceRangeValue) => void;\n}\n\n/**\n * An id fragment for a group key (`attr.colour` → `attr-colour`).\n *\n * @param key - The key.\n * @returns The fragment.\n */\nfunction idFragment(key: string): string {\n return key.replace(/[^A-Za-z0-9_-]/g, '-');\n}\n\n/**\n * The currency's symbol in the storefront's language.\n *\n * The locale comes from the shared props, not the document, so the server\n * render and the browser's hydration draw the same symbol.\n *\n * @param currency - ISO 4217 code.\n * @param locale - The storefront locale (`pt_BR`), or undefined for the default.\n * @returns The symbol.\n */\nfunction currencySymbol(currency: string, locale?: string): string {\n try {\n const lang = undefined === locale || '' === locale ? undefined : locale.replace('_', '-');\n\n return (\n new Intl.NumberFormat(lang, { style: 'currency', currency })\n .formatToParts(0)\n .find((part) => 'currency' === part.type)?.value ?? currency\n );\n } catch {\n return currency;\n }\n}\n\n/**\n * A price group as the price range component takes it.\n *\n * @since 1.0.0\n *\n * @param group - The price group.\n * @param locale - The storefront locale, for the currency symbol.\n * @returns The range.\n */\nexport function priceRangeFor(\n group: StorefrontPriceFilterGroup,\n locale?: string,\n): StorefrontPriceRange {\n let decimals = 2;\n\n try {\n decimals = subunit(group.currency);\n } catch {\n decimals = 2;\n }\n\n return {\n min: group.min,\n max: group.max,\n step: group.step,\n from: group.from,\n to: group.to,\n currency: group.currency,\n decimals,\n divisor: 10 ** decimals,\n symbol: currencySymbol(group.currency, locale),\n };\n}\n\n/**\n * A filter option as a swatch.\n *\n * @param option - The option.\n * @param selected - Whether it is chosen.\n * @returns The swatch.\n */\nfunction swatchFor(option: StorefrontFilterOption, selected: boolean): StorefrontSwatchOption {\n return {\n value: option.value,\n label: option.label,\n color: option.color ?? null,\n image: option.image ?? null,\n count: option.count,\n meta: null,\n selected,\n disabled: option.disabled,\n soldOut: false,\n reason: null,\n };\n}\n\n/**\n * A single-choice group: category, tag or rating.\n *\n * @param props - The group, its id, the chosen value and the handler.\n * @returns The fieldset.\n */\nfunction ChoiceGroup({\n group,\n groupId,\n value,\n onChoice,\n}: {\n group: StorefrontFilterGroup & { options: StorefrontFilterOption[] };\n groupId: string;\n value: string;\n onChoice: CatalogFiltersProps['onChoice'];\n}): ReactElement {\n const rating = 'rating' === group.type;\n const options: Array<StorefrontFilterOption & { depth?: number }> = [\n {\n value: rating ? '0' : '',\n label: rating ? __('All ratings') : __('All'),\n count: null,\n selected: false,\n disabled: false,\n depth: 0,\n },\n ...group.options,\n ];\n\n return (\n <fieldset\n className=\"apui-radio-group ec-filters__options\"\n id={groupId}\n data-orientation=\"vertical\"\n data-variant=\"default\"\n >\n <legend data-scope=\"radio-group\" data-part=\"label\" className=\"ec-filters__legend\">\n {group.label}\n </legend>\n\n <div data-scope=\"radio-group\" data-part=\"items\">\n {options.map((option, index) => (\n <label\n key={`${groupId}-${option.value}`}\n data-scope=\"radio-group\"\n data-part=\"item\"\n className=\"ec-filters__option\"\n data-depth={Math.min(4, Math.max(0, Math.trunc(option.depth ?? 0)))}\n data-disabled={option.disabled ? '' : undefined}\n >\n <span data-scope=\"radio-group\" data-part=\"box\">\n <input\n type=\"radio\"\n data-scope=\"radio-group\"\n data-part=\"control\"\n id={`${groupId}-${index}`}\n name={groupId}\n value={option.value}\n checked={value === option.value}\n disabled={option.disabled}\n onChange={() => onChoice(group, option.value)}\n />\n <span data-scope=\"radio-group\" data-part=\"indicator\" aria-hidden=\"true\" />\n </span>\n <span data-scope=\"radio-group\" data-part=\"item-text\">\n {option.label}\n </span>\n {null !== option.count ? (\n <span data-scope=\"radio-group\" data-part=\"item-meta\" className=\"ec-filters__count\">\n {option.count}\n </span>\n ) : null}\n </label>\n ))}\n </div>\n </fieldset>\n );\n}\n\n/**\n * The filter groups.\n *\n * @since 1.0.0\n *\n * @param props - The groups, the state and the handlers.\n * @returns The groups.\n */\nexport function CatalogFilters({\n groups,\n state,\n idPrefix,\n onChoice,\n onOption,\n onToggle,\n onPrice,\n}: CatalogFiltersProps): ReactElement {\n const { locale } = useStorefront();\n const control = (group: StorefrontFilterGroup, groupId: string): ReactElement => {\n switch (group.type) {\n case 'category':\n case 'tag':\n case 'rating':\n return (\n <ChoiceGroup\n group={group}\n groupId={groupId}\n value={choiceValue(state, group)}\n onChoice={onChoice}\n />\n );\n\n case 'price':\n return (\n <PriceRange\n range={priceRangeFor(\n {\n ...group,\n from: state.price_min ?? null,\n to: state.price_max ?? null,\n },\n locale,\n )}\n label={group.label}\n idPrefix={groupId}\n onValueChange={(value) => onPrice(group, value)}\n />\n );\n\n case 'attribute':\n case 'custom-options':\n return (\n <Swatches\n name={groupId}\n legend={group.label}\n options={group.options.map((option) =>\n swatchFor(option, optionValues(state, group).includes(option.value)),\n )}\n multiple\n idPrefix={groupId}\n onValueChange={(value, checked) => onOption(group, value, checked)}\n />\n );\n\n default:\n return (\n <Toggle\n id={groupId}\n label={\n null === group.count\n ? group.label\n : __(':label (:count)', { label: group.label, count: group.count })\n }\n size=\"sm\"\n checked={toggleValue(state, group)}\n onCheckedChange={(on) => onToggle(group, on)}\n disabled={group.disabled}\n className=\"ec-filters__toggle\"\n />\n );\n }\n };\n\n return (\n <div className=\"ec-filters\" data-catalog-filters={idPrefix}>\n {groups.map((group) => {\n const groupId = `${idPrefix}-${idFragment(group.key)}`;\n\n return (\n <div key={groupId} className=\"ec-filters__group\" data-filter-group={group.key}>\n {control(group, groupId)}\n </div>\n );\n })}\n </div>\n );\n}\n","/**\n * A product card's quick add, as Livewire's `AddsToCart::quickAdd()`.\n *\n * Posts the product to the listing's `addToCartUrl`. The server answers\n * with a redirect back, a toast, the new cart count, and `cart.open` when\n * `cart.after_add` opens the drawer. The card's button is disabled while\n * its add is on its way.\n *\n * @since 1.0.0\n */\n\nimport type { StorefrontProductCard } from '@artisanpack-ui/ecommerce-storefront-core';\nimport { useState } from 'react';\n\nimport { useStorefrontRouter } from '../internal/storefrontRouter';\n\n/**\n * The quick add state.\n *\n * @since 1.0.0\n */\nexport interface QuickAdd {\n /** The id of the product being added, or null. */\n pending: number | null;\n /** Adds a card's product to the cart. */\n add: (card: StorefrontProductCard) => void;\n}\n\n/**\n * Quick add for a listing.\n *\n * @since 1.0.0\n *\n * @param url - Where the add posts, or null when adding isn't available.\n * @returns The quick add state.\n */\nexport function useQuickAdd(url: string | null): QuickAdd {\n const [pending, setPending] = useState<number | null>(null);\n const visits = useStorefrontRouter();\n\n return {\n pending,\n add: (card) => {\n if (null === url || null !== pending) {\n return;\n }\n\n visits.post(\n url,\n { product_id: card.id },\n {\n preserveScroll: true,\n preserveState: true,\n onStart: () => setPending(card.id),\n onFinish: () => setPending(null),\n },\n );\n },\n };\n}\n","/**\n * `ec-catalog`: a product listing with filters, sorting and paging.\n *\n * Mirrors ecommerce-storefront-livewire's `livewire/catalog/index`. From\n * 1024px the filters sit in a sidebar beside the results; below that a\n * \"Filters (2)\" button opens them in a start-side drawer. The results: the\n * toolbar (the live results count, \"Sort by\" and \"Per page\"), the active\n * filter chips with \"Clear all\", the product cards and the pagination.\n * While a filter, sort or page loads, skeleton cards stand in for the cards\n * and the results are `aria-busy`. With no products: the search's own\n * empty state, the no-match card (\"Clear filters\") or the empty catalog.\n *\n * Every change is an Inertia visit to the listing URL the server's state\n * gives, back on page 1. Filters wait 300ms for more changes, as Livewire's\n * `wire:model.live.debounce.300ms` does; the controls show the shopper's\n * choices meanwhile. Removing a chip or using \"Clear all\" takes the control\n * out of the page, so focus moves on to the chip now in its place (else the\n * one before it), to \"Show N products\" in the drawer, or to the results\n * count, but only when it fell to the page.\n *\n * The search page reuses it with `resultsLabel`, `emptyState` and\n * `browseUrl`.\n *\n * @since 1.0.0\n */\n\nimport {\n __,\n trans_choice,\n type StorefrontCatalogListing,\n type StorefrontFilterGroup,\n type StorefrontListingState,\n type StorefrontProductCard,\n type StorefrontSearchEmptyState,\n} from '@artisanpack-ui/ecommerce-storefront-core';\nimport {\n Button,\n Card,\n Drawer,\n Icon,\n Link,\n Pagination,\n Select,\n Skeleton,\n} from '@artisanpack-ui/react';\nimport { useEffect, useRef, useState, type ReactElement } from 'react';\n\nimport { useStorefrontRouter } from '../internal/storefrontRouter';\nimport { EmptyState } from '../components/EmptyState';\nimport { ProductCard } from '../components/ProductCard';\nimport { CatalogFilters } from './CatalogFilters';\nimport { listingUrl, withChoice, withOption, withPrice, withToggle } from './listingState';\nimport { useQuickAdd } from './useQuickAdd';\n\n/**\n * Props for {@link CatalogListing}.\n *\n * @since 1.0.0\n */\nexport interface CatalogListingProps {\n listing: StorefrontCatalogListing;\n /** The live results count; the product count by default. */\n resultsLabel?: string;\n /** The search's empty state, in place of the catalog's own. */\n emptyState?: StorefrontSearchEmptyState | null;\n /** \"Browse all products\", for the search's empty states. */\n browseUrl?: string | null;\n /** How long filters wait for more changes, in ms. Default 300. */\n debounce?: number;\n /** Shows the loading state (skeleton cards, `aria-busy`) regardless of visits. */\n loading?: boolean;\n}\n\n/** Where focus goes after a change that removes its own control. */\ntype FocusAfter = 'count' | 'apply' | number | null;\n\n/**\n * Compares two states by their URL.\n *\n * @param a - One state.\n * @param b - The other.\n * @returns True when they make the same URL.\n */\nfunction sameState(a: StorefrontListingState, b: StorefrontListingState): boolean {\n return listingUrl('', a) === listingUrl('', b);\n}\n\n/**\n * A product listing.\n *\n * @since 1.0.0\n *\n * @param props - The listing and the search's overrides.\n * @returns The section.\n */\nexport function CatalogListing({\n listing,\n resultsLabel,\n emptyState = null,\n browseUrl = null,\n debounce = 300,\n loading = false,\n}: CatalogListingProps): ReactElement {\n const [draft, setDraft] = useState<StorefrontListingState>(listing.state);\n const [given, setGiven] = useState<StorefrontListingState>(listing.state);\n const [busy, setBusy] = useState(false);\n const [drawerOpen, setDrawerOpen] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const busyTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const focusAfter = useRef<FocusAfter>(null);\n const root = useRef<HTMLElement>(null);\n const filtersButton = useRef<HTMLButtonElement>(null);\n const drawer = useRef<HTMLElement>(null);\n // The design-system Drawer names its panel itself (its `id` prop is\n // replaced), so the Filters button's aria-controls reads the real id.\n const [drawerId, setDrawerId] = useState<string | undefined>(undefined);\n const quickAdd = useQuickAdd(listing.addToCartUrl);\n const visits = useStorefrontRouter();\n\n // The latest draft, for changes that run later than the render they were\n // made in (the price range's debounce): building on a stale draft would\n // drop a choice made in between.\n const latestDraft = useRef(draft);\n\n // A new listing from the server replaces the shopper's pending choices.\n if (!sameState(given, listing.state)) {\n setGiven(listing.state);\n setDraft(listing.state);\n }\n\n useEffect(() => {\n latestDraft.current = draft;\n }, [draft]);\n\n useEffect(\n () => () => {\n clearTimeout(timer.current);\n clearTimeout(busyTimer.current);\n },\n [],\n );\n\n useEffect(() => {\n setDrawerId(drawer.current?.id || undefined);\n }, [drawerOpen]);\n\n // After a change that took its own control away, move focus on.\n useEffect(() => {\n const target = focusAfter.current;\n\n if (null === target || null === root.current) {\n return;\n }\n\n focusAfter.current = null;\n\n if (null !== document.activeElement && document.body !== document.activeElement) {\n return;\n }\n\n const chips = Array.from(root.current.querySelectorAll<HTMLElement>('[data-active-filter]'));\n let next: HTMLElement | null = null;\n\n if ('apply' === target) {\n next = document.querySelector<HTMLElement>('[data-filters-apply]');\n } else if ('number' === typeof target && chips.length > 0) {\n next = chips[Math.min(target, chips.length - 1)] ?? null;\n }\n\n (next ?? root.current.querySelector<HTMLElement>('[data-results-count]'))?.focus();\n }, [listing]);\n\n const visit = (url: string, focus: FocusAfter = null): void => {\n clearTimeout(timer.current);\n focusAfter.current = focus;\n visits.get(\n url,\n {},\n {\n preserveState: true,\n preserveScroll: true,\n onStart: () => {\n clearTimeout(busyTimer.current);\n busyTimer.current = setTimeout(() => setBusy(true), 200);\n },\n onFinish: () => {\n clearTimeout(busyTimer.current);\n setBusy(false);\n },\n },\n );\n };\n\n const change = (next: StorefrontListingState): void => {\n latestDraft.current = next;\n setDraft(next);\n clearTimeout(timer.current);\n timer.current = setTimeout(() => visit(listingUrl(listing.urls.base, next)), debounce);\n };\n\n const filters = {\n onChoice: (group: StorefrontFilterGroup, value: string) =>\n change(withChoice(latestDraft.current, group, value)),\n onOption: (group: StorefrontFilterGroup, value: string, checked: boolean) =>\n change(withOption(latestDraft.current, group, value, checked)),\n onToggle: (group: StorefrontFilterGroup, on: boolean) =>\n change(withToggle(latestDraft.current, group, on)),\n // The price range already waits for the shopper to stop.\n onPrice: (_group: StorefrontFilterGroup, value: { from: number | null; to: number | null }) => {\n const next = withPrice(latestDraft.current, value.from, value.to, listing.currency);\n\n latestDraft.current = next;\n setDraft(next);\n visit(listingUrl(listing.urls.base, next));\n },\n };\n\n const clearFilters = (focus: FocusAfter): void => visit(listing.urls.clear, focus);\n\n const hasFilters = listing.groups.length > 0;\n const activeCount = listing.activeFilters.length;\n const total = listing.total;\n const products = listing.products;\n const headingLevel = null !== listing.heading ? 3 : 2;\n const label =\n resultsLabel ?? trans_choice(':count product|:count products', total, { count: total });\n\n const card = (product: StorefrontProductCard): ReactElement => (\n <ProductCard\n card={{ ...product, headingLevel }}\n onQuickAdd={quickAdd.add}\n quickAddPending={quickAdd.pending === product.id}\n />\n );\n\n const filterGroups = (idPrefix: string): ReactElement => (\n <CatalogFilters groups={listing.groups} state={draft} idPrefix={idPrefix} {...filters} />\n );\n\n return (\n <section\n ref={root}\n className=\"ec-catalog\"\n data-ecommerce-catalog=\"\"\n aria-labelledby={null !== listing.heading ? 'ecommerce-catalog-heading' : undefined}\n aria-label={null === listing.heading ? __('Products') : undefined}\n >\n {null !== listing.heading ? (\n <h2 id=\"ecommerce-catalog-heading\" className=\"ec-catalog__title\">\n {listing.heading}\n </h2>\n ) : null}\n\n <div className=\"ec-catalog__layout\" data-with-filters={hasFilters ? '' : undefined}>\n {hasFilters ? (\n <section\n className=\"ec-catalog__sidebar\"\n aria-labelledby=\"ecommerce-catalog-filters-heading\"\n data-filters-sidebar=\"\"\n >\n <div className=\"ec-catalog__sidebar-header\">\n <h2 id=\"ecommerce-catalog-filters-heading\" className=\"ec-catalog__sidebar-title\">\n {__('Filters')}\n </h2>\n\n {0 !== activeCount ? (\n <Link\n href={listing.urls.clear}\n onClick={(event) => {\n event.preventDefault();\n clearFilters('count');\n }}\n data-sidebar-clear-filters=\"\"\n >\n {__('Clear all')}\n </Link>\n ) : null}\n </div>\n\n {filterGroups('ecommerce-filters-sidebar')}\n </section>\n ) : null}\n\n <div className=\"ec-catalog__main\">\n <div className=\"ec-catalog__toolbar\">\n <p\n className=\"ec-catalog__count\"\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n tabIndex={-1}\n data-results-count=\"\"\n >\n {label}\n </p>\n\n <div className=\"ec-catalog__controls\">\n {hasFilters ? (\n <div className=\"ec-catalog__filters-button\">\n <Button\n ref={filtersButton}\n variant=\"outline\"\n color=\"neutral\"\n size=\"sm\"\n leadingIcon=\"sliders-horizontal\"\n aria-haspopup=\"dialog\"\n aria-controls={drawerId}\n onClick={() => setDrawerOpen(true)}\n data-filters-open=\"\"\n >\n {0 === activeCount\n ? __('Filters')\n : __('Filters (:count)', { count: activeCount })}\n </Button>\n </div>\n ) : null}\n\n {total > 0 ? (\n <>\n <Select\n placeholder=\"\"\n id=\"ecommerce-catalog-sort\"\n label={__('Sort by')}\n options={listing.sorts}\n value={listing.sort}\n onValueChange={(value) =>\n visit(listingUrl(listing.urls.base, { ...draft, sort: String(value) }))\n }\n size=\"sm\"\n className=\"ec-catalog__select ec-catalog__sort\"\n />\n\n <Select\n placeholder=\"\"\n id=\"ecommerce-catalog-per-page\"\n label={__('Per page')}\n options={listing.perPageValues.map((value) => ({\n value: String(value),\n label: String(value),\n }))}\n value={String(listing.perPage)}\n onValueChange={(value) =>\n visit(\n listingUrl(listing.urls.base, {\n ...draft,\n per_page: Number.parseInt(String(value), 10),\n }),\n )\n }\n size=\"sm\"\n className=\"ec-catalog__select ec-catalog__per-page\"\n />\n </>\n ) : null}\n </div>\n </div>\n\n {0 !== activeCount ? (\n <div\n className=\"ec-catalog__chips\"\n role=\"group\"\n aria-label={__('Active filters')}\n data-active-filters=\"\"\n >\n {listing.activeFilters.map((filter, index) => (\n <button\n key={`${filter.group}-${filter.value ?? ''}`}\n type=\"button\"\n className=\"ec-chip\"\n data-variant=\"filter\"\n aria-label={__('Remove filter: :filter', { filter: filter.label })}\n onClick={() => visit(filter.removeUrl, index)}\n data-active-filter={filter.group}\n >\n <span>{filter.label}</span>\n <Icon name=\"x\" className=\"ec-chip__icon\" aria-hidden=\"true\" />\n </button>\n ))}\n\n <Button\n variant=\"ghost\"\n color=\"neutral\"\n size=\"sm\"\n onClick={() => clearFilters('count')}\n data-clear-filters=\"\"\n >\n {__('Clear all')}\n </Button>\n </div>\n ) : null}\n\n {0 === products.length ? (\n null !== emptyState ? (\n <EmptyState\n icon={emptyState.icon}\n title={emptyState.title}\n description={emptyState.description}\n card\n data-empty-reason={emptyState.key}\n >\n {emptyState.tips.length > 0 ? (\n <ul className=\"ec-catalog__tips\" data-search-tips=\"\">\n {emptyState.tips.map((tip) => (\n <li key={tip}>{tip}</li>\n ))}\n </ul>\n ) : null}\n\n {listing.filtered ? (\n <Button color=\"primary\" onClick={() => clearFilters('count')}>\n {__('Clear filters')}\n </Button>\n ) : null}\n\n {('no-results' === emptyState.key || 'unavailable' === emptyState.key) &&\n null !== browseUrl ? (\n <Button variant=\"outline\" color=\"neutral\" href={browseUrl} data-search-browse=\"\">\n {__('Browse all products')}\n </Button>\n ) : null}\n </EmptyState>\n ) : listing.filtered ? (\n <EmptyState\n icon=\"funnel\"\n title={__('No products match your filters')}\n description={__('Try removing a filter or two.')}\n card\n data-empty-reason=\"no-match\"\n >\n <Button\n color=\"primary\"\n onClick={() => clearFilters('count')}\n data-empty-clear-filters=\"\"\n >\n {__('Clear filters')}\n </Button>\n </EmptyState>\n ) : (\n <EmptyState\n icon=\"shopping-bag\"\n title={__('No products to show')}\n description={__('There are no products here yet. Check back soon.')}\n card\n data-empty-reason=\"empty\"\n />\n )\n ) : (\n <>\n <div\n className=\"ec-catalog__results\"\n aria-busy={busy || loading ? 'true' : undefined}\n data-catalog-results=\"\"\n >\n <ul\n role=\"list\"\n className=\"ec-catalog__grid\"\n data-wide={hasFilters ? undefined : ''}\n data-catalog-grid=\"\"\n >\n {products.map((product) => (\n <li key={product.id} className=\"ec-catalog__item\">\n {card(product)}\n </li>\n ))}\n </ul>\n\n <ul\n role=\"list\"\n className=\"ec-catalog__grid ec-catalog__skeleton\"\n data-wide={hasFilters ? undefined : ''}\n aria-hidden=\"true\"\n data-skeleton=\"card\"\n data-catalog-skeleton=\"\"\n >\n {Array.from({ length: Math.min(6, products.length) }, (_, index) => (\n <li key={index} className=\"ec-catalog__item\">\n <Card\n className=\"ec-skeleton-card\"\n media={<Skeleton className=\"ec-skeleton-card__media\" />}\n >\n <Skeleton\n shape=\"text\"\n className=\"ec-skeleton-card__line\"\n data-length=\"medium\"\n />\n <Skeleton\n shape=\"text\"\n className=\"ec-skeleton-card__line\"\n data-length=\"long\"\n />\n <Skeleton\n shape=\"text\"\n className=\"ec-skeleton-card__line\"\n data-length=\"short\"\n />\n <Skeleton className=\"ec-skeleton-card__button\" />\n </Card>\n </li>\n ))}\n </ul>\n </div>\n\n <div className=\"ec-catalog__pagination\">\n <Pagination\n page={listing.pagination.currentPage}\n pageCount={listing.pagination.lastPage}\n total={listing.pagination.total}\n perPage={listing.pagination.perPage}\n summary\n summaryLabel={__('Showing {from} to {to} of {total} results')}\n onPageChange={(page) =>\n visit(\n listingUrl(listing.urls.base, {\n ...listing.state,\n ...(page > 1 ? { page } : {}),\n }),\n )\n }\n />\n </div>\n </>\n )}\n </div>\n </div>\n\n {hasFilters ? (\n <Drawer\n ref={drawer}\n side=\"start\"\n id=\"ecommerce-catalog-filters-drawer\"\n size=\"sm\"\n title={__('Filters')}\n description={\n 0 === activeCount\n ? undefined\n : trans_choice(':count applied|:count applied', activeCount, { count: activeCount })\n }\n closeLabel={__('Close filters')}\n open={drawerOpen}\n onOpenChange={(open) => {\n setDrawerOpen(open);\n\n if (!open) {\n filtersButton.current?.focus();\n }\n }}\n footer={\n <>\n {0 !== activeCount ? (\n <Button\n variant=\"ghost\"\n color=\"neutral\"\n onClick={() => clearFilters('apply')}\n data-drawer-clear-filters=\"\"\n >\n {__('Clear all')}\n </Button>\n ) : null}\n\n <Button\n color=\"primary\"\n onClick={() => {\n setDrawerOpen(false);\n filtersButton.current?.focus();\n }}\n data-filters-apply=\"\"\n >\n {trans_choice('Show :count product|Show :count products', total, { count: total })}\n </Button>\n </>\n }\n data-filters-drawer=\"\"\n >\n {filterGroups('ecommerce-filters-drawer')}\n </Drawer>\n ) : null}\n </section>\n );\n}\n","/**\n * The storefront's breadcrumbs: the design-system Breadcrumbs with plain\n * links, as Livewire's `navigate=\"false\"`.\n *\n * @since 1.0.0\n */\n\nimport { __, type StorefrontBreadcrumb } from '@artisanpack-ui/ecommerce-storefront-core';\nimport { Breadcrumbs } from '@artisanpack-ui/react';\nimport type { ReactElement } from 'react';\n\n/**\n * Props for {@link StorefrontBreadcrumbs}.\n *\n * @since 1.0.0\n */\nexport interface StorefrontBreadcrumbsProps {\n /** The trail; the current page's has no URL. */\n items: StorefrontBreadcrumb[];\n}\n\n/**\n * Breadcrumbs.\n *\n * @since 1.0.0\n *\n * @param props - The trail.\n * @returns The breadcrumbs.\n */\nexport function StorefrontBreadcrumbs({ items }: StorefrontBreadcrumbsProps): ReactElement {\n return (\n <Breadcrumbs\n items={items.map((item) => ({ label: item.label, href: item.url ?? undefined }))}\n label={__('Breadcrumb')}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAaA,SAAS,UAAqC;AAC9C,SAAS,OAAO,aAAa;AAC7B,SAAS,WAAW,QAAQ,gBAAmC;AAgJ3D,cAmDE,YAnDF;AAxGG,SAAS,WAAW;AAAA,EACzB;AAAA,EACA,QAAQ;AAAA,EACR,WAAW;AAAA,EACX;AAAA,EACA,WAAW;AAAA,EACX;AACF,GAAkC;AAChC,QAAM,EAAE,KAAK,KAAK,MAAM,SAAS,UAAU,UAAU,OAAO,IAAI;AAChE,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA0B,EAAE,MAAM,MAAM,MAAM,IAAI,MAAM,GAAG,CAAC;AACxF,QAAM,QAAQ,OAAkD,MAAS;AACzE,QAAM,OAAO,OAA4B,IAAI;AAG7C,QAAM,sBAAsB,OAAO,aAAa;AAEhD,YAAU,MAAM;AACd,wBAAoB,UAAU;AAAA,EAChC,CAAC;AACD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAqD;AAAA,IAC7E,MAAM;AAAA,I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,EAAE,OAAO,MAAM,CAAC;AAAA;AAAA,cACnF;AAAA,eACF;AAAA,YAEF,uBAAoB;AAAA,YAEnB,uBAAa,0BAA0B;AAAA;AAAA,QAC1C,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;;;AC3jBA,SAAS,MAAAM,WAAqC;AAC9C,SAAS,mBAAmB;AAuBxB,gBAAAC,YAAA;AAFG,SAAS,sBAAsB,EAAE,MAAM,GAA6C;AACzF,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,MAAM,IAAI,CAAC,UAAU,EAAE,OAAO,KAAK,OAAO,MAAM,KAAK,OAAO,OAAU,EAAE;AAAA,MAC/E,OAAOD,IAAG,YAAY;AAAA;AAAA,EACxB;AAEJ;","names":["__","jsx","jsxs","__","useState","useState","__","useEffect","useRef","useState","jsx","jsxs","useState","useRef","useEffect","__","__","jsx"]}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProductCard
|
|
3
|
+
} from "./chunk-ABGPTZ3Q.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useStorefrontRouter
|
|
6
|
+
} from "./chunk-TPOKMH5E.mjs";
|
|
7
|
+
import {
|
|
8
|
+
StorefrontPageContext,
|
|
9
|
+
cartWriteOnly,
|
|
10
|
+
useStorefront,
|
|
11
|
+
useStorefrontPage
|
|
12
|
+
} from "./chunk-VX5TEJNU.mjs";
|
|
13
|
+
|
|
14
|
+
// src/product/sections/RelatedProducts.tsx
|
|
15
|
+
import {
|
|
16
|
+
__
|
|
17
|
+
} from "@artisanpack-ui/ecommerce-storefront-core";
|
|
18
|
+
import { Button, Card, Skeleton as Bone } from "@artisanpack-ui/react";
|
|
19
|
+
import { Deferred } from "@inertiajs/react";
|
|
20
|
+
import { useContext, useRef, useState } from "react";
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
function relatedHeading(type, onCart) {
|
|
23
|
+
if ("upsell" === type) {
|
|
24
|
+
return __("You may also like");
|
|
25
|
+
}
|
|
26
|
+
if ("cross_sell" === type) {
|
|
27
|
+
return onCart ? __("Complete your order") : __("Frequently bought together");
|
|
28
|
+
}
|
|
29
|
+
return __("Related products");
|
|
30
|
+
}
|
|
31
|
+
function RelatedProducts({
|
|
32
|
+
sectionKey,
|
|
33
|
+
type,
|
|
34
|
+
heading = null,
|
|
35
|
+
limit = null,
|
|
36
|
+
addToCartUrl
|
|
37
|
+
}) {
|
|
38
|
+
const { component, props } = useStorefrontPage();
|
|
39
|
+
const inBlock = null !== useContext(StorefrontPageContext);
|
|
40
|
+
const title = null !== heading && "" !== heading.trim() ? heading : relatedHeading(type, "EcommerceStorefront/Cart/Index" === component);
|
|
41
|
+
if (inBlock && void 0 !== props.relatedProducts) {
|
|
42
|
+
return /* @__PURE__ */ jsx(RelatedProductsLoaded, { sectionKey, addToCartUrl });
|
|
43
|
+
}
|
|
44
|
+
return /* @__PURE__ */ jsx(
|
|
45
|
+
Deferred,
|
|
46
|
+
{
|
|
47
|
+
data: "relatedProducts",
|
|
48
|
+
fallback: /* @__PURE__ */ jsx(RelatedProductsPlaceholder, { title, count: limit ?? 4 }),
|
|
49
|
+
children: /* @__PURE__ */ jsx(RelatedProductsLoaded, { sectionKey, addToCartUrl })
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
function RelatedProductsLoaded({
|
|
54
|
+
sectionKey,
|
|
55
|
+
addToCartUrl
|
|
56
|
+
}) {
|
|
57
|
+
const all = useStorefrontPage().props.relatedProducts;
|
|
58
|
+
const related = all?.[sectionKey];
|
|
59
|
+
return null === related || void 0 === related ? /* @__PURE__ */ jsx("div", { "data-related-products": "" }) : /* @__PURE__ */ jsx(RelatedProductsRow, { related, addToCartUrl });
|
|
60
|
+
}
|
|
61
|
+
function RelatedProductsRow({
|
|
62
|
+
related,
|
|
63
|
+
addToCartUrl
|
|
64
|
+
}) {
|
|
65
|
+
const { routes } = useStorefront();
|
|
66
|
+
const page = useStorefrontPage();
|
|
67
|
+
const component = page.component;
|
|
68
|
+
const product = page.props.product;
|
|
69
|
+
const list = useRef(null);
|
|
70
|
+
const [pending, setPending] = useState(null);
|
|
71
|
+
const visits = useStorefrontRouter();
|
|
72
|
+
const headingId = `ec-related-${related.type}-${product?.id ?? "cart"}`;
|
|
73
|
+
const quickAddUrl = addToCartUrl ?? (null === routes.storefront.base ? null : `${routes.storefront.base.replace(/\/$/, "")}/cart/add`);
|
|
74
|
+
const scrollBy = (direction) => {
|
|
75
|
+
const element = list.current;
|
|
76
|
+
if (null === element) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const sign = "rtl" === getComputedStyle(element).direction ? -1 : 1;
|
|
80
|
+
const reduce = "function" === typeof window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
81
|
+
element.scrollBy?.({
|
|
82
|
+
left: sign * direction * element.clientWidth * 0.8,
|
|
83
|
+
behavior: reduce ? "auto" : "smooth"
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
const quickAdd = (card) => {
|
|
87
|
+
if (null === quickAddUrl) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
visits.post(
|
|
91
|
+
quickAddUrl,
|
|
92
|
+
{ product_id: card.id, quantity: 1 },
|
|
93
|
+
{
|
|
94
|
+
errorBag: "quickAdd",
|
|
95
|
+
// On the cart page the cross-sell's add reloads the cart page's props too.
|
|
96
|
+
only: cartWriteOnly(component),
|
|
97
|
+
preserveScroll: true,
|
|
98
|
+
preserveState: true,
|
|
99
|
+
onStart: () => setPending(card.id),
|
|
100
|
+
onFinish: () => setPending(null)
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
return /* @__PURE__ */ jsx("div", { "data-related-products": related.type, children: related.products.length > 0 ? /* @__PURE__ */ jsxs("section", { className: "ec-related", "aria-labelledby": headingId, children: [
|
|
105
|
+
/* @__PURE__ */ jsxs("div", { className: "ec-related__header", children: [
|
|
106
|
+
/* @__PURE__ */ jsx("h2", { id: headingId, className: "ec-related__title", children: related.title }),
|
|
107
|
+
related.products.length > 1 ? /* @__PURE__ */ jsxs("div", { className: "ec-related__controls", children: [
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
Button,
|
|
110
|
+
{
|
|
111
|
+
variant: "outline",
|
|
112
|
+
color: "neutral",
|
|
113
|
+
size: "sm",
|
|
114
|
+
iconOnly: true,
|
|
115
|
+
leadingIcon: "chevron-left",
|
|
116
|
+
className: "ec-related__control",
|
|
117
|
+
"aria-label": __("Previous products"),
|
|
118
|
+
"aria-controls": `${headingId}-list`,
|
|
119
|
+
onClick: () => scrollBy(-1),
|
|
120
|
+
"data-related-previous": ""
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ jsx(
|
|
124
|
+
Button,
|
|
125
|
+
{
|
|
126
|
+
variant: "outline",
|
|
127
|
+
color: "neutral",
|
|
128
|
+
size: "sm",
|
|
129
|
+
iconOnly: true,
|
|
130
|
+
leadingIcon: "chevron-right",
|
|
131
|
+
className: "ec-related__control",
|
|
132
|
+
"aria-label": __("Next products"),
|
|
133
|
+
"aria-controls": `${headingId}-list`,
|
|
134
|
+
onClick: () => scrollBy(1),
|
|
135
|
+
"data-related-next": ""
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
] }) : null
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ jsx(
|
|
141
|
+
"ul",
|
|
142
|
+
{
|
|
143
|
+
id: `${headingId}-list`,
|
|
144
|
+
ref: list,
|
|
145
|
+
role: "list",
|
|
146
|
+
className: "ec-related__list",
|
|
147
|
+
"data-columns": related.columns,
|
|
148
|
+
"aria-labelledby": headingId,
|
|
149
|
+
"data-related-list": "",
|
|
150
|
+
children: related.products.map((card) => /* @__PURE__ */ jsx("li", { className: "ec-related__item", children: /* @__PURE__ */ jsx(
|
|
151
|
+
ProductCard,
|
|
152
|
+
{
|
|
153
|
+
card,
|
|
154
|
+
onQuickAdd: null === quickAddUrl ? void 0 : quickAdd,
|
|
155
|
+
quickAddPending: pending === card.id
|
|
156
|
+
}
|
|
157
|
+
) }, card.id))
|
|
158
|
+
}
|
|
159
|
+
)
|
|
160
|
+
] }) : null });
|
|
161
|
+
}
|
|
162
|
+
function RelatedProductsPlaceholder({
|
|
163
|
+
title,
|
|
164
|
+
count = 4
|
|
165
|
+
}) {
|
|
166
|
+
const cards = Math.max(1, Math.min(4, Math.trunc(count)));
|
|
167
|
+
return /* @__PURE__ */ jsx("div", { "data-related-placeholder": "", children: /* @__PURE__ */ jsxs("section", { className: "ec-suggestions", children: [
|
|
168
|
+
/* @__PURE__ */ jsx("h2", { className: "ec-suggestions__title", children: title }),
|
|
169
|
+
/* @__PURE__ */ jsx("span", { className: "apui-sr-only", role: "status", children: __("Loading suggestions\u2026") }),
|
|
170
|
+
/* @__PURE__ */ jsx(
|
|
171
|
+
"ul",
|
|
172
|
+
{
|
|
173
|
+
className: "ec-suggestions__grid",
|
|
174
|
+
"data-columns": cards,
|
|
175
|
+
"aria-busy": "true",
|
|
176
|
+
"data-skeleton": "card",
|
|
177
|
+
children: Array.from({ length: cards }, (_, index) => /* @__PURE__ */ jsx("li", { className: "ec-suggestions__item", "aria-hidden": "true", children: /* @__PURE__ */ jsxs(
|
|
178
|
+
Card,
|
|
179
|
+
{
|
|
180
|
+
className: "ec-skeleton-card",
|
|
181
|
+
media: /* @__PURE__ */ jsx(Bone, { className: "ec-skeleton-card__media" }),
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsx(Bone, { shape: "text", className: "ec-skeleton-card__line", "data-length": "medium" }),
|
|
184
|
+
/* @__PURE__ */ jsx(Bone, { shape: "text", className: "ec-skeleton-card__line", "data-length": "long" }),
|
|
185
|
+
/* @__PURE__ */ jsx(Bone, { shape: "text", className: "ec-skeleton-card__line", "data-length": "short" }),
|
|
186
|
+
/* @__PURE__ */ jsx(Bone, { className: "ec-skeleton-card__button" })
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
) }, index))
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] }) });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export {
|
|
196
|
+
relatedHeading,
|
|
197
|
+
RelatedProducts,
|
|
198
|
+
RelatedProductsRow,
|
|
199
|
+
RelatedProductsPlaceholder
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=chunk-PEBBSZ5R.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/product/sections/RelatedProducts.tsx"],"sourcesContent":["/**\n * The `related-products` section: upsells and related products on the\n * product page, the cart's cross-sells below the cart.\n *\n * Mirrors ecommerce-storefront-livewire's `livewire/product/related-products`\n * (a scrolling row of product cards with previous and next buttons) and its\n * lazy placeholder. The suggestions arrive in the page's deferred\n * `relatedProducts` prop (group `related`), keyed by the section's key, so\n * the placeholder shows until Inertia has fetched them.\n *\n * @since 1.0.0\n */\n\nimport {\n __,\n type StorefrontProductCard,\n type StorefrontRelatedProducts,\n} from '@artisanpack-ui/ecommerce-storefront-core';\nimport { Button, Card, Skeleton as Bone } from '@artisanpack-ui/react';\nimport { Deferred } from '@inertiajs/react';\nimport { useContext, useRef, useState, type ReactElement } from 'react';\n\nimport { useStorefrontRouter } from '../../internal/storefrontRouter';\nimport { cartWriteOnly } from '../../cart/cartRoutes';\nimport { ProductCard } from '../../components/ProductCard';\nimport { StorefrontPageContext } from '../../internal/pageContext';\nimport { useStorefront, useStorefrontPage } from '../../useStorefront';\n\n/**\n * Props for {@link RelatedProducts}.\n *\n * @since 1.0.0\n */\nexport interface RelatedProductsProps {\n /** The section's key: its suggestions are `relatedProducts[sectionKey]`. */\n sectionKey: string;\n /** `related`, `upsell` or `cross_sell`. */\n type?: string;\n /** A heading in place of the type's. */\n heading?: string | null;\n /** Placeholder cards while loading (1–4). */\n limit?: number | null;\n /**\n * Columns from the section's params. The server applies them to the\n * suggestions (`related.columns`), which the row reads, so the section\n * itself doesn't need them.\n */\n columns?: number | null;\n /** Where a card's \"Add to cart\" posts; defaults to the storefront's `cart/add`. */\n addToCartUrl?: string | null;\n}\n\n/**\n * The heading a related-products section shows before its suggestions load.\n *\n * @since 1.0.0\n *\n * @param type - The suggestion type.\n * @param onCart - Whether the section is below the cart.\n * @returns The heading.\n */\nexport function relatedHeading(type: string | undefined, onCart: boolean): string {\n if ('upsell' === type) {\n return __('You may also like');\n }\n\n if ('cross_sell' === type) {\n return onCart ? __('Complete your order') : __('Frequently bought together');\n }\n\n return __('Related products');\n}\n\n/**\n * The related-products section.\n *\n * @since 1.0.0\n *\n * @param props - The section's key and params.\n * @returns The section.\n */\nexport function RelatedProducts({\n sectionKey,\n type,\n heading = null,\n limit = null,\n addToCartUrl,\n}: RelatedProductsProps): ReactElement {\n const { component, props } = useStorefrontPage();\n const inBlock = null !== useContext(StorefrontPageContext);\n const title =\n null !== heading && '' !== heading.trim()\n ? heading\n : relatedHeading(type, 'EcommerceStorefront/Cart/Index' === component);\n\n // A Single Product block's props carry the suggestions straight away, and\n // Inertia's <Deferred> would read the host page's props instead.\n if (inBlock && undefined !== props.relatedProducts) {\n return <RelatedProductsLoaded sectionKey={sectionKey} addToCartUrl={addToCartUrl} />;\n }\n\n return (\n <Deferred\n data=\"relatedProducts\"\n fallback={<RelatedProductsPlaceholder title={title} count={limit ?? 4} />}\n >\n <RelatedProductsLoaded sectionKey={sectionKey} addToCartUrl={addToCartUrl} />\n </Deferred>\n );\n}\n\n/**\n * The section once `relatedProducts` has arrived.\n *\n * @param props - The section's key and the quick add URL.\n * @returns The row, or its empty root.\n */\nfunction RelatedProductsLoaded({\n sectionKey,\n addToCartUrl,\n}: Pick<RelatedProductsProps, 'sectionKey' | 'addToCartUrl'>): ReactElement {\n const all = useStorefrontPage().props.relatedProducts as\n Record<string, StorefrontRelatedProducts> | undefined;\n const related = all?.[sectionKey];\n\n return null === related || undefined === related ? (\n <div data-related-products=\"\" />\n ) : (\n <RelatedProductsRow related={related} addToCartUrl={addToCartUrl} />\n );\n}\n\n/**\n * Props for {@link RelatedProductsRow}.\n *\n * @since 1.0.0\n */\nexport interface RelatedProductsRowProps {\n /** The suggestions. */\n related: StorefrontRelatedProducts;\n /** Where a card's \"Add to cart\" posts. */\n addToCartUrl?: string | null;\n}\n\n/**\n * A row of suggestions (also the Related Products block).\n *\n * @since 1.0.0\n *\n * @param props - The suggestions.\n * @returns The row.\n */\nexport function RelatedProductsRow({\n related,\n addToCartUrl,\n}: RelatedProductsRowProps): ReactElement {\n const { routes } = useStorefront();\n const page = useStorefrontPage();\n const component = page.component;\n const product = page.props.product as { id?: number } | null | undefined;\n const list = useRef<HTMLUListElement>(null);\n const [pending, setPending] = useState<number | null>(null);\n const visits = useStorefrontRouter();\n const headingId = `ec-related-${related.type}-${product?.id ?? 'cart'}`;\n const quickAddUrl =\n addToCartUrl ??\n (null === routes.storefront.base\n ? null\n : `${routes.storefront.base.replace(/\\/$/, '')}/cart/add`);\n\n const scrollBy = (direction: -1 | 1): void => {\n const element = list.current;\n\n if (null === element) {\n return;\n }\n\n const sign = 'rtl' === getComputedStyle(element).direction ? -1 : 1;\n const reduce =\n 'function' === typeof window.matchMedia &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\n element.scrollBy?.({\n left: sign * direction * element.clientWidth * 0.8,\n behavior: reduce ? 'auto' : 'smooth',\n });\n };\n\n const quickAdd = (card: StorefrontProductCard): void => {\n if (null === quickAddUrl) {\n return;\n }\n\n visits.post(\n quickAddUrl,\n { product_id: card.id, quantity: 1 },\n {\n errorBag: 'quickAdd',\n // On the cart page the cross-sell's add reloads the cart page's props too.\n only: cartWriteOnly(component),\n preserveScroll: true,\n preserveState: true,\n onStart: () => setPending(card.id),\n onFinish: () => setPending(null),\n },\n );\n };\n\n return (\n <div data-related-products={related.type}>\n {related.products.length > 0 ? (\n <section className=\"ec-related\" aria-labelledby={headingId}>\n <div className=\"ec-related__header\">\n <h2 id={headingId} className=\"ec-related__title\">\n {related.title}\n </h2>\n\n {related.products.length > 1 ? (\n <div className=\"ec-related__controls\">\n <Button\n variant=\"outline\"\n color=\"neutral\"\n size=\"sm\"\n iconOnly\n leadingIcon=\"chevron-left\"\n className=\"ec-related__control\"\n aria-label={__('Previous products')}\n aria-controls={`${headingId}-list`}\n onClick={() => scrollBy(-1)}\n data-related-previous=\"\"\n />\n <Button\n variant=\"outline\"\n color=\"neutral\"\n size=\"sm\"\n iconOnly\n leadingIcon=\"chevron-right\"\n className=\"ec-related__control\"\n aria-label={__('Next products')}\n aria-controls={`${headingId}-list`}\n onClick={() => scrollBy(1)}\n data-related-next=\"\"\n />\n </div>\n ) : null}\n </div>\n\n <ul\n id={`${headingId}-list`}\n ref={list}\n role=\"list\"\n className=\"ec-related__list\"\n data-columns={related.columns}\n aria-labelledby={headingId}\n data-related-list=\"\"\n >\n {related.products.map((card) => (\n <li key={card.id} className=\"ec-related__item\">\n <ProductCard\n card={card}\n onQuickAdd={null === quickAddUrl ? undefined : quickAdd}\n quickAddPending={pending === card.id}\n />\n </li>\n ))}\n </ul>\n </section>\n ) : null}\n </div>\n );\n}\n\n/**\n * Props for {@link RelatedProductsPlaceholder}.\n *\n * @since 1.0.0\n */\nexport interface RelatedProductsPlaceholderProps {\n /** The section's heading. */\n title: string;\n /** Skeleton cards (1–4). */\n count?: number;\n}\n\n/**\n * The skeleton row shown while the suggestions load.\n *\n * @since 1.0.0\n *\n * @param props - The heading and the number of cards.\n * @returns The placeholder.\n */\nexport function RelatedProductsPlaceholder({\n title,\n count = 4,\n}: RelatedProductsPlaceholderProps): ReactElement {\n const cards = Math.max(1, Math.min(4, Math.trunc(count)));\n\n return (\n <div data-related-placeholder=\"\">\n <section className=\"ec-suggestions\">\n <h2 className=\"ec-suggestions__title\">{title}</h2>\n\n <span className=\"apui-sr-only\" role=\"status\">\n {__('Loading suggestions…')}\n </span>\n\n <ul\n className=\"ec-suggestions__grid\"\n data-columns={cards}\n aria-busy=\"true\"\n data-skeleton=\"card\"\n >\n {Array.from({ length: cards }, (_, index) => (\n <li key={index} className=\"ec-suggestions__item\" aria-hidden=\"true\">\n <Card\n className=\"ec-skeleton-card\"\n media={<Bone className=\"ec-skeleton-card__media\" />}\n >\n <Bone shape=\"text\" className=\"ec-skeleton-card__line\" data-length=\"medium\" />\n <Bone shape=\"text\" className=\"ec-skeleton-card__line\" data-length=\"long\" />\n <Bone shape=\"text\" className=\"ec-skeleton-card__line\" data-length=\"short\" />\n <Bone className=\"ec-skeleton-card__button\" />\n </Card>\n </li>\n ))}\n </ul>\n </section>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,QAAQ,MAAM,YAAY,YAAY;AAC/C,SAAS,gBAAgB;AACzB,SAAS,YAAY,QAAQ,gBAAmC;AA8ErD,cAwHG,YAxHH;AArCJ,SAAS,eAAe,MAA0B,QAAyB;AAChF,MAAI,aAAa,MAAM;AACrB,WAAO,GAAG,mBAAmB;AAAA,EAC/B;AAEA,MAAI,iBAAiB,MAAM;AACzB,WAAO,SAAS,GAAG,qBAAqB,IAAI,GAAG,4BAA4B;AAAA,EAC7E;AAEA,SAAO,GAAG,kBAAkB;AAC9B;AAUO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AAAA,EACR;AACF,GAAuC;AACrC,QAAM,EAAE,WAAW,MAAM,IAAI,kBAAkB;AAC/C,QAAM,UAAU,SAAS,WAAW,qBAAqB;AACzD,QAAM,QACJ,SAAS,WAAW,OAAO,QAAQ,KAAK,IACpC,UACA,eAAe,MAAM,qCAAqC,SAAS;AAIzE,MAAI,WAAW,WAAc,MAAM,iBAAiB;AAClD,WAAO,oBAAC,yBAAsB,YAAwB,cAA4B;AAAA,EACpF;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU,oBAAC,8BAA2B,OAAc,OAAO,SAAS,GAA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,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Money
|
|
3
|
+
} from "./chunk-VX5TEJNU.mjs";
|
|
4
|
+
|
|
5
|
+
// src/cart/OrderTotals.tsx
|
|
6
|
+
import {
|
|
7
|
+
__
|
|
8
|
+
} from "@artisanpack-ui/ecommerce-storefront-core";
|
|
9
|
+
import { Divider } from "@artisanpack-ui/react";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
function unsigned(money) {
|
|
12
|
+
return { ...money, negative: false, formatted: money.magnitude ?? money.formatted };
|
|
13
|
+
}
|
|
14
|
+
function OrderTotals({
|
|
15
|
+
totals,
|
|
16
|
+
shippingPending = null,
|
|
17
|
+
taxPending = null
|
|
18
|
+
}) {
|
|
19
|
+
const { shipping, tax } = totals;
|
|
20
|
+
const calculatedAtCheckout = __("Calculated at checkout");
|
|
21
|
+
const refunded = "refunded" in totals ? totals.refunded : null;
|
|
22
|
+
return /* @__PURE__ */ jsxs("div", { className: "ec-totals", "data-cart-totals": "", children: [
|
|
23
|
+
/* @__PURE__ */ jsxs("dl", { className: "ec-totals__list", children: [
|
|
24
|
+
/* @__PURE__ */ jsxs("div", { className: "ec-totals__row", children: [
|
|
25
|
+
/* @__PURE__ */ jsx("dt", { children: __("Subtotal") }),
|
|
26
|
+
/* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(Money, { money: totals.subtotal, "data-cart-subtotal": "" }) })
|
|
27
|
+
] }),
|
|
28
|
+
totals.discounts.map((discount, index) => /* @__PURE__ */ jsxs("div", { className: "ec-totals__row", "data-cart-discount": "", children: [
|
|
29
|
+
/* @__PURE__ */ jsx("dt", { children: discount.label }),
|
|
30
|
+
/* @__PURE__ */ jsx("dd", { className: "ec-totals__discount", children: (discount.amount.amount ?? 0) !== 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
/* @__PURE__ */ jsx("span", { className: "apui-sr-only", children: __("Minus") }),
|
|
32
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2212" }),
|
|
33
|
+
/* @__PURE__ */ jsx(Money, { money: unsigned(discount.amount) })
|
|
34
|
+
] }) : __("Free shipping") })
|
|
35
|
+
] }, `${discount.label}-${index}`)),
|
|
36
|
+
"none" !== shipping.state ? /* @__PURE__ */ jsxs("div", { className: "ec-totals__row", "data-cart-shipping": shipping.state, children: [
|
|
37
|
+
/* @__PURE__ */ jsxs("dt", { children: [
|
|
38
|
+
__("Shipping"),
|
|
39
|
+
"chosen" === shipping.state && null !== shipping.label && "" !== shipping.label ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
40
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
41
|
+
/* @__PURE__ */ jsx("span", { className: "apui-sr-only", children: ", " }),
|
|
42
|
+
/* @__PURE__ */ jsx("span", { "data-cart-shipping-method": "", children: shipping.label })
|
|
43
|
+
] }) : null
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ jsx("dd", { children: "chosen" === shipping.state ? /* @__PURE__ */ jsx(Money, { money: shipping.amount }) : "free" === shipping.state ? __("Free") : /* @__PURE__ */ jsx("span", { className: "ec-totals__pending", children: shippingPending ?? calculatedAtCheckout }) })
|
|
46
|
+
] }) : null,
|
|
47
|
+
/* @__PURE__ */ jsxs("div", { className: "ec-totals__row", "data-cart-tax": tax.estimated ? "estimated" : "calculated", children: [
|
|
48
|
+
/* @__PURE__ */ jsx("dt", { children: tax.inclusive ? tax.estimated ? __("Included tax (estimated)") : __("Included tax") : tax.estimated ? __("Tax (estimated)") : __("Tax") }),
|
|
49
|
+
/* @__PURE__ */ jsx("dd", { children: tax.estimated && 0 === (tax.amount.amount ?? 0) ? /* @__PURE__ */ jsx("span", { className: "ec-totals__pending", children: taxPending ?? calculatedAtCheckout }) : /* @__PURE__ */ jsx(Money, { money: tax.amount }) })
|
|
50
|
+
] })
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ jsx(Divider, { decorative: true }),
|
|
53
|
+
/* @__PURE__ */ jsxs("dl", { className: "ec-totals__list", children: [
|
|
54
|
+
/* @__PURE__ */ jsxs("div", { className: "ec-totals__row ec-totals__total", children: [
|
|
55
|
+
/* @__PURE__ */ jsx("dt", { children: __("Total") }),
|
|
56
|
+
/* @__PURE__ */ jsx("dd", { children: /* @__PURE__ */ jsx(Money, { money: totals.total, "data-cart-total": "" }) })
|
|
57
|
+
] }),
|
|
58
|
+
null !== refunded && (refunded.amount ?? 0) > 0 ? /* @__PURE__ */ jsxs("div", { className: "ec-totals__row", "data-order-refunded": "", children: [
|
|
59
|
+
/* @__PURE__ */ jsx("dt", { children: __("Refunded") }),
|
|
60
|
+
/* @__PURE__ */ jsxs("dd", { children: [
|
|
61
|
+
/* @__PURE__ */ jsx("span", { className: "apui-sr-only", children: __("Minus") }),
|
|
62
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2212" }),
|
|
63
|
+
/* @__PURE__ */ jsx(Money, { money: unsigned(refunded) })
|
|
64
|
+
] })
|
|
65
|
+
] }) : null
|
|
66
|
+
] })
|
|
67
|
+
] });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
OrderTotals
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=chunk-T5OWL6EG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cart/OrderTotals.tsx"],"sourcesContent":["/**\n * An order summary's totals: subtotal, each discount, shipping, tax, then a\n * divider and the total.\n *\n * Mirrors ecommerce-storefront-livewire's `partials/order-totals`. Labels\n * are muted and values sit at the end; a discount reads after a true minus\n * (announced as \"Minus\"). A `<dl>` can't hold an `<hr>`, so the rows and the\n * total are two lists either side of the divider. The cart page, the\n * checkout summary and a placed order's summary share it; a placed order's\n * refunds follow the total.\n *\n * @since 1.0.0\n */\n\nimport {\n __,\n type StorefrontCartTotals,\n type StorefrontMoney,\n type StorefrontOrderTotals,\n} from '@artisanpack-ui/ecommerce-storefront-core';\nimport { Divider } from '@artisanpack-ui/react';\nimport type { ReactElement } from 'react';\n\nimport { Money } from '../components/Money';\n\n/**\n * Props for {@link OrderTotals}.\n *\n * @since 1.0.0\n */\nexport interface OrderTotalsProps {\n /** A cart's totals, or a placed order's (which may carry `refunded`). */\n totals: StorefrontCartTotals | StorefrontOrderTotals;\n /** Replaces \"Calculated at checkout\" for a shipping cost that isn't known yet. */\n shippingPending?: string | null;\n /** Replaces \"Calculated at checkout\" for tax that isn't known yet. */\n taxPending?: string | null;\n}\n\n/**\n * A positive amount: discounts come signed or not, and the minus is drawn here.\n *\n * @param money - The amount.\n * @returns The amount without its sign.\n */\nfunction unsigned(money: StorefrontMoney): StorefrontMoney {\n return { ...money, negative: false, formatted: money.magnitude ?? money.formatted };\n}\n\n/**\n * The totals.\n *\n * @since 1.0.0\n *\n * @param props - The totals and the pending texts.\n * @returns The totals.\n */\nexport function OrderTotals({\n totals,\n shippingPending = null,\n taxPending = null,\n}: OrderTotalsProps): ReactElement {\n const { shipping, tax } = totals;\n const calculatedAtCheckout = __('Calculated at checkout');\n const refunded = 'refunded' in totals ? totals.refunded : null;\n\n return (\n <div className=\"ec-totals\" data-cart-totals=\"\">\n <dl className=\"ec-totals__list\">\n <div className=\"ec-totals__row\">\n <dt>{__('Subtotal')}</dt>\n <dd>\n <Money money={totals.subtotal} data-cart-subtotal=\"\" />\n </dd>\n </div>\n\n {totals.discounts.map((discount, index) => (\n <div className=\"ec-totals__row\" data-cart-discount=\"\" key={`${discount.label}-${index}`}>\n <dt>{discount.label}</dt>\n <dd className=\"ec-totals__discount\">\n {(discount.amount.amount ?? 0) !== 0 ? (\n <>\n <span className=\"apui-sr-only\">{__('Minus')}</span>\n <span aria-hidden=\"true\">−</span>\n <Money money={unsigned(discount.amount)} />\n </>\n ) : (\n __('Free shipping')\n )}\n </dd>\n </div>\n ))}\n\n {'none' !== shipping.state ? (\n <div className=\"ec-totals__row\" data-cart-shipping={shipping.state}>\n <dt>\n {__('Shipping')}\n {'chosen' === shipping.state && null !== shipping.label && '' !== shipping.label ? (\n <>\n <span aria-hidden=\"true\"> · </span>\n <span className=\"apui-sr-only\">, </span>\n <span data-cart-shipping-method=\"\">{shipping.label}</span>\n </>\n ) : null}\n </dt>\n <dd>\n {'chosen' === shipping.state ? (\n <Money money={shipping.amount} />\n ) : 'free' === shipping.state ? (\n __('Free')\n ) : (\n <span className=\"ec-totals__pending\">\n {shippingPending ?? calculatedAtCheckout}\n </span>\n )}\n </dd>\n </div>\n ) : null}\n\n <div className=\"ec-totals__row\" data-cart-tax={tax.estimated ? 'estimated' : 'calculated'}>\n <dt>\n {tax.inclusive\n ? tax.estimated\n ? __('Included tax (estimated)')\n : __('Included tax')\n : tax.estimated\n ? __('Tax (estimated)')\n : __('Tax')}\n </dt>\n <dd>\n {tax.estimated && 0 === (tax.amount.amount ?? 0) ? (\n <span className=\"ec-totals__pending\">{taxPending ?? calculatedAtCheckout}</span>\n ) : (\n <Money money={tax.amount} />\n )}\n </dd>\n </div>\n </dl>\n\n <Divider decorative />\n\n <dl className=\"ec-totals__list\">\n <div className=\"ec-totals__row ec-totals__total\">\n <dt>{__('Total')}</dt>\n <dd>\n <Money money={totals.total} data-cart-total=\"\" />\n </dd>\n </div>\n\n {null !== refunded && (refunded.amount ?? 0) > 0 ? (\n <div className=\"ec-totals__row\" data-order-refunded=\"\">\n <dt>{__('Refunded')}</dt>\n <dd>\n <span className=\"apui-sr-only\">{__('Minus')}</span>\n <span aria-hidden=\"true\">−</span>\n <Money money={unsigned(refunded)} />\n </dd>\n </div>\n ) : null}\n </dl>\n </div>\n );\n}\n"],"mappings":";;;;;AAcA;AAAA,EACE;AAAA,OAIK;AACP,SAAS,eAAe;AAiDhB,SAYQ,UAXN,KADF;AAxBR,SAAS,SAAS,OAAyC;AACzD,SAAO,EAAE,GAAG,OAAO,UAAU,OAAO,WAAW,MAAM,aAAa,MAAM,UAAU;AACpF;AAUO,SAA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ds
|
|
4
|
+
} from "./chunk-Y5BRPEHA.mjs";
|
|
5
|
+
import {
|
|
6
|
+
Field
|
|
7
|
+
} from "./chunk-WYGOMIZK.mjs";
|
|
8
|
+
import {
|
|
9
|
+
usePageErrors
|
|
10
|
+
} from "./chunk-VX5TEJNU.mjs";
|
|
11
|
+
|
|
12
|
+
// src/order/OrderLookup.tsx
|
|
13
|
+
import { __ } from "@artisanpack-ui/ecommerce-storefront-core";
|
|
14
|
+
import { Alert, Button, Card, Link } from "@artisanpack-ui/react";
|
|
15
|
+
import { router } from "@inertiajs/react";
|
|
16
|
+
import { useState } from "react";
|
|
17
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
18
|
+
function OrderLookup({
|
|
19
|
+
findUrl,
|
|
20
|
+
loginUrl,
|
|
21
|
+
failure,
|
|
22
|
+
showTitle = true
|
|
23
|
+
}) {
|
|
24
|
+
const errors = usePageErrors();
|
|
25
|
+
const fieldIds = useFieldIds("ec-order-lookup", { email: "email", order_number: "number" });
|
|
26
|
+
const [email, setEmail] = useState("");
|
|
27
|
+
const [orderNumber, setOrderNumber] = useState("");
|
|
28
|
+
const [processing, setProcessing] = useState(false);
|
|
29
|
+
const [submission, setSubmission] = useState(0);
|
|
30
|
+
const notFound = null !== failure && failure.notFound;
|
|
31
|
+
const submit = (event) => {
|
|
32
|
+
event.preventDefault();
|
|
33
|
+
router.post(
|
|
34
|
+
findUrl,
|
|
35
|
+
{ email, order_number: orderNumber },
|
|
36
|
+
{
|
|
37
|
+
preserveScroll: true,
|
|
38
|
+
onStart: () => setProcessing(true),
|
|
39
|
+
onFinish: () => {
|
|
40
|
+
setProcessing(false);
|
|
41
|
+
setSubmission((count) => count + 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
return /* @__PURE__ */ jsxs("div", { className: "ec-lookup", "data-order-lookup": "", children: [
|
|
47
|
+
/* @__PURE__ */ jsxs("div", { className: "ec-lookup__intro", children: [
|
|
48
|
+
showTitle ? /* @__PURE__ */ jsx("h1", { className: "ec-lookup__title", children: __("Find your order") }) : null,
|
|
49
|
+
/* @__PURE__ */ jsx("p", { className: "ec-lookup__lead", children: __(
|
|
50
|
+
"Enter the email address you used at checkout and your order number. You'll find both in your order confirmation email."
|
|
51
|
+
) })
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ jsx("div", { role: "alert", "aria-live": "assertive", className: "ec-lookup__failure", children: null !== failure ? /* @__PURE__ */ jsx(
|
|
54
|
+
Alert,
|
|
55
|
+
{
|
|
56
|
+
color: "error",
|
|
57
|
+
icon: "circle-alert",
|
|
58
|
+
title: failure.message,
|
|
59
|
+
description: failure.notFound ? __("Check the order number and use the same email as at checkout.") : void 0,
|
|
60
|
+
"data-order-lookup-failure": ""
|
|
61
|
+
}
|
|
62
|
+
) : null }),
|
|
63
|
+
/* @__PURE__ */ jsx(Card, { className: "ec-lookup__card", children: /* @__PURE__ */ jsxs("form", { onSubmit: submit, className: "ec-lookup__form", noValidate: true, "data-order-lookup-form": "", children: [
|
|
64
|
+
/* @__PURE__ */ jsx(
|
|
65
|
+
ErrorSummary,
|
|
66
|
+
{
|
|
67
|
+
id: "ec-order-lookup",
|
|
68
|
+
errors,
|
|
69
|
+
fieldIds,
|
|
70
|
+
submission
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ jsx(
|
|
74
|
+
Field,
|
|
75
|
+
{
|
|
76
|
+
id: fieldIds.email,
|
|
77
|
+
name: "email",
|
|
78
|
+
type: "email",
|
|
79
|
+
leadingIcon: "mail",
|
|
80
|
+
label: __("Email"),
|
|
81
|
+
autoComplete: "email",
|
|
82
|
+
required: true,
|
|
83
|
+
error: errors.email ?? null,
|
|
84
|
+
value: email,
|
|
85
|
+
onValueChange: setEmail,
|
|
86
|
+
attributes: { size: "lg" }
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
Field,
|
|
91
|
+
{
|
|
92
|
+
id: fieldIds.order_number,
|
|
93
|
+
name: "order_number",
|
|
94
|
+
label: __("Order number"),
|
|
95
|
+
autoComplete: "off",
|
|
96
|
+
required: true,
|
|
97
|
+
error: errors.order_number ?? null,
|
|
98
|
+
value: orderNumber,
|
|
99
|
+
onValueChange: setOrderNumber,
|
|
100
|
+
attributes: {
|
|
101
|
+
size: "lg",
|
|
102
|
+
className: "ec-lookup__number",
|
|
103
|
+
spellCheck: false,
|
|
104
|
+
invalid: notFound
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ jsx(
|
|
109
|
+
Button,
|
|
110
|
+
{
|
|
111
|
+
type: "submit",
|
|
112
|
+
size: "lg",
|
|
113
|
+
color: "primary",
|
|
114
|
+
className: "ec-lookup__submit",
|
|
115
|
+
disabled: processing,
|
|
116
|
+
"data-order-lookup-submit": "",
|
|
117
|
+
children: __("Find my order")
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
] }) }),
|
|
121
|
+
null !== loginUrl ? /* @__PURE__ */ jsxs("p", { className: "ec-lookup__login", "data-order-lookup-login": "", children: [
|
|
122
|
+
__("Have an account?"),
|
|
123
|
+
" ",
|
|
124
|
+
/* @__PURE__ */ jsx(Link, { href: loginUrl, children: __("Sign in to see all your orders") })
|
|
125
|
+
] }) : null
|
|
126
|
+
] });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export {
|
|
130
|
+
OrderLookup
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=chunk-THPUK35U.mjs.map
|