@lynx-js/web-elements 0.5.3 → 0.6.0

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/ScrollView/ScrollView.js +3 -3
  3. package/dist/XAudioTT/XAudioTT.js +2 -2
  4. package/dist/XCanvas/XCanvas.js +2 -2
  5. package/dist/XFoldViewNg/XFoldviewHeaderNg.d.ts +2 -0
  6. package/dist/XFoldViewNg/XFoldviewHeaderNg.js +9 -4
  7. package/dist/XFoldViewNg/XFoldviewNg.d.ts +13 -2
  8. package/dist/XFoldViewNg/XFoldviewNg.js +43 -5
  9. package/dist/XFoldViewNg/XFoldviewNgEvents.d.ts +1 -1
  10. package/dist/XFoldViewNg/XFoldviewNgEvents.js +17 -5
  11. package/dist/XFoldViewNg/XFoldviewSlotDragNg.js +2 -2
  12. package/dist/XFoldViewNg/XFoldviewSlotNg.d.ts +1 -0
  13. package/dist/XFoldViewNg/XFoldviewSlotNg.js +8 -2
  14. package/dist/XFoldViewNg/XFoldviewSlotNgTouchEventsHandler.js +51 -37
  15. package/dist/XFoldViewNg/XFoldviewToolbarNg.d.ts +2 -0
  16. package/dist/XFoldViewNg/XFoldviewToolbarNg.js +9 -2
  17. package/dist/XImage/FilterImage.js +2 -2
  18. package/dist/XImage/XImage.js +2 -2
  19. package/dist/XInput/InputBaseAttributes.js +3 -2
  20. package/dist/XInput/XInput.js +2 -2
  21. package/dist/XInput/XInputEvents.js +1 -1
  22. package/dist/XList/ListItem.js +2 -2
  23. package/dist/XList/XList.js +4 -3
  24. package/dist/XList/XListAttributes.js +1 -0
  25. package/dist/XList/XListWaterfall.d.ts +8 -0
  26. package/dist/XList/XListWaterfall.js +144 -0
  27. package/dist/XOverlayNg/XOverlayNg.d.ts +2 -0
  28. package/dist/XOverlayNg/XOverlayNg.js +5 -2
  29. package/dist/XRefreshView/XRefreshFooter.js +2 -2
  30. package/dist/XRefreshView/XRefreshHeader.js +2 -2
  31. package/dist/XRefreshView/XRefreshView.js +2 -2
  32. package/dist/XSvg/XSvg.js +2 -2
  33. package/dist/XSwiper/SwiperItem.js +2 -2
  34. package/dist/XSwiper/XSwiper.js +2 -2
  35. package/dist/XText/XText.d.ts +2 -0
  36. package/dist/XText/XText.js +3 -3
  37. package/dist/XTextarea/XTextarea.js +2 -2
  38. package/dist/XView/XBlurView.js +2 -2
  39. package/dist/XView/XView.d.ts +2 -0
  40. package/dist/XView/XView.js +5 -3
  41. package/dist/XViewpagerNg/XViewpagerItemNg.js +2 -2
  42. package/dist/XViewpagerNg/XViewpagerNg.js +2 -2
  43. package/dist/common/CommonEventsAndMethods.d.ts +31 -2
  44. package/dist/common/CommonEventsAndMethods.js +198 -7
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js +1 -1
  47. package/package.json +1 -1
  48. package/src/ScrollView/scroll-view.css +0 -1
  49. package/src/XFoldViewNg/x-foldview-ng.css +0 -3
  50. package/src/XList/x-list.css +67 -5
  51. package/src/XText/x-text.css +14 -45
  52. package/dist/XFoldViewNg/XFoldviewHeaderNgFeatures.d.ts +0 -9
  53. package/dist/XFoldViewNg/XFoldviewHeaderNgFeatures.js +0 -32
  54. package/dist/common/Exposure.d.ts +0 -32
  55. package/dist/common/Exposure.js +0 -202
package/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # @lynx-js/web-elements
2
2
 
3
+ ## 0.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - fix: When list-type is not specified, it is treated as single formatting. ([#535](https://github.com/lynx-family/lynx-stack/pull/535))
8
+
9
+ - feat: improve compatibility for chrome 108 & support linear-gradient for nested x-text ([#590](https://github.com/lynx-family/lynx-stack/pull/590))
10
+
11
+ **This is a breaking change**
12
+
13
+ - Please upgrade your `@lynx-js/web-elements` to >=0.6.0
14
+ - Please upgrade your `@lynx-js/web-core` to >=0.12.0
15
+ - The compiled lynx template json won't be impacted.
16
+
17
+ On chrome 108, the `-webkit-background-clip:text` cannot be computed by a `var(--css-var-value-text)`
18
+
19
+ Therefore we move the logic into style transformation logic.
20
+
21
+ Now the following status is supported
22
+
23
+ ```
24
+ <text style="color:linear-gradient()">
25
+ <text>
26
+ <text>
27
+ </text>
28
+ ```
29
+
30
+ ### Patch Changes
31
+
32
+ - feat: fully support MTS ([#569](https://github.com/lynx-family/lynx-stack/pull/569))
33
+
34
+ Now use support the following usage
35
+
36
+ - mainthread event
37
+ - mainthread ref
38
+ - runOnMainThread/runOnBackground
39
+ - ref.current.xx
40
+
41
+ - feat: support `layoutchange` event for x-overlay-ng ([#519](https://github.com/lynx-family/lynx-stack/pull/519))
42
+
43
+ - fix: position:fixed not work in scroll-view ([#580](https://github.com/lynx-family/lynx-stack/pull/580))
44
+
45
+ - fix: x-list may cause error: 'Resizeobserver loop completed with undelivered notifications'. ([#541](https://github.com/lynx-family/lynx-stack/pull/541))
46
+
47
+ - fix: refactor foldview slot offset logic ([#575](https://github.com/lynx-family/lynx-stack/pull/575))
48
+
49
+ - fix: improve x-foldview-ng ([#513](https://github.com/lynx-family/lynx-stack/pull/513))
50
+
51
+ - support fling for touch event driven scrolling
52
+ - allow the height of `x-foldview-slot-ng` + `x-foldview-toolbar-ng` > `x-foldview-ng`
53
+ - do not prevent horizontal gesture. After this commit we only allow one direction gesture for one touch (start -> end)
54
+
55
+ - feat: add list with waterfall ([#331](https://github.com/lynx-family/lynx-stack/pull/331))
56
+
57
+ ## 0.5.4
58
+
59
+ ### Patch Changes
60
+
61
+ - chore: bump the output target to es2024 ([#518](https://github.com/lynx-family/lynx-stack/pull/518))
62
+
63
+ - fix: the `\n` character should create a new line ([#522](https://github.com/lynx-family/lynx-stack/pull/522))
64
+
65
+ add `white-space-collapse: preserve-breaks` to raw-text
66
+
67
+ - fix: the `input` event of x-input with number type should have raw value ([#517](https://github.com/lynx-family/lynx-stack/pull/517))
68
+
69
+ For `type:=number` x-input with typed value "2."
70
+
71
+ Before this commit: the value is "2"
72
+
73
+ After this commit the value is "2."
74
+
3
75
  ## 0.5.3
4
76
 
5
77
  ### Patch Changes
@@ -4,16 +4,16 @@ import { __esDecorate, __runInitializers } from "tslib";
4
4
  // Licensed under the Apache License Version 2.0 that can be found in the
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { LynxExposure } from '../common/Exposure.js';
7
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
8
8
  import { FadeEdgeLengthAttribute } from './FadeEdgeLengthAttribute.js';
9
9
  import { ScrollAttributes } from './ScrollAttributes.js';
10
10
  import { ScrollViewEvents } from './ScrollViewEvents.js';
11
11
  import { ScrollIntoView } from './ScrollIntoView.js';
12
- import { Component, genDomGetter, html } from '@lynx-js/web-elements-reactive';
12
+ import { Component, html } from '@lynx-js/web-elements-reactive';
13
13
  import { scrollContainerDom } from '../common/constants.js';
14
14
  let ScrollView = (() => {
15
15
  let _classDecorators = [Component('scroll-view', [
16
- LynxExposure,
16
+ CommonEventsAndMethods,
17
17
  ScrollAttributes,
18
18
  FadeEdgeLengthAttribute,
19
19
  ScrollViewEvents,
@@ -7,11 +7,11 @@ import { __esDecorate, __runInitializers } from "tslib";
7
7
  import { Component, html, genDomGetter, bindToAttribute, } from '@lynx-js/web-elements-reactive';
8
8
  import { XAudioAttribute } from './XAudioAttribute.js';
9
9
  import { XAudioEvents } from './XAudioEvents.js';
10
- import { LynxExposure } from '../common/Exposure.js';
10
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
11
11
  import { commonComponentEventSetting } from '../common/commonEventInitConfiguration.js';
12
12
  import { XAudioErrorCode, audioPlaybackStateMap, getAudioState, xAudioBlob, xAudioSrc, } from './utils.js';
13
13
  let XAudioTT = (() => {
14
- let _classDecorators = [Component('x-audio-tt', [LynxExposure, XAudioAttribute, XAudioEvents], html `<audio id="audio"></audio>`)];
14
+ let _classDecorators = [Component('x-audio-tt', [CommonEventsAndMethods, XAudioAttribute, XAudioEvents], html `<audio id="audio"></audio>`)];
15
15
  let _classDescriptor;
16
16
  let _classExtraInitializers = [];
17
17
  let _classThis;
@@ -5,13 +5,13 @@ import { __esDecorate, __runInitializers } from "tslib";
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Component, html } from '@lynx-js/web-elements-reactive';
8
- import { LynxExposure } from '../common/Exposure.js';
8
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
9
9
  import { CanvasAttributes } from './CanvasAttributes.js';
10
10
  /**
11
11
  * @deprecated this proposals cannot be implemented on other platforms
12
12
  */
13
13
  let XCanvas = (() => {
14
- let _classDecorators = [Component('x-canvas', [LynxExposure, CanvasAttributes], html `<canvas id="canvas" part="canvas"></canvas>`)];
14
+ let _classDecorators = [Component('x-canvas', [CommonEventsAndMethods, CanvasAttributes], html `<canvas id="canvas" part="canvas"></canvas>`)];
15
15
  let _classDescriptor;
16
16
  let _classExtraInitializers = [];
17
17
  let _classThis;
@@ -1,2 +1,4 @@
1
1
  export declare class XFoldviewHeaderNg extends HTMLElement {
2
+ connectedCallback(): void;
3
+ dispose(): void;
2
4
  }
@@ -5,12 +5,11 @@ import { __esDecorate, __runInitializers } from "tslib";
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Component } from '@lynx-js/web-elements-reactive';
8
- import { LynxExposure } from '../common/Exposure.js';
9
- import { XFoldviewHeaderNgFeatures } from './XFoldviewHeaderNgFeatures.js';
8
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
9
+ import { resizeObserver } from './XFoldviewNg.js';
10
10
  let XFoldviewHeaderNg = (() => {
11
11
  let _classDecorators = [Component('x-foldview-header-ng', [
12
- LynxExposure,
13
- XFoldviewHeaderNgFeatures,
12
+ CommonEventsAndMethods,
14
13
  ])];
15
14
  let _classDescriptor;
16
15
  let _classExtraInitializers = [];
@@ -25,6 +24,12 @@ let XFoldviewHeaderNg = (() => {
25
24
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
26
25
  __runInitializers(_classThis, _classExtraInitializers);
27
26
  }
27
+ connectedCallback() {
28
+ this.parentElement?.[resizeObserver]?.observe(this);
29
+ }
30
+ dispose() {
31
+ this.parentElement?.[resizeObserver]?.unobserve(this);
32
+ }
28
33
  };
29
34
  return XFoldviewHeaderNg = _classThis;
30
35
  })();
@@ -1,11 +1,22 @@
1
1
  import { scrollContainerDom } from '../common/constants.js';
2
+ import type { XFoldviewSlotNg } from './XFoldviewSlotNg.js';
3
+ export declare const scrollableLength: unique symbol;
4
+ export declare const isHeaderShowing: unique symbol;
5
+ export declare const resizeObserver: unique symbol;
6
+ export declare const slotKid: unique symbol;
2
7
  export declare class XFoldviewNg extends HTMLElement {
8
+ #private;
3
9
  static readonly notToFilterFalseAttributes: Set<string>;
4
- __scrollableLength: number;
5
- get __headershowing(): boolean;
10
+ [slotKid]?: XFoldviewSlotNg;
11
+ [resizeObserver]?: ResizeObserver;
12
+ get [scrollableLength](): number;
13
+ get [isHeaderShowing](): boolean;
14
+ get scrollTop(): number;
15
+ set scrollTop(value: number);
6
16
  setFoldExpanded(params: {
7
17
  offset: string;
8
18
  smooth: boolean;
9
19
  }): void;
10
20
  get [scrollContainerDom](): this;
21
+ disconnectedCallback(): void;
11
22
  }
@@ -5,12 +5,16 @@ import { __esDecorate, __runInitializers } from "tslib";
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Component } from '@lynx-js/web-elements-reactive';
8
- import { LynxExposure } from '../common/Exposure.js';
8
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
9
9
  import { XFoldviewNgEvents } from './XFoldviewNgEvents.js';
10
10
  import { scrollContainerDom } from '../common/constants.js';
11
+ export const scrollableLength = Symbol('scrollableLength');
12
+ export const isHeaderShowing = Symbol('isHeaderShowing');
13
+ export const resizeObserver = Symbol('resizeObserver');
14
+ export const slotKid = Symbol('slotKid');
11
15
  let XFoldviewNg = (() => {
12
16
  let _classDecorators = [Component('x-foldview-ng', [
13
- LynxExposure,
17
+ CommonEventsAndMethods,
14
18
  XFoldviewNgEvents,
15
19
  ])];
16
20
  let _classDescriptor;
@@ -26,10 +30,40 @@ let XFoldviewNg = (() => {
26
30
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
27
31
  }
28
32
  static notToFilterFalseAttributes = new Set(['scroll-enable']);
29
- __scrollableLength = 0;
30
- get __headershowing() {
33
+ [slotKid];
34
+ [resizeObserver] = new ResizeObserver((resizeEntries) => {
35
+ for (const resize of resizeEntries) {
36
+ if (resize.target.tagName === 'X-FOLDVIEW-HEADER-NG') {
37
+ this.#headerHeight = resize.contentRect.height;
38
+ }
39
+ else if (resize.target.tagName === 'X-FOLDVIEW-TOOLBAR-NG') {
40
+ this.#toolbarHeight = resize.contentRect.height;
41
+ }
42
+ }
43
+ if (this[slotKid]) {
44
+ this[slotKid].style.top = `${this.#headerHeight - this.#toolbarHeight}px`;
45
+ }
46
+ });
47
+ #headerHeight = 0;
48
+ #toolbarHeight = 0;
49
+ get [scrollableLength]() {
50
+ return this.#headerHeight - this.#toolbarHeight;
51
+ }
52
+ get [isHeaderShowing]() {
31
53
  // This behavior cannot be reproduced in the current test, but can be reproduced in Android WebView
32
- return Math.abs(this.scrollTop - this.__scrollableLength) > 1;
54
+ return this[scrollableLength] - this.scrollTop >= 1;
55
+ }
56
+ get scrollTop() {
57
+ return super.scrollTop;
58
+ }
59
+ set scrollTop(value) {
60
+ if (value > this[scrollableLength]) {
61
+ value = this[scrollableLength];
62
+ }
63
+ else if (value < 0) {
64
+ value = 0;
65
+ }
66
+ super.scrollTop = value;
33
67
  }
34
68
  setFoldExpanded(params) {
35
69
  const { offset, smooth = true } = params;
@@ -42,6 +76,10 @@ let XFoldviewNg = (() => {
42
76
  get [scrollContainerDom]() {
43
77
  return this;
44
78
  }
79
+ disconnectedCallback() {
80
+ this[resizeObserver]?.disconnect();
81
+ this[resizeObserver] = undefined;
82
+ }
45
83
  static {
46
84
  __runInitializers(_classThis, _classExtraInitializers);
47
85
  }
@@ -1,5 +1,5 @@
1
1
  import { type AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
2
- import type { XFoldviewNg } from './XFoldviewNg.js';
2
+ import { type XFoldviewNg } from './XFoldviewNg.js';
3
3
  export declare class XFoldviewNgEvents implements InstanceType<AttributeReactiveClass<typeof XFoldviewNg>> {
4
4
  #private;
5
5
  constructor(dom: XFoldviewNg);
@@ -4,22 +4,36 @@ import { __esDecorate, __runInitializers, __setFunctionName } from "tslib";
4
4
  // Licensed under the Apache License Version 2.0 that can be found in the
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { registerAttributeHandler, } from '@lynx-js/web-elements-reactive';
7
+ import { registerAttributeHandler, registerEventEnableStatusChangeHandler, } from '@lynx-js/web-elements-reactive';
8
8
  import { commonComponentEventSetting } from '../common/commonEventInitConfiguration.js';
9
+ import { scrollableLength } from './XFoldviewNg.js';
9
10
  let XFoldviewNgEvents = (() => {
10
11
  let _instanceExtraInitializers = [];
11
12
  let _private_handleGranularity_decorators;
12
13
  let _private_handleGranularity_descriptor;
14
+ let _private_enableOffsetEvent_decorators;
15
+ let _private_enableOffsetEvent_descriptor;
13
16
  return class XFoldviewNgEvents {
14
17
  static {
15
18
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
16
19
  _private_handleGranularity_decorators = [registerAttributeHandler('granularity', true)];
20
+ _private_enableOffsetEvent_decorators = [registerEventEnableStatusChangeHandler('offset')];
17
21
  __esDecorate(this, _private_handleGranularity_descriptor = { value: __setFunctionName(function (newVal) {
18
22
  if (newVal && newVal !== '')
19
23
  this.#granularity = parseFloat(newVal);
20
24
  else
21
25
  this.#granularity = 0.01;
22
26
  }, "#handleGranularity") }, _private_handleGranularity_decorators, { kind: "method", name: "#handleGranularity", static: false, private: true, access: { has: obj => #handleGranularity in obj, get: obj => obj.#handleGranularity }, metadata: _metadata }, null, _instanceExtraInitializers);
27
+ __esDecorate(this, _private_enableOffsetEvent_descriptor = { value: __setFunctionName(function (enable) {
28
+ if (enable) {
29
+ this.#dom.addEventListener('scroll', this.#handleScroll, {
30
+ passive: true,
31
+ });
32
+ }
33
+ else {
34
+ this.#dom.removeEventListener('scroll', this.#handleScroll);
35
+ }
36
+ }, "#enableOffsetEvent") }, _private_enableOffsetEvent_decorators, { kind: "method", name: "#enableOffsetEvent", static: false, private: true, access: { has: obj => #enableOffsetEvent in obj, get: obj => obj.#enableOffsetEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
23
37
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
24
38
  }
25
39
  #dom = __runInitializers(this, _instanceExtraInitializers);
@@ -27,12 +41,10 @@ let XFoldviewNgEvents = (() => {
27
41
  #pervScroll = 0;
28
42
  constructor(dom) {
29
43
  this.#dom = dom;
30
- this.#dom.addEventListener('scroll', this.#handleScroll, {
31
- passive: true,
32
- });
33
44
  }
34
45
  static observedAttributes = ['granularity'];
35
46
  get #handleGranularity() { return _private_handleGranularity_descriptor.value; }
47
+ get #enableOffsetEvent() { return _private_enableOffsetEvent_descriptor.value; }
36
48
  #handleScroll = () => {
37
49
  const curentScrollTop = this.#dom.scrollTop;
38
50
  const scrollLength = Math.abs(this.#pervScroll - curentScrollTop);
@@ -44,7 +56,7 @@ let XFoldviewNgEvents = (() => {
44
56
  ...commonComponentEventSetting,
45
57
  detail: {
46
58
  offset: curentScrollTop,
47
- height: this.#dom.__scrollableLength,
59
+ height: this.#dom[scrollableLength],
48
60
  },
49
61
  }));
50
62
  }
@@ -5,10 +5,10 @@ import { __esDecorate, __runInitializers } from "tslib";
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Component } from '@lynx-js/web-elements-reactive';
8
- import { LynxExposure } from '../common/Exposure.js';
8
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
9
9
  let XFoldviewSlotDragNg = (() => {
10
10
  let _classDecorators = [Component('x-foldivew-slot-drag-ng', [
11
- LynxExposure,
11
+ CommonEventsAndMethods,
12
12
  ])];
13
13
  let _classDescriptor;
14
14
  let _classExtraInitializers = [];
@@ -1,2 +1,3 @@
1
1
  export declare class XFoldviewSlotNg extends HTMLElement {
2
+ connectedCallback(): void;
2
3
  }
@@ -5,11 +5,12 @@ import { __esDecorate, __runInitializers } from "tslib";
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Component } from '@lynx-js/web-elements-reactive';
8
- import { LynxExposure } from '../common/Exposure.js';
8
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
9
9
  import { XFoldviewSlotNgTouchEventsHandler } from './XFoldviewSlotNgTouchEventsHandler.js';
10
+ import { slotKid } from './XFoldviewNg.js';
10
11
  let XFoldviewSlotNg = (() => {
11
12
  let _classDecorators = [Component('x-foldview-slot-ng', [
12
- LynxExposure,
13
+ CommonEventsAndMethods,
13
14
  XFoldviewSlotNgTouchEventsHandler,
14
15
  ])];
15
16
  let _classDescriptor;
@@ -25,6 +26,11 @@ let XFoldviewSlotNg = (() => {
25
26
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
26
27
  __runInitializers(_classThis, _classExtraInitializers);
27
28
  }
29
+ connectedCallback() {
30
+ if (this.matches('x-foldview-ng>x-foldview-slot-ng:first-of-type')) {
31
+ this.parentElement[slotKid] = this;
32
+ }
33
+ }
28
34
  };
29
35
  return XFoldviewSlotNg = _classThis;
30
36
  })();
@@ -1,11 +1,14 @@
1
+ import { isHeaderShowing } from './XFoldviewNg.js';
1
2
  import { isChromium } from '../common/constants.js';
2
3
  export class XFoldviewSlotNgTouchEventsHandler {
3
4
  #parentScrollTop = 0;
4
5
  #childrenElemsntsScrollTop = new WeakMap();
5
- #childrenElemsntsScrollLeft = new WeakMap();
6
6
  #elements;
7
7
  #previousPageY = 0;
8
8
  #previousPageX = 0;
9
+ #scrollingVertically = null;
10
+ #currentScrollingElement;
11
+ #deltaY = 0;
9
12
  #dom;
10
13
  static observedAttributes = [];
11
14
  constructor(dom) {
@@ -13,76 +16,72 @@ export class XFoldviewSlotNgTouchEventsHandler {
13
16
  this.#dom.addEventListener('touchmove', this.#scroller, {
14
17
  passive: false,
15
18
  });
16
- this.#dom.addEventListener('touchstart', this.#initPreviousScreen, {
19
+ this.#dom.addEventListener('touchstart', this.#touchStart, {
17
20
  passive: true,
18
21
  });
19
- this.#dom.addEventListener('touchcancel', this.#initPreviousScreen, {
22
+ this.#dom.addEventListener('touchend', this.#touchEnd, {
20
23
  passive: true,
21
24
  });
22
25
  }
23
- #getTheMostScrollableKid(delta, isVertical) {
26
+ #getTheMostScrollableKid(delta) {
24
27
  const scrollableKid = this.#elements?.find((element) => {
25
- if ((isVertical && element.scrollHeight > element.clientHeight)
26
- || (!isVertical && element.scrollWidth > element.clientWidth)) {
28
+ if (element.scrollHeight > element.clientHeight) {
27
29
  const couldScrollNear = delta < 0
28
- && (isVertical ? element.scrollTop !== 0 : element.scrollLeft !== 0);
30
+ && element.scrollTop !== 0;
29
31
  const couldScrollFar = delta > 0
30
- && Math.abs(isVertical
31
- ? (element.scrollHeight - element.clientHeight
32
- - element.scrollTop)
33
- : (element.scrollWidth - element.clientWidth
34
- - element.scrollLeft)) > 1;
32
+ && Math.abs(element.scrollHeight - element.clientHeight
33
+ - element.scrollTop) > 1;
35
34
  return couldScrollNear || couldScrollFar;
36
35
  }
37
36
  return false;
38
37
  });
39
38
  return scrollableKid;
40
39
  }
41
- #scrollKid(scrollableKid, delta, isVertical) {
42
- let targetKidScrollDistance = (isVertical
43
- ? this.#childrenElemsntsScrollTop
44
- : this.#childrenElemsntsScrollLeft)
45
- .get(scrollableKid) ?? 0;
40
+ #scrollKid(scrollableKid, delta) {
41
+ let targetKidScrollDistance = this.#childrenElemsntsScrollTop.get(scrollableKid) ?? 0;
46
42
  targetKidScrollDistance += delta;
47
43
  this.#childrenElemsntsScrollTop.set(scrollableKid, targetKidScrollDistance);
48
- isVertical
49
- ? (scrollableKid.scrollTop = targetKidScrollDistance)
50
- : (scrollableKid.scrollLeft = targetKidScrollDistance);
44
+ scrollableKid.scrollTop = targetKidScrollDistance;
51
45
  }
52
46
  #scroller = (event) => {
53
47
  const parentElement = this.#getParentElement();
54
48
  const touch = event.touches.item(0);
55
49
  const { pageY, pageX } = touch;
56
50
  const deltaY = this.#previousPageY - pageY;
57
- const deltaX = this.#previousPageX - pageX;
58
- const scrollableKidY = this.#getTheMostScrollableKid(deltaY, true);
59
- const scrollableKidX = this.#getTheMostScrollableKid(deltaX, false);
60
- /**
61
- * on chromium browsers, the y-axis js scrolling won't interrupt the pan-x gestures
62
- * we make sure the x-axis scrolling will block the y-axis scrolling
63
- */
64
- if (deltaY && parentElement && Math.abs(deltaX / 4) < Math.abs(deltaY)) {
65
- if (event.cancelable && !isChromium) {
51
+ if (this.#scrollingVertically === null) {
52
+ const deltaX = this.#previousPageX - pageX;
53
+ this.#scrollingVertically = Math.abs(deltaY) > Math.abs(deltaX);
54
+ }
55
+ if (this.#scrollingVertically === false) {
56
+ return;
57
+ }
58
+ const scrollableKidY = this.#getTheMostScrollableKid(deltaY);
59
+ if (parentElement) {
60
+ if (event.cancelable) {
66
61
  event.preventDefault();
67
- if (scrollableKidX) {
68
- this.#scrollKid(scrollableKidX, deltaX, false);
69
- }
70
62
  }
71
- if ((parentElement.__headershowing && deltaY > 0
63
+ if ((parentElement[isHeaderShowing] && deltaY > 0
72
64
  || (deltaY < 0 && !scrollableKidY))
73
65
  // deltaY > 0: swipe up (folding header)
74
66
  // scroll the foldview if its scrollable
75
- || (!parentElement.__headershowing && !scrollableKidY)
67
+ || (!parentElement[isHeaderShowing] && !scrollableKidY)
76
68
  // all sub doms are scrolled
77
69
  ) {
70
+ parentElement.scrollBy({
71
+ top: deltaY,
72
+ behavior: 'smooth',
73
+ });
78
74
  this.#parentScrollTop += deltaY;
79
75
  parentElement.scrollTop = this.#parentScrollTop;
76
+ this.#currentScrollingElement = parentElement;
80
77
  }
81
78
  else if (scrollableKidY) {
82
- this.#scrollKid(scrollableKidY, deltaY, true);
79
+ this.#currentScrollingElement = scrollableKidY;
80
+ this.#scrollKid(scrollableKidY, deltaY);
83
81
  }
84
82
  }
85
83
  this.#previousPageY = pageY;
84
+ this.#deltaY = deltaY;
86
85
  };
87
86
  #getParentElement() {
88
87
  const parentElement = this.#dom.parentElement;
@@ -90,7 +89,7 @@ export class XFoldviewSlotNgTouchEventsHandler {
90
89
  return parentElement;
91
90
  }
92
91
  }
93
- #initPreviousScreen = (event) => {
92
+ #touchStart = (event) => {
94
93
  const { pageX, pageY } = event.touches.item(0);
95
94
  this.#elements = document.elementsFromPoint(pageX, pageY).filter(e => this.#dom.contains(e));
96
95
  this.#previousPageY = pageY;
@@ -98,7 +97,22 @@ export class XFoldviewSlotNgTouchEventsHandler {
98
97
  this.#parentScrollTop = this.#getParentElement()?.scrollTop ?? 0;
99
98
  for (const element of this.#elements) {
100
99
  this.#childrenElemsntsScrollTop.set(element, element.scrollTop);
101
- this.#childrenElemsntsScrollLeft.set(element, element.scrollLeft);
100
+ }
101
+ this.#scrollingVertically = null;
102
+ this.#currentScrollingElement = undefined;
103
+ };
104
+ #touchEnd = () => {
105
+ this.#scrollingVertically = null;
106
+ if (this.#currentScrollingElement) {
107
+ const parentElement = this.#getParentElement();
108
+ if (this.#currentScrollingElement === parentElement
109
+ && !parentElement[isHeaderShowing]) {
110
+ return;
111
+ }
112
+ this.#currentScrollingElement.scrollBy({
113
+ top: this.#deltaY * 4,
114
+ behavior: 'smooth',
115
+ });
102
116
  }
103
117
  };
104
118
  }
@@ -1,2 +1,4 @@
1
1
  export declare class XFoldviewToolbarNg extends HTMLElement {
2
+ connectedCallback(): void;
3
+ dispose(): void;
2
4
  }
@@ -5,10 +5,11 @@ import { __esDecorate, __runInitializers } from "tslib";
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Component } from '@lynx-js/web-elements-reactive';
8
- import { LynxExposure } from '../common/Exposure.js';
8
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
9
+ import { resizeObserver } from './XFoldviewNg.js';
9
10
  let XFoldviewToolbarNg = (() => {
10
11
  let _classDecorators = [Component('x-foldview-toolbar-ng', [
11
- LynxExposure,
12
+ CommonEventsAndMethods,
12
13
  ])];
13
14
  let _classDescriptor;
14
15
  let _classExtraInitializers = [];
@@ -23,6 +24,12 @@ let XFoldviewToolbarNg = (() => {
23
24
  if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
24
25
  __runInitializers(_classThis, _classExtraInitializers);
25
26
  }
27
+ connectedCallback() {
28
+ this.parentElement?.[resizeObserver]?.observe(this);
29
+ }
30
+ dispose() {
31
+ this.parentElement?.[resizeObserver]?.unobserve(this);
32
+ }
26
33
  };
27
34
  return XFoldviewToolbarNg = _classThis;
28
35
  })();
@@ -5,12 +5,12 @@ import { __esDecorate, __runInitializers } from "tslib";
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Component, html } from '@lynx-js/web-elements-reactive';
8
- import { LynxExposure } from '../common/Exposure.js';
8
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
9
9
  import { DropShadow } from './DropShadow.js';
10
10
  import { ImageSrc } from './ImageSrc.js';
11
11
  import { ImageEvents } from './ImageEvents.js';
12
12
  let FilterImage = (() => {
13
- let _classDecorators = [Component('filter-image', [LynxExposure, ImageSrc, DropShadow, ImageEvents], html ` <img part="img" alt="" id="img" /> `)];
13
+ let _classDecorators = [Component('filter-image', [CommonEventsAndMethods, ImageSrc, DropShadow, ImageEvents], html ` <img part="img" alt="" id="img" /> `)];
14
14
  let _classDescriptor;
15
15
  let _classExtraInitializers = [];
16
16
  let _classThis;
@@ -5,11 +5,11 @@ import { __esDecorate, __runInitializers } from "tslib";
5
5
  // LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { Component, html } from '@lynx-js/web-elements-reactive';
8
- import { LynxExposure } from '../common/Exposure.js';
8
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
9
9
  import { ImageSrc } from './ImageSrc.js';
10
10
  import { ImageEvents } from './ImageEvents.js';
11
11
  let XImage = (() => {
12
- let _classDecorators = [Component('x-image', [LynxExposure, ImageSrc, ImageEvents], html ` <img part="img" alt="" id="img" /> `)];
12
+ let _classDecorators = [Component('x-image', [CommonEventsAndMethods, ImageSrc, ImageEvents], html ` <img part="img" alt="" id="img" /> `)];
13
13
  let _classDescriptor;
14
14
  let _classExtraInitializers = [];
15
15
  let _classThis;
@@ -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';
@@ -9,10 +9,10 @@ import { InputBaseAttributes } from './InputBaseAttributes.js';
9
9
  import { Placeholder } from './Placeholder.js';
10
10
  import { XInputAttribute } from './XInputAttribute.js';
11
11
  import { XInputEvents } from './XInputEvents.js';
12
- import { LynxExposure } from '../common/Exposure.js';
12
+ import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
13
13
  let XInput = (() => {
14
14
  let _classDecorators = [Component('x-input', [
15
- LynxExposure,
15
+ CommonEventsAndMethods,
16
16
  Placeholder,
17
17
  XInputAttribute,
18
18
  InputBaseAttributes,
@@ -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);