iglooform 2.5.46 → 2.5.48
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/es/confirmation/index.js +1 -1
- package/es/types.d.ts +1 -1
- package/es/utils/form-utils.js +44 -0
- package/es/utils/option-utils.d.ts +1 -0
- package/es/utils/option-utils.js +21 -13
- package/lib/confirmation/index.js +1 -1
- package/lib/types.d.ts +1 -1
- package/lib/utils/form-utils.js +44 -0
- package/lib/utils/option-utils.d.ts +1 -0
- package/lib/utils/option-utils.js +21 -13
- package/package.json +1 -1
package/es/confirmation/index.js
CHANGED
package/es/types.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface FormBasicConfig {
|
|
|
35
35
|
export declare type FormItemAssert = {
|
|
36
36
|
field: NamePath;
|
|
37
37
|
value?: any;
|
|
38
|
-
operation?: 'eq' | 'ne' | 'in' | 'ni' | 'lt' | 'le' | 'gt' | 'ge' | 'co' | 'nc' | 'filled' | 'unfilled';
|
|
38
|
+
operation?: 'eq' | 'ne' | 'in' | 'ni' | 'lt' | 'le' | 'gt' | 'ge' | 'co' | 'nc' | 'filled' | 'unfilled' | 'co-some' | 'co-every' | 'some-in' | 'every-in';
|
|
39
39
|
};
|
|
40
40
|
export declare type FormItemCopyValue = {
|
|
41
41
|
assert: FormItemAssert;
|
package/es/utils/form-utils.js
CHANGED
|
@@ -99,6 +99,50 @@ export var testAssert = function testAssert(form, assert) {
|
|
|
99
99
|
case 'eq':
|
|
100
100
|
return v === value;
|
|
101
101
|
|
|
102
|
+
case 'co-every':
|
|
103
|
+
{
|
|
104
|
+
if (!Array.isArray(v) || !Array.isArray(value)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return value.every(function (i) {
|
|
109
|
+
return v.includes(i);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
case 'co-some':
|
|
114
|
+
{
|
|
115
|
+
if (!Array.isArray(v) || !Array.isArray(value)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return value.some(function (i) {
|
|
120
|
+
return v.includes(i);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
case 'every-in':
|
|
125
|
+
{
|
|
126
|
+
if (!Array.isArray(v) || !Array.isArray(value)) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return v.every(function (i) {
|
|
131
|
+
return value.includes(i);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
case 'some-in':
|
|
136
|
+
{
|
|
137
|
+
if (!Array.isArray(v) || !Array.isArray(value)) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return v.some(function (i) {
|
|
142
|
+
return value.includes(i);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
102
146
|
default:
|
|
103
147
|
if (value !== undefined) return v === value;
|
|
104
148
|
return v !== undefined;
|
package/es/utils/option-utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["options", "optionGroups", "getOptions", "datasourceKey", "dependField", "children", "onSearch"];
|
|
1
|
+
var _excluded = ["options", "optionGroups", "getOptions", "datasourceFilters", "datasourceKey", "dependField", "children", "onSearch"];
|
|
2
2
|
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
@@ -86,6 +86,7 @@ export function optionsHOC(Component) {
|
|
|
86
86
|
var options = props.options,
|
|
87
87
|
optionGroups = props.optionGroups,
|
|
88
88
|
getOptions = props.getOptions,
|
|
89
|
+
datasourceFilters = props.datasourceFilters,
|
|
89
90
|
datasourceKey = props.datasourceKey,
|
|
90
91
|
dependField = props.dependField,
|
|
91
92
|
children = props.children,
|
|
@@ -127,6 +128,7 @@ export function optionsHOC(Component) {
|
|
|
127
128
|
}
|
|
128
129
|
}, [optionsFromGetOptions]);
|
|
129
130
|
invariant(datasourceKey && selectDatasourceApi || !datasourceKey, 'Please provide selectDatasourceApi in Form props');
|
|
131
|
+
invariant(datasourceFilters && datasourceKey && selectDatasourceApi || !datasourceFilters, 'Please provide selectDatasourceApi in Form props');
|
|
130
132
|
useEffect(function () {
|
|
131
133
|
if (Array.isArray(optionsFromGetOptions)) {
|
|
132
134
|
return;
|
|
@@ -190,7 +192,7 @@ export function optionsHOC(Component) {
|
|
|
190
192
|
|
|
191
193
|
case 9:
|
|
192
194
|
if (!(selectDatasourceApi && datasourceKey)) {
|
|
193
|
-
_context.next =
|
|
195
|
+
_context.next = 28;
|
|
194
196
|
break;
|
|
195
197
|
}
|
|
196
198
|
|
|
@@ -202,35 +204,41 @@ export function optionsHOC(Component) {
|
|
|
202
204
|
query += "&search_keyword=".concat(searchKey);
|
|
203
205
|
}
|
|
204
206
|
|
|
207
|
+
if (datasourceFilters) {
|
|
208
|
+
query += datasourceFilters.map(function (f) {
|
|
209
|
+
return "filter=".concat(f);
|
|
210
|
+
}).join('&');
|
|
211
|
+
}
|
|
212
|
+
|
|
205
213
|
api = "".concat(selectDatasourceApi, "/").concat(datasourceKey);
|
|
206
|
-
_context.prev =
|
|
207
|
-
_context.next =
|
|
214
|
+
_context.prev = 14;
|
|
215
|
+
_context.next = 17;
|
|
208
216
|
return fetch(query ? "".concat(api, "?").concat(query) : api);
|
|
209
217
|
|
|
210
|
-
case
|
|
218
|
+
case 17:
|
|
211
219
|
rst = _context.sent;
|
|
212
|
-
_context.next =
|
|
220
|
+
_context.next = 20;
|
|
213
221
|
return rst.json();
|
|
214
222
|
|
|
215
|
-
case
|
|
223
|
+
case 20:
|
|
216
224
|
_yield$rst$json = _context.sent;
|
|
217
225
|
data = _yield$rst$json.data;
|
|
218
226
|
return _context.abrupt("return", data || []);
|
|
219
227
|
|
|
220
|
-
case
|
|
221
|
-
_context.prev =
|
|
222
|
-
_context.t0 = _context["catch"](
|
|
228
|
+
case 25:
|
|
229
|
+
_context.prev = 25;
|
|
230
|
+
_context.t0 = _context["catch"](14);
|
|
223
231
|
return _context.abrupt("return", []);
|
|
224
232
|
|
|
225
|
-
case
|
|
233
|
+
case 28:
|
|
226
234
|
return _context.abrupt("return", []);
|
|
227
235
|
|
|
228
|
-
case
|
|
236
|
+
case 29:
|
|
229
237
|
case "end":
|
|
230
238
|
return _context.stop();
|
|
231
239
|
}
|
|
232
240
|
}
|
|
233
|
-
}, _callee, null, [[
|
|
241
|
+
}, _callee, null, [[14, 25]]);
|
|
234
242
|
}));
|
|
235
243
|
|
|
236
244
|
return function calcOptions() {
|
package/lib/types.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface FormBasicConfig {
|
|
|
35
35
|
export declare type FormItemAssert = {
|
|
36
36
|
field: NamePath;
|
|
37
37
|
value?: any;
|
|
38
|
-
operation?: 'eq' | 'ne' | 'in' | 'ni' | 'lt' | 'le' | 'gt' | 'ge' | 'co' | 'nc' | 'filled' | 'unfilled';
|
|
38
|
+
operation?: 'eq' | 'ne' | 'in' | 'ni' | 'lt' | 'le' | 'gt' | 'ge' | 'co' | 'nc' | 'filled' | 'unfilled' | 'co-some' | 'co-every' | 'some-in' | 'every-in';
|
|
39
39
|
};
|
|
40
40
|
export declare type FormItemCopyValue = {
|
|
41
41
|
assert: FormItemAssert;
|
package/lib/utils/form-utils.js
CHANGED
|
@@ -116,6 +116,50 @@ var testAssert = function testAssert(form, assert) {
|
|
|
116
116
|
case 'eq':
|
|
117
117
|
return v === value;
|
|
118
118
|
|
|
119
|
+
case 'co-every':
|
|
120
|
+
{
|
|
121
|
+
if (!Array.isArray(v) || !Array.isArray(value)) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return value.every(function (i) {
|
|
126
|
+
return v.includes(i);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
case 'co-some':
|
|
131
|
+
{
|
|
132
|
+
if (!Array.isArray(v) || !Array.isArray(value)) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return value.some(function (i) {
|
|
137
|
+
return v.includes(i);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
case 'every-in':
|
|
142
|
+
{
|
|
143
|
+
if (!Array.isArray(v) || !Array.isArray(value)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return v.every(function (i) {
|
|
148
|
+
return value.includes(i);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
case 'some-in':
|
|
153
|
+
{
|
|
154
|
+
if (!Array.isArray(v) || !Array.isArray(value)) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return v.some(function (i) {
|
|
159
|
+
return value.includes(i);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
119
163
|
default:
|
|
120
164
|
if (value !== undefined) return v === value;
|
|
121
165
|
return v !== undefined;
|
|
@@ -15,7 +15,7 @@ var _formContext = _interopRequireDefault(require("../form-context"));
|
|
|
15
15
|
|
|
16
16
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
17
17
|
|
|
18
|
-
var _excluded = ["options", "optionGroups", "getOptions", "datasourceKey", "dependField", "children", "onSearch"];
|
|
18
|
+
var _excluded = ["options", "optionGroups", "getOptions", "datasourceFilters", "datasourceKey", "dependField", "children", "onSearch"];
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
@@ -107,6 +107,7 @@ function optionsHOC(Component) {
|
|
|
107
107
|
var options = props.options,
|
|
108
108
|
optionGroups = props.optionGroups,
|
|
109
109
|
getOptions = props.getOptions,
|
|
110
|
+
datasourceFilters = props.datasourceFilters,
|
|
110
111
|
datasourceKey = props.datasourceKey,
|
|
111
112
|
dependField = props.dependField,
|
|
112
113
|
children = props.children,
|
|
@@ -148,6 +149,7 @@ function optionsHOC(Component) {
|
|
|
148
149
|
}
|
|
149
150
|
}, [optionsFromGetOptions]);
|
|
150
151
|
(0, _invariant.default)(datasourceKey && selectDatasourceApi || !datasourceKey, 'Please provide selectDatasourceApi in Form props');
|
|
152
|
+
(0, _invariant.default)(datasourceFilters && datasourceKey && selectDatasourceApi || !datasourceFilters, 'Please provide selectDatasourceApi in Form props');
|
|
151
153
|
(0, _react.useEffect)(function () {
|
|
152
154
|
if (Array.isArray(optionsFromGetOptions)) {
|
|
153
155
|
return;
|
|
@@ -211,7 +213,7 @@ function optionsHOC(Component) {
|
|
|
211
213
|
|
|
212
214
|
case 9:
|
|
213
215
|
if (!(selectDatasourceApi && datasourceKey)) {
|
|
214
|
-
_context.next =
|
|
216
|
+
_context.next = 28;
|
|
215
217
|
break;
|
|
216
218
|
}
|
|
217
219
|
|
|
@@ -223,35 +225,41 @@ function optionsHOC(Component) {
|
|
|
223
225
|
query += "&search_keyword=".concat(searchKey);
|
|
224
226
|
}
|
|
225
227
|
|
|
228
|
+
if (datasourceFilters) {
|
|
229
|
+
query += datasourceFilters.map(function (f) {
|
|
230
|
+
return "filter=".concat(f);
|
|
231
|
+
}).join('&');
|
|
232
|
+
}
|
|
233
|
+
|
|
226
234
|
api = "".concat(selectDatasourceApi, "/").concat(datasourceKey);
|
|
227
|
-
_context.prev =
|
|
228
|
-
_context.next =
|
|
235
|
+
_context.prev = 14;
|
|
236
|
+
_context.next = 17;
|
|
229
237
|
return fetch(query ? "".concat(api, "?").concat(query) : api);
|
|
230
238
|
|
|
231
|
-
case
|
|
239
|
+
case 17:
|
|
232
240
|
rst = _context.sent;
|
|
233
|
-
_context.next =
|
|
241
|
+
_context.next = 20;
|
|
234
242
|
return rst.json();
|
|
235
243
|
|
|
236
|
-
case
|
|
244
|
+
case 20:
|
|
237
245
|
_yield$rst$json = _context.sent;
|
|
238
246
|
data = _yield$rst$json.data;
|
|
239
247
|
return _context.abrupt("return", data || []);
|
|
240
248
|
|
|
241
|
-
case
|
|
242
|
-
_context.prev =
|
|
243
|
-
_context.t0 = _context["catch"](
|
|
249
|
+
case 25:
|
|
250
|
+
_context.prev = 25;
|
|
251
|
+
_context.t0 = _context["catch"](14);
|
|
244
252
|
return _context.abrupt("return", []);
|
|
245
253
|
|
|
246
|
-
case
|
|
254
|
+
case 28:
|
|
247
255
|
return _context.abrupt("return", []);
|
|
248
256
|
|
|
249
|
-
case
|
|
257
|
+
case 29:
|
|
250
258
|
case "end":
|
|
251
259
|
return _context.stop();
|
|
252
260
|
}
|
|
253
261
|
}
|
|
254
|
-
}, _callee, null, [[
|
|
262
|
+
}, _callee, null, [[14, 25]]);
|
|
255
263
|
}));
|
|
256
264
|
|
|
257
265
|
return function calcOptions() {
|