iglooform 2.5.7 → 2.5.8

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 (61) hide show
  1. package/es/confirmation/index.d.ts +2 -2
  2. package/es/confirmation/index.js +37 -2
  3. package/es/form/hstep/index.d.ts +17 -0
  4. package/es/form/hstep/index.js +149 -0
  5. package/es/form/hstep/style/index.d.ts +1 -0
  6. package/es/form/hstep/style/index.js +1 -0
  7. package/es/form/hstep/style/index.less +84 -0
  8. package/es/form/hsteps/index.d.ts +13 -0
  9. package/es/form/hsteps/index.js +384 -0
  10. package/es/form/hsteps/style/index.d.ts +1 -0
  11. package/es/form/hsteps/style/index.js +1 -0
  12. package/es/form/hsteps/style/index.less +72 -0
  13. package/es/form/index.js +31 -40
  14. package/es/form/section/index.d.ts +2 -0
  15. package/es/form/section/index.js +70 -10
  16. package/es/form/section/style/index.less +14 -0
  17. package/es/form/step/index.js +1 -5
  18. package/es/form/steps/index.js +25 -13
  19. package/es/form-step-context.d.ts +6 -0
  20. package/es/form-step-context.js +4 -0
  21. package/es/free-form/index.js +24 -38
  22. package/es/input/input-number.js +2 -2
  23. package/es/locale/en-US/messages.json +9 -0
  24. package/es/locale/id-ID/messages.json +9 -0
  25. package/es/locale/th-TH/messages.json +9 -0
  26. package/es/locale/vi-VN/messages.json +9 -0
  27. package/es/locale/zh-CN/messages.json +9 -0
  28. package/es/locale/zh-TW/messages.json +9 -0
  29. package/es/types.d.ts +13 -1
  30. package/es/utils/form-utils.js +84 -1
  31. package/lib/confirmation/index.d.ts +2 -2
  32. package/lib/confirmation/index.js +37 -1
  33. package/lib/form/hstep/index.d.ts +17 -0
  34. package/lib/form/hstep/index.js +174 -0
  35. package/lib/form/hstep/style/index.d.ts +1 -0
  36. package/lib/form/hstep/style/index.js +3 -0
  37. package/lib/form/hstep/style/index.less +84 -0
  38. package/lib/form/hsteps/index.d.ts +13 -0
  39. package/lib/form/hsteps/index.js +414 -0
  40. package/lib/form/hsteps/style/index.d.ts +1 -0
  41. package/lib/form/hsteps/style/index.js +3 -0
  42. package/lib/form/hsteps/style/index.less +72 -0
  43. package/lib/form/index.js +31 -39
  44. package/lib/form/section/index.d.ts +2 -0
  45. package/lib/form/section/index.js +72 -8
  46. package/lib/form/section/style/index.less +14 -0
  47. package/lib/form/step/index.js +1 -5
  48. package/lib/form/steps/index.js +25 -12
  49. package/lib/form-step-context.d.ts +6 -0
  50. package/lib/form-step-context.js +16 -0
  51. package/lib/free-form/index.js +23 -37
  52. package/lib/input/input-number.js +2 -2
  53. package/lib/locale/en-US/messages.json +9 -0
  54. package/lib/locale/id-ID/messages.json +9 -0
  55. package/lib/locale/th-TH/messages.json +9 -0
  56. package/lib/locale/vi-VN/messages.json +9 -0
  57. package/lib/locale/zh-CN/messages.json +9 -0
  58. package/lib/locale/zh-TW/messages.json +9 -0
  59. package/lib/types.d.ts +13 -1
  60. package/lib/utils/form-utils.js +85 -1
  61. 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,
@@ -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,149 @@
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$current2, _containerRef$current3;
78
+
79
+ if (md || !(shouldScroll && edit)) return;
80
+ var scrollContainer = getScrollContainer() || window;
81
+ (containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.offsetTop) ? scrollContainer.scrollTo({
82
+ top: (containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current2 = containerRef.current) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.offsetTop) - 50,
83
+ behavior: 'smooth'
84
+ }) : containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.scrollIntoView();
85
+ }, [shouldScroll, edit]);
86
+ return _jsxs(_Fragment, {
87
+ children: [_jsxs("div", {
88
+ className: classnames('igloo-hstep-container', {
89
+ 'igloo-hstep-container-preview': preview
90
+ }),
91
+ ref: containerRef,
92
+ children: [_jsxs(Typography, {
93
+ className: "igloo-hstep-label",
94
+ level: "h3a",
95
+ children: [_jsx("span", {
96
+ className: "igloo-hstep-label-text",
97
+ children: label
98
+ }), preview && _jsx(Button, {
99
+ type: "link",
100
+ className: "igloo-hstep-label-edit",
101
+ onClick: handleEdit,
102
+ disabled: disableEditButton,
103
+ children: editButtonLabel || formatMessage({
104
+ id: 'Edit'
105
+ })
106
+ }), edit && !md && _jsxs(Typography, {
107
+ level: "body3",
108
+ children: [index + 1, "/", total]
109
+ })]
110
+ }), (edit || preview) && _jsxs("div", {
111
+ className: 'igloo-hstep-content',
112
+ children: [_jsx(_Row, {
113
+ gutter: [32, preview ? 16 : 24],
114
+ children: elements.map(function (child, index) {
115
+ return _jsx(Element, {
116
+ config: child,
117
+ parentName: calcNamePath(parentName, name),
118
+ setShowStepButton: setShowButton,
119
+ preview: preview
120
+ }, index);
121
+ })
122
+ }), edit && showButton && md && _jsx(Button, {
123
+ onClick: handleNext,
124
+ className: 'igloo-hstep-button',
125
+ type: "primary",
126
+ disabled: buttonDisabled,
127
+ children: buttonText || continueText || formatMessage({
128
+ id: 'Continue'
129
+ })
130
+ })]
131
+ }), !edit && !preview && _jsx(_Divider, {
132
+ className: "igloo-hstep-divider"
133
+ })]
134
+ }), edit && showButton && !md && _jsx("div", {
135
+ className: "igloo-hstep-button-container",
136
+ children: _jsx(Button, {
137
+ onClick: handleNext,
138
+ className: 'igloo-hstep-button',
139
+ type: "primary",
140
+ disabled: buttonDisabled,
141
+ children: buttonText || continueText || formatMessage({
142
+ id: 'Continue'
143
+ })
144
+ })
145
+ })]
146
+ });
147
+ };
148
+
149
+ export default Step;
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1,84 @@
1
+ .igloo-hstep-container {
2
+ width: 100%;
3
+ background: #ffffff;
4
+ padding: 32px;
5
+ margin-top: 16px;
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
+
51
+ .igloo-hstep-content {
52
+ margin-top: 24px;
53
+ }
54
+
55
+ .igloo-hstep-divider {
56
+ margin-top: 8px;
57
+ width: auto;
58
+ min-width: auto;
59
+ margin-left: 16px;
60
+ margin-right: 16px;
61
+ }
62
+
63
+ .igloo-hstep-label {
64
+ margin-bottom: 8px;
65
+ font-size: 16px;
66
+ line-height: 24px;
67
+ }
68
+ }
69
+
70
+ .igloo-hstep-button-container {
71
+ width: 100%;
72
+ position: sticky;
73
+ bottom: 0;
74
+ box-shadow: 0px 0px 1px rgba(20, 20, 20, 0.04),
75
+ 0px 1px 8px 2px rgba(20, 20, 20, 0.08);
76
+
77
+ padding: 24px 16px;
78
+ background: #ffffff;
79
+
80
+ .igloo-hstep-button {
81
+ width: 100%;
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,13 @@
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
+ parentName?: FormItemName;
8
+ name?: FormItemName;
9
+ withReview?: boolean;
10
+ confirmation?: ConfirmationProps;
11
+ }
12
+ declare const HSteps: FC<HStepsProps>;
13
+ export default HSteps;