UNPKG

@snowball-tech/fractal

Version:

Fractal's (Snowball's design system) React component library based on RadixUI and PandaCSS

2 lines 1.44 kB
import{Children as c,cloneElement as a,Fragment as h,isValidElement as l}from"react";import k from"lodash/fp/isArray";import A from"lodash/fp/isBoolean";import m from"lodash/fp/isEmpty";import g from"lodash/fp/isNil";import x from"lodash/fp/isNumber";import R from"lodash/fp/isObject";import b from"lodash/fp/isString";function X(r){return new Promise(n=>{setTimeout(n,r)})}function y(r,n,e,i){const o=Array.isArray(e)?e:[e],s=g(i)||m(i)?[]:Array.isArray(i)?i:[i];let t=!1;return c.forEach(r,p=>{if(t||!l(p))return;const u=p.props;t=(n==="*"||p.type===n)&&o.every(f=>Object.hasOwn(u,f)&&!!u[f]),!t&&u.children?t=y(u.children,n,e,i):t&&!m(s)&&(t=s.every(f=>!Object.hasOwn(u,f)))}),t}function F(r,n,e){const i=[];for(let o=r;o<=n;o+=e)i.push(o);return i}function C(r,n,e){let i=r;return c.count(r)===0?r:(c.count(r)===1&&l(r)&&r.type===h&&(i=r.props.children),c.map(i,o=>{if(!l(o))return o;const s=o.type,t=o.props;return!m(e)&&(b(s)&&s!==e||R(s)&&s.displayName!==e)?a(o,{...t}):!m(t.children)&&k(t.children)?a(o,{...t,...n(t)},C(t.children,n,e)):a(o,n(t))}))}function w(r){try{if(g(r)||A(r)||!r)return"";let n="";if(b(r))n=r;else if(x(r))n=r.toString();else if(R(r)&&Symbol.iterator in r)for(const e of r)n+=w(e);else l(r)&&(n+=w(r.props.children));return n.replaceAll("[object Object]","").trim()}catch{return""}}export{C as extendChildren,y as hasChildWithProps,w as onlyText,F as rangeStep,X as sleep}; //# sourceMappingURL=utils.js.map