@xaypay/tui 0.0.104 → 0.0.105

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
@@ -190,6 +190,29 @@ File.defaultProps = {
190
190
  fileExtensions: ['jpg', 'jpeg', 'png', 'pdf']
191
191
  };
192
192
 
193
+ const _ = require('lodash');
194
+ const compereConfigs = () => {
195
+ let projectConfig = {};
196
+ let packageConfig = {};
197
+ try {
198
+ packageConfig = require('../tui.config.js');
199
+ } catch (e) {
200
+ try {
201
+ packageConfig = require('../../tui.config.js');
202
+ } catch (err) {
203
+ packageConfig = {};
204
+ }
205
+ }
206
+ try {
207
+ projectConfig = require('../../../../tui.config.js');
208
+ } catch (error) {
209
+ projectConfig = {};
210
+ // console.log(error, 'Project: if you want to use custom styles, create tui.config.js file in your project root');
211
+ }
212
+
213
+ return _.merge(packageConfig, projectConfig);
214
+ };
215
+
193
216
  const SvgCheckboxUnchecked = ({
194
217
  title,
195
218
  titleId,
@@ -232,17 +255,24 @@ const SvgCheckboxChecked = ({
232
255
  fill: fillColor ? fillColor : '#00236A'
233
256
  }));
234
257
 
235
- const SingleCheckbox = ({
236
- id,
237
- float,
258
+ const Checkbox$1 = ({
259
+ data,
260
+ styles,
238
261
  checked,
239
- onClick,
240
- content,
241
262
  disabled,
242
263
  checkedColor,
264
+ handleChecked,
243
265
  unCheckedColor
244
266
  }) => {
245
- const [innerCheckd, setInnerChecked] = useState(false);
267
+ const configStyles = compereConfigs();
268
+ const [innerChecked, setInnerChecked] = useState(false);
269
+ const [innerDisabled, setInnerDisabled] = useState(false);
270
+ const handleClick = e => {
271
+ handleChecked(data, e);
272
+ };
273
+ useEffect(() => {
274
+ setInnerDisabled(disabled);
275
+ }, [disabled]);
246
276
  useEffect(() => {
247
277
  setInnerChecked(checked);
248
278
  }, [checked]);
@@ -252,48 +282,61 @@ const SingleCheckbox = ({
252
282
  height: '16px',
253
283
  marginRight: '9px',
254
284
  display: 'inline-block',
255
- float: float ? float : '',
256
- cursor: !disabled && onClick ? 'pointer' : 'normal'
257
- }
258
- }, innerCheckd ? /*#__PURE__*/React__default.createElement(SvgCheckboxChecked, {
259
- onClick: !disabled && onClick ? e => onClick(e, content, id) : _ => _,
260
- fillColor: checkedColor ? checkedColor : ''
285
+ cursor: !innerDisabled ? 'pointer' : 'not-allowed',
286
+ ...styles
287
+ },
288
+ onClick: !innerDisabled && handleChecked ? handleClick : _ => _
289
+ }, innerChecked && !innerDisabled ? /*#__PURE__*/React__default.createElement(SvgCheckboxChecked, {
290
+ fillColor: checkedColor ? checkedColor : configStyles.SINGLECHECKBOX.checkedColor
261
291
  }) : /*#__PURE__*/React__default.createElement(SvgCheckboxUnchecked, {
262
- onClick: !disabled && onClick ? e => onClick(e, content, id) : _ => _,
263
- fillColor: unCheckedColor ? unCheckedColor : ''
292
+ fillColor: unCheckedColor ? unCheckedColor : configStyles.SINGLECHECKBOX.unCheckedColor
264
293
  }));
265
294
  };
295
+
296
+ const SingleCheckbox = ({
297
+ data,
298
+ styles,
299
+ checked,
300
+ disabled,
301
+ checkedColor,
302
+ handleChecked,
303
+ unCheckedColor
304
+ }) => {
305
+ const [innerData, setInnerData] = useState(null);
306
+ useEffect(() => {
307
+ // if (data) {
308
+ // if (typeof data === 'object' && data.constructor === Object) {
309
+ // setInnerData(data);
310
+ // } else {
311
+ // alert('Data props on Checkbox component must be an object');
312
+ // }
313
+ // } else {
314
+ // alert('Please add data props on Checkbox component');
315
+ // }
316
+ setInnerData(data);
317
+ }, [data]);
318
+ return /*#__PURE__*/React__default.createElement(Checkbox$1, {
319
+ styles: styles,
320
+ data: innerData,
321
+ checked: checked,
322
+ disabled: disabled,
323
+ checkedColor: checkedColor,
324
+ handleChecked: handleChecked,
325
+ unCheckedColor: unCheckedColor
326
+ });
327
+ };
266
328
  SingleCheckbox.propTypes = {
329
+ onClick: PropTypes.func,
330
+ styles: PropTypes.object,
267
331
  disabled: PropTypes.bool,
268
- checked: PropTypes.bool.isRequired
332
+ checkedColor: PropTypes.string,
333
+ unCheckedColor: PropTypes.string,
334
+ data: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired
269
335
  };
270
336
 
271
337
  var css_248z$e = ".table-module_sorting-arrows__BaN-G:after{content:\"▲\";font-size:11px;position:absolute;right:0;top:calc(50% - 12px)}.table-module_sorting-arrows__BaN-G:before{bottom:calc(50% - 12px);content:\"▼\";font-size:11px;position:absolute;right:0}.table-module_td-span__XHo6k{cursor:pointer;display:inline-block;position:relative}.table-module_td-span__XHo6k>svg{left:0;position:absolute;top:0;z-index:-1}";
272
338
  styleInject(css_248z$e);
273
339
 
274
- const _ = require('lodash');
275
- const compereConfigs = () => {
276
- let projectConfig = {};
277
- let packageConfig = {};
278
- try {
279
- packageConfig = require('../tui.config.js');
280
- } catch (e) {
281
- try {
282
- packageConfig = require('../../tui.config.js');
283
- } catch (err) {
284
- packageConfig = {};
285
- }
286
- }
287
- try {
288
- projectConfig = require('../../../../tui.config.js');
289
- } catch (error) {
290
- projectConfig = {};
291
- // console.log(error, 'Project: if you want to use custom styles, create tui.config.js file in your project root');
292
- }
293
-
294
- return _.merge(packageConfig, projectConfig);
295
- };
296
-
297
340
  ({
298
341
  dataBody: PropTypes.array,
299
342
  dataHeader: PropTypes.array,
@@ -616,9 +659,11 @@ const Modal = ({
616
659
  } else {
617
660
  return /*#__PURE__*/React__default.createElement("img", {
618
661
  style: {
662
+ display: 'block',
619
663
  objectFit: 'cover',
620
664
  objectPosition: 'center',
621
665
  borderRadius: radius ? radius : configStyles.MODAL.radius,
666
+ width: imageWidth ? imageWidth : configStyles.MODAL.imageWidth,
622
667
  height: imageHeight ? imageHeight : configStyles.MODAL.imageHeight
623
668
  },
624
669
  src: item.url,
@@ -3574,8 +3619,6 @@ var css_248z$2 = ".pagination-module_listItem__b1-WN:focus{background-color:#4ca
3574
3619
  var styles$2 = {"listItem":"pagination-module_listItem__b1-WN","active":"pagination-module_active__KwBDp","pagination-bar":"pagination-module_pagination-bar__MrtYT","pagination-btn":"pagination-module_pagination-btn__w8Yh8","pagination-item":"pagination-module_pagination-item__t3emS","pagination-jump-next":"pagination-module_pagination-jump-next__LAb9Z","selected":"pagination-module_selected__EXzCA","pagination-jump-next-txt":"pagination-module_pagination-jump-next-txt__e7nFj","pagination-jump-next-arrow":"pagination-module_pagination-jump-next-arrow__aEVD8"};
3575
3620
  styleInject(css_248z$2);
3576
3621
 
3577
- // import styles from "./pagination.module.scss";
3578
-
3579
3622
  const Dots = "...";
3580
3623
  const range = (start, end) => {
3581
3624
  const length = end - start + 1;
@@ -3584,41 +3627,36 @@ const range = (start, end) => {
3584
3627
  }, (_, idx) => idx + start);
3585
3628
  };
3586
3629
  const PaginationRange = ({
3587
- currentTotalCount,
3588
3630
  offset,
3589
- siblingCountNumber,
3631
+ currentTotalCount,
3590
3632
  currentPageNumber
3591
3633
  }) => {
3592
3634
  const paginationRange = useMemo(() => {
3635
+ const firstPageIndex = 1;
3593
3636
  const totalPageCount = Math.ceil(currentTotalCount / offset);
3594
-
3595
- //currentPage + 2*Dots + start + end = 5
3596
- const totalPageNumber = siblingCountNumber + 5;
3597
- if (totalPageNumber >= totalPageCount) {
3637
+ const lastPageIndex = totalPageCount;
3638
+ if (7 >= totalPageCount) {
3598
3639
  return range(1, totalPageCount);
3599
3640
  }
3600
- const rightSiblingIndex = Math.min(currentPageNumber + siblingCountNumber, totalPageCount);
3601
- const leftSiblingIndex = Math.max(currentPageNumber - siblingCountNumber, 1);
3641
+ const leftSiblingIndex = Math.max(currentPageNumber - 1, 1);
3642
+ const rightSiblingIndex = Math.min(currentPageNumber + 1, totalPageCount);
3602
3643
  const shouldShowLeftDots = leftSiblingIndex > 2;
3603
3644
  const shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
3604
- const firstPageIndex = 1;
3605
- const lastPageIndex = totalPageCount;
3606
3645
  if (!shouldShowLeftDots && shouldShowRightDots) {
3607
- let leftItemCount = currentPageNumber === 4 && lastPageIndex > 7 ? 4 + siblingCountNumber : 3 + siblingCountNumber;
3646
+ let leftItemCount = currentPageNumber === 4 && lastPageIndex >= 7 ? 5 : 4;
3608
3647
  let leftRange = range(1, leftItemCount);
3609
3648
  return [...leftRange, Dots, totalPageCount];
3610
- }
3611
- if (shouldShowLeftDots && !shouldShowRightDots) {
3612
- let rightItemCount = 0;
3613
- currentPageNumber === lastPageIndex - 3 && lastPageIndex > 7 ? rightItemCount = 4 + siblingCountNumber : rightItemCount = 3 + siblingCountNumber;
3649
+ } else if (shouldShowLeftDots && !shouldShowRightDots) {
3650
+ let rightItemCount = currentPageNumber === lastPageIndex - 3 && lastPageIndex >= 7 ? 4 : 3;
3614
3651
  let rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);
3615
3652
  return [firstPageIndex, Dots, ...rightRange];
3616
- }
3617
- if (shouldShowLeftDots && shouldShowRightDots) {
3653
+ } else if (shouldShowLeftDots && shouldShowRightDots) {
3618
3654
  let middleRange = range(leftSiblingIndex, rightSiblingIndex);
3619
3655
  return [firstPageIndex, Dots, ...middleRange, Dots, lastPageIndex];
3656
+ } else {
3657
+ return range(firstPageIndex, totalPageCount);
3620
3658
  }
3621
- }, [currentTotalCount, offset, siblingCountNumber, currentPageNumber]);
3659
+ }, [currentTotalCount, offset, currentPageNumber]);
3622
3660
  return paginationRange;
3623
3661
  };
3624
3662
 
@@ -3662,24 +3700,19 @@ const SvgNextarrow = ({
3662
3700
 
3663
3701
  const Pagination = ({
3664
3702
  goTo,
3703
+ offset,
3665
3704
  onChange,
3705
+ className,
3666
3706
  totalCount,
3667
- siblingCount,
3668
- currentPage,
3669
- offset,
3670
- className
3707
+ currentPage
3671
3708
  }) => {
3672
3709
  const [inpVal, setInpVal] = useState('');
3673
3710
  const [error, setError] = useState(false);
3674
- const [siblingCountNumber, setSibilingCountNumber] = useState(siblingCount);
3675
3711
  const [currentPageNumber, setCurrentPage] = useState(currentPage);
3676
3712
  const [currentTotalCount, setcurrentTotalCount] = useState(totalCount);
3677
3713
  useEffect(() => {
3678
3714
  setcurrentTotalCount(totalCount);
3679
3715
  }, [totalCount]);
3680
- useEffect(() => {
3681
- setSibilingCountNumber(siblingCount);
3682
- }, [siblingCount]);
3683
3716
  useEffect(() => {
3684
3717
  setCurrentPage(currentPage);
3685
3718
  }, [currentPage]);
@@ -3694,10 +3727,9 @@ const Pagination = ({
3694
3727
  const paginationRange = PaginationRange({
3695
3728
  currentPageNumber,
3696
3729
  currentTotalCount,
3697
- siblingCountNumber,
3698
3730
  offset
3699
3731
  });
3700
- if (currentPageNumber === 0 || paginationRange.length < 2) {
3732
+ if (currentPageNumber === 0 || paginationRange?.length < 2) {
3701
3733
  return null;
3702
3734
  }
3703
3735
  const classProps = classnames(styles$2.list, className ? className : `${styles$2["pagination-bar"]} pagination-bar-rem`);
@@ -3824,12 +3856,10 @@ Pagination.propTypes = {
3824
3856
  offset: PropTypes.number,
3825
3857
  totalCount: PropTypes.number,
3826
3858
  className: PropTypes.string,
3827
- siblingCount: PropTypes.number,
3828
3859
  currentPage: PropTypes.number
3829
3860
  };
3830
3861
  Pagination.defaultProps = {
3831
- offset: 2,
3832
- siblingCount: 2
3862
+ offset: 2
3833
3863
  };
3834
3864
 
3835
3865
  var css_248z$1 = ".autocomplate-module_autocomplate-content__UbIUT{display:flex;flex-direction:column;position:relative}.autocomplate-module_autocomplate-content-top__FVgCp{border:2px solid #d1d1d1;border-radius:6px;box-sizing:border-box;color:#3c393e;cursor:pointer;display:flex;flex-direction:row;font-size:16px;font-weight:500;height:46px;line-height:22px;max-width:400px;padding:0 15px;transition:border-color .24s}.autocomplate-module_autocomplate-content-top__FVgCp.autocomplate-module_active__40fdV{border-color:#00236a}.autocomplate-module_autocomplate-content-top__FVgCp:hover{border-color:#3c393e}.autocomplate-module_autocomplate-content-bottom__yk0zP{animation:autocomplate-module_select-show__7Uap4 .64s linear forwards;background:#fbfbfb;border-radius:6px;box-shadow:0 0 10px rgba(60,57,62,.08);left:0;max-height:0;max-width:400px;overflow:hidden;position:absolute;top:52px;width:100%;z-index:1}.autocomplate-module_autocomplate-content-bottom-inner__rF5IF{display:flex;flex-direction:column;max-height:234px;overflow-x:hidden;overflow-y:auto}@keyframes autocomplate-module_select-show__7Uap4{to{max-height:400px}}.autocomplate-module_autocomplate-content-bottom-row__dRsZa{align-items:center;background:#fff;box-sizing:border-box;color:#3c393e;cursor:pointer;display:flex;font-size:16px;font-weight:500;height:46px;line-height:22px;margin-bottom:2px;padding:0 15px;transition:background .24s,color .24s}.autocomplate-module_autocomplate-content-bottom-row__dRsZa .autocomplate-module_no-option__xv0-E{color:red}.autocomplate-module_autocomplate-content-bottom-row__dRsZa:hover{background:unset;color:#00236a}.autocomplate-module_option-active__WuH4I .autocomplate-module_autocomplate-content-bottom-row__dRsZa{color:#00236a}.autocomplate-module_autocomplate-title__3Qxqz{color:#3c393e;display:block;font-size:16px;font-weight:500;line-height:22px;margin-bottom:6px;text-transform:none}.autocomplate-module_errorBorder__LV-nb{border:2px solid #e00!important}.autocomplate-module_errorMessage__Gchpc{color:#e00!important}";
package/dist/index.js CHANGED
@@ -220,6 +220,29 @@ File.defaultProps = {
220
220
  fileExtensions: ['jpg', 'jpeg', 'png', 'pdf']
221
221
  };
222
222
 
223
+ const _ = require('lodash');
224
+ const compereConfigs = () => {
225
+ let projectConfig = {};
226
+ let packageConfig = {};
227
+ try {
228
+ packageConfig = require('../tui.config.js');
229
+ } catch (e) {
230
+ try {
231
+ packageConfig = require('../../tui.config.js');
232
+ } catch (err) {
233
+ packageConfig = {};
234
+ }
235
+ }
236
+ try {
237
+ projectConfig = require('../../../../tui.config.js');
238
+ } catch (error) {
239
+ projectConfig = {};
240
+ // console.log(error, 'Project: if you want to use custom styles, create tui.config.js file in your project root');
241
+ }
242
+
243
+ return _.merge(packageConfig, projectConfig);
244
+ };
245
+
223
246
  const SvgCheckboxUnchecked = ({
224
247
  title,
225
248
  titleId,
@@ -262,17 +285,24 @@ const SvgCheckboxChecked = ({
262
285
  fill: fillColor ? fillColor : '#00236A'
263
286
  }));
264
287
 
265
- const SingleCheckbox = ({
266
- id,
267
- float,
288
+ const Checkbox$1 = ({
289
+ data,
290
+ styles,
268
291
  checked,
269
- onClick,
270
- content,
271
292
  disabled,
272
293
  checkedColor,
294
+ handleChecked,
273
295
  unCheckedColor
274
296
  }) => {
275
- const [innerCheckd, setInnerChecked] = React.useState(false);
297
+ const configStyles = compereConfigs();
298
+ const [innerChecked, setInnerChecked] = React.useState(false);
299
+ const [innerDisabled, setInnerDisabled] = React.useState(false);
300
+ const handleClick = e => {
301
+ handleChecked(data, e);
302
+ };
303
+ React.useEffect(() => {
304
+ setInnerDisabled(disabled);
305
+ }, [disabled]);
276
306
  React.useEffect(() => {
277
307
  setInnerChecked(checked);
278
308
  }, [checked]);
@@ -282,48 +312,61 @@ const SingleCheckbox = ({
282
312
  height: '16px',
283
313
  marginRight: '9px',
284
314
  display: 'inline-block',
285
- float: float ? float : '',
286
- cursor: !disabled && onClick ? 'pointer' : 'normal'
287
- }
288
- }, innerCheckd ? /*#__PURE__*/React__default["default"].createElement(SvgCheckboxChecked, {
289
- onClick: !disabled && onClick ? e => onClick(e, content, id) : _ => _,
290
- fillColor: checkedColor ? checkedColor : ''
315
+ cursor: !innerDisabled ? 'pointer' : 'not-allowed',
316
+ ...styles
317
+ },
318
+ onClick: !innerDisabled && handleChecked ? handleClick : _ => _
319
+ }, innerChecked && !innerDisabled ? /*#__PURE__*/React__default["default"].createElement(SvgCheckboxChecked, {
320
+ fillColor: checkedColor ? checkedColor : configStyles.SINGLECHECKBOX.checkedColor
291
321
  }) : /*#__PURE__*/React__default["default"].createElement(SvgCheckboxUnchecked, {
292
- onClick: !disabled && onClick ? e => onClick(e, content, id) : _ => _,
293
- fillColor: unCheckedColor ? unCheckedColor : ''
322
+ fillColor: unCheckedColor ? unCheckedColor : configStyles.SINGLECHECKBOX.unCheckedColor
294
323
  }));
295
324
  };
325
+
326
+ const SingleCheckbox = ({
327
+ data,
328
+ styles,
329
+ checked,
330
+ disabled,
331
+ checkedColor,
332
+ handleChecked,
333
+ unCheckedColor
334
+ }) => {
335
+ const [innerData, setInnerData] = React.useState(null);
336
+ React.useEffect(() => {
337
+ // if (data) {
338
+ // if (typeof data === 'object' && data.constructor === Object) {
339
+ // setInnerData(data);
340
+ // } else {
341
+ // alert('Data props on Checkbox component must be an object');
342
+ // }
343
+ // } else {
344
+ // alert('Please add data props on Checkbox component');
345
+ // }
346
+ setInnerData(data);
347
+ }, [data]);
348
+ return /*#__PURE__*/React__default["default"].createElement(Checkbox$1, {
349
+ styles: styles,
350
+ data: innerData,
351
+ checked: checked,
352
+ disabled: disabled,
353
+ checkedColor: checkedColor,
354
+ handleChecked: handleChecked,
355
+ unCheckedColor: unCheckedColor
356
+ });
357
+ };
296
358
  SingleCheckbox.propTypes = {
359
+ onClick: PropTypes__default["default"].func,
360
+ styles: PropTypes__default["default"].object,
297
361
  disabled: PropTypes__default["default"].bool,
298
- checked: PropTypes__default["default"].bool.isRequired
362
+ checkedColor: PropTypes__default["default"].string,
363
+ unCheckedColor: PropTypes__default["default"].string,
364
+ data: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].array]).isRequired
299
365
  };
300
366
 
301
367
  var css_248z$e = ".table-module_sorting-arrows__BaN-G:after{content:\"▲\";font-size:11px;position:absolute;right:0;top:calc(50% - 12px)}.table-module_sorting-arrows__BaN-G:before{bottom:calc(50% - 12px);content:\"▼\";font-size:11px;position:absolute;right:0}.table-module_td-span__XHo6k{cursor:pointer;display:inline-block;position:relative}.table-module_td-span__XHo6k>svg{left:0;position:absolute;top:0;z-index:-1}";
302
368
  styleInject(css_248z$e);
303
369
 
304
- const _ = require('lodash');
305
- const compereConfigs = () => {
306
- let projectConfig = {};
307
- let packageConfig = {};
308
- try {
309
- packageConfig = require('../tui.config.js');
310
- } catch (e) {
311
- try {
312
- packageConfig = require('../../tui.config.js');
313
- } catch (err) {
314
- packageConfig = {};
315
- }
316
- }
317
- try {
318
- projectConfig = require('../../../../tui.config.js');
319
- } catch (error) {
320
- projectConfig = {};
321
- // console.log(error, 'Project: if you want to use custom styles, create tui.config.js file in your project root');
322
- }
323
-
324
- return _.merge(packageConfig, projectConfig);
325
- };
326
-
327
370
  ({
328
371
  dataBody: PropTypes__default["default"].array,
329
372
  dataHeader: PropTypes__default["default"].array,
@@ -646,9 +689,11 @@ const Modal = ({
646
689
  } else {
647
690
  return /*#__PURE__*/React__default["default"].createElement("img", {
648
691
  style: {
692
+ display: 'block',
649
693
  objectFit: 'cover',
650
694
  objectPosition: 'center',
651
695
  borderRadius: radius ? radius : configStyles.MODAL.radius,
696
+ width: imageWidth ? imageWidth : configStyles.MODAL.imageWidth,
652
697
  height: imageHeight ? imageHeight : configStyles.MODAL.imageHeight
653
698
  },
654
699
  src: item.url,
@@ -3604,8 +3649,6 @@ var css_248z$2 = ".pagination-module_listItem__b1-WN:focus{background-color:#4ca
3604
3649
  var styles$2 = {"listItem":"pagination-module_listItem__b1-WN","active":"pagination-module_active__KwBDp","pagination-bar":"pagination-module_pagination-bar__MrtYT","pagination-btn":"pagination-module_pagination-btn__w8Yh8","pagination-item":"pagination-module_pagination-item__t3emS","pagination-jump-next":"pagination-module_pagination-jump-next__LAb9Z","selected":"pagination-module_selected__EXzCA","pagination-jump-next-txt":"pagination-module_pagination-jump-next-txt__e7nFj","pagination-jump-next-arrow":"pagination-module_pagination-jump-next-arrow__aEVD8"};
3605
3650
  styleInject(css_248z$2);
3606
3651
 
3607
- // import styles from "./pagination.module.scss";
3608
-
3609
3652
  const Dots = "...";
3610
3653
  const range = (start, end) => {
3611
3654
  const length = end - start + 1;
@@ -3614,41 +3657,36 @@ const range = (start, end) => {
3614
3657
  }, (_, idx) => idx + start);
3615
3658
  };
3616
3659
  const PaginationRange = ({
3617
- currentTotalCount,
3618
3660
  offset,
3619
- siblingCountNumber,
3661
+ currentTotalCount,
3620
3662
  currentPageNumber
3621
3663
  }) => {
3622
3664
  const paginationRange = React.useMemo(() => {
3665
+ const firstPageIndex = 1;
3623
3666
  const totalPageCount = Math.ceil(currentTotalCount / offset);
3624
-
3625
- //currentPage + 2*Dots + start + end = 5
3626
- const totalPageNumber = siblingCountNumber + 5;
3627
- if (totalPageNumber >= totalPageCount) {
3667
+ const lastPageIndex = totalPageCount;
3668
+ if (7 >= totalPageCount) {
3628
3669
  return range(1, totalPageCount);
3629
3670
  }
3630
- const rightSiblingIndex = Math.min(currentPageNumber + siblingCountNumber, totalPageCount);
3631
- const leftSiblingIndex = Math.max(currentPageNumber - siblingCountNumber, 1);
3671
+ const leftSiblingIndex = Math.max(currentPageNumber - 1, 1);
3672
+ const rightSiblingIndex = Math.min(currentPageNumber + 1, totalPageCount);
3632
3673
  const shouldShowLeftDots = leftSiblingIndex > 2;
3633
3674
  const shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
3634
- const firstPageIndex = 1;
3635
- const lastPageIndex = totalPageCount;
3636
3675
  if (!shouldShowLeftDots && shouldShowRightDots) {
3637
- let leftItemCount = currentPageNumber === 4 && lastPageIndex > 7 ? 4 + siblingCountNumber : 3 + siblingCountNumber;
3676
+ let leftItemCount = currentPageNumber === 4 && lastPageIndex >= 7 ? 5 : 4;
3638
3677
  let leftRange = range(1, leftItemCount);
3639
3678
  return [...leftRange, Dots, totalPageCount];
3640
- }
3641
- if (shouldShowLeftDots && !shouldShowRightDots) {
3642
- let rightItemCount = 0;
3643
- currentPageNumber === lastPageIndex - 3 && lastPageIndex > 7 ? rightItemCount = 4 + siblingCountNumber : rightItemCount = 3 + siblingCountNumber;
3679
+ } else if (shouldShowLeftDots && !shouldShowRightDots) {
3680
+ let rightItemCount = currentPageNumber === lastPageIndex - 3 && lastPageIndex >= 7 ? 4 : 3;
3644
3681
  let rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);
3645
3682
  return [firstPageIndex, Dots, ...rightRange];
3646
- }
3647
- if (shouldShowLeftDots && shouldShowRightDots) {
3683
+ } else if (shouldShowLeftDots && shouldShowRightDots) {
3648
3684
  let middleRange = range(leftSiblingIndex, rightSiblingIndex);
3649
3685
  return [firstPageIndex, Dots, ...middleRange, Dots, lastPageIndex];
3686
+ } else {
3687
+ return range(firstPageIndex, totalPageCount);
3650
3688
  }
3651
- }, [currentTotalCount, offset, siblingCountNumber, currentPageNumber]);
3689
+ }, [currentTotalCount, offset, currentPageNumber]);
3652
3690
  return paginationRange;
3653
3691
  };
3654
3692
 
@@ -3692,24 +3730,19 @@ const SvgNextarrow = ({
3692
3730
 
3693
3731
  const Pagination = ({
3694
3732
  goTo,
3733
+ offset,
3695
3734
  onChange,
3735
+ className,
3696
3736
  totalCount,
3697
- siblingCount,
3698
- currentPage,
3699
- offset,
3700
- className
3737
+ currentPage
3701
3738
  }) => {
3702
3739
  const [inpVal, setInpVal] = React.useState('');
3703
3740
  const [error, setError] = React.useState(false);
3704
- const [siblingCountNumber, setSibilingCountNumber] = React.useState(siblingCount);
3705
3741
  const [currentPageNumber, setCurrentPage] = React.useState(currentPage);
3706
3742
  const [currentTotalCount, setcurrentTotalCount] = React.useState(totalCount);
3707
3743
  React.useEffect(() => {
3708
3744
  setcurrentTotalCount(totalCount);
3709
3745
  }, [totalCount]);
3710
- React.useEffect(() => {
3711
- setSibilingCountNumber(siblingCount);
3712
- }, [siblingCount]);
3713
3746
  React.useEffect(() => {
3714
3747
  setCurrentPage(currentPage);
3715
3748
  }, [currentPage]);
@@ -3724,10 +3757,9 @@ const Pagination = ({
3724
3757
  const paginationRange = PaginationRange({
3725
3758
  currentPageNumber,
3726
3759
  currentTotalCount,
3727
- siblingCountNumber,
3728
3760
  offset
3729
3761
  });
3730
- if (currentPageNumber === 0 || paginationRange.length < 2) {
3762
+ if (currentPageNumber === 0 || paginationRange?.length < 2) {
3731
3763
  return null;
3732
3764
  }
3733
3765
  const classProps = classnames__default["default"](styles$2.list, className ? className : `${styles$2["pagination-bar"]} pagination-bar-rem`);
@@ -3854,12 +3886,10 @@ Pagination.propTypes = {
3854
3886
  offset: PropTypes__default["default"].number,
3855
3887
  totalCount: PropTypes__default["default"].number,
3856
3888
  className: PropTypes__default["default"].string,
3857
- siblingCount: PropTypes__default["default"].number,
3858
3889
  currentPage: PropTypes__default["default"].number
3859
3890
  };
3860
3891
  Pagination.defaultProps = {
3861
- offset: 2,
3862
- siblingCount: 2
3892
+ offset: 2
3863
3893
  };
3864
3894
 
3865
3895
  var css_248z$1 = ".autocomplate-module_autocomplate-content__UbIUT{display:flex;flex-direction:column;position:relative}.autocomplate-module_autocomplate-content-top__FVgCp{border:2px solid #d1d1d1;border-radius:6px;box-sizing:border-box;color:#3c393e;cursor:pointer;display:flex;flex-direction:row;font-size:16px;font-weight:500;height:46px;line-height:22px;max-width:400px;padding:0 15px;transition:border-color .24s}.autocomplate-module_autocomplate-content-top__FVgCp.autocomplate-module_active__40fdV{border-color:#00236a}.autocomplate-module_autocomplate-content-top__FVgCp:hover{border-color:#3c393e}.autocomplate-module_autocomplate-content-bottom__yk0zP{animation:autocomplate-module_select-show__7Uap4 .64s linear forwards;background:#fbfbfb;border-radius:6px;box-shadow:0 0 10px rgba(60,57,62,.08);left:0;max-height:0;max-width:400px;overflow:hidden;position:absolute;top:52px;width:100%;z-index:1}.autocomplate-module_autocomplate-content-bottom-inner__rF5IF{display:flex;flex-direction:column;max-height:234px;overflow-x:hidden;overflow-y:auto}@keyframes autocomplate-module_select-show__7Uap4{to{max-height:400px}}.autocomplate-module_autocomplate-content-bottom-row__dRsZa{align-items:center;background:#fff;box-sizing:border-box;color:#3c393e;cursor:pointer;display:flex;font-size:16px;font-weight:500;height:46px;line-height:22px;margin-bottom:2px;padding:0 15px;transition:background .24s,color .24s}.autocomplate-module_autocomplate-content-bottom-row__dRsZa .autocomplate-module_no-option__xv0-E{color:red}.autocomplate-module_autocomplate-content-bottom-row__dRsZa:hover{background:unset;color:#00236a}.autocomplate-module_option-active__WuH4I .autocomplate-module_autocomplate-content-bottom-row__dRsZa{color:#00236a}.autocomplate-module_autocomplate-title__3Qxqz{color:#3c393e;display:block;font-size:16px;font-weight:500;line-height:22px;margin-bottom:6px;text-transform:none}.autocomplate-module_errorBorder__LV-nb{border:2px solid #e00!important}.autocomplate-module_errorMessage__Gchpc{color:#e00!important}";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.0.104",
3
+ "version": "0.0.105",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -261,9 +261,11 @@ export const Modal = ({
261
261
  return (
262
262
  <img
263
263
  style={{
264
+ display: 'block',
264
265
  objectFit: 'cover',
265
266
  objectPosition: 'center',
266
267
  borderRadius: radius ? radius : configStyles.MODAL.radius,
268
+ width: imageWidth ? imageWidth : configStyles.MODAL.imageWidth,
267
269
  height: imageHeight ? imageHeight : configStyles.MODAL.imageHeight
268
270
  }}
269
271
  src={item.url}
@@ -9,24 +9,19 @@ import SvgNextarrow from './../../components/icon/Nextarrow';
9
9
 
10
10
  export const Pagination = ({
11
11
  goTo,
12
+ offset,
12
13
  onChange,
14
+ className,
13
15
  totalCount,
14
- siblingCount,
15
16
  currentPage,
16
- offset,
17
- className,
18
17
  }) => {
19
18
  const [inpVal, setInpVal] = useState('');
20
19
  const [error, setError] = useState(false);
21
- const [siblingCountNumber, setSibilingCountNumber] = useState(siblingCount);
22
20
  const [currentPageNumber, setCurrentPage] = useState(currentPage);
23
21
  const [currentTotalCount, setcurrentTotalCount] = useState(totalCount);
24
22
  useEffect(() => {
25
23
  setcurrentTotalCount(totalCount);
26
24
  }, [totalCount]);
27
- useEffect(() => {
28
- setSibilingCountNumber(siblingCount);
29
- }, [siblingCount]);
30
25
  useEffect(() => {
31
26
  setCurrentPage(currentPage);
32
27
  }, [currentPage]);
@@ -41,10 +36,10 @@ export const Pagination = ({
41
36
  const paginationRange = PaginationRange({
42
37
  currentPageNumber,
43
38
  currentTotalCount,
44
- siblingCountNumber,
45
39
  offset,
46
40
  });
47
- if (currentPageNumber === 0 || paginationRange.length < 2) {
41
+
42
+ if (currentPageNumber === 0 || paginationRange?.length < 2) {
48
43
  return null;
49
44
  }
50
45
  const classProps = classnames(styles.list, className ? className : `${styles["pagination-bar"]} pagination-bar-rem`);
@@ -251,8 +246,7 @@ Pagination.propTypes = {
251
246
  offset: PropTypes.number,
252
247
  totalCount: PropTypes.number,
253
248
  className: PropTypes.string,
254
- siblingCount: PropTypes.number,
255
249
  currentPage: PropTypes.number,
256
250
  };
257
251
 
258
- Pagination.defaultProps = { offset: 2, siblingCount: 2 };
252
+ Pagination.defaultProps = { offset: 2 };
@@ -316,7 +316,7 @@ const data = [
316
316
  phone: "572-905-5251",
317
317
  },
318
318
  ];
319
- const Template = ({ goTo, offset, currentPage, siblingCount, totalCount }) => {
319
+ const Template = ({ goTo, offset, currentPage, totalCount }) => {
320
320
  const [currentPageNumber, setCurrentPageNumber] = useState(currentPage);
321
321
  const currentTableData = useMemo(() => {
322
322
  const firstPageIndex = (currentPageNumber - 1) * offset;
@@ -355,7 +355,6 @@ const Template = ({ goTo, offset, currentPage, siblingCount, totalCount }) => {
355
355
  currentPage={currentPage}
356
356
  totalCount={totalCount}
357
357
  offset={offset}
358
- siblingCount={siblingCount}
359
358
  onChange={(page) => setCurrentPageNumber(page)}
360
359
  />
361
360
  </>
@@ -368,6 +367,5 @@ Default.args = {
368
367
  goTo: false,
369
368
  offset: 10,
370
369
  currentPage: 1,
371
- siblingCount: 2,
372
370
  totalCount: 44
373
371
  };
@@ -1,5 +1,4 @@
1
1
  import React, { useMemo } from "react";
2
- // import styles from "./pagination.module.scss";
3
2
 
4
3
  export const Dots = "...";
5
4
 
@@ -9,62 +8,49 @@ const range = (start, end) => {
9
8
  };
10
9
 
11
10
  export const PaginationRange = ({
12
- currentTotalCount,
13
11
  offset,
14
- siblingCountNumber,
12
+ currentTotalCount,
15
13
  currentPageNumber,
16
14
  }) => {
17
15
  const paginationRange = useMemo(() => {
16
+ const firstPageIndex = 1;
18
17
  const totalPageCount = Math.ceil(currentTotalCount / offset);
18
+ const lastPageIndex = totalPageCount;
19
19
 
20
- //currentPage + 2*Dots + start + end = 5
21
- const totalPageNumber = siblingCountNumber + 5;
22
- if (totalPageNumber >= totalPageCount) {
20
+ if (7 >= totalPageCount) {
23
21
  return range(1, totalPageCount);
24
22
  }
25
- const rightSiblingIndex = Math.min(
26
- currentPageNumber + siblingCountNumber,
27
- totalPageCount
28
- );
29
23
 
30
- const leftSiblingIndex = Math.max(
31
- currentPageNumber - siblingCountNumber,
32
- 1
33
- );
24
+ const leftSiblingIndex = Math.max(currentPageNumber - 1, 1);
25
+ const rightSiblingIndex = Math.min(currentPageNumber + 1, totalPageCount);
34
26
 
35
27
  const shouldShowLeftDots = leftSiblingIndex > 2;
36
28
  const shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
37
- const firstPageIndex = 1;
38
- const lastPageIndex = totalPageCount;
29
+
39
30
  if (!shouldShowLeftDots && shouldShowRightDots) {
40
- let leftItemCount =
41
- currentPageNumber === 4 && lastPageIndex > 7
42
- ? 4 + siblingCountNumber
43
- : 3 + siblingCountNumber;
44
31
 
45
- let leftRange = range(1, leftItemCount);
32
+ let leftItemCount = currentPageNumber === 4 && lastPageIndex >= 7 ? 5 : 4;
46
33
 
34
+ let leftRange = range(1, leftItemCount);
47
35
  return [...leftRange, Dots, totalPageCount];
48
- }
49
36
 
50
- if (shouldShowLeftDots && !shouldShowRightDots) {
51
- let rightItemCount = 0;
52
- currentPageNumber === lastPageIndex - 3 && lastPageIndex > 7
53
- ? (rightItemCount = 4 + siblingCountNumber)
54
- : (rightItemCount = 3 + siblingCountNumber);
37
+ } else if (shouldShowLeftDots && !shouldShowRightDots) {
55
38
 
56
- let rightRange = range(
57
- totalPageCount - rightItemCount + 1,
58
- totalPageCount
59
- );
39
+ let rightItemCount = currentPageNumber === lastPageIndex - 3 && lastPageIndex >= 7 ? 4 : 3;
40
+
41
+ let rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);
60
42
  return [firstPageIndex, Dots, ...rightRange];
61
- }
62
43
 
63
- if (shouldShowLeftDots && shouldShowRightDots) {
44
+ } else if (shouldShowLeftDots && shouldShowRightDots) {
45
+
64
46
  let middleRange = range(leftSiblingIndex, rightSiblingIndex);
65
47
  return [firstPageIndex, Dots, ...middleRange, Dots, lastPageIndex];
48
+
49
+ } else {
50
+ return range(firstPageIndex, totalPageCount);
66
51
  }
67
- }, [currentTotalCount, offset, siblingCountNumber, currentPageNumber]);
52
+
53
+ }, [currentTotalCount, offset, currentPageNumber]);
68
54
 
69
55
  return paginationRange;
70
56
  };
@@ -0,0 +1,56 @@
1
+ import React, { useEffect, useState } from 'react';
2
+
3
+ import { compereConfigs } from './../../utils';
4
+
5
+ import ReactCheckbox from '../icon/CheckboxUnchecked';
6
+ import ReactCheckboxChecked from '../icon/CheckboxChecked';
7
+
8
+ const Checkbox = ({
9
+ data,
10
+ styles,
11
+ checked,
12
+ disabled,
13
+ checkedColor,
14
+ handleChecked,
15
+ unCheckedColor
16
+ }) => {
17
+ const configStyles = compereConfigs();
18
+
19
+ const [ innerChecked, setInnerChecked ] = useState(false);
20
+ const [ innerDisabled, setInnerDisabled ] = useState(false);
21
+
22
+ const handleClick = (e) => {
23
+ handleChecked(data, e);
24
+ };
25
+
26
+ useEffect(() => {
27
+ setInnerDisabled(disabled);
28
+ }, [disabled]);
29
+
30
+ useEffect(() => {
31
+ setInnerChecked(checked);
32
+ }, [checked]);
33
+
34
+ return (
35
+ <div
36
+ style={{
37
+ width: '16px',
38
+ height: '16px',
39
+ marginRight: '9px',
40
+ display: 'inline-block',
41
+ cursor: !innerDisabled ? 'pointer' : 'not-allowed',
42
+ ...styles
43
+ }}
44
+ onClick={!innerDisabled && handleChecked ? handleClick : _ => _}
45
+ >
46
+ { innerChecked && !innerDisabled
47
+ ? <ReactCheckboxChecked fillColor={checkedColor ? checkedColor : configStyles.SINGLECHECKBOX.checkedColor} />
48
+ : <ReactCheckbox fillColor={unCheckedColor ? unCheckedColor : configStyles.SINGLECHECKBOX.unCheckedColor} />
49
+ }
50
+
51
+ {/* {label && <span>{ label }</span>} */}
52
+ </div>
53
+ );
54
+ };
55
+
56
+ export default Checkbox;
@@ -1,42 +1,51 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
- import ReactCheckbox from '../icon/CheckboxUnchecked';
5
- import ReactCheckboxChecked from '../icon/CheckboxChecked';
4
+ import Checkbox from './Checkbox';
6
5
 
7
6
  export const SingleCheckbox = ({
8
- id,
9
- float,
7
+ data,
8
+ styles,
10
9
  checked,
11
- onClick,
12
- content,
13
10
  disabled,
14
11
  checkedColor,
12
+ handleChecked,
15
13
  unCheckedColor
16
14
  }) => {
17
- const [innerCheckd, setInnerChecked] = useState(false);
15
+
16
+ const [ innerData, setInnerData ] = useState(null);
18
17
 
19
18
  useEffect(() => {
20
- setInnerChecked(checked);
21
- }, [checked]);
22
- return <div
23
- style={{
24
- width: '16px',
25
- height: '16px',
26
- marginRight: '9px',
27
- display: 'inline-block',
28
- float: float ? float : '',
29
- cursor: !disabled && onClick ? 'pointer' : 'normal'
30
- }}
31
- >
32
- { innerCheckd
33
- ? <ReactCheckboxChecked onClick={!disabled && onClick ? (e) => onClick(e, content, id) : _ => _} fillColor={checkedColor ? checkedColor : ''} />
34
- : <ReactCheckbox onClick={!disabled && onClick ? (e) => onClick(e, content, id) : _ => _} fillColor={unCheckedColor ? unCheckedColor : ''} />
35
- }
36
- </div>;
19
+ // if (data) {
20
+ // if (typeof data === 'object' && data.constructor === Object) {
21
+ // setInnerData(data);
22
+ // } else {
23
+ // alert('Data props on Checkbox component must be an object');
24
+ // }
25
+ // } else {
26
+ // alert('Please add data props on Checkbox component');
27
+ // }
28
+ setInnerData(data);
29
+ }, [data]);
30
+
31
+ return (
32
+ <Checkbox
33
+ styles={styles}
34
+ data={innerData}
35
+ checked={checked}
36
+ disabled={disabled}
37
+ checkedColor={checkedColor}
38
+ handleChecked={handleChecked}
39
+ unCheckedColor={unCheckedColor}
40
+ />
41
+ );
37
42
  };
38
43
 
39
44
  SingleCheckbox.propTypes = {
45
+ onClick: PropTypes.func,
46
+ styles: PropTypes.object,
40
47
  disabled: PropTypes.bool,
41
- checked: PropTypes.bool.isRequired,
42
- }
48
+ checkedColor: PropTypes.string,
49
+ unCheckedColor: PropTypes.string,
50
+ data: PropTypes.oneOfType([PropTypes.object, PropTypes.array]).isRequired
51
+ };
@@ -1,10 +1,24 @@
1
- import React from "react";
1
+ import React, { useState } from "react";
2
2
  import { SingleCheckbox } from ".";
3
3
  export default {
4
4
  component: SingleCheckbox,
5
5
  title: "Components/SingleCheckbox",
6
6
  };
7
7
 
8
- const Template = (args) => <SingleCheckbox {...args} />;
8
+ const Template = (args) => {
9
+ const [ check, setCheck ] = useState(false);
9
10
 
10
- export const Default = Template.bind({});
11
+ const handleChecked = (data, e) => {
12
+ console.log(e, 'target event');
13
+ console.log(data, 'data');
14
+ setCheck(!check);
15
+ };
16
+
17
+ return <SingleCheckbox checked={check} data={[1,2,3]} handleChecked={handleChecked} {...args} />;
18
+ }
19
+
20
+ export const Default = Template.bind({});
21
+ Default.args = {
22
+ checkedColor: '#00236A',
23
+ unCheckedColor: '#D1D1D1'
24
+ };
@@ -353,7 +353,7 @@ const Template = (args) => {
353
353
  };
354
354
 
355
355
  const handleCheckedHeader = (e, content) => {
356
- e.stopPropagation();
356
+ // e.stopPropagation();
357
357
  let checkableItemIndex;
358
358
  let checkableItemBool;
359
359
  const updatedHeader = tableDataHeader.slice();
@@ -40,7 +40,7 @@ const TH = ({
40
40
  float='left'
41
41
  checked={item.checkBox.checked}
42
42
  content={item.content ? item.content : ''}
43
- onClick={handleCheckedHeader ? handleCheckedHeader : _ => _}
43
+ handleChecked={handleCheckedHeader ? handleCheckedHeader : _ => _}
44
44
  checkedColor={item.checkBox.checkedColor ? item.checkBox.checkedColor : ''}
45
45
  unCheckedColor={item.checkBox.unCheckedColor ? item.checkBox.unCheckedColor : ''}
46
46
  />
@@ -596,6 +596,7 @@ import StackAlt from './assets/stackalt.svg';
596
596
  minHeight: '200px', // for modal min height
597
597
  headerWeight: '600', // for modal header font weight
598
598
  imageHeight: '100%', // for modal image height on images mode
599
+ imageWidth: '', // for modal image width on images mode
599
600
  headerHeight: '30px', // for modal header height
600
601
  grayDecorHeight: '80px', // for modal top decoration when show slider
601
602
  width: 'fit-content', // for modal width
@@ -608,3 +609,11 @@ import StackAlt from './assets/stackalt.svg';
608
609
  borderStyle: 'solid', // for modal border style
609
610
  }
610
611
  ```
612
+
613
+ ### SingleCheckbox
614
+ ```
615
+ {
616
+ checkedColor: '#00236A', // for checkbox background ( fill ) color
617
+ unCheckedColor: '#D1D1D1', // for checkbox border color
618
+ }
619
+ ```
package/tui.config.js CHANGED
@@ -391,6 +391,7 @@ module.exports = {
391
391
  minHeight: '200px', // for modal min height
392
392
  headerWeight: '600', // for modal header font weight
393
393
  imageHeight: '100%', // for modal image height on images mode
394
+ imageWidth: '', // for modal image width on images mode
394
395
  headerHeight: '30px', // for modal header height
395
396
  grayDecorHeight: '80px', // for modal top decoration when show slider
396
397
  width: 'fit-content', // for modal width
@@ -403,6 +404,10 @@ module.exports = {
403
404
  borderStyle: 'solid', // for modal border style
404
405
  borderColor: 'transparent', // for modal border color
405
406
  },
407
+ SINGLECHECKBOX: {
408
+ checkedColor: '#00236A', // for checkbox background ( fill ) color
409
+ unCheckedColor: '#D1D1D1', // for checkbox border color
410
+ },
406
411
  // default properties for <Table /> component
407
412
  TABLE: {
408
413
  tHeadFontWeight: 600,