@panneau/core 3.0.140 → 3.0.142

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
@@ -265,7 +265,7 @@ var button = PropTypes.shape({
265
265
  });
266
266
  PropTypes.arrayOf(button);
267
267
  PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', null]);
268
- PropTypes.oneOf(['lg', 'sm', null]);
268
+ PropTypes.oneOf(['lg', 'md', 'sm', null]);
269
269
  PropTypes.oneOf(['button', 'submit']);
270
270
  PropTypes.oneOf(['start', 'end']);
271
271
  PropTypes.oneOf(['lg', 'sm', null]);
package/es/index.js CHANGED
@@ -41,7 +41,7 @@ var button = PropTypes$1.shape({
41
41
  });
42
42
  var buttons = PropTypes$1.arrayOf(button);
43
43
  var buttonTheme = PropTypes$1.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', null]);
44
- var buttonSize = PropTypes$1.oneOf(['lg', 'sm', null]);
44
+ var buttonSize = PropTypes$1.oneOf(['lg', 'md', 'sm', null]);
45
45
  var buttonType = PropTypes$1.oneOf(['button', 'submit']);
46
46
  var dropdownAlign = PropTypes$1.oneOf(['start', 'end']);
47
47
  var controlSize = PropTypes$1.oneOf(['lg', 'sm', null]);
package/lib/contexts.js CHANGED
@@ -286,7 +286,7 @@ var button = PropTypes.shape({
286
286
  });
287
287
  PropTypes.arrayOf(button);
288
288
  PropTypes.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', null]);
289
- PropTypes.oneOf(['lg', 'sm', null]);
289
+ PropTypes.oneOf(['lg', 'md', 'sm', null]);
290
290
  PropTypes.oneOf(['button', 'submit']);
291
291
  PropTypes.oneOf(['start', 'end']);
292
292
  PropTypes.oneOf(['lg', 'sm', null]);
@@ -1229,7 +1229,7 @@ if (typeof history !== "undefined" && typeof window[patchKey] === "undefined") {
1229
1229
  });
1230
1230
  }
1231
1231
 
1232
- var _excluded3 = ["to", "href", "onClick", "asChild", "children", "replace", "state"];
1232
+ var _excluded3 = ["to", "href", "onClick", "asChild", "children", "className", "replace", "state"];
1233
1233
 
1234
1234
  /*
1235
1235
  * Transforms `path` into its relative `base` version
@@ -1272,7 +1272,11 @@ var defaultRouter = {
1272
1272
  base: "",
1273
1273
  // this option is used to override the current location during SSR
1274
1274
  ssrPath: undefined,
1275
- ssrSearch: undefined
1275
+ ssrSearch: undefined,
1276
+ // customizes how `href` props are transformed for <Link />
1277
+ hrefs: function hrefs(x) {
1278
+ return x;
1279
+ }
1276
1280
  };
1277
1281
  var RouterCtx = React.createContext(defaultRouter);
1278
1282
 
@@ -1314,13 +1318,15 @@ React.forwardRef(function (props, ref) {
1314
1318
  var router = useRouter();
1315
1319
  var _useLocationFromRoute3 = useLocationFromRouter(router),
1316
1320
  _useLocationFromRoute4 = _slicedToArray(_useLocationFromRoute3, 2),
1321
+ path = _useLocationFromRoute4[0],
1317
1322
  navigate = _useLocationFromRoute4[1];
1318
1323
  var to = props.to,
1319
1324
  _props$href = props.href,
1320
1325
  _href = _props$href === void 0 ? to : _props$href,
1321
1326
  _onClick = props.onClick,
1322
1327
  asChild = props.asChild,
1323
- children = props.children;
1328
+ children = props.children,
1329
+ cls = props.className;
1324
1330
  props.replace;
1325
1331
  props.state;
1326
1332
  var restProps = _objectWithoutProperties(props, _excluded3);
@@ -1328,7 +1334,7 @@ React.forwardRef(function (props, ref) {
1328
1334
  // ignores the navigation when clicked using right mouse button or
1329
1335
  // by holding a special modifier key: ctrl, command, win, alt, shift
1330
1336
  if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || event.button !== 0) return;
1331
- _onClick && _onClick(event); // TODO: is it safe to use _onClick?.(event)
1337
+ _onClick === null || _onClick === void 0 || _onClick(event);
1332
1338
  if (!event.defaultPrevented) {
1333
1339
  event.preventDefault();
1334
1340
  navigate(_href, props);
@@ -1336,13 +1342,16 @@ React.forwardRef(function (props, ref) {
1336
1342
  });
1337
1343
 
1338
1344
  // handle nested routers and absolute paths
1339
- var href = _href[0] === "~" ? _href.slice(1) : router.base + _href;
1345
+ var href = router.hrefs(_href[0] === "~" ? _href.slice(1) : router.base + _href, router // pass router as a second argument for convinience
1346
+ );
1340
1347
  return asChild && React.isValidElement(children) ? React.cloneElement(children, {
1341
- href: href,
1342
- onClick: onClick
1348
+ onClick: onClick,
1349
+ href: href
1343
1350
  }) : React.createElement("a", _objectSpread(_objectSpread({}, restProps), {}, {
1344
- href: href,
1345
1351
  onClick: onClick,
1352
+ href: href,
1353
+ // `className` can be a function to apply the class if this link is active
1354
+ className: cls !== null && cls !== void 0 && cls.call ? cls(path === href) : cls,
1346
1355
  children: children,
1347
1356
  ref: ref
1348
1357
  }));
package/lib/index.js CHANGED
@@ -43,7 +43,7 @@ var button = PropTypes$1.shape({
43
43
  });
44
44
  var buttons = PropTypes$1.arrayOf(button);
45
45
  var buttonTheme = PropTypes$1.oneOf(['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark', null]);
46
- var buttonSize = PropTypes$1.oneOf(['lg', 'sm', null]);
46
+ var buttonSize = PropTypes$1.oneOf(['lg', 'md', 'sm', null]);
47
47
  var buttonType = PropTypes$1.oneOf(['button', 'submit']);
48
48
  var dropdownAlign = PropTypes$1.oneOf(['start', 'end']);
49
49
  var controlSize = PropTypes$1.oneOf(['lg', 'sm', null]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/core",
3
- "version": "3.0.140",
3
+ "version": "3.0.142",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -93,7 +93,7 @@
93
93
  "classnames": "^2.5.1",
94
94
  "css-mediaquery": "^0.1.2",
95
95
  "dayjs": "^1.10.4",
96
- "debug": "^4.3.1",
96
+ "debug": "^4.3.4",
97
97
  "flat": "^5.0.2",
98
98
  "hoist-non-react-statics": "^3.3.2",
99
99
  "lodash": "^4.17.21",
@@ -106,10 +106,10 @@
106
106
  "tinycolor2": "^1.4.2",
107
107
  "webfontloader": "^1.6.28",
108
108
  "wolfy87-eventemitter": "^5.2.9",
109
- "wouter": "^3.0.0"
109
+ "wouter": "^3.1.0"
110
110
  },
111
111
  "publishConfig": {
112
112
  "access": "public"
113
113
  },
114
- "gitHead": "f148a421cabe2dfa529d2df1eaae42d0f4bb32c5"
114
+ "gitHead": "293308a0e1b7175dcc56128f6dbc1416845d0b15"
115
115
  }