@papillonbits/components 1.13.0 → 1.14.0
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/build/index.js +1 -12
- package/build/primer/Alert/Alert.js +82 -94
- package/build/primer/Alert/Alert.prop.js +19 -25
- package/build/primer/Alert/index.js +2 -19
- package/build/primer/Blankslate/Blankslate.js +22 -26
- package/build/primer/Blankslate/Blankslate.prop.js +11 -17
- package/build/primer/Blankslate/index.js +2 -19
- package/build/primer/Breadcrumb/Breadcrumb.js +59 -61
- package/build/primer/Breadcrumb/Breadcrumb.prop.js +14 -20
- package/build/primer/Breadcrumb/index.js +2 -19
- package/build/primer/Button/Button.js +63 -72
- package/build/primer/Button/Button.prop.js +27 -33
- package/build/primer/Button/index.js +2 -49
- package/build/primer/Dropdown/Dropdown.js +79 -85
- package/build/primer/Dropdown/Dropdown.prop.js +15 -21
- package/build/primer/Dropdown/index.js +2 -19
- package/build/primer/ErrorBoundary/ErrorBoundary.js +35 -55
- package/build/primer/ErrorBoundary/ErrorBoundary.prop.js +4 -10
- package/build/primer/ErrorBoundary/index.js +1 -12
- package/build/primer/Form/Checkbox/Checkbox.js +29 -39
- package/build/primer/Form/Checkbox/Checkbox.prop.js +15 -21
- package/build/primer/Form/Checkbox/index.js +2 -19
- package/build/primer/Form/Input/Input.js +29 -43
- package/build/primer/Form/Input/Input.prop.js +19 -25
- package/build/primer/Form/Input/index.js +2 -25
- package/build/primer/Form/Radio/Radio.js +26 -38
- package/build/primer/Form/Radio/Radio.prop.js +14 -20
- package/build/primer/Form/Radio/index.js +2 -19
- package/build/primer/Form/index.js +11 -17
- package/build/primer/Grid/DisplayTable/DisplayTable.js +44 -54
- package/build/primer/Grid/DisplayTable/DisplayTable.prop.js +7 -13
- package/build/primer/Grid/DisplayTable/index.js +1 -12
- package/build/primer/Grid/FlexGrid/FlexGrid.js +186 -207
- package/build/primer/Grid/FlexGrid/FlexGrid.prop.js +24 -30
- package/build/primer/Grid/FlexGrid/index.js +2 -25
- package/build/primer/Grid/index.js +7 -13
- package/build/primer/Icon/Icon.js +35 -52
- package/build/primer/Icon/Icon.part.js +1287 -1294
- package/build/primer/Icon/Icon.prop.js +20 -26
- package/build/primer/Icon/index.js +2 -25
- package/build/primer/Label/Label.js +22 -28
- package/build/primer/Label/Label.prop.js +11 -17
- package/build/primer/Label/index.js +1 -12
- package/build/primer/Loader/Loader.js +38 -45
- package/build/primer/Loader/Loader.prop.js +7 -13
- package/build/primer/Loader/index.js +2 -19
- package/build/primer/Navigation/Menu/Menu.js +52 -59
- package/build/primer/Navigation/Menu/Menu.prop.js +16 -22
- package/build/primer/Navigation/Menu/index.js +1 -12
- package/build/primer/Navigation/TabNav/TabNav.js +89 -94
- package/build/primer/Navigation/TabNav/TabNav.prop.js +19 -25
- package/build/primer/Navigation/TabNav/index.js +2 -19
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.js +82 -86
- package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.js +21 -27
- package/build/primer/Navigation/UnderlineNav/index.js +2 -25
- package/build/primer/Navigation/index.js +10 -16
- package/build/primer/Pagination/PreviousNext/PreviousNext.js +53 -54
- package/build/primer/Pagination/PreviousNext/PreviousNext.prop.js +22 -28
- package/build/primer/Pagination/PreviousNext/index.js +2 -19
- package/build/primer/Pagination/index.js +4 -10
- package/build/primer/Popover/Popover.js +59 -50
- package/build/primer/Popover/Popover.prop.js +16 -22
- package/build/primer/Popover/index.js +2 -25
- package/build/primer/Progress/Progress.js +20 -26
- package/build/primer/Progress/Progress.prop.js +7 -13
- package/build/primer/Progress/index.js +2 -19
- package/build/primer/Select/Select.js +43 -51
- package/build/primer/Select/Select.prop.js +12 -18
- package/build/primer/Select/index.js +2 -19
- package/build/primer/SelectMenu/SelectMenu.js +65 -74
- package/build/primer/SelectMenu/SelectMenu.prop.js +14 -20
- package/build/primer/SelectMenu/index.js +1 -12
- package/build/primer/Subhead/Subhead.js +16 -23
- package/build/primer/Subhead/Subhead.prop.js +6 -12
- package/build/primer/Subhead/index.js +1 -12
- package/build/primer/Toast/Toast.js +39 -46
- package/build/primer/Toast/Toast.prop.js +10 -16
- package/build/primer/Toast/index.js +2 -19
- package/build/primer/index.js +58 -64
- package/package.json +4 -4
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.propTypes = exports.iconSizeKeysDefault = exports.iconSizeKeys = exports.iconSize = exports.iconNameKeysDefault = exports.iconNameKeys = exports.iconName = exports.iconAlignKeysDefault = exports.iconAlignKeys = exports.iconAlign = exports.defaultProps = void 0;
|
|
7
|
-
var _propTypes = require("prop-types");
|
|
8
|
-
var iconName = exports.iconName = {
|
|
1
|
+
import { string, number, oneOfType, oneOf } from 'prop-types';
|
|
2
|
+
export const iconName = {
|
|
9
3
|
Accessibility16: 'Accessibility16',
|
|
10
4
|
Accessibility24: 'Accessibility24',
|
|
11
5
|
AccessibilityInset16: 'AccessibilityInset16',
|
|
@@ -650,35 +644,35 @@ var iconName = exports.iconName = {
|
|
|
650
644
|
ZoomOut16: 'ZoomOut16',
|
|
651
645
|
ZoomOut24: 'ZoomOut24'
|
|
652
646
|
};
|
|
653
|
-
|
|
647
|
+
export const iconSize = {
|
|
654
648
|
small: 16,
|
|
655
649
|
medium: 32,
|
|
656
650
|
large: 64
|
|
657
651
|
};
|
|
658
|
-
|
|
652
|
+
export const iconAlign = {
|
|
659
653
|
middle: 'middle',
|
|
660
654
|
'text-bottom': 'text-bottom',
|
|
661
655
|
'text-top': 'text-top',
|
|
662
656
|
top: 'top',
|
|
663
657
|
unset: 'unset'
|
|
664
658
|
};
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
className:
|
|
673
|
-
ariaLabel:
|
|
674
|
-
icon:
|
|
675
|
-
height:
|
|
676
|
-
width:
|
|
677
|
-
size:
|
|
678
|
-
fill:
|
|
679
|
-
verticalAlign:
|
|
659
|
+
export const iconNameKeys = Object.keys(iconName);
|
|
660
|
+
export const iconNameKeysDefault = iconNameKeys[0];
|
|
661
|
+
export const iconSizeKeys = Object.keys(iconSize);
|
|
662
|
+
export const iconSizeKeysDefault = iconSizeKeys[0];
|
|
663
|
+
export const iconAlignKeys = Object.keys(iconAlign);
|
|
664
|
+
export const iconAlignKeysDefault = iconAlignKeys[0];
|
|
665
|
+
export const propTypes = {
|
|
666
|
+
className: string,
|
|
667
|
+
ariaLabel: string,
|
|
668
|
+
icon: oneOf(iconNameKeys).isRequired,
|
|
669
|
+
height: number,
|
|
670
|
+
width: number,
|
|
671
|
+
size: oneOfType([number, oneOf(iconSizeKeys)]),
|
|
672
|
+
fill: string,
|
|
673
|
+
verticalAlign: oneOf(iconAlignKeys)
|
|
680
674
|
};
|
|
681
|
-
|
|
675
|
+
export const defaultProps = {
|
|
682
676
|
className: 'octicon',
|
|
683
677
|
ariaLabel: null,
|
|
684
678
|
height: null,
|
|
@@ -1,25 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Icon", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _Icon.Icon;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "iconName", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _Icon2.iconName;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "iconSize", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _Icon2.iconSize;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
var _Icon = require("./Icon");
|
|
25
|
-
var _Icon2 = require("./Icon.prop");
|
|
1
|
+
export { Icon } from './Icon';
|
|
2
|
+
export { iconName, iconSize } from './Icon.prop';
|
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
backgroundColor = _ref$backgroundColor === void 0 ? _Label.defaultProps.backgroundColor : _ref$backgroundColor,
|
|
23
|
-
_ref$textColor = _ref.textColor,
|
|
24
|
-
textColor = _ref$textColor === void 0 ? _Label.defaultProps.textColor : _ref$textColor;
|
|
25
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
26
|
-
title: "Label: ".concat(text),
|
|
27
|
-
className: (0, _classnames["default"])(className, (0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, _labels["default"].Label, variant === _Label.labelVariant.regular), _issueLabels["default"].IssueLabel, variant === _Label.labelVariant.issue), _colors["default"]['bg-blue'], backgroundColor === _Label.labelBackgroundColor.blue), _colors["default"]['text-white'], textColor === _Label.labelTextColor.white)),
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import colorStyles from '@papillonbits/css/build/primer/utilities/colors.scss';
|
|
3
|
+
import { propTypes, defaultProps, labelVariant, labelBackgroundColor, labelTextColor } from './Label.prop';
|
|
4
|
+
import labelsStyles from './labels.scss';
|
|
5
|
+
import issueLabelsStyles from './issue-labels.scss';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export function Label({
|
|
8
|
+
className = defaultProps.className,
|
|
9
|
+
text,
|
|
10
|
+
variant = defaultProps.variant,
|
|
11
|
+
backgroundColor = defaultProps.backgroundColor,
|
|
12
|
+
textColor = defaultProps.textColor
|
|
13
|
+
}) {
|
|
14
|
+
return /*#__PURE__*/_jsx("span", {
|
|
15
|
+
title: `Label: ${text}`,
|
|
16
|
+
className: cx(className, {
|
|
17
|
+
[labelsStyles.Label]: variant === labelVariant.regular,
|
|
18
|
+
[issueLabelsStyles.IssueLabel]: variant === labelVariant.issue,
|
|
19
|
+
[colorStyles['bg-blue']]: backgroundColor === labelBackgroundColor.blue,
|
|
20
|
+
[colorStyles['text-white']]: textColor === labelTextColor.white
|
|
21
|
+
}),
|
|
28
22
|
children: text
|
|
29
23
|
});
|
|
30
24
|
}
|
|
31
|
-
Label.propTypes =
|
|
25
|
+
Label.propTypes = propTypes;
|
|
@@ -1,32 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.propTypes = exports.labelVariant = exports.labelTextColor = exports.labelBackgroundColor = exports.defaultProps = void 0;
|
|
7
|
-
var _propTypes = require("prop-types");
|
|
8
|
-
var labelVariant = exports.labelVariant = {
|
|
1
|
+
import { string, oneOf } from 'prop-types';
|
|
2
|
+
export const labelVariant = {
|
|
9
3
|
regular: 'regular',
|
|
10
4
|
state: 'state',
|
|
11
5
|
counter: 'counter',
|
|
12
6
|
issue: 'issue'
|
|
13
7
|
};
|
|
14
|
-
|
|
8
|
+
export const labelBackgroundColor = {
|
|
15
9
|
blue: 'blue',
|
|
16
10
|
red: 'red',
|
|
17
11
|
green: 'green'
|
|
18
12
|
};
|
|
19
|
-
|
|
13
|
+
export const labelTextColor = {
|
|
20
14
|
white: 'white'
|
|
21
15
|
};
|
|
22
|
-
|
|
23
|
-
className:
|
|
24
|
-
text:
|
|
25
|
-
variant:
|
|
26
|
-
backgroundColor:
|
|
27
|
-
textColor:
|
|
16
|
+
export const propTypes = {
|
|
17
|
+
className: string,
|
|
18
|
+
text: string.isRequired,
|
|
19
|
+
variant: oneOf(Object.keys(labelVariant)),
|
|
20
|
+
backgroundColor: oneOf(Object.keys(labelBackgroundColor)),
|
|
21
|
+
textColor: oneOf(Object.keys(labelTextColor))
|
|
28
22
|
};
|
|
29
|
-
|
|
23
|
+
export const defaultProps = {
|
|
30
24
|
className: null,
|
|
31
25
|
variant: labelVariant.issue,
|
|
32
26
|
backgroundColor: labelBackgroundColor.blue,
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Label", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _Label.Label;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _Label = require("./Label");
|
|
1
|
+
export { Label } from './Label';
|
|
@@ -1,65 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _labels = _interopRequireDefault(require("../Label/labels.scss"));
|
|
16
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
function Loader(_ref) {
|
|
18
|
-
var _ref$className = _ref.className,
|
|
19
|
-
className = _ref$className === void 0 ? _Loader.defaultProps.className : _ref$className,
|
|
20
|
-
variant = _ref.variant,
|
|
21
|
-
text = _ref.text;
|
|
1
|
+
import cx from 'classnames';
|
|
2
|
+
import colorStyles from '@papillonbits/css/build/primer/utilities/colors.scss';
|
|
3
|
+
import marginStyles from '@papillonbits/css/build/primer/utilities/margin.scss';
|
|
4
|
+
import { propTypes, defaultProps, loaderVariant } from './Loader.prop';
|
|
5
|
+
import styles from './Loader.scss';
|
|
6
|
+
import branchNameStyles from '../BranchName/branch-name.scss';
|
|
7
|
+
import buttonStyles from '../Button/Button.scss';
|
|
8
|
+
import labelStyles from '../Label/labels.scss';
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
export function Loader({
|
|
11
|
+
className = defaultProps.className,
|
|
12
|
+
variant,
|
|
13
|
+
text
|
|
14
|
+
}) {
|
|
22
15
|
switch (variant) {
|
|
23
|
-
case
|
|
24
|
-
return /*#__PURE__*/(
|
|
16
|
+
case loaderVariant.heading:
|
|
17
|
+
return /*#__PURE__*/_jsxs("h2", {
|
|
25
18
|
className: className,
|
|
26
|
-
children: [/*#__PURE__*/(
|
|
19
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
27
20
|
children: text
|
|
28
|
-
}), /*#__PURE__*/(
|
|
29
|
-
className:
|
|
21
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
22
|
+
className: styles.AnimatedEllipsis
|
|
30
23
|
})]
|
|
31
24
|
});
|
|
32
|
-
case
|
|
33
|
-
return /*#__PURE__*/(
|
|
34
|
-
className: (
|
|
35
|
-
children: [/*#__PURE__*/(
|
|
25
|
+
case loaderVariant.text:
|
|
26
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
27
|
+
className: cx(branchNameStyles['branch-name'], marginStyles['mt-2']),
|
|
28
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
36
29
|
children: text
|
|
37
|
-
}), /*#__PURE__*/(
|
|
38
|
-
className:
|
|
30
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
31
|
+
className: styles.AnimatedEllipsis
|
|
39
32
|
})]
|
|
40
33
|
});
|
|
41
|
-
case
|
|
42
|
-
return /*#__PURE__*/(
|
|
43
|
-
className: (
|
|
44
|
-
children: [/*#__PURE__*/(
|
|
34
|
+
case loaderVariant.label:
|
|
35
|
+
return /*#__PURE__*/_jsxs("span", {
|
|
36
|
+
className: cx(labelStyles.Label, colorStyles['bg-blue'], marginStyles['mt-3']),
|
|
37
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
45
38
|
children: text
|
|
46
|
-
}), /*#__PURE__*/(
|
|
47
|
-
className:
|
|
39
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
40
|
+
className: styles.AnimatedEllipsis
|
|
48
41
|
})]
|
|
49
42
|
});
|
|
50
|
-
case
|
|
51
|
-
return /*#__PURE__*/(
|
|
43
|
+
case loaderVariant.button:
|
|
44
|
+
return /*#__PURE__*/_jsxs("button", {
|
|
52
45
|
type: "button",
|
|
53
|
-
className: (
|
|
46
|
+
className: cx(buttonStyles.btn, marginStyles['mt-3']),
|
|
54
47
|
"aria-disabled": "true",
|
|
55
|
-
children: [/*#__PURE__*/(
|
|
48
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
56
49
|
children: text
|
|
57
|
-
}), /*#__PURE__*/(
|
|
58
|
-
className:
|
|
50
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
51
|
+
className: styles.AnimatedEllipsis
|
|
59
52
|
})]
|
|
60
53
|
});
|
|
61
54
|
default:
|
|
62
55
|
return null;
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
|
-
Loader.propTypes =
|
|
58
|
+
Loader.propTypes = propTypes;
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.propTypes = exports.loaderVariant = exports.defaultProps = void 0;
|
|
7
|
-
var _propTypes = require("prop-types");
|
|
8
|
-
var loaderVariant = exports.loaderVariant = {
|
|
1
|
+
import { string, oneOf } from 'prop-types';
|
|
2
|
+
export const loaderVariant = {
|
|
9
3
|
heading: 'heading',
|
|
10
4
|
text: 'text',
|
|
11
5
|
label: 'label',
|
|
12
6
|
button: 'button'
|
|
13
7
|
};
|
|
14
|
-
|
|
15
|
-
className:
|
|
16
|
-
variant:
|
|
17
|
-
text:
|
|
8
|
+
export const propTypes = {
|
|
9
|
+
className: string,
|
|
10
|
+
variant: oneOf(Object.keys(loaderVariant)).isRequired,
|
|
11
|
+
text: string.isRequired
|
|
18
12
|
};
|
|
19
|
-
|
|
13
|
+
export const defaultProps = {
|
|
20
14
|
className: null
|
|
21
15
|
};
|
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Loader", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _Loader.Loader;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "loaderVariant", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _Loader2.loaderVariant;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
var _Loader = require("./Loader");
|
|
19
|
-
var _Loader2 = require("./Loader.prop");
|
|
1
|
+
export { Loader } from './Loader';
|
|
2
|
+
export { loaderVariant } from './Loader.prop';
|
|
@@ -1,70 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
items = _ref.items,
|
|
27
|
-
_onClick = _ref.onClick;
|
|
28
|
-
var _useState = (0, _hooks.useState)((0, _array.getIndexItems)(items)),
|
|
29
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
30
|
-
indexItems = _useState2[0],
|
|
31
|
-
setIndexItems = _useState2[1];
|
|
32
|
-
var label = ariaAttr.label,
|
|
33
|
-
labelledBy = ariaAttr.labelledBy,
|
|
34
|
-
current = ariaAttr.current;
|
|
35
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("nav", {
|
|
36
|
-
className: (0, _classnames["default"])(className, _Menu2["default"].menu),
|
|
1
|
+
import "core-js/modules/es.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/es.iterator.map.js";
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { v1 as uuidv1 } from 'uuid';
|
|
5
|
+
import { getIndexItems, getIndexItemsWithSelected } from '@papillonbits/library/array';
|
|
6
|
+
import { useState } from '@papillonbits/library/hooks';
|
|
7
|
+
import { propTypes, defaultProps } from './Menu.prop';
|
|
8
|
+
import styles from './Menu.scss';
|
|
9
|
+
import { Icon, iconSize } from '../../Icon';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
export function Menu({
|
|
12
|
+
className = defaultProps.className,
|
|
13
|
+
heading = defaultProps.heading,
|
|
14
|
+
ariaAttr,
|
|
15
|
+
items,
|
|
16
|
+
onClick
|
|
17
|
+
}) {
|
|
18
|
+
const [indexItems, setIndexItems] = useState(getIndexItems(items));
|
|
19
|
+
const {
|
|
20
|
+
label,
|
|
21
|
+
labelledBy,
|
|
22
|
+
current
|
|
23
|
+
} = ariaAttr;
|
|
24
|
+
return /*#__PURE__*/_jsxs("nav", {
|
|
25
|
+
className: cx(className, styles.menu),
|
|
37
26
|
"aria-label": label,
|
|
38
27
|
"aria-labelledby": labelledBy,
|
|
39
|
-
children: [heading && /*#__PURE__*/(
|
|
40
|
-
className:
|
|
28
|
+
children: [heading && /*#__PURE__*/_jsx("span", {
|
|
29
|
+
className: styles['menu-heading'],
|
|
41
30
|
children: heading
|
|
42
|
-
}), indexItems.map(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
}), indexItems.map(indexItem => {
|
|
32
|
+
const {
|
|
33
|
+
href,
|
|
34
|
+
icon,
|
|
35
|
+
text,
|
|
36
|
+
html,
|
|
37
|
+
isSelected
|
|
38
|
+
} = indexItem;
|
|
39
|
+
const itemOtherProps = isSelected ? {
|
|
40
|
+
...{
|
|
41
|
+
'aria-current': current
|
|
42
|
+
}
|
|
43
|
+
} : null;
|
|
44
|
+
return /*#__PURE__*/_jsxs("a", {
|
|
45
|
+
onClick: e => {
|
|
53
46
|
e.preventDefault();
|
|
54
|
-
|
|
47
|
+
const newIndexItems = getIndexItemsWithSelected(indexItems, indexItem);
|
|
55
48
|
setIndexItems(newIndexItems);
|
|
56
|
-
|
|
49
|
+
onClick(newIndexItems);
|
|
57
50
|
},
|
|
58
|
-
className:
|
|
59
|
-
href: href
|
|
60
|
-
|
|
61
|
-
children: [icon && /*#__PURE__*/(
|
|
62
|
-
className:
|
|
51
|
+
className: styles['menu-item'],
|
|
52
|
+
href: href,
|
|
53
|
+
...itemOtherProps,
|
|
54
|
+
children: [icon && /*#__PURE__*/_jsx(Icon, {
|
|
55
|
+
className: styles.octicon,
|
|
63
56
|
icon: icon,
|
|
64
|
-
size:
|
|
57
|
+
size: iconSize.small
|
|
65
58
|
}), html || null, text]
|
|
66
|
-
}
|
|
59
|
+
}, uuidv1());
|
|
67
60
|
})]
|
|
68
61
|
});
|
|
69
62
|
}
|
|
70
|
-
Menu.propTypes =
|
|
63
|
+
Menu.propTypes = propTypes;
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
className: _propTypes.string,
|
|
10
|
-
heading: _propTypes.string,
|
|
11
|
-
ariaAttr: (0, _propTypes.shape)({
|
|
12
|
-
label: _propTypes.string,
|
|
13
|
-
labelledBy: _propTypes.string,
|
|
14
|
-
current: _propTypes.string
|
|
1
|
+
import { string, arrayOf, shape, node, bool, func } from 'prop-types';
|
|
2
|
+
export const propTypes = {
|
|
3
|
+
className: string,
|
|
4
|
+
heading: string,
|
|
5
|
+
ariaAttr: shape({
|
|
6
|
+
label: string,
|
|
7
|
+
labelledBy: string,
|
|
8
|
+
current: string
|
|
15
9
|
}).isRequired,
|
|
16
|
-
items:
|
|
17
|
-
href:
|
|
18
|
-
icon:
|
|
19
|
-
text:
|
|
20
|
-
html:
|
|
21
|
-
isSelected:
|
|
10
|
+
items: arrayOf(shape({
|
|
11
|
+
href: string,
|
|
12
|
+
icon: string,
|
|
13
|
+
text: string,
|
|
14
|
+
html: node,
|
|
15
|
+
isSelected: bool
|
|
22
16
|
})).isRequired,
|
|
23
|
-
onClick:
|
|
17
|
+
onClick: func.isRequired
|
|
24
18
|
};
|
|
25
|
-
|
|
19
|
+
export const defaultProps = {
|
|
26
20
|
className: null,
|
|
27
21
|
heading: null
|
|
28
22
|
};
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Menu", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _Menu.Menu;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _Menu = require("./Menu");
|
|
1
|
+
export { Menu } from './Menu';
|