@webx-ui/module-banners 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 webx-ui
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @webx-ui/module-banners
2
+
3
+ The front end of the banners section of the [WebX UI](https://github.com/webx-ui/webx-ui) admin
4
+ panel: pictures (and a narrower one for a phone), an optional video, a title, a text and up to
5
+ three buttons, standing in **named places** and arranged by hand.
6
+
7
+ The other half is the Composer package `webx-ui/module-banners`, which owns the places, the banners,
8
+ `banners()` and `banners_layout()` for templates and the API. A section appears in the panel when
9
+ both halves are installed. Banners reach a site only through a template helper: the site's own
10
+ markup draws them.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install @webx-ui/module-banners
16
+ ```
17
+
18
+ ```ts
19
+ import { createAdmin } from '@webx-ui/module-admin'
20
+ import { banners } from '@webx-ui/module-banners'
21
+ import '@webx-ui/module-banners/style.css'
22
+
23
+ createAdmin({
24
+ basePath: '/cms',
25
+ modules: [banners()],
26
+ }).mount()
27
+ ```
28
+
29
+ `banners()` is one section and one entry of the menu, at the top level. `banners({ path: '/promo' })`
30
+ puts it somewhere else inside the panel.
31
+
32
+ ## Places and banners
33
+
34
+ `/banners` is the places on the left and the banners of one of them on the right. A place the
35
+ site's config declares is on the list before anything was saved into it, carries a lock and cannot
36
+ be renamed or deleted here: a template asks for it by key, and the list says how —
37
+ `banners('hero')`. A place of somebody's own is made with **New place**, renamed from its row, and
38
+ deleted only when it is empty, the bin included.
39
+
40
+ The banners of a place are in the order the site shows them: drag the grip, or pick it up with the
41
+ keyboard (space, arrows, space). A switched-off banner stays in its place, quieter; the bin is the
42
+ same list turned over, and a banner comes back from it with **Restore**.
43
+
44
+ A banner opens on a page of its own (`/banners/<id>`, a new one at `/banners/new?place=<key>`):
45
+ the place above the described screen `banners.form`, one **Save** under it, Ctrl+S, and a question
46
+ before leaving with something unsaved. Moved to another place, a banner stands last in it. A new
47
+ banner starts switched off.
48
+
49
+ The guide — places, the two helpers, a complete template with its styles and slider script, the
50
+ agent's tools — is at https://webx-ui.github.io/webx-ui/guide/banners.
@@ -0,0 +1,7 @@
1
+ type __VLS_Props = {
2
+ base?: string;
3
+ };
4
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ base: string;
6
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
7
+ export default _default;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The section: the places of the site on the left, the banners of one of them on the right
3
+ * (§5.4) — the shape of the menus, for the same reason: somebody who opens this is arranging one
4
+ * place, not choosing between them, so the first one opens by itself where there is room for it.
5
+ * On a phone it does not: there the same line would raise a panel over a list nobody touched.
6
+ *
7
+ * A declared place is on the list before anything was ever saved into it (decision 1) — its row
8
+ * in the table is made by its first banner — so places are named by key throughout, not by id.
9
+ */
10
+ type __VLS_Props = {
11
+ base?: string;
12
+ };
13
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
14
+ base: string;
15
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
16
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { PlaceRow } from './types';
2
+ type __VLS_Props = {
3
+ place?: PlaceRow | null;
4
+ };
5
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
6
+ place: PlaceRow | null;
7
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
8
+ field: HTMLDivElement;
9
+ }, any>;
10
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { PlaceRow } from './types';
2
+ type __VLS_Props = {
3
+ place: PlaceRow;
4
+ base: string;
5
+ /** False in the drawer a narrow screen opens this in. */
6
+ inline?: boolean;
7
+ };
8
+ declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
9
+ back: () => any;
10
+ changed: () => any;
11
+ }, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
12
+ onBack?: (() => any) | undefined;
13
+ onChanged?: (() => any) | undefined;
14
+ }>, {
15
+ inline: boolean;
16
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
17
+ export default _default;
package/dist/api.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { AdminContext } from '@webx-ui/module-admin';
2
+ import { ScreenModel } from '@webx-ui/schema';
3
+ import { BannerDetail, BannerRow, PlaceInput, PlaceRow } from './types';
4
+ export interface BannersApi {
5
+ /** Every place: the declared ones in the config's order, then the own ones by name. */
6
+ places(): Promise<PlaceRow[]>;
7
+ createPlace(input: PlaceInput): Promise<PlaceRow>;
8
+ /** Only a place of somebody's own, and only its name: the key is what a template asks for. */
9
+ renamePlace(key: string, title: PlaceInput['title']): Promise<PlaceRow>;
10
+ /** Only an own place with nothing in it, the bin included — a 422 with the count otherwise. */
11
+ removePlace(key: string): Promise<void>;
12
+ /** The banners of a place in their order, or its bin. A declared place without a row: `[]`. */
13
+ list(place: string, trashed?: boolean): Promise<BannerRow[]>;
14
+ get(id: number): Promise<BannerDetail>;
15
+ /**
16
+ * A new banner out of the values of its form, in one request: the form is filled in first and
17
+ * the record made on the first save, so nobody leaves an empty banner in a place.
18
+ */
19
+ create(place: string, values: ScreenModel): Promise<BannerDetail>;
20
+ /**
21
+ * Refused with a 422 under the name of the field — `buttons.<n>.link` for a button's row. A
22
+ * `place` other than the one it stands in moves it to the end of that one (decision 14).
23
+ */
24
+ save(id: number, values: ScreenModel, place?: string): Promise<BannerDetail>;
25
+ remove(id: number): Promise<void>;
26
+ restore(id: number): Promise<BannerRow>;
27
+ /** The order of one place, written whole. */
28
+ reorder(place: string, ids: number[]): Promise<void>;
29
+ }
30
+ /** Everything under `/banners`, below the panel's API path (§5.6). */
31
+ export declare function createBannersApi(admin: AdminContext): BannersApi;
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** Puts this package's English under the panel's dictionary, once per panel. */
2
+ export declare function useBannersMessages(): void;
@@ -0,0 +1,6 @@
1
+ export { banners, type BannersOptions } from './module';
2
+ export { createBannersApi, type BannersApi } from './api';
3
+ export { bannersMessages } from './messages';
4
+ export { default as WxBannersPage } from './BannersPage';
5
+ export { default as WxBannerEditorPage } from './BannerEditorPage';
6
+ export type { BannerButton, BannerDetail, BannerRow, BannerSummary, PlaceInput, PlaceRow, } from './types';