@imdz/react 0.0.0-stage → 0.1.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 +21 -0
- package/OFL.txt +189 -0
- package/README.md +85 -2
- package/dist/accordion.d.ts +13 -0
- package/dist/accordion.js +12 -0
- package/dist/alert.d.ts +7 -0
- package/dist/alert.js +11 -0
- package/dist/avatar.d.ts +8 -0
- package/dist/avatar.js +21 -0
- package/dist/badge.d.ts +6 -0
- package/dist/badge.js +11 -0
- package/dist/button.d.ts +8 -0
- package/dist/button.js +11 -0
- package/dist/card.d.ts +6 -0
- package/dist/card.js +11 -0
- package/dist/checkbox.d.ts +3 -0
- package/dist/checkbox.js +12 -0
- package/dist/cx.d.ts +1 -0
- package/dist/cx.js +3 -0
- package/dist/dark.css +13 -0
- package/dist/dialog.d.ts +12 -0
- package/dist/dialog.js +24 -0
- package/dist/fonts/inter-latin-400-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-600-normal.woff2 +0 -0
- package/dist/fonts/jetbrains-mono-latin-600-normal.woff2 +0 -0
- package/dist/fonts.css +24 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +17 -0
- package/dist/input.d.ts +7 -0
- package/dist/input.js +17 -0
- package/dist/progress.d.ts +8 -0
- package/dist/progress.js +13 -0
- package/dist/select.d.ts +7 -0
- package/dist/select.js +19 -0
- package/dist/skeleton.d.ts +7 -0
- package/dist/skeleton.js +12 -0
- package/dist/spinner.d.ts +7 -0
- package/dist/spinner.js +11 -0
- package/dist/style.d.ts +5 -0
- package/dist/style.js +26 -0
- package/dist/styles/accordion.d.ts +1 -0
- package/dist/styles/accordion.js +1 -0
- package/dist/styles/alert.d.ts +1 -0
- package/dist/styles/alert.js +1 -0
- package/dist/styles/avatar.d.ts +1 -0
- package/dist/styles/avatar.js +1 -0
- package/dist/styles/badge.d.ts +1 -0
- package/dist/styles/badge.js +1 -0
- package/dist/styles/button.d.ts +1 -0
- package/dist/styles/button.js +1 -0
- package/dist/styles/card.d.ts +1 -0
- package/dist/styles/card.js +1 -0
- package/dist/styles/checkbox.d.ts +1 -0
- package/dist/styles/checkbox.js +1 -0
- package/dist/styles/dialog.d.ts +1 -0
- package/dist/styles/dialog.js +1 -0
- package/dist/styles/field.d.ts +1 -0
- package/dist/styles/field.js +1 -0
- package/dist/styles/fonts.d.ts +1 -0
- package/dist/styles/fonts.js +1 -0
- package/dist/styles/progress.d.ts +1 -0
- package/dist/styles/progress.js +1 -0
- package/dist/styles/select.d.ts +1 -0
- package/dist/styles/select.js +1 -0
- package/dist/styles/skeleton.d.ts +1 -0
- package/dist/styles/skeleton.js +1 -0
- package/dist/styles/spinner.d.ts +1 -0
- package/dist/styles/spinner.js +1 -0
- package/dist/styles/switch.d.ts +1 -0
- package/dist/styles/switch.js +1 -0
- package/dist/styles/tabs.d.ts +1 -0
- package/dist/styles/tabs.js +1 -0
- package/dist/styles/textarea.d.ts +1 -0
- package/dist/styles/textarea.js +1 -0
- package/dist/styles/tooltip.d.ts +1 -0
- package/dist/styles/tooltip.js +1 -0
- package/dist/styles.css +872 -0
- package/dist/switch.d.ts +3 -0
- package/dist/switch.js +12 -0
- package/dist/tabs.d.ts +12 -0
- package/dist/tabs.js +36 -0
- package/dist/textarea.d.ts +7 -0
- package/dist/textarea.js +18 -0
- package/dist/tooltip.d.ts +7 -0
- package/dist/tooltip.js +12 -0
- package/package.json +47 -4
package/dist/switch.d.ts
ADDED
package/dist/switch.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
import { Style } from "./style.js";
|
|
4
|
+
import { css as fontsCss } from "./styles/fonts.js";
|
|
5
|
+
import { css as switchCss } from "./styles/switch.js";
|
|
6
|
+
/** The switch label goes as children. */
|
|
7
|
+
function SwitchBase({ className, children, ...props }) {
|
|
8
|
+
return (_jsxs("label", { className: cx("imdz-switch", className), children: [_jsx("input", { type: "checkbox", role: "switch", className: "imdz-switch-input", ...props }), _jsx("span", { children: children })] }));
|
|
9
|
+
}
|
|
10
|
+
export function Switch(props) {
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx(Style, { id: "fonts", css: fontsCss }), _jsx(Style, { id: "switch", css: switchCss }), _jsx(SwitchBase, { ...props })] }));
|
|
12
|
+
}
|
package/dist/tabs.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type TabItem = {
|
|
3
|
+
label: string;
|
|
4
|
+
content: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
export type TabsProps = {
|
|
7
|
+
items: TabItem[];
|
|
8
|
+
defaultIndex?: number;
|
|
9
|
+
onChange?: (index: number) => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function Tabs(props: TabsProps): import("react").JSX.Element;
|
package/dist/tabs.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useRef, useState, } from "react";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
import { Style } from "./style.js";
|
|
6
|
+
import { css as fontsCss } from "./styles/fonts.js";
|
|
7
|
+
import { css as tabsCss } from "./styles/tabs.js";
|
|
8
|
+
function TabsBase({ items, defaultIndex = 0, onChange, className, }) {
|
|
9
|
+
const [selected, setSelected] = useState(defaultIndex);
|
|
10
|
+
const tabRefs = useRef([]);
|
|
11
|
+
const baseId = useId();
|
|
12
|
+
function select(index) {
|
|
13
|
+
setSelected(index);
|
|
14
|
+
onChange?.(index);
|
|
15
|
+
}
|
|
16
|
+
function handleKeyDown(event) {
|
|
17
|
+
const last = items.length - 1;
|
|
18
|
+
const next = {
|
|
19
|
+
ArrowRight: selected === last ? 0 : selected + 1,
|
|
20
|
+
ArrowLeft: selected === 0 ? last : selected - 1,
|
|
21
|
+
Home: 0,
|
|
22
|
+
End: last,
|
|
23
|
+
}[event.key];
|
|
24
|
+
if (next === undefined)
|
|
25
|
+
return;
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
select(next);
|
|
28
|
+
tabRefs.current[next]?.focus();
|
|
29
|
+
}
|
|
30
|
+
return (_jsxs("div", { className: cx("imdz-tabs", className), children: [_jsx("div", { className: "imdz-tabs-list", role: "tablist", onKeyDown: handleKeyDown, children: items.map((item, index) => (_jsx("button", { ref: (element) => {
|
|
31
|
+
tabRefs.current[index] = element;
|
|
32
|
+
}, type: "button", role: "tab", id: `${baseId}-tab-${index}`, className: "imdz-tabs-tab", "aria-selected": index === selected, "aria-controls": `${baseId}-panel-${index}`, tabIndex: index === selected ? 0 : -1, onClick: () => select(index), children: item.label }, item.label))) }), items.map((item, index) => (_jsx("div", { role: "tabpanel", id: `${baseId}-panel-${index}`, className: "imdz-tabs-panel", "aria-labelledby": `${baseId}-tab-${index}`, hidden: index !== selected, children: item.content }, item.label)))] }));
|
|
33
|
+
}
|
|
34
|
+
export function Tabs(props) {
|
|
35
|
+
return (_jsxs(_Fragment, { children: [_jsx(Style, { id: "fonts", css: fontsCss }), _jsx(Style, { id: "tabs", css: tabsCss }), _jsx(TabsBase, { ...props })] }));
|
|
36
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type TextareaHTMLAttributes } from "react";
|
|
2
|
+
export type TextareaProps = TextareaHTMLAttributes<HTMLTextAreaElement> & {
|
|
3
|
+
label?: string;
|
|
4
|
+
hint?: string;
|
|
5
|
+
error?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function Textarea(props: TextareaProps): import("react").JSX.Element;
|
package/dist/textarea.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { cx } from "./cx.js";
|
|
5
|
+
import { Style } from "./style.js";
|
|
6
|
+
import { css as fontsCss } from "./styles/fonts.js";
|
|
7
|
+
import { css as fieldCss } from "./styles/field.js";
|
|
8
|
+
import { css as textareaCss } from "./styles/textarea.js";
|
|
9
|
+
function TextareaBase({ label, hint, error, id, rows = 4, className, ...props }) {
|
|
10
|
+
const generatedId = useId();
|
|
11
|
+
const inputId = id ?? generatedId;
|
|
12
|
+
const message = error || hint;
|
|
13
|
+
const messageId = `${inputId}-message`;
|
|
14
|
+
return (_jsxs("div", { className: "imdz-field", children: [label && (_jsx("label", { className: "imdz-field-label", htmlFor: inputId, children: label })), _jsx("textarea", { id: inputId, rows: rows, className: cx("imdz-field-input", "imdz-textarea", className), "aria-invalid": error ? true : undefined, "aria-describedby": message ? messageId : undefined, ...props }), message && (_jsx("p", { id: messageId, className: error ? "imdz-field-error" : "imdz-field-hint", children: message }))] }));
|
|
15
|
+
}
|
|
16
|
+
export function Textarea(props) {
|
|
17
|
+
return (_jsxs(_Fragment, { children: [_jsx(Style, { id: "fonts", css: fontsCss }), _jsx(Style, { id: "field", css: fieldCss }), _jsx(Style, { id: "textarea", css: textareaCss }), _jsx(TextareaBase, { ...props })] }));
|
|
18
|
+
}
|
package/dist/tooltip.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
import { Style } from "./style.js";
|
|
4
|
+
import { css as fontsCss } from "./styles/fonts.js";
|
|
5
|
+
import { css as tooltipCss } from "./styles/tooltip.js";
|
|
6
|
+
/** Wraps an element and shows a short text on hover or focus. */
|
|
7
|
+
function TooltipBase({ text, className, children }) {
|
|
8
|
+
return (_jsxs("span", { className: cx("imdz-tooltip", className), children: [children, _jsx("span", { className: "imdz-tooltip-bubble", role: "tooltip", children: text })] }));
|
|
9
|
+
}
|
|
10
|
+
export function Tooltip(props) {
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx(Style, { id: "fonts", css: fontsCss }), _jsx(Style, { id: "tooltip", css: tooltipCss }), _jsx(TooltipBase, { ...props })] }));
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imdz/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Accessible React components with plain CSS. npm i @imdz/react and import them: no Tailwind, no config, works with any React framework.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"*.css"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./dark.css": "./dist/dark.css",
|
|
18
|
+
"./styles.css": "./dist/styles.css",
|
|
19
|
+
"./fonts.css": "./dist/fonts.css",
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"OFL.txt",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://imdz.dev",
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "node scripts/build.mjs",
|
|
33
|
+
"prepack": "node scripts/build.mjs"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"react",
|
|
37
|
+
"components",
|
|
38
|
+
"ui",
|
|
39
|
+
"css",
|
|
40
|
+
"accessible"
|
|
41
|
+
],
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@fontsource/inter": "^5.3.0",
|
|
47
|
+
"@fontsource/jetbrains-mono": "^5.3.0"
|
|
48
|
+
}
|
|
49
|
+
}
|