@nativescript-community/ui-label 1.2.16 → 1.2.18
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 +27 -19
- package/README.md +4 -4
- package/label-common.js +2 -2
- package/label.android.js +4 -5
- package/label.ios.js +22 -17
- package/package.json +2 -2
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.18](https://github.com/nativescript-community/ui-label/compare/v1.2.17...v1.2.18) (2023-01-17)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
9
|
+
|
10
|
+
## [1.2.17](https://github.com/nativescript-community/ui-label/compare/v1.2.16...v1.2.17) (2023-01-12)
|
11
|
+
|
12
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
13
|
+
|
6
14
|
## [1.2.16](https://github.com/nativescript-community/ui-label/compare/v1.2.15...v1.2.16) (2022-12-01)
|
7
15
|
|
8
16
|
**Note:** Version bump only for package @nativescript-community/ui-label
|
@@ -286,7 +294,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
286
294
|
|
287
295
|
## [1.0.41](https://github.com/nativescript-community/ui-label/compare/v1.0.40...v1.0.41) (2020-07-26)
|
288
296
|
|
289
|
-
**Note:** Version bump only for package nativescript-
|
297
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
290
298
|
|
291
299
|
## [1.0.40](https://github.com/nativescript-community/ui-label/compare/v1.0.39...v1.0.40) (2020-07-26)
|
292
300
|
|
@@ -314,7 +322,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
314
322
|
|
315
323
|
## [1.0.36](https://github.com/nativescript-community/ui-label/compare/v1.0.35...v1.0.36) (2020-05-21)
|
316
324
|
|
317
|
-
**Note:** Version bump only for package nativescript-
|
325
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
318
326
|
|
319
327
|
## [1.0.35](https://github.com/nativescript-community/ui-label/compare/v1.0.34...v1.0.35) (2020-05-21)
|
320
328
|
|
@@ -324,11 +332,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
324
332
|
|
325
333
|
## [1.0.34](https://github.com/nativescript-community/ui-label/compare/v1.0.33...v1.0.34) (2020-05-21)
|
326
334
|
|
327
|
-
**Note:** Version bump only for package nativescript-
|
335
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
328
336
|
|
329
337
|
## [1.0.33](https://github.com/nativescript-community/ui-label/compare/v1.0.32...v1.0.33) (2020-05-21)
|
330
338
|
|
331
|
-
**Note:** Version bump only for package nativescript-
|
339
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
332
340
|
|
333
341
|
## [1.0.32](https://github.com/nativescript-community/ui-label/compare/v1.0.31...v1.0.32) (2020-05-10)
|
334
342
|
|
@@ -356,7 +364,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
356
364
|
|
357
365
|
## [1.0.28](https://github.com/nativescript-community/ui-label/compare/v1.0.27...v1.0.28) (2020-04-29)
|
358
366
|
|
359
|
-
**Note:** Version bump only for package nativescript-
|
367
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
360
368
|
|
361
369
|
## [1.0.27](https://github.com/nativescript-community/ui-label/compare/v1.0.26...v1.0.27) (2020-03-30)
|
362
370
|
|
@@ -372,19 +380,19 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
372
380
|
|
373
381
|
## [1.0.25](https://github.com/nativescript-community/ui-label/compare/v1.0.24...v1.0.25) (2020-03-04)
|
374
382
|
|
375
|
-
**Note:** Version bump only for package nativescript-
|
383
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
376
384
|
|
377
385
|
## [1.0.24](https://github.com/nativescript-community/ui-label/compare/v1.0.23...v1.0.24) (2020-03-04)
|
378
386
|
|
379
|
-
**Note:** Version bump only for package nativescript-
|
387
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
380
388
|
|
381
389
|
## [1.0.23](https://github.com/nativescript-community/ui-label/compare/v1.0.22...v1.0.23) (2020-03-02)
|
382
390
|
|
383
|
-
**Note:** Version bump only for package nativescript-
|
391
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
384
392
|
|
385
393
|
## [1.0.22](https://github.com/nativescript-community/ui-label/compare/v1.0.21...v1.0.22) (2020-02-27)
|
386
394
|
|
387
|
-
**Note:** Version bump only for package nativescript-
|
395
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
388
396
|
|
389
397
|
## [1.0.21](https://github.com/nativescript-community/ui-label/compare/v1.0.20...v1.0.21) (2020-02-26)
|
390
398
|
|
@@ -394,11 +402,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
394
402
|
|
395
403
|
## [1.0.20](https://github.com/nativescript-community/ui-label/compare/v1.0.19...v1.0.20) (2020-02-17)
|
396
404
|
|
397
|
-
**Note:** Version bump only for package nativescript-
|
405
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
398
406
|
|
399
407
|
## [1.0.19](https://github.com/nativescript-community/ui-label/compare/v1.0.18...v1.0.19) (2020-02-17)
|
400
408
|
|
401
|
-
**Note:** Version bump only for package nativescript-
|
409
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
402
410
|
|
403
411
|
## [1.0.18](https://github.com/nativescript-community/ui-label/compare/v1.0.17...v1.0.18) (2020-02-14)
|
404
412
|
|
@@ -420,35 +428,35 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
420
428
|
|
421
429
|
## [1.0.15](https://github.com/nativescript-community/ui-label/compare/v1.0.14...v1.0.15) (2020-02-07)
|
422
430
|
|
423
|
-
**Note:** Version bump only for package nativescript-
|
431
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
424
432
|
|
425
433
|
## [1.0.14](https://github.com/nativescript-community/ui-label/compare/v1.0.13...v1.0.14) (2019-10-18)
|
426
434
|
|
427
|
-
**Note:** Version bump only for package nativescript-
|
435
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
428
436
|
|
429
437
|
## [1.0.13](https://github.com/nativescript-community/ui-label/compare/v1.0.12...v1.0.13) (2019-10-16)
|
430
438
|
|
431
|
-
**Note:** Version bump only for package nativescript-
|
439
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
432
440
|
|
433
441
|
## [1.0.12](https://github.com/nativescript-community/ui-label/compare/v1.0.11...v1.0.12) (2019-10-16)
|
434
442
|
|
435
|
-
**Note:** Version bump only for package nativescript-
|
443
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
436
444
|
|
437
445
|
## [1.0.11](https://github.com/nativescript-community/ui-label/compare/v1.0.10...v1.0.11) (2019-08-22)
|
438
446
|
|
439
|
-
**Note:** Version bump only for package nativescript-
|
447
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
440
448
|
|
441
449
|
## [1.0.10](https://github.com/nativescript-community/ui-label/compare/v1.0.9...v1.0.10) (2019-08-02)
|
442
450
|
|
443
|
-
**Note:** Version bump only for package nativescript-
|
451
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
444
452
|
|
445
453
|
## [1.0.9](https://github.com/nativescript-community/ui-label/compare/v1.0.8...v1.0.9) (2019-07-29)
|
446
454
|
|
447
|
-
**Note:** Version bump only for package nativescript-
|
455
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
448
456
|
|
449
457
|
## [1.0.8](https://github.com/nativescript-community/ui-label/compare/v1.0.7...v1.0.8) (2019-07-12)
|
450
458
|
|
451
|
-
**Note:** Version bump only for package nativescript-
|
459
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
452
460
|
|
453
461
|
## 1.0.7 (2019-07-12)
|
454
462
|
|
package/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# NativeScript Label widget
|
2
2
|
|
3
|
-
[](https://www.npmjs.com/package/@nativescript-community/ui-label)
|
4
|
+
[](https://www.npmjs.com/package/@nativescript-community/ui-label)
|
5
|
+
[](https://www.npmjs.com/package/@nativescript-community/ui-label)
|
6
6
|
|
7
7
|
A NativeScript Label widget. It is a direct replacement for the {N} Label widget.
|
8
8
|
|
@@ -12,7 +12,7 @@ Run the following command from the root of your project:
|
|
12
12
|
|
13
13
|
`tns plugin add @nativescript-community/ui-label`
|
14
14
|
|
15
|
-
This command automatically installs the necessary files, as well as stores nativescript-
|
15
|
+
This command automatically installs the necessary files, as well as stores nativescript-community/ui-label as a dependency in your project's package.json file.
|
16
16
|
|
17
17
|
## Configuration
|
18
18
|
|
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 {
|
3
|
+
import { Utils } from '@nativescript/core';
|
4
4
|
// declare module '@nativescript/core/ui/text-base/formatted-string' {
|
5
5
|
// interface FormattedString {
|
6
6
|
// addPropertyChangeHandler(span: Span);
|
@@ -141,7 +141,7 @@ export const maxFontSizeProperty = new CssProperty({
|
|
141
141
|
maxFontSizeProperty.register(Style);
|
142
142
|
function parseDIPs(value) {
|
143
143
|
if (value.indexOf('px') !== -1) {
|
144
|
-
return layout.toDeviceIndependentPixels(parseFloat(value.replace('px', '').trim()));
|
144
|
+
return Utils.layout.toDeviceIndependentPixels(parseFloat(value.replace('px', '').trim()));
|
145
145
|
}
|
146
146
|
else {
|
147
147
|
return parseFloat(value.replace('dip', '').trim());
|
package/label.android.js
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
import { LightFormattedString, createNativeAttributedString, cssProperty, overrideSpanAndFormattedStringEnabled, verticalTextAlignmentProperty } from '@nativescript-community/text';
|
2
|
-
import { CSSType, Device, FormattedString, Observable, Property, Span, View, booleanConverter, profile } from '@nativescript/core';
|
2
|
+
import { CSSType, Device, FormattedString, Observable, Property, Span, Utils, View, booleanConverter, profile } from '@nativescript/core';
|
3
3
|
import { Color } from '@nativescript/core/color';
|
4
4
|
import { Font } from '@nativescript/core/ui/styling/font';
|
5
5
|
import { Length, colorProperty, fontInternalProperty, fontSizeProperty, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty } from '@nativescript/core/ui/styling/style-properties';
|
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/layout-helper';
|
10
9
|
import { autoFontSizeProperty, lineBreakProperty, selectableProperty, textShadowProperty } from './label-common';
|
11
10
|
export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
|
12
11
|
export * from './label-common';
|
@@ -391,11 +390,11 @@ export class Label extends LabelBase {
|
|
391
390
|
}
|
392
391
|
[lineHeightProperty.setNative](value) {
|
393
392
|
if (sdkVersion() >= 28) {
|
394
|
-
this.nativeTextViewProtected.setLineHeight(value * layout.getDisplayDensity());
|
393
|
+
this.nativeTextViewProtected.setLineHeight(value * Utils.layout.getDisplayDensity());
|
395
394
|
}
|
396
395
|
else {
|
397
396
|
const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null);
|
398
|
-
this.nativeTextViewProtected.setLineSpacing(value * layout.getDisplayDensity() - fontHeight, 1);
|
397
|
+
this.nativeTextViewProtected.setLineSpacing(value * Utils.layout.getDisplayDensity() - fontHeight, 1);
|
399
398
|
}
|
400
399
|
}
|
401
400
|
[fontInternalProperty.setNative](value) {
|
@@ -403,7 +402,7 @@ export class Label extends LabelBase {
|
|
403
402
|
this.nativeTextViewProtected.setTypeface(androidFont);
|
404
403
|
if (this.lineHeight && sdkVersion() < 28) {
|
405
404
|
const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null);
|
406
|
-
this.nativeTextViewProtected.setLineSpacing(this.lineHeight * layout.getDisplayDensity() - fontHeight, 1);
|
405
|
+
this.nativeTextViewProtected.setLineSpacing(this.lineHeight * Utils.layout.getDisplayDensity() - fontHeight, 1);
|
407
406
|
}
|
408
407
|
}
|
409
408
|
[textDecorationProperty.setNative](value) {
|
package/label.ios.js
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
var _a, _b, _c, _d;
|
2
2
|
import { createNativeAttributedString, verticalTextAlignmentProperty } from '@nativescript-community/text';
|
3
|
-
import { Color, Font, Span, View } from '@nativescript/core';
|
3
|
+
import { Color, Font, Span, Utils, View } from '@nativescript/core';
|
4
4
|
import { borderBottomWidthProperty, borderLeftWidthProperty, borderRightWidthProperty, borderTopWidthProperty, fontInternalProperty, paddingBottomProperty, paddingLeftProperty, paddingRightProperty, paddingTopProperty } from '@nativescript/core/ui/styling/style-properties';
|
5
5
|
import { formattedTextProperty, letterSpacingProperty, lineHeightProperty, whiteSpaceProperty } from '@nativescript/core/ui/text-base';
|
6
6
|
import { maxLinesProperty } from '@nativescript/core/ui/text-base/text-base-common';
|
7
|
+
import { iOSNativeHelper } from '@nativescript/core/utils';
|
7
8
|
import { isNullOrUndefined, isString } from '@nativescript/core/utils/types';
|
8
|
-
import { layout } from '@nativescript/core/utils/layout-helper';
|
9
9
|
import { LabelBase, autoFontSizeProperty, htmlProperty, lineBreakProperty, linkColorProperty, linkUnderlineProperty, needFormattedStringComputation, selectableProperty, textShadowProperty } from './label-common';
|
10
|
-
import { iOSNativeHelper } from '@nativescript/core/utils';
|
11
10
|
export { createNativeAttributedString, enableIOSDTCoreText } from '@nativescript-community/text';
|
12
11
|
export * from './label-common';
|
13
12
|
const majorVersion = iOSNativeHelper.MajorVersion;
|
@@ -179,10 +178,10 @@ export class Label extends LabelBase {
|
|
179
178
|
}
|
180
179
|
updateTextContainerInset(applyVerticalTextAlignment = true) {
|
181
180
|
const tv = this.nativeTextViewProtected;
|
182
|
-
const top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
|
183
|
-
const right = layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth);
|
184
|
-
const bottom = layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth);
|
185
|
-
const left = layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth);
|
181
|
+
const top = Utils.layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
|
182
|
+
const right = Utils.layout.toDeviceIndependentPixels(this.effectivePaddingRight + this.effectiveBorderRightWidth);
|
183
|
+
const bottom = Utils.layout.toDeviceIndependentPixels(this.effectivePaddingBottom + this.effectiveBorderBottomWidth);
|
184
|
+
const left = Utils.layout.toDeviceIndependentPixels(this.effectivePaddingLeft + this.effectiveBorderLeftWidth);
|
186
185
|
if (!applyVerticalTextAlignment ||
|
187
186
|
!this.verticalTextAlignment ||
|
188
187
|
(tv.text?.length === 0 && tv.attributedText?.length === 0)) {
|
@@ -244,28 +243,28 @@ export class Label extends LabelBase {
|
|
244
243
|
onMeasure(widthMeasureSpec, heightMeasureSpec) {
|
245
244
|
const nativeView = this.nativeTextViewProtected;
|
246
245
|
if (nativeView) {
|
247
|
-
const width = layout.getMeasureSpecSize(widthMeasureSpec);
|
248
|
-
const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
|
249
|
-
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
250
|
-
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
246
|
+
const width = Utils.layout.getMeasureSpecSize(widthMeasureSpec);
|
247
|
+
const widthMode = Utils.layout.getMeasureSpecMode(widthMeasureSpec);
|
248
|
+
const height = Utils.layout.getMeasureSpecSize(heightMeasureSpec);
|
249
|
+
const heightMode = Utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
251
250
|
let resetFont;
|
252
251
|
if (this.autoFontSize) {
|
253
|
-
const finiteWidth = widthMode === layout.EXACTLY;
|
254
|
-
const finiteHeight = heightMode === layout.EXACTLY;
|
252
|
+
const finiteWidth = widthMode === Utils.layout.EXACTLY;
|
253
|
+
const finiteHeight = heightMode === Utils.layout.EXACTLY;
|
255
254
|
if (!finiteWidth || !finiteHeight) {
|
256
255
|
resetFont = this.updateAutoFontSize({
|
257
256
|
textView: nativeView,
|
258
|
-
width: layout.toDeviceIndependentPixels(width),
|
259
|
-
height: layout.toDeviceIndependentPixels(height),
|
257
|
+
width: Utils.layout.toDeviceIndependentPixels(width),
|
258
|
+
height: Utils.layout.toDeviceIndependentPixels(height),
|
260
259
|
onlyMeasure: true
|
261
260
|
});
|
262
261
|
}
|
263
262
|
}
|
264
|
-
const desiredSize = layout.measureNativeView(nativeView, width, widthMode, height, heightMode);
|
263
|
+
const desiredSize = Utils.layout.measureNativeView(nativeView, width, widthMode, height, heightMode);
|
265
264
|
if (!this.formattedText && !this.html && resetFont) {
|
266
265
|
nativeView.font = resetFont;
|
267
266
|
}
|
268
|
-
const labelWidth = widthMode === layout.AT_MOST ? Math.min(desiredSize.width, width) : desiredSize.width;
|
267
|
+
const labelWidth = widthMode === Utils.layout.AT_MOST ? Math.min(desiredSize.width, width) : desiredSize.width;
|
269
268
|
// const labelHeight = heightMode === layout.AT_MOST ? Math.min(desiredSize.height, height) : desiredSize.height;
|
270
269
|
const measureWidth = Math.max(labelWidth, this.effectiveMinWidth);
|
271
270
|
const measureHeight = Math.max(desiredSize.height, this.effectiveMinHeight);
|
@@ -288,6 +287,12 @@ export class Label extends LabelBase {
|
|
288
287
|
}
|
289
288
|
}
|
290
289
|
textViewShouldInteractWithURLInRangeInteraction(textView, url, characterRange, interaction) {
|
290
|
+
if (!this.formattedText?.spans) {
|
291
|
+
if (url) {
|
292
|
+
this.notify({ eventName: Span.linkTapEvent, link: url?.toString() });
|
293
|
+
}
|
294
|
+
return false;
|
295
|
+
}
|
291
296
|
for (let i = 0, spanStart = 0, length = this.formattedText.spans.length; i < length; i++) {
|
292
297
|
const span = this.formattedText.spans.getItem(i);
|
293
298
|
const text = span.text;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/ui-label",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.18",
|
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": "
|
37
|
+
"gitHead": "ae294ad826343d7d82fae189b32a95f9ad14b4af"
|
38
38
|
}
|