siam-ui-utils 2.0.24 → 2.0.26

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/src/index.css ADDED
@@ -0,0 +1,74 @@
1
+ :root {
2
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 0.2;
4
+ font-weight: 400;
5
+
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ }
15
+
16
+ a {
17
+ font-weight: 500;
18
+ color: #646cff;
19
+ text-decoration: inherit;
20
+ }
21
+ a:hover {
22
+ color: #535bf2;
23
+ }
24
+
25
+ body {
26
+ margin: 0;
27
+ display: flex;
28
+ place-items: center;
29
+ min-width: 320px;
30
+ min-height: 100vh;
31
+ }
32
+
33
+ h1 {
34
+ font-size: 1.2em;
35
+ line-height: 1.1;
36
+ }
37
+
38
+ h2 {
39
+ font-size: 1.2em;
40
+ line-height: 1.1;
41
+ }
42
+
43
+
44
+ button {
45
+ border-radius: 8px;
46
+ border: 1px solid transparent;
47
+ padding: 0.6em 1.2em;
48
+ font-size: 1em;
49
+ font-weight: 500;
50
+ font-family: inherit;
51
+ background-color: #1a1a1a;
52
+ cursor: pointer;
53
+ transition: border-color 0.25s;
54
+ }
55
+ button:hover {
56
+ border-color: #646cff;
57
+ }
58
+ button:focus,
59
+ button:focus-visible {
60
+ outline: 4px auto -webkit-focus-ring-color;
61
+ }
62
+
63
+ @media (prefers-color-scheme: light) {
64
+ :root {
65
+ color: #213547;
66
+ background-color: #ffffff;
67
+ }
68
+ a:hover {
69
+ color: #747bff;
70
+ }
71
+ button {
72
+ background-color: #f9f9f9;
73
+ }
74
+ }
package/src/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export * from './archivos-adjuntos'
2
- export * from './archivos-adjuntos/dropzone-uploader-dni-digital'
3
- export * from './bridges'
4
- export * from './CustomBootstrap'
5
- export * from './CustomSelectInput'
6
- export * from './IntlMessages'
7
- export * from './tomar-foto'
1
+ export * from './archivos-adjuntos';
2
+ export * from './archivos-adjuntos/dropzone-uploader-dni-digital';
3
+ export * from './bridges';
4
+ export * from './CustomBootstrap';
5
+ export * from './CustomSelectInput';
6
+ export * from './tomar-foto';
7
+ export * from './react-notifications';
package/src/main.jsx ADDED
@@ -0,0 +1,7 @@
1
+ import { createRoot } from 'react-dom/client';
2
+ import './assets/css/vendor/bootstrap.min.css';
3
+ import './assets/css/vendor/bootstrap.rtl.only.min.css';
4
+
5
+ import App from './App';
6
+
7
+ createRoot(document.getElementById('root')).render(<App />);
@@ -0,0 +1,89 @@
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;
@@ -0,0 +1,53 @@
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;
@@ -0,0 +1,135 @@
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();
@@ -0,0 +1,66 @@
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;
@@ -0,0 +1,5 @@
1
+ import Notifications from './Notifications';
2
+ import NotificationContainer from './NotificationContainer';
3
+ import NotificationManager from './NotificationManager';
4
+
5
+ export { Notifications, NotificationContainer, NotificationManager };
package/vite.config.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import react from "@vitejs/plugin-react";
2
2
  import { defineConfig } from "vitest/config";
3
- import eslint from 'vite-plugin-eslint';
3
+ import commonjs from 'vite-plugin-commonjs'
4
4
 
5
5
  export default defineConfig({
6
- plugins: [react(), eslint()],
7
- test: {
8
- globals: true,
9
- },
6
+ plugins: [react(), commonjs()],
7
+ css: {
8
+ preprocessorOptions: {
9
+ scss: {
10
+ silenceDeprecations: ['legacy-js-api'],
11
+ },
12
+ },
13
+ },
10
14
  });
package/.eslintrc.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "extends": [
3
- "eslint:recommended",
4
- "plugin:react/recommended",
5
- "plugin:react-hooks/recommended"
6
- ],
7
- "plugins": [
8
- "react",
9
- "react-hooks"
10
- ],
11
- "parserOptions": {
12
- "ecmaVersion": 2020,
13
- "sourceType": "module",
14
- "ecmaFeatures": {
15
- "jsx": true
16
- }
17
- },
18
- "env": {
19
- "browser": true,
20
- "es2020": true
21
- },
22
- "rules": {
23
- "react/react-in-jsx-scope": "off"
24
- }
25
- }
@@ -1,11 +0,0 @@
1
-
2
- import {
3
- FormattedMessage,
4
- injectIntl
5
- } from 'react-intl';
6
-
7
- const _InjectMassage = (props: any) => <FormattedMessage {...props} />;
8
-
9
- export const IntlMessages = injectIntl(_InjectMassage, {
10
- withRef: false,
11
- } as any);