Skip to content

Commit

Permalink
fix vite not including SFC template part of component, move entries t…
Browse files Browse the repository at this point in the history
…o index as described here eclipsesource/jsonforms-vue-seed#13
  • Loading branch information
mgineer85 committed Mar 26, 2024
1 parent dfc911a commit 08e447c
Show file tree
Hide file tree
Showing 21 changed files with 211 additions and 236 deletions.
1 change: 1 addition & 0 deletions src/components/form/array/ArrayListElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<script lang="ts">
import { defineComponent, PropType } from 'vue';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { classes, Styles } from '../styles';
const listItem = defineComponent({
Expand Down
16 changes: 1 addition & 15 deletions src/components/form/array/ArrayListRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,7 @@
</template>

<script lang="ts">
import {
composePaths,
createDefaultValue,
JsonFormsRendererRegistryEntry,
rankWith,
ControlElement,
schemaTypeIs,
Resolve,
JsonSchema,
} from '@jsonforms/core';
import { composePaths, createDefaultValue, ControlElement, Resolve, JsonSchema } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { DispatchRenderer, rendererProps, useJsonFormsArrayControl, RendererProps } from '@jsonforms/vue';
import { useQuasarArrayControl } from '../util';
Expand Down Expand Up @@ -101,9 +92,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(2.1, schemaTypeIs('array')),
};
</script>
10 changes: 7 additions & 3 deletions src/components/form/array/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export { default as ArrayListRenderer } from './ArrayListRenderer.vue';
import { JsonFormsRendererRegistryEntry, rankWith, schemaTypeIs } from '@jsonforms/core';

import { entry as arrayListRendererEntry } from './ArrayListRenderer.vue';
import { default as ArrayListRenderer } from './ArrayListRenderer.vue';

export const arrayRenderers = [arrayListRendererEntry];
export const ArrayListRendererEntry: JsonFormsRendererRegistryEntry = {
renderer: ArrayListRenderer,
tester: rankWith(2.1, schemaTypeIs('array')),
};
export const arrayRenderers = [ArrayListRendererEntry];
18 changes: 2 additions & 16 deletions src/components/form/complex/AllOfRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@
</template>

<script lang="ts">
import {
CombinatorSubSchemaRenderInfo,
ControlElement,
createCombinatorRenderInfos,
findMatchingUISchema,
isAllOfControl,
JsonFormsRendererRegistryEntry,
rankWith,
UISchemaElement,
} from '@jsonforms/core';
import { CombinatorSubSchemaRenderInfo, ControlElement, createCombinatorRenderInfos, findMatchingUISchema, UISchemaElement } from '@jsonforms/core';
import { DispatchRenderer, rendererProps, RendererProps, useJsonFormsAllOfControl } from '@jsonforms/vue';
import { defineComponent } from 'vue';
import { useQuasarControl } from '../util';
Expand Down Expand Up @@ -68,7 +59,7 @@ const controlRenderer = defineComponent({
'allOf',
this.control.uischema,
this.control.path,
this.control.uischemas
this.control.uischemas,
);
return result.filter((info) => info.uischema);
Expand All @@ -77,9 +68,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(3, isAllOfControl),
};
</script>
37 changes: 1 addition & 36 deletions src/components/form/complex/EnumArrayRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@
</template>

<script lang="ts">
import {
ControlElement,
JsonFormsRendererRegistryEntry,
rankWith,
and,
hasType,
JsonSchema,
schemaMatches,
schemaSubPathMatches,
uiTypeIs,
} from '@jsonforms/core';
import { ControlElement } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { rendererProps, useJsonFormsMultiEnumControl, RendererProps } from '@jsonforms/vue';
import { useQuasarBasicControl } from '../util';
Expand All @@ -51,29 +41,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
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;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(
5.1,
and(
uiTypeIs('Control'),
and(
schemaMatches((schema) => hasType(schema, 'array') && !Array.isArray(schema.items)),
schemaSubPathMatches('items', (schema) => {
return hasOneOfItems(schema) || hasEnumItems(schema);
})
)
)
),
};
</script>
56 changes: 45 additions & 11 deletions src/components/form/complex/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,58 @@
export { default as AllOfRenderer } from './AllOfRenderer.vue';
import {
isAllOfControl,
JsonFormsRendererRegistryEntry,
rankWith,
and,
hasType,
JsonSchema,
schemaMatches,
schemaSubPathMatches,
uiTypeIs,
} from '@jsonforms/core';

import { default as AllOfRenderer } from './AllOfRenderer.vue';
// export { default as AnyOfRenderer } from "./AnyOfRenderer.vue";
// export { default as ArrayControlRenderer } from "./ArrayControlRenderer.vue";
export { default as EnumArrayRenderer } from './EnumArrayRenderer.vue';
import { default as EnumArrayRenderer } from './EnumArrayRenderer.vue';
// export { default as ObjectRenderer } from "./ObjectRenderer.vue";
// export { default as OneOfRenderer } from "./OneOfRenderer.vue";
// export { default as OneOfTabRenderer } from "./OneOfTabRenderer.vue";

import { entry as allOfRendererEntry } from './AllOfRenderer.vue';
// import { entry as anyOfRendererEntry } from "./AnyOfRenderer.vue";
// import { entry as arrayControlRendererEntry } from "./ArrayControlRenderer.vue";
import { entry as enumArrayRendererEntry } from './EnumArrayRenderer.vue';
// import { entry as objectRendererEntry } from "./ObjectRenderer.vue";
// import { entry as oneOfRendererEntry } from "./OneOfRenderer.vue";
// import { entry as oneOfTabRendererEntry } from "./OneOfTabRenderer.vue";
export const AllOfRendererEntry: JsonFormsRendererRegistryEntry = {
renderer: AllOfRenderer,
tester: rankWith(3, isAllOfControl),
};

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;

export const EnumArrayRendererEntry: JsonFormsRendererRegistryEntry = {
renderer: EnumArrayRenderer,
tester: rankWith(
5.1,
and(
uiTypeIs('Control'),
and(
schemaMatches((schema) => hasType(schema, 'array') && !Array.isArray(schema.items)),
schemaSubPathMatches('items', (schema) => {
return hasOneOfItems(schema) || hasEnumItems(schema);
}),
),
),
),
};

export const complexRenderers = [
allOfRendererEntry,
AllOfRendererEntry,
// anyOfRendererEntry,
// arrayControlRendererEntry,
enumArrayRendererEntry,
EnumArrayRendererEntry,
// objectRendererEntry,
// oneOfRendererEntry,
// oneOfTabRendererEntry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</template>

<script lang="ts">
import { ControlElement, JsonFormsRendererRegistryEntry, rankWith, isBooleanControl } from '@jsonforms/core';
import { ControlElement } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { rendererProps, useJsonFormsControl, RendererProps } from '@jsonforms/vue';
import { default as ControlWrapper } from './ControlWrapper.vue';
Expand All @@ -32,9 +32,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(1.1, isBooleanControl),
};
</script>
7 changes: 1 addition & 6 deletions src/components/form/controls/ColorControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</template>

<script lang="ts">
import { ControlElement, JsonFormsRendererRegistryEntry, rankWith, isStringControl, and, or, formatIs, optionIs } from '@jsonforms/core';
import { ControlElement } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { rendererProps, useJsonFormsControl, RendererProps } from '@jsonforms/vue';
import { default as ControlWrapper } from './ControlWrapper.vue';
Expand All @@ -37,9 +37,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(1.1, and(isStringControl, or(formatIs('color'), optionIs('format', 'color')))),
};
</script>
37 changes: 1 addition & 36 deletions src/components/form/controls/EnumArrayControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@
</template>

<script lang="ts">
import {
ControlElement,
JsonFormsRendererRegistryEntry,
rankWith,
and,
hasType,
JsonSchema,
schemaMatches,
schemaSubPathMatches,
uiTypeIs,
} from '@jsonforms/core';
import { ControlElement } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { rendererProps, useJsonFormsMultiEnumControl, RendererProps } from '@jsonforms/vue';
import { useQuasarBasicControl } from '../util';
Expand All @@ -54,29 +44,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
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;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(
5.2,
and(
uiTypeIs('Control'),
and(
schemaMatches((schema) => hasType(schema, 'array') && !Array.isArray(schema.items)),
schemaSubPathMatches('items', (schema) => {
return hasOneOfItems(schema) || hasEnumItems(schema);
})
)
)
),
};
</script>
7 changes: 1 addition & 6 deletions src/components/form/controls/EnumControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</template>

<script lang="ts">
import { ControlElement, JsonFormsRendererRegistryEntry, rankWith, isEnumControl } from '@jsonforms/core';
import { ControlElement } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { rendererProps, useJsonFormsEnumControl, RendererProps } from '@jsonforms/vue';
import { default as ControlWrapper } from './ControlWrapper.vue';
Expand All @@ -37,9 +37,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(2.1, isEnumControl),
};
</script>
7 changes: 1 addition & 6 deletions src/components/form/controls/NumberControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</template>

<script lang="ts">
import { ControlElement, JsonFormsRendererRegistryEntry, rankWith, isNumberControl, or, isIntegerControl } from '@jsonforms/core';
import { ControlElement } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { rendererProps, useJsonFormsControl, RendererProps } from '@jsonforms/vue';
import { default as ControlWrapper } from './ControlWrapper.vue';
Expand All @@ -38,9 +38,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(1.1, or(isNumberControl, isIntegerControl)),
};
</script>
9 changes: 2 additions & 7 deletions src/components/form/controls/SliderControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</template>

<script lang="ts">
import { ControlElement, JsonFormsRendererRegistryEntry, rankWith, isRangeControl } from '@jsonforms/core';
import { ControlElement } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { rendererProps, useJsonFormsControl, RendererProps } from '@jsonforms/vue';
import { default as ControlWrapper } from './ControlWrapper.vue';
Expand All @@ -40,15 +40,10 @@ const controlRenderer = defineComponent({
(value) => {
return Number(value);
},
300
300,
);
},
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(4.1, isRangeControl), //TODO: Tester not working as expected.
};
</script>
7 changes: 1 addition & 6 deletions src/components/form/controls/StringControlRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</template>

<script lang="ts">
import { ControlElement, JsonFormsRendererRegistryEntry, rankWith, isStringControl } from '@jsonforms/core';
import { ControlElement } from '@jsonforms/core';
import { defineComponent } from 'vue';
import { rendererProps, useJsonFormsControl, RendererProps } from '@jsonforms/vue';
import { default as ControlWrapper } from './ControlWrapper.vue';
Expand All @@ -35,9 +35,4 @@ const controlRenderer = defineComponent({
});
export default controlRenderer;
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(1.1, isStringControl),
};
</script>
Loading

0 comments on commit 08e447c

Please sign in to comment.