@atlaskit/pragmatic-drag-and-drop-react-accessibility 0.1.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/CHANGELOG.md +1 -0
- package/LICENSE.md +13 -0
- package/README.md +9 -0
- package/constellation/drag-handle-button/examples.mdx +21 -0
- package/constellation/drag-handle-button/props.mdx +14 -0
- package/constellation/drag-handle-dropdown-menu/examples.mdx +21 -0
- package/constellation/drag-handle-dropdown-menu/props.mdx +14 -0
- package/constellation/index/about.mdx +8 -0
- package/constellation/index/props.mdx +14 -0
- package/dist/cjs/drag-handle-button.js +74 -0
- package/dist/cjs/drag-handle-dropdown-menu.js +40 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/drag-handle-button.js +64 -0
- package/dist/es2019/drag-handle-dropdown-menu.js +31 -0
- package/dist/es2019/index.js +4 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/drag-handle-button.js +67 -0
- package/dist/esm/drag-handle-dropdown-menu.js +31 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/drag-handle-button.d.ts +49 -0
- package/dist/types/drag-handle-dropdown-menu.d.ts +26 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types-ts4.5/drag-handle-button.d.ts +49 -0
- package/dist/types-ts4.5/drag-handle-dropdown-menu.d.ts +26 -0
- package/dist/types-ts4.5/index.d.ts +5 -0
- package/drag-handle-button/package.json +15 -0
- package/drag-handle-dropdown-menu/package.json +15 -0
- package/extract-react-types/drag-handle-button.tsx +3 -0
- package/extract-react-types/drag-handle-dropdown-menu.tsx +3 -0
- package/package.json +98 -0
- package/report.api.md +37 -0
- package/tmp/api-report-tmp.d.ts +13 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @atlaskit/pragmatic-drag-and-drop-react-accessibility
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# PragmaticDragAndDropReactAccessibility
|
|
2
|
+
|
|
3
|
+
Accessibility helpers for pragmatic-drag-and-drop, written in React.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
`import PragmaticDragAndDropReactAccessibility from '@atlaskit/pragmatic-drag-and-drop-react-accessibility';`
|
|
8
|
+
|
|
9
|
+
Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/pragmatic-drag-and-drop/pragmatic-drag-and-drop-react-accessibility).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 0
|
|
3
|
+
title: Drag Handle Button
|
|
4
|
+
description: A button styled to look like a drag handle
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { Code } from '@atlaskit/code';
|
|
8
|
+
import SectionMessage from '@atlaskit/section-message';
|
|
9
|
+
|
|
10
|
+
import DragHandleButtonExample from '../../examples/drag-handle-button';
|
|
11
|
+
|
|
12
|
+
<SectionMessage appearance="warning">
|
|
13
|
+
This component does not use the <Code>@atlaskit/button</Code> component,
|
|
14
|
+
because <Code>@atlaskit/button</Code> cancels <Code>mousedown</Code> events
|
|
15
|
+
and prevents dragging from occurring.
|
|
16
|
+
Instead this component uses a native <Code><button></Code> element.
|
|
17
|
+
</SectionMessage>
|
|
18
|
+
|
|
19
|
+
## Default
|
|
20
|
+
|
|
21
|
+
<Example Component={DragHandleButtonExample} />
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 1
|
|
3
|
+
title: Drag Handle Button
|
|
4
|
+
description: A button styled to look like a drag handle
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { Code } from '@atlaskit/code';
|
|
8
|
+
|
|
9
|
+
import DragHandleButtonProps from '!!extract-react-types-loader!../../extract-react-types/drag-handle-button';
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
<PropsTable heading="" props={DragHandleButtonProps} />
|
|
14
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 0
|
|
3
|
+
title: Drag Handle Dropdown Menu
|
|
4
|
+
description: A dropdown menu with a drag handle as the trigger
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { Code } from '@atlaskit/code';
|
|
8
|
+
import SectionMessage from '@atlaskit/section-message';
|
|
9
|
+
|
|
10
|
+
import DragHandleDropdownMenuExample from '../../examples/drag-handle-dropdown-menu';
|
|
11
|
+
|
|
12
|
+
<SectionMessage appearance="warning">
|
|
13
|
+
This component does not use the <Code>@atlaskit/button</Code> component,
|
|
14
|
+
because <Code>@atlaskit/button</Code> cancels <Code>mousedown</Code> events
|
|
15
|
+
and prevents dragging from occurring.
|
|
16
|
+
Instead this component uses a native <Code><button></Code> element.
|
|
17
|
+
</SectionMessage>
|
|
18
|
+
|
|
19
|
+
## Default
|
|
20
|
+
|
|
21
|
+
<Example Component={DragHandleDropdownMenuExample} />
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
order: 1
|
|
3
|
+
title: Drag Handle Dropdown Menu
|
|
4
|
+
description: A dropdown menu with a drag handle as the trigger
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
import { Code } from '@atlaskit/code';
|
|
8
|
+
|
|
9
|
+
import DragHandleButtonProps from '!!extract-react-types-loader!../../extract-react-types/drag-handle-button';
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
<PropsTable heading="" props={DragHandleButtonProps} />
|
|
14
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Code } from '@atlaskit/code';
|
|
2
|
+
|
|
3
|
+
import DragHandleButtonProps from '!!extract-react-types-loader!../../extract-react-types/drag-handle-button';
|
|
4
|
+
import DragHandleDropdownMenuProps from '!!extract-react-types-loader!../../extract-react-types/drag-handle-dropdown-menu';
|
|
5
|
+
|
|
6
|
+
## Props
|
|
7
|
+
|
|
8
|
+
### Drag Handle Button Props
|
|
9
|
+
|
|
10
|
+
<PropsTable heading="" props={DragHandleButtonProps} />
|
|
11
|
+
|
|
12
|
+
### Drag Handle Dropdown Menu Props
|
|
13
|
+
|
|
14
|
+
<PropsTable heading="" props={DragHandleDropdownMenuProps} />
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DragHandleButton = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _react2 = require("@emotion/react");
|
|
12
|
+
var _focusRing = _interopRequireDefault(require("@atlaskit/focus-ring"));
|
|
13
|
+
var _dragHandler = _interopRequireDefault(require("@atlaskit/icon/glyph/drag-handler"));
|
|
14
|
+
var _excluded = ["isSelected", "testId", "appearance", "label"];
|
|
15
|
+
/** @jsx jsx */
|
|
16
|
+
/**
|
|
17
|
+
* Cannot use `@atlaskit/button` here because it cancels `mousedown` events
|
|
18
|
+
* which prevents dragging.
|
|
19
|
+
*/
|
|
20
|
+
var buttonStyles = (0, _react2.css)({
|
|
21
|
+
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
22
|
+
padding: "var(--ds-space-0, 0px)",
|
|
23
|
+
width: 'max-content',
|
|
24
|
+
border: 'none',
|
|
25
|
+
cursor: 'grab'
|
|
26
|
+
});
|
|
27
|
+
var buttonAppearanceStyles = {
|
|
28
|
+
default: (0, _react2.css)({
|
|
29
|
+
backgroundColor: "var(--ds-background-neutral, #091E420F)",
|
|
30
|
+
':hover': {
|
|
31
|
+
backgroundColor: "var(--ds-background-neutral-hovered, #091E4224)"
|
|
32
|
+
},
|
|
33
|
+
':active': {
|
|
34
|
+
backgroundColor: "var(--ds-background-neutral-pressed, #091E424F)"
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
subtle: (0, _react2.css)({
|
|
38
|
+
backgroundColor: "var(--ds-background-neutral-subtle, #00000000)",
|
|
39
|
+
':hover': {
|
|
40
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
41
|
+
},
|
|
42
|
+
':active': {
|
|
43
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
selected: (0, _react2.css)({
|
|
47
|
+
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
48
|
+
color: "var(--ds-text-selected, #0C66E4)"
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A button with pre-configured styling to look like a drag handle.
|
|
53
|
+
*
|
|
54
|
+
* This component uses a native button because the `@atlaskit/button`
|
|
55
|
+
* cancels `mouseDown` events, which prevents dragging.
|
|
56
|
+
*/
|
|
57
|
+
var DragHandleButton = /*#__PURE__*/(0, _react.forwardRef)(function DragHandleButton(_ref, ref) {
|
|
58
|
+
var _ref$isSelected = _ref.isSelected,
|
|
59
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
60
|
+
testId = _ref.testId,
|
|
61
|
+
_ref$appearance = _ref.appearance,
|
|
62
|
+
appearanceProp = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
63
|
+
label = _ref.label,
|
|
64
|
+
buttonProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
65
|
+
var appearance = isSelected ? 'selected' : appearanceProp;
|
|
66
|
+
return (0, _react2.jsx)(_focusRing.default, null, (0, _react2.jsx)("button", (0, _extends2.default)({
|
|
67
|
+
ref: ref,
|
|
68
|
+
css: [buttonStyles, buttonAppearanceStyles[appearance]],
|
|
69
|
+
"data-testid": testId
|
|
70
|
+
}, buttonProps), (0, _react2.jsx)(_dragHandler.default, {
|
|
71
|
+
label: label
|
|
72
|
+
})));
|
|
73
|
+
});
|
|
74
|
+
exports.DragHandleButton = DragHandleButton;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.DragHandleDropdownMenu = DragHandleDropdownMenu;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _dropdownMenu = _interopRequireDefault(require("@atlaskit/dropdown-menu"));
|
|
13
|
+
var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
|
|
14
|
+
var _dragHandleButton = require("./drag-handle-button");
|
|
15
|
+
var _excluded = ["triggerRef"]; // eslint-disable-next-line @atlaskit/design-system/no-banned-imports
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
|
+
/**
|
|
19
|
+
* A dropdown menu with a predefined trigger, styled to look like a drag handle.
|
|
20
|
+
*
|
|
21
|
+
* The API is designed to mirror the `@atlaskit/dropdown-menu` API.
|
|
22
|
+
*/
|
|
23
|
+
function DragHandleDropdownMenu(_ref) {
|
|
24
|
+
var children = _ref.children,
|
|
25
|
+
consumerRef = _ref.triggerRef,
|
|
26
|
+
label = _ref.label;
|
|
27
|
+
var renderTrigger = (0, _react.useCallback)(function (_ref2) {
|
|
28
|
+
var triggerRef = _ref2.triggerRef,
|
|
29
|
+
triggerProps = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
|
30
|
+
var mergedRef = (0, _mergeRefs.default)([consumerRef, triggerRef]);
|
|
31
|
+
return /*#__PURE__*/_react.default.createElement(_dragHandleButton.DragHandleButton, (0, _extends2.default)({
|
|
32
|
+
ref: mergedRef
|
|
33
|
+
}, triggerProps, {
|
|
34
|
+
label: label
|
|
35
|
+
}));
|
|
36
|
+
}, [consumerRef, label]);
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement(_dropdownMenu.default, {
|
|
38
|
+
trigger: renderTrigger
|
|
39
|
+
}, children);
|
|
40
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
|
+
import { css, jsx } from '@emotion/react';
|
|
6
|
+
import FocusRing from '@atlaskit/focus-ring';
|
|
7
|
+
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
8
|
+
/**
|
|
9
|
+
* Cannot use `@atlaskit/button` here because it cancels `mousedown` events
|
|
10
|
+
* which prevents dragging.
|
|
11
|
+
*/
|
|
12
|
+
const buttonStyles = css({
|
|
13
|
+
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
14
|
+
padding: "var(--ds-space-0, 0px)",
|
|
15
|
+
width: 'max-content',
|
|
16
|
+
border: 'none',
|
|
17
|
+
cursor: 'grab'
|
|
18
|
+
});
|
|
19
|
+
const buttonAppearanceStyles = {
|
|
20
|
+
default: css({
|
|
21
|
+
backgroundColor: "var(--ds-background-neutral, #091E420F)",
|
|
22
|
+
':hover': {
|
|
23
|
+
backgroundColor: "var(--ds-background-neutral-hovered, #091E4224)"
|
|
24
|
+
},
|
|
25
|
+
':active': {
|
|
26
|
+
backgroundColor: "var(--ds-background-neutral-pressed, #091E424F)"
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
subtle: css({
|
|
30
|
+
backgroundColor: "var(--ds-background-neutral-subtle, #00000000)",
|
|
31
|
+
':hover': {
|
|
32
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
33
|
+
},
|
|
34
|
+
':active': {
|
|
35
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
selected: css({
|
|
39
|
+
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
40
|
+
color: "var(--ds-text-selected, #0C66E4)"
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* A button with pre-configured styling to look like a drag handle.
|
|
45
|
+
*
|
|
46
|
+
* This component uses a native button because the `@atlaskit/button`
|
|
47
|
+
* cancels `mouseDown` events, which prevents dragging.
|
|
48
|
+
*/
|
|
49
|
+
export const DragHandleButton = /*#__PURE__*/forwardRef(function DragHandleButton({
|
|
50
|
+
isSelected = false,
|
|
51
|
+
testId,
|
|
52
|
+
appearance: appearanceProp = 'default',
|
|
53
|
+
label,
|
|
54
|
+
...buttonProps
|
|
55
|
+
}, ref) {
|
|
56
|
+
const appearance = isSelected ? 'selected' : appearanceProp;
|
|
57
|
+
return jsx(FocusRing, null, jsx("button", _extends({
|
|
58
|
+
ref: ref,
|
|
59
|
+
css: [buttonStyles, buttonAppearanceStyles[appearance]],
|
|
60
|
+
"data-testid": testId
|
|
61
|
+
}, buttonProps), jsx(DragHandlerIcon, {
|
|
62
|
+
label: label
|
|
63
|
+
})));
|
|
64
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
4
|
+
// eslint-disable-next-line @atlaskit/design-system/no-banned-imports
|
|
5
|
+
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
6
|
+
import { DragHandleButton } from './drag-handle-button';
|
|
7
|
+
/**
|
|
8
|
+
* A dropdown menu with a predefined trigger, styled to look like a drag handle.
|
|
9
|
+
*
|
|
10
|
+
* The API is designed to mirror the `@atlaskit/dropdown-menu` API.
|
|
11
|
+
*/
|
|
12
|
+
export function DragHandleDropdownMenu({
|
|
13
|
+
children,
|
|
14
|
+
triggerRef: consumerRef,
|
|
15
|
+
label
|
|
16
|
+
}) {
|
|
17
|
+
const renderTrigger = useCallback(({
|
|
18
|
+
triggerRef,
|
|
19
|
+
...triggerProps
|
|
20
|
+
}) => {
|
|
21
|
+
const mergedRef = mergeRefs([consumerRef, triggerRef]);
|
|
22
|
+
return /*#__PURE__*/React.createElement(DragHandleButton, _extends({
|
|
23
|
+
ref: mergedRef
|
|
24
|
+
}, triggerProps, {
|
|
25
|
+
label: label
|
|
26
|
+
}));
|
|
27
|
+
}, [consumerRef, label]);
|
|
28
|
+
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
29
|
+
trigger: renderTrigger
|
|
30
|
+
}, children);
|
|
31
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["isSelected", "testId", "appearance", "label"];
|
|
4
|
+
/** @jsx jsx */
|
|
5
|
+
|
|
6
|
+
import { forwardRef } from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/react';
|
|
8
|
+
import FocusRing from '@atlaskit/focus-ring';
|
|
9
|
+
import DragHandlerIcon from '@atlaskit/icon/glyph/drag-handler';
|
|
10
|
+
/**
|
|
11
|
+
* Cannot use `@atlaskit/button` here because it cancels `mousedown` events
|
|
12
|
+
* which prevents dragging.
|
|
13
|
+
*/
|
|
14
|
+
var buttonStyles = css({
|
|
15
|
+
borderRadius: "var(--ds-border-radius-100, 3px)",
|
|
16
|
+
padding: "var(--ds-space-0, 0px)",
|
|
17
|
+
width: 'max-content',
|
|
18
|
+
border: 'none',
|
|
19
|
+
cursor: 'grab'
|
|
20
|
+
});
|
|
21
|
+
var buttonAppearanceStyles = {
|
|
22
|
+
default: css({
|
|
23
|
+
backgroundColor: "var(--ds-background-neutral, #091E420F)",
|
|
24
|
+
':hover': {
|
|
25
|
+
backgroundColor: "var(--ds-background-neutral-hovered, #091E4224)"
|
|
26
|
+
},
|
|
27
|
+
':active': {
|
|
28
|
+
backgroundColor: "var(--ds-background-neutral-pressed, #091E424F)"
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
subtle: css({
|
|
32
|
+
backgroundColor: "var(--ds-background-neutral-subtle, #00000000)",
|
|
33
|
+
':hover': {
|
|
34
|
+
backgroundColor: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
35
|
+
},
|
|
36
|
+
':active': {
|
|
37
|
+
backgroundColor: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
selected: css({
|
|
41
|
+
backgroundColor: "var(--ds-background-selected, #E9F2FF)",
|
|
42
|
+
color: "var(--ds-text-selected, #0C66E4)"
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A button with pre-configured styling to look like a drag handle.
|
|
47
|
+
*
|
|
48
|
+
* This component uses a native button because the `@atlaskit/button`
|
|
49
|
+
* cancels `mouseDown` events, which prevents dragging.
|
|
50
|
+
*/
|
|
51
|
+
export var DragHandleButton = /*#__PURE__*/forwardRef(function DragHandleButton(_ref, ref) {
|
|
52
|
+
var _ref$isSelected = _ref.isSelected,
|
|
53
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
|
|
54
|
+
testId = _ref.testId,
|
|
55
|
+
_ref$appearance = _ref.appearance,
|
|
56
|
+
appearanceProp = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
57
|
+
label = _ref.label,
|
|
58
|
+
buttonProps = _objectWithoutProperties(_ref, _excluded);
|
|
59
|
+
var appearance = isSelected ? 'selected' : appearanceProp;
|
|
60
|
+
return jsx(FocusRing, null, jsx("button", _extends({
|
|
61
|
+
ref: ref,
|
|
62
|
+
css: [buttonStyles, buttonAppearanceStyles[appearance]],
|
|
63
|
+
"data-testid": testId
|
|
64
|
+
}, buttonProps), jsx(DragHandlerIcon, {
|
|
65
|
+
label: label
|
|
66
|
+
})));
|
|
67
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["triggerRef"];
|
|
4
|
+
import React, { useCallback } from 'react';
|
|
5
|
+
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
6
|
+
// eslint-disable-next-line @atlaskit/design-system/no-banned-imports
|
|
7
|
+
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
8
|
+
import { DragHandleButton } from './drag-handle-button';
|
|
9
|
+
/**
|
|
10
|
+
* A dropdown menu with a predefined trigger, styled to look like a drag handle.
|
|
11
|
+
*
|
|
12
|
+
* The API is designed to mirror the `@atlaskit/dropdown-menu` API.
|
|
13
|
+
*/
|
|
14
|
+
export function DragHandleDropdownMenu(_ref) {
|
|
15
|
+
var children = _ref.children,
|
|
16
|
+
consumerRef = _ref.triggerRef,
|
|
17
|
+
label = _ref.label;
|
|
18
|
+
var renderTrigger = useCallback(function (_ref2) {
|
|
19
|
+
var triggerRef = _ref2.triggerRef,
|
|
20
|
+
triggerProps = _objectWithoutProperties(_ref2, _excluded);
|
|
21
|
+
var mergedRef = mergeRefs([consumerRef, triggerRef]);
|
|
22
|
+
return /*#__PURE__*/React.createElement(DragHandleButton, _extends({
|
|
23
|
+
ref: mergedRef
|
|
24
|
+
}, triggerProps, {
|
|
25
|
+
label: label
|
|
26
|
+
}));
|
|
27
|
+
}, [consumerRef, label]);
|
|
28
|
+
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
29
|
+
trigger: renderTrigger
|
|
30
|
+
}, children);
|
|
31
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
export type DragHandleButtonAppearance = 'default' | 'subtle' | 'selected';
|
|
4
|
+
export type DragHandleButtonProps = HTMLAttributes<HTMLButtonElement> & {
|
|
5
|
+
/**
|
|
6
|
+
* Change the style to indicate the button is selected
|
|
7
|
+
*/
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A `testId` prop is provided for specified elements, which is a unique string
|
|
11
|
+
* that appears as a data attribute `data-testid` in the rendered code,
|
|
12
|
+
* serving as a hook for automated tests
|
|
13
|
+
*/
|
|
14
|
+
testId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The base styling to apply to the button
|
|
17
|
+
*/
|
|
18
|
+
appearance?: DragHandleButtonAppearance;
|
|
19
|
+
/**
|
|
20
|
+
* Text used to describe what the button is in context.
|
|
21
|
+
*/
|
|
22
|
+
label: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A button with pre-configured styling to look like a drag handle.
|
|
26
|
+
*
|
|
27
|
+
* This component uses a native button because the `@atlaskit/button`
|
|
28
|
+
* cancels `mouseDown` events, which prevents dragging.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DragHandleButton: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLButtonElement> & {
|
|
31
|
+
/**
|
|
32
|
+
* Change the style to indicate the button is selected
|
|
33
|
+
*/
|
|
34
|
+
isSelected?: boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* A `testId` prop is provided for specified elements, which is a unique string
|
|
37
|
+
* that appears as a data attribute `data-testid` in the rendered code,
|
|
38
|
+
* serving as a hook for automated tests
|
|
39
|
+
*/
|
|
40
|
+
testId?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* The base styling to apply to the button
|
|
43
|
+
*/
|
|
44
|
+
appearance?: DragHandleButtonAppearance | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Text used to describe what the button is in context.
|
|
47
|
+
*/
|
|
48
|
+
label: string;
|
|
49
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactElement, Ref } from 'react';
|
|
2
|
+
import { DragHandleButtonAppearance } from './drag-handle-button';
|
|
3
|
+
export type DragHandleDropdownMenuProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The contents of the dropdown menu.
|
|
6
|
+
*/
|
|
7
|
+
children: ReactElement;
|
|
8
|
+
/**
|
|
9
|
+
* Ref for the button which acts as the dropdown trigger.
|
|
10
|
+
*/
|
|
11
|
+
triggerRef: Ref<HTMLButtonElement>;
|
|
12
|
+
/**
|
|
13
|
+
* The appearance of the button which acts as the dropdown trigger.
|
|
14
|
+
*/
|
|
15
|
+
appearance?: DragHandleButtonAppearance;
|
|
16
|
+
/**
|
|
17
|
+
* The string used as the button label.
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A dropdown menu with a predefined trigger, styled to look like a drag handle.
|
|
23
|
+
*
|
|
24
|
+
* The API is designed to mirror the `@atlaskit/dropdown-menu` API.
|
|
25
|
+
*/
|
|
26
|
+
export declare function DragHandleDropdownMenu({ children, triggerRef: consumerRef, label, }: DragHandleDropdownMenuProps): JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
export type DragHandleButtonAppearance = 'default' | 'subtle' | 'selected';
|
|
4
|
+
export type DragHandleButtonProps = HTMLAttributes<HTMLButtonElement> & {
|
|
5
|
+
/**
|
|
6
|
+
* Change the style to indicate the button is selected
|
|
7
|
+
*/
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* A `testId` prop is provided for specified elements, which is a unique string
|
|
11
|
+
* that appears as a data attribute `data-testid` in the rendered code,
|
|
12
|
+
* serving as a hook for automated tests
|
|
13
|
+
*/
|
|
14
|
+
testId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The base styling to apply to the button
|
|
17
|
+
*/
|
|
18
|
+
appearance?: DragHandleButtonAppearance;
|
|
19
|
+
/**
|
|
20
|
+
* Text used to describe what the button is in context.
|
|
21
|
+
*/
|
|
22
|
+
label: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A button with pre-configured styling to look like a drag handle.
|
|
26
|
+
*
|
|
27
|
+
* This component uses a native button because the `@atlaskit/button`
|
|
28
|
+
* cancels `mouseDown` events, which prevents dragging.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DragHandleButton: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLButtonElement> & {
|
|
31
|
+
/**
|
|
32
|
+
* Change the style to indicate the button is selected
|
|
33
|
+
*/
|
|
34
|
+
isSelected?: boolean | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* A `testId` prop is provided for specified elements, which is a unique string
|
|
37
|
+
* that appears as a data attribute `data-testid` in the rendered code,
|
|
38
|
+
* serving as a hook for automated tests
|
|
39
|
+
*/
|
|
40
|
+
testId?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* The base styling to apply to the button
|
|
43
|
+
*/
|
|
44
|
+
appearance?: DragHandleButtonAppearance | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Text used to describe what the button is in context.
|
|
47
|
+
*/
|
|
48
|
+
label: string;
|
|
49
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactElement, Ref } from 'react';
|
|
2
|
+
import { DragHandleButtonAppearance } from './drag-handle-button';
|
|
3
|
+
export type DragHandleDropdownMenuProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The contents of the dropdown menu.
|
|
6
|
+
*/
|
|
7
|
+
children: ReactElement;
|
|
8
|
+
/**
|
|
9
|
+
* Ref for the button which acts as the dropdown trigger.
|
|
10
|
+
*/
|
|
11
|
+
triggerRef: Ref<HTMLButtonElement>;
|
|
12
|
+
/**
|
|
13
|
+
* The appearance of the button which acts as the dropdown trigger.
|
|
14
|
+
*/
|
|
15
|
+
appearance?: DragHandleButtonAppearance;
|
|
16
|
+
/**
|
|
17
|
+
* The string used as the button label.
|
|
18
|
+
*/
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* A dropdown menu with a predefined trigger, styled to look like a drag handle.
|
|
23
|
+
*
|
|
24
|
+
* The API is designed to mirror the `@atlaskit/dropdown-menu` API.
|
|
25
|
+
*/
|
|
26
|
+
export declare function DragHandleDropdownMenu({ children, triggerRef: consumerRef, label, }: DragHandleDropdownMenuProps): JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/pragmatic-drag-and-drop-react-accessibility/drag-handle-button",
|
|
3
|
+
"main": "../dist/cjs/drag-handle-button.js",
|
|
4
|
+
"module": "../dist/esm/drag-handle-button.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/drag-handle-button.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/drag-handle-button.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <4.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/drag-handle-button.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/pragmatic-drag-and-drop-react-accessibility/drag-handle-dropdown-menu",
|
|
3
|
+
"main": "../dist/cjs/drag-handle-dropdown-menu.js",
|
|
4
|
+
"module": "../dist/esm/drag-handle-dropdown-menu.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/drag-handle-dropdown-menu.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/drag-handle-dropdown-menu.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <4.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/drag-handle-dropdown-menu.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/pragmatic-drag-and-drop-react-accessibility",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Optional react components to help implement accessible alternative flows for Pragmatic drag and drop",
|
|
5
|
+
"author": "Atlassian Pty Ltd",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"atlassian": {
|
|
11
|
+
"team": "Design System Team",
|
|
12
|
+
"inPublicMirror": false,
|
|
13
|
+
"releaseModel": "continuous",
|
|
14
|
+
"website": {
|
|
15
|
+
"name": "PragmaticDragAndDropReactAccessibility",
|
|
16
|
+
"category": "Components"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
20
|
+
"homepage": "https://atlassian.design/components/pragmatic-drag-and-drop/",
|
|
21
|
+
"main": "dist/cjs/index.js",
|
|
22
|
+
"module": "dist/esm/index.js",
|
|
23
|
+
"module:es2019": "dist/es2019/index.js",
|
|
24
|
+
"types": "dist/types/index.d.ts",
|
|
25
|
+
"typesVersions": {
|
|
26
|
+
">=4.5 <4.9": {
|
|
27
|
+
"*": [
|
|
28
|
+
"dist/types-ts4.5/*",
|
|
29
|
+
"dist/types-ts4.5/index.d.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"atlaskit:src": "src/index.tsx",
|
|
35
|
+
"af:exports": {
|
|
36
|
+
"./drag-handle-button": "./src/drag-handle-button.tsx",
|
|
37
|
+
"./drag-handle-dropdown-menu": "./src/drag-handle-dropdown-menu.tsx"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@atlaskit/dropdown-menu": "^11.11.2",
|
|
41
|
+
"@atlaskit/ds-lib": "^2.2.3",
|
|
42
|
+
"@atlaskit/focus-ring": "^1.3.4",
|
|
43
|
+
"@atlaskit/icon": "^21.12.6",
|
|
44
|
+
"@atlaskit/tokens": "^1.13.0",
|
|
45
|
+
"@babel/runtime": "^7.0.0",
|
|
46
|
+
"@emotion/react": "^11.7.1"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"react": "^16.8.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@af/visual-regression": "*",
|
|
53
|
+
"@atlaskit/ssr": "*",
|
|
54
|
+
"@atlaskit/visual-regression": "*",
|
|
55
|
+
"@atlaskit/webdriver-runner": "*",
|
|
56
|
+
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
57
|
+
"@testing-library/react": "^12.1.5",
|
|
58
|
+
"react-dom": "^16.8.0",
|
|
59
|
+
"typescript": "~4.9.5",
|
|
60
|
+
"wait-for-expect": "^1.2.0"
|
|
61
|
+
},
|
|
62
|
+
"techstack": {
|
|
63
|
+
"@atlassian/frontend": {
|
|
64
|
+
"import-structure": [
|
|
65
|
+
"atlassian-conventions"
|
|
66
|
+
],
|
|
67
|
+
"circular-dependencies": [
|
|
68
|
+
"file-and-folder-level"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"@repo/internal": {
|
|
72
|
+
"dom-events": "use-bind-event-listener",
|
|
73
|
+
"analytics": [
|
|
74
|
+
"analytics-next"
|
|
75
|
+
],
|
|
76
|
+
"design-tokens": [
|
|
77
|
+
"color"
|
|
78
|
+
],
|
|
79
|
+
"theming": [
|
|
80
|
+
"react-context"
|
|
81
|
+
],
|
|
82
|
+
"ui-components": [
|
|
83
|
+
"lite-mode"
|
|
84
|
+
],
|
|
85
|
+
"deprecation": [
|
|
86
|
+
"no-deprecated-imports"
|
|
87
|
+
],
|
|
88
|
+
"styling": [
|
|
89
|
+
"static",
|
|
90
|
+
"emotion"
|
|
91
|
+
],
|
|
92
|
+
"imports": [
|
|
93
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
98
|
+
}
|
package/report.api.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!-- API Report Version: 2.3 -->
|
|
2
|
+
|
|
3
|
+
## API Report File for "@atlaskit/pragmatic-drag-and-drop-react-accessibility"
|
|
4
|
+
|
|
5
|
+
> Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
|
|
6
|
+
> [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
|
|
7
|
+
|
|
8
|
+
### Table of contents
|
|
9
|
+
|
|
10
|
+
- [Main Entry Types](#main-entry-types)
|
|
11
|
+
- [Peer Dependencies](#peer-dependencies)
|
|
12
|
+
|
|
13
|
+
### Main Entry Types
|
|
14
|
+
|
|
15
|
+
<!--SECTION START: Main Entry Types-->
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// @public
|
|
19
|
+
const _default: {};
|
|
20
|
+
export default _default;
|
|
21
|
+
|
|
22
|
+
// (No @packageDocumentation comment for this package)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<!--SECTION END: Main Entry Types-->
|
|
26
|
+
|
|
27
|
+
### Peer Dependencies
|
|
28
|
+
|
|
29
|
+
<!--SECTION START: Peer Dependencies-->
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"react": "^16.8.0"
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
<!--SECTION END: Peer Dependencies-->
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/pragmatic-drag-and-drop-react-accessibility"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
// @public
|
|
8
|
+
const _default: {};
|
|
9
|
+
export default _default;
|
|
10
|
+
|
|
11
|
+
// (No @packageDocumentation comment for this package)
|
|
12
|
+
|
|
13
|
+
```
|