@rockshin/tao-ui 0.0.53 → 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.
@@ -5,11 +5,6 @@
5
5
  display: block;
6
6
  }
7
7
 
8
- [data-tao-textarea]:has( > [data-tao-input-count]) {
9
- grid-template-columns: minmax(0, 1fr) max-content;
10
- display: grid;
11
- }
12
-
13
8
  [data-tao-textarea][data-tao-size="small"] {
14
9
  border-radius: var(--tao-radius-sm);
15
10
  }
@@ -102,7 +97,6 @@
102
97
  }
103
98
 
104
99
  [data-tao-textarea] > [data-tao-input-clear] {
105
- grid-area: 1 / 1 / 2 / 2;
106
100
  position: absolute;
107
101
  inset-block-start: var(--tao-padding-xxs);
108
102
  inset-inline-end: var(--tao-padding-xxs);
@@ -112,10 +106,14 @@
112
106
  padding-inline-end: var(--tao-control-height);
113
107
  }
114
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
+
115
114
  [data-tao-textarea] > [data-tao-input-count] {
116
- text-align: end;
117
- padding-inline: var(--tao-padding-xxs) var(--tao-padding-xs);
118
- align-self: end;
119
- padding-block-end: var(--tao-padding-xxs);
115
+ position: absolute;
116
+ inset-block-end: var(--tao-padding-xxs);
117
+ inset-inline-end: var(--tao-padding-md);
120
118
  }
121
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rockshin/tao-ui",
3
- "version": "0.0.53",
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": [