@deque/cauldron-react 6.18.5 → 6.19.0-canary.4d3cd93f
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.
|
@@ -14,6 +14,7 @@ export interface SelectProps extends Omit<React.HTMLProps<HTMLSelectElement>, 'c
|
|
|
14
14
|
children?: React.ReactElement<HTMLOptionElement | HTMLOptGroupElement>[];
|
|
15
15
|
value?: any;
|
|
16
16
|
defaultValue?: any;
|
|
17
|
+
description?: React.ReactNode;
|
|
17
18
|
onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
18
19
|
}
|
|
19
20
|
declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ChangeEvent } from 'react';
|
|
2
2
|
export interface TextFieldProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
|
|
3
3
|
label: React.ReactNode;
|
|
4
|
+
description?: React.ReactNode;
|
|
4
5
|
error?: React.ReactNode;
|
|
5
6
|
defaultValue?: string;
|
|
6
7
|
onChange?: (value: string, e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
@@ -24,6 +25,7 @@ export default class TextField extends React.Component<TextFieldProps, TextField
|
|
|
24
25
|
};
|
|
25
26
|
private inputId;
|
|
26
27
|
private errorId;
|
|
28
|
+
private descriptionId;
|
|
27
29
|
private input;
|
|
28
30
|
constructor(props: TextFieldProps);
|
|
29
31
|
render(): React.JSX.Element;
|
package/lib/index.js
CHANGED
|
@@ -2258,7 +2258,7 @@ var randomId = function () {
|
|
|
2258
2258
|
};
|
|
2259
2259
|
|
|
2260
2260
|
var Select = React__default["default"].forwardRef(function (_a, ref) {
|
|
2261
|
-
var options = _a.options, children = _a.children, disabled = _a.disabled, label = _a.label, id = _a.id, required = _a.required, _b = _a.requiredText, requiredText = _b === void 0 ? 'Required' : _b, error = _a.error, value = _a.value, ariaDescribedby = _a["aria-describedby"], defaultValue = _a.defaultValue, onChange = _a.onChange, rest = tslib.__rest(_a, ["options", "children", "disabled", "label", "id", "required", "requiredText", "error", "value", 'aria-describedby', "defaultValue", "onChange"]);
|
|
2261
|
+
var options = _a.options, children = _a.children, disabled = _a.disabled, label = _a.label, id = _a.id, required = _a.required, _b = _a.requiredText, requiredText = _b === void 0 ? 'Required' : _b, error = _a.error, value = _a.value, ariaDescribedby = _a["aria-describedby"], defaultValue = _a.defaultValue, description = _a.description, onChange = _a.onChange, rest = tslib.__rest(_a, ["options", "children", "disabled", "label", "id", "required", "requiredText", "error", "value", 'aria-describedby', "defaultValue", "description", "onChange"]);
|
|
2262
2262
|
if (options && children) {
|
|
2263
2263
|
console.error('The Select component only takes the options props or child option elements, not both.');
|
|
2264
2264
|
}
|
|
@@ -2282,6 +2282,7 @@ var Select = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
2282
2282
|
}, [value]);
|
|
2283
2283
|
var selectId = id || randomId();
|
|
2284
2284
|
var errorId = randomId();
|
|
2285
|
+
var descriptionId = randomId();
|
|
2285
2286
|
var dynamicProps = {};
|
|
2286
2287
|
if (isControlled) {
|
|
2287
2288
|
dynamicProps.value = currentValue;
|
|
@@ -2289,8 +2290,12 @@ var Select = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
2289
2290
|
else if (typeof defaultValue !== 'undefined') {
|
|
2290
2291
|
dynamicProps.defaultValue = defaultValue;
|
|
2291
2292
|
}
|
|
2293
|
+
dynamicProps['aria-describedby'] = ariaDescribedby;
|
|
2294
|
+
if (description) {
|
|
2295
|
+
dynamicProps['aria-describedby'] = addIdRef(dynamicProps['aria-describedby'], descriptionId);
|
|
2296
|
+
}
|
|
2292
2297
|
if (error) {
|
|
2293
|
-
dynamicProps['aria-describedby'] = addIdRef(
|
|
2298
|
+
dynamicProps['aria-describedby'] = addIdRef(dynamicProps['aria-describedby'], errorId);
|
|
2294
2299
|
}
|
|
2295
2300
|
// In order to support controlled selects, we
|
|
2296
2301
|
// have to attach an `onChange` to the select.
|
|
@@ -2302,6 +2307,10 @@ var Select = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
2302
2307
|
}) },
|
|
2303
2308
|
React__default["default"].createElement("span", null, label),
|
|
2304
2309
|
required && (React__default["default"].createElement("span", { className: "Field__required-text", "aria-hidden": "true" }, requiredText))),
|
|
2310
|
+
description && (React__default["default"].createElement("div", { id: descriptionId, className: "Field__description" }, description)),
|
|
2311
|
+
error && (React__default["default"].createElement("div", { id: errorId, className: "Field__error" },
|
|
2312
|
+
React__default["default"].createElement(Icon, { type: "caution" }),
|
|
2313
|
+
error)),
|
|
2305
2314
|
React__default["default"].createElement("div", { className: classNames__default["default"]('Field__select--wrapper', {
|
|
2306
2315
|
'Field__select--disabled': disabled,
|
|
2307
2316
|
'Field--has-error': !!error
|
|
@@ -2311,8 +2320,7 @@ var Select = React__default["default"].forwardRef(function (_a, ref) {
|
|
|
2311
2320
|
return (React__default["default"].createElement("option", { className: "Field__option", key: option.key, value: option.value, disabled: option.disabled }, option.label || option.value));
|
|
2312
2321
|
})
|
|
2313
2322
|
: children),
|
|
2314
|
-
React__default["default"].createElement("div", { className: "arrow-down" }))
|
|
2315
|
-
error && (React__default["default"].createElement("div", { id: errorId, className: "Error" }, error))));
|
|
2323
|
+
React__default["default"].createElement("div", { className: "arrow-down" }))));
|
|
2316
2324
|
/* eslint-disable jsx-a11y/no-onchange */
|
|
2317
2325
|
});
|
|
2318
2326
|
Select.displayName = 'Select';
|
|
@@ -2593,6 +2601,7 @@ var TextField = /** @class */ (function (_super) {
|
|
|
2593
2601
|
var _this = _super.call(this, props) || this;
|
|
2594
2602
|
_this.inputId = _this.props.id || randomId();
|
|
2595
2603
|
_this.errorId = randomId();
|
|
2604
|
+
_this.descriptionId = randomId();
|
|
2596
2605
|
_this.state = {
|
|
2597
2606
|
value: typeof _this.props.value !== 'undefined'
|
|
2598
2607
|
? _this.props.value
|
|
@@ -2606,19 +2615,22 @@ var TextField = /** @class */ (function (_super) {
|
|
|
2606
2615
|
var isRequired = !!this.props.required;
|
|
2607
2616
|
// disabling `no-unused-vars` to prevent specific
|
|
2608
2617
|
// props from being passed through to the input
|
|
2609
|
-
var _a = this.props, label = _a.label, fieldRef = _a.fieldRef, value = _a.value;
|
|
2618
|
+
var _a = this.props, label = _a.label, fieldRef = _a.fieldRef, value = _a.value, description = _a.description;
|
|
2610
2619
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2611
2620
|
_a.onChange;
|
|
2612
2621
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2613
|
-
_a.defaultValue; var _b = _a.error, error = _b === void 0 ? null : _b, requiredText = _a.requiredText, multiline = _a.multiline, ariaDescribedby = _a["aria-describedby"]; _a.children; var className = _a.className, other = tslib.__rest(_a, ["label", "fieldRef", "value", "onChange", "defaultValue", "error", "requiredText", "multiline", 'aria-describedby', "children", "className"]);
|
|
2622
|
+
_a.defaultValue; var _b = _a.error, error = _b === void 0 ? null : _b, requiredText = _a.requiredText, multiline = _a.multiline, ariaDescribedby = _a["aria-describedby"]; _a.children; var className = _a.className, other = tslib.__rest(_a, ["label", "fieldRef", "value", "description", "onChange", "defaultValue", "error", "requiredText", "multiline", 'aria-describedby', "children", "className"]);
|
|
2614
2623
|
// typescript can't infer the type so it's complaining about
|
|
2615
2624
|
// textarea and input props being incompatible
|
|
2616
2625
|
// we should probably fix this
|
|
2617
2626
|
var Field = multiline ? 'textarea' : 'input';
|
|
2627
|
+
var describedby = description
|
|
2628
|
+
? addIdRef(ariaDescribedby, this.descriptionId)
|
|
2629
|
+
: ariaDescribedby;
|
|
2618
2630
|
var inputProps = {
|
|
2619
2631
|
'aria-describedby': error
|
|
2620
|
-
? addIdRef(
|
|
2621
|
-
:
|
|
2632
|
+
? addIdRef(describedby, this.errorId)
|
|
2633
|
+
: describedby
|
|
2622
2634
|
};
|
|
2623
2635
|
return (React__default["default"].createElement("div", { className: "Field" },
|
|
2624
2636
|
React__default["default"].createElement("label", { className: classNames__default["default"]('Field__label', {
|
|
@@ -2627,6 +2639,10 @@ var TextField = /** @class */ (function (_super) {
|
|
|
2627
2639
|
}), htmlFor: this.inputId },
|
|
2628
2640
|
React__default["default"].createElement("span", null, label),
|
|
2629
2641
|
isRequired && (React__default["default"].createElement("span", { className: "Field__required-text", "aria-hidden": "true" }, requiredText))),
|
|
2642
|
+
description && (React__default["default"].createElement("div", { className: "Field__description", id: this.descriptionId }, description)),
|
|
2643
|
+
error && (React__default["default"].createElement("div", { className: "Field__error", id: this.errorId },
|
|
2644
|
+
React__default["default"].createElement(Icon, { type: "caution" }),
|
|
2645
|
+
error)),
|
|
2630
2646
|
React__default["default"].createElement(Field, tslib.__assign({ className: classNames__default["default"](className, {
|
|
2631
2647
|
'Field__text-input': !multiline,
|
|
2632
2648
|
Field__textarea: multiline,
|
|
@@ -2634,8 +2650,7 @@ var TextField = /** @class */ (function (_super) {
|
|
|
2634
2650
|
}), id: this.inputId, value: typeof value !== 'undefined' ? value : this.state.value, onChange: this.onChange, "aria-invalid": !!error, ref: function (input) {
|
|
2635
2651
|
_this.input = input;
|
|
2636
2652
|
setRef(fieldRef, input);
|
|
2637
|
-
} }, other, inputProps))
|
|
2638
|
-
error && (React__default["default"].createElement("div", { className: "Error", id: this.errorId }, error))));
|
|
2653
|
+
} }, other, inputProps))));
|
|
2639
2654
|
};
|
|
2640
2655
|
TextField.prototype.onChange = function (e) {
|
|
2641
2656
|
var _a, _b;
|
package/package.json
CHANGED