@vendure/dashboard 3.3.4-master-202506181256 → 3.3.4-master-202506181834

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.
@@ -2,16 +2,36 @@ import path from 'path';
2
2
  export function viteConfigPlugin({ packageRoot }) {
3
3
  return {
4
4
  name: 'vendure:vite-config-plugin',
5
- config: (config) => {
6
- var _a, _b, _c, _d;
5
+ config: (config, env) => {
6
+ var _a, _b, _c, _d, _e;
7
+ // Only set the vite `root` to the dashboard package when running the dev server.
8
+ // During a production build we still need to reference the dashboard source which
9
+ // lives in `node_modules`, but we don't want the build output to be emitted in there.
10
+ // Therefore we set `root` only for `serve` and, for `build`, we instead make sure that
11
+ // an `outDir` **outside** of `node_modules` is used (defaulting to the current working
12
+ // directory if the user did not provide one already).
7
13
  config.root = packageRoot;
14
+ // If we are building and no explicit outDir has been provided (or it is a relative path),
15
+ // set it to an **absolute** path relative to the cwd so that the output never ends up in
16
+ // `node_modules`.
17
+ if (env.command === 'build') {
18
+ const buildConfig = (_a = config.build) !== null && _a !== void 0 ? _a : {};
19
+ const hasOutDir = typeof buildConfig.outDir === 'string' && buildConfig.outDir.length > 0;
20
+ const outDirIsAbsolute = hasOutDir && path.isAbsolute(buildConfig.outDir);
21
+ const normalizedOutDir = hasOutDir
22
+ ? outDirIsAbsolute
23
+ ? buildConfig.outDir
24
+ : path.resolve(process.cwd(), buildConfig.outDir)
25
+ : path.resolve(process.cwd(), 'dist/vendure-dashboard');
26
+ config.build = Object.assign(Object.assign({}, buildConfig), { outDir: normalizedOutDir });
27
+ }
8
28
  config.resolve = {
9
- alias: Object.assign(Object.assign({}, ((_b = (_a = config.resolve) === null || _a === void 0 ? void 0 : _a.alias) !== null && _b !== void 0 ? _b : {})), { '@': path.resolve(packageRoot, './src/lib') }),
29
+ alias: Object.assign(Object.assign({}, ((_c = (_b = config.resolve) === null || _b === void 0 ? void 0 : _b.alias) !== null && _c !== void 0 ? _c : {})), { '@': path.resolve(packageRoot, './src/lib') }),
10
30
  };
11
31
  // This is required to prevent Vite from pre-bundling the
12
32
  // dashboard source when it resides in node_modules.
13
33
  config.optimizeDeps = Object.assign(Object.assign({}, config.optimizeDeps), { exclude: [
14
- ...(((_c = config.optimizeDeps) === null || _c === void 0 ? void 0 : _c.exclude) || []),
34
+ ...(((_d = config.optimizeDeps) === null || _d === void 0 ? void 0 : _d.exclude) || []),
15
35
  '@vendure/dashboard',
16
36
  '@/providers',
17
37
  '@/framework',
@@ -26,7 +46,7 @@ export function viteConfigPlugin({ packageRoot }) {
26
46
  // on lodash which is a CJS packages and _does_ require
27
47
  // pre-bundling.
28
48
  include: [
29
- ...(((_d = config.optimizeDeps) === null || _d === void 0 ? void 0 : _d.include) || []),
49
+ ...(((_e = config.optimizeDeps) === null || _e === void 0 ? void 0 : _e.include) || []),
30
50
  '@/components > recharts',
31
51
  '@/components > react-dropzone',
32
52
  ] });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vendure/dashboard",
3
3
  "private": false,
4
- "version": "3.3.4-master-202506181256",
4
+ "version": "3.3.4-master-202506181834",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -86,8 +86,8 @@
86
86
  "@types/react-dom": "^19.0.4",
87
87
  "@types/react-grid-layout": "^1.3.5",
88
88
  "@uidotdev/usehooks": "^2.4.1",
89
- "@vendure/common": "^3.3.4-master-202506181256",
90
- "@vendure/core": "^3.3.4-master-202506181256",
89
+ "@vendure/common": "^3.3.4-master-202506181834",
90
+ "@vendure/core": "^3.3.4-master-202506181834",
91
91
  "@vitejs/plugin-react": "^4.3.4",
92
92
  "awesome-graphql-client": "^2.1.0",
93
93
  "class-variance-authority": "^0.7.1",
@@ -130,5 +130,5 @@
130
130
  "lightningcss-linux-arm64-musl": "^1.29.3",
131
131
  "lightningcss-linux-x64-musl": "^1.29.1"
132
132
  },
133
- "gitHead": "2b51aa1b137d9ce0feea6ebb1ee2318d905672de"
133
+ "gitHead": "78db619a3a32108f73408c0e8ecc1846c78529a0"
134
134
  }
@@ -1,18 +1,19 @@
1
+ import { DateTimeInput } from '@/components/data-input/datetime-input.js';
1
2
  import { FormFieldWrapper } from '@/components/shared/form-field-wrapper.js';
3
+ import { Button } from '@/components/ui/button.js';
4
+ import { Checkbox } from '@/components/ui/checkbox.js';
2
5
  import { Input } from '@/components/ui/input.js';
6
+ import { NEW_ENTITY_PATH } from '@/constants.js';
3
7
  import { useDetailPage } from '@/framework/page/use-detail-page.js';
4
8
  import { Trans } from '@/lib/trans.js';
5
9
  import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
6
10
  import { AnyRoute, useNavigate } from '@tanstack/react-router';
7
11
  import { ResultOf, VariablesOf } from 'gql.tada';
8
- import { DateTimeInput } from '@/components/data-input/datetime-input.js';
9
- import { Button } from '@/components/ui/button.js';
10
- import { Checkbox } from '@/components/ui/checkbox.js';
11
- import { NEW_ENTITY_PATH } from '@/constants.js';
12
12
  import { toast } from 'sonner';
13
13
  import { getOperationVariablesFields } from '../document-introspection/get-document-structure.js';
14
14
 
15
15
  import {
16
+ CustomFieldsPageBlock,
16
17
  DetailFormGrid,
17
18
  Page,
18
19
  PageActionBar,
@@ -37,6 +38,11 @@ export interface DetailPageProps<
37
38
  U extends TypedDocumentNode<any, any>,
38
39
  EntityField extends keyof ResultOf<T> = DetailEntityPath<T>,
39
40
  > {
41
+ /**
42
+ * @description
43
+ * The name of the entity.
44
+ */
45
+ entityName?: string;
40
46
  /**
41
47
  * @description
42
48
  * A unique identifier for the page.
@@ -94,6 +100,7 @@ export function DetailPage<
94
100
  >({
95
101
  pageId,
96
102
  route,
103
+ entityName,
97
104
  queryDocument,
98
105
  createDocument,
99
106
  updateDocument,
@@ -110,7 +117,7 @@ export function DetailPage<
110
117
  createDocument,
111
118
  params: { id: params.id },
112
119
  setValuesForUpdate,
113
- onSuccess: async (data) => {
120
+ onSuccess: async data => {
114
121
  toast.success('Updated successfully');
115
122
  resetForm();
116
123
  const id = (data as any).id;
@@ -143,41 +150,53 @@ export function DetailPage<
143
150
  <PageLayout>
144
151
  <PageBlock column="main" blockId="main-form">
145
152
  <DetailFormGrid>
146
- {updateFields.map(fieldInfo => {
147
- if (fieldInfo.name === 'id' && fieldInfo.type === 'ID') {
148
- return null;
149
- }
150
- return (
151
- <FormFieldWrapper
152
- key={fieldInfo.name}
153
- control={form.control}
154
- name={fieldInfo.name as never}
155
- label={fieldInfo.name}
156
- render={({ field }) => {
157
- switch (fieldInfo.type) {
158
- case 'Int':
159
- case 'Float':
160
- return (
161
- <Input
162
- type="number"
163
- value={field.value}
164
- onChange={e => field.onChange(e.target.valueAsNumber)}
165
- />
166
- );
167
- case 'DateTime':
168
- return <DateTimeInput {...field} />;
169
- case 'Boolean':
170
- return <Checkbox value={field.value} onCheckedChange={field.onChange} />;
171
- case 'String':
172
- default:
173
- return <Input {...field} />;
174
- }
175
- }}
176
- />
177
- );
178
- })}
153
+ {updateFields
154
+ .filter(fieldInfo => fieldInfo.name !== 'customFields')
155
+ .map(fieldInfo => {
156
+ if (fieldInfo.name === 'id' && fieldInfo.type === 'ID') {
157
+ return null;
158
+ }
159
+ return (
160
+ <FormFieldWrapper
161
+ key={fieldInfo.name}
162
+ control={form.control}
163
+ name={fieldInfo.name as never}
164
+ label={fieldInfo.name}
165
+ render={({ field }) => {
166
+ switch (fieldInfo.type) {
167
+ case 'Int':
168
+ case 'Float':
169
+ return (
170
+ <Input
171
+ type="number"
172
+ value={field.value}
173
+ onChange={e =>
174
+ field.onChange(e.target.valueAsNumber)
175
+ }
176
+ />
177
+ );
178
+ case 'DateTime':
179
+ return <DateTimeInput {...field} />;
180
+ case 'Boolean':
181
+ return (
182
+ <Checkbox
183
+ value={field.value}
184
+ onCheckedChange={field.onChange}
185
+ />
186
+ );
187
+ case 'String':
188
+ default:
189
+ return <Input {...field} />;
190
+ }
191
+ }}
192
+ />
193
+ );
194
+ })}
179
195
  </DetailFormGrid>
180
196
  </PageBlock>
197
+ {entityName && (
198
+ <CustomFieldsPageBlock column="main" entityType={entityName} control={form.control} />
199
+ )}
181
200
  </PageLayout>
182
201
  </Page>
183
202
  );
@@ -1,11 +1,39 @@
1
1
  import path from 'path';
2
- import { Plugin, UserConfig } from 'vite';
2
+ import { ConfigEnv, Plugin, UserConfig } from 'vite';
3
3
 
4
4
  export function viteConfigPlugin({ packageRoot }: { packageRoot: string }): Plugin {
5
5
  return {
6
6
  name: 'vendure:vite-config-plugin',
7
- config: (config: UserConfig) => {
7
+ config: (config: UserConfig, env: ConfigEnv) => {
8
+ // Only set the vite `root` to the dashboard package when running the dev server.
9
+ // During a production build we still need to reference the dashboard source which
10
+ // lives in `node_modules`, but we don't want the build output to be emitted in there.
11
+ // Therefore we set `root` only for `serve` and, for `build`, we instead make sure that
12
+ // an `outDir` **outside** of `node_modules` is used (defaulting to the current working
13
+ // directory if the user did not provide one already).
8
14
  config.root = packageRoot;
15
+
16
+ // If we are building and no explicit outDir has been provided (or it is a relative path),
17
+ // set it to an **absolute** path relative to the cwd so that the output never ends up in
18
+ // `node_modules`.
19
+ if (env.command === 'build') {
20
+ const buildConfig = config.build ?? {};
21
+
22
+ const hasOutDir = typeof buildConfig.outDir === 'string' && buildConfig.outDir.length > 0;
23
+ const outDirIsAbsolute = hasOutDir && path.isAbsolute(buildConfig.outDir as string);
24
+
25
+ const normalizedOutDir = hasOutDir
26
+ ? outDirIsAbsolute
27
+ ? (buildConfig.outDir as string)
28
+ : path.resolve(process.cwd(), buildConfig.outDir as string)
29
+ : path.resolve(process.cwd(), 'dist/vendure-dashboard');
30
+
31
+ config.build = {
32
+ ...buildConfig,
33
+ outDir: normalizedOutDir,
34
+ };
35
+ }
36
+
9
37
  config.resolve = {
10
38
  alias: {
11
39
  ...(config.resolve?.alias ?? {}),