@field-studio/react 0.0.0-stage → 0.1.3
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 +37 -2
- package/dist/agent/AgentEditor.d.ts +16 -0
- package/dist/agent/AgentEditor.js +51 -0
- package/dist/agent/MCPManager.d.ts +12 -0
- package/dist/agent/MCPManager.js +72 -0
- package/dist/agent/SkillImport.d.ts +8 -0
- package/dist/agent/SkillImport.js +31 -0
- package/dist/agent/SkillViewer.d.ts +7 -0
- package/dist/agent/SkillViewer.js +61 -0
- package/dist/agent/catalog.css +205 -0
- package/dist/agent/index.d.ts +7 -0
- package/dist/agent/index.js +5 -0
- package/dist/agent/skillTitle.d.ts +3 -0
- package/dist/agent/skillTitle.js +4 -0
- package/dist/agent/types.d.ts +46 -0
- package/dist/agent/types.js +1 -0
- package/dist/assistant/AssistantPanel.d.ts +15 -0
- package/dist/assistant/AssistantPanel.js +144 -0
- package/dist/assistant/AssistantProvider.d.ts +119 -0
- package/dist/assistant/AssistantProvider.js +427 -0
- package/dist/assistant/QuestionPanel.d.ts +8 -0
- package/dist/assistant/QuestionPanel.js +32 -0
- package/dist/assistant/TaskComposer.d.ts +25 -0
- package/dist/assistant/TaskComposer.js +354 -0
- package/dist/assistant/TaskFiles.d.ts +24 -0
- package/dist/assistant/TaskFiles.js +107 -0
- package/dist/assistant/assistant.css +428 -0
- package/dist/assistant/composer.css +116 -0
- package/dist/assistant/files.css +19 -0
- package/dist/assistant/index.d.ts +10 -0
- package/dist/assistant/index.js +6 -0
- package/dist/assistant/layout.d.ts +7 -0
- package/dist/assistant/layout.js +19 -0
- package/dist/assistant/messages.d.ts +355 -0
- package/dist/assistant/messages.js +239 -0
- package/dist/assistant/questions.css +6 -0
- package/dist/assistant/types.d.ts +85 -0
- package/dist/assistant/types.js +1 -0
- package/dist/auth/AuthShell.d.ts +34 -0
- package/dist/auth/AuthShell.js +195 -0
- package/dist/auth/RoleManager.d.ts +23 -0
- package/dist/auth/RoleManager.js +95 -0
- package/dist/auth/auth.css +67 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.js +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +153 -0
- package/dist/ui/Controls.d.ts +78 -0
- package/dist/ui/Controls.js +234 -0
- package/dist/ui/base.css +261 -0
- package/dist/ui/controls.css +35 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +2 -0
- package/package.json +69 -3
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type ReactNode, type RefObject } from 'react';
|
|
2
|
+
import './controls.css';
|
|
3
|
+
type SelectProps = {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
value?: string | number;
|
|
6
|
+
defaultValue?: string | number;
|
|
7
|
+
name?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
selectedLabel?: ReactNode;
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
onChange?: (event: {
|
|
15
|
+
target: {
|
|
16
|
+
value: string;
|
|
17
|
+
};
|
|
18
|
+
}) => void;
|
|
19
|
+
};
|
|
20
|
+
/** Choose an option with a project-styled popup and native form value. */
|
|
21
|
+
export declare function Select({ children, value, defaultValue, name, id, disabled, required, className, selectedLabel, onChange, ...aria }: SelectProps): import("react").JSX.Element;
|
|
22
|
+
type DialogRegion = {
|
|
23
|
+
background: RefObject<HTMLElement | null>;
|
|
24
|
+
portal: RefObject<HTMLElement | null>;
|
|
25
|
+
overlayClassName: string;
|
|
26
|
+
};
|
|
27
|
+
/** Limit dialogs to a host surface while sibling surfaces remain interactive. */
|
|
28
|
+
export declare function DialogScope({ background, portal, overlayClassName, children }: DialogRegion & {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}): import("react").JSX.Element;
|
|
31
|
+
/** Show a dialog with Escape, backdrop dismissal and scope-aware focus. */
|
|
32
|
+
export declare function Dialog({ title, lang, closeLabel, closeOnBackdrop, closeDisabled, onClose, className, children }: {
|
|
33
|
+
title: string;
|
|
34
|
+
lang?: string;
|
|
35
|
+
closeLabel?: string;
|
|
36
|
+
closeOnBackdrop?: boolean;
|
|
37
|
+
closeDisabled?: boolean;
|
|
38
|
+
onClose: () => void;
|
|
39
|
+
className?: string;
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
}): import("react").ReactPortal;
|
|
42
|
+
type CheckboxProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'value' | 'defaultChecked'> & {
|
|
43
|
+
checked?: boolean;
|
|
44
|
+
defaultChecked?: boolean;
|
|
45
|
+
value?: string;
|
|
46
|
+
onChange?: (event: {
|
|
47
|
+
target: {
|
|
48
|
+
checked: boolean;
|
|
49
|
+
};
|
|
50
|
+
}) => void;
|
|
51
|
+
};
|
|
52
|
+
/** Draw a project checkbox while preserving labels, keyboard activation and form values. */
|
|
53
|
+
export declare function Checkbox({ checked, defaultChecked, value, name, disabled, className, onChange, onClick, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
54
|
+
type RadioOption = {
|
|
55
|
+
value: string;
|
|
56
|
+
label: ReactNode;
|
|
57
|
+
description?: ReactNode;
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/** Select one option using project styling, arrow navigation and a single tab stop. */
|
|
61
|
+
export declare function RadioGroup({ options, value, onChange, disabled, name, ...aria }: {
|
|
62
|
+
options: RadioOption[];
|
|
63
|
+
value?: string;
|
|
64
|
+
onChange: (value: string) => void;
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
name?: string;
|
|
67
|
+
'aria-label': string;
|
|
68
|
+
}): import("react").JSX.Element;
|
|
69
|
+
/** Open the system file picker through a styled, explicitly labeled control. */
|
|
70
|
+
export declare function FilePicker({ label, files, onChange, accept, multiple, disabled }: {
|
|
71
|
+
label: string;
|
|
72
|
+
files: File[];
|
|
73
|
+
onChange: (files: File[]) => void;
|
|
74
|
+
accept?: string;
|
|
75
|
+
multiple?: boolean;
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
}): import("react").JSX.Element;
|
|
78
|
+
export {};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Children, createContext, isValidElement, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
4
|
+
import { Check, ChevronDown, FileUp, X } from 'lucide-react';
|
|
5
|
+
import './controls.css';
|
|
6
|
+
/** Choose an option with a project-styled popup and native form value. */
|
|
7
|
+
export function Select({ children, value, defaultValue, name, id, disabled, required, className = '', selectedLabel, onChange, ...aria }) {
|
|
8
|
+
const dialogScope = useContext(DialogRegionContext);
|
|
9
|
+
const options = Children.toArray(children).filter(isValidElement).map(child => {
|
|
10
|
+
const props = child.props;
|
|
11
|
+
return { value: String(props.value ?? props.children), label: props.children, disabled: props.disabled };
|
|
12
|
+
});
|
|
13
|
+
const [internal, setInternal] = useState(String(defaultValue ?? options.find(option => !option.disabled)?.value ?? ''));
|
|
14
|
+
const selected = String(value ?? internal);
|
|
15
|
+
const [open, setOpen] = useState(false);
|
|
16
|
+
const [active, setActive] = useState(0);
|
|
17
|
+
const [position, setPosition] = useState({ top: 0, left: 0, minWidth: 0, maxWidth: undefined, maxHeight: 240 });
|
|
18
|
+
const trigger = useRef(null);
|
|
19
|
+
const list = useRef(null);
|
|
20
|
+
const listId = useId();
|
|
21
|
+
const enabled = options.map((option, index) => option.disabled ? -1 : index).filter(index => index >= 0);
|
|
22
|
+
const menuBounds = () => {
|
|
23
|
+
const overlay = dialogScope ? trigger.current?.closest('.overlay') : null;
|
|
24
|
+
return overlay?.getBoundingClientRect() ?? { top: 0, left: 0, right: window.innerWidth, bottom: window.innerHeight };
|
|
25
|
+
};
|
|
26
|
+
const show = () => {
|
|
27
|
+
if (disabled || !enabled.length)
|
|
28
|
+
return;
|
|
29
|
+
const rect = trigger.current.getBoundingClientRect();
|
|
30
|
+
const bounds = menuBounds();
|
|
31
|
+
const maxWidth = Math.max(0, bounds.right - bounds.left - 16);
|
|
32
|
+
setPosition({ top: 0, left: 0, minWidth: Math.min(rect.width, maxWidth), maxWidth, maxHeight: 240 });
|
|
33
|
+
const index = options.findIndex(option => option.value === selected && !option.disabled);
|
|
34
|
+
setActive(index >= 0 ? index : enabled[0]);
|
|
35
|
+
setOpen(true);
|
|
36
|
+
};
|
|
37
|
+
useLayoutEffect(() => {
|
|
38
|
+
if (!open || !trigger.current || !list.current)
|
|
39
|
+
return;
|
|
40
|
+
const rect = trigger.current.getBoundingClientRect();
|
|
41
|
+
const menu = list.current.getBoundingClientRect();
|
|
42
|
+
const bounds = menuBounds();
|
|
43
|
+
const below = Math.max(0, bounds.bottom - rect.bottom - 12);
|
|
44
|
+
const above = Math.max(0, rect.top - bounds.top - 12);
|
|
45
|
+
const opensAbove = below < menu.height && above > below;
|
|
46
|
+
const maxHeight = Math.min(240, opensAbove ? above : below);
|
|
47
|
+
const height = Math.min(menu.height, maxHeight);
|
|
48
|
+
setPosition(previous => ({ ...previous,
|
|
49
|
+
top: Math.max(bounds.top + 8, opensAbove ? rect.top - height - 4 : rect.bottom + 4),
|
|
50
|
+
left: Math.max(bounds.left + 8, Math.min(rect.left, bounds.right - menu.width - 8)),
|
|
51
|
+
maxHeight,
|
|
52
|
+
}));
|
|
53
|
+
}, [open]);
|
|
54
|
+
const choose = (index) => {
|
|
55
|
+
const option = options[index];
|
|
56
|
+
if (!option || option.disabled || disabled)
|
|
57
|
+
return;
|
|
58
|
+
setInternal(option.value);
|
|
59
|
+
onChange?.({ target: { value: option.value } });
|
|
60
|
+
setOpen(false);
|
|
61
|
+
trigger.current?.focus();
|
|
62
|
+
};
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (!open)
|
|
65
|
+
return;
|
|
66
|
+
const outside = (event) => {
|
|
67
|
+
if (!trigger.current?.contains(event.target) && !list.current?.contains(event.target))
|
|
68
|
+
setOpen(false);
|
|
69
|
+
};
|
|
70
|
+
const close = (event) => {
|
|
71
|
+
if (!(event.target instanceof Node) || !list.current?.contains(event.target))
|
|
72
|
+
setOpen(false);
|
|
73
|
+
};
|
|
74
|
+
document.addEventListener('pointerdown', outside);
|
|
75
|
+
window.addEventListener('resize', close);
|
|
76
|
+
window.addEventListener('scroll', close, true);
|
|
77
|
+
return () => {
|
|
78
|
+
document.removeEventListener('pointerdown', outside);
|
|
79
|
+
window.removeEventListener('resize', close);
|
|
80
|
+
window.removeEventListener('scroll', close, true);
|
|
81
|
+
};
|
|
82
|
+
}, [open]);
|
|
83
|
+
useEffect(() => { if (open)
|
|
84
|
+
list.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({ block: 'nearest' }); }, [active, open]);
|
|
85
|
+
return _jsxs("span", { className: `ui-select ${className}`, children: [_jsxs("button", { ...aria, id: id, ref: trigger, type: "button", className: "ui-select-trigger", role: "combobox", "aria-haspopup": "listbox", "aria-required": required || undefined, "aria-expanded": open, "aria-controls": open ? listId : undefined, "aria-activedescendant": open ? `${listId}-${active}` : undefined, disabled: disabled, onBlur: event => { if (!list.current?.contains(event.relatedTarget))
|
|
86
|
+
setOpen(false); }, onClick: () => open ? setOpen(false) : show(), onKeyDown: event => {
|
|
87
|
+
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
88
|
+
if (event.key === 'Escape' && open)
|
|
89
|
+
event.stopPropagation();
|
|
90
|
+
setOpen(false);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (['ArrowDown', 'ArrowUp', 'Home', 'End', 'Enter', ' '].includes(event.key)) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
if (!open) {
|
|
96
|
+
show();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
100
|
+
choose(active);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const current = enabled.indexOf(active);
|
|
104
|
+
setActive(event.key === 'Home' ? enabled[0] : event.key === 'End' ? enabled[enabled.length - 1] : enabled[(current + (event.key === 'ArrowUp' ? -1 : 1) + enabled.length) % enabled.length]);
|
|
105
|
+
}
|
|
106
|
+
else if (event.key.length === 1 && !event.ctrlKey && !event.metaKey) {
|
|
107
|
+
const index = options.findIndex(option => !option.disabled && String(option.label).toLocaleLowerCase().startsWith(event.key.toLocaleLowerCase()));
|
|
108
|
+
if (index >= 0) {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
if (open)
|
|
111
|
+
setActive(index);
|
|
112
|
+
else
|
|
113
|
+
choose(index);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, children: [_jsx("span", { children: selectedLabel ?? options.find(option => option.value === selected)?.label ?? 'Choose an option' }), _jsx(ChevronDown, { size: 14, "aria-hidden": "true" })] }), (name || required) && _jsx("input", { type: required ? "text" : "hidden", className: "ui-select-value", tabIndex: -1, "aria-hidden": "true", name: name, value: selected, required: required, disabled: disabled, onChange: () => { }, onInvalid: event => { event.preventDefault(); trigger.current?.focus(); show(); } }), open && createPortal(_jsx("div", { ref: list, id: listId, role: "listbox", "aria-label": aria['aria-label'] ?? 'Options', className: "ui-select-menu", style: position, children: options.map((option, index) => _jsxs("div", { id: `${listId}-${index}`, role: "option", "aria-selected": selected === option.value, "aria-disabled": option.disabled || undefined, "data-active": active === index, className: "ui-select-option", onPointerDown: event => event.preventDefault(), onMouseDown: event => event.preventDefault(), onClick: () => choose(index), onPointerMove: () => !option.disabled && setActive(index), children: [_jsx("span", { children: option.label }), selected === option.value && _jsx(Check, { size: 14, "aria-hidden": "true" })] }, option.value)) }), document.body)] });
|
|
117
|
+
}
|
|
118
|
+
// Open dialogs register here so only the topmost one reacts to Escape and Tab.
|
|
119
|
+
const dialogStack = [];
|
|
120
|
+
const DialogRegionContext = createContext(null);
|
|
121
|
+
const regionDialogs = new WeakMap();
|
|
122
|
+
/** Limit dialogs to a host surface while sibling surfaces remain interactive. */
|
|
123
|
+
export function DialogScope({ background, portal, overlayClassName, children }) {
|
|
124
|
+
return (_jsx(DialogRegionContext.Provider, { value: { background, portal, overlayClassName }, children: children }));
|
|
125
|
+
}
|
|
126
|
+
/** Show a dialog with Escape, backdrop dismissal and scope-aware focus. */
|
|
127
|
+
export function Dialog({ title, lang, closeLabel = `Close ${title}`, closeOnBackdrop = true, closeDisabled = false, onClose, className = '', children }) {
|
|
128
|
+
const scope = useContext(DialogRegionContext);
|
|
129
|
+
const background = scope?.background;
|
|
130
|
+
const dialog = useRef(null);
|
|
131
|
+
const closeRef = useRef(() => { });
|
|
132
|
+
closeRef.current = () => { if (!closeDisabled)
|
|
133
|
+
onClose(); };
|
|
134
|
+
useLayoutEffect(() => {
|
|
135
|
+
const frame = dialog.current;
|
|
136
|
+
const surface = background?.current;
|
|
137
|
+
const close = () => closeRef.current();
|
|
138
|
+
dialogStack.push(close);
|
|
139
|
+
const previous = document.activeElement;
|
|
140
|
+
if (surface) {
|
|
141
|
+
regionDialogs.set(surface, (regionDialogs.get(surface) ?? 0) + 1);
|
|
142
|
+
surface.setAttribute('inert', '');
|
|
143
|
+
}
|
|
144
|
+
const fields = 'input:not([type=hidden]):not([hidden]):not([tabindex="-1"]):not(:disabled),select:not(:disabled),textarea:not(:disabled)';
|
|
145
|
+
(frame.querySelector(fields) ?? frame.querySelector('button:not(:disabled)') ?? frame).focus();
|
|
146
|
+
const handler = (event) => {
|
|
147
|
+
if (dialogStack[dialogStack.length - 1] !== close)
|
|
148
|
+
return;
|
|
149
|
+
if (surface && !frame.contains(document.activeElement))
|
|
150
|
+
return;
|
|
151
|
+
if (event.key === 'Escape') {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
close();
|
|
154
|
+
}
|
|
155
|
+
if (event.key === 'Tab' && !surface) {
|
|
156
|
+
const nodes = frame.querySelectorAll(`button:not(:disabled):not([tabindex="-1"]),${fields},a[href]`);
|
|
157
|
+
if (!nodes.length)
|
|
158
|
+
return;
|
|
159
|
+
const first = nodes[0], last = nodes[nodes.length - 1];
|
|
160
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
last.focus();
|
|
163
|
+
}
|
|
164
|
+
else if (!event.shiftKey && document.activeElement === last) {
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
first.focus();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
document.addEventListener('keydown', handler);
|
|
171
|
+
return () => {
|
|
172
|
+
const index = dialogStack.lastIndexOf(close);
|
|
173
|
+
if (index >= 0)
|
|
174
|
+
dialogStack.splice(index, 1);
|
|
175
|
+
document.removeEventListener('keydown', handler);
|
|
176
|
+
if (surface) {
|
|
177
|
+
const count = (regionDialogs.get(surface) ?? 1) - 1;
|
|
178
|
+
if (count)
|
|
179
|
+
regionDialogs.set(surface, count);
|
|
180
|
+
else {
|
|
181
|
+
regionDialogs.delete(surface);
|
|
182
|
+
surface.removeAttribute('inert');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (!surface || frame.contains(document.activeElement) || document.activeElement === document.body)
|
|
186
|
+
previous?.focus();
|
|
187
|
+
};
|
|
188
|
+
}, [background]);
|
|
189
|
+
return createPortal(_jsx("div", { className: scope ? `overlay ${scope.overlayClassName}` : 'overlay', onClick: event => { if (closeOnBackdrop && event.target === event.currentTarget)
|
|
190
|
+
closeRef.current(); }, children: _jsxs("div", { className: `dialog ${className}`.trimEnd(), role: "dialog", lang: lang, "aria-modal": scope ? undefined : true, "aria-label": title, ref: dialog, tabIndex: -1, children: [_jsxs("div", { className: "dialog-header", children: [_jsx("h2", { children: title }), _jsx("button", { type: "button", className: "icon-button", "aria-label": closeLabel, disabled: closeDisabled, onClick: () => closeRef.current(), children: _jsx(X, { size: 18, "aria-hidden": "true" }) })] }), children] }) }), scope?.portal.current ?? document.body);
|
|
191
|
+
}
|
|
192
|
+
/** Draw a project checkbox while preserving labels, keyboard activation and form values. */
|
|
193
|
+
export function Checkbox({ checked, defaultChecked = false, value = 'on', name, disabled, className = '', onChange, onClick, ...props }) {
|
|
194
|
+
const [internal, setInternal] = useState(defaultChecked);
|
|
195
|
+
const selected = checked ?? internal;
|
|
196
|
+
const control = useRef(null);
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
const form = control.current?.closest('form');
|
|
199
|
+
const reset = () => setInternal(defaultChecked);
|
|
200
|
+
form?.addEventListener('reset', reset);
|
|
201
|
+
return () => form?.removeEventListener('reset', reset);
|
|
202
|
+
}, [defaultChecked]);
|
|
203
|
+
return _jsxs(_Fragment, { children: [name && selected && _jsx("input", { type: "hidden", name: name, value: value, disabled: disabled }), _jsx("button", { ...props, ref: control, type: "button", role: "checkbox", "aria-checked": selected, disabled: disabled, className: `ui-checkbox ${className}`, onClick: event => {
|
|
204
|
+
onClick?.(event);
|
|
205
|
+
if (event.defaultPrevented)
|
|
206
|
+
return;
|
|
207
|
+
if (checked === undefined)
|
|
208
|
+
setInternal(!selected);
|
|
209
|
+
onChange?.({ target: { checked: !selected } });
|
|
210
|
+
}, children: selected && _jsx(Check, { size: 13, "aria-hidden": "true" }) })] });
|
|
211
|
+
}
|
|
212
|
+
/** Select one option using project styling, arrow navigation and a single tab stop. */
|
|
213
|
+
export function RadioGroup({ options, value, onChange, disabled = false, name, ...aria }) {
|
|
214
|
+
const controls = useRef([]);
|
|
215
|
+
const enabled = options.map((option, index) => option.disabled ? -1 : index).filter(index => index >= 0);
|
|
216
|
+
const selected = options.findIndex(option => option.value === value && !option.disabled);
|
|
217
|
+
return _jsxs("div", { className: "ui-radio-group", role: "radiogroup", ...aria, "aria-disabled": disabled || undefined, children: [name && value !== undefined && _jsx("input", { type: "hidden", name: name, value: value, disabled: disabled }), options.map((option, index) => _jsxs("button", { ref: element => { controls.current[index] = element; }, className: "ui-radio-option", type: "button", role: "radio", "aria-checked": value === option.value, disabled: disabled || option.disabled, tabIndex: index === (selected >= 0 ? selected : enabled[0]) ? 0 : -1, onClick: () => onChange(option.value), onKeyDown: event => {
|
|
218
|
+
if (!['ArrowRight', 'ArrowDown', 'ArrowLeft', 'ArrowUp', 'Home', 'End'].includes(event.key))
|
|
219
|
+
return;
|
|
220
|
+
event.preventDefault();
|
|
221
|
+
const position = enabled.indexOf(index);
|
|
222
|
+
const next = event.key === 'Home' ? enabled[0] : event.key === 'End' ? enabled[enabled.length - 1]
|
|
223
|
+
: enabled[(position + (['ArrowLeft', 'ArrowUp'].includes(event.key) ? -1 : 1) + enabled.length) % enabled.length];
|
|
224
|
+
if (next === undefined)
|
|
225
|
+
return;
|
|
226
|
+
onChange(options[next].value);
|
|
227
|
+
controls.current[next]?.focus();
|
|
228
|
+
}, children: [_jsx("span", { className: "ui-radio-mark", "aria-hidden": "true" }), _jsxs("span", { children: [option.label, option.description && _jsx("small", { children: option.description })] })] }, option.value))] });
|
|
229
|
+
}
|
|
230
|
+
/** Open the system file picker through a styled, explicitly labeled control. */
|
|
231
|
+
export function FilePicker({ label, files, onChange, accept, multiple, disabled }) {
|
|
232
|
+
const input = useRef(null);
|
|
233
|
+
return _jsxs("div", { className: "ui-file-picker", children: [_jsx("input", { ref: input, hidden: true, type: "file", "aria-label": label, accept: accept, multiple: multiple, disabled: disabled, onChange: event => { onChange(Array.from(event.target.files ?? [])); event.target.value = ''; } }), _jsxs("button", { type: "button", className: "button ui-file-button", disabled: disabled, onClick: () => input.current?.click(), children: [_jsx(FileUp, { size: 16, "aria-hidden": "true" }), "Select ", label] }), _jsx("span", { className: "ui-file-name", title: files.map(file => file.name).join(', '), children: files.length ? files.map(file => file.name).join(', ') : 'No files selected' })] });
|
|
234
|
+
}
|
package/dist/ui/base.css
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family:
|
|
3
|
+
"DM Sans",
|
|
4
|
+
-apple-system,
|
|
5
|
+
BlinkMacSystemFont,
|
|
6
|
+
"PingFang SC",
|
|
7
|
+
"Microsoft YaHei",
|
|
8
|
+
sans-serif;
|
|
9
|
+
color: #25344b;
|
|
10
|
+
background: #f4f6fa;
|
|
11
|
+
font-synthesis: none;
|
|
12
|
+
font-size: 13px;
|
|
13
|
+
line-height: 1.6;
|
|
14
|
+
font-weight: 400;
|
|
15
|
+
}
|
|
16
|
+
* {
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
}
|
|
19
|
+
body {
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
button,
|
|
23
|
+
input,
|
|
24
|
+
textarea,
|
|
25
|
+
select {
|
|
26
|
+
font: inherit;
|
|
27
|
+
}
|
|
28
|
+
button {
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
color: inherit;
|
|
31
|
+
}
|
|
32
|
+
button:disabled {
|
|
33
|
+
cursor: not-allowed;
|
|
34
|
+
opacity: 0.5;
|
|
35
|
+
}
|
|
36
|
+
button,
|
|
37
|
+
a,
|
|
38
|
+
input,
|
|
39
|
+
textarea,
|
|
40
|
+
select {
|
|
41
|
+
outline-offset: 3px;
|
|
42
|
+
}
|
|
43
|
+
button:focus-visible,
|
|
44
|
+
a:focus-visible {
|
|
45
|
+
outline: 3px solid #94b7fa;
|
|
46
|
+
}
|
|
47
|
+
button {
|
|
48
|
+
border: 0;
|
|
49
|
+
background: none;
|
|
50
|
+
}
|
|
51
|
+
button svg {
|
|
52
|
+
flex-shrink: 0;
|
|
53
|
+
}
|
|
54
|
+
input,
|
|
55
|
+
textarea,
|
|
56
|
+
select {
|
|
57
|
+
color: inherit;
|
|
58
|
+
border: 1px solid #e2e7ef;
|
|
59
|
+
border-radius: 7px;
|
|
60
|
+
background: #fff;
|
|
61
|
+
padding: 9px 11px;
|
|
62
|
+
}
|
|
63
|
+
input:focus,
|
|
64
|
+
textarea:focus,
|
|
65
|
+
select:focus {
|
|
66
|
+
outline: 2px solid #b7d0ff;
|
|
67
|
+
border-color: #6b9bea;
|
|
68
|
+
}
|
|
69
|
+
textarea {
|
|
70
|
+
resize: vertical;
|
|
71
|
+
}
|
|
72
|
+
h1,
|
|
73
|
+
h2,
|
|
74
|
+
h3,
|
|
75
|
+
h4,
|
|
76
|
+
p {
|
|
77
|
+
margin: 0;
|
|
78
|
+
}
|
|
79
|
+
h1 {
|
|
80
|
+
font-size: 24px;
|
|
81
|
+
font-weight: 650;
|
|
82
|
+
letter-spacing: -0.7px;
|
|
83
|
+
}
|
|
84
|
+
h2 {
|
|
85
|
+
font-size: 16px;
|
|
86
|
+
font-weight: 650;
|
|
87
|
+
}
|
|
88
|
+
h3 {
|
|
89
|
+
font-size: 14px;
|
|
90
|
+
}
|
|
91
|
+
h4 {
|
|
92
|
+
font-size: 13px;
|
|
93
|
+
}
|
|
94
|
+
small,
|
|
95
|
+
.muted {
|
|
96
|
+
color: #586b83;
|
|
97
|
+
}
|
|
98
|
+
.tag {
|
|
99
|
+
display: inline-flex;
|
|
100
|
+
align-items: center;
|
|
101
|
+
gap: 5px;
|
|
102
|
+
font-size: 11px;
|
|
103
|
+
border-radius: 4px;
|
|
104
|
+
padding: 2px 7px;
|
|
105
|
+
white-space: nowrap;
|
|
106
|
+
background: #f0f3f8;
|
|
107
|
+
color: #586b83;
|
|
108
|
+
}
|
|
109
|
+
.tag.blue {
|
|
110
|
+
color: #4874cb;
|
|
111
|
+
background: #edf3ff;
|
|
112
|
+
}
|
|
113
|
+
.tag.green {
|
|
114
|
+
color: #586b83;
|
|
115
|
+
background: #eaf7f0;
|
|
116
|
+
}
|
|
117
|
+
.tag.orange {
|
|
118
|
+
color: #c88430;
|
|
119
|
+
background: #fff4e4;
|
|
120
|
+
}
|
|
121
|
+
.tag.red {
|
|
122
|
+
color: #d36363;
|
|
123
|
+
background: #fdf0ef;
|
|
124
|
+
}
|
|
125
|
+
.icon-button {
|
|
126
|
+
display: inline-flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
justify-content: center;
|
|
129
|
+
padding: 6px;
|
|
130
|
+
border-radius: 6px;
|
|
131
|
+
position: relative;
|
|
132
|
+
}
|
|
133
|
+
.icon-button:hover {
|
|
134
|
+
background: #edf2f9;
|
|
135
|
+
}
|
|
136
|
+
.button {
|
|
137
|
+
display: inline-flex;
|
|
138
|
+
align-items: center;
|
|
139
|
+
justify-content: center;
|
|
140
|
+
gap: 6px;
|
|
141
|
+
padding: 8px 13px;
|
|
142
|
+
border: 1px solid #dfe6ef;
|
|
143
|
+
border-radius: 7px;
|
|
144
|
+
background: white;
|
|
145
|
+
line-height: 1.5;
|
|
146
|
+
white-space: nowrap;
|
|
147
|
+
font-size: 12px;
|
|
148
|
+
}
|
|
149
|
+
.button:hover {
|
|
150
|
+
background: #f4f7fc;
|
|
151
|
+
}
|
|
152
|
+
.button.primary {
|
|
153
|
+
background: #3169e5;
|
|
154
|
+
border-color: #3169e5;
|
|
155
|
+
color: white;
|
|
156
|
+
box-shadow: 0 3px 7px #3169e513;
|
|
157
|
+
}
|
|
158
|
+
.button.primary:hover {
|
|
159
|
+
background: #2458cc;
|
|
160
|
+
}
|
|
161
|
+
.button.small {
|
|
162
|
+
padding: 5px 9px;
|
|
163
|
+
font-size: 11px;
|
|
164
|
+
}
|
|
165
|
+
.button.danger {
|
|
166
|
+
color: #c55353;
|
|
167
|
+
}
|
|
168
|
+
.error-banner {
|
|
169
|
+
display: flex;
|
|
170
|
+
align-items: center;
|
|
171
|
+
gap: 8px;
|
|
172
|
+
background: #fff1ef;
|
|
173
|
+
border: 1px solid #f4d9d4;
|
|
174
|
+
border-radius: 7px;
|
|
175
|
+
padding: 11px;
|
|
176
|
+
color: #b85b51;
|
|
177
|
+
font-size: 12px;
|
|
178
|
+
margin-bottom: 15px;
|
|
179
|
+
}
|
|
180
|
+
.error-banner button {
|
|
181
|
+
margin-left: auto;
|
|
182
|
+
}
|
|
183
|
+
.overlay {
|
|
184
|
+
position: fixed;
|
|
185
|
+
inset: 0;
|
|
186
|
+
background: #192d4b45;
|
|
187
|
+
z-index: 70;
|
|
188
|
+
display: flex;
|
|
189
|
+
align-items: center;
|
|
190
|
+
justify-content: center;
|
|
191
|
+
padding: 20px;
|
|
192
|
+
backdrop-filter: blur(3px);
|
|
193
|
+
}
|
|
194
|
+
.dialog {
|
|
195
|
+
width: 460px;
|
|
196
|
+
max-width: 100%;
|
|
197
|
+
background: white;
|
|
198
|
+
border-radius: 13px;
|
|
199
|
+
box-shadow: 0 15px 70px #1d375630;
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
max-height: 90vh;
|
|
202
|
+
overflow-y: auto;
|
|
203
|
+
}
|
|
204
|
+
.dialog-header {
|
|
205
|
+
display: flex;
|
|
206
|
+
justify-content: space-between;
|
|
207
|
+
align-items: center;
|
|
208
|
+
padding: 19px 22px;
|
|
209
|
+
border-bottom: 1px solid #edf1f5;
|
|
210
|
+
}
|
|
211
|
+
.dialog-body {
|
|
212
|
+
min-width: 0;
|
|
213
|
+
padding: 20px 22px;
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-direction: column;
|
|
216
|
+
gap: 15px;
|
|
217
|
+
}
|
|
218
|
+
.dialog-body label {
|
|
219
|
+
display: flex;
|
|
220
|
+
flex-direction: column;
|
|
221
|
+
gap: 6px;
|
|
222
|
+
font-size: 12px;
|
|
223
|
+
color: #586b83;
|
|
224
|
+
}
|
|
225
|
+
.dialog-body > .muted {
|
|
226
|
+
overflow-wrap: anywhere;
|
|
227
|
+
}
|
|
228
|
+
.dialog-footer {
|
|
229
|
+
padding: 16px 22px;
|
|
230
|
+
border-top: 1px solid #edf1f5;
|
|
231
|
+
display: flex;
|
|
232
|
+
justify-content: flex-end;
|
|
233
|
+
gap: 9px;
|
|
234
|
+
}
|
|
235
|
+
.loading-spin {
|
|
236
|
+
animation: spin 1.2s linear infinite;
|
|
237
|
+
}
|
|
238
|
+
@keyframes spin {
|
|
239
|
+
to {
|
|
240
|
+
transform: rotate(360deg);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
.tag.green {
|
|
244
|
+
color: #17715d;
|
|
245
|
+
}
|
|
246
|
+
.tag.orange {
|
|
247
|
+
color: #9a5b14;
|
|
248
|
+
}
|
|
249
|
+
.tag.red {
|
|
250
|
+
color: #a84339;
|
|
251
|
+
}
|
|
252
|
+
.tag.blue {
|
|
253
|
+
color: #315da9;
|
|
254
|
+
}
|
|
255
|
+
.tag {
|
|
256
|
+
color: #586b83;
|
|
257
|
+
}
|
|
258
|
+
.dialog-footer {
|
|
259
|
+
flex-wrap: wrap;
|
|
260
|
+
}
|
|
261
|
+
.button.primary { box-shadow: none; }
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.ui-select { display: inline-flex; min-width: 0; max-width: 100%; vertical-align: middle; position: relative; }
|
|
2
|
+
.ui-select-trigger { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 34px; padding: 7px 10px; border: 1px solid #dfe6ef; border-radius: 8px; background: #fff; color: #334155; font: inherit; font-size: 12px; text-align: left; }
|
|
3
|
+
.ui-select-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
4
|
+
.ui-select-trigger > svg { flex: none; color: #64748b; }
|
|
5
|
+
.ui-select-trigger:hover:not(:disabled) { border-color: #95b5f2; background: #f8faff; }
|
|
6
|
+
.ui-select-trigger:focus-visible, .ui-file-button:focus-visible, .ui-checkbox:focus-visible { outline: 2px solid #3169e5; outline-offset: 3px; }
|
|
7
|
+
.ui-select-trigger[aria-expanded="true"] { border-color: #95b5f2; }
|
|
8
|
+
.ui-select-trigger:disabled { opacity: .5; cursor: not-allowed; }
|
|
9
|
+
.ui-select-menu { position: fixed; z-index: 10000; box-sizing: border-box; width: max-content; max-width: calc(100vw - 16px); overflow-y: auto; padding: 4px; border: 1px solid #dfe6ef; border-radius: 9px; background: #fff; box-shadow: 0 8px 24px #19345124; color: #334155; font-size: 12px; }
|
|
10
|
+
.ui-select-option { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 32px; padding: 6px 8px; border-radius: 5px; cursor: pointer; }
|
|
11
|
+
.ui-select-option > span { min-width: 0; overflow-wrap: anywhere; }
|
|
12
|
+
.ui-select-option > svg { flex: none; }
|
|
13
|
+
.ui-select-option[data-active="true"] { background: #eff5ff; }
|
|
14
|
+
.ui-select-option[aria-selected="true"] { color: #245ac7; }
|
|
15
|
+
.ui-select-option[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
|
|
16
|
+
.ui-checkbox { display: inline-grid; place-content: center; flex: 0 0 18px; width: 18px; height: 18px; min-height: 18px; padding: 0; margin: 2px 0; border: 1px solid #a6b6ca; border-radius: 4px; background: #fff; color: #fff; cursor: pointer; vertical-align: middle; }
|
|
17
|
+
.ui-checkbox[aria-checked="true"] { background: #3169e5; border-color: #3169e5; }
|
|
18
|
+
.ui-checkbox:disabled { opacity: .45; cursor: not-allowed; }
|
|
19
|
+
.ui-checkbox:focus-visible, .ui-radio-option:focus-visible { outline: 2px solid #3169e5; outline-offset: 3px; }
|
|
20
|
+
.ui-radio-group { display: flex; flex-direction: column; gap: 8px; }
|
|
21
|
+
.ui-radio-option { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 12px; border: 1px solid #dfe6ef; border-radius: 6px; background: #fff; color: #334155; text-align: left; width: 100%; font: inherit; font-size: 13px; }
|
|
22
|
+
.ui-radio-option:hover:not(:disabled) { border-color: #95b5f2; }
|
|
23
|
+
.ui-radio-option[aria-checked="true"] { border-color: #3169e5; background: #f3f7ff; }
|
|
24
|
+
.ui-radio-option > span:last-child { min-width: 0; overflow-wrap: anywhere; }
|
|
25
|
+
.ui-radio-option small { display: block; margin-top: 4px; color: #657488; font-size: 12px; line-height: 1.5; }
|
|
26
|
+
.ui-radio-mark { display: grid; place-items: center; flex: 0 0 17px; height: 17px; margin-top: 2px; border: 1px solid #a6b6ca; border-radius: 50%; color: #3169e5; }
|
|
27
|
+
.ui-radio-option[aria-checked="true"] .ui-radio-mark { border-color: currentColor; }
|
|
28
|
+
.ui-radio-option[aria-checked="true"] .ui-radio-mark::after { content: ''; width: 0; height: 0; border: 4px solid currentColor; border-radius: 50%; }
|
|
29
|
+
.ui-file-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 12px; border: 1px dashed #bfcee2; border-radius: 10px; background: #f8faff; }
|
|
30
|
+
.ui-file-picker .ui-file-button { flex: none; }
|
|
31
|
+
.ui-file-name { min-width: 0; overflow-wrap: anywhere; color: #64748b; font-size: 12px; }
|
|
32
|
+
.dialog-body label > .ui-select, .task-history > .ui-select { width: 100%; }
|
|
33
|
+
@media (forced-colors: active) { .ui-checkbox[aria-checked="true"] { background: Highlight; color: HighlightText; border-color: Highlight; } .ui-radio-option[aria-checked="true"] { border-color: Highlight; } }
|
|
34
|
+
|
|
35
|
+
input.ui-select-value { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; clip-path: inset(50%); }
|
package/dist/ui/index.js
ADDED