@nectary/components 4.11.0 → 4.11.2

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.
@@ -81,6 +81,13 @@ export class ActionMenu extends NectaryElement {
81
81
  top: 0,
82
82
  behavior: 'auto'
83
83
  });
84
+ } else {
85
+ const activeElement = this.#getDeepActiveElement();
86
+ const isTextInput = activeElement !== null && activeElement.tagName === 'INPUT';
87
+ if (!isTextInput) {
88
+ this.focus();
89
+ this.#selectOption(this.#getFirstOption());
90
+ }
84
91
  }
85
92
  };
86
93
  #handleKeydown(e) {
@@ -155,6 +162,13 @@ export class ActionMenu extends NectaryElement {
155
162
  }
156
163
  return this.#getLastOption();
157
164
  }
165
+ #getDeepActiveElement() {
166
+ let activeElement = this.ownerDocument.activeElement;
167
+ while (activeElement !== null && activeElement.shadowRoot !== null && activeElement.shadowRoot.activeElement !== null) {
168
+ activeElement = activeElement.shadowRoot.activeElement;
169
+ }
170
+ return activeElement;
171
+ }
158
172
  #selectOption($option) {
159
173
  const hasRows = this.hasAttribute('rows');
160
174
  for (const $op of this.#getOptionElements()) {
@@ -166,6 +180,15 @@ export class ActionMenu extends NectaryElement {
166
180
  });
167
181
  }
168
182
  }
183
+ if ($option !== null) {
184
+ $option.focus();
185
+ $option.onmouseover = e => {
186
+ if (e.defaultPrevented) {
187
+ return;
188
+ }
189
+ this.#selectOption(null);
190
+ };
191
+ }
169
192
  }
170
193
  #getOptionElements() {
171
194
  return this.#$optionSlot.assignedElements();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nectary/components",
3
- "version": "4.11.0",
3
+ "version": "4.11.2",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
package/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ClassAttributes, DOMAttributes, HTMLAttributes } from 'react'
2
- import type { ReactifyEvents, ReactifyElement, SafeSelect, CamelCaseify, RemoveReadonly, SetAttributes, ExtendEventListeners } from './utils/adapters'
1
+ import type { HTMLAttributes, CSSProperties } from 'react'
2
+ import type { ReactifyEvents, WebComponentReactBaseProp, SafeSelect, CamelCaseify, RemoveReadonly, SetAttributes, ExtendEventListeners } from './utils/adapters'
3
3
 
4
4
  export type TRect = {
5
5
  x: number,
@@ -8,21 +8,24 @@ export type TRect = {
8
8
  height: number,
9
9
  }
10
10
 
11
- export type NectaryComponentVanillaByType<T extends object> =
11
+ export type NectaryComponentVanillaByType<T extends NectaryComponentMap[keyof NectaryComponentMap]> =
12
12
  Omit<HTMLElement, 'addEventListener' | 'removeEventListener'> &
13
13
  ExtendEventListeners<Required<SafeSelect<T, 'events'>>> &
14
14
  SetAttributes<Required<RemoveReadonly<SafeSelect<T, 'props'>>>> &
15
15
  Required<CamelCaseify<SafeSelect<T, 'props'>>> &
16
16
  Required<SafeSelect<T, 'methods'>>
17
17
 
18
- export type NectaryComponentReactByType<T extends object> =
19
- ReactifyElement<HTMLElement> &
18
+ export type NectaryComponentReactByType<T extends NectaryComponentMap[keyof NectaryComponentMap]> =
19
+ WebComponentReactBaseProp<NectaryComponentVanillaByType<T>> &
20
20
  ReactifyEvents<SafeSelect<T, 'events'>> &
21
21
  RemoveReadonly<SafeSelect<T, 'props'>> &
22
- { style?: SafeSelect<T, 'style'> }
22
+ {
23
+ style?: Partial<SafeSelect<T, 'style'>> & CSSProperties;
24
+ }
25
+
23
26
 
24
27
  export type NectaryComponentVanilla<K extends keyof NectaryComponentMap> =
25
28
  NectaryComponentVanillaByType<NectaryComponentMap[K]>
26
29
 
27
30
  export type NectaryComponentReact<K extends keyof NectaryComponentMap> =
28
- NectaryComponentReactByType<NectaryComponentMap[K]>
31
+ NectaryComponentReactByType<NectaryComponentMap[K]>
@@ -1,4 +1,4 @@
1
- import type { ClassAttributes, DOMAttributes, HTMLAttributes } from 'react';
1
+ import type { DetailedHTMLProps, HTMLAttributes } from 'react';
2
2
  export type SafeSelect<T extends object, K extends string | number | symbol> = K extends keyof T ? T[K] extends object ? T[K] : {} : {};
3
3
  type CamelCaseString<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${Lowercase<P1>}${Uppercase<P2>}${CamelCaseString<P3>}` : S;
4
4
  export type CamelCaseify<T> = T extends object ? {
@@ -21,10 +21,10 @@ export type ExtendEventListeners<Events> = {
21
21
  export type SetAttributes<Props> = {
22
22
  setAttribute<K extends keyof Props>(attr: K, value: Props[K] extends boolean ? '' : Props[K]): void;
23
23
  };
24
- export type ReactifyElement<TElement> = Pick<HTMLAttributes<HTMLElement>, 'id' | 'className' | 'style' | 'slot' | 'children'> & ClassAttributes<TElement> & Pick<DOMAttributes<TElement>, 'onClick' | 'onDoubleClick' | 'onMouseDown' | 'onMouseUp' | 'onMouseMove' | 'onMouseOver' | 'onMouseOut' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp' | 'onKeyPress'> & {
25
- class?: string;
26
- };
27
24
  export type ReactifyEvents<T> = {
28
25
  [K in keyof T as K extends string ? `on${K}` : never]: T[K];
29
26
  };
27
+ export type WebComponentReactBaseProp<T = HTMLElement> = Omit<DetailedHTMLProps<HTMLAttributes<T>, T>, 'className' | 'style'> & {
28
+ class?: string;
29
+ };
30
30
  export {};