@lynx-js/web-elements 0.6.0 → 0.7.1

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,36 @@
1
1
  # @lynx-js/web-elements
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(web): x-swiper-item threshold updated to 20 ([#639](https://github.com/lynx-family/lynx-stack/pull/639))
8
+
9
+ - fix: In React19, setter and getter functions are treated as properties, making it impossible to retrieve the current value via attributes. ([#639](https://github.com/lynx-family/lynx-stack/pull/639))
10
+
11
+ ## 0.7.0
12
+
13
+ ### Minor Changes
14
+
15
+ - fix: ([#629](https://github.com/lynx-family/lynx-stack/pull/629))
16
+
17
+ - typo of `initial-scroll-offset` in scroll-view.
18
+ - scroll-view's `initial-scroll-index` is changed to `initial-scroll-to-index`.
19
+
20
+ ### Patch Changes
21
+
22
+ - fix: x-image border-radius setting has no effect. ([#638](https://github.com/lynx-family/lynx-stack/pull/638))
23
+
24
+ - perf: late evaluate document.font.ready ([#604](https://github.com/lynx-family/lynx-stack/pull/604))
25
+
26
+ - perf: improve raw-text performance ([#601](https://github.com/lynx-family/lynx-stack/pull/601))
27
+
28
+ - fix: the scroll-x field of scroll-view needs to be handled correctly. ([#635](https://github.com/lynx-family/lynx-stack/pull/635))
29
+
30
+ Before this, scroll-x of '' would result in no scrolling along x-axis.
31
+
32
+ - feat: x-list supports `need-visible-item-info`, now you can get visible cells info in `scroll`、`scrolltoupper`、`scrolltolower` event. ([#595](https://github.com/lynx-family/lynx-stack/pull/595))
33
+
3
34
  ## 0.6.0
4
35
 
5
36
  ### Minor Changes
@@ -14,8 +14,8 @@ let ScrollAttributes = (() => {
14
14
  return class ScrollAttributes {
15
15
  static {
16
16
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
17
- _private_handleInitialScrollOffset_decorators = [registerAttributeHandler('scroll-top', false), registerAttributeHandler('scroll-left', false), registerAttributeHandler('nitial-scroll-offset', false)];
18
- _private_handleInitialScrollIndex_decorators = [registerAttributeHandler('scroll-to-index', false), registerAttributeHandler('initial-scroll-index', false)];
17
+ _private_handleInitialScrollOffset_decorators = [registerAttributeHandler('scroll-top', false), registerAttributeHandler('scroll-left', false), registerAttributeHandler('initial-scroll-offset', false)];
18
+ _private_handleInitialScrollIndex_decorators = [registerAttributeHandler('scroll-to-index', false), registerAttributeHandler('initial-scroll-to-index', false)];
19
19
  __esDecorate(this, _private_handleInitialScrollOffset_descriptor = { value: __setFunctionName(function (newVal, _, attributeName) {
20
20
  if (newVal) {
21
21
  const scrollValue = parseFloat(newVal);
@@ -49,7 +49,7 @@ let ScrollAttributes = (() => {
49
49
  const scrollValue = parseFloat(newVal);
50
50
  const childrenElement = this.#dom.children.item(scrollValue);
51
51
  if (childrenElement && childrenElement instanceof HTMLElement) {
52
- const scrollX = !!this.#dom.getAttribute('scroll-x');
52
+ const scrollX = this.#dom.getAttribute('scroll-x') !== null;
53
53
  requestAnimationFrame(() => {
54
54
  if (scrollX) {
55
55
  this.#dom.scrollLeft = childrenElement.offsetLeft;
@@ -69,7 +69,7 @@ let ScrollAttributes = (() => {
69
69
  'scroll-left',
70
70
  'initial-scroll-offset',
71
71
  'scroll-to-index',
72
- 'initial-scroll-index',
72
+ 'initial-scroll-to-index',
73
73
  ];
74
74
  constructor(dom) {
75
75
  this.#dom = dom;
@@ -101,6 +101,7 @@ let XListEvents = (() => {
101
101
  #getUpperThresholdObserverDom = genDomGetter(() => this.#dom.shadowRoot, '#upper-threshold-observer');
102
102
  #getLowerThresholdObserverDom = genDomGetter(() => this.#dom.shadowRoot, '#lower-threshold-observer');
103
103
  #getScrollDetail() {
104
+ const needVisibleItemInfo = this.#dom.getAttribute('need-visible-item-info') !== null;
104
105
  const { scrollTop, scrollLeft, scrollHeight, scrollWidth } = this
105
106
  .#getListContainer();
106
107
  const detail = {
@@ -110,6 +111,9 @@ let XListEvents = (() => {
110
111
  scrollWidth,
111
112
  deltaX: scrollLeft - this.#prevX,
112
113
  deltaY: scrollTop - this.#prevY,
114
+ attachedCells: needVisibleItemInfo
115
+ ? this.#dom.getVisibleCells()
116
+ : undefined,
113
117
  };
114
118
  this.#prevX = scrollLeft;
115
119
  this.#prevY = scrollTop;
@@ -276,9 +280,7 @@ let XListEvents = (() => {
276
280
  }
277
281
  this.#dom.dispatchEvent(new CustomEvent('lynxscroll', {
278
282
  ...commonComponentEventSetting,
279
- detail: {
280
- type: 'scroll',
281
- },
283
+ detail: this.#getScrollDetail(),
282
284
  }));
283
285
  };
284
286
  #handleScrollEventsSwitches = __runInitializers(this, _private_handleScrollEventsSwitches_initializers, (enabled, name) => {
@@ -2,8 +2,8 @@ import { scrollContainerDom } from '../common/constants.js';
2
2
  export declare class XSwiper extends HTMLElement {
3
3
  #private;
4
4
  static notToFilterFalseAttributes: Set<string>;
5
- get current(): number;
6
- set current(newval: number);
5
+ get currentIndex(): number;
6
+ set currentIndex(newval: number);
7
7
  get snapDistance(): number;
8
8
  get isVertical(): boolean;
9
9
  get circularPlay(): boolean;
@@ -136,12 +136,12 @@ let XSwiper = (() => {
136
136
  minOffsetToMid,
137
137
  };
138
138
  }
139
- get current() {
139
+ get currentIndex() {
140
140
  return this.#getNeatestElementIndexAndDistanceToMid().current;
141
141
  }
142
- set current(newval) {
142
+ set currentIndex(newval) {
143
143
  // When current is specified and current is updated in bindchange, there is no need to respond to the update of current
144
- if (this.current === newval) {
144
+ if (this.currentIndex === newval) {
145
145
  return;
146
146
  }
147
147
  const smooth = this.getAttribute('smooth-scroll') === null; // smooth-scroll default true, it is set to be false
@@ -186,29 +186,29 @@ let XSwiper = (() => {
186
186
  return this.getAttribute('circular') !== null;
187
187
  }
188
188
  scrollToNext() {
189
- const current = this.current;
189
+ const current = this.currentIndex;
190
190
  const count = this.childElementCount;
191
191
  if (current === count - 1) {
192
192
  const circularPlay = this.circularPlay;
193
193
  if (circularPlay) {
194
- this.current = 0;
194
+ this.currentIndex = 0;
195
195
  }
196
196
  }
197
197
  else {
198
- this.current += 1;
198
+ this.currentIndex += 1;
199
199
  }
200
200
  }
201
201
  scrollToPrevious() {
202
- const current = this.current;
202
+ const current = this.currentIndex;
203
203
  const count = this.childElementCount;
204
204
  if (current === 0) {
205
205
  const circularPlay = this.circularPlay;
206
206
  if (circularPlay) {
207
- this.current = count - 1;
207
+ this.currentIndex = count - 1;
208
208
  }
209
209
  }
210
210
  else {
211
- this.current == count - 1;
211
+ this.currentIndex = count - 1;
212
212
  }
213
213
  }
214
214
  connectedCallback() {
@@ -19,7 +19,7 @@ let XSwiperAutoScroll = (() => {
19
19
  __esDecorate(this, _private_handleCurrentChange_descriptor = { value: __setFunctionName(function (newVal) {
20
20
  const newval = Number(newVal);
21
21
  if (!Number.isNaN(newval)) {
22
- this.#dom.current = newval;
22
+ this.#dom.currentIndex = newval;
23
23
  }
24
24
  }, "#handleCurrentChange") }, _private_handleCurrentChange_decorators, { kind: "method", name: "#handleCurrentChange", static: false, private: true, access: { has: obj => #handleCurrentChange in obj, get: obj => obj.#handleCurrentChange }, metadata: _metadata }, null, _instanceExtraInitializers);
25
25
  __esDecorate(this, _private_handleAutoplay_descriptor = { value: __setFunctionName(function () {
@@ -21,7 +21,7 @@ let XSwiperCircular = (() => {
21
21
  if (newVal !== null) {
22
22
  this.#changeEventHandler({
23
23
  detail: {
24
- current: this.#dom.current,
24
+ current: this.#dom.currentIndex,
25
25
  isDragged: false,
26
26
  __isFirstLayout: true,
27
27
  },
@@ -77,7 +77,7 @@ let XSwipeEvents = (() => {
77
77
  > pageLength / 4
78
78
  || currentScrollDistance < 10
79
79
  || Math.abs(currentScrollDistance - totalScrollDistance) <= pageLength) {
80
- const current = this.#dom.current;
80
+ const current = this.#dom.currentIndex;
81
81
  if (current !== this.#current) {
82
82
  this.#dom.dispatchEvent(new CustomEvent('change', {
83
83
  ...commonComponentEventSetting,
@@ -103,7 +103,7 @@ let XSwiperIndicator = (() => {
103
103
  }
104
104
  }).bind(this));
105
105
  boostedQueueMicrotask(() => {
106
- this.#getIndicatorContainer().children[this.#dom.current]?.style.setProperty('background-color', 'var(--indicator-active-color)', 'important');
106
+ this.#getIndicatorContainer().children[this.#dom.currentIndex]?.style.setProperty('background-color', 'var(--indicator-active-color)', 'important');
107
107
  });
108
108
  }
109
109
  }
@@ -14,17 +14,17 @@ let RawTextAttributes = (() => {
14
14
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
15
15
  _private_handleText_decorators = [registerAttributeHandler('text', true)];
16
16
  __esDecorate(this, _private_handleText_descriptor = { value: __setFunctionName(function (newVal) {
17
+ this.#text?.remove();
17
18
  if (newVal) {
18
- this.#dom.innerHTML = newVal;
19
- }
20
- else {
21
- this.#dom.innerHTML = '';
19
+ this.#text = new Text(newVal);
20
+ this.#dom.append(this.#text);
22
21
  }
23
22
  }, "#handleText") }, _private_handleText_decorators, { kind: "method", name: "#handleText", static: false, private: true, access: { has: obj => #handleText in obj, get: obj => obj.#handleText }, metadata: _metadata }, null, _instanceExtraInitializers);
24
23
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
25
24
  }
26
25
  static observedAttributes = ['text'];
27
26
  #dom = __runInitializers(this, _instanceExtraInitializers);
27
+ #text;
28
28
  constructor(currentElement) {
29
29
  this.#dom = currentElement;
30
30
  }
@@ -127,20 +127,19 @@ let XTextTruncation = (() => {
127
127
  if (this.#scheduledTextLayout)
128
128
  return;
129
129
  this.#scheduledTextLayout = true;
130
- boostedQueueMicrotask(() => {
131
- this.#layoutTextInner();
130
+ boostedQueueMicrotask(async () => {
131
+ await this.#layoutTextInner();
132
132
  this.#startObservers();
133
- queueMicrotask(() => {
134
- this.#scheduledTextLayout = false;
135
- });
133
+ this.#scheduledTextLayout = false;
136
134
  });
137
135
  }
138
- #layoutTextInner() {
136
+ async #layoutTextInner() {
139
137
  this.#inplaceEllipsisNode?.parentElement?.removeChild(this.#inplaceEllipsisNode);
140
138
  this.#revertTruncatedTextNodes();
141
139
  if (!this.#doExpensiveLineLayoutCalculation && isNaN(this.#maxLength)) {
142
140
  return;
143
141
  }
142
+ await document.fonts.ready;
144
143
  const parentBondingRect = this.#getInnerBox().getBoundingClientRect();
145
144
  this.#textMeasure = new TextRenderingMeasureTool(this.#dom, parentBondingRect);
146
145
  const measure = this.#textMeasure;
@@ -338,9 +337,7 @@ let XTextTruncation = (() => {
338
337
  connectedCallback() {
339
338
  this.#componentConnected = true;
340
339
  this.#handleEnableLayoutEvent(this.#enableLayoutEvent);
341
- document.fonts.ready.then(() => {
342
- this.#handleAttributeChange();
343
- });
340
+ this.#handleAttributeChange();
344
341
  boostedQueueMicrotask(() => {
345
342
  this.#sendLayoutEvent();
346
343
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-elements",
3
- "version": "0.6.0",
3
+ "version": "0.7.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -68,6 +68,7 @@ x-image[auto-size]::part(img) {
68
68
  min-width: inherit;
69
69
  min-height: inherit;
70
70
  border: inherit;
71
+ border-radius: inherit;
71
72
  max-width: 100%;
72
73
  max-height: 100%;
73
74
  position: inherit;
@@ -74,7 +74,7 @@ x-swiper-item {
74
74
  flex-basis: var(--lynx-linear-weight-basis) !important;
75
75
  }
76
76
 
77
- x-swiper-item:nth-child(n+5) {
77
+ x-swiper-item:nth-child(n+20) {
78
78
  contain: strict;
79
79
  content-visibility: auto;
80
80
  }
@@ -196,14 +196,16 @@ x-refresh-view,
196
196
  x-swiper-item,
197
197
  x-viewpager-item-ng,
198
198
  x-viewpager-ng {
199
- flex-wrap: var(--lynx-display-linear, nowrap) var(
200
- --lynx-display-flex,
201
- var(--flex-wrap)
202
- );
203
- flex-direction: var(--lynx-display-linear, var(--linear-flex-direction)) var(
204
- --lynx-display-flex,
205
- var(--flex-direction)
206
- );
199
+ flex-wrap: var(--lynx-display-linear, nowrap)
200
+ var(
201
+ --lynx-display-flex,
202
+ var(--flex-wrap)
203
+ );
204
+ flex-direction: var(--lynx-display-linear, var(--linear-flex-direction))
205
+ var(
206
+ --lynx-display-flex,
207
+ var(--flex-direction)
208
+ );
207
209
  justify-content: var(--lynx-display-linear, var(--linear-justify-content));
208
210
  }
209
211