@elliemae/ds-utilities 3.22.0-next.2 → 3.22.0-next.21

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.
@@ -44,6 +44,7 @@ __export(hooks_exports, {
44
44
  useHoverHandlersDelay: () => import_useHoverHandlersDelay.useHoverHandlersDelay,
45
45
  useIsMobile: () => import_useIsMobile.useIsMobile,
46
46
  useIsShowingEllipsis: () => import_useIsShowingEllipsis.useIsShowingEllipsis,
47
+ useLatestValueReferenciallyStable: () => import_useMakeMutable.useLatestValueReferenciallyStable,
47
48
  useMakeMutable: () => import_useMakeMutable.useMakeMutable,
48
49
  useMeasure: () => import_use_measure.default,
49
50
  useNativeIntersectionObserver: () => import_useNativeIntersectionObserver.useNativeIntersectionObserver,
@@ -56,6 +57,7 @@ __export(hooks_exports, {
56
57
  usePrevious: () => import_usePrevious.usePrevious,
57
58
  useResizeObserver: () => import_useResizeObserver.useResizeObserver,
58
59
  useShouldRecalculate: () => import_useShouldRecalculate.useShouldRecalculate,
60
+ useSideEffectSyntheticEvent: () => import_useSideEffectSyntheticEvent.useSideEffectSyntheticEvent,
59
61
  useTrackElement: () => import_useTrackElement.useTrackElement,
60
62
  useWindowScrollerList: () => import_useWindowScrollerList.useWindowScrollerList
61
63
  });
@@ -85,6 +87,7 @@ var import_useOnSpecificFocus = require("./useOnSpecificFocus.js");
85
87
  var import_usePrevious = require("./usePrevious.js");
86
88
  var import_useResizeObserver = require("./useResizeObserver.js");
87
89
  var import_useShouldRecalculate = require("./useShouldRecalculate.js");
90
+ var import_useSideEffectSyntheticEvent = require("./useSideEffectSyntheticEvent.js");
88
91
  var import_useTrackElement = require("./useTrackElement.js");
89
92
  var import_useWindowScrollerList = require("./useWindowScrollerList.js");
90
93
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export { default as useMeasure } from 'use-measure';\nexport { default as useForceUpdate } from 'use-force-update';\nexport { default as useOnClickOutside } from 'use-onclickoutside';\n\nexport { useCallbackAfterRender } from './useCallbackAfterRender.js';\nexport { useCancellableDelayedCallback } from './useCancellableDelayedCallback.js';\nexport { useDerivedStateFromProps } from './useDerivedStateFromProps.js';\nexport { useExecutionTimer } from './useExecutionTimer.js';\nexport { useExpandState } from './useExpandState.js';\nexport { useFocusTrap, UseFocusTrapWithSchema } from './useFocusTrap.js';\nexport { useHeadlessTooltip } from './useHeadlessTooltip.js';\nexport { useHotkeys } from './useHotkeys.js';\nexport { useHoverHandlersDelay } from './useHoverHandlersDelay.js';\nexport { useIsMobile } from './useIsMobile.js';\nexport { useIsShowingEllipsis } from './useIsShowingEllipsis.js';\nexport { useMakeMutable } from './useMakeMutable.js';\nexport { useNativeIntersectionObserver } from './useNativeIntersectionObserver.js';\nexport { useNativeResizeObserver } from './useNativeResizeObserver.js';\nexport { useOnBlurOut, UseOnBlurOutWithSchema } from './useOnBlurOut.js';\nexport { useOnElementResize } from './useOnElementResize.js';\nexport { useOnFirstFocusIn, UseOnFirstFocusInWithSchema } from './useOnFirstFocusIn.js';\nexport { useOnSpecificFocus, UseOnSpecificFocusWithSchema } from './useOnSpecificFocus.js';\nexport { usePrevious } from './usePrevious.js';\nexport { useResizeObserver } from './useResizeObserver.js';\nexport { useShouldRecalculate } from './useShouldRecalculate.js';\nexport { useTrackElement } from './useTrackElement.js';\nexport { useWindowScrollerList } from './useWindowScrollerList.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,yBAAsC;AACtC,8BAA0C;AAC1C,gCAA6C;AAE7C,oCAAuC;AACvC,2CAA8C;AAC9C,sCAAyC;AACzC,+BAAkC;AAClC,4BAA+B;AAC/B,0BAAqD;AACrD,gCAAmC;AACnC,wBAA2B;AAC3B,mCAAsC;AACtC,yBAA4B;AAC5B,kCAAqC;AACrC,4BAA+B;AAC/B,2CAA8C;AAC9C,qCAAwC;AACxC,0BAAqD;AACrD,gCAAmC;AACnC,+BAA+D;AAC/D,gCAAiE;AACjE,yBAA4B;AAC5B,+BAAkC;AAClC,kCAAqC;AACrC,6BAAgC;AAChC,mCAAsC;",
4
+ "sourcesContent": ["export { default as useMeasure } from 'use-measure';\nexport { default as useForceUpdate } from 'use-force-update';\nexport { default as useOnClickOutside } from 'use-onclickoutside';\n\nexport { useCallbackAfterRender } from './useCallbackAfterRender.js';\nexport { useCancellableDelayedCallback } from './useCancellableDelayedCallback.js';\nexport { useDerivedStateFromProps } from './useDerivedStateFromProps.js';\nexport { useExecutionTimer } from './useExecutionTimer.js';\nexport { useExpandState } from './useExpandState.js';\nexport { useFocusTrap, UseFocusTrapWithSchema } from './useFocusTrap.js';\nexport { useHeadlessTooltip } from './useHeadlessTooltip.js';\nexport { useHotkeys } from './useHotkeys.js';\nexport { useHoverHandlersDelay } from './useHoverHandlersDelay.js';\nexport { useIsMobile } from './useIsMobile.js';\nexport { useIsShowingEllipsis } from './useIsShowingEllipsis.js';\nexport { useMakeMutable, useLatestValueReferenciallyStable } from './useMakeMutable.js';\nexport { useNativeIntersectionObserver } from './useNativeIntersectionObserver.js';\nexport { useNativeResizeObserver } from './useNativeResizeObserver.js';\nexport { useOnBlurOut, UseOnBlurOutWithSchema } from './useOnBlurOut.js';\nexport { useOnElementResize } from './useOnElementResize.js';\nexport { useOnFirstFocusIn, UseOnFirstFocusInWithSchema } from './useOnFirstFocusIn.js';\nexport { useOnSpecificFocus, UseOnSpecificFocusWithSchema } from './useOnSpecificFocus.js';\nexport { usePrevious } from './usePrevious.js';\nexport { useResizeObserver } from './useResizeObserver.js';\nexport { useShouldRecalculate } from './useShouldRecalculate.js';\nexport { useSideEffectSyntheticEvent } from './useSideEffectSyntheticEvent.js';\nexport { useTrackElement } from './useTrackElement.js';\nexport { useWindowScrollerList } from './useWindowScrollerList.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,yBAAsC;AACtC,8BAA0C;AAC1C,gCAA6C;AAE7C,oCAAuC;AACvC,2CAA8C;AAC9C,sCAAyC;AACzC,+BAAkC;AAClC,4BAA+B;AAC/B,0BAAqD;AACrD,gCAAmC;AACnC,wBAA2B;AAC3B,mCAAsC;AACtC,yBAA4B;AAC5B,kCAAqC;AACrC,4BAAkE;AAClE,2CAA8C;AAC9C,qCAAwC;AACxC,0BAAqD;AACrD,gCAAmC;AACnC,+BAA+D;AAC/D,gCAAiE;AACjE,yBAA4B;AAC5B,+BAAkC;AAClC,kCAAqC;AACrC,yCAA4C;AAC5C,6BAAgC;AAChC,mCAAsC;",
6
6
  "names": []
7
7
  }
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var useMakeMutable_exports = {};
30
30
  __export(useMakeMutable_exports, {
31
+ useLatestValueReferenciallyStable: () => useLatestValueReferenciallyStable,
31
32
  useMakeMutable: () => useMakeMutable
32
33
  });
33
34
  module.exports = __toCommonJS(useMakeMutable_exports);
@@ -40,4 +41,5 @@ const useMakeMutable = (referenceVar) => {
40
41
  }, [referenceVar]);
41
42
  return mutable;
42
43
  };
44
+ const useLatestValueReferenciallyStable = useMakeMutable;
43
45
  //# sourceMappingURL=useMakeMutable.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useMakeMutable.ts", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { useRef, useEffect } from 'react';\ntype UseMakeMutable = <T>(referenceVar: T) => React.MutableRefObject<T>;\nexport const useMakeMutable: UseMakeMutable = (referenceVar) => {\n const mutable = useRef(referenceVar);\n useEffect(() => {\n mutable.current = referenceVar;\n }, [referenceVar]);\n return mutable;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkC;AAE3B,MAAM,iBAAiC,CAAC,iBAAiB;AAC9D,QAAM,cAAU,qBAAO,YAAY;AACnC,8BAAU,MAAM;AACd,YAAQ,UAAU;AAAA,EACpB,GAAG,CAAC,YAAY,CAAC;AACjB,SAAO;AACT;",
4
+ "sourcesContent": ["import type React from 'react';\nimport { useRef, useEffect } from 'react';\ntype UseMakeMutable = <T>(referenceVar: T) => React.MutableRefObject<T>;\n\n/**\n * For specific scenarios we need to be able to read the latest value of a variable at execution time without triggering dependency updates on useEffect/useCallback/useMemo\n * This is a custom hook that allows us to do that, with a performance overhead of a useEffect and a memory overhead of a ref.\n * @param {any} referenceVar - the value to be made \"referentially stable\", this works with primitive values and values by reference\n * @returns {object} - an object with a \"current\" property that holds the latest value of the variable passed as argument\n * @property {any} current - the latest value of the variable passed as argument\n * @example\n * const Comp = ({ value }) => {\n * const latestValueRef = useMakeMutable(value);\n * React.useEffect(() => {\n * console.log(latestValueRef.current); // this will log 'hola' at the time of execution\n * }, []);\n * latestValueRef.current = 'hola'; // this will update the latest value of \"value\" at the time of execution\n * ...\n * return <div>...</div>\n * }\n */\nexport const useMakeMutable: UseMakeMutable = (referenceVar) => {\n const mutable = useRef(referenceVar);\n useEffect(() => {\n mutable.current = referenceVar;\n }, [referenceVar]);\n return mutable;\n};\n\n/**\n * For specific scenarios we need to be able to read the latest value of a variable at execution time without triggering dependency updates on useEffect/useCallback/useMemo\n * This is a custom hook that allows us to do that, with a performance overhead of a useEffect and a memory overhead of a ref.\n * N.B. this is the same as useMakeMutable, but with a more explicit name.\n * @param {any} referenceVar - the value to be made \"referentially stable\", this works with primitive values and values by reference\n * @returns {object} - an object with a \"current\" property that holds the latest value of the variable passed as argument\n * @property {any} current - the latest value of the variable passed as argument\n * @example\n * const Comp = ({ value }) => {\n * const latestValueRef = useLatestValueReferenciallyStable(value);\n * React.useEffect(() => {\n * console.log(latestValueRef.current); // this will log 'hola' at the time of execution\n * }, []);\n * latestValueRef.current = 'hola'; // this will update the latest value of \"value\" at the time of execution\n * ...\n * return <div>...</div>\n * }\n */\nexport const useLatestValueReferenciallyStable = useMakeMutable;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAkC;AAoB3B,MAAM,iBAAiC,CAAC,iBAAiB;AAC9D,QAAM,cAAU,qBAAO,YAAY;AACnC,8BAAU,MAAM;AACd,YAAQ,UAAU;AAAA,EACpB,GAAG,CAAC,YAAY,CAAC;AACjB,SAAO;AACT;AAoBO,MAAM,oCAAoC;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var useSideEffectSyntheticEvent_exports = {};
30
+ __export(useSideEffectSyntheticEvent_exports, {
31
+ useSideEffectSyntheticEvent: () => useSideEffectSyntheticEvent
32
+ });
33
+ module.exports = __toCommonJS(useSideEffectSyntheticEvent_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_react = __toESM(require("react"));
36
+ var import_useMakeMutable = require("./useMakeMutable.js");
37
+ const useSideEffectSyntheticEvent = (dependency, callback, callbackOpts) => {
38
+ const refCb = (0, import_useMakeMutable.useLatestValueReferenciallyStable)(callback);
39
+ const refCbOpts = (0, import_useMakeMutable.useLatestValueReferenciallyStable)(callbackOpts);
40
+ import_react.default.useEffect(() => {
41
+ refCb?.current?.(dependency, refCbOpts.current);
42
+ }, [dependency, refCb, refCbOpts]);
43
+ };
44
+ //# sourceMappingURL=useSideEffectSyntheticEvent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/hooks/useSideEffectSyntheticEvent.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import React from 'react';\nimport { useLatestValueReferenciallyStable } from './useMakeMutable.js';\n/**\n * This is a custom hook that allows us to simulate a synthetic event. This ensure we only trigger a side effect when a specific variable(dependency) changes.\n * @param {any} dependency - the variable that we want to listen to\n * @param {Function} callback - the callback that we want to execute when the dependency changes\n * @param {object} callbackOpts - the options to be passed to the callback function\n * @returns {void}\n * @invoke useLatestValueReferenciallyStable\n */\nexport const useSideEffectSyntheticEvent = <T, CBOpts>(\n dependency: T,\n callback: (latestVal: T, opts: CBOpts) => void,\n callbackOpts: CBOpts,\n) => {\n const refCb = useLatestValueReferenciallyStable(callback);\n const refCbOpts = useLatestValueReferenciallyStable(callbackOpts);\n // this is the useEffect that simulates the event\n React.useEffect(() => {\n refCb?.current?.(dependency, refCbOpts.current);\n // the point of this custom hook is making sure we only listen to the dependency and nothing else\n // without violating the rules of hooks/exhaustive-deps rule and making it explicit that we want to simulate an event\n // refCb & refCbOpts are forced to be referentially stable, so we can safely put it in the dependency array\n }, [dependency, refCb, refCbOpts]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkB;AAClB,4BAAkD;AAS3C,MAAM,8BAA8B,CACzC,YACA,UACA,iBACG;AACH,QAAM,YAAQ,yDAAkC,QAAQ;AACxD,QAAM,gBAAY,yDAAkC,YAAY;AAEhE,eAAAA,QAAM,UAAU,MAAM;AACpB,WAAO,UAAU,YAAY,UAAU,OAAO;AAAA,EAIhD,GAAG,CAAC,YAAY,OAAO,SAAS,CAAC;AACnC;",
6
+ "names": ["React"]
7
+ }
package/dist/cjs/index.js CHANGED
@@ -124,6 +124,7 @@ __export(src_exports, {
124
124
  useHoverHandlersDelay: () => import_hooks.useHoverHandlersDelay,
125
125
  useIsMobile: () => import_hooks.useIsMobile,
126
126
  useIsShowingEllipsis: () => import_hooks.useIsShowingEllipsis,
127
+ useLatestValueReferenciallyStable: () => import_hooks.useLatestValueReferenciallyStable,
127
128
  useMakeMutable: () => import_hooks.useMakeMutable,
128
129
  useMeasure: () => import_hooks.useMeasure,
129
130
  useNativeIntersectionObserver: () => import_hooks.useNativeIntersectionObserver,
@@ -136,6 +137,7 @@ __export(src_exports, {
136
137
  usePrevious: () => import_hooks.usePrevious,
137
138
  useResizeObserver: () => import_hooks.useResizeObserver,
138
139
  useShouldRecalculate: () => import_hooks.useShouldRecalculate,
140
+ useSideEffectSyntheticEvent: () => import_hooks.useSideEffectSyntheticEvent,
139
141
  useTrackElement: () => import_hooks.useTrackElement,
140
142
  useWindowScrollerList: () => import_hooks.useWindowScrollerList,
141
143
  validDate: () => import_operators.validDate,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export { default as getComponentFromProps } from './getComponentFromProps.js';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements.js';\nexport { capitalize } from './capitalize.js';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities.js';\nexport {\n checkEmpty,\n checkNotEmpty,\n contains,\n equal,\n greaterThan,\n greaterThanOrEquals,\n isIn,\n isNotIn,\n isNotNull,\n isNull,\n lessThanOrEquals,\n notEqual,\n startsWith,\n validDate,\n} from './operators.js';\nexport {\n addOrRemove,\n arrayMove,\n cloneDeep,\n curry,\n cx,\n debounce,\n differenceBy,\n differenceWith,\n filter,\n findIndex,\n get,\n groupBy,\n hashArray,\n isBoolean,\n isEmpty,\n isEqual,\n isEqualWith,\n isFunction,\n isNaN,\n isObject,\n isString,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n padStart,\n parseInt,\n pick,\n pickBy,\n property,\n pull,\n range,\n removeUndefinedProperties,\n runAll,\n safeCall,\n set,\n sortBy,\n sumBy,\n throttle,\n toggleInArray,\n toggleInObject,\n transform,\n uniq,\n uniqBy,\n values,\n} from './utils.js';\nexport { setRef, mergeRefs, setMultipleRefs, logger } from './system.js';\nexport {\n useCallbackAfterRender,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useExecutionTimer,\n useExpandState,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useForceUpdate,\n useHeadlessTooltip,\n useHotkeys,\n useHoverHandlersDelay,\n useIsMobile,\n useIsShowingEllipsis,\n useMakeMutable,\n useMeasure,\n useNativeIntersectionObserver,\n useNativeResizeObserver,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnClickOutside,\n useOnElementResize,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n usePrevious,\n useResizeObserver,\n useShouldRecalculate,\n useTrackElement,\n useWindowScrollerList,\n} from './hooks/index.js';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils.js';\nexport { compose } from './compose.js';\nexport { DOCUMENT, WINDOW } from './platform.js';\nexport { isDOMTypeElement } from './reactTypesUtility.js';\nexport { isRequired, isGreaterThan, isValidDate } from './validations.js';\nexport { getHighlightedRerendersStyle } from './getHighlightedRerendersStyle.js';\n\nexport { crossTypeSort } from './algorithms/crossTypeSort.js';\nexport { appendComponentIfNotExist } from './addComponentIfNotExists.js';\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated/index.js';\nexport * from './props-helpers/index.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mCAAiD;AACjD,qDAAmE;AACnE,wBAA2B;AAC3B,6BAA6D;AAC7D,uBAeO;AACP,mBA+CO;AACP,oBAA2D;AAC3D,mBA+BO;AACP,uBAAwD;AACxD,qBAAwB;AACxB,sBAAiC;AACjC,+BAAiC;AACjC,yBAAuD;AACvD,0CAA6C;AAE7C,2BAA8B;AAC9B,qCAA0C;AAE1C,wBAAc,kCA/Gd;AAgHA,wBAAc,qCAhHd;",
4
+ "sourcesContent": ["export { default as getComponentFromProps } from './getComponentFromProps.js';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements.js';\nexport { capitalize } from './capitalize.js';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities.js';\nexport {\n checkEmpty,\n checkNotEmpty,\n contains,\n equal,\n greaterThan,\n greaterThanOrEquals,\n isIn,\n isNotIn,\n isNotNull,\n isNull,\n lessThanOrEquals,\n notEqual,\n startsWith,\n validDate,\n} from './operators.js';\nexport {\n addOrRemove,\n arrayMove,\n cloneDeep,\n curry,\n cx,\n debounce,\n differenceBy,\n differenceWith,\n filter,\n findIndex,\n get,\n groupBy,\n hashArray,\n isBoolean,\n isEmpty,\n isEqual,\n isEqualWith,\n isFunction,\n isNaN,\n isObject,\n isString,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n padStart,\n parseInt,\n pick,\n pickBy,\n property,\n pull,\n range,\n removeUndefinedProperties,\n runAll,\n safeCall,\n set,\n sortBy,\n sumBy,\n throttle,\n toggleInArray,\n toggleInObject,\n transform,\n uniq,\n uniqBy,\n values,\n} from './utils.js';\nexport { setRef, mergeRefs, setMultipleRefs, logger } from './system.js';\nexport {\n useCallbackAfterRender,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useExecutionTimer,\n useExpandState,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useForceUpdate,\n useHeadlessTooltip,\n useHotkeys,\n useHoverHandlersDelay,\n useIsMobile,\n useIsShowingEllipsis,\n useMakeMutable,\n useLatestValueReferenciallyStable,\n useMeasure,\n useNativeIntersectionObserver,\n useNativeResizeObserver,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnClickOutside,\n useOnElementResize,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n usePrevious,\n useResizeObserver,\n useShouldRecalculate,\n useSideEffectSyntheticEvent,\n useTrackElement,\n useWindowScrollerList,\n} from './hooks/index.js';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils.js';\nexport { compose } from './compose.js';\nexport { DOCUMENT, WINDOW } from './platform.js';\nexport { isDOMTypeElement } from './reactTypesUtility.js';\nexport { isRequired, isGreaterThan, isValidDate } from './validations.js';\nexport { getHighlightedRerendersStyle } from './getHighlightedRerendersStyle.js';\n\nexport { crossTypeSort } from './algorithms/crossTypeSort.js';\nexport { appendComponentIfNotExist } from './addComponentIfNotExists.js';\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated/index.js';\nexport * from './props-helpers/index.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mCAAiD;AACjD,qDAAmE;AACnE,wBAA2B;AAC3B,6BAA6D;AAC7D,uBAeO;AACP,mBA+CO;AACP,oBAA2D;AAC3D,mBAiCO;AACP,uBAAwD;AACxD,qBAAwB;AACxB,sBAAiC;AACjC,+BAAiC;AACjC,yBAAuD;AACvD,0CAA6C;AAE7C,2BAA8B;AAC9B,qCAA0C;AAE1C,wBAAc,kCAjHd;AAkHA,wBAAc,qCAlHd;",
6
6
  "names": []
7
7
  }
@@ -13,7 +13,7 @@ import { useHotkeys } from "./useHotkeys.js";
13
13
  import { useHoverHandlersDelay } from "./useHoverHandlersDelay.js";
14
14
  import { useIsMobile } from "./useIsMobile.js";
15
15
  import { useIsShowingEllipsis } from "./useIsShowingEllipsis.js";
16
- import { useMakeMutable } from "./useMakeMutable.js";
16
+ import { useMakeMutable, useLatestValueReferenciallyStable } from "./useMakeMutable.js";
17
17
  import { useNativeIntersectionObserver } from "./useNativeIntersectionObserver.js";
18
18
  import { useNativeResizeObserver } from "./useNativeResizeObserver.js";
19
19
  import { useOnBlurOut, UseOnBlurOutWithSchema } from "./useOnBlurOut.js";
@@ -23,6 +23,7 @@ import { useOnSpecificFocus, UseOnSpecificFocusWithSchema } from "./useOnSpecifi
23
23
  import { usePrevious } from "./usePrevious.js";
24
24
  import { useResizeObserver } from "./useResizeObserver.js";
25
25
  import { useShouldRecalculate } from "./useShouldRecalculate.js";
26
+ import { useSideEffectSyntheticEvent } from "./useSideEffectSyntheticEvent.js";
26
27
  import { useTrackElement } from "./useTrackElement.js";
27
28
  import { useWindowScrollerList } from "./useWindowScrollerList.js";
28
29
  export {
@@ -42,6 +43,7 @@ export {
42
43
  useHoverHandlersDelay,
43
44
  useIsMobile,
44
45
  useIsShowingEllipsis,
46
+ useLatestValueReferenciallyStable,
45
47
  useMakeMutable,
46
48
  default2 as useMeasure,
47
49
  useNativeIntersectionObserver,
@@ -54,6 +56,7 @@ export {
54
56
  usePrevious,
55
57
  useResizeObserver,
56
58
  useShouldRecalculate,
59
+ useSideEffectSyntheticEvent,
57
60
  useTrackElement,
58
61
  useWindowScrollerList
59
62
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/index.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as useMeasure } from 'use-measure';\nexport { default as useForceUpdate } from 'use-force-update';\nexport { default as useOnClickOutside } from 'use-onclickoutside';\n\nexport { useCallbackAfterRender } from './useCallbackAfterRender.js';\nexport { useCancellableDelayedCallback } from './useCancellableDelayedCallback.js';\nexport { useDerivedStateFromProps } from './useDerivedStateFromProps.js';\nexport { useExecutionTimer } from './useExecutionTimer.js';\nexport { useExpandState } from './useExpandState.js';\nexport { useFocusTrap, UseFocusTrapWithSchema } from './useFocusTrap.js';\nexport { useHeadlessTooltip } from './useHeadlessTooltip.js';\nexport { useHotkeys } from './useHotkeys.js';\nexport { useHoverHandlersDelay } from './useHoverHandlersDelay.js';\nexport { useIsMobile } from './useIsMobile.js';\nexport { useIsShowingEllipsis } from './useIsShowingEllipsis.js';\nexport { useMakeMutable } from './useMakeMutable.js';\nexport { useNativeIntersectionObserver } from './useNativeIntersectionObserver.js';\nexport { useNativeResizeObserver } from './useNativeResizeObserver.js';\nexport { useOnBlurOut, UseOnBlurOutWithSchema } from './useOnBlurOut.js';\nexport { useOnElementResize } from './useOnElementResize.js';\nexport { useOnFirstFocusIn, UseOnFirstFocusInWithSchema } from './useOnFirstFocusIn.js';\nexport { useOnSpecificFocus, UseOnSpecificFocusWithSchema } from './useOnSpecificFocus.js';\nexport { usePrevious } from './usePrevious.js';\nexport { useResizeObserver } from './useResizeObserver.js';\nexport { useShouldRecalculate } from './useShouldRecalculate.js';\nexport { useTrackElement } from './useTrackElement.js';\nexport { useWindowScrollerList } from './useWindowScrollerList.js';\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAoC;AAE7C,SAAS,8BAA8B;AACvC,SAAS,qCAAqC;AAC9C,SAAS,gCAAgC;AACzC,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,8BAA8B;AACrD,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,sBAAsB;AAC/B,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,SAAS,cAAc,8BAA8B;AACrD,SAAS,0BAA0B;AACnC,SAAS,mBAAmB,mCAAmC;AAC/D,SAAS,oBAAoB,oCAAoC;AACjE,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as useMeasure } from 'use-measure';\nexport { default as useForceUpdate } from 'use-force-update';\nexport { default as useOnClickOutside } from 'use-onclickoutside';\n\nexport { useCallbackAfterRender } from './useCallbackAfterRender.js';\nexport { useCancellableDelayedCallback } from './useCancellableDelayedCallback.js';\nexport { useDerivedStateFromProps } from './useDerivedStateFromProps.js';\nexport { useExecutionTimer } from './useExecutionTimer.js';\nexport { useExpandState } from './useExpandState.js';\nexport { useFocusTrap, UseFocusTrapWithSchema } from './useFocusTrap.js';\nexport { useHeadlessTooltip } from './useHeadlessTooltip.js';\nexport { useHotkeys } from './useHotkeys.js';\nexport { useHoverHandlersDelay } from './useHoverHandlersDelay.js';\nexport { useIsMobile } from './useIsMobile.js';\nexport { useIsShowingEllipsis } from './useIsShowingEllipsis.js';\nexport { useMakeMutable, useLatestValueReferenciallyStable } from './useMakeMutable.js';\nexport { useNativeIntersectionObserver } from './useNativeIntersectionObserver.js';\nexport { useNativeResizeObserver } from './useNativeResizeObserver.js';\nexport { useOnBlurOut, UseOnBlurOutWithSchema } from './useOnBlurOut.js';\nexport { useOnElementResize } from './useOnElementResize.js';\nexport { useOnFirstFocusIn, UseOnFirstFocusInWithSchema } from './useOnFirstFocusIn.js';\nexport { useOnSpecificFocus, UseOnSpecificFocusWithSchema } from './useOnSpecificFocus.js';\nexport { usePrevious } from './usePrevious.js';\nexport { useResizeObserver } from './useResizeObserver.js';\nexport { useShouldRecalculate } from './useShouldRecalculate.js';\nexport { useSideEffectSyntheticEvent } from './useSideEffectSyntheticEvent.js';\nexport { useTrackElement } from './useTrackElement.js';\nexport { useWindowScrollerList } from './useWindowScrollerList.js';\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAoB,WAAXA,gBAA6B;AACtC,SAAoB,WAAXA,gBAAiC;AAC1C,SAAoB,WAAXA,gBAAoC;AAE7C,SAAS,8BAA8B;AACvC,SAAS,qCAAqC;AAC9C,SAAS,gCAAgC;AACzC,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,cAAc,8BAA8B;AACrD,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,gBAAgB,yCAAyC;AAClE,SAAS,qCAAqC;AAC9C,SAAS,+BAA+B;AACxC,SAAS,cAAc,8BAA8B;AACrD,SAAS,0BAA0B;AACnC,SAAS,mBAAmB,mCAAmC;AAC/D,SAAS,oBAAoB,oCAAoC;AACjE,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,mCAAmC;AAC5C,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;",
6
6
  "names": ["default"]
7
7
  }
@@ -7,7 +7,9 @@ const useMakeMutable = (referenceVar) => {
7
7
  }, [referenceVar]);
8
8
  return mutable;
9
9
  };
10
+ const useLatestValueReferenciallyStable = useMakeMutable;
10
11
  export {
12
+ useLatestValueReferenciallyStable,
11
13
  useMakeMutable
12
14
  };
13
15
  //# sourceMappingURL=useMakeMutable.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useMakeMutable.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useRef, useEffect } from 'react';\ntype UseMakeMutable = <T>(referenceVar: T) => React.MutableRefObject<T>;\nexport const useMakeMutable: UseMakeMutable = (referenceVar) => {\n const mutable = useRef(referenceVar);\n useEffect(() => {\n mutable.current = referenceVar;\n }, [referenceVar]);\n return mutable;\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,QAAQ,iBAAiB;AAE3B,MAAM,iBAAiC,CAAC,iBAAiB;AAC9D,QAAM,UAAU,OAAO,YAAY;AACnC,YAAU,MAAM;AACd,YAAQ,UAAU;AAAA,EACpB,GAAG,CAAC,YAAY,CAAC;AACjB,SAAO;AACT;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type React from 'react';\nimport { useRef, useEffect } from 'react';\ntype UseMakeMutable = <T>(referenceVar: T) => React.MutableRefObject<T>;\n\n/**\n * For specific scenarios we need to be able to read the latest value of a variable at execution time without triggering dependency updates on useEffect/useCallback/useMemo\n * This is a custom hook that allows us to do that, with a performance overhead of a useEffect and a memory overhead of a ref.\n * @param {any} referenceVar - the value to be made \"referentially stable\", this works with primitive values and values by reference\n * @returns {object} - an object with a \"current\" property that holds the latest value of the variable passed as argument\n * @property {any} current - the latest value of the variable passed as argument\n * @example\n * const Comp = ({ value }) => {\n * const latestValueRef = useMakeMutable(value);\n * React.useEffect(() => {\n * console.log(latestValueRef.current); // this will log 'hola' at the time of execution\n * }, []);\n * latestValueRef.current = 'hola'; // this will update the latest value of \"value\" at the time of execution\n * ...\n * return <div>...</div>\n * }\n */\nexport const useMakeMutable: UseMakeMutable = (referenceVar) => {\n const mutable = useRef(referenceVar);\n useEffect(() => {\n mutable.current = referenceVar;\n }, [referenceVar]);\n return mutable;\n};\n\n/**\n * For specific scenarios we need to be able to read the latest value of a variable at execution time without triggering dependency updates on useEffect/useCallback/useMemo\n * This is a custom hook that allows us to do that, with a performance overhead of a useEffect and a memory overhead of a ref.\n * N.B. this is the same as useMakeMutable, but with a more explicit name.\n * @param {any} referenceVar - the value to be made \"referentially stable\", this works with primitive values and values by reference\n * @returns {object} - an object with a \"current\" property that holds the latest value of the variable passed as argument\n * @property {any} current - the latest value of the variable passed as argument\n * @example\n * const Comp = ({ value }) => {\n * const latestValueRef = useLatestValueReferenciallyStable(value);\n * React.useEffect(() => {\n * console.log(latestValueRef.current); // this will log 'hola' at the time of execution\n * }, []);\n * latestValueRef.current = 'hola'; // this will update the latest value of \"value\" at the time of execution\n * ...\n * return <div>...</div>\n * }\n */\nexport const useLatestValueReferenciallyStable = useMakeMutable;\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,QAAQ,iBAAiB;AAoB3B,MAAM,iBAAiC,CAAC,iBAAiB;AAC9D,QAAM,UAAU,OAAO,YAAY;AACnC,YAAU,MAAM;AACd,YAAQ,UAAU;AAAA,EACpB,GAAG,CAAC,YAAY,CAAC;AACjB,SAAO;AACT;AAoBO,MAAM,oCAAoC;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ import { useLatestValueReferenciallyStable } from "./useMakeMutable.js";
4
+ const useSideEffectSyntheticEvent = (dependency, callback, callbackOpts) => {
5
+ const refCb = useLatestValueReferenciallyStable(callback);
6
+ const refCbOpts = useLatestValueReferenciallyStable(callbackOpts);
7
+ React2.useEffect(() => {
8
+ refCb?.current?.(dependency, refCbOpts.current);
9
+ }, [dependency, refCb, refCbOpts]);
10
+ };
11
+ export {
12
+ useSideEffectSyntheticEvent
13
+ };
14
+ //# sourceMappingURL=useSideEffectSyntheticEvent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/hooks/useSideEffectSyntheticEvent.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { useLatestValueReferenciallyStable } from './useMakeMutable.js';\n/**\n * This is a custom hook that allows us to simulate a synthetic event. This ensure we only trigger a side effect when a specific variable(dependency) changes.\n * @param {any} dependency - the variable that we want to listen to\n * @param {Function} callback - the callback that we want to execute when the dependency changes\n * @param {object} callbackOpts - the options to be passed to the callback function\n * @returns {void}\n * @invoke useLatestValueReferenciallyStable\n */\nexport const useSideEffectSyntheticEvent = <T, CBOpts>(\n dependency: T,\n callback: (latestVal: T, opts: CBOpts) => void,\n callbackOpts: CBOpts,\n) => {\n const refCb = useLatestValueReferenciallyStable(callback);\n const refCbOpts = useLatestValueReferenciallyStable(callbackOpts);\n // this is the useEffect that simulates the event\n React.useEffect(() => {\n refCb?.current?.(dependency, refCbOpts.current);\n // the point of this custom hook is making sure we only listen to the dependency and nothing else\n // without violating the rules of hooks/exhaustive-deps rule and making it explicit that we want to simulate an event\n // refCb & refCbOpts are forced to be referentially stable, so we can safely put it in the dependency array\n }, [dependency, refCb, refCbOpts]);\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,YAAW;AAClB,SAAS,yCAAyC;AAS3C,MAAM,8BAA8B,CACzC,YACA,UACA,iBACG;AACH,QAAM,QAAQ,kCAAkC,QAAQ;AACxD,QAAM,YAAY,kCAAkC,YAAY;AAEhE,EAAAA,OAAM,UAAU,MAAM;AACpB,WAAO,UAAU,YAAY,UAAU,OAAO;AAAA,EAIhD,GAAG,CAAC,YAAY,OAAO,SAAS,CAAC;AACnC;",
6
+ "names": ["React"]
7
+ }
package/dist/esm/index.js CHANGED
@@ -83,6 +83,7 @@ import {
83
83
  useIsMobile,
84
84
  useIsShowingEllipsis,
85
85
  useMakeMutable,
86
+ useLatestValueReferenciallyStable,
86
87
  useMeasure,
87
88
  useNativeIntersectionObserver,
88
89
  useNativeResizeObserver,
@@ -97,6 +98,7 @@ import {
97
98
  usePrevious,
98
99
  useResizeObserver,
99
100
  useShouldRecalculate,
101
+ useSideEffectSyntheticEvent,
100
102
  useTrackElement,
101
103
  useWindowScrollerList
102
104
  } from "./hooks/index.js";
@@ -206,6 +208,7 @@ export {
206
208
  useHoverHandlersDelay,
207
209
  useIsMobile,
208
210
  useIsShowingEllipsis,
211
+ useLatestValueReferenciallyStable,
209
212
  useMakeMutable,
210
213
  useMeasure,
211
214
  useNativeIntersectionObserver,
@@ -218,6 +221,7 @@ export {
218
221
  usePrevious,
219
222
  useResizeObserver,
220
223
  useShouldRecalculate,
224
+ useSideEffectSyntheticEvent,
221
225
  useTrackElement,
222
226
  useWindowScrollerList,
223
227
  validDate,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as getComponentFromProps } from './getComponentFromProps.js';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements.js';\nexport { capitalize } from './capitalize.js';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities.js';\nexport {\n checkEmpty,\n checkNotEmpty,\n contains,\n equal,\n greaterThan,\n greaterThanOrEquals,\n isIn,\n isNotIn,\n isNotNull,\n isNull,\n lessThanOrEquals,\n notEqual,\n startsWith,\n validDate,\n} from './operators.js';\nexport {\n addOrRemove,\n arrayMove,\n cloneDeep,\n curry,\n cx,\n debounce,\n differenceBy,\n differenceWith,\n filter,\n findIndex,\n get,\n groupBy,\n hashArray,\n isBoolean,\n isEmpty,\n isEqual,\n isEqualWith,\n isFunction,\n isNaN,\n isObject,\n isString,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n padStart,\n parseInt,\n pick,\n pickBy,\n property,\n pull,\n range,\n removeUndefinedProperties,\n runAll,\n safeCall,\n set,\n sortBy,\n sumBy,\n throttle,\n toggleInArray,\n toggleInObject,\n transform,\n uniq,\n uniqBy,\n values,\n} from './utils.js';\nexport { setRef, mergeRefs, setMultipleRefs, logger } from './system.js';\nexport {\n useCallbackAfterRender,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useExecutionTimer,\n useExpandState,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useForceUpdate,\n useHeadlessTooltip,\n useHotkeys,\n useHoverHandlersDelay,\n useIsMobile,\n useIsShowingEllipsis,\n useMakeMutable,\n useMeasure,\n useNativeIntersectionObserver,\n useNativeResizeObserver,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnClickOutside,\n useOnElementResize,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n usePrevious,\n useResizeObserver,\n useShouldRecalculate,\n useTrackElement,\n useWindowScrollerList,\n} from './hooks/index.js';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils.js';\nexport { compose } from './compose.js';\nexport { DOCUMENT, WINDOW } from './platform.js';\nexport { isDOMTypeElement } from './reactTypesUtility.js';\nexport { isRequired, isGreaterThan, isValidDate } from './validations.js';\nexport { getHighlightedRerendersStyle } from './getHighlightedRerendersStyle.js';\n\nexport { crossTypeSort } from './algorithms/crossTypeSort.js';\nexport { appendComponentIfNotExist } from './addComponentIfNotExists.js';\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated/index.js';\nexport * from './props-helpers/index.js';\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAA0D;AACnE,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB,4BAA4B;AAC7D;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,OACK;AACP;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,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,OACK;AACP,SAAS,QAAQ,WAAW,iBAAiB,cAAc;AAC3D;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,OACK;AACP,SAAS,wBAAwB,uBAAuB;AACxD,SAAS,eAAe;AACxB,SAAS,UAAU,cAAc;AACjC,SAAS,wBAAwB;AACjC,SAAS,YAAY,eAAe,mBAAmB;AACvD,SAAS,oCAAoC;AAE7C,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;AAE1C,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { default as getComponentFromProps } from './getComponentFromProps.js';\nexport { default as onClickHandlerForNonInteractiveElements } from './onClickHandlerForNonInteractiveElements.js';\nexport { capitalize } from './capitalize.js';\nexport { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities.js';\nexport {\n checkEmpty,\n checkNotEmpty,\n contains,\n equal,\n greaterThan,\n greaterThanOrEquals,\n isIn,\n isNotIn,\n isNotNull,\n isNull,\n lessThanOrEquals,\n notEqual,\n startsWith,\n validDate,\n} from './operators.js';\nexport {\n addOrRemove,\n arrayMove,\n cloneDeep,\n curry,\n cx,\n debounce,\n differenceBy,\n differenceWith,\n filter,\n findIndex,\n get,\n groupBy,\n hashArray,\n isBoolean,\n isEmpty,\n isEqual,\n isEqualWith,\n isFunction,\n isNaN,\n isObject,\n isString,\n maxBy,\n meanBy,\n noop,\n omit,\n orderBy,\n padStart,\n parseInt,\n pick,\n pickBy,\n property,\n pull,\n range,\n removeUndefinedProperties,\n runAll,\n safeCall,\n set,\n sortBy,\n sumBy,\n throttle,\n toggleInArray,\n toggleInObject,\n transform,\n uniq,\n uniqBy,\n values,\n} from './utils.js';\nexport { setRef, mergeRefs, setMultipleRefs, logger } from './system.js';\nexport {\n useCallbackAfterRender,\n useCancellableDelayedCallback,\n useDerivedStateFromProps,\n useExecutionTimer,\n useExpandState,\n useFocusTrap,\n UseFocusTrapWithSchema,\n useForceUpdate,\n useHeadlessTooltip,\n useHotkeys,\n useHoverHandlersDelay,\n useIsMobile,\n useIsShowingEllipsis,\n useMakeMutable,\n useLatestValueReferenciallyStable,\n useMeasure,\n useNativeIntersectionObserver,\n useNativeResizeObserver,\n useOnBlurOut,\n UseOnBlurOutWithSchema,\n useOnClickOutside,\n useOnElementResize,\n useOnFirstFocusIn,\n UseOnFirstFocusInWithSchema,\n useOnSpecificFocus,\n UseOnSpecificFocusWithSchema,\n usePrevious,\n useResizeObserver,\n useShouldRecalculate,\n useSideEffectSyntheticEvent,\n useTrackElement,\n useWindowScrollerList,\n} from './hooks/index.js';\nexport { getVisibleTimeByFormat, addLeadingZeros } from './timeUtils.js';\nexport { compose } from './compose.js';\nexport { DOCUMENT, WINDOW } from './platform.js';\nexport { isDOMTypeElement } from './reactTypesUtility.js';\nexport { isRequired, isGreaterThan, isValidDate } from './validations.js';\nexport { getHighlightedRerendersStyle } from './getHighlightedRerendersStyle.js';\n\nexport { crossTypeSort } from './algorithms/crossTypeSort.js';\nexport { appendComponentIfNotExist } from './addComponentIfNotExists.js';\n// TODO -- REMOVE WHEN READY\nexport * from './deprecated/index.js';\nexport * from './props-helpers/index.js';\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAoB,WAAXA,gBAAwC;AACjD,SAAoB,WAAXA,gBAA0D;AACnE,SAAS,kBAAkB;AAC3B,SAAS,wBAAwB,4BAA4B;AAC7D;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,OACK;AACP;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,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,OACK;AACP,SAAS,QAAQ,WAAW,iBAAiB,cAAc;AAC3D;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,EACA;AAAA,OACK;AACP,SAAS,wBAAwB,uBAAuB;AACxD,SAAS,eAAe;AACxB,SAAS,UAAU,cAAc;AACjC,SAAS,wBAAwB;AACjC,SAAS,YAAY,eAAe,mBAAmB;AACvD,SAAS,oCAAoC;AAE7C,SAAS,qBAAqB;AAC9B,SAAS,iCAAiC;AAE1C,cAAc;AACd,cAAc;",
6
6
  "names": ["default"]
7
7
  }
@@ -12,7 +12,7 @@ export { useHotkeys } from './useHotkeys.js';
12
12
  export { useHoverHandlersDelay } from './useHoverHandlersDelay.js';
13
13
  export { useIsMobile } from './useIsMobile.js';
14
14
  export { useIsShowingEllipsis } from './useIsShowingEllipsis.js';
15
- export { useMakeMutable } from './useMakeMutable.js';
15
+ export { useMakeMutable, useLatestValueReferenciallyStable } from './useMakeMutable.js';
16
16
  export { useNativeIntersectionObserver } from './useNativeIntersectionObserver.js';
17
17
  export { useNativeResizeObserver } from './useNativeResizeObserver.js';
18
18
  export { useOnBlurOut, UseOnBlurOutWithSchema } from './useOnBlurOut.js';
@@ -22,5 +22,6 @@ export { useOnSpecificFocus, UseOnSpecificFocusWithSchema } from './useOnSpecifi
22
22
  export { usePrevious } from './usePrevious.js';
23
23
  export { useResizeObserver } from './useResizeObserver.js';
24
24
  export { useShouldRecalculate } from './useShouldRecalculate.js';
25
+ export { useSideEffectSyntheticEvent } from './useSideEffectSyntheticEvent.js';
25
26
  export { useTrackElement } from './useTrackElement.js';
26
27
  export { useWindowScrollerList } from './useWindowScrollerList.js';
@@ -1,4 +1,40 @@
1
- /// <reference types="react" />
1
+ import type React from 'react';
2
2
  type UseMakeMutable = <T>(referenceVar: T) => React.MutableRefObject<T>;
3
+ /**
4
+ * For specific scenarios we need to be able to read the latest value of a variable at execution time without triggering dependency updates on useEffect/useCallback/useMemo
5
+ * This is a custom hook that allows us to do that, with a performance overhead of a useEffect and a memory overhead of a ref.
6
+ * @param {any} referenceVar - the value to be made "referentially stable", this works with primitive values and values by reference
7
+ * @returns {object} - an object with a "current" property that holds the latest value of the variable passed as argument
8
+ * @property {any} current - the latest value of the variable passed as argument
9
+ * @example
10
+ * const Comp = ({ value }) => {
11
+ * const latestValueRef = useMakeMutable(value);
12
+ * React.useEffect(() => {
13
+ * console.log(latestValueRef.current); // this will log 'hola' at the time of execution
14
+ * }, []);
15
+ * latestValueRef.current = 'hola'; // this will update the latest value of "value" at the time of execution
16
+ * ...
17
+ * return <div>...</div>
18
+ * }
19
+ */
3
20
  export declare const useMakeMutable: UseMakeMutable;
21
+ /**
22
+ * For specific scenarios we need to be able to read the latest value of a variable at execution time without triggering dependency updates on useEffect/useCallback/useMemo
23
+ * This is a custom hook that allows us to do that, with a performance overhead of a useEffect and a memory overhead of a ref.
24
+ * N.B. this is the same as useMakeMutable, but with a more explicit name.
25
+ * @param {any} referenceVar - the value to be made "referentially stable", this works with primitive values and values by reference
26
+ * @returns {object} - an object with a "current" property that holds the latest value of the variable passed as argument
27
+ * @property {any} current - the latest value of the variable passed as argument
28
+ * @example
29
+ * const Comp = ({ value }) => {
30
+ * const latestValueRef = useLatestValueReferenciallyStable(value);
31
+ * React.useEffect(() => {
32
+ * console.log(latestValueRef.current); // this will log 'hola' at the time of execution
33
+ * }, []);
34
+ * latestValueRef.current = 'hola'; // this will update the latest value of "value" at the time of execution
35
+ * ...
36
+ * return <div>...</div>
37
+ * }
38
+ */
39
+ export declare const useLatestValueReferenciallyStable: UseMakeMutable;
4
40
  export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This is a custom hook that allows us to simulate a synthetic event. This ensure we only trigger a side effect when a specific variable(dependency) changes.
3
+ * @param {any} dependency - the variable that we want to listen to
4
+ * @param {Function} callback - the callback that we want to execute when the dependency changes
5
+ * @param {object} callbackOpts - the options to be passed to the callback function
6
+ * @returns {void}
7
+ * @invoke useLatestValueReferenciallyStable
8
+ */
9
+ export declare const useSideEffectSyntheticEvent: <T, CBOpts>(dependency: T, callback: (latestVal: T, opts: CBOpts) => void, callbackOpts: CBOpts) => void;
@@ -5,7 +5,7 @@ export { getObjectValuesToArray, getObjectKeysToArray } from './objectUtilities.
5
5
  export { checkEmpty, checkNotEmpty, contains, equal, greaterThan, greaterThanOrEquals, isIn, isNotIn, isNotNull, isNull, lessThanOrEquals, notEqual, startsWith, validDate, } from './operators.js';
6
6
  export { addOrRemove, arrayMove, cloneDeep, curry, cx, debounce, differenceBy, differenceWith, filter, findIndex, get, groupBy, hashArray, isBoolean, isEmpty, isEqual, isEqualWith, isFunction, isNaN, isObject, isString, maxBy, meanBy, noop, omit, orderBy, padStart, parseInt, pick, pickBy, property, pull, range, removeUndefinedProperties, runAll, safeCall, set, sortBy, sumBy, throttle, toggleInArray, toggleInObject, transform, uniq, uniqBy, values, } from './utils.js';
7
7
  export { setRef, mergeRefs, setMultipleRefs, logger } from './system.js';
8
- export { useCallbackAfterRender, useCancellableDelayedCallback, useDerivedStateFromProps, useExecutionTimer, useExpandState, useFocusTrap, UseFocusTrapWithSchema, useForceUpdate, useHeadlessTooltip, useHotkeys, useHoverHandlersDelay, useIsMobile, useIsShowingEllipsis, useMakeMutable, useMeasure, useNativeIntersectionObserver, useNativeResizeObserver, useOnBlurOut, UseOnBlurOutWithSchema, useOnClickOutside, useOnElementResize, useOnFirstFocusIn, UseOnFirstFocusInWithSchema, useOnSpecificFocus, UseOnSpecificFocusWithSchema, usePrevious, useResizeObserver, useShouldRecalculate, useTrackElement, useWindowScrollerList, } from './hooks/index.js';
8
+ export { useCallbackAfterRender, useCancellableDelayedCallback, useDerivedStateFromProps, useExecutionTimer, useExpandState, useFocusTrap, UseFocusTrapWithSchema, useForceUpdate, useHeadlessTooltip, useHotkeys, useHoverHandlersDelay, useIsMobile, useIsShowingEllipsis, useMakeMutable, useLatestValueReferenciallyStable, useMeasure, useNativeIntersectionObserver, useNativeResizeObserver, useOnBlurOut, UseOnBlurOutWithSchema, useOnClickOutside, useOnElementResize, useOnFirstFocusIn, UseOnFirstFocusInWithSchema, useOnSpecificFocus, UseOnSpecificFocusWithSchema, usePrevious, useResizeObserver, useShouldRecalculate, useSideEffectSyntheticEvent, useTrackElement, useWindowScrollerList, } 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.22.0-next.2",
3
+ "version": "3.22.0-next.21",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Utilities",
6
6
  "files": [
@@ -160,12 +160,14 @@
160
160
  "use-force-update": "~1.0.11",
161
161
  "use-measure": "~0.3.0",
162
162
  "use-onclickoutside": "~0.4.1",
163
- "@elliemae/ds-props-helpers": "3.22.0-next.2"
163
+ "@elliemae/ds-props-helpers": "3.22.0-next.21"
164
164
  },
165
165
  "devDependencies": {
166
+ "@elliemae/pui-cli": "~9.0.0-next.22",
166
167
  "@testing-library/react": "~12.1.3",
167
168
  "@testing-library/react-hooks": "~8.0.1",
168
- "react-dom": "^17.0.2"
169
+ "react-dom": "^17.0.2",
170
+ "@elliemae/ds-monorepo-devops": "3.22.0-next.21"
169
171
  },
170
172
  "peerDependencies": {
171
173
  "lodash": "^4.17.21",
@@ -173,7 +175,7 @@
173
175
  "react-dom": "^17.0.2"
174
176
  },
175
177
  "scripts": {
176
- "test": "node ../../scripts/testing/test.mjs",
178
+ "test": "pui-cli test --passWithNoTests",
177
179
  "lint": "node ../../scripts/lint.mjs",
178
180
  "eslint:fix": "eslint --ext='.js,.jsx,.test.js,.ts,.tsx' --fix --config='../../.eslintrc.js' src/",
179
181
  "dts": "node ../../scripts/dts.mjs",