guestbell-forms 2.0.287 → 2.0.288

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.
@@ -5,6 +5,7 @@ export interface CheckboxProps extends BaseInputProps<HTMLInputElement> {
5
5
  onChange?: never;
6
6
  type?: string;
7
7
  checked?: boolean;
8
+ supportsIndeterminate?: boolean;
8
9
  }
9
10
  export interface CheckboxState extends BaseInputState {
10
11
  checked: boolean;
@@ -12,11 +13,11 @@ export interface CheckboxState extends BaseInputState {
12
13
  export declare class CheckboxRaw extends BaseInput<CheckboxProps, CheckboxState, HTMLInputElement> {
13
14
  static defaultProps: CheckboxProps;
14
15
  constructor(props: CheckboxProps);
16
+ componentDidMount(): void;
15
17
  componentDidUpdate(oldProps: CheckboxProps): void;
16
18
  render(): JSX.Element;
17
19
  private handleChecked;
18
20
  protected handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>): void;
19
- private renderInput;
20
21
  }
21
22
  export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxProps & React.RefAttributes<CheckboxRaw>>;
22
23
  export default Checkbox;
@@ -31,6 +31,10 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
31
31
 
32
32
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
33
33
 
34
+ function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
35
+
36
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
37
+
34
38
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
35
39
 
36
40
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
@@ -74,8 +78,23 @@ var CheckboxRaw = /*#__PURE__*/function (_BaseInput) {
74
78
  }
75
79
 
76
80
  _createClass(CheckboxRaw, [{
81
+ key: "componentDidMount",
82
+ value: function componentDidMount() {
83
+ var _this$inputRef$curren, _get2;
84
+
85
+ var finalIndeterminate = Boolean(this.props.supportsIndeterminate && typeof this.props.checked !== 'boolean');
86
+
87
+ if (typeof this.props.checked !== 'boolean' && this.inputRef.current && ((_this$inputRef$curren = this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.indeterminate) !== finalIndeterminate) {
88
+ this.inputRef.current.indeterminate = finalIndeterminate;
89
+ }
90
+
91
+ (_get2 = _get(_getPrototypeOf(CheckboxRaw.prototype), "componentDidMount", this)) === null || _get2 === void 0 ? void 0 : _get2.call(this);
92
+ }
93
+ }, {
77
94
  key: "componentDidUpdate",
78
95
  value: function componentDidUpdate(oldProps) {
96
+ var _this$inputRef$curren2;
97
+
79
98
  if (this.props.checked !== this.state.checked) {
80
99
  this.setState({
81
100
  checked: this.props.checked
@@ -97,20 +116,42 @@ var CheckboxRaw = /*#__PURE__*/function (_BaseInput) {
97
116
  this.setValid();
98
117
  }
99
118
  }
119
+
120
+ var finalIndeterminate = Boolean(this.props.supportsIndeterminate && typeof this.props.checked !== 'boolean');
121
+
122
+ if (this.props.supportsIndeterminate && ((_this$inputRef$curren2 = this.inputRef.current) === null || _this$inputRef$curren2 === void 0 ? void 0 : _this$inputRef$curren2.indeterminate) !== finalIndeterminate) {
123
+ this.inputRef.current.indeterminate = finalIndeterminate;
124
+ }
100
125
  }
101
126
  }, {
102
127
  key: "render",
103
128
  value: function render() {
129
+ var _this$state$checked;
130
+
104
131
  var containerClassName = classNames(['input__base checkbox-input', this.getValidationClass(), this.props.className, _defineProperty({}, 'checkbox-input--with-label', Boolean(this.props.label)), _defineProperty({}, 'checkbox-input--disabled', this.props.disabled)]);
132
+ var input = /*#__PURE__*/React.createElement("input", _extends({}, this.props.id && {
133
+ id: this.props.id
134
+ }, {
135
+ ref: this.inputRef,
136
+ value: this.props.value || '',
137
+ type: "checkbox",
138
+ required: this.props.required,
139
+ checked: (_this$state$checked = this.state.checked) !== null && _this$state$checked !== void 0 ? _this$state$checked : false,
140
+ onChange: this.handleChecked,
141
+ onBlur: this.handleBlur,
142
+ onFocus: this.handleFocus,
143
+ onKeyDown: this.handleKeyDown,
144
+ tabIndex: this.props.disabled ? -1 : 0
145
+ }));
105
146
  return /*#__PURE__*/React.createElement(_InputGroup.default, {
106
147
  title: this.props.title,
107
148
  tooltip: this.props.tooltip
108
149
  }, /*#__PURE__*/React.createElement("div", {
109
150
  className: containerClassName,
110
151
  ref: this.containerRef
111
- }, this.props.title && !this.props.label && this.renderInput(), !this.props.title && !this.props.label && this.renderTooltip(this.renderInput()), this.renderDefaultValidation(), this.props.label && /*#__PURE__*/React.createElement("label", {
152
+ }, this.props.title && !this.props.label && input, !this.props.title && !this.props.label && this.renderTooltip(input), this.renderDefaultValidation(), this.props.label && /*#__PURE__*/React.createElement("label", {
112
153
  className: "checkbox-input__label"
113
- }, this.renderInput(), this.renderLabel())));
154
+ }, input, this.renderLabel())));
114
155
  }
115
156
  }, {
116
157
  key: "handleChecked",
@@ -135,30 +176,12 @@ var CheckboxRaw = /*#__PURE__*/function (_BaseInput) {
135
176
  value: function handleKeyDown(e) {
136
177
  if (!this.props.disabled) {
137
178
  if (e.key === 'Enter') {
138
- var _this$inputRef$curren;
179
+ var _this$inputRef$curren3;
139
180
 
140
- (_this$inputRef$curren = this.inputRef.current) === null || _this$inputRef$curren === void 0 ? void 0 : _this$inputRef$curren.click();
181
+ (_this$inputRef$curren3 = this.inputRef.current) === null || _this$inputRef$curren3 === void 0 ? void 0 : _this$inputRef$curren3.click();
141
182
  }
142
183
  }
143
184
  }
144
- }, {
145
- key: "renderInput",
146
- value: function renderInput() {
147
- return /*#__PURE__*/React.createElement("input", _extends({}, this.props.id && {
148
- id: this.props.id
149
- }, {
150
- ref: this.inputRef,
151
- value: this.props.value || '',
152
- type: "checkbox",
153
- required: this.props.required,
154
- checked: this.state.checked,
155
- onChange: this.handleChecked,
156
- onBlur: this.handleBlur,
157
- onFocus: this.handleFocus,
158
- onKeyDown: this.handleKeyDown,
159
- tabIndex: this.props.disabled ? -1 : 0
160
- }));
161
- }
162
185
  }]);
163
186
 
164
187
  return CheckboxRaw;
@@ -166,8 +189,7 @@ var CheckboxRaw = /*#__PURE__*/function (_BaseInput) {
166
189
 
167
190
  exports.CheckboxRaw = CheckboxRaw;
168
191
 
169
- _defineProperty(CheckboxRaw, "defaultProps", Object.assign({}, _BaseInput2.BaseInput.defaultProps, {
170
- checked: false
192
+ _defineProperty(CheckboxRaw, "defaultProps", Object.assign({}, _BaseInput2.BaseInput.defaultProps, {// checked: false,
171
193
  }));
172
194
 
173
195
  var Checkbox = (0, _withThemeContext.withThemeContext)((0, _withFormContext.withFormContext)(CheckboxRaw), 'checkbox');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/components/checkbox/Checkbox.tsx"],"names":["classNames","require","CheckboxRaw","props","state","Object","assign","checked","isValid","required","errors","getTranslations","defaultBaseTranslations","handleChecked","bind","handleKeyDown","subscribeSelf","oldProps","setState","setValid","setInvalid","containerClassName","getValidationClass","className","Boolean","label","disabled","title","tooltip","containerRef","renderInput","renderTooltip","renderDefaultValidation","renderLabel","e","onChecked","key","inputRef","current","click","id","value","handleBlur","handleFocus","BaseInput","defaultProps","Checkbox"],"mappings":";;;;;;;;;AACA;;AAGA;;AACA;;AAOA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAFA,IAAIA,UAAU,GAAGC,OAAO,C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BsC,sBAAUC,YAA5B,EAA0C;AACrEtC,EAAAA,OAAO,EAAE;AAD4D,CAA1C,C;;AAiHxB,IAAMuC,QAAQ,GAAG,wCAGtB,sCAA+B5C,WAA/B,CAHsB,EAGuB,UAHvB,CAAjB;;eAKQ4C,Q","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport {\r\n BaseInputProps,\r\n BaseInput,\r\n BaseInputState,\r\n defaultBaseTranslations,\r\n} from '../base/input/BaseInput';\r\nvar classNames = require('classnames');\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\n\r\nexport interface CheckboxProps extends BaseInputProps<HTMLInputElement> {\r\n onChecked?: (e: React.ChangeEvent<HTMLInputElement>) => void;\r\n onChange?: never;\r\n type?: string;\r\n checked?: boolean;\r\n}\r\n\r\nexport interface CheckboxState extends BaseInputState {\r\n checked: boolean;\r\n}\r\n\r\nexport class CheckboxRaw extends BaseInput<\r\n CheckboxProps,\r\n CheckboxState,\r\n HTMLInputElement\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n checked: false,\r\n }) as CheckboxProps;\r\n\r\n constructor(props: CheckboxProps) {\r\n super(props, false);\r\n this.state = Object.assign(this.state, {\r\n checked: props.checked,\r\n isValid: props.required ? props.checked : true,\r\n errors:\r\n props.required && !props.checked\r\n ? [this.getTranslations(defaultBaseTranslations).required]\r\n : [],\r\n });\r\n this.handleChecked = this.handleChecked.bind(this);\r\n this.handleKeyDown = this.handleKeyDown.bind(this);\r\n this.subscribeSelf(props);\r\n }\r\n\r\n public componentDidUpdate(oldProps: CheckboxProps) {\r\n if (this.props.checked !== this.state.checked) {\r\n this.setState({ checked: this.props.checked });\r\n if (this.props.checked) {\r\n this.setValid();\r\n } else {\r\n if (this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n }\r\n }\r\n }\r\n if (oldProps.required !== this.props.required) {\r\n if (this.props.required && !this.props.checked) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n } else {\r\n this.setValid();\r\n }\r\n }\r\n }\r\n\r\n public render() {\r\n const containerClassName = classNames([\r\n 'input__base checkbox-input',\r\n this.getValidationClass(),\r\n this.props.className,\r\n { ['checkbox-input--with-label']: Boolean(this.props.label) },\r\n { ['checkbox-input--disabled']: this.props.disabled },\r\n ]);\r\n return (\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div className={containerClassName} ref={this.containerRef}>\r\n {this.props.title && !this.props.label && this.renderInput()}\r\n {!this.props.title &&\r\n !this.props.label &&\r\n this.renderTooltip(this.renderInput())}\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label className=\"checkbox-input__label\">\r\n {this.renderInput()}\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n private handleChecked(e: React.ChangeEvent<HTMLInputElement>) {\r\n if (!this.props.disabled) {\r\n this.props.onChecked && this.props.onChecked(e);\r\n this.setState({ checked: !this.state.checked });\r\n if (!this.state.checked) {\r\n this.setValid();\r\n } else {\r\n if (this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\r\n if (!this.props.disabled) {\r\n if (e.key === 'Enter') {\r\n this.inputRef.current?.click();\r\n }\r\n }\r\n }\r\n\r\n private renderInput() {\r\n return (\r\n <input\r\n {...(this.props.id && { id: this.props.id })}\r\n ref={this.inputRef}\r\n value={this.props.value || ''}\r\n type=\"checkbox\"\r\n required={this.props.required}\r\n checked={this.state.checked}\r\n onChange={this.handleChecked}\r\n onBlur={this.handleBlur}\r\n onFocus={this.handleFocus}\r\n onKeyDown={this.handleKeyDown}\r\n tabIndex={this.props.disabled ? -1 : 0}\r\n />\r\n );\r\n }\r\n}\r\n\r\nexport const Checkbox = withThemeContext<\r\n CheckboxProps,\r\n InstanceType<typeof CheckboxRaw>\r\n>(withFormContext<CheckboxProps>(CheckboxRaw), 'checkbox');\r\n\r\nexport default Checkbox;\r\n"],"file":"Checkbox.js"}
1
+ {"version":3,"sources":["../../../src/lib/components/checkbox/Checkbox.tsx"],"names":["classNames","require","CheckboxRaw","props","state","Object","assign","checked","isValid","required","errors","getTranslations","defaultBaseTranslations","handleChecked","bind","handleKeyDown","subscribeSelf","finalIndeterminate","Boolean","supportsIndeterminate","inputRef","current","indeterminate","oldProps","setState","setValid","setInvalid","containerClassName","getValidationClass","className","label","disabled","input","id","value","handleBlur","handleFocus","title","tooltip","containerRef","renderTooltip","renderDefaultValidation","renderLabel","e","onChecked","key","click","BaseInput","defaultProps","Checkbox"],"mappings":";;;;;;;;;AACA;;AAGA;;AACA;;AAOA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAFA,IAAIA,UAAU,GAAGC,OAAO,CAAC,YAAD,CAAxB;;IAgBaC,W;;;;;AASX,uBAAYC,KAAZ,EAAkC;AAAA;;AAAA;;AAChC,8BAAMA,KAAN,EAAa,KAAb;AACA,UAAKC,KAAL,GAAaC,MAAM,CAACC,MAAP,CAAc,MAAKF,KAAnB,EAA0B;AACrCG,MAAAA,OAAO,EAAEJ,KAAK,CAACI,OADsB;AAErCC,MAAAA,OAAO,EAAEL,KAAK,CAACM,QAAN,GAAiBN,KAAK,CAACI,OAAvB,GAAiC,IAFL;AAGrCG,MAAAA,MAAM,EACJP,KAAK,CAACM,QAAN,IAAkB,CAACN,KAAK,CAACI,OAAzB,GACI,CAAC,MAAKI,eAAL,CAAqBC,mCAArB,EAA8CH,QAA/C,CADJ,GAEI;AAN+B,KAA1B,CAAb;AAQA,UAAKI,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,IAAnB,+BAArB;AACA,UAAKC,aAAL,GAAqB,M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rB,yCAAKzB,QAAL,CAAcC,OAAd,kFAAuByB,KAAvB;AACD;AACF;AACF;;;;EAvI8BC,qB;;;;gBAApB7C,W,kBAKkBG,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkByC,sBAAUC,YAA5B,EAA0C,CACrE;AADqE,CAA1C,C;;AAqIxB,IAAMC,QAAQ,GAAG,wCAGtB,sCAA+B/C,WAA/B,CAHsB,EAGuB,UAHvB,CAAjB;;eAKQ+C,Q","sourcesContent":["// Libs\r\nimport * as React from 'react';\r\n\r\n// Misc\r\nimport InputGroup from '../inputGroup/InputGroup';\r\nimport {\r\n BaseInputProps,\r\n BaseInput,\r\n BaseInputState,\r\n defaultBaseTranslations,\r\n} from '../base/input/BaseInput';\r\nvar classNames = require('classnames');\r\nimport { withFormContext } from '../form/withFormContext';\r\nimport { withThemeContext } from '../themeProvider/withThemeContext';\r\n\r\nexport interface CheckboxProps extends BaseInputProps<HTMLInputElement> {\r\n onChecked?: (e: React.ChangeEvent<HTMLInputElement>) => void;\r\n onChange?: never;\r\n type?: string;\r\n checked?: boolean;\r\n supportsIndeterminate?: boolean;\r\n}\r\n\r\nexport interface CheckboxState extends BaseInputState {\r\n checked: boolean;\r\n}\r\n\r\nexport class CheckboxRaw extends BaseInput<\r\n CheckboxProps,\r\n CheckboxState,\r\n HTMLInputElement\r\n> {\r\n public static defaultProps = Object.assign({}, BaseInput.defaultProps, {\r\n // checked: false,\r\n }) as CheckboxProps;\r\n\r\n constructor(props: CheckboxProps) {\r\n super(props, false);\r\n this.state = Object.assign(this.state, {\r\n checked: props.checked,\r\n isValid: props.required ? props.checked : true,\r\n errors:\r\n props.required && !props.checked\r\n ? [this.getTranslations(defaultBaseTranslations).required]\r\n : [],\r\n });\r\n this.handleChecked = this.handleChecked.bind(this);\r\n this.handleKeyDown = this.handleKeyDown.bind(this);\r\n this.subscribeSelf(props);\r\n }\r\n\r\n public componentDidMount() {\r\n const finalIndeterminate = Boolean(\r\n this.props.supportsIndeterminate &&\r\n typeof this.props.checked !== 'boolean'\r\n );\r\n if (\r\n typeof this.props.checked !== 'boolean' &&\r\n this.inputRef.current &&\r\n this.inputRef.current?.indeterminate !== finalIndeterminate\r\n ) {\r\n this.inputRef.current.indeterminate = finalIndeterminate;\r\n }\r\n super.componentDidMount?.();\r\n }\r\n\r\n public componentDidUpdate(oldProps: CheckboxProps) {\r\n if (this.props.checked !== this.state.checked) {\r\n this.setState({ checked: this.props.checked });\r\n if (this.props.checked) {\r\n this.setValid();\r\n } else {\r\n if (this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n }\r\n }\r\n }\r\n if (oldProps.required !== this.props.required) {\r\n if (this.props.required && !this.props.checked) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n } else {\r\n this.setValid();\r\n }\r\n }\r\n const finalIndeterminate = Boolean(\r\n this.props.supportsIndeterminate &&\r\n typeof this.props.checked !== 'boolean'\r\n );\r\n if (\r\n this.props.supportsIndeterminate &&\r\n this.inputRef.current?.indeterminate !== finalIndeterminate\r\n ) {\r\n this.inputRef.current.indeterminate = finalIndeterminate;\r\n }\r\n }\r\n\r\n public render() {\r\n const containerClassName = classNames([\r\n 'input__base checkbox-input',\r\n this.getValidationClass(),\r\n this.props.className,\r\n { ['checkbox-input--with-label']: Boolean(this.props.label) },\r\n { ['checkbox-input--disabled']: this.props.disabled },\r\n ]);\r\n const input = (\r\n <input\r\n {...(this.props.id && { id: this.props.id })}\r\n ref={this.inputRef}\r\n value={this.props.value || ''}\r\n type=\"checkbox\"\r\n required={this.props.required}\r\n checked={this.state.checked ?? false}\r\n onChange={this.handleChecked}\r\n onBlur={this.handleBlur}\r\n onFocus={this.handleFocus}\r\n onKeyDown={this.handleKeyDown}\r\n tabIndex={this.props.disabled ? -1 : 0}\r\n />\r\n );\r\n return (\r\n <InputGroup title={this.props.title} tooltip={this.props.tooltip}>\r\n <div className={containerClassName} ref={this.containerRef}>\r\n {this.props.title && !this.props.label && input}\r\n {!this.props.title && !this.props.label && this.renderTooltip(input)}\r\n {this.renderDefaultValidation()}\r\n {this.props.label && (\r\n <label className=\"checkbox-input__label\">\r\n {input}\r\n {this.renderLabel()}\r\n </label>\r\n )}\r\n </div>\r\n </InputGroup>\r\n );\r\n }\r\n\r\n private handleChecked(e: React.ChangeEvent<HTMLInputElement>) {\r\n if (!this.props.disabled) {\r\n this.props.onChecked && this.props.onChecked(e);\r\n this.setState({ checked: !this.state.checked });\r\n if (!this.state.checked) {\r\n this.setValid();\r\n } else {\r\n if (this.props.required) {\r\n this.setInvalid([\r\n this.getTranslations(defaultBaseTranslations).required,\r\n ]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n protected handleKeyDown(e: React.KeyboardEvent<HTMLInputElement>) {\r\n if (!this.props.disabled) {\r\n if (e.key === 'Enter') {\r\n this.inputRef.current?.click();\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport const Checkbox = withThemeContext<\r\n CheckboxProps,\r\n InstanceType<typeof CheckboxRaw>\r\n>(withFormContext<CheckboxProps>(CheckboxRaw), 'checkbox');\r\n\r\nexport default Checkbox;\r\n"],"file":"Checkbox.js"}
@@ -1376,6 +1376,9 @@
1376
1376
  pointer-events: none; }
1377
1377
  .input__base.checkbox-input input:checked:before {
1378
1378
  transform: rotate(-45deg) scale(1, 1); }
1379
+ .input__base.checkbox-input input:indeterminate:before {
1380
+ border-left-style: none;
1381
+ transform: rotate(0deg) scale(0.8, 1.2) translateX(0); }
1379
1382
  .input__base.checkbox-input input:after {
1380
1383
  content: '';
1381
1384
  position: absolute;