tauri-plugin-system-symbols-react 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 insd47
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # tauri-plugin-system-symbols-react
2
+
3
+ React SVG components for
4
+ [`tauri-plugin-system-symbols`](https://github.com/insd47/tauri-plugin-system-symbols).
5
+
6
+ Use this package when your Tauri frontend is built with React. The native symbol
7
+ resolution, cache, and Tauri commands live in the core plugin repository:
8
+
9
+ https://github.com/insd47/tauri-plugin-system-symbols
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ pnpm add tauri-plugin-system-symbols-react tauri-plugin-system-symbols @tauri-apps/plugin-os
15
+ ```
16
+
17
+ The Tauri app must register:
18
+
19
+ - `tauri-plugin-system-symbols`
20
+ - `@tauri-apps/plugin-os`
21
+
22
+ See the core plugin README for Rust setup and capability permissions:
23
+
24
+ https://github.com/insd47/tauri-plugin-system-symbols#install
25
+
26
+ ## Usage
27
+
28
+ ```tsx
29
+ import Symbol from 'tauri-plugin-system-symbols-react'
30
+
31
+ export function Toolbar() {
32
+ return (
33
+ <Symbol
34
+ symbol="square.and.arrow.up"
35
+ icon={"\uE8BB"}
36
+ size={16}
37
+ />
38
+ )
39
+ }
40
+ ```
41
+
42
+ `size` is sent to the native resolver and is also used as the default SVG
43
+ `width` and `height`. When omitted, it defaults to `16`. `Symbol` uses
44
+ `platform()` from `@tauri-apps/plugin-os`.
45
+
46
+ ## Exports
47
+
48
+ - default `Symbol`
49
+
50
+ The component extends `SVGProps<SVGSVGElement>`.
51
+
52
+ ## License
53
+
54
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var pluginOs = require('@tauri-apps/plugin-os');
5
+ var react = require('react');
6
+ var tauriPluginSystemSymbols = require('tauri-plugin-system-symbols');
7
+
8
+ /**
9
+ * Renders a platform system symbol as an SVG.
10
+ *
11
+ * @param symbol SF Symbols name used when `platform()` is `"macos"`.
12
+ * @param icon Segoe glyph used when `platform()` is `"windows"`.
13
+ * @param size Target icon size in CSS pixels. Defaults to `16`.
14
+ * @param props
15
+ */
16
+ function Symbol({ symbol, icon, size, ...props }) {
17
+ const key = pluginOs.platform() === 'macos' ? symbol : icon;
18
+ const [current, setCurrent] = react.useState(() => ({ key, size, path: tauriPluginSystemSymbols.getCachedSymbol(key, size) }));
19
+ react.useLayoutEffect(() => {
20
+ if (current.key === key && current.size === size && current.path)
21
+ return;
22
+ let active = true;
23
+ tauriPluginSystemSymbols.getSymbol(key, size).then((path) => {
24
+ if (active)
25
+ setCurrent({ key, size, path });
26
+ });
27
+ return () => {
28
+ active = false;
29
+ };
30
+ }, [key, size]);
31
+ return (jsxRuntime.jsx("svg", { fill: "currentColor", height: size, viewBox: `0 0 ${size} ${size}`, width: size, "data-symbol": key, ...props, children: current.path?.map((props, index) => (jsxRuntime.jsx("path", { ...props }, index))) }));
32
+ }
33
+
34
+ module.exports = Symbol;
@@ -0,0 +1,19 @@
1
+ import * as react from 'react';
2
+ import { SVGProps } from 'react';
3
+
4
+ /**
5
+ * Renders a platform system symbol as an SVG.
6
+ *
7
+ * @param symbol SF Symbols name used when `platform()` is `"macos"`.
8
+ * @param icon Segoe glyph used when `platform()` is `"windows"`.
9
+ * @param size Target icon size in CSS pixels. Defaults to `16`.
10
+ * @param props
11
+ */
12
+ declare function Symbol({ symbol, icon, size, ...props }: Props): react.JSX.Element;
13
+ interface Props extends SVGProps<SVGSVGElement> {
14
+ symbol: string;
15
+ icon: string;
16
+ size: number;
17
+ }
18
+
19
+ export { Symbol as default };
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { platform } from '@tauri-apps/plugin-os';
3
+ import { useState, useLayoutEffect } from 'react';
4
+ import { getCachedSymbol, getSymbol } from 'tauri-plugin-system-symbols';
5
+
6
+ /**
7
+ * Renders a platform system symbol as an SVG.
8
+ *
9
+ * @param symbol SF Symbols name used when `platform()` is `"macos"`.
10
+ * @param icon Segoe glyph used when `platform()` is `"windows"`.
11
+ * @param size Target icon size in CSS pixels. Defaults to `16`.
12
+ * @param props
13
+ */
14
+ function Symbol({ symbol, icon, size, ...props }) {
15
+ const key = platform() === 'macos' ? symbol : icon;
16
+ const [current, setCurrent] = useState(() => ({ key, size, path: getCachedSymbol(key, size) }));
17
+ useLayoutEffect(() => {
18
+ if (current.key === key && current.size === size && current.path)
19
+ return;
20
+ let active = true;
21
+ getSymbol(key, size).then((path) => {
22
+ if (active)
23
+ setCurrent({ key, size, path });
24
+ });
25
+ return () => {
26
+ active = false;
27
+ };
28
+ }, [key, size]);
29
+ return (jsx("svg", { fill: "currentColor", height: size, viewBox: `0 0 ${size} ${size}`, width: size, "data-symbol": key, ...props, children: current.path?.map((props, index) => (jsx("path", { ...props }, index))) }));
30
+ }
31
+
32
+ export { Symbol as default };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "tauri-plugin-system-symbols-react",
3
+ "version": "0.2.0",
4
+ "description": "React SVG components for tauri-plugin-system-symbols.",
5
+ "license": "MIT",
6
+ "author": "insd47",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/insd47/tauri-plugin-system-symbols-react.git"
10
+ },
11
+ "packageManager": "pnpm@10.24.0",
12
+ "type": "module",
13
+ "types": "./dist/index.d.ts",
14
+ "main": "./dist/index.cjs",
15
+ "module": "./dist/index.js",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js",
20
+ "require": "./dist/index.cjs"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "scripts": {
29
+ "build": "rollup -c",
30
+ "check": "tsc --noEmit",
31
+ "prepack": "pnpm run build"
32
+ },
33
+ "peerDependencies": {
34
+ "@tauri-apps/plugin-os": "^2.3.2",
35
+ "react": ">=18",
36
+ "tauri-plugin-system-symbols": "^0.1.0"
37
+ },
38
+ "devDependencies": {
39
+ "@rollup/plugin-typescript": "^12.3.0",
40
+ "@tauri-apps/plugin-os": "^2.3.2",
41
+ "@types/react": "^19.0.0",
42
+ "prettier": "^3.8.4",
43
+ "react": "^19.0.0",
44
+ "rollup": "^4.44.0",
45
+ "rollup-plugin-dts": "^6.2.1",
46
+ "tauri-plugin-system-symbols": "file:../tauri-plugin-system-symbols",
47
+ "tslib": "^2.8.1",
48
+ "typescript": "^5.8.3"
49
+ }
50
+ }