@panneau/core 2.0.15 → 2.0.35

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/es/contexts.js CHANGED
@@ -280,7 +280,8 @@ var page = PropTypes.shape({
280
280
  });
281
281
  var pages = PropTypes.objectOf(page);
282
282
  var field = PropTypes.shape({
283
- name: PropTypes.string.isRequired,
283
+ name: PropTypes.string,
284
+ // Not required on localized fields
284
285
  type: PropTypes.string,
285
286
  component: PropTypes.string,
286
287
  label: PropTypes.node
@@ -349,6 +350,7 @@ var font = PropTypes.shape({
349
350
  // url: PropTypes.string,
350
351
  });
351
352
  PropTypes.arrayOf(font);
353
+ PropTypes.shape({});
352
354
 
353
355
  /* eslint-disable react/jsx-props-no-spreading */
354
356
  var DefinitionContext = /*#__PURE__*/React.createContext(null);
@@ -753,10 +755,13 @@ var defaultProps$7 = {
753
755
  var LocalesProvider = function LocalesProvider(_ref) {
754
756
  var locales = _ref.locales,
755
757
  children = _ref.children;
756
- return /*#__PURE__*/React.createElement(LocalesContext.Provider, {
757
- value: {
758
+ var value = useMemo(function () {
759
+ return {
758
760
  locales: locales
759
- }
761
+ };
762
+ }, [locales]);
763
+ return /*#__PURE__*/React.createElement(LocalesContext.Provider, {
764
+ value: value
760
765
  }, children);
761
766
  };
762
767
  LocalesProvider.propTypes = propTypes$7;
@@ -1051,8 +1056,9 @@ var useUrlGenerator = function useUrlGenerator() {
1051
1056
  routes = _useContext2.routes,
1052
1057
  basePath = _useContext2.basePath;
1053
1058
  var urlGenerator = useCallback(function (key, data) {
1059
+ // console.log('urlGenerator', basePath, routes, routes[key], data);
1054
1060
  var url = generatePath(routes[key], data);
1055
- // console.log('urlGenerator', basePath, routes[key], url, data);
1061
+ // console.log('url', url);
1056
1062
  return basePath !== null ? "".concat(basePath.replace(/\/$/, ''), "/").concat(url.replace(/^\//, '')) : url;
1057
1063
  }, [generatePath, routes, basePath]);
1058
1064
  return urlGenerator;
@@ -1065,14 +1071,14 @@ var useRoutePush = function useRoutePush() {
1065
1071
  args[_key - 2] = arguments[_key];
1066
1072
  }
1067
1073
  if (isString(route)) {
1068
- var _history;
1069
- (_history = history).push.apply(_history, [url(route, data)].concat(args));
1074
+ navigate.apply(void 0, [url(route, data)].concat(args));
1070
1075
  } else {
1071
1076
  var _ref = route || {},
1072
1077
  _ref$pathname = _ref.pathname,
1073
1078
  pathname = _ref$pathname === void 0 ? null : _ref$pathname,
1074
1079
  _ref$search = _ref.search,
1075
1080
  search = _ref$search === void 0 ? null : _ref$search;
1081
+ // TODO: test this
1076
1082
  navigate.apply(void 0, [{
1077
1083
  pathname: url(pathname, data),
1078
1084
  search: search
@@ -1091,8 +1097,10 @@ var useRouteBack = function useRouteBack() {
1091
1097
  };
1092
1098
  var propTypes$2 = {
1093
1099
  children: PropTypes.node.isRequired,
1094
- routes: PropTypes.objectOf(PropTypes.string),
1095
- // .isRequired,
1100
+ routes: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
1101
+ path: PropTypes.string,
1102
+ component: PropTypes.string
1103
+ })])),
1096
1104
  basePath: PropTypes.string
1097
1105
  };
1098
1106
  var defaultProps$2 = {
@@ -1103,11 +1111,15 @@ var RoutesProvider = function RoutesProvider(_ref2) {
1103
1111
  var routes = _ref2.routes,
1104
1112
  basePath = _ref2.basePath,
1105
1113
  children = _ref2.children;
1106
- return /*#__PURE__*/React.createElement(RoutesContext.Provider, {
1107
- value: {
1114
+ var value = useMemo(function () {
1115
+ return {
1108
1116
  routes: routes,
1109
1117
  basePath: basePath
1110
- }
1118
+ };
1119
+ }, [routes, basePath]);
1120
+ // console.log(routes, basePath);
1121
+ return /*#__PURE__*/React.createElement(RoutesContext.Provider, {
1122
+ value: value
1111
1123
  }, children);
1112
1124
  };
1113
1125
  RoutesProvider.propTypes = propTypes$2;
package/es/hooks.js CHANGED
@@ -879,6 +879,7 @@ var useResourceUrlGenerator = function useResourceUrlGenerator() {
879
879
  // ...finalParams,
880
880
  // resource: id,
881
881
  // }));
882
+ // console.log(finalRouteName, id, finalParams);
882
883
  return id !== null ? route("resources.".concat(finalRouteName), _objectSpread(_objectSpread({}, finalParams), {}, {
883
884
  resource: id
884
885
  })) : null;
package/es/index.js CHANGED
@@ -95,7 +95,8 @@ var page = PropTypes$1.shape({
95
95
  });
96
96
  var pages = PropTypes$1.objectOf(page);
97
97
  var field = PropTypes$1.shape({
98
- name: PropTypes$1.string.isRequired,
98
+ name: PropTypes$1.string,
99
+ // Not required on localized fields
99
100
  type: PropTypes$1.string,
100
101
  component: PropTypes$1.string,
101
102
  label: PropTypes$1.node
@@ -164,6 +165,7 @@ var font = PropTypes$1.shape({
164
165
  // url: PropTypes.string,
165
166
  });
166
167
  var fonts = PropTypes$1.arrayOf(font);
168
+ var trackingVariables = PropTypes$1.shape({});
167
169
 
168
170
  var PropTypes = /*#__PURE__*/Object.freeze({
169
171
  __proto__: null,
@@ -212,7 +214,8 @@ var PropTypes = /*#__PURE__*/Object.freeze({
212
214
  breadcrumb: breadcrumb,
213
215
  breadcrumbs: breadcrumbs,
214
216
  font: font,
215
- fonts: fonts
217
+ fonts: fonts,
218
+ trackingVariables: trackingVariables
216
219
  });
217
220
 
218
221
  var flattenComponents = function flattenComponents(components) {
package/lib/contexts.js CHANGED
@@ -315,7 +315,8 @@ var page = PropTypes__default["default"].shape({
315
315
  });
316
316
  var pages = PropTypes__default["default"].objectOf(page);
317
317
  var field = PropTypes__default["default"].shape({
318
- name: PropTypes__default["default"].string.isRequired,
318
+ name: PropTypes__default["default"].string,
319
+ // Not required on localized fields
319
320
  type: PropTypes__default["default"].string,
320
321
  component: PropTypes__default["default"].string,
321
322
  label: PropTypes__default["default"].node
@@ -384,6 +385,7 @@ var font = PropTypes__default["default"].shape({
384
385
  // url: PropTypes.string,
385
386
  });
386
387
  PropTypes__default["default"].arrayOf(font);
388
+ PropTypes__default["default"].shape({});
387
389
 
388
390
  /* eslint-disable react/jsx-props-no-spreading */
389
391
  var DefinitionContext = /*#__PURE__*/React__default["default"].createContext(null);
@@ -788,10 +790,13 @@ var defaultProps$7 = {
788
790
  var LocalesProvider = function LocalesProvider(_ref) {
789
791
  var locales = _ref.locales,
790
792
  children = _ref.children;
791
- return /*#__PURE__*/React__default["default"].createElement(LocalesContext.Provider, {
792
- value: {
793
+ var value = React.useMemo(function () {
794
+ return {
793
795
  locales: locales
794
- }
796
+ };
797
+ }, [locales]);
798
+ return /*#__PURE__*/React__default["default"].createElement(LocalesContext.Provider, {
799
+ value: value
795
800
  }, children);
796
801
  };
797
802
  LocalesProvider.propTypes = propTypes$7;
@@ -1086,8 +1091,9 @@ var useUrlGenerator = function useUrlGenerator() {
1086
1091
  routes = _useContext2.routes,
1087
1092
  basePath = _useContext2.basePath;
1088
1093
  var urlGenerator = React.useCallback(function (key, data) {
1094
+ // console.log('urlGenerator', basePath, routes, routes[key], data);
1089
1095
  var url = reactRouter.generatePath(routes[key], data);
1090
- // console.log('urlGenerator', basePath, routes[key], url, data);
1096
+ // console.log('url', url);
1091
1097
  return basePath !== null ? "".concat(basePath.replace(/\/$/, ''), "/").concat(url.replace(/^\//, '')) : url;
1092
1098
  }, [reactRouter.generatePath, routes, basePath]);
1093
1099
  return urlGenerator;
@@ -1100,14 +1106,14 @@ var useRoutePush = function useRoutePush() {
1100
1106
  args[_key - 2] = arguments[_key];
1101
1107
  }
1102
1108
  if (isString__default["default"](route)) {
1103
- var _history;
1104
- (_history = history).push.apply(_history, [url(route, data)].concat(args));
1109
+ navigate.apply(void 0, [url(route, data)].concat(args));
1105
1110
  } else {
1106
1111
  var _ref = route || {},
1107
1112
  _ref$pathname = _ref.pathname,
1108
1113
  pathname = _ref$pathname === void 0 ? null : _ref$pathname,
1109
1114
  _ref$search = _ref.search,
1110
1115
  search = _ref$search === void 0 ? null : _ref$search;
1116
+ // TODO: test this
1111
1117
  navigate.apply(void 0, [{
1112
1118
  pathname: url(pathname, data),
1113
1119
  search: search
@@ -1126,8 +1132,10 @@ var useRouteBack = function useRouteBack() {
1126
1132
  };
1127
1133
  var propTypes$2 = {
1128
1134
  children: PropTypes__default["default"].node.isRequired,
1129
- routes: PropTypes__default["default"].objectOf(PropTypes__default["default"].string),
1130
- // .isRequired,
1135
+ routes: PropTypes__default["default"].objectOf(PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].shape({
1136
+ path: PropTypes__default["default"].string,
1137
+ component: PropTypes__default["default"].string
1138
+ })])),
1131
1139
  basePath: PropTypes__default["default"].string
1132
1140
  };
1133
1141
  var defaultProps$2 = {
@@ -1138,11 +1146,15 @@ var RoutesProvider = function RoutesProvider(_ref2) {
1138
1146
  var routes = _ref2.routes,
1139
1147
  basePath = _ref2.basePath,
1140
1148
  children = _ref2.children;
1141
- return /*#__PURE__*/React__default["default"].createElement(RoutesContext.Provider, {
1142
- value: {
1149
+ var value = React.useMemo(function () {
1150
+ return {
1143
1151
  routes: routes,
1144
1152
  basePath: basePath
1145
- }
1153
+ };
1154
+ }, [routes, basePath]);
1155
+ // console.log(routes, basePath);
1156
+ return /*#__PURE__*/React__default["default"].createElement(RoutesContext.Provider, {
1157
+ value: value
1146
1158
  }, children);
1147
1159
  };
1148
1160
  RoutesProvider.propTypes = propTypes$2;
package/lib/hooks.js CHANGED
@@ -914,6 +914,7 @@ var useResourceUrlGenerator = function useResourceUrlGenerator() {
914
914
  // ...finalParams,
915
915
  // resource: id,
916
916
  // }));
917
+ // console.log(finalRouteName, id, finalParams);
917
918
  return id !== null ? route("resources.".concat(finalRouteName), _objectSpread__default["default"](_objectSpread__default["default"]({}, finalParams), {}, {
918
919
  resource: id
919
920
  })) : null;
package/lib/index.js CHANGED
@@ -117,7 +117,8 @@ var page = PropTypes__default["default"].shape({
117
117
  });
118
118
  var pages = PropTypes__default["default"].objectOf(page);
119
119
  var field = PropTypes__default["default"].shape({
120
- name: PropTypes__default["default"].string.isRequired,
120
+ name: PropTypes__default["default"].string,
121
+ // Not required on localized fields
121
122
  type: PropTypes__default["default"].string,
122
123
  component: PropTypes__default["default"].string,
123
124
  label: PropTypes__default["default"].node
@@ -186,6 +187,7 @@ var font = PropTypes__default["default"].shape({
186
187
  // url: PropTypes.string,
187
188
  });
188
189
  var fonts = PropTypes__default["default"].arrayOf(font);
190
+ var trackingVariables = PropTypes__default["default"].shape({});
189
191
 
190
192
  var PropTypes = /*#__PURE__*/Object.freeze({
191
193
  __proto__: null,
@@ -234,7 +236,8 @@ var PropTypes = /*#__PURE__*/Object.freeze({
234
236
  breadcrumb: breadcrumb,
235
237
  breadcrumbs: breadcrumbs,
236
238
  font: font,
237
- fonts: fonts
239
+ fonts: fonts,
240
+ trackingVariables: trackingVariables
238
241
  });
239
242
 
240
243
  var flattenComponents = function flattenComponents(components) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/core",
3
- "version": "2.0.15",
3
+ "version": "2.0.35",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -114,5 +114,5 @@
114
114
  "publishConfig": {
115
115
  "access": "public"
116
116
  },
117
- "gitHead": "7eff06c0b11fc480d1cf437036dbe0e0ef893650"
117
+ "gitHead": "6e5fe320b1e2d939d5cf30dd36ea3a86e903cb00"
118
118
  }