@gjsify/storybook-nativescript 0.46.0 → 0.48.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/lib/esm/app.js +1 -1
- package/lib/esm/appearance.js +1 -1
- package/lib/esm/controls.js +1 -1
- package/lib/esm/story-view.js +1 -1
- package/lib/types/app.d.ts +2 -2
- package/lib/types/appearance.d.ts +3 -3
- package/lib/types/story-view.d.ts +1 -1
- package/package.json +9 -9
package/lib/esm/app.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{StorybookNsAppearance as e,buildAppearanceDialog as t,installAppearanceDialog as n}from"./appearance.js";import{createControlRow as r}from"./controls.js";import{StorybookController as i}from"@gjsify/storybook-core";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{StorybookNsAppearance as e,buildAppearanceDialog as t,installAppearanceDialog as n}from"./appearance.js";import{createControlRow as r}from"./controls.js";import{StorybookController as i}from"@gjsify/storybook-core";import{Adw as a,AdwBreakpoint as o,AdwImageButton as s,addBreakpoints as c,attachRowPressFeedback as l,setAdwaitaColorScheme as u}from"@gjsify/adwaita-nativescript";import{colorSelectSymbolic as d,goPreviousSymbolic as f,sidebarShowRightSymbolic as p}from"@gjsify/adwaita-icons/actions";import{Label as m,Screen as h,ScrollView as g,StackLayout as _}from"@nativescript/core";var StorybookNativeApp=class{_controller=new i(this,e=>this._buildControls(e));_options;root;_listColumn;_previewSlot;_previewTitle;_controlsGroup;_controlsSplit;_backButton;_appearance=new e;_appearanceDialog=null;_rowByTitle=new Map;_collapsed=!0;_disposeBreakpoint=null;constructor(e){this._options=e,this.root=new a.NavigationSplitView,this._collapsed=!this._isWideWidth(h.mainScreen?.widthDIPs??0),this.root.collapsed=this._collapsed,this.root.className=`sb-window`}_isWideWidth(e){return e>=720}mount(){return this._buildUI(),this._controller.mount(this._options.stories,this._options.openFirst!==!1),this._wireColorScheme(),this._wireBreakpoint(),this._appearanceDialog||(this._appearanceDialog=t(this._appearance),n(this.root,this._appearanceDialog)),this.root}_presentAppearance(){this._appearanceDialog?.present()}_wireBreakpoint(){let e=new o(`max-width: 720sp`,{onApply:()=>this._applyLayoutMode(!0),onUnapply:()=>this._applyLayoutMode(!1)});this._disposeBreakpoint=c(this.root,[e])}_applyLayoutMode(e){e===this._collapsed&&this.root.collapsed===e||(this._collapsed=e,this.root.collapsed=e,this._controlsSplit.collapsed=e,this.root.showSidebarPane(),this._backButton.visibility=e?`visible`:`collapse`)}get activeStory(){return this._controller.activeStory}listStories(){return this._controller.listStories()}openStoryByTitle(e){return this._controller.openStoryByTitle(e)}getCurrentStory(){return this._controller.getCurrentStory()}setActiveArg(e,t){return this._controller.setActiveArg(e,t)}get controller(){return this._controller}_wireColorScheme(){let e=this._options.application;e?.systemAppearance&&u(e.systemAppearance()===`dark`?`dark`:`light`)}renderSidebar(e,t){this._listColumn.removeChildren(),this._rowByTitle.clear();for(let{category:n,stories:r}of e){let e=new m;e.text=n,e.className=`sb-category`,this._listColumn.addChild(e);for(let{instance:e,name:n}of r){let r=new _;r.orientation=`vertical`,r.className=`sb-story-row`;let i=new m;i.text=n,i.className=`sb-story-row-label`,r.addChild(i),l(r),r.addEventListener(`tap`,()=>{t(e),this._collapsed&&this.root.hideSidebarPane()}),this._listColumn.addChild(r),this._rowByTitle.set(e.meta.title,r)}}}markSelected(e){for(let[t,n]of this._rowByTitle)n.className=t===e?`sb-story-row sb-story-row-selected`:`sb-story-row`}setPreviewTitle(e){this._previewTitle.title=e}showPreview(e){this._previewSlot.removeChildren(),this._previewSlot.addChild(e.view)}renderControls(e){this._controlsGroup.listbox.removeChildren();for(let t of e)this._controlsGroup.addRow(t.view)}_buildControls(e){let t=[],n=e.meta.controls;if(Array.isArray(n))for(let i of n){if(!i?.name||!i?.type){console.warn(`Invalid control configuration:`,i);continue}let n=r(e,i);n&&t.push(n)}return t}_buildUI(){let e=new a.ToolbarView;e.className=`${e.className} sb-sidebar-pane`.trim();let t=new a.HeaderBar;t.className=`${t.className} sb-sidebar-header`.trim();let n=new a.WindowTitle;n.title=this._options.title??`Stories`,t.setTitleWidget(n),e.addTopBar(t),this._listColumn=new _,this._listColumn.orientation=`vertical`,this._listColumn.className=`sb-sidebar-list`;let r=new g;r.className=`sb-sidebar-scroll`,r.content=this._listColumn,e.setContent(r),this.root.setSidebar(e);let i=new a.ToolbarView;i.className=`${i.className} sb-content-pane`.trim();let o=new a.HeaderBar;o.className=`${o.className} sb-detail-header`.trim();let c=new s;c.iconName=f,c.className=`${c.className} sb-back-button`.trim(),c.addEventListener(`tap`,()=>this.root.showSidebarPane()),c.visibility=this._collapsed?`visible`:`collapse`,this._backButton=c,o.packStart(c),this._previewTitle=new a.WindowTitle,this._previewTitle.title=`Preview`,o.setTitleWidget(this._previewTitle);let l=new s;l.iconName=p,l.className=`${l.className} sb-controls-toggle`.trim(),l.addEventListener(`tap`,()=>{this._controlsSplit.showSidebar=!this._controlsSplit.showSidebar});let u=new s;u.iconName=d,u.className=`${u.className} sb-appearance-button`.trim(),u.addEventListener(`tap`,()=>this._presentAppearance()),o.packEnd(u),o.packEnd(l),i.addTopBar(o),this._controlsSplit=new a.OverlaySplitView,this._controlsSplit.collapsed=this._collapsed,this._controlsSplit.sidebarPosition=`end`,this._controlsSplit.sidebarWidth=320,this._controlsSplit.className=`${this._controlsSplit.className} sb-controls-split`.trim(),this._previewSlot=new _,this._previewSlot.orientation=`vertical`,this._previewSlot.className=`sb-preview-pane`;let m=new g;m.className=`sb-preview-scroll`,m.content=this._previewSlot,this._controlsSplit.setContent(m),this._controlsGroup=new a.PreferencesGroup,this._controlsGroup.title=`Controls`,this._controlsGroup.className=`${this._controlsGroup.className} sb-controls-group`.trim();let h=new g;h.className=`sb-controls-scroll`,h.content=this._controlsGroup,this._controlsSplit.setSidebar(h),i.setContent(this._controlsSplit),this.root.setContent(i),this.root.showSidebarPane()}};function runStorybook(e){let t=new StorybookNativeApp(e);return t.mount(),t}export{StorybookNativeApp,runStorybook};
|
package/lib/esm/appearance.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{StorybookSettings as e}from"@gjsify/storybook-core";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{StorybookSettings as e}from"@gjsify/storybook-core";import{Adw as t,NOTIFY_ACTIVE as n,applyAdwaitaNsAccent as r,clearAdwaitaNsAccent as i}from"@gjsify/adwaita-nativescript";import{GridLayout as a,WrapLayout as o}from"@nativescript/core";import{ADW_ACCENT_COLOR_NAMES as s,adwaitaAccentBgColor as c,adwaitaColorScheme as l}from"@gjsify/adwaita-core";const u=`sb-swatch`;var StorybookNsAppearance=class{settings;constructor(){this.settings=new e(()=>l()===`dark`),this.settings.subscribe(()=>this._apply()),this._apply()}_apply(){let e=this.settings.resolvedAccent;e?r(e):i()}};function buildSwatch(e){let t=new a;return t.className=u,t.backgroundColor=c(e),t}function buildAppearanceDialog(e){let r=e.settings,i=new t.PreferencesDialog;i.title=`Appearance`;let a=new t.PreferencesPage,c=new t.PreferencesGroup;c.title=`ACCENT COLOUR`;let l=new t.SwitchRow;l.title=`Use a custom accent colour`,l.subtitle=`Off keeps the default Adwaita blue`,l.active=r.accentMode===`custom`,c.addRow(l);let d=new o;d.orientation=`horizontal`,d.className=`sb-swatch-row`;let f=new Map;for(let e of s){let t=buildSwatch(e);t.addEventListener(`tap`,()=>{r.accentMode===`custom`&&(r.accent=e)}),f.set(e,t),d.addChild(t)}c.addRow(d),a.addGroup(c),i.add(a);let sync=()=>{let e=r.accentMode===`custom`;l.active!==e&&(l.active=e),d.opacity=e?1:.4;for(let[e,t]of f)t.className=e===r.accent?`${u} selected`:u};return l.addEventListener(n,e=>{r.accentMode=e.active?`custom`:`system`}),r.subscribe(sync),sync(),i}function installAppearanceDialog(e,t){a.setColumn(t,0),a.setColumnSpan(t,3),a.setRow(t,0),a.setRowSpan(t,3),e.addChild(t)}export{StorybookNsAppearance,buildAppearanceDialog,installAppearanceDialog};
|
package/lib/esm/controls.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{bindControl as e}from"@gjsify/storybook-core";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{bindControl as e}from"@gjsify/storybook-core";import{Adw as t,AdwSliderRow as n,NOTIFY_ACTIVE as r,NOTIFY_SELECTED as i,NOTIFY_SLIDER_VALUE as a,NOTIFY_TEXT as o,NOTIFY_VALUE as s}from"@gjsify/adwaita-nativescript";function createControlRow(t,n){return e(t,n,c)}const c={text(e){let n=new t.EntryRow;n.title=e;let cb=()=>{};return n.addEventListener(o,e=>cb(e.text)),{node:n,get:()=>n.text??``,set:e=>{n.text=e},onChange:e=>{cb=e}}},color(e,n){let r=new t.EntryRow;r.title=`${e} (hex)`,n&&(r.subtitle=n);let cb=()=>{};return r.addEventListener(o,e=>cb(e.text)),{node:r,get:()=>r.text??``,set:e=>{r.text=e},onChange:e=>{cb=e}}},boolean(e,n){let i=new t.SwitchRow;i.title=e,n&&(i.subtitle=n);let cb=()=>{};return i.addEventListener(r,e=>cb(e.active)),{node:i,get:()=>i.active,set:e=>{i.active=e},onChange:e=>{cb=e}}},number(e){return spinRow(e)},range(e){return sliderRow(e)},select(e){let n=e.options??[],r=new t.ComboRow;r.title=label(e),e.description&&(r.subtitle=e.description),r.model=n.map(e=>({label:e.label,value:String(e.value)}));let cb=()=>{};return r.addEventListener(i,e=>cb(e.selected)),{node:r,get:()=>r.selected,set:e=>{r.selected=e},onChange:e=>{cb=e}}}};function spinRow(e){let n=new t.SpinRow;n.title=label(e),e.description&&(n.subtitle=e.description),n.adjustment={lower:e.min??0,upper:e.max??100,stepIncrement:e.step??1};let cb=()=>{};return n.addEventListener(s,e=>cb(e.value)),{node:n,get:()=>n.value,set:e=>{n.value=e},onChange:e=>{cb=e}}}function sliderRow(e){let t=new n;t.title=label(e),t.adjustment={lower:e.min??0,upper:e.max??100,stepIncrement:e.step??1};let cb=()=>{};return t.addEventListener(a,e=>cb(e.value)),{node:t,get:()=>t.value,set:e=>{t.value=e},onChange:e=>{cb=e}}}function label(e){return e.label||e.name}export{createControlRow};
|
package/lib/esm/story-view.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{StoryViewBase as e}from"@gjsify/storybook-core";import{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{StoryViewBase as e}from"@gjsify/storybook-core";import{Adw as t}from"@gjsify/adwaita-nativescript";import{Label as n,StackLayout as r}from"@nativescript/core";var StoryView=class extends e{constructor(e,t=`Default`,n){super(),this.initBase(e,t,n)}get view(){return this.root}createChrome(e,t){return t?{root:t,hasStage:!1,setStageContent:()=>{},setChromeText:()=>{}}:this._installDefaultChrome()}_installDefaultChrome(){let e=new r;e.orientation=`vertical`,e.className=`sb-story-page`;let i=new t.Clamp;i.className=`${i.className} sb-story-clamp`.trim();let a=new r;a.orientation=`vertical`,a.className=`sb-story-group`;let o=new r;o.orientation=`vertical`,o.className=`sb-story-group-header`;let s=new n;s.className=`sb-story-group-title`,s.textWrap=!0,o.addChild(s);let c=new n;c.className=`sb-story-group-description`,c.textWrap=!0;let l=!1,u=new r;return u.orientation=`vertical`,u.className=`story-stage`,u.horizontalAlignment=`center`,a.addChild(o),a.addChild(u),i.setChild(a),e.addChild(i),{root:e,hasStage:!0,setStageContent:e=>{u.removeChildren(),u.addChild(e)},setChromeText:(e,t)=>{s.text=e,c.text=t;let n=t.length>0;n&&!l?(o.addChild(c),l=!0):!n&&l&&(o.removeChild(c),l=!1)}}}};export{StoryView};
|
package/lib/types/app.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StoryArgValue } from '@gjsify/stories';
|
|
2
2
|
import { type CategoryGroup, type ControlRow, StorybookController, type StorybookView, type StorySummary } from '@gjsify/storybook-core';
|
|
3
|
-
import {
|
|
3
|
+
import { Adw } from '@gjsify/adwaita-nativescript';
|
|
4
4
|
import { type View } from '@nativescript/core';
|
|
5
5
|
import type { StoryView } from './story-view.js';
|
|
6
6
|
import type { NsStoryModule } from './types.js';
|
|
@@ -34,7 +34,7 @@ export declare class StorybookNativeApp implements StorybookView<StoryView> {
|
|
|
34
34
|
private _options;
|
|
35
35
|
/** The single root view the host adds to its page — a collapsed navigation
|
|
36
36
|
* split view (master story list ⇄ detail preview). */
|
|
37
|
-
readonly root:
|
|
37
|
+
readonly root: Adw.NavigationSplitView;
|
|
38
38
|
private _listColumn;
|
|
39
39
|
private _previewSlot;
|
|
40
40
|
private _previewTitle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Adw } from '@gjsify/adwaita-nativescript';
|
|
2
2
|
import { StorybookSettings } from '@gjsify/storybook-core';
|
|
3
3
|
import { GridLayout } from '@nativescript/core';
|
|
4
4
|
/** Owns the NativeScript side of {@link StorybookSettings}. */
|
|
@@ -13,7 +13,7 @@ export declare class StorybookNsAppearance {
|
|
|
13
13
|
* Returned unpresented; the caller adds it to a host cell and calls `present()`, the
|
|
14
14
|
* way every NS dialog in this tree is used.
|
|
15
15
|
*/
|
|
16
|
-
export declare function buildAppearanceDialog(appearance: StorybookNsAppearance):
|
|
16
|
+
export declare function buildAppearanceDialog(appearance: StorybookNsAppearance): Adw.PreferencesDialog;
|
|
17
17
|
/**
|
|
18
18
|
* Put `dialog` into `root` so its scrim covers every pane.
|
|
19
19
|
*
|
|
@@ -25,4 +25,4 @@ export declare function buildAppearanceDialog(appearance: StorybookNsAppearance)
|
|
|
25
25
|
* alone. The span is deliberately larger than the declared column count, which NS
|
|
26
26
|
* clamps — the count differs between the collapsed and expanded layouts.
|
|
27
27
|
*/
|
|
28
|
-
export declare function installAppearanceDialog(root: GridLayout, dialog:
|
|
28
|
+
export declare function installAppearanceDialog(root: GridLayout, dialog: Adw.PreferencesDialog): void;
|
|
@@ -6,7 +6,7 @@ export type StoryArgsListener = (args: StoryArgs) => void;
|
|
|
6
6
|
/**
|
|
7
7
|
* Base class for NativeScript story views.
|
|
8
8
|
*
|
|
9
|
-
* Provides default chrome — a clamped boxed group (`
|
|
9
|
+
* Provides default chrome — a clamped boxed group (`Adw.Clamp` +
|
|
10
10
|
* `AdwPreferencesGroup`) with a title + description above a centered, tinted
|
|
11
11
|
* preview "stage" — built programmatically with the
|
|
12
12
|
* `@gjsify/adwaita-nativescript` widgets + the Adwaita CSS classes. Simple
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/storybook-nativescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"description": "NativeScript renderer for the @gjsify/stories contract — the NS counterpart of @gjsify/storybook (GTK) and @gjsify/adwaita-storybook (browser), built on @gjsify/adwaita-nativescript real native widgets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"gnome"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@gjsify/adwaita-icons": "^0.
|
|
43
|
-
"@gjsify/adwaita-core": "^0.
|
|
44
|
-
"@gjsify/adwaita-nativescript": "^0.
|
|
45
|
-
"@gjsify/devtools-nativescript": "^0.
|
|
46
|
-
"@gjsify/stories": "^0.
|
|
47
|
-
"@gjsify/storybook-core": "^0.
|
|
42
|
+
"@gjsify/adwaita-icons": "^0.48.0",
|
|
43
|
+
"@gjsify/adwaita-core": "^0.48.0",
|
|
44
|
+
"@gjsify/adwaita-nativescript": "^0.48.0",
|
|
45
|
+
"@gjsify/devtools-nativescript": "^0.48.0",
|
|
46
|
+
"@gjsify/stories": "^0.48.0",
|
|
47
|
+
"@gjsify/storybook-core": "^0.48.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@nativescript/core": "*"
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@gjsify/cli": "^0.
|
|
59
|
-
"@gjsify/unit": "^0.
|
|
58
|
+
"@gjsify/cli": "^0.48.0",
|
|
59
|
+
"@gjsify/unit": "^0.48.0",
|
|
60
60
|
"@nativescript/types": "~9.0.0",
|
|
61
61
|
"@types/node": "^25.9.2",
|
|
62
62
|
"typescript": "^6.0.3"
|