@zentauri-ui/zentauri-components 1.7.9 → 1.8.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.
Files changed (123) hide show
  1. package/README.md +9 -4
  2. package/cli/registry.json +3 -0
  3. package/dist/chunk-7TGUGTTQ.mjs +147 -0
  4. package/dist/chunk-7TGUGTTQ.mjs.map +1 -0
  5. package/dist/chunk-CQMV7BB6.js +50 -0
  6. package/dist/chunk-CQMV7BB6.js.map +1 -0
  7. package/dist/chunk-DN7TYUJ6.js +119 -0
  8. package/dist/chunk-DN7TYUJ6.js.map +1 -0
  9. package/dist/chunk-ODBG4Y6R.mjs +48 -0
  10. package/dist/chunk-ODBG4Y6R.mjs.map +1 -0
  11. package/dist/chunk-RKX5MERK.js +150 -0
  12. package/dist/chunk-RKX5MERK.js.map +1 -0
  13. package/dist/chunk-VYI3GS2C.mjs +115 -0
  14. package/dist/chunk-VYI3GS2C.mjs.map +1 -0
  15. package/dist/design-system/animated-number.d.ts +32 -0
  16. package/dist/design-system/animated-number.d.ts.map +1 -0
  17. package/dist/design-system/copy-button.d.ts +43 -0
  18. package/dist/design-system/copy-button.d.ts.map +1 -0
  19. package/dist/design-system/index.d.ts +3 -0
  20. package/dist/design-system/index.d.ts.map +1 -1
  21. package/dist/design-system/kbd.d.ts +44 -0
  22. package/dist/design-system/kbd.d.ts.map +1 -0
  23. package/dist/hooks/useClipboard.js +6 -44
  24. package/dist/hooks/useClipboard.js.map +1 -1
  25. package/dist/hooks/useClipboard.mjs +1 -46
  26. package/dist/hooks/useClipboard.mjs.map +1 -1
  27. package/dist/ui/animated-number/animated-number.d.ts +4 -0
  28. package/dist/ui/animated-number/animated-number.d.ts.map +1 -0
  29. package/dist/ui/animated-number/animations.d.ts +59 -0
  30. package/dist/ui/animated-number/animations.d.ts.map +1 -0
  31. package/dist/ui/animated-number/index.d.ts +4 -0
  32. package/dist/ui/animated-number/index.d.ts.map +1 -0
  33. package/dist/ui/animated-number/types.d.ts +31 -0
  34. package/dist/ui/animated-number/types.d.ts.map +1 -0
  35. package/dist/ui/animated-number/variants.d.ts +5 -0
  36. package/dist/ui/animated-number/variants.d.ts.map +1 -0
  37. package/dist/ui/animated-number.js +181 -0
  38. package/dist/ui/animated-number.js.map +1 -0
  39. package/dist/ui/animated-number.mjs +177 -0
  40. package/dist/ui/animated-number.mjs.map +1 -0
  41. package/dist/ui/copy-button/animated/animations.d.ts +3 -0
  42. package/dist/ui/copy-button/animated/animations.d.ts.map +1 -0
  43. package/dist/ui/copy-button/animated/copy-button-animated.d.ts +6 -0
  44. package/dist/ui/copy-button/animated/copy-button-animated.d.ts.map +1 -0
  45. package/dist/ui/copy-button/animated/index.d.ts +4 -0
  46. package/dist/ui/copy-button/animated/index.d.ts.map +1 -0
  47. package/dist/ui/copy-button/animated/types.d.ts +26 -0
  48. package/dist/ui/copy-button/animated/types.d.ts.map +1 -0
  49. package/dist/ui/copy-button/animated.js +59 -0
  50. package/dist/ui/copy-button/animated.js.map +1 -0
  51. package/dist/ui/copy-button/animated.mjs +56 -0
  52. package/dist/ui/copy-button/animated.mjs.map +1 -0
  53. package/dist/ui/copy-button/copy-button-base.d.ts +6 -0
  54. package/dist/ui/copy-button/copy-button-base.d.ts.map +1 -0
  55. package/dist/ui/copy-button/copy-button.d.ts +6 -0
  56. package/dist/ui/copy-button/copy-button.d.ts.map +1 -0
  57. package/dist/ui/copy-button/index.d.ts +4 -0
  58. package/dist/ui/copy-button/index.d.ts.map +1 -0
  59. package/dist/ui/copy-button/types.d.ts +32 -0
  60. package/dist/ui/copy-button/types.d.ts.map +1 -0
  61. package/dist/ui/copy-button/variants.d.ts +6 -0
  62. package/dist/ui/copy-button/variants.d.ts.map +1 -0
  63. package/dist/ui/copy-button.js +20 -0
  64. package/dist/ui/copy-button.js.map +1 -0
  65. package/dist/ui/copy-button.mjs +15 -0
  66. package/dist/ui/copy-button.mjs.map +1 -0
  67. package/dist/ui/kbd/animated/animations.d.ts +3 -0
  68. package/dist/ui/kbd/animated/animations.d.ts.map +1 -0
  69. package/dist/ui/kbd/animated/index.d.ts +4 -0
  70. package/dist/ui/kbd/animated/index.d.ts.map +1 -0
  71. package/dist/ui/kbd/animated/kbd-animated.d.ts +6 -0
  72. package/dist/ui/kbd/animated/kbd-animated.d.ts.map +1 -0
  73. package/dist/ui/kbd/animated/types.d.ts +10 -0
  74. package/dist/ui/kbd/animated/types.d.ts.map +1 -0
  75. package/dist/ui/kbd/animated.js +42 -0
  76. package/dist/ui/kbd/animated.js.map +1 -0
  77. package/dist/ui/kbd/animated.mjs +39 -0
  78. package/dist/ui/kbd/animated.mjs.map +1 -0
  79. package/dist/ui/kbd/index.d.ts +4 -0
  80. package/dist/ui/kbd/index.d.ts.map +1 -0
  81. package/dist/ui/kbd/kbd-base.d.ts +6 -0
  82. package/dist/ui/kbd/kbd-base.d.ts.map +1 -0
  83. package/dist/ui/kbd/kbd.d.ts +6 -0
  84. package/dist/ui/kbd/kbd.d.ts.map +1 -0
  85. package/dist/ui/kbd/types.d.ts +17 -0
  86. package/dist/ui/kbd/types.d.ts.map +1 -0
  87. package/dist/ui/kbd/variants.d.ts +8 -0
  88. package/dist/ui/kbd/variants.d.ts.map +1 -0
  89. package/dist/ui/kbd.js +23 -0
  90. package/dist/ui/kbd.js.map +1 -0
  91. package/dist/ui/kbd.mjs +14 -0
  92. package/dist/ui/kbd.mjs.map +1 -0
  93. package/package.json +1 -1
  94. package/src/design-system/animated-number.ts +53 -0
  95. package/src/design-system/copy-button.ts +81 -0
  96. package/src/design-system/index.ts +3 -0
  97. package/src/design-system/kbd.ts +83 -0
  98. package/src/ui/animated-number/animated-number.test.tsx +64 -0
  99. package/src/ui/animated-number/animated-number.tsx +120 -0
  100. package/src/ui/animated-number/animations.ts +22 -0
  101. package/src/ui/animated-number/index.ts +4 -0
  102. package/src/ui/animated-number/types.ts +39 -0
  103. package/src/ui/animated-number/variants.ts +14 -0
  104. package/src/ui/copy-button/animated/animations.ts +22 -0
  105. package/src/ui/copy-button/animated/copy-button-animated.tsx +39 -0
  106. package/src/ui/copy-button/animated/index.ts +10 -0
  107. package/src/ui/copy-button/animated/types.ts +21 -0
  108. package/src/ui/copy-button/copy-button-base.tsx +88 -0
  109. package/src/ui/copy-button/copy-button.test.tsx +82 -0
  110. package/src/ui/copy-button/copy-button.tsx +9 -0
  111. package/src/ui/copy-button/index.ts +10 -0
  112. package/src/ui/copy-button/types.ts +37 -0
  113. package/src/ui/copy-button/variants.ts +29 -0
  114. package/src/ui/kbd/animated/animations.ts +15 -0
  115. package/src/ui/kbd/animated/index.ts +9 -0
  116. package/src/ui/kbd/animated/kbd-animated.tsx +26 -0
  117. package/src/ui/kbd/animated/types.ts +16 -0
  118. package/src/ui/kbd/index.ts +5 -0
  119. package/src/ui/kbd/kbd-base.tsx +50 -0
  120. package/src/ui/kbd/kbd.test.tsx +48 -0
  121. package/src/ui/kbd/kbd.tsx +9 -0
  122. package/src/ui/kbd/types.ts +21 -0
  123. package/src/ui/kbd/variants.ts +31 -0
@@ -0,0 +1,50 @@
1
+ "use client";
2
+
3
+ import { Fragment } from "react";
4
+
5
+ import { zuiKbdBase } from "../../design-system/kbd";
6
+ import { cn } from "../../lib/utils";
7
+
8
+ import type { KbdBaseProps } from "./types";
9
+ import { kbdKeyVariants, kbdSeparatorVariants } from "./variants";
10
+
11
+ export function KbdBase({
12
+ keys,
13
+ separator,
14
+ appearance,
15
+ size,
16
+ children,
17
+ className,
18
+ as: Wrapper = "span",
19
+ ref,
20
+ ...rest
21
+ }: KbdBaseProps) {
22
+ const items = keys ?? (children != null ? [children] : []);
23
+
24
+ return (
25
+ <Wrapper
26
+ ref={ref}
27
+ data-slot="kbd"
28
+ className={cn(zuiKbdBase, className)}
29
+ {...rest}
30
+ >
31
+ {items.map((key, index) => (
32
+ <Fragment key={index}>
33
+ {index > 0 && separator != null ? (
34
+ <span data-slot="kbd-separator" className={kbdSeparatorVariants({ size })}>
35
+ {separator}
36
+ </span>
37
+ ) : null}
38
+ <kbd
39
+ data-slot="kbd-key"
40
+ className={kbdKeyVariants({ appearance, size })}
41
+ >
42
+ {key}
43
+ </kbd>
44
+ </Fragment>
45
+ ))}
46
+ </Wrapper>
47
+ );
48
+ }
49
+
50
+ KbdBase.displayName = "Kbd";
@@ -0,0 +1,48 @@
1
+ import { createRef } from "react";
2
+ import { render, screen } from "@testing-library/react";
3
+ import { describe, expect, it } from "vitest";
4
+
5
+ import { Kbd } from "./kbd";
6
+
7
+ describe("Kbd", () => {
8
+ it("should expose displayName", () => {
9
+ expect(Kbd.displayName).toBe("Kbd");
10
+ });
11
+
12
+ it("should stamp data-slot on the wrapper", () => {
13
+ render(<Kbd keys={["⌘", "K"]} />);
14
+ expect(document.querySelector('[data-slot="kbd"]')).toBeInTheDocument();
15
+ });
16
+
17
+ it("should render one keycap per key", () => {
18
+ render(<Kbd keys={["Ctrl", "Shift", "P"]} />);
19
+ expect(document.querySelectorAll('[data-slot="kbd-key"]')).toHaveLength(3);
20
+ });
21
+
22
+ it("should render children as a single keycap", () => {
23
+ render(<Kbd>Esc</Kbd>);
24
+ expect(document.querySelectorAll('[data-slot="kbd-key"]')).toHaveLength(1);
25
+ expect(screen.getByText("Esc")).toBeInTheDocument();
26
+ });
27
+
28
+ it("should render separators between keys", () => {
29
+ render(<Kbd keys={["⌘", "K"]} separator="+" />);
30
+ expect(
31
+ document.querySelectorAll('[data-slot="kbd-separator"]'),
32
+ ).toHaveLength(1);
33
+ });
34
+
35
+ it("should apply the appearance token", () => {
36
+ render(<Kbd keys={["A"]} appearance="emerald" />);
37
+ const key = document.querySelector(
38
+ '[data-slot="kbd-key"]',
39
+ ) as HTMLElement;
40
+ expect(key.className).toMatch(/--zui-kbd-emerald-bg/);
41
+ });
42
+
43
+ it("should forward ref", () => {
44
+ const ref = createRef<HTMLSpanElement>();
45
+ render(<Kbd ref={ref} keys={["A"]} />);
46
+ expect(ref.current?.getAttribute("data-slot")).toBe("kbd");
47
+ });
48
+ });
@@ -0,0 +1,9 @@
1
+ // kbd.tsx — default static entry (no framer-motion)
2
+ import { KbdBase } from "./kbd-base";
3
+ import type { KbdProps } from "./types";
4
+
5
+ export function Kbd(props: KbdProps) {
6
+ return <KbdBase {...props} />;
7
+ }
8
+
9
+ Kbd.displayName = "Kbd";
@@ -0,0 +1,21 @@
1
+ import type { VariantProps } from "class-variance-authority";
2
+ import type { ComponentPropsWithRef, ElementType, ReactNode } from "react";
3
+
4
+ import type { kbdKeyVariants } from "./variants";
5
+
6
+ export type KbdVariantProps = VariantProps<typeof kbdKeyVariants>;
7
+
8
+ export interface KbdBaseProps
9
+ extends Omit<ComponentPropsWithRef<"span">, "children"> {
10
+ /** Keys to render as individual keycaps, e.g. `["⌘", "K"]`. Takes precedence over `children`. */
11
+ keys?: ReactNode[];
12
+ /** Optional node rendered between keycaps (e.g. "+" or "then"). */
13
+ separator?: ReactNode;
14
+ appearance?: KbdVariantProps["appearance"];
15
+ size?: KbdVariantProps["size"];
16
+ /** Single keycap content when `keys` is not provided. */
17
+ children?: ReactNode;
18
+ as?: ElementType;
19
+ }
20
+
21
+ export type KbdProps = Omit<KbdBaseProps, "as">;
@@ -0,0 +1,31 @@
1
+ import { cva } from "class-variance-authority";
2
+
3
+ import {
4
+ zuiKbdKeyAppearances,
5
+ zuiKbdKeyBase,
6
+ zuiKbdKeySizes,
7
+ zuiKbdSeparatorSizes,
8
+ } from "../../design-system/kbd";
9
+
10
+ export const kbdKeyVariants = cva(zuiKbdKeyBase, {
11
+ variants: {
12
+ appearance: zuiKbdKeyAppearances,
13
+ size: zuiKbdKeySizes,
14
+ },
15
+ defaultVariants: {
16
+ appearance: "outline",
17
+ size: "md",
18
+ },
19
+ });
20
+
21
+ export const kbdSeparatorVariants = cva(
22
+ "text-[color:var(--zui-kbd-separator-fg,#94a3b8)] dark:text-[color:var(--zui-kbd-separator-fg-dark,#64748b)]",
23
+ {
24
+ variants: {
25
+ size: zuiKbdSeparatorSizes,
26
+ },
27
+ defaultVariants: {
28
+ size: "md",
29
+ },
30
+ },
31
+ );