@studiocubics/components 0.0.19 → 0.0.21
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useAnchorElement, useDisclosure } from "@studiocubics/hooks";
|
|
2
1
|
import { type ElementType, type ReactNode } from "react";
|
|
3
2
|
import { type ButtonProps } from "../../Inputs/Button/Button";
|
|
4
3
|
export type DocumentAction<C extends ElementType = "a"> = {
|
|
@@ -7,7 +6,6 @@ export type DocumentAction<C extends ElementType = "a"> = {
|
|
|
7
6
|
actionType: "popover";
|
|
8
7
|
popoverChildren: ReactNode;
|
|
9
8
|
icon: ReactNode;
|
|
10
|
-
anchorElementDefaults?: ReturnType<typeof useAnchorElement>;
|
|
11
9
|
} & ButtonProps<C>) | {
|
|
12
10
|
actionType: "node";
|
|
13
11
|
children: ReactNode;
|
|
@@ -19,7 +17,6 @@ export type DocumentAction<C extends ElementType = "a"> = {
|
|
|
19
17
|
actionType: "dialog";
|
|
20
18
|
icon: ReactNode;
|
|
21
19
|
dialogChildren: ReactNode;
|
|
22
|
-
disclosureDefaults?: ReturnType<typeof useDisclosure>;
|
|
23
20
|
} & ButtonProps));
|
|
24
21
|
export declare function CollectionItemCardActions({ actions, }: {
|
|
25
22
|
actions: DocumentAction[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsx as
|
|
1
|
+
"use client";import{jsx as o,Fragment as n,jsxs as r}from"react/jsx-runtime";import{useDisclosure as e,useAnchorElement as i}from"@studiocubics/hooks";import{Fragment as t}from"react";import{Button as c}from"../../Inputs/Button/Button.js";import{Tooltip as l}from"../../Display/Tooltip/Tooltip.js";import{Popover as a}from"../../Layout/Popover/Popover.js";import{Dialog as p}from"../../Layout/Dialog/Dialog.js";function d({actions:r}){return o(n,{children:r.map((n,r)=>{switch(n.actionType){case"popover":return o(s,{action:n},r);case"link":return o(h,{action:n},r);case"dialog":return o(u,{action:n},r);default:return o(t,{children:n.children},r)}})})}function s({action:e}){const{actionType:t,icon:p,popoverChildren:d,onClick:s,...h}=e,{anchorEl:u,open:m,handleClick:f,handleClose:C}=i();return r(n,{children:[o(l,{renderArrow:!0,title:e.label,children:o(c,{...h,onClick:o=>{f(o),s?.(o)},children:p})}),o(a,{open:m,anchorEl:u,onClose:C,children:d})]})}function h({action:n}){const{actionType:r,icon:e,...i}=n;return o(l,{renderArrow:!0,title:n.label,children:o(c,{...i,children:e})})}function u({action:i}){const{actionType:t,icon:a,dialogChildren:d,onClick:s,...h}=i,{open:u,handleOpen:m,handleClose:f}=e();return r(n,{children:[o(l,{renderArrow:!0,title:i.label,children:o(c,{...h,onClick:o=>{m(),s?.(o)},children:a})}),o(p,{open:u,onClose:f,children:d})]})}export{d as CollectionItemCardActions};
|
|
2
2
|
//# sourceMappingURL=CollectionItemCardActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollectionItemCardActions.js","sources":["../../../src/Cards/CollectionItemCard/CollectionItemCardActions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useAnchorElement, useDisclosure } from \"@studiocubics/hooks\";\nimport {\n type ElementType,\n type ReactNode,\n type MouseEvent,\n Fragment,\n
|
|
1
|
+
{"version":3,"file":"CollectionItemCardActions.js","sources":["../../../src/Cards/CollectionItemCard/CollectionItemCardActions.tsx"],"sourcesContent":["\"use client\";\n\nimport { useAnchorElement, useDisclosure } from \"@studiocubics/hooks\";\nimport {\n type ElementType,\n type ReactNode,\n type MouseEvent,\n Fragment,\n} from \"react\";\nimport { Button, type ButtonProps } from \"../../Inputs/Button/Button\";\nimport { Tooltip } from \"../../Display/Tooltip/Tooltip\";\nimport { Popover } from \"../../Layout/Popover/Popover\";\nimport { Dialog } from \"../../Layout/Dialog/Dialog\";\n\nexport type DocumentAction<C extends ElementType = \"a\"> = {\n label: string;\n} & (\n | ({\n actionType: \"popover\";\n popoverChildren: ReactNode;\n icon: ReactNode;\n // TODO add overrides for useAnchorEl hook\n } & ButtonProps<C>)\n | { actionType: \"node\"; children: ReactNode }\n | ({\n actionType: \"link\";\n href: string;\n icon: ReactNode;\n } & ButtonProps) //TODO Avoid 'as' conflict\n | ({\n actionType: \"dialog\";\n icon: ReactNode;\n dialogChildren: ReactNode;\n // TODO add overrides for useDisclosure hook\n } & ButtonProps)\n);\nexport function CollectionItemCardActions({\n actions,\n}: {\n actions: DocumentAction[];\n}) {\n return (\n <>\n {actions.map((action, i) => {\n switch (action.actionType) {\n case \"popover\":\n return <PopoverTypeAction key={i} action={action} />;\n case \"link\":\n return <LinkTypeAction key={i} action={action} />;\n case \"dialog\":\n return <DialogTypeAction key={i} action={action} />;\n default:\n return <Fragment key={i}>{action.children}</Fragment>;\n }\n })}\n </>\n );\n}\n\nfunction PopoverTypeAction({\n action,\n}: {\n action: DocumentAction & { actionType: \"popover\" };\n}) {\n const { actionType: _, icon, popoverChildren, onClick, ...rest } = action;\n const { anchorEl, open, handleClick, handleClose } = useAnchorElement();\n return (\n <>\n <Tooltip renderArrow title={action.label}>\n <Button\n {...rest}\n onClick={(e: MouseEvent<HTMLAnchorElement>) => {\n handleClick(e);\n onClick?.(e);\n }}\n >\n {icon}\n </Button>\n </Tooltip>\n <Popover open={open} anchorEl={anchorEl} onClose={handleClose}>\n {popoverChildren}\n </Popover>\n </>\n );\n}\nfunction LinkTypeAction({\n action,\n}: {\n action: DocumentAction & { actionType: \"link\" };\n}) {\n const { actionType: _, icon, ...rest } = action;\n return (\n <Tooltip renderArrow title={action.label}>\n <Button {...rest}>{icon}</Button>\n </Tooltip>\n );\n}\n\nfunction DialogTypeAction({\n action,\n}: {\n action: DocumentAction & { actionType: \"dialog\" };\n}) {\n const { actionType: _, icon, dialogChildren, onClick, ...rest } = action;\n const { open, handleOpen, handleClose } = useDisclosure();\n return (\n <>\n <Tooltip renderArrow title={action.label}>\n <Button\n {...rest}\n onClick={(e: MouseEvent<HTMLButtonElement>) => {\n handleOpen();\n onClick?.(e);\n }}\n >\n {icon}\n </Button>\n </Tooltip>\n <Dialog open={open} onClose={handleClose}>\n {dialogChildren}\n </Dialog>\n </>\n );\n}\n"],"names":["CollectionItemCardActions","actions","_jsx","_Fragment","children","map","action","i","actionType","PopoverTypeAction","LinkTypeAction","DialogTypeAction","Fragment","_","icon","popoverChildren","onClick","rest","anchorEl","open","handleClick","handleClose","useAnchorElement","_jsxs","Tooltip","renderArrow","title","label","Button","e","Popover","onClose","dialogChildren","handleOpen","useDisclosure","Dialog"],"mappings":"2ZAoCM,SAAUA,GAA0BC,QACxCA,IAIA,OACEC,EAAAC,EAAA,CAAAC,SACGH,EAAQI,IAAI,CAACC,EAAQC,KACpB,OAAQD,EAAOE,YACb,IAAK,UACH,OAAON,EAACO,EAAiB,CAASH,OAAQA,GAAXC,GACjC,IAAK,OACH,OAAOL,EAACQ,EAAc,CAASJ,OAAQA,GAAXC,GAC9B,IAAK,SACH,OAAOL,EAACS,EAAgB,CAASL,OAAQA,GAAXC,GAChC,QACE,OAAOL,EAACU,EAAQ,CAAAR,SAAUE,EAAOF,UAAXG,OAKlC,CAEA,SAASE,GAAkBH,OACzBA,IAIA,MAAQE,WAAYK,EAACC,KAAEA,EAAIC,gBAAEA,EAAeC,QAAEA,KAAYC,GAASX,GAC7DY,SAAEA,EAAQC,KAAEA,EAAIC,YAAEA,EAAWC,YAAEA,GAAgBC,IACrD,OACEC,eACErB,EAACsB,GAAQC,aAAW,EAACC,MAAOpB,EAAOqB,MAAKvB,SACtCF,EAAC0B,EAAM,IACDX,EACJD,QAAUa,IACRT,EAAYS,GACZb,IAAUa,IACXzB,SAEAU,MAGLZ,EAAC4B,EAAO,CAACX,KAAMA,EAAMD,SAAUA,EAAUa,QAASV,WAC/CN,MAIT,CACA,SAASL,GAAeJ,OACtBA,IAIA,MAAQE,WAAYK,EAACC,KAAEA,KAASG,GAASX,EACzC,OACEJ,EAACsB,EAAO,CAACC,aAAW,EAACC,MAAOpB,EAAOqB,MAAKvB,SACtCF,EAAC0B,EAAM,IAAKX,WAAOH,KAGzB,CAEA,SAASH,GAAiBL,OACxBA,IAIA,MAAQE,WAAYK,EAACC,KAAEA,EAAIkB,eAAEA,EAAchB,QAAEA,KAAYC,GAASX,GAC5Da,KAAEA,EAAIc,WAAEA,EAAUZ,YAAEA,GAAgBa,IAC1C,OACEX,eACErB,EAACsB,GAAQC,aAAW,EAACC,MAAOpB,EAAOqB,MAAKvB,SACtCF,EAAC0B,EAAM,IACDX,EACJD,QAAUa,IACRI,IACAjB,IAAUa,IACXzB,SAEAU,MAGLZ,EAACiC,GAAOhB,KAAMA,EAAMY,QAASV,EAAWjB,SACrC4B,MAIT"}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
7
|
"private": false,
|
|
8
|
-
"version": "0.0.
|
|
8
|
+
"version": "0.0.21",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"@studiocubics",
|
|
11
11
|
"cubics",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"react-dom": ">= 19"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@studiocubics/hooks": "^0.0.
|
|
38
|
-
"@studiocubics/types": "^0.0.
|
|
39
|
-
"@studiocubics/utils": "^0.0.
|
|
37
|
+
"@studiocubics/hooks": "^0.0.21",
|
|
38
|
+
"@studiocubics/types": "^0.0.21",
|
|
39
|
+
"@studiocubics/utils": "^0.0.21"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@eslint/js": "^9.39.1",
|