scb-wc-test 0.1.108 → 0.1.110

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.
@@ -4,6 +4,7 @@ JS-bryggan (scb-blazor-bridge.js) samlar state från DOM:en och levererar det so
4
4
  som kan användas direkt i Razor-vyer */
5
5
 
6
6
  using System;
7
+ using System.Linq;
7
8
  using System.Threading.Tasks;
8
9
  using Microsoft.AspNetCore.Components;
9
10
  using Microsoft.JSInterop;
@@ -39,11 +40,11 @@ namespace ScbBlazorDemo
39
40
  // Alla accordions på sidan (scb-accordion) med sina items
40
41
  protected AccordionListState[] Accordions { get; private set; } = Array.Empty<AccordionListState>();
41
42
 
42
- // Bool-array som speglar checkboxarnas valda läge
43
- protected bool[] Checkboxes { get; private set; } = Array.Empty<bool>();
43
+ // Lista som speglar checkboxarnas valda läge och metadata
44
+ protected CheckboxState[] Checkboxes { get; private set; } = Array.Empty<CheckboxState>();
44
45
 
45
- // Bool-array som speglar switcharnas på/av-läge
46
- protected bool[] Switches { get; private set; } = Array.Empty<bool>();
46
+ // Lista som speglar switcharnas valda läge och metadata
47
+ protected SwitchState[] Switches { get; private set; } = Array.Empty<SwitchState>();
47
48
 
48
49
  // App-bar (scb-app-bar)
49
50
  protected AppBarState AppBar { get; private set; } = new();
@@ -63,7 +64,7 @@ namespace ScbBlazorDemo
63
64
  // Nyckeltalskort (scb-keyfigure-card)
64
65
  protected KeyfigureState[] Keyfigures { get; private set; } = Array.Empty<KeyfigureState>();
65
66
 
66
- // Enskild kalender (scb-calendar-card) för scenarier där man bara bryr sig om en
67
+ // Enskild kalender (scb-calendar-card) för scenarion där man bara bryr sig om en
67
68
  protected CalendarState Calendar { get; private set; } = new();
68
69
 
69
70
  // Alla kalenderkort på sidan
@@ -249,8 +250,25 @@ namespace ScbBlazorDemo
249
250
  }
250
251
 
251
252
  // Checkboxar och switchar
252
- Checkboxes = state.Checkboxes ?? Array.Empty<bool>();
253
- Switches = state.Switches ?? Array.Empty<bool>();
253
+ Checkboxes = (state.Checkboxes ?? Array.Empty<CheckboxDto>())
254
+ .Select(dto => new CheckboxState
255
+ {
256
+ Checked = dto.Checked,
257
+ Name = dto.Name ?? string.Empty,
258
+ Value = dto.Value ?? string.Empty,
259
+ Label = dto.Label ?? string.Empty,
260
+ })
261
+ .ToArray();
262
+
263
+ Switches = (state.Switches ?? Array.Empty<SwitchDto>())
264
+ .Select(dto => new SwitchState
265
+ {
266
+ Selected = dto.Selected,
267
+ Name = dto.Name ?? string.Empty,
268
+ Value = dto.Value ?? string.Empty,
269
+ Label = dto.Label ?? string.Empty,
270
+ })
271
+ .ToArray();
254
272
 
255
273
  // App-bar
256
274
  AppBar.Title = state.AppBar.Title ?? string.Empty;
@@ -577,7 +595,9 @@ namespace ScbBlazorDemo
577
595
  Value = dto.Value ?? string.Empty,
578
596
  Label = dto.Label ?? string.Empty,
579
597
  SupportingText = dto.SupportingText ?? string.Empty,
580
- Error = dto.Error
598
+ Error = dto.Error,
599
+ Name = dto.Name ?? string.Empty,
600
+ Id = dto.Id ?? string.Empty
581
601
  };
582
602
  }
583
603
  Textfields = fields;
@@ -599,7 +619,9 @@ namespace ScbBlazorDemo
599
619
  Value = dto.Value ?? string.Empty,
600
620
  SupportingText = dto.SupportingText ?? string.Empty,
601
621
  FullScreen = dto.FullScreen,
602
- Size = dto.Size ?? string.Empty
622
+ Size = dto.Size ?? string.Empty,
623
+ Name = dto.Name ?? string.Empty,
624
+ Id = dto.Id ?? string.Empty
603
625
  };
604
626
  }
605
627
  Searches = searches;
@@ -777,7 +799,246 @@ namespace ScbBlazorDemo
777
799
  return ValueTask.CompletedTask;
778
800
  }
779
801
 
780
- // Nedan följer alla state-klasser som används i Razor views
802
+
803
+
804
+ // Styrkommandon som skickar anrop från Blazor till SCB web components via SCBBlazor-objektet i JS.
805
+ // Dessa metoder uppdaterar DOM:ens state och triggar samma normaliserade events som vid användarinteraktion.
806
+ // Id- och name-baserade varianter rekommenderas för mer robust adressering än ren index-baserad styrning.
807
+
808
+ // Header (scb-header)
809
+ protected Task SetHeaderActiveTabAsync(int activeTab)
810
+ {
811
+ return JS.InvokeVoidAsync("SCBBlazor.setHeaderActiveTab", activeTab).AsTask();
812
+ }
813
+
814
+ protected Task SetHeaderDrawerOpenAsync(bool open)
815
+ {
816
+ return JS.InvokeVoidAsync("SCBBlazor.setHeaderDrawerOpen", open).AsTask();
817
+ }
818
+
819
+ protected Task SetHeaderSearchTextAsync(string searchText)
820
+ {
821
+ return JS.InvokeVoidAsync("SCBBlazor.setHeaderSearchText", searchText ?? string.Empty).AsTask();
822
+ }
823
+
824
+ // Drawer och meny
825
+ protected Task SetDrawerOpenAsync(bool open)
826
+ {
827
+ return JS.InvokeVoidAsync("SCBBlazor.setDrawerOpen", open).AsTask();
828
+ }
829
+
830
+ protected Task SetDrawerTextAsync(string label, string subLabel)
831
+ {
832
+ return JS.InvokeVoidAsync(
833
+ "SCBBlazor.setDrawerText",
834
+ label ?? string.Empty,
835
+ subLabel ?? string.Empty).AsTask();
836
+ }
837
+
838
+ protected Task SetMenuOpenAsync(bool open)
839
+ {
840
+ return JS.InvokeVoidAsync("SCBBlazor.setMenuOpen", open).AsTask();
841
+ }
842
+
843
+ // Sub-menyer: index-baserad och id-baserad variant
844
+ protected Task SetSubMenuOpenAsync(int index, bool open)
845
+ {
846
+ return JS.InvokeVoidAsync("SCBBlazor.setSubMenuOpen", index, open).AsTask();
847
+ }
848
+
849
+ protected Task SetSubMenuOpenByIdAsync(string id, bool open)
850
+ {
851
+ return JS.InvokeVoidAsync("SCBBlazor.setSubMenuOpenById", id ?? string.Empty, open).AsTask();
852
+ }
853
+
854
+ // Breadcrumb
855
+ protected Task SetBreadcrumbShowAllAsync(bool showAll)
856
+ {
857
+ return JS.InvokeVoidAsync("SCBBlazor.setBreadcrumbShowAll", showAll).AsTask();
858
+ }
859
+
860
+ // Accordions: index-baserad och id-baserad variant för items
861
+ protected Task SetAccordionItemOpenAsync(int accordionIndex, int itemIndex, bool open)
862
+ {
863
+ return JS.InvokeVoidAsync("SCBBlazor.setAccordionItemOpen", accordionIndex, itemIndex, open).AsTask();
864
+ }
865
+
866
+ protected Task SetAccordionItemOpenByIdAsync(string itemId, bool open)
867
+ {
868
+ return JS.InvokeVoidAsync("SCBBlazor.setAccordionItemOpenById", itemId ?? string.Empty, open).AsTask();
869
+ }
870
+
871
+ // Checkboxar: index-baserad och id-baserad variant
872
+ protected Task SetCheckboxCheckedAsync(int index, bool isChecked)
873
+ {
874
+ return JS.InvokeVoidAsync("SCBBlazor.setCheckboxChecked", index, isChecked).AsTask();
875
+ }
876
+
877
+ protected Task SetCheckboxCheckedByIdAsync(string id, bool isChecked)
878
+ {
879
+ return JS.InvokeVoidAsync("SCBBlazor.setCheckboxCheckedById", id ?? string.Empty, isChecked).AsTask();
880
+ }
881
+
882
+ // Switchar: index-baserad och id-baserad variant
883
+ protected Task SetSwitchSelectedAsync(int index, bool selected)
884
+ {
885
+ return JS.InvokeVoidAsync("SCBBlazor.setSwitchSelected", index, selected).AsTask();
886
+ }
887
+
888
+ protected Task SetSwitchSelectedByIdAsync(string id, bool selected)
889
+ {
890
+ return JS.InvokeVoidAsync("SCBBlazor.setSwitchSelectedById", id ?? string.Empty, selected).AsTask();
891
+ }
892
+
893
+ // Segmented button: global och id-baserad variant
894
+ protected Task SetSegmentedValueAsync(string value)
895
+ {
896
+ return JS.InvokeVoidAsync("SCBBlazor.setSegmentedValue", value ?? string.Empty).AsTask();
897
+ }
898
+
899
+ protected Task SetSegmentedValuesAsync(string[] values)
900
+ {
901
+ return JS.InvokeVoidAsync("SCBBlazor.setSegmentedValues", values ?? Array.Empty<string>()).AsTask();
902
+ }
903
+
904
+ protected Task SetSegmentedValueByIdAsync(string id, string value)
905
+ {
906
+ return JS.InvokeVoidAsync("SCBBlazor.setSegmentedValueById", id ?? string.Empty, value ?? string.Empty).AsTask();
907
+ }
908
+
909
+ protected Task SetSegmentedValuesByIdAsync(string id, string[] values)
910
+ {
911
+ return JS.InvokeVoidAsync("SCBBlazor.setSegmentedValuesById", id ?? string.Empty, values ?? Array.Empty<string>()).AsTask();
912
+ }
913
+
914
+ // Tabs: index-baserad och id-baserad variant
915
+ protected Task SetTabsActiveIndexAsync(int tabsIndex, int activeIndex)
916
+ {
917
+ return JS.InvokeVoidAsync("SCBBlazor.setTabsActiveIndex", tabsIndex, activeIndex).AsTask();
918
+ }
919
+
920
+ protected Task SetTabsActiveIndexByIdAsync(string id, int activeIndex)
921
+ {
922
+ return JS.InvokeVoidAsync("SCBBlazor.setTabsActiveIndexById", id ?? string.Empty, activeIndex).AsTask();
923
+ }
924
+
925
+ // Dialog
926
+ protected Task SetDialogOpenAsync(bool open)
927
+ {
928
+ return JS.InvokeVoidAsync("SCBBlazor.setDialogOpen", open).AsTask();
929
+ }
930
+
931
+ // Notification: index-baserad och id-baserad variant
932
+ protected Task SetNotificationOpenAsync(int index, bool open)
933
+ {
934
+ return JS.InvokeVoidAsync("SCBBlazor.setNotificationOpen", index, open).AsTask();
935
+ }
936
+
937
+ protected Task SetNotificationOpenByIdAsync(string id, bool open)
938
+ {
939
+ return JS.InvokeVoidAsync("SCBBlazor.setNotificationOpenById", id ?? string.Empty, open).AsTask();
940
+ }
941
+
942
+ // Snackbar: index-baserad och id-baserad variant
943
+ protected Task SetSnackbarOpenAsync(int index, bool open)
944
+ {
945
+ return JS.InvokeVoidAsync("SCBBlazor.setSnackbarOpen", index, open).AsTask();
946
+ }
947
+
948
+ protected Task SetSnackbarOpenByIdAsync(string id, bool open)
949
+ {
950
+ return JS.InvokeVoidAsync("SCBBlazor.setSnackbarOpenById", id ?? string.Empty, open).AsTask();
951
+ }
952
+
953
+ // Stepper: global och id-baserad variant
954
+ protected Task SetStepperActiveIndexAsync(int activeIndex)
955
+ {
956
+ return JS.InvokeVoidAsync("SCBBlazor.setStepperActiveIndex", activeIndex).AsTask();
957
+ }
958
+
959
+ protected Task SetStepperActiveIndexByIdAsync(string id, int activeIndex)
960
+ {
961
+ return JS.InvokeVoidAsync("SCBBlazor.setStepperActiveIndexById", id ?? string.Empty, activeIndex).AsTask();
962
+ }
963
+
964
+ // Pagination: index-baserad och id-baserad variant
965
+ protected Task SetPaginationPageAsync(int paginationIndex, int page)
966
+ {
967
+ return JS.InvokeVoidAsync("SCBBlazor.setPaginationPage", paginationIndex, page).AsTask();
968
+ }
969
+
970
+ protected Task SetPaginationPageByIdAsync(string id, int page)
971
+ {
972
+ return JS.InvokeVoidAsync("SCBBlazor.setPaginationPageById", id ?? string.Empty, page).AsTask();
973
+ }
974
+
975
+ // Radio-group: index-, name- och id-baserad variant
976
+ protected Task SetRadioGroupValueByIndexAsync(int index, string value)
977
+ {
978
+ return JS.InvokeVoidAsync("SCBBlazor.setRadioGroupValueByIndex", index, value ?? string.Empty).AsTask();
979
+ }
980
+
981
+ protected Task SetRadioGroupValueByNameAsync(string name, string value)
982
+ {
983
+ return JS.InvokeVoidAsync(
984
+ "SCBBlazor.setRadioGroupValueByName",
985
+ name ?? string.Empty,
986
+ value ?? string.Empty).AsTask();
987
+ }
988
+
989
+ protected Task SetRadioGroupValueByIdAsync(string id, string value)
990
+ {
991
+ return JS.InvokeVoidAsync(
992
+ "SCBBlazor.setRadioGroupValueById",
993
+ id ?? string.Empty,
994
+ value ?? string.Empty).AsTask();
995
+ }
996
+
997
+ // Textfield: index- och id-baserad variant
998
+ protected Task SetTextfieldValueAsync(int index, string value)
999
+ {
1000
+ return JS.InvokeVoidAsync("SCBBlazor.setTextfieldValue", index, value ?? string.Empty).AsTask();
1001
+ }
1002
+
1003
+ protected Task SetTextfieldValueByIdAsync(string id, string value)
1004
+ {
1005
+ return JS.InvokeVoidAsync("SCBBlazor.setTextfieldValueById", id ?? string.Empty, value ?? string.Empty).AsTask();
1006
+ }
1007
+
1008
+ // Search: index- och id-baserad variant
1009
+ protected Task SetSearchValueAsync(int index, string value)
1010
+ {
1011
+ return JS.InvokeVoidAsync("SCBBlazor.setSearchValue", index, value ?? string.Empty).AsTask();
1012
+ }
1013
+
1014
+ protected Task SetSearchValueByIdAsync(string id, string value)
1015
+ {
1016
+ return JS.InvokeVoidAsync("SCBBlazor.setSearchValueById", id ?? string.Empty, value ?? string.Empty).AsTask();
1017
+ }
1018
+
1019
+ // TOC: index-baserad och id-baserad variant för items
1020
+ protected Task SetTocItemExpandedAsync(int tocIndex, int itemIndex, bool expanded)
1021
+ {
1022
+ return JS.InvokeVoidAsync("SCBBlazor.setTocItemExpanded", tocIndex, itemIndex, expanded).AsTask();
1023
+ }
1024
+
1025
+ protected Task SetTocItemExpandedByIdAsync(string itemId, bool expanded)
1026
+ {
1027
+ return JS.InvokeVoidAsync("SCBBlazor.setTocItemExpandedById", itemId ?? string.Empty, expanded).AsTask();
1028
+ }
1029
+
1030
+ // Viz: index- och id-baserad variant
1031
+ protected Task SetVizSelectedChipAsync(int index, string selectedChip)
1032
+ {
1033
+ return JS.InvokeVoidAsync("SCBBlazor.setVizSelectedChip", index, selectedChip ?? string.Empty).AsTask();
1034
+ }
1035
+
1036
+ protected Task SetVizSelectedChipByIdAsync(string id, string selectedChip)
1037
+ {
1038
+ return JS.InvokeVoidAsync("SCBBlazor.setVizSelectedChipById", id ?? string.Empty, selectedChip ?? string.Empty).AsTask();
1039
+ }
1040
+
1041
+ // Nedan följer alla state-klasser som används i Razor views
781
1042
 
782
1043
  protected sealed class HeaderState
783
1044
  {
@@ -830,6 +1091,22 @@ namespace ScbBlazorDemo
830
1091
  public string SupportingText { get; set; } = string.Empty;
831
1092
  }
832
1093
 
1094
+ protected sealed class CheckboxState
1095
+ {
1096
+ public bool Checked { get; set; }
1097
+ public string Name { get; set; } = string.Empty;
1098
+ public string Value { get; set; } = string.Empty;
1099
+ public string Label { get; set; } = string.Empty;
1100
+ }
1101
+
1102
+ protected sealed class SwitchState
1103
+ {
1104
+ public bool Selected { get; set; }
1105
+ public string Name { get; set; } = string.Empty;
1106
+ public string Value { get; set; } = string.Empty;
1107
+ public string Label { get; set; } = string.Empty;
1108
+ }
1109
+
833
1110
  protected sealed class AppBarState
834
1111
  {
835
1112
  public string Title { get; set; } = string.Empty;
@@ -957,6 +1234,8 @@ namespace ScbBlazorDemo
957
1234
  public string Label { get; set; } = string.Empty;
958
1235
  public string SupportingText { get; set; } = string.Empty;
959
1236
  public bool Error { get; set; }
1237
+ public string Name { get; set; } = string.Empty;
1238
+ public string Id { get; set; } = string.Empty;
960
1239
  }
961
1240
 
962
1241
  protected sealed class SearchState
@@ -965,6 +1244,8 @@ namespace ScbBlazorDemo
965
1244
  public string SupportingText { get; set; } = string.Empty;
966
1245
  public bool FullScreen { get; set; }
967
1246
  public string Size { get; set; } = string.Empty;
1247
+ public string Name { get; set; } = string.Empty;
1248
+ public string Id { get; set; } = string.Empty;
968
1249
  }
969
1250
 
970
1251
  protected sealed class ListState
@@ -1056,8 +1337,8 @@ namespace ScbBlazorDemo
1056
1337
 
1057
1338
  public AccordionListDto[] Accordions { get; set; } = Array.Empty<AccordionListDto>();
1058
1339
 
1059
- public bool[] Checkboxes { get; set; } = Array.Empty<bool>();
1060
- public bool[] Switches { get; set; } = Array.Empty<bool>();
1340
+ public CheckboxDto[] Checkboxes { get; set; } = Array.Empty<CheckboxDto>();
1341
+ public SwitchDto[] Switches { get; set; } = Array.Empty<SwitchDto>();
1061
1342
  public AppBarDto AppBar { get; set; } = new();
1062
1343
  public SegmentedDto Segmented { get; set; } = new();
1063
1344
 
@@ -1151,6 +1432,22 @@ namespace ScbBlazorDemo
1151
1432
  public string? SupportingText { get; set; }
1152
1433
  }
1153
1434
 
1435
+ private sealed class CheckboxDto
1436
+ {
1437
+ public bool Checked { get; set; }
1438
+ public string? Name { get; set; }
1439
+ public string? Value { get; set; }
1440
+ public string? Label { get; set; }
1441
+ }
1442
+
1443
+ private sealed class SwitchDto
1444
+ {
1445
+ public bool Selected { get; set; }
1446
+ public string? Name { get; set; }
1447
+ public string? Value { get; set; }
1448
+ public string? Label { get; set; }
1449
+ }
1450
+
1154
1451
  private sealed class AppBarDto
1155
1452
  {
1156
1453
  public string? Title { get; set; }
@@ -1278,6 +1575,8 @@ namespace ScbBlazorDemo
1278
1575
  public string? Label { get; set; }
1279
1576
  public string? SupportingText { get; set; }
1280
1577
  public bool Error { get; set; }
1578
+ public string? Name { get; set; }
1579
+ public string? Id { get; set; }
1281
1580
  }
1282
1581
 
1283
1582
  private sealed class SearchDto
@@ -1286,6 +1585,8 @@ namespace ScbBlazorDemo
1286
1585
  public string? SupportingText { get; set; }
1287
1586
  public bool FullScreen { get; set; }
1288
1587
  public string? Size { get; set; }
1588
+ public string? Name { get; set; }
1589
+ public string? Id { get; set; }
1289
1590
  }
1290
1591
 
1291
1592
  private sealed class ListDto