@clayui/tooltip 3.35.1 → 4.0.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 CHANGED
@@ -3,6 +3,26 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.0.0](https://github.com/liferay/clay/compare/v3.36.0...v4.0.0) (2021-10-06)
7
+
8
+ **Note:** Version bump only for package @clayui/tooltip
9
+
10
+ # [3.36.0](https://github.com/liferay/clay/compare/v3.35.3...v3.36.0) (2021-09-23)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **@clayui/tooltip:** forces tooltip to be repositioned when the x-axis is modified ([b62313c](https://github.com/liferay/clay/commit/b62313c))
15
+ - **@clayui/tooltip:** stop the always showing warnings ([3858bfe](https://github.com/liferay/clay/commit/3858bfe))
16
+ - **@clyaui/tooltip:** fixes error when not forcing Tooltip repositioning when X axis is modified ([187f1ef](https://github.com/liferay/clay/commit/187f1ef))
17
+
18
+ ## [3.35.3](https://github.com/liferay/clay/compare/v3.35.2...v3.35.3) (2021-09-09)
19
+
20
+ **Note:** Version bump only for package @clayui/tooltip
21
+
22
+ ## [3.35.2](https://github.com/liferay/clay/compare/v3.35.1...v3.35.2) (2021-08-30)
23
+
24
+ **Note:** Version bump only for package @clayui/tooltip
25
+
6
26
  ## [3.35.1](https://github.com/liferay/clay/compare/v3.35.0...v3.35.1) (2021-08-30)
7
27
 
8
28
  **Note:** Version bump only for package @clayui/tooltip
@@ -33,16 +33,16 @@ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(
33
33
 
34
34
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
35
 
36
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
37
+
38
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
39
+
36
40
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
37
41
 
38
42
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
39
43
 
40
44
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
41
45
 
42
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
43
-
44
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
45
-
46
46
  var ALIGNMENTS = ['top', 'top-right', 'right', 'bottom-right', 'bottom', 'bottom-left', 'left', 'top-left'];
47
47
  var ALIGNMENTS_MAP = {
48
48
  bottom: ['tc', 'bc'],
@@ -64,6 +64,12 @@ var ALIGNMENTS_INVERSE_MAP = {
64
64
  tlbl: 'bottom-left',
65
65
  trbr: 'bottom-right'
66
66
  };
67
+
68
+ var ALIGNMENTS_FORCE_MAP = _objectSpread(_objectSpread({}, ALIGNMENTS_INVERSE_MAP), {}, {
69
+ bctc: 'top-left',
70
+ tcbc: 'bottom-left'
71
+ });
72
+
67
73
  var initialState = {
68
74
  align: 'top',
69
75
  message: '',
@@ -274,7 +280,7 @@ var TooltipProvider = function TooltipProvider(_ref2) {
274
280
  _react.default.useEffect(function () {
275
281
  if (titleNodeRef.current && tooltipRef.current) {
276
282
  var points = ALIGNMENTS_MAP[align || 'top'];
277
- var newAlignmentString = (0, _shared.doAlign)({
283
+ var alignment = (0, _shared.doAlign)({
278
284
  overflow: {
279
285
  adjustX: autoAlign,
280
286
  adjustY: autoAlign
@@ -282,20 +288,26 @@ var TooltipProvider = function TooltipProvider(_ref2) {
282
288
  points: points,
283
289
  sourceElement: tooltipRef.current,
284
290
  targetElement: titleNodeRef.current
285
- }).points.join('');
291
+ });
292
+ var alignmentString = alignment.points.join('');
286
293
  var pointsString = points.join('');
287
294
 
288
- if (pointsString !== newAlignmentString) {
295
+ if (alignment.overflow.adjustX) {
296
+ dispatch({
297
+ align: ALIGNMENTS_FORCE_MAP[alignmentString],
298
+ type: 'align'
299
+ });
300
+ } else if (pointsString !== alignmentString) {
289
301
  dispatch({
290
- align: ALIGNMENTS_INVERSE_MAP[newAlignmentString],
302
+ align: ALIGNMENTS_INVERSE_MAP[alignmentString],
291
303
  type: 'align'
292
304
  });
293
305
  }
294
306
  }
295
307
  }, [align, show]);
296
308
 
297
- "production" !== "production" ? (0, _warning.default)(!children && !scope, '<TooltipProvider />: You must use at least one of the following props: `children` or `scope`.') : void 0;
298
- "production" !== "production" ? (0, _warning.default)(children && scope, '<TooltipProvider />: If you want to use `scope`, use <TooltipProvider /> as a singleton and do not pass `children`.') : void 0;
309
+ "production" !== "production" ? (0, _warning.default)(typeof children === 'undefined' && typeof scope !== 'undefined' || typeof scope === 'undefined' && typeof children !== 'undefined', '<TooltipProvider />: You must use at least one of the following props: `children` or `scope`.') : void 0;
310
+ "production" !== "production" ? (0, _warning.default)(typeof children !== 'undefined' || typeof scope !== 'undefined', '<TooltipProvider />: If you want to use `scope`, use <TooltipProvider /> as a singleton and do not pass `children`.') : void 0;
299
311
  "production" !== "production" ? (0, _warning.default)((children === null || children === void 0 ? void 0 : children.type) !== _react.default.Fragment, '<TooltipProvider />: React Fragment is not allowed as a child to TooltipProvider. Child must be a single HTML element that accepts `onMouseOver` and `onMouseOut`.') : void 0;
300
312
  var titleContent = contentRenderer({
301
313
  targetNode: targetRef.current,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clayui/tooltip",
3
- "version": "3.35.1",
3
+ "version": "4.0.0",
4
4
  "description": "ClayTooltip component",
5
5
  "license": "BSD-3-Clause",
6
6
  "repository": "https://github.com/liferay/clay",
@@ -26,7 +26,7 @@
26
26
  "react"
27
27
  ],
28
28
  "dependencies": {
29
- "@clayui/shared": "^3.35.1",
29
+ "@clayui/shared": "^4.0.0",
30
30
  "classnames": "^2.2.6",
31
31
  "warning": "^4.0.3"
32
32
  },
@@ -38,5 +38,5 @@
38
38
  "browserslist": [
39
39
  "extends browserslist-config-clay"
40
40
  ],
41
- "gitHead": "986bb1acce9efef75fdc1bcd8af7b9c0b9daff7a"
41
+ "gitHead": "0d285c26936b985e7be90e61b6c21e04734a0ad9"
42
42
  }
@@ -48,6 +48,12 @@ const ALIGNMENTS_INVERSE_MAP = {
48
48
  trbr: 'bottom-right',
49
49
  } as const;
50
50
 
51
+ const ALIGNMENTS_FORCE_MAP = {
52
+ ...ALIGNMENTS_INVERSE_MAP,
53
+ bctc: 'top-left',
54
+ tcbc: 'bottom-left',
55
+ } as const;
56
+
51
57
  interface IState {
52
58
  align?: typeof ALIGNMENTS[number];
53
59
  message?: string;
@@ -335,7 +341,7 @@ const TooltipProvider: React.FunctionComponent<
335
341
  ) {
336
342
  const points = ALIGNMENTS_MAP[align || 'top'] as [string, string];
337
343
 
338
- const newAlignmentString = doAlign({
344
+ const alignment = doAlign({
339
345
  overflow: {
340
346
  adjustX: autoAlign,
341
347
  adjustY: autoAlign,
@@ -344,13 +350,22 @@ const TooltipProvider: React.FunctionComponent<
344
350
  sourceElement: (tooltipRef as React.RefObject<HTMLDivElement>)
345
351
  .current!,
346
352
  targetElement: titleNodeRef.current,
347
- }).points.join('') as keyof typeof ALIGNMENTS_INVERSE_MAP;
353
+ });
354
+
355
+ const alignmentString = alignment.points.join(
356
+ ''
357
+ ) as keyof typeof ALIGNMENTS_INVERSE_MAP;
348
358
 
349
359
  const pointsString = points.join('');
350
360
 
351
- if (pointsString !== newAlignmentString) {
361
+ if (alignment.overflow.adjustX) {
362
+ dispatch({
363
+ align: ALIGNMENTS_FORCE_MAP[alignmentString],
364
+ type: 'align',
365
+ });
366
+ } else if (pointsString !== alignmentString) {
352
367
  dispatch({
353
- align: ALIGNMENTS_INVERSE_MAP[newAlignmentString],
368
+ align: ALIGNMENTS_INVERSE_MAP[alignmentString],
354
369
  type: 'align',
355
370
  });
356
371
  }
@@ -358,12 +373,13 @@ const TooltipProvider: React.FunctionComponent<
358
373
  }, [align, show]);
359
374
 
360
375
  warning(
361
- !children && !scope,
376
+ (typeof children === 'undefined' && typeof scope !== 'undefined') ||
377
+ (typeof scope === 'undefined' && typeof children !== 'undefined'),
362
378
  '<TooltipProvider />: You must use at least one of the following props: `children` or `scope`.'
363
379
  );
364
380
 
365
381
  warning(
366
- children && scope,
382
+ typeof children !== 'undefined' || typeof scope !== 'undefined',
367
383
  '<TooltipProvider />: If you want to use `scope`, use <TooltipProvider /> as a singleton and do not pass `children`.'
368
384
  );
369
385