@zendeskgarden/react-buttons 9.0.0-next.1 → 9.0.0-next.11

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.
Files changed (35) hide show
  1. package/README.md +0 -27
  2. package/dist/esm/elements/Anchor.js +54 -0
  3. package/dist/esm/elements/Button.js +49 -0
  4. package/dist/esm/elements/ChevronButton.js +27 -0
  5. package/dist/esm/elements/IconButton.js +50 -0
  6. package/dist/esm/elements/SplitButton.js +29 -0
  7. package/dist/esm/elements/ToggleButton.js +30 -0
  8. package/dist/esm/elements/ToggleIconButton.js +32 -0
  9. package/dist/esm/elements/components/EndIcon.js +28 -0
  10. package/dist/esm/elements/components/StartIcon.js +28 -0
  11. package/dist/esm/index.js +13 -0
  12. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/12/new-window-stroke.svg.js +27 -0
  13. package/dist/esm/node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js +25 -0
  14. package/dist/esm/styled/StyledAnchor.js +27 -0
  15. package/dist/esm/styled/StyledButton.js +316 -0
  16. package/dist/esm/styled/StyledExternalIcon.js +23 -0
  17. package/dist/esm/styled/StyledIcon.js +31 -0
  18. package/dist/esm/styled/StyledIconButton.js +61 -0
  19. package/dist/esm/styled/StyledSplitButton.js +22 -0
  20. package/dist/esm/types/index.js +9 -0
  21. package/dist/esm/utils/useSplitButtonContext.js +14 -0
  22. package/dist/index.cjs.js +296 -195
  23. package/dist/typings/elements/Button.d.ts +1 -7
  24. package/dist/typings/elements/components/EndIcon.d.ts +1 -1
  25. package/dist/typings/elements/components/StartIcon.d.ts +1 -1
  26. package/dist/typings/index.d.ts +2 -3
  27. package/dist/typings/styled/StyledAnchor.d.ts +1 -1
  28. package/dist/typings/styled/StyledIcon.d.ts +4 -4
  29. package/dist/typings/styled/{StyledButtonGroup.d.ts → StyledSplitButton.d.ts} +1 -1
  30. package/dist/typings/styled/index.d.ts +1 -1
  31. package/dist/typings/types/index.d.ts +1 -13
  32. package/package.json +6 -7
  33. package/dist/index.esm.js +0 -559
  34. package/dist/typings/elements/ButtonGroup.d.ts +0 -14
  35. package/dist/typings/utils/useButtonGroupContext.d.ts +0 -14
package/README.md CHANGED
@@ -57,30 +57,3 @@ const MediaButton = ({ children, ...props }) => {
57
57
  );
58
58
  };
59
59
  ```
60
-
61
- ### Button group
62
-
63
- ```jsx
64
- import React, { useState } from 'react';
65
- import { ButtonGroup, Button } from '@zendeskgarden/react-buttons';
66
-
67
- const MyButtonGroup = ({ children, initialItem, ...props }) => {
68
- const [selectedItem, setSelectedItem] = useState(initialItem);
69
-
70
- return (
71
- <ButtonGroup
72
- selectedItem={selectedItem}
73
- onSelect={selectedItem => setSelectedItem(selectedItem)}
74
- {...props}
75
- >
76
- {children}
77
- </ButtonGroup>
78
- );
79
- };
80
-
81
- <MyButtonGroup initialKey="item-1">
82
- <Button key="item-1">Item 1</Button>
83
- <Button key="item-2">Item 2</Button>
84
- <Button key="item-3">Item 3</Button>
85
- </MyButtonGroup>;
86
- ```
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default, { forwardRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { StyledAnchor } from '../styled/StyledAnchor.js';
10
+ import '../styled/StyledButton.js';
11
+ import '../styled/StyledSplitButton.js';
12
+ import { StyledExternalIcon } from '../styled/StyledExternalIcon.js';
13
+ import '../styled/StyledIcon.js';
14
+ import '../styled/StyledIconButton.js';
15
+ import { useText } from '@zendeskgarden/react-theming';
16
+
17
+ const Anchor = forwardRef((_ref, ref) => {
18
+ let {
19
+ children,
20
+ isExternal,
21
+ externalIconLabel,
22
+ ...otherProps
23
+ } = _ref;
24
+ let anchorProps = otherProps;
25
+ if (isExternal) {
26
+ anchorProps = {
27
+ target: '_blank',
28
+ rel: 'noopener noreferrer',
29
+ ...anchorProps
30
+ };
31
+ }
32
+ const checkProps = isExternal ? {
33
+ externalIconLabel
34
+ } : {
35
+ noIconLabel: 'true'
36
+ };
37
+ const iconAriaLabel = useText(Anchor, checkProps, isExternal ? 'externalIconLabel' : 'noIconLabel', '(opens in a new tab)');
38
+ return React__default.createElement(StyledAnchor, Object.assign({
39
+ ref: ref
40
+ }, anchorProps), children, isExternal &&
41
+ React__default.createElement(StyledExternalIcon, {
42
+ role: "img",
43
+ "aria-label": iconAriaLabel,
44
+ "aria-hidden": undefined
45
+ }));
46
+ });
47
+ Anchor.displayName = 'Anchor';
48
+ Anchor.propTypes = {
49
+ isExternal: PropTypes.bool,
50
+ isDanger: PropTypes.bool,
51
+ externalIconLabel: PropTypes.string
52
+ };
53
+
54
+ export { Anchor };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default, { forwardRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { SIZE } from '../types/index.js';
10
+ import '../styled/StyledAnchor.js';
11
+ import { StyledButton } from '../styled/StyledButton.js';
12
+ import '../styled/StyledSplitButton.js';
13
+ import '../styled/StyledExternalIcon.js';
14
+ import '../styled/StyledIcon.js';
15
+ import '../styled/StyledIconButton.js';
16
+ import { useSplitButtonContext } from '../utils/useSplitButtonContext.js';
17
+ import { StartIcon } from './components/StartIcon.js';
18
+ import { EndIcon } from './components/EndIcon.js';
19
+
20
+ const ButtonComponent = forwardRef((props, ref) => {
21
+ const splitButtonContext = useSplitButtonContext();
22
+ const computedProps = {
23
+ ...props,
24
+ focusInset: props.focusInset || splitButtonContext
25
+ };
26
+ return React__default.createElement(StyledButton, Object.assign({}, computedProps, {
27
+ ref: ref
28
+ }));
29
+ });
30
+ ButtonComponent.displayName = 'Button';
31
+ ButtonComponent.propTypes = {
32
+ isNeutral: PropTypes.bool,
33
+ isPrimary: PropTypes.bool,
34
+ isDanger: PropTypes.bool,
35
+ isPill: PropTypes.bool,
36
+ isBasic: PropTypes.bool,
37
+ focusInset: PropTypes.bool,
38
+ isLink: PropTypes.bool,
39
+ isStretched: PropTypes.bool,
40
+ size: PropTypes.oneOf(SIZE)
41
+ };
42
+ ButtonComponent.defaultProps = {
43
+ size: 'medium'
44
+ };
45
+ const Button = ButtonComponent;
46
+ Button.EndIcon = EndIcon;
47
+ Button.StartIcon = StartIcon;
48
+
49
+ export { Button };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default, { forwardRef } from 'react';
8
+ import { IconButton } from './IconButton.js';
9
+ import SvgChevronDownStroke from '../node_modules/@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg.js';
10
+
11
+ const ChevronButton = forwardRef((_ref, ref) => {
12
+ let {
13
+ ...buttonProps
14
+ } = _ref;
15
+ return React__default.createElement(IconButton, Object.assign({
16
+ ref: ref
17
+ }, buttonProps), React__default.createElement(SvgChevronDownStroke, null));
18
+ });
19
+ ChevronButton.displayName = 'ChevronButton';
20
+ ChevronButton.propTypes = IconButton.propTypes;
21
+ ChevronButton.defaultProps = {
22
+ isBasic: false,
23
+ isPill: false,
24
+ size: 'medium'
25
+ };
26
+
27
+ export { ChevronButton };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default, { forwardRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { SIZE } from '../types/index.js';
10
+ import '../styled/StyledAnchor.js';
11
+ import '../styled/StyledButton.js';
12
+ import '../styled/StyledSplitButton.js';
13
+ import '../styled/StyledExternalIcon.js';
14
+ import { StyledIcon } from '../styled/StyledIcon.js';
15
+ import { StyledIconButton } from '../styled/StyledIconButton.js';
16
+ import { useSplitButtonContext } from '../utils/useSplitButtonContext.js';
17
+
18
+ const IconButton = forwardRef((_ref, ref) => {
19
+ let {
20
+ children,
21
+ isRotated,
22
+ ...otherProps
23
+ } = _ref;
24
+ const focusInset = useSplitButtonContext();
25
+ return React__default.createElement(StyledIconButton, Object.assign({
26
+ ref: ref
27
+ }, otherProps, {
28
+ focusInset: otherProps.focusInset || focusInset
29
+ }), React__default.createElement(StyledIcon, {
30
+ $isRotated: isRotated
31
+ }, children));
32
+ });
33
+ IconButton.displayName = 'IconButton';
34
+ IconButton.propTypes = {
35
+ isDanger: PropTypes.bool,
36
+ size: PropTypes.oneOf(SIZE),
37
+ isNeutral: PropTypes.bool,
38
+ isPrimary: PropTypes.bool,
39
+ isBasic: PropTypes.bool,
40
+ isPill: PropTypes.bool,
41
+ focusInset: PropTypes.bool,
42
+ isRotated: PropTypes.bool
43
+ };
44
+ IconButton.defaultProps = {
45
+ isPill: true,
46
+ isBasic: true,
47
+ size: 'medium'
48
+ };
49
+
50
+ export { IconButton };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default, { forwardRef } from 'react';
8
+ import '../styled/StyledAnchor.js';
9
+ import '../styled/StyledButton.js';
10
+ import { StyledSplitButton } from '../styled/StyledSplitButton.js';
11
+ import '../styled/StyledExternalIcon.js';
12
+ import '../styled/StyledIcon.js';
13
+ import '../styled/StyledIconButton.js';
14
+ import { SplitButtonContext } from '../utils/useSplitButtonContext.js';
15
+
16
+ const SplitButton = forwardRef((_ref, ref) => {
17
+ let {
18
+ children,
19
+ ...other
20
+ } = _ref;
21
+ return React__default.createElement(SplitButtonContext.Provider, {
22
+ value: true
23
+ }, React__default.createElement(StyledSplitButton, Object.assign({
24
+ ref: ref
25
+ }, other), children));
26
+ });
27
+ SplitButton.displayName = 'SplitButton';
28
+
29
+ export { SplitButton };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default, { forwardRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { Button } from './Button.js';
10
+
11
+ const ToggleButton = forwardRef((_ref, ref) => {
12
+ let {
13
+ isPressed,
14
+ ...otherProps
15
+ } = _ref;
16
+ return React__default.createElement(Button, Object.assign({
17
+ "aria-pressed": isPressed,
18
+ ref: ref
19
+ }, otherProps));
20
+ });
21
+ ToggleButton.displayName = 'ToggleButton';
22
+ ToggleButton.propTypes = {
23
+ ...Button.propTypes,
24
+ isPressed: PropTypes.oneOf([true, false, 'mixed'])
25
+ };
26
+ ToggleButton.defaultProps = {
27
+ size: 'medium'
28
+ };
29
+
30
+ export { ToggleButton };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default, { forwardRef } from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { IconButton } from './IconButton.js';
10
+
11
+ const ToggleIconButton = forwardRef((_ref, ref) => {
12
+ let {
13
+ isPressed,
14
+ ...otherProps
15
+ } = _ref;
16
+ return React__default.createElement(IconButton, Object.assign({
17
+ "aria-pressed": isPressed,
18
+ ref: ref
19
+ }, otherProps));
20
+ });
21
+ ToggleIconButton.displayName = 'ToggleIconButton';
22
+ ToggleIconButton.propTypes = {
23
+ ...IconButton.propTypes,
24
+ isPressed: PropTypes.oneOf([true, false, 'mixed'])
25
+ };
26
+ ToggleIconButton.defaultProps = {
27
+ isPill: true,
28
+ isBasic: true,
29
+ size: 'medium'
30
+ };
31
+
32
+ export { ToggleIconButton };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default from 'react';
8
+ import '../../styled/StyledAnchor.js';
9
+ import '../../styled/StyledButton.js';
10
+ import '../../styled/StyledSplitButton.js';
11
+ import '../../styled/StyledExternalIcon.js';
12
+ import { StyledIcon } from '../../styled/StyledIcon.js';
13
+ import '../../styled/StyledIconButton.js';
14
+
15
+ const EndIconComponent = _ref => {
16
+ let {
17
+ isRotated,
18
+ ...props
19
+ } = _ref;
20
+ return React__default.createElement(StyledIcon, Object.assign({
21
+ $position: "end",
22
+ $isRotated: isRotated
23
+ }, props));
24
+ };
25
+ EndIconComponent.displayName = 'Button.EndIcon';
26
+ const EndIcon = EndIconComponent;
27
+
28
+ export { EndIcon };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import React__default from 'react';
8
+ import '../../styled/StyledAnchor.js';
9
+ import '../../styled/StyledButton.js';
10
+ import '../../styled/StyledSplitButton.js';
11
+ import '../../styled/StyledExternalIcon.js';
12
+ import { StyledIcon } from '../../styled/StyledIcon.js';
13
+ import '../../styled/StyledIconButton.js';
14
+
15
+ const StartIconComponent = _ref => {
16
+ let {
17
+ isRotated,
18
+ ...props
19
+ } = _ref;
20
+ return React__default.createElement(StyledIcon, Object.assign({
21
+ $position: "start",
22
+ $isRotated: isRotated
23
+ }, props));
24
+ };
25
+ StartIconComponent.displayName = 'Button.StartIcon';
26
+ const StartIcon = StartIconComponent;
27
+
28
+ export { StartIcon };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ export { Button } from './elements/Button.js';
8
+ export { Anchor } from './elements/Anchor.js';
9
+ export { ChevronButton } from './elements/ChevronButton.js';
10
+ export { IconButton } from './elements/IconButton.js';
11
+ export { SplitButton } from './elements/SplitButton.js';
12
+ export { ToggleButton } from './elements/ToggleButton.js';
13
+ export { ToggleIconButton } from './elements/ToggleIconButton.js';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import * as React from 'react';
8
+
9
+ var _path;
10
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
+ var SvgNewWindowStroke = function SvgNewWindowStroke(props) {
12
+ return /*#__PURE__*/React.createElement("svg", _extends({
13
+ xmlns: "http://www.w3.org/2000/svg",
14
+ width: 12,
15
+ height: 12,
16
+ focusable: "false",
17
+ viewBox: "0 0 12 12",
18
+ "aria-hidden": "true"
19
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
20
+ fill: "none",
21
+ stroke: "currentColor",
22
+ strokeLinecap: "round",
23
+ d: "M10.5 8.5V10c0 .3-.2.5-.5.5H2c-.3 0-.5-.2-.5-.5V2c0-.3.2-.5.5-.5h1.5M6 6l4-4m-3.5-.5H10c.3 0 .5.2.5.5v3.5"
24
+ })));
25
+ };
26
+
27
+ export { SvgNewWindowStroke as default };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import * as React from 'react';
8
+
9
+ var _path;
10
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
11
+ var SvgChevronDownStroke = function SvgChevronDownStroke(props) {
12
+ return /*#__PURE__*/React.createElement("svg", _extends({
13
+ xmlns: "http://www.w3.org/2000/svg",
14
+ width: 16,
15
+ height: 16,
16
+ focusable: "false",
17
+ viewBox: "0 0 16 16",
18
+ "aria-hidden": "true"
19
+ }, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
20
+ fill: "currentColor",
21
+ d: "M12.688 5.61a.5.5 0 01.69.718l-.066.062-5 4a.5.5 0 01-.542.054l-.082-.054-5-4a.5.5 0 01.55-.83l.074.05L8 9.359l4.688-3.75z"
22
+ })));
23
+ };
24
+
25
+ export { SvgChevronDownStroke as default };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright Zendesk, Inc.
3
+ *
4
+ * Use of this source code is governed under the Apache License, Version 2.0
5
+ * found at http://www.apache.org/licenses/LICENSE-2.0.
6
+ */
7
+ import styled from 'styled-components';
8
+ import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
9
+ import { StyledButton } from './StyledButton.js';
10
+
11
+ const COMPONENT_ID = 'buttons.anchor';
12
+ const StyledAnchor = styled(StyledButton).attrs(props => ({
13
+ 'data-garden-id': COMPONENT_ID,
14
+ 'data-garden-version': '9.0.0-next.11',
15
+ as: 'a',
16
+ dir: props.theme.rtl ? 'rtl' : undefined,
17
+ isLink: true,
18
+ type: undefined
19
+ })).withConfig({
20
+ displayName: "StyledAnchor",
21
+ componentId: "sc-xshgmo-0"
22
+ })(["direction:", ";", ";"], props => props.theme.rtl && 'rtl', props => retrieveComponentStyles(COMPONENT_ID, props));
23
+ StyledAnchor.defaultProps = {
24
+ theme: DEFAULT_THEME
25
+ };
26
+
27
+ export { StyledAnchor };