@stapel/search-react 0.4.0 → 0.7.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/CHANGELOG.md +151 -0
- package/README.md +1 -1
- package/dist/default/DegradationNotice.d.ts +7 -0
- package/dist/default/DegradationNotice.d.ts.map +1 -1
- package/dist/default/DegradationNotice.js +17 -6
- package/dist/default/DegradationNotice.js.map +1 -1
- package/dist/default/FacetPanelPane.d.ts +54 -3
- package/dist/default/FacetPanelPane.d.ts.map +1 -1
- package/dist/default/FacetPanelPane.js +119 -19
- package/dist/default/FacetPanelPane.js.map +1 -1
- package/dist/default/LanguageSelect.d.ts +9 -0
- package/dist/default/LanguageSelect.d.ts.map +1 -0
- package/dist/default/LanguageSelect.js +72 -0
- package/dist/default/LanguageSelect.js.map +1 -0
- package/dist/default/PageSizeSelect.d.ts +29 -0
- package/dist/default/PageSizeSelect.d.ts.map +1 -0
- package/dist/default/PageSizeSelect.js +25 -0
- package/dist/default/PageSizeSelect.js.map +1 -0
- package/dist/default/RangeFilterRow.d.ts +12 -0
- package/dist/default/RangeFilterRow.d.ts.map +1 -0
- package/dist/default/RangeFilterRow.js +75 -0
- package/dist/default/RangeFilterRow.js.map +1 -0
- package/dist/default/RankingDisclosurePane.d.ts +5 -0
- package/dist/default/RankingDisclosurePane.d.ts.map +1 -1
- package/dist/default/RankingDisclosurePane.js +15 -15
- package/dist/default/RankingDisclosurePane.js.map +1 -1
- package/dist/default/SearchBox.d.ts +13 -0
- package/dist/default/SearchBox.d.ts.map +1 -0
- package/dist/default/SearchBox.js +67 -0
- package/dist/default/SearchBox.js.map +1 -0
- package/dist/default/SearchPage.d.ts +54 -16
- package/dist/default/SearchPage.d.ts.map +1 -1
- package/dist/default/SearchPage.js +155 -8
- package/dist/default/SearchPage.js.map +1 -1
- package/dist/default/SearchResultCard.d.ts +19 -18
- package/dist/default/SearchResultCard.d.ts.map +1 -1
- package/dist/default/SearchResultCard.js +178 -5
- package/dist/default/SearchResultCard.js.map +1 -1
- package/dist/default/SearchResultsPane.d.ts +42 -3
- package/dist/default/SearchResultsPane.d.ts.map +1 -1
- package/dist/default/SearchResultsPane.js +38 -21
- package/dist/default/SearchResultsPane.js.map +1 -1
- package/dist/default/SortSelect.d.ts +10 -2
- package/dist/default/SortSelect.d.ts.map +1 -1
- package/dist/default/SortSelect.js +27 -24
- package/dist/default/SortSelect.js.map +1 -1
- package/dist/default/UrlIssueNotice.d.ts.map +1 -1
- package/dist/default/UrlIssueNotice.js +19 -1
- package/dist/default/UrlIssueNotice.js.map +1 -1
- package/dist/default/index.d.ts +32 -15
- package/dist/default/index.d.ts.map +1 -1
- package/dist/default/index.js +26 -12
- package/dist/default/index.js.map +1 -1
- package/dist/default/sortLabels.d.ts +5 -0
- package/dist/default/sortLabels.d.ts.map +1 -0
- package/dist/default/sortLabels.js +32 -0
- package/dist/default/sortLabels.js.map +1 -0
- package/dist/headless/FacetPanel.d.ts +17 -0
- package/dist/headless/FacetPanel.d.ts.map +1 -1
- package/dist/headless/FacetPanel.js +23 -2
- package/dist/headless/FacetPanel.js.map +1 -1
- package/dist/headless/useAppliedCount.d.ts +8 -0
- package/dist/headless/useAppliedCount.d.ts.map +1 -0
- package/dist/headless/useAppliedCount.js +30 -0
- package/dist/headless/useAppliedCount.js.map +1 -0
- package/dist/headless/useScorerNames.d.ts +4 -0
- package/dist/headless/useScorerNames.d.ts.map +1 -0
- package/dist/headless/useScorerNames.js +34 -0
- package/dist/headless/useScorerNames.js.map +1 -0
- package/dist/headless/useSearchBox.d.ts +44 -0
- package/dist/headless/useSearchBox.d.ts.map +1 -0
- package/dist/headless/useSearchBox.js +116 -0
- package/dist/headless/useSearchBox.js.map +1 -0
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +30 -4
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/keys.d.ts +35 -0
- package/dist/i18n/keys.d.ts.map +1 -1
- package/dist/i18n/keys.js +72 -4
- package/dist/i18n/keys.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +34 -4
- package/dist/i18n/ru.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/model/queries.d.ts +26 -2
- package/dist/model/queries.d.ts.map +1 -1
- package/dist/model/queries.js +38 -1
- package/dist/model/queries.js.map +1 -1
- package/dist/state/limits.d.ts +44 -0
- package/dist/state/limits.d.ts.map +1 -0
- package/dist/state/limits.js +44 -0
- package/dist/state/limits.js.map +1 -0
- package/dist/state/ranges.d.ts +52 -0
- package/dist/state/ranges.d.ts.map +1 -0
- package/dist/state/ranges.js +108 -0
- package/dist/state/ranges.js.map +1 -0
- package/llms.txt +15 -4
- package/manifest.json +238 -21
- package/nav-manifest.json +1 -1
- package/package.json +15 -10
- package/src/analytics/generated/events.json +1 -1
- package/src/default/DegradationNotice.tsx +34 -12
- package/src/default/FacetPanelPane.tsx +343 -64
- package/src/default/LanguageSelect.tsx +93 -0
- package/src/default/PageSizeSelect.tsx +80 -0
- package/src/default/RangeFilterRow.tsx +148 -0
- package/src/default/RankingDisclosurePane.tsx +67 -35
- package/src/default/SearchBox.tsx +130 -0
- package/src/default/SearchPage.tsx +351 -44
- package/src/default/SearchResultCard.tsx +231 -24
- package/src/default/SearchResultsPane.tsx +120 -70
- package/src/default/SortSelect.tsx +50 -37
- package/src/default/UrlIssueNotice.tsx +21 -3
- package/src/default/index.ts +38 -15
- package/src/default/sortLabels.ts +34 -0
- package/src/headless/FacetPanel.tsx +30 -2
- package/src/headless/useAppliedCount.ts +41 -0
- package/src/headless/useScorerNames.ts +36 -0
- package/src/headless/useSearchBox.ts +189 -0
- package/src/i18n/es.ts +37 -4
- package/src/i18n/keys.ts +83 -4
- package/src/i18n/ru.ts +41 -4
- package/src/index.ts +22 -2
- package/src/model/queries.ts +51 -1
- package/src/state/limits.ts +50 -0
- package/src/state/ranges.ts +144 -0
- package/dist/default/ErrorAlert.d.ts +0 -9
- package/dist/default/ErrorAlert.d.ts.map +0 -1
- package/dist/default/ErrorAlert.js +0 -27
- package/dist/default/ErrorAlert.js.map +0 -1
- package/dist/default/theme.d.ts +0 -24
- package/dist/default/theme.d.ts.map +0 -1
- package/dist/default/theme.js +0 -39
- package/dist/default/theme.js.map +0 -1
- package/src/default/ErrorAlert.tsx +0 -46
- package/src/default/theme.tsx +0 -66
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { errorCode,
|
|
2
|
+
import { Flex, Typography } from "antd";
|
|
3
|
+
import { errorCode, useT, useTPlural } from "@stapel/core";
|
|
4
|
+
import { EmptyState, ErrorAlert, GatedButton, LoadList, SkinTheme, } from "@stapel/tokens-antd/skin";
|
|
5
|
+
import { spacing } from "@stapel/tokens";
|
|
4
6
|
import { SearchResults } from "../headless/SearchResults.js";
|
|
7
|
+
import { useScorerNames } from "../headless/useScorerNames.js";
|
|
5
8
|
import { SEARCH_WINDOW_EXCEEDED } from "../i18n/errorsMap.js";
|
|
6
9
|
import { SEARCH_I18N_KEYS } from "../i18n/keys.js";
|
|
7
10
|
import { DegradationNotice } from "./DegradationNotice.js";
|
|
8
|
-
import { ErrorAlert } from "./ErrorAlert.js";
|
|
9
11
|
import { SearchResultCard } from "./SearchResultCard.js";
|
|
10
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The widest a column of results is allowed to get.
|
|
14
|
+
*
|
|
15
|
+
* Off the spacing scale and named for it: it is a MEASURE, the reading-width
|
|
16
|
+
* decision every long page has to take. Without it the pane spread the full
|
|
17
|
+
* width of whatever it was dropped into — the visual pass measured a 2560px
|
|
18
|
+
* pane with four cards floating at the top of it and a status row 1350px from
|
|
19
|
+
* the buttons that act on it (class C-NOMAXW).
|
|
20
|
+
*/
|
|
21
|
+
export const RESULTS_MAX_WIDTH = 1120;
|
|
11
22
|
/**
|
|
12
23
|
* The results grid. `auto-fill` + `minmax(280px, 1fr)`: as many columns as fit,
|
|
13
24
|
* each at least a readable card and never wider than its share — a catalogue
|
|
@@ -19,7 +30,7 @@ import { SearchSkinTheme } from "./theme.js";
|
|
|
19
30
|
const RESULTS_GRID = {
|
|
20
31
|
display: "grid",
|
|
21
32
|
gridTemplateColumns: "repeat(auto-fill, minmax(280px, 1fr))",
|
|
22
|
-
gap:
|
|
33
|
+
gap: spacing[3],
|
|
23
34
|
alignItems: "stretch",
|
|
24
35
|
};
|
|
25
36
|
function Count(props) {
|
|
@@ -39,30 +50,36 @@ function Count(props) {
|
|
|
39
50
|
? tPlural(SEARCH_I18N_KEYS.resultsCountAtLeast, { count: page.count })
|
|
40
51
|
: tPlural(SEARCH_I18N_KEYS.resultsCountExact, { count: page.count }) }));
|
|
41
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* The keyset controls — rendered only when there IS another page.
|
|
55
|
+
*
|
|
56
|
+
* Keyset paging has no page numbers to jump to: there is a next, a previous,
|
|
57
|
+
* and a server-side depth cap. When neither direction exists the pager is not
|
|
58
|
+
* "disabled", it is absent — a control that can never do anything is not a
|
|
59
|
+
* control that needs explaining.
|
|
60
|
+
*/
|
|
42
61
|
function Pager(props) {
|
|
43
62
|
const t = useT();
|
|
44
|
-
const { prev, next, goPrev, goNext } = props.bag;
|
|
45
|
-
|
|
63
|
+
const { page, prev, next, goPrev, goNext } = props.bag;
|
|
64
|
+
if (page === null || (!page.hasNext && !page.hasPrev))
|
|
65
|
+
return null;
|
|
66
|
+
return (_jsxs(Flex, { gap: spacing[2], justify: "center", wrap: true, "data-testid": "search-pager", children: [_jsx(GatedButton, { gate: prev, onClick: goPrev, testId: "search-prev", "data-analytics": "none", "data-analytics-reason": "keyset paging is a read, not a flow step", children: t(SEARCH_I18N_KEYS.resultsPrev) }), _jsx(GatedButton, { gate: next, onClick: goNext, testId: "search-next", "data-analytics": "none", "data-analytics-reason": "keyset paging is a read, not a flow step", children: t(SEARCH_I18N_KEYS.resultsNext) })] }));
|
|
46
67
|
}
|
|
47
68
|
export function SearchResultsPane(props) {
|
|
48
69
|
const t = useT();
|
|
49
|
-
const describe = useDescribeFlowError();
|
|
50
70
|
const { renderCard, renderResults } = props;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
const scorerName = useScorerNames();
|
|
72
|
+
const maxWidth = props.maxWidth === undefined ? RESULTS_MAX_WIDTH : props.maxWidth;
|
|
73
|
+
return (_jsx(SkinTheme, { surface: "base", ...(props.mode !== undefined ? { mode: props.mode } : {}), style: {
|
|
74
|
+
width: "100%",
|
|
75
|
+
...(maxWidth !== null ? { maxWidth } : {}),
|
|
76
|
+
}, children: _jsx(SearchResults, { ...(props.enabled !== undefined ? { enabled: props.enabled } : {}), children: (bag) => (_jsxs(Flex, { vertical: true, gap: spacing[4], children: [_jsxs(Flex, { justify: "space-between", align: "center", wrap: true, gap: spacing[2], children: [_jsx(Typography.Title, { level: 4, style: { margin: 0 }, "data-testid": "search-results-heading", children: props.heading ?? t(SEARCH_I18N_KEYS.resultsTitle) }), _jsxs(Flex, { align: "center", wrap: true, gap: spacing[3], children: [_jsx(Count, { bag: bag }), props.toolbar] })] }), _jsx(DegradationNotice, { degradations: bag.degradations, variant: props.degradationNotice ?? "banner", scorerName: scorerName }), _jsx(LoadList, { state: bag.state, testId: "search", skeletonRows: 6, onRetry: bag.refetch, empty: _jsx(EmptyState, { title: t(SEARCH_I18N_KEYS.resultsEmpty), testId: "search-empty" }), failed: (error) => {
|
|
54
77
|
// The window refusal is a DIFFERENT sentence from a failed
|
|
55
78
|
// search, and both are different from "nothing found".
|
|
56
79
|
const isWindow = errorCode(error) === SEARCH_WINDOW_EXCEEDED;
|
|
57
|
-
return (_jsx(ErrorAlert, { testId: isWindow ? "search-window-exceeded" : "search-failed", error:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
: SEARCH_I18N_KEYS.resultsLoadFailed),
|
|
62
|
-
}, action: _jsx(Button, { size: "small", onClick: bag.refetch, "data-analytics": "none", "data-analytics-reason": "retry of a failed read; no flow to step", children: t(SEARCH_I18N_KEYS.resultsRetry) }) }));
|
|
63
|
-
},
|
|
64
|
-
empty: () => (_jsx(Empty, { "data-testid": "search-empty", description: t(SEARCH_I18N_KEYS.resultsEmpty) })),
|
|
65
|
-
ready: (items) => (_jsx("div", { "data-testid": "search-results", children: renderResults !== undefined ? (renderResults(items)) : (_jsx("div", { style: RESULTS_GRID, "data-testid": "search-results-grid", children: items.map((item) => (_jsx("div", { children: renderCard !== undefined ? (renderCard(item)) : (_jsx(SearchResultCard, { item: item })) }, item.key))) })) })),
|
|
66
|
-
}), _jsx(Pager, { bag: bag }), props.footer] })) }) }));
|
|
80
|
+
return (_jsx(ErrorAlert, { testId: isWindow ? "search-window-exceeded" : "search-failed", thrown: error, message: t(isWindow
|
|
81
|
+
? SEARCH_I18N_KEYS.resultsWindowExceeded
|
|
82
|
+
: SEARCH_I18N_KEYS.resultsLoadFailed), retryLabel: t(SEARCH_I18N_KEYS.resultsRetry), onRetry: bag.refetch }));
|
|
83
|
+
}, children: (items) => (_jsx("div", { "data-testid": "search-results", children: renderResults !== undefined ? (renderResults(items)) : (_jsx("div", { style: RESULTS_GRID, "data-testid": "search-results-grid", children: items.map((item) => (_jsx("div", { children: renderCard !== undefined ? (renderCard(item)) : (_jsx(SearchResultCard, { item: item })) }, item.key))) })) })) }), _jsx(Pager, { bag: bag }), props.footer] })) }) }));
|
|
67
84
|
}
|
|
68
85
|
//# sourceMappingURL=SearchResultsPane.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResultsPane.js","sourceRoot":"","sources":["../../src/default/SearchResultsPane.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"SearchResultsPane.js","sourceRoot":"","sources":["../../src/default/SearchResultsPane.tsx"],"names":[],"mappings":";AA2BA,OAAO,EAAE,IAAI,EAAE,UAA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AAC,IAAgB,EAAE,EAAE,CAAC,CAC/B,wBACG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAC1B,UAAU,CAAC,IAAI,CAAC,CACjB,CAAC,CAAC,CAAC,CACF,KAAC,gBAAgB,IAAC,IAAI,EAAE,IAAI,GAAI,CACjC,IALO,IAAI,CAAC,GAAG,CAMZ,CACP,CAAC,GACE,CACP,GACG,CACP,GACQ,EAEX,KAAC,KAAK,IAAC,GAAG,EAAE,GAAG,GAAI,EAClB,KAAK,CAAC,MAAM,IACR,CACR,GACa,GACN,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -10,10 +10,18 @@
|
|
|
10
10
|
*
|
|
11
11
|
* `sort=distance` needs a centre — the server answers
|
|
12
12
|
* `error.400.search_sort_needs_center` without one. The option is therefore
|
|
13
|
-
* DISABLED
|
|
14
|
-
*
|
|
13
|
+
* DISABLED when no geo centre is set, and the REASON is rendered beside the
|
|
14
|
+
* control through `GatedControl`, not in a `title=` a phone can never surface.
|
|
15
|
+
* That is the whole defect this file used to carry: the one sort a person
|
|
16
|
+
* would most want on a phone was greyed out with its explanation in a hover.
|
|
15
17
|
*/
|
|
16
18
|
import type { ReactElement } from "react";
|
|
19
|
+
/**
|
|
20
|
+
* The select's floor width. Off the spacing scale on purpose and named for it:
|
|
21
|
+
* it is the width of the longest shipped sort label ("Price: low to high") at
|
|
22
|
+
* the default type step, so the control does not resize as the choice changes.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SORT_SELECT_MIN_WIDTH = 200;
|
|
17
25
|
export interface SortSelectProps {
|
|
18
26
|
/** The sort the SERVER applied, shown when the URL names none. Omitted, it
|
|
19
27
|
* is read from the page already in cache — see {@link useAppliedSort}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortSelect.d.ts","sourceRoot":"","sources":["../../src/default/SortSelect.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"SortSelect.d.ts","sourceRoot":"","sources":["../../src/default/SortSelect.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAY1C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B;8EAC0E;IAC1E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAwD/D"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Flex, Select, Typography } from "antd";
|
|
3
|
-
import { useT } from "@stapel/core";
|
|
3
|
+
import { actionAvailable, actionBlocked, useT } from "@stapel/core";
|
|
4
|
+
import { GatedControl } from "@stapel/tokens-antd/skin";
|
|
5
|
+
import { spacing } from "@stapel/tokens";
|
|
4
6
|
import { SEARCH_SORTS } from "../api/types.js";
|
|
5
7
|
import { useAppliedSort } from "../headless/useAppliedSort.js";
|
|
6
8
|
import { useSearchState } from "../headless/SearchStateProvider.js";
|
|
7
9
|
import { SEARCH_I18N_KEYS } from "../i18n/keys.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import { sortLabelKey } from "./sortLabels.js";
|
|
11
|
+
/**
|
|
12
|
+
* The select's floor width. Off the spacing scale on purpose and named for it:
|
|
13
|
+
* it is the width of the longest shipped sort label ("Price: low to high") at
|
|
14
|
+
* the default type step, so the control does not resize as the choice changes.
|
|
15
|
+
*/
|
|
16
|
+
export const SORT_SELECT_MIN_WIDTH = 200;
|
|
15
17
|
export function SortSelect(props) {
|
|
16
18
|
const t = useT();
|
|
17
19
|
const { state, setSort } = useSearchState();
|
|
@@ -28,21 +30,22 @@ export function SortSelect(props) {
|
|
|
28
30
|
const values = active !== undefined && !known.has(active)
|
|
29
31
|
? [...SEARCH_SORTS, active]
|
|
30
32
|
: SEARCH_SORTS;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
:
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
// The gate is about ONE option, not the whole control — so the binding's
|
|
34
|
+
// `aria-describedby` is spread onto the select (a screen reader hears the
|
|
35
|
+
// reason with the control) and its `disabled` deliberately is not: the other
|
|
36
|
+
// four sorts work perfectly well without a location.
|
|
37
|
+
const distance = hasCentre
|
|
38
|
+
? actionAvailable()
|
|
39
|
+
: actionBlocked("error.400.search_sort_needs_center");
|
|
40
|
+
return (_jsx(GatedControl, { gate: distance, testId: "search-sort-gate", children: (bind) => (_jsxs(Flex, { gap: spacing[2], align: "center", children: [_jsx(Typography.Text, { type: "secondary", "aria-hidden": "true", children: t(SEARCH_I18N_KEYS.sortLabel) }), _jsx(Select, { "data-testid": "search-sort", "aria-label": t(SEARCH_I18N_KEYS.sortLabel), "aria-describedby": bind["aria-describedby"], style: { minWidth: SORT_SELECT_MIN_WIDTH }, value: active ?? null, onChange: (next) => {
|
|
41
|
+
setSort(next);
|
|
42
|
+
}, options: values.map((value) => {
|
|
43
|
+
const key = sortLabelKey(value);
|
|
44
|
+
return {
|
|
45
|
+
value,
|
|
46
|
+
label: key !== undefined ? t(key) : value,
|
|
47
|
+
disabled: value === "distance" && !hasCentre,
|
|
48
|
+
};
|
|
49
|
+
}) })] })) }));
|
|
47
50
|
}
|
|
48
51
|
//# sourceMappingURL=SortSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortSelect.js","sourceRoot":"","sources":["../../src/default/SortSelect.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"SortSelect.js","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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlIssueNotice.d.ts","sourceRoot":"","sources":["../../src/default/UrlIssueNotice.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"UrlIssueNotice.d.ts","sourceRoot":"","sources":["../../src/default/UrlIssueNotice.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAwB1C,wBAAgB,cAAc,IAAI,YAAY,GAAG,IAAI,CAqBpD"}
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Alert } from "antd";
|
|
3
|
+
import { spacing } from "@stapel/tokens";
|
|
3
4
|
import { useT } from "@stapel/core";
|
|
5
|
+
import { FILTER_PREFIX, RANGE_PREFIX } from "../state/urlState.js";
|
|
4
6
|
import { useSearchState } from "../headless/SearchStateProvider.js";
|
|
5
7
|
import { SEARCH_I18N_KEYS } from "../i18n/keys.js";
|
|
8
|
+
/**
|
|
9
|
+
* The parameter as a person can recognise it.
|
|
10
|
+
*
|
|
11
|
+
* The codec reports the WIRE name, which for a facet or a range carries the
|
|
12
|
+
* prefix that tells the backend which family it belongs to (`r.price`,
|
|
13
|
+
* `f.brand`). That prefix is a protocol detail: the sentence is read by
|
|
14
|
+
* somebody who followed a link, and "price" is the part of `r.price` they
|
|
15
|
+
* have any chance of recognising.
|
|
16
|
+
*/
|
|
17
|
+
function readableParam(param) {
|
|
18
|
+
for (const prefix of [RANGE_PREFIX, FILTER_PREFIX]) {
|
|
19
|
+
if (param.startsWith(prefix))
|
|
20
|
+
return param.slice(prefix.length);
|
|
21
|
+
}
|
|
22
|
+
return param;
|
|
23
|
+
}
|
|
6
24
|
export function UrlIssueNotice() {
|
|
7
25
|
const t = useT();
|
|
8
26
|
const { issues } = useSearchState();
|
|
9
27
|
if (issues.length === 0)
|
|
10
28
|
return null;
|
|
11
|
-
return (_jsx(Alert, { type: "warning", showIcon: true, "data-testid": "search-url-issues",
|
|
29
|
+
return (_jsx(Alert, { type: "warning", showIcon: true, "data-testid": "search-url-issues", title: t(SEARCH_I18N_KEYS.urlIssuesTitle), description: _jsx("ul", { style: { margin: 0, paddingInlineStart: spacing[5] }, children: issues.map((issue) => (_jsx("li", { children: t(issue.messageKey, { param: readableParam(issue.param) }) }, `${issue.param}:${issue.code}`))) }) }));
|
|
12
30
|
}
|
|
13
31
|
//# sourceMappingURL=UrlIssueNotice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlIssueNotice.js","sourceRoot":"","sources":["../../src/default/UrlIssueNotice.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,UAAU,cAAc;IAC5B,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,OAAO,CACL,KAAC,KAAK,IACJ,IAAI,EAAC,SAAS,EACd,QAAQ,uBACI,mBAAmB,EAC/B,
|
|
1
|
+
{"version":3,"file":"UrlIssueNotice.js","sourceRoot":"","sources":["../../src/default/UrlIssueNotice.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC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for this bundle (enforced by size-limit and the bundle-purity
|
|
7
7
|
* test).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Five override levers, none of which requires forking anything:
|
|
10
10
|
*
|
|
11
11
|
* 1. **`renderCard`** — the card slot. A storefront passes
|
|
12
12
|
* `<ListingCard>` from `@stapel/listings-react/default`; the generic card
|
|
13
13
|
* here is the documented default, not the intended end state (spec §3.7).
|
|
14
14
|
* `renderResults` is the level above it: the whole layout, for a container
|
|
15
15
|
* whose arrangement is not "cards in a grid".
|
|
16
|
-
* 2. **`categoryFeatures`** — the facet-label slot
|
|
17
|
-
* `{value: count}` and no
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* 2. **`categoryFeatures`** — the facet-label slot, and the source of which
|
|
17
|
+
* slugs get a numeric range row. The server sends `{value: count}` and no
|
|
18
|
+
* labels; the schema that names them lives in categories, and the
|
|
19
|
+
* container hands it in (spec §6.2 item 2).
|
|
20
|
+
* 3. **`renderCategoryFilter`** — the catalogue picker. `categories-react`
|
|
21
|
+
* owns walking the tree; this pair owns the `category` parameter.
|
|
22
|
+
* 4. **`renderGeoFilter`** — the location control. `geo-react` owns the map
|
|
23
|
+
* and the geocoder; this pair owns `lat`/`lon`/`radius_km`/`bbox`, and
|
|
24
|
+
* keeps the controls that WIDEN a location a link already carries.
|
|
25
|
+
* 5. **retheming through the §68 token JSON** — every surface wraps itself
|
|
26
|
+
* in the shared `SkinTheme`, so a host's regenerated `--stapel-*` custom
|
|
21
27
|
* properties reach this skin with zero code.
|
|
28
|
+
*
|
|
29
|
+
* The pair's own `theme.tsx` and `ErrorAlert.tsx` are GONE as of 0.6.0: both
|
|
30
|
+
* were copies of a decision now stated once in `@stapel/tokens-antd/skin`
|
|
31
|
+
* (`SkinTheme`, `ErrorAlert`). A host that imported `SearchSkinTheme` imports
|
|
32
|
+
* `SkinTheme` from the substrate instead — same props, one implementation, and
|
|
33
|
+
* a runtime `data-theme` flip actually repaints it.
|
|
22
34
|
*/
|
|
23
35
|
export { SearchPage } from "./SearchPage.js";
|
|
24
|
-
export type { SearchPageProps } from "./SearchPage.js";
|
|
25
|
-
export { SearchResultsPane } from "./SearchResultsPane.js";
|
|
36
|
+
export type { SearchPageProps, SearchFiltersLayout } from "./SearchPage.js";
|
|
37
|
+
export { SearchResultsPane, RESULTS_MAX_WIDTH } from "./SearchResultsPane.js";
|
|
26
38
|
export type { SearchResultsPaneProps, SearchResultsRenderer, } from "./SearchResultsPane.js";
|
|
27
39
|
export { FacetPanelPane } from "./FacetPanelPane.js";
|
|
28
|
-
export type { FacetPanelPaneProps } from "./FacetPanelPane.js";
|
|
29
|
-
export { RankingDisclosurePane } from "./RankingDisclosurePane.js";
|
|
40
|
+
export type { FacetPanelPaneProps, CategoryFilterSlotProps, GeoFilterSlotProps, } from "./FacetPanelPane.js";
|
|
41
|
+
export { RankingDisclosurePane, RANKING_MAX_WIDTH } from "./RankingDisclosurePane.js";
|
|
30
42
|
export type { RankingDisclosurePaneProps } from "./RankingDisclosurePane.js";
|
|
43
|
+
export { SearchBox } from "./SearchBox.js";
|
|
44
|
+
export type { SearchBoxProps } from "./SearchBox.js";
|
|
45
|
+
export { SortSelect, SORT_SELECT_MIN_WIDTH } from "./SortSelect.js";
|
|
46
|
+
export type { SortSelectProps } from "./SortSelect.js";
|
|
47
|
+
export { PageSizeSelect, SEARCH_PAGE_SIZES } from "./PageSizeSelect.js";
|
|
48
|
+
export type { PageSizeSelectProps } from "./PageSizeSelect.js";
|
|
49
|
+
export { LanguageSelect } from "./LanguageSelect.js";
|
|
50
|
+
export type { LanguageSelectProps } from "./LanguageSelect.js";
|
|
31
51
|
export { SearchResultCard, GENERIC_CARD_FIELDS } from "./SearchResultCard.js";
|
|
32
52
|
export type { SearchCardProps, SearchCardRenderer } from "./SearchResultCard.js";
|
|
33
53
|
export { DegradationNotice } from "./DegradationNotice.js";
|
|
34
54
|
export type { DegradationNoticeProps, DegradationNoticeVariant, } from "./DegradationNotice.js";
|
|
35
55
|
export { UrlIssueNotice } from "./UrlIssueNotice.js";
|
|
36
|
-
export {
|
|
37
|
-
export type {
|
|
38
|
-
export { ErrorAlert } from "./ErrorAlert.js";
|
|
39
|
-
export { SearchSkinTheme } from "./theme.js";
|
|
40
|
-
export type { SearchSkinThemeProps } from "./theme.js";
|
|
56
|
+
export { RangeFilterRow } from "./RangeFilterRow.js";
|
|
57
|
+
export type { RangeFilterRowProps } from "./RangeFilterRow.js";
|
|
41
58
|
export type { ThemeModeProp } from "./types.js";
|
|
42
59
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/default/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/default/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACtF,YAAY,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAG7E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EACV,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG/D,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/default/index.js
CHANGED
|
@@ -6,31 +6,45 @@
|
|
|
6
6
|
* never pays for this bundle (enforced by size-limit and the bundle-purity
|
|
7
7
|
* test).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Five override levers, none of which requires forking anything:
|
|
10
10
|
*
|
|
11
11
|
* 1. **`renderCard`** — the card slot. A storefront passes
|
|
12
12
|
* `<ListingCard>` from `@stapel/listings-react/default`; the generic card
|
|
13
13
|
* here is the documented default, not the intended end state (spec §3.7).
|
|
14
14
|
* `renderResults` is the level above it: the whole layout, for a container
|
|
15
15
|
* whose arrangement is not "cards in a grid".
|
|
16
|
-
* 2. **`categoryFeatures`** — the facet-label slot
|
|
17
|
-
* `{value: count}` and no
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* 2. **`categoryFeatures`** — the facet-label slot, and the source of which
|
|
17
|
+
* slugs get a numeric range row. The server sends `{value: count}` and no
|
|
18
|
+
* labels; the schema that names them lives in categories, and the
|
|
19
|
+
* container hands it in (spec §6.2 item 2).
|
|
20
|
+
* 3. **`renderCategoryFilter`** — the catalogue picker. `categories-react`
|
|
21
|
+
* owns walking the tree; this pair owns the `category` parameter.
|
|
22
|
+
* 4. **`renderGeoFilter`** — the location control. `geo-react` owns the map
|
|
23
|
+
* and the geocoder; this pair owns `lat`/`lon`/`radius_km`/`bbox`, and
|
|
24
|
+
* keeps the controls that WIDEN a location a link already carries.
|
|
25
|
+
* 5. **retheming through the §68 token JSON** — every surface wraps itself
|
|
26
|
+
* in the shared `SkinTheme`, so a host's regenerated `--stapel-*` custom
|
|
21
27
|
* properties reach this skin with zero code.
|
|
28
|
+
*
|
|
29
|
+
* The pair's own `theme.tsx` and `ErrorAlert.tsx` are GONE as of 0.6.0: both
|
|
30
|
+
* were copies of a decision now stated once in `@stapel/tokens-antd/skin`
|
|
31
|
+
* (`SkinTheme`, `ErrorAlert`). A host that imported `SearchSkinTheme` imports
|
|
32
|
+
* `SkinTheme` from the substrate instead — same props, one implementation, and
|
|
33
|
+
* a runtime `data-theme` flip actually repaints it.
|
|
22
34
|
*/
|
|
23
35
|
// ── surfaces ────────────────────────────────────────────────────────────────
|
|
24
36
|
export { SearchPage } from "./SearchPage.js";
|
|
25
|
-
export { SearchResultsPane } from "./SearchResultsPane.js";
|
|
37
|
+
export { SearchResultsPane, RESULTS_MAX_WIDTH } from "./SearchResultsPane.js";
|
|
26
38
|
export { FacetPanelPane } from "./FacetPanelPane.js";
|
|
27
|
-
export { RankingDisclosurePane } from "./RankingDisclosurePane.js";
|
|
39
|
+
export { RankingDisclosurePane, RANKING_MAX_WIDTH } from "./RankingDisclosurePane.js";
|
|
40
|
+
// ── controls, exported so a host can compose its own layout ─────────────────
|
|
41
|
+
export { SearchBox } from "./SearchBox.js";
|
|
42
|
+
export { SortSelect, SORT_SELECT_MIN_WIDTH } from "./SortSelect.js";
|
|
43
|
+
export { PageSizeSelect, SEARCH_PAGE_SIZES } from "./PageSizeSelect.js";
|
|
44
|
+
export { LanguageSelect } from "./LanguageSelect.js";
|
|
28
45
|
// ── parts, exported so a host can compose or wrap one ───────────────────────
|
|
29
46
|
export { SearchResultCard, GENERIC_CARD_FIELDS } from "./SearchResultCard.js";
|
|
30
47
|
export { DegradationNotice } from "./DegradationNotice.js";
|
|
31
48
|
export { UrlIssueNotice } from "./UrlIssueNotice.js";
|
|
32
|
-
export {
|
|
33
|
-
export { ErrorAlert } from "./ErrorAlert.js";
|
|
34
|
-
// ── theming ─────────────────────────────────────────────────────────────────
|
|
35
|
-
export { SearchSkinTheme } from "./theme.js";
|
|
49
|
+
export { RangeFilterRow } from "./RangeFilterRow.js";
|
|
36
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/default/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/default/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,+EAA+E;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAM9E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAOrD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGtF,+EAA+E;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,+EAA+E;AAC/E,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The i18n key for a shipped sort, or `undefined` for a deployment's own. */
|
|
2
|
+
export declare function sortLabelKey(sort: string): string | undefined;
|
|
3
|
+
/** The sort's name for a reader, falling back to the slug. */
|
|
4
|
+
export declare function sortLabel(t: (key: string) => string, sort: string): string;
|
|
5
|
+
//# sourceMappingURL=sortLabels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortLabels.d.ts","sourceRoot":"","sources":["../../src/default/sortLabels.ts"],"names":[],"mappings":"AAwBA,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE7D;AAED,8DAA8D;AAC9D,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sort SLUG as the skin names it, in one place.
|
|
3
|
+
*
|
|
4
|
+
* `relevance`, `price_asc`, `distance` are wire values: the URL carries them,
|
|
5
|
+
* the envelope reports them, and the ranking disclosure lists them per scorer.
|
|
6
|
+
* The sort SELECT translated them and the disclosure did not, so the same page
|
|
7
|
+
* offered "Most relevant" in the control and stamped "Applies to: relevance"
|
|
8
|
+
* under every parameter — the registry's word, in a statutory text, next to
|
|
9
|
+
* the human word for the same thing.
|
|
10
|
+
*
|
|
11
|
+
* A slug the pair does not ship is returned as it is. Deployments register
|
|
12
|
+
* their own scorers and sorts, and an unknown one is a real value that belongs
|
|
13
|
+
* on screen; only an invented label would be worse.
|
|
14
|
+
*/
|
|
15
|
+
import { SEARCH_I18N_KEYS } from "../i18n/keys.js";
|
|
16
|
+
const SORT_LABEL_KEY = {
|
|
17
|
+
relevance: SEARCH_I18N_KEYS.sortRelevance,
|
|
18
|
+
newest: SEARCH_I18N_KEYS.sortNewest,
|
|
19
|
+
price_asc: SEARCH_I18N_KEYS.sortPriceAsc,
|
|
20
|
+
price_desc: SEARCH_I18N_KEYS.sortPriceDesc,
|
|
21
|
+
distance: SEARCH_I18N_KEYS.sortDistance,
|
|
22
|
+
};
|
|
23
|
+
/** The i18n key for a shipped sort, or `undefined` for a deployment's own. */
|
|
24
|
+
export function sortLabelKey(sort) {
|
|
25
|
+
return SORT_LABEL_KEY[sort];
|
|
26
|
+
}
|
|
27
|
+
/** The sort's name for a reader, falling back to the slug. */
|
|
28
|
+
export function sortLabel(t, sort) {
|
|
29
|
+
const key = SORT_LABEL_KEY[sort];
|
|
30
|
+
return key === undefined ? sort : t(key);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=sortLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortLabels.js","sourceRoot":"","sources":["../../src/default/sortLabels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,cAAc,GAAqC;IACvD,SAAS,EAAE,gBAAgB,CAAC,aAAa;IACzC,MAAM,EAAE,gBAAgB,CAAC,UAAU;IACnC,SAAS,EAAE,gBAAgB,CAAC,YAAY;IACxC,UAAU,EAAE,gBAAgB,CAAC,aAAa;IAC1C,QAAQ,EAAE,gBAAgB,CAAC,YAAY;CACxC,CAAC;AAEF,8EAA8E;AAC9E,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAC,CAA0B,EAAE,IAAY;IAChE,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -58,4 +58,21 @@ export declare function FacetPanel(props: {
|
|
|
58
58
|
enabled?: boolean;
|
|
59
59
|
children: (bag: FacetPanelBag) => ReactNode;
|
|
60
60
|
}): ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* The same bag, as a hook — for a caller that has to know what the panel WILL
|
|
63
|
+
* render before it renders it.
|
|
64
|
+
*
|
|
65
|
+
* The one real caller is `<SearchPage>`: a facet column is a quarter of a
|
|
66
|
+
* catalogue page, and on a deployment whose plan has no facets at all it was
|
|
67
|
+
* a quarter of every results page spent on an empty-state illustration
|
|
68
|
+
* repeating "no filters for this search". Whether to lay out that column is a
|
|
69
|
+
* LAYOUT decision, and layout is decided by the component that owns the grid
|
|
70
|
+
* — which therefore has to be able to ask. A render prop cannot answer a
|
|
71
|
+
* question asked one level up.
|
|
72
|
+
*/
|
|
73
|
+
export declare function useFacetPanel(props?: {
|
|
74
|
+
categoryFeatures?: readonly FeatureDef[];
|
|
75
|
+
locale?: string;
|
|
76
|
+
enabled?: boolean;
|
|
77
|
+
}): FacetPanelBag;
|
|
61
78
|
//# sourceMappingURL=FacetPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FacetPanel.d.ts","sourceRoot":"","sources":["../../src/headless/FacetPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS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AAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,SAAS,CAAC;CAC7C,GAAG,SAAS,CAUZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,KAAK,GAAE;IACnC,gBAAgB,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,GAAG,aAAa,CAuCrB"}
|
|
@@ -24,6 +24,27 @@ const EMPTY_META = {
|
|
|
24
24
|
* blanks.
|
|
25
25
|
*/
|
|
26
26
|
export function FacetPanel(props) {
|
|
27
|
+
return props.children(useFacetPanel({
|
|
28
|
+
...(props.categoryFeatures !== undefined
|
|
29
|
+
? { categoryFeatures: props.categoryFeatures }
|
|
30
|
+
: {}),
|
|
31
|
+
...(props.locale !== undefined ? { locale: props.locale } : {}),
|
|
32
|
+
...(props.enabled !== undefined ? { enabled: props.enabled } : {}),
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The same bag, as a hook — for a caller that has to know what the panel WILL
|
|
37
|
+
* render before it renders it.
|
|
38
|
+
*
|
|
39
|
+
* The one real caller is `<SearchPage>`: a facet column is a quarter of a
|
|
40
|
+
* catalogue page, and on a deployment whose plan has no facets at all it was
|
|
41
|
+
* a quarter of every results page spent on an empty-state illustration
|
|
42
|
+
* repeating "no filters for this search". Whether to lay out that column is a
|
|
43
|
+
* LAYOUT decision, and layout is decided by the component that owns the grid
|
|
44
|
+
* — which therefore has to be able to ask. A render prop cannot answer a
|
|
45
|
+
* question asked one level up.
|
|
46
|
+
*/
|
|
47
|
+
export function useFacetPanel(props = {}) {
|
|
27
48
|
const { state: searchState, setFilter, setRange, clearAll, toggleFilter, activeFilters } = useSearchState();
|
|
28
49
|
const t = useT();
|
|
29
50
|
const query = useSearchQuery(searchState, props.enabled !== undefined ? { enabled: props.enabled } : undefined);
|
|
@@ -39,7 +60,7 @@ export function FacetPanel(props) {
|
|
|
39
60
|
t,
|
|
40
61
|
...(props.locale !== undefined ? { locale: props.locale } : {}),
|
|
41
62
|
}));
|
|
42
|
-
return
|
|
63
|
+
return {
|
|
43
64
|
state: groups,
|
|
44
65
|
approximate: meta.approximate,
|
|
45
66
|
skipped: meta.skipped,
|
|
@@ -52,6 +73,6 @@ export function FacetPanel(props) {
|
|
|
52
73
|
setFilter(slug, []);
|
|
53
74
|
},
|
|
54
75
|
clearAll,
|
|
55
|
-
}
|
|
76
|
+
};
|
|
56
77
|
}
|
|
57
78
|
//# sourceMappingURL=FacetPanel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FacetPanel.js","sourceRoot":"","sources":["../../src/headless/FacetPanel.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAoC1D,MAAM,UAAU,GAAc;IAC5B,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,KAO1B;IACC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,GACtF,cAAc,EAAE,CAAC;IACnB,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC;IACjB,MAAM,KAAK,GAAG,cAAc,CAC1B,WAAW,EACX,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,E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,CAAC,IAAI,EAAE,EAAE,CACxC,gBAAgB,CAAC;QACf,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI,EAAE,IAAI,CAAC,UAAU;QACrB,KAAK,EAAE,WAAW;QAClB,GAAG,CAAC,KAAK,CAAC,gBAAgB,KAAK,SAAS;YACtC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE;YAC9C,CAAC,CAAC,EAAE,CAAC;QACP,CAAC;QACD,GAAG,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC,CACH,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,MAAM;QACb,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,aAAa;QACb,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;YACd,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtB,CAAC;QACD,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SearchCountKind } from "../state/degradations.js";
|
|
2
|
+
export interface AppliedCount {
|
|
3
|
+
/** `null` when the engine cannot say — never rendered as `0`. */
|
|
4
|
+
readonly count: number | null;
|
|
5
|
+
readonly kind: SearchCountKind;
|
|
6
|
+
}
|
|
7
|
+
export declare function useAppliedCount(): AppliedCount;
|
|
8
|
+
//# sourceMappingURL=useAppliedCount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppliedCount.d.ts","sourceRoot":"","sources":["../../src/headless/useAppliedCount.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;CAChC;AAED,wBAAgB,eAAe,IAAI,YAAY,CAc9C"}
|