cozy-ui 105.0.2 → 105.2.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 CHANGED
@@ -1,3 +1,22 @@
1
+ # [105.2.0](https://github.com/cozy/cozy-ui/compare/v105.1.0...v105.2.0) (2024-03-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * **Viewer:** Refactor PrintButton and use `ActionsItems` ([8b7a068](https://github.com/cozy/cozy-ui/commit/8b7a068))
7
+
8
+ # [105.1.0](https://github.com/cozy/cozy-ui/compare/v105.0.2...v105.1.0) (2024-03-21)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **NestedSelect:** Remove title attribute on modal ([de57aff](https://github.com/cozy/cozy-ui/commit/de57aff))
14
+
15
+
16
+ ### Features
17
+
18
+ * **NestedSelect:** Add ellipsis on modal title ([341db5a](https://github.com/cozy/cozy-ui/commit/341db5a))
19
+
1
20
  ## [105.0.2](https://github.com/cozy/cozy-ui/compare/v105.0.1...v105.0.2) (2024-03-20)
2
21
 
3
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "105.0.2",
3
+ "version": "105.2.0",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -5,18 +5,18 @@ import { fetchBlobFileById } from 'cozy-client/dist/models/file'
5
5
  const MAX_RESIZE_IMAGE_SIZE = 3840
6
6
 
7
7
  /**
8
- * Make array of actions for ActionsItems component
8
+ * Make array of actions and hydrate actions with options
9
9
  *
10
- * @param {Function[]} actions - Array of actions to create ActionsMenuItem components with associated actions and conditions
10
+ * @param {Function[]} actions - Array of actions with associated actions and conditions
11
11
  * @param {object} actionOptions - Options that need to be passed on actions
12
12
  * @returns {object[]} Array of actions
13
13
  */
14
14
  export const makeActions = (actions = [], options = {}) => {
15
- return actions.filter(Boolean).map(action => {
16
- const actionMenu = action(options)
17
- const name = actionMenu.name || action.name
15
+ return actions.filter(Boolean).map(actionFn => {
16
+ const action = actionFn(options)
17
+ const name = action.name || actionFn.name
18
18
 
19
- return { [name]: actionMenu }
19
+ return { [name]: action }
20
20
  })
21
21
  }
22
22
 
@@ -58,7 +58,7 @@ export const getOnlyNeededActions = (actions, docs) => {
58
58
  return actionObject
59
59
  })
60
60
  .filter(Boolean)
61
- // We don't want to have an hr as the latest actions available
61
+ // We don't want to have an hr/divider as the latest actions available
62
62
  .filter((cleanedAction, idx, cleanedActions) => {
63
63
  return !(
64
64
  (getActionName(cleanedAction) === 'hr' ||
@@ -74,4 +74,12 @@ ActionsItems.propTypes = {
74
74
  onClick: PropTypes.func
75
75
  }
76
76
 
77
+ export const actionsItemsComponentPropTypes = {
78
+ docs: PropTypes.array,
79
+ action: PropTypes.object,
80
+ autoFocus: PropTypes.bool,
81
+ disabled: PropTypes.bool,
82
+ onClick: PropTypes.func
83
+ }
84
+
77
85
  export default ActionsItems
@@ -4,23 +4,7 @@ You can pass a reference to a custom DOM element through the `ref` prop to attac
4
4
 
5
5
  A header `ActionsMenuMobileHeader` can be used to provide context on the menu actions. Since on desktop, we display a popper and not a `BottomSheet`, context for the user is not lost, so the header would be redundant. This is why it is not rendered unless we are on mobile.
6
6
 
7
- ### With an automatic creation of actions
8
-
9
- Use `makeActions` method and create (or use the predefined actions) to build the actions to pass to `ActionsMenu` high level component. The method `makeActions` takes `actions` array as first argument, and `options` as second argument. `options` are then passed to the `actions` component as `props`.
10
-
11
- ```bash
12
- const action1 = ({ option1, option2 }) => ({
13
- name: action1,
14
- action: (doc, { option3, option4 }) => {}
15
- Component: ({ onClick, ...props }) => <SomeComponent {...props} onClick={() => onClick({ option3 })}} />
16
- })
17
-
18
- const actions = makeActions([action1, action2], { option1, option2 })
19
-
20
- <ActionsMenu actions={actions} componentsProps={{ actionsItems: { actionOptions: { option4 }} }}
21
- ```
22
-
23
- #### How to create actions
7
+ ### How to create and use actions
24
8
 
25
9
  An action is a simple function that returns an object with specific keys:
26
10
 
@@ -33,7 +17,7 @@ An action is a simple function that returns an object with specific keys:
33
17
  * **Component** : `<func>` – The returned component that manages the display
34
18
 
35
19
  ```bash
36
- const expl = makeActionOptions => ({
20
+ const actionExpl = options => ({
37
21
  name: 'expl',
38
22
  action: () => {},
39
23
  disabled: false,
@@ -43,6 +27,32 @@ const expl = makeActionOptions => ({
43
27
  })
44
28
  ```
45
29
 
30
+ The method `makeActions` takes `actions` array as first argument, and `options` as second argument. `options` are then passed to the `actions` component as `props`.
31
+
32
+ ```bash
33
+ const action1 = ({ option1, option2, option5 }) => ({
34
+ name: action1,
35
+ action: (doc, { option3, option4 }) => {}
36
+ Component: ({ onClick, ...props }) => <SomeComponent {...props} onClick={() => onClick({ option3 })}} />
37
+ })
38
+
39
+ const actions = makeActions([action1, action2], { option1, option2 })
40
+ ```
41
+
42
+ Then you can use `ActionsItems` to render the actions, and pass options (as simple props) and component (in `component` prop) to be used for rendering.
43
+
44
+ ```bash
45
+ <ActionsItems actions={actions} docs={[file]} component={ActionComponent} option5="" />
46
+ ```
47
+
48
+ ### ActionsMenu with an automatic creation of actions
49
+
50
+ Use `makeActions` method and create (or use the predefined actions) to build the actions to pass to `ActionsMenu`. You can pass options to actions with `componentsProps.actionsItems.actionOptions` prop.
51
+
52
+ ```bash
53
+ <ActionsMenu actions={actions} componentsProps={{ actionsItems: { actionOptions: { option4 }} }} />
54
+ ```
55
+
46
56
  ```jsx
47
57
  import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
48
58
  import DropdownButton from 'cozy-ui/transpiled/react/DropdownButton'
@@ -125,7 +135,9 @@ const actions = makeActions([ modify, viewInContacts, divider, call, smsTo, emai
125
135
  </DemoProvider>
126
136
  ```
127
137
 
128
- ### With a manual creation of the actions
138
+ ### ActionsMenu with a manual creation of the actions
139
+
140
+ We don't use `makeActions` here, all actions are created "by hand". This is not the recommanded choice.
129
141
 
130
142
  ```jsx
131
143
  import DemoProvider from 'cozy-ui/docs/components/DemoProvider'
@@ -13,7 +13,8 @@ import List from '../List'
13
13
 
14
14
  const NestedSelectDialogHeader = ({ onClickBack, showBack, title }) => {
15
15
  const { dialogTitleProps } = useCozyDialog({
16
- open: true
16
+ open: true,
17
+ onClose: true
17
18
  })
18
19
 
19
20
  if (!title) return null
@@ -28,7 +29,7 @@ const NestedSelectDialogHeader = ({ onClickBack, showBack, title }) => {
28
29
  </IconButton>
29
30
  </Img>
30
31
  )}
31
- <Bd>{title}</Bd>
32
+ <Bd className="u-ellipsis">{title}</Bd>
32
33
  </Media>
33
34
  </DialogTitle>
34
35
  )
@@ -44,8 +45,9 @@ const NestedSelectDialogContent = ({ children }) => {
44
45
 
45
46
  const NestedSelectModal = props => {
46
47
  const { dialogProps } = useCozyDialog({ open: true })
48
+
47
49
  return (
48
- <Dialog {...dialogProps} title={props.title} onClose={props.onClose}>
50
+ <Dialog {...dialogProps} onClose={props.onClose}>
49
51
  <DialogCloseButton
50
52
  onClick={props.onClose}
51
53
  data-testid={`modal-close-button-nested-select`}
@@ -68,6 +68,7 @@ const files = [
68
68
  {
69
69
  _id: 'audio',
70
70
  class: 'audio',
71
+ type: 'file',
71
72
  name: 'Sample.mp3',
72
73
  mime: 'audio/mp3',
73
74
  dir_id: 'parent_folder'
@@ -75,6 +76,7 @@ const files = [
75
76
  {
76
77
  _id: 'slide',
77
78
  class: 'slide',
79
+ type: 'file',
78
80
  name: 'Slide.pptx',
79
81
  mime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
80
82
  dir_id: 'parent_folder'
@@ -82,6 +84,7 @@ const files = [
82
84
  {
83
85
  _id: 'pdf',
84
86
  class: 'pdf',
87
+ type: 'file',
85
88
  name: 'My vehicle registration.pdf',
86
89
  mime: 'application/pdf',
87
90
  metadata: {
@@ -107,6 +110,7 @@ const files = [
107
110
  {
108
111
  _id: 'text',
109
112
  class: 'text',
113
+ type: 'file',
110
114
  name: 'LoremipsumdolorsitametconsecteturadipiscingelitSednonrisusSuspendisselectustortordignissimsitametadipiscingnecultriciesseddolorCraselementumultricesdiamMaecenasligulamassavariusasempercongueeuismodnonmiProinporttitororcinecnonummymolestieenimesteleifendminonfermentumdiamnislsitameteratDuissemperDuisarcumassascelerisquevitaeconsequatinpretiumaenimPellentesquecongueUtinrisusvolutpatliberopharetratemporCrasvestibulumbibendumauguePraesentegestasleoinpedePraesentblanditodioeuenimPellentesquesedduiutaugueblanditsodalesVestibulumanteipsumprimisinfaucibusorciluctusetultricesposuerecubiliaCuraeAliquamnibhMaurisacmaurissedpedepellentesquefermentumMaecenasadipiscingantenondiamsodaleshendrerit.txt',
111
115
  mime: 'text/plain',
112
116
  metadata: {
@@ -120,6 +124,7 @@ const files = [
120
124
  {
121
125
  _id: 'text',
122
126
  class: 'text',
127
+ type: 'file',
123
128
  name: 'encrypted-example.txt',
124
129
  mime: 'text/plain',
125
130
  encrypted: true
@@ -128,6 +133,7 @@ const files = [
128
133
  {
129
134
  _id: 'image',
130
135
  class: 'image',
136
+ type: 'file',
131
137
  name: 'Demo.jpg',
132
138
  mime: 'image/jpg',
133
139
  metadata: {
@@ -143,12 +149,14 @@ const files = [
143
149
  {
144
150
  _id: 'none',
145
151
  class: 'unknown',
152
+ type: 'file',
146
153
  name: 'Unsupported file type',
147
154
  mime: '???/???'
148
155
  },
149
156
  {
150
157
  _id: 'none',
151
158
  class: 'unknown',
159
+ type: 'file',
152
160
  name: 'Unsupported file type',
153
161
  mime: '???/???',
154
162
  metadata: {
@@ -1,30 +1,57 @@
1
- import React, { useState, useEffect } from 'react'
1
+ import React, { useState, useEffect, forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
 
4
- import { useClient } from 'cozy-client'
5
4
  import { useWebviewIntent } from 'cozy-intent'
6
5
 
7
6
  import Button from '../../Buttons'
8
7
  import IconButton from '../../IconButton'
9
8
  import Icon from '../../Icon'
9
+ import ActionsItems, {
10
+ actionsItemsComponentPropTypes
11
+ } from '../../ActionsMenu/ActionsItems'
10
12
  import { print } from '../../ActionsMenu/Actions/print'
13
+ import { makeActions } from '../../ActionsMenu/Actions/helpers'
14
+
15
+ const ActionComponent = forwardRef(({ action, variant, onClick }, ref) => {
16
+ const { label, icon } = action
17
+
18
+ if (variant === 'button') {
19
+ return (
20
+ <Button
21
+ ref={ref}
22
+ variant="secondary"
23
+ aria-label={label}
24
+ label={<Icon icon={icon} />}
25
+ onClick={onClick}
26
+ />
27
+ )
28
+ }
29
+
30
+ return (
31
+ <IconButton
32
+ ref={ref}
33
+ className="u-white"
34
+ aria-label={label}
35
+ onClick={onClick}
36
+ >
37
+ <Icon icon={icon} />
38
+ </IconButton>
39
+ )
40
+ })
41
+
42
+ ActionComponent.displayName = 'ActionComponent'
43
+
44
+ ActionComponent.propTypes = {
45
+ ...actionsItemsComponentPropTypes,
46
+ variant: PropTypes.oneOf(['default', 'button'])
47
+ }
11
48
 
12
49
  const PrintButton = ({ file, variant }) => {
13
50
  const [isPrintAvailable, setIsPrintAvailable] = useState(false)
14
- const client = useClient()
15
51
  const webviewIntent = useWebviewIntent()
16
- const {
17
- icon: printIcon,
18
- label: printLabel,
19
- action: printAction,
20
- displayCondition: printDisplayCondition
21
- } = print()
22
52
 
23
53
  const isPDFDoc = file.mime === 'application/pdf'
24
- const showPrintButton = printDisplayCondition && isPDFDoc && isPrintAvailable
25
-
26
- const handleClick = async () =>
27
- await printAction([file], { client, webviewIntent })
54
+ const showPrintButton = isPDFDoc && isPrintAvailable
28
55
 
29
56
  useEffect(() => {
30
57
  const init = async () => {
@@ -39,25 +66,15 @@ const PrintButton = ({ file, variant }) => {
39
66
 
40
67
  if (!showPrintButton) return null
41
68
 
42
- if (variant === 'button') {
43
- return (
44
- <Button
45
- variant="secondary"
46
- aria-label={printLabel}
47
- label={<Icon icon={printIcon} />}
48
- onClick={handleClick}
49
- />
50
- )
51
- }
69
+ const actions = makeActions([print])
52
70
 
53
71
  return (
54
- <IconButton
55
- className="u-white"
56
- aria-label={printLabel}
57
- onClick={handleClick}
58
- >
59
- <Icon icon={printIcon} />
60
- </IconButton>
72
+ <ActionsItems
73
+ docs={[file]}
74
+ actions={actions}
75
+ component={ActionComponent}
76
+ variant={variant}
77
+ />
61
78
  )
62
79
  }
63
80
 
@@ -13,9 +13,9 @@ import { fetchBlobFileById } from 'cozy-client/dist/models/file'; // Should guar
13
13
 
14
14
  var MAX_RESIZE_IMAGE_SIZE = 3840;
15
15
  /**
16
- * Make array of actions for ActionsItems component
16
+ * Make array of actions and hydrate actions with options
17
17
  *
18
- * @param {Function[]} actions - Array of actions to create ActionsMenuItem components with associated actions and conditions
18
+ * @param {Function[]} actions - Array of actions with associated actions and conditions
19
19
  * @param {object} actionOptions - Options that need to be passed on actions
20
20
  * @returns {object[]} Array of actions
21
21
  */
@@ -23,10 +23,10 @@ var MAX_RESIZE_IMAGE_SIZE = 3840;
23
23
  export var makeActions = function makeActions() {
24
24
  var actions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
25
25
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26
- return actions.filter(Boolean).map(function (action) {
27
- var actionMenu = action(options);
28
- var name = actionMenu.name || action.name;
29
- return _defineProperty({}, name, actionMenu);
26
+ return actions.filter(Boolean).map(function (actionFn) {
27
+ var action = actionFn(options);
28
+ var name = action.name || actionFn.name;
29
+ return _defineProperty({}, name, action);
30
30
  });
31
31
  };
32
32
  export var getActionName = function getActionName(actionObject) {
@@ -57,7 +57,7 @@ export var getOnlyNeededActions = function getOnlyNeededActions(actions, docs) {
57
57
  }
58
58
 
59
59
  return actionObject;
60
- }).filter(Boolean) // We don't want to have an hr as the latest actions available
60
+ }).filter(Boolean) // We don't want to have an hr/divider as the latest actions available
61
61
  .filter(function (cleanedAction, idx, cleanedActions) {
62
62
  return !((getActionName(cleanedAction) === 'hr' || getActionName(cleanedAction) === 'divider') && idx === cleanedActions.length - 1);
63
63
  });
@@ -71,4 +71,11 @@ ActionsItems.propTypes = {
71
71
  /** The overrideClick function from ActionsMenuWrapper */
72
72
  onClick: PropTypes.func
73
73
  };
74
+ export var actionsItemsComponentPropTypes = {
75
+ docs: PropTypes.array,
76
+ action: PropTypes.object,
77
+ autoFocus: PropTypes.bool,
78
+ disabled: PropTypes.bool,
79
+ onClick: PropTypes.func
80
+ };
74
81
  export default ActionsItems;
@@ -18,7 +18,8 @@ var NestedSelectDialogHeader = function NestedSelectDialogHeader(_ref) {
18
18
  title = _ref.title;
19
19
 
20
20
  var _useCozyDialog = useCozyDialog({
21
- open: true
21
+ open: true,
22
+ onClose: true
22
23
  }),
23
24
  dialogTitleProps = _useCozyDialog.dialogTitleProps;
24
25
 
@@ -30,7 +31,9 @@ var NestedSelectDialogHeader = function NestedSelectDialogHeader(_ref) {
30
31
  onClick: onClickBack
31
32
  }, /*#__PURE__*/React.createElement(Icon, {
32
33
  icon: LeftIcon
33
- }))), /*#__PURE__*/React.createElement(Bd, null, title)));
34
+ }))), /*#__PURE__*/React.createElement(Bd, {
35
+ className: "u-ellipsis"
36
+ }, title)));
34
37
  };
35
38
 
36
39
  var NestedSelectDialogContent = function NestedSelectDialogContent(_ref2) {
@@ -47,7 +50,6 @@ var NestedSelectModal = function NestedSelectModal(props) {
47
50
  dialogProps = _useCozyDialog2.dialogProps;
48
51
 
49
52
  return /*#__PURE__*/React.createElement(Dialog, _extends({}, dialogProps, {
50
- title: props.title,
51
53
  onClose: props.onClose
52
54
  }), /*#__PURE__*/React.createElement(DialogCloseButton, {
53
55
  onClick: props.onClose,
@@ -1,111 +1,113 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import React, { useState, useEffect } from 'react';
5
+
6
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
+
8
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+
10
+ import React, { useState, useEffect, forwardRef } from 'react';
5
11
  import PropTypes from 'prop-types';
6
- import { useClient } from 'cozy-client';
7
12
  import { useWebviewIntent } from 'cozy-intent';
8
13
  import Button from "cozy-ui/transpiled/react/Buttons";
9
14
  import IconButton from "cozy-ui/transpiled/react/IconButton";
10
15
  import Icon from "cozy-ui/transpiled/react/Icon";
16
+ import ActionsItems, { actionsItemsComponentPropTypes } from "cozy-ui/transpiled/react/ActionsMenu/ActionsItems";
11
17
  import { print } from "cozy-ui/transpiled/react/ActionsMenu/Actions/print";
18
+ import { makeActions } from "cozy-ui/transpiled/react/ActionsMenu/Actions/helpers";
19
+ var ActionComponent = /*#__PURE__*/forwardRef(function (_ref, ref) {
20
+ var action = _ref.action,
21
+ variant = _ref.variant,
22
+ onClick = _ref.onClick;
23
+ var label = action.label,
24
+ icon = action.icon;
25
+
26
+ if (variant === 'button') {
27
+ return /*#__PURE__*/React.createElement(Button, {
28
+ ref: ref,
29
+ variant: "secondary",
30
+ "aria-label": label,
31
+ label: /*#__PURE__*/React.createElement(Icon, {
32
+ icon: icon
33
+ }),
34
+ onClick: onClick
35
+ });
36
+ }
12
37
 
13
- var PrintButton = function PrintButton(_ref) {
14
- var file = _ref.file,
15
- variant = _ref.variant;
38
+ return /*#__PURE__*/React.createElement(IconButton, {
39
+ ref: ref,
40
+ className: "u-white",
41
+ "aria-label": label,
42
+ onClick: onClick
43
+ }, /*#__PURE__*/React.createElement(Icon, {
44
+ icon: icon
45
+ }));
46
+ });
47
+ ActionComponent.displayName = 'ActionComponent';
48
+ ActionComponent.propTypes = _objectSpread(_objectSpread({}, actionsItemsComponentPropTypes), {}, {
49
+ variant: PropTypes.oneOf(['default', 'button'])
50
+ });
51
+
52
+ var PrintButton = function PrintButton(_ref2) {
53
+ var file = _ref2.file,
54
+ variant = _ref2.variant;
16
55
 
17
56
  var _useState = useState(false),
18
57
  _useState2 = _slicedToArray(_useState, 2),
19
58
  isPrintAvailable = _useState2[0],
20
59
  setIsPrintAvailable = _useState2[1];
21
60
 
22
- var client = useClient();
23
61
  var webviewIntent = useWebviewIntent();
24
-
25
- var _print = print(),
26
- printIcon = _print.icon,
27
- printLabel = _print.label,
28
- printAction = _print.action,
29
- printDisplayCondition = _print.displayCondition;
30
-
31
62
  var isPDFDoc = file.mime === 'application/pdf';
32
- var showPrintButton = printDisplayCondition && isPDFDoc && isPrintAvailable;
33
-
34
- var handleClick = /*#__PURE__*/function () {
35
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
36
- return _regeneratorRuntime.wrap(function _callee$(_context) {
37
- while (1) {
38
- switch (_context.prev = _context.next) {
39
- case 0:
40
- _context.next = 2;
41
- return printAction([file], {
42
- client: client,
43
- webviewIntent: webviewIntent
44
- });
45
-
46
- case 2:
47
- return _context.abrupt("return", _context.sent);
48
-
49
- case 3:
50
- case "end":
51
- return _context.stop();
52
- }
53
- }
54
- }, _callee);
55
- }));
56
-
57
- return function handleClick() {
58
- return _ref2.apply(this, arguments);
59
- };
60
- }();
61
-
63
+ var showPrintButton = isPDFDoc && isPrintAvailable;
62
64
  useEffect(function () {
63
65
  var init = /*#__PURE__*/function () {
64
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
66
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
65
67
  var _yield$webviewIntent$;
66
68
 
67
69
  var isAvailable;
68
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
70
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
69
71
  while (1) {
70
- switch (_context2.prev = _context2.next) {
72
+ switch (_context.prev = _context.next) {
71
73
  case 0:
72
- _context2.next = 2;
74
+ _context.next = 2;
73
75
  return webviewIntent === null || webviewIntent === void 0 ? void 0 : webviewIntent.call('isAvailable', 'print');
74
76
 
75
77
  case 2:
76
- _context2.t1 = _yield$webviewIntent$ = _context2.sent;
77
- _context2.t0 = _context2.t1 !== null;
78
+ _context.t1 = _yield$webviewIntent$ = _context.sent;
79
+ _context.t0 = _context.t1 !== null;
78
80
 
79
- if (!_context2.t0) {
80
- _context2.next = 6;
81
+ if (!_context.t0) {
82
+ _context.next = 6;
81
83
  break;
82
84
  }
83
85
 
84
- _context2.t0 = _yield$webviewIntent$ !== void 0;
86
+ _context.t0 = _yield$webviewIntent$ !== void 0;
85
87
 
86
88
  case 6:
87
- if (!_context2.t0) {
88
- _context2.next = 10;
89
+ if (!_context.t0) {
90
+ _context.next = 10;
89
91
  break;
90
92
  }
91
93
 
92
- _context2.t2 = _yield$webviewIntent$;
93
- _context2.next = 11;
94
+ _context.t2 = _yield$webviewIntent$;
95
+ _context.next = 11;
94
96
  break;
95
97
 
96
98
  case 10:
97
- _context2.t2 = true;
99
+ _context.t2 = true;
98
100
 
99
101
  case 11:
100
- isAvailable = _context2.t2;
102
+ isAvailable = _context.t2;
101
103
  setIsPrintAvailable(isAvailable);
102
104
 
103
105
  case 13:
104
106
  case "end":
105
- return _context2.stop();
107
+ return _context.stop();
106
108
  }
107
109
  }
108
- }, _callee2);
110
+ }, _callee);
109
111
  }));
110
112
 
111
113
  return function init() {
@@ -116,25 +118,13 @@ var PrintButton = function PrintButton(_ref) {
116
118
  init();
117
119
  }, [webviewIntent]);
118
120
  if (!showPrintButton) return null;
119
-
120
- if (variant === 'button') {
121
- return /*#__PURE__*/React.createElement(Button, {
122
- variant: "secondary",
123
- "aria-label": printLabel,
124
- label: /*#__PURE__*/React.createElement(Icon, {
125
- icon: printIcon
126
- }),
127
- onClick: handleClick
128
- });
129
- }
130
-
131
- return /*#__PURE__*/React.createElement(IconButton, {
132
- className: "u-white",
133
- "aria-label": printLabel,
134
- onClick: handleClick
135
- }, /*#__PURE__*/React.createElement(Icon, {
136
- icon: printIcon
137
- }));
121
+ var actions = makeActions([print]);
122
+ return /*#__PURE__*/React.createElement(ActionsItems, {
123
+ docs: [file],
124
+ actions: actions,
125
+ component: ActionComponent,
126
+ variant: variant
127
+ });
138
128
  };
139
129
 
140
130
  PrintButton.propTypes = {