x25 3.0.0 → 17.0.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 (274) hide show
  1. package/Account/Load.js +75 -0
  2. package/Account/actions.js +15 -0
  3. package/Account/index.js +20 -0
  4. package/Account/reducer.js +122 -0
  5. package/Account/request.js +44 -0
  6. package/Async/InitModule.js +190 -0
  7. package/Async/RouteLoading.js +64 -0
  8. package/Async/SimulatedException.js +44 -0
  9. package/Async/index.js +95 -0
  10. package/Async/types.js +1 -0
  11. package/Company/Load.js +82 -0
  12. package/Company/actions.js +15 -0
  13. package/Company/index.js +20 -0
  14. package/Company/reducer.js +165 -0
  15. package/Company/request.js +36 -0
  16. package/Company/util.js +10 -0
  17. package/Header/AccountOptionsContainer.js +144 -0
  18. package/Header/AdminSelectCompany.js +109 -0
  19. package/Header/ClientSelectCompany.js +104 -0
  20. package/Header/Header.js +127 -0
  21. package/Header/HeaderContainer.js +39 -0
  22. package/Header/Logo.js +30 -0
  23. package/Header/LogoutButton.js +39 -0
  24. package/Header/index.js +19 -0
  25. package/Header/request.js +26 -0
  26. package/Header/types.js +1 -0
  27. package/Header/util.js +58 -0
  28. package/Inputs/Business/BankAccount.js +48 -0
  29. package/Inputs/Business/BankName.js +49 -0
  30. package/Inputs/Business/CifField.js +112 -0
  31. package/Inputs/Business/CifFieldContainer.js +157 -0
  32. package/Inputs/Business/Email.js +37 -0
  33. package/Inputs/Business/NidField.js +91 -0
  34. package/Inputs/Business/Phone.js +37 -0
  35. package/Inputs/Business/index.js +34 -0
  36. package/Inputs/Business/request.js +39 -0
  37. package/Inputs/CaptchaBox.js +151 -0
  38. package/Inputs/DateInput.js +172 -0
  39. package/Inputs/DateTemplate.js +200 -0
  40. package/Inputs/DelayInputChange.js +135 -0
  41. package/Inputs/FocusTemplate.js +47 -0
  42. package/Inputs/InputTemplate.js +78 -0
  43. package/Inputs/LabelTemplate.js +59 -0
  44. package/Inputs/NumericInput.js +139 -0
  45. package/Inputs/NumericTemplate.js +148 -0
  46. package/Inputs/Selects/County.js +29 -0
  47. package/Inputs/Selects/Custom.js +56 -0
  48. package/Inputs/Selects/Simple.js +75 -0
  49. package/Inputs/Selects/index.js +52 -0
  50. package/Inputs/SimpleInput.js +42 -0
  51. package/Inputs/SimpleTextarea.js +47 -0
  52. package/Inputs/TextareaTemplate.js +55 -0
  53. package/Inputs/Tooltip.js +82 -0
  54. package/Inputs/index.js +185 -0
  55. package/Messages/Error.js +106 -0
  56. package/Messages/Loading.js +68 -0
  57. package/Messages/index.js +29 -0
  58. package/Modal/Delete.js +240 -0
  59. package/Modal/Root.js +81 -0
  60. package/Modal/SimpleModal.js +57 -0
  61. package/Modal/actions.js +10 -0
  62. package/Modal/getComponent.js +42 -0
  63. package/Modal/index.js +22 -0
  64. package/Modal/reducer.js +53 -0
  65. package/Modal/types.js +7 -0
  66. package/Modal/util.js +17 -0
  67. package/Payment/EstimatePrice/Description.js +92 -0
  68. package/Payment/EstimatePrice/PayBox.js +220 -0
  69. package/Payment/EstimatePrice/index.js +92 -0
  70. package/Payment/EstimatePrice/util.js +21 -0
  71. package/Payment/MobilpayForm.js +86 -0
  72. package/Payment/Modal/BankTransfer.js +233 -0
  73. package/Payment/Modal/CompanyValability.js +28 -0
  74. package/Payment/Modal/DoneForm.js +222 -0
  75. package/Payment/Modal/PaymentDone.js +53 -0
  76. package/Payment/Modal/index.js +27 -0
  77. package/Payment/actions.js +23 -0
  78. package/{src/Payment → Payment}/codes.js +19 -16
  79. package/Payment/index.js +141 -0
  80. package/Payment/request.js +49 -0
  81. package/Payment/types.js +1 -0
  82. package/Payment/util.js +50 -0
  83. package/Payment/validate.js +23 -0
  84. package/Sidebar.js +156 -0
  85. package/Things.js +53 -0
  86. package/actions.js +73 -0
  87. package/config.js +10 -0
  88. package/dev/ErrorBoundary.js +109 -0
  89. package/dev/TheError.js +113 -0
  90. package/dev/index.js +132 -0
  91. package/dev/types.js +1 -0
  92. package/package.json +13 -13
  93. package/prod/SentryErrorBoundary.js +150 -0
  94. package/reducer/captchas.js +51 -0
  95. package/reducer/counties.js +57 -0
  96. package/reducer/index.js +38 -0
  97. package/reducer/module.js +48 -0
  98. package/style/index.css +1 -0
  99. package/style/sidebar.css +1 -0
  100. package/types.js +1 -0
  101. package/utility/calendar.js +45 -0
  102. package/utility/date.js +111 -0
  103. package/utility/index.js +125 -0
  104. package/utility/language.js +20 -0
  105. package/utility/mql.js +6 -0
  106. package/utility/normalize-test.js +54 -0
  107. package/utility/normalize.js +108 -0
  108. package/utility/numbers.js +93 -0
  109. package/utility/numeric.js +103 -0
  110. package/utility/others.js +142 -0
  111. package/utility/strings-test.js +216 -0
  112. package/utility/strings.js +85 -0
  113. package/utility/validation/common.js +278 -0
  114. package/utility/validation/index.js +110 -0
  115. package/utility/validation/specific.js +14 -0
  116. package/utility/validation/validate/bank-test.js +41 -0
  117. package/utility/validation/validate/bank.js +176 -0
  118. package/utility/validation/validate/cif-test.js +37 -0
  119. package/utility/validation/validate/cif.js +44 -0
  120. package/utility/validation/validate/cnp-test.js +68 -0
  121. package/utility/validation/validate/cnp.js +193 -0
  122. package/{src/utility → utility}/validation/validate/date.js +61 -73
  123. package/utility/validation/validate/email-test.js +30 -0
  124. package/utility/validation/validate/email.js +11 -0
  125. package/utility/validation/validate/index.js +65 -0
  126. package/.eslintignore +0 -2
  127. package/.eslintrc.json +0 -275
  128. package/.flowconfig +0 -23
  129. package/conf/dev.js +0 -19
  130. package/conf/dist.js +0 -19
  131. package/conf/polyfills/tempPolyfills.js +0 -7
  132. package/src/Account/Load.jsx +0 -79
  133. package/src/Account/actions.js +0 -10
  134. package/src/Account/index.js +0 -11
  135. package/src/Account/reducer.js +0 -139
  136. package/src/Account/request.js +0 -36
  137. package/src/Async/InitModule.jsx +0 -114
  138. package/src/Async/RouteLoading.jsx +0 -52
  139. package/src/Async/SimulatedException.jsx +0 -19
  140. package/src/Async/index.jsx +0 -75
  141. package/src/Async/types.js +0 -39
  142. package/src/Company/Load.jsx +0 -84
  143. package/src/Company/actions.js +0 -10
  144. package/src/Company/index.js +0 -11
  145. package/src/Company/reducer.js +0 -201
  146. package/src/Company/request.js +0 -30
  147. package/src/Company/util.js +0 -7
  148. package/src/Header/AccountOptionsContainer.jsx +0 -124
  149. package/src/Header/AdminSelectCompany.jsx +0 -101
  150. package/src/Header/ClientSelectCompany.jsx +0 -90
  151. package/src/Header/Header.jsx +0 -120
  152. package/src/Header/HeaderContainer.jsx +0 -30
  153. package/src/Header/Logo.jsx +0 -16
  154. package/src/Header/LogoutButton.jsx +0 -34
  155. package/src/Header/index.jsx +0 -9
  156. package/src/Header/request.js +0 -28
  157. package/src/Header/types.js +0 -6
  158. package/src/Header/util.jsx +0 -61
  159. package/src/Inputs/Business/BankAccount.jsx +0 -39
  160. package/src/Inputs/Business/BankName.jsx +0 -40
  161. package/src/Inputs/Business/CifField.jsx +0 -93
  162. package/src/Inputs/Business/CifFieldContainer.jsx +0 -142
  163. package/src/Inputs/Business/Email.jsx +0 -23
  164. package/src/Inputs/Business/NidField.jsx +0 -77
  165. package/src/Inputs/Business/Phone.jsx +0 -23
  166. package/src/Inputs/Business/index.js +0 -16
  167. package/src/Inputs/Business/request.js +0 -39
  168. package/src/Inputs/CaptchaBox.jsx +0 -131
  169. package/src/Inputs/DateInput.jsx +0 -188
  170. package/src/Inputs/DateTemplate.jsx +0 -213
  171. package/src/Inputs/DelayInputChange.jsx +0 -130
  172. package/src/Inputs/FocusTemplate.jsx +0 -41
  173. package/src/Inputs/InputTemplate.jsx +0 -79
  174. package/src/Inputs/LabelTemplate.jsx +0 -47
  175. package/src/Inputs/NumericInput.jsx +0 -142
  176. package/src/Inputs/NumericTemplate.jsx +0 -155
  177. package/src/Inputs/Selects/County.jsx +0 -19
  178. package/src/Inputs/Selects/Custom.jsx +0 -55
  179. package/src/Inputs/Selects/Simple.jsx +0 -73
  180. package/src/Inputs/Selects/index.jsx +0 -37
  181. package/src/Inputs/SimpleInput.jsx +0 -40
  182. package/src/Inputs/SimpleTextarea.jsx +0 -55
  183. package/src/Inputs/TextareaTemplate.jsx +0 -57
  184. package/src/Inputs/Tooltip.jsx +0 -61
  185. package/src/Inputs/index.js +0 -22
  186. package/src/Messages/Error.jsx +0 -83
  187. package/src/Messages/Loading.jsx +0 -43
  188. package/src/Messages/index.jsx +0 -4
  189. package/src/Modal/Delete.jsx +0 -237
  190. package/src/Modal/Root.jsx +0 -57
  191. package/src/Modal/SimpleModal.jsx +0 -47
  192. package/src/Modal/actions.js +0 -7
  193. package/src/Modal/getComponent.jsx +0 -32
  194. package/src/Modal/index.jsx +0 -12
  195. package/src/Modal/reducer.js +0 -40
  196. package/src/Modal/types.js +0 -6
  197. package/src/Modal/util.js +0 -15
  198. package/src/Payment/EstimatePrice/Description.jsx +0 -101
  199. package/src/Payment/EstimatePrice/PayBox.jsx +0 -173
  200. package/src/Payment/EstimatePrice/index.jsx +0 -63
  201. package/src/Payment/EstimatePrice/util.js +0 -15
  202. package/src/Payment/MobilpayForm.jsx +0 -77
  203. package/src/Payment/Modal/BankTransfer.jsx +0 -129
  204. package/src/Payment/Modal/CompanyValability.jsx +0 -14
  205. package/src/Payment/Modal/DoneForm.jsx +0 -209
  206. package/src/Payment/Modal/PaymentDone.jsx +0 -27
  207. package/src/Payment/Modal/index.js +0 -13
  208. package/src/Payment/actions.jsx +0 -22
  209. package/src/Payment/index.jsx +0 -124
  210. package/src/Payment/request.js +0 -50
  211. package/src/Payment/types.js +0 -14
  212. package/src/Payment/util.jsx +0 -52
  213. package/src/Payment/validate.js +0 -25
  214. package/src/Sidebar.jsx +0 -158
  215. package/src/Things.jsx +0 -35
  216. package/src/actions.js +0 -36
  217. package/src/config.js +0 -7
  218. package/src/dev/ErrorBoundary.jsx +0 -98
  219. package/src/dev/TheError.jsx +0 -87
  220. package/src/dev/index.js +0 -127
  221. package/src/dev/types.js +0 -10
  222. package/src/prod/SentryErrorBoundary.jsx +0 -98
  223. package/src/reducer/captchas.js +0 -44
  224. package/src/reducer/counties.js +0 -46
  225. package/src/reducer/index.js +0 -25
  226. package/src/reducer/module.jsx +0 -43
  227. package/src/style/.sass-lint.yml +0 -84
  228. package/src/style/.stylelintrc.json +0 -161
  229. package/src/style/_fancy-text.scss +0 -37
  230. package/src/style/_fix_bootstrap_placeholder_color.scss +0 -14
  231. package/src/style/_header-company.scss +0 -69
  232. package/src/style/_inputs.scss +0 -12
  233. package/src/style/_minimal.scss +0 -31
  234. package/src/style/_navigation.scss +0 -24
  235. package/src/style/_others.scss +0 -79
  236. package/src/style/index.scss +0 -7
  237. package/src/style/sidebar/_animations.scss +0 -21
  238. package/src/style/sidebar/_dark-theme.scss +0 -77
  239. package/src/style/sidebar/_scroll.scss +0 -37
  240. package/src/style/sidebar/_structure.scss +0 -299
  241. package/src/style/sidebar.scss +0 -4
  242. package/src/types.js +0 -31
  243. package/src/utility/calendar.js +0 -39
  244. package/src/utility/date.js +0 -100
  245. package/src/utility/index.js +0 -12
  246. package/src/utility/language.js +0 -17
  247. package/src/utility/mql.js +0 -3
  248. package/src/utility/normalize-test.js +0 -58
  249. package/src/utility/normalize.js +0 -119
  250. package/src/utility/numbers.js +0 -87
  251. package/src/utility/numeric.js +0 -114
  252. package/src/utility/others.jsx +0 -160
  253. package/src/utility/strings-test.js +0 -136
  254. package/src/utility/strings.js +0 -80
  255. package/src/utility/validation/common.js +0 -360
  256. package/src/utility/validation/index.js +0 -70
  257. package/src/utility/validation/specific.js +0 -9
  258. package/src/utility/validation/validate/bank-test.js +0 -129
  259. package/src/utility/validation/validate/bank.js +0 -176
  260. package/src/utility/validation/validate/cif-test.js +0 -105
  261. package/src/utility/validation/validate/cif.js +0 -44
  262. package/src/utility/validation/validate/cnp-test.js +0 -216
  263. package/src/utility/validation/validate/cnp.js +0 -261
  264. package/src/utility/validation/validate/email-test.js +0 -36
  265. package/src/utility/validation/validate/email.js +0 -6
  266. package/src/utility/validation/validate/index.js +0 -7
  267. package/webpack.config.js +0 -90
  268. package/x25.wiki/Account.md +0 -41
  269. package/x25.wiki/Company.md +0 -39
  270. package/x25.wiki/Header.md +0 -21
  271. package/x25.wiki/Home.md +0 -1
  272. package/x25.wiki/Inputs.md +0 -33
  273. package/x25.wiki/Messages.md +0 -27
  274. package/x25.wiki/Payment.md +0 -42
@@ -1,131 +0,0 @@
1
- // @flow
2
-
3
- type CaptchaPropTypes = {
4
- +type: string;
5
- +id: string;
6
- +tabIndex?: string;
7
- +input: any;
8
- +label: string;
9
- +autoFocus?: boolean;
10
- +left?: string;
11
- +right?: string;
12
- +meta: {
13
- touched: boolean;
14
- error?: any;
15
- submitting: boolean;
16
- }
17
- };
18
-
19
- type InfoIconStateTypes = {
20
- showTooltip: boolean;
21
- };
22
-
23
-
24
- import React from "react";
25
- import { Tooltip } from "reactstrap";
26
- import classnames from "classnames";
27
-
28
- class InfoIcon extends React.Component<{}, InfoIconStateTypes> {
29
-
30
- state: InfoIconStateTypes;
31
-
32
- toggle: () => void;
33
-
34
- constructor (props) {
35
- super(props);
36
-
37
- this.state = {
38
- showTooltip: false,
39
- };
40
-
41
- this.toggle = () => {
42
- this.setState((prevState : InfoIconStateTypes) => ({
43
- showTooltip: !prevState.showTooltip,
44
- }));
45
- };
46
- }
47
-
48
- render () {
49
- return (
50
- <div className="d-inline float-right">
51
- <i
52
- className="fa fa-info-circle fa-2x text-info pull-right"
53
- id="TooltipExample"
54
- />
55
- <Tooltip
56
- isOpen={this.state.showTooltip}
57
- placement="right"
58
- target="TooltipExample"
59
- toggle={this.toggle}>
60
- {`Scopul acestei verificări este de a deosebi o personă de un robot.
61
- De obicei, acest cod apare atunci cand se fololește excesiv
62
- o functionalitate din aplicație`}
63
- </Tooltip>
64
- </div>
65
- );
66
- }
67
- }
68
-
69
- export const CaptchaBox = (props : CaptchaPropTypes) => {
70
- const {
71
- autoFocus,
72
- id,
73
- input,
74
- tabIndex,
75
- label,
76
- left,
77
- right,
78
- meta: { touched, error, submitting },
79
- type,
80
- } = props;
81
-
82
- if (typeof id === "undefined" || id === "") {
83
- return null;
84
- }
85
-
86
- return (
87
- <div className="form-group row">
88
- <label
89
- className={`${left ? left : "col-md-4 text-md-right"} form-control-label`}
90
- htmlFor={input.name}>
91
- {"Verificare "}
92
- <InfoIcon />
93
- </label>
94
- <div className={right ? right : "col-md-8"}>
95
- <div className="custom-class">
96
- <span className="custom-control-description text-muted">
97
- {"Tastează numere din imaginea de mai jos"}
98
- </span>
99
- <div className="text-center my-1">
100
- <img
101
- alt="CaptchaBox"
102
- src={`/captcha/${id}.png`}
103
- />
104
- </div>
105
- </div>
106
- <input
107
- {...input}
108
- aria-label={label}
109
- autoFocus={autoFocus}
110
- className={classnames("form-control", {
111
- "is-invalid": touched && error,
112
- })}
113
- disabled={submitting}
114
- id={input.name}
115
- placeholder="Tastează numerele"
116
- tabIndex={tabIndex}
117
- type={type}
118
- />
119
- <div className="invalid-feedback">
120
- {
121
- touched && error ? (
122
- <span>
123
- {error}
124
- </span>
125
- ) : null
126
- }
127
- </div>
128
- </div>
129
- </div>
130
- );
131
- };
@@ -1,188 +0,0 @@
1
- // @flow
2
- /* eslint-disable */
3
-
4
- type DateInputPropTypes = {
5
- +customClass?: any;
6
- +input: any;
7
- +meta: {
8
- error?: string;
9
- submitting: boolean;
10
- touched: boolean;
11
- };
12
- +placeholder?: string;
13
- +value?: string;
14
- +tabIndex?: string;
15
- +currency?: boolean;
16
-
17
- +formatValue: (raw: string) => string;
18
- +normalizeValue: (raw: string) => any;
19
- +onBlur?: () => void;
20
- +onChange?: (event : any) => void;
21
- +onRegisterRef?: (callback : (node : any) => void) => void;
22
- };
23
-
24
- type DateInputStateTypes = {
25
- value: string,
26
- };
27
-
28
- import React from "react";
29
- import classnames from "classnames";
30
-
31
- import {
32
- formatDate,
33
- isValidDate,
34
- normalizeDate,
35
- } from "../utility";
36
-
37
- const normalizeRawDate = (raw : string) : string => {
38
-
39
- /* eslint-disable no-magic-numbers */
40
-
41
- if (isValidDate(raw)) {
42
- return normalizeDate(raw);
43
- }
44
-
45
- return raw;
46
- };
47
-
48
- const formatRawDate = (raw : string) : string => {
49
-
50
- /* eslint-disable no-magic-numbers */
51
-
52
-
53
- if (typeof raw !== "undefined") {
54
- return formatDate(raw);
55
- }
56
-
57
- return "";
58
- };
59
-
60
- export class DateInput extends React.Component<DateInputPropTypes, DateInputStateTypes> {
61
-
62
- static defaultProps = {
63
- formatValue : formatRawDate,
64
- normalizeValue : normalizeRawDate,
65
- }
66
-
67
- props: DateInputPropTypes;
68
-
69
- state: DateInputStateTypes;
70
-
71
- handleBlur: () => void;
72
- handleKeyDown: (event : any) => void;
73
- handleChange: () => void;
74
-
75
- constructor (props : DateInputPropTypes) {
76
- super();
77
-
78
- this.state = {
79
- value: formatRawDate(props.input.value),
80
- };
81
-
82
- this.handleKeyDown = (event : any) => {
83
- if (event.key === "Enter") {
84
- this.handleBlur();
85
- }
86
- };
87
-
88
- this.handleBlur = () => {
89
- const { onBlur } = this.props.input;
90
-
91
- const { input, normalizeValue } = this.props;
92
-
93
- const { value: currentValue } = this.state;
94
-
95
- const normalizedValue = normalizeValue(currentValue),
96
- shouldRenderAgain = (
97
- (normalizedValue !== "") &&
98
- (currentValue !== normalizedValue)
99
- );
100
-
101
- input.onChange(normalizedValue);
102
-
103
- /*
104
- * Swallow the event to prevent Redux Form from
105
- * extracting the form value
106
- */
107
- onBlur();
108
-
109
- if (shouldRenderAgain) {
110
- this.setState({
111
- value: formatDate(normalizedValue),
112
- });
113
- }
114
- };
115
-
116
- this.handleChange = ({ target : { value } } : any) => {
117
- this.props.input.onChange();
118
-
119
- /*
120
- * Update the internal state to trigger a re-render
121
- * using the formatted value
122
- */
123
- this.setState({ value });
124
- };
125
- }
126
-
127
- UNSAFE_componentWillReceiveProps (nextProps : DateInputPropTypes) {
128
- const {
129
- input: {
130
- value: newValue,
131
- },
132
- } = nextProps;
133
-
134
- const { value: currentValue } = this.state;
135
-
136
- const shouldRenderAgain = (
137
- isValidDate(newValue) &&
138
- (currentValue !== newValue)
139
- );
140
-
141
- if (newValue === "") {
142
- this.setState({
143
- value: "",
144
- });
145
- }
146
-
147
- if (shouldRenderAgain) {
148
- this.setState({
149
- value: formatDate(newValue),
150
- });
151
- }
152
- }
153
-
154
- render () {
155
- const {
156
- customClass,
157
- input,
158
- onRegisterRef,
159
- meta: {
160
- submitting,
161
- touched,
162
- error,
163
- },
164
- tabIndex,
165
- formatValue,
166
- placeholder,
167
- } = this.props;
168
-
169
- return (
170
- <input
171
- {...input}
172
- className={classnames(`form-control ${(customClass || "")}`, {
173
- "is-invalid": touched && error,
174
- })}
175
- disabled={submitting}
176
- id={input.name}
177
- onBlur={this.handleBlur}
178
- onChange={this.handleChange}
179
- onKeyDown={this.handleKeyDown}
180
- placeholder={placeholder || "ZZ.LL.ANUL"}
181
- ref={onRegisterRef}
182
- tabIndex={tabIndex}
183
- type="text"
184
- value={formatValue(this.state.value)}
185
- />
186
- );
187
- }
188
- }
@@ -1,213 +0,0 @@
1
- // @flow
2
- /* eslint-disable */
3
-
4
- type DateTemplatePropTypes = {
5
- +customClass?: any;
6
- +input: any;
7
- +label?: string;
8
- +meta: {
9
- error?: string;
10
- submitting: boolean;
11
- touched: boolean;
12
- };
13
- +left?: string;
14
- +right?: string;
15
- +placeholder?: string;
16
- +value?: string;
17
- +tabIndex?: string;
18
- +currency?: boolean;
19
-
20
- +formatValue: (raw: string) => string;
21
- +normalizeValue: (raw: string) => any;
22
- +onBlur?: () => void;
23
- +onChange?: (event : any) => void;
24
- +onRegisterRef?: (callback : (node : any) => void) => void;
25
- };
26
-
27
- type DateTemplateStateTypes = {
28
- value: string,
29
- };
30
-
31
- import React from "react";
32
- import classnames from "classnames";
33
-
34
- import {
35
- formatDate,
36
- isValidDate,
37
- normalizeDate,
38
- } from "../utility";
39
-
40
- const normalizeRawDate = (raw : string) : string => {
41
-
42
- /* eslint-disable no-magic-numbers */
43
-
44
- if (isValidDate(raw)) {
45
- return normalizeDate(raw);
46
- }
47
-
48
- return raw;
49
- };
50
-
51
- const formatRawDate = (raw : string) : string => {
52
-
53
- /* eslint-disable no-magic-numbers */
54
-
55
-
56
- if (typeof raw !== "undefined") {
57
- return formatDate(raw);
58
- }
59
-
60
- return "";
61
- };
62
-
63
- export class DateTemplate extends React.Component<DateTemplatePropTypes, DateTemplateStateTypes> {
64
-
65
- static defaultProps = {
66
- formatValue : formatRawDate,
67
- normalizeValue : normalizeRawDate,
68
- }
69
-
70
- props: DateTemplatePropTypes;
71
-
72
- state: DateTemplateStateTypes;
73
-
74
- handleBlur: () => void;
75
- handleKeyDown: (event : any) => void;
76
- handleChange: () => void;
77
-
78
- constructor (props : DateTemplatePropTypes) {
79
- super();
80
-
81
- this.state = {
82
- value: formatRawDate(props.input.value),
83
- };
84
-
85
- this.handleKeyDown = (event : any) => {
86
- if (event.key === "Enter") {
87
- this.handleBlur();
88
- }
89
- };
90
-
91
- this.handleBlur = () => {
92
- const { onBlur } = this.props.input;
93
-
94
- const { input, normalizeValue } = this.props;
95
-
96
- const { value: currentValue } = this.state;
97
-
98
- const normalizedValue = normalizeValue(currentValue),
99
- shouldRenderAgain = (
100
- (normalizedValue !== "") &&
101
- (currentValue !== normalizedValue)
102
- );
103
-
104
- input.onChange(normalizedValue);
105
-
106
- /*
107
- * Swallow the event to prevent Redux Form from
108
- * extracting the form value
109
- */
110
- onBlur();
111
-
112
- if (shouldRenderAgain) {
113
- this.setState({
114
- value: formatDate(normalizedValue),
115
- });
116
- }
117
- };
118
-
119
- this.handleChange = ({ target : { value } } : any) => {
120
- this.props.input.onChange();
121
-
122
- /*
123
- * Update the internal state to trigger a re-render
124
- * using the formatted value
125
- */
126
- this.setState({ value });
127
- };
128
- }
129
-
130
- UNSAFE_componentWillReceiveProps (nextProps : DateTemplatePropTypes) {
131
- const {
132
- input: {
133
- value: newValue,
134
- },
135
- } = nextProps;
136
-
137
- const { value: currentValue } = this.state;
138
-
139
- const shouldRenderAgain = (
140
- isValidDate(newValue) &&
141
- (currentValue !== newValue)
142
- );
143
-
144
- if (newValue === "") {
145
- this.setState({
146
- value: "",
147
- });
148
- }
149
-
150
- if (shouldRenderAgain) {
151
- this.setState({
152
- value: formatDate(newValue),
153
- });
154
- }
155
- }
156
-
157
- render () {
158
- const {
159
- customClass,
160
- input,
161
- label,
162
- onRegisterRef,
163
- meta: {
164
- submitting,
165
- touched,
166
- error,
167
- },
168
- left,
169
- right,
170
- tabIndex,
171
- formatValue,
172
- placeholder,
173
- } = this.props;
174
-
175
- return (
176
- <div className={classnames("form-group row", { "is-invalid": touched && error })}>
177
- <label
178
- className={`${left ? left : "col-md-4 text-md-right"} form-control-label`}
179
- htmlFor={input.name}>
180
- {label}
181
- </label>
182
- <div className={right ? right : "col-md-8"}>
183
- <input
184
- {...input}
185
- aria-label={label}
186
- className={classnames(`form-control ${(customClass || "")}`, {
187
- "is-invalid": touched && error,
188
- })}
189
- disabled={submitting}
190
- id={input.name}
191
- onBlur={this.handleBlur}
192
- onChange={this.handleChange}
193
- onKeyDown={this.handleKeyDown}
194
- placeholder={placeholder || "ZZ.LL.ANUL"}
195
- ref={onRegisterRef}
196
- tabIndex={tabIndex}
197
- type="text"
198
- value={formatValue(this.state.value)}
199
- />
200
- <div className="invalid-feedback">
201
- {
202
- touched && error && (
203
- <span>
204
- {error}
205
- </span>
206
- )
207
- }
208
- </div>
209
- </div>
210
- </div>
211
- );
212
- }
213
- }
@@ -1,130 +0,0 @@
1
- // @flow
2
- /* eslint-disable */
3
-
4
- import React from "react";
5
-
6
- type TypeInputPropTypes = {
7
- +change : (event : any) => void;
8
- +value: any;
9
- +tabIndex?: string;
10
- +delay?: number;
11
- };
12
-
13
- type TypeInputStateTypes = {
14
- value: string;
15
- isWaiting: bool;
16
- };
17
-
18
- const delay = 700;
19
-
20
- import { LoadingMessage } from "../Messages";
21
-
22
- export class DelayInputChange extends React.Component<TypeInputPropTypes, TypeInputStateTypes> {
23
- props: TypeInputPropTypes;
24
- state: TypeInputStateTypes;
25
-
26
- timeout: any;
27
-
28
- delayChange: (event : any) => void;
29
- handleKeyPressed: (event : any) => void;
30
- stopWaiting: (value : string) => void;
31
-
32
- constructor (props : TypeInputPropTypes) {
33
- super(props);
34
-
35
- this.timeout = null;
36
-
37
- this.state = {
38
- isWaiting : false,
39
- value : this.props.value,
40
- };
41
-
42
- this.handleKeyPressed = (event : any) => {
43
- if (event.key === "Enter") {
44
- this.stopWaiting(this.state.value);
45
- }
46
- };
47
-
48
- this.stopWaiting = (value :string) => {
49
- clearTimeout(this.timeout);
50
-
51
- this.setState({
52
- isWaiting: false,
53
- value,
54
- }, () => {
55
- this.props.change({
56
- target: {
57
- value,
58
- },
59
- });
60
- });
61
- };
62
-
63
- this.delayChange = ({ target : { value } }) => {
64
- clearTimeout(this.timeout);
65
-
66
- if (value === "") {
67
- this.stopWaiting(value);
68
- } else {
69
- const that = this;
70
-
71
- that.setState({
72
- isWaiting: true,
73
- value,
74
- }, () => {
75
-
76
- that.timeout = setTimeout(() => {
77
- that.setState({
78
- isWaiting: false,
79
- });
80
- that.props.change({
81
- target: {
82
- value,
83
- },
84
- });
85
- }, this.props.delay || delay);
86
- });
87
- }
88
- };
89
- }
90
-
91
- UNSAFE_componentWillReceiveProps (nextProps : TypeInputPropTypes) {
92
- if (this.props.value !== nextProps.value) {
93
- this.setState({
94
- value: nextProps.value,
95
- });
96
- }
97
- }
98
-
99
- shouldComponentUpdate (nextProps : TypeInputPropTypes, nextState :TypeInputStateTypes) {
100
- return (
101
- this.props.value !== nextProps.value ||
102
- this.state.value !== nextState.value ||
103
- this.state.isWaiting !== nextState.isWaiting
104
- );
105
- }
106
-
107
- render () {
108
- const { value, isWaiting } = this.state;
109
-
110
- const { tabIndex } = this.props;
111
-
112
- return (
113
- <div className="delay-input">
114
- <input
115
- {...this.props}
116
- change=""
117
- onChange={this.delayChange}
118
- onKeyPress={this.handleKeyPressed}
119
- tabIndex={tabIndex}
120
- value={value}
121
- />
122
- {
123
- isWaiting ? (
124
- <LoadingMessage className="loading-spinner d-inline-block" sm />
125
- ) : null
126
- }
127
- </div>
128
- );
129
- }
130
- }
@@ -1,41 +0,0 @@
1
- // @flow
2
- /* eslint-disable react/prefer-stateless-function, react/require-optimization */
3
-
4
- type FocusTemplatePropTypes = {
5
- +autoFocus?: boolean;
6
- +input: any;
7
- +label: string;
8
- +placeholder: string;
9
- +type: string;
10
- +meta: {
11
- submitting: boolean;
12
- touched: boolean;
13
- error?: any;
14
- };
15
-
16
- +onRegisterRef: (callback : (node : any) => void) => void;
17
- };
18
-
19
- import React from "react";
20
-
21
- import { InputTemplate } from "./InputTemplate";
22
-
23
- export class FocusTemplate extends React.Component<FocusTemplatePropTypes> {
24
- props: FocusTemplatePropTypes;
25
-
26
- shouldComponentUpdate (nextProps: FocusTemplatePropTypes) {
27
- return (
28
- this.props.input !== nextProps.input ||
29
- this.props.label !== nextProps.label ||
30
- this.props.meta.submitting !== nextProps.meta.submitting ||
31
- this.props.meta.touched !== nextProps.meta.touched ||
32
- this.props.meta.error !== nextProps.meta.error
33
- );
34
- }
35
-
36
- render () {
37
- return (
38
- <InputTemplate {...this.props} />
39
- );
40
- }
41
- }