@vkontakte/vkui 4.33.1 → 4.33.2

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.
Files changed (40) hide show
  1. package/.cache/.eslintcache +1 -1
  2. package/.cache/.stylelintcache +1 -1
  3. package/.cache/.tsbuildinfo +5 -6
  4. package/.cache/ts/src/components/Typography/Title/Title.d.ts +1 -1
  5. package/dist/cjs/components/ModalRoot/ModalRoot.js +8 -2
  6. package/dist/cjs/components/ModalRoot/ModalRoot.js.map +1 -1
  7. package/dist/cjs/components/Typography/Title/Title.d.ts +1 -1
  8. package/dist/cjs/components/Typography/Title/Title.js.map +1 -1
  9. package/dist/cjs/components/WriteBar/WriteBar.js +9 -29
  10. package/dist/cjs/components/WriteBar/WriteBar.js.map +1 -1
  11. package/dist/cjs/lib/polyfills.js +20 -0
  12. package/dist/cjs/lib/polyfills.js.map +1 -1
  13. package/dist/components/ModalRoot/ModalRoot.js +8 -2
  14. package/dist/components/ModalRoot/ModalRoot.js.map +1 -1
  15. package/dist/components/Typography/Title/Title.d.ts +1 -1
  16. package/dist/components/Typography/Title/Title.js.map +1 -1
  17. package/dist/components/WriteBar/WriteBar.js +9 -28
  18. package/dist/components/WriteBar/WriteBar.js.map +1 -1
  19. package/dist/components.css +1 -1
  20. package/dist/components.css.map +1 -1
  21. package/dist/cssm/components/ModalCard/ModalCard.css +1 -1
  22. package/dist/cssm/components/ModalRoot/ModalRoot.js +8 -2
  23. package/dist/cssm/components/ModalRoot/ModalRoot.js.map +1 -1
  24. package/dist/cssm/components/Typography/Title/Title.d.ts +1 -1
  25. package/dist/cssm/components/Typography/Title/Title.js.map +1 -1
  26. package/dist/cssm/components/WriteBar/WriteBar.js +9 -28
  27. package/dist/cssm/components/WriteBar/WriteBar.js.map +1 -1
  28. package/dist/cssm/lib/polyfills.js +20 -0
  29. package/dist/cssm/lib/polyfills.js.map +1 -1
  30. package/dist/cssm/styles/components.css +1 -1
  31. package/dist/lib/polyfills.js +20 -0
  32. package/dist/lib/polyfills.js.map +1 -1
  33. package/dist/vkui.css +1 -1
  34. package/dist/vkui.css.map +1 -1
  35. package/package.json +1 -1
  36. package/src/components/ModalCard/ModalCard.css +1 -1
  37. package/src/components/ModalRoot/ModalRoot.tsx +7 -1
  38. package/src/components/Typography/Title/Title.tsx +1 -1
  39. package/src/components/WriteBar/WriteBar.tsx +13 -27
  40. package/src/lib/polyfills.ts +17 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/vkui",
3
- "version": "4.33.1",
3
+ "version": "4.33.2",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  width: 100%;
16
16
  margin-left: auto;
17
17
  margin-right: auto;
18
- transform: translateY(100%);
18
+ transform: translateY(calc(100% + 16px));
19
19
  }
20
20
 
21
21
  /**
@@ -362,7 +362,7 @@ class ModalRootTouchComponent extends React.Component<
362
362
 
363
363
  if (!this.state.touchDown) {
364
364
  modalState.touchStartContentScrollTop =
365
- modalState.contentElement?.scrollTop;
365
+ modalState.contentElement?.scrollTop ?? 0;
366
366
  this.setState({ touchDown: true });
367
367
  }
368
368
 
@@ -830,6 +830,12 @@ function initPageModal(modalState: ModalsStateEntry) {
830
830
  translateY = 0;
831
831
  }
832
832
 
833
+ // Если модалка уже раскрыта обновляем состояния
834
+ if (translateY === 0) {
835
+ expanded = true;
836
+ collapsed = false;
837
+ }
838
+
833
839
  modalState.expandedRange = expandedRange;
834
840
  modalState.collapsedRange = collapsedRange;
835
841
  modalState.hiddenRange = hiddenRange;
@@ -21,7 +21,7 @@ export interface TitleProps
21
21
  | "1"
22
22
  | "2"
23
23
  | "3";
24
- level: "1" | "2" | "3";
24
+ level?: "1" | "2" | "3";
25
25
  }
26
26
 
27
27
  const warn = warnOnce("Title");
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import { usePlatform } from "../../hooks/usePlatform";
3
3
  import { useExternRef } from "../../hooks/useExternRef";
4
4
  import { hasReactNode, isFunction } from "../../lib/utils";
5
- import { useDOM } from "../../lib/dom";
6
5
  import { getClassName } from "../../helpers/getClassName";
7
6
  import { HasRef, HasRootRef } from "../../types";
8
7
  import "./WriteBar.css";
@@ -55,9 +54,8 @@ export const WriteBar: React.FC<WriteBarProps> = (props: WriteBarProps) => {
55
54
 
56
55
  const isControlledOutside = value != null;
57
56
 
58
- const { window } = useDOM();
59
57
  const textareaRef = useExternRef(getRef);
60
- const textareaMinHeightRef = React.useRef<number | null>(null);
58
+ const currentScrollHeight = React.useRef<number>();
61
59
 
62
60
  const resize = React.useCallback(() => {
63
61
  const textareaEl = textareaRef.current;
@@ -65,31 +63,19 @@ export const WriteBar: React.FC<WriteBarProps> = (props: WriteBarProps) => {
65
63
  return;
66
64
  }
67
65
 
68
- const { offsetHeight, scrollHeight } = textareaEl;
69
- const style = window!.getComputedStyle(textareaEl);
70
- const paddingTop = parseInt(style.paddingTop);
71
- const paddingBottom = parseInt(style.paddingBottom);
72
-
73
- if (textareaMinHeightRef.current === null) {
74
- textareaMinHeightRef.current = offsetHeight;
75
- }
76
-
77
- let diff = paddingTop + paddingBottom + 10;
78
-
79
- if (scrollHeight + diff <= offsetHeight) {
80
- diff = 0;
81
- }
82
-
83
- textareaEl.style.height = "0px";
84
-
85
- const height = textareaEl.scrollHeight - diff / 4;
86
- textareaEl.style.height =
87
- String(Math.max(height, textareaMinHeightRef.current)) + "px";
88
-
89
- if (isFunction(onHeightChange)) {
90
- onHeightChange();
66
+ if (textareaEl.offsetParent) {
67
+ textareaEl.style.height = "";
68
+ textareaEl.style.height = `${textareaEl.scrollHeight}px`;
69
+
70
+ if (
71
+ textareaEl.scrollHeight !== currentScrollHeight.current &&
72
+ onHeightChange
73
+ ) {
74
+ onHeightChange();
75
+ currentScrollHeight.current = textareaEl.scrollHeight;
76
+ }
91
77
  }
92
- }, [onHeightChange, textareaRef, window]);
78
+ }, [onHeightChange, textareaRef]);
93
79
 
94
80
  const onTextareaChange: React.ChangeEventHandler<HTMLTextAreaElement> = (
95
81
  event
@@ -94,3 +94,20 @@ if (!Array.prototype.find) {
94
94
  },
95
95
  });
96
96
  }
97
+
98
+ // String.prototype.padStart
99
+ if (!String.prototype.padStart) {
100
+ String.prototype.padStart = function padStart(targetLength, padString) {
101
+ targetLength = targetLength >> 0;
102
+ padString = String(padString || " ");
103
+ if (this.length > targetLength) {
104
+ return String(this);
105
+ } else {
106
+ targetLength = targetLength - this.length;
107
+ if (targetLength > padString.length) {
108
+ padString += padString.repeat(targetLength / padString.length);
109
+ }
110
+ return padString.slice(0, targetLength) + String(this);
111
+ }
112
+ };
113
+ }