@studiocubics/components 0.0.27 → 0.0.28
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,2 +1,2 @@
|
|
|
1
|
-
"use client";import{jsxs as t,jsx as
|
|
1
|
+
"use client";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{cn as o}from"@studiocubics/utils";import{useState as r,useEffect as s}from"react";import e from"./CopyableText.module.css.js";import{useDelayedAction as n}from"@studiocubics/hooks";import{Button as p}from"../../Inputs/Button/Button.js";import"../../Display/Accordion/Accordion.js";import"../../Cards/GlassCard/GlassCard.js";import"../../Display/Chip/Chip.js";import"../../Display/Divider/Divider.js";import"../../Display/IdentityDisplay/IdentityDisplay.js";import"../../Display/InputErrors/InputErrors.js";import"../../Display/Kbd/buttonList.js";import"../../Display/List/List.js";import{Tooltip as l}from"../../Display/Tooltip/Tooltip.js";function a(a){const{as:c,children:m,className:h,disabled:y=!1,slotProps:j={},...w}=a,[f,C]=r(!1),b=n(),D=c||"div",k={...w,className:o(h,e.root)};return s(()=>{f&&b(()=>C(!1),2e3)},[b,f]),t(D,{...k,children:[i("span",{children:m}),i(l,{title:f?"Copied!":"Copy",children:i(p,{disabled:y,square:!0,size:"sm",type:"button",...j.button,onClick:async function(t){await navigator.clipboard.writeText(m),C(!0),j.button?.onClick?.(t)},children:i(f?u:d,{width:24,height:24})})})]})}a.displayName="CopyableText";const c=a;function d(o){return t("svg",{...o,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round",children:[i("rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}),i("path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"})]})}function u(t){return i("svg",{...t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.3",strokeLinecap:"round",strokeLinejoin:"round",children:i("path",{d:"M4 12 9 17l11 -11"})})}export{c as CopyableText};
|
|
2
2
|
//# sourceMappingURL=CopyableText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CopyableText.js","sources":["../../../src/Typography/CopyableText/CopyableText.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n PolymorphicComponentProps,\n PolymorphicComponentType,\n} from \"@studiocubics/types\";\nimport { cn } from \"@studiocubics/utils\";\nimport {\n type ComponentProps,\n type MouseEvent,\n useEffect,\n useState,\n type ElementType,\n} from \"react\";\nimport styles from \"./CopyableText.module.css\";\nimport { useDelayedAction } from \"@studiocubics/hooks\";\nimport { Button, type ButtonProps } from \"../../Inputs/Button/Button\";\n\nexport interface CopyableTextBaseProps {\n children: string;\n disabled?: boolean;\n slotProps?: {\n button?: ButtonProps;\n };\n}\n\nconst defaultElement = \"div\";\ntype DefaultElement = typeof defaultElement;\n\nexport type CopyableTextProps<C extends ElementType = DefaultElement> =\n PolymorphicComponentProps<C, CopyableTextBaseProps>;\n\nfunction CopyableTextBase<C extends ElementType = DefaultElement>(\n props: CopyableTextProps<C>,\n) {\n const {\n as,\n children,\n className,\n disabled = false,\n slotProps = {},\n ...rest\n } = props as CopyableTextProps<DefaultElement>;\n\n const [copied, setCopied] = useState(false);\n const delay = useDelayedAction();\n const Component = (as || defaultElement) as ElementType;\n const componentProps = { ...rest, className: cn(className, styles.root) };\n\n async function handleCopy(e: MouseEvent<HTMLButtonElement>) {\n await navigator.clipboard.writeText(children);\n setCopied(true);\n slotProps.button?.onClick?.(e);\n }\n useEffect(() => {\n if (copied) {\n delay(() => setCopied(false), 2000);\n }\n }, [delay, copied]);\n return (\n <Component {...componentProps}>\n <span>{children}</span>\n <Button\n
|
|
1
|
+
{"version":3,"file":"CopyableText.js","sources":["../../../src/Typography/CopyableText/CopyableText.tsx"],"sourcesContent":["\"use client\";\n\nimport type {\n PolymorphicComponentProps,\n PolymorphicComponentType,\n} from \"@studiocubics/types\";\nimport { cn } from \"@studiocubics/utils\";\nimport {\n type ComponentProps,\n type MouseEvent,\n useEffect,\n useState,\n type ElementType,\n} from \"react\";\nimport styles from \"./CopyableText.module.css\";\nimport { useDelayedAction } from \"@studiocubics/hooks\";\nimport { Button, type ButtonProps } from \"../../Inputs/Button/Button\";\nimport { Tooltip } from \"../../Display/_index\";\n\nexport interface CopyableTextBaseProps {\n children: string;\n disabled?: boolean;\n slotProps?: {\n button?: ButtonProps;\n };\n}\n\nconst defaultElement = \"div\";\ntype DefaultElement = typeof defaultElement;\n\nexport type CopyableTextProps<C extends ElementType = DefaultElement> =\n PolymorphicComponentProps<C, CopyableTextBaseProps>;\n\nfunction CopyableTextBase<C extends ElementType = DefaultElement>(\n props: CopyableTextProps<C>,\n) {\n const {\n as,\n children,\n className,\n disabled = false,\n slotProps = {},\n ...rest\n } = props as CopyableTextProps<DefaultElement>;\n\n const [copied, setCopied] = useState(false);\n const delay = useDelayedAction();\n const Component = (as || defaultElement) as ElementType;\n const componentProps = { ...rest, className: cn(className, styles.root) };\n\n async function handleCopy(e: MouseEvent<HTMLButtonElement>) {\n await navigator.clipboard.writeText(children);\n setCopied(true);\n slotProps.button?.onClick?.(e);\n }\n useEffect(() => {\n if (copied) {\n delay(() => setCopied(false), 2000);\n }\n }, [delay, copied]);\n return (\n <Component {...componentProps}>\n <span>{children}</span>\n <Tooltip title={copied ? \"Copied!\" : \"Copy\"}>\n <Button\n disabled={disabled}\n square\n size=\"sm\"\n type=\"button\"\n {...slotProps.button}\n onClick={handleCopy}\n >\n {copied ? (\n <CheckIcon width={24} height={24} />\n ) : (\n <CopyIcon width={24} height={24} />\n )}\n </Button>\n </Tooltip>\n </Component>\n );\n}\n\nCopyableTextBase.displayName = \"CopyableText\";\n\nexport const CopyableText = CopyableTextBase as PolymorphicComponentType<\n CopyableTextBaseProps,\n DefaultElement\n>;\n\nfunction CopyIcon(props: ComponentProps<\"svg\">) {\n return (\n <svg\n {...props}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.3\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\" />\n <path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\" />\n </svg>\n );\n}\n// TODO convert to animated check icon\nfunction CheckIcon(props: ComponentProps<\"svg\">) {\n return (\n <svg\n {...props}\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.3\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M4 12 9 17l11 -11\" />\n </svg>\n );\n}\n"],"names":["CopyableTextBase","props","as","children","className","disabled","slotProps","rest","copied","setCopied","useState","delay","useDelayedAction","Component","componentProps","cn","styles","root","useEffect","_jsxs","_jsx","Tooltip","title","Button","square","size","type","button","onClick","async","e","navigator","clipboard","writeText","CheckIcon","CopyIcon","width","height","displayName","CopyableText","xmlns","viewBox","fill","stroke","strokeWidth","strokeLinecap","strokeLinejoin","x","y","rx","ry","d"],"mappings":"ssBAiCA,SAASA,EACPC,GAEA,MAAMC,GACJA,EAAEC,SACFA,EAAQC,UACRA,EAASC,SACTA,GAAW,EAAKC,UAChBA,EAAY,CAAA,KACTC,GACDN,GAEGO,EAAQC,GAAaC,GAAS,GAC/BC,EAAQC,IACRC,EAAaX,GApBE,MAqBfY,EAAiB,IAAKP,EAAMH,UAAWW,EAAGX,EAAWY,EAAOC,OAYlE,OALAC,EAAU,KACJV,GACFG,EAAM,IAAMF,GAAU,GAAQ,MAE/B,CAACE,EAAOH,IAETW,EAACN,MAAcC,EAAcX,SAAA,CAC3BiB,mBAAOjB,IACPiB,EAACC,EAAO,CAACC,MAAOd,EAAS,UAAY,OAAML,SACzCiB,EAACG,EAAM,CACLlB,SAAUA,EACVmB,QAAM,EACNC,KAAK,KACLC,KAAK,YACDpB,EAAUqB,OACdC,QApBRC,eAA0BC,SAClBC,UAAUC,UAAUC,UAAU9B,GACpCM,GAAU,GACVH,EAAUqB,QAAQC,UAAUE,EAC9B,EAgB2B3B,SAGjBiB,EADDZ,EACE0B,EAEAC,GAFUC,MAAO,GAAIC,OAAQ,WAQ1C,CAEArC,EAAiBsC,YAAc,eAExB,MAAMC,EAAevC,EAK5B,SAASmC,EAASlC,GAChB,OACEkB,EAAA,MAAA,IACMlB,EACJuC,MAAM,6BACNC,QAAQ,YACRC,KAAK,OACLC,OAAO,eACPC,YAAY,MACZC,cAAc,QACdC,eAAe,QAAO3C,SAAA,CAEtBiB,EAAA,OAAA,CAAMgB,MAAM,KAAKC,OAAO,KAAKU,EAAE,IAAIC,EAAE,IAAIC,GAAG,IAAIC,GAAG,MACnD9B,EAAA,OAAA,CAAM+B,EAAE,8DAGd,CAEA,SAASjB,EAAUjC,GACjB,OACEmB,EAAA,MAAA,IACMnB,EACJuC,MAAM,6BACNC,QAAQ,YACRC,KAAK,OACLC,OAAO,eACPC,YAAY,MACZC,cAAc,QACdC,eAAe,QAAO3C,SAEtBiB,UAAM+B,EAAE,uBAGd"}
|
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.28",
|
|
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.28",
|
|
38
|
+
"@studiocubics/types": "^0.0.28",
|
|
39
|
+
"@studiocubics/utils": "^0.0.28"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@eslint/js": "^9.39.1",
|