@zayne-labs/ui-react 0.0.9 → 0.1.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/dist/esm/chunk-ENDWJXPF.js +1 -1
- package/dist/esm/chunk-ENDWJXPF.js.map +1 -1
- package/dist/esm/{chunk-GBLTOENX.js → chunk-MPOYLILK.js} +6 -8
- package/dist/esm/chunk-MPOYLILK.js.map +1 -0
- package/dist/esm/chunk-PZ5AY32C.js +9 -0
- package/dist/esm/chunk-PZ5AY32C.js.map +1 -0
- package/dist/esm/common/for/index.d.ts +4 -4
- package/dist/esm/common/for/index.js +2 -1
- package/dist/esm/common/show/index.d.ts +10 -6
- package/dist/esm/common/show/index.js +10 -6
- package/dist/esm/common/show/index.js.map +1 -1
- package/dist/esm/common/slot/index.js +1 -0
- package/dist/esm/common/switch/index.d.ts +2 -5
- package/dist/esm/common/switch/index.js +4 -7
- package/dist/esm/common/switch/index.js.map +1 -1
- package/dist/esm/common/teleport/index.js +1 -1
- package/dist/esm/{for-BmvZgK9J.d.ts → for-C3T5FbXd.d.ts} +1 -3
- package/dist/esm/ui/card/index.d.ts +5 -7
- package/dist/esm/ui/card/index.js +13 -7
- package/dist/esm/ui/card/index.js.map +1 -1
- package/dist/esm/ui/carousel/index.d.ts +7 -12
- package/dist/esm/ui/carousel/index.js +31 -19
- package/dist/esm/ui/carousel/index.js.map +1 -1
- package/dist/esm/ui/drag-scroll/index.d.ts +285 -4
- package/dist/esm/ui/drag-scroll/index.js +41 -21
- package/dist/esm/ui/drag-scroll/index.js.map +1 -1
- package/dist/esm/ui/drop-zone/index.d.ts +24 -14
- package/dist/esm/ui/drop-zone/index.js +45 -44
- package/dist/esm/ui/drop-zone/index.js.map +1 -1
- package/dist/esm/ui/form/index.d.ts +26 -32
- package/dist/esm/ui/form/index.js +67 -39
- package/dist/esm/ui/form/index.js.map +1 -1
- package/package.json +10 -10
- package/dist/esm/chunk-GBLTOENX.js.map +0 -1
|
@@ -25,7 +25,7 @@ function Slot(props) {
|
|
|
25
25
|
}
|
|
26
26
|
return child;
|
|
27
27
|
});
|
|
28
|
-
return /* @__PURE__ */ React.createElement(SlotClone, { ...restOfSlotProps }, isValidElement(newElement) && cloneElement(newElement,
|
|
28
|
+
return /* @__PURE__ */ React.createElement(SlotClone, { ...restOfSlotProps }, isValidElement(newElement) && cloneElement(newElement, undefined, newElementChildren));
|
|
29
29
|
}
|
|
30
30
|
return /* @__PURE__ */ React.createElement(SlotClone, { ...restOfSlotProps }, children);
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/common/slot/slot.tsx"],"names":[],"mappings":";;;;;;AAYO,SAAS,SAAA,CAAU,EAAE,QAAA,EAAyC,EAAA;AACpE,EAAO,OAAA,QAAA;AACR;AAEA,IAAM,WAAA,GAAc,CAAC,KAAwD,KAAA;AAC5E,EAAA,OAAO,cAAe,CAAA,KAAK,CAAK,IAAA,KAAA,CAAM,IAAS,KAAA,SAAA;AAChD,CAAA;AAMO,SAAS,KAAK,KAAkB,EAAA;AACtC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,eAAA,EAAoB,GAAA,KAAA;AAEzC,EAAA,MAAM,gBAAgB,OAAyB,CAAA,QAAQ,CAAI,GAAA,QAAA,GAAW,CAAC,QAAQ,CAAA;AAC/E,EAAA,MAAM,YAAY,aAAc,CAAA,IAAA,CAAK,CAAC,OAAY,KAAA,WAAA,CAAY,OAAO,CAAC,CAAA;AAEtE,EAAA,IAAI,SAAW,EAAA;AAEd,IAAM,MAAA,UAAA,GAAc,UAAU,KAAoB,CAAA,QAAA;AAElD,IAAA,IAAI,QAAS,CAAA,KAAA,CAAM,UAAU,CAAA,GAAI,CAAG,EAAA;AACnC,MAAO,OAAA,QAAA,CAAS,KAAK,IAAI,CAAA;AAAA;AAG1B,IAAA,MAAM,kBAAqB,GAAA,aAAA,CAAc,GAAI,CAAA,CAAC,KAAU,KAAA;AACvD,MAAA,IAAI,UAAU,SAAW,EAAA;AAExB,QAAA,OAAO,cAA0B,CAAA,UAAU,CAAK,IAAA,UAAA,CAAW,KAAM,CAAA,QAAA;AAAA;AAGlE,MAAO,OAAA,KAAA;AAAA,KACP,CAAA;AAED,IACC,uBAAA,KAAA,CAAA,aAAA,CAAC,SAAW,EAAA,EAAA,GAAG,eACb,EAAA,EAAA,cAAA,CAAe,UAAU,CAAA,IAAK,YAAa,CAAA,UAAA,EAAY,
|
|
1
|
+
{"version":3,"sources":["../../src/components/common/slot/slot.tsx"],"names":[],"mappings":";;;;;;AAYO,SAAS,SAAA,CAAU,EAAE,QAAA,EAAyC,EAAA;AACpE,EAAO,OAAA,QAAA;AACR;AAEA,IAAM,WAAA,GAAc,CAAC,KAAwD,KAAA;AAC5E,EAAA,OAAO,cAAe,CAAA,KAAK,CAAK,IAAA,KAAA,CAAM,IAAS,KAAA,SAAA;AAChD,CAAA;AAMO,SAAS,KAAK,KAAkB,EAAA;AACtC,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,eAAA,EAAoB,GAAA,KAAA;AAEzC,EAAA,MAAM,gBAAgB,OAAyB,CAAA,QAAQ,CAAI,GAAA,QAAA,GAAW,CAAC,QAAQ,CAAA;AAC/E,EAAA,MAAM,YAAY,aAAc,CAAA,IAAA,CAAK,CAAC,OAAY,KAAA,WAAA,CAAY,OAAO,CAAC,CAAA;AAEtE,EAAA,IAAI,SAAW,EAAA;AAEd,IAAM,MAAA,UAAA,GAAc,UAAU,KAAoB,CAAA,QAAA;AAElD,IAAA,IAAI,QAAS,CAAA,KAAA,CAAM,UAAU,CAAA,GAAI,CAAG,EAAA;AACnC,MAAO,OAAA,QAAA,CAAS,KAAK,IAAI,CAAA;AAAA;AAG1B,IAAA,MAAM,kBAAqB,GAAA,aAAA,CAAc,GAAI,CAAA,CAAC,KAAU,KAAA;AACvD,MAAA,IAAI,UAAU,SAAW,EAAA;AAExB,QAAA,OAAO,cAA0B,CAAA,UAAU,CAAK,IAAA,UAAA,CAAW,KAAM,CAAA,QAAA;AAAA;AAGlE,MAAO,OAAA,KAAA;AAAA,KACP,CAAA;AAED,IACC,uBAAA,KAAA,CAAA,aAAA,CAAC,SAAW,EAAA,EAAA,GAAG,eACb,EAAA,EAAA,cAAA,CAAe,UAAU,CAAA,IAAK,YAAa,CAAA,UAAA,EAAY,SAAW,EAAA,kBAAkB,CACtF,CAAA;AAAA;AAIF,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,SAAA,EAAA,EAAW,GAAG,eAAA,EAAA,EAAkB,QAAS,CAAA;AAClD;AASA,SAAS,UAAU,KAAuB,EAAA;AACzC,EAAA,MAAM,EAAE,QAAU,EAAA,GAAA,EAAK,YAAc,EAAA,GAAG,iBAAoB,GAAA,KAAA;AAE5D,EAAI,IAAA,CAAC,cAA6B,CAAA,QAAQ,CAAG,EAAA;AAC5C,IAAO,OAAA,QAAA,CAAS,MAAM,QAAQ,CAAA,GAAI,IAAI,QAAS,CAAA,IAAA,CAAK,IAAI,CAAI,GAAA,IAAA;AAAA;AAG7D,EAAA,MAAM,QAAW,GAAA,QAAA,CAAS,KAAM,CAAA,GAAA,IAAQ,QAAqC,CAAA,GAAA;AAE7E,EAAA,MAAM,WAAc,GAAA;AAAA,IACnB,GAAG,UAAA,CAAW,eAAiB,EAAA,QAAA,CAAS,KAAK,CAAA;AAAA,IAC7C,KAAK,YAAe,GAAA,WAAA,CAAY,CAAC,YAAc,EAAA,QAA8B,CAAC,CAAI,GAAA;AAAA,GACnF;AAEA,EAAO,OAAA,YAAA,CAAa,UAAU,WAAW,CAAA;AAC1C","file":"chunk-ENDWJXPF.js","sourcesContent":["import * as React from \"react\";\n\nimport { type InferProps, composeRefs, mergeProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray } from \"@zayne-labs/toolkit-type-helpers\";\nimport { Children, cloneElement, isValidElement } from \"react\";\n\ntype SlotProps = InferProps<HTMLElement>;\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * ----------------------------------------------------------------------------------------------- */\n\nexport function Slottable({ children }: Pick<SlotProps, \"children\">) {\n\treturn children;\n}\n\nconst isSlottable = (child: React.ReactNode): child is React.ReactElement => {\n\treturn isValidElement(child) && child.type === Slottable;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * ----------------------------------------------------------------------------------------------- */\n\nexport function Slot(props: SlotProps) {\n\tconst { children, ...restOfSlotProps } = props;\n\n\tconst childrenArray = isArray<React.ReactNode>(children) ? children : [children];\n\tconst slottable = childrenArray.find((element) => isSlottable(element));\n\n\tif (slottable) {\n\t\t// == The new element to render is the one passed as a child of `Slottable`\n\t\tconst newElement = (slottable.props as SlotProps).children;\n\n\t\tif (Children.count(newElement) > 1) {\n\t\t\treturn Children.only(null);\n\t\t}\n\n\t\tconst newElementChildren = childrenArray.map((child) => {\n\t\t\tif (child === slottable) {\n\t\t\t\t// == Because the new element will be the one rendered, we are only interested in grabbing its children (`newElement.props.children`)\n\t\t\t\treturn isValidElement<SlotProps>(newElement) && newElement.props.children;\n\t\t\t}\n\n\t\t\treturn child;\n\t\t});\n\n\t\treturn (\n\t\t\t<SlotClone {...restOfSlotProps}>\n\t\t\t\t{isValidElement(newElement) && cloneElement(newElement, undefined, newElementChildren)}\n\t\t\t</SlotClone>\n\t\t);\n\t}\n\n\treturn <SlotClone {...restOfSlotProps}>{children}</SlotClone>;\n}\n\ntype SlotCloneProps = {\n\tchildren: React.ReactNode;\n\tref?: React.RefObject<HTMLElement>;\n};\n\ntype UnknownProps = Record<string, unknown>;\n\nfunction SlotClone(props: SlotCloneProps) {\n\tconst { children, ref: forwardedRef, ...restOfSlotProps } = props;\n\n\tif (!isValidElement<UnknownProps>(children)) {\n\t\treturn Children.count(children) > 1 ? Children.only(null) : null;\n\t}\n\n\tconst childRef = children.props.ref ?? (children as unknown as UnknownProps).ref;\n\n\tconst clonedProps = {\n\t\t...mergeProps(restOfSlotProps, children.props),\n\t\tref: forwardedRef ? composeRefs([forwardedRef, childRef as React.Ref<unknown>]) : childRef,\n\t};\n\n\treturn cloneElement(children, clonedProps);\n}\n"]}
|
|
@@ -19,24 +19,22 @@ function ForList(props) {
|
|
|
19
19
|
const { as: ListContainer = "ul", children, className, each, ref, render, ...restOfListProps } = props;
|
|
20
20
|
return /* @__PURE__ */ React.createElement(ListContainer, { ref, className, ...restOfListProps }, /* @__PURE__ */ React.createElement(ForBase, { ...{ children, each, render } }));
|
|
21
21
|
}
|
|
22
|
-
var Base = ForBase;
|
|
23
|
-
var List = ForList;
|
|
24
22
|
|
|
25
23
|
// src/components/common/for/getElementList.ts
|
|
26
24
|
var getElementList = (variant) => {
|
|
27
25
|
switch (variant) {
|
|
28
26
|
case "base": {
|
|
29
|
-
return [
|
|
27
|
+
return [ForBase];
|
|
30
28
|
}
|
|
31
29
|
case "withWrapper": {
|
|
32
|
-
return [
|
|
30
|
+
return [ForList];
|
|
33
31
|
}
|
|
34
32
|
default: {
|
|
35
|
-
return [
|
|
33
|
+
return [ForList];
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
};
|
|
39
37
|
|
|
40
|
-
export {
|
|
41
|
-
//# sourceMappingURL=chunk-
|
|
42
|
-
//# sourceMappingURL=chunk-
|
|
38
|
+
export { ForBase, ForList, getElementList };
|
|
39
|
+
//# sourceMappingURL=chunk-MPOYLILK.js.map
|
|
40
|
+
//# sourceMappingURL=chunk-MPOYLILK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/common/for/for.tsx","../../src/components/common/for/getElementList.ts"],"names":[],"mappings":";;;;AAkBO,SAAS,QAAoB,KAA6B,EAAA;AAChE,EAAA,MAAM,EAAE,QAAA,EAAU,IAAM,EAAA,MAAA,EAAW,GAAA,KAAA;AAEnC,EAAI,IAAA,CAAC,OAAQ,CAAA,IAAI,CAAG,EAAA;AACnB,IAAO,OAAA,IAAA;AAAA;AAGR,EAAA,MAAM,cAAiB,GAAA,IAAA,CAAK,GAAI,CAAA,CAAA,GAAI,MAAiD,KAAA;AACpF,IAAI,IAAA,OAAO,aAAa,UAAY,EAAA;AACnC,MAAO,OAAA,QAAA,CAAS,GAAG,MAAM,CAAA;AAAA;AAG1B,IAAO,OAAA,MAAA,CAAO,GAAG,MAAM,CAAA;AAAA,GACvB,CAAA;AAED,EAAO,OAAA,cAAA;AACR;AAEO,SAAS,QACf,KACC,EAAA;AACD,EAAM,MAAA,EAAE,EAAI,EAAA,aAAA,GAAgB,IAAM,EAAA,QAAA,EAAU,SAAW,EAAA,IAAA,EAAM,GAAK,EAAA,MAAA,EAAQ,GAAG,eAAA,EAAoB,GAAA,KAAA;AAEjG,EAAA,uBACE,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,EAAc,GAAU,EAAA,SAAA,EAAuB,GAAG,eAClD,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,OAAS,EAAA,EAAA,GAAI,EAAE,QAAA,EAAU,IAAM,EAAA,MAAA,IAAmC,CACpE,CAAA;AAEF;;;ACxCM,IAAA,cAAA,GAAiB,CACtB,OACoC,KAAA;AACpC,EAAA,QAAQ,OAAS;AAAA,IAChB,KAAK,MAAQ,EAAA;AACZ,MAAA,OAAO,CAAC,OAAO,CAAA;AAAA;AAChB,IACA,KAAK,aAAe,EAAA;AACnB,MAAA,OAAO,CAAC,OAAO,CAAA;AAAA;AAChB,IACA,SAAS;AACR,MAAA,OAAO,CAAC,OAAO,CAAA;AAAA;AAChB;AAEF","file":"chunk-MPOYLILK.js","sourcesContent":["import * as React from \"react\";\n\nimport type { DiscriminatedRenderProps, PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\nimport { isArray } from \"@zayne-labs/toolkit-type-helpers\";\n\n// prettier-ignore\ntype RenderPropFn<TArrayItem> = (\n\titem: TArrayItem,\n\tindex: number,\n\tarray: TArrayItem[]\n) => React.ReactNode;\n\nexport type EachProp<TArrayItem> = { each: TArrayItem[] };\n\nexport type ForRenderProps<TArrayItem> = DiscriminatedRenderProps<RenderPropFn<TArrayItem>>;\n\ntype ForProps<TArrayItem> = EachProp<TArrayItem> & ForRenderProps<TArrayItem>;\n\nexport function ForBase<TArrayItem>(props: ForProps<TArrayItem>) {\n\tconst { children, each, render } = props;\n\n\tif (!isArray(each)) {\n\t\treturn each;\n\t}\n\n\tconst JSXElementList = each.map((...params: Parameters<RenderPropFn<TArrayItem>>) => {\n\t\tif (typeof children === \"function\") {\n\t\t\treturn children(...params);\n\t\t}\n\n\t\treturn render(...params);\n\t});\n\n\treturn JSXElementList;\n}\n\nexport function ForList<TArrayItem, TElement extends React.ElementType = \"ul\">(\n\tprops: PolymorphicProps<TElement, ForProps<TArrayItem> & { className?: string }>\n) {\n\tconst { as: ListContainer = \"ul\", children, className, each, ref, render, ...restOfListProps } = props;\n\n\treturn (\n\t\t<ListContainer ref={ref} className={className} {...restOfListProps}>\n\t\t\t<ForBase {...({ children, each, render } as ForProps<TArrayItem>)} />\n\t\t</ListContainer>\n\t);\n}\n","import { ForBase, ForList } from \"./for\";\n\ntype GetElementListResult<TVariant extends \"base\" | \"withWrapper\"> = TVariant extends \"base\"\n\t? [typeof ForBase]\n\t: [typeof ForList];\n\nconst getElementList = <TVariant extends \"base\" | \"withWrapper\" = \"withWrapper\">(\n\tvariant?: TVariant\n): GetElementListResult<TVariant> => {\n\tswitch (variant) {\n\t\tcase \"base\": {\n\t\t\treturn [ForBase] as never;\n\t\t}\n\t\tcase \"withWrapper\": {\n\t\t\treturn [ForList] as never;\n\t\t}\n\t\tdefault: {\n\t\t\treturn [ForList] as never;\n\t\t}\n\t}\n};\n\nexport { getElementList };\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export { __export };
|
|
8
|
+
//# sourceMappingURL=chunk-PZ5AY32C.js.map
|
|
9
|
+
//# sourceMappingURL=chunk-PZ5AY32C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-PZ5AY32C.js"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { E as EachProp,
|
|
1
|
+
import { F as ForBase, a as ForList } from '../../for-C3T5FbXd.js';
|
|
2
|
+
export { E as EachProp, b as ForRenderProps } from '../../for-C3T5FbXd.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@zayne-labs/toolkit-react/utils';
|
|
5
5
|
|
|
6
|
-
type GetElementListResult<TVariant extends "base" | "withWrapper"> = TVariant extends "base" ? [typeof
|
|
6
|
+
type GetElementListResult<TVariant extends "base" | "withWrapper"> = TVariant extends "base" ? [typeof ForBase] : [typeof ForList];
|
|
7
7
|
declare const getElementList: <TVariant extends "base" | "withWrapper" = "withWrapper">(variant?: TVariant) => GetElementListResult<TVariant>;
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { ForBase, ForList, getElementList };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { ForBase, ForList, getElementList } from '../../chunk-MPOYLILK.js';
|
|
2
|
+
import '../../chunk-PZ5AY32C.js';
|
|
2
3
|
//# sourceMappingURL=index.js.map
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,6 +6,7 @@ type ShowProps = {
|
|
|
6
6
|
when: boolean;
|
|
7
7
|
};
|
|
8
8
|
declare function ShowRoot({ children, fallback, when }: ShowProps): react.ReactNode;
|
|
9
|
+
declare const Show: typeof ShowRoot;
|
|
9
10
|
declare function ShowContent({ children }: Pick<ShowProps, "children">): react.ReactNode;
|
|
10
11
|
declare namespace ShowContent {
|
|
11
12
|
var slot: symbol;
|
|
@@ -14,10 +15,13 @@ declare function ShowFallback({ children }: Pick<ShowProps, "children">): react.
|
|
|
14
15
|
declare namespace ShowFallback {
|
|
15
16
|
var slot: symbol;
|
|
16
17
|
}
|
|
17
|
-
declare const Show: typeof ShowRoot;
|
|
18
|
-
declare const Root: typeof ShowRoot;
|
|
19
|
-
declare const Fallback: typeof ShowFallback;
|
|
20
|
-
declare const Content: typeof ShowContent;
|
|
21
|
-
declare const OtherWise: typeof ShowFallback;
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
declare const show_Show: typeof Show;
|
|
20
|
+
declare const show_ShowContent: typeof ShowContent;
|
|
21
|
+
declare const show_ShowFallback: typeof ShowFallback;
|
|
22
|
+
declare const show_ShowRoot: typeof ShowRoot;
|
|
23
|
+
declare namespace show {
|
|
24
|
+
export { show_Show as Show, show_ShowContent as ShowContent, show_ShowFallback as ShowFallback, show_ShowRoot as ShowRoot };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { show as Show, ShowContent, ShowFallback, ShowRoot };
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { __export } from '../../chunk-PZ5AY32C.js';
|
|
1
2
|
import 'react';
|
|
2
3
|
import { getSlotElement, getOtherChildren } from '@zayne-labs/toolkit-react/utils';
|
|
3
4
|
import { AssertionError } from '@zayne-labs/toolkit-type-helpers';
|
|
4
5
|
|
|
5
6
|
// src/components/common/show/show.tsx
|
|
7
|
+
var show_exports = {};
|
|
8
|
+
__export(show_exports, {
|
|
9
|
+
Show: () => Show,
|
|
10
|
+
ShowContent: () => ShowContent,
|
|
11
|
+
ShowFallback: () => ShowFallback,
|
|
12
|
+
ShowRoot: () => ShowRoot
|
|
13
|
+
});
|
|
6
14
|
function ShowRoot({ children, fallback, when }) {
|
|
7
15
|
const fallBackSlot = getSlotElement(children, ShowFallback, {
|
|
8
16
|
errorMessage: "Only one <Show.Fallback> or <Show.OtherWise> component is allowed",
|
|
@@ -20,6 +28,7 @@ function ShowRoot({ children, fallback, when }) {
|
|
|
20
28
|
}
|
|
21
29
|
return when ? contentSlot ?? otherChildren : fallBackSlot ?? fallback;
|
|
22
30
|
}
|
|
31
|
+
var Show = ShowRoot;
|
|
23
32
|
function ShowContent({ children }) {
|
|
24
33
|
return children;
|
|
25
34
|
}
|
|
@@ -28,12 +37,7 @@ function ShowFallback({ children }) {
|
|
|
28
37
|
return children;
|
|
29
38
|
}
|
|
30
39
|
ShowFallback.slot = Symbol.for("show-fallback");
|
|
31
|
-
var Show = ShowRoot;
|
|
32
|
-
var Root = ShowRoot;
|
|
33
|
-
var Fallback = ShowFallback;
|
|
34
|
-
var Content = ShowContent;
|
|
35
|
-
var OtherWise = ShowFallback;
|
|
36
40
|
|
|
37
|
-
export {
|
|
41
|
+
export { show_exports as Show, ShowContent, ShowFallback, ShowRoot };
|
|
38
42
|
//# sourceMappingURL=index.js.map
|
|
39
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/common/show/show.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/common/show/show.tsx"],"names":[],"mappings":";;;;;;AAAA,IAAA,YAAA,GAAA;AAAA,QAAA,CAAA,YAAA,EAAA;AAAA,EAAA,IAAA,EAAA,MAAA,IAAA;AAAA,EAAA,WAAA,EAAA,MAAA,WAAA;AAAA,EAAA,YAAA,EAAA,MAAA,YAAA;AAAA,EAAA,QAAA,EAAA,MAAA;AAAA,CAAA,CAAA;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,IAAM,IAAO,GAAA,QAAA;AAEb,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","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 const Show = ShowRoot;\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"]}
|
|
@@ -10,14 +10,11 @@ type SwitchMatchProps<TWhen = boolean> = {
|
|
|
10
10
|
when: TWhen;
|
|
11
11
|
};
|
|
12
12
|
declare function SwitchRoot<TCondition = true>(props: SwitchProps<TCondition>): react.ReactElement<Pick<SwitchMatchProps<boolean>, "children">, string | react.JSXElementConstructor<any>> | undefined;
|
|
13
|
+
declare const Switch: typeof SwitchRoot;
|
|
13
14
|
declare function SwitchMatch<TWhen>({ children }: SwitchMatchProps<TWhen>): react.ReactNode;
|
|
14
15
|
declare function SwitchDefault({ children }: Pick<SwitchMatchProps, "children">): react.ReactNode;
|
|
15
16
|
declare namespace SwitchDefault {
|
|
16
17
|
var slot: symbol;
|
|
17
18
|
}
|
|
18
|
-
declare const Switch: typeof SwitchRoot;
|
|
19
|
-
declare const Root: typeof SwitchRoot;
|
|
20
|
-
declare const Match: typeof SwitchMatch;
|
|
21
|
-
declare const Default: typeof SwitchDefault;
|
|
22
19
|
|
|
23
|
-
export { Default, Match, Root, Switch, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
20
|
+
export { SwitchDefault as Default, SwitchMatch as Match, SwitchRoot as Root, Switch, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import '../../chunk-PZ5AY32C.js';
|
|
1
2
|
import 'react';
|
|
2
3
|
import { getSlotElement, getOtherChildren } from '@zayne-labs/toolkit-react/utils';
|
|
3
4
|
|
|
4
|
-
// src/components/common/switch/switch.tsx
|
|
5
5
|
function SwitchRoot(props) {
|
|
6
6
|
const { children, condition = true } = props;
|
|
7
7
|
const defaultCase = getSlotElement(children, SwitchDefault, {
|
|
8
8
|
errorMessage: "Only one <Switch.Default> component is allowed",
|
|
9
9
|
throwOnMultipleSlotMatch: true
|
|
10
10
|
});
|
|
11
|
-
const childrenCasesArray = getOtherChildren(children,
|
|
11
|
+
const childrenCasesArray = getOtherChildren(children, SwitchDefault);
|
|
12
12
|
const matchedCase = childrenCasesArray.find((child) => child.props.when === condition);
|
|
13
13
|
return matchedCase ?? defaultCase;
|
|
14
14
|
}
|
|
15
|
+
var Switch = SwitchRoot;
|
|
15
16
|
function SwitchMatch({ children }) {
|
|
16
17
|
return children;
|
|
17
18
|
}
|
|
@@ -19,11 +20,7 @@ function SwitchDefault({ children }) {
|
|
|
19
20
|
return children;
|
|
20
21
|
}
|
|
21
22
|
SwitchDefault.slot = Symbol.for("switch-default");
|
|
22
|
-
var Switch = SwitchRoot;
|
|
23
|
-
var Root = SwitchRoot;
|
|
24
|
-
var Match = SwitchMatch;
|
|
25
|
-
var Default = SwitchDefault;
|
|
26
23
|
|
|
27
|
-
export { Default, Match, Root, Switch, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
24
|
+
export { SwitchDefault as Default, SwitchMatch as Match, SwitchRoot as Root, Switch, SwitchDefault, SwitchMatch, SwitchRoot };
|
|
28
25
|
//# sourceMappingURL=index.js.map
|
|
29
26
|
//# 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,aAAe,EAAA;AAAA,IAC3D,YAAc,EAAA,gDAAA;AAAA,IACd,wBAA0B,EAAA;AAAA,GAC1B,CAAA;AAED,EAAM,MAAA,kBAAA,GAAqB,gBAAiB,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,aAAa,CAAA;AAEnE,EAAM,MAAA,WAAA,GAAc,mBAAmB,IAAK,CAAA,CAAC,UAAU,KAAM,CAAA,KAAA,CAAM,SAAS,SAAS,CAAA;AAErF,EAAA,OAAO,WAAe,IAAA,WAAA;AACvB;AAEO,IAAM,MAAS,GAAA;AAEf,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","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, SwitchDefault);\n\n\tconst matchedCase = childrenCasesArray.find((child) => child.props.when === condition);\n\n\treturn matchedCase ?? defaultCase;\n}\n\nexport const Switch = SwitchRoot;\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"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import '../../chunk-PZ5AY32C.js';
|
|
1
2
|
import { useState } from 'react';
|
|
2
3
|
import { useEffectOnce, useMountEffect } from '@zayne-labs/toolkit-react';
|
|
3
4
|
import { isString } from '@zayne-labs/toolkit-type-helpers';
|
|
4
5
|
import { createPortal } from 'react-dom';
|
|
5
6
|
|
|
6
|
-
// src/components/common/teleport/teleport.tsx
|
|
7
7
|
function Teleport(props) {
|
|
8
8
|
const { children, insertPosition, to } = props;
|
|
9
9
|
const [reactPortal, setReactPortal] = useState(null);
|
|
@@ -11,7 +11,5 @@ declare function ForBase<TArrayItem>(props: ForProps<TArrayItem>): react.ReactNo
|
|
|
11
11
|
declare function ForList<TArrayItem, TElement extends react.ElementType = "ul">(props: PolymorphicProps<TElement, ForProps<TArrayItem> & {
|
|
12
12
|
className?: string;
|
|
13
13
|
}>): react.JSX.Element;
|
|
14
|
-
declare const Base: typeof ForBase;
|
|
15
|
-
declare const List: typeof ForList;
|
|
16
14
|
|
|
17
|
-
export {
|
|
15
|
+
export { type EachProp as E, ForBase as F, ForList as a, type ForRenderProps as b };
|
|
@@ -9,11 +9,9 @@ declare function CardContent<TElement extends react.ElementType = "div">(props:
|
|
|
9
9
|
declare function CardFooter<TElement extends react.ElementType = "footer">(props: PolymorphicProps<TElement, {
|
|
10
10
|
asChild?: boolean;
|
|
11
11
|
}>): react.JSX.Element;
|
|
12
|
-
declare const Root: typeof CardRoot;
|
|
13
|
-
declare const Header: typeof CardHeader;
|
|
14
|
-
declare const Title: typeof CardTitle;
|
|
15
|
-
declare const Description: typeof CardDescription;
|
|
16
|
-
declare const Content: typeof CardContent;
|
|
17
|
-
declare const Footer: typeof CardFooter;
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
declare namespace cardParts {
|
|
14
|
+
export { CardContent as Content, CardDescription as Description, CardFooter as Footer, CardHeader as Header, CardRoot as Root, CardTitle as Title };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { cardParts as Card, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Slot } from '../../chunk-ENDWJXPF.js';
|
|
2
2
|
import { cnMerge } from '../../chunk-OHG7GB7O.js';
|
|
3
|
+
import { __export } from '../../chunk-PZ5AY32C.js';
|
|
3
4
|
import * as React from 'react';
|
|
4
5
|
|
|
5
6
|
function CardRoot(props) {
|
|
@@ -27,13 +28,18 @@ function CardFooter(props) {
|
|
|
27
28
|
const Component = asChild ? Slot : Element;
|
|
28
29
|
return /* @__PURE__ */ React.createElement(Component, { ...restOfProps });
|
|
29
30
|
}
|
|
30
|
-
var Root = CardRoot;
|
|
31
|
-
var Header = CardHeader;
|
|
32
|
-
var Title = CardTitle;
|
|
33
|
-
var Description = CardDescription;
|
|
34
|
-
var Content = CardContent;
|
|
35
|
-
var Footer = CardFooter;
|
|
36
31
|
|
|
37
|
-
|
|
32
|
+
// src/components/ui/card/card-parts.ts
|
|
33
|
+
var card_parts_exports = {};
|
|
34
|
+
__export(card_parts_exports, {
|
|
35
|
+
Content: () => CardContent,
|
|
36
|
+
Description: () => CardDescription,
|
|
37
|
+
Footer: () => CardFooter,
|
|
38
|
+
Header: () => CardHeader,
|
|
39
|
+
Root: () => CardRoot,
|
|
40
|
+
Title: () => CardTitle
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export { card_parts_exports as Card, CardContent, CardDescription, CardFooter, CardHeader, CardRoot, CardTitle };
|
|
38
44
|
//# sourceMappingURL=index.js.map
|
|
39
45
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ui/card/card.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ui/card/card.tsx","../../../../src/components/ui/card/card-parts.ts"],"names":[],"mappings":";;;;;AAMO,SAAS,SACf,KACC,EAAA;AACD,EAAA,MAAM,EAAE,EAAI,EAAA,OAAA,GAAU,SAAW,EAAA,GAAG,aAAgB,GAAA,KAAA;AAEpD,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,OAAS,EAAA,EAAA,GAAG,WAAa,EAAA,CAAA;AAClC;AAEO,SAAS,WACf,KACC,EAAA;AACD,EAAA,MAAM,EAAE,EAAI,EAAA,OAAA,GAAU,QAAU,EAAA,GAAG,aAAgB,GAAA,KAAA;AAEnD,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,OAAS,EAAA,EAAA,GAAG,WAAa,EAAA,CAAA;AAClC;AAEO,SAAS,UAAqD,KAAmC,EAAA;AACvG,EAAA,MAAM,EAAE,EAAI,EAAA,OAAA,GAAU,MAAM,SAAW,EAAA,GAAG,aAAgB,GAAA,KAAA;AAE1D,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,WAAQ,SAAW,EAAA,OAAA,CAAQ,iBAAiB,SAAS,CAAA,EAAI,GAAG,WAAa,EAAA,CAAA;AAClF;AAEO,SAAS,gBACf,KACC,EAAA;AACD,EAAA,MAAM,EAAE,EAAI,EAAA,OAAA,GAAU,KAAK,SAAW,EAAA,GAAG,aAAgB,GAAA,KAAA;AAEzD,EACC,uBAAA,KAAA,CAAA,aAAA,CAAC,WAAQ,SAAW,EAAA,OAAA,CAAQ,wCAAwC,SAAS,CAAA,EAAI,GAAG,WAAa,EAAA,CAAA;AAEnG;AAEO,SAAS,YACf,KACC,EAAA;AACD,EAAA,MAAM,EAAE,EAAI,EAAA,OAAA,GAAU,KAAO,EAAA,GAAG,aAAgB,GAAA,KAAA;AAEhD,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,OAAS,EAAA,EAAA,GAAG,WAAa,EAAA,CAAA;AAClC;AAEO,SAAS,WACf,KACC,EAAA;AACD,EAAA,MAAM,EAAE,EAAI,EAAA,OAAA,GAAU,UAAU,OAAS,EAAA,GAAG,aAAgB,GAAA,KAAA;AAE5D,EAAM,MAAA,SAAA,GAAY,UAAU,IAAO,GAAA,OAAA;AAEnC,EAAO,uBAAA,KAAA,CAAA,aAAA,CAAC,SAAW,EAAA,EAAA,GAAG,WAAa,EAAA,CAAA;AACpC;;;ACtDA,IAAA,kBAAA,GAAA;AAAA,QAAA,CAAA,kBAAA,EAAA;AAAA,EAAA,OAAA,EAAA,MAAA,WAAA;AAAA,EAAA,WAAA,EAAA,MAAA,eAAA;AAAA,EAAA,MAAA,EAAA,MAAA,UAAA;AAAA,EAAA,MAAA,EAAA,MAAA,UAAA;AAAA,EAAA,IAAA,EAAA,MAAA,QAAA;AAAA,EAAA,KAAA,EAAA,MAAA;AAAA,CAAA,CAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\n\nimport { Slot } from \"@/components/common/slot\";\nimport { cnMerge } from \"@/lib/utils/cn\";\nimport type { PolymorphicProps } from \"@zayne-labs/toolkit-react/utils\";\n\nexport function CardRoot<TElement extends React.ElementType = \"article\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"article\", ...restOfProps } = props;\n\n\treturn <Element {...restOfProps} />;\n}\n\nexport function CardHeader<TElement extends React.ElementType = \"header\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"header\", ...restOfProps } = props;\n\n\treturn <Element {...restOfProps} />;\n}\n\nexport function CardTitle<TElement extends React.ElementType = \"h3\">(props: PolymorphicProps<TElement>) {\n\tconst { as: Element = \"h3\", className, ...restOfProps } = props;\n\n\treturn <Element className={cnMerge(\"font-semibold\", className)} {...restOfProps} />;\n}\n\nexport function CardDescription<TElement extends React.ElementType = \"p\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"p\", className, ...restOfProps } = props;\n\n\treturn (\n\t\t<Element className={cnMerge(\"text-sm text-shadcn-muted-foreground\", className)} {...restOfProps} />\n\t);\n}\n\nexport function CardContent<TElement extends React.ElementType = \"div\">(\n\tprops: PolymorphicProps<TElement>\n) {\n\tconst { as: Element = \"div\", ...restOfProps } = props;\n\n\treturn <Element {...restOfProps} />;\n}\n\nexport function CardFooter<TElement extends React.ElementType = \"footer\">(\n\tprops: PolymorphicProps<TElement, { asChild?: boolean }>\n) {\n\tconst { as: Element = \"footer\", asChild, ...restOfProps } = props;\n\n\tconst Component = asChild ? Slot : Element;\n\n\treturn <Component {...restOfProps} />;\n}\n","export {\n\tCardContent as Content,\n\tCardDescription as Description,\n\tCardFooter as Footer,\n\tCardHeader as Header,\n\tCardRoot as Root,\n\tCardTitle as Title,\n} from \"./card\";\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { PolymorphicProps } from '@zayne-labs/toolkit-react/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { b as ForRenderProps, E as EachProp } from '../../for-C3T5FbXd.js';
|
|
4
4
|
import { Prettify } from '@zayne-labs/toolkit-type-helpers';
|
|
5
5
|
import { StoreApi } from 'zustand';
|
|
6
6
|
|
|
@@ -73,8 +73,6 @@ type OtherCarouselProps = {
|
|
|
73
73
|
style?: React.CSSProperties;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
declare function CarouselContextProvider<TImages extends ImagesType>(props: CarouselProviderProps<TImages>): react.JSX.Element;
|
|
77
|
-
|
|
78
76
|
declare function CarouselContent<TElement extends react.ElementType = "article">(props: PolymorphicProps<TElement, CarouselContentProps>): react.JSX.Element;
|
|
79
77
|
declare function CarouselButton(props: CarouselButtonsProps): react.JSX.Element;
|
|
80
78
|
declare function CarouselControls(props: CarouselControlProps): react.JSX.Element;
|
|
@@ -84,13 +82,10 @@ declare function CarouselCaption<TElement extends react.ElementType = "div">(pro
|
|
|
84
82
|
declare function CarouselIndicatorWrapper<TArrayItem>(props: CarouselWrapperProps<TArrayItem>): react.JSX.Element;
|
|
85
83
|
declare function CarouselIndicator(props: CarouselIndicatorProps): react.JSX.Element;
|
|
86
84
|
|
|
87
|
-
declare
|
|
88
|
-
|
|
89
|
-
declare
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
declare const Caption: typeof CarouselCaption;
|
|
93
|
-
declare const Indicator: typeof CarouselIndicator;
|
|
94
|
-
declare const IndicatorWrapper: typeof CarouselIndicatorWrapper;
|
|
85
|
+
declare function CarouselContextProvider<TImages extends ImagesType>(props: CarouselProviderProps<TImages>): react.JSX.Element;
|
|
86
|
+
|
|
87
|
+
declare namespace carouselParts {
|
|
88
|
+
export { CarouselButton as Button, CarouselCaption as Caption, CarouselContent as Content, CarouselControls as Controls, CarouselIndicator as Indicator, CarouselIndicatorWrapper as IndicatorWrapper, CarouselItem as Item, CarouselItemWrapper as ItemWrapper, CarouselContextProvider as Root };
|
|
89
|
+
}
|
|
95
90
|
|
|
96
|
-
export {
|
|
91
|
+
export { carouselParts as Carousel, CarouselButton, type CarouselButtonsProps, CarouselCaption, CarouselContent, type CarouselContentProps, type CarouselControlProps, CarouselControls, CarouselIndicator, type CarouselIndicatorProps, CarouselIndicatorWrapper, CarouselItem, CarouselItemWrapper, type CarouselProviderProps, type CarouselStore, type CarouselStoreApi, type CarouselWrapperProps, type ImagesType, type OtherCarouselProps };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { getElementList } from '../../chunk-
|
|
1
|
+
import { getElementList } from '../../chunk-MPOYLILK.js';
|
|
2
2
|
import { cnMerge } from '../../chunk-OHG7GB7O.js';
|
|
3
|
+
import { __export } from '../../chunk-PZ5AY32C.js';
|
|
3
4
|
import * as React3 from 'react';
|
|
4
5
|
import { useEffect, useState } from 'react';
|
|
5
6
|
import { useConstant, useAnimationInterval, useCallbackRef } from '@zayne-labs/toolkit-react';
|
|
@@ -7,7 +8,7 @@ import { createZustandContext } from '@zayne-labs/toolkit-react/zustand';
|
|
|
7
8
|
import { create } from 'zustand';
|
|
8
9
|
|
|
9
10
|
var ChevronLeftIcon = (props) => /* @__PURE__ */ React3.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React3.createElement("g", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2" }, /* @__PURE__ */ React3.createElement("circle", { cx: "12", cy: "12", r: "10" }), /* @__PURE__ */ React3.createElement("path", { d: "m14 16l-4-4l4-4" })));
|
|
10
|
-
var [Provider,
|
|
11
|
+
var [Provider, useCarouselStoreContext] = createZustandContext({
|
|
11
12
|
hookName: "useCarouselStore",
|
|
12
13
|
name: "CarouselStoreContext",
|
|
13
14
|
providerName: "CarouselContextProvider"
|
|
@@ -47,17 +48,22 @@ var createCarouselStore = (storeValues) => {
|
|
|
47
48
|
}));
|
|
48
49
|
return useInitCarouselStore;
|
|
49
50
|
};
|
|
50
|
-
|
|
51
|
-
const {
|
|
51
|
+
var useCarousel = (props) => {
|
|
52
|
+
const { images, onSlideBtnClick } = props;
|
|
52
53
|
const useInitCarouselStore = useConstant(() => createCarouselStore({ images, onSlideBtnClick }));
|
|
53
54
|
useEffect(() => {
|
|
54
55
|
useInitCarouselStore.setState({ images });
|
|
55
56
|
}, [images]);
|
|
57
|
+
return useInitCarouselStore;
|
|
58
|
+
};
|
|
59
|
+
function CarouselContextProvider(props) {
|
|
60
|
+
const { children, images, onSlideBtnClick } = props;
|
|
61
|
+
const useInitCarouselStore = useCarousel({ images, onSlideBtnClick });
|
|
56
62
|
return /* @__PURE__ */ React.createElement(Provider, { value: useInitCarouselStore }, children);
|
|
57
63
|
}
|
|
58
64
|
var useCarouselOptions = (options = {}) => {
|
|
59
65
|
const { autoSlideInterval = 5e3, hasAutoSlide = false, shouldPauseOnHover = false } = options;
|
|
60
|
-
const { goToNextSlide } =
|
|
66
|
+
const { goToNextSlide } = useCarouselStoreContext((state) => state.actions);
|
|
61
67
|
const [isPaused, setIsPaused] = useState(false);
|
|
62
68
|
const shouldAutoSlide = hasAutoSlide && !isPaused;
|
|
63
69
|
useAnimationInterval({
|
|
@@ -107,7 +113,7 @@ function CarouselContent(props) {
|
|
|
107
113
|
}
|
|
108
114
|
function CarouselButton(props) {
|
|
109
115
|
const { classNames, icon, variant } = props;
|
|
110
|
-
const { goToNextSlide, goToPreviousSlide } =
|
|
116
|
+
const { goToNextSlide, goToPreviousSlide } = useCarouselStoreContext((state) => state.actions);
|
|
111
117
|
return /* @__PURE__ */ React3.createElement(
|
|
112
118
|
"button",
|
|
113
119
|
{
|
|
@@ -180,8 +186,8 @@ function CarouselControls(props) {
|
|
|
180
186
|
function CarouselItemWrapper(props) {
|
|
181
187
|
const { children, className, each, render } = props;
|
|
182
188
|
const [ItemList] = getElementList("base");
|
|
183
|
-
const currentSlide =
|
|
184
|
-
const images =
|
|
189
|
+
const currentSlide = useCarouselStoreContext((state) => state.currentSlide);
|
|
190
|
+
const images = useCarouselStoreContext((state) => each ?? state.images);
|
|
185
191
|
return /* @__PURE__ */ React3.createElement(
|
|
186
192
|
"ul",
|
|
187
193
|
{
|
|
@@ -214,7 +220,7 @@ function CarouselCaption(props) {
|
|
|
214
220
|
}
|
|
215
221
|
function CarouselIndicatorWrapper(props) {
|
|
216
222
|
const { children, className, each, render } = props;
|
|
217
|
-
const images =
|
|
223
|
+
const images = useCarouselStoreContext((state) => each ?? state.images);
|
|
218
224
|
const [IndicatorList] = getElementList("base");
|
|
219
225
|
return /* @__PURE__ */ React3.createElement(
|
|
220
226
|
"ul",
|
|
@@ -233,7 +239,7 @@ function CarouselIndicator(props) {
|
|
|
233
239
|
const {
|
|
234
240
|
actions: { goToSlide },
|
|
235
241
|
currentSlide
|
|
236
|
-
} =
|
|
242
|
+
} = useCarouselStoreContext((state) => state);
|
|
237
243
|
return /* @__PURE__ */ React3.createElement("li", { className: cnMerge("inline-flex", classNames?.base) }, /* @__PURE__ */ React3.createElement(
|
|
238
244
|
"button",
|
|
239
245
|
{
|
|
@@ -248,15 +254,21 @@ function CarouselIndicator(props) {
|
|
|
248
254
|
}
|
|
249
255
|
));
|
|
250
256
|
}
|
|
251
|
-
var Content = CarouselContent;
|
|
252
|
-
var Controls = CarouselControls;
|
|
253
|
-
var Button = CarouselButton;
|
|
254
|
-
var Item = CarouselItem;
|
|
255
|
-
var ItemWrapper = CarouselItemWrapper;
|
|
256
|
-
var Caption = CarouselCaption;
|
|
257
|
-
var Indicator = CarouselIndicator;
|
|
258
|
-
var IndicatorWrapper = CarouselIndicatorWrapper;
|
|
259
257
|
|
|
260
|
-
|
|
258
|
+
// src/components/ui/carousel/carousel-parts.ts
|
|
259
|
+
var carousel_parts_exports = {};
|
|
260
|
+
__export(carousel_parts_exports, {
|
|
261
|
+
Button: () => CarouselButton,
|
|
262
|
+
Caption: () => CarouselCaption,
|
|
263
|
+
Content: () => CarouselContent,
|
|
264
|
+
Controls: () => CarouselControls,
|
|
265
|
+
Indicator: () => CarouselIndicator,
|
|
266
|
+
IndicatorWrapper: () => CarouselIndicatorWrapper,
|
|
267
|
+
Item: () => CarouselItem,
|
|
268
|
+
ItemWrapper: () => CarouselItemWrapper,
|
|
269
|
+
Root: () => CarouselContextProvider
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
export { carousel_parts_exports as Carousel, CarouselButton, CarouselCaption, CarouselContent, CarouselControls, CarouselIndicator, CarouselIndicatorWrapper, CarouselItem, CarouselItemWrapper };
|
|
261
273
|
//# sourceMappingURL=index.js.map
|
|
262
274
|
//# sourceMappingURL=index.js.map
|