@semcore/base-components 17.0.0-prerelease.30 → 17.0.0-prerelease.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -1
- package/lib/cjs/components/ellipsis/Ellipsis.types.js.map +1 -1
- package/lib/cjs/components/ellipsis/EllipsisManager.js +16 -3
- package/lib/cjs/components/ellipsis/EllipsisManager.js.map +1 -1
- package/lib/cjs/components/flex-box/Box/useBox.js +24 -16
- package/lib/cjs/components/flex-box/Box/useBox.js.map +1 -1
- package/lib/cjs/components/flex-box/style/use-box.shadow.css +6 -0
- package/lib/cjs/components/hint/Hint.js +32 -26
- package/lib/cjs/components/hint/Hint.js.map +1 -1
- package/lib/cjs/components/hint/Middleware.js +4 -2
- package/lib/cjs/components/hint/Middleware.js.map +1 -1
- package/lib/cjs/components/hint/style/hint.shadow.css +3 -2
- package/lib/es6/components/ellipsis/Ellipsis.types.js.map +1 -1
- package/lib/es6/components/ellipsis/EllipsisManager.js +16 -3
- package/lib/es6/components/ellipsis/EllipsisManager.js.map +1 -1
- package/lib/es6/components/flex-box/Box/useBox.js +24 -16
- package/lib/es6/components/flex-box/Box/useBox.js.map +1 -1
- package/lib/es6/components/flex-box/style/use-box.shadow.css +6 -0
- package/lib/es6/components/hint/Hint.js +32 -26
- package/lib/es6/components/hint/Hint.js.map +1 -1
- package/lib/es6/components/hint/Middleware.js +4 -2
- package/lib/es6/components/hint/Middleware.js.map +1 -1
- package/lib/es6/components/hint/style/hint.shadow.css +3 -2
- package/lib/esm/components/ellipsis/EllipsisManager.mjs +17 -4
- package/lib/esm/components/flex-box/Box/useBox.mjs +25 -17
- package/lib/esm/components/flex-box/invalid-state-box/InvalidStateBox.mjs +1 -2
- package/lib/esm/components/flex-box/screen-reader-only-box/ScreenReaderOnlyBox.mjs +1 -2
- package/lib/esm/components/flex-box/style/use-box.shadow.css +6 -0
- package/lib/esm/components/hint/Hint.mjs +33 -28
- package/lib/esm/components/hint/Middleware.mjs +4 -2
- package/lib/esm/components/hint/style/hint.shadow.css +3 -2
- package/lib/esm/components/neighbor-location/NeighborLocation.mjs +1 -1
- package/lib/esm/index.mjs +24 -24
- package/lib/types/components/ellipsis/Ellipsis.types.d.ts +5 -5
- package/lib/types/components/flex-box/Box/useBox.d.ts +2 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
|
|
4
4
|
|
|
5
|
-
## [17.0.0] - 2026-
|
|
5
|
+
## [17.0.0] - 2026-04-08
|
|
6
6
|
|
|
7
7
|
### BREAK
|
|
8
8
|
|
|
@@ -11,6 +11,13 @@ CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangel
|
|
|
11
11
|
- **outside-click**: Removed using `getNodeByRef`. Use `React.RefObject` instead.
|
|
12
12
|
- **scroll-area**: Removed using `getNodeByRef`. Use `React.RefObject` instead.
|
|
13
13
|
|
|
14
|
+
## [16.5.0] - 2026-04-01
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **box**: Add `hoverCursor` to `Box`.
|
|
19
|
+
- `inset` property for the Box component.
|
|
20
|
+
|
|
14
21
|
## [16.4.2] - 2025-12-01
|
|
15
22
|
|
|
16
23
|
### Fixed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ellipsis.types.js","names":[],"sources":["../../../../src/components/ellipsis/Ellipsis.types.ts"],"sourcesContent":["type CommonEllipsisSettings = {\n /**\n * Common container element for few ellipsises for improve performance.\n */\n containerElement?: HTMLElement;\n\n /**\n * Function for crop or increase a container width. For example, for tables with accordion\n */\n recalculateContainerWidth?: (width: number) => number;\n\n /**\n * Flag to enable observing changes in cropped texts.\n * @default false\n */\n observeChildrenMutations?: boolean;\n};\n\
|
|
1
|
+
{"version":3,"file":"Ellipsis.types.js","names":[],"sources":["../../../../src/components/ellipsis/Ellipsis.types.ts"],"sourcesContent":["export type CommonEllipsisSettings = {\n /**\n * Common container element for few ellipsises for improve performance.\n */\n containerElement?: HTMLElement;\n\n /**\n * Function for crop or increase a container width. For example, for tables with accordion\n */\n recalculateContainerWidth?: (width: number) => number;\n\n /**\n * Flag to enable observing changes in cropped texts.\n * @default false\n */\n observeChildrenMutations?: boolean;\n};\n\nexport type MiddleCroppedEllipsisSettings = {\n /**\n * Crop position\n * @default end\n */\n cropPosition: 'middle';\n\n maxLine?: never;\n\n /**\n * Count of last symbols which shouldn't be cropped.\n */\n lastRequiredSymbols?: number;\n};\n\nexport type EndCroppedEllipsisSettings = {\n /**\n * Crop position\n * @default end\n */\n cropPosition?: 'end';\n /**\n * Lines count in multiline Ellipsis.\n * Applies only for `cropPosition = 'end'`\n * @default 1\n */\n maxLine?: number;\n\n lastRequiredSymbols?: never;\n};\n\nexport type EllipsisSettings = (EndCroppedEllipsisSettings | MiddleCroppedEllipsisSettings) & CommonEllipsisSettings;\n\nexport type Events = {\n isEllipsized: (isEllipsized: boolean) => void;\n};\n\nexport type TruncateOptions = {\n text?: string;\n containerWidth?: number;\n font?: string;\n direction?: 'start' | 'end';\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -173,14 +173,27 @@ class EllipsisManager {
|
|
|
173
173
|
handleCopy(event) {
|
|
174
174
|
if (event instanceof ClipboardEvent && event.target instanceof HTMLElement && event.target.parentElement instanceof HTMLElement) {
|
|
175
175
|
const selection = window.getSelection();
|
|
176
|
-
|
|
176
|
+
let ellipsis = this.ellipsisEntities.get(event.target);
|
|
177
|
+
if (event.target.getAttribute('aria-hidden') === 'true') {
|
|
178
|
+
ellipsis = this.ellipsisEntities.get(event.target.parentElement);
|
|
179
|
+
}
|
|
177
180
|
if (selection && ellipsis) {
|
|
178
181
|
const ellipsisSpans = ellipsis.element.childNodes;
|
|
179
182
|
const croppedSpan = ellipsisSpans[0];
|
|
183
|
+
const lastSpan = ellipsisSpans[ellipsisSpans.length - 2];
|
|
180
184
|
const fullSpan = ellipsisSpans[ellipsisSpans.length - 1];
|
|
181
|
-
const
|
|
182
|
-
const
|
|
185
|
+
const croppedLength = croppedSpan?.textContent?.length;
|
|
186
|
+
const lastLength = lastSpan?.textContent?.length;
|
|
187
|
+
const anchorInCropped = selection.anchorNode === croppedSpan?.childNodes[0];
|
|
188
|
+
const anchorInLast = selection.anchorNode === lastSpan?.childNodes[0];
|
|
189
|
+
const focusInCropped = selection.focusNode === croppedSpan?.childNodes[0];
|
|
190
|
+
const focusInLast = selection.focusNode === lastSpan?.childNodes[0];
|
|
191
|
+
const anchorOffset = selection.anchorOffset;
|
|
192
|
+
const focusOffset = selection.focusOffset;
|
|
193
|
+
const isCroppedSelected = anchorInCropped && focusOffset === croppedLength || anchorInLast && anchorOffset === lastLength && focusInCropped && focusOffset === 0 || focusInLast && focusOffset === lastLength;
|
|
194
|
+
const isFullSelected = selection.focusNode === fullSpan?.childNodes[0] && focusOffset === fullSpan?.textContent?.length;
|
|
183
195
|
if (fullSpan?.textContent && (!(selection.focusNode instanceof Text) || isCroppedSelected || isFullSelected)) {
|
|
196
|
+
event.preventDefault();
|
|
184
197
|
navigator.clipboard.writeText(fullSpan.textContent);
|
|
185
198
|
}
|
|
186
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsisManager.js","names":["_canUseDOM","_interopRequireDefault","require","_Queue","isSafari","exports","canUseDOM","test","navigator","userAgent","EllipsisManager","constructor","_defineProperty2","default","WeakMap","WeakSet","queue","Queue","queueTimeout","undefined","handleResizeObserver","bind","handleMutationObserver","handleIntersectionObserver","handleCopy","ro","ResizeObserver","io","IntersectionObserver","root","scrollMargin","threshold","document","addEventListener","addEllipsis","ellipsis","element","ellipsisEntities","has","set","observe","observeChildrenMutations","mo","MutationObserver","characterData","subtree","characterDataOldValue","childList","ellipsisMutationObservers","containerElement","ellipsisSet","containersMap","get","Set","add","removeEllipsis","delete","handledElements","unobserve","disconnect","size","entries","forEach","entry","target","HTMLElement","firstEllipsis","values","next","value","containersApproximateSizeMap","getTruncateSize","el","cropPosition","setApproximateSize","handleChanges","mutations","length","type","text","Text","mutation","addedNodes","removedNodes","HTMLSpanElement","parent","parentElement","textContent","wholeText","scheduler","schedule","isIntersecting","container","approximateSize","slice","event","ClipboardEvent","selection","window","getSelection","ellipsisSpans","childNodes","croppedSpan","fullSpan","isCroppedSelected","anchorNode","focusOffset","focusNode","isFullSelected","clipboard","writeText","ellipsisManager"],"sources":["../../../../src/components/ellipsis/EllipsisManager.ts"],"sourcesContent":["import canUseDOM from '@semcore/core/lib/utils/canUseDOM';\n\nimport type { Ellipsis } from './Ellipsis';\nimport { Queue } from './Queue';\n\nexport const isSafari = canUseDOM() ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;\n\nclass EllipsisManager {\n private readonly queue: Queue;\n\n private ro: ResizeObserver | undefined;\n private io: IntersectionObserver | undefined;\n\n private readonly containersMap = new WeakMap<HTMLElement, Set<Ellipsis>>();\n private readonly containersApproximateSizeMap = new WeakMap<HTMLElement, [number, number]>();\n\n private handledElements = new WeakSet<HTMLElement>();\n private ellipsisEntities = new WeakMap<HTMLElement, Ellipsis>();\n private ellipsisMutationObservers = new WeakMap<HTMLElement, MutationObserver>();\n\n constructor() {\n this.queue = new Queue(isSafari ? { queueTimeout: 16 } : undefined);\n\n this.handleResizeObserver = this.handleResizeObserver.bind(this);\n this.handleMutationObserver = this.handleMutationObserver.bind(this);\n this.handleIntersectionObserver = this.handleIntersectionObserver.bind(this);\n\n this.handleCopy = this.handleCopy.bind(this);\n\n if (canUseDOM()) {\n this.ro = new ResizeObserver(this.handleResizeObserver);\n this.io = new IntersectionObserver(this.handleIntersectionObserver, {\n root: null,\n // @ts-ignore\n scrollMargin: '500px 500px 500px 500px',\n threshold: 0.1,\n });\n document.addEventListener('copy', this.handleCopy);\n }\n }\n\n public addEllipsis(ellipsis: Ellipsis) {\n const element = ellipsis.element;\n\n if (!this.ellipsisEntities.has(element)) {\n this.ellipsisEntities.set(element, ellipsis);\n\n this.io?.observe(element);\n\n if (ellipsis.observeChildrenMutations && canUseDOM()) {\n const mo = new MutationObserver(this.handleMutationObserver);\n mo.observe(element, {\n characterData: true,\n subtree: true,\n characterDataOldValue: true,\n childList: true,\n });\n\n this.ellipsisMutationObservers.set(element, mo);\n }\n }\n\n if (ellipsis.containerElement !== undefined) {\n const ellipsisSet = this.containersMap.get(ellipsis.containerElement) ?? new Set();\n\n ellipsisSet.add(ellipsis);\n\n this.containersMap.set(ellipsis.containerElement, ellipsisSet);\n }\n }\n\n public removeEllipsis(ellipsis: Ellipsis) {\n const element = ellipsis.element;\n\n if (this.ellipsisEntities.has(element)) {\n this.ellipsisEntities.delete(element);\n this.handledElements.delete(element);\n\n this.io?.unobserve(element);\n this.ro?.unobserve(element);\n this.ellipsisMutationObservers.get(element)?.disconnect();\n this.ellipsisMutationObservers.delete(element);\n }\n\n if (ellipsis.containerElement) {\n const ellipsisSet = this.containersMap.get(ellipsis.containerElement);\n if (ellipsisSet) {\n ellipsisSet.delete(ellipsis);\n\n if (ellipsisSet.size === 0) {\n this.containersMap.delete(ellipsis.containerElement);\n } else {\n this.containersMap.set(ellipsis.containerElement, ellipsisSet);\n }\n }\n }\n }\n\n private handleResizeObserver(entries: ResizeObserverEntry[]) {\n entries.forEach((entry) => {\n const target = entry.target;\n\n if (target instanceof HTMLElement) {\n const ellipsisSet = this.containersMap.get(target);\n if (ellipsisSet !== undefined) {\n const firstEllipsis = ellipsisSet.values().next().value;\n if (firstEllipsis) {\n this.containersApproximateSizeMap.set(target, firstEllipsis.getTruncateSize());\n }\n\n for (const el of ellipsisSet.values()) {\n const ellipsis = this.ellipsisEntities.get(el.element);\n\n if (ellipsis) {\n if (ellipsis.cropPosition === 'middle') {\n this.setApproximateSize(target, ellipsis);\n }\n\n this.queue.add(ellipsis.handleChanges);\n }\n }\n } else {\n const ellipsis = this.ellipsisEntities.get(target);\n\n if (ellipsis) {\n this.queue.add(ellipsis.handleChanges);\n }\n }\n }\n });\n }\n\n private handleMutationObserver(mutations: MutationRecord[]) {\n if (mutations.length === 1) {\n const { type, target } = mutations[0];\n\n let text: Text | undefined;\n\n if (type === 'characterData' && target instanceof Text) {\n text = target;\n } else if (type === 'childList') {\n const mutation = mutations[0];\n const addedNodes = mutation.addedNodes;\n const removedNodes = mutation.removedNodes;\n if (addedNodes.length === 1 && addedNodes[0] instanceof Text && removedNodes.length === 2 && removedNodes[0] instanceof HTMLSpanElement && removedNodes[1] instanceof HTMLSpanElement) {\n text = addedNodes[0];\n }\n }\n\n const parent = text?.parentElement;\n if (text && parent instanceof HTMLElement) {\n const ellipsis = this.ellipsisEntities.get(parent);\n\n if (ellipsis) {\n ellipsis.textContent = text.wholeText;\n ellipsis?.scheduler.schedule(ellipsis?.handleChanges);\n }\n }\n }\n }\n\n private handleIntersectionObserver(entries: IntersectionObserverEntry[]) {\n entries.forEach((entry) => {\n const target = entry.target;\n\n if (target instanceof HTMLElement) {\n if (entry.isIntersecting === true && !this.handledElements.has(target)) {\n const ellipsis = this.ellipsisEntities.get(target);\n\n if (ellipsis?.containerElement !== undefined) {\n this.ro?.observe(ellipsis?.containerElement);\n\n if (ellipsis.cropPosition === 'middle') {\n this.setApproximateSize(target, ellipsis);\n }\n\n this.queue.add(ellipsis.handleChanges);\n } else {\n this.ro?.observe(target);\n }\n\n this.handledElements.add(target);\n } else if (entry.isIntersecting === false && this.handledElements.has(target)) {\n const ellipsis = this.ellipsisEntities.get(target);\n\n if (ellipsis) {\n this.queue.delete(ellipsis.handleChanges);\n }\n\n this.handledElements.delete(target);\n\n this.ro?.unobserve(target);\n this.ellipsisMutationObservers.get(target)?.disconnect();\n }\n }\n });\n }\n\n private setApproximateSize(container: HTMLElement, ellipsis: Ellipsis) {\n const approximateSize = this.containersApproximateSizeMap.get(container);\n\n if (approximateSize && ellipsis.textContent.length > approximateSize[0] + approximateSize[1]) {\n ellipsis.element.textContent = ellipsis?.textContent.slice(0, approximateSize[0]) + '...' + ellipsis?.textContent.slice(-1 * approximateSize[1]);\n }\n }\n\n private handleCopy(event: ClipboardEvent) {\n if (event instanceof ClipboardEvent && event.target instanceof HTMLElement && event.target.parentElement instanceof HTMLElement) {\n const selection = window.getSelection();\n const ellipsis = this.ellipsisEntities.get(event.target.parentElement);\n\n if (selection && ellipsis) {\n const ellipsisSpans = ellipsis.element.childNodes;\n const croppedSpan = ellipsisSpans[0];\n const fullSpan = ellipsisSpans[ellipsisSpans.length - 1];\n\n const isCroppedSelected = (selection.anchorNode === croppedSpan?.childNodes[0] && selection.focusOffset === croppedSpan?.textContent?.length) || (selection.focusNode === croppedSpan?.childNodes[0] && selection.focusOffset === 0);\n const isFullSelected = selection.focusNode === fullSpan?.childNodes[0] && selection.focusOffset === fullSpan?.textContent?.length;\n\n if (fullSpan?.textContent && (!(selection.focusNode instanceof Text) || isCroppedSelected || isFullSelected)) {\n navigator.clipboard.writeText(fullSpan.textContent);\n }\n }\n }\n }\n}\n\nexport const ellipsisManager = new EllipsisManager();\n"],"mappings":";;;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAEO,MAAME,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG,IAAAE,kBAAS,EAAC,CAAC,GAAG,gCAAgC,CAACC,IAAI,CAACC,SAAS,CAACC,SAAS,CAAC,GAAG,KAAK;AAExG,MAAMC,eAAe,CAAC;EAapBC,WAAWA,CAAA,EAAG;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,yBAPmB,IAAIC,OAAO,CAA6B,CAAC;IAAA,IAAAF,gBAAA,CAAAC,OAAA,wCAC1B,IAAIC,OAAO,CAAgC,CAAC;IAAA,IAAAF,gBAAA,CAAAC,OAAA,2BAElE,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CAACsB,aAAa,CAAC;MAEtE,IAAIW,SAAS,IAAI9D,QAAQ,EAAE;QACzB,MAAMiE,aAAa,GAAGjE,QAAQ,CAACC,OAAO,CAACiE,UAAU;QACjD,MAAMC,WAAW,GAAGF,aAAa,CAAC,CAAC,CAAC;QACpC,MAAMG,QAAQ,GAAGH,aAAa,CAACA,aAAa,CAACvB,MAAM,GAAG,CAAC,CAAC;QAExD,MAAM2B,iBAAiB,GAAIP,SAAS,CAACQ,UAAU,KAAKH,WAAW,EAAED,UAAU,CAAC,CAAC,CAAC,IAAIJ,SAAS,CAACS,WAAW,KAAKJ,WAAW,EAAEf,WAAW,EAAEV,MAAM,IAAMoB,SAAS,CAACU,SAAS,KAAKL,WAAW,EAAED,UAAU,CAAC,CAAC,CAAC,IAAIJ,SAAS,CAACS,WAAW,KAAK,CAAE;QACpO,MAAME,cAAc,GAAGX,SAAS,CAACU,SAAS,KAAKJ,QAAQ,EAAEF,UAAU,CAAC,CAAC,CAAC,IAAIJ,SAAS,CAACS,WAAW,KAAKH,QAAQ,EAAEhB,WAAW,EAAEV,MAAM;QAEjI,IAAI0B,QAAQ,EAAEhB,WAAW,KAAK,EAAEU,SAAS,CAACU,SAAS,YAAY3B,IAAI,CAAC,IAAIwB,iBAAiB,IAAII,cAAc,CAAC,EAAE;UAC5GpG,SAAS,CAACqG,SAAS,CAACC,SAAS,CAACP,QAAQ,CAAChB,WAAW,CAAC;QACrD;MACF;IACF;EACF;AACF;AAEO,MAAMwB,eAAe,GAAA1G,OAAA,CAAA0G,eAAA,GAAG,IAAIrG,eAAe,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"EllipsisManager.js","names":["_canUseDOM","_interopRequireDefault","require","_Queue","isSafari","exports","canUseDOM","test","navigator","userAgent","EllipsisManager","constructor","_defineProperty2","default","WeakMap","WeakSet","queue","Queue","queueTimeout","undefined","handleResizeObserver","bind","handleMutationObserver","handleIntersectionObserver","handleCopy","ro","ResizeObserver","io","IntersectionObserver","root","scrollMargin","threshold","document","addEventListener","addEllipsis","ellipsis","element","ellipsisEntities","has","set","observe","observeChildrenMutations","mo","MutationObserver","characterData","subtree","characterDataOldValue","childList","ellipsisMutationObservers","containerElement","ellipsisSet","containersMap","get","Set","add","removeEllipsis","delete","handledElements","unobserve","disconnect","size","entries","forEach","entry","target","HTMLElement","firstEllipsis","values","next","value","containersApproximateSizeMap","getTruncateSize","el","cropPosition","setApproximateSize","handleChanges","mutations","length","type","text","Text","mutation","addedNodes","removedNodes","HTMLSpanElement","parent","parentElement","textContent","wholeText","scheduler","schedule","isIntersecting","container","approximateSize","slice","event","ClipboardEvent","selection","window","getSelection","getAttribute","ellipsisSpans","childNodes","croppedSpan","lastSpan","fullSpan","croppedLength","lastLength","anchorInCropped","anchorNode","anchorInLast","focusInCropped","focusNode","focusInLast","anchorOffset","focusOffset","isCroppedSelected","isFullSelected","preventDefault","clipboard","writeText","ellipsisManager"],"sources":["../../../../src/components/ellipsis/EllipsisManager.ts"],"sourcesContent":["import canUseDOM from '@semcore/core/lib/utils/canUseDOM';\n\nimport type { Ellipsis } from './Ellipsis';\nimport { Queue } from './Queue';\n\nexport const isSafari = canUseDOM() ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;\n\nclass EllipsisManager {\n private readonly queue: Queue;\n\n private ro: ResizeObserver | undefined;\n private io: IntersectionObserver | undefined;\n\n private readonly containersMap = new WeakMap<HTMLElement, Set<Ellipsis>>();\n private readonly containersApproximateSizeMap = new WeakMap<HTMLElement, [number, number]>();\n\n private handledElements = new WeakSet<HTMLElement>();\n private ellipsisEntities = new WeakMap<HTMLElement, Ellipsis>();\n private ellipsisMutationObservers = new WeakMap<HTMLElement, MutationObserver>();\n\n constructor() {\n this.queue = new Queue(isSafari ? { queueTimeout: 16 } : undefined);\n\n this.handleResizeObserver = this.handleResizeObserver.bind(this);\n this.handleMutationObserver = this.handleMutationObserver.bind(this);\n this.handleIntersectionObserver = this.handleIntersectionObserver.bind(this);\n\n this.handleCopy = this.handleCopy.bind(this);\n\n if (canUseDOM()) {\n this.ro = new ResizeObserver(this.handleResizeObserver);\n this.io = new IntersectionObserver(this.handleIntersectionObserver, {\n root: null,\n // @ts-ignore\n scrollMargin: '500px 500px 500px 500px',\n threshold: 0.1,\n });\n document.addEventListener('copy', this.handleCopy);\n }\n }\n\n public addEllipsis(ellipsis: Ellipsis) {\n const element = ellipsis.element;\n\n if (!this.ellipsisEntities.has(element)) {\n this.ellipsisEntities.set(element, ellipsis);\n\n this.io?.observe(element);\n\n if (ellipsis.observeChildrenMutations && canUseDOM()) {\n const mo = new MutationObserver(this.handleMutationObserver);\n mo.observe(element, {\n characterData: true,\n subtree: true,\n characterDataOldValue: true,\n childList: true,\n });\n\n this.ellipsisMutationObservers.set(element, mo);\n }\n }\n\n if (ellipsis.containerElement !== undefined) {\n const ellipsisSet = this.containersMap.get(ellipsis.containerElement) ?? new Set();\n\n ellipsisSet.add(ellipsis);\n\n this.containersMap.set(ellipsis.containerElement, ellipsisSet);\n }\n }\n\n public removeEllipsis(ellipsis: Ellipsis) {\n const element = ellipsis.element;\n\n if (this.ellipsisEntities.has(element)) {\n this.ellipsisEntities.delete(element);\n this.handledElements.delete(element);\n\n this.io?.unobserve(element);\n this.ro?.unobserve(element);\n this.ellipsisMutationObservers.get(element)?.disconnect();\n this.ellipsisMutationObservers.delete(element);\n }\n\n if (ellipsis.containerElement) {\n const ellipsisSet = this.containersMap.get(ellipsis.containerElement);\n if (ellipsisSet) {\n ellipsisSet.delete(ellipsis);\n\n if (ellipsisSet.size === 0) {\n this.containersMap.delete(ellipsis.containerElement);\n } else {\n this.containersMap.set(ellipsis.containerElement, ellipsisSet);\n }\n }\n }\n }\n\n private handleResizeObserver(entries: ResizeObserverEntry[]) {\n entries.forEach((entry) => {\n const target = entry.target;\n\n if (target instanceof HTMLElement) {\n const ellipsisSet = this.containersMap.get(target);\n if (ellipsisSet !== undefined) {\n const firstEllipsis = ellipsisSet.values().next().value;\n if (firstEllipsis) {\n this.containersApproximateSizeMap.set(target, firstEllipsis.getTruncateSize());\n }\n\n for (const el of ellipsisSet.values()) {\n const ellipsis = this.ellipsisEntities.get(el.element);\n\n if (ellipsis) {\n if (ellipsis.cropPosition === 'middle') {\n this.setApproximateSize(target, ellipsis);\n }\n\n this.queue.add(ellipsis.handleChanges);\n }\n }\n } else {\n const ellipsis = this.ellipsisEntities.get(target);\n\n if (ellipsis) {\n this.queue.add(ellipsis.handleChanges);\n }\n }\n }\n });\n }\n\n private handleMutationObserver(mutations: MutationRecord[]) {\n if (mutations.length === 1) {\n const { type, target } = mutations[0];\n\n let text: Text | undefined;\n\n if (type === 'characterData' && target instanceof Text) {\n text = target;\n } else if (type === 'childList') {\n const mutation = mutations[0];\n const addedNodes = mutation.addedNodes;\n const removedNodes = mutation.removedNodes;\n if (addedNodes.length === 1 && addedNodes[0] instanceof Text && removedNodes.length === 2 && removedNodes[0] instanceof HTMLSpanElement && removedNodes[1] instanceof HTMLSpanElement) {\n text = addedNodes[0];\n }\n }\n\n const parent = text?.parentElement;\n if (text && parent instanceof HTMLElement) {\n const ellipsis = this.ellipsisEntities.get(parent);\n\n if (ellipsis) {\n ellipsis.textContent = text.wholeText;\n ellipsis?.scheduler.schedule(ellipsis?.handleChanges);\n }\n }\n }\n }\n\n private handleIntersectionObserver(entries: IntersectionObserverEntry[]) {\n entries.forEach((entry) => {\n const target = entry.target;\n\n if (target instanceof HTMLElement) {\n if (entry.isIntersecting === true && !this.handledElements.has(target)) {\n const ellipsis = this.ellipsisEntities.get(target);\n\n if (ellipsis?.containerElement !== undefined) {\n this.ro?.observe(ellipsis?.containerElement);\n\n if (ellipsis.cropPosition === 'middle') {\n this.setApproximateSize(target, ellipsis);\n }\n\n this.queue.add(ellipsis.handleChanges);\n } else {\n this.ro?.observe(target);\n }\n\n this.handledElements.add(target);\n } else if (entry.isIntersecting === false && this.handledElements.has(target)) {\n const ellipsis = this.ellipsisEntities.get(target);\n\n if (ellipsis) {\n this.queue.delete(ellipsis.handleChanges);\n }\n\n this.handledElements.delete(target);\n\n this.ro?.unobserve(target);\n this.ellipsisMutationObservers.get(target)?.disconnect();\n }\n }\n });\n }\n\n private setApproximateSize(container: HTMLElement, ellipsis: Ellipsis) {\n const approximateSize = this.containersApproximateSizeMap.get(container);\n\n if (approximateSize && ellipsis.textContent.length > approximateSize[0] + approximateSize[1]) {\n ellipsis.element.textContent = ellipsis?.textContent.slice(0, approximateSize[0]) + '...' + ellipsis?.textContent.slice(-1 * approximateSize[1]);\n }\n }\n\n private handleCopy(event: ClipboardEvent) {\n if (event instanceof ClipboardEvent && event.target instanceof HTMLElement && event.target.parentElement instanceof HTMLElement) {\n const selection = window.getSelection();\n let ellipsis = this.ellipsisEntities.get(event.target);\n\n if (event.target.getAttribute('aria-hidden') === 'true') {\n ellipsis = this.ellipsisEntities.get(event.target.parentElement);\n }\n\n if (selection && ellipsis) {\n const ellipsisSpans = ellipsis.element.childNodes;\n const croppedSpan = ellipsisSpans[0];\n const lastSpan = ellipsisSpans[ellipsisSpans.length - 2];\n const fullSpan = ellipsisSpans[ellipsisSpans.length - 1];\n\n const croppedLength = croppedSpan?.textContent?.length;\n const lastLength = lastSpan?.textContent?.length;\n\n const anchorInCropped = selection.anchorNode === croppedSpan?.childNodes[0];\n const anchorInLast = selection.anchorNode === lastSpan?.childNodes[0];\n const focusInCropped = selection.focusNode === croppedSpan?.childNodes[0];\n const focusInLast = selection.focusNode === lastSpan?.childNodes[0];\n\n const anchorOffset = selection.anchorOffset;\n const focusOffset = selection.focusOffset;\n\n const isCroppedSelected =\n (anchorInCropped && focusOffset === croppedLength) ||\n (anchorInLast && anchorOffset === lastLength && focusInCropped && focusOffset === 0) ||\n (focusInLast && focusOffset === lastLength);\n\n const isFullSelected = selection.focusNode === fullSpan?.childNodes[0] && focusOffset === fullSpan?.textContent?.length;\n\n if (fullSpan?.textContent && (!(selection.focusNode instanceof Text) || isCroppedSelected || isFullSelected)) {\n event.preventDefault();\n navigator.clipboard.writeText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semcore/core/lib/utils/p
|
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
/*!__reshadow-styles__:"../style/use-box.shadow.css"*/
|
|
14
|
-
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
14
|
+
const style = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SBox_1x9qy_gg_._inAfterOutline_false_1x9qy_gg_:focus-visible,.___SBox_1x9qy_gg_._inAfterOutline_true_1x9qy_gg_:focus-visible::after{z-index:1;outline-color:var(--intergalactic-keyboard-focus-outline, #008ff8);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset}.___SBox_1x9qy_gg_._inAfterOutline_false_1x9qy_gg_.__invertOutline_1x9qy_gg_:focus-visible,.___SBox_1x9qy_gg_._inAfterOutline_true_1x9qy_gg_.__invertOutline_1x9qy_gg_:focus-visible::after{outline-color:var(--intergalactic-keyboard-focus-invert-outline, rgba(255, 255, 255, 0.8))}.___SBox_1x9qy_gg_._inAfterOutline_true_1x9qy_gg_:focus-visible::after{position:absolute;display:block;content:\"\";top:0;right:0;bottom:0;left:0;top:var(0);right:var(0);bottom:var(0);left:var(0)}@media (hover:hover){.___SBox_1x9qy_gg_.__hoverCursor_1x9qy_gg_:hover{cursor:var(--hoverCursor_1x9qy)}}.___SBoxInnerOutline_1x9qy_gg_._inAfterOutline_false_1x9qy_gg_:focus-visible,.___SBoxInnerOutline_1x9qy_gg_._inAfterOutline_true_1x9qy_gg_:focus-visible::after{outline-offset:-2px}.___SBoxSizing_1x9qy_gg_{box-sizing:border-box}.___SBoxInline_1x9qy_gg_{display:inline-block}", /*__inner_css_end__*/"1x9qy_gg_"),
|
|
15
15
|
/*__reshadow_css_end__*/
|
|
16
16
|
{
|
|
17
|
-
"__SBoxInnerOutline": "
|
|
18
|
-
"_inAfterOutline_false": "
|
|
19
|
-
"_inAfterOutline_true": "
|
|
20
|
-
"__SBoxSizing": "
|
|
21
|
-
"__SBoxInline": "
|
|
22
|
-
"__SBox": "
|
|
23
|
-
"_invertOutline": "
|
|
17
|
+
"__SBoxInnerOutline": "___SBoxInnerOutline_1x9qy_gg_",
|
|
18
|
+
"_inAfterOutline_false": "_inAfterOutline_false_1x9qy_gg_",
|
|
19
|
+
"_inAfterOutline_true": "_inAfterOutline_true_1x9qy_gg_",
|
|
20
|
+
"__SBoxSizing": "___SBoxSizing_1x9qy_gg_",
|
|
21
|
+
"__SBoxInline": "___SBoxInline_1x9qy_gg_",
|
|
22
|
+
"__SBox": "___SBox_1x9qy_gg_",
|
|
23
|
+
"_invertOutline": "__invertOutline_1x9qy_gg_",
|
|
24
|
+
"_hoverCursor": "__hoverCursor_1x9qy_gg_",
|
|
25
|
+
"--hoverCursor": "--hoverCursor_1x9qy"
|
|
24
26
|
});
|
|
25
27
|
/** @deprecated */
|
|
26
28
|
function calculateIndentStyles(props, scaleIndent) {
|
|
@@ -94,25 +96,31 @@ function useBox(props, ref) {
|
|
|
94
96
|
right,
|
|
95
97
|
inset,
|
|
96
98
|
zIndex,
|
|
99
|
+
hoverCursor,
|
|
97
100
|
...other
|
|
98
101
|
} = props;
|
|
99
102
|
const indentStyles = _react.default.useMemo(() => {
|
|
100
103
|
return calculateIndentStyles(props, scaleIndent);
|
|
101
104
|
}, [scaleIndent, display, w, h, wMin, wMax, hMin, hMax, flex, m, mt, mb, my, ml, mr, mx, p, pt, pb, py, pl, pr, px, position, top, left, bottom, right, inset, zIndex]);
|
|
102
105
|
const styles = (0, _core.sstyled)(style);
|
|
106
|
+
const {
|
|
107
|
+
className: rootClassName,
|
|
108
|
+
style: rootStyle
|
|
109
|
+
} = styles.cn('SBox', {
|
|
110
|
+
SBoxSizing: boxSizing,
|
|
111
|
+
SBoxInline: inline,
|
|
112
|
+
SBoxInnerOutline: innerOutline,
|
|
113
|
+
inAfterOutline: inAfterOutline === true ? 'true' : 'false',
|
|
114
|
+
invertOutline,
|
|
115
|
+
hoverCursor
|
|
116
|
+
});
|
|
103
117
|
if (Tag === _react.default.Fragment) return [_react.default.Fragment, {
|
|
104
118
|
children: props.children
|
|
105
119
|
}];
|
|
106
120
|
return [Tag, {
|
|
107
121
|
ref,
|
|
108
|
-
'className': (0, _classnames.default)(
|
|
109
|
-
|
|
110
|
-
SBoxInline: inline,
|
|
111
|
-
SBoxInnerOutline: innerOutline,
|
|
112
|
-
inAfterOutline: inAfterOutline === true ? 'true' : 'false',
|
|
113
|
-
invertOutline
|
|
114
|
-
}).className, className) || undefined,
|
|
115
|
-
'style': Object.assign({}, styleProp, css, indentStyles),
|
|
122
|
+
'className': (0, _classnames.default)(rootClassName, className) || undefined,
|
|
123
|
+
'style': Object.assign({}, rootStyle, styleProp, css, indentStyles),
|
|
116
124
|
'data-ui-name': 'Box',
|
|
117
125
|
...(0, _propsForElement.default)(other, Tag)
|
|
118
126
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBox.js","names":["_core","require","_indentStyles","_propsForElement","_interopRequireDefault","_classnames","_react","style","sstyled","insert","calculateIndentStyles","props","scaleIndent","removeUndefinedKeys","display","width","getSize","height","minWidth","maxWidth","minHeight","maxHeight","position","top","left","bottom","right","inset","flex","zIndex","textAlign","margin","getAutoOrScaleIndent","marginTop","marginBottom","marginLeft","marginRight","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","useBox","ref","tag","Tag","className","styleProp","boxSizing","inline","innerOutline","invertOutline","inAfterOutline","w","h","wMin","wMax","hMin","hMax","m","mt","mb","my","ml","mr","mx","p","pt","pb","py","pl","pr","px","css","other","indentStyles","React","useMemo","styles","Fragment","children","cn","SBoxSizing","SBoxInline","SBoxInnerOutline","undefined","Object","assign","propsForElement"],"sources":["../../../../../src/components/flex-box/Box/useBox.tsx"],"sourcesContent":["import { sstyled, type UnknownProperties, type IStyledProps } from '@semcore/core';\nimport { getAutoOrScaleIndent, removeUndefinedKeys, getSize } from '@semcore/core/lib/utils/indentStyles';\nimport propsForElement from '@semcore/core/lib/utils/propsForElement';\nimport cn from 'classnames';\nimport type { Properties, Property } from 'csstype';\nimport React from 'react';\n\nimport style from '../style/use-box.shadow.css';\n\nexport type BoxProps = IStyledProps & {\n /**\n * CSS `display` property\n */\n display?: Property.Display;\n\n /** Sets the `inline-block` property */\n inline?: boolean;\n\n /** CSS `box-sizing: border-box` property */\n boxSizing?: boolean | 'border-box';\n\n /** CSS `flex` property */\n flex?: Property.Flex<string>;\n\n /** CSS `margin` property */\n m?: number | string;\n\n /** CSS `margin-top` property */\n mt?: number | string;\n\n /** CSS `margin-right` property */\n mr?: number | string;\n\n /** CSS `margin-bottom` property */\n mb?: number | string;\n\n /** CSS `margin-left` property */\n ml?: number | string;\n\n /** CSS `margin-left` and `margin-right` property */\n mx?: number | string;\n\n /** CSS `margin-top` and `margin-bottom` property */\n my?: number | string;\n\n /** CSS `padding` property */\n p?: number | string;\n\n /** CSS `padding-top` property */\n pt?: number | string;\n\n /** CSS `padding-right` property */\n pr?: number | string;\n\n /** CSS `padding-bottom` property */\n pb?: number | string;\n\n /** CSS `padding-left` property */\n pl?: number | string;\n\n /** CSS `padding-left` and `padding-right` property */\n px?: number | string;\n\n /** CSS `padding-top` and `padding-bottom` property */\n py?: number | string;\n\n /**\n * CSS `width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n w?: number | string;\n\n /**\n * CSS `min-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMin?: number | string;\n\n /**\n * CSS `max-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMax?: number | string;\n\n /**\n * CSS `height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n h?: number | string;\n\n /**\n * CSS `min-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMin?: number | string;\n\n /**\n * CSS `max-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMax?: number | string;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n\n /**\n * Flag for render outline inside box\n * @default false\n */\n innerOutline?: boolean;\n\n /**\n * Flag for render inverted outline\n * @default false\n */\n invertOutline?: boolean;\n\n /**\n * Flag for render outline in the ::after element\n * @default false\n */\n inAfterOutline?: boolean;\n /** CSS `position` property */\n position?: Property.Position;\n /** CSS `top` property */\n top?: number | string;\n /** CSS `left` property */\n left?: number | string;\n /** CSS `bottom` property */\n bottom?: number | string;\n /** CSS `right` property */\n right?: number | string;\n /** CSS `inset` property */\n inset?: string;\n /** CSS `z-index` property */\n zIndex?: number;\n /** CSS `text-align` property */\n textAlign?: Property.TextAlign;\n /** Box content */\n children?: React.ReactNode;\n};\n\n/** @deprecated */\nexport interface IBoxProps extends BoxProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n * @default div\n */\n tag?: React.ElementType | string;\n}\n\nfunction calculateIndentStyles(props: BoxProps, scaleIndent: number) {\n return removeUndefinedKeys({\n display: props['display'],\n width: getSize(props['w']),\n height: getSize(props['h']),\n minWidth: getSize(props['wMin']),\n maxWidth: getSize(props['wMax']),\n minHeight: getSize(props['hMin']),\n maxHeight: getSize(props['hMax']),\n position: props['position'],\n top: getSize(props['top']),\n left: getSize(props['left']),\n bottom: getSize(props['bottom']),\n right: getSize(props['right']),\n inset: props.inset,\n flex: props.flex,\n zIndex: props.zIndex,\n textAlign: props.textAlign,\n\n margin: getAutoOrScaleIndent(props['m'], scaleIndent),\n marginTop:\n getAutoOrScaleIndent(props['mt'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginBottom:\n getAutoOrScaleIndent(props['mb'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginLeft:\n getAutoOrScaleIndent(props['ml'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n marginRight:\n getAutoOrScaleIndent(props['mr'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n\n padding: getAutoOrScaleIndent(props['p'], scaleIndent),\n paddingTop:\n getAutoOrScaleIndent(props['pt'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingBottom:\n getAutoOrScaleIndent(props['pb'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingLeft:\n getAutoOrScaleIndent(props['pl'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n paddingRight:\n getAutoOrScaleIndent(props['pr'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n });\n}\n\nexport default function useBox<T extends BoxProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const {\n tag: Tag = 'div',\n className,\n style: styleProp,\n scaleIndent = 4,\n display,\n boxSizing,\n inline,\n innerOutline,\n invertOutline,\n inAfterOutline,\n flex,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n css,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ...other\n } = props as any;\n\n const indentStyles: Properties = React.useMemo(() => {\n return calculateIndentStyles(props, scaleIndent);\n }, [\n scaleIndent,\n display,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n flex,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ]);\n\n const styles = sstyled(style);\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n ref,\n 'className':\n cn(\n styles.cn('SBox', {\n SBoxSizing: boxSizing,\n SBoxInline: inline,\n SBoxInnerOutline: innerOutline,\n inAfterOutline: inAfterOutline === true ? 'true' : 'false',\n invertOutline,\n }).className,\n className,\n ) || undefined,\n 'style': Object.assign({}, styleProp, css, indentStyles),\n 'data-ui-name': 'Box',\n ...propsForElement(other, Tag),\n },\n ];\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,WAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,MAAA,GAAAF,sBAAA,CAAAH,OAAA;AAA0B;AAAA,MAAAM,KAAA,8BAAAP,KAAA,CAAAQ,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAkJ1B;AASA,SAASC,qBAAqBA,CAACC,KAAe,EAAEC,WAAmB,EAAE;EACnE,OAAO,IAAAC,iCAAmB,EAAC;IACzBC,OAAO,EAAEH,KAAK,CAAC,SAAS,CAAC;IACzBI,KAAK,EAAE,IAAAC,qBAAO,EAACL,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1BM,MAAM,EAAE,IAAAD,qBAAO,EAACL,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3BO,QAAQ,EAAE,IAAAF,qBAAO,EAACL,KAAK,CAAC,MAAM,CAAC,CAAC;IAChCQ,QAAQ,EAAE,IAAAH,qBAAO,EAACL,KAAK,CAAC,MAAM,CAAC,CAAC;IAChCS,SAAS,EAAE,IAAAJ,qBAAO,EAACL,KAAK,CAAC,MAAM,CAAC,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AACL,SAAS,EACZA,SACF,CAAC,IAAIuC,SAAS;IAChB,OAAO,EAAEC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAExC,SAAS,EAAE0B,GAAG,EAAEE,YAAY,CAAC;IACxD,cAAc,EAAE,KAAK;IACrB,GAAG,IAAAa,wBAAe,EAACd,KAAK,EAAE7B,GAAG;EAC/B,CAAC,CACF;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useBox.js","names":["_core","require","_indentStyles","_propsForElement","_interopRequireDefault","_classnames","_react","style","sstyled","insert","calculateIndentStyles","props","scaleIndent","removeUndefinedKeys","display","width","getSize","height","minWidth","maxWidth","minHeight","maxHeight","position","top","left","bottom","right","inset","flex","zIndex","textAlign","margin","getAutoOrScaleIndent","marginTop","marginBottom","marginLeft","marginRight","padding","paddingTop","paddingBottom","paddingLeft","paddingRight","useBox","ref","tag","Tag","className","styleProp","boxSizing","inline","innerOutline","invertOutline","inAfterOutline","w","h","wMin","wMax","hMin","hMax","m","mt","mb","my","ml","mr","mx","p","pt","pb","py","pl","pr","px","css","hoverCursor","other","indentStyles","React","useMemo","styles","rootClassName","rootStyle","cn","SBoxSizing","SBoxInline","SBoxInnerOutline","Fragment","children","undefined","Object","assign","propsForElement"],"sources":["../../../../../src/components/flex-box/Box/useBox.tsx"],"sourcesContent":["import { sstyled, type UnknownProperties, type IStyledProps } from '@semcore/core';\nimport { getAutoOrScaleIndent, removeUndefinedKeys, getSize } from '@semcore/core/lib/utils/indentStyles';\nimport propsForElement from '@semcore/core/lib/utils/propsForElement';\nimport cn from 'classnames';\nimport type { Properties, Property } from 'csstype';\nimport React from 'react';\n\nimport style from '../style/use-box.shadow.css';\n\nexport type BoxProps = IStyledProps & {\n /**\n * CSS `display` property\n */\n display?: Property.Display;\n\n /** Sets the `inline-block` property */\n inline?: boolean;\n\n /** CSS `box-sizing: border-box` property */\n boxSizing?: boolean | 'border-box';\n\n /** CSS `flex` property */\n flex?: Property.Flex<string>;\n\n /** CSS `margin` property */\n m?: number | string;\n\n /** CSS `margin-top` property */\n mt?: number | string;\n\n /** CSS `margin-right` property */\n mr?: number | string;\n\n /** CSS `margin-bottom` property */\n mb?: number | string;\n\n /** CSS `margin-left` property */\n ml?: number | string;\n\n /** CSS `margin-left` and `margin-right` property */\n mx?: number | string;\n\n /** CSS `margin-top` and `margin-bottom` property */\n my?: number | string;\n\n /** CSS `padding` property */\n p?: number | string;\n\n /** CSS `padding-top` property */\n pt?: number | string;\n\n /** CSS `padding-right` property */\n pr?: number | string;\n\n /** CSS `padding-bottom` property */\n pb?: number | string;\n\n /** CSS `padding-left` property */\n pl?: number | string;\n\n /** CSS `padding-left` and `padding-right` property */\n px?: number | string;\n\n /** CSS `padding-top` and `padding-bottom` property */\n py?: number | string;\n\n /**\n * CSS `width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n w?: number | string;\n\n /**\n * CSS `min-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMin?: number | string;\n\n /**\n * CSS `max-width` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n wMax?: number | string;\n\n /**\n * CSS `height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n h?: number | string;\n\n /**\n * CSS `min-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMin?: number | string;\n\n /**\n * CSS `max-height` property.\n * If its value is less than 1, is considered as a fraction of 100%.\n * If its value is more than 1, is considered as value in px, if it is a string, is passed as is.\n */\n hMax?: number | string;\n\n /**\n * Multiplier of all indents. For example, if you specify a margin-top equal to 3 (mt = {3}), it will be 12px (3 * 4 = 12).\n * @default 4\n */\n scaleIndent?: number;\n\n /**\n * Flag for render outline inside box\n * @default false\n */\n innerOutline?: boolean;\n\n /**\n * Flag for render inverted outline\n * @default false\n */\n invertOutline?: boolean;\n\n /**\n * Flag for render outline in the ::after element\n * @default false\n */\n inAfterOutline?: boolean;\n /** CSS `position` property */\n position?: Property.Position;\n /** CSS `top` property */\n top?: number | string;\n /** CSS `left` property */\n left?: number | string;\n /** CSS `bottom` property */\n bottom?: number | string;\n /** CSS `right` property */\n right?: number | string;\n /** CSS `inset` property */\n inset?: string;\n /** CSS `z-index` property */\n zIndex?: number;\n /** CSS `text-align` property */\n textAlign?: Property.TextAlign;\n /** Box content */\n children?: React.ReactNode;\n /** Hover cursor */\n hoverCursor?: Property.Cursor;\n};\n\n/** @deprecated */\nexport interface IBoxProps extends BoxProps, UnknownProperties {\n /**\n * HTML tag name for the displayed item\n * @default div\n */\n tag?: React.ElementType | string;\n}\n\nfunction calculateIndentStyles(props: BoxProps, scaleIndent: number) {\n return removeUndefinedKeys({\n display: props['display'],\n width: getSize(props['w']),\n height: getSize(props['h']),\n minWidth: getSize(props['wMin']),\n maxWidth: getSize(props['wMax']),\n minHeight: getSize(props['hMin']),\n maxHeight: getSize(props['hMax']),\n position: props['position'],\n top: getSize(props['top']),\n left: getSize(props['left']),\n bottom: getSize(props['bottom']),\n right: getSize(props['right']),\n inset: props.inset,\n flex: props.flex,\n zIndex: props.zIndex,\n textAlign: props.textAlign,\n\n margin: getAutoOrScaleIndent(props['m'], scaleIndent),\n marginTop:\n getAutoOrScaleIndent(props['mt'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginBottom:\n getAutoOrScaleIndent(props['mb'], scaleIndent) ||\n getAutoOrScaleIndent(props['my'], scaleIndent),\n marginLeft:\n getAutoOrScaleIndent(props['ml'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n marginRight:\n getAutoOrScaleIndent(props['mr'], scaleIndent) ||\n getAutoOrScaleIndent(props['mx'], scaleIndent),\n\n padding: getAutoOrScaleIndent(props['p'], scaleIndent),\n paddingTop:\n getAutoOrScaleIndent(props['pt'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingBottom:\n getAutoOrScaleIndent(props['pb'], scaleIndent) ||\n getAutoOrScaleIndent(props['py'], scaleIndent),\n paddingLeft:\n getAutoOrScaleIndent(props['pl'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n paddingRight:\n getAutoOrScaleIndent(props['pr'], scaleIndent) ||\n getAutoOrScaleIndent(props['px'], scaleIndent),\n });\n}\n\nexport default function useBox<T extends BoxProps>(\n props: T,\n ref: React.Ref<HTMLElement>,\n): [React.ElementType | string, any] {\n const {\n tag: Tag = 'div',\n className,\n style: styleProp,\n scaleIndent = 4,\n display,\n boxSizing,\n inline,\n innerOutline,\n invertOutline,\n inAfterOutline,\n flex,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n css,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n hoverCursor,\n ...other\n } = props as any;\n\n const indentStyles: Properties = React.useMemo(() => {\n return calculateIndentStyles(props, scaleIndent);\n }, [\n scaleIndent,\n display,\n w,\n h,\n wMin,\n wMax,\n hMin,\n hMax,\n flex,\n m,\n mt,\n mb,\n my,\n ml,\n mr,\n mx,\n p,\n pt,\n pb,\n py,\n pl,\n pr,\n px,\n position,\n top,\n left,\n bottom,\n right,\n inset,\n zIndex,\n ]);\n\n const styles = sstyled(style);\n const { className: rootClassName, style: rootStyle } = styles.cn('SBox', {\n SBoxSizing: boxSizing,\n SBoxInline: inline,\n SBoxInnerOutline: innerOutline,\n inAfterOutline: inAfterOutline === true ? 'true' : 'false',\n invertOutline,\n hoverCursor,\n });\n\n if (Tag === React.Fragment) return [React.Fragment, { children: props.children }];\n\n return [\n Tag,\n {\n ref,\n 'className':\n cn(\n rootClassName,\n className,\n ) ||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KAAK;IACrB,GAAG,IAAAe,wBAAe,EAAChB,KAAK,EAAE9B,GAAG;EAC/B,CAAC,CACF;AACH","ignoreList":[]}
|
|
@@ -25,6 +25,12 @@ SBox[inAfterOutline='true']:focus-visible {
|
|
|
25
25
|
outline-color: var(--intergalactic-keyboard-focus-invert-outline, rgba(255, 255, 255, 0.8));
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
SBox[hoverCursor] {
|
|
30
|
+
&:hover {
|
|
31
|
+
cursor: var(--hoverCursor);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
28
34
|
SBoxInnerOutline[inAfterOutline='false']:focus-visible {
|
|
29
35
|
outline-offset: -2px;
|
|
30
36
|
}
|
|
@@ -49,16 +49,16 @@ const keyframes = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_
|
|
|
49
49
|
"@transform-exit": "transform-exit_1ns4f"
|
|
50
50
|
});
|
|
51
51
|
/*!__reshadow-styles__:"./style/hint.shadow.css"*/
|
|
52
|
-
const styles = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".
|
|
52
|
+
const styles = (/*__reshadow_css_start__*/_core.sstyled.insert(/*__inner_css_start__*/".___SHintPopper_19wzn_gg_{width:-moz-max-content;width:max-content;position:absolute;top:0;left:0;max-width:250px;word-wrap:break-word;opacity:0;pointer-events:none;background:var(--intergalactic-tooltip-invert, #191b23);border:1px solid var(--intergalactic-border-tooltip-invert, #6c6e79);color:var(--intergalactic-text-primary-invert, #ffffff);padding:var(--intergalactic-spacing-1x, 4px) var(--intergalactic-spacing-2x, 8px);border-radius:var(--intergalactic-rounded-small, 4px);font-size:var(--intergalactic-fs-100, 12px);line-height:var(--intergalactic-lh-100, 133%);box-shadow:var(--intergalactic-box-shadow-popper, 0px 1px 12px 0px rgba(25, 27, 35, 0.15));animation-fill-mode:both;animation-timing-function:var(--timingFunction_19wzn);animation-duration:var(--durationFinalize_19wzn);animation-name:var(--keyframesFinalize_19wzn)}.___SHintPopper_19wzn_gg_.__visible_19wzn_gg_{animation-duration:var(--durationInitialize_19wzn);animation-name:var(--keyframesInitialize_19wzn)}@media (prefers-reduced-motion){.___SHintPopper_19wzn_gg_,.___SHintPopper_19wzn_gg_.__visible_19wzn_gg_{animation-timing-function:step-end;animation-iteration-count:1}}", /*__inner_css_end__*/"19wzn_gg_"),
|
|
53
53
|
/*__reshadow_css_end__*/
|
|
54
54
|
{
|
|
55
|
-
"__SHintPopper": "
|
|
56
|
-
"_visible": "
|
|
57
|
-
"--timingFunction": "--
|
|
58
|
-
"--durationFinalize": "--
|
|
59
|
-
"--keyframesFinalize": "--
|
|
60
|
-
"--durationInitialize": "--
|
|
61
|
-
"--keyframesInitialize": "--
|
|
55
|
+
"__SHintPopper": "___SHintPopper_19wzn_gg_",
|
|
56
|
+
"_visible": "__visible_19wzn_gg_",
|
|
57
|
+
"--timingFunction": "--timingFunction_19wzn",
|
|
58
|
+
"--durationFinalize": "--durationFinalize_19wzn",
|
|
59
|
+
"--keyframesFinalize": "--keyframesFinalize_19wzn",
|
|
60
|
+
"--durationInitialize": "--durationInitialize_19wzn",
|
|
61
|
+
"--keyframesInitialize": "--keyframesInitialize_19wzn"
|
|
62
62
|
});
|
|
63
63
|
const enhances = [(0, _zIndexStacking.zIndexStackingEnhance)('z-index-tooltip'), (0, _useCssVariable.cssVariableEnhance)({
|
|
64
64
|
variable: '--intergalactic-duration-popper',
|
|
@@ -92,7 +92,7 @@ class HintPopperRoot extends _core.Component {
|
|
|
92
92
|
this.handleMouseLeave = this.handleMouseLeave.bind(this);
|
|
93
93
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
94
94
|
this.state = {
|
|
95
|
-
innerVisible:
|
|
95
|
+
innerVisible: null,
|
|
96
96
|
calculatedPlacement: props.placement
|
|
97
97
|
};
|
|
98
98
|
}
|
|
@@ -184,7 +184,6 @@ class HintPopperRoot extends _core.Component {
|
|
|
184
184
|
left: `${x}px`,
|
|
185
185
|
top: `${y}px`
|
|
186
186
|
});
|
|
187
|
-
popperElement.style.visibility = 'visible';
|
|
188
187
|
this.setState({
|
|
189
188
|
innerVisible: true,
|
|
190
189
|
calculatedPlacement: placement
|
|
@@ -202,43 +201,50 @@ class HintPopperRoot extends _core.Component {
|
|
|
202
201
|
if (this.showTimer) {
|
|
203
202
|
clearTimeout(this.showTimer);
|
|
204
203
|
}
|
|
205
|
-
this.
|
|
206
|
-
innerVisible: false
|
|
207
|
-
});
|
|
208
|
-
this.hideTimer = window.setTimeout(() => {
|
|
209
|
-
this.hintRef.current?.style.setProperty('visibility', 'hidden');
|
|
210
|
-
this.handlers.visible(false);
|
|
204
|
+
if (this.state.innerVisible) {
|
|
211
205
|
this.setState({
|
|
212
|
-
innerVisible:
|
|
206
|
+
innerVisible: false
|
|
213
207
|
});
|
|
214
|
-
|
|
208
|
+
this.hideTimer = window.setTimeout(() => {
|
|
209
|
+
this.handlers.visible(false);
|
|
210
|
+
this.setState({
|
|
211
|
+
innerVisible: null
|
|
212
|
+
});
|
|
213
|
+
}, hideTimeout);
|
|
214
|
+
}
|
|
215
215
|
}
|
|
216
216
|
handleFocus(e) {
|
|
217
|
-
if (e.target
|
|
217
|
+
if (this.isCompatibleElement(e.target) && this.sameAsTrigger(e) && _core.lastInteraction.isKeyboard()) {
|
|
218
218
|
this.showHint(e.target);
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
handleBlur(e) {
|
|
222
|
-
if (e.target
|
|
222
|
+
if (this.isCompatibleElement(e.target) && this.sameAsTrigger(e)) {
|
|
223
223
|
this.hideHint();
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
handleKeyDown(e) {
|
|
227
|
-
if (e.key === 'Escape' && e.target
|
|
227
|
+
if (e.key === 'Escape' && this.isCompatibleElement(e.target) && this.sameAsTrigger(e) && this.state.innerVisible) {
|
|
228
228
|
e.stopPropagation();
|
|
229
229
|
this.hideHint();
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
handleMouseEnter(e) {
|
|
233
|
-
if (e.target
|
|
233
|
+
if (this.isCompatibleElement(e.target) && this.sameAsTrigger(e)) {
|
|
234
234
|
this.showHint(e.target, e);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
handleMouseLeave(e) {
|
|
238
|
-
if (e.target
|
|
238
|
+
if (this.isCompatibleElement(e.target) && this.sameAsTrigger(e)) {
|
|
239
239
|
this.hideHint();
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
+
isCompatibleElement(target) {
|
|
243
|
+
return target instanceof HTMLElement || target instanceof SVGElement;
|
|
244
|
+
}
|
|
245
|
+
sameAsTrigger(e) {
|
|
246
|
+
return this.asProps.triggerRef.current === e.target;
|
|
247
|
+
}
|
|
242
248
|
keyframesKey(placement) {
|
|
243
249
|
if (!placement) {
|
|
244
250
|
return 'opacity';
|
|
@@ -289,7 +295,7 @@ class HintPopperRoot extends _core.Component {
|
|
|
289
295
|
if ((0, _canUseDOM.default)()) {
|
|
290
296
|
this.setTriggerAriaLabel();
|
|
291
297
|
}
|
|
292
|
-
if (!visible) {
|
|
298
|
+
if (!visible && innerVisible === null) {
|
|
293
299
|
return null;
|
|
294
300
|
}
|
|
295
301
|
const duration = propToArray(Number(this.asProps.duration));
|
|
@@ -306,8 +312,8 @@ class HintPopperRoot extends _core.Component {
|
|
|
306
312
|
"durationInitialize": `${duration[0]}ms`,
|
|
307
313
|
"durationFinalize": `${duration[1]}ms`,
|
|
308
314
|
"timingFunction": timingFunction,
|
|
309
|
-
"keyframesInitialize": keyframes[`@${this.keyframesKey(calculatedPlacement)}-in`],
|
|
310
|
-
"keyframesFinalize": keyframes[`@${this.keyframesKey(calculatedPlacement)}-out`],
|
|
315
|
+
"keyframesInitialize": innerVisible === true ? keyframes[`@${this.keyframesKey(calculatedPlacement)}-in`] : undefined,
|
|
316
|
+
"keyframesFinalize": innerVisible === false ? keyframes[`@${this.keyframesKey(calculatedPlacement)}-out`] : undefined,
|
|
311
317
|
"use:data-ui-name": 'Hint'
|
|
312
318
|
}, _ref)
|
|
313
319
|
}), /*#__PURE__*/_react.default.createElement(Children, _ref2.cn("Children", {}))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hint.js","names":["_core","require","_dom","_canUseDOM","_interopRequireDefault","_getAccessibleName","_useCssVariable","_zIndexStacking","_react","_Middleware","_flexBox","_portal","keyframes","sstyled","insert","styles","enhances","zIndexStackingEnhance","cssVariableEnhance","variable","fallback","map","v","Number","parseInt","toString","prop","propToArray","Array","isArray","keyframesMap","Map","HintPopperRoot","Component","constructor","props","_defineProperty2","default","React","createRef","handleFocus","bind","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","state","innerVisible","visible","calculatedPlacement","placement","uncontrolledProps","componentDidMount","triggerRef","children","asProps","trigger","current","subscribe","componentWillUnmount","unsubscribe","componentDidUpdate","prevProps","requestAnimationFrame","showHint","hideHint","addEventListener","removeEventListener","node","mouseEvent","timeout","showTimeout","hideTimer","clearTimeout","showTimer","window","setTimeout","handlers","popperElement","hintRef","middleware","offset","flip","shift","padding","verticalPlacement","startsWith","undefined","push","Middleware","verticalCursorAnchoring","x","clientX","computePosition","then","y","Object","assign","style","left","top","visibility","setState","hideTimeout","setProperty","e","target","HTMLElement","lastInteraction","isKeyboard","key","stopPropagation","keyframesKey","has","get","keyframe","set","setTriggerAriaLabel","textContent","ariaLabel","getAccessibleName","label","setAttribute","render","_ref","_ref2","SHintPopper","Box","Children","parentZIndexStacking","timingFunction","canUseDOM","duration","createElement","Portal","cn","assignProps","defaultVisible","Hint","exports","createComponent"],"sources":["../../../../src/components/hint/Hint.tsx"],"sourcesContent":["import { computePosition, flip, offset, shift, type Placement } from '@floating-ui/dom';\nimport { createComponent, Root, sstyled, Component, lastInteraction } from '@semcore/core';\nimport canUseDOM from '@semcore/core/lib/utils/canUseDOM';\nimport { getAccessibleName } from '@semcore/core/lib/utils/getAccessibleName';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport { zIndexStackingEnhance } from '@semcore/core/lib/utils/zIndexStacking';\nimport type { DataType } from 'csstype';\nimport React from 'react';\n\nimport { Middleware } from './Middleware';\nimport keyframes from '../animation/style/keyframes.shadow.css';\nimport { Box } from '../flex-box';\nimport { Portal } from '../portal';\nimport styles from './style/hint.shadow.css';\n\ntype Handlers = {\n visible: null;\n};\n\nexport type SimpleHintPopperProps = {\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>;\n /**\n * The position of the popper relative to the trigger that called it.\n * @default top\n */\n placement?: Placement;\n /**\n * Timer to show and hide the popper\n * @default [500, 500]\n */\n timeout?: DefaultProps['timeout'];\n /**\n * Hint content.\n * Better to use here some short text.\n * */\n children: React.ReactNode;\n\n /** Popper visibility value */\n visible?: boolean;\n /** Default popper visibility\n * @default false */\n defaultVisible?: boolean;\n /** Function called when visibility changes */\n onVisibleChange?: (visible: boolean, e?: Event) => boolean | void;\n};\n\ntype DefaultProps = {\n defaultVisible?: boolean;\n timeout: number | [number, number];\n timingFunction: DataType.EasingFunction;\n placement?: Placement;\n};\n\ntype State = {\n innerVisible: boolean | null;\n calculatedPlacement?: Placement;\n};\n\nconst enhances = [\n zIndexStackingEnhance('z-index-tooltip'),\n cssVariableEnhance({\n variable: '--intergalactic-duration-popper',\n fallback: '200',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'duration',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'offset',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'padding',\n }),\n] as const;\n\nfunction propToArray(prop: number | [number, number]): [number, number] {\n return Array.isArray(prop) ? prop : [prop, prop];\n}\n\nconst keyframesMap = new Map<Placement, string>();\n\nclass HintPopperRoot extends Component<SimpleHintPopperProps, typeof enhances, Handlers, DefaultProps, State> {\n public readonly hintRef = React.createRef<HTMLElement>();\n\n static style = Object.assign(keyframes, styles);\n\n private showTimer?: number;\n private hideTimer?: number;\n\n static enhance = enhances;\n\n static defaultProps: DefaultProps = {\n defaultVisible: false,\n timeout: [500, 500],\n timingFunction: 'ease-out',\n placement: 'top',\n };\n\n constructor(props: SimpleHintPopperProps) {\n super(props);\n\n this.handleFocus = this.handleFocus.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleMouseEnter = this.handleMouseEnter.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.state = {\n innerVisible: props.visible ?? null,\n calculatedPlacement: props.placement,\n };\n }\n\n uncontrolledProps() {\n return {\n visible: null,\n };\n }\n\n componentDidMount() {\n const { triggerRef, children } = this.asProps;\n const trigger = triggerRef.current;\n\n if (trigger && children) {\n this.subscribe(trigger);\n }\n }\n\n componentWillUnmount() {\n const trigger = this.asProps.triggerRef.current;\n\n if (trigger) {\n this.unsubscribe(trigger);\n }\n }\n\n componentDidUpdate(prevProps: SimpleHintPopperProps) {\n if (prevProps.visible !== this.props.visible) {\n requestAnimationFrame(() => {\n const trigger = this.props.triggerRef.current;\n\n if (this.props.visible && trigger) {\n this.showHint(trigger);\n } else {\n this.hideHint();\n }\n });\n }\n }\n\n private subscribe(trigger: HTMLElement) {\n trigger.addEventListener('focus', this.handleFocus);\n trigger.addEventListener('blur', this.handleBlur);\n trigger.addEventListener('mouseenter', this.handleMouseEnter);\n trigger.addEventListener('mouseleave', this.handleMouseLeave);\n trigger.addEventListener('keydown', this.handleKeyDown);\n\n if (this.asProps.visible) {\n this.showHint(trigger);\n }\n }\n\n private unsubscribe(trigger: HTMLElement) {\n trigger.removeEventListener('focus', this.handleFocus);\n trigger.removeEventListener('blur', this.handleBlur);\n trigger.removeEventListener('mouseenter', this.handleMouseEnter);\n trigger.removeEventListener('mouseleave', this.handleMouseLeave);\n trigger.removeEventListener('keydown', this.handleKeyDown);\n\n this.hideHint();\n }\n\n private showHint(node: HTMLElement, mouseEvent?: MouseEvent): void {\n const { placement, timeout } = this.asProps;\n\n const showTimeout = Array.isArray(timeout) ? timeout[0] : timeout;\n\n if (this.hideTimer) {\n clearTimeout(this.hideTimer);\n }\n\n this.showTimer = window.setTimeout(() => {\n this.handlers.visible(true);\n\n window.setTimeout(() => {\n const popperElement = this.hintRef.current;\n if (popperElement) {\n const middleware = [\n offset(Number(this.asProps.offset)),\n flip(),\n shift({ padding: Number(this.asProps.padding) }),\n ];\n const verticalPlacement = !placement || placement.startsWith('top') || placement.startsWith('bottom');\n if (mouseEvent !== undefined && verticalPlacement) {\n middleware.push(\n Middleware.verticalCursorAnchoring({ x: mouseEvent.clientX }),\n shift({ padding: Number(this.asProps.padding) }),\n );\n }\n\n computePosition(node, popperElement, {\n placement: placement,\n middleware,\n }).then(({ x, y, placement }) => {\n Object.assign(popperElement.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n popperElement.style.visibility = 'visible';\n\n this.setState({ innerVisible: true, calculatedPlacement: placement });\n });\n }\n }, 10);\n }, showTimeout);\n }\n\n private hideHint(): void {\n const { timeout } = this.asProps;\n\n const hideTimeout = Array.isArray(timeout) ? timeout[1] : timeout;\n\n if (this.showTimer) {\n clearTimeout(this.showTimer);\n }\n\n this.setState({ innerVisible: false });\n\n this.hideTimer = window.setTimeout(() => {\n this.hintRef.current?.style.setProperty('visibility', 'hidden');\n this.handlers.visible(false);\n this.setState({ innerVisible: null });\n }, hideTimeout);\n }\n\n private handleFocus(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && lastInteraction.isKeyboard()) {\n this.showHint(e.target);\n }\n }\n\n private handleBlur(e: FocusEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape' && e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target && this.state.innerVisible) {\n e.stopPropagation();\n this.hideHint();\n }\n }\n\n private handleMouseEnter(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.showHint(e.target, e);\n }\n }\n\n private handleMouseLeave(e: MouseEvent): void {\n if (e.target instanceof HTMLElement && this.asProps.triggerRef.current === e.target) {\n this.hideHint();\n }\n }\n\n private keyframesKey(placement?: Placement) {\n if (!placement) {\n return 'opacity';\n }\n\n if (keyframesMap.has(placement)) {\n return keyframesMap.get(placement)!;\n }\n\n let keyframe: string = 'opacity';\n\n if (placement.startsWith('left')) keyframe = 'scale-left';\n if (placement.startsWith('right')) keyframe = 'scale-right';\n if (placement.startsWith('bottom')) keyframe = 'scale-bottom';\n if (placement.startsWith('top')) keyframe = 'scale-top';\n\n keyframesMap.set(placement, keyframe);\n\n return keyframe;\n }\n\n private setTriggerAriaLabel() {\n const { triggerRef, children } = this.asProps;\n\n requestAnimationFrame(() => {\n const trigger = triggerRef.current;\n\n if (trigger) {\n const textContent = trigger.textContent;\n const ariaLabel = getAccessibleName(trigger);\n\n if (!textContent && !ariaLabel) {\n const label = (typeof children === 'string' || typeof children === 'number')\n ? children.toString()\n : (this.hintRef.current?.textContent ?? '');\n triggerRef.current?.setAttribute('aria-label', label);\n }\n }\n });\n }\n\n render() {\n const SHintPopper = Root;\n const { visible, Children, parentZIndexStacking, styles, timingFunction } = this.asProps;\n const { innerVisible, calculatedPlacement } = this.state;\n\n if (canUseDOM()) {\n this.setTriggerAriaLabel();\n }\n\n if (!visible) {\n return null;\n }\n\n const duration = propToArray(Number(this.asProps.duration));\n\n /* `visible && innerVisible === null` - is a condition to start showing right after hover/focus */\n const showHint = (visible && innerVisible === null) || innerVisible === true;\n\n return sstyled(styles)(\n <Portal>\n <SHintPopper\n render={Box}\n ref={this.hintRef}\n aria-hidden={true}\n role={undefined}\n zIndex={parentZIndexStacking}\n use:visible={showHint}\n durationInitialize={`${duration[0]}ms`}\n durationFinalize={`${duration[1]}ms`}\n timingFunction={timingFunction}\n keyframesInitialize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-in`]}\n keyframesFinalize={keyframes[`@${this.keyframesKey(calculatedPlacement)}-out`]}\n use:data-ui-name='Hint'\n >\n <Children />\n </SHintPopper>\n </Portal>,\n );\n }\n}\n\nexport const Hint = createComponent<'div', SimpleHintPopperProps>(HintPopperRoot);\n"],"mappings":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAEA,IAAAQ,WAAA,GAAAR,OAAA;AAEA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAAmC;AAAA,MAAAW,SAAA,8BAAAZ,KAAA,CAAAa,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AAAA;AAAA,MAAAC,MAAA,8BAAAf,KAAA,CAAAa,OAAA,CAAAC,MAAA;AAAA;AAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;EAAA;AAAA;AA+CnC,MAAME,QAAQ,GAAG,CACf,IAAAC,qCAAqB,EAAC,iBAAiB,CAAC,EACxC,IAAAC,kCAAkB,EAAC;EACjBC,QAAQ,EAAE,iCAAiC;EAC3CC,QAAQ,EAAE,KAAK;EACfC,GAAG,EAAGC,CAAS,IAAKC,MAAM,CAACC,QAAQ,CAACF,CAAC,EAAE,EAAE,CAAC,CAACG,QAAQ,CAAC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CAAAU,EAAA,gBAAE,CACA,CACP,CAAC;EAEb;AACF;AAAC,IAAAnG,gBAAA,CAAAC,OAAA,EAzQKL,cAAc,WAGHgE,MAAM,CAACC,MAAM,CAACrF,SAAS,EAAEG,MAAM,CAAC;AAAA,IAAAqB,gBAAA,CAAAC,OAAA,EAH3CL,cAAc,aAQDhB,QAAQ;AAAA,IAAAoB,gBAAA,CAAAC,OAAA,EARrBL,cAAc,kBAUkB;EAClCyG,cAAc,EAAE,KAAK;EACrBnE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC;EACnB4D,cAAc,EAAE,UAAU;EAC1BhF,SAAS,EAAE;AACb,CAAC;AA4PI,MAAMwF,IAAI,GAAAC,OAAA,CAAAD,IAAA,GAAG,IAAAE,qBAAe,EAA+B5G,cAAc,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Hint.js","names":["_core","require","_dom","_canUseDOM","_interopRequireDefault","_getAccessibleName","_useCssVariable","_zIndexStacking","_react","_Middleware","_flexBox","_portal","keyframes","sstyled","insert","styles","enhances","zIndexStackingEnhance","cssVariableEnhance","variable","fallback","map","v","Number","parseInt","toString","prop","propToArray","Array","isArray","keyframesMap","Map","HintPopperRoot","Component","constructor","props","_defineProperty2","default","React","createRef","handleFocus","bind","handleBlur","handleMouseEnter","handleMouseLeave","handleKeyDown","state","innerVisible","calculatedPlacement","placement","uncontrolledProps","visible","componentDidMount","triggerRef","children","asProps","trigger","current","subscribe","componentWillUnmount","unsubscribe","componentDidUpdate","prevProps","requestAnimationFrame","showHint","hideHint","addEventListener","removeEventListener","node","mouseEvent","timeout","showTimeout","hideTimer","clearTimeout","showTimer","window","setTimeout","handlers","popperElement","hintRef","middleware","offset","flip","shift","padding","verticalPlacement","startsWith","undefined","push","Middleware","verticalCursorAnchoring","x","clientX","computePosition","then","y","Object","assign","style","left","top","setState","hideTimeout","e","isCompatibleElement","target","sameAsTrigger","lastInteraction","isKeyboard","key","stopPropagation","HTMLElement","SVGElement","keyframesKey","has","get","keyframe","set","setTriggerAriaLabel","textContent","ariaLabel","getAccessibleName","label","setAttribute","render","_ref","_ref2","SHintPopper","Box","Children","parentZIndexStacking","timingFunction","canUseDOM","duration","createElement","Portal","cn","assignProps","defaultVisible","Hint","exports","createComponent"],"sources":["../../../../src/components/hint/Hint.tsx"],"sourcesContent":["import { computePosition, flip, offset, shift, type Placement } from '@floating-ui/dom';\nimport { createComponent, Root, sstyled, Component, lastInteraction } from '@semcore/core';\nimport canUseDOM from '@semcore/core/lib/utils/canUseDOM';\nimport { getAccessibleName } from '@semcore/core/lib/utils/getAccessibleName';\nimport { cssVariableEnhance } from '@semcore/core/lib/utils/useCssVariable';\nimport { zIndexStackingEnhance } from '@semcore/core/lib/utils/zIndexStacking';\nimport type { DataType } from 'csstype';\nimport React from 'react';\n\nimport { Middleware } from './Middleware';\nimport keyframes from '../animation/style/keyframes.shadow.css';\nimport { Box } from '../flex-box';\nimport { Portal } from '../portal';\nimport styles from './style/hint.shadow.css';\n\ntype Handlers = {\n visible: null;\n};\n\nexport type SimpleHintPopperProps = {\n /** Ref to the trigger element */\n triggerRef: React.RefObject<HTMLElement | null>;\n /**\n * The position of the popper relative to the trigger that called it.\n * @default top\n */\n placement?: Placement;\n /**\n * Timer to show and hide the popper\n * @default [500, 500]\n */\n timeout?: DefaultProps['timeout'];\n /**\n * Hint content.\n * Better to use here some short text.\n * */\n children: React.ReactNode;\n\n /** Popper visibility value */\n visible?: boolean;\n /** Default popper visibility\n * @default false */\n defaultVisible?: boolean;\n /** Function called when visibility changes */\n onVisibleChange?: (visible: boolean, e?: Event) => boolean | void;\n};\n\ntype DefaultProps = {\n defaultVisible?: boolean;\n timeout: number | [number, number];\n timingFunction: DataType.EasingFunction;\n placement?: Placement;\n};\n\ntype State = {\n innerVisible: boolean | null;\n calculatedPlacement?: Placement;\n};\n\nconst enhances = [\n zIndexStackingEnhance('z-index-tooltip'),\n cssVariableEnhance({\n variable: '--intergalactic-duration-popper',\n fallback: '200',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'duration',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'offset',\n }),\n cssVariableEnhance({\n variable: '--intergalactic-spacing-1x',\n fallback: '4',\n map: (v: string) => Number.parseInt(v, 10).toString(),\n prop: 'padding',\n }),\n] as const;\n\nfunction propToArray(prop: number | [number, number]): [number, number] {\n return Array.isArray(prop) ? prop : [prop, prop];\n}\n\nconst keyframesMap = new Map<Placement, string>();\n\nclass HintPopperRoot extends Component<SimpleHintPopperProps, typeof enhances, Handlers, DefaultProps, State> {\n public readonly hintRef = React.createRef<HTMLElement>();\n\n static style = Object.assign(keyframes, styles);\n\n private showTimer?: number;\n private hideTimer?: number;\n\n static enhance = enhances;\n\n static defaultProps: DefaultProps = {\n defaultVisible: false,\n timeout: [500, 500],\n timingFunction: 'ease-out',\n placement: 'top',\n };\n\n constructor(props: SimpleHintPopperProps) {\n super(props);\n\n this.handleFocus = this.handleFocus.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleMouseEnter = this.handleMouseEnter.bind(this);\n this.handleMouseLeave = this.handleMouseLeave.bind(this);\n this.handleKeyDown = this.handleKeyDown.bind(this);\n\n this.state = {\n innerVisible: null,\n calculatedPlacement: props.placement,\n };\n }\n\n uncontrolledProps() {\n return {\n visible: null,\n };\n }\n\n componentDidMount() {\n const { triggerRef, children } = this.asProps;\n const trigger = triggerRef.current;\n\n if (trigger && children) {\n this.subscribe(trigger);\n }\n }\n\n componentWillUnmount() {\n const trigger = this.asProps.triggerRef.current;\n\n if (trigger) {\n this.unsubscribe(trigger);\n }\n }\n\n componentDidUpdate(prevProps: SimpleHintPopperProps) {\n if (prevProps.visible !== this.props.visible) {\n requestAnimationFrame(() => {\n const trigger = this.props.triggerRef.current;\n\n if (this.props.visible && trigger) {\n this.showHint(trigger);\n } else {\n this.hideHint();\n }\n });\n }\n }\n\n private subscribe(trigger: HTMLElement) {\n trigger.addEventListener('focus', this.handleFocus);\n trigger.addEventListener('blur', this.handleBlur);\n trigger.addEventListener('mouseenter', this.handleMouseEnter);\n trigger.addEventListener('mouseleave', this.handleMouseLeave);\n trigger.addEventListener('keydown', this.handleKeyDown);\n\n if (this.asProps.visible) {\n this.showHint(trigger);\n }\n }\n\n private unsubscribe(trigger: HTMLElement) {\n trigger.removeEventListener('focus', this.handleFocus);\n trigger.removeEventListener('blur', this.handleBlur);\n trigger.removeEventListener('mouseenter', this.handleMouseEnter);\n trigger.removeEventListener('mouseleave', this.handleMouseLeave);\n trigger.removeEventListener('keydown', this.handleKeyDown);\n\n this.hideHint();\n }\n\n private showHint(node: Element, mouseEvent?: MouseEvent): void {\n const { placement, timeout } = this.asProps;\n\n const showTimeout = Array.isArray(timeout) ? timeout[0] : timeout;\n\n if (this.hideTimer) {\n clearTimeout(this.hideTimer);\n }\n\n this.showTimer = window.setTimeout(() => {\n this.handlers.visible(true);\n\n window.setTimeout(() => {\n const popperElement = this.hintRef.current;\n if (popperElement) {\n const middleware = [\n offset(Number(this.asProps.offset)),\n flip(),\n shift({ padding: Number(this.asProps.padding) }),\n ];\n const verticalPlacement = !placement || placement.startsWith('top') || placement.startsWith('bottom');\n if (mouseEvent !== undefined && verticalPlacement) {\n middleware.push(\n Middleware.verticalCursorAnchoring({ x: mouseEvent.clientX }),\n shift({ padding: Number(this.asProps.padding) }),\n );\n }\n\n computePosition(node, popperElement, {\n placement: placement,\n middleware,\n }).then(({ x, y, placement }) => {\n Object.assign(popperElement.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n\n this.setState({ innerVisible: true, calculatedPlacement: placement });\n });\n }\n }, 10);\n }, showTimeout);\n }\n\n private hideHint(): void {\n const { timeout } = this.asProps;\n\n const hideTimeout = Array.isArray(timeout) ? timeout[1] : timeout;\n\n if (this.showTimer) {\n clearTimeout(this.showTimer);\n }\n\n if (this.state.innerVisible) {\n this.setState({ innerVisible: false });\n\n this.hideTimer = window.setTimeout(() => {\n this.handlers.visible(false);\n this.setState({ innerVisible: null });\n }, hideTimeout);\n }\n }\n\n private handleFocus(e: FocusEvent): void {\n if (this.isCompatibleElement(e.target) && this.sameAsTrigger(e) && lastInteraction.isKeyboard()) {\n this.showHint(e.target);\n }\n }\n\n private handleBlur(e: FocusEvent): void {\n if (this.isCompatibleElement(e.target) && this.sameAsTrigger(e)) {\n this.hideHint();\n }\n }\n\n private handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape' && this.isCompatibleElement(e.target) && this.sameAsTrigger(e) && this.state.innerVisible) {\n e.stopPropagation();\n this.hideHint();\n }\n }\n\n private handleMouseEnter(e: MouseEvent): void {\n if (this.isCompatibleElement(e.target) && this.sameAsTrigger(e)) {\n this.showHint(e.target, e);\n }\n }\n\n private handleMouseLeave(e: MouseEvent): void {\n if (this.isCompatibleElement(e.target) && this.sameAsTrigger(e)) {\n this.hideHint();\n }\n }\n\n private isCompatibleElement(target: unknown): target is HTMLElement | SVGElement {\n return target instanceof HTMLElement || target instanceof SVGElement;\n }\n\n private sameAsTrigger(e: MouseEvent | KeyboardEvent | FocusEvent): boolean {\n return this.asProps.triggerRef.current === e.target;\n }\n\n private keyframesKey(placement?: Placement) {\n if (!placement) {\n return 'opacity';\n }\n\n if (keyframesMap.has(placement)) {\n return keyframesMap.get(placement)!;\n }\n\n let keyframe: string = 'opacity';\n\n if (placement.startsWith('left')) keyframe = 'scale-left';\n if (placement.startsWith('right')) keyframe = 'scale-right';\n if (placement.startsWith('bottom')) keyframe = 'scale-bottom';\n if (placement.startsWith('top')) keyframe = 'scale-top';\n\n keyframesMap.set(placement, keyframe);\n\n return keyframe;\n }\n\n private setTriggerAriaLabel() {\n const { triggerRef, children } = this.asProps;\n\n requestAnimationFrame(() => {\n const trigger = triggerRef.current;\n\n if (trigger) {\n const textContent = trigger.textContent;\n const ariaLabel = getAccessibleName(trigger);\n\n if (!textContent && !ariaLabel) {\n const label = (typeof children === 'string' || typeof children === 'number')\n ? children.toString()\n : (this.hintRef.current?.textContent ?? '');\n triggerRef.current?.setAttribute('aria-label', label);\n }\n }\n });\n }\n\n render() {\n const SHintPopper = Root;\n const { visible, Children, parentZIndexStacking, styles, timingFunction } = this.asProps;\n const { innerVisible, calculatedPlacement } = this.state;\n\n if (canUseDOM()) {\n this.setTriggerAriaLabel();\n }\n\n if (!visible && innerVisible === null) {\n return null;\n }\n\n const duration = propToArray(Number(this.asProps.duration));\n\n /* `visible && innerVisible === null` - is a condition to start showing right after hover/focus */\n const showHint = (visible && innerVisible === null) || innerVisible === true;\n\n return sstyled(styles)(\n <Portal>\n <SHintPopper\n render={Box}\n ref={this.hintRef}\n aria-hidden={true}\n role={undefined}\n zIndex={parentZIndexStacking}\n use:visible={showHint}\n durationInitialize={`${duration[0]}ms`}\n durationFinalize={`${duration[1]}ms`}\n timingFunction={timingFunction}\n keyframesInitialize={innerVisible === true ? keyframes[`@${this.keyframesKey(calculatedPlacement)}-in`] : undefined}\n keyframesFinalize={innerVisible === false ? keyframes[`@${this.keyframesKey(calculatedPlacement)}-out`] : undefined}\n use:data-ui-name='Hint'\n >\n <Children />\n </SHintPopper>\n </Portal>,\n );\n }\n}\n\nexport const Hint = createComponent<'div', SimpleHintPopperProps>(HintPopperRoot);\n"],"mappings":";;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AAEA,IAAAO,MAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAEA,IAAAQ,WAAA,GAAAR,OAAA;AAEA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AAAmC;AAAA,MAAAW,SAAA,8BAAAZ,KAAA,CAAAa,OAAA,CAAAC,MAAA;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
|
|
|
11
11
|
fn(state) {
|
|
12
12
|
const {
|
|
13
13
|
rects,
|
|
14
|
-
x
|
|
14
|
+
x,
|
|
15
|
+
elements
|
|
15
16
|
} = state;
|
|
17
|
+
const referenceLeft = elements.reference.getBoundingClientRect().left;
|
|
16
18
|
return {
|
|
17
|
-
x: rects.floating.width > rects.reference.width ? x : mouseCursorPosition.x - rects.floating.width / 2
|
|
19
|
+
x: rects.floating.width > rects.reference.width ? x : referenceLeft > rects.reference.x ? mouseCursorPosition.x - referenceLeft + rects.reference.x - rects.floating.width / 2 : mouseCursorPosition.x - rects.floating.width / 2
|
|
18
20
|
};
|
|
19
21
|
}
|
|
20
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Middleware.js","names":["Middleware","verticalCursorAnchoring","mouseCursorPosition","name","fn","state","rects","x","
|
|
1
|
+
{"version":3,"file":"Middleware.js","names":["Middleware","verticalCursorAnchoring","mouseCursorPosition","name","fn","state","rects","x","elements","referenceLeft","reference","getBoundingClientRect","left","floating","width","exports"],"sources":["../../../../src/components/hint/Middleware.ts"],"sourcesContent":["import type { MiddlewareState } from '@floating-ui/dom';\n\ntype MouseEnterCursorPosition = {\n x: number;\n};\n\nexport class Middleware {\n public static verticalCursorAnchoring(mouseCursorPosition: MouseEnterCursorPosition) {\n return {\n name: 'verticalCursorAnchoring',\n fn(state: MiddlewareState) {\n const { rects, x, elements } = state;\n const referenceLeft = elements.reference.getBoundingClientRect().left;\n\n return {\n x: rects.floating.width > rects.reference.width\n ? x\n : referenceLeft > rects.reference.x\n ? mouseCursorPosition.x - referenceLeft + rects.reference.x - rects.floating.width / 2\n : mouseCursorPosition.x - rects.floating.width / 2,\n };\n },\n };\n }\n}\n"],"mappings":";;;;;;AAMO,MAAMA,UAAU,CAAC;EACtB,OAAcC,uBAAuBA,CAACC,mBAA6C,EAAE;IACnF,OAAO;MACLC,IAAI,EAAE,yBAAyB;MAC/BC,EAAEA,CAACC,KAAsB,EAAE;QACzB,MAAM;UAAEC,KAAK;UAAEC,CAAC;UAAEC;QAAS,CAAC,GAAGH,KAAK;QACpC,MAAMI,aAAa,GAAGD,QAAQ,CAACE,SAAS,CAACC,qBAAqB,CAAC,CAAC,CAACC,IAAI;QAErE,OAAO;UACLL,CAAC,EAAED,KAAK,CAACO,QAAQ,CAACC,KAAK,GAAGR,KAAK,CAACI,SAAS,CAACI,KAAK,GAC3CP,CAAC,GACDE,aAAa,GAAGH,KAAK,CAACI,SAAS,CAACH,CAAC,GAC/BL,mBAAmB,CAACK,CAAC,GAAGE,aAAa,GAAGH,KAAK,CAACI,SAAS,CAACH,CAAC,GAAGD,KAAK,CAACO,QAAQ,CAACC,KAAK,GAAG,CAAC,GACpFZ,mBAAmB,CAACK,CAAC,GAAGD,KAAK,CAACO,QAAQ,CAACC,KAAK,GAAG;QACvD,CAAC;MACH;IACF,CAAC;EACH;AACF;AAACC,OAAA,CAAAf,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -4,8 +4,9 @@ SHintPopper {
|
|
|
4
4
|
top: 0;
|
|
5
5
|
left: 0;
|
|
6
6
|
max-width: 250px;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
overflow-wrap: break-word;
|
|
8
|
+
opacity: 0;
|
|
9
|
+
pointer-events: none;
|
|
9
10
|
|
|
10
11
|
background: var(--intergalactic-tooltip-invert, #191b23);
|
|
11
12
|
border: 1px solid var(--intergalactic-border-tooltip-invert, #6c6e79);
|