@spark-ui/internal-utils 2.2.0 → 2.3.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/CHANGELOG.md CHANGED
@@ -3,6 +3,23 @@
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.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
+
8
+ ### Bug Fixes
9
+
10
+ - **internal-utils:** update rollup conf, include ext peerDeps to avoid deps mismatches at call site ([fc4ec83](https://github.com/adevinta/spark/commit/fc4ec8360965735e148316304e1e2cf3c769d2b3))
11
+
12
+ # [2.3.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@2.2.0...@spark-ui/internal-utils@2.3.0) (2024-03-15)
13
+
14
+ ### Bug Fixes
15
+
16
+ - doc ([5506203](https://github.com/adevinta/spark/commit/55062039dc67c3532be42a4661540052094163d9))
17
+ - **internal-utils:** doc ([0014463](https://github.com/adevinta/spark/commit/00144635922cfc8a082a137070a758261e9fa162))
18
+
19
+ ### Features
20
+
21
+ - **internal-utils:** add deepFind internal util ([597d534](https://github.com/adevinta/spark/commit/597d53412aeac6fcb5cdf890ba6c1f86e4f540c9))
22
+
6
23
  # [2.2.0](https://github.com/adevinta/spark/compare/@spark-ui/internal-utils@2.1.3...@spark-ui/internal-utils@2.2.0) (2023-09-28)
7
24
 
8
25
  ### Features
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Internal utils
2
2
  > @spark-ui/internal-utils
3
3
 
4
- [//]: # (![storybook](https://img.shields.io/badge/storybook-black?logo=storybook&link=https%3A%2F%2Fsparkui.vercel.app%2F%3Fpath%3D%2Fdocs%2Futils-internalutils--docs))
5
- [//]: # (![documentation](https://img.shields.io/badge/documentation-black?logo=googledocs&link=https%3A%2F%2Fsparkui-adv.vercel.app%2Fdocs%2Futil%2Finternal-utils))
6
- ![issue](https://img.shields.io/badge/report%20a%20bug-black?logo=openbugbounty&logoColor=red&link=https%3A%2F%2Fgithub.com%2Fadevinta%2Fspark%2Fissues%2Fnew%3F%26projects%3D4%26template%3Dbug-report.yml%26assignees%3D%26labels%3Dutil%2Cinternal-utils)
7
- ![npm](https://img.shields.io/npm/dt/%40spark-ui/internal-utils?logo=npm&labelColor=black&link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40spark-ui%2Finternal-utils)
4
+ [//]: # ([![storybook](https://img.shields.io/badge/storybook-black?logo=storybook)](https://sparkui.vercel.app/?path=/docs/utils-internalutils--docs))
5
+ [//]: # ([![documentation](https://img.shields.io/badge/documentation-black?logo=googledocs)](https://sparkui-adv.vercel.app/docs/utils/internal-utils))
6
+ [![issue](https://img.shields.io/badge/report%20a%20bug-black?logo=openbugbounty&logoColor=red)](https://github.com/adevinta/spark/issues/new?&projects=4&template=bug-report.yml&assignees=&labels=util,internal-utils)
7
+ [![npm](https://img.shields.io/npm/dt/%40spark-ui/internal-utils?logo=npm&labelColor=black)](https://www.npmjs.com/package/@spark-ui/internal-utils)
8
8
 
9
9
 
10
10
  This package is part of the [`@spark-ui`](https://github.com/adevinta/spark) react-js user interface component library project.
11
11
 
12
- ![Issues open](https://img.shields.io/github/issues-search/adevinta/spark?query=is%3Aopen%20label%3Autil%20label%3Ainternal-utils&logo=openbugbounty&logoColor=red&label=issues%20open&color=red&link=https%3A%2F%2Fgithub.com%2Fadevinta%2Fspark%2Fissues%3Fq%3Dis%253Aopen%2Blabel%253Autil%2Blabel%253Ainternal-utils)
13
- ![NPM](https://img.shields.io/npm/l/%40spark-ui%2Finternal-utils)
12
+ [![Issues open](https://img.shields.io/github/issues-search/adevinta/spark?query=is%3Aopen%20label%3Autil%20label%3Ainternal-utils&logo=openbugbounty&logoColor=red&label=issues%20open&color=red)](https://github.com/adevinta/spark/issues?q=is%3Aopen+label%3Autil+label%3Ainternal-utils)
13
+ [![NPM](https://img.shields.io/npm/l/%40spark-ui%2Finternal-utils)](https://github.com/adevinta/spark/blob/main/packages/utils/internal-utils/LICENSE.md)
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export { tw } from './tw';
2
2
  export { makeVariants } from './variants';
3
3
  export * as VariantTypes from './variants/types';
4
4
  export * as variantConstants from './variants/constants';
5
+ export { deepFind } from './react-children-utilities/deepFind';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),r=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"}));exports.VariantTypes=t,exports.makeVariants=function(e){return e},exports.tw=function(e){return e},exports.variantConstants=r;
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;
package/dist/index.mjs CHANGED
@@ -1,13 +1,24 @@
1
- function t(e) {
1
+ import { isValidElement as o, Children as a } from "react";
2
+ function c(e) {
2
3
  return e;
3
4
  }
4
- function r(e) {
5
+ function p(e) {
5
6
  return e;
6
7
  }
7
- const n = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), a = 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" }));
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);
13
+ }
14
+ function u(e, n) {
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;
17
+ }
8
18
  export {
9
- n as VariantTypes,
10
- r as makeVariants,
11
- t as tw,
12
- a as variantConstants
19
+ f as VariantTypes,
20
+ u as deepFind,
21
+ p as makeVariants,
22
+ c as tw,
23
+ m as variantConstants
13
24
  };
@@ -0,0 +1,3 @@
1
+ import type { ReactNode } from 'react';
2
+ declare function deepFind(children: ReactNode | ReactNode[], deepFindFn: (child: ReactNode, index?: number, children?: ReactNode[]) => boolean): ReactNode | undefined;
3
+ export { deepFind };
@@ -0,0 +1,5 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ declare function hasChildren(element: ReactNode): element is ReactElement<{
3
+ children: ReactNode | ReactNode[];
4
+ }>;
5
+ export { hasChildren };
@@ -0,0 +1,5 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ declare function hasComplexChildren(element: ReactNode): element is ReactElement<{
3
+ children: ReactNode | ReactNode[];
4
+ }>;
5
+ export { hasComplexChildren };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-ui/internal-utils",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "package for sharing reusable code and resources across the codebase",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,6 +16,10 @@
16
16
  "scripts": {
17
17
  "build": "vite build"
18
18
  },
19
+ "peerDependencies": {
20
+ "react": "^18.0 || ^19.0",
21
+ "react-dom": "^18.0 || ^19.0"
22
+ },
19
23
  "repository": {
20
24
  "type": "git",
21
25
  "url": "https://github.com/adevinta/spark.git",
@@ -30,5 +34,5 @@
30
34
  },
31
35
  "homepage": "https://sparkui.vercel.app",
32
36
  "license": "MIT",
33
- "gitHead": "60a8f00aef92177084ac744bc4fd56ef13bc9948"
37
+ "gitHead": "374c07a266a2b772cbedcd6040b774ac2c023226"
34
38
  }
package/vite.config.ts CHANGED
@@ -2,6 +2,9 @@ import { terser } from 'rollup-plugin-terser'
2
2
  import dts from 'vite-plugin-dts'
3
3
  import browserslistToEsbuild from 'browserslist-to-esbuild'
4
4
 
5
+ const pkg = require('./package.json')
6
+ const peerDeps = Object.keys(pkg.peerDependencies || {})
7
+
5
8
  export default {
6
9
  build: {
7
10
  target: browserslistToEsbuild(),
@@ -11,7 +14,7 @@ export default {
11
14
  fileName: 'index',
12
15
  },
13
16
  rollupOptions: {
14
- external: ['node:path', 'node:fs'],
17
+ external: ['node:path', 'node:fs', ...peerDeps],
15
18
  plugins: [terser()],
16
19
  },
17
20
  },