@workbench-kit/react 0.0.1-prototype.0 → 0.0.2-prototype.0.1.2
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/package.json +33 -9
- package/src/index.ts +545 -43
- package/src/jdw/JdwPreview.tsx +38 -0
- package/src/jdw/JsonCodeEditorPane.tsx +274 -0
- package/src/jdw/builtins/renderBuiltinWidgetLeaf.tsx +29 -0
- package/src/jdw/builtins/renderBuiltinWidgetNode.tsx +126 -0
- package/src/jdw/createBuiltinJdwRegistry.ts +111 -0
- package/src/jdw/cssRenderBackend.tsx +134 -0
- package/src/jdw/document.ts +38 -0
- package/src/jdw/fixtures/jdw-fixtures.ts +52 -0
- package/src/jdw/fixtures/jdw-sample-screens.ts +522 -0
- package/src/jdw/index.ts +45 -0
- package/src/jdw/parse.ts +1 -0
- package/src/jdw/renderJdw.tsx +32 -0
- package/src/json-config/JsonConfigWorkbench.tsx +316 -0
- package/src/json-config/index.ts +6 -0
- package/src/json-config/json-config-editor-state.ts +42 -0
- package/src/layout/Panel.tsx +146 -1
- package/src/layout/SideBarViewFrame.tsx +367 -328
- package/src/layout/WorkbenchCanvas.tsx +849 -0
- package/src/layout/WorkbenchFullscreen.tsx +368 -0
- package/src/layout/WorkbenchLayout.tsx +5 -0
- package/src/layout/WorkbenchLayoutBase.tsx +294 -0
- package/src/layout/WorkbenchPropertyPanel.tsx +497 -0
- package/src/layout/WorkbenchSidebarActions.tsx +274 -0
- package/src/layout/WorkbenchTree.tsx +351 -0
- package/src/layout/layoutHelpers.ts +25 -0
- package/src/modal/ConfirmDialog.tsx +61 -53
- package/src/modal/Modal.tsx +295 -35
- package/src/overlay/ContextMenu.tsx +146 -145
- package/src/primitives/AbsoluteBox.tsx +46 -0
- package/src/primitives/Badge.tsx +12 -12
- package/src/primitives/Button.tsx +44 -14
- package/src/primitives/Checkbox.tsx +11 -5
- package/src/primitives/EmptyState.tsx +27 -26
- package/src/primitives/Field.tsx +38 -38
- package/src/primitives/IconButton.tsx +5 -2
- package/src/primitives/List.tsx +111 -0
- package/src/primitives/NumberInput.tsx +38 -0
- package/src/primitives/ScrollArea.tsx +42 -0
- package/src/primitives/Select.tsx +1 -12
- package/src/primitives/StatusBar.tsx +46 -0
- package/src/primitives/TextArea.tsx +36 -0
- package/src/primitives/TextInput.tsx +11 -2
- package/src/primitives/WorkbenchChrome.tsx +424 -0
- package/src/primitives/WorkbenchEditor.tsx +394 -0
- package/src/primitives/index.ts +105 -0
- package/src/primitives/select/Select.tsx +266 -0
- package/src/primitives/select/index.ts +2 -0
- package/src/primitives/select/options.ts +38 -0
- package/src/primitives/select/overlay.ts +63 -0
- package/src/primitives/select/select.app.css +9 -0
- package/src/primitives/select/select.css +140 -0
- package/src/primitives/select/types.ts +18 -0
- package/src/primitives/styles.css +955 -0
- package/src/scrollbars.css +69 -0
- package/src/styles.css +7738 -1762
- package/src/utils/codicon.ts +17 -0
- package/src/widget-asset/WidgetAssetEditor.tsx +140 -0
- package/src/widget-asset/WidgetAssetMetadataForm.tsx +82 -0
- package/src/widget-asset/WidgetAssetModeControls.tsx +42 -0
- package/src/widget-asset/WidgetAssetSourceEditor.tsx +50 -0
- package/src/widget-asset/WidgetAssetWorkbench.tsx +112 -0
- package/src/widget-asset/index.ts +17 -0
- package/src/widget-asset/widget-asset-document.ts +37 -0
- package/src/widget-asset/widget-asset-mode.ts +3 -0
- package/src/widget-studio/builtin-widget-asset-catalog.ts +12 -0
- package/src/widget-studio/create-widget-studio-workspace-editor.tsx +79 -0
- package/src/widget-studio/index.ts +7 -0
- package/src/widget-studio/resolve-widget-studio-asset-catalog.ts +26 -0
- package/src/widget-tree/WidgetAssetPalette.tsx +77 -0
- package/src/widget-tree/WidgetInspectorPanel.tsx +266 -0
- package/src/widget-tree/WidgetSourceEditor.tsx +56 -0
- package/src/widget-tree/WidgetTreeLab.tsx +272 -0
- package/src/widget-tree/WidgetTreeModeControls.tsx +44 -0
- package/src/widget-tree/WidgetTreeSidePanel.tsx +49 -0
- package/src/widget-tree/WidgetTreeView.tsx +97 -0
- package/src/widget-tree/WidgetTreeWorkbench.tsx +111 -0
- package/src/widget-tree/WidgetTreeWorkspaceShell.tsx +154 -0
- package/src/widget-tree/demo-registry.ts +32 -0
- package/src/widget-tree/demo-widget-assets.ts +4 -0
- package/src/widget-tree/index.ts +27 -0
- package/src/widget-tree/widget-tree-document.ts +20 -0
- package/src/widget-tree/widget-tree-layout.ts +31 -0
- package/src/widget-tree/widget-tree-mode.ts +7 -0
- package/src/widget-tree/widget-tree-play-helpers.ts +74 -0
- package/src/workbench/ActivityBar.tsx +52 -52
- package/src/workbench/ArtifactShell.tsx +397 -0
- package/src/workbench/CommandPalette.tsx +819 -0
- package/src/workbench/ConfirmationFlow.tsx +245 -0
- package/src/workbench/MarkdownPreview.tsx +151 -0
- package/src/workbench/ShortcutCommandBridge.tsx +368 -0
- package/src/workbench/SplitView.tsx +136 -136
- package/src/workbench/StatusBar.tsx +178 -123
- package/src/workbench/StructuredArtifactEditor.tsx +205 -0
- package/src/workbench/Timeline.tsx +302 -0
- package/src/workbench/WorkbenchCanvasShell.tsx +941 -0
- package/src/workbench/WorkbenchShell.tsx +74 -70
- package/src/workbench/WorkbenchStandaloneShell.tsx +318 -291
- package/src/workbench/auth/WorkbenchAuthGate.tsx +61 -0
- package/src/workbench/auth/WorkbenchLoginView.tsx +635 -0
- package/src/workbench/auth/index.ts +19 -0
- package/src/workbench/chat/ChatComposer.tsx +165 -148
- package/src/workbench/chat/ChatMessageItem.tsx +10 -1
- package/src/workbench/chat/index.ts +9 -0
- package/src/workbench/chat/slashCommand.ts +28 -0
- package/src/workbench/chat/useChatRuntimeState.ts +76 -0
- package/src/workbench/chat/useSlashCommandSuggest.ts +101 -0
- package/src/workbench/commands.ts +520 -490
- package/src/workbench/index.ts +443 -98
- package/src/workbench/keyboard.ts +53 -0
- package/src/workbench/schema/index.ts +48 -0
- package/src/workbench/schema/workbenchDocument.ts +31 -0
- package/src/workbench/schema/workbenchDocumentActions.ts +6 -0
- package/src/workbench/schema/workbenchDocumentAdapter.ts +9 -0
- package/src/workbench/schema/workbenchDocumentPatch.ts +13 -0
- package/src/workbench/schema/workbenchDocumentRenderer.tsx +702 -0
- package/src/workbench/settings/NavigationPanel.tsx +47 -0
- package/src/workbench/settings/SchemaForm.tsx +420 -0
- package/src/workbench/settings/SectionedPanel.tsx +415 -0
- package/src/workbench/settings/StructuredDataForm.tsx +539 -0
- package/src/workbench/settings/StructuredDataSchemaPanel.tsx +559 -0
- package/src/workbench/settings/StructuredDataSchemaPanelEmbed.tsx +21 -0
- package/src/workbench/settings/StructuredDataSchemaPanelFrame.tsx +76 -0
- package/src/workbench/settings/StructuredDataTableView.tsx +127 -0
- package/src/workbench/settings/WorkbenchPanelRegion.tsx +46 -0
- package/src/workbench/settings/WorkbenchSettingsModal.tsx +21 -12
- package/src/workbench/settings/WorkbenchSettingsNav.tsx +38 -22
- package/src/workbench/settings/index.ts +135 -0
- package/src/workbench/settings/panel-region.css +21 -0
- package/src/workbench/settings/sectionedPanelScrollSpy.ts +143 -0
- package/src/workbench/settings/structured-data-schema-panel.css +330 -0
- package/src/workbench/settings/structured-data-table-view.css +85 -0
- package/src/workbench/settings/structuredDataSchema.ts +886 -0
- package/src/workbench/shell.ts +15 -0
- package/src/workbench/shellState.ts +203 -203
- package/src/workbench/standalone.ts +101 -94
- package/src/workbench/status.ts +129 -0
- package/src/workbench/theme.ts +44 -0
- package/src/workbench/workspace/MultiProviderExplorer.tsx +625 -0
- package/src/workbench/workspace/WorkspaceDraftsContext.tsx +111 -0
- package/src/workbench/workspace/WorkspaceEditor.tsx +47 -12
- package/src/workbench/workspace/WorkspaceEditorPanel.tsx +334 -353
- package/src/workbench/workspace/WorkspaceExplorer.tsx +532 -524
- package/src/workbench/workspace/WorkspaceFileIcon.tsx +32 -2
- package/src/workbench/workspace/WorkspaceSearchPanel.tsx +113 -113
- package/src/workbench/workspace/WorkspaceSearchResults.tsx +47 -47
- package/src/workbench/workspace/index.ts +156 -98
- package/src/workbench/workspace/mimeType.ts +45 -0
- package/src/workbench/workspace/path.ts +10 -10
- package/src/workbench/workspace/search.ts +6 -6
- package/src/workbench/workspace/tree.ts +1 -1
- package/src/workbench/workspace/types.ts +10 -10
- package/src/workbench/workspace/useVirtualWorkspace.ts +111 -98
- package/src/workbench/workspace/workspaceJsonDiagnostics.ts +83 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from 'react';
|
|
2
|
+
import { IconButton } from './IconButton';
|
|
3
|
+
import type { IconButtonProps } from './IconButton';
|
|
4
|
+
import { cxCodicon } from '../utils/codicon';
|
|
5
|
+
import { cx } from '../utils/cx';
|
|
6
|
+
|
|
7
|
+
export interface ListProps extends ComponentPropsWithRef<'div'> {
|
|
8
|
+
ariaLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function List({ ariaLabel, className, role = 'listbox', ...props }: ListProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
aria-label={ariaLabel ?? props['aria-label']}
|
|
15
|
+
className={cx('ui-list', 'ui-workbench-scrollbar', className)}
|
|
16
|
+
role={role}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ListItemProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
23
|
+
actions?: ReactNode;
|
|
24
|
+
description?: ReactNode;
|
|
25
|
+
icon?: ReactNode | string;
|
|
26
|
+
label: ReactNode;
|
|
27
|
+
leading?: ReactNode;
|
|
28
|
+
meta?: ReactNode;
|
|
29
|
+
selected?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function ListItem({
|
|
33
|
+
actions,
|
|
34
|
+
className,
|
|
35
|
+
description,
|
|
36
|
+
icon,
|
|
37
|
+
label,
|
|
38
|
+
leading,
|
|
39
|
+
meta,
|
|
40
|
+
role = 'option',
|
|
41
|
+
selected = false,
|
|
42
|
+
tabIndex = 0,
|
|
43
|
+
...props
|
|
44
|
+
}: ListItemProps) {
|
|
45
|
+
const hasDescription = description !== undefined && description !== null && description !== '';
|
|
46
|
+
const resolvedIcon = typeof icon === 'string' ? <i className={cxCodicon(icon)} /> : icon;
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
aria-selected={selected}
|
|
51
|
+
className={cx('ui-list-item', selected && 'ui-list-item--selected', className)}
|
|
52
|
+
role={role}
|
|
53
|
+
tabIndex={tabIndex}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
{leading ??
|
|
57
|
+
(resolvedIcon ? <span className="ui-list-item__icon">{resolvedIcon}</span> : null)}
|
|
58
|
+
<span className="ui-list-item__content">
|
|
59
|
+
<span className="ui-list-item__label">{label}</span>
|
|
60
|
+
{hasDescription ? <span className="ui-list-item__description">{description}</span> : null}
|
|
61
|
+
</span>
|
|
62
|
+
{meta ? <span className="ui-list-item__meta">{meta}</span> : null}
|
|
63
|
+
{actions ? <span className="ui-list-item__actions">{actions}</span> : null}
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type ListItemActionButtonProps = IconButtonProps;
|
|
69
|
+
|
|
70
|
+
function handleNestedListActionEvent<TEvent extends { stopPropagation(): void }>(
|
|
71
|
+
event: TEvent,
|
|
72
|
+
handler: ((event: TEvent) => void) | undefined,
|
|
73
|
+
) {
|
|
74
|
+
event.stopPropagation();
|
|
75
|
+
handler?.(event);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function ListItemActionButton({
|
|
79
|
+
compact = true,
|
|
80
|
+
onClick,
|
|
81
|
+
onDoubleClick,
|
|
82
|
+
onPointerDown,
|
|
83
|
+
...props
|
|
84
|
+
}: ListItemActionButtonProps) {
|
|
85
|
+
return (
|
|
86
|
+
<IconButton
|
|
87
|
+
compact={compact}
|
|
88
|
+
onClick={(event) => handleNestedListActionEvent(event, onClick)}
|
|
89
|
+
onDoubleClick={(event) => handleNestedListActionEvent(event, onDoubleClick)}
|
|
90
|
+
onPointerDown={(event) => handleNestedListActionEvent(event, onPointerDown)}
|
|
91
|
+
{...props}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ListEmptyStateProps extends ComponentPropsWithRef<'div'> {
|
|
97
|
+
tone?: 'error' | 'normal';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function ListEmptyState({ className, tone = 'normal', ...props }: ListEmptyStateProps) {
|
|
101
|
+
return (
|
|
102
|
+
<div
|
|
103
|
+
className={cx(
|
|
104
|
+
'ui-list-empty-state',
|
|
105
|
+
tone === 'error' && 'ui-list-empty-state--error',
|
|
106
|
+
className,
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
import { TextInput } from './TextInput';
|
|
3
|
+
import type { ControlWidth, TextInputProps } from './TextInput';
|
|
4
|
+
|
|
5
|
+
export interface NumberInputProps extends Omit<
|
|
6
|
+
TextInputProps,
|
|
7
|
+
'defaultValue' | 'onValueChange' | 'type' | 'value'
|
|
8
|
+
> {
|
|
9
|
+
defaultValue?: number | undefined;
|
|
10
|
+
onValueChange?: (value: number, event: ChangeEvent<HTMLInputElement>) => void;
|
|
11
|
+
value?: number | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function NumberInput({
|
|
15
|
+
controlWidth = 'default',
|
|
16
|
+
defaultValue,
|
|
17
|
+
onValueChange,
|
|
18
|
+
value,
|
|
19
|
+
...props
|
|
20
|
+
}: NumberInputProps & { controlWidth?: ControlWidth }) {
|
|
21
|
+
const valueProps =
|
|
22
|
+
value !== undefined ? { value } : defaultValue !== undefined ? { defaultValue } : {};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<TextInput
|
|
26
|
+
controlWidth={controlWidth}
|
|
27
|
+
type="number"
|
|
28
|
+
onValueChange={(next, event) => {
|
|
29
|
+
const parsed = Number.parseFloat(next);
|
|
30
|
+
if (!Number.isNaN(parsed)) {
|
|
31
|
+
onValueChange?.(parsed, event);
|
|
32
|
+
}
|
|
33
|
+
}}
|
|
34
|
+
{...valueProps}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ElementType, ReactNode } from 'react';
|
|
2
|
+
import { cx } from '../utils/cx';
|
|
3
|
+
|
|
4
|
+
export type ScrollAreaGutter = 'auto' | 'stable';
|
|
5
|
+
export type ScrollAreaOrientation = 'both' | 'horizontal' | 'vertical';
|
|
6
|
+
export type ScrollAreaScrollbarVisibility = 'auto' | 'hidden';
|
|
7
|
+
|
|
8
|
+
export interface ScrollAreaProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
|
|
9
|
+
as?: ElementType | undefined;
|
|
10
|
+
children?: ReactNode | undefined;
|
|
11
|
+
gutter?: ScrollAreaGutter | undefined;
|
|
12
|
+
orientation?: ScrollAreaOrientation | undefined;
|
|
13
|
+
scrollbars?: ScrollAreaScrollbarVisibility | undefined;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function ScrollArea({
|
|
17
|
+
as,
|
|
18
|
+
children,
|
|
19
|
+
className,
|
|
20
|
+
gutter = 'stable',
|
|
21
|
+
orientation = 'both',
|
|
22
|
+
scrollbars = 'auto',
|
|
23
|
+
...props
|
|
24
|
+
}: ScrollAreaProps) {
|
|
25
|
+
const Component = (as ?? 'div') as ElementType;
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Component
|
|
29
|
+
className={cx(
|
|
30
|
+
'ui-scroll-area',
|
|
31
|
+
'ui-workbench-scrollbar',
|
|
32
|
+
`ui-scroll-area--${orientation}`,
|
|
33
|
+
gutter === 'stable' && 'ui-scroll-area--stable-gutter',
|
|
34
|
+
scrollbars === 'hidden' && 'ui-workbench-scrollbar--hidden',
|
|
35
|
+
className,
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</Component>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -1,12 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { cx } from '../utils/cx';
|
|
3
|
-
|
|
4
|
-
type ControlWidth = 'default' | 'wide' | 'full';
|
|
5
|
-
|
|
6
|
-
export interface SelectProps extends ComponentPropsWithRef<'select'> {
|
|
7
|
-
controlWidth?: ControlWidth;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function Select({ className, controlWidth = 'default', ...props }: SelectProps) {
|
|
11
|
-
return <select className={cx('ui-select', className)} data-width={controlWidth} {...props} />;
|
|
12
|
-
}
|
|
1
|
+
export { Select, type SelectProps } from './select/index';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { cx } from '../utils/cx';
|
|
3
|
+
|
|
4
|
+
export type StatusBarSeverity = 'error' | 'normal' | 'warning';
|
|
5
|
+
export type StatusBarSectionAlign = 'end' | 'start';
|
|
6
|
+
|
|
7
|
+
export interface StatusBarProps extends ComponentPropsWithRef<'footer'> {
|
|
8
|
+
severity?: StatusBarSeverity;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function StatusBar({ className, severity = 'normal', ...props }: StatusBarProps) {
|
|
12
|
+
return (
|
|
13
|
+
<footer
|
|
14
|
+
className={cx(
|
|
15
|
+
'ui-status-bar',
|
|
16
|
+
severity !== 'normal' && `ui-status-bar--${severity}`,
|
|
17
|
+
className,
|
|
18
|
+
)}
|
|
19
|
+
data-severity={severity}
|
|
20
|
+
{...props}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface StatusBarSectionProps extends ComponentPropsWithRef<'span'> {
|
|
26
|
+
align?: StatusBarSectionAlign;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function StatusBarSection({ align = 'start', className, ...props }: StatusBarSectionProps) {
|
|
30
|
+
return (
|
|
31
|
+
<span
|
|
32
|
+
className={cx(
|
|
33
|
+
'ui-status-bar__section',
|
|
34
|
+
align === 'end' && 'ui-status-bar__section--end',
|
|
35
|
+
className,
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type StatusBarLabelProps = ComponentPropsWithRef<'span'>;
|
|
43
|
+
|
|
44
|
+
export function StatusBarLabel({ className, ...props }: StatusBarLabelProps) {
|
|
45
|
+
return <span className={cx('ui-status-bar__label', className)} {...props} />;
|
|
46
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, CSSProperties } from 'react';
|
|
2
|
+
import { cx } from '../utils/cx';
|
|
3
|
+
|
|
4
|
+
type ControlWidth = 'default' | 'wide' | 'full';
|
|
5
|
+
|
|
6
|
+
export interface TextAreaProps extends ComponentPropsWithRef<'textarea'> {
|
|
7
|
+
controlWidth?: ControlWidth;
|
|
8
|
+
monospace?: boolean;
|
|
9
|
+
resize?: CSSProperties['resize'] | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function TextArea({
|
|
13
|
+
className,
|
|
14
|
+
controlWidth = 'default',
|
|
15
|
+
monospace = false,
|
|
16
|
+
resize,
|
|
17
|
+
style,
|
|
18
|
+
...props
|
|
19
|
+
}: TextAreaProps) {
|
|
20
|
+
const resolvedStyle =
|
|
21
|
+
resize !== undefined
|
|
22
|
+
? {
|
|
23
|
+
resize,
|
|
24
|
+
...style,
|
|
25
|
+
}
|
|
26
|
+
: style;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<textarea
|
|
30
|
+
className={cx('ui-textarea', monospace && 'ui-input--monospace', className)}
|
|
31
|
+
data-width={controlWidth}
|
|
32
|
+
style={resolvedStyle}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import type { ComponentPropsWithRef } from 'react';
|
|
1
|
+
import type { ChangeEvent, ComponentPropsWithRef } from 'react';
|
|
2
2
|
import { cx } from '../utils/cx';
|
|
3
3
|
|
|
4
|
-
type ControlWidth = 'default' | 'wide' | 'full';
|
|
4
|
+
export type ControlWidth = 'default' | 'wide' | 'full';
|
|
5
5
|
|
|
6
6
|
export interface TextInputProps extends ComponentPropsWithRef<'input'> {
|
|
7
7
|
controlWidth?: ControlWidth;
|
|
8
8
|
monospace?: boolean;
|
|
9
|
+
onValueChange?: ((value: string, event: ChangeEvent<HTMLInputElement>) => void) | undefined;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export function TextInput({
|
|
12
13
|
className,
|
|
13
14
|
controlWidth = 'default',
|
|
14
15
|
monospace = false,
|
|
16
|
+
onChange,
|
|
17
|
+
onValueChange,
|
|
15
18
|
...props
|
|
16
19
|
}: TextInputProps) {
|
|
20
|
+
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
21
|
+
onChange?.(event);
|
|
22
|
+
onValueChange?.(event.currentTarget.value, event);
|
|
23
|
+
};
|
|
24
|
+
|
|
17
25
|
return (
|
|
18
26
|
<input
|
|
19
27
|
className={cx('ui-input', monospace && 'ui-input--monospace', className)}
|
|
20
28
|
data-width={controlWidth}
|
|
29
|
+
onChange={handleChange}
|
|
21
30
|
{...props}
|
|
22
31
|
/>
|
|
23
32
|
);
|