refactor: Widgetのcomposition api移行 (#8125)

* wip

* wip

* wip

* wip

* wip

* wip

* fix
This commit is contained in:
syuilo
2022-01-08 20:30:01 +09:00
committed by GitHub
parent faef125b74
commit 0bbde336b3
23 changed files with 1389 additions and 1221 deletions

View File

@@ -1,45 +1,56 @@
<template>
<MkContainer :naked="props.transparent" :show-header="false">
<MkContainer :naked="widgetProps.transparent" :show-header="false">
<div class="vubelbmv">
<MkAnalogClock class="clock" :thickness="props.thickness"/>
<MkAnalogClock class="clock" :thickness="widgetProps.thickness"/>
</div>
</MkContainer>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import define from './define';
<script lang="ts" setup>
import { } from 'vue';
import { GetFormResultType } from '@/scripts/form';
import { useWidgetPropsManager, Widget, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget';
import MkContainer from '@/components/ui/container.vue';
import MkAnalogClock from '@/components/analog-clock.vue';
import * as os from '@/os';
const widget = define({
name: 'clock',
props: () => ({
transparent: {
type: 'boolean',
default: false,
},
thickness: {
type: 'radio',
default: 0.1,
options: [{
value: 0.1, label: 'thin'
}, {
value: 0.2, label: 'medium'
}, {
value: 0.3, label: 'thick'
}]
}
})
});
const name = 'clock';
export default defineComponent({
components: {
MkContainer,
MkAnalogClock
const widgetPropsDef = {
transparent: {
type: 'boolean' as const,
default: false,
},
extends: widget,
thickness: {
type: 'radio' as const,
default: 0.1,
options: [{
value: 0.1, label: 'thin'
}, {
value: 0.2, label: 'medium'
}, {
value: 0.3, label: 'thick'
}],
},
};
type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
// 現時点ではvueの制限によりimportしたtypeをジェネリックに渡せない
//const props = defineProps<WidgetComponentProps<WidgetProps>>();
//const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
const props = defineProps<{ widget?: Widget<WidgetProps>; }>();
const emit = defineEmits<{ (e: 'updateProps', props: WidgetProps); }>();
const { widgetProps, configure } = useWidgetPropsManager(name,
widgetPropsDef,
props,
emit,
);
defineExpose<WidgetComponentExpose>({
name,
configure,
id: props.widget ? props.widget.id : null,
});
</script>