@lynx-js/web-elements 0.11.1 → 0.11.3

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,23 @@
1
1
  # @lynx-js/web-elements
2
2
 
3
+ ## 0.11.3
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: firefox 147+ layout issue ([#2205](https://github.com/lynx-family/lynx-stack/pull/2205))
8
+
9
+ ## 0.11.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Add scrollHeight/scrollWidth getters to XList. ([#2156](https://github.com/lynx-family/lynx-stack/pull/2156))
14
+
15
+ - Inherit padding styles for x-input elements. ([#2199](https://github.com/lynx-family/lynx-stack/pull/2199))
16
+
17
+ - Remove the default lazy-loading attribute from x-image elements. ([#2186](https://github.com/lynx-family/lynx-stack/pull/2186))
18
+
19
+ - Fix x-input number type forwarding to the inner input element. ([#2193](https://github.com/lynx-family/lynx-stack/pull/2193))
20
+
3
21
  ## 0.11.1
4
22
 
5
23
  ### Patch Changes
@@ -1,5 +1,4 @@
1
1
  import { type AttributeReactiveClass } from '../../element-reactive/index.js';
2
- import '../../../src/compat/LinearContainer/linear-compat.css';
3
2
  declare class LinearContainerImpl implements InstanceType<AttributeReactiveClass<typeof HTMLElement>> {
4
3
  #private;
5
4
  static readonly observedAttributes: never[];
@@ -2,7 +2,6 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { bindToAttribute, } from '../../element-reactive/index.js';
5
- import '../../../src/compat/LinearContainer/linear-compat.css';
6
5
  /** For @container
7
6
  * chrome 111, safari 18, firefox no
8
7
  *
@@ -39,15 +38,15 @@ import '../../../src/compat/LinearContainer/linear-compat.css';
39
38
  * it fixed in 116.0.5806.0, detail: https://issues.chromium.org/issues/40270007
40
39
  *
41
40
  * so we limit this feature to chrome 117, safari 18, firefox no:
42
- * rex unit: chrome 111, safari 17.2, firefox no
43
- * https://developer.mozilla.org/en-US/docs/Web/CSS/length
41
+ * -webkit-box-reflect: chrome 4, safari 4, firefox no
42
+ * https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/-webkit-box-reflect
44
43
  * transition-behavior:allow-discrete: chrome 117, safari 18, firefox 125
45
44
  * https://developer.mozilla.org/en-US/docs/Web/CSS/transition-behavior
46
45
  * https://caniuse.com/mdn-css_properties_display_is_transitionable
47
46
  *
48
47
  * update this once firefox supports this.
49
48
  */
50
- const supportContainerStyleQuery = CSS.supports('width:1rex')
49
+ const supportContainerStyleQuery = CSS.supports('-webkit-box-reflect: above')
51
50
  && CSS.supports('transition-behavior:allow-discrete')
52
51
  && CSS.supports('content-visibility: auto');
53
52
  class LinearContainerImpl {
@@ -27,6 +27,7 @@ let XInputEvents = (() => {
27
27
  static observedAttributes = ['send-composing-input', 'input-filter'];
28
28
  #dom = __runInitializers(this, _instanceExtraInitializers);
29
29
  #sendComposingInput = false;
30
+ #numberInputFilter = /[^0-9.]|\.(?=.*\.)/g;
30
31
  #getInputElement = genDomGetter(() => this.#dom.shadowRoot, '#input');
31
32
  #getFormElement = genDomGetter(() => this.#dom.shadowRoot, '#form');
32
33
  _handleEnableInputEvent(status) {
@@ -54,10 +55,7 @@ let XInputEvents = (() => {
54
55
  };
55
56
  #teleportInput = (event) => {
56
57
  const input = this.#getInputElement();
57
- const inputFilter = this.#dom.getAttribute('input-filter');
58
- const filterValue = inputFilter
59
- ? input.value.replace(new RegExp(inputFilter, 'g'), '')
60
- : input.value;
58
+ const filterValue = this.#filterInputValue(input.value);
61
59
  const isComposing = event.isComposing;
62
60
  input.value = filterValue;
63
61
  if (isComposing && !this.#sendComposingInput)
@@ -78,10 +76,7 @@ let XInputEvents = (() => {
78
76
  };
79
77
  #teleportCompositionendInput = () => {
80
78
  const input = this.#getInputElement();
81
- const inputFilter = this.#dom.getAttribute('input-filter');
82
- const filterValue = inputFilter
83
- ? input.value.replace(new RegExp(inputFilter, 'g'), '')
84
- : input.value;
79
+ const filterValue = this.#filterInputValue(input.value);
85
80
  input.value = filterValue;
86
81
  // if #sendComposingInput set true, #teleportInput will send detail
87
82
  if (!this.#sendComposingInput) {
@@ -100,6 +95,17 @@ let XInputEvents = (() => {
100
95
  }));
101
96
  }
102
97
  };
98
+ #filterInputValue(value) {
99
+ let filterValue = value;
100
+ if (this.#dom.getAttribute('type') === 'number') {
101
+ filterValue = filterValue.replace(this.#numberInputFilter, '');
102
+ }
103
+ const inputFilter = this.#dom.getAttribute('input-filter');
104
+ if (inputFilter) {
105
+ filterValue = filterValue.replace(new RegExp(inputFilter, 'g'), '');
106
+ }
107
+ return filterValue;
108
+ }
103
109
  _handleEnableSelectionEvent(status) {
104
110
  if (status) {
105
111
  this.#getInputElement().addEventListener('select', this.#selectEvent, {
@@ -5,6 +5,8 @@ export declare class XList extends HTMLElement {
5
5
  set scrollTop(val: number);
6
6
  get scrollLeft(): number;
7
7
  set scrollLeft(val: number);
8
+ get scrollHeight(): number;
9
+ get scrollWidth(): number;
8
10
  get __scrollTop(): number;
9
11
  get __scrollLeft(): number;
10
12
  scrollToPosition(params: {
@@ -46,6 +46,12 @@ let XList = (() => {
46
46
  set scrollLeft(val) {
47
47
  this.#getListContainer().scrollLeft = val;
48
48
  }
49
+ get scrollHeight() {
50
+ return this.#getListContainer().scrollHeight;
51
+ }
52
+ get scrollWidth() {
53
+ return this.#getListContainer().scrollWidth;
54
+ }
49
55
  get __scrollTop() {
50
56
  return super.scrollTop;
51
57
  }
@@ -4,7 +4,7 @@ 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 { genDomGetter, registerAttributeHandler, bindToStyle, boostedQueueMicrotask, } from '../../element-reactive/index.js';
7
+ import { genDomGetter, registerAttributeHandler, bindToStyle, } from '../../element-reactive/index.js';
8
8
  let XSwiperIndicator = (() => {
9
9
  let __handleIndicatorColor_decorators;
10
10
  let __handleIndicatorColor_initializers = [];
@@ -102,9 +102,8 @@ let XSwiperIndicator = (() => {
102
102
  }
103
103
  }
104
104
  }).bind(this));
105
- boostedQueueMicrotask(() => {
106
- this.#getIndicatorContainer().children[this.#dom.currentIndex]?.style.setProperty('background-color', 'var(--indicator-active-color)', 'important');
107
- });
105
+ const firstPaintIndex = parseFloat(this.#dom.getAttribute('current') ?? '0');
106
+ this.#getIndicatorContainer().children[firstPaintIndex]?.style.setProperty('background-color', 'var(--indicator-active-color)', 'important');
108
107
  }
109
108
  }
110
109
  dispose() {
@@ -1,4 +1,2 @@
1
1
  export declare const useScrollEnd: boolean;
2
- export declare const isChromium: boolean;
3
- export declare const isWebkit: boolean;
4
2
  export declare const scrollContainerDom: unique symbol;
@@ -3,12 +3,5 @@
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  // safari cannot use scrollend event
5
5
  export const useScrollEnd = 'onscrollend' in document;
6
- const UA = window.navigator.userAgent;
7
- export const isChromium = UA.includes('Chrome');
8
- export const isWebkit = /\b(iPad|iPhone|iPod|OS X)\b/.test(UA)
9
- && !/Edge/.test(UA)
10
- && /WebKit/.test(UA)
11
- // @ts-expect-error
12
- && !window.MSStream;
13
6
  export const scrollContainerDom = Symbol.for('lynx-scroll-container-dom');
14
7
  //# sourceMappingURL=constants.js.map
@@ -1,6 +1,12 @@
1
1
  // Copyright 2024 The Lynx Authors. All rights reserved.
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
+ // --- IMPORTANT SYNCHRONIZATION NOTICE ---
5
+ // The templates defined in this file are mirrored in the pure Rust library `web_elements`.
6
+ // If you modify, add, or remove any template in this file, you MUST ALSO update
7
+ // the corresponding Rust implementation in `src/template.rs` to ensure they
8
+ // remain exactly synchronized. Tests enforce this parity.
9
+ // ----------------------------------------
4
10
  export const templateScrollView = `<style>
5
11
  .placeholder-dom {
6
12
  display: none;
@@ -85,13 +91,13 @@ export const templateScrollView = `<style>
85
91
  part="bot-fade-mask"
86
92
  ></div>`;
87
93
  export const templateXAudioTT = `<audio id="audio"></audio>`;
88
- const XSSDetector = /<\s*script/g;
94
+ const XSSDetector = /<\s*script/;
89
95
  export const templateXImage = (attributes) => {
90
96
  const { src } = attributes;
91
97
  if (src && XSSDetector.test(src)) {
92
98
  throw new Error('detected <script, this is a potential XSS attack, please check your src');
93
99
  }
94
- return `<img part="img" alt="" loading="lazy" id="img" ${src ? `src="${src}"` : ''}/> `;
100
+ return `<img part="img" alt="" id="img" ${src ? `src="${src}"` : ''}/> `;
95
101
  };
96
102
  export const templateFilterImage = templateXImage;
97
103
  export const templateXInput = `<style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-elements",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -127,9 +127,9 @@
127
127
  "**/*.css"
128
128
  ],
129
129
  "devDependencies": {
130
- "@playwright/test": "^1.57.0",
131
- "@rsbuild/core": "1.7.2",
132
- "@rsbuild/plugin-source-build": "1.0.3",
130
+ "@playwright/test": "^1.58.2",
131
+ "@rsbuild/core": "1.7.3",
132
+ "@rsbuild/plugin-source-build": "1.0.4",
133
133
  "nyc": "^17.1.0",
134
134
  "tslib": "^2.8.1",
135
135
  "@lynx-js/playwright-fixtures": "0.0.0"
@@ -28,6 +28,7 @@ x-input::part(input), x-input::part(form) {
28
28
  background-color: inherit;
29
29
  z-index: inherit;
30
30
  margin: inherit;
31
+ padding: inherit;
31
32
  color: inherit;
32
33
  }
33
34