react-form-builder-more-flexibility 1.0.72 → 1.0.73
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.
|
@@ -15,6 +15,10 @@ var ComponentLabel = function ComponentLabel(props) {
|
|
|
15
15
|
}
|
|
16
16
|
var hasPopUp = !!props.data.hasPopUp;
|
|
17
17
|
return /*#__PURE__*/_react["default"].createElement("label", {
|
|
18
|
+
// id so the paired input can name itself via aria-labelledby (H91/F68):
|
|
19
|
+
// the label's onClick opens the rules popup for hasPopUp items, so
|
|
20
|
+
// htmlFor would wrongly focus the field — name by reference instead.
|
|
21
|
+
id: props.data.field_name ? "".concat(props.data.field_name, "__label") : undefined,
|
|
18
22
|
onClick: hasPopUp ? props.passUpClick : undefined // Pass the function reference instead of invoking it
|
|
19
23
|
,
|
|
20
24
|
className: props.className || 'form-label',
|
|
@@ -29,6 +29,28 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
29
29
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
30
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
31
31
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /* eslint-disable quote-props */ // eslint-disable-next-line max-classes-per-file
|
|
32
|
+
// Accessible NAME for every input (WCAG H91 / F68). Operators often leave the
|
|
33
|
+
// label blank and rely on the placeholder, which axe tolerates but Pa11y
|
|
34
|
+
// rightly rejects (a placeholder vanishes on first keystroke). Name by the
|
|
35
|
+
// visible label when there is one (aria-labelledby → ComponentLabel's id),
|
|
36
|
+
// else fall back to a stable aria-label from the placeholder or a humanized
|
|
37
|
+
// custom_name. Mirrors the fan side's LightFormRenderer.nameProps.
|
|
38
|
+
var humanizeName = function humanizeName(s) {
|
|
39
|
+
return (s || '').replace(/_\d+$/, '').replace(/[_-]+/g, ' ').trim().replace(/\b\w/g, function (c) {
|
|
40
|
+
return c.toUpperCase();
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
var accessibleNameProps = function accessibleNameProps() {
|
|
44
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
45
|
+
var hasVisibleLabel = !!(data.label && String(data.label).trim());
|
|
46
|
+
if (hasVisibleLabel) return {
|
|
47
|
+
'aria-labelledby': "".concat(data.field_name, "__label")
|
|
48
|
+
};
|
|
49
|
+
var fallback = data.placeholder && String(data.placeholder).trim() || humanizeName(data.custom_name) || humanizeName(data.field_name);
|
|
50
|
+
return fallback ? {
|
|
51
|
+
'aria-label': fallback
|
|
52
|
+
} : {};
|
|
53
|
+
};
|
|
32
54
|
var FormElements = {};
|
|
33
55
|
var Header = /*#__PURE__*/function (_React$Component) {
|
|
34
56
|
function Header() {
|
|
@@ -164,6 +186,7 @@ var TextInput = /*#__PURE__*/function (_React$Component5) {
|
|
|
164
186
|
props.className = 'form-control';
|
|
165
187
|
props.name = this.props.data.field_name;
|
|
166
188
|
props.placeholder = this.props.data.placeholder;
|
|
189
|
+
Object.assign(props, accessibleNameProps(this.props.data));
|
|
167
190
|
if (this.props.mutable) {
|
|
168
191
|
props.defaultValue = this.props.defaultValue;
|
|
169
192
|
props.ref = this.inputField;
|
|
@@ -201,6 +224,7 @@ var EmailInput = /*#__PURE__*/function (_React$Component6) {
|
|
|
201
224
|
props.className = 'form-control';
|
|
202
225
|
props.name = this.props.data.field_name;
|
|
203
226
|
props.placeholder = this.props.data.placeholder;
|
|
227
|
+
Object.assign(props, accessibleNameProps(this.props.data));
|
|
204
228
|
if (this.props.mutable) {
|
|
205
229
|
props.defaultValue = this.props.defaultValue;
|
|
206
230
|
props.ref = this.inputField;
|
|
@@ -238,6 +262,7 @@ var PhoneNumber = /*#__PURE__*/function (_React$Component7) {
|
|
|
238
262
|
props.className = 'form-control';
|
|
239
263
|
props.name = this.props.data.field_name;
|
|
240
264
|
props.placeholder = this.props.data.placeholder;
|
|
265
|
+
Object.assign(props, accessibleNameProps(this.props.data));
|
|
241
266
|
if (this.props.mutable) {
|
|
242
267
|
props.defaultValue = this.props.defaultValue;
|
|
243
268
|
props.ref = this.inputField;
|
|
@@ -275,6 +300,7 @@ var NumberInput = /*#__PURE__*/function (_React$Component8) {
|
|
|
275
300
|
props.className = 'form-control';
|
|
276
301
|
props.name = this.props.data.field_name;
|
|
277
302
|
props.placeholder = this.props.data.placeholder;
|
|
303
|
+
Object.assign(props, accessibleNameProps(this.props.data));
|
|
278
304
|
if (this.props.mutable) {
|
|
279
305
|
props.defaultValue = this.props.defaultValue;
|
|
280
306
|
props.ref = this.inputField;
|
|
@@ -311,6 +337,7 @@ var TextArea = /*#__PURE__*/function (_React$Component9) {
|
|
|
311
337
|
props.className = 'form-control';
|
|
312
338
|
props.name = this.props.data.field_name;
|
|
313
339
|
props.placeholder = this.props.data.placeholder;
|
|
340
|
+
Object.assign(props, accessibleNameProps(this.props.data));
|
|
314
341
|
if (this.props.read_only) {
|
|
315
342
|
props.disabled = 'disabled';
|
|
316
343
|
}
|
|
@@ -626,7 +653,13 @@ var Checkbox = /*#__PURE__*/function (_React$Component12) {
|
|
|
626
653
|
}, /*#__PURE__*/_react["default"].createElement("input", (0, _extends2["default"])({
|
|
627
654
|
className: "form-check-input",
|
|
628
655
|
id: this.props.data.field_name
|
|
656
|
+
// Named by the box label via aria-labelledby, not htmlFor — the
|
|
657
|
+
// box label's onClick opens the rules popup and must not toggle
|
|
658
|
+
// the box (H91.InputCheckbox.Name).
|
|
659
|
+
,
|
|
660
|
+
"aria-labelledby": "".concat(this.props.data.field_name, "__boxlabel")
|
|
629
661
|
}, props)), /*#__PURE__*/_react["default"].createElement("label", {
|
|
662
|
+
id: "".concat(this.props.data.field_name, "__boxlabel"),
|
|
630
663
|
className: "form-check-label",
|
|
631
664
|
onClick: this.handleLabelClick,
|
|
632
665
|
dangerouslySetInnerHTML: {
|