@appsemble/sdk 0.39.2 → 0.40.1

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 (3) hide show
  1. package/README.md +3 -3
  2. package/index.d.ts +53 -3
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.39.2/config/assets/logo.svg) Appsemble SDK
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.40.1/config/assets/logo.svg) Appsemble SDK
2
2
 
3
3
  > Build your own blocks
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/sdk)](https://www.npmjs.com/package/@appsemble/sdk)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.39.2/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.39.2)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.40.1/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.40.1)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -153,5 +153,5 @@ declare module '@appsemble/sdk' {
153
153
 
154
154
  ## License
155
155
 
156
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.39.2/LICENSE.md) ©
156
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.40.1/LICENSE.md) ©
157
157
  [Appsemble](https://appsemble.com)
package/index.d.ts CHANGED
@@ -1,13 +1,46 @@
1
- import { type Action, type ActionError, type BaseMessage, type Theme } from '@appsemble/lang-sdk';
1
+ import { type Action, type ActionError, type BaseMessage, type IconReference, type IconRegistry, type IconRegistryEntry, type Theme } from '@appsemble/lang-sdk';
2
2
  import { type BulmaColor, type BulmaSize } from '@appsemble/types';
3
3
  import { type IconName } from '@fortawesome/fontawesome-common-types';
4
4
  import { type Promisable } from 'type-fest';
5
- export { type IconName };
5
+ export { type IconName, type IconReference, type IconRegistry, type IconRegistryEntry };
6
6
  export { type Action, type BulmaColor, type BulmaSize, type Theme };
7
7
  /**
8
8
  * A user defined remapper function.
9
9
  */
10
10
  export type Remapper = object[] | boolean | number | object | string;
11
+ /**
12
+ * Options for rendering an icon.
13
+ */
14
+ export interface IconRenderOptions {
15
+ /**
16
+ * An additional CSS class to apply to the outer `.icon` wrapper.
17
+ */
18
+ className?: string;
19
+ /**
20
+ * The Bulma size modifier of the wrapper.
21
+ */
22
+ size?: BulmaSize;
23
+ /**
24
+ * The size modifier of a Font Awesome glyph. Defaults to a value derived from `size`.
25
+ *
26
+ * Custom icons fill the wrapper, so only `size` affects them.
27
+ */
28
+ iconSize?: '2x' | '3x' | 'lg';
29
+ }
30
+ /**
31
+ * An icon reference resolved against the app’s icon registry.
32
+ *
33
+ * Invalid references, including registry keys which don’t exist, never produce a URL.
34
+ */
35
+ export type RenderableIcon = {
36
+ type: 'asset';
37
+ url: string;
38
+ } | {
39
+ type: 'fontawesome';
40
+ name: IconName;
41
+ } | {
42
+ type: 'invalid';
43
+ };
11
44
  /**
12
45
  * Actions defined on a block.
13
46
  *
@@ -107,7 +140,7 @@ export interface MenuItem {
107
140
  /**
108
141
  * The icon to display next to the title.
109
142
  */
110
- icon?: IconName;
143
+ icon?: IconReference;
111
144
  /**
112
145
  * The color to use for the icon.
113
146
  */
@@ -192,6 +225,23 @@ export interface BlockUtils extends Utils {
192
225
  * @returns String containing the FontAwesome classes for the icon.
193
226
  */
194
227
  fa: (icon: IconName) => string;
228
+ /**
229
+ * Resolve a Font Awesome icon name or an `icon:<key>` reference against the app’s icon registry.
230
+ *
231
+ * @param reference The icon reference to resolve.
232
+ * @returns A Font Awesome name, the URL of a custom icon asset, or an invalid result.
233
+ */
234
+ resolveIcon: (reference: IconReference) => RenderableIcon;
235
+ /**
236
+ * Create a DOM element rendering a Font Awesome icon or a custom icon from the app’s registry.
237
+ *
238
+ * Each call returns a fresh `.icon` wrapper. Replace the element when the reference changes.
239
+ *
240
+ * @param reference The icon reference to render.
241
+ * @param options Rendering options.
242
+ * @returns A span element containing the glyph or image.
243
+ */
244
+ icon: (reference: IconReference, options?: IconRenderOptions) => HTMLSpanElement;
195
245
  /**
196
246
  * @param items The list of menu items to display.
197
247
  * @param header A header that can be used to separate from other block menus.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/sdk",
3
- "version": "0.39.2",
3
+ "version": "0.40.1",
4
4
  "description": "Build your own blocks",
5
5
  "keywords": [
6
6
  "app",
@@ -43,8 +43,8 @@
43
43
  "test": "vitest"
44
44
  },
45
45
  "dependencies": {
46
- "@appsemble/types": "0.39.2",
47
- "@appsemble/lang-sdk": "0.39.2",
46
+ "@appsemble/types": "0.40.1",
47
+ "@appsemble/lang-sdk": "0.40.1",
48
48
  "@fortawesome/fontawesome-common-types": "^6.0.0",
49
49
  "type-fest": "^4.0.0"
50
50
  },