@xaypay/tui 0.2.10 → 0.2.12

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/dist/index.es.js CHANGED
@@ -1465,6 +1465,22 @@ const SvgDeleteComponent = ({
1465
1465
  fill: fillColor ? fillColor : '#E00'
1466
1466
  }));
1467
1467
 
1468
+ class FileTypeParser {
1469
+ static ftypHeader = new Uint8Array([0x66, 0x74, 0x79, 0x70]);
1470
+ hasISOBaseMediaFile(buffer) {
1471
+ const slicedBuffer = new Uint8Array(buffer.slice(0, 12));
1472
+ return this.check(slicedBuffer, FileTypeParser.ftypHeader, {
1473
+ offset: 4
1474
+ }) && (slicedBuffer[8] & 0x60) !== 0x00;
1475
+ }
1476
+ check(buffer, headers, options) {
1477
+ for (const [index, header] of headers.entries()) {
1478
+ if (header !== buffer[index + options.offset]) return false;
1479
+ }
1480
+ return true;
1481
+ }
1482
+ }
1483
+
1468
1484
  // eslint-disable-next-line react/display-name
1469
1485
  const File = /*#__PURE__*/forwardRef(({
1470
1486
  or,
@@ -1572,6 +1588,15 @@ const File = /*#__PURE__*/forwardRef(({
1572
1588
  const [configStyles, setConfigStyles] = useState({});
1573
1589
  const [choosenFileCount, setChoosenFileCount] = useState(0);
1574
1590
  const [image, setImage] = useState(!multiple ? defaultData ? defaultData.type !== 'application/pdf' ? defaultData.url : 'pdf' : null : null);
1591
+ const handleCheckHeicFormat = async file => {
1592
+ const buffer = await file.arrayBuffer();
1593
+ const fileTypeParser = new FileTypeParser();
1594
+ const hasISOBaseMediaFile = fileTypeParser.hasISOBaseMediaFile(buffer);
1595
+ if (hasISOBaseMediaFile) {
1596
+ return Promise.resolve();
1597
+ }
1598
+ return Promise.reject();
1599
+ };
1575
1600
  const handleRemoveComponent = () => {
1576
1601
  if (!multiple) {
1577
1602
  removeFile && removeFile(singleFile);
@@ -1600,14 +1625,32 @@ const File = /*#__PURE__*/forwardRef(({
1600
1625
  for (let ix = 0; ix < file.length; ix++) {
1601
1626
  if (file[ix]) {
1602
1627
  if (file[ix].size <= maxSize * Math.pow(2, 20)) {
1603
- if (fileExtensions.includes(file[ix].type.split('/')[1]) || fileExtensions.includes('heic') && file[ix].type.split('/')[1] === 'heif') {
1604
- change({
1605
- id: '',
1606
- check: '',
1607
- status: '',
1608
- file: file[ix],
1609
- uuid: v4()
1610
- });
1628
+ if (fileExtensions.includes(file[ix].type.split('/')[1]) || file[ix].name.toLowerCase().endsWith('.heic') || file[ix].name.toLowerCase().endsWith('.heif')) {
1629
+ if ((fileExtensions.includes('heic') || fileExtensions.includes('heif')) && (file[ix].name.toLowerCase().endsWith('.heic') || file[ix].name.toLowerCase().endsWith('.heif'))) {
1630
+ handleCheckHeicFormat(file[ix]).then(() => {
1631
+ change({
1632
+ id: '',
1633
+ check: '',
1634
+ status: '',
1635
+ file: file[ix],
1636
+ uuid: v4()
1637
+ });
1638
+ }).catch(() => {
1639
+ change({
1640
+ file: file[ix],
1641
+ uuid: v4(),
1642
+ check: formatError ?? configStyles.FILE.error.format
1643
+ });
1644
+ });
1645
+ } else {
1646
+ change({
1647
+ id: '',
1648
+ check: '',
1649
+ status: '',
1650
+ file: file[ix],
1651
+ uuid: v4()
1652
+ });
1653
+ }
1611
1654
  } else {
1612
1655
  change({
1613
1656
  file: file[ix],
@@ -1629,14 +1672,32 @@ const File = /*#__PURE__*/forwardRef(({
1629
1672
  for (let ix = 0; ix < file.length; ix++) {
1630
1673
  if (file[ix]) {
1631
1674
  if (file[ix].size <= maxSize * Math.pow(2, 20)) {
1632
- if (fileExtensions.includes(file[ix].type.split('/')[1]) || fileExtensions.includes('heic') && file[ix].type.split('/')[1] === 'heif') {
1633
- change({
1634
- id: '',
1635
- check: '',
1636
- status: '',
1637
- file: file[ix],
1638
- uuid: v4()
1639
- });
1675
+ if (fileExtensions.includes(file[ix].type.split('/')[1]) || file[ix].name.toLowerCase().endsWith('.heic') || file[ix].name.toLowerCase().endsWith('.heif')) {
1676
+ if ((fileExtensions.includes('heic') || fileExtensions.includes('heif')) && (file[ix].name.toLowerCase().endsWith('.heic') || file[ix].name.toLowerCase().endsWith('.heif'))) {
1677
+ handleCheckHeicFormat(file[ix]).then(() => {
1678
+ change({
1679
+ id: '',
1680
+ check: '',
1681
+ status: '',
1682
+ file: file[ix],
1683
+ uuid: v4()
1684
+ });
1685
+ }).catch(() => {
1686
+ change({
1687
+ file: file[ix],
1688
+ uuid: v4(),
1689
+ check: formatError ?? configStyles.FILE.error.format
1690
+ });
1691
+ });
1692
+ } else {
1693
+ change({
1694
+ id: '',
1695
+ check: '',
1696
+ status: '',
1697
+ file: file[ix],
1698
+ uuid: v4()
1699
+ });
1700
+ }
1640
1701
  } else {
1641
1702
  change({
1642
1703
  file: file[ix],
@@ -1667,14 +1728,19 @@ const File = /*#__PURE__*/forwardRef(({
1667
1728
  } else {
1668
1729
  if (file[0]) {
1669
1730
  if (file[0].size <= maxSize * Math.pow(2, 20)) {
1670
- if (fileExtensions.includes(file[0].type.split('/')[1]) || fileExtensions.includes('heic') && (file[0].type === 'image/heif' || file[0].type === 'image/heic')) {
1731
+ if (fileExtensions.includes(file[0].type.split('/')[1]) || (fileExtensions.includes('heic') || fileExtensions.includes('heif')) && (file[0].type === 'image/heif' || file[0].type === 'image/heic' || file[0].name.toLowerCase().endsWith('.heic') || file[0].name.toLowerCase().endsWith('.heif'))) {
1671
1732
  setError('');
1672
1733
  change(file);
1673
1734
  setSingleFile(file);
1674
1735
  if (file[0].type === 'application/pdf') {
1675
1736
  setImage('pdf');
1676
- } else if (file[0].type === 'image/heif' || file[0].type === 'image/heic') {
1677
- setImage('heic');
1737
+ } else if (file[0].type === 'image/heif' || file[0].type === 'image/heic' || file[0].name.toLowerCase().endsWith('.heic') || file[0].name.toLowerCase().endsWith('.heif')) {
1738
+ handleCheckHeicFormat(file[0]).then(() => {
1739
+ setImage('heic');
1740
+ }).catch(() => {
1741
+ setImage(null);
1742
+ setError(formatError ?? configStyles.FILE.error.format);
1743
+ });
1678
1744
  } else {
1679
1745
  setImage(URL.createObjectURL(file[0]));
1680
1746
  }
@@ -2276,6 +2342,9 @@ const handleUtilsMouseEnterLeave = (e, behaviourStyle) => {
2276
2342
  };
2277
2343
  const handleUtilsCheckTypeTel = (val, prevVal) => {
2278
2344
  const phoneNumberRegex = /^\d{0,8}$/;
2345
+ if (val.length > 7) {
2346
+ val = val.substr(0, 8);
2347
+ }
2279
2348
  if (!phoneNumberRegex.test(val)) {
2280
2349
  val = prevVal;
2281
2350
  }
@@ -2310,14 +2379,16 @@ const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumS
2310
2379
  }
2311
2380
  }
2312
2381
  if (!regNum.test(val)) {
2313
- const newStr = val.replace(/[^0-9.]/g, '').replace(/^([^.]*\.|\․|\.|\,)(.*)$/, function (_, b, c) {
2382
+ let newVal = typeof val === 'number' ? val.toString() : val;
2383
+ const newStr = newVal.replace(/[^0-9.]/g, '').replace(/^([^.]*\.|\․|\.|\,)(.*)$/, function (_, b, c) {
2314
2384
  return b + c.replace(/\.|\․|\.|\,/g, '');
2315
2385
  });
2316
2386
  val = newStr;
2317
2387
  }
2318
2388
  }
2319
2389
  if (withoutDot && !/^\d+$/.test(val)) {
2320
- const newStr = val.replace(/[^0-9]/g, '').replace(/^([^.]*\.|\․|\.|\,)(.*)$/, function (_, b, c) {
2390
+ let newVal = typeof val === 'number' ? val.toString() : val;
2391
+ const newStr = newVal.replace(/[^0-9]/g, '').replace(/^([^.]*\.|\․|\.|\,)(.*)$/, function (_, b, c) {
2321
2392
  return b + c.replace(/\.|\․|\.|\,/g, '');
2322
2393
  });
2323
2394
  val = newStr;
@@ -2329,6 +2400,9 @@ const handleUtilsOpenInNewTab = url => {
2329
2400
  imageLink.href = url, imageLink.target = '_blank';
2330
2401
  imageLink.click();
2331
2402
  };
2403
+ const handleRemoveLeadingZeros = str => {
2404
+ return str.replace(/^0+(\d)/, '$1');
2405
+ };
2332
2406
 
2333
2407
  function styleInject(css, ref) {
2334
2408
  if ( ref === void 0 ) ref = {};
@@ -3556,6 +3630,8 @@ const Modal = ({
3556
3630
  closeAreaBackgroundColor,
3557
3631
  type = 'content'
3558
3632
  }) => {
3633
+ const leftBtnRef = useRef(null);
3634
+ const rightBtnRef = useRef(null);
3559
3635
  const [select, setSelect] = useState(0);
3560
3636
  const [isHover, setIsHover] = useState(false);
3561
3637
  const [innerData, setInnerData] = useState([]);
@@ -3582,6 +3658,17 @@ const Modal = ({
3582
3658
  }
3583
3659
  }
3584
3660
  };
3661
+ const handleNavigateArrow = e => {
3662
+ if (e.key === 'ArrowRight') {
3663
+ if (rightBtnRef.current) {
3664
+ rightBtnRef.current.click();
3665
+ }
3666
+ } else if (e.key === 'ArrowLeft') {
3667
+ if (leftBtnRef.current) {
3668
+ leftBtnRef.current.click();
3669
+ }
3670
+ }
3671
+ };
3585
3672
  const handleESC = e => {
3586
3673
  if (e.key === 'Escape') {
3587
3674
  handleCloseModal();
@@ -3621,7 +3708,10 @@ const Modal = ({
3621
3708
  className && setClassProps(() => classnames(className ?? configStyles.MODAL.className));
3622
3709
  }, [className]);
3623
3710
  useEffect(() => {
3624
- document.addEventListener('keydown', handleESC, false);
3711
+ document.addEventListener('keydown', e => {
3712
+ handleESC(e);
3713
+ handleNavigateArrow(e);
3714
+ }, false);
3625
3715
  configStylesPromise.then(data => {
3626
3716
  setClassProps(() => classnames(className ?? data.MODAL.className));
3627
3717
  setConfigStyles(() => {
@@ -3635,7 +3725,10 @@ const Modal = ({
3635
3725
  return () => {
3636
3726
  setSelect(0);
3637
3727
  setInnerData([]);
3638
- document.removeEventListener('keydown', handleESC, false);
3728
+ document.removeEventListener('keydown', e => {
3729
+ handleESC(e);
3730
+ handleNavigateArrow(e);
3731
+ }, false);
3639
3732
  };
3640
3733
  }, []);
3641
3734
  return configStyles.MODAL && /*#__PURE__*/React__default.createElement("div", {
@@ -3809,6 +3902,7 @@ const Modal = ({
3809
3902
  }
3810
3903
  }
3811
3904
  }), innerData && innerData.length > 1 && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("button", {
3905
+ ref: leftBtnRef,
3812
3906
  onClick: () => handleGoTo('prev'),
3813
3907
  style: {
3814
3908
  position: 'absolute',
@@ -3823,6 +3917,7 @@ const Modal = ({
3823
3917
  backgroundColor: 'transparent'
3824
3918
  }
3825
3919
  }, prevIcon ? prevIcon : configStyles.MODAL.icon.prev ? configStyles.MODAL.icon.prev : /*#__PURE__*/React__default.createElement(SvgPrev, null)), /*#__PURE__*/React__default.createElement("button", {
3920
+ ref: rightBtnRef,
3826
3921
  onClick: () => handleGoTo('next'),
3827
3922
  style: {
3828
3923
  position: 'absolute',
@@ -3912,7 +4007,7 @@ const TelInput = ({
3912
4007
  useEffect(() => {
3913
4008
  let newValue = '';
3914
4009
  if (value !== undefined && value !== null) {
3915
- newValue = handleUtilsCheckTypeTel(value, newValue);
4010
+ newValue = handleUtilsCheckTypeTel(value);
3916
4011
  }
3917
4012
  setInnerValue(() => newValue);
3918
4013
  }, [value]);
@@ -4064,15 +4159,21 @@ const NumberInput = ({
4064
4159
  const [innerMinNumSize, setInnerMinNumSize] = useState(0);
4065
4160
  const handleChange = event => {
4066
4161
  let prevValue = innerValue;
4067
- let currentValue = event.target.value;
4162
+ let currentValue = event.target.value.replace(/\.|․|\.|,/g, '.');
4068
4163
  currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, null, float, maxNumSize, dots);
4069
4164
  setInnerValue(() => currentValue);
4070
4165
  if (inputChange && currentValue !== prevValue) {
4071
- if (currentValue < Number.MIN_SAFE_INTEGER || currentValue > Number.MAX_SAFE_INTEGER || innerMinNumSize && currentValue < innerMinNumSize || maxNumSize && currentValue > maxNumSize) {
4166
+ if (currentValue < Number.MIN_SAFE_INTEGER || currentValue > Number.MAX_SAFE_INTEGER) {
4167
+ if (currentValue === '') {
4168
+ setInnerErrorMessage(() => '');
4169
+ } else {
4170
+ setInnerErrorMessage(() => `Լրացված դաշտի արժեքը պետք է լինի ${Number.MIN_SAFE_INTEGER} - ${Number.MAX_SAFE_INTEGER} թվերի միջակայքում`);
4171
+ }
4172
+ } else if (innerMinNumSize && currentValue < innerMinNumSize || maxNumSize && currentValue > maxNumSize) {
4072
4173
  if (currentValue === '') {
4073
4174
  setInnerErrorMessage(() => '');
4074
4175
  } else {
4075
- setInnerErrorMessage(() => `Լրացված դաշտի արժեքը պետք է լինի ${innerMinNumSize} - ${maxNumSize} միջակայքում`);
4176
+ setInnerErrorMessage(() => `Լրացված դաշտի արժեքը պետք է լինի ${innerMinNumSize} - ${maxNumSize} թվերի միջակայքում`);
4076
4177
  }
4077
4178
  } else if (currentValue >= Number.MIN_SAFE_INTEGER || currentValue <= Number.MAX_SAFE_INTEGER || innerMinNumSize && currentValue >= innerMinNumSize || maxNumSize && currentValue <= maxNumSize) {
4078
4179
  inputChange(currentValue);
@@ -4080,6 +4181,14 @@ const NumberInput = ({
4080
4181
  }
4081
4182
  }
4082
4183
  };
4184
+ const handleBlur = () => {
4185
+ const newVal = handleRemoveLeadingZeros(innerValue);
4186
+ if (parseFloat(newVal) === 0) {
4187
+ inputChange('');
4188
+ } else {
4189
+ inputChange(newVal);
4190
+ }
4191
+ };
4083
4192
  useEffect(() => {
4084
4193
  if (minNumSize && minNumSize < 0) {
4085
4194
  setInnerMinNumSize(0);
@@ -4113,6 +4222,7 @@ const NumberInput = ({
4113
4222
  },
4114
4223
  min: minNumSize,
4115
4224
  max: maxNumSize,
4225
+ onBlur: handleBlur,
4116
4226
  onInput: handleChange
4117
4227
  });
4118
4228
  };
@@ -4304,7 +4414,7 @@ const Input = ({
4304
4414
  boxSizing: boxSizing ?? configStyles.INPUT.box.sizing,
4305
4415
  borderTopLeftRadius: radius ?? configStyles.INPUT.radius,
4306
4416
  borderBottomLeftRadius: radius ?? configStyles.INPUT.radius,
4307
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : configStyles.INPUT.colors.background
4417
+ backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : configStyles.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : configStyles.INPUT.colors.background
4308
4418
  }
4309
4419
  }, type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]) : '', type === 'tel' ? /*#__PURE__*/React__default.createElement(TelInput, {
4310
4420
  type: type,
@@ -4365,7 +4475,7 @@ const Input = ({
4365
4475
  boxSizing: boxSizing ?? configStyles.INPUT.box.sizing,
4366
4476
  borderTopRightRadius: radius ?? configStyles.INPUT.radius,
4367
4477
  borderBottomRightRadius: radius ?? configStyles.INPUT.radius,
4368
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : configStyles.INPUT.colors.background
4478
+ backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : configStyles.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : configStyles.INPUT.colors.background
4369
4479
  }
4370
4480
  }, type === 'password' ? show ? rightIcon[1] : rightIcon[0] : rightIcon[0]) : ''), tooltip ? tooltip : '', innerErrorMessage ? /*#__PURE__*/React__default.createElement(P, {
4371
4481
  animation: animation,
@@ -4932,7 +5042,7 @@ const Select = ({
4932
5042
  transform: opened ? 'rotate(180deg)' : 'rotate(0deg)'
4933
5043
  },
4934
5044
  className: `${styles$6['arrow-icon']}`
4935
- }, arrowIcon ? arrowIcon : configStyles.SELECT.arrowIcon ? configStyles.SELECT.arrowIcon : /*#__PURE__*/React__default.createElement(SvgArrow, null)) : '')), opened && !disabled ? /*#__PURE__*/React__default.createElement("div", {
5045
+ }, arrowIcon ? arrowIcon : configStyles.SELECT.arrowIcon ? configStyles.SELECT.arrowIcon : /*#__PURE__*/React__default.createElement(SvgArrow, null)) : '')), opened && existOptions && existOptions.length > 0 && !disabled ? /*#__PURE__*/React__default.createElement("div", {
4936
5046
  style: {
4937
5047
  boxShadow: optionsBoxShadow ?? configStyles.SELECT.options.box.shadow,
4938
5048
  borderRadius: optionsBorderRadius ?? configStyles.SELECT.options.radius,
package/dist/index.js CHANGED
@@ -1496,6 +1496,22 @@ const SvgDeleteComponent = ({
1496
1496
  fill: fillColor ? fillColor : '#E00'
1497
1497
  }));
1498
1498
 
1499
+ class FileTypeParser {
1500
+ static ftypHeader = new Uint8Array([0x66, 0x74, 0x79, 0x70]);
1501
+ hasISOBaseMediaFile(buffer) {
1502
+ const slicedBuffer = new Uint8Array(buffer.slice(0, 12));
1503
+ return this.check(slicedBuffer, FileTypeParser.ftypHeader, {
1504
+ offset: 4
1505
+ }) && (slicedBuffer[8] & 0x60) !== 0x00;
1506
+ }
1507
+ check(buffer, headers, options) {
1508
+ for (const [index, header] of headers.entries()) {
1509
+ if (header !== buffer[index + options.offset]) return false;
1510
+ }
1511
+ return true;
1512
+ }
1513
+ }
1514
+
1499
1515
  // eslint-disable-next-line react/display-name
1500
1516
  const File = /*#__PURE__*/React.forwardRef(({
1501
1517
  or,
@@ -1603,6 +1619,15 @@ const File = /*#__PURE__*/React.forwardRef(({
1603
1619
  const [configStyles, setConfigStyles] = React.useState({});
1604
1620
  const [choosenFileCount, setChoosenFileCount] = React.useState(0);
1605
1621
  const [image, setImage] = React.useState(!multiple ? defaultData ? defaultData.type !== 'application/pdf' ? defaultData.url : 'pdf' : null : null);
1622
+ const handleCheckHeicFormat = async file => {
1623
+ const buffer = await file.arrayBuffer();
1624
+ const fileTypeParser = new FileTypeParser();
1625
+ const hasISOBaseMediaFile = fileTypeParser.hasISOBaseMediaFile(buffer);
1626
+ if (hasISOBaseMediaFile) {
1627
+ return Promise.resolve();
1628
+ }
1629
+ return Promise.reject();
1630
+ };
1606
1631
  const handleRemoveComponent = () => {
1607
1632
  if (!multiple) {
1608
1633
  removeFile && removeFile(singleFile);
@@ -1631,14 +1656,32 @@ const File = /*#__PURE__*/React.forwardRef(({
1631
1656
  for (let ix = 0; ix < file.length; ix++) {
1632
1657
  if (file[ix]) {
1633
1658
  if (file[ix].size <= maxSize * Math.pow(2, 20)) {
1634
- if (fileExtensions.includes(file[ix].type.split('/')[1]) || fileExtensions.includes('heic') && file[ix].type.split('/')[1] === 'heif') {
1635
- change({
1636
- id: '',
1637
- check: '',
1638
- status: '',
1639
- file: file[ix],
1640
- uuid: v4()
1641
- });
1659
+ if (fileExtensions.includes(file[ix].type.split('/')[1]) || file[ix].name.toLowerCase().endsWith('.heic') || file[ix].name.toLowerCase().endsWith('.heif')) {
1660
+ if ((fileExtensions.includes('heic') || fileExtensions.includes('heif')) && (file[ix].name.toLowerCase().endsWith('.heic') || file[ix].name.toLowerCase().endsWith('.heif'))) {
1661
+ handleCheckHeicFormat(file[ix]).then(() => {
1662
+ change({
1663
+ id: '',
1664
+ check: '',
1665
+ status: '',
1666
+ file: file[ix],
1667
+ uuid: v4()
1668
+ });
1669
+ }).catch(() => {
1670
+ change({
1671
+ file: file[ix],
1672
+ uuid: v4(),
1673
+ check: formatError ?? configStyles.FILE.error.format
1674
+ });
1675
+ });
1676
+ } else {
1677
+ change({
1678
+ id: '',
1679
+ check: '',
1680
+ status: '',
1681
+ file: file[ix],
1682
+ uuid: v4()
1683
+ });
1684
+ }
1642
1685
  } else {
1643
1686
  change({
1644
1687
  file: file[ix],
@@ -1660,14 +1703,32 @@ const File = /*#__PURE__*/React.forwardRef(({
1660
1703
  for (let ix = 0; ix < file.length; ix++) {
1661
1704
  if (file[ix]) {
1662
1705
  if (file[ix].size <= maxSize * Math.pow(2, 20)) {
1663
- if (fileExtensions.includes(file[ix].type.split('/')[1]) || fileExtensions.includes('heic') && file[ix].type.split('/')[1] === 'heif') {
1664
- change({
1665
- id: '',
1666
- check: '',
1667
- status: '',
1668
- file: file[ix],
1669
- uuid: v4()
1670
- });
1706
+ if (fileExtensions.includes(file[ix].type.split('/')[1]) || file[ix].name.toLowerCase().endsWith('.heic') || file[ix].name.toLowerCase().endsWith('.heif')) {
1707
+ if ((fileExtensions.includes('heic') || fileExtensions.includes('heif')) && (file[ix].name.toLowerCase().endsWith('.heic') || file[ix].name.toLowerCase().endsWith('.heif'))) {
1708
+ handleCheckHeicFormat(file[ix]).then(() => {
1709
+ change({
1710
+ id: '',
1711
+ check: '',
1712
+ status: '',
1713
+ file: file[ix],
1714
+ uuid: v4()
1715
+ });
1716
+ }).catch(() => {
1717
+ change({
1718
+ file: file[ix],
1719
+ uuid: v4(),
1720
+ check: formatError ?? configStyles.FILE.error.format
1721
+ });
1722
+ });
1723
+ } else {
1724
+ change({
1725
+ id: '',
1726
+ check: '',
1727
+ status: '',
1728
+ file: file[ix],
1729
+ uuid: v4()
1730
+ });
1731
+ }
1671
1732
  } else {
1672
1733
  change({
1673
1734
  file: file[ix],
@@ -1698,14 +1759,19 @@ const File = /*#__PURE__*/React.forwardRef(({
1698
1759
  } else {
1699
1760
  if (file[0]) {
1700
1761
  if (file[0].size <= maxSize * Math.pow(2, 20)) {
1701
- if (fileExtensions.includes(file[0].type.split('/')[1]) || fileExtensions.includes('heic') && (file[0].type === 'image/heif' || file[0].type === 'image/heic')) {
1762
+ if (fileExtensions.includes(file[0].type.split('/')[1]) || (fileExtensions.includes('heic') || fileExtensions.includes('heif')) && (file[0].type === 'image/heif' || file[0].type === 'image/heic' || file[0].name.toLowerCase().endsWith('.heic') || file[0].name.toLowerCase().endsWith('.heif'))) {
1702
1763
  setError('');
1703
1764
  change(file);
1704
1765
  setSingleFile(file);
1705
1766
  if (file[0].type === 'application/pdf') {
1706
1767
  setImage('pdf');
1707
- } else if (file[0].type === 'image/heif' || file[0].type === 'image/heic') {
1708
- setImage('heic');
1768
+ } else if (file[0].type === 'image/heif' || file[0].type === 'image/heic' || file[0].name.toLowerCase().endsWith('.heic') || file[0].name.toLowerCase().endsWith('.heif')) {
1769
+ handleCheckHeicFormat(file[0]).then(() => {
1770
+ setImage('heic');
1771
+ }).catch(() => {
1772
+ setImage(null);
1773
+ setError(formatError ?? configStyles.FILE.error.format);
1774
+ });
1709
1775
  } else {
1710
1776
  setImage(URL.createObjectURL(file[0]));
1711
1777
  }
@@ -2307,6 +2373,9 @@ const handleUtilsMouseEnterLeave = (e, behaviourStyle) => {
2307
2373
  };
2308
2374
  const handleUtilsCheckTypeTel = (val, prevVal) => {
2309
2375
  const phoneNumberRegex = /^\d{0,8}$/;
2376
+ if (val.length > 7) {
2377
+ val = val.substr(0, 8);
2378
+ }
2310
2379
  if (!phoneNumberRegex.test(val)) {
2311
2380
  val = prevVal;
2312
2381
  }
@@ -2341,14 +2410,16 @@ const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumS
2341
2410
  }
2342
2411
  }
2343
2412
  if (!regNum.test(val)) {
2344
- const newStr = val.replace(/[^0-9.]/g, '').replace(/^([^.]*\.|\․|\.|\,)(.*)$/, function (_, b, c) {
2413
+ let newVal = typeof val === 'number' ? val.toString() : val;
2414
+ const newStr = newVal.replace(/[^0-9.]/g, '').replace(/^([^.]*\.|\․|\.|\,)(.*)$/, function (_, b, c) {
2345
2415
  return b + c.replace(/\.|\․|\.|\,/g, '');
2346
2416
  });
2347
2417
  val = newStr;
2348
2418
  }
2349
2419
  }
2350
2420
  if (withoutDot && !/^\d+$/.test(val)) {
2351
- const newStr = val.replace(/[^0-9]/g, '').replace(/^([^.]*\.|\․|\.|\,)(.*)$/, function (_, b, c) {
2421
+ let newVal = typeof val === 'number' ? val.toString() : val;
2422
+ const newStr = newVal.replace(/[^0-9]/g, '').replace(/^([^.]*\.|\․|\.|\,)(.*)$/, function (_, b, c) {
2352
2423
  return b + c.replace(/\.|\․|\.|\,/g, '');
2353
2424
  });
2354
2425
  val = newStr;
@@ -2360,6 +2431,9 @@ const handleUtilsOpenInNewTab = url => {
2360
2431
  imageLink.href = url, imageLink.target = '_blank';
2361
2432
  imageLink.click();
2362
2433
  };
2434
+ const handleRemoveLeadingZeros = str => {
2435
+ return str.replace(/^0+(\d)/, '$1');
2436
+ };
2363
2437
 
2364
2438
  function styleInject(css, ref) {
2365
2439
  if ( ref === void 0 ) ref = {};
@@ -3587,6 +3661,8 @@ const Modal = ({
3587
3661
  closeAreaBackgroundColor,
3588
3662
  type = 'content'
3589
3663
  }) => {
3664
+ const leftBtnRef = React.useRef(null);
3665
+ const rightBtnRef = React.useRef(null);
3590
3666
  const [select, setSelect] = React.useState(0);
3591
3667
  const [isHover, setIsHover] = React.useState(false);
3592
3668
  const [innerData, setInnerData] = React.useState([]);
@@ -3613,6 +3689,17 @@ const Modal = ({
3613
3689
  }
3614
3690
  }
3615
3691
  };
3692
+ const handleNavigateArrow = e => {
3693
+ if (e.key === 'ArrowRight') {
3694
+ if (rightBtnRef.current) {
3695
+ rightBtnRef.current.click();
3696
+ }
3697
+ } else if (e.key === 'ArrowLeft') {
3698
+ if (leftBtnRef.current) {
3699
+ leftBtnRef.current.click();
3700
+ }
3701
+ }
3702
+ };
3616
3703
  const handleESC = e => {
3617
3704
  if (e.key === 'Escape') {
3618
3705
  handleCloseModal();
@@ -3652,7 +3739,10 @@ const Modal = ({
3652
3739
  className && setClassProps(() => classnames__default["default"](className ?? configStyles.MODAL.className));
3653
3740
  }, [className]);
3654
3741
  React.useEffect(() => {
3655
- document.addEventListener('keydown', handleESC, false);
3742
+ document.addEventListener('keydown', e => {
3743
+ handleESC(e);
3744
+ handleNavigateArrow(e);
3745
+ }, false);
3656
3746
  configStylesPromise.then(data => {
3657
3747
  setClassProps(() => classnames__default["default"](className ?? data.MODAL.className));
3658
3748
  setConfigStyles(() => {
@@ -3666,7 +3756,10 @@ const Modal = ({
3666
3756
  return () => {
3667
3757
  setSelect(0);
3668
3758
  setInnerData([]);
3669
- document.removeEventListener('keydown', handleESC, false);
3759
+ document.removeEventListener('keydown', e => {
3760
+ handleESC(e);
3761
+ handleNavigateArrow(e);
3762
+ }, false);
3670
3763
  };
3671
3764
  }, []);
3672
3765
  return configStyles.MODAL && /*#__PURE__*/React__default["default"].createElement("div", {
@@ -3840,6 +3933,7 @@ const Modal = ({
3840
3933
  }
3841
3934
  }
3842
3935
  }), innerData && innerData.length > 1 && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("button", {
3936
+ ref: leftBtnRef,
3843
3937
  onClick: () => handleGoTo('prev'),
3844
3938
  style: {
3845
3939
  position: 'absolute',
@@ -3854,6 +3948,7 @@ const Modal = ({
3854
3948
  backgroundColor: 'transparent'
3855
3949
  }
3856
3950
  }, prevIcon ? prevIcon : configStyles.MODAL.icon.prev ? configStyles.MODAL.icon.prev : /*#__PURE__*/React__default["default"].createElement(SvgPrev, null)), /*#__PURE__*/React__default["default"].createElement("button", {
3951
+ ref: rightBtnRef,
3857
3952
  onClick: () => handleGoTo('next'),
3858
3953
  style: {
3859
3954
  position: 'absolute',
@@ -3943,7 +4038,7 @@ const TelInput = ({
3943
4038
  React.useEffect(() => {
3944
4039
  let newValue = '';
3945
4040
  if (value !== undefined && value !== null) {
3946
- newValue = handleUtilsCheckTypeTel(value, newValue);
4041
+ newValue = handleUtilsCheckTypeTel(value);
3947
4042
  }
3948
4043
  setInnerValue(() => newValue);
3949
4044
  }, [value]);
@@ -4095,15 +4190,21 @@ const NumberInput = ({
4095
4190
  const [innerMinNumSize, setInnerMinNumSize] = React.useState(0);
4096
4191
  const handleChange = event => {
4097
4192
  let prevValue = innerValue;
4098
- let currentValue = event.target.value;
4193
+ let currentValue = event.target.value.replace(/\.|․|\.|,/g, '.');
4099
4194
  currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, null, float, maxNumSize, dots);
4100
4195
  setInnerValue(() => currentValue);
4101
4196
  if (inputChange && currentValue !== prevValue) {
4102
- if (currentValue < Number.MIN_SAFE_INTEGER || currentValue > Number.MAX_SAFE_INTEGER || innerMinNumSize && currentValue < innerMinNumSize || maxNumSize && currentValue > maxNumSize) {
4197
+ if (currentValue < Number.MIN_SAFE_INTEGER || currentValue > Number.MAX_SAFE_INTEGER) {
4198
+ if (currentValue === '') {
4199
+ setInnerErrorMessage(() => '');
4200
+ } else {
4201
+ setInnerErrorMessage(() => `Լրացված դաշտի արժեքը պետք է լինի ${Number.MIN_SAFE_INTEGER} - ${Number.MAX_SAFE_INTEGER} թվերի միջակայքում`);
4202
+ }
4203
+ } else if (innerMinNumSize && currentValue < innerMinNumSize || maxNumSize && currentValue > maxNumSize) {
4103
4204
  if (currentValue === '') {
4104
4205
  setInnerErrorMessage(() => '');
4105
4206
  } else {
4106
- setInnerErrorMessage(() => `Լրացված դաշտի արժեքը պետք է լինի ${innerMinNumSize} - ${maxNumSize} միջակայքում`);
4207
+ setInnerErrorMessage(() => `Լրացված դաշտի արժեքը պետք է լինի ${innerMinNumSize} - ${maxNumSize} թվերի միջակայքում`);
4107
4208
  }
4108
4209
  } else if (currentValue >= Number.MIN_SAFE_INTEGER || currentValue <= Number.MAX_SAFE_INTEGER || innerMinNumSize && currentValue >= innerMinNumSize || maxNumSize && currentValue <= maxNumSize) {
4109
4210
  inputChange(currentValue);
@@ -4111,6 +4212,14 @@ const NumberInput = ({
4111
4212
  }
4112
4213
  }
4113
4214
  };
4215
+ const handleBlur = () => {
4216
+ const newVal = handleRemoveLeadingZeros(innerValue);
4217
+ if (parseFloat(newVal) === 0) {
4218
+ inputChange('');
4219
+ } else {
4220
+ inputChange(newVal);
4221
+ }
4222
+ };
4114
4223
  React.useEffect(() => {
4115
4224
  if (minNumSize && minNumSize < 0) {
4116
4225
  setInnerMinNumSize(0);
@@ -4144,6 +4253,7 @@ const NumberInput = ({
4144
4253
  },
4145
4254
  min: minNumSize,
4146
4255
  max: maxNumSize,
4256
+ onBlur: handleBlur,
4147
4257
  onInput: handleChange
4148
4258
  });
4149
4259
  };
@@ -4335,7 +4445,7 @@ const Input = ({
4335
4445
  boxSizing: boxSizing ?? configStyles.INPUT.box.sizing,
4336
4446
  borderTopLeftRadius: radius ?? configStyles.INPUT.radius,
4337
4447
  borderBottomLeftRadius: radius ?? configStyles.INPUT.radius,
4338
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : configStyles.INPUT.colors.background
4448
+ backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : configStyles.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : configStyles.INPUT.colors.background
4339
4449
  }
4340
4450
  }, type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]) : '', type === 'tel' ? /*#__PURE__*/React__default["default"].createElement(TelInput, {
4341
4451
  type: type,
@@ -4396,7 +4506,7 @@ const Input = ({
4396
4506
  boxSizing: boxSizing ?? configStyles.INPUT.box.sizing,
4397
4507
  borderTopRightRadius: radius ?? configStyles.INPUT.radius,
4398
4508
  borderBottomRightRadius: radius ?? configStyles.INPUT.radius,
4399
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : configStyles.INPUT.colors.background
4509
+ backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : configStyles.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : configStyles.INPUT.colors.background
4400
4510
  }
4401
4511
  }, type === 'password' ? show ? rightIcon[1] : rightIcon[0] : rightIcon[0]) : ''), tooltip ? tooltip : '', innerErrorMessage ? /*#__PURE__*/React__default["default"].createElement(P, {
4402
4512
  animation: animation,
@@ -4963,7 +5073,7 @@ const Select = ({
4963
5073
  transform: opened ? 'rotate(180deg)' : 'rotate(0deg)'
4964
5074
  },
4965
5075
  className: `${styles$6['arrow-icon']}`
4966
- }, arrowIcon ? arrowIcon : configStyles.SELECT.arrowIcon ? configStyles.SELECT.arrowIcon : /*#__PURE__*/React__default["default"].createElement(SvgArrow, null)) : '')), opened && !disabled ? /*#__PURE__*/React__default["default"].createElement("div", {
5076
+ }, arrowIcon ? arrowIcon : configStyles.SELECT.arrowIcon ? configStyles.SELECT.arrowIcon : /*#__PURE__*/React__default["default"].createElement(SvgArrow, null)) : '')), opened && existOptions && existOptions.length > 0 && !disabled ? /*#__PURE__*/React__default["default"].createElement("div", {
4967
5077
  style: {
4968
5078
  boxShadow: optionsBoxShadow ?? configStyles.SELECT.options.box.shadow,
4969
5079
  borderRadius: optionsBorderRadius ?? configStyles.SELECT.options.radius,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",