pds-dev-kit-web-test 2.2.85 → 2.2.87

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.
@@ -63,7 +63,9 @@ function Text(props) {
63
63
  var hasEffect = !isNoneEffectType;
64
64
  var effectVisibleStyle = hasEffect ? { opacity: isVisible ? 1 : 0 } : {};
65
65
  var baseFontSize = (0, useMaxFontAdjustment_1.default)(cbRef, textStyle.fontSize, mode);
66
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isEditModeAndHidden && (0, jsx_runtime_1.jsx)(S_HiddenCover_1.S_HiddenCover, {}), (0, jsx_runtime_1.jsx)(S_CB_AnimationObserverBox_1.S_CB_AnimationObserverBox, __assign({ ref: hasEffect ? cbRef : null, effectVisibleStyle: effectVisibleStyle }, { children: (0, jsx_runtime_1.jsx)(S_CB_Box_1.S_CB_Box, __assign({ className: "cb-layout-box cb-text-box", normalStyle: __assign(__assign(__assign(__assign(__assign({}, textStyle), propsStyle), effectCssProperties), layoutStyle), { cursor: CLINKCursor, paddingTop: 0, paddingBottom: 0, paddingLeft: 0, paddingRight: 0, fontSize: baseFontSize }), hoverStyle: __assign(__assign({}, textHoverStyle), propsHoverStyle), onClick: onClickCLINK }, { children: (0, jsx_runtime_1.jsx)(S_TextContent, __assign({ className: "cb-text-content", style: {
66
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isEditModeAndHidden && (0, jsx_runtime_1.jsx)(S_HiddenCover_1.S_HiddenCover, {}), (0, jsx_runtime_1.jsx)(S_CB_AnimationObserverBox_1.S_CB_AnimationObserverBox, __assign({ ref: hasEffect ? cbRef : null, effectVisibleStyle: effectVisibleStyle, style: {
67
+ fontSize: "".concat(baseFontSize, "px")
68
+ } }, { children: (0, jsx_runtime_1.jsx)(S_CB_Box_1.S_CB_Box, __assign({ className: "cb-layout-box cb-text-box", normalStyle: __assign(__assign(__assign(__assign(__assign({}, textStyle), propsStyle), effectCssProperties), layoutStyle), { cursor: CLINKCursor, paddingTop: 0, paddingBottom: 0, paddingLeft: 0, paddingRight: 0 }), hoverStyle: __assign(__assign({}, textHoverStyle), propsHoverStyle), onClick: onClickCLINK }, { children: (0, jsx_runtime_1.jsx)(S_TextContent, __assign({ className: "cb-text-content", style: {
67
69
  whiteSpace: 'pre-wrap',
68
70
  wordBreak: 'break-word',
69
71
  height: 'fit-content',
@@ -1,3 +1,4 @@
1
+ import { RefObject } from 'react';
1
2
  import type { DynamicLayoutProps } from '../../../../../../../DynamicLayout/types';
2
- declare const useMaxFontAdjustment: (ref: any, defaultSize: string, mode: DynamicLayoutProps['mode']) => string;
3
+ declare const useMaxFontAdjustment: (ref: RefObject<HTMLDivElement>, defaultSize: string, mode: DynamicLayoutProps['mode']) => number;
3
4
  export default useMaxFontAdjustment;
@@ -1,27 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  var react_1 = require("react");
4
+ var DEFAULT_BASE_FONT = 16;
4
5
  var useMaxFontAdjustment = function (ref, defaultSize, mode) {
5
- var _a = (0, react_1.useState)(defaultSize), fontSize = _a[0], setFontSize = _a[1];
6
+ var _a = (0, react_1.useState)(DEFAULT_BASE_FONT), fontSize = _a[0], setFontSize = _a[1];
7
+ var ogRef = (0, react_1.useRef)(0);
6
8
  (0, react_1.useEffect)(function () {
7
9
  if (mode !== 'PREVIEW') {
8
10
  return;
9
11
  }
10
12
  if (!ref.current)
11
13
  return;
14
+ if (fontSize === 16) {
15
+ var boxHeight = ref.current.clientHeight;
16
+ var contentHeight = ref.current.children[0].children[0].clientHeight;
17
+ var percent = (contentHeight / boxHeight) * 100;
18
+ ogRef.current = percent;
19
+ }
12
20
  var resizeObserver = new ResizeObserver(function (callback) {
13
21
  var object = callback[0];
14
- var height = object.contentRect.height;
22
+ var height = object.target.clientHeight;
15
23
  var contentHeight = object.target.children[0].children[0].clientHeight;
24
+ var p = (contentHeight / height) * 100;
16
25
  var isOverflow = contentHeight > height;
17
- if (isOverflow) {
18
- setFontSize(function (prev) {
19
- var value = parseEmToNumber(prev);
20
- if (value === null) {
21
- return prev;
22
- }
23
- return "".concat((value - 0.3).toFixed(3), "em");
24
- });
26
+ var hasContentGap = p > ogRef.current;
27
+ if (isOverflow || hasContentGap) {
28
+ setFontSize(function (prev) { return Number((prev - 0.3).toFixed(3)); });
29
+ // setFontSize((prev) => {
30
+ // const value = parseEmToNumber(prev);
31
+ // if (value === null) {
32
+ // return prev;
33
+ // }
34
+ // return `${(value - 0.3).toFixed(3)}em`;
35
+ // });
25
36
  }
26
37
  });
27
38
  resizeObserver.observe(ref.current);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "2.2.85",
3
+ "version": "2.2.87",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",