@mackin.com/styleguide 10.0.0 → 10.0.2
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/index.d.ts +12 -27
- package/index.esm.js +181 -207
- package/index.js +181 -207
- package/package.json +5 -5
package/index.esm.js
CHANGED
|
@@ -335,18 +335,18 @@ const Button = React.forwardRef((props, ref) => {
|
|
|
335
335
|
`;
|
|
336
336
|
const styles = css `
|
|
337
337
|
${buttonStyles}
|
|
338
|
-
${
|
|
338
|
+
${variant === 'circle' && `
|
|
339
339
|
width: ${theme.controls.height};
|
|
340
340
|
border-radius: 100%;
|
|
341
341
|
display: flex;
|
|
342
342
|
justify-content: center;
|
|
343
343
|
align-items: center;
|
|
344
|
-
${
|
|
344
|
+
${small && `
|
|
345
345
|
width: ${theme.controls.heightSmall};
|
|
346
346
|
min-width: ${theme.controls.heightSmall};
|
|
347
347
|
`}
|
|
348
348
|
`}
|
|
349
|
-
${
|
|
349
|
+
${variant === 'icon' && `
|
|
350
350
|
width: ${theme.controls.height};
|
|
351
351
|
border-radius: 100%;
|
|
352
352
|
padding: 0;
|
|
@@ -360,13 +360,13 @@ const Button = React.forwardRef((props, ref) => {
|
|
|
360
360
|
&:hover:not(:disabled) {
|
|
361
361
|
background-color: ${theme.controls.hoverBackground};
|
|
362
362
|
}
|
|
363
|
-
${
|
|
363
|
+
${small && `
|
|
364
364
|
width: ${theme.controls.heightSmall};
|
|
365
365
|
min-width: ${theme.controls.heightSmall};
|
|
366
366
|
font-size: 1.3rem;
|
|
367
367
|
`}
|
|
368
368
|
`}
|
|
369
|
-
${(
|
|
369
|
+
${(variant === 'label') && `
|
|
370
370
|
display: inline-block;
|
|
371
371
|
width: auto;
|
|
372
372
|
box-shadow: none;
|
|
@@ -376,7 +376,7 @@ const Button = React.forwardRef((props, ref) => {
|
|
|
376
376
|
background-color: ${theme.controls.hoverBackground};
|
|
377
377
|
}
|
|
378
378
|
`}
|
|
379
|
-
${(
|
|
379
|
+
${(variant === 'text') && `
|
|
380
380
|
background-color: transparent;
|
|
381
381
|
font-weight: normal;
|
|
382
382
|
cursor: auto;
|
|
@@ -389,7 +389,7 @@ const Button = React.forwardRef((props, ref) => {
|
|
|
389
389
|
filter: none;
|
|
390
390
|
}
|
|
391
391
|
`}
|
|
392
|
-
${
|
|
392
|
+
${variant === 'link' && `
|
|
393
393
|
padding: 0;
|
|
394
394
|
display: inline-block;
|
|
395
395
|
width: auto;
|
|
@@ -406,7 +406,7 @@ const Button = React.forwardRef((props, ref) => {
|
|
|
406
406
|
text-decoration: underline;
|
|
407
407
|
}
|
|
408
408
|
`}
|
|
409
|
-
${
|
|
409
|
+
${variant === 'inlineLink' && `
|
|
410
410
|
padding: 0;
|
|
411
411
|
display: inline-block;
|
|
412
412
|
width: auto;
|
|
@@ -424,34 +424,34 @@ const Button = React.forwardRef((props, ref) => {
|
|
|
424
424
|
text-decoration: underline;
|
|
425
425
|
}
|
|
426
426
|
`}
|
|
427
|
-
${
|
|
427
|
+
${variant === 'primary' && `
|
|
428
428
|
background-color: ${theme.colors.primary};
|
|
429
429
|
color: ${theme.colors.primaryFont};
|
|
430
430
|
`}
|
|
431
|
-
${
|
|
431
|
+
${variant === 'primary2' && `
|
|
432
432
|
background-color: ${theme.colors.primary2};
|
|
433
433
|
color: ${theme.colors.primary2Font};
|
|
434
434
|
`}
|
|
435
|
-
${
|
|
435
|
+
${variant === 'secondary' && `
|
|
436
436
|
background-color: ${theme.colors.secondary};
|
|
437
437
|
color: ${theme.colors.secondary2Font};
|
|
438
438
|
`}
|
|
439
|
-
${
|
|
439
|
+
${variant === 'omg' && `
|
|
440
440
|
background-color: ${theme.colors.omg};
|
|
441
441
|
color: ${theme.colors.omgFont};
|
|
442
442
|
`}
|
|
443
|
-
${
|
|
443
|
+
${variant === 'positive' && `
|
|
444
444
|
background-color: ${theme.colors.positive};
|
|
445
445
|
color: ${theme.colors.positiveFont};
|
|
446
446
|
`}
|
|
447
|
-
${
|
|
447
|
+
${variant === 'negative' && `
|
|
448
448
|
background-color: ${theme.colors.negative};
|
|
449
449
|
color: ${theme.colors.negativeFont};
|
|
450
450
|
`}
|
|
451
|
-
${
|
|
451
|
+
${enforceMinWidth && `
|
|
452
452
|
min-width: ${theme.controls.formButtonMinWidth};
|
|
453
453
|
`}
|
|
454
|
-
${
|
|
454
|
+
${readOnly && `
|
|
455
455
|
cursor: default;
|
|
456
456
|
box-shadow: none;
|
|
457
457
|
pointer-events:none;
|
|
@@ -464,31 +464,31 @@ const Button = React.forwardRef((props, ref) => {
|
|
|
464
464
|
box-shadow: none;
|
|
465
465
|
}
|
|
466
466
|
`}
|
|
467
|
-
${
|
|
467
|
+
${small && `
|
|
468
468
|
font-size: 0.8rem;
|
|
469
469
|
height:${theme.controls.heightSmall};
|
|
470
470
|
`}
|
|
471
|
-
${
|
|
471
|
+
${round && `
|
|
472
472
|
border-radius: ${theme.controls.roundRadius};
|
|
473
473
|
`}
|
|
474
|
-
${
|
|
474
|
+
${iconBlock && `
|
|
475
475
|
display: flex;
|
|
476
476
|
justify-content: space-between;
|
|
477
477
|
align-items: center;
|
|
478
478
|
`}
|
|
479
479
|
`;
|
|
480
|
-
const disabled = props.disabled ||
|
|
480
|
+
const disabled = props.disabled || waiting;
|
|
481
481
|
let content;
|
|
482
482
|
if (variant === 'text') {
|
|
483
483
|
content = React.createElement(Text, { className: cx(styles, props.className), tag: "div" }, props.children);
|
|
484
484
|
}
|
|
485
485
|
else {
|
|
486
486
|
content = (React.createElement("button", Object.assign({}, nativeProps, { ref: ref, disabled: disabled, className: cx('button', styles, props.className), type: (_a = props.type) !== null && _a !== void 0 ? _a : 'button' }),
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
leftIcon && React.createElement("span", { className: css({ marginRight: '0.5rem' }) }, leftIcon),
|
|
488
|
+
waiting ? React.createElement(Icon, { id: "waiting", spin: true }) : props.children,
|
|
489
|
+
rightIcon && React.createElement("span", { className: css({ marginLeft: '0.5rem' }) }, rightIcon)));
|
|
490
490
|
}
|
|
491
|
-
if (
|
|
491
|
+
if (controlAlign) {
|
|
492
492
|
return (React.createElement("span", { className: css({
|
|
493
493
|
display: 'inline-block',
|
|
494
494
|
paddingBottom: theme.controls.inputErrorMinHeight
|
|
@@ -592,7 +592,7 @@ const InputErrorDisplay = (props) => {
|
|
|
592
592
|
|
|
593
593
|
const defaultMaxLength$1 = 100;
|
|
594
594
|
const BaseInput = React.forwardRef((props, ref) => {
|
|
595
|
-
var _a
|
|
595
|
+
var _a;
|
|
596
596
|
const theme = useThemeSafely();
|
|
597
597
|
const { rightControl, round, wrapperClassName, showErrorDisplay } = props, nativeProps = __rest(props, ["rightControl", "round", "wrapperClassName", "showErrorDisplay"]);
|
|
598
598
|
const inputStyles = css({
|
|
@@ -621,7 +621,7 @@ const BaseInput = React.forwardRef((props, ref) => {
|
|
|
621
621
|
boxShadow: theme.controls.focusOutlineRequiredShadow
|
|
622
622
|
}
|
|
623
623
|
},
|
|
624
|
-
},
|
|
624
|
+
}, round && {
|
|
625
625
|
borderRadius: theme.controls.roundRadius,
|
|
626
626
|
paddingLeft: `calc(${theme.controls.padding} * 2)`,
|
|
627
627
|
paddingRight: `calc(${theme.controls.padding} * 2)`
|
|
@@ -641,24 +641,24 @@ const BaseInput = React.forwardRef((props, ref) => {
|
|
|
641
641
|
'::-webkit-inner-spin-button': {
|
|
642
642
|
appearance: 'none'
|
|
643
643
|
}
|
|
644
|
-
},
|
|
644
|
+
}, rightControl && {
|
|
645
645
|
paddingRight: theme.controls.height
|
|
646
646
|
});
|
|
647
647
|
const inputElement = React.createElement("input", Object.assign({}, nativeProps, { ref: ref, autoComplete: (_a = nativeProps.autoComplete) !== null && _a !== void 0 ? _a : 'off', tabIndex: nativeProps.readOnly ? -1 : nativeProps.tabIndex, maxLength: nativeProps.maxLength || defaultMaxLength$1, className: cx(inputStyles, props.className) }));
|
|
648
648
|
const inputWrapperStyles = css `
|
|
649
649
|
width:100%;
|
|
650
|
-
${
|
|
650
|
+
${rightControl && `
|
|
651
651
|
position: relative;
|
|
652
652
|
`}
|
|
653
653
|
`;
|
|
654
|
-
const rightControlStyles =
|
|
654
|
+
const rightControlStyles = rightControl && css `
|
|
655
655
|
position: absolute;
|
|
656
656
|
right: ${theme.controls.padding};
|
|
657
657
|
top: 0;
|
|
658
658
|
bottom: 0;
|
|
659
659
|
display: flex;
|
|
660
660
|
align-items: center;
|
|
661
|
-
${
|
|
661
|
+
${round && `
|
|
662
662
|
right: calc(${theme.controls.padding} * 2);
|
|
663
663
|
`}
|
|
664
664
|
`;
|
|
@@ -668,8 +668,8 @@ const BaseInput = React.forwardRef((props, ref) => {
|
|
|
668
668
|
}) },
|
|
669
669
|
React.createElement("div", { className: cx('input', inputWrapperStyles, wrapperClassName) },
|
|
670
670
|
inputElement,
|
|
671
|
-
|
|
672
|
-
(
|
|
671
|
+
rightControl && (React.createElement("div", { className: rightControlStyles }, rightControl))),
|
|
672
|
+
(showErrorDisplay !== null && showErrorDisplay !== void 0 ? showErrorDisplay : true) && React.createElement(InputErrorDisplay, { error: props.readOnly ? undefined : props.error })));
|
|
673
673
|
});
|
|
674
674
|
|
|
675
675
|
/** useEffect but ignores the first call on component mount. */
|
|
@@ -816,26 +816,27 @@ const TextInput = React.forwardRef((props, ref) => {
|
|
|
816
816
|
const [localValue, setLocalValue] = React.useState(props.value);
|
|
817
817
|
const inputRef = (ref !== null && ref !== void 0 ? ref : React.useRef(null));
|
|
818
818
|
const [validationError, updateErrorMessage] = useInputValidationMessage(inputRef, props);
|
|
819
|
-
|
|
819
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
820
|
+
const { emptyString, onValueChange, customError, patternErrorMessage, allowUpdateOnFocus } = props, nativeProps = __rest(props, ["emptyString", "onValueChange", "customError", "patternErrorMessage", "allowUpdateOnFocus"]);
|
|
820
821
|
useIgnoreMount(() => {
|
|
821
822
|
var _a;
|
|
822
823
|
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.checkValidity()) {
|
|
823
|
-
|
|
824
|
+
onValueChange(localValue);
|
|
824
825
|
}
|
|
825
826
|
else {
|
|
826
|
-
|
|
827
|
+
onValueChange(undefined);
|
|
827
828
|
}
|
|
828
829
|
updateErrorMessage();
|
|
829
830
|
}, [localValue]);
|
|
830
831
|
useIgnoreMount(() => {
|
|
831
|
-
if (
|
|
832
|
+
if (allowUpdateOnFocus || document.activeElement !== inputRef.current) {
|
|
832
833
|
setLocalValue(props.value);
|
|
833
834
|
}
|
|
834
835
|
updateErrorMessage();
|
|
835
836
|
}, [props.value]);
|
|
836
837
|
return (React.createElement(BaseInput, Object.assign({}, nativeProps, { error: validationError, type: (_a = props.type) !== null && _a !== void 0 ? _a : 'text', ref: inputRef, value: localValue !== null && localValue !== void 0 ? localValue : '', onChange: e => {
|
|
837
838
|
var _a;
|
|
838
|
-
setLocalValue(
|
|
839
|
+
setLocalValue(emptyString ? e.target.value : e.target.value || undefined);
|
|
839
840
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
840
841
|
}, onBlur: e => {
|
|
841
842
|
var _a, _b;
|
|
@@ -852,19 +853,19 @@ const TextInput = React.forwardRef((props, ref) => {
|
|
|
852
853
|
});
|
|
853
854
|
|
|
854
855
|
const List = React.forwardRef((props, ref) => {
|
|
855
|
-
const
|
|
856
|
+
const { altRowColor, noLines, items } = props, listProps = __rest(props, ["altRowColor", "noLines", "items"]);
|
|
857
|
+
const children = items ? items.map((item, i) => React.createElement(ListItem, { key: i }, item)) : props.children;
|
|
856
858
|
const theme = useThemeSafely();
|
|
857
|
-
const listProps = __rest(props, ["altRowColor", "noLines", "items"]);
|
|
858
859
|
const listStyles = css `
|
|
859
860
|
margin: 0;
|
|
860
861
|
padding: 0;
|
|
861
862
|
list-style-type: none;
|
|
862
|
-
${
|
|
863
|
+
${altRowColor && `
|
|
863
864
|
> .listItem:nth-of-type(even) {
|
|
864
865
|
background-color: ${theme.colors.lightBg};
|
|
865
866
|
}
|
|
866
867
|
`}
|
|
867
|
-
${
|
|
868
|
+
${noLines && `
|
|
868
869
|
> .listItem {
|
|
869
870
|
border-bottom: none;
|
|
870
871
|
}
|
|
@@ -873,7 +874,7 @@ const List = React.forwardRef((props, ref) => {
|
|
|
873
874
|
return (React.createElement("ul", Object.assign({}, listProps, { ref: ref, className: cx('list', listStyles, props.className) }), children));
|
|
874
875
|
});
|
|
875
876
|
const ListItem = (props) => {
|
|
876
|
-
const liProps = __rest(props, ["variant", "noContentStyling"]);
|
|
877
|
+
const { variant, noContentStyling } = props, liProps = __rest(props, ["variant", "noContentStyling"]);
|
|
877
878
|
const theme = useThemeSafely();
|
|
878
879
|
const itemStyles = css `
|
|
879
880
|
border-bottom: ${theme.controls.border};
|
|
@@ -883,9 +884,9 @@ const ListItem = (props) => {
|
|
|
883
884
|
`;
|
|
884
885
|
const contentStyle = css({
|
|
885
886
|
padding: `calc(${theme.controls.padding} * 1.5)`
|
|
886
|
-
},
|
|
887
|
+
}, variant === 'full' && {
|
|
887
888
|
padding: 0
|
|
888
|
-
}, !
|
|
889
|
+
}, !noContentStyling && {
|
|
889
890
|
'>.button': {
|
|
890
891
|
padding: `calc(${theme.controls.padding} * 1.5)`,
|
|
891
892
|
width: '100%',
|
|
@@ -945,6 +946,7 @@ const buttonMarkerClass = 'ListItem__button';
|
|
|
945
946
|
const defaultOnPickFocusMs = 100;
|
|
946
947
|
const Autocomplete = (p) => {
|
|
947
948
|
var _a;
|
|
949
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
948
950
|
const inputProps = __rest(p, ["value", "className", "inputWrapperClassName", "inputClassName", "listClassName", "listItemClassName", "listItemButtonClassName", "maxShownValues", "allowScroll", "options", "onPick", "onPickFocusWaitMs"]);
|
|
949
951
|
const theme = useThemeSafely();
|
|
950
952
|
const element = React.useRef(null);
|
|
@@ -1235,7 +1237,7 @@ const BackdropContext = React__default.createContext({
|
|
|
1235
1237
|
showing: false,
|
|
1236
1238
|
showCount: 0,
|
|
1237
1239
|
portalId: portalId,
|
|
1238
|
-
setShow: (
|
|
1240
|
+
setShow: () => {
|
|
1239
1241
|
/* empty */
|
|
1240
1242
|
}
|
|
1241
1243
|
});
|
|
@@ -1423,22 +1425,22 @@ const Calendar = (p) => {
|
|
|
1423
1425
|
};
|
|
1424
1426
|
|
|
1425
1427
|
const Checkbox = (props) => {
|
|
1426
|
-
const inputProps = __rest(props, ["onChange", "label", "checkedIcon", "uncheckedIcon", "checkedThemeColor", "checkedColor", "readOnly"]);
|
|
1427
|
-
const selected =
|
|
1428
|
-
const unselected =
|
|
1428
|
+
const { onChange, label, checkedIcon, uncheckedIcon, checkedThemeColor, checkedColor, readOnly } = props, inputProps = __rest(props, ["onChange", "label", "checkedIcon", "uncheckedIcon", "checkedThemeColor", "checkedColor", "readOnly"]);
|
|
1429
|
+
const selected = checkedIcon || 'selected';
|
|
1430
|
+
const unselected = uncheckedIcon || 'unselected';
|
|
1429
1431
|
const theme = useThemeSafely();
|
|
1430
1432
|
let finalCheckedColor;
|
|
1431
1433
|
if (props.checked) {
|
|
1432
|
-
if (
|
|
1433
|
-
finalCheckedColor = theme.colors[
|
|
1434
|
+
if (checkedThemeColor) {
|
|
1435
|
+
finalCheckedColor = theme.colors[checkedThemeColor];
|
|
1434
1436
|
}
|
|
1435
1437
|
else {
|
|
1436
|
-
finalCheckedColor =
|
|
1438
|
+
finalCheckedColor = checkedColor;
|
|
1437
1439
|
}
|
|
1438
1440
|
}
|
|
1439
1441
|
const checkboxStyles = css `
|
|
1440
1442
|
display: inline-block;
|
|
1441
|
-
${!props.disabled && !
|
|
1443
|
+
${!props.disabled && !readOnly && `
|
|
1442
1444
|
&:hover {
|
|
1443
1445
|
filter: ${theme.controls.hoverBrightness};
|
|
1444
1446
|
}
|
|
@@ -1452,7 +1454,7 @@ const Checkbox = (props) => {
|
|
|
1452
1454
|
${props.disabled && `
|
|
1453
1455
|
cursor: not-allowed;
|
|
1454
1456
|
`}
|
|
1455
|
-
${
|
|
1457
|
+
${readOnly && `
|
|
1456
1458
|
cursor: default;
|
|
1457
1459
|
`}
|
|
1458
1460
|
`;
|
|
@@ -1464,21 +1466,21 @@ const Checkbox = (props) => {
|
|
|
1464
1466
|
width: 0;
|
|
1465
1467
|
opacity: 0;
|
|
1466
1468
|
|
|
1467
|
-
${!
|
|
1469
|
+
${!readOnly && `
|
|
1468
1470
|
&:focus + .checkboxIcon {
|
|
1469
1471
|
box-shadow: ${theme.controls.focusOutlineShadow};
|
|
1470
1472
|
}
|
|
1471
1473
|
`}
|
|
1472
1474
|
`;
|
|
1473
1475
|
const iconStyles = css `
|
|
1474
|
-
${!!
|
|
1476
|
+
${!!label && `
|
|
1475
1477
|
margin-right: 0.5rem;
|
|
1476
1478
|
`}
|
|
1477
1479
|
${props.disabled && `
|
|
1478
1480
|
background-color: ${theme.colors.disabled};
|
|
1479
1481
|
cursor: not-allowed;
|
|
1480
1482
|
`}
|
|
1481
|
-
${
|
|
1483
|
+
${readOnly && `
|
|
1482
1484
|
cursor: default;
|
|
1483
1485
|
`}
|
|
1484
1486
|
${props.checked && `
|
|
@@ -1487,15 +1489,15 @@ const Checkbox = (props) => {
|
|
|
1487
1489
|
`;
|
|
1488
1490
|
return (React.createElement("span", { className: cx('checkbox', checkboxStyles, props.className) },
|
|
1489
1491
|
React.createElement("label", { className: labelStyles },
|
|
1490
|
-
React.createElement("input", Object.assign({}, inputProps, { tabIndex:
|
|
1491
|
-
if (
|
|
1492
|
+
React.createElement("input", Object.assign({}, inputProps, { tabIndex: readOnly ? -1 : undefined, className: nativeCheckboxStyles, type: "checkbox", onChange: e => {
|
|
1493
|
+
if (readOnly) {
|
|
1492
1494
|
e.preventDefault();
|
|
1493
1495
|
return;
|
|
1494
1496
|
}
|
|
1495
|
-
return
|
|
1497
|
+
return onChange(e.currentTarget.checked, e);
|
|
1496
1498
|
} })),
|
|
1497
1499
|
React.createElement(Icon, { className: cx('checkboxIcon', iconStyles), id: props.checked ? selected : unselected }),
|
|
1498
|
-
|
|
1500
|
+
label,
|
|
1499
1501
|
props.children)));
|
|
1500
1502
|
};
|
|
1501
1503
|
|
|
@@ -1693,7 +1695,7 @@ const Modal = (p) => {
|
|
|
1693
1695
|
React__default.createElement("div", { id: p.id, ref: contentRef, onClick: e => e.stopPropagation(), onMouseDown: e => {
|
|
1694
1696
|
mouseDownElement.current = e.target;
|
|
1695
1697
|
e.stopPropagation();
|
|
1696
|
-
}, onMouseUp:
|
|
1698
|
+
}, onMouseUp: () => {
|
|
1697
1699
|
mouseDownElement.current = undefined;
|
|
1698
1700
|
/*
|
|
1699
1701
|
MouseDown and MouseUp stopPropagation was added to fix bugs while clicking within the modal.
|
|
@@ -1739,7 +1741,7 @@ const ConfirmModal = (props) => {
|
|
|
1739
1741
|
};
|
|
1740
1742
|
|
|
1741
1743
|
const CopyButton = React.forwardRef((props, ref) => {
|
|
1742
|
-
const buttonProps = __rest(props, ["selector"]);
|
|
1744
|
+
const { selector } = props, buttonProps = __rest(props, ["selector"]);
|
|
1743
1745
|
const [copied, setCopied] = React.useState(false);
|
|
1744
1746
|
return (React.createElement(Button, Object.assign({}, buttonProps, { ref: ref, title: copied ? 'Copied!' : (props.title || 'Copy to clipboard'), variant: "icon", onBlur: e => {
|
|
1745
1747
|
var _a;
|
|
@@ -1750,7 +1752,7 @@ const CopyButton = React.forwardRef((props, ref) => {
|
|
|
1750
1752
|
const button = e.currentTarget;
|
|
1751
1753
|
let copySuccess = false;
|
|
1752
1754
|
try {
|
|
1753
|
-
const text = document.querySelector(
|
|
1755
|
+
const text = document.querySelector(selector);
|
|
1754
1756
|
text.select();
|
|
1755
1757
|
copySuccess = document.execCommand('copy');
|
|
1756
1758
|
// the input gets focus on select. bring it back.
|
|
@@ -1793,15 +1795,16 @@ const ErrorModal = (props) => {
|
|
|
1793
1795
|
|
|
1794
1796
|
/** Use this instead of <form> directly. If we need to fight Chrome's autofill, we can do so at a global level. */
|
|
1795
1797
|
const Form = React.forwardRef((props, ref) => {
|
|
1798
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1796
1799
|
const { inline, children, onSubmit, className, ajax, unstyled } = props, rest = __rest(props, ["inline", "children", "onSubmit", "className", "ajax", "unstyled"]);
|
|
1797
1800
|
const theme = useThemeSafely();
|
|
1798
1801
|
let defaultStyle;
|
|
1799
|
-
if (!
|
|
1802
|
+
if (!unstyled) {
|
|
1800
1803
|
defaultStyle = css({
|
|
1801
1804
|
label: 'Form',
|
|
1802
1805
|
display: 'flex',
|
|
1803
|
-
flexDirection:
|
|
1804
|
-
alignItems:
|
|
1806
|
+
flexDirection: inline ? 'row' : 'column',
|
|
1807
|
+
alignItems: inline ? 'flex-end' : 'normal',
|
|
1805
1808
|
gap: theme.controls.gap
|
|
1806
1809
|
});
|
|
1807
1810
|
}
|
|
@@ -1988,7 +1991,7 @@ const FileUploader = (p) => {
|
|
|
1988
1991
|
if (!((_a = form.current) === null || _a === void 0 ? void 0 : _a.classList.contains(hoverClass))) {
|
|
1989
1992
|
(_b = form.current) === null || _b === void 0 ? void 0 : _b.classList.add(hoverClass);
|
|
1990
1993
|
}
|
|
1991
|
-
}, onDragLeave:
|
|
1994
|
+
}, onDragLeave: () => {
|
|
1992
1995
|
var _a;
|
|
1993
1996
|
(_a = form.current) === null || _a === void 0 ? void 0 : _a.classList.remove(hoverClass);
|
|
1994
1997
|
}, onDrop: e => {
|
|
@@ -2001,7 +2004,7 @@ const FileUploader = (p) => {
|
|
|
2001
2004
|
return;
|
|
2002
2005
|
}
|
|
2003
2006
|
onFilesChange(e.dataTransfer.files);
|
|
2004
|
-
}, onSubmit:
|
|
2007
|
+
}, onSubmit: () => {
|
|
2005
2008
|
if (!files) {
|
|
2006
2009
|
return;
|
|
2007
2010
|
}
|
|
@@ -2048,7 +2051,7 @@ const FileUploader = (p) => {
|
|
|
2048
2051
|
flexDirection: 'column',
|
|
2049
2052
|
gap: '1rem',
|
|
2050
2053
|
alignItems: 'center',
|
|
2051
|
-
zIndex:
|
|
2054
|
+
zIndex: (files === null || files === void 0 ? void 0 : files.length) ? 1 : undefined
|
|
2052
2055
|
}) },
|
|
2053
2056
|
!(files === null || files === void 0 ? void 0 : files.length) && React__default.createElement(Icon, { style: { fontSize: '2rem' }, id: "upload" }),
|
|
2054
2057
|
React__default.createElement(Text, { align: "center", noPad: true, spacedOut: true, className: css({
|
|
@@ -2179,14 +2182,6 @@ const Header = (props) => {
|
|
|
2179
2182
|
gridAutoFlow: 'column',
|
|
2180
2183
|
alignItems: 'center'
|
|
2181
2184
|
});
|
|
2182
|
-
const centerElementsStyles = props.centerOffsetElements && css `
|
|
2183
|
-
position: absolute;
|
|
2184
|
-
display: flex;
|
|
2185
|
-
justify-content: center;
|
|
2186
|
-
left: 0;
|
|
2187
|
-
right: 0;
|
|
2188
|
-
bottom: calc(${theme.layout.headerHeight} / 2 * -1);
|
|
2189
|
-
`;
|
|
2190
2185
|
let title;
|
|
2191
2186
|
if (props.title) {
|
|
2192
2187
|
if (typeof props.title === 'string') {
|
|
@@ -2206,9 +2201,7 @@ const Header = (props) => {
|
|
|
2206
2201
|
React.createElement(Icon, { id: "menu" }))),
|
|
2207
2202
|
props.leftElements && React.createElement("div", { className: leftElementStyles }, props.leftElements),
|
|
2208
2203
|
title,
|
|
2209
|
-
props.rightElements && React.createElement("div", { className: rightElementStyles }, props.rightElements)
|
|
2210
|
-
props.centerOffsetElements && (React.createElement("div", { className: centerElementsStyles },
|
|
2211
|
-
React.createElement("div", null, props.centerOffsetElements)))));
|
|
2204
|
+
props.rightElements && React.createElement("div", { className: rightElementStyles }, props.rightElements)));
|
|
2212
2205
|
};
|
|
2213
2206
|
|
|
2214
2207
|
const Highlight = (props) => {
|
|
@@ -2277,7 +2270,7 @@ const InfoTip = (props) => {
|
|
|
2277
2270
|
if (props.loadOnHover) {
|
|
2278
2271
|
props.loadOnHover().then(() => {
|
|
2279
2272
|
openTip();
|
|
2280
|
-
}).catch(
|
|
2273
|
+
}).catch(() => {
|
|
2281
2274
|
/* Not my responsiblity. */
|
|
2282
2275
|
});
|
|
2283
2276
|
}
|
|
@@ -2359,7 +2352,7 @@ const DateInput = React.forwardRef((props, ref) => {
|
|
|
2359
2352
|
const updateDateErrorMessages = React.useCallback(() => {
|
|
2360
2353
|
let dateError = '';
|
|
2361
2354
|
if (dateValue === undefined) {
|
|
2362
|
-
if (
|
|
2355
|
+
if (textValue) {
|
|
2363
2356
|
// the text pattern is a valid date format, but the numbers are wrong. example: 05/35/2000.
|
|
2364
2357
|
dateError = invalidDateMessage;
|
|
2365
2358
|
}
|
|
@@ -2397,7 +2390,8 @@ const DateInput = React.forwardRef((props, ref) => {
|
|
|
2397
2390
|
}
|
|
2398
2391
|
}, [dateValue, showCalendar]);
|
|
2399
2392
|
const popover = React.useRef(null);
|
|
2400
|
-
|
|
2393
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2394
|
+
const { customError, reposition, onValueChange, allowUpdateOnFocus, pageYear: showYearControls } = props, nativeProps = __rest(props, ["customError", "reposition", "onValueChange", "allowUpdateOnFocus", "pageYear"]);
|
|
2401
2395
|
useIgnoreMount(() => {
|
|
2402
2396
|
var _a;
|
|
2403
2397
|
/*
|
|
@@ -2406,10 +2400,10 @@ const DateInput = React.forwardRef((props, ref) => {
|
|
|
2406
2400
|
*/
|
|
2407
2401
|
updateDateErrorMessages();
|
|
2408
2402
|
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.checkValidity()) {
|
|
2409
|
-
|
|
2403
|
+
onValueChange(dateValue);
|
|
2410
2404
|
}
|
|
2411
2405
|
else {
|
|
2412
|
-
|
|
2406
|
+
onValueChange(undefined);
|
|
2413
2407
|
}
|
|
2414
2408
|
}, [dateValue]);
|
|
2415
2409
|
useIgnoreMount(() => {
|
|
@@ -2417,7 +2411,7 @@ const DateInput = React.forwardRef((props, ref) => {
|
|
|
2417
2411
|
}, [textValue]);
|
|
2418
2412
|
useIgnoreMount(() => {
|
|
2419
2413
|
var _a;
|
|
2420
|
-
if (
|
|
2414
|
+
if (allowUpdateOnFocus || document.activeElement !== inputRef.current) {
|
|
2421
2415
|
updateValues(props.value);
|
|
2422
2416
|
setCalendarDate(getCalendarDate((_a = props.value) !== null && _a !== void 0 ? _a : 0, props.min, props.max));
|
|
2423
2417
|
}
|
|
@@ -2459,7 +2453,7 @@ const DateInput = React.forwardRef((props, ref) => {
|
|
|
2459
2453
|
}
|
|
2460
2454
|
(_b = props.onBlur) === null || _b === void 0 ? void 0 : _b.call(props, e);
|
|
2461
2455
|
} })));
|
|
2462
|
-
return (React.createElement(Popover, { reposition:
|
|
2456
|
+
return (React.createElement(Popover, { reposition: reposition, isOpen: showCalendar, onClickOutside: () => {
|
|
2463
2457
|
toggleCalendar(false);
|
|
2464
2458
|
}, parent: input, content: (React.createElement("div", { ref: popover, className: css({
|
|
2465
2459
|
paddingLeft: '1rem',
|
|
@@ -2525,19 +2519,20 @@ const NumberInput = React.forwardRef((props, ref) => {
|
|
|
2525
2519
|
const [localValue, setLocalValue] = React.useState(props.value);
|
|
2526
2520
|
const inputRef = (ref !== null && ref !== void 0 ? ref : React.useRef(null));
|
|
2527
2521
|
const [validationError, updateErrorMessage] = useInputValidationMessage(inputRef, props);
|
|
2528
|
-
|
|
2522
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2523
|
+
const { customError, onValueChange, allowUpdateOnFocus } = props, nativeProps = __rest(props, ["customError", "onValueChange", "allowUpdateOnFocus"]);
|
|
2529
2524
|
useIgnoreMount(() => {
|
|
2530
2525
|
var _a;
|
|
2531
2526
|
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.checkValidity()) {
|
|
2532
|
-
|
|
2527
|
+
onValueChange(localValue);
|
|
2533
2528
|
}
|
|
2534
2529
|
else {
|
|
2535
|
-
|
|
2530
|
+
onValueChange(undefined);
|
|
2536
2531
|
}
|
|
2537
2532
|
updateErrorMessage();
|
|
2538
2533
|
}, [localValue]);
|
|
2539
2534
|
useIgnoreMount(() => {
|
|
2540
|
-
if (
|
|
2535
|
+
if (allowUpdateOnFocus || document.activeElement !== inputRef.current) {
|
|
2541
2536
|
setLocalValue(props.value);
|
|
2542
2537
|
}
|
|
2543
2538
|
updateErrorMessage();
|
|
@@ -2578,11 +2573,11 @@ const parseNumber = (rawValue) => {
|
|
|
2578
2573
|
};
|
|
2579
2574
|
|
|
2580
2575
|
const Label = (props) => {
|
|
2581
|
-
var _a
|
|
2582
|
-
const labelProps = __rest(props, ["text", "static", "orientation", "align", "noWrap", "subText", "optional", "controlAlign"]);
|
|
2576
|
+
var _a;
|
|
2577
|
+
const { text, static: propsStatic, orientation, align, noWrap, subText, optional, controlAlign } = props, labelProps = __rest(props, ["text", "static", "orientation", "align", "noWrap", "subText", "optional", "controlAlign"]);
|
|
2583
2578
|
const theme = useThemeSafely();
|
|
2584
|
-
const orientationChoice =
|
|
2585
|
-
const alignChoice =
|
|
2579
|
+
const orientationChoice = orientation !== null && orientation !== void 0 ? orientation : 'vertical';
|
|
2580
|
+
const alignChoice = align !== null && align !== void 0 ? align : 'left';
|
|
2586
2581
|
const padding = '0.25rem';
|
|
2587
2582
|
const labelStyles = css `
|
|
2588
2583
|
label: Label;
|
|
@@ -2609,14 +2604,14 @@ const Label = (props) => {
|
|
|
2609
2604
|
${orientationChoice === 'horizontal' && `
|
|
2610
2605
|
flex-direction: row;
|
|
2611
2606
|
margin-right:${padding};
|
|
2612
|
-
${
|
|
2607
|
+
${propsStatic && `
|
|
2613
2608
|
margin-right:0.5rem;
|
|
2614
2609
|
`}
|
|
2615
2610
|
`}
|
|
2616
2611
|
${orientationChoice === 'horizontalReverse' && `
|
|
2617
2612
|
margin-left:${padding};
|
|
2618
2613
|
`}
|
|
2619
|
-
${(
|
|
2614
|
+
${(subText || optional) && `
|
|
2620
2615
|
margin-right: 0.5rem;
|
|
2621
2616
|
`}
|
|
2622
2617
|
`;
|
|
@@ -2624,23 +2619,23 @@ const Label = (props) => {
|
|
|
2624
2619
|
label: LabelContent;
|
|
2625
2620
|
display:inline-block;
|
|
2626
2621
|
width:100%;
|
|
2627
|
-
${
|
|
2622
|
+
${controlAlign && `
|
|
2628
2623
|
height:${theme.controls.height};
|
|
2629
2624
|
line-height:${theme.controls.height};
|
|
2630
2625
|
`}
|
|
2631
2626
|
`;
|
|
2632
2627
|
const outerClass = props.className;
|
|
2633
|
-
let labelText = React.createElement(Text, { align: alignChoice, className: labelTextStyles, tag: "div", bold: true },
|
|
2628
|
+
let labelText = React.createElement(Text, { align: alignChoice, className: labelTextStyles, tag: "div", bold: true }, text);
|
|
2634
2629
|
let subTextChoice;
|
|
2635
|
-
if (
|
|
2636
|
-
if (typeof
|
|
2637
|
-
subTextChoice = React.createElement(Text, { tag: "div" },
|
|
2630
|
+
if (subText) {
|
|
2631
|
+
if (typeof subText === 'string') {
|
|
2632
|
+
subTextChoice = React.createElement(Text, { tag: "div" }, subText);
|
|
2638
2633
|
}
|
|
2639
2634
|
else {
|
|
2640
|
-
subTextChoice =
|
|
2635
|
+
subTextChoice = subText;
|
|
2641
2636
|
}
|
|
2642
2637
|
}
|
|
2643
|
-
else if (
|
|
2638
|
+
else if (optional) {
|
|
2644
2639
|
subTextChoice = React.createElement(Text, { tag: "div" },
|
|
2645
2640
|
React.createElement("em", null, "(optional)"));
|
|
2646
2641
|
}
|
|
@@ -2652,7 +2647,7 @@ const Label = (props) => {
|
|
|
2652
2647
|
marginBottom: padding
|
|
2653
2648
|
}) }, subTextChoice));
|
|
2654
2649
|
}
|
|
2655
|
-
if (
|
|
2650
|
+
if (noWrap) {
|
|
2656
2651
|
return (React.createElement("span", { className: cx(labelStyles, outerClass) },
|
|
2657
2652
|
React.createElement("label", { htmlFor: props.htmlFor, className: outerClass }, labelText),
|
|
2658
2653
|
props.children));
|
|
@@ -2660,36 +2655,15 @@ const Label = (props) => {
|
|
|
2660
2655
|
const content = React.createElement(React.Fragment, null,
|
|
2661
2656
|
labelText,
|
|
2662
2657
|
React.createElement("span", { className: css(labelContentStyles) }, props.children));
|
|
2663
|
-
if (
|
|
2658
|
+
if (propsStatic) {
|
|
2664
2659
|
return (React.createElement("span", { className: cx(labelStyles, outerClass) }, content));
|
|
2665
2660
|
}
|
|
2666
2661
|
// labels without htmlFor can cause focus, hover, and click issues when wrapping other elements.
|
|
2667
2662
|
// this fixes the issues.
|
|
2668
|
-
const htmlFor = (
|
|
2663
|
+
const htmlFor = (_a = props.htmlFor) !== null && _a !== void 0 ? _a : `labelAutoId_${createUid()}`;
|
|
2669
2664
|
return (React.createElement("label", Object.assign({}, labelProps, { htmlFor: htmlFor, className: cx('label', labelStyles, outerClass) }), content));
|
|
2670
2665
|
};
|
|
2671
2666
|
|
|
2672
|
-
/*
|
|
2673
|
-
From https://fireship.io/snippets/use-media-query-hook/.
|
|
2674
|
-
Tried using https://www.npmjs.com/package/react-media, but it cause Webpack build issues.
|
|
2675
|
-
*/
|
|
2676
|
-
/** React wrapper around window resizing and window.matchMedia.
|
|
2677
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
|
|
2678
|
-
*/
|
|
2679
|
-
const useMediaQuery = (query) => {
|
|
2680
|
-
const [matches, setMatches] = useState(window.matchMedia(query).matches);
|
|
2681
|
-
useEffect(() => {
|
|
2682
|
-
const media = window.matchMedia(query);
|
|
2683
|
-
if (media.matches !== matches) {
|
|
2684
|
-
setMatches(media.matches);
|
|
2685
|
-
}
|
|
2686
|
-
const listener = () => setMatches(media.matches);
|
|
2687
|
-
window.addEventListener("resize", listener);
|
|
2688
|
-
return () => window.removeEventListener("resize", listener);
|
|
2689
|
-
}, [matches, query]);
|
|
2690
|
-
return matches;
|
|
2691
|
-
};
|
|
2692
|
-
|
|
2693
2667
|
const Nav = (props) => {
|
|
2694
2668
|
var _a, _b, _c, _d;
|
|
2695
2669
|
const nav = React.useRef(null);
|
|
@@ -2697,7 +2671,6 @@ const Nav = (props) => {
|
|
|
2697
2671
|
const navWidth = (_a = props.navWidth) !== null && _a !== void 0 ? _a : theme.layout.navWidth;
|
|
2698
2672
|
const totalNavOffset = `calc(${navWidth} + 20px)`;
|
|
2699
2673
|
const backdrop = React.useContext(BackdropContext);
|
|
2700
|
-
const isLargeScreen = useMediaQuery(`(min-width:${theme.breakpoints.desktop})`);
|
|
2701
2674
|
const log = useLogger(`Nav ${(_b = props.id) !== null && _b !== void 0 ? _b : '?'}`, (_c = props.__debug) !== null && _c !== void 0 ? _c : false);
|
|
2702
2675
|
const slideMs = (_d = props.slideMs) !== null && _d !== void 0 ? _d : theme.timings.nav.slideMs;
|
|
2703
2676
|
const slideRight = keyframes `
|
|
@@ -2742,19 +2715,6 @@ const Nav = (props) => {
|
|
|
2742
2715
|
color: ${theme.colors.navFont};
|
|
2743
2716
|
}
|
|
2744
2717
|
padding-top:0;
|
|
2745
|
-
${props.responsive && `
|
|
2746
|
-
@media(min-width:${theme.breakpoints.desktop}) {
|
|
2747
|
-
position: relative;
|
|
2748
|
-
left: 0;
|
|
2749
|
-
box-shadow: none;
|
|
2750
|
-
z-index: 1;
|
|
2751
|
-
animation: none !important;
|
|
2752
|
-
margin-right: 1rem;
|
|
2753
|
-
overflow-y: visible;
|
|
2754
|
-
margin-top:-2rem;
|
|
2755
|
-
padding-top: 1rem;
|
|
2756
|
-
}
|
|
2757
|
-
`}
|
|
2758
2718
|
`;
|
|
2759
2719
|
React.useEffect(() => {
|
|
2760
2720
|
if (!backdrop.showing) {
|
|
@@ -2786,13 +2746,6 @@ const Nav = (props) => {
|
|
|
2786
2746
|
}
|
|
2787
2747
|
}
|
|
2788
2748
|
});
|
|
2789
|
-
if (props.responsive) {
|
|
2790
|
-
React.useEffect(() => {
|
|
2791
|
-
if (backdrop.showing) {
|
|
2792
|
-
props.toggle(false);
|
|
2793
|
-
}
|
|
2794
|
-
}, [isLargeScreen]);
|
|
2795
|
-
}
|
|
2796
2749
|
return (React.createElement("nav", { ref: nav, className: cx('nav', navStyles, props.className) }, props.children));
|
|
2797
2750
|
};
|
|
2798
2751
|
|
|
@@ -3055,18 +3008,19 @@ const generateLinkStyles = (props, theme) => {
|
|
|
3055
3008
|
};
|
|
3056
3009
|
|
|
3057
3010
|
const OmniLink = (props) => {
|
|
3011
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
3058
3012
|
const { noRouter, rightIcon, leftIcon, block, iconBlock, variant, round, small, colorOverride, children, ref, waiting } = props, linkProps = __rest(props, ["noRouter", "rightIcon", "leftIcon", "block", "iconBlock", "variant", "round", "small", "colorOverride", "children", "ref", "waiting"]);
|
|
3059
3013
|
const theme = useThemeSafely();
|
|
3060
3014
|
const linkStyles = generateLinkStyles(props, theme);
|
|
3061
3015
|
const mainClassName = cx('omniLink', linkStyles, props.className);
|
|
3062
3016
|
if (variant === 'text') {
|
|
3063
|
-
return React.createElement(Text, { className: mainClassName, tag: "div" },
|
|
3017
|
+
return React.createElement(Text, { className: mainClassName, tag: "div" }, children);
|
|
3064
3018
|
}
|
|
3065
3019
|
const content = React.createElement(LinkContent, Object.assign({}, props));
|
|
3066
|
-
if (
|
|
3020
|
+
if (noRouter) {
|
|
3067
3021
|
return (React.createElement("a", Object.assign({}, linkProps, { target: props.target, className: mainClassName }), content));
|
|
3068
3022
|
}
|
|
3069
|
-
const isDisabled = props.disabled ||
|
|
3023
|
+
const isDisabled = props.disabled || waiting;
|
|
3070
3024
|
return (React.createElement(Link$1, Object.assign({}, linkProps, { className: mainClassName, to: props.href, onClick: e => {
|
|
3071
3025
|
var _a;
|
|
3072
3026
|
if (isDisabled) {
|
|
@@ -3081,13 +3035,13 @@ const OmniLink = (props) => {
|
|
|
3081
3035
|
|
|
3082
3036
|
const roundPxPadding = '4px';
|
|
3083
3037
|
const Picker = (props) => {
|
|
3084
|
-
const selectProps = __rest(props
|
|
3038
|
+
const { value, options, onValueChange, readOnly, round, controlAlign, wrapperClassName, iconClassName, error } = props, selectProps = __rest(props
|
|
3085
3039
|
// if we put numbers in, we expect them out
|
|
3086
3040
|
, ["value", "options", "onValueChange", "readOnly", "round", "controlAlign", "wrapperClassName", "iconClassName", "error"]);
|
|
3087
3041
|
// if we put numbers in, we expect them out
|
|
3088
3042
|
let isNumber = false;
|
|
3089
|
-
if (
|
|
3090
|
-
const testOption =
|
|
3043
|
+
if (options && options.length) {
|
|
3044
|
+
const testOption = options[0];
|
|
3091
3045
|
if (typeof testOption === 'object') {
|
|
3092
3046
|
isNumber = typeof testOption.id === 'number';
|
|
3093
3047
|
}
|
|
@@ -3119,16 +3073,16 @@ const Picker = (props) => {
|
|
|
3119
3073
|
outline: 'none',
|
|
3120
3074
|
boxShadow: theme.controls.focusOutlineShadow
|
|
3121
3075
|
}
|
|
3122
|
-
},
|
|
3076
|
+
}, round && {
|
|
3123
3077
|
borderRadius: theme.controls.roundRadius,
|
|
3124
3078
|
paddingLeft: `calc(${theme.controls.padding} + ${roundPxPadding})`,
|
|
3125
3079
|
paddingRight: `calc(${theme.controls.padding} + 1rem + ${roundPxPadding})`,
|
|
3126
|
-
},
|
|
3080
|
+
}, error && {
|
|
3127
3081
|
borderColor: theme.colors.required,
|
|
3128
3082
|
':focus': {
|
|
3129
3083
|
boxShadow: theme.controls.focusOutlineRequiredShadow
|
|
3130
3084
|
}
|
|
3131
|
-
},
|
|
3085
|
+
}, readOnly && {
|
|
3132
3086
|
backgroundColor: 'transparent !important',
|
|
3133
3087
|
backgroundImage: 'unset',
|
|
3134
3088
|
border: 'none',
|
|
@@ -3137,9 +3091,9 @@ const Picker = (props) => {
|
|
|
3137
3091
|
boxShadow: 'none'
|
|
3138
3092
|
}
|
|
3139
3093
|
});
|
|
3140
|
-
const select = (React.createElement("select", Object.assign({}, selectProps, { tabIndex:
|
|
3094
|
+
const select = (React.createElement("select", Object.assign({}, selectProps, { tabIndex: readOnly ? -1 : selectProps.tabIndex, className: cx('picker', selectStyles, props.className), value: value, onKeyDown: e => {
|
|
3141
3095
|
var _a;
|
|
3142
|
-
if (
|
|
3096
|
+
if (readOnly) {
|
|
3143
3097
|
if (e.keyCode === 9) {
|
|
3144
3098
|
//TAB
|
|
3145
3099
|
return;
|
|
@@ -3152,7 +3106,7 @@ const Picker = (props) => {
|
|
|
3152
3106
|
}
|
|
3153
3107
|
}, onMouseDown: e => {
|
|
3154
3108
|
var _a;
|
|
3155
|
-
if (
|
|
3109
|
+
if (readOnly) {
|
|
3156
3110
|
e.preventDefault();
|
|
3157
3111
|
e.stopPropagation();
|
|
3158
3112
|
}
|
|
@@ -3168,9 +3122,9 @@ const Picker = (props) => {
|
|
|
3168
3122
|
val = '';
|
|
3169
3123
|
}
|
|
3170
3124
|
}
|
|
3171
|
-
|
|
3125
|
+
onValueChange(val);
|
|
3172
3126
|
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
3173
|
-
} }), (
|
|
3127
|
+
} }), (options || []).map(o => {
|
|
3174
3128
|
var _a;
|
|
3175
3129
|
let val;
|
|
3176
3130
|
let label;
|
|
@@ -3189,19 +3143,19 @@ const Picker = (props) => {
|
|
|
3189
3143
|
position: 'relative',
|
|
3190
3144
|
display: 'inline-block',
|
|
3191
3145
|
width: '100%',
|
|
3192
|
-
}),
|
|
3146
|
+
}), wrapperClassName) },
|
|
3193
3147
|
React.createElement("div", { className: css({
|
|
3194
3148
|
position: 'relative'
|
|
3195
3149
|
}) },
|
|
3196
3150
|
select,
|
|
3197
|
-
!
|
|
3151
|
+
!readOnly && (React.createElement(Icon, { id: "sortDesc", className: cx(css({
|
|
3198
3152
|
position: 'absolute',
|
|
3199
|
-
right: `calc(${theme.controls.padding} + ${
|
|
3153
|
+
right: `calc(${theme.controls.padding} + ${round ? roundPxPadding : '0px'})`,
|
|
3200
3154
|
height: '100%',
|
|
3201
3155
|
pointerEvents: 'none',
|
|
3202
3156
|
color: theme.colors.font
|
|
3203
|
-
}),
|
|
3204
|
-
(
|
|
3157
|
+
}), iconClassName) }))),
|
|
3158
|
+
(error || controlAlign) && React.createElement(InputErrorDisplay, { error: error })));
|
|
3205
3159
|
};
|
|
3206
3160
|
|
|
3207
3161
|
const Pager = (props) => {
|
|
@@ -3265,7 +3219,7 @@ const Pager = (props) => {
|
|
|
3265
3219
|
const BoundMemoryPager = (p) => {
|
|
3266
3220
|
var _a, _b, _c;
|
|
3267
3221
|
const { pager, showPageText } = p, rest = __rest(p, ["pager", "showPageText"]);
|
|
3268
|
-
return (React.createElement(Pager, Object.assign({}, rest, { pageIndex:
|
|
3222
|
+
return (React.createElement(Pager, Object.assign({}, rest, { pageIndex: showPageText ? pager.page : undefined, totalPages: showPageText ? pager.totalPages : undefined, canGoNext: pager.hasNext, canGoPrevious: pager.hasPrevious, minItem: pager.minItemIndex + 1, maxItem: pager.maxItemIndex + 1, totalItems: pager.totalItems, leftControls: pager.limitOptions.length > 1 && p.onLimit ? (React.createElement(Label, { text: (_a = p.limitText) !== null && _a !== void 0 ? _a : 'Limit', orientation: "horizontal" },
|
|
3269
3223
|
React.createElement(Picker, { value: pager.limit, options: pager.limitOptions, onValueChange: v => { var _a; return (_a = p.onLimit) === null || _a === void 0 ? void 0 : _a.call(p, v); } }))) : undefined, rightControls: pager.sortOptions.length > 1 && p.onSort ? (React.createElement(Label, { text: (_b = p.sortText) !== null && _b !== void 0 ? _b : 'Sort', orientation: "horizontalReverse" },
|
|
3270
3224
|
React.createElement(Picker, { value: (_c = pager.sort) !== null && _c !== void 0 ? _c : '', options: pager.sortOptions, onValueChange: v => { var _a; return (_a = p.onSort) === null || _a === void 0 ? void 0 : _a.call(p, v); } }))) : undefined, page: d => {
|
|
3271
3225
|
p.onPage(d);
|
|
@@ -3277,7 +3231,7 @@ const BoundStaticPager = (p) => {
|
|
|
3277
3231
|
const { result, showPageText } = p, rest = __rest(p, ["result", "showPageText"]);
|
|
3278
3232
|
const showLimit = !!(result.limit && p.limitOptions && p.limitOptions.length > 1 && p.onLimit);
|
|
3279
3233
|
const showSort = !!(p.sort !== undefined && p.sortOptions && p.sortOptions.length > 1 && p.onSort);
|
|
3280
|
-
return (React.createElement(Pager, Object.assign({}, rest, { pageIndex:
|
|
3234
|
+
return (React.createElement(Pager, Object.assign({}, rest, { pageIndex: showPageText ? result.page : undefined, totalPages: showPageText ? result.totalPages : undefined, canGoNext: result.hasNext, canGoPrevious: result.hasPrevious, minItem: result.minPageItemIndex + 1, maxItem: result.maxPageItemIndex + 1, totalItems: result.total, leftControls: showLimit ? (React.createElement(Label, { text: (_a = p.limitText) !== null && _a !== void 0 ? _a : 'Limit', orientation: "horizontal" },
|
|
3281
3235
|
React.createElement(Picker, { value: (_b = result.limit) !== null && _b !== void 0 ? _b : 1, options: (_c = p.limitOptions) !== null && _c !== void 0 ? _c : [1], onValueChange: v => { var _a; return (_a = p.onLimit) === null || _a === void 0 ? void 0 : _a.call(p, v); } }))) : undefined, rightControls: showSort ? (React.createElement(Label, { text: (_d = p.sortText) !== null && _d !== void 0 ? _d : 'Sort', orientation: "horizontalReverse" },
|
|
3282
3236
|
React.createElement(Picker, { value: (_e = p.sort) !== null && _e !== void 0 ? _e : '', options: (_f = p.sortOptions) !== null && _f !== void 0 ? _f : [], onValueChange: v => {
|
|
3283
3237
|
var _a;
|
|
@@ -3295,10 +3249,6 @@ class PagedResult {
|
|
|
3295
3249
|
this.limit = limit;
|
|
3296
3250
|
this.total = total;
|
|
3297
3251
|
}
|
|
3298
|
-
/** @deprecated Use fromPagedResultDto going forward. */
|
|
3299
|
-
static fromDto(dto) {
|
|
3300
|
-
return new PagedResult(dto.items, dto.total, dto.page, dto.limit);
|
|
3301
|
-
}
|
|
3302
3252
|
static fromPagedResultDto(dto, convert) {
|
|
3303
3253
|
const items = convert ? dto.items.map(convert) : dto.items;
|
|
3304
3254
|
return new PagedResult(items, dto.total, dto.page, dto.limit);
|
|
@@ -3410,6 +3360,7 @@ class PagedResult {
|
|
|
3410
3360
|
items: this.items.map(item => {
|
|
3411
3361
|
if (!!item && typeof item === 'object') {
|
|
3412
3362
|
if ('toJSON' in item) {
|
|
3363
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3413
3364
|
return item.toJSON();
|
|
3414
3365
|
}
|
|
3415
3366
|
}
|
|
@@ -3708,33 +3659,33 @@ const useWaiting = (func) => {
|
|
|
3708
3659
|
};
|
|
3709
3660
|
|
|
3710
3661
|
const SearchBox = React.forwardRef((props, ref) => {
|
|
3711
|
-
const { wrapperClassName, buttonClassName, inputWrapperClassName, inputClassName, onSubmit, noForm, noSubmitWhenEmpty
|
|
3662
|
+
const { wrapperClassName, buttonClassName, inputWrapperClassName, inputClassName, onSubmit, noForm, noSubmitWhenEmpty, onClear } = props, inputProps = __rest(props, ["wrapperClassName", "buttonClassName", "inputWrapperClassName", "inputClassName", "onSubmit", "noForm", "noSubmitWhenEmpty", "onClear"]);
|
|
3712
3663
|
const [waiting, handleSubmit] = useWaiting(async () => {
|
|
3713
|
-
var _a, _b
|
|
3664
|
+
var _a, _b;
|
|
3714
3665
|
if (noForm) {
|
|
3715
3666
|
return;
|
|
3716
3667
|
}
|
|
3717
|
-
if (!
|
|
3668
|
+
if (!onSubmit) {
|
|
3718
3669
|
return;
|
|
3719
3670
|
}
|
|
3720
|
-
if ((
|
|
3671
|
+
if ((noSubmitWhenEmpty !== null && noSubmitWhenEmpty !== void 0 ? noSubmitWhenEmpty : true) && !props.value) {
|
|
3721
3672
|
return;
|
|
3722
3673
|
}
|
|
3723
3674
|
// the active element will be the input. if the submit action changes props.value it will
|
|
3724
3675
|
// be ignored due to Inputs focused handling.
|
|
3725
3676
|
if (document.activeElement) {
|
|
3726
|
-
(
|
|
3677
|
+
(_b = (_a = document.activeElement).blur) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3727
3678
|
}
|
|
3728
|
-
return
|
|
3679
|
+
return onSubmit();
|
|
3729
3680
|
});
|
|
3730
3681
|
const theme = useThemeSafely();
|
|
3731
3682
|
const buttonStyles = cx(css({
|
|
3732
3683
|
color: `${theme.colors.font} !important;`,
|
|
3733
3684
|
fontSize: '1rem'
|
|
3734
|
-
}),
|
|
3685
|
+
}), buttonClassName);
|
|
3735
3686
|
let clearButton;
|
|
3736
|
-
if (
|
|
3737
|
-
clearButton = (React.createElement(Button, { onClick:
|
|
3687
|
+
if (onClear && !!props.value) {
|
|
3688
|
+
clearButton = (React.createElement(Button, { onClick: onClear, tabIndex: -1, disabled: waiting, className: buttonStyles, variant: "icon", small: true },
|
|
3738
3689
|
React.createElement(Icon, { id: "clear" })));
|
|
3739
3690
|
}
|
|
3740
3691
|
const saveButton = (React.createElement(Button, { tabIndex: -1, disabled: waiting, readOnly: !props.onSubmit, type: "submit", className: buttonStyles, variant: "icon", small: true },
|
|
@@ -3743,22 +3694,22 @@ const SearchBox = React.forwardRef((props, ref) => {
|
|
|
3743
3694
|
clearButton,
|
|
3744
3695
|
saveButton) : saveButton;
|
|
3745
3696
|
let clearButtonInputStyles;
|
|
3746
|
-
if (
|
|
3697
|
+
if (onClear) {
|
|
3747
3698
|
clearButtonInputStyles = css({
|
|
3748
3699
|
paddingRight: `calc(${theme.controls.height} + ${theme.controls.heightSmall})`
|
|
3749
3700
|
});
|
|
3750
3701
|
}
|
|
3751
|
-
const input = (React.createElement(TextInput, Object.assign({}, inputProps, { ref: ref, wrapperClassName:
|
|
3702
|
+
const input = (React.createElement(TextInput, Object.assign({}, inputProps, { ref: ref, wrapperClassName: inputWrapperClassName, className: cx(clearButtonInputStyles, inputClassName), rightControl: rightControls })));
|
|
3752
3703
|
const searchBoxWrapperStyles = cx(css({
|
|
3753
3704
|
label: 'SearchBox'
|
|
3754
|
-
}),
|
|
3755
|
-
if (!
|
|
3705
|
+
}), wrapperClassName);
|
|
3706
|
+
if (!noForm) {
|
|
3756
3707
|
return (React.createElement(Form, { role: "search", className: searchBoxWrapperStyles, onSubmit: handleSubmit }, input));
|
|
3757
3708
|
}
|
|
3758
3709
|
return (React.createElement("div", { className: searchBoxWrapperStyles }, input));
|
|
3759
3710
|
});
|
|
3760
3711
|
|
|
3761
|
-
const GlobalStyles = (
|
|
3712
|
+
const GlobalStyles = () => {
|
|
3762
3713
|
const theme = useThemeSafely();
|
|
3763
3714
|
injectGlobal({
|
|
3764
3715
|
'*': {
|
|
@@ -3786,6 +3737,27 @@ const GlobalStyles = (p) => {
|
|
|
3786
3737
|
return null;
|
|
3787
3738
|
};
|
|
3788
3739
|
|
|
3740
|
+
/*
|
|
3741
|
+
From https://fireship.io/snippets/use-media-query-hook/.
|
|
3742
|
+
Tried using https://www.npmjs.com/package/react-media, but it cause Webpack build issues.
|
|
3743
|
+
*/
|
|
3744
|
+
/** React wrapper around window resizing and window.matchMedia.
|
|
3745
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
|
|
3746
|
+
*/
|
|
3747
|
+
const useMediaQuery = (query) => {
|
|
3748
|
+
const [matches, setMatches] = useState(window.matchMedia(query).matches);
|
|
3749
|
+
useEffect(() => {
|
|
3750
|
+
const media = window.matchMedia(query);
|
|
3751
|
+
if (media.matches !== matches) {
|
|
3752
|
+
setMatches(media.matches);
|
|
3753
|
+
}
|
|
3754
|
+
const listener = () => setMatches(media.matches);
|
|
3755
|
+
window.addEventListener("resize", listener);
|
|
3756
|
+
return () => window.removeEventListener("resize", listener);
|
|
3757
|
+
}, [matches, query]);
|
|
3758
|
+
return matches;
|
|
3759
|
+
};
|
|
3760
|
+
|
|
3789
3761
|
const Slider = (p) => {
|
|
3790
3762
|
var _a;
|
|
3791
3763
|
const theme = useThemeSafely();
|
|
@@ -3807,13 +3779,13 @@ const Slider = (p) => {
|
|
|
3807
3779
|
width: '100%',
|
|
3808
3780
|
height,
|
|
3809
3781
|
}), p.className) },
|
|
3810
|
-
React__default.createElement(ReactSlider, { step: p.step, min: p.min, max: p.max, value: p.value, onAfterChange: (value
|
|
3782
|
+
React__default.createElement(ReactSlider, { step: p.step, min: p.min, max: p.max, value: p.value, onAfterChange: (value) => {
|
|
3811
3783
|
p.onChange(value);
|
|
3812
|
-
}, onChange: p.onUpdate || p.showValue ? (value
|
|
3784
|
+
}, onChange: p.onUpdate || p.showValue ? (value) => {
|
|
3813
3785
|
var _a;
|
|
3814
3786
|
currentValue.current = value;
|
|
3815
3787
|
(_a = p.onUpdate) === null || _a === void 0 ? void 0 : _a.call(p, value);
|
|
3816
|
-
} : undefined, renderTrack: (props
|
|
3788
|
+
} : undefined, renderTrack: (props) => {
|
|
3817
3789
|
const { className } = props, rest = __rest(props, ["className"]);
|
|
3818
3790
|
return (React__default.createElement("div", Object.assign({ className: cx(className, p.trackClassName, css({
|
|
3819
3791
|
display: 'flex',
|
|
@@ -3973,7 +3945,7 @@ const TabHeader = (p) => {
|
|
|
3973
3945
|
.then(() => {
|
|
3974
3946
|
onChange();
|
|
3975
3947
|
})
|
|
3976
|
-
.catch(
|
|
3948
|
+
.catch(() => {
|
|
3977
3949
|
/* do nothing */
|
|
3978
3950
|
})
|
|
3979
3951
|
.finally(() => {
|
|
@@ -4116,11 +4088,12 @@ const ThSort = (props) => {
|
|
|
4116
4088
|
const defaultMaxLength = 200;
|
|
4117
4089
|
const defaultRows = 10;
|
|
4118
4090
|
const TextArea = React.forwardRef((props, ref) => {
|
|
4119
|
-
var _a, _b
|
|
4091
|
+
var _a, _b;
|
|
4120
4092
|
const [localValue, setLocalValue] = React.useState(props.value);
|
|
4121
4093
|
const inputRef = (ref !== null && ref !== void 0 ? ref : React.useRef(null));
|
|
4122
4094
|
const [validationError, updateErrorMessage] = useInputValidationMessage(inputRef, props);
|
|
4123
|
-
|
|
4095
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4096
|
+
const { onValueChange, customError, reportValueOnError, showErrorDisplay, allowUpdateOnFocus } = props, nativeProps = __rest(props, ["onValueChange", "customError", "reportValueOnError", "showErrorDisplay", "allowUpdateOnFocus"]);
|
|
4124
4097
|
const theme = useThemeSafely();
|
|
4125
4098
|
React.useEffect(() => {
|
|
4126
4099
|
updateErrorMessage();
|
|
@@ -4128,21 +4101,21 @@ const TextArea = React.forwardRef((props, ref) => {
|
|
|
4128
4101
|
useIgnoreMount(() => {
|
|
4129
4102
|
var _a;
|
|
4130
4103
|
if ((_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.checkValidity()) {
|
|
4131
|
-
|
|
4104
|
+
onValueChange(localValue);
|
|
4132
4105
|
}
|
|
4133
4106
|
else {
|
|
4134
|
-
if (
|
|
4107
|
+
if (reportValueOnError) {
|
|
4135
4108
|
//TB: temp, add a custom list of validators that will be run for all inputs if a pattern cannot be decided.
|
|
4136
|
-
|
|
4109
|
+
onValueChange(localValue);
|
|
4137
4110
|
}
|
|
4138
4111
|
else {
|
|
4139
|
-
|
|
4112
|
+
onValueChange(undefined);
|
|
4140
4113
|
}
|
|
4141
4114
|
}
|
|
4142
4115
|
updateErrorMessage();
|
|
4143
4116
|
}, [localValue]);
|
|
4144
4117
|
useIgnoreMount(() => {
|
|
4145
|
-
if (
|
|
4118
|
+
if (allowUpdateOnFocus || document.activeElement !== inputRef.current) {
|
|
4146
4119
|
setLocalValue(props.value);
|
|
4147
4120
|
}
|
|
4148
4121
|
updateErrorMessage();
|
|
@@ -4202,20 +4175,19 @@ const TextArea = React.forwardRef((props, ref) => {
|
|
|
4202
4175
|
}
|
|
4203
4176
|
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
4204
4177
|
} })),
|
|
4205
|
-
(
|
|
4178
|
+
(showErrorDisplay !== null && showErrorDisplay !== void 0 ? showErrorDisplay : true) && React.createElement(InputErrorDisplay, { error: validationError })));
|
|
4206
4179
|
});
|
|
4207
4180
|
|
|
4208
4181
|
const ToggleButton = React.forwardRef((props, ref) => {
|
|
4209
|
-
|
|
4210
|
-
const buttonProps = __rest(props, ["checked", "checkedText", "uncheckedText", "checkedChildren", "uncheckedChildren", "checkedVariant", "checkedClassName", "checkedStyle", "checkedIcon", "uncheckedIcon"]);
|
|
4182
|
+
const { checked, checkedChildren, uncheckedChildren, checkedVariant, checkedClassName, checkedStyle, checkedIcon, uncheckedIcon } = props, buttonProps = __rest(props, ["checked", "checkedChildren", "uncheckedChildren", "checkedVariant", "checkedClassName", "checkedStyle", "checkedIcon", "uncheckedIcon"]);
|
|
4211
4183
|
let children;
|
|
4212
|
-
if (
|
|
4213
|
-
children =
|
|
4184
|
+
if (checked) {
|
|
4185
|
+
children = checkedChildren;
|
|
4214
4186
|
}
|
|
4215
4187
|
else {
|
|
4216
|
-
children =
|
|
4188
|
+
children = uncheckedChildren;
|
|
4217
4189
|
}
|
|
4218
|
-
return (React.createElement(Button, Object.assign({}, buttonProps, { ref: ref, className: cx('toggleButton',
|
|
4190
|
+
return (React.createElement(Button, Object.assign({}, buttonProps, { ref: ref, className: cx('toggleButton', checked && 'toggleButton--checked', props.className, checked && checkedClassName), rightIcon: checked ? checkedIcon : uncheckedIcon, variant: checked ? checkedVariant : props.variant, style: checked ? checkedStyle : props.style }), children));
|
|
4219
4191
|
});
|
|
4220
4192
|
|
|
4221
4193
|
const ToggleButtonGroup = (props) => {
|
|
@@ -4364,7 +4336,7 @@ const WaitingIndicator = (p) => {
|
|
|
4364
4336
|
the IE-specific fixes have been removed.
|
|
4365
4337
|
*/
|
|
4366
4338
|
/** Resets certain styles so there is more consistancy between browsers. */
|
|
4367
|
-
const NormalizeCss = (
|
|
4339
|
+
const NormalizeCss = () => {
|
|
4368
4340
|
/* tslint:disable:no-unused-expression */
|
|
4369
4341
|
injectGlobal `
|
|
4370
4342
|
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
|
|
@@ -4680,6 +4652,7 @@ const enumToEntities = (enumObj) => {
|
|
|
4680
4652
|
};
|
|
4681
4653
|
|
|
4682
4654
|
const Link = (props) => {
|
|
4655
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
4683
4656
|
const { rightIcon, leftIcon, block, iconBlock, variant, round, small, colorOverride, children, disabled, ref, waiting } = props, linkProps = __rest(props, ["rightIcon", "leftIcon", "block", "iconBlock", "variant", "round", "small", "colorOverride", "children", "disabled", "ref", "waiting"]);
|
|
4684
4657
|
const theme = useThemeSafely();
|
|
4685
4658
|
const linkStyles = generateLinkStyles(props, theme);
|
|
@@ -4701,6 +4674,7 @@ const Link = (props) => {
|
|
|
4701
4674
|
React.createElement(LinkContent, Object.assign({}, props))));
|
|
4702
4675
|
};
|
|
4703
4676
|
|
|
4677
|
+
/* eslint @typescript-eslint/no-explicit-any: 0 */
|
|
4704
4678
|
const ThemeRenderer = (p) => {
|
|
4705
4679
|
const { backgroundColor, color } = p, theme = __rest(p, ["backgroundColor", "color"]);
|
|
4706
4680
|
const flatTheme = flatten(theme);
|