@mackin.com/styleguide 10.2.4 → 10.2.6
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 +2 -0
- package/index.esm.js +11 -43
- package/index.js +11 -43
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ interface CheckboxProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttr
|
|
|
140
140
|
checkedThemeColor?: 'primary' | 'primary2' | 'secondary';
|
|
141
141
|
/** Background color when checked. Mutually exclusive with 'checkedThemeColor'. */
|
|
142
142
|
checkedColor?: string;
|
|
143
|
+
tabIndex?: number | undefined;
|
|
143
144
|
}
|
|
144
145
|
declare const Checkbox: (props: CheckboxProps) => React.JSX.Element;
|
|
145
146
|
|
|
@@ -865,6 +866,7 @@ interface SliderProps<T extends SliderValue> {
|
|
|
865
866
|
sliderTextClassName?: string;
|
|
866
867
|
/** Sets the aria-label value. */
|
|
867
868
|
ariaLabel?: (T extends number ? string : readonly string[] | undefined) | undefined;
|
|
869
|
+
tabIndex?: number | undefined;
|
|
868
870
|
}
|
|
869
871
|
declare const Slider: <T extends SliderValue>(p: SliderProps<T>) => React__default.JSX.Element;
|
|
870
872
|
|
package/index.esm.js
CHANGED
|
@@ -497,45 +497,6 @@ const Button = React.forwardRef((props, ref) => {
|
|
|
497
497
|
return content;
|
|
498
498
|
});
|
|
499
499
|
|
|
500
|
-
/* Type is not always determinable due to the nature of custom components in typescript. For example OmniLink will not have a type of "a" but rather "OmniLink" so we have to determine
|
|
501
|
-
if the child component is focusable based on certain properties on the control that are found on focusable components */
|
|
502
|
-
const isChildFocusable = (props, type) => {
|
|
503
|
-
if (props.tabIndex !== undefined && props.tabIndex !== null) {
|
|
504
|
-
return true;
|
|
505
|
-
}
|
|
506
|
-
if (props.onClick !== undefined || props.onValueChange !== undefined) { //button or select
|
|
507
|
-
return true;
|
|
508
|
-
}
|
|
509
|
-
if (props.href || props.cols || props.rows || props.maxLength) {
|
|
510
|
-
return true;
|
|
511
|
-
}
|
|
512
|
-
if ((type === 'button' || type === 'input' || type === 'select' || type === 'textarea') && !props.disabled) {
|
|
513
|
-
return true;
|
|
514
|
-
}
|
|
515
|
-
return false;
|
|
516
|
-
};
|
|
517
|
-
const TabIndexContainer = (props) => {
|
|
518
|
-
const processElement = (node) => {
|
|
519
|
-
if (!React__default.isValidElement(node)) {
|
|
520
|
-
return node;
|
|
521
|
-
}
|
|
522
|
-
let updatedNode = node;
|
|
523
|
-
// Use the props-based logic to check focusability
|
|
524
|
-
if (isChildFocusable(node.props, node.type)) {
|
|
525
|
-
updatedNode = React__default.cloneElement(node, { tabIndex: props.tabIndexValue });
|
|
526
|
-
}
|
|
527
|
-
// Recursively process children
|
|
528
|
-
if (updatedNode.props.children) {
|
|
529
|
-
const clonedChildren = React__default.Children.map(updatedNode.props.children, processElement);
|
|
530
|
-
updatedNode = React__default.cloneElement(updatedNode, {
|
|
531
|
-
children: clonedChildren,
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
return updatedNode;
|
|
535
|
-
};
|
|
536
|
-
return (React__default.createElement(React__default.Fragment, null, React__default.Children.map(props.children, processElement)));
|
|
537
|
-
};
|
|
538
|
-
|
|
539
500
|
const accordianExpandTimeMs = 250;
|
|
540
501
|
const accordianMaxHeight = 1020;
|
|
541
502
|
const accordianTimingFunction = 'ease-in-out';
|
|
@@ -549,6 +510,7 @@ const Accordian = (props) => {
|
|
|
549
510
|
const [open, setOpen] = React.useState(false);
|
|
550
511
|
const theme = useThemeSafely();
|
|
551
512
|
const content = React.useRef(null);
|
|
513
|
+
const [children, setChildren] = React.useState();
|
|
552
514
|
const contentStyles = css({
|
|
553
515
|
overflow: 'hidden',
|
|
554
516
|
maxHeight: 0,
|
|
@@ -564,6 +526,7 @@ const Accordian = (props) => {
|
|
|
564
526
|
const currentContent = content.current;
|
|
565
527
|
if (currentContent) {
|
|
566
528
|
if (open) {
|
|
529
|
+
setChildren(props.children);
|
|
567
530
|
currentContent.classList.add(expandedContentStyles);
|
|
568
531
|
window.setTimeout(() => {
|
|
569
532
|
currentContent.classList.add(visibleStyle);
|
|
@@ -571,6 +534,11 @@ const Accordian = (props) => {
|
|
|
571
534
|
}
|
|
572
535
|
else {
|
|
573
536
|
currentContent.classList.remove(visibleStyle, expandedContentStyles);
|
|
537
|
+
if (children !== undefined) {
|
|
538
|
+
window.setTimeout(() => {
|
|
539
|
+
setChildren(undefined);
|
|
540
|
+
}, accordianExpandTimeMs);
|
|
541
|
+
}
|
|
574
542
|
}
|
|
575
543
|
}
|
|
576
544
|
}, [open]);
|
|
@@ -602,8 +570,7 @@ const Accordian = (props) => {
|
|
|
602
570
|
}, rightIcon: !props.disabled ? React.createElement(Icon, { id: open ? 'collapse' : 'expand' }) : undefined },
|
|
603
571
|
React.createElement("span", null, props.header)),
|
|
604
572
|
React.createElement("div", { ref: content, className: cx('accordian__body', contentStyles) },
|
|
605
|
-
React.createElement("div", { className: expandedContentWrapperStyles },
|
|
606
|
-
React.createElement(TabIndexContainer, { tabIndexValue: open ? 0 : -1 }, props.children)))));
|
|
573
|
+
React.createElement("div", { className: expandedContentWrapperStyles }, children))));
|
|
607
574
|
};
|
|
608
575
|
const useAccordianState = (count, openIndex) => {
|
|
609
576
|
const [panels, setShowPanel] = React.useState(new Array(count).fill(false).map((b, i) => {
|
|
@@ -1525,6 +1492,7 @@ const Calendar = (p) => {
|
|
|
1525
1492
|
};
|
|
1526
1493
|
|
|
1527
1494
|
const Checkbox = (props) => {
|
|
1495
|
+
var _a;
|
|
1528
1496
|
const { onChange, label, checkedIcon, uncheckedIcon, checkedThemeColor, checkedColor, readOnly } = props, inputProps = __rest(props, ["onChange", "label", "checkedIcon", "uncheckedIcon", "checkedThemeColor", "checkedColor", "readOnly"]);
|
|
1529
1497
|
const selected = checkedIcon || 'selected';
|
|
1530
1498
|
const unselected = uncheckedIcon || 'unselected';
|
|
@@ -1589,7 +1557,7 @@ const Checkbox = (props) => {
|
|
|
1589
1557
|
`;
|
|
1590
1558
|
return (React.createElement("span", { className: cx('checkbox', checkboxStyles, props.className) },
|
|
1591
1559
|
React.createElement("label", { className: labelStyles },
|
|
1592
|
-
React.createElement("input", Object.assign({}, inputProps, { tabIndex: readOnly ? -1 : undefined, className: nativeCheckboxStyles, type: "checkbox", onChange: e => {
|
|
1560
|
+
React.createElement("input", Object.assign({}, inputProps, { tabIndex: readOnly ? -1 : (_a = props.tabIndex) !== null && _a !== void 0 ? _a : undefined, className: nativeCheckboxStyles, type: "checkbox", onChange: e => {
|
|
1593
1561
|
if (readOnly) {
|
|
1594
1562
|
e.preventDefault();
|
|
1595
1563
|
return;
|
|
@@ -3984,7 +3952,7 @@ const Slider = (p) => {
|
|
|
3984
3952
|
}), specificThumbStyles, p.handleClassName, css({
|
|
3985
3953
|
width: sliderHandleSize,
|
|
3986
3954
|
height: sliderHandleSize,
|
|
3987
|
-
})) }, rest), p.showValue && (React__default.createElement(HandleText, { sliderHandleSize: sliderHandleSize, className: p.sliderTextClassName, index: state.index, parentElement: sliderContainer.current, value: Array.isArray(currentValue.current) ? currentValue.current[state.index] : currentValue.current, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth }))));
|
|
3955
|
+
})) }, rest, { tabIndex: p.tabIndex }), p.showValue && (React__default.createElement(HandleText, { sliderHandleSize: sliderHandleSize, className: p.sliderTextClassName, index: state.index, parentElement: sliderContainer.current, value: Array.isArray(currentValue.current) ? currentValue.current[state.index] : currentValue.current, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth }))));
|
|
3988
3956
|
} })));
|
|
3989
3957
|
};
|
|
3990
3958
|
const rectsCollideX = (r1, r2) => {
|
package/index.js
CHANGED
|
@@ -515,45 +515,6 @@ const Button = React__namespace.forwardRef((props, ref) => {
|
|
|
515
515
|
return content;
|
|
516
516
|
});
|
|
517
517
|
|
|
518
|
-
/* Type is not always determinable due to the nature of custom components in typescript. For example OmniLink will not have a type of "a" but rather "OmniLink" so we have to determine
|
|
519
|
-
if the child component is focusable based on certain properties on the control that are found on focusable components */
|
|
520
|
-
const isChildFocusable = (props, type) => {
|
|
521
|
-
if (props.tabIndex !== undefined && props.tabIndex !== null) {
|
|
522
|
-
return true;
|
|
523
|
-
}
|
|
524
|
-
if (props.onClick !== undefined || props.onValueChange !== undefined) { //button or select
|
|
525
|
-
return true;
|
|
526
|
-
}
|
|
527
|
-
if (props.href || props.cols || props.rows || props.maxLength) {
|
|
528
|
-
return true;
|
|
529
|
-
}
|
|
530
|
-
if ((type === 'button' || type === 'input' || type === 'select' || type === 'textarea') && !props.disabled) {
|
|
531
|
-
return true;
|
|
532
|
-
}
|
|
533
|
-
return false;
|
|
534
|
-
};
|
|
535
|
-
const TabIndexContainer = (props) => {
|
|
536
|
-
const processElement = (node) => {
|
|
537
|
-
if (!React.isValidElement(node)) {
|
|
538
|
-
return node;
|
|
539
|
-
}
|
|
540
|
-
let updatedNode = node;
|
|
541
|
-
// Use the props-based logic to check focusability
|
|
542
|
-
if (isChildFocusable(node.props, node.type)) {
|
|
543
|
-
updatedNode = React.cloneElement(node, { tabIndex: props.tabIndexValue });
|
|
544
|
-
}
|
|
545
|
-
// Recursively process children
|
|
546
|
-
if (updatedNode.props.children) {
|
|
547
|
-
const clonedChildren = React.Children.map(updatedNode.props.children, processElement);
|
|
548
|
-
updatedNode = React.cloneElement(updatedNode, {
|
|
549
|
-
children: clonedChildren,
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
return updatedNode;
|
|
553
|
-
};
|
|
554
|
-
return (React.createElement(React.Fragment, null, React.Children.map(props.children, processElement)));
|
|
555
|
-
};
|
|
556
|
-
|
|
557
518
|
const accordianExpandTimeMs = 250;
|
|
558
519
|
const accordianMaxHeight = 1020;
|
|
559
520
|
const accordianTimingFunction = 'ease-in-out';
|
|
@@ -567,6 +528,7 @@ const Accordian = (props) => {
|
|
|
567
528
|
const [open, setOpen] = React__namespace.useState(false);
|
|
568
529
|
const theme = useThemeSafely();
|
|
569
530
|
const content = React__namespace.useRef(null);
|
|
531
|
+
const [children, setChildren] = React__namespace.useState();
|
|
570
532
|
const contentStyles = css.css({
|
|
571
533
|
overflow: 'hidden',
|
|
572
534
|
maxHeight: 0,
|
|
@@ -582,6 +544,7 @@ const Accordian = (props) => {
|
|
|
582
544
|
const currentContent = content.current;
|
|
583
545
|
if (currentContent) {
|
|
584
546
|
if (open) {
|
|
547
|
+
setChildren(props.children);
|
|
585
548
|
currentContent.classList.add(expandedContentStyles);
|
|
586
549
|
window.setTimeout(() => {
|
|
587
550
|
currentContent.classList.add(visibleStyle);
|
|
@@ -589,6 +552,11 @@ const Accordian = (props) => {
|
|
|
589
552
|
}
|
|
590
553
|
else {
|
|
591
554
|
currentContent.classList.remove(visibleStyle, expandedContentStyles);
|
|
555
|
+
if (children !== undefined) {
|
|
556
|
+
window.setTimeout(() => {
|
|
557
|
+
setChildren(undefined);
|
|
558
|
+
}, accordianExpandTimeMs);
|
|
559
|
+
}
|
|
592
560
|
}
|
|
593
561
|
}
|
|
594
562
|
}, [open]);
|
|
@@ -620,8 +588,7 @@ const Accordian = (props) => {
|
|
|
620
588
|
}, rightIcon: !props.disabled ? React__namespace.createElement(Icon, { id: open ? 'collapse' : 'expand' }) : undefined },
|
|
621
589
|
React__namespace.createElement("span", null, props.header)),
|
|
622
590
|
React__namespace.createElement("div", { ref: content, className: css.cx('accordian__body', contentStyles) },
|
|
623
|
-
React__namespace.createElement("div", { className: expandedContentWrapperStyles },
|
|
624
|
-
React__namespace.createElement(TabIndexContainer, { tabIndexValue: open ? 0 : -1 }, props.children)))));
|
|
591
|
+
React__namespace.createElement("div", { className: expandedContentWrapperStyles }, children))));
|
|
625
592
|
};
|
|
626
593
|
const useAccordianState = (count, openIndex) => {
|
|
627
594
|
const [panels, setShowPanel] = React__namespace.useState(new Array(count).fill(false).map((b, i) => {
|
|
@@ -1543,6 +1510,7 @@ const Calendar = (p) => {
|
|
|
1543
1510
|
};
|
|
1544
1511
|
|
|
1545
1512
|
const Checkbox = (props) => {
|
|
1513
|
+
var _a;
|
|
1546
1514
|
const { onChange, label, checkedIcon, uncheckedIcon, checkedThemeColor, checkedColor, readOnly } = props, inputProps = __rest(props, ["onChange", "label", "checkedIcon", "uncheckedIcon", "checkedThemeColor", "checkedColor", "readOnly"]);
|
|
1547
1515
|
const selected = checkedIcon || 'selected';
|
|
1548
1516
|
const unselected = uncheckedIcon || 'unselected';
|
|
@@ -1607,7 +1575,7 @@ const Checkbox = (props) => {
|
|
|
1607
1575
|
`;
|
|
1608
1576
|
return (React__namespace.createElement("span", { className: css.cx('checkbox', checkboxStyles, props.className) },
|
|
1609
1577
|
React__namespace.createElement("label", { className: labelStyles },
|
|
1610
|
-
React__namespace.createElement("input", Object.assign({}, inputProps, { tabIndex: readOnly ? -1 : undefined, className: nativeCheckboxStyles, type: "checkbox", onChange: e => {
|
|
1578
|
+
React__namespace.createElement("input", Object.assign({}, inputProps, { tabIndex: readOnly ? -1 : (_a = props.tabIndex) !== null && _a !== void 0 ? _a : undefined, className: nativeCheckboxStyles, type: "checkbox", onChange: e => {
|
|
1611
1579
|
if (readOnly) {
|
|
1612
1580
|
e.preventDefault();
|
|
1613
1581
|
return;
|
|
@@ -4002,7 +3970,7 @@ const Slider = (p) => {
|
|
|
4002
3970
|
}), specificThumbStyles, p.handleClassName, css.css({
|
|
4003
3971
|
width: sliderHandleSize,
|
|
4004
3972
|
height: sliderHandleSize,
|
|
4005
|
-
})) }, rest), p.showValue && (React.createElement(HandleText, { sliderHandleSize: sliderHandleSize, className: p.sliderTextClassName, index: state.index, parentElement: sliderContainer.current, value: Array.isArray(currentValue.current) ? currentValue.current[state.index] : currentValue.current, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth }))));
|
|
3973
|
+
})) }, rest, { tabIndex: p.tabIndex }), p.showValue && (React.createElement(HandleText, { sliderHandleSize: sliderHandleSize, className: p.sliderTextClassName, index: state.index, parentElement: sliderContainer.current, value: Array.isArray(currentValue.current) ? currentValue.current[state.index] : currentValue.current, renderValue: p.renderValue, renderValueWidth: p.renderValueWidth }))));
|
|
4006
3974
|
} })));
|
|
4007
3975
|
};
|
|
4008
3976
|
const rectsCollideX = (r1, r2) => {
|