@spark-ui/internal-utils 2.3.1 → 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/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
+ # [2.4.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@2.3.1...@spark-ui/internal-utils@2.4.0) (2024-06-15)
7
+
8
+ ### Features
9
+
10
+ - **internal-utils:** add new createSplitProps util ([7e6827a](https://github.com/adevinta/spark/commit/7e6827a7ee556edb1288b38a7eb1a6bd033b9816))
11
+
6
12
  ## [2.3.1](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@2.3.0...@spark-ui/internal-utils@2.3.1) (2024-05-30)
7
13
 
8
14
  ### Bug Fixes
@@ -0,0 +1,3 @@
1
+ type EnsureKeys<ExpectedKeys extends (keyof Target)[], Target> = keyof Target extends ExpectedKeys[number] ? unknown : `Missing required keys: ${Exclude<keyof Target, ExpectedKeys[number]> & string}`;
2
+ export declare const createSplitProps: <Target>() => <Keys extends (keyof Target)[], Props extends Target = Target>(props: Props, keys: Keys & EnsureKeys<Keys, Target>) => [Target, Omit<Props, Extract<(Keys & EnsureKeys<Keys, Target>)[number], string>>];
3
+ export {};
package/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export { makeVariants } from './variants';
3
3
  export * as VariantTypes from './variants/types';
4
4
  export * as variantConstants from './variants/constants';
5
5
  export { deepFind } from './react-children-utilities/deepFind';
6
+ export { createSplitProps } from './create-split-props';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),a=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),d=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 u(e){return r.isValidElement(e)&&function(n){return r.isValidElement(n)&&!!n.props.children}(e)&&r.Children.toArray(e.props.children).reduce((n,i)=>n||r.isValidElement(i),!1)}exports.VariantTypes=a,exports.deepFind=function e(n,i){let o;return r.Children.toArray(n).find((t,l,s)=>i(t,l,s)?(o=t,!0):!(!r.isValidElement(t)||!u(t))&&(o=e(t.props.children,i),o!==void 0)),o},exports.makeVariants=function(e){return e},exports.tw=function(e){return e},exports.variantConstants=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),a=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),d=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 u(e){return s.isValidElement(e)&&function(r){return s.isValidElement(r)&&!!r.props.children}(e)&&s.Children.toArray(e.props.children).reduce((r,t)=>r||s.isValidElement(t),!1)}exports.VariantTypes=a,exports.createSplitProps=()=>(e,r)=>r.reduce((t,i)=>{const[n,o]=t,l=i;return o[l]!==void 0&&(n[l]=o[l]),delete o[l],[n,o]},[{},{...e}]),exports.deepFind=function e(r,t){let i;return s.Children.toArray(r).find((n,o,l)=>t(n,o,l)?(i=n,!0):!(!s.isValidElement(n)||!u(n))&&(i=e(n.props.children,t),i!==void 0)),i},exports.makeVariants=function(e){return e},exports.tw=function(e){return e},exports.variantConstants=d;
package/dist/index.mjs CHANGED
@@ -1,24 +1,29 @@
1
- import { isValidElement as o, Children as a } from "react";
2
- function c(e) {
1
+ import { isValidElement as i, Children as l } from "react";
2
+ function p(e) {
3
3
  return e;
4
4
  }
5
- function p(e) {
5
+ function f(e) {
6
6
  return e;
7
7
  }
8
- const f = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), m = 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 l(e) {
10
- return o(e) && function(n) {
11
- return o(n) && !!n.props.children;
12
- }(e) && a.toArray(e.props.children).reduce((n, r) => n || o(r), !1);
8
+ const m = 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 u(e) {
10
+ return i(e) && function(t) {
11
+ return i(t) && !!t.props.children;
12
+ }(e) && l.toArray(e.props.children).reduce((t, r) => t || i(r), !1);
13
13
  }
14
- function u(e, n) {
14
+ function c(e, t) {
15
15
  let r;
16
- return a.toArray(e).find((t, s, i) => n(t, s, i) ? (r = t, !0) : !(!o(t) || !l(t)) && (r = u(t.props.children, n), r !== void 0)), r;
16
+ return l.toArray(e).find((n, s, o) => t(n, s, o) ? (r = n, !0) : !(!i(n) || !u(n)) && (r = c(n.props.children, t), r !== void 0)), r;
17
17
  }
18
+ const _ = () => (e, t) => t.reduce((r, n) => {
19
+ const [s, o] = r, a = n;
20
+ return o[a] !== void 0 && (s[a] = o[a]), delete o[a], [s, o];
21
+ }, [{}, { ...e }]);
18
22
  export {
19
- f as VariantTypes,
20
- u as deepFind,
21
- p as makeVariants,
22
- c as tw,
23
- m as variantConstants
23
+ m as VariantTypes,
24
+ _ as createSplitProps,
25
+ c as deepFind,
26
+ f as makeVariants,
27
+ p as tw,
28
+ g as variantConstants
24
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-ui/internal-utils",
3
- "version": "2.3.1",
3
+ "version": "2.4.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": "374c07a266a2b772cbedcd6040b774ac2c023226"
37
+ "gitHead": "55efa48313eb5707161d980f13ee0a15c47413a3"
38
38
  }