@stapel/listings-react 0.3.1 → 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 +122 -0
- package/MODULE.md +12 -6
- package/README.md +33 -17
- package/dist/api/generated/schema.d.ts +129 -3
- package/dist/api/generated/schema.d.ts.map +1 -1
- package/dist/api/listingsApi.d.ts +35 -22
- package/dist/api/listingsApi.d.ts.map +1 -1
- package/dist/api/listingsApi.js +17 -0
- package/dist/api/listingsApi.js.map +1 -1
- package/dist/api/types.d.ts +43 -2
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js.map +1 -1
- package/dist/default/FavoritesPane.d.ts +40 -3
- package/dist/default/FavoritesPane.d.ts.map +1 -1
- package/dist/default/FavoritesPane.js +30 -18
- package/dist/default/FavoritesPane.js.map +1 -1
- package/dist/default/ListingCard.d.ts +25 -4
- package/dist/default/ListingCard.d.ts.map +1 -1
- package/dist/default/ListingCard.js +19 -12
- package/dist/default/ListingCard.js.map +1 -1
- package/dist/default/ListingComposerPage.d.ts +163 -23
- package/dist/default/ListingComposerPage.d.ts.map +1 -1
- package/dist/default/ListingComposerPage.js +85 -43
- package/dist/default/ListingComposerPage.js.map +1 -1
- package/dist/default/ListingDetailPane.d.ts +41 -4
- package/dist/default/ListingDetailPane.d.ts.map +1 -1
- package/dist/default/ListingDetailPane.js +38 -25
- package/dist/default/ListingDetailPane.js.map +1 -1
- package/dist/default/ListingPhoto.d.ts +13 -1
- package/dist/default/ListingPhoto.d.ts.map +1 -1
- package/dist/default/ListingPhoto.js +47 -9
- package/dist/default/ListingPhoto.js.map +1 -1
- package/dist/default/ListingPrice.d.ts +13 -0
- package/dist/default/ListingPrice.d.ts.map +1 -0
- package/dist/default/ListingPrice.js +60 -0
- package/dist/default/ListingPrice.js.map +1 -0
- package/dist/default/MyListingsPane.d.ts +9 -17
- package/dist/default/MyListingsPane.d.ts.map +1 -1
- package/dist/default/MyListingsPane.js +148 -63
- package/dist/default/MyListingsPane.js.map +1 -1
- package/dist/default/SignInLink.js +8 -7
- package/dist/default/SignInLink.js.map +1 -1
- package/dist/default/StatusTags.d.ts +16 -5
- package/dist/default/StatusTags.d.ts.map +1 -1
- package/dist/default/StatusTags.js +19 -13
- package/dist/default/StatusTags.js.map +1 -1
- package/dist/default/index.d.ts +15 -9
- package/dist/default/index.d.ts.map +1 -1
- package/dist/default/index.js +13 -6
- package/dist/default/index.js.map +1 -1
- package/dist/headless/Favorites.d.ts +6 -0
- package/dist/headless/Favorites.d.ts.map +1 -1
- package/dist/headless/Favorites.js +4 -0
- package/dist/headless/Favorites.js.map +1 -1
- package/dist/headless/ListingActions.d.ts +12 -0
- package/dist/headless/ListingActions.d.ts.map +1 -1
- package/dist/headless/ListingActions.js +3 -0
- package/dist/headless/ListingActions.js.map +1 -1
- package/dist/headless/ListingComposer.d.ts +23 -0
- package/dist/headless/ListingComposer.d.ts.map +1 -1
- package/dist/headless/ListingComposer.js +33 -7
- package/dist/headless/ListingComposer.js.map +1 -1
- package/dist/headless/MyListings.d.ts +27 -12
- package/dist/headless/MyListings.d.ts.map +1 -1
- package/dist/headless/MyListings.js +29 -7
- package/dist/headless/MyListings.js.map +1 -1
- package/dist/i18n/es.d.ts +6 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +28 -6
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/generated/errors.es.gen.d.ts +1 -1
- package/dist/i18n/generated/errors.es.gen.js +1 -1
- package/dist/i18n/generated/errors.gen.d.ts +6 -0
- package/dist/i18n/generated/errors.gen.d.ts.map +1 -1
- package/dist/i18n/generated/errors.gen.js +3 -0
- package/dist/i18n/generated/errors.gen.js.map +1 -1
- package/dist/i18n/generated/errors.ru.gen.d.ts +1 -1
- package/dist/i18n/generated/errors.ru.gen.js +1 -1
- package/dist/i18n/keys.d.ts +28 -4
- package/dist/i18n/keys.d.ts.map +1 -1
- package/dist/i18n/keys.js +49 -8
- package/dist/i18n/keys.js.map +1 -1
- package/dist/i18n/ru.d.ts +16 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +40 -6
- package/dist/i18n/ru.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/model/draft.d.ts +9 -6
- package/dist/model/draft.d.ts.map +1 -1
- package/dist/model/draft.js +3 -1
- package/dist/model/draft.js.map +1 -1
- package/dist/model/features.d.ts +21 -7
- package/dist/model/features.d.ts.map +1 -1
- package/dist/model/features.js +26 -0
- package/dist/model/features.js.map +1 -1
- package/dist/model/mine.d.ts +44 -0
- package/dist/model/mine.d.ts.map +1 -0
- package/dist/model/mine.js +52 -0
- package/dist/model/mine.js.map +1 -0
- package/dist/model/mineSource.d.ts +39 -34
- package/dist/model/mineSource.d.ts.map +1 -1
- package/dist/model/mineSource.js +10 -41
- package/dist/model/mineSource.js.map +1 -1
- package/dist/model/mutations.d.ts.map +1 -1
- package/dist/model/mutations.js +11 -4
- package/dist/model/mutations.js.map +1 -1
- package/dist/model/queryKeys.d.ts +7 -2
- package/dist/model/queryKeys.d.ts.map +1 -1
- package/dist/model/queryKeys.js +2 -0
- package/dist/model/queryKeys.js.map +1 -1
- package/dist/model/status.d.ts +12 -31
- package/dist/model/status.d.ts.map +1 -1
- package/dist/model/status.js +44 -0
- package/dist/model/status.js.map +1 -1
- package/llms.txt +11 -8
- package/manifest.json +88 -14
- package/nav-manifest.json +1 -1
- package/package.json +17 -12
- package/src/analytics/generated/events.json +1 -1
- package/src/api/generated/schema.ts +129 -3
- package/src/api/listingsApi.ts +60 -21
- package/src/api/types.ts +46 -2
- package/src/default/FavoritesPane.tsx +156 -82
- package/src/default/ListingCard.tsx +88 -46
- package/src/default/ListingComposerPage.tsx +403 -187
- package/src/default/ListingDetailPane.tsx +200 -98
- package/src/default/ListingPhoto.tsx +89 -16
- package/src/default/ListingPrice.tsx +77 -0
- package/src/default/MyListingsPane.tsx +344 -222
- package/src/default/SignInLink.tsx +4 -4
- package/src/default/StatusTags.tsx +36 -18
- package/src/default/index.ts +18 -7
- package/src/headless/Favorites.tsx +10 -0
- package/src/headless/ListingActions.tsx +19 -0
- package/src/headless/ListingComposer.tsx +56 -5
- package/src/headless/MyListings.tsx +62 -22
- package/src/i18n/es.ts +36 -7
- package/src/i18n/generated/errors.es.gen.ts +1 -1
- package/src/i18n/generated/errors.gen.ts +3 -0
- package/src/i18n/generated/errors.json +9 -0
- package/src/i18n/generated/errors.ru.gen.ts +1 -1
- package/src/i18n/keys.ts +58 -9
- package/src/i18n/ru.ts +48 -7
- package/src/index.ts +16 -5
- package/src/model/draft.ts +12 -7
- package/src/model/features.ts +48 -7
- package/src/model/mine.ts +70 -0
- package/src/model/mineSource.ts +46 -41
- package/src/model/mutations.ts +11 -4
- package/src/model/queryKeys.ts +9 -2
- package/src/model/status.ts +15 -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 -25
- package/dist/default/theme.d.ts.map +0 -1
- package/dist/default/theme.js +0 -40
- package/dist/default/theme.js.map +0 -1
- package/src/default/ErrorAlert.tsx +0 -46
- package/src/default/theme.tsx +0 -67
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StapelClient } from "@stapel/core";
|
|
2
|
-
import type { DeleteResponse, FavoriteToggleResponse, ListingActionResponse, ListingDetail, ListingDraft, ListingDraftPatch, ListingPageParams, ListingStatusInfo, MyCounters, PaginatedListingCards, PublishResponse } from "./types.js";
|
|
2
|
+
import type { DeleteResponse, FavoriteToggleResponse, ListingActionResponse, ListingDetail, ListingDraft, ListingDraftPatch, ListingPageParams, ListingStatusInfo, MyCounters, MyListingsParams, PaginatedListingCards, PaginatedMyListingCards, PublishResponse } from "./types.js";
|
|
3
3
|
import type { ValidationBatchResult } from "@stapel/attributes-react";
|
|
4
4
|
/**
|
|
5
5
|
* The pair's typed operation surface — one method per stapel-listings endpoint
|
|
@@ -9,21 +9,16 @@ import type { ValidationBatchResult } from "@stapel/attributes-react";
|
|
|
9
9
|
*
|
|
10
10
|
* ── The two operations that are on the contract and NOT here ───────────────
|
|
11
11
|
*
|
|
12
|
-
* `PUT /{pk}/` and `PATCH /{pk}/` are absent
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* check, so the pair uses it and nothing is lost. Both stay in the generated
|
|
23
|
-
* schema and therefore in `manifest.json` — the contract is not hidden, this
|
|
24
|
-
* pair simply declines to be the client that exercises it. Upstream ask,
|
|
25
|
-
* recorded in MODULE.md: put `_get_own` in front of `update`/`partial_update`
|
|
26
|
-
* (or drop them from the router).
|
|
12
|
+
* `PUT /{pk}/` and `PATCH /{pk}/` are absent. That began as a safety decision:
|
|
13
|
+
* until stapel-listings 0.6.2 both were the plain `ModelViewSet`
|
|
14
|
+
* implementations under `IsAuthenticatedOrReadOnly` over
|
|
15
|
+
* `Listing.objects.all()`, so any authenticated caller could write any
|
|
16
|
+
* listing's draft fields through them — this pair filed the ask and declined
|
|
17
|
+
* to be the client that exercised the hole. 0.6.2 put `views._get_own` in
|
|
18
|
+
* front of both, so the hole is closed and the absence is now a plain scope
|
|
19
|
+
* decision: `POST /{pk}/save-draft/` performs the SAME write (the same
|
|
20
|
+
* `ListingDraftSerializer`, `partial=True`) and one write path is enough.
|
|
21
|
+
* Both stay in the generated schema and therefore in `manifest.json`.
|
|
27
22
|
*
|
|
28
23
|
* These operations will be GENERATED from schema.json operationIds by gen-api
|
|
29
24
|
* v2 (task `core-typed-ops`); until then they are hand-authored here (the ONE
|
|
@@ -54,12 +49,12 @@ export interface ListingsApi {
|
|
|
54
49
|
/**
|
|
55
50
|
* One listing in full.
|
|
56
51
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* `
|
|
61
|
-
*
|
|
62
|
-
*
|
|
52
|
+
* Since 0.6.2 the queryset is `visible_to(user)` — the indexed statuses for
|
|
53
|
+
* everyone plus one's OWN rows in any status — so a stranger's draft 404s
|
|
54
|
+
* from the same code path an absent id does. The `publiclyVisible` report
|
|
55
|
+
* `useListing` derives from `status` (`model/status.ts`) stays, and is now
|
|
56
|
+
* addressed at the one reader who still reaches an unpublished listing
|
|
57
|
+
* here: its owner, who needs to be told it is not on the shelf.
|
|
63
58
|
*/
|
|
64
59
|
retrieve(id: number, options?: {
|
|
65
60
|
readonly signal?: AbortSignal;
|
|
@@ -81,6 +76,24 @@ export interface ListingsApi {
|
|
|
81
76
|
myCounters(options?: {
|
|
82
77
|
readonly signal?: AbortSignal;
|
|
83
78
|
}): Promise<MyCounters>;
|
|
79
|
+
/**
|
|
80
|
+
* One keyset page of the caller's OWN listings, in every status.
|
|
81
|
+
*
|
|
82
|
+
* The route `list` is not and cannot be made into: `list` answers
|
|
83
|
+
* `published()` and takes no owner parameter, so before stapel-listings
|
|
84
|
+
* 0.7.0 a seller's own DRAFTS were unreachable by any call this contract
|
|
85
|
+
* offered — the gap `model/mineSource.ts` used to name on screen. Owner
|
|
86
|
+
* scope is a property of the ROUTE (`owned_by(request.user)`), not of a
|
|
87
|
+
* parameter a caller supplies, so there is no way to point it at anyone
|
|
88
|
+
* else.
|
|
89
|
+
*
|
|
90
|
+
* `params.status` narrows to a set of lifecycle statuses; omit it for all
|
|
91
|
+
* nine. Rows are {@link MyListingCard} — the public card plus
|
|
92
|
+
* `moderation_status` and the `*_draft` twins.
|
|
93
|
+
*/
|
|
94
|
+
myListings(params?: MyListingsParams, options?: {
|
|
95
|
+
readonly signal?: AbortSignal;
|
|
96
|
+
}): Promise<PaginatedMyListingCards>;
|
|
84
97
|
/** One keyset page of the caller's favourites. */
|
|
85
98
|
myFavorites(params?: ListingPageParams, options?: {
|
|
86
99
|
readonly signal?: AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listingsApi.d.ts","sourceRoot":"","sources":["../../src/api/listingsApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,qBAAqB,EACrB,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"listingsApi.d.ts","sourceRoot":"","sources":["../../src/api/listingsApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B;;;;;;;;;;;;;;;;OAgBG;IACH,IAAI,CACF,MAAM,CAAC,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAC1C,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAElC;;;;;;;;;OASG;IACH,QAAQ,CACN,EAAE,EAA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EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE9C;oEACgE;IAChE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAEpD,uDAAuD;IACvD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAErD,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAEtD,oEAAoE;IACpE,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAExD;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC7C;AAwCD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CA8CnE"}
|
package/dist/api/listingsApi.js
CHANGED
|
@@ -5,6 +5,19 @@ function pageQuery(params) {
|
|
|
5
5
|
...(params?.limit !== undefined ? { limit: params.limit } : {}),
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* The `?status=` half of a `my/listings` query.
|
|
10
|
+
*
|
|
11
|
+
* One comma-separated value rather than a repeated parameter: both spellings
|
|
12
|
+
* are accepted upstream, and this one survives every `query` serializer a
|
|
13
|
+
* host's `StapelClient` might carry without depending on how it encodes an
|
|
14
|
+
* array. An empty set sends nothing at all — the route's own "every status".
|
|
15
|
+
*/
|
|
16
|
+
function statusQuery(statuses) {
|
|
17
|
+
return statuses !== undefined && statuses.length > 0
|
|
18
|
+
? { status: statuses.join(",") }
|
|
19
|
+
: {};
|
|
20
|
+
}
|
|
8
21
|
function signal(options) {
|
|
9
22
|
return options?.signal !== undefined ? { signal: options.signal } : {};
|
|
10
23
|
}
|
|
@@ -20,6 +33,10 @@ export function createListingsApi(client) {
|
|
|
20
33
|
retrieve: (id, options) => client.get(listingPath(id), signal(options)),
|
|
21
34
|
status: (id, options) => client.get(`${listingPath(id)}status/`, signal(options)),
|
|
22
35
|
myCounters: (options) => client.get(`${COLLECTION}my/counters/`, signal(options)),
|
|
36
|
+
myListings: (params, options) => client.get(`${COLLECTION}my/listings/`, {
|
|
37
|
+
query: { ...pageQuery(params), ...statusQuery(params?.status) },
|
|
38
|
+
...signal(options),
|
|
39
|
+
}),
|
|
23
40
|
myFavorites: (params, options) => client.get(`${COLLECTION}my/favorites/`, {
|
|
24
41
|
query: pageQuery(params),
|
|
25
42
|
...signal(options),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listingsApi.js","sourceRoot":"","sources":["../../src/api/listingsApi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listingsApi.js","sourceRoot":"","sources":["../../src/api/listingsApi.ts"],"names":[],"mappings":"AA+LA,SAAS,SAAS,CAChB,MAAqC;IAErC,OAAO;QACL,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAClE,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3E,GAAG,CAAC,MAAM,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,WAAW,CAClB,QAAuC;IAEvC,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAClD,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACh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W,CAAC,EAAE,CAAC,aAAa,CAAC;QAEhE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;KAC/C,CAAC;AACJ,CAAC"}
|
package/dist/api/types.d.ts
CHANGED
|
@@ -60,8 +60,31 @@ export type ListingActionResponse = Schemas["ListingActionResponse"];
|
|
|
60
60
|
export type FavoriteToggleResponse = Schemas["FavoriteToggleResponse"];
|
|
61
61
|
/** `DELETE /{pk}/` 200. */
|
|
62
62
|
export type DeleteResponse = Schemas["DeleteResponse"];
|
|
63
|
-
/** The keyset envelope both card lists come back in
|
|
63
|
+
/** The keyset envelope both public card lists come back in
|
|
64
|
+
* (`IDAnchorPagination`). */
|
|
64
65
|
export type PaginatedListingCards = Schemas["PaginatedListingCardList"];
|
|
66
|
+
/**
|
|
67
|
+
* One row of `GET /listings/my/listings/` — the OWNER's card.
|
|
68
|
+
*
|
|
69
|
+
* A superset of {@link ListingCard}, and the two additions are the two things
|
|
70
|
+
* only an owner is owed (stapel-listings 0.7.0, `MyListingCardSerializer`):
|
|
71
|
+
*
|
|
72
|
+
* - `moderation_status`, the second axis. `model/status.ts` argues at length
|
|
73
|
+
* that a dashboard cannot derive "your edit is being screened" from
|
|
74
|
+
* `status` — a re-published LIVE listing keeps `status: "published"` and
|
|
75
|
+
* moves only this field. The public card omits it, so before 0.7.0 the
|
|
76
|
+
* dashboard row passed `"approved"` as an honest stand-in and simply could
|
|
77
|
+
* not show the row that most needed showing.
|
|
78
|
+
* - the `*_draft` twins. `title`/`price`/`images` are the PUBLISHED fields
|
|
79
|
+
* and are empty on a listing that has never been published, so a drafts
|
|
80
|
+
* tab keyed off them is a column of blank rows. `myListingTitle` /
|
|
81
|
+
* `myListingPrice` (`model/mine.ts`) are the one place the fallback lives.
|
|
82
|
+
*/
|
|
83
|
+
export type MyListingCard = Schemas["MyListingCard"];
|
|
84
|
+
/** The keyset envelope `GET /listings/my/listings/` comes back in — the same
|
|
85
|
+
* `IDAnchorPagination` shape as {@link PaginatedListingCards}, over the owner
|
|
86
|
+
* row. */
|
|
87
|
+
export type PaginatedMyListingCards = Schemas["PaginatedMyListingCardList"];
|
|
65
88
|
/**
|
|
66
89
|
* The nine lifecycle states, as `models.ListingStatus` declares them.
|
|
67
90
|
*
|
|
@@ -136,13 +159,31 @@ export interface ListingFeatureView {
|
|
|
136
159
|
/** Re-exported so a consumer types a feature config without also depending on
|
|
137
160
|
* `@stapel/attributes-react` directly. */
|
|
138
161
|
export type { FeatureConfig, FeatureDef, FeatureValueDto };
|
|
139
|
-
/** Query parameters of
|
|
162
|
+
/** Query parameters of every keyset-paginated card list. */
|
|
140
163
|
export interface ListingPageParams {
|
|
141
164
|
/** Opaque cursor from a previous answer. */
|
|
142
165
|
readonly anchor?: string;
|
|
143
166
|
readonly direction?: "next" | "prev" | "center";
|
|
144
167
|
readonly limit?: number;
|
|
145
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* `GET /listings/my/listings/` — a page, plus the statuses to narrow to.
|
|
171
|
+
*
|
|
172
|
+
* `status` is a SET because a dashboard tab is one (`active` is
|
|
173
|
+
* `published` + `pending`, `drafts` is `draft` + `rejected` — the groupings
|
|
174
|
+
* are the server's, copied in `model/status.ts` so a tab's rows and its count
|
|
175
|
+
* cannot describe different sets). An empty or absent array means every
|
|
176
|
+
* status, which is what the route answers with no parameter at all.
|
|
177
|
+
*
|
|
178
|
+
* On the wire it goes as one comma-separated value; stapel-listings accepts
|
|
179
|
+
* that and the repeated-parameter spelling interchangeably
|
|
180
|
+
* (`views.parse_status_filter`). An unknown value is a `400`
|
|
181
|
+
* `error.400.listing_invalid_status_filter`, not an empty page — so a status
|
|
182
|
+
* this pair does not know about cannot silently look like "you have none".
|
|
183
|
+
*/
|
|
184
|
+
export interface MyListingsParams extends ListingPageParams {
|
|
185
|
+
readonly status?: readonly ListingLifecycleStatus[];
|
|
186
|
+
}
|
|
146
187
|
/**
|
|
147
188
|
* The currency a composer starts a new listing in.
|
|
148
189
|
*
|
package/dist/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,4EAA4E;AAC5E,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;AAE5C,kEAAkE;AAClE,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAErD,gFAAgF;AAChF,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEjD;;yCAEyC;AACzC,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;AAEnD,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAE/D;uEACuE;AACvE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAEzD,gEAAgE;AAChE,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAEvD;iDACiD;AACjD,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEzD,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;AAErE,6CAA6C;AAC7C,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAEvE,2BAA2B;AAC3B,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAEvD
|
|
1
|
+
{"version":3,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AAM,GAAG,OAAO,CAAC;CACjC;AAED,yEAAyE;AACzE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,CAAC;CAC7C;AAED;0CAC0C;AAC1C,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AAE3D,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;IAChD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;CACrD;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,QAAQ,CAAC"}
|
package/dist/api/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAsGA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,OAAO;IACP,SAAS;IACT,WAAW;IACX,QAAQ;IACR,SAAS;IACT,MAAM;IACN,UAAU;IACV,SAAS;IACT,UAAU;CACX,CAAC;AAMF;gEACgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAuC;IACrE,SAAS;IACT,UAAU;IACV,UAAU;IACV,cAAc;CACf,CAAC;AA+FF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC"}
|
|
@@ -6,10 +6,37 @@
|
|
|
6
6
|
* "You have not saved anything yet" and "we could not load your favourites"
|
|
7
7
|
* are the pair a `data ?? []` would have merged, and merging them is exactly
|
|
8
8
|
* the substitution that cost the fleet an incident (spec §7.4).
|
|
9
|
+
*
|
|
10
|
+
* ── A visitor is told ONE thing ────────────────────────────────────────────
|
|
11
|
+
*
|
|
12
|
+
* `useFavorites` disables the query without a mandate, so a visitor's `rows`
|
|
13
|
+
* sit in `loading` forever — and the pane rendered the blocked notice AND the
|
|
14
|
+
* spinner underneath it, saying "you cannot see this" and "we are fetching it"
|
|
15
|
+
* at the same time, with no sign-in link anywhere on the screen. The gate is
|
|
16
|
+
* now the WHOLE body: one designed state, with the door the container supplies
|
|
17
|
+
* (`signIn`) inside it, and nothing else drawn.
|
|
18
|
+
*
|
|
19
|
+
* The pager obeys the same rule. `Previous`/`Next` were rendered disabled in
|
|
20
|
+
* every state including empty, failed and blocked — two controls that meant
|
|
21
|
+
* nothing, three times over. They render when there is a page to go to.
|
|
22
|
+
*
|
|
23
|
+
* And each one renders only when ITS page exists. The keyset gates name the
|
|
24
|
+
* missing page with the button's own label key, so a blocked `Previous` drew
|
|
25
|
+
* the word twice — once as a dead button, once as its own "reason". A pager
|
|
26
|
+
* does not explain itself: the page indicator says where you are, and a
|
|
27
|
+
* direction with nowhere to go is simply not drawn.
|
|
9
28
|
*/
|
|
10
|
-
import type { ReactElement } from "react";
|
|
11
|
-
import type { LinkComponent } from "@stapel/core";
|
|
29
|
+
import type { ReactElement, ReactNode } from "react";
|
|
30
|
+
import type { LinkComponent, SignInCtaProp } from "@stapel/core";
|
|
12
31
|
import type { ThemeModeProp } from "./types.js";
|
|
32
|
+
/** The narrowest a card may get before the grid drops a column — the same
|
|
33
|
+
* element-relative rule the detail gallery uses. It was `width: 240`, which
|
|
34
|
+
* left two cards floating in a 2560px pane and overflowed a 390px one. */
|
|
35
|
+
export declare const FAVORITES_CARD_MIN = "15rem";
|
|
36
|
+
/** How wide the saved grid may get before it stops being a grid and becomes
|
|
37
|
+
* three cards adrift in a 1280px window. A measure, not a breakpoint: the
|
|
38
|
+
* cards keep filling it, and past it the page centres. */
|
|
39
|
+
export declare const FAVORITES_MEASURE = "72rem";
|
|
13
40
|
/** How a card in this grid opens — the same one-contract union `<ListingCard>`
|
|
14
41
|
* takes, one level up, so a pane cannot re-introduce the double navigation the
|
|
15
42
|
* card no longer allows. */
|
|
@@ -28,6 +55,16 @@ export type FavoritesPaneOpenProps = {
|
|
|
28
55
|
readonly onOpen?: undefined;
|
|
29
56
|
readonly linkComponent?: undefined;
|
|
30
57
|
};
|
|
31
|
-
|
|
58
|
+
/** The way OUT of an empty favourites list. */
|
|
59
|
+
export interface FavoritesBrowseCtaProp {
|
|
60
|
+
/**
|
|
61
|
+
* What a person with nothing saved can do next — a "Browse listings"
|
|
62
|
+
* button, supplied by the container because only it knows where the
|
|
63
|
+
* catalogue lives. An empty state without one is a dead end, and this
|
|
64
|
+
* screen was one of four sharing a single stock illustration and no exit.
|
|
65
|
+
*/
|
|
66
|
+
readonly browseCta?: ReactNode;
|
|
67
|
+
}
|
|
68
|
+
export type FavoritesPaneProps = ThemeModeProp & SignInCtaProp & FavoritesBrowseCtaProp & FavoritesPaneOpenProps;
|
|
32
69
|
export declare function FavoritesPane(props: FavoritesPaneProps): ReactElement;
|
|
33
70
|
//# sourceMappingURL=FavoritesPane.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritesPane.d.ts","sourceRoot":"","sources":["../../src/default/FavoritesPane.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"FavoritesPane.d.ts","sourceRoot":"","sources":["../../src/default/FavoritesPane.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAQrD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,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/jsx-runtime";
|
|
2
|
+
import { Button, Flex, Typography } from "antd";
|
|
3
|
+
import { EmptyState, ErrorAlert, SkinTheme, } from "@stapel/tokens-antd/skin";
|
|
4
|
+
import { matchList, useT } from "@stapel/core";
|
|
5
|
+
import { spacing } from "@stapel/tokens";
|
|
4
6
|
import { useFavorites } from "../headless/Favorites.js";
|
|
5
7
|
import { LISTINGS_I18N_KEYS } from "../i18n/keys.js";
|
|
6
|
-
import { ErrorAlert } from "./ErrorAlert.js";
|
|
7
8
|
import { ListingCard } from "./ListingCard.js";
|
|
8
|
-
import {
|
|
9
|
+
import { SignInLink } from "./SignInLink.js";
|
|
10
|
+
/** The narrowest a card may get before the grid drops a column — the same
|
|
11
|
+
* element-relative rule the detail gallery uses. It was `width: 240`, which
|
|
12
|
+
* left two cards floating in a 2560px pane and overflowed a 390px one. */
|
|
13
|
+
export const FAVORITES_CARD_MIN = "15rem";
|
|
14
|
+
/** How wide the saved grid may get before it stops being a grid and becomes
|
|
15
|
+
* three cards adrift in a 1280px window. A measure, not a breakpoint: the
|
|
16
|
+
* cards keep filling it, and past it the page centres. */
|
|
17
|
+
export const FAVORITES_MEASURE = "72rem";
|
|
9
18
|
/** The card's own open props for one row. One arm, never two. */
|
|
10
19
|
function cardOpenProps(props, id) {
|
|
11
20
|
if (props.hrefFor !== undefined) {
|
|
@@ -20,19 +29,22 @@ function cardOpenProps(props, id) {
|
|
|
20
29
|
}
|
|
21
30
|
export function FavoritesPane(props) {
|
|
22
31
|
const t = useT();
|
|
23
|
-
const describe = useDescribeFlowError();
|
|
24
32
|
const bag = useFavorites();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
status:
|
|
31
|
-
message:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
const paged = bag.prevPage.available || bag.nextPage.available;
|
|
34
|
+
return (_jsx(SkinTheme, { surface: "base", style: { padding: spacing[4], maxWidth: FAVORITES_MEASURE }, ...(props.mode !== undefined ? { mode: props.mode } : {}), children: _jsxs(Flex, { vertical: true, gap: spacing[4], "data-testid": "listings-favorites", children: [_jsx(Typography.Title, { level: 3, children: t(LISTINGS_I18N_KEYS.favoritesTitle) }), !bag.gate.available ? (
|
|
35
|
+
// The whole body, not a banner over a spinner. A blocked screen has
|
|
36
|
+
// one state and it carries its own way out.
|
|
37
|
+
_jsx(EmptyState, { testId: "listings-favorites-blocked", title: t(bag.gate.block.code, bag.gate.block.params), hint: t(LISTINGS_I18N_KEYS.favoritesSignInHint), action: _jsx(SignInLink, { cta: props.signIn, testId: "listings-favorites-sign-in" }) })) : (_jsxs(_Fragment, { children: [matchList(bag.rows, {
|
|
38
|
+
loading: () => (_jsx("div", { role: "status", "aria-busy": "true", "aria-label": t(LISTINGS_I18N_KEYS.favoritesLoading), "data-testid": "listings-favorites-loading", "data-stapel-load-state": "loading" })),
|
|
39
|
+
failed: (error) => (_jsx(ErrorAlert, { testId: "listings-favorites-error", thrown: error, message: t(LISTINGS_I18N_KEYS.favoritesLoadFailed), onRetry: bag.refetch, retryLabel: t(LISTINGS_I18N_KEYS.mineRetry) })),
|
|
40
|
+
empty: () => (_jsx(EmptyState, { testId: "listings-favorites-empty", title: t(LISTINGS_I18N_KEYS.favoritesEmpty), hint: t(LISTINGS_I18N_KEYS.favoritesEmptyHint), ...(props.browseCta !== undefined
|
|
41
|
+
? { action: props.browseCta }
|
|
42
|
+
: {}) })),
|
|
43
|
+
ready: (rows) => (_jsx("div", { "data-testid": "listings-favorites-grid", style: {
|
|
44
|
+
display: "grid",
|
|
45
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${FAVORITES_CARD_MIN}, 1fr))`,
|
|
46
|
+
gap: spacing[4],
|
|
47
|
+
}, children: rows.map((row) => (_jsx(ListingCard, { listing: row, blockedReason: "line", ...(props.signIn !== undefined ? { signIn: props.signIn } : {}), ...cardOpenProps(props, row.id) }, row.id))) })),
|
|
48
|
+
}), paged ? (_jsxs(Flex, { gap: spacing[3], wrap: true, align: "center", children: [bag.prevPage.available ? (_jsx(Button, { size: "small", "data-testid": "listings-favorites-prev", "data-analytics": "none", "data-analytics-reason": "paging a list the person is already reading; not a business action", onClick: bag.goPrev, children: t(LISTINGS_I18N_KEYS.pagePrev) })) : null, _jsx(Typography.Text, { type: "secondary", "data-testid": "listings-favorites-page", children: t(LISTINGS_I18N_KEYS.pageIndicator, { page: bag.pageNumber }) }), bag.nextPage.available ? (_jsx(Button, { size: "small", "data-testid": "listings-favorites-next", "data-analytics": "none", "data-analytics-reason": "paging a list the person is already reading; not a business action", onClick: bag.goNext, children: t(LISTINGS_I18N_KEYS.pageNext) })) : null] })) : null] }))] }) }));
|
|
37
49
|
}
|
|
38
50
|
//# sourceMappingURL=FavoritesPane.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FavoritesPane.js","sourceRoot":"","sources":["../../src/default/FavoritesPane.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"FavoritesPane.js","sourceRoot":"","sources":["../../src/default/FavoritesPane.tsx"],"names":[],"mappings":";AA6BA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EACL,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;0EAE0E;AAC1E,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CA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,CAAC,SAAS,CAAC,CAAC,CAAC,CACxB,KAAC,MAAM,IACL,IAAI,EAAC,OAAO,iBACA,yBAAyB,oBACtB,MAAM,2BACC,oEAAoE,EAC1F,OAAO,EAAE,GAAG,CAAC,MAAM,YAElB,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GACxB,CACV,CAAC,CAAC,CAAC,IAAI,IACH,CACR,CAAC,CAAC,CAAC,IAAI,IACP,CACJ,IACI,GACG,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -22,14 +22,17 @@
|
|
|
22
22
|
* card. That property is the whole reason the projection exists, and it is
|
|
23
23
|
* what makes a grid of forty cards cost one query.
|
|
24
24
|
*
|
|
25
|
-
* ── The heart is never hidden
|
|
25
|
+
* ── The heart is never hidden, and never explained by hover ────────────────
|
|
26
26
|
*
|
|
27
27
|
* A visitor sees it, blocked, with the reason IN WORDS beside it and the
|
|
28
28
|
* sign-in link the container supplies (`signIn`, typically `?next=<current>`).
|
|
29
29
|
* Hiding it would teach nobody that favourites exist (private-space canon
|
|
30
|
-
* §6.3, spec §6.2 item 6)
|
|
31
|
-
*
|
|
32
|
-
*
|
|
30
|
+
* §6.3, spec §6.2 item 6). The reason itself goes through the shared
|
|
31
|
+
* `<GatedControl>`, which renders it as text linked by `aria-describedby` —
|
|
32
|
+
* a disabled antd button receives no pointer events and is not focusable, so
|
|
33
|
+
* the `Tooltip` this component used to offer as a "quieter" volume was a
|
|
34
|
+
* reason nobody could read on any device. That arm is gone; `blockedReason`
|
|
35
|
+
* is now "text" (reason + door) or "line" (reason alone, for a grid).
|
|
33
36
|
*/
|
|
34
37
|
import type { ReactElement, ReactNode } from "react";
|
|
35
38
|
import type { LinkComponent, SignInCtaProp } from "@stapel/core";
|
|
@@ -71,8 +74,26 @@ export type ListingCardOpenProps = {
|
|
|
71
74
|
readonly onOpen?: undefined;
|
|
72
75
|
readonly linkComponent?: undefined;
|
|
73
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* How loudly a blocked favourite states its reason on THIS surface.
|
|
79
|
+
*
|
|
80
|
+
* `"text"` (the default) is the sentence under the controls, with the sign-in
|
|
81
|
+
* door beside it — the right volume for a card that stands alone.
|
|
82
|
+
*
|
|
83
|
+
* `"line"` collapses it to the reason alone, no door: a grid of forty cards
|
|
84
|
+
* repeating "sign in to do this — sign in" forty times is not forty pieces of
|
|
85
|
+
* help, it is the loudest thing on the page, and every one of those doors
|
|
86
|
+
* leads where the header's own sign-in button already leads.
|
|
87
|
+
*
|
|
88
|
+
* There is no third setting. The reason is on screen in both, because the only
|
|
89
|
+
* way to make it quieter than a line of text is to hide it behind hover, and
|
|
90
|
+
* hover does not exist on the device most of these cards are read on.
|
|
91
|
+
*/
|
|
92
|
+
export type ListingCardBlockedReason = "text" | "line";
|
|
74
93
|
export interface ListingCardBaseProps extends ThemeModeProp, SignInCtaProp {
|
|
75
94
|
readonly listing: ListingCardData;
|
|
95
|
+
/** See {@link ListingCardBlockedReason}. Default `"text"`. */
|
|
96
|
+
readonly blockedReason?: ListingCardBlockedReason;
|
|
76
97
|
/** Extra chrome the container adds (a `promoted` tag from search, say —
|
|
77
98
|
* DSA Art. 26 marking belongs to the pair that receives it). */
|
|
78
99
|
readonly badge?: ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListingCard.d.ts","sourceRoot":"","sources":["../../src/default/ListingCard.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ListingCard.d.ts","sourceRoot":"","sources":["../../src/default/ListingCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIrD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAStE,OAAO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xs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Card, Flex,
|
|
2
|
+
import { Button, Card, Flex, Typography } from "antd";
|
|
3
|
+
import { GatedControl, SkinTheme } from "@stapel/tokens-antd/skin";
|
|
3
4
|
import { useActionGate, useT } from "@stapel/core";
|
|
5
|
+
import { spacing } from "@stapel/tokens";
|
|
4
6
|
import { FeatureBadges } from "@stapel/attributes-react/default";
|
|
5
7
|
import { asFeatureDaoList, featuresDtoFromDaoList, featuresFromDaoList } from "../model/features.js";
|
|
6
8
|
import { lifecycleCaption } from "../model/status.js";
|
|
@@ -9,13 +11,18 @@ import { LISTINGS_I18N_KEYS } from "../i18n/keys.js";
|
|
|
9
11
|
import { HeartIcon } from "./icons.js";
|
|
10
12
|
import { SignInLink } from "./SignInLink.js";
|
|
11
13
|
import { ListingPhoto } from "./ListingPhoto.js";
|
|
12
|
-
import {
|
|
14
|
+
import { ListingPrice } from "./ListingPrice.js";
|
|
13
15
|
/**
|
|
14
16
|
* The one control that opens the card: an anchor, a button, or nothing.
|
|
15
17
|
*
|
|
16
18
|
* Exactly one of the three renders, so exactly one navigation happens per
|
|
17
19
|
* click. That is the whole fix — the branch below has no arm in which both a
|
|
18
20
|
* handler and an `href` reach the DOM.
|
|
21
|
+
*
|
|
22
|
+
* It is the card's PRIMARY action and is drawn as one: a full-width button,
|
|
23
|
+
* which on a phone is 44px tall because `SkinTheme` sets antd's
|
|
24
|
+
* `controlHeight` there. It was a bare text link beside a 40px icon button,
|
|
25
|
+
* with no hierarchy between them and neither one a real touch target.
|
|
19
26
|
*/
|
|
20
27
|
function OpenControl(props) {
|
|
21
28
|
const t = useT();
|
|
@@ -27,11 +34,11 @@ function OpenControl(props) {
|
|
|
27
34
|
// element around a link is a click target that is not the link. A host
|
|
28
35
|
// that wants the antd look styles its own `<Link>` — it is one component,
|
|
29
36
|
// written once, and it is already the thing that knows the design system.
|
|
30
|
-
return Link !== undefined ? (_jsx(Link, { href: props.href, "aria-label": label, "data-testid": "listings-card-open", "data-analytics": "none", "data-analytics-reason": "business action \u2014 host app wraps with its own tracked()", children: label })) : (_jsx(Button, {
|
|
37
|
+
return Link !== undefined ? (_jsx(Link, { href: props.href, "aria-label": label, "data-testid": "listings-card-open", "data-analytics": "none", "data-analytics-reason": "business action \u2014 host app wraps with its own tracked()", children: label })) : (_jsx(Button, { type: "primary", block: true, href: props.href, "data-testid": "listings-card-open", "data-analytics": "none", "data-analytics-reason": "business action \u2014 host app wraps with its own tracked()", children: label }));
|
|
31
38
|
}
|
|
32
39
|
if (props.onOpen !== undefined) {
|
|
33
40
|
const onOpen = props.onOpen;
|
|
34
|
-
return (_jsx(Button, {
|
|
41
|
+
return (_jsx(Button, { type: "primary", block: true, "data-testid": "listings-card-open", "data-analytics": "none", "data-analytics-reason": "business action \u2014 host app wraps with its own tracked()", onClick: () => {
|
|
35
42
|
onOpen(props.listingId);
|
|
36
43
|
}, children: label }));
|
|
37
44
|
}
|
|
@@ -46,19 +53,19 @@ export function ListingCard(props) {
|
|
|
46
53
|
const badgeValues = featuresDtoFromDaoList(badgeDaos);
|
|
47
54
|
const titleDaos = asFeatureDaoList(listing.features_title);
|
|
48
55
|
const status = listing.status === undefined ? undefined : lifecycleCaption(listing.status);
|
|
49
|
-
const price = listing.price !== undefined && listing.price.length > 0
|
|
50
|
-
? `${listing.price} ${listing.currency ?? ""}`.trim()
|
|
51
|
-
: t(LISTINGS_I18N_KEYS.cardPriceAbsent);
|
|
52
56
|
const favoriteGate = useActionGate(favorite.gate);
|
|
57
|
+
const blockedReason = props.blockedReason ?? "text";
|
|
53
58
|
const favoriteLabel = t(favorite.favorited
|
|
54
59
|
? LISTINGS_I18N_KEYS.cardFavoriteRemove
|
|
55
60
|
: LISTINGS_I18N_KEYS.cardFavoriteAdd);
|
|
56
|
-
return (_jsx(
|
|
61
|
+
return (_jsx(SkinTheme, { surface: "bare", ...(props.mode !== undefined ? { mode: props.mode } : {}), children: _jsx(Card, { size: "small", "data-testid": "listings-card", "data-listing-id": listing.id, ...(status !== undefined
|
|
57
62
|
? { "data-listing-status": status.status }
|
|
58
|
-
: {}), cover: _jsx(ListingPhoto, { imageRef: listing.images?.[0], alt: listing.title ?? String(listing.id)
|
|
63
|
+
: {}), styles: { body: { minWidth: 0 } }, cover: _jsx(ListingPhoto, { imageRef: listing.images?.[0], alt: listing.title ?? String(listing.id) }), children: _jsxs(Flex, { vertical: true, gap: spacing[1], style: { minWidth: 0 }, children: [props.badge, _jsx(Typography.Text, { strong: true, "data-testid": "listings-card-price", children: _jsx(ListingPrice, { amount: listing.price, ...(listing.currency !== undefined ? { currency: listing.currency } : {}) }) }), _jsx(Typography.Text, { ellipsis: true, "data-testid": "listings-card-title", children: listing.title ?? "" }), titleDaos.length > 0 ? (_jsx(Typography.Text, { type: "secondary", ellipsis: true, children: _jsx(FeatureBadges, { features: featuresFromDaoList(titleDaos)
|
|
59
64
|
.map((view) => view.feature), values: featuresDtoFromDaoList(titleDaos) }) })) : null, badgeFeatures.length > 0 ? (_jsx(FeatureBadges, { features: badgeFeatures.map((view) => view.feature), values: badgeValues })) : null, listing.location_label !== undefined &&
|
|
60
|
-
listing.location_label.length > 0 ? (_jsx(Typography.Text, { type: "secondary", "data-testid": "listings-card-location", children: listing.location_label })) : null, _jsxs(Flex, { gap:
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
listing.location_label.length > 0 ? (_jsx(Typography.Text, { type: "secondary", "data-testid": "listings-card-location", children: listing.location_label })) : null, props.showFavorite === false ? (_jsx(OpenControl, { ...props, listingId: listing.id })) : (_jsx(GatedControl, { gate: favorite.gate, testId: "listings-card-actions", style: { width: "100%" }, children: (bind) => (_jsxs(Flex, { gap: spacing[2], align: "center", style: { width: "100%", minWidth: 0 }, children: [_jsx("div", { style: { flex: "1 1 auto", minWidth: 0 }, children: _jsx(OpenControl, { ...props, listingId: listing.id }) }), _jsx(Button, { disabled: bind.disabled, "data-disabled-reason": "the enclosing <GatedControl> renders the gate's reason beside this button", ...(bind["aria-describedby"] !== undefined
|
|
66
|
+
? { "aria-describedby": bind["aria-describedby"] }
|
|
67
|
+
: {}), "aria-label": favoriteLabel, "aria-pressed": favorite.favorited, "data-testid": "listings-card-favorite", "data-favorited": String(favorite.favorited), "data-analytics": "none", "data-analytics-reason": "business action \u2014 host app wraps with its own tracked()", onClick: favorite.toggle, icon: _jsx(HeartIcon, { filled: favorite.favorited }) })] })) })), props.showFavorite === false ||
|
|
68
|
+
favoriteGate.reason === undefined ||
|
|
69
|
+
blockedReason === "line" ? null : (_jsx(Typography.Text, { type: "secondary", "data-testid": "listings-card-favorite-blocked", children: _jsx(SignInLink, { cta: props.signIn, testId: "listings-card-sign-in" }) }))] }) }) }));
|
|
63
70
|
}
|
|
64
71
|
//# sourceMappingURL=ListingCard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListingCard.js","sourceRoot":"","sources":["../../src/default/ListingCard.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ListingCard.js","sourceRoot":"","sources":["../../src/default/ListingCard.tsx"],"names":[],"mappings":";AAqCA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,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