first commit
This commit is contained in:
89
node_modules/vant/lib/text-ellipsis/TextEllipsis.d.ts
generated
vendored
Normal file
89
node_modules/vant/lib/text-ellipsis/TextEllipsis.d.ts
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
import { type ExtractPropTypes } from 'vue';
|
||||
export declare const textEllipsisProps: {
|
||||
rows: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
dots: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
content: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
expandText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
collapseText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
position: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
};
|
||||
export type TextEllipsisProps = ExtractPropTypes<typeof textEllipsisProps>;
|
||||
declare const _default: import("vue").DefineComponent<ExtractPropTypes<{
|
||||
rows: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
dots: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
content: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
expandText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
collapseText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
position: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "clickAction"[], "clickAction", import("vue").PublicProps, Readonly<ExtractPropTypes<{
|
||||
rows: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
dots: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
content: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
expandText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
collapseText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
position: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onClickAction?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
content: string;
|
||||
position: string;
|
||||
rows: string | number;
|
||||
dots: string;
|
||||
expandText: string;
|
||||
collapseText: string;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
||||
186
node_modules/vant/lib/text-ellipsis/TextEllipsis.js
generated
vendored
Normal file
186
node_modules/vant/lib/text-ellipsis/TextEllipsis.js
generated
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name2 in all)
|
||||
__defProp(target, name2, { get: all[name2], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
default: () => stdin_default,
|
||||
textEllipsisProps: () => textEllipsisProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_vue = require("vue");
|
||||
var import_utils = require("../utils");
|
||||
var import_use_expose = require("../composables/use-expose");
|
||||
const [name, bem] = (0, import_utils.createNamespace)("text-ellipsis");
|
||||
const textEllipsisProps = {
|
||||
rows: (0, import_utils.makeNumericProp)(1),
|
||||
dots: (0, import_utils.makeStringProp)("..."),
|
||||
content: (0, import_utils.makeStringProp)(""),
|
||||
expandText: (0, import_utils.makeStringProp)(""),
|
||||
collapseText: (0, import_utils.makeStringProp)(""),
|
||||
position: (0, import_utils.makeStringProp)("end")
|
||||
};
|
||||
var stdin_default = (0, import_vue.defineComponent)({
|
||||
name,
|
||||
props: textEllipsisProps,
|
||||
emits: ["clickAction"],
|
||||
setup(props, {
|
||||
emit,
|
||||
slots
|
||||
}) {
|
||||
const text = (0, import_vue.ref)(props.content);
|
||||
const expanded = (0, import_vue.ref)(false);
|
||||
const hasAction = (0, import_vue.ref)(false);
|
||||
const root = (0, import_vue.ref)();
|
||||
const actionRef = (0, import_vue.ref)();
|
||||
let needRecalculate = false;
|
||||
const actionText = (0, import_vue.computed)(() => expanded.value ? props.collapseText : props.expandText);
|
||||
const pxToNum = (value) => {
|
||||
if (!value) return 0;
|
||||
const match = value.match(/^\d*(\.\d*)?/);
|
||||
return match ? Number(match[0]) : 0;
|
||||
};
|
||||
const cloneContainer = () => {
|
||||
if (!root.value || !root.value.isConnected) return;
|
||||
const originStyle = window.getComputedStyle(root.value);
|
||||
const container = document.createElement("div");
|
||||
const styleNames = Array.prototype.slice.apply(originStyle);
|
||||
styleNames.forEach((name2) => {
|
||||
container.style.setProperty(name2, originStyle.getPropertyValue(name2));
|
||||
});
|
||||
container.style.position = "fixed";
|
||||
container.style.zIndex = "-9999";
|
||||
container.style.top = "-9999px";
|
||||
container.style.height = "auto";
|
||||
container.style.minHeight = "auto";
|
||||
container.style.maxHeight = "auto";
|
||||
container.innerText = props.content;
|
||||
document.body.appendChild(container);
|
||||
return container;
|
||||
};
|
||||
const calcEllipsisText = (container, maxHeight) => {
|
||||
var _a, _b;
|
||||
const {
|
||||
content,
|
||||
position,
|
||||
dots
|
||||
} = props;
|
||||
const end = content.length;
|
||||
const middle = 0 + end >> 1;
|
||||
const actionHTML = slots.action ? (_b = (_a = actionRef.value) == null ? void 0 : _a.outerHTML) != null ? _b : "" : props.expandText;
|
||||
const calcEllipse = () => {
|
||||
const tail = (left, right) => {
|
||||
if (right - left <= 1) {
|
||||
if (position === "end") {
|
||||
return content.slice(0, left) + dots;
|
||||
}
|
||||
return dots + content.slice(right, end);
|
||||
}
|
||||
const middle2 = Math.round((left + right) / 2);
|
||||
if (position === "end") {
|
||||
container.innerText = content.slice(0, middle2) + dots;
|
||||
} else {
|
||||
container.innerText = dots + content.slice(middle2, end);
|
||||
}
|
||||
container.innerHTML += actionHTML;
|
||||
if (container.offsetHeight > maxHeight) {
|
||||
if (position === "end") {
|
||||
return tail(left, middle2);
|
||||
}
|
||||
return tail(middle2, right);
|
||||
}
|
||||
if (position === "end") {
|
||||
return tail(middle2, right);
|
||||
}
|
||||
return tail(left, middle2);
|
||||
};
|
||||
return tail(0, end);
|
||||
};
|
||||
const middleTail = (leftPart, rightPart) => {
|
||||
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
||||
return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
|
||||
}
|
||||
const leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
||||
const rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
||||
container.innerText = props.content.slice(0, leftMiddle) + props.dots + props.content.slice(rightMiddle, end);
|
||||
container.innerHTML += actionHTML;
|
||||
if (container.offsetHeight >= maxHeight) {
|
||||
return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
|
||||
}
|
||||
return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
|
||||
};
|
||||
return props.position === "middle" ? middleTail([0, middle], [middle, end]) : calcEllipse();
|
||||
};
|
||||
const calcEllipsised = () => {
|
||||
const container = cloneContainer();
|
||||
if (!container) {
|
||||
needRecalculate = true;
|
||||
return;
|
||||
}
|
||||
const {
|
||||
paddingBottom,
|
||||
paddingTop,
|
||||
lineHeight
|
||||
} = container.style;
|
||||
const maxHeight = Math.ceil((Number(props.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
|
||||
if (maxHeight < container.offsetHeight) {
|
||||
hasAction.value = true;
|
||||
text.value = calcEllipsisText(container, maxHeight);
|
||||
} else {
|
||||
hasAction.value = false;
|
||||
text.value = props.content;
|
||||
}
|
||||
document.body.removeChild(container);
|
||||
};
|
||||
const toggle = (isExpanded = !expanded.value) => {
|
||||
expanded.value = isExpanded;
|
||||
};
|
||||
const onClickAction = (event) => {
|
||||
toggle();
|
||||
emit("clickAction", event);
|
||||
};
|
||||
const renderAction = () => {
|
||||
const action = slots.action ? slots.action({
|
||||
expanded: expanded.value
|
||||
}) : actionText.value;
|
||||
return (0, import_vue.createVNode)("span", {
|
||||
"ref": actionRef,
|
||||
"class": bem("action"),
|
||||
"onClick": onClickAction
|
||||
}, [action]);
|
||||
};
|
||||
(0, import_vue.onMounted)(() => {
|
||||
calcEllipsised();
|
||||
if (slots.action) {
|
||||
(0, import_vue.nextTick)(calcEllipsised);
|
||||
}
|
||||
});
|
||||
(0, import_vue.onActivated)(() => {
|
||||
if (needRecalculate) {
|
||||
needRecalculate = false;
|
||||
calcEllipsised();
|
||||
}
|
||||
});
|
||||
(0, import_vue.watch)([import_utils.windowWidth, () => [props.content, props.rows, props.position]], calcEllipsised);
|
||||
(0, import_use_expose.useExpose)({
|
||||
toggle
|
||||
});
|
||||
return () => (0, import_vue.createVNode)("div", {
|
||||
"ref": root,
|
||||
"class": bem()
|
||||
}, [expanded.value ? props.content : text.value, hasAction.value ? renderAction() : null]);
|
||||
}
|
||||
});
|
||||
1
node_modules/vant/lib/text-ellipsis/index.css
generated
vendored
Normal file
1
node_modules/vant/lib/text-ellipsis/index.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
:root,:host{--van-text-ellipsis-line-height: 1.6;--van-text-ellipsis-action-color: var(--van-blue)}.van-text-ellipsis{line-height:var(--van-text-ellipsis-line-height);white-space:pre-wrap;overflow-wrap:break-word}.van-text-ellipsis__action{cursor:pointer;color:var(--van-text-ellipsis-action-color)}.van-text-ellipsis__action:active{opacity:var(--van-active-opacity)}
|
||||
69
node_modules/vant/lib/text-ellipsis/index.d.ts
generated
vendored
Normal file
69
node_modules/vant/lib/text-ellipsis/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
export declare const TextEllipsis: import("../utils").WithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
||||
rows: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
dots: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
content: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
expandText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
collapseText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
position: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "clickAction"[], "clickAction", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
||||
rows: {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
};
|
||||
dots: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
content: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
expandText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
collapseText: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
position: {
|
||||
type: import("vue").PropType<string>;
|
||||
default: string;
|
||||
};
|
||||
}>> & Readonly<{
|
||||
onClickAction?: ((...args: any[]) => any) | undefined;
|
||||
}>, {
|
||||
content: string;
|
||||
position: string;
|
||||
rows: string | number;
|
||||
dots: string;
|
||||
expandText: string;
|
||||
collapseText: string;
|
||||
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
|
||||
export default TextEllipsis;
|
||||
export { textEllipsisProps } from './TextEllipsis';
|
||||
export type { TextEllipsisProps } from './TextEllipsis';
|
||||
export type { TextEllipsisInstance, TextEllipsisThemeVars } from './types';
|
||||
declare module 'vue' {
|
||||
interface GlobalComponents {
|
||||
VanTextEllipsis: typeof TextEllipsis;
|
||||
}
|
||||
}
|
||||
39
node_modules/vant/lib/text-ellipsis/index.js
generated
vendored
Normal file
39
node_modules/vant/lib/text-ellipsis/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
__export(stdin_exports, {
|
||||
TextEllipsis: () => TextEllipsis,
|
||||
default: () => stdin_default,
|
||||
textEllipsisProps: () => import_TextEllipsis2.textEllipsisProps
|
||||
});
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
var import_utils = require("../utils");
|
||||
var import_TextEllipsis = __toESM(require("./TextEllipsis"));
|
||||
var import_TextEllipsis2 = require("./TextEllipsis");
|
||||
const TextEllipsis = (0, import_utils.withInstall)(import_TextEllipsis.default);
|
||||
var stdin_default = TextEllipsis;
|
||||
1
node_modules/vant/lib/text-ellipsis/style/index.d.ts
generated
vendored
Normal file
1
node_modules/vant/lib/text-ellipsis/style/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
2
node_modules/vant/lib/text-ellipsis/style/index.js
generated
vendored
Normal file
2
node_modules/vant/lib/text-ellipsis/style/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
require("../../style/base.css");
|
||||
require("../index.css");
|
||||
9
node_modules/vant/lib/text-ellipsis/types.d.ts
generated
vendored
Normal file
9
node_modules/vant/lib/text-ellipsis/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { ComponentPublicInstance } from 'vue';
|
||||
import type { TextEllipsisProps } from './TextEllipsis';
|
||||
export type TextEllipsisExpose = {
|
||||
toggle: (expanded?: boolean) => void;
|
||||
};
|
||||
export type TextEllipsisInstance = ComponentPublicInstance<TextEllipsisProps, TextEllipsisExpose>;
|
||||
export type TextEllipsisThemeVars = {
|
||||
textEllipsisActionColor?: string;
|
||||
};
|
||||
15
node_modules/vant/lib/text-ellipsis/types.js
generated
vendored
Normal file
15
node_modules/vant/lib/text-ellipsis/types.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var stdin_exports = {};
|
||||
module.exports = __toCommonJS(stdin_exports);
|
||||
Reference in New Issue
Block a user