2023-05-24 11:15:28 +00:00
|
|
|
<script>
|
|
|
|
import BaseComponent from 'primevue/basecomponent';
|
|
|
|
import { useStyle } from 'primevue/usestyle';
|
|
|
|
|
|
|
|
const styles = `
|
2023-09-25 19:11:55 +00:00
|
|
|
@layer primevue {
|
|
|
|
.p-inputswitch {
|
|
|
|
display: inline-block;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-inputswitch-slider {
|
|
|
|
position: absolute;
|
|
|
|
cursor: pointer;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
border: 1px solid transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.p-inputswitch-slider:before {
|
|
|
|
position: absolute;
|
|
|
|
content: '';
|
|
|
|
top: 50%;
|
|
|
|
}
|
2023-05-24 11:15:28 +00:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const inlineStyles = {
|
|
|
|
root: { position: 'relative' }
|
|
|
|
};
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
root: ({ instance, props }) => [
|
|
|
|
'p-inputswitch p-component',
|
|
|
|
{
|
|
|
|
'p-inputswitch-checked': instance.checked,
|
|
|
|
'p-disabled': props.disabled,
|
|
|
|
'p-focus': instance.focused
|
|
|
|
}
|
|
|
|
],
|
|
|
|
slider: 'p-inputswitch-slider'
|
|
|
|
};
|
|
|
|
|
2023-07-03 22:20:35 +00:00
|
|
|
const { load: loadStyle } = useStyle(styles, { name: 'inputswitch', manual: true });
|
2023-05-24 11:15:28 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'BaseInputSwitch',
|
|
|
|
extends: BaseComponent,
|
|
|
|
props: {
|
|
|
|
modelValue: {
|
|
|
|
type: null,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
trueValue: {
|
|
|
|
type: null,
|
|
|
|
default: true
|
|
|
|
},
|
|
|
|
falseValue: {
|
|
|
|
type: null,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
inputId: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
inputClass: {
|
|
|
|
type: [String, Object],
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
inputStyle: {
|
|
|
|
type: Object,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
inputProps: {
|
|
|
|
type: null,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
'aria-labelledby': {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
'aria-label': {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
classes,
|
2023-05-30 11:06:57 +00:00
|
|
|
inlineStyles,
|
|
|
|
loadStyle
|
2023-05-24 11:15:28 +00:00
|
|
|
},
|
2023-05-30 11:06:57 +00:00
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
$parentInstance: this
|
|
|
|
};
|
2023-05-24 11:15:28 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|