@nativescript-community/ui-label 1.2.14 → 1.2.16

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
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.16](https://github.com/nativescript-community/ui-label/compare/v1.2.15...v1.2.16) (2022-12-01)
7
+
8
+ **Note:** Version bump only for package @nativescript-community/ui-label
9
+
10
+ ## [1.2.15](https://github.com/nativescript-community/ui-label/compare/v1.2.14...v1.2.15) (2022-11-21)
11
+
12
+ **Note:** Version bump only for package @nativescript-community/ui-label
13
+
6
14
  ## [1.2.14](https://github.com/nativescript-community/ui-label/compare/v1.2.13...v1.2.14) (2022-11-20)
7
15
 
8
16
  **Note:** Version bump only for package @nativescript-community/ui-label
package/label-common.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cssProperty, init } from '@nativescript-community/text';
2
2
  import { CSSType, Color, CssProperty, Property, Style, Label as TNLabel, booleanConverter, fontInternalProperty } from '@nativescript/core';
3
- import { layout } from '@nativescript/core/utils/utils';
3
+ import { layout } from '@nativescript/core/utils/layout-helper';
4
4
  // declare module '@nativescript/core/ui/text-base/formatted-string' {
5
5
  // interface FormattedString {
6
6
  // addPropertyChangeHandler(span: Span);
@@ -2,7 +2,7 @@ import { VerticalTextAlignment } from '@nativescript-community/text';
2
2
  import { CoreTypes, FormattedString, Property, PropertyChangeData, View } from '@nativescript/core';
3
3
  import { Color } from '@nativescript/core/color';
4
4
  import { CSSShadow } from '@nativescript/core/ui/styling/css-shadow';
5
- import { FontStyle, FontWeight } from '@nativescript/core/ui/styling/font';
5
+ import { FontStyleType, FontWeightType } from '@nativescript/core/ui/styling/font';
6
6
  import { Label as LabelViewDefinition, LineBreak } from './label';
7
7
  export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
8
8
  export * from './label-common';
@@ -32,8 +32,8 @@ declare abstract class LabelBase extends View implements LabelViewDefinition {
32
32
  _setTappableState(value: boolean): void;
33
33
  fontFamily: string;
34
34
  fontSize: number;
35
- fontStyle: FontStyle;
36
- fontWeight: FontWeight;
35
+ fontStyle: FontStyleType;
36
+ fontWeight: FontWeightType;
37
37
  letterSpacing: number;
38
38
  lineHeight: number;
39
39
  lineBreak: LineBreak;
package/label.android.js CHANGED
@@ -6,7 +6,7 @@ import { Length, colorProperty, fontInternalProperty, fontSizeProperty, paddingB
6
6
  import { letterSpacingProperty, lineHeightProperty, textAlignmentProperty, textDecorationProperty, textTransformProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
7
7
  import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
8
8
  import lazy from '@nativescript/core/utils/lazy';
9
- import { layout } from '@nativescript/core/utils/utils';
9
+ import { layout } from '@nativescript/core/utils/layout-helper';
10
10
  import { autoFontSizeProperty, lineBreakProperty, selectableProperty, textShadowProperty } from './label-common';
11
11
  export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
12
12
  export * from './label-common';
@@ -51,27 +51,26 @@ function initializeClickableSpan() {
51
51
  if (ClickableSpan) {
52
52
  return;
53
53
  }
54
- let ClickableSpanImpl = class ClickableSpanImpl extends android.text.style.ClickableSpan {
55
- constructor(owner) {
56
- super();
57
- this.owner = new WeakRef(owner);
58
- return global.__native(this);
59
- }
60
- onClick(view) {
61
- const owner = this.owner.get();
62
- if (owner) {
63
- owner._emit(Span.linkTapEvent);
64
- }
65
- view.clearFocus();
66
- view.invalidate();
67
- }
68
- updateDrawState(tp) {
69
- // don't style as link
54
+ var ClickableSpanImpl = /** @class */ (function (_super) {
55
+ __extends(ClickableSpanImpl, _super);
56
+ function ClickableSpanImpl(owner) {
57
+ var _this = _super.call(this) || this;
58
+ _this.owner = new WeakRef(owner);
59
+ return global.__native(_this);
60
+ }
61
+ ClickableSpanImpl.prototype.onClick = function (view) {
62
+ var owner = this.owner.get();
63
+ if (owner) {
64
+ owner._emit(Span.linkTapEvent);
70
65
  }
66
+ view.clearFocus();
67
+ view.invalidate();
68
+ };
69
+ ClickableSpanImpl.prototype.updateDrawState = function (tp) {
70
+ // don't style as link
71
71
  };
72
- ClickableSpanImpl = __decorate([
73
- NativeClass
74
- ], ClickableSpanImpl);
72
+ return ClickableSpanImpl;
73
+ }(android.text.style.ClickableSpan));
75
74
  ClickableSpan = ClickableSpanImpl;
76
75
  }
77
76
  // eslint-disable-next-line no-redeclare
@@ -80,36 +79,35 @@ function initializeURLClickableSpan() {
80
79
  if (URLClickableSpan) {
81
80
  return;
82
81
  }
83
- let URLClickableSpanImpl = class URLClickableSpanImpl extends android.text.style.URLSpan {
84
- constructor(url, owner) {
85
- super(url);
86
- this.owner = new WeakRef(owner);
87
- return global.__native(this);
82
+ var URLClickableSpanImpl = /** @class */ (function (_super) {
83
+ __extends(URLClickableSpanImpl, _super);
84
+ function URLClickableSpanImpl(url, owner) {
85
+ var _this = _super.call(this, url) || this;
86
+ _this.owner = new WeakRef(owner);
87
+ return global.__native(_this);
88
+ }
89
+ URLClickableSpanImpl.prototype.onClick = function (view) {
90
+ var owner = this.owner.get();
91
+ if (owner) {
92
+ owner.notify({ eventName: Span.linkTapEvent, object: owner, link: this.getURL() });
88
93
  }
89
- onClick(view) {
90
- const owner = this.owner.get();
91
- if (owner) {
92
- owner.notify({ eventName: Span.linkTapEvent, object: owner, link: this.getURL() });
93
- }
94
- view.clearFocus();
95
- view.invalidate();
94
+ view.clearFocus();
95
+ view.invalidate();
96
+ };
97
+ URLClickableSpanImpl.prototype.updateDrawState = function (tp) {
98
+ var owner = this.owner.get();
99
+ if (!owner || owner.linkUnderline !== false) {
100
+ _super.prototype.updateDrawState.call(this, tp);
96
101
  }
97
- updateDrawState(tp) {
98
- const owner = this.owner.get();
99
- if (!owner || owner.linkUnderline !== false) {
100
- super.updateDrawState(tp);
101
- }
102
- if (owner && owner.linkColor) {
103
- const color = !owner.linkColor || owner.linkColor instanceof Color
104
- ? owner.linkColor
105
- : new Color(owner.linkColor);
106
- tp.setColor(color.android);
107
- }
102
+ if (owner && owner.linkColor) {
103
+ var color = !owner.linkColor || owner.linkColor instanceof Color
104
+ ? owner.linkColor
105
+ : new Color(owner.linkColor);
106
+ tp.setColor(color.android);
108
107
  }
109
108
  };
110
- URLClickableSpanImpl = __decorate([
111
- NativeClass
112
- ], URLClickableSpanImpl);
109
+ return URLClickableSpanImpl;
110
+ }(android.text.style.URLSpan));
113
111
  URLClickableSpan = URLClickableSpanImpl;
114
112
  }
115
113
  let LabelBase = class LabelBase extends View {
package/label.ios.js CHANGED
@@ -1,4 +1,3 @@
1
- var LabelUITextViewDelegateImpl_1;
2
1
  var _a, _b, _c, _d;
3
2
  import { createNativeAttributedString, verticalTextAlignmentProperty } from '@nativescript-community/text';
4
3
  import { Color, Font, Span, View } from '@nativescript/core';
@@ -6,8 +5,9 @@ import { borderBottomWidthProperty, borderLeftWidthProperty, borderRightWidthPro
6
5
  import { formattedTextProperty, letterSpacingProperty, lineHeightProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
7
6
  import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
8
7
  import { isNullOrUndefined, isString } from '@nativescript/core/utils/types';
9
- import { iOSNativeHelper, layout } from '@nativescript/core/utils/utils';
8
+ import { layout } from '@nativescript/core/utils/layout-helper';
10
9
  import { LabelBase, autoFontSizeProperty, htmlProperty, lineBreakProperty, linkColorProperty, linkUnderlineProperty, needFormattedStringComputation, selectableProperty, textShadowProperty } from './label-common';
10
+ import { iOSNativeHelper } from '@nativescript/core/utils';
11
11
  export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
12
12
  export * from './label-common';
13
13
  const majorVersion = iOSNativeHelper.MajorVersion;
@@ -60,44 +60,48 @@ function whiteSpaceToLineBreakMode(value) {
60
60
  return 4 /* NSLineBreakMode.ByTruncatingTail */;
61
61
  }
62
62
  }
63
- let LabelUITextViewDelegateImpl = LabelUITextViewDelegateImpl_1 = class LabelUITextViewDelegateImpl extends NSObject {
64
- static initWithOwner(owner) {
65
- const impl = LabelUITextViewDelegateImpl_1.new();
63
+ var LabelUITextViewDelegateImpl = /** @class */ (function (_super) {
64
+ __extends(LabelUITextViewDelegateImpl, _super);
65
+ function LabelUITextViewDelegateImpl() {
66
+ return _super !== null && _super.apply(this, arguments) || this;
67
+ }
68
+ LabelUITextViewDelegateImpl.initWithOwner = function (owner) {
69
+ var impl = LabelUITextViewDelegateImpl.new();
66
70
  impl._owner = owner;
67
71
  return impl;
68
- }
69
- textViewShouldInteractWithURLInRangeInteraction(textView, URL, characterRange, interaction) {
70
- const owner = this._owner.get();
72
+ };
73
+ LabelUITextViewDelegateImpl.prototype.textViewShouldInteractWithURLInRangeInteraction = function (textView, URL, characterRange, interaction) {
74
+ var owner = this._owner.get();
71
75
  if (owner) {
72
76
  return owner.textViewShouldInteractWithURLInRangeInteraction(textView, URL, characterRange, interaction);
73
77
  }
74
78
  return false;
75
- }
76
- textViewDidChange(textView) {
77
- const owner = this._owner.get();
79
+ };
80
+ LabelUITextViewDelegateImpl.prototype.textViewDidChange = function (textView) {
81
+ var owner = this._owner.get();
78
82
  if (owner) {
79
83
  owner.textViewDidChange(textView);
80
84
  }
85
+ };
86
+ LabelUITextViewDelegateImpl.ObjCProtocols = [UITextViewDelegate];
87
+ return LabelUITextViewDelegateImpl;
88
+ }(NSObject));
89
+ var LabelObserverClass = /** @class */ (function (_super) {
90
+ __extends(LabelObserverClass, _super);
91
+ function LabelObserverClass() {
92
+ return _super !== null && _super.apply(this, arguments) || this;
81
93
  }
82
- };
83
- LabelUITextViewDelegateImpl.ObjCProtocols = [UITextViewDelegate];
84
- LabelUITextViewDelegateImpl = LabelUITextViewDelegateImpl_1 = __decorate([
85
- NativeClass
86
- ], LabelUITextViewDelegateImpl);
87
- let LabelObserverClass = class LabelObserverClass extends NSObject {
88
94
  // NOTE: Refactor this - use Typescript property instead of strings....
89
- observeValueForKeyPathOfObjectChangeContext(path, tv) {
95
+ LabelObserverClass.prototype.observeValueForKeyPathOfObjectChangeContext = function (path, tv) {
90
96
  if (path === 'contentSize') {
91
- const owner = this._owner && this._owner.get();
97
+ var owner = this._owner && this._owner.get();
92
98
  if (owner) {
93
99
  owner.updateTextContainerInset();
94
100
  }
95
101
  }
96
- }
97
- };
98
- LabelObserverClass = __decorate([
99
- NativeClass
100
- ], LabelObserverClass);
102
+ };
103
+ return LabelObserverClass;
104
+ }(NSObject));
101
105
  export class Label extends LabelBase {
102
106
  constructor() {
103
107
  super(...arguments);
@@ -174,7 +178,6 @@ export class Label extends LabelBase {
174
178
  return result.height;
175
179
  }
176
180
  updateTextContainerInset(applyVerticalTextAlignment = true) {
177
- var _e, _f;
178
181
  const tv = this.nativeTextViewProtected;
179
182
  const top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
180
183
  const right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth);
@@ -182,7 +185,7 @@ export class Label extends LabelBase {
182
185
  const left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth);
183
186
  if (!applyVerticalTextAlignment ||
184
187
  !this.verticalTextAlignment ||
185
- (((_e = tv.text) === null || _e === void 0 ? void 0 : _e.length) === 0 && ((_f = tv.attributedText) === null || _f === void 0 ? void 0 : _f.length) === 0)) {
188
+ (tv.text?.length === 0 && tv.attributedText?.length === 0)) {
186
189
  tv.textContainerInset = {
187
190
  top,
188
191
  left,
@@ -298,7 +301,7 @@ export class Label extends LabelBase {
298
301
  const span = this.formattedText.spans.getItem(i);
299
302
  if (span && span.tappable) {
300
303
  // if the span is found and tappable emit the linkTap event
301
- span.notify({ eventName: Span.linkTapEvent, link: url === null || url === void 0 ? void 0 : url.toString() });
304
+ span.notify({ eventName: Span.linkTapEvent, link: url?.toString() });
302
305
  }
303
306
  break;
304
307
  }
@@ -313,7 +316,7 @@ export class Label extends LabelBase {
313
316
  else {
314
317
  const font = this.nativeViewProtected.font;
315
318
  if (!fontSize) {
316
- fontSize = this.fontSize || (font === null || font === void 0 ? void 0 : font.pointSize) || 17;
319
+ fontSize = this.fontSize || font?.pointSize || 17;
317
320
  }
318
321
  const fontWeight = this.style.fontWeight;
319
322
  const familyName = this.style.fontFamily || (this.style.fontInternal && this.style.fontInternal.fontFamily) || undefined;
@@ -321,7 +324,7 @@ export class Label extends LabelBase {
321
324
  text: this.html,
322
325
  fontSize,
323
326
  familyName,
324
- fontWeight,
327
+ fontWeight: fontWeight,
325
328
  // color: this.color,
326
329
  letterSpacing: this.letterSpacing,
327
330
  lineHeight: this.lineHeight,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-label",
3
- "version": "1.2.14",
3
+ "version": "1.2.16",
4
4
  "description": "Alternative to the built-in NativeScript Label but with better performance and additional features such as HTML rendering and more.",
5
5
  "main": "./label",
6
6
  "sideEffects": false,
@@ -34,5 +34,5 @@
34
34
  "dependencies": {
35
35
  "@nativescript-community/text": "^1.5.9"
36
36
  },
37
- "gitHead": "8e25e7262711dca1e2742e0c8e16c50db611afa5"
37
+ "gitHead": "f00f8a1e5c2ba68a3fd44b9a7c5818ced99100f1"
38
38
  }
@@ -0,0 +1 @@
1
+ /// <reference path="./typings/DTCoreText.ios.d.ts" />
@@ -0,0 +1,23 @@
1
+ declare var DTDefaultTextAlignment: string;
2
+ declare var DTDefaultFontStyle: string;
3
+ declare var DTIgnoreLinkStyleOption: string;
4
+ declare var DTDefaultFontFamily: string;
5
+ declare var DTUseiOS6Attributes: string;
6
+ declare var DTDocumentPreserveTrailingSpaces: string;
7
+ declare var DTDefaultLineBreakMode: string;
8
+ declare var NSTextSizeMultiplierDocumentOption: string;
9
+ declare var kCTLineBreakByWordWrapping: string;
10
+ declare var kCTLeftTextAlignment: string;
11
+ declare var NSAttributedStringEnumerationReverse: number;
12
+
13
+
14
+ declare namespace DTCoreTextFontDescriptor {
15
+ function asyncPreloadFontLookupTable()
16
+ }
17
+
18
+ declare interface NSAttributedString {
19
+ initWithHTMLDataOptionsDocumentAttributes(data, options, attr);
20
+ }
21
+ declare interface NSMutableAttributedString {
22
+ initWithHTMLDataOptionsDocumentAttributes(data, options, attr);
23
+ }
@@ -0,0 +1,11 @@
1
+ declare module com {
2
+ export module lsjwzh {
3
+ export module widget {
4
+ export module text {
5
+ export class FastTextView extends globalAndroid.view.View {
6
+
7
+ }
8
+ }
9
+ }
10
+ }
11
+ }