iglooform 2.4.20 → 2.4.24

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.
@@ -307,7 +307,9 @@ var Element = function Element(_ref) {
307
307
  className: "igloo-element-preview-value",
308
308
  children: [error && !!error.length && _jsx(AlertFilled, {
309
309
  className: "igloo-element-preview-value-icon"
310
- }, void 0), previewFormater ? previewFormater(value, form) : value || '-']
310
+ }, void 0), _jsx("div", {
311
+ children: previewFormater ? previewFormater(value, form) : _typeof(value) === 'object' ? JSON.stringify(value) : value
312
+ }, void 0)]
311
313
  }, void 0)]
312
314
  }, void 0)
313
315
  }), void 0)
@@ -43,6 +43,7 @@ var Step = function Step(_ref) {
43
43
  editButtonLabel = _ref$config.editButtonLabel,
44
44
  getButtonDisabledState = _ref$config.getButtonDisabledState,
45
45
  disableEditButton = _ref$config.disableEditButton,
46
+ buttonText = _ref$config.buttonText,
46
47
  edit = _ref.edit,
47
48
  preview = _ref.preview,
48
49
  index = _ref.index,
@@ -139,7 +140,7 @@ var Step = function Step(_ref) {
139
140
  className: 'igloo-step-button',
140
141
  type: "primary",
141
142
  disabled: buttonDisabled,
142
- children: continueText || formatMessage({
143
+ children: buttonText || continueText || formatMessage({
143
144
  id: 'Continue'
144
145
  })
145
146
  }, void 0)
@@ -153,7 +154,7 @@ var Step = function Step(_ref) {
153
154
  className: 'igloo-step-button',
154
155
  loading: submitting,
155
156
  disabled: buttonDisabled,
156
- children: submitText || formatMessage({
157
+ children: buttonText || submitText || formatMessage({
157
158
  id: 'Submit'
158
159
  })
159
160
  }, void 0)
@@ -262,7 +262,9 @@ var Element = function Element(props) {
262
262
  className: "igloo-freeform-element-preview-value",
263
263
  children: [error && !!error.length && _jsx(AlertFilled, {
264
264
  className: "igloo-freeform-element-preview-value-icon"
265
- }, void 0), previewFormater ? previewFormater(value, form) : value || '-']
265
+ }, void 0), _jsx("div", {
266
+ children: previewFormater ? previewFormater(value, form) : _typeof(value) === 'object' ? JSON.stringify(value) : value
267
+ }, void 0)]
266
268
  }, void 0)]
267
269
  }, void 0)
268
270
  }), void 0)
@@ -15,6 +15,7 @@ export interface StepProps extends FormItemConfig {
15
15
  shouldScroll?: boolean;
16
16
  editButtonLabel?: string;
17
17
  disableEditButton?: boolean;
18
+ buttonText?: string;
18
19
  }
19
20
  declare const Step: FC<StepProps>;
20
21
  export default Step;
@@ -60,7 +60,8 @@ var Step = function Step(_ref) {
60
60
  shouldScroll = _ref.shouldScroll,
61
61
  children = _ref.children,
62
62
  shouldRender = _ref.shouldRender,
63
- subscribedFields = _ref.subscribedFields;
63
+ subscribedFields = _ref.subscribedFields,
64
+ buttonText = _ref.buttonText;
64
65
 
65
66
  var _useContext = useContext(LocaleContext),
66
67
  formatMessage = _useContext.formatMessage;
@@ -261,7 +262,7 @@ var Step = function Step(_ref) {
261
262
  className: 'igloo-freeform-step-button',
262
263
  type: "primary",
263
264
  disabled: buttonDisabled,
264
- children: continueText || formatMessage({
265
+ children: buttonText || continueText || formatMessage({
265
266
  id: 'Continue'
266
267
  })
267
268
  }, void 0)
@@ -275,7 +276,7 @@ var Step = function Step(_ref) {
275
276
  className: 'igloo-freeform-step-button',
276
277
  loading: submitting,
277
278
  disabled: buttonDisabled,
278
- children: submitText || formatMessage({
279
+ children: buttonText || submitText || formatMessage({
279
280
  id: 'Submit'
280
281
  })
281
282
  }, void 0)
@@ -172,6 +172,7 @@ var IglooCredit = function IglooCredit(props) {
172
172
  }
173
173
  }
174
174
 
175
+ formOnChange && formOnChange('error type');
175
176
  setFieldError && setFieldError(formatMessage({
176
177
  id: 'Credit card must be {typeNames} or {finalName}',
177
178
  values: getErrorMessage(cardRules)
@@ -179,7 +180,7 @@ var IglooCredit = function IglooCredit(props) {
179
180
  }
180
181
 
181
182
  useEffect(function () {
182
- if (value) {
183
+ if (value && value !== 'error type') {
183
184
  handleOnChange(value, [].concat(_toConsumableArray(cardConfig), defaultCheck), formChangeProps);
184
185
  }
185
186
  }, [value]);
@@ -214,7 +215,8 @@ function checkCard(value, cardRules) {
214
215
  }
215
216
 
216
217
  IglooCredit.formItemPropsHandler = function (config) {
217
- var cardConfig = config.cardConfig;
218
+ var _config$cardConfig = config.cardConfig,
219
+ cardConfig = _config$cardConfig === void 0 ? [] : _config$cardConfig;
218
220
  return {
219
221
  rules: [{
220
222
  validator: function validator(_, value) {
@@ -100,7 +100,8 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
100
100
  setInput = _useState4[1];
101
101
 
102
102
  useEffect(function () {
103
- if (!value) return;
103
+ if (!value || typeof value === 'string') return; //=== string 就是value='error type'
104
+
104
105
  setInput(value);
105
106
  inputValueRef.current = value;
106
107
  }, [value.year, value.month]);
@@ -119,6 +120,7 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
119
120
  if (userCheck && compCheck) {
120
121
  onChangeProps && onChangeProps(value);
121
122
  } else {
123
+ onChangeProps && onChangeProps('error type');
122
124
  setFieldError && setFieldError(formatMessage({
123
125
  id: 'Please enter a valid date.'
124
126
  }));
@@ -280,7 +282,12 @@ IglooExpiryDate.formItemPropsHandler = function (config) {
280
282
  validator: function validator(_, value) {
281
283
  return checkTime(value, check);
282
284
  }
283
- }]
285
+ }],
286
+ previewFormater: function previewFormater(_ref2) {
287
+ var year = _ref2.year,
288
+ month = _ref2.month;
289
+ return "".concat(month, "/").concat(year);
290
+ }
284
291
  };
285
292
  };
286
293
 
@@ -105,7 +105,7 @@ var IglooInputDate = function IglooInputDate(props) {
105
105
  formatMessage = _useContext.formatMessage;
106
106
 
107
107
  useEffect(function () {
108
- if (!value) return;
108
+ if (!value || value === 'error type') return;
109
109
  var init = value.split(delimiter);
110
110
  setInput(init);
111
111
  inputValueRef.current = init;
@@ -119,6 +119,7 @@ var IglooInputDate = function IglooInputDate(props) {
119
119
  if (available) {
120
120
  onChangeProps && onChangeProps(value);
121
121
  } else {
122
+ onChangeProps && onChangeProps('error type');
122
123
  setFieldError && setFieldError(formatMessage({
123
124
  id: 'Please enter a valid date.'
124
125
  }));
@@ -36,8 +36,8 @@ IglooInputNumber.formItemPropsHandler = function (config) {
36
36
  getValueFromEvent: function getValueFromEvent(e) {
37
37
  var value = e.target.value;
38
38
  var str = value.replaceAll(/[^0-9\.]/g, '');
39
- if (value.endsWith('.')) return str;
40
- return str ? parseFloat(str) : str;
39
+ if (value.endsWith('.')) return parseInt(str);
40
+ return str ? parseFloat(str) : undefined;
41
41
  }
42
42
  };
43
43
  };
@@ -1,7 +1,10 @@
1
1
  import { FC, CSSProperties } from 'react';
2
2
  import './style/index.less';
3
3
  declare const PlatformCard: FC<{
4
- platform: string;
4
+ platform: string | {
5
+ name: string;
6
+ key: string;
7
+ };
5
8
  onClick: any;
6
9
  className?: any;
7
10
  style?: CSSProperties;
@@ -30,6 +30,8 @@ var PlatformCard = function PlatformCard(_ref) {
30
30
  showDefault = _useState2[0],
31
31
  setShowDefault = _useState2[1];
32
32
 
33
+ var key = typeof platform === 'string' ? platform : platform.key;
34
+ var name = typeof platform === 'string' ? platform : platform.name;
33
35
  return _jsxs("div", {
34
36
  className: classnames('igloo-platform', className),
35
37
  onClick: onClick,
@@ -43,12 +45,12 @@ var PlatformCard = function PlatformCard(_ref) {
43
45
  className: "igloo-platform-defaultLogo"
44
46
  }, void 0), _jsx("div", {
45
47
  className: "igloo-platform-name",
46
- children: platform
48
+ children: name
47
49
  }, void 0)]
48
50
  }, void 0), !showDefault && _jsx(_Image, {
49
51
  width: 200,
50
52
  height: 200,
51
- src: "https://static.iglooinsure.com/partner/normal/".concat(platform.toLowerCase(), ".svg"),
53
+ src: "https://static.iglooinsure.com/partner/normal/".concat(key.toLowerCase(), ".svg"),
52
54
  onError: function onError() {
53
55
  return setShowDefault(true);
54
56
  },
@@ -1,7 +1,10 @@
1
1
  import { FC } from 'react';
2
2
  import './style/index.less';
3
3
  interface Props {
4
- platforms: string[];
4
+ platforms: (string | {
5
+ name: string;
6
+ key: string;
7
+ })[];
5
8
  currentPlatform: string;
6
9
  onChange: (platform: string) => any;
7
10
  }
@@ -45,7 +45,9 @@ var SwitchPlatform = function SwitchPlatform(_ref) {
45
45
  trigger: ['click'],
46
46
  overlay: _jsx(_Menu, {
47
47
  onClick: handleChange,
48
- children: platforms === null || platforms === void 0 ? void 0 : platforms.map(function (name) {
48
+ children: platforms === null || platforms === void 0 ? void 0 : platforms.map(function (platform) {
49
+ var name = typeof platform === 'string' ? platform : platform.name;
50
+ var key = typeof platform === 'string' ? platform : platform.key;
49
51
  return _jsxs(_Menu.Item, {
50
52
  className: "igloo-switch-platform-option",
51
53
  children: [_jsx(_Image, {
@@ -57,7 +59,7 @@ var SwitchPlatform = function SwitchPlatform(_ref) {
57
59
  className: "igloo-switch-platform-name",
58
60
  children: name
59
61
  }, void 0)]
60
- }, name);
62
+ }, key);
61
63
  })
62
64
  }, void 0),
63
65
  getPopupContainer: function getPopupContainer(trigger) {
@@ -336,7 +336,9 @@ var Element = function Element(_ref) {
336
336
  className: "igloo-element-preview-value",
337
337
  children: [error && !!error.length && (0, _jsxRuntime.jsx)(_iglooicon.AlertFilled, {
338
338
  className: "igloo-element-preview-value-icon"
339
- }, void 0), previewFormater ? previewFormater(value, form) : value || '-']
339
+ }, void 0), (0, _jsxRuntime.jsx)("div", {
340
+ children: previewFormater ? previewFormater(value, form) : _typeof(value) === 'object' ? JSON.stringify(value) : value
341
+ }, void 0)]
340
342
  }, void 0)]
341
343
  }, void 0)
342
344
  }), void 0)
@@ -67,6 +67,7 @@ var Step = function Step(_ref) {
67
67
  editButtonLabel = _ref$config.editButtonLabel,
68
68
  getButtonDisabledState = _ref$config.getButtonDisabledState,
69
69
  disableEditButton = _ref$config.disableEditButton,
70
+ buttonText = _ref$config.buttonText,
70
71
  edit = _ref.edit,
71
72
  preview = _ref.preview,
72
73
  index = _ref.index,
@@ -163,7 +164,7 @@ var Step = function Step(_ref) {
163
164
  className: 'igloo-step-button',
164
165
  type: "primary",
165
166
  disabled: buttonDisabled,
166
- children: continueText || formatMessage({
167
+ children: buttonText || continueText || formatMessage({
167
168
  id: 'Continue'
168
169
  })
169
170
  }, void 0)
@@ -177,7 +178,7 @@ var Step = function Step(_ref) {
177
178
  className: 'igloo-step-button',
178
179
  loading: submitting,
179
180
  disabled: buttonDisabled,
180
- children: submitText || formatMessage({
181
+ children: buttonText || submitText || formatMessage({
181
182
  id: 'Submit'
182
183
  })
183
184
  }, void 0)
@@ -288,7 +288,9 @@ var Element = function Element(props) {
288
288
  className: "igloo-freeform-element-preview-value",
289
289
  children: [error && !!error.length && (0, _jsxRuntime.jsx)(_iglooicon.AlertFilled, {
290
290
  className: "igloo-freeform-element-preview-value-icon"
291
- }, void 0), previewFormater ? previewFormater(value, form) : value || '-']
291
+ }, void 0), (0, _jsxRuntime.jsx)("div", {
292
+ children: previewFormater ? previewFormater(value, form) : _typeof(value) === 'object' ? JSON.stringify(value) : value
293
+ }, void 0)]
292
294
  }, void 0)]
293
295
  }, void 0)
294
296
  }), void 0)
@@ -15,6 +15,7 @@ export interface StepProps extends FormItemConfig {
15
15
  shouldScroll?: boolean;
16
16
  editButtonLabel?: string;
17
17
  disableEditButton?: boolean;
18
+ buttonText?: string;
18
19
  }
19
20
  declare const Step: FC<StepProps>;
20
21
  export default Step;
@@ -83,7 +83,8 @@ var Step = function Step(_ref) {
83
83
  shouldScroll = _ref.shouldScroll,
84
84
  children = _ref.children,
85
85
  shouldRender = _ref.shouldRender,
86
- subscribedFields = _ref.subscribedFields;
86
+ subscribedFields = _ref.subscribedFields,
87
+ buttonText = _ref.buttonText;
87
88
 
88
89
  var _useContext = (0, _react.useContext)(_locale.LocaleContext),
89
90
  formatMessage = _useContext.formatMessage;
@@ -284,7 +285,7 @@ var Step = function Step(_ref) {
284
285
  className: 'igloo-freeform-step-button',
285
286
  type: "primary",
286
287
  disabled: buttonDisabled,
287
- children: continueText || formatMessage({
288
+ children: buttonText || continueText || formatMessage({
288
289
  id: 'Continue'
289
290
  })
290
291
  }, void 0)
@@ -298,7 +299,7 @@ var Step = function Step(_ref) {
298
299
  className: 'igloo-freeform-step-button',
299
300
  loading: submitting,
300
301
  disabled: buttonDisabled,
301
- children: submitText || formatMessage({
302
+ children: buttonText || submitText || formatMessage({
302
303
  id: 'Submit'
303
304
  })
304
305
  }, void 0)
@@ -187,6 +187,7 @@ var IglooCredit = function IglooCredit(props) {
187
187
  }
188
188
  }
189
189
 
190
+ formOnChange && formOnChange('error type');
190
191
  setFieldError && setFieldError(formatMessage({
191
192
  id: 'Credit card must be {typeNames} or {finalName}',
192
193
  values: getErrorMessage(cardRules)
@@ -194,7 +195,7 @@ var IglooCredit = function IglooCredit(props) {
194
195
  }
195
196
 
196
197
  (0, _react.useEffect)(function () {
197
- if (value) {
198
+ if (value && value !== 'error type') {
198
199
  handleOnChange(value, [].concat(_toConsumableArray(cardConfig), defaultCheck), formChangeProps);
199
200
  }
200
201
  }, [value]);
@@ -229,7 +230,8 @@ function checkCard(value, cardRules) {
229
230
  }
230
231
 
231
232
  IglooCredit.formItemPropsHandler = function (config) {
232
- var cardConfig = config.cardConfig;
233
+ var _config$cardConfig = config.cardConfig,
234
+ cardConfig = _config$cardConfig === void 0 ? [] : _config$cardConfig;
233
235
  return {
234
236
  rules: [{
235
237
  validator: function validator(_, value) {
@@ -116,7 +116,8 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
116
116
  setInput = _useState4[1];
117
117
 
118
118
  (0, _react.useEffect)(function () {
119
- if (!value) return;
119
+ if (!value || typeof value === 'string') return; //=== string 就是value='error type'
120
+
120
121
  setInput(value);
121
122
  inputValueRef.current = value;
122
123
  }, [value.year, value.month]);
@@ -135,6 +136,7 @@ var IglooExpiryDate = function IglooExpiryDate(props) {
135
136
  if (userCheck && compCheck) {
136
137
  onChangeProps && onChangeProps(value);
137
138
  } else {
139
+ onChangeProps && onChangeProps('error type');
138
140
  setFieldError && setFieldError(formatMessage({
139
141
  id: 'Please enter a valid date.'
140
142
  }));
@@ -296,7 +298,12 @@ IglooExpiryDate.formItemPropsHandler = function (config) {
296
298
  validator: function validator(_, value) {
297
299
  return checkTime(value, check);
298
300
  }
299
- }]
301
+ }],
302
+ previewFormater: function previewFormater(_ref2) {
303
+ var year = _ref2.year,
304
+ month = _ref2.month;
305
+ return "".concat(month, "/").concat(year);
306
+ }
300
307
  };
301
308
  };
302
309
 
@@ -122,7 +122,7 @@ var IglooInputDate = function IglooInputDate(props) {
122
122
  formatMessage = _useContext.formatMessage;
123
123
 
124
124
  (0, _react.useEffect)(function () {
125
- if (!value) return;
125
+ if (!value || value === 'error type') return;
126
126
  var init = value.split(delimiter);
127
127
  setInput(init);
128
128
  inputValueRef.current = init;
@@ -136,6 +136,7 @@ var IglooInputDate = function IglooInputDate(props) {
136
136
  if (available) {
137
137
  onChangeProps && onChangeProps(value);
138
138
  } else {
139
+ onChangeProps && onChangeProps('error type');
139
140
  setFieldError && setFieldError(formatMessage({
140
141
  id: 'Please enter a valid date.'
141
142
  }));
@@ -49,8 +49,8 @@ IglooInputNumber.formItemPropsHandler = function (config) {
49
49
  getValueFromEvent: function getValueFromEvent(e) {
50
50
  var value = e.target.value;
51
51
  var str = value.replaceAll(/[^0-9\.]/g, '');
52
- if (value.endsWith('.')) return str;
53
- return str ? parseFloat(str) : str;
52
+ if (value.endsWith('.')) return parseInt(str);
53
+ return str ? parseFloat(str) : undefined;
54
54
  }
55
55
  };
56
56
  };
@@ -1,7 +1,10 @@
1
1
  import { FC, CSSProperties } from 'react';
2
2
  import './style/index.less';
3
3
  declare const PlatformCard: FC<{
4
- platform: string;
4
+ platform: string | {
5
+ name: string;
6
+ key: string;
7
+ };
5
8
  onClick: any;
6
9
  className?: any;
7
10
  style?: CSSProperties;
@@ -44,6 +44,8 @@ var PlatformCard = function PlatformCard(_ref) {
44
44
  showDefault = _useState2[0],
45
45
  setShowDefault = _useState2[1];
46
46
 
47
+ var key = typeof platform === 'string' ? platform : platform.key;
48
+ var name = typeof platform === 'string' ? platform : platform.name;
47
49
  return (0, _jsxRuntime.jsxs)("div", {
48
50
  className: (0, _classnames.default)('igloo-platform', className),
49
51
  onClick: onClick,
@@ -57,12 +59,12 @@ var PlatformCard = function PlatformCard(_ref) {
57
59
  className: "igloo-platform-defaultLogo"
58
60
  }, void 0), (0, _jsxRuntime.jsx)("div", {
59
61
  className: "igloo-platform-name",
60
- children: platform
62
+ children: name
61
63
  }, void 0)]
62
64
  }, void 0), !showDefault && (0, _jsxRuntime.jsx)(_image.default, {
63
65
  width: 200,
64
66
  height: 200,
65
- src: "https://static.iglooinsure.com/partner/normal/".concat(platform.toLowerCase(), ".svg"),
67
+ src: "https://static.iglooinsure.com/partner/normal/".concat(key.toLowerCase(), ".svg"),
66
68
  onError: function onError() {
67
69
  return setShowDefault(true);
68
70
  },
@@ -1,7 +1,10 @@
1
1
  import { FC } from 'react';
2
2
  import './style/index.less';
3
3
  interface Props {
4
- platforms: string[];
4
+ platforms: (string | {
5
+ name: string;
6
+ key: string;
7
+ })[];
5
8
  currentPlatform: string;
6
9
  onChange: (platform: string) => any;
7
10
  }
@@ -65,7 +65,9 @@ var SwitchPlatform = function SwitchPlatform(_ref) {
65
65
  trigger: ['click'],
66
66
  overlay: (0, _jsxRuntime.jsx)(_menu.default, {
67
67
  onClick: handleChange,
68
- children: platforms === null || platforms === void 0 ? void 0 : platforms.map(function (name) {
68
+ children: platforms === null || platforms === void 0 ? void 0 : platforms.map(function (platform) {
69
+ var name = typeof platform === 'string' ? platform : platform.name;
70
+ var key = typeof platform === 'string' ? platform : platform.key;
69
71
  return (0, _jsxRuntime.jsxs)(_menu.default.Item, {
70
72
  className: "igloo-switch-platform-option",
71
73
  children: [(0, _jsxRuntime.jsx)(_image.default, {
@@ -77,7 +79,7 @@ var SwitchPlatform = function SwitchPlatform(_ref) {
77
79
  className: "igloo-switch-platform-name",
78
80
  children: name
79
81
  }, void 0)]
80
- }, name);
82
+ }, key);
81
83
  })
82
84
  }, void 0),
83
85
  getPopupContainer: function getPopupContainer(trigger) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iglooform",
3
- "version": "2.4.20",
3
+ "version": "2.4.24",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "build-dev": "dumi build",