@digigov/ui 0.22.0 → 0.23.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 +18 -1
- package/admin/CopyToClipboard/CopyToClipboard.stories.d.ts +9 -0
- package/{app → admin}/CopyToClipboard/CopyToClipboard.stories.js +5 -5
- package/{app → admin}/CopyToClipboard/__stories__/Banner.d.ts +0 -0
- package/{app → admin}/CopyToClipboard/__stories__/Banner.js +2 -2
- package/{app → admin}/CopyToClipboard/__stories__/Default.d.ts +0 -0
- package/{app → admin}/CopyToClipboard/__stories__/Default.js +7 -5
- package/{app → admin}/CopyToClipboard/__stories__/MultipleCopies.d.ts +0 -0
- package/{app → admin}/CopyToClipboard/__stories__/MultipleCopies.js +15 -15
- package/admin/CopyToClipboard/index.d.ts +1 -1
- package/admin/CopyToClipboard/index.js +3 -2
- package/admin/CopyToClipboard/index.mdx +22 -0
- package/admin/Dropdown/Dropdown.stories.d.ts +9 -0
- package/admin/Dropdown/Dropdown.stories.js +60 -0
- package/admin/Dropdown/__stories__/AlignRight.d.ts +3 -0
- package/admin/Dropdown/__stories__/AlignRight.js +83 -0
- package/admin/Dropdown/__stories__/Default.d.ts +3 -0
- package/admin/Dropdown/__stories__/Default.js +75 -0
- package/admin/Dropdown/__stories__/PlacementTop.d.ts +3 -0
- package/admin/Dropdown/__stories__/PlacementTop.js +83 -0
- package/admin/Dropdown/index.mdx +29 -0
- package/admin/Modal/Modal.stories.d.ts +8 -0
- package/admin/Modal/Modal.stories.js +44 -0
- package/admin/Modal/__stories__/AlertDialog.d.ts +3 -0
- package/admin/Modal/__stories__/AlertDialog.js +80 -0
- package/admin/Modal/__stories__/Default.d.ts +3 -0
- package/admin/Modal/__stories__/Default.js +79 -0
- package/admin/Modal/index.mdx +26 -0
- package/admin/index.d.ts +1 -1
- package/admin/index.js +4 -4
- package/api/fetchAPI.js +6 -4
- package/api/index.spec.js +18 -19
- package/api/useResource.js +6 -4
- package/api/useResourceAction.js +6 -4
- package/api/useResourceQuery.js +7 -4
- package/api/utils.js +8 -6
- package/core/Accordion/__stories__/Default.js +17 -1
- package/core/Accordion/__stories__/WithHints.js +17 -1
- package/core/Accordion/index.mdx +6 -1
- package/core/Breadcrumbs/__stories__/Default.js +6 -2
- package/core/Button/Button.stories.d.ts +3 -0
- package/core/Button/Button.stories.js +44 -0
- package/core/Button/__stories__/Back.d.ts +4 -0
- package/core/Button/__stories__/Back.js +26 -0
- package/core/Button/__stories__/ButtonLinkButton.d.ts +6 -0
- package/core/Button/__stories__/ButtonLinkButton.js +30 -0
- package/core/Button/__stories__/CallToActionButton.d.ts +3 -0
- package/core/Button/__stories__/CallToActionButton.js +9 -1
- package/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
- package/core/Button/__stories__/Primary.js +3 -1
- package/core/Button/__stories__/Secondary.js +3 -2
- package/core/Button/__stories__/Warning.d.ts +0 -1
- package/core/Button/__stories__/Warning.js +4 -5
- package/core/Button/__stories__/WithVariantLink.d.ts +6 -0
- package/core/Button/__stories__/WithVariantLink.js +29 -0
- package/{es/core/Button/Button.mdx → core/Button/index.mdx} +9 -2
- package/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
- package/core/Checkboxes/__stories__/Default.js +5 -1
- package/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
- package/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
- package/core/Checkboxes/__stories__/NoneAnswerWithError.js +7 -1
- package/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
- package/core/Checkboxes/__stories__/WithHint.js +5 -1
- package/core/Link/__stories__/DarkBackground.js +3 -1
- package/core/Link/__stories__/DarkBackgroundNoUnderline.js +3 -1
- package/core/Link/__stories__/Default.js +3 -1
- package/core/Link/__stories__/NoUnderline.js +3 -1
- package/core/Link/link.mdx +4 -0
- package/core/NavList/NavList.js +4 -2
- package/core/NavList/NavList.stories.d.ts +8 -0
- package/core/NavList/NavList.stories.js +44 -0
- package/core/NavList/NavListBase.js +3 -1
- package/core/NavList/NavListItem.d.ts +1 -0
- package/core/NavList/NavListItem.js +3 -1
- package/core/NavList/NavListItemBase.d.ts +1 -0
- package/core/NavList/NavListItemBase.js +7 -3
- package/core/NavList/__stories__/Default.d.ts +3 -0
- package/core/NavList/__stories__/Default.js +69 -0
- package/core/NavList/__stories__/NavHorizontalLayout.d.ts +3 -0
- package/core/NavList/__stories__/NavHorizontalLayout.js +67 -0
- package/core/NavList/index.mdx +22 -1
- package/core/NavList/types.d.ts +1 -0
- package/core/Radios/__stories__/ConditionalReveal.js +5 -1
- package/core/Radios/__stories__/Inline.js +5 -1
- package/core/Radios/__stories__/MultipleQuestions.js +6 -2
- package/core/Radios/__stories__/WithErrorMessage.js +7 -1
- package/core/Radios/__stories__/WithHints.js +17 -7
- package/core/Select/__stories__/Default.js +2 -2
- package/core/Select/__stories__/DisabledInput.js +3 -1
- package/core/Select/__stories__/WithHint.d.ts +2 -2
- package/core/Select/__stories__/WithHint.js +6 -6
- package/core/Select/index.mdx +6 -0
- package/core/Table/__stories__/NoData.js +3 -1
- package/core/Table/__stories__/WithLoader.js +16 -12
- package/core/Table/index.mdx +8 -1
- package/es/admin/CopyToClipboard/CopyToClipboard.stories.js +8 -0
- package/{esm/app → es/admin}/CopyToClipboard/__stories__/Banner.js +1 -1
- package/{esm/app → es/admin}/CopyToClipboard/__stories__/Default.js +6 -4
- package/es/{app → admin}/CopyToClipboard/__stories__/MultipleCopies.js +4 -4
- package/es/admin/CopyToClipboard/index.js +3 -2
- package/es/admin/CopyToClipboard/index.mdx +22 -0
- package/es/admin/Dropdown/Dropdown.stories.js +9 -0
- package/es/admin/Dropdown/__stories__/AlignRight.js +56 -0
- package/es/admin/Dropdown/__stories__/Default.js +48 -0
- package/es/admin/Dropdown/__stories__/PlacementTop.js +56 -0
- package/es/admin/Dropdown/index.mdx +29 -0
- package/es/admin/Modal/Modal.stories.js +7 -0
- package/es/admin/Modal/__stories__/AlertDialog.js +58 -0
- package/es/admin/Modal/__stories__/Default.js +56 -0
- package/es/admin/Modal/index.mdx +26 -0
- package/es/admin/index.js +1 -1
- package/es/api/fetchAPI.js +6 -3
- package/es/api/index.spec.js +19 -17
- package/es/api/useResource.js +6 -3
- package/es/api/useResourceAction.js +6 -3
- package/es/api/useResourceQuery.js +6 -3
- package/es/api/utils.js +8 -5
- package/es/core/Accordion/__stories__/Default.js +17 -1
- package/es/core/Accordion/__stories__/WithHints.js +17 -1
- package/es/core/Accordion/index.mdx +6 -1
- package/es/core/Breadcrumbs/__stories__/Default.js +6 -2
- package/es/core/Button/Button.stories.js +5 -1
- package/es/core/Button/__stories__/Back.js +13 -0
- package/es/core/Button/__stories__/ButtonLinkButton.js +17 -0
- package/es/core/Button/__stories__/CallToActionButton.js +9 -1
- package/es/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
- package/es/core/Button/__stories__/Primary.js +3 -1
- package/es/core/Button/__stories__/Secondary.js +3 -2
- package/es/core/Button/__stories__/Warning.js +3 -3
- package/es/core/Button/__stories__/WithVariantLink.js +16 -0
- package/{core/Button/Button.mdx → es/core/Button/index.mdx} +9 -2
- package/es/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
- package/es/core/Checkboxes/__stories__/Default.js +5 -1
- package/es/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
- package/es/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
- package/es/core/Checkboxes/__stories__/NoneAnswerWithError.js +7 -1
- package/es/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
- package/es/core/Checkboxes/__stories__/WithHint.js +5 -1
- package/es/core/Link/__stories__/DarkBackground.js +7 -5
- package/es/core/Link/__stories__/DarkBackgroundNoUnderline.js +7 -5
- package/es/core/Link/__stories__/Default.js +5 -3
- package/es/core/Link/__stories__/NoUnderline.js +5 -3
- package/es/core/Link/link.mdx +4 -0
- package/es/core/NavList/NavList.js +4 -2
- package/es/core/NavList/NavList.stories.js +7 -0
- package/es/core/NavList/NavListBase.js +3 -1
- package/es/core/NavList/NavListItem.js +3 -1
- package/es/core/NavList/NavListItemBase.js +7 -3
- package/es/core/NavList/__stories__/Default.js +48 -0
- package/es/core/NavList/__stories__/NavHorizontalLayout.js +46 -0
- package/es/core/NavList/index.mdx +22 -1
- package/es/core/Radios/__stories__/ConditionalReveal.js +5 -1
- package/es/core/Radios/__stories__/Inline.js +5 -1
- package/es/core/Radios/__stories__/MultipleQuestions.js +6 -2
- package/es/core/Radios/__stories__/WithErrorMessage.js +7 -1
- package/es/core/Radios/__stories__/WithHints.js +17 -7
- package/es/core/Select/__stories__/Default.js +5 -4
- package/es/core/Select/__stories__/DisabledInput.js +5 -3
- package/es/core/Select/__stories__/WithHint.js +7 -6
- package/es/core/Select/index.mdx +6 -0
- package/es/core/Table/__stories__/NoData.js +3 -1
- package/es/core/Table/__stories__/WithLoader.js +12 -10
- package/es/core/Table/index.mdx +8 -1
- package/es/layouts/Basic/Content/index.mdx +0 -12
- package/es/layouts/Basic/Main/index.mdx +0 -10
- package/es/layouts/Basic/Masthead/index.mdx +0 -12
- package/es/layouts/Basic/Side/index.mdx +0 -12
- package/es/layouts/Basic/Top/index.mdx +0 -12
- package/es/layouts/Basic/index.mdx +1 -15
- package/es/layouts/Grid/__stories__/Default.js +26 -6
- package/es/layouts/Grid/__stories__/Inline.js +26 -6
- package/es/registry.js +17 -21
- package/es/test-utils/delay.js +6 -3
- package/esm/admin/CopyToClipboard/CopyToClipboard.stories.js +8 -0
- package/{es/app → esm/admin}/CopyToClipboard/__stories__/Banner.js +1 -1
- package/{es/app → esm/admin}/CopyToClipboard/__stories__/Default.js +6 -4
- package/esm/{app → admin}/CopyToClipboard/__stories__/MultipleCopies.js +4 -4
- package/esm/admin/CopyToClipboard/index.js +3 -2
- package/esm/admin/CopyToClipboard/index.mdx +22 -0
- package/esm/admin/Dropdown/Dropdown.stories.js +9 -0
- package/esm/admin/Dropdown/__stories__/AlignRight.js +56 -0
- package/esm/admin/Dropdown/__stories__/Default.js +48 -0
- package/esm/admin/Dropdown/__stories__/PlacementTop.js +56 -0
- package/esm/admin/Dropdown/index.mdx +29 -0
- package/esm/admin/Modal/Modal.stories.js +7 -0
- package/esm/admin/Modal/__stories__/AlertDialog.js +58 -0
- package/esm/admin/Modal/__stories__/Default.js +56 -0
- package/esm/admin/Modal/index.mdx +26 -0
- package/esm/admin/index.js +1 -1
- package/esm/api/fetchAPI.js +6 -3
- package/esm/api/index.spec.js +19 -17
- package/esm/api/useResource.js +6 -3
- package/esm/api/useResourceAction.js +6 -3
- package/esm/api/useResourceQuery.js +6 -3
- package/esm/api/utils.js +8 -5
- package/esm/core/Accordion/__stories__/Default.js +17 -1
- package/esm/core/Accordion/__stories__/WithHints.js +17 -1
- package/esm/core/Accordion/index.mdx +6 -1
- package/esm/core/Breadcrumbs/__stories__/Default.js +6 -2
- package/esm/core/Button/Button.stories.js +5 -1
- package/esm/core/Button/__stories__/Back.js +13 -0
- package/esm/core/Button/__stories__/ButtonLinkButton.js +17 -0
- package/esm/core/Button/__stories__/CallToActionButton.js +9 -1
- package/esm/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
- package/esm/core/Button/__stories__/Primary.js +3 -1
- package/esm/core/Button/__stories__/Secondary.js +3 -2
- package/esm/core/Button/__stories__/Warning.js +3 -3
- package/esm/core/Button/__stories__/WithVariantLink.js +16 -0
- package/esm/core/Button/{Button.mdx → index.mdx} +9 -2
- package/esm/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
- package/esm/core/Checkboxes/__stories__/Default.js +5 -1
- package/esm/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
- package/esm/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
- package/esm/core/Checkboxes/__stories__/NoneAnswerWithError.js +7 -1
- package/esm/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
- package/esm/core/Checkboxes/__stories__/WithHint.js +5 -1
- package/esm/core/Link/__stories__/DarkBackground.js +7 -5
- package/esm/core/Link/__stories__/DarkBackgroundNoUnderline.js +7 -5
- package/esm/core/Link/__stories__/Default.js +5 -3
- package/esm/core/Link/__stories__/NoUnderline.js +5 -3
- package/esm/core/Link/link.mdx +4 -0
- package/esm/core/NavList/NavList.js +4 -2
- package/esm/core/NavList/NavList.stories.js +7 -0
- package/esm/core/NavList/NavListBase.js +3 -1
- package/esm/core/NavList/NavListItem.js +3 -1
- package/esm/core/NavList/NavListItemBase.js +7 -3
- package/esm/core/NavList/__stories__/Default.js +48 -0
- package/esm/core/NavList/__stories__/NavHorizontalLayout.js +46 -0
- package/esm/core/NavList/index.mdx +22 -1
- package/esm/core/Radios/__stories__/ConditionalReveal.js +5 -1
- package/esm/core/Radios/__stories__/Inline.js +5 -1
- package/esm/core/Radios/__stories__/MultipleQuestions.js +6 -2
- package/esm/core/Radios/__stories__/WithErrorMessage.js +7 -1
- package/esm/core/Radios/__stories__/WithHints.js +17 -7
- package/esm/core/Select/__stories__/Default.js +5 -4
- package/esm/core/Select/__stories__/DisabledInput.js +5 -3
- package/esm/core/Select/__stories__/WithHint.js +7 -6
- package/esm/core/Select/index.mdx +6 -0
- package/esm/core/Table/__stories__/NoData.js +3 -1
- package/esm/core/Table/__stories__/WithLoader.js +12 -10
- package/esm/core/Table/index.mdx +8 -1
- package/esm/index.js +1 -1
- package/esm/layouts/Basic/Content/index.mdx +0 -12
- package/esm/layouts/Basic/Main/index.mdx +0 -10
- package/esm/layouts/Basic/Masthead/index.mdx +0 -12
- package/esm/layouts/Basic/Side/index.mdx +0 -12
- package/esm/layouts/Basic/Top/index.mdx +0 -12
- package/esm/layouts/Basic/index.mdx +1 -15
- package/esm/layouts/Grid/__stories__/Default.js +26 -6
- package/esm/layouts/Grid/__stories__/Inline.js +26 -6
- package/esm/registry.js +17 -21
- package/esm/test-utils/delay.js +6 -3
- package/layouts/Basic/Content/index.mdx +0 -12
- package/layouts/Basic/Main/index.mdx +0 -10
- package/layouts/Basic/Masthead/index.mdx +0 -12
- package/layouts/Basic/Side/index.mdx +0 -12
- package/layouts/Basic/Top/index.mdx +0 -12
- package/layouts/Basic/index.mdx +1 -15
- package/layouts/Grid/__stories__/Default.js +26 -6
- package/layouts/Grid/__stories__/Inline.js +26 -6
- package/package.json +3 -3
- package/registry.d.ts +8 -10
- package/registry.js +25 -31
- package/test-utils/delay.js +5 -3
- package/admin/CopyToClipboardMessage/index.d.ts +0 -3
- package/admin/CopyToClipboardMessage/index.js +0 -30
- package/app/CopyToClipboard/CopyToClipboard.stories.d.ts +0 -9
- package/app/CopyToClipboard/index.d.ts +0 -9
- package/app/CopyToClipboard/index.js +0 -69
- package/app/CopyToClipboard/index.mdx +0 -22
- package/es/admin/CopyToClipboardMessage/index.js +0 -3
- package/es/app/CopyToClipboard/CopyToClipboard.stories.js +0 -8
- package/es/app/CopyToClipboard/index.js +0 -45
- package/es/app/CopyToClipboard/index.mdx +0 -22
- package/esm/admin/CopyToClipboardMessage/index.js +0 -3
- package/esm/app/CopyToClipboard/CopyToClipboard.stories.js +0 -8
- package/esm/app/CopyToClipboard/index.js +0 -45
- package/esm/app/CopyToClipboard/index.mdx +0 -22
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: dropdown
|
|
3
|
+
title: Dropdown
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dropdown
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
import Dropdown from '@digigov/ui/admin/Dropdown';
|
|
10
|
+
```
|
|
11
|
+
## How to use
|
|
12
|
+
|
|
13
|
+
<Story packageName="@digigov/ui" component="admin/Dropdown" story="Default.tsx" />
|
|
14
|
+
|
|
15
|
+
### Dropdown with align right
|
|
16
|
+
|
|
17
|
+
You can display the dropdown menu to the right side of the `Dropdown` button.
|
|
18
|
+
|
|
19
|
+
<Story packageName="@digigov/ui" component="admin/Dropdown" story="AlignRight.tsx" />
|
|
20
|
+
|
|
21
|
+
### Dropdown with placement top
|
|
22
|
+
|
|
23
|
+
You can display the dropdown menu to the top of the `Dropdown` button.
|
|
24
|
+
|
|
25
|
+
<Story packageName="@digigov/ui" component="admin/Dropdown" story="PlacementTop.tsx" />
|
|
26
|
+
|
|
27
|
+
You can read more about the accessibility patterns used in our Dropdown
|
|
28
|
+
implementation in the ARIA Authoring Practices Guide (APG) at
|
|
29
|
+
[Menu Button](https://www.w3.org/WAI/ARIA/apg/patterns/menubutton/) section.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
var _exportNames = {};
|
|
9
|
+
exports["default"] = void 0;
|
|
10
|
+
|
|
11
|
+
var _Modal = _interopRequireDefault(require("@digigov/ui/admin/Modal"));
|
|
12
|
+
|
|
13
|
+
var _Default = require("./__stories__/Default");
|
|
14
|
+
|
|
15
|
+
Object.keys(_Default).forEach(function (key) {
|
|
16
|
+
if (key === "default" || key === "__esModule") return;
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
18
|
+
if (key in exports && exports[key] === _Default[key]) return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _Default[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
var _AlertDialog = require("./__stories__/AlertDialog");
|
|
28
|
+
|
|
29
|
+
Object.keys(_AlertDialog).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
32
|
+
if (key in exports && exports[key] === _AlertDialog[key]) return;
|
|
33
|
+
Object.defineProperty(exports, key, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function get() {
|
|
36
|
+
return _AlertDialog[key];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
var _default = {
|
|
41
|
+
title: 'Digigov UI/admin/Modal',
|
|
42
|
+
component: _Modal["default"]
|
|
43
|
+
};
|
|
44
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = exports.AlertDialog = void 0;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _Modal = _interopRequireWildcard(require("@digigov/ui/admin/Modal"));
|
|
17
|
+
|
|
18
|
+
var _core = require("@digigov/ui/core");
|
|
19
|
+
|
|
20
|
+
var _typography = require("@digigov/ui/typography");
|
|
21
|
+
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
function useModal() {
|
|
27
|
+
var _useState = (0, _react.useState)(false),
|
|
28
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
29
|
+
open = _useState2[0],
|
|
30
|
+
setOpen = _useState2[1];
|
|
31
|
+
|
|
32
|
+
function toggleModal() {
|
|
33
|
+
setOpen(!open);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
open: open,
|
|
38
|
+
toggleModal: toggleModal
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var _ref = /*#__PURE__*/_react["default"].createElement(_Modal.ModalHeading, {
|
|
43
|
+
id: "modal-label"
|
|
44
|
+
}, "\u0395\u03C0\u03B9\u03B2\u03B5\u03B2\u03B1\u03AF\u03C9\u03C3\u03B7");
|
|
45
|
+
|
|
46
|
+
var _ref2 = /*#__PURE__*/_react["default"].createElement(_Modal.ModalContent, {
|
|
47
|
+
id: "modal-content"
|
|
48
|
+
}, /*#__PURE__*/_react["default"].createElement(_typography.Paragraph, null, "\u0395\u03AF\u03C3\u03C4\u03B5 \u03C3\u03AF\u03B3\u03BF\u03C5\u03C1\u03BF\u03B9 \u03CC\u03C4\u03B9 \u03B8\u03AD\u03BB\u03B5\u03C4\u03B5 \u03BD\u03B1 \u03B4\u03B9\u03B1\u03B3\u03C1\u03AC\u03C8\u03B5\u03C4\u03B5 \u03C4\u03B7\u03BD \u03B5\u03B3\u03B3\u03C1\u03B1\u03C6\u03AE;"));
|
|
49
|
+
|
|
50
|
+
var AlertDialog = function AlertDialog() {
|
|
51
|
+
var _useModal = useModal(),
|
|
52
|
+
open = _useModal.open,
|
|
53
|
+
toggleModal = _useModal.toggleModal;
|
|
54
|
+
|
|
55
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
56
|
+
color: "warning",
|
|
57
|
+
onClick: function onClick() {
|
|
58
|
+
return toggleModal();
|
|
59
|
+
}
|
|
60
|
+
}, "\u0394\u03B9\u03B1\u03B3\u03C1\u03B1\u03C6\u03AE"), /*#__PURE__*/_react["default"].createElement(_Modal["default"], {
|
|
61
|
+
open: open,
|
|
62
|
+
role: "alertdialog",
|
|
63
|
+
"aria-modal": "true",
|
|
64
|
+
"aria-labelledby": "modal-label",
|
|
65
|
+
"aria-describedby": "modal-content"
|
|
66
|
+
}, _ref, _ref2, /*#__PURE__*/_react["default"].createElement(_Modal.ModalAction, null, /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
67
|
+
onClick: function onClick() {
|
|
68
|
+
return toggleModal();
|
|
69
|
+
}
|
|
70
|
+
}, "\u0394\u03B9\u03B1\u03B3\u03C1\u03B1\u03C6\u03AE"), /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
71
|
+
variant: "link",
|
|
72
|
+
onClick: function onClick() {
|
|
73
|
+
return toggleModal();
|
|
74
|
+
}
|
|
75
|
+
}, "\u0391\u03BA\u03CD\u03C1\u03C9\u03C3\u03B7"))));
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.AlertDialog = AlertDialog;
|
|
79
|
+
var _default = AlertDialog;
|
|
80
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = exports.Default = void 0;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _Modal = _interopRequireWildcard(require("@digigov/ui/admin/Modal"));
|
|
17
|
+
|
|
18
|
+
var _core = require("@digigov/ui/core");
|
|
19
|
+
|
|
20
|
+
var _Field = _interopRequireDefault(require("@digigov/ui/core/Field"));
|
|
21
|
+
|
|
22
|
+
var _Label = _interopRequireDefault(require("@digigov/react-core/Label"));
|
|
23
|
+
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
|
+
function useModal() {
|
|
29
|
+
var _useState = (0, _react.useState)(false),
|
|
30
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
31
|
+
open = _useState2[0],
|
|
32
|
+
setOpen = _useState2[1];
|
|
33
|
+
|
|
34
|
+
function toggleModal() {
|
|
35
|
+
setOpen(!open);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
open: open,
|
|
40
|
+
toggleModal: toggleModal
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var _ref = /*#__PURE__*/_react["default"].createElement(_Modal.ModalHeading, {
|
|
45
|
+
id: "modal-label"
|
|
46
|
+
}, "\u03A0\u03C1\u03BF\u03C3\u03B8\u03AE\u03BA\u03B7 \u03C4\u03B7\u03BB\u03B5\u03C6\u03CE\u03BD\u03BF\u03C5");
|
|
47
|
+
|
|
48
|
+
var _ref2 = /*#__PURE__*/_react["default"].createElement(_Modal.ModalContent, null, /*#__PURE__*/_react["default"].createElement(_Field["default"], null, /*#__PURE__*/_react["default"].createElement(_Label["default"], null, "\u03A3\u03C5\u03BC\u03C0\u03BB\u03B7\u03C1\u03CE\u03C3\u03C4\u03B5 \u03C4\u03BF \u03C4\u03B7\u03BB\u03AD\u03C6\u03C9\u03BD\u03BF \u03B5\u03C0\u03B9\u03BA\u03BF\u03B9\u03BD\u03C9\u03BD\u03AF\u03B1\u03C2", /*#__PURE__*/_react["default"].createElement(_core.TextInput, {
|
|
49
|
+
name: "inputext",
|
|
50
|
+
characterWidth: 10
|
|
51
|
+
}))));
|
|
52
|
+
|
|
53
|
+
var _ref3 = /*#__PURE__*/_react["default"].createElement(_core.Button, null, "\u03A5\u03C0\u03BF\u03B2\u03BF\u03BB\u03AE");
|
|
54
|
+
|
|
55
|
+
var Default = function Default() {
|
|
56
|
+
var _useModal = useModal(),
|
|
57
|
+
open = _useModal.open,
|
|
58
|
+
toggleModal = _useModal.toggleModal;
|
|
59
|
+
|
|
60
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
61
|
+
onClick: function onClick() {
|
|
62
|
+
return toggleModal();
|
|
63
|
+
}
|
|
64
|
+
}, "\u03A0\u03C1\u03BF\u03C3\u03B8\u03AE\u03BA\u03B7 \u03C4\u03B7\u03BB\u03B5\u03C6\u03CE\u03BD\u03BF\u03C5"), /*#__PURE__*/_react["default"].createElement(_Modal["default"], {
|
|
65
|
+
open: open,
|
|
66
|
+
role: "dialog",
|
|
67
|
+
"aria-modal": "true",
|
|
68
|
+
"aria-labelledby": "modal-label"
|
|
69
|
+
}, _ref, _ref2, /*#__PURE__*/_react["default"].createElement(_Modal.ModalAction, null, _ref3, /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
70
|
+
variant: "link",
|
|
71
|
+
onClick: function onClick() {
|
|
72
|
+
return toggleModal();
|
|
73
|
+
}
|
|
74
|
+
}, "\u0391\u03BA\u03CD\u03C1\u03C9\u03C3\u03B7"))));
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.Default = Default;
|
|
78
|
+
var _default = Default;
|
|
79
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: modal
|
|
3
|
+
title: Modal
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
import Modal, {ModalHeading, ModalContent, ModalAction} from "@digigov/ui/admin/Modal";
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## How to use
|
|
11
|
+
|
|
12
|
+
### As a Dialog
|
|
13
|
+
|
|
14
|
+
<Story packageName="@digigov/ui" component="admin/Modal" story="Default.tsx" />
|
|
15
|
+
|
|
16
|
+
### As an Alert Dialog
|
|
17
|
+
|
|
18
|
+
<Story packageName="@digigov/ui" component="admin/Modal" story="AlertDialog.tsx" />
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Accessibility
|
|
22
|
+
|
|
23
|
+
You can read more about the accessibility patterns used in our Modal
|
|
24
|
+
implementation in the ARIA Authoring Practices Guide (APG) at
|
|
25
|
+
[Dialog](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/) and
|
|
26
|
+
[Alert Dialog](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/) sections.
|
package/admin/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from '@digigov/ui/admin/Dropdown';
|
|
2
2
|
export * from '@digigov/ui/admin/Chip';
|
|
3
|
-
export * from '@digigov/ui/admin/
|
|
3
|
+
export * from '@digigov/ui/admin/CopyToClipboard';
|
|
4
4
|
export * from '@digigov/ui/admin/FillableText';
|
|
5
5
|
export * from '@digigov/ui/admin/Drawer';
|
|
6
6
|
export * from '@digigov/ui/admin/Modal';
|
package/admin/index.js
CHANGED
|
@@ -30,15 +30,15 @@ Object.keys(_Chip).forEach(function (key) {
|
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _CopyToClipboard = require("@digigov/ui/admin/CopyToClipboard");
|
|
34
34
|
|
|
35
|
-
Object.keys(
|
|
35
|
+
Object.keys(_CopyToClipboard).forEach(function (key) {
|
|
36
36
|
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] ===
|
|
37
|
+
if (key in exports && exports[key] === _CopyToClipboard[key]) return;
|
|
38
38
|
Object.defineProperty(exports, key, {
|
|
39
39
|
enumerable: true,
|
|
40
40
|
get: function get() {
|
|
41
|
-
return
|
|
41
|
+
return _CopyToClipboard[key];
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
});
|
package/api/fetchAPI.js
CHANGED
|
@@ -2,29 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports["default"] = void 0;
|
|
9
11
|
exports.fetchAPI = fetchAPI;
|
|
10
12
|
|
|
11
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
-
|
|
13
13
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
14
14
|
|
|
15
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
16
|
|
|
17
17
|
var _utils = require("@digigov/ui/api/utils");
|
|
18
18
|
|
|
19
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
20
|
+
|
|
19
21
|
function fetchAPI(_x, _x2, _x3) {
|
|
20
22
|
return _fetchAPI.apply(this, arguments);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
function _fetchAPI() {
|
|
24
|
-
_fetchAPI = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
26
|
+
_fetchAPI = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(resource, _ref, apiConfig) {
|
|
25
27
|
var _ref$query, query, _ref$path, path, _ref$method, method, _ref$body, body, baseURL, token, _getArgs, _getArgs2, url, options, response, _yield$processRespons, data, error, status;
|
|
26
28
|
|
|
27
|
-
return
|
|
29
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
28
30
|
while (1) {
|
|
29
31
|
switch (_context.prev = _context.next) {
|
|
30
32
|
case 0:
|
package/api/index.spec.js
CHANGED
|
@@ -4,8 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
|
|
5
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
6
|
|
|
7
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
8
|
-
|
|
9
7
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
8
|
|
|
11
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
@@ -30,7 +28,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
30
28
|
|
|
31
29
|
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; }
|
|
32
30
|
|
|
33
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
31
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
32
|
+
|
|
34
33
|
var _ref2 = /*#__PURE__*/_react["default"].createElement("span", null, "something went wrong");
|
|
35
34
|
|
|
36
35
|
var HandleError = function HandleError(_ref) {
|
|
@@ -114,10 +113,10 @@ describe('fetchAPI', function () {
|
|
|
114
113
|
});
|
|
115
114
|
beforeEach(_fetchMock["default"].resetBehavior);
|
|
116
115
|
beforeEach(_fetchMock["default"].resetHistory);
|
|
117
|
-
it('fetchAPI gets', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
116
|
+
it('fetchAPI gets', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
118
117
|
var resource, path, _yield$fetchAPI, data;
|
|
119
118
|
|
|
120
|
-
return
|
|
119
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
121
120
|
while (1) {
|
|
122
121
|
switch (_context.prev = _context.next) {
|
|
123
122
|
case 0:
|
|
@@ -157,10 +156,10 @@ describe('useResource', function () {
|
|
|
157
156
|
});
|
|
158
157
|
beforeEach(_fetchMock["default"].resetBehavior);
|
|
159
158
|
beforeEach(_fetchMock["default"].resetHistory);
|
|
160
|
-
it('useResource should return data', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
159
|
+
it('useResource should return data', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
161
160
|
var resource, Page, _render, container, _container$firstChild, _container$firstChild2;
|
|
162
161
|
|
|
163
|
-
return
|
|
162
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
164
163
|
while (1) {
|
|
165
164
|
switch (_context2.prev = _context2.next) {
|
|
166
165
|
case 0:
|
|
@@ -207,12 +206,12 @@ describe('useResource', function () {
|
|
|
207
206
|
}
|
|
208
207
|
}, _callee2);
|
|
209
208
|
})));
|
|
210
|
-
it('should run duplicate request once', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
209
|
+
it('should run duplicate request once', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
211
210
|
var _container$firstChild3, _container$firstChild4;
|
|
212
211
|
|
|
213
212
|
var resource, Page, _render2, container;
|
|
214
213
|
|
|
215
|
-
return
|
|
214
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
216
215
|
while (1) {
|
|
217
216
|
switch (_context3.prev = _context3.next) {
|
|
218
217
|
case 0:
|
|
@@ -261,12 +260,12 @@ describe('useResourceAction', function () {
|
|
|
261
260
|
});
|
|
262
261
|
beforeEach(_fetchMock["default"].resetBehavior);
|
|
263
262
|
beforeEach(_fetchMock["default"].resetHistory);
|
|
264
|
-
it('useResourceAction should return result ', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
263
|
+
it('useResourceAction should return result ', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
265
264
|
var _container$firstChild5, _container$firstChild6;
|
|
266
265
|
|
|
267
266
|
var resource, Page, _render3, container;
|
|
268
267
|
|
|
269
|
-
return
|
|
268
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
270
269
|
while (1) {
|
|
271
270
|
switch (_context4.prev = _context4.next) {
|
|
272
271
|
case 0:
|
|
@@ -312,12 +311,12 @@ describe('useResourceAction', function () {
|
|
|
312
311
|
}
|
|
313
312
|
}, _callee4);
|
|
314
313
|
})));
|
|
315
|
-
it('useResourceAction should be invalidated and run twice', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
314
|
+
it('useResourceAction should be invalidated and run twice', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
316
315
|
var _container$firstChild7, _container$firstChild8, _container$firstChild9, _container$firstChild10;
|
|
317
316
|
|
|
318
317
|
var resource, Page, _render4, container;
|
|
319
318
|
|
|
320
|
-
return
|
|
319
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
321
320
|
while (1) {
|
|
322
321
|
switch (_context5.prev = _context5.next) {
|
|
323
322
|
case 0:
|
|
@@ -391,12 +390,12 @@ describe('useResourceMany', function () {
|
|
|
391
390
|
beforeEach(_fetchMock["default"].resetBehavior);
|
|
392
391
|
beforeEach(_fetchMock["default"].resetHistory); //check this test again (loading/hello)
|
|
393
392
|
|
|
394
|
-
it('useResourceMany should return data', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
393
|
+
it('useResourceMany should return data', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
395
394
|
var _container$firstChild11, _container$firstChild12;
|
|
396
395
|
|
|
397
396
|
var resource, Page, _render5, container;
|
|
398
397
|
|
|
399
|
-
return
|
|
398
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
400
399
|
while (1) {
|
|
401
400
|
switch (_context6.prev = _context6.next) {
|
|
402
401
|
case 0:
|
|
@@ -443,12 +442,12 @@ describe('useResourceMany', function () {
|
|
|
443
442
|
}
|
|
444
443
|
}, _callee6);
|
|
445
444
|
})));
|
|
446
|
-
it('useResourceMany should handle hasNext, hasPrevious', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
445
|
+
it('useResourceMany should handle hasNext, hasPrevious', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
447
446
|
var _container$firstChild13, _container$firstChild14;
|
|
448
447
|
|
|
449
448
|
var resource, Page, _render6, container;
|
|
450
449
|
|
|
451
|
-
return
|
|
450
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
452
451
|
while (1) {
|
|
453
452
|
switch (_context7.prev = _context7.next) {
|
|
454
453
|
case 0:
|
|
@@ -496,12 +495,12 @@ describe('useResourceMany', function () {
|
|
|
496
495
|
}
|
|
497
496
|
}, _callee7);
|
|
498
497
|
})));
|
|
499
|
-
it('useResourceMany should handle setPage with custom limit option', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
498
|
+
it('useResourceMany should handle setPage with custom limit option', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
500
499
|
var _container$firstChild15, _container$firstChild16, _container$firstChild17;
|
|
501
500
|
|
|
502
501
|
var resource, Page, _render7, container, getByText;
|
|
503
502
|
|
|
504
|
-
return
|
|
503
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
505
504
|
while (1) {
|
|
506
505
|
switch (_context8.prev = _context8.next) {
|
|
507
506
|
case 0:
|
package/api/useResource.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports.useResource = useResource;
|
|
9
11
|
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
12
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
13
|
|
|
14
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
@@ -21,6 +21,8 @@ var _api = require("@digigov/ui/api");
|
|
|
21
21
|
|
|
22
22
|
var _react = require("react");
|
|
23
23
|
|
|
24
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
25
|
+
|
|
24
26
|
function useResource(resource, id, query, options, suspense) {
|
|
25
27
|
var _useAPI = (0, _api.useAPI)(),
|
|
26
28
|
baseURL = _useAPI.config.baseURL,
|
|
@@ -41,10 +43,10 @@ function useResource(resource, id, query, options, suspense) {
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
function _customFetcher() {
|
|
44
|
-
_customFetcher = (0, _asyncToGenerator2["default"])( /*#__PURE__*/
|
|
46
|
+
_customFetcher = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fetchUrl, options) {
|
|
45
47
|
var response, _yield$processRespons, _data, _error;
|
|
46
48
|
|
|
47
|
-
return
|
|
49
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
48
50
|
while (1) {
|
|
49
51
|
switch (_context.prev = _context.next) {
|
|
50
52
|
case 0:
|