|
|
|
@@ -10,8 +10,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
<MkAsUi v-if="!g(child).hidden" :component="g(child)" :components="props.components" :size="size"/>
|
|
|
|
<MkAsUi v-if="!g(child).hidden" :component="g(child)" :components="props.components" :size="size"/>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<span v-else-if="c.type === 'text'" :class="{ [$style.fontSerif]: c.font === 'serif', [$style.fontMonospace]: c.font === 'monospace' }" :style="{ fontSize: c.size ? `${c.size * 100}%` : null, fontWeight: c.bold ? 'bold' : null, color: c.color ?? null }">{{ c.text }}</span>
|
|
|
|
<span v-else-if="c.type === 'text'" :class="{ [$style.fontSerif]: c.font === 'serif', [$style.fontMonospace]: c.font === 'monospace' }" :style="{ fontSize: c.size ? `${c.size * 100}%` : undefined, fontWeight: c.bold ? 'bold' : undefined, color: c.color }">{{ c.text }}</span>
|
|
|
|
<Mfm v-else-if="c.type === 'mfm'" :class="{ [$style.fontSerif]: c.font === 'serif', [$style.fontMonospace]: c.font === 'monospace' }" :style="{ fontSize: c.size ? `${c.size * 100}%` : null, fontWeight: c.bold ? 'bold' : null, color: c.color ?? null }" :text="c.text" @clickEv="c.onClickEv"/>
|
|
|
|
<Mfm v-else-if="c.type === 'mfm'" :class="{ [$style.fontSerif]: c.font === 'serif', [$style.fontMonospace]: c.font === 'monospace' }" :style="{ fontSize: c.size ? `${c.size * 100}%` : null, fontWeight: c.bold ? 'bold' : null, color: c.color ?? null }" :text="c.text ?? ''" @clickEv="c.onClickEv"/>
|
|
|
|
<MkButton v-else-if="c.type === 'button'" :primary="c.primary" :rounded="c.rounded" :disabled="c.disabled" :small="size === 'small'" inline @click="c.onClick">{{ c.text }}</MkButton>
|
|
|
|
<MkButton v-else-if="c.type === 'button'" :primary="c.primary" :rounded="c.rounded" :disabled="c.disabled" :small="size === 'small'" inline @click="c.onClick">{{ c.text }}</MkButton>
|
|
|
|
<div v-else-if="c.type === 'buttons'" class="_buttons" :style="{ justifyContent: align }">
|
|
|
|
<div v-else-if="c.type === 'buttons'" class="_buttons" :style="{ justifyContent: align }">
|
|
|
|
<MkButton v-for="button in c.buttons" :primary="button.primary" :rounded="button.rounded" :disabled="button.disabled" inline :small="size === 'small'" @click="button.onClick">{{ button.text }}</MkButton>
|
|
|
|
<MkButton v-for="button in c.buttons" :primary="button.primary" :rounded="button.rounded" :disabled="button.disabled" inline :small="size === 'small'" @click="button.onClick">{{ button.text }}</MkButton>
|
|
|
|
@@ -20,19 +20,19 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkSwitch>
|
|
|
|
<MkTextarea v-else-if="c.type === 'textarea'" :modelValue="c.default" @update:modelValue="c.onInput">
|
|
|
|
<MkTextarea v-else-if="c.type === 'textarea'" :modelValue="c.default ?? null" @update:modelValue="c.onInput">
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
</MkTextarea>
|
|
|
|
</MkTextarea>
|
|
|
|
<MkInput v-else-if="c.type === 'textInput'" :small="size === 'small'" :modelValue="c.default" @update:modelValue="c.onInput">
|
|
|
|
<MkInput v-else-if="c.type === 'textInput'" :small="size === 'small'" :modelValue="c.default ?? null" @update:modelValue="c.onInput">
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
</MkInput>
|
|
|
|
</MkInput>
|
|
|
|
<MkInput v-else-if="c.type === 'numberInput'" :small="size === 'small'" :modelValue="c.default" type="number" @update:modelValue="c.onInput">
|
|
|
|
<MkInput v-else-if="c.type === 'numberInput'" :small="size === 'small'" :modelValue="c.default ?? null" type="number" @update:modelValue="c.onInput">
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
</MkInput>
|
|
|
|
</MkInput>
|
|
|
|
<MkSelect v-else-if="c.type === 'select'" :small="size === 'small'" :modelValue="c.default" @update:modelValue="c.onChange">
|
|
|
|
<MkSelect v-else-if="c.type === 'select'" :small="size === 'small'" :modelValue="c.default ?? null" @update:modelValue="c.onChange">
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.label" #label>{{ c.label }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
<template v-if="c.caption" #caption>{{ c.caption }}</template>
|
|
|
|
<option v-for="item in c.items" :key="item.value" :value="item.value">{{ item.text }}</option>
|
|
|
|
<option v-for="item in c.items" :key="item.value" :value="item.value">{{ item.text }}</option>
|
|
|
|
@@ -42,8 +42,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
<MkPostForm
|
|
|
|
<MkPostForm
|
|
|
|
fixed
|
|
|
|
fixed
|
|
|
|
:instant="true"
|
|
|
|
:instant="true"
|
|
|
|
:initialText="c.form.text"
|
|
|
|
:initialText="c.form?.text"
|
|
|
|
:initialCw="c.form.cw"
|
|
|
|
:initialCw="c.form?.cw"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<MkFolder v-else-if="c.type === 'folder'" :defaultOpen="c.opened">
|
|
|
|
<MkFolder v-else-if="c.type === 'folder'" :defaultOpen="c.opened">
|
|
|
|
@@ -52,7 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
<MkAsUi v-if="!g(child).hidden" :component="g(child)" :components="props.components" :size="size"/>
|
|
|
|
<MkAsUi v-if="!g(child).hidden" :component="g(child)" :components="props.components" :size="size"/>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</MkFolder>
|
|
|
|
</MkFolder>
|
|
|
|
<div v-else-if="c.type === 'container'" :class="[$style.container, { [$style.fontSerif]: c.font === 'serif', [$style.fontMonospace]: c.font === 'monospace' }]" :style="{ textAlign: c.align ?? null, backgroundColor: c.bgColor ?? null, color: c.fgColor ?? null, borderWidth: c.borderWidth ? `${c.borderWidth}px` : 0, borderColor: c.borderColor ?? 'var(--divider)', padding: c.padding ? `${c.padding}px` : 0, borderRadius: c.rounded ? '8px' : 0 }">
|
|
|
|
<div v-else-if="c.type === 'container'" :class="[$style.container, { [$style.fontSerif]: c.font === 'serif', [$style.fontMonospace]: c.font === 'monospace' }]" :style="{ textAlign: c.align, backgroundColor: c.bgColor, color: c.fgColor, borderWidth: c.borderWidth ? `${c.borderWidth}px` : 0, borderColor: c.borderColor ?? 'var(--divider)', padding: c.padding ? `${c.padding}px` : 0, borderRadius: c.rounded ? '8px' : 0 }">
|
|
|
|
<template v-for="child in c.children" :key="child">
|
|
|
|
<template v-for="child in c.children" :key="child">
|
|
|
|
<MkAsUi v-if="!g(child).hidden" :component="g(child)" :components="props.components" :size="size" :align="c.align"/>
|
|
|
|
<MkAsUi v-if="!g(child).hidden" :component="g(child)" :components="props.components" :size="size" :align="c.align"/>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
@@ -68,7 +68,7 @@ import MkInput from '@/components/MkInput.vue';
|
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
|
|
|
import MkTextarea from '@/components/MkTextarea.vue';
|
|
|
|
import MkTextarea from '@/components/MkTextarea.vue';
|
|
|
|
import MkSelect from '@/components/MkSelect.vue';
|
|
|
|
import MkSelect from '@/components/MkSelect.vue';
|
|
|
|
import { AsUiComponent } from '@/scripts/aiscript/ui.js';
|
|
|
|
import { AsUiComponent, AsUiRoot, AsUiPostFormButton } from '@/scripts/aiscript/ui.js';
|
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
|
|
|
import MkFolder from '@/components/MkFolder.vue';
|
|
|
|
import MkPostForm from '@/components/MkPostForm.vue';
|
|
|
|
import MkPostForm from '@/components/MkPostForm.vue';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -85,20 +85,32 @@ const props = withDefaults(defineProps<{
|
|
|
|
const c = props.component;
|
|
|
|
const c = props.component;
|
|
|
|
|
|
|
|
|
|
|
|
function g(id) {
|
|
|
|
function g(id) {
|
|
|
|
return props.components.find(x => x.value.id === id).value;
|
|
|
|
const v = props.components.find(x => x.value.id === id)?.value;
|
|
|
|
|
|
|
|
if (v) return v;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
id: 'dummy',
|
|
|
|
|
|
|
|
type: 'root',
|
|
|
|
|
|
|
|
children: [],
|
|
|
|
|
|
|
|
} as AsUiRoot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const valueForSwitch = ref(c.default ?? false);
|
|
|
|
const valueForSwitch = ref('default' in c && typeof c.default === 'boolean' ? c.default : false);
|
|
|
|
|
|
|
|
|
|
|
|
function onSwitchUpdate(v) {
|
|
|
|
function onSwitchUpdate(v) {
|
|
|
|
valueForSwitch.value = v;
|
|
|
|
valueForSwitch.value = v;
|
|
|
|
if (c.onChange) c.onChange(v);
|
|
|
|
if ('onChange' in c && c.onChange) {
|
|
|
|
|
|
|
|
c.onChange(v as never);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function openPostForm() {
|
|
|
|
function openPostForm() {
|
|
|
|
|
|
|
|
const form = (c as AsUiPostFormButton).form;
|
|
|
|
|
|
|
|
if (!form) return;
|
|
|
|
|
|
|
|
|
|
|
|
os.post({
|
|
|
|
os.post({
|
|
|
|
initialText: c.form.text,
|
|
|
|
initialText: form.text,
|
|
|
|
initialCw: c.form.cw,
|
|
|
|
initialCw: form.cw,
|
|
|
|
instant: true,
|
|
|
|
instant: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|