You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
3.7 KiB
69 lines
3.7 KiB
import { defineComponent, computed, mergeProps, useSSRContext } from 'vue';
|
|
import { ssrRenderAttrs, ssrRenderClass, ssrRenderList, ssrInterpolate, ssrIncludeBooleanAttr, ssrRenderAttr } from 'vue/server-renderer';
|
|
import { L as LANG_OPTIONS, l as langName } from './useLangOptions-DMhiAuTa.mjs';
|
|
import { _ as _export_sfc } from './server.mjs';
|
|
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "LangSelect",
|
|
__ssrInlineRender: true,
|
|
props: {
|
|
modelValue: {},
|
|
multiple: { type: Boolean, default: false },
|
|
disabled: { type: Boolean, default: false },
|
|
options: { default: void 0 }
|
|
},
|
|
emits: ["update:modelValue"],
|
|
setup(__props, { emit: __emit }) {
|
|
const props = __props;
|
|
const opts = computed(() => props.options && props.options.length ? props.options : LANG_OPTIONS);
|
|
const selected = computed(
|
|
() => (props.modelValue || "").split(",").map((s) => s.trim()).filter(Boolean)
|
|
);
|
|
function nameOf(code) {
|
|
return langName(code);
|
|
}
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(`<div${ssrRenderAttrs(mergeProps({ class: "lang-select" }, _attrs))} data-v-4903af59>`);
|
|
if (__props.multiple) {
|
|
_push(`<!--[--><div class="${ssrRenderClass([{ "lang-disabled": __props.disabled }, "lang-chips"])}" data-v-4903af59><!--[-->`);
|
|
ssrRenderList(selected.value, (code) => {
|
|
_push(`<span class="lang-chip" data-v-4903af59>${ssrInterpolate(code)}<span class="lang-chip-name" data-v-4903af59>${ssrInterpolate(nameOf(code))}</span><button type="button" class="lang-x" data-v-4903af59>×</button></span>`);
|
|
});
|
|
_push(`<!--]-->`);
|
|
if (!selected.value.length) {
|
|
_push(`<span class="lang-empty" data-v-4903af59>未选择语言</span>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
if (!__props.disabled) {
|
|
_push(`<details class="lang-dd" data-v-4903af59><summary class="lang-dd-sum" data-v-4903af59>+ 选择语言(已选 ${ssrInterpolate(selected.value.length)})</summary><div class="lang-dd-panel" data-v-4903af59><!--[-->`);
|
|
ssrRenderList(opts.value, (o) => {
|
|
_push(`<label class="lang-opt" data-v-4903af59><input type="checkbox" class="checkbox checkbox-xs checkbox-primary"${ssrIncludeBooleanAttr(selected.value.includes(o.code)) ? " checked" : ""} data-v-4903af59><span class="lang-opt-code" data-v-4903af59>${ssrInterpolate(o.code)}</span><span class="lang-opt-name" data-v-4903af59>${ssrInterpolate(o.name)}</span></label>`);
|
|
});
|
|
_push(`<!--]--></div></details>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
} else {
|
|
_push(`<select class="select select-bordered select-sm w-full text-xs"${ssrRenderAttr("value", __props.modelValue)}${ssrIncludeBooleanAttr(__props.disabled) ? " disabled" : ""} data-v-4903af59><option value="" data-v-4903af59>(未设置)</option><!--[-->`);
|
|
ssrRenderList(opts.value, (o) => {
|
|
_push(`<option${ssrRenderAttr("value", o.code)} data-v-4903af59>${ssrInterpolate(o.code)} · ${ssrInterpolate(o.name)}</option>`);
|
|
});
|
|
_push(`<!--]--></select>`);
|
|
}
|
|
_push(`</div>`);
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup = _sfc_main.setup;
|
|
_sfc_main.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/LangSelect.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
const __nuxt_component_0 = /* @__PURE__ */ Object.assign(_export_sfc(_sfc_main, [["__scopeId", "data-v-4903af59"]]), { __name: "LangSelect" });
|
|
|
|
export { __nuxt_component_0 as _ };
|
|
//# sourceMappingURL=LangSelect-C_QPlcDf.mjs.map
|
|
|