@lynx-js/web-elements 0.2.4 → 0.4.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 (59) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/ScrollView/FadeEdgeLengthAttribute.d.ts +2 -2
  3. package/dist/ScrollView/ScrollAttributes.d.ts +2 -2
  4. package/dist/ScrollView/ScrollIntoView.d.ts +2 -2
  5. package/dist/ScrollView/ScrollIntoView.js +6 -0
  6. package/dist/ScrollView/ScrollView.js +1 -1
  7. package/dist/ScrollView/ScrollViewEvents.d.ts +1 -1
  8. package/dist/ScrollView/ScrollViewEvents.js +64 -43
  9. package/dist/XAudioTT/XAudioAttribute.d.ts +1 -1
  10. package/dist/XAudioTT/XAudioEvents.d.ts +1 -1
  11. package/dist/XCanvas/CanvasAttributes.d.ts +2 -2
  12. package/dist/XFoldViewNg/XFoldviewHeaderNgFeatures.d.ts +1 -1
  13. package/dist/XFoldViewNg/XFoldviewNgEvents.d.ts +2 -2
  14. package/dist/XFoldViewNg/XFoldviewSlotNgTouchEventsHandler.d.ts +1 -1
  15. package/dist/XImage/DropShadow.d.ts +1 -1
  16. package/dist/XImage/ImageEvents.d.ts +2 -2
  17. package/dist/XImage/ImageEvents.js +15 -14
  18. package/dist/XInput/InputBaseAttributes.d.ts +1 -1
  19. package/dist/XInput/Placeholder.d.ts +1 -1
  20. package/dist/XInput/XInputAttribute.d.ts +1 -1
  21. package/dist/XInput/XInputEvents.d.ts +1 -1
  22. package/dist/XInput/XInputEvents.js +5 -4
  23. package/dist/XList/XList.js +1 -1
  24. package/dist/XList/XListAttributes.d.ts +1 -1
  25. package/dist/XList/XListEvents.d.ts +1 -1
  26. package/dist/XList/XListEvents.js +209 -188
  27. package/dist/XOverlayNg/XOverlayAttributes.d.ts +2 -2
  28. package/dist/XOverlayNg/XOverlayAttributes.js +7 -2
  29. package/dist/XRefreshView/XRefreshSubElementIntersectionObserver.d.ts +3 -3
  30. package/dist/XRefreshView/XRefreshViewEventsEmitter.d.ts +2 -2
  31. package/dist/XRefreshView/XRefreshViewEventsEmitter.js +45 -93
  32. package/dist/XSvg/XSvg.d.ts +1 -1
  33. package/dist/XSvg/XSvg.js +0 -2
  34. package/dist/XSwiper/XSwiperAutoScroll.d.ts +2 -2
  35. package/dist/XSwiper/XSwiperCircular.d.ts +2 -2
  36. package/dist/XSwiper/XSwiperCircular.js +1 -2
  37. package/dist/XSwiper/XSwiperEvents.d.ts +2 -2
  38. package/dist/XSwiper/XSwiperEvents.js +18 -20
  39. package/dist/XSwiper/XSwiperIndicator.d.ts +2 -2
  40. package/dist/XSwiper/XSwiperIndicator.js +0 -1
  41. package/dist/XText/InlineImage.d.ts +1 -1
  42. package/dist/XText/XTextTruncation.d.ts +1 -1
  43. package/dist/XText/XTextTruncation.js +5 -5
  44. package/dist/XTextarea/Placeholder.d.ts +1 -1
  45. package/dist/XTextarea/Placeholder.js +1 -0
  46. package/dist/XTextarea/TextareaBaseAttributes.d.ts +1 -1
  47. package/dist/XTextarea/XTextareaAttributes.d.ts +1 -1
  48. package/dist/XTextarea/XTextareaEvents.d.ts +1 -1
  49. package/dist/XTextarea/XTextareaEvents.js +5 -4
  50. package/dist/XView/BlurRadius.d.ts +2 -2
  51. package/dist/XViewpagerNg/XViewpagerNgEvents.d.ts +2 -2
  52. package/dist/XViewpagerNg/XViewpagerNgEvents.js +40 -32
  53. package/dist/common/Exposure.d.ts +4 -0
  54. package/dist/common/Exposure.js +14 -5
  55. package/dist/common/bindToIntersectionObserver.d.ts +1 -1
  56. package/package.json +7 -6
  57. package/src/common-css/linear.css +1 -11
  58. package/dist/lazy.d.ts +0 -1
  59. package/dist/lazy.js +0 -106
@@ -9,178 +9,81 @@ import { commonComponentEventSetting } from '../common/commonEventInitConfigurat
9
9
  import { throttle } from '../common/throttle.js';
10
10
  import { bindToIntersectionObserver } from '../common/bindToIntersectionObserver.js';
11
11
  import { useScrollEnd } from '../common/constants.js';
12
+ import { registerEventEnableStatusChangeHandler } from '@lynx-js/web-elements-reactive';
12
13
  let XListEvents = (() => {
13
14
  let _instanceExtraInitializers = [];
14
- let _private_updateUpperIntersectionObserver_decorators;
15
- let _private_updateUpperIntersectionObserver_descriptor;
16
- let _private_updateLowerIntersectionObserver_decorators;
17
- let _private_updateLowerIntersectionObserver_descriptor;
18
- let _private_handleScrollEvents_decorators;
19
- let _private_handleScrollEvents_descriptor;
20
- let _private_updateUpperEdgeIntersectionObserver_decorators;
21
- let _private_updateUpperEdgeIntersectionObserver_initializers = [];
22
- let _private_updateUpperEdgeIntersectionObserver_extraInitializers = [];
23
- let _private_updateLowerEdgeIntersectionObserver_decorators;
24
- let _private_updateLowerEdgeIntersectionObserver_initializers = [];
25
- let _private_updateLowerEdgeIntersectionObserver_extraInitializers = [];
15
+ let _private_updateEventSwitches_decorators;
16
+ let _private_updateEventSwitches_initializers = [];
17
+ let _private_updateEventSwitches_extraInitializers = [];
18
+ let _private_handleUpperThresholdItemCountChange_decorators;
19
+ let _private_handleUpperThresholdItemCountChange_descriptor;
20
+ let _private_updateScrollToLowerEventSwitches_decorators;
21
+ let _private_updateScrollToLowerEventSwitches_initializers = [];
22
+ let _private_updateScrollToLowerEventSwitches_extraInitializers = [];
23
+ let _private_handleLowerThresholdItemCountChange_decorators;
24
+ let _private_handleLowerThresholdItemCountChange_descriptor;
25
+ let _private_handleScrollEventsSwitches_decorators;
26
+ let _private_handleScrollEventsSwitches_initializers = [];
27
+ let _private_handleScrollEventsSwitches_extraInitializers = [];
28
+ let _private_handleScrollToUpperEdgeEventEnable_decorators;
29
+ let _private_handleScrollToUpperEdgeEventEnable_initializers = [];
30
+ let _private_handleScrollToUpperEdgeEventEnable_extraInitializers = [];
31
+ let _private_handleScrollToLowerEdgeEventEnable_decorators;
32
+ let _private_handleScrollToLowerEdgeEventEnable_initializers = [];
33
+ let _private_handleScrollToLowerEdgeEventEnable_extraInitializers = [];
26
34
  return class XListEvents {
27
35
  static {
28
36
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
29
- _private_updateUpperIntersectionObserver_decorators = [registerAttributeHandler('upper-threshold-item-count', true), registerAttributeHandler('x-enable-scrolltoupper-event', true)];
30
- _private_updateLowerIntersectionObserver_decorators = [registerAttributeHandler('lower-threshold-item-count', true), registerAttributeHandler('x-enable-scrolltolower-event', true)];
31
- _private_handleScrollEvents_decorators = [registerAttributeHandler('x-enable-scroll-event', true), registerAttributeHandler('scroll-event-throttle', true), registerAttributeHandler('x-enable-scrollend-event', true), registerAttributeHandler('x-enable-snap-event', true)];
32
- _private_updateUpperEdgeIntersectionObserver_decorators = [registerAttributeHandler('x-enable-scrolltoupperedge-event', true)];
33
- _private_updateLowerEdgeIntersectionObserver_decorators = [registerAttributeHandler('x-enable-scrolltoloweredge-event', true)];
34
- __esDecorate(this, _private_updateUpperIntersectionObserver_descriptor = { value: __setFunctionName(function (newValue, oldValue, name) {
35
- const enableScrollToUpper = this.#dom.getAttribute('x-enable-scrolltoupper-event');
36
- if (enableScrollToUpper === null) {
37
- // if x-enable-scrolltoupper-event null, no need to handle upper-threshold-item-count
38
- if (this.#upperObserver) {
39
- this.#upperObserver.disconnect();
40
- this.#upperObserver = undefined;
41
- }
42
- if (this.#childrenObserver) {
43
- this.#childrenObserver.disconnect();
44
- this.#childrenObserver = undefined;
45
- }
46
- return;
47
- }
48
- if (!this.#upperObserver) {
49
- this.#upperObserver = new IntersectionObserver(this.#handleUpperObserver, {
50
- root: this.#getListContainer(),
51
- });
52
- }
53
- if (!this.#childrenObserver) {
54
- this.#childrenObserver = new MutationObserver(this.#handleChildrenObserver);
55
- }
56
- if (name === 'x-enable-scrolltoupper-event') {
57
- const upperThresholdItemCount = this.#dom.getAttribute('upper-threshold-item-count');
58
- const itemCount = upperThresholdItemCount !== null
59
- ? parseFloat(upperThresholdItemCount)
60
- : 0;
61
- const observerDom = itemCount === 0
62
- ? this.#getUpperThresholdObserverDom()
63
- : this.#dom.children[itemCount - 1];
64
- observerDom && this.#upperObserver.observe(observerDom);
65
- this.#childrenObserver.observe(this.#dom, {
66
- childList: true,
67
- });
68
- }
69
- if (name === 'upper-threshold-item-count') {
70
- const oldItemCount = oldValue !== null
71
- ? parseFloat(oldValue)
72
- : 0;
73
- const oldObserverDom = oldItemCount === 0
74
- ? this.#getUpperThresholdObserverDom()
75
- : this.#dom.children[oldItemCount - 1];
76
- oldObserverDom && this.#upperObserver.unobserve(oldObserverDom);
77
- const itemCount = newValue !== null
78
- ? parseFloat(newValue)
79
- : 0;
80
- const observerDom = itemCount === 0
81
- ? this.#getUpperThresholdObserverDom()
82
- : this.#dom.children[itemCount - 1];
83
- observerDom && this.#upperObserver.observe(observerDom);
84
- }
85
- }, "#updateUpperIntersectionObserver") }, _private_updateUpperIntersectionObserver_decorators, { kind: "method", name: "#updateUpperIntersectionObserver", static: false, private: true, access: { has: obj => #updateUpperIntersectionObserver in obj, get: obj => obj.#updateUpperIntersectionObserver }, metadata: _metadata }, null, _instanceExtraInitializers);
86
- __esDecorate(this, _private_updateLowerIntersectionObserver_descriptor = { value: __setFunctionName(function (newValue, oldValue, name) {
87
- const enableScrollToLower = this.#dom.getAttribute('x-enable-scrolltolower-event');
88
- if (enableScrollToLower === null) {
89
- if (this.#lowerObserver) {
90
- this.#lowerObserver.disconnect();
91
- this.#lowerObserver = undefined;
92
- }
93
- if (this.#childrenObserver) {
94
- this.#childrenObserver.disconnect();
95
- this.#childrenObserver = undefined;
96
- }
97
- return;
98
- }
99
- if (!this.#lowerObserver) {
100
- this.#lowerObserver = new IntersectionObserver(this.#handleLowerObserver, {
101
- root: this.#getListContainer(),
102
- });
103
- }
104
- if (!this.#childrenObserver) {
105
- this.#childrenObserver = new MutationObserver(this.#handleChildrenObserver);
106
- }
107
- if (name === 'x-enable-scrolltolower-event') {
108
- const lowerThresholdItemCount = this.#dom.getAttribute('lower-threshold-item-count');
109
- const itemCount = lowerThresholdItemCount !== null
110
- ? parseFloat(lowerThresholdItemCount)
111
- : 0;
112
- const observerDom = itemCount === 0
113
- ? this.#getLowerThresholdObserverDom()
114
- : this.#dom.children[this.#dom.children.length
115
- - itemCount];
116
- observerDom && this.#lowerObserver.observe(observerDom);
117
- this.#childrenObserver.observe(this.#dom, {
118
- childList: true,
119
- });
120
- }
121
- if (name === 'lower-threshold-item-count') {
122
- const oldItemCount = oldValue !== null
123
- ? parseFloat(oldValue)
124
- : 0;
125
- const oldObserverDom = oldItemCount === 0
126
- ? this.#getLowerThresholdObserverDom()
127
- : this.#dom.children[this.#dom.children.length - oldItemCount];
128
- oldObserverDom && this.#lowerObserver.unobserve(oldObserverDom);
129
- const itemCount = newValue !== null
130
- ? parseFloat(newValue)
131
- : 0;
132
- const observerDom = itemCount === 0
133
- ? this.#getLowerThresholdObserverDom()
134
- : this.#dom.children[this.#dom.children.length
135
- - itemCount];
136
- observerDom && this.#lowerObserver.observe(observerDom);
137
- }
138
- }, "#updateLowerIntersectionObserver") }, _private_updateLowerIntersectionObserver_decorators, { kind: "method", name: "#updateLowerIntersectionObserver", static: false, private: true, access: { has: obj => #updateLowerIntersectionObserver in obj, get: obj => obj.#updateLowerIntersectionObserver }, metadata: _metadata }, null, _instanceExtraInitializers);
139
- __esDecorate(this, _private_handleScrollEvents_descriptor = { value: __setFunctionName(function () {
140
- const scroll = this.#dom.getAttribute('x-enable-scroll-event') !== null;
141
- const scrollEventThrottle = this.#dom.getAttribute('scroll-event-throttle');
142
- const scrollend = this.#dom.getAttribute('x-enable-scrollend-event');
143
- const snap = this.#dom.getAttribute('x-enable-snap-event');
144
- this.#enableScrollEnd = scrollend !== null || snap !== null;
145
- const listContainer = this.#getListContainer();
146
- // cancel the previous listener first
147
- this.#throttledScroll
148
- && listContainer.removeEventListener('scroll', this.#throttledScroll);
149
- if (scroll !== null || this.#enableScrollEnd) {
150
- const wait = scrollEventThrottle !== null
151
- ? parseFloat(scrollEventThrottle)
152
- : 0;
153
- const throttledScroll = throttle(this.#handleScroll, wait, {
154
- leading: true,
155
- trailing: false,
156
- });
157
- this.#throttledScroll = throttledScroll;
158
- listContainer.addEventListener('scroll', this.#throttledScroll);
159
- this.#prevX = 0;
160
- this.#prevY = 0;
161
- }
162
- if (useScrollEnd && this.#enableScrollEnd) {
163
- listContainer.addEventListener('scrollend', this.#handleScrollEnd);
164
- }
165
- else {
166
- listContainer.removeEventListener('scrollend', this.#handleScrollEnd);
167
- }
168
- }, "#handleScrollEvents") }, _private_handleScrollEvents_decorators, { kind: "method", name: "#handleScrollEvents", static: false, private: true, access: { has: obj => #handleScrollEvents in obj, get: obj => obj.#handleScrollEvents }, metadata: _metadata }, null, _instanceExtraInitializers);
169
- __esDecorate(null, null, _private_updateUpperEdgeIntersectionObserver_decorators, { kind: "field", name: "#updateUpperEdgeIntersectionObserver", static: false, private: true, access: { has: obj => #updateUpperEdgeIntersectionObserver in obj, get: obj => obj.#updateUpperEdgeIntersectionObserver, set: (obj, value) => { obj.#updateUpperEdgeIntersectionObserver = value; } }, metadata: _metadata }, _private_updateUpperEdgeIntersectionObserver_initializers, _private_updateUpperEdgeIntersectionObserver_extraInitializers);
170
- __esDecorate(null, null, _private_updateLowerEdgeIntersectionObserver_decorators, { kind: "field", name: "#updateLowerEdgeIntersectionObserver", static: false, private: true, access: { has: obj => #updateLowerEdgeIntersectionObserver in obj, get: obj => obj.#updateLowerEdgeIntersectionObserver, set: (obj, value) => { obj.#updateLowerEdgeIntersectionObserver = value; } }, metadata: _metadata }, _private_updateLowerEdgeIntersectionObserver_initializers, _private_updateLowerEdgeIntersectionObserver_extraInitializers);
37
+ _private_updateEventSwitches_decorators = [registerEventEnableStatusChangeHandler('scrolltoupper')];
38
+ _private_handleUpperThresholdItemCountChange_decorators = [registerAttributeHandler('upper-threshold-item-count', true)];
39
+ _private_updateScrollToLowerEventSwitches_decorators = [registerEventEnableStatusChangeHandler('scrolltolower')];
40
+ _private_handleLowerThresholdItemCountChange_decorators = [registerAttributeHandler('lower-threshold-item-count', true)];
41
+ _private_handleScrollEventsSwitches_decorators = [registerEventEnableStatusChangeHandler('lynxscroll'), registerEventEnableStatusChangeHandler('lynxscrollend'), registerEventEnableStatusChangeHandler('snap')];
42
+ _private_handleScrollToUpperEdgeEventEnable_decorators = [registerEventEnableStatusChangeHandler('scrolltoupperedge')];
43
+ _private_handleScrollToLowerEdgeEventEnable_decorators = [registerEventEnableStatusChangeHandler('scrolltoloweredge')];
44
+ __esDecorate(this, _private_handleUpperThresholdItemCountChange_descriptor = { value: __setFunctionName(function (newValue, oldValue) {
45
+ const oldItemCount = oldValue !== null
46
+ ? parseFloat(oldValue)
47
+ : 0;
48
+ const oldObserverDom = oldItemCount === 0
49
+ ? this.#getUpperThresholdObserverDom()
50
+ : this.#dom.children[oldItemCount - 1];
51
+ oldObserverDom && this.#upperObserver?.unobserve(oldObserverDom);
52
+ const itemCount = newValue !== null
53
+ ? parseFloat(newValue)
54
+ : 0;
55
+ const observerDom = itemCount === 0
56
+ ? this.#getUpperThresholdObserverDom()
57
+ : this.#dom.children[itemCount - 1];
58
+ observerDom && this.#upperObserver?.observe(observerDom);
59
+ }, "#handleUpperThresholdItemCountChange") }, _private_handleUpperThresholdItemCountChange_decorators, { kind: "method", name: "#handleUpperThresholdItemCountChange", static: false, private: true, access: { has: obj => #handleUpperThresholdItemCountChange in obj, get: obj => obj.#handleUpperThresholdItemCountChange }, metadata: _metadata }, null, _instanceExtraInitializers);
60
+ __esDecorate(this, _private_handleLowerThresholdItemCountChange_descriptor = { value: __setFunctionName(function (newValue, oldValue) {
61
+ const oldItemCount = oldValue !== null
62
+ ? parseFloat(oldValue)
63
+ : 0;
64
+ const oldObserverDom = oldItemCount === 0
65
+ ? this.#getLowerThresholdObserverDom()
66
+ : this.#dom.children[this.#dom.children.length - oldItemCount];
67
+ oldObserverDom && this.#lowerObserver?.unobserve(oldObserverDom);
68
+ const itemCount = newValue !== null
69
+ ? parseFloat(newValue)
70
+ : 0;
71
+ const observerDom = itemCount === 0
72
+ ? this.#getLowerThresholdObserverDom()
73
+ : this.#dom.children[this.#dom.children.length
74
+ - itemCount];
75
+ observerDom && this.#lowerObserver?.observe(observerDom);
76
+ }, "#handleLowerThresholdItemCountChange") }, _private_handleLowerThresholdItemCountChange_decorators, { kind: "method", name: "#handleLowerThresholdItemCountChange", static: false, private: true, access: { has: obj => #handleLowerThresholdItemCountChange in obj, get: obj => obj.#handleLowerThresholdItemCountChange }, metadata: _metadata }, null, _instanceExtraInitializers);
77
+ __esDecorate(null, null, _private_updateEventSwitches_decorators, { kind: "field", name: "#updateEventSwitches", static: false, private: true, access: { has: obj => #updateEventSwitches in obj, get: obj => obj.#updateEventSwitches, set: (obj, value) => { obj.#updateEventSwitches = value; } }, metadata: _metadata }, _private_updateEventSwitches_initializers, _private_updateEventSwitches_extraInitializers);
78
+ __esDecorate(null, null, _private_updateScrollToLowerEventSwitches_decorators, { kind: "field", name: "#updateScrollToLowerEventSwitches", static: false, private: true, access: { has: obj => #updateScrollToLowerEventSwitches in obj, get: obj => obj.#updateScrollToLowerEventSwitches, set: (obj, value) => { obj.#updateScrollToLowerEventSwitches = value; } }, metadata: _metadata }, _private_updateScrollToLowerEventSwitches_initializers, _private_updateScrollToLowerEventSwitches_extraInitializers);
79
+ __esDecorate(null, null, _private_handleScrollEventsSwitches_decorators, { kind: "field", name: "#handleScrollEventsSwitches", static: false, private: true, access: { has: obj => #handleScrollEventsSwitches in obj, get: obj => obj.#handleScrollEventsSwitches, set: (obj, value) => { obj.#handleScrollEventsSwitches = value; } }, metadata: _metadata }, _private_handleScrollEventsSwitches_initializers, _private_handleScrollEventsSwitches_extraInitializers);
80
+ __esDecorate(null, null, _private_handleScrollToUpperEdgeEventEnable_decorators, { kind: "field", name: "#handleScrollToUpperEdgeEventEnable", static: false, private: true, access: { has: obj => #handleScrollToUpperEdgeEventEnable in obj, get: obj => obj.#handleScrollToUpperEdgeEventEnable, set: (obj, value) => { obj.#handleScrollToUpperEdgeEventEnable = value; } }, metadata: _metadata }, _private_handleScrollToUpperEdgeEventEnable_initializers, _private_handleScrollToUpperEdgeEventEnable_extraInitializers);
81
+ __esDecorate(null, null, _private_handleScrollToLowerEdgeEventEnable_decorators, { kind: "field", name: "#handleScrollToLowerEdgeEventEnable", static: false, private: true, access: { has: obj => #handleScrollToLowerEdgeEventEnable in obj, get: obj => obj.#handleScrollToLowerEdgeEventEnable, set: (obj, value) => { obj.#handleScrollToLowerEdgeEventEnable = value; } }, metadata: _metadata }, _private_handleScrollToLowerEdgeEventEnable_initializers, _private_handleScrollToLowerEdgeEventEnable_extraInitializers);
171
82
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
172
83
  }
173
84
  static observedAttributes = [
174
- 'x-enable-scroll-event',
175
- 'x-enable-scrollend-event',
176
85
  'upper-threshold-item-count',
177
86
  'lower-threshold-item-count',
178
- 'x-enable-scrolltoupper-event',
179
- 'x-enable-scrolltolower-event',
180
- 'x-enable-scrolltoupperedge-event',
181
- 'x-enable-scrolltoloweredge-event',
182
- 'x-enable-snap-event',
183
- 'scroll-event-throttle',
184
87
  ];
185
88
  #dom = __runInitializers(this, _instanceExtraInitializers);
186
89
  #getListContainer = genDomGetter(() => this.#dom.shadowRoot, '#content');
@@ -213,32 +116,113 @@ let XListEvents = (() => {
213
116
  return detail;
214
117
  }
215
118
  #handleUpperObserver = (entries) => {
216
- const { isIntersecting, target } = entries[0];
217
- const scrolltoupper = this.#dom.getAttribute('x-enable-scrolltoupper-event');
119
+ const { isIntersecting } = entries[0];
218
120
  if (isIntersecting) {
219
- scrolltoupper !== null && this.#dom.dispatchEvent(new CustomEvent('scrolltoupper', {
121
+ this.#dom.dispatchEvent(new CustomEvent('scrolltoupper', {
220
122
  ...commonComponentEventSetting,
221
123
  detail: this.#getScrollDetail(),
222
124
  }));
223
125
  }
224
126
  };
225
- get #updateUpperIntersectionObserver() { return _private_updateUpperIntersectionObserver_descriptor.value; }
226
- #handleLowerObserver = (entries) => {
127
+ #updateEventSwitches = __runInitializers(this, _private_updateEventSwitches_initializers, (enableScrollToUpper) => {
128
+ enableScrollToUpper
129
+ ? this.#dom.setAttribute('x-enable-scrolltoupper-event', '')
130
+ : this.#dom.removeAttribute('x-enable-scrolltoupper-event'); // css needs this;
131
+ this.#eventSwitches.scrolltoupper = enableScrollToUpper;
132
+ if (!enableScrollToUpper) {
133
+ // if x-enable-scrolltoupper-event null, no need to handle upper-threshold-item-count
134
+ if (this.#upperObserver) {
135
+ this.#upperObserver.disconnect();
136
+ this.#upperObserver = undefined;
137
+ }
138
+ if (this.#childrenObserver) {
139
+ this.#childrenObserver.disconnect();
140
+ this.#childrenObserver = undefined;
141
+ }
142
+ }
143
+ else {
144
+ if (!this.#upperObserver) {
145
+ this.#upperObserver = new IntersectionObserver(this.#handleUpperObserver, {
146
+ root: this.#getListContainer(),
147
+ });
148
+ }
149
+ if (!this.#childrenObserver) {
150
+ this.#childrenObserver = new MutationObserver(this.#handleChildrenObserver);
151
+ }
152
+ const upperThresholdItemCount = this.#dom.getAttribute('upper-threshold-item-count');
153
+ const itemCount = upperThresholdItemCount !== null
154
+ ? parseFloat(upperThresholdItemCount)
155
+ : 0;
156
+ const observerDom = itemCount === 0
157
+ ? this.#getUpperThresholdObserverDom()
158
+ : this.#dom.children[itemCount - 1];
159
+ observerDom && this.#upperObserver.observe(observerDom);
160
+ this.#childrenObserver.observe(this.#dom, {
161
+ childList: true,
162
+ });
163
+ }
164
+ });
165
+ get #handleUpperThresholdItemCountChange() { return _private_handleUpperThresholdItemCountChange_descriptor.value; }
166
+ #handleLowerObserver = (__runInitializers(this, _private_updateEventSwitches_extraInitializers), (entries) => {
227
167
  const { isIntersecting } = entries[0];
228
- const scrolltolower = this.#dom.getAttribute('x-enable-scrolltolower-event');
229
168
  if (isIntersecting) {
230
- scrolltolower !== null && this.#dom.dispatchEvent(new CustomEvent('scrolltolower', {
169
+ this.#dom.dispatchEvent(new CustomEvent('scrolltolower', {
231
170
  ...commonComponentEventSetting,
232
171
  detail: this.#getScrollDetail(),
233
172
  }));
234
173
  }
174
+ });
175
+ #eventSwitches = {
176
+ lynxscroll: false,
177
+ lynxscrollend: false,
178
+ snap: false,
179
+ scrolltolower: false,
180
+ scrolltoupper: false,
235
181
  };
236
- get #updateLowerIntersectionObserver() { return _private_updateLowerIntersectionObserver_descriptor.value; }
237
- #handleChildrenObserver = (mutationList) => {
182
+ #updateScrollToLowerEventSwitches = __runInitializers(this, _private_updateScrollToLowerEventSwitches_initializers, (enableScrollToLower) => {
183
+ this.#eventSwitches.scrolltolower = enableScrollToLower;
184
+ enableScrollToLower
185
+ ? this.#dom.setAttribute('x-enable-scrolltolower-event', '')
186
+ : this.#dom.removeAttribute('x-enable-scrolltolower-event'); // css needs this;
187
+ if (!enableScrollToLower) {
188
+ if (this.#lowerObserver) {
189
+ this.#lowerObserver.disconnect();
190
+ this.#lowerObserver = undefined;
191
+ }
192
+ if (this.#childrenObserver) {
193
+ this.#childrenObserver.disconnect();
194
+ this.#childrenObserver = undefined;
195
+ }
196
+ }
197
+ else {
198
+ if (!this.#lowerObserver) {
199
+ this.#lowerObserver = new IntersectionObserver(this.#handleLowerObserver, {
200
+ root: this.#getListContainer(),
201
+ });
202
+ }
203
+ if (!this.#childrenObserver) {
204
+ this.#childrenObserver = new MutationObserver(this.#handleChildrenObserver);
205
+ }
206
+ const lowerThresholdItemCount = this.#dom.getAttribute('lower-threshold-item-count');
207
+ const itemCount = lowerThresholdItemCount !== null
208
+ ? parseFloat(lowerThresholdItemCount)
209
+ : 0;
210
+ const observerDom = itemCount === 0
211
+ ? this.#getLowerThresholdObserverDom()
212
+ : this.#dom.children[this.#dom.children.length
213
+ - itemCount];
214
+ observerDom && this.#lowerObserver.observe(observerDom);
215
+ this.#childrenObserver.observe(this.#dom, {
216
+ childList: true,
217
+ });
218
+ }
219
+ });
220
+ get #handleLowerThresholdItemCountChange() { return _private_handleLowerThresholdItemCountChange_descriptor.value; }
221
+ #handleChildrenObserver = (__runInitializers(this, _private_updateScrollToLowerEventSwitches_extraInitializers), (mutationList) => {
238
222
  const mutation = mutationList?.[0];
239
223
  // reset upper and lower observers
240
224
  if (mutation?.type === 'childList') {
241
- if (this.#dom.getAttribute('x-enable-scrolltolower-event') !== null) {
225
+ if (this.#eventSwitches.scrolltolower) {
242
226
  // The reason why unobserve cannot be used is that the structure of list-item has changed,
243
227
  // and the list-item before the change cannot be obtained.
244
228
  // so disconnect and reconnect is required.
@@ -280,7 +264,7 @@ let XListEvents = (() => {
280
264
  observerDom && this.#upperObserver.observe(observerDom);
281
265
  }
282
266
  }
283
- };
267
+ });
284
268
  #throttledScroll = null;
285
269
  #handleScroll = () => {
286
270
  if (this.#enableScrollEnd && !useScrollEnd) {
@@ -297,8 +281,37 @@ let XListEvents = (() => {
297
281
  },
298
282
  }));
299
283
  };
300
- get #handleScrollEvents() { return _private_handleScrollEvents_descriptor.value; }
301
- #handleObserver = (entries) => {
284
+ #handleScrollEventsSwitches = __runInitializers(this, _private_handleScrollEventsSwitches_initializers, (enabled, name) => {
285
+ this.#eventSwitches[name] =
286
+ enabled;
287
+ const { lynxscroll, lynxscrollend, snap } = this.#eventSwitches;
288
+ const scrollEventThrottle = this.#dom.getAttribute('scroll-event-throttle');
289
+ this.#enableScrollEnd = lynxscrollend !== null || snap !== null;
290
+ const listContainer = this.#getListContainer();
291
+ // cancel the previous listener first
292
+ this.#throttledScroll
293
+ && listContainer.removeEventListener('scroll', this.#throttledScroll);
294
+ if (scroll !== null || this.#enableScrollEnd) {
295
+ const wait = scrollEventThrottle !== null
296
+ ? parseFloat(scrollEventThrottle)
297
+ : 0;
298
+ const throttledScroll = throttle(this.#handleScroll, wait, {
299
+ leading: true,
300
+ trailing: false,
301
+ });
302
+ this.#throttledScroll = throttledScroll;
303
+ listContainer.addEventListener('scroll', this.#throttledScroll);
304
+ this.#prevX = 0;
305
+ this.#prevY = 0;
306
+ }
307
+ if (useScrollEnd && this.#enableScrollEnd) {
308
+ listContainer.addEventListener('scrollend', this.#handleScrollEnd);
309
+ }
310
+ else {
311
+ listContainer.removeEventListener('scrollend', this.#handleScrollEnd);
312
+ }
313
+ });
314
+ #handleObserver = (__runInitializers(this, _private_handleScrollEventsSwitches_extraInitializers), (entries) => {
302
315
  const { isIntersecting, target } = entries[0];
303
316
  const id = target.id;
304
317
  if (isIntersecting) {
@@ -315,19 +328,27 @@ let XListEvents = (() => {
315
328
  }));
316
329
  }
317
330
  }
318
- };
319
- #updateUpperEdgeIntersectionObserver = __runInitializers(this, _private_updateUpperEdgeIntersectionObserver_initializers, bindToIntersectionObserver(this.#getListContainer, this.#getUpperThresholdObserverDom, this.#handleObserver));
320
- #updateLowerEdgeIntersectionObserver = (__runInitializers(this, _private_updateUpperEdgeIntersectionObserver_extraInitializers), __runInitializers(this, _private_updateLowerEdgeIntersectionObserver_initializers, bindToIntersectionObserver(this.#getListContainer, this.#getLowerThresholdObserverDom, this.#handleObserver)));
321
- #handleScrollEnd = (__runInitializers(this, _private_updateLowerEdgeIntersectionObserver_extraInitializers), () => {
322
- const scrollend = this.#dom.getAttribute('x-enable-scrollend-event');
331
+ });
332
+ #handleScrollToUpperEdgeEventEnable = __runInitializers(this, _private_handleScrollToUpperEdgeEventEnable_initializers, (enabled) => {
333
+ enabled
334
+ ? this.#dom.setAttribute('x-enable-scrolltoupperedge-event', '')
335
+ : this.#dom.removeAttribute('x-enable-scrolltoupperedge-event'); // css needs this;
336
+ this.#updateUpperEdgeIntersectionObserver(enabled);
337
+ });
338
+ #updateUpperEdgeIntersectionObserver = (__runInitializers(this, _private_handleScrollToUpperEdgeEventEnable_extraInitializers), bindToIntersectionObserver(this.#getListContainer, this.#getUpperThresholdObserverDom, this.#handleObserver));
339
+ #handleScrollToLowerEdgeEventEnable = __runInitializers(this, _private_handleScrollToLowerEdgeEventEnable_initializers, (enabled) => {
340
+ enabled
341
+ ? this.#dom.setAttribute('x-enable-scrolltoloweredge-event', '')
342
+ : this.#dom.removeAttribute('x-enable-scrolltoloweredge-event'); // css needs this;
343
+ this.#updateLowerEdgeIntersectionObserver(enabled);
344
+ });
345
+ #updateLowerEdgeIntersectionObserver = (__runInitializers(this, _private_handleScrollToLowerEdgeEventEnable_extraInitializers), bindToIntersectionObserver(this.#getListContainer, this.#getLowerThresholdObserverDom, this.#handleObserver));
346
+ #handleScrollEnd = () => {
323
347
  const itemSnap = this.#dom.getAttribute('item-snap');
324
- const snap = this.#dom.getAttribute('x-enable-snap-event');
325
- if (scrollend !== null) {
326
- this.#dom.dispatchEvent(new CustomEvent('lynxscrollend', {
327
- ...commonComponentEventSetting,
328
- }));
329
- }
330
- if (itemSnap !== null && snap !== null) {
348
+ this.#dom.dispatchEvent(new CustomEvent('lynxscrollend', {
349
+ ...commonComponentEventSetting,
350
+ }));
351
+ if (itemSnap !== null) {
331
352
  const children = Array.from(this.#dom.children).filter(node => {
332
353
  return node.tagName === 'LIST-ITEM';
333
354
  });
@@ -346,7 +367,7 @@ let XListEvents = (() => {
346
367
  },
347
368
  }));
348
369
  }
349
- });
370
+ };
350
371
  constructor(dom) {
351
372
  this.#dom = dom;
352
373
  }
@@ -1,5 +1,5 @@
1
- import { XOverlayNg } from './XOverlayNg.js';
2
- import { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
1
+ import type { XOverlayNg } from './XOverlayNg.js';
2
+ import { type AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
3
3
  export declare class XOverlayAttributes implements InstanceType<AttributeReactiveClass<typeof XOverlayNg>> {
4
4
  #private;
5
5
  static observedAttributes: string[];
@@ -60,8 +60,13 @@ let XOverlayAttributes = (() => {
60
60
  if (e.target === this.#dom || e.target === diaglogDom) {
61
61
  diaglogDom.close();
62
62
  const { clientX, clientY } = e;
63
- const targetElemnt = document.elementFromPoint(clientX, clientY);
64
- targetElemnt?.dispatchEvent(new MouseEvent('click', e));
63
+ let targetElement = document.elementFromPoint(clientX, clientY);
64
+ if (targetElement?.tagName === 'LYNX-VIEW' && targetElement.shadowRoot) {
65
+ targetElement =
66
+ targetElement.shadowRoot.elementFromPoint(clientX, clientY)
67
+ ?? targetElement;
68
+ }
69
+ targetElement?.dispatchEvent(new MouseEvent('click', e));
65
70
  requestAnimationFrame(() => {
66
71
  if (this.#visible && diaglogDom.isConnected) {
67
72
  diaglogDom.showModal();
@@ -1,6 +1,6 @@
1
- import { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
2
- import { XRefreshFooter } from './XRefreshFooter.js';
3
- import { XRefreshHeader } from './XRefreshHeader.js';
1
+ import type { AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
2
+ import type { XRefreshFooter } from './XRefreshFooter.js';
3
+ import type { XRefreshHeader } from './XRefreshHeader.js';
4
4
  export declare class XRefreshIntersectionObserverEvent extends Event {
5
5
  startShowing: boolean;
6
6
  fullyShowing: boolean;
@@ -1,8 +1,8 @@
1
1
  import { type AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
2
- import { XRefreshView } from './XRefreshView.js';
2
+ import type { XRefreshView } from './XRefreshView.js';
3
3
  export declare class XRefreshViewEventsEmitter implements InstanceType<AttributeReactiveClass<typeof XRefreshView>> {
4
4
  #private;
5
- static observedAttributes: string[];
5
+ static observedAttributes: never[];
6
6
  constructor(dom: XRefreshView);
7
7
  dispose(): void;
8
8
  }