@iyulab/components 2.1.0 → 2.2.0

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,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.2.0] - 2026-10-06
4
+
5
+ ### Added
6
+
7
+ - **`isTextEntry(target)`** — whether a key or clipboard event came from a text field (a text-like
8
+ `<input>`, a `<textarea>`, editable content), which keeps its own clipboard. Pairs with
9
+ `copyFromKey`/`pasteFromKey`: a grid skips its copy key in the cell editor, but not while a row
10
+ checkbox has focus.
11
+
3
12
  ## [2.1.0] - 2026-10-06
4
13
 
5
14
  ### Added
package/dist/index.js CHANGED
@@ -59,9 +59,9 @@ import { UTextarea } from "./components/textarea/UTextarea.js";
59
59
  import { UTreeItem } from "./components/tree-item/UTreeItem.js";
60
60
  import { UTree } from "./components/tree/UTree.js";
61
61
  import { BrowserStorage } from "./utilities/BrowserStorage.js";
62
- import { copyFromKey, pasteFromKey } from "./utilities/clipboard.js";
62
+ import { copyFromKey, isTextEntry, pasteFromKey } from "./utilities/clipboard.js";
63
63
  import { Dialog } from "./utilities/Dialog.js";
64
64
  import { Theme } from "./utilities/Theme.js";
65
65
  import { Toast } from "./utilities/Toast.js";
66
66
  import { decodeTsv, encodeTsv } from "./utilities/tsv.js";
67
- export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USteps, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, copyFromKey, createDevWarner, dateAttrConverter, dateTextPattern, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isImeComposing, jsonAttrConverter, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, pasteFromKey, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
67
+ export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USteps, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, copyFromKey, createDevWarner, dateAttrConverter, dateTextPattern, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isImeComposing, isTextEntry, jsonAttrConverter, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, pasteFromKey, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
@@ -34,3 +34,10 @@ export declare function copyFromKey(text: string): Promise<boolean>;
34
34
  * none comes, from the Clipboard API. Rejects with the Clipboard API's error when neither gives text.
35
35
  */
36
36
  export declare function pasteFromKey(): Promise<string>;
37
+ /**
38
+ * Whether `target` is a text field — a text-like `<input>`, a `<textarea>`, or editable content. A
39
+ * text field keeps its own clipboard: pass `event.composedPath()[0]` and skip `copyFromKey` /
40
+ * `pasteFromKey` when this is true. A checkbox or a button is not a text field — a grid's copy key
41
+ * still applies while one of its row checkboxes has focus.
42
+ */
43
+ export declare function isTextEntry(target: EventTarget | null | undefined): boolean;
@@ -83,5 +83,29 @@ function pasteFromKey() {
83
83
  });
84
84
  });
85
85
  }
86
+ /** `<input>` types that hold no text a person selects and copies. */
87
+ var NON_TEXT_INPUTS = /* @__PURE__ */ new Set([
88
+ "checkbox",
89
+ "radio",
90
+ "button",
91
+ "submit",
92
+ "reset",
93
+ "range",
94
+ "color",
95
+ "file",
96
+ "image",
97
+ "hidden"
98
+ ]);
99
+ /**
100
+ * Whether `target` is a text field — a text-like `<input>`, a `<textarea>`, or editable content. A
101
+ * text field keeps its own clipboard: pass `event.composedPath()[0]` and skip `copyFromKey` /
102
+ * `pasteFromKey` when this is true. A checkbox or a button is not a text field — a grid's copy key
103
+ * still applies while one of its row checkboxes has focus.
104
+ */
105
+ function isTextEntry(target) {
106
+ if (target instanceof HTMLTextAreaElement) return true;
107
+ if (target instanceof HTMLInputElement) return !NON_TEXT_INPUTS.has(target.type);
108
+ return target instanceof HTMLElement && target.isContentEditable;
109
+ }
86
110
  //#endregion
87
- export { copyFromKey, pasteFromKey };
111
+ export { copyFromKey, isTextEntry, pasteFromKey };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iyulab/components",
3
3
  "description": "web-components library based on lit-element made by iyulab",
4
- "version": "2.1.0",
4
+ "version": "2.2.0",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -135,7 +135,7 @@ carries the control's role, not on the host element. Native nodes use native `di
135
135
  - [`Locale`](./references/utilities/locale.md) — Validation-message locale registry and lookup utility
136
136
  - [`elements`](./references/utilities/elements.md) — Shadow-DOM-aware DOM query helpers
137
137
  - [`format`](./references/utilities/format.md) — Locale-aware number, currency and date formatting
138
- - [`clipboard`](./references/utilities/clipboard.md) — `copyFromKey` / `pasteFromKey`, Ctrl/Cmd + C · X · V for a grid or list selection in every browser (Safari fires no copy event without a text selection)
138
+ - [`clipboard`](./references/utilities/clipboard.md) — `copyFromKey` / `pasteFromKey` / `isTextEntry`, Ctrl/Cmd + C · X · V for a grid or list selection in every browser (Safari fires no copy event without a text selection)
139
139
  - [`keyboard`](./references/utilities/keyboard.md) — `isImeComposing` for Enter handlers that must not fire mid-composition (Korean/Japanese/Chinese input)
140
140
  - [`tsv`](./references/utilities/tsv.md) — `encodeTsv` / `decodeTsv`, the spreadsheet clipboard format with RFC 4180 quoting
141
141
  - [`OverlayManager`](./references/utilities/overlay-manager.md) — Internal overlay stack and z-index manager
@@ -1,8 +1,8 @@
1
1
  # clipboard
2
2
 
3
3
  ```ts
4
- import { copyFromKey, pasteFromKey } from '@iyulab/components';
5
- // or: import { copyFromKey, pasteFromKey } from '@iyulab/components/dist/utilities/clipboard.js';
4
+ import { copyFromKey, pasteFromKey, isTextEntry } from '@iyulab/components';
5
+ // or: import { copyFromKey, pasteFromKey, isTextEntry } from '@iyulab/components/dist/utilities/clipboard.js';
6
6
  ```
7
7
 
8
8
  Copy and paste for a keyboard shortcut on something that is not a text field — a grid's selected
@@ -30,9 +30,16 @@ cut clears its selection only on `true` — otherwise the data is gone without b
30
30
  Reads the clipboard text — from the paste event, or, when none comes, from `navigator.clipboard.readText()`.
31
31
  Rejects with the Clipboard API's error when neither gives text.
32
32
 
33
+ ## `isTextEntry(target): boolean`
34
+
35
+ Whether `target` is a text field — a text-like `<input>`, a `<textarea>`, or editable content. A text
36
+ field keeps its own clipboard: pass `event.composedPath()[0]` and leave the key alone when this is
37
+ true. A checkbox or a button is not one, so the grid's copy still applies while a row checkbox has
38
+ focus.
39
+
33
40
  ```ts
34
41
  onKeydown(e: KeyboardEvent) {
35
- if (!(e.ctrlKey || e.metaKey) || this.editing) return; // a text field keeps its own clipboard
42
+ if (!(e.ctrlKey || e.metaKey) || isTextEntry(e.composedPath()[0])) return;
36
43
  const key = e.key.toLowerCase();
37
44
  if (key === 'c' || key === 'x') {
38
45
  const range = this.selection;