mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 17:02:38 +00:00
Refactor #3922 - For InputSwitch
This commit is contained in:
parent
6539ba296d
commit
636bd1de8f
4 changed files with 66 additions and 4 deletions
|
@ -40,6 +40,12 @@ const InputSwitchProps = [
|
||||||
type: 'object',
|
type: 'object',
|
||||||
default: 'null',
|
default: 'null',
|
||||||
description: 'Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component.'
|
description: 'Uses to pass all properties of the HTMLInputElement to the focusable input element inside the component.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pt',
|
||||||
|
type: 'any',
|
||||||
|
default: 'null',
|
||||||
|
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
2
components/lib/config/PrimeVue.d.ts
vendored
2
components/lib/config/PrimeVue.d.ts
vendored
|
@ -32,6 +32,7 @@ import { InlineMessagePassThroughOptions } from '../inlinemessage';
|
||||||
import { InplacePassThroughOptions } from '../inplace';
|
import { InplacePassThroughOptions } from '../inplace';
|
||||||
import { InputMaskPassThroughOptions } from '../inputmask';
|
import { InputMaskPassThroughOptions } from '../inputmask';
|
||||||
import { InputNumberPassThroughOptions } from '../inputnumber';
|
import { InputNumberPassThroughOptions } from '../inputnumber';
|
||||||
|
import { InputSwitchPassThroughOptions } from '../inputswitch';
|
||||||
import { InputTextPassThroughOptions } from '../inputtext';
|
import { InputTextPassThroughOptions } from '../inputtext';
|
||||||
import { MegaMenuPassThroughOptions } from '../megamenu';
|
import { MegaMenuPassThroughOptions } from '../megamenu';
|
||||||
import { MenuPassThroughOptions } from '../menu';
|
import { MenuPassThroughOptions } from '../menu';
|
||||||
|
@ -110,6 +111,7 @@ interface PrimeVuePTOptions {
|
||||||
inplace?: InplacePassThroughOptions;
|
inplace?: InplacePassThroughOptions;
|
||||||
inputmask?: InputMaskPassThroughOptions;
|
inputmask?: InputMaskPassThroughOptions;
|
||||||
inputnumber?: InputNumberPassThroughOptions;
|
inputnumber?: InputNumberPassThroughOptions;
|
||||||
|
inputswitch?: InputSwitchPassThroughOptions;
|
||||||
inputtext?: InputTextPassThroughOptions;
|
inputtext?: InputTextPassThroughOptions;
|
||||||
megamenu?: MegaMenuPassThroughOptions;
|
megamenu?: MegaMenuPassThroughOptions;
|
||||||
menu?: MenuPassThroughOptions;
|
menu?: MenuPassThroughOptions;
|
||||||
|
|
51
components/lib/inputswitch/InputSwitch.d.ts
vendored
51
components/lib/inputswitch/InputSwitch.d.ts
vendored
|
@ -10,6 +10,57 @@
|
||||||
import { InputHTMLAttributes } from 'vue';
|
import { InputHTMLAttributes } from 'vue';
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
|
export declare type InputSwitchPassThroughOptionType = InputSwitchPassThroughAttributes | ((options: InputSwitchPassThroughMethodOptions) => InputSwitchPassThroughAttributes) | null | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) option method.
|
||||||
|
*/
|
||||||
|
export interface InputSwitchPassThroughMethodOptions {
|
||||||
|
props: InputSwitchProps;
|
||||||
|
state: InputSwitchState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) options.
|
||||||
|
* @see {@link InputSwitchProps.pt}
|
||||||
|
*/
|
||||||
|
export interface InputSwitchPassThroughOptions {
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the root's DOM element.
|
||||||
|
*/
|
||||||
|
root?: InputSwitchPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the slider's DOM element.
|
||||||
|
*/
|
||||||
|
slider?: InputSwitchPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the hidden accessible DOM element.
|
||||||
|
*/
|
||||||
|
hiddenAccessible?: InputSwitchPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the input aria's DOM element.
|
||||||
|
*/
|
||||||
|
inputAria?: InputSwitchPassThroughOptionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough attributes for each DOM elements
|
||||||
|
*/
|
||||||
|
export interface InputSwitchPassThroughAttributes {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines current inline state in InputSwitch component.
|
||||||
|
*/
|
||||||
|
export interface InputSwitchState {
|
||||||
|
/**
|
||||||
|
* Current focus state as a boolean.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
focused: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines valid properties in InputSwitch component.
|
* Defines valid properties in InputSwitch component.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="containerClass" @click="onClick($event)">
|
<div :class="containerClass" @click="onClick($event)" v-bind="ptm('root')">
|
||||||
<div class="p-hidden-accessible">
|
<div class="p-hidden-accessible" v-bind="ptm('hiddenAccessible')">
|
||||||
<input
|
<input
|
||||||
ref="input"
|
ref="input"
|
||||||
:id="inputId"
|
:id="inputId"
|
||||||
|
@ -15,16 +15,19 @@
|
||||||
:aria-label="ariaLabel"
|
:aria-label="ariaLabel"
|
||||||
@focus="onFocus($event)"
|
@focus="onFocus($event)"
|
||||||
@blur="onBlur($event)"
|
@blur="onBlur($event)"
|
||||||
v-bind="inputProps"
|
v-bind="ptm('inputAria')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span class="p-inputswitch-slider"></span>
|
<span class="p-inputswitch-slider" v-bind="{ ...inputProps, ...ptm('slider') }"></span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import BaseComponent from 'primevue/basecomponent';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'InputSwitch',
|
name: 'InputSwitch',
|
||||||
|
extends: BaseComponent,
|
||||||
emits: ['click', 'update:modelValue', 'change', 'input', 'focus', 'blur'],
|
emits: ['click', 'update:modelValue', 'change', 'input', 'focus', 'blur'],
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue