inviton-powerduck 0.0.105 → 0.0.107

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.
@@ -829,6 +829,43 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
829
829
  };
830
830
 
831
831
  if (!this.useMultiCheckboxes()) {
832
+ const DIACRITICS = ($ as any).fn.select2.amd.require('select2/diacritics');
833
+ const normalizeForSearch = (text: string) => {
834
+ if (text == null) {
835
+ return null;
836
+ }
837
+
838
+ return stripDiacritics(text).toUpperCase();
839
+ };
840
+ const stripDiacritics = (text: string) => {
841
+ function match(a) {
842
+ return DIACRITICS[a] || a;
843
+ }
844
+
845
+ return text.replace(/[^\u0000-\u007E]/g, match);
846
+ };
847
+ const getMatchingChildren = (term: string, dataSet: any) => {
848
+ const retVal: any[] = [];
849
+ for (const item of dataSet) {
850
+ if (item.children?.length > 0) {
851
+ const subData = getMatchingChildren(term, item.children);
852
+ if (subData.length > 0) {
853
+ retVal.push({
854
+ ...item,
855
+ children: subData
856
+ })
857
+ }
858
+ } else {
859
+ const normalized = normalizeForSearch(item.text);
860
+ if (normalized.indexOf(term) > -1) {
861
+ retVal.push(item);
862
+ }
863
+ }
864
+ }
865
+
866
+ return retVal;
867
+ };
868
+
832
869
  s2Args.data = null
833
870
  s2Args.ajax = {
834
871
  transport: function (params, success, failure) {
@@ -840,7 +877,15 @@ class DropdownListComponent extends TsxComponent<DropdownListArgs> implements Dr
840
877
  resData = opts;
841
878
  }
842
879
 
843
- success({ results: resData });
880
+ const data = (params?.data || {});
881
+ const query = normalizeForSearch(data.q ?? data.term)?.trim();
882
+
883
+ if (query == null || query.length == 0) {
884
+ success({ results: resData });
885
+ return;
886
+ }
887
+
888
+ success({ results: getMatchingChildren(query, resData) });
844
889
  }
845
890
  };
846
891
  }
@@ -1,4 +1,4 @@
1
- import { toNative, Prop, Watch } from "vue-facing-decorator";
1
+ import { toNative, Prop } from "vue-facing-decorator";
2
2
  import TsxComponent, { Component } from "../../app/vuetsx";
3
3
  import FormItemWrapper, { FormItemWrapperArgs, MarginType } from "../form/form-item-wrapper";
4
4
  import HtmlLiteral from "../html-literal/html-literal";
@@ -9,13 +9,20 @@ interface CheckBoxArgs extends FormItemWrapperArgs {
9
9
  value: boolean;
10
10
  checkboxLabelHtml?: string;
11
11
  skin?: CheckBoxSkin;
12
+ size?: CheckBoxSize;
12
13
  disabled?: boolean;
13
14
  changed?: (newValue: boolean) => void;
14
15
  }
15
16
 
16
17
  export enum CheckBoxSkin {
17
18
  NowUi = 0,
18
- Material = 1,
19
+ Material = 1, // default
20
+ MinusVariant = 2,
21
+ }
22
+
23
+ export enum CheckBoxSize {
24
+ Small = "sm",
25
+ Medium = "md",
19
26
  }
20
27
 
21
28
  @Component
@@ -30,6 +37,7 @@ class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxAr
30
37
  @Prop() wrap!: boolean;
31
38
  @Prop() maxWidth?: number;
32
39
  @Prop() skin!: CheckBoxSkin;
40
+ @Prop() size?: CheckBoxSize;
33
41
  @Prop() disabled?: boolean;
34
42
  @Prop() marginType?: MarginType;
35
43
  @Prop() hint: string;
@@ -75,14 +83,20 @@ class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxAr
75
83
  renderCheckboxBasedOnSkin(h) {
76
84
  if (this.skin == CheckBoxSkin.NowUi) {
77
85
  return this.renderCheckboxNowUi(h);
78
- } else {
79
- return this.renderCheckboxMaterial(h);
86
+ } else if (this.skin == CheckBoxSkin.MinusVariant) {
87
+ return this.renderCheckboxMaterialMinus(h);
80
88
  }
89
+ // default -> CheckBoxSkin.Material
90
+ return this.renderCheckboxMaterial(h);
81
91
  }
82
92
 
83
93
  renderCheckboxNowUi(h) {
94
+ const checkboxClass = "form-check " +
95
+ (this.wrap ? "ui-checkbox-wrapped" : "ui-checkbox-nonwrapped") +
96
+ (this.size === CheckBoxSize.Small ? " ui-checkbox-sm" : "");
97
+
84
98
  return (
85
- <div class={"form-check " + (this.wrap ? "ui-checkbox-wrapped" : "ui-checkbox-nonwrapped")}>
99
+ <div class={checkboxClass}>
86
100
  <label class="form-check-label">
87
101
  <input class="form-check-input" type="checkbox" checked={this.value} disabled={this.disabled || undefined} onChange={(e) => this.raiseChangeEvent(e)} />
88
102
  <span class="form-check-sign"></span>
@@ -97,8 +111,32 @@ class CheckBoxComponent extends TsxComponent<CheckBoxArgs> implements CheckBoxAr
97
111
  this.uuid = PortalUtils.randomString(12);
98
112
  }
99
113
 
114
+ const checkboxClass = "inv-md-checkbox" +
115
+ (this.size === CheckBoxSize.Small ? " inv-md-checkbox-sm" : "");
116
+
117
+ return (
118
+ <div class={checkboxClass}>
119
+ <div class="inv-cbrb-inner">
120
+ <input class="inv-chckb-clickable" type="checkbox" id={"iei-input-" + this.uuid} checked={this.value} disabled={this.disabled || undefined} onChange={(e) => this.raiseChangeEvent(e)} />
121
+ <label class="inv-chckb-clickable form-check-label " for={"iei-input-" + this.uuid}>
122
+ <HtmlLiteral innerHTML={this.checkboxLabelHtml} />
123
+ </label>
124
+ </div>
125
+ </div>
126
+ );
127
+ }
128
+
129
+ renderCheckboxMaterialMinus(h) {
130
+ if (this.uuid == null) {
131
+ this.uuid = PortalUtils.randomString(12);
132
+ }
133
+
134
+ const checkboxClass = "inv-md-checkbox" +
135
+ (this.size === CheckBoxSize.Small ? " inv-md-checkbox-sm" : "") +
136
+ (this.skin === CheckBoxSkin.MinusVariant ? " inv-md-checkbox-minus" : "");
137
+
100
138
  return (
101
- <div class="inv-md-checkbox">
139
+ <div class={checkboxClass}>
102
140
  <div class="inv-cbrb-inner">
103
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)} />
104
142
  <label class="inv-chckb-clickable form-check-label " for={"iei-input-" + this.uuid}>
@@ -16,6 +16,12 @@ interface RadioButtonGroupArgs extends FormItemWrapperArgs {
16
16
  displayMember?: string | RowToString;
17
17
  valueMember?: string | RowToString;
18
18
  selected: string | any;
19
+ radioButtonSize?: RadioButtonSize;
20
+ }
21
+
22
+ export const enum RadioButtonSize {
23
+ Small = 'sm',
24
+ Medium = 'md'
19
25
  }
20
26
 
21
27
  interface RadioDisplayArgs {
@@ -38,6 +44,7 @@ class RadioButtonGroupComponent extends TsxComponent<RadioButtonGroupArgs> imple
38
44
  @Prop() prependIcon: string
39
45
  @Prop() appendClicked: () => void
40
46
  @Prop() prependClicked: () => void
47
+ @Prop() radioButtonSize?: RadioButtonSize;
41
48
  @Prop() marginType?: MarginType
42
49
  @Prop() maxWidth?: number
43
50
  @Prop() options!: Array<string> | Array<any>;
@@ -193,31 +200,48 @@ class RadioButtonGroupComponent extends TsxComponent<RadioButtonGroupArgs> imple
193
200
  }
194
201
 
195
202
  renderInput(h) {
196
- let nameId = 'iei-group-' + PortalUtils.randomString(6);
197
- let selectedItem = this.getSelectedItem();
198
-
199
- return (
200
- <div class="radio-group-wrap">
201
- {this.getOptions().map((optionItem) => {
202
- const uuid = 'iei-input-' + PortalUtils.randomString(10);
203
- const selected = optionItem.id == selectedItem?.id;
204
- const disabled = optionItem.dataRow?.dataRow?.disabled ?? false;
205
-
206
- return (
207
- <div class="inv-rbchb form-check inv-mdfw-radio">
208
- <div class="inv-cbrb-inner">
209
- <input class="form-check-input" key={uuid} checked={selected} type="radio" name={nameId} id={uuid} value={optionItem.id} disabled={disabled} onChange={() => this.handleRadioValueChanged()} />
210
- <label class="form-check-label" for={uuid}>
211
- {/* <span>{optionItem.text}</span> */}
212
- <HtmlLiteral innerHTML={optionItem.text} />
213
- </label>
214
- </div>
215
- </div>
216
- )
217
- })}
218
- </div>
219
- )
220
- }
203
+ const nameId = 'iei-group-' + PortalUtils.randomString(6);
204
+ const selectedItem = this.getSelectedItem();
205
+ const isSmall = this.radioButtonSize === RadioButtonSize.Small;
206
+
207
+ return (
208
+ <div class="radio-group-wrap">
209
+ {this.getOptions().map((optionItem) => {
210
+ const uuid = 'iei-input-' + PortalUtils.randomString(10);
211
+ const selected = optionItem.id == selectedItem?.id;
212
+ const disabled = optionItem.dataRow?.disabled ?? false;
213
+
214
+ const wrapperClass = [
215
+ "inv-rbchb",
216
+ "form-check",
217
+ "inv-mdfw-radio",
218
+ isSmall ? "inv-md-radio-sm" : ""
219
+ ].join(" ");
220
+
221
+ return (
222
+ <div class={wrapperClass}>
223
+ <div class="inv-cbrb-inner">
224
+ <input
225
+ class="form-check-input"
226
+ key={uuid}
227
+ checked={selected}
228
+ type="radio"
229
+ name={nameId}
230
+ id={uuid}
231
+ value={optionItem.id}
232
+ disabled={disabled}
233
+ onChange={() => this.handleRadioValueChanged()}
234
+ />
235
+ <label class="form-check-label" for={uuid}>
236
+ <HtmlLiteral innerHTML={optionItem.text} />
237
+ </label>
238
+ </div>
239
+ </div>
240
+ );
241
+ })}
242
+ </div>
243
+ );
244
+ }
221
245
  }
222
246
 
223
247
  const RadioButtonGroup = toNative(RadioButtonGroupComponent)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
- "version": "0.0.105",
3
+ "version": "0.0.107",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": " vite build && vue-tsc --declaration --emitDeclarationOnly",