@qrvey/widget-configurability 0.0.0-beta.4737 → 0.0.0-beta.4768

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.
@@ -32,6 +32,84 @@ var __objRest = (source, exclude) => {
32
32
  };
33
33
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
34
34
 
35
+ // src/constants/structure.constants.ts
36
+ var STRUCTURE_SECTION_NAME_SEPARATOR = ".";
37
+ var STRUCTURE_VIEW_NAME_SEPARATOR = "::";
38
+ var STRUCTURE_RESERVED_WORDS = [
39
+ "views",
40
+ "defaults",
41
+ "subModules"
42
+ ];
43
+ var Widget = /* @__PURE__ */ function(Widget2) {
44
+ Widget2["DASHBOARD"] = "dashboard";
45
+ Widget2["REPORT"] = "report";
46
+ Widget2["DOWNLOAD_MANAGER"] = "download-manager";
47
+ Widget2["DOWNLOAD_MODAL"] = "download-modal";
48
+ Widget2["CHART_PANEL"] = "chart-panel";
49
+ Widget2["CHART_GALLERY"] = "chart-gallery";
50
+ Widget2["CHART_BUILDER"] = "chart-builder";
51
+ return Widget2;
52
+ }({});
53
+ var WIDGET_SUBMODULE_NAMES = {
54
+ ["download-modal"]: "downloadModal",
55
+ ["chart-panel"]: "chartPanel",
56
+ ["chart-gallery"]: "chartGallery",
57
+ ["chart-builder"]: "chartBuilder"
58
+ };
59
+ var WIDGET_STRUCTURE_SCOPE_KIND = "qrvey.widget-structure-scope";
60
+ var WIDGET_STRUCTURE_SCOPE_FORMAT = 1;
61
+ var WidgetVersion = /* @__PURE__ */ function(WidgetVersion2) {
62
+ WidgetVersion2["v1"] = "1.0";
63
+ WidgetVersion2["latest"] = "latest";
64
+ return WidgetVersion2;
65
+ }({});
66
+
67
+ // src/metadata/customization-applicability.ts
68
+ var chainOf = /* @__PURE__ */ __name((key) => key.split(STRUCTURE_SECTION_NAME_SEPARATOR).map((_, index, parts) => parts.slice(0, index + 1).join(STRUCTURE_SECTION_NAME_SEPARATOR)), "chainOf");
69
+ var defaultRole = /* @__PURE__ */ __name((kind) => kind === "item" ? "item" : "group", "defaultRole");
70
+ function resolveApplicability(map, key, view, kind, gate) {
71
+ var _a, _b, _c, _d;
72
+ const chain = chainOf(key);
73
+ let views = gate == null ? void 0 : gate.views;
74
+ const requires = new Set((_a = gate == null ? void 0 : gate.requires) != null ? _a : []);
75
+ let underNone = false;
76
+ chain.forEach((path) => {
77
+ var _a2;
78
+ const entry = map[path];
79
+ if (!entry) return;
80
+ if (entry.views) {
81
+ const declared = entry.views;
82
+ views = views ? views.filter((name) => declared.includes(name)) : [
83
+ ...declared
84
+ ];
85
+ }
86
+ (_a2 = entry.requires) == null ? void 0 : _a2.forEach((requirement) => requires.add(requirement));
87
+ if (path !== key && entry.role === "none") underNone = true;
88
+ });
89
+ const role = (_c = (_b = map[key]) == null ? void 0 : _b.role) != null ? _c : defaultRole(kind);
90
+ const applies = role !== "none" && !underNone && ((_d = gate == null ? void 0 : gate.applies) != null ? _d : true) && (view === void 0 || !views || views.includes(view));
91
+ return __spreadValues(__spreadValues({
92
+ role,
93
+ applies,
94
+ toggleable: applies && (role === "item" || role === "group")
95
+ }, views && {
96
+ views
97
+ }), requires.size && {
98
+ requires: [
99
+ ...requires
100
+ ]
101
+ });
102
+ }
103
+ __name(resolveApplicability, "resolveApplicability");
104
+ function mergeApplicability(states) {
105
+ const [first] = states;
106
+ return __spreadProps(__spreadValues({}, first), {
107
+ applies: states.some((state) => state.applies),
108
+ toggleable: states.some((state) => state.toggleable)
109
+ });
110
+ }
111
+ __name(mergeApplicability, "mergeApplicability");
112
+
35
113
  // src/metadata/labels/chart-panel.defaults.ts
36
114
  var CHART_PANEL_DEFAULTS = {
37
115
  menuLayout: {
@@ -523,6 +601,326 @@ var CHART_PANEL_LABELS = {
523
601
  }
524
602
  };
525
603
 
604
+ // src/metadata/labels/dashboard.applicability.ts
605
+ var each = /* @__PURE__ */ __name((keys, applicability) => Object.fromEntries(keys.map((key) => [
606
+ key,
607
+ applicability
608
+ ])), "each");
609
+ var DASHBOARD_APPLICABILITY = __spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues({
610
+ // The manager bar is not rendered in dummy mode, nor for a single dashboard outside Composer.
611
+ navBar: {
612
+ requires: [
613
+ "environment"
614
+ ]
615
+ },
616
+ "navBar.qBackButton": {
617
+ views: [
618
+ "design",
619
+ "preview",
620
+ "endUser"
621
+ ]
622
+ },
623
+ // Dashboard list. Card and table fields only show in their mode of the list.
624
+ "assetList.asset.card": {
625
+ requires: [
626
+ "cardView"
627
+ ]
628
+ },
629
+ "assetList.asset.table": {
630
+ requires: [
631
+ "tableView"
632
+ ]
633
+ },
634
+ // Nothing reads it: the list has one Duplicate option whose modal asks about the charts.
635
+ "assetList.asset.optionMenu.qDuplDashAndCharts": {
636
+ role: "none"
637
+ }
638
+ }, each([
639
+ "assetList.asset.optionMenu.qEditDash",
640
+ "assetList.asset.optionMenu.qUseDash",
641
+ "assetList.asset.optionMenu.qRenameDash",
642
+ "assetList.asset.optionMenu.qDuplDash",
643
+ "assetList.asset.optionMenu.qManageSharing",
644
+ "controlBarLeft.qCreateDash"
645
+ ], {
646
+ requires: [
647
+ "permission"
648
+ ]
649
+ })), each([
650
+ "controlBarRight.qSwitchView",
651
+ "controlBarRight.timezone",
652
+ "controlBarRight.qFilterBy",
653
+ "controlBarRight.qFilterByTags",
654
+ "controlBarRight.qSearch"
655
+ ], {
656
+ views: [
657
+ "list"
658
+ ]
659
+ })), {
660
+ "controlBarRight.qSortBy": {
661
+ views: [
662
+ "list"
663
+ ],
664
+ requires: [
665
+ "cardView"
666
+ ]
667
+ },
668
+ "controlBarRight.qSelectColumn": {
669
+ views: [
670
+ "list"
671
+ ],
672
+ requires: [
673
+ "tableView"
674
+ ]
675
+ }
676
+ }), each([
677
+ "controlBarRight.qPreview",
678
+ "controlBarRight.qDiscard",
679
+ "controlBarRight.qPublish",
680
+ "controlBarRight.qUnpublish",
681
+ "controlBarRight.qSwitchMode"
682
+ ], {
683
+ views: [
684
+ "design"
685
+ ]
686
+ })), {
687
+ "controlBarRight.qDesign": {
688
+ views: [
689
+ "preview"
690
+ ],
691
+ requires: [
692
+ "permission"
693
+ ]
694
+ }
695
+ }), each([
696
+ "controlBarRight.qStatus",
697
+ "controlBarRight.qDownloadList"
698
+ ], {
699
+ views: [
700
+ "design",
701
+ "preview"
702
+ ]
703
+ })), {
704
+ // Only after a 401 (expired qv_token), or a go-to-dashboard navigation.
705
+ qQvTokenExpiredMessage: {
706
+ requires: [
707
+ "environment"
708
+ ]
709
+ },
710
+ qGoToDashBackButton: {
711
+ requires: [
712
+ "navigation"
713
+ ]
714
+ },
715
+ // Duplicating is a command, and dummy mode refuses commands. The options node only carries defaults nobody reads:
716
+ // DashboardX reads them from duplicateModal.
717
+ duplicateModal: {
718
+ requires: [
719
+ "environment"
720
+ ]
721
+ },
722
+ "duplicateModal.options": {
723
+ role: "none"
724
+ },
725
+ // Only defaults (drag, resize, remove, changeLayout, unsavedChangesBehavior). Removing it hides no control, it
726
+ // drops the defaults, which turns off dragging and resizing in design.
727
+ canvas: {
728
+ role: "defaults"
729
+ },
730
+ "header.qTags": {
731
+ requires: [
732
+ "content"
733
+ ]
734
+ },
735
+ // Design menu bar.
736
+ "menuBar.file.qMnuDuplicateDashAndCharts": {
737
+ role: "none"
738
+ },
739
+ "menuBar.edit.qSelectAllContElem": {
740
+ role: "none"
741
+ }
742
+ }), each([
743
+ "menuBar.file.qMnuCanvasSize",
744
+ "menuBar.grid.qMnuSnapToGrid",
745
+ "menuBar.qMnuArrange",
746
+ "menuBar.insert.qMnuInsertHeader"
747
+ ], {
748
+ requires: [
749
+ "fixedCanvas"
750
+ ]
751
+ })), each([
752
+ "menuBar.file.qManageSharing",
753
+ "menuBar.file.qCreateDataset",
754
+ "menuBar.insert.qMnuInsertChart.qMnuNewChartAI"
755
+ ], {
756
+ requires: [
757
+ "permission"
758
+ ]
759
+ })), each([
760
+ "toolBar.qInsertChart",
761
+ "toolBar.qInsertFilterCtrl",
762
+ "toolBar.qInsertShape",
763
+ "toolBar.grid",
764
+ "toolBar.qResponsiveView",
765
+ "toolBar.qInsertText",
766
+ "toolBar.qInsertImage",
767
+ "toolBar.qInsertButton",
768
+ "toolBar.qInsertContainer",
769
+ "toolBar.qThemes"
770
+ ], {
771
+ views: [
772
+ "design"
773
+ ]
774
+ })), each([
775
+ "toolBar.qCanvasSize",
776
+ "toolBar.qArrange",
777
+ "toolBar.qAlign"
778
+ ], {
779
+ views: [
780
+ "design"
781
+ ],
782
+ requires: [
783
+ "fixedCanvas"
784
+ ]
785
+ })), {
786
+ "toolBar.grid.qSnapToGrid": {
787
+ requires: [
788
+ "fixedCanvas"
789
+ ]
790
+ }
791
+ }), each([
792
+ "toolBar.qRespGridMargins",
793
+ "toolBar.qRespGridColumns"
794
+ ], {
795
+ views: [
796
+ "design"
797
+ ],
798
+ requires: [
799
+ "responsiveCanvas"
800
+ ]
801
+ })), {
802
+ "toolBar.qResponsiveView.qBreakpoints": {
803
+ requires: [
804
+ "responsiveCanvas"
805
+ ]
806
+ },
807
+ "toolBar.qCreateDataset": {
808
+ views: [
809
+ "design"
810
+ ],
811
+ requires: [
812
+ "permission"
813
+ ]
814
+ },
815
+ "toolBar.qInsertChart.qNewChartAI": {
816
+ requires: [
817
+ "permission"
818
+ ]
819
+ },
820
+ "toolBar.qDownloadDash": {
821
+ requires: [
822
+ "permission"
823
+ ]
824
+ }
825
+ }), each([
826
+ "toolBar.qDashVersion",
827
+ "toolBar.qDiscard",
828
+ "toolBar.qSave",
829
+ "toolBar.qSwitchMode",
830
+ "toolBar.qHideToolBar",
831
+ "toolBar.qDownloadList",
832
+ "toolBar.qChangeLayout"
833
+ ], {
834
+ views: [
835
+ "endUser"
836
+ ]
837
+ })), each([
838
+ "toolBar.qGetDashVersion",
839
+ "toolBar.qSourceDashBanner",
840
+ "toolBar.qHiddenItems"
841
+ ], {
842
+ views: [
843
+ "endUser"
844
+ ],
845
+ requires: [
846
+ "personalization"
847
+ ]
848
+ })), {
849
+ // The filter settings button needs the canvas in edit mode; view-only filters come from navigation.
850
+ "filterPanel.qFilterSettings": {
851
+ views: [
852
+ "design"
853
+ ]
854
+ },
855
+ "filterPanel.viewOnlyFilterScope": {
856
+ views: [
857
+ "preview",
858
+ "endUser"
859
+ ],
860
+ requires: [
861
+ "navigation"
862
+ ]
863
+ }
864
+ }), each([
865
+ "filterPanel.tabFilterScope",
866
+ "filterPanel.panelFilterScope"
867
+ ], {
868
+ requires: [
869
+ "content"
870
+ ]
871
+ })), each([
872
+ "downloadModal.qExportVersion",
873
+ "downloadModal.qSavedVersionWarning"
874
+ ], {
875
+ views: [
876
+ "endUser"
877
+ ]
878
+ })), {
879
+ "downloadModal.qUnsavedVersionWarning": {
880
+ views: [
881
+ "endUser"
882
+ ],
883
+ requires: [
884
+ "personalization"
885
+ ]
886
+ },
887
+ // Only an admin editing a schedule reads it, and DashboardX never opens the modal that way.
888
+ "downloadModal.qSubscribeOwner": {
889
+ role: "none"
890
+ },
891
+ // No reader in DashboardX nor in the qomponents export modal.
892
+ "downloadModal.qIncludeHeader": {
893
+ role: "none"
894
+ },
895
+ "downloadModal.qSubscribeOrganization": {
896
+ requires: [
897
+ "composer"
898
+ ]
899
+ },
900
+ "downloadModal.qIncludeHyperlinks": {
901
+ requires: [
902
+ "content"
903
+ ]
904
+ },
905
+ // The chart panel has no charts to render in the list; the gallery always reads its design keys, also in endUser;
906
+ // nothing reads the chart builder's.
907
+ "subModules.chartPanel": {
908
+ views: [
909
+ "design",
910
+ "preview",
911
+ "endUser"
912
+ ]
913
+ },
914
+ "subModules.chartGallery": {
915
+ views: [
916
+ "design"
917
+ ]
918
+ },
919
+ "subModules.chartBuilder": {
920
+ role: "none"
921
+ }
922
+ });
923
+
526
924
  // src/metadata/labels/dashboard.defaults.ts
527
925
  var COLOR = "Color names or hex, e.g. '#000000', 'green', 'GREEN'";
528
926
  var IMAGE_URL = "Valid image url";
@@ -1190,12 +1588,12 @@ var DASHBOARD_DEFAULTS = __spreadProps(__spreadValues(__spreadProps(__spreadValu
1190
1588
  },
1191
1589
  "downloadModal.columns.minColumnWidth": {
1192
1590
  type: "number",
1193
- description: "Defines the Minimum Column Width, an integer from 32 to 240 CSS px, that Advanced Settings preselects for table PDF exports; an invalid value is ignored",
1591
+ description: "Defines the Minimum Column Width, a positive integer in CSS px (the allowed range is set per environment, 32 to 500 by default), that Advanced Settings preselects for table PDF exports; an invalid value is ignored",
1194
1592
  since: "9.6"
1195
1593
  },
1196
1594
  "downloadModal.columns.repeatTableContext": {
1197
1595
  type: "boolean",
1198
- description: "Defines whether Advanced Settings preselects Repeat table context for table PDF exports",
1596
+ description: "Defines whether Advanced Settings preselects Repeat table context for table PDF exports; off when unset",
1199
1597
  since: "9.6"
1200
1598
  },
1201
1599
  "downloadModal.includeTables": {
@@ -2407,38 +2805,6 @@ var DASHBOARD_LABELS = {
2407
2805
  }
2408
2806
  };
2409
2807
 
2410
- // src/constants/structure.constants.ts
2411
- var STRUCTURE_SECTION_NAME_SEPARATOR = ".";
2412
- var STRUCTURE_VIEW_NAME_SEPARATOR = "::";
2413
- var STRUCTURE_RESERVED_WORDS = [
2414
- "views",
2415
- "defaults",
2416
- "subModules"
2417
- ];
2418
- var Widget = /* @__PURE__ */ function(Widget2) {
2419
- Widget2["DASHBOARD"] = "dashboard";
2420
- Widget2["REPORT"] = "report";
2421
- Widget2["DOWNLOAD_MANAGER"] = "download-manager";
2422
- Widget2["DOWNLOAD_MODAL"] = "download-modal";
2423
- Widget2["CHART_PANEL"] = "chart-panel";
2424
- Widget2["CHART_GALLERY"] = "chart-gallery";
2425
- Widget2["CHART_BUILDER"] = "chart-builder";
2426
- return Widget2;
2427
- }({});
2428
- var WIDGET_SUBMODULE_NAMES = {
2429
- ["download-modal"]: "downloadModal",
2430
- ["chart-panel"]: "chartPanel",
2431
- ["chart-gallery"]: "chartGallery",
2432
- ["chart-builder"]: "chartBuilder"
2433
- };
2434
- var WIDGET_STRUCTURE_SCOPE_KIND = "qrvey.widget-structure-scope";
2435
- var WIDGET_STRUCTURE_SCOPE_FORMAT = 1;
2436
- var WidgetVersion = /* @__PURE__ */ function(WidgetVersion2) {
2437
- WidgetVersion2["v1"] = "1.0";
2438
- WidgetVersion2["latest"] = "latest";
2439
- return WidgetVersion2;
2440
- }({});
2441
-
2442
2808
  // src/utils/defaults.helpers.ts
2443
2809
  var FONT_SIZES2 = [
2444
2810
  8,
@@ -2545,11 +2911,8 @@ var COLUMN_SIZINGS = [
2545
2911
  "FIT_TO_CONTENT",
2546
2912
  "FIT_TO_PAGE_WIDTH"
2547
2913
  ];
2548
- var MIN_COLUMN_WIDTH = 32;
2549
- var MAX_COLUMN_WIDTH = 240;
2550
2914
  var validateOneOf = /* @__PURE__ */ __name((validValues) => (value) => typeof value === "string" && validValues.includes(value) ? value : void 0, "validateOneOf");
2551
- var validateIntegerInRange = /* @__PURE__ */ __name((minValue, maxValue) => (value) => Number.isInteger(value) && value >= minValue && value <= maxValue ? value : void 0, "validateIntegerInRange");
2552
- var validateMinColumnWidth = validateIntegerInRange(MIN_COLUMN_WIDTH, MAX_COLUMN_WIDTH);
2915
+ var validateMinColumnWidth = /* @__PURE__ */ __name((value) => Number.isInteger(value) && value > 0 ? value : void 0, "validateMinColumnWidth");
2553
2916
  var DX_VALIDATOR_MAP = {
2554
2917
  "customStyles.header.height": numberMinMaxValue(300, 10),
2555
2918
  "customStyles.text.fontSize": fontSizeMinMaxValue(8, 96),
@@ -4230,7 +4593,8 @@ __name(structureFromSubmodule, "structureFromSubmodule");
4230
4593
  var widgetMetadata = {
4231
4594
  [Widget.DASHBOARD]: {
4232
4595
  labels: DASHBOARD_LABELS,
4233
- defaults: DASHBOARD_DEFAULTS
4596
+ defaults: DASHBOARD_DEFAULTS,
4597
+ applicability: DASHBOARD_APPLICABILITY
4234
4598
  },
4235
4599
  [Widget.CHART_PANEL]: {
4236
4600
  labels: CHART_PANEL_LABELS,
@@ -4305,6 +4669,49 @@ function getCustomizationLabel(widget, key) {
4305
4669
  };
4306
4670
  }
4307
4671
  __name(getCustomizationLabel, "getCustomizationLabel");
4672
+ var SUBMODULES_PREFIX = `subModules${STRUCTURE_SECTION_NAME_SEPARATOR}`;
4673
+ var applicabilityMapOf = /* @__PURE__ */ __name((widget) => {
4674
+ var _a, _b;
4675
+ return (_b = (_a = widgetMetadata[widget]) == null ? void 0 : _a.applicability) != null ? _b : {};
4676
+ }, "applicabilityMapOf");
4677
+ var subModuleGate = /* @__PURE__ */ __name((widget, name, view) => resolveApplicability(applicabilityMapOf(widget), `${SUBMODULES_PREFIX}${name}`, view, "subModule"), "subModuleGate");
4678
+ function getKeyApplicability(widget, key, view, options = {}) {
4679
+ const { subModule } = options;
4680
+ if (!subModule && key.startsWith(SUBMODULES_PREFIX)) {
4681
+ return subModuleGate(widget, key.slice(SUBMODULES_PREFIX.length), view);
4682
+ }
4683
+ const owner = subModule ? widgetOfSubmodule(subModule) : widget;
4684
+ const structure = structureRootOf(owner, options, subModule);
4685
+ const keys = structureKeysOf(owner, structure.views ? view : void 0, void 0, {
4686
+ structure
4687
+ });
4688
+ const kind = keys.some((other) => other.startsWith(`${key}${STRUCTURE_SECTION_NAME_SEPARATOR}`)) ? "section" : "item";
4689
+ const applicability = resolveApplicability(applicabilityMapOf(owner), key, view, kind, subModule ? subModuleGate(widget, subModule, view) : void 0);
4690
+ return keys.includes(key) ? applicability : __spreadProps(__spreadValues({}, applicability), {
4691
+ applies: false,
4692
+ toggleable: false
4693
+ });
4694
+ }
4695
+ __name(getKeyApplicability, "getKeyApplicability");
4696
+ function withApplicability(host, widget, target, nodes, applicableOnly) {
4697
+ var _a;
4698
+ const views = target.views.length ? target.views : [
4699
+ void 0
4700
+ ];
4701
+ const subModules = (_a = target.subModules) != null ? _a : [];
4702
+ const gates = views.map((view) => subModules.length ? subModuleGate(host, subModules[subModules.length - 1], view) : void 0);
4703
+ const map = applicabilityMapOf(widget);
4704
+ const annotate = /* @__PURE__ */ __name((list) => list.map((node) => {
4705
+ const applicability = mergeApplicability(views.map((view, index) => resolveApplicability(map, node.key, view, node.kind, gates[index])));
4706
+ const children = node.children && annotate(node.children);
4707
+ const annotated = __spreadValues(__spreadValues({}, node), applicability);
4708
+ if (children == null ? void 0 : children.length) annotated.children = children;
4709
+ else delete annotated.children;
4710
+ return annotated;
4711
+ }).filter((node) => !applicableOnly || node.applies), "annotate");
4712
+ return annotate(nodes);
4713
+ }
4714
+ __name(withApplicability, "withApplicability");
4308
4715
  function getCustomizationTree(widget, target, options = {}) {
4309
4716
  const resolved = resolveTarget(widget, target, options);
4310
4717
  const ordered = [];
@@ -4326,7 +4733,10 @@ function getCustomizationTree(widget, target, options = {}) {
4326
4733
  }, description && {
4327
4734
  description
4328
4735
  }), {
4329
- kind: "item"
4736
+ kind: "item",
4737
+ role: "item",
4738
+ applies: true,
4739
+ toggleable: true
4330
4740
  });
4331
4741
  nodes.set(key, node);
4332
4742
  if (parts.length === 1) {
@@ -4342,7 +4752,7 @@ function getCustomizationTree(widget, target, options = {}) {
4342
4752
  return node;
4343
4753
  }, "ensure");
4344
4754
  ordered.forEach(ensure);
4345
- return roots;
4755
+ return withApplicability(widget, resolved.widget, target, roots, !!options.applicableOnly);
4346
4756
  }
4347
4757
  __name(getCustomizationTree, "getCustomizationTree");
4348
4758
  function instanceFor(widget, customization, target, view) {
@@ -4409,9 +4819,9 @@ function lockOf(customization, target, view, key, hiddenParent) {
4409
4819
  };
4410
4820
  }
4411
4821
  __name(lockOf, "lockOf");
4412
- function getCustomizationTreeState(widget, customization, target) {
4822
+ function getCustomizationTreeState(widget, customization, target, options = {}) {
4413
4823
  var _a;
4414
- const tree = getCustomizationTree(widget, target);
4824
+ const tree = getCustomizationTree(widget, target, options);
4415
4825
  const embedded = !!((_a = target.subModules) == null ? void 0 : _a.length);
4416
4826
  const instances = target.views.map((view) => ({
4417
4827
  view,
@@ -4613,6 +5023,11 @@ function flatten(widget, tree, scope, defaults) {
4613
5023
  since,
4614
5024
  notes,
4615
5025
  audience: own,
5026
+ role: node.role,
5027
+ applies: node.applies,
5028
+ toggleable: node.toggleable,
5029
+ views: node.views,
5030
+ requires: node.requires,
4616
5031
  defaults: byKey.get(node.key)
4617
5032
  });
4618
5033
  return [
@@ -4623,13 +5038,13 @@ function flatten(widget, tree, scope, defaults) {
4623
5038
  return walk(tree, null, DEFAULT_AUDIENCE);
4624
5039
  }
4625
5040
  __name(flatten, "flatten");
4626
- function subModuleEntry(widget, name, scope) {
5041
+ function subModuleEntry(widget, name, view) {
4627
5042
  var _a;
4628
5043
  const key = `subModules${STRUCTURE_SECTION_NAME_SEPARATOR}${name}`;
4629
5044
  const { label, description, since, notes, audience } = (_a = SUBMODULE_LABELS[name]) != null ? _a : getCustomizationLabel(widget, key);
4630
- return compact({
5045
+ return compact(__spreadValues({
4631
5046
  key,
4632
- scope,
5047
+ scope: view != null ? view : "",
4633
5048
  parent: null,
4634
5049
  kind: "subModule",
4635
5050
  label,
@@ -4637,7 +5052,7 @@ function subModuleEntry(widget, name, scope) {
4637
5052
  since,
4638
5053
  notes,
4639
5054
  audience: audience != null ? audience : DEFAULT_AUDIENCE
4640
- });
5055
+ }, getKeyApplicability(widget, key, view)));
4641
5056
  }
4642
5057
  __name(subModuleEntry, "subModuleEntry");
4643
5058
  function getCustomizationDocs(widget, options = {}) {
@@ -4656,7 +5071,9 @@ function getCustomizationDocs(widget, options = {}) {
4656
5071
  };
4657
5072
  const entries = flatten(widget, getCustomizationTree(widget, target, options), scope, hostDefaults);
4658
5073
  Object.keys(asObject(map[`${viewPrefix(view)}subModules`])).filter((name) => !options.subModules || options.subModules.includes(name)).forEach((name) => {
4659
- entries.push(subModuleEntry(widget, name, scope));
5074
+ const entry = subModuleEntry(widget, name, view);
5075
+ if (options.applicableOnly && !entry.applies) return;
5076
+ entries.push(entry);
4660
5077
  const embedded = findWidgetOfSubmodule(name);
4661
5078
  if (!embedded) return;
4662
5079
  entries.push(...flatten(embedded, getCustomizationTree(widget, __spreadProps(__spreadValues({}, target), {
@@ -4689,6 +5106,6 @@ function getCustomizationDefaultDocs(widget, options = {}) {
4689
5106
  }
4690
5107
  __name(getCustomizationDefaultDocs, "getCustomizationDefaultDocs");
4691
5108
 
4692
- export { getCustomizationDefaultDocs, getCustomizationDocs, getCustomizationLabel, getCustomizationTree, getCustomizationTreeState, structureKeysOf, toggleCustomizationKey, widgetMetadata };
5109
+ export { getCustomizationDefaultDocs, getCustomizationDocs, getCustomizationLabel, getCustomizationTree, getCustomizationTreeState, getKeyApplicability, structureKeysOf, toggleCustomizationKey, widgetMetadata };
4693
5110
  //# sourceMappingURL=metadata.mjs.map
4694
5111
  //# sourceMappingURL=metadata.mjs.map