@charcoal-ui/react 3.8.0 → 3.9.0
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/dist/components/Checkbox/index.d.ts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/useCustomModalOverlay.d.ts +12 -0
- package/dist/components/Modal/useCustomModalOverlay.d.ts.map +1 -0
- package/dist/components/Radio/index.d.ts.map +1 -1
- package/dist/components/TextArea/index.d.ts.map +1 -1
- package/dist/components/TextField/TextField.story.d.ts +1 -0
- package/dist/components/TextField/TextField.story.d.ts.map +1 -1
- package/dist/components/TextField/index.d.ts.map +1 -1
- package/dist/index.cjs.js +996 -2224
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +990 -2224
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -6
- package/src/components/Checkbox/__snapshots__/index.story.storyshot +43 -15
- package/src/components/Checkbox/index.tsx +13 -5
- package/src/components/DropdownSelector/__snapshots__/index.story.storyshot +3 -0
- package/src/components/IconButton/__snapshots__/index.story.storyshot +5 -0
- package/src/components/IconButton/index.tsx +4 -1
- package/src/components/Modal/__snapshots__/index.story.storyshot +12 -0
- package/src/components/Modal/index.tsx +15 -20
- package/src/components/Modal/useCustomModalOverlay.tsx +42 -0
- package/src/components/Radio/__snapshots__/index.story.storyshot +25 -5
- package/src/components/Radio/index.tsx +5 -1
- package/src/components/TextArea/index.tsx +22 -14
- package/src/components/TextField/TextField.story.tsx +20 -0
- package/src/components/TextField/__snapshots__/TextField.story.storyshot +277 -0
- package/src/components/TextField/index.tsx +22 -14
|
@@ -37,6 +37,26 @@ const Container = styled.div`
|
|
|
37
37
|
|
|
38
38
|
export const Default = {}
|
|
39
39
|
|
|
40
|
+
export const Number: StoryObj<typeof TextField> = {
|
|
41
|
+
render: function Render(args) {
|
|
42
|
+
const [count, setCount] = useState(0)
|
|
43
|
+
return (
|
|
44
|
+
<Container>
|
|
45
|
+
<TextField
|
|
46
|
+
{...args}
|
|
47
|
+
type="number"
|
|
48
|
+
value={count.toString()}
|
|
49
|
+
onChange={(value) => setCount(parseInt(value))}
|
|
50
|
+
onWheel={(e) => {
|
|
51
|
+
e.currentTarget.blur()
|
|
52
|
+
e.stopPropagation()
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
</Container>
|
|
56
|
+
)
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
|
|
40
60
|
export const HasLabel = {
|
|
41
61
|
args: {
|
|
42
62
|
showLabel: true,
|
|
@@ -1201,6 +1201,281 @@ exports[`Storybook Tests TextField HasLabel 1`] = `
|
|
|
1201
1201
|
</div>
|
|
1202
1202
|
`;
|
|
1203
1203
|
|
|
1204
|
+
exports[`Storybook Tests TextField Number 1`] = `
|
|
1205
|
+
.c7 {
|
|
1206
|
+
cursor: pointer;
|
|
1207
|
+
-webkit-appearance: none;
|
|
1208
|
+
-moz-appearance: none;
|
|
1209
|
+
appearance: none;
|
|
1210
|
+
background: transparent;
|
|
1211
|
+
padding: 0;
|
|
1212
|
+
border-style: none;
|
|
1213
|
+
outline: none;
|
|
1214
|
+
color: inherit;
|
|
1215
|
+
text-rendering: inherit;
|
|
1216
|
+
-webkit-letter-spacing: inherit;
|
|
1217
|
+
-moz-letter-spacing: inherit;
|
|
1218
|
+
-ms-letter-spacing: inherit;
|
|
1219
|
+
letter-spacing: inherit;
|
|
1220
|
+
word-spacing: inherit;
|
|
1221
|
+
-webkit-text-decoration: none;
|
|
1222
|
+
text-decoration: none;
|
|
1223
|
+
font: inherit;
|
|
1224
|
+
margin: 0;
|
|
1225
|
+
overflow: visible;
|
|
1226
|
+
text-transform: none;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
.c7:disabled,
|
|
1230
|
+
.c7[aria-disabled]:not([aria-disabled=false]) {
|
|
1231
|
+
cursor: default;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
.c7:focus {
|
|
1235
|
+
outline: none;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
.c7::-moz-focus-inner {
|
|
1239
|
+
border-style: none;
|
|
1240
|
+
padding: 0;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
.c4 {
|
|
1244
|
+
font-size: 14px;
|
|
1245
|
+
line-height: 22px;
|
|
1246
|
+
font-weight: bold;
|
|
1247
|
+
display: flow-root;
|
|
1248
|
+
color: var(--charcoal-text1);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
.c4::before {
|
|
1252
|
+
display: block;
|
|
1253
|
+
width: 0;
|
|
1254
|
+
height: 0;
|
|
1255
|
+
content: '';
|
|
1256
|
+
margin-top: -4px;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
.c4::after {
|
|
1260
|
+
display: block;
|
|
1261
|
+
width: 0;
|
|
1262
|
+
height: 0;
|
|
1263
|
+
content: '';
|
|
1264
|
+
margin-bottom: -4px;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
.c6 {
|
|
1268
|
+
font-size: 14px;
|
|
1269
|
+
line-height: 22px;
|
|
1270
|
+
display: flow-root;
|
|
1271
|
+
color: var(--charcoal-text3);
|
|
1272
|
+
-webkit-transition: 0.2s color,0.2s box-shadow;
|
|
1273
|
+
transition: 0.2s color,0.2s box-shadow;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
.c6::before {
|
|
1277
|
+
display: block;
|
|
1278
|
+
width: 0;
|
|
1279
|
+
height: 0;
|
|
1280
|
+
content: '';
|
|
1281
|
+
margin-top: -4px;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
.c6::after {
|
|
1285
|
+
display: block;
|
|
1286
|
+
width: 0;
|
|
1287
|
+
height: 0;
|
|
1288
|
+
content: '';
|
|
1289
|
+
margin-bottom: -4px;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
.c6:not(:disabled):not([aria-disabled]):hover,
|
|
1293
|
+
.c6[aria-disabled='false']:hover {
|
|
1294
|
+
color: var(--charcoal-text3-hover);
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
.c6:not(:disabled):not([aria-disabled]):active,
|
|
1298
|
+
.c6[aria-disabled='false']:active {
|
|
1299
|
+
color: var(--charcoal-text3-press);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
.c6:not(:disabled):not([aria-disabled]):active,
|
|
1303
|
+
.c6[aria-disabled='false']:active,
|
|
1304
|
+
.c6:not(:disabled):not([aria-disabled]):focus,
|
|
1305
|
+
.c6[aria-disabled='false']:focus,
|
|
1306
|
+
.c6:not(:disabled):not([aria-disabled]):focus-visible,
|
|
1307
|
+
.c6[aria-disabled='false']:focus-visible {
|
|
1308
|
+
outline: none;
|
|
1309
|
+
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
.c2 {
|
|
1313
|
+
display: -webkit-inline-box;
|
|
1314
|
+
display: -webkit-inline-flex;
|
|
1315
|
+
display: -ms-inline-flexbox;
|
|
1316
|
+
display: inline-flex;
|
|
1317
|
+
-webkit-align-items: center;
|
|
1318
|
+
-webkit-box-align: center;
|
|
1319
|
+
-ms-flex-align: center;
|
|
1320
|
+
align-items: center;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
.c2 > .c5 {
|
|
1324
|
+
margin-left: auto;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
.c1 {
|
|
1328
|
+
display: -webkit-box;
|
|
1329
|
+
display: -webkit-flex;
|
|
1330
|
+
display: -ms-flexbox;
|
|
1331
|
+
display: flex;
|
|
1332
|
+
-webkit-flex-direction: column;
|
|
1333
|
+
-ms-flex-direction: column;
|
|
1334
|
+
flex-direction: column;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
.c3 {
|
|
1338
|
+
margin-bottom: 8px;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
.c8 {
|
|
1342
|
+
display: grid;
|
|
1343
|
+
grid-template-columns: 1fr;
|
|
1344
|
+
height: 40px;
|
|
1345
|
+
-webkit-transition: 0.2s background-color,0.2s box-shadow;
|
|
1346
|
+
transition: 0.2s background-color,0.2s box-shadow;
|
|
1347
|
+
color: var(--charcoal-text2);
|
|
1348
|
+
background-color: var(--charcoal-surface3);
|
|
1349
|
+
border-radius: 4px;
|
|
1350
|
+
gap: 4px;
|
|
1351
|
+
padding: 0 8px;
|
|
1352
|
+
line-height: 22px;
|
|
1353
|
+
font-size: 14px;
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
.c8:not(:disabled):not([aria-disabled]):hover,
|
|
1357
|
+
.c8 [aria-disabled='false']:hover {
|
|
1358
|
+
background-color: var(--charcoal-surface3-hover);
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
.c8:focus-within {
|
|
1362
|
+
outline: none;
|
|
1363
|
+
box-shadow: 0 0 0 4px rgba(0,150,250,0.32);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
.c9 {
|
|
1367
|
+
border: none;
|
|
1368
|
+
box-sizing: border-box;
|
|
1369
|
+
outline: none;
|
|
1370
|
+
font-family: inherit;
|
|
1371
|
+
-webkit-transform-origin: top left;
|
|
1372
|
+
-ms-transform-origin: top left;
|
|
1373
|
+
transform-origin: top left;
|
|
1374
|
+
-webkit-transform: scale(0.875);
|
|
1375
|
+
-ms-transform: scale(0.875);
|
|
1376
|
+
transform: scale(0.875);
|
|
1377
|
+
width: calc(100% / 0.875);
|
|
1378
|
+
height: calc(100% / 0.875);
|
|
1379
|
+
font-size: calc(14px / 0.875);
|
|
1380
|
+
line-height: calc(22px / 0.875);
|
|
1381
|
+
padding-left: 0;
|
|
1382
|
+
padding-right: 0;
|
|
1383
|
+
border-radius: calc(4px / 0.875);
|
|
1384
|
+
-webkit-appearance: none;
|
|
1385
|
+
-moz-appearance: none;
|
|
1386
|
+
appearance: none;
|
|
1387
|
+
background: transparent;
|
|
1388
|
+
color: var(--charcoal-text2);
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
.c9::-webkit-input-placeholder {
|
|
1392
|
+
color: var(--charcoal-text3);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
.c9::-moz-placeholder {
|
|
1396
|
+
color: var(--charcoal-text3);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
.c9:-ms-input-placeholder {
|
|
1400
|
+
color: var(--charcoal-text3);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
.c9::placeholder {
|
|
1404
|
+
color: var(--charcoal-text3);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
.c0 {
|
|
1408
|
+
display: grid;
|
|
1409
|
+
gap: 24px;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
<div
|
|
1413
|
+
data-dark={false}
|
|
1414
|
+
>
|
|
1415
|
+
<div
|
|
1416
|
+
className="c0"
|
|
1417
|
+
>
|
|
1418
|
+
<div
|
|
1419
|
+
className="c1"
|
|
1420
|
+
>
|
|
1421
|
+
<div
|
|
1422
|
+
className="c2 c3"
|
|
1423
|
+
style={
|
|
1424
|
+
Object {
|
|
1425
|
+
"border": 0,
|
|
1426
|
+
"clip": "rect(0 0 0 0)",
|
|
1427
|
+
"clipPath": "inset(50%)",
|
|
1428
|
+
"height": "1px",
|
|
1429
|
+
"margin": "-1px",
|
|
1430
|
+
"overflow": "hidden",
|
|
1431
|
+
"padding": 0,
|
|
1432
|
+
"position": "absolute",
|
|
1433
|
+
"whiteSpace": "nowrap",
|
|
1434
|
+
"width": "1px",
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
>
|
|
1438
|
+
<label
|
|
1439
|
+
className="c4"
|
|
1440
|
+
htmlFor="test-id"
|
|
1441
|
+
id="test-id"
|
|
1442
|
+
>
|
|
1443
|
+
Label
|
|
1444
|
+
</label>
|
|
1445
|
+
<div
|
|
1446
|
+
className="c5 c6"
|
|
1447
|
+
>
|
|
1448
|
+
<span>
|
|
1449
|
+
<button
|
|
1450
|
+
className="c7"
|
|
1451
|
+
>
|
|
1452
|
+
Text Link
|
|
1453
|
+
</button>
|
|
1454
|
+
</span>
|
|
1455
|
+
</div>
|
|
1456
|
+
</div>
|
|
1457
|
+
<div
|
|
1458
|
+
className="c8"
|
|
1459
|
+
>
|
|
1460
|
+
<input
|
|
1461
|
+
aria-labelledby="test-id"
|
|
1462
|
+
className="c9"
|
|
1463
|
+
disabled={false}
|
|
1464
|
+
id="test-id"
|
|
1465
|
+
onChange={[Function]}
|
|
1466
|
+
onWheel={[Function]}
|
|
1467
|
+
placeholder="TextField"
|
|
1468
|
+
readOnly={false}
|
|
1469
|
+
required={false}
|
|
1470
|
+
type="number"
|
|
1471
|
+
value="0"
|
|
1472
|
+
/>
|
|
1473
|
+
</div>
|
|
1474
|
+
</div>
|
|
1475
|
+
</div>
|
|
1476
|
+
</div>
|
|
1477
|
+
`;
|
|
1478
|
+
|
|
1204
1479
|
exports[`Storybook Tests TextField PrefixIcon 1`] = `
|
|
1205
1480
|
.c6 {
|
|
1206
1481
|
cursor: pointer;
|
|
@@ -1352,11 +1627,13 @@ exports[`Storybook Tests TextField PrefixIcon 1`] = `
|
|
|
1352
1627
|
|
|
1353
1628
|
.c12:not(:disabled):not([aria-disabled]):hover,
|
|
1354
1629
|
.c12[aria-disabled='false']:hover {
|
|
1630
|
+
color: var(--charcoal-text5-hover);
|
|
1355
1631
|
background-color: var(--charcoal-surface4-hover);
|
|
1356
1632
|
}
|
|
1357
1633
|
|
|
1358
1634
|
.c12:not(:disabled):not([aria-disabled]):active,
|
|
1359
1635
|
.c12[aria-disabled='false']:active {
|
|
1636
|
+
color: var(--charcoal-text5-press);
|
|
1360
1637
|
background-color: var(--charcoal-surface4-press);
|
|
1361
1638
|
}
|
|
1362
1639
|
|
|
@@ -7,6 +7,7 @@ import FieldLabel, { FieldLabelProps } from '../FieldLabel'
|
|
|
7
7
|
import { countCodePointsInString, mergeRefs } from '../../_lib'
|
|
8
8
|
import { ReactAreaUseTextFieldCompat } from '../../_lib/compat'
|
|
9
9
|
import { useFocusWithClick } from './useFocusWithClick'
|
|
10
|
+
import { mergeProps } from '@react-aria/utils'
|
|
10
11
|
|
|
11
12
|
type DOMProps = Omit<
|
|
12
13
|
React.InputHTMLAttributes<HTMLInputElement>,
|
|
@@ -60,6 +61,7 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
60
61
|
maxLength,
|
|
61
62
|
prefix = null,
|
|
62
63
|
suffix = null,
|
|
64
|
+
...restProps
|
|
63
65
|
} = props
|
|
64
66
|
|
|
65
67
|
const { visuallyHiddenProps } = useVisuallyHidden()
|
|
@@ -87,25 +89,31 @@ const TextField = React.forwardRef<HTMLInputElement, TextFieldProps>(
|
|
|
87
89
|
setCount(countCodePointsInString(props.value ?? ''))
|
|
88
90
|
}, [props.value])
|
|
89
91
|
|
|
90
|
-
const {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
const {
|
|
93
|
+
inputProps: ariaInputProps,
|
|
94
|
+
labelProps,
|
|
95
|
+
descriptionProps,
|
|
96
|
+
errorMessageProps,
|
|
97
|
+
} = useTextField(
|
|
98
|
+
{
|
|
99
|
+
inputElementType: 'input',
|
|
100
|
+
isDisabled: disabled,
|
|
101
|
+
isRequired: required,
|
|
102
|
+
validationState: invalid ? 'invalid' : 'valid',
|
|
103
|
+
description: !invalid && assistiveText,
|
|
104
|
+
errorMessage: invalid && assistiveText,
|
|
105
|
+
onChange: handleChange,
|
|
106
|
+
...props,
|
|
107
|
+
},
|
|
108
|
+
ariaRef
|
|
109
|
+
)
|
|
104
110
|
|
|
105
111
|
const containerRef = useRef(null)
|
|
106
112
|
|
|
107
113
|
useFocusWithClick(containerRef, ariaRef)
|
|
108
114
|
|
|
115
|
+
const inputProps = mergeProps(restProps, ariaInputProps)
|
|
116
|
+
|
|
109
117
|
return (
|
|
110
118
|
<TextFieldRoot className={className} isDisabled={disabled}>
|
|
111
119
|
<TextFieldLabel
|