@rockshin/tao-ui 0.0.52 → 0.0.54

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.
@@ -106,9 +106,14 @@
106
106
  padding-inline-end: var(--tao-control-height);
107
107
  }
108
108
 
109
+ :where([data-tao-textarea]:has( > [data-tao-input-count]) textarea) {
110
+ padding-inline-end: calc(var(--tao-textarea-count-width, 0px) + var(--tao-padding-md) +
111
+ var(--tao-padding-xs));
112
+ }
113
+
109
114
  [data-tao-textarea] > [data-tao-input-count] {
110
- text-align: end;
111
- padding: 0 var(--tao-padding-xs) var(--tao-padding-xxs);
112
- display: block;
115
+ position: absolute;
116
+ inset-block-end: var(--tao-padding-xxs);
117
+ inset-inline-end: var(--tao-padding-md);
113
118
  }
114
119
 
@@ -18,7 +18,9 @@ const textarea_Textarea = /*#__PURE__*/ forwardRef(function(props, ref) {
18
18
  const resolvedDisabled = disabled ?? ctx.disabled;
19
19
  const innerRef = useRef(null);
20
20
  const rootRef = useRef(null);
21
+ const countRef = useRef(null);
21
22
  const field = useTextControl(props, innerRef);
23
+ const hasCount = null != field.counter;
22
24
  useTextControlRef(ref, innerRef, rootRef);
23
25
  const [measuredStyle, setMeasuredStyle] = useState();
24
26
  const resize = useCallback(()=>{
@@ -57,20 +59,38 @@ const textarea_Textarea = /*#__PURE__*/ forwardRef(function(props, ref) {
57
59
  resize,
58
60
  field.value
59
61
  ]);
62
+ useLayoutEffect(()=>{
63
+ if (!hasCount) return;
64
+ const count_0 = countRef.current;
65
+ const root = rootRef.current;
66
+ if (!count_0 || !root) return;
67
+ const update = ()=>{
68
+ root.style.setProperty('--tao-textarea-count-width', `${count_0.offsetWidth}px`);
69
+ };
70
+ update();
71
+ const observer = new ResizeObserver(update);
72
+ observer.observe(count_0);
73
+ return ()=>{
74
+ observer.disconnect();
75
+ root.style.removeProperty('--tao-textarea-count-width');
76
+ };
77
+ }, [
78
+ hasCount
79
+ ]);
60
80
  useLayoutEffect(()=>{
61
81
  const el_0 = innerRef.current;
62
82
  if (!el_0 || !autoSize) return;
63
83
  let width;
64
84
  let frame = 0;
65
- const observer = new ResizeObserver(([entry])=>{
85
+ const observer_0 = new ResizeObserver(([entry])=>{
66
86
  if (entry.contentRect.width === width) return;
67
87
  width = entry.contentRect.width;
68
88
  cancelAnimationFrame(frame);
69
89
  frame = requestAnimationFrame(resize);
70
90
  });
71
- observer.observe(el_0);
91
+ observer_0.observe(el_0);
72
92
  return ()=>{
73
- observer.disconnect();
93
+ observer_0.disconnect();
74
94
  cancelAnimationFrame(frame);
75
95
  };
76
96
  }, [
@@ -125,7 +145,8 @@ const textarea_Textarea = /*#__PURE__*/ forwardRef(function(props, ref) {
125
145
  className: classNames?.clear,
126
146
  style: styles?.clear
127
147
  }),
128
- null != field.counter && /*#__PURE__*/ jsx("span", {
148
+ hasCount && /*#__PURE__*/ jsx("span", {
149
+ ref: countRef,
129
150
  "data-tao-input-count": "",
130
151
  "data-tao-exceeded": field.exceeded || void 0,
131
152
  className: classNames?.count,
@@ -306,6 +306,7 @@
306
306
  width: 26px;
307
307
  height: 28px;
308
308
  color: var(--tao-color-text-light-solid);
309
+ background: none;
309
310
  }
310
311
 
311
312
  & [data-tao-upload-actions] button:disabled {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockshin/tao-ui",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "type": "module",
5
5
  "description": "A modern React component library with semantic DOM customization and OKLCH-based theming.",
6
6
  "keywords": [