@scvzerng/element-plus-search-vue2 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ import { Searchable } from './types/Searchable';
2
+ type __VLS_Props = {
3
+ searches: Searchable[];
4
+ id: string;
5
+ onSearch: (params: any) => Promise<void>;
6
+ defaultSpan?: number;
7
+ maxRows?: number;
8
+ itemHeight?: number;
9
+ resetAutoSearch?: boolean;
10
+ };
11
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
12
+ getSearchItems: () => {
13
+ field: string;
14
+ label: string;
15
+ value?: any;
16
+ required?: boolean | undefined;
17
+ index: number;
18
+ visible: boolean;
19
+ span: number;
20
+ initValue?: any;
21
+ tagFilter?: ((value: any) => boolean) | undefined;
22
+ render: import("./model/SearchItem").SearchItemRender;
23
+ transform?: import("./types/Searchable").TransformCallback<any> | undefined;
24
+ clean: () => void;
25
+ reset: () => void;
26
+ }[];
27
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
28
+ defaultSpan: number;
29
+ maxRows: number;
30
+ itemHeight: number;
31
+ resetAutoSearch: boolean;
32
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
+ declare const _default: typeof __VLS_export;
34
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import { SearchItem } from './model/SearchItem';
2
+ import { SearchConfig } from './model/SearchConfig';
3
+ import { SearchTag } from './model/SearchTag';
4
+ import { Reactive } from 'vue';
5
+ import { Searchable } from './types/Searchable';
6
+ export declare class SearchBarState {
7
+ id: string;
8
+ items: SearchItem[];
9
+ config: Reactive<SearchConfig>;
10
+ searching: boolean;
11
+ tags: SearchTag[];
12
+ searchCallback: <T>(params: T) => Promise<void>;
13
+ sourceSearchable: Searchable[];
14
+ constructor(id: string, searches: Searchable[], onSearch: (params: any) => Promise<void>);
15
+ updateTags(): void;
16
+ getSearchObject<T>(ext?: any): T;
17
+ doSearch(): Promise<void>;
18
+ reset(search?: boolean): Promise<void>;
19
+ }
@@ -0,0 +1,5 @@
1
+ import type { FunctionalComponent } from 'vue';
2
+ import type { SearchItem } from './model/SearchItem';
3
+ export declare const SearchItemRender: FunctionalComponent<{
4
+ search: SearchItem;
5
+ }>;
@@ -0,0 +1,7 @@
1
+ import type { SearchTag } from './model/SearchTag';
2
+ type __VLS_Props = {
3
+ tags: SearchTag[];
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
6
+ declare const _default: typeof __VLS_export;
7
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { TransformCallback } from './types/Searchable';
2
+ import { SearchValueLike } from './types/SearchValueLike';
3
+ export { default as SearchBar } from './SearchBar.vue';
4
+ export type SearchBarInstance = {
5
+ getSearchItems(): SearchValueLike[];
6
+ };
7
+ export declare class Searches {
8
+ record: Record<string, any>;
9
+ constructor(record: Record<string, any>);
10
+ static from(searches: SearchValueLike[]): Searches;
11
+ transform<T>(field: string, transformCallback: TransformCallback<T>): Searches;
12
+ toCondition<T>(record?: Record<string, any>): T;
13
+ }
@@ -0,0 +1,38 @@
1
+ import type { SearchItem } from './SearchItem';
2
+ import type { SearchBarState } from '../SearchBarState';
3
+ import { Searchable } from '../types/Searchable';
4
+ /**
5
+ * 搜索项布局
6
+ */
7
+ export declare class SearchItemLayout {
8
+ field: string;
9
+ span: number;
10
+ index: number;
11
+ visible: boolean;
12
+ constructor(field: string, span: number, index: number, visible: boolean);
13
+ static fromSearchItem(searchItem: SearchItem, index?: number): SearchItemLayout;
14
+ static formSearchConfig(searchable: Searchable, index?: number): SearchItemLayout;
15
+ static fromString(str: string): SearchItemLayout;
16
+ toString(): string;
17
+ merge(layout: SearchItemLayout): void;
18
+ }
19
+ type Layout = Record<string, SearchItemLayout>;
20
+ /**
21
+ * 搜索配置
22
+ */
23
+ export declare class SearchConfig {
24
+ id: string;
25
+ state: SearchBarState;
26
+ itemLayouts: Layout;
27
+ initialLayouts: SearchItemLayout[];
28
+ constructor(state: SearchBarState, initialLayouts: SearchItemLayout[]);
29
+ /**
30
+ * 恢复自缓存中的布局信息
31
+ * @private
32
+ */
33
+ private restoreCachedLayouts;
34
+ sync(sortedKeys: string[], visibleKeys: Set<string>): void;
35
+ persistent(): void;
36
+ reset(): void;
37
+ }
38
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { VNode } from 'vue';
2
+ import { SearchValueLike } from '../types/SearchValueLike';
3
+ import { Searchable, TransformCallback } from '../types/Searchable';
4
+ export declare const DEFAULT_SEARCH_SPAN = 6;
5
+ export type SearchItemRender = (value: SearchValueLike) => VNode | undefined;
6
+ export declare class SearchItem {
7
+ field: string;
8
+ label: string;
9
+ value?: any;
10
+ required?: boolean;
11
+ index: number;
12
+ visible: boolean;
13
+ span: number;
14
+ initValue?: any;
15
+ tagFilter?: (value: any) => boolean;
16
+ render: SearchItemRender;
17
+ transform?: TransformCallback<any>;
18
+ constructor(searchable: Searchable, index: number);
19
+ clean(): void;
20
+ reset(): void;
21
+ }
@@ -0,0 +1,22 @@
1
+ import type { SearchBarState } from '../SearchBarState';
2
+ import type { SearchItem } from './SearchItem';
3
+ type ComponentTextGetter = {
4
+ isApply: (el: DOMTokenList) => boolean;
5
+ getText: (el: Element, search: SearchTag) => string;
6
+ };
7
+ export declare const COMPONENT_TEXT_GETTER: ComponentTextGetter[];
8
+ export declare class SearchTag {
9
+ private readonly id;
10
+ field: string;
11
+ value: any;
12
+ label: string;
13
+ valueText?: string;
14
+ required: boolean;
15
+ private item;
16
+ private state;
17
+ constructor(state: SearchBarState, item: SearchItem);
18
+ static hasValue(item: SearchItem): boolean;
19
+ private updateValueText;
20
+ clean(): Promise<void>;
21
+ }
22
+ export {};
@@ -0,0 +1,5 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {
2
+ show: (api: import("../SearchBarState").SearchBarState) => void;
3
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
4
+ declare const _default: typeof __VLS_export;
5
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { UnwrapNestedRefs } from 'vue';
2
+ import { SearchBarState } from '../SearchBarState';
3
+ type __VLS_Props = {
4
+ state: UnwrapNestedRefs<SearchBarState>;
5
+ };
6
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
+ declare const _default: typeof __VLS_export;
8
+ export default _default;
@@ -0,0 +1,30 @@
1
+ import type { SearchBarState } from '../SearchBarState';
2
+ import { TreeInstance } from 'element-plus';
3
+ type TreeNode = {
4
+ label: string;
5
+ id: string;
6
+ children?: TreeNode[];
7
+ };
8
+ export declare const useSetting: () => {
9
+ treeRef: import("vue").Ref<TreeInstance | undefined, TreeInstance | undefined>;
10
+ visible: import("vue").Ref<boolean, boolean>;
11
+ snapshot: import("vue").Ref<{
12
+ label: string;
13
+ id: string;
14
+ children?: /*elided*/ any[] | undefined;
15
+ }[], TreeNode[] | {
16
+ label: string;
17
+ id: string;
18
+ children?: /*elided*/ any[] | undefined;
19
+ }[]>;
20
+ defaultCheckedKeys: import("vue").Ref<string[] | undefined, string[] | undefined>;
21
+ drawerWidth: import("vue").Ref<number, number>;
22
+ updateSnapshot: (api: SearchBarState) => void;
23
+ show: (api: SearchBarState) => void;
24
+ save: () => void;
25
+ reset: () => void;
26
+ keepSelection: () => void;
27
+ restoreSelection: () => void;
28
+ allowDrop: (_: any, __: any, type: string) => boolean;
29
+ };
30
+ export {};
@@ -0,0 +1,5 @@
1
+ import { TransformCallback } from './Searchable';
2
+ export type SearchValueLike = any & {
3
+ value?: any;
4
+ transform?: TransformCallback<any>;
5
+ };
@@ -0,0 +1,35 @@
1
+ import type { VNode } from 'vue';
2
+ import { SearchItem } from '../model/SearchItem';
3
+ export type TransformCallback<T> = (value: T) => Record<string, any>;
4
+ export interface Searchable {
5
+ /**
6
+ * 属性名
7
+ */
8
+ field: string;
9
+ /**
10
+ * 描述
11
+ */
12
+ label: string;
13
+ /**
14
+ * 绑定数据
15
+ */
16
+ value?: any;
17
+ /**
18
+ * 初始化数据
19
+ */
20
+ initValue?: any;
21
+ /**
22
+ * 搜索的tag标签是否可以关闭
23
+ */
24
+ required?: boolean;
25
+ index?: number;
26
+ visible?: boolean;
27
+ span?: number;
28
+ /**
29
+ * 渲染器
30
+ * @param row
31
+ */
32
+ render: (value: SearchItem) => VNode | undefined;
33
+ transform?: TransformCallback<any>;
34
+ tagFilter?: (value: any) => boolean;
35
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@scvzerng/element-plus-search-vue2",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "private": false,
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build && vue-tsc --declaration --emitDeclarationOnly",
9
+ "lint:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore",
10
+ "lint": "run-s lint:*",
11
+ "format": "prettier --write src/"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/types/index.d.ts",
16
+ "import": "./dist/ElementPlusSearch.es.js",
17
+ "require": "./dist/ElementPlusSearch.umd.js"
18
+ },
19
+ "./style": {
20
+ "default": "./dist/element-plus-search.css"
21
+ }
22
+
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "peerDependencies": {
28
+ "@vueuse/core": "9.13.0",
29
+ "element-ui": "2.15.14",
30
+ "lodash-unified": "^1.0.3",
31
+ "vue": "2.7.16"
32
+ },
33
+ "devDependencies": {
34
+ "unplugin-vue-macros": "2.14.5",
35
+ "@prettier/plugin-oxc": "0.0.4",
36
+ "@types/md5": "2.3.5",
37
+ "@types/node": "22.16.5",
38
+ "@vitejs/plugin-vue2": "2.3.3",
39
+ "@vitejs/plugin-vue2-jsx": "1.1.1",
40
+ "@vue/babel-helper-vue-jsx-merge-props": "1.4.0",
41
+ "@vue/eslint-config-prettier": "10.2.0",
42
+ "@vue/eslint-config-typescript": "14.6.0",
43
+ "eslint": "9.31.0",
44
+ "eslint-plugin-oxlint": "1.8.0",
45
+ "eslint-plugin-vue": "10.3.0",
46
+ "jiti": "2.4.2",
47
+ "npm-run-all2": "8.0.4",
48
+ "oxlint": "~1.8.0",
49
+ "prettier": "3.6.2",
50
+ "sass-embedded": "1.90.0",
51
+ "typescript": "5.9.2",
52
+ "vite": "5.4.19",
53
+ "vue-tsc": "2.1.10"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ }
58
+ }