@elliemae/ds-utilities 3.16.0-next.11 → 3.16.0-next.13
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/dist/cjs/algorithms/crossTypeSort.js +4 -0
- package/dist/cjs/algorithms/crossTypeSort.js.map +1 -1
- package/dist/cjs/capitalize.js +4 -0
- package/dist/cjs/capitalize.js.map +1 -1
- package/dist/cjs/compose.js +4 -0
- package/dist/cjs/compose.js.map +1 -1
- package/dist/cjs/deprecated/deprecatedMsg.js +4 -0
- package/dist/cjs/deprecated/deprecatedMsg.js.map +1 -1
- package/dist/cjs/deprecated/index.js +4 -0
- package/dist/cjs/deprecated/index.js.map +1 -1
- package/dist/cjs/deprecated/reactTypesUtility.js +4 -0
- package/dist/cjs/deprecated/reactTypesUtility.js.map +1 -1
- package/dist/cjs/deprecated/scrollingTimer.js +4 -0
- package/dist/cjs/deprecated/scrollingTimer.js.map +1 -1
- package/dist/cjs/deprecated/useParentElement.js +4 -0
- package/dist/cjs/deprecated/useParentElement.js.map +1 -1
- package/dist/cjs/deprecated/useSetRef.js +4 -0
- package/dist/cjs/deprecated/useSetRef.js.map +1 -1
- package/dist/cjs/deprecated/useUncontrolled.js +4 -0
- package/dist/cjs/deprecated/useUncontrolled.js.map +1 -1
- package/dist/cjs/deprecated/useWindowSize.js +4 -0
- package/dist/cjs/deprecated/useWindowSize.js.map +1 -1
- package/dist/cjs/getComponentFromProps.js +5 -0
- package/dist/cjs/getComponentFromProps.js.map +1 -1
- package/dist/cjs/hooks/index.js +6 -0
- package/dist/cjs/hooks/index.js.map +2 -2
- package/dist/cjs/hooks/useCallbackAfterRender.js +4 -0
- package/dist/cjs/hooks/useCallbackAfterRender.js.map +1 -1
- package/dist/cjs/hooks/useCancellableDelayedCallback.js +4 -0
- package/dist/cjs/hooks/useCancellableDelayedCallback.js.map +1 -1
- package/dist/cjs/hooks/useDerivedStateFromProps.js +4 -0
- package/dist/cjs/hooks/useDerivedStateFromProps.js.map +1 -1
- package/dist/cjs/hooks/useDimensions.js +4 -0
- package/dist/cjs/hooks/useDimensions.js.map +1 -1
- package/dist/cjs/hooks/useExecutionTimer.js +4 -0
- package/dist/cjs/hooks/useExecutionTimer.js.map +1 -1
- package/dist/cjs/hooks/useExpandState.js +4 -0
- package/dist/cjs/hooks/useExpandState.js.map +1 -1
- package/dist/cjs/hooks/useFocusTrap.js +4 -0
- package/dist/cjs/hooks/useFocusTrap.js.map +1 -1
- package/dist/cjs/hooks/useHeadlessTooltip.js +140 -0
- package/dist/cjs/hooks/useHeadlessTooltip.js.map +7 -0
- package/dist/cjs/hooks/useHotkeys.js +4 -0
- package/dist/cjs/hooks/useHotkeys.js.map +1 -1
- package/dist/cjs/hooks/useHoverHandlersDelay.js +4 -0
- package/dist/cjs/hooks/useHoverHandlersDelay.js.map +1 -1
- package/dist/cjs/hooks/useIsMobile.js +4 -0
- package/dist/cjs/hooks/useIsMobile.js.map +1 -1
- package/dist/cjs/hooks/useIsShowingEllipsis.js +4 -0
- package/dist/cjs/hooks/useIsShowingEllipsis.js.map +1 -1
- package/dist/cjs/hooks/useMakeMutable.js +4 -0
- package/dist/cjs/hooks/useMakeMutable.js.map +1 -1
- package/dist/cjs/hooks/useNativeResizeObserver.js +4 -0
- package/dist/cjs/hooks/useNativeResizeObserver.js.map +1 -1
- package/dist/cjs/hooks/useOnBlurOut.js +4 -0
- package/dist/cjs/hooks/useOnBlurOut.js.map +1 -1
- package/dist/cjs/hooks/useOnElementResize.js +4 -0
- package/dist/cjs/hooks/useOnElementResize.js.map +1 -1
- package/dist/cjs/hooks/useOnFirstFocusIn.js +4 -0
- package/dist/cjs/hooks/useOnFirstFocusIn.js.map +1 -1
- package/dist/cjs/hooks/useOnSpecificFocus.js +4 -0
- package/dist/cjs/hooks/useOnSpecificFocus.js.map +1 -1
- package/dist/cjs/hooks/usePrevious.js +4 -0
- package/dist/cjs/hooks/usePrevious.js.map +1 -1
- package/dist/cjs/hooks/useResizeObserver.js +4 -0
- package/dist/cjs/hooks/useResizeObserver.js.map +1 -1
- package/dist/cjs/hooks/useShouldRecalculate.js +4 -0
- package/dist/cjs/hooks/useShouldRecalculate.js.map +1 -1
- package/dist/cjs/hooks/useWindowScrollerList.js +4 -0
- package/dist/cjs/hooks/useWindowScrollerList.js.map +1 -1
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/objectUtilities.js +4 -0
- package/dist/cjs/objectUtilities.js.map +1 -1
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js +4 -0
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js.map +1 -1
- package/dist/cjs/operators.js +8 -1
- package/dist/cjs/operators.js.map +1 -1
- package/dist/cjs/platform.js +4 -0
- package/dist/cjs/platform.js.map +1 -1
- package/dist/cjs/props-helpers/index.js +4 -0
- package/dist/cjs/props-helpers/index.js.map +1 -1
- package/dist/cjs/reactTypesUtility.js +4 -0
- package/dist/cjs/reactTypesUtility.js.map +1 -1
- package/dist/cjs/system.js +4 -0
- package/dist/cjs/system.js.map +1 -1
- package/dist/cjs/timeUtils.js +4 -0
- package/dist/cjs/timeUtils.js.map +1 -1
- package/dist/cjs/utils.js +4 -0
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/validations.js +4 -0
- package/dist/cjs/validations.js.map +1 -1
- package/dist/esm/compose.js.map +1 -1
- package/dist/esm/getComponentFromProps.js +1 -0
- package/dist/esm/getComponentFromProps.js.map +1 -1
- package/dist/esm/hooks/index.js +2 -0
- package/dist/esm/hooks/index.js.map +2 -2
- package/dist/esm/hooks/useExpandState.js.map +1 -1
- package/dist/esm/hooks/useFocusTrap.js.map +1 -1
- package/dist/esm/hooks/useHeadlessTooltip.js +110 -0
- package/dist/esm/hooks/useHeadlessTooltip.js.map +7 -0
- package/dist/esm/hooks/useIsMobile.js.map +1 -1
- package/dist/esm/hooks/useNativeResizeObserver.js.map +1 -1
- package/dist/esm/hooks/useResizeObserver.js.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/objectUtilities.js.map +1 -1
- package/dist/esm/operators.js +4 -1
- package/dist/esm/operators.js.map +1 -1
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/tests/useHeadlessTooltip.func.test.d.ts +1 -0
- package/dist/types/hooks/tests/useHeadlessTooltip.render.test.d.ts +1 -0
- package/dist/types/hooks/useHeadlessTooltip.d.ts +85 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +4 -4
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/objectUtilities.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "const JSONKeyValueRegExp = /\"(.+?)\": \"(.+?)\",?$/gm;\nconst prettyStringfy = (obj: Record<string, unknown>): string => JSON.stringify(obj, null, 2);\nfunction getFirstGroup(regexp: RegExp, str: string) {\n const array = [...str.matchAll(regexp)];\n const firstGroup = array.map((m) => m[1]).filter((v) => v !== undefined);\n if (firstGroup.length > 0) return firstGroup;\n return null;\n}\nfunction getSecondGroup(regexp: RegExp, str: string) {\n const array = [...str.matchAll(regexp)];\n const secondGroup = array.map((m) => m[2]).filter((v) => v !== undefined);\n if (secondGroup.length > 0) return secondGroup;\n return null;\n}\nexport const getObjectValuesToArray = (obj: Record<string, unknown>): string[] | null =>\n getSecondGroup(JSONKeyValueRegExp, prettyStringfy(obj));\n\nexport const getObjectKeysToArray = (obj: Record<string, unknown>): string[] | null =>\n getFirstGroup(JSONKeyValueRegExp, prettyStringfy(obj));\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB,CAAC,QAAyC,KAAK,UAAU,KAAK,MAAM,CAAC;AAC5F,SAAS,cAAc,QAAgB,KAAa;AAClD,QAAM,QAAQ,CAAC,GAAG,IAAI,SAAS,MAAM,CAAC;AACtC,QAAM,aAAa,MAAM,IAAI,CAAC,MAAM,EAAE,
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,MAAM,qBAAqB;AAC3B,MAAM,iBAAiB,CAAC,QAAyC,KAAK,UAAU,KAAK,MAAM,CAAC;AAC5F,SAAS,cAAc,QAAgB,KAAa;AAClD,QAAM,QAAQ,CAAC,GAAG,IAAI,SAAS,MAAM,CAAC;AACtC,QAAM,aAAa,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,MAAM,MAAS;AACvE,MAAI,WAAW,SAAS;AAAG,WAAO;AAClC,SAAO;AACT;AACA,SAAS,eAAe,QAAgB,KAAa;AACnD,QAAM,QAAQ,CAAC,GAAG,IAAI,SAAS,MAAM,CAAC;AACtC,QAAM,cAAc,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,MAAM,MAAS;AACxE,MAAI,YAAY,SAAS;AAAG,WAAO;AACnC,SAAO;AACT;AACO,MAAM,yBAAyB,CAAC,QACrC,eAAe,oBAAoB,eAAe,GAAG,CAAC;AAEjD,MAAM,uBAAuB,CAAC,QACnC,cAAc,oBAAoB,eAAe,GAAG,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/operators.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { isEmpty } from "lodash";
|
|
3
|
-
const checkNotEmpty = (value) =>
|
|
3
|
+
const checkNotEmpty = (value) => (
|
|
4
|
+
// eslint-disable-next-line eqeqeq
|
|
5
|
+
value === "" || value === void 0 || value === null || isEmpty(value)
|
|
6
|
+
);
|
|
4
7
|
const checkEmpty = (value) => !isEmpty(value);
|
|
5
8
|
const greaterThan = (value, comparator) => value > comparator;
|
|
6
9
|
const validDate = (value) => {
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/operators.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { isEmpty } from 'lodash';\n\n// Check if the value is empty\nexport const checkNotEmpty = (value: unknown) =>\n // eslint-disable-next-line eqeqeq\n value === '' || value === undefined || value === null || isEmpty(value);\n\n// Check if the value is not empty\nexport const checkEmpty = (value: unknown) => !isEmpty(value);\n\nexport const greaterThan = (value: number, comparator: number) => value > comparator;\n\n// Check if a valid date with format MM/DD/YYYY\nexport const validDate = (value: string) => {\n const dateValidationRegex = /^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$/;\n if (!dateValidationRegex.test(value)) return false;\n const [m, d, y] = value.split('/').map((n) => Number(n));\n return m === Number(new Date(y, m - 1, d).getMonth()) + 1 && d === Number(new Date(y, m - 1, d).getDate());\n};\n\nexport const equal = (a: unknown, b: unknown) => a === b;\n\nexport const notEqual = (a: unknown, b: unknown) => !equal(a, b);\n\nexport const isNull = (a: unknown) => checkNotEmpty(a);\n\nexport const isNotNull = (a: unknown) => !isNull(a);\n\nexport const isIn = <T,>(a: T, b: T[]) => b.indexOf(a) > -1;\n\nexport const isNotIn = <T,>(a: T, b: T[]) => !isIn(a, b);\n\nexport const greaterThanOrEquals = (value: number, comparator: number) => value >= comparator;\nexport const lessThanOrEquals = (value: number, comparator: number) => value <= comparator;\nexport const startsWith = (value: unknown, comparator: string) => String(value).startsWith(comparator);\nexport const contains = (value: unknown, comparator: string) => String(value).includes(comparator);\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe;AAGjB,MAAM,gBAAgB,CAAC,
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe;AAGjB,MAAM,gBAAgB,CAAC;AAAA;AAAA,EAE5B,UAAU,MAAM,UAAU,UAAa,UAAU,QAAQ,QAAQ,KAAK;AAAA;AAGjE,MAAM,aAAa,CAAC,UAAmB,CAAC,QAAQ,KAAK;AAErD,MAAM,cAAc,CAAC,OAAe,eAAuB,QAAQ;AAGnE,MAAM,YAAY,CAAC,UAAkB;AAC1C,QAAM,sBAAsB;AAC5B,MAAI,CAAC,oBAAoB,KAAK,KAAK;AAAG,WAAO;AAC7C,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI,MAAM,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC;AACvD,SAAO,MAAM,OAAO,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,SAAS,CAAC,IAAI,KAAK,MAAM,OAAO,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,QAAQ,CAAC;AAC3G;AAEO,MAAM,QAAQ,CAAC,GAAY,MAAe,MAAM;AAEhD,MAAM,WAAW,CAAC,GAAY,MAAe,CAAC,MAAM,GAAG,CAAC;AAExD,MAAM,SAAS,CAAC,MAAe,cAAc,CAAC;AAE9C,MAAM,YAAY,CAAC,MAAe,CAAC,OAAO,CAAC;AAE3C,MAAM,OAAO,CAAK,GAAM,MAAW,EAAE,QAAQ,CAAC,IAAI;AAElD,MAAM,UAAU,CAAK,GAAM,MAAW,CAAC,KAAK,GAAG,CAAC;AAEhD,MAAM,sBAAsB,CAAC,OAAe,eAAuB,SAAS;AAC5E,MAAM,mBAAmB,CAAC,OAAe,eAAuB,SAAS;AACzE,MAAM,aAAa,CAAC,OAAgB,eAAuB,OAAO,KAAK,EAAE,WAAW,UAAU;AAC9F,MAAM,WAAW,CAAC,OAAgB,eAAuB,OAAO,KAAK,EAAE,SAAS,UAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/utils.tsx"],
|
|
4
4
|
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-param-reassign */\n/* eslint-disable max-lines */\n/**\n * commonly used functions\n * Add a level of indirection to lodash so we can replace\n * it if desired, while keeping function names the same\n */\n// TODO: Import individual packages vs referencing all of lodash\nimport {\n cloneDeep,\n filter,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n noop,\n omit,\n orderBy,\n pull,\n sumBy,\n maxBy,\n meanBy,\n sortBy,\n transform,\n isFunction,\n uniq,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n isEqualWith,\n curry,\n isObject,\n isBoolean,\n} from 'lodash';\n\ntype UnknownFunctionT = (...args: unknown[]) => unknown;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ValidKeys = string | number | symbol;\n\n/**\n * Concatenates classNames from arguments\n *\n * @param {...any} classnames classnames you want to join\n * @returns {string} All classnames string concatenated\n */\nexport const cx = (...classnames: string[]): string => classnames.reduce((result, cn) => `${result} ${cn || ''}`, '');\n\n// if entry exists, remove it, if not, add it\nconst toggleInObject = (obj: Record<string, unknown>, key: string, value: unknown) =>\n obj[key] !== undefined ? omit(obj, [key]) : { ...obj, [key]: value };\n\nconst toggleInArray = (array: unknown[], value: unknown) => (array.indexOf(value) === -1 ? [value] : []);\n\nconst arrayMoveMutate = (array: unknown[], from: number, to: number) => {\n array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);\n};\n\nconst arrayMove = <T,>(array: T[], from: number, to: number): T[] => {\n array = array.slice();\n arrayMoveMutate(array, from, to);\n return array;\n};\n\nconst accessorDefault = <T,>(item: T): T => item;\n\nconst addOrRemove = <T,>(array: T[], item: T, accessor = accessorDefault): T[] => {\n const index = array.findIndex((iItem) => accessor(iItem) === accessor(item));\n\n if (index !== -1) {\n const nextArray = cloneDeep(array);\n nextArray.splice(index, 1);\n return nextArray;\n }\n\n return [...array, item];\n};\n\nexport function runAll(...fns: (UnknownFunctionT | UnknownFunctionT[])[]) {\n return (...args: unknown[]) =>\n fns.forEach((fn) => {\n if (Array.isArray(fn)) runAll(fn);\n if (isFunction(fn)) fn(...args);\n });\n}\n\nexport function hashArray(arr: (ValidKeys | Record<string, ValidKeys>)[], fieldName?: string) {\n return arr.reduce<Record<ValidKeys, boolean>>((result, item) => {\n const newKey: ValidKeys = fieldName && typeof item === 'object' ? item[fieldName] : (item as ValidKeys);\n return {\n ...result,\n [newKey]: true,\n };\n }, {});\n}\n\nexport function safeCall(fun: unknown, ...args: unknown[]) {\n if (isFunction(fun)) {\n fun(...args);\n }\n}\n\nexport const removeUndefinedProperties = (obj: Record<string, unknown>) => {\n const cleanObject = { ...obj };\n Object.keys(obj).forEach((key) => cleanObject[key] === undefined && delete cleanObject[key]);\n return cleanObject;\n};\n\nexport default {};\nexport {\n isObject,\n curry,\n arrayMove,\n uniq,\n filter,\n uniqBy,\n groupBy,\n property,\n get,\n set,\n cloneDeep,\n debounce,\n findIndex,\n isEmpty,\n isString,\n isEqual,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n pull,\n sortBy,\n sumBy,\n transform,\n isFunction,\n range,\n parseInt,\n padStart,\n isNaN,\n values,\n throttle,\n toggleInObject,\n toggleInArray,\n pick,\n pickBy,\n differenceBy,\n differenceWith,\n addOrRemove,\n isEqualWith,\n isBoolean,\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACQvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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|
export { useExecutionTimer } from './useExecutionTimer.js';
|
|
8
8
|
export { useExpandState } from './useExpandState.js';
|
|
9
9
|
export { useFocusTrap, UseFocusTrapWithSchema } from './useFocusTrap.js';
|
|
10
|
+
export { useHeadlessTooltip } from './useHeadlessTooltip.js';
|
|
10
11
|
export { useHotkeys } from './useHotkeys.js';
|
|
11
12
|
export { useHoverHandlersDelay } from './useHoverHandlersDelay.js';
|
|
12
13
|
export { useIsMobile } from './useIsMobile.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type LatestOpenInteraction = '' | 'onFocus' | 'onMouseEnter';
|
|
3
|
+
export type UseHeadlessTooltipConfig = {
|
|
4
|
+
hasFocus?: boolean;
|
|
5
|
+
isHovering?: boolean;
|
|
6
|
+
latestOpenInteraction?: LatestOpenInteraction;
|
|
7
|
+
onOpen?: () => void;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A custom hook that provides logic for a headless tooltip. This hook can be used in a controlled or uncontrolled way.
|
|
12
|
+
*
|
|
13
|
+
* @param {UseHeadlessTooltipConfig} config - The configuration object for the hook.
|
|
14
|
+
* @param {boolean} config.hasFocus - Whether or not the trigger element has focus. If this is not provided, the hook will track focus internally.
|
|
15
|
+
* @param {boolean} config.isHovering - Whether or not the mouse is hovering over the trigger element. If this is not provided, the hook will track hover internally.
|
|
16
|
+
* @param {LatestOpenInteraction} config.latestOpenInteraction - Whether or not the mouse is hovering over the trigger element. If this is not provided, the hook will track hover internally.
|
|
17
|
+
* @param {Function} config.onOpen - A callback that will be invoked when the tooltip is opened.
|
|
18
|
+
* @param {Function} config.onClose - A callback that will be invoked when the tooltip is closed.
|
|
19
|
+
* @returns {object} - An object containing the following properties:
|
|
20
|
+
*
|
|
21
|
+
* {boolean} hasFocus - Whether or not the trigger element has focus.
|
|
22
|
+
*
|
|
23
|
+
* {boolean} isHovering - Whether or not the mouse is hovering over the trigger element.
|
|
24
|
+
*
|
|
25
|
+
* {'' | 'onFocus' | 'onMouseEnter'} latestOpenInteraction - which was the last operation that is used to control if the tooltip should show or not.
|
|
26
|
+
*
|
|
27
|
+
* {string} finalLatestOpenInteraction - The most recent interaction that caused the tooltip to open.
|
|
28
|
+
*
|
|
29
|
+
* {HTMLDivElement} referenceElement - The trigger element.
|
|
30
|
+
*
|
|
31
|
+
* {function} setReferenceElement - A function that sets the trigger element.
|
|
32
|
+
*
|
|
33
|
+
* {boolean} shouldShowPopover - Whether or not the tooltip is visible.
|
|
34
|
+
*
|
|
35
|
+
* {function} showTooltip - A function that opens the tooltip.
|
|
36
|
+
*
|
|
37
|
+
* {function} hideTooltip - A function that closes the tooltip.
|
|
38
|
+
*
|
|
39
|
+
* {function} onFocus - A function that should be invoked when the trigger element receives focus.
|
|
40
|
+
*
|
|
41
|
+
* {function} onBlur - A function that should be invoked when the trigger element loses focus.
|
|
42
|
+
*
|
|
43
|
+
* {function} onMouseEnter - A function that should be invoked when the mouse enters the trigger element.
|
|
44
|
+
*
|
|
45
|
+
* {function} onMouseLeave - A function that should be invoked when the mouse leaves the trigger element.
|
|
46
|
+
* @example
|
|
47
|
+
* const tooltipHelpers = useHeadlessTooltip({
|
|
48
|
+
* hasFocus: true,
|
|
49
|
+
* isHovering: false,
|
|
50
|
+
* onOpen: () => console.log('tooltip opened'),
|
|
51
|
+
* onClose: () => console.log('tooltip closed'),
|
|
52
|
+
* });
|
|
53
|
+
* ...
|
|
54
|
+
* <div>
|
|
55
|
+
* <button
|
|
56
|
+
* ref={tooltipHelpers.setReferenceElement}
|
|
57
|
+
* onMouseEnter={tooltipHelpers.onMouseEnter}
|
|
58
|
+
* onMouseLeave={tooltipHelpers.onMouseLeave}
|
|
59
|
+
* onPointerEnter={tooltipHelpers.onMouseEnter}
|
|
60
|
+
* onPointerLeave={tooltipHelpers.onMouseLeave}
|
|
61
|
+
* onFocus={tooltipHelpers.onFocus}
|
|
62
|
+
* onBlur={tooltipHelpers.onBlur}
|
|
63
|
+
* >hello</button>
|
|
64
|
+
* <DSPopperJS
|
|
65
|
+
* referenceElement={tooltipHelpers.referenceElement}
|
|
66
|
+
* shouldShowPopover={tooltipHelpers.shouldShowPopover}
|
|
67
|
+
* >
|
|
68
|
+
* <div>Tooltip content</div>
|
|
69
|
+
* </DSPopperJS>
|
|
70
|
+
* </div>
|
|
71
|
+
*/
|
|
72
|
+
export declare const useHeadlessTooltip: (config?: UseHeadlessTooltipConfig) => {
|
|
73
|
+
hasFocus: boolean | null;
|
|
74
|
+
isHovering: boolean | null;
|
|
75
|
+
latestOpenInteraction: string | null;
|
|
76
|
+
referenceElement: HTMLDivElement | null;
|
|
77
|
+
setReferenceElement: React.Dispatch<React.SetStateAction<HTMLDivElement | null>>;
|
|
78
|
+
shouldShowPopover: boolean;
|
|
79
|
+
showTooltip: () => void;
|
|
80
|
+
hideTooltip: () => void;
|
|
81
|
+
onFocus: () => void;
|
|
82
|
+
onBlur: () => void;
|
|
83
|
+
onMouseEnter: () => void;
|
|
84
|
+
onMouseLeave: () => void;
|
|
85
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities.
|
|
|
5
5
|
export { checkNotEmpty, checkEmpty, greaterThan, validDate, equal, notEqual, isNull, isNotNull, isIn, isNotIn, greaterThanOrEquals, lessThanOrEquals, startsWith, contains, } from './operators.js';
|
|
6
6
|
export { cx, runAll, hashArray, safeCall, removeUndefinedProperties, isObject, curry, arrayMove, uniq, filter, uniqBy, groupBy, property, get, set, cloneDeep, debounce, findIndex, isEmpty, isString, isEqual, maxBy, meanBy, noop, omit, orderBy, pull, sortBy, sumBy, transform, isFunction, range, parseInt, padStart, isNaN, values, throttle, toggleInObject, toggleInArray, pick, pickBy, differenceBy, differenceWith, addOrRemove, isEqualWith, isBoolean, } from './utils.js';
|
|
7
7
|
export { setRef, mergeRefs, setMultipleRefs, logger } from './system.js';
|
|
8
|
-
export { useMeasure, useForceUpdate, useOnClickOutside, useExecutionTimer, useExpandState, useHotkeys, useHoverHandlersDelay, useResizeObserver, useShouldRecalculate, useWindowScrollerList, usePrevious, useCancellableDelayedCallback, useDerivedStateFromProps, useOnElementResize, useIsShowingEllipsis, useMakeMutable, useCallbackAfterRender, useFocusTrap, UseFocusTrapWithSchema, useIsMobile, useOnBlurOut, UseOnBlurOutWithSchema, useOnFirstFocusIn, UseOnFirstFocusInWithSchema, useOnSpecificFocus, UseOnSpecificFocusWithSchema, } from './hooks/index.js';
|
|
8
|
+
export { useMeasure, useForceUpdate, useOnClickOutside, useExecutionTimer, useExpandState, useHotkeys, useHoverHandlersDelay, useResizeObserver, useShouldRecalculate, useWindowScrollerList, usePrevious, useCancellableDelayedCallback, useDerivedStateFromProps, useOnElementResize, useIsShowingEllipsis, useMakeMutable, useCallbackAfterRender, useFocusTrap, UseFocusTrapWithSchema, useIsMobile, useOnBlurOut, UseOnBlurOutWithSchema, useOnFirstFocusIn, UseOnFirstFocusInWithSchema, useOnSpecificFocus, UseOnSpecificFocusWithSchema, useHeadlessTooltip, } from './hooks/index.js';
|
|
9
9
|
export { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils.js';
|
|
10
10
|
export { compose } from './compose.js';
|
|
11
11
|
export { DOCUMENT, WINDOW } from './platform.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-utilities",
|
|
3
|
-
"version": "3.16.0-next.
|
|
3
|
+
"version": "3.16.0-next.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Utilities",
|
|
6
6
|
"files": [
|
|
@@ -152,14 +152,14 @@
|
|
|
152
152
|
},
|
|
153
153
|
"dependencies": {
|
|
154
154
|
"@elliemae/pui-theme": "~2.6.0",
|
|
155
|
-
"hotkeys-js": "~3.10.
|
|
155
|
+
"hotkeys-js": "~3.10.1",
|
|
156
156
|
"raf": "~3.4.1",
|
|
157
157
|
"resize-observer-polyfill": "~1.5.1",
|
|
158
158
|
"uncontrollable": "~7.2.1",
|
|
159
|
-
"use-force-update": "~1.0.
|
|
159
|
+
"use-force-update": "~1.0.11",
|
|
160
160
|
"use-measure": "~0.3.0",
|
|
161
161
|
"use-onclickoutside": "~0.4.1",
|
|
162
|
-
"@elliemae/ds-props-helpers": "3.16.0-next.
|
|
162
|
+
"@elliemae/ds-props-helpers": "3.16.0-next.13"
|
|
163
163
|
},
|
|
164
164
|
"devDependencies": {
|
|
165
165
|
"@testing-library/jest-dom": "~5.16.5",
|