@staffbase/widget-sdk 3.3.4 → 3.4.0-alpha.15

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 (61) hide show
  1. package/dist/base-block.d.ts +98 -0
  2. package/{lib/block-attributes.ts → dist/block-attributes.d.ts} +2 -3
  3. package/dist/block-definition.d.ts +91 -0
  4. package/dist/block-element.d.ts +45 -0
  5. package/{lib/block-factory.ts → dist/block-factory.d.ts} +2 -6
  6. package/{lib/external-block-definition.ts → dist/external-block-definition.d.ts} +15 -19
  7. package/{lib → dist}/global.d.ts +6 -9
  8. package/dist/index.d.ts +9 -0
  9. package/{index.d.ts → dist/index.js} +9 -11
  10. package/dist/index.mjs +21 -0
  11. package/{lib/widget-api-types.ts → dist/widget-api-types.d.ts} +93 -76
  12. package/{lib/widget-api.ts → dist/widget-api.d.ts} +18 -8
  13. package/docs/.nojekyll +1 -0
  14. package/docs/BaseBlock.md +5887 -0
  15. package/docs/BlockAttributes.md +21 -0
  16. package/docs/BlockDefinition.md +167 -0
  17. package/docs/BlockElement.md +103 -0
  18. package/docs/ColorTheme.md +97 -0
  19. package/docs/ExternalBlockDefinition.md +58 -0
  20. package/docs/Home.md +87 -30
  21. package/docs/IntegrationInformation.md +70 -0
  22. package/docs/IntegrationToken.md +30 -0
  23. package/docs/SBColors.md +639 -0
  24. package/docs/SBFileType.md +74 -0
  25. package/docs/SBImageEntity.md +74 -0
  26. package/docs/SBUserAvatar.md +52 -0
  27. package/docs/SBUserProfile.md +96 -0
  28. package/docs/UserListItem.md +52 -0
  29. package/docs/UserListRequestQuery.md +52 -0
  30. package/docs/UserListResponse.md +52 -0
  31. package/docs/WidgetApi.md +142 -0
  32. package/docs/_Sidebar.md +2 -19
  33. package/package.json +24 -17
  34. package/.commitlintrc.json +0 -28
  35. package/.github/CODEOWNERS +0 -1
  36. package/.github/workflows/ci.yaml +0 -61
  37. package/.github/workflows/dependency-update.yml +0 -24
  38. package/.husky/commit-msg +0 -6
  39. package/.releaserc +0 -38
  40. package/CHANGELOG.md +0 -271
  41. package/CONTRIBUTING.md +0 -10
  42. package/catalog-info.yaml +0 -11
  43. package/docs/Interface: BaseBlock.md +0 -3226
  44. package/docs/Interface: BlockAttributes.md +0 -11
  45. package/docs/Interface: BlockDefinition.md +0 -117
  46. package/docs/Interface: BlockElement.md +0 -89
  47. package/docs/Interface: ColorTheme.md +0 -52
  48. package/docs/Interface: ExternalBlockDefinition.md +0 -38
  49. package/docs/Interface: SBColors.md +0 -354
  50. package/docs/Interface: SBFileType.md +0 -39
  51. package/docs/Interface: SBImageEntity.md +0 -39
  52. package/docs/Interface: SBUserAvatar.md +0 -27
  53. package/docs/Interface: SBUserProfile.md +0 -51
  54. package/docs/Interface: UserListItem.md +0 -27
  55. package/docs/Interface: UserListRequestQuery.md +0 -27
  56. package/docs/Interface: UserListResponse.md +0 -27
  57. package/docs/Interface: WidgetApi.md +0 -75
  58. package/lib/base-block.ts +0 -110
  59. package/lib/block-definition.ts +0 -101
  60. package/lib/block-element.ts +0 -56
  61. package/tsconfig.json +0 -13
@@ -1,27 +0,0 @@
1
- # Interface: SBUserAvatar
2
-
3
- User avatar definition
4
-
5
- ## Properties
6
-
7
- ### icon
8
-
9
- • **icon**: [*SBImageEntity*](../wiki/Interface:%20SBImageEntity)
10
-
11
- ___
12
-
13
- ### original
14
-
15
- • **original**: [*SBImageEntity*](../wiki/Interface:%20SBImageEntity)
16
-
17
- ___
18
-
19
- ### publicID
20
-
21
- • **publicID**: *string*
22
-
23
- ___
24
-
25
- ### thumb
26
-
27
- • **thumb**: [*SBImageEntity*](../wiki/Interface:%20SBImageEntity)
@@ -1,51 +0,0 @@
1
- # Interface: SBUserProfile
2
-
3
- User profile data
4
-
5
- ## Properties
6
-
7
- ### avatar
8
-
9
- • `Optional` **avatar**: [*SBUserAvatar*](../wiki/Interface:%20SBUserAvatar)
10
-
11
- ___
12
-
13
- ### department
14
-
15
- • `Optional` **department**: *string*
16
-
17
- ___
18
-
19
- ### firstName
20
-
21
- • **firstName**: *string*
22
-
23
- ___
24
-
25
- ### lastName
26
-
27
- • **lastName**: *string*
28
-
29
- ___
30
-
31
- ### location
32
-
33
- • `Optional` **location**: *string*
34
-
35
- ___
36
-
37
- ### phoneNumber
38
-
39
- • `Optional` **phoneNumber**: *string*
40
-
41
- ___
42
-
43
- ### position
44
-
45
- • `Optional` **position**: *string*
46
-
47
- ___
48
-
49
- ### publicEmailAddress
50
-
51
- • `Optional` **publicEmailAddress**: *string*
@@ -1,27 +0,0 @@
1
- # Interface: UserListItem
2
-
3
- Single user item
4
-
5
- ## Properties
6
-
7
- ### entityType
8
-
9
- • `Optional` **entityType**: *string*
10
-
11
- ___
12
-
13
- ### firstName
14
-
15
- • `Optional` **firstName**: *string*
16
-
17
- ___
18
-
19
- ### id
20
-
21
- • `Optional` **id**: *string*
22
-
23
- ___
24
-
25
- ### lastName
26
-
27
- • `Optional` **lastName**: *string*
@@ -1,27 +0,0 @@
1
- # Interface: UserListRequestQuery
2
-
3
- User list request parameters
4
-
5
- ## Properties
6
-
7
- ### filter
8
-
9
- • `Optional` **filter**: *string*
10
-
11
- ___
12
-
13
- ### limit
14
-
15
- • `Optional` **limit**: *number*
16
-
17
- ___
18
-
19
- ### offset
20
-
21
- • `Optional` **offset**: *number*
22
-
23
- ___
24
-
25
- ### sort
26
-
27
- • `Optional` **sort**: [*UserListSorting*](../wiki/Home#userlistsorting)
@@ -1,27 +0,0 @@
1
- # Interface: UserListResponse
2
-
3
- Responded user list
4
-
5
- ## Properties
6
-
7
- ### data
8
-
9
- • **data**: [*UserListItem*](../wiki/Interface:%20UserListItem)[]
10
-
11
- ___
12
-
13
- ### limit
14
-
15
- • **limit**: *number*
16
-
17
- ___
18
-
19
- ### offset
20
-
21
- • **offset**: *number*
22
-
23
- ___
24
-
25
- ### total
26
-
27
- • **total**: *number*
@@ -1,75 +0,0 @@
1
- # Interface: WidgetApi
2
-
3
- Widget API class.
4
-
5
- A class providing access to additional information about the Staffbase ecosystem for widgets.
6
-
7
- ## Methods
8
-
9
- ### getLegacyAppTheme
10
-
11
- ▸ **getLegacyAppTheme**(): [*ColorTheme*](../wiki/Interface:%20ColorTheme)
12
-
13
- Call to retrieve the color theme of the app. Since this theme definitions
14
- are currently redesigned, this method is called legacy.
15
-
16
- **Returns:** [*ColorTheme*](../wiki/Interface:%20ColorTheme)
17
-
18
- An object containing the color theme data is returned.
19
-
20
- ___
21
-
22
- ### getUserInformation
23
-
24
- ▸ **getUserInformation**(`userId?`: *string*): *Promise*<[*SBUserProfile*](../wiki/Interface:%20SBUserProfile)\>
25
-
26
- Call to retrieve the user profile of the current or a specific user.
27
-
28
- #### Parameters:
29
-
30
- | Name | Type | Description |
31
- | :------ | :------ | :------ |
32
- | `userId?` | *string* | User ID to lookup for; leave blank to retrieve current user |
33
-
34
- **Returns:** *Promise*<[*SBUserProfile*](../wiki/Interface:%20SBUserProfile)\>
35
-
36
- A promise containing the SBUserProfile is returned. In case of an error,
37
- the promise is rejected.
38
-
39
- ___
40
-
41
- ### getUserInformationByExternalId
42
-
43
- ▸ **getUserInformationByExternalId**(`externalId`: *string*): *Promise*<[*SBUserProfile*](../wiki/Interface:%20SBUserProfile)\>
44
-
45
- Call to retrieve a user profile by its external ID.
46
-
47
- #### Parameters:
48
-
49
- | Name | Type | Description |
50
- | :------ | :------ | :------ |
51
- | `externalId` | *string* | An external ID of the user that shall be returned |
52
-
53
- **Returns:** *Promise*<[*SBUserProfile*](../wiki/Interface:%20SBUserProfile)\>
54
-
55
- A promise containing the SBUserProfile is returned. In case of an error,
56
- the promise is rejected.
57
-
58
- ___
59
-
60
- ### getUserList
61
-
62
- ▸ **getUserList**(`query`: [*UserListRequestQuery*](../wiki/Interface:%20UserListRequestQuery)): *Promise*<[*UserListResponse*](../wiki/Interface:%20UserListResponse)\>
63
-
64
- Call to retrieve a list of users determined by the query object.
65
-
66
- #### Parameters:
67
-
68
- | Name | Type | Description |
69
- | :------ | :------ | :------ |
70
- | `query` | [*UserListRequestQuery*](../wiki/Interface:%20UserListRequestQuery) | Adjust limit, offset, filter, and sorting for the request |
71
-
72
- **Returns:** *Promise*<[*UserListResponse*](../wiki/Interface:%20UserListResponse)\>
73
-
74
- A promise containing the UserListResponse is returned. In case of an error,
75
- the promise is rejected.
package/lib/base-block.ts DELETED
@@ -1,110 +0,0 @@
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
- /**
15
- * Base class for custom widgets.
16
- *
17
- * Should be used to extend other custom elements to render their content.
18
- * Provides common editing and render capabilities for Staffbase widgets.
19
- */
20
- export interface BaseBlock extends HTMLElement {
21
- /**
22
- * Called when the widget is rendered in a page.
23
- * Override this method in order to display your widget contents.
24
- *
25
- * Default implementation is a noop.
26
- *
27
- * @param container an `HTMLElement` into which the contents of the widget should be rendered.
28
- * Note that this does not necessarily have to be `this` since the base class might
29
- * render a title, a div with a border, or other decorations.
30
- */
31
- renderBlock(container: HTMLElement): void;
32
-
33
- /**
34
- * Called when the widget is rendered in the WYSIWYG editor.
35
- * override this method in order to display your widget preview.
36
- *
37
- * By default, the editor will display a generic placeholder
38
- * with the widget name and icon.
39
- *
40
- * @param container an `HTMLElement` into which the contents of the widget should be rendered
41
- * Note that this does not necessarily have to be `this` since the base class might
42
- * render a title, a div with a border, or other decorations.
43
- */
44
- renderBlockInEditor(container: HTMLElement): void;
45
-
46
- /**
47
- * Called when the widget is unmounted from the DOM.
48
- *
49
- * Override this in order to implement your unmount logic.
50
- *
51
- * @param container an `HTMLElement` which was used previously to render the widget.
52
- */
53
- unmountBlock(container: HTMLElement): void;
54
-
55
- /**
56
- * Called when an attribute is changed.
57
- *
58
- * Override this in order to get notified about new attribute values.
59
- *
60
- * NOTE: There are attributes that are common to all widgets. They are handled
61
- * inside the base block. Therefore, if you override this method, be sure to
62
- * call `super.attributeChangedCallback()` inside your implementation, in
63
- * order to let the base class know about the arguments that it might be interested in.
64
- */
65
- attributeChangedCallback(
66
- attrName: string,
67
- oldValue: string | undefined,
68
- newValue: string | undefined
69
- ): void;
70
-
71
- /**
72
- * Called after the dialog is closed and the attributes are set on the web component.
73
- *
74
- * Override this if the attributes are handled with a different logic then the default one.
75
- *
76
- * @param attributes A map of attributes, as defined in the block definition, which have the
77
- * types from the form data
78
- *
79
- * NOTE: The default implementation turns every value in a string, except arrays and object, which
80
- * are converted to base64 encoded data uris in the format `data:text/plain;base64,...`
81
- */
82
- parseConfig<T extends Record<string, any>>(attributes: T): Record<string, string>;
83
-
84
- /**
85
- * Called when the config dialog is opened. The dialog uses the parsed attributes, to fill
86
- * the fields with the existing values.
87
- *
88
- * Uses the property blockDefinition.attributes to parse each indidividual attribute and
89
- * returns it in the format, the configuration form needs. The common attributes are handled
90
- * externally
91
- *
92
- * This method is the counter part of parseConfig, the this must be implemented, if parseConfig
93
- * is overriden.
94
- *
95
- * NOTE: The default implementation converts every string to string, boolean or number and decodes
96
- * and parses the data uris to the arrays and objects. Dates are remaining a string!
97
- */
98
- parseAttributes<T extends Record<string, any>>(): T;
99
-
100
- /**
101
- * The content language as defined in the hosting system. Should be used to provide
102
- * the correct localization in the widget.
103
- *
104
- * NOTE: This is not necessarily the same as the UI language, which is defined by the browser.
105
- * When a widget is added to a specific content, the content-language attribute gets automatically set
106
- * to that language.
107
- */
108
- contentLanguage: string;
109
-
110
- }
@@ -1,101 +0,0 @@
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
- import { BlockFactory } from "./block-factory";
15
- import { JSONSchema7 } from "json-schema";
16
- import {UiSchema} from '@rjsf/core';
17
-
18
- export interface BlockDefinition<Factory = BlockFactory> {
19
- /**
20
- * The tag name of the widget. It must be compatible with
21
- * webcomponent naming conventions.
22
- *
23
- * @see https://www.webcomponents.org/community/articles/how-should-i-name-my-element
24
- */
25
- name: string;
26
-
27
- /**
28
- * The implementation of the web component.
29
- */
30
- factory: Factory;
31
-
32
- /**
33
- * Can be used for extending from a built-in element.
34
- */
35
- options?: ElementDefinitionOptions;
36
-
37
- /**
38
- * DOM attributes of the element, must be in kebab-case.
39
- */
40
- attributes: string[];
41
-
42
- /**
43
- * Set to `inline` if you want the element to behave like a span element
44
- * rather than a div element if not specified, it defaults to `block`.
45
- */
46
- blockLevel?: "block" | "inline";
47
-
48
- /**
49
- * Schema used for defining the configuration form.
50
- *
51
- * @example
52
- * ```json
53
- * {
54
- * "type": "object",
55
- * "required": [
56
- * "firstName",
57
- * "lastName"
58
- * ],
59
- * "properties": {
60
- * "firstName": {
61
- * "type": "string",
62
- * "title": "First name"
63
- * },
64
- * "lastName": {
65
- * "type": "string",
66
- * "title": "Last name"
67
- * }
68
- * }
69
- * }
70
- * ```
71
- * @see https://react-jsonschema-form.readthedocs.io/en/latest/
72
- */
73
- configurationSchema: JSONSchema7;
74
-
75
- /**
76
- *
77
- * Schema to add more customization to the look and feel of the configuration form.
78
- *
79
- * ```json
80
- * {
81
- * "firstName": {
82
- * "ui:help": "Your first name."
83
- * }
84
- * }
85
- * ```
86
- *
87
- * @see https://react-jsonschema-form.readthedocs.io/en/latest/api-reference/uiSchema/
88
- */
89
- uiSchema?: UiSchema;
90
-
91
- /**
92
- * Label displayed in the settings dialog and in the default widget preview.
93
- */
94
- label?: string;
95
-
96
- /**
97
- * Icon displayed on the widget installation page.
98
- * We recommend an icon with the dimensions 32x32 px.
99
- */
100
- iconUrl?: string;
101
- }
@@ -1,56 +0,0 @@
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
- export interface BlockElement {
15
- /**
16
- * Static getter to determine which HTML attributes should trigger the function 'attributeChangedCallback';
17
- */
18
- // readonly observedAttributes: string[];
19
-
20
- /**
21
- * Invoked when the custom element is first connected to the DOM.
22
- */
23
- connectedCallback: () => void;
24
-
25
- /**
26
- * Invoked when the custom element is disconnected from the DOM.
27
- */
28
- disconnectedCallback: () => void;
29
-
30
- /**
31
- * Invoked when the custom element is moved to a new document.
32
- */
33
- adoptedCallback: () => void;
34
-
35
- /**
36
- * Invoked when one of the attributes of the custom element is added, removed, or changed.
37
- *
38
- * Note that you have to statically register the observed values with the 'observedAttributes' static getter.
39
- *
40
- * @param attrName The changed attributes name
41
- * @param oldValue The old value
42
- * @param newValue The new value
43
- */
44
- attributeChangedCallback: (
45
- attrName: string,
46
- oldValue: string | undefined,
47
- newValue: string | undefined
48
- ) => void;
49
-
50
- /**
51
- * Method to unmount / revert any effects applied by rendering.
52
- * E.g. to be used in editor cases to remove any rendered content
53
- * and revert the block to its initial state.
54
- */
55
- unmount: () => void;
56
- }
package/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "commonjs",
5
- "noEmit": true,
6
-
7
- "strict": true,
8
-
9
- "moduleResolution": "node",
10
- "baseUrl": "./",
11
- "esModuleInterop": true
12
- }
13
- }