@k-int/stripes-kint-components 5.10.0 → 5.11.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 +7 -0
- package/es/index.js +12 -0
- package/es/lib/Tags/Tags.js +143 -0
- package/es/lib/Tags/Tags.test.js +80 -0
- package/es/lib/Tags/hooks/index.js +28 -0
- package/es/lib/Tags/hooks/useTags.js +15 -0
- package/es/lib/Tags/hooks/useTagsEnabled.js +25 -0
- package/es/lib/Tags/index.js +40 -0
- package/es/lib/Tags/tagsConfig.js +10 -0
- package/es/lib/hooks/useHelperApp.js +18 -15
- package/package.json +3 -2
- package/src/index.js +2 -0
- package/src/lib/Tags/Tags.js +145 -0
- package/src/lib/Tags/Tags.test.js +77 -0
- package/src/lib/Tags/hooks/index.js +2 -0
- package/src/lib/Tags/hooks/useTags.js +16 -0
- package/src/lib/Tags/hooks/useTagsEnabled.js +19 -0
- package/src/lib/Tags/index.js +4 -0
- package/src/lib/Tags/tagsConfig.js +16 -0
- package/src/lib/hooks/useHelperApp.js +21 -13
- package/test/helpers/test-implementor-translations.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [5.11.0](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.10.0...v5.11.0) (2025-02-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Added Tags helper app and hooks to stripes-kint-components (Moving out of erm-components longer term) ([e881639](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/commit/e881639b49036d6016dc65d83bcf67e596652acc))
|
|
7
|
+
|
|
1
8
|
# [5.10.0](https://gitlab.com/knowledge-integration/folio/stripes-kint-components/compare/v5.9.0...v5.10.0) (2025-02-04)
|
|
2
9
|
|
|
3
10
|
|
package/es/index.js
CHANGED
|
@@ -400,6 +400,18 @@ var _ResponsiveButtonGroup = _interopRequireDefault(require("./lib/ResponsiveBut
|
|
|
400
400
|
var _SettingsFormContainer = _interopRequireDefault(require("./lib/SettingsFormContainer"));
|
|
401
401
|
var _ComboButton = _interopRequireDefault(require("./lib/ComboButton"));
|
|
402
402
|
var _NumberField = _interopRequireDefault(require("./lib/NumberField"));
|
|
403
|
+
var _Tags = require("./lib/Tags");
|
|
404
|
+
Object.keys(_Tags).forEach(function (key) {
|
|
405
|
+
if (key === "default" || key === "__esModule") return;
|
|
406
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
407
|
+
if (key in exports && exports[key] === _Tags[key]) return;
|
|
408
|
+
Object.defineProperty(exports, key, {
|
|
409
|
+
enumerable: true,
|
|
410
|
+
get: function () {
|
|
411
|
+
return _Tags[key];
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
});
|
|
403
415
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
404
416
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
405
417
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _reactQuery = require("react-query");
|
|
10
|
+
var _core = require("@folio/stripes/core");
|
|
11
|
+
var _lodash = require("lodash");
|
|
12
|
+
var _components = require("@folio/stripes/components");
|
|
13
|
+
var _smartComponents = require("@folio/stripes/smart-components");
|
|
14
|
+
var _tagsConfig = require("./tagsConfig");
|
|
15
|
+
var _hooks = require("./hooks");
|
|
16
|
+
var _hooks2 = require("../hooks");
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
const Tags = _ref => {
|
|
20
|
+
let {
|
|
21
|
+
invalidateLinks = [],
|
|
22
|
+
// If there are other queries that need invalidating, pass those here
|
|
23
|
+
labelOverrides = {},
|
|
24
|
+
link,
|
|
25
|
+
onToggle,
|
|
26
|
+
intlKey: passedIntlKey,
|
|
27
|
+
intlNS: passedIntlNS
|
|
28
|
+
} = _ref;
|
|
29
|
+
const kintIntl = (0, _hooks2.useKintIntl)(passedIntlKey, passedIntlNS);
|
|
30
|
+
const ky = (0, _core.useOkapiKy)();
|
|
31
|
+
const callout = (0, _react.useContext)(_core.CalloutContext);
|
|
32
|
+
const queryClient = (0, _reactQuery.useQueryClient)();
|
|
33
|
+
|
|
34
|
+
// TAG GET/POST
|
|
35
|
+
const {
|
|
36
|
+
data: {
|
|
37
|
+
tags = []
|
|
38
|
+
} = {}
|
|
39
|
+
} = (0, _hooks.useTags)([..._tagsConfig.tagNamespaceArray, link]);
|
|
40
|
+
|
|
41
|
+
// istanbul ignore next
|
|
42
|
+
const {
|
|
43
|
+
mutateAsync: postTags
|
|
44
|
+
} = (0, _reactQuery.useMutation)(['tags', 'stripes-erm-components', 'Tags', 'postTags'], data => ky.post('tags', {
|
|
45
|
+
json: data
|
|
46
|
+
}).then(() => {
|
|
47
|
+
queryClient.invalidateQueries('tags');
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
// ENTITY GET/PUT
|
|
51
|
+
const {
|
|
52
|
+
data: entity
|
|
53
|
+
} = (0, _reactQuery.useQuery)([link, 'stripes-erm-components', 'Tags'], () => ky.get(link).json());
|
|
54
|
+
|
|
55
|
+
// istanbul ignore next
|
|
56
|
+
const {
|
|
57
|
+
mutateAsync: putEntity
|
|
58
|
+
} = (0, _reactQuery.useMutation)([link, 'stripes-erm-components', 'Tags', 'putEntity'], data => ky.put(link, {
|
|
59
|
+
json: data
|
|
60
|
+
}).then(() => {
|
|
61
|
+
queryClient.invalidateQueries(link);
|
|
62
|
+
if (invalidateLinks?.length) {
|
|
63
|
+
invalidateLinks.forEach(il => queryClient.invalidateQueries(il));
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
// add tags to global list of tags
|
|
68
|
+
// istanbul ignore next
|
|
69
|
+
const saveTags = tagsToSave => {
|
|
70
|
+
const newTag = (0, _lodash.difference)(tagsToSave.map(t => t.value || t), tags.map(t => t.label.toLowerCase()));
|
|
71
|
+
if (!newTag || !newTag.length) return;
|
|
72
|
+
postTags({
|
|
73
|
+
label: newTag[0],
|
|
74
|
+
description: newTag[0]
|
|
75
|
+
});
|
|
76
|
+
callout.sendCallout({
|
|
77
|
+
message: kintIntl.formatKintMessage({
|
|
78
|
+
id: 'newTagCreated',
|
|
79
|
+
overrideValue: labelOverrides.newTagCreated
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// add tag to the list of entity tags
|
|
85
|
+
// istanbul ignore next
|
|
86
|
+
const saveEntityTags = tagsToSave => {
|
|
87
|
+
const tagListMap = (entity?.tags ?? []).map(tag => ({
|
|
88
|
+
'value': tag.value
|
|
89
|
+
}));
|
|
90
|
+
const tagsMap = tagsToSave.map(tag => ({
|
|
91
|
+
'value': tag.value || tag
|
|
92
|
+
}));
|
|
93
|
+
const newTags = (0, _lodash.sortBy)((0, _lodash.uniqBy)([...tagListMap, ...tagsMap], 'value'));
|
|
94
|
+
putEntity({
|
|
95
|
+
tags: newTags
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const onAdd = addTags => {
|
|
99
|
+
saveEntityTags(addTags);
|
|
100
|
+
saveTags(addTags);
|
|
101
|
+
};
|
|
102
|
+
const onRemove = tag => {
|
|
103
|
+
const tagToDelete = (entity?.tags ?? []).filter(t => t.value.toLowerCase() === tag.toLowerCase());
|
|
104
|
+
putEntity({
|
|
105
|
+
tags: [{
|
|
106
|
+
id: tagToDelete[0].id,
|
|
107
|
+
_delete: true
|
|
108
|
+
}]
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const entityTags = (entity?.tags ?? []).map(tag => tag.value.toLowerCase());
|
|
112
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Pane, {
|
|
113
|
+
defaultWidth: "20%",
|
|
114
|
+
dismissible: true,
|
|
115
|
+
id: "tags-helper-pane",
|
|
116
|
+
onClose: onToggle,
|
|
117
|
+
paneSub: kintIntl.formatKintMessage({
|
|
118
|
+
id: 'numberOfTags',
|
|
119
|
+
overrideValue: labelOverrides.numberOfTags
|
|
120
|
+
}, {
|
|
121
|
+
count: entity?.tags?.length ?? 0
|
|
122
|
+
}),
|
|
123
|
+
paneTitle: kintIntl.formatKintMessage({
|
|
124
|
+
id: 'tags',
|
|
125
|
+
overrideValue: labelOverrides.tags
|
|
126
|
+
}),
|
|
127
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_smartComponents.TagsForm, {
|
|
128
|
+
entityTags: entityTags,
|
|
129
|
+
onAdd: onAdd,
|
|
130
|
+
onRemove: onRemove,
|
|
131
|
+
tags: tags
|
|
132
|
+
})
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
Tags.propTypes = {
|
|
136
|
+
intlKey: _propTypes.default.string,
|
|
137
|
+
intlNS: _propTypes.default.string,
|
|
138
|
+
invalidateLinks: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
139
|
+
labelOverrides: _propTypes.default.object,
|
|
140
|
+
link: _propTypes.default.string,
|
|
141
|
+
onToggle: _propTypes.default.func
|
|
142
|
+
};
|
|
143
|
+
var _default = exports.default = Tags;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
var _reactRouterDom = require("react-router-dom");
|
|
5
|
+
var _stripesErmTesting = require("@folio/stripes-erm-testing");
|
|
6
|
+
var _Tags = _interopRequireDefault(require("./Tags"));
|
|
7
|
+
var _jest = require("../../../test/jest");
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const onToggle = jest.fn();
|
|
11
|
+
const onAdd = jest.fn();
|
|
12
|
+
const link = 'erm/sas/14c16fc4-f986-4e60-aa59-4e627fcf160b';
|
|
13
|
+
describe('Tags', () => {
|
|
14
|
+
let renderComponent;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
renderComponent = (0, _jest.renderWithKintHarness)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.MemoryRouter, {
|
|
17
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tags.default, {
|
|
18
|
+
invalidateLinks: [],
|
|
19
|
+
link: link,
|
|
20
|
+
onAdd: onAdd,
|
|
21
|
+
onToggle: onToggle
|
|
22
|
+
})
|
|
23
|
+
}));
|
|
24
|
+
});
|
|
25
|
+
test('renders the expected label', () => {
|
|
26
|
+
const {
|
|
27
|
+
getByText
|
|
28
|
+
} = renderComponent;
|
|
29
|
+
expect(getByText('0 Tags')).toBeInTheDocument();
|
|
30
|
+
});
|
|
31
|
+
test('renders expected pane dismiss button ', async () => {
|
|
32
|
+
await (0, _stripesErmTesting.IconButton)('Close Tags').exists();
|
|
33
|
+
});
|
|
34
|
+
test('renders expected open menu button ', () => {
|
|
35
|
+
const {
|
|
36
|
+
getByRole
|
|
37
|
+
} = renderComponent;
|
|
38
|
+
expect(getByRole('button', {
|
|
39
|
+
name: 'stripes-components.multiSelection.dropdownTriggerLabel'
|
|
40
|
+
})).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
test('renders tags heading ', () => {
|
|
43
|
+
const {
|
|
44
|
+
getByRole
|
|
45
|
+
} = renderComponent;
|
|
46
|
+
expect(getByRole('heading', {
|
|
47
|
+
name: 'Tags'
|
|
48
|
+
})).toBeInTheDocument();
|
|
49
|
+
});
|
|
50
|
+
test('renders expected region with zero tags', () => {
|
|
51
|
+
const {
|
|
52
|
+
getByRole
|
|
53
|
+
} = renderComponent;
|
|
54
|
+
expect(getByRole('region', {
|
|
55
|
+
name: 'Tags 0 Tags'
|
|
56
|
+
})).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
test('renders the expected multiSelectDescription', () => {
|
|
59
|
+
const {
|
|
60
|
+
getByText
|
|
61
|
+
} = renderComponent;
|
|
62
|
+
expect(getByText('Contains a list of any selected values, followed by an autocomplete textfield for selecting additional values.')).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
test('renders the expected label', () => {
|
|
65
|
+
const {
|
|
66
|
+
getByText
|
|
67
|
+
} = renderComponent;
|
|
68
|
+
expect(getByText('0 items selected')).toBeInTheDocument();
|
|
69
|
+
});
|
|
70
|
+
test('displays the tags pane', async () => {
|
|
71
|
+
await (0, _stripesErmTesting.Pane)('Tags').is({
|
|
72
|
+
visible: true
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
test('displays the tags pane header', async () => {
|
|
76
|
+
await (0, _stripesErmTesting.PaneHeader)('Tags').is({
|
|
77
|
+
visible: true
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "tagsEnabledQueryKey", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useTagsEnabled.tagsEnabledQueryKey;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useTags", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _useTags.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "useTagsEnabled", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _useTagsEnabled.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _useTagsEnabled = _interopRequireWildcard(require("./useTagsEnabled"));
|
|
25
|
+
var _useTags = _interopRequireDefault(require("./useTags"));
|
|
26
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
28
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactQuery = require("react-query");
|
|
8
|
+
var _core = require("@folio/stripes/core");
|
|
9
|
+
var _tagsConfig = require("../tagsConfig");
|
|
10
|
+
const useTags = (namespaceArray, options) => {
|
|
11
|
+
const ky = (0, _core.useOkapiKy)();
|
|
12
|
+
const nsArray = namespaceArray ?? _tagsConfig.tagNamespaceArray;
|
|
13
|
+
return (0, _reactQuery.useQuery)(nsArray, () => ky.get(_tagsConfig.defaultTagQuery).json(), options);
|
|
14
|
+
};
|
|
15
|
+
var _default = exports.default = useTags;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tagsEnabledQueryKey = exports.default = void 0;
|
|
7
|
+
var _core = require("@folio/stripes/core");
|
|
8
|
+
var _reactQuery = require("react-query");
|
|
9
|
+
var _endpoints = require("../../constants/endpoints");
|
|
10
|
+
const tagsEnabledQueryKey = exports.tagsEnabledQueryKey = [_endpoints.MOD_SETTINGS_ENDPOINT, 'query=(module==TAGS and configName==tags_enabled)', 'stripes-kint-components', 'useTagsEnabled'];
|
|
11
|
+
const useTagsEnabled = () => {
|
|
12
|
+
const ky = (0, _core.useOkapiKy)();
|
|
13
|
+
const queryObject = (0, _reactQuery.useQuery)(tagsEnabledQueryKey, () => ky.get(`${_endpoints.MOD_SETTINGS_ENDPOINT}?query=(module==TAGS and configName==tags_enabled)`).json());
|
|
14
|
+
const {
|
|
15
|
+
data: {
|
|
16
|
+
configs: {
|
|
17
|
+
0: {
|
|
18
|
+
value
|
|
19
|
+
} = {}
|
|
20
|
+
} = []
|
|
21
|
+
} = {}
|
|
22
|
+
} = queryObject;
|
|
23
|
+
return !value || value === 'true';
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = useTagsEnabled;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
Tags: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "Tags", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _Tags.default;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _Tags = _interopRequireDefault(require("./Tags"));
|
|
16
|
+
var _tagsConfig = require("./tagsConfig");
|
|
17
|
+
Object.keys(_tagsConfig).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
+
if (key in exports && exports[key] === _tagsConfig[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _tagsConfig[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _hooks = require("./hooks");
|
|
29
|
+
Object.keys(_hooks).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] === _hooks[key]) return;
|
|
33
|
+
Object.defineProperty(exports, key, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _hooks[key];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.tagsPath = exports.tagNamespaceArray = exports.defaultTagsParams = exports.defaultTagQuery = void 0;
|
|
7
|
+
const tagNamespaceArray = exports.tagNamespaceArray = ['tags', 'stripes-kint-components', 'Tags'];
|
|
8
|
+
const tagsPath = exports.tagsPath = 'tags';
|
|
9
|
+
const defaultTagsParams = exports.defaultTagsParams = ['limit=1000', 'query=cql.allRecords%3D1%20sortby%20label'];
|
|
10
|
+
const defaultTagQuery = exports.defaultTagQuery = `${tagsPath}?${defaultTagsParams?.join('&')}`;
|
|
@@ -4,18 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _react =
|
|
7
|
+
var _react = require("react");
|
|
8
8
|
var _reactRouterDom = require("react-router-dom");
|
|
9
9
|
var _queryString = _interopRequireDefault(require("query-string"));
|
|
10
10
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
11
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
let helperObject = {};
|
|
16
13
|
const useHelperApp = helpers => {
|
|
17
14
|
const history = (0, _reactRouterDom.useHistory)();
|
|
18
15
|
const location = (0, _reactRouterDom.useLocation)();
|
|
16
|
+
const [helperObject, setHelperObject] = (0, _react.useState)({});
|
|
17
|
+
const [helperToggleFunctions, setHelperToggleFunctions] = (0, _react.useState)({});
|
|
19
18
|
const query = _queryString.default.parse(location.search);
|
|
20
19
|
const [currentHelper, setCurrentHelper] = (0, _react.useState)(query?.helper);
|
|
21
20
|
const handleToggleHelper = (0, _react.useCallback)(helper => {
|
|
@@ -25,9 +24,16 @@ const useHelperApp = helpers => {
|
|
|
25
24
|
return currentHelper === hlp;
|
|
26
25
|
};
|
|
27
26
|
(0, _react.useEffect)(() => {
|
|
28
|
-
// Keep object outside of hook to avoid redraw, oncly change when keys change
|
|
29
27
|
if (!(0, _isEqual.default)(Object.keys(helperObject), Object.keys(helpers))) {
|
|
30
|
-
|
|
28
|
+
setHelperObject(helpers);
|
|
29
|
+
}
|
|
30
|
+
const newHelperToggleFunctions = {};
|
|
31
|
+
Object.keys(helperObject).forEach(h => {
|
|
32
|
+
newHelperToggleFunctions[h] = () => handleToggleHelper(h);
|
|
33
|
+
});
|
|
34
|
+
if (!(0, _isEqual.default)(Object.keys(helperToggleFunctions), Object.keys(newHelperToggleFunctions))) {
|
|
35
|
+
// This makes sure adding/removing helpers changes the functions
|
|
36
|
+
setHelperToggleFunctions(newHelperToggleFunctions);
|
|
31
37
|
}
|
|
32
38
|
if (currentHelper !== query?.helper) {
|
|
33
39
|
const newQuery = {
|
|
@@ -38,11 +44,14 @@ const useHelperApp = helpers => {
|
|
|
38
44
|
pathname: location.pathname,
|
|
39
45
|
search: `?${_queryString.default.stringify(newQuery)}`
|
|
40
46
|
});
|
|
47
|
+
|
|
48
|
+
// When helper changes, reset helperToggleFunctions
|
|
49
|
+
setHelperToggleFunctions(newHelperToggleFunctions);
|
|
41
50
|
}
|
|
42
|
-
}, [currentHelper, helpers, history, location, query]);
|
|
51
|
+
}, [currentHelper, handleToggleHelper, helperObject, helperToggleFunctions, helpers, history, location, query]);
|
|
43
52
|
|
|
44
53
|
// Set the HelperComponent
|
|
45
|
-
const HelperComponent = (0, _react.
|
|
54
|
+
const HelperComponent = (0, _react.useCallback)(props => {
|
|
46
55
|
if (!query?.helper) return null;
|
|
47
56
|
let Component = null;
|
|
48
57
|
Component = helperObject[query?.helper];
|
|
@@ -51,13 +60,7 @@ const useHelperApp = helpers => {
|
|
|
51
60
|
onToggle: () => handleToggleHelper(query?.helper),
|
|
52
61
|
...props
|
|
53
62
|
});
|
|
54
|
-
}, [handleToggleHelper, query
|
|
55
|
-
|
|
56
|
-
// Set up the helperToggleFunctions
|
|
57
|
-
const helperToggleFunctions = {};
|
|
58
|
-
Object.keys(helperObject).forEach(h => {
|
|
59
|
-
helperToggleFunctions[h] = () => handleToggleHelper(h);
|
|
60
|
-
});
|
|
63
|
+
}, [handleToggleHelper, helperObject, query?.helper]);
|
|
61
64
|
return {
|
|
62
65
|
currentHelper,
|
|
63
66
|
HelperComponent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k-int/stripes-kint-components",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.0",
|
|
4
4
|
"description": "Stripes Component library for K-Int specific applications",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css"
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"build:es": "rm -rf ./es && babel --extensions .js --ignore ./src/**/tests/**/* ./src --out-dir es",
|
|
14
14
|
"build": "yarn build:es",
|
|
15
15
|
"clean": "rm -rf ./node_modules ./*/node_modules ./yarn.lock && yarn install --ignore-scripts",
|
|
16
|
-
"clean-
|
|
16
|
+
"clean-install": "yarn clean && yarn install --ignore-scripts",
|
|
17
|
+
"clean-build": "yarn clean-install && yarn build",
|
|
17
18
|
"prepare": "yarn build",
|
|
18
19
|
"semantic-release": "semantic-release"
|
|
19
20
|
},
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useQuery, useMutation, useQueryClient } from 'react-query';
|
|
5
|
+
import { CalloutContext, useOkapiKy } from '@folio/stripes/core';
|
|
6
|
+
|
|
7
|
+
import { uniqBy, sortBy, difference } from 'lodash';
|
|
8
|
+
import { Pane } from '@folio/stripes/components';
|
|
9
|
+
|
|
10
|
+
import { TagsForm } from '@folio/stripes/smart-components';
|
|
11
|
+
|
|
12
|
+
import { tagNamespaceArray } from './tagsConfig';
|
|
13
|
+
import { useTags } from './hooks';
|
|
14
|
+
import { useKintIntl } from '../hooks';
|
|
15
|
+
|
|
16
|
+
const Tags = ({
|
|
17
|
+
invalidateLinks = [], // If there are other queries that need invalidating, pass those here
|
|
18
|
+
labelOverrides = {},
|
|
19
|
+
link,
|
|
20
|
+
onToggle,
|
|
21
|
+
intlKey: passedIntlKey,
|
|
22
|
+
intlNS: passedIntlNS,
|
|
23
|
+
}) => {
|
|
24
|
+
const kintIntl = useKintIntl(passedIntlKey, passedIntlNS);
|
|
25
|
+
|
|
26
|
+
const ky = useOkapiKy();
|
|
27
|
+
const callout = useContext(CalloutContext);
|
|
28
|
+
const queryClient = useQueryClient();
|
|
29
|
+
|
|
30
|
+
// TAG GET/POST
|
|
31
|
+
const { data: { tags = [] } = {} } = useTags(
|
|
32
|
+
[...tagNamespaceArray, link]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// istanbul ignore next
|
|
36
|
+
const { mutateAsync: postTags } = useMutation(
|
|
37
|
+
['tags', 'stripes-erm-components', 'Tags', 'postTags'],
|
|
38
|
+
(data) => ky.post('tags', { json: data }).then(() => {
|
|
39
|
+
queryClient.invalidateQueries('tags');
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// ENTITY GET/PUT
|
|
44
|
+
const { data: entity } = useQuery(
|
|
45
|
+
[link, 'stripes-erm-components', 'Tags'],
|
|
46
|
+
() => ky.get(link).json()
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// istanbul ignore next
|
|
50
|
+
const { mutateAsync: putEntity } = useMutation(
|
|
51
|
+
[link, 'stripes-erm-components', 'Tags', 'putEntity'],
|
|
52
|
+
(data) => ky.put(link, { json: data }).then(() => {
|
|
53
|
+
queryClient.invalidateQueries(link);
|
|
54
|
+
if (invalidateLinks?.length) {
|
|
55
|
+
invalidateLinks.forEach(il => queryClient.invalidateQueries(il));
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// add tags to global list of tags
|
|
61
|
+
// istanbul ignore next
|
|
62
|
+
const saveTags = (tagsToSave) => {
|
|
63
|
+
const newTag = difference(tagsToSave.map(t => (t.value || t)), tags.map(t => t.label.toLowerCase()));
|
|
64
|
+
if (!newTag || !newTag.length) return;
|
|
65
|
+
|
|
66
|
+
postTags({
|
|
67
|
+
label: newTag[0],
|
|
68
|
+
description: newTag[0]
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
callout.sendCallout({
|
|
72
|
+
message: kintIntl.formatKintMessage({
|
|
73
|
+
id: 'newTagCreated',
|
|
74
|
+
overrideValue: labelOverrides.newTagCreated
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// add tag to the list of entity tags
|
|
80
|
+
// istanbul ignore next
|
|
81
|
+
const saveEntityTags = (tagsToSave) => {
|
|
82
|
+
const tagListMap = (entity?.tags ?? []).map(tag => ({ 'value': tag.value }));
|
|
83
|
+
const tagsMap = tagsToSave.map(tag => ({ 'value': tag.value || tag }));
|
|
84
|
+
|
|
85
|
+
const newTags = sortBy(uniqBy([...tagListMap, ...tagsMap], 'value'));
|
|
86
|
+
|
|
87
|
+
putEntity({
|
|
88
|
+
tags: newTags
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const onAdd = (addTags) => {
|
|
93
|
+
saveEntityTags(addTags);
|
|
94
|
+
saveTags(addTags);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const onRemove = (tag) => {
|
|
98
|
+
const tagToDelete = (entity?.tags ?? []).filter(t => t.value.toLowerCase() === tag.toLowerCase());
|
|
99
|
+
|
|
100
|
+
putEntity({
|
|
101
|
+
tags: [{ id: tagToDelete[0].id, _delete:true }]
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const entityTags = (entity?.tags ?? []).map(tag => tag.value.toLowerCase());
|
|
106
|
+
return (
|
|
107
|
+
<Pane
|
|
108
|
+
defaultWidth="20%"
|
|
109
|
+
dismissible
|
|
110
|
+
id="tags-helper-pane"
|
|
111
|
+
onClose={onToggle}
|
|
112
|
+
paneSub={kintIntl.formatKintMessage(
|
|
113
|
+
{
|
|
114
|
+
id: 'numberOfTags',
|
|
115
|
+
overrideValue: labelOverrides.numberOfTags
|
|
116
|
+
},
|
|
117
|
+
{ count: entity?.tags?.length ?? 0 }
|
|
118
|
+
)}
|
|
119
|
+
paneTitle={kintIntl.formatKintMessage(
|
|
120
|
+
{
|
|
121
|
+
id: 'tags',
|
|
122
|
+
overrideValue: labelOverrides.tags
|
|
123
|
+
}
|
|
124
|
+
)}
|
|
125
|
+
>
|
|
126
|
+
<TagsForm
|
|
127
|
+
entityTags={entityTags}
|
|
128
|
+
onAdd={onAdd}
|
|
129
|
+
onRemove={onRemove}
|
|
130
|
+
tags={tags}
|
|
131
|
+
/>
|
|
132
|
+
</Pane>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
Tags.propTypes = {
|
|
137
|
+
intlKey: PropTypes.string,
|
|
138
|
+
intlNS: PropTypes.string,
|
|
139
|
+
invalidateLinks: PropTypes.arrayOf(PropTypes.string),
|
|
140
|
+
labelOverrides: PropTypes.object,
|
|
141
|
+
link: PropTypes.string,
|
|
142
|
+
onToggle: PropTypes.func
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default Tags;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
IconButton,
|
|
6
|
+
Pane,
|
|
7
|
+
PaneHeader
|
|
8
|
+
} from '@folio/stripes-erm-testing';
|
|
9
|
+
|
|
10
|
+
import Tags from './Tags';
|
|
11
|
+
import { renderWithKintHarness } from '../../../test/jest';
|
|
12
|
+
|
|
13
|
+
const onToggle = jest.fn();
|
|
14
|
+
const onAdd = jest.fn();
|
|
15
|
+
const link = 'erm/sas/14c16fc4-f986-4e60-aa59-4e627fcf160b';
|
|
16
|
+
|
|
17
|
+
describe('Tags', () => {
|
|
18
|
+
let renderComponent;
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
renderComponent = renderWithKintHarness(
|
|
21
|
+
<MemoryRouter>
|
|
22
|
+
<Tags
|
|
23
|
+
invalidateLinks={[]}
|
|
24
|
+
link={link}
|
|
25
|
+
onAdd={onAdd}
|
|
26
|
+
onToggle={onToggle}
|
|
27
|
+
/>
|
|
28
|
+
</MemoryRouter>
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('renders the expected label', () => {
|
|
33
|
+
const { getByText } = renderComponent;
|
|
34
|
+
expect(getByText('0 Tags')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('renders expected pane dismiss button ', async () => {
|
|
38
|
+
await IconButton('Close Tags').exists();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('renders expected open menu button ', () => {
|
|
42
|
+
const { getByRole } = renderComponent;
|
|
43
|
+
expect(
|
|
44
|
+
getByRole('button', {
|
|
45
|
+
name: 'stripes-components.multiSelection.dropdownTriggerLabel',
|
|
46
|
+
})
|
|
47
|
+
).toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('renders tags heading ', () => {
|
|
51
|
+
const { getByRole } = renderComponent;
|
|
52
|
+
expect(getByRole('heading', { name: 'Tags' })).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('renders expected region with zero tags', () => {
|
|
56
|
+
const { getByRole } = renderComponent;
|
|
57
|
+
expect(getByRole('region', { name: 'Tags 0 Tags' })).toBeInTheDocument();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('renders the expected multiSelectDescription', () => {
|
|
61
|
+
const { getByText } = renderComponent;
|
|
62
|
+
expect(getByText('Contains a list of any selected values, followed by an autocomplete textfield for selecting additional values.')).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test('renders the expected label', () => {
|
|
66
|
+
const { getByText } = renderComponent;
|
|
67
|
+
expect(getByText('0 items selected')).toBeInTheDocument();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('displays the tags pane', async () => {
|
|
71
|
+
await Pane('Tags').is({ visible: true });
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('displays the tags pane header', async () => {
|
|
75
|
+
await PaneHeader('Tags').is({ visible: true });
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useQuery } from 'react-query';
|
|
2
|
+
import { useOkapiKy } from '@folio/stripes/core';
|
|
3
|
+
import { defaultTagQuery, tagNamespaceArray } from '../tagsConfig';
|
|
4
|
+
|
|
5
|
+
const useTags = (namespaceArray, options) => {
|
|
6
|
+
const ky = useOkapiKy();
|
|
7
|
+
const nsArray = namespaceArray ?? tagNamespaceArray;
|
|
8
|
+
|
|
9
|
+
return useQuery(
|
|
10
|
+
nsArray,
|
|
11
|
+
() => ky.get(defaultTagQuery).json(),
|
|
12
|
+
options
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default useTags;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useOkapiKy } from '@folio/stripes/core';
|
|
2
|
+
import { useQuery } from 'react-query';
|
|
3
|
+
import { MOD_SETTINGS_ENDPOINT } from '../../constants/endpoints';
|
|
4
|
+
|
|
5
|
+
export const tagsEnabledQueryKey = [MOD_SETTINGS_ENDPOINT, 'query=(module==TAGS and configName==tags_enabled)', 'stripes-kint-components', 'useTagsEnabled'];
|
|
6
|
+
|
|
7
|
+
const useTagsEnabled = () => {
|
|
8
|
+
const ky = useOkapiKy();
|
|
9
|
+
|
|
10
|
+
const queryObject = useQuery(
|
|
11
|
+
tagsEnabledQueryKey,
|
|
12
|
+
() => ky.get(`${MOD_SETTINGS_ENDPOINT}?query=(module==TAGS and configName==tags_enabled)`).json()
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const { data: { configs: { 0: { value } = {} } = [] } = {} } = queryObject;
|
|
16
|
+
return !value || value === 'true';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default useTagsEnabled;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const tagNamespaceArray = ['tags', 'stripes-kint-components', 'Tags'];
|
|
2
|
+
|
|
3
|
+
const tagsPath = 'tags';
|
|
4
|
+
const defaultTagsParams = [
|
|
5
|
+
'limit=1000',
|
|
6
|
+
'query=cql.allRecords%3D1%20sortby%20label'
|
|
7
|
+
];
|
|
8
|
+
|
|
9
|
+
const defaultTagQuery = `${tagsPath}?${defaultTagsParams?.join('&')}`;
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
tagsPath,
|
|
13
|
+
defaultTagsParams,
|
|
14
|
+
defaultTagQuery,
|
|
15
|
+
tagNamespaceArray
|
|
16
|
+
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
3
|
|
|
4
4
|
import queryString from 'query-string';
|
|
5
5
|
import isEqual from 'lodash/isEqual';
|
|
6
6
|
|
|
7
|
-
let helperObject = {};
|
|
8
|
-
|
|
9
7
|
const useHelperApp = (helpers) => {
|
|
10
8
|
const history = useHistory();
|
|
11
9
|
const location = useLocation();
|
|
12
10
|
|
|
11
|
+
const [helperObject, setHelperObject] = useState({});
|
|
12
|
+
const [helperToggleFunctions, setHelperToggleFunctions] = useState({});
|
|
13
|
+
|
|
13
14
|
const query = queryString.parse(location.search);
|
|
14
15
|
|
|
15
16
|
const [currentHelper, setCurrentHelper] = useState(query?.helper);
|
|
@@ -22,9 +23,18 @@ const useHelperApp = (helpers) => {
|
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
useEffect(() => {
|
|
25
|
-
// Keep object outside of hook to avoid redraw, oncly change when keys change
|
|
26
26
|
if (!isEqual(Object.keys(helperObject), Object.keys(helpers))) {
|
|
27
|
-
|
|
27
|
+
setHelperObject(helpers);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const newHelperToggleFunctions = {};
|
|
31
|
+
Object.keys(helperObject).forEach(h => {
|
|
32
|
+
newHelperToggleFunctions[h] = () => handleToggleHelper(h);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (!isEqual(Object.keys(helperToggleFunctions), Object.keys(newHelperToggleFunctions))) {
|
|
36
|
+
// This makes sure adding/removing helpers changes the functions
|
|
37
|
+
setHelperToggleFunctions(newHelperToggleFunctions);
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
if (currentHelper !== query?.helper) {
|
|
@@ -37,11 +47,14 @@ const useHelperApp = (helpers) => {
|
|
|
37
47
|
pathname: location.pathname,
|
|
38
48
|
search: `?${queryString.stringify(newQuery)}`
|
|
39
49
|
});
|
|
50
|
+
|
|
51
|
+
// When helper changes, reset helperToggleFunctions
|
|
52
|
+
setHelperToggleFunctions(newHelperToggleFunctions);
|
|
40
53
|
}
|
|
41
|
-
}, [currentHelper, helpers, history, location, query]);
|
|
54
|
+
}, [currentHelper, handleToggleHelper, helperObject, helperToggleFunctions, helpers, history, location, query]);
|
|
42
55
|
|
|
43
56
|
// Set the HelperComponent
|
|
44
|
-
const HelperComponent =
|
|
57
|
+
const HelperComponent = useCallback((props) => {
|
|
45
58
|
if (!query?.helper) return null;
|
|
46
59
|
|
|
47
60
|
let Component = null;
|
|
@@ -56,13 +69,8 @@ const useHelperApp = (helpers) => {
|
|
|
56
69
|
{...props}
|
|
57
70
|
/>
|
|
58
71
|
);
|
|
59
|
-
}
|
|
72
|
+
}, [handleToggleHelper, helperObject, query?.helper]);
|
|
60
73
|
|
|
61
|
-
// Set up the helperToggleFunctions
|
|
62
|
-
const helperToggleFunctions = {};
|
|
63
|
-
Object.keys(helperObject).forEach(h => {
|
|
64
|
-
helperToggleFunctions[h] = () => handleToggleHelper(h);
|
|
65
|
-
});
|
|
66
74
|
|
|
67
75
|
return { currentHelper, HelperComponent, helperToggleFunctions, isOpen };
|
|
68
76
|
};
|