@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
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,25 @@ Currently, this repo is in Prerelease. When it is released, this project will ad
|
|
|
8
8
|
|
|
9
9
|
## Prerelease
|
|
10
10
|
|
|
11
|
+
## 1.2.2 (November 10, 2022)
|
|
12
|
+
|
|
13
|
+
### Adds
|
|
14
|
+
|
|
15
|
+
- Adds an `isClearable` prop to the `TextInput` component. When set to `true`, a close `Button` component will render on top of the input element. Once clicked, any text value in the input field will be cleared and focus will return to the input element.
|
|
16
|
+
- Adds the `isClearable` property to the `textInputProps` prop object in the `SearchBar` component. This allows the `isClearable` prop to be passed to the `TextInput` component to render the close `Button` component.
|
|
17
|
+
|
|
18
|
+
### Updates
|
|
19
|
+
|
|
20
|
+
- Updates the `Icon` and `Logo` documentation to include size values in px.
|
|
21
|
+
- Updates the spacing within the `tertiary` variant of the `Hero` component.
|
|
22
|
+
- Updates the `Buttons Style Guide` to extend the information about button sizes.
|
|
23
|
+
|
|
24
|
+
### Fixes
|
|
25
|
+
|
|
26
|
+
- Fixes an invalid TOC link on the `Card` component Storybook page.
|
|
27
|
+
- Fixes the sizing of the `errorFilled` and `errorOutline` icons in the `Icon` component.
|
|
28
|
+
- Adds new props to Chakra's `ToolTip` to more forcefully close the DS `ToolTip`. New props include `closeDelay`, `closeOnClick`, `closeOnEsc`, and `closeOnMouseDown`.
|
|
29
|
+
|
|
11
30
|
## 1.2.1 (October 27, 2022)
|
|
12
31
|
|
|
13
32
|
### Adds
|
|
@@ -22,6 +22,8 @@ export interface InputProps {
|
|
|
22
22
|
id: string;
|
|
23
23
|
/** Populates the HelperErrorText for the error state */
|
|
24
24
|
invalidText?: HelperErrorTextType;
|
|
25
|
+
/** Adds a button to clear existing text in the input field. */
|
|
26
|
+
isClearable?: boolean;
|
|
25
27
|
/** Adds the `disabled` and `aria-disabled` prop to the input when true */
|
|
26
28
|
isDisabled?: boolean;
|
|
27
29
|
/** Adds errored styling to the input/textarea and helper text elements */
|
|
@@ -48,6 +50,9 @@ export interface InputProps {
|
|
|
48
50
|
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
49
51
|
/** Populates the placeholder for the input/textarea elements */
|
|
50
52
|
placeholder?: string;
|
|
53
|
+
/** Allows the '(Required)' text to be changed for language purposes
|
|
54
|
+
* Note: Parenthesis will be added automatically by the component */
|
|
55
|
+
requiredLabelText?: string;
|
|
51
56
|
/** Offers the ability to hide the helper/invalid text. */
|
|
52
57
|
showHelperInvalidText?: boolean;
|
|
53
58
|
/** Offers the ability to show the label onscreen or hide it. Refer to the
|
|
@@ -56,9 +61,6 @@ export interface InputProps {
|
|
|
56
61
|
/** Whether or not to display the "(Required)" text in the label text.
|
|
57
62
|
* True by default. */
|
|
58
63
|
showRequiredLabel?: boolean;
|
|
59
|
-
/** Allows the '(Required)' text to be changed for language purposes
|
|
60
|
-
* Note: Parenthesis will be added automatically by the component */
|
|
61
|
-
requiredLabelText?: string;
|
|
62
64
|
/** The amount to increase or decrease when using the number type. */
|
|
63
65
|
step?: number;
|
|
64
66
|
/** FOR INTERNAL DS USE ONLY: the input variant to display. */
|
|
@@ -605,7 +605,7 @@ var SvgErrorFilled = function SvgErrorFilled(_ref) {
|
|
|
605
605
|
}, title) : null, _path$n || (_path$n = /*#__PURE__*/React.createElement("path", {
|
|
606
606
|
fillRule: "evenodd",
|
|
607
607
|
clipRule: "evenodd",
|
|
608
|
-
d: "M12
|
|
608
|
+
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"
|
|
609
609
|
})));
|
|
610
610
|
};
|
|
611
611
|
|
|
@@ -619,7 +619,7 @@ var SvgErrorOutline = function SvgErrorOutline(_ref) {
|
|
|
619
619
|
titleId = _ref.titleId,
|
|
620
620
|
props = _objectWithoutProperties$o(_ref, _excluded$o);
|
|
621
621
|
return /*#__PURE__*/React.createElement("svg", _extends$p({
|
|
622
|
-
viewBox: "0 0 24
|
|
622
|
+
viewBox: "0 0 24 24",
|
|
623
623
|
xmlns: "http://www.w3.org/2000/svg",
|
|
624
624
|
role: "img",
|
|
625
625
|
"aria-labelledby": titleId
|
|
@@ -628,7 +628,7 @@ var SvgErrorOutline = function SvgErrorOutline(_ref) {
|
|
|
628
628
|
}, title) : null, _path$o || (_path$o = /*#__PURE__*/React.createElement("path", {
|
|
629
629
|
fillRule: "evenodd",
|
|
630
630
|
clipRule: "evenodd",
|
|
631
|
-
d: "M11.
|
|
631
|
+
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"
|
|
632
632
|
})));
|
|
633
633
|
};
|
|
634
634
|
|
|
@@ -2450,8 +2450,7 @@ var Image = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(function (p
|
|
|
2450
2450
|
size: size
|
|
2451
2451
|
}, caption || credit ? {} : rest), imageComponent) : imageComponent;
|
|
2452
2452
|
return React__default.createElement(react.Box, {
|
|
2453
|
-
ref: finalRefs
|
|
2454
|
-
"data-testid": "test"
|
|
2453
|
+
ref: finalRefs
|
|
2455
2454
|
}, caption || credit ? React__default.createElement(react.Box, {
|
|
2456
2455
|
as: "figure",
|
|
2457
2456
|
__css: _extends({}, styles.figure, additionalFigureStyles)
|
|
@@ -3607,7 +3606,7 @@ var Label = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(function (p
|
|
|
3607
3606
|
}, rest), children, isRequired && React__default.createElement("span", null, requiredLabelText ? " (" + requiredLabelText + ")" : " (Required)"));
|
|
3608
3607
|
}));
|
|
3609
3608
|
|
|
3610
|
-
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"];
|
|
3609
|
+
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"];
|
|
3611
3610
|
// Only used internally.
|
|
3612
3611
|
var TextInputFormats = {
|
|
3613
3612
|
email: "jdoe@domain.com",
|
|
@@ -3629,6 +3628,8 @@ var TextInput = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(functio
|
|
|
3629
3628
|
helperText = props.helperText,
|
|
3630
3629
|
id = props.id,
|
|
3631
3630
|
invalidText = props.invalidText,
|
|
3631
|
+
_props$isClearable = props.isClearable,
|
|
3632
|
+
isClearable = _props$isClearable === void 0 ? false : _props$isClearable,
|
|
3632
3633
|
_props$isDisabled = props.isDisabled,
|
|
3633
3634
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
3634
3635
|
_props$isInvalid = props.isInvalid,
|
|
@@ -3659,12 +3660,24 @@ var TextInput = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(functio
|
|
|
3659
3660
|
type = _props$type === void 0 ? "text" : _props$type,
|
|
3660
3661
|
value = props.value,
|
|
3661
3662
|
rest = _objectWithoutPropertiesLoose(props, _excluded$19);
|
|
3663
|
+
var _useState = React.useState(value || ""),
|
|
3664
|
+
finalValue = _useState[0],
|
|
3665
|
+
setFinalValue = _useState[1];
|
|
3666
|
+
var closedRef = React.useRef();
|
|
3667
|
+
var mergedRefs = react.useMergeRefs(closedRef, ref);
|
|
3668
|
+
// If a ref is not passed, then merging refs won't work.
|
|
3669
|
+
var finalRef = ref ? mergedRefs : closedRef;
|
|
3662
3670
|
var styles = react.useMultiStyleConfig("TextInput", {
|
|
3671
|
+
showLabel: showLabel,
|
|
3663
3672
|
variant: textInputType
|
|
3664
3673
|
});
|
|
3665
3674
|
var isTextArea = type === "textarea";
|
|
3666
3675
|
var isHidden = type === "hidden";
|
|
3667
3676
|
var finalInvalidText = invalidText ? invalidText : "There is an error related to this field.";
|
|
3677
|
+
var internalOnChange = function internalOnChange(e) {
|
|
3678
|
+
setFinalValue(e.target.value);
|
|
3679
|
+
onChange && onChange(e);
|
|
3680
|
+
};
|
|
3668
3681
|
var footnote = isInvalid ? finalInvalidText : helperText;
|
|
3669
3682
|
var ariaAttributes = getAriaAttrs({
|
|
3670
3683
|
footnote: footnote,
|
|
@@ -3673,9 +3686,20 @@ var TextInput = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(functio
|
|
|
3673
3686
|
name: "TextInput",
|
|
3674
3687
|
showLabel: showLabel
|
|
3675
3688
|
});
|
|
3689
|
+
var onClearClick = function onClearClick() {
|
|
3690
|
+
setFinalValue("");
|
|
3691
|
+
// Set focus back to the input element.
|
|
3692
|
+
finalRef.current.focus();
|
|
3693
|
+
};
|
|
3676
3694
|
var finalIsInvalid = isInvalid;
|
|
3677
3695
|
var fieldOutput;
|
|
3696
|
+
var clearButtonOutput;
|
|
3678
3697
|
var options;
|
|
3698
|
+
React.useEffect(function () {
|
|
3699
|
+
if (value && value !== finalValue) {
|
|
3700
|
+
setFinalValue(value);
|
|
3701
|
+
}
|
|
3702
|
+
}, [finalValue, value]);
|
|
3679
3703
|
if (!id) {
|
|
3680
3704
|
console.warn("NYPL Reservoir TextInput: This component's required `id` prop was not passed.");
|
|
3681
3705
|
}
|
|
@@ -3693,8 +3717,8 @@ var TextInput = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(functio
|
|
|
3693
3717
|
id: id,
|
|
3694
3718
|
"aria-hidden": isHidden,
|
|
3695
3719
|
name: name,
|
|
3696
|
-
onChange:
|
|
3697
|
-
ref:
|
|
3720
|
+
onChange: internalOnChange,
|
|
3721
|
+
ref: finalRef
|
|
3698
3722
|
} : _extends({
|
|
3699
3723
|
"aria-required": isRequired,
|
|
3700
3724
|
defaultValue: defaultValue,
|
|
@@ -3706,11 +3730,11 @@ var TextInput = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(functio
|
|
|
3706
3730
|
maxLength: maxLength,
|
|
3707
3731
|
min: min,
|
|
3708
3732
|
name: name,
|
|
3709
|
-
onChange:
|
|
3733
|
+
onChange: internalOnChange,
|
|
3710
3734
|
onClick: onClick,
|
|
3711
3735
|
onFocus: onFocus,
|
|
3712
3736
|
placeholder: placeholder,
|
|
3713
|
-
ref:
|
|
3737
|
+
ref: finalRef,
|
|
3714
3738
|
// The `step` attribute is useful for the number type.
|
|
3715
3739
|
step: type === "number" ? step : null
|
|
3716
3740
|
}, ariaAttributes, rest);
|
|
@@ -3719,12 +3743,27 @@ var TextInput = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(functio
|
|
|
3719
3743
|
if (!isTextArea) {
|
|
3720
3744
|
options = _extends({
|
|
3721
3745
|
type: type,
|
|
3722
|
-
value:
|
|
3746
|
+
value: finalValue
|
|
3723
3747
|
}, options);
|
|
3724
3748
|
fieldOutput = React__default.createElement(react.Input, Object.assign({}, options, {
|
|
3725
3749
|
__css: styles.input
|
|
3726
3750
|
}));
|
|
3751
|
+
if (isClearable && !isHidden) {
|
|
3752
|
+
clearButtonOutput = React__default.createElement(Button, {
|
|
3753
|
+
buttonType: "text",
|
|
3754
|
+
id: id + "-clear-btn",
|
|
3755
|
+
onClick: onClearClick,
|
|
3756
|
+
sx: styles.clearButton
|
|
3757
|
+
}, React__default.createElement(Icon, {
|
|
3758
|
+
color: "ui.black",
|
|
3759
|
+
name: "close",
|
|
3760
|
+
size: "medium"
|
|
3761
|
+
}), React__default.createElement("span", null, "Clear ", labelText));
|
|
3762
|
+
}
|
|
3727
3763
|
} else {
|
|
3764
|
+
if (isClearable) {
|
|
3765
|
+
console.warn("NYPL Reservoir TextInput: The `isClearable` prop cannot be used with the `textarea` type.");
|
|
3766
|
+
}
|
|
3728
3767
|
fieldOutput = React__default.createElement(react.Textarea, Object.assign({}, options, {
|
|
3729
3768
|
__css: styles.textarea
|
|
3730
3769
|
}), value);
|
|
@@ -3742,7 +3781,7 @@ var TextInput = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(functio
|
|
|
3742
3781
|
id: id + "-label",
|
|
3743
3782
|
isRequired: showRequiredLabel && isRequired,
|
|
3744
3783
|
requiredLabelText: requiredLabelText
|
|
3745
|
-
}, labelText), fieldOutput);
|
|
3784
|
+
}, labelText), fieldOutput, !isHidden && finalValue.length > 0 && clearButtonOutput);
|
|
3746
3785
|
}));
|
|
3747
3786
|
|
|
3748
3787
|
var _excluded$1a = ["dsRef", "helperText", "id", "invalidText", "isDisabled", "isInvalid", "isRequired", "labelText", "name", "onChange", "onClick", "showLabel", "showHelperInvalidText", "showRequiredLabel", "value"],
|
|
@@ -6910,10 +6949,17 @@ var tertiary = {
|
|
|
6910
6949
|
color: "ui.white",
|
|
6911
6950
|
display: "flex",
|
|
6912
6951
|
flexFlow: "column nowrap",
|
|
6913
|
-
|
|
6952
|
+
px: "inset.default",
|
|
6953
|
+
py: {
|
|
6954
|
+
base: "inset.default",
|
|
6955
|
+
xl: "inset.wide"
|
|
6956
|
+
},
|
|
6914
6957
|
p: {
|
|
6915
6958
|
marginBottom: "0",
|
|
6916
|
-
marginTop:
|
|
6959
|
+
marginTop: {
|
|
6960
|
+
base: "xxs",
|
|
6961
|
+
xl: "xs"
|
|
6962
|
+
}
|
|
6917
6963
|
}
|
|
6918
6964
|
}),
|
|
6919
6965
|
heading: {
|
|
@@ -8619,12 +8665,28 @@ var input = {
|
|
|
8619
8665
|
};
|
|
8620
8666
|
var TextInput$1 = {
|
|
8621
8667
|
parts: ["input", "textarea"],
|
|
8622
|
-
baseStyle: {
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8668
|
+
baseStyle: function baseStyle(_ref) {
|
|
8669
|
+
var showLabel = _ref.showLabel;
|
|
8670
|
+
return {
|
|
8671
|
+
position: "relative",
|
|
8672
|
+
input: input,
|
|
8673
|
+
textarea: _extends({}, input, {
|
|
8674
|
+
lineheight: "1.5",
|
|
8675
|
+
minHeight: "xxl"
|
|
8676
|
+
}),
|
|
8677
|
+
clearButton: {
|
|
8678
|
+
position: "absolute",
|
|
8679
|
+
// When `showLabel` is false, the input field is at the top
|
|
8680
|
+
// which means the clear button should float higher.
|
|
8681
|
+
top: showLabel ? "32px" : "0",
|
|
8682
|
+
px: "xs",
|
|
8683
|
+
right: "0",
|
|
8684
|
+
// Don't visually show the text. This also helps
|
|
8685
|
+
// use the "text" `Button` type.
|
|
8686
|
+
span: screenreaderOnly(),
|
|
8687
|
+
zIndex: "9999"
|
|
8688
|
+
}
|
|
8689
|
+
};
|
|
8628
8690
|
},
|
|
8629
8691
|
variants: {
|
|
8630
8692
|
searchBar: {
|
|
@@ -13805,6 +13867,7 @@ var SearchBar$1 = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(funct
|
|
|
13805
13867
|
// Render the `TextInput` component.
|
|
13806
13868
|
var textInputNative = textInputProps && React__default.createElement(TextInput, Object.assign({
|
|
13807
13869
|
id: (textInputProps == null ? void 0 : textInputProps.id) || "searchbar-textinput-" + id,
|
|
13870
|
+
isClearable: textInputProps == null ? void 0 : textInputProps.isClearable,
|
|
13808
13871
|
labelText: textInputProps == null ? void 0 : textInputProps.labelText,
|
|
13809
13872
|
name: textInputProps == null ? void 0 : textInputProps.name,
|
|
13810
13873
|
onChange: textInputProps == null ? void 0 : textInputProps.onChange,
|
|
@@ -14536,12 +14599,16 @@ var Tooltip$1 = /*#__PURE__*/react.chakra( /*#__PURE__*/React.forwardRef(functio
|
|
|
14536
14599
|
}, children) : children;
|
|
14537
14600
|
var styles = react.useMultiStyleConfig("Tooltip", {});
|
|
14538
14601
|
return React__default.createElement(react.Tooltip, Object.assign({
|
|
14539
|
-
hasArrow: true,
|
|
14540
14602
|
"aria-label": typeof content !== "string" ? "Tooltip" : undefined,
|
|
14541
|
-
|
|
14603
|
+
closeDelay: 750,
|
|
14604
|
+
closeOnClick: true,
|
|
14605
|
+
closeOnEsc: true,
|
|
14606
|
+
closeOnMouseDown: true,
|
|
14607
|
+
hasArrow: true,
|
|
14542
14608
|
isDisabled: isDisabled,
|
|
14543
|
-
|
|
14609
|
+
label: content,
|
|
14544
14610
|
openDelay: 500,
|
|
14611
|
+
placement: "top",
|
|
14545
14612
|
ref: ref,
|
|
14546
14613
|
__css: styles
|
|
14547
14614
|
}, rest), newChildren);
|