@progress/kendo-vue-labels
Version:
78 lines (77 loc) • 2.27 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { defineComponent as n, createVNode as i, inject as d } from "vue";
import { getDefaultSlots as p, validatePackage as c } from "@progress/kendo-vue-common";
import { labelsOptional as r, messages as f } from "./messages/main.mjs";
import { provideLocalizationService as u } from "@progress/kendo-vue-intl";
import { packageMetadata as m } from "./package-metadata.mjs";
const L = /* @__PURE__ */ n({
name: "KendoLabel",
props: {
id: String,
editorId: String,
editorRef: String,
editorValid: {
type: Boolean,
default: void 0
},
editorDisabled: Boolean,
optional: Boolean
},
inject: {
kendoLocalizationService: {
default: null
}
},
created() {
c(m);
},
computed: {
labelClassName() {
return {
"k-label": !0,
"k-label-empty": !this.defaultSlots,
"k-text-error": this.$props.editorValid === !1,
"k-text-disabled": this.$props.editorDisabled === !0
};
}
},
methods: {
onLabelClick(e) {
if (this.$props.editorRef && this.$props.editorRef.current && !this.$props.editorDisabled) {
this.$props.editorRef.current.focus && (e.preventDefault(), this.$props.editorRef.current.focus());
const t = this.$props.editorRef.current.actionElement;
t && (e.preventDefault(), t.click());
}
}
},
setup() {
return {
kendoLocalizationService: d("kendoLocalizationService", {})
};
},
render() {
this.defaultSlots = p(this);
const e = u(this), {
id: t,
editorId: a,
optional: l
} = this.$props, o = l ? e.toLanguageString(r, f[r]) : "", s = o && i("span", {
class: "k-label-optional"
}, [o]);
return i("label", {
id: t,
for: a,
onClick: this.onLabelClick,
class: this.labelClassName
}, [this.defaultSlots, s]);
}
});
export {
L as Label
};