@ajaxjs/util 1.0.8 → 1.1.0

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.
Files changed (83) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +11 -20
  3. package/dist/index.d.ts +34 -6
  4. package/dist/index.js +45 -8
  5. package/dist/index.js.map +1 -1
  6. package/dist/main.d.ts +1 -0
  7. package/dist/main.js +16 -0
  8. package/dist/main.js.map +1 -0
  9. package/dist/router/index.d.ts +3 -0
  10. package/dist/router/index.js +44 -0
  11. package/dist/router/index.js.map +1 -0
  12. package/dist/shims-vue.d.ts +4 -0
  13. package/dist/util/cookies.d.ts +18 -0
  14. package/dist/util/cookies.js +46 -0
  15. package/dist/util/cookies.js.map +1 -0
  16. package/dist/util/dom.d.ts +17 -0
  17. package/dist/util/dom.js +44 -0
  18. package/dist/util/dom.js.map +1 -0
  19. package/dist/util/utils.d.ts +51 -0
  20. package/dist/util/utils.js +174 -0
  21. package/dist/util/utils.js.map +1 -0
  22. package/dist/{xhr-config.js.map → util/xhr-config.js.map} +1 -1
  23. package/dist/{xhr.d.ts → util/xhr.d.ts} +16 -1
  24. package/dist/{xhr.js → util/xhr.js} +90 -38
  25. package/dist/util/xhr.js.map +1 -0
  26. package/dist/widget/AccordionMenu.vue +140 -0
  27. package/dist/widget/AdjustFontSize.vue +65 -0
  28. package/dist/widget/Article.vue +59 -0
  29. package/dist/widget/EmptyContent.d.ts +5 -0
  30. package/dist/widget/EmptyContent.js +7 -0
  31. package/dist/widget/EmptyContent.js.map +1 -0
  32. package/dist/widget/Expander.vue +65 -0
  33. package/dist/widget/FileUploader/FileUploader.d.ts +70 -0
  34. package/dist/widget/FileUploader/FileUploader.js +139 -0
  35. package/dist/widget/FileUploader/FileUploader.js.map +1 -0
  36. package/dist/widget/FileUploader/FileUploader.less +68 -0
  37. package/dist/widget/FileUploader/FileUploader.ts +156 -0
  38. package/dist/widget/FileUploader/FileUploader.vue +43 -0
  39. package/dist/widget/HtmlEditor/HtmlEditor.d.ts +70 -0
  40. package/dist/widget/HtmlEditor/HtmlEditor.js +287 -0
  41. package/dist/widget/HtmlEditor/HtmlEditor.js.map +1 -0
  42. package/dist/widget/HtmlEditor/HtmlEditor.less +345 -0
  43. package/dist/widget/HtmlEditor/HtmlEditor.ts +339 -0
  44. package/dist/widget/HtmlEditor/HtmlEditor.vue +70 -0
  45. package/dist/widget/HtmlEditor/html-editor-HtmlSanitizer.js +103 -0
  46. package/dist/widget/ImageEnlarger.vue +105 -0
  47. package/dist/widget/OpacityBanner.vue +125 -0
  48. package/dist/widget/ProcessLine.vue +133 -0
  49. package/dist/widget/Resize.d.ts +51 -0
  50. package/dist/widget/Resize.js +133 -0
  51. package/dist/widget/Resize.js.map +1 -0
  52. package/dist/widget/Resize.ts +152 -0
  53. package/dist/widget/Resize.vue +104 -0
  54. package/dist/widget/TreeSelector.vue +4 -0
  55. package/dist/widget/calendar/BetweenDate.vue +63 -0
  56. package/dist/widget/calendar/Calendar.d.ts +55 -0
  57. package/dist/widget/calendar/Calendar.js +145 -0
  58. package/dist/widget/calendar/Calendar.js.map +1 -0
  59. package/dist/widget/calendar/Calendar.less +210 -0
  60. package/dist/widget/calendar/Calendar.ts +167 -0
  61. package/dist/widget/calendar/Calendar.vue +52 -0
  62. package/dist/widget/calendar/CalendarInput.vue +71 -0
  63. package/dist/widget/form/validator.d.ts +70 -0
  64. package/dist/widget/form/validator.js +220 -0
  65. package/dist/widget/form/validator.js.map +1 -0
  66. package/dist/widget/form/validator.ts +289 -0
  67. package/dist/widget/play-ground/sku.vue +93 -0
  68. package/package.json +31 -15
  69. package/dist/base.d.ts +0 -42
  70. package/dist/base.js +0 -133
  71. package/dist/base.js.map +0 -1
  72. package/dist/entity.d.ts +0 -26
  73. package/dist/entity.js +0 -2
  74. package/dist/entity.js.map +0 -1
  75. package/dist/xhr.js.map +0 -1
  76. package/src/base.ts +0 -145
  77. package/src/entity.ts +0 -31
  78. package/src/index.ts +0 -13
  79. package/src/xhr-config.ts +0 -25
  80. package/src/xhr.ts +0 -229
  81. package/tsconfig.json +0 -73
  82. /package/dist/{xhr-config.d.ts → util/xhr-config.d.ts} +0 -0
  83. /package/dist/{xhr-config.js → util/xhr-config.js} +0 -0
package/src/xhr.ts DELETED
@@ -1,229 +0,0 @@
1
- import { XhrConfig } from './xhr-config';
2
-
3
- /**
4
- * 默认的请求配置
5
- */
6
- const DEFAULT_XHR_CFG: XhrConfig = {
7
- timeout: 3000,
8
- withCredentials: false,
9
- parseContentType: 'json'
10
- };
11
-
12
- /**
13
- * 处理响应的回调函数
14
- */
15
- type XhrCallback = (json: {}, text: string) => void;
16
-
17
- /**
18
- *
19
- * @param getOrDel
20
- * @param url
21
- * @param cb
22
- * @param params
23
- * @param cfg
24
- */
25
- function getOrDel(getOrDel: 'get' | 'delete', url: string, cb: XhrCallback, params?: {}, cfg: XhrConfig = DEFAULT_XHR_CFG): void {
26
- let xhr: XMLHttpRequest = initXhr(cfg);
27
-
28
- if (params != null)
29
- url += '?' + toParams(params);
30
-
31
- xhr.open(getOrDel.toUpperCase(), url, true);
32
- xhr.onreadystatechange = function () {
33
- responseHandle(this, cb, cfg);
34
- }
35
-
36
- xhr.send();
37
- }
38
-
39
- /**
40
- *
41
- * @param method
42
- * @param url
43
- * @param cb
44
- * @param params
45
- * @param cfg
46
- */
47
- function postOrPut(method: 'post' | 'put', url: string, cb: XhrCallback, params: string | {}, cfg: XhrConfig = DEFAULT_XHR_CFG): void {
48
- let xhr: XMLHttpRequest = initXhr(cfg);
49
- xhr.open(method, url, true);
50
- xhr.onreadystatechange = function () {
51
- responseHandle(this, cb, cfg);
52
- }
53
-
54
- // 此方法必须在 open()方法和 send() 之间调用
55
- if (!cfg.contentType) // 如未设置,默认为表单请求
56
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
57
-
58
- let _params: string = typeof params != 'string' ? toParams(params) : <string>params;
59
-
60
- if (_params)
61
- xhr.send(_params);
62
- else
63
- xhr.send();
64
- }
65
-
66
- /**
67
- * XHR GET 请求
68
- *
69
- * @param url 请求地址
70
- * @param cb 回调函数 @example (json: {}, text: string) => void;
71
- * @param params 参数,必填,如无填空字符串 "";参数类型是json;参数值会进行 URL 编码,最后附加到 QueryString 中
72
- * @param cfg 配置,可选的
73
- */
74
- export function xhr_get(url: string, cb: XhrCallback, params?: {}, cfg: XhrConfig = DEFAULT_XHR_CFG): void {
75
- getOrDel('get', url, cb, params, cfg);
76
- }
77
-
78
- /**
79
- * XHR DELETE 请求
80
- *
81
- * @param url 请求地址
82
- * @param cb 回调函数 @example (json: {}, text: string) => void;
83
- * @param params 参数,必填,如无填空字符串 "";参数类型是json;参数值会进行 URL 编码,最后附加到 QueryString 中
84
- * @param cfg 配置,可选的
85
- */
86
- export function xhr_del(url: string, cb: XhrCallback, params?: {}, cfg: XhrConfig = DEFAULT_XHR_CFG): void {
87
- getOrDel('delete', url, cb, params, cfg);
88
- }
89
-
90
- /**
91
- * XHR POST 请求
92
- *
93
- * @param url 请求地址
94
- * @param cb 回调函数 @example (json: {}, text: string) => void;
95
- * @param params 参数,必填,如无填空字符串 "";参数类型可以是字符串或 json;参数值会进行 URL 编码
96
- * @param cfg 配置,可选的
97
- */
98
- export function xhr_post(url: string, cb: XhrCallback, params: string | {}, cfg: XhrConfig = DEFAULT_XHR_CFG): void {
99
- postOrPut('post', url, cb, params, cfg);
100
- }
101
-
102
- /**
103
- * XHR PUT 请求
104
- *
105
- * @param url 请求地址
106
- * @param cb 回调函数 @example (json: {}, text: string) => void;
107
- * @param params 参数,必填,如无填空字符串 "";参数类型可以是字符串或 json;参数值会进行 URL 编码
108
- * @param cfg 配置,可选的
109
- */
110
- export function xhr_put(url: string, cb: XhrCallback, params: string | {}, cfg: XhrConfig = DEFAULT_XHR_CFG): void {
111
- postOrPut('put', url, cb, params, cfg);
112
- }
113
-
114
- /**
115
- * 初始化 XHR
116
- *
117
- * @param cfg
118
- * @returns
119
- */
120
- function initXhr(cfg: XhrConfig): XMLHttpRequest {
121
- let xhr: XMLHttpRequest = new XMLHttpRequest();
122
-
123
- if (cfg && cfg.timeout) {
124
- xhr.timeout = cfg.timeout;
125
- xhr.ontimeout = (e: ProgressEvent<EventTarget>) => { alert('系统异常,XHR 连接服务超时'); };
126
- }
127
-
128
- if (cfg && cfg.withCredentials)
129
- xhr.withCredentials = true;
130
-
131
- return xhr;
132
- }
133
-
134
- /**
135
- * 错误处理
136
- *
137
- * @param xhr
138
- */
139
- function errHandle(xhr: XMLHttpRequest): void {
140
- let msg: string;
141
-
142
- if (xhr.status <= 400)
143
- msg = '请求参数错误或者权限不足。';
144
- else if (xhr.status <= 500)
145
- msg = '服务端异常。';
146
- else
147
- msg = `未知异常,HTTP code:${xhr.status}。`;
148
-
149
- if (!xhr.responseText)
150
- msg += " 服务端返回空的字符串!";
151
-
152
- console.error(msg, xhr.responseText);
153
- alert(msg);
154
- }
155
-
156
- /**
157
- * 响应处理
158
- *
159
- * @param xhr
160
- * @param cb
161
- * @param cfg
162
- */
163
- function responseHandle(xhr: XMLHttpRequest, cb: XhrCallback, cfg: XhrConfig): void {
164
- if (xhr.readyState == 4) {
165
- if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
166
- let text: string = xhr.responseText;
167
- let json: any;
168
-
169
- if (!text)
170
- console.warn('服务端没有返回任何字符串');
171
-
172
- switch (cfg.parseContentType) {
173
- case 'text':
174
- break;
175
- case 'xml':
176
- json = xhr.responseXML;
177
- break;
178
- case 'json':
179
- default:
180
- try {
181
- json = JSON.parse(text);
182
- } catch (e) {
183
- console.warn(e);
184
- alert('解析 JSON 时候发生错误,非法 JSON');
185
- }
186
- }
187
-
188
- cb && cb(json, text);
189
- } else errHandle(xhr);
190
- }
191
- }
192
-
193
- /**
194
- * 对象转换为 URL 参数列表,用 & 分隔
195
- *
196
- * @param {Object} param JSON 对象
197
- * @returns URL 参数列表
198
- */
199
- export function toParams(param: any): string {
200
- let result: string = "";
201
-
202
- for (let name in param) {
203
- if (typeof param[name] != "function")
204
- result += "&" + name + "=" + encodeURIComponent(param[name]);
205
- }
206
-
207
- return result.substring(1);
208
- }
209
-
210
- /**
211
- * 获取 QueryString 的某个参数
212
- *
213
- * @param val
214
- * @returns
215
- */
216
- export function getQuery(val: string): string {
217
- const w: number = location.hash.indexOf('?');
218
- const query: string = location.hash.substring(w + 1);
219
- let vars: string[] = query.split('&');
220
-
221
- for (let i = 0; i < vars.length; i++) {
222
- const pair = vars[i].split('=');
223
-
224
- if (pair[0] == val)
225
- return pair[1];
226
- }
227
-
228
- return '';
229
- }
package/tsconfig.json DELETED
@@ -1,73 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- /* Basic Options */
6
- // "incremental": true, /* Enable incremental compilation */
7
- "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
8
- "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9
- // "lib": [], /* Specify library files to be included in the compilation. */
10
- "allowJs": true, /* Allow javascript files to be compiled. */
11
- // "checkJs": true, /* Report errors in .js files. */
12
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
13
- "declaration": true, /* Generates corresponding '.d.ts' file. */
14
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15
- "sourceMap": true, /* Generates corresponding '.map' file. */
16
- // "outFile": "./", /* Concatenate and emit output to single file. */
17
- "outDir": "./dist", /* Redirect output structure to the directory. */
18
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19
- // "composite": true, /* Enable project compilation */
20
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21
- // "removeComments": true, /* Do not emit comments to output. */
22
- // "noEmit": true, /* Do not emit outputs. */
23
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26
-
27
- /* Strict Type-Checking Options */
28
- "strict": true, /* Enable all strict type-checking options. */
29
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30
- // "strictNullChecks": true, /* Enable strict null checks. */
31
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
32
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
34
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36
-
37
- /* Additional Checks */
38
- // "noUnusedLocals": true, /* Report errors on unused locals. */
39
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
40
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
43
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
44
- // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
45
-
46
- /* Module Resolution Options */
47
- // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
48
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
49
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
50
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
51
- // "typeRoots": [], /* List of folders to include type definitions from. */
52
- // "types": [], /* Type declaration files to be included in compilation. */
53
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
54
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
55
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
56
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
57
-
58
- /* Source Map Options */
59
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
60
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
61
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
62
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
63
-
64
- /* Experimental Options */
65
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
66
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
67
-
68
- /* Advanced Options */
69
- "skipLibCheck": true, /* Skip type checking of declaration files. */
70
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
71
- },
72
- "exclude": ["node_modules", "dist"]
73
- }
File without changes
File without changes