react-form-builder-more-flexibility 1.0.71 → 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: {
@@ -583,23 +583,56 @@ var FormElementsEdit = exports["default"] = /*#__PURE__*/function (_React$Compon
583
583
  }
584
584
  }), el.element === 'Image' && typeof this.props.onImageUpload === 'function' && /*#__PURE__*/_react["default"].createElement("div", {
585
585
  style: {
586
- marginTop: 8
586
+ marginTop: 12,
587
+ display: 'flex',
588
+ alignItems: 'center',
589
+ gap: 12,
590
+ flexWrap: 'wrap'
591
+ }
592
+ }, el.src && /*#__PURE__*/_react["default"].createElement("img", {
593
+ src: el.src,
594
+ alt: "",
595
+ style: {
596
+ width: 56,
597
+ height: 56,
598
+ objectFit: 'cover',
599
+ borderRadius: 4,
600
+ border: '1px solid #dee2e6',
601
+ background: '#f8f9fa'
587
602
  }
588
- }, /*#__PURE__*/_react["default"].createElement("input", {
603
+ }), /*#__PURE__*/_react["default"].createElement("input", {
589
604
  ref: this.imageFileInputRef,
590
605
  id: "srcImageUpload",
591
606
  type: "file",
592
607
  accept: "image/png,image/jpeg,image/jpg,image/gif,image/webp",
593
- className: "form-control",
594
- disabled: this.state.uploadingImage,
608
+ style: {
609
+ display: 'none'
610
+ },
595
611
  onChange: this.handleImageFileChange
596
- }), this.state.uploadingImage && /*#__PURE__*/_react["default"].createElement("small", {
597
- className: "text-muted"
598
- }, "Uploading\u2026"), this.state.imageUploadError && /*#__PURE__*/_react["default"].createElement("small", {
612
+ }), /*#__PURE__*/_react["default"].createElement("button", {
613
+ type: "button",
614
+ className: "btn btn-outline-secondary btn-sm",
615
+ disabled: this.state.uploadingImage,
616
+ onClick: function onClick() {
617
+ return _this2.imageFileInputRef.current && _this2.imageFileInputRef.current.click();
618
+ }
619
+ }, this.state.uploadingImage ? 'Uploading…' : el.src ? 'Replace image' : 'Upload image'), el.src && !this.state.uploadingImage && /*#__PURE__*/_react["default"].createElement("button", {
620
+ type: "button",
621
+ className: "btn btn-link btn-sm p-0",
622
+ onClick: function onClick() {
623
+ return _this2.setDraftProp('src', '');
624
+ }
625
+ }, "Remove"), this.state.imageUploadError && /*#__PURE__*/_react["default"].createElement("small", {
599
626
  style: {
600
- color: '#d9534f'
627
+ color: '#d9534f',
628
+ flexBasis: '100%'
629
+ }
630
+ }, this.state.imageUploadError), /*#__PURE__*/_react["default"].createElement("small", {
631
+ className: "text-muted",
632
+ style: {
633
+ flexBasis: '100%'
601
634
  }
602
- }, this.state.imageUploadError))), canHaveImageSize && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
635
+ }, "PNG, JPG, GIF, or WebP. Max 2MB."))), canHaveImageSize && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
603
636
  className: "form-group"
604
637
  }, /*#__PURE__*/_react["default"].createElement("div", {
605
638
  className: "custom-control custom-checkbox"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-form-builder-more-flexibility",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "A complete form builder for react.",
5
5
  "main": "lib/index.js",
6
6
  "types": "types/index.d.ts",