@gridui/clipboard 1.0.9 → 2.0.0

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/README.md CHANGED
@@ -1,11 +1,21 @@
1
1
  # @gridui/clipboard
2
2
 
3
- Core family. Public API: `CopyButton`, `CopyButtonProps`, `CopyPath`, `CopyPathProps`.
3
+ Controls family. Public API: `CopyButton`, `CopyButtonProps`, `CopyPath`, `CopyPathProps`.
4
4
 
5
5
  Import components from `@gridui/clipboard` and load `@gridui/clipboard/styles.css` after Theme.
6
- Load styles for any composed dependency used by this family. Applications own routes, labels, state persistence, and branding.
6
+ Applications own routes, labels, state persistence, and branding.
7
+
8
+ See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-controls/clipboard/.changeset/history).
9
+
10
+ ## Styles
11
+
12
+ Load Theme once. Use `@gridui/clipboard/styled` for automatic component CSS in
13
+ CSS-aware bundlers, or keep the CSS-free root import and load `@gridui/clipboard/styles.css`.
14
+ Both entries expose the same root API. The standalone stylesheet includes component
15
+ dependency styles; Theme/reset remain separate. See the
16
+ [integration guide](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/usage/integration.md)
17
+ for static HTML loading, SSR limits, and avoiding duplicate CSS.
7
18
 
8
- See [component ownership](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/component-ownership.md) and [release history](https://github.com/sudo-ui/GridUI-React-Monorepo/tree/main/packages-core/clipboard/.changeset/history).
9
19
 
10
20
  ## Behavior
11
21
 
@@ -26,3 +36,10 @@ padding or expands environment variables, usernames, or path placeholders.
26
36
 
27
37
 
28
38
  [Component reference](docs/reference/README.md) contains focused API pages for each public component.
39
+
40
+ ## Sizing and density
41
+
42
+ CopyButton inherits Button size, including extra-large. CopyPath accepts small, medium (default) or large for its path/action geometry; long paths remain readable and can grow the row.
43
+
44
+ See the [shared sizing contract](https://github.com/sudo-ui/GridUI-React-Monorepo/blob/main/docs/usage/sizing.md)
45
+ for native attributes, scope precedence, tokens and target behavior.
@@ -4,9 +4,11 @@
4
4
  * @namespace CopyPath
5
5
  * @description Copy Path
6
6
  */
7
+ import type { Size } from "@gridui/theme";
7
8
  import type { CopyOptions } from "../shared/copy-options";
8
9
  import { type FC } from "react";
9
10
  export type CopyPathProps = CopyOptions & {
11
+ readonly size?: Size;
10
12
  readonly label: string;
11
13
  readonly copyLabel: string;
12
14
  readonly frame?: "standalone" | "integrated";
package/dist/index.js CHANGED
@@ -154,8 +154,8 @@ var CopyButton = (props) => {
154
154
  import { cva as cva2 } from "class-variance-authority";
155
155
  var copyPathStyles = cva2("gridui-copy-path gridui-u-clipboard--min-w-0 gridui-u-clipboard--rounded-none");
156
156
  var copyPathRowStyles = cva2("gridui-u-clipboard--grid gridui-u-clipboard--min-w-0 gridui-u-clipboard--grid-cols-[minmax(0,1fr)_auto] gridui-u-clipboard--bg-surface");
157
- var copyPathValueStyles = cva2("gridui-u-clipboard--min-w-0 gridui-u-clipboard--self-center gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-16 gridui-u-clipboard--type-code gridui-u-clipboard--text-foreground gridui-u-clipboard--wrap-anywhere gridui-u-clipboard--select-text");
158
- var copyPathActionStyles = cva2("gridui-copy-path-action gridui-u-clipboard--flex gridui-u-clipboard--min-h-11 gridui-u-clipboard--items-center gridui-u-clipboard--justify-center gridui-u-clipboard--gap-gridui-8 gridui-u-clipboard--rounded-none gridui-u-clipboard--bg-background gridui-u-clipboard--px-gridui-16 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--text-foreground gridui-u-clipboard--type-ui gridui-u-clipboard--cursor-pointer gridui-u-clipboard--[&_svg]:h-gridui-16 gridui-u-clipboard--[&_svg]:w-gridui-16 gridui-u-clipboard--[&_svg]:shrink-0");
157
+ var copyPathValueStyles = cva2("gridui-u-clipboard--min-w-0 gridui-u-clipboard--self-center gridui-u-clipboard--px-(--gridui-copy-inline) gridui-u-clipboard--py-(--gridui-copy-block) gridui-u-clipboard--type-code gridui-u-clipboard--text-foreground gridui-u-clipboard--wrap-anywhere gridui-u-clipboard--select-text");
158
+ var copyPathActionStyles = cva2("gridui-copy-path-action gridui-u-clipboard--flex gridui-u-clipboard--items-center gridui-u-clipboard--justify-center gridui-u-clipboard--gap-gridui-8 gridui-u-clipboard--rounded-none gridui-u-clipboard--bg-background gridui-u-clipboard--text-foreground gridui-u-clipboard--type-ui gridui-u-clipboard--cursor-pointer gridui-u-clipboard--[&_svg]:shrink-0");
159
159
  var copyPathStatusStyles = cva2("gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--type-supporting gridui-u-clipboard--text-muted");
160
160
 
161
161
  // src/copy-path/copy-path.tsx
@@ -166,6 +166,7 @@ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
166
166
  var CopyPath = (props) => {
167
167
  const {
168
168
  value,
169
+ size = "medium",
169
170
  label,
170
171
  copyLabel,
171
172
  copiedLabel,
@@ -193,6 +194,7 @@ var CopyPath = (props) => {
193
194
  {
194
195
  className: copyPathStyles(),
195
196
  "data-frame": frame,
197
+ "data-size": size,
196
198
  role: "group",
197
199
  "aria-label": label,
198
200
  children: [
@@ -212,6 +214,7 @@ var CopyPath = (props) => {
212
214
  /* @__PURE__ */ jsx3(
213
215
  Button2,
214
216
  {
217
+ size,
215
218
  type: "button",
216
219
  className: copyPathActionStyles(),
217
220
  variant: "quiet",
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/shared/copy-status.tsx", "../src/shared/clipboard.ts", "../src/shared/use-copy.ts", "../src/copy-button/copy-button.tsx", "../src/copy-path/style.ts", "../src/copy-path/copy-path.tsx"],
4
- "sourcesContent": ["/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Copy Status\n */\n\nimport { cva } from \"class-variance-authority\";\nimport type { FC } from \"react\";\n\nconst copyStatusStyles = cva(\"gridui-copy-status\");\n\nexport type CopyStatusProps = {\n readonly copiedLabel: string;\n readonly failedLabel: string;\n readonly message: string;\n readonly className?: string;\n};\n\nexport const CopyStatus: FC<CopyStatusProps> = (props: CopyStatusProps) => {\n const { copiedLabel, failedLabel, message, className } = props;\n return (<span\n className={copyStatusStyles({ className })}\n >\n <span\n aria-hidden=\"true\"\n >\n {copiedLabel}\n </span>\n <span\n aria-hidden=\"true\"\n >\n {failedLabel}\n </span>\n <span\n role=\"status\"\n >\n {message}\n </span>\n </span>);\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Clipboard\n */\n\nexport const copyPath = async (value: string): Promise<boolean> => {\n try {\n await navigator.clipboard.writeText(value);\n return true;\n } catch {\n return false;\n }\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Use Copy\n */\n\nimport { copyPath } from \"./clipboard\";\nimport { useEffect, useRef, useState } from \"react\";\n\nexport const useCopy = (value: string) => {\n const [\n result,\n setResult,\n ] = useState<{\n value: string;\n success: boolean;\n } | null>(null);\n const [\n pending,\n setPending,\n ] = useState(false);\n const active = useRef(false);\n const mounted = useRef(true);\n const currentValue = useRef(value);\n currentValue.current = value;\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const copy = async (): Promise<boolean | undefined> => {\n if (active.current) {\n return undefined;\n }\n active.current = true;\n setPending(true);\n const success = await copyPath(value);\n active.current = false;\n // Activity can disconnect effects while preserving pending state.\n setPending(false);\n if (!mounted.current) {\n return undefined;\n }\n if (value !== currentValue.current) {\n return undefined;\n }\n setResult({\n value,\n success,\n });\n return success;\n };\n return {\n pending,\n copy,\n result: result?.value === value ? result : null,\n };\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyButton\n * @description Copy Button\n */\n\nimport type { CopyOptions } from \"../shared/copy-options\";\nimport { CopyStatus } from \"../shared/copy-status\";\nimport { useCopy } from \"../shared/use-copy\";\nimport { Button, type ButtonProps, type ButtonVariants } from \"@gridui/button\";\nimport { Textarea } from \"@gridui/input\";\nimport { type FC, useEffect, useRef } from \"react\";\n\nexport type CopyButtonProps = Omit<ButtonProps, \"children\" | \"onClick\" | \"value\"> & ButtonVariants & CopyOptions & {\n readonly label: string;\n};\n\nexport const CopyButton: FC<CopyButtonProps> = (props: CopyButtonProps) => {\n const { value, label, copiedLabel, failedLabel, disabled, loading, ...restProps } = props;\n const { result: visibleResult, pending, copy } = useCopy(value);\n const manualCopyInput = useRef<HTMLTextAreaElement>(null);\n useEffect(() => {\n if (visibleResult && !visibleResult.success) {\n manualCopyInput.current?.focus();\n manualCopyInput.current?.select();\n }\n }, [visibleResult]);\n const message = visibleResult?.success ? copiedLabel : failedLabel;\n return (<span\n className=\"gridui-copy-button\"\n >\n <Button\n {...restProps}\n disabled={disabled}\n loading={loading || pending}\n onClick={() => {\n void copy();\n }}\n >\n {label}\n </Button>\n <CopyStatus\n copiedLabel={copiedLabel}\n failedLabel={failedLabel}\n message={visibleResult ? message : \"\"}\n />\n {visibleResult && !visibleResult.success && (<Textarea\n ref={manualCopyInput}\n aria-label={failedLabel}\n className=\"gridui-u-clipboard--col-span-full\"\n value={value}\n readOnly\n />)}\n </span>);\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyPath\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const copyPathStyles = cva(\"gridui-copy-path gridui-u-clipboard--min-w-0 gridui-u-clipboard--rounded-none\");\n\nexport const copyPathRowStyles = cva(\"gridui-u-clipboard--grid gridui-u-clipboard--min-w-0 gridui-u-clipboard--grid-cols-[minmax(0,1fr)_auto] gridui-u-clipboard--bg-surface\");\n\nexport const copyPathValueStyles = cva(\"gridui-u-clipboard--min-w-0 gridui-u-clipboard--self-center gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-16 gridui-u-clipboard--type-code gridui-u-clipboard--text-foreground gridui-u-clipboard--wrap-anywhere gridui-u-clipboard--select-text\");\n\nexport const copyPathActionStyles = cva(\"gridui-copy-path-action gridui-u-clipboard--flex gridui-u-clipboard--min-h-11 gridui-u-clipboard--items-center gridui-u-clipboard--justify-center gridui-u-clipboard--gap-gridui-8 gridui-u-clipboard--rounded-none gridui-u-clipboard--bg-background gridui-u-clipboard--px-gridui-16 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--text-foreground gridui-u-clipboard--type-ui gridui-u-clipboard--cursor-pointer gridui-u-clipboard--[&_svg]:h-gridui-16 gridui-u-clipboard--[&_svg]:w-gridui-16 gridui-u-clipboard--[&_svg]:shrink-0\");\n\nexport const copyPathStatusStyles = cva(\"gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--type-supporting gridui-u-clipboard--text-muted\");\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyPath\n * @description Copy Path\n */\n\nimport type { CopyOptions } from \"../shared/copy-options\";\nimport { CopyStatus } from \"../shared/copy-status\";\nimport { useCopy } from \"../shared/use-copy\";\nimport { copyPathActionStyles, copyPathRowStyles, copyPathStatusStyles, copyPathStyles, copyPathValueStyles } from \"./style\";\nimport { Button } from \"@gridui/button\";\nimport { Check, Copy } from \"lucide-react\";\nimport { type FC, useRef } from \"react\";\n\nexport type CopyPathProps = CopyOptions & {\n readonly label: string;\n readonly copyLabel: string;\n readonly frame?: \"standalone\" | \"integrated\";\n};\n\nexport const CopyPath: FC<CopyPathProps> = (props: CopyPathProps) => {\n const {\n value,\n label,\n copyLabel,\n copiedLabel,\n failedLabel,\n frame = \"standalone\",\n } = props;\n const { pending, result, copy } = useCopy(value);\n const code = useRef<HTMLElement>(null);\n let statusLabel = \"\";\n if (result) {\n statusLabel = result.success ? copiedLabel : failedLabel;\n }\n const copyValue = async (): Promise<void> => {\n const success = await copy();\n if (success === false && code.current?.textContent === value) {\n const range = document.createRange();\n range.selectNodeContents(code.current);\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(range);\n }\n };\n return (<div\n className={copyPathStyles()}\n data-frame={frame}\n role=\"group\"\n aria-label={label}\n >\n <div\n className={copyPathRowStyles()}\n >\n <code\n ref={code}\n className={copyPathValueStyles()}\n >\n {value}\n </code>\n <Button\n type=\"button\"\n className={copyPathActionStyles()}\n variant=\"quiet\"\n loading={pending}\n startIcon={result?.success ? (<Check\n aria-hidden=\"true\"\n />) : (<Copy\n aria-hidden=\"true\"\n />)}\n onClick={() => {\n void copyValue();\n }}\n >\n {copyLabel}\n </Button>\n </div>\n <CopyStatus\n copiedLabel={copiedLabel}\n failedLabel={failedLabel}\n message={statusLabel}\n className={copyPathStatusStyles()}\n />\n </div>);\n};\n"],
5
- "mappings": ";AAOA,SAAS,WAAW;AAcR,SAGJ,KAHI;AAXZ,IAAM,mBAAmB,IAAI,oBAAoB;AAS1C,IAAM,aAAkC,CAAC,UAA2B;AACvE,QAAM,EAAE,aAAa,aAAa,SAAS,UAAU,IAAI;AACzD,SAAQ;AAAA,IAAC;AAAA;AAAA,MACL,WAAW,iBAAiB,EAAE,UAAU,CAAC;AAAA,MAEzC;AAAA;AAAA,UAAC;AAAA;AAAA,YACG,eAAY;AAAA,YAEX;AAAA;AAAA,QACL;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACG,eAAY;AAAA,YAEX;AAAA;AAAA,QACL;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACG,MAAK;AAAA,YAEJ;AAAA;AAAA,QACL;AAAA;AAAA;AAAA,EACJ;AACJ;;;ACjCO,IAAM,WAAW,OAAO,UAAoC;AAC/D,MAAI;AACA,UAAM,UAAU,UAAU,UAAU,KAAK;AACzC,WAAO;AAAA,EACX,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;;;ACNA,SAAS,WAAW,QAAQ,gBAAgB;AAErC,IAAM,UAAU,CAAC,UAAkB;AACtC,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAGM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ACA,QAAM,YAAY,YAA2B;AACzC,UAAM,UAAU,MAAM,KAAK;AAC3B,QAAI,YAAY,SAAS,KAAK,SAAS,gBAAgB,OAAO;AAC1D,YAAM,QAAQ,SAAS,YAAY;AACnC,YAAM,mBAAmB,KAAK,OAAO;AACrC,YAAM,YAAY,OAAO,aAAa;AACtC,iBAAW,gBAAgB;AAC3B,iBAAW,SAAS,KAAK;AAAA,IAC7B;AAAA,EACJ;AACA,SAAQ,gBAAAE;AAAA,IAAC;AAAA;AAAA,MACL,WAAW,eAAe;AAAA,MAC1B,cAAY;AAAA,MACZ,MAAK;AAAA,MACL,cAAY;AAAA,MAEZ;AAAA,wBAAAA;AAAA,UAAC;AAAA;AAAA,YACG,WAAW,kBAAkB;AAAA,YAE7B;AAAA,8BAAAD;AAAA,gBAAC;AAAA;AAAA,kBACG,KAAK;AAAA,kBACL,WAAW,oBAAoB;AAAA,kBAE9B;AAAA;AAAA,cACL;AAAA,cACA,gBAAAA;AAAA,gBAACF;AAAA,gBAAA;AAAA,kBACG,MAAK;AAAA,kBACL,WAAW,qBAAqB;AAAA,kBAChC,SAAQ;AAAA,kBACR,SAAS;AAAA,kBACT,WAAW,QAAQ,UAAW,gBAAAE;AAAA,oBAAC;AAAA;AAAA,sBAC3B,eAAY;AAAA;AAAA,kBAChB,IAAO,gBAAAA;AAAA,oBAAC;AAAA;AAAA,sBACJ,eAAY;AAAA;AAAA,kBAChB;AAAA,kBACA,SAAS,MAAM;AACX,yBAAK,UAAU;AAAA,kBACnB;AAAA,kBAEC;AAAA;AAAA,cACL;AAAA;AAAA;AAAA,QACJ;AAAA,QACA,gBAAAA;AAAA,UAAC;AAAA;AAAA,YACG;AAAA,YACA;AAAA,YACA,SAAS;AAAA,YACT,WAAW,qBAAqB;AAAA;AAAA,QACpC;AAAA;AAAA;AAAA,EACJ;AACJ;",
4
+ "sourcesContent": ["/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Copy Status\n */\n\nimport { cva } from \"class-variance-authority\";\nimport type { FC } from \"react\";\n\nconst copyStatusStyles = cva(\"gridui-copy-status\");\n\nexport type CopyStatusProps = {\n readonly copiedLabel: string;\n readonly failedLabel: string;\n readonly message: string;\n readonly className?: string;\n};\n\nexport const CopyStatus: FC<CopyStatusProps> = (props: CopyStatusProps) => {\n const { copiedLabel, failedLabel, message, className } = props;\n return (<span\n className={copyStatusStyles({ className })}\n >\n <span\n aria-hidden=\"true\"\n >\n {copiedLabel}\n </span>\n <span\n aria-hidden=\"true\"\n >\n {failedLabel}\n </span>\n <span\n role=\"status\"\n >\n {message}\n </span>\n </span>);\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Clipboard\n */\n\nexport const copyPath = async (value: string): Promise<boolean> => {\n try {\n await navigator.clipboard.writeText(value);\n return true;\n } catch {\n return false;\n }\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace Shared\n * @description Use Copy\n */\n\nimport { copyPath } from \"./clipboard\";\nimport { useEffect, useRef, useState } from \"react\";\n\nexport const useCopy = (value: string) => {\n const [\n result,\n setResult,\n ] = useState<{\n value: string;\n success: boolean;\n } | null>(null);\n const [\n pending,\n setPending,\n ] = useState(false);\n const active = useRef(false);\n const mounted = useRef(true);\n const currentValue = useRef(value);\n currentValue.current = value;\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const copy = async (): Promise<boolean | undefined> => {\n if (active.current) {\n return undefined;\n }\n active.current = true;\n setPending(true);\n const success = await copyPath(value);\n active.current = false;\n // Activity can disconnect effects while preserving pending state.\n setPending(false);\n if (!mounted.current) {\n return undefined;\n }\n if (value !== currentValue.current) {\n return undefined;\n }\n setResult({\n value,\n success,\n });\n return success;\n };\n return {\n pending,\n copy,\n result: result?.value === value ? result : null,\n };\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyButton\n * @description Copy Button\n */\n\nimport type { CopyOptions } from \"../shared/copy-options\";\nimport { CopyStatus } from \"../shared/copy-status\";\nimport { useCopy } from \"../shared/use-copy\";\nimport { Button, type ButtonProps, type ButtonVariants } from \"@gridui/button\";\nimport { Textarea } from \"@gridui/input\";\nimport { type FC, useEffect, useRef } from \"react\";\n\nexport type CopyButtonProps = Omit<ButtonProps, \"children\" | \"onClick\" | \"value\"> & ButtonVariants & CopyOptions & {\n readonly label: string;\n};\n\nexport const CopyButton: FC<CopyButtonProps> = (props: CopyButtonProps) => {\n const { value, label, copiedLabel, failedLabel, disabled, loading, ...restProps } = props;\n const { result: visibleResult, pending, copy } = useCopy(value);\n const manualCopyInput = useRef<HTMLTextAreaElement>(null);\n useEffect(() => {\n if (visibleResult && !visibleResult.success) {\n manualCopyInput.current?.focus();\n manualCopyInput.current?.select();\n }\n }, [visibleResult]);\n const message = visibleResult?.success ? copiedLabel : failedLabel;\n return (<span\n className=\"gridui-copy-button\"\n >\n <Button\n {...restProps}\n disabled={disabled}\n loading={loading || pending}\n onClick={() => {\n void copy();\n }}\n >\n {label}\n </Button>\n <CopyStatus\n copiedLabel={copiedLabel}\n failedLabel={failedLabel}\n message={visibleResult ? message : \"\"}\n />\n {visibleResult && !visibleResult.success && (<Textarea\n ref={manualCopyInput}\n aria-label={failedLabel}\n className=\"gridui-u-clipboard--col-span-full\"\n value={value}\n readOnly\n />)}\n </span>);\n};\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyPath\n * @description Style\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const copyPathStyles = cva(\"gridui-copy-path gridui-u-clipboard--min-w-0 gridui-u-clipboard--rounded-none\");\n\nexport const copyPathRowStyles = cva(\"gridui-u-clipboard--grid gridui-u-clipboard--min-w-0 gridui-u-clipboard--grid-cols-[minmax(0,1fr)_auto] gridui-u-clipboard--bg-surface\");\n\nexport const copyPathValueStyles = cva(\"gridui-u-clipboard--min-w-0 gridui-u-clipboard--self-center gridui-u-clipboard--px-(--gridui-copy-inline) gridui-u-clipboard--py-(--gridui-copy-block) gridui-u-clipboard--type-code gridui-u-clipboard--text-foreground gridui-u-clipboard--wrap-anywhere gridui-u-clipboard--select-text\");\n\nexport const copyPathActionStyles = cva(\"gridui-copy-path-action gridui-u-clipboard--flex gridui-u-clipboard--items-center gridui-u-clipboard--justify-center gridui-u-clipboard--gap-gridui-8 gridui-u-clipboard--rounded-none gridui-u-clipboard--bg-background gridui-u-clipboard--text-foreground gridui-u-clipboard--type-ui gridui-u-clipboard--cursor-pointer gridui-u-clipboard--[&_svg]:shrink-0\");\n\nexport const copyPathStatusStyles = cva(\"gridui-u-clipboard--px-gridui-24 gridui-u-clipboard--py-gridui-8 gridui-u-clipboard--type-supporting gridui-u-clipboard--text-muted\");\n", "/**\n * @author WMXPY\n * @package Clipboard\n * @namespace CopyPath\n * @description Copy Path\n */\n\nimport type { Size } from \"@gridui/theme\";\nimport type { CopyOptions } from \"../shared/copy-options\";\nimport { CopyStatus } from \"../shared/copy-status\";\nimport { useCopy } from \"../shared/use-copy\";\nimport { copyPathActionStyles, copyPathRowStyles, copyPathStatusStyles, copyPathStyles, copyPathValueStyles } from \"./style\";\nimport { Button } from \"@gridui/button\";\nimport { Check, Copy } from \"lucide-react\";\nimport { type FC, useRef } from \"react\";\n\nexport type CopyPathProps = CopyOptions & {\n readonly size?: Size;\n readonly label: string;\n readonly copyLabel: string;\n readonly frame?: \"standalone\" | \"integrated\";\n};\n\nexport const CopyPath: FC<CopyPathProps> = (props: CopyPathProps) => {\n const {\n value,\n size = \"medium\",\n label,\n copyLabel,\n copiedLabel,\n failedLabel,\n frame = \"standalone\",\n } = props;\n const { pending, result, copy } = useCopy(value);\n const code = useRef<HTMLElement>(null);\n let statusLabel = \"\";\n if (result) {\n statusLabel = result.success ? copiedLabel : failedLabel;\n }\n const copyValue = async (): Promise<void> => {\n const success = await copy();\n if (success === false && code.current?.textContent === value) {\n const range = document.createRange();\n range.selectNodeContents(code.current);\n const selection = window.getSelection();\n selection?.removeAllRanges();\n selection?.addRange(range);\n }\n };\n return (<div\n className={copyPathStyles()}\n data-frame={frame}\n data-size={size}\n role=\"group\"\n aria-label={label}\n >\n <div\n className={copyPathRowStyles()}\n >\n <code\n ref={code}\n className={copyPathValueStyles()}\n >\n {value}\n </code>\n <Button\n size={size}\n type=\"button\"\n className={copyPathActionStyles()}\n variant=\"quiet\"\n loading={pending}\n startIcon={result?.success ? (<Check\n aria-hidden=\"true\"\n />) : (<Copy\n aria-hidden=\"true\"\n />)}\n onClick={() => {\n void copyValue();\n }}\n >\n {copyLabel}\n </Button>\n </div>\n <CopyStatus\n copiedLabel={copiedLabel}\n failedLabel={failedLabel}\n message={statusLabel}\n className={copyPathStatusStyles()}\n />\n </div>);\n};\n"],
5
+ "mappings": ";AAOA,SAAS,WAAW;AAcR,SAGJ,KAHI;AAXZ,IAAM,mBAAmB,IAAI,oBAAoB;AAS1C,IAAM,aAAkC,CAAC,UAA2B;AACvE,QAAM,EAAE,aAAa,aAAa,SAAS,UAAU,IAAI;AACzD,SAAQ;AAAA,IAAC;AAAA;AAAA,MACL,WAAW,iBAAiB,EAAE,UAAU,CAAC;AAAA,MAEzC;AAAA;AAAA,UAAC;AAAA;AAAA,YACG,eAAY;AAAA,YAEX;AAAA;AAAA,QACL;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACG,eAAY;AAAA,YAEX;AAAA;AAAA,QACL;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACG,MAAK;AAAA,YAEJ;AAAA;AAAA,QACL;AAAA;AAAA;AAAA,EACJ;AACJ;;;ACjCO,IAAM,WAAW,OAAO,UAAoC;AAC/D,MAAI;AACA,UAAM,UAAU,UAAU,UAAU,KAAK;AACzC,WAAO;AAAA,EACX,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;;;ACNA,SAAS,WAAW,QAAQ,gBAAgB;AAErC,IAAM,UAAU,CAAC,UAAkB;AACtC,QAAM;AAAA,IACF;AAAA,IACA;AAAA,EACJ,IAAI,SAGM,IAAI;AACd,QAAM;AAAA,IACF;AAAA,IACA;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js ADDED
@@ -0,0 +1,4 @@
1
+ import "@gridui/button/styled";
2
+ import "@gridui/input/styled";
3
+ import "./styles.local.css";
4
+ export * from "./index.js";