@multiplatform.one/backoffice 7.35.0 → 7.37.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/package.json +12 -12
- package/src/desk/DeskPokemon.stories.tsx +177 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/backoffice",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.37.0",
|
|
4
4
|
"description": "Embeddable Frappe desk recreation (backoffice) for the multiplatform.one stack",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backoffice",
|
|
@@ -71,21 +71,21 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@multiplatform.one/components": "^7.
|
|
75
|
-
"@multiplatform.one/forms": "^7.
|
|
76
|
-
"@multiplatform.one/frappe": "^7.
|
|
77
|
-
"@multiplatform.one/frappe-ui": "^7.
|
|
78
|
-
"@multiplatform.one/i18n": "^7.
|
|
79
|
-
"@multiplatform.one/platform": "^7.
|
|
80
|
-
"@multiplatform.one/store": "^7.
|
|
81
|
-
"@multiplatform.one/table": "^7.
|
|
82
|
-
"@multiplatform.one/theme": "^7.
|
|
74
|
+
"@multiplatform.one/components": "^7.37.0",
|
|
75
|
+
"@multiplatform.one/forms": "^7.37.0",
|
|
76
|
+
"@multiplatform.one/frappe": "^7.37.0",
|
|
77
|
+
"@multiplatform.one/frappe-ui": "^7.37.0",
|
|
78
|
+
"@multiplatform.one/i18n": "^7.37.0",
|
|
79
|
+
"@multiplatform.one/platform": "^7.37.0",
|
|
80
|
+
"@multiplatform.one/store": "^7.37.0",
|
|
81
|
+
"@multiplatform.one/table": "^7.37.0",
|
|
82
|
+
"@multiplatform.one/theme": "^7.37.0",
|
|
83
83
|
"@phosphor-icons/react": "^2.1.10",
|
|
84
84
|
"tamagui": "2.7.6"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@multiplatform.one/config": "7.
|
|
88
|
-
"@multiplatform.one/test-utils": "7.
|
|
87
|
+
"@multiplatform.one/config": "7.37.0",
|
|
88
|
+
"@multiplatform.one/test-utils": "7.37.0",
|
|
89
89
|
"@tamagui/build": "2.7.6",
|
|
90
90
|
"@testing-library/react": "^16.3.3",
|
|
91
91
|
"@types/react-dom": "^19.2.3",
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// The real desk screens on the Pokemon doctype the One app ships, served from
|
|
2
|
+
// fixtures. Shoot these at phone width to check the backoffice against its
|
|
3
|
+
// approved board (FZ-7684).
|
|
4
|
+
import { YStack } from "@multiplatform.one/components";
|
|
5
|
+
import { InMemoryFixtureProvider } from "@multiplatform.one/frappe";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
import { Desk } from "./Desk";
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: "Screens/Backoffice/Desk/Pokemon",
|
|
11
|
+
component: Desk,
|
|
12
|
+
tags: ["!test"],
|
|
13
|
+
parameters: {
|
|
14
|
+
status: { type: "beta" },
|
|
15
|
+
layout: "fullscreen",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
|
|
20
|
+
const MOCK_HOST = "https://backoffice-pokemon.mock.test";
|
|
21
|
+
const DOCTYPE = "Pokemon";
|
|
22
|
+
|
|
23
|
+
const pokemonMeta = {
|
|
24
|
+
name: DOCTYPE,
|
|
25
|
+
doctype: "DocType",
|
|
26
|
+
module: "Core",
|
|
27
|
+
title_field: "pokemon_name",
|
|
28
|
+
image_field: "sprite_front",
|
|
29
|
+
sort_field: "modified",
|
|
30
|
+
sort_order: "DESC",
|
|
31
|
+
fields: [
|
|
32
|
+
{ fieldname: "pokemon_name", fieldtype: "Data", label: "Pokemon Name", in_list_view: 1 },
|
|
33
|
+
{ fieldname: "poke_id", fieldtype: "Int", label: "Poke ID", in_list_view: 1 },
|
|
34
|
+
{ fieldname: "species", fieldtype: "Data", label: "Species", in_list_view: 1 },
|
|
35
|
+
{ fieldname: "height", fieldtype: "Int", label: "Height (dm)" },
|
|
36
|
+
{ fieldname: "weight", fieldtype: "Int", label: "Weight (hg)" },
|
|
37
|
+
{ fieldname: "base_experience", fieldtype: "Int", label: "Base Experience" },
|
|
38
|
+
{ fieldname: "column_break_1", fieldtype: "Column Break" },
|
|
39
|
+
{ fieldname: "sprite_front", fieldtype: "Attach Image", label: "Sprite (Front)" },
|
|
40
|
+
{ fieldname: "sprite_back", fieldtype: "Attach Image", label: "Sprite (Back)" },
|
|
41
|
+
{ fieldname: "section_break_stats", fieldtype: "Section Break", label: "Stats" },
|
|
42
|
+
{ fieldname: "stats", fieldtype: "Table", label: "Stats", options: "Pokemon Stat" },
|
|
43
|
+
],
|
|
44
|
+
permissions: [{ role: "All", read: 1, write: 1, create: 1 }],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const statMeta = {
|
|
48
|
+
name: "Pokemon Stat",
|
|
49
|
+
doctype: "DocType",
|
|
50
|
+
module: "Core",
|
|
51
|
+
istable: 1,
|
|
52
|
+
fields: [
|
|
53
|
+
{ fieldname: "stat", fieldtype: "Data", label: "Stat", in_list_view: 1 },
|
|
54
|
+
{ fieldname: "base_stat", fieldtype: "Int", label: "Base Stat", in_list_view: 1 },
|
|
55
|
+
{ fieldname: "effort", fieldtype: "Int", label: "Effort", in_list_view: 1 },
|
|
56
|
+
],
|
|
57
|
+
permissions: [{ role: "All", read: 1, write: 1, create: 1 }],
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const sprite = (id: number, back = false) =>
|
|
61
|
+
`https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/${back ? "back/" : ""}${id}.png`;
|
|
62
|
+
|
|
63
|
+
const rows: [string, string, number, string, number, number, number][] = [
|
|
64
|
+
["pikachu", "Pikachu", 25, "Mouse Pokémon", 4, 60, 112],
|
|
65
|
+
["raticate", "Raticate", 20, "Mouse Pokémon", 7, 185, 145],
|
|
66
|
+
["rattata", "Rattata", 19, "Mouse Pokémon", 3, 35, 51],
|
|
67
|
+
["pidgeot", "Pidgeot", 18, "Bird Pokémon", 15, 395, 216],
|
|
68
|
+
["pidgeotto", "Pidgeotto", 17, "Bird Pokémon", 11, 300, 122],
|
|
69
|
+
["pidgey", "Pidgey", 16, "Tiny Bird Pokémon", 3, 18, 50],
|
|
70
|
+
["beedrill", "Beedrill", 15, "Poison Bee Pokémon", 10, 295, 178],
|
|
71
|
+
["caterpie", "Caterpie", 10, "Worm Pokémon", 3, 29, 39],
|
|
72
|
+
...(
|
|
73
|
+
[
|
|
74
|
+
"Bulbasaur",
|
|
75
|
+
"Ivysaur",
|
|
76
|
+
"Venusaur",
|
|
77
|
+
"Charmander",
|
|
78
|
+
"Charmeleon",
|
|
79
|
+
"Charizard",
|
|
80
|
+
"Squirtle",
|
|
81
|
+
"Wartortle",
|
|
82
|
+
"Blastoise",
|
|
83
|
+
"Metapod",
|
|
84
|
+
"Butterfree",
|
|
85
|
+
"Weedle",
|
|
86
|
+
"Kakuna",
|
|
87
|
+
"Spearow",
|
|
88
|
+
"Fearow",
|
|
89
|
+
"Ekans",
|
|
90
|
+
"Arbok",
|
|
91
|
+
"Raichu",
|
|
92
|
+
] as const
|
|
93
|
+
).map((title, i): [string, string, number, string, number, number, number] => {
|
|
94
|
+
const id = i < 9 ? i + 1 : i + 2;
|
|
95
|
+
return [title.toLowerCase(), title, id, "Pokémon", 5 + (i % 9), 60 + i * 37, 60 + i * 11];
|
|
96
|
+
}),
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
const now = Date.now();
|
|
100
|
+
const pokemonDocs = rows.map(
|
|
101
|
+
([name, pokemon_name, poke_id, species, height, weight, base_experience], i) => ({
|
|
102
|
+
name,
|
|
103
|
+
doctype: DOCTYPE,
|
|
104
|
+
pokemon_name,
|
|
105
|
+
poke_id,
|
|
106
|
+
species,
|
|
107
|
+
height,
|
|
108
|
+
weight,
|
|
109
|
+
base_experience,
|
|
110
|
+
sprite_front: sprite(poke_id),
|
|
111
|
+
sprite_back: sprite(poke_id, true),
|
|
112
|
+
modified: new Date(now - (4 + Math.floor(i / 5)) * 86_400_000).toISOString(),
|
|
113
|
+
stats: [
|
|
114
|
+
{ name: `${name}-hp`, stat: "hp", base_stat: 45, effort: 1 },
|
|
115
|
+
{ name: `${name}-attack`, stat: "attack", base_stat: 30, effort: 0 },
|
|
116
|
+
{ name: `${name}-defense`, stat: "defense", base_stat: 35, effort: 0 },
|
|
117
|
+
{ name: `${name}-speed`, stat: "speed", base_stat: 45, effort: 0 },
|
|
118
|
+
],
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const frappe = () => ({
|
|
123
|
+
baseURL: MOCK_HOST,
|
|
124
|
+
fixtures: new InMemoryFixtureProvider({
|
|
125
|
+
DocType: [pokemonMeta, statMeta],
|
|
126
|
+
Workspace: [],
|
|
127
|
+
"Notification Log": [],
|
|
128
|
+
[DOCTYPE]: pokemonDocs,
|
|
129
|
+
}),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
(() => {
|
|
133
|
+
if (typeof window === "undefined") return;
|
|
134
|
+
const w = window as unknown as Record<string, unknown>;
|
|
135
|
+
if (w.__deskPokemonMockFetch) return;
|
|
136
|
+
w.__deskPokemonMockFetch = true;
|
|
137
|
+
const realFetch = window.fetch.bind(window);
|
|
138
|
+
window.fetch = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
|
139
|
+
const urlStr =
|
|
140
|
+
typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
141
|
+
if (!urlStr.startsWith(MOCK_HOST)) return realFetch(input as RequestInfo, init);
|
|
142
|
+
const body =
|
|
143
|
+
new URL(urlStr).pathname === "/api/method/frappe.auth.get_logged_user"
|
|
144
|
+
? { message: null }
|
|
145
|
+
: { data: [], message: [] };
|
|
146
|
+
return new Response(JSON.stringify(body), {
|
|
147
|
+
status: 200,
|
|
148
|
+
headers: { "Content-Type": "application/json" },
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
})();
|
|
152
|
+
|
|
153
|
+
function Frame({ children }: { children: ReactNode }) {
|
|
154
|
+
return (
|
|
155
|
+
<YStack height="100vh" minHeight="$0">
|
|
156
|
+
{children}
|
|
157
|
+
</YStack>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const List = () => (
|
|
162
|
+
<Frame>
|
|
163
|
+
<Desk frappe={frappe()} doctype={DOCTYPE} />
|
|
164
|
+
</Frame>
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
export const Form = () => (
|
|
168
|
+
<Frame>
|
|
169
|
+
<Desk frappe={frappe()} doctype={DOCTYPE} name="caterpie" />
|
|
170
|
+
</Frame>
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
export const Report = () => (
|
|
174
|
+
<Frame>
|
|
175
|
+
<Desk frappe={frappe()} doctype={DOCTYPE} view="report" />
|
|
176
|
+
</Frame>
|
|
177
|
+
);
|