iglooform 2.5.7 → 2.5.10

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 (75) hide show
  1. package/es/confirmation/index.d.ts +2 -2
  2. package/es/confirmation/index.js +37 -2
  3. package/es/form/element/index.js +22 -21
  4. package/es/form/hstep/index.d.ts +17 -0
  5. package/es/form/hstep/index.js +158 -0
  6. package/es/form/hstep/style/index.d.ts +1 -0
  7. package/es/form/hstep/style/index.js +1 -0
  8. package/es/form/hstep/style/index.less +79 -0
  9. package/es/form/hsteps/index.d.ts +19 -0
  10. package/es/form/hsteps/index.js +418 -0
  11. package/es/form/hsteps/style/index.d.ts +1 -0
  12. package/es/form/hsteps/style/index.js +1 -0
  13. package/es/form/hsteps/style/index.less +100 -0
  14. package/es/form/index.js +31 -40
  15. package/es/form/pages/index.js +2 -2
  16. package/es/form/section/index.d.ts +2 -0
  17. package/es/form/section/index.js +70 -10
  18. package/es/form/section/style/index.less +18 -0
  19. package/es/form/step/index.js +15 -10
  20. package/es/form/steps/index.js +27 -15
  21. package/es/form-step-context.d.ts +6 -0
  22. package/es/form-step-context.js +4 -0
  23. package/es/free-form/index.js +24 -38
  24. package/es/input/input-number.js +87 -3
  25. package/es/input/phone-number.js +80 -20
  26. package/es/locale/en-US/messages.json +13 -0
  27. package/es/locale/format-message.js +2 -2
  28. package/es/locale/id-ID/messages.json +13 -0
  29. package/es/locale/locale-provider.js +2 -2
  30. package/es/locale/th-TH/messages.json +13 -0
  31. package/es/locale/vi-VN/messages.json +13 -0
  32. package/es/locale/zh-CN/messages.json +13 -0
  33. package/es/locale/zh-TW/messages.json +13 -0
  34. package/es/types.d.ts +17 -1
  35. package/es/upload/style/index.less +2 -0
  36. package/es/upload-photo/index.js +10 -4
  37. package/es/utils/form-utils.js +84 -1
  38. package/lib/confirmation/index.d.ts +2 -2
  39. package/lib/confirmation/index.js +37 -1
  40. package/lib/form/element/index.js +22 -21
  41. package/lib/form/hstep/index.d.ts +17 -0
  42. package/lib/form/hstep/index.js +183 -0
  43. package/lib/form/hstep/style/index.d.ts +1 -0
  44. package/lib/form/hstep/style/index.js +3 -0
  45. package/lib/form/hstep/style/index.less +79 -0
  46. package/lib/form/hsteps/index.d.ts +19 -0
  47. package/lib/form/hsteps/index.js +448 -0
  48. package/lib/form/hsteps/style/index.d.ts +1 -0
  49. package/lib/form/hsteps/style/index.js +3 -0
  50. package/lib/form/hsteps/style/index.less +100 -0
  51. package/lib/form/index.js +31 -39
  52. package/lib/form/pages/index.js +2 -2
  53. package/lib/form/section/index.d.ts +2 -0
  54. package/lib/form/section/index.js +72 -8
  55. package/lib/form/section/style/index.less +18 -0
  56. package/lib/form/step/index.js +15 -10
  57. package/lib/form/steps/index.js +27 -14
  58. package/lib/form-step-context.d.ts +6 -0
  59. package/lib/form-step-context.js +16 -0
  60. package/lib/free-form/index.js +23 -37
  61. package/lib/input/input-number.js +88 -3
  62. package/lib/input/phone-number.js +78 -18
  63. package/lib/locale/en-US/messages.json +13 -0
  64. package/lib/locale/format-message.js +2 -2
  65. package/lib/locale/id-ID/messages.json +13 -0
  66. package/lib/locale/locale-provider.js +2 -2
  67. package/lib/locale/th-TH/messages.json +13 -0
  68. package/lib/locale/vi-VN/messages.json +13 -0
  69. package/lib/locale/zh-CN/messages.json +13 -0
  70. package/lib/locale/zh-TW/messages.json +13 -0
  71. package/lib/types.d.ts +17 -1
  72. package/lib/upload/style/index.less +2 -0
  73. package/lib/upload-photo/index.js +10 -4
  74. package/lib/utils/form-utils.js +85 -1
  75. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { FC } from '../types';
3
- interface ConfirmationProps {
3
+ export interface ConfirmationProps {
4
4
  onChange?: Function;
5
5
  value?: boolean;
6
- message: ReactNode;
6
+ message?: ReactNode;
7
7
  modalContent?: ReactNode;
8
8
  modalTitle?: ReactNode;
9
9
  okText?: ReactNode;
@@ -10,11 +10,12 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState, useContext } from 'react';
15
15
  import Modal from '../modal';
16
16
  import Typography from '../typography';
17
17
  import Checkbox from '../checkbox';
18
+ import Button from '../button';
18
19
  import LocaleContext from '../locale/locale-context';
19
20
 
20
21
  var Confirmation = function Confirmation(_ref) {
@@ -86,7 +87,41 @@ var Confirmation = function Confirmation(_ref) {
86
87
  cursor: 'pointer',
87
88
  marginLeft: 8
88
89
  },
89
- children: message
90
+ children: message || _jsxs(_Fragment, {
91
+ children: [formatMessage({
92
+ id: 'I agree to the Igloo'
93
+ }), _jsx(Button, {
94
+ type: "link",
95
+ href: "https://contents.iglooinsure.com/termsofservice",
96
+ target: '_blank',
97
+ style: {
98
+ margin: '0 4px',
99
+ lineHeight: 'inherit'
100
+ },
101
+ onClick: function onClick(e) {
102
+ return e.stopPropagation();
103
+ },
104
+ children: formatMessage({
105
+ id: 'Terms of Use'
106
+ })
107
+ }), formatMessage({
108
+ id: 'and'
109
+ }), _jsx(Button, {
110
+ type: "link",
111
+ href: "https://contents.iglooinsure.com/privacypolicy",
112
+ style: {
113
+ margin: '0 4px',
114
+ lineHeight: 'inherit'
115
+ },
116
+ target: '_blank',
117
+ onClick: function onClick(e) {
118
+ return e.stopPropagation();
119
+ },
120
+ children: formatMessage({
121
+ id: 'Privacy Policy'
122
+ })
123
+ })]
124
+ })
90
125
  }), modalContent && _jsx(Modal, {
91
126
  title: modalTitle,
92
127
  visible: visible,
@@ -151,26 +151,6 @@ var Element = function Element(_ref) {
151
151
  var _useBreakpoint = useBreakpoint(),
152
152
  md = _useBreakpoint.md;
153
153
 
154
- if (type === 'Section') {
155
- return _jsx(Section, {
156
- parentName: parentName,
157
- config: config,
158
- preview: preview,
159
- disabled: disabled,
160
- setShowStepButton: setShowStepButton
161
- });
162
- }
163
-
164
- if (type === 'AddableSection') {
165
- return _jsx(AddableSection, {
166
- parentName: parentName,
167
- config: config,
168
- preview: preview,
169
- disabled: disabled,
170
- setShowStepButton: setShowStepButton
171
- });
172
- }
173
-
174
154
  var _calcFormItemProps = calcFormItemProps(config, _objectSpread(_objectSpread({}, extraConfig), {}, {
175
155
  requiredMark: requiredMark
176
156
  }), form, parentName),
@@ -235,7 +215,28 @@ var Element = function Element(_ref) {
235
215
  name: formItemProps.name,
236
216
  value: formItemProps.initialValue
237
217
  }]);
238
- }, [formItemProps.initialValue]); //这里要想一下有没有更优雅的实现方式
218
+ }, [formItemProps.initialValue]);
219
+
220
+ if (type === 'Section') {
221
+ return _jsx(Section, {
222
+ parentName: parentName,
223
+ config: config,
224
+ preview: preview,
225
+ disabled: disabled,
226
+ setShowStepButton: setShowStepButton
227
+ });
228
+ }
229
+
230
+ if (type === 'AddableSection') {
231
+ return _jsx(AddableSection, {
232
+ parentName: parentName,
233
+ config: config,
234
+ preview: preview,
235
+ disabled: disabled,
236
+ setShowStepButton: setShowStepButton
237
+ });
238
+ } //这里要想一下有没有更优雅的实现方式
239
+
239
240
 
240
241
  if (withoutForm) {
241
242
  var hideWhenPreview = elementProps.hideWhenPreview,
@@ -0,0 +1,17 @@
1
+ import { FC } from 'react';
2
+ import { FormItemConfig, FormItemName } from '../../types';
3
+ import './style/index.less';
4
+ export interface StepProps {
5
+ parentName?: FormItemName;
6
+ config: FormItemConfig;
7
+ edit: boolean;
8
+ preview: boolean;
9
+ index: number;
10
+ total: number;
11
+ handleNext(): void;
12
+ handleEdit(index: number): void;
13
+ showLastIndex?: boolean;
14
+ shouldScroll: boolean;
15
+ }
16
+ declare const Step: FC<StepProps>;
17
+ export default Step;
@@ -0,0 +1,158 @@
1
+ import "antd/es/divider/style";
2
+ import _Divider from "antd/es/divider";
3
+ import "antd/es/row/style";
4
+ import _Row from "antd/es/row";
5
+ import "antd/es/grid/style";
6
+ import _Grid from "antd/es/grid";
7
+
8
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
+
10
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+
14
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
15
+
16
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
17
+
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
19
+
20
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
21
+ import { useContext, useState, useRef, useEffect } from 'react';
22
+ import { LocaleContext } from '../../locale';
23
+ import Button from '../../button';
24
+ import Element from '../element';
25
+ import { calcNamePath } from '../../utils/form-utils';
26
+ import FormContext from '../../form-context';
27
+ import Typography from '../../typography';
28
+ import classnames from 'classnames';
29
+ import './style/index.less';
30
+ var useBreakpoint = _Grid.useBreakpoint;
31
+
32
+ var Step = function Step(_ref) {
33
+ var parentName = _ref.parentName,
34
+ _ref$config = _ref.config,
35
+ _ref$config$elements = _ref$config.elements,
36
+ elements = _ref$config$elements === void 0 ? [] : _ref$config$elements,
37
+ name = _ref$config.name,
38
+ label = _ref$config.label,
39
+ editButtonLabel = _ref$config.editButtonLabel,
40
+ getButtonDisabledState = _ref$config.getButtonDisabledState,
41
+ disableEditButton = _ref$config.disableEditButton,
42
+ buttonText = _ref$config.buttonText,
43
+ edit = _ref.edit,
44
+ preview = _ref.preview,
45
+ index = _ref.index,
46
+ total = _ref.total,
47
+ handleNext = _ref.handleNext,
48
+ handleEditProp = _ref.handleEdit,
49
+ showLastIndex = _ref.showLastIndex,
50
+ shouldScroll = _ref.shouldScroll;
51
+
52
+ var _useContext = useContext(LocaleContext),
53
+ formatMessage = _useContext.formatMessage;
54
+
55
+ var _useContext2 = useContext(FormContext),
56
+ continueText = _useContext2.continueText,
57
+ form = _useContext2.form,
58
+ getScrollContainer = _useContext2.getScrollContainer;
59
+
60
+ var _useState = useState(true),
61
+ _useState2 = _slicedToArray(_useState, 2),
62
+ showButton = _useState2[0],
63
+ setShowButton = _useState2[1];
64
+
65
+ var containerRef = useRef(null);
66
+
67
+ var handleEdit = function handleEdit() {
68
+ return handleEditProp(index);
69
+ };
70
+
71
+ var buttonDisabled = getButtonDisabledState && form && getButtonDisabledState(form);
72
+
73
+ var _useBreakpoint = useBreakpoint(),
74
+ md = _useBreakpoint.md;
75
+
76
+ useEffect(function () {
77
+ var _containerRef$current, _containerRef$current4;
78
+
79
+ if (md || !(shouldScroll && edit)) return;
80
+ var scrollContainer = getScrollContainer() || window;
81
+ if (typeof scrollContainer.scrollTo !== 'function') return;
82
+
83
+ if (containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetTop) {
84
+ var _containerRef$current2, _containerRef$current3;
85
+
86
+ scrollContainer.scrollTo.length === 2 ? scrollContainer.scrollTo(0, (containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.offsetTop) - 50) : scrollContainer.scrollTo({
87
+ top: (containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.offsetTop) - 50,
88
+ behavior: 'smooth'
89
+ });
90
+ return;
91
+ }
92
+
93
+ containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.scrollIntoView();
94
+ }, [shouldScroll, edit]);
95
+ return _jsxs(_Fragment, {
96
+ children: [_jsxs("div", {
97
+ className: classnames('igloo-hstep-container', {
98
+ 'igloo-hstep-container-preview': preview
99
+ }),
100
+ ref: containerRef,
101
+ children: [_jsxs(Typography, {
102
+ className: "igloo-hstep-label",
103
+ level: "h3a",
104
+ children: [_jsx("span", {
105
+ className: "igloo-hstep-label-text",
106
+ children: label
107
+ }), preview && _jsx(Button, {
108
+ type: "link",
109
+ className: "igloo-hstep-label-edit",
110
+ onClick: handleEdit,
111
+ disabled: disableEditButton,
112
+ children: editButtonLabel || formatMessage({
113
+ id: 'Edit'
114
+ })
115
+ }), edit && !md && _jsxs(Typography, {
116
+ level: "body3",
117
+ children: [index + 1, "/", total]
118
+ })]
119
+ }), (edit || preview) && _jsxs("div", {
120
+ className: 'igloo-hstep-content',
121
+ children: [_jsx(_Row, {
122
+ gutter: [32, preview ? 16 : 24],
123
+ children: elements.map(function (child, index) {
124
+ return _jsx(Element, {
125
+ config: child,
126
+ parentName: calcNamePath(parentName, name),
127
+ setShowStepButton: setShowButton,
128
+ preview: preview
129
+ }, index);
130
+ })
131
+ }), edit && showButton && md && _jsx(Button, {
132
+ onClick: handleNext,
133
+ className: 'igloo-hstep-button',
134
+ type: "primary",
135
+ disabled: buttonDisabled,
136
+ children: buttonText || continueText || formatMessage({
137
+ id: 'Continue'
138
+ })
139
+ })]
140
+ }), !edit && !preview && _jsx(_Divider, {
141
+ className: "igloo-hstep-divider"
142
+ })]
143
+ }), edit && showButton && !md && _jsx("div", {
144
+ className: "igloo-hstep-button-container",
145
+ children: _jsx(Button, {
146
+ onClick: handleNext,
147
+ className: 'igloo-hstep-button',
148
+ type: "primary",
149
+ disabled: buttonDisabled,
150
+ children: buttonText || continueText || formatMessage({
151
+ id: 'Continue'
152
+ })
153
+ })
154
+ })]
155
+ });
156
+ };
157
+
158
+ export default Step;
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,79 @@
1
+ .igloo-hstep-container {
2
+ width: 100%;
3
+ background: #ffffff;
4
+ padding: 32px;
5
+ margin-top: 32px;
6
+
7
+ .igloo-hstep-label {
8
+ display: flex;
9
+ justify-content: space-between;
10
+ align-items: center;
11
+ font-size: 20px;
12
+ line-height: 28px;
13
+ margin-bottom: 16px;
14
+
15
+ .igloo-hstep-label-edit {
16
+ font-size: 16px;
17
+ color: @primary-color;
18
+ cursor: pointer;
19
+ font-weight: 500;
20
+ }
21
+
22
+ .igloo-hstep-label-text {
23
+ color: #212121;
24
+ }
25
+ }
26
+
27
+ .igloo-hstep-content {
28
+ width: 100%;
29
+
30
+ .igloo-hstep-button {
31
+ min-width: 221px;
32
+ margin-top: 32px;
33
+ }
34
+ }
35
+
36
+ .igloo-hstep-divider {
37
+ margin-top: 16px;
38
+ border-color: #bdbdbd;
39
+ }
40
+ }
41
+
42
+ @media screen and (max-width: 768px) {
43
+ .igloo-hstep-container-preview {
44
+ background: #f9f9f9;
45
+ }
46
+
47
+ .igloo-hstep-container {
48
+ width: 100%;
49
+ padding: 24px 16px;
50
+ margin-top: 0;
51
+
52
+ .igloo-hstep-content {
53
+ margin-top: 24px;
54
+ }
55
+
56
+ .igloo-hstep-divider {
57
+ margin-top: 8px;
58
+ width: auto;
59
+ min-width: auto;
60
+ margin-left: 16px;
61
+ margin-right: 16px;
62
+ }
63
+ }
64
+
65
+ .igloo-hstep-button-container {
66
+ width: 100%;
67
+ position: sticky;
68
+ bottom: 0;
69
+ box-shadow: 0px 0px 1px rgba(20, 20, 20, 0.04),
70
+ 0px 1px 8px 2px rgba(20, 20, 20, 0.08);
71
+
72
+ padding: 24px 16px;
73
+ background: #ffffff;
74
+
75
+ .igloo-hstep-button {
76
+ width: 100%;
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,19 @@
1
+ import { FC } from 'react';
2
+ import { FormItemConfig, FormItemName } from '../../types';
3
+ import './style/index.less';
4
+ import { ConfirmationProps } from '../../confirmation';
5
+ export interface HStepsProps {
6
+ config: FormItemConfig & {
7
+ confirmations?: {
8
+ [key: string]: {
9
+ required: boolean;
10
+ confirmation?: ConfirmationProps;
11
+ };
12
+ };
13
+ withReview?: boolean;
14
+ };
15
+ parentName?: FormItemName;
16
+ name?: FormItemName;
17
+ }
18
+ declare const HSteps: FC<HStepsProps>;
19
+ export default HSteps;