@lynx-js/web-elements 0.7.3 → 0.7.5

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,27 @@
1
1
  # @lynx-js/web-elements
2
2
 
3
+ ## 0.7.5
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: x-input && x-textarea add new method: `getValue`, which returns the value of the input element, selectionStart and selectEnd when success. ([#982](https://github.com/lynx-family/lynx-stack/pull/982))
8
+
9
+ - feat: x-input and x-textarea bindinput event return structures add `selectionStart`, `selectionEnd`, and `textLength`, `textLength` are marked as @deprecated ([#996](https://github.com/lynx-family/lynx-stack/pull/996))
10
+
11
+ - feat: x-input and x-textarea support bindselection event, the returned type structure is `{ selectionStart: number; selectionEnd: number }`. ([#990](https://github.com/lynx-family/lynx-stack/pull/990))
12
+
13
+ - Updated dependencies []:
14
+ - @lynx-js/web-elements-template@0.7.5
15
+
16
+ ## 0.7.4
17
+
18
+ ### Patch Changes
19
+
20
+ - fix: x-foldview-ng `overflow-y: scroll` add !important to avoid being covered. ([#932](https://github.com/lynx-family/lynx-stack/pull/932))
21
+
22
+ - Updated dependencies []:
23
+ - @lynx-js/web-elements-template@0.7.4
24
+
3
25
  ## 0.7.3
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -4,26 +4,25 @@ It provides the custom-element implementation of Lynx Elements in Web.
4
4
 
5
5
  So far, support compared to Lynx Elements on the client:
6
6
 
7
- | Elements | Whether support | Details |
8
- | -------------- | --------------- | ------------------------------------------------------------------------------ |
9
- | Elements | | |
10
- | canvas | | No |
11
- | image | ✅ | Full Support |
12
- | list | ✅ | list-type with single and flow are available, and waterfall is being supported |
13
- | scroll-view | ✅ | Full Support |
14
- | text | ✅ | Full Support |
15
- | view | | Full Support |
16
- | X-Elements | | |
17
- | svg | ✅ | Full Support |
18
- | x-blur-view | ✅ | Full Support |
19
- | x-input | ✅ | Full Support |
20
- | x-textarea | ✅ | Full Support |
21
- | x-swiper | ✅ | Full Support |
22
- | x-viewpager-ng | ✅ | Full Support |
23
- | x-foldview-ng | ✅ | Full Support |
24
- | x-refresh-view | ✅ | Full Support |
25
- | x-overlay-ng | ✅ | Full Support |
26
- | x-audio-tt | ✅ | Full Support |
7
+ | Elements | Whether support | Details |
8
+ | -------------- | --------------- | ------------ |
9
+ | Elements | | |
10
+ | image | | Full Support |
11
+ | list | ✅ | Full Support |
12
+ | scroll-view | ✅ | Full Support |
13
+ | text | ✅ | Full Support |
14
+ | view | ✅ | Full Support |
15
+ | X-Elements | | |
16
+ | svg || Full Support |
17
+ | x-blur-view | ✅ | Full Support |
18
+ | x-input | ✅ | Full Support |
19
+ | x-textarea | ✅ | Full Support |
20
+ | x-swiper | ✅ | Full Support |
21
+ | x-viewpager-ng | ✅ | Full Support |
22
+ | x-foldview-ng | ✅ | Full Support |
23
+ | x-refresh-view | ✅ | Full Support |
24
+ | x-overlay-ng | ✅ | Full Support |
25
+ | x-audio-tt | ✅ | Full Support |
27
26
 
28
27
  ## Usage
29
28
 
@@ -46,16 +46,16 @@ let XFoldviewNgEvents = (() => {
46
46
  get #handleGranularity() { return _private_handleGranularity_descriptor.value; }
47
47
  get #enableOffsetEvent() { return _private_enableOffsetEvent_descriptor.value; }
48
48
  #handleScroll = () => {
49
- const curentScrollTop = this.#dom.scrollTop;
50
- const scrollLength = Math.abs(this.#pervScroll - curentScrollTop);
49
+ const currentScrollTop = this.#dom.scrollTop;
50
+ const scrollLength = Math.abs(this.#pervScroll - currentScrollTop);
51
51
  if (scrollLength > this.#granularity
52
52
  || this.#dom.scrollTop === 0
53
53
  || Math.abs(this.#dom.scrollHeight - this.#dom.clientHeight - this.#dom.scrollTop) <= 1) {
54
- this.#pervScroll = curentScrollTop;
54
+ this.#pervScroll = currentScrollTop;
55
55
  this.#dom.dispatchEvent(new CustomEvent('offset', {
56
56
  ...commonComponentEventSetting,
57
57
  detail: {
58
- offset: curentScrollTop,
58
+ offset: currentScrollTop,
59
59
  height: this.#dom[scrollableLength],
60
60
  },
61
61
  }));
@@ -10,6 +10,11 @@ export declare class XInput extends HTMLElement {
10
10
  value: string;
11
11
  index: number;
12
12
  }): void;
13
+ getValue(): {
14
+ value: string;
15
+ selectionBegin: number | null;
16
+ selectionEnd: number | null;
17
+ };
13
18
  sendDelEvent(params: {
14
19
  action: number;
15
20
  length: number;
@@ -64,6 +64,14 @@ let XInput = (() => {
64
64
  input.setSelectionRange(cursorIndex, cursorIndex);
65
65
  }
66
66
  }
67
+ getValue() {
68
+ const input = this.#getInput();
69
+ return {
70
+ value: input.value,
71
+ selectionBegin: input.selectionStart,
72
+ selectionEnd: input.selectionEnd,
73
+ };
74
+ }
67
75
  sendDelEvent(params) {
68
76
  let { action, length } = params;
69
77
  const input = this.#getInput();
@@ -10,16 +10,19 @@ import { renameEvent } from '../common/renameEvent.js';
10
10
  import { registerEventEnableStatusChangeHandler } from '@lynx-js/web-elements-reactive';
11
11
  let XInputEvents = (() => {
12
12
  let _instanceExtraInitializers = [];
13
- let _private_handleEnableConfirmEvent_decorators;
14
- let _private_handleEnableConfirmEvent_descriptor;
13
+ let _private_handleEnableInputEvent_decorators;
14
+ let _private_handleEnableInputEvent_descriptor;
15
15
  let _private_handleSendComposingInput_decorators;
16
16
  let _private_handleSendComposingInput_descriptor;
17
+ let _private_handleEnableSelectionEvent_decorators;
18
+ let _private_handleEnableSelectionEvent_descriptor;
17
19
  return class XInputEvents {
18
20
  static {
19
21
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
20
- _private_handleEnableConfirmEvent_decorators = [registerEventEnableStatusChangeHandler('input')];
22
+ _private_handleEnableInputEvent_decorators = [registerEventEnableStatusChangeHandler('input')];
21
23
  _private_handleSendComposingInput_decorators = [registerAttributeHandler('send-composing-input', true)];
22
- __esDecorate(this, _private_handleEnableConfirmEvent_descriptor = { value: __setFunctionName(function (status) {
24
+ _private_handleEnableSelectionEvent_decorators = [registerEventEnableStatusChangeHandler('selection')];
25
+ __esDecorate(this, _private_handleEnableInputEvent_descriptor = { value: __setFunctionName(function (status) {
23
26
  const input = this.#getInputElement();
24
27
  if (status) {
25
28
  input.addEventListener('input', this.#teleportInput, { passive: true });
@@ -29,10 +32,20 @@ let XInputEvents = (() => {
29
32
  input.removeEventListener('input', this.#teleportInput);
30
33
  input.removeEventListener('compositionend', this.#teleportCompositionendInput);
31
34
  }
32
- }, "#handleEnableConfirmEvent") }, _private_handleEnableConfirmEvent_decorators, { kind: "method", name: "#handleEnableConfirmEvent", static: false, private: true, access: { has: obj => #handleEnableConfirmEvent in obj, get: obj => obj.#handleEnableConfirmEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
35
+ }, "#handleEnableInputEvent") }, _private_handleEnableInputEvent_decorators, { kind: "method", name: "#handleEnableInputEvent", static: false, private: true, access: { has: obj => #handleEnableInputEvent in obj, get: obj => obj.#handleEnableInputEvent }, metadata: _metadata }, null, _instanceExtraInitializers);
33
36
  __esDecorate(this, _private_handleSendComposingInput_descriptor = { value: __setFunctionName(function (newVal) {
34
37
  this.#sendComposingInput = newVal !== null;
35
38
  }, "#handleSendComposingInput") }, _private_handleSendComposingInput_decorators, { kind: "method", name: "#handleSendComposingInput", static: false, private: true, access: { has: obj => #handleSendComposingInput in obj, get: obj => obj.#handleSendComposingInput }, metadata: _metadata }, null, _instanceExtraInitializers);
39
+ __esDecorate(this, _private_handleEnableSelectionEvent_descriptor = { value: __setFunctionName(function (status) {
40
+ if (status) {
41
+ this.#getInputElement().addEventListener('select', this.#selectEvent, {
42
+ passive: true,
43
+ });
44
+ }
45
+ else {
46
+ this.#getInputElement().removeEventListener('select', this.#selectEvent);
47
+ }
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);
36
49
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
37
50
  }
38
51
  static observedAttributes = ['send-composing-input'];
@@ -40,7 +53,7 @@ let XInputEvents = (() => {
40
53
  #sendComposingInput = false;
41
54
  #getInputElement = genDomGetter(() => this.#dom.shadowRoot, '#input');
42
55
  #getFormElement = genDomGetter(() => this.#dom.shadowRoot, '#form');
43
- get #handleEnableConfirmEvent() { return _private_handleEnableConfirmEvent_descriptor.value; }
56
+ get #handleEnableInputEvent() { return _private_handleEnableInputEvent_descriptor.value; }
44
57
  get #handleSendComposingInput() { return _private_handleSendComposingInput_descriptor.value; }
45
58
  #teleportEvent = (event) => {
46
59
  const eventType = renameEvent[event.type] ?? event.type;
@@ -61,9 +74,13 @@ let XInputEvents = (() => {
61
74
  ...commonComponentEventSetting,
62
75
  detail: {
63
76
  value,
77
+ /** @deprecated */
64
78
  textLength: value.length,
79
+ /** @deprecated */
65
80
  cursor: input.selectionStart,
66
81
  isComposing,
82
+ selectionStart: input.selectionStart,
83
+ selectionEnd: input.selectionEnd,
67
84
  },
68
85
  }));
69
86
  };
@@ -76,12 +93,28 @@ let XInputEvents = (() => {
76
93
  ...commonComponentEventSetting,
77
94
  detail: {
78
95
  value,
96
+ /** @deprecated */
79
97
  textLength: value.length,
98
+ /** @deprecated */
80
99
  cursor: input.selectionStart,
100
+ isComposing: false,
101
+ selectionStart: input.selectionStart,
102
+ selectionEnd: input.selectionEnd,
81
103
  },
82
104
  }));
83
105
  }
84
106
  };
107
+ get #handleEnableSelectionEvent() { return _private_handleEnableSelectionEvent_descriptor.value; }
108
+ #selectEvent = () => {
109
+ const input = this.#getInputElement();
110
+ this.#dom.dispatchEvent(new CustomEvent('selection', {
111
+ ...commonComponentEventSetting,
112
+ detail: {
113
+ selectionStart: input.selectionStart,
114
+ selectionEnd: input.selectionEnd,
115
+ },
116
+ }));
117
+ };
85
118
  #blockHtmlEvent = (event) => {
86
119
  if (event.target === this.#getInputElement()
87
120
  && typeof event.detail === 'number') {
@@ -110,16 +110,16 @@ let XTextTruncation = (() => {
110
110
  this.#dom.removeAttribute(XTextTruncation.exceedMathLengthAttribute);
111
111
  this.#dom.removeAttribute(XTextTruncation.showInlineTruncation);
112
112
  }
113
- #getAllSibilings(targetNode) {
114
- const sibilingNodes = [];
115
- let targetNodeSibiling = targetNode;
116
- while ((targetNodeSibiling = targetNodeSibiling.nextSibling)) {
117
- if (targetNodeSibiling.nodeType === Node.TEXT_NODE
118
- || targetNodeSibiling.nodeType === Node.ELEMENT_NODE) {
119
- sibilingNodes.push(targetNodeSibiling);
113
+ #getAllSiblings(targetNode) {
114
+ const siblingNodes = [];
115
+ let targetNodeSibling = targetNode;
116
+ while ((targetNodeSibling = targetNodeSibling.nextSibling)) {
117
+ if (targetNodeSibling.nodeType === Node.TEXT_NODE
118
+ || targetNodeSibling.nodeType === Node.ELEMENT_NODE) {
119
+ siblingNodes.push(targetNodeSibling);
120
120
  }
121
121
  }
122
- return sibilingNodes;
122
+ return siblingNodes;
123
123
  }
124
124
  #layoutText() {
125
125
  if (!this.#componentConnected || this.#dom.matches('x-text>x-text'))
@@ -208,10 +208,10 @@ let XTextTruncation = (() => {
208
208
  else {
209
209
  toBeHideNodes.push(targetNode);
210
210
  }
211
- toBeHideNodes = toBeHideNodes.concat(this.#getAllSibilings(targetNode));
211
+ toBeHideNodes = toBeHideNodes.concat(this.#getAllSiblings(targetNode));
212
212
  let targetNodeParentElement = targetNode.parentElement;
213
213
  while (targetNodeParentElement !== this.#dom) {
214
- toBeHideNodes = toBeHideNodes.concat(this.#getAllSibilings(targetNodeParentElement));
214
+ toBeHideNodes = toBeHideNodes.concat(this.#getAllSiblings(targetNodeParentElement));
215
215
  targetNodeParentElement = targetNodeParentElement.parentElement;
216
216
  }
217
217
  toBeHideNodes.forEach((node) => {
@@ -450,7 +450,7 @@ class TextRenderingMeasureTool {
450
450
  getLineInfo(lineIndex) {
451
451
  this.#genLinesInfoUntil(lineIndex + 1);
452
452
  if (lineIndex < this.#lazyLinesInfo.length) {
453
- // get catched info first
453
+ // get caught info first
454
454
  const pervLineInfo = lineIndex > 0
455
455
  ? this.#cachedLineInfo[lineIndex - 1] ?? {}
456
456
  : undefined;
@@ -9,6 +9,11 @@ export declare class XTextarea extends HTMLElement {
9
9
  value: string;
10
10
  index: number;
11
11
  }): void;
12
+ getValue(): {
13
+ value: string;
14
+ selectionBegin: number;
15
+ selectionEnd: number;
16
+ };
12
17
  sendDelEvent(params: {
13
18
  action: number;
14
19
  length: number;
@@ -62,6 +62,14 @@ let XTextarea = (() => {
62
62
  input.setSelectionRange(cursorIndex, cursorIndex);
63
63
  }
64
64
  }
65
+ getValue() {
66
+ const input = this.#getTextarea();
67
+ return {
68
+ value: input.value,
69
+ selectionBegin: input.selectionStart,
70
+ selectionEnd: input.selectionEnd,
71
+ };
72
+ }
65
73
  sendDelEvent(params) {
66
74
  let { action, length } = params;
67
75
  const input = this.#getTextarea();
@@ -14,11 +14,14 @@ let XTextareaEvents = (() => {
14
14
  let _private_handleEnableConfirmEvent_descriptor;
15
15
  let _private_handleSendComposingInput_decorators;
16
16
  let _private_handleSendComposingInput_descriptor;
17
+ let _private_handleEnableSelectionEvent_decorators;
18
+ let _private_handleEnableSelectionEvent_descriptor;
17
19
  return class XTextareaEvents {
18
20
  static {
19
21
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
20
22
  _private_handleEnableConfirmEvent_decorators = [registerEventEnableStatusChangeHandler('input')];
21
23
  _private_handleSendComposingInput_decorators = [registerAttributeHandler('send-composing-input', true)];
24
+ _private_handleEnableSelectionEvent_decorators = [registerEventEnableStatusChangeHandler('selection')];
22
25
  __esDecorate(this, _private_handleEnableConfirmEvent_descriptor = { value: __setFunctionName(function (status) {
23
26
  const textareaElement = this.#getTextareaElement();
24
27
  if (status) {
@@ -33,6 +36,16 @@ let XTextareaEvents = (() => {
33
36
  __esDecorate(this, _private_handleSendComposingInput_descriptor = { value: __setFunctionName(function (newVal) {
34
37
  this.#sendComposingInput = newVal !== null;
35
38
  }, "#handleSendComposingInput") }, _private_handleSendComposingInput_decorators, { kind: "method", name: "#handleSendComposingInput", static: false, private: true, access: { has: obj => #handleSendComposingInput in obj, get: obj => obj.#handleSendComposingInput }, metadata: _metadata }, null, _instanceExtraInitializers);
39
+ __esDecorate(this, _private_handleEnableSelectionEvent_descriptor = { value: __setFunctionName(function (status) {
40
+ if (status) {
41
+ this.#getTextareaElement().addEventListener('select', this.#selectEvent, {
42
+ passive: true,
43
+ });
44
+ }
45
+ else {
46
+ this.#getTextareaElement().removeEventListener('select', this.#selectEvent);
47
+ }
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);
36
49
  if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
37
50
  }
38
51
  static observedAttributes = ['send-composing-input'];
@@ -61,9 +74,13 @@ let XTextareaEvents = (() => {
61
74
  ...commonComponentEventSetting,
62
75
  detail: {
63
76
  value,
77
+ /** @deprecated */
64
78
  textLength: value.length,
79
+ /** @deprecated */
65
80
  cursor: input.selectionStart,
66
81
  isComposing,
82
+ selectionStart: input.selectionStart,
83
+ selectionEnd: input.selectionEnd,
67
84
  },
68
85
  }));
69
86
  };
@@ -76,12 +93,28 @@ let XTextareaEvents = (() => {
76
93
  ...commonComponentEventSetting,
77
94
  detail: {
78
95
  value,
96
+ /** @deprecated */
79
97
  textLength: value.length,
98
+ /** @deprecated */
80
99
  cursor: input.selectionStart,
100
+ isComposing: false,
101
+ selectionStart: input.selectionStart,
102
+ selectionEnd: input.selectionEnd,
81
103
  },
82
104
  }));
83
105
  }
84
106
  };
107
+ get #handleEnableSelectionEvent() { return _private_handleEnableSelectionEvent_descriptor.value; }
108
+ #selectEvent = () => {
109
+ const input = this.#getTextareaElement();
110
+ this.#dom.dispatchEvent(new CustomEvent('selection', {
111
+ ...commonComponentEventSetting,
112
+ detail: {
113
+ selectionStart: input.selectionStart,
114
+ selectionEnd: input.selectionEnd,
115
+ },
116
+ }));
117
+ };
85
118
  #blockHtmlEvent = (event) => {
86
119
  if (event.target === this.#getTextareaElement()
87
120
  && typeof event.detail === 'number') {
@@ -40,7 +40,7 @@ let CommonEventsAndMethods = (() => {
40
40
  /**
41
41
  * If this dom is already exposured
42
42
  */
43
- #exposureTriggerd = false;
43
+ #exposureTriggered = false;
44
44
  /**
45
45
  * keeps the observer of current dom
46
46
  */
@@ -158,11 +158,11 @@ let CommonEventsAndMethods = (() => {
158
158
  root = root.parentElement;
159
159
  }
160
160
  }
161
- this.#exposureTriggerd = false;
161
+ this.#exposureTriggered = false;
162
162
  this.#exposureObserver = new IntersectionObserver(([entry]) => {
163
163
  if (entry) {
164
164
  if (entry.isIntersecting) {
165
- this.#exposureTriggerd = true;
165
+ this.#exposureTriggered = true;
166
166
  }
167
167
  this.#sendOneExposureEvent(entry);
168
168
  }
@@ -179,7 +179,7 @@ let CommonEventsAndMethods = (() => {
179
179
  }
180
180
  }
181
181
  #sendOneExposureEvent(entry, overrideExposureId) {
182
- if (!this.#exposureTriggerd) {
182
+ if (!this.#exposureTriggered) {
183
183
  return;
184
184
  }
185
185
  const exposureID = overrideExposureId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-elements",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
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.3"
104
+ "@lynx-js/web-elements-template": "0.7.5"
105
105
  },
106
106
  "devDependencies": {
107
107
  "tslib": "^2.8.1"
@@ -5,7 +5,7 @@
5
5
  */
6
6
  x-foldview-ng {
7
7
  display: flex;
8
- overflow-y: scroll;
8
+ overflow-y: scroll !important;
9
9
  overflow-x: clip;
10
10
  overflow-x: hidden;
11
11
  overscroll-behavior: contain;
@@ -179,7 +179,7 @@ x-text[x-text-clipped][x-text-custom-overflow]::part(inner-box)::after {
179
179
  * 1. without customized inline-truncation
180
180
  * 2. users do not force we apply styles on the ellipsis
181
181
  *
182
- * Overall, we do calculate the layout of texts with (dispaly:block) for
182
+ * Overall, we do calculate the layout of texts with (display:block) for
183
183
  * 1. analyze the truncation length for a customized inline-truncation (attribute x-text-custom-overflow, selector :has())
184
184
  * 2. users explicit declare that we have to put the ellipsis in place. (with attribute tail-color-convert='false')
185
185
  */