inviton-powerduck 0.0.221 → 0.0.223

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.
@@ -10,6 +10,7 @@ import './css/checkbox.css';
10
10
  interface CheckBoxArgs extends FormItemWrapperArgs {
11
11
  value: boolean;
12
12
  checkboxLabelHtml?: string;
13
+ customRenderOption?: (h, state: CheckBoxDisplayArgs) => any;
13
14
  skin?: CheckBoxSkin;
14
15
  size?: CheckBoxSize;
15
16
  disabled?: boolean;
@@ -27,6 +28,11 @@ export enum CheckBoxSize {
27
28
  Medium = 'md',
28
29
  }
29
30
 
31
+ interface CheckBoxDisplayArgs {
32
+ checked: boolean;
33
+ disabled: boolean;
34
+ }
35
+
30
36
  @Component
31
37
  class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxArgs {
32
38
  @Prop() label!: string;
@@ -34,6 +40,7 @@ class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxAr
34
40
  @Prop() cssClass!: string;
35
41
  @Prop() subtitle!: string;
36
42
  @Prop() checkboxLabelHtml!: string;
43
+ @Prop() customRenderOption?: (h, state: CheckBoxDisplayArgs) => any;
37
44
  @Prop() value!: boolean;
38
45
  @Prop() mandatory!: boolean;
39
46
  @Prop() wrap!: boolean;
@@ -50,6 +57,19 @@ class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxAr
50
57
  @Prop() changed: (newValue: boolean) => void;
51
58
  uuid: string = null;
52
59
 
60
+ getCustomRenderedLabel(h) {
61
+ if (this.customRenderOption != null) {
62
+ const displayArgs: CheckBoxDisplayArgs = {
63
+ checked: this.value,
64
+ disabled: this.disabled ?? false,
65
+ };
66
+
67
+ return this.customRenderOption(h, displayArgs);
68
+ }
69
+
70
+ return null;
71
+ }
72
+
53
73
  raiseChangeEvent(e) {
54
74
  this.populateValidationDeclaration();
55
75
  const val = e.target.checked;
@@ -102,7 +122,7 @@ class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxAr
102
122
  <label class="form-check-label">
103
123
  <input class="form-check-input" type="checkbox" checked={this.value} disabled={this.disabled || undefined} onChange={e => this.raiseChangeEvent(e)} />
104
124
  <span class="form-check-sign"></span>
105
- {this.checkboxLabelHtml}
125
+ {this.getCustomRenderedLabel != null ? this.getCustomRenderedLabel(h) : this.checkboxLabelHtml}
106
126
  </label>
107
127
  </div>
108
128
  );
@@ -120,7 +140,7 @@ class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxAr
120
140
  <div class="inv-cbrb-inner">
121
141
  <input class="inv-chckb-clickable" type="checkbox" id={`iei-input-${this.uuid}`} checked={this.value} disabled={this.disabled || undefined} onChange={e => this.raiseChangeEvent(e)} />
122
142
  <label class="inv-chckb-clickable form-check-label " for={`iei-input-${this.uuid}`}>
123
- <HtmlLiteral innerHTML={this.checkboxLabelHtml} />
143
+ {this.getCustomRenderedLabel != null ? this.getCustomRenderedLabel(h) : <HtmlLiteral innerHTML={this.checkboxLabelHtml} />}
124
144
  </label>
125
145
  </div>
126
146
  </div>
@@ -140,7 +160,7 @@ class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxAr
140
160
  <div class="inv-cbrb-inner">
141
161
  <input class="inv-chckb-clickable" type="checkbox" id={`iei-input-${this.uuid}`} checked={this.value} disabled={this.disabled || undefined} onChange={e => this.raiseChangeEvent(e)} />
142
162
  <label class="inv-chckb-clickable form-check-label " for={`iei-input-${this.uuid}`}>
143
- <HtmlLiteral innerHTML={this.checkboxLabelHtml} />
163
+ {this.getCustomRenderedLabel != null ? this.getCustomRenderedLabel(h) : <HtmlLiteral innerHTML={this.checkboxLabelHtml} />}
144
164
  </label>
145
165
  </div>
146
166
  </div>
@@ -131,7 +131,7 @@ class RadioButtonGroupComponent extends TsxComponent<RadioButtonGroupArgs> imple
131
131
  opts.forEach((item) => {
132
132
  retVal.push({
133
133
  id: this.getReflectedRowValue(item, true),
134
- text: this.customRenderOption != null ? this.handleCustomRenderResult(h, this.customRenderOption(h, item)) : this.getReflectedRowValue(item, false),
134
+ text: this.getReflectedRowValue(item, false),
135
135
  dataRow: item,
136
136
  });
137
137
  });
@@ -141,7 +141,7 @@ class RadioButtonGroupComponent extends TsxComponent<RadioButtonGroupArgs> imple
141
141
  return retVal;
142
142
  }
143
143
 
144
- private handleCustomRenderResult(h: any, renderResult: any): string {
144
+ private handleCustomRenderResult(renderResult: any): string {
145
145
  if (renderResult == null) {
146
146
  return '';
147
147
  }
@@ -226,6 +226,7 @@ class RadioButtonGroupComponent extends TsxComponent<RadioButtonGroupArgs> imple
226
226
  const nameId = `iei-group-${PortalUtils.randomString(6)}`;
227
227
  const selectedItem = this.getSelectedItem(h);
228
228
  const isSmall = this.radioButtonSize === RadioButtonSize.Small;
229
+ const hasCustomRender = this.customRenderOption != null;
229
230
 
230
231
  return (
231
232
  <div class="radio-group-wrap">
@@ -257,7 +258,9 @@ class RadioButtonGroupComponent extends TsxComponent<RadioButtonGroupArgs> imple
257
258
  onChange={() => this.handleRadioValueChanged(h)}
258
259
  />
259
260
  <label class="form-check-label" for={uuid}>
260
- <HtmlLiteral innerHTML={optionItem.text} />
261
+ {hasCustomRender
262
+ ? this.customRenderOption(h, optionItem.dataRow)
263
+ : <HtmlLiteral innerHTML={this.handleCustomRenderResult(optionItem.text)} />}
261
264
  </label>
262
265
  </div>
263
266
  </div>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
3
  "type": "module",
4
- "version": "0.0.221",
4
+ "version": "0.0.223",
5
5
  "files": [
6
6
  "app/",
7
7
  "common/",