@spark-ui/internal-utils 7.1.1 → 7.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 +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +35 -27
- package/dist/use-event/index.d.ts +12 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [7.2.0](https://github.com/adevinta/spark/compare/v7.1.1...v7.2.0) (2024-11-26)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **internal-utils:** add "useEvent" internal util ([9b495a1](https://github.com/adevinta/spark/commit/9b495a1f25f3d98e5cc0f74bc4a03943670350f8))
|
|
11
|
+
|
|
6
12
|
## [7.1.1](https://github.com/adevinta/spark/compare/v7.1.0...v7.1.1) (2024-11-26)
|
|
7
13
|
|
|
8
14
|
**Note:** Version bump only for package @spark-ui/internal-utils
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),c=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),c=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),l=Object.freeze(Object.defineProperty({__proto__:null,designs:["filled","outlined","tinted","ghost","contrast","dashed"],intents:["current","main","support","success","error","info","alert","danger","neutral","surface","accent","basic"],shapes:["rounded","square","pill"],sizes:["current","sm","md","lg","xl"]},Symbol.toStringTag,{value:"Module"}));function a(n){return s.isValidElement(n)&&function(t){return s.isValidElement(t)&&!!t.props.children}(n)&&s.Children.toArray(n.props.children).reduce((t,r)=>t||s.isValidElement(r),!1)}exports.VariantTypes=c,exports.createSplitProps=()=>(n,t)=>t.reduce((r,o)=>{const[e,i]=r,u=o;return i[u]!==void 0&&(e[u]=i[u]),delete i[u],[e,i]},[{},{...n}]),exports.deepFind=function n(t,r){let o;return s.Children.toArray(t).find((e,i,u)=>r(e,i,u)?(o=e,!0):!(!s.isValidElement(e)||!a(e))&&(o=n(e.props.children,r),o!==void 0)),o},exports.makeVariants=function(n){return n},exports.omit=function(n,t){const r={};return Object.keys(n).forEach(o=>{const e=o;t.includes(e)||(r[e]=n[e])}),r},exports.tw=function(n){return n},exports.useEvent=function(n,t={}){const{sync:r=!1}=t,o=function(e){const i=s.useRef(e);return i.current=e,i}(n);return s.useCallback((...e)=>r?queueMicrotask(()=>o.current?.(...e)):o.current?.(...e),[r,o])},exports.variantConstants=l;
|
package/dist/index.mjs
CHANGED
|
@@ -1,37 +1,45 @@
|
|
|
1
|
-
import { isValidElement as
|
|
2
|
-
function
|
|
1
|
+
import { isValidElement as c, Children as u, useCallback as i, useRef as l } from "react";
|
|
2
|
+
function m(e) {
|
|
3
3
|
return e;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function b(e) {
|
|
6
6
|
return e;
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
return
|
|
11
|
-
return
|
|
12
|
-
}(e) &&
|
|
8
|
+
const y = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), g = Object.freeze(Object.defineProperty({ __proto__: null, designs: ["filled", "outlined", "tinted", "ghost", "contrast", "dashed"], intents: ["current", "main", "support", "success", "error", "info", "alert", "danger", "neutral", "surface", "accent", "basic"], shapes: ["rounded", "square", "pill"], sizes: ["current", "sm", "md", "lg", "xl"] }, Symbol.toStringTag, { value: "Module" }));
|
|
9
|
+
function d(e) {
|
|
10
|
+
return c(e) && function(r) {
|
|
11
|
+
return c(r) && !!r.props.children;
|
|
12
|
+
}(e) && u.toArray(e.props.children).reduce((r, t) => r || c(t), !1);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
let
|
|
16
|
-
return
|
|
14
|
+
function f(e, r) {
|
|
15
|
+
let t;
|
|
16
|
+
return u.toArray(e).find((o, n, s) => r(o, n, s) ? (t = o, !0) : !(!c(o) || !d(o)) && (t = f(o.props.children, r), t !== void 0)), t;
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
const [
|
|
20
|
-
return s[a] !== void 0 && (
|
|
18
|
+
const h = () => (e, r) => r.reduce((t, o) => {
|
|
19
|
+
const [n, s] = t, a = o;
|
|
20
|
+
return s[a] !== void 0 && (n[a] = s[a]), delete s[a], [n, s];
|
|
21
21
|
}, [{}, { ...e }]);
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
return Object.keys(e).forEach((
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
}),
|
|
22
|
+
function _(e, r) {
|
|
23
|
+
const t = {};
|
|
24
|
+
return Object.keys(e).forEach((o) => {
|
|
25
|
+
const n = o;
|
|
26
|
+
r.includes(n) || (t[n] = e[n]);
|
|
27
|
+
}), t;
|
|
28
|
+
}
|
|
29
|
+
function v(e, r = {}) {
|
|
30
|
+
const { sync: t = !1 } = r, o = function(n) {
|
|
31
|
+
const s = l(n);
|
|
32
|
+
return s.current = n, s;
|
|
33
|
+
}(e);
|
|
34
|
+
return i((...n) => t ? queueMicrotask(() => o.current?.(...n)) : o.current?.(...n), [t, o]);
|
|
28
35
|
}
|
|
29
36
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
y as VariantTypes,
|
|
38
|
+
h as createSplitProps,
|
|
39
|
+
f as deepFind,
|
|
40
|
+
b as makeVariants,
|
|
41
|
+
_ as omit,
|
|
42
|
+
m as tw,
|
|
43
|
+
v as useEvent,
|
|
44
|
+
g as variantConstants
|
|
37
45
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type AnyFunction = (...args: any[]) => any;
|
|
2
|
+
interface Options {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to use queueMicrotask or not
|
|
5
|
+
*/
|
|
6
|
+
sync?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Returns a memoized callback that will queueMicrotask the callback if sync is true
|
|
10
|
+
*/
|
|
11
|
+
declare function useEvent<T extends AnyFunction>(callback: T | undefined, opts?: Options): T;
|
|
12
|
+
export { useEvent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-ui/internal-utils",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "package for sharing reusable code and resources across the codebase",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://sparkui.vercel.app",
|
|
36
36
|
"license": "MIT",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "819bc8f1d05c1fdd206165218e12b1bfa62376f7"
|
|
38
38
|
}
|