@necto-react/types 2.3.0 → 2.4.1

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/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var s=(o,e,m,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let p of x(e))!y.call(o,p)&&p!==m&&r(o,p,{get:()=>e[p],enumerable:!(t=f(e,p))||t.enumerable});return o};var n=o=>s(r({},"__esModule",{value:!0}),o);var c={};module.exports=n(c);
@@ -0,0 +1,286 @@
1
+ import { AriaAttributes, DOMAttributes as DOMAttributes$1, AriaRole, CSSProperties, HTMLAttributeAnchorTarget, HTMLAttributeReferrerPolicy, ReactNode, SyntheticEvent, FocusEvent, ForwardedRef } from 'react';
2
+
3
+ /**
4
+ * Copyright (c) Corinvo, LLC. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ */
10
+
11
+
12
+
13
+ /**
14
+ * Props for DOM elements that may require an id.
15
+ */
16
+ interface DOMProps {
17
+ /** The unique id for the DOM element. */
18
+ id?: string | undefined;
19
+ }
20
+
21
+ /**
22
+ * Props for focusable DOM elements, extending basic DOM props.
23
+ */
24
+ interface FocusableDOMProps extends DOMProps {
25
+ /**
26
+ * Whether the element should be excluded from the tab order.
27
+ */
28
+ excludeFromTabOrder?: boolean;
29
+ }
30
+
31
+ /**
32
+ * Standard DOM attributes for focusable elements, including ARIA and React DOM attributes.
33
+ *
34
+ * @template T The element type, defaults to FocusableElement.
35
+ */
36
+ interface DOMAttributes<T = FocusableElement>
37
+ extends AriaAttributes,
38
+ DOMAttributes$1<T> {
39
+ /** The unique id for the DOM element. */
40
+ id?: string | undefined;
41
+
42
+ /** The ARIA role for the element. */
43
+ role?: AriaRole | undefined;
44
+
45
+ /** The tab index of the element. */
46
+ tabIndex?: number | undefined;
47
+
48
+ /** Inline CSS styles for the element. */
49
+ style?: CSSProperties | undefined;
50
+
51
+ /** The CSS class name for the element. */
52
+ className?: string | undefined;
53
+ }
54
+
55
+ /**
56
+ * Props for anchor/link elements.
57
+ */
58
+ interface LinkDOMProps {
59
+ /** The URL to link to. */
60
+ href?: string | undefined;
61
+
62
+ /** The language of the linked resource. */
63
+ hrefLang?: string;
64
+
65
+ /** The browsing context for the link. */
66
+ target?: HTMLAttributeAnchorTarget;
67
+
68
+ /** The relationship of the linked resource. */
69
+ rel?: string;
70
+
71
+ /** Prompts the user to save the linked URL instead of navigating to it. */
72
+ download?: boolean | string;
73
+
74
+ /** Space-separated list of URLs to notify when the user follows the hyperlink. */
75
+ ping?: string;
76
+
77
+ /** Referrer policy for the link. */
78
+ referrerPolicy?: HTMLAttributeReferrerPolicy;
79
+
80
+ /** Additional router options (type depends on router implementation). */
81
+ routerOptions?: unknown;
82
+ }
83
+
84
+ /**
85
+ * Copyright (c) Corinvo, LLC. and affiliates.
86
+ *
87
+ * This source code is licensed under the MIT license found in the
88
+ * LICENSE file in the root directory of this source tree.
89
+ *
90
+ */
91
+
92
+
93
+
94
+ interface StyleRenderProps<T> {
95
+ /** The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. */
96
+ className?:
97
+ | string
98
+ | ((values: T & { defaultClassName: string | undefined }) => string);
99
+
100
+ /** The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. */
101
+ style?:
102
+ | CSSProperties
103
+ | ((
104
+ values: T & { defaultStyle: CSSProperties }
105
+ ) => CSSProperties | undefined);
106
+ }
107
+
108
+ interface RenderProps<T> extends StyleRenderProps<T> {
109
+ /** The children of the component. A function may be provided to alter the children based on component state. */
110
+ children?:
111
+ | ReactNode
112
+ | ((values: T | { defaultChildren: ReactNode | undefined }) => ReactNode);
113
+ }
114
+
115
+ /**
116
+ * Copyright (c) Corinvo, LLC. and affiliates.
117
+ *
118
+ * This source code is licensed under the MIT license found in the
119
+ * LICENSE file in the root directory of this source tree.
120
+ *
121
+ */
122
+
123
+ /**
124
+ * Flags indicating disabled states for different interaction types.
125
+ */
126
+ type DisabledFlags = {
127
+ /** Whether the element is generally disabled. */
128
+ general?: boolean;
129
+
130
+ /** Whether the element is disabled for form interactions. */
131
+ form?: boolean;
132
+
133
+ /** Whether the element is disabled for user interactions (e.g., pointer, keyboard). */
134
+ interactions?: boolean;
135
+
136
+ /** Custom disabled flags for additional types of interactions. */
137
+ [key: string]: boolean | undefined;
138
+ };
139
+
140
+ /**
141
+ * Copyright (c) Corinvo, LLC. and affiliates.
142
+ *
143
+ * This source code is licensed under the MIT license found in the
144
+ * LICENSE file in the root directory of this source tree.
145
+ *
146
+ */
147
+
148
+
149
+
150
+ /**
151
+ * Extended SyntheticEvent with custom propagation control methods.
152
+ *
153
+ * @template T The type of the original SyntheticEvent.
154
+ */
155
+ type BaseEvent<T extends SyntheticEvent> = T & {
156
+ /**
157
+ * Use continuePropagation instead.
158
+ * @deprecated
159
+ */
160
+ stopPropagation(): void;
161
+
162
+ /**
163
+ * Continues propagation for the event.
164
+ */
165
+ continuePropagation(): void;
166
+ };
167
+
168
+ /**
169
+ * Event handlers for hover interactions.
170
+ */
171
+ interface HoverEvent {
172
+ /** Called when a hover interaction starts. */
173
+ onHoverStart?: (event: HoverEvent) => void;
174
+
175
+ /** Called when a hover interaction ends. */
176
+ onHoverEnd?: (event: HoverEvent) => void;
177
+
178
+ /** Called when the hover state changes. */
179
+ onHoverChange?: (isHovering: boolean) => void;
180
+ }
181
+
182
+ /**
183
+ * Event handlers for focus interactions.
184
+ */
185
+ interface FocusEvents<Target = Element> {
186
+ /** Called when the element receives focus. */
187
+ onFocus?: (e: FocusEvent<Target>) => void;
188
+
189
+ /** Called when the element loses focus. */
190
+ onBlur?: (e: FocusEvent<Target>) => void;
191
+
192
+ /** Called when the focus state changes. */
193
+ onFocusChange?: (isFocused: boolean) => void;
194
+ }
195
+
196
+ /**
197
+ * Event handlers for keyboard interactions.
198
+ */
199
+ interface KeyboardEvents {
200
+ /** Called when a key is pressed down. */
201
+ onKeyDown?: (e: KeyboardEvent) => void;
202
+
203
+ /** Called when a key is released. */
204
+ onKeyUp?: (e: KeyboardEvent) => void;
205
+ }
206
+
207
+ /**
208
+ * Copyright (c) Corinvo, LLC. and affiliates.
209
+ *
210
+ * This source code is licensed under the MIT license found in the
211
+ * LICENSE file in the root directory of this source tree.
212
+ *
213
+ */
214
+
215
+
216
+
217
+ type SlottedContextValue<T, E = never> =
218
+ | (T & {
219
+ slots?: Record<string | symbol, T>;
220
+ ref?: E extends never ? never : ForwardedRef<E>;
221
+ })
222
+ | null
223
+ | undefined;
224
+
225
+ /**
226
+ * Copyright (c) Corinvo, LLC. and affiliates.
227
+ *
228
+ * This source code is licensed under the MIT license found in the
229
+ * LICENSE file in the root directory of this source tree.
230
+ *
231
+ */
232
+
233
+ /** Selection mode for a collection. */
234
+ type SelectionMode = 'none' | 'single' | 'multiple';
235
+
236
+ /** Focus strategy when auto-focusing. */
237
+ type FocusStrategy = 'first' | 'last';
238
+
239
+ /**
240
+ * Interface for managing selection state in a collection.
241
+ */
242
+ interface SelectionManager {
243
+ /** The currently focused key. */
244
+ readonly focusedKey: (string | number) | null;
245
+ /** Set the focused key. */
246
+ setFocusedKey(
247
+ key: (string | number) | null,
248
+ childFocus?: FocusStrategy
249
+ ): void;
250
+ /** Whether the collection is focused. */
251
+ readonly isFocused: boolean;
252
+ /** Set whether the collection is focused. */
253
+ setFocused(isFocused: boolean): void;
254
+ /** The set of selected keys. */
255
+ readonly selectedKeys: Set<string | number>;
256
+ /** The selection mode. */
257
+ readonly selectionMode: SelectionMode;
258
+ /** Replace selection with a single key. */
259
+ replaceSelection(key: string | number): void;
260
+ /** Extend selection to include a key. */
261
+ extendSelection(key: string | number): void;
262
+ /** Toggle selection of a key. */
263
+ toggleSelection(key: string | number): void;
264
+ /** Select all items. */
265
+ selectAll(): void;
266
+ /** Clear all selection. */
267
+ clearSelection(): void;
268
+ /** Check if a key is selected. */
269
+ isSelected(key: string | number): boolean;
270
+ /** Check if a key is disabled. */
271
+ isDisabled?(key: string | number): boolean;
272
+ /** Check if a key is a link. */
273
+ isLink?(key: string | number): boolean;
274
+ /** Get props for an item. */
275
+ getItemProps?(
276
+ key: string | number
277
+ ): { href?: string; routerOptions?: unknown } | undefined;
278
+ /** Whether the user can select an item. */
279
+ canSelectItem?(key: string | number): boolean;
280
+ /** The first selected key. */
281
+ readonly firstSelectedKey?: (string | number) | null;
282
+ /** The last selected key. */
283
+ readonly lastSelectedKey?: (string | number) | null;
284
+ }
285
+
286
+ export type { BaseEvent, DOMAttributes, DOMProps, DisabledFlags, FocusEvents, FocusStrategy, FocusableDOMProps, HoverEvent, KeyboardEvents, LinkDOMProps, RenderProps, SelectionManager, SelectionMode, SlottedContextValue, StyleRenderProps };
package/dist/index.d.mts CHANGED
@@ -222,4 +222,65 @@ type SlottedContextValue<T, E = never> =
222
222
  | null
223
223
  | undefined;
224
224
 
225
- export type { BaseEvent, DOMAttributes, DOMProps, DisabledFlags, FocusEvents, FocusableDOMProps, HoverEvent, KeyboardEvents, LinkDOMProps, RenderProps, SlottedContextValue, StyleRenderProps };
225
+ /**
226
+ * Copyright (c) Corinvo, LLC. and affiliates.
227
+ *
228
+ * This source code is licensed under the MIT license found in the
229
+ * LICENSE file in the root directory of this source tree.
230
+ *
231
+ */
232
+
233
+ /** Selection mode for a collection. */
234
+ type SelectionMode = 'none' | 'single' | 'multiple';
235
+
236
+ /** Focus strategy when auto-focusing. */
237
+ type FocusStrategy = 'first' | 'last';
238
+
239
+ /**
240
+ * Interface for managing selection state in a collection.
241
+ */
242
+ interface SelectionManager {
243
+ /** The currently focused key. */
244
+ readonly focusedKey: (string | number) | null;
245
+ /** Set the focused key. */
246
+ setFocusedKey(
247
+ key: (string | number) | null,
248
+ childFocus?: FocusStrategy
249
+ ): void;
250
+ /** Whether the collection is focused. */
251
+ readonly isFocused: boolean;
252
+ /** Set whether the collection is focused. */
253
+ setFocused(isFocused: boolean): void;
254
+ /** The set of selected keys. */
255
+ readonly selectedKeys: Set<string | number>;
256
+ /** The selection mode. */
257
+ readonly selectionMode: SelectionMode;
258
+ /** Replace selection with a single key. */
259
+ replaceSelection(key: string | number): void;
260
+ /** Extend selection to include a key. */
261
+ extendSelection(key: string | number): void;
262
+ /** Toggle selection of a key. */
263
+ toggleSelection(key: string | number): void;
264
+ /** Select all items. */
265
+ selectAll(): void;
266
+ /** Clear all selection. */
267
+ clearSelection(): void;
268
+ /** Check if a key is selected. */
269
+ isSelected(key: string | number): boolean;
270
+ /** Check if a key is disabled. */
271
+ isDisabled?(key: string | number): boolean;
272
+ /** Check if a key is a link. */
273
+ isLink?(key: string | number): boolean;
274
+ /** Get props for an item. */
275
+ getItemProps?(
276
+ key: string | number
277
+ ): { href?: string; routerOptions?: unknown } | undefined;
278
+ /** Whether the user can select an item. */
279
+ canSelectItem?(key: string | number): boolean;
280
+ /** The first selected key. */
281
+ readonly firstSelectedKey?: (string | number) | null;
282
+ /** The last selected key. */
283
+ readonly lastSelectedKey?: (string | number) | null;
284
+ }
285
+
286
+ export type { BaseEvent, DOMAttributes, DOMProps, DisabledFlags, FocusEvents, FocusStrategy, FocusableDOMProps, HoverEvent, KeyboardEvents, LinkDOMProps, RenderProps, SelectionManager, SelectionMode, SlottedContextValue, StyleRenderProps };
package/dist/index.d.ts CHANGED
@@ -222,4 +222,65 @@ type SlottedContextValue<T, E = never> =
222
222
  | null
223
223
  | undefined;
224
224
 
225
- export type { BaseEvent, DOMAttributes, DOMProps, DisabledFlags, FocusEvents, FocusableDOMProps, HoverEvent, KeyboardEvents, LinkDOMProps, RenderProps, SlottedContextValue, StyleRenderProps };
225
+ /**
226
+ * Copyright (c) Corinvo, LLC. and affiliates.
227
+ *
228
+ * This source code is licensed under the MIT license found in the
229
+ * LICENSE file in the root directory of this source tree.
230
+ *
231
+ */
232
+
233
+ /** Selection mode for a collection. */
234
+ type SelectionMode = 'none' | 'single' | 'multiple';
235
+
236
+ /** Focus strategy when auto-focusing. */
237
+ type FocusStrategy = 'first' | 'last';
238
+
239
+ /**
240
+ * Interface for managing selection state in a collection.
241
+ */
242
+ interface SelectionManager {
243
+ /** The currently focused key. */
244
+ readonly focusedKey: (string | number) | null;
245
+ /** Set the focused key. */
246
+ setFocusedKey(
247
+ key: (string | number) | null,
248
+ childFocus?: FocusStrategy
249
+ ): void;
250
+ /** Whether the collection is focused. */
251
+ readonly isFocused: boolean;
252
+ /** Set whether the collection is focused. */
253
+ setFocused(isFocused: boolean): void;
254
+ /** The set of selected keys. */
255
+ readonly selectedKeys: Set<string | number>;
256
+ /** The selection mode. */
257
+ readonly selectionMode: SelectionMode;
258
+ /** Replace selection with a single key. */
259
+ replaceSelection(key: string | number): void;
260
+ /** Extend selection to include a key. */
261
+ extendSelection(key: string | number): void;
262
+ /** Toggle selection of a key. */
263
+ toggleSelection(key: string | number): void;
264
+ /** Select all items. */
265
+ selectAll(): void;
266
+ /** Clear all selection. */
267
+ clearSelection(): void;
268
+ /** Check if a key is selected. */
269
+ isSelected(key: string | number): boolean;
270
+ /** Check if a key is disabled. */
271
+ isDisabled?(key: string | number): boolean;
272
+ /** Check if a key is a link. */
273
+ isLink?(key: string | number): boolean;
274
+ /** Get props for an item. */
275
+ getItemProps?(
276
+ key: string | number
277
+ ): { href?: string; routerOptions?: unknown } | undefined;
278
+ /** Whether the user can select an item. */
279
+ canSelectItem?(key: string | number): boolean;
280
+ /** The first selected key. */
281
+ readonly firstSelectedKey?: (string | number) | null;
282
+ /** The last selected key. */
283
+ readonly lastSelectedKey?: (string | number) | null;
284
+ }
285
+
286
+ export type { BaseEvent, DOMAttributes, DOMProps, DisabledFlags, FocusEvents, FocusStrategy, FocusableDOMProps, HoverEvent, KeyboardEvents, LinkDOMProps, RenderProps, SelectionManager, SelectionMode, SlottedContextValue, StyleRenderProps };
package/dist/index.js CHANGED
@@ -1 +0,0 @@
1
- "use strict";var r=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var s=(e,o,m,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let p of x(o))!y.call(e,p)&&p!==m&&r(e,p,{get:()=>o[p],enumerable:!(t=f(o,p))||t.enumerable});return e};var n=e=>s(r({},"__esModule",{value:!0}),e);var a={};module.exports=n(a);
package/package.json CHANGED
@@ -1,14 +1,22 @@
1
1
  {
2
2
  "name": "@necto-react/types",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist",
7
7
  "README.md"
8
8
  ],
9
- "types": "dist/index.d.ts",
10
- "main": "./dist/index.js",
11
- "module": "./dist/index.mjs",
9
+ "type": "module",
10
+ "types": "./dist/index.d.ts",
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
18
+ }
19
+ },
12
20
  "author": "Corinvo OSS Team",
13
21
  "license": "MIT",
14
22
  "devDependencies": {