iglooform 3.3.8 → 3.4.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.
Files changed (253) hide show
  1. package/.dumi/tmp/core/defineApp.ts +1 -1
  2. package/.dumi/tmp/core/helmet.ts +1 -1
  3. package/.dumi/tmp/core/history.ts +1 -1
  4. package/.dumi/tmp/core/historyIntelli.ts +1 -1
  5. package/.dumi/tmp/core/plugin.ts +2 -2
  6. package/.dumi/tmp/core/polyfill.ts +197 -197
  7. package/.dumi/tmp/core/route.tsx +33 -33
  8. package/.dumi/tmp/dumi/exports.ts +1 -1
  9. package/.dumi/tmp/dumi/locales/runtime.tsx +2 -2
  10. package/.dumi/tmp/dumi/meta/index.ts +33 -33
  11. package/.dumi/tmp/dumi/meta/runtime.ts +1 -1
  12. package/.dumi/tmp/dumi/theme/ContextWrapper.tsx +2 -2
  13. package/.dumi/tmp/dumi/theme/builtins/API.ts +1 -1
  14. package/.dumi/tmp/dumi/theme/builtins/Badge.ts +1 -1
  15. package/.dumi/tmp/dumi/theme/builtins/Container.ts +1 -1
  16. package/.dumi/tmp/dumi/theme/builtins/Previewer.ts +1 -1
  17. package/.dumi/tmp/dumi/theme/builtins/SourceCode.ts +1 -1
  18. package/.dumi/tmp/dumi/theme/builtins/Table.ts +1 -1
  19. package/.dumi/tmp/dumi/theme/builtins/Tree.ts +1 -1
  20. package/.dumi/tmp/dumi/theme/layouts/DocLayout.ts +1 -1
  21. package/.dumi/tmp/dumi/theme/loading.tsx +1 -1
  22. package/.dumi/tmp/dumi/theme/slots/ColorSwitch.ts +1 -1
  23. package/.dumi/tmp/dumi/theme/slots/Content.ts +1 -1
  24. package/.dumi/tmp/dumi/theme/slots/ContentFooter.ts +1 -1
  25. package/.dumi/tmp/dumi/theme/slots/ContentTabs.ts +1 -1
  26. package/.dumi/tmp/dumi/theme/slots/Features.ts +1 -1
  27. package/.dumi/tmp/dumi/theme/slots/Footer.ts +1 -1
  28. package/.dumi/tmp/dumi/theme/slots/Header.ts +1 -1
  29. package/.dumi/tmp/dumi/theme/slots/HeaderExtra.ts +1 -1
  30. package/.dumi/tmp/dumi/theme/slots/Hero.ts +1 -1
  31. package/.dumi/tmp/dumi/theme/slots/HeroTitle.ts +1 -1
  32. package/.dumi/tmp/dumi/theme/slots/LangSwitch.ts +1 -1
  33. package/.dumi/tmp/dumi/theme/slots/Logo.ts +1 -1
  34. package/.dumi/tmp/dumi/theme/slots/Navbar.ts +1 -1
  35. package/.dumi/tmp/dumi/theme/slots/NavbarExtra.ts +1 -1
  36. package/.dumi/tmp/dumi/theme/slots/NotFound.ts +1 -1
  37. package/.dumi/tmp/dumi/theme/slots/PreviewerActions.ts +1 -1
  38. package/.dumi/tmp/dumi/theme/slots/PreviewerActionsExtra.ts +1 -1
  39. package/.dumi/tmp/dumi/theme/slots/RtlSwitch.ts +1 -1
  40. package/.dumi/tmp/dumi/theme/slots/SearchBar.ts +2 -2
  41. package/.dumi/tmp/dumi/theme/slots/SearchResult.ts +1 -1
  42. package/.dumi/tmp/dumi/theme/slots/Sidebar.ts +1 -1
  43. package/.dumi/tmp/dumi/theme/slots/SocialIcon.ts +1 -1
  44. package/.dumi/tmp/dumi/theme/slots/Toc.ts +1 -1
  45. package/.dumi/tmp/exports.ts +5 -5
  46. package/.dumi/tmp/testBrowser.tsx +3 -3
  47. package/.dumi/tmp/umi.ts +4 -4
  48. package/es/documents/index.js +27 -3
  49. package/es/form/hsteps/index.d.ts +21 -0
  50. package/es/form/step-items-selection/components/section-of-item-condition/hooks/useAdaptAssertConfig.d.ts +4 -0
  51. package/es/index.d.ts +49 -0
  52. package/es/media/index.d.ts +1 -0
  53. package/es/media/index.js +67 -36
  54. package/es/media/media.d.ts +4 -1
  55. package/es/media/media.js +75 -28
  56. package/es/types.d.ts +189 -0
  57. package/es/utils/form-utils.d.ts +79 -0
  58. package/lib/documents/index.js +27 -3
  59. package/lib/form/hsteps/index.d.ts +21 -0
  60. package/lib/form/step-items-selection/components/section-of-item-condition/hooks/useAdaptAssertConfig.d.ts +4 -0
  61. package/lib/index.d.ts +49 -0
  62. package/lib/media/index.d.ts +1 -0
  63. package/lib/media/index.js +66 -36
  64. package/lib/media/media.d.ts +4 -1
  65. package/lib/media/media.js +74 -28
  66. package/lib/types.d.ts +189 -0
  67. package/lib/utils/form-utils.d.ts +79 -0
  68. package/package.json +1 -1
  69. package/.idea/codeStyles/Project.xml +0 -59
  70. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  71. package/.idea/iglooform.iml +0 -12
  72. package/.idea/modules.xml +0 -8
  73. package/.idea/prettier.xml +0 -6
  74. package/.idea/vcs.xml +0 -6
  75. package/es/admin-amount/style/index.d.ts +0 -0
  76. package/es/babel-plugin-import-option.d.ts +0 -7
  77. package/es/back-top/index.d.ts +0 -5
  78. package/es/claim-list/style/index.d.ts +0 -1
  79. package/es/confirmation/style/index.d.ts +0 -1
  80. package/es/currency-context/index.d.ts +0 -8
  81. package/es/currency-context/style/index.d.ts +0 -0
  82. package/es/date-picker/style/index.d.ts +0 -1
  83. package/es/declaration/style/index.d.ts +0 -1
  84. package/es/detail-panel/style/index.d.ts +0 -1
  85. package/es/documents/style/index.d.ts +0 -1
  86. package/es/filter/style/index.d.ts +0 -1
  87. package/es/form/addable-section/style/index.d.ts +0 -1
  88. package/es/form/divider/style/index.d.ts +0 -1
  89. package/es/form/element/style/index.d.ts +0 -1
  90. package/es/form/hstep/style/index.d.ts +0 -1
  91. package/es/form/hsteps/style/index.d.ts +0 -1
  92. package/es/form/login/style/index.d.ts +0 -1
  93. package/es/form/messages.d.ts +0 -48
  94. package/es/form/page/style/index.d.ts +0 -1
  95. package/es/form/pages/style/index.d.ts +0 -1
  96. package/es/form/render/style/index.d.ts +0 -1
  97. package/es/form/section/style/index.d.ts +0 -1
  98. package/es/form/step/style/index.d.ts +0 -1
  99. package/es/form/steps/style/index.d.ts +0 -1
  100. package/es/form/style/index.d.ts +0 -1
  101. package/es/free-form/addable-section/style/index.d.ts +0 -1
  102. package/es/free-form/element/style/index.d.ts +0 -1
  103. package/es/free-form/messages.d.ts +0 -48
  104. package/es/free-form/page/style/index.d.ts +0 -1
  105. package/es/free-form/pages/style/index.d.ts +0 -1
  106. package/es/free-form/section/style/index.d.ts +0 -1
  107. package/es/free-form/step/style/index.d.ts +0 -1
  108. package/es/free-form/steps/style/index.d.ts +0 -1
  109. package/es/free-form/style/index.d.ts +0 -1
  110. package/es/home-menu/style/index.d.ts +0 -1
  111. package/es/input/style/amount/index.d.ts +0 -2
  112. package/es/input/style/index.d.ts +0 -2
  113. package/es/input/style/input-date/index.d.ts +0 -2
  114. package/es/input/style/otp/index.d.ts +0 -2
  115. package/es/input/style/phone-number/index.d.ts +0 -2
  116. package/es/input/style/text-area/index.d.ts +0 -2
  117. package/es/layout/defaultHeader.d.ts +0 -4
  118. package/es/layout/style/index.d.ts +0 -1
  119. package/es/locale/en-US.d.ts +0 -2
  120. package/es/locale/format-message.d.ts +0 -10
  121. package/es/locale/formatted-message.d.ts +0 -6
  122. package/es/locale/id-ID.d.ts +0 -2
  123. package/es/locale/index.d.ts +0 -4
  124. package/es/locale/locale-context.d.ts +0 -12
  125. package/es/locale/ms-MY.d.ts +0 -2
  126. package/es/locale/th-TH.d.ts +0 -2
  127. package/es/locale/vi-VN.d.ts +0 -2
  128. package/es/locale/zh-CN.d.ts +0 -2
  129. package/es/locale/zh-TW.d.ts +0 -2
  130. package/es/login-page/index.d.ts +0 -7
  131. package/es/login-page/style/index.d.ts +0 -1
  132. package/es/media/style/index.d.ts +0 -1
  133. package/es/message/style/index.d.ts +0 -1
  134. package/es/mobile-insurer-detail/style/index.d.ts +0 -1
  135. package/es/mobile-insurer-list/style/index.d.ts +0 -1
  136. package/es/modal/style/index.d.ts +0 -1
  137. package/es/ocr/micro-blink/style/index.d.ts +0 -1
  138. package/es/platform/index.d.ts +0 -2
  139. package/es/platform/platform-card/index.d.ts +0 -12
  140. package/es/platform/platform-card/style/index.d.ts +0 -1
  141. package/es/platform/switch-platform/index.d.ts +0 -12
  142. package/es/platform/switch-platform/style/index.d.ts +0 -1
  143. package/es/policy-list/style/index.d.ts +0 -1
  144. package/es/radio/style/index.d.ts +0 -1
  145. package/es/search-box/style/index.d.ts +0 -1
  146. package/es/select/style/index.d.ts +0 -1
  147. package/es/status-box/style/index.d.ts +0 -1
  148. package/es/table/style/index.d.ts +0 -1
  149. package/es/tabs/index.d.ts +0 -15
  150. package/es/tabs/style/index.d.ts +0 -1
  151. package/es/typography/style/index.d.ts +0 -1
  152. package/es/upload/style/index.d.ts +0 -1
  153. package/es/upload-photo/media.d.ts +0 -7
  154. package/es/upload-photo/style/index.d.ts +0 -1
  155. package/es/upload-preview/style/index.d.ts +0 -1
  156. package/es/utils/agent-detect.d.ts +0 -1
  157. package/es/utils/useAsyncEffect.d.ts +0 -3
  158. package/lib/admin-amount/style/index.d.ts +0 -0
  159. package/lib/admin-upload/style/index.d.ts +0 -1
  160. package/lib/alert-message/style/index.d.ts +0 -1
  161. package/lib/babel-plugin-import-option.d.ts +0 -7
  162. package/lib/back-top/index.d.ts +0 -5
  163. package/lib/back-top/style/index.d.ts +0 -1
  164. package/lib/button/style/index.d.ts +0 -1
  165. package/lib/card-detail/style/index.d.ts +0 -1
  166. package/lib/checkbox/style/index.d.ts +0 -1
  167. package/lib/claim-list/style/index.d.ts +0 -1
  168. package/lib/confirmation/style/index.d.ts +0 -1
  169. package/lib/currency-context/index.d.ts +0 -8
  170. package/lib/currency-context/style/index.d.ts +0 -0
  171. package/lib/date-picker/style/index.d.ts +0 -1
  172. package/lib/declaration/style/index.d.ts +0 -1
  173. package/lib/detail-panel/style/index.d.ts +0 -1
  174. package/lib/documents/style/index.d.ts +0 -1
  175. package/lib/filter/style/index.d.ts +0 -1
  176. package/lib/form/addable-section/style/index.d.ts +0 -1
  177. package/lib/form/divider/style/index.d.ts +0 -1
  178. package/lib/form/element/style/index.d.ts +0 -1
  179. package/lib/form/hstep/style/index.d.ts +0 -1
  180. package/lib/form/hsteps/style/index.d.ts +0 -1
  181. package/lib/form/login/style/index.d.ts +0 -1
  182. package/lib/form/messages.d.ts +0 -48
  183. package/lib/form/page/style/index.d.ts +0 -1
  184. package/lib/form/pages/style/index.d.ts +0 -1
  185. package/lib/form/render/style/index.d.ts +0 -1
  186. package/lib/form/section/style/index.d.ts +0 -1
  187. package/lib/form/step/style/index.d.ts +0 -1
  188. package/lib/form/steps/style/index.d.ts +0 -1
  189. package/lib/form/style/index.d.ts +0 -1
  190. package/lib/free-form/addable-section/style/index.d.ts +0 -1
  191. package/lib/free-form/element/style/index.d.ts +0 -1
  192. package/lib/free-form/messages.d.ts +0 -48
  193. package/lib/free-form/page/style/index.d.ts +0 -1
  194. package/lib/free-form/pages/style/index.d.ts +0 -1
  195. package/lib/free-form/section/style/index.d.ts +0 -1
  196. package/lib/free-form/step/style/index.d.ts +0 -1
  197. package/lib/free-form/steps/style/index.d.ts +0 -1
  198. package/lib/free-form/style/index.d.ts +0 -1
  199. package/lib/home-menu/style/index.d.ts +0 -1
  200. package/lib/input/style/amount/index.d.ts +0 -2
  201. package/lib/input/style/index.d.ts +0 -2
  202. package/lib/input/style/input-date/index.d.ts +0 -2
  203. package/lib/input/style/otp/index.d.ts +0 -2
  204. package/lib/input/style/phone-number/index.d.ts +0 -2
  205. package/lib/input/style/text-area/index.d.ts +0 -2
  206. package/lib/layout/defaultHeader.d.ts +0 -4
  207. package/lib/layout/style/index.d.ts +0 -1
  208. package/lib/locale/en-US.d.ts +0 -2
  209. package/lib/locale/format-message.d.ts +0 -10
  210. package/lib/locale/formatted-message.d.ts +0 -6
  211. package/lib/locale/id-ID.d.ts +0 -2
  212. package/lib/locale/index.d.ts +0 -4
  213. package/lib/locale/locale-context.d.ts +0 -12
  214. package/lib/locale/ms-MY.d.ts +0 -2
  215. package/lib/locale/th-TH.d.ts +0 -2
  216. package/lib/locale/vi-VN.d.ts +0 -2
  217. package/lib/locale/zh-CN.d.ts +0 -2
  218. package/lib/locale/zh-TW.d.ts +0 -2
  219. package/lib/login-page/index.d.ts +0 -7
  220. package/lib/login-page/style/index.d.ts +0 -1
  221. package/lib/media/style/index.d.ts +0 -1
  222. package/lib/message/style/index.d.ts +0 -1
  223. package/lib/mobile-insurer-detail/style/index.d.ts +0 -1
  224. package/lib/mobile-insurer-list/style/index.d.ts +0 -1
  225. package/lib/modal/style/index.d.ts +0 -1
  226. package/lib/ocr/micro-blink/style/index.d.ts +0 -1
  227. package/lib/platform/index.d.ts +0 -2
  228. package/lib/platform/platform-card/index.d.ts +0 -12
  229. package/lib/platform/platform-card/style/index.d.ts +0 -1
  230. package/lib/platform/switch-platform/index.d.ts +0 -12
  231. package/lib/platform/switch-platform/style/index.d.ts +0 -1
  232. package/lib/policy-list/style/index.d.ts +0 -1
  233. package/lib/radio/style/index.d.ts +0 -1
  234. package/lib/search-box/style/index.d.ts +0 -1
  235. package/lib/select/style/index.d.ts +0 -1
  236. package/lib/status-box/style/index.d.ts +0 -1
  237. package/lib/table/style/index.d.ts +0 -1
  238. package/lib/tabs/index.d.ts +0 -15
  239. package/lib/tabs/style/index.d.ts +0 -1
  240. package/lib/typography/style/index.d.ts +0 -1
  241. package/lib/upload/style/index.d.ts +0 -1
  242. package/lib/upload-photo/media.d.ts +0 -7
  243. package/lib/upload-photo/style/index.d.ts +0 -1
  244. package/lib/upload-preview/style/index.d.ts +0 -1
  245. package/lib/utils/agent-detect.d.ts +0 -1
  246. package/lib/utils/useAsyncEffect.d.ts +0 -3
  247. package/yarn-error.log +0 -16168
  248. /package/es/{admin-upload → form/step-items-selection/components/checkbox-group-items}/style/index.d.ts +0 -0
  249. /package/es/{alert-message → form/step-items-selection/components/item-info}/style/index.d.ts +0 -0
  250. /package/es/{back-top → form/step-items-selection/components/section-of-item-condition}/style/index.d.ts +0 -0
  251. /package/{es/button → lib/form/step-items-selection/components/checkbox-group-items}/style/index.d.ts +0 -0
  252. /package/{es/card-detail → lib/form/step-items-selection/components/item-info}/style/index.d.ts +0 -0
  253. /package/{es/checkbox → lib/form/step-items-selection/components/section-of-item-condition}/style/index.d.ts +0 -0
@@ -31,7 +31,14 @@ var Documents = function Documents(_ref) {
31
31
  _useState2 = _slicedToArray(_useState, 2),
32
32
  current = _useState2[0],
33
33
  setCurrent = _useState2[1];
34
- var _useState3 = useState([]),
34
+ var _useState3 = useState(function () {
35
+ return docList.map(function (d) {
36
+ return {
37
+ loading: true,
38
+ src: typeof d === 'string' ? d : d.src
39
+ };
40
+ });
41
+ }),
35
42
  _useState4 = _slicedToArray(_useState3, 2),
36
43
  list = _useState4[0],
37
44
  setList = _useState4[1];
@@ -91,8 +98,25 @@ var Documents = function Documents(_ref) {
91
98
  return /*#__PURE__*/_jsx(Space, {
92
99
  size: [8, 8],
93
100
  wrap: true,
94
- children: list.map(function (_ref3, index) {
95
- var _src = _ref3.src,
101
+ children: list.map(function (item, index) {
102
+ if (item.loading) {
103
+ var loading = item.loading,
104
+ _src2 = item.src;
105
+ return /*#__PURE__*/_jsx("div", {
106
+ style: {
107
+ left: "".concat((index - current) * 100, "%")
108
+ },
109
+ children: /*#__PURE__*/_jsx(MediaWithPreview, {
110
+ loading: loading,
111
+ index: index,
112
+ src: _src2,
113
+ className: className,
114
+ style: style
115
+ })
116
+ }, index);
117
+ }
118
+ var _ref3 = item,
119
+ _src = _ref3.src,
96
120
  type = _ref3.type,
97
121
  nonCORSSrc = _ref3.nonCORSSrc;
98
122
  var src = !!nonCORSSrc ? {
@@ -0,0 +1,21 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { FormItemConfig, FormItemName } from '../../types';
3
+ import './style';
4
+ import { ConfirmationProps } from '../../confirmation';
5
+ export interface HStepsProps {
6
+ config: FormItemConfig & {
7
+ confirmations?: {
8
+ [key: string]: {
9
+ required: boolean;
10
+ confirmation?: ConfirmationProps;
11
+ requiredMessage?: string;
12
+ };
13
+ };
14
+ withReview?: boolean;
15
+ description?: ReactNode;
16
+ };
17
+ parentName?: FormItemName;
18
+ name?: FormItemName;
19
+ }
20
+ declare const HSteps: FC<HStepsProps>;
21
+ export default HSteps;
@@ -0,0 +1,4 @@
1
+ import type { FormItemConfig } from '../../../../../types';
2
+ type useAdaptAssertConfig = (elements: FormItemConfig[], index: number) => FormItemConfig[];
3
+ export declare const useAdaptAssertConfig: useAdaptAssertConfig;
4
+ export {};
package/es/index.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ export { default as Form } from './form';
2
+ export { default as Button, GreenButton, YellowButton, RedButton, } from './button';
3
+ export { default as DatePicker, IglooBuddhistDatePicker as BuddhistDatePicker, IglooRangePicker as RangePicker, IglooWeekPicker as WeekPicker, IglooMonthPicker as MonthPicker, } from './date-picker';
4
+ export { default as Input, PhoneNumber, Amount, Password, Email, InputNumber, TextArea, InputDate, CreditCard, ExpiryDate, InputId, } from './input';
5
+ export { default as OCR } from './ocr';
6
+ export { default as Select, TimeSelect, AttachedSelect } from './select';
7
+ export { default as Radio, RadioGroup, RadioGroupWithOther } from './radio';
8
+ export { default as Upload } from './upload';
9
+ export { default as Checkbox, CheckboxGroup } from './checkbox';
10
+ export { default as Declaration } from './declaration';
11
+ export { Divider } from 'antd';
12
+ export { default as UploadPhoto } from './upload-photo';
13
+ export { default as AlertMessage } from './alert-message';
14
+ export { default as LoginPage } from './login-page';
15
+ export { default as UploadPreview } from './upload-preview';
16
+ export { default as Typography } from './typography';
17
+ export { default as PlatformCard } from './platform/platform-card';
18
+ export { default as SwitchPlatform } from './platform/switch-platform';
19
+ export { default as Table } from './table';
20
+ export { default as StatusBox } from './status-box';
21
+ export { CardPage, Card, CardGroup, CardItem } from './card-detail';
22
+ export { default as AdminMedia } from './media';
23
+ export { default as Documents } from './documents';
24
+ export { default as Filter } from './filter';
25
+ export { default as CurrencyContext } from './currency-context';
26
+ export { default as Tabs } from './tabs';
27
+ export { default as AdminAmount } from './admin-amount';
28
+ export { default as AdminUpload } from './admin-upload';
29
+ export { LocaleProvider } from './locale';
30
+ export { default as Modal } from './modal';
31
+ export { default as BackTop } from './back-top';
32
+ export { default as MediaPreview } from './upload-preview/media';
33
+ export { default as PolicyList } from './policy-list';
34
+ export { default as ClaimList } from './claim-list';
35
+ export { default as MobileInsurerDetail } from './mobile-insurer-detail';
36
+ export { default as Layout } from './layout';
37
+ export { default as DetailPanel } from './detail-panel';
38
+ export { default as message } from './message';
39
+ export { default as SearchBox } from './search-box';
40
+ export { default as FreeForm } from './free-form';
41
+ export { default as FormItem } from './free-form/element';
42
+ export { default as FormPages } from './free-form/pages';
43
+ export { default as FormPage } from './free-form/page';
44
+ export { default as FormSteps } from './free-form/steps';
45
+ export { default as FormStep } from './free-form/step';
46
+ export { default as FormSection } from './free-form/section';
47
+ export { default as FormAddableSection } from './free-form/addable-section';
48
+ export { default as App } from './app';
49
+ export { default as ConfigProvider } from './config-provider';
@@ -24,6 +24,7 @@ interface Props {
24
24
  destroyOnClose?: boolean;
25
25
  download?: Download;
26
26
  getNonCORSUrl?: GetNonCORSUrl;
27
+ loading?: boolean;
27
28
  }
28
29
  declare const MediaWithPreview: FC<Props>;
29
30
  export default MediaWithPreview;
package/es/media/index.js CHANGED
@@ -19,6 +19,7 @@ import FileIcon from "./file-icon";
19
19
  import { MinusOutlined, PlusOutlined, ArrowRightOutlined, ArrowLeftOutlined, CrossOutlined, DownloadOutlined } from 'iglooicon';
20
20
  import "./style";
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { Fragment as _Fragment } from "react/jsx-runtime";
22
23
  import { jsxs as _jsxs } from "react/jsx-runtime";
23
24
  var MediaWithPreview = function MediaWithPreview(_ref) {
24
25
  var srcProp = _ref.src,
@@ -41,40 +42,54 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
41
42
  download = _ref$download === void 0 ? {
42
43
  actionType: 'downloadBlob'
43
44
  } : _ref$download,
44
- getNonCORSUrl = _ref.getNonCORSUrl;
45
+ getNonCORSUrl = _ref.getNonCORSUrl,
46
+ loadingProp = _ref.loading;
45
47
  var _ref2 = _typeof(srcProp) === 'object' ? [srcProp.origin, srcProp.nonCORS] : [srcProp],
46
48
  _ref3 = _slicedToArray(_ref2, 2),
47
49
  src = _ref3[0],
48
50
  nonCORSSrcProp = _ref3[1];
49
- var _useState = useState(nonCORSSrcProp),
51
+ var _useState = useState(true),
50
52
  _useState2 = _slicedToArray(_useState, 2),
51
- nonCORSSrc = _useState2[0],
52
- setNonCORSSrc = _useState2[1];
53
- var _useState3 = useState(1),
53
+ loading = _useState2[0],
54
+ setLoading = _useState2[1];
55
+ var _useState3 = useState(nonCORSSrcProp),
54
56
  _useState4 = _slicedToArray(_useState3, 2),
55
- scale = _useState4[0],
56
- setScale = _useState4[1];
57
- var _useState5 = useState(type),
57
+ nonCORSSrc = _useState4[0],
58
+ setNonCORSSrc = _useState4[1];
59
+ var _useState5 = useState(1),
58
60
  _useState6 = _slicedToArray(_useState5, 2),
59
- mediaType = _useState6[0],
60
- setType = _useState6[1];
61
- var _useState7 = useState(false),
61
+ scale = _useState6[0],
62
+ setScale = _useState6[1];
63
+ var _useState7 = useState(type),
62
64
  _useState8 = _slicedToArray(_useState7, 2),
63
- showModal = _useState8[0],
64
- setShowModal = _useState8[1];
65
- var _useState9 = useState(index),
65
+ mediaType = _useState8[0],
66
+ setType = _useState8[1];
67
+ var _useState9 = useState(false),
66
68
  _useState10 = _slicedToArray(_useState9, 2),
67
- current = _useState10[0],
68
- setCurrent = _useState10[1];
69
- var _useState11 = useState(''),
69
+ showModal = _useState10[0],
70
+ setShowModal = _useState10[1];
71
+ var _useState11 = useState(index),
70
72
  _useState12 = _slicedToArray(_useState11, 2),
71
- direction = _useState12[0],
72
- setDirection = _useState12[1];
73
+ current = _useState12[0],
74
+ setCurrent = _useState12[1];
75
+ var _useState13 = useState(''),
76
+ _useState14 = _slicedToArray(_useState13, 2),
77
+ direction = _useState14[0],
78
+ setDirection = _useState14[1];
79
+ useEffect(function () {
80
+ setType(type);
81
+ }, [type]);
82
+ useEffect(function () {
83
+ if (loadingProp === undefined) return;
84
+ setLoading(loadingProp);
85
+ }, [loadingProp]);
73
86
  useEffect(function () {
74
87
  setNonCORSSrc(nonCORSSrcProp);
75
88
  }, [nonCORSSrcProp]);
76
89
  useEffect(function () {
90
+ if (!src) return;
77
91
  if (mediaType) {
92
+ setLoading(false);
78
93
  return;
79
94
  }
80
95
  var unmounted = false;
@@ -84,27 +99,29 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
84
99
  return _regeneratorRuntime().wrap(function _callee$(_context) {
85
100
  while (1) switch (_context.prev = _context.next) {
86
101
  case 0:
102
+ setLoading(true);
87
103
  _context.t0 = nonCORSSrc;
88
104
  if (_context.t0) {
89
- _context.next = 5;
105
+ _context.next = 6;
90
106
  break;
91
107
  }
92
- _context.next = 4;
108
+ _context.next = 5;
93
109
  return getNonCORSUrl === null || getNonCORSUrl === void 0 ? void 0 : getNonCORSUrl(src);
94
- case 4:
95
- _context.t0 = _context.sent;
96
110
  case 5:
111
+ _context.t0 = _context.sent;
112
+ case 6:
97
113
  _nonCORSSrc = _context.t0;
98
- _context.next = 8;
114
+ _context.next = 9;
99
115
  return getResourceContentType(_nonCORSSrc !== null && _nonCORSSrc !== void 0 ? _nonCORSSrc : src);
100
- case 8:
116
+ case 9:
101
117
  contentType = _context.sent;
102
118
  typeClass = classifyType(contentType);
103
119
  if (!unmounted) {
104
120
  !nonCORSSrc && setNonCORSSrc(_nonCORSSrc);
105
121
  setType(typeClass);
106
122
  }
107
- case 11:
123
+ setLoading(false);
124
+ case 13:
108
125
  case "end":
109
126
  return _context.stop();
110
127
  }
@@ -118,7 +135,7 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
118
135
  return function () {
119
136
  unmounted = true;
120
137
  };
121
- }, [src, nonCORSSrc]);
138
+ }, [mediaType, src, nonCORSSrc]);
122
139
  useEffect(function () {
123
140
  var handleKeyDown = function handleKeyDown(e) {
124
141
  if (!showModal || list.length === 1) return;
@@ -358,15 +375,29 @@ var MediaWithPreview = function MediaWithPreview(_ref) {
358
375
  return /*#__PURE__*/_jsxs("div", {
359
376
  className: className,
360
377
  style: style,
361
- children: [canRenderMedia ? /*#__PURE__*/_jsx(Media, {
362
- type: mediaType,
363
- src: src,
364
- onClick: open,
365
- name: name
366
- }) : /*#__PURE__*/_jsx(FileIcon, {
367
- type: mediaType,
368
- onDownloadClick: onDownloadByFileIcon,
369
- disabledDownload: !download
378
+ children: [loading && /*#__PURE__*/_jsx("div", {
379
+ style: {
380
+ position: 'relative',
381
+ width: 80,
382
+ height: 80,
383
+ display: 'flex',
384
+ justifyContent: 'center',
385
+ alignItems: 'center',
386
+ overflow: 'hidden',
387
+ border: '1px solid #EEEEEE'
388
+ },
389
+ children: /*#__PURE__*/_jsx(Media.Loading, {})
390
+ }), !loading && /*#__PURE__*/_jsx(_Fragment, {
391
+ children: canRenderMedia ? /*#__PURE__*/_jsx(Media, {
392
+ type: mediaType,
393
+ src: src,
394
+ onClick: open,
395
+ name: name
396
+ }) : /*#__PURE__*/_jsx(FileIcon, {
397
+ type: mediaType,
398
+ onDownloadClick: onDownloadByFileIcon,
399
+ disabledDownload: !download
400
+ })
370
401
  }), /*#__PURE__*/_jsxs(Modal, {
371
402
  open: showModal,
372
403
  onCancel: close,
@@ -1,4 +1,5 @@
1
1
  import { FC, CSSProperties } from 'react';
2
+ declare const Loading: () => import("react/jsx-runtime").JSX.Element;
2
3
  interface MediaProps {
3
4
  src: string;
4
5
  type: string;
@@ -7,5 +8,7 @@ interface MediaProps {
7
8
  style?: CSSProperties;
8
9
  name?: string;
9
10
  }
10
- declare const Media: FC<MediaProps>;
11
+ declare const Media: FC<MediaProps> & {
12
+ Loading: typeof Loading;
13
+ };
11
14
  export default Media;
package/es/media/media.js CHANGED
@@ -8,8 +8,30 @@ import React, { useRef, useState, useContext } from 'react';
8
8
  import { Document, Page } from 'react-pdf/dist/esm/entry.webpack';
9
9
  import { Tooltip } from 'antd';
10
10
  import { LocaleContext } from "../locale";
11
+ import { LoadingOutlined } from 'iglooicon';
11
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { Fragment as _Fragment } from "react/jsx-runtime";
12
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ var Loading = function Loading() {
16
+ return /*#__PURE__*/_jsx("div", {
17
+ style: {
18
+ display: 'flex',
19
+ justifyContent: 'center',
20
+ alignItems: 'center',
21
+ width: '100%',
22
+ height: '100%',
23
+ position: 'absolute',
24
+ zIndex: 1
25
+ },
26
+ children: /*#__PURE__*/_jsx(LoadingOutlined, {
27
+ spinning: true,
28
+ style: {
29
+ fontSize: 24,
30
+ color: '#999999'
31
+ }
32
+ })
33
+ });
34
+ };
13
35
  var MediaItem = function MediaItem(_ref) {
14
36
  var type = _ref.type,
15
37
  src = _ref.src;
@@ -22,15 +44,25 @@ var MediaItem = function MediaItem(_ref) {
22
44
  _useState2 = _slicedToArray(_useState, 2),
23
45
  errorText = _useState2[0],
24
46
  setErrorText = _useState2[1];
47
+ var _useState3 = useState(true),
48
+ _useState4 = _slicedToArray(_useState3, 2),
49
+ loading = _useState4[0],
50
+ setLoading = _useState4[1];
25
51
  switch (type) {
26
52
  case 'video':
27
- return /*#__PURE__*/_jsx("video", {
28
- src: src,
29
- style: {
30
- maxWidth: 80,
31
- maxHeight: 80
32
- },
33
- autoPlay: false
53
+ return /*#__PURE__*/_jsxs(_Fragment, {
54
+ children: [loading && /*#__PURE__*/_jsx(Loading, {}), /*#__PURE__*/_jsx("video", {
55
+ src: src,
56
+ style: {
57
+ maxWidth: 80,
58
+ maxHeight: 80,
59
+ opacity: loading ? 0 : 1
60
+ },
61
+ autoPlay: false,
62
+ onLoadedData: function onLoadedData() {
63
+ return setLoading(false);
64
+ }
65
+ })]
34
66
  });
35
67
  case 'pdf':
36
68
  var needPassword = function needPassword() {
@@ -45,36 +77,50 @@ var MediaItem = function MediaItem(_ref) {
45
77
  }));
46
78
  }
47
79
  };
48
- return /*#__PURE__*/_jsx("div", {
80
+ return /*#__PURE__*/_jsxs("div", {
49
81
  style: {
50
82
  maxWidth: 80,
51
83
  maxHeight: 80,
52
84
  position: 'absolute'
53
85
  },
54
- children: /*#__PURE__*/_jsx(Document, {
55
- ref: documentRef,
56
- file: src,
57
- onPassword: needPassword,
58
- error: /*#__PURE__*/_jsx("div", {
59
- style: {
60
- textAlign: 'center'
86
+ children: [loading && /*#__PURE__*/_jsx(Loading, {}), /*#__PURE__*/_jsx("div", {
87
+ style: {
88
+ opacity: loading ? 0 : 1
89
+ },
90
+ children: /*#__PURE__*/_jsx(Document, {
91
+ ref: documentRef,
92
+ file: src,
93
+ onPassword: needPassword,
94
+ error: /*#__PURE__*/_jsx("div", {
95
+ style: {
96
+ textAlign: 'center'
97
+ },
98
+ children: errorText
99
+ }),
100
+ onLoadSuccess: function onLoadSuccess() {
101
+ return setLoading(false);
61
102
  },
62
- children: errorText
63
- }),
64
- children: /*#__PURE__*/_jsx(Page, {
65
- pageNumber: 1,
66
- scale: 0.1
103
+ children: /*#__PURE__*/_jsx(Page, {
104
+ pageNumber: 1,
105
+ scale: 0.1
106
+ })
67
107
  })
68
- })
108
+ })]
69
109
  });
70
110
  default:
71
- return /*#__PURE__*/_jsx("img", {
72
- src: src,
73
- style: {
74
- maxWidth: 80,
75
- maxHeight: 80,
76
- position: 'absolute'
77
- }
111
+ return /*#__PURE__*/_jsxs(_Fragment, {
112
+ children: [loading && /*#__PURE__*/_jsx(Loading, {}), /*#__PURE__*/_jsx("img", {
113
+ src: src,
114
+ style: {
115
+ maxWidth: 80,
116
+ maxHeight: 80,
117
+ position: 'absolute',
118
+ opacity: loading ? 0 : 1
119
+ },
120
+ onLoad: function onLoad() {
121
+ return setLoading(false);
122
+ }
123
+ })]
78
124
  });
79
125
  }
80
126
  };
@@ -113,4 +159,5 @@ var Media = function Media(_ref2) {
113
159
  })
114
160
  });
115
161
  };
162
+ Media.Loading = Loading;
116
163
  export default Media;
package/es/types.d.ts ADDED
@@ -0,0 +1,189 @@
1
+ /// <reference path="../typings.d.ts" />
2
+ import { BlinkIdSingleSideRecognizerResult } from '@microblink/blinkid-in-browser-sdk';
3
+ import { FormItemProps, FormInstance } from 'antd/es/form';
4
+ import { ReactNode } from 'react';
5
+ import { NamePath } from 'rc-field-form/lib/interface';
6
+ import { CheckboxOptionType } from 'antd/es/checkbox';
7
+ import { SelectProps } from 'antd/es/select';
8
+ export { Rule } from 'rc-field-form/lib/interface';
9
+ export interface OCRHooks {
10
+ microBlink?: {
11
+ initResult: {
12
+ error?: string;
13
+ failed: boolean;
14
+ };
15
+ recognize: ((file: File) => Promise<BlinkIdSingleSideRecognizerResult | null>) | null;
16
+ loading?: boolean;
17
+ };
18
+ }
19
+ export interface OCRConfig {
20
+ microBlink?: {
21
+ licenseKey: string;
22
+ };
23
+ }
24
+ export type FormItemName = NamePath;
25
+ export interface FormBasicConfig {
26
+ config: FormItemConfig;
27
+ className?: string;
28
+ style?: Object;
29
+ locales?: {
30
+ cancelText?: string;
31
+ submitText?: string;
32
+ previewText?: string;
33
+ nextText?: string;
34
+ continueText?: string;
35
+ validateMessages?: Object;
36
+ };
37
+ initialValues?: any;
38
+ form?: FormInstance;
39
+ onCancel?(): void;
40
+ onSubmit?(values: Object, allValues?: Object): any;
41
+ requiredMark?: boolean;
42
+ showSubmitButton?: boolean;
43
+ getScrollContainer?: () => HTMLElement | null;
44
+ onFirstModified?: () => any;
45
+ uploadApi?: string;
46
+ selectDatasourceApi?: string;
47
+ validationRule?: string;
48
+ getRuleValidationApi?: string;
49
+ stepDirection?: 'vertical' | 'horizontal';
50
+ customizeComponents?: {
51
+ [name: string]: FC;
52
+ };
53
+ ocr?: OCRConfig;
54
+ validationCodeExtraParams?: Record<string, any>;
55
+ onValuesChange?: (changedValues: any, values: any) => void;
56
+ }
57
+ export type FormItemAssert = {
58
+ field: NamePath;
59
+ value?: any;
60
+ operation?: 'eq' | 'ne' | 'in' | 'ni' | 'lt' | 'le' | 'gt' | 'ge' | 'co' | 'nc' | 'filled' | 'unfilled' | 'co-some' | 'co-every' | 'some-in' | 'every-in';
61
+ };
62
+ export type FormItemCopyValue = {
63
+ assert: FormItemAssert;
64
+ copyFrom: NamePath;
65
+ disabled?: boolean;
66
+ };
67
+ export type FormItemSelectValue = {
68
+ assert: FormItemAssert;
69
+ value: any;
70
+ disabled?: boolean;
71
+ };
72
+ export interface FormItemExtraConfig extends FormItemProps {
73
+ labelTooltip?: string;
74
+ elements?: FormItemConfig[];
75
+ required?: boolean;
76
+ requiredAsserts?: FormItemAssert[];
77
+ extraLabel?: any;
78
+ xl?: number;
79
+ md?: number;
80
+ xs?: number;
81
+ span?: number;
82
+ areaCode?: number | string | (number | string)[];
83
+ phoneNumber?: number | string;
84
+ mergeRules?: boolean;
85
+ dependencies?: NamePath[];
86
+ antdDependencies?: NamePath[];
87
+ asserts?: FormItemAssert[];
88
+ shouldRender?: (form?: FormInstance) => boolean;
89
+ ignore?: boolean;
90
+ copyValue?: FormItemCopyValue;
91
+ selectValue?: FormItemSelectValue[];
92
+ disabled?: boolean | FormItemAssert | FormItemAssert[];
93
+ halfRow?: boolean;
94
+ fullRow?: boolean;
95
+ limit?: number;
96
+ hideWhenPreview?: boolean;
97
+ hideWhenEdit?: boolean;
98
+ requiredMessage?: string | ReactNode;
99
+ showOptional?: boolean;
100
+ previewFormater?(value: any, form?: FormInstance): any;
101
+ handleNext?(values: any): any;
102
+ render?(preview: boolean, form?: FormInstance, value?: any, onChange?: (params: any) => any, setShowStepButton?: IglooComponentProps['setShowStepButton']): any;
103
+ locales?: {
104
+ [key: string]: string;
105
+ };
106
+ options?: (CheckboxOptionType & {
107
+ extraInfo?: {
108
+ content: any;
109
+ shownTrigger: 'unchecked' | 'checked' | 'all';
110
+ };
111
+ })[] | SelectProps['options'];
112
+ sendOtp?: (value: any) => any;
113
+ dependField?: FormItemName;
114
+ countDownSeconds?: number;
115
+ getButtonDisabledState?: (form: FormInstance) => boolean;
116
+ getPreviousDisabledState?: (form: FormInstance) => boolean;
117
+ handleUpload?(file: File): PromiseLike<string>;
118
+ withoutForm?: boolean;
119
+ disableEditButton?: boolean;
120
+ hidePreviewDivider?: boolean;
121
+ valueFormater?: (value: any) => any;
122
+ currentStep?: number;
123
+ subscribedFields?: FormItemName[];
124
+ description?: string | React.ReactNode;
125
+ dateLimitationType?: 'relative' | 'absolute';
126
+ absoluteRangeStart?: number;
127
+ absoluteRangeEnd?: number;
128
+ relativeRangeStart?: {
129
+ type: 'day' | 'month' | 'year';
130
+ quantity: number;
131
+ pattern?: string;
132
+ dependField?: NamePath;
133
+ };
134
+ relativeRangeEnd?: {
135
+ type: 'day' | 'month' | 'year';
136
+ quantity: number;
137
+ pattern?: string;
138
+ dependField?: NamePath;
139
+ };
140
+ validationCode?: {
141
+ code: string;
142
+ errorMessage: string;
143
+ warningOnly?: boolean;
144
+ }[];
145
+ length?: number;
146
+ minLength?: number;
147
+ maxLength?: number;
148
+ idType?: 'KTP' | 'NIK';
149
+ validationRule?: string;
150
+ shouldRenderCode?: string;
151
+ disabledCode?: string;
152
+ automaticCalcCode?: string;
153
+ enableAutomaticCalc?: boolean;
154
+ [key: string]: any;
155
+ }
156
+ export interface FormItemConfig extends FormItemExtraConfig {
157
+ type?: string;
158
+ name?: NamePath;
159
+ label?: string | React.ReactNode;
160
+ previewLabel?: string | React.ReactNode;
161
+ labelProps?: any;
162
+ contentProps?: any;
163
+ ocr?: {
164
+ vender: string;
165
+ outputMap: {
166
+ field: string[];
167
+ source: string[];
168
+ }[];
169
+ };
170
+ }
171
+ export type FormItemPropsHandler = (config: FormItemConfig) => FormItemConfig;
172
+ export interface FC<P = {}> extends React.FunctionComponent<P> {
173
+ formItemPropsHandler?: FormItemPropsHandler;
174
+ isPreviewSupport?: boolean;
175
+ }
176
+ export interface Form extends React.ForwardRefExoticComponent<FormBasicConfig & React.RefAttributes<any>> {
177
+ useForm: () => FormInstance;
178
+ }
179
+ export interface IglooComponentProps {
180
+ validateField?: (nameList?: NamePath[]) => Promise<any>;
181
+ containerRef?: React.RefObject<any>;
182
+ setFieldError?(errorMsg?: string): void;
183
+ setFieldValue?(value?: any): void;
184
+ setShowStepButton?: (showButton: boolean) => void;
185
+ getFormInstance?: () => FormInstance;
186
+ locales?: {
187
+ [key: string]: string;
188
+ };
189
+ }