@tridion-docs/extensions 1.0.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,7 +1,23 @@
1
1
  # @tridion-docs/extensions
2
2
 
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Added zIndex property to an useItemSelector hook
8
+ - Updated package dependencies
9
+ - Fixed export for ItemSelectorObjectType and PublicationObjectType
10
+ - Added support for Publication Hub
11
+ - Updated types to support Nswag
12
+
13
+ ## 1.0.4
14
+
15
+ ### Patch Changes
16
+
17
+ - For useNotification hook optional property area for adding action button is added
18
+
3
19
  ## 1.0.3
4
20
 
5
21
  ### Major Changes
6
22
 
7
- - Tridion Docs extensions for Organize Space
23
+ - Tridion Docs extensions for Organize Space
package/LICENSE.md CHANGED
@@ -1,2 +1,2 @@
1
1
  License: https://www.rws.com/legal/terms-and-conditions/rws-technology/
2
- Copyright (c) 2014-2023. All Rights Reserved by RWS Group for and on behalf of its affiliates and subsidiaries.
2
+ Copyright © 2024 RWS Holdings plc including its subsidiaries and affiliated companies. All rights reserved.
package/README.md CHANGED
@@ -5,11 +5,42 @@ This project contains the helper function, components and hooks for working wit
5
5
  # License
6
6
  License: https://www.rws.com/legal/terms-and-conditions/rws-technology/
7
7
 
8
- Copyright (c) 2014-2023. All Rights Reserved by RWS Group for and on behalf of its affiliates and subsidiaries.
8
+ Copyright © 2024 RWS Holdings plc including its subsidiaries and affiliated companies. All rights reserved.
9
9
 
10
10
  # Compatibility
11
11
 
12
- This version of the package is compatible with Tridion Docs 15.0
12
+ This version of the package is compatible with Tridion Docs 15.1
13
+
14
+ # Upgrade instruction
15
+
16
+ ## Packages
17
+ To use latest version of extension and extension-cli you need to update versions of package.json in your extension application.
18
+
19
+ You need to update versions of these two packages `@tridion-docs/extensions` and `@tridion-docs/extensions-cli`. We also recommend you to keep all other dependencies up to date. You can find examples of packages and their versions in package.json of extension-example application available on CD.
20
+
21
+ ```
22
+ "dependencies": {
23
+ ...
24
+ "@tridion-docs/extensions": "2.0.0",
25
+ ...
26
+ },
27
+ "devDependencies": {
28
+ ...
29
+ "@tridion-docs/extensions-cli": "2.0.0",
30
+ ...
31
+ }
32
+ ```
33
+ ## Enums
34
+
35
+ `BaseFolder`, `DocumentObjectType`, `FolderType`, `PublicationObjectType` enums keys were changed from UPPERCASE to PascalCase.
36
+
37
+ ```js
38
+ // before
39
+ BaseFolder.EDITOR_TEMPLATE
40
+
41
+ // after
42
+ BaseFolder.EditorTemplate
43
+ ```
13
44
 
14
45
  # Documentation
15
46
 
@@ -107,11 +138,11 @@ export const useCustomHook = () => {
107
138
 
108
139
  const itemSelectorProps = {
109
140
  objectTypesToSelect: [
110
- DocumentObjectType.ILLUSTRATION,
111
- DocumentObjectType.LIBRARY,
112
- DocumentObjectType.MAP,
113
- DocumentObjectType.OTHER,
114
- DocumentObjectType.TOPIC,
141
+ DocumentObjectType.Illustration,
142
+ DocumentObjectType.Library,
143
+ DocumentObjectType.Map,
144
+ DocumentObjectType.Other,
145
+ DocumentObjectType.Topic,
115
146
  ],
116
147
  isMultiSelect: false,
117
148
  onOk: async (values: Content[]) => {
@@ -138,6 +169,7 @@ export const useCustomHook = () => {
138
169
  `onOk` | `function` | Function that will be called when a user clicks the OK button
139
170
  `okLabel` | `string` | Label of the 'Ok' button
140
171
  `cancelLabel` | `string` | Label of the 'Cancel' button
172
+ `modalZindex` | `number` | Property to set z-index property on the item selector modal
141
173
 
142
174
 
143
175
  **Return**
@@ -233,7 +265,7 @@ export const useCustomHook = (props: any) => {
233
265
  **Return**
234
266
  | Name | Type | Description |
235
267
  | :-------------------- | :------------------ | :---------------------------------------- |
236
- `execute` | `function(message, description, severity)` | By calling this function you will show a notification message. `message`: Title of the notification, `description`: Body or text of the notification, `severity`: notification type
268
+ `execute` | `function(message, description, severity, actionArea)` | By calling this function you will show a notification message. `message`: Title of the notification, `description`: Body or text of the notification, `severity`: notification type, `actionArea`: Area to add action button (optional)
237
269
  `messageSeverity` | `MessageSeverity` | Message type, based on the type design and behavior of notification may vary.
238
270
 
239
271
 
@@ -460,7 +492,10 @@ builder.header.addMainNavigationLink(() => ({
460
492
  `component` | `ComponentType` | Component that will be rendered after mouse click
461
493
 
462
494
  ## Action
463
- Custom action button that might be used for executing custom logic for selected items.Registration of new navigation items is required to call the builder function `builder.header.builder.action.addExplorerAction`
495
+ Custom action button that might be used for executing custom logic for selected items. Registration of new navigation items is required to call the builder function `builder.header.builder.action.addExplorerAction`.
496
+
497
+ `addExplorerAction` supports generic type definition, so we specify expected selected object type [more about generics](#generic-types).
498
+
464
499
 
465
500
  ```typescript jsx
466
501
 
@@ -474,6 +509,19 @@ builder.action.addExplorerAction(() => ({
474
509
  icon: CustomIcon,
475
510
  hook: useCustomHook,
476
511
  }));
512
+
513
+ /* if we expect type other than `Content` we can define it here */
514
+ import { Project, ViewType } from '@tridion-docs/extensions';
515
+ builder.action.addExplorerAction<Project>(() => ({
516
+ id: 'id',
517
+ title: 'title',
518
+ tooltip: '',
519
+ isVisible: ({ activeView }) => {
520
+ return activeView === ViewType.project;
521
+ },
522
+ icon: CustomIcon,
523
+ hook: useCustomHook,
524
+ }));
477
525
  ```
478
526
 
479
527
  **Props**
@@ -490,6 +538,7 @@ builder.action.addExplorerAction(() => ({
490
538
  ## Object Insight
491
539
  The object right side panel is representing a custom data view for one or multiple selected items. Registration of new object insight is required to call the builder function `builder.objectInsight.addObjectInsightItem`
492
540
 
541
+ `addObjectInsightItem` supports generic type definition, so we specify expected selected object type [more about generics](#generic-types).
493
542
  ```typescript jsx
494
543
  builder.objectInsight.addObjectInsightItem(() => ({
495
544
  id: 'id',
@@ -501,6 +550,17 @@ builder.objectInsight.addObjectInsightItem(() => ({
501
550
  component: CustomComponent,
502
551
  }));
503
552
 
553
+ /* if we expect type other than `Content` we can define it here */
554
+ builder.objectInsight.addObjectInsightItem<Project>(() => ({
555
+ id: 'id',
556
+ tooltip: 'tooltip',
557
+ isVisible: (props) => {
558
+ return false;
559
+ },
560
+ icon: CustomIcon,
561
+ component: CustomComponent,
562
+ }));
563
+
504
564
  ```
505
565
 
506
566
 
@@ -530,6 +590,13 @@ builder.objectInsight.addObjectInsightItem(() => ({
530
590
  `item` | `string` | Id of the navigation item that will be used for positioning. Default navigation items ('content', 'events', 'settings'), also you can use a previously added custom navigation items id
531
591
  `PositioningType` | `PositioningType`| `string` | Indicate where should be located navigation item relative to previously selected item (`after` or `before`)
532
592
 
593
+ ### Generic types
594
+ As far as we're supporting extensions in different areas like Publication Hub and Content Explorer hooks or components will operate with different types of input parameters. It doesn't not affect the API of the function but it will affect the types of arguments. For example, if we define action in Project or Project assignees in "Publication hub" we will get a `Project` type object instead of `Content` type. To support this case we introduced a generic type for some of the functions like `addExplorerAction` where you may specify the expected type of the active objects.
595
+
596
+ The default type is `Content`. That means `addExplorerAction<Content>()` and `addExplorerAction()` are equal code blocks.
597
+
598
+ [More about typescript generics](https://www.typescriptlang.org/docs/handbook/2/generics.html)
599
+
533
600
 
534
601
  ## Translations
535
602
  Translation records can be registered per language by using the function `builder.translations.addTranslation`
@@ -546,6 +613,7 @@ Translation records can be registered per language by using the function `builde
546
613
  //....
547
614
  ```
548
615
 
616
+
549
617
  ### Usage
550
618
  Import ```t``` function returned by ```createExtensionGlobals``` and pass it the translation key.
551
619
 
@@ -560,6 +628,7 @@ Import ```t``` function returned by ```createExtensionGlobals``` and pass it the
560
628
  | Deutsch | `de` |
561
629
  | Spanish | `es` |
562
630
  | French | `fr` |
631
+ | French (Canada) | `fr-CA` |
563
632
  | Italian | `it` |
564
633
  | Japanese | `ja` |
565
634
  | Chinese (Simplified) | `zh` |
@@ -43,6 +43,13 @@ export interface ItemSelectorProps {
43
43
  * @memberof ItemSelectorProps
44
44
  */
45
45
  cancelLabel: string;
46
+ /**
47
+ * Property to set z-index property on the item selector modal.
48
+ *
49
+ * @type {number}
50
+ * @memberof ItemSelectorProps
51
+ */
52
+ modalZindex?: number;
46
53
  }
47
54
  export type ItemSelectorHook = (props: ItemSelectorProps) => ItemSelectorHookResult;
48
55
  /**
@@ -2,9 +2,9 @@
2
2
  * Enumeration holding all base folders.
3
3
  */
4
4
  export declare enum BaseFolder {
5
- NONE = "none",
6
- DATA = "data",
7
- SYSTEM = "system",
8
- FAVORITES = "favorites",
9
- EDITOR_TEMPLATE = "editorTemplate"
5
+ None = "none",
6
+ Data = "data",
7
+ System = "system",
8
+ Favorites = "favorites",
9
+ EditorTemplate = "editorTemplate"
10
10
  }
@@ -3,11 +3,11 @@
3
3
  */
4
4
  var BaseFolder;
5
5
  (function (BaseFolder) {
6
- BaseFolder["NONE"] = "none";
7
- BaseFolder["DATA"] = "data";
8
- BaseFolder["SYSTEM"] = "system";
9
- BaseFolder["FAVORITES"] = "favorites";
10
- BaseFolder["EDITOR_TEMPLATE"] = "editorTemplate";
6
+ BaseFolder["None"] = "none";
7
+ BaseFolder["Data"] = "data";
8
+ BaseFolder["System"] = "system";
9
+ BaseFolder["Favorites"] = "favorites";
10
+ BaseFolder["EditorTemplate"] = "editorTemplate";
11
11
  })(BaseFolder || (BaseFolder = {}));
12
12
 
13
13
  export { BaseFolder };
@@ -0,0 +1,18 @@
1
+ export interface BaseObject {
2
+ /**
3
+ * The identifier.
4
+ */
5
+ id?: string;
6
+ /**
7
+ * The title.
8
+ */
9
+ title?: string | null;
10
+ /**
11
+ * The description.
12
+ */
13
+ description?: string | null;
14
+ /**
15
+ * The type of the current object.
16
+ */
17
+ type: string;
18
+ }
@@ -1,22 +1,5 @@
1
1
  import { BaseFolder, DocumentObjectType, FolderType } from "..";
2
- interface BaseObject {
3
- /**
4
- * The identifier.
5
- */
6
- id?: string;
7
- /**
8
- * The title.
9
- */
10
- title?: string | null;
11
- /**
12
- * The description.
13
- */
14
- description?: string | null;
15
- /**
16
- * The type of the current object.
17
- */
18
- type: string;
19
- }
2
+ import { BaseObject } from './BaseObject';
20
3
  export interface DocumentObject extends BaseObject {
21
4
  /**
22
5
  * The document object type.
@@ -55,7 +38,7 @@ export interface Folder extends BaseObject {
55
38
  /**
56
39
  * The type of the base folder (e.g. Data, System, Favorites, EditorTemplate).
57
40
  */
58
- baseFolder?: BaseFolder | null;
41
+ baseFolder?: BaseFolder;
59
42
  }
60
43
  export interface Publication extends BaseObject {
61
44
  /**
@@ -84,4 +67,3 @@ export interface Publication extends BaseObject {
84
67
  languageCombinationIds?: Array<string> | null;
85
68
  }
86
69
  export type Content = DocumentObject | Folder | Publication;
87
- export {};
@@ -2,10 +2,10 @@
2
2
  * Enumeration holding the type of document.
3
3
  */
4
4
  export declare enum DocumentObjectType {
5
- UNDEFINED = "undefined",
6
- ILLUSTRATION = "illustration",
7
- LIBRARY = "library",
8
- MAP = "map",
9
- OTHER = "other",
10
- TOPIC = "topic"
5
+ Undefined = "undefined",
6
+ Illustration = "illustration",
7
+ Library = "library",
8
+ Map = "map",
9
+ Other = "other",
10
+ Topic = "topic"
11
11
  }
@@ -3,12 +3,12 @@
3
3
  */
4
4
  var DocumentObjectType;
5
5
  (function (DocumentObjectType) {
6
- DocumentObjectType["UNDEFINED"] = "undefined";
7
- DocumentObjectType["ILLUSTRATION"] = "illustration";
8
- DocumentObjectType["LIBRARY"] = "library";
9
- DocumentObjectType["MAP"] = "map";
10
- DocumentObjectType["OTHER"] = "other";
11
- DocumentObjectType["TOPIC"] = "topic";
6
+ DocumentObjectType["Undefined"] = "undefined";
7
+ DocumentObjectType["Illustration"] = "illustration";
8
+ DocumentObjectType["Library"] = "library";
9
+ DocumentObjectType["Map"] = "map";
10
+ DocumentObjectType["Other"] = "other";
11
+ DocumentObjectType["Topic"] = "topic";
12
12
  })(DocumentObjectType || (DocumentObjectType = {}));
13
13
 
14
14
  export { DocumentObjectType };
@@ -2,12 +2,12 @@
2
2
  * Enumeration holding the type of a folder.
3
3
  */
4
4
  export declare enum FolderType {
5
- FOLDER = "folder",
6
- ILLUSTRATION_FOLDER = "illustrationFolder",
7
- LIBRARY_FOLDER = "libraryFolder",
8
- MAP_FOLDER = "mapFolder",
9
- OTHER_FOLDER = "otherFolder",
10
- PUBLICATION_FOLDER = "publicationFolder",
11
- REFERENCE_FOLDER = "referenceFolder",
12
- TOPIC_FOLDER = "topicFolder"
5
+ Folder = "folder",
6
+ IllustrationFolder = "illustrationFolder",
7
+ LibraryFolder = "libraryFolder",
8
+ MapFolder = "mapFolder",
9
+ OtherFolder = "otherFolder",
10
+ PublicationFolder = "publicationFolder",
11
+ ReferenceFolder = "referenceFolder",
12
+ TopicFolder = "topicFolder"
13
13
  }
@@ -3,14 +3,14 @@
3
3
  */
4
4
  var FolderType;
5
5
  (function (FolderType) {
6
- FolderType["FOLDER"] = "folder";
7
- FolderType["ILLUSTRATION_FOLDER"] = "illustrationFolder";
8
- FolderType["LIBRARY_FOLDER"] = "libraryFolder";
9
- FolderType["MAP_FOLDER"] = "mapFolder";
10
- FolderType["OTHER_FOLDER"] = "otherFolder";
11
- FolderType["PUBLICATION_FOLDER"] = "publicationFolder";
12
- FolderType["REFERENCE_FOLDER"] = "referenceFolder";
13
- FolderType["TOPIC_FOLDER"] = "topicFolder";
6
+ FolderType["Folder"] = "folder";
7
+ FolderType["IllustrationFolder"] = "illustrationFolder";
8
+ FolderType["LibraryFolder"] = "libraryFolder";
9
+ FolderType["MapFolder"] = "mapFolder";
10
+ FolderType["OtherFolder"] = "otherFolder";
11
+ FolderType["PublicationFolder"] = "publicationFolder";
12
+ FolderType["ReferenceFolder"] = "referenceFolder";
13
+ FolderType["TopicFolder"] = "topicFolder";
14
14
  })(FolderType || (FolderType = {}));
15
15
 
16
16
  export { FolderType };
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  export interface NotificationProps {
2
3
  /**
3
4
  * The title of notification box
@@ -20,6 +21,13 @@ export interface NotificationProps {
20
21
  * @memberof NotificationProps
21
22
  */
22
23
  severity: MessageSeverity;
24
+ /**
25
+ * Action area to show buttons
26
+ *
27
+ * @type {ReactNode}
28
+ * @memberof NotificationProps
29
+ */
30
+ actionArea?: ReactNode;
23
31
  }
24
32
  export declare enum MessageSeverity {
25
33
  ERROR = 0,
@@ -0,0 +1,11 @@
1
+ import { BaseObject } from './BaseObject';
2
+ export interface Project extends BaseObject {
3
+ /** The element name of the project. */
4
+ projectId?: string;
5
+ /** The CardId of the Assignee (if available). */
6
+ assigneeCardId?: number | null;
7
+ /** The title of the publication. */
8
+ publicationTitle?: string | null;
9
+ /** The version number of the publication version. */
10
+ publicationVersion?: string | null;
11
+ }
@@ -2,5 +2,5 @@
2
2
  * Enumeration holding the type of publication.
3
3
  */
4
4
  export declare enum PublicationObjectType {
5
- PUBLICATION = "publication"
5
+ Publication = "publication"
6
6
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Enumeration holding the type of publication.
3
+ */
4
+ var PublicationObjectType;
5
+ (function (PublicationObjectType) {
6
+ PublicationObjectType["Publication"] = "publication";
7
+ })(PublicationObjectType || (PublicationObjectType = {}));
8
+
9
+ export { PublicationObjectType };
@@ -8,5 +8,7 @@ export declare enum ViewType {
8
8
  explore = "Explore",
9
9
  details = "Details",
10
10
  search = "Search",
11
- inbox = "Inbox"
11
+ inbox = "Inbox",
12
+ project = "Project",
13
+ projectAssignee = "ProjectAssignee"
12
14
  }
@@ -10,6 +10,8 @@ var ViewType;
10
10
  ViewType["details"] = "Details";
11
11
  ViewType["search"] = "Search";
12
12
  ViewType["inbox"] = "Inbox";
13
+ ViewType["project"] = "Project";
14
+ ViewType["projectAssignee"] = "ProjectAssignee";
13
15
  })(ViewType || (ViewType = {}));
14
16
 
15
17
  export { ViewType };
@@ -1,4 +1,5 @@
1
1
  export * from './Content';
2
+ export * from './Project';
2
3
  export * from './BaseFolder';
3
4
  export * from './DocumentObjectType';
4
5
  export * from './FolderType';
@@ -11,3 +12,5 @@ export * from './FrontendAddon';
11
12
  export * from './FrontendAddons';
12
13
  export * from './Hierarchy';
13
14
  export * from './UserInfo';
15
+ export * from './ItemSelectorObjectType';
16
+ export * from './PublicationObjectType';
@@ -1,4 +1,4 @@
1
1
  import { ExplorerActionExtension } from './explorerAction';
2
2
  export interface ActionExtensions {
3
- explorerActions: ReadonlyArray<ExplorerActionExtension>;
3
+ explorerActions: ReadonlyArray<ExplorerActionExtension<any>>;
4
4
  }
@@ -2,6 +2,6 @@ import { ActionExtensions } from './actionExtensions';
2
2
  import { ExplorerActionExtension } from './explorerAction';
3
3
  export declare class ActionExtensionsBuilder {
4
4
  private _explorerActionExtensions;
5
- addExplorerAction: (item: ExplorerActionExtension) => this;
5
+ addExplorerAction: <T>(item: ExplorerActionExtension<T>) => this;
6
6
  build: () => ActionExtensions;
7
7
  }
@@ -1,6 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { Content, Folder, ViewType, UserInfo } from "../../api";
2
- export type ExplorerActionExtension = () => ExplorerActionExtensionConfiguration;
3
- export interface ExplorerActionExtensionConfiguration {
3
+ export type ExplorerActionExtension<T> = () => ExplorerActionExtensionConfiguration<T>;
4
+ export interface ExplorerActionExtensionConfiguration<T = Content> {
4
5
  /**
5
6
  * Action id (should be unique)
6
7
  *
@@ -31,15 +32,15 @@ export interface ExplorerActionExtensionConfiguration {
31
32
  *
32
33
  * @type {(props: ExplorerActionExtensionVisibilityConfiguration) => boolean}
33
34
  */
34
- readonly isVisible?: (props: ExplorerActionExtensionVisibilityConfiguration) => boolean;
35
+ readonly isVisible?: (props: ExplorerActionExtensionVisibilityConfiguration<T>) => boolean;
35
36
  /**
36
37
  * Hook to place on action button
37
38
  *
38
39
  * @memberof ExplorerActionExtensionConfiguration
39
40
  */
40
- readonly hook: (props: ExplorerActionExtensionHookConfiguration) => ExplorerActionExtensionHookResults;
41
+ readonly hook: (props: ExplorerActionExtensionHookConfiguration<T>) => ExplorerActionExtensionHookResults;
41
42
  }
42
- export interface ExplorerActionExtensionVisibilityConfiguration extends ExplorerActionExtensionBaseConfiguration {
43
+ export interface ExplorerActionExtensionVisibilityConfiguration<T = Content> extends ExplorerActionExtensionBaseConfiguration<T> {
43
44
  /**
44
45
  * Indicates in which part of the UI explorer action is visible
45
46
  *
@@ -63,6 +64,13 @@ export type ExplorerActionExtensionHookResults = {
63
64
  * @memberof ExplorerActionExtensionHookResults
64
65
  */
65
66
  readonly isAvailable: boolean;
67
+ /**
68
+ * Return true if you want to switch the button to the loading state. Loading state changing icon to the spinner and disables the button
69
+ *
70
+ * @type {boolean}
71
+ * @memberof ExplorerActionExtensionHookResults
72
+ */
73
+ readonly isLoading?: boolean;
66
74
  /**
67
75
  * Method that is called when the action is clicked
68
76
  *
@@ -71,21 +79,22 @@ export type ExplorerActionExtensionHookResults = {
71
79
  */
72
80
  readonly execute: () => void | Promise<void>;
73
81
  };
74
- export interface ExplorerActionExtensionHookConfiguration extends ExplorerActionExtensionBaseConfiguration {
82
+ export interface ExplorerActionExtensionHookConfiguration<T = Content> extends ExplorerActionExtensionBaseConfiguration<T> {
75
83
  }
76
84
  /**
77
85
  * Base properties for visibility and hook
78
86
  *
79
87
  * @interface ExplorerActionExtensionBaseConfiguration
88
+ * @typeParam T - type of active item, `Content` is default type
80
89
  */
81
- interface ExplorerActionExtensionBaseConfiguration {
90
+ interface ExplorerActionExtensionBaseConfiguration<T = Content> {
82
91
  /**
83
92
  * The currently selected items inside the Explorer
84
93
  *
85
- * @type {Content[]}
94
+ * @type {T[]}
86
95
  * @memberof ExplorerActionExtensionBaseConfiguration
87
96
  */
88
- readonly selectedItems: Content[];
97
+ readonly selectedItems: T[];
89
98
  /**
90
99
  * Folder we are currently in
91
100
  *
@@ -1,4 +1,4 @@
1
1
  import { ObjectInsightItemExtension } from './objectInsightItem';
2
2
  export interface ObjectInsightExtensions {
3
- objectInsightItems: ReadonlyArray<ObjectInsightItemExtension>;
3
+ objectInsightItems: ReadonlyArray<ObjectInsightItemExtension<any>>;
4
4
  }
@@ -2,6 +2,6 @@ import { ObjectInsightExtensions } from './objectInsightExtensions';
2
2
  import { ObjectInsightItemExtension } from './objectInsightItem';
3
3
  export declare class ObjectInsightExtensionsBuilder {
4
4
  private _objectInsightItemExtensions;
5
- addObjectInsightItem: (item: ObjectInsightItemExtension) => this;
5
+ addObjectInsightItem: <T>(item: ObjectInsightItemExtension<T>) => this;
6
6
  build: () => ObjectInsightExtensions;
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import { Content, Folder, UserInfo, ViewType } from "../../api";
2
2
  import type { ComponentType } from 'react';
3
- export type ObjectInsightItemExtension = () => ObjectInsightItemExtensionConfiguration;
4
- export interface ObjectInsightItemExtensionConfiguration {
3
+ export type ObjectInsightItemExtension<T> = () => ObjectInsightItemExtensionConfiguration<T>;
4
+ export interface ObjectInsightItemExtensionConfiguration<T = Content> {
5
5
  /**
6
6
  * Object Insight item id (should be unique)
7
7
  *
@@ -26,22 +26,23 @@ export interface ObjectInsightItemExtensionConfiguration {
26
26
  *
27
27
  * @type {(props: ObjectInsightItemExtensionsVisibilityConfiguration) => boolean}
28
28
  */
29
- readonly isVisible?: (props: ObjectInsightItemExtensionsVisibilityConfiguration) => boolean;
29
+ readonly isVisible?: (props: ObjectInsightItemExtensionsVisibilityConfiguration<T>) => boolean;
30
30
  /**
31
31
  * Menu item component to render on this path
32
32
  *
33
33
  * @type {ComponentType}
34
34
  * @memberof ObjectInsightItemExtensionConfiguration
35
35
  */
36
- readonly component: ComponentType<ObjectInsightItemExtensionComponentConfiguration>;
36
+ readonly component: ComponentType<ObjectInsightItemExtensionComponentConfiguration<T>>;
37
37
  }
38
38
  /**
39
39
  * Component properties in object insight panel
40
40
  *
41
41
  * @export
42
42
  * @interface ObjectInsightItemExtensionComponentConfiguration
43
+ * @typeParam T - type of active item, default value is Content
43
44
  */
44
- export interface ObjectInsightItemExtensionComponentConfiguration extends ObjectInsightItemExtensionBaseConfiguration {
45
+ export interface ObjectInsightItemExtensionComponentConfiguration<T = Content> extends ObjectInsightItemExtensionBaseConfiguration<T> {
45
46
  /**
46
47
  * Indicates when item is in loading state or part of the UI is refreshing,
47
48
  * so item can get new information after
@@ -56,8 +57,10 @@ export interface ObjectInsightItemExtensionComponentConfiguration extends Object
56
57
  *
57
58
  * @export
58
59
  * @interface ObjectInsightItemExtensionsVisibilityConfiguration
60
+ * @typeParam T - type of active item, `Content` is default type
61
+ *
59
62
  */
60
- export interface ObjectInsightItemExtensionsVisibilityConfiguration extends ObjectInsightItemExtensionBaseConfiguration {
63
+ export interface ObjectInsightItemExtensionsVisibilityConfiguration<T = Content> extends ObjectInsightItemExtensionBaseConfiguration<T> {
61
64
  /**
62
65
  * Indicates in which part of the UI object insight panel is visible
63
66
  *
@@ -77,15 +80,16 @@ export interface ObjectInsightItemExtensionsVisibilityConfiguration extends Obje
77
80
  * Base properties for component and visibility
78
81
  *
79
82
  * @interface ObjectInsightItemExtensionBaseConfiguration
83
+ * @typeParam T - type of active item, `Content` is default type
80
84
  */
81
- interface ObjectInsightItemExtensionBaseConfiguration {
85
+ interface ObjectInsightItemExtensionBaseConfiguration<T = Content> {
82
86
  /**
83
87
  * Active item in the view, can be document object, folder or publication
84
88
  *
85
- * @type {Content}
89
+ * @type {T}
86
90
  * @memberof ObjectInsightItemExtensionBaseConfiguration
87
91
  */
88
- activeItem: Content;
92
+ activeItem: T;
89
93
  /**
90
94
  * Folder in which active items is in UI. Usually the same as parent folder,
91
95
  * exception is when item is visible in reference folder and in search results
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ export { FolderType } from './api/typings/FolderType.js';
14
14
  export { MessageSeverity } from './api/typings/Notification.js';
15
15
  export { NavigationItemIdType, PositioningType } from './api/typings/Position.js';
16
16
  export { ViewType } from './api/typings/ViewType.js';
17
+ export { PublicationObjectType } from './api/typings/PublicationObjectType.js';
17
18
  export { initializeExtensionApiStorage } from './apiStorage/apiStorage.js';
18
19
  import 'react';
19
20
  export { ActionExtensionsBuilder } from './extensionPoints/action/actionExtensionsBuilder.js';
@@ -1,9 +1,9 @@
1
- const version = "1.0.3";
1
+ const version = "2.0.0";
2
2
  const peerDependencies = {
3
- react: "18.2.0",
4
- "react-dom": "18.2.0",
5
- "react-is": "18.2.0",
6
- "styled-components": "5.3.6"
3
+ react: "*",
4
+ "react-dom": "*",
5
+ "react-is": "*",
6
+ "styled-components": "*"
7
7
  };
8
8
 
9
9
  export { peerDependencies, version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tridion-docs/extensions",
3
- "version": "1.0.3",
3
+ "version": "2.0.0",
4
4
  "description": "Tridion Docs Extensions API",
5
5
  "author": "RWS Group for and on behalf of its affiliates and subsidiaries",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -21,34 +21,34 @@
21
21
  "build": "rollup -c",
22
22
  "release": "rollup -c",
23
23
  "start": "rollup -c -w",
24
- "lint": "eslint . --fix && prettier --write \"src/**/*\"",
24
+ "start:remote": "yarn run start",
25
+ "lint": "eslint .",
26
+ "lint:fix": "eslint . --fix && prettier --write \"src/**/*\"",
25
27
  "prepublish": "yarn build"
26
28
  },
27
29
  "peerDependencies": {
28
- "react": "18.2.0",
29
- "react-dom": "18.2.0",
30
- "react-is": "18.2.0",
31
- "styled-components": "5.3.6"
30
+ "react": "*",
31
+ "react-dom": "*",
32
+ "react-is": "*",
33
+ "styled-components": "*"
32
34
  },
33
35
  "devDependencies": {
34
- "@rollup/plugin-commonjs": "24.0.1",
35
- "@rollup/plugin-json": "6.0.0",
36
- "@rollup/plugin-node-resolve": "15.0.1",
37
- "@rollup/plugin-typescript": "11.0.0",
38
- "@tridion/graphene": "1.31.0",
39
- "@types/react": "18.0.31",
40
- "@types/react-dom": "18.0.11",
41
- "@types/react-is": "17.0.3",
42
- "@types/styled-components": "5.1.26",
36
+ "@rollup/plugin-commonjs": "25.0.7",
37
+ "@rollup/plugin-json": "6.1.0",
38
+ "@rollup/plugin-node-resolve": "15.2.3",
39
+ "@rollup/plugin-typescript": "11.1.6",
40
+ "@types/react": "18.2.58",
41
+ "@types/react-dom": "18.2.19",
42
+ "@types/react-is": "18.2.4",
43
43
  "react": "18.2.0",
44
44
  "react-dom": "18.2.0",
45
45
  "react-is": "18.2.0",
46
- "rimraf": "3.0.2",
47
- "rollup": "3.20.2",
46
+ "rimraf": "5.0.5",
47
+ "rollup": "4.12.0",
48
48
  "rollup-plugin-delete": "2.0.0",
49
- "rollup-plugin-node-externals": "5.1.2",
50
- "styled-components": "5.3.9",
51
- "typescript": "5.0.2",
52
- "typescript-transform-paths": "3.4.6"
49
+ "rollup-plugin-node-externals": "7.0.1",
50
+ "styled-components": "6.1.8",
51
+ "typescript": "5.3.3",
52
+ "typescript-transform-paths": "3.4.7"
53
53
  }
54
54
  }