@nativescript-community/ui-label 1.2.16 → 1.2.19
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 +31 -19
- package/README.md +4 -4
- package/label-common.js +2 -2
- package/label.android.js +4 -5
- package/label.ios.js +23 -18
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,18 @@
|
|
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.19](https://github.com/nativescript-community/ui-label/compare/v1.2.18...v1.2.19) (2023-01-17)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
9
|
+
|
10
|
+
## [1.2.18](https://github.com/nativescript-community/ui-label/compare/v1.2.17...v1.2.18) (2023-01-17)
|
11
|
+
|
12
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
13
|
+
|
14
|
+
## [1.2.17](https://github.com/nativescript-community/ui-label/compare/v1.2.16...v1.2.17) (2023-01-12)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
17
|
+
|
6
18
|
## [1.2.16](https://github.com/nativescript-community/ui-label/compare/v1.2.15...v1.2.16) (2022-12-01)
|
7
19
|
|
8
20
|
**Note:** Version bump only for package @nativescript-community/ui-label
|
@@ -286,7 +298,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
286
298
|
|
287
299
|
## [1.0.41](https://github.com/nativescript-community/ui-label/compare/v1.0.40...v1.0.41) (2020-07-26)
|
288
300
|
|
289
|
-
**Note:** Version bump only for package nativescript-
|
301
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
290
302
|
|
291
303
|
## [1.0.40](https://github.com/nativescript-community/ui-label/compare/v1.0.39...v1.0.40) (2020-07-26)
|
292
304
|
|
@@ -314,7 +326,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
314
326
|
|
315
327
|
## [1.0.36](https://github.com/nativescript-community/ui-label/compare/v1.0.35...v1.0.36) (2020-05-21)
|
316
328
|
|
317
|
-
**Note:** Version bump only for package nativescript-
|
329
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
318
330
|
|
319
331
|
## [1.0.35](https://github.com/nativescript-community/ui-label/compare/v1.0.34...v1.0.35) (2020-05-21)
|
320
332
|
|
@@ -324,11 +336,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
324
336
|
|
325
337
|
## [1.0.34](https://github.com/nativescript-community/ui-label/compare/v1.0.33...v1.0.34) (2020-05-21)
|
326
338
|
|
327
|
-
**Note:** Version bump only for package nativescript-
|
339
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
328
340
|
|
329
341
|
## [1.0.33](https://github.com/nativescript-community/ui-label/compare/v1.0.32...v1.0.33) (2020-05-21)
|
330
342
|
|
331
|
-
**Note:** Version bump only for package nativescript-
|
343
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
332
344
|
|
333
345
|
## [1.0.32](https://github.com/nativescript-community/ui-label/compare/v1.0.31...v1.0.32) (2020-05-10)
|
334
346
|
|
@@ -356,7 +368,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
356
368
|
|
357
369
|
## [1.0.28](https://github.com/nativescript-community/ui-label/compare/v1.0.27...v1.0.28) (2020-04-29)
|
358
370
|
|
359
|
-
**Note:** Version bump only for package nativescript-
|
371
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
360
372
|
|
361
373
|
## [1.0.27](https://github.com/nativescript-community/ui-label/compare/v1.0.26...v1.0.27) (2020-03-30)
|
362
374
|
|
@@ -372,19 +384,19 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
372
384
|
|
373
385
|
## [1.0.25](https://github.com/nativescript-community/ui-label/compare/v1.0.24...v1.0.25) (2020-03-04)
|
374
386
|
|
375
|
-
**Note:** Version bump only for package nativescript-
|
387
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
376
388
|
|
377
389
|
## [1.0.24](https://github.com/nativescript-community/ui-label/compare/v1.0.23...v1.0.24) (2020-03-04)
|
378
390
|
|
379
|
-
**Note:** Version bump only for package nativescript-
|
391
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
380
392
|
|
381
393
|
## [1.0.23](https://github.com/nativescript-community/ui-label/compare/v1.0.22...v1.0.23) (2020-03-02)
|
382
394
|
|
383
|
-
**Note:** Version bump only for package nativescript-
|
395
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
384
396
|
|
385
397
|
## [1.0.22](https://github.com/nativescript-community/ui-label/compare/v1.0.21...v1.0.22) (2020-02-27)
|
386
398
|
|
387
|
-
**Note:** Version bump only for package nativescript-
|
399
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
388
400
|
|
389
401
|
## [1.0.21](https://github.com/nativescript-community/ui-label/compare/v1.0.20...v1.0.21) (2020-02-26)
|
390
402
|
|
@@ -394,11 +406,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
394
406
|
|
395
407
|
## [1.0.20](https://github.com/nativescript-community/ui-label/compare/v1.0.19...v1.0.20) (2020-02-17)
|
396
408
|
|
397
|
-
**Note:** Version bump only for package nativescript-
|
409
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
398
410
|
|
399
411
|
## [1.0.19](https://github.com/nativescript-community/ui-label/compare/v1.0.18...v1.0.19) (2020-02-17)
|
400
412
|
|
401
|
-
**Note:** Version bump only for package nativescript-
|
413
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
402
414
|
|
403
415
|
## [1.0.18](https://github.com/nativescript-community/ui-label/compare/v1.0.17...v1.0.18) (2020-02-14)
|
404
416
|
|
@@ -420,35 +432,35 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
420
432
|
|
421
433
|
## [1.0.15](https://github.com/nativescript-community/ui-label/compare/v1.0.14...v1.0.15) (2020-02-07)
|
422
434
|
|
423
|
-
**Note:** Version bump only for package nativescript-
|
435
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
424
436
|
|
425
437
|
## [1.0.14](https://github.com/nativescript-community/ui-label/compare/v1.0.13...v1.0.14) (2019-10-18)
|
426
438
|
|
427
|
-
**Note:** Version bump only for package nativescript-
|
439
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
428
440
|
|
429
441
|
## [1.0.13](https://github.com/nativescript-community/ui-label/compare/v1.0.12...v1.0.13) (2019-10-16)
|
430
442
|
|
431
|
-
**Note:** Version bump only for package nativescript-
|
443
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
432
444
|
|
433
445
|
## [1.0.12](https://github.com/nativescript-community/ui-label/compare/v1.0.11...v1.0.12) (2019-10-16)
|
434
446
|
|
435
|
-
**Note:** Version bump only for package nativescript-
|
447
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
436
448
|
|
437
449
|
## [1.0.11](https://github.com/nativescript-community/ui-label/compare/v1.0.10...v1.0.11) (2019-08-22)
|
438
450
|
|
439
|
-
**Note:** Version bump only for package nativescript-
|
451
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
440
452
|
|
441
453
|
## [1.0.10](https://github.com/nativescript-community/ui-label/compare/v1.0.9...v1.0.10) (2019-08-02)
|
442
454
|
|
443
|
-
**Note:** Version bump only for package nativescript-
|
455
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
444
456
|
|
445
457
|
## [1.0.9](https://github.com/nativescript-community/ui-label/compare/v1.0.8...v1.0.9) (2019-07-29)
|
446
458
|
|
447
|
-
**Note:** Version bump only for package nativescript-
|
459
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
448
460
|
|
449
461
|
## [1.0.8](https://github.com/nativescript-community/ui-label/compare/v1.0.7...v1.0.8) (2019-07-12)
|
450
462
|
|
451
|
-
**Note:** Version bump only for package nativescript-
|
463
|
+
**Note:** Version bump only for package @nativescript-community/ui-label
|
452
464
|
|
453
465
|
## 1.0.7 (2019-07-12)
|
454
466
|
|
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;
|
@@ -296,7 +301,6 @@ export class Label extends LabelBase {
|
|
296
301
|
if (textTransform !== 'none' && textTransform !== 'initial') {
|
297
302
|
spanText = getTransformedText(spanText, textTransform);
|
298
303
|
}
|
299
|
-
spanStart += spanText.length;
|
300
304
|
if (characterRange.location - 1 <= spanStart && characterRange.location - 1 + characterRange.length > spanStart) {
|
301
305
|
const span = this.formattedText.spans.getItem(i);
|
302
306
|
if (span && span.tappable) {
|
@@ -305,6 +309,7 @@ export class Label extends LabelBase {
|
|
305
309
|
}
|
306
310
|
break;
|
307
311
|
}
|
312
|
+
spanStart += spanText.length;
|
308
313
|
}
|
309
314
|
return false;
|
310
315
|
}
|
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.19",
|
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": "7ebfca2cd7bd3a360f58cba96c25739db916c79e"
|
38
38
|
}
|