@necto-react/helpers 2.1.0 → 2.4.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/LICENSE +1 -1
- package/README.md +22 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +156 -1
- package/dist/index.d.ts +131 -2
- package/dist/index.global.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +13 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://necto.dev">
|
|
3
|
+
<img alt="Necto Logo" src="https://avatars.githubusercontent.com/u/158605331?s=100&v=4">
|
|
4
|
+
<a>
|
|
5
|
+
|
|
6
|
+
<h2>Necto - React Helpers Library</h2>
|
|
7
|
+
|
|
8
|
+
<p>Necto's library for providing global helpers for React applications.</p>
|
|
9
|
+
|
|
10
|
+
<a aria-label="Corinvo" href="https://corinvo.github.io">
|
|
11
|
+
<img src="https://img.shields.io/badge/Made%20by-Corinvo-black.svg?style=for-the-badge&color=black">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@necto-react/helpers">
|
|
14
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/@necto-react/helpers.svg?style=for-the-badge">
|
|
15
|
+
</a>
|
|
16
|
+
<a aria-label="License" href="https://jsr.io/@necto-react/helpers">
|
|
17
|
+
<img src="https://jsr.io/badges/@necto-react/helpers?style=for-the-badge">
|
|
18
|
+
</a>
|
|
19
|
+
<a aria-label="License" href="https://github.com/nectoutil/NodeKit/blob/main/LICENSE">
|
|
20
|
+
<img src="https://img.shields.io/badge/License-MIT-97CA25.svg?style=for-the-badge">
|
|
21
|
+
</a>
|
|
22
|
+
</div>
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},w=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!P.call(e,o)&&o!==n&&c(e,o,{get:()=>t[o],enumerable:!(a=v(t,o))||a.enumerable});return e};var T=e=>w(c({},"__esModule",{value:!0}),e);var L={};b(L,{createEventHandler:()=>m,createSyntheticEvent:()=>x,filterDOMProps:()=>d,isKeyboardFocusEvent:()=>D,isVirtualClick:()=>g});module.exports=T(L);var M=new Set(["id"]);function d(e,t){let{allowLabelableProps:n=!1,allowLinkProps:a=!1,extraAllowedProps:o,allowedLabelableProps:l=new Set,allowedLinkProps:u=new Set}=t,s={};for(let r in e)Object.hasOwn(e,r)&&(M.has(r)||n&&l.has(r)||a&&u.has(r)||o?.has(r)||new RegExp(/^(data-.*)$/).test(r))&&(s[r]=e[r]);return s}var f=require("@necto/platform");function g(e){return e.mozInputSource===0&&e.isTrusted?!0:(0,f.isAndroid)()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}var E=require("std-env");function m(e){if(!e)return;let t=!0;return n=>{let a={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){t&&E.isProduction?console.error("stopPropagation is now the default behavior for events in Necto. You can use continuePropagation() to revert this behavior."):t=!0},continuePropagation(){t=!1},isPropagationStopped(){return t}};e(a),t&&n.stopPropagation()}}function x(e){let t=e;return Object.assign(t,{nativeEvent:e,isDefaultPrevented:()=>t.defaultPrevented,isPropagationStopped:()=>t.cancelBubble,persist:()=>{}}),t}var p=require("@necto/dom"),H=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),O={Tab:!0,Escape:!0};function D(e,t,n){if(!n||!("target"in n)||!n.target)return!1;let a=(0,p.getOwnerDocument)(n.target),o=(0,p.getOwnerWindow)(n.target),l=typeof window<"u"?o.HTMLInputElement:HTMLInputElement,u=typeof window<"u"?o.HTMLTextAreaElement:HTMLTextAreaElement,s=typeof window<"u"?o.HTMLElement:HTMLElement,r=typeof window<"u"?o.KeyboardEvent:KeyboardEvent,i=a.activeElement;return e=e||i instanceof l&&!H.has(i.type)||i instanceof u||i instanceof s&&i.isContentEditable,!(e&&t==="keyboard"&&n instanceof r&&!O[n.key])}0&&(module.exports={createEventHandler,createSyntheticEvent,filterDOMProps,isKeyboardFocusEvent,isVirtualClick});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,160 @@
|
|
|
1
|
+
import { LinkDOMProps, BaseEvent } from '@necto-react/types';
|
|
2
|
+
import { SyntheticEvent } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Options for filtering DOM props.
|
|
14
|
+
*/
|
|
15
|
+
interface FilterOptions {
|
|
16
|
+
/** Whether to allow labelable props (e.g., htmlFor, aria-label). */
|
|
17
|
+
allowLabelableProps?: boolean;
|
|
18
|
+
/** Whether to allow link-related props (e.g., href, target). */
|
|
19
|
+
allowLinkProps?: boolean;
|
|
20
|
+
/** Extra prop names to allow through the filter. */
|
|
21
|
+
extraAllowedProps?: Set<string>;
|
|
22
|
+
/** Custom set of allowed labelable prop names. */
|
|
23
|
+
allowedLabelableProps?: Set<string>;
|
|
24
|
+
/** Custom set of allowed link-related prop names. */
|
|
25
|
+
allowedLinkProps?: Set<string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Props allowed for DOM filtering, including link props and id.
|
|
29
|
+
*/
|
|
30
|
+
interface FilterDOMProps extends LinkDOMProps {
|
|
31
|
+
/** The id attribute for the element. */
|
|
32
|
+
id?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Return type for filtered DOM props.
|
|
36
|
+
*/
|
|
37
|
+
interface FilterDOMReturn {
|
|
38
|
+
/** The id attribute for the element. */
|
|
39
|
+
id?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
44
|
+
* licensed under the Apache License, Version 2.0.
|
|
45
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
46
|
+
* See: https://github.com/adobe/react-spectrum
|
|
47
|
+
*
|
|
48
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
49
|
+
*
|
|
50
|
+
* This file contains code licensed under:
|
|
51
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
52
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
53
|
+
*
|
|
54
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Filters a props object to include only allowed DOM props based on the provided options.
|
|
59
|
+
*
|
|
60
|
+
* @param {FilterDOMProps} props - The props object to filter.
|
|
61
|
+
* @param {FilterOptions} options - Options to control which props are allowed.
|
|
62
|
+
* @returns {FilterDOMReturn} An object containing only the allowed DOM props.
|
|
63
|
+
*/
|
|
64
|
+
declare function filterDOMProps(props: FilterDOMProps, options: FilterOptions): FilterDOMReturn;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
68
|
+
* licensed under the Apache License, Version 2.0.
|
|
69
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
70
|
+
* See: https://github.com/adobe/react-spectrum
|
|
71
|
+
*
|
|
72
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
73
|
+
*
|
|
74
|
+
* This file contains code licensed under:
|
|
75
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
76
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
77
|
+
*
|
|
78
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
79
|
+
*/
|
|
80
|
+
declare function isVirtualClick(event: MouseEvent | PointerEvent): boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the MIT license found in the
|
|
86
|
+
* LICENSE file in the root directory of this source tree.
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Type for the event handler function returned by createEventHandler.
|
|
92
|
+
*
|
|
93
|
+
* @template T The type of the SyntheticEvent.
|
|
94
|
+
*/
|
|
95
|
+
type EventHandler<T extends SyntheticEvent> = (e: T) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Type for the handler function passed to createEventHandler.
|
|
98
|
+
*
|
|
99
|
+
* @template T The type of the SyntheticEvent.
|
|
100
|
+
*/
|
|
101
|
+
type BaseEventHandler<T extends SyntheticEvent> = (e: BaseEvent<T>) => void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
105
|
+
* licensed under the Apache License, Version 2.0.
|
|
106
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
107
|
+
* See: https://github.com/adobe/react-spectrum
|
|
108
|
+
*
|
|
109
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
110
|
+
*
|
|
111
|
+
* This file contains code licensed under:
|
|
112
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
113
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
114
|
+
*
|
|
115
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Creates an event handler that wraps a BaseEventHandler, providing custom propagation control.
|
|
120
|
+
*
|
|
121
|
+
* @template T The type of the SyntheticEvent.
|
|
122
|
+
* @param {BaseEventHandler<T>} [handler] - The handler function to invoke with the extended event.
|
|
123
|
+
* @returns {EventHandler<T> | undefined} A standard event handler or undefined if no handler is provided.
|
|
124
|
+
*/
|
|
125
|
+
declare function createEventHandler<T extends SyntheticEvent>(handler?: BaseEventHandler<T>): EventHandler<T> | undefined;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the MIT license found in the
|
|
131
|
+
* LICENSE file in the root directory of this source tree.
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Creates a synthetic React event from a native DOM event.
|
|
137
|
+
* This is used to maintain compatibility with React's event system.
|
|
138
|
+
*
|
|
139
|
+
* @param nativeEvent - The original native DOM event.
|
|
140
|
+
* @returns The synthetic React event.
|
|
141
|
+
*/
|
|
142
|
+
declare function createSyntheticEvent<T extends SyntheticEvent>(nativeEvent: Event): T;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
146
|
+
*
|
|
147
|
+
* This source code is licensed under the MIT license found in the
|
|
148
|
+
* LICENSE file in the root directory of this source tree.
|
|
149
|
+
*
|
|
150
|
+
* Portions of this code are based on the React Aria Spectrum library by Adobe,
|
|
151
|
+
* licensed under the Apache License, Version 2.0.
|
|
152
|
+
* See: https://github.com/adobe/react-spectrum
|
|
153
|
+
*
|
|
154
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
155
|
+
*/
|
|
1
156
|
type Modality = 'keyboard' | 'pointer' | 'virtual';
|
|
2
157
|
type HandlerEvent = PointerEvent | MouseEvent | KeyboardEvent | FocusEvent | null;
|
|
3
158
|
declare function isKeyboardFocusEvent(isTextInput: boolean, modality: Modality, e: HandlerEvent): boolean;
|
|
4
159
|
|
|
5
|
-
export { type HandlerEvent, type Modality, isKeyboardFocusEvent };
|
|
160
|
+
export { type FilterDOMProps, type FilterDOMReturn, type FilterOptions, type HandlerEvent, type Modality, createEventHandler, createSyntheticEvent, filterDOMProps, isKeyboardFocusEvent, isVirtualClick };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,146 @@
|
|
|
1
|
+
import { LinkDOMProps, BaseEvent } from '@necto-react/types';
|
|
2
|
+
import { SyntheticEvent } from 'react';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
6
|
*
|
|
4
7
|
* This source code is licensed under the MIT license found in the
|
|
5
8
|
* LICENSE file in the root directory of this source tree.
|
|
6
9
|
*
|
|
7
|
-
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Options for filtering DOM props.
|
|
14
|
+
*/
|
|
15
|
+
interface FilterOptions {
|
|
16
|
+
/** Whether to allow labelable props (e.g., htmlFor, aria-label). */
|
|
17
|
+
allowLabelableProps?: boolean;
|
|
18
|
+
/** Whether to allow link-related props (e.g., href, target). */
|
|
19
|
+
allowLinkProps?: boolean;
|
|
20
|
+
/** Extra prop names to allow through the filter. */
|
|
21
|
+
extraAllowedProps?: Set<string>;
|
|
22
|
+
/** Custom set of allowed labelable prop names. */
|
|
23
|
+
allowedLabelableProps?: Set<string>;
|
|
24
|
+
/** Custom set of allowed link-related prop names. */
|
|
25
|
+
allowedLinkProps?: Set<string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Props allowed for DOM filtering, including link props and id.
|
|
29
|
+
*/
|
|
30
|
+
interface FilterDOMProps extends LinkDOMProps {
|
|
31
|
+
/** The id attribute for the element. */
|
|
32
|
+
id?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Return type for filtered DOM props.
|
|
36
|
+
*/
|
|
37
|
+
interface FilterDOMReturn {
|
|
38
|
+
/** The id attribute for the element. */
|
|
39
|
+
id?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
44
|
+
* licensed under the Apache License, Version 2.0.
|
|
45
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
46
|
+
* See: https://github.com/adobe/react-spectrum
|
|
47
|
+
*
|
|
48
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
49
|
+
*
|
|
50
|
+
* This file contains code licensed under:
|
|
51
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
52
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
53
|
+
*
|
|
54
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Filters a props object to include only allowed DOM props based on the provided options.
|
|
59
|
+
*
|
|
60
|
+
* @param {FilterDOMProps} props - The props object to filter.
|
|
61
|
+
* @param {FilterOptions} options - Options to control which props are allowed.
|
|
62
|
+
* @returns {FilterDOMReturn} An object containing only the allowed DOM props.
|
|
63
|
+
*/
|
|
64
|
+
declare function filterDOMProps(props: FilterDOMProps, options: FilterOptions): FilterDOMReturn;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
8
68
|
* licensed under the Apache License, Version 2.0.
|
|
69
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
9
70
|
* See: https://github.com/adobe/react-spectrum
|
|
10
71
|
*
|
|
72
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
73
|
+
*
|
|
74
|
+
* This file contains code licensed under:
|
|
75
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
76
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
77
|
+
*
|
|
11
78
|
* Modifications have been made to adapt the code for use in this project.
|
|
12
79
|
*/
|
|
13
80
|
declare function isVirtualClick(event: MouseEvent | PointerEvent): boolean;
|
|
14
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the MIT license found in the
|
|
86
|
+
* LICENSE file in the root directory of this source tree.
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Type for the event handler function returned by createEventHandler.
|
|
92
|
+
*
|
|
93
|
+
* @template T The type of the SyntheticEvent.
|
|
94
|
+
*/
|
|
95
|
+
type EventHandler<T extends SyntheticEvent> = (e: T) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Type for the handler function passed to createEventHandler.
|
|
98
|
+
*
|
|
99
|
+
* @template T The type of the SyntheticEvent.
|
|
100
|
+
*/
|
|
101
|
+
type BaseEventHandler<T extends SyntheticEvent> = (e: BaseEvent<T>) => void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Portions of this file are based on code from the React Aria Spectrum library by Adobe,
|
|
105
|
+
* licensed under the Apache License, Version 2.0.
|
|
106
|
+
* Copyright (c) Adobe. All rights reserved.
|
|
107
|
+
* See: https://github.com/adobe/react-spectrum
|
|
108
|
+
*
|
|
109
|
+
* Modifications copyright (c) Corinvo, LLC. and affiliates. All rights reserved.
|
|
110
|
+
*
|
|
111
|
+
* This file contains code licensed under:
|
|
112
|
+
* - The MIT License (see LICENSE in the root directory) for Corinvo modifications.
|
|
113
|
+
* - The Apache License, Version 2.0 for portions from Adobe.
|
|
114
|
+
*
|
|
115
|
+
* Modifications have been made to adapt the code for use in this project.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Creates an event handler that wraps a BaseEventHandler, providing custom propagation control.
|
|
120
|
+
*
|
|
121
|
+
* @template T The type of the SyntheticEvent.
|
|
122
|
+
* @param {BaseEventHandler<T>} [handler] - The handler function to invoke with the extended event.
|
|
123
|
+
* @returns {EventHandler<T> | undefined} A standard event handler or undefined if no handler is provided.
|
|
124
|
+
*/
|
|
125
|
+
declare function createEventHandler<T extends SyntheticEvent>(handler?: BaseEventHandler<T>): EventHandler<T> | undefined;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the MIT license found in the
|
|
131
|
+
* LICENSE file in the root directory of this source tree.
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Creates a synthetic React event from a native DOM event.
|
|
137
|
+
* This is used to maintain compatibility with React's event system.
|
|
138
|
+
*
|
|
139
|
+
* @param nativeEvent - The original native DOM event.
|
|
140
|
+
* @returns The synthetic React event.
|
|
141
|
+
*/
|
|
142
|
+
declare function createSyntheticEvent<T extends SyntheticEvent>(nativeEvent: Event): T;
|
|
143
|
+
|
|
15
144
|
/**
|
|
16
145
|
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
17
146
|
*
|
|
@@ -28,4 +157,4 @@ type Modality = 'keyboard' | 'pointer' | 'virtual';
|
|
|
28
157
|
type HandlerEvent = PointerEvent | MouseEvent | KeyboardEvent | FocusEvent | null;
|
|
29
158
|
declare function isKeyboardFocusEvent(isTextInput: boolean, modality: Modality, e: HandlerEvent): boolean;
|
|
30
159
|
|
|
31
|
-
export { type HandlerEvent, type Modality, isKeyboardFocusEvent, isVirtualClick };
|
|
160
|
+
export { type FilterDOMProps, type FilterDOMReturn, type FilterOptions, type HandlerEvent, type Modality, createEventHandler, createSyntheticEvent, filterDOMProps, isKeyboardFocusEvent, isVirtualClick };
|
package/dist/index.global.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{function
|
|
1
|
+
"use strict";(()=>{var D=new Set(["id"]);function P(e,t){let{allowLabelableProps:n=!1,allowLinkProps:i=!1,extraAllowedProps:a,allowedLabelableProps:E=new Set,allowedLinkProps:f=new Set}=t,u={};for(let o in e)Object.hasOwn(e,o)&&(D.has(o)||n&&E.has(o)||i&&f.has(o)||a?.has(o)||new RegExp(/^(data-.*)$/).test(o))&&(u[o]=e[o]);return u}function C(e){return typeof window>"u"||window.navigator==null?!1:window.navigator.userAgentData?.brands.some(t=>e.test(t.brand))||e.test(window.navigator.userAgent)}var b=()=>C(/Android/i);function ie(e){return e.mozInputSource===0&&e.isTrusted?!0:b()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}var Z={},p=Object.create(null),c=e=>globalThis.process?.env||Z.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?p:globalThis),r=new Proxy(p,{get(e,t){return c()[t]??p[t]},has(e,t){let n=c();return t in n||t in p},set(e,t,n){let i=c(!0);return i[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=c(!0);return delete n[t],!0},ownKeys(){let e=c(!0);return Object.keys(e)}}),I=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",_=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CLOUDFLARE_WORKERS","WORKERS_CI",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["CODESANDBOX","CODESANDBOX_HOST",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]];function N(){if(globalThis.process?.env)for(let e of _){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}var S=N(),ae=S.name;function s(e){return e?e!=="false":!1}var m=globalThis.process?.platform||"",w=s(r.CI)||S.ci!==!1,L=s(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY);var le=s(r.DEBUG),M=I==="test"||s(r.TEST),h=I==="production";var ce=s(r.MINIMAL)||w||M||!L,B=/^win/i.test(m),de=/^linux/i.test(m),ue=/^darwin/i.test(m),pe=!s(r.NO_COLOR)&&(s(r.FORCE_COLOR)||(L||B)&&r.TERM!=="dumb"||w),U=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null,Ee=Number(U?.split(".")[0])||null,H=globalThis.process||Object.create(null),v={versions:{}},fe=new Proxy(H,{get(e,t){if(t==="env")return r;if(t in e)return e[t];if(t in v)return v[t]}}),x=globalThis.process?.release?.name==="node",k=!!globalThis.Bun||!!globalThis.process?.versions?.bun,F=!!globalThis.Deno,W=!!globalThis.fastly,V=!!globalThis.Netlify,Y=!!globalThis.EdgeRuntime,K=globalThis.navigator?.userAgent==="Cloudflare-Workers",G=[[V,"netlify"],[Y,"edge-light"],[K,"workerd"],[W,"fastly"],[F,"deno"],[k,"bun"],[x,"node"]];function j(){let e=G.find(t=>t[0]);if(e)return{name:e[1]}}var z=j(),me=z?.name||"";function X(e){if(!e)return;let t=!0;return n=>{let i={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){t&&h?console.error("stopPropagation is now the default behavior for events in Necto. You can use continuePropagation() to revert this behavior."):t=!0},continuePropagation(){t=!1},isPropagationStopped(){return t}};e(i),t&&n.stopPropagation()}}function Se(e){let t=e;return Object.assign(t,{nativeEvent:e,isDefaultPrevented:()=>t.defaultPrevented,isPropagationStopped:()=>t.cancelBubble,persist:()=>{}}),t}var O=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","math","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rb","rp","rt","rtc","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"];var y=O;var T=e=>e?.ownerDocument??document,A=e=>e&&"window"in e&&e.window===e?e:T(e).defaultView||window;var d=new Map,R=new Set;function J(e){if(!("propertyName"in e)||!e.target)return;let t=d.get(e.target);t||(t=new Set,d.set(e.target,t),e.target.addEventListener("transitioncancel",g,{once:!0})),t.add(e.propertyName)}function g(e){if(!("propertyName"in e)||!e.target)return;let t=d.get(e.target);if(t&&(t.delete(e.propertyName),t.size===0&&(e.target.removeEventListener("transitioncancel",g),d.delete(e.target)),d.size===0)){for(let n of R)n();R.clear()}}if(typeof window<"u"&&typeof document<"u"){let e=()=>{let t=document.body;t&&(t.addEventListener("transitionrun",J),t.addEventListener("transitionend",g))};document.readyState!=="loading"?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}var Ae=y.reduce((e,t)=>{var n;return e[n=t,n.charAt(0).toUpperCase()+n.slice(1)]=t,e},{});var Q=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),$={Tab:!0,Escape:!0};function _e(e,t,n){if(!n||!("target"in n)||!n.target)return!1;let i=T(n.target),a=A(n.target),E=typeof window<"u"?a.HTMLInputElement:HTMLInputElement,f=typeof window<"u"?a.HTMLTextAreaElement:HTMLTextAreaElement,u=typeof window<"u"?a.HTMLElement:HTMLElement,o=typeof window<"u"?a.KeyboardEvent:KeyboardEvent,l=i.activeElement;return e=e||l instanceof E&&!Q.has(l.type)||l instanceof f||l instanceof u&&l.isContentEditable,!(e&&t==="keyboard"&&n instanceof o&&!$[n.key])}})();
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isAndroid as
|
|
1
|
+
var u=new Set(["id"]);function c(e,t){let{allowLabelableProps:n=!1,allowLinkProps:a=!1,extraAllowedProps:r,allowedLabelableProps:p=new Set,allowedLinkProps:l=new Set}=t,s={};for(let o in e)Object.hasOwn(e,o)&&(u.has(o)||n&&p.has(o)||a&&l.has(o)||r?.has(o)||new RegExp(/^(data-.*)$/).test(o))&&(s[o]=e[o]);return s}import{isAndroid as d}from"@necto/platform";function g(e){return e.mozInputSource===0&&e.isTrusted?!0:d()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}import{isProduction as f}from"std-env";function E(e){if(!e)return;let t=!0;return n=>{let a={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){t&&f?console.error("stopPropagation is now the default behavior for events in Necto. You can use continuePropagation() to revert this behavior."):t=!0},continuePropagation(){t=!1},isPropagationStopped(){return t}};e(a),t&&n.stopPropagation()}}function S(e){let t=e;return Object.assign(t,{nativeEvent:e,isDefaultPrevented:()=>t.defaultPrevented,isPropagationStopped:()=>t.cancelBubble,persist:()=>{}}),t}import{getOwnerDocument as m,getOwnerWindow as v}from"@necto/dom";var y=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),P={Tab:!0,Escape:!0};function F(e,t,n){if(!n||!("target"in n)||!n.target)return!1;let a=m(n.target),r=v(n.target),p=typeof window<"u"?r.HTMLInputElement:HTMLInputElement,l=typeof window<"u"?r.HTMLTextAreaElement:HTMLTextAreaElement,s=typeof window<"u"?r.HTMLElement:HTMLElement,o=typeof window<"u"?r.KeyboardEvent:KeyboardEvent,i=a.activeElement;return e=e||i instanceof p&&!y.has(i.type)||i instanceof l||i instanceof s&&i.isContentEditable,!(e&&t==="keyboard"&&n instanceof o&&!P[n.key])}export{E as createEventHandler,S as createSyntheticEvent,c as filterDOMProps,F as isKeyboardFocusEvent,g as isVirtualClick};
|
package/package.json
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@necto-react/helpers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Necto's library for providing global helpers React applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"README.md"
|
|
9
9
|
],
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
11
|
"main": "./dist/index.cjs",
|
|
12
12
|
"module": "./dist/index.js",
|
|
13
13
|
"author": "Corinvo OSS Team",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"devDependencies": {
|
|
16
|
+
"@types/node": "^22.14.1",
|
|
17
|
+
"@types/react": "^19.1.2",
|
|
18
|
+
"@types/react-dom": "^19.1.2",
|
|
19
|
+
"react": "^19.1.0",
|
|
20
|
+
"react-dom": "^19.1.0",
|
|
16
21
|
"tsup": "^8.4.0"
|
|
17
22
|
},
|
|
18
23
|
"peerDependencies": {
|
|
@@ -20,10 +25,13 @@
|
|
|
20
25
|
"react-dom": "^19.1.0"
|
|
21
26
|
},
|
|
22
27
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"@necto/
|
|
28
|
+
"std-env": "^3.9.0",
|
|
29
|
+
"@necto-react/types": "2.3.0",
|
|
30
|
+
"@necto/dom": "1.4.0",
|
|
31
|
+
"@necto/platform": "1.4.0"
|
|
25
32
|
},
|
|
26
33
|
"scripts": {
|
|
27
|
-
"
|
|
34
|
+
"test": "vitest",
|
|
35
|
+
"build": "tsup ./src/index.ts --minify --format esm,cjs,iife --dts"
|
|
28
36
|
}
|
|
29
37
|
}
|