siam-ui-utils 2.0.26 → 2.0.28

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.
@@ -1,66 +1,69 @@
1
- import { useState } from 'react'
2
- import { Row } from 'reactstrap'
3
- import { DropzoneUploader, Colxx } from '../'
4
- import { TAKE_PHOTO } from '../constants'
5
- import imgHacerFoto from '../assets/img/take-photo.png'
1
+ import { useState } from 'react';
2
+ import { Row } from 'reactstrap';
3
+ import { DropzoneUploader, Colxx } from '../';
4
+ import { TAKE_PHOTO } from '../constants';
5
+ import imgHacerFoto from '../assets/img/take-photo.png';
6
6
 
7
7
  // eslint-disable-next-line react/prop-types
8
- export const TomarFoto = ({ onFilesSelectedSelfie, isMobile = false }) => {
9
- const [filesTotalSelectedSelfie, setTotalFilesSelectedSelfie] = useState(0)
10
- const {
11
- LOAD_SELFIE_WITH_IDENTITY_CARD_MESSAGE,
12
- MESSAGE_SELFIE_ONLY_CAN_TAKE_FROM_CELLPHONE,
13
- TAKE_PHOTO_MESSAGE,
14
- } = TAKE_PHOTO
8
+ export const TomarFoto = ({
9
+ onFilesSelectedSelfie = () => {},
10
+ isMobile = false,
11
+ }) => {
12
+ const [filesTotalSelectedSelfie, setTotalFilesSelectedSelfie] = useState(0);
13
+ const {
14
+ LOAD_SELFIE_WITH_IDENTITY_CARD_MESSAGE,
15
+ MESSAGE_SELFIE_ONLY_CAN_TAKE_FROM_CELLPHONE,
16
+ TAKE_PHOTO_MESSAGE,
17
+ } = TAKE_PHOTO;
15
18
 
16
- const handleFilesSelectedSelfie = (files) => {
17
- setTotalFilesSelectedSelfie(files.length)
18
- onFilesSelectedSelfie(files)
19
- }
19
+ const handleFilesSelectedSelfie = (files) => {
20
+ setTotalFilesSelectedSelfie(files.length);
21
+ onFilesSelectedSelfie(files);
22
+ };
20
23
 
21
- return (
22
- <>
23
- <Row className='pt-2 ml-4'>
24
- <Colxx xxs='11' md='5'>
25
- {LOAD_SELFIE_WITH_IDENTITY_CARD_MESSAGE}
26
- </Colxx>
27
- </Row>
28
- <Row className='pt-2 ml-2'>
29
- <Colxx xxs='12' md='9'>
30
- {isMobile ? (
31
- <>
32
- <Colxx xxs='12' className='text-center'>
33
- {filesTotalSelectedSelfie === 0 && (
34
- <img
35
- style={{ width: '97%' }}
36
- alt='hacerFotoDNI'
37
- src={imgHacerFoto}
38
- />
39
- )}
40
- <DropzoneUploader
41
- className='pt-2 ml-2'
42
- maxFiles={1}
43
- onChangeFiles={handleFilesSelectedSelfie}
44
- totalFiles={filesTotalSelectedSelfie}
45
- accept='image/jpg,image/jpeg'
46
- capture='environment'
47
- nameFileLabel={TAKE_PHOTO_MESSAGE}
48
- />
49
- </Colxx>
50
- </>
51
- ) : (
52
- <h2
53
- className={'view-icon iconsminds-smartphone-4 ml-2 mr-2'}
54
- style={{
55
- color: 'red',
56
- margin: '10px 10px 0px 10px',
57
- }}
58
- >
59
- {MESSAGE_SELFIE_ONLY_CAN_TAKE_FROM_CELLPHONE}
60
- </h2>
61
- )}
62
- </Colxx>
63
- </Row>
64
- </>
65
- )
66
- }
24
+ return (
25
+ <>
26
+ <Row className="pt-2 ml-4">
27
+ <Colxx xxs="11" md="5">
28
+ {LOAD_SELFIE_WITH_IDENTITY_CARD_MESSAGE}
29
+ </Colxx>
30
+ </Row>
31
+ <Row className="pt-2 ml-2">
32
+ <Colxx xxs="12" md="9">
33
+ {isMobile ? (
34
+ <>
35
+ <Colxx xxs="12" className="text-center">
36
+ {filesTotalSelectedSelfie === 0 && (
37
+ <img
38
+ style={{ width: '97%' }}
39
+ alt="hacerFotoDNI"
40
+ src={imgHacerFoto}
41
+ />
42
+ )}
43
+ <DropzoneUploader
44
+ className="pt-2 ml-2"
45
+ maxFiles={1}
46
+ onChangeFiles={handleFilesSelectedSelfie}
47
+ totalFiles={filesTotalSelectedSelfie}
48
+ accept="image/jpg,image/jpeg"
49
+ capture="environment"
50
+ nameFileLabel={TAKE_PHOTO_MESSAGE}
51
+ />
52
+ </Colxx>
53
+ </>
54
+ ) : (
55
+ <h2
56
+ className={'view-icon iconsminds-smartphone-4 ml-2 mr-2'}
57
+ style={{
58
+ color: 'red',
59
+ margin: '10px 10px 0px 10px',
60
+ }}
61
+ >
62
+ {MESSAGE_SELFIE_ONLY_CAN_TAKE_FROM_CELLPHONE}
63
+ </h2>
64
+ )}
65
+ </Colxx>
66
+ </Row>
67
+ </>
68
+ );
69
+ };
package/vite.config.ts CHANGED
@@ -4,6 +4,11 @@ import commonjs from 'vite-plugin-commonjs'
4
4
 
5
5
  export default defineConfig({
6
6
  plugins: [react(), commonjs()],
7
+ server: {
8
+ port: 5173,
9
+ open: true,
10
+ hmr: true
11
+ },
7
12
  css: {
8
13
  preprocessorOptions: {
9
14
  scss: {
@@ -1,89 +0,0 @@
1
- import { useEffect } from 'react';
2
- import PropTypes from 'prop-types';
3
- import classnames from 'classnames';
4
-
5
- const Notification = ({
6
- title,
7
- type,
8
- message,
9
- customClassName,
10
- timeOut,
11
- onClick,
12
- onRequestHide,
13
- }) => {
14
- const requestHide = () => {
15
- if (onRequestHide) {
16
- onRequestHide();
17
- }
18
- };
19
-
20
- useEffect(() => {
21
- let timer = null;
22
- if (timeOut !== 0) {
23
- timer = setTimeout(requestHide, timeOut);
24
- }
25
- return () => {
26
- if (timer) {
27
- clearTimeout(timer);
28
- }
29
- };
30
- // eslint-disable-next-line react-hooks/exhaustive-deps
31
- }, []);
32
-
33
- const handleClick = () => {
34
- if (onClick) {
35
- onClick();
36
- }
37
- requestHide();
38
- };
39
-
40
- const className = classnames([
41
- 'notification',
42
- `notification-${type}`,
43
- customClassName,
44
- ]);
45
- const titleHtml = title ? <h4 className="title">{title}</h4> : null;
46
- return (
47
- <div className={className} onClick={() => handleClick()}>
48
- <div className="notification-message" role="alert">
49
- {titleHtml}
50
- <div className="message">{message}</div>
51
- </div>
52
- </div>
53
- );
54
- };
55
-
56
- Notification.propTypes = {
57
- type: PropTypes.oneOf([
58
- 'info',
59
- 'success',
60
- 'warning',
61
- 'error',
62
- 'primary',
63
- 'secondary',
64
- ]),
65
- title: PropTypes.node,
66
- message: PropTypes.node,
67
- timeOut: PropTypes.number,
68
- onClick: PropTypes.func,
69
- onRequestHide: PropTypes.func,
70
- customClassName: PropTypes.string,
71
- };
72
-
73
- Notification.defaultProps = {
74
- type: 'info',
75
- title: null,
76
- message: null,
77
- timeOut: 5000,
78
-
79
- onClick: () => {
80
- undefined;
81
- },
82
- onRequestHide: () => {
83
- undefined;
84
- },
85
-
86
- customClassName: '',
87
- };
88
-
89
- export default Notification;
@@ -1,53 +0,0 @@
1
- import { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
- import NotificationManager from './NotificationManager';
4
- import Notifications from './Notifications';
5
-
6
- class NotificationContainer extends Component {
7
- constructor(props) {
8
- super(props);
9
- NotificationManager.addChangeListener(this.handleStoreChange);
10
- this.state = {
11
- notifications: [],
12
- };
13
- }
14
-
15
- componentWillUnmount = () => {
16
- NotificationManager.removeChangeListener(this.handleStoreChange);
17
- };
18
-
19
- handleStoreChange = (notifications) => {
20
- this.setState({
21
- notifications,
22
- });
23
- };
24
-
25
- handleRequestHide = (notification) => {
26
- NotificationManager.remove(notification);
27
- };
28
-
29
- render() {
30
- const { notifications } = this.state;
31
- const { enterTimeout, leaveTimeout } = this.props;
32
- return (
33
- <Notifications
34
- enterTimeout={enterTimeout}
35
- leaveTimeout={leaveTimeout}
36
- notifications={notifications}
37
- onRequestHide={this.handleRequestHide}
38
- />
39
- );
40
- }
41
- }
42
-
43
- NotificationContainer.propTypes = {
44
- enterTimeout: PropTypes.number,
45
- leaveTimeout: PropTypes.number,
46
- };
47
-
48
- NotificationContainer.defaultProps = {
49
- enterTimeout: 400,
50
- leaveTimeout: 400,
51
- };
52
-
53
- export default NotificationContainer;
@@ -1,135 +0,0 @@
1
- import { EventEmitter } from "events";
2
-
3
- const createUUID = () => {
4
- const pattern = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
5
- return pattern.replace(/[xy]/g, (c) => {
6
- const r = (Math.random() * 16) | 0;
7
- const v = c === "x" ? r : (r & 0x3) | 0x8;
8
- return v.toString(16);
9
- });
10
- };
11
-
12
- const Constants = {
13
- CHANGE: "change",
14
- PRIMARY: "primary",
15
- SECONDARY: "secondary",
16
- INFO: "info",
17
- SUCCESS: "success",
18
- WARNING: "warning",
19
- ERROR: "error",
20
- };
21
-
22
- class NotificationManager extends EventEmitter {
23
- constructor() {
24
- super();
25
- this.listNotify = [];
26
- }
27
-
28
- create(notify) {
29
- const defaultNotify = {
30
- id: createUUID(),
31
- type: "info",
32
- title: null,
33
- message: null,
34
- timeOut: 3000,
35
- customClassName: "",
36
- };
37
- if (notify.priority) {
38
- this.listNotify.unshift(Object.assign(defaultNotify, notify));
39
- } else {
40
- this.listNotify.push(Object.assign(defaultNotify, notify));
41
- }
42
- this.emitChange();
43
- }
44
-
45
- primary(message, title, timeOut, onClick, priority, customClassName) {
46
- this.create({
47
- type: Constants.PRIMARY,
48
- message,
49
- title,
50
- timeOut,
51
- onClick,
52
- priority,
53
- customClassName,
54
- });
55
- }
56
-
57
- secondary(message, title, timeOut, onClick, priority, customClassName) {
58
- this.create({
59
- type: Constants.SECONDARY,
60
- message,
61
- title,
62
- timeOut,
63
- onClick,
64
- priority,
65
- customClassName,
66
- });
67
- }
68
-
69
- info(message, title, timeOut, onClick, priority, customClassName) {
70
- this.create({
71
- type: Constants.INFO,
72
- message,
73
- title,
74
- timeOut,
75
- onClick,
76
- priority,
77
- customClassName,
78
- });
79
- }
80
-
81
- success(message, title, timeOut, onClick, priority, customClassName) {
82
- this.create({
83
- type: Constants.SUCCESS,
84
- message,
85
- title,
86
- timeOut,
87
- onClick,
88
- priority,
89
- customClassName,
90
- });
91
- }
92
-
93
- warning(message, title, timeOut, onClick, priority, customClassName) {
94
- this.create({
95
- type: Constants.WARNING,
96
- message,
97
- title,
98
- timeOut,
99
- onClick,
100
- priority,
101
- customClassName,
102
- });
103
- }
104
-
105
- error(message, title, timeOut, onClick, priority, customClassName) {
106
- this.create({
107
- type: Constants.ERROR,
108
- message,
109
- title,
110
- timeOut,
111
- onClick,
112
- priority,
113
- customClassName,
114
- });
115
- }
116
-
117
- remove(notification) {
118
- this.listNotify = this.listNotify.filter((n) => notification.id !== n.id);
119
- this.emitChange();
120
- }
121
-
122
- emitChange() {
123
- this.emit(Constants.CHANGE, this.listNotify);
124
- }
125
-
126
- addChangeListener(callback) {
127
- this.addListener(Constants.CHANGE, callback);
128
- }
129
-
130
- removeChangeListener(callback) {
131
- this.removeListener(Constants.CHANGE, callback);
132
- }
133
- }
134
-
135
- export default new NotificationManager();
@@ -1,66 +0,0 @@
1
- import { Component } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { TransitionGroup, CSSTransition } from 'react-transition-group';
4
- import classnames from 'classnames';
5
- import Notification from './Notification';
6
-
7
- class Notifications extends Component {
8
- handleRequestHide = (notification) => () => {
9
- const { onRequestHide } = this.props;
10
- if (onRequestHide) {
11
- onRequestHide(notification);
12
- }
13
- };
14
-
15
- render() {
16
- const { notifications, enterTimeout, leaveTimeout } = this.props;
17
- const className = classnames('notification-container', {
18
- 'notification-container-empty': notifications.length === 0,
19
- });
20
- return (
21
- <div className={className}>
22
- <TransitionGroup>
23
- {notifications.map((notification) => {
24
- const key = notification.id || new Date().getTime();
25
- return (
26
- <CSSTransition
27
- classNames="notification"
28
- key={key}
29
- timeout={{ exit: leaveTimeout, enter: enterTimeout }}
30
- >
31
- <Notification
32
- key={key}
33
- type={notification.type}
34
- title={notification.title}
35
- message={notification.message}
36
- timeOut={notification.timeOut}
37
- onClick={notification.onClick}
38
- onRequestHide={this.handleRequestHide(notification)}
39
- customClassName={notification.customClassName}
40
- />
41
- </CSSTransition>
42
- );
43
- })}
44
- </TransitionGroup>
45
- </div>
46
- );
47
- }
48
- }
49
- Notifications.propTypes = {
50
- notifications: PropTypes.array,
51
- onRequestHide: PropTypes.func,
52
- enterTimeout: PropTypes.number,
53
- leaveTimeout: PropTypes.number,
54
- };
55
-
56
- Notifications.defaultProps = {
57
- notifications: [],
58
-
59
- onRequestHide: () => {
60
- undefined;
61
- },
62
-
63
- enterTimeout: 400,
64
- leaveTimeout: 400,
65
- };
66
- export default Notifications;
@@ -1,5 +0,0 @@
1
- import Notifications from './Notifications';
2
- import NotificationContainer from './NotificationContainer';
3
- import NotificationManager from './NotificationManager';
4
-
5
- export { Notifications, NotificationContainer, NotificationManager };