-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vue-vuetify: Extract control entries and fix usage instructions
fix #2378 The registry entries for the renderers were configured in the same files as the renderers. This lead to the entries being removed due to tree shaking during production builds using esbuild (as used by Vite). This extracts all entries to separate files and improves the README to no longer import the renderers asynchronously .
- Loading branch information
1 parent
cf45f9b
commit d6293f3
Showing
89 changed files
with
563 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/vue-vuetify/src/additional/LabelRenderer.entry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { | ||
rankWith, | ||
uiTypeIs, | ||
type JsonFormsRendererRegistryEntry, | ||
} from '@jsonforms/core'; | ||
import labelRenderer from './LabelRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: labelRenderer, | ||
tester: rankWith(1, uiTypeIs('Label')), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/vue-vuetify/src/additional/ListWithDetailRenderer.entry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { | ||
and, | ||
isObjectArray, | ||
rankWith, | ||
uiTypeIs, | ||
type JsonFormsRendererRegistryEntry, | ||
} from '@jsonforms/core'; | ||
import controlRenderer from './ListWithDetailRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: controlRenderer, | ||
tester: rankWith(4, and(uiTypeIs('ListWithDetail'), isObjectArray)), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { | ||
isAllOfControl, | ||
rankWith, | ||
type JsonFormsRendererRegistryEntry, | ||
} from '@jsonforms/core'; | ||
import controlRenderer from './AllOfRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: controlRenderer, | ||
tester: rankWith(3, isAllOfControl), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { | ||
isAnyOfControl, | ||
rankWith, | ||
type JsonFormsRendererRegistryEntry, | ||
} from '@jsonforms/core'; | ||
import controlRenderer from './AnyOfRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: controlRenderer, | ||
tester: rankWith(3, isAnyOfControl), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/vue-vuetify/src/complex/ArrayControlRenderer.entry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { | ||
isObjectArrayControl, | ||
isPrimitiveArrayControl, | ||
or, | ||
rankWith, | ||
type JsonFormsRendererRegistryEntry, | ||
} from '@jsonforms/core'; | ||
import controlRenderer from './ArrayControlRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: controlRenderer, | ||
tester: rankWith(3, or(isObjectArrayControl, isPrimitiveArrayControl)), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/vue-vuetify/src/complex/EnumArrayRenderer.entry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { | ||
and, | ||
hasType, | ||
rankWith, | ||
schemaMatches, | ||
schemaSubPathMatches, | ||
uiTypeIs, | ||
type JsonFormsRendererRegistryEntry, | ||
type JsonSchema, | ||
} from '@jsonforms/core'; | ||
import controlRenderer from './EnumArrayRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: controlRenderer, | ||
tester: rankWith( | ||
5, | ||
and( | ||
uiTypeIs('Control'), | ||
and( | ||
schemaMatches( | ||
(schema) => | ||
hasType(schema, 'array') && | ||
!Array.isArray(schema.items) && | ||
schema.uniqueItems === true, | ||
), | ||
schemaSubPathMatches('items', (schema) => { | ||
return hasOneOfItems(schema) || hasEnumItems(schema); | ||
}), | ||
), | ||
), | ||
), | ||
}; | ||
|
||
const hasOneOfItems = (schema: JsonSchema): boolean => | ||
schema.oneOf !== undefined && | ||
schema.oneOf.length > 0 && | ||
(schema.oneOf as JsonSchema[]).every((entry: JsonSchema) => { | ||
return entry.const !== undefined; | ||
}); | ||
|
||
const hasEnumItems = (schema: JsonSchema): boolean => | ||
schema.type === 'string' && schema.enum !== undefined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { | ||
isObjectControl, | ||
rankWith, | ||
type JsonFormsRendererRegistryEntry, | ||
} from '@jsonforms/core'; | ||
import controlRenderer from './ObjectRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: controlRenderer, | ||
tester: rankWith(2, isObjectControl), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { | ||
isOneOfControl, | ||
rankWith, | ||
type JsonFormsRendererRegistryEntry, | ||
} from '@jsonforms/core'; | ||
import controlRenderer from './OneOfRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: controlRenderer, | ||
tester: rankWith(3, isOneOfControl), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/vue-vuetify/src/complex/OneOfTabRenderer.entry.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { | ||
and, | ||
isOneOfControl, | ||
optionIs, | ||
rankWith, | ||
type JsonFormsRendererRegistryEntry, | ||
} from '@jsonforms/core'; | ||
import controlRenderer from './OneOfTabRenderer.vue'; | ||
|
||
export const entry: JsonFormsRendererRegistryEntry = { | ||
renderer: controlRenderer, | ||
tester: rankWith(4, and(isOneOfControl, optionIs('variant', 'tab'))), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.