@ibiz-template/vue3-components 0.4.3-dev.1 → 0.4.3
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.
- package/dist/index-1dtzc9-X.js +14 -0
- package/dist/index-1dtzc9-X.js.map +1 -0
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/{xlsx-util-pR_RfupW.js → xlsx-util-Mxa6HuaG.js} +2 -2
- package/dist/{xlsx-util-pR_RfupW.js.map → xlsx-util-Mxa6HuaG.js.map} +1 -1
- package/es/_virtual/_commonjs-dynamic-modules.mjs +5 -0
- package/es/_virtual/pluralize.mjs +3 -0
- package/es/common/data-import2/data-import2.css +1 -0
- package/es/common/data-import2/data-import2.d.ts +54 -0
- package/es/common/data-import2/data-import2.mjs +459 -0
- package/es/common/index.mjs +2 -0
- package/es/editor/upload/ibiz-file-upload/ibiz-file-upload.css +1 -1
- package/es/editor/upload/ibiz-file-upload/ibiz-file-upload.d.ts +1 -0
- package/es/editor/upload/ibiz-file-upload/ibiz-file-upload.mjs +8 -3
- package/es/editor/upload/ibiz-image-upload/ibiz-image-upload.css +1 -1
- package/es/editor/upload/ibiz-image-upload/ibiz-image-upload.mjs +3 -1
- package/es/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/format-path/format-path.mjs +11 -0
- package/es/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/index.mjs +4 -0
- package/es/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/merge-model/merge-model.mjs +22 -0
- package/es/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/plural/plural.mjs +30 -0
- package/es/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/service-path-util/service-path-util.mjs +187 -0
- package/es/node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.mjs +515 -0
- package/es/panel-component/auth-userinfo/auth-userinfo.d.ts +0 -2
- package/es/panel-component/auth-userinfo/auth-userinfo.mjs +2 -25
- package/es/panel-component/auth-userinfo/index.d.ts +0 -2
- package/lib/_virtual/_commonjs-dynamic-modules.cjs +7 -0
- package/lib/_virtual/pluralize.cjs +5 -0
- package/lib/common/data-import2/data-import2.cjs +461 -0
- package/lib/common/data-import2/data-import2.css +1 -0
- package/lib/common/index.cjs +2 -0
- package/lib/editor/upload/ibiz-file-upload/ibiz-file-upload.cjs +8 -3
- package/lib/editor/upload/ibiz-file-upload/ibiz-file-upload.css +1 -1
- package/lib/editor/upload/ibiz-image-upload/ibiz-image-upload.cjs +3 -1
- package/lib/editor/upload/ibiz-image-upload/ibiz-image-upload.css +1 -1
- package/lib/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/format-path/format-path.cjs +13 -0
- package/lib/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/index.cjs +14 -0
- package/lib/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/merge-model/merge-model.cjs +24 -0
- package/lib/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/plural/plural.cjs +33 -0
- package/lib/node_modules/.pnpm/@ibiz-template_model-helper@0.4.3_@ibiz-template_runtime@0.4.3_ramda@0.29.1/node_modules/@ibiz-template/model-helper/out/utils/service-path-util/service-path-util.cjs +189 -0
- package/lib/node_modules/.pnpm/pluralize@8.0.0/node_modules/pluralize/pluralize.cjs +519 -0
- package/lib/panel-component/auth-userinfo/auth-userinfo.cjs +0 -23
- package/package.json +6 -6
- package/dist/index--HgeuaLg.js +0 -14
- package/dist/index--HgeuaLg.js.map +0 -1
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var plural = require('../plural/plural.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 服务路径拼接工具
|
|
7
|
+
*
|
|
8
|
+
* @author chitanda
|
|
9
|
+
* @date 2022-08-22 21:08:52
|
|
10
|
+
* @export
|
|
11
|
+
* @class ServicePathUtil
|
|
12
|
+
*/
|
|
13
|
+
class ServicePathUtil {
|
|
14
|
+
constructor(appDataEntities, allDERss) {
|
|
15
|
+
this.appDataEntities = appDataEntities;
|
|
16
|
+
this.allDERss = allDERss;
|
|
17
|
+
/**
|
|
18
|
+
* 应用实体关系
|
|
19
|
+
*
|
|
20
|
+
* @author chitanda
|
|
21
|
+
* @date 2022-08-22 22:08:18
|
|
22
|
+
* @protected
|
|
23
|
+
* @type {Map<string, IAppDERS[]>} <应用实体 id, 应用实体父关系>
|
|
24
|
+
*/
|
|
25
|
+
this.entityRsMap = new Map();
|
|
26
|
+
/**
|
|
27
|
+
* 实体资源路径
|
|
28
|
+
*
|
|
29
|
+
* @author chitanda
|
|
30
|
+
* @date 2022-08-22 22:08:58
|
|
31
|
+
* @protected
|
|
32
|
+
* @type {Map<string, ServicePathItem[][]>}
|
|
33
|
+
*/
|
|
34
|
+
this.entityRsPathMap = new Map();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 根据应用主实体过滤从关系集合
|
|
38
|
+
*
|
|
39
|
+
* @author chitanda
|
|
40
|
+
* @date 2023-04-20 17:04:34
|
|
41
|
+
* @protected
|
|
42
|
+
* @param {string} id
|
|
43
|
+
* @return {*} {IAppDERS[]}
|
|
44
|
+
*/
|
|
45
|
+
filterDERSs(id) {
|
|
46
|
+
if (this.entityRsMap.has(id)) {
|
|
47
|
+
return this.entityRsMap.get(id);
|
|
48
|
+
}
|
|
49
|
+
const items = this.allDERss.filter(item => {
|
|
50
|
+
if (item.minorAppDataEntityId === id) {
|
|
51
|
+
return item;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
});
|
|
55
|
+
if (items.length > 0) {
|
|
56
|
+
this.entityRsMap.set(id, items);
|
|
57
|
+
}
|
|
58
|
+
return items;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 计算指定应用实体所有资源路径
|
|
62
|
+
*
|
|
63
|
+
* @author chitanda
|
|
64
|
+
* @date 2023-04-22 13:04:27
|
|
65
|
+
* @param {string} id
|
|
66
|
+
* @return {*} {string[]}
|
|
67
|
+
*/
|
|
68
|
+
calcRequestPaths(id) {
|
|
69
|
+
const paths = this.calcPaths(id);
|
|
70
|
+
return paths.map(path => {
|
|
71
|
+
return path.map(item => `${item.plural}/\${${item.lower}}`).join('/');
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 计算指定实体所有资源路径
|
|
76
|
+
*
|
|
77
|
+
* @author chitanda
|
|
78
|
+
* @date 2023-04-22 13:04:36
|
|
79
|
+
* @protected
|
|
80
|
+
* @param {string} id
|
|
81
|
+
* @return {*} {ServicePathItem[][]} 返回顺序为 [祖父实体,爷爷实体,父实体,当前实体]
|
|
82
|
+
*/
|
|
83
|
+
calcPaths(id) {
|
|
84
|
+
const entityRef = this.appDataEntities.find(item => item.id === id);
|
|
85
|
+
if (!entityRef) {
|
|
86
|
+
throw new Error(`未找到实体 ${id}`);
|
|
87
|
+
}
|
|
88
|
+
const { codeName } = entityRef;
|
|
89
|
+
if (this.entityRsPathMap.has(codeName)) {
|
|
90
|
+
return this.entityRsPathMap.get(codeName);
|
|
91
|
+
}
|
|
92
|
+
const deRss = this.filterDERSs(id);
|
|
93
|
+
if (deRss) {
|
|
94
|
+
// 已经计算过的应用实体标识
|
|
95
|
+
const ids = [id];
|
|
96
|
+
const arr = this.calcDeepPath(ids, deRss);
|
|
97
|
+
this.deepFillPath(codeName, [codeName], arr);
|
|
98
|
+
let paths = this.entityRsPathMap.get(codeName);
|
|
99
|
+
if (paths) {
|
|
100
|
+
paths = this.sortPath(paths);
|
|
101
|
+
this.entityRsPathMap.set(codeName, paths);
|
|
102
|
+
return paths;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 计算递归资源路径
|
|
109
|
+
*
|
|
110
|
+
* @author chitanda
|
|
111
|
+
* @date 2023-08-23 14:08:39
|
|
112
|
+
* @protected
|
|
113
|
+
* @param {string[]} ids
|
|
114
|
+
* @param {IAppDERS[]} deRss
|
|
115
|
+
* @param {number} [num=0]
|
|
116
|
+
* @return {*} {ServicePathDeep[]}
|
|
117
|
+
*/
|
|
118
|
+
calcDeepPath(ids, deRss, num = 0) {
|
|
119
|
+
if (num > 10) {
|
|
120
|
+
throw new Error('服务路径计算超过最大层级 10');
|
|
121
|
+
}
|
|
122
|
+
num += 1;
|
|
123
|
+
const arr = [];
|
|
124
|
+
deRss.forEach(rs => {
|
|
125
|
+
if (ids.includes(rs.majorAppDataEntityId)) {
|
|
126
|
+
ibiz.log.warn('计算资源关系路径出现循环递归引用,触发实体:', rs.majorAppDataEntityId, '当前已计算过实体清单: ', ids);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const items = this.filterDERSs(rs.majorAppDataEntityId);
|
|
130
|
+
arr.push([
|
|
131
|
+
rs,
|
|
132
|
+
this.calcDeepPath([...ids, rs.majorAppDataEntityId], items, num),
|
|
133
|
+
]);
|
|
134
|
+
});
|
|
135
|
+
return arr;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 递归填充计算所有资源路径
|
|
139
|
+
*
|
|
140
|
+
* @author chitanda
|
|
141
|
+
* @date 2022-08-22 22:08:04
|
|
142
|
+
* @protected
|
|
143
|
+
* @param {string} deCodeName
|
|
144
|
+
* @param {string[]} pathNames
|
|
145
|
+
* @param {ServicePathDeep[]} items
|
|
146
|
+
*/
|
|
147
|
+
deepFillPath(deCodeName, pathNames, items) {
|
|
148
|
+
items.forEach(item => {
|
|
149
|
+
const [rs, children] = item;
|
|
150
|
+
if (children.length > 0) {
|
|
151
|
+
this.deepFillPath(deCodeName, [...pathNames, rs.majorDECodeName], children);
|
|
152
|
+
}
|
|
153
|
+
if (!this.entityRsPathMap.has(deCodeName)) {
|
|
154
|
+
this.entityRsPathMap.set(deCodeName, []);
|
|
155
|
+
}
|
|
156
|
+
const arr = this.entityRsPathMap.get(deCodeName);
|
|
157
|
+
arr.push([
|
|
158
|
+
...pathNames.map(pathName => {
|
|
159
|
+
return {
|
|
160
|
+
codeName: pathName,
|
|
161
|
+
lower: pathName.toLowerCase(),
|
|
162
|
+
plural: plural.pluralLower(pathName),
|
|
163
|
+
};
|
|
164
|
+
}),
|
|
165
|
+
{
|
|
166
|
+
codeName: rs.majorDECodeName,
|
|
167
|
+
lower: rs.majorDECodeName.toLowerCase(),
|
|
168
|
+
plural: plural.pluralLower(rs.majorDECodeName),
|
|
169
|
+
},
|
|
170
|
+
].reverse());
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* 排序资源路径顺序
|
|
175
|
+
*
|
|
176
|
+
* @author chitanda
|
|
177
|
+
* @date 2022-08-22 22:08:44
|
|
178
|
+
* @protected
|
|
179
|
+
* @param {ServicePathItem[][]} paths
|
|
180
|
+
* @return {*} {ServicePathItem[][]}
|
|
181
|
+
*/
|
|
182
|
+
sortPath(paths) {
|
|
183
|
+
return paths.sort((a, b) => {
|
|
184
|
+
return b.length - a.length;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
exports.ServicePathUtil = ServicePathUtil;
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _commonjsHelpers = require('../../../../../_virtual/_commonjsHelpers.cjs');
|
|
6
|
+
var _commonjsDynamicModules = require('../../../../../_virtual/_commonjs-dynamic-modules.cjs');
|
|
7
|
+
var pluralize$2 = require('../../../../../_virtual/pluralize.cjs');
|
|
8
|
+
|
|
9
|
+
/* global define */
|
|
10
|
+
var pluralize = pluralize$2.__module.exports;
|
|
11
|
+
|
|
12
|
+
(function (module, exports) {
|
|
13
|
+
(function (root, pluralize) {
|
|
14
|
+
/* istanbul ignore else */
|
|
15
|
+
if (typeof _commonjsDynamicModules.commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
|
|
16
|
+
// Node.
|
|
17
|
+
module.exports = pluralize();
|
|
18
|
+
} else if (typeof undefined === 'function' && undefined.amd) {
|
|
19
|
+
// AMD, registers as an anonymous module.
|
|
20
|
+
undefined(function () {
|
|
21
|
+
return pluralize();
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
// Browser global.
|
|
25
|
+
root.pluralize = pluralize();
|
|
26
|
+
}
|
|
27
|
+
})(_commonjsHelpers.commonjsGlobal, function () {
|
|
28
|
+
// Rule storage - pluralize and singularize need to be run sequentially,
|
|
29
|
+
// while other rules can be optimized using an object for instant lookups.
|
|
30
|
+
var pluralRules = [];
|
|
31
|
+
var singularRules = [];
|
|
32
|
+
var uncountables = {};
|
|
33
|
+
var irregularPlurals = {};
|
|
34
|
+
var irregularSingles = {};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Sanitize a pluralization rule to a usable regular expression.
|
|
38
|
+
*
|
|
39
|
+
* @param {(RegExp|string)} rule
|
|
40
|
+
* @return {RegExp}
|
|
41
|
+
*/
|
|
42
|
+
function sanitizeRule (rule) {
|
|
43
|
+
if (typeof rule === 'string') {
|
|
44
|
+
return new RegExp('^' + rule + '$', 'i');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return rule;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Pass in a word token to produce a function that can replicate the case on
|
|
52
|
+
* another word.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} word
|
|
55
|
+
* @param {string} token
|
|
56
|
+
* @return {Function}
|
|
57
|
+
*/
|
|
58
|
+
function restoreCase (word, token) {
|
|
59
|
+
// Tokens are an exact match.
|
|
60
|
+
if (word === token) return token;
|
|
61
|
+
|
|
62
|
+
// Lower cased words. E.g. "hello".
|
|
63
|
+
if (word === word.toLowerCase()) return token.toLowerCase();
|
|
64
|
+
|
|
65
|
+
// Upper cased words. E.g. "WHISKY".
|
|
66
|
+
if (word === word.toUpperCase()) return token.toUpperCase();
|
|
67
|
+
|
|
68
|
+
// Title cased words. E.g. "Title".
|
|
69
|
+
if (word[0] === word[0].toUpperCase()) {
|
|
70
|
+
return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Lower cased words. E.g. "test".
|
|
74
|
+
return token.toLowerCase();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Interpolate a regexp string.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} str
|
|
81
|
+
* @param {Array} args
|
|
82
|
+
* @return {string}
|
|
83
|
+
*/
|
|
84
|
+
function interpolate (str, args) {
|
|
85
|
+
return str.replace(/\$(\d{1,2})/g, function (match, index) {
|
|
86
|
+
return args[index] || '';
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Replace a word using a rule.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} word
|
|
94
|
+
* @param {Array} rule
|
|
95
|
+
* @return {string}
|
|
96
|
+
*/
|
|
97
|
+
function replace (word, rule) {
|
|
98
|
+
return word.replace(rule[0], function (match, index) {
|
|
99
|
+
var result = interpolate(rule[1], arguments);
|
|
100
|
+
|
|
101
|
+
if (match === '') {
|
|
102
|
+
return restoreCase(word[index - 1], result);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return restoreCase(match, result);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Sanitize a word by passing in the word and sanitization rules.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} token
|
|
113
|
+
* @param {string} word
|
|
114
|
+
* @param {Array} rules
|
|
115
|
+
* @return {string}
|
|
116
|
+
*/
|
|
117
|
+
function sanitizeWord (token, word, rules) {
|
|
118
|
+
// Empty string or doesn't need fixing.
|
|
119
|
+
if (!token.length || uncountables.hasOwnProperty(token)) {
|
|
120
|
+
return word;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var len = rules.length;
|
|
124
|
+
|
|
125
|
+
// Iterate over the sanitization rules and use the first one to match.
|
|
126
|
+
while (len--) {
|
|
127
|
+
var rule = rules[len];
|
|
128
|
+
|
|
129
|
+
if (rule[0].test(word)) return replace(word, rule);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return word;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Replace a word with the updated word.
|
|
137
|
+
*
|
|
138
|
+
* @param {Object} replaceMap
|
|
139
|
+
* @param {Object} keepMap
|
|
140
|
+
* @param {Array} rules
|
|
141
|
+
* @return {Function}
|
|
142
|
+
*/
|
|
143
|
+
function replaceWord (replaceMap, keepMap, rules) {
|
|
144
|
+
return function (word) {
|
|
145
|
+
// Get the correct token and case restoration functions.
|
|
146
|
+
var token = word.toLowerCase();
|
|
147
|
+
|
|
148
|
+
// Check against the keep object map.
|
|
149
|
+
if (keepMap.hasOwnProperty(token)) {
|
|
150
|
+
return restoreCase(word, token);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Check against the replacement map for a direct word replacement.
|
|
154
|
+
if (replaceMap.hasOwnProperty(token)) {
|
|
155
|
+
return restoreCase(word, replaceMap[token]);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Run all the rules against the word.
|
|
159
|
+
return sanitizeWord(token, word, rules);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Check if a word is part of the map.
|
|
165
|
+
*/
|
|
166
|
+
function checkWord (replaceMap, keepMap, rules, bool) {
|
|
167
|
+
return function (word) {
|
|
168
|
+
var token = word.toLowerCase();
|
|
169
|
+
|
|
170
|
+
if (keepMap.hasOwnProperty(token)) return true;
|
|
171
|
+
if (replaceMap.hasOwnProperty(token)) return false;
|
|
172
|
+
|
|
173
|
+
return sanitizeWord(token, token, rules) === token;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Pluralize or singularize a word based on the passed in count.
|
|
179
|
+
*
|
|
180
|
+
* @param {string} word The word to pluralize
|
|
181
|
+
* @param {number} count How many of the word exist
|
|
182
|
+
* @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
|
|
183
|
+
* @return {string}
|
|
184
|
+
*/
|
|
185
|
+
function pluralize (word, count, inclusive) {
|
|
186
|
+
var pluralized = count === 1
|
|
187
|
+
? pluralize.singular(word) : pluralize.plural(word);
|
|
188
|
+
|
|
189
|
+
return (inclusive ? count + ' ' : '') + pluralized;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Pluralize a word.
|
|
194
|
+
*
|
|
195
|
+
* @type {Function}
|
|
196
|
+
*/
|
|
197
|
+
pluralize.plural = replaceWord(
|
|
198
|
+
irregularSingles, irregularPlurals, pluralRules
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Check if a word is plural.
|
|
203
|
+
*
|
|
204
|
+
* @type {Function}
|
|
205
|
+
*/
|
|
206
|
+
pluralize.isPlural = checkWord(
|
|
207
|
+
irregularSingles, irregularPlurals, pluralRules
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Singularize a word.
|
|
212
|
+
*
|
|
213
|
+
* @type {Function}
|
|
214
|
+
*/
|
|
215
|
+
pluralize.singular = replaceWord(
|
|
216
|
+
irregularPlurals, irregularSingles, singularRules
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Check if a word is singular.
|
|
221
|
+
*
|
|
222
|
+
* @type {Function}
|
|
223
|
+
*/
|
|
224
|
+
pluralize.isSingular = checkWord(
|
|
225
|
+
irregularPlurals, irregularSingles, singularRules
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Add a pluralization rule to the collection.
|
|
230
|
+
*
|
|
231
|
+
* @param {(string|RegExp)} rule
|
|
232
|
+
* @param {string} replacement
|
|
233
|
+
*/
|
|
234
|
+
pluralize.addPluralRule = function (rule, replacement) {
|
|
235
|
+
pluralRules.push([sanitizeRule(rule), replacement]);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Add a singularization rule to the collection.
|
|
240
|
+
*
|
|
241
|
+
* @param {(string|RegExp)} rule
|
|
242
|
+
* @param {string} replacement
|
|
243
|
+
*/
|
|
244
|
+
pluralize.addSingularRule = function (rule, replacement) {
|
|
245
|
+
singularRules.push([sanitizeRule(rule), replacement]);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Add an uncountable word rule.
|
|
250
|
+
*
|
|
251
|
+
* @param {(string|RegExp)} word
|
|
252
|
+
*/
|
|
253
|
+
pluralize.addUncountableRule = function (word) {
|
|
254
|
+
if (typeof word === 'string') {
|
|
255
|
+
uncountables[word.toLowerCase()] = true;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Set singular and plural references for the word.
|
|
260
|
+
pluralize.addPluralRule(word, '$0');
|
|
261
|
+
pluralize.addSingularRule(word, '$0');
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Add an irregular word definition.
|
|
266
|
+
*
|
|
267
|
+
* @param {string} single
|
|
268
|
+
* @param {string} plural
|
|
269
|
+
*/
|
|
270
|
+
pluralize.addIrregularRule = function (single, plural) {
|
|
271
|
+
plural = plural.toLowerCase();
|
|
272
|
+
single = single.toLowerCase();
|
|
273
|
+
|
|
274
|
+
irregularSingles[single] = plural;
|
|
275
|
+
irregularPlurals[plural] = single;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Irregular rules.
|
|
280
|
+
*/
|
|
281
|
+
[
|
|
282
|
+
// Pronouns.
|
|
283
|
+
['I', 'we'],
|
|
284
|
+
['me', 'us'],
|
|
285
|
+
['he', 'they'],
|
|
286
|
+
['she', 'they'],
|
|
287
|
+
['them', 'them'],
|
|
288
|
+
['myself', 'ourselves'],
|
|
289
|
+
['yourself', 'yourselves'],
|
|
290
|
+
['itself', 'themselves'],
|
|
291
|
+
['herself', 'themselves'],
|
|
292
|
+
['himself', 'themselves'],
|
|
293
|
+
['themself', 'themselves'],
|
|
294
|
+
['is', 'are'],
|
|
295
|
+
['was', 'were'],
|
|
296
|
+
['has', 'have'],
|
|
297
|
+
['this', 'these'],
|
|
298
|
+
['that', 'those'],
|
|
299
|
+
// Words ending in with a consonant and `o`.
|
|
300
|
+
['echo', 'echoes'],
|
|
301
|
+
['dingo', 'dingoes'],
|
|
302
|
+
['volcano', 'volcanoes'],
|
|
303
|
+
['tornado', 'tornadoes'],
|
|
304
|
+
['torpedo', 'torpedoes'],
|
|
305
|
+
// Ends with `us`.
|
|
306
|
+
['genus', 'genera'],
|
|
307
|
+
['viscus', 'viscera'],
|
|
308
|
+
// Ends with `ma`.
|
|
309
|
+
['stigma', 'stigmata'],
|
|
310
|
+
['stoma', 'stomata'],
|
|
311
|
+
['dogma', 'dogmata'],
|
|
312
|
+
['lemma', 'lemmata'],
|
|
313
|
+
['schema', 'schemata'],
|
|
314
|
+
['anathema', 'anathemata'],
|
|
315
|
+
// Other irregular rules.
|
|
316
|
+
['ox', 'oxen'],
|
|
317
|
+
['axe', 'axes'],
|
|
318
|
+
['die', 'dice'],
|
|
319
|
+
['yes', 'yeses'],
|
|
320
|
+
['foot', 'feet'],
|
|
321
|
+
['eave', 'eaves'],
|
|
322
|
+
['goose', 'geese'],
|
|
323
|
+
['tooth', 'teeth'],
|
|
324
|
+
['quiz', 'quizzes'],
|
|
325
|
+
['human', 'humans'],
|
|
326
|
+
['proof', 'proofs'],
|
|
327
|
+
['carve', 'carves'],
|
|
328
|
+
['valve', 'valves'],
|
|
329
|
+
['looey', 'looies'],
|
|
330
|
+
['thief', 'thieves'],
|
|
331
|
+
['groove', 'grooves'],
|
|
332
|
+
['pickaxe', 'pickaxes'],
|
|
333
|
+
['passerby', 'passersby']
|
|
334
|
+
].forEach(function (rule) {
|
|
335
|
+
return pluralize.addIrregularRule(rule[0], rule[1]);
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Pluralization rules.
|
|
340
|
+
*/
|
|
341
|
+
[
|
|
342
|
+
[/s?$/i, 's'],
|
|
343
|
+
[/[^\u0000-\u007F]$/i, '$0'],
|
|
344
|
+
[/([^aeiou]ese)$/i, '$1'],
|
|
345
|
+
[/(ax|test)is$/i, '$1es'],
|
|
346
|
+
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],
|
|
347
|
+
[/(e[mn]u)s?$/i, '$1s'],
|
|
348
|
+
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],
|
|
349
|
+
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],
|
|
350
|
+
[/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],
|
|
351
|
+
[/(seraph|cherub)(?:im)?$/i, '$1im'],
|
|
352
|
+
[/(her|at|gr)o$/i, '$1oes'],
|
|
353
|
+
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],
|
|
354
|
+
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],
|
|
355
|
+
[/sis$/i, 'ses'],
|
|
356
|
+
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],
|
|
357
|
+
[/([^aeiouy]|qu)y$/i, '$1ies'],
|
|
358
|
+
[/([^ch][ieo][ln])ey$/i, '$1ies'],
|
|
359
|
+
[/(x|ch|ss|sh|zz)$/i, '$1es'],
|
|
360
|
+
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
|
|
361
|
+
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'],
|
|
362
|
+
[/(pe)(?:rson|ople)$/i, '$1ople'],
|
|
363
|
+
[/(child)(?:ren)?$/i, '$1ren'],
|
|
364
|
+
[/eaux$/i, '$0'],
|
|
365
|
+
[/m[ae]n$/i, 'men'],
|
|
366
|
+
['thou', 'you']
|
|
367
|
+
].forEach(function (rule) {
|
|
368
|
+
return pluralize.addPluralRule(rule[0], rule[1]);
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Singularization rules.
|
|
373
|
+
*/
|
|
374
|
+
[
|
|
375
|
+
[/s$/i, ''],
|
|
376
|
+
[/(ss)$/i, '$1'],
|
|
377
|
+
[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'],
|
|
378
|
+
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'],
|
|
379
|
+
[/ies$/i, 'y'],
|
|
380
|
+
[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],
|
|
381
|
+
[/\b(mon|smil)ies$/i, '$1ey'],
|
|
382
|
+
[/\b((?:tit)?m|l)ice$/i, '$1ouse'],
|
|
383
|
+
[/(seraph|cherub)im$/i, '$1'],
|
|
384
|
+
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],
|
|
385
|
+
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],
|
|
386
|
+
[/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],
|
|
387
|
+
[/(test)(?:is|es)$/i, '$1is'],
|
|
388
|
+
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],
|
|
389
|
+
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],
|
|
390
|
+
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],
|
|
391
|
+
[/(alumn|alg|vertebr)ae$/i, '$1a'],
|
|
392
|
+
[/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],
|
|
393
|
+
[/(matr|append)ices$/i, '$1ix'],
|
|
394
|
+
[/(pe)(rson|ople)$/i, '$1rson'],
|
|
395
|
+
[/(child)ren$/i, '$1'],
|
|
396
|
+
[/(eau)x?$/i, '$1'],
|
|
397
|
+
[/men$/i, 'man']
|
|
398
|
+
].forEach(function (rule) {
|
|
399
|
+
return pluralize.addSingularRule(rule[0], rule[1]);
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Uncountable rules.
|
|
404
|
+
*/
|
|
405
|
+
[
|
|
406
|
+
// Singular words with no plurals.
|
|
407
|
+
'adulthood',
|
|
408
|
+
'advice',
|
|
409
|
+
'agenda',
|
|
410
|
+
'aid',
|
|
411
|
+
'aircraft',
|
|
412
|
+
'alcohol',
|
|
413
|
+
'ammo',
|
|
414
|
+
'analytics',
|
|
415
|
+
'anime',
|
|
416
|
+
'athletics',
|
|
417
|
+
'audio',
|
|
418
|
+
'bison',
|
|
419
|
+
'blood',
|
|
420
|
+
'bream',
|
|
421
|
+
'buffalo',
|
|
422
|
+
'butter',
|
|
423
|
+
'carp',
|
|
424
|
+
'cash',
|
|
425
|
+
'chassis',
|
|
426
|
+
'chess',
|
|
427
|
+
'clothing',
|
|
428
|
+
'cod',
|
|
429
|
+
'commerce',
|
|
430
|
+
'cooperation',
|
|
431
|
+
'corps',
|
|
432
|
+
'debris',
|
|
433
|
+
'diabetes',
|
|
434
|
+
'digestion',
|
|
435
|
+
'elk',
|
|
436
|
+
'energy',
|
|
437
|
+
'equipment',
|
|
438
|
+
'excretion',
|
|
439
|
+
'expertise',
|
|
440
|
+
'firmware',
|
|
441
|
+
'flounder',
|
|
442
|
+
'fun',
|
|
443
|
+
'gallows',
|
|
444
|
+
'garbage',
|
|
445
|
+
'graffiti',
|
|
446
|
+
'hardware',
|
|
447
|
+
'headquarters',
|
|
448
|
+
'health',
|
|
449
|
+
'herpes',
|
|
450
|
+
'highjinks',
|
|
451
|
+
'homework',
|
|
452
|
+
'housework',
|
|
453
|
+
'information',
|
|
454
|
+
'jeans',
|
|
455
|
+
'justice',
|
|
456
|
+
'kudos',
|
|
457
|
+
'labour',
|
|
458
|
+
'literature',
|
|
459
|
+
'machinery',
|
|
460
|
+
'mackerel',
|
|
461
|
+
'mail',
|
|
462
|
+
'media',
|
|
463
|
+
'mews',
|
|
464
|
+
'moose',
|
|
465
|
+
'music',
|
|
466
|
+
'mud',
|
|
467
|
+
'manga',
|
|
468
|
+
'news',
|
|
469
|
+
'only',
|
|
470
|
+
'personnel',
|
|
471
|
+
'pike',
|
|
472
|
+
'plankton',
|
|
473
|
+
'pliers',
|
|
474
|
+
'police',
|
|
475
|
+
'pollution',
|
|
476
|
+
'premises',
|
|
477
|
+
'rain',
|
|
478
|
+
'research',
|
|
479
|
+
'rice',
|
|
480
|
+
'salmon',
|
|
481
|
+
'scissors',
|
|
482
|
+
'series',
|
|
483
|
+
'sewage',
|
|
484
|
+
'shambles',
|
|
485
|
+
'shrimp',
|
|
486
|
+
'software',
|
|
487
|
+
'species',
|
|
488
|
+
'staff',
|
|
489
|
+
'swine',
|
|
490
|
+
'tennis',
|
|
491
|
+
'traffic',
|
|
492
|
+
'transportation',
|
|
493
|
+
'trout',
|
|
494
|
+
'tuna',
|
|
495
|
+
'wealth',
|
|
496
|
+
'welfare',
|
|
497
|
+
'whiting',
|
|
498
|
+
'wildebeest',
|
|
499
|
+
'wildlife',
|
|
500
|
+
'you',
|
|
501
|
+
/pok[eé]mon$/i,
|
|
502
|
+
// Regexes.
|
|
503
|
+
/[^aeiou]ese$/i, // "chinese", "japanese"
|
|
504
|
+
/deer$/i, // "deer", "reindeer"
|
|
505
|
+
/fish$/i, // "fish", "blowfish", "angelfish"
|
|
506
|
+
/measles$/i,
|
|
507
|
+
/o[iu]s$/i, // "carnivorous"
|
|
508
|
+
/pox$/i, // "chickpox", "smallpox"
|
|
509
|
+
/sheep$/i
|
|
510
|
+
].forEach(pluralize.addUncountableRule);
|
|
511
|
+
|
|
512
|
+
return pluralize;
|
|
513
|
+
});
|
|
514
|
+
} (pluralize$2.__module, pluralize$2.__module.exports));
|
|
515
|
+
|
|
516
|
+
var pluralizeExports = pluralize$2.__module.exports;
|
|
517
|
+
var pluralize$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(pluralizeExports);
|
|
518
|
+
|
|
519
|
+
exports.default = pluralize$1;
|