@gjsify/adwaita-nativescript 0.64.1-next.241 → 0.64.1-next.244
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/widgets/gtk-label.js +2 -1
- package/lib/esm/widgets/gtk-window.js +1 -1
- package/lib/esm/widgets/native-tooltip.js +1 -1
- package/lib/types/namespace/gtk.d.ts +1 -0
- package/lib/types/widgets/gtk-label.d.ts +19 -6
- package/lib/types/widgets/gtk-window.d.ts +6 -2
- package/lib/types/widgets/native-tooltip.d.ts +2 -0
- package/package.json +13 -13
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{xmlBoolean as e,xmlNumber as t}from"./xml-values.js";import{applyConstructProps as n}from"./construct-props.js";import{
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{xmlBoolean as e,xmlNumber as t}from"./xml-values.js";import{applyConstructProps as n}from"./construct-props.js";import{androidApiLevel as r}from"./native-tooltip.js";import{withSignals as i}from"./signals.js";import{classNameWith as a,normalizeStyleClasses as o,withCssClass as s,withoutCssClass as c}from"./style-classes.js";import{DEFAULT_LABEL_LINES as l,DEFAULT_LABEL_XALIGN as u,LABEL_JUSTIFICATIONS as d,labelDisplayText as f,labelEffectiveLines as p,labelEllipsizeOverflowValue as m,normalizeLabelEllipsize as h,normalizeLabelLines as g,normalizeLabelXalign as _}from"@gjsify/adwaita-core";import{Label as v}from"@nativescript/core";const y=new Map([[0,`start`],[.5,`center`],[1,`end`]]),b={left:`start`,right:`end`,center:`center`,fill:`start`};function physical(e,t){return e===`center`?`center`:e===`start`===t?`right`:`left`}var GtkLabel=class extends i(v){static GTypeName=`GtkLabel`;_label=``;_useMarkup=!1;_useUnderline=!1;_ellipsize=`none`;_lines=-1;_styleClasses=[];_xalign=u;_xalignWritten=!1;_justify=`left`;_selectable=!1;constructor(e){super(),this.addEventListener(`loaded`,()=>{this._applySelectable(),this._applyJustificationMode()}),n(this,e)}get label(){return this._label}set label(e){this._label=e??``,this._render()}get useMarkup(){return this._useMarkup}set useMarkup(t){this._useMarkup=e(t,this._useMarkup),this._render()}get useUnderline(){return this._useUnderline}set useUnderline(t){this._useUnderline=e(t,this._useUnderline),this._render()}get wrap(){return this.textWrap}set wrap(t){let n=e(t,this.textWrap);this._applyAlignment({wrap:n}),this.textWrap=n}get ellipsize(){return this._ellipsize}set ellipsize(e){this._ellipsize=h(e),this.textOverflow=m(this._ellipsize),this._applyLines()}get lines(){return this._lines}set lines(e){this._lines=g(t(e,l)),this._applyLines()}get selectable(){return this._selectable}set selectable(t){this._selectable=e(t,this._selectable),this._applySelectable()}_applySelectable(){this.nativeViewProtected?.setTextIsSelectable?.(this._selectable)}_applyLines(){this.maxLines=p(this._lines,this._ellipsize)??0}get justify(){return this._justify}set justify(e){let n=d.includes(e)?e:d[t(e,-1)];if(n===void 0)throw TypeError(`'${String(e)}' is not a Gtk.Justification, so it cannot be 'justify'. The members are ${d.join(`, `)}, or their values 0 to 3.`);this._applyAlignment({justify:n})}get xalign(){return this._xalign}set xalign(e){let n=_(t(e,u));if(!y.has(n))throw TypeError(`Gtk.Label xalign ${n} has no NativeScript counterpart: textAlignment places text at the start, the centre or the end, so only 0, 0.5 and 1 render as written. Snapping it would show a different label than GTK does with no sign of the difference.`);this._applyAlignment({xalign:n})}_applyAlignment(e){let t=e.xalign??(this._xalignWritten?this._xalign:null),n=e.justify??this._justify,r=e.text??this.text??``,i=(e.wrap??this.textWrap)||r.includes(`
|
|
2
|
+
`),a=b[n],o=t===null?null:y.get(t),s;if(o===null)s=n===`left`?null:a;else if(o===a||!i||n===`left`)s=o;else throw TypeError(`Gtk.Label justify ${n} beside xalign ${t} has no NativeScript counterpart on a label that can show several lines: GTK places the text block at its ${o} and aligns the lines inside it to their ${a}, and textAlignment is one alignment for both. An xalign on the justify edge, or a label without wrap and newline, renders exactly.`);if(e.xalign!==void 0&&(this._xalign=e.xalign,this._xalignWritten=!0),e.justify!==void 0&&(this._justify=e.justify),s===null){(e.xalign!==void 0||e.justify!==void 0)&&(this.textAlignment=`initial`);return}let c=physical(s,this.style?.direction===`rtl`);this.textAlignment=n===`fill`&&c===`left`?`justify`:c,this._applyJustificationMode()}_applyJustificationMode(){this.textAlignment===`justify`||r()<26||this.nativeViewProtected?.setJustificationMode?.(+(this._justify===`fill`))}get styleClasses(){return[...this._styleClasses]}set styleClasses(e){this._setClasses(o(e))}get_label(){return this.label}set_label(e){this.label=e}set_markup(e){this._label=e??``,this._useMarkup=!0,this._render()}get_text(){return this.text??``}add_css_class(e){this._setClasses(s(this._styleClasses,e))}remove_css_class(e){this._setClasses(c(this._styleClasses,e))}has_css_class(e){return this._styleClasses.includes((e??``).trim())}get_css_classes(){return[...this._styleClasses]}set_css_classes(e){this._setClasses(o([...e].join(` `)))}_setClasses(e){this._styleClasses=[...e],this.className=a(``,this._styleClasses)}_render(){let e=f(this._label,this._useMarkup,this._useUnderline);this._applyAlignment({text:e}),this.text=e}};export{GtkLabel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";import{xmlBoolean as e,xmlNumber as t}from"./xml-values.js";import{applyConstructProps as n}from"./construct-props.js";import{surfaceSize as r}from"./window-state.js";import{windowHost as i}from"../window-host.js";import{AdwSingleChildBase as a}from"./single-child-base.js";import{CloseRequestState as o,HandledAccumulator as s,WindowMemberState as c}from"@gjsify/adwaita-core";const l=`notify::is-active`,u=`notify::maximized`,d=`notify::focus-widget`,f=`close-request`;var p=class GtkWindow extends a{static GTypeName=`GtkWindow`;_title=``;_defaultWidth=0;_defaultHeight=0;_members=new c(e=>{let t=e===`is-active`?l:u;this.notify({eventName:t,object:this,value:e===`is-active`?this.isActive:this.maximized})},{maximized:!0});_closeRequest=new o;_unwatchForeground=null;_unwatchBack=null;constructor(e){super(),n(this,e)}onLoaded(){super.onLoaded();let e=i();this._unwatchForeground?.(),this._unwatchForeground=e.watchForeground(e=>this._members.reportActive(e)),this._members.reportActive(e.isForeground()),this._unwatchBack?.(),this._unwatchBack=this._isToplevel()?e.watchBack(()=>this._handleBack()):null}onUnloaded(){this._unwatchForeground?.(),this._unwatchForeground=null,this._unwatchBack?.(),this._unwatchBack=null,this._members.reportActive(!1),super.onUnloaded()}get isActive(){return this._members.active}is_active(){return this.
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";import{xmlBoolean as e,xmlNumber as t}from"./xml-values.js";import{applyConstructProps as n}from"./construct-props.js";import{surfaceSize as r}from"./window-state.js";import{windowHost as i}from"../window-host.js";import{AdwSingleChildBase as a}from"./single-child-base.js";import{CloseRequestState as o,HandledAccumulator as s,WindowMemberState as c}from"@gjsify/adwaita-core";const l=`notify::is-active`,u=`notify::maximized`,d=`notify::focus-widget`,f=`close-request`;var p=class GtkWindow extends a{static GTypeName=`GtkWindow`;_title=``;_defaultWidth=0;_defaultHeight=0;_members=new c(e=>{let t=e===`is-active`?l:u;this.notify({eventName:t,object:this,value:e===`is-active`?this.isActive:this.maximized})},{maximized:!0});_closeRequest=new o;_unwatchForeground=null;_unwatchBack=null;constructor(e){super(),n(this,e)}onLoaded(){super.onLoaded();let e=i();this._unwatchForeground?.(),this._unwatchForeground=e.watchForeground(e=>this._members.reportActive(e)),this._members.reportActive(e.isForeground()),this._unwatchBack?.(),this._unwatchBack=this._isToplevel()?e.watchBack(()=>this._handleBack()):null}onUnloaded(){this._unwatchForeground?.(),this._unwatchForeground=null,this._unwatchBack?.(),this._unwatchBack=null,this._members.reportActive(!1),super.onUnloaded()}get isActive(){return this._members.active}get is_active(){return this._members.active}get maximized(){return this._members.maximized}set maximized(t){e(t,!0)?this.maximize():this.unmaximize()}is_maximized(){return this.maximized}maximize(){}unmaximize(){throw Error(`GtkWindow.unmaximize is not supported on NativeScript: the window is the whole screen and the platform has no un-maximized state to go back to.`)}present(){}get focusWidget(){return this.get_focus()}get focus_widget(){return this.get_focus()}set focus_widget(e){this.set_focus(e)}get_focus(){let e=i();return findView(this,t=>e.isFocused(t))}set_focus(e){let t=i();if(e===null){let e=this.get_focus();e!==null&&t.clearFocus(e);return}if(findView(this,t=>t===e)===null)throw Error(`GtkWindow.set_focus: the widget is not a descendant of this window.`);t.requestFocus(e)}close(){let e=i();if(this.isLoaded&&!e.canFinish)throw Error(`GtkWindow.close is not supported on this platform: iOS has no public API to close the root window. Android finishes the foreground activity.`);this._requestClose()}_requestClose(){let e=i();this._closeRequest.close({realized:this.isLoaded,hideOnClose:!1,emit:()=>{let e=new s;return this.notify({eventName:f,object:this,accumulator:e}),e.stopped},hide:()=>{},destroy:()=>e.finish()})}_handleBack(){return this._consumeBack()||popInnermostNavigation(this)||this._requestClose(),!0}_consumeBack(){return!1}_isToplevel(){for(let e=this.parent;e;e=e.parent)if(e instanceof GtkWindow)return!1;return!0}connect(e,t){if(e===`notify::focus-widget`)throw Error(`GtkWindow notify::focus-widget is not supported on NativeScript: focus the user moves is not observable here. Read get_focus() when you need it.`);return super.connect(e,t)}get title(){return this._title}set title(e){this._title=e??``}get defaultWidth(){return this._defaultWidth}set defaultWidth(e){this._defaultWidth=r(t(e,NaN),e,this._defaultWidth,`defaultWidth`)}get defaultHeight(){return this._defaultHeight}set defaultHeight(e){this._defaultHeight=r(t(e,NaN),e,this._defaultHeight,`defaultHeight`)}};function findView(e,t){let n=null;return e.eachChildView(e=>t(e)?(n=e,!1):(n=findView(e,t),n===null)),n}const popsOnBack=e=>typeof e.popFromShortcut==`function`;function popInnermostNavigation(e){let t=!1;return e.eachChildView(e=>e.visibility===`visible`&&(popInnermostNavigation(e)||popsOnBack(e)&&e.isLoaded&&e.popFromShortcut()===`stop`)?(t=!0,!1):!0),t}export{f as CLOSE_REQUEST,p as GtkWindow,d as NOTIFY_FOCUS_WIDGET,l as NOTIFY_IS_ACTIVE,u as NOTIFY_MAXIMIZED};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../_virtual/_rolldown/runtime.js";function androidApiLevel(){return typeof android<`u`&&android?.os?.Build?.VERSION?.SDK_INT||1/0}function applyNativeTooltip(e,t,n=androidApiLevel()){if(n<26)return;let r=e.nativeViewProtected;r&&typeof r.setTooltipText==`function`&&r.setTooltipText(t===``?null:t)}export{applyNativeTooltip};
|
|
1
|
+
import"../_virtual/_rolldown/runtime.js";function androidApiLevel(){return typeof android<`u`&&android?.os?.Build?.VERSION?.SDK_INT||1/0}function applyNativeTooltip(e,t,n=androidApiLevel()){if(n<26)return;let r=e.nativeViewProtected;r&&typeof r.setTooltipText==`function`&&r.setTooltipText(t===``?null:t)}export{androidApiLevel,applyNativeTooltip};
|
|
@@ -19,6 +19,7 @@ export { GtkOverlay as Overlay } from '../widgets/gtk-overlay.js';
|
|
|
19
19
|
export { GtkRevealer as Revealer } from '../widgets/gtk-revealer.js';
|
|
20
20
|
export { GtkScrolledWindow as ScrolledWindow } from '../widgets/gtk-scrolled-window.js';
|
|
21
21
|
export { GtkWindow as Window } from '../widgets/gtk-window.js';
|
|
22
|
+
export type { WindowCommon } from '@gjsify/adwaita-core';
|
|
22
23
|
export { GtkSeparator as Separator } from '../widgets/gtk-separator.js';
|
|
23
24
|
export { GtkStack as Stack } from '../widgets/gtk-stack.js';
|
|
24
25
|
export { GtkStackPage as StackPage } from '../widgets/stack-page.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Label } from '@nativescript/core';
|
|
2
|
-
import { type LabelEllipsizeMode } from '@gjsify/adwaita-core';
|
|
2
|
+
import { type LabelEllipsizeMode, type LabelJustification } from '@gjsify/adwaita-core';
|
|
3
3
|
import { type ConstructProps } from './construct-props.js';
|
|
4
4
|
declare const GtkLabel_base: (abstract new (...args: any[]) => {
|
|
5
5
|
connect(eventName: string, callback: (self: /*elided*/ any, data: import("@nativescript/core").EventData) => unknown): number;
|
|
@@ -59,6 +59,8 @@ export declare class GtkLabel extends GtkLabel_base {
|
|
|
59
59
|
private _lines;
|
|
60
60
|
private _styleClasses;
|
|
61
61
|
private _xalign;
|
|
62
|
+
private _xalignWritten;
|
|
63
|
+
private _justify;
|
|
62
64
|
private _selectable;
|
|
63
65
|
constructor(props?: ConstructProps<GtkLabel>);
|
|
64
66
|
/**
|
|
@@ -128,12 +130,12 @@ export declare class GtkLabel extends GtkLabel_base {
|
|
|
128
130
|
private _applySelectable;
|
|
129
131
|
private _applyLines;
|
|
130
132
|
/**
|
|
131
|
-
* `Gtk.Label:justify
|
|
132
|
-
*
|
|
133
|
-
*
|
|
133
|
+
* `Gtk.Label:justify` — how the lines align with one another; no effect on a single line.
|
|
134
|
+
* Takes a nick or the `Gtk.Justification` constant and reads back as the nick. How it shares
|
|
135
|
+
* `textAlignment` with {@link xalign}, and the one combination that throws, is in the header.
|
|
134
136
|
*/
|
|
135
|
-
get justify():
|
|
136
|
-
set justify(
|
|
137
|
+
get justify(): LabelJustification;
|
|
138
|
+
set justify(raw: LabelJustification | number | string);
|
|
137
139
|
/**
|
|
138
140
|
* `Gtk.Label:xalign` — where the text sits in the label's box, `0` the start and `1` the
|
|
139
141
|
* end. Clamped to that range as `gtk_label_set_xalign` clamps it, and painted only at the
|
|
@@ -141,6 +143,17 @@ export declare class GtkLabel extends GtkLabel_base {
|
|
|
141
143
|
*/
|
|
142
144
|
get xalign(): number;
|
|
143
145
|
set xalign(raw: number | string);
|
|
146
|
+
/**
|
|
147
|
+
* Resolve `xalign` and `justify` onto `textAlignment` for the state `next` would leave, and
|
|
148
|
+
* commit it — or throw BEFORE anything changes, so a refused write leaves the label as it was.
|
|
149
|
+
*/
|
|
150
|
+
private _applyAlignment;
|
|
151
|
+
/**
|
|
152
|
+
* FILL off NativeScript's `'justify'` word: that word also forces LEFT gravity, so an RTL
|
|
153
|
+
* FILL label sets the mode on the `TextView` itself, after the platform's `textAlignment`
|
|
154
|
+
* setter has reset it.
|
|
155
|
+
*/
|
|
156
|
+
private _applyJustificationMode;
|
|
144
157
|
/**
|
|
145
158
|
* `GtkWidget:css-classes`, spelled `styleClasses` for the reason `style-classes.ts`
|
|
146
159
|
* records: the platform owns `cssClasses` as a live `Set` and taking that name kills
|
|
@@ -19,7 +19,8 @@ export declare class GtkWindow extends AdwSingleChildBase {
|
|
|
19
19
|
onUnloaded(): void;
|
|
20
20
|
/** `GtkWindow:is-active` (read-only): the application is in the foreground. */
|
|
21
21
|
get isActive(): boolean;
|
|
22
|
-
|
|
22
|
+
/** The GJS spelling of {@link isActive}: a property, as in `@girs/gtk-4.0` (ADR 0098 Amendment 4). */
|
|
23
|
+
get is_active(): boolean;
|
|
23
24
|
/** `GtkWindow:maximized`: always true here. Writing false throws; writing true is a no-op. */
|
|
24
25
|
get maximized(): boolean;
|
|
25
26
|
set maximized(value: boolean | string);
|
|
@@ -29,8 +30,11 @@ export declare class GtkWindow extends AdwSingleChildBase {
|
|
|
29
30
|
unmaximize(): void;
|
|
30
31
|
/** The application's `activate` returns the root window, so it is presented already. */
|
|
31
32
|
present(): void;
|
|
32
|
-
/** `GtkWindow:focus-widget
|
|
33
|
+
/** `GtkWindow:focus-widget`: the view holding native focus, found live. */
|
|
33
34
|
get focusWidget(): View | null;
|
|
35
|
+
/** `GtkWindow:focus-widget` under its GJS spelling; writing it is `set_focus`. */
|
|
36
|
+
get focus_widget(): View | null;
|
|
37
|
+
set focus_widget(widget: View | null);
|
|
34
38
|
get_focus(): View | null;
|
|
35
39
|
/** Move native focus to a descendant, or clear it with `null`. */
|
|
36
40
|
set_focus(widget: View | null): void;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
/** `Build.VERSION.SDK_INT`, or `Infinity` where there is no Android runtime (nothing to gate). */
|
|
2
|
+
export declare function androidApiLevel(): number;
|
|
1
3
|
/** Push `text` onto the view's native tooltip, if the native view has one. Empty clears it. */
|
|
2
4
|
export declare function applyNativeTooltip(view: object, text: string, apiLevel?: number): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/adwaita-nativescript",
|
|
3
|
-
"version": "0.64.1-next.
|
|
3
|
+
"version": "0.64.1-next.244",
|
|
4
4
|
"description": "Native Adwaita widgets for the NativeScript runtime — real NativeScript components (StackLayout/GridLayout/Switch/Label) styled like Libadwaita, not a webview",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"design-system"
|
|
74
74
|
],
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@gjsify/adwaita-core": "0.64.1-next.
|
|
77
|
-
"@gjsify/adwaita-fonts": "0.64.1-next.
|
|
78
|
-
"@gjsify/adwaita-icons": "0.64.1-next.
|
|
79
|
-
"@gjsify/canvas2d-core": "0.64.1-next.
|
|
80
|
-
"@gjsify/native-platform": "0.64.1-next.
|
|
76
|
+
"@gjsify/adwaita-core": "0.64.1-next.244",
|
|
77
|
+
"@gjsify/adwaita-fonts": "0.64.1-next.244",
|
|
78
|
+
"@gjsify/adwaita-icons": "0.64.1-next.244",
|
|
79
|
+
"@gjsify/canvas2d-core": "0.64.1-next.244",
|
|
80
|
+
"@gjsify/native-platform": "0.64.1-next.244"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"@nativescript/core": "*",
|
|
84
|
-
"@gjsify/app-settings": "0.64.1-next.
|
|
84
|
+
"@gjsify/app-settings": "0.64.1-next.244"
|
|
85
85
|
},
|
|
86
86
|
"peerDependenciesMeta": {
|
|
87
87
|
"@nativescript/core": {
|
|
@@ -92,11 +92,11 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
|
-
"@gjsify/app-settings": "0.64.1-next.
|
|
96
|
-
"@gjsify/blueprint": "0.64.1-next.
|
|
97
|
-
"@gjsify/cli": "0.64.1-next.
|
|
98
|
-
"@gjsify/unit": "0.64.1-next.
|
|
99
|
-
"@gjsify/vite-plugin-blueprint": "0.64.1-next.
|
|
95
|
+
"@gjsify/app-settings": "0.64.1-next.244",
|
|
96
|
+
"@gjsify/blueprint": "0.64.1-next.244",
|
|
97
|
+
"@gjsify/cli": "0.64.1-next.244",
|
|
98
|
+
"@gjsify/unit": "0.64.1-next.244",
|
|
99
|
+
"@gjsify/vite-plugin-blueprint": "0.64.1-next.244",
|
|
100
100
|
"@types/node": "^25.9.2",
|
|
101
101
|
"typescript": "^6.0.3"
|
|
102
102
|
},
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"url": "https://github.com/gjsify/gjsify/issues"
|
|
127
127
|
},
|
|
128
128
|
"homepage": "https://github.com/gjsify/gjsify/tree/main/packages/nativescript-bridge/adwaita#readme",
|
|
129
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "9a6ca179c1a74477f23791c5b8f6d5a7bffaee61"
|
|
130
130
|
}
|