selective-ui 1.3.0 → 1.4.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "selective-ui",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "An overlay for the HTML select element.",
5
5
  "author": "Huỳnh Công Xuân Mai",
6
6
  "license": "MIT",
@@ -1,15 +1,14 @@
1
1
  .seui-placeholder {
2
- display: flex;
3
2
  align-items: center;
4
3
 
5
4
  margin-left: 10px;
6
- max-width: calc(100% - 30px);
7
- height: calc(100% - 10px);
5
+ max-width: calc(100% - 40px);
8
6
  text-overflow: ellipsis;
9
7
  white-space: nowrap;
10
8
  pointer-events: none;
9
+ overflow: hidden;
10
+
11
11
  font-family: var(--seui-view-text-style);
12
12
  font-size: var(--seui-view-text-size) !important;
13
- overflow: hidden;
14
13
  color: var(--seui-view-text-color);
15
14
  }
@@ -867,6 +867,23 @@ export class SelectBox extends Lifecycle {
867
867
  this.change(false, trigger);
868
868
  },
869
869
 
870
+ deSelectByDataset(_evtToken?: IEventCallback, dataset?: any, trigger: boolean = true) {
871
+ if (dataset) {
872
+ superThis.getModelOption().forEach(optionModel => {
873
+ if (optionModel.dataset) {
874
+ for (let searchKey in dataset) {
875
+ let value = dataset[searchKey];
876
+ !Array.isArray(value) && (value = [value]);
877
+ if (value.includes(optionModel.dataset[searchKey])) {
878
+ optionModel.selectedNonTrigger = false;
879
+ }
880
+ }
881
+ }
882
+ });
883
+ this.change(false, trigger);
884
+ }
885
+ },
886
+
870
887
  setValue(_evtToken: IEventCallback | null = null, value: any, trigger: boolean = true, force: boolean = false) {
871
888
  if (!Array.isArray(value)) value = [value];
872
889
  value = value.filter((v: any) => v !== "" && v != null);
@@ -899,18 +916,15 @@ export class SelectBox extends Lifecycle {
899
916
  const result = await container.searchController.loadByValues(missing);
900
917
  if (result.success && result.items.length > 0) {
901
918
  result.items.forEach((it: any) => {
902
- if (missing.includes(it.value)) it.selected = true;
919
+ if (missing.includes(it.value) || missing.includes(it.text)) it.selected = true;
903
920
  });
904
921
 
905
- // keep legacy private hook access
906
- container.searchController.applyAjaxResult?.(result.items, true, true);
907
-
922
+ container.searchController.applyAjaxResult?.(result.items, false, false);
923
+
908
924
  setTimeout(() => {
909
- superThis.getModelOption().forEach((m) => {
910
- m.selectedNonTrigger = value.some((v: any) => v == m.value);
911
- });
912
- this.change(false, false);
913
- }, 100);
925
+ container.searchController.resetPagination();
926
+ this.change(false, trigger);
927
+ }, 200);
914
928
  } else if (missing.length > 0) {
915
929
  console.warn(`Could not load ${missing.length} values:`, missing);
916
930
  }