@arc-ui/components 4.0.0 → 6.0.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/index.es.js +116 -109
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +116 -109
- package/dist/index.js.map +1 -1
- package/dist/polyfills.js +3331 -17
- package/dist/polyfills.js.map +1 -1
- package/dist/styles.bt.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.ee.css +1 -1
- package/dist/types/components/Button/Button.d.ts +4 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +13 -9
- package/dist/types/components/FormControl/FormControl.d.ts +8 -2
- package/dist/types/components/FormControl/index.d.ts +1 -1
- package/dist/types/components/RadioGroup/RadioButton/RadioButton.d.ts +4 -0
- package/dist/types/components/RadioGroup/RadioGroup.d.ts +17 -12
- package/dist/types/components/RadioGroup/context.d.ts +5 -6
- package/dist/types/components/TextInput/TextInput.d.ts +15 -9
- package/package.json +6 -4
package/dist/index.es.js
CHANGED
|
@@ -308,9 +308,9 @@ var Base = function (_a) {
|
|
|
308
308
|
return (React.createElement("div", __assign({ className: "arc".concat(brand ? " arc-".concat(brand) : "") }, filterDataAttrs(props)), children));
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
-
var defaultContext$
|
|
312
|
-
var Context$
|
|
313
|
-
var Provider$
|
|
311
|
+
var defaultContext$3 = { surface: "light" };
|
|
312
|
+
var Context$3 = createContext(defaultContext$3);
|
|
313
|
+
var Provider$4 = Context$3.Provider;
|
|
314
314
|
/**
|
|
315
315
|
* Use `Surface` to compose content using the Arc system.
|
|
316
316
|
*/
|
|
@@ -325,7 +325,7 @@ var Surface = function (_a) {
|
|
|
325
325
|
background === "darker") {
|
|
326
326
|
surface = "dark";
|
|
327
327
|
}
|
|
328
|
-
return (React.createElement(Provider$
|
|
328
|
+
return (React.createElement(Provider$4, { value: { surface: surface } },
|
|
329
329
|
React.createElement("div", __assign({ className: classNames((_b = {
|
|
330
330
|
"arc-Surface": true
|
|
331
331
|
},
|
|
@@ -357,7 +357,7 @@ __spreadArray([], backgroundsShared, true);
|
|
|
357
357
|
var BrandLogo = function (_a) {
|
|
358
358
|
var _b;
|
|
359
359
|
var _c = _a.color, color = _c === void 0 ? "auto" : _c, label = _a.label, _d = _a.size, size = _d === void 0 ? 34 : _d, subBrand = _a.subBrand, props = __rest(_a, ["color", "label", "size", "subBrand"]);
|
|
360
|
-
var surface = useContext(Context$
|
|
360
|
+
var surface = useContext(Context$3).surface;
|
|
361
361
|
return (React.createElement("div", __assign({ className: classNames((_b = {
|
|
362
362
|
"arc-BrandLogo": true,
|
|
363
363
|
"arc-BrandLogo--colorBrand": color === "brand",
|
|
@@ -635,7 +635,7 @@ const iconsSelected = [
|
|
|
635
635
|
var Icon = function (_a) {
|
|
636
636
|
var _b;
|
|
637
637
|
var _c = _a.color, color = _c === void 0 ? "auto" : _c, icon = _a.icon, _d = _a.isInline, isInline = _d === void 0 ? false : _d, _e = _a.isSelected, isSelected = _e === void 0 ? false : _e, label = _a.label, size = _a.size, props = __rest(_a, ["color", "icon", "isInline", "isSelected", "label", "size"]);
|
|
638
|
-
var surface = useContext(Context$
|
|
638
|
+
var surface = useContext(Context$3).surface;
|
|
639
639
|
return (React.createElement("span", __assign({ "aria-label": label, className: classNames((_b = {},
|
|
640
640
|
_b["arc-Icon"] = true,
|
|
641
641
|
_b[suffixModifier("arc-Icon--color", color)] = color !== "auto",
|
|
@@ -653,8 +653,8 @@ var Icon = function (_a) {
|
|
|
653
653
|
*/
|
|
654
654
|
var Button = forwardRef(function (_a, ref) {
|
|
655
655
|
var _b;
|
|
656
|
-
var ariaLabel = _a.ariaLabel, _c = _a.fill, fill = _c === void 0 ? "solid" : _c, href = _a.href, icon = _a.icon, _d = _a.iconPosition, iconPosition = _d === void 0 ? "afterText" : _d, id = _a.id, _e = _a.isDisabled, isDisabled = _e === void 0 ? false : _e, _f = _a.isDisplayBlock, isDisplayBlock = _f === void 0 ? false : _f, _g = _a.isFullWidth, isFullWidth = _g === void 0 ? false : _g, label = _a.label, onClick = _a.onClick, rel = _a.rel, target = _a.target, type = _a.type, props = __rest(_a, ["ariaLabel", "fill", "href", "icon", "iconPosition", "id", "isDisabled", "isDisplayBlock", "isFullWidth", "label", "onClick", "rel", "target", "type"]);
|
|
657
|
-
var surface = useContext(Context$
|
|
656
|
+
var ariaLabel = _a.ariaLabel, _c = _a.fill, fill = _c === void 0 ? "solid" : _c, href = _a.href, icon = _a.icon, _d = _a.iconPosition, iconPosition = _d === void 0 ? "afterText" : _d, id = _a.id, _e = _a.isDisabled, isDisabled = _e === void 0 ? false : _e, _f = _a.isDisplayBlock, isDisplayBlock = _f === void 0 ? false : _f, _g = _a.isFullWidth, isFullWidth = _g === void 0 ? false : _g, label = _a.label, onClick = _a.onClick, rel = _a.rel, supportingText = _a.supportingText, target = _a.target, type = _a.type, props = __rest(_a, ["ariaLabel", "fill", "href", "icon", "iconPosition", "id", "isDisabled", "isDisplayBlock", "isFullWidth", "label", "onClick", "rel", "supportingText", "target", "type"]);
|
|
657
|
+
var surface = useContext(Context$3).surface;
|
|
658
658
|
var buttonClasses = classNames((_b = {
|
|
659
659
|
"arc-Button": true,
|
|
660
660
|
"arc-Button--displayBlock": isDisplayBlock
|
|
@@ -664,19 +664,23 @@ var Button = forwardRef(function (_a, ref) {
|
|
|
664
664
|
_b[suffixModifier("arc-Button--icon", iconPosition.replace("icon", ""))] = (icon || fill === "flat") &&
|
|
665
665
|
iconPosition &&
|
|
666
666
|
iconPosition !== "afterText",
|
|
667
|
+
_b["arc-Button--hasSupportingText"] = supportingText,
|
|
667
668
|
_b["arc-Button--onDarkSurface"] = surface === "dark",
|
|
668
669
|
_b));
|
|
669
670
|
var commonProps = __assign({ id: id, onClick: onClick, ref: ref }, filterDataAttrs(props));
|
|
671
|
+
var buttonText = supportingText ? (React.createElement("span", null,
|
|
672
|
+
React.createElement("span", { className: "arc-Button-text" }, label),
|
|
673
|
+
React.createElement("span", { className: "arc-Button-supportingText" }, supportingText))) : (React.createElement("span", { className: "arc-Button-text" }, label));
|
|
670
674
|
var buttonIcon = icon || fill === "flat" ? (React.createElement(ButtonIcon, { icon: icon, isChevron: !icon && fill === "flat", isBeforeText: iconPosition === "beforeText" })) : null;
|
|
671
675
|
if (href && !isDisabled) {
|
|
672
676
|
return (React.createElement("a", __assign({}, commonProps, { "aria-label": ariaLabel, className: buttonClasses, href: href, rel: rel, target: target }),
|
|
673
677
|
React.createElement("span", { className: "arc-Button-inner" },
|
|
674
|
-
|
|
678
|
+
buttonText,
|
|
675
679
|
buttonIcon)));
|
|
676
680
|
}
|
|
677
681
|
return (React.createElement("button", __assign({}, commonProps, { "aria-label": ariaLabel, className: buttonClasses, disabled: isDisabled, type: type }),
|
|
678
682
|
React.createElement("span", { className: "arc-Button-inner" },
|
|
679
|
-
|
|
683
|
+
buttonText,
|
|
680
684
|
buttonIcon)));
|
|
681
685
|
});
|
|
682
686
|
var ButtonIcon = function (_a) {
|
|
@@ -709,7 +713,7 @@ var Image = function (_a) {
|
|
|
709
713
|
var Heading = function (_a) {
|
|
710
714
|
var _b;
|
|
711
715
|
var _c = _a.align, align = _c === void 0 ? "left" : _c, _d = _a.casing, casing = _d === void 0 ? "auto" : _d, children = _a.children, _e = _a.color, color = _e === void 0 ? "auto" : _e, level = _a.level, size = _a.size, _f = _a.typeface, typeface = _f === void 0 ? "default" : _f, props = __rest(_a, ["align", "casing", "children", "color", "level", "size", "typeface"]);
|
|
712
|
-
var surface = useContext(Context$
|
|
716
|
+
var surface = useContext(Context$3).surface;
|
|
713
717
|
var Element = "span";
|
|
714
718
|
if (level) {
|
|
715
719
|
Element = "h".concat(level);
|
|
@@ -853,7 +857,7 @@ var useNumericInput = function (props) {
|
|
|
853
857
|
var Card = function (_a) {
|
|
854
858
|
var _b;
|
|
855
859
|
var actionId = _a.actionId, _c = _a.actionLabel, actionLabel = _c === void 0 ? "Read more" : _c, children = _a.children, _d = _a.fill, fill = _d === void 0 ? "solid" : _d, href = _a.href, imageAlt = _a.imageAlt, imageSrc = _a.imageSrc, imageSrcSet = _a.imageSrcSet, imageHeight = _a.imageHeight, minHeight = _a.minHeight, target = _a.target, title = _a.title, _e = _a.titleSize, titleSize = _e === void 0 ? "s" : _e, props = __rest(_a, ["actionId", "actionLabel", "children", "fill", "href", "imageAlt", "imageSrc", "imageSrcSet", "imageHeight", "minHeight", "target", "title", "titleSize"]);
|
|
856
|
-
var surface = useContext(Context$
|
|
860
|
+
var surface = useContext(Context$3).surface;
|
|
857
861
|
var interactionMode = useInteractionMode().interactionMode;
|
|
858
862
|
var Wrapper = function (_a) {
|
|
859
863
|
var children = _a.children;
|
|
@@ -912,7 +916,7 @@ Card.Image = CardImage;
|
|
|
912
916
|
*/
|
|
913
917
|
var CardLink = function (_a) {
|
|
914
918
|
var actionId = _a.actionId, isButton = _a.isButton, children = _a.children, fill = _a.fill, href = _a.href, stretch = _a.stretch, target = _a.target;
|
|
915
|
-
var surface = useContext(Context$
|
|
919
|
+
var surface = useContext(Context$3).surface;
|
|
916
920
|
return (React.createElement("a", { "aria-describedby": actionId, className: classNames({
|
|
917
921
|
"arc-CardLink": true,
|
|
918
922
|
"arc-CardLink--button": isButton,
|
|
@@ -924,38 +928,87 @@ var CardLink = function (_a) {
|
|
|
924
928
|
React.createElement(Icon, { icon: "btChevronRight2px", size: 8 })))));
|
|
925
929
|
};
|
|
926
930
|
|
|
931
|
+
var defaultContext$2 = {
|
|
932
|
+
requirementStatus: null
|
|
933
|
+
};
|
|
934
|
+
var Context$2 = createContext(defaultContext$2);
|
|
935
|
+
var Provider$3 = Context$2.Provider;
|
|
936
|
+
/**
|
|
937
|
+
* Use `FormControl` to provide inputs with labels, helper text and error messages
|
|
938
|
+
*/
|
|
939
|
+
var FormControl = function (_a) {
|
|
940
|
+
var children = _a.children, _b = _a.elementType, ElementType = _b === void 0 ? "div" : _b, errorMessage = _a.errorMessage, helper = _a.helper, htmlFor = _a.htmlFor, id = _a.id, label = _a.label, _c = _a.labelSize, labelSize = _c === void 0 ? "l" : _c, _d = _a.requirementStatus, requirementStatus = _d === void 0 ? "optional" : _d, props = __rest(_a, ["children", "elementType", "errorMessage", "helper", "htmlFor", "id", "label", "labelSize", "requirementStatus"]);
|
|
941
|
+
var surface = useContext(Context$3).surface;
|
|
942
|
+
var _e = useAriaDescribedby({
|
|
943
|
+
errorMessage: errorMessage,
|
|
944
|
+
helper: helper,
|
|
945
|
+
id: htmlFor || id // `htmlFor` is preference to keep this deterministic with TextInput
|
|
946
|
+
}), ariaDescribedby = _e.ariaDescribedby, idError = _e.idError, idHelper = _e.idHelper;
|
|
947
|
+
var LabelType = ElementType === "div" ? "label" : "legend";
|
|
948
|
+
var elementProps = {};
|
|
949
|
+
var labelProps = {};
|
|
950
|
+
if (LabelType === "label") {
|
|
951
|
+
labelProps["htmlFor"] = htmlFor;
|
|
952
|
+
if (htmlFor) {
|
|
953
|
+
labelProps["id"] = "".concat(htmlFor, "-label");
|
|
954
|
+
}
|
|
955
|
+
else if (id) {
|
|
956
|
+
labelProps["id"] = "".concat(id, "-label");
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
else {
|
|
960
|
+
elementProps["aria-describedby"] = ariaDescribedby;
|
|
961
|
+
}
|
|
962
|
+
return (React.createElement(Provider$3, { value: { requirementStatus: requirementStatus } },
|
|
963
|
+
React.createElement(ElementType, __assign({ className: classNames({
|
|
964
|
+
"arc-FormControl": true,
|
|
965
|
+
"arc-FormControl--smallLabel": labelSize === "s",
|
|
966
|
+
"arc-FormControl--onDarkSurface": surface === "dark"
|
|
967
|
+
}), id: id }, elementProps, filterDataAttrs(props)),
|
|
968
|
+
React.createElement(LabelType, __assign({ className: "arc-FormControl-label" }, labelProps),
|
|
969
|
+
label,
|
|
970
|
+
requirementStatus === "optional" && (React.createElement("span", { className: "arc-FormControl-labelOptional" }, "(optional)"))),
|
|
971
|
+
helper && (React.createElement("div", { className: "arc-FormControl-helper", id: idHelper }, helper)),
|
|
972
|
+
children,
|
|
973
|
+
errorMessage && (React.createElement("div", { className: "arc-FormControl-error", id: idError }, errorMessage)))));
|
|
974
|
+
};
|
|
975
|
+
|
|
927
976
|
/**
|
|
928
977
|
* Use `Checkbox` to allow users to select individual options.
|
|
929
978
|
*/
|
|
930
979
|
var Checkbox = forwardRef(function (_a, ref) {
|
|
931
|
-
var
|
|
932
|
-
var
|
|
933
|
-
var
|
|
980
|
+
var _b = _a.checked, checked = _b === void 0 ? false : _b, errorMessage = _a.errorMessage, helper = _a.helper, id = _a.id, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isRequired, isRequired = _d === void 0 ? false : _d, label = _a.label, name = _a.name, onBlur = _a.onBlur, onChange = _a.onChange, _e = _a.size, size = _e === void 0 ? "l" : _e, value = _a.value, props = __rest(_a, ["checked", "errorMessage", "helper", "id", "isDisabled", "isRequired", "label", "name", "onBlur", "onChange", "size", "value"]);
|
|
981
|
+
var requirementStatus = useContext(Context$2).requirementStatus;
|
|
982
|
+
var surface = useContext(Context$3).surface;
|
|
983
|
+
var _f = useAriaDescribedby({
|
|
934
984
|
id: id,
|
|
935
|
-
errorMessage: errorMessage
|
|
936
|
-
|
|
937
|
-
}), ariaDescribedby = _e.ariaDescribedby, idHelper = _e.idHelper, idError = _e.idError;
|
|
985
|
+
errorMessage: errorMessage
|
|
986
|
+
}), ariaDescribedby = _f.ariaDescribedby, idError = _f.idError;
|
|
938
987
|
var idLabel = "".concat(id, "-label");
|
|
939
988
|
var checkedProps = {};
|
|
940
989
|
if (typeof onChange === "function") {
|
|
941
|
-
checkedProps.checked =
|
|
990
|
+
checkedProps.checked = checked;
|
|
942
991
|
}
|
|
943
|
-
else if (
|
|
992
|
+
else if (checked && !onChange) {
|
|
944
993
|
checkedProps.defaultChecked = true;
|
|
945
994
|
}
|
|
995
|
+
if (requirementStatus === "required") {
|
|
996
|
+
isRequired = true;
|
|
997
|
+
}
|
|
946
998
|
return (React.createElement("div", { className: classNames({
|
|
947
999
|
"arc-Checkbox": true,
|
|
948
1000
|
"arc-Checkbox--disabled": isDisabled,
|
|
949
1001
|
"arc-Checkbox--invalid": errorMessage,
|
|
1002
|
+
"arc-Checkbox--small": size === "s",
|
|
950
1003
|
"arc-Checkbox--onDarkSurface": surface === "dark"
|
|
951
1004
|
}) },
|
|
952
1005
|
React.createElement("label", { id: idLabel, htmlFor: id, className: "arc-Checkbox-label" },
|
|
953
|
-
React.createElement("input", __assign({ "aria-describedby": ariaDescribedby, "aria-
|
|
1006
|
+
React.createElement("input", __assign({ "aria-describedby": ariaDescribedby, "aria-invalid": errorMessage ? "true" : "false", className: "arc-Checkbox-input" }, checkedProps, { disabled: isDisabled, id: id, name: name, onBlur: onBlur, onChange: onChange, ref: ref, required: isRequired, type: "checkbox", value: value }, filterDataAttrs(props))),
|
|
954
1007
|
React.createElement("span", { className: "arc-Checkbox-box" }),
|
|
955
1008
|
React.createElement("span", null,
|
|
956
1009
|
label,
|
|
957
|
-
!isRequired && " (
|
|
958
|
-
|
|
1010
|
+
!isRequired && requirementStatus !== "optional" ? (React.createElement("span", { className: "arc-Checkbox-labelOptional" }, "(optional)")) : null,
|
|
1011
|
+
helper && React.createElement("span", { className: "arc-Checkbox-helper" }, helper))),
|
|
959
1012
|
errorMessage && (React.createElement("div", { id: idError, className: "arc-Checkbox-error" }, errorMessage))));
|
|
960
1013
|
});
|
|
961
1014
|
|
|
@@ -1058,7 +1111,7 @@ var Curve = function (_a) {
|
|
|
1058
1111
|
*/
|
|
1059
1112
|
var Disclosure = function (_a) {
|
|
1060
1113
|
var children = _a.children, headingLevel = _a.headingLevel, _b = _a.indentDetails, indentDetails = _b === void 0 ? false : _b, _c = _a.isOpen, isOpen = _c === void 0 ? false : _c, summary = _a.summary, props = __rest(_a, ["children", "headingLevel", "indentDetails", "isOpen", "summary"]);
|
|
1061
|
-
var surface = useContext(Context$
|
|
1114
|
+
var surface = useContext(Context$3).surface;
|
|
1062
1115
|
return (React.createElement("details", __assign({ className: classNames({
|
|
1063
1116
|
"arc-Disclosure": true,
|
|
1064
1117
|
"arc-Disclosure--indentDetails": indentDetails,
|
|
@@ -1081,53 +1134,13 @@ var Elevation = function (_a) {
|
|
|
1081
1134
|
_b)) }, filterDataAttrs(props)), children));
|
|
1082
1135
|
};
|
|
1083
1136
|
|
|
1084
|
-
/**
|
|
1085
|
-
* Use `FormControl` to provide inputs with labels, helper text and error messages
|
|
1086
|
-
*/
|
|
1087
|
-
var FormControl = function (_a) {
|
|
1088
|
-
var children = _a.children, _b = _a.elementType, ElementType = _b === void 0 ? "div" : _b, errorMessage = _a.errorMessage, helper = _a.helper, htmlFor = _a.htmlFor, id = _a.id, _c = _a.isRequired, isRequired = _c === void 0 ? false : _c, label = _a.label, _d = _a.labelSize, labelSize = _d === void 0 ? "l" : _d, props = __rest(_a, ["children", "elementType", "errorMessage", "helper", "htmlFor", "id", "isRequired", "label", "labelSize"]);
|
|
1089
|
-
var surface = useContext(Context$2).surface;
|
|
1090
|
-
var _e = useAriaDescribedby({
|
|
1091
|
-
errorMessage: errorMessage,
|
|
1092
|
-
helper: helper,
|
|
1093
|
-
id: htmlFor || id // `htmlFor` is preference to keep this deterministic with TextInput
|
|
1094
|
-
}), ariaDescribedby = _e.ariaDescribedby, idError = _e.idError, idHelper = _e.idHelper;
|
|
1095
|
-
var LabelType = ElementType === "div" ? "label" : "legend";
|
|
1096
|
-
var elementProps = {};
|
|
1097
|
-
var labelProps = {};
|
|
1098
|
-
if (LabelType === "label") {
|
|
1099
|
-
labelProps["htmlFor"] = htmlFor;
|
|
1100
|
-
if (htmlFor) {
|
|
1101
|
-
labelProps["id"] = "".concat(htmlFor, "-label");
|
|
1102
|
-
}
|
|
1103
|
-
else if (id) {
|
|
1104
|
-
labelProps["id"] = "".concat(id, "-label");
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
else {
|
|
1108
|
-
elementProps["aria-describedby"] = ariaDescribedby;
|
|
1109
|
-
}
|
|
1110
|
-
return (React.createElement(ElementType, __assign({ className: classNames({
|
|
1111
|
-
"arc-FormControl": true,
|
|
1112
|
-
"arc-FormControl--smallLabel": labelSize === "s",
|
|
1113
|
-
"arc-FormControl--onDarkSurface": surface === "dark"
|
|
1114
|
-
}), id: id }, elementProps, filterDataAttrs(props)),
|
|
1115
|
-
React.createElement(LabelType, __assign({ className: "arc-FormControl-label" }, labelProps),
|
|
1116
|
-
label,
|
|
1117
|
-
" ",
|
|
1118
|
-
!isRequired && (React.createElement("span", { className: "arc-FormControl-labelOptional" }, "(Optional)"))),
|
|
1119
|
-
helper && (React.createElement("div", { className: "arc-FormControl-helper", id: idHelper }, helper)),
|
|
1120
|
-
children,
|
|
1121
|
-
errorMessage && (React.createElement("div", { className: "arc-FormControl-error", id: idError }, errorMessage))));
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
1137
|
/**
|
|
1125
1138
|
* Use `Group` to arrange flexible items in a row.
|
|
1126
1139
|
*/
|
|
1127
1140
|
var Group = function (_a) {
|
|
1128
1141
|
var _b;
|
|
1129
1142
|
var children = _a.children, _c = _a.grow, grow = _c === void 0 ? false : _c, _d = _a.growEqual, growEqual = _d === void 0 ? false : _d, _e = _a.gutterBorder, gutterBorder = _e === void 0 ? false : _e, _f = _a.noWrap, noWrap = _f === void 0 ? false : _f, props = __rest(_a, ["children", "grow", "growEqual", "gutterBorder", "noWrap"]);
|
|
1130
|
-
var surface = useContext(Context$
|
|
1143
|
+
var surface = useContext(Context$3).surface;
|
|
1131
1144
|
useEffect(function () {
|
|
1132
1145
|
React.Children.map(children, function (item) {
|
|
1133
1146
|
if (item && item.type !== GroupItem) {
|
|
@@ -1162,7 +1175,7 @@ Group.Item = GroupItem;
|
|
|
1162
1175
|
*/
|
|
1163
1176
|
var Markup = function (_a) {
|
|
1164
1177
|
var children = _a.children, _b = _a.isMeasured, isMeasured = _b === void 0 ? false : _b, props = __rest(_a, ["children", "isMeasured"]);
|
|
1165
|
-
var surface = useContext(Context$
|
|
1178
|
+
var surface = useContext(Context$3).surface;
|
|
1166
1179
|
return (React.createElement("div", __assign({ className: classNames({
|
|
1167
1180
|
"arc-Markup": true,
|
|
1168
1181
|
"arc-Markup--measured": isMeasured,
|
|
@@ -1234,9 +1247,6 @@ var RadioContext = createContext({});
|
|
|
1234
1247
|
var Provider$2 = RadioContext.Provider;
|
|
1235
1248
|
var useRadioContext = function () {
|
|
1236
1249
|
var context = useContext(RadioContext);
|
|
1237
|
-
if (!context) {
|
|
1238
|
-
console.warn("Ensure to use <RadioGroup.RadioButton /> within the <RadioGroup /> or its branded version.");
|
|
1239
|
-
}
|
|
1240
1250
|
return context;
|
|
1241
1251
|
};
|
|
1242
1252
|
|
|
@@ -1244,60 +1254,57 @@ var useRadioContext = function () {
|
|
|
1244
1254
|
* Radio Button component.
|
|
1245
1255
|
*/
|
|
1246
1256
|
var RadioButton = forwardRef(function (_a, ref) {
|
|
1247
|
-
var helper = _a.helper, id = _a.id, label = _a.label, value = _a.value, props = __rest(_a, ["helper", "id", "label", "value"]);
|
|
1248
|
-
var _b = useRadioContext(),
|
|
1249
|
-
var surface = useContext(Context$
|
|
1250
|
-
var _c = useAriaDescribedby({
|
|
1251
|
-
id: id,
|
|
1252
|
-
idError: "".concat(errorId, "-error"),
|
|
1253
|
-
helper: helper,
|
|
1254
|
-
errorMessage: errorMessage
|
|
1255
|
-
}), ariaDescribedby = _c.ariaDescribedby, idHelper = _c.idHelper;
|
|
1257
|
+
var helper = _a.helper, id = _a.id, isDisabled = _a.isDisabled, label = _a.label, value = _a.value, props = __rest(_a, ["helper", "id", "isDisabled", "label", "value"]);
|
|
1258
|
+
var _b = useRadioContext(), blurEvent = _b.blurEvent, changeEvent = _b.changeEvent, groupDisabled = _b.groupDisabled, checkedValue = _b.checkedValue, labelSize = _b.labelSize, name = _b.name, size = _b.size;
|
|
1259
|
+
var surface = useContext(Context$3).surface;
|
|
1256
1260
|
var idLabel = "".concat(id, "-label");
|
|
1257
|
-
var checked =
|
|
1258
|
-
var disabled = isDisabled ? isDisabled : false;
|
|
1261
|
+
var checked = checkedValue === value ? true : false;
|
|
1259
1262
|
return (React.createElement("div", __assign({ className: classNames({
|
|
1260
1263
|
"arc-RadioButton": true,
|
|
1261
|
-
"arc-RadioButton--
|
|
1262
|
-
"arc-RadioButton--
|
|
1263
|
-
"arc-RadioButton--
|
|
1264
|
-
"arc-RadioButton--required": isRequired,
|
|
1264
|
+
"arc-RadioButton--disabled": isDisabled || groupDisabled,
|
|
1265
|
+
"arc-RadioButton--small": size === "s",
|
|
1266
|
+
"arc-RadioButton--smallLabel": labelSize === "s",
|
|
1265
1267
|
"arc-RadioButton--onDarkSurface": surface === "dark"
|
|
1266
1268
|
}) }, filterDataAttrs(props)),
|
|
1267
|
-
React.createElement("
|
|
1268
|
-
|
|
1269
|
-
|
|
1269
|
+
React.createElement("label", { className: "arc-RadioButton-label", htmlFor: id, id: idLabel },
|
|
1270
|
+
React.createElement("input", { className: "arc-RadioButton-input", checked: typeof changeEvent !== "function" ? undefined : checked, defaultChecked: typeof changeEvent !== "function" ? checked : undefined, disabled: isDisabled || groupDisabled, id: id, name: name, onBlur: blurEvent, onChange: changeEvent, ref: ref, type: "radio", value: value }),
|
|
1271
|
+
React.createElement("span", null,
|
|
1272
|
+
label,
|
|
1273
|
+
helper && React.createElement("span", { className: "arc-RadioButton-helper" }, helper)))));
|
|
1270
1274
|
});
|
|
1271
1275
|
|
|
1272
1276
|
/**
|
|
1273
1277
|
* Use `RadioGroup` to wrap and control radio buttons and apply default values
|
|
1274
1278
|
*/
|
|
1275
1279
|
var RadioGroup = function (_a) {
|
|
1276
|
-
var children = _a.children,
|
|
1280
|
+
var children = _a.children, checkedValue = _a.checkedValue, _b = _a.isDisabled, isDisabled = _b === void 0 ? false : _b, id = _a.id, helper = _a.helper, label = _a.label, _c = _a.labelSize, labelSize = _c === void 0 ? "l" : _c, name = _a.name, onBlur = _a.onBlur, onChange = _a.onChange, _d = _a.size, size = _d === void 0 ? "l" : _d, props = __rest(_a, ["children", "checkedValue", "isDisabled", "id", "helper", "label", "labelSize", "name", "onBlur", "onChange", "size"]);
|
|
1281
|
+
useEffect(function () {
|
|
1282
|
+
React.Children.map(children, function (item) {
|
|
1283
|
+
if (item && item.type !== RadioButton) {
|
|
1284
|
+
throw new Error("Illegal child passed to <RadioGroup />. Ensure to only use <RadioGroup.RadioButton />.");
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
}, [children]);
|
|
1277
1288
|
return (React.createElement(Provider$2, { value: {
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
errorMessage: errorMessage,
|
|
1289
|
+
blurEvent: onBlur,
|
|
1290
|
+
changeEvent: onChange,
|
|
1291
|
+
groupDisabled: isDisabled,
|
|
1292
|
+
checkedValue: checkedValue,
|
|
1293
|
+
labelSize: labelSize,
|
|
1284
1294
|
name: name,
|
|
1285
|
-
|
|
1295
|
+
size: size
|
|
1286
1296
|
} },
|
|
1287
|
-
React.createElement(
|
|
1288
|
-
React.createElement("
|
|
1289
|
-
"arc-RadioGroup": true,
|
|
1290
|
-
"arc-RadioGroup--invalid": errorMessage,
|
|
1291
|
-
"arc-RadioGroup--disabled": isDisabled
|
|
1292
|
-
}) }, filterDataAttrs(props)), children))));
|
|
1297
|
+
React.createElement("div", __assign({ className: "arc-RadioGroup" }, filterDataAttrs(props)),
|
|
1298
|
+
React.createElement(FormControl, { elementType: "fieldset", label: label, labelSize: labelSize, helper: helper, id: id, requirementStatus: "not-applicable" }, children))));
|
|
1293
1299
|
};
|
|
1300
|
+
RadioButton.displayName = "RadioGroup.RadioButton";
|
|
1294
1301
|
RadioGroup.RadioButton = RadioButton;
|
|
1295
1302
|
|
|
1296
1303
|
/**
|
|
1297
1304
|
* Use `Rule` to display a horizontal rule.
|
|
1298
1305
|
*/
|
|
1299
1306
|
var Rule = function (props) {
|
|
1300
|
-
var surface = useContext(Context$
|
|
1307
|
+
var surface = useContext(Context$3).surface;
|
|
1301
1308
|
return (React.createElement("hr", __assign({ className: classNames({
|
|
1302
1309
|
"arc-Rule": true,
|
|
1303
1310
|
"arc-Rule--onDarkSurface": surface === "dark"
|
|
@@ -1969,7 +1976,7 @@ SiteHeaderRehydrator.SubNavItemRehydrator = SubNavItemRehydrator;
|
|
|
1969
1976
|
var Text = function (_a) {
|
|
1970
1977
|
var _b;
|
|
1971
1978
|
var _c = _a.align, align = _c === void 0 ? "left" : _c, children = _a.children, _d = _a.isInline, isInline = _d === void 0 ? false : _d, _e = _a.isMeasured, isMeasured = _e === void 0 ? false : _e, _f = _a.size, size = _f === void 0 ? "m" : _f, _g = _a.tone, tone = _g === void 0 ? "default" : _g, props = __rest(_a, ["align", "children", "isInline", "isMeasured", "size", "tone"]);
|
|
1972
|
-
var surface = useContext(Context$
|
|
1979
|
+
var surface = useContext(Context$3).surface;
|
|
1973
1980
|
return (React.createElement("span", __assign({ className: classNames((_b = {
|
|
1974
1981
|
"arc-Text": true
|
|
1975
1982
|
},
|
|
@@ -1986,8 +1993,8 @@ var Text = function (_a) {
|
|
|
1986
1993
|
* Use `TextInput` to allow custom user text entry with a keyboard.
|
|
1987
1994
|
*/
|
|
1988
1995
|
var TextInput = forwardRef(function (_a, ref) {
|
|
1989
|
-
var _b = _a.defaultValue, defaultValue = _b === void 0 ? "" : _b, errorMessage = _a.errorMessage, helper = _a.helper, id = _a.id, inputMode = _a.inputMode, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isReadOnly, isReadOnly = _d === void 0 ? false : _d, _e = _a.isRequired, isRequired = _e === void 0 ? false : _e, label = _a.label, _f = _a.labelSize, labelSize = _f === void 0 ? "l" : _f, maxLength = _a.maxLength, minLength = _a.minLength, name = _a.name, onChange = _a.onChange, pattern = _a.pattern, _g = _a.type, type = _g === void 0 ? "text" : _g, value = _a.value, props = __rest(_a, ["defaultValue", "errorMessage", "helper", "id", "inputMode", "isDisabled", "isReadOnly", "isRequired", "label", "labelSize", "maxLength", "minLength", "name", "onChange", "pattern", "type", "value"]);
|
|
1990
|
-
var surface = useContext(Context$
|
|
1996
|
+
var _b = _a.defaultValue, defaultValue = _b === void 0 ? "" : _b, errorMessage = _a.errorMessage, helper = _a.helper, id = _a.id, inputMode = _a.inputMode, _c = _a.isDisabled, isDisabled = _c === void 0 ? false : _c, _d = _a.isReadOnly, isReadOnly = _d === void 0 ? false : _d, _e = _a.isRequired, isRequired = _e === void 0 ? false : _e, label = _a.label, _f = _a.labelSize, labelSize = _f === void 0 ? "l" : _f, maxLength = _a.maxLength, minLength = _a.minLength, name = _a.name, onBlur = _a.onBlur, onChange = _a.onChange, pattern = _a.pattern, _g = _a.type, type = _g === void 0 ? "text" : _g, value = _a.value, props = __rest(_a, ["defaultValue", "errorMessage", "helper", "id", "inputMode", "isDisabled", "isReadOnly", "isRequired", "label", "labelSize", "maxLength", "minLength", "name", "onBlur", "onChange", "pattern", "type", "value"]);
|
|
1997
|
+
var surface = useContext(Context$3).surface;
|
|
1991
1998
|
var inferredInputProps = useNumericInput({ inputMode: inputMode, pattern: pattern, type: type });
|
|
1992
1999
|
// Although this is used within FormControlWrapper, it's deterministic so we can call it here too
|
|
1993
2000
|
var ariaDescribedby = useAriaDescribedby({
|
|
@@ -2000,8 +2007,8 @@ var TextInput = forwardRef(function (_a, ref) {
|
|
|
2000
2007
|
"arc-TextInput--invalid": errorMessage,
|
|
2001
2008
|
"arc-TextInput--onDarkSurface": surface === "dark"
|
|
2002
2009
|
}) }, filterDataAttrs(props)),
|
|
2003
|
-
React.createElement(FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id,
|
|
2004
|
-
React.createElement("input", __assign({ "aria-describedby": ariaDescribedby, "aria-invalid": errorMessage ? "true" : "false",
|
|
2010
|
+
React.createElement(FormControl, { errorMessage: errorMessage, helper: helper, htmlFor: id, label: label, labelSize: labelSize, requirementStatus: isRequired ? "required" : "optional" },
|
|
2011
|
+
React.createElement("input", __assign({ "aria-describedby": ariaDescribedby, "aria-invalid": errorMessage ? "true" : "false", className: "arc-TextInput-input", defaultValue: typeof value !== "undefined" ? undefined : defaultValue, disabled: isDisabled, id: id, maxLength: maxLength, minLength: minLength, name: name, onChange: onChange, onBlur: onBlur, readOnly: isReadOnly, ref: ref, required: isRequired, value: typeof value !== "undefined" ? value : undefined }, inferredInputProps)))));
|
|
2005
2012
|
});
|
|
2006
2013
|
|
|
2007
2014
|
/**
|
|
@@ -2018,5 +2025,5 @@ var VerticalSpace = function (_a) {
|
|
|
2018
2025
|
_b)) }, filterDataAttrs(props))));
|
|
2019
2026
|
};
|
|
2020
2027
|
|
|
2021
|
-
export { Align, Base, BrandLogo, Button, Card, Checkbox, Clock, Clock_rehydrator as ClockRehydrator, Columns, Curve, Disclosure, Elevation, FormControl, Group, Heading, Icon, Image, Markup, Poster, RadioGroup, Rule, Section, SiteFooter, SiteFooter_rehydrator as SiteFooterRehydrator, SiteHeader, SiteHeaderRehydrator, Surface, Context$
|
|
2028
|
+
export { Align, Base, BrandLogo, Button, Card, Checkbox, Clock, Clock_rehydrator as ClockRehydrator, Columns, Curve, Disclosure, Elevation, FormControl, Group, Heading, Icon, Image, Markup, Poster, RadioGroup, Rule, Section, SiteFooter, SiteFooter_rehydrator as SiteFooterRehydrator, SiteHeader, SiteHeaderRehydrator, Surface, Context$3 as SurfaceContext, Text, TextInput, UniversalHeader, VerticalSpace };
|
|
2022
2029
|
//# sourceMappingURL=index.es.js.map
|