You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/pluggable-widgets/_index.md
+43-43Lines changed: 43 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,9 @@ weight: 90
11
11
12
12
Mendix comes with a wide variety of [Widgets](/refguide/pages/#widgets-categories), but sometimes your app requires a widget outside of this set. To support a more advanced UI pattern or create app-specific interactions, you will need to make your own pluggable widget. This documentation will help you achieve that in Studio Pro 11. See these links for other versions' documentation:
Your new pluggable widget can be used while modeling pages alongside standard Mendix components. It can also be shared between multiple apps and distributed through the [Marketplace](/appstore/).
19
19
@@ -23,7 +23,7 @@ Pluggable widgets, like core widgets, can have properties which a Mendix develop
23
23
24
24
Pluggable widgets can also include a preview component for when they are previewed in Studio Pro's **Design mode**.
25
25
26
-
For information on which libraries Mendix supports when developing pluggable widgets, see the [Pluggable Widgets](/refguide/mendix-client/#pluggable-widgets) section of _Mendix Client_.
26
+
For information on which libraries Mendix supports when developing pluggable widgets, see the [Pluggable Widgets](/refguide/mendix-client/#pluggable-widgets) section of *Mendix Client*.
27
27
28
28
For information on how to update Pluggable Widgets Tools to a newer version, see [Updating Pluggable Widgets Tools](/howto/extensibility/update-pluggable-widgets-tools/)
29
29
@@ -42,38 +42,38 @@ A widget component is [mounted](https://en.reactjs.org/docs/react-component.html
42
42
A prop value is often not just a primitive value, but an object whose structure depends on the [`type`](#type-attribute) of its widget's property. A prop's values can expose data, metadata, and associated actions — whatever is applicable for the property. Here is an example of one interface. It is a value for an action property, such as the type you would find in the [On click](/refguide/on-click-event/#on-click) property of an action button:
43
43
44
44
```ts
45
-
exportinterfaceActionValue {
46
-
readonly canExecute:boolean;
47
-
readonly isExecuting:boolean;
48
-
execute():void;
49
-
}
45
+
exportinterfaceActionValue {
46
+
readonly canExecute:boolean;
47
+
readonly isExecuting:boolean;
48
+
execute():void;
49
+
}
50
50
```
51
51
52
-
The above interface could be used this way: a component uses a `canExecute` flag to decide whether it should be enabled, uses an `isExecuting` flag to show an inline progress indicator, and triggers `execute()` method in a reaction to user click. Normally, after `execute()` has been triggered, the component will be re-rendered with a new value that has the `isExecuting` flag set, and when an action, for example a microflow, completes, the component is re-rendered again without `isExecuting`.
52
+
The above interface could be used this way: a component uses a `canExecute`flag to decide whether it should be enabled, uses an `isExecuting` flag to show an inline progress indicator, and triggers `execute()` method in a reaction to user click. Normally, after `execute()` has been triggered, the component will be re-rendered with a new value that has the `isExecuting` flag set, and when an action, for example a microflow, completes, the component is re-rendered again without `isExecuting`.
53
53
54
54
## Widget Package {#widget-package}
55
55
56
-
A pluggable widget is distributed as single widget package file with an _.mpk_ extension. This file should be placed in your app's `widgets` directory. Mendix Studio Pro discovers all widgets in your app when you open your app, add a widget through the Marketplace, or click **App** > **Synchronize App Directory**.
56
+
A pluggable widget is distributed as single widget package file with an *.mpk* extension. This file should be placed in your app's `widgets` directory. Mendix Studio Pro discovers all widgets in your app when you open your app, add a widget through the Marketplace, or click **App** > **Synchronize App Directory**.
57
57
58
58
Manually building a widget package can be difficult, so Mendix recommends you use scripts provided by the [Mendix Pluggable Widget Generator](https://www.npmjs.com/package/@mendix/generator-widget). For more information on how to use a generator, see [How To Build a Text Box Pluggable Widget: Part 1](/howto/extensibility/create-a-pluggable-widget-one/).
59
59
60
60
A widget package file is just a ZIP archive containing the following things:
61
61
62
-
- A _package.xml_ file describing the whole package
63
-
- A widget definition XML file, preferably located in _{widgetName}.xml_ where `widgetName` is the last part of widget [ID](#widget-id)
64
-
- A client component of a widget located, for example, in _com/mendix/widget/MyProgressCircle.js_ for a widget with the ID `com.mendix.widget.MyProgressCircle`
65
-
- Optionally, a widget preview Studio Pro’s **Design mode** located in _{widgetName}.editorPreview.js_
66
-
- Optionally, widget icons (which must be the PNG format):
67
-
-_{widgetName}.icon.png_ sets the widget icon inside the Studio Pro toolbox in list view (the ideal image size is 64x64 pixels, but other sizes will be resized to fit)
68
-
-_{widgetName}.icon.dark.png_ sets the dark-mode equivalent to _{widgetName}.icon.png_
69
-
-_{widgetName}.tile.png_ sets the tile image inside the Studio Pro toolbox in tile view (the ideal image size is 256x192 pixels, but other sizes will be resized to fit)
70
-
-_{widgetName}.tile.dark.png_ sets the dark-mode equivalent to _{widgetName}.tile.png_
71
-
- Optionally, some widget-related resources, preferably located next to the file which contains the client component
72
-
- Note that all CSS files you add (except the one located in the **lib** sub-directory) will automatically be loaded in an app via the widget
62
+
* A *package.xml* file describing the whole package
63
+
* A widget definition XML file, preferably located in *{widgetName}.xml* where `widgetName` is the last part of widget [ID](#widget-id)
64
+
* A client component of a widget located, for example, in *com/mendix/widget/MyProgressCircle.js* for a widget with the ID `com.mendix.widget.MyProgressCircle`
65
+
* Optionally, a widget preview Studio Pro’s **Design mode** located in *{widgetName}.editorPreview.js*
66
+
* Optionally, widget icons (which must be the PNG format):
67
+
**{widgetName}.icon.png* sets the widget icon inside the Studio Pro toolbox in list view (the ideal image size is 64x64 pixels, but other sizes will be resized to fit)
68
+
**{widgetName}.icon.dark.png* sets the dark-mode equivalent to *{widgetName}.icon.png*
69
+
**{widgetName}.tile.png* sets the tile image inside the Studio Pro toolbox in tile view (the ideal image size is 256x192 pixels, but other sizes will be resized to fit)
70
+
**{widgetName}.tile.dark.png* sets the dark-mode equivalent to *{widgetName}.tile.png*
71
+
* Optionally, some widget-related resources, preferably located next to the file which contains the client component
72
+
* Note that all CSS files you add (except the one located in the **lib** sub-directory) will automatically be loaded in an app via the widget
73
73
74
-
Naming your widget package file after the `widgetName` is best practice. Also, a widget package can include multiple widgets by putting several of the above items in the same widget package. However, creating such packages is _not recommended_.
74
+
Naming your widget package file after the `widgetName` is best practice. Also, a widget package can include multiple widgets by putting several of the above items in the same widget package. However, creating such packages is *not recommended*.
75
75
76
-
The _package.xml_ file has the following structure:
76
+
The *package.xml* file has the following structure:
77
77
78
78
```xml
79
79
<?xml version="1.0" encoding="utf-8" ?>
@@ -123,20 +123,20 @@ Here is an example of a widget’s attributes section:
123
123
124
124
This section is generated based on options chosen while running the Mendix Pluggable Widget Generator. You will rarely need to modify it after it is generated. This sample widget features several widget attributes:
125
125
126
-
-`id`<aid="widget-id"></a> — This the fully qualified name of the widget called widget ID. Using widget ID, the Mendix Platform distinguishes widgets from each other. Widget ID should never be changed after a widget is used in an app or is published in the Marketplace. Reverse domain-style names, as in example above, are recommended.
127
-
-`pluginWidget` — This should always be set to `true`. This way, the Mendix Platform can distinguish between the newer pluggable widgets and the older custom widgets.
128
-
-`offlineCapable` — This shows if a widget can work while an app is offline. For more information on offline apps, see the [Offline-First](/refguide/offline-first/) guide. A widget that fetches information from a third-party API, for example a widget that fetches airline ticket prices, could not function without an internet connection. If a widget cannot work offline, Mendix Studio Pro will forbid its use on pages that must be available offline.
129
-
-`supportedPlatform` — This shows the platforms a widget is compatible with. `Web` describes widgets that are only compatible with web and hybrid mobile apps. `Native` describes widgets that are compatible with native mobile apps.
126
+
*`id`<aid="widget-id"></a> — This the fully qualified name of the widget called widget ID. Using widget ID, the Mendix Platform distinguishes widgets from each other. Widget ID should never be changed after a widget is used in an app or is published in the Marketplace. Reverse domain-style names, as in example above, are recommended.
127
+
*`pluginWidget` — This should always be set to `true`. This way, the Mendix Platform can distinguish between the newer pluggable widgets and the older custom widgets.
128
+
*`offlineCapable` — This shows if a widget can work while an app is offline. For more information on offline apps, see the [Offline-First](/refguide/offline-first/) guide. A widget that fetches information from a third-party API, for example a widget that fetches airline ticket prices, could not function without an internet connection. If a widget cannot work offline, Mendix Studio Pro will forbid its use on pages that must be available offline.
129
+
*`supportedPlatform` — This shows the platforms a widget is compatible with. `Web` describes widgets that are only compatible with web and hybrid mobile apps. `Native` describes widgets that are compatible with native mobile apps.
130
130
131
131
### Widget Description {#widget-description}
132
132
133
-
The presentation of the widget in Studio Pro is determined by the first set of elements inside the widget tag. The order of these descriptive tags is important, and is demonstrated in the list below. Only the name and description tags are mandatory — the others are optional. The description can be omitted with a self-closing tag: `<description />`:
133
+
The presentation of the widget in Studio Pro is determined by the first set of elements inside the widget tag. The order of these descriptive tags is important, and is demonstrated in the list below. Only the name and description tags are mandatory — the others are optional. The description can be omitted with a self-closing tag: `<description />`:
134
134
135
-
-`name` — The display name of the widget.
136
-
-`description` — A short written description of the widget.
137
-
-`studioProCategory` — See [Toolbox Category](#toolbox-category).
138
-
-`helpUrl` — See [Help Page](#help).
139
-
-`icon` — See [Icon](#icon).
135
+
*`name` — The display name of the widget.
136
+
*`description` — A short written description of the widget.
137
+
*`studioProCategory` — See [Toolbox Category](#toolbox-category).
138
+
*`helpUrl` — See [Help Page](#help).
139
+
*`icon` — See [Icon](#icon).
140
140
141
141
```xml
142
142
<name>My Progress Card</name>
@@ -151,9 +151,9 @@ In Mendix Studio Pro, the widget described above would look like this:
151
151
152
152
#### Toolbox Category {#toolbox-category}
153
153
154
-
To provide more clarity for Studio Pro users you can specify a toolbox category for your widgets. When provided, it determines a toolbox category for a widget in Studio Pro. It is possible to specify existing built-in categories such as **Data** or **Input** as well as new arbitrary categories like **Maps**.
154
+
To provide more clarity for Studio Pro users you can specify a toolbox category for your widgets. When provided, it determines a toolbox category for a widget in Studio Pro. It is possible to specify existing built-in categories such as **Data** or **Input** as well as new arbitrary categories like **Maps**.
155
155
156
-
When an existing category is specified, then your widget is placed in it next to existing built-in widgets. When a new category is specified, then your widget placed in that new category.
156
+
When an existing category is specified, then your widget is placed in it next to existing built-in widgets. When a new category is specified, then your widget placed in that new category.
157
157
158
158
A category can be provided through the `studioProCategory` tag:
159
159
@@ -181,9 +181,9 @@ A URL of a help page can be provided through the `helpUrl` property after the `d
181
181
182
182
For more complex help pages you can link to a markdown page. For security reasons, URLs have the following restrictions:
183
183
184
-
- Must use HTTPS protocol
185
-
- Host name must end with _.mendix.com_ or _github.com_
186
-
- If host name is _github.com_ the full URL must end with _.md_
184
+
* Must use HTTPS protocol
185
+
* Host name must end with *.mendix.com* or *github.com*
186
+
* If host name is *github.com* the full URL must end with *.md*
187
187
188
188
#### Icon {#icon}
189
189
@@ -385,10 +385,10 @@ This section will explain the shape of the widget property. For more detailed in
385
385
386
386
Some properties can or must have more attributes or tags. This depends on the `type` property. The following elements should be present for every property:
387
387
388
-
-`key`<aid="key-attribute"></a> — This element is a property's unique, single-word identifier. The `key` elements are used internally to identify properties, so they should never change after a widget is used in an app or is published in the Marketplace. A `key` element also identifies a property value when it is passed to a pluggable widget’s client component.
389
-
-`type`<aid="type-attribute"></a> — This element is a property's type. The `type` element defines which values can be configured for a property, which UI is used in the Mendix Studio Pro, and what type of value a pluggable widget’s client component receives.
390
-
-`caption` — This element is a short label identifying a property to a modeling developer. The first letter of a caption should be capitalized.
391
-
-`description` — This element is a longer description of a property. A description should be capitalized and limited to one or two sentences.
388
+
*`key`<aid="key-attribute"></a> — This element is a property's unique, single-word identifier. The `key` elements are used internally to identify properties, so they should never change after a widget is used in an app or is published in the Marketplace. A `key` element also identifies a property value when it is passed to a pluggable widget’s client component.
389
+
*`type`<aid="type-attribute"></a> — This element is a property's type. The `type` element defines which values can be configured for a property, which UI is used in the Mendix Studio Pro, and what type of value a pluggable widget’s client component receives.
390
+
*`caption` — This element is a short label identifying a property to a modeling developer. The first letter of a caption should be capitalized.
391
+
*`description` — This element is a longer description of a property. A description should be capitalized and limited to one or two sentences.
392
392
393
393
Here is how a caption and description look in Studio Pro:
0 commit comments