@flood-md/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/README.md +17 -2
- package/dist/index.d.ts +35 -0
- package/dist/index.js +36 -0
- package/dist/styles.css +191 -0
- package/package.json +36 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Oleg (tillwithered)
|
|
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
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @flood-md/react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Original Flood components for React 18.3/19 and Next.js.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import "@flood-md/react/styles.css";
|
|
7
|
+
import { Button, Field, Input } from "@flood-md/react";
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Exports: Button, Input, Textarea, Checkbox, Radio, Switch, Field, Link and their
|
|
11
|
+
TypeScript prop types. Button variants: solid/outline/ghost; sizes: sm/md.
|
|
12
|
+
Loading buttons disable activation. Choice components require a visible label.
|
|
13
|
+
Field uses a function child: `{props => <Input {...props} />}` to wire label and
|
|
14
|
+
description associations. Compose Field in a client component in Next.js.
|
|
15
|
+
|
|
16
|
+
Import CSS once in Next app/layout.tsx. Add `"use client"` to host components with
|
|
17
|
+
callbacks/state. Override semantic --flood-* variables after the CSS import.
|
|
18
|
+
Native HTML props and refs are forwarded. No Tailwind or third-party UI dependency.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type InputHTMLAttributes, type TextareaHTMLAttributes, type AnchorHTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
3
|
+
variant?: "solid" | "outline" | "ghost";
|
|
4
|
+
size?: "sm" | "md";
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
9
|
+
invalid?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const Input: import("react").ForwardRefExoticComponent<InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
12
|
+
export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
13
|
+
invalid?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
16
|
+
export interface ChoiceProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size"> {
|
|
17
|
+
label: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare const Checkbox: import("react").ForwardRefExoticComponent<ChoiceProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
20
|
+
export declare const Radio: import("react").ForwardRefExoticComponent<ChoiceProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
21
|
+
export declare const Switch: import("react").ForwardRefExoticComponent<ChoiceProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
22
|
+
export interface FieldControlProps {
|
|
23
|
+
id: string;
|
|
24
|
+
"aria-describedby"?: string;
|
|
25
|
+
"aria-invalid"?: true;
|
|
26
|
+
}
|
|
27
|
+
export interface FieldProps {
|
|
28
|
+
id?: string;
|
|
29
|
+
label: ReactNode;
|
|
30
|
+
hint?: ReactNode;
|
|
31
|
+
error?: ReactNode;
|
|
32
|
+
children: (props: FieldControlProps) => ReactNode;
|
|
33
|
+
}
|
|
34
|
+
export declare function Field({ id: explicitId, label, hint, error, children, }: FieldProps): import("react").JSX.Element;
|
|
35
|
+
export declare const Link: import("react").ForwardRefExoticComponent<AnchorHTMLAttributes<HTMLAnchorElement> & import("react").RefAttributes<HTMLAnchorElement>>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useId, } from "react";
|
|
4
|
+
const classes = (...values) => values.filter(Boolean).join(" ");
|
|
5
|
+
export const Button = forwardRef(function Button({ variant = "solid", size = "md", loading = false, disabled, type = "button", className, children, ...props }, ref) {
|
|
6
|
+
return (_jsxs("button", { ...props, ref: ref, type: type, disabled: disabled || loading, "aria-busy": loading || undefined, className: classes("flood-button", `flood-button--${variant}`, `flood-button--${size}`, className), children: [loading && _jsx("span", { className: "flood-spinner", "aria-hidden": "true" }), children] }));
|
|
7
|
+
});
|
|
8
|
+
export const Input = forwardRef(function Input({ invalid, className, ...props }, ref) {
|
|
9
|
+
return (_jsx("input", { ...props, ref: ref, "aria-invalid": invalid || props["aria-invalid"], className: classes("flood-input", className) }));
|
|
10
|
+
});
|
|
11
|
+
export const Textarea = forwardRef(function Textarea({ invalid, className, ...props }, ref) {
|
|
12
|
+
return (_jsx("textarea", { ...props, ref: ref, "aria-invalid": invalid || props["aria-invalid"], className: classes("flood-input", "flood-textarea", className) }));
|
|
13
|
+
});
|
|
14
|
+
export const Checkbox = forwardRef(function Checkbox({ label, className, ...props }, ref) {
|
|
15
|
+
return (_jsxs("label", { className: classes("flood-choice", className), children: [_jsx("input", { ...props, ref: ref, type: "checkbox", className: "flood-check" }), _jsx("span", { children: label })] }));
|
|
16
|
+
});
|
|
17
|
+
export const Radio = forwardRef(function Radio({ label, className, ...props }, ref) {
|
|
18
|
+
return (_jsxs("label", { className: classes("flood-choice", className), children: [_jsx("input", { ...props, ref: ref, type: "radio", className: "flood-check" }), _jsx("span", { children: label })] }));
|
|
19
|
+
});
|
|
20
|
+
export const Switch = forwardRef(function Switch({ label, className, ...props }, ref) {
|
|
21
|
+
return (_jsxs("label", { className: classes("flood-choice", "flood-switch", className), children: [_jsx("span", { children: label }), _jsx("input", { ...props, ref: ref, type: "checkbox", role: "switch", className: "flood-switch-input" })] }));
|
|
22
|
+
});
|
|
23
|
+
export function Field({ id: explicitId, label, hint, error, children, }) {
|
|
24
|
+
const generatedId = useId();
|
|
25
|
+
const id = explicitId ?? `flood-${generatedId}`;
|
|
26
|
+
const description = [hint && `${id}-hint`, error && `${id}-error`].filter(Boolean).join(" ") ||
|
|
27
|
+
undefined;
|
|
28
|
+
return (_jsxs("div", { className: "flood-field", children: [_jsx("label", { className: "flood-label", htmlFor: id, children: label }), children({
|
|
29
|
+
id,
|
|
30
|
+
"aria-describedby": description,
|
|
31
|
+
"aria-invalid": error ? true : undefined,
|
|
32
|
+
}), hint && (_jsx("div", { id: `${id}-hint`, className: "flood-hint", children: hint })), error && (_jsx("div", { id: `${id}-error`, className: "flood-error", role: "alert", children: error }))] }));
|
|
33
|
+
}
|
|
34
|
+
export const Link = forwardRef(function Link({ className, ...props }, ref) {
|
|
35
|
+
return (_jsx("a", { ...props, ref: ref, className: classes("flood-link", className) }));
|
|
36
|
+
});
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
@import "@flood-md/tokens/tokens.css";
|
|
2
|
+
|
|
3
|
+
:where(.flood-button, .flood-input, .flood-choice, .flood-field, .flood-link) {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
font-family: var(--flood-font-sans);
|
|
6
|
+
font-size: var(--flood-text-sm);
|
|
7
|
+
line-height: 1.45;
|
|
8
|
+
}
|
|
9
|
+
:where(
|
|
10
|
+
.flood-button,
|
|
11
|
+
.flood-input,
|
|
12
|
+
.flood-check,
|
|
13
|
+
.flood-switch-input,
|
|
14
|
+
.flood-link
|
|
15
|
+
):focus-visible {
|
|
16
|
+
outline: 2px solid var(--flood-focus);
|
|
17
|
+
outline-offset: 3px;
|
|
18
|
+
}
|
|
19
|
+
.flood-button {
|
|
20
|
+
display: inline-flex;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: var(--flood-space-2);
|
|
24
|
+
min-height: var(--flood-control-height);
|
|
25
|
+
padding: 8px 16px;
|
|
26
|
+
border: 1px solid transparent;
|
|
27
|
+
border-radius: var(--flood-radius-md);
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
transition: opacity var(--flood-duration);
|
|
31
|
+
}
|
|
32
|
+
.flood-button--solid {
|
|
33
|
+
background: var(--flood-action);
|
|
34
|
+
color: var(--flood-action-text);
|
|
35
|
+
}
|
|
36
|
+
.flood-button--outline {
|
|
37
|
+
border-color: var(--flood-border);
|
|
38
|
+
background: var(--flood-surface);
|
|
39
|
+
color: var(--flood-text);
|
|
40
|
+
}
|
|
41
|
+
.flood-button--ghost {
|
|
42
|
+
background: transparent;
|
|
43
|
+
color: var(--flood-text);
|
|
44
|
+
}
|
|
45
|
+
.flood-button--sm {
|
|
46
|
+
min-height: 32px;
|
|
47
|
+
padding: 4px 12px;
|
|
48
|
+
}
|
|
49
|
+
.flood-button--solid:hover:not(:disabled) {
|
|
50
|
+
opacity: 0.86;
|
|
51
|
+
}
|
|
52
|
+
.flood-button--outline:hover:not(:disabled),
|
|
53
|
+
.flood-button--ghost:hover:not(:disabled) {
|
|
54
|
+
background: var(--flood-surface-hover);
|
|
55
|
+
}
|
|
56
|
+
.flood-button:disabled {
|
|
57
|
+
cursor: not-allowed;
|
|
58
|
+
background: var(--flood-disabled);
|
|
59
|
+
color: var(--flood-disabled-text);
|
|
60
|
+
}
|
|
61
|
+
.flood-input {
|
|
62
|
+
width: 100%;
|
|
63
|
+
min-height: var(--flood-control-height);
|
|
64
|
+
padding: 9px 12px;
|
|
65
|
+
border: 1px solid var(--flood-border);
|
|
66
|
+
border-radius: var(--flood-radius-md);
|
|
67
|
+
background: var(--flood-surface);
|
|
68
|
+
color: var(--flood-text);
|
|
69
|
+
}
|
|
70
|
+
.flood-input::placeholder {
|
|
71
|
+
color: var(--flood-muted);
|
|
72
|
+
}
|
|
73
|
+
.flood-input[aria-invalid="true"] {
|
|
74
|
+
border-color: var(--flood-danger);
|
|
75
|
+
}
|
|
76
|
+
.flood-input:disabled {
|
|
77
|
+
background: var(--flood-disabled);
|
|
78
|
+
color: var(--flood-disabled-text);
|
|
79
|
+
cursor: not-allowed;
|
|
80
|
+
}
|
|
81
|
+
.flood-textarea {
|
|
82
|
+
min-height: 96px;
|
|
83
|
+
resize: vertical;
|
|
84
|
+
}
|
|
85
|
+
.flood-choice {
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: var(--flood-space-2);
|
|
89
|
+
min-height: var(--flood-control-height);
|
|
90
|
+
color: var(--flood-text);
|
|
91
|
+
cursor: pointer;
|
|
92
|
+
}
|
|
93
|
+
.flood-choice:has(input:disabled) {
|
|
94
|
+
cursor: not-allowed;
|
|
95
|
+
color: var(--flood-disabled-text);
|
|
96
|
+
}
|
|
97
|
+
.flood-check {
|
|
98
|
+
margin: 0;
|
|
99
|
+
width: 18px;
|
|
100
|
+
height: 18px;
|
|
101
|
+
flex-shrink: 0;
|
|
102
|
+
accent-color: var(--flood-action);
|
|
103
|
+
cursor: inherit;
|
|
104
|
+
}
|
|
105
|
+
.flood-switch {
|
|
106
|
+
justify-content: space-between;
|
|
107
|
+
gap: var(--flood-space-6);
|
|
108
|
+
}
|
|
109
|
+
.flood-switch-input {
|
|
110
|
+
appearance: none;
|
|
111
|
+
flex-shrink: 0;
|
|
112
|
+
width: 36px;
|
|
113
|
+
height: 22px;
|
|
114
|
+
margin: 0;
|
|
115
|
+
padding: 2px;
|
|
116
|
+
border: 1px solid var(--flood-border);
|
|
117
|
+
border-radius: 999px;
|
|
118
|
+
background: var(--flood-surface-hover);
|
|
119
|
+
cursor: inherit;
|
|
120
|
+
}
|
|
121
|
+
.flood-switch-input::before {
|
|
122
|
+
content: "";
|
|
123
|
+
display: block;
|
|
124
|
+
width: 16px;
|
|
125
|
+
height: 16px;
|
|
126
|
+
border-radius: 50%;
|
|
127
|
+
background: var(--flood-muted);
|
|
128
|
+
transition: transform var(--flood-duration);
|
|
129
|
+
}
|
|
130
|
+
.flood-switch-input:checked {
|
|
131
|
+
background: var(--flood-action);
|
|
132
|
+
border-color: var(--flood-action);
|
|
133
|
+
}
|
|
134
|
+
.flood-switch-input:checked::before {
|
|
135
|
+
transform: translateX(14px);
|
|
136
|
+
background: var(--flood-action-text);
|
|
137
|
+
}
|
|
138
|
+
.flood-switch-input:disabled {
|
|
139
|
+
opacity: 0.6;
|
|
140
|
+
}
|
|
141
|
+
.flood-field {
|
|
142
|
+
display: grid;
|
|
143
|
+
gap: var(--flood-space-2);
|
|
144
|
+
}
|
|
145
|
+
.flood-label {
|
|
146
|
+
font-weight: 500;
|
|
147
|
+
color: var(--flood-text);
|
|
148
|
+
}
|
|
149
|
+
.flood-hint {
|
|
150
|
+
color: var(--flood-muted);
|
|
151
|
+
font-size: var(--flood-text-xs);
|
|
152
|
+
}
|
|
153
|
+
.flood-error {
|
|
154
|
+
color: var(--flood-danger);
|
|
155
|
+
font-size: var(--flood-text-xs);
|
|
156
|
+
}
|
|
157
|
+
.flood-link {
|
|
158
|
+
color: var(--flood-text);
|
|
159
|
+
text-underline-offset: 4px;
|
|
160
|
+
text-decoration-thickness: 1px;
|
|
161
|
+
}
|
|
162
|
+
.flood-spinner {
|
|
163
|
+
width: 12px;
|
|
164
|
+
height: 12px;
|
|
165
|
+
border: 2px solid currentColor;
|
|
166
|
+
border-right-color: transparent;
|
|
167
|
+
border-radius: 50%;
|
|
168
|
+
animation: flood-spin 0.7s linear infinite;
|
|
169
|
+
}
|
|
170
|
+
@keyframes flood-spin {
|
|
171
|
+
to {
|
|
172
|
+
transform: rotate(360deg);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
@media (prefers-reduced-motion: reduce) {
|
|
176
|
+
.flood-spinner {
|
|
177
|
+
animation: none;
|
|
178
|
+
}
|
|
179
|
+
.flood-switch-input::before,
|
|
180
|
+
.flood-button {
|
|
181
|
+
transition: none;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
@media (forced-colors: active) {
|
|
185
|
+
.flood-switch-input {
|
|
186
|
+
appearance: auto;
|
|
187
|
+
}
|
|
188
|
+
.flood-switch-input::before {
|
|
189
|
+
display: none;
|
|
190
|
+
}
|
|
191
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flood-md/react",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Original Flood components for React and Next.js.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/tillwithered/flood.md.git",
|
|
10
|
+
"directory": "packages/react"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"**/*.css"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./styles.css": "./dist/styles.css"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^18.3.0 || ^19.0.0",
|
|
30
|
+
"react-dom": "^18.3.0 || ^19.0.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@flood-md/tokens": "0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|