@terrafirmagreg-team/recipe 1.2.1 → 1.2.3
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/package.json +6 -7
- package/src/components/cards/slot-hitbox.tsx +2 -2
- package/src/components/embed-card.tsx +1 -0
- package/src/components/tree.tsx +4 -4
- package/src/components/views/browser/card-grid.tsx +5 -3
- package/src/components/views/browser/frame.tsx +3 -2
- package/src/components/views/browser/index.tsx +21 -0
- package/src/components/views/browser/item-panel/index.tsx +4 -3
- package/src/components/views/browser/item-view/index.tsx +4 -3
- package/src/components/views/browser/item-view/tags.tsx +4 -2
- package/src/components/views/browser/query-controls.tsx +5 -6
- package/src/components/views/browser/type-view.tsx +7 -6
- package/src/components/views/landing.tsx +32 -0
- package/src/components/views/layout.tsx +14 -0
- package/src/hooks/alloy/use-mix-state.ts +4 -2
- package/src/hooks/calc/use-data.ts +1 -2
- package/src/hooks/calc/use-share.ts +4 -4
- package/src/hooks/use-add-to-calc.ts +5 -3
- package/src/hooks/use-item-pane.ts +3 -4
- package/src/hooks/use-item-press.ts +3 -4
- package/src/hooks/use-query.ts +10 -9
- package/src/hooks/use-session.ts +7 -3
- package/src/hooks/use-type-filter.ts +6 -5
- package/src/lib/source.ts +13 -0
- package/styles/calc.css +308 -308
- package/src/locales/en_us.json +0 -172
- package/src/locales/ru_ru.json +0 -172
- package/src/locales.ts +0 -6
package/src/hooks/use-query.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
|
|
|
3
3
|
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
5
|
import { useLocationSearchParams } from '@terrafirmagreg-team/ui/hooks/page/use-location-search';
|
|
6
|
+
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
6
7
|
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
7
8
|
import {
|
|
8
9
|
recipeCalcHref,
|
|
@@ -10,7 +11,6 @@ import {
|
|
|
10
11
|
recipePlaceFromParams,
|
|
11
12
|
} from '@terrafirmagreg-team/recipe/lib/links';
|
|
12
13
|
import { canonicalStackId } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
|
|
13
|
-
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
14
14
|
import type { RecipeRelation } from '@terrafirmagreg-team/recipe/types';
|
|
15
15
|
|
|
16
16
|
function urlPage(params: URLSearchParams, key: string) {
|
|
@@ -25,8 +25,9 @@ function urlRelation(
|
|
|
25
25
|
return value === 'uses' || value === 'tags' ? value : undefined;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export function useRecipeQuery(dataset: DatasetRef
|
|
28
|
+
export function useRecipeQuery(dataset: DatasetRef) {
|
|
29
29
|
const params = useLocationSearchParams();
|
|
30
|
+
const resolved = useResolvedLang();
|
|
30
31
|
|
|
31
32
|
const place = recipePlaceFromParams(params);
|
|
32
33
|
const isCalc = place.kind === 'calc';
|
|
@@ -79,8 +80,8 @@ export function useRecipeQuery(dataset: DatasetRef, lang: Lang) {
|
|
|
79
80
|
if (!stray) return;
|
|
80
81
|
replaceUrlState(
|
|
81
82
|
isCalc
|
|
82
|
-
? recipeCalcHref(dataset,
|
|
83
|
-
: recipeHref(dataset,
|
|
83
|
+
? recipeCalcHref(dataset, resolved, tree || undefined)
|
|
84
|
+
: recipeHref(dataset, resolved, {
|
|
84
85
|
tool: place.kind,
|
|
85
86
|
id: recipeId,
|
|
86
87
|
unit: alloyUnit,
|
|
@@ -92,7 +93,7 @@ export function useRecipeQuery(dataset: DatasetRef, lang: Lang) {
|
|
|
92
93
|
isTool,
|
|
93
94
|
isCalc,
|
|
94
95
|
place.kind,
|
|
95
|
-
|
|
96
|
+
resolved,
|
|
96
97
|
dataset,
|
|
97
98
|
params,
|
|
98
99
|
tree,
|
|
@@ -107,7 +108,7 @@ export function useRecipeQuery(dataset: DatasetRef, lang: Lang) {
|
|
|
107
108
|
if (isTool) return;
|
|
108
109
|
if (rawItem && rawFluid) {
|
|
109
110
|
replaceUrlState(
|
|
110
|
-
recipeHref(dataset,
|
|
111
|
+
recipeHref(dataset, resolved, {
|
|
111
112
|
type: params.get('type') ?? undefined,
|
|
112
113
|
item: rawItem,
|
|
113
114
|
id: recipeId,
|
|
@@ -121,7 +122,7 @@ export function useRecipeQuery(dataset: DatasetRef, lang: Lang) {
|
|
|
121
122
|
}
|
|
122
123
|
}, [
|
|
123
124
|
isTool,
|
|
124
|
-
|
|
125
|
+
resolved,
|
|
125
126
|
dataset,
|
|
126
127
|
params,
|
|
127
128
|
rawItem,
|
|
@@ -140,7 +141,7 @@ export function useRecipeQuery(dataset: DatasetRef, lang: Lang) {
|
|
|
140
141
|
const canonFluid = rawFluid ? canonicalStackId(rawFluid) : undefined;
|
|
141
142
|
if (canonItem === rawItem && canonFluid === rawFluid) return;
|
|
142
143
|
replaceUrlState(
|
|
143
|
-
recipeHref(dataset,
|
|
144
|
+
recipeHref(dataset, resolved, {
|
|
144
145
|
type: params.get('type') ?? undefined,
|
|
145
146
|
item: canonItem,
|
|
146
147
|
fluid: canonFluid,
|
|
@@ -154,7 +155,7 @@ export function useRecipeQuery(dataset: DatasetRef, lang: Lang) {
|
|
|
154
155
|
);
|
|
155
156
|
}, [
|
|
156
157
|
isTool,
|
|
157
|
-
|
|
158
|
+
resolved,
|
|
158
159
|
dataset,
|
|
159
160
|
params,
|
|
160
161
|
rawItem,
|
package/src/hooks/use-session.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { useVersionedDataset } from '@terrafirmagreg-team/kit/hooks/use-versione
|
|
|
5
5
|
import { useRecipeIndex } from '@terrafirmagreg-team/recipe/hooks/use-index';
|
|
6
6
|
import { useRecipeQuery } from '@terrafirmagreg-team/recipe/hooks/use-query';
|
|
7
7
|
import { useAsyncValue } from '@terrafirmagreg-team/ui/hooks/use-async-value';
|
|
8
|
+
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
8
9
|
import { clientDumpLang } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
9
10
|
import { useRecipeIndexNames } from '@terrafirmagreg-team/recipe/lib/index-store';
|
|
10
11
|
import {
|
|
@@ -24,7 +25,7 @@ export function useRecipeSession(page: RecipePageData): RecipeSession {
|
|
|
24
25
|
const { dataset: id, lang } = page;
|
|
25
26
|
const dataset =
|
|
26
27
|
useVersionedDataset(id.id, { versions: page.versions }) ?? id;
|
|
27
|
-
const query = useRecipeQuery(dataset
|
|
28
|
+
const query = useRecipeQuery(dataset);
|
|
28
29
|
const { index, indexLoading } = useRecipeIndex(dataset, lang);
|
|
29
30
|
const placeOpts = recipePlaceOpts(query.place);
|
|
30
31
|
|
|
@@ -65,11 +66,14 @@ export function useRecipeSession(page: RecipePageData): RecipeSession {
|
|
|
65
66
|
query.place.id === RECIPE_ALL_TYPE &&
|
|
66
67
|
!query.item &&
|
|
67
68
|
!query.fluid;
|
|
69
|
+
const resolved = useResolvedLang();
|
|
68
70
|
useEffect(() => {
|
|
69
71
|
if (!bareIndex || !firstType) return;
|
|
70
|
-
replaceUrlState(
|
|
72
|
+
replaceUrlState(
|
|
73
|
+
recipeHref(dataset, resolved, { ...nav, type: firstType }),
|
|
74
|
+
);
|
|
71
75
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- nav rebuilds per render
|
|
72
|
-
}, [bareIndex, firstType, dataset,
|
|
76
|
+
}, [bareIndex, firstType, dataset, resolved]);
|
|
73
77
|
|
|
74
78
|
return {
|
|
75
79
|
page,
|
|
@@ -4,6 +4,7 @@ import { useEffect, useMemo } from 'react';
|
|
|
4
4
|
import { groupByCategory } from '@terrafirmagreg-team/recipe/lib/group';
|
|
5
5
|
import { TAG_RECIPE_TYPE } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
6
6
|
import { RECIPE_ALL_TYPE, recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
7
|
+
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
7
8
|
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
8
9
|
import type {
|
|
9
10
|
RecipeCompactRow,
|
|
@@ -14,7 +15,6 @@ export function useTypeFilter(
|
|
|
14
15
|
session: Pick<
|
|
15
16
|
RecipeSession,
|
|
16
17
|
| 'dataset'
|
|
17
|
-
| 'lang'
|
|
18
18
|
| 'index'
|
|
19
19
|
| 'nav'
|
|
20
20
|
| 'place'
|
|
@@ -24,7 +24,8 @@ export function useTypeFilter(
|
|
|
24
24
|
>,
|
|
25
25
|
rows: RecipeCompactRow[],
|
|
26
26
|
) {
|
|
27
|
-
const { dataset,
|
|
27
|
+
const { dataset, index, nav, place, recipeId } = session;
|
|
28
|
+
const resolved = useResolvedLang();
|
|
28
29
|
const groups = useMemo(
|
|
29
30
|
() => groupByCategory(rows, index?.types ?? [], index?.categories),
|
|
30
31
|
[rows, index],
|
|
@@ -51,15 +52,15 @@ export function useTypeFilter(
|
|
|
51
52
|
useEffect(() => {
|
|
52
53
|
if (!primary || valid) return;
|
|
53
54
|
replaceUrlState(
|
|
54
|
-
recipeHref(dataset,
|
|
55
|
+
recipeHref(dataset, resolved, { ...nav, type: primary, rpage: undefined }),
|
|
55
56
|
);
|
|
56
57
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- nav rebuilds per render
|
|
57
|
-
}, [primary, valid, dataset,
|
|
58
|
+
}, [primary, valid, dataset, resolved]);
|
|
58
59
|
|
|
59
60
|
const setActive = (next: string) => {
|
|
60
61
|
if (next === active || next === urlType) return;
|
|
61
62
|
replaceUrlState(
|
|
62
|
-
recipeHref(dataset,
|
|
63
|
+
recipeHref(dataset, resolved, { ...nav, type: next, rpage: undefined }),
|
|
63
64
|
);
|
|
64
65
|
};
|
|
65
66
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as clientIndex from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
2
|
+
import { loadDatasetRecipeCategories } from '@terrafirmagreg-team/recipe/lib/data/category/load';
|
|
3
|
+
import { loadClientManifest } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
|
|
4
|
+
|
|
5
|
+
export function getRecipeSource() {
|
|
6
|
+
return {
|
|
7
|
+
...clientIndex,
|
|
8
|
+
categories: loadDatasetRecipeCategories,
|
|
9
|
+
manifest: loadClientManifest,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type RecipeSource = ReturnType<typeof getRecipeSource>;
|