@necto-react/helpers 2.1.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Necto
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 s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var y=(t,n)=>{for(var e in n)s(t,e,{get:n[e],enumerable:!0})},p=(t,n,e,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of f(n))!m.call(t,o)&&o!==e&&s(t,o,{get:()=>n[o],enumerable:!(a=u(n,o))||a.enumerable});return t};var T=t=>p(s({},"__esModule",{value:!0}),t);var M={};y(M,{isKeyboardFocusEvent:()=>w});module.exports=T(M);var i=require("@necto/dom"),b=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),v={Tab:!0,Escape:!0};function w(t,n,e){if(!e||!("target"in e)||!e.target)return!1;let a=(0,i.getOwnerDocument)(e.target),o=(0,i.getOwnerWindow)(e.target),E=typeof window<"u"?o.HTMLInputElement:HTMLInputElement,l=typeof window<"u"?o.HTMLTextAreaElement:HTMLTextAreaElement,d=typeof window<"u"?o.HTMLElement:HTMLElement,c=typeof window<"u"?o.KeyboardEvent:KeyboardEvent,r=a.activeElement;return t=t||r instanceof E&&!b.has(r.type)||r instanceof l||r instanceof d&&r.isContentEditable,!(t&&n==="keyboard"&&e instanceof c&&!v[e.key])}0&&(module.exports={isKeyboardFocusEvent});
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
- * Portions of this code are based on the React Aria Spectrum library by Adobe,
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 };
@@ -1 +1 @@
1
- "use strict";(()=>{function w(t){return typeof window>"u"||window.navigator==null?!1:window.navigator.userAgentData?.brands.some(r=>t.test(r.brand))||t.test(window.navigator.userAgent)}var i=function(){return w(/Android/i)};function g(t){return t.mozInputSource===0&&t.isTrusted?!0:i()&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}var a=t=>t?.ownerDocument??document,s=t=>t&&"window"in t&&t.window===t?t:a(t).defaultView||window;var E=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),p={Tab:!0,Escape:!0};function M(t,r,e){if(!e||!("target"in e)||!e.target)return!1;let u=a(e.target),o=s(e.target),d=typeof window<"u"?o.HTMLInputElement:HTMLInputElement,c=typeof window<"u"?o.HTMLTextAreaElement:HTMLTextAreaElement,l=typeof window<"u"?o.HTMLElement:HTMLElement,f=typeof window<"u"?o.KeyboardEvent:KeyboardEvent,n=u.activeElement;return t=t||n instanceof d&&!E.has(n.type)||n instanceof c||n instanceof l&&n.isContentEditable,!(t&&r==="keyboard"&&e instanceof f&&!p[e.key])}})();
1
+ "use strict";(()=>{var Ee=new Set(["id"]);function ce(e,t){let{allowLabelableProps:n=!1,allowLinkProps:a=!1,extraAllowedProps:i,allowedLabelableProps:f=new Set,allowedLinkProps:T=new Set}=t,d={};for(let o in e)Object.hasOwn(e,o)&&(Ee.has(o)||n&&f.has(o)||a&&T.has(o)||i?.has(o)||new RegExp(/^(data-.*)$/).test(o))&&(d[o]=e[o]);return d}function de(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 R=()=>de(/Android/i);function je(e){return e.mozInputSource===0&&e.isTrusted?!0:R()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}var Pe={},u=Object.create(null),E=e=>globalThis.process?.env||Pe.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?u:globalThis),r=new Proxy(u,{get(e,t){return E()[t]??u[t]},has(e,t){let n=E();return t in n||t in u},set(e,t,n){let a=E(!0);return a[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=E(!0);return delete n[t],!0},ownKeys(){let e=E(!0);return Object.keys(e)}}),L=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",ue=[["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 pe(){if(globalThis.process?.env)for(let e of ue){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 _=pe(),Ze=_.name;function s(e){return e?e!=="false":!1}var m=globalThis.process?.platform||"",O=s(r.CI)||_.ci!==!1,C=s(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY);var Xe=s(r.DEBUG),fe=L==="test"||s(r.TEST),g=L==="production";var ze=s(r.MINIMAL)||O||fe||!C,Te=/^win/i.test(m),qe=/^linux/i.test(m),Je=/^darwin/i.test(m),$e=!s(r.NO_COLOR)&&(s(r.FORCE_COLOR)||(C||Te)&&r.TERM!=="dumb"||O),me=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null,et=Number(me?.split(".")[0])||null,Ae=globalThis.process||Object.create(null),S={versions:{}},tt=new Proxy(Ae,{get(e,t){if(t==="env")return r;if(t in e)return e[t];if(t in S)return S[t]}}),ve=globalThis.process?.release?.name==="node",Ie=!!globalThis.Bun||!!globalThis.process?.versions?.bun,Re=!!globalThis.Deno,Se=!!globalThis.fastly,Le=!!globalThis.Netlify,_e=!!globalThis.EdgeRuntime,Oe=globalThis.navigator?.userAgent==="Cloudflare-Workers",Ce=[[Le,"netlify"],[_e,"edge-light"],[Oe,"workerd"],[Se,"fastly"],[Re,"deno"],[Ie,"bun"],[ve,"node"]];function ge(){let e=Ce.find(t=>t[0]);if(e)return{name:e[1]}}var be=ge(),nt=be?.name||"";function De(e){if(!e)return;let t=!0;return n=>{let a={...n,preventDefault(){n.preventDefault()},isDefaultPrevented(){return n.isDefaultPrevented()},stopPropagation(){t&&g?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 lt(e){let t=e;return Object.assign(t,{nativeEvent:e,isDefaultPrevented:()=>t.defaultPrevented,isPropagationStopped:()=>t.cancelBubble,persist:()=>{}}),t}var Ne=Object.defineProperty,p=(e,t)=>{for(var n in t)Ne(e,n,{get:t[n],enumerable:!0})},A={};p(A,{HTML_TAGS:()=>P,PRIMITIVE_TAGS:()=>b,default:()=>he});var b=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],P=["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","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","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"],he={PRIMITIVE_TAGS:b,HTML_TAGS:P},we={};p(we,{NUMERIC_DIGITS:()=>D,default:()=>ye});var D=["1","2","3","4","5","6","7","8","9","0"],ye={NUMERIC_DIGITS:D},Me={};p(Me,{AMPERSAND:()=>G,ASTERISK:()=>K,BACKSLASH:()=>J,BOM:()=>N,CARRIAGE_RETURN:()=>y,COLON:()=>j,COMMA:()=>k,COMMERCIAL_AT:()=>z,DOT:()=>Y,DOUBLE_QUOTE:()=>B,EXCLAMATION:()=>U,GRAVE_ACCENT:()=>ee,GREATER_THAN:()=>Z,LEFT_CURLY_BRACKET:()=>te,LEFT_SQUARE_BRACKET:()=>q,LINE_FEED:()=>w,MINUS:()=>W,PERCENT:()=>x,PLUS:()=>V,QUESTION:()=>X,RIGHT_CURLY_BRACKET:()=>oe,RIGHT_SQUARE_BRACKET:()=>$,SHARP:()=>H,SINGLE_QUOTE:()=>F,SMALLER_THAN:()=>Q,SPACE:()=>M,TAB:()=>h,VERTICAL_LINE:()=>ne,default:()=>Ue});var N=65279,h=9,w=10,y=13,M=32,U=33,B=34,H=35,x=37,G=38,F=39,K=42,V=43,k=44,W=45,Y=46,j=58,Q=60,Z=62,X=63,z=64,q=91,J=92,$=93,ee=96,te=123,ne=124,oe=125,Ue={BOM:N,TAB:h,LINE_FEED:w,CARRIAGE_RETURN:y,SPACE:M,EXCLAMATION:U,DOUBLE_QUOTE:B,SHARP:H,PERCENT:x,AMPERSAND:G,SINGLE_QUOTE:F,ASTERISK:K,PLUS:V,COMMA:k,MINUS:W,DOT:Y,COLON:j,SMALLER_THAN:Q,GREATER_THAN:Z,QUESTION:X,COMMERCIAL_AT:z,LEFT_SQUARE_BRACKET:q,BACKSLASH:J,RIGHT_SQUARE_BRACKET:$,GRAVE_ACCENT:ee,LEFT_CURLY_BRACKET:te,VERTICAL_LINE:ne,RIGHT_CURLY_BRACKET:oe},Be={};p(Be,{CAPITALIZED:()=>re,LOWERCASE:()=>ae,VOWELS:()=>se,default:()=>He});var re=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],ae=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],se=["A","E","I","O","U","a","e","i","o","u"],He={CAPITALIZED:re,LOWERCASE:ae,VOWELS:se};var v=e=>e?.ownerDocument??document,le=e=>e&&"window"in e&&e.window===e?e:v(e).defaultView||window;var c=new Map,ie=new Set;function xe(e){if(!("propertyName"in e)||!e.target)return;let t=c.get(e.target);t||(t=new Set,c.set(e.target,t),e.target.addEventListener("transitioncancel",I,{once:!0})),t.add(e.propertyName)}function I(e){if(!("propertyName"in e)||!e.target)return;let t=c.get(e.target);if(t&&(t.delete(e.propertyName),t.size===0&&(e.target.removeEventListener("transitioncancel",I),c.delete(e.target)),c.size===0)){for(let n of ie)n();ie.clear()}}if(typeof window<"u"&&typeof document<"u"){let e=()=>{let t=document.body;t&&(t.addEventListener("transitionrun",xe),t.addEventListener("transitionend",I))};document.readyState!=="loading"?e():document.addEventListener("DOMContentLoaded",e,{once:!0})}var pt=A.HTML_TAGS.reduce((e,t)=>{var n;return e[n=t,n.charAt(0).toUpperCase()+n.slice(1)]=t,e},{});var Ge=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),Fe={Tab:!0,Escape:!0};function At(e,t,n){if(!n||!("target"in n)||!n.target)return!1;let a=v(n.target),i=le(n.target),f=typeof window<"u"?i.HTMLInputElement:HTMLInputElement,T=typeof window<"u"?i.HTMLTextAreaElement:HTMLTextAreaElement,d=typeof window<"u"?i.HTMLElement:HTMLElement,o=typeof window<"u"?i.KeyboardEvent:KeyboardEvent,l=a.activeElement;return e=e||l instanceof f&&!Ge.has(l.type)||l instanceof T||l instanceof d&&l.isContentEditable,!(e&&t==="keyboard"&&n instanceof o&&!Fe[n.key])}})();
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{isAndroid as E}from"@necto/platform";function y(e){return e.mozInputSource===0&&e.isTrusted?!0:E()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}import{getOwnerDocument as d,getOwnerWindow as c}from"@necto/dom";var p=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),f={Tab:!0,Escape:!0};function M(e,r,t){if(!t||!("target"in t)||!t.target)return!1;let a=d(t.target),o=c(t.target),i=typeof window<"u"?o.HTMLInputElement:HTMLInputElement,s=typeof window<"u"?o.HTMLTextAreaElement:HTMLTextAreaElement,l=typeof window<"u"?o.HTMLElement:HTMLElement,u=typeof window<"u"?o.KeyboardEvent:KeyboardEvent,n=a.activeElement;return e=e||n instanceof i&&!p.has(n.type)||n instanceof s||n instanceof l&&n.isContentEditable,!(e&&r==="keyboard"&&t instanceof u&&!f[t.key])}export{M as isKeyboardFocusEvent,y as isVirtualClick};
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.1.0",
3
+ "version": "2.4.1",
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
- "@necto/platform": "1.1.0",
24
- "@necto/dom": "1.1.0"
28
+ "std-env": "^3.9.0",
29
+ "@necto-react/types": "2.3.0",
30
+ "@necto/dom": "1.4.1",
31
+ "@necto/platform": "1.4.0"
25
32
  },
26
33
  "scripts": {
27
- "build": "tsup --minify"
34
+ "test": "vitest",
35
+ "build": "tsup ./src/index.ts --minify --format esm,cjs,iife --dts"
28
36
  }
29
37
  }