@dashboard-designer/ui 0.2.1 → 0.2.2

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/README.md CHANGED
@@ -209,3 +209,29 @@ buttons. These application-provided callbacks are not stored in dashboard JSON.
209
209
 
210
210
  The native Angular package exposes the equivalent `[toolbarButtons]` input on
211
211
  its designer and viewer, using text or `TemplateRef` icons instead of React nodes.
212
+
213
+
214
+ ## Hide toolbar controls from application code
215
+
216
+ Use `toolbarVisibility` on the designer or viewer. Set a key to `false` to hide
217
+ that control; omitted keys retain their normal behavior. `true` does not override
218
+ read-only mode, permissions, or the dashboard's export settings.
219
+
220
+ ```ts
221
+ const toolbarVisibility = { share: false, settings: false, print: false, pdf: false, json: false, email: false };
222
+ ```
223
+
224
+ ```tsx
225
+ <DashboardViewer dashboard={dashboard} apiBaseUrl={apiBaseUrl} auth={auth}
226
+ toolbarVisibility={toolbarVisibility} />
227
+ // Use hideToolbar={true} to hide the entire header, including custom buttons.
228
+ ```
229
+
230
+ Supported keys: `refresh`, `lastRefresh`, `filters`, `variables`, `print`, `pdf`,
231
+ `json`, `email`, `edit`, `share`, `settings`, `history`, `undo`, `redo`, `reset`,
232
+ `add`, `save`, `drillBack`, and `import` (Angular's built-in import control).
233
+ For custom buttons use their existing `visible: false` or `visible: context =>
234
+ boolean` option. Update the inputs/props to change visibility at runtime. These
235
+ options are application configuration and are not saved in dashboard JSON.
236
+ Hiding a control is presentation only, not an authorization mechanism; keyboard
237
+ shortcuts and other entry points remain subject to their existing permissions.
package/dist/index.d.ts CHANGED
@@ -29,7 +29,11 @@ interface DashboardToolbarButton {
29
29
  }
30
30
  interface DashboardToolbarProps {
31
31
  toolbarButtons?: readonly DashboardToolbarButton[];
32
+ hideToolbar?: boolean;
33
+ toolbarVisibility?: DashboardToolbarVisibility;
32
34
  }
35
+ /** False hides a built-in control; omitted keys retain normal behavior. */
36
+ type DashboardToolbarVisibility = Partial<Record<'refresh' | 'filters' | 'variables' | 'print' | 'pdf' | 'json' | 'email' | 'edit' | 'share' | 'settings' | 'history' | 'undo' | 'redo' | 'reset' | 'add' | 'save' | 'import' | 'drillBack' | 'lastRefresh', boolean>>;
33
37
 
34
38
  interface ChartDataRowActionContext {
35
39
  dashboardId: string;
@@ -69,7 +73,7 @@ interface DashboardDesignerProps extends DashboardVariableProps, ChartDataAction
69
73
  /** When set, shows Edit / Done in the dashboard toolbar. */
70
74
  onToggleEdit?: () => void;
71
75
  }
72
- declare function DashboardDesigner({ dashboard: initial, apiBaseUrl, auth, locale, onChange, onSave, readOnly, onToggleEdit, predefinedVariables, variableValues, variablesReady, resolveVariables, chartDataRowActions, toolbarButtons, }: DashboardDesignerProps): React__default.JSX.Element;
76
+ declare function DashboardDesigner({ dashboard: initial, apiBaseUrl, auth, locale, onChange, onSave, readOnly, onToggleEdit, predefinedVariables, variableValues, variablesReady, resolveVariables, chartDataRowActions, toolbarButtons, hideToolbar, toolbarVisibility, }: DashboardDesignerProps): React__default.JSX.Element;
73
77
 
74
78
  interface DashboardViewerProps extends DashboardVariableProps, ChartDataActionProps, DashboardToolbarProps {
75
79
  dashboard: Dashboard;
@@ -280,4 +284,4 @@ declare function downloadDashboardJson(dashboard: Dashboard): void;
280
284
  /** Read a File as text and return JSON. */
281
285
  declare function readJsonFile(file: File): Promise<unknown>;
282
286
 
283
- export { type ChartDataActionProps, type ChartDataRowAction, type ChartDataRowActionContext, ChartRenderer, DashboardApiClient, DashboardDesigner, type DashboardDesignerProps, type DashboardToolbarButton, type DashboardToolbarContext, type DashboardToolbarProps, type DashboardVariableProps, DashboardViewer, type DashboardViewerProps, FieldHelp, type FieldHelpProps, FieldLabel, type FieldLabelProps, FilterBar, ICON_SIZE, SearchableSelect, type SearchableSelectProps, chartTypeIcon, downloadDashboardJson, ensureI18n, navIcon, readJsonFile };
287
+ export { type ChartDataActionProps, type ChartDataRowAction, type ChartDataRowActionContext, ChartRenderer, DashboardApiClient, DashboardDesigner, type DashboardDesignerProps, type DashboardToolbarButton, type DashboardToolbarContext, type DashboardToolbarProps, type DashboardToolbarVisibility, type DashboardVariableProps, DashboardViewer, type DashboardViewerProps, FieldHelp, type FieldHelpProps, FieldLabel, type FieldLabelProps, FilterBar, ICON_SIZE, SearchableSelect, type SearchableSelectProps, chartTypeIcon, downloadDashboardJson, ensureI18n, navIcon, readJsonFile };
package/dist/index.js CHANGED
@@ -8473,7 +8473,9 @@ function DashboardDesigner({
8473
8473
  variablesReady,
8474
8474
  resolveVariables,
8475
8475
  chartDataRowActions,
8476
- toolbarButtons
8476
+ toolbarButtons,
8477
+ hideToolbar = false,
8478
+ toolbarVisibility = {}
8477
8479
  }) {
8478
8480
  ensureI18n(locale);
8479
8481
  const { t, i18n: i18n2 } = useTranslation20();
@@ -8879,7 +8881,7 @@ function DashboardDesigner({
8879
8881
  children: /* @__PURE__ */ jsxs25(VariableContext.Provider, { value: variableContext, children: [
8880
8882
  variableContext.error && /* @__PURE__ */ jsx28("div", { className: "dd-error", role: "alert", children: variableContext.error }),
8881
8883
  !variableContext.ready && !variableContext.error && /* @__PURE__ */ jsx28("div", { role: "status", className: "dd-hint", children: "Loading variables\u2026" }),
8882
- /* @__PURE__ */ jsxs25("header", { className: "dd-toolbar", children: [
8884
+ !hideToolbar && /* @__PURE__ */ jsxs25("header", { className: "dd-toolbar", children: [
8883
8885
  /* @__PURE__ */ jsxs25("div", { className: "dd-toolbar-left", children: [
8884
8886
  editingTitle && !effectiveReadOnly ? /* @__PURE__ */ jsx28(
8885
8887
  "input",
@@ -8934,11 +8936,11 @@ function DashboardDesigner({
8934
8936
  /* @__PURE__ */ jsxs25("div", { className: "dd-toolbar-right", children: [
8935
8937
  /* @__PURE__ */ jsx28(ToolbarButtons, { buttons: toolbarButtons, context: { dashboard, dashboardId: dashboard.id, mode: effectiveReadOnly ? "view" : "edit", variables: variableContext.values, refresh: refreshFromToolbar } }),
8936
8938
  drillError && /* @__PURE__ */ jsx28("span", { className: "dd-error dd-inline-error", children: drillError }),
8937
- drillTrail.length > 0 && /* @__PURE__ */ jsxs25("button", { type: "button", className: "dd-btn", onClick: handleDrillBack, children: [
8939
+ toolbarVisibility.drillBack !== false && drillTrail.length > 0 && /* @__PURE__ */ jsxs25("button", { type: "button", className: "dd-btn", onClick: handleDrillBack, children: [
8938
8940
  /* @__PURE__ */ jsx28(ArrowUpLeft, { size: ICON_SIZE }),
8939
8941
  t("drillBack")
8940
8942
  ] }),
8941
- /* @__PURE__ */ jsx28(
8943
+ toolbarVisibility.filters !== false && /* @__PURE__ */ jsx28(
8942
8944
  GlobalFiltersPopover,
8943
8945
  {
8944
8946
  filters: dashboard.globalFilters,
@@ -8948,7 +8950,7 @@ function DashboardDesigner({
8948
8950
  onPanelChange: setFiltersPanel
8949
8951
  }
8950
8952
  ),
8951
- /* @__PURE__ */ jsx28(
8953
+ toolbarVisibility.refresh !== false && /* @__PURE__ */ jsx28(
8952
8954
  "button",
8953
8955
  {
8954
8956
  type: "button",
@@ -8960,7 +8962,7 @@ function DashboardDesigner({
8960
8962
  children: /* @__PURE__ */ jsx28(RefreshCw2, { size: ICON_SIZE })
8961
8963
  }
8962
8964
  ),
8963
- /* @__PURE__ */ jsxs25("span", { className: "dd-hint", role: "status", title: t("lastRefreshHint"), children: [
8965
+ toolbarVisibility.lastRefresh !== false && /* @__PURE__ */ jsxs25("span", { className: "dd-hint", role: "status", title: t("lastRefreshHint"), children: [
8964
8966
  refreshing ? t("refreshingDashboard") : refreshFailed ? t("dashboardRefreshFailed") : "",
8965
8967
  lastRefresh?.dashboardId === dashboard.id && /* @__PURE__ */ jsxs25(Fragment10, { children: [
8966
8968
  " ",
@@ -8969,9 +8971,9 @@ function DashboardDesigner({
8969
8971
  /* @__PURE__ */ jsx28("time", { dateTime: lastRefresh.value, children: new Date(lastRefresh.value).toLocaleString(effectiveLocale, { timeZone: dashboard.timeZone }) })
8970
8972
  ] })
8971
8973
  ] }),
8972
- !effectiveReadOnly && /* @__PURE__ */ jsx28("button", { type: "button", className: "dd-btn", onClick: () => setVariablesOpen(true), children: "Variables" }),
8974
+ !effectiveReadOnly && toolbarVisibility.variables !== false && /* @__PURE__ */ jsx28("button", { type: "button", className: "dd-btn", onClick: () => setVariablesOpen(true), children: "Variables" }),
8973
8975
  (exportOpts.print || exportOpts.pdf || exportOpts.json || exportOpts.email) && /* @__PURE__ */ jsxs25("div", { className: "dd-toolbar-export", role: "group", "aria-label": t("exportOptions"), children: [
8974
- exportOpts.print && /* @__PURE__ */ jsxs25(
8976
+ toolbarVisibility.print !== false && exportOpts.print && /* @__PURE__ */ jsxs25(
8975
8977
  "button",
8976
8978
  {
8977
8979
  type: "button",
@@ -8985,7 +8987,7 @@ function DashboardDesigner({
8985
8987
  ]
8986
8988
  }
8987
8989
  ),
8988
- exportOpts.pdf && /* @__PURE__ */ jsxs25(
8990
+ toolbarVisibility.pdf !== false && exportOpts.pdf && /* @__PURE__ */ jsxs25(
8989
8991
  "button",
8990
8992
  {
8991
8993
  type: "button",
@@ -8999,7 +9001,7 @@ function DashboardDesigner({
8999
9001
  ]
9000
9002
  }
9001
9003
  ),
9002
- exportOpts.json && /* @__PURE__ */ jsxs25(
9004
+ toolbarVisibility.json !== false && exportOpts.json && /* @__PURE__ */ jsxs25(
9003
9005
  "button",
9004
9006
  {
9005
9007
  type: "button",
@@ -9013,7 +9015,7 @@ function DashboardDesigner({
9013
9015
  ]
9014
9016
  }
9015
9017
  ),
9016
- exportOpts.email && /* @__PURE__ */ jsxs25(
9018
+ toolbarVisibility.email !== false && exportOpts.email && /* @__PURE__ */ jsxs25(
9017
9019
  "button",
9018
9020
  {
9019
9021
  type: "button",
@@ -9028,7 +9030,7 @@ function DashboardDesigner({
9028
9030
  }
9029
9031
  )
9030
9032
  ] }),
9031
- onToggleEdit && readOnly && drillTrail.length === 0 && /* @__PURE__ */ jsxs25(
9033
+ toolbarVisibility.edit !== false && onToggleEdit && readOnly && drillTrail.length === 0 && /* @__PURE__ */ jsxs25(
9032
9034
  "button",
9033
9035
  {
9034
9036
  type: "button",
@@ -9043,7 +9045,7 @@ function DashboardDesigner({
9043
9045
  }
9044
9046
  ),
9045
9047
  !effectiveReadOnly && /* @__PURE__ */ jsxs25(Fragment10, { children: [
9046
- /* @__PURE__ */ jsxs25(
9048
+ toolbarVisibility.share !== false && /* @__PURE__ */ jsxs25(
9047
9049
  "button",
9048
9050
  {
9049
9051
  type: "button",
@@ -9057,7 +9059,7 @@ function DashboardDesigner({
9057
9059
  ]
9058
9060
  }
9059
9061
  ),
9060
- /* @__PURE__ */ jsx28(
9062
+ toolbarVisibility.settings !== false && /* @__PURE__ */ jsx28(
9061
9063
  "button",
9062
9064
  {
9063
9065
  type: "button",
@@ -9068,7 +9070,7 @@ function DashboardDesigner({
9068
9070
  children: /* @__PURE__ */ jsx28(Settings2, { size: ICON_SIZE })
9069
9071
  }
9070
9072
  ),
9071
- /* @__PURE__ */ jsxs25(
9073
+ toolbarVisibility.history !== false && /* @__PURE__ */ jsxs25(
9072
9074
  "button",
9073
9075
  {
9074
9076
  type: "button",
@@ -9083,7 +9085,7 @@ function DashboardDesigner({
9083
9085
  }
9084
9086
  ),
9085
9087
  /* @__PURE__ */ jsxs25("div", { className: "dd-toolbar-history", role: "group", "aria-label": t("editHistory"), children: [
9086
- /* @__PURE__ */ jsx28(
9088
+ toolbarVisibility.undo !== false && /* @__PURE__ */ jsx28(
9087
9089
  "button",
9088
9090
  {
9089
9091
  type: "button",
@@ -9095,7 +9097,7 @@ function DashboardDesigner({
9095
9097
  children: /* @__PURE__ */ jsx28(Undo2, { size: ICON_SIZE })
9096
9098
  }
9097
9099
  ),
9098
- /* @__PURE__ */ jsx28(
9100
+ toolbarVisibility.redo !== false && /* @__PURE__ */ jsx28(
9099
9101
  "button",
9100
9102
  {
9101
9103
  type: "button",
@@ -9107,7 +9109,7 @@ function DashboardDesigner({
9107
9109
  children: /* @__PURE__ */ jsx28(Redo2, { size: ICON_SIZE })
9108
9110
  }
9109
9111
  ),
9110
- /* @__PURE__ */ jsx28(
9112
+ toolbarVisibility.reset !== false && /* @__PURE__ */ jsx28(
9111
9113
  "button",
9112
9114
  {
9113
9115
  type: "button",
@@ -9120,11 +9122,11 @@ function DashboardDesigner({
9120
9122
  }
9121
9123
  )
9122
9124
  ] }),
9123
- /* @__PURE__ */ jsxs25("button", { type: "button", className: "dd-btn", onClick: openAddModal, children: [
9125
+ toolbarVisibility.add !== false && /* @__PURE__ */ jsxs25("button", { type: "button", className: "dd-btn", onClick: openAddModal, children: [
9124
9126
  /* @__PURE__ */ jsx28(Plus6, { size: ICON_SIZE }),
9125
9127
  t("add")
9126
9128
  ] }),
9127
- /* @__PURE__ */ jsxs25("button", { type: "button", className: "dd-btn dd-btn-primary", onClick: () => void handleSave(), children: [
9129
+ toolbarVisibility.save !== false && /* @__PURE__ */ jsxs25("button", { type: "button", className: "dd-btn dd-btn-primary", onClick: () => void handleSave(), children: [
9128
9130
  /* @__PURE__ */ jsx28(Save2, { size: ICON_SIZE }),
9129
9131
  t("save")
9130
9132
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashboard-designer/ui",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",