siam-ui-utils 2.2.20 → 2.2.21

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/index.d.ts CHANGED
@@ -9,6 +9,9 @@ declare module 'siam-ui-utils' {
9
9
  //CUSTOMSELECTINPUT
10
10
  export function CustomSelectInput(props);
11
11
 
12
+ //CUSTOMSELECT
13
+ export function CustomSelect(props);
14
+
12
15
  //CUSTOMINPUTCHECKBOX
13
16
  export function CustomInputCheckbox(props);
14
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siam-ui-utils",
3
- "version": "2.2.20",
3
+ "version": "2.2.21",
4
4
  "keywords": [
5
5
  "ampf-react",
6
6
  "ampf-utils",
@@ -35,6 +35,7 @@
35
35
  "react-router-dom": "^6.26.2",
36
36
  "react-select": "^5.8.0",
37
37
  "reactstrap": "^9.2.2",
38
+ "react-tagsinput": "^3.20.3",
38
39
  "siam-utils": "^1.1.4",
39
40
  "source-map-loader": "^5.0.0",
40
41
  "styled-components": "^6.1.12",
package/src/App.jsx CHANGED
@@ -5,31 +5,37 @@ import {
5
5
  AccordionHeader,
6
6
  AccordionItem,
7
7
  } from 'reactstrap';
8
- import { TomarFoto, DropzoneUploader, DropzoneUploaderDniDigital } from './';
9
- import { CustomInputRadio, CustomInputCheckbox } from './custom-input';
10
- import './index.css';
8
+ import {
9
+ CopyLinkView,
10
+ CustomInputsView,
11
+ CustomSelectView,
12
+ DropzoneUploaderDniDigitalView,
13
+ DropzoneUploaderFirmaDigitalView,
14
+ DropzoneUploaderView,
15
+ TimerView,
16
+ VideoCallView,
17
+ ViewLayoutView,
18
+ } from './test-resources';
11
19
  import './App.css';
12
20
  import './assets/css/vendor/bootstrap.min.css';
13
- import { WhereByRoom } from './where-by-room';
14
- import { ViewLayout } from './view-layout';
15
- import { CopyLink } from './copy-link';
16
- import { Timer } from './timer';
21
+ import './index.css';
17
22
 
18
- const slots = [
23
+ const views = [
24
+ { title: 'CopyLink', component: <CopyLinkView /> },
25
+ { title: 'CustomInputs', component: <CustomInputsView /> },
26
+ { title: 'CustomSelect', component: <CustomSelectView /> },
27
+ {
28
+ title: 'DropzoneDniDigital',
29
+ component: <DropzoneUploaderDniDigitalView />,
30
+ },
19
31
  {
20
- slot: 1,
21
- x: 3,
22
- y: 3,
23
- w: 2,
24
- h: 2,
25
- legend: 'Prueba',
26
- direction: 'column',
27
- contentSize: 'medium',
28
- align: 'stretch',
29
- justify: 'flex-start',
30
- component: null,
31
- showBorder: true,
32
+ title: 'DropZoneFirmaDigital',
33
+ component: <DropzoneUploaderFirmaDigitalView />,
32
34
  },
35
+ { title: 'DropzoneUploader', component: <DropzoneUploaderView /> },
36
+ { title: 'Timer', component: <TimerView /> },
37
+ { title: 'VideoCall', component: <VideoCallView /> },
38
+ { title: 'ViewLayoutGenerico', component: <ViewLayoutView /> },
33
39
  ];
34
40
 
35
41
  const App = () => {
@@ -42,118 +48,18 @@ const App = () => {
42
48
  }
43
49
  };
44
50
 
45
- const handleChecked = (item, isSelected) => {
46
- console.log('Item checked:', item, 'Selected:', isSelected);
47
- };
48
-
49
- const handleChangeRadio = (ID) => {
50
- console.log('ID :', ID);
51
- };
52
-
53
51
  return (
54
- <div>
55
- <Accordion open={open} toggle={toggle}>
56
- <AccordionItem>
57
- <AccordionHeader targetId="1">Tomar Foto</AccordionHeader>
58
- <AccordionBody accordionId="1">
59
- <TomarFoto isMobile={true} />
60
- <DropzoneUploader
61
- totalFiles={4}
62
- onChangeFiles={() => alert('onChange')}
63
- maxFiles={3}
64
- nameFileLabel="file"
65
- />
66
- </AccordionBody>
67
- </AccordionItem>
68
- <AccordionItem>
69
- <AccordionHeader targetId="2">
70
- DropzoneUploader Firma Digital
71
- </AccordionHeader>
72
- <AccordionBody accordionId="2">
73
- <DropzoneUploader
74
- totalFiles={0}
75
- onChangeFiles={() => {
76
- console.log('onChange');
77
- }}
78
- maxFiles={7}
79
- nameFileLabel="Subir archivos"
80
- capture="environment"
81
- onFilesSelectedSelfie
82
- />
83
- </AccordionBody>
84
- </AccordionItem>
85
- <AccordionItem>
86
- <AccordionHeader targetId="3">
87
- DropzoneUploader DNI Digital
88
- </AccordionHeader>
89
- <AccordionBody accordionId="3">
90
- <DropzoneUploaderDniDigital
91
- totalFiles={0}
92
- maxFiles={2}
93
- onChangeFiles={() => {
94
- console.log('onChange');
95
- }}
96
- classNames="custom-dropzone-uploader-dni-digital"
97
- />
98
- </AccordionBody>
99
- </AccordionItem>
100
- <AccordionItem>
101
- <AccordionHeader targetId="4">Video Call Room</AccordionHeader>
102
- <AccordionBody accordionId="4">
103
- <WhereByRoom
104
- src="https://whereby.com/test-ampf-room"
105
- title="Videollamada de ejemplo"
106
- />
107
- </AccordionBody>
108
- </AccordionItem>
109
- <AccordionItem>
110
- <AccordionHeader targetId="5">Custom Inputs</AccordionHeader>
111
- <AccordionBody accordionId="5">
112
- <CustomInputCheckbox
113
- className="itemCheck m-0"
114
- id={1}
115
- onChange={(e) => handleChecked(1, e.target.checked)}
116
- label={<span className="custom-checkbox">Checkbox 1</span>}
117
- />
118
- <CustomInputRadio
119
- name="radioTest"
120
- label="1"
121
- id="1"
122
- defaultChecked={true}
123
- onChange={handleChangeRadio}
124
- />
125
- <CustomInputRadio
126
- name="radioTest"
127
- label="2"
128
- id="2"
129
- onChange={handleChangeRadio}
130
- />
131
- </AccordionBody>
132
- </AccordionItem>
133
- <AccordionItem>
134
- <AccordionHeader targetId="6">Copy-Link</AccordionHeader>
135
- <AccordionBody accordionId="6">
136
- <CopyLink link="https://linkdepruebaparaelcopylink.com" />
137
- </AccordionBody>
138
- </AccordionItem>
139
- <AccordionItem>
140
- <AccordionHeader targetId="7">Reusable ViewLayout</AccordionHeader>
141
- <AccordionBody accordionId="7">
142
- <ViewLayout slots={slots} />
143
- </AccordionBody>
144
- </AccordionItem>
145
- <AccordionItem>
146
- <AccordionHeader targetId="8">Timer</AccordionHeader>
147
- <AccordionBody accordionId="8">
148
- <Timer
149
- initialMinutes={2}
150
- active={true}
151
- style={{ color: 'green' }}
152
- />
153
- </AccordionBody>
154
- </AccordionItem>
155
- </Accordion>
156
- </div>
52
+ <Accordion open={open} toggle={toggle}>
53
+ {views.map((view, index) => {
54
+ const { title, component: vista } = view;
55
+ return (
56
+ <AccordionItem key={index}>
57
+ <AccordionHeader targetId={`${index + 1}`}>{title}</AccordionHeader>
58
+ <AccordionBody accordionId={`${index + 1}`}>{vista}</AccordionBody>
59
+ </AccordionItem>
60
+ );
61
+ })}
62
+ </Accordion>
157
63
  );
158
64
  };
159
65
 
package/src/index.js CHANGED
@@ -3,6 +3,7 @@ export * from './dropzone-uploader/dropzone-uploader-dni-digital';
3
3
  export * from './bridges';
4
4
  export * from './CustomBootstrap';
5
5
  export * from './custom-input';
6
+ export * from './select';
6
7
  export * from './CustomSelectInput';
7
8
  export * from './tomar-foto';
8
9
  export * as IntlMessages from './IntlMessages';
@@ -0,0 +1,4 @@
1
+ export const LABELS = {
2
+ SIN_DATOS: "SIN DATOS",
3
+ SELECCIONE: "SELECCIONE...",
4
+ };
@@ -0,0 +1,147 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import Select from 'react-select';
3
+ import { Label } from 'reactstrap';
4
+ import CustomSelectInput from '../CustomSelectInput';
5
+ import { LABELS } from './constants';
6
+ import 'react-tagsinput/react-tagsinput.css';
7
+
8
+ interface ICustomStylesOption {
9
+ fieldMatch: string;
10
+ valueMatch: any;
11
+ }
12
+ interface IOption {
13
+ label: string;
14
+ value: any;
15
+ fields?: any;
16
+ }
17
+ interface IOption {
18
+ label: string;
19
+ value: any;
20
+ fields?: any;
21
+ }
22
+ interface Props {
23
+ label: string;
24
+ tabIndex: number;
25
+ options: [IOption];
26
+ onChange: any;
27
+ selectedValue: any;
28
+ firstElement?: IOption; // no ingresar null como VALUE del elemento, setear '' ya que lo toma como que no se selecciono nada
29
+ newItem?: IOption;
30
+ placeholder?: string;
31
+ disabled?: boolean;
32
+ customStylesOption?: ICustomStylesOption;
33
+ }
34
+
35
+ const {SIN_DATOS, SELECCIONE}=LABELS
36
+
37
+ const CustomSelect: React.FC<Props> = (props: Props) => {
38
+ const [firstElement] = useState(props.firstElement);
39
+ const [newItem] = useState(props.newItem);
40
+ const [selectedIoption, setIoption] = useState({});
41
+ const [customStylesOption] = useState(props.customStylesOption);
42
+ const [customStyles, setCustomStyles] = useState({});
43
+
44
+ // agrega items
45
+ useEffect(() => {
46
+ if (newItem) {
47
+ props.options.push(newItem);
48
+ }
49
+ }, [newItem, props.options]);
50
+
51
+ // Seleccion del 1er item.
52
+ useEffect(() => {
53
+ const { options = [] } = props;
54
+ if (firstElement && Number(options?.length) > 1) {
55
+ const propIOption = options.filter((item) => item === firstElement);
56
+
57
+ if (propIOption?.length === 0) {
58
+ props.options.unshift(firstElement);
59
+ }
60
+ }
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
+ }, [firstElement, props.options]);
63
+
64
+ // selecciona un valor seteado dentro de la coleccion
65
+ useEffect(() => {
66
+ const { selectedValue } = props;
67
+ const errorProp = { value: null };
68
+
69
+ if (
70
+ selectedValue ||
71
+ (firstElement && firstElement.value === selectedValue)
72
+ ) {
73
+ const propIOption = props.options.filter(({ value }) => {
74
+ return JSON.stringify(value) === JSON.stringify(selectedValue);
75
+ });
76
+
77
+ if (propIOption[0]) {
78
+ setIoption(propIOption[0]);
79
+ if (!Object.getOwnPropertyDescriptor(selectedIoption, 'label')) {
80
+ props.onChange(propIOption[0]);
81
+ }
82
+ } else {
83
+ setIoption(errorProp);
84
+ props.onChange(errorProp);
85
+ }
86
+ } else if (props.options.length > 0) {
87
+ setIoption(errorProp);
88
+ props.onChange(errorProp);
89
+ }
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps
91
+ }, [props.selectedValue, props.options, firstElement]);
92
+
93
+ useEffect(() => {
94
+ if (customStylesOption) {
95
+ const stylesOption = {
96
+ option: (base: any, { data }: any) => {
97
+ return {
98
+ ...base,
99
+ color:
100
+ data.fields &&
101
+ data.fields[customStylesOption.fieldMatch] ===
102
+ customStylesOption.valueMatch
103
+ ? 'blue !important'
104
+ : '',
105
+ fontWeight:
106
+ data.fields &&
107
+ data.fields[customStylesOption.fieldMatch] ===
108
+ customStylesOption.valueMatch
109
+ ? 'bold'
110
+ : '',
111
+ };
112
+ },
113
+ };
114
+ setCustomStyles(stylesOption);
115
+ }
116
+ }, [customStylesOption]);
117
+
118
+ return (
119
+ <>
120
+ {props.label && props.label !== '' && (
121
+ <Label className="mb-0">{props.label}:</Label>
122
+ )}
123
+ <Select
124
+ {...props}
125
+ components={{ Input: CustomSelectInput }}
126
+ className="react-select"
127
+ classNamePrefix="react-select"
128
+ name="form-field-name"
129
+ value={
130
+ Object.getOwnPropertyDescriptor(selectedIoption, 'label')
131
+ ? selectedIoption
132
+ : ''
133
+ }
134
+ onChange={props.onChange}
135
+ options={props.options}
136
+ placeholder={
137
+ Number(props.options.length) === 0
138
+ ? SIN_DATOS
139
+ : props.placeholder || SELECCIONE
140
+ }
141
+ isDisabled={props.disabled}
142
+ styles={customStyles}
143
+ />
144
+ </>
145
+ );
146
+ };
147
+ export default CustomSelect;
@@ -0,0 +1,145 @@
1
+ import { DropzoneUploader, DropzoneUploaderDniDigital, TomarFoto } from '.';
2
+ import { CopyLink } from './copy-link';
3
+ import { CustomInputCheckbox, CustomInputRadio } from './custom-input';
4
+ import CustomSelect from './select';
5
+ import { Timer } from './timer';
6
+ import { ViewLayout } from './view-layout';
7
+ import { WhereByRoom } from './where-by-room';
8
+ import './assets/css/vendor/bootstrap.min.css';
9
+ import './index.css';
10
+ import './App.css';
11
+ import { useState } from 'react';
12
+
13
+ const slots = [
14
+ {
15
+ slot: 1,
16
+ x: 3,
17
+ y: 3,
18
+ w: 2,
19
+ h: 2,
20
+ legend: 'Prueba',
21
+ direction: 'column',
22
+ contentSize: 'medium',
23
+ align: 'stretch',
24
+ justify: 'flex-start',
25
+ component: null,
26
+ showBorder: true,
27
+ },
28
+ ];
29
+
30
+ export const DropzoneUploaderView = () => (
31
+ <>
32
+ <TomarFoto isMobile={true} />
33
+ <DropzoneUploader
34
+ totalFiles={4}
35
+ onChangeFiles={() => alert('onChange')}
36
+ maxFiles={3}
37
+ nameFileLabel="file"
38
+ />
39
+ </>
40
+ );
41
+
42
+ export const DropzoneUploaderFirmaDigitalView = () => (
43
+ <DropzoneUploader
44
+ totalFiles={0}
45
+ onChangeFiles={() => {
46
+ console.log('onChange');
47
+ }}
48
+ maxFiles={7}
49
+ nameFileLabel="Subir archivos"
50
+ capture="environment"
51
+ onFilesSelectedSelfie
52
+ />
53
+ );
54
+
55
+ export const DropzoneUploaderDniDigitalView = () => (
56
+ <DropzoneUploaderDniDigital
57
+ totalFiles={0}
58
+ onChangeFiles={() => {
59
+ console.log('onChange');
60
+ }}
61
+ maxFiles={7}
62
+ nameFileLabel="Subir archivos"
63
+ capture="environment"
64
+ onFilesSelectedSelfie
65
+ />
66
+ );
67
+
68
+ export const VideoCallView = () => (
69
+ <WhereByRoom
70
+ src="https://whereby.com/test-ampf-room"
71
+ title="Videollamada de ejemplo"
72
+ />
73
+ );
74
+
75
+ export const CustomInputsView = () => {
76
+ const handleChecked = (item, isSelected) => {
77
+ console.log('Item checked:', item, 'Selected:', isSelected);
78
+ };
79
+
80
+ const handleChangeRadio = (ID) => {
81
+ console.log('ID :', ID);
82
+ };
83
+ return (
84
+ <>
85
+ <CustomInputCheckbox
86
+ className="itemCheck m-0"
87
+ id={1}
88
+ onChange={(e) => handleChecked(1, e.target.checked)}
89
+ label={<span className="custom-checkbox">Checkbox 1</span>}
90
+ />
91
+ <CustomInputRadio
92
+ name="radioTest"
93
+ label="1"
94
+ id="1"
95
+ defaultChecked={true}
96
+ onChange={handleChangeRadio}
97
+ />
98
+ <CustomInputRadio
99
+ name="radioTest"
100
+ label="2"
101
+ id="2"
102
+ onChange={handleChangeRadio}
103
+ />
104
+ </>
105
+ );
106
+ };
107
+
108
+ export const CopyLinkView = () => (
109
+ <CopyLink link="https://linkdepruebaparaelcopylink.com" />
110
+ );
111
+
112
+ export const ViewLayoutView = () => <ViewLayout slots={slots} />;
113
+
114
+ export const TimerView = () => (
115
+ <Timer initialMinutes={2} active={true} style={{ color: 'green' }} />
116
+ );
117
+
118
+ export const CustomSelectView = () => {
119
+ const motivosBaja = [
120
+ {
121
+ label: 'MAL SERVICIO',
122
+ value: 'MSR',
123
+ },
124
+ {
125
+ label: 'AUMENTO DE CUOTA',
126
+ value: 'ADC',
127
+ },
128
+ ];
129
+ const [motivoBajaSelected, setMotivoBajaSelected] = useState({});
130
+
131
+ const handleMotivoSelected = (e) => {
132
+ setMotivoBajaSelected(e.value);
133
+ };
134
+
135
+ return (
136
+ <CustomSelect
137
+ tabIndex={0}
138
+ options={motivosBaja}
139
+ label="Seleccione una opción"
140
+ onChange={handleMotivoSelected}
141
+ placeholder="Seleccione..."
142
+ selectedValue={motivoBajaSelected}
143
+ />
144
+ );
145
+ };