@lynx-js/web-elements 0.5.2 → 0.5.4

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
@@ -1,5 +1,29 @@
1
1
  # @lynx-js/web-elements
2
2
 
3
+ ## 0.5.4
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: bump the output target to es2024 ([#518](https://github.com/lynx-family/lynx-stack/pull/518))
8
+
9
+ - fix: the `\n` character should create a new line ([#522](https://github.com/lynx-family/lynx-stack/pull/522))
10
+
11
+ add `white-space-collapse: preserve-breaks` to raw-text
12
+
13
+ - fix: the `input` event of x-input with number type should have raw value ([#517](https://github.com/lynx-family/lynx-stack/pull/517))
14
+
15
+ For `type:=number` x-input with typed value "2."
16
+
17
+ Before this commit: the value is "2"
18
+
19
+ After this commit the value is "2."
20
+
21
+ ## 0.5.3
22
+
23
+ ### Patch Changes
24
+
25
+ - feat: add `layoutchange` event support for x-view and x-text ([#408](https://github.com/lynx-family/lynx-stack/pull/408))
26
+
3
27
  ## 0.5.2
4
28
 
5
29
  ### Patch Changes
@@ -37,13 +37,14 @@ let InputBaseAttributes = (() => {
37
37
  // @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
38
38
  let inputMode = 'text';
39
39
  let inputType = 'text';
40
+ /**
41
+ * For number / digit type, if the user is typing "2.", the raw value is expected to remain "2." rather than being altered.
42
+ */
40
43
  if (attributeValue === 'digit') {
41
44
  inputMode = 'numeric';
42
- inputType = 'number';
43
45
  }
44
46
  else if (attributeValue === 'number') {
45
47
  inputMode = 'decimal';
46
- inputType = 'number';
47
48
  }
48
49
  else if (attributeValue === 'email') {
49
50
  inputMode = 'email';
@@ -26,7 +26,7 @@ let XInputEvents = (() => {
26
26
  input.addEventListener('compositionend', this.#teleportCompositionendInput, { passive: true });
27
27
  }
28
28
  else {
29
- input.addEventListener('input', this.#teleportInput, { passive: true });
29
+ input.removeEventListener('input', this.#teleportInput);
30
30
  input.removeEventListener('compositionend', this.#teleportCompositionendInput);
31
31
  }
32
32
  }, "#handleEnableConfirmEvent") }, _private_handleEnableConfirmEvent_decorators, { kind: "method", name: "#handleEnableConfirmEvent", static: false, private: true, access: { has: obj => #handleEnableConfirmEvent in obj, get: obj => obj.#handleEnableConfirmEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
@@ -8,8 +8,9 @@ import { Component, html } from '@lynx-js/web-elements-reactive';
8
8
  import { LynxExposure } from '../common/Exposure.js';
9
9
  import { XTextTruncation } from './XTextTruncation.js';
10
10
  import { ScrollIntoView } from '../ScrollView/ScrollIntoView.js';
11
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
11
12
  let XText = (() => {
12
- let _classDecorators = [Component('x-text', [LynxExposure, XTextTruncation], html `<div id="inner-box" part="inner-box"><slot></slot><slot name="inline-truncation"></slot></div>`)];
13
+ let _classDecorators = [Component('x-text', [LynxExposure, CommonEventsAndMethods, XTextTruncation], html `<div id="inner-box" part="inner-box"><slot></slot><slot name="inline-truncation"></slot></div>`)];
13
14
  let _classDescriptor;
14
15
  let _classExtraInitializers = [];
15
16
  let _classThis;
@@ -7,8 +7,9 @@ import { __esDecorate, __runInitializers } from "tslib";
7
7
  import { Component } from '@lynx-js/web-elements-reactive';
8
8
  import { ScrollIntoView } from '../ScrollView/ScrollIntoView.js';
9
9
  import { LynxExposure } from '../common/Exposure.js';
10
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
10
11
  let XView = (() => {
11
- let _classDecorators = [Component('x-view', [LynxExposure])];
12
+ let _classDecorators = [Component('x-view', [LynxExposure, CommonEventsAndMethods])];
12
13
  let _classDescriptor;
13
14
  let _classExtraInitializers = [];
14
15
  let _classThis;
@@ -0,0 +1,6 @@
1
+ export declare class CommonEventsAndMethods {
2
+ #private;
3
+ static readonly observedAttributes: never[];
4
+ constructor(currentElement: HTMLElement);
5
+ __handleScrollUpperThresholdEventEnabled: (enabled: boolean) => void;
6
+ }
@@ -0,0 +1,61 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { __esDecorate, __runInitializers } from "tslib";
5
+ import { commonComponentEventSetting } from './commonEventInitConfiguration.js';
6
+ import { registerEventEnableStatusChangeHandler } from '@lynx-js/web-elements-reactive';
7
+ let CommonEventsAndMethods = (() => {
8
+ let ___handleScrollUpperThresholdEventEnabled_decorators;
9
+ let ___handleScrollUpperThresholdEventEnabled_initializers = [];
10
+ let ___handleScrollUpperThresholdEventEnabled_extraInitializers = [];
11
+ return class CommonEventsAndMethods {
12
+ static {
13
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
14
+ ___handleScrollUpperThresholdEventEnabled_decorators = [registerEventEnableStatusChangeHandler('layoutchange')];
15
+ __esDecorate(null, null, ___handleScrollUpperThresholdEventEnabled_decorators, { kind: "field", name: "__handleScrollUpperThresholdEventEnabled", static: false, private: false, access: { has: obj => "__handleScrollUpperThresholdEventEnabled" in obj, get: obj => obj.__handleScrollUpperThresholdEventEnabled, set: (obj, value) => { obj.__handleScrollUpperThresholdEventEnabled = value; } }, metadata: _metadata }, ___handleScrollUpperThresholdEventEnabled_initializers, ___handleScrollUpperThresholdEventEnabled_extraInitializers);
16
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
17
+ }
18
+ static observedAttributes = [];
19
+ #dom;
20
+ #observing = false;
21
+ #resizeObserver;
22
+ constructor(currentElement) {
23
+ __runInitializers(this, ___handleScrollUpperThresholdEventEnabled_extraInitializers);
24
+ this.#dom = currentElement;
25
+ }
26
+ __handleScrollUpperThresholdEventEnabled = __runInitializers(this, ___handleScrollUpperThresholdEventEnabled_initializers, (enabled) => {
27
+ if (enabled) {
28
+ if (!this.#resizeObserver) {
29
+ this.#resizeObserver = new ResizeObserver(([entry]) => {
30
+ if (entry) {
31
+ // The layoutchange event is the border box of the element
32
+ const { width, height, left, right, top, bottom } = entry.contentRect;
33
+ const id = this.#dom.id;
34
+ this.#dom.dispatchEvent(new CustomEvent('layoutchange', {
35
+ detail: {
36
+ width,
37
+ height,
38
+ left,
39
+ right,
40
+ top,
41
+ bottom,
42
+ id,
43
+ },
44
+ ...commonComponentEventSetting,
45
+ }));
46
+ }
47
+ });
48
+ if (!this.#observing) {
49
+ this.#resizeObserver.observe(this.#dom);
50
+ this.#observing = true;
51
+ }
52
+ }
53
+ }
54
+ else {
55
+ this.#resizeObserver?.disconnect();
56
+ }
57
+ });
58
+ };
59
+ })();
60
+ export { CommonEventsAndMethods };
61
+ //# sourceMappingURL=CommonEventsAndMethods.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-elements",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -263,6 +263,7 @@ x-text[text-maxline][tail-color-convert="false"]::part(inner-box) {
263
263
 
264
264
  raw-text {
265
265
  display: none;
266
+ white-space-collapse: preserve-breaks;
266
267
  }
267
268
  x-text > raw-text,
268
269
  inline-text > raw-text,