@blackcube/aurelia-kit 1.0.0-rc1 → 1.0.0-rc3

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/README.md CHANGED
@@ -12,7 +12,7 @@ widgets, styled with Tailwind classes written in the PHP markup. The HTTP layer
12
12
  npm install @blackcube/aurelia-kit @blackcube/aurelia-api
13
13
  ```
14
14
 
15
- Peer dependencies: `aurelia` `^2.0.0-rc.2`, `@blackcube/aurelia-api` `^1.0.0`.
15
+ Peer dependencies: `aurelia` `^2.0.0-rc.2`, `@blackcube/aurelia-api` `^1.0.0-rc1`.
16
16
 
17
17
  The package is ESM only (`dist/index.es.js`, built by Vite in library mode); the application bundler resolves it.
18
18
 
@@ -101,6 +101,7 @@ sends. Its template holds no markup of its own:
101
101
  <au-slot name="loader" if.bind="loading"><progress></progress></au-slot>
102
102
  <template else>
103
103
  <au-compose if.bind="contentView" template.bind="contentView"></au-compose>
104
+ <au-slot else></au-slot>
104
105
  </template>
105
106
  </dialog>
106
107
  ```
@@ -140,12 +141,17 @@ Behavior:
140
141
  - `content` is the whole HTML of the dialog (frame, header, body, footer), rendered by the server; it becomes the
141
142
  view of the `au-compose`, so the `bleet-*` attributes it holds work. A response without `content` keeps the
142
143
  current view.
144
+ - `Open` (or `Toggle` when closed) with a `content` and no `url`: that HTML is shown as the server's would be, without
145
+ request (the same view, its `bleet-*` attributes, its forms posted by the element) — a page that already holds the
146
+ HTML (a confirmation, a `<template>` of the page).
143
147
  - A `<form>` submitted inside the dialog is posted by the element (multipart, method from `_method` or the form,
144
148
  POST by default, with the clicked submit button `name` / `value`); its `IDialogResponse` is applied the same way.
145
149
  - A `<form>` marked `data-dialog="native"` is not intercepted: the browser submits it (download, plain post).
146
150
  - A click on an element inside `[data-dialog="close"]`, the Escape key, or a click on the overlay closes the dialog
147
151
  with the hide transition; closing empties the view. A `cancel` coming from an `<input type="file">` (file chooser
148
152
  dismissed) does not close it. An `Open` received while the dialog is closing cancels the closing.
153
+ - Escape while a menu of the dialog is open (`[aria-expanded="true"]`: `bleet-dropdown`, `bleet-profile`) closes
154
+ that menu, not the dialog.
149
155
  - Statuses `Opening`, `Opened`, `Closing`, `Closed` (with the `id`) on `Channels.ModalStatus`.
150
156
 
151
157
  ```typescript
@@ -163,6 +169,28 @@ interface IDialogResponse {
163
169
 
164
170
  PHP side, `AureliaCommunication::dialogContent($content, $color)` builds the `content` / `color` part of it.
165
171
 
172
+ **In a SPA**, the content is the application's: its frame and its view go in the default slot of `<bleet-dialog>`,
173
+ written once in the shell, and the dialog is opened without `url`:
174
+
175
+ ```html
176
+ <bleet-dialog id="drawer"
177
+ data-dialog-class="… translate-x-full"
178
+ data-dialog-show="translate-x-0"
179
+ data-dialog-hide="translate-x-full">
180
+ <header …>${$host.title} <button type="button" data-dialog="close">…</button></header>
181
+ <au-viewport name="drawer"></au-viewport>
182
+ </bleet-dialog>
183
+ ```
184
+
185
+ ```typescript
186
+ resolve(IEventAggregator).publish(Channels.Modal, <IModal>{ action: ModalAction.Open, id: 'drawer', title: 'Edit user', color: UiColor.Primary });
187
+ ```
188
+
189
+ - `Open` (or `Toggle` when closed) with neither `url` nor `content` opens the dialog on its default slot; its `title`
190
+ and `color` are kept on the element for the frame (`$host.title`, `$host.color`) until it is closed.
191
+ - A form of the default slot is not posted by the element: it belongs to the page that projects it.
192
+ - `ModalStatus.Closed` with the `id` tells the page the dialog is closed (its route can be left).
193
+
166
194
  ## Ajaxify
167
195
 
168
196
  ### `<bleet-ajaxify>`
@@ -305,6 +333,39 @@ Publishes one toast on click. Rendered by `Bleet::toast()->…->trigger()` as at
305
333
 
306
334
  Options: `id`, `color`, `icon`, `title`, `content`, `duration`.
307
335
 
336
+ ### `<bleet-toaster>` (SPA)
337
+
338
+ The toaster of a SPA, where the application's templates render the markup: the same channel, the same payload and the
339
+ same state classes as the `bleet-toaster` attribute, but each toast is rendered by Aurelia from the markup the
340
+ application projects into the element. The element holds no markup and no class of its own: its template only repeats
341
+ its default slot, once per toast, the toast exposed as `$host`.
342
+
343
+ ```html
344
+ <bleet-toaster popover="manual" class="fixed inset-auto top-4 right-0 … flex flex-col gap-4 pointer-events-none">
345
+ <div data-toaster-id.bind="$host.id"
346
+ class="… translate-x-full opacity-0 transition-all duration-500"
347
+ data-toaster-show="translate-x-0 opacity-100"
348
+ data-toaster-hide="translate-x-full opacity-0">
349
+ … ${$host.title} … <div innerhtml.bind="$host.content"></div> …
350
+ <button type="button" click.trigger="$host.close($event)">…</button>
351
+ </div>
352
+ </bleet-toaster>
353
+ ```
354
+
355
+ | `$host` (`IToastView`) | Meaning |
356
+ |---|---|
357
+ | `id`, `color`, `icon`, `title`, `content`, `duration` | the published toast, with the defaults of the attribute |
358
+ | `close(event)` | closes the toast (its button) |
359
+
360
+ Behavior:
361
+
362
+ - The root of the projected toast carries `data-toaster-id="${$host.id}"`: once rendered, its hide classes are
363
+ swapped for its show classes; `close()`, `ToasterAction.Remove` or the end of its `duration` swap them back, then the
364
+ toast leaves the list once the transition ends.
365
+ - With `popover="manual"` on the element, it is shown again on each toast and hidden once the last one is gone, as the
366
+ attribute's container.
367
+ - The texts, the icons and the classes are the application's: its i18n, its icon component, its theme.
368
+
308
369
  ## Alerts
309
370
 
310
371
  ### `bleet-alert`
@@ -538,6 +599,17 @@ Behavior:
538
599
  is selected, the `count` template text beyond.
539
600
  - The panel does not open while the native select is disabled.
540
601
 
602
+ ### `bleet-focus`
603
+
604
+ An element that takes the focus as it appears — a field or a message shown later (a condition of the page, a fragment
605
+ loaded by ajaxify):
606
+
607
+ ```html
608
+ <input bleet-focus …>
609
+ ```
610
+
611
+ When attached, the element is focused on the next frame; the browser brings it into view.
612
+
541
613
  ## Upload channel
542
614
 
543
615
  `Channels.Upload` carries `IUpload` (`{ action: UploadAction.Reset, id?: string }`) for the upload bridges