@nypl/design-system-react-components 1.2.1 → 1.2.2
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 +19 -0
- package/dist/components/SearchBar/SearchBar.d.ts +1 -0
- package/dist/components/TextInput/TextInput.d.ts +5 -3
- package/dist/design-system-react-components.cjs.development.js +90 -23
- package/dist/design-system-react-components.cjs.development.js.map +1 -1
- package/dist/design-system-react-components.cjs.production.min.js +1 -1
- package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
- package/dist/design-system-react-components.esm.js +90 -23
- package/dist/design-system-react-components.esm.js.map +1 -1
- package/dist/theme/components/hero.d.ts +10 -2
- package/dist/theme/components/textInput.d.ts +28 -1
- package/package.json +1 -1
|
@@ -599,7 +599,7 @@ var SvgErrorFilled = function SvgErrorFilled(_ref) {
|
|
|
599
599
|
}, title) : null, _path$n || (_path$n = /*#__PURE__*/createElement("path", {
|
|
600
600
|
fillRule: "evenodd",
|
|
601
601
|
clipRule: "evenodd",
|
|
602
|
-
d: "M12
|
|
602
|
+
d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1.003 11h-2V7h2v6Zm-2 3.998h2v-2h-2v2Z"
|
|
603
603
|
})));
|
|
604
604
|
};
|
|
605
605
|
|
|
@@ -613,7 +613,7 @@ var SvgErrorOutline = function SvgErrorOutline(_ref) {
|
|
|
613
613
|
titleId = _ref.titleId,
|
|
614
614
|
props = _objectWithoutProperties$o(_ref, _excluded$o);
|
|
615
615
|
return /*#__PURE__*/createElement("svg", _extends$p({
|
|
616
|
-
viewBox: "0 0 24
|
|
616
|
+
viewBox: "0 0 24 24",
|
|
617
617
|
xmlns: "http://www.w3.org/2000/svg",
|
|
618
618
|
role: "img",
|
|
619
619
|
"aria-labelledby": titleId
|
|
@@ -622,7 +622,7 @@ var SvgErrorOutline = function SvgErrorOutline(_ref) {
|
|
|
622
622
|
}, title) : null, _path$o || (_path$o = /*#__PURE__*/createElement("path", {
|
|
623
623
|
fillRule: "evenodd",
|
|
624
624
|
clipRule: "evenodd",
|
|
625
|
-
d: "M11.
|
|
625
|
+
d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2Zm1.013 5h-2v6h2V7Zm0 7.998h-2v2h2v-2Zm-9.002-2.996c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8-8 3.58-8 8Z"
|
|
626
626
|
})));
|
|
627
627
|
};
|
|
628
628
|
|
|
@@ -2444,8 +2444,7 @@ var Image = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
2444
2444
|
size: size
|
|
2445
2445
|
}, caption || credit ? {} : rest), imageComponent) : imageComponent;
|
|
2446
2446
|
return React__default.createElement(Box, {
|
|
2447
|
-
ref: finalRefs
|
|
2448
|
-
"data-testid": "test"
|
|
2447
|
+
ref: finalRefs
|
|
2449
2448
|
}, caption || credit ? React__default.createElement(Box, {
|
|
2450
2449
|
as: "figure",
|
|
2451
2450
|
__css: _extends({}, styles.figure, additionalFigureStyles)
|
|
@@ -3601,7 +3600,7 @@ var Label = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
3601
3600
|
}, rest), children, isRequired && React__default.createElement("span", null, requiredLabelText ? " (" + requiredLabelText + ")" : " (Required)"));
|
|
3602
3601
|
}));
|
|
3603
3602
|
|
|
3604
|
-
var _excluded$19 = ["className", "defaultValue", "helperText", "id", "invalidText", "isDisabled", "isInvalid", "isRequired", "labelText", "max", "maxLength", "min", "name", "onChange", "onClick", "onFocus", "placeholder", "showHelperInvalidText", "showLabel", "showRequiredLabel", "requiredLabelText", "step", "textInputType", "type", "value"];
|
|
3603
|
+
var _excluded$19 = ["className", "defaultValue", "helperText", "id", "invalidText", "isClearable", "isDisabled", "isInvalid", "isRequired", "labelText", "max", "maxLength", "min", "name", "onChange", "onClick", "onFocus", "placeholder", "showHelperInvalidText", "showLabel", "showRequiredLabel", "requiredLabelText", "step", "textInputType", "type", "value"];
|
|
3605
3604
|
// Only used internally.
|
|
3606
3605
|
var TextInputFormats = {
|
|
3607
3606
|
email: "jdoe@domain.com",
|
|
@@ -3623,6 +3622,8 @@ var TextInput = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
|
|
|
3623
3622
|
helperText = props.helperText,
|
|
3624
3623
|
id = props.id,
|
|
3625
3624
|
invalidText = props.invalidText,
|
|
3625
|
+
_props$isClearable = props.isClearable,
|
|
3626
|
+
isClearable = _props$isClearable === void 0 ? false : _props$isClearable,
|
|
3626
3627
|
_props$isDisabled = props.isDisabled,
|
|
3627
3628
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
3628
3629
|
_props$isInvalid = props.isInvalid,
|
|
@@ -3653,12 +3654,24 @@ var TextInput = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
|
|
|
3653
3654
|
type = _props$type === void 0 ? "text" : _props$type,
|
|
3654
3655
|
value = props.value,
|
|
3655
3656
|
rest = _objectWithoutPropertiesLoose(props, _excluded$19);
|
|
3657
|
+
var _useState = useState(value || ""),
|
|
3658
|
+
finalValue = _useState[0],
|
|
3659
|
+
setFinalValue = _useState[1];
|
|
3660
|
+
var closedRef = useRef();
|
|
3661
|
+
var mergedRefs = useMergeRefs(closedRef, ref);
|
|
3662
|
+
// If a ref is not passed, then merging refs won't work.
|
|
3663
|
+
var finalRef = ref ? mergedRefs : closedRef;
|
|
3656
3664
|
var styles = useMultiStyleConfig("TextInput", {
|
|
3665
|
+
showLabel: showLabel,
|
|
3657
3666
|
variant: textInputType
|
|
3658
3667
|
});
|
|
3659
3668
|
var isTextArea = type === "textarea";
|
|
3660
3669
|
var isHidden = type === "hidden";
|
|
3661
3670
|
var finalInvalidText = invalidText ? invalidText : "There is an error related to this field.";
|
|
3671
|
+
var internalOnChange = function internalOnChange(e) {
|
|
3672
|
+
setFinalValue(e.target.value);
|
|
3673
|
+
onChange && onChange(e);
|
|
3674
|
+
};
|
|
3662
3675
|
var footnote = isInvalid ? finalInvalidText : helperText;
|
|
3663
3676
|
var ariaAttributes = getAriaAttrs({
|
|
3664
3677
|
footnote: footnote,
|
|
@@ -3667,9 +3680,20 @@ var TextInput = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
|
|
|
3667
3680
|
name: "TextInput",
|
|
3668
3681
|
showLabel: showLabel
|
|
3669
3682
|
});
|
|
3683
|
+
var onClearClick = function onClearClick() {
|
|
3684
|
+
setFinalValue("");
|
|
3685
|
+
// Set focus back to the input element.
|
|
3686
|
+
finalRef.current.focus();
|
|
3687
|
+
};
|
|
3670
3688
|
var finalIsInvalid = isInvalid;
|
|
3671
3689
|
var fieldOutput;
|
|
3690
|
+
var clearButtonOutput;
|
|
3672
3691
|
var options;
|
|
3692
|
+
useEffect(function () {
|
|
3693
|
+
if (value && value !== finalValue) {
|
|
3694
|
+
setFinalValue(value);
|
|
3695
|
+
}
|
|
3696
|
+
}, [finalValue, value]);
|
|
3673
3697
|
if (!id) {
|
|
3674
3698
|
console.warn("NYPL Reservoir TextInput: This component's required `id` prop was not passed.");
|
|
3675
3699
|
}
|
|
@@ -3687,8 +3711,8 @@ var TextInput = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
|
|
|
3687
3711
|
id: id,
|
|
3688
3712
|
"aria-hidden": isHidden,
|
|
3689
3713
|
name: name,
|
|
3690
|
-
onChange:
|
|
3691
|
-
ref:
|
|
3714
|
+
onChange: internalOnChange,
|
|
3715
|
+
ref: finalRef
|
|
3692
3716
|
} : _extends({
|
|
3693
3717
|
"aria-required": isRequired,
|
|
3694
3718
|
defaultValue: defaultValue,
|
|
@@ -3700,11 +3724,11 @@ var TextInput = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
|
|
|
3700
3724
|
maxLength: maxLength,
|
|
3701
3725
|
min: min,
|
|
3702
3726
|
name: name,
|
|
3703
|
-
onChange:
|
|
3727
|
+
onChange: internalOnChange,
|
|
3704
3728
|
onClick: onClick,
|
|
3705
3729
|
onFocus: onFocus,
|
|
3706
3730
|
placeholder: placeholder,
|
|
3707
|
-
ref:
|
|
3731
|
+
ref: finalRef,
|
|
3708
3732
|
// The `step` attribute is useful for the number type.
|
|
3709
3733
|
step: type === "number" ? step : null
|
|
3710
3734
|
}, ariaAttributes, rest);
|
|
@@ -3713,12 +3737,27 @@ var TextInput = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
|
|
|
3713
3737
|
if (!isTextArea) {
|
|
3714
3738
|
options = _extends({
|
|
3715
3739
|
type: type,
|
|
3716
|
-
value:
|
|
3740
|
+
value: finalValue
|
|
3717
3741
|
}, options);
|
|
3718
3742
|
fieldOutput = React__default.createElement(Input, Object.assign({}, options, {
|
|
3719
3743
|
__css: styles.input
|
|
3720
3744
|
}));
|
|
3745
|
+
if (isClearable && !isHidden) {
|
|
3746
|
+
clearButtonOutput = React__default.createElement(Button, {
|
|
3747
|
+
buttonType: "text",
|
|
3748
|
+
id: id + "-clear-btn",
|
|
3749
|
+
onClick: onClearClick,
|
|
3750
|
+
sx: styles.clearButton
|
|
3751
|
+
}, React__default.createElement(Icon, {
|
|
3752
|
+
color: "ui.black",
|
|
3753
|
+
name: "close",
|
|
3754
|
+
size: "medium"
|
|
3755
|
+
}), React__default.createElement("span", null, "Clear ", labelText));
|
|
3756
|
+
}
|
|
3721
3757
|
} else {
|
|
3758
|
+
if (isClearable) {
|
|
3759
|
+
console.warn("NYPL Reservoir TextInput: The `isClearable` prop cannot be used with the `textarea` type.");
|
|
3760
|
+
}
|
|
3722
3761
|
fieldOutput = React__default.createElement(Textarea, Object.assign({}, options, {
|
|
3723
3762
|
__css: styles.textarea
|
|
3724
3763
|
}), value);
|
|
@@ -3736,7 +3775,7 @@ var TextInput = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
|
|
|
3736
3775
|
id: id + "-label",
|
|
3737
3776
|
isRequired: showRequiredLabel && isRequired,
|
|
3738
3777
|
requiredLabelText: requiredLabelText
|
|
3739
|
-
}, labelText), fieldOutput);
|
|
3778
|
+
}, labelText), fieldOutput, !isHidden && finalValue.length > 0 && clearButtonOutput);
|
|
3740
3779
|
}));
|
|
3741
3780
|
|
|
3742
3781
|
var _excluded$1a = ["dsRef", "helperText", "id", "invalidText", "isDisabled", "isInvalid", "isRequired", "labelText", "name", "onChange", "onClick", "showLabel", "showHelperInvalidText", "showRequiredLabel", "value"],
|
|
@@ -6904,10 +6943,17 @@ var tertiary = {
|
|
|
6904
6943
|
color: "ui.white",
|
|
6905
6944
|
display: "flex",
|
|
6906
6945
|
flexFlow: "column nowrap",
|
|
6907
|
-
|
|
6946
|
+
px: "inset.default",
|
|
6947
|
+
py: {
|
|
6948
|
+
base: "inset.default",
|
|
6949
|
+
xl: "inset.wide"
|
|
6950
|
+
},
|
|
6908
6951
|
p: {
|
|
6909
6952
|
marginBottom: "0",
|
|
6910
|
-
marginTop:
|
|
6953
|
+
marginTop: {
|
|
6954
|
+
base: "xxs",
|
|
6955
|
+
xl: "xs"
|
|
6956
|
+
}
|
|
6911
6957
|
}
|
|
6912
6958
|
}),
|
|
6913
6959
|
heading: {
|
|
@@ -8613,12 +8659,28 @@ var input = {
|
|
|
8613
8659
|
};
|
|
8614
8660
|
var TextInput$1 = {
|
|
8615
8661
|
parts: ["input", "textarea"],
|
|
8616
|
-
baseStyle: {
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8662
|
+
baseStyle: function baseStyle(_ref) {
|
|
8663
|
+
var showLabel = _ref.showLabel;
|
|
8664
|
+
return {
|
|
8665
|
+
position: "relative",
|
|
8666
|
+
input: input,
|
|
8667
|
+
textarea: _extends({}, input, {
|
|
8668
|
+
lineheight: "1.5",
|
|
8669
|
+
minHeight: "xxl"
|
|
8670
|
+
}),
|
|
8671
|
+
clearButton: {
|
|
8672
|
+
position: "absolute",
|
|
8673
|
+
// When `showLabel` is false, the input field is at the top
|
|
8674
|
+
// which means the clear button should float higher.
|
|
8675
|
+
top: showLabel ? "32px" : "0",
|
|
8676
|
+
px: "xs",
|
|
8677
|
+
right: "0",
|
|
8678
|
+
// Don't visually show the text. This also helps
|
|
8679
|
+
// use the "text" `Button` type.
|
|
8680
|
+
span: screenreaderOnly(),
|
|
8681
|
+
zIndex: "9999"
|
|
8682
|
+
}
|
|
8683
|
+
};
|
|
8622
8684
|
},
|
|
8623
8685
|
variants: {
|
|
8624
8686
|
searchBar: {
|
|
@@ -13799,6 +13861,7 @@ var SearchBar$1 = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props,
|
|
|
13799
13861
|
// Render the `TextInput` component.
|
|
13800
13862
|
var textInputNative = textInputProps && React__default.createElement(TextInput, Object.assign({
|
|
13801
13863
|
id: (textInputProps == null ? void 0 : textInputProps.id) || "searchbar-textinput-" + id,
|
|
13864
|
+
isClearable: textInputProps == null ? void 0 : textInputProps.isClearable,
|
|
13802
13865
|
labelText: textInputProps == null ? void 0 : textInputProps.labelText,
|
|
13803
13866
|
name: textInputProps == null ? void 0 : textInputProps.name,
|
|
13804
13867
|
onChange: textInputProps == null ? void 0 : textInputProps.onChange,
|
|
@@ -14530,12 +14593,16 @@ var Tooltip$1 = /*#__PURE__*/chakra( /*#__PURE__*/forwardRef(function (props, re
|
|
|
14530
14593
|
}, children) : children;
|
|
14531
14594
|
var styles = useMultiStyleConfig("Tooltip", {});
|
|
14532
14595
|
return React__default.createElement(Tooltip$2, Object.assign({
|
|
14533
|
-
hasArrow: true,
|
|
14534
14596
|
"aria-label": typeof content !== "string" ? "Tooltip" : undefined,
|
|
14535
|
-
|
|
14597
|
+
closeDelay: 750,
|
|
14598
|
+
closeOnClick: true,
|
|
14599
|
+
closeOnEsc: true,
|
|
14600
|
+
closeOnMouseDown: true,
|
|
14601
|
+
hasArrow: true,
|
|
14536
14602
|
isDisabled: isDisabled,
|
|
14537
|
-
|
|
14603
|
+
label: content,
|
|
14538
14604
|
openDelay: 500,
|
|
14605
|
+
placement: "top",
|
|
14539
14606
|
ref: ref,
|
|
14540
14607
|
__css: styles
|
|
14541
14608
|
}, rest), newChildren);
|