@embedpdf/plugin-ui 2.0.0-next.1 → 2.0.0-next.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.
Files changed (56) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +235 -146
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +31 -15
  6. package/dist/lib/schema.d.ts +51 -10
  7. package/dist/lib/selectors.d.ts +5 -5
  8. package/dist/lib/types.d.ts +39 -23
  9. package/dist/lib/ui-plugin.d.ts +11 -8
  10. package/dist/lib/utils/consts.d.ts +3 -0
  11. package/dist/lib/utils/schema-merger.d.ts +1 -1
  12. package/dist/lib/utils/stylesheet-generator.d.ts +17 -0
  13. package/dist/preact/adapter.d.ts +1 -1
  14. package/dist/preact/index.cjs +1 -1
  15. package/dist/preact/index.cjs.map +1 -1
  16. package/dist/preact/index.js +143 -38
  17. package/dist/preact/index.js.map +1 -1
  18. package/dist/react/adapter.d.ts +1 -1
  19. package/dist/react/index.cjs +1 -1
  20. package/dist/react/index.cjs.map +1 -1
  21. package/dist/react/index.js +143 -38
  22. package/dist/react/index.js.map +1 -1
  23. package/dist/shared/hooks/index.d.ts +1 -0
  24. package/dist/shared/hooks/use-schema-renderer.d.ts +41 -9
  25. package/dist/shared/hooks/use-ui-container.d.ts +39 -0
  26. package/dist/shared/root.d.ts +1 -1
  27. package/dist/shared/types.d.ts +31 -6
  28. package/dist/shared-preact/hooks/index.d.ts +1 -0
  29. package/dist/shared-preact/hooks/use-schema-renderer.d.ts +41 -9
  30. package/dist/shared-preact/hooks/use-ui-container.d.ts +39 -0
  31. package/dist/shared-preact/root.d.ts +1 -1
  32. package/dist/shared-preact/types.d.ts +31 -6
  33. package/dist/shared-react/hooks/index.d.ts +1 -0
  34. package/dist/shared-react/hooks/use-schema-renderer.d.ts +41 -9
  35. package/dist/shared-react/hooks/use-ui-container.d.ts +39 -0
  36. package/dist/shared-react/root.d.ts +1 -1
  37. package/dist/shared-react/types.d.ts +31 -6
  38. package/dist/svelte/hooks/index.d.ts +1 -0
  39. package/dist/svelte/hooks/use-schema-renderer.svelte.d.ts +55 -12
  40. package/dist/svelte/hooks/use-ui-container.svelte.d.ts +41 -0
  41. package/dist/svelte/hooks/use-ui.svelte.d.ts +2 -2
  42. package/dist/svelte/index.cjs +1 -1
  43. package/dist/svelte/index.cjs.map +1 -1
  44. package/dist/svelte/index.js +112 -20
  45. package/dist/svelte/index.js.map +1 -1
  46. package/dist/svelte/types.d.ts +31 -6
  47. package/dist/vue/hooks/index.d.ts +1 -0
  48. package/dist/vue/hooks/use-schema-renderer.d.ts +41 -9
  49. package/dist/vue/hooks/use-ui-container.d.ts +39 -0
  50. package/dist/vue/hooks/use-ui.d.ts +148 -20
  51. package/dist/vue/index.cjs +1 -1
  52. package/dist/vue/index.cjs.map +1 -1
  53. package/dist/vue/index.js +126 -25
  54. package/dist/vue/index.js.map +1 -1
  55. package/dist/vue/types.d.ts +31 -6
  56. package/package.json +12 -12
package/dist/index.js CHANGED
@@ -9,13 +9,13 @@ const manifest = {
9
9
  // Depends on commands
10
10
  optional: ["i18n"],
11
11
  defaultConfig: {
12
- enabled: true,
13
12
  schema: {
14
13
  id: "empty",
15
14
  version: "1.0.0",
16
15
  toolbars: {},
17
16
  menus: {},
18
- panels: {},
17
+ sidebars: {},
18
+ modals: {},
19
19
  selectionMenus: {}
20
20
  }
21
21
  }
@@ -24,15 +24,17 @@ const INIT_UI_STATE = "UI/INIT_STATE";
24
24
  const CLEANUP_UI_STATE = "UI/CLEANUP_STATE";
25
25
  const SET_ACTIVE_TOOLBAR = "UI/SET_ACTIVE_TOOLBAR";
26
26
  const CLOSE_TOOLBAR_SLOT = "UI/CLOSE_TOOLBAR_SLOT";
27
- const SET_ACTIVE_PANEL = "UI/SET_ACTIVE_PANEL";
28
- const CLOSE_PANEL_SLOT = "UI/CLOSE_PANEL_SLOT";
29
- const SET_PANEL_TAB = "UI/SET_PANEL_TAB";
27
+ const SET_ACTIVE_SIDEBAR = "UI/SET_ACTIVE_SIDEBAR";
28
+ const CLOSE_SIDEBAR_SLOT = "UI/CLOSE_SIDEBAR_SLOT";
29
+ const SET_SIDEBAR_TAB = "UI/SET_SIDEBAR_TAB";
30
30
  const OPEN_MODAL = "UI/OPEN_MODAL";
31
31
  const CLOSE_MODAL = "UI/CLOSE_MODAL";
32
+ const CLEAR_MODAL = "UI/CLEAR_MODAL";
32
33
  const OPEN_MENU = "UI/OPEN_MENU";
33
34
  const CLOSE_MENU = "UI/CLOSE_MENU";
34
35
  const CLOSE_ALL_MENUS = "UI/CLOSE_ALL_MENUS";
35
36
  const SET_DISABLED_CATEGORIES = "UI/SET_DISABLED_CATEGORIES";
37
+ const SET_HIDDEN_ITEMS = "UI/SET_HIDDEN_ITEMS";
36
38
  const initUIState = (documentId, schema) => ({
37
39
  type: INIT_UI_STATE,
38
40
  payload: { documentId, schema }
@@ -49,17 +51,17 @@ const closeToolbarSlot = (documentId, placement, slot) => ({
49
51
  type: CLOSE_TOOLBAR_SLOT,
50
52
  payload: { documentId, placement, slot }
51
53
  });
52
- const setActivePanel = (documentId, placement, slot, panelId, activeTab) => ({
53
- type: SET_ACTIVE_PANEL,
54
- payload: { documentId, placement, slot, panelId, activeTab }
54
+ const setActiveSidebar = (documentId, placement, slot, sidebarId, activeTab) => ({
55
+ type: SET_ACTIVE_SIDEBAR,
56
+ payload: { documentId, placement, slot, sidebarId, activeTab }
55
57
  });
56
- const closePanelSlot = (documentId, placement, slot) => ({
57
- type: CLOSE_PANEL_SLOT,
58
+ const closeSidebarSlot = (documentId, placement, slot) => ({
59
+ type: CLOSE_SIDEBAR_SLOT,
58
60
  payload: { documentId, placement, slot }
59
61
  });
60
- const setPanelTab = (documentId, panelId, tabId) => ({
61
- type: SET_PANEL_TAB,
62
- payload: { documentId, panelId, tabId }
62
+ const setSidebarTab = (documentId, sidebarId, tabId) => ({
63
+ type: SET_SIDEBAR_TAB,
64
+ payload: { documentId, sidebarId, tabId }
63
65
  });
64
66
  const openModal = (documentId, modalId) => ({
65
67
  type: OPEN_MODAL,
@@ -69,6 +71,10 @@ const closeModal = (documentId) => ({
69
71
  type: CLOSE_MODAL,
70
72
  payload: { documentId }
71
73
  });
74
+ const clearModal = (documentId) => ({
75
+ type: CLEAR_MODAL,
76
+ payload: { documentId }
77
+ });
72
78
  const openMenu = (documentId, menuState) => ({
73
79
  type: OPEN_MENU,
74
80
  payload: { documentId, menuState }
@@ -85,13 +91,17 @@ const setDisabledCategories = (categories) => ({
85
91
  type: SET_DISABLED_CATEGORIES,
86
92
  payload: { categories }
87
93
  });
94
+ const setHiddenItems = (hiddenItems) => ({
95
+ type: SET_HIDDEN_ITEMS,
96
+ payload: { hiddenItems }
97
+ });
88
98
  function mergeUISchema(base, override) {
89
99
  return {
90
100
  ...base,
91
101
  ...override,
92
102
  toolbars: mergeToolbars(base.toolbars, override.toolbars),
93
103
  menus: mergeMenus(base.menus, override.menus),
94
- panels: mergePanels(base.panels, override.panels)
104
+ sidebars: mergeSidebars(base.sidebars, override.sidebars)
95
105
  };
96
106
  }
97
107
  function mergeToolbars(base, override) {
@@ -127,7 +137,7 @@ function mergeMenus(base, override) {
127
137
  }
128
138
  return result;
129
139
  }
130
- function mergePanels(base, override) {
140
+ function mergeSidebars(base, override) {
131
141
  if (!override) return base;
132
142
  const result = { ...base };
133
143
  for (const [id, panel] of Object.entries(override)) {
@@ -153,9 +163,9 @@ function removeFromSchema(schema, options) {
153
163
  result.menus = { ...result.menus };
154
164
  options.menus.forEach((id) => delete result.menus[id]);
155
165
  }
156
- if (options.panels) {
157
- result.panels = { ...result.panels };
158
- options.panels.forEach((id) => delete result.panels[id]);
166
+ if (options.sidebars) {
167
+ result.sidebars = { ...result.sidebars };
168
+ options.sidebars.forEach((id) => delete result.sidebars[id]);
159
169
  }
160
170
  if (options.commands) {
161
171
  result.toolbars = removeCommandsFromToolbars(result.toolbars, options.commands);
@@ -321,14 +331,17 @@ const UI_ATTRIBUTES = {
321
331
  /** Item categories for category-based hiding */
322
332
  CATEGORIES: "data-epdf-cat",
323
333
  /** Disabled categories list on root element */
324
- DISABLED_CATEGORIES: "data-epdf-dis"
334
+ DISABLED_CATEGORIES: "data-epdf-dis",
335
+ /** Hidden item IDs (computed from disabled categories) */
336
+ HIDDEN_ITEMS: "data-epdf-hid"
325
337
  };
326
338
  const UI_SELECTORS = {
327
339
  ROOT: `[${UI_ATTRIBUTES.ROOT}]`,
328
340
  STYLES: `[${UI_ATTRIBUTES.STYLES}]`,
329
341
  ITEM: (id) => `[${UI_ATTRIBUTES.ITEM}="${id}"]`,
330
342
  CATEGORIES: (category) => `[${UI_ATTRIBUTES.CATEGORIES}~="${category}"]`,
331
- DISABLED_CATEGORY: (category) => `[${UI_ATTRIBUTES.DISABLED_CATEGORIES}~="${category}"]`
343
+ DISABLED_CATEGORY: (category) => `[${UI_ATTRIBUTES.DISABLED_CATEGORIES}~="${category}"]`,
344
+ HIDDEN_ITEM: (itemId) => `[${UI_ATTRIBUTES.HIDDEN_ITEMS}~="${itemId}"]`
332
345
  };
333
346
  const DEFAULT_CONFIG = {
334
347
  useContainerQueries: true
@@ -351,6 +364,20 @@ function extractCategories(schema) {
351
364
  const analysis = analyzeSchema(schema);
352
365
  return Array.from(analysis.categories).sort();
353
366
  }
367
+ function extractItemCategories(schema) {
368
+ const analysis = analyzeSchema(schema);
369
+ return analysis.itemCategories;
370
+ }
371
+ function computeHiddenItems(itemCategories, disabledCategories) {
372
+ const disabledSet = new Set(disabledCategories);
373
+ const hiddenItems = [];
374
+ itemCategories.forEach((categories, itemId) => {
375
+ if (categories.some((cat) => disabledSet.has(cat))) {
376
+ hiddenItems.push(itemId);
377
+ }
378
+ });
379
+ return hiddenItems;
380
+ }
354
381
  function getStylesheetConfig(config = {}) {
355
382
  return { ...DEFAULT_CONFIG, ...config };
356
383
  }
@@ -383,7 +410,7 @@ function analyzeSchema(schema, locale) {
383
410
  locale
384
411
  );
385
412
  }
386
- for (const [panelId, panel] of Object.entries(schema.panels)) {
413
+ for (const [panelId, panel] of Object.entries(schema.sidebars)) {
387
414
  analyzePanel(panelId, panel, categories, itemCategories, dependencies);
388
415
  }
389
416
  for (const [selMenuId, selMenu] of Object.entries(schema.selectionMenus || {})) {
@@ -451,22 +478,25 @@ function computeMenuBreakpointVisibilities(menu, itemCategories, locale) {
451
478
  breakpointVisibilities.push({
452
479
  minWidth: bp.minWidth,
453
480
  maxWidth: bp.maxWidth,
481
+ visibleItemIds: visibleItems,
454
482
  visibleCategories: visibleCats
455
483
  });
456
484
  }
457
485
  } else {
486
+ const allItemIds = [];
458
487
  const allCats = /* @__PURE__ */ new Set();
459
- collectAllMenuItemCategories(menu.items, itemCategories, allCats);
460
- breakpointVisibilities.push({ visibleCategories: allCats });
488
+ collectAllMenuItemInfo(menu.items, itemCategories, allItemIds, allCats);
489
+ breakpointVisibilities.push({ visibleItemIds: allItemIds, visibleCategories: allCats });
461
490
  }
462
491
  return breakpointVisibilities;
463
492
  }
464
- function collectAllMenuItemCategories(items, itemCategories, result) {
493
+ function collectAllMenuItemInfo(items, itemCategories, resultIds, resultCats) {
465
494
  for (const item of items) {
495
+ resultIds.push(item.id);
466
496
  const cats = itemCategories.get(item.id);
467
- if (cats) cats.forEach((c) => result.add(c));
497
+ if (cats) cats.forEach((c) => resultCats.add(c));
468
498
  if (item.type === "section") {
469
- collectAllMenuItemCategories(item.items, itemCategories, result);
499
+ collectAllMenuItemInfo(item.items, itemCategories, resultIds, resultCats);
470
500
  }
471
501
  }
472
502
  }
@@ -691,9 +721,9 @@ function generateSingleDependencyRules(dep, analysis, queryType, cfg) {
691
721
  if (breakpoints && breakpoints.length > 0) {
692
722
  rules.push(`/* "${dep.itemId}" depends on menu "${dep.dependsOnMenuId}" */`);
693
723
  for (const bp of breakpoints) {
694
- if (bp.visibleCategories.size === 0) continue;
695
- const categorySelectors = Array.from(bp.visibleCategories).sort().map((cat) => UI_SELECTORS.DISABLED_CATEGORY(cat)).join("");
696
- const cssRule = `${UI_SELECTORS.ROOT}${categorySelectors} ${UI_SELECTORS.ITEM(dep.itemId)} {
724
+ if (bp.visibleItemIds.length === 0) continue;
725
+ const hiddenItemSelectors = bp.visibleItemIds.sort().map((id) => UI_SELECTORS.HIDDEN_ITEM(id)).join("");
726
+ const cssRule = `${UI_SELECTORS.ROOT}${hiddenItemSelectors} ${UI_SELECTORS.ITEM(dep.itemId)} {
697
727
  display: none !important;
698
728
  }`;
699
729
  const conditions = [];
@@ -710,18 +740,11 @@ function generateSingleDependencyRules(dep, analysis, queryType, cfg) {
710
740
  }
711
741
  }
712
742
  if ((_a = dep.dependsOnItemIds) == null ? void 0 : _a.length) {
713
- const relevantCategories = /* @__PURE__ */ new Set();
714
- for (const itemId of dep.dependsOnItemIds) {
715
- const cats = analysis.itemCategories.get(itemId);
716
- if (cats) cats.forEach((c) => relevantCategories.add(c));
717
- }
718
- if (relevantCategories.size > 0) {
719
- const categorySelectors = Array.from(relevantCategories).sort().map((cat) => UI_SELECTORS.DISABLED_CATEGORY(cat)).join("");
720
- rules.push(`/* "${dep.itemId}" depends on items: ${dep.dependsOnItemIds.join(", ")} */
721
- ${UI_SELECTORS.ROOT}${categorySelectors} ${UI_SELECTORS.ITEM(dep.itemId)} {
743
+ rules.push(`/* "${dep.itemId}" depends on items: ${dep.dependsOnItemIds.join(", ")} */`);
744
+ const hiddenItemSelectors = dep.dependsOnItemIds.sort().map((id) => UI_SELECTORS.HIDDEN_ITEM(id)).join("");
745
+ rules.push(`${UI_SELECTORS.ROOT}${hiddenItemSelectors} ${UI_SELECTORS.ITEM(dep.itemId)} {
722
746
  display: none !important;
723
747
  }`);
724
- }
725
748
  }
726
749
  return rules;
727
750
  }
@@ -745,10 +768,7 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
745
768
  this.categoryChanged$ = createBehaviorEmitter();
746
769
  this.stylesheetInvalidated$ = createEmitter();
747
770
  this.toolbarChanged$ = createScopedEmitter((documentId, data) => ({ documentId, ...data }), { cache: false });
748
- this.panelChanged$ = createScopedEmitter(
749
- (documentId, data) => ({ documentId, ...data }),
750
- { cache: false }
751
- );
771
+ this.sidebarChanged$ = createScopedEmitter((documentId, data) => ({ documentId, ...data }), { cache: false });
752
772
  this.modalChanged$ = createScopedEmitter(
753
773
  (documentId, data) => ({ documentId, ...data }),
754
774
  { cache: false }
@@ -759,8 +779,11 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
759
779
  );
760
780
  this.schema = config.schema;
761
781
  this.stylesheetConfig = config.stylesheetConfig || {};
782
+ this.itemCategories = extractItemCategories(this.schema);
762
783
  if ((_a = config.disabledCategories) == null ? void 0 : _a.length) {
763
784
  this.dispatch(setDisabledCategories(config.disabledCategories));
785
+ const hiddenItems = computeHiddenItems(this.itemCategories, config.disabledCategories);
786
+ this.dispatch(setHiddenItems(hiddenItems));
764
787
  }
765
788
  this.i18n = ((_b = registry.getPlugin("i18n")) == null ? void 0 : _b.provides()) ?? null;
766
789
  if (this.i18n) {
@@ -779,7 +802,7 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
779
802
  this.i18nCleanup = null;
780
803
  }
781
804
  this.toolbarChanged$.clear();
782
- this.panelChanged$.clear();
805
+ this.sidebarChanged$.clear();
783
806
  this.modalChanged$.clear();
784
807
  this.menuChanged$.clear();
785
808
  this.stylesheetInvalidated$.clear();
@@ -791,7 +814,7 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
791
814
  onDocumentClosed(documentId) {
792
815
  this.dispatch(cleanupUIState(documentId));
793
816
  this.toolbarChanged$.clearScope(documentId);
794
- this.panelChanged$.clearScope(documentId);
817
+ this.sidebarChanged$.clearScope(documentId);
795
818
  this.modalChanged$.clearScope(documentId);
796
819
  this.menuChanged$.clearScope(documentId);
797
820
  }
@@ -851,16 +874,22 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
851
874
  const current = new Set(this.state.disabledCategories);
852
875
  if (!current.has(category)) {
853
876
  current.add(category);
854
- this.dispatch(setDisabledCategories(Array.from(current)));
855
- this.categoryChanged$.emit({ disabledCategories: Array.from(current) });
877
+ const categories = Array.from(current);
878
+ this.dispatch(setDisabledCategories(categories));
879
+ const hiddenItems = computeHiddenItems(this.itemCategories, categories);
880
+ this.dispatch(setHiddenItems(hiddenItems));
881
+ this.categoryChanged$.emit({ disabledCategories: categories, hiddenItems });
856
882
  }
857
883
  }
858
884
  enableCategoryImpl(category) {
859
885
  const current = new Set(this.state.disabledCategories);
860
886
  if (current.has(category)) {
861
887
  current.delete(category);
862
- this.dispatch(setDisabledCategories(Array.from(current)));
863
- this.categoryChanged$.emit({ disabledCategories: Array.from(current) });
888
+ const categories = Array.from(current);
889
+ this.dispatch(setDisabledCategories(categories));
890
+ const hiddenItems = computeHiddenItems(this.itemCategories, categories);
891
+ this.dispatch(setHiddenItems(hiddenItems));
892
+ this.categoryChanged$.emit({ disabledCategories: categories, hiddenItems });
864
893
  }
865
894
  }
866
895
  toggleCategoryImpl(category) {
@@ -872,7 +901,9 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
872
901
  }
873
902
  setDisabledCategoriesImpl(categories) {
874
903
  this.dispatch(setDisabledCategories(categories));
875
- this.categoryChanged$.emit({ disabledCategories: categories });
904
+ const hiddenItems = computeHiddenItems(this.itemCategories, categories);
905
+ this.dispatch(setHiddenItems(hiddenItems));
906
+ this.categoryChanged$.emit({ disabledCategories: categories, hiddenItems });
876
907
  }
877
908
  // ─────────────────────────────────────────────────────────
878
909
  // Capability
@@ -881,8 +912,8 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
881
912
  return {
882
913
  // Active document operations
883
914
  setActiveToolbar: (placement, slot, toolbarId, documentId) => this.setToolbarForDocument(placement, slot, toolbarId, documentId),
884
- setActivePanel: (placement, slot, panelId, documentId, activeTab) => this.setPanelForDocument(placement, slot, panelId, documentId, activeTab),
885
- togglePanel: (placement, slot, panelId, documentId, activeTab) => this.togglePanelForDocument(placement, slot, panelId, documentId, activeTab),
915
+ setActiveSidebar: (placement, slot, sidebarId, documentId, activeTab) => this.setSidebarForDocument(placement, slot, sidebarId, documentId, activeTab),
916
+ toggleSidebar: (placement, slot, sidebarId, documentId, activeTab) => this.toggleSidebarForDocument(placement, slot, sidebarId, documentId, activeTab),
886
917
  openModal: (modalId, documentId) => this.openModalForDocument(modalId, documentId),
887
918
  openMenu: (menuId, triggeredByCommandId, triggeredByItemId, documentId) => this.openMenuForDocument(menuId, triggeredByCommandId, triggeredByItemId, documentId),
888
919
  toggleMenu: (menuId, triggeredByCommandId, triggeredByItemId, documentId) => this.toggleMenuForDocument(menuId, triggeredByCommandId, triggeredByItemId, documentId),
@@ -900,9 +931,10 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
900
931
  setDisabledCategories: (categories) => this.setDisabledCategoriesImpl(categories),
901
932
  getDisabledCategories: () => this.state.disabledCategories,
902
933
  isCategoryDisabled: (category) => this.state.disabledCategories.includes(category),
934
+ getHiddenItems: () => this.state.hiddenItems,
903
935
  // Events
904
936
  onToolbarChanged: this.toolbarChanged$.onGlobal,
905
- onPanelChanged: this.panelChanged$.onGlobal,
937
+ onSidebarChanged: this.sidebarChanged$.onGlobal,
906
938
  onModalChanged: this.modalChanged$.onGlobal,
907
939
  onMenuChanged: this.menuChanged$.onGlobal,
908
940
  onCategoryChanged: this.categoryChanged$.on
@@ -918,19 +950,21 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
918
950
  getActiveToolbar: (placement, slot) => this.getToolbarForDocument(placement, slot, documentId),
919
951
  closeToolbarSlot: (placement, slot) => this.closeToolbarForDocument(placement, slot, documentId),
920
952
  isToolbarOpen: (placement, slot, toolbarId) => this.isToolbarOpenForDocument(placement, slot, toolbarId, documentId),
921
- // ───── Panels ─────
922
- setActivePanel: (placement, slot, panelId, activeTab) => this.setPanelForDocument(placement, slot, panelId, documentId, activeTab),
923
- getActivePanel: (placement, slot) => this.getPanelForDocument(placement, slot, documentId),
924
- closePanelSlot: (placement, slot) => this.closePanelForDocument(placement, slot, documentId),
925
- togglePanel: (placement, slot, panelId, activeTab) => this.togglePanelForDocument(placement, slot, panelId, documentId, activeTab),
926
- isPanelOpen: (placement, slot, panelId) => this.isPanelOpenForDocument(placement, slot, panelId, documentId),
927
- // ───── Panel tabs ─────
928
- setPanelTab: (panelId, tabId) => this.setPanelTabForDocument(panelId, tabId, documentId),
929
- getPanelTab: (panelId) => this.getPanelTabForDocument(panelId, documentId),
930
- // ───── Modals ─────
953
+ // ───── Sidebars ─────
954
+ setActiveSidebar: (placement, slot, sidebarId, activeTab) => this.setSidebarForDocument(placement, slot, sidebarId, documentId, activeTab),
955
+ getActiveSidebar: (placement, slot) => this.getSidebarForDocument(placement, slot, documentId),
956
+ closeSidebarSlot: (placement, slot) => this.closeSidebarForDocument(placement, slot, documentId),
957
+ toggleSidebar: (placement, slot, sidebarId, activeTab) => this.toggleSidebarForDocument(placement, slot, sidebarId, documentId, activeTab),
958
+ isSidebarOpen: (placement, slot, sidebarId) => this.isSidebarOpenForDocument(placement, slot, sidebarId, documentId),
959
+ // ───── Sidebar tabs ─────
960
+ setSidebarTab: (sidebarId, tabId) => this.setSidebarTabForDocument(sidebarId, tabId, documentId),
961
+ getSidebarTab: (sidebarId) => this.getSidebarTabForDocument(sidebarId, documentId),
962
+ // ───── Modals (with animation lifecycle) ─────
931
963
  openModal: (modalId) => this.openModalForDocument(modalId, documentId),
932
964
  closeModal: () => this.closeModalForDocument(documentId),
965
+ clearModal: () => this.clearModalForDocument(documentId),
933
966
  getActiveModal: () => this.getActiveModalForDocument(documentId),
967
+ isModalOpen: () => this.isModalOpenForDocument(documentId),
934
968
  // ───── Menus ─────
935
969
  openMenu: (menuId, triggeredByCommandId, triggeredByItemId) => this.openMenuForDocument(menuId, triggeredByCommandId, triggeredByItemId, documentId),
936
970
  closeMenu: (menuId) => this.closeMenuForDocument(menuId, documentId),
@@ -943,7 +977,7 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
943
977
  getState: () => this.getDocumentStateOrThrow(documentId),
944
978
  // ───── Scoped events ─────
945
979
  onToolbarChanged: this.toolbarChanged$.forScope(documentId),
946
- onPanelChanged: this.panelChanged$.forScope(documentId),
980
+ onSidebarChanged: this.sidebarChanged$.forScope(documentId),
947
981
  onModalChanged: this.modalChanged$.forScope(documentId),
948
982
  onMenuChanged: this.menuChanged$.forScope(documentId)
949
983
  };
@@ -987,67 +1021,76 @@ const _UIPlugin = class _UIPlugin extends BasePlugin {
987
1021
  return toolbarId ? toolbarSlot.toolbarId === toolbarId : true;
988
1022
  }
989
1023
  // ─────────────────────────────────────────────────────────
990
- // Core Operations - Panels
1024
+ // Core Operations - Sidebars
991
1025
  // ─────────────────────────────────────────────────────────
992
- setPanelForDocument(placement, slot, panelId, documentId, activeTab) {
1026
+ setSidebarForDocument(placement, slot, sidebarId, documentId, activeTab) {
993
1027
  const id = documentId ?? this.getActiveDocumentId();
994
- this.dispatch(setActivePanel(id, placement, slot, panelId, activeTab));
995
- this.panelChanged$.emit(id, { placement, slot, panelId });
1028
+ this.dispatch(setActiveSidebar(id, placement, slot, sidebarId, activeTab));
1029
+ this.sidebarChanged$.emit(id, { placement, slot, sidebarId });
996
1030
  }
997
- getPanelForDocument(placement, slot, documentId) {
1031
+ getSidebarForDocument(placement, slot, documentId) {
998
1032
  const slotKey = `${placement}-${slot}`;
999
- const panelSlot = this.getDocumentStateOrThrow(documentId).activePanels[slotKey];
1000
- return (panelSlot == null ? void 0 : panelSlot.isOpen) ? panelSlot.panelId : null;
1033
+ const sidebarSlot = this.getDocumentStateOrThrow(documentId).activeSidebars[slotKey];
1034
+ return (sidebarSlot == null ? void 0 : sidebarSlot.isOpen) ? sidebarSlot.sidebarId : null;
1001
1035
  }
1002
- closePanelForDocument(placement, slot, documentId) {
1036
+ closeSidebarForDocument(placement, slot, documentId) {
1003
1037
  const id = documentId ?? this.getActiveDocumentId();
1004
- this.dispatch(closePanelSlot(id, placement, slot));
1005
- this.panelChanged$.emit(id, { placement, slot, panelId: "" });
1038
+ this.dispatch(closeSidebarSlot(id, placement, slot));
1039
+ this.sidebarChanged$.emit(id, { placement, slot, sidebarId: "" });
1006
1040
  }
1007
- togglePanelForDocument(placement, slot, panelId, documentId, activeTab) {
1041
+ toggleSidebarForDocument(placement, slot, sidebarId, documentId, activeTab) {
1008
1042
  const id = documentId ?? this.getActiveDocumentId();
1009
1043
  const slotKey = `${placement}-${slot}`;
1010
- const panelSlot = this.getDocumentStateOrThrow(id).activePanels[slotKey];
1011
- if ((panelSlot == null ? void 0 : panelSlot.panelId) === panelId && (panelSlot == null ? void 0 : panelSlot.isOpen)) {
1012
- this.dispatch(closePanelSlot(id, placement, slot));
1013
- this.panelChanged$.emit(id, { placement, slot, panelId: "" });
1044
+ const sidebarSlot = this.getDocumentStateOrThrow(id).activeSidebars[slotKey];
1045
+ if ((sidebarSlot == null ? void 0 : sidebarSlot.sidebarId) === sidebarId && (sidebarSlot == null ? void 0 : sidebarSlot.isOpen)) {
1046
+ this.dispatch(closeSidebarSlot(id, placement, slot));
1047
+ this.sidebarChanged$.emit(id, { placement, slot, sidebarId: "" });
1014
1048
  } else {
1015
- this.dispatch(setActivePanel(id, placement, slot, panelId, activeTab));
1016
- this.panelChanged$.emit(id, { placement, slot, panelId });
1049
+ this.dispatch(setActiveSidebar(id, placement, slot, sidebarId, activeTab));
1050
+ this.sidebarChanged$.emit(id, { placement, slot, sidebarId });
1017
1051
  }
1018
1052
  }
1019
- isPanelOpenForDocument(placement, slot, panelId, documentId) {
1053
+ isSidebarOpenForDocument(placement, slot, sidebarId, documentId) {
1020
1054
  const slotKey = `${placement}-${slot}`;
1021
- const panelSlot = this.getDocumentStateOrThrow(documentId).activePanels[slotKey];
1022
- if (!panelSlot || !panelSlot.isOpen) return false;
1023
- return panelId ? panelSlot.panelId === panelId : true;
1055
+ const sidebarSlot = this.getDocumentStateOrThrow(documentId).activeSidebars[slotKey];
1056
+ if (!sidebarSlot || !sidebarSlot.isOpen) return false;
1057
+ return sidebarId ? sidebarSlot.sidebarId === sidebarId : true;
1024
1058
  }
1025
1059
  // ─────────────────────────────────────────────────────────
1026
- // Core Operations - Panel Tabs
1060
+ // Core Operations - Sidebar Tabs
1027
1061
  // ─────────────────────────────────────────────────────────
1028
- setPanelTabForDocument(panelId, tabId, documentId) {
1062
+ setSidebarTabForDocument(sidebarId, tabId, documentId) {
1029
1063
  const id = documentId ?? this.getActiveDocumentId();
1030
- this.dispatch(setPanelTab(id, panelId, tabId));
1064
+ this.dispatch(setSidebarTab(id, sidebarId, tabId));
1031
1065
  }
1032
- getPanelTabForDocument(panelId, documentId) {
1033
- return this.getDocumentStateOrThrow(documentId).panelTabs[panelId] ?? null;
1066
+ getSidebarTabForDocument(sidebarId, documentId) {
1067
+ return this.getDocumentStateOrThrow(documentId).sidebarTabs[sidebarId] ?? null;
1034
1068
  }
1035
1069
  // ─────────────────────────────────────────────────────────
1036
- // Core Operations - Modals
1070
+ // Core Operations - Modals (with animation lifecycle)
1037
1071
  // ─────────────────────────────────────────────────────────
1038
1072
  openModalForDocument(modalId, documentId) {
1039
1073
  const id = documentId ?? this.getActiveDocumentId();
1040
1074
  this.dispatch(openModal(id, modalId));
1041
- this.modalChanged$.emit(id, { modalId });
1075
+ this.modalChanged$.emit(id, { modalId, isOpen: true });
1042
1076
  }
1043
1077
  closeModalForDocument(documentId) {
1044
1078
  const id = documentId ?? this.getActiveDocumentId();
1079
+ const currentModal = this.getDocumentStateOrThrow(id).activeModal;
1045
1080
  this.dispatch(closeModal(id));
1046
- this.modalChanged$.emit(id, { modalId: null });
1081
+ this.modalChanged$.emit(id, { modalId: (currentModal == null ? void 0 : currentModal.modalId) ?? null, isOpen: false });
1082
+ }
1083
+ clearModalForDocument(documentId) {
1084
+ const id = documentId ?? this.getActiveDocumentId();
1085
+ this.dispatch(clearModal(id));
1047
1086
  }
1048
1087
  getActiveModalForDocument(documentId) {
1049
1088
  return this.getDocumentStateOrThrow(documentId).activeModal;
1050
1089
  }
1090
+ isModalOpenForDocument(documentId) {
1091
+ const modal = this.getDocumentStateOrThrow(documentId).activeModal;
1092
+ return (modal == null ? void 0 : modal.isOpen) ?? false;
1093
+ }
1051
1094
  // ─────────────────────────────────────────────────────────
1052
1095
  // Core Operations - Menus
1053
1096
  // ─────────────────────────────────────────────────────────
@@ -1087,16 +1130,18 @@ _UIPlugin.id = "ui";
1087
1130
  let UIPlugin = _UIPlugin;
1088
1131
  const initialDocumentState = {
1089
1132
  activeToolbars: {},
1090
- activePanels: {},
1133
+ activeSidebars: {},
1091
1134
  activeModal: null,
1092
1135
  openMenus: {},
1093
- panelTabs: {}
1136
+ sidebarTabs: {}
1094
1137
  };
1095
1138
  const initialState = {
1096
1139
  documents: {},
1097
- disabledCategories: []
1140
+ disabledCategories: [],
1141
+ hiddenItems: []
1098
1142
  };
1099
1143
  const uiReducer = (state = initialState, action) => {
1144
+ var _a;
1100
1145
  switch (action.type) {
1101
1146
  case INIT_UI_STATE: {
1102
1147
  const { documentId, schema } = action.payload;
@@ -1152,85 +1197,88 @@ const uiReducer = (state = initialState, action) => {
1152
1197
  }
1153
1198
  };
1154
1199
  }
1155
- case SET_ACTIVE_PANEL: {
1156
- const { documentId, placement, slot, panelId, activeTab } = action.payload;
1157
- const docState = state.documents[documentId] || initialDocumentState;
1200
+ case CLOSE_TOOLBAR_SLOT: {
1201
+ const { documentId, placement, slot } = action.payload;
1202
+ const docState = state.documents[documentId];
1203
+ if (!docState) return state;
1158
1204
  const slotKey = `${placement}-${slot}`;
1205
+ const toolbarSlot = docState.activeToolbars[slotKey];
1206
+ if (!toolbarSlot) return state;
1159
1207
  return {
1160
1208
  ...state,
1161
1209
  documents: {
1162
1210
  ...state.documents,
1163
1211
  [documentId]: {
1164
1212
  ...docState,
1165
- activePanels: {
1166
- ...docState.activePanels,
1213
+ activeToolbars: {
1214
+ ...docState.activeToolbars,
1167
1215
  [slotKey]: {
1168
- panelId,
1169
- isOpen: true
1170
- }
1171
- },
1172
- ...activeTab && {
1173
- panelTabs: {
1174
- ...docState.panelTabs,
1175
- [panelId]: activeTab
1216
+ ...toolbarSlot,
1217
+ isOpen: false
1218
+ // Keep toolbar, just close it
1176
1219
  }
1177
1220
  }
1178
1221
  }
1179
1222
  }
1180
1223
  };
1181
1224
  }
1182
- case CLOSE_PANEL_SLOT: {
1183
- const { documentId, placement, slot } = action.payload;
1184
- const docState = state.documents[documentId];
1185
- if (!docState) return state;
1225
+ // ─────────────────────────────────────────────────────────
1226
+ // Sidebar Actions
1227
+ // ─────────────────────────────────────────────────────────
1228
+ case SET_ACTIVE_SIDEBAR: {
1229
+ const { documentId, placement, slot, sidebarId, activeTab } = action.payload;
1230
+ const docState = state.documents[documentId] || initialDocumentState;
1186
1231
  const slotKey = `${placement}-${slot}`;
1187
- const panelSlot = docState.activePanels[slotKey];
1188
- if (!panelSlot) return state;
1189
1232
  return {
1190
1233
  ...state,
1191
1234
  documents: {
1192
1235
  ...state.documents,
1193
1236
  [documentId]: {
1194
1237
  ...docState,
1195
- activePanels: {
1196
- ...docState.activePanels,
1238
+ activeSidebars: {
1239
+ ...docState.activeSidebars,
1197
1240
  [slotKey]: {
1198
- ...panelSlot,
1199
- isOpen: false
1200
- // Keep panel, just close it
1241
+ sidebarId,
1242
+ isOpen: true
1243
+ }
1244
+ },
1245
+ ...activeTab && {
1246
+ sidebarTabs: {
1247
+ ...docState.sidebarTabs,
1248
+ [sidebarId]: activeTab
1201
1249
  }
1202
1250
  }
1203
1251
  }
1204
1252
  }
1205
1253
  };
1206
1254
  }
1207
- case CLOSE_TOOLBAR_SLOT: {
1255
+ case CLOSE_SIDEBAR_SLOT: {
1208
1256
  const { documentId, placement, slot } = action.payload;
1209
1257
  const docState = state.documents[documentId];
1210
1258
  if (!docState) return state;
1211
1259
  const slotKey = `${placement}-${slot}`;
1212
- const toolbarSlot = docState.activeToolbars[slotKey];
1213
- if (!toolbarSlot) return state;
1260
+ const sidebarSlot = docState.activeSidebars[slotKey];
1261
+ if (!sidebarSlot) return state;
1214
1262
  return {
1215
1263
  ...state,
1216
1264
  documents: {
1217
1265
  ...state.documents,
1218
1266
  [documentId]: {
1219
1267
  ...docState,
1220
- activeToolbars: {
1221
- ...docState.activeToolbars,
1268
+ activeSidebars: {
1269
+ ...docState.activeSidebars,
1222
1270
  [slotKey]: {
1223
- ...toolbarSlot,
1271
+ ...sidebarSlot,
1224
1272
  isOpen: false
1225
- // Keep toolbar, just close it
1273
+ // Keep sidebar, just close it
1226
1274
  }
1227
1275
  }
1228
1276
  }
1229
1277
  }
1230
1278
  };
1231
1279
  }
1232
- case SET_PANEL_TAB: {
1233
- const { documentId, panelId, tabId } = action.payload;
1280
+ case SET_SIDEBAR_TAB: {
1281
+ const { documentId, sidebarId, tabId } = action.payload;
1234
1282
  const docState = state.documents[documentId] || initialDocumentState;
1235
1283
  return {
1236
1284
  ...state,
@@ -1238,14 +1286,17 @@ const uiReducer = (state = initialState, action) => {
1238
1286
  ...state.documents,
1239
1287
  [documentId]: {
1240
1288
  ...docState,
1241
- panelTabs: {
1242
- ...docState.panelTabs,
1243
- [panelId]: tabId
1289
+ sidebarTabs: {
1290
+ ...docState.sidebarTabs,
1291
+ [sidebarId]: tabId
1244
1292
  }
1245
1293
  }
1246
1294
  }
1247
1295
  };
1248
1296
  }
1297
+ // ─────────────────────────────────────────────────────────
1298
+ // Modal Actions (with animation lifecycle)
1299
+ // ─────────────────────────────────────────────────────────
1249
1300
  case OPEN_MODAL: {
1250
1301
  const { documentId, modalId } = action.payload;
1251
1302
  const docState = state.documents[documentId] || initialDocumentState;
@@ -1255,7 +1306,10 @@ const uiReducer = (state = initialState, action) => {
1255
1306
  ...state.documents,
1256
1307
  [documentId]: {
1257
1308
  ...docState,
1258
- activeModal: modalId,
1309
+ activeModal: {
1310
+ modalId,
1311
+ isOpen: true
1312
+ },
1259
1313
  openMenus: {}
1260
1314
  // Close all menus when opening modal
1261
1315
  }
@@ -1263,9 +1317,29 @@ const uiReducer = (state = initialState, action) => {
1263
1317
  };
1264
1318
  }
1265
1319
  case CLOSE_MODAL: {
1320
+ const { documentId } = action.payload;
1321
+ const docState = state.documents[documentId];
1322
+ if (!(docState == null ? void 0 : docState.activeModal)) return state;
1323
+ return {
1324
+ ...state,
1325
+ documents: {
1326
+ ...state.documents,
1327
+ [documentId]: {
1328
+ ...docState,
1329
+ activeModal: {
1330
+ ...docState.activeModal,
1331
+ isOpen: false
1332
+ // Keep modal for exit animation
1333
+ }
1334
+ }
1335
+ }
1336
+ };
1337
+ }
1338
+ case CLEAR_MODAL: {
1266
1339
  const { documentId } = action.payload;
1267
1340
  const docState = state.documents[documentId];
1268
1341
  if (!docState) return state;
1342
+ if ((_a = docState.activeModal) == null ? void 0 : _a.isOpen) return state;
1269
1343
  return {
1270
1344
  ...state,
1271
1345
  documents: {
@@ -1277,6 +1351,9 @@ const uiReducer = (state = initialState, action) => {
1277
1351
  }
1278
1352
  };
1279
1353
  }
1354
+ // ─────────────────────────────────────────────────────────
1355
+ // Menu Actions
1356
+ // ─────────────────────────────────────────────────────────
1280
1357
  case OPEN_MENU: {
1281
1358
  const { documentId, menuState } = action.payload;
1282
1359
  const docState = state.documents[documentId] || initialDocumentState;
@@ -1331,6 +1408,12 @@ const uiReducer = (state = initialState, action) => {
1331
1408
  disabledCategories: action.payload.categories
1332
1409
  };
1333
1410
  }
1411
+ case SET_HIDDEN_ITEMS: {
1412
+ return {
1413
+ ...state,
1414
+ hiddenItems: action.payload.hiddenItems
1415
+ };
1416
+ }
1334
1417
  default:
1335
1418
  return state;
1336
1419
  }
@@ -1355,15 +1438,15 @@ function isToolbarOpen(plugins, documentId, placement, slot, toolbarId) {
1355
1438
  if (!slotState || !slotState.isOpen) return false;
1356
1439
  return toolbarId ? slotState.toolbarId === toolbarId : true;
1357
1440
  }
1358
- function selectPanelSlot(plugins, documentId, placement, slot) {
1441
+ function selectSidebarSlot(plugins, documentId, placement, slot) {
1359
1442
  const doc = selectUIDocumentState(plugins, documentId);
1360
1443
  if (!doc) return null;
1361
- return doc.activePanels[makeSlotKey(placement, slot)] ?? null;
1444
+ return doc.activeSidebars[makeSlotKey(placement, slot)] ?? null;
1362
1445
  }
1363
- function isPanelOpen(plugins, documentId, placement, slot, panelId) {
1364
- const slotState = selectPanelSlot(plugins, documentId, placement, slot);
1446
+ function isSidebarOpen(plugins, documentId, placement, slot, sidebarId) {
1447
+ const slotState = selectSidebarSlot(plugins, documentId, placement, slot);
1365
1448
  if (!slotState || !slotState.isOpen) return false;
1366
- return panelId ? slotState.panelId === panelId : true;
1449
+ return sidebarId ? slotState.sidebarId === sidebarId : true;
1367
1450
  }
1368
1451
  const UIPluginPackage = {
1369
1452
  manifest,
@@ -1373,36 +1456,41 @@ const UIPluginPackage = {
1373
1456
  };
1374
1457
  export {
1375
1458
  CLEANUP_UI_STATE,
1459
+ CLEAR_MODAL,
1376
1460
  CLOSE_ALL_MENUS,
1377
1461
  CLOSE_MENU,
1378
1462
  CLOSE_MODAL,
1379
- CLOSE_PANEL_SLOT,
1463
+ CLOSE_SIDEBAR_SLOT,
1380
1464
  CLOSE_TOOLBAR_SLOT,
1381
1465
  INIT_UI_STATE,
1382
1466
  OPEN_MENU,
1383
1467
  OPEN_MODAL,
1384
- SET_ACTIVE_PANEL,
1468
+ SET_ACTIVE_SIDEBAR,
1385
1469
  SET_ACTIVE_TOOLBAR,
1386
1470
  SET_DISABLED_CATEGORIES,
1387
- SET_PANEL_TAB,
1471
+ SET_HIDDEN_ITEMS,
1472
+ SET_SIDEBAR_TAB,
1388
1473
  UIPlugin,
1389
1474
  UIPluginPackage,
1390
1475
  UI_ATTRIBUTES,
1391
1476
  UI_PLUGIN_ID,
1392
1477
  UI_SELECTORS,
1393
1478
  cleanupUIState,
1479
+ clearModal,
1394
1480
  closeAllMenus,
1395
1481
  closeMenu,
1396
1482
  closeModal,
1397
- closePanelSlot,
1483
+ closeSidebarSlot,
1398
1484
  closeToolbarSlot,
1485
+ computeHiddenItems,
1399
1486
  extractCategories,
1487
+ extractItemCategories,
1400
1488
  generateUIStylesheet,
1401
1489
  getItemResponsiveMetadata,
1402
1490
  getStylesheetConfig,
1403
1491
  getUIItemProps,
1404
1492
  initUIState,
1405
- isPanelOpen,
1493
+ isSidebarOpen,
1406
1494
  isToolbarOpen,
1407
1495
  manifest,
1408
1496
  mergeUISchema,
@@ -1410,13 +1498,14 @@ export {
1410
1498
  openModal,
1411
1499
  removeFromSchema,
1412
1500
  resolveResponsiveMetadata,
1413
- selectPanelSlot,
1501
+ selectSidebarSlot,
1414
1502
  selectToolbarSlot,
1415
1503
  selectUIDocumentState,
1416
1504
  selectUIState,
1417
- setActivePanel,
1505
+ setActiveSidebar,
1418
1506
  setActiveToolbar,
1419
1507
  setDisabledCategories,
1420
- setPanelTab
1508
+ setHiddenItems,
1509
+ setSidebarTab
1421
1510
  };
1422
1511
  //# sourceMappingURL=index.js.map