@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.
Files changed (155) hide show
  1. package/package.json +33 -9
  2. package/src/index.ts +545 -43
  3. package/src/jdw/JdwPreview.tsx +38 -0
  4. package/src/jdw/JsonCodeEditorPane.tsx +274 -0
  5. package/src/jdw/builtins/renderBuiltinWidgetLeaf.tsx +29 -0
  6. package/src/jdw/builtins/renderBuiltinWidgetNode.tsx +126 -0
  7. package/src/jdw/createBuiltinJdwRegistry.ts +111 -0
  8. package/src/jdw/cssRenderBackend.tsx +134 -0
  9. package/src/jdw/document.ts +38 -0
  10. package/src/jdw/fixtures/jdw-fixtures.ts +52 -0
  11. package/src/jdw/fixtures/jdw-sample-screens.ts +522 -0
  12. package/src/jdw/index.ts +45 -0
  13. package/src/jdw/parse.ts +1 -0
  14. package/src/jdw/renderJdw.tsx +32 -0
  15. package/src/json-config/JsonConfigWorkbench.tsx +316 -0
  16. package/src/json-config/index.ts +6 -0
  17. package/src/json-config/json-config-editor-state.ts +42 -0
  18. package/src/layout/Panel.tsx +146 -1
  19. package/src/layout/SideBarViewFrame.tsx +367 -328
  20. package/src/layout/WorkbenchCanvas.tsx +849 -0
  21. package/src/layout/WorkbenchFullscreen.tsx +368 -0
  22. package/src/layout/WorkbenchLayout.tsx +5 -0
  23. package/src/layout/WorkbenchLayoutBase.tsx +294 -0
  24. package/src/layout/WorkbenchPropertyPanel.tsx +497 -0
  25. package/src/layout/WorkbenchSidebarActions.tsx +274 -0
  26. package/src/layout/WorkbenchTree.tsx +351 -0
  27. package/src/layout/layoutHelpers.ts +25 -0
  28. package/src/modal/ConfirmDialog.tsx +61 -53
  29. package/src/modal/Modal.tsx +295 -35
  30. package/src/overlay/ContextMenu.tsx +146 -145
  31. package/src/primitives/AbsoluteBox.tsx +46 -0
  32. package/src/primitives/Badge.tsx +12 -12
  33. package/src/primitives/Button.tsx +44 -14
  34. package/src/primitives/Checkbox.tsx +11 -5
  35. package/src/primitives/EmptyState.tsx +27 -26
  36. package/src/primitives/Field.tsx +38 -38
  37. package/src/primitives/IconButton.tsx +5 -2
  38. package/src/primitives/List.tsx +111 -0
  39. package/src/primitives/NumberInput.tsx +38 -0
  40. package/src/primitives/ScrollArea.tsx +42 -0
  41. package/src/primitives/Select.tsx +1 -12
  42. package/src/primitives/StatusBar.tsx +46 -0
  43. package/src/primitives/TextArea.tsx +36 -0
  44. package/src/primitives/TextInput.tsx +11 -2
  45. package/src/primitives/WorkbenchChrome.tsx +424 -0
  46. package/src/primitives/WorkbenchEditor.tsx +394 -0
  47. package/src/primitives/index.ts +105 -0
  48. package/src/primitives/select/Select.tsx +266 -0
  49. package/src/primitives/select/index.ts +2 -0
  50. package/src/primitives/select/options.ts +38 -0
  51. package/src/primitives/select/overlay.ts +63 -0
  52. package/src/primitives/select/select.app.css +9 -0
  53. package/src/primitives/select/select.css +140 -0
  54. package/src/primitives/select/types.ts +18 -0
  55. package/src/primitives/styles.css +955 -0
  56. package/src/scrollbars.css +69 -0
  57. package/src/styles.css +7738 -1762
  58. package/src/utils/codicon.ts +17 -0
  59. package/src/widget-asset/WidgetAssetEditor.tsx +140 -0
  60. package/src/widget-asset/WidgetAssetMetadataForm.tsx +82 -0
  61. package/src/widget-asset/WidgetAssetModeControls.tsx +42 -0
  62. package/src/widget-asset/WidgetAssetSourceEditor.tsx +50 -0
  63. package/src/widget-asset/WidgetAssetWorkbench.tsx +112 -0
  64. package/src/widget-asset/index.ts +17 -0
  65. package/src/widget-asset/widget-asset-document.ts +37 -0
  66. package/src/widget-asset/widget-asset-mode.ts +3 -0
  67. package/src/widget-studio/builtin-widget-asset-catalog.ts +12 -0
  68. package/src/widget-studio/create-widget-studio-workspace-editor.tsx +79 -0
  69. package/src/widget-studio/index.ts +7 -0
  70. package/src/widget-studio/resolve-widget-studio-asset-catalog.ts +26 -0
  71. package/src/widget-tree/WidgetAssetPalette.tsx +77 -0
  72. package/src/widget-tree/WidgetInspectorPanel.tsx +266 -0
  73. package/src/widget-tree/WidgetSourceEditor.tsx +56 -0
  74. package/src/widget-tree/WidgetTreeLab.tsx +272 -0
  75. package/src/widget-tree/WidgetTreeModeControls.tsx +44 -0
  76. package/src/widget-tree/WidgetTreeSidePanel.tsx +49 -0
  77. package/src/widget-tree/WidgetTreeView.tsx +97 -0
  78. package/src/widget-tree/WidgetTreeWorkbench.tsx +111 -0
  79. package/src/widget-tree/WidgetTreeWorkspaceShell.tsx +154 -0
  80. package/src/widget-tree/demo-registry.ts +32 -0
  81. package/src/widget-tree/demo-widget-assets.ts +4 -0
  82. package/src/widget-tree/index.ts +27 -0
  83. package/src/widget-tree/widget-tree-document.ts +20 -0
  84. package/src/widget-tree/widget-tree-layout.ts +31 -0
  85. package/src/widget-tree/widget-tree-mode.ts +7 -0
  86. package/src/widget-tree/widget-tree-play-helpers.ts +74 -0
  87. package/src/workbench/ActivityBar.tsx +52 -52
  88. package/src/workbench/ArtifactShell.tsx +397 -0
  89. package/src/workbench/CommandPalette.tsx +819 -0
  90. package/src/workbench/ConfirmationFlow.tsx +245 -0
  91. package/src/workbench/MarkdownPreview.tsx +151 -0
  92. package/src/workbench/ShortcutCommandBridge.tsx +368 -0
  93. package/src/workbench/SplitView.tsx +136 -136
  94. package/src/workbench/StatusBar.tsx +178 -123
  95. package/src/workbench/StructuredArtifactEditor.tsx +205 -0
  96. package/src/workbench/Timeline.tsx +302 -0
  97. package/src/workbench/WorkbenchCanvasShell.tsx +941 -0
  98. package/src/workbench/WorkbenchShell.tsx +74 -70
  99. package/src/workbench/WorkbenchStandaloneShell.tsx +318 -291
  100. package/src/workbench/auth/WorkbenchAuthGate.tsx +61 -0
  101. package/src/workbench/auth/WorkbenchLoginView.tsx +635 -0
  102. package/src/workbench/auth/index.ts +19 -0
  103. package/src/workbench/chat/ChatComposer.tsx +165 -148
  104. package/src/workbench/chat/ChatMessageItem.tsx +10 -1
  105. package/src/workbench/chat/index.ts +9 -0
  106. package/src/workbench/chat/slashCommand.ts +28 -0
  107. package/src/workbench/chat/useChatRuntimeState.ts +76 -0
  108. package/src/workbench/chat/useSlashCommandSuggest.ts +101 -0
  109. package/src/workbench/commands.ts +520 -490
  110. package/src/workbench/index.ts +443 -98
  111. package/src/workbench/keyboard.ts +53 -0
  112. package/src/workbench/schema/index.ts +48 -0
  113. package/src/workbench/schema/workbenchDocument.ts +31 -0
  114. package/src/workbench/schema/workbenchDocumentActions.ts +6 -0
  115. package/src/workbench/schema/workbenchDocumentAdapter.ts +9 -0
  116. package/src/workbench/schema/workbenchDocumentPatch.ts +13 -0
  117. package/src/workbench/schema/workbenchDocumentRenderer.tsx +702 -0
  118. package/src/workbench/settings/NavigationPanel.tsx +47 -0
  119. package/src/workbench/settings/SchemaForm.tsx +420 -0
  120. package/src/workbench/settings/SectionedPanel.tsx +415 -0
  121. package/src/workbench/settings/StructuredDataForm.tsx +539 -0
  122. package/src/workbench/settings/StructuredDataSchemaPanel.tsx +559 -0
  123. package/src/workbench/settings/StructuredDataSchemaPanelEmbed.tsx +21 -0
  124. package/src/workbench/settings/StructuredDataSchemaPanelFrame.tsx +76 -0
  125. package/src/workbench/settings/StructuredDataTableView.tsx +127 -0
  126. package/src/workbench/settings/WorkbenchPanelRegion.tsx +46 -0
  127. package/src/workbench/settings/WorkbenchSettingsModal.tsx +21 -12
  128. package/src/workbench/settings/WorkbenchSettingsNav.tsx +38 -22
  129. package/src/workbench/settings/index.ts +135 -0
  130. package/src/workbench/settings/panel-region.css +21 -0
  131. package/src/workbench/settings/sectionedPanelScrollSpy.ts +143 -0
  132. package/src/workbench/settings/structured-data-schema-panel.css +330 -0
  133. package/src/workbench/settings/structured-data-table-view.css +85 -0
  134. package/src/workbench/settings/structuredDataSchema.ts +886 -0
  135. package/src/workbench/shell.ts +15 -0
  136. package/src/workbench/shellState.ts +203 -203
  137. package/src/workbench/standalone.ts +101 -94
  138. package/src/workbench/status.ts +129 -0
  139. package/src/workbench/theme.ts +44 -0
  140. package/src/workbench/workspace/MultiProviderExplorer.tsx +625 -0
  141. package/src/workbench/workspace/WorkspaceDraftsContext.tsx +111 -0
  142. package/src/workbench/workspace/WorkspaceEditor.tsx +47 -12
  143. package/src/workbench/workspace/WorkspaceEditorPanel.tsx +334 -353
  144. package/src/workbench/workspace/WorkspaceExplorer.tsx +532 -524
  145. package/src/workbench/workspace/WorkspaceFileIcon.tsx +32 -2
  146. package/src/workbench/workspace/WorkspaceSearchPanel.tsx +113 -113
  147. package/src/workbench/workspace/WorkspaceSearchResults.tsx +47 -47
  148. package/src/workbench/workspace/index.ts +156 -98
  149. package/src/workbench/workspace/mimeType.ts +45 -0
  150. package/src/workbench/workspace/path.ts +10 -10
  151. package/src/workbench/workspace/search.ts +6 -6
  152. package/src/workbench/workspace/tree.ts +1 -1
  153. package/src/workbench/workspace/types.ts +10 -10
  154. package/src/workbench/workspace/useVirtualWorkspace.ts +111 -98
  155. 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
- import type { ComponentPropsWithRef } from 'react';
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
  );