react-restyle-components 0.1.24 → 0.1.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.
- package/README.md +1 -19
- package/lib/cjs/core-components/atoms/buttons/button.stories.js +19 -0
- package/lib/cjs/core-components/atoms/buttons/button.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/buttons/buttons.component.js +12 -0
- package/lib/cjs/core-components/atoms/buttons/buttons.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/buttons/buttons.component.test.js +14 -0
- package/lib/cjs/core-components/atoms/buttons/buttons.component.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/check-box/checkBox.component.js +18 -0
- package/lib/cjs/core-components/atoms/check-box/checkBox.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/check-box/checkBox.component.test.js +14 -0
- package/lib/cjs/core-components/atoms/check-box/checkBox.component.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/check-box/checkBox.stories.js +19 -0
- package/lib/cjs/core-components/atoms/check-box/checkBox.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/date-picker/date-picker.component.js +51 -0
- package/lib/cjs/core-components/atoms/date-picker/date-picker.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/date-picker/date-picker.component.test.js +15 -0
- package/lib/cjs/core-components/atoms/date-picker/date-picker.component.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/date-picker/date-picker.stories.js +19 -0
- package/lib/cjs/core-components/atoms/date-picker/date-picker.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/input/input-otp.component.js +89 -0
- package/lib/cjs/core-components/atoms/input/input-otp.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/input/input-pin.component.js +106 -0
- package/lib/cjs/core-components/atoms/input/input-pin.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/input/input-pin.component.test.js +18 -0
- package/lib/cjs/core-components/atoms/input/input-pin.component.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/input/input-pin.stories.js +20 -0
- package/lib/cjs/core-components/atoms/input/input-pin.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/input/input.component.js +21 -0
- package/lib/cjs/core-components/atoms/input/input.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/input/input.component.test.js +18 -0
- package/lib/cjs/core-components/atoms/input/input.component.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/input/input.stories.js +17 -0
- package/lib/cjs/core-components/atoms/input/input.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.js +68 -0
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.test.js +14 -0
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.stories.js +17 -0
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/loader/loader.component.js +61 -0
- package/lib/cjs/core-components/atoms/loader/loader.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/loader/loader.component.test.js +14 -0
- package/lib/cjs/core-components/atoms/loader/loader.component.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/loader/loader.stories.js +18 -0
- package/lib/cjs/core-components/atoms/loader/loader.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/radio/radio.component.js +15 -0
- package/lib/cjs/core-components/atoms/radio/radio.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/radio/radio.component.test.js +14 -0
- package/lib/cjs/core-components/atoms/radio/radio.component.test.js.map +1 -0
- package/lib/cjs/core-components/atoms/radio/radio.stories.js +20 -0
- package/lib/cjs/core-components/atoms/radio/radio.stories.js.map +1 -0
- package/lib/cjs/core-components/atoms/stepper/stepper.stories.js +0 -4
- package/lib/cjs/core-components/atoms/stepper/stepper.stories.js.map +1 -1
- package/lib/cjs/core-components/atoms/timer/timer.component.js +106 -0
- package/lib/cjs/core-components/atoms/timer/timer.component.js.map +1 -0
- package/lib/cjs/core-components/atoms/timer/timer.component.test.js +20 -0
- package/lib/cjs/core-components/atoms/timer/timer.component.test.js.map +1 -0
- package/lib/cjs/core-components/index.js +10 -0
- package/lib/cjs/core-components/index.js.map +1 -1
- package/lib/esm/core-components/atoms/buttons/button.stories.js +11 -0
- package/lib/esm/core-components/atoms/buttons/button.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/buttons/buttons.component.js +5 -0
- package/lib/esm/core-components/atoms/buttons/buttons.component.js.map +1 -0
- package/lib/esm/core-components/atoms/buttons/buttons.component.test.js +9 -0
- package/lib/esm/core-components/atoms/buttons/buttons.component.test.js.map +1 -0
- package/lib/esm/core-components/atoms/check-box/checkBox.component.js +11 -0
- package/lib/esm/core-components/atoms/check-box/checkBox.component.js.map +1 -0
- package/lib/esm/core-components/atoms/check-box/checkBox.component.test.js +9 -0
- package/lib/esm/core-components/atoms/check-box/checkBox.component.test.js.map +1 -0
- package/lib/esm/core-components/atoms/check-box/checkBox.stories.js +12 -0
- package/lib/esm/core-components/atoms/check-box/checkBox.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/date-picker/date-picker.component.js +21 -0
- package/lib/esm/core-components/atoms/date-picker/date-picker.component.js.map +1 -0
- package/lib/esm/core-components/atoms/date-picker/date-picker.component.test.js +10 -0
- package/lib/esm/core-components/atoms/date-picker/date-picker.component.test.js.map +1 -0
- package/lib/esm/core-components/atoms/date-picker/date-picker.stories.js +12 -0
- package/lib/esm/core-components/atoms/date-picker/date-picker.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/input/input-otp.component.js +62 -0
- package/lib/esm/core-components/atoms/input/input-otp.component.js.map +1 -0
- package/lib/esm/core-components/atoms/input/input-pin.component.js +79 -0
- package/lib/esm/core-components/atoms/input/input-pin.component.js.map +1 -0
- package/lib/esm/core-components/atoms/input/input-pin.component.test.js +13 -0
- package/lib/esm/core-components/atoms/input/input-pin.component.test.js.map +1 -0
- package/lib/esm/core-components/atoms/input/input-pin.stories.js +13 -0
- package/lib/esm/core-components/atoms/input/input-pin.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/input/input.component.js +14 -0
- package/lib/esm/core-components/atoms/input/input.component.js.map +1 -0
- package/lib/esm/core-components/atoms/input/input.component.test.js +13 -0
- package/lib/esm/core-components/atoms/input/input.component.test.js.map +1 -0
- package/lib/esm/core-components/atoms/input/input.stories.js +10 -0
- package/lib/esm/core-components/atoms/input/input.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.js +38 -0
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.js.map +1 -0
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.test.js +9 -0
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.test.js.map +1 -0
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.stories.js +10 -0
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/loader/loader.component.js +53 -0
- package/lib/esm/core-components/atoms/loader/loader.component.js.map +1 -0
- package/lib/esm/core-components/atoms/loader/loader.component.test.js +9 -0
- package/lib/esm/core-components/atoms/loader/loader.component.test.js.map +1 -0
- package/lib/esm/core-components/atoms/loader/loader.stories.js +11 -0
- package/lib/esm/core-components/atoms/loader/loader.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/radio/radio.component.js +8 -0
- package/lib/esm/core-components/atoms/radio/radio.component.js.map +1 -0
- package/lib/esm/core-components/atoms/radio/radio.component.test.js +9 -0
- package/lib/esm/core-components/atoms/radio/radio.component.test.js.map +1 -0
- package/lib/esm/core-components/atoms/radio/radio.stories.js +13 -0
- package/lib/esm/core-components/atoms/radio/radio.stories.js.map +1 -0
- package/lib/esm/core-components/atoms/stepper/stepper.stories.js +0 -4
- package/lib/esm/core-components/atoms/stepper/stepper.stories.js.map +1 -1
- package/lib/esm/core-components/atoms/timer/timer.component.js +80 -0
- package/lib/esm/core-components/atoms/timer/timer.component.js.map +1 -0
- package/lib/esm/core-components/atoms/timer/timer.component.test.js +15 -0
- package/lib/esm/core-components/atoms/timer/timer.component.test.js.map +1 -0
- package/lib/esm/core-components/index.js +10 -0
- package/lib/esm/core-components/index.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker.component.test.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/date-picker/date-picker.component.test.tsx"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;IACxC,MAAM,UAAU,GAAG,MAAM,CACvB,oBAAC,cAAc,IACb,SAAS,EAAC,MAAM,EAChB,KAAK,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EACnC,UAAU,EAAE,YAAY,GACxB,CACH,CAAC;IACF,MAAM,CAAC,UAAU,CAAC,CAAC,eAAe,EAAE,CAAC;AACvC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DatePickerComp } from './date-picker.component';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Atoms/DatePickerComp',
|
|
7
|
+
component: DatePickerComp,
|
|
8
|
+
};
|
|
9
|
+
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
10
|
+
export const Primary = () => (React.createElement("div", { className: "flex flex-row" },
|
|
11
|
+
React.createElement(DatePickerComp, { className: "mt-6", value: dayjs().format('YYYY-MM-DD'), showFormat: 'dd-MM-yyyy' })));
|
|
12
|
+
//# sourceMappingURL=date-picker.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-picker.stories.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/date-picker/date-picker.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,0GAA0G;AAC1G,eAAe;IACb,KAAK,EAAE,sBAAsB;IAC7B,SAAS,EAAE,cAAc;CACc,CAAC;AAE1C,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAA0C,GAAG,EAAE,CAAC,CAClE,6BAAK,SAAS,EAAC,eAAe;IAC5B,oBAAC,cAAc,IACb,SAAS,EAAC,MAAM,EAChB,KAAK,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EACnC,UAAU,EAAE,YAAY,GACxB,CACE,CACP,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import './inputOtp.styles.css';
|
|
4
|
+
export const InputOtp = ({ className, pin, onPinChanged, }) => {
|
|
5
|
+
const pinLength = 6;
|
|
6
|
+
const Pin_Min_Value = 0;
|
|
7
|
+
const Pin_Max_Value = 9;
|
|
8
|
+
const BACKSPACE_Key = 'Backspace';
|
|
9
|
+
const inputRefs = useRef([]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const ref = inputRefs.current[0];
|
|
12
|
+
if (ref) {
|
|
13
|
+
ref.focus();
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
const changePinFocus = (pinIndex) => {
|
|
17
|
+
const ref = inputRefs.current[pinIndex];
|
|
18
|
+
if (ref) {
|
|
19
|
+
ref.focus();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const onChange = (event, index) => {
|
|
23
|
+
const value = event.target.value;
|
|
24
|
+
const pinNumber = Number(value.trim());
|
|
25
|
+
if (isNaN(pinNumber) || value.length === 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
|
|
29
|
+
onPinChanged(pinNumber, index);
|
|
30
|
+
if (index < pinLength - 1) {
|
|
31
|
+
changePinFocus(index + 1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const onKeyDown = (event, index) => {
|
|
36
|
+
console.log({ event, index });
|
|
37
|
+
const keyboardKeyCode = event.nativeEvent.code;
|
|
38
|
+
if (keyboardKeyCode != BACKSPACE_Key)
|
|
39
|
+
return;
|
|
40
|
+
if (pin[index] === undefined) {
|
|
41
|
+
changePinFocus(index - 1);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
onPinChanged(undefined, index);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return (React.createElement("div", { className: `${className} relative` },
|
|
48
|
+
React.createElement("div", { className: "flex space-x-1 bg-background-secondary rounded-lg outline-offset-8" }, Array.from({ length: pinLength }, (_, index) => (React.createElement("input", { "data-testid": "onPinChanged", className: "pt-3 pb-2 block w-full px-0 text-5xl font-extrabold border-b-0 text-orange mt-0 bg-transparent text-center z-20 appearance-none focus:outline-none font-nunitoSansRegular", onKeyDown: (event) => onKeyDown(event, index), key: index, onMouseUp: () => {
|
|
49
|
+
if (pin.join('').length <= 0) {
|
|
50
|
+
changePinFocus(0);
|
|
51
|
+
}
|
|
52
|
+
}, onClick: () => {
|
|
53
|
+
if (pin.join('').length <= 0) {
|
|
54
|
+
onPinChanged(undefined, 0);
|
|
55
|
+
}
|
|
56
|
+
}, ref: (el) => {
|
|
57
|
+
if (el) {
|
|
58
|
+
inputRefs.current[index] = el;
|
|
59
|
+
}
|
|
60
|
+
}, onChange: (event) => onChange(event, index), value: pin[index] || '' }))))));
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=input-otp.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-otp.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input-otp.component.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC/C,OAAO,uBAAuB,CAAC;AAa/B,MAAM,CAAC,MAAM,QAAQ,GAAgC,CAAC,EACpD,SAAS,EACT,GAAG,EACH,YAAY,GACb,EAAE,EAAE;IACH,MAAM,SAAS,GAAG,CAAC,CAAC;IACpB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,aAAa,GAAG,WAAW,CAAC;IAClC,MAAM,SAAS,GAAG,MAAM,CAAqB,EAAE,CAAC,CAAC;IAEjD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,GAAG,EAAE;YACP,GAAG,CAAC,KAAK,EAAE,CAAC;SACb;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,GAAG,EAAE;YACP,GAAG,CAAC,KAAK,EAAE,CAAC;SACb;IACH,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,CACf,KAA0C,EAC1C,KAAa,EACb,EAAE;QACF,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACjC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAEvC,IAAI,KAAK,CAAC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iBACnB;YACH,CAAC,EACD,OAAO,EAAE,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE;oBAC5B,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;iBAC5B;YACH,CAAC,EACD,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE;gBACV,IAAI,EAAE,EAAE;oBACN,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;iBAC/B;YACH,CAAC,EACD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,EAC3C,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,GACvB,CACH,CAAC,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import './input.styles.css';
|
|
4
|
+
export const InputPin = ({ title, className, pin, errorMsg, defaultMsg, hasError, onPinChanged, }) => {
|
|
5
|
+
const pinLength = 12;
|
|
6
|
+
const Pin_Min_Value = 0;
|
|
7
|
+
const Pin_Max_Value = 9;
|
|
8
|
+
const BACKSPACE_Key = 'Backspace';
|
|
9
|
+
const inputRefs = useRef([]);
|
|
10
|
+
const removeValuesFromArray = (valuesArray, value) => {
|
|
11
|
+
const valueIndex = valuesArray.findIndex((entry) => entry === value);
|
|
12
|
+
if (valueIndex === -1) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
valuesArray.splice(valueIndex, 1);
|
|
16
|
+
};
|
|
17
|
+
const changePinFocus = (pinIndex) => {
|
|
18
|
+
const ref = inputRefs.current[pinIndex];
|
|
19
|
+
if (ref) {
|
|
20
|
+
ref.focus();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const onChange = (event, index) => {
|
|
24
|
+
const previousValue = event.target.defaultValue;
|
|
25
|
+
const valueArray = event.target.value.split('');
|
|
26
|
+
removeValuesFromArray(valueArray, previousValue);
|
|
27
|
+
const value = valueArray.pop();
|
|
28
|
+
if (!value) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const pinNumber = Number(value);
|
|
32
|
+
if (isNaN(pinNumber) || value.length === 0) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
|
|
36
|
+
onPinChanged(pinNumber, index);
|
|
37
|
+
if (index < pinLength - 1) {
|
|
38
|
+
changePinFocus(index + 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const onKeyDown = (event, index) => {
|
|
43
|
+
const keyboardKeyCode = event.nativeEvent.code;
|
|
44
|
+
if (keyboardKeyCode != BACKSPACE_Key)
|
|
45
|
+
return;
|
|
46
|
+
if (pin[index] !== undefined && keyboardKeyCode === BACKSPACE_Key) {
|
|
47
|
+
changePinFocus(index - 1);
|
|
48
|
+
}
|
|
49
|
+
if (pin[index] === undefined) {
|
|
50
|
+
changePinFocus(index - 1);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
onPinChanged(undefined, index);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return (React.createElement("div", { className: `${className} relative` },
|
|
57
|
+
React.createElement("label", { className: "duration-300 -z-1 origin-0 text-gray-dark-secondary font-nunitoSansRegular text-md" }, title),
|
|
58
|
+
React.createElement("div", { className: "flex space-x-1" }, Array.from({ length: pinLength }, (_, index) => {
|
|
59
|
+
var _a;
|
|
60
|
+
return (React.createElement("div", { className: "flex space-x-1 max-w-full items-stretch", key: index },
|
|
61
|
+
React.createElement("input", { "data-testid": "inputElementPin", type: "tel", className: "pb-2 block w-4 px-0 mt-0 bg-transparent text-center border-0 border-b z-20 appearance-none rounded-none focus:outline-none focus:ring-0 focus:border-gray-secondary border-gray-secondary font-nunitoSansRegular ", onKeyUp: (event) => onKeyDown(event, index), key: index, onMouseUp: () => {
|
|
62
|
+
if (pin.join('').length <= 0) {
|
|
63
|
+
changePinFocus(0);
|
|
64
|
+
}
|
|
65
|
+
}, onClick: () => {
|
|
66
|
+
if (pin.join('').length <= 0) {
|
|
67
|
+
onPinChanged(undefined, 0);
|
|
68
|
+
}
|
|
69
|
+
}, ref: (el) => {
|
|
70
|
+
if (el) {
|
|
71
|
+
inputRefs.current[index] = el;
|
|
72
|
+
}
|
|
73
|
+
}, onChange: (event) => onChange(event, index), value: ((_a = pin[index]) === null || _a === void 0 ? void 0 : _a.toString()) || '' }),
|
|
74
|
+
React.createElement("div", { className: "invisible" }, (index + 1) % 4 === 0 ? 'ss' : null)));
|
|
75
|
+
})),
|
|
76
|
+
hasError && (hasError === null || hasError === void 0 ? void 0 : hasError.type) !== 'required' && (React.createElement("span", { className: "text-sm text-red text-4xs font-nunitoSansRegular", id: "error" }, `${errorMsg || ''}`)),
|
|
77
|
+
(!hasError || (hasError === null || hasError === void 0 ? void 0 : hasError.type) === 'required') && (React.createElement("span", { className: "text-sm text-4xs font-nunitoSansRegular", id: "error" }, `${defaultMsg || ''}`))));
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=input-pin.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-pin.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input-pin.component.tsx"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,OAAO,KAAK,EAAE,EAAC,MAAM,EAAW,MAAM,OAAO,CAAC;AAC9C,OAAO,oBAAoB,CAAC;AAc5B,MAAM,CAAC,MAAM,QAAQ,GAAgC,CAAC,EACpD,KAAK,EACL,SAAS,EACT,GAAG,EACH,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,YAAY,GACb,EAAE,EAAE;IACH,MAAM,SAAS,GAAG,EAAE,CAAC;IACrB,MAAM,aAAa,GAAG,CAAC,CAAC;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disable testing-library/render-result-naming-convention */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render } from '@core-utils';
|
|
4
|
+
import { InputPin } from './input-pin.component';
|
|
5
|
+
it('render InputOtp correctly without error', () => {
|
|
6
|
+
const pinInput = render(React.createElement(InputPin, { title: "Enter your Aadhaar Number", hasError: false, errorMsg: "Uh oh! You\u2019ve entered an invalid aadhaar number", onPinChanged: () => jest.fn(), pin: new Array(12) }));
|
|
7
|
+
expect(pinInput).toMatchSnapshot();
|
|
8
|
+
});
|
|
9
|
+
it('render InputOtp correctly with error', () => {
|
|
10
|
+
const pinInput = render(React.createElement(InputPin, { title: "Enter your Aadhaar Number", hasError: true, errorMsg: "Uh oh! You\u2019ve entered an invalid aadhaar number", onPinChanged: () => jest.fn(), pin: new Array(12) }));
|
|
11
|
+
expect(pinInput).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=input-pin.component.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-pin.component.test.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input-pin.component.test.tsx"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE/C,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACjD,MAAM,QAAQ,GAAG,MAAM,CACrB,oBAAC,QAAQ,IACP,KAAK,EAAC,2BAA2B,EACjC,QAAQ,EAAE,KAAK,EACf,QAAQ,EAAC,sDAAiD,EAC1D,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAC7B,GAAG,EAAE,IAAI,KAAK,CAAC,EAAE,CAAC,GAClB,CACH,CAAC;IACF,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;AACrC,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAC9C,MAAM,QAAQ,GAAG,MAAM,CACrB,oBAAC,QAAQ,IACP,KAAK,EAAC,2BAA2B,EACjC,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAC,sDAAiD,EAC1D,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAC7B,GAAG,EAAE,IAAI,KAAK,CAAC,EAAE,CAAC,GAClB,CACH,CAAC;IACF,MAAM,CAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAC;AACrC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputPin } from './input-pin.component';
|
|
3
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Atoms/InputPin',
|
|
6
|
+
component: InputPin,
|
|
7
|
+
};
|
|
8
|
+
const pin = new Array(12);
|
|
9
|
+
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
10
|
+
export const Primary = () => (React.createElement(InputPin, { title: "Enter your Aadhaar Number", hasError: true, onPinChanged: (value) => {
|
|
11
|
+
console.log({ value });
|
|
12
|
+
}, pin: pin }));
|
|
13
|
+
//# sourceMappingURL=input-pin.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-pin.stories.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input-pin.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE/C,0GAA0G;AAC1G,eAAe;IACb,KAAK,EAAE,gBAAgB;IACvB,SAAS,EAAE,QAAQ;CACc,CAAC;AAEpC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC;AAE1B,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAoC,GAAG,EAAE,CAAC,CAC5D,oBAAC,QAAQ,IACP,KAAK,EAAC,2BAA2B,EACjC,QAAQ,EAAE,IAAI,EACd,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE;QACtB,OAAO,CAAC,GAAG,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC;IACvB,CAAC,EACD,GAAG,EAAE,GAAG,GACR,CACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import './input.styles.css';
|
|
4
|
+
export const Input = ({ title, value, className, disable, hasError, errorMsg, defaultMsg, inputStyle, autoComplete, maxlength = 40, onChange, onBlur, }) => {
|
|
5
|
+
const onKeyUpValue = (event) => {
|
|
6
|
+
onChange(event.target.value);
|
|
7
|
+
};
|
|
8
|
+
return (React.createElement("div", { className: `${className} relative` },
|
|
9
|
+
React.createElement("input", { "data-testid": "inputElement", type: "text", name: "name", value: value, placeholder: " ", disabled: disable, className: `pt-3 pb-2 bg-transparent block w-full px-0 mt-0 rounded-none border-0 border-b appearance-none focus:outline-none focus:ring-0 focus:border-gray-secondary border-gray-secondary font-nunitoSansRegular ${inputStyle}`, onChange: (e) => onChange && onChange(e.target.value), onKeyUp: onKeyUpValue, onBlur: (e) => onBlur && onBlur(e.target.value), autoComplete: autoComplete, maxLength: maxlength }),
|
|
10
|
+
React.createElement("label", { className: "absolute duration-300 top-3 -z-1 origin-0 text-gray-dark-secondary font-nunitoSansRegular text-md" }, title),
|
|
11
|
+
hasError && (hasError === null || hasError === void 0 ? void 0 : hasError.type) !== 'required' && (React.createElement("span", { className: "text-sm text-red text-4xs", id: "error" }, `${errorMsg || ''}`)),
|
|
12
|
+
(!hasError || (hasError === null || hasError === void 0 ? void 0 : hasError.type) === 'required') && (React.createElement("span", { className: "text-sm text-4xs", id: "error" }, `${defaultMsg || ''}`))));
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=input.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input.component.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,oBAAoB,CAAC;AAiB5B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,KAAK,EACL,KAAK,EACL,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,UAAU,EACV,YAAY,EACZ,SAAS,GAAG,EAAE,EACd,QAAQ,EACR,MAAM,GACK,EAAE,EAAE;IACf,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,EAAE;QAC7B,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAE,GAAG,SAAS,WAAW;QACrC,8CACc,cAAc,EAC1B,IAAI,EAAC,MAAM,EACX,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,KAAK,EACZ,WAAW,EAAC,GAAG,EACf,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,6MAA6M,UAAU,EAAE,EACpO,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACrD,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC/C,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,GACpB;QACF,+BAAO,SAAS,EAAC,mGAAmG,IACjH,KAAK,CACA;QACP,QAAQ,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,UAAU,IAAI,CAC5C,8BAAM,SAAS,EAAC,2BAA2B,EAAC,EAAE,EAAC,OAAO,IACnD,GAAG,QAAQ,IAAI,EAAE,EAAE,CACf,CACR;QACA,CAAC,CAAC,QAAQ,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,UAAU,CAAC,IAAI,CAC/C,8BAAM,SAAS,EAAC,kBAAkB,EAAC,EAAE,EAAC,OAAO,IAC1C,GAAG,UAAU,IAAI,EAAE,EAAE,CACjB,CACR,CACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render } from '@core-utils';
|
|
4
|
+
import { Input } from './input.component';
|
|
5
|
+
it('render Input correctly without error', () => {
|
|
6
|
+
const input = render(React.createElement(Input, { className: "h-1 relative top-1 border-red-600 border-b-0 dummy", title: 'input', hasError: false, value: '', inputStyle: " border-b-0 invisible ", onChange: () => jest.fn() }));
|
|
7
|
+
expect(input).toMatchSnapshot();
|
|
8
|
+
});
|
|
9
|
+
it('render Input correctly with error', () => {
|
|
10
|
+
const input = render(React.createElement(Input, { className: "h-1 relative top-1 border-red-600 border-b-0 dummy", title: 'input', hasError: true, value: '', inputStyle: " border-b-0 invisible ", onChange: () => jest.fn() }));
|
|
11
|
+
expect(input).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=input.component.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.component.test.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input.component.test.tsx"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAExC,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;IAC9C,MAAM,KAAK,GAAG,MAAM,CAClB,oBAAC,KAAK,IACJ,SAAS,EAAC,oDAAoD,EAC9D,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,KAAK,EACf,KAAK,EAAE,EAAE,EACT,UAAU,EAAC,wBAAwB,EACnC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,GACzB,CACH,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,CAAC;AAClC,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;IAC3C,MAAM,KAAK,GAAG,MAAM,CAClB,oBAAC,KAAK,IACJ,SAAS,EAAC,oDAAoD,EAC9D,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,IAAI,EACd,KAAK,EAAE,EAAE,EACT,UAAU,EAAC,wBAAwB,EACnC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,GACzB,CACH,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,CAAC;AAClC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Input } from './input.component';
|
|
3
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Atoms/Input',
|
|
6
|
+
component: Input,
|
|
7
|
+
};
|
|
8
|
+
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
9
|
+
export const Primary = () => (React.createElement(Input, { className: "mt-4", title: "Enter your Pan Number", hasError: true, value: "", onChange: (panNumber) => console.log({ panNumber }) }));
|
|
10
|
+
//# sourceMappingURL=input.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.stories.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAExC,0GAA0G;AAC1G,eAAe;IACb,KAAK,EAAE,aAAa;IACpB,SAAS,EAAE,KAAK;CACc,CAAC;AAEjC,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAiC,GAAG,EAAE,CAAC,CACzD,oBAAC,KAAK,IACJ,SAAS,EAAC,MAAM,EAChB,KAAK,EAAC,uBAAuB,EAC7B,QAAQ,EAAE,IAAI,EACd,KAAK,EAAC,EAAE,EACR,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAC,SAAS,EAAC,CAAC,GACjD,CACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import UpArrow from '../../../library/assets/svg/UpArrow.svg';
|
|
3
|
+
import DownArrow from '../../../library/assets/svg/DownArrow.svg';
|
|
4
|
+
export const InputDropdown = ({ items, className, hasError, title, onChange, }) => {
|
|
5
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
6
|
+
const [value, setValue] = useState('');
|
|
7
|
+
const useOutsideAlerter = (ref) => {
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
function handleClickOutside(event) {
|
|
10
|
+
if (ref.current &&
|
|
11
|
+
!ref.current.contains(event.target) &&
|
|
12
|
+
isOpen &&
|
|
13
|
+
isOpen)
|
|
14
|
+
setIsOpen(!isOpen);
|
|
15
|
+
}
|
|
16
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
17
|
+
return () => {
|
|
18
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
19
|
+
};
|
|
20
|
+
}, [ref]);
|
|
21
|
+
};
|
|
22
|
+
const wrapperRef = useRef(null);
|
|
23
|
+
useOutsideAlerter(wrapperRef);
|
|
24
|
+
return (React.createElement("div", { className: `${className} relative` },
|
|
25
|
+
React.createElement("div", { className: "flex flex-row items-center " },
|
|
26
|
+
React.createElement("input", { type: "text", name: "name", placeholder: title, value: value, className: " text-gray-dark-secondary pt-3 pb-2 w-full px-0 mt-0 bg-transparent border-gray-secondary border-0 border-b appearance-none focus:outline-none focus:ring-0 font-nunitoSansRegular text-md", onClick: () => {
|
|
27
|
+
setIsOpen(!isOpen);
|
|
28
|
+
}, onChange: (event) => onChange && onChange(event.target.value) }),
|
|
29
|
+
!isOpen && React.createElement("img", { src: UpArrow, className: "absolute h-4 w-4 right-0" }),
|
|
30
|
+
isOpen && React.createElement("img", { src: DownArrow, className: "absolute h-4 w-4 right-0" })),
|
|
31
|
+
isOpen && (React.createElement("div", { className: "z-10 w-full absolute text-base list-none bg-white rounded divide-y divide-gray-100 shadow dark:bg-gray-700", ref: wrapperRef },
|
|
32
|
+
React.createElement("ul", { className: "py-1" }, items.map((item, index) => (React.createElement("li", { key: index, className: "block py-2 px-4 text-md hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 font-nunitoSansRegular", onClick: () => {
|
|
33
|
+
setValue(item);
|
|
34
|
+
setIsOpen(!isOpen);
|
|
35
|
+
} }, item)))))),
|
|
36
|
+
hasError && (React.createElement("span", { className: "text-primaryCharcoal text-4xs", id: "error" }, `${title} is required`))));
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=input-dropdown.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-dropdown.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input-dropdown/input-dropdown.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACzD,OAAO,OAAO,MAAM,yCAAyC,CAAC;AAC9D,OAAO,SAAS,MAAM,2CAA2C,CAAC;AASlE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,KAAK,EACL,SAA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AC,MAAM,CAAC,KAAK,CAAC,GAC7D;YACD,CAAC,MAAM,IAAI,6BAAK,GAAG,EAAE,OAAO,EAAE,SAAS,EAAC,0BAA0B,GAAG;YACrE,MAAM,IAAI,6BAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAC,0BAA0B,GAAG,CACnE;QACL,MAAM,IAAI,CACT,6BACE,SAAS,EAAC,6GAA6G,EACvH,GAAG,EAAE,UAAU;YAEf,4BAAI,SAAS,EAAC,MAAM,IACjB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1B,4BACE,GAAG,EAAE,KAAK,EACV,SAAS,EAAC,+GAA+G,EACzH,OAAO,EAAE,GAAG,EAAE;oBACZ,QAAQ,CAAC,IAAI,CAAC,CAAC;oBACf,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;gBACrB,CAAC,IAEA,IAAI,CACF,CACN,CAAC,CACC,CACD,CACP;QAEA,QAAQ,IAAI,CACX,8BAAM,SAAS,EAAC,+BAA+B,EAAC,EAAE,EAAC,OAAO,IACvD,GAAG,KAAK,cAAc,CAClB,CACR,CACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render } from '@core-utils';
|
|
4
|
+
import { InputDropdown } from './input-dropdown.component';
|
|
5
|
+
it('render InputDropdown correctly', () => {
|
|
6
|
+
const inputDropDown = render(React.createElement(InputDropdown, { title: "Source of funds", items: ['Bank account', 'UPI', 'Credit Card'], hasError: true, onChange: () => jest.fn() }));
|
|
7
|
+
expect(inputDropDown).toMatchSnapshot();
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=input-dropdown.component.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-dropdown.component.test.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input-dropdown/input-dropdown.component.test.tsx"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAEzD,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;IACxC,MAAM,aAAa,GAAG,MAAM,CAC1B,oBAAC,aAAa,IACZ,KAAK,EAAC,iBAAiB,EACvB,KAAK,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,aAAa,CAAC,EAC7C,QAAQ,EAAE,IAAI,EACd,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,GACzB,CACH,CAAC;IACF,MAAM,CAAC,aAAa,CAAC,CAAC,eAAe,EAAE,CAAC;AAC1C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputDropdown } from './input-dropdown.component';
|
|
3
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Atoms/InputDropdown',
|
|
6
|
+
component: InputDropdown,
|
|
7
|
+
};
|
|
8
|
+
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
9
|
+
export const Primary = () => (React.createElement(InputDropdown, { title: "Source of funds", items: ['Bank account', 'UPI', 'Credit Card'], hasError: true }));
|
|
10
|
+
//# sourceMappingURL=input-dropdown.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-dropdown.stories.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input-dropdown/input-dropdown.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAEzD,0GAA0G;AAC1G,eAAe;IACb,KAAK,EAAE,qBAAqB;IAC5B,SAAS,EAAE,aAAa;CACc,CAAC;AAEzC,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAyC,GAAG,EAAE,CAAC,CACjE,oBAAC,aAAa,IACZ,KAAK,EAAC,iBAAiB,EACvB,KAAK,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,aAAa,CAAC,EAC7C,QAAQ,EAAE,IAAI,GACd,CACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Container, Row, Spinner } from 'reactstrap';
|
|
3
|
+
export const Loader = () => (React.createElement(Container, { fluid: true, className: "vh-50 d-flex" },
|
|
4
|
+
React.createElement(Row, { className: "justify-content-center align-self-center w-100 text-center" },
|
|
5
|
+
React.createElement(Spinner, { color: "primary" }))));
|
|
6
|
+
export const ModalLoader = () => {
|
|
7
|
+
return (React.createElement(React.Fragment, null,
|
|
8
|
+
React.createElement(React.Fragment, null,
|
|
9
|
+
React.createElement("div", { className: "justify-center items-center flex overflow-x-hidden overflow-y-auto fixed inset-0 z-50 outline-none focus:outline-none" },
|
|
10
|
+
React.createElement("div", { className: "relative mx-auto " },
|
|
11
|
+
React.createElement("div", { className: "border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none" },
|
|
12
|
+
React.createElement("div", { className: "relative p-2 flex-auto flex flex-col items-center" },
|
|
13
|
+
React.createElement("style", null, `
|
|
14
|
+
.spinner .background {
|
|
15
|
+
fill: #555;
|
|
16
|
+
}
|
|
17
|
+
.spinner .line {
|
|
18
|
+
animation: PacMan 5s infinite;
|
|
19
|
+
fill: none;
|
|
20
|
+
stroke: #d26188;
|
|
21
|
+
stroke-width: 25;
|
|
22
|
+
}
|
|
23
|
+
.spinner .spinner {
|
|
24
|
+
animation: Spin 2s infinite linear;
|
|
25
|
+
}
|
|
26
|
+
@keyframes PacMan {
|
|
27
|
+
0% {
|
|
28
|
+
stroke-dasharray: 79px 79;
|
|
29
|
+
}
|
|
30
|
+
50% {
|
|
31
|
+
stroke-dasharray: 1px 79;
|
|
32
|
+
}
|
|
33
|
+
100% {
|
|
34
|
+
stroke-dasharray: 79px 79;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
@keyframes Spin {
|
|
38
|
+
0% {
|
|
39
|
+
transform: rotate(0deg);
|
|
40
|
+
}
|
|
41
|
+
100% {
|
|
42
|
+
transform: rotate(360deg);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`),
|
|
46
|
+
React.createElement("svg", { className: "spinner", width: "100", height: "100", viewBox: "0 0 100 100" },
|
|
47
|
+
React.createElement("circle", { className: "background", cx: "0", cy: "0" }),
|
|
48
|
+
React.createElement("path", { className: "line", d: "M 37.5,50 C 37.5,43.096441 43.096441,37.5 50,37.5 C 56.903559,37.5 62.5,43.096441 62.5,50 C 62.5,56.903559 56.903559,62.5 50,62.5 C 43.096441,62.5 37.5,56.903559 37.5,50" })),
|
|
49
|
+
' ',
|
|
50
|
+
React.createElement("span", { style: { marginTop: -15 } }, "loading ..."))))),
|
|
51
|
+
React.createElement("div", { className: "opacity-25 fixed inset-0 z-40 bg-black" }))));
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=loader.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/loader/loader.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAE,GAAG,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAEnD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,CAC1B,oBAAC,SAAS,IAAC,KAAK,QAAC,SAAS,EAAC,cAAc;IACvC,oBAAC,GAAG,IAAC,SAAS,EAAC,4DAA4D;QACzE,oBAAC,OAAO,IAAC,KAAK,EAAC,SAAS,GAAG,CACvB,CACI,CACb,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,OAAO,CACL;QACE;YACE,6BAAK,SAAS,EAAC,uHAAuH;gBACpI,6BAAK,SAAS,EAAC,oBAAoB;oBAEjC,6BAAK,SAAS,EAAC,sGAAsG;wBAEnH,6BAAK,SAAS,EAAC,mDAAmD;4BAChE,mCACG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgCd,CACmB;4BACR,6BACE,SAAS,EAAC,SAAS,EACnB,KAAK,EAAC,KAAK,EACX,MAAM,EAAC,KAAK,EACZ,OAAO,EAAC,aAAa;gCAErB,gCAAQ,SAAS,EAAC,YAAY,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,GAAU;gCACtD,8BACE,SAAS,EAAC,MAAM,EAChB,CAAC,EAAC,2KAA2K,GACvK,CACJ;4BAAC,GAAG;4BACV,8BAAM,KAAK,EAAE,EAAC,SAAS,EAAE,CAAC,EAAE,EAAC,kBAAoB,CAC7C,CACF,CACF,CACF;YACN,6BAAK,SAAS,EAAC,wCAAwC,GAAO,CAC7D,CACF,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render } from '@core-utils';
|
|
4
|
+
import { Loader } from './loader.component';
|
|
5
|
+
it('render XB_Loader correctly', () => {
|
|
6
|
+
const loader = render(React.createElement(Loader, null));
|
|
7
|
+
expect(loader).toMatchSnapshot();
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=loader.component.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.component.test.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/loader/loader.component.test.tsx"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAE1C,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,oBAAC,MAAM,OAAG,CAAC,CAAC;IAClC,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;AACnC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Loader } from './loader.component';
|
|
3
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Atoms/Loader',
|
|
6
|
+
component: Loader,
|
|
7
|
+
};
|
|
8
|
+
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
9
|
+
export const Primary = () => (React.createElement("div", { className: "flex flex-row" },
|
|
10
|
+
React.createElement(Loader, null)));
|
|
11
|
+
//# sourceMappingURL=loader.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.stories.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/loader/loader.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAE1C,0GAA0G;AAC1G,eAAe;IACb,KAAK,EAAE,cAAc;IACrB,SAAS,EAAE,MAAM;CACc,CAAC;AAElC,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAkC,GAAG,EAAE,CAAC,CAC1D,6BAAK,SAAS,EAAC,eAAe;IAC5B,oBAAC,MAAM,OAAG,CACN,CACP,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactComponent as CheckedRadio } from '../../../library/assets/svg/checkedRadio.svg';
|
|
3
|
+
import { ReactComponent as UncheckRadio } from '../../../library/assets/svg/uncheckRadio.svg';
|
|
4
|
+
export const Radio = ({ className, checked, onChange }) => {
|
|
5
|
+
const width = 20;
|
|
6
|
+
return (React.createElement("div", { className: `${className} flex flex-row mr-2`, onClick: onChange }, checked ? (React.createElement(CheckedRadio, { width: width, height: width })) : (React.createElement(UncheckRadio, { width: width, height: width }))));
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=radio.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/radio/radio.component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,cAAc,IAAI,YAAY,EAAC,MAAM,8CAA8C,CAAC;AAC5F,OAAO,EAAC,cAAc,IAAI,YAAY,EAAC,MAAM,8CAA8C,CAAC;AAQ5F,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAa,EAAE,EAAE;IAClE,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,OAAO,CACL,6BAAK,SAAS,EAAE,GAAG,SAAS,qBAAqB,EAAE,OAAO,EAAE,QAAQ,IACjE,OAAO,CAAC,CAAC,CAAC,CACT,oBAAC,YAAY,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAI,CAC9C,CAAC,CAAC,CAAC,CACF,oBAAC,YAAY,IAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,GAAI,CAC9C,CACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { render } from '@core-utils';
|
|
4
|
+
import { Radio } from './radio.component';
|
|
5
|
+
it('render XB_Radio correctly', () => {
|
|
6
|
+
const radio = render(React.createElement(Radio, { checked: true, onChange: () => jest.fn() }));
|
|
7
|
+
expect(radio).toMatchSnapshot();
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=radio.component.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.component.test.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/radio/radio.component.test.tsx"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAExC,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,oBAAC,KAAK,IAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,GAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,KAAK,CAAC,CAAC,eAAe,EAAE,CAAC;AAClC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Radio } from './radio.component';
|
|
3
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Atoms/Radio',
|
|
6
|
+
component: Radio,
|
|
7
|
+
};
|
|
8
|
+
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
9
|
+
export const Primary = () => (React.createElement(React.Fragment, null,
|
|
10
|
+
React.createElement("div", { className: "flex flex-row" },
|
|
11
|
+
React.createElement(Radio, { checked: true, onChange: () => { } }),
|
|
12
|
+
React.createElement("span", null, "Married"))));
|
|
13
|
+
//# sourceMappingURL=radio.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.stories.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/radio/radio.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAExC,0GAA0G;AAC1G,eAAe;IACb,KAAK,EAAE,aAAa;IACpB,SAAS,EAAE,KAAK;CACc,CAAC;AAEjC,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAiC,GAAG,EAAE,CAAC,CACzD;IACE,6BAAK,SAAS,EAAC,eAAe;QAC5B,oBAAC,KAAK,IAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,GAAI;QAC5C,4CAAoB,CAChB,CACL,CACJ,CAAC"}
|
|
@@ -6,10 +6,6 @@ import { Stepper } from './stepper.component';
|
|
|
6
6
|
export default {
|
|
7
7
|
title: 'Atoms/Stepper',
|
|
8
8
|
component: Stepper,
|
|
9
|
-
// More on argTypes: https://storybook.js.org/docs/react/api/argtypes
|
|
10
|
-
argTypes: {
|
|
11
|
-
backgroundColor: { control: 'color' },
|
|
12
|
-
},
|
|
13
9
|
};
|
|
14
10
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
15
11
|
export const Primary = () => (React.createElement(Stepper, { steps: ['1', '2', '3', '4'], currentStep: 2, onStepClick: (currentStep, step) => { }, className: "mt-4" }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stepper.stories.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/stepper/stepper.stories.tsx"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,2CAA2C;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAE5C,0GAA0G;AAC1G,eAAe;IACb,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"stepper.stories.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/stepper/stepper.stories.tsx"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,2CAA2C;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,OAAO,EAAC,MAAM,qBAAqB,CAAC;AAE5C,0GAA0G;AAC1G,eAAe;IACb,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,OAAO;CACc,CAAC;AAEnC,2GAA2G;AAC3G,MAAM,CAAC,MAAM,OAAO,GAAmC,GAAG,EAAE,CAAC,CAC3D,oBAAC,OAAO,IACN,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC3B,WAAW,EAAE,CAAC,EACd,WAAW,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,GAAE,CAAC,EACtC,SAAS,EAAC,MAAM,GAChB,CACH,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* eslint-disable react/prop-types */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
3
|
+
import React, { useEffect, useState, useImperativeHandle } from 'react';
|
|
4
|
+
import { ReactComponent as TimerSVG } from '../../../library/assets/svg/timer.svg';
|
|
5
|
+
// eslint-disable-next-line react/display-name
|
|
6
|
+
export const Timer = React.forwardRef(({ onClear }, ref) => {
|
|
7
|
+
const width = 15;
|
|
8
|
+
const [minute, setMinute] = useState('00');
|
|
9
|
+
const [second, setSecond] = useState('10');
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const sec = parseInt(second);
|
|
12
|
+
const min = parseInt(minute);
|
|
13
|
+
const countDown = setInterval(() => {
|
|
14
|
+
if (min === 0 && sec === 0) {
|
|
15
|
+
setMinute('00');
|
|
16
|
+
setSecond('00');
|
|
17
|
+
clearInterval(countDown);
|
|
18
|
+
onClear && onClear();
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
let secondstTmp = (sec - 1).toString();
|
|
22
|
+
if (secondstTmp.length === 1) {
|
|
23
|
+
secondstTmp = '0'.concat(secondstTmp);
|
|
24
|
+
}
|
|
25
|
+
setSecond(secondstTmp);
|
|
26
|
+
if (sec === 0) {
|
|
27
|
+
setSecond('59');
|
|
28
|
+
const m = (min - 1).toString();
|
|
29
|
+
setMinute('0' + m);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, 1000);
|
|
33
|
+
return () => {
|
|
34
|
+
clearInterval(countDown);
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
useImperativeHandle(ref, () => ({
|
|
38
|
+
updateState() {
|
|
39
|
+
setMinute('02');
|
|
40
|
+
setSecond('00');
|
|
41
|
+
},
|
|
42
|
+
resetTimer() {
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
44
|
+
const sec = parseInt(second);
|
|
45
|
+
const min = parseInt(minute === '00' ? '02' : minute);
|
|
46
|
+
const countDown = setInterval(() => {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
|
+
if (min === 0 && sec === 0) {
|
|
49
|
+
setMinute('00');
|
|
50
|
+
setSecond('00');
|
|
51
|
+
clearInterval(countDown);
|
|
52
|
+
onClear && onClear();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
let secondstTmp = (sec - 1).toString();
|
|
56
|
+
if (secondstTmp.length === 1) {
|
|
57
|
+
secondstTmp = '0'.concat(secondstTmp);
|
|
58
|
+
}
|
|
59
|
+
setSecond(secondstTmp);
|
|
60
|
+
if (sec === 0) {
|
|
61
|
+
setSecond('59');
|
|
62
|
+
const m = (min - 1).toString();
|
|
63
|
+
setMinute('0' + m);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}, 1000);
|
|
67
|
+
return () => {
|
|
68
|
+
clearInterval(countDown);
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
}));
|
|
72
|
+
return (React.createElement("div", { className: "flex flex-row items-center" },
|
|
73
|
+
React.createElement(TimerSVG, { width: width, height: width, fill: "#E7503D" }),
|
|
74
|
+
React.createElement("div", { className: "ml-2 flex flex-row" },
|
|
75
|
+
React.createElement("span", null,
|
|
76
|
+
minute,
|
|
77
|
+
":"),
|
|
78
|
+
React.createElement("span", null, second))));
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=timer.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timer.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/timer/timer.component.tsx"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,6DAA6D;AAC7D,OAAO,KAAK,EAAE,EAAC,SAAS,EAAO,QAAQ,EAAE,mBAAmB,EAAC,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAC,cAAc,IAAI,QAAQ,EAAC,MAAM,uCAAuC,CAAC;AAMjF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CACnC,CAAC,EAAC,OAAO,EAAa,EAAE,GAAa,EAAE,EAAE;IACvC,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,GAAG,GAAW,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,GAAG,GAAW,QAAQ,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE;YACjC,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,EAAE;gBAC1B,SAAS,CAAC,IAAI,CAAC,CAAC;gBAChB,SAAS,CAAC,IAAI,CAAC,CAAC;gBAChB,aAAa,CAAC,SAAS,CAAC,CAAC;gBACzB,OAAO,IAAI,OAAO,EAAE,CAAC;aACtB;iBAAM;gBACL,IAAI,WAAW,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,EA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