@lynx-js/web-elements 0.12.6 → 0.12.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @lynx-js/web-elements
2
2
 
3
+ ## 0.12.8
4
+
5
+ ### Patch Changes
6
+
7
+ - Keep XList scroll offsets and automatic scrolling aligned with its configured orientation. ([#3357](https://github.com/lynx-family/lynx-stack/pull/3357))
8
+
9
+ - Updated dependency `dompurify` to `^3.4.13`. ([#3417](https://github.com/lynx-family/lynx-stack/pull/3417))
10
+
11
+ - Updated dependency `markdown-it` to `^15.0.0`. ([#3423](https://github.com/lynx-family/lynx-stack/pull/3423))
12
+
13
+ ## 0.12.7
14
+
15
+ ### Patch Changes
16
+
17
+ - Fix internal variable typo (`mesaurement` -> `measurement`). No behavior change. ([#3128](https://github.com/lynx-family/lynx-stack/pull/3128))
18
+
19
+ - Fix x-text custom truncation when inline x-view elements are included in the measured text. ([#2998](https://github.com/lynx-family/lynx-stack/pull/2998))
20
+
21
+ - Update `dompurify` from `^3.3.1` to `^3.4.12` ([#3200](https://github.com/lynx-family/lynx-stack/pull/3200))
22
+
23
+ - Update `markdown-it` from `^14.1.0` to `^14.3.0` ([#3121](https://github.com/lynx-family/lynx-stack/pull/3121))
24
+
25
+ - Document and verify the `message` event forwarded from an `x-webview` iframe. ([#3167](https://github.com/lynx-family/lynx-stack/pull/3167))
26
+
3
27
  ## 0.12.6
4
28
 
5
29
  ### Patch Changes
@@ -42,7 +42,7 @@ let XList = (() => {
42
42
  this.#getListContainer().scrollTop = val;
43
43
  }
44
44
  get scrollLeft() {
45
- return this.#getListContainer().scrollTop;
45
+ return this.#getListContainer().scrollLeft;
46
46
  }
47
47
  set scrollLeft(val) {
48
48
  this.#getListContainer().scrollLeft = val;
@@ -60,7 +60,7 @@ let XList = (() => {
60
60
  return super.scrollTop;
61
61
  }
62
62
  get __scrollLeft() {
63
- return super.scrollTop;
63
+ return super.scrollLeft;
64
64
  }
65
65
  scrollToPosition(params) {
66
66
  let offset;
@@ -110,15 +110,15 @@ let XList = (() => {
110
110
  const scrollContainer = this.#getListContainer();
111
111
  const deltaTime = timestamp - this.#autoScrollOptions.lastTimestamp;
112
112
  const tickDistance = (deltaTime / 1000) * this.#autoScrollOptions.rate;
113
+ const isScrollVertical = (this.getAttribute('scroll-orientation')
114
+ || 'vertical') === 'vertical';
113
115
  scrollContainer.scrollBy({
114
- left: tickDistance,
115
- top: tickDistance,
116
+ left: isScrollVertical ? 0 : tickDistance,
117
+ top: isScrollVertical ? tickDistance : 0,
116
118
  // smooth might cause lag when scrolling.
117
119
  behavior: 'auto',
118
120
  });
119
121
  this.#autoScrollOptions.lastTimestamp = timestamp;
120
- const isScrollVertical = (this.getAttribute('scroll-orientation')
121
- || 'vertical') === 'vertical';
122
122
  const isContainerScrollable = isScrollVertical
123
123
  ? scrollContainer.scrollTop + scrollContainer.clientHeight
124
124
  >= scrollContainer.scrollHeight
@@ -7,6 +7,39 @@ import { __esDecorate, __runInitializers } from "tslib";
7
7
  import { boostedQueueMicrotask, genDomGetter, registerAttributeHandler, } from '../../element-reactive/index.js';
8
8
  import { commonComponentEventSetting } from '../common/commonEventInitConfiguration.js';
9
9
  import { registerEventEnableStatusChangeHandler } from '../../element-reactive/index.js';
10
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
11
+ const getSiblingIndex = (node) => {
12
+ let index = 0;
13
+ let previousNode = node.previousSibling;
14
+ while (previousNode) {
15
+ index++;
16
+ previousNode = previousNode.previousSibling;
17
+ }
18
+ return index;
19
+ };
20
+ const getRangePosition = (nodeInfo, offsetInNode) => {
21
+ const { node } = nodeInfo;
22
+ if (node.nodeType === Node.TEXT_NODE) {
23
+ return {
24
+ container: node,
25
+ offset: clamp(offsetInNode, 0, node.data.length),
26
+ };
27
+ }
28
+ // Elements are one virtual character, while DOM Range offsets address child
29
+ // indexes. Use the parent's before/after-element boundary instead.
30
+ const elementOffset = offsetInNode > 0 ? 1 : 0;
31
+ const parentNode = node.parentNode;
32
+ if (!parentNode) {
33
+ return {
34
+ container: node,
35
+ offset: clamp(elementOffset, 0, node.childNodes.length),
36
+ };
37
+ }
38
+ return {
39
+ container: parentNode,
40
+ offset: getSiblingIndex(node) + elementOffset,
41
+ };
42
+ };
10
43
  let XTextTruncation = (() => {
11
44
  var _a;
12
45
  let _instanceExtraInitializers = [];
@@ -144,12 +177,14 @@ let XTextTruncation = (() => {
144
177
  let currentNodeInfo = measure
145
178
  .getNodeInfoByCharIndex(maxLineEndAt);
146
179
  const endCharInNodeIndex = end - currentNodeInfo.start;
147
- range.setEnd(currentNodeInfo.node, endCharInNodeIndex);
148
- range.setStart(currentNodeInfo.node, endCharInNodeIndex);
180
+ const initialRangePosition = getRangePosition(currentNodeInfo, endCharInNodeIndex);
181
+ range.setEnd(initialRangePosition.container, initialRangePosition.offset);
182
+ range.setStart(initialRangePosition.container, initialRangePosition.offset);
149
183
  while (range.getBoundingClientRect().width < inlineTruncationWidth
150
184
  && (maxLineEndAt -= 1)
151
185
  && (currentNodeInfo = measure.getNodeInfoByCharIndex(maxLineEndAt))) {
152
- range.setStart(currentNodeInfo.node, maxLineEndAt - currentNodeInfo.start);
186
+ const rangePosition = getRangePosition(currentNodeInfo, maxLineEndAt - currentNodeInfo.start);
187
+ range.setStart(rangePosition.container, rangePosition.offset);
153
188
  }
154
189
  }
155
190
  else {
@@ -353,11 +388,11 @@ class TextRenderingMeasureTool {
353
388
  if (lastRectInfo.node.nodeType === Node.TEXT_NODE) {
354
389
  const { rect, rectIndex } = lastRectInfo;
355
390
  const textNode = lastRectInfo.node;
356
- const mesaurementRange = document.createRange();
357
- mesaurementRange.selectNode(textNode);
391
+ const measurementRange = document.createRange();
392
+ measurementRange.selectNode(textNode);
358
393
  for (let charIndex = 0; charIndex < textNode.data.length; charIndex++) {
359
- mesaurementRange.setEnd(textNode, charIndex);
360
- const targetRect = mesaurementRange.getClientRects().item(rectIndex);
394
+ measurementRange.setEnd(textNode, charIndex);
395
+ const targetRect = measurementRange.getClientRects().item(rectIndex);
361
396
  if (targetRect && targetRect.right === rect.right) {
362
397
  return charIndex;
363
398
  }
@@ -10,6 +10,8 @@
10
10
  * Events:
11
11
  * - `bindload`: Fired when the page loads. Detail: `{ url }`.
12
12
  * - `binderror`: Fired when an error occurs. Detail: `{ errorMsg }`.
13
+ * - `message`: Fired when the page posts a message to its parent. Detail:
14
+ * `{ msg, data }`.
13
15
  * - `bindmessage`: Fired when a message is received from the page. Detail: `{ msg }`.
14
16
  *
15
17
  * Methods:
@@ -13,6 +13,8 @@
13
13
  * Events:
14
14
  * - `bindload`: Fired when the page loads. Detail: `{ url }`.
15
15
  * - `binderror`: Fired when an error occurs. Detail: `{ errorMsg }`.
16
+ * - `message`: Fired when the page posts a message to its parent. Detail:
17
+ * `{ msg, data }`.
16
18
  * - `bindmessage`: Fired when a message is received from the page. Detail: `{ msg }`.
17
19
  *
18
20
  * Methods:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-elements",
3
- "version": "0.12.6",
3
+ "version": "0.12.8",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -134,15 +134,16 @@
134
134
  "**/*.css"
135
135
  ],
136
136
  "dependencies": {
137
- "dompurify": "^3.3.1",
138
- "markdown-it": "^14.1.0"
137
+ "dompurify": "^3.4.13",
138
+ "markdown-it": "^15.0.0"
139
139
  },
140
140
  "devDependencies": {
141
141
  "@playwright/test": "^1.61.1",
142
- "@rsbuild/core": "2.1.4",
143
- "@rsbuild/plugin-source-build": "1.0.5",
144
- "@types/markdown-it": "^14.1.1",
145
- "nyc": "^17.1.0",
142
+ "@rsbuild/core": "2.1.10",
143
+ "@rsbuild/plugin-source-build": "1.0.6",
144
+ "@types/markdown-it": "^14.1.2",
145
+ "@types/node": "^24.13.3",
146
+ "nyc": "^18.0.0",
146
147
  "tslib": "^2.8.1",
147
148
  "@lynx-js/playwright-fixtures": "0.0.0"
148
149
  },
@@ -192,10 +192,6 @@ x-list::part(lower-threshold-observer) {
192
192
  flex-direction: column-reverse;
193
193
  }
194
194
 
195
- x-list[vertical-orientation="false"]::part(lower-threshold-observer) {
196
- flex-direction: row-reverse;
197
- }
198
-
199
195
  /* list-type single */
200
196
  x-list {
201
197
  display: flex;