@luomus/laji-form 15.1.26 → 15.1.27

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.
@@ -27,9 +27,9 @@ export default class CheckboxWidget extends React.Component<any, any, any> {
27
27
  getOptions: (props: any) => any;
28
28
  getToggleMode: (props: any) => boolean;
29
29
  onGroupKeyDown: any;
30
- onTrueKeyDown: any;
31
- onFalseKeyDown: any;
32
- onUndefinedKeyDown: any;
30
+ onTrueKeyDown: (e: any) => void;
31
+ onFalseKeyDown: (e: any) => void;
32
+ onUndefinedKeyDown: (e: any) => void;
33
33
  toggle: (e: any) => void;
34
34
  formatValue(value: any, options: any, props: any): any;
35
35
  }
@@ -46,21 +46,36 @@ class CheckboxWidget extends React.Component {
46
46
  this.onGroupKeyDown = this.props.formContext.utils.keyboardClick((e) => {
47
47
  this.getToggleMode(this.props) && this.toggle(e);
48
48
  }, [" "]);
49
- this.onTrueKeyDown = this.props.formContext.utils.keyboardClick(() => {
50
- if (this.props.disabled || this.props.readonly) {
51
- return;
49
+ // onTrueKeyDown = this.props.formContext.utils.keyboardClick(() => {
50
+ // if (this.props.disabled || this.props.readonly) {
51
+ // return;
52
+ // }
53
+ // this.onChange(true);
54
+ // }, [" "]);
55
+ this.onTrueKeyDown = (e) => {
56
+ const { key } = e;
57
+ if (key === " ") {
58
+ this.onChange(true);
59
+ e.preventDefault();
60
+ e.stopPropagation();
52
61
  }
53
- this.onChange(true);
54
- }, [" "]);
55
- this.onFalseKeyDown = this.props.formContext.utils.keyboardClick(() => {
56
- if (this.props.disabled || this.props.readonly) {
57
- return;
62
+ };
63
+ this.onFalseKeyDown = (e) => {
64
+ const { key } = e;
65
+ if (key === " ") {
66
+ this.onChange(false);
67
+ e.preventDefault();
68
+ e.stopPropagation();
58
69
  }
59
- this.onChange(false);
60
- }, [" "]);
61
- this.onUndefinedKeyDown = this.props.formContext.utils.keyboardClick(() => {
62
- this.onChange(undefined);
63
- });
70
+ };
71
+ this.onUndefinedKeyDown = (e) => {
72
+ const { key } = e;
73
+ if (key === " ") {
74
+ this.onChange(undefined);
75
+ e.preventDefault();
76
+ e.stopPropagation();
77
+ }
78
+ };
64
79
  this.toggle = (e) => {
65
80
  if (this.props.disabled || this.props.readonly) {
66
81
  return;
@@ -108,7 +123,7 @@ class CheckboxWidget extends React.Component {
108
123
  React.createElement(ToggleButton, Object.assign({ id: `${id}-true`, ref: this.trueRef, value: true, onClick: toggleMode ? this.toggle : undefined, className: utils_1.classNames(toggleMode && _value === false && "laji-form-hide-btn-label", _value === true && tabTargetClass), onKeyDown: this.onTrueKeyDown }, commonProps), trueLabel),
109
124
  React.createElement(ToggleButton, Object.assign({ id: `${id}-false`, ref: this.falseRef, value: false, onClick: toggleMode ? this.toggle : undefined, className: utils_1.classNames(toggleMode && _value === true && "laji-form-hide-btn-label", _value === false && tabTargetClass), onKeyDown: this.onFalseKeyDown }, commonProps), falseLabel),
110
125
  (displayUndefined ?
111
- React.createElement(ToggleButton, Object.assign({ id: `${id}-undefined`, ref: this.undefinedRef, value: "undefined", className: utils_1.classNames(_value === undefined && tabTargetClass) }, commonProps, { onKeyDown: this.onUndefinedKeyDown }), unknownLabel) : null))));
126
+ React.createElement(ToggleButton, Object.assign({ id: `${id}-undefined`, ref: this.undefinedRef, value: "undefined", className: utils_1.classNames(value === undefined && tabTargetClass) }, commonProps, { onKeyDown: this.onUndefinedKeyDown }), unknownLabel) : null))));
112
127
  const { Label } = this.props.formContext;
113
128
  return !hasLabel ? checkbox : (React.createElement(Label, { label: label, required: required, uiSchema: options, contextId: this.props.formContext.contextId }, checkbox));
114
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luomus/laji-form",
3
- "version": "15.1.26",
3
+ "version": "15.1.27",
4
4
  "description": "React module capable of building dynamic forms from Laji form json schemas",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",