@mason-ds/vue 0.2.0 → 0.2.1
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/index.cjs +207 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -3
- package/dist/index.d.ts +101 -3
- package/dist/index.js +206 -8
- package/dist/index.js.map +1 -1
- package/llms.txt +57 -0
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ __export(index_exports, {
|
|
|
28
28
|
Divider: () => Divider,
|
|
29
29
|
Link: () => Link,
|
|
30
30
|
MasonProvider: () => MasonProvider,
|
|
31
|
+
Radio: () => Radio,
|
|
31
32
|
Select: () => Select,
|
|
32
33
|
Spinner: () => Spinner,
|
|
33
34
|
Stack: () => Stack,
|
|
@@ -863,6 +864,21 @@ function fieldErrorStyle() {
|
|
|
863
864
|
...typographyStyle("body.sm")
|
|
864
865
|
};
|
|
865
866
|
}
|
|
867
|
+
function visuallyHiddenControlStyle() {
|
|
868
|
+
return {
|
|
869
|
+
position: "absolute",
|
|
870
|
+
width: "1px",
|
|
871
|
+
height: "1px",
|
|
872
|
+
padding: "0",
|
|
873
|
+
margin: "-1px",
|
|
874
|
+
overflow: "hidden",
|
|
875
|
+
clip: "rect(0, 0, 0, 0)",
|
|
876
|
+
whiteSpace: "nowrap",
|
|
877
|
+
borderWidth: "0",
|
|
878
|
+
borderStyle: "solid",
|
|
879
|
+
borderColor: "transparent"
|
|
880
|
+
};
|
|
881
|
+
}
|
|
866
882
|
|
|
867
883
|
// src/field.ts
|
|
868
884
|
var fieldSeq = 0;
|
|
@@ -1150,6 +1166,7 @@ var Select = (0, import_vue13.defineComponent)({
|
|
|
1150
1166
|
var import_vue14 = require("vue");
|
|
1151
1167
|
|
|
1152
1168
|
// src/checkboxStyles.ts
|
|
1169
|
+
var CONTROL_SIZE = "1.125rem";
|
|
1153
1170
|
function checkboxRootStyle() {
|
|
1154
1171
|
return {
|
|
1155
1172
|
display: "flex",
|
|
@@ -1168,14 +1185,19 @@ function checkboxLabelStyle(disabled = false) {
|
|
|
1168
1185
|
...typographyStyle("body.md")
|
|
1169
1186
|
};
|
|
1170
1187
|
}
|
|
1171
|
-
function
|
|
1188
|
+
function checkboxIndicatorStyle() {
|
|
1172
1189
|
return {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1190
|
+
display: "inline-flex",
|
|
1191
|
+
alignItems: "center",
|
|
1192
|
+
justifyContent: "center",
|
|
1193
|
+
width: CONTROL_SIZE,
|
|
1194
|
+
height: CONTROL_SIZE,
|
|
1195
|
+
marginBlockStart: "0.2em",
|
|
1196
|
+
flexShrink: "0",
|
|
1197
|
+
boxSizing: "border-box",
|
|
1198
|
+
borderRadius: radiusVar("sm"),
|
|
1199
|
+
borderStyle: "solid",
|
|
1200
|
+
borderWidth: "1.5px"
|
|
1179
1201
|
};
|
|
1180
1202
|
}
|
|
1181
1203
|
|
|
@@ -1251,7 +1273,12 @@ var Checkbox = (0, import_vue14.defineComponent)({
|
|
|
1251
1273
|
"aria-describedby": ids.describedBy,
|
|
1252
1274
|
...props.modelValue === void 0 ? null : { checked: props.modelValue },
|
|
1253
1275
|
onChange: forwarded ? [emitChange, forwarded] : emitChange,
|
|
1254
|
-
style:
|
|
1276
|
+
style: visuallyHiddenControlStyle()
|
|
1277
|
+
}),
|
|
1278
|
+
(0, import_vue14.h)("span", {
|
|
1279
|
+
"data-mason-slot": "indicator",
|
|
1280
|
+
"aria-hidden": "true",
|
|
1281
|
+
style: checkboxIndicatorStyle()
|
|
1255
1282
|
}),
|
|
1256
1283
|
label ? (0, import_vue14.h)("span", { "data-mason-slot": "label-text" }, label) : null
|
|
1257
1284
|
]
|
|
@@ -1298,6 +1325,177 @@ var Checkbox = (0, import_vue14.defineComponent)({
|
|
|
1298
1325
|
};
|
|
1299
1326
|
}
|
|
1300
1327
|
});
|
|
1328
|
+
|
|
1329
|
+
// src/Radio.ts
|
|
1330
|
+
var import_vue15 = require("vue");
|
|
1331
|
+
|
|
1332
|
+
// src/radioStyles.ts
|
|
1333
|
+
var CONTROL_SIZE2 = "1.125rem";
|
|
1334
|
+
function radioRootStyle() {
|
|
1335
|
+
return {
|
|
1336
|
+
display: "flex",
|
|
1337
|
+
flexDirection: "column",
|
|
1338
|
+
gap: spacingVar("stack", "sm"),
|
|
1339
|
+
minWidth: "0"
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
function radioLabelStyle(disabled = false) {
|
|
1343
|
+
return {
|
|
1344
|
+
display: "inline-flex",
|
|
1345
|
+
alignItems: "flex-start",
|
|
1346
|
+
gap: spacingVar("inline", "sm"),
|
|
1347
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
1348
|
+
color: disabled ? cssVar("color.text.disabled") : cssVar("color.text.primary"),
|
|
1349
|
+
...typographyStyle("body.md")
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1352
|
+
function radioIndicatorStyle() {
|
|
1353
|
+
return {
|
|
1354
|
+
display: "inline-flex",
|
|
1355
|
+
alignItems: "center",
|
|
1356
|
+
justifyContent: "center",
|
|
1357
|
+
width: CONTROL_SIZE2,
|
|
1358
|
+
height: CONTROL_SIZE2,
|
|
1359
|
+
marginBlockStart: "0.2em",
|
|
1360
|
+
flexShrink: "0",
|
|
1361
|
+
boxSizing: "border-box",
|
|
1362
|
+
borderRadius: "999px",
|
|
1363
|
+
borderStyle: "solid",
|
|
1364
|
+
borderWidth: "1.5px"
|
|
1365
|
+
};
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
// src/Radio.ts
|
|
1369
|
+
var Radio = (0, import_vue15.defineComponent)({
|
|
1370
|
+
name: "MasonRadio",
|
|
1371
|
+
inheritAttrs: false,
|
|
1372
|
+
props: {
|
|
1373
|
+
label: {
|
|
1374
|
+
type: String,
|
|
1375
|
+
default: void 0
|
|
1376
|
+
},
|
|
1377
|
+
description: {
|
|
1378
|
+
type: String,
|
|
1379
|
+
default: void 0
|
|
1380
|
+
},
|
|
1381
|
+
error: {
|
|
1382
|
+
type: String,
|
|
1383
|
+
default: void 0
|
|
1384
|
+
},
|
|
1385
|
+
invalid: {
|
|
1386
|
+
type: Boolean,
|
|
1387
|
+
default: void 0
|
|
1388
|
+
},
|
|
1389
|
+
disabled: {
|
|
1390
|
+
type: Boolean,
|
|
1391
|
+
default: false
|
|
1392
|
+
},
|
|
1393
|
+
id: {
|
|
1394
|
+
type: String,
|
|
1395
|
+
default: void 0
|
|
1396
|
+
},
|
|
1397
|
+
modelValue: {
|
|
1398
|
+
type: [String, Number, Boolean],
|
|
1399
|
+
default: void 0
|
|
1400
|
+
},
|
|
1401
|
+
value: {
|
|
1402
|
+
type: [String, Number, Boolean],
|
|
1403
|
+
default: void 0
|
|
1404
|
+
}
|
|
1405
|
+
},
|
|
1406
|
+
emits: ["update:modelValue"],
|
|
1407
|
+
setup(props, { slots, attrs, emit }) {
|
|
1408
|
+
const autoId = nextFieldId();
|
|
1409
|
+
return () => {
|
|
1410
|
+
const {
|
|
1411
|
+
class: attrClass,
|
|
1412
|
+
style: attrStyle,
|
|
1413
|
+
onChange: attrChange,
|
|
1414
|
+
...controlAttrs
|
|
1415
|
+
} = attrs;
|
|
1416
|
+
const label = slots.label?.() ?? props.label;
|
|
1417
|
+
const description = slots.description?.() ?? props.description;
|
|
1418
|
+
const error = slots.error?.() ?? props.error;
|
|
1419
|
+
const invalid = props.invalid ?? Boolean(error);
|
|
1420
|
+
const ids = fieldIds(props.id ?? autoId, Boolean(description), Boolean(error));
|
|
1421
|
+
const emitChange = (event) => {
|
|
1422
|
+
const input = event.target;
|
|
1423
|
+
emit("update:modelValue", props.value === void 0 ? input.value : props.value);
|
|
1424
|
+
};
|
|
1425
|
+
const forwarded = attrChange;
|
|
1426
|
+
const checked = props.modelValue === void 0 || props.value === void 0 ? void 0 : props.modelValue === props.value;
|
|
1427
|
+
const children = [
|
|
1428
|
+
(0, import_vue15.h)(
|
|
1429
|
+
"label",
|
|
1430
|
+
{
|
|
1431
|
+
"data-mason-slot": "label",
|
|
1432
|
+
for: ids.controlId,
|
|
1433
|
+
style: radioLabelStyle(props.disabled)
|
|
1434
|
+
},
|
|
1435
|
+
[
|
|
1436
|
+
(0, import_vue15.h)("input", {
|
|
1437
|
+
...controlAttrs,
|
|
1438
|
+
type: "radio",
|
|
1439
|
+
id: ids.controlId,
|
|
1440
|
+
"data-mason-slot": "control",
|
|
1441
|
+
disabled: props.disabled,
|
|
1442
|
+
value: props.value,
|
|
1443
|
+
"aria-invalid": invalid || void 0,
|
|
1444
|
+
"aria-describedby": ids.describedBy,
|
|
1445
|
+
...checked === void 0 ? null : { checked },
|
|
1446
|
+
onChange: forwarded ? [emitChange, forwarded] : emitChange,
|
|
1447
|
+
style: visuallyHiddenControlStyle()
|
|
1448
|
+
}),
|
|
1449
|
+
(0, import_vue15.h)("span", {
|
|
1450
|
+
"data-mason-slot": "indicator",
|
|
1451
|
+
"aria-hidden": "true",
|
|
1452
|
+
style: radioIndicatorStyle()
|
|
1453
|
+
}),
|
|
1454
|
+
label ? (0, import_vue15.h)("span", { "data-mason-slot": "label-text" }, label) : null
|
|
1455
|
+
]
|
|
1456
|
+
)
|
|
1457
|
+
];
|
|
1458
|
+
if (description) {
|
|
1459
|
+
children.push(
|
|
1460
|
+
(0, import_vue15.h)(
|
|
1461
|
+
"p",
|
|
1462
|
+
{
|
|
1463
|
+
"data-mason-slot": "description",
|
|
1464
|
+
id: ids.descriptionId,
|
|
1465
|
+
style: fieldDescriptionStyle()
|
|
1466
|
+
},
|
|
1467
|
+
description
|
|
1468
|
+
)
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
if (error) {
|
|
1472
|
+
children.push(
|
|
1473
|
+
(0, import_vue15.h)(
|
|
1474
|
+
"p",
|
|
1475
|
+
{
|
|
1476
|
+
"data-mason-slot": "error",
|
|
1477
|
+
id: ids.errorId,
|
|
1478
|
+
role: "alert",
|
|
1479
|
+
style: fieldErrorStyle()
|
|
1480
|
+
},
|
|
1481
|
+
error
|
|
1482
|
+
)
|
|
1483
|
+
);
|
|
1484
|
+
}
|
|
1485
|
+
return (0, import_vue15.h)(
|
|
1486
|
+
"div",
|
|
1487
|
+
{
|
|
1488
|
+
"data-mason-component": "radio",
|
|
1489
|
+
"data-invalid": invalid || void 0,
|
|
1490
|
+
"data-disabled": props.disabled || void 0,
|
|
1491
|
+
class: mergeClassName(attrClass),
|
|
1492
|
+
style: [radioRootStyle(), attrStyle]
|
|
1493
|
+
},
|
|
1494
|
+
children
|
|
1495
|
+
);
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
});
|
|
1301
1499
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1302
1500
|
0 && (module.exports = {
|
|
1303
1501
|
Badge,
|
|
@@ -1308,6 +1506,7 @@ var Checkbox = (0, import_vue14.defineComponent)({
|
|
|
1308
1506
|
Divider,
|
|
1309
1507
|
Link,
|
|
1310
1508
|
MasonProvider,
|
|
1509
|
+
Radio,
|
|
1311
1510
|
Select,
|
|
1312
1511
|
Spinner,
|
|
1313
1512
|
Stack,
|