@ilo-org/react 0.9.0 → 0.10.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.
Files changed (85) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/lib/cjs/components/Checkbox/Checkbox.js +1 -1
  3. package/lib/cjs/components/Checkbox/index.js +1 -1
  4. package/lib/cjs/components/DatePicker/DatePicker.js +1 -1
  5. package/lib/cjs/components/DatePicker/index.js +1 -1
  6. package/lib/cjs/components/Dropdown/Dropdown.js +1 -1
  7. package/lib/cjs/components/Dropdown/index.js +1 -1
  8. package/lib/cjs/components/Fieldset/Fieldset.js +1 -1
  9. package/lib/cjs/components/Fieldset/index.js +1 -1
  10. package/lib/cjs/components/FileUpload/FileUpload.js +1 -1
  11. package/lib/cjs/components/FileUpload/index.js +1 -1
  12. package/lib/cjs/components/FormControl/FormControl.js +1 -1
  13. package/lib/cjs/components/FormControl/index.js +1 -1
  14. package/lib/cjs/components/Hero/Hero.js +6 -4
  15. package/lib/cjs/components/Hero/index.js +1 -1
  16. package/lib/cjs/components/Input/Input.js +1 -1
  17. package/lib/cjs/components/Input/index.js +1 -1
  18. package/lib/cjs/components/Navigation/Navigation.js +1 -1
  19. package/lib/cjs/components/Navigation/index.js +1 -1
  20. package/lib/cjs/components/NumberPicker/NumberPicker.js +1 -1
  21. package/lib/cjs/components/NumberPicker/index.js +1 -1
  22. package/lib/cjs/components/Profile/Profile.js +4 -2
  23. package/lib/cjs/components/Radio/Radio.js +1 -1
  24. package/lib/cjs/components/Radio/index.js +1 -1
  25. package/lib/cjs/components/SearchField/SearchField.js +1 -1
  26. package/lib/cjs/components/SearchField/index.js +1 -1
  27. package/lib/cjs/components/TextInput/TextInput.js +1 -1
  28. package/lib/cjs/components/TextInput/index.js +1 -1
  29. package/lib/cjs/components/Textarea/Textarea.js +1 -1
  30. package/lib/cjs/components/Textarea/index.js +1 -1
  31. package/lib/cjs/components/Toggle/Toggle.js +1 -1
  32. package/lib/cjs/components/Toggle/index.js +1 -1
  33. package/lib/cjs/components/Tooltip/Tooltip.js +42 -72
  34. package/lib/cjs/components/Tooltip/index.js +1 -1
  35. package/lib/cjs/components/index.js +1 -0
  36. package/lib/cjs/index.js +1 -0
  37. package/lib/esm/components/Checkbox/Checkbox.js +1 -1
  38. package/lib/esm/components/Checkbox/index.js +1 -1
  39. package/lib/esm/components/DatePicker/DatePicker.js +1 -1
  40. package/lib/esm/components/DatePicker/index.js +1 -1
  41. package/lib/esm/components/Dropdown/Dropdown.js +1 -1
  42. package/lib/esm/components/Dropdown/index.js +1 -1
  43. package/lib/esm/components/Fieldset/Fieldset.js +1 -1
  44. package/lib/esm/components/Fieldset/index.js +1 -1
  45. package/lib/esm/components/FileUpload/FileUpload.js +1 -1
  46. package/lib/esm/components/FileUpload/index.js +1 -1
  47. package/lib/esm/components/FormControl/FormControl.js +1 -1
  48. package/lib/esm/components/FormControl/index.js +1 -1
  49. package/lib/esm/components/Hero/Hero.js +7 -5
  50. package/lib/esm/components/Hero/index.js +1 -1
  51. package/lib/esm/components/Input/Input.js +1 -1
  52. package/lib/esm/components/Input/index.js +1 -1
  53. package/lib/esm/components/Navigation/Navigation.js +1 -1
  54. package/lib/esm/components/Navigation/index.js +1 -1
  55. package/lib/esm/components/NumberPicker/NumberPicker.js +1 -1
  56. package/lib/esm/components/NumberPicker/index.js +1 -1
  57. package/lib/esm/components/Profile/Profile.js +4 -2
  58. package/lib/esm/components/Radio/Radio.js +1 -1
  59. package/lib/esm/components/Radio/index.js +1 -1
  60. package/lib/esm/components/SearchField/SearchField.js +1 -1
  61. package/lib/esm/components/SearchField/index.js +1 -1
  62. package/lib/esm/components/TextInput/TextInput.js +1 -1
  63. package/lib/esm/components/TextInput/index.js +1 -1
  64. package/lib/esm/components/Textarea/Textarea.js +1 -1
  65. package/lib/esm/components/Textarea/index.js +1 -1
  66. package/lib/esm/components/Toggle/Toggle.js +1 -1
  67. package/lib/esm/components/Toggle/index.js +1 -1
  68. package/lib/esm/components/Tooltip/Tooltip.js +42 -72
  69. package/lib/esm/components/Tooltip/index.js +1 -1
  70. package/lib/esm/components/index.js +1 -0
  71. package/lib/esm/index.js +1 -0
  72. package/lib/types/react/src/components/Hero/Hero.props.d.ts +4 -0
  73. package/lib/types/react/src/components/Profile/Profile.props.d.ts +9 -0
  74. package/lib/types/react/src/components/Tooltip/Tooltip.props.d.ts +3 -11
  75. package/lib/types/react/src/types/index.d.ts +1 -0
  76. package/package.json +16 -16
  77. package/src/components/Hero/Hero.args.ts +28 -0
  78. package/src/components/Hero/Hero.props.ts +5 -0
  79. package/src/components/Hero/Hero.tsx +15 -6
  80. package/src/components/Profile/Profile.props.ts +12 -0
  81. package/src/components/Profile/Profile.tsx +19 -11
  82. package/src/components/Tooltip/Tooltip.args.ts +1 -1
  83. package/src/components/Tooltip/Tooltip.props.ts +3 -13
  84. package/src/components/Tooltip/Tooltip.tsx +68 -91
  85. package/src/types/index.ts +1 -0
@@ -6,4 +6,4 @@ import 'classnames';
6
6
  import '../../hooks/useGlobalSettings.js';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../Tooltip/Tooltip.js';
9
- import 'react-dom';
9
+ import '@popperjs/core';
@@ -7,7 +7,7 @@ import FormControl, { useFormControl } from '../FormControl/FormControl.js';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import 'nanoid';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
 
12
12
  function formatBytes(bytes, decimals = 2) {
13
13
  if (!+bytes)
@@ -8,4 +8,4 @@ import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../FormControl/FormControl.js';
9
9
  import 'nanoid';
10
10
  import '../Tooltip/Tooltip.js';
11
- import 'react-dom';
11
+ import '@popperjs/core';
@@ -6,7 +6,7 @@ import useGlobalSettings from '../../hooks/useGlobalSettings.js';
6
6
  import Tooltip from '../Tooltip/Tooltip.js';
7
7
  import 'tslib';
8
8
  import '../../GlobalCtx-7fb23cfa.js';
9
- import 'react-dom';
9
+ import '@popperjs/core';
10
10
 
11
11
  // Calculates unique IDs for the internal accessibility elements
12
12
  // TODO: When we upgrade to React 8, this should use useId instead
@@ -7,4 +7,4 @@ import '../../hooks/useGlobalSettings.js';
7
7
  import 'tslib';
8
8
  import '../../GlobalCtx-7fb23cfa.js';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
@@ -1,4 +1,4 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import classNames from 'classnames';
3
3
  import useGlobalSettings from '../../hooks/useGlobalSettings.js';
4
4
  import HeroCard from './HeroCard.js';
@@ -10,7 +10,7 @@ import '../../GlobalCtx-7fb23cfa.js';
10
10
  import '../SocialMedia/SocialMedia.js';
11
11
  import '../SocialMedia/index.js';
12
12
  import '../ContextMenu/ContextMenu.js';
13
- import 'react-dom';
13
+ import '@popperjs/core';
14
14
 
15
15
  const HeroImage = ({ url, alt }) => {
16
16
  const { prefix } = useGlobalSettings();
@@ -20,14 +20,16 @@ const HeroImage = ({ url, alt }) => {
20
20
  const defaultSrc = sortedUrls[sortedUrls.length - 1].src;
21
21
  return (jsx("figure", Object.assign({ className: "hero--image" }, { children: jsxs("picture", { children: [sortedUrls.map((img) => (jsx("source", { srcSet: img.src, media: `(min-width: ${img.breakpoint}px)` }, img.breakpoint))), jsx("img", { className: imageClass, src: defaultSrc, alt: alt })] }) })));
22
22
  };
23
- const Hero = ({ justify = "start", align = "baseline", cardSize = "small", posterSize = "large", image, breadcrumb, heroCard, caption, }) => {
23
+ const Hero = ({ justify = "start", align = "baseline", cardSize = "small", posterSize = "large", theme = "dark", image, breadcrumb, heroCard, caption, gap, }) => {
24
24
  const baseClass = "hero";
25
25
  const justifyClass = `${baseClass}__card-justify__${justify}`;
26
26
  const alignClass = `${baseClass}__card-align__${align}`;
27
27
  const cardSizeClass = `${baseClass}__card-size__${cardSize}`;
28
28
  const posterSizeClass = `${baseClass}__poster-size__${posterSize}`;
29
- const heroClasses = classNames(baseClass, justifyClass, alignClass, cardSizeClass, posterSizeClass);
30
- return (jsxs("div", Object.assign({ className: heroClasses }, { children: [jsx("div", Object.assign({ className: "hero--background" }, { children: image && jsx(HeroImage, Object.assign({}, image)) })), breadcrumb && (jsx("div", Object.assign({ className: "hero--breadcrumbs" }, { children: jsx("div", Object.assign({ className: "hero--breadcrumbs--wrapper" }, { children: jsx(Breadcrumb, Object.assign({}, breadcrumb)) })) }))), jsx("div", Object.assign({ className: "hero--card" }, { children: jsx(HeroCard, Object.assign({}, heroCard)) })), caption && (jsx("div", Object.assign({ className: "hero--caption" }, { children: jsx("div", Object.assign({ className: "hero--caption--wrapper" }, { children: jsx(Tooltip, Object.assign({}, caption)) })) })))] })));
29
+ const themeClass = `${baseClass}__card-theme__${theme}`;
30
+ const gapClass = `${baseClass}__gap__${gap}`;
31
+ const heroClasses = classNames(baseClass, justifyClass, alignClass, cardSizeClass, posterSizeClass, themeClass, { [gapClass]: !!gap });
32
+ return (jsxs("div", Object.assign({ className: heroClasses }, { children: [jsx("div", Object.assign({ className: "hero--background" }, { children: image && jsx(HeroImage, Object.assign({}, image)) })), breadcrumb && (jsx(Fragment, { children: jsx("div", Object.assign({ className: "hero--breadcrumbs" }, { children: jsx("div", Object.assign({ className: "hero--breadcrumbs--wrapper" }, { children: jsx(Breadcrumb, Object.assign({}, breadcrumb)) })) })) })), jsx("div", { className: "hero--card-offset" }), jsx("div", Object.assign({ className: "hero--card" }, { children: jsx(HeroCard, Object.assign({}, heroCard)) })), caption && (jsx("div", Object.assign({ className: "hero--caption" }, { children: jsx("div", Object.assign({ className: "hero--caption--wrapper" }, { children: jsx(Tooltip, Object.assign({}, caption)) })) })))] })));
31
33
  };
32
34
 
33
35
  export { Hero as default };
@@ -9,6 +9,6 @@ import '../../GlobalCtx-7fb23cfa.js';
9
9
  import '../Breadcrumb/Breadcrumb.js';
10
10
  import '../ContextMenu/ContextMenu.js';
11
11
  import '../Tooltip/Tooltip.js';
12
- import 'react-dom';
12
+ import '@popperjs/core';
13
13
  import '../SocialMedia/SocialMedia.js';
14
14
  import '../SocialMedia/index.js';
@@ -7,7 +7,7 @@ import 'tslib';
7
7
  import 'react';
8
8
  import '../../GlobalCtx-7fb23cfa.js';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
 
12
12
  const Input = ({ callback, disabled = false, error, helper, id, label, name, placeholder, required, tooltip, type = "text", }) => {
13
13
  const { prefix } = useGlobalSettings();
@@ -7,5 +7,5 @@ import 'react';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../Fieldset/Fieldset.js';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
  import '../FormElement/FormElement.js';
@@ -9,7 +9,7 @@ import '../../GlobalCtx-7fb23cfa.js';
9
9
  import '../Input/Input.js';
10
10
  import '../Fieldset/Fieldset.js';
11
11
  import '../Tooltip/Tooltip.js';
12
- import 'react-dom';
12
+ import '@popperjs/core';
13
13
  import '../FormElement/FormElement.js';
14
14
 
15
15
  const Navigation = ({ logo, mobilelogo, siteurl, tagline, primarynav, subnav, menulabel, menucloselabel, searchlabel, searchfield, languagelabel, languagecontextmenu, }) => {
@@ -10,5 +10,5 @@ import '../SearchField/SearchField.js';
10
10
  import '../Input/Input.js';
11
11
  import '../Fieldset/Fieldset.js';
12
12
  import '../Tooltip/Tooltip.js';
13
- import 'react-dom';
13
+ import '@popperjs/core';
14
14
  import '../FormElement/FormElement.js';
@@ -7,7 +7,7 @@ import FormControl, { useFormControl } from '../FormControl/FormControl.js';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import 'nanoid';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
 
12
12
  const NumberPicker = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, name, placeholder, required, max, min, step, }, ref) => {
13
13
  const { prefix } = useGlobalSettings();
@@ -8,4 +8,4 @@ import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../FormControl/FormControl.js';
9
9
  import 'nanoid';
10
10
  import '../Tooltip/Tooltip.js';
11
- import 'react-dom';
11
+ import '@popperjs/core';
@@ -5,13 +5,15 @@ import 'tslib';
5
5
  import 'react';
6
6
  import '../../GlobalCtx-7fb23cfa.js';
7
7
 
8
- const Profile = ({ avatar, className, description, link, name, role, }) => {
8
+ const Profile = ({ avatar, className, description, link, name, role, theme = "light", size = "large", }) => {
9
9
  const { prefix } = useGlobalSettings();
10
10
  const baseClass = `${prefix}--profile`;
11
11
  const profileClasses = classNames(className, {
12
12
  [baseClass]: true,
13
+ [`${baseClass}__theme__${theme}`]: theme,
14
+ [`${baseClass}__size__${size}`]: size,
13
15
  });
14
- return (jsxs("figure", Object.assign({ className: profileClasses }, { children: [jsx("img", { className: `${baseClass}--avatar`, src: avatar, alt: `Avatar for ${name}` }), jsxs("figcaption", Object.assign({ className: `${baseClass}--contents` }, { children: [jsx("span", Object.assign({ className: `${baseClass}--name id` }, { children: name })), role && jsx("span", Object.assign({ className: `${baseClass}--role id` }, { children: role })), description && (jsx("p", Object.assign({ className: `${baseClass}--description info` }, { children: description }))), link && (jsx("a", Object.assign({ className: `${baseClass}--link info`, href: link.url }, { children: jsx("span", { children: link.label }) })))] }))] })));
16
+ return (jsxs("figure", Object.assign({ className: profileClasses }, { children: [jsx("img", { className: `${baseClass}--avatar`, src: avatar, alt: `Avatar for ${name}` }), jsx("figcaption", { children: jsxs("div", Object.assign({ className: `${baseClass}--figcaption--content` }, { children: [jsx("div", Object.assign({ className: `${baseClass}--name` }, { children: name })), role && jsx("div", Object.assign({ className: `${baseClass}--role` }, { children: role }))] })) }), description && (jsx("p", Object.assign({ className: `${baseClass}--description` }, { children: description }))), link && (jsx("div", Object.assign({ className: `${baseClass}--link` }, { children: jsx("a", Object.assign({ href: link.url, target: "__blank", rel: "noopener noreferrer" }, { children: jsx("span", Object.assign({ className: `${baseClass}--link--label` }, { children: link.label })) })) })))] })));
15
17
  };
16
18
 
17
19
  export { Profile as default };
@@ -8,7 +8,7 @@ import FormControl, { useFormControl } from '../FormControl/FormControl.js';
8
8
  import { usePrevious } from '../../hooks/usePrevious.js';
9
9
  import '../../GlobalCtx-7fb23cfa.js';
10
10
  import '../Tooltip/Tooltip.js';
11
- import 'react-dom';
11
+ import '@popperjs/core';
12
12
  import 'nanoid';
13
13
 
14
14
  const Radio = require$$0.forwardRef(({ onChange, onBlur, disabled = false, error, id, name, required, checked, defaultChecked = false, value, }, ref) => {
@@ -7,7 +7,7 @@ import '../../hooks/useGlobalSettings.js';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../Fieldset/Fieldset.js';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
  import '../FormControl/FormControl.js';
12
12
  import 'nanoid';
13
13
  import '../../hooks/usePrevious.js';
@@ -7,7 +7,7 @@ import 'react';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../Fieldset/Fieldset.js';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
  import '../FormElement/FormElement.js';
12
12
 
13
13
  const SearchField = ({ action, callback, className, input, }) => {
@@ -8,5 +8,5 @@ import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../Input/Input.js';
9
9
  import '../Fieldset/Fieldset.js';
10
10
  import '../Tooltip/Tooltip.js';
11
- import 'react-dom';
11
+ import '@popperjs/core';
12
12
  import '../FormElement/FormElement.js';
@@ -7,7 +7,7 @@ import FormControl, { useFormControl } from '../FormControl/FormControl.js';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import 'nanoid';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
 
12
12
  const TextInput = require$$0.forwardRef(({ onChange, onBlur, error, id, name, placeholder, required, pattern, disabled = false, type = "text", }, ref) => {
13
13
  const { prefix } = useGlobalSettings();
@@ -8,7 +8,7 @@ import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../FormControl/FormControl.js';
9
9
  import 'nanoid';
10
10
  import '../Tooltip/Tooltip.js';
11
- import 'react-dom';
11
+ import '@popperjs/core';
12
12
 
13
13
  const basic = {
14
14
  disabled: false,
@@ -7,7 +7,7 @@ import FormControl, { useFormControl } from '../FormControl/FormControl.js';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import 'nanoid';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
 
12
12
  const Textarea = require$$0.forwardRef((_a, ref) => {
13
13
  var { error, className, name, id } = _a, props = __rest(_a, ["error", "className", "name", "id"]);
@@ -8,7 +8,7 @@ import '../../GlobalCtx-7fb23cfa.js';
8
8
  import '../FormControl/FormControl.js';
9
9
  import 'nanoid';
10
10
  import '../Tooltip/Tooltip.js';
11
- import 'react-dom';
11
+ import '@popperjs/core';
12
12
 
13
13
  const placeholder = "It was a cold day in April and the clocks were striking thirteen....";
14
14
  const basic = {
@@ -7,7 +7,7 @@ import FormControl, { useFormControl } from '../FormControl/FormControl.js';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
  import 'nanoid';
9
9
  import '../Tooltip/Tooltip.js';
10
- import 'react-dom';
10
+ import '@popperjs/core';
11
11
 
12
12
  const Toggle = forwardRef(({ size = "medium", error = false, disabled = false, defaultChecked = false, required = false, id, name, onChange, onBlur, onClick, checked, className, }, ref) => {
13
13
  const { prefix } = useGlobalSettings();
@@ -8,7 +8,7 @@ import 'classnames';
8
8
  import '../FormControl/FormControl.js';
9
9
  import 'nanoid';
10
10
  import '../Tooltip/Tooltip.js';
11
- import 'react-dom';
11
+ import '@popperjs/core';
12
12
 
13
13
  const Default = {
14
14
  defaultChecked: false,
@@ -2,100 +2,70 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { useState, useRef } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import useGlobalSettings from '../../hooks/useGlobalSettings.js';
5
- import ReactDOM from 'react-dom';
5
+ import { createPopper } from '@popperjs/core';
6
6
  import 'tslib';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
8
 
9
- const Tooltip = ({ className, children, icon, label, theme, id, }) => {
9
+ const Tooltip = ({ className, children, icon, label, iconTheme, theme, id, }) => {
10
10
  const { prefix } = useGlobalSettings();
11
11
  const baseClass = `${prefix}--tooltip`;
12
12
  const [isVisible, setIsVisible] = useState(false);
13
- const [position, setPosition] = useState({
14
- x: 0,
15
- y: 0,
16
- });
17
- const [arrowPlacement, setArrowPlacement] = useState("center");
18
- const [arrowAlignment, setArrowAlignment] = useState("left");
19
13
  const tooltipRef = useRef(null);
14
+ const popperInstanceRef = useRef(null);
15
+ const isLongTooltip = () => {
16
+ var _a, _b;
17
+ const tooltipText = (((_a = tooltipRef.current) === null || _a === void 0 ? void 0 : _a.textContent) ||
18
+ ((_b = tooltipRef.current) === null || _b === void 0 ? void 0 : _b.innerText) ||
19
+ "").trim();
20
+ return tooltipText.length > 50;
21
+ };
20
22
  const tooltipClasses = classNames(className, {
21
23
  [baseClass]: true,
22
24
  [`${baseClass}--${theme}`]: theme,
23
- [`${baseClass}--alignment-${arrowAlignment}`]: arrowAlignment,
24
25
  [`${baseClass}--visible`]: isVisible,
26
+ [`${baseClass}--long`]: isLongTooltip(),
25
27
  });
26
- const tooltipArrowClasses = classNames(className, {
27
- [`${baseClass}--arrow`]: true,
28
- [`${baseClass}--arrow--placement-${arrowPlacement}`]: arrowPlacement,
28
+ const tooltipArrowClasses = classNames(`${baseClass}--arrow`, `${baseClass}--arrow--placement-negative`);
29
+ const iconClasses = classNames(className, `${baseClass}--wrapper`, {
30
+ [`${baseClass}--wrapper__icon ${baseClass}--wrapper__icon__theme__${theme}`]: icon,
31
+ [`${baseClass}--wrapper__icon__theme__${theme}`]: iconTheme,
29
32
  });
30
33
  const handleOnMouseOver = (e) => {
31
- // get hovered element reference
32
34
  const target = e.currentTarget;
33
- if (target) {
34
- const rect = target.getBoundingClientRect();
35
+ if (target && tooltipRef.current) {
36
+ const popperInstance = createPopper(target, tooltipRef.current, {
37
+ placement: "top",
38
+ modifiers: [
39
+ {
40
+ name: "offset",
41
+ options: {
42
+ offset: [0, 12], // Adjust offset as needed
43
+ },
44
+ },
45
+ {
46
+ name: "flip",
47
+ enabled: true,
48
+ },
49
+ {
50
+ name: "preventOverflow",
51
+ enabled: true,
52
+ },
53
+ ],
54
+ });
55
+ popperInstanceRef.current = popperInstance;
35
56
  setIsVisible(true);
36
- postMouseOver(rect);
37
- }
38
- };
39
- const postMouseOver = (hoverRect) => {
40
- // position the tooltip after showing it
41
- let placement = "center";
42
- let alignment = "left";
43
- const ttNode = ReactDOM.findDOMNode(tooltipRef.current);
44
- if (ttNode != null) {
45
- let x = 0, y = 0;
46
- const docWidth = document.documentElement.clientWidth, docHeight = document.documentElement.clientHeight;
47
- const rx = hoverRect.x + hoverRect.width, // most right x
48
- lx = hoverRect.x, // most left x
49
- ty = hoverRect.y, // most top y
50
- by = hoverRect.y + hoverRect.height; // most bottom y
51
- // tool tip rectange
52
- const ttRect = ttNode.getBoundingClientRect();
53
- const bRight = rx + ttRect.width <= window.scrollX + docWidth &&
54
- ty + ttRect.height <= window.scrollY + docHeight;
55
- const bLeft = lx - ttRect.width >= 0 &&
56
- ty + ttRect.height <= window.scrollY + docHeight;
57
- const bAbove = ty - ttRect.height >= 0;
58
- const bBellow = by + ttRect.height <= window.scrollY + docHeight;
59
- // the tooltip doesn't fit to the left
60
- if (bRight) {
61
- x = hoverRect.width + 16;
62
- y = icon ? -8 : 0;
63
- placement = "negative";
64
- alignment = "right";
65
- }
66
- else if (bBellow) {
67
- x = icon ? -8 : 0;
68
- y = hoverRect.height + 16;
69
- placement = "center";
70
- alignment = "bottom";
71
- }
72
- else if (bLeft) {
73
- x = -ttRect.width - 16;
74
- y = icon ? -8 : 0;
75
- placement = "negative";
76
- alignment = "left";
77
- }
78
- else if (bAbove) {
79
- x = icon ? -8 : 0;
80
- y = -ttRect.height - 16;
81
- placement = "center";
82
- alignment = "top";
83
- }
84
- setPosition({ x: x, y: y });
85
- setArrowPlacement(placement);
86
- setArrowAlignment(alignment);
87
57
  }
88
58
  };
89
59
  const handleOnMouseOut = () => {
60
+ if (popperInstanceRef.current) {
61
+ popperInstanceRef.current.destroy();
62
+ }
90
63
  setIsVisible(false);
91
64
  };
92
- const style = {
93
- // left: ((position.x + window.scrollX) + 'px'),
94
- // top: ((position.y + window.scrollY) + 'px')
95
- left: position.x + "px",
96
- top: position.y + "px",
65
+ const handleOnFocus = (e) => {
66
+ handleOnMouseOver(e);
97
67
  };
98
- return (jsxs("div", Object.assign({ className: `${baseClass}--wrapper ${icon && "has-icon"}`, onMouseOver: handleOnMouseOver, onFocus: handleOnMouseOver, onMouseOut: handleOnMouseOut, onBlur: handleOnMouseOut, id: id }, { children: [!icon && jsx(Fragment, { children: children }), jsxs("span", Object.assign({ className: tooltipClasses, style: style, ref: tooltipRef }, { children: [jsx("span", { className: tooltipArrowClasses, role: "presentation" }), label] }))] })));
68
+ return (jsxs("div", Object.assign({ className: iconClasses, onMouseOver: handleOnMouseOver, onFocus: handleOnFocus, onMouseOut: handleOnMouseOut, onBlur: handleOnMouseOut, id: id }, { children: [!icon && jsx(Fragment, { children: children }), jsxs("span", Object.assign({ className: tooltipClasses, ref: tooltipRef, "data-id": id, id: "tooltip", role: "tooltip", "aria-hidden": !isVisible }, { children: [jsx("span", { "data-popper-arrow": true, className: tooltipArrowClasses, "data-placement": "negative", role: "presentation" }), label] }))] })));
99
69
  };
100
70
 
101
71
  export { Tooltip as default };
@@ -5,4 +5,4 @@ import 'classnames';
5
5
  import '../../hooks/useGlobalSettings.js';
6
6
  import 'tslib';
7
7
  import '../../GlobalCtx-7fb23cfa.js';
8
- import 'react-dom';
8
+ import '@popperjs/core';
@@ -67,6 +67,7 @@ import '../utils/triggerBrowserReflow.js';
67
67
  import './FormControl/FormControl.js';
68
68
  import 'nanoid';
69
69
  import '../hooks/usePrevious.js';
70
+ import '@popperjs/core';
70
71
  import './Hero/HeroCard.js';
71
72
  import './SocialMedia/SocialMedia.js';
72
73
  import './Input/Input.js';
package/lib/esm/index.js CHANGED
@@ -66,6 +66,7 @@ import './utils/transitionEndListener.js';
66
66
  import './utils/triggerBrowserReflow.js';
67
67
  import './components/FormControl/FormControl.js';
68
68
  import 'nanoid';
69
+ import '@popperjs/core';
69
70
  import './hooks/usePrevious.js';
70
71
  import '@ilo-org/icons-react';
71
72
  import './components/Hero/HeroCard.js';
@@ -36,6 +36,10 @@ export interface HeroProps {
36
36
  * Props for the card for the hero
37
37
  */
38
38
  heroCard: HeroCardProps;
39
+ /**
40
+ * Color of the gap space between bottom of the hero image and bottom of the card
41
+ */
42
+ gap?: "white" | "transparent" | "dark" | "light";
39
43
  /**
40
44
  * The size of the poster image
41
45
  */
@@ -1,3 +1,4 @@
1
+ import { ThemeTypes, SizeTypes } from "../../types";
1
2
  interface LinkProps {
2
3
  /**
3
4
  * Specify the label for the the Profile's link
@@ -9,6 +10,14 @@ interface LinkProps {
9
10
  url?: Required<string>;
10
11
  }
11
12
  export interface ProfileProps {
13
+ /**
14
+ * Specify the theme for your profile component.
15
+ */
16
+ theme?: ThemeTypes;
17
+ /**
18
+ * Specify the size for your profile component.
19
+ */
20
+ size?: SizeTypes;
12
21
  /**
13
22
  * Specify an optional avatar to be added to your Profile component. Image *must* be a perfect square. CMS backend should provide a fallback if the avatar is not populated.
14
23
  */
@@ -1,4 +1,4 @@
1
- import { TooltipThemes } from "../../types";
1
+ import { TooltipThemes, TooltipIconThemes } from "../../types";
2
2
  export interface TooltipProps {
3
3
  /**
4
4
  * Specify an optional className to be added to your Tooltip.
@@ -20,20 +20,12 @@ export interface TooltipProps {
20
20
  * Set whether the tooltip is visible or not
21
21
  */
22
22
  isVisible?: boolean;
23
- /**
24
- * Callback fired onMouseOver
25
- */
26
- onMouseOver?: (e: React.MouseEventHandler<HTMLDivElement>) => any;
27
- /**
28
- * Callback fired onMouseOut
29
- */
30
- onMouseOut?: (e: React.MouseEventHandler<HTMLDivElement>) => any;
31
23
  /**
32
24
  * Describe the theme of the tooltip
33
25
  */
34
26
  theme?: Required<TooltipThemes>;
35
27
  /**
36
- * Set a width for the tooltip
28
+ * Describe the background theme of the tooltip
37
29
  */
38
- width?: string;
30
+ iconTheme?: Required<TooltipIconThemes>;
39
31
  }
@@ -13,6 +13,7 @@ export type LabelTypes = "default" | "actionable" | "light";
13
13
  export type LinkTypes = "light" | "dark" | "footer" | "button";
14
14
  export type LinkListThemes = "light" | "dark";
15
15
  export type TooltipThemes = "light" | "dark";
16
+ export type TooltipIconThemes = "light" | "dark";
16
17
  export type TooltipAlignment = "top" | "right" | "bottom" | "left";
17
18
  export type TooltipPlacement = "negative" | "center" | "positive";
18
19
  export type ListAlignment = "default" | "horizontal";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ilo-org/react",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "React components for the ILO's Design System",
5
5
  "keywords": [
6
6
  "ui_patterns",
@@ -68,6 +68,7 @@
68
68
  ]
69
69
  },
70
70
  "dependencies": {
71
+ "@popperjs/core": "^2.11.8",
71
72
  "classnames": "^2.3.1",
72
73
  "dom-helpers": "^5.2.1",
73
74
  "nanoid": "^3.3.6",
@@ -76,7 +77,7 @@
76
77
  "@ilo-org/brand-assets": "0.2.0",
77
78
  "@ilo-org/fonts": "0.1.2",
78
79
  "@ilo-org/icons-react": "0.0.21",
79
- "@ilo-org/styles": "0.12.0",
80
+ "@ilo-org/styles": "0.13.1",
80
81
  "@ilo-org/themes": "0.7.0",
81
82
  "@ilo-org/utils": "0.0.11"
82
83
  },
@@ -84,21 +85,20 @@
84
85
  "@rollup/plugin-commonjs": "^23.0.2",
85
86
  "@rollup/plugin-json": "^5.0.1",
86
87
  "@rollup/plugin-node-resolve": "^15.0.1",
87
- "@storybook/addon-a11y": "7.5.0-alpha.1",
88
- "@storybook/addon-actions": "7.5.0-alpha.1",
89
- "@storybook/addon-docs": "7.5.0-alpha.1",
90
- "@storybook/addon-essentials": "7.5.0-alpha.1",
91
- "@storybook/addon-links": "7.5.0-alpha.1",
88
+ "@storybook/addon-a11y": "7.6.6",
89
+ "@storybook/addon-actions": "7.6.6",
90
+ "@storybook/addon-docs": "7.6.6",
91
+ "@storybook/addon-essentials": "7.6.6",
92
+ "@storybook/addon-links": "7.6.6",
92
93
  "@storybook/addon-styling": "^1.3.7",
93
- "@storybook/blocks": "7.5.0-alpha.1",
94
- "@storybook/builder-vite": "7.5.0-alpha.1",
95
- "@storybook/client-api": "7.5.0-alpha.1",
96
- "@storybook/manager-api": "7.5.0-alpha.1",
97
- "@storybook/node-logger": "7.5.0-alpha.1",
94
+ "@storybook/blocks": "7.6.6",
95
+ "@storybook/client-api": "7.6.6",
96
+ "@storybook/manager-api": "7.6.6",
97
+ "@storybook/node-logger": "7.6.6",
98
98
  "@storybook/preset-scss": "^1.0.3",
99
- "@storybook/react": "7.5.0-alpha.1",
100
- "@storybook/react-vite": "7.5.0-alpha.1",
101
- "@storybook/theming": "7.5.0-alpha.1",
99
+ "@storybook/react": "7.6.6",
100
+ "@storybook/react-vite": "7.6.6",
101
+ "@storybook/theming": "7.6.6",
102
102
  "@testing-library/jest-dom": "5.16.5",
103
103
  "@testing-library/react": "^12.1.2",
104
104
  "@testing-library/user-event": "^13.5.0",
@@ -124,7 +124,7 @@
124
124
  "rollup-plugin-peer-deps-external": "^2.2.4",
125
125
  "rollup-plugin-typescript2": "^0.34.1",
126
126
  "screenfull": "^5.2.0",
127
- "storybook": "7.5.0-alpha.1",
127
+ "storybook": "7.6.6",
128
128
  "storybook-addon-performance": "^0.17.1",
129
129
  "storybook-addon-rtl-direction": "^0.0.19",
130
130
  "ts-dedent": "^2.2.0",
@@ -2,6 +2,7 @@ import { HeroProps } from "./Hero.props";
2
2
  import { defaultArgs } from "../SocialMedia";
3
3
  import { HeroCardProps } from "./HeroCard.props";
4
4
  import { ImageProps } from "../Image/Image.props";
5
+ import { BreadcrumbProps } from "../Breadcrumb/Breadcrumb.props";
5
6
 
6
7
  const lightArticleCard: HeroCardProps = {
7
8
  title: "Does Artificial Intelligence threaten decent work?",
@@ -55,8 +56,35 @@ const heroImage: ImageProps = {
55
56
  ],
56
57
  };
57
58
 
59
+ const heroBreadCrumb: BreadcrumbProps = {
60
+ home: {
61
+ indented: false,
62
+ label: "Home",
63
+ url: "/",
64
+ },
65
+ links: [
66
+ {
67
+ label: "Link One",
68
+ url: "https://www.ilo.org/",
69
+ },
70
+ {
71
+ label: "Link Two",
72
+ url: "https://www.ilo.org/",
73
+ },
74
+ {
75
+ label: "Link Three",
76
+ url: "https://www.ilo.org/",
77
+ },
78
+ {
79
+ label: "Link Four",
80
+ url: "https://www.ilo.org/",
81
+ },
82
+ ],
83
+ };
84
+
58
85
  const standard = {
59
86
  image: heroImage,
87
+ breadcrumb: heroBreadCrumb,
60
88
  heroCard: darkPortalCard,
61
89
  };
62
90
 
@@ -45,6 +45,11 @@ export interface HeroProps {
45
45
  */
46
46
  heroCard: HeroCardProps;
47
47
 
48
+ /**
49
+ * Color of the gap space between bottom of the hero image and bottom of the card
50
+ */
51
+ gap?: "white" | "transparent" | "dark" | "light";
52
+
48
53
  /**
49
54
  * The size of the poster image
50
55
  */