@elliemae/ds-hooks-on-overflow-change 3.52.0-rc.25
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/DSHooksIsOverflowing.js +89 -0
- package/dist/cjs/DSHooksIsOverflowing.js.map +7 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/react-desc-prop-types.js +47 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/tests/overflow/DSHooksIsOverflowing.overflow.test.playwright.js +66 -0
- package/dist/cjs/tests/overflow/DSHooksIsOverflowing.overflow.test.playwright.js.map +7 -0
- package/dist/cjs/tests/overflow/DSHooksIsOverflowingTestRenderer.js +66 -0
- package/dist/cjs/tests/overflow/DSHooksIsOverflowingTestRenderer.js.map +7 -0
- package/dist/cjs/typescript-testing/typescript-on-overflow-change.js +73 -0
- package/dist/cjs/typescript-testing/typescript-on-overflow-change.js.map +7 -0
- package/dist/esm/DSHooksIsOverflowing.js +62 -0
- package/dist/esm/DSHooksIsOverflowing.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +7 -0
- package/dist/esm/react-desc-prop-types.js +17 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/tests/overflow/DSHooksIsOverflowing.overflow.test.playwright.js +43 -0
- package/dist/esm/tests/overflow/DSHooksIsOverflowing.overflow.test.playwright.js.map +7 -0
- package/dist/esm/tests/overflow/DSHooksIsOverflowingTestRenderer.js +36 -0
- package/dist/esm/tests/overflow/DSHooksIsOverflowingTestRenderer.js.map +7 -0
- package/dist/esm/typescript-testing/typescript-on-overflow-change.js +43 -0
- package/dist/esm/typescript-testing/typescript-on-overflow-change.js.map +7 -0
- package/dist/types/DSHooksIsOverflowing.d.ts +6 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/react-desc-prop-types.d.ts +14 -0
- package/dist/types/tests/overflow/DSHooksIsOverflowing.overflow.test.playwright.d.ts +1 -0
- package/dist/types/tests/overflow/DSHooksIsOverflowingTestRenderer.d.ts +2 -0
- package/dist/types/typescript-testing/typescript-on-overflow-change.d.ts +2 -0
- package/package.json +74 -0
|
@@ -0,0 +1,89 @@
|
|
|
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 DSHooksIsOverflowing_exports = {};
|
|
30
|
+
__export(DSHooksIsOverflowing_exports, {
|
|
31
|
+
useOnOverflowChange: () => useOnOverflowChange,
|
|
32
|
+
useOnOverflowChangeWithSchema: () => useOnOverflowChangeWithSchema
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(DSHooksIsOverflowing_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
38
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
39
|
+
const isOverflowing = (node) => node.offsetWidth < node.scrollWidth;
|
|
40
|
+
const useOnOverflowChange = ({
|
|
41
|
+
onOverflowStateChange
|
|
42
|
+
}) => {
|
|
43
|
+
const nodeForComparison = (0, import_react.useRef)(null);
|
|
44
|
+
const resizeObserver = (0, import_react.useRef)(null);
|
|
45
|
+
const previousOverflowState = (0, import_react.useRef)(null);
|
|
46
|
+
const onResizeNotifier = (0, import_react.useCallback)(
|
|
47
|
+
(node) => {
|
|
48
|
+
const isTruncating = isOverflowing(node);
|
|
49
|
+
if (previousOverflowState.current !== isTruncating) {
|
|
50
|
+
onOverflowStateChange(isTruncating);
|
|
51
|
+
previousOverflowState.current = isTruncating;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
[onOverflowStateChange]
|
|
55
|
+
);
|
|
56
|
+
const handleRef = (0, import_react.useCallback)(
|
|
57
|
+
(node) => {
|
|
58
|
+
if (node) {
|
|
59
|
+
onResizeNotifier(node);
|
|
60
|
+
const didNodeChange = nodeForComparison.current !== node;
|
|
61
|
+
if (didNodeChange) {
|
|
62
|
+
if (resizeObserver.current) {
|
|
63
|
+
resizeObserver.current.disconnect();
|
|
64
|
+
}
|
|
65
|
+
resizeObserver.current = new ResizeObserver(() => {
|
|
66
|
+
onResizeNotifier(node);
|
|
67
|
+
});
|
|
68
|
+
resizeObserver.current.observe(node);
|
|
69
|
+
nodeForComparison.current = node;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
[onResizeNotifier]
|
|
74
|
+
);
|
|
75
|
+
(0, import_react.useEffect)(
|
|
76
|
+
() => () => {
|
|
77
|
+
if (resizeObserver.current) {
|
|
78
|
+
resizeObserver.current.disconnect();
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
[]
|
|
82
|
+
);
|
|
83
|
+
return (0, import_react.useMemo)(() => ({ handleRef }), [handleRef]);
|
|
84
|
+
};
|
|
85
|
+
useOnOverflowChange.displayName = "useOnOverflowChange";
|
|
86
|
+
const useOnOverflowChangeWithSchema = (0, import_ds_props_helpers.describe)(useOnOverflowChange);
|
|
87
|
+
useOnOverflowChangeWithSchema.propTypes = import_react_desc_prop_types.UseOnOverflowChangeTPropTypes;
|
|
88
|
+
useOnOverflowChangeWithSchema.returnType = import_react_desc_prop_types.UseOnOverflowChangeTReturnType;
|
|
89
|
+
//# sourceMappingURL=DSHooksIsOverflowing.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/DSHooksIsOverflowing.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\nimport React, { useCallback, useRef, useEffect, useMemo } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport {\n type DSHooksUseOnOverflowChangeT,\n UseOnOverflowChangeTPropTypes,\n UseOnOverflowChangeTReturnType,\n} from './react-desc-prop-types.js';\n\nconst isOverflowing = (node: HTMLElement) => node.offsetWidth < node.scrollWidth;\n\nconst useOnOverflowChange: DSHooksUseOnOverflowChangeT.UseOnOverflowChange & { displayName: string } = ({\n onOverflowStateChange,\n}) => {\n const nodeForComparison = useRef<HTMLElement | null>(null);\n const resizeObserver = useRef<ResizeObserver | null>(null);\n const previousOverflowState = useRef<boolean | null>(null);\n\n const onResizeNotifier = useCallback(\n (node: HTMLElement) => {\n const isTruncating = isOverflowing(node);\n\n if (previousOverflowState.current !== isTruncating) {\n onOverflowStateChange(isTruncating);\n previousOverflowState.current = isTruncating;\n }\n },\n [onOverflowStateChange],\n );\n\n const handleRef = useCallback(\n (node: HTMLElement | null) => {\n if (node) {\n onResizeNotifier(node);\n\n const didNodeChange = nodeForComparison.current !== node;\n if (didNodeChange) {\n if (resizeObserver.current) {\n resizeObserver.current.disconnect();\n }\n\n resizeObserver.current = new ResizeObserver(() => {\n onResizeNotifier(node);\n });\n resizeObserver.current.observe(node);\n\n nodeForComparison.current = node;\n }\n }\n },\n [onResizeNotifier],\n );\n\n useEffect(\n () => () => {\n if (resizeObserver.current) {\n resizeObserver.current.disconnect();\n }\n },\n [],\n );\n\n return useMemo(() => ({ handleRef }), [handleRef]);\n};\n\nuseOnOverflowChange.displayName = 'useOnOverflowChange';\n\nconst useOnOverflowChangeWithSchema = describe(useOnOverflowChange);\n\nuseOnOverflowChangeWithSchema.propTypes = UseOnOverflowChangeTPropTypes;\nuseOnOverflowChangeWithSchema.returnType = UseOnOverflowChangeTReturnType;\n\nexport { useOnOverflowChange, useOnOverflowChangeWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAA+D;AAC/D,8BAAyB;AACzB,mCAIO;AAEP,MAAM,gBAAgB,CAAC,SAAsB,KAAK,cAAc,KAAK;AAErE,MAAM,sBAAiG,CAAC;AAAA,EACtG;AACF,MAAM;AACJ,QAAM,wBAAoB,qBAA2B,IAAI;AACzD,QAAM,qBAAiB,qBAA8B,IAAI;AACzD,QAAM,4BAAwB,qBAAuB,IAAI;AAEzD,QAAM,uBAAmB;AAAA,IACvB,CAAC,SAAsB;AACrB,YAAM,eAAe,cAAc,IAAI;AAEvC,UAAI,sBAAsB,YAAY,cAAc;AAClD,8BAAsB,YAAY;AAClC,8BAAsB,UAAU;AAAA,MAClC;AAAA,IACF;AAAA,IACA,CAAC,qBAAqB;AAAA,EACxB;AAEA,QAAM,gBAAY;AAAA,IAChB,CAAC,SAA6B;AAC5B,UAAI,MAAM;AACR,yBAAiB,IAAI;AAErB,cAAM,gBAAgB,kBAAkB,YAAY;AACpD,YAAI,eAAe;AACjB,cAAI,eAAe,SAAS;AAC1B,2BAAe,QAAQ,WAAW;AAAA,UACpC;AAEA,yBAAe,UAAU,IAAI,eAAe,MAAM;AAChD,6BAAiB,IAAI;AAAA,UACvB,CAAC;AACD,yBAAe,QAAQ,QAAQ,IAAI;AAEnC,4BAAkB,UAAU;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,gBAAgB;AAAA,EACnB;AAEA;AAAA,IACE,MAAM,MAAM;AACV,UAAI,eAAe,SAAS;AAC1B,uBAAe,QAAQ,WAAW;AAAA,MACpC;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,aAAO,sBAAQ,OAAO,EAAE,UAAU,IAAI,CAAC,SAAS,CAAC;AACnD;AAEA,oBAAoB,cAAc;AAElC,MAAM,oCAAgC,kCAAS,mBAAmB;AAElE,8BAA8B,YAAY;AAC1C,8BAA8B,aAAa;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
|
+
useOnOverflowChange: () => import_DSHooksIsOverflowing.useOnOverflowChange,
|
|
32
|
+
useOnOverflowChangeWithSchema: () => import_DSHooksIsOverflowing.useOnOverflowChangeWithSchema
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_DSHooksIsOverflowing = require("./DSHooksIsOverflowing.js");
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["export { useOnOverflowChange, useOnOverflowChangeWithSchema } from './DSHooksIsOverflowing.js';\nexport { type DSHooksUseOnOverflowChangeT } from './react-desc-prop-types.js';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,kCAAmE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 react_desc_prop_types_exports = {};
|
|
30
|
+
__export(react_desc_prop_types_exports, {
|
|
31
|
+
UseOnOverflowChangeTPropTypes: () => UseOnOverflowChangeTPropTypes,
|
|
32
|
+
UseOnOverflowChangeTReturnType: () => UseOnOverflowChangeTReturnType
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
37
|
+
const UseOnOverflowChangeTPropTypes = {
|
|
38
|
+
onOverflowStateChange: import_ds_props_helpers.PropTypes.func.description(
|
|
39
|
+
"Callback function triggered when the overflow state changes. Receives a boolean indicating whether the content is overflowing."
|
|
40
|
+
).isRequired
|
|
41
|
+
};
|
|
42
|
+
const UseOnOverflowChangeTReturnType = {
|
|
43
|
+
handleRef: import_ds_props_helpers.PropTypes.func.description(
|
|
44
|
+
"Function to be passed as a ref to the element being monitored for overflow changes."
|
|
45
|
+
).isRequired
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/react-desc-prop-types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import type { WeakValidationMap } from 'react';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSHooksUseOnOverflowChangeT {\n export interface Arguments {\n onOverflowStateChange: (isOverflowing: boolean) => void;\n }\n\n export interface ResultType {\n handleRef: (node: HTMLElement | null) => void;\n }\n\n export type UseOnOverflowChange = (args: Arguments) => ResultType;\n}\n\nexport const UseOnOverflowChangeTPropTypes = {\n onOverflowStateChange: PropTypes.func.description(\n 'Callback function triggered when the overflow state changes. Receives a boolean indicating whether the content is overflowing.',\n ).isRequired,\n} as WeakValidationMap<unknown>;\n\nexport const UseOnOverflowChangeTReturnType = {\n handleRef: PropTypes.func.description(\n 'Function to be passed as a ref to the element being monitored for overflow changes.',\n ).isRequired,\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,8BAA0B;AAcnB,MAAM,gCAAgC;AAAA,EAC3C,uBAAuB,kCAAU,KAAK;AAAA,IACpC;AAAA,EACF,EAAE;AACJ;AAEO,MAAM,iCAAiC;AAAA,EAC5C,WAAW,kCAAU,KAAK;AAAA,IACxB;AAAA,EACF,EAAE;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var React = __toESM(require("react"));
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_experimental_ct_react = require("@playwright/experimental-ct-react");
|
|
27
|
+
var import_DSHooksIsOverflowingTestRenderer = require("./DSHooksIsOverflowingTestRenderer");
|
|
28
|
+
const containerSelector = '[data-testid="container"]';
|
|
29
|
+
const overflowStateSelector = '[data-testid="overflow-state"]';
|
|
30
|
+
import_experimental_ct_react.test.describe("DSHooksIsOverflowingTestRenderer - Overflow Behavior", () => {
|
|
31
|
+
(0, import_experimental_ct_react.test)("Should detect overflow when content exceeds container width", async ({ mount, page }) => {
|
|
32
|
+
import_experimental_ct_react.test.setTimeout(2e4);
|
|
33
|
+
await mount(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DSHooksIsOverflowingTestRenderer.DSHooksIsOverflowingTestRenderer, {}));
|
|
34
|
+
const container = page.locator(containerSelector);
|
|
35
|
+
await container.waitFor({ state: "attached" });
|
|
36
|
+
await container.evaluate((node) => {
|
|
37
|
+
node.style.width = "100px";
|
|
38
|
+
});
|
|
39
|
+
await (0, import_experimental_ct_react.expect)(page.locator(overflowStateSelector)).toContainText("Overflowing: true");
|
|
40
|
+
});
|
|
41
|
+
(0, import_experimental_ct_react.test)("Should detect no overflow when content fits within container", async ({ mount, page }) => {
|
|
42
|
+
import_experimental_ct_react.test.setTimeout(2e4);
|
|
43
|
+
await mount(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DSHooksIsOverflowingTestRenderer.DSHooksIsOverflowingTestRenderer, {}));
|
|
44
|
+
const container = page.locator(containerSelector);
|
|
45
|
+
await container.waitFor({ state: "attached" });
|
|
46
|
+
await container.evaluate((node) => {
|
|
47
|
+
node.style.width = "500px";
|
|
48
|
+
});
|
|
49
|
+
await (0, import_experimental_ct_react.expect)(page.locator(overflowStateSelector)).toContainText("Overflowing: false");
|
|
50
|
+
});
|
|
51
|
+
(0, import_experimental_ct_react.test)("Should update overflow state dynamically when container size changes", async ({ mount, page }) => {
|
|
52
|
+
import_experimental_ct_react.test.setTimeout(2e4);
|
|
53
|
+
await mount(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DSHooksIsOverflowingTestRenderer.DSHooksIsOverflowingTestRenderer, {}));
|
|
54
|
+
const container = page.locator(containerSelector);
|
|
55
|
+
await container.waitFor({ state: "attached" });
|
|
56
|
+
await container.evaluate((node) => {
|
|
57
|
+
node.style.width = "500px";
|
|
58
|
+
});
|
|
59
|
+
await (0, import_experimental_ct_react.expect)(page.locator(overflowStateSelector)).toContainText("Overflowing: false");
|
|
60
|
+
await container.evaluate((node) => {
|
|
61
|
+
node.style.width = "100px";
|
|
62
|
+
});
|
|
63
|
+
await (0, import_experimental_ct_react.expect)(page.locator(overflowStateSelector)).toContainText("Overflowing: true");
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=DSHooksIsOverflowing.overflow.test.playwright.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/overflow/DSHooksIsOverflowing.overflow.test.playwright.jsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { expect, test } from '@playwright/experimental-ct-react';\nimport { DSHooksIsOverflowingTestRenderer } from './DSHooksIsOverflowingTestRenderer';\n\nconst containerSelector = '[data-testid=\"container\"]';\nconst overflowStateSelector = '[data-testid=\"overflow-state\"]';\n\ntest.describe('DSHooksIsOverflowingTestRenderer - Overflow Behavior', () => {\n test('Should detect overflow when content exceeds container width', async ({ mount, page }) => {\n test.setTimeout(20000);\n await mount(<DSHooksIsOverflowingTestRenderer />);\n const container = page.locator(containerSelector);\n await container.waitFor({ state: 'attached' });\n\n await container.evaluate((node) => {\n node.style.width = '100px';\n });\n\n await expect(page.locator(overflowStateSelector)).toContainText('Overflowing: true');\n });\n\n test('Should detect no overflow when content fits within container', async ({ mount, page }) => {\n test.setTimeout(20000);\n await mount(<DSHooksIsOverflowingTestRenderer />);\n const container = page.locator(containerSelector);\n await container.waitFor({ state: 'attached' });\n\n await container.evaluate((node) => {\n node.style.width = '500px';\n });\n\n await expect(page.locator(overflowStateSelector)).toContainText('Overflowing: false');\n });\n\n test('Should update overflow state dynamically when container size changes', async ({ mount, page }) => {\n test.setTimeout(20000);\n await mount(<DSHooksIsOverflowingTestRenderer />);\n const container = page.locator(containerSelector);\n await container.waitFor({ state: 'attached' });\n\n await container.evaluate((node) => {\n node.style.width = '500px';\n });\n await expect(page.locator(overflowStateSelector)).toContainText('Overflowing: false');\n\n await container.evaluate((node) => {\n node.style.width = '100px';\n });\n await expect(page.locator(overflowStateSelector)).toContainText('Overflowing: true');\n });\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,YAAuB;ACSP;AAThB,mCAA6B;AAC7B,8CAAiD;AAEjD,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAE9B,kCAAK,SAAS,wDAAwD,MAAM;AAC1E,yCAAK,+DAA+D,OAAO,EAAE,OAAO,KAAK,MAAM;AAC7F,sCAAK,WAAW,GAAK;AACrB,UAAM,MAAM,4CAAC,4EAAiC,CAAE;AAChD,UAAM,YAAY,KAAK,QAAQ,iBAAiB;AAChD,UAAM,UAAU,QAAQ,EAAE,OAAO,WAAW,CAAC;AAE7C,UAAM,UAAU,SAAS,CAAC,SAAS;AACjC,WAAK,MAAM,QAAQ;AAAA,IACrB,CAAC;AAED,cAAM,qCAAO,KAAK,QAAQ,qBAAqB,CAAC,EAAE,cAAc,mBAAmB;AAAA,EACrF,CAAC;AAED,yCAAK,gEAAgE,OAAO,EAAE,OAAO,KAAK,MAAM;AAC9F,sCAAK,WAAW,GAAK;AACrB,UAAM,MAAM,4CAAC,4EAAiC,CAAE;AAChD,UAAM,YAAY,KAAK,QAAQ,iBAAiB;AAChD,UAAM,UAAU,QAAQ,EAAE,OAAO,WAAW,CAAC;AAE7C,UAAM,UAAU,SAAS,CAAC,SAAS;AACjC,WAAK,MAAM,QAAQ;AAAA,IACrB,CAAC;AAED,cAAM,qCAAO,KAAK,QAAQ,qBAAqB,CAAC,EAAE,cAAc,oBAAoB;AAAA,EACtF,CAAC;AAED,yCAAK,wEAAwE,OAAO,EAAE,OAAO,KAAK,MAAM;AACtG,sCAAK,WAAW,GAAK;AACrB,UAAM,MAAM,4CAAC,4EAAiC,CAAE;AAChD,UAAM,YAAY,KAAK,QAAQ,iBAAiB;AAChD,UAAM,UAAU,QAAQ,EAAE,OAAO,WAAW,CAAC;AAE7C,UAAM,UAAU,SAAS,CAAC,SAAS;AACjC,WAAK,MAAM,QAAQ;AAAA,IACrB,CAAC;AACD,cAAM,qCAAO,KAAK,QAAQ,qBAAqB,CAAC,EAAE,cAAc,oBAAoB;AAEpF,UAAM,UAAU,SAAS,CAAC,SAAS;AACjC,WAAK,MAAM,QAAQ;AAAA,IACrB,CAAC;AACD,cAAM,qCAAO,KAAK,QAAQ,qBAAqB,CAAC,EAAE,cAAc,mBAAmB;AAAA,EACrF,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 DSHooksIsOverflowingTestRenderer_exports = {};
|
|
30
|
+
__export(DSHooksIsOverflowingTestRenderer_exports, {
|
|
31
|
+
DSHooksIsOverflowingTestRenderer: () => DSHooksIsOverflowingTestRenderer
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(DSHooksIsOverflowingTestRenderer_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_ds_hooks_on_overflow_change = require("@elliemae/ds-hooks-on-overflow-change");
|
|
38
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
39
|
+
const DSHooksIsOverflowingTestRenderer = (0, import_ds_system.themeProviderHOC)(() => {
|
|
40
|
+
const [isOverflowing, setIsOverflowing] = (0, import_react.useState)(false);
|
|
41
|
+
const { handleRef } = (0, import_ds_hooks_on_overflow_change.useOnOverflowChange)({
|
|
42
|
+
onOverflowStateChange: setIsOverflowing
|
|
43
|
+
});
|
|
44
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-testid": "overflow-state", children: [
|
|
46
|
+
"Overflowing: ",
|
|
47
|
+
isOverflowing ? "true" : "false"
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
"data-testid": "container",
|
|
53
|
+
ref: handleRef,
|
|
54
|
+
style: {
|
|
55
|
+
whiteSpace: "nowrap",
|
|
56
|
+
overflow: "hidden",
|
|
57
|
+
textOverflow: "ellipsis",
|
|
58
|
+
background: "rgba(30, 121, 194, 0.2)",
|
|
59
|
+
padding: "10px"
|
|
60
|
+
},
|
|
61
|
+
children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod."
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] });
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=DSHooksIsOverflowingTestRenderer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/tests/overflow/DSHooksIsOverflowingTestRenderer.jsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useState } from 'react';\nimport { useOnOverflowChange } from '@elliemae/ds-hooks-on-overflow-change';\nimport { themeProviderHOC } from '@elliemae/ds-system';\n\nexport const DSHooksIsOverflowingTestRenderer = themeProviderHOC(() => {\n const [isOverflowing, setIsOverflowing] = useState(false);\n\n const { handleRef } = useOnOverflowChange({\n onOverflowStateChange: setIsOverflowing,\n });\n\n return (\n <div>\n <div data-testid=\"overflow-state\">Overflowing: {isOverflowing ? 'true' : 'false'}</div>\n <div\n data-testid=\"container\"\n ref={handleRef}\n style={{\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n background: 'rgba(30, 121, 194, 0.2)',\n padding: '10px',\n }}\n >\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.\n </div>\n </div>\n );\n});\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADajB;AAbN,mBAAgC;AAChC,yCAAoC;AACpC,uBAAiC;AAE1B,MAAM,uCAAmC,mCAAiB,MAAM;AACrE,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAAS,KAAK;AAExD,QAAM,EAAE,UAAU,QAAI,wDAAoB;AAAA,IACxC,uBAAuB;AAAA,EACzB,CAAC;AAED,SACE,6CAAC,SACC;AAAA,iDAAC,SAAI,eAAY,kBAAiB;AAAA;AAAA,MAAc,gBAAgB,SAAS;AAAA,OAAQ;AAAA,IACjF;AAAA,MAAC;AAAA;AAAA,QACC,eAAY;AAAA,QACZ,KAAK;AAAA,QACL,OAAO;AAAA,UACL,YAAY;AAAA,UACZ,UAAU;AAAA,UACV,cAAc;AAAA,UACd,YAAY;AAAA,UACZ,SAAS;AAAA,QACX;AAAA,QACD;AAAA;AAAA,IAED;AAAA,KACF;AAEJ,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 typescript_on_overflow_change_exports = {};
|
|
30
|
+
__export(typescript_on_overflow_change_exports, {
|
|
31
|
+
default: () => typescript_on_overflow_change_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(typescript_on_overflow_change_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_DSHooksIsOverflowing = require("../DSHooksIsOverflowing");
|
|
37
|
+
const TestComponent = ({ onOverflowStateChange }) => {
|
|
38
|
+
const { handleRef } = (0, import_DSHooksIsOverflowing.useOnOverflowChange)({ onOverflowStateChange });
|
|
39
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
"data-testid": "container",
|
|
43
|
+
ref: (node) => {
|
|
44
|
+
if (node) {
|
|
45
|
+
handleRef(node);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
style: {
|
|
49
|
+
width: "100px",
|
|
50
|
+
overflow: "hidden",
|
|
51
|
+
whiteSpace: "nowrap"
|
|
52
|
+
},
|
|
53
|
+
children: "This is long text that should overflow the container."
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
const testExplicitDefinition = {
|
|
58
|
+
onOverflowStateChange: (isOverflowing) => console.log(`Overflow state: ${isOverflowing}`)
|
|
59
|
+
};
|
|
60
|
+
const testInferredTypeCompatibility = {
|
|
61
|
+
onOverflowStateChange: (isOverflowing) => console.log(`Overflow state: ${isOverflowing}`)
|
|
62
|
+
};
|
|
63
|
+
const testDefinitionAsConst = {
|
|
64
|
+
onOverflowStateChange: (isOverflowing) => console.log(`Overflow state: ${isOverflowing}`)
|
|
65
|
+
};
|
|
66
|
+
const ExampleUsageComponent = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TestComponent, { ...testExplicitDefinition }),
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TestComponent, { ...testInferredTypeCompatibility }),
|
|
69
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TestComponent, { ...testDefinitionAsConst }),
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TestComponent, { onOverflowStateChange: (isOverflowing) => console.log(`Inline overflow state: ${isOverflowing}`) })
|
|
71
|
+
] });
|
|
72
|
+
var typescript_on_overflow_change_default = ExampleUsageComponent;
|
|
73
|
+
//# sourceMappingURL=typescript-on-overflow-change.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/typescript-testing/typescript-on-overflow-change.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\n// eslint-disable-next-line local-rules/custom-rule\nimport { useOnOverflowChange } from '../DSHooksIsOverflowing';\n\ntype TestComponentProps = {\n onOverflowStateChange: (isOverflowing: boolean) => void;\n};\n\nconst TestComponent: React.FC<TestComponentProps> = ({ onOverflowStateChange }) => {\n const { handleRef } = useOnOverflowChange({ onOverflowStateChange });\n\n return (\n <div\n data-testid=\"container\"\n ref={(node) => {\n if (node) {\n handleRef(node);\n }\n }}\n style={{\n width: '100px',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n }}\n >\n This is long text that should overflow the container.\n </div>\n );\n};\n\nconst testExplicitDefinition: TestComponentProps = {\n onOverflowStateChange: (isOverflowing) => console.log(`Overflow state: ${isOverflowing}`),\n};\n\nconst testInferredTypeCompatibility = {\n onOverflowStateChange: (isOverflowing: boolean) => console.log(`Overflow state: ${isOverflowing}`),\n} as TestComponentProps;\n\nconst testDefinitionAsConst = {\n onOverflowStateChange: (isOverflowing: boolean) => console.log(`Overflow state: ${isOverflowing}`),\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* Works with explicitly casted props */}\n <TestComponent {...testExplicitDefinition} />\n <TestComponent {...testInferredTypeCompatibility} />\n <TestComponent {...testDefinitionAsConst} />\n\n {/* Inline props test */}\n <TestComponent onOverflowStateChange={(isOverflowing) => console.log(`Inline overflow state: ${isOverflowing}`)} />\n </>\n);\n\nexport default ExampleUsageComponent;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADYnB;AAVJ,kCAAoC;AAMpC,MAAM,gBAA8C,CAAC,EAAE,sBAAsB,MAAM;AACjF,QAAM,EAAE,UAAU,QAAI,iDAAoB,EAAE,sBAAsB,CAAC;AAEnE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAY;AAAA,MACZ,KAAK,CAAC,SAAS;AACb,YAAI,MAAM;AACR,oBAAU,IAAI;AAAA,QAChB;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,MACd;AAAA,MACD;AAAA;AAAA,EAED;AAEJ;AAEA,MAAM,yBAA6C;AAAA,EACjD,uBAAuB,CAAC,kBAAkB,QAAQ,IAAI,mBAAmB,aAAa,EAAE;AAC1F;AAEA,MAAM,gCAAgC;AAAA,EACpC,uBAAuB,CAAC,kBAA2B,QAAQ,IAAI,mBAAmB,aAAa,EAAE;AACnG;AAEA,MAAM,wBAAwB;AAAA,EAC5B,uBAAuB,CAAC,kBAA2B,QAAQ,IAAI,mBAAmB,aAAa,EAAE;AACnG;AAEA,MAAM,wBAAwB,MAC5B,4EAEE;AAAA,8CAAC,iBAAe,GAAG,wBAAwB;AAAA,EAC3C,4CAAC,iBAAe,GAAG,+BAA+B;AAAA,EAClD,4CAAC,iBAAe,GAAG,uBAAuB;AAAA,EAG1C,4CAAC,iBAAc,uBAAuB,CAAC,kBAAkB,QAAQ,IAAI,0BAA0B,aAAa,EAAE,GAAG;AAAA,GACnH;AAGF,IAAO,wCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useRef, useEffect, useMemo } from "react";
|
|
3
|
+
import { describe } from "@elliemae/ds-props-helpers";
|
|
4
|
+
import {
|
|
5
|
+
UseOnOverflowChangeTPropTypes,
|
|
6
|
+
UseOnOverflowChangeTReturnType
|
|
7
|
+
} from "./react-desc-prop-types.js";
|
|
8
|
+
const isOverflowing = (node) => node.offsetWidth < node.scrollWidth;
|
|
9
|
+
const useOnOverflowChange = ({
|
|
10
|
+
onOverflowStateChange
|
|
11
|
+
}) => {
|
|
12
|
+
const nodeForComparison = useRef(null);
|
|
13
|
+
const resizeObserver = useRef(null);
|
|
14
|
+
const previousOverflowState = useRef(null);
|
|
15
|
+
const onResizeNotifier = useCallback(
|
|
16
|
+
(node) => {
|
|
17
|
+
const isTruncating = isOverflowing(node);
|
|
18
|
+
if (previousOverflowState.current !== isTruncating) {
|
|
19
|
+
onOverflowStateChange(isTruncating);
|
|
20
|
+
previousOverflowState.current = isTruncating;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
[onOverflowStateChange]
|
|
24
|
+
);
|
|
25
|
+
const handleRef = useCallback(
|
|
26
|
+
(node) => {
|
|
27
|
+
if (node) {
|
|
28
|
+
onResizeNotifier(node);
|
|
29
|
+
const didNodeChange = nodeForComparison.current !== node;
|
|
30
|
+
if (didNodeChange) {
|
|
31
|
+
if (resizeObserver.current) {
|
|
32
|
+
resizeObserver.current.disconnect();
|
|
33
|
+
}
|
|
34
|
+
resizeObserver.current = new ResizeObserver(() => {
|
|
35
|
+
onResizeNotifier(node);
|
|
36
|
+
});
|
|
37
|
+
resizeObserver.current.observe(node);
|
|
38
|
+
nodeForComparison.current = node;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
[onResizeNotifier]
|
|
43
|
+
);
|
|
44
|
+
useEffect(
|
|
45
|
+
() => () => {
|
|
46
|
+
if (resizeObserver.current) {
|
|
47
|
+
resizeObserver.current.disconnect();
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[]
|
|
51
|
+
);
|
|
52
|
+
return useMemo(() => ({ handleRef }), [handleRef]);
|
|
53
|
+
};
|
|
54
|
+
useOnOverflowChange.displayName = "useOnOverflowChange";
|
|
55
|
+
const useOnOverflowChangeWithSchema = describe(useOnOverflowChange);
|
|
56
|
+
useOnOverflowChangeWithSchema.propTypes = UseOnOverflowChangeTPropTypes;
|
|
57
|
+
useOnOverflowChangeWithSchema.returnType = UseOnOverflowChangeTReturnType;
|
|
58
|
+
export {
|
|
59
|
+
useOnOverflowChange,
|
|
60
|
+
useOnOverflowChangeWithSchema
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=DSHooksIsOverflowing.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/DSHooksIsOverflowing.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\nimport React, { useCallback, useRef, useEffect, useMemo } from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport {\n type DSHooksUseOnOverflowChangeT,\n UseOnOverflowChangeTPropTypes,\n UseOnOverflowChangeTReturnType,\n} from './react-desc-prop-types.js';\n\nconst isOverflowing = (node: HTMLElement) => node.offsetWidth < node.scrollWidth;\n\nconst useOnOverflowChange: DSHooksUseOnOverflowChangeT.UseOnOverflowChange & { displayName: string } = ({\n onOverflowStateChange,\n}) => {\n const nodeForComparison = useRef<HTMLElement | null>(null);\n const resizeObserver = useRef<ResizeObserver | null>(null);\n const previousOverflowState = useRef<boolean | null>(null);\n\n const onResizeNotifier = useCallback(\n (node: HTMLElement) => {\n const isTruncating = isOverflowing(node);\n\n if (previousOverflowState.current !== isTruncating) {\n onOverflowStateChange(isTruncating);\n previousOverflowState.current = isTruncating;\n }\n },\n [onOverflowStateChange],\n );\n\n const handleRef = useCallback(\n (node: HTMLElement | null) => {\n if (node) {\n onResizeNotifier(node);\n\n const didNodeChange = nodeForComparison.current !== node;\n if (didNodeChange) {\n if (resizeObserver.current) {\n resizeObserver.current.disconnect();\n }\n\n resizeObserver.current = new ResizeObserver(() => {\n onResizeNotifier(node);\n });\n resizeObserver.current.observe(node);\n\n nodeForComparison.current = node;\n }\n }\n },\n [onResizeNotifier],\n );\n\n useEffect(\n () => () => {\n if (resizeObserver.current) {\n resizeObserver.current.disconnect();\n }\n },\n [],\n );\n\n return useMemo(() => ({ handleRef }), [handleRef]);\n};\n\nuseOnOverflowChange.displayName = 'useOnOverflowChange';\n\nconst useOnOverflowChangeWithSchema = describe(useOnOverflowChange);\n\nuseOnOverflowChangeWithSchema.propTypes = UseOnOverflowChangeTPropTypes;\nuseOnOverflowChangeWithSchema.returnType = UseOnOverflowChangeTReturnType;\n\nexport { useOnOverflowChange, useOnOverflowChangeWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAgB,aAAa,QAAQ,WAAW,eAAe;AAC/D,SAAS,gBAAgB;AACzB;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAEP,MAAM,gBAAgB,CAAC,SAAsB,KAAK,cAAc,KAAK;AAErE,MAAM,sBAAiG,CAAC;AAAA,EACtG;AACF,MAAM;AACJ,QAAM,oBAAoB,OAA2B,IAAI;AACzD,QAAM,iBAAiB,OAA8B,IAAI;AACzD,QAAM,wBAAwB,OAAuB,IAAI;AAEzD,QAAM,mBAAmB;AAAA,IACvB,CAAC,SAAsB;AACrB,YAAM,eAAe,cAAc,IAAI;AAEvC,UAAI,sBAAsB,YAAY,cAAc;AAClD,8BAAsB,YAAY;AAClC,8BAAsB,UAAU;AAAA,MAClC;AAAA,IACF;AAAA,IACA,CAAC,qBAAqB;AAAA,EACxB;AAEA,QAAM,YAAY;AAAA,IAChB,CAAC,SAA6B;AAC5B,UAAI,MAAM;AACR,yBAAiB,IAAI;AAErB,cAAM,gBAAgB,kBAAkB,YAAY;AACpD,YAAI,eAAe;AACjB,cAAI,eAAe,SAAS;AAC1B,2BAAe,QAAQ,WAAW;AAAA,UACpC;AAEA,yBAAe,UAAU,IAAI,eAAe,MAAM;AAChD,6BAAiB,IAAI;AAAA,UACvB,CAAC;AACD,yBAAe,QAAQ,QAAQ,IAAI;AAEnC,4BAAkB,UAAU;AAAA,QAC9B;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,gBAAgB;AAAA,EACnB;AAEA;AAAA,IACE,MAAM,MAAM;AACV,UAAI,eAAe,SAAS;AAC1B,uBAAe,QAAQ,WAAW;AAAA,MACpC;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO,QAAQ,OAAO,EAAE,UAAU,IAAI,CAAC,SAAS,CAAC;AACnD;AAEA,oBAAoB,cAAc;AAElC,MAAM,gCAAgC,SAAS,mBAAmB;AAElE,8BAA8B,YAAY;AAC1C,8BAA8B,aAAa;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { useOnOverflowChange, useOnOverflowChangeWithSchema } from './DSHooksIsOverflowing.js';\nexport { type DSHooksUseOnOverflowChangeT } from './react-desc-prop-types.js';\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB,qCAAqC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "@elliemae/ds-props-helpers";
|
|
3
|
+
const UseOnOverflowChangeTPropTypes = {
|
|
4
|
+
onOverflowStateChange: PropTypes.func.description(
|
|
5
|
+
"Callback function triggered when the overflow state changes. Receives a boolean indicating whether the content is overflowing."
|
|
6
|
+
).isRequired
|
|
7
|
+
};
|
|
8
|
+
const UseOnOverflowChangeTReturnType = {
|
|
9
|
+
handleRef: PropTypes.func.description(
|
|
10
|
+
"Function to be passed as a ref to the element being monitored for overflow changes."
|
|
11
|
+
).isRequired
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
UseOnOverflowChangeTPropTypes,
|
|
15
|
+
UseOnOverflowChangeTReturnType
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { WeakValidationMap } from 'react';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSHooksUseOnOverflowChangeT {\n export interface Arguments {\n onOverflowStateChange: (isOverflowing: boolean) => void;\n }\n\n export interface ResultType {\n handleRef: (node: HTMLElement | null) => void;\n }\n\n export type UseOnOverflowChange = (args: Arguments) => ResultType;\n}\n\nexport const UseOnOverflowChangeTPropTypes = {\n onOverflowStateChange: PropTypes.func.description(\n 'Callback function triggered when the overflow state changes. Receives a boolean indicating whether the content is overflowing.',\n ).isRequired,\n} as WeakValidationMap<unknown>;\n\nexport const UseOnOverflowChangeTReturnType = {\n handleRef: PropTypes.func.description(\n 'Function to be passed as a ref to the element being monitored for overflow changes.',\n ).isRequired,\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,iBAAiB;AAcnB,MAAM,gCAAgC;AAAA,EAC3C,uBAAuB,UAAU,KAAK;AAAA,IACpC;AAAA,EACF,EAAE;AACJ;AAEO,MAAM,iCAAiC;AAAA,EAC5C,WAAW,UAAU,KAAK;AAAA,IACxB;AAAA,EACF,EAAE;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { expect, test } from "@playwright/experimental-ct-react";
|
|
4
|
+
import { DSHooksIsOverflowingTestRenderer } from "./DSHooksIsOverflowingTestRenderer";
|
|
5
|
+
const containerSelector = '[data-testid="container"]';
|
|
6
|
+
const overflowStateSelector = '[data-testid="overflow-state"]';
|
|
7
|
+
test.describe("DSHooksIsOverflowingTestRenderer - Overflow Behavior", () => {
|
|
8
|
+
test("Should detect overflow when content exceeds container width", async ({ mount, page }) => {
|
|
9
|
+
test.setTimeout(2e4);
|
|
10
|
+
await mount(/* @__PURE__ */ jsx(DSHooksIsOverflowingTestRenderer, {}));
|
|
11
|
+
const container = page.locator(containerSelector);
|
|
12
|
+
await container.waitFor({ state: "attached" });
|
|
13
|
+
await container.evaluate((node) => {
|
|
14
|
+
node.style.width = "100px";
|
|
15
|
+
});
|
|
16
|
+
await expect(page.locator(overflowStateSelector)).toContainText("Overflowing: true");
|
|
17
|
+
});
|
|
18
|
+
test("Should detect no overflow when content fits within container", async ({ mount, page }) => {
|
|
19
|
+
test.setTimeout(2e4);
|
|
20
|
+
await mount(/* @__PURE__ */ jsx(DSHooksIsOverflowingTestRenderer, {}));
|
|
21
|
+
const container = page.locator(containerSelector);
|
|
22
|
+
await container.waitFor({ state: "attached" });
|
|
23
|
+
await container.evaluate((node) => {
|
|
24
|
+
node.style.width = "500px";
|
|
25
|
+
});
|
|
26
|
+
await expect(page.locator(overflowStateSelector)).toContainText("Overflowing: false");
|
|
27
|
+
});
|
|
28
|
+
test("Should update overflow state dynamically when container size changes", async ({ mount, page }) => {
|
|
29
|
+
test.setTimeout(2e4);
|
|
30
|
+
await mount(/* @__PURE__ */ jsx(DSHooksIsOverflowingTestRenderer, {}));
|
|
31
|
+
const container = page.locator(containerSelector);
|
|
32
|
+
await container.waitFor({ state: "attached" });
|
|
33
|
+
await container.evaluate((node) => {
|
|
34
|
+
node.style.width = "500px";
|
|
35
|
+
});
|
|
36
|
+
await expect(page.locator(overflowStateSelector)).toContainText("Overflowing: false");
|
|
37
|
+
await container.evaluate((node) => {
|
|
38
|
+
node.style.width = "100px";
|
|
39
|
+
});
|
|
40
|
+
await expect(page.locator(overflowStateSelector)).toContainText("Overflowing: true");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=DSHooksIsOverflowing.overflow.test.playwright.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/overflow/DSHooksIsOverflowing.overflow.test.playwright.jsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { expect, test } from '@playwright/experimental-ct-react';\nimport { DSHooksIsOverflowingTestRenderer } from './DSHooksIsOverflowingTestRenderer';\n\nconst containerSelector = '[data-testid=\"container\"]';\nconst overflowStateSelector = '[data-testid=\"overflow-state\"]';\n\ntest.describe('DSHooksIsOverflowingTestRenderer - Overflow Behavior', () => {\n test('Should detect overflow when content exceeds container width', async ({ mount, page }) => {\n test.setTimeout(20000);\n await mount(<DSHooksIsOverflowingTestRenderer />);\n const container = page.locator(containerSelector);\n await container.waitFor({ state: 'attached' });\n\n await container.evaluate((node) => {\n node.style.width = '100px';\n });\n\n await expect(page.locator(overflowStateSelector)).toContainText('Overflowing: true');\n });\n\n test('Should detect no overflow when content fits within container', async ({ mount, page }) => {\n test.setTimeout(20000);\n await mount(<DSHooksIsOverflowingTestRenderer />);\n const container = page.locator(containerSelector);\n await container.waitFor({ state: 'attached' });\n\n await container.evaluate((node) => {\n node.style.width = '500px';\n });\n\n await expect(page.locator(overflowStateSelector)).toContainText('Overflowing: false');\n });\n\n test('Should update overflow state dynamically when container size changes', async ({ mount, page }) => {\n test.setTimeout(20000);\n await mount(<DSHooksIsOverflowingTestRenderer />);\n const container = page.locator(containerSelector);\n await container.waitFor({ state: 'attached' });\n\n await container.evaluate((node) => {\n node.style.width = '500px';\n });\n await expect(page.locator(overflowStateSelector)).toContainText('Overflowing: false');\n\n await container.evaluate((node) => {\n node.style.width = '100px';\n });\n await expect(page.locator(overflowStateSelector)).toContainText('Overflowing: true');\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACSP;AAThB,SAAS,QAAQ,YAAY;AAC7B,SAAS,wCAAwC;AAEjD,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAE9B,KAAK,SAAS,wDAAwD,MAAM;AAC1E,OAAK,+DAA+D,OAAO,EAAE,OAAO,KAAK,MAAM;AAC7F,SAAK,WAAW,GAAK;AACrB,UAAM,MAAM,oBAAC,oCAAiC,CAAE;AAChD,UAAM,YAAY,KAAK,QAAQ,iBAAiB;AAChD,UAAM,UAAU,QAAQ,EAAE,OAAO,WAAW,CAAC;AAE7C,UAAM,UAAU,SAAS,CAAC,SAAS;AACjC,WAAK,MAAM,QAAQ;AAAA,IACrB,CAAC;AAED,UAAM,OAAO,KAAK,QAAQ,qBAAqB,CAAC,EAAE,cAAc,mBAAmB;AAAA,EACrF,CAAC;AAED,OAAK,gEAAgE,OAAO,EAAE,OAAO,KAAK,MAAM;AAC9F,SAAK,WAAW,GAAK;AACrB,UAAM,MAAM,oBAAC,oCAAiC,CAAE;AAChD,UAAM,YAAY,KAAK,QAAQ,iBAAiB;AAChD,UAAM,UAAU,QAAQ,EAAE,OAAO,WAAW,CAAC;AAE7C,UAAM,UAAU,SAAS,CAAC,SAAS;AACjC,WAAK,MAAM,QAAQ;AAAA,IACrB,CAAC;AAED,UAAM,OAAO,KAAK,QAAQ,qBAAqB,CAAC,EAAE,cAAc,oBAAoB;AAAA,EACtF,CAAC;AAED,OAAK,wEAAwE,OAAO,EAAE,OAAO,KAAK,MAAM;AACtG,SAAK,WAAW,GAAK;AACrB,UAAM,MAAM,oBAAC,oCAAiC,CAAE;AAChD,UAAM,YAAY,KAAK,QAAQ,iBAAiB;AAChD,UAAM,UAAU,QAAQ,EAAE,OAAO,WAAW,CAAC;AAE7C,UAAM,UAAU,SAAS,CAAC,SAAS;AACjC,WAAK,MAAM,QAAQ;AAAA,IACrB,CAAC;AACD,UAAM,OAAO,KAAK,QAAQ,qBAAqB,CAAC,EAAE,cAAc,oBAAoB;AAEpF,UAAM,UAAU,SAAS,CAAC,SAAS;AACjC,WAAK,MAAM,QAAQ;AAAA,IACrB,CAAC;AACD,UAAM,OAAO,KAAK,QAAQ,qBAAqB,CAAC,EAAE,cAAc,mBAAmB;AAAA,EACrF,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import React2, { useState } from "react";
|
|
4
|
+
import { useOnOverflowChange } from "@elliemae/ds-hooks-on-overflow-change";
|
|
5
|
+
import { themeProviderHOC } from "@elliemae/ds-system";
|
|
6
|
+
const DSHooksIsOverflowingTestRenderer = themeProviderHOC(() => {
|
|
7
|
+
const [isOverflowing, setIsOverflowing] = useState(false);
|
|
8
|
+
const { handleRef } = useOnOverflowChange({
|
|
9
|
+
onOverflowStateChange: setIsOverflowing
|
|
10
|
+
});
|
|
11
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
12
|
+
/* @__PURE__ */ jsxs("div", { "data-testid": "overflow-state", children: [
|
|
13
|
+
"Overflowing: ",
|
|
14
|
+
isOverflowing ? "true" : "false"
|
|
15
|
+
] }),
|
|
16
|
+
/* @__PURE__ */ jsx(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
"data-testid": "container",
|
|
20
|
+
ref: handleRef,
|
|
21
|
+
style: {
|
|
22
|
+
whiteSpace: "nowrap",
|
|
23
|
+
overflow: "hidden",
|
|
24
|
+
textOverflow: "ellipsis",
|
|
25
|
+
background: "rgba(30, 121, 194, 0.2)",
|
|
26
|
+
padding: "10px"
|
|
27
|
+
},
|
|
28
|
+
children: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod."
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
] });
|
|
32
|
+
});
|
|
33
|
+
export {
|
|
34
|
+
DSHooksIsOverflowingTestRenderer
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=DSHooksIsOverflowingTestRenderer.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/tests/overflow/DSHooksIsOverflowingTestRenderer.jsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState } from 'react';\nimport { useOnOverflowChange } from '@elliemae/ds-hooks-on-overflow-change';\nimport { themeProviderHOC } from '@elliemae/ds-system';\n\nexport const DSHooksIsOverflowingTestRenderer = themeProviderHOC(() => {\n const [isOverflowing, setIsOverflowing] = useState(false);\n\n const { handleRef } = useOnOverflowChange({\n onOverflowStateChange: setIsOverflowing,\n });\n\n return (\n <div>\n <div data-testid=\"overflow-state\">Overflowing: {isOverflowing ? 'true' : 'false'}</div>\n <div\n data-testid=\"container\"\n ref={handleRef}\n style={{\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n background: 'rgba(30, 121, 194, 0.2)',\n padding: '10px',\n }}\n >\n Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.\n </div>\n </div>\n );\n});\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACajB,SACA,KADA;AAbN,OAAOA,UAAS,gBAAgB;AAChC,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AAE1B,MAAM,mCAAmC,iBAAiB,MAAM;AACrE,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,KAAK;AAExD,QAAM,EAAE,UAAU,IAAI,oBAAoB;AAAA,IACxC,uBAAuB;AAAA,EACzB,CAAC;AAED,SACE,qBAAC,SACC;AAAA,yBAAC,SAAI,eAAY,kBAAiB;AAAA;AAAA,MAAc,gBAAgB,SAAS;AAAA,OAAQ;AAAA,IACjF;AAAA,MAAC;AAAA;AAAA,QACC,eAAY;AAAA,QACZ,KAAK;AAAA,QACL,OAAO;AAAA,UACL,YAAY;AAAA,UACZ,UAAU;AAAA,UACV,cAAc;AAAA,UACd,YAAY;AAAA,UACZ,SAAS;AAAA,QACX;AAAA,QACD;AAAA;AAAA,IAED;AAAA,KACF;AAEJ,CAAC;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useOnOverflowChange } from "../DSHooksIsOverflowing";
|
|
4
|
+
const TestComponent = ({ onOverflowStateChange }) => {
|
|
5
|
+
const { handleRef } = useOnOverflowChange({ onOverflowStateChange });
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"div",
|
|
8
|
+
{
|
|
9
|
+
"data-testid": "container",
|
|
10
|
+
ref: (node) => {
|
|
11
|
+
if (node) {
|
|
12
|
+
handleRef(node);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
style: {
|
|
16
|
+
width: "100px",
|
|
17
|
+
overflow: "hidden",
|
|
18
|
+
whiteSpace: "nowrap"
|
|
19
|
+
},
|
|
20
|
+
children: "This is long text that should overflow the container."
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
const testExplicitDefinition = {
|
|
25
|
+
onOverflowStateChange: (isOverflowing) => console.log(`Overflow state: ${isOverflowing}`)
|
|
26
|
+
};
|
|
27
|
+
const testInferredTypeCompatibility = {
|
|
28
|
+
onOverflowStateChange: (isOverflowing) => console.log(`Overflow state: ${isOverflowing}`)
|
|
29
|
+
};
|
|
30
|
+
const testDefinitionAsConst = {
|
|
31
|
+
onOverflowStateChange: (isOverflowing) => console.log(`Overflow state: ${isOverflowing}`)
|
|
32
|
+
};
|
|
33
|
+
const ExampleUsageComponent = () => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
34
|
+
/* @__PURE__ */ jsx(TestComponent, { ...testExplicitDefinition }),
|
|
35
|
+
/* @__PURE__ */ jsx(TestComponent, { ...testInferredTypeCompatibility }),
|
|
36
|
+
/* @__PURE__ */ jsx(TestComponent, { ...testDefinitionAsConst }),
|
|
37
|
+
/* @__PURE__ */ jsx(TestComponent, { onOverflowStateChange: (isOverflowing) => console.log(`Inline overflow state: ${isOverflowing}`) })
|
|
38
|
+
] });
|
|
39
|
+
var typescript_on_overflow_change_default = ExampleUsageComponent;
|
|
40
|
+
export {
|
|
41
|
+
typescript_on_overflow_change_default as default
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=typescript-on-overflow-change.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-on-overflow-change.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\n// eslint-disable-next-line local-rules/custom-rule\nimport { useOnOverflowChange } from '../DSHooksIsOverflowing';\n\ntype TestComponentProps = {\n onOverflowStateChange: (isOverflowing: boolean) => void;\n};\n\nconst TestComponent: React.FC<TestComponentProps> = ({ onOverflowStateChange }) => {\n const { handleRef } = useOnOverflowChange({ onOverflowStateChange });\n\n return (\n <div\n data-testid=\"container\"\n ref={(node) => {\n if (node) {\n handleRef(node);\n }\n }}\n style={{\n width: '100px',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n }}\n >\n This is long text that should overflow the container.\n </div>\n );\n};\n\nconst testExplicitDefinition: TestComponentProps = {\n onOverflowStateChange: (isOverflowing) => console.log(`Overflow state: ${isOverflowing}`),\n};\n\nconst testInferredTypeCompatibility = {\n onOverflowStateChange: (isOverflowing: boolean) => console.log(`Overflow state: ${isOverflowing}`),\n} as TestComponentProps;\n\nconst testDefinitionAsConst = {\n onOverflowStateChange: (isOverflowing: boolean) => console.log(`Overflow state: ${isOverflowing}`),\n} as const;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* Works with explicitly casted props */}\n <TestComponent {...testExplicitDefinition} />\n <TestComponent {...testInferredTypeCompatibility} />\n <TestComponent {...testDefinitionAsConst} />\n\n {/* Inline props test */}\n <TestComponent onOverflowStateChange={(isOverflowing) => console.log(`Inline overflow state: ${isOverflowing}`)} />\n </>\n);\n\nexport default ExampleUsageComponent;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACYnB,SA+BF,UA/BE,KA+BF,YA/BE;AAVJ,SAAS,2BAA2B;AAMpC,MAAM,gBAA8C,CAAC,EAAE,sBAAsB,MAAM;AACjF,QAAM,EAAE,UAAU,IAAI,oBAAoB,EAAE,sBAAsB,CAAC;AAEnE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,eAAY;AAAA,MACZ,KAAK,CAAC,SAAS;AACb,YAAI,MAAM;AACR,oBAAU,IAAI;AAAA,QAChB;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,OAAO;AAAA,QACP,UAAU;AAAA,QACV,YAAY;AAAA,MACd;AAAA,MACD;AAAA;AAAA,EAED;AAEJ;AAEA,MAAM,yBAA6C;AAAA,EACjD,uBAAuB,CAAC,kBAAkB,QAAQ,IAAI,mBAAmB,aAAa,EAAE;AAC1F;AAEA,MAAM,gCAAgC;AAAA,EACpC,uBAAuB,CAAC,kBAA2B,QAAQ,IAAI,mBAAmB,aAAa,EAAE;AACnG;AAEA,MAAM,wBAAwB;AAAA,EAC5B,uBAAuB,CAAC,kBAA2B,QAAQ,IAAI,mBAAmB,aAAa,EAAE;AACnG;AAEA,MAAM,wBAAwB,MAC5B,iCAEE;AAAA,sBAAC,iBAAe,GAAG,wBAAwB;AAAA,EAC3C,oBAAC,iBAAe,GAAG,+BAA+B;AAAA,EAClD,oBAAC,iBAAe,GAAG,uBAAuB;AAAA,EAG1C,oBAAC,iBAAc,uBAAuB,CAAC,kBAAkB,QAAQ,IAAI,0BAA0B,aAAa,EAAE,GAAG;AAAA,GACnH;AAGF,IAAO,wCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DSHooksUseOnOverflowChangeT } from './react-desc-prop-types.js';
|
|
2
|
+
declare const useOnOverflowChange: DSHooksUseOnOverflowChangeT.UseOnOverflowChange & {
|
|
3
|
+
displayName: string;
|
|
4
|
+
};
|
|
5
|
+
declare const useOnOverflowChangeWithSchema: import("@elliemae/ds-props-helpers/dist/types/propTypes/types.js").DocumentedReactComponent<DSHooksUseOnOverflowChangeT.Arguments>;
|
|
6
|
+
export { useOnOverflowChange, useOnOverflowChangeWithSchema };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WeakValidationMap } from 'react';
|
|
2
|
+
export declare namespace DSHooksUseOnOverflowChangeT {
|
|
3
|
+
interface Arguments {
|
|
4
|
+
onOverflowStateChange: (isOverflowing: boolean) => void;
|
|
5
|
+
}
|
|
6
|
+
interface ResultType {
|
|
7
|
+
handleRef: (node: HTMLElement | null) => void;
|
|
8
|
+
}
|
|
9
|
+
type UseOnOverflowChange = (args: Arguments) => ResultType;
|
|
10
|
+
}
|
|
11
|
+
export declare const UseOnOverflowChangeTPropTypes: WeakValidationMap<unknown>;
|
|
12
|
+
export declare const UseOnOverflowChangeTReturnType: {
|
|
13
|
+
handleRef: import("@elliemae/ds-props-helpers/dist/types/propTypes/types").ReactDescT;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elliemae/ds-hooks-on-overflow-change",
|
|
3
|
+
"version": "3.52.0-rc.25",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "ICE MT - Dimsum - Hooks Is Overflowing",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"main": "./dist/cjs/index.js",
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/types/index.d.ts",
|
|
15
|
+
"import": "./dist/esm/index.js",
|
|
16
|
+
"require": "./dist/cjs/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"*.css",
|
|
21
|
+
"*.scss"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://git.elliemae.io/platform-ui/dimsum.git"
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"pnpm": ">=9",
|
|
29
|
+
"node": ">=22"
|
|
30
|
+
},
|
|
31
|
+
"author": "ICE MT",
|
|
32
|
+
"jestSonar": {
|
|
33
|
+
"sonar56x": true,
|
|
34
|
+
"reportPath": "reports",
|
|
35
|
+
"reportFile": "tests.xml",
|
|
36
|
+
"indent": 4
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@xstyled/styled-components": "~3.7.3",
|
|
40
|
+
"@elliemae/ds-grid": "3.52.0-rc.25",
|
|
41
|
+
"@elliemae/ds-hooks-on-blur-out": "3.52.0-rc.25",
|
|
42
|
+
"@elliemae/ds-props-helpers": "3.52.0-rc.25",
|
|
43
|
+
"@elliemae/ds-system": "3.52.0-rc.25"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@elliemae/pui-cli": "9.0.0-next.63",
|
|
47
|
+
"@playwright/experimental-ct-react": "^1.51.1",
|
|
48
|
+
"jest": "~29.7.0",
|
|
49
|
+
"styled-components": "~5.3.9",
|
|
50
|
+
"@elliemae/ds-monorepo-devops": "3.52.0-rc.25",
|
|
51
|
+
"@elliemae/ds-typescript-helpers": "3.52.0-rc.25"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"@testing-library/jest-dom": "^6.6.3",
|
|
55
|
+
"@testing-library/react": "^16.0.1",
|
|
56
|
+
"@testing-library/user-event": "~14.5.2",
|
|
57
|
+
"react": "^18.3.1",
|
|
58
|
+
"react-dom": "^18.3.1",
|
|
59
|
+
"styled-components": "~5.3.9"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public",
|
|
63
|
+
"typeSafety": true
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"dev": "cross-env NODE_ENV=development node ../../../scripts/build/build.mjs --watch",
|
|
67
|
+
"test": "pui-cli test --passWithNoTests --coverage=\"false\" && [ -n \"$CI\" ] || playwright test -c ./playwright.config.mjs",
|
|
68
|
+
"lint": "node ../../../scripts/lint.mjs --fix",
|
|
69
|
+
"lint:strict": "node ../../../scripts/lint-strict.mjs",
|
|
70
|
+
"dts": "node ../../../scripts/dts.mjs",
|
|
71
|
+
"build": "cross-env NODE_ENV=production node ../../../scripts/build/build.mjs",
|
|
72
|
+
"checkDeps": "npx -yes ../../util/ds-codemods check-missing-packages --projectFolderPath=\"./\" --ignorePackagesGlobPattern=\"\" --ignoreFilesGlobPattern=\"**/test-ables/*,**/tests/*\""
|
|
73
|
+
}
|
|
74
|
+
}
|