Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@namelessdev/flow

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@namelessdev/flow - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+1
-1
build/esm/If.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/If.tsx"],"names":["True","False"],"mappings":"AAAA,OAAO,WAAiC;AACxC,SAAS,eAAe;AACxB,SAAS,SAAe,YAAY;AAO7B,MAAM,KAAkB,CAAC,EAAE,MAAM,SAAS,MAAM;AACrD,QAAM,EAAE,MAAAA,OAAM,OAAAC,OAAM,IAAI,QAAQ,UAAU,QAAQ,OAAO;AAEzD,SAAO,QAAQ,KAAK,MAAM,oCAACD,OAAA,IAAK,GAAI,oCAACC,QAAA,IAAM,CAAE;AAC/C;AAGO,MAAM,OAAqB,KAAK,MAAM;AAEtC,MAAM,QAAsB,KAAK,OAAO","sourcesContent":["import React, { FC, ReactElement } from \"react\";\nimport { Logical } from \"@namelessdev/helper\";\nimport { retrive, Slot, slot } from \"@namelessdev/slots\";\n\ntype IfProps = {\n when: boolean;\n children: ReactElement | ReactElement[];\n};\n\nexport const If: FC<IfProps> = ({ when, children }) => {\n const { True, False } = retrive(children, \"true\", \"false\");\n\n return Logical.when(when, <True />, <False />);\n};\n\n// @ts-ignore\nexport const True: Slot<\"true\"> = slot(\"true\");\n// @ts-ignore\nexport const False: Slot<\"true\"> = slot(\"false\");\n"]}
{"version":3,"sources":["../../src/If.tsx"],"names":["True","False"],"mappings":"AAAA,OAAO,WAAiC;AACxC,SAAS,eAAe;AACxB,SAAS,SAAe,YAAY;AAO7B,MAAM,KAAgB,CAAC,EAAE,MAAM,SAAS,MAAM;AACnD,QAAM,EAAE,MAAAA,OAAM,OAAAC,OAAM,IAAI,QAAQ,UAAU,QAAQ,OAAO;AAEzD,SAAO,QAAQ,KAAK,MAAM,oCAACD,OAAA,IAAK,GAAI,oCAACC,QAAA,IAAM,CAAE;AAC/C;AAEO,MAAM,OAAqB,KAAK,MAAM;AACtC,MAAM,QAAuB,KAAK,OAAO","sourcesContent":["import React, { FC, ReactElement } from \"react\";\nimport { Logical } from \"@namelessdev/helper\";\nimport { retrive, Slot, slot } from \"@namelessdev/slots\";\n\ntype Props = {\n when: boolean;\n children: ReactElement | ReactElement[];\n};\n\nexport const If: FC<Props> = ({ when, children }) => {\n const { True, False } = retrive(children, \"true\", \"false\");\n\n return Logical.when(when, <True />, <False />);\n};\n\nexport const True: Slot<\"true\"> = slot(\"true\");\nexport const False: Slot<\"false\"> = slot(\"false\");\n"]}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/Repeat.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAkC,YAA4B;AACrE,SAAS,WAAW;AAQb,MAAM,SAAgC;AAAA,EAC3C,CAAC,EAAE,OAAO,UAAU,MAAM,MACxB,oCAAC,OAAI,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,SACzD,QACH;AAEJ","sourcesContent":["import React, { ReactNode, ReactElement, memo, isValidElement } from \"react\";\nimport { For } from \"./For\";\n\ntype RepeatProps = {\n count: number;\n children: (item: number, index: number) => ReactNode;\n empty?: ReactNode | (() => ReactNode);\n};\n\nexport const Repeat: React.FC<RepeatProps> = memo(\n ({ count, children, empty }) => (\n <For items={Array.from({ length: count }).map((_, i) => i)} empty={empty}>\n {children}\n </For>\n ),\n);\n"]}
{"version":3,"sources":["../../src/Repeat.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAoB,YAAY;AACvC,SAAS,WAAW;AAQb,MAAM,SAAgC;AAAA,EAC3C,CAAC,EAAE,OAAO,UAAU,MAAM,MACxB,oCAAC,OAAI,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,SACzD,QACH;AAEJ","sourcesContent":["import React, { ReactNode, memo } from \"react\";\nimport { For } from \"./For\";\n\ntype RepeatProps = {\n count: number;\n children: (item: number, index: number) => ReactNode;\n empty?: ReactNode | (() => ReactNode);\n};\n\nexport const Repeat: React.FC<RepeatProps> = memo(\n ({ count, children, empty }) => (\n <For items={Array.from({ length: count }).map((_, i) => i)} empty={empty}>\n {children}\n </For>\n ),\n);\n"]}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/Show.tsx"],"names":[],"mappings":"AAAA,SAAS,eAAe;AASjB,MAAM,OAAsB,CAAC,EAAE,MAAM,UAAU,SAAS,MAAM;AACnE,SAAO,QAAQ,KAAK,MAAM,UAAU,YAAY,IAAI;AACtD","sourcesContent":["import { Logical } from \"@namelessdev/helper\";\nimport { FC, ReactNode } from \"react\";\n\ntype ShowProps = {\n when: boolean;\n fallback?: ReactNode;\n children: ReactNode;\n};\n\nexport const Show: FC<ShowProps> = ({ when, fallback, children }) => {\n return Logical.when(when, children, fallback || null);\n};\n"]}
{"version":3,"sources":["../../src/Show.tsx"],"names":[],"mappings":"AAAA,SAAS,eAAe;AASjB,MAAM,OAAkB,CAAC,EAAE,MAAM,UAAU,SAAS,MAAM;AAC/D,SAAO,QAAQ,KAAK,MAAM,UAAU,YAAY,IAAI;AACtD","sourcesContent":["import { Logical } from \"@namelessdev/helper\";\nimport { FC, ReactNode } from \"react\";\n\ntype Props = {\n when: boolean;\n fallback?: ReactNode;\n children: ReactNode;\n};\n\nexport const Show: FC<Props> = ({ when, fallback, children }) => {\n return Logical.when(when, children, fallback || null);\n};\n"]}

@@ -1,1 +0,1 @@

import e from"react";import{wrap as t,retrive as r}from"@namelessdev/slots";const l=({children:t,fallback:l})=>{const{Match:n}=r(t,{name:"match",filter:t=>e.isValidElement(t)&&t.props.when});return e.createElement(n,null,l)},n=t("match",(({children:e})=>e));export{n as Match,l as Switch};//# sourceMappingURL=Switch.js.map
import{retrive as e}from"@namelessdev/slots";import*as t from"effect/Match";const r=({children:r,target:n})=>{const{Match:o,Orelse:l}=e(r,"match","orelse");return t.type().pipe(...o.raw().map((e=>t.when(e.props.when,e.props.then))),t.orElse(l.raw()[0].props.then||(()=>null)))(n)};function n(e){return null}function o(e){return null}n.slot="orelse",o.slot="match",o.Default=n;export{n as Default,o as Match,r as Switch};//# sourceMappingURL=Switch.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/Switch.tsx"],"names":["Match"],"mappings":"AAAA,OAAO,WAA4C;AACnD,SAAS,SAAS,YAAY;AAOvB,MAAM,SAAgC,CAAC,EAAE,UAAU,SAAS,MAAM;AACvE,QAAM,EAAE,OAAAA,OAAM,IAAI,QAAQ,UAAU;AAAA,IAClC,MAAM;AAAA,IACN,QAAQ,CAAC,UACP,MAAM,eAAe,KAAK,KAAM,MAAuB,MAAM;AAAA,EACjE,CAAC;AACD,SAAO,oCAACA,QAAA,MAAO,QAAS;AAC1B;AAOO,MAAM,QAAwB,KAAK,SAAS,CAAC,EAAE,SAAS,MAAM,QAAQ","sourcesContent":["import React, { FC, ReactElement, ReactNode } from \"react\";\nimport { retrive, wrap } from \"@namelessdev/slots\";\n\ninterface SwitchProps {\n children: ReactElement | ReactElement[];\n fallback: ReactElement;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({ children, fallback }) => {\n const { Match } = retrive(children, {\n name: \"match\",\n filter: (child) =>\n React.isValidElement(child) && (child as ReactElement).props.when,\n });\n return <Match>{fallback}</Match>;\n};\n\ninterface MatchProps {\n when: boolean;\n children: ReactNode;\n}\n\nexport const Match: FC<MatchProps> = wrap(\"match\", ({ children }) => children);\n"]}
{"version":3,"sources":["../../src/Switch.tsx"],"names":["Match"],"mappings":"AAEA,SAAS,eAAe;AACxB,YAAY,OAAO;AAMnB,EAAE;AACK,MAAM,SAA0B,CAAC,EAAE,UAAU,OAAO,MAAM;AAC/D,QAAM,EAAE,OAAAA,QAAO,OAAO,IAAI,QAAQ,UAAU,SAAS,QAAQ;AAC7D,SAAO,EAAE,KAAU,EAAE;AAAA,IACnB,GAAIA,OAAM,IAAI,EAA0B,IAAI,CAAC,UAAU;AACrD,aAAO,EAAE,KAAK,MAAM,MAAM,MAAM,GAAG,MAAM,MAAM,MAAM,CAAC;AAAA,IACxD,CAAC;AAAA,IACD,EAAE;AAAA,MACC,OAAO,IAAI,EAA0B,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM;AAAA,IACnE;AAAA,EACF,EAAE,MAAM;AACV;AAWO,SAAS,QAAW,GAAoB;AAC7C,SAAO;AACT;AACA,QAAQ,OAAO;AAYR,SAAS,MAAS,GAAkB;AACzC,SAAO;AACT;AACA,MAAM,OAAO;AACb,MAAM,UAAU","sourcesContent":["// @ts-nocheck\nimport React, { FC, ReactElement, ReactNode } from \"react\";\nimport { retrive } from \"@namelessdev/slots\";\nimport * as M from \"effect/Match\";\n\ninterface SwitchProps {\n children: ReactNode;\n target: any;\n}\nM.number;\nexport const Switch: FC<SwitchProps> = ({ children, target }) => {\n const { Match, Orelse } = retrive(children, \"match\", \"orelse\");\n return M.type<any>().pipe(\n ...(Match.raw() as Array<ReactElement>).map((value) => {\n return M.when(value.props[\"when\"], value.props[\"then\"]);\n }),\n M.orElse(\n (Orelse.raw() as Array<ReactElement>)[0].props[\"then\"] || (() => null),\n ),\n )(target);\n};\n\ninterface DefaultProps<T> {\n then: (\n _: M.Types.WhenMatch<\n T,\n M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>\n >,\n ) => unknown;\n}\n\nexport function Default<T>(_: DefaultProps<T>) {\n return null;\n}\nDefault.slot = \"orelse\";\n\ninterface MatchProps<T> {\n when: M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>;\n then: (\n _: M.Types.WhenMatch<\n T,\n M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>\n >,\n ) => unknown;\n}\n\nexport function Match<T>(_: MatchProps<T>) {\n return null;\n}\nMatch.slot = \"match\";\nMatch.Default = Default;\n"]}
import { FC, ReactElement } from 'react';
import { Slot } from '@namelessdev/slots';
type IfProps = {
type Props = {
when: boolean;
children: ReactElement | ReactElement[];
};
declare const If: FC<IfProps>;
declare const If: FC<Props>;
declare const True: Slot<"true">;
declare const False: Slot<"true">;
declare const False: Slot<"false">;
export { False, If, True };
import { FC, ReactElement } from 'react';
import { Slot } from '@namelessdev/slots';
type IfProps = {
type Props = {
when: boolean;
children: ReactElement | ReactElement[];
};
declare const If: FC<IfProps>;
declare const If: FC<Props>;
declare const True: Slot<"true">;
declare const False: Slot<"true">;
declare const False: Slot<"false">;
export { False, If, True };

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/If.tsx"],"names":["True","False"],"mappings":"AAAA,OAAO,WAAiC;AACxC,SAAS,eAAe;AACxB,SAAS,SAAe,YAAY;AAO7B,MAAM,KAAkB,CAAC,EAAE,MAAM,SAAS,MAAM;AACrD,QAAM,EAAE,MAAAA,OAAM,OAAAC,OAAM,IAAI,QAAQ,UAAU,QAAQ,OAAO;AAEzD,SAAO,QAAQ,KAAK,MAAM,oCAACD,OAAA,IAAK,GAAI,oCAACC,QAAA,IAAM,CAAE;AAC/C;AAGO,MAAM,OAAqB,KAAK,MAAM;AAEtC,MAAM,QAAsB,KAAK,OAAO","sourcesContent":["import React, { FC, ReactElement } from \"react\";\nimport { Logical } from \"@namelessdev/helper\";\nimport { retrive, Slot, slot } from \"@namelessdev/slots\";\n\ntype IfProps = {\n when: boolean;\n children: ReactElement | ReactElement[];\n};\n\nexport const If: FC<IfProps> = ({ when, children }) => {\n const { True, False } = retrive(children, \"true\", \"false\");\n\n return Logical.when(when, <True />, <False />);\n};\n\n// @ts-ignore\nexport const True: Slot<\"true\"> = slot(\"true\");\n// @ts-ignore\nexport const False: Slot<\"true\"> = slot(\"false\");\n"]}
{"version":3,"sources":["../src/If.tsx"],"names":["True","False"],"mappings":"AAAA,OAAO,WAAiC;AACxC,SAAS,eAAe;AACxB,SAAS,SAAe,YAAY;AAO7B,MAAM,KAAgB,CAAC,EAAE,MAAM,SAAS,MAAM;AACnD,QAAM,EAAE,MAAAA,OAAM,OAAAC,OAAM,IAAI,QAAQ,UAAU,QAAQ,OAAO;AAEzD,SAAO,QAAQ,KAAK,MAAM,oCAACD,OAAA,IAAK,GAAI,oCAACC,QAAA,IAAM,CAAE;AAC/C;AAEO,MAAM,OAAqB,KAAK,MAAM;AACtC,MAAM,QAAuB,KAAK,OAAO","sourcesContent":["import React, { FC, ReactElement } from \"react\";\nimport { Logical } from \"@namelessdev/helper\";\nimport { retrive, Slot, slot } from \"@namelessdev/slots\";\n\ntype Props = {\n when: boolean;\n children: ReactElement | ReactElement[];\n};\n\nexport const If: FC<Props> = ({ when, children }) => {\n const { True, False } = retrive(children, \"true\", \"false\");\n\n return Logical.when(when, <True />, <False />);\n};\n\nexport const True: Slot<\"true\"> = slot(\"true\");\nexport const False: Slot<\"false\"> = slot(\"false\");\n"]}

@@ -9,1 +9,2 @@ export { Show } from './Show.mjs';

import '@namelessdev/slots';
import 'effect/Match';

@@ -9,1 +9,2 @@ export { Show } from './Show.js';

import '@namelessdev/slots';
import 'effect/Match';

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/Repeat.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAkC,YAA4B;AACrE,SAAS,WAAW;AAQb,MAAM,SAAgC;AAAA,EAC3C,CAAC,EAAE,OAAO,UAAU,MAAM,MACxB,oCAAC,OAAI,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,SACzD,QACH;AAEJ","sourcesContent":["import React, { ReactNode, ReactElement, memo, isValidElement } from \"react\";\nimport { For } from \"./For\";\n\ntype RepeatProps = {\n count: number;\n children: (item: number, index: number) => ReactNode;\n empty?: ReactNode | (() => ReactNode);\n};\n\nexport const Repeat: React.FC<RepeatProps> = memo(\n ({ count, children, empty }) => (\n <For items={Array.from({ length: count }).map((_, i) => i)} empty={empty}>\n {children}\n </For>\n ),\n);\n"]}
{"version":3,"sources":["../src/Repeat.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAoB,YAAY;AACvC,SAAS,WAAW;AAQb,MAAM,SAAgC;AAAA,EAC3C,CAAC,EAAE,OAAO,UAAU,MAAM,MACxB,oCAAC,OAAI,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,SACzD,QACH;AAEJ","sourcesContent":["import React, { ReactNode, memo } from \"react\";\nimport { For } from \"./For\";\n\ntype RepeatProps = {\n count: number;\n children: (item: number, index: number) => ReactNode;\n empty?: ReactNode | (() => ReactNode);\n};\n\nexport const Repeat: React.FC<RepeatProps> = memo(\n ({ count, children, empty }) => (\n <For items={Array.from({ length: count }).map((_, i) => i)} empty={empty}>\n {children}\n </For>\n ),\n);\n"]}
import { FC, ReactNode } from 'react';
type ShowProps = {
type Props = {
when: boolean;

@@ -8,4 +8,4 @@ fallback?: ReactNode;

};
declare const Show: FC<ShowProps>;
declare const Show: FC<Props>;
export { Show };
import { FC, ReactNode } from 'react';
type ShowProps = {
type Props = {
when: boolean;

@@ -8,4 +8,4 @@ fallback?: ReactNode;

};
declare const Show: FC<ShowProps>;
declare const Show: FC<Props>;
export { Show };

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/Show.tsx"],"names":[],"mappings":"AAAA,SAAS,eAAe;AASjB,MAAM,OAAsB,CAAC,EAAE,MAAM,UAAU,SAAS,MAAM;AACnE,SAAO,QAAQ,KAAK,MAAM,UAAU,YAAY,IAAI;AACtD","sourcesContent":["import { Logical } from \"@namelessdev/helper\";\nimport { FC, ReactNode } from \"react\";\n\ntype ShowProps = {\n when: boolean;\n fallback?: ReactNode;\n children: ReactNode;\n};\n\nexport const Show: FC<ShowProps> = ({ when, fallback, children }) => {\n return Logical.when(when, children, fallback || null);\n};\n"]}
{"version":3,"sources":["../src/Show.tsx"],"names":[],"mappings":"AAAA,SAAS,eAAe;AASjB,MAAM,OAAkB,CAAC,EAAE,MAAM,UAAU,SAAS,MAAM;AAC/D,SAAO,QAAQ,KAAK,MAAM,UAAU,YAAY,IAAI;AACtD","sourcesContent":["import { Logical } from \"@namelessdev/helper\";\nimport { FC, ReactNode } from \"react\";\n\ntype Props = {\n when: boolean;\n fallback?: ReactNode;\n children: ReactNode;\n};\n\nexport const Show: FC<Props> = ({ when, fallback, children }) => {\n return Logical.when(when, children, fallback || null);\n};\n"]}

@@ -1,14 +0,26 @@

import React, { FC, ReactElement, ReactNode } from 'react';
import { FC, ReactNode } from 'react';
import * as M from 'effect/Match';
interface SwitchProps {
children: ReactElement | ReactElement[];
fallback: ReactElement;
}
declare const Switch: React.FC<SwitchProps>;
interface MatchProps {
when: boolean;
children: ReactNode;
target: any;
}
declare const Match: FC<MatchProps>;
declare const Switch: FC<SwitchProps>;
interface DefaultProps<T> {
then: (_: M.Types.WhenMatch<T, M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>>) => unknown;
}
declare function Default<T>(_: DefaultProps<T>): null;
declare namespace Default {
var slot: string;
}
interface MatchProps<T> {
when: M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>;
then: (_: M.Types.WhenMatch<T, M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>>) => unknown;
}
declare function Match<T>(_: MatchProps<T>): null;
declare namespace Match {
var slot: string;
var Default: typeof Default;
}
export { Match, Switch };
export { Default, Match, Switch };

@@ -1,14 +0,26 @@

import React, { FC, ReactElement, ReactNode } from 'react';
import { FC, ReactNode } from 'react';
import * as M from 'effect/Match';
interface SwitchProps {
children: ReactElement | ReactElement[];
fallback: ReactElement;
}
declare const Switch: React.FC<SwitchProps>;
interface MatchProps {
when: boolean;
children: ReactNode;
target: any;
}
declare const Match: FC<MatchProps>;
declare const Switch: FC<SwitchProps>;
interface DefaultProps<T> {
then: (_: M.Types.WhenMatch<T, M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>>) => unknown;
}
declare function Default<T>(_: DefaultProps<T>): null;
declare namespace Default {
var slot: string;
}
interface MatchProps<T> {
when: M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>;
then: (_: M.Types.WhenMatch<T, M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>>) => unknown;
}
declare function Match<T>(_: MatchProps<T>): null;
declare namespace Match {
var slot: string;
var Default: typeof Default;
}
export { Match, Switch };
export { Default, Match, Switch };

@@ -1,1 +0,1 @@

"use strict";var e=require("react"),t=require("@namelessdev/slots");function r(e){return e&&e.__esModule?e:{default:e}}var a=r(e);const l=t.wrap("match",(({children:e})=>e));exports.Match=l,exports.Switch=({children:e,fallback:r})=>{const{Match:l}=t.retrive(e,{name:"match",filter:e=>a.default.isValidElement(e)&&e.props.when});return a.default.createElement(l,null,r)};//# sourceMappingURL=Switch.js.map
"use strict";var e=require("@namelessdev/slots");function t(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var r=t(require("effect/Match"));function n(e){return null}function u(e){return null}n.slot="orelse",u.slot="match",u.Default=n,exports.Default=n,exports.Match=u,exports.Switch=({children:t,target:n})=>{const{Match:u,Orelse:c}=e.retrive(t,"match","orelse");return r.type().pipe(...u.raw().map((e=>r.when(e.props.when,e.props.then))),r.orElse(c.raw()[0].props.then||(()=>null)))(n)};//# sourceMappingURL=Switch.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/Switch.tsx"],"names":["Match"],"mappings":"AAAA,OAAO,WAA4C;AACnD,SAAS,SAAS,YAAY;AAOvB,MAAM,SAAgC,CAAC,EAAE,UAAU,SAAS,MAAM;AACvE,QAAM,EAAE,OAAAA,OAAM,IAAI,QAAQ,UAAU;AAAA,IAClC,MAAM;AAAA,IACN,QAAQ,CAAC,UACP,MAAM,eAAe,KAAK,KAAM,MAAuB,MAAM;AAAA,EACjE,CAAC;AACD,SAAO,oCAACA,QAAA,MAAO,QAAS;AAC1B;AAOO,MAAM,QAAwB,KAAK,SAAS,CAAC,EAAE,SAAS,MAAM,QAAQ","sourcesContent":["import React, { FC, ReactElement, ReactNode } from \"react\";\nimport { retrive, wrap } from \"@namelessdev/slots\";\n\ninterface SwitchProps {\n children: ReactElement | ReactElement[];\n fallback: ReactElement;\n}\n\nexport const Switch: React.FC<SwitchProps> = ({ children, fallback }) => {\n const { Match } = retrive(children, {\n name: \"match\",\n filter: (child) =>\n React.isValidElement(child) && (child as ReactElement).props.when,\n });\n return <Match>{fallback}</Match>;\n};\n\ninterface MatchProps {\n when: boolean;\n children: ReactNode;\n}\n\nexport const Match: FC<MatchProps> = wrap(\"match\", ({ children }) => children);\n"]}
{"version":3,"sources":["../src/Switch.tsx"],"names":["Match"],"mappings":"AAEA,SAAS,eAAe;AACxB,YAAY,OAAO;AAMnB,EAAE;AACK,MAAM,SAA0B,CAAC,EAAE,UAAU,OAAO,MAAM;AAC/D,QAAM,EAAE,OAAAA,QAAO,OAAO,IAAI,QAAQ,UAAU,SAAS,QAAQ;AAC7D,SAAO,EAAE,KAAU,EAAE;AAAA,IACnB,GAAIA,OAAM,IAAI,EAA0B,IAAI,CAAC,UAAU;AACrD,aAAO,EAAE,KAAK,MAAM,MAAM,MAAM,GAAG,MAAM,MAAM,MAAM,CAAC;AAAA,IACxD,CAAC;AAAA,IACD,EAAE;AAAA,MACC,OAAO,IAAI,EAA0B,CAAC,EAAE,MAAM,MAAM,MAAM,MAAM;AAAA,IACnE;AAAA,EACF,EAAE,MAAM;AACV;AAWO,SAAS,QAAW,GAAoB;AAC7C,SAAO;AACT;AACA,QAAQ,OAAO;AAYR,SAAS,MAAS,GAAkB;AACzC,SAAO;AACT;AACA,MAAM,OAAO;AACb,MAAM,UAAU","sourcesContent":["// @ts-nocheck\nimport React, { FC, ReactElement, ReactNode } from \"react\";\nimport { retrive } from \"@namelessdev/slots\";\nimport * as M from \"effect/Match\";\n\ninterface SwitchProps {\n children: ReactNode;\n target: any;\n}\nM.number;\nexport const Switch: FC<SwitchProps> = ({ children, target }) => {\n const { Match, Orelse } = retrive(children, \"match\", \"orelse\");\n return M.type<any>().pipe(\n ...(Match.raw() as Array<ReactElement>).map((value) => {\n return M.when(value.props[\"when\"], value.props[\"then\"]);\n }),\n M.orElse(\n (Orelse.raw() as Array<ReactElement>)[0].props[\"then\"] || (() => null),\n ),\n )(target);\n};\n\ninterface DefaultProps<T> {\n then: (\n _: M.Types.WhenMatch<\n T,\n M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>\n >,\n ) => unknown;\n}\n\nexport function Default<T>(_: DefaultProps<T>) {\n return null;\n}\nDefault.slot = \"orelse\";\n\ninterface MatchProps<T> {\n when: M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>;\n then: (\n _: M.Types.WhenMatch<\n T,\n M.Types.PatternPrimitive<T> | M.Types.PatternBase<T>\n >,\n ) => unknown;\n}\n\nexport function Match<T>(_: MatchProps<T>) {\n return null;\n}\nMatch.slot = \"match\";\nMatch.Default = Default;\n"]}
{
"name": "@namelessdev/flow",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

@@ -44,4 +44,5 @@ "main": "./build/index.js",

"dependencies": {
"@namelessdev/slots": "0.0.7",
"@namelessdev/helper": "0.0.2"
"effect": "^2.4.15",
"@namelessdev/helper": "0.0.3",
"@namelessdev/slots": "0.0.8"
},

@@ -48,0 +49,0 @@ "scripts": {