@lynx-js/web-elements 0.7.5 → 0.7.7
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 +30 -0
- package/dist/XFoldViewNg/XFoldviewHeaderNg.d.ts +1 -0
- package/dist/XFoldViewNg/XFoldviewHeaderNg.js +6 -2
- package/dist/XFoldViewNg/XFoldviewToolbarNg.d.ts +1 -0
- package/dist/XFoldViewNg/XFoldviewToolbarNg.js +6 -2
- package/dist/XInput/XInputEvents.js +18 -10
- package/dist/XList/XList.d.ts +1 -1
- package/dist/XList/XList.js +4 -4
- package/dist/XList/XListAttributes.js +2 -2
- package/dist/XTextarea/XTextareaEvents.js +18 -10
- package/dist/common/getCombinedParentElement.d.ts +1 -0
- package/dist/common/getCombinedParentElement.js +11 -0
- package/package.json +2 -2
- package/src/XCanvas/x-canvas.css +1 -1
- package/src/XText/x-text.css +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @lynx-js/web-elements
|
|
2
2
|
|
|
3
|
+
## 0.7.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix: the param `index` of list scrollToPosition function should be `position`. ([#1135](https://github.com/lynx-family/lynx-stack/pull/1135))
|
|
8
|
+
|
|
9
|
+
- fix: in lynx-view all-on-ui mode, the input event of input and textarea is triggered twice, and the first e.detail is a string, which does not conform to the expected data format. ([#1179](https://github.com/lynx-family/lynx-stack/pull/1179))
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- @lynx-js/web-elements-template@0.7.7
|
|
13
|
+
|
|
14
|
+
## 0.7.6
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- fix: incorrect syntax for x-canvas part ([#1067](https://github.com/lynx-family/lynx-stack/pull/1067))
|
|
19
|
+
|
|
20
|
+
- feat: x-input && x-textarea add attribute input-filter, which can filter input value. ([#1037](https://github.com/lynx-family/lynx-stack/pull/1037))
|
|
21
|
+
|
|
22
|
+
- fix: incorrect top style of x-foldview-slot-ng if the toolbar is wrapped in lynx-wrapper ([#1101](https://github.com/lynx-family/lynx-stack/pull/1101))
|
|
23
|
+
|
|
24
|
+
- perf: add loading="lazy" for image element ([#1056](https://github.com/lynx-family/lynx-stack/pull/1056))
|
|
25
|
+
|
|
26
|
+
https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#loading
|
|
27
|
+
|
|
28
|
+
- fix: --lynx-color will be removed, and if color contains `gradient` it will be processed as transparent. ([#1069](https://github.com/lynx-family/lynx-stack/pull/1069))
|
|
29
|
+
|
|
30
|
+
- Updated dependencies [[`62d1078`](https://github.com/lynx-family/lynx-stack/commit/62d1078e67f2aba216a0d97bf1ad9ece624e498e)]:
|
|
31
|
+
- @lynx-js/web-elements-template@0.7.6
|
|
32
|
+
|
|
3
33
|
## 0.7.5
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -7,6 +7,7 @@ import { __esDecorate, __runInitializers } from "tslib";
|
|
|
7
7
|
import { Component } from '@lynx-js/web-elements-reactive';
|
|
8
8
|
import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
|
|
9
9
|
import { resizeObserver } from './XFoldviewNg.js';
|
|
10
|
+
import { getCombinedDirectParentElement } from '../common/getCombinedParentElement.js';
|
|
10
11
|
let XFoldviewHeaderNg = (() => {
|
|
11
12
|
let _classDecorators = [Component('x-foldview-header-ng', [
|
|
12
13
|
CommonEventsAndMethods,
|
|
@@ -24,11 +25,14 @@ let XFoldviewHeaderNg = (() => {
|
|
|
24
25
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
25
26
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
26
27
|
}
|
|
28
|
+
#parentResizeObserver = undefined;
|
|
27
29
|
connectedCallback() {
|
|
28
|
-
|
|
30
|
+
const parentElement = getCombinedDirectParentElement(this, 'X-FOLDVIEW-NG');
|
|
31
|
+
this.#parentResizeObserver = parentElement?.[resizeObserver];
|
|
32
|
+
this.#parentResizeObserver?.observe(this);
|
|
29
33
|
}
|
|
30
34
|
dispose() {
|
|
31
|
-
this
|
|
35
|
+
this.#parentResizeObserver?.unobserve(this);
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
return XFoldviewHeaderNg = _classThis;
|
|
@@ -7,6 +7,7 @@ import { __esDecorate, __runInitializers } from "tslib";
|
|
|
7
7
|
import { Component } from '@lynx-js/web-elements-reactive';
|
|
8
8
|
import { CommonEventsAndMethods } from '../common/CommonEventsAndMethods.js';
|
|
9
9
|
import { resizeObserver } from './XFoldviewNg.js';
|
|
10
|
+
import { getCombinedDirectParentElement } from '../common/getCombinedParentElement.js';
|
|
10
11
|
let XFoldviewToolbarNg = (() => {
|
|
11
12
|
let _classDecorators = [Component('x-foldview-toolbar-ng', [
|
|
12
13
|
CommonEventsAndMethods,
|
|
@@ -24,11 +25,14 @@ let XFoldviewToolbarNg = (() => {
|
|
|
24
25
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
25
26
|
__runInitializers(_classThis, _classExtraInitializers);
|
|
26
27
|
}
|
|
28
|
+
#parentResizeObserver = undefined;
|
|
27
29
|
connectedCallback() {
|
|
28
|
-
|
|
30
|
+
const parentElement = getCombinedDirectParentElement(this, 'X-FOLDVIEW-NG');
|
|
31
|
+
this.#parentResizeObserver = parentElement?.[resizeObserver];
|
|
32
|
+
this.#parentResizeObserver?.observe(this);
|
|
29
33
|
}
|
|
30
34
|
dispose() {
|
|
31
|
-
this
|
|
35
|
+
this.#parentResizeObserver?.unobserve(this);
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
return XFoldviewToolbarNg = _classThis;
|
|
@@ -19,7 +19,7 @@ let XInputEvents = (() => {
|
|
|
19
19
|
return class XInputEvents {
|
|
20
20
|
static {
|
|
21
21
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
22
|
-
_private_handleEnableInputEvent_decorators = [
|
|
22
|
+
_private_handleEnableInputEvent_decorators = [registerAttributeHandler('input-filter', true), registerEventEnableStatusChangeHandler('lynxinput')];
|
|
23
23
|
_private_handleSendComposingInput_decorators = [registerAttributeHandler('send-composing-input', true)];
|
|
24
24
|
_private_handleEnableSelectionEvent_decorators = [registerEventEnableStatusChangeHandler('selection')];
|
|
25
25
|
__esDecorate(this, _private_handleEnableInputEvent_descriptor = { value: __setFunctionName(function (status) {
|
|
@@ -48,7 +48,7 @@ let XInputEvents = (() => {
|
|
|
48
48
|
}, "#handleEnableSelectionEvent") }, _private_handleEnableSelectionEvent_decorators, { kind: "method", name: "#handleEnableSelectionEvent", static: false, private: true, access: { has: obj => #handleEnableSelectionEvent in obj, get: obj => obj.#handleEnableSelectionEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
49
49
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
50
50
|
}
|
|
51
|
-
static observedAttributes = ['send-composing-input'];
|
|
51
|
+
static observedAttributes = ['send-composing-input', 'input-filter'];
|
|
52
52
|
#dom = __runInitializers(this, _instanceExtraInitializers);
|
|
53
53
|
#sendComposingInput = false;
|
|
54
54
|
#getInputElement = genDomGetter(() => this.#dom.shadowRoot, '#input');
|
|
@@ -66,16 +66,20 @@ let XInputEvents = (() => {
|
|
|
66
66
|
};
|
|
67
67
|
#teleportInput = (event) => {
|
|
68
68
|
const input = this.#getInputElement();
|
|
69
|
-
const
|
|
69
|
+
const inputFilter = this.#dom.getAttribute('input-filter');
|
|
70
|
+
const filterValue = inputFilter
|
|
71
|
+
? input.value.replace(new RegExp(inputFilter, 'g'), '')
|
|
72
|
+
: input.value;
|
|
70
73
|
const isComposing = event.isComposing;
|
|
74
|
+
input.value = filterValue;
|
|
71
75
|
if (isComposing && !this.#sendComposingInput)
|
|
72
76
|
return;
|
|
73
|
-
this.#dom.dispatchEvent(new CustomEvent('
|
|
77
|
+
this.#dom.dispatchEvent(new CustomEvent('lynxinput', {
|
|
74
78
|
...commonComponentEventSetting,
|
|
75
79
|
detail: {
|
|
76
|
-
value,
|
|
80
|
+
value: filterValue,
|
|
77
81
|
/** @deprecated */
|
|
78
|
-
textLength:
|
|
82
|
+
textLength: filterValue.length,
|
|
79
83
|
/** @deprecated */
|
|
80
84
|
cursor: input.selectionStart,
|
|
81
85
|
isComposing,
|
|
@@ -86,15 +90,19 @@ let XInputEvents = (() => {
|
|
|
86
90
|
};
|
|
87
91
|
#teleportCompositionendInput = () => {
|
|
88
92
|
const input = this.#getInputElement();
|
|
89
|
-
const
|
|
93
|
+
const inputFilter = this.#dom.getAttribute('input-filter');
|
|
94
|
+
const filterValue = inputFilter
|
|
95
|
+
? input.value.replace(new RegExp(inputFilter, 'g'), '')
|
|
96
|
+
: input.value;
|
|
97
|
+
input.value = filterValue;
|
|
90
98
|
// if #sendComposingInput set true, #teleportInput will send detail
|
|
91
99
|
if (!this.#sendComposingInput) {
|
|
92
|
-
this.#dom.dispatchEvent(new CustomEvent('
|
|
100
|
+
this.#dom.dispatchEvent(new CustomEvent('lynxinput', {
|
|
93
101
|
...commonComponentEventSetting,
|
|
94
102
|
detail: {
|
|
95
|
-
value,
|
|
103
|
+
value: filterValue,
|
|
96
104
|
/** @deprecated */
|
|
97
|
-
textLength:
|
|
105
|
+
textLength: filterValue.length,
|
|
98
106
|
/** @deprecated */
|
|
99
107
|
cursor: input.selectionStart,
|
|
100
108
|
isComposing: false,
|
package/dist/XList/XList.d.ts
CHANGED
package/dist/XList/XList.js
CHANGED
|
@@ -61,13 +61,13 @@ let XList = (() => {
|
|
|
61
61
|
else if (typeof params.offset === 'number') {
|
|
62
62
|
offset = { left: params.offset, top: params.offset };
|
|
63
63
|
}
|
|
64
|
-
if (typeof params.
|
|
65
|
-
if (params.
|
|
64
|
+
if (typeof params.position === 'number') {
|
|
65
|
+
if (params.position === 0) {
|
|
66
66
|
this.#getListContainer().scrollTop = 0;
|
|
67
67
|
this.#getListContainer().scrollLeft = 0;
|
|
68
68
|
}
|
|
69
|
-
else if (params.
|
|
70
|
-
const targetKid = this.children.item(params.
|
|
69
|
+
else if (params.position > 0 && params.position < this.childElementCount) {
|
|
70
|
+
const targetKid = this.children.item(params.position);
|
|
71
71
|
if (targetKid instanceof HTMLElement) {
|
|
72
72
|
if (offset) {
|
|
73
73
|
offset = {
|
|
@@ -37,7 +37,7 @@ let XListAttributes = (() => {
|
|
|
37
37
|
connectedCallback() {
|
|
38
38
|
const initialScrollIndex = this.#dom.getAttribute('initial-scroll-index');
|
|
39
39
|
if (initialScrollIndex !== null) {
|
|
40
|
-
const
|
|
40
|
+
const position = parseFloat(initialScrollIndex);
|
|
41
41
|
const scrollToInitialIndex = () => {
|
|
42
42
|
if (this.#dom.clientHeight === 0) {
|
|
43
43
|
// In Safari, there is the potential race condition between the browser's layout and clientWidth calculate.
|
|
@@ -45,7 +45,7 @@ let XListAttributes = (() => {
|
|
|
45
45
|
requestAnimationFrame(scrollToInitialIndex);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
this.#dom.scrollToPosition({
|
|
48
|
+
this.#dom.scrollToPosition({ position });
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
// The reason for using microtasks is that the width and height of the child element may not be rendered at this time, so it will not be able to scroll.
|
|
@@ -19,7 +19,7 @@ let XTextareaEvents = (() => {
|
|
|
19
19
|
return class XTextareaEvents {
|
|
20
20
|
static {
|
|
21
21
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
22
|
-
_private_handleEnableConfirmEvent_decorators = [
|
|
22
|
+
_private_handleEnableConfirmEvent_decorators = [registerAttributeHandler('input-filter', true), registerEventEnableStatusChangeHandler('lynxinput')];
|
|
23
23
|
_private_handleSendComposingInput_decorators = [registerAttributeHandler('send-composing-input', true)];
|
|
24
24
|
_private_handleEnableSelectionEvent_decorators = [registerEventEnableStatusChangeHandler('selection')];
|
|
25
25
|
__esDecorate(this, _private_handleEnableConfirmEvent_descriptor = { value: __setFunctionName(function (status) {
|
|
@@ -48,7 +48,7 @@ let XTextareaEvents = (() => {
|
|
|
48
48
|
}, "#handleEnableSelectionEvent") }, _private_handleEnableSelectionEvent_decorators, { kind: "method", name: "#handleEnableSelectionEvent", static: false, private: true, access: { has: obj => #handleEnableSelectionEvent in obj, get: obj => obj.#handleEnableSelectionEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
49
49
|
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
50
50
|
}
|
|
51
|
-
static observedAttributes = ['send-composing-input'];
|
|
51
|
+
static observedAttributes = ['send-composing-input', 'input-filter'];
|
|
52
52
|
#dom = __runInitializers(this, _instanceExtraInitializers);
|
|
53
53
|
#sendComposingInput = false;
|
|
54
54
|
#getTextareaElement = genDomGetter(() => this.#dom.shadowRoot, '#textarea');
|
|
@@ -66,16 +66,20 @@ let XTextareaEvents = (() => {
|
|
|
66
66
|
};
|
|
67
67
|
#teleportInput = (event) => {
|
|
68
68
|
const input = this.#getTextareaElement();
|
|
69
|
-
const
|
|
69
|
+
const inputFilter = this.#dom.getAttribute('input-filter');
|
|
70
|
+
const filterValue = inputFilter
|
|
71
|
+
? input.value.replace(new RegExp(inputFilter, 'g'), '')
|
|
72
|
+
: input.value;
|
|
70
73
|
const isComposing = event.isComposing;
|
|
74
|
+
input.value = filterValue;
|
|
71
75
|
if (isComposing && !this.#sendComposingInput)
|
|
72
76
|
return;
|
|
73
|
-
this.#dom.dispatchEvent(new CustomEvent('
|
|
77
|
+
this.#dom.dispatchEvent(new CustomEvent('lynxinput', {
|
|
74
78
|
...commonComponentEventSetting,
|
|
75
79
|
detail: {
|
|
76
|
-
value,
|
|
80
|
+
value: filterValue,
|
|
77
81
|
/** @deprecated */
|
|
78
|
-
textLength:
|
|
82
|
+
textLength: filterValue.length,
|
|
79
83
|
/** @deprecated */
|
|
80
84
|
cursor: input.selectionStart,
|
|
81
85
|
isComposing,
|
|
@@ -86,15 +90,19 @@ let XTextareaEvents = (() => {
|
|
|
86
90
|
};
|
|
87
91
|
#teleportCompositionendInput = () => {
|
|
88
92
|
const input = this.#getTextareaElement();
|
|
89
|
-
const
|
|
93
|
+
const inputFilter = this.#dom.getAttribute('input-filter');
|
|
94
|
+
const filterValue = inputFilter
|
|
95
|
+
? input.value.replace(new RegExp(inputFilter, 'g'), '')
|
|
96
|
+
: input.value;
|
|
97
|
+
input.value = filterValue;
|
|
90
98
|
// if #sendComposingInput set true, #teleportInput will send detail
|
|
91
99
|
if (!this.#sendComposingInput) {
|
|
92
|
-
this.#dom.dispatchEvent(new CustomEvent('
|
|
100
|
+
this.#dom.dispatchEvent(new CustomEvent('lynxinput', {
|
|
93
101
|
...commonComponentEventSetting,
|
|
94
102
|
detail: {
|
|
95
|
-
value,
|
|
103
|
+
value: filterValue,
|
|
96
104
|
/** @deprecated */
|
|
97
|
-
textLength:
|
|
105
|
+
textLength: filterValue.length,
|
|
98
106
|
/** @deprecated */
|
|
99
107
|
cursor: input.selectionStart,
|
|
100
108
|
isComposing: false,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCombinedDirectParentElement: <T extends HTMLElement>(element: HTMLElement, parentTagName: string) => T | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const getCombinedDirectParentElement = (element, parentTagName) => {
|
|
2
|
+
let parentElement = element.parentElement;
|
|
3
|
+
if (parentElement?.tagName === 'LYNX-WRAPPER') {
|
|
4
|
+
parentElement = parentElement.parentElement;
|
|
5
|
+
}
|
|
6
|
+
if (parentElement?.tagName === parentTagName) {
|
|
7
|
+
return parentElement;
|
|
8
|
+
}
|
|
9
|
+
return;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=getCombinedParentElement.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-elements",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7",
|
|
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": "0.2.2",
|
|
104
|
-
"@lynx-js/web-elements-template": "0.7.
|
|
104
|
+
"@lynx-js/web-elements-template": "0.7.7"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"tslib": "^2.8.1"
|
package/src/XCanvas/x-canvas.css
CHANGED
package/src/XText/x-text.css
CHANGED
|
@@ -8,11 +8,15 @@ x-text {
|
|
|
8
8
|
display: flex;
|
|
9
9
|
overflow-wrap: break-word;
|
|
10
10
|
align-items: stretch;
|
|
11
|
-
color: var(--lynx-color);
|
|
12
11
|
background-image: var(--lynx-text-bg-color);
|
|
12
|
+
color: initial;
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
x-text > x-text, x-text > lynx-wrapper > x-text {
|
|
16
|
+
color: inherit;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
x-text:not(x-text > x-text):not(x-text > lynx-wrapper > x-text) {
|
|
15
|
-
--lynx-color: canvastext;
|
|
16
20
|
--lynx-text-bg-color: initial;
|
|
17
21
|
}
|
|
18
22
|
|