diginet-core-ui 1.3.87-beta.2 → 1.3.87-beta.3
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/components/button/icon.js +1 -0
- package/components/form-control/calendar/function.js +113 -113
- package/components/form-control/checkbox/index.js +4 -4
- package/components/form-control/radio/index.js +5 -5
- package/components/form-control/toggle/index.js +4 -4
- package/components/grid/index.js +3 -1
- package/components/others/option-wrapper/index.js +3 -1
- package/components/popover/index.js +32 -23
- package/components/rating/index.js +8 -8
- package/components/tab/tab-container.js +8 -7
- package/components/tab/tab-header.js +40 -47
- package/components/tab/tab-panel.js +11 -18
- package/components/tab/tab.js +65 -80
- package/components/transfer/index.js +3 -3
- package/package.json +1 -1
- package/styles/general.js +1 -1
- package/styles/sx/index.js +23 -0
|
@@ -124,6 +124,7 @@ const ButtonIcon = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
124
124
|
css: [_ButtonRootCSS, _ButtonSizeCSS, disabled && ButtonDisabledCSS],
|
|
125
125
|
ref: ref,
|
|
126
126
|
id: id,
|
|
127
|
+
disabled: disabled,
|
|
127
128
|
style: style,
|
|
128
129
|
onClick: _onClick,
|
|
129
130
|
className: classNames('DGN-UI-ButtonIcon', viewType, getClassNameFromColor(colorProp), size, loading && 'button-icon--loading', className)
|
|
@@ -32,15 +32,15 @@ const {
|
|
|
32
32
|
info8
|
|
33
33
|
} = colors;
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* START STYLE
|
|
35
|
+
/**
|
|
36
|
+
* START STYLE
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
* @param {Object} unique
|
|
42
|
-
* @param {Boolean} boxShadow
|
|
43
|
-
* @returns
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {Object} unique
|
|
42
|
+
* @param {Boolean} boxShadow
|
|
43
|
+
* @returns
|
|
44
44
|
*/
|
|
45
45
|
const generateCalendarCSS = (unique, boxShadow = true, onClickActive = true) => css`
|
|
46
46
|
${borderRadius4px}
|
|
@@ -243,15 +243,15 @@ const generateCalendarCSS = (unique, boxShadow = true, onClickActive = true) =>
|
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
`;
|
|
246
|
-
/**
|
|
247
|
-
* END STYLE
|
|
246
|
+
/**
|
|
247
|
+
* END STYLE
|
|
248
248
|
*/
|
|
249
249
|
|
|
250
|
-
/**
|
|
251
|
-
*
|
|
252
|
-
* @description return props of the typography.
|
|
253
|
-
* @param {String} className
|
|
254
|
-
* @returns {Object} props of the typography
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
* @description return props of the typography.
|
|
253
|
+
* @param {String} className
|
|
254
|
+
* @returns {Object} props of the typography
|
|
255
255
|
*/
|
|
256
256
|
const typographyProps = className => {
|
|
257
257
|
return {
|
|
@@ -270,11 +270,11 @@ const typographyProps = className => {
|
|
|
270
270
|
type: 'h6'
|
|
271
271
|
};
|
|
272
272
|
};
|
|
273
|
-
/**
|
|
274
|
-
*
|
|
275
|
-
* @description return props of the button icon.
|
|
276
|
-
* @param {String} className
|
|
277
|
-
* @returns {Object} props of the button icon
|
|
273
|
+
/**
|
|
274
|
+
*
|
|
275
|
+
* @description return props of the button icon.
|
|
276
|
+
* @param {String} className
|
|
277
|
+
* @returns {Object} props of the button icon
|
|
278
278
|
*/
|
|
279
279
|
const buttonIconProps = className => {
|
|
280
280
|
return {
|
|
@@ -286,11 +286,11 @@ const buttonIconProps = className => {
|
|
|
286
286
|
width: 28
|
|
287
287
|
};
|
|
288
288
|
};
|
|
289
|
-
/**
|
|
290
|
-
*
|
|
291
|
-
* @description return props of the button icon.
|
|
292
|
-
* @param {Function} fn
|
|
293
|
-
* @returns {Object} props of the button text
|
|
289
|
+
/**
|
|
290
|
+
*
|
|
291
|
+
* @description return props of the button icon.
|
|
292
|
+
* @param {Function} fn
|
|
293
|
+
* @returns {Object} props of the button text
|
|
294
294
|
*/
|
|
295
295
|
const buttonTextProps = fn => {
|
|
296
296
|
return {
|
|
@@ -306,43 +306,43 @@ const buttonTextProps = fn => {
|
|
|
306
306
|
};
|
|
307
307
|
};
|
|
308
308
|
|
|
309
|
-
/**
|
|
310
|
-
* @description detect value is a Date object
|
|
311
|
-
* @param {String | Number | Array} value
|
|
312
|
-
* @returns boolean
|
|
309
|
+
/**
|
|
310
|
+
* @description detect value is a Date object
|
|
311
|
+
* @param {String | Number | Array} value
|
|
312
|
+
* @returns boolean
|
|
313
313
|
*/
|
|
314
314
|
const isValidDate = value => {
|
|
315
315
|
return new Date(value) instanceof Date && !isNaN(new Date(value));
|
|
316
316
|
};
|
|
317
|
-
/**
|
|
318
|
-
*
|
|
319
|
-
* @description set Sunday (0) to the last day of week.
|
|
320
|
-
* @param {Date} date
|
|
321
|
-
* @returns number of day from 0 (Monday) to 6 (Sunday).
|
|
317
|
+
/**
|
|
318
|
+
*
|
|
319
|
+
* @description set Sunday (0) to the last day of week.
|
|
320
|
+
* @param {Date} date
|
|
321
|
+
* @returns number of day from 0 (Monday) to 6 (Sunday).
|
|
322
322
|
*/
|
|
323
323
|
const getDateOfWeek = date => {
|
|
324
324
|
let day = date.getDay();
|
|
325
325
|
if (day === 0) day = 7;
|
|
326
326
|
return day - 1;
|
|
327
327
|
};
|
|
328
|
-
/**
|
|
329
|
-
*
|
|
330
|
-
* @description check day is today.
|
|
331
|
-
* @param {Date} day
|
|
332
|
-
* @param {Date} today
|
|
333
|
-
* @param {String} className
|
|
334
|
-
* @returns {Boolean} is today
|
|
328
|
+
/**
|
|
329
|
+
*
|
|
330
|
+
* @description check day is today.
|
|
331
|
+
* @param {Date} day
|
|
332
|
+
* @param {Date} today
|
|
333
|
+
* @param {String} className
|
|
334
|
+
* @returns {Boolean} is today
|
|
335
335
|
*/
|
|
336
336
|
const isToday = (day, today, className) => {
|
|
337
337
|
return +moment(day).diff(today) === 0 ? className : '';
|
|
338
338
|
};
|
|
339
|
-
/**
|
|
340
|
-
*
|
|
341
|
-
* @description check day is active day.
|
|
342
|
-
* @param {Date} day
|
|
343
|
-
* @param {Date} active
|
|
344
|
-
* @param {String} className
|
|
345
|
-
* @returns {Boolean} is active day
|
|
339
|
+
/**
|
|
340
|
+
*
|
|
341
|
+
* @description check day is active day.
|
|
342
|
+
* @param {Date} day
|
|
343
|
+
* @param {Date} active
|
|
344
|
+
* @param {String} className
|
|
345
|
+
* @returns {Boolean} is active day
|
|
346
346
|
*/
|
|
347
347
|
const isActive = (day, active, className) => {
|
|
348
348
|
if (Array.isArray(active)) {
|
|
@@ -355,14 +355,14 @@ const isActive = (day, active, className) => {
|
|
|
355
355
|
}
|
|
356
356
|
return '';
|
|
357
357
|
};
|
|
358
|
-
/**
|
|
359
|
-
*
|
|
360
|
-
* @description check day is min/max day.
|
|
361
|
-
* @param {Date} day
|
|
362
|
-
* @param {Date} max
|
|
363
|
-
* @param {Date} min
|
|
364
|
-
* @param {Object} className
|
|
365
|
-
* @returns {Boolean} is limited day
|
|
358
|
+
/**
|
|
359
|
+
*
|
|
360
|
+
* @description check day is min/max day.
|
|
361
|
+
* @param {Date} day
|
|
362
|
+
* @param {Date} max
|
|
363
|
+
* @param {Date} min
|
|
364
|
+
* @param {Object} className
|
|
365
|
+
* @returns {Boolean} is limited day
|
|
366
366
|
*/
|
|
367
367
|
const isLimit = (day, max, min, className) => {
|
|
368
368
|
return isBeforeLimit(min, day) || isAfterLimit(max, day) ? className : '';
|
|
@@ -385,17 +385,17 @@ const isBeforeLimit = (min, time) => {
|
|
|
385
385
|
const isAfterLimit = (max, time) => {
|
|
386
386
|
return max && isValidDate(max) && moment(time).diff(new Date(max).setHours(0, 0, 0, 0)) > 0;
|
|
387
387
|
};
|
|
388
|
-
/**
|
|
389
|
-
*
|
|
390
|
-
* @description return the table body of the calendar.
|
|
391
|
-
* @param {Date} time
|
|
392
|
-
* @param {Date} activeValue
|
|
393
|
-
* @param {Object} className
|
|
394
|
-
* @param {Boolean} displayAnotherMonth
|
|
395
|
-
* @param {Function} onTableDataClick
|
|
396
|
-
* @param {Date} min
|
|
397
|
-
* @param {Date} max
|
|
398
|
-
* @returns {Element}
|
|
388
|
+
/**
|
|
389
|
+
*
|
|
390
|
+
* @description return the table body of the calendar.
|
|
391
|
+
* @param {Date} time
|
|
392
|
+
* @param {Date} activeValue
|
|
393
|
+
* @param {Object} className
|
|
394
|
+
* @param {Boolean} displayAnotherMonth
|
|
395
|
+
* @param {Function} onTableDataClick
|
|
396
|
+
* @param {Date} min
|
|
397
|
+
* @param {Date} max
|
|
398
|
+
* @returns {Element}
|
|
399
399
|
*/
|
|
400
400
|
const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTableDataClick, min, max) => {
|
|
401
401
|
time = new Date(time);
|
|
@@ -412,8 +412,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
412
412
|
weekDateFirst = getDateOfWeek(firstDay),
|
|
413
413
|
weekDateLast = getDateOfWeek(lastDay);
|
|
414
414
|
if (activeValue && Array.isArray(activeValue) && activeValue.length === 2 && activeValue[0] !== activeValue[1]) {
|
|
415
|
-
/**
|
|
416
|
-
* days of previous month
|
|
415
|
+
/**
|
|
416
|
+
* days of previous month
|
|
417
417
|
*/
|
|
418
418
|
active = activeValue;
|
|
419
419
|
for (let i = weekDateFirst; i > 0; i--) {
|
|
@@ -428,8 +428,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
428
428
|
...typographyProps(className.day.day)
|
|
429
429
|
}, '')));
|
|
430
430
|
}
|
|
431
|
-
/**
|
|
432
|
-
* days of this month
|
|
431
|
+
/**
|
|
432
|
+
* days of this month
|
|
433
433
|
*/
|
|
434
434
|
for (let i = 0; i < lastDate; i++) {
|
|
435
435
|
const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
|
|
@@ -442,8 +442,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
442
442
|
...typographyProps(className.day.day)
|
|
443
443
|
}, i + 1)));
|
|
444
444
|
}
|
|
445
|
-
/**
|
|
446
|
-
* days of next month
|
|
445
|
+
/**
|
|
446
|
+
* days of next month
|
|
447
447
|
*/
|
|
448
448
|
for (let i = 0; i < 20 - weekDateLast; i++) {
|
|
449
449
|
const day = new Date(time.getFullYear(), time.getMonth() + 1,
|
|
@@ -458,8 +458,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
458
458
|
}, '')));
|
|
459
459
|
}
|
|
460
460
|
} else {
|
|
461
|
-
/**
|
|
462
|
-
* days of previous month
|
|
461
|
+
/**
|
|
462
|
+
* days of previous month
|
|
463
463
|
*/
|
|
464
464
|
for (let i = weekDateFirst; i > 0; i--) {
|
|
465
465
|
const day = new Date(time.getFullYear(), time.getMonth() - 1, displayAnotherMonth ? prevDate - i + 1 : 1);
|
|
@@ -472,8 +472,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
472
472
|
...typographyProps(className.day.day)
|
|
473
473
|
}, displayAnotherMonth ? prevDate - i + 1 : '')));
|
|
474
474
|
}
|
|
475
|
-
/**
|
|
476
|
-
* days of this month
|
|
475
|
+
/**
|
|
476
|
+
* days of this month
|
|
477
477
|
*/
|
|
478
478
|
for (let i = 0; i < lastDate; i++) {
|
|
479
479
|
const day = new Date(time.getFullYear(), time.getMonth(), i + 1);
|
|
@@ -486,8 +486,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
486
486
|
...typographyProps(className.day.day)
|
|
487
487
|
}, i + 1)));
|
|
488
488
|
}
|
|
489
|
-
/**
|
|
490
|
-
* days of next month
|
|
489
|
+
/**
|
|
490
|
+
* days of next month
|
|
491
491
|
*/
|
|
492
492
|
for (let i = 0; i < 20 - weekDateLast; i++) {
|
|
493
493
|
const day = new Date(time.getFullYear(), time.getMonth() + 1, displayAnotherMonth ? i + 1 : 6 - weekDateLast);
|
|
@@ -513,10 +513,10 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
|
|
|
513
513
|
}
|
|
514
514
|
return tableBody;
|
|
515
515
|
};
|
|
516
|
-
/**
|
|
517
|
-
*
|
|
518
|
-
* @param {Object} className
|
|
519
|
-
* @returns
|
|
516
|
+
/**
|
|
517
|
+
*
|
|
518
|
+
* @param {Object} className
|
|
519
|
+
* @returns
|
|
520
520
|
*/
|
|
521
521
|
const renderHeader = className => {
|
|
522
522
|
const weekdays = getGlobal(['weekdaysLong']);
|
|
@@ -535,15 +535,15 @@ const renderHeader = className => {
|
|
|
535
535
|
}, tableHeader));
|
|
536
536
|
return header;
|
|
537
537
|
};
|
|
538
|
-
/**
|
|
539
|
-
*
|
|
540
|
-
* @param {Object} className
|
|
541
|
-
* @param {Object} refs
|
|
542
|
-
* @param {Function} dbLeftFn
|
|
543
|
-
* @param {Function} leftFn
|
|
544
|
-
* @param {Function} rightFn
|
|
545
|
-
* @param {Function} dbRightFn
|
|
546
|
-
* @returns navigator
|
|
538
|
+
/**
|
|
539
|
+
*
|
|
540
|
+
* @param {Object} className
|
|
541
|
+
* @param {Object} refs
|
|
542
|
+
* @param {Function} dbLeftFn
|
|
543
|
+
* @param {Function} leftFn
|
|
544
|
+
* @param {Function} rightFn
|
|
545
|
+
* @param {Function} dbRightFn
|
|
546
|
+
* @returns navigator
|
|
547
547
|
*/
|
|
548
548
|
const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn, fn) => jsx("div", {
|
|
549
549
|
className: className.navigator.navigator
|
|
@@ -580,22 +580,22 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
|
|
|
580
580
|
onClick: dbRightFn,
|
|
581
581
|
ref: refs.doubleRight
|
|
582
582
|
})));
|
|
583
|
-
/**
|
|
584
|
-
*
|
|
585
|
-
* @param {Date} time
|
|
586
|
-
* @returns {String} month year
|
|
583
|
+
/**
|
|
584
|
+
*
|
|
585
|
+
* @param {Date} time
|
|
586
|
+
* @returns {String} month year
|
|
587
587
|
*/
|
|
588
588
|
const renderNavigatorContent = time => {
|
|
589
589
|
const value = new Date(time);
|
|
590
590
|
const months = getGlobal(['months', 'full']);
|
|
591
591
|
return [months[value.getMonth()], value.getFullYear()];
|
|
592
592
|
};
|
|
593
|
-
/**
|
|
594
|
-
*
|
|
595
|
-
* @param {Date} time
|
|
596
|
-
* @param {Object} refs
|
|
597
|
-
* @param {Date} min
|
|
598
|
-
* @param {Date} max
|
|
593
|
+
/**
|
|
594
|
+
*
|
|
595
|
+
* @param {Date} time
|
|
596
|
+
* @param {Object} refs
|
|
597
|
+
* @param {Date} min
|
|
598
|
+
* @param {Date} max
|
|
599
599
|
*/
|
|
600
600
|
const onUpdateNavigator = (time, refs, min, max) => {
|
|
601
601
|
var _refs$doubleLeft$curr, _refs$doubleLeft$curr2, _refs$doubleRight$cur, _refs$doubleRight$cur2, _refs$left$current, _refs$left$current$in, _refs$right$current, _refs$right$current$i;
|
|
@@ -634,18 +634,18 @@ const onUpdateNavigator = (time, refs, min, max) => {
|
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
636
|
};
|
|
637
|
-
/**
|
|
638
|
-
*
|
|
639
|
-
* @param {Date} time
|
|
640
|
-
* @param {Object} navigatorRefs
|
|
641
|
-
* @param {Date} min
|
|
642
|
-
* @param {Date} max
|
|
643
|
-
* @param {Element} table
|
|
644
|
-
* @param {Date} activeValue
|
|
645
|
-
* @param {Object} className
|
|
646
|
-
* @param {Boolean} displayAnotherMonth
|
|
647
|
-
* @param {Function} onTableDataClick
|
|
648
|
-
* @param {Function} onUpdateNavigatorValue
|
|
637
|
+
/**
|
|
638
|
+
*
|
|
639
|
+
* @param {Date} time
|
|
640
|
+
* @param {Object} navigatorRefs
|
|
641
|
+
* @param {Date} min
|
|
642
|
+
* @param {Date} max
|
|
643
|
+
* @param {Element} table
|
|
644
|
+
* @param {Date} activeValue
|
|
645
|
+
* @param {Object} className
|
|
646
|
+
* @param {Boolean} displayAnotherMonth
|
|
647
|
+
* @param {Function} onTableDataClick
|
|
648
|
+
* @param {Function} onUpdateNavigatorValue
|
|
649
649
|
*/
|
|
650
650
|
const onUpdateCalendar = (time, navigatorRefs, min, max, table, activeValue, className, displayAnotherMonth, onTableDataClick, onUpdateNavigatorValue) => {
|
|
651
651
|
onUpdateNavigator(time, navigatorRefs, min, max);
|
|
@@ -298,10 +298,10 @@ Checkbox.propTypes = {
|
|
|
298
298
|
labelProps: PropTypes.object,
|
|
299
299
|
/** The name of the Checkbox corresponds to the label displayed on the interface. */
|
|
300
300
|
name: PropTypes.string,
|
|
301
|
-
/**
|
|
302
|
-
* Callback fired when the state is changed.
|
|
303
|
-
*
|
|
304
|
-
* You can pull out the new checked state by accessing `event.value` or `event.target.checked` (boolean).
|
|
301
|
+
/**
|
|
302
|
+
* Callback fired when the state is changed.
|
|
303
|
+
*
|
|
304
|
+
* You can pull out the new checked state by accessing `event.value` or `event.target.checked` (boolean).
|
|
305
305
|
*/
|
|
306
306
|
onChange: PropTypes.func,
|
|
307
307
|
/** If `true`, the component is readonly. */
|
|
@@ -191,11 +191,11 @@ Radio.propTypes = {
|
|
|
191
191
|
className: PropTypes.string,
|
|
192
192
|
/** Props for input. */
|
|
193
193
|
inputProps: PropTypes.object,
|
|
194
|
-
/** Callback fired when the state is changed.
|
|
195
|
-
*
|
|
196
|
-
* @param {object} event The event source of the callback.
|
|
197
|
-
* You can pull out the new value by accessing `event.target.value` (string).
|
|
198
|
-
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
194
|
+
/** Callback fired when the state is changed.
|
|
195
|
+
*
|
|
196
|
+
* @param {object} event The event source of the callback.
|
|
197
|
+
* You can pull out the new value by accessing `event.target.value` (string).
|
|
198
|
+
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
199
199
|
* */
|
|
200
200
|
onChange: PropTypes.func,
|
|
201
201
|
/** Prevent all event if true. */
|
|
@@ -226,10 +226,10 @@ Toggle.propTypes = {
|
|
|
226
226
|
lineClamp: PropTypes.number,
|
|
227
227
|
/** Shows tooltip containing Label on hover */
|
|
228
228
|
hoverTooltip: PropTypes.bool,
|
|
229
|
-
/** * Callback fired when the state is changed.
|
|
230
|
-
*
|
|
231
|
-
* @param {object} event The event source of the callback.
|
|
232
|
-
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
229
|
+
/** * Callback fired when the state is changed.
|
|
230
|
+
*
|
|
231
|
+
* @param {object} event The event source of the callback.
|
|
232
|
+
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
233
233
|
*/
|
|
234
234
|
onChange: PropTypes.func,
|
|
235
235
|
/** If `true`, the label will indicate that the checkbox is required. */
|
package/components/grid/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import OptionWrapper from "../others/option-wrapper";
|
|
4
5
|
import PropTypes from 'prop-types';
|
|
5
6
|
import { forwardRef, memo, useContext, useImperativeHandle, useMemo, useRef } from 'react';
|
|
6
7
|
import { boxBorder } from "../../styles/general";
|
|
@@ -232,4 +233,5 @@ Grid.propTypes = {
|
|
|
232
233
|
/** If `true`, it sets `min-width: 0` on the item. Refer to the limitations section of the documentation to better understand the use case. */
|
|
233
234
|
zeroMinWidth: PropTypes.bool
|
|
234
235
|
};
|
|
235
|
-
export
|
|
236
|
+
export { Grid };
|
|
237
|
+
export default OptionWrapper(Grid);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** @jsx jsx */
|
|
3
3
|
import { useState, forwardRef, useEffect } from 'react';
|
|
4
4
|
import { jsx } from '@emotion/core';
|
|
5
|
+
import sx from "../../../styles/sx";
|
|
5
6
|
const OptionWrapper = WrappedComponent => {
|
|
6
7
|
return /*#__PURE__*/forwardRef((props, ref) => {
|
|
7
8
|
const [options, setOptions] = useState({});
|
|
@@ -28,7 +29,8 @@ const OptionWrapper = WrappedComponent => {
|
|
|
28
29
|
action: {
|
|
29
30
|
option
|
|
30
31
|
},
|
|
31
|
-
ref: ref
|
|
32
|
+
ref: ref,
|
|
33
|
+
css: sx(props === null || props === void 0 ? void 0 : props.sx)
|
|
32
34
|
});
|
|
33
35
|
});
|
|
34
36
|
};
|
|
@@ -131,6 +131,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
131
131
|
height,
|
|
132
132
|
marginThreshold,
|
|
133
133
|
onClose,
|
|
134
|
+
onOpen,
|
|
134
135
|
open,
|
|
135
136
|
pressESCToClose,
|
|
136
137
|
style,
|
|
@@ -144,6 +145,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
144
145
|
const ref = useRef(null);
|
|
145
146
|
const arrowRef = useRef(null);
|
|
146
147
|
const overflow = useRef(null);
|
|
148
|
+
const anchorRef = useRef(anchor);
|
|
147
149
|
const [openState, setOpenState] = useState(open);
|
|
148
150
|
const [element, setElement] = useState(null);
|
|
149
151
|
const _PortalPopoverCSS = PortalPopoverCSS(zIndex, fullScreen);
|
|
@@ -157,6 +159,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
157
159
|
}
|
|
158
160
|
const onOpenPopover = () => {
|
|
159
161
|
if (!openState) setOpenState(true);
|
|
162
|
+
onOpen && onOpen();
|
|
160
163
|
};
|
|
161
164
|
const onClosePopover = () => {
|
|
162
165
|
if (openState) {
|
|
@@ -389,8 +392,12 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
389
392
|
};
|
|
390
393
|
}, []);
|
|
391
394
|
useEffect(() => {
|
|
392
|
-
|
|
395
|
+
anchorRef.current = anchor;
|
|
396
|
+
}, [anchor]);
|
|
397
|
+
useEffect(() => {
|
|
398
|
+
var _anchor8, _anchor9, _anchorRef$current, _anchorRef$current$pr;
|
|
393
399
|
const anchorEl = ((_anchor8 = anchor) === null || _anchor8 === void 0 ? void 0 : _anchor8.element) || ((_anchor9 = anchor) === null || _anchor9 === void 0 ? void 0 : _anchor9.current) || anchor;
|
|
400
|
+
if (anchorEl !== null && anchorEl !== void 0 && anchorEl.disabled || (_anchorRef$current = anchorRef.current) !== null && _anchorRef$current !== void 0 && (_anchorRef$current$pr = _anchorRef$current.props) !== null && _anchorRef$current$pr !== void 0 && _anchorRef$current$pr.disabled) return;
|
|
394
401
|
const eventArr = eventMap.get(trigger) || [];
|
|
395
402
|
if (anchorEl && open === undefined && (eventArr === null || eventArr === void 0 ? void 0 : eventArr.length) > 0) {
|
|
396
403
|
eventArr.forEach(evt => anchorEl.addEventListener(evt, handleEventTrigger, false));
|
|
@@ -398,7 +405,7 @@ const Popover = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
398
405
|
eventArr.forEach(evt => anchorEl.removeEventListener(evt, handleEventTrigger, false));
|
|
399
406
|
};
|
|
400
407
|
}
|
|
401
|
-
}, [trigger, openState]);
|
|
408
|
+
}, [anchor, trigger, openState]);
|
|
402
409
|
useEffect(() => {
|
|
403
410
|
if (open !== undefined) setOpenState(open);
|
|
404
411
|
}, [open]);
|
|
@@ -554,9 +561,9 @@ Popover.defaultProps = {
|
|
|
554
561
|
Popover.propTypes = {
|
|
555
562
|
/** An HTML element, or a function that returns one. It's used to set the position of the popover. */
|
|
556
563
|
anchor: PropTypes.oneOfType([PropTypes.instanceOf(Element), PropTypes.func, PropTypes.object, PropTypes.node, ref]),
|
|
557
|
-
/**
|
|
558
|
-
* This is the point on the anchor where the popover's anchor will attach to.
|
|
559
|
-
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
564
|
+
/**
|
|
565
|
+
* This is the point on the anchor where the popover's anchor will attach to.
|
|
566
|
+
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
560
567
|
*/
|
|
561
568
|
anchorOrigin: PropTypes.shape({
|
|
562
569
|
horizontal: PropTypes.oneOf(['center', 'left', 'right']),
|
|
@@ -572,14 +579,14 @@ Popover.propTypes = {
|
|
|
572
579
|
className: PropTypes.string,
|
|
573
580
|
/** If `true`, click outside will close component. */
|
|
574
581
|
clickOutsideToClose: PropTypes.bool,
|
|
575
|
-
/**
|
|
576
|
-
* Direction when Popover shown.
|
|
577
|
-
* Note: This prop will overwrite anchorOrigin & transformOrigin.
|
|
578
|
-
*
|
|
579
|
-
* * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
|
|
580
|
-
* * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
|
|
581
|
-
* * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
|
|
582
|
-
* * bottom: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
|
|
582
|
+
/**
|
|
583
|
+
* Direction when Popover shown.
|
|
584
|
+
* Note: This prop will overwrite anchorOrigin & transformOrigin.
|
|
585
|
+
*
|
|
586
|
+
* * top: anchorOrigin: { vertical: 'top', horizontal: 'center' }, transformOrigin: { vertical: 'bottom', horizontal: 'center' }
|
|
587
|
+
* * left: anchorOrigin: { vertical: 'center', horizontal: 'left' }, transformOrigin: { vertical: 'center', horizontal: 'right' }
|
|
588
|
+
* * right: anchorOrigin: { vertical: 'center', horizontal: 'right' }, transformOrigin: { vertical: 'center', horizontal: 'left' }
|
|
589
|
+
* * bottom: anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' }
|
|
583
590
|
*/
|
|
584
591
|
direction: PropTypes.oneOf(['top', 'left', 'right', 'bottom']),
|
|
585
592
|
/** Height of the component. */
|
|
@@ -588,15 +595,17 @@ Popover.propTypes = {
|
|
|
588
595
|
marginThreshold: PropTypes.number,
|
|
589
596
|
/** Callback fired when the component requests to be closed. */
|
|
590
597
|
onClose: PropTypes.func,
|
|
598
|
+
/** Callback fired when the component requests to be opened. */
|
|
599
|
+
onOpen: PropTypes.func,
|
|
591
600
|
/** If `true`, the component is shown. */
|
|
592
601
|
open: PropTypes.bool,
|
|
593
602
|
/** If `true`, hitting escape will close component. */
|
|
594
603
|
pressESCToClose: PropTypes.bool,
|
|
595
604
|
/** Style inline of component. */
|
|
596
605
|
style: PropTypes.object,
|
|
597
|
-
/**
|
|
598
|
-
* This is the point on the popover which will attach to the anchor's origin.
|
|
599
|
-
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
606
|
+
/**
|
|
607
|
+
* This is the point on the popover which will attach to the anchor's origin.
|
|
608
|
+
* Options: vertical: [top, center, bottom]; horizontal: [left, center, right].
|
|
600
609
|
*/
|
|
601
610
|
transformOrigin: PropTypes.shape({
|
|
602
611
|
horizontal: PropTypes.oneOf(['center', 'left', 'right']),
|
|
@@ -608,13 +617,13 @@ Popover.propTypes = {
|
|
|
608
617
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
609
618
|
/** Config z-index of the component. */
|
|
610
619
|
zIndex: PropTypes.number,
|
|
611
|
-
/**
|
|
612
|
-
* ref methods (ref.current.instance.*method*)
|
|
613
|
-
*
|
|
614
|
-
* * show: Show popover
|
|
615
|
-
* * close: Close popover
|
|
616
|
-
* * setPosition(element): Set position of popover
|
|
617
|
-
* * @param {element} - element
|
|
620
|
+
/**
|
|
621
|
+
* ref methods (ref.current.instance.*method*)
|
|
622
|
+
*
|
|
623
|
+
* * show: Show popover
|
|
624
|
+
* * close: Close popover
|
|
625
|
+
* * setPosition(element): Set position of popover
|
|
626
|
+
* * @param {element} - element
|
|
618
627
|
*/
|
|
619
628
|
reference: ref
|
|
620
629
|
};
|
|
@@ -243,14 +243,14 @@ Rating.propTypes = {
|
|
|
243
243
|
className: PropTypes.string,
|
|
244
244
|
/** Style inline of component. */
|
|
245
245
|
style: PropTypes.object,
|
|
246
|
-
/**
|
|
247
|
-
* Callback fired when the value changes.
|
|
248
|
-
*
|
|
249
|
-
|
|
250
|
-
*
|
|
251
|
-
* event: The event source of the callback.
|
|
252
|
-
*
|
|
253
|
-
* value: The new value.
|
|
246
|
+
/**
|
|
247
|
+
* Callback fired when the value changes.
|
|
248
|
+
*
|
|
249
|
+
function(event: React.SyntheticEvent, value: number) => void
|
|
250
|
+
*
|
|
251
|
+
* event: The event source of the callback.
|
|
252
|
+
*
|
|
253
|
+
* value: The new value.
|
|
254
254
|
*/
|
|
255
255
|
onRating: PropTypes.func
|
|
256
256
|
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import
|
|
4
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
5
|
+
import React, { forwardRef, memo, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { displayFlex, flexCol, flexRow, parseWidth, positionRelative, typographyTypes } from "../../styles/general";
|
|
6
7
|
import { classNames, randomString, refType as ref } from "../../utils";
|
|
7
8
|
import TabContext from "./context";
|
|
8
|
-
import { isNumeric } from "../../utils/type";
|
|
9
|
-
import { flexCol, flexRow, positionRelative, parseWidth, typographyTypes } from "../../styles/general";
|
|
10
9
|
const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
11
10
|
action = {},
|
|
12
11
|
children,
|
|
@@ -18,6 +17,7 @@ const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
18
17
|
width,
|
|
19
18
|
...props
|
|
20
19
|
}, reference) => {
|
|
20
|
+
if (!reference) reference = useRef(null);
|
|
21
21
|
const ref = useRef(null);
|
|
22
22
|
const {
|
|
23
23
|
value
|
|
@@ -31,7 +31,7 @@ const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
31
31
|
if (level === 'level2') level = 'p1';
|
|
32
32
|
const _TabContainerCSS = TabContainerCSS(direction, width);
|
|
33
33
|
useEffect(() => {
|
|
34
|
-
if (
|
|
34
|
+
if (typeof value === 'number') setTabIndexState(value);else setTabIndexState(tabIndex);
|
|
35
35
|
}, [value, tabIndex]);
|
|
36
36
|
useImperativeHandle(reference, () => {
|
|
37
37
|
const currentRef = ref.current || {};
|
|
@@ -63,6 +63,7 @@ const TabContainer = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
63
63
|
}, [children, className, direction, level, props, style, tabIndex, width, tabIndexState, value]);
|
|
64
64
|
}));
|
|
65
65
|
const TabContainerCSS = (direction, width) => css`
|
|
66
|
+
${displayFlex};
|
|
66
67
|
${direction === 'vertical' ? flexRow : flexCol};
|
|
67
68
|
${positionRelative};
|
|
68
69
|
${parseWidth(width)};
|
|
@@ -92,8 +93,8 @@ TabContainer.propTypes = {
|
|
|
92
93
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
93
94
|
/** Any props else. */
|
|
94
95
|
props: PropTypes.any,
|
|
95
|
-
/**
|
|
96
|
-
* Ref methods.
|
|
96
|
+
/**
|
|
97
|
+
* Ref methods.
|
|
97
98
|
*/
|
|
98
99
|
reference: ref
|
|
99
100
|
};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { ButtonIcon } from "./..";
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { boxBorder, displayNone, flexCol, flexRow, justifyCenter, overflowHidden, parseWidth, parseWidthHeight, positionRelative, whiteSpaceNoWrap } from "../../styles/general";
|
|
6
|
+
import React, { forwardRef, memo, useContext, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { boxBorder, displayFlex, displayNone, flexCol, flexRow, justifyCenter, mg, overflowHidden, parseMaxWidth, parseWidth, parseWidthHeight, pd, positionRelative, selfCenter, whiteSpaceNoWrap } from "../../styles/general";
|
|
9
8
|
import { classNames, refType as ref } from "../../utils";
|
|
10
|
-
import
|
|
11
|
-
const {
|
|
12
|
-
spacing
|
|
13
|
-
} = theme;
|
|
9
|
+
import TabContext from "./context";
|
|
14
10
|
const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
15
11
|
action = {},
|
|
16
12
|
centered,
|
|
@@ -26,15 +22,16 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
26
22
|
const {
|
|
27
23
|
direction
|
|
28
24
|
} = useContext(TabContext);
|
|
25
|
+
if (!reference) reference = useRef(null);
|
|
29
26
|
const ref = useRef(null);
|
|
30
27
|
const [scrollLeft, setScrollLeft] = useState(0);
|
|
31
28
|
const isVertical = direction === 'vertical';
|
|
32
29
|
let showScrollLeftButton = !isVertical && scrollLeft > 0;
|
|
33
30
|
let showScrollRightButton = !isVertical && (ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.offsetWidth) + scrollLeft < (ref === null || ref === void 0 ? void 0 : (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.scrollWidth);
|
|
34
31
|
const _ContainerCSS = ContainerCSS(centered, isVertical, width);
|
|
35
|
-
const _TabHeaderCSS = TabHeaderCSS(
|
|
36
|
-
const
|
|
37
|
-
const
|
|
32
|
+
const _TabHeaderCSS = TabHeaderCSS(width);
|
|
33
|
+
const ScrollLeftButtonCSS = ScrollButtonCSS(true, showScrollLeftButton, showScrollRightButton);
|
|
34
|
+
const ScrollRightButtonCSS = ScrollButtonCSS(false, showScrollLeftButton, showScrollRightButton);
|
|
38
35
|
const _onClickScrollButton = scrollPrevious => {
|
|
39
36
|
let scrollValue = scrollPrevious ? ref.current.scrollLeft - (ref.current.offsetWidth + 30) : ref.current.scrollLeft + (ref.current.offsetWidth + 30);
|
|
40
37
|
ref.current.scrollLeft = scrollValue;
|
|
@@ -58,7 +55,7 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
58
55
|
style: style,
|
|
59
56
|
...props
|
|
60
57
|
}, scrollButtons && !isVertical && jsx(ButtonIcon, {
|
|
61
|
-
css:
|
|
58
|
+
css: ScrollLeftButtonCSS,
|
|
62
59
|
name: isVertical ? 'ArrowUp' : 'ArrowLeft',
|
|
63
60
|
viewType: 'text',
|
|
64
61
|
size: 'tiny',
|
|
@@ -66,7 +63,7 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
66
63
|
disabled: !showScrollLeftButton,
|
|
67
64
|
onClick: () => _onClickScrollButton(true)
|
|
68
65
|
}), jsx("div", {
|
|
69
|
-
css: _TabHeaderCSS,
|
|
66
|
+
css: [_TabHeaderCSS, !isVertical && TabHeaderHorizontalCSS],
|
|
70
67
|
className: 'DGN-UI-Tab-Header',
|
|
71
68
|
ref: ref,
|
|
72
69
|
onScroll: e => {
|
|
@@ -76,7 +73,7 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
76
73
|
}, React.Children.map(children, child => child && /*#__PURE__*/React.cloneElement(child, {
|
|
77
74
|
level
|
|
78
75
|
}))), scrollButtons && !isVertical && jsx(ButtonIcon, {
|
|
79
|
-
css:
|
|
76
|
+
css: ScrollRightButtonCSS,
|
|
80
77
|
name: isVertical ? 'ArrowDown' : 'ArrowRight',
|
|
81
78
|
viewType: 'text',
|
|
82
79
|
size: 'tiny',
|
|
@@ -87,45 +84,41 @@ const TabHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
87
84
|
}, [centered, children, className, level, props, scrollButtons, style, width, direction, isVertical, scrollLeft]);
|
|
88
85
|
}));
|
|
89
86
|
const ContainerCSS = (centered, isVertical, width) => css`
|
|
90
|
-
${
|
|
87
|
+
${displayFlex};
|
|
91
88
|
${overflowHidden};
|
|
92
89
|
${positionRelative};
|
|
93
90
|
${boxBorder};
|
|
94
91
|
${parseWidthHeight(width, 'auto')};
|
|
95
92
|
${centered && justifyCenter};
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
${isVertical ? flexCol : flexRow};
|
|
94
|
+
${parseMaxWidth(isVertical ? 'max-content' : '100%')};
|
|
95
|
+
${pd(0)};
|
|
99
96
|
`;
|
|
100
|
-
const TabHeaderCSS =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
97
|
+
const TabHeaderCSS = width => css`
|
|
98
|
+
${displayFlex};
|
|
99
|
+
${flexCol};
|
|
100
|
+
${parseWidth(width)};
|
|
101
|
+
`;
|
|
102
|
+
const TabHeaderHorizontalCSS = css`
|
|
103
|
+
${flexRow};
|
|
104
|
+
${positionRelative};
|
|
105
|
+
${whiteSpaceNoWrap};
|
|
106
|
+
${mg(0)};
|
|
107
|
+
overflow-x: auto;
|
|
108
|
+
scroll-behavior: smooth;
|
|
109
|
+
scroll-snap-type: x mandatory;
|
|
110
|
+
scroll-padding: 50%;
|
|
111
|
+
transition: 0.3s ease-in-out 0.3s;
|
|
112
|
+
&::-webkit-scrollbar {
|
|
113
|
+
${displayNone};
|
|
114
|
+
}
|
|
115
|
+
`;
|
|
116
|
+
const ScrollButtonCSS = (scrollPrevious, showScrollLeftButton, showScrollRightButton) => css`
|
|
119
117
|
${parseWidthHeight(24, 24)};
|
|
118
|
+
${selfCenter};
|
|
119
|
+
${mg(scrollPrevious ? [0, 2, 0, 0] : [0, 0, 0, 2])}
|
|
120
120
|
overflow: initial;
|
|
121
|
-
align-self: center;
|
|
122
|
-
margin: ${scrollPrevious ? spacing([0, 2, 0, 0]) : spacing([0, 0, 0, 2])};
|
|
123
121
|
opacity: ${scrollPrevious && showScrollLeftButton || !scrollPrevious && showScrollRightButton ? '1' : '0'};
|
|
124
|
-
:disabled {
|
|
125
|
-
span {
|
|
126
|
-
cursor: default !important;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
122
|
`;
|
|
130
123
|
TabHeader.defaultProps = {
|
|
131
124
|
centered: false,
|
|
@@ -149,8 +142,8 @@ TabHeader.propTypes = {
|
|
|
149
142
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
150
143
|
/** Any props else. */
|
|
151
144
|
props: PropTypes.any,
|
|
152
|
-
/**
|
|
153
|
-
* Ref methods.
|
|
145
|
+
/**
|
|
146
|
+
* Ref methods.
|
|
154
147
|
*/
|
|
155
148
|
reference: ref
|
|
156
149
|
};
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import { jsx, css } from '@emotion/core';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
7
|
-
import { boxBorder, displayNone, flexCol, parseWidthHeight, positionRelative } from "../../styles/general";
|
|
8
|
-
import theme from "../../theme/settings";
|
|
5
|
+
import { forwardRef, memo, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { boxBorder, displayFlex, displayNone, flexCol, parseWidthHeight, pd, positionRelative, textColor } from "../../styles/general";
|
|
9
7
|
import { classNames, refType as ref } from "../../utils";
|
|
10
|
-
|
|
11
|
-
colors: {
|
|
12
|
-
text: {
|
|
13
|
-
main
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
spacing
|
|
17
|
-
} = theme;
|
|
8
|
+
import TabContext from "./context";
|
|
18
9
|
const TabPanel = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
19
10
|
action = {},
|
|
20
11
|
children,
|
|
@@ -28,6 +19,7 @@ const TabPanel = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
28
19
|
tabIndexState,
|
|
29
20
|
direction
|
|
30
21
|
} = useContext(TabContext);
|
|
22
|
+
if (!reference) reference = useRef(null);
|
|
31
23
|
const [isRendered, setIsRendered] = useState(false);
|
|
32
24
|
const ref = useRef(null);
|
|
33
25
|
const isVertical = direction === 'vertical';
|
|
@@ -60,13 +52,14 @@ const TabPanel = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
60
52
|
}, [children, className, index, lazyLoading, props, style, isActive, isRendered, tabIndexState]);
|
|
61
53
|
}));
|
|
62
54
|
const TabPanelCSS = (isVertical, isActive) => css`
|
|
55
|
+
${displayFlex};
|
|
63
56
|
${flexCol};
|
|
64
57
|
${boxBorder};
|
|
65
58
|
${positionRelative};
|
|
66
59
|
${isActive ? flexCol : displayNone};
|
|
67
|
-
${parseWidthHeight('100%', isVertical ? 300 : '100%')}
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
${parseWidthHeight('100%', isVertical ? 300 : '100%')};
|
|
61
|
+
${textColor('text.main')};
|
|
62
|
+
${pd([0, isVertical ? 3 : 2.5])};
|
|
70
63
|
`;
|
|
71
64
|
TabPanel.defaultProps = {
|
|
72
65
|
className: '',
|
|
@@ -86,8 +79,8 @@ TabPanel.propTypes = {
|
|
|
86
79
|
style: PropTypes.object,
|
|
87
80
|
/** Any props else. */
|
|
88
81
|
props: PropTypes.any,
|
|
89
|
-
/**
|
|
90
|
-
* Ref methods.
|
|
82
|
+
/**
|
|
83
|
+
* Ref methods.
|
|
91
84
|
*/
|
|
92
85
|
reference: ref
|
|
93
86
|
};
|
package/components/tab/tab.js
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
/** @jsx jsx */
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import Icon from "../../icons";
|
|
7
|
-
import { useTheme, useColor as colors } from "../../theme";
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import { Icon, Typography } from "./..";
|
|
8
5
|
import Ripple from "../button/ripple-effect";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { forwardRef, memo, useContext, useImperativeHandle, useMemo, useRef } from 'react';
|
|
8
|
+
import { bgColor, bgTransparent, borderRadius, boxBorder, breakWord, cursorDefault, cursorPointer, displayFlex, flexRow, itemsCenter, justifyCenter, justifyStart, mgl, mgr, outlineNone, overflowHidden, parseHeight, parseMaxWidth, parseMaxWidthHeight, parseMinWidth, parseWidth, pd, pointerEventsAuto, pointerEventsNone, positionAbsolute, positionRelative, shadowNone, textCenter, textColor, userSelectNone, whiteSpaceNoWrap } from "../../styles/general";
|
|
12
9
|
import { classNames, refType as ref } from "../../utils";
|
|
13
|
-
|
|
14
|
-
colors: {
|
|
15
|
-
system: {
|
|
16
|
-
active,
|
|
17
|
-
disabled: systemDisabled,
|
|
18
|
-
rest,
|
|
19
|
-
white
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
spacing
|
|
23
|
-
} = useTheme();
|
|
10
|
+
import TabContext from "./context";
|
|
24
11
|
const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
25
12
|
action = {},
|
|
26
13
|
children,
|
|
@@ -42,13 +29,16 @@ const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
42
29
|
setTabIndexState,
|
|
43
30
|
direction
|
|
44
31
|
} = useContext(TabContext);
|
|
32
|
+
if (!reference) reference = useRef(null);
|
|
45
33
|
const ref = useRef(null);
|
|
34
|
+
const rippleRef = useRef(null);
|
|
46
35
|
const isVertical = direction === 'vertical';
|
|
47
|
-
const
|
|
36
|
+
const _TabItemCSS = TabItemCSS(color, isVertical);
|
|
48
37
|
const _IndicatorCSS = IndicatorCSS(isVertical);
|
|
49
|
-
const _onClick =
|
|
38
|
+
const _onClick = e => {
|
|
50
39
|
if (disabled) return;
|
|
51
|
-
|
|
40
|
+
rippleRef.current.start(e);
|
|
41
|
+
onClick ? onClick(e, index) : setTabIndexState(index);
|
|
52
42
|
};
|
|
53
43
|
useImperativeHandle(reference, () => {
|
|
54
44
|
const currentRef = ref.current || {};
|
|
@@ -60,50 +50,44 @@ const TabItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
60
50
|
currentRef.instance = _instance;
|
|
61
51
|
return currentRef;
|
|
62
52
|
});
|
|
63
|
-
const
|
|
64
|
-
let node =
|
|
65
|
-
if (typeof node === 'string') {
|
|
66
|
-
node = jsx(Icon, {
|
|
67
|
-
color: 'currentColor',
|
|
68
|
-
name: startIcon
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return jsx("span", {
|
|
72
|
-
css: ButtonIconCSS
|
|
73
|
-
}, " ", node, " ");
|
|
74
|
-
}, [startIcon]);
|
|
75
|
-
const EndIcon = useMemo(() => {
|
|
76
|
-
let node = endIcon;
|
|
53
|
+
const renderIcon = (icon, isEndIcon) => {
|
|
54
|
+
let node = icon;
|
|
77
55
|
if (typeof node === 'string') {
|
|
78
56
|
node = jsx(Icon, {
|
|
79
57
|
color: 'currentColor',
|
|
80
|
-
name:
|
|
58
|
+
name: icon
|
|
81
59
|
});
|
|
82
60
|
}
|
|
83
61
|
return jsx("span", {
|
|
84
|
-
css:
|
|
85
|
-
className: 'end-icon'
|
|
86
|
-
},
|
|
87
|
-
}
|
|
62
|
+
css: IconCSS,
|
|
63
|
+
className: isEndIcon ? 'end-icon' : ''
|
|
64
|
+
}, node);
|
|
65
|
+
};
|
|
88
66
|
return useMemo(() => {
|
|
89
67
|
return jsx("div", {
|
|
90
|
-
css:
|
|
68
|
+
css: [_TabItemCSS, disabled && TabItemDisabledCSS, index === tabIndexState && !disabled && TabItemSelectedCSS],
|
|
91
69
|
ref: ref,
|
|
92
70
|
className: classNames('DGN-UI-Tab-Item', disabled && 'disabled', index === tabIndexState && !disabled && 'selected', className),
|
|
93
71
|
style: style,
|
|
94
72
|
onClick: _onClick,
|
|
95
73
|
...props
|
|
96
|
-
}, startIcon &&
|
|
97
|
-
...labelProps,
|
|
74
|
+
}, startIcon && renderIcon(startIcon), jsx(Typography, {
|
|
98
75
|
type: level,
|
|
99
|
-
color: 'inherit'
|
|
100
|
-
|
|
76
|
+
color: 'inherit',
|
|
77
|
+
lineClamp: 1,
|
|
78
|
+
hoverTooltip: true,
|
|
79
|
+
...labelProps
|
|
80
|
+
}, label), children, endIcon && renderIcon(endIcon, true), jsx(Ripple, {
|
|
81
|
+
ref: rippleRef,
|
|
82
|
+
css: pointerEventsNone
|
|
83
|
+
}), jsx("span", {
|
|
101
84
|
css: _IndicatorCSS,
|
|
102
85
|
className: 'Indicator'
|
|
103
86
|
}));
|
|
104
87
|
}, [children, className, color, disabled, endIcon, index, label, labelProps, level, onClick, props, startIcon, style, isVertical, tabIndexState]);
|
|
105
88
|
}));
|
|
106
|
-
const
|
|
89
|
+
const TabItemCSS = (color, isVertical) => css`
|
|
90
|
+
${displayFlex};
|
|
107
91
|
${flexRow};
|
|
108
92
|
${overflowHidden};
|
|
109
93
|
${itemsCenter};
|
|
@@ -116,65 +100,66 @@ const TabButtonCSS = (color, isVertical) => css`
|
|
|
116
100
|
${whiteSpaceNoWrap};
|
|
117
101
|
${shadowNone};
|
|
118
102
|
${!isVertical && textCenter};
|
|
103
|
+
${bgColor('system.white')};
|
|
104
|
+
${textColor(color)};
|
|
105
|
+
${parseMinWidth(80)};
|
|
106
|
+
${parseMaxWidth(isVertical ? '100%' : 287)};
|
|
107
|
+
${pd(isVertical ? [3.5, 4] : [2, 4])}
|
|
108
|
+
${pointerEventsAuto};
|
|
109
|
+
${userSelectNone};
|
|
119
110
|
flex: 0 0 auto;
|
|
120
|
-
background-color: ${white};
|
|
121
111
|
border: 0;
|
|
122
|
-
color: ${colors[color] || color || rest};
|
|
123
|
-
max-width: ${isVertical ? '100%' : '287px'};
|
|
124
|
-
min-width: 80px;
|
|
125
|
-
padding: ${isVertical ? spacing([3.5, 4]) : spacing([2.5, 4])};
|
|
126
|
-
pointer-events: auto;
|
|
127
112
|
transition: all 0.2s ease-in-out, background-color 0.2s ease-in-out;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
${
|
|
131
|
-
${
|
|
132
|
-
color: ${systemDisabled};
|
|
133
|
-
}
|
|
134
|
-
:hover,
|
|
135
|
-
:focus:not(.selected):not(:disabled) {
|
|
136
|
-
background-color: ${white};
|
|
137
|
-
color: ${rest};
|
|
113
|
+
:hover:not(.selected):not(.disabled),
|
|
114
|
+
:focus {
|
|
115
|
+
${bgColor('system.white')};
|
|
116
|
+
${textColor('system.rest')};
|
|
138
117
|
.Indicator {
|
|
139
|
-
|
|
118
|
+
${bgColor('system.rest')};
|
|
140
119
|
transform: scale(1);
|
|
141
120
|
}
|
|
142
121
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
122
|
+
`;
|
|
123
|
+
const TabItemDisabledCSS = css`
|
|
124
|
+
${pointerEventsNone};
|
|
125
|
+
${bgTransparent};
|
|
126
|
+
${cursorDefault};
|
|
127
|
+
${textColor('system.disabled')};
|
|
128
|
+
`;
|
|
129
|
+
const TabItemSelectedCSS = css`
|
|
130
|
+
${bgColor('system.white')};
|
|
131
|
+
${textColor('system.active')};
|
|
132
|
+
.Indicator {
|
|
133
|
+
${bgColor('system.active')};
|
|
134
|
+
transform: scale(1);
|
|
150
135
|
}
|
|
151
136
|
`;
|
|
152
137
|
const IndicatorCSS = isVertical => css`
|
|
153
138
|
${positionAbsolute};
|
|
154
|
-
|
|
155
|
-
|
|
139
|
+
${parseHeight(isVertical ? '100%' : 4)};
|
|
140
|
+
${parseWidth(isVertical ? 4 : '100%')}
|
|
141
|
+
${borderRadius(1)};
|
|
156
142
|
bottom: 0;
|
|
157
143
|
left: 0;
|
|
158
144
|
transform: ${isVertical ? 'scaleY(0)' : 'scaleX(0)'};
|
|
159
145
|
transition: transform 0.2s ease-in-out;
|
|
160
|
-
border-radius: 1px;
|
|
161
146
|
`;
|
|
162
|
-
const
|
|
147
|
+
const IconCSS = css`
|
|
163
148
|
${flexRow};
|
|
164
149
|
${itemsCenter};
|
|
165
150
|
${justifyCenter};
|
|
166
151
|
${positionRelative};
|
|
167
152
|
${boxBorder};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
margin-right: ${spacing([1])};
|
|
153
|
+
${parseMaxWidthHeight(24)};
|
|
154
|
+
${mgr([1])};
|
|
171
155
|
&.end-icon {
|
|
172
|
-
|
|
173
|
-
|
|
156
|
+
${mgr('unset')};
|
|
157
|
+
${mgl([1])};
|
|
174
158
|
}
|
|
175
159
|
`;
|
|
176
160
|
TabItem.defaultProps = {
|
|
177
161
|
className: '',
|
|
162
|
+
color: 'system.rest',
|
|
178
163
|
disabled: false,
|
|
179
164
|
label: '',
|
|
180
165
|
style: {}
|
|
@@ -416,9 +416,9 @@ Transfer.propTypes = {
|
|
|
416
416
|
height: oneOfType([string, number]),
|
|
417
417
|
/** field name used for icon display */
|
|
418
418
|
iconExpr: string,
|
|
419
|
-
/** field name used for text display<br/>
|
|
420
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
421
|
-
* Note: don't use 'id - name', return undefined
|
|
419
|
+
/** field name used for text display<br/>
|
|
420
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
421
|
+
* Note: don't use 'id - name', return undefined
|
|
422
422
|
*/
|
|
423
423
|
displayExpr: oneOfType([string, array]),
|
|
424
424
|
/** display header to select all choices if true */
|
package/package.json
CHANGED
package/styles/general.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { css } from '@emotion/core';
|
|
2
|
+
import { handleBreakpoints } from "../../utils";
|
|
3
|
+
const cssKeyMap = new Map([['display', 'display']]);
|
|
4
|
+
const sx = prop => {
|
|
5
|
+
if (typeof prop !== 'object' || Array.isArray(prop) || prop === null) return null;
|
|
6
|
+
let sxStyleCSS = '';
|
|
7
|
+
Object.keys(prop).forEach(key => {
|
|
8
|
+
const cssKey = cssKeyMap.get(key);
|
|
9
|
+
if (!cssKey) return null;
|
|
10
|
+
sxStyleCSS += handleBreakpoints(prop[key], propValue => {
|
|
11
|
+
if (propValue) {
|
|
12
|
+
return `
|
|
13
|
+
${cssKey}: ${propValue};
|
|
14
|
+
`;
|
|
15
|
+
}
|
|
16
|
+
return '';
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
return css`
|
|
20
|
+
${sxStyleCSS}
|
|
21
|
+
`;
|
|
22
|
+
};
|
|
23
|
+
export default sx;
|