@xaypay/tui 0.2.13 → 0.2.14

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
@@ -521,6 +521,7 @@ var packageResult = {
521
521
  ...fontObject
522
522
  },
523
523
  label: {
524
+ dots: false,
524
525
  color: presetColors.dark,
525
526
  display: 'block',
526
527
  lineHeight: '22px',
@@ -1148,6 +1149,12 @@ var packageResult = {
1148
1149
  font: {
1149
1150
  ...fontObject
1150
1151
  }
1152
+ },
1153
+ draggable: {
1154
+ boxShadow: '1px 1px 9px black',
1155
+ color: {
1156
+ background: 'white'
1157
+ }
1151
1158
  }
1152
1159
  },
1153
1160
  // default properties for <Pagination /> component
@@ -1730,19 +1737,19 @@ const File = /*#__PURE__*/forwardRef(({
1730
1737
  setError('');
1731
1738
  if (file[0].type === 'application/pdf') {
1732
1739
  setImage('pdf');
1733
- change(file[0]);
1734
- setSingleFile(file[0]);
1740
+ change(file);
1741
+ setSingleFile(file);
1735
1742
  } else if (file[0].type === 'image/heif' || file[0].type === 'image/heic' || file[0].name.toLowerCase().endsWith('.heic') || file[0].name.toLowerCase().endsWith('.heif')) {
1736
1743
  handleCheckHeicFormat(file[0]).then(() => {
1737
1744
  setImage('heic');
1738
- change(file[0]);
1739
- setSingleFile(file[0]);
1745
+ change(file);
1746
+ setSingleFile(file);
1740
1747
  }).catch(() => {
1741
1748
  setImage(null);
1742
1749
  setError(formatError ?? configStyles.FILE.error.format);
1743
1750
  });
1744
1751
  } else {
1745
- change(file[0]);
1752
+ change(file);
1746
1753
  setImage(URL.createObjectURL(file[0]));
1747
1754
  }
1748
1755
  } else {
@@ -2351,7 +2358,7 @@ const handleUtilsCheckTypeTel = (val, prevVal) => {
2351
2358
  }
2352
2359
  return val;
2353
2360
  };
2354
- const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumSize, withoutDot, innerMinNumSize) => {
2361
+ const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumSize, withoutDot, innerMinNumSize, numberMaxLength) => {
2355
2362
  if (maxLength && maxLength > 0) {
2356
2363
  if (val.length > maxLength) {
2357
2364
  val = val.substr(0, maxLength);
@@ -2361,6 +2368,9 @@ const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumS
2361
2368
  if (val.length > 16 && !val.includes('.')) {
2362
2369
  val = val.substr(0, 16);
2363
2370
  }
2371
+ if (numberMaxLength && numberMaxLength > 0 && !val.includes('.')) {
2372
+ val = val.substr(0, numberMaxLength);
2373
+ }
2364
2374
  const floatNumParts = typeof val === 'string' ? val.split(/\.|\․|\.|\,/) : val;
2365
2375
  const int = floatNumParts[0];
2366
2376
  const float = floatNumParts[1];
@@ -2505,16 +2515,16 @@ const TD = ({
2505
2515
  item,
2506
2516
  index,
2507
2517
  rowItem,
2518
+ dragged,
2519
+ dragEnd,
2508
2520
  rowRadius,
2509
2521
  dragStart,
2510
- handleMouseDown,
2511
2522
  hideBorder,
2512
2523
  innerIndex,
2513
2524
  tBodyColor,
2514
2525
  orderColor,
2515
2526
  borderRight,
2516
2527
  tBodyPadding,
2517
- setIsDragging,
2518
2528
  orderFontSize,
2519
2529
  tBodyFontSize,
2520
2530
  openListColor,
@@ -2664,7 +2674,9 @@ const TD = ({
2664
2674
  height: '24px',
2665
2675
  cursor: 'grab'
2666
2676
  },
2667
- onDragStart: () => dragStart(index)
2677
+ onDrag: dragged,
2678
+ onDragEnd: dragEnd,
2679
+ onDragStart: e => dragStart(e, index, row)
2668
2680
  }, /*#__PURE__*/React__default.createElement("img", {
2669
2681
  src: img$1,
2670
2682
  alt: "drag"
@@ -2904,8 +2916,11 @@ const Table = ({
2904
2916
  draggable,
2905
2917
  showOrder,
2906
2918
  draggableColor,
2907
- getDraggableData
2919
+ getDraggableData,
2920
+ draggableItemBoxShadow,
2921
+ draggableItemBackgroundColor
2908
2922
  }) => {
2923
+ const itemRefs = useRef({});
2909
2924
  const headerRef = useRef(null);
2910
2925
  const draggedRowIndex = useRef(null);
2911
2926
  const [body, setBody] = useState([]);
@@ -2915,8 +2930,12 @@ const Table = ({
2915
2930
  const [checkDrag, setCheckDrag] = useState(false);
2916
2931
  const [checkedArray, setCheckedArray] = useState([]);
2917
2932
  const [configStyles, setConfigStyles] = useState({});
2918
- useState(false);
2919
- const [draggingIndex, setDraggingIndex] = useState(null);
2933
+ const [dragging, setDragging] = useState(false);
2934
+ const [draggedItem, setDraggedItem] = useState(null);
2935
+ const [position, setPosition] = useState({
2936
+ x: 0,
2937
+ y: 0
2938
+ });
2920
2939
  const handleCheckIfArrow = (bodyData, data) => {
2921
2940
  let removeItemIndex;
2922
2941
  let headerWithoutArrow = [];
@@ -3053,6 +3072,7 @@ const Table = ({
3053
3072
  }
3054
3073
  };
3055
3074
  const handleCheckedHeader = (data, e) => {
3075
+ console.log('ok - - - - - - - ');
3056
3076
  e.stopPropagation();
3057
3077
  let removeItemIndex;
3058
3078
  let checkableItemBool;
@@ -3323,11 +3343,19 @@ const Table = ({
3323
3343
  });
3324
3344
  setBody(() => checkBodyMore);
3325
3345
  };
3326
- const handleDragStart = index => {
3346
+ const handleDragStart = (e, index, row) => {
3347
+ setDragging(true);
3348
+ setDraggedItem(row);
3327
3349
  draggedRowIndex.current = index;
3328
- setDraggingIndex(() => index);
3350
+ e.dataTransfer.setDragImage(new Image(), 0, 0);
3329
3351
  };
3330
- const handleDrop = index => {
3352
+ const handleDrag = e => {
3353
+ setPosition({
3354
+ x: e.clientX,
3355
+ y: e.clientY
3356
+ });
3357
+ };
3358
+ const handleDrop = (e, index) => {
3331
3359
  let correctData = [];
3332
3360
  const newRows = body;
3333
3361
  const [draggedRow] = newRows.splice(draggedRowIndex.current, 1);
@@ -3339,8 +3367,20 @@ const Table = ({
3339
3367
  getDraggableData && getDraggableData(correctData);
3340
3368
  setCheckDrag(prev => !prev);
3341
3369
  draggedRowIndex.current = null;
3342
- setDraggingIndex(() => null);
3343
3370
  correctData = null;
3371
+ setDraggedItem(null);
3372
+ setDragging(false);
3373
+ e.dataTransfer.setDragImage(new Image(), 0, 0);
3374
+ };
3375
+ const handleDragEnd = e => {
3376
+ setDraggedItem(null);
3377
+ setDragging(false);
3378
+ e.dataTransfer.setDragImage(new Image(), 0, 0);
3379
+ };
3380
+ const setRef = (index, element) => {
3381
+ if (element) {
3382
+ itemRefs.current[index] = element;
3383
+ }
3344
3384
  };
3345
3385
  useEffect(() => {
3346
3386
  const draggableArray = body && body.length && body.map((item, index) => {
@@ -3545,22 +3585,24 @@ const Table = ({
3545
3585
  }
3546
3586
  }, body.map((item, index) => {
3547
3587
  return /*#__PURE__*/React__default.createElement("tr", {
3548
- onDragStart: () => handleDragStart(index),
3549
3588
  onDragOver: e => e.preventDefault(),
3550
- onDrop: () => handleDrop(index),
3589
+ onDrop: e => handleDrop(e, index),
3551
3590
  key: `${item}_${index}`,
3552
3591
  style: {
3553
3592
  backgroundColor: tableRowBGColor ?? configStyles.TABLE.body.row.colors.background,
3554
3593
  borderBottom: index === body.length - 1 ? 'none' : tBodyRowBorder ? tBodyRowBorder : configStyles.TABLE.body.row.border,
3555
3594
  borderColor: hideBorder ? 'transparent' : configStyles.TABLE.body.row.borderColor,
3556
3595
  boxShadow: (tableRowItem ? tableRowItem : configStyles.TABLE.body.row.asItem) ? tableRowBoxShadow ? tableRowBoxShadow : configStyles.TABLE.body.row.box.shadow : 'none'
3557
- }
3596
+ },
3597
+ ref: el => setRef(index, el)
3558
3598
  }, Object.values(item).map((innerItem, innerIndex) => {
3559
3599
  return /*#__PURE__*/React__default.createElement(TD, {
3560
3600
  index: index,
3561
3601
  item: innerItem,
3602
+ dragged: handleDrag,
3562
3603
  hideBorder: hideBorder,
3563
3604
  innerIndex: innerIndex,
3605
+ dragEnd: handleDragEnd,
3564
3606
  row: Object.values(item),
3565
3607
  dragStart: handleDragStart,
3566
3608
  id: item.id ? item.id : '',
@@ -3596,6 +3638,52 @@ const Table = ({
3596
3638
  handleOpenCloseRowSingleArrow: handleOpenCloseRowSingleArrow
3597
3639
  });
3598
3640
  }));
3641
+ })), draggable && dragging && draggedItem && /*#__PURE__*/React__default.createElement("div", {
3642
+ style: {
3643
+ position: 'fixed',
3644
+ top: `${position.y - 30}px`,
3645
+ left: `${position.x - 30}px`,
3646
+ borderSpacing: '0px',
3647
+ pointerEvents: 'none',
3648
+ height: 'fit-content',
3649
+ blockSize: 'fit-content',
3650
+ borderRadius: tableRowItem ? tableRowRadius ?? configStyles.TABLE.body.row.radius : '0px',
3651
+ boxShadow: draggableItemBoxShadow ?? configStyles.TABLE.draggable.boxShadow,
3652
+ backgroundColor: draggableItemBackgroundColor ?? configStyles.TABLE.draggable.color.background
3653
+ }
3654
+ }, draggedItem.map((innerItem, innerIndex) => {
3655
+ return /*#__PURE__*/React__default.createElement(TD, {
3656
+ item: innerItem,
3657
+ dragged: handleDrag,
3658
+ hideBorder: hideBorder,
3659
+ innerIndex: innerIndex,
3660
+ row: Object.values(draggedItem),
3661
+ dragStart: handleDragStart,
3662
+ handleCheckDots: handleCheckDots,
3663
+ key: `${innerItem}__${innerIndex}`,
3664
+ openListColor: openListColor ?? configStyles.TABLE.openList.color,
3665
+ tableColumnMinWidth: tableColumnMinWidth ?? configStyles.TABLE.column.minWidth,
3666
+ tableColumnMaxWidth: tableColumnMaxWidth ?? configStyles.TABLE.column.maxWidth,
3667
+ openListFontSize: openListFontSize ?? configStyles.TABLE.openList.font.size,
3668
+ openListFontStyle: openListFontStyle ?? configStyles.TABLE.openList.font.style,
3669
+ openListFontWeight: openListFontWeight ?? configStyles.TABLE.openList.font.weight,
3670
+ openListFontFamily: openListFontFamily ?? configStyles.TABLE.openList.font.family,
3671
+ tBodyColor: tBodyColor ?? configStyles.TABLE.body.color,
3672
+ orderColor: orderColor ?? configStyles.TABLE.order.color,
3673
+ rowItem: tableRowItem ?? configStyles.TABLE.body.row.isItem,
3674
+ tBodyPadding: tBodyPadding ?? configStyles.TABLE.body.padding,
3675
+ tBodyTextAlign: tBodyTextAlign ?? configStyles.TABLE.textAlign,
3676
+ rowRadius: tableRowRadius ?? configStyles.TABLE.body.row.radius,
3677
+ tBodyFontSize: tBodyFontSize ?? configStyles.TABLE.body.font.size,
3678
+ orderFontSize: orderFontSize ?? configStyles.TABLE.order.font.size,
3679
+ orderFontStyle: orderFontStyle ?? configStyles.TABLE.order.font.style,
3680
+ tBodyFontFamily: tBodyFontFamily ?? configStyles.TABLE.body.font.family,
3681
+ tBodyFontWeight: tBodyFontWeight ?? configStyles.TABLE.body.font.weight,
3682
+ orderFontFamily: orderFontFamily ?? configStyles.TABLE.order.font.family,
3683
+ orderFontWeight: orderFontWeight ?? configStyles.TABLE.order.font.weight,
3684
+ borderRight: innerIndex === Object.values(draggedItem).length - 1 ? 'none' : configStyles.TABLE.body.row.border,
3685
+ borderRightColor: innerIndex === Object.values(draggedItem).length - 1 ? 'transparent' : configStyles.TABLE.body.row.borderColor
3686
+ });
3599
3687
  })));
3600
3688
  };
3601
3689
  Table.propTypes = {
@@ -4308,6 +4396,7 @@ const NumberInput = ({
4308
4396
  value,
4309
4397
  float,
4310
4398
  radius,
4399
+ withZero,
4311
4400
  disabled,
4312
4401
  inpStyles,
4313
4402
  minNumSize,
@@ -4315,6 +4404,7 @@ const NumberInput = ({
4315
4404
  insideError,
4316
4405
  inputChange,
4317
4406
  inpAttributes,
4407
+ numberMaxLength,
4318
4408
  setInnerErrorMessage
4319
4409
  }) => {
4320
4410
  const [innerValue, setInnerValue] = useState('');
@@ -4322,7 +4412,7 @@ const NumberInput = ({
4322
4412
  const handleChange = event => {
4323
4413
  let prevValue = innerValue;
4324
4414
  let currentValue = event.target.value.replace(/\.|․|\.|,/g, '.');
4325
- currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, null, float, maxNumSize, dots);
4415
+ currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, null, float, maxNumSize, dots, innerMinNumSize, numberMaxLength);
4326
4416
  setInnerValue(() => currentValue);
4327
4417
  if (inputChange && currentValue !== prevValue) {
4328
4418
  if (currentValue < Number.MIN_SAFE_INTEGER || currentValue > Number.MAX_SAFE_INTEGER) {
@@ -4352,11 +4442,13 @@ const NumberInput = ({
4352
4442
  }
4353
4443
  };
4354
4444
  const handleBlur = () => {
4355
- const newVal = handleRemoveLeadingZeros(innerValue);
4356
- if (parseFloat(newVal) === 0) {
4357
- inputChange('');
4358
- } else {
4359
- inputChange(newVal);
4445
+ if (!withZero) {
4446
+ const newVal = handleRemoveLeadingZeros(innerValue);
4447
+ if (parseFloat(newVal) === 0) {
4448
+ inputChange('');
4449
+ } else {
4450
+ inputChange(newVal);
4451
+ }
4360
4452
  }
4361
4453
  };
4362
4454
  useEffect(() => {
@@ -4373,10 +4465,10 @@ const NumberInput = ({
4373
4465
  useEffect(() => {
4374
4466
  let newValue = '';
4375
4467
  if (value !== undefined && value !== null) {
4376
- newValue = handleUtilsCheckTypeNumber(value, newValue, null, float, maxNumSize, dots);
4468
+ newValue = handleUtilsCheckTypeNumber(value, newValue, null, float, maxNumSize, dots, innerMinNumSize, numberMaxLength);
4377
4469
  }
4378
4470
  setInnerValue(() => newValue);
4379
- }, [dots, value, float, maxNumSize, minNumSize]);
4471
+ }, [dots, value, float, maxNumSize, minNumSize, numberMaxLength]);
4380
4472
  return /*#__PURE__*/React__default.createElement("input", {
4381
4473
  type: "text",
4382
4474
  value: innerValue,
@@ -4429,6 +4521,7 @@ const Input = ({
4429
4521
  leftIcon,
4430
4522
  required,
4431
4523
  disabled,
4524
+ labelDots,
4432
4525
  iconWidth,
4433
4526
  rightIcon,
4434
4527
  className,
@@ -4462,7 +4555,9 @@ const Input = ({
4462
4555
  phoneAlignItems,
4463
4556
  errorLineHeight,
4464
4557
  labelLineHeight,
4558
+ numberMaxLength,
4465
4559
  backgroundColor,
4560
+ withZero = false,
4466
4561
  labelMarginBottom,
4467
4562
  regexpErrorMessage,
4468
4563
  phoneJustifyContent,
@@ -4554,6 +4649,7 @@ const Input = ({
4554
4649
  className: classProps
4555
4650
  }, label ? /*#__PURE__*/React__default.createElement("label", {
4556
4651
  style: {
4652
+ maxWidth: '100%',
4557
4653
  color: labelColor ?? configStyles.INPUT.label.color,
4558
4654
  fontSize: labelSize ?? configStyles.INPUT.label.font.size,
4559
4655
  fontStyle: labelStyle ?? configStyles.INPUT.label.font.style,
@@ -4561,8 +4657,12 @@ const Input = ({
4561
4657
  fontWeight: labelWeight ?? configStyles.INPUT.label.font.weight,
4562
4658
  lineHeight: labelLineHeight ?? configStyles.INPUT.label.lineHeight,
4563
4659
  marginBottom: labelMarginBottom ?? configStyles.INPUT.label.marginBottom,
4564
- fontFamily: labelFontFamily ?? configStyles.INPUT.label.font.family
4565
- }
4660
+ fontFamily: labelFontFamily ?? configStyles.INPUT.label.font.family,
4661
+ whiteSpace: (labelDots ? labelDots : configStyles.INPUT.label.dots) ? 'nowrap' : 'normal',
4662
+ overflow: (labelDots ? labelDots : configStyles.INPUT.label.dots) ? 'hidden' : 'visible',
4663
+ textOverflow: (labelDots ? labelDots : configStyles.INPUT.label.dots) ? 'ellipsis' : ''
4664
+ },
4665
+ title: label
4566
4666
  }, label, required && /*#__PURE__*/React__default.createElement("sup", null, /*#__PURE__*/React__default.createElement(SvgRequired, null))) : '', /*#__PURE__*/React__default.createElement("div", {
4567
4667
  className: `${styles$7['input-content']}`,
4568
4668
  style: {
@@ -4608,9 +4708,11 @@ const Input = ({
4608
4708
  value: innerValue,
4609
4709
  float: floatToFix,
4610
4710
  disabled: disabled,
4711
+ withZero: withZero,
4611
4712
  inputChange: change,
4612
4713
  inpStyles: inpStyles,
4613
4714
  inpAttributes: inpAttributes,
4715
+ numberMaxLength: numberMaxLength,
4614
4716
  insideError: fireInputInsideError,
4615
4717
  minNumSize: minNumSize ? minNumSize : '',
4616
4718
  maxNumSize: maxNumSize ? maxNumSize : '',
@@ -4672,18 +4774,20 @@ const Input = ({
4672
4774
  Input.propTypes = {
4673
4775
  size: PropTypes.string,
4674
4776
  name: PropTypes.string,
4675
- style: PropTypes.string,
4676
- weight: PropTypes.string,
4677
- family: PropTypes.string,
4678
4777
  change: PropTypes.func,
4778
+ style: PropTypes.string,
4679
4779
  color: PropTypes.string,
4680
4780
  width: PropTypes.string,
4681
4781
  label: PropTypes.string,
4782
+ withZero: PropTypes.bool,
4783
+ weight: PropTypes.string,
4784
+ family: PropTypes.string,
4682
4785
  required: PropTypes.bool,
4683
4786
  disabled: PropTypes.bool,
4684
4787
  height: PropTypes.string,
4685
4788
  radius: PropTypes.string,
4686
4789
  padding: PropTypes.string,
4790
+ labelDots: PropTypes.bool,
4687
4791
  tooltip: PropTypes.element,
4688
4792
  withoutDot: PropTypes.bool,
4689
4793
  className: PropTypes.string,
@@ -4720,6 +4824,7 @@ Input.propTypes = {
4720
4824
  phoneAlignItems: PropTypes.string,
4721
4825
  errorLineHeight: PropTypes.string,
4722
4826
  labelLineHeight: PropTypes.string,
4827
+ numberMaxLength: PropTypes.number,
4723
4828
  labelMarginBottom: PropTypes.string,
4724
4829
  regexpErrorMessage: PropTypes.string,
4725
4830
  regexp: PropTypes.instanceOf(RegExp),
package/dist/index.js CHANGED
@@ -552,6 +552,7 @@ var packageResult = {
552
552
  ...fontObject
553
553
  },
554
554
  label: {
555
+ dots: false,
555
556
  color: presetColors.dark,
556
557
  display: 'block',
557
558
  lineHeight: '22px',
@@ -1179,6 +1180,12 @@ var packageResult = {
1179
1180
  font: {
1180
1181
  ...fontObject
1181
1182
  }
1183
+ },
1184
+ draggable: {
1185
+ boxShadow: '1px 1px 9px black',
1186
+ color: {
1187
+ background: 'white'
1188
+ }
1182
1189
  }
1183
1190
  },
1184
1191
  // default properties for <Pagination /> component
@@ -1761,19 +1768,19 @@ const File = /*#__PURE__*/React.forwardRef(({
1761
1768
  setError('');
1762
1769
  if (file[0].type === 'application/pdf') {
1763
1770
  setImage('pdf');
1764
- change(file[0]);
1765
- setSingleFile(file[0]);
1771
+ change(file);
1772
+ setSingleFile(file);
1766
1773
  } else if (file[0].type === 'image/heif' || file[0].type === 'image/heic' || file[0].name.toLowerCase().endsWith('.heic') || file[0].name.toLowerCase().endsWith('.heif')) {
1767
1774
  handleCheckHeicFormat(file[0]).then(() => {
1768
1775
  setImage('heic');
1769
- change(file[0]);
1770
- setSingleFile(file[0]);
1776
+ change(file);
1777
+ setSingleFile(file);
1771
1778
  }).catch(() => {
1772
1779
  setImage(null);
1773
1780
  setError(formatError ?? configStyles.FILE.error.format);
1774
1781
  });
1775
1782
  } else {
1776
- change(file[0]);
1783
+ change(file);
1777
1784
  setImage(URL.createObjectURL(file[0]));
1778
1785
  }
1779
1786
  } else {
@@ -2382,7 +2389,7 @@ const handleUtilsCheckTypeTel = (val, prevVal) => {
2382
2389
  }
2383
2390
  return val;
2384
2391
  };
2385
- const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumSize, withoutDot, innerMinNumSize) => {
2392
+ const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumSize, withoutDot, innerMinNumSize, numberMaxLength) => {
2386
2393
  if (maxLength && maxLength > 0) {
2387
2394
  if (val.length > maxLength) {
2388
2395
  val = val.substr(0, maxLength);
@@ -2392,6 +2399,9 @@ const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumS
2392
2399
  if (val.length > 16 && !val.includes('.')) {
2393
2400
  val = val.substr(0, 16);
2394
2401
  }
2402
+ if (numberMaxLength && numberMaxLength > 0 && !val.includes('.')) {
2403
+ val = val.substr(0, numberMaxLength);
2404
+ }
2395
2405
  const floatNumParts = typeof val === 'string' ? val.split(/\.|\․|\.|\,/) : val;
2396
2406
  const int = floatNumParts[0];
2397
2407
  const float = floatNumParts[1];
@@ -2536,16 +2546,16 @@ const TD = ({
2536
2546
  item,
2537
2547
  index,
2538
2548
  rowItem,
2549
+ dragged,
2550
+ dragEnd,
2539
2551
  rowRadius,
2540
2552
  dragStart,
2541
- handleMouseDown,
2542
2553
  hideBorder,
2543
2554
  innerIndex,
2544
2555
  tBodyColor,
2545
2556
  orderColor,
2546
2557
  borderRight,
2547
2558
  tBodyPadding,
2548
- setIsDragging,
2549
2559
  orderFontSize,
2550
2560
  tBodyFontSize,
2551
2561
  openListColor,
@@ -2695,7 +2705,9 @@ const TD = ({
2695
2705
  height: '24px',
2696
2706
  cursor: 'grab'
2697
2707
  },
2698
- onDragStart: () => dragStart(index)
2708
+ onDrag: dragged,
2709
+ onDragEnd: dragEnd,
2710
+ onDragStart: e => dragStart(e, index, row)
2699
2711
  }, /*#__PURE__*/React__default["default"].createElement("img", {
2700
2712
  src: img$1,
2701
2713
  alt: "drag"
@@ -2935,8 +2947,11 @@ const Table = ({
2935
2947
  draggable,
2936
2948
  showOrder,
2937
2949
  draggableColor,
2938
- getDraggableData
2950
+ getDraggableData,
2951
+ draggableItemBoxShadow,
2952
+ draggableItemBackgroundColor
2939
2953
  }) => {
2954
+ const itemRefs = React.useRef({});
2940
2955
  const headerRef = React.useRef(null);
2941
2956
  const draggedRowIndex = React.useRef(null);
2942
2957
  const [body, setBody] = React.useState([]);
@@ -2946,8 +2961,12 @@ const Table = ({
2946
2961
  const [checkDrag, setCheckDrag] = React.useState(false);
2947
2962
  const [checkedArray, setCheckedArray] = React.useState([]);
2948
2963
  const [configStyles, setConfigStyles] = React.useState({});
2949
- React.useState(false);
2950
- const [draggingIndex, setDraggingIndex] = React.useState(null);
2964
+ const [dragging, setDragging] = React.useState(false);
2965
+ const [draggedItem, setDraggedItem] = React.useState(null);
2966
+ const [position, setPosition] = React.useState({
2967
+ x: 0,
2968
+ y: 0
2969
+ });
2951
2970
  const handleCheckIfArrow = (bodyData, data) => {
2952
2971
  let removeItemIndex;
2953
2972
  let headerWithoutArrow = [];
@@ -3084,6 +3103,7 @@ const Table = ({
3084
3103
  }
3085
3104
  };
3086
3105
  const handleCheckedHeader = (data, e) => {
3106
+ console.log('ok - - - - - - - ');
3087
3107
  e.stopPropagation();
3088
3108
  let removeItemIndex;
3089
3109
  let checkableItemBool;
@@ -3354,11 +3374,19 @@ const Table = ({
3354
3374
  });
3355
3375
  setBody(() => checkBodyMore);
3356
3376
  };
3357
- const handleDragStart = index => {
3377
+ const handleDragStart = (e, index, row) => {
3378
+ setDragging(true);
3379
+ setDraggedItem(row);
3358
3380
  draggedRowIndex.current = index;
3359
- setDraggingIndex(() => index);
3381
+ e.dataTransfer.setDragImage(new Image(), 0, 0);
3360
3382
  };
3361
- const handleDrop = index => {
3383
+ const handleDrag = e => {
3384
+ setPosition({
3385
+ x: e.clientX,
3386
+ y: e.clientY
3387
+ });
3388
+ };
3389
+ const handleDrop = (e, index) => {
3362
3390
  let correctData = [];
3363
3391
  const newRows = body;
3364
3392
  const [draggedRow] = newRows.splice(draggedRowIndex.current, 1);
@@ -3370,8 +3398,20 @@ const Table = ({
3370
3398
  getDraggableData && getDraggableData(correctData);
3371
3399
  setCheckDrag(prev => !prev);
3372
3400
  draggedRowIndex.current = null;
3373
- setDraggingIndex(() => null);
3374
3401
  correctData = null;
3402
+ setDraggedItem(null);
3403
+ setDragging(false);
3404
+ e.dataTransfer.setDragImage(new Image(), 0, 0);
3405
+ };
3406
+ const handleDragEnd = e => {
3407
+ setDraggedItem(null);
3408
+ setDragging(false);
3409
+ e.dataTransfer.setDragImage(new Image(), 0, 0);
3410
+ };
3411
+ const setRef = (index, element) => {
3412
+ if (element) {
3413
+ itemRefs.current[index] = element;
3414
+ }
3375
3415
  };
3376
3416
  React.useEffect(() => {
3377
3417
  const draggableArray = body && body.length && body.map((item, index) => {
@@ -3576,22 +3616,24 @@ const Table = ({
3576
3616
  }
3577
3617
  }, body.map((item, index) => {
3578
3618
  return /*#__PURE__*/React__default["default"].createElement("tr", {
3579
- onDragStart: () => handleDragStart(index),
3580
3619
  onDragOver: e => e.preventDefault(),
3581
- onDrop: () => handleDrop(index),
3620
+ onDrop: e => handleDrop(e, index),
3582
3621
  key: `${item}_${index}`,
3583
3622
  style: {
3584
3623
  backgroundColor: tableRowBGColor ?? configStyles.TABLE.body.row.colors.background,
3585
3624
  borderBottom: index === body.length - 1 ? 'none' : tBodyRowBorder ? tBodyRowBorder : configStyles.TABLE.body.row.border,
3586
3625
  borderColor: hideBorder ? 'transparent' : configStyles.TABLE.body.row.borderColor,
3587
3626
  boxShadow: (tableRowItem ? tableRowItem : configStyles.TABLE.body.row.asItem) ? tableRowBoxShadow ? tableRowBoxShadow : configStyles.TABLE.body.row.box.shadow : 'none'
3588
- }
3627
+ },
3628
+ ref: el => setRef(index, el)
3589
3629
  }, Object.values(item).map((innerItem, innerIndex) => {
3590
3630
  return /*#__PURE__*/React__default["default"].createElement(TD, {
3591
3631
  index: index,
3592
3632
  item: innerItem,
3633
+ dragged: handleDrag,
3593
3634
  hideBorder: hideBorder,
3594
3635
  innerIndex: innerIndex,
3636
+ dragEnd: handleDragEnd,
3595
3637
  row: Object.values(item),
3596
3638
  dragStart: handleDragStart,
3597
3639
  id: item.id ? item.id : '',
@@ -3627,6 +3669,52 @@ const Table = ({
3627
3669
  handleOpenCloseRowSingleArrow: handleOpenCloseRowSingleArrow
3628
3670
  });
3629
3671
  }));
3672
+ })), draggable && dragging && draggedItem && /*#__PURE__*/React__default["default"].createElement("div", {
3673
+ style: {
3674
+ position: 'fixed',
3675
+ top: `${position.y - 30}px`,
3676
+ left: `${position.x - 30}px`,
3677
+ borderSpacing: '0px',
3678
+ pointerEvents: 'none',
3679
+ height: 'fit-content',
3680
+ blockSize: 'fit-content',
3681
+ borderRadius: tableRowItem ? tableRowRadius ?? configStyles.TABLE.body.row.radius : '0px',
3682
+ boxShadow: draggableItemBoxShadow ?? configStyles.TABLE.draggable.boxShadow,
3683
+ backgroundColor: draggableItemBackgroundColor ?? configStyles.TABLE.draggable.color.background
3684
+ }
3685
+ }, draggedItem.map((innerItem, innerIndex) => {
3686
+ return /*#__PURE__*/React__default["default"].createElement(TD, {
3687
+ item: innerItem,
3688
+ dragged: handleDrag,
3689
+ hideBorder: hideBorder,
3690
+ innerIndex: innerIndex,
3691
+ row: Object.values(draggedItem),
3692
+ dragStart: handleDragStart,
3693
+ handleCheckDots: handleCheckDots,
3694
+ key: `${innerItem}__${innerIndex}`,
3695
+ openListColor: openListColor ?? configStyles.TABLE.openList.color,
3696
+ tableColumnMinWidth: tableColumnMinWidth ?? configStyles.TABLE.column.minWidth,
3697
+ tableColumnMaxWidth: tableColumnMaxWidth ?? configStyles.TABLE.column.maxWidth,
3698
+ openListFontSize: openListFontSize ?? configStyles.TABLE.openList.font.size,
3699
+ openListFontStyle: openListFontStyle ?? configStyles.TABLE.openList.font.style,
3700
+ openListFontWeight: openListFontWeight ?? configStyles.TABLE.openList.font.weight,
3701
+ openListFontFamily: openListFontFamily ?? configStyles.TABLE.openList.font.family,
3702
+ tBodyColor: tBodyColor ?? configStyles.TABLE.body.color,
3703
+ orderColor: orderColor ?? configStyles.TABLE.order.color,
3704
+ rowItem: tableRowItem ?? configStyles.TABLE.body.row.isItem,
3705
+ tBodyPadding: tBodyPadding ?? configStyles.TABLE.body.padding,
3706
+ tBodyTextAlign: tBodyTextAlign ?? configStyles.TABLE.textAlign,
3707
+ rowRadius: tableRowRadius ?? configStyles.TABLE.body.row.radius,
3708
+ tBodyFontSize: tBodyFontSize ?? configStyles.TABLE.body.font.size,
3709
+ orderFontSize: orderFontSize ?? configStyles.TABLE.order.font.size,
3710
+ orderFontStyle: orderFontStyle ?? configStyles.TABLE.order.font.style,
3711
+ tBodyFontFamily: tBodyFontFamily ?? configStyles.TABLE.body.font.family,
3712
+ tBodyFontWeight: tBodyFontWeight ?? configStyles.TABLE.body.font.weight,
3713
+ orderFontFamily: orderFontFamily ?? configStyles.TABLE.order.font.family,
3714
+ orderFontWeight: orderFontWeight ?? configStyles.TABLE.order.font.weight,
3715
+ borderRight: innerIndex === Object.values(draggedItem).length - 1 ? 'none' : configStyles.TABLE.body.row.border,
3716
+ borderRightColor: innerIndex === Object.values(draggedItem).length - 1 ? 'transparent' : configStyles.TABLE.body.row.borderColor
3717
+ });
3630
3718
  })));
3631
3719
  };
3632
3720
  Table.propTypes = {
@@ -4339,6 +4427,7 @@ const NumberInput = ({
4339
4427
  value,
4340
4428
  float,
4341
4429
  radius,
4430
+ withZero,
4342
4431
  disabled,
4343
4432
  inpStyles,
4344
4433
  minNumSize,
@@ -4346,6 +4435,7 @@ const NumberInput = ({
4346
4435
  insideError,
4347
4436
  inputChange,
4348
4437
  inpAttributes,
4438
+ numberMaxLength,
4349
4439
  setInnerErrorMessage
4350
4440
  }) => {
4351
4441
  const [innerValue, setInnerValue] = React.useState('');
@@ -4353,7 +4443,7 @@ const NumberInput = ({
4353
4443
  const handleChange = event => {
4354
4444
  let prevValue = innerValue;
4355
4445
  let currentValue = event.target.value.replace(/\.|․|\.|,/g, '.');
4356
- currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, null, float, maxNumSize, dots);
4446
+ currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, null, float, maxNumSize, dots, innerMinNumSize, numberMaxLength);
4357
4447
  setInnerValue(() => currentValue);
4358
4448
  if (inputChange && currentValue !== prevValue) {
4359
4449
  if (currentValue < Number.MIN_SAFE_INTEGER || currentValue > Number.MAX_SAFE_INTEGER) {
@@ -4383,11 +4473,13 @@ const NumberInput = ({
4383
4473
  }
4384
4474
  };
4385
4475
  const handleBlur = () => {
4386
- const newVal = handleRemoveLeadingZeros(innerValue);
4387
- if (parseFloat(newVal) === 0) {
4388
- inputChange('');
4389
- } else {
4390
- inputChange(newVal);
4476
+ if (!withZero) {
4477
+ const newVal = handleRemoveLeadingZeros(innerValue);
4478
+ if (parseFloat(newVal) === 0) {
4479
+ inputChange('');
4480
+ } else {
4481
+ inputChange(newVal);
4482
+ }
4391
4483
  }
4392
4484
  };
4393
4485
  React.useEffect(() => {
@@ -4404,10 +4496,10 @@ const NumberInput = ({
4404
4496
  React.useEffect(() => {
4405
4497
  let newValue = '';
4406
4498
  if (value !== undefined && value !== null) {
4407
- newValue = handleUtilsCheckTypeNumber(value, newValue, null, float, maxNumSize, dots);
4499
+ newValue = handleUtilsCheckTypeNumber(value, newValue, null, float, maxNumSize, dots, innerMinNumSize, numberMaxLength);
4408
4500
  }
4409
4501
  setInnerValue(() => newValue);
4410
- }, [dots, value, float, maxNumSize, minNumSize]);
4502
+ }, [dots, value, float, maxNumSize, minNumSize, numberMaxLength]);
4411
4503
  return /*#__PURE__*/React__default["default"].createElement("input", {
4412
4504
  type: "text",
4413
4505
  value: innerValue,
@@ -4460,6 +4552,7 @@ const Input = ({
4460
4552
  leftIcon,
4461
4553
  required,
4462
4554
  disabled,
4555
+ labelDots,
4463
4556
  iconWidth,
4464
4557
  rightIcon,
4465
4558
  className,
@@ -4493,7 +4586,9 @@ const Input = ({
4493
4586
  phoneAlignItems,
4494
4587
  errorLineHeight,
4495
4588
  labelLineHeight,
4589
+ numberMaxLength,
4496
4590
  backgroundColor,
4591
+ withZero = false,
4497
4592
  labelMarginBottom,
4498
4593
  regexpErrorMessage,
4499
4594
  phoneJustifyContent,
@@ -4585,6 +4680,7 @@ const Input = ({
4585
4680
  className: classProps
4586
4681
  }, label ? /*#__PURE__*/React__default["default"].createElement("label", {
4587
4682
  style: {
4683
+ maxWidth: '100%',
4588
4684
  color: labelColor ?? configStyles.INPUT.label.color,
4589
4685
  fontSize: labelSize ?? configStyles.INPUT.label.font.size,
4590
4686
  fontStyle: labelStyle ?? configStyles.INPUT.label.font.style,
@@ -4592,8 +4688,12 @@ const Input = ({
4592
4688
  fontWeight: labelWeight ?? configStyles.INPUT.label.font.weight,
4593
4689
  lineHeight: labelLineHeight ?? configStyles.INPUT.label.lineHeight,
4594
4690
  marginBottom: labelMarginBottom ?? configStyles.INPUT.label.marginBottom,
4595
- fontFamily: labelFontFamily ?? configStyles.INPUT.label.font.family
4596
- }
4691
+ fontFamily: labelFontFamily ?? configStyles.INPUT.label.font.family,
4692
+ whiteSpace: (labelDots ? labelDots : configStyles.INPUT.label.dots) ? 'nowrap' : 'normal',
4693
+ overflow: (labelDots ? labelDots : configStyles.INPUT.label.dots) ? 'hidden' : 'visible',
4694
+ textOverflow: (labelDots ? labelDots : configStyles.INPUT.label.dots) ? 'ellipsis' : ''
4695
+ },
4696
+ title: label
4597
4697
  }, label, required && /*#__PURE__*/React__default["default"].createElement("sup", null, /*#__PURE__*/React__default["default"].createElement(SvgRequired, null))) : '', /*#__PURE__*/React__default["default"].createElement("div", {
4598
4698
  className: `${styles$7['input-content']}`,
4599
4699
  style: {
@@ -4639,9 +4739,11 @@ const Input = ({
4639
4739
  value: innerValue,
4640
4740
  float: floatToFix,
4641
4741
  disabled: disabled,
4742
+ withZero: withZero,
4642
4743
  inputChange: change,
4643
4744
  inpStyles: inpStyles,
4644
4745
  inpAttributes: inpAttributes,
4746
+ numberMaxLength: numberMaxLength,
4645
4747
  insideError: fireInputInsideError,
4646
4748
  minNumSize: minNumSize ? minNumSize : '',
4647
4749
  maxNumSize: maxNumSize ? maxNumSize : '',
@@ -4703,18 +4805,20 @@ const Input = ({
4703
4805
  Input.propTypes = {
4704
4806
  size: PropTypes__default["default"].string,
4705
4807
  name: PropTypes__default["default"].string,
4706
- style: PropTypes__default["default"].string,
4707
- weight: PropTypes__default["default"].string,
4708
- family: PropTypes__default["default"].string,
4709
4808
  change: PropTypes__default["default"].func,
4809
+ style: PropTypes__default["default"].string,
4710
4810
  color: PropTypes__default["default"].string,
4711
4811
  width: PropTypes__default["default"].string,
4712
4812
  label: PropTypes__default["default"].string,
4813
+ withZero: PropTypes__default["default"].bool,
4814
+ weight: PropTypes__default["default"].string,
4815
+ family: PropTypes__default["default"].string,
4713
4816
  required: PropTypes__default["default"].bool,
4714
4817
  disabled: PropTypes__default["default"].bool,
4715
4818
  height: PropTypes__default["default"].string,
4716
4819
  radius: PropTypes__default["default"].string,
4717
4820
  padding: PropTypes__default["default"].string,
4821
+ labelDots: PropTypes__default["default"].bool,
4718
4822
  tooltip: PropTypes__default["default"].element,
4719
4823
  withoutDot: PropTypes__default["default"].bool,
4720
4824
  className: PropTypes__default["default"].string,
@@ -4751,6 +4855,7 @@ Input.propTypes = {
4751
4855
  phoneAlignItems: PropTypes__default["default"].string,
4752
4856
  errorLineHeight: PropTypes__default["default"].string,
4753
4857
  labelLineHeight: PropTypes__default["default"].string,
4858
+ numberMaxLength: PropTypes__default["default"].number,
4754
4859
  labelMarginBottom: PropTypes__default["default"].string,
4755
4860
  regexpErrorMessage: PropTypes__default["default"].string,
4756
4861
  regexp: PropTypes__default["default"].instanceOf(RegExp),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
package/tui.config.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { background } from '@storybook/theming';
1
2
  import React from 'react'
2
3
 
3
4
  const boxSizing = 'border-box';
@@ -97,6 +98,7 @@ export default {
97
98
  font: {...fontObject},
98
99
 
99
100
  label: {
101
+ dots: false,
100
102
  color: presetColors.dark,
101
103
  display: 'block',
102
104
  lineHeight: '22px',
@@ -772,6 +774,13 @@ export default {
772
774
  order: {
773
775
  color: '#000',
774
776
  font: {...fontObject}
777
+ },
778
+
779
+ draggable: {
780
+ boxShadow: '1px 1px 9px black',
781
+ color: {
782
+ background: 'white'
783
+ }
775
784
  }
776
785
  },
777
786
  // default properties for <Pagination /> component