@ilo-org/react 0.9.1 → 0.10.1
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 +25 -0
- package/lib/cjs/components/Button/Button.js +2 -2
- package/lib/cjs/components/Button/index.js +12 -3
- package/lib/cjs/components/Card/Card.js +1 -1
- package/lib/cjs/components/Checkbox/Checkbox.js +1 -1
- package/lib/cjs/components/Checkbox/index.js +1 -1
- package/lib/cjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/cjs/components/DatePicker/index.js +1 -1
- package/lib/cjs/components/Dropdown/Dropdown.js +2 -2
- package/lib/cjs/components/Dropdown/index.js +1 -1
- package/lib/cjs/components/Fieldset/Fieldset.js +1 -1
- package/lib/cjs/components/Fieldset/index.js +1 -1
- package/lib/cjs/components/FileUpload/FileUpload.js +1 -1
- package/lib/cjs/components/FileUpload/index.js +1 -1
- package/lib/cjs/components/FormControl/FormControl.js +1 -1
- package/lib/cjs/components/FormControl/index.js +1 -1
- package/lib/cjs/components/Hero/Hero.js +1 -1
- package/lib/cjs/components/Hero/index.js +1 -1
- package/lib/cjs/components/Input/Input.js +1 -1
- package/lib/cjs/components/Input/index.js +1 -1
- package/lib/cjs/components/Navigation/Navigation.js +1 -1
- package/lib/cjs/components/Navigation/index.js +1 -1
- package/lib/cjs/components/NumberPicker/NumberPicker.js +1 -1
- package/lib/cjs/components/NumberPicker/index.js +1 -1
- package/lib/cjs/components/Profile/Profile.js +4 -2
- package/lib/cjs/components/Radio/Radio.js +1 -1
- package/lib/cjs/components/Radio/index.js +1 -1
- package/lib/cjs/components/SearchField/SearchField.js +1 -1
- package/lib/cjs/components/SearchField/index.js +1 -1
- package/lib/cjs/components/TextInput/TextInput.js +1 -1
- package/lib/cjs/components/TextInput/index.js +1 -1
- package/lib/cjs/components/Textarea/Textarea.js +1 -1
- package/lib/cjs/components/Textarea/index.js +1 -1
- package/lib/cjs/components/Toggle/Toggle.js +1 -1
- package/lib/cjs/components/Toggle/index.js +1 -1
- package/lib/cjs/components/Tooltip/Tooltip.js +42 -72
- package/lib/cjs/components/Tooltip/index.js +1 -1
- package/lib/cjs/components/index.js +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/esm/components/Button/Button.js +2 -2
- package/lib/esm/components/Button/index.js +12 -3
- package/lib/esm/components/Card/Card.js +1 -1
- package/lib/esm/components/Checkbox/Checkbox.js +1 -1
- package/lib/esm/components/Checkbox/index.js +1 -1
- package/lib/esm/components/DatePicker/DatePicker.js +1 -1
- package/lib/esm/components/DatePicker/index.js +1 -1
- package/lib/esm/components/Dropdown/Dropdown.js +2 -2
- package/lib/esm/components/Dropdown/index.js +1 -1
- package/lib/esm/components/Fieldset/Fieldset.js +1 -1
- package/lib/esm/components/Fieldset/index.js +1 -1
- package/lib/esm/components/FileUpload/FileUpload.js +1 -1
- package/lib/esm/components/FileUpload/index.js +1 -1
- package/lib/esm/components/FormControl/FormControl.js +1 -1
- package/lib/esm/components/FormControl/index.js +1 -1
- package/lib/esm/components/Hero/Hero.js +1 -1
- package/lib/esm/components/Hero/index.js +1 -1
- package/lib/esm/components/Input/Input.js +1 -1
- package/lib/esm/components/Input/index.js +1 -1
- package/lib/esm/components/Navigation/Navigation.js +1 -1
- package/lib/esm/components/Navigation/index.js +1 -1
- package/lib/esm/components/NumberPicker/NumberPicker.js +1 -1
- package/lib/esm/components/NumberPicker/index.js +1 -1
- package/lib/esm/components/Profile/Profile.js +4 -2
- package/lib/esm/components/Radio/Radio.js +1 -1
- package/lib/esm/components/Radio/index.js +1 -1
- package/lib/esm/components/SearchField/SearchField.js +1 -1
- package/lib/esm/components/SearchField/index.js +1 -1
- package/lib/esm/components/TextInput/TextInput.js +1 -1
- package/lib/esm/components/TextInput/index.js +1 -1
- package/lib/esm/components/Textarea/Textarea.js +1 -1
- package/lib/esm/components/Textarea/index.js +1 -1
- package/lib/esm/components/Toggle/Toggle.js +1 -1
- package/lib/esm/components/Toggle/index.js +1 -1
- package/lib/esm/components/Tooltip/Tooltip.js +42 -72
- package/lib/esm/components/Tooltip/index.js +1 -1
- package/lib/esm/components/index.js +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/types/react/src/components/Button/Button.props.d.ts +4 -0
- package/lib/types/react/src/components/Profile/Profile.props.d.ts +9 -0
- package/lib/types/react/src/components/Tooltip/Tooltip.props.d.ts +3 -11
- package/lib/types/react/src/types/index.d.ts +1 -0
- package/package.json +16 -16
- package/src/components/Button/Button.args.ts +12 -3
- package/src/components/Button/Button.props.ts +5 -0
- package/src/components/Button/Button.tsx +2 -0
- package/src/components/Card/Card.tsx +1 -1
- package/src/components/Dropdown/Dropdown.tsx +3 -1
- package/src/components/Profile/Profile.props.ts +12 -0
- package/src/components/Profile/Profile.tsx +19 -11
- package/src/components/Tooltip/Tooltip.args.ts +1 -1
- package/src/components/Tooltip/Tooltip.props.ts +3 -13
- package/src/components/Tooltip/Tooltip.tsx +68 -91
- package/src/types/index.ts +1 -0
|
@@ -13,10 +13,19 @@ const primary = {
|
|
|
13
13
|
type: "primary",
|
|
14
14
|
label: "Primary",
|
|
15
15
|
size: "medium",
|
|
16
|
+
name: "primary",
|
|
16
17
|
};
|
|
17
|
-
const secondary = {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const secondary = {
|
|
19
|
+
type: "secondary",
|
|
20
|
+
label: "Secondary",
|
|
21
|
+
name: "secondary",
|
|
22
|
+
};
|
|
23
|
+
const tertiary = {
|
|
24
|
+
type: "tertiary",
|
|
25
|
+
label: "Tertiary",
|
|
26
|
+
name: "tertiary",
|
|
27
|
+
};
|
|
28
|
+
const alert = { type: "alert", label: "Alert", name: "alert" };
|
|
20
29
|
const icon = { type: "primary", label: "Icon", icon: "close" };
|
|
21
30
|
const disabled = {
|
|
22
31
|
type: "primary",
|
|
@@ -26,7 +26,7 @@ const Card = ({ isvideo, eyebrow, title, color, theme, variant, size, cornercut,
|
|
|
26
26
|
return (jsxs("div", Object.assign({ className: cardClasses }, { children: [link &&
|
|
27
27
|
variant != "data" &&
|
|
28
28
|
variant != "factlist" &&
|
|
29
|
-
variant != "stat" && (jsx("a", Object.assign({ className: `${baseClass}--link`, href: link, title: title }, { children: jsx("span", Object.assign({ className: `${baseClass}--link--text` }, { children: title })) }))), jsxs("div", Object.assign({ className: `${baseClass}--wrap` }, { children: [image && (jsx("div", Object.assign({ className: `${baseClass}--image--wrapper` }, { children: jsx("picture", { children: jsx("img", { className: `${baseClass}--image`, src: image, alt: title }) }) }))), jsxs("div", Object.assign({ className: `${baseClass}--content` }, { children: [eyebrow && jsx("p", Object.assign({ className: `${baseClass}--eyebrow` }, { children: eyebrow })), title && jsx("
|
|
29
|
+
variant != "stat" && (jsx("a", Object.assign({ className: `${baseClass}--link`, href: link, title: title }, { children: jsx("span", Object.assign({ className: `${baseClass}--link--text` }, { children: title })) }))), jsxs("div", Object.assign({ className: `${baseClass}--wrap` }, { children: [image && (jsx("div", Object.assign({ className: `${baseClass}--image--wrapper` }, { children: jsx("picture", { children: jsx("img", { className: `${baseClass}--image`, src: image, alt: title }) }) }))), jsxs("div", Object.assign({ className: `${baseClass}--content` }, { children: [eyebrow && jsx("p", Object.assign({ className: `${baseClass}--eyebrow` }, { children: eyebrow })), title && jsx("h3", Object.assign({ className: `${baseClass}--title` }, { children: title })), (variant == "multilink" || (variant == "data" && image)) && (jsx("div", Object.assign({ className: `${baseClass}--image--wrapper` }, { children: jsx("picture", { children: jsx("img", { className: `${baseClass}--image`, src: image, alt: title }) }) }))), intro && jsx("p", Object.assign({ className: `${baseClass}--intro` }, { children: intro })), date &&
|
|
30
30
|
variant != "stat" &&
|
|
31
31
|
variant != "data" &&
|
|
32
32
|
variant != "graphicpromo" &&
|
|
@@ -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 '
|
|
11
|
+
import '@popperjs/core';
|
|
12
12
|
import 'nanoid';
|
|
13
13
|
|
|
14
14
|
const Checkbox = forwardRef((props, 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 '
|
|
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 FormControl, { useFormControl } from '../FormControl/FormControl.js';
|
|
|
7
7
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
8
|
import 'nanoid';
|
|
9
9
|
import '../Tooltip/Tooltip.js';
|
|
10
|
-
import '
|
|
10
|
+
import '@popperjs/core';
|
|
11
11
|
|
|
12
12
|
const DatePicker = forwardRef((props, ref) => {
|
|
13
13
|
const { onChange, onBlur, disabled = false, error, id, name, placeholder, required, max, min, step, } = props;
|
|
@@ -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 '
|
|
10
|
+
import '@popperjs/core';
|
|
11
11
|
|
|
12
12
|
const Dropdown = forwardRef((props, ref) => {
|
|
13
13
|
const { autocomplete, onChange, onBlur, disabled = false, error, id, name, options, required, value, form, multiple, selectSize, } = props;
|
|
@@ -26,7 +26,7 @@ const Dropdown = forwardRef((props, ref) => {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
return (jsx("div", Object.assign({ className: `${baseClass}--wrapper` }, { children: jsx("select", Object.assign({ ref: ref, id: id ? id : name, autoComplete: autocomplete, name: name, required: required, onChange: handleChange, onBlur: onBlur, disabled: disabled, className: dropdownClasses, value: currentvalue, form: form, multiple: multiple, size: selectSize, "aria-describedby": ariaDescribedBy }, { children: options &&
|
|
29
|
-
options.map((option, i) => (jsx("option", { disabled: option.disabled, label: option.label, value: option.value }, `${baseClass}--option--${i}`))) })) })));
|
|
29
|
+
options.map((option, i) => (jsx("option", Object.assign({ disabled: option.disabled, label: option.label, value: option.value }, { children: option.label }), `${baseClass}--option--${i}`))) })) })));
|
|
30
30
|
});
|
|
31
31
|
const LabelledDropdown = forwardRef((props, ref) => {
|
|
32
32
|
const { style, inputStyle, className } = props, rest = __rest(props, ["style", "inputStyle", "className"]);
|
|
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
import useGlobalSettings from '../../hooks/useGlobalSettings.js';
|
|
6
6
|
import Tooltip from '../Tooltip/Tooltip.js';
|
|
7
7
|
import '../../GlobalCtx-7fb23cfa.js';
|
|
8
|
-
import '
|
|
8
|
+
import '@popperjs/core';
|
|
9
9
|
|
|
10
10
|
// Create a new context for the error state
|
|
11
11
|
const FieldsetErrorContext = createContext({
|
|
@@ -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 '
|
|
10
|
+
import '@popperjs/core';
|
|
11
11
|
|
|
12
12
|
function formatBytes(bytes, decimals = 2) {
|
|
13
13
|
if (!+bytes)
|
|
@@ -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 '
|
|
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
|
|
@@ -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 '
|
|
13
|
+
import '@popperjs/core';
|
|
14
14
|
|
|
15
15
|
const HeroImage = ({ url, alt }) => {
|
|
16
16
|
const { prefix } = useGlobalSettings();
|
|
@@ -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 '
|
|
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 '
|
|
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();
|
|
@@ -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 '
|
|
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, }) => {
|
|
@@ -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 '
|
|
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();
|
|
@@ -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}` }),
|
|
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 '
|
|
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 '
|
|
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 '
|
|
10
|
+
import '@popperjs/core';
|
|
11
11
|
import '../FormElement/FormElement.js';
|
|
12
12
|
|
|
13
13
|
const SearchField = ({ action, callback, className, input, }) => {
|
|
@@ -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 '
|
|
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();
|
|
@@ -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 '
|
|
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 '
|
|
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 '
|
|
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();
|
|
@@ -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
|
|
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(
|
|
27
|
-
|
|
28
|
-
[`${baseClass}--
|
|
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
|
|
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
|
|
93
|
-
|
|
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:
|
|
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 };
|
|
@@ -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';
|
|
@@ -13,6 +13,10 @@ export interface ButtonProps {
|
|
|
13
13
|
* Specify an optional className to be added to your Button.
|
|
14
14
|
*/
|
|
15
15
|
className?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Specify the name for the Button.
|
|
18
|
+
*/
|
|
19
|
+
name?: string;
|
|
16
20
|
/**
|
|
17
21
|
* Specify whether or not the button is disabled.
|
|
18
22
|
*/
|
|
@@ -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
|
-
*
|
|
28
|
+
* Describe the background theme of the tooltip
|
|
37
29
|
*/
|
|
38
|
-
|
|
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";
|