@scm-manager/ui-extensions 2.44.2 → 2.44.3-20230523-110923

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/build/index.d.ts CHANGED
@@ -59,6 +59,15 @@ declare class Binder {
59
59
  * @param options object with additional settings
60
60
  */
61
61
  bind<E extends ExtensionPointDefinition<string, unknown, any>>(extensionPoint: E["name"], extension: E["type"], options?: BindOptions<E["props"]>): void;
62
+ /**
63
+ * Binds an extension to the extension point.
64
+ *
65
+ * @param extensionPoint name of extension point
66
+ * @param extension provided extension
67
+ * @param predicate to decide if the extension gets rendered for the given props
68
+ * @param options object with additional settings
69
+ */
70
+ bind<E extends ExtensionPointDefinition<string, unknown, any>>(extensionPoint: E["name"], extension: E["type"], predicate?: Predicate<E["props"]>, options?: BindOptions<E["props"]>): void;
62
71
  /**
63
72
  * Returns the first extension or null for the given extension point and its props.
64
73
  *
@@ -274,7 +283,7 @@ declare type RepositoryOverviewTopExtensionProps = RepositoryOverviewTop["props"
274
283
  declare type RepositoryOverviewTopExtension = RepositoryOverviewTop;
275
284
  declare type RepositoryOverviewTop = RenderableExtensionPointDefinition<"repository.overview.top", {
276
285
  page: number;
277
- search: string;
286
+ search?: string;
278
287
  namespace?: string;
279
288
  }>;
280
289
  /**
package/build/index.js CHANGED
@@ -37,7 +37,7 @@ module.exports = __toCommonJS(src_exports);
37
37
 
38
38
  // src/binder.ts
39
39
  function isBindOptions(input) {
40
- return typeof input !== "function" && typeof input === "object";
40
+ return typeof input !== "string" && typeof input !== "function" && typeof input === "object";
41
41
  }
42
42
  var Binder = class {
43
43
  constructor(name) {
@@ -62,7 +62,7 @@ var Binder = class {
62
62
  this.name = name;
63
63
  this.extensionPoints = {};
64
64
  }
65
- bind(extensionPoint, extension, predicateOrOptions, extensionName) {
65
+ bind(extensionPoint, extension, predicateOrOptions, extensionNameOrOptions) {
66
66
  let predicate = () => true;
67
67
  let priority = 0;
68
68
  if (isBindOptions(predicateOrOptions)) {
@@ -70,13 +70,23 @@ var Binder = class {
70
70
  predicate = predicateOrOptions.predicate;
71
71
  }
72
72
  if (predicateOrOptions.extensionName) {
73
- extensionName = predicateOrOptions.extensionName;
73
+ extensionNameOrOptions = predicateOrOptions.extensionName;
74
74
  }
75
75
  if (typeof predicateOrOptions.priority === "number") {
76
76
  priority = predicateOrOptions.priority;
77
77
  }
78
78
  } else if (predicateOrOptions) {
79
79
  predicate = predicateOrOptions;
80
+ if (isBindOptions(extensionNameOrOptions)) {
81
+ if (typeof extensionNameOrOptions.priority === "number") {
82
+ priority = extensionNameOrOptions.priority;
83
+ }
84
+ if (extensionNameOrOptions == null ? void 0 : extensionNameOrOptions.extensionName) {
85
+ extensionNameOrOptions = extensionNameOrOptions.extensionName;
86
+ } else {
87
+ extensionNameOrOptions = void 0;
88
+ }
89
+ }
80
90
  }
81
91
  if (!this.extensionPoints[extensionPoint]) {
82
92
  this.extensionPoints[extensionPoint] = [];
@@ -84,7 +94,7 @@ var Binder = class {
84
94
  const registration = {
85
95
  predicate,
86
96
  extension,
87
- extensionName: extensionName ? extensionName : "",
97
+ extensionName: extensionNameOrOptions ? extensionNameOrOptions : "",
88
98
  priority
89
99
  };
90
100
  this.extensionPoints[extensionPoint].push(registration);
@@ -98,9 +108,7 @@ var Binder = class {
98
108
  }
99
109
  getExtensions(extensionPoint, props) {
100
110
  let registrations = this.extensionPoints[extensionPoint] || [];
101
- if (props) {
102
- registrations = registrations.filter((reg) => reg.predicate(props));
103
- }
111
+ registrations = registrations.filter((reg) => reg.predicate(props));
104
112
  registrations.sort(this.sortExtensions);
105
113
  return registrations.map((reg) => reg.extension);
106
114
  }
package/build/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/binder.ts
2
2
  function isBindOptions(input) {
3
- return typeof input !== "function" && typeof input === "object";
3
+ return typeof input !== "string" && typeof input !== "function" && typeof input === "object";
4
4
  }
5
5
  var Binder = class {
6
6
  constructor(name) {
@@ -25,7 +25,7 @@ var Binder = class {
25
25
  this.name = name;
26
26
  this.extensionPoints = {};
27
27
  }
28
- bind(extensionPoint, extension, predicateOrOptions, extensionName) {
28
+ bind(extensionPoint, extension, predicateOrOptions, extensionNameOrOptions) {
29
29
  let predicate = () => true;
30
30
  let priority = 0;
31
31
  if (isBindOptions(predicateOrOptions)) {
@@ -33,13 +33,23 @@ var Binder = class {
33
33
  predicate = predicateOrOptions.predicate;
34
34
  }
35
35
  if (predicateOrOptions.extensionName) {
36
- extensionName = predicateOrOptions.extensionName;
36
+ extensionNameOrOptions = predicateOrOptions.extensionName;
37
37
  }
38
38
  if (typeof predicateOrOptions.priority === "number") {
39
39
  priority = predicateOrOptions.priority;
40
40
  }
41
41
  } else if (predicateOrOptions) {
42
42
  predicate = predicateOrOptions;
43
+ if (isBindOptions(extensionNameOrOptions)) {
44
+ if (typeof extensionNameOrOptions.priority === "number") {
45
+ priority = extensionNameOrOptions.priority;
46
+ }
47
+ if (extensionNameOrOptions == null ? void 0 : extensionNameOrOptions.extensionName) {
48
+ extensionNameOrOptions = extensionNameOrOptions.extensionName;
49
+ } else {
50
+ extensionNameOrOptions = void 0;
51
+ }
52
+ }
43
53
  }
44
54
  if (!this.extensionPoints[extensionPoint]) {
45
55
  this.extensionPoints[extensionPoint] = [];
@@ -47,7 +57,7 @@ var Binder = class {
47
57
  const registration = {
48
58
  predicate,
49
59
  extension,
50
- extensionName: extensionName ? extensionName : "",
60
+ extensionName: extensionNameOrOptions ? extensionNameOrOptions : "",
51
61
  priority
52
62
  };
53
63
  this.extensionPoints[extensionPoint].push(registration);
@@ -61,9 +71,7 @@ var Binder = class {
61
71
  }
62
72
  getExtensions(extensionPoint, props) {
63
73
  let registrations = this.extensionPoints[extensionPoint] || [];
64
- if (props) {
65
- registrations = registrations.filter((reg) => reg.predicate(props));
66
- }
74
+ registrations = registrations.filter((reg) => reg.predicate(props));
67
75
  registrations.sort(this.sortExtensions);
68
76
  return registrations.map((reg) => reg.extension);
69
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-manager/ui-extensions",
3
- "version": "2.44.2",
3
+ "version": "2.44.3-20230523-110923",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Sebastian Sdorra <sebastian.sdorra@cloudogu.com>",
@@ -17,7 +17,7 @@
17
17
  "test": "jest"
18
18
  },
19
19
  "dependencies": {
20
- "@scm-manager/ui-types": "2.44.2",
20
+ "@scm-manager/ui-types": "2.44.3-20230523-110923",
21
21
  "react": "^17.0.1"
22
22
  },
23
23
  "devDependencies": {