init component
This commit is contained in:
1
node_modules/buetify/lib/composables/selectionControl/index.d.ts
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/selectionControl/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
export * from './useSelectionControl';
|
||||
2
node_modules/buetify/lib/composables/selectionControl/index.js
generated
vendored
Executable file
2
node_modules/buetify/lib/composables/selectionControl/index.js
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export * from './useSelectionControl';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/buetify/lib/composables/selectionControl/index.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/selectionControl/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/composables/selectionControl/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAd","sourcesContent":["export * from './useSelectionControl';\n"],"sourceRoot":"","file":"index.js"}
|
||||
144
node_modules/buetify/lib/composables/selectionControl/useSelectionControl.d.ts
generated
vendored
Executable file
144
node_modules/buetify/lib/composables/selectionControl/useSelectionControl.d.ts
generated
vendored
Executable file
@@ -0,0 +1,144 @@
|
||||
import { Eq } from 'fp-ts/lib/Eq';
|
||||
import { PropType, Ref, ComputedRef } from 'vue';
|
||||
import { ColorVariant } from '../../types/ColorVariants';
|
||||
import { SizeVariant } from '../../types/SizeVariants';
|
||||
import { UseDisableProps } from '../disable';
|
||||
import { UseLabelIdProps } from '../labelId';
|
||||
import { UseModelProps } from '../model';
|
||||
import { EqProps } from '../shared';
|
||||
export declare function getUseSelectablePropsDefinition<T>(): {
|
||||
isFocused: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
onFocus: {
|
||||
type: PropType<(e?: Event | undefined) => void>;
|
||||
required: false;
|
||||
};
|
||||
onBlur: {
|
||||
type: PropType<(e?: Event | undefined) => void>;
|
||||
required: false;
|
||||
};
|
||||
focusOnMount: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
labelFor: PropType<string>;
|
||||
label: {
|
||||
type: PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
isDisabled: {
|
||||
type: PropType<boolean>;
|
||||
required: boolean;
|
||||
default: boolean;
|
||||
};
|
||||
isReadonly: {
|
||||
type: PropType<boolean>;
|
||||
required: boolean;
|
||||
default: boolean;
|
||||
};
|
||||
disableIfReadonly: {
|
||||
type: PropType<boolean>;
|
||||
required: boolean;
|
||||
default: boolean;
|
||||
};
|
||||
modelValue: {
|
||||
type: PropType<T>;
|
||||
required: false;
|
||||
};
|
||||
'onUpdate:modelValue': {
|
||||
type: PropType<import("fp-ts/lib/function").FunctionN<[T], void>>;
|
||||
default: import("fp-ts/lib/function").Lazy<import("fp-ts/lib/function").FunctionN<[T], void>>;
|
||||
};
|
||||
eq: {
|
||||
type: PropType<Eq<T>>;
|
||||
default: import("fp-ts/lib/function").Lazy<Eq<T>>;
|
||||
};
|
||||
nativeValue: {
|
||||
type: PropType<unknown>;
|
||||
required: boolean;
|
||||
default: null;
|
||||
};
|
||||
trueValue: {
|
||||
type: PropType<T>;
|
||||
default: T;
|
||||
};
|
||||
falseValue: {
|
||||
type: PropType<T>;
|
||||
default: T;
|
||||
};
|
||||
isIndeterminate: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
isMultiple: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
variant: {
|
||||
type: PropType<ColorVariant>;
|
||||
default: ColorVariant;
|
||||
};
|
||||
size: {
|
||||
type: PropType<SizeVariant>;
|
||||
default: SizeVariant;
|
||||
};
|
||||
isRequired: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
name: {
|
||||
type: PropType<string>;
|
||||
required: boolean;
|
||||
};
|
||||
};
|
||||
export declare type UseSelectableProps<T> = {
|
||||
nativeValue: unknown;
|
||||
trueValue: T;
|
||||
falseValue: T;
|
||||
indeterminateValue?: T;
|
||||
isMultiple: boolean;
|
||||
variant: ColorVariant;
|
||||
size: SizeVariant;
|
||||
isRequired: boolean;
|
||||
isIndeterminate: boolean;
|
||||
name?: string;
|
||||
} & EqProps<T> & UseModelProps<T> & UseDisableProps & UseLabelIdProps;
|
||||
export declare function useSelectionControl<T>(props: UseSelectableProps<T>, ref: Ref<HTMLElement>, role: string, type: string): {
|
||||
isDisabled: Ref<boolean>;
|
||||
isMultiple: ComputedRef<boolean>;
|
||||
isActive: ComputedRef<boolean>;
|
||||
attrs: ComputedRef<{
|
||||
role: string;
|
||||
type: string;
|
||||
id: string;
|
||||
name: string | undefined;
|
||||
checked: boolean;
|
||||
'aria-checked': boolean;
|
||||
'aria-disabled': boolean;
|
||||
'aria-labelledby': string;
|
||||
tabindex: number;
|
||||
readonly: boolean;
|
||||
disabled: boolean;
|
||||
required: boolean;
|
||||
indeterminate: boolean | undefined;
|
||||
value: string;
|
||||
'true-value': string;
|
||||
'false-value': string;
|
||||
}>;
|
||||
onChange: () => void;
|
||||
onKeydown: (e: KeyboardEvent) => void;
|
||||
onClick: () => void;
|
||||
label: {
|
||||
id: ComputedRef<string>;
|
||||
labelId: ComputedRef<string>;
|
||||
label: Ref<string>;
|
||||
};
|
||||
isFocused: Ref<boolean>;
|
||||
focus: (e?: Event | undefined) => void;
|
||||
onFocus: (e?: Event | undefined) => void;
|
||||
onBlur: (e?: Event | undefined) => void;
|
||||
modelValue: Ref<T | undefined>;
|
||||
};
|
||||
export declare type SelectionControl = ReturnType<typeof useSelectionControl>;
|
||||
150
node_modules/buetify/lib/composables/selectionControl/useSelectionControl.js
generated
vendored
Executable file
150
node_modules/buetify/lib/composables/selectionControl/useSelectionControl.js
generated
vendored
Executable file
@@ -0,0 +1,150 @@
|
||||
import { computed, toRef } from 'vue';
|
||||
import { isEnterEvent, isSpaceEvent } from '../../utils/eventHelpers';
|
||||
import { toggleListItem } from '../../utils/helpers';
|
||||
import { useDisable, UseDisablePropsDefinition } from '../disable';
|
||||
import { useFocus, UseFocusPropsDefinition } from '../focus';
|
||||
import { useLabelId, UseLabelIdPropsDefinition } from '../labelId';
|
||||
import { getUseModelPropsDefinition, useModel } from '../model';
|
||||
import { getEqPropsDefinition } from '../shared';
|
||||
export function getUseSelectablePropsDefinition() {
|
||||
return {
|
||||
nativeValue: {
|
||||
type: null,
|
||||
required: false,
|
||||
default: null
|
||||
},
|
||||
trueValue: {
|
||||
type: null,
|
||||
default: true
|
||||
},
|
||||
falseValue: {
|
||||
type: null,
|
||||
default: false
|
||||
},
|
||||
isIndeterminate: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isMultiple: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
variant: {
|
||||
type: String,
|
||||
default: 'is-primary'
|
||||
},
|
||||
size: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
isRequired: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
required: false
|
||||
},
|
||||
...getEqPropsDefinition(),
|
||||
...getUseModelPropsDefinition(),
|
||||
...UseDisablePropsDefinition,
|
||||
...UseLabelIdPropsDefinition,
|
||||
...UseFocusPropsDefinition
|
||||
};
|
||||
}
|
||||
|
||||
function getIsActive(value, trueValue, isMultiple, eq) {
|
||||
if (isMultiple) {
|
||||
if (!Array.isArray(value)) return false;
|
||||
return trueValue !== undefined && value.some(item => eq.equals(item, trueValue));
|
||||
}
|
||||
|
||||
if (!Array.isArray(value) && trueValue !== undefined) {
|
||||
return value !== undefined && eq.equals(value, trueValue);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getOnChange(value, trueValue, falseValue, isDisabled, isMultiple, eq) {
|
||||
return function onChange() {
|
||||
if (isDisabled.value) return;
|
||||
if (trueValue.value === undefined) return;
|
||||
const currentValue = value.value;
|
||||
const tValue = trueValue.value;
|
||||
const fValue = falseValue.value;
|
||||
|
||||
if (isMultiple.value) {
|
||||
if (!Array.isArray(currentValue)) {
|
||||
value.value = [];
|
||||
} else {
|
||||
value.value = toggleListItem(eq.value)(tValue, currentValue);
|
||||
}
|
||||
} else if (!Array.isArray(currentValue)) {
|
||||
if (currentValue === undefined || currentValue !== undefined && !eq.value.equals(currentValue, tValue)) {
|
||||
value.value = tValue;
|
||||
} else {
|
||||
value.value = fValue;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getInputAttrs(role, type, id, labelId, isActive, isDisabled, isReadonly, isRequired, trueValue, falseValue, nativeValue, isIndeterminate, name) {
|
||||
return {
|
||||
role,
|
||||
type,
|
||||
id,
|
||||
name,
|
||||
checked: isActive,
|
||||
'aria-checked': isActive,
|
||||
'aria-disabled': isDisabled,
|
||||
'aria-labelledby': labelId,
|
||||
tabindex: -1,
|
||||
readonly: isReadonly,
|
||||
disabled: isDisabled,
|
||||
required: isRequired,
|
||||
indeterminate: isIndeterminate,
|
||||
value: JSON.stringify(nativeValue),
|
||||
'true-value': JSON.stringify(trueValue),
|
||||
'false-value': JSON.stringify(falseValue)
|
||||
};
|
||||
}
|
||||
|
||||
export function useSelectionControl(props, ref, role, type) {
|
||||
const {
|
||||
modelValue
|
||||
} = useModel(props);
|
||||
const focus = useFocus(props, ref);
|
||||
const trueValue = computed(() => props.nativeValue || props.trueValue);
|
||||
const label = useLabelId(props, role);
|
||||
const isMultiple = computed(() => props.isMultiple || Array.isArray(modelValue.value));
|
||||
const isActive = computed(() => getIsActive(modelValue.value, trueValue.value, isMultiple.value, props.eq));
|
||||
const isDisabled = useDisable(props);
|
||||
const onChange = getOnChange(modelValue, trueValue, toRef(props, 'falseValue'), isDisabled, isMultiple, toRef(props, 'eq'));
|
||||
const attrs = computed(() => getInputAttrs(role, type, label.id.value, label.labelId.value, isActive.value, isDisabled.value, props.isReadonly, props.isRequired, props.trueValue, props.falseValue, props.nativeValue, props.isIndeterminate, props.name));
|
||||
|
||||
function onKeydown(e) {
|
||||
if (isEnterEvent(e) || isSpaceEvent(e)) {
|
||||
ref.value?.click();
|
||||
}
|
||||
}
|
||||
|
||||
function onClick() {
|
||||
focus.focus();
|
||||
}
|
||||
|
||||
return {
|
||||
modelValue,
|
||||
...focus,
|
||||
isDisabled,
|
||||
isMultiple,
|
||||
isActive,
|
||||
attrs,
|
||||
onChange,
|
||||
onKeydown,
|
||||
onClick,
|
||||
label
|
||||
};
|
||||
}
|
||||
//# sourceMappingURL=useSelectionControl.js.map
|
||||
1
node_modules/buetify/lib/composables/selectionControl/useSelectionControl.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/composables/selectionControl/useSelectionControl.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user