@primer/react 0.0.0-20260624193537 → 0.0.0-20260624200955
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 +26 -2
- package/dist/ButtonGroup/ButtonGroup-be1c1123.css +2 -0
- package/dist/ButtonGroup/ButtonGroup-be1c1123.css.map +1 -0
- package/dist/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup/ButtonGroup.js +1 -0
- package/dist/ButtonGroup/ButtonGroup.module.css.js +2 -2
- package/dist/Checkbox/Checkbox-7476a7ba.css +2 -0
- package/dist/Checkbox/Checkbox-7476a7ba.css.map +1 -0
- package/dist/Checkbox/Checkbox.module.css.js +1 -1
- package/dist/ConfirmationDialog/useConfirm.d.ts.map +1 -1
- package/dist/ConfirmationDialog/useConfirm.js +4 -8
- package/dist/DataTable/Pagination-aebe86e8.css +2 -0
- package/dist/DataTable/Pagination-aebe86e8.css.map +1 -0
- package/dist/DataTable/Pagination.module.css.js +1 -1
- package/dist/Radio/Radio.d.ts.map +1 -1
- package/dist/Radio/Radio.js +2 -1
- package/dist/RadioGroup/RadioGroup.js +1 -0
- package/dist/RelativeTime/RelativeTime.js +1 -0
- package/dist/ScrollableRegion/ScrollableRegion.d.ts.map +1 -1
- package/dist/ScrollableRegion/ScrollableRegion.js +1 -0
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +1 -0
- package/dist/SegmentedControl/SegmentedControlButton.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlButton.js +1 -0
- package/dist/SegmentedControl/SegmentedControlIconButton.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlIconButton.js +1 -0
- package/dist/Select/Select.d.ts.map +1 -1
- package/dist/Select/Select.js +6 -2
- package/dist/SelectPanel/SelectPanel.d.ts +2 -2
- package/dist/SelectPanel/SelectPanel.d.ts.map +1 -1
- package/dist/SelectPanel/SelectPanel.js +4 -1
- package/dist/SideNav.d.ts.map +1 -1
- package/dist/SideNav.js +2 -0
- package/dist/Skeleton/SkeletonBox.d.ts +1 -0
- package/dist/Skeleton/SkeletonBox.d.ts.map +1 -1
- package/dist/Skeleton/SkeletonBox.js +54 -47
- package/dist/SkeletonText/SkeletonText.d.ts.map +1 -1
- package/dist/SkeletonText/SkeletonText.js +2 -2
- package/dist/Spinner/Spinner.js +1 -0
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +27 -68
- package/dist/Textarea/Textarea.d.ts.map +1 -1
- package/dist/Textarea/Textarea.js +158 -186
- package/dist/UnderlineNav/UnderlineNav-4344d9b0.css +2 -0
- package/dist/UnderlineNav/UnderlineNav-4344d9b0.css.map +1 -0
- package/dist/UnderlineNav/UnderlineNav.d.ts +2 -1
- package/dist/UnderlineNav/UnderlineNav.d.ts.map +1 -1
- package/dist/UnderlineNav/UnderlineNav.js +331 -91
- package/dist/UnderlineNav/UnderlineNav.module.css.js +2 -2
- package/dist/UnderlineNav/UnderlineNavContext.d.ts +11 -1
- package/dist/UnderlineNav/UnderlineNavContext.d.ts.map +1 -1
- package/dist/UnderlineNav/UnderlineNavContext.js +4 -1
- package/dist/UnderlineNav/UnderlineNavItem-b65e8fd3.css +2 -0
- package/dist/UnderlineNav/UnderlineNavItem-b65e8fd3.css.map +1 -0
- package/dist/UnderlineNav/UnderlineNavItem.d.ts +44 -1
- package/dist/UnderlineNav/UnderlineNavItem.d.ts.map +1 -1
- package/dist/UnderlineNav/UnderlineNavItem.js +38 -33
- package/dist/UnderlineNav/UnderlineNavItem.module.css.js +1 -1
- package/dist/UnderlineNav/index.d.ts +1 -1
- package/dist/UnderlineNav/index.d.ts.map +1 -1
- package/dist/UnderlineNav/styles.d.ts +16 -0
- package/dist/UnderlineNav/styles.d.ts.map +1 -0
- package/dist/UnderlineNav/styles.js +19 -0
- package/dist/UnderlineNav/types.d.ts +10 -0
- package/dist/UnderlineNav/types.d.ts.map +1 -0
- package/dist/UnderlineNav/utils.d.ts +0 -2
- package/dist/UnderlineNav/utils.d.ts.map +1 -1
- package/dist/UnderlineNav/utils.js +1 -2
- package/dist/_VisuallyHidden.js +2 -2
- package/dist/_VisuallyHidden.module.css.js +2 -2
- package/dist/experimental/UnderlinePanels/UnderlinePanels-e4b325b9.css +2 -0
- package/dist/experimental/UnderlinePanels/UnderlinePanels-e4b325b9.css.map +1 -0
- package/dist/experimental/UnderlinePanels/UnderlinePanels.d.ts.map +1 -1
- package/dist/experimental/UnderlinePanels/UnderlinePanels.js +11 -8
- package/dist/experimental/UnderlinePanels/UnderlinePanels.module.css.js +1 -1
- package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css +2 -0
- package/dist/internal/components/UnderlineTabbedInterface-4197ee28.css.map +1 -0
- package/dist/internal/components/UnderlineTabbedInterface.d.ts +1 -0
- package/dist/internal/components/UnderlineTabbedInterface.d.ts.map +1 -1
- package/dist/internal/components/UnderlineTabbedInterface.js +60 -66
- package/dist/internal/components/UnderlineTabbedInterface.module.css.js +1 -1
- package/dist/live-region/Announce.d.ts.map +1 -1
- package/dist/live-region/Announce.js +51 -36
- package/dist/utils/character-counter.d.ts +16 -21
- package/dist/utils/character-counter.d.ts.map +1 -1
- package/dist/utils/character-counter.js +23 -59
- package/generated/components.json +2 -2
- package/package.json +2 -2
- package/dist/ButtonGroup/ButtonGroup-54ba293b.css +0 -2
- package/dist/ButtonGroup/ButtonGroup-54ba293b.css.map +0 -1
- package/dist/Checkbox/Checkbox-edc5dc3e.css +0 -2
- package/dist/Checkbox/Checkbox-edc5dc3e.css.map +0 -1
- package/dist/DataTable/Pagination-b6f8418c.css +0 -2
- package/dist/DataTable/Pagination-b6f8418c.css.map +0 -1
- package/dist/UnderlineNav/UnderlineNav-b4b22899.css +0 -2
- package/dist/UnderlineNav/UnderlineNav-b4b22899.css.map +0 -1
- package/dist/UnderlineNav/UnderlineNavItem-402cd41c.css +0 -2
- package/dist/UnderlineNav/UnderlineNavItem-402cd41c.css.map +0 -1
- package/dist/UnderlineNav/UnderlineNavItemsRegistry.d.ts +0 -51
- package/dist/UnderlineNav/UnderlineNavItemsRegistry.d.ts.map +0 -1
- package/dist/UnderlineNav/UnderlineNavItemsRegistry.js +0 -8
- package/dist/experimental/UnderlinePanels/UnderlinePanels-162f9aed.css +0 -2
- package/dist/experimental/UnderlinePanels/UnderlinePanels-162f9aed.css.map +0 -1
- package/dist/internal/components/UnderlineTabbedInterface-1745a3d6.css +0 -2
- package/dist/internal/components/UnderlineTabbedInterface-1745a3d6.css.map +0 -1
package/dist/Spinner/Spinner.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../src/TextInput/TextInput.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../src/TextInput/TextInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqC,MAAM,OAAO,CAAA;AAEzD,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;AAU/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;IACvB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,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,kBAAkB,CACrB,CACF,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,4BAA4B,CAAC,CAAA;;;;;;;;;;;AAyNzG,wBAGE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState,
|
|
1
|
+
import React, { useState, useId, useCallback } from 'react';
|
|
2
2
|
import { isValidElementType } from 'react-is';
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { AlertFillIcon } from '@primer/octicons-react';
|
|
@@ -8,9 +8,11 @@ import { TextInputWrapper } from '../internal/components/TextInputWrapper.js';
|
|
|
8
8
|
import TextInputAction from '../internal/components/TextInputInnerAction.js';
|
|
9
9
|
import UnstyledTextInput from '../internal/components/UnstyledTextInput.js';
|
|
10
10
|
import VisuallyHidden from '../_VisuallyHidden.js';
|
|
11
|
-
import
|
|
11
|
+
import visuallyHiddenClasses from '../_VisuallyHidden.module.css.js';
|
|
12
|
+
import { SCREEN_READER_DELAY, getCharacterCountState } from '../utils/character-counter.js';
|
|
12
13
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
13
14
|
import { useProvidedRefOrCreate } from '../hooks/useProvidedRefOrCreate.js';
|
|
15
|
+
import { AriaStatus } from '../live-region/AriaStatus.js';
|
|
14
16
|
import Text from '../Text/Text.js';
|
|
15
17
|
|
|
16
18
|
// using forwardRef is important so that other components can autofocus the input
|
|
@@ -46,16 +48,22 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
46
48
|
'data-component': dataComponent,
|
|
47
49
|
...inputProps
|
|
48
50
|
}, ref) => {
|
|
51
|
+
var _counter$isOverLimit;
|
|
49
52
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
|
50
53
|
const inputRef = useProvidedRefOrCreate(ref);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
54
|
+
|
|
55
|
+
// For uncontrolled usage we track the length of the input's content so the
|
|
56
|
+
// character counter can be derived during render rather than synced from an
|
|
57
|
+
// effect (which would trigger an extra render on every keystroke). For
|
|
58
|
+
// controlled usage the `value` prop is the source of truth.
|
|
59
|
+
const isControlled = value !== undefined;
|
|
60
|
+
const [uncontrolledLength, setUncontrolledLength] = useState(() => defaultValue !== undefined ? String(defaultValue).length : 0);
|
|
61
|
+
const currentLength = isControlled ? String(value).length : uncontrolledLength;
|
|
62
|
+
|
|
63
|
+
// The counter and validation state are derived directly from the current
|
|
64
|
+
// length, so they stay in sync with the input without an extra render.
|
|
65
|
+
const counter = characterLimit ? getCharacterCountState(currentLength, characterLimit) : undefined;
|
|
66
|
+
const isOverLimit = (_counter$isOverLimit = counter === null || counter === void 0 ? void 0 : counter.isOverLimit) !== null && _counter$isOverLimit !== void 0 ? _counter$isOverLimit : false;
|
|
59
67
|
|
|
60
68
|
// this class is necessary to style FilterSearch, plz no touchy!
|
|
61
69
|
const wrapperClasses = clsx(className, 'TextInput-wrapper');
|
|
@@ -84,63 +92,13 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
84
92
|
onBlur && onBlur(e_1);
|
|
85
93
|
}, [onBlur]);
|
|
86
94
|
|
|
87
|
-
// Initialize character counter
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
if (characterLimit) {
|
|
90
|
-
characterCounterRef.current = new CharacterCounter({
|
|
91
|
-
onCountUpdate: (count, overLimit, message) => {
|
|
92
|
-
if (message !== lastCharacterCountRef.current) {
|
|
93
|
-
lastCharacterCountRef.current = message;
|
|
94
|
-
setCharacterCount(message);
|
|
95
|
-
}
|
|
96
|
-
if (overLimit !== lastIsOverLimitRef.current) {
|
|
97
|
-
lastIsOverLimitRef.current = overLimit;
|
|
98
|
-
setIsOverLimit(overLimit);
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
onScreenReaderAnnounce: message_0 => {
|
|
102
|
-
if (message_0 !== lastScreenReaderMessageRef.current) {
|
|
103
|
-
lastScreenReaderMessageRef.current = message_0;
|
|
104
|
-
setScreenReaderMessage(message_0);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
lastCountedLengthRef.current = null;
|
|
109
|
-
return () => {
|
|
110
|
-
var _characterCounterRef$;
|
|
111
|
-
(_characterCounterRef$ = characterCounterRef.current) === null || _characterCounterRef$ === void 0 ? void 0 : _characterCounterRef$.cleanup();
|
|
112
|
-
characterCounterRef.current = null;
|
|
113
|
-
lastCountedLengthRef.current = null;
|
|
114
|
-
lastCharacterCountRef.current = '';
|
|
115
|
-
lastIsOverLimitRef.current = false;
|
|
116
|
-
lastScreenReaderMessageRef.current = '';
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
}, [characterLimit]);
|
|
120
|
-
|
|
121
|
-
// Update character count when value changes or on mount
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
if (characterLimit && characterCounterRef.current) {
|
|
124
|
-
const currentValue = value !== undefined ? String(value) : defaultValue !== undefined ? String(defaultValue) : '';
|
|
125
|
-
const currentLength = currentValue.length;
|
|
126
|
-
if (currentLength !== lastCountedLengthRef.current) {
|
|
127
|
-
lastCountedLengthRef.current = currentLength;
|
|
128
|
-
characterCounterRef.current.updateCharacterCount(currentLength, characterLimit);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}, [value, defaultValue, characterLimit]);
|
|
132
|
-
|
|
133
95
|
// Handle input change with character counter
|
|
134
96
|
const handleInputChange = useCallback(e_2 => {
|
|
135
|
-
if (characterLimit &&
|
|
136
|
-
|
|
137
|
-
if (currentLength_0 !== lastCountedLengthRef.current) {
|
|
138
|
-
lastCountedLengthRef.current = currentLength_0;
|
|
139
|
-
characterCounterRef.current.updateCharacterCount(currentLength_0, characterLimit);
|
|
140
|
-
}
|
|
97
|
+
if (characterLimit && !isControlled) {
|
|
98
|
+
setUncontrolledLength(e_2.target.value.length);
|
|
141
99
|
}
|
|
142
100
|
onChange === null || onChange === void 0 ? void 0 : onChange(e_2);
|
|
143
|
-
}, [onChange, characterLimit]);
|
|
101
|
+
}, [onChange, characterLimit, isControlled]);
|
|
144
102
|
const characterCountId = useId();
|
|
145
103
|
const characterCountStaticMessageId = useId();
|
|
146
104
|
const isValid = isOverLimit ? 'error' : validationStatus;
|
|
@@ -202,10 +160,11 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
202
160
|
children: typeof TrailingVisual !== 'string' && isValidElementType(TrailingVisual) ? /*#__PURE__*/jsx(TrailingVisual, {}) : TrailingVisual
|
|
203
161
|
}), trailingAction]
|
|
204
162
|
}), characterLimit && /*#__PURE__*/jsxs(Fragment, {
|
|
205
|
-
children: [/*#__PURE__*/jsx(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
163
|
+
children: [/*#__PURE__*/jsx(AriaStatus, {
|
|
164
|
+
announceOnShow: false,
|
|
165
|
+
delayMs: SCREEN_READER_DELAY,
|
|
166
|
+
className: visuallyHiddenClasses.InternalVisuallyHidden,
|
|
167
|
+
children: counter === null || counter === void 0 ? void 0 : counter.message
|
|
209
168
|
}), /*#__PURE__*/jsxs(VisuallyHidden, {
|
|
210
169
|
id: characterCountStaticMessageId,
|
|
211
170
|
children: ["You can enter up to ", characterLimit, " ", characterLimit === 1 ? 'character' : 'characters']
|
|
@@ -217,7 +176,7 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
|
|
|
217
176
|
"data-component": "TextInput.CharacterCounter",
|
|
218
177
|
children: [isOverLimit && /*#__PURE__*/jsx(AlertFillIcon, {
|
|
219
178
|
size: 16
|
|
220
|
-
}),
|
|
179
|
+
}), counter === null || counter === void 0 ? void 0 : counter.message]
|
|
221
180
|
})]
|
|
222
181
|
})]
|
|
223
182
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/Textarea/Textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAe,MAAM,OAAO,CAAA;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/Textarea/Textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAe,MAAM,OAAO,CAAA;AAC/D,OAAO,KAAqC,MAAM,OAAO,CAAA;AAEzD,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,qCAAqC,CAAA;AAE7E,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AASlD,eAAO,MAAM,qBAAqB,IAAI,CAAA;AACtC,eAAO,MAAM,qBAAqB,KAAK,CAAA;AACvC,eAAO,MAAM,uBAAuB,SAAS,CAAA;AAE7C,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,oBAAoB,CAAA;IACvC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,CAAA;IACpD;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,CAAA;AAE/C;;;GAGG;AACH,QAAA,MAAM,QAAQ;IA/CZ;;OAEG;eACQ,OAAO;IAClB;;OAEG;uBACgB,oBAAoB;IACvC;;OAEG;YACK,OAAO;IACf;;OAEG;aACM,MAAM,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU;IACpD;;OAEG;eACQ,OAAO;IAClB;;OAEG;gBACS,MAAM;IAClB;;OAEG;gBACS,MAAM;IAClB;;OAEG;gBACS,MAAM;IAClB;;OAEG;YACK,KAAK,CAAC,aAAa;IAC3B;;;OAGG;qBACc,MAAM;2FA6HxB,CAAA;wBAK0B,cAAc,CAAC,OAAO,QAAQ,CAAC;AAA1D,wBAA0D"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { c } from 'react-compiler-runtime';
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useId, useState } from 'react';
|
|
3
3
|
import { TextInputBaseWrapper } from '../internal/components/TextInputWrapper.js';
|
|
4
4
|
import classes from './TextArea.module.css.js';
|
|
5
5
|
import { AlertFillIcon } from '@primer/octicons-react';
|
|
6
|
-
import {
|
|
6
|
+
import { SCREEN_READER_DELAY, getCharacterCountState } from '../utils/character-counter.js';
|
|
7
7
|
import VisuallyHidden from '../_VisuallyHidden.js';
|
|
8
|
+
import visuallyHiddenClasses from '../_VisuallyHidden.module.css.js';
|
|
8
9
|
import { clsx } from 'clsx';
|
|
9
10
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
|
+
import { AriaStatus } from '../live-region/AriaStatus.js';
|
|
10
12
|
import Text from '../Text/Text.js';
|
|
11
13
|
|
|
12
14
|
const DEFAULT_TEXTAREA_ROWS = 7;
|
|
@@ -17,7 +19,7 @@ const DEFAULT_TEXTAREA_RESIZE = 'both';
|
|
|
17
19
|
* This component accepts all native HTML <textarea> attributes as props.
|
|
18
20
|
*/
|
|
19
21
|
const Textarea = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
20
|
-
const $ = c(
|
|
22
|
+
const $ = c(76);
|
|
21
23
|
let block;
|
|
22
24
|
let characterLimit;
|
|
23
25
|
let className;
|
|
@@ -95,200 +97,170 @@ const Textarea = /*#__PURE__*/React.forwardRef((t0, ref) => {
|
|
|
95
97
|
const rows = t1 === undefined ? DEFAULT_TEXTAREA_ROWS : t1;
|
|
96
98
|
const cols = t2 === undefined ? DEFAULT_TEXTAREA_COLS : t2;
|
|
97
99
|
const resize = t3 === undefined ? DEFAULT_TEXTAREA_RESIZE : t3;
|
|
98
|
-
const [characterCount, setCharacterCount] = React.useState("");
|
|
99
|
-
const [isOverLimit, setIsOverLimit] = React.useState(false);
|
|
100
|
-
const [screenReaderMessage, setScreenReaderMessage] = React.useState("");
|
|
101
|
-
const characterCounterRef = useRef(null);
|
|
102
100
|
const characterCountId = useId();
|
|
103
101
|
const characterCountStaticMessageId = useId();
|
|
102
|
+
const isControlled = value !== undefined;
|
|
104
103
|
let t4;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (characterLimit) {
|
|
109
|
-
characterCounterRef.current = new CharacterCounter({
|
|
110
|
-
onCountUpdate: (count, overLimit, message) => {
|
|
111
|
-
setCharacterCount(message);
|
|
112
|
-
setIsOverLimit(overLimit);
|
|
113
|
-
},
|
|
114
|
-
onScreenReaderAnnounce: message_0 => {
|
|
115
|
-
setScreenReaderMessage(message_0);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
return () => {
|
|
119
|
-
var _characterCounterRef$;
|
|
120
|
-
(_characterCounterRef$ = characterCounterRef.current) === null || _characterCounterRef$ === void 0 ? void 0 : _characterCounterRef$.cleanup();
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
t5 = [characterLimit];
|
|
125
|
-
$[18] = characterLimit;
|
|
104
|
+
if ($[18] !== defaultValue) {
|
|
105
|
+
t4 = () => defaultValue !== undefined ? String(defaultValue).length : 0;
|
|
106
|
+
$[18] = defaultValue;
|
|
126
107
|
$[19] = t4;
|
|
127
|
-
$[20] = t5;
|
|
128
108
|
} else {
|
|
129
109
|
t4 = $[19];
|
|
130
|
-
t5 = $[20];
|
|
131
|
-
}
|
|
132
|
-
useEffect(t4, t5);
|
|
133
|
-
let t6;
|
|
134
|
-
let t7;
|
|
135
|
-
if ($[21] !== characterLimit || $[22] !== defaultValue || $[23] !== value) {
|
|
136
|
-
t6 = () => {
|
|
137
|
-
if (characterLimit && characterCounterRef.current) {
|
|
138
|
-
const currentValue = value !== undefined ? String(value) : defaultValue !== undefined ? String(defaultValue) : "";
|
|
139
|
-
characterCounterRef.current.updateCharacterCount(currentValue.length, characterLimit);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
t7 = [value, defaultValue, characterLimit];
|
|
143
|
-
$[21] = characterLimit;
|
|
144
|
-
$[22] = defaultValue;
|
|
145
|
-
$[23] = value;
|
|
146
|
-
$[24] = t6;
|
|
147
|
-
$[25] = t7;
|
|
148
|
-
} else {
|
|
149
|
-
t6 = $[24];
|
|
150
|
-
t7 = $[25];
|
|
151
|
-
}
|
|
152
|
-
useEffect(t6, t7);
|
|
153
|
-
let t8;
|
|
154
|
-
if ($[26] !== characterLimit || $[27] !== onChange) {
|
|
155
|
-
t8 = e => {
|
|
156
|
-
var _onChange;
|
|
157
|
-
if (characterLimit && characterCounterRef.current) {
|
|
158
|
-
characterCounterRef.current.updateCharacterCount(e.target.value.length, characterLimit);
|
|
159
|
-
}
|
|
160
|
-
(_onChange = onChange) === null || _onChange === void 0 ? void 0 : _onChange(e);
|
|
161
|
-
};
|
|
162
|
-
$[26] = characterLimit;
|
|
163
|
-
$[27] = onChange;
|
|
164
|
-
$[28] = t8;
|
|
165
|
-
} else {
|
|
166
|
-
t8 = $[28];
|
|
167
|
-
}
|
|
168
|
-
const handleTextareaChange = t8;
|
|
169
|
-
const isValid = isOverLimit ? "error" : validationStatus;
|
|
170
|
-
const t9 = isValid === "error" ? "true" : "false";
|
|
171
|
-
let t10;
|
|
172
|
-
if ($[29] !== maxHeight || $[30] !== minHeight || $[31] !== style) {
|
|
173
|
-
t10 = {
|
|
174
|
-
minHeight,
|
|
175
|
-
maxHeight,
|
|
176
|
-
...style
|
|
177
|
-
};
|
|
178
|
-
$[29] = maxHeight;
|
|
179
|
-
$[30] = minHeight;
|
|
180
|
-
$[31] = style;
|
|
181
|
-
$[32] = t10;
|
|
182
|
-
} else {
|
|
183
|
-
t10 = $[32];
|
|
184
|
-
}
|
|
185
|
-
let t11;
|
|
186
|
-
if ($[33] !== characterCountStaticMessageId || $[34] !== characterLimit || $[35] !== rest) {
|
|
187
|
-
t11 = characterLimit ? [characterCountStaticMessageId, rest["aria-describedby"]].filter(Boolean).join(" ") || undefined : rest["aria-describedby"];
|
|
188
|
-
$[33] = characterCountStaticMessageId;
|
|
189
|
-
$[34] = characterLimit;
|
|
190
|
-
$[35] = rest;
|
|
191
|
-
$[36] = t11;
|
|
192
|
-
} else {
|
|
193
|
-
t11 = $[36];
|
|
194
110
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
$[
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
$[57]
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
"aria-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
111
|
+
const [uncontrolledLength, setUncontrolledLength] = useState(t4);
|
|
112
|
+
const currentLength = isControlled ? String(value).length : uncontrolledLength;
|
|
113
|
+
let t5;
|
|
114
|
+
if ($[20] !== block || $[21] !== characterCountId || $[22] !== characterCountStaticMessageId || $[23] !== characterLimit || $[24] !== className || $[25] !== cols || $[26] !== contrast || $[27] !== currentLength || $[28] !== defaultValue || $[29] !== disabled || $[30] !== isControlled || $[31] !== maxHeight || $[32] !== minHeight || $[33] !== onChange || $[34] !== ref || $[35] !== required || $[36] !== resize || $[37] !== rest || $[38] !== rows || $[39] !== style || $[40] !== validationStatus || $[41] !== value) {
|
|
115
|
+
var _counter$isOverLimit;
|
|
116
|
+
const counter = characterLimit ? getCharacterCountState(currentLength, characterLimit) : undefined;
|
|
117
|
+
const isOverLimit = (_counter$isOverLimit = counter === null || counter === void 0 ? void 0 : counter.isOverLimit) !== null && _counter$isOverLimit !== void 0 ? _counter$isOverLimit : false;
|
|
118
|
+
let t6;
|
|
119
|
+
if ($[43] !== characterLimit || $[44] !== isControlled || $[45] !== onChange) {
|
|
120
|
+
t6 = e => {
|
|
121
|
+
var _onChange;
|
|
122
|
+
if (characterLimit && !isControlled) {
|
|
123
|
+
setUncontrolledLength(e.target.value.length);
|
|
124
|
+
}
|
|
125
|
+
(_onChange = onChange) === null || _onChange === void 0 ? void 0 : _onChange(e);
|
|
126
|
+
};
|
|
127
|
+
$[43] = characterLimit;
|
|
128
|
+
$[44] = isControlled;
|
|
129
|
+
$[45] = onChange;
|
|
130
|
+
$[46] = t6;
|
|
131
|
+
} else {
|
|
132
|
+
t6 = $[46];
|
|
133
|
+
}
|
|
134
|
+
const handleTextareaChange = t6;
|
|
135
|
+
const isValid = isOverLimit ? "error" : validationStatus;
|
|
136
|
+
const t7 = isValid === "error" ? "true" : "false";
|
|
137
|
+
let t8;
|
|
138
|
+
if ($[47] !== maxHeight || $[48] !== minHeight || $[49] !== style) {
|
|
139
|
+
t8 = {
|
|
140
|
+
minHeight,
|
|
141
|
+
maxHeight,
|
|
142
|
+
...style
|
|
143
|
+
};
|
|
144
|
+
$[47] = maxHeight;
|
|
145
|
+
$[48] = minHeight;
|
|
146
|
+
$[49] = style;
|
|
147
|
+
$[50] = t8;
|
|
148
|
+
} else {
|
|
149
|
+
t8 = $[50];
|
|
150
|
+
}
|
|
151
|
+
let t9;
|
|
152
|
+
if ($[51] !== characterCountStaticMessageId || $[52] !== characterLimit || $[53] !== rest) {
|
|
153
|
+
t9 = characterLimit ? [characterCountStaticMessageId, rest["aria-describedby"]].filter(Boolean).join(" ") || undefined : rest["aria-describedby"];
|
|
154
|
+
$[51] = characterCountStaticMessageId;
|
|
155
|
+
$[52] = characterLimit;
|
|
156
|
+
$[53] = rest;
|
|
157
|
+
$[54] = t9;
|
|
158
|
+
} else {
|
|
159
|
+
t9 = $[54];
|
|
160
|
+
}
|
|
161
|
+
let t10;
|
|
162
|
+
if ($[55] !== cols || $[56] !== defaultValue || $[57] !== disabled || $[58] !== handleTextareaChange || $[59] !== ref || $[60] !== required || $[61] !== resize || $[62] !== rest || $[63] !== rows || $[64] !== t7 || $[65] !== t8 || $[66] !== t9 || $[67] !== value) {
|
|
163
|
+
t10 = /*#__PURE__*/jsx("textarea", {
|
|
164
|
+
value: value,
|
|
165
|
+
defaultValue: defaultValue,
|
|
166
|
+
"data-resize": resize,
|
|
167
|
+
"aria-required": required,
|
|
168
|
+
"aria-invalid": t7,
|
|
169
|
+
ref: ref,
|
|
170
|
+
disabled: disabled,
|
|
171
|
+
rows: rows,
|
|
172
|
+
cols: cols,
|
|
173
|
+
className: classes.TextArea,
|
|
174
|
+
onChange: handleTextareaChange,
|
|
175
|
+
style: t8,
|
|
176
|
+
...rest,
|
|
177
|
+
"aria-describedby": t9
|
|
178
|
+
});
|
|
179
|
+
$[55] = cols;
|
|
180
|
+
$[56] = defaultValue;
|
|
181
|
+
$[57] = disabled;
|
|
182
|
+
$[58] = handleTextareaChange;
|
|
183
|
+
$[59] = ref;
|
|
184
|
+
$[60] = required;
|
|
185
|
+
$[61] = resize;
|
|
186
|
+
$[62] = rest;
|
|
187
|
+
$[63] = rows;
|
|
188
|
+
$[64] = t7;
|
|
189
|
+
$[65] = t8;
|
|
190
|
+
$[66] = t9;
|
|
191
|
+
$[67] = value;
|
|
192
|
+
$[68] = t10;
|
|
193
|
+
} else {
|
|
194
|
+
t10 = $[68];
|
|
195
|
+
}
|
|
196
|
+
let t11;
|
|
197
|
+
if ($[69] !== block || $[70] !== className || $[71] !== contrast || $[72] !== disabled || $[73] !== isValid || $[74] !== t10) {
|
|
198
|
+
t11 = /*#__PURE__*/jsx(TextInputBaseWrapper, {
|
|
199
|
+
validationStatus: isValid,
|
|
200
|
+
disabled: disabled,
|
|
201
|
+
block: block,
|
|
202
|
+
contrast: contrast,
|
|
203
|
+
className: className,
|
|
204
|
+
children: t10
|
|
205
|
+
});
|
|
206
|
+
$[69] = block;
|
|
207
|
+
$[70] = className;
|
|
208
|
+
$[71] = contrast;
|
|
209
|
+
$[72] = disabled;
|
|
210
|
+
$[73] = isValid;
|
|
211
|
+
$[74] = t10;
|
|
212
|
+
$[75] = t11;
|
|
213
|
+
} else {
|
|
214
|
+
t11 = $[75];
|
|
215
|
+
}
|
|
216
|
+
t5 = /*#__PURE__*/jsxs(Fragment, {
|
|
217
|
+
children: [t11, characterLimit && /*#__PURE__*/jsxs(Fragment, {
|
|
218
|
+
children: [/*#__PURE__*/jsx(AriaStatus, {
|
|
219
|
+
announceOnShow: false,
|
|
220
|
+
delayMs: SCREEN_READER_DELAY,
|
|
221
|
+
className: visuallyHiddenClasses.InternalVisuallyHidden,
|
|
222
|
+
children: counter === null || counter === void 0 ? void 0 : counter.message
|
|
223
|
+
}), /*#__PURE__*/jsxs(VisuallyHidden, {
|
|
224
|
+
id: characterCountStaticMessageId,
|
|
225
|
+
children: ["You can enter up to ", characterLimit, " ", characterLimit === 1 ? "character" : "characters"]
|
|
226
|
+
}), /*#__PURE__*/jsxs(Text, {
|
|
227
|
+
"aria-hidden": "true",
|
|
228
|
+
id: characterCountId,
|
|
229
|
+
size: "small",
|
|
230
|
+
className: clsx(classes.CharacterCounter, isOverLimit && classes["CharacterCounter--error"]),
|
|
231
|
+
children: [isOverLimit && /*#__PURE__*/jsx(AlertFillIcon, {
|
|
232
|
+
size: 16
|
|
233
|
+
}), counter === null || counter === void 0 ? void 0 : counter.message]
|
|
234
|
+
})]
|
|
268
235
|
})]
|
|
269
236
|
});
|
|
270
|
-
$[
|
|
271
|
-
$[
|
|
272
|
-
$[
|
|
273
|
-
$[
|
|
274
|
-
$[
|
|
275
|
-
$[
|
|
276
|
-
$[
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
$[
|
|
286
|
-
$[
|
|
287
|
-
$[
|
|
237
|
+
$[20] = block;
|
|
238
|
+
$[21] = characterCountId;
|
|
239
|
+
$[22] = characterCountStaticMessageId;
|
|
240
|
+
$[23] = characterLimit;
|
|
241
|
+
$[24] = className;
|
|
242
|
+
$[25] = cols;
|
|
243
|
+
$[26] = contrast;
|
|
244
|
+
$[27] = currentLength;
|
|
245
|
+
$[28] = defaultValue;
|
|
246
|
+
$[29] = disabled;
|
|
247
|
+
$[30] = isControlled;
|
|
248
|
+
$[31] = maxHeight;
|
|
249
|
+
$[32] = minHeight;
|
|
250
|
+
$[33] = onChange;
|
|
251
|
+
$[34] = ref;
|
|
252
|
+
$[35] = required;
|
|
253
|
+
$[36] = resize;
|
|
254
|
+
$[37] = rest;
|
|
255
|
+
$[38] = rows;
|
|
256
|
+
$[39] = style;
|
|
257
|
+
$[40] = validationStatus;
|
|
258
|
+
$[41] = value;
|
|
259
|
+
$[42] = t5;
|
|
288
260
|
} else {
|
|
289
|
-
|
|
261
|
+
t5 = $[42];
|
|
290
262
|
}
|
|
291
|
-
return
|
|
263
|
+
return t5;
|
|
292
264
|
});
|
|
293
265
|
Textarea.displayName = 'Textarea';
|
|
294
266
|
Textarea.__SLOT__ = Symbol('Textarea');
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.prc-UnderlineNav-MenuItemContent-3J7gB{align-items:center;display:flex;justify-content:space-between}.prc-UnderlineNav-MoreButton-Y8soj{background:transparent;border:0;box-shadow:none;font-weight:var(--base-text-weight-normal,400);margin:0;padding:var(--base-size-4,.25rem) var(--base-size-8,.5rem)}.prc-UnderlineNav-MoreButton-Y8soj>[data-component=trailingVisual]{margin-left:0}
|
|
2
|
+
/*# sourceMappingURL=UnderlineNav-4344d9b0.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/UnderlineNav/UnderlineNav.module.css.js"],"names":[],"mappings":"AAAA,wCAEE,kBAAmB,CADnB,YAAa,CAEb,6BACF,CAGA,mCAGE,sBAAuB,CADvB,QAAS,CAGT,eAAgB,CADhB,8CAA2C,CAH3C,QAAS,CAQT,0DAKF,CAHE,mEACE,aACF","file":"UnderlineNav-4344d9b0.css","sourcesContent":[".MenuItemContent {\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n/* More button styles migrated from styles.ts (was moreBtnStyles) */\n.MoreButton {\n margin: 0; /* reset Safari extra margin */\n border: 0;\n background: transparent;\n font-weight: var(--base-text-weight-normal);\n box-shadow: none;\n padding-top: var(--base-size-4);\n padding-bottom: var(--base-size-4);\n padding-left: var(--base-size-8);\n padding-right: var(--base-size-8);\n\n & > [data-component='trailingVisual'] {\n margin-left: 0;\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export type UnderlineNavProps = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
@@ -15,5 +15,6 @@ export type UnderlineNavProps = {
|
|
|
15
15
|
*/
|
|
16
16
|
variant?: 'inset' | 'flush';
|
|
17
17
|
};
|
|
18
|
+
export declare const MORE_BTN_WIDTH = 86;
|
|
18
19
|
export declare const UnderlineNav: React.ForwardRefExoticComponent<UnderlineNavProps & React.RefAttributes<unknown>>;
|
|
19
20
|
//# sourceMappingURL=UnderlineNav.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAqBtE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACjD,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B,CAAA;AAGD,eAAO,MAAM,cAAc,KAAK,CAAA;AAsGhC,eAAO,MAAM,YAAY,mFA0SxB,CAAA"}
|