@efolusi/meridian 1.7.0 → 1.9.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.
@@ -2,86 +2,117 @@
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  import React from 'react';
4
4
  import { Icon } from "../icons/Icon.js";
5
+ // Every fill carries the label colour that clears 4.5:1 on it in BOTH themes —
6
+ // no single label colour does (white fails on brand-500/sand-500 in light, dark
7
+ // ink fails on the fixed dark fills in dark). Status fills flip via the
8
+ // *-contrast tokens; fixed fills pair with a fixed label.
9
+ const T = {
10
+ flipD: 'var(--danger-contrast)',
11
+ flipS: 'var(--success-contrast)',
12
+ flipW: 'var(--warning-contrast)',
13
+ white: 'var(--text-on-brand)',
14
+ ink: 'var(--brand-950)'
15
+ };
5
16
  const KIND = {
6
17
  pdf: {
7
18
  icon: 'file-text',
8
- color: 'var(--danger-600)'
19
+ color: 'var(--danger-600)',
20
+ label: T.flipD
9
21
  },
10
22
  doc: {
11
23
  icon: 'file-text',
12
- color: 'var(--brand-700)'
24
+ color: 'var(--brand-700)',
25
+ label: T.white
13
26
  },
14
27
  docx: {
15
28
  icon: 'file-text',
16
- color: 'var(--brand-700)'
29
+ color: 'var(--brand-700)',
30
+ label: T.white
17
31
  },
18
32
  txt: {
19
33
  icon: 'file-text',
20
- color: 'var(--sand-600)'
34
+ color: 'var(--sand-600)',
35
+ label: T.white
21
36
  },
22
37
  md: {
23
38
  icon: 'file-text',
24
- color: 'var(--sand-600)'
39
+ color: 'var(--sand-600)',
40
+ label: T.white
25
41
  },
26
42
  csv: {
27
43
  icon: 'table',
28
- color: 'var(--success-600)'
44
+ color: 'var(--success-600)',
45
+ label: T.flipS
29
46
  },
30
47
  xls: {
31
48
  icon: 'table',
32
- color: 'var(--success-600)'
49
+ color: 'var(--success-600)',
50
+ label: T.flipS
33
51
  },
34
52
  xlsx: {
35
53
  icon: 'table',
36
- color: 'var(--success-600)'
54
+ color: 'var(--success-600)',
55
+ label: T.flipS
37
56
  },
38
57
  png: {
39
58
  icon: 'image',
40
- color: 'var(--brand-500)'
59
+ color: 'var(--brand-500)',
60
+ label: T.ink
41
61
  },
42
62
  jpg: {
43
63
  icon: 'image',
44
- color: 'var(--brand-500)'
64
+ color: 'var(--brand-500)',
65
+ label: T.ink
45
66
  },
46
67
  svg: {
47
68
  icon: 'image',
48
- color: 'var(--brand-500)'
69
+ color: 'var(--brand-500)',
70
+ label: T.ink
49
71
  },
50
72
  gif: {
51
73
  icon: 'image',
52
- color: 'var(--brand-500)'
74
+ color: 'var(--brand-500)',
75
+ label: T.ink
53
76
  },
54
77
  mp4: {
55
78
  icon: 'video',
56
- color: 'var(--warning-600)'
79
+ color: 'var(--warning-600)',
80
+ label: T.flipW
57
81
  },
58
82
  mov: {
59
83
  icon: 'video',
60
- color: 'var(--warning-600)'
84
+ color: 'var(--warning-600)',
85
+ label: T.flipW
61
86
  },
62
87
  mp3: {
63
88
  icon: 'mic',
64
- color: 'var(--warning-600)'
89
+ color: 'var(--warning-600)',
90
+ label: T.flipW
65
91
  },
66
92
  wav: {
67
93
  icon: 'mic',
68
- color: 'var(--warning-600)'
94
+ color: 'var(--warning-600)',
95
+ label: T.flipW
69
96
  },
70
97
  zip: {
71
98
  icon: 'archive',
72
- color: 'var(--sand-600)'
99
+ color: 'var(--sand-600)',
100
+ label: T.white
73
101
  },
74
102
  json: {
75
103
  icon: 'code',
76
- color: 'var(--sand-800)'
104
+ color: 'var(--sand-800)',
105
+ label: T.white
77
106
  },
78
107
  js: {
79
108
  icon: 'code',
80
- color: 'var(--warning-600)'
109
+ color: 'var(--warning-600)',
110
+ label: T.flipW
81
111
  },
82
112
  ts: {
83
113
  icon: 'code',
84
- color: 'var(--brand-700)'
114
+ color: 'var(--brand-700)',
115
+ label: T.white
85
116
  }
86
117
  };
87
118
  export function FileTypeIcon({
@@ -94,7 +125,8 @@ export function FileTypeIcon({
94
125
  }) {
95
126
  const k = KIND[ext.toLowerCase()] || {
96
127
  icon: 'file',
97
- color: 'var(--sand-500)'
128
+ color: 'var(--sand-500)',
129
+ label: T.ink
98
130
  };
99
131
  return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
100
132
  className: `ef-filetype${className ? ' ' + className : ''}`,
@@ -110,7 +142,8 @@ export function FileTypeIcon({
110
142
  }), showExt ? /*#__PURE__*/React.createElement("span", {
111
143
  className: "ef-filetype__ext",
112
144
  style: {
113
- background: k.color
145
+ background: k.color,
146
+ color: k.label
114
147
  }
115
148
  }, ext) : null);
116
149
  }
@@ -37,3 +37,46 @@ export interface FormFieldProps {
37
37
  * anything else, pass a function and spread `controlProps` on the control.
38
38
  */
39
39
  export declare function FormField(props: FormFieldProps): React.JSX.Element;
40
+
41
+ /** What `field(name)` returns: spread it on a control, or wire prop-by-prop. */
42
+ export interface FormFieldControl<V = unknown> {
43
+ value: V;
44
+ /** Accepts a change event (reads `target.value`, or `target.checked` for checkboxes) or a raw value. */
45
+ onChange: (eventOrValue: unknown) => void;
46
+ /** Marks the field touched, which lets its error surface. */
47
+ onBlur: () => void;
48
+ invalid: boolean;
49
+ /** Only set after the field was touched or a submit attempt (guidelines/forms.md timing). */
50
+ error: string | undefined;
51
+ }
52
+ export interface UseFormStateOptions<T extends Record<string, any>> {
53
+ /** Seed values. Read once, on the first render. */
54
+ initial: T;
55
+ /** Returns `{ field: 'message' }` for invalid fields; empty object = valid. */
56
+ validate?: (values: T) => Partial<Record<keyof T & string, string>>;
57
+ }
58
+ export interface UseFormStateReturn<T extends Record<string, any>> {
59
+ values: T;
60
+ /** The raw `validate(values)` result — not gated by touch. `field().error` is. */
61
+ errors: Partial<Record<keyof T & string, string>>;
62
+ touched: Partial<Record<keyof T & string, boolean>>;
63
+ set: <K extends keyof T & string>(name: K, value: T[K]) => void;
64
+ field: <K extends keyof T & string>(name: K) => FormFieldControl<T[K]>;
65
+ /** True while an async submit handler is in flight. */
66
+ submitting: boolean;
67
+ /**
68
+ * Wraps a submit handler: validates everything, marks all fields touched,
69
+ * and only calls `fn(values)` when clean. An async `fn` sets `submitting`
70
+ * around its promise.
71
+ */
72
+ handleSubmit: (fn?: (values: T) => unknown | Promise<unknown>) => (e?: React.SyntheticEvent) => unknown;
73
+ /** Back to `initial`, untouched, not submitting. */
74
+ reset: () => void;
75
+ }
76
+ /**
77
+ * Zero-dependency form state. Published as a static — `FormField.useFormState()`
78
+ * — because only capitalised exports reach the global namespace.
79
+ */
80
+ export declare namespace FormField {
81
+ function useFormState<T extends Record<string, any>>(options: UseFormStateOptions<T>): UseFormStateReturn<T>;
82
+ }
@@ -116,4 +116,94 @@ export function FormField({
116
116
  id: noteId,
117
117
  className: "ef-field__hint"
118
118
  }, hint) : null);
119
- }
119
+ }
120
+
121
+ /**
122
+ * Zero-dependency form state: values, per-field wiring, validation timing.
123
+ *
124
+ * `validate(values)` returns `{ field: 'message' }` for whatever is currently
125
+ * invalid; an empty object means clean. A field's error only surfaces once
126
+ * that field has blurred or a submit was attempted — the timing
127
+ * guidelines/forms.md prescribes (blur, then re-validate on change, then
128
+ * everything on submit) — while `errors` always carries the raw result.
129
+ *
130
+ * Lowercase, so the compiler files it under unexposedExports and it never
131
+ * reaches the global namespace directly. Consumers get it as
132
+ * `FormField.useFormState` (assigned at the bottom of this file), the same
133
+ * publication Toaster.useToast uses.
134
+ */
135
+ export function useFormState({
136
+ initial,
137
+ validate
138
+ } = {}) {
139
+ // The first render's `initial` wins for the life of the hook, so an inline
140
+ // object literal does not re-seed the form on every render.
141
+ const initialRef = React.useRef(initial || {});
142
+ const [values, setValues] = React.useState(initialRef.current);
143
+ const [touched, setTouched] = React.useState({});
144
+ const [submitted, setSubmitted] = React.useState(false);
145
+ const [submitting, setSubmitting] = React.useState(false);
146
+ const errors = validate ? validate(values) || {} : {};
147
+ const set = React.useCallback((name, val) => {
148
+ setValues(prev => ({
149
+ ...prev,
150
+ [name]: val
151
+ }));
152
+ }, []);
153
+ const field = name => {
154
+ const err = touched[name] || submitted ? errors[name] : undefined;
155
+ return {
156
+ value: values[name],
157
+ onChange: eventOrValue => {
158
+ const t = eventOrValue && typeof eventOrValue === 'object' ? eventOrValue.target : null;
159
+ set(name, t && 'value' in t ? t.type === 'checkbox' ? t.checked : t.value : eventOrValue);
160
+ },
161
+ onBlur: () => setTouched(prev => prev[name] ? prev : {
162
+ ...prev,
163
+ [name]: true
164
+ }),
165
+ invalid: err != null && err !== '',
166
+ error: err != null && err !== '' ? err : undefined
167
+ };
168
+ };
169
+ const handleSubmit = fn => e => {
170
+ if (e && typeof e.preventDefault === 'function') e.preventDefault();
171
+ setSubmitted(true);
172
+ const errs = validate ? validate(values) || {} : {};
173
+ const all = {};
174
+ Object.keys(values).forEach(k => {
175
+ all[k] = true;
176
+ });
177
+ Object.keys(errs).forEach(k => {
178
+ all[k] = true;
179
+ });
180
+ setTouched(prev => ({
181
+ ...prev,
182
+ ...all
183
+ }));
184
+ if (Object.keys(errs).length > 0) return;
185
+ const out = fn ? fn(values) : undefined;
186
+ if (out && typeof out.then === 'function') {
187
+ setSubmitting(true);
188
+ return Promise.resolve(out).finally(() => setSubmitting(false));
189
+ }
190
+ return out;
191
+ };
192
+ const reset = React.useCallback(() => {
193
+ setValues(initialRef.current);
194
+ setTouched({});
195
+ setSubmitted(false);
196
+ setSubmitting(false);
197
+ }, []);
198
+ return {
199
+ values,
200
+ errors,
201
+ touched,
202
+ set,
203
+ field,
204
+ submitting,
205
+ handleSubmit,
206
+ reset
207
+ };
208
+ }
209
+ FormField.useFormState = useFormState;
@@ -0,0 +1,39 @@
1
+ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'value' | 'defaultValue' | 'onChange' | 'min' | 'max' | 'step'> {
2
+ /** Field label rendered above */
3
+ label?: string;
4
+ /** Muted helper text below */
5
+ hint?: string;
6
+ /** Error message below — also sets invalid styling */
7
+ error?: string;
8
+ /** Invalid styling with no message. @default false */
9
+ invalid?: boolean;
10
+ /** Controlled value; null is "empty" */
11
+ value?: number | null;
12
+ defaultValue?: number | null;
13
+ /** Fires on commit (blur, arrow keys, steppers). null when cleared. */
14
+ onChange?: (value: number | null, e: React.SyntheticEvent) => void;
15
+ /** Lower rail; commits clamp to it, Home jumps to it when finite */
16
+ min?: number;
17
+ /** Upper rail; commits clamp to it, End jumps to it when finite */
18
+ max?: number;
19
+ /** Arrow/stepper increment; commits snap to its grid. @default 1 */
20
+ step?: number;
21
+ /** @default 'md' */
22
+ size?: 'sm' | 'md' | 'lg';
23
+ disabled?: boolean;
24
+ placeholder?: string;
25
+ /** Display formatting for the committed value, e.g. n => n + ' GB' */
26
+ format?: (value: number) => string;
27
+ /** Turn typed text back into a number; pair it with `format`. Return null for unparseable. */
28
+ parse?: (text: string) => number | null;
29
+ style?: React.CSSProperties;
30
+ className?: string;
31
+ }
32
+ /**
33
+ * Numeric field with stepper buttons. A text input with inputmode="decimal" —
34
+ * not type=number — so typing stays free-form; the value commits on blur:
35
+ * parse, clamp to min/max, snap to the step grid. Empty commits null.
36
+ * ArrowUp/Down step, Shift+Arrow steps by 10× step, Home/End jump to finite
37
+ * rails. Steppers disable at the rails.
38
+ */
39
+ export declare function NumberInput(props: NumberInputProps): React.JSX.Element;
@@ -0,0 +1,177 @@
1
+ 'use client';
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ import React from 'react';
4
+ import { Icon } from "../icons/Icon.js";
5
+ import { useFieldProps } from "./FormField.js";
6
+ // How many decimal places a number carries, so a commit can round away float
7
+ // noise: 0.1 + 0.2 must land as 0.3, not 0.30000000000000004.
8
+ function decimalsOf(n) {
9
+ if (!Number.isFinite(n)) return 0;
10
+ const s = String(n);
11
+ const e = s.search(/e-/i);
12
+ const i = s.indexOf('.');
13
+ if (e !== -1) return (+s.slice(e + 2) || 0) + (i !== -1 ? e - i - 1 : 0);
14
+ return i === -1 ? 0 : s.length - i - 1;
15
+ }
16
+ const defaultParse = t => {
17
+ const n = Number(t.replace(/,/g, ''));
18
+ return Number.isFinite(n) ? n : null;
19
+ };
20
+ /**
21
+ * A numeric field with stepper buttons — a text input with inputmode="decimal"
22
+ * rather than type=number, so typing stays free-form and the value only
23
+ * commits (parse → clamp → snap to step) on blur. Empty commits null.
24
+ * ArrowUp/Down step, Shift multiplies by 10, Home/End jump to finite rails.
25
+ */
26
+ export function NumberInput({
27
+ label,
28
+ hint,
29
+ error,
30
+ invalid,
31
+ value,
32
+ defaultValue,
33
+ onChange,
34
+ min,
35
+ max,
36
+ step = 1,
37
+ size = 'md',
38
+ disabled,
39
+ placeholder,
40
+ format,
41
+ parse,
42
+ style,
43
+ className,
44
+ ...rest
45
+ }) {
46
+ // Picks up id / aria wiring when nested in a FormField; standalone this is a no-op.
47
+ const field = useFieldProps({
48
+ invalid,
49
+ error,
50
+ id: rest.id,
51
+ 'aria-describedby': rest['aria-describedby']
52
+ });
53
+ const uid = React.useId();
54
+ const inputId = field.id || (label ? uid + 'n' : undefined);
55
+ const bad = field.invalid;
56
+ const [inner, setInner] = React.useState(defaultValue !== undefined ? defaultValue : null);
57
+ const v = value !== undefined ? value : inner;
58
+ // The text being edited; null means "not editing, show the formatted value".
59
+ const [draft, setDraft] = React.useState(null);
60
+ const fmt = n => format ? format(n) : String(n);
61
+ const parseText = t => {
62
+ const s = t.trim();
63
+ if (s === '') return null;
64
+ const n = (parse || defaultParse)(s);
65
+ return n != null && Number.isFinite(n) ? n : undefined; // undefined = unparseable
66
+ };
67
+ const normalize = n => {
68
+ let x = n;
69
+ if (step > 0) {
70
+ const base = Number.isFinite(min) ? min : 0;
71
+ const d = Math.max(decimalsOf(step), decimalsOf(base));
72
+ x = base + Math.round((x - base) / step) * step;
73
+ x = Number(x.toFixed(Math.min(d, 20)));
74
+ }
75
+ if (Number.isFinite(min) && x < min) x = min;
76
+ if (Number.isFinite(max) && x > max) x = max;
77
+ return x;
78
+ };
79
+ const emit = (next, e) => {
80
+ if (value === undefined) setInner(next);
81
+ if (onChange && !Object.is(next, v)) onChange(next, e);
82
+ };
83
+ const commit = e => {
84
+ if (draft == null) return;
85
+ const n = parseText(draft);
86
+ setDraft(null);
87
+ if (n === undefined) return; // unparseable: revert to the last committed value
88
+ emit(n === null ? null : normalize(n), e);
89
+ };
90
+ const stepBy = (dir, mult, e) => {
91
+ const parsed = draft != null ? parseText(draft) : v;
92
+ const cur = parsed === undefined ? v : parsed;
93
+ let next;
94
+ if (cur == null) next = Number.isFinite(min) ? min : Number.isFinite(max) && dir < 0 ? max : 0;else next = cur + dir * step * mult;
95
+ setDraft(null);
96
+ emit(normalize(next), e);
97
+ };
98
+ const keys = e => {
99
+ if (disabled) return;
100
+ if (e.key === 'ArrowUp') {
101
+ e.preventDefault();
102
+ stepBy(1, e.shiftKey ? 10 : 1, e);
103
+ } else if (e.key === 'ArrowDown') {
104
+ e.preventDefault();
105
+ stepBy(-1, e.shiftKey ? 10 : 1, e);
106
+ } else if (e.key === 'Home' && Number.isFinite(min)) {
107
+ e.preventDefault();
108
+ setDraft(null);
109
+ emit(normalize(min), e);
110
+ } else if (e.key === 'End' && Number.isFinite(max)) {
111
+ e.preventDefault();
112
+ setDraft(null);
113
+ emit(normalize(max), e);
114
+ }
115
+ };
116
+ const shown = draft != null ? draft : v == null ? '' : fmt(v);
117
+ const upStuck = disabled || v != null && Number.isFinite(max) && v >= max;
118
+ const downStuck = disabled || v != null && Number.isFinite(min) && v <= min;
119
+ const control = /*#__PURE__*/React.createElement("span", {
120
+ className: `ef-number ef-number--${size}${bad ? ' ef-number--invalid' : ''}${disabled ? ' ef-number--disabled' : ''}`
121
+ }, /*#__PURE__*/React.createElement("input", _extends({}, rest, field.controlProps, {
122
+ id: inputId,
123
+ className: "ef-number__el",
124
+ type: "text",
125
+ inputMode: "decimal",
126
+ autoComplete: "off",
127
+ placeholder: placeholder,
128
+ disabled: disabled,
129
+ value: shown,
130
+ "aria-invalid": bad || undefined,
131
+ onChange: e => setDraft(e.target.value),
132
+ onKeyDown: keys,
133
+ onBlur: commit
134
+ })), /*#__PURE__*/React.createElement("span", {
135
+ className: "ef-number__steps"
136
+ }, /*#__PURE__*/React.createElement("button", {
137
+ type: "button",
138
+ className: "ef-number__step",
139
+ "aria-label": "Increase",
140
+ tabIndex: -1,
141
+ disabled: upStuck,
142
+ onMouseDown: e => e.preventDefault(),
143
+ onClick: e => stepBy(1, 1, e)
144
+ }, /*#__PURE__*/React.createElement(Icon, {
145
+ name: "chevron-up",
146
+ size: size === 'lg' ? 14 : 12
147
+ })), /*#__PURE__*/React.createElement("button", {
148
+ type: "button",
149
+ className: "ef-number__step",
150
+ "aria-label": "Decrease",
151
+ tabIndex: -1,
152
+ disabled: downStuck,
153
+ onMouseDown: e => e.preventDefault(),
154
+ onClick: e => stepBy(-1, 1, e)
155
+ }, /*#__PURE__*/React.createElement(Icon, {
156
+ name: "chevron-down",
157
+ size: size === 'lg' ? 14 : 12
158
+ }))));
159
+ if (!label && !hint && !error) return /*#__PURE__*/React.cloneElement(control, {
160
+ style,
161
+ className: control.props.className + (className ? ' ' + className : '')
162
+ });
163
+ return /*#__PURE__*/React.createElement("div", {
164
+ className: `ef-field${className ? ' ' + className : ''}`,
165
+ style: style
166
+ }, label ? /*#__PURE__*/React.createElement("label", {
167
+ htmlFor: inputId,
168
+ className: "ef-field__label"
169
+ }, label) : null, control, error ? /*#__PURE__*/React.createElement("span", {
170
+ className: "ef-field__error"
171
+ }, /*#__PURE__*/React.createElement(Icon, {
172
+ name: "circle-alert",
173
+ size: 12
174
+ }), error) : hint ? /*#__PURE__*/React.createElement("span", {
175
+ className: "ef-field__hint"
176
+ }, hint) : null);
177
+ }
package/index.d.ts CHANGED
@@ -41,6 +41,8 @@ export * from './data/StatusDot.js';
41
41
  export * from './data/Table.js';
42
42
  export * from './dates/Calendar.js';
43
43
  export * from './dates/DatePicker.js';
44
+ export * from './dates/DateRangePicker.js';
45
+ export * from './dates/TimePicker.js';
44
46
  export * from './display/Accordion.js';
45
47
  export * from './display/AspectRatio.js';
46
48
  export * from './display/Avatar.js';
@@ -81,6 +83,7 @@ export * from './forms/IconButton.js';
81
83
  export * from './forms/Input.js';
82
84
  export * from './forms/InputGroup.js';
83
85
  export * from './forms/Label.js';
86
+ export * from './forms/NumberInput.js';
84
87
  export * from './forms/Radio.js';
85
88
  export * from './forms/Select.js';
86
89
  export * from './forms/Slider.js';
package/index.js CHANGED
@@ -41,6 +41,8 @@ export { StatusDot } from './data/StatusDot.js';
41
41
  export { Table } from './data/Table.js';
42
42
  export { Calendar } from './dates/Calendar.js';
43
43
  export { DatePicker } from './dates/DatePicker.js';
44
+ export { DateRangePicker } from './dates/DateRangePicker.js';
45
+ export { TimePicker } from './dates/TimePicker.js';
44
46
  export { Accordion } from './display/Accordion.js';
45
47
  export { AspectRatio } from './display/AspectRatio.js';
46
48
  export { Avatar, AvatarGroup } from './display/Avatar.js';
@@ -81,6 +83,7 @@ export { IconButton } from './forms/IconButton.js';
81
83
  export { Input } from './forms/Input.js';
82
84
  export { InputGroup } from './forms/InputGroup.js';
83
85
  export { Label } from './forms/Label.js';
86
+ export { NumberInput } from './forms/NumberInput.js';
84
87
  export { Radio } from './forms/Radio.js';
85
88
  export { Select } from './forms/Select.js';
86
89
  export { Slider } from './forms/Slider.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@efolusi/meridian",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "A general-purpose open-source design system by Efolusi: accessible React components, design tokens, blocks and example apps.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://meridian.efolusi.com",
@@ -51,12 +51,19 @@ module.exports = { theme: { extend: {
51
51
  "surface-code": "var(--surface-code)",
52
52
  "text-code": "var(--text-code)",
53
53
  "border-code": "var(--border-code)",
54
+ "success-on-dark": "var(--success-on-dark)",
55
+ "danger-on-dark": "var(--danger-on-dark)",
56
+ "warning-on-dark": "var(--warning-on-dark)",
54
57
  "overlay-scrim": "var(--overlay-scrim)",
55
58
  "text-on-brand-muted": "var(--text-on-brand-muted)",
59
+ "text-on-brand": "var(--text-on-brand)",
60
+ "text-on-media": "var(--text-on-media)",
61
+ "text-on-media-muted": "var(--text-on-media-muted)",
56
62
  "text-primary": "var(--text-primary)",
57
63
  "text-secondary": "var(--text-secondary)",
58
64
  "text-muted": "var(--text-muted)",
59
65
  "text-inverse": "var(--text-inverse)",
66
+ "text-inverse-muted": "var(--text-inverse-muted)",
60
67
  "text-link": "var(--text-link)",
61
68
  "border-default": "var(--border-default)",
62
69
  "border-strong": "var(--border-strong)",
@@ -68,6 +75,8 @@ module.exports = { theme: { extend: {
68
75
  "accent-subtle-border": "var(--accent-subtle-border)",
69
76
  "accent-contrast": "var(--accent-contrast)",
70
77
  "danger-contrast": "var(--danger-contrast)",
78
+ "success-contrast": "var(--success-contrast)",
79
+ "warning-contrast": "var(--warning-contrast)",
71
80
  "text-2xs": "var(--text-2xs)",
72
81
  "text-xs": "var(--text-xs)",
73
82
  "text-sm": "var(--text-sm)",
package/tokens/colors.css CHANGED
@@ -12,11 +12,21 @@
12
12
  /* Semantic aliases */
13
13
  --surface-page:var(--sand-50);--surface-card:#FFFFFF;--surface-sunken:var(--sand-100);--surface-subtle:var(--sand-25);--surface-inverse:var(--sand-950);--surface-brand:var(--brand-900);
14
14
  --surface-code:#14110B;--text-code:#E8E3D9;--border-code:rgba(240,235,225,.09);/* code/terminal surface — fixed dark espresso in BOTH themes (never remap) */
15
- --overlay-scrim:rgba(31,26,20,.45);/* modal/drawer backdrop */--text-on-brand-muted:rgba(248,244,230,.75);/* muted text on brand/inverse surfaces */
16
- --text-primary:var(--sand-950);--text-secondary:var(--sand-700);--text-muted:#746A55;/* between sand-600/700: ≥4.5:1 on page, card, and sunken */--text-inverse:var(--sand-50);--text-link:var(--brand-700);
15
+ /* Code-surface ink ladder — everything here sits on --surface-code, so each step is fixed in BOTH themes on purpose (never remap) */
16
+ --code-ink:rgba(250,249,246,.82);/* default terminal output */--code-ink-strong:rgba(250,249,246,.85);/* control labels on code */--code-ink-bright:#FFFFFF;/* hovered controls on code */
17
+ --code-ink-muted:rgba(250,249,246,.6);/* resting copy button */--code-ink-subtle:rgba(250,249,246,.55);/* language/host labels, info lines */--code-ink-faint:rgba(250,249,246,.35);/* timestamps */
18
+ --code-divider:rgba(250,249,246,.1);/* header hairline on code */--code-edge:rgba(250,249,246,.25);/* pill border on code */--code-edge-hover:rgba(250,249,246,.5);--code-raised:rgba(30,26,20,.85);/* pill fill floating over code */
19
+ /* Pastel status tints for dark fills (terminal ok/err lines, toast icons on the inverse surface) — fixed in BOTH themes on purpose; where the surface itself flips in dark, the component rule swaps to the strong status tokens */
20
+ --success-on-dark:#7FD08D;--danger-on-dark:#F49B93;--warning-on-dark:#F2C078;
21
+ --overlay-scrim:rgba(31,26,20,.45);/* modal/drawer backdrop */--text-on-brand-muted:rgba(248,244,230,.75);/* muted text on brand/inverse surfaces */--text-on-brand:#FFFFFF;/* label on a fixed brand-ramp fill (e.g. a --brand-700 button) — a fixed dark brand- or sand-ramp fill never remaps, so this is fixed in BOTH themes on purpose */
22
+ /* Media tones (GeneratedImage) — sit over user imagery, dark in BOTH themes on purpose (never remap) */
23
+ --media-backdrop:#141210;/* generation backdrop */--media-backdrop-dot:rgba(243,239,231,.22);/* shimmer dots on the backdrop */
24
+ --media-scrim:rgba(20,16,12,.55);/* legibility gradient over the finished image */--media-scrim-soft:rgba(20,16,12,.45);/* action chip resting fill */--media-scrim-strong:rgba(20,16,12,.7);/* action chip hover fill */
25
+ --text-on-media:var(--sand-50);/* prompt text over imagery — stays light in both themes */--text-on-media-muted:rgba(250,249,246,.75);/* status line over imagery */
26
+ --text-primary:var(--sand-950);--text-secondary:var(--sand-700);--text-muted:#746A55;/* between sand-600/700: ≥4.5:1 on page, card, and sunken */--text-inverse:var(--sand-50);--text-inverse-muted:rgba(250,249,246,.6);/* dim ink on --surface-inverse (toast close button); remapped in dark where the inverse surface flips light */--text-link:var(--brand-700);
17
27
  --border-default:var(--sand-200);--border-strong:var(--sand-300);--border-inverse:rgba(250,249,246,.18);
18
28
  --accent:var(--brand-950);--accent-hover:#1D0E04;--accent-active:#120801;--accent-subtle:var(--brand-50);--accent-subtle-border:var(--brand-200);--accent-contrast:#FFFFFF;
19
- --danger-contrast:#FFFFFF;/* label on a solid --danger-600 fill; flips in dark where the red lightens */
29
+ --danger-contrast:#FFFFFF;/* label on a solid --danger-600 fill; flips in dark where the red lightens */--success-contrast:#FFFFFF;--warning-contrast:#FFFFFF;/* same contract as --danger-contrast, for the green and amber fills */
20
30
  /* Focus ring — opaque, two-layer. The inner offset ring is surface-coloured so the
21
31
  indicator never sits directly against a control fill; the outer ring only ever needs
22
32
  contrast against the surface, clearing WCAG 1.4.11 (3:1 non-text) on every background. */
@@ -27,12 +37,12 @@
27
37
  /* Dark theme — semantic remap only; ramps stay fixed */
28
38
  [data-theme="dark"]{
29
39
  --surface-page:#191512;--surface-card:#211C17;--surface-sunken:#2A251E;--surface-subtle:#1D1814;--surface-inverse:var(--sand-50);--surface-brand:var(--brand-950);
30
- --text-primary:#F3EFE7;--text-secondary:#C9C0B2;--text-muted:#9C9280;--text-inverse:var(--sand-950);--text-link:var(--brand-400);
40
+ --text-primary:#F3EFE7;--text-secondary:#C9C0B2;--text-muted:#9C9280;--text-inverse:var(--sand-950);--text-inverse-muted:rgba(30,26,20,.55);--text-link:var(--brand-400);
31
41
  --border-default:#332C24;--border-strong:#453C31;--border-inverse:rgba(30,26,20,.2);
32
42
  --accent:#F3EFE7;--accent-hover:#FFFFFF;--accent-active:#D5CFC0;--accent-subtle:#2A2119;--accent-subtle-border:#453728;--accent-contrast:#1E1A14;
33
43
  --success-600:#5FB86E;--success-100:#1C2B1F;--success-300:#2E4A34;
34
44
  --warning-100:#2E2413;--warning-300:#4A3A1D;--warning-600:#D9822B;
35
- --danger-100:#321B18;--danger-300:#54291F;--danger-600:#E85D4A;--danger-contrast:#1E1A14;
45
+ --danger-100:#321B18;--danger-300:#54291F;--danger-600:#E85D4A;--danger-contrast:#1E1A14;--success-contrast:#1E1A14;--warning-contrast:#1E1A14;
36
46
  --focus-ring-color:var(--brand-400);/* offset + composite inherit from :root and re-resolve here */
37
47
  }
38
48
  [data-theme="dark"] ::selection{background:#453728}