@lynx-js/web-elements-canary 0.8.9 → 0.8.10-canary-20251103-fece7d0a
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 +22 -7
- package/dist/XList/ListItem.js +5 -1
- package/dist/XList/ListItemAttributes.d.ts +7 -0
- package/dist/XList/ListItemAttributes.js +32 -0
- package/dist/XList/XList.js +34 -6
- package/dist/XList/XListWaterfall.js +33 -24
- package/dist/all.d.ts +1 -0
- package/dist/all.js +1 -0
- package/package.json +2 -2
- package/src/XList/x-list.css +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @lynx-js/web-elements
|
|
2
2
|
|
|
3
|
+
## 0.8.10-canary-20251103115041-fece7d0a92fa76948488373757a27dff52a90437
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: 1. Added support for the list `estimated-main-axis-size-px` property; the width and height of `list-item` are no longer required. ([#1911](https://github.com/lynx-family/lynx-stack/pull/1911))
|
|
8
|
+
|
|
9
|
+
2. Fixed an issue where the list `lower-threshold-item-count` event would not trigger when using a horizontal layout under a waterfall layout.
|
|
10
|
+
|
|
11
|
+
3. Fixed an issue where calling the list `autoScroll` method in `useEffect` might not scroll.
|
|
12
|
+
|
|
13
|
+
4. Fixed an issue where the `scrolltolower` event might not be triggered in waterfall, because the lower styles was not updated in `registerEventEnableStatusChangeHandler`.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies []:
|
|
16
|
+
- @lynx-js/web-elements-template@0.8.10-canary-20251103115041-fece7d0a92fa76948488373757a27dff52a90437
|
|
17
|
+
|
|
3
18
|
## 0.8.9
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -634,8 +649,8 @@
|
|
|
634
649
|
For compating usage, `@lynx-js/web-elements-compat/LinearContainer` is provided.
|
|
635
650
|
|
|
636
651
|
```javascript
|
|
637
|
-
import
|
|
638
|
-
import
|
|
652
|
+
import "@lynx-js/web-elements-compat/LinearContainer";
|
|
653
|
+
import "@lynx-js/web-elements/all";
|
|
639
654
|
```
|
|
640
655
|
|
|
641
656
|
- f8d1d98: break: rename the `blur` and `focus` event to `lynxblur` and `lynxfocus` for x-input element
|
|
@@ -657,11 +672,11 @@
|
|
|
657
672
|
There is also a simple way to use this feature
|
|
658
673
|
|
|
659
674
|
```javascript
|
|
660
|
-
import { LynxCard } from
|
|
661
|
-
import { loadElement } from
|
|
662
|
-
import
|
|
663
|
-
import
|
|
664
|
-
import
|
|
675
|
+
import { LynxCard } from "@lynx-js/web-core";
|
|
676
|
+
import { loadElement } from "@lynx-js/web-elements/lazy";
|
|
677
|
+
import "@lynx-js/web-elements/index.css";
|
|
678
|
+
import "@lynx-js/web-core/index.css";
|
|
679
|
+
import "./index.css";
|
|
665
680
|
|
|
666
681
|
const lynxcard = new LynxCard({
|
|
667
682
|
...beforeConfigs,
|
package/dist/XList/ListItem.js
CHANGED
|
@@ -6,8 +6,12 @@ import { __esDecorate, __runInitializers } from "tslib";
|
|
|
6
6
|
*/
|
|
7
7
|
import { Component } from '@lynx-js/web-elements-reactive';
|
|
8
8
|
import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
|
|
9
|
+
import { ListItemAttributes } from './ListItemAttributes.js';
|
|
9
10
|
let ListItem = (() => {
|
|
10
|
-
let _classDecorators = [Component('list-item', [
|
|
11
|
+
let _classDecorators = [Component('list-item', [
|
|
12
|
+
CommonEventsAndMethods,
|
|
13
|
+
ListItemAttributes,
|
|
14
|
+
])];
|
|
11
15
|
let _classDescriptor;
|
|
12
16
|
let _classExtraInitializers = [];
|
|
13
17
|
let _classThis;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AttributeReactiveClass } from '@lynx-js/web-elements-reactive';
|
|
2
|
+
import type { ListItem } from './ListItem.js';
|
|
3
|
+
export declare class ListItemAttributes implements InstanceType<AttributeReactiveClass<typeof HTMLElement>> {
|
|
4
|
+
#private;
|
|
5
|
+
static observedAttributes: string[];
|
|
6
|
+
constructor(dom: ListItem);
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
/*
|
|
3
|
+
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
4
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { Component, registerAttributeHandler, bindToStyle, } from '@lynx-js/web-elements-reactive';
|
|
8
|
+
import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
|
|
9
|
+
let ListItemAttributes = (() => {
|
|
10
|
+
let _private_handlerEstimatedMainAxisSizePx_decorators;
|
|
11
|
+
let _private_handlerEstimatedMainAxisSizePx_initializers = [];
|
|
12
|
+
let _private_handlerEstimatedMainAxisSizePx_extraInitializers = [];
|
|
13
|
+
return class ListItemAttributes {
|
|
14
|
+
static {
|
|
15
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
16
|
+
_private_handlerEstimatedMainAxisSizePx_decorators = [registerAttributeHandler('estimated-main-axis-size-px', true)];
|
|
17
|
+
__esDecorate(null, null, _private_handlerEstimatedMainAxisSizePx_decorators, { kind: "field", name: "#handlerEstimatedMainAxisSizePx", static: false, private: true, access: { has: obj => #handlerEstimatedMainAxisSizePx in obj, get: obj => obj.#handlerEstimatedMainAxisSizePx, set: (obj, value) => { obj.#handlerEstimatedMainAxisSizePx = value; } }, metadata: _metadata }, _private_handlerEstimatedMainAxisSizePx_initializers, _private_handlerEstimatedMainAxisSizePx_extraInitializers);
|
|
18
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
19
|
+
}
|
|
20
|
+
static observedAttributes = [
|
|
21
|
+
'estimated-main-axis-size-px',
|
|
22
|
+
];
|
|
23
|
+
#dom;
|
|
24
|
+
#handlerEstimatedMainAxisSizePx = __runInitializers(this, _private_handlerEstimatedMainAxisSizePx_initializers, bindToStyle(() => this.#dom, '--estimated-main-axis-size-px', (v) => `${parseFloat(v)}px`));
|
|
25
|
+
constructor(dom) {
|
|
26
|
+
__runInitializers(this, _private_handlerEstimatedMainAxisSizePx_extraInitializers);
|
|
27
|
+
this.#dom = dom;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
export { ListItemAttributes };
|
|
32
|
+
//# sourceMappingURL=ListItemAttributes.js.map
|
package/dist/XList/XList.js
CHANGED
|
@@ -94,6 +94,8 @@ let XList = (() => {
|
|
|
94
94
|
}
|
|
95
95
|
if (!this.#autoScrollOptions.lastTimestamp) {
|
|
96
96
|
this.#autoScrollOptions.lastTimestamp = timestamp;
|
|
97
|
+
requestAnimationFrame(this.#autoScroll);
|
|
98
|
+
return;
|
|
97
99
|
}
|
|
98
100
|
const scrollContainer = this.#getListContainer();
|
|
99
101
|
const deltaTime = timestamp - this.#autoScrollOptions.lastTimestamp;
|
|
@@ -101,13 +103,26 @@ let XList = (() => {
|
|
|
101
103
|
scrollContainer.scrollBy({
|
|
102
104
|
left: tickDistance,
|
|
103
105
|
top: tickDistance,
|
|
104
|
-
|
|
106
|
+
// smooth might cause lag when scrolling.
|
|
107
|
+
behavior: 'auto',
|
|
105
108
|
});
|
|
106
109
|
this.#autoScrollOptions.lastTimestamp = timestamp;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
const isScrollVertical = (this.getAttribute('scroll-orientation')
|
|
111
|
+
|| 'vertical') === 'vertical';
|
|
112
|
+
const isContainerScrollable = isScrollVertical
|
|
113
|
+
? scrollContainer.scrollTop + scrollContainer.clientHeight
|
|
114
|
+
>= scrollContainer.scrollHeight
|
|
115
|
+
: scrollContainer.scrollLeft + scrollContainer.clientWidth
|
|
116
|
+
>= scrollContainer.scrollWidth;
|
|
117
|
+
if (isContainerScrollable && this.#autoScrollOptions.autoStop) {
|
|
118
|
+
if (isScrollVertical) {
|
|
119
|
+
scrollContainer.scrollTop = scrollContainer.scrollHeight
|
|
120
|
+
- scrollContainer.clientHeight;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
scrollContainer.scrollLeft = scrollContainer.scrollWidth
|
|
124
|
+
- scrollContainer.clientWidth;
|
|
125
|
+
}
|
|
111
126
|
this.#autoScrollOptions.isScrolling = false;
|
|
112
127
|
}
|
|
113
128
|
else {
|
|
@@ -125,7 +140,20 @@ let XList = (() => {
|
|
|
125
140
|
isScrolling: true,
|
|
126
141
|
autoStop: params.autoStop !== false ? true : false,
|
|
127
142
|
};
|
|
128
|
-
|
|
143
|
+
const scrollContainer = this.#getListContainer();
|
|
144
|
+
const isScrollVertical = (this.getAttribute('scroll-orientation')
|
|
145
|
+
|| 'vertical') === 'vertical';
|
|
146
|
+
const isContainerScrollable = isScrollVertical
|
|
147
|
+
? scrollContainer.clientHeight <= scrollContainer.scrollHeight
|
|
148
|
+
: scrollContainer.clientWidth <= scrollContainer.scrollWidth;
|
|
149
|
+
this.#autoScrollOptions.lastTimestamp = 0;
|
|
150
|
+
if (isContainerScrollable) {
|
|
151
|
+
// During the initial render, there might be instances in raq where scrollContainer hasn't fully expanded (rendering hasn't succeeded yet), so use setTimeout.
|
|
152
|
+
setTimeout(() => requestAnimationFrame(this.#autoScroll), 0);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
requestAnimationFrame(this.#autoScroll);
|
|
156
|
+
}
|
|
129
157
|
}
|
|
130
158
|
else {
|
|
131
159
|
this.#autoScrollOptions.isScrolling = false;
|
|
@@ -4,17 +4,48 @@ 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 { genDomGetter, registerAttributeHandler, } from '@lynx-js/web-elements-reactive';
|
|
7
|
+
import { genDomGetter, registerAttributeHandler, registerEventEnableStatusChangeHandler, } from '@lynx-js/web-elements-reactive';
|
|
8
8
|
const WATERFALL_SLOT = 'waterfall-slot';
|
|
9
9
|
const WATERFALL_STYLE = 'waterfall-style';
|
|
10
10
|
let XListWaterfall = (() => {
|
|
11
11
|
let _instanceExtraInitializers = [];
|
|
12
|
+
let _private_handleXEnableHeaderOffsetEvent_decorators;
|
|
13
|
+
let _private_handleXEnableHeaderOffsetEvent_descriptor;
|
|
12
14
|
let _private_handlerListType_decorators;
|
|
13
15
|
let _private_handlerListType_descriptor;
|
|
14
16
|
return class XListWaterfall {
|
|
15
17
|
static {
|
|
16
18
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
19
|
+
_private_handleXEnableHeaderOffsetEvent_decorators = [registerEventEnableStatusChangeHandler('scrolltolower')];
|
|
17
20
|
_private_handlerListType_decorators = [registerAttributeHandler('list-type', true)];
|
|
21
|
+
__esDecorate(this, _private_handleXEnableHeaderOffsetEvent_descriptor = { value: __setFunctionName(function (enableScrollToLower) {
|
|
22
|
+
enableScrollToLower
|
|
23
|
+
? this.#dom.setAttribute('x-enable-scrolltolower-event', '')
|
|
24
|
+
: this.#dom.removeAttribute('x-enable-scrolltolower-event'); // css needs this;
|
|
25
|
+
if (enableScrollToLower) {
|
|
26
|
+
const lower = this.#getLowerThresholdObserver();
|
|
27
|
+
const scrollOrientation = this.#dom.getAttribute('scroll-orientation')
|
|
28
|
+
|| 'vertical';
|
|
29
|
+
const listContent = this.#getListContainer();
|
|
30
|
+
// under waterfall, and when the list-item does not have a specified height, obtaining the correct scrollable value takes some time.
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
if (scrollOrientation === 'vertical') {
|
|
33
|
+
lower.style.setProperty('top',
|
|
34
|
+
// Firefox cannot trigger the bottom IntersectionObserver
|
|
35
|
+
`${String(listContent.scrollHeight - 1)}px`, 'important');
|
|
36
|
+
// Firefox needs this
|
|
37
|
+
lower.style.setProperty('bottom', 'unset', 'important');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
lower.style.setProperty('left',
|
|
41
|
+
// Firefox cannot trigger the bottom IntersectionObserver
|
|
42
|
+
`${String(listContent.scrollWidth - 1)}px`, 'important');
|
|
43
|
+
// Firefox needs this
|
|
44
|
+
lower.style.setProperty('right', 'unset', 'important');
|
|
45
|
+
}
|
|
46
|
+
}, 100);
|
|
47
|
+
}
|
|
48
|
+
}, "#handleXEnableHeaderOffsetEvent") }, _private_handleXEnableHeaderOffsetEvent_decorators, { kind: "method", name: "#handleXEnableHeaderOffsetEvent", static: false, private: true, access: { has: obj => #handleXEnableHeaderOffsetEvent in obj, get: obj => obj.#handleXEnableHeaderOffsetEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
18
49
|
__esDecorate(this, _private_handlerListType_descriptor = { value: __setFunctionName(function (newVal) {
|
|
19
50
|
if (newVal === 'waterfall') {
|
|
20
51
|
this.#createWaterfallContainer();
|
|
@@ -54,6 +85,7 @@ let XListWaterfall = (() => {
|
|
|
54
85
|
#getLowerThresholdObserver = genDomGetter(() => this.#dom.shadowRoot, 'div[part="lower-threshold-observer"]');
|
|
55
86
|
#resizeObserver;
|
|
56
87
|
#childrenObserver;
|
|
88
|
+
get #handleXEnableHeaderOffsetEvent() { return _private_handleXEnableHeaderOffsetEvent_descriptor.value; }
|
|
57
89
|
#createWaterfallContainer = () => {
|
|
58
90
|
const waterfallSlot = document.createElement('slot');
|
|
59
91
|
waterfallSlot.setAttribute('name', `${WATERFALL_SLOT}`);
|
|
@@ -122,29 +154,6 @@ let XListWaterfall = (() => {
|
|
|
122
154
|
listItem.style.setProperty('top', listItem.getAttribute(`${WATERFALL_STYLE}-top`));
|
|
123
155
|
listItem.setAttribute('slot', WATERFALL_SLOT);
|
|
124
156
|
}
|
|
125
|
-
// The reasons why it is not unified in #updateScrollToLowerEventSwitches is:
|
|
126
|
-
// It is impossible to ensure that list-item is not rendered, so it will cause incorrect listContent.scrollHeight/scrollWidth as height/width.
|
|
127
|
-
const enableScrollToLower = this.#dom.getAttribute('x-enable-scrolltolower-event');
|
|
128
|
-
if (enableScrollToLower !== null && enableScrollToLower !== 'false') {
|
|
129
|
-
const lower = this.#getLowerThresholdObserver();
|
|
130
|
-
const scrollOrientation = this.#dom.getAttribute('scroll-orientation')
|
|
131
|
-
|| 'vertical';
|
|
132
|
-
const listContent = this.#getListContainer();
|
|
133
|
-
if (scrollOrientation === 'vertical') {
|
|
134
|
-
lower.style.setProperty('top',
|
|
135
|
-
// Firefox cannot trigger the bottom IntersectionObserver
|
|
136
|
-
`${String(listContent.scrollHeight - 1)}px`, 'important');
|
|
137
|
-
// Firefox needs this
|
|
138
|
-
lower.style.setProperty('bottom', 'unset', 'important');
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
lower.style.setProperty('left',
|
|
142
|
-
// Firefox cannot trigger the bottom IntersectionObserver
|
|
143
|
-
`${String(listContent.scrollHeight - 1)}px`);
|
|
144
|
-
// Firefox needs this
|
|
145
|
-
lower.style.setProperty('right', 'unset');
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
157
|
};
|
|
149
158
|
constructor(dom) {
|
|
150
159
|
this.#dom = dom;
|
package/dist/all.d.ts
CHANGED
package/dist/all.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-elements-canary",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.10-canary-20251103-fece7d0a",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
],
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"@lynx-js/web-elements-reactive": "npm:@lynx-js/web-elements-reactive-canary@0.2.2",
|
|
104
|
-
"@lynx-js/web-elements-template": "npm:@lynx-js/web-elements-template-canary@0.8.
|
|
104
|
+
"@lynx-js/web-elements-template": "npm:@lynx-js/web-elements-template-canary@0.8.10-canary-20251103-fece7d0a"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"tslib": "^2.8.1"
|
package/src/XList/x-list.css
CHANGED
|
@@ -60,6 +60,8 @@ list-item {
|
|
|
60
60
|
content-visibility: auto;
|
|
61
61
|
flex: 0 0 auto !important;
|
|
62
62
|
position: static;
|
|
63
|
+
contain: size;
|
|
64
|
+
contain-intrinsic-size: auto var(--estimated-main-axis-size-px);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
x-list > list-item, x-list > lynx-wrapper > list-item {
|
|
@@ -266,5 +268,6 @@ x-list[list-type="waterfall"]::part(lower-threshold-observer) {
|
|
|
266
268
|
}
|
|
267
269
|
|
|
268
270
|
x-list[list-type="waterfall"][scroll-orientation="horizontal"]::part(lower-threshold-observer) {
|
|
271
|
+
bottom: unset;
|
|
269
272
|
right: -999px;
|
|
270
273
|
}
|