@wintermuted/ui-theme 0.21.4 → 0.21.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.
- package/README.md +144 -0
- package/package.json +78 -4
- package/react/index.d.ts +74 -0
- package/react/index.js +325 -0
- package/react/select.d.ts +10 -0
- package/react/select.js +38 -0
- package/react/theme.d.ts +9 -0
- package/react/theme.js +41 -0
- package/styles/components/accordion.css +18 -0
- package/styles/components/alert.css +27 -0
- package/styles/components/badge.css +24 -0
- package/styles/components/card.css +9 -0
- package/styles/components/dialog.css +24 -0
- package/styles/components/field.css +45 -0
- package/styles/components/list-group.css +14 -0
- package/styles/components/menu.css +47 -0
- package/styles/components/nav.css +18 -0
- package/styles/components/progress.css +23 -0
- package/styles/components/search-select.css +5 -0
- package/styles/components/spinner.css +34 -0
- package/styles/components/tab-bar.css +17 -0
- package/styles/components/table.css +27 -0
- package/styles/components/tooltip.css +20 -0
- package/styles/components.css +12 -0
- package/styles/tokens.css +12 -0
package/README.md
CHANGED
|
@@ -74,12 +74,28 @@ Available modular entry points:
|
|
|
74
74
|
|
|
75
75
|
This repo includes a static showcase app for validating common component scenarios.
|
|
76
76
|
|
|
77
|
+
The optional React examples run through the local Vite development server; the existing HTML pages stay static.
|
|
78
|
+
|
|
77
79
|
```bash
|
|
78
80
|
npm run showcase:serve
|
|
79
81
|
```
|
|
80
82
|
|
|
81
83
|
Then open `http://localhost:4174/showcase/`.
|
|
82
84
|
|
|
85
|
+
### GitHub Copilot app
|
|
86
|
+
|
|
87
|
+
Review and accept `.github/github-app.yml` when prompted by the app. Node.js 22
|
|
88
|
+
and npm must be available locally.
|
|
89
|
+
|
|
90
|
+
The **Install dependencies** script runs `npm ci --no-audit --no-fund` when a
|
|
91
|
+
session is created and can also be rerun manually. **Run showcase** starts the
|
|
92
|
+
existing Vite development server on port 4174.
|
|
93
|
+
|
|
94
|
+
Open `http://127.0.0.1:4174/showcase/` to view the documentation and React examples.
|
|
95
|
+
Automatic browser opening is disabled because Vite reports the repository root
|
|
96
|
+
URL, while the showcase lives under `/showcase/`. Stop the run script before
|
|
97
|
+
starting the showcase in another session, since the server requires port 4174.
|
|
98
|
+
|
|
83
99
|
Helpful local viewing scripts:
|
|
84
100
|
|
|
85
101
|
```bash
|
|
@@ -152,3 +168,131 @@ Scripts:
|
|
|
152
168
|
- The package intentionally avoids application-specific layout opinions.
|
|
153
169
|
- Projects should keep product-specific selectors and layout rules in their own repositories.
|
|
154
170
|
- Publishing is handled through GitHub Actions to npmjs.
|
|
171
|
+
|
|
172
|
+
## Optional React components
|
|
173
|
+
|
|
174
|
+
The CSS/root entry points are unchanged and do not load or install React. Install React
|
|
175
|
+
and ReactDOM 18.3+ (or 19) only for the React API. Add react-select 5.8+ only when using
|
|
176
|
+
the separate select adapter:
|
|
177
|
+
|
|
178
|
+
```powershell
|
|
179
|
+
npm install @wintermuted/ui-theme react react-dom
|
|
180
|
+
npm install react-select
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import "@wintermuted/ui-theme/index.css";
|
|
185
|
+
import { createRoot } from "react-dom/client";
|
|
186
|
+
import {
|
|
187
|
+
Button, Card, CardHeader, CardTitle, CardBody, CardText, FieldGroup,
|
|
188
|
+
Input, ThemeProvider, ThemeSelect,
|
|
189
|
+
} from "@wintermuted/ui-theme/react";
|
|
190
|
+
import { initTheme } from "@wintermuted/ui-theme/theme";
|
|
191
|
+
|
|
192
|
+
initTheme({ storageKey: "my-app:theme" });
|
|
193
|
+
createRoot(document.getElementById("root")!).render(
|
|
194
|
+
<ThemeProvider storageKey="my-app:theme">
|
|
195
|
+
<ThemeSelect />
|
|
196
|
+
<Card>
|
|
197
|
+
<CardHeader><CardTitle>Departures</CardTitle></CardHeader>
|
|
198
|
+
<CardBody>
|
|
199
|
+
<CardText>Select stops to see arrivals.</CardText>
|
|
200
|
+
<FieldGroup label="Stop name" hint="Enter part of a name."><Input /></FieldGroup>
|
|
201
|
+
<Button onClick={refresh}>Refresh arrivals</Button>
|
|
202
|
+
</CardBody>
|
|
203
|
+
</Card>
|
|
204
|
+
</ThemeProvider>
|
|
205
|
+
);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
These are distributable ES modules, not TSX source, with separate declaration files.
|
|
209
|
+
No application compiler needs to transpile JSX inside this package. React is never bundled.
|
|
210
|
+
The `typesVersions` entries support TypeScript 4.9's legacy `moduleResolution: node`;
|
|
211
|
+
conditional exports support newer resolvers. CI checks packed-package React 18,
|
|
212
|
+
TypeScript 4.9, Vite 5 and Webpack 5 consumers, plus CSS-only installation without peers.
|
|
213
|
+
For CRA 5/Jest consumers, allow this ESM package through Babel's dependency transform:
|
|
214
|
+
|
|
215
|
+
```json
|
|
216
|
+
{
|
|
217
|
+
"jest": {
|
|
218
|
+
"transformIgnorePatterns": ["node_modules/(?!@wintermuted/ui-theme/)"]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Component contracts
|
|
224
|
+
|
|
225
|
+
All components come from `@wintermuted/ui-theme/react` except `MultiSelect`.
|
|
226
|
+
Primitives preserve native attributes, `className`, `style`, children and refs.
|
|
227
|
+
|
|
228
|
+
| Export | Contract |
|
|
229
|
+
| --- | --- |
|
|
230
|
+
| `Button` | Native button; defaults to `type="button"`. `variant`: primary, secondary, ghost, danger, success, warning, link. Optional `size="sm"` and decorative `icon`. Supply an accessible name for icon-only buttons. |
|
|
231
|
+
| `Badge`, `Alert` | `tone`: neutral, info, success, warning, danger. Alert defaults to `role="status"`; opt into `role="alert"` for urgent messages. |
|
|
232
|
+
| `Card`, `CardHeader`, `CardBody`, `CardTitle`, `CardText`, `CardFooter` | Semantic section/header/div/h3/p/footer slots; `as` selects an element or custom component. |
|
|
233
|
+
| `ListGroup`, `ListItem`, `Nav` | Semantic ul/li/nav; `as` supports other elements or router links without a router dependency. Label navigation regions and use `aria-current="page"` on active links. Compose grid/flex layout in your application. |
|
|
234
|
+
| `Input`, `Select` | Native input/select attributes and refs, including controlled or default values. Select takes native option children. |
|
|
235
|
+
| `FieldGroup` | Required `label` and one control element; optional `htmlFor`, `hint`, `error`. Generates IDs and merges `aria-describedby`; errors set `aria-invalid`. Custom controls must forward the supplied ID/ARIA props to their input. |
|
|
236
|
+
| `Table` | Native table attributes/ref, optional `responsive` overflow region. Provide a caption or `aria-label`, and native thead/tbody/th scope markup. |
|
|
237
|
+
| `Spinner` | `label` defaults to Loading; status text stays available with reduced motion. |
|
|
238
|
+
| `ProgressBar` | Native progress element, numeric `value`/`max` (defaults 0/100), accessible `label` or native label/ARIA association. Values clamp to range; nonfinite inputs or nonpositive max throw. |
|
|
239
|
+
| `Accordion` | Native details attributes with `title` as summary; supports `open`, `onToggle` and normal keyboard behavior. |
|
|
240
|
+
| `Tabs` | Required `label` and `items: {id,label,content,disabled?}[]`; optional controlled `value`, uncontrolled `defaultValue`, `onValueChange(id)`. Unique stable IDs required. Arrow Left/Right, Home/End skip disabled tabs. Inactive panels stay mounted and hidden. |
|
|
241
|
+
| `Menu` | `label` trigger; `items: {id,label,onSelect?,href?,disabled?}[]`. Arrow Up/Down, Home/End, Escape and Tab; closes on selection, outside click or focus leaving. For router navigation use `onSelect` or compose ordinary links in Nav. |
|
|
242
|
+
| `Tooltip` | `text` and one focusable element child that forwards ARIA props. Visible on focus/hover, Escape dismisses, descriptions are merged. Do not put interactive content in tooltips or use a tooltip as the only accessible name. |
|
|
243
|
+
| `Dialog` | Required controlled `open`, `onClose()` and `title`. Uses native `dialog.showModal()` for top-layer modality and Escape, plus explicit Tab/Shift+Tab wrapping. Focus returns to the opener on close/unmount. Caller must set open=false in onClose. Native dialog-capable browsers required; no silent non-modal fallback. |
|
|
244
|
+
| `ThemeProvider`, `useTheme`, `ThemeSelect` | See theme preferences below. |
|
|
245
|
+
|
|
246
|
+
### Searchable select
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import { MultiSelect } from "@wintermuted/ui-theme/react/select";
|
|
250
|
+
|
|
251
|
+
const options = [{ value: 1, label: "North at Main", stop: { id: 1 } }];
|
|
252
|
+
<MultiSelect
|
|
253
|
+
options={options}
|
|
254
|
+
defaultValue={[options[0]]}
|
|
255
|
+
onChange={values => values.map(option => option.stop.id)}
|
|
256
|
+
/>;
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
The adapter preserves react-select `Props<Option, IsMulti, Group>` inference, option objects,
|
|
260
|
+
`defaultValue`, `value`, `onChange`, formatted labels, menu portals and callbacks. `isMulti`
|
|
261
|
+
defaults to true; set `isMulti={false}` for a single value. `styles` overrides merge over
|
|
262
|
+
token-based defaults; application-specific behavior remains in the application. Provide
|
|
263
|
+
an accessible name with `aria-label`, `inputId` plus a label, or `FieldGroup`.
|
|
264
|
+
Portals inherit document-level theme tokens; nested scoped themes need a portal target
|
|
265
|
+
inside that scope.
|
|
266
|
+
|
|
267
|
+
### Theme preferences
|
|
268
|
+
|
|
269
|
+
`useTheme()` returns `{ preference, setPreference, resolvedTheme }`. Preference is
|
|
270
|
+
`"system" | "light" | "dark"` and defaults to System. Overrides persist under
|
|
271
|
+
`wintermuted:theme` by default; pass a namespaced `storageKey` to both initialization
|
|
272
|
+
and provider to isolate applications. Returning to System follows OS changes immediately.
|
|
273
|
+
Cross-tab storage changes synchronize. Storage failures warn explicitly while the current
|
|
274
|
+
selection still works in memory.
|
|
275
|
+
|
|
276
|
+
For client rendering, call `initTheme({ storageKey })` from the React-free
|
|
277
|
+
`@wintermuted/ui-theme/theme` entry **before mounting React**. For SSR or first paint of
|
|
278
|
+
server HTML, emit `getThemeScript(storageKey)` in a synchronous inline `<head>` script
|
|
279
|
+
before styles, with the appropriate CSP nonce. Never interpolate an unsanitized key into
|
|
280
|
+
your own script. The helper safely escapes `<` in serialized keys. Hydration markup should
|
|
281
|
+
not branch on the client preference on the server; theme-dependent UI should render after
|
|
282
|
+
mount. Importing the React-free helper on the server is safe.
|
|
283
|
+
|
|
284
|
+
Only `document.documentElement.dataset.theme` and `style.colorScheme` are updated.
|
|
285
|
+
Map styles, tile sources, transit data and application state are not changed.
|
|
286
|
+
Use one document-level ThemeProvider per app. `ThemeSelect` defaults to label Appearance
|
|
287
|
+
with System, Light and Dark options and must be inside a provider.
|
|
288
|
+
|
|
289
|
+
### Development and release
|
|
290
|
+
|
|
291
|
+
Run `npm test` for DOM behavior/package contracts and `npm run test:browser` for native
|
|
292
|
+
Chromium keyboard/focus/theme checks (`npx playwright install chromium` once if needed).
|
|
293
|
+
Open `/showcase/react.html` with `npm run showcase:serve` for live examples.
|
|
294
|
+
CI alone runs builds/type checks via `npm run test:consumers` and bundles the React
|
|
295
|
+
showcase for Pages. Existing CSS pages are copied unchanged alongside it.
|
|
296
|
+
Publication is still the automated release process; an unpublished source tarball with
|
|
297
|
+
unchanged version metadata is an integration artifact, not proof that the registry version
|
|
298
|
+
has these APIs. Do not commit machine-local tarball dependencies to consumers.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wintermuted/ui-theme",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.6",
|
|
4
4
|
"description": "Shared Wintermuted UI theme (design tokens, base resets, and component styles) derived from the CV styling language.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -15,12 +15,14 @@
|
|
|
15
15
|
"index.js",
|
|
16
16
|
"index.css",
|
|
17
17
|
"styles/**/*.css",
|
|
18
|
+
"react/**/*.js",
|
|
19
|
+
"react/**/*.d.ts",
|
|
18
20
|
"README.md",
|
|
19
21
|
"LICENSE"
|
|
20
22
|
],
|
|
21
23
|
"repository": {
|
|
22
24
|
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/wintermuted/ui
|
|
25
|
+
"url": "git+https://github.com/wintermuted/wintermuted-ui.git"
|
|
24
26
|
},
|
|
25
27
|
"bugs": {
|
|
26
28
|
"url": "https://github.com/wintermuted/ui-theme/issues"
|
|
@@ -32,6 +34,18 @@
|
|
|
32
34
|
},
|
|
33
35
|
"exports": {
|
|
34
36
|
".": "./index.js",
|
|
37
|
+
"./react": {
|
|
38
|
+
"types": "./react/index.d.ts",
|
|
39
|
+
"default": "./react/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./react/select": {
|
|
42
|
+
"types": "./react/select.d.ts",
|
|
43
|
+
"default": "./react/select.js"
|
|
44
|
+
},
|
|
45
|
+
"./theme": {
|
|
46
|
+
"types": "./react/theme.d.ts",
|
|
47
|
+
"default": "./react/theme.js"
|
|
48
|
+
},
|
|
35
49
|
"./index.css": "./index.css",
|
|
36
50
|
"./styles/tokens.css": "./styles/tokens.css",
|
|
37
51
|
"./styles/base.css": "./styles/base.css",
|
|
@@ -58,10 +72,56 @@
|
|
|
58
72
|
"./styles/components/slider.css": "./styles/components/slider.css",
|
|
59
73
|
"./styles/components/toggle-group.css": "./styles/components/toggle-group.css",
|
|
60
74
|
"./styles/components/toast.css": "./styles/components/toast.css",
|
|
61
|
-
"./styles/components/code-block.css": "./styles/components/code-block.css"
|
|
75
|
+
"./styles/components/code-block.css": "./styles/components/code-block.css",
|
|
76
|
+
"./styles/components/alert.css": "./styles/components/alert.css",
|
|
77
|
+
"./styles/components/spinner.css": "./styles/components/spinner.css",
|
|
78
|
+
"./styles/components/progress.css": "./styles/components/progress.css",
|
|
79
|
+
"./styles/components/field.css": "./styles/components/field.css",
|
|
80
|
+
"./styles/components/list-group.css": "./styles/components/list-group.css",
|
|
81
|
+
"./styles/components/table.css": "./styles/components/table.css",
|
|
82
|
+
"./styles/components/nav.css": "./styles/components/nav.css",
|
|
83
|
+
"./styles/components/accordion.css": "./styles/components/accordion.css",
|
|
84
|
+
"./styles/components/menu.css": "./styles/components/menu.css",
|
|
85
|
+
"./styles/components/tooltip.css": "./styles/components/tooltip.css",
|
|
86
|
+
"./styles/components/dialog.css": "./styles/components/dialog.css",
|
|
87
|
+
"./styles/components/search-select.css": "./styles/components/search-select.css"
|
|
88
|
+
},
|
|
89
|
+
"typesVersions": {
|
|
90
|
+
"*": {
|
|
91
|
+
"react": [
|
|
92
|
+
"react/index.d.ts"
|
|
93
|
+
],
|
|
94
|
+
"react/select": [
|
|
95
|
+
"react/select.d.ts"
|
|
96
|
+
],
|
|
97
|
+
"theme": [
|
|
98
|
+
"react/theme.d.ts"
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"peerDependencies": {
|
|
103
|
+
"react": "^18.3.0 || ^19.0.0",
|
|
104
|
+
"react-dom": "^18.3.0 || ^19.0.0",
|
|
105
|
+
"react-select": "^5.8.0"
|
|
106
|
+
},
|
|
107
|
+
"peerDependenciesMeta": {
|
|
108
|
+
"react": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"react-dom": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"react-select": {
|
|
115
|
+
"optional": true
|
|
116
|
+
}
|
|
62
117
|
},
|
|
63
118
|
"scripts": {
|
|
64
|
-
"
|
|
119
|
+
"test": "node --test tests/*.test.js",
|
|
120
|
+
"test:browser": "node --test browser-tests/*.test.js",
|
|
121
|
+
"test:pack": "node tests/consumers.mjs --package-only",
|
|
122
|
+
"test:consumers": "node tests/consumers.mjs",
|
|
123
|
+
"showcase:serve": "vite --host 127.0.0.1 --port 4174 --strictPort",
|
|
124
|
+
"showcase:build": "vite build --config showcase/vite.config.js",
|
|
65
125
|
"showcase:open": "sh -c 'command -v open >/dev/null 2>&1 && open http://localhost:4174/showcase/ || xdg-open http://localhost:4174/showcase/'",
|
|
66
126
|
"showcase:open:sample-data": "sh -c 'command -v open >/dev/null 2>&1 && open http://localhost:4174/showcase/sample-data.html || xdg-open http://localhost:4174/showcase/sample-data.html'",
|
|
67
127
|
"showcase:open:forms": "sh -c 'command -v open >/dev/null 2>&1 && open http://localhost:4174/showcase/forms.html || xdg-open http://localhost:4174/showcase/forms.html'",
|
|
@@ -71,6 +131,20 @@
|
|
|
71
131
|
"lint": "stylelint \"styles/**/*.css\" \"index.css\""
|
|
72
132
|
},
|
|
73
133
|
"devDependencies": {
|
|
134
|
+
"@testing-library/react": "^16.3.0",
|
|
135
|
+
"@testing-library/user-event": "^14.6.1",
|
|
136
|
+
"playwright": "^1.56.1",
|
|
137
|
+
"@types/react": "^18.3.0",
|
|
138
|
+
"@types/react-dom": "^18.3.0",
|
|
139
|
+
"jsdom": "^26.1.0",
|
|
140
|
+
"css-loader": "^7.1.2",
|
|
141
|
+
"style-loader": "^4.0.0",
|
|
142
|
+
"react": "^18.3.1",
|
|
143
|
+
"react-dom": "^18.3.1",
|
|
144
|
+
"react-select": "^5.10.2",
|
|
145
|
+
"typescript": "~4.9.5",
|
|
146
|
+
"vite": "^5.4.21",
|
|
147
|
+
"webpack": "^5.102.1",
|
|
74
148
|
"stylelint": "^17.10.0",
|
|
75
149
|
"stylelint-config-standard": "^40.0.0"
|
|
76
150
|
}
|
package/react/index.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import type { ThemePreference, ResolvedTheme } from "./theme";
|
|
3
|
+
export type { ThemePreference, ResolvedTheme } from "./theme";
|
|
4
|
+
|
|
5
|
+
export type Tone = "neutral" | "info" | "success" | "warning" | "danger";
|
|
6
|
+
type Primitive<Default extends React.ElementType> = {
|
|
7
|
+
(props: { as?: Default } & React.ComponentPropsWithRef<Default>): React.ReactElement | null;
|
|
8
|
+
<T extends React.ElementType>(
|
|
9
|
+
props: { as: T } & Omit<React.ComponentPropsWithRef<T>, "as">
|
|
10
|
+
): React.ReactElement | null;
|
|
11
|
+
};
|
|
12
|
+
export const Card: Primitive<"section">;
|
|
13
|
+
export const CardHeader: Primitive<"header">;
|
|
14
|
+
export const CardBody: Primitive<"div">;
|
|
15
|
+
export const CardTitle: Primitive<"h3">;
|
|
16
|
+
export const CardText: Primitive<"p">;
|
|
17
|
+
export const CardFooter: Primitive<"footer">;
|
|
18
|
+
export const ListGroup: Primitive<"ul">;
|
|
19
|
+
export const ListItem: Primitive<"li">;
|
|
20
|
+
export const Nav: Primitive<"nav">;
|
|
21
|
+
export const Input: Primitive<"input">;
|
|
22
|
+
export const Select: Primitive<"select">;
|
|
23
|
+
|
|
24
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
25
|
+
variant?: "primary" | "secondary" | "ghost" | "danger" | "success" | "warning" | "link";
|
|
26
|
+
size?: "sm";
|
|
27
|
+
icon?: React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
export const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
30
|
+
export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> { tone?: Tone }
|
|
31
|
+
export const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
32
|
+
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> { tone?: Tone }
|
|
33
|
+
export const Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<HTMLDivElement>>;
|
|
34
|
+
export function Spinner(props: React.HTMLAttributes<HTMLSpanElement> & { label?: string }): React.ReactElement;
|
|
35
|
+
export function ProgressBar(props: React.ProgressHTMLAttributes<HTMLProgressElement> & {
|
|
36
|
+
value?: number; max?: number; label?: string;
|
|
37
|
+
}): React.ReactElement;
|
|
38
|
+
export const Table: React.ForwardRefExoticComponent<React.TableHTMLAttributes<HTMLTableElement> & {
|
|
39
|
+
responsive?: boolean;
|
|
40
|
+
} & React.RefAttributes<HTMLTableElement>>;
|
|
41
|
+
export interface FieldGroupProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
42
|
+
label: React.ReactNode; htmlFor?: string; hint?: React.ReactNode; error?: React.ReactNode;
|
|
43
|
+
children: React.ReactElement;
|
|
44
|
+
}
|
|
45
|
+
export function FieldGroup(props: FieldGroupProps): React.ReactElement;
|
|
46
|
+
export function Accordion(props: Omit<React.DetailsHTMLAttributes<HTMLDetailsElement>, "title"> & {
|
|
47
|
+
title: React.ReactNode;
|
|
48
|
+
}): React.ReactElement;
|
|
49
|
+
export interface TabItem { id: string; label: React.ReactNode; content: React.ReactNode; disabled?: boolean }
|
|
50
|
+
export interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
|
|
51
|
+
items: TabItem[]; value?: string; defaultValue?: string;
|
|
52
|
+
onValueChange?: (id: string) => void; label: string;
|
|
53
|
+
}
|
|
54
|
+
export function Tabs(props: TabsProps): React.ReactElement;
|
|
55
|
+
export interface MenuItem {
|
|
56
|
+
id: string; label: React.ReactNode; href?: string; disabled?: boolean;
|
|
57
|
+
onSelect?: (event: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
|
|
58
|
+
}
|
|
59
|
+
export function Menu(props: Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
60
|
+
label: React.ReactNode; items: MenuItem[];
|
|
61
|
+
}): React.ReactElement;
|
|
62
|
+
export function Tooltip(props: { text: string; children: React.ReactElement }): React.ReactElement;
|
|
63
|
+
export function Dialog(props: Omit<React.DialogHTMLAttributes<HTMLDialogElement>, "open" | "onClose" | "title"> & {
|
|
64
|
+
open: boolean; onClose: () => void; title: React.ReactNode;
|
|
65
|
+
}): React.ReactElement;
|
|
66
|
+
export interface ThemeContextValue {
|
|
67
|
+
preference: ThemePreference;
|
|
68
|
+
setPreference: (preference: ThemePreference) => void;
|
|
69
|
+
resolvedTheme: ResolvedTheme;
|
|
70
|
+
}
|
|
71
|
+
export function ThemeProvider(props: { children: React.ReactNode; storageKey?: string }): React.ReactElement;
|
|
72
|
+
export function useTheme(): ThemeContextValue;
|
|
73
|
+
export function ThemeSelect(props: Omit<React.SelectHTMLAttributes<HTMLSelectElement>,
|
|
74
|
+
"value" | "defaultValue" | "onChange"> & { label?: string }): React.ReactElement;
|
package/react/index.js
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children, cloneElement, createContext, createElement as h, forwardRef,
|
|
3
|
+
useContext, useEffect, useId, useLayoutEffect, useRef, useState,
|
|
4
|
+
} from "react";
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_THEME_KEY, applyTheme, isThemePreference, readThemePreference, resolveTheme,
|
|
7
|
+
} from "./theme.js";
|
|
8
|
+
|
|
9
|
+
const cx = (...values) => values.filter(Boolean).join(" ");
|
|
10
|
+
const useClientLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
11
|
+
|
|
12
|
+
function primitive(tag, baseClass) {
|
|
13
|
+
return forwardRef(function Primitive({ as = tag, className, ...props }, ref) {
|
|
14
|
+
return h(as, { ...props, ref, className: cx(baseClass, className) });
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Card = primitive("section", "wm-card");
|
|
19
|
+
export const CardHeader = primitive("header", "wm-card-header");
|
|
20
|
+
export const CardBody = primitive("div", "wm-card-body");
|
|
21
|
+
export const CardTitle = primitive("h3", "wm-card-title");
|
|
22
|
+
export const CardText = primitive("p", "wm-card-text");
|
|
23
|
+
export const CardFooter = primitive("footer", "wm-card-footer");
|
|
24
|
+
export const ListGroup = primitive("ul", "wm-list-group");
|
|
25
|
+
export const ListItem = primitive("li", "wm-list-item");
|
|
26
|
+
export const Nav = primitive("nav", "wm-nav");
|
|
27
|
+
export const Input = primitive("input", "wm-input");
|
|
28
|
+
export const Select = primitive("select", "wm-select");
|
|
29
|
+
|
|
30
|
+
export const Button = forwardRef(function Button({
|
|
31
|
+
variant = "primary", size, icon, className, children, type = "button", ...props
|
|
32
|
+
}, ref) {
|
|
33
|
+
return h("button", {
|
|
34
|
+
...props, ref, type,
|
|
35
|
+
className: cx("wm-btn", `wm-btn-${variant}`, size && `wm-btn-${size}`, className),
|
|
36
|
+
}, icon && h("span", { "aria-hidden": true, className: "wm-btn-icon" }, icon), children);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const Badge = forwardRef(function Badge({ tone = "neutral", className, ...props }, ref) {
|
|
40
|
+
return h("span", { ...props, ref, className: cx("wm-badge", `wm-badge-${tone}`, className) });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const Alert = forwardRef(function Alert({ tone = "info", className, role = "status", ...props }, ref) {
|
|
44
|
+
return h("div", { ...props, ref, role, className: cx("wm-alert", `wm-alert-${tone}`, className) });
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export function Spinner({ label = "Loading", className, ...props }) {
|
|
48
|
+
return h("span", { ...props, role: "status", className: cx("wm-spinner", className) },
|
|
49
|
+
h("span", { "aria-hidden": true, className: "wm-spinner-indicator" }),
|
|
50
|
+
h("span", { className: "wm-sr-only" }, label));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function ProgressBar({ value = 0, max = 100, label, className, ...props }) {
|
|
54
|
+
if (!Number.isFinite(max) || max <= 0 || !Number.isFinite(value)) {
|
|
55
|
+
throw new RangeError("ProgressBar requires a finite value and a positive finite max.");
|
|
56
|
+
}
|
|
57
|
+
return h("progress", { ...props, className: cx("wm-progress", className),
|
|
58
|
+
value: Math.min(max, Math.max(0, value)), max, "aria-label": label ?? props["aria-label"] });
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const Table = forwardRef(function Table({ responsive = false, className, ...props }, ref) {
|
|
62
|
+
const table = h("table", { ...props, ref, className: cx("wm-table", className) });
|
|
63
|
+
return responsive ? h("div", { className: "wm-table-responsive", tabIndex: 0,
|
|
64
|
+
role: "region", "aria-label": props["aria-label"] || "Scrollable table" }, table) : table;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export function FieldGroup({ label, htmlFor, hint, error, className, children, ...props }) {
|
|
68
|
+
const id = useId();
|
|
69
|
+
const descriptionId = `${id}-description`;
|
|
70
|
+
const child = Children.only(children);
|
|
71
|
+
const controlId = htmlFor || child.props.inputId || child.props.id || `${id}-control`;
|
|
72
|
+
const describedBy = cx(child.props["aria-describedby"], (hint || error) && descriptionId) || undefined;
|
|
73
|
+
return h("div", { ...props, className: cx("wm-field", className) },
|
|
74
|
+
h("label", { htmlFor: controlId }, label),
|
|
75
|
+
cloneElement(child, {
|
|
76
|
+
id: controlId, "aria-describedby": describedBy,
|
|
77
|
+
...(child.props.inputId !== undefined ? { inputId: controlId } : {}),
|
|
78
|
+
"aria-invalid": error ? true : child.props["aria-invalid"],
|
|
79
|
+
}),
|
|
80
|
+
(hint || error) && h("div", { id: descriptionId, className: error ? "wm-field-error" : "wm-field-hint" }, error || hint));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function Accordion({ title, children, className, ...props }) {
|
|
84
|
+
return h("details", { ...props, className: cx("wm-accordion", className) },
|
|
85
|
+
h("summary", null, title), h("div", { className: "wm-accordion-body" }, children));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function Tabs({ items, value, defaultValue, onValueChange, label, className, ...props }) {
|
|
89
|
+
const prefix = useId();
|
|
90
|
+
const [internal, setInternal] = useState(defaultValue);
|
|
91
|
+
const requested = value === undefined ? internal : value;
|
|
92
|
+
const active = items.find(item => item.id === requested && !item.disabled)?.id
|
|
93
|
+
?? items.find(item => !item.disabled)?.id;
|
|
94
|
+
const refs = useRef([]);
|
|
95
|
+
function activate(item) {
|
|
96
|
+
if (value === undefined) setInternal(item.id);
|
|
97
|
+
onValueChange?.(item.id);
|
|
98
|
+
}
|
|
99
|
+
function navigate(event, index) {
|
|
100
|
+
const enabled = items.map((item, i) => item.disabled ? -1 : i).filter(i => i !== -1);
|
|
101
|
+
const position = enabled.indexOf(index);
|
|
102
|
+
let target;
|
|
103
|
+
if (event.key === "ArrowRight") target = enabled[(position + 1) % enabled.length];
|
|
104
|
+
if (event.key === "ArrowLeft") target = enabled[(position - 1 + enabled.length) % enabled.length];
|
|
105
|
+
if (event.key === "Home") target = enabled[0];
|
|
106
|
+
if (event.key === "End") target = enabled[enabled.length - 1];
|
|
107
|
+
if (target === undefined) return;
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
refs.current[target]?.focus();
|
|
110
|
+
activate(items[target]);
|
|
111
|
+
}
|
|
112
|
+
return h("div", { ...props, className: cx("wm-tabs", className) },
|
|
113
|
+
h("div", { role: "tablist", "aria-label": label, className: "wm-tab-bar" },
|
|
114
|
+
items.map((item, index) => h("button", {
|
|
115
|
+
key: item.id, id: `${prefix}-tab-${item.id}`, type: "button", role: "tab",
|
|
116
|
+
"aria-selected": active === item.id, "aria-controls": `${prefix}-panel-${item.id}`,
|
|
117
|
+
tabIndex: active === item.id ? 0 : -1, disabled: item.disabled,
|
|
118
|
+
className: cx("wm-tab-btn", active === item.id && "wm-tab-btn-active"),
|
|
119
|
+
ref: node => { refs.current[index] = node; },
|
|
120
|
+
onKeyDown: event => navigate(event, index), onClick: () => activate(item),
|
|
121
|
+
}, item.label))),
|
|
122
|
+
items.map(item => h("div", { key: item.id, id: `${prefix}-panel-${item.id}`,
|
|
123
|
+
role: "tabpanel", "aria-labelledby": `${prefix}-tab-${item.id}`,
|
|
124
|
+
hidden: active !== item.id, tabIndex: 0, className: "wm-tab-panel" }, item.content)));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function Menu({ label, items, className, ...props }) {
|
|
128
|
+
const id = useId();
|
|
129
|
+
const [open, setOpen] = useState(false);
|
|
130
|
+
const trigger = useRef(null);
|
|
131
|
+
const root = useRef(null);
|
|
132
|
+
const refs = useRef([]);
|
|
133
|
+
const focusLast = useRef(false);
|
|
134
|
+
useClientLayoutEffect(() => {
|
|
135
|
+
if (!open) return;
|
|
136
|
+
const enabled = refs.current.filter(node => node && node.getAttribute("aria-disabled") !== "true");
|
|
137
|
+
(focusLast.current ? enabled.at(-1) : enabled[0])?.focus();
|
|
138
|
+
}, [open]);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (!open) return;
|
|
141
|
+
const outside = event => { if (!root.current?.contains(event.target)) setOpen(false); };
|
|
142
|
+
document.addEventListener("pointerdown", outside);
|
|
143
|
+
return () => document.removeEventListener("pointerdown", outside);
|
|
144
|
+
}, [open]);
|
|
145
|
+
function close(restore = false) {
|
|
146
|
+
setOpen(false);
|
|
147
|
+
if (restore) trigger.current?.focus();
|
|
148
|
+
}
|
|
149
|
+
function navigate(event) {
|
|
150
|
+
if (event.key === "Escape") { event.preventDefault(); close(true); return; }
|
|
151
|
+
if (event.key === "Tab") { close(true); return; }
|
|
152
|
+
const enabled = refs.current.filter(node => node && node.getAttribute("aria-disabled") !== "true");
|
|
153
|
+
const index = enabled.indexOf(document.activeElement);
|
|
154
|
+
let next;
|
|
155
|
+
if (event.key === "ArrowDown") next = enabled[(index + 1) % enabled.length];
|
|
156
|
+
if (event.key === "ArrowUp") next = enabled[(index - 1 + enabled.length) % enabled.length];
|
|
157
|
+
if (event.key === "Home") next = enabled[0];
|
|
158
|
+
if (event.key === "End") next = enabled.at(-1);
|
|
159
|
+
if (next) { event.preventDefault(); next.focus(); }
|
|
160
|
+
}
|
|
161
|
+
return h("div", { ...props, ref: root, className: cx("wm-menu", className),
|
|
162
|
+
onBlur: event => { if (!event.currentTarget.contains(event.relatedTarget)) close(); } },
|
|
163
|
+
h(Button, { ref: trigger, variant: "secondary", "aria-haspopup": "menu",
|
|
164
|
+
"aria-expanded": open, "aria-controls": open ? id : undefined,
|
|
165
|
+
onClick: () => { focusLast.current = false; setOpen(!open); },
|
|
166
|
+
onKeyDown: event => {
|
|
167
|
+
if (open && event.key === "Escape") { event.preventDefault(); close(true); return; }
|
|
168
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
169
|
+
event.preventDefault(); focusLast.current = event.key === "ArrowUp"; setOpen(true);
|
|
170
|
+
}
|
|
171
|
+
} }, label),
|
|
172
|
+
open && h("ul", { id, role: "menu", "aria-label": typeof label === "string" ? label : "Actions",
|
|
173
|
+
className: "wm-menu-items", onKeyDown: navigate },
|
|
174
|
+
items.map((item, index) => h("li", { key: item.id, role: "none" },
|
|
175
|
+
h(item.href && !item.disabled ? "a" : "button", {
|
|
176
|
+
href: item.disabled ? undefined : item.href,
|
|
177
|
+
type: item.href && !item.disabled ? undefined : "button",
|
|
178
|
+
role: "menuitem", tabIndex: -1, "aria-disabled": item.disabled || undefined,
|
|
179
|
+
ref: node => { refs.current[index] = node; },
|
|
180
|
+
onClick: event => {
|
|
181
|
+
if (item.disabled) { event.preventDefault(); return; }
|
|
182
|
+
close(true); item.onSelect?.(event);
|
|
183
|
+
},
|
|
184
|
+
}, item.label)))));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function Tooltip({ text, children }) {
|
|
188
|
+
const id = useId();
|
|
189
|
+
const [hovered, setHovered] = useState(false);
|
|
190
|
+
const [focused, setFocused] = useState(false);
|
|
191
|
+
const [dismissed, setDismissed] = useState(false);
|
|
192
|
+
const visible = (hovered || focused) && !dismissed;
|
|
193
|
+
const child = Children.only(children);
|
|
194
|
+
useEffect(() => {
|
|
195
|
+
if (!visible) return;
|
|
196
|
+
const dismiss = event => { if (event.key === "Escape") setDismissed(true); };
|
|
197
|
+
document.addEventListener("keydown", dismiss);
|
|
198
|
+
return () => document.removeEventListener("keydown", dismiss);
|
|
199
|
+
}, [visible]);
|
|
200
|
+
return h("span", { className: "wm-tooltip-anchor",
|
|
201
|
+
onMouseEnter: () => { setHovered(true); setDismissed(false); },
|
|
202
|
+
onMouseLeave: () => setHovered(false),
|
|
203
|
+
onFocus: () => { setFocused(true); setDismissed(false); },
|
|
204
|
+
onBlur: event => { if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false); } },
|
|
205
|
+
cloneElement(child, { "aria-describedby": cx(child.props["aria-describedby"], visible && id) || undefined }),
|
|
206
|
+
visible && h("span", { id, role: "tooltip", className: "wm-tooltip" }, text));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function Dialog({ open, onClose, title, children, className, ...props }) {
|
|
210
|
+
const ref = useRef(null);
|
|
211
|
+
const restoreTarget = useRef(null);
|
|
212
|
+
const internalCloses = useRef(0);
|
|
213
|
+
const titleId = useId();
|
|
214
|
+
useClientLayoutEffect(() => {
|
|
215
|
+
const dialog = ref.current;
|
|
216
|
+
if (!open) return;
|
|
217
|
+
if (!restoreTarget.current || !dialog.contains(document.activeElement)) {
|
|
218
|
+
restoreTarget.current = document.activeElement;
|
|
219
|
+
}
|
|
220
|
+
const previous = restoreTarget.current;
|
|
221
|
+
dialog.showModal();
|
|
222
|
+
return () => {
|
|
223
|
+
if (dialog.open) { internalCloses.current += 1; dialog.close(); }
|
|
224
|
+
// Restore after React's commit-time focus restoration, including unmount.
|
|
225
|
+
queueMicrotask(() => {
|
|
226
|
+
if (dialog.open) return;
|
|
227
|
+
if (previous?.isConnected) previous.focus();
|
|
228
|
+
restoreTarget.current = null;
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
}, [open]);
|
|
232
|
+
function trapFocus(event) {
|
|
233
|
+
props.onKeyDown?.(event);
|
|
234
|
+
if (event.defaultPrevented || event.key !== "Tab") return;
|
|
235
|
+
const dialog = ref.current;
|
|
236
|
+
const candidates = Array.from(dialog.querySelectorAll(
|
|
237
|
+
"a[href], area[href], button, input, select, textarea, summary, iframe, object, embed, audio[controls], video[controls], [tabindex], [contenteditable='true']",
|
|
238
|
+
)).filter(node => (node.tabIndex >= 0 || (node.isContentEditable && !node.hasAttribute("tabindex")))
|
|
239
|
+
&& !node.matches(":disabled")
|
|
240
|
+
&& !node.closest("[inert]") && node.getClientRects().length > 0
|
|
241
|
+
&& window.getComputedStyle(node).visibility === "visible");
|
|
242
|
+
const tabbable = candidates.filter(node => {
|
|
243
|
+
if (node.tagName !== "INPUT" || node.type !== "radio" || !node.name) return true;
|
|
244
|
+
const group = candidates.filter(other => other.tagName === "INPUT" && other.type === "radio"
|
|
245
|
+
&& other.name === node.name && other.form === node.form);
|
|
246
|
+
return node === (group.find(other => other.checked) || group[0]);
|
|
247
|
+
}).sort((a, b) => (a.tabIndex > 0 ? a.tabIndex : Infinity) - (b.tabIndex > 0 ? b.tabIndex : Infinity));
|
|
248
|
+
const first = tabbable[0];
|
|
249
|
+
const last = tabbable[tabbable.length - 1];
|
|
250
|
+
if (!first) { event.preventDefault(); dialog.focus(); return; }
|
|
251
|
+
if (event.shiftKey && (document.activeElement === first || document.activeElement === dialog)) {
|
|
252
|
+
event.preventDefault(); last.focus();
|
|
253
|
+
} else if (!event.shiftKey && (document.activeElement === last || document.activeElement === dialog)) {
|
|
254
|
+
event.preventDefault(); first.focus();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return h("dialog", { ...props, ref, "aria-labelledby": titleId,
|
|
258
|
+
tabIndex: props.tabIndex ?? -1, onKeyDown: trapFocus,
|
|
259
|
+
className: cx("wm-dialog", className),
|
|
260
|
+
onCancel: event => {
|
|
261
|
+
props.onCancel?.(event);
|
|
262
|
+
const cancelled = event.defaultPrevented;
|
|
263
|
+
event.preventDefault();
|
|
264
|
+
if (!cancelled) onClose();
|
|
265
|
+
},
|
|
266
|
+
onClose: () => {
|
|
267
|
+
if (internalCloses.current > 0) internalCloses.current -= 1;
|
|
268
|
+
else if (open) onClose();
|
|
269
|
+
} },
|
|
270
|
+
h("header", { className: "wm-dialog-header" }, h("h3", { id: titleId }, title),
|
|
271
|
+
h(Button, { variant: "ghost", onClick: onClose, "aria-label": "Close dialog" }, "Close")),
|
|
272
|
+
h("div", { className: "wm-dialog-body" }, children));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const ThemeContext = createContext(null);
|
|
276
|
+
|
|
277
|
+
export function ThemeProvider({ children, storageKey = DEFAULT_THEME_KEY }) {
|
|
278
|
+
const [preference, setPreferenceState] = useState(() => readThemePreference(storageKey));
|
|
279
|
+
const currentPreference = useRef(preference);
|
|
280
|
+
const [resolvedTheme, setResolvedTheme] = useState(() => resolveTheme(preference));
|
|
281
|
+
useClientLayoutEffect(() => {
|
|
282
|
+
const sync = () => {
|
|
283
|
+
const current = readThemePreference(storageKey);
|
|
284
|
+
currentPreference.current = current;
|
|
285
|
+
setPreferenceState(current);
|
|
286
|
+
setResolvedTheme(applyTheme(current));
|
|
287
|
+
};
|
|
288
|
+
sync();
|
|
289
|
+
const query = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
290
|
+
const systemChange = () => setResolvedTheme(applyTheme(currentPreference.current));
|
|
291
|
+
const storage = event => { if (event.key === storageKey || event.key === null) sync(); };
|
|
292
|
+
query?.addEventListener("change", systemChange);
|
|
293
|
+
window.addEventListener("storage", storage);
|
|
294
|
+
return () => {
|
|
295
|
+
query?.removeEventListener("change", systemChange);
|
|
296
|
+
window.removeEventListener("storage", storage);
|
|
297
|
+
};
|
|
298
|
+
}, [storageKey]);
|
|
299
|
+
function setPreference(next) {
|
|
300
|
+
if (!isThemePreference(next)) throw new TypeError("Theme preference must be system, light, or dark.");
|
|
301
|
+
try { window.localStorage.setItem(storageKey, next); }
|
|
302
|
+
catch (error) { console.warn("Wintermuted theme preference could not be saved.", error); }
|
|
303
|
+
currentPreference.current = next;
|
|
304
|
+
setPreferenceState(next);
|
|
305
|
+
setResolvedTheme(applyTheme(next));
|
|
306
|
+
}
|
|
307
|
+
return h(ThemeContext.Provider, { value: { preference, setPreference, resolvedTheme } }, children);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export function useTheme() {
|
|
311
|
+
const theme = useContext(ThemeContext);
|
|
312
|
+
if (!theme) throw new Error("useTheme must be used inside ThemeProvider.");
|
|
313
|
+
return theme;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function ThemeSelect({ label = "Appearance", id, ...props }) {
|
|
317
|
+
const generated = useId();
|
|
318
|
+
const { preference, setPreference } = useTheme();
|
|
319
|
+
const controlId = id || generated;
|
|
320
|
+
return h(FieldGroup, { label, htmlFor: controlId },
|
|
321
|
+
h(Select, { ...props, id: controlId, value: preference, onChange: event => setPreference(event.target.value) },
|
|
322
|
+
h("option", { value: "system" }, "System"),
|
|
323
|
+
h("option", { value: "light" }, "Light"),
|
|
324
|
+
h("option", { value: "dark" }, "Dark")));
|
|
325
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactElement } from "react";
|
|
2
|
+
import type { GroupBase, Props } from "react-select";
|
|
3
|
+
|
|
4
|
+
export type MultiSelectProps<Option = unknown, IsMulti extends boolean = true,
|
|
5
|
+
Group extends GroupBase<Option> = GroupBase<Option>> = Props<Option, IsMulti, Group>;
|
|
6
|
+
|
|
7
|
+
export function MultiSelect<Option = unknown, IsMulti extends boolean = true,
|
|
8
|
+
Group extends GroupBase<Option> = GroupBase<Option>>(
|
|
9
|
+
props: MultiSelectProps<Option, IsMulti, Group>
|
|
10
|
+
): ReactElement;
|
package/react/select.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createElement, useId } from "react";
|
|
2
|
+
import ReactSelect, { mergeStyles } from "react-select";
|
|
3
|
+
|
|
4
|
+
// Inline values are CSS variables so open menus follow a theme change immediately.
|
|
5
|
+
const styles = {
|
|
6
|
+
control: (base, state) => ({ ...base,
|
|
7
|
+
backgroundColor: "var(--wm-color-bg)", color: "var(--wm-color-text)",
|
|
8
|
+
borderColor: state.isFocused ? "var(--wm-color-accent)" : "var(--wm-color-border-strong)",
|
|
9
|
+
borderRadius: "var(--wm-radius-xs)",
|
|
10
|
+
boxShadow: state.isFocused ? "0 0 0 2px var(--wm-color-accent-border)" : "none",
|
|
11
|
+
":hover": { borderColor: "var(--wm-color-accent)" },
|
|
12
|
+
}),
|
|
13
|
+
menu: base => ({ ...base, backgroundColor: "var(--wm-color-surface-solid)",
|
|
14
|
+
color: "var(--wm-color-text)", border: "1px solid var(--wm-color-border)" }),
|
|
15
|
+
menuPortal: base => ({ ...base, color: "var(--wm-color-text)" }),
|
|
16
|
+
option: (base, state) => ({ ...base,
|
|
17
|
+
backgroundColor: state.isSelected ? "var(--wm-color-accent-soft)"
|
|
18
|
+
: state.isFocused ? "var(--wm-color-surface-strong)" : "transparent",
|
|
19
|
+
color: state.isDisabled ? "var(--wm-color-text-muted)" : "var(--wm-color-text)",
|
|
20
|
+
":active": { backgroundColor: "var(--wm-color-accent-soft)" },
|
|
21
|
+
}),
|
|
22
|
+
singleValue: base => ({ ...base, color: "var(--wm-color-text)" }),
|
|
23
|
+
input: base => ({ ...base, color: "var(--wm-color-text)" }),
|
|
24
|
+
placeholder: base => ({ ...base, color: "var(--wm-color-text-muted)" }),
|
|
25
|
+
multiValue: base => ({ ...base, backgroundColor: "var(--wm-color-surface-strong)" }),
|
|
26
|
+
multiValueLabel: base => ({ ...base, color: "var(--wm-color-text)" }),
|
|
27
|
+
multiValueRemove: base => ({ ...base, color: "var(--wm-color-text-secondary)",
|
|
28
|
+
":hover": { backgroundColor: "var(--wm-color-danger-soft)", color: "var(--wm-color-danger)" } }),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function MultiSelect({ styles: overrides, isMulti = true, id, className, ...props }) {
|
|
32
|
+
const generated = useId();
|
|
33
|
+
return createElement(ReactSelect, {
|
|
34
|
+
instanceId: generated, ...props, inputId: props.inputId ?? id,
|
|
35
|
+
className: ["wm-search-select", className].filter(Boolean).join(" "),
|
|
36
|
+
isMulti, styles: mergeStyles(styles, overrides),
|
|
37
|
+
});
|
|
38
|
+
}
|
package/react/theme.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ThemePreference = "system" | "light" | "dark";
|
|
2
|
+
export type ResolvedTheme = "light" | "dark";
|
|
3
|
+
export const DEFAULT_THEME_KEY: string;
|
|
4
|
+
export function isThemePreference(value: unknown): value is ThemePreference;
|
|
5
|
+
export function readThemePreference(storageKey?: string): ThemePreference;
|
|
6
|
+
export function resolveTheme(preference: ThemePreference): ResolvedTheme;
|
|
7
|
+
export function applyTheme(preference: ThemePreference): ResolvedTheme;
|
|
8
|
+
export function initTheme(options?: { storageKey?: string }): ResolvedTheme;
|
|
9
|
+
export function getThemeScript(storageKey?: string): string;
|
package/react/theme.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const DEFAULT_THEME_KEY = "wintermuted:theme";
|
|
2
|
+
|
|
3
|
+
export function isThemePreference(value) {
|
|
4
|
+
return value === "system" || value === "light" || value === "dark";
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function readThemePreference(storageKey = DEFAULT_THEME_KEY) {
|
|
8
|
+
if (typeof window === "undefined") return "system";
|
|
9
|
+
try {
|
|
10
|
+
const stored = window.localStorage.getItem(storageKey);
|
|
11
|
+
return isThemePreference(stored) ? stored : "system";
|
|
12
|
+
} catch (error) {
|
|
13
|
+
console.warn("Wintermuted theme preference could not be read.", error);
|
|
14
|
+
return "system";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function resolveTheme(preference) {
|
|
19
|
+
return preference === "system"
|
|
20
|
+
? (typeof window !== "undefined" && window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light")
|
|
21
|
+
: preference;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function applyTheme(preference) {
|
|
25
|
+
const resolved = resolveTheme(preference);
|
|
26
|
+
if (typeof document !== "undefined") {
|
|
27
|
+
document.documentElement.dataset.theme = resolved;
|
|
28
|
+
document.documentElement.style.colorScheme = resolved;
|
|
29
|
+
}
|
|
30
|
+
return resolved;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function initTheme({ storageKey = DEFAULT_THEME_KEY } = {}) {
|
|
34
|
+
return applyTheme(readThemePreference(storageKey));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Keep this synchronous bootstrap self-contained so SSR can emit it before CSS.
|
|
38
|
+
export function getThemeScript(storageKey = DEFAULT_THEME_KEY) {
|
|
39
|
+
const key = JSON.stringify(storageKey).replace(/</g, "\\u003c");
|
|
40
|
+
return `(function(){var p="system";try{var s=localStorage.getItem(${key});if(s==="light"||s==="dark")p=s;}catch(e){console.warn("Wintermuted theme preference could not be read.",e);}var t=p==="system"?(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"):p;document.documentElement.dataset.theme=t;document.documentElement.style.colorScheme=t;})();`;
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.wm-accordion {
|
|
2
|
+
border: 1px solid var(--wm-color-border);
|
|
3
|
+
border-radius: var(--wm-radius-xs);
|
|
4
|
+
color: var(--wm-color-text);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.wm-accordion > summary {
|
|
8
|
+
padding: var(--wm-space-3) var(--wm-space-4);
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
font-weight: 600;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.wm-accordion > summary:focus-visible {
|
|
14
|
+
outline: 2px solid var(--wm-color-accent);
|
|
15
|
+
outline-offset: 2px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.wm-accordion-body { padding: var(--wm-space-4); }
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.wm-alert {
|
|
2
|
+
padding: var(--wm-space-3) var(--wm-space-4);
|
|
3
|
+
border: 1px solid var(--wm-color-border);
|
|
4
|
+
border-radius: var(--wm-radius-xs);
|
|
5
|
+
background: var(--wm-color-surface-muted);
|
|
6
|
+
color: var(--wm-color-text);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.wm-alert-info {
|
|
10
|
+
background: var(--wm-color-accent-soft);
|
|
11
|
+
border-color: var(--wm-color-accent-border);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wm-alert-success {
|
|
15
|
+
background: var(--wm-color-success-soft);
|
|
16
|
+
border-color: var(--wm-color-success-border);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.wm-alert-warning {
|
|
20
|
+
background: var(--wm-color-warning-soft);
|
|
21
|
+
border-color: var(--wm-color-warning-border);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.wm-alert-danger {
|
|
25
|
+
background: var(--wm-color-danger-soft);
|
|
26
|
+
border-color: var(--wm-color-danger-border);
|
|
27
|
+
}
|
|
@@ -15,3 +15,27 @@
|
|
|
15
15
|
letter-spacing: 0.06em;
|
|
16
16
|
text-transform: uppercase;
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
.wm-badge-info {
|
|
20
|
+
background: var(--wm-color-accent-soft);
|
|
21
|
+
border-color: var(--wm-color-accent-border);
|
|
22
|
+
color: var(--wm-color-accent);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.wm-badge-success {
|
|
26
|
+
background: var(--wm-color-success-soft);
|
|
27
|
+
border-color: var(--wm-color-success-border);
|
|
28
|
+
color: var(--wm-color-success);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.wm-badge-warning {
|
|
32
|
+
background: var(--wm-color-warning-soft);
|
|
33
|
+
border-color: var(--wm-color-warning-border);
|
|
34
|
+
color: var(--wm-color-text);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.wm-badge-danger {
|
|
38
|
+
background: var(--wm-color-danger-soft);
|
|
39
|
+
border-color: var(--wm-color-danger-border);
|
|
40
|
+
color: var(--wm-color-danger);
|
|
41
|
+
}
|
|
@@ -47,6 +47,15 @@
|
|
|
47
47
|
padding: 1.25rem;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
.wm-card-title {
|
|
51
|
+
margin: 0;
|
|
52
|
+
color: var(--wm-color-text);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.wm-card-text {
|
|
56
|
+
color: var(--wm-color-text-secondary);
|
|
57
|
+
}
|
|
58
|
+
|
|
50
59
|
/**
|
|
51
60
|
* .card-footer — Secondary action / metadata row at the bottom.
|
|
52
61
|
* Muted surface with a top border separator.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.wm-dialog {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
width: min(var(--wm-dialog-width), calc(100% - var(--wm-space-6)));
|
|
4
|
+
max-height: calc(100% - var(--wm-space-6));
|
|
5
|
+
padding: 0;
|
|
6
|
+
border: 1px solid var(--wm-color-border);
|
|
7
|
+
border-radius: var(--wm-radius-md);
|
|
8
|
+
background: var(--wm-color-surface-solid);
|
|
9
|
+
color: var(--wm-color-text);
|
|
10
|
+
box-shadow: var(--wm-shadow-soft);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.wm-dialog::backdrop { background: var(--wm-dialog-backdrop); }
|
|
14
|
+
|
|
15
|
+
.wm-dialog-header {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
gap: var(--wm-space-4);
|
|
20
|
+
padding: var(--wm-space-4);
|
|
21
|
+
border-bottom: 1px solid var(--wm-color-border);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.wm-dialog-body { padding: var(--wm-space-4); }
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.wm-field {
|
|
2
|
+
display: grid;
|
|
3
|
+
gap: var(--wm-space-2);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.wm-field > label {
|
|
7
|
+
font-weight: 600;
|
|
8
|
+
color: var(--wm-color-text);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.wm-field-hint,
|
|
12
|
+
.wm-field-error {
|
|
13
|
+
font-size: var(--wm-text-sm);
|
|
14
|
+
color: var(--wm-color-text-secondary);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.wm-field-error { color: var(--wm-color-danger); }
|
|
18
|
+
|
|
19
|
+
.wm-input,
|
|
20
|
+
.wm-select {
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
width: 100%;
|
|
23
|
+
min-height: var(--wm-control-height);
|
|
24
|
+
padding: var(--wm-space-2) var(--wm-space-3);
|
|
25
|
+
font: inherit;
|
|
26
|
+
color: var(--wm-color-text);
|
|
27
|
+
background: var(--wm-color-bg);
|
|
28
|
+
border: 1px solid var(--wm-color-border-strong);
|
|
29
|
+
border-radius: var(--wm-radius-xs);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.wm-input[aria-invalid="true"],
|
|
33
|
+
.wm-select[aria-invalid="true"] { border-color: var(--wm-color-danger); }
|
|
34
|
+
|
|
35
|
+
.wm-input:disabled,
|
|
36
|
+
.wm-select:disabled {
|
|
37
|
+
cursor: not-allowed;
|
|
38
|
+
opacity: 0.6;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.wm-input:focus-visible,
|
|
42
|
+
.wm-select:focus-visible {
|
|
43
|
+
outline: 2px solid var(--wm-color-accent);
|
|
44
|
+
outline-offset: 2px;
|
|
45
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.wm-list-group {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
list-style: none;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.wm-list-item {
|
|
8
|
+
display: block;
|
|
9
|
+
padding: var(--wm-space-3) var(--wm-space-4);
|
|
10
|
+
color: var(--wm-color-text);
|
|
11
|
+
border-bottom: 1px solid var(--wm-color-border);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wm-list-item:last-child { border-bottom: 0; }
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.wm-menu {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.wm-menu-items {
|
|
7
|
+
position: absolute;
|
|
8
|
+
inset-inline-end: 0;
|
|
9
|
+
z-index: var(--wm-layer-popup);
|
|
10
|
+
width: max-content;
|
|
11
|
+
min-width: min(12rem, 90vw);
|
|
12
|
+
max-width: min(24rem, 90vw);
|
|
13
|
+
margin: var(--wm-space-1) 0;
|
|
14
|
+
padding: var(--wm-space-1);
|
|
15
|
+
list-style: none;
|
|
16
|
+
border: 1px solid var(--wm-color-border);
|
|
17
|
+
border-radius: var(--wm-radius-xs);
|
|
18
|
+
background: var(--wm-color-surface-solid);
|
|
19
|
+
box-shadow: var(--wm-shadow-soft);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.wm-menu-items [role="menuitem"] {
|
|
23
|
+
display: block;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
width: 100%;
|
|
26
|
+
padding: var(--wm-space-2) var(--wm-space-3);
|
|
27
|
+
border: 0;
|
|
28
|
+
background: transparent;
|
|
29
|
+
color: var(--wm-color-text);
|
|
30
|
+
font: inherit;
|
|
31
|
+
text-align: start;
|
|
32
|
+
text-decoration: none;
|
|
33
|
+
overflow-wrap: anywhere;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.wm-menu-items [role="menuitem"]:focus-visible,
|
|
38
|
+
.wm-menu-items [role="menuitem"]:hover {
|
|
39
|
+
outline: 2px solid var(--wm-color-accent);
|
|
40
|
+
outline-offset: -2px;
|
|
41
|
+
background: var(--wm-color-accent-soft);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.wm-menu-items [aria-disabled="true"] {
|
|
45
|
+
color: var(--wm-color-text-muted);
|
|
46
|
+
cursor: not-allowed;
|
|
47
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.wm-nav {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-wrap: wrap;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--wm-space-3);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.wm-nav a[aria-current="page"] {
|
|
9
|
+
color: var(--wm-color-accent);
|
|
10
|
+
text-decoration-color: currentcolor;
|
|
11
|
+
font-weight: 600;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wm-nav a:focus-visible,
|
|
15
|
+
.wm-btn:focus-visible {
|
|
16
|
+
outline: 2px solid var(--wm-color-accent);
|
|
17
|
+
outline-offset: 2px;
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.wm-progress {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: var(--wm-space-2);
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
appearance: none;
|
|
7
|
+
border: 0;
|
|
8
|
+
border-radius: var(--wm-radius-pill);
|
|
9
|
+
background: var(--wm-color-surface-strong);
|
|
10
|
+
accent-color: var(--wm-color-accent);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.wm-progress::-webkit-progress-bar {
|
|
14
|
+
background: var(--wm-color-surface-strong);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.wm-progress::-webkit-progress-value {
|
|
18
|
+
background: var(--wm-color-accent);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.wm-progress::-moz-progress-bar {
|
|
22
|
+
background: var(--wm-color-accent);
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.wm-sr-only {
|
|
2
|
+
position: absolute;
|
|
3
|
+
width: 1px;
|
|
4
|
+
height: 1px;
|
|
5
|
+
padding: 0;
|
|
6
|
+
margin: -1px;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
clip-path: inset(50%);
|
|
9
|
+
white-space: nowrap;
|
|
10
|
+
border: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.wm-spinner {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
color: var(--wm-color-accent);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.wm-spinner-indicator {
|
|
20
|
+
width: var(--wm-space-5);
|
|
21
|
+
height: var(--wm-space-5);
|
|
22
|
+
border: 2px solid var(--wm-color-border-strong);
|
|
23
|
+
border-top-color: currentcolor;
|
|
24
|
+
border-radius: 50%;
|
|
25
|
+
animation: wm-spin 0.8s linear infinite;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@keyframes wm-spin {
|
|
29
|
+
to { transform: rotate(360deg); }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@media (prefers-reduced-motion: reduce) {
|
|
33
|
+
.wm-spinner-indicator { animation: none; }
|
|
34
|
+
}
|
|
@@ -66,6 +66,23 @@
|
|
|
66
66
|
|
|
67
67
|
/* Section label above a tab group or filter set */
|
|
68
68
|
|
|
69
|
+
.wm-tabs .wm-tab-bar {
|
|
70
|
+
max-width: 100%;
|
|
71
|
+
overflow-x: auto;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.wm-tabs .wm-tab-btn:disabled {
|
|
75
|
+
cursor: not-allowed;
|
|
76
|
+
opacity: 0.6;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.wm-tabs .wm-tab-btn:focus-visible {
|
|
80
|
+
outline: 2px solid var(--wm-color-accent);
|
|
81
|
+
outline-offset: -2px;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.wm-tab-panel { padding-block: var(--wm-space-4); }
|
|
85
|
+
|
|
69
86
|
.tab-section-label,
|
|
70
87
|
.wm-tab-section-label {
|
|
71
88
|
display: flex;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.wm-table {
|
|
2
|
+
width: 100%;
|
|
3
|
+
border-collapse: collapse;
|
|
4
|
+
color: var(--wm-color-text);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.wm-table th,
|
|
8
|
+
.wm-table td {
|
|
9
|
+
padding: var(--wm-space-3) var(--wm-space-4);
|
|
10
|
+
text-align: start;
|
|
11
|
+
border-bottom: 1px solid var(--wm-color-border);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wm-table th {
|
|
15
|
+
color: var(--wm-color-text-secondary);
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.wm-table-responsive {
|
|
20
|
+
max-width: 100%;
|
|
21
|
+
overflow-x: auto;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.wm-table-responsive:focus-visible {
|
|
25
|
+
outline: 2px solid var(--wm-color-accent);
|
|
26
|
+
outline-offset: 2px;
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.wm-tooltip-anchor {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.wm-tooltip {
|
|
7
|
+
position: absolute;
|
|
8
|
+
inset-block-end: 100%;
|
|
9
|
+
inset-inline-start: 0;
|
|
10
|
+
z-index: var(--wm-layer-tooltip);
|
|
11
|
+
width: max-content;
|
|
12
|
+
max-width: min(24rem, 80vw);
|
|
13
|
+
padding: var(--wm-space-2) var(--wm-space-3);
|
|
14
|
+
border: 1px solid var(--wm-color-border-strong);
|
|
15
|
+
border-radius: var(--wm-radius-xs);
|
|
16
|
+
background: var(--wm-color-surface-solid);
|
|
17
|
+
color: var(--wm-color-text);
|
|
18
|
+
font-size: var(--wm-text-sm);
|
|
19
|
+
box-shadow: var(--wm-shadow-soft);
|
|
20
|
+
}
|
package/styles/components.css
CHANGED
|
@@ -23,3 +23,15 @@
|
|
|
23
23
|
@import url("./components/toggle-group.css");
|
|
24
24
|
@import url("./components/toast.css");
|
|
25
25
|
@import url("./components/code-block.css");
|
|
26
|
+
@import url("./components/alert.css");
|
|
27
|
+
@import url("./components/spinner.css");
|
|
28
|
+
@import url("./components/progress.css");
|
|
29
|
+
@import url("./components/field.css");
|
|
30
|
+
@import url("./components/list-group.css");
|
|
31
|
+
@import url("./components/table.css");
|
|
32
|
+
@import url("./components/nav.css");
|
|
33
|
+
@import url("./components/accordion.css");
|
|
34
|
+
@import url("./components/menu.css");
|
|
35
|
+
@import url("./components/tooltip.css");
|
|
36
|
+
@import url("./components/dialog.css");
|
|
37
|
+
@import url("./components/search-select.css");
|
package/styles/tokens.css
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
/* Shared Wintermuted UI theme tokens. */
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
|
+
--wm-space-1: 0.25rem;
|
|
5
|
+
--wm-space-2: 0.5rem;
|
|
6
|
+
--wm-space-3: 0.75rem;
|
|
7
|
+
--wm-space-4: 1rem;
|
|
8
|
+
--wm-space-5: 1.25rem;
|
|
9
|
+
--wm-space-6: 1.5rem;
|
|
10
|
+
--wm-text-sm: 0.875rem;
|
|
11
|
+
--wm-control-height: 2.75rem;
|
|
12
|
+
--wm-dialog-width: 36rem;
|
|
13
|
+
--wm-dialog-backdrop: rgb(0 0 0 / 55%);
|
|
14
|
+
--wm-layer-popup: 20;
|
|
15
|
+
--wm-layer-tooltip: 30;
|
|
4
16
|
--wm-font-sans: "Inter", "Sohne", "Söhne", system-ui, -apple-system, "Segoe UI",
|
|
5
17
|
helvetica, arial, sans-serif;
|
|
6
18
|
--wm-color-text: #0d0d0d;
|