@brokerize/elements 1.1.0 → 1.2.0

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/CHANGELOG.md CHANGED
@@ -1,11 +1,30 @@
1
1
  # Changelog
2
2
 
3
+
4
+ # 1.2.0 (released 2025-04-24)
5
+
6
+ - `ADDED` the option to pass a `reportingTag` for `createOrderForm`, `createChangeOrderForm` and `createCancelOrderForm`
7
+ - `FIXED` a wrong label in order receipts for trailing stops
8
+ - `CHANGED` the OrderForm label for "legalHint" has been changed to "Rechtliche Hinweise"
9
+
10
+ # 1.1.1 (released 2025-03-31)
11
+
12
+ - `FIXED` cost label in OrderForm was wrong in some cases
13
+ - `FIXED` issues with number parsing in some environments
14
+ - `FIXED` formatting of staking positions information in portfolio tables
15
+ - `FIXED` validity date changes in ChangeOrder
16
+ - `CHANGED` support for strict content security policies by removing usages of `eval`
17
+ - `CHANGED` better looking countdown for quote trading
18
+ - `CHANGED` buying power in OrderForm now selects the cash account based on selected exchange
19
+ - `ADDED` order fees in order receipts
20
+
3
21
  # 1.1.0 (released 2024-12-06)
4
- - `CHANGED` opening a sessionTanForm now automatically requests the TAN from the API if there is exactly one method available with `flow=DECOUPLED`.
5
- - `ADDED` support for switching between the brokerize and DonauCapital order endpoints via the `tradingViaCryptoService` flag. If your client supports crypto trading, you have to add a `basePathCryptoService` option next to `basePath` in the `BrokerizeConfig`. The URLs will be provided to you. The elements will then automatically direct createTrade, changeOrder and cancelOrder requests to that service and display the corresponding provider logo in the UI.
6
- - `FIXED` hide cash account select when there is actually nothing to choose for the user.
7
- - `FIXED` number input behavior if the input is restricted to have 0 decimal places.
8
- - `CHANGED` `getQuote` is now called with the selected `sellPositionId`, if applicable.
22
+
23
+ - `CHANGED` opening a sessionTanForm now automatically requests the TAN from the API if there is exactly one method available with `flow=DECOUPLED`.
24
+ - `ADDED` support for switching between the brokerize and DonauCapital order endpoints via the `tradingViaCryptoService` flag. If your client supports crypto trading, you have to add a `basePathCryptoService` option next to `basePath` in the `BrokerizeConfig`. The URLs will be provided to you. The elements will then automatically direct createTrade, changeOrder and cancelOrder requests to that service and display the corresponding provider logo in the UI.
25
+ - `FIXED` hide cash account select when there is actually nothing to choose for the user.
26
+ - `FIXED` number input behavior if the input is restricted to have 0 decimal places.
27
+ - `CHANGED` `getQuote` is now called with the selected `sellPositionId`, if applicable.
9
28
 
10
29
  # 1.0.4 (released 2024-10-28)
11
30
 
package/README.md CHANGED
@@ -1,12 +1,10 @@
1
1
  # brokerize elements
2
2
 
3
- `brokerize elements` is the official UI elements library for the brokerize API. Together with `@brokerize/client` it provides drop-in brokerage UI elements for various trading use cases.
3
+ `@brokerize/elements` is the official UI library for the brokerize API. Together with `@brokerize/client` it provides drop-in brokerage UI elements for various trading use cases.
4
4
 
5
5
  # how to install
6
6
 
7
- The brokerize client libraries are publicly available, so you can just install them like any other npm package:
8
-
9
- Once you have the token, this is how you add it to a project:
7
+ The brokerize client libraries are publicly available, so you can install them like any other npm package:
10
8
 
11
9
  ```
12
10
  $ npm init -y
@@ -24,26 +22,36 @@ const brokerizeClient = new Brokerize({
24
22
  // API configuration
25
23
  basePath: BROKERIZE_API_URL /* https://api-preview.brokerize.com for our preview environment */,
26
24
  clientId: '<YOUR-API-CLIENT-ID>',
27
- cognito: {
28
- Endpoint: '<PROVIDED-COGNITO-ENDPOINT>',
29
- ClientId: '<PROVIDED-COGNITO-CLIENT-ID>',
30
- UserPoolId: '<PROVIDED-COGNITO-USERPOOL-ID>'
31
- },
32
25
  // provide global dependencies
33
- fetch: globalThis.fetch.bind(globalThis),
34
- createAbortController: () => new AbortController(),
35
- createWebSocket: (url, protocol) => new WebSocket(url, protocol)
26
+ fetch: globalThis.fetch.bind(globalThis), // optionally, a custom fetch implementation can be used
27
+ createAbortController: () => new AbortController(), // optionally, a custom AbortController can be used
28
+ createWebSocket: (url, protocol) => new WebSocket(url, protocol) // optionally, a custom WebSocket implementation can be used
36
29
  });
37
30
  ```
38
31
 
39
- | Property | Description | optional |
40
- | :-------------------- | ---------------------------------------------------------------------------------------------------------------------- | :------: |
41
- | basePath | The API base path | &#10060; |
42
- | clientId | Your Client ID for the brokerize API | &#10060; |
43
- | cognito | Configuration for logging in brokerize users (not relevant for most clients) | &#9989; |
44
- | fetch | Optional custom implementation of `fetch` | &#9989; |
45
- | createAbortController | Optional create function (should return an instance of `AbortController` that is compatible with the provided `fetch`) | &#9989; |
46
- | createWebSocket | Optional create function for WebSockets | &#9989; |
32
+ Applications create temporary brokerize guest users for accessing the API. This code creates a guest user with the API and a corresponding `AuthorizedApiContext`:
33
+
34
+ ```typescript
35
+ const user = await brokerizeClient.createGuestUser();
36
+ const apiCtx = brokerizeClient.createAuthorizedContext(user);
37
+ ```
38
+
39
+ `apiCtx` can now be used to interact with the API in the scope if the newly created user (you can also use that instance directly in your application code). The `user` object can be stored as JSON in order to authenticate as the same user again. Note that the created credentials' lifetime depends on the client configuration. By default, those temporary users are deleted at night.
40
+
41
+ Now that you have a brokerize client instance as well as an `AuthorizedApiContext`, you can show the list of available brokers (or any other view) like this:
42
+
43
+ ```
44
+ createBrokerList({
45
+ authorizedApiContext,
46
+ theme,
47
+ addFrame,
48
+ renderTo,
49
+ onLogin({ brokerName }) {
50
+ // show the login process for broker `brokerName` here
51
+ },
52
+ openExternalLink
53
+ });
54
+ ```
47
55
 
48
56
  ## theming
49
57
 
@@ -138,6 +146,8 @@ createBrokerList({
138
146
 
139
147
  ## BrokerLoginForm
140
148
 
149
+ **NOTE**: `createBrokerLoginForm` does not actually present a login form directly in most cases but rather triggers an OAuth redirect. This depends on the client configuration and specific demands of brokers and/or partners. By default, all brokers use an OAuth-style login flow.
150
+
141
151
  ```typescript
142
152
  createBrokerLoginForm({
143
153
  authorizedApiContext,
@@ -190,66 +200,6 @@ createBrokerLoginForm({
190
200
  | login | is fired when the user has successfully logged in |
191
201
  | redirect | is fired when a redirect to the broker login page should take place |
192
202
 
193
- ## Brokerize Login
194
-
195
- As described in the OpenAPI specification, users can either log in with their brokerize account or create a guest user. This will create a guest user with the API and a corresponding `AuthorizedApiContext`:
196
-
197
- ```typescript
198
- const user = await brokerizeClient.createGuestUser();
199
- const apiCtx = brokerizeClient.createAuthorizedContext(user);
200
- ```
201
-
202
- `apiCtx` can now be used to interact with the API (you can also use that instance directly in your application code).
203
-
204
- If you want to support users to choose between logging in with their brokerize credentials or using a guest account, use `LoginForm` to retrieve either `AuthorizedApiContext` like this:
205
-
206
- ```javascript
207
- Brokerize.Elements.createLoginForm({
208
- renderTo: $el,
209
- theme,
210
- addFrame,
211
- client: brokerizeClient,
212
- onGuestLogin() {
213
- client.createGuestUser().then(
214
- (authCtxCfg) => {
215
- setLogin(authCtxCfg);
216
- },
217
- (err) => showError(err)
218
- );
219
- },
220
- onLogin(authCtxCfg) {
221
- setLogin(authCtxCfg);
222
- },
223
- openExternalLink
224
- });
225
-
226
- function setLogin(authCtxCfg) {
227
- apiCtx = client.createAuthorizedContext(cfg);
228
- }
229
- ```
230
-
231
- <img src="example-screenshots/brokerize-login.png" width="500"/>
232
-
233
- ### web component
234
-
235
- ```html
236
- <brokerize-login ... />
237
- ```
238
-
239
- ### properties
240
-
241
- | Property | Description | optional |
242
- | :------- | -------------------------------------------------------------------------------------------------------------- | :------: |
243
- | client | Instance of the `@brokerize/client` | &#10060; |
244
- | theme | You can use the <a href="https://app.brokerize.com/theming">brokerize theme designer</a> to build a theme JSON | &#9989; |
245
-
246
- ### events
247
-
248
- | event | Description |
249
- | :---- | ------------------------------------------------- |
250
- | guest | is fired when the user clicks the guest login |
251
- | login | is fired when the user has successfully logged in |
252
-
253
203
  ## Brokerize Main
254
204
 
255
205
  The main component is the default goto component for the simplest and quickest brokerize experience, as all the default behavior is already interconnected and ready to use. You just need to integrate this one component and can use all of brokerize's features.
package/dist/bundle.d.ts CHANGED
@@ -54,7 +54,6 @@ export declare type BrokerizeElement = {
54
54
  export declare type BrokerizeElements = {
55
55
  createBrokerizeMain: (cfg: BrokerizeMainConfig) => BrokerizeMainElement;
56
56
  createBrokerList: (cfg: BrokerListConfig) => BrokerizeElement;
57
- createLoginForm: (cfg: LoginFormConfig) => BrokerizeElement;
58
57
  createBrokerLoginForm: (cfg: BrokerLoginFormConfig) => BrokerizeElement;
59
58
  createOrderForm: (cfg: OrderFormConfig) => BrokerizeElement;
60
59
  createPortfolioTable: (cfg: PortfolioTableConfig) => BrokerizeElement;
@@ -67,6 +66,7 @@ export declare type BrokerizeElements = {
67
66
  createSessionsTable: (cfg: SessionsTableConfig) => BrokerizeElement;
68
67
  createPortfolioView: (cfg: PortfolioViewConfig) => BrokerizeElement;
69
68
  createModalHost: (cfg: ModalHostConfig) => BrokerizeElement;
69
+ createStylingUIExample: (cfg: StylingUIExampleConfig) => BrokerizeElement;
70
70
  modalService: ModalService;
71
71
  /**
72
72
  * Configure global settings for Brokerize Elements. The global configuration is shared across all instances of Brokerize Elements.
@@ -164,11 +164,19 @@ export declare type CancelOrderFormConfig = {
164
164
  orderId: string;
165
165
  onExit: () => void;
166
166
  onNavigate: (linkTarget: LinkTarget) => void;
167
+ /**
168
+ * Optional `reportingTag` to send with order creates. ReportingTags appear in order reports.
169
+ */
170
+ reportingTag?: string;
167
171
  } & BrokerizeBaseConfig;
168
172
 
169
173
  export declare type ChangeOrderFormConfig = {
170
174
  orderId: string;
171
175
  onExit: () => void;
176
+ /**
177
+ * Optional `reportingTag` to send with order creates. ReportingTags appear in order reports.
178
+ */
179
+ reportingTag?: string;
172
180
  } & BrokerizeBaseConfig;
173
181
 
174
182
  export { Client }
@@ -306,6 +314,31 @@ export declare type DataCellValueString = {
306
314
  cssConfig?: any;
307
315
  };
308
316
 
317
+ /**
318
+ * For generic application dialogs: a configuration for the dialog, including a
319
+ * headline title, a content text and a list of input boxes where users may enter data.
320
+ */
321
+ export declare type DialogConfig = {
322
+ title?: string;
323
+ content?: string;
324
+ inputConfigs: InputConfig[];
325
+ };
326
+
327
+ /**
328
+ * Result of a `ModalService.showDialog(...)` operation.
329
+ */
330
+ export declare type DialogResult = DialogResultCancel | DialogResultOk;
331
+
332
+ /**
333
+ * For generic dialogs: the result when the user has canceled the dialog.
334
+ */
335
+ export declare type DialogResultCancel = { response: 'cancel' };
336
+
337
+ /**
338
+ * For generic dialogs: the result when user has entered data and confirmed the dialog.
339
+ */
340
+ export declare type DialogResultOk = { response: 'ok'; inputs: InputConfig[] };
341
+
309
342
  export declare type DownloadedFile = {
310
343
  blob: Blob;
311
344
  filename: string;
@@ -335,6 +368,15 @@ declare type Image_2 = {
335
368
  };
336
369
  export { Image_2 as Image }
337
370
 
371
+ export declare type InputConfig = {
372
+ id?: string;
373
+ defaultValue?: string;
374
+ inputLabel: string;
375
+ placeholder?: string;
376
+ required?: boolean;
377
+ value?: string;
378
+ };
379
+
338
380
  export declare type LinkTarget = {
339
381
  type: 'portfolio';
340
382
  portfolioId: string;
@@ -350,20 +392,32 @@ export declare type ModalHostConfig = { showToast?: ShowToast } & BrokerizeBaseC
350
392
 
351
393
  export declare interface ModalService {
352
394
  showSecurityInformation(title: string, content: string): void;
395
+
353
396
  showConfirm(msg: string): Promise<boolean>;
397
+
398
+ showDialog(dialogConfig: DialogConfig): Promise<DialogResult>;
399
+
354
400
  showSessionTanModal(sessionId: string): void;
401
+
355
402
  activate(): void;
403
+
356
404
  deactivate(): void;
405
+
357
406
  override(overrides: Partial<ModalService>): void;
407
+
358
408
  showReceipt(data: ReceiptData, showActions: boolean, handleOrderTableAction: (e: any) => void): void;
409
+
359
410
  showDetailedTable(table: Models.GenericTable): void;
411
+
360
412
  showPositionDetail(
361
413
  position: Models.Position,
362
414
  row?: TableRow,
363
415
  header?: Header,
364
416
  handleTableAction?: (actionId: string, rowId: string) => void
365
417
  ): void;
418
+
366
419
  showLoginForm(brokerName: any, returnToUrl: string, redirect: (redirecTo: string) => void): void;
420
+
367
421
  showToast(opts: ToastOptions): void;
368
422
  }
369
423
 
@@ -421,6 +475,10 @@ export declare type OrderFormConfig = {
421
475
  * If custom quotes should be shown in the order form, provide an implementation of `SecurityQuotesProvider`.
422
476
  */
423
477
  quotesProvider?: SecurityQuotesProvider;
478
+ /**
479
+ * Optional `reportingTag` to send with order creates. ReportingTags appear in order reports.
480
+ */
481
+ reportingTag?: string;
424
482
  } & BrokerizeBaseConfig;
425
483
 
426
484
  export declare type OrderFormInitialOrder = Partial<
@@ -542,6 +600,10 @@ export declare type SessionTanFormConfig = {
542
600
 
543
601
  export declare type ShowToast = (opts: ToastOptions) => void;
544
602
 
603
+ export declare type StylingUIExampleConfig = {
604
+ theme: Theme;
605
+ } & BrokerizeBaseConfig;
606
+
545
607
  export declare type SupportLink = {
546
608
  emailSubject: string;
547
609
  };
@@ -602,7 +664,6 @@ export declare type ThemeTokens = {
602
664
  'zl-btn-border-radius'?: string;
603
665
  'zl-btn-border-style'?: string;
604
666
  'zl-btn-border-width'?: string;
605
- 'zl-btn-countdown-bar-color'?: string;
606
667
  'zl-btn-default-color'?: string;
607
668
  'zl-btn-focus-background-image'?: string;
608
669
  'zl-btn-focus-color'?: string;
@@ -618,7 +679,6 @@ export declare type ThemeTokens = {
618
679
  'zl-btn-md-padding-y'?: string;
619
680
  'zl-btn-muted-color'?: string;
620
681
  'zl-btn-outlined-color'?: string;
621
- 'zl-btn-progessbar-height'?: string;
622
682
  'zl-btn-sm-font-size'?: string;
623
683
  'zl-btn-sm-padding-x'?: string;
624
684
  'zl-btn-sm-padding-y'?: string;