@azmr/ui 0.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alshafaraz Gazi / Azmara Technologies
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,73 @@
1
+ # @azmr/ui
2
+
3
+ React components wired to reactive Signals. The `Grid` component re-renders automatically when its Signal changes — no state management needed.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @azmr/ui @azmr/core react react-dom
9
+ # or
10
+ npm install @azmr/ui @azmr/core react react-dom
11
+ ```
12
+
13
+ ## Grid
14
+
15
+ ```tsx
16
+ import { Signal } from "@azmr/core";
17
+ import { Grid } from "@azmr/ui";
18
+
19
+ const customers = new Signal([
20
+ { name: "Aroha", balance: 150 },
21
+ { name: "Mere", balance: 320 },
22
+ ]);
23
+
24
+ function App() {
25
+ return (
26
+ <Grid
27
+ signal={customers}
28
+ labels={{ name: "Customer", balance: "Balance ($)" }}
29
+ />
30
+ );
31
+ }
32
+
33
+ // Grid updates automatically
34
+ customers.set([...customers.peek(), { name: "Tane", balance: 0 }]);
35
+ ```
36
+
37
+ ## useSignal
38
+
39
+ Hook to subscribe any React component to a Signal.
40
+
41
+ ```tsx
42
+ import { useSignal } from "@azmr/ui";
43
+
44
+ function Counter({ count }: { count: Signal<number> }) {
45
+ const value = useSignal(count); // push-based, no polling
46
+ return <span>{value}</span>;
47
+ }
48
+ ```
49
+
50
+ ## Grid Props
51
+
52
+ | Prop | Type | Description |
53
+ |---|---|---|
54
+ | `signal` | `Signal<T[]>` | Reactive data source |
55
+ | `columns` | `(keyof T)[]` | Optional column order |
56
+ | `labels` | `Partial<Record<keyof T, string>>` | Optional column label overrides |
57
+ | `emptyMessage` | `string` | Message shown when Signal is empty |
58
+
59
+ All cell values are rendered through React's JSX escaping — `dangerouslySetInnerHTML` is never used.
60
+
61
+ ## Requirements
62
+
63
+ - Node.js ≥ 18
64
+ - React 18 or 19
65
+ - TypeScript ≥ 5 (types included)
66
+
67
+ ## Documentation
68
+
69
+ Full docs at [docs.azmara.io](https://docs.azmara.io)
70
+
71
+ ## License
72
+
73
+ MIT © [Azmara Technologies](https://azmara.io)
@@ -0,0 +1,23 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Signal } from '@azmr/core';
3
+
4
+ interface GridProps<T extends Record<string, unknown>> {
5
+ signal: Signal<T[]>;
6
+ /** Optional column order. Defaults to keys from first row. */
7
+ columns?: (keyof T)[];
8
+ /** Optional label overrides per column key. */
9
+ labels?: Partial<Record<keyof T, string>>;
10
+ emptyMessage?: string;
11
+ }
12
+ /**
13
+ * A reactive data grid that automatically re-renders when the Signal updates.
14
+ * All cell values are rendered via React's JSX escaping — no dangerouslySetInnerHTML.
15
+ */
16
+ declare function Grid<T extends Record<string, unknown>>({ signal, columns, labels, emptyMessage, }: GridProps<T>): react_jsx_runtime.JSX.Element;
17
+
18
+ /**
19
+ * React hook that subscribes to a Signal and triggers re-renders on change.
20
+ */
21
+ declare function useSignal<T>(signal: Signal<T>): T;
22
+
23
+ export { Grid, useSignal };
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ // src/useSignal.ts
2
+ import { useEffect, useState } from "react";
3
+ function useSignal(signal) {
4
+ const [value, setValue] = useState(() => signal.get());
5
+ useEffect(() => {
6
+ setValue(signal.get());
7
+ return signal.subscribe(setValue);
8
+ }, [signal]);
9
+ return value;
10
+ }
11
+
12
+ // src/Grid.tsx
13
+ import { jsx, jsxs } from "react/jsx-runtime";
14
+ function Grid({
15
+ signal,
16
+ columns,
17
+ labels,
18
+ emptyMessage = "No records found."
19
+ }) {
20
+ const data = useSignal(signal);
21
+ if (data.length === 0) {
22
+ return /* @__PURE__ */ jsx("p", { style: { color: "#888", fontStyle: "italic" }, children: emptyMessage });
23
+ }
24
+ const cols = columns ?? Object.keys(data[0]);
25
+ return /* @__PURE__ */ jsxs("table", { style: { borderCollapse: "collapse", width: "100%" }, children: [
26
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: cols.map((col) => /* @__PURE__ */ jsx(
27
+ "th",
28
+ {
29
+ style: {
30
+ textAlign: "left",
31
+ padding: "8px 12px",
32
+ borderBottom: "2px solid #e2e8f0",
33
+ fontWeight: 600,
34
+ fontSize: "0.875rem",
35
+ color: "#374151"
36
+ },
37
+ children: labels?.[col] ?? String(col)
38
+ },
39
+ String(col)
40
+ )) }) }),
41
+ /* @__PURE__ */ jsx("tbody", { children: data.map((row, rowIndex) => (
42
+ // biome-ignore lint/suspicious/noArrayIndexKey: row has no guaranteed unique ID at this layer
43
+ /* @__PURE__ */ jsx("tr", { style: { backgroundColor: rowIndex % 2 === 0 ? "#fff" : "#f9fafb" }, children: cols.map((col) => /* @__PURE__ */ jsx(
44
+ "td",
45
+ {
46
+ style: {
47
+ padding: "8px 12px",
48
+ borderBottom: "1px solid #e2e8f0",
49
+ fontSize: "0.875rem",
50
+ color: "#1f2937"
51
+ },
52
+ children: String(row[col] ?? "")
53
+ },
54
+ String(col)
55
+ )) }, rowIndex)
56
+ )) })
57
+ ] });
58
+ }
59
+ export {
60
+ Grid,
61
+ useSignal
62
+ };
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@azmr/ui",
3
+ "version": "0.0.1",
4
+ "description": "React UI components wired to reactive Signals — Grid, useSignal",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Alshafaraz Gazi <alshafaraz.gazi@gmail.com>",
8
+ "homepage": "https://docs.azmara.io",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/coderchef26/azmara-platform.git",
12
+ "directory": "packages/ui"
13
+ },
14
+ "keywords": [
15
+ "react",
16
+ "components",
17
+ "grid",
18
+ "reactive",
19
+ "signals",
20
+ "data-table",
21
+ "azmara"
22
+ ],
23
+ "engines": {
24
+ "node": ">=18.0.0"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "exports": {
32
+ ".": {
33
+ "import": "./dist/index.js",
34
+ "types": "./dist/index.d.ts"
35
+ }
36
+ },
37
+ "dependencies": {
38
+ "@azmr/core": "0.0.1"
39
+ },
40
+ "peerDependencies": {
41
+ "react": "^18.0.0 || ^19.0.0",
42
+ "react-dom": "^18.0.0 || ^19.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@types/react": "^18.3.12",
46
+ "@types/react-dom": "^18.3.1",
47
+ "@vitest/browser": "^2.1.9",
48
+ "jsdom": "^25.0.1",
49
+ "react": "^18.3.1",
50
+ "react-dom": "^18.3.1",
51
+ "tsup": "^8.3.5",
52
+ "typescript": "^5.7.3",
53
+ "vitest": "^2.1.9"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "scripts": {
59
+ "build": "tsup src/index.ts --format esm --dts --clean",
60
+ "dev": "tsup src/index.ts --format esm --dts --watch",
61
+ "check-types": "tsc --noEmit",
62
+ "test": "vitest run",
63
+ "clean": "rm -rf dist"
64
+ }
65
+ }