@truedat/core 4.54.6 → 4.54.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truedat/core",
3
- "version": "4.54.6",
3
+ "version": "4.54.8",
4
4
  "description": "Truedat Web Core",
5
5
  "sideEffects": false,
6
6
  "jsnext:main": "src/index.js",
@@ -35,7 +35,7 @@
35
35
  "@testing-library/jest-dom": "^5.16.4",
36
36
  "@testing-library/react": "^12.0.0",
37
37
  "@testing-library/user-event": "^13.2.1",
38
- "@truedat/test": "4.54.6",
38
+ "@truedat/test": "4.54.8",
39
39
  "babel-jest": "^28.1.0",
40
40
  "babel-plugin-dynamic-import-node": "^2.3.3",
41
41
  "babel-plugin-lodash": "^3.3.4",
@@ -112,5 +112,5 @@
112
112
  "react-dom": ">= 16.8.6 < 17",
113
113
  "semantic-ui-react": ">= 0.88.2 < 2.1"
114
114
  },
115
- "gitHead": "ea7f461e39111f0a162656e5d2dbd67215dc198e"
115
+ "gitHead": "f2274cf8a260efe11653e9e9132962cf0162c4c2"
116
116
  }
@@ -33,6 +33,18 @@ export const TEMPLATES_QUERY = gql`
33
33
  }
34
34
  `;
35
35
 
36
+ export const TEMPLATE_QUERY = gql`
37
+ query Template($name: String!, $domainIds: [ID]) {
38
+ template(name: $name, domainIds: $domainIds) {
39
+ id
40
+ name
41
+ label
42
+ scope
43
+ content
44
+ }
45
+ }
46
+ `;
47
+
36
48
  export const FUNCTIONS_QUERY = gql`
37
49
  query Functions {
38
50
  functions {
@@ -4,3 +4,4 @@ export * from "./useAuthorized";
4
4
  export * from "./usePath";
5
5
  export * from "./useOnScreen";
6
6
  export * from "./useOperators";
7
+ export * from "./useTemplate";
@@ -0,0 +1,18 @@
1
+ import PropTypes from "prop-types";
2
+ import { useQuery } from "@apollo/client";
3
+ import { TEMPLATE_QUERY } from "../api/queries";
4
+
5
+ export const useTemplate = ({ name, onLoad, domainIds }) =>
6
+ useQuery(TEMPLATE_QUERY, {
7
+ fetchPolicy: "cache-and-network",
8
+ variables: { name, domainIds },
9
+ onCompleted: onLoad,
10
+ });
11
+
12
+ useTemplate.propTypes = {
13
+ domainIds: PropTypes.array,
14
+ name: PropTypes.string.isRequired,
15
+ onLoad: PropTypes.func,
16
+ };
17
+
18
+ export default useTemplate;