iglooform 3.1.5 → 3.2.0
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/.dumi/tmp/dumi/theme/ContextWrapper.tsx +1 -1
- package/es/config-provider.d.ts +13 -0
- package/es/config-provider.js +28 -0
- package/es/form/addable-section/index.js +18 -7
- package/es/form/element/index.d.ts +12 -0
- package/es/form/element/index.js +3 -2
- package/es/form/hsteps/index.js +4 -3
- package/es/form/steps/index.js +3 -2
- package/es/free-form/addable-section/index.js +33 -10
- package/es/free-form/element/index.js +4 -2
- package/es/free-form/step/index.js +1 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -1
- package/es/input/amount.js +3 -1
- package/es/locale/locale-provider.d.ts +3 -0
- package/es/locale/locale-provider.js +6 -4
- package/es/media/file-icon.d.ts +9 -0
- package/es/media/preview.js +6 -2
- package/es/modal/index.js +5 -4
- package/es/select/attached-select.d.ts +17 -0
- package/es/types.d.ts +1 -0
- package/es/upload/index.js +16 -15
- package/es/upload-photo/index.js +6 -5
- package/es/upload-preview/media.js +8 -4
- package/es/utils/form-utils.d.ts +3 -2
- package/es/utils/form-utils.js +84 -16
- package/lib/config-provider.d.ts +13 -0
- package/lib/config-provider.js +37 -0
- package/lib/form/addable-section/index.js +18 -7
- package/lib/form/element/index.d.ts +12 -0
- package/lib/form/element/index.js +3 -2
- package/lib/form/hsteps/index.js +4 -3
- package/lib/form/steps/index.js +3 -2
- package/lib/free-form/addable-section/index.js +32 -9
- package/lib/free-form/element/index.js +4 -2
- package/lib/free-form/step/index.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +7 -0
- package/lib/input/amount.js +3 -1
- package/lib/locale/locale-provider.d.ts +3 -0
- package/lib/locale/locale-provider.js +6 -4
- package/lib/media/file-icon.d.ts +9 -0
- package/lib/media/preview.js +6 -2
- package/lib/modal/index.js +5 -4
- package/lib/select/attached-select.d.ts +17 -0
- package/lib/types.d.ts +1 -0
- package/lib/upload/index.js +16 -15
- package/lib/upload-photo/index.js +6 -5
- package/lib/upload-preview/media.js +8 -4
- package/lib/utils/form-utils.d.ts +3 -2
- package/lib/utils/form-utils.js +86 -17
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ export default function DumiContextWrapper() {
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<SiteContext.Provider value={{
|
|
33
|
-
pkg: {"name":"iglooform","version":"3.1.
|
|
33
|
+
pkg: {"name":"iglooform","version":"3.1.6","license":"MIT"},
|
|
34
34
|
historyType: "browser",
|
|
35
35
|
entryExports,
|
|
36
36
|
demos,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ConfigProvider as AntdConfigProvider } from 'antd';
|
|
3
|
+
import { ConfigProviderProps } from 'antd/es/config-provider';
|
|
4
|
+
export interface ConfigProviderContextType {
|
|
5
|
+
configProvider: typeof AntdConfigProvider;
|
|
6
|
+
}
|
|
7
|
+
export declare let staticAntdConfig: ConfigProviderProps;
|
|
8
|
+
declare const ConfigProvider: FC<{
|
|
9
|
+
currentLang: string;
|
|
10
|
+
config?: ConfigProviderProps;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}>;
|
|
13
|
+
export default ConfigProvider;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
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; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { useEffect } from 'react';
|
|
8
|
+
import { ConfigProvider as AntdConfigProvider } from 'antd';
|
|
9
|
+
import LocalProvider from "./locale/locale-provider";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export var staticAntdConfig;
|
|
12
|
+
var ConfigProvider = function ConfigProvider(_ref) {
|
|
13
|
+
var currentLang = _ref.currentLang,
|
|
14
|
+
_ref$config = _ref.config,
|
|
15
|
+
config = _ref$config === void 0 ? {} : _ref$config,
|
|
16
|
+
children = _ref.children;
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
staticAntdConfig = config;
|
|
19
|
+
}, [config]);
|
|
20
|
+
return /*#__PURE__*/_jsx(AntdConfigProvider, _objectSpread(_objectSpread({}, config), {}, {
|
|
21
|
+
children: /*#__PURE__*/_jsx(LocalProvider, {
|
|
22
|
+
currentLang: currentLang,
|
|
23
|
+
underConfigProvider: true,
|
|
24
|
+
children: children
|
|
25
|
+
})
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
export default ConfigProvider;
|
|
@@ -18,7 +18,7 @@ import React, { useReducer, useContext, useCallback } from 'react';
|
|
|
18
18
|
import { Col, Divider, Row, Grid } from 'antd';
|
|
19
19
|
import Element from "../element";
|
|
20
20
|
import FormContext from "../../form-context";
|
|
21
|
-
import { calcNamePath, calcFormItemProps } from "../../utils/form-utils";
|
|
21
|
+
import { calcNamePath, calcFormItemProps, calcAddableSectionAssertField } from "../../utils/form-utils";
|
|
22
22
|
import Typography from "../../typography";
|
|
23
23
|
import Button from "../../button";
|
|
24
24
|
import { LocaleContext } from "../../locale";
|
|
@@ -153,25 +153,36 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
153
153
|
},
|
|
154
154
|
children: /*#__PURE__*/_jsx(Row, {
|
|
155
155
|
gutter: [32, preview ? 16 : 24],
|
|
156
|
-
children: elements.map(function (child,
|
|
156
|
+
children: elements.map(function (child, _index) {
|
|
157
157
|
var _child = _objectSpread({}, child);
|
|
158
158
|
if (Array.isArray(child.asserts)) {
|
|
159
159
|
_child.asserts = child.asserts.map(function (assert) {
|
|
160
160
|
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
161
|
-
field:
|
|
161
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, elements)
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
if (Array.isArray(child.requiredAsserts)) {
|
|
166
166
|
_child.requiredAsserts = child.requiredAsserts.map(function (assert) {
|
|
167
167
|
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
168
|
-
field:
|
|
168
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, elements)
|
|
169
169
|
});
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
+
if (Array.isArray(child.disabled)) {
|
|
173
|
+
_child.disabled = child.disabled.map(function (assert) {
|
|
174
|
+
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
175
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, elements)
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
} else if (_typeof(child.disabled) === 'object') {
|
|
179
|
+
_child.disabled = _objectSpread(_objectSpread({}, child.disabled), {}, {
|
|
180
|
+
field: calcAddableSectionAssertField(namePath, child.disabled.field, index, elements)
|
|
181
|
+
});
|
|
182
|
+
}
|
|
172
183
|
if (Array.isArray(child.dependencies)) {
|
|
173
184
|
_child.dependencies = child.dependencies.map(function (path) {
|
|
174
|
-
return
|
|
185
|
+
return calcAddableSectionAssertField(namePath, path, index, elements);
|
|
175
186
|
});
|
|
176
187
|
}
|
|
177
188
|
return /*#__PURE__*/_jsx(Element, {
|
|
@@ -180,11 +191,11 @@ var AddableSection = function AddableSection(_ref) {
|
|
|
180
191
|
disabled: elementProps.disabled || disabled,
|
|
181
192
|
preview: preview,
|
|
182
193
|
setShowStepButton: setShowStepButton
|
|
183
|
-
},
|
|
194
|
+
}, _index);
|
|
184
195
|
})
|
|
185
196
|
})
|
|
186
197
|
}))]
|
|
187
|
-
}, key);
|
|
198
|
+
}, key + index);
|
|
188
199
|
});
|
|
189
200
|
return /*#__PURE__*/_jsxs("div", {
|
|
190
201
|
className: "igloo-form-addable-section-container",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FormItemConfig, FormItemName } from '../../types';
|
|
3
|
+
import './style';
|
|
4
|
+
interface ElementProps {
|
|
5
|
+
config: FormItemConfig;
|
|
6
|
+
parentName?: FormItemName;
|
|
7
|
+
preview?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
setShowStepButton?: (showButton: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const Element: FC<ElementProps>;
|
|
12
|
+
export default Element;
|
package/es/form/element/index.js
CHANGED
|
@@ -68,7 +68,8 @@ var Element = function Element(_ref) {
|
|
|
68
68
|
disabled = config.disabled,
|
|
69
69
|
extraLabel = config.extraLabel,
|
|
70
70
|
requiredAsserts = config.requiredAsserts,
|
|
71
|
-
shouldRenderCode = config.shouldRenderCode
|
|
71
|
+
shouldRenderCode = config.shouldRenderCode,
|
|
72
|
+
disabledCode = config.disabledCode;
|
|
72
73
|
var dependentField = dependencies || [];
|
|
73
74
|
if (Array.isArray(subscribedFields)) {
|
|
74
75
|
dependentField.push.apply(dependentField, _toConsumableArray(subscribedFields));
|
|
@@ -94,7 +95,7 @@ var Element = function Element(_ref) {
|
|
|
94
95
|
return dependentField.push(assert.field);
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
|
-
if ((shouldRender || shouldRenderCode || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
|
|
98
|
+
if ((shouldRender || shouldRenderCode || disabledCode || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
|
|
98
99
|
dependentField.push('SUBSCRIBE_ALL');
|
|
99
100
|
}
|
|
100
101
|
if (dependField) {
|
package/es/form/hsteps/index.js
CHANGED
|
@@ -76,6 +76,7 @@ var HSteps = function HSteps(_ref) {
|
|
|
76
76
|
var _useContext2 = useContext(LocaleContext),
|
|
77
77
|
formatMessage = _useContext2.formatMessage,
|
|
78
78
|
currentLang = _useContext2.currentLang;
|
|
79
|
+
var _parentName = calcNamePath(parentName, name);
|
|
79
80
|
useEffect(function () {
|
|
80
81
|
var subscribe = elements.some(function (_ref2) {
|
|
81
82
|
var shouldRender = _ref2.shouldRender,
|
|
@@ -111,7 +112,7 @@ var HSteps = function HSteps(_ref) {
|
|
|
111
112
|
shouldRenderCode = _ref5.shouldRenderCode;
|
|
112
113
|
invariant(type === 'Step', 'Child of steps should be Step');
|
|
113
114
|
invariant(!validationRule || getRuleValidationApi, 'Please provide getRuleValidationApi in Form props');
|
|
114
|
-
return calcShouldRender(calcNamePath(
|
|
115
|
+
return calcShouldRender(calcNamePath(_parentName, curName), _parentName, dependencies, asserts, shouldRender, shouldRenderCode, form);
|
|
115
116
|
});
|
|
116
117
|
var handleNext = /*#__PURE__*/function () {
|
|
117
118
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -270,7 +271,7 @@ var HSteps = function HSteps(_ref) {
|
|
|
270
271
|
},
|
|
271
272
|
children: /*#__PURE__*/_jsx(HStep, {
|
|
272
273
|
config: renderElements[current],
|
|
273
|
-
parentName:
|
|
274
|
+
parentName: _parentName,
|
|
274
275
|
index: current,
|
|
275
276
|
total: withReview ? renderElements.length + 1 : renderElements.length,
|
|
276
277
|
preview: false,
|
|
@@ -300,7 +301,7 @@ var HSteps = function HSteps(_ref) {
|
|
|
300
301
|
}), renderElements.map(function (step, index) {
|
|
301
302
|
return /*#__PURE__*/_jsx(HStep, {
|
|
302
303
|
config: step,
|
|
303
|
-
parentName:
|
|
304
|
+
parentName: _parentName,
|
|
304
305
|
index: index,
|
|
305
306
|
total: withReview ? renderElements.length + 1 : renderElements.length,
|
|
306
307
|
preview: true,
|
package/es/form/steps/index.js
CHANGED
|
@@ -53,6 +53,7 @@ var Steps = function Steps(_ref) {
|
|
|
53
53
|
registerDependencies = _useContext.registerDependencies;
|
|
54
54
|
var _useContext2 = useContext(LocaleContext),
|
|
55
55
|
currentLang = _useContext2.currentLang;
|
|
56
|
+
var _parentName = calcNamePath(parentName, name);
|
|
56
57
|
useEffect(function () {
|
|
57
58
|
var subscribe = elements.some(function (_ref2) {
|
|
58
59
|
var shouldRender = _ref2.shouldRender,
|
|
@@ -84,7 +85,7 @@ var Steps = function Steps(_ref) {
|
|
|
84
85
|
asserts = _ref5.asserts,
|
|
85
86
|
shouldRender = _ref5.shouldRender,
|
|
86
87
|
shouldRenderCode = _ref5.shouldRenderCode;
|
|
87
|
-
return calcShouldRender(calcNamePath(
|
|
88
|
+
return calcShouldRender(calcNamePath(_parentName, curName), _parentName, dependencies, asserts, shouldRender, shouldRenderCode, form);
|
|
88
89
|
});
|
|
89
90
|
var handleNext = /*#__PURE__*/function () {
|
|
90
91
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -197,7 +198,7 @@ var Steps = function Steps(_ref) {
|
|
|
197
198
|
},
|
|
198
199
|
children: /*#__PURE__*/_jsx(Step, {
|
|
199
200
|
config: child,
|
|
200
|
-
parentName:
|
|
201
|
+
parentName: _parentName,
|
|
201
202
|
index: index,
|
|
202
203
|
total: renderElements.length,
|
|
203
204
|
preview: current > index,
|
|
@@ -17,7 +17,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
17
17
|
import React, { useReducer, useContext, useEffect, useCallback, cloneElement, isValidElement } from 'react';
|
|
18
18
|
import { Col, Row } from 'antd';
|
|
19
19
|
import FormContext from "../../form-context";
|
|
20
|
-
import { calcNamePath, calcFormItemProps } from "../../utils/form-utils";
|
|
20
|
+
import { calcNamePath, calcFormItemProps, calcAddableSectionAssertField } from "../../utils/form-utils";
|
|
21
21
|
import Typography from "../../typography";
|
|
22
22
|
import Button from "../../button";
|
|
23
23
|
import { LocaleContext } from "../../locale";
|
|
@@ -156,32 +156,44 @@ var AddableSection = function AddableSection(props) {
|
|
|
156
156
|
}]);
|
|
157
157
|
}
|
|
158
158
|
var transformChildren = function transformChildren(parentName) {
|
|
159
|
+
var index = parentName[parentName.length - 1];
|
|
159
160
|
if (Array.isArray(children)) {
|
|
160
|
-
return children.map(function (c,
|
|
161
|
+
return children.map(function (c, _index) {
|
|
161
162
|
var _c$type;
|
|
162
163
|
var _child = _objectSpread({}, c.props);
|
|
163
164
|
if (Array.isArray(_child.asserts)) {
|
|
164
165
|
_child.asserts = _child.asserts.map(function (assert) {
|
|
165
166
|
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
166
|
-
field:
|
|
167
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, children)
|
|
167
168
|
});
|
|
168
169
|
});
|
|
169
170
|
}
|
|
170
171
|
if (Array.isArray(_child.requiredAsserts)) {
|
|
171
172
|
_child.requiredAsserts = _child.requiredAsserts.map(function (assert) {
|
|
172
173
|
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
173
|
-
field:
|
|
174
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, children)
|
|
174
175
|
});
|
|
175
176
|
});
|
|
176
177
|
}
|
|
178
|
+
if (Array.isArray(_child.disabled)) {
|
|
179
|
+
_child.disabled = _child.disabled.map(function (assert) {
|
|
180
|
+
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
181
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, children)
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
} else if (_typeof(_child.disabled) === 'object') {
|
|
185
|
+
_child.disabled = _objectSpread(_objectSpread({}, _child.disabled), {}, {
|
|
186
|
+
field: calcAddableSectionAssertField(namePath, _child.disabled.field, index, children)
|
|
187
|
+
});
|
|
188
|
+
}
|
|
177
189
|
if (Array.isArray(_child.dependencies)) {
|
|
178
190
|
_child.dependencies = _child.dependencies.map(function (path) {
|
|
179
|
-
return
|
|
191
|
+
return calcAddableSectionAssertField(namePath, path, index, children);
|
|
180
192
|
});
|
|
181
193
|
}
|
|
182
194
|
if (['Igloo_Free_Form_Item', 'Igloo_Free_Form_Section', 'Igloo_Free_Form_AddableSection'].includes(c === null || c === void 0 ? void 0 : (_c$type = c.type) === null || _c$type === void 0 ? void 0 : _c$type.displayName)) {
|
|
183
195
|
return /*#__PURE__*/cloneElement(c, _objectSpread(_objectSpread({
|
|
184
|
-
key:
|
|
196
|
+
key: _index
|
|
185
197
|
}, _child), {}, {
|
|
186
198
|
parentName: parentName,
|
|
187
199
|
setShowStepButton: setShowStepButton,
|
|
@@ -197,20 +209,31 @@ var AddableSection = function AddableSection(props) {
|
|
|
197
209
|
if (Array.isArray(_child.asserts)) {
|
|
198
210
|
_child.asserts = _child.asserts.map(function (assert) {
|
|
199
211
|
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
200
|
-
field:
|
|
212
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, [children])
|
|
201
213
|
});
|
|
202
214
|
});
|
|
203
215
|
}
|
|
204
216
|
if (Array.isArray(_child.requiredAsserts)) {
|
|
205
217
|
_child.requiredAsserts = _child.requiredAsserts.map(function (assert) {
|
|
206
218
|
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
207
|
-
field:
|
|
219
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, [children])
|
|
208
220
|
});
|
|
209
221
|
});
|
|
210
222
|
}
|
|
223
|
+
if (Array.isArray(_child.disabled)) {
|
|
224
|
+
_child.disabled = _child.disabled.map(function (assert) {
|
|
225
|
+
return _objectSpread(_objectSpread({}, assert), {}, {
|
|
226
|
+
field: calcAddableSectionAssertField(namePath, assert.field, index, [children])
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
} else if (_typeof(_child.disabled) === 'object') {
|
|
230
|
+
_child.disabled = _objectSpread(_objectSpread({}, _child.disabled), {}, {
|
|
231
|
+
field: calcAddableSectionAssertField(namePath, _child.disabled.field, index, [children])
|
|
232
|
+
});
|
|
233
|
+
}
|
|
211
234
|
if (Array.isArray(_child.dependencies)) {
|
|
212
235
|
_child.dependencies = _child.dependencies.map(function (path) {
|
|
213
|
-
return
|
|
236
|
+
return calcAddableSectionAssertField(namePath, path, index, [children]);
|
|
214
237
|
});
|
|
215
238
|
}
|
|
216
239
|
return /*#__PURE__*/cloneElement(children, _objectSpread(_objectSpread({}, _child), {}, {
|
|
@@ -266,7 +289,7 @@ var AddableSection = function AddableSection(props) {
|
|
|
266
289
|
children: transformChildren(parentName)
|
|
267
290
|
})
|
|
268
291
|
}))]
|
|
269
|
-
}, key);
|
|
292
|
+
}, key + index);
|
|
270
293
|
});
|
|
271
294
|
return /*#__PURE__*/_jsxs("div", {
|
|
272
295
|
className: "igloo-addable-section-container",
|
|
@@ -61,7 +61,9 @@ var Element = function Element(props) {
|
|
|
61
61
|
subscribedFields = props.subscribedFields,
|
|
62
62
|
extraLabel = props.extraLabel,
|
|
63
63
|
disabled = props.disabled,
|
|
64
|
-
requiredAsserts = props.requiredAsserts
|
|
64
|
+
requiredAsserts = props.requiredAsserts,
|
|
65
|
+
shouldRenderCode = props.shouldRenderCode,
|
|
66
|
+
disabledCode = props.disabledCode;
|
|
65
67
|
var dependentField = dependencies || [];
|
|
66
68
|
if (Array.isArray(subscribedFields)) {
|
|
67
69
|
dependentField.push.apply(dependentField, _toConsumableArray(subscribedFields));
|
|
@@ -87,7 +89,7 @@ var Element = function Element(props) {
|
|
|
87
89
|
return dependentField.push(assert.field);
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
|
-
if ((shouldRender || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
|
|
92
|
+
if ((shouldRender || shouldRenderCode || disabledCode || getOptions || typeof extraLabel === 'function') && !Array.isArray(subscribedFields)) {
|
|
91
93
|
dependentField.push('SUBSCRIBE_ALL');
|
|
92
94
|
}
|
|
93
95
|
if (dependField) {
|
|
@@ -210,7 +210,7 @@ var Step = function Step(_ref) {
|
|
|
210
210
|
return _ref3.apply(this, arguments);
|
|
211
211
|
};
|
|
212
212
|
}();
|
|
213
|
-
if (!calcShouldRender(pName, dependencies, asserts, shouldRender, shouldRenderCode, form)) {
|
|
213
|
+
if (!calcShouldRender(pName, parentName, dependencies, asserts, shouldRender, shouldRenderCode, form)) {
|
|
214
214
|
return null;
|
|
215
215
|
}
|
|
216
216
|
return /*#__PURE__*/_jsxs("div", {
|
package/es/index.d.ts
CHANGED
|
@@ -46,3 +46,4 @@ export { default as FormStep } from './free-form/step';
|
|
|
46
46
|
export { default as FormSection } from './free-form/section';
|
|
47
47
|
export { default as FormAddableSection } from './free-form/addable-section';
|
|
48
48
|
export { default as App } from './app';
|
|
49
|
+
export { default as ConfigProvider } from './config-provider';
|
package/es/index.js
CHANGED
|
@@ -45,4 +45,5 @@ export { default as FormSteps } from "./free-form/steps";
|
|
|
45
45
|
export { default as FormStep } from "./free-form/step";
|
|
46
46
|
export { default as FormSection } from "./free-form/section";
|
|
47
47
|
export { default as FormAddableSection } from "./free-form/addable-section";
|
|
48
|
-
export { default as App } from "./app";
|
|
48
|
+
export { default as App } from "./app";
|
|
49
|
+
export { default as ConfigProvider } from "./config-provider";
|
package/es/input/amount.js
CHANGED
|
@@ -17,7 +17,9 @@ import "./style/amount";
|
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
var thousands = function thousands(number, decimalSeparator, separator) {
|
|
19
19
|
if (number === null || number === undefined) return undefined;
|
|
20
|
-
var arr = String(number)
|
|
20
|
+
var arr = String(number)
|
|
21
|
+
// .replace('.', decimalSeparator)
|
|
22
|
+
.split(decimalSeparator);
|
|
21
23
|
return arr.map(function (s, index) {
|
|
22
24
|
if (index === 0) {
|
|
23
25
|
return s.replace(/(?=(?!\b)(\d{3})+$)/g, separator);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { ConfigProviderProps } from 'antd/es/config-provider';
|
|
2
3
|
export declare const locales: {
|
|
3
4
|
[key: string]: {
|
|
4
5
|
[id: string]: string;
|
|
@@ -6,6 +7,8 @@ export declare const locales: {
|
|
|
6
7
|
};
|
|
7
8
|
declare const LocaleProvider: FC<{
|
|
8
9
|
currentLang: string;
|
|
10
|
+
underConfigProvider?: boolean;
|
|
11
|
+
antdConfig?: ConfigProviderProps;
|
|
9
12
|
children?: ReactNode;
|
|
10
13
|
}>;
|
|
11
14
|
export default LocaleProvider;
|
|
@@ -6,7 +6,6 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
6
6
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
import { useEffect } from 'react';
|
|
8
8
|
import LocaleContext from "./locale-context";
|
|
9
|
-
import { ConfigProvider } from 'antd';
|
|
10
9
|
import en from "./en-US";
|
|
11
10
|
import zh from "./zh-CN";
|
|
12
11
|
import id from "./id-ID";
|
|
@@ -23,6 +22,7 @@ import antdZhTw from 'antd/es/locale/zh_TW';
|
|
|
23
22
|
import antdMY from 'antd/es/locale/ms_MY';
|
|
24
23
|
import antdDefault from 'antd/es/locale/en_US';
|
|
25
24
|
import { staticLang } from "./format-message";
|
|
25
|
+
import { ConfigProvider } from 'antd';
|
|
26
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
27
|
export var locales = {
|
|
28
28
|
'en-US': en,
|
|
@@ -44,7 +44,9 @@ var antdLocale = {
|
|
|
44
44
|
};
|
|
45
45
|
var LocaleProvider = function LocaleProvider(_ref) {
|
|
46
46
|
var children = _ref.children,
|
|
47
|
-
currentLang = _ref.currentLang
|
|
47
|
+
currentLang = _ref.currentLang,
|
|
48
|
+
underConfigProvider = _ref.underConfigProvider,
|
|
49
|
+
antdConfig = _ref.antdConfig;
|
|
48
50
|
var locale = locales[currentLang] || en;
|
|
49
51
|
useEffect(function () {
|
|
50
52
|
staticLang.current = currentLang;
|
|
@@ -64,10 +66,10 @@ var LocaleProvider = function LocaleProvider(_ref) {
|
|
|
64
66
|
formatMessage: formatMessage,
|
|
65
67
|
currentLang: currentLang
|
|
66
68
|
},
|
|
67
|
-
children: /*#__PURE__*/_jsx(ConfigProvider, {
|
|
69
|
+
children: underConfigProvider ? children : /*#__PURE__*/_jsx(ConfigProvider, _objectSpread(_objectSpread({}, antdConfig), {}, {
|
|
68
70
|
locale: antdLocale[currentLang] || antdDefault,
|
|
69
71
|
children: children
|
|
70
|
-
})
|
|
72
|
+
}))
|
|
71
73
|
});
|
|
72
74
|
};
|
|
73
75
|
export default LocaleProvider;
|
package/es/media/preview.js
CHANGED
|
@@ -60,6 +60,10 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
60
60
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
61
61
|
index = _useReducer2[0],
|
|
62
62
|
update = _useReducer2[1];
|
|
63
|
+
var _Modal$useModal = Modal.useModal(),
|
|
64
|
+
_Modal$useModal2 = _slicedToArray(_Modal$useModal, 2),
|
|
65
|
+
modal = _Modal$useModal2[0],
|
|
66
|
+
modalHolder = _Modal$useModal2[1];
|
|
63
67
|
var handlePageInit = function handlePageInit(document) {
|
|
64
68
|
var _ref2 = document || {},
|
|
65
69
|
numPages = _ref2.numPages;
|
|
@@ -85,7 +89,7 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
85
89
|
id: 'Invalid password.'
|
|
86
90
|
}));
|
|
87
91
|
}
|
|
88
|
-
|
|
92
|
+
modal.confirm({
|
|
89
93
|
title: formatMessage({
|
|
90
94
|
id: 'Enter the password to open this PDF file.'
|
|
91
95
|
}),
|
|
@@ -155,7 +159,7 @@ var PdfViewer = function PdfViewer(_ref) {
|
|
|
155
159
|
}, index);
|
|
156
160
|
}
|
|
157
161
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
158
|
-
children: [/*#__PURE__*/_jsx("div", {
|
|
162
|
+
children: [modalHolder, /*#__PURE__*/_jsx("div", {
|
|
159
163
|
style: {
|
|
160
164
|
maxWidth: "calc(100vw - ".concat(md ? 64 : 32, "px)"),
|
|
161
165
|
maxHeight: '100%',
|
package/es/modal/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import Form from "../form";
|
|
|
22
22
|
import { LocaleContext, LocaleProvider } from "../locale";
|
|
23
23
|
import { staticLang } from "../locale/format-message";
|
|
24
24
|
import useModal from "./useModal";
|
|
25
|
+
import { staticAntdConfig } from "../config-provider";
|
|
25
26
|
import "./style";
|
|
26
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
28
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -180,11 +181,11 @@ var modalFunction = function modalFunction(_ref2) {
|
|
|
180
181
|
_onCancel = _ref3.onCancel,
|
|
181
182
|
_onOk = _ref3.onOk,
|
|
182
183
|
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
183
|
-
render( /*#__PURE__*/
|
|
184
|
+
render( /*#__PURE__*/_jsx(ConfigProvider, _objectSpread(_objectSpread({}, staticAntdConfig), {}, {
|
|
184
185
|
theme: {
|
|
185
186
|
token: token
|
|
186
187
|
},
|
|
187
|
-
children:
|
|
188
|
+
children: /*#__PURE__*/_jsx(LocaleProvider, {
|
|
188
189
|
currentLang: staticLang.current,
|
|
189
190
|
children: /*#__PURE__*/_jsx(IglooModal, _objectSpread(_objectSpread({}, rest), {}, {
|
|
190
191
|
open: true,
|
|
@@ -205,8 +206,8 @@ var modalFunction = function modalFunction(_ref2) {
|
|
|
205
206
|
},
|
|
206
207
|
children: content
|
|
207
208
|
}))
|
|
208
|
-
})
|
|
209
|
-
}), ele);
|
|
209
|
+
})
|
|
210
|
+
})), ele);
|
|
210
211
|
};
|
|
211
212
|
var destroy = function destroy() {
|
|
212
213
|
unmount(ele);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Select } from 'antd';
|
|
2
|
+
import { SelectProps, SelectValue } from 'antd/es/select';
|
|
3
|
+
import { FC, IglooComponentProps } from '../types';
|
|
4
|
+
import './style';
|
|
5
|
+
import { ComponentProps } from '../utils/option-utils';
|
|
6
|
+
type Props = SelectProps<SelectValue> & IglooComponentProps & {
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
preview?: boolean;
|
|
9
|
+
} & ComponentProps;
|
|
10
|
+
type OptionType = typeof Select.Option;
|
|
11
|
+
type OptGroupType = typeof Select.OptGroup;
|
|
12
|
+
interface IglooSelectType extends FC<Props> {
|
|
13
|
+
Option: OptionType;
|
|
14
|
+
OptGroup: OptGroupType;
|
|
15
|
+
}
|
|
16
|
+
declare const AttachedSelect: IglooSelectType;
|
|
17
|
+
export default AttachedSelect;
|
package/es/types.d.ts
CHANGED
|
@@ -146,6 +146,7 @@ export interface FormItemExtraConfig extends FormItemProps {
|
|
|
146
146
|
idType?: 'KTP' | 'NIK';
|
|
147
147
|
validationRule?: string;
|
|
148
148
|
shouldRenderCode?: string;
|
|
149
|
+
disabledCode?: string;
|
|
149
150
|
[key: string]: any;
|
|
150
151
|
}
|
|
151
152
|
export interface FormItemConfig extends FormItemExtraConfig {
|