@snowball-tech/fractal
Version:
Fractal's (Snowball's design system) React component library based on RadixUI and TailwindCSS
2 lines • 1.55 kB
JavaScript
import{Children as e,Fragment as t,cloneElement as n,isValidElement as r}from"react";import i from"lodash/fp/isEmpty.js";import a from"lodash/fp/isString.js";import o from"lodash/fp/isArray.js";import s from"lodash/fp/isNil.js";import c from"lodash/fp/isObject.js";function l(e){return new Promise(t=>{setTimeout(t,e)})}function u(t,n,a,o){let c=Array.isArray(a)?a:[a],l=s(o)||i(o)?[]:Array.isArray(o)?o:[o],d=!1;return e.forEach(t,e=>{if(d||!r(e))return;let t=e.props;d=(n===`*`||e.type===n)&&c.every(e=>Object.hasOwn(t,e)&&!!t[e]),!d&&t.children?d=u(t.children,n,a,o):d&&!i(l)&&(d=l.every(e=>!Object.hasOwn(t,e)))}),d}function d(e,t,n){let r=[];for(let i=e;i<=t;i+=n)r.push(i);return r}function f(s,l,u){let d=s;return e.count(s)===0?s:(e.count(s)===1&&r(s)&&s.type===t&&(d=s.props.children),e.map(d,e=>{if(!r(e))return e;let t=e.type,s=e.props;return!i(u)&&(a(t)&&t!==u||c(t)&&t.displayName!==u)?n(e,{...s}):!i(s.children)&&o(s.children)?n(e,{...s,...l(s)},f(s.children,l,u)):n(e,l(s))}))}function p(e){try{if(e==null||typeof e==`boolean`||e===``)return``;if(typeof e==`string`)return e;if(typeof e==`number`)return String(e);if(Array.isArray(e))return e.map(p).join(``).replaceAll(`[object Object]`,``).trim();if(r(e)){let{children:t,value:n}=e.props;return p(t??n)}if(typeof e==`object`&&Symbol.iterator in e){let t=``;for(let n of e)t+=p(n);return t.replaceAll(`[object Object]`,``).trim()}return``}catch{return``}}export{f as extendChildren,u as hasChildWithProps,p as onlyText,d as rangeStep,l as sleep};
//# sourceMappingURL=utils.js.map