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.
@@ -81,7 +81,7 @@ var Confirmation = function Confirmation(_ref) {
81
81
  return;
82
82
  }
83
83
 
84
- onChange && onChange(!value);
84
+ onChange && onChange(!value || undefined);
85
85
  },
86
86
  style: {
87
87
  cursor: 'pointer',
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;
@@ -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;
@@ -13,6 +13,7 @@ export interface HOCProps extends IglooComponentProps {
13
13
  parentKey: string;
14
14
  options: Options;
15
15
  }[];
16
+ datasourceFilters?: string[];
16
17
  datasourceKey?: string;
17
18
  datasourceApi?: string;
18
19
  dependField?: NamePath;
@@ -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 = 27;
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 = 13;
207
- _context.next = 16;
214
+ _context.prev = 14;
215
+ _context.next = 17;
208
216
  return fetch(query ? "".concat(api, "?").concat(query) : api);
209
217
 
210
- case 16:
218
+ case 17:
211
219
  rst = _context.sent;
212
- _context.next = 19;
220
+ _context.next = 20;
213
221
  return rst.json();
214
222
 
215
- case 19:
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 24:
221
- _context.prev = 24;
222
- _context.t0 = _context["catch"](13);
228
+ case 25:
229
+ _context.prev = 25;
230
+ _context.t0 = _context["catch"](14);
223
231
  return _context.abrupt("return", []);
224
232
 
225
- case 27:
233
+ case 28:
226
234
  return _context.abrupt("return", []);
227
235
 
228
- case 28:
236
+ case 29:
229
237
  case "end":
230
238
  return _context.stop();
231
239
  }
232
240
  }
233
- }, _callee, null, [[13, 24]]);
241
+ }, _callee, null, [[14, 25]]);
234
242
  }));
235
243
 
236
244
  return function calcOptions() {
@@ -96,7 +96,7 @@ var Confirmation = function Confirmation(_ref) {
96
96
  return;
97
97
  }
98
98
 
99
- onChange && onChange(!value);
99
+ onChange && onChange(!value || undefined);
100
100
  },
101
101
  style: {
102
102
  cursor: 'pointer',
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;
@@ -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;
@@ -13,6 +13,7 @@ export interface HOCProps extends IglooComponentProps {
13
13
  parentKey: string;
14
14
  options: Options;
15
15
  }[];
16
+ datasourceFilters?: string[];
16
17
  datasourceKey?: string;
17
18
  datasourceApi?: string;
18
19
  dependField?: NamePath;
@@ -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 = 27;
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 = 13;
228
- _context.next = 16;
235
+ _context.prev = 14;
236
+ _context.next = 17;
229
237
  return fetch(query ? "".concat(api, "?").concat(query) : api);
230
238
 
231
- case 16:
239
+ case 17:
232
240
  rst = _context.sent;
233
- _context.next = 19;
241
+ _context.next = 20;
234
242
  return rst.json();
235
243
 
236
- case 19:
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 24:
242
- _context.prev = 24;
243
- _context.t0 = _context["catch"](13);
249
+ case 25:
250
+ _context.prev = 25;
251
+ _context.t0 = _context["catch"](14);
244
252
  return _context.abrupt("return", []);
245
253
 
246
- case 27:
254
+ case 28:
247
255
  return _context.abrupt("return", []);
248
256
 
249
- case 28:
257
+ case 29:
250
258
  case "end":
251
259
  return _context.stop();
252
260
  }
253
261
  }
254
- }, _callee, null, [[13, 24]]);
262
+ }, _callee, null, [[14, 25]]);
255
263
  }));
256
264
 
257
265
  return function calcOptions() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iglooform",
3
- "version": "2.5.46",
3
+ "version": "2.5.48",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "build-dev": "dumi build",