adminforth 2.1.0-next.15 → 2.1.0-next.17

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.
@@ -47,9 +47,27 @@ async function findResourceFilePath(resourceId) {
47
47
 
48
48
  if (n.TSAsExpression.check(declaration) && n.ObjectExpression.check(declaration.expression)) {
49
49
  objectExpressionNode = declaration.expression;
50
- }
51
- else if (n.ObjectExpression.check(declaration)) {
50
+ } else if (n.ObjectExpression.check(declaration)) {
52
51
  objectExpressionNode = declaration;
52
+ } else if (n.Identifier.check(declaration)) {
53
+ const varName = declaration.name;
54
+
55
+ recast.visit(ast, {
56
+ visitVariableDeclaration(path) {
57
+ for (const decl of path.node.declarations) {
58
+ if (
59
+ n.VariableDeclarator.check(decl) &&
60
+ n.Identifier.check(decl.id) &&
61
+ decl.id.name === varName &&
62
+ n.ObjectExpression.check(decl.init)
63
+ ) {
64
+ objectExpressionNode = decl.init;
65
+ return false;
66
+ }
67
+ }
68
+ this.traverse(path);
69
+ }
70
+ });
53
71
  }
54
72
 
55
73
  if (objectExpressionNode) {
@@ -118,6 +136,25 @@ export async function updateResourceConfig(resourceId, columnName, fieldType, co
118
136
  objectExpressionNode = declaration.expression;
119
137
  } else if (n.ObjectExpression.check(declaration)) {
120
138
  objectExpressionNode = declaration;
139
+ } else if (n.Identifier.check(declaration)) {
140
+ const varName = declaration.name;
141
+
142
+ recast.visit(ast, {
143
+ visitVariableDeclaration(path) {
144
+ for (const decl of path.node.declarations) {
145
+ if (
146
+ n.VariableDeclarator.check(decl) &&
147
+ n.Identifier.check(decl.id) &&
148
+ decl.id.name === varName &&
149
+ n.ObjectExpression.check(decl.init)
150
+ ) {
151
+ objectExpressionNode = decl.init;
152
+ return false;
153
+ }
154
+ }
155
+ this.traverse(path);
156
+ }
157
+ });
121
158
  }
122
159
 
123
160
  if (!objectExpressionNode) {
@@ -446,9 +483,28 @@ export async function updateCrudInjectionConfig(resourceId, crudType, injectionP
446
483
  let objectExpressionNode = null;
447
484
 
448
485
  if (n.TSAsExpression.check(declaration) && n.ObjectExpression.check(declaration.expression)) {
449
- objectExpressionNode = declaration.expression;
486
+ objectExpressionNode = declaration.expression;
450
487
  } else if (n.ObjectExpression.check(declaration)) {
451
- objectExpressionNode = declaration;
488
+ objectExpressionNode = declaration;
489
+ } else if (n.Identifier.check(declaration)) {
490
+ const varName = declaration.name;
491
+
492
+ recast.visit(ast, {
493
+ visitVariableDeclaration(path) {
494
+ for (const decl of path.node.declarations) {
495
+ if (
496
+ n.VariableDeclarator.check(decl) &&
497
+ n.Identifier.check(decl.id) &&
498
+ decl.id.name === varName &&
499
+ n.ObjectExpression.check(decl.init)
500
+ ) {
501
+ objectExpressionNode = decl.init;
502
+ return false;
503
+ }
504
+ }
505
+ this.traverse(path);
506
+ }
507
+ });
452
508
  }
453
509
 
454
510
  if (!objectExpressionNode) {
@@ -58,13 +58,26 @@ async function handleFieldComponentCreation(config, resources) {
58
58
 
59
59
  console.log(chalk.grey(`Selected ❯ 🔤 Custom fields ❯ ${fieldType}`));
60
60
 
61
- const resourceId = await select({
62
- message: 'Select resource for which you want to change component:',
63
- choices: [
64
- ...resources.map(r => ({ name: `${r.label} ${chalk.grey(`${r.resourceId}`)}`, value: r.resourceId })),
65
- new Separator(),
66
- { name: '🔙 BACK', value: '__BACK__' },
67
- ]
61
+ const resourceId = await search({
62
+ message: 'Select resource for which you want to change component:',
63
+ source: async (input) => {
64
+ const searchTerm = input ? input.toLowerCase() : '';
65
+
66
+ const filtered = resources.filter(r => {
67
+ const label = r.label || '';
68
+ const id = r.resourceId || '';
69
+ return label.toLowerCase().includes(searchTerm) || id.toLowerCase().includes(searchTerm);
70
+ });
71
+
72
+ return [
73
+ ...filtered.map(r => ({
74
+ name: `${r.label} ${chalk.grey(`${r.resourceId}`)}`,
75
+ value: r.resourceId,
76
+ })),
77
+ new Separator(),
78
+ { name: '🔙 BACK', value: '__BACK__' },
79
+ ];
80
+ }
68
81
  });
69
82
  if (resourceId === '__BACK__') return handleFieldComponentCreation(config, resources); // Pass config back
70
83
 
@@ -144,14 +157,28 @@ async function handleCrudPageInjectionCreation(config, resources) {
144
157
 
145
158
  console.log(chalk.grey(`Selected ❯ 📄 CRUD Page Injection ❯ ${crudType}`));
146
159
 
147
- const resourceId = await select({
160
+ const resourceId = await search({
148
161
  message: 'Select resource for which you want to inject the component:',
149
- choices: [
150
- ...resources.map(r => ({ name: `${r.label} ${chalk.grey(`${r.resourceId}`)}`, value: r.resourceId })),
151
- new Separator(),
152
- { name: '🔙 BACK', value: '__BACK__' },
153
- ],
162
+ source: async (input) => {
163
+ const searchTerm = input ? input.toLowerCase() : '';
164
+
165
+ const filtered = resources.filter(r => {
166
+ const label = r.label || '';
167
+ const id = r.resourceId || '';
168
+ return label.toLowerCase().includes(searchTerm) || id.toLowerCase().includes(searchTerm);
169
+ });
170
+
171
+ return [
172
+ ...filtered.map(r => ({
173
+ name: `${r.label} ${chalk.grey(`${r.resourceId}`)}`,
174
+ value: r.resourceId,
175
+ })),
176
+ new Separator(),
177
+ { name: '🔙 BACK', value: '__BACK__' },
178
+ ];
179
+ }
154
180
  });
181
+
155
182
  if (resourceId === '__BACK__') return handleCrudPageInjectionCreation(config, resources);
156
183
 
157
184
  const selectedResource = resources.find(r => r.resourceId === resourceId);
@@ -59,7 +59,7 @@ const respondNoServer = (title, explanation) => {
59
59
  display: flex;
60
60
  justify-content: center;
61
61
  align-items: center;
62
- height: 100vh;
62
+ height: 100dvh;
63
63
  flex-direction: column;
64
64
  }
65
65
  </style>
@@ -6,7 +6,7 @@
6
6
 
7
7
  :class="show ? 'top-0 transform-none' : ''"
8
8
  tabindex="-1" aria-labelledby="drawer-navigation-label"
9
- :style="{ height: `calc(100vh ` }"
9
+ :style="{ height: `calc(100dvh ` }"
10
10
  >
11
11
  <h5 id="drawer-navigation-label" class="text-base font-semibold text-gray-500 uppercase dark:text-gray-400">
12
12
  {{ $t('Filters') }}
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div :key="`${$route?.params.resourceId}---${$route?.params.primaryKey}`" class="p-4 flex"
3
- :class="limitHeightToPage ? 'h-[calc(100vh-3.5rem)]': undefined"
3
+ :class="limitHeightToPage ? 'h-[calc(100dvh-3.5rem)]': undefined"
4
4
  >
5
5
  <RouterView/>
6
6
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "2.1.0-next.15",
3
+ "version": "2.1.0-next.17",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",