first commit
This commit is contained in:
58
node_modules/vant/es/switch/Switch.d.ts
generated
vendored
Normal file
58
node_modules/vant/es/switch/Switch.d.ts
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
import { type ExtractPropTypes } from 'vue';
|
||||
export declare const switchProps: {
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
loading: BooleanConstructor;
|
||||
disabled: BooleanConstructor;
|
||||
modelValue: import("vue").PropType<unknown>;
|
||||
activeColor: StringConstructor;
|
||||
inactiveColor: StringConstructor;
|
||||
activeValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
inactiveValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
};
|
||||
export type SwitchProps = ExtractPropTypes<typeof switchProps>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
loading: BooleanConstructor;
|
||||
disabled: BooleanConstructor;
|
||||
modelValue: import("vue").PropType<unknown>;
|
||||
activeColor: StringConstructor;
|
||||
inactiveColor: StringConstructor;
|
||||
activeValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
inactiveValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "change")[], "update:modelValue" | "change", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
loading: BooleanConstructor;
|
||||
disabled: BooleanConstructor;
|
||||
modelValue: import("vue").PropType<unknown>;
|
||||
activeColor: StringConstructor;
|
||||
inactiveColor: StringConstructor;
|
||||
activeValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
inactiveValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
disabled: boolean;
|
||||
loading: boolean;
|
||||
activeValue: unknown;
|
||||
inactiveValue: unknown;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
85
node_modules/vant/es/switch/Switch.mjs
generated
vendored
Normal file
85
node_modules/vant/es/switch/Switch.mjs
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { defineComponent, createVNode as _createVNode } from "vue";
|
||||
import { addUnit, numericProp, unknownProp, createNamespace } from "../utils/index.mjs";
|
||||
import { useCustomFieldValue } from "@vant/use";
|
||||
import { Loading } from "../loading/index.mjs";
|
||||
const [name, bem] = createNamespace("switch");
|
||||
const switchProps = {
|
||||
size: numericProp,
|
||||
loading: Boolean,
|
||||
disabled: Boolean,
|
||||
modelValue: unknownProp,
|
||||
activeColor: String,
|
||||
inactiveColor: String,
|
||||
activeValue: {
|
||||
type: unknownProp,
|
||||
default: true
|
||||
},
|
||||
inactiveValue: {
|
||||
type: unknownProp,
|
||||
default: false
|
||||
}
|
||||
};
|
||||
var stdin_default = defineComponent({
|
||||
name,
|
||||
props: switchProps,
|
||||
emits: ["change", "update:modelValue"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const isChecked = () => props.modelValue === props.activeValue;
|
||||
const onClick = () => {
|
||||
if (!props.disabled && !props.loading) {
|
||||
const newValue = isChecked() ? props.inactiveValue : props.activeValue;
|
||||
emit("update:modelValue", newValue);
|
||||
emit("change", newValue);
|
||||
}
|
||||
};
|
||||
const renderLoading = () => {
|
||||
if (props.loading) {
|
||||
const color = isChecked() ? props.activeColor : props.inactiveColor;
|
||||
return _createVNode(Loading, {
|
||||
"class": bem("loading"),
|
||||
"color": color
|
||||
}, null);
|
||||
}
|
||||
if (slots.node) {
|
||||
return slots.node();
|
||||
}
|
||||
};
|
||||
useCustomFieldValue(() => props.modelValue);
|
||||
return () => {
|
||||
var _a;
|
||||
const {
|
||||
size,
|
||||
loading,
|
||||
disabled,
|
||||
activeColor,
|
||||
inactiveColor
|
||||
} = props;
|
||||
const checked = isChecked();
|
||||
const style = {
|
||||
fontSize: addUnit(size),
|
||||
backgroundColor: checked ? activeColor : inactiveColor
|
||||
};
|
||||
return _createVNode("div", {
|
||||
"role": "switch",
|
||||
"class": bem({
|
||||
on: checked,
|
||||
loading,
|
||||
disabled
|
||||
}),
|
||||
"style": style,
|
||||
"tabindex": disabled ? void 0 : 0,
|
||||
"aria-checked": checked,
|
||||
"onClick": onClick
|
||||
}, [_createVNode("div", {
|
||||
"class": bem("node")
|
||||
}, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
|
||||
};
|
||||
}
|
||||
});
|
||||
export {
|
||||
stdin_default as default,
|
||||
switchProps
|
||||
};
|
||||
1
node_modules/vant/es/switch/index.css
generated
vendored
Normal file
1
node_modules/vant/es/switch/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-switch-size: 26px;--van-switch-width: calc(1.8em + 4px) ;--van-switch-height: calc(1em + 4px) ;--van-switch-node-size: 1em;--van-switch-node-background: var(--van-white);--van-switch-node-shadow: 0 3px 1px 0 rgba(0, 0, 0, .05);--van-switch-background: rgba(120, 120, 128, .16);--van-switch-on-background: var(--van-primary-color);--van-switch-duration: var(--van-duration-base);--van-switch-disabled-opacity: var(--van-disabled-opacity)}.van-theme-dark{--van-switch-background: rgba(120, 120, 128, .32)}.van-switch{position:relative;display:inline-block;box-sizing:content-box;width:var(--van-switch-width);height:var(--van-switch-height);font-size:var(--van-switch-size);background:var(--van-switch-background);border-radius:var(--van-switch-node-size);cursor:pointer;transition:background-color var(--van-switch-duration)}.van-switch__node{position:absolute;top:2px;left:2px;width:var(--van-switch-node-size);height:var(--van-switch-node-size);font-size:inherit;background:var(--van-switch-node-background);border-radius:100%;box-shadow:var(--van-switch-node-shadow);transition:transform var(--van-switch-duration) cubic-bezier(.3,1.05,.4,1.05)}.van-switch__loading{top:25%;left:25%;width:50%;height:50%;line-height:1}.van-switch--on{background:var(--van-switch-on-background)}.van-switch--on .van-switch__node{transform:translate(calc(var(--van-switch-width) - var(--van-switch-node-size) - 4px))}.van-switch--on .van-switch__loading{color:var(--van-switch-on-background)}.van-switch--disabled{cursor:not-allowed;opacity:var(--van-switch-disabled-opacity)}.van-switch--loading{cursor:default}
|
||||
48
node_modules/vant/es/switch/index.d.ts
generated
vendored
Normal file
48
node_modules/vant/es/switch/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
export declare const Switch: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
loading: BooleanConstructor;
|
||||
disabled: BooleanConstructor;
|
||||
modelValue: import("vue").PropType<unknown>;
|
||||
activeColor: StringConstructor;
|
||||
inactiveColor: StringConstructor;
|
||||
activeValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
inactiveValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "change")[], "update:modelValue" | "change", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
size: (NumberConstructor | StringConstructor)[];
|
||||
loading: BooleanConstructor;
|
||||
disabled: BooleanConstructor;
|
||||
modelValue: import("vue").PropType<unknown>;
|
||||
activeColor: StringConstructor;
|
||||
inactiveColor: StringConstructor;
|
||||
activeValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
inactiveValue: {
|
||||
type: import("vue").PropType<unknown>;
|
||||
default: unknown;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onChange?: ((...args: any[]) => any) | undefined;
|
||||
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
disabled: boolean;
|
||||
loading: boolean;
|
||||
activeValue: unknown;
|
||||
inactiveValue: unknown;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default Switch;
|
||||
export { switchProps } from './Switch';
|
||||
export type { SwitchProps } from './Switch';
|
||||
export type { SwitchThemeVars } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
VanSwitch: typeof Switch;
|
||||
}
|
||||
}
|
||||
10
node_modules/vant/es/switch/index.mjs
generated
vendored
Normal file
10
node_modules/vant/es/switch/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { withInstall } from "../utils/index.mjs";
|
||||
import _Switch from "./Switch.mjs";
|
||||
const Switch = withInstall(_Switch);
|
||||
var stdin_default = Switch;
|
||||
import { switchProps } from "./Switch.mjs";
|
||||
export {
|
||||
Switch,
|
||||
stdin_default as default,
|
||||
switchProps
|
||||
};
|
||||
1
node_modules/vant/es/switch/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/es/switch/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
3
node_modules/vant/es/switch/style/index.mjs
generated
vendored
Normal file
3
node_modules/vant/es/switch/style/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import "../../style/base.css";
|
||||
import "../../loading/index.css";
|
||||
import "../index.css";
|
||||
12
node_modules/vant/es/switch/types.d.ts
generated
vendored
Normal file
12
node_modules/vant/es/switch/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export type SwitchThemeVars = {
|
||||
switchSize?: string;
|
||||
switchWidth?: string;
|
||||
switchHeight?: string;
|
||||
switchNodeSize?: string;
|
||||
switchNodeBackground?: string;
|
||||
switchNodeShadow?: string;
|
||||
switchBackground?: string;
|
||||
switchOnBackground?: string;
|
||||
switchDuration?: string;
|
||||
switchDisabledOpacity?: number | string;
|
||||
};
|
||||
0
node_modules/vant/es/switch/types.mjs
generated
vendored
Normal file
0
node_modules/vant/es/switch/types.mjs
generated
vendored
Normal file
Reference in New Issue
Block a user