@zayne-labs/ui-react 0.0.4 → 0.0.5
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/dist/esm/common/show/index.d.ts +2 -1
- package/dist/esm/common/show/index.js +3 -2
- package/dist/esm/common/show/index.js.map +1 -1
- package/dist/esm/common/switch/index.d.ts +2 -1
- package/dist/esm/common/switch/index.js +4 -3
- package/dist/esm/common/switch/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,9 +14,10 @@ declare function ShowFallback({ children }: Pick<ShowProps, "children">): react.
|
|
|
14
14
|
declare namespace ShowFallback {
|
|
15
15
|
var slot: symbol;
|
|
16
16
|
}
|
|
17
|
+
declare const Show: typeof ShowRoot;
|
|
17
18
|
declare const Root: typeof ShowRoot;
|
|
18
19
|
declare const Fallback: typeof ShowFallback;
|
|
19
20
|
declare const Content: typeof ShowContent;
|
|
20
21
|
declare const OtherWise: typeof ShowFallback;
|
|
21
22
|
|
|
22
|
-
export { Content, Fallback, OtherWise, Root, ShowContent, ShowFallback, ShowRoot };
|
|
23
|
+
export { Content, Fallback, OtherWise, Root, Show, ShowContent, ShowFallback, ShowRoot };
|
|
@@ -27,12 +27,13 @@ ShowContent.slot = Symbol.for("content");
|
|
|
27
27
|
function ShowFallback({ children }) {
|
|
28
28
|
return children;
|
|
29
29
|
}
|
|
30
|
-
ShowFallback.slot = Symbol.for("fallback");
|
|
30
|
+
ShowFallback.slot = Symbol.for("show-fallback");
|
|
31
|
+
var Show = ShowRoot;
|
|
31
32
|
var Root = ShowRoot;
|
|
32
33
|
var Fallback = ShowFallback;
|
|
33
34
|
var Content = ShowContent;
|
|
34
35
|
var OtherWise = ShowFallback;
|
|
35
36
|
|
|
36
|
-
export { Content, Fallback, OtherWise, Root, ShowContent, ShowFallback, ShowRoot };
|
|
37
|
+
export { Content, Fallback, OtherWise, Root, Show, ShowContent, ShowFallback, ShowRoot };
|
|
37
38
|
//# sourceMappingURL=index.js.map
|
|
38
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/common/show/show.tsx"],"names":[],"mappings":";;;;;AAaO,SAAS,QAAS,CAAA,EAAE,QAAU,EAAA,QAAA,EAAU,MAAmB,EAAA;AACjE,EAAM,MAAA,YAAA,GAAe,cAAe,CAAA,QAAA,EAAU,YAAc,EAAA;AAAA,IAC3D,YAAc,EAAA,mEAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAM,MAAA,WAAA,GAAc,cAAe,CAAA,QAAA,EAAU,WAAa,EAAA;AAAA,IACzD,YAAc,EAAA,8CAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAA,MAAM,gBAAgB,gBAAiB,CAAA,QAAA,EAAU,CAAC,YAAA,EAAc,WAAW,CAAC,CAAA;AAE5E,EAAA,IAAI,gBAAgB,QAAU,EAAA;AAC7B,IAAA,MAAM,IAAI,cAAe,CAAA;AAAA;AAAA,EAExB,CAAA,CAAA;AAAA;AAGF,EAAO,OAAA,IAAA,GAAQ,WAAe,IAAA,aAAA,GAAkB,YAAgB,IAAA,QAAA;AACjE;AAEO,SAAS,WAAA,CAAY,EAAE,QAAA,EAAyC,EAAA;AACtE,EAAO,OAAA,QAAA;AACR;AACA,WAAY,CAAA,IAAA,GAAO,MAAO,CAAA,GAAA,CAAI,SAAS,CAAA;AAEhC,SAAS,YAAA,CAAa,EAAE,QAAA,EAAyC,EAAA;AACvE,EAAO,OAAA,QAAA;AACR;AACA,YAAa,CAAA,IAAA,GAAO,MAAO,CAAA,GAAA,CAAI,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/common/show/show.tsx"],"names":[],"mappings":";;;;;AAaO,SAAS,QAAS,CAAA,EAAE,QAAU,EAAA,QAAA,EAAU,MAAmB,EAAA;AACjE,EAAM,MAAA,YAAA,GAAe,cAAe,CAAA,QAAA,EAAU,YAAc,EAAA;AAAA,IAC3D,YAAc,EAAA,mEAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAM,MAAA,WAAA,GAAc,cAAe,CAAA,QAAA,EAAU,WAAa,EAAA;AAAA,IACzD,YAAc,EAAA,8CAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAA,MAAM,gBAAgB,gBAAiB,CAAA,QAAA,EAAU,CAAC,YAAA,EAAc,WAAW,CAAC,CAAA;AAE5E,EAAA,IAAI,gBAAgB,QAAU,EAAA;AAC7B,IAAA,MAAM,IAAI,cAAe,CAAA;AAAA;AAAA,EAExB,CAAA,CAAA;AAAA;AAGF,EAAO,OAAA,IAAA,GAAQ,WAAe,IAAA,aAAA,GAAkB,YAAgB,IAAA,QAAA;AACjE;AAEO,SAAS,WAAA,CAAY,EAAE,QAAA,EAAyC,EAAA;AACtE,EAAO,OAAA,QAAA;AACR;AACA,WAAY,CAAA,IAAA,GAAO,MAAO,CAAA,GAAA,CAAI,SAAS,CAAA;AAEhC,SAAS,YAAA,CAAa,EAAE,QAAA,EAAyC,EAAA;AACvE,EAAO,OAAA,QAAA;AACR;AACA,YAAa,CAAA,IAAA,GAAO,MAAO,CAAA,GAAA,CAAI,eAAe,CAAA;AAEvC,IAAM,IAAO,GAAA;AAEb,IAAM,IAAO,GAAA;AAEb,IAAM,QAAW,GAAA;AAEjB,IAAM,OAAU,GAAA;AAEhB,IAAM,SAAY,GAAA","file":"index.js","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { getOtherChildren, getSlotElement } from \"@zayne-labs/toolkit-react/utils\";\nimport { AssertionError } from \"@zayne-labs/toolkit-type-helpers\";\n\ntype ShowProps = {\n\tchildren: React.ReactNode;\n\tfallback?: React.ReactNode;\n\twhen: boolean;\n};\n\nexport function ShowRoot({ children, fallback, when }: ShowProps) {\n\tconst fallBackSlot = getSlotElement(children, ShowFallback, {\n\t\terrorMessage: \"Only one <Show.Fallback> or <Show.OtherWise> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst contentSlot = getSlotElement(children, ShowContent, {\n\t\terrorMessage: \"Only one <Show.Content> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst otherChildren = getOtherChildren(children, [ShowFallback, ShowContent]);\n\n\tif (fallBackSlot && fallback) {\n\t\tthrow new AssertionError(`\n\t\t\tThe fallback prop and <Show.Fallback>/<Show.OtherWise> cannot be used at the same time.\n\t\t`);\n\t}\n\n\treturn when ? (contentSlot ?? otherChildren) : (fallBackSlot ?? fallback);\n}\n\nexport function ShowContent({ children }: Pick<ShowProps, \"children\">) {\n\treturn children;\n}\nShowContent.slot = Symbol.for(\"content\");\n\nexport function ShowFallback({ children }: Pick<ShowProps, \"children\">) {\n\treturn children;\n}\nShowFallback.slot = Symbol.for(\"show-fallback\");\n\nexport const Show = ShowRoot;\n\nexport const Root = ShowRoot;\n\nexport const Fallback = ShowFallback;\n\nexport const Content = ShowContent;\n\nexport const OtherWise = ShowFallback;\n"]}
|
|
@@ -15,8 +15,9 @@ declare function SwitchDefault({ children }: Pick<SwitchMatchProps, "children">)
|
|
|
15
15
|
declare namespace SwitchDefault {
|
|
16
16
|
var slot: symbol;
|
|
17
17
|
}
|
|
18
|
+
declare const Switch: typeof SwitchRoot;
|
|
18
19
|
declare const Root: typeof SwitchRoot;
|
|
19
20
|
declare const Match: typeof SwitchMatch;
|
|
20
21
|
declare const Default: typeof SwitchDefault;
|
|
21
22
|
|
|
22
|
-
export { Default, Match, Root, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
23
|
+
export { Default, Match, Root, Switch, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
@@ -4,7 +4,7 @@ import { getSlotElement, getOtherChildren } from '@zayne-labs/toolkit-react/util
|
|
|
4
4
|
// src/components/common/switch/switch.tsx
|
|
5
5
|
function SwitchRoot(props) {
|
|
6
6
|
const { children, condition = true } = props;
|
|
7
|
-
const defaultCase = getSlotElement(children,
|
|
7
|
+
const defaultCase = getSlotElement(children, SwitchDefault, {
|
|
8
8
|
errorMessage: "Only one <Switch.Default> component is allowed",
|
|
9
9
|
throwOnMultipleSlotMatch: true
|
|
10
10
|
});
|
|
@@ -18,11 +18,12 @@ function SwitchMatch({ children }) {
|
|
|
18
18
|
function SwitchDefault({ children }) {
|
|
19
19
|
return children;
|
|
20
20
|
}
|
|
21
|
-
SwitchDefault.slot = Symbol.for("default
|
|
21
|
+
SwitchDefault.slot = Symbol.for("switch-default");
|
|
22
|
+
var Switch = SwitchRoot;
|
|
22
23
|
var Root = SwitchRoot;
|
|
23
24
|
var Match = SwitchMatch;
|
|
24
25
|
var Default = SwitchDefault;
|
|
25
26
|
|
|
26
|
-
export { Default, Match, Root, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
27
|
+
export { Default, Match, Root, Switch, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
|
28
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/common/switch/switch.tsx"],"names":[],"mappings":";;;;AAkBO,SAAS,WAA8B,KAAgC,EAAA;AAC7E,EAAA,MAAM,EAAE,QAAA,EAAU,SAAY,GAAA,IAAA,EAAS,GAAA,KAAA;AAEvC,EAAM,MAAA,WAAA,GAAc,cAAe,CAAA,QAAA,EAAU,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/common/switch/switch.tsx"],"names":[],"mappings":";;;;AAkBO,SAAS,WAA8B,KAAgC,EAAA;AAC7E,EAAA,MAAM,EAAE,QAAA,EAAU,SAAY,GAAA,IAAA,EAAS,GAAA,KAAA;AAEvC,EAAM,MAAA,WAAA,GAAc,cAAe,CAAA,QAAA,EAAU,aAAe,EAAA;AAAA,IAC3D,YAAc,EAAA,gDAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAM,MAAA,kBAAA,GAAqB,gBAAiB,CAAA,QAAA,EAAU,OAAO,CAAA;AAE7D,EAAM,MAAA,WAAA,GAAc,mBAAmB,IAAK,CAAA,CAAC,UAAU,KAAM,CAAA,KAAA,CAAM,SAAS,SAAS,CAAA;AAErF,EAAA,OAAO,WAAe,IAAA,WAAA;AACvB;AAEO,SAAS,WAAA,CAAmB,EAAE,QAAA,EAAqC,EAAA;AACzE,EAAO,OAAA,QAAA;AACR;AAEO,SAAS,aAAA,CAAc,EAAE,QAAA,EAAgD,EAAA;AAC/E,EAAO,OAAA,QAAA;AACR;AACA,aAAc,CAAA,IAAA,GAAO,MAAO,CAAA,GAAA,CAAI,gBAAgB,CAAA;AAEzC,IAAM,MAAS,GAAA;AAEf,IAAM,IAAO,GAAA;AAEb,IAAM,KAAQ,GAAA;AAEd,IAAM,OAAU,GAAA","file":"index.js","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { getOtherChildren, getSlotElement } from \"@zayne-labs/toolkit-react/utils\";\n\ntype ValidSwitchComponentType = React.ReactElement<SwitchMatchProps>;\n\ntype SwitchProps<TCondition> = {\n\tchildren: ValidSwitchComponentType | ValidSwitchComponentType[];\n\tcondition?: TCondition;\n};\n\ntype SwitchMatchProps<TWhen = boolean> = {\n\tchildren: React.ReactNode;\n\twhen: TWhen;\n};\n\nexport function SwitchRoot<TCondition = true>(props: SwitchProps<TCondition>) {\n\tconst { children, condition = true } = props;\n\n\tconst defaultCase = getSlotElement(children, SwitchDefault, {\n\t\terrorMessage: \"Only one <Switch.Default> component is allowed\",\n\t\tthrowOnMultipleSlotMatch: true,\n\t});\n\n\tconst childrenCasesArray = getOtherChildren(children, Default);\n\n\tconst matchedCase = childrenCasesArray.find((child) => child.props.when === condition);\n\n\treturn matchedCase ?? defaultCase;\n}\n\nexport function SwitchMatch<TWhen>({ children }: SwitchMatchProps<TWhen>) {\n\treturn children;\n}\n\nexport function SwitchDefault({ children }: Pick<SwitchMatchProps, \"children\">) {\n\treturn children;\n}\nSwitchDefault.slot = Symbol.for(\"switch-default\");\n\nexport const Switch = SwitchRoot;\n\nexport const Root = SwitchRoot;\n\nexport const Match = SwitchMatch;\n\nexport const Default = SwitchDefault;\n"]}
|