@staffbase/widget-sdk 3.3.3 → 3.4.0-alpha.14

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 (69) hide show
  1. package/dist/base-block.d.ts +98 -0
  2. package/{index.d.ts → dist/base-block.js} +2 -11
  3. package/{lib/block-attributes.ts → dist/block-attributes.d.ts} +2 -3
  4. package/dist/block-attributes.js +13 -0
  5. package/dist/block-definition.d.ts +91 -0
  6. package/dist/block-definition.js +13 -0
  7. package/dist/block-element.d.ts +45 -0
  8. package/dist/block-element.js +13 -0
  9. package/{lib/block-factory.ts → dist/block-factory.d.ts} +2 -6
  10. package/dist/block-factory.js +13 -0
  11. package/{lib/external-block-definition.ts → dist/external-block-definition.d.ts} +15 -19
  12. package/dist/external-block-definition.js +13 -0
  13. package/{lib → dist}/global.d.ts +6 -9
  14. package/dist/global.js +13 -0
  15. package/dist/index.d.ts +9 -0
  16. package/dist/index.js +9 -0
  17. package/{lib/widget-api-types.ts → dist/widget-api-types.d.ts} +92 -76
  18. package/dist/widget-api-types.js +21 -0
  19. package/{lib/widget-api.ts → dist/widget-api.d.ts} +18 -8
  20. package/dist/widget-api.js +13 -0
  21. package/docs/.nojekyll +1 -0
  22. package/docs/BaseBlock.md +5887 -0
  23. package/docs/BlockAttributes.md +21 -0
  24. package/docs/BlockDefinition.md +167 -0
  25. package/docs/BlockElement.md +103 -0
  26. package/docs/ColorTheme.md +97 -0
  27. package/docs/ExternalBlockDefinition.md +58 -0
  28. package/docs/Home.md +56 -30
  29. package/docs/IntegrationInformation.md +70 -0
  30. package/docs/IntegrationState.md +41 -0
  31. package/docs/IntegrationToken.md +30 -0
  32. package/docs/SBColors.md +639 -0
  33. package/docs/SBFileType.md +74 -0
  34. package/docs/SBImageEntity.md +74 -0
  35. package/docs/SBUserAvatar.md +52 -0
  36. package/docs/SBUserProfile.md +96 -0
  37. package/docs/UserListItem.md +52 -0
  38. package/docs/UserListRequestQuery.md +52 -0
  39. package/docs/UserListResponse.md +52 -0
  40. package/docs/WidgetApi.md +142 -0
  41. package/docs/_Sidebar.md +2 -19
  42. package/package.json +22 -17
  43. package/.commitlintrc.json +0 -28
  44. package/.github/CODEOWNERS +0 -1
  45. package/.github/workflows/ci.yaml +0 -63
  46. package/.husky/commit-msg +0 -6
  47. package/.releaserc +0 -38
  48. package/CHANGELOG.md +0 -234
  49. package/CONTRIBUTING.md +0 -10
  50. package/catalog-info.yaml +0 -11
  51. package/docs/Interface: BaseBlock.md +0 -3226
  52. package/docs/Interface: BlockAttributes.md +0 -11
  53. package/docs/Interface: BlockDefinition.md +0 -117
  54. package/docs/Interface: BlockElement.md +0 -89
  55. package/docs/Interface: ColorTheme.md +0 -52
  56. package/docs/Interface: ExternalBlockDefinition.md +0 -38
  57. package/docs/Interface: SBColors.md +0 -354
  58. package/docs/Interface: SBFileType.md +0 -39
  59. package/docs/Interface: SBImageEntity.md +0 -39
  60. package/docs/Interface: SBUserAvatar.md +0 -27
  61. package/docs/Interface: SBUserProfile.md +0 -51
  62. package/docs/Interface: UserListItem.md +0 -27
  63. package/docs/Interface: UserListRequestQuery.md +0 -27
  64. package/docs/Interface: UserListResponse.md +0 -27
  65. package/docs/Interface: WidgetApi.md +0 -75
  66. package/lib/base-block.ts +0 -110
  67. package/lib/block-definition.ts +0 -101
  68. package/lib/block-element.ts +0 -56
  69. package/tsconfig.json +0 -13
@@ -0,0 +1,98 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ /**
14
+ * Base class for custom widgets.
15
+ *
16
+ * Should be used to extend other custom elements to render their content.
17
+ * Provides common editing and render capabilities for Staffbase widgets.
18
+ */
19
+ export interface BaseBlock extends HTMLElement {
20
+ /**
21
+ * Called when the widget is rendered in a page.
22
+ * Override this method in order to display your widget contents.
23
+ *
24
+ * Default implementation is a noop.
25
+ *
26
+ * @param container an `HTMLElement` into which the contents of the widget should be rendered.
27
+ * Note that this does not necessarily have to be `this` since the base class might
28
+ * render a title, a div with a border, or other decorations.
29
+ */
30
+ renderBlock(container: HTMLElement): void;
31
+ /**
32
+ * Called when the widget is rendered in the WYSIWYG editor.
33
+ * override this method in order to display your widget preview.
34
+ *
35
+ * By default, the editor will display a generic placeholder
36
+ * with the widget name and icon.
37
+ *
38
+ * @param container an `HTMLElement` into which the contents of the widget should be rendered
39
+ * Note that this does not necessarily have to be `this` since the base class might
40
+ * render a title, a div with a border, or other decorations.
41
+ */
42
+ renderBlockInEditor(container: HTMLElement): void;
43
+ /**
44
+ * Called when the widget is unmounted from the DOM.
45
+ *
46
+ * Override this in order to implement your unmount logic.
47
+ *
48
+ * @param container an `HTMLElement` which was used previously to render the widget.
49
+ */
50
+ unmountBlock(container: HTMLElement): void;
51
+ /**
52
+ * Called when an attribute is changed.
53
+ *
54
+ * Override this in order to get notified about new attribute values.
55
+ *
56
+ * NOTE: There are attributes that are common to all widgets. They are handled
57
+ * inside the base block. Therefore, if you override this method, be sure to
58
+ * call `super.attributeChangedCallback()` inside your implementation, in
59
+ * order to let the base class know about the arguments that it might be interested in.
60
+ */
61
+ attributeChangedCallback(attrName: string, oldValue: string | undefined, newValue: string | undefined): void;
62
+ /**
63
+ * Called after the dialog is closed and the attributes are set on the web component.
64
+ *
65
+ * Override this if the attributes are handled with a different logic then the default one.
66
+ *
67
+ * @param attributes A map of attributes, as defined in the block definition, which have the
68
+ * types from the form data
69
+ *
70
+ * NOTE: The default implementation turns every value in a string, except arrays and object, which
71
+ * are converted to base64 encoded data uris in the format `data:text/plain;base64,...`
72
+ */
73
+ parseConfig<T extends Record<string, any>>(attributes: T): Record<string, string>;
74
+ /**
75
+ * Called when the config dialog is opened. The dialog uses the parsed attributes, to fill
76
+ * the fields with the existing values.
77
+ *
78
+ * Uses the property blockDefinition.attributes to parse each indidividual attribute and
79
+ * returns it in the format, the configuration form needs. The common attributes are handled
80
+ * externally
81
+ *
82
+ * This method is the counter part of parseConfig, the this must be implemented, if parseConfig
83
+ * is overriden.
84
+ *
85
+ * NOTE: The default implementation converts every string to string, boolean or number and decodes
86
+ * and parses the data uris to the arrays and objects. Dates are remaining a string!
87
+ */
88
+ parseAttributes<T extends Record<string, any>>(): T;
89
+ /**
90
+ * The content language as defined in the hosting system. Should be used to provide
91
+ * the correct localization in the widget.
92
+ *
93
+ * NOTE: This is not necessarily the same as the UI language, which is defined by the browser.
94
+ * When a widget is added to a specific content, the content-language attribute gets automatically set
95
+ * to that language.
96
+ */
97
+ contentLanguage: string;
98
+ }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Copyright 2020, Staffbase GmbH and contributors.
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
3
  * Licensed under the Apache License, Version 2.0 (the "License");
4
4
  * you may not use this file except in compliance with the License.
5
5
  * You may obtain a copy of the License at
@@ -10,13 +10,4 @@
10
10
  * See the License for the specific language governing permissions and
11
11
  * limitations under the License.
12
12
  */
13
-
14
- export * from "./lib/block-attributes";
15
- export * from "./lib/block-definition";
16
- export * from "./lib/block-element";
17
- export * from "./lib/block-factory";
18
- export * from "./lib/global";
19
- export * from "./lib/external-block-definition";
20
- export * from "./lib/base-block";
21
- export * from './lib/widget-api';
22
- export * from './lib/widget-api-types';
13
+ export {};
@@ -10,8 +10,7 @@
10
10
  * See the License for the specific language governing permissions and
11
11
  * limitations under the License.
12
12
  */
13
-
14
13
  export interface BlockAttributes {
15
- contentLanguage: string;
16
- [key: string]: number | boolean | string;
14
+ contentLanguage: string;
15
+ [key: string]: number | boolean | string;
17
16
  }
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export {};
@@ -0,0 +1,91 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ import { BlockFactory } from "./block-factory";
14
+ import { JSONSchema7 } from "json-schema";
15
+ import { UiSchema } from '@rjsf/core';
16
+ export interface BlockDefinition<Factory = BlockFactory> {
17
+ /**
18
+ * The tag name of the widget. It must be compatible with
19
+ * webcomponent naming conventions.
20
+ *
21
+ * @see https://www.webcomponents.org/community/articles/how-should-i-name-my-element
22
+ */
23
+ name: string;
24
+ /**
25
+ * The implementation of the web component.
26
+ */
27
+ factory: Factory;
28
+ /**
29
+ * Can be used for extending from a built-in element.
30
+ */
31
+ options?: ElementDefinitionOptions;
32
+ /**
33
+ * DOM attributes of the element, must be in kebab-case.
34
+ */
35
+ attributes: string[];
36
+ /**
37
+ * Set to `inline` if you want the element to behave like a span element
38
+ * rather than a div element if not specified, it defaults to `block`.
39
+ */
40
+ blockLevel?: "block" | "inline";
41
+ /**
42
+ * Schema used for defining the configuration form.
43
+ *
44
+ * @example
45
+ * ```json
46
+ * {
47
+ * "type": "object",
48
+ * "required": [
49
+ * "firstName",
50
+ * "lastName"
51
+ * ],
52
+ * "properties": {
53
+ * "firstName": {
54
+ * "type": "string",
55
+ * "title": "First name"
56
+ * },
57
+ * "lastName": {
58
+ * "type": "string",
59
+ * "title": "Last name"
60
+ * }
61
+ * }
62
+ * }
63
+ * ```
64
+ * @see https://react-jsonschema-form.readthedocs.io/en/latest/
65
+ */
66
+ configurationSchema: JSONSchema7;
67
+ /**
68
+ *
69
+ * Schema to add more customization to the look and feel of the configuration form.
70
+ *
71
+ * ```json
72
+ * {
73
+ * "firstName": {
74
+ * "ui:help": "Your first name."
75
+ * }
76
+ * }
77
+ * ```
78
+ *
79
+ * @see https://react-jsonschema-form.readthedocs.io/en/latest/api-reference/uiSchema/
80
+ */
81
+ uiSchema?: UiSchema;
82
+ /**
83
+ * Label displayed in the settings dialog and in the default widget preview.
84
+ */
85
+ label?: string;
86
+ /**
87
+ * Icon displayed on the widget installation page.
88
+ * We recommend an icon with the dimensions 32x32 px.
89
+ */
90
+ iconUrl?: string;
91
+ }
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export {};
@@ -0,0 +1,45 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export interface BlockElement {
14
+ /**
15
+ * Static getter to determine which HTML attributes should trigger the function 'attributeChangedCallback';
16
+ */
17
+ /**
18
+ * Invoked when the custom element is first connected to the DOM.
19
+ */
20
+ connectedCallback: () => void;
21
+ /**
22
+ * Invoked when the custom element is disconnected from the DOM.
23
+ */
24
+ disconnectedCallback: () => void;
25
+ /**
26
+ * Invoked when the custom element is moved to a new document.
27
+ */
28
+ adoptedCallback: () => void;
29
+ /**
30
+ * Invoked when one of the attributes of the custom element is added, removed, or changed.
31
+ *
32
+ * Note that you have to statically register the observed values with the 'observedAttributes' static getter.
33
+ *
34
+ * @param attrName The changed attributes name
35
+ * @param oldValue The old value
36
+ * @param newValue The new value
37
+ */
38
+ attributeChangedCallback: (attrName: string, oldValue: string | undefined, newValue: string | undefined) => void;
39
+ /**
40
+ * Method to unmount / revert any effects applied by rendering.
41
+ * E.g. to be used in editor cases to remove any rendered content
42
+ * and revert the block to its initial state.
43
+ */
44
+ unmount: () => void;
45
+ }
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export {};
@@ -10,17 +10,15 @@
10
10
  * See the License for the specific language governing permissions and
11
11
  * limitations under the License.
12
12
  */
13
-
14
13
  import { BaseBlock } from "./base-block";
15
14
  import { WidgetApi } from "./widget-api";
16
-
17
15
  /**
18
16
  * Factory for the custom widgets.
19
17
  *
20
18
  * @param Base base class for the custom widgets to inherit from.
21
19
  * The class itself is a subclass of `HTMLElement` of the relevant `window` object,
22
20
  * with additional functionality.
23
- *
21
+ *
24
22
  * @param widgetApi API providing methods for additional information by the Staffbase framework
25
23
  *
26
24
  * @example
@@ -35,6 +33,4 @@ import { WidgetApi } from "./widget-api";
35
33
  * }
36
34
  * };
37
35
  */
38
- export type BlockFactory = (
39
- Base: new () => BaseBlock, widgetApi: WidgetApi
40
- ) => CustomElementConstructor;
36
+ export declare type BlockFactory = (Base: new () => BaseBlock, widgetApi: WidgetApi) => CustomElementConstructor;
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export {};
@@ -10,10 +10,8 @@
10
10
  * See the License for the specific language governing permissions and
11
11
  * limitations under the License.
12
12
  */
13
-
14
- import { BlockDefinition } from "..";
13
+ import { BlockDefinition } from ".";
15
14
  import { BlockFactory } from "./block-factory";
16
-
17
15
  /**
18
16
  * Defintion of the Widget.
19
17
  *
@@ -21,20 +19,18 @@ import { BlockFactory } from "./block-factory";
21
19
  * and meta information (author and version of the widget).
22
20
  */
23
21
  export interface ExternalBlockDefinition<Factory = BlockFactory> {
24
- /**
25
- * Definition of the block.
26
- *
27
- * Will be registered to the staffbase app.
28
- */
29
- blockDefinition: BlockDefinition<Factory>;
30
-
31
- /**
32
- * Current version of the widget.
33
- */
34
- version: string;
35
-
36
- /**
37
- * Name of the author.
38
- */
39
- author: string;
22
+ /**
23
+ * Definition of the block.
24
+ *
25
+ * Will be registered to the staffbase app.
26
+ */
27
+ blockDefinition: BlockDefinition<Factory>;
28
+ /**
29
+ * Current version of the widget.
30
+ */
31
+ version: string;
32
+ /**
33
+ * Name of the author.
34
+ */
35
+ author: string;
40
36
  }
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export {};
@@ -10,20 +10,17 @@
10
10
  * See the License for the specific language governing permissions and
11
11
  * limitations under the License.
12
12
  */
13
-
14
13
  import { ExternalBlockDefinition } from "./external-block-definition";
15
-
16
14
  export {};
17
-
18
15
  /**
19
16
  * declaration merging
20
17
  * to add the defineBlock to the window
21
18
  */
22
19
  declare global {
23
- interface Window {
24
- /**
25
- * global method to register the widget to the frontend
26
- */
27
- defineBlock: (widget: ExternalBlockDefinition) => void;
28
- }
20
+ interface Window {
21
+ /**
22
+ * global method to register the widget to the frontend
23
+ */
24
+ defineBlock: (widget: ExternalBlockDefinition) => void;
25
+ }
29
26
  }
package/dist/global.js ADDED
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright 2021, Staffbase GmbH and contributors.
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ * http://www.apache.org/licenses/LICENSE-2.0
7
+ * Unless required by applicable law or agreed to in writing, software
8
+ * distributed under the License is distributed on an "AS IS" BASIS,
9
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ * See the License for the specific language governing permissions and
11
+ * limitations under the License.
12
+ */
13
+ export {};
@@ -0,0 +1,9 @@
1
+ export * from './base-block.js';
2
+ export * from './block-attributes.js';
3
+ export * from './block-definition.js';
4
+ export * from './block-element.js';
5
+ export * from './block-factory.js';
6
+ export * from './external-block-definition.js';
7
+ export * from './widget-api-types.js';
8
+ export * from './widget-api.js';
9
+ export * from './global.js';
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export * from './base-block.js';
2
+ export * from './block-attributes.js';
3
+ export * from './block-definition.js';
4
+ export * from './block-element.js';
5
+ export * from './block-factory.js';
6
+ export * from './external-block-definition.js';
7
+ export * from './widget-api-types.js';
8
+ export * from './widget-api.js';
9
+ export * from './global.js';