@primer/react 0.0.0-20260226121350 → 0.0.0-20260226124445
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
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../src/TextInput/TextInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAwD,MAAM,OAAO,CAAA;AAE5E,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAO/F,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAA;AAQ/E,MAAM,MAAM,4BAA4B,GAAG;IACzC,uEAAuE;IACvE,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACxB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;QAKI;IACJ,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;IAChD,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAA;IACnD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAA;IACpD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACvE;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,OAAO,CACT,IAAI,CACF,kBAAkB,EAChB,OAAO,GACP,UAAU,GACV,UAAU,GACV,WAAW,GACX,OAAO,GACP,UAAU,GACV,UAAU,GACV,SAAS,GACT,MAAM,GACN,kB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A;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,4BAA4B,CAAC,CAAA;;;;;;;;;;;AA+PzG,wBAGE"}
|
|
@@ -51,6 +51,10 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
51
51
|
const [isOverLimit, setIsOverLimit] = useState(false);
|
|
52
52
|
const [screenReaderMessage, setScreenReaderMessage] = useState('');
|
|
53
53
|
const characterCounterRef = useRef(null);
|
|
54
|
+
const lastCountedLengthRef = useRef(null);
|
|
55
|
+
const lastCharacterCountRef = useRef('');
|
|
56
|
+
const lastIsOverLimitRef = useRef(false);
|
|
57
|
+
const lastScreenReaderMessageRef = useRef('');
|
|
54
58
|
|
|
55
59
|
// this class is necessary to style FilterSearch, plz no touchy!
|
|
56
60
|
const wrapperClasses = clsx(className, 'TextInput-wrapper');
|
|
@@ -84,17 +88,31 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
84
88
|
if (characterLimit) {
|
|
85
89
|
characterCounterRef.current = new CharacterCounter({
|
|
86
90
|
onCountUpdate: (count, overLimit, message) => {
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
if (message !== lastCharacterCountRef.current) {
|
|
92
|
+
lastCharacterCountRef.current = message;
|
|
93
|
+
setCharacterCount(message);
|
|
94
|
+
}
|
|
95
|
+
if (overLimit !== lastIsOverLimitRef.current) {
|
|
96
|
+
lastIsOverLimitRef.current = overLimit;
|
|
97
|
+
setIsOverLimit(overLimit);
|
|
98
|
+
}
|
|
89
99
|
},
|
|
90
100
|
onScreenReaderAnnounce: message_0 => {
|
|
91
|
-
|
|
101
|
+
if (message_0 !== lastScreenReaderMessageRef.current) {
|
|
102
|
+
lastScreenReaderMessageRef.current = message_0;
|
|
103
|
+
setScreenReaderMessage(message_0);
|
|
104
|
+
}
|
|
92
105
|
}
|
|
93
106
|
});
|
|
107
|
+
lastCountedLengthRef.current = null;
|
|
94
108
|
return () => {
|
|
95
109
|
var _characterCounterRef$;
|
|
96
110
|
(_characterCounterRef$ = characterCounterRef.current) === null || _characterCounterRef$ === void 0 ? void 0 : _characterCounterRef$.cleanup();
|
|
97
111
|
characterCounterRef.current = null;
|
|
112
|
+
lastCountedLengthRef.current = null;
|
|
113
|
+
lastCharacterCountRef.current = '';
|
|
114
|
+
lastIsOverLimitRef.current = false;
|
|
115
|
+
lastScreenReaderMessageRef.current = '';
|
|
98
116
|
};
|
|
99
117
|
}
|
|
100
118
|
}, [characterLimit]);
|
|
@@ -103,14 +121,22 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
103
121
|
useEffect(() => {
|
|
104
122
|
if (characterLimit && characterCounterRef.current) {
|
|
105
123
|
const currentValue = value !== undefined ? String(value) : defaultValue !== undefined ? String(defaultValue) : '';
|
|
106
|
-
|
|
124
|
+
const currentLength = currentValue.length;
|
|
125
|
+
if (currentLength !== lastCountedLengthRef.current) {
|
|
126
|
+
lastCountedLengthRef.current = currentLength;
|
|
127
|
+
characterCounterRef.current.updateCharacterCount(currentLength, characterLimit);
|
|
128
|
+
}
|
|
107
129
|
}
|
|
108
130
|
}, [value, defaultValue, characterLimit]);
|
|
109
131
|
|
|
110
132
|
// Handle input change with character counter
|
|
111
133
|
const handleInputChange = useCallback(e_2 => {
|
|
112
134
|
if (characterLimit && characterCounterRef.current) {
|
|
113
|
-
|
|
135
|
+
const currentLength_0 = e_2.target.value.length;
|
|
136
|
+
if (currentLength_0 !== lastCountedLengthRef.current) {
|
|
137
|
+
lastCountedLengthRef.current = currentLength_0;
|
|
138
|
+
characterCounterRef.current.updateCharacterCount(currentLength_0, characterLimit);
|
|
139
|
+
}
|
|
114
140
|
}
|
|
115
141
|
onChange === null || onChange === void 0 ? void 0 : onChange(e_2);
|
|
116
142
|
}, [onChange, characterLimit]);
|
package/package.json
CHANGED