@ucdjs-internal/shared-ui 0.1.5 → 0.1.6

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.
@@ -0,0 +1,3 @@
1
+ import { ShikiCode, ShikiCodeProps } from "./shiki-code.mjs";
2
+ import { ThemeToggle, ThemeToggleFallback } from "./theme-toggle.mjs";
3
+ export { ShikiCode, ShikiCodeProps, ThemeToggle, ThemeToggleFallback };
@@ -0,0 +1,4 @@
1
+ import { ShikiCode } from "./shiki-code.mjs";
2
+ import { ThemeToggle, ThemeToggleFallback } from "./theme-toggle.mjs";
3
+
4
+ export { ShikiCode, ThemeToggle, ThemeToggleFallback };
@@ -11,7 +11,7 @@ interface ShikiCodeProps {
11
11
  * The language to use for syntax highlighting
12
12
  * @default "typescript"
13
13
  */
14
- language?: BundledLanguage;
14
+ language?: BundledLanguage | "ucd";
15
15
  /**
16
16
  * Additional CSS class names
17
17
  */
@@ -1,3 +1,4 @@
1
+ import ucd_tmLanguage_default from "../vscode/syntaxes/ucd.tmLanguage.mjs";
1
2
  import { use, useMemo } from "react";
2
3
  import { createJavaScriptRegexEngine } from "shiki";
3
4
  import { createCssVariablesTheme, createHighlighterCore } from "shiki/core";
@@ -12,7 +13,8 @@ const highlighterPromise = createHighlighterCore({
12
13
  langs: [
13
14
  import("shiki/langs/javascript.mjs"),
14
15
  import("shiki/langs/typescript.mjs"),
15
- import("shiki/langs/json.mjs")
16
+ import("shiki/langs/json.mjs"),
17
+ ucd_tmLanguage_default
16
18
  ],
17
19
  engine: createJavaScriptRegexEngine()
18
20
  });
@@ -2,5 +2,6 @@ import * as react_jsx_runtime0 from "react/jsx-runtime";
2
2
 
3
3
  //#region src/components/theme-toggle.d.ts
4
4
  declare function ThemeToggle(): react_jsx_runtime0.JSX.Element;
5
+ declare function ThemeToggleFallback(): react_jsx_runtime0.JSX.Element;
5
6
  //#endregion
6
- export { ThemeToggle };
7
+ export { ThemeToggle, ThemeToggleFallback };
@@ -22,7 +22,10 @@ function ThemeToggle() {
22
22
  size: "icon",
23
23
  className: "h-7 w-7",
24
24
  ...props,
25
- children: [/* @__PURE__ */ jsx(Icon, { className: "h-4 w-4" }), /* @__PURE__ */ jsx("span", {
25
+ children: [/* @__PURE__ */ jsx(Icon, {
26
+ className: "h-4 w-4",
27
+ suppressHydrationWarning: true
28
+ }), /* @__PURE__ */ jsx("span", {
26
29
  className: "sr-only",
27
30
  children: "Toggle theme"
28
31
  })]
@@ -70,6 +73,24 @@ function ThemeToggle() {
70
73
  } else t3 = $[8];
71
74
  return t3;
72
75
  }
76
+ function ThemeToggleFallback() {
77
+ const $ = c(1);
78
+ let t0;
79
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
80
+ t0 = /* @__PURE__ */ jsx(Button, {
81
+ variant: "ghost",
82
+ size: "icon",
83
+ className: "h-7 w-7",
84
+ disabled: true,
85
+ children: /* @__PURE__ */ jsx("span", {
86
+ className: "sr-only",
87
+ children: "Toggle theme"
88
+ })
89
+ });
90
+ $[0] = t0;
91
+ } else t0 = $[0];
92
+ return t0;
93
+ }
73
94
 
74
95
  //#endregion
75
- export { ThemeToggle };
96
+ export { ThemeToggle, ThemeToggleFallback };
@@ -1,3 +1,4 @@
1
+ import { useClipboard } from "./use-clipboard.mjs";
1
2
  import { useIsMobile } from "./use-mobile.mjs";
2
3
  import { ThemeMode, UseThemeReturn, useTheme } from "./use-theme.mjs";
3
- export { type ThemeMode, type UseThemeReturn, useIsMobile, useTheme };
4
+ export { type ThemeMode, type UseThemeReturn, useClipboard, useIsMobile, useTheme };
@@ -1,4 +1,5 @@
1
1
  import { useTheme } from "./use-theme.mjs";
2
+ import { useClipboard } from "./use-clipboard.mjs";
2
3
  import { useIsMobile } from "./use-mobile.mjs";
3
4
 
4
- export { useIsMobile, useTheme };
5
+ export { useClipboard, useIsMobile, useTheme };
@@ -0,0 +1,28 @@
1
+ //#region src/hooks/use-clipboard.d.ts
2
+ interface UseClipboardOptions {
3
+ /**
4
+ * Time in ms after which the copied state will reset, `2000` by default
5
+ */
6
+ timeout?: number;
7
+ }
8
+ interface UseClipboardReturnValue {
9
+ /**
10
+ * Function to copy value to clipboard
11
+ */
12
+ copy: (value: unknown) => void;
13
+ /**
14
+ * Function to reset copied state and error
15
+ */
16
+ reset: () => void;
17
+ /**
18
+ * Error if copying failed
19
+ */
20
+ error: Error | null;
21
+ /**
22
+ * Boolean indicating if the value was copied successfully
23
+ */
24
+ copied: boolean;
25
+ }
26
+ declare function useClipboard(options?: UseClipboardOptions): UseClipboardReturnValue;
27
+ //#endregion
28
+ export { useClipboard };
@@ -0,0 +1,62 @@
1
+ import { useState } from "react";
2
+ import { c } from "react/compiler-runtime";
3
+
4
+ //#region src/hooks/use-clipboard.ts
5
+ function useClipboard(t0) {
6
+ const $ = c(12);
7
+ let t1;
8
+ if ($[0] !== t0) {
9
+ t1 = t0 === void 0 ? { timeout: 2e3 } : t0;
10
+ $[0] = t0;
11
+ $[1] = t1;
12
+ } else t1 = $[1];
13
+ const options = t1;
14
+ const [error, setError] = useState(null);
15
+ const [copied, setCopied] = useState(false);
16
+ const [copyTimeout, setCopyTimeout] = useState(null);
17
+ let t2;
18
+ if ($[2] !== copyTimeout || $[3] !== options) {
19
+ const handleCopyResult = (value) => {
20
+ window.clearTimeout(copyTimeout);
21
+ setCopyTimeout(window.setTimeout(() => setCopied(false), options.timeout));
22
+ setCopied(value);
23
+ };
24
+ t2 = (value_0) => {
25
+ if ("clipboard" in navigator) navigator.clipboard.writeText(value_0).then(() => handleCopyResult(true)).catch((err) => setError(err));
26
+ else setError(/* @__PURE__ */ new Error("useClipboard: navigator.clipboard is not supported"));
27
+ };
28
+ $[2] = copyTimeout;
29
+ $[3] = options;
30
+ $[4] = t2;
31
+ } else t2 = $[4];
32
+ const copy = t2;
33
+ let t3;
34
+ if ($[5] !== copyTimeout) {
35
+ t3 = () => {
36
+ setCopied(false);
37
+ setError(null);
38
+ window.clearTimeout(copyTimeout);
39
+ };
40
+ $[5] = copyTimeout;
41
+ $[6] = t3;
42
+ } else t3 = $[6];
43
+ const reset = t3;
44
+ let t4;
45
+ if ($[7] !== copied || $[8] !== copy || $[9] !== error || $[10] !== reset) {
46
+ t4 = {
47
+ copy,
48
+ reset,
49
+ error,
50
+ copied
51
+ };
52
+ $[7] = copied;
53
+ $[8] = copy;
54
+ $[9] = error;
55
+ $[10] = reset;
56
+ $[11] = t4;
57
+ } else t4 = $[11];
58
+ return t4;
59
+ }
60
+
61
+ //#endregion
62
+ export { useClipboard };
@@ -21,7 +21,7 @@ function syncTheme(resolved) {
21
21
  }
22
22
  function useTheme() {
23
23
  const $ = c(11);
24
- const [theme, setThemeState] = useState(_temp);
24
+ const [theme, setTheme] = useState(_temp);
25
25
  const [systemTheme, setSystemTheme] = useState(_temp2);
26
26
  const resolvedTheme = theme === "system" ? systemTheme : theme;
27
27
  let t0;
@@ -62,15 +62,15 @@ function useTheme() {
62
62
  let t4;
63
63
  if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
64
64
  t4 = (nextTheme) => {
65
- setThemeState(nextTheme);
65
+ setTheme(nextTheme);
66
66
  };
67
67
  $[6] = t4;
68
68
  } else t4 = $[6];
69
- const setTheme = t4;
69
+ const setThemeCb = t4;
70
70
  let t5;
71
71
  if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
72
72
  t5 = () => {
73
- setThemeState(_temp3);
73
+ setTheme(_temp3);
74
74
  };
75
75
  $[7] = t5;
76
76
  } else t5 = $[7];
@@ -80,7 +80,7 @@ function useTheme() {
80
80
  t6 = {
81
81
  theme,
82
82
  resolvedTheme,
83
- setTheme,
83
+ setTheme: setThemeCb,
84
84
  toggleTheme
85
85
  };
86
86
  $[8] = resolvedTheme;
@@ -1,6 +1,5 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
2
  import { Button } from "./button.mjs";
3
- import "react";
4
3
  import { jsx, jsxs } from "react/jsx-runtime";
5
4
  import { c } from "react/compiler-runtime";
6
5
  import { AlertDialog as AlertDialog$1 } from "@base-ui/react/alert-dialog";
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
  import { Avatar as Avatar$1 } from "@base-ui/react/avatar";
@@ -5,7 +5,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
5
5
 
6
6
  //#region src/ui/badge.d.ts
7
7
  declare const badgeVariants: (props?: ({
8
- variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
8
+ variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | null | undefined;
9
9
  } & class_variance_authority_types0.ClassProp) | undefined) => string;
10
10
  declare function Badge({
11
11
  className,
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx, jsxs } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
  import { ChevronRight, MoreHorizontal } from "lucide-react";
@@ -5,7 +5,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
5
5
 
6
6
  //#region src/ui/button.d.ts
7
7
  declare const buttonVariants: (props?: ({
8
- variant?: "link" | "default" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
8
+ variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | null | undefined;
9
9
  size?: "xs" | "sm" | "icon-xs" | "icon-sm" | "default" | "lg" | "icon" | "icon-lg" | null | undefined;
10
10
  } & class_variance_authority_types0.ClassProp) | undefined) => string;
11
11
  declare function Button({
package/dist/ui/card.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
 
@@ -2,7 +2,6 @@ import { cn } from "../lib/utils.mjs";
2
2
  import { InputGroup, InputGroupAddon } from "./input-group.mjs";
3
3
  import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "./dialog.mjs";
4
4
  import { pkg } from "../vendor/cmdk/index.mjs";
5
- import "react";
6
5
  import { jsx, jsxs } from "react/jsx-runtime";
7
6
  import { c } from "react/compiler-runtime";
8
7
  import { CheckIcon, SearchIcon } from "lucide-react";
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx, jsxs } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
  import { CheckIcon, ChevronRightIcon } from "lucide-react";
@@ -1,6 +1,5 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
2
  import { Button } from "./button.mjs";
3
- import "react";
4
3
  import { jsx, jsxs } from "react/jsx-runtime";
5
4
  import { c } from "react/compiler-runtime";
6
5
  import { XIcon } from "lucide-react";
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx, jsxs } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
  import { Check, ChevronRight } from "lucide-react";
@@ -20,7 +20,7 @@ declare function FieldGroup({
20
20
  ...props
21
21
  }: React.ComponentProps<"div">): react_jsx_runtime0.JSX.Element;
22
22
  declare const fieldVariants: (props?: ({
23
- orientation?: "vertical" | "horizontal" | "responsive" | null | undefined;
23
+ orientation?: "horizontal" | "vertical" | "responsive" | null | undefined;
24
24
  } & class_variance_authority_types0.ClassProp) | undefined) => string;
25
25
  declare function Field({
26
26
  className,
@@ -2,7 +2,6 @@ import { cn } from "../lib/utils.mjs";
2
2
  import { Button } from "./button.mjs";
3
3
  import { Input } from "./input.mjs";
4
4
  import { Textarea } from "./textarea.mjs";
5
- import "react";
6
5
  import { jsx } from "react/jsx-runtime";
7
6
  import { c } from "react/compiler-runtime";
8
7
  import { cva } from "class-variance-authority";
package/dist/ui/input.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
  import { Input as Input$1 } from "@base-ui/react/input";
package/dist/ui/label.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
 
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx, jsxs } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
  import { ScrollArea as ScrollArea$1 } from "@base-ui/react/scroll-area";
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx, jsxs } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
  import { Check, ChevronDown, ChevronUp } from "lucide-react";
package/dist/ui/sheet.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
2
  import { Button } from "./button.mjs";
3
- import "react";
4
3
  import { jsx, jsxs } from "react/jsx-runtime";
5
4
  import { c } from "react/compiler-runtime";
6
5
  import { X } from "lucide-react";
package/dist/ui/table.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
 
@@ -1,5 +1,4 @@
1
1
  import { cn } from "../lib/utils.mjs";
2
- import "react";
3
2
  import { jsx } from "react/jsx-runtime";
4
3
  import { c } from "react/compiler-runtime";
5
4
 
@@ -0,0 +1,43 @@
1
+ //#region ../../vscode/syntaxes/ucd.tmLanguage.json
2
+ var ucd_tmLanguage_default = {
3
+ $schema: "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
4
+ name: "ucd",
5
+ displayName: "Unicode Character Database",
6
+ scopeName: "source.ucd",
7
+ patterns: [{ "include": "#comment" }, { "include": "#entry" }],
8
+ repository: {
9
+ "comment": {
10
+ "name": "comment.line.number-sign.ucd",
11
+ "match": "#.*$"
12
+ },
13
+ "entry": { "patterns": [
14
+ { "include": "#range" },
15
+ { "include": "#codepoint" },
16
+ { "include": "#separator" },
17
+ { "include": "#field" }
18
+ ] },
19
+ "range": {
20
+ "name": "constant.numeric.range.ucd",
21
+ "match": "\\b([0-9A-Fa-f]{4,6})\\.\\.([0-9A-Fa-f]{4,6})\\b",
22
+ "captures": {
23
+ "1": { "name": "constant.numeric.codepoint.ucd" },
24
+ "2": { "name": "constant.numeric.codepoint.ucd" }
25
+ }
26
+ },
27
+ "codepoint": {
28
+ "name": "constant.numeric.codepoint.ucd",
29
+ "match": "^[0-9A-Fa-f]{4,6}\\b"
30
+ },
31
+ "separator": {
32
+ "name": "punctuation.separator.ucd",
33
+ "match": ";"
34
+ },
35
+ "field": {
36
+ "name": "string.unquoted.field.ucd",
37
+ "match": "[^;#\\n]+"
38
+ }
39
+ }
40
+ };
41
+
42
+ //#endregion
43
+ export { ucd_tmLanguage_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucdjs-internal/shared-ui",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Lucas Nørgård",
@@ -26,8 +26,7 @@
26
26
  },
27
27
  "exports": {
28
28
  ".": "./dist/index.mjs",
29
- "./components/shiki-code": "./dist/components/shiki-code.mjs",
30
- "./components/theme-toggle": "./dist/components/theme-toggle.mjs",
29
+ "./components": "./dist/components/index.mjs",
31
30
  "./hooks": "./dist/hooks/index.mjs",
32
31
  "./lib/theme-script": "./dist/lib/theme-script.mjs",
33
32
  "./lib/utils": "./dist/lib/utils.mjs",
@@ -73,26 +72,26 @@
73
72
  "@fontsource-variable/inter": "5.2.8",
74
73
  "class-variance-authority": "0.7.1",
75
74
  "clsx": "2.1.1",
76
- "lucide-react": "0.574.0",
75
+ "lucide-react": "0.575.0",
77
76
  "react": "19.2.4",
78
77
  "react-dom": "19.2.4",
79
- "shiki": "3.22.0",
80
- "tailwind-merge": "3.4.1",
81
- "tailwindcss": "4.2.0",
78
+ "shiki": "3.23.0",
79
+ "tailwind-merge": "3.5.0",
80
+ "tailwindcss": "4.2.1",
82
81
  "tw-animate-css": "1.4.0",
83
82
  "zod": "4.3.6"
84
83
  },
85
84
  "devDependencies": {
86
85
  "@eslint-react/eslint-plugin": "2.13.0",
87
- "@luxass/eslint-config": "7.2.0",
86
+ "@luxass/eslint-config": "7.2.1",
88
87
  "@rollup/plugin-babel": "6.1.0",
89
88
  "@types/react": "19.2.14",
90
89
  "@types/react-dom": "19.2.3",
91
90
  "babel-plugin-react-compiler": "1.0.0",
92
- "eslint": "10.0.0",
93
- "eslint-plugin-format": "1.4.0",
91
+ "eslint": "10.0.2",
92
+ "eslint-plugin-format": "2.0.1",
94
93
  "eslint-plugin-react-hooks": "7.0.1",
95
- "eslint-plugin-react-refresh": "0.5.0",
94
+ "eslint-plugin-react-refresh": "0.5.2",
96
95
  "publint": "0.3.17",
97
96
  "tsdown": "0.20.3",
98
97
  "typescript": "5.9.3",