Files
manolia-alpha/node_modules/buetify/lib/components/form/shared/useSelectionControl.js
Robin COuret e0e50af706 init component
2026-02-16 17:28:37 +01:00

54 lines
1.6 KiB
JavaScript
Executable File

import { getUseSelectablePropsDefinition, useSelectionControl as useControl } from '../../../composables/selectionControl/useSelectionControl';
import { defineComponent, shallowRef, h } from 'vue';
function generateCheck(variant) {
return h('span', {
class: [variant, 'check']
});
}
function generateInput(selectionControl) {
return h('input', {
onChange: selectionControl.onChange,
onBlur: selectionControl.onBlur,
onFocus: selectionControl.onFocus,
...selectionControl.attrs.value
});
}
function generateLabelText(selectionControl, slots) {
return h('span', {
class: 'control-label'
}, slots.default && slots.default());
}
export function useSelectionControl(role, type, name, staticClass) {
return () => defineComponent({
name,
props: getUseSelectablePropsDefinition(),
setup(props, {
slots
}) {
const label = shallowRef(null);
const selection = useControl(props, label, role, type);
return () => {
return h('label', {
class: [staticClass, props.size, {
'is-disabled': selection.isDisabled.value
}],
ref: label,
id: selection.label.labelId.value,
for: selection.label.id.value,
disabled: selection.isDisabled.value || null,
tabindex: selection.isDisabled.value ? -1 : 0,
onKeydown: selection.onKeydown,
onBlur: selection.onBlur,
onClick: selection.onClick
}, [generateInput(selection), generateCheck(props.variant), generateLabelText(selection, slots)]);
};
}
});
}
//# sourceMappingURL=useSelectionControl.js.map