Merge branch 'v4.2.0-form' of https://github.com/primefaces/primevue into v4.2.0-form
commit
debb54cf37
|
@ -22,7 +22,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
initialValues: {
|
initialValues: {
|
||||||
slider: null
|
slider: 0
|
||||||
},
|
},
|
||||||
resolver: zodResolver(
|
resolver: zodResolver(
|
||||||
z.object({
|
z.object({
|
||||||
|
@ -60,7 +60,7 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
initialValues: {
|
initialValues: {
|
||||||
slider: null
|
slider: 0
|
||||||
},
|
},
|
||||||
resolver: zodResolver(
|
resolver: zodResolver(
|
||||||
z.object({
|
z.object({
|
||||||
|
@ -101,7 +101,7 @@ import { z } from 'zod';
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const initialValues = ref({
|
const initialValues = ref({
|
||||||
slider: null
|
slider: 0
|
||||||
});
|
});
|
||||||
const resolver = ref(zodResolver(
|
const resolver = ref(zodResolver(
|
||||||
z.object({
|
z.object({
|
||||||
|
|
|
@ -355,7 +355,7 @@ export default {
|
||||||
this.focusedOptionIndex = -1;
|
this.focusedOptionIndex = -1;
|
||||||
this.searchValue = '';
|
this.searchValue = '';
|
||||||
this.$emit('blur', event);
|
this.$emit('blur', event);
|
||||||
this.formField.onBlur?.();
|
this.formField.onBlur?.(event);
|
||||||
},
|
},
|
||||||
onKeyDown(event) {
|
onKeyDown(event) {
|
||||||
if (this.disabled || isAndroid()) {
|
if (this.disabled || isAndroid()) {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<script>
|
<script>
|
||||||
import BaseComponent from '@primevue/core/basecomponent';
|
import BaseEditableHolder from '@primevue/core/baseeditableholder';
|
||||||
import SliderStyle from 'primevue/slider/style';
|
import SliderStyle from 'primevue/slider/style';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'BaseSlider',
|
name: 'BaseSlider',
|
||||||
extends: BaseComponent,
|
extends: BaseEditableHolder,
|
||||||
props: {
|
props: {
|
||||||
modelValue: [Number, Array],
|
|
||||||
min: {
|
min: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0
|
||||||
|
@ -27,10 +26,6 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
tabindex: {
|
tabindex: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 0
|
default: 0
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
@touchend="onDragEnd($event)"
|
@touchend="onDragEnd($event)"
|
||||||
@mousedown="onMouseDown($event)"
|
@mousedown="onMouseDown($event)"
|
||||||
@keydown="onKeyDown($event)"
|
@keydown="onKeyDown($event)"
|
||||||
|
@blur="onBlur($event)"
|
||||||
:tabindex="tabindex"
|
:tabindex="tabindex"
|
||||||
role="slider"
|
role="slider"
|
||||||
:aria-valuemin="min"
|
:aria-valuemin="min"
|
||||||
:aria-valuenow="modelValue"
|
:aria-valuenow="d_value"
|
||||||
:aria-valuemax="max"
|
:aria-valuemax="max"
|
||||||
:aria-labelledby="ariaLabelledby"
|
:aria-labelledby="ariaLabelledby"
|
||||||
:aria-label="ariaLabel"
|
:aria-label="ariaLabel"
|
||||||
|
@ -29,10 +30,11 @@
|
||||||
@touchend="onDragEnd($event)"
|
@touchend="onDragEnd($event)"
|
||||||
@mousedown="onMouseDown($event, 0)"
|
@mousedown="onMouseDown($event, 0)"
|
||||||
@keydown="onKeyDown($event, 0)"
|
@keydown="onKeyDown($event, 0)"
|
||||||
|
@blur="onBlur($event, 0)"
|
||||||
:tabindex="tabindex"
|
:tabindex="tabindex"
|
||||||
role="slider"
|
role="slider"
|
||||||
:aria-valuemin="min"
|
:aria-valuemin="min"
|
||||||
:aria-valuenow="modelValue ? modelValue[0] : null"
|
:aria-valuenow="d_value ? d_value[0] : null"
|
||||||
:aria-valuemax="max"
|
:aria-valuemax="max"
|
||||||
:aria-labelledby="ariaLabelledby"
|
:aria-labelledby="ariaLabelledby"
|
||||||
:aria-label="ariaLabel"
|
:aria-label="ariaLabel"
|
||||||
|
@ -48,10 +50,11 @@
|
||||||
@touchend="onDragEnd($event)"
|
@touchend="onDragEnd($event)"
|
||||||
@mousedown="onMouseDown($event, 1)"
|
@mousedown="onMouseDown($event, 1)"
|
||||||
@keydown="onKeyDown($event, 1)"
|
@keydown="onKeyDown($event, 1)"
|
||||||
|
@blur="onBlur($event, 1)"
|
||||||
:tabindex="tabindex"
|
:tabindex="tabindex"
|
||||||
role="slider"
|
role="slider"
|
||||||
:aria-valuemin="min"
|
:aria-valuemin="min"
|
||||||
:aria-valuenow="modelValue ? modelValue[1] : null"
|
:aria-valuenow="d_value ? d_value[1] : null"
|
||||||
:aria-valuemax="max"
|
:aria-valuemax="max"
|
||||||
:aria-labelledby="ariaLabelledby"
|
:aria-labelledby="ariaLabelledby"
|
||||||
:aria-label="ariaLabel"
|
:aria-label="ariaLabel"
|
||||||
|
@ -62,14 +65,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getWindowScrollLeft, getWindowScrollTop, getAttribute } from '@primeuix/utils/dom';
|
import { getAttribute, getWindowScrollLeft, getWindowScrollTop } from '@primeuix/utils/dom';
|
||||||
import BaseSlider from './BaseSlider.vue';
|
import BaseSlider from './BaseSlider.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Slider',
|
name: 'Slider',
|
||||||
extends: BaseSlider,
|
extends: BaseSlider,
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
emits: ['update:modelValue', 'change', 'slideend'],
|
emits: ['change', 'slideend'],
|
||||||
dragging: false,
|
dragging: false,
|
||||||
handleIndex: null,
|
handleIndex: null,
|
||||||
initX: null,
|
initX: null,
|
||||||
|
@ -136,7 +139,7 @@ export default {
|
||||||
modelValue = newValue;
|
modelValue = newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('update:modelValue', modelValue);
|
this.updateValue(modelValue, event);
|
||||||
this.$emit('change', modelValue);
|
this.$emit('change', modelValue);
|
||||||
},
|
},
|
||||||
onDragStart(event, index) {
|
onDragStart(event, index) {
|
||||||
|
@ -224,6 +227,9 @@ export default {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onBlur(event, index) {
|
||||||
|
this.formField.onBlur?.(event);
|
||||||
|
},
|
||||||
decrementValue(event, index, pageKey = false) {
|
decrementValue(event, index, pageKey = false) {
|
||||||
let newValue;
|
let newValue;
|
||||||
|
|
||||||
|
@ -280,10 +286,10 @@ export default {
|
||||||
computed: {
|
computed: {
|
||||||
value() {
|
value() {
|
||||||
if (this.range) {
|
if (this.range) {
|
||||||
return [this.modelValue?.[0] ?? this.min, this.modelValue?.[1] ?? this.max];
|
return [this.d_value?.[0] ?? this.min, this.d_value?.[1] ?? this.max];
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.modelValue ?? this.min;
|
return this.d_value ?? this.min;
|
||||||
},
|
},
|
||||||
horizontal() {
|
horizontal() {
|
||||||
return this.orientation === 'horizontal';
|
return this.orientation === 'horizontal';
|
||||||
|
|
|
@ -95,10 +95,11 @@ const inlineStyles = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const classes = {
|
const classes = {
|
||||||
root: ({ props }) => [
|
root: ({ instance, props }) => [
|
||||||
'p-slider p-component',
|
'p-slider p-component',
|
||||||
{
|
{
|
||||||
'p-disabled': props.disabled,
|
'p-disabled': props.disabled,
|
||||||
|
'p-invalid': instance.$invalid,
|
||||||
'p-slider-horizontal': props.orientation === 'horizontal',
|
'p-slider-horizontal': props.orientation === 'horizontal',
|
||||||
'p-slider-vertical': props.orientation === 'vertical'
|
'p-slider-vertical': props.orientation === 'vertical'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue