datocms-react-ui 2.1.0-alpha.0 → 2.1.0-alpha.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/dist/cjs/HotKey/index.js +105 -0
- package/dist/cjs/HotKey/index.js.map +1 -0
- package/dist/cjs/HotKey/styles.module.css.json +1 -0
- package/dist/cjs/SplitView/SplitViewPane/index.js +14 -0
- package/dist/cjs/SplitView/SplitViewPane/index.js.map +1 -0
- package/dist/cjs/SplitView/SplitViewPane/styles.module.css.json +1 -0
- package/dist/cjs/SplitView/SplitViewSash/index.js +76 -0
- package/dist/cjs/SplitView/SplitViewSash/index.js.map +1 -0
- package/dist/cjs/SplitView/SplitViewSash/styles.module.css.json +1 -0
- package/dist/cjs/SplitView/index.js +206 -0
- package/dist/cjs/SplitView/index.js.map +1 -0
- package/dist/cjs/SplitView/styles.module.css.json +1 -0
- package/dist/cjs/SplitView/types.js +3 -0
- package/dist/cjs/SplitView/types.js.map +1 -0
- package/dist/cjs/Tooltip/Tooltip/index.js +116 -0
- package/dist/cjs/Tooltip/Tooltip/index.js.map +1 -0
- package/dist/cjs/Tooltip/TooltipContent/index.js +147 -0
- package/dist/cjs/Tooltip/TooltipContent/index.js.map +1 -0
- package/dist/cjs/Tooltip/TooltipContent/styles.module.css.json +1 -0
- package/dist/cjs/Tooltip/TooltipDelayGroup/index.js +140 -0
- package/dist/cjs/Tooltip/TooltipDelayGroup/index.js.map +1 -0
- package/dist/cjs/Tooltip/TooltipTrigger/index.js +102 -0
- package/dist/cjs/Tooltip/TooltipTrigger/index.js.map +1 -0
- package/dist/cjs/Tooltip/index.js +12 -0
- package/dist/cjs/Tooltip/index.js.map +1 -0
- package/dist/cjs/Tooltip/utils.js +165 -0
- package/dist/cjs/Tooltip/utils.js.map +1 -0
- package/dist/cjs/VerticalSplit/index.js +337 -0
- package/dist/cjs/VerticalSplit/index.js.map +1 -0
- package/dist/cjs/VerticalSplit/styles.module.css.json +1 -0
- package/dist/cjs/icons.js +19 -1
- package/dist/cjs/icons.js.map +1 -1
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/HotKey/index.d.ts +70 -0
- package/dist/esm/HotKey/index.js +75 -0
- package/dist/esm/HotKey/index.js.map +1 -0
- package/dist/esm/HotKey/styles.module.css.json +1 -0
- package/dist/esm/SplitView/SplitViewPane/index.d.ts +7 -0
- package/dist/esm/SplitView/SplitViewPane/index.js +7 -0
- package/dist/esm/SplitView/SplitViewPane/index.js.map +1 -0
- package/dist/esm/SplitView/SplitViewPane/styles.module.css.json +1 -0
- package/dist/esm/SplitView/SplitViewSash/index.d.ts +17 -0
- package/dist/esm/SplitView/SplitViewSash/index.js +46 -0
- package/dist/esm/SplitView/SplitViewSash/index.js.map +1 -0
- package/dist/esm/SplitView/SplitViewSash/styles.module.css.json +1 -0
- package/dist/esm/SplitView/index.d.ts +16 -0
- package/dist/esm/SplitView/index.js +176 -0
- package/dist/esm/SplitView/index.js.map +1 -0
- package/dist/esm/SplitView/styles.module.css.json +1 -0
- package/dist/esm/SplitView/types.d.ts +8 -0
- package/dist/esm/SplitView/types.js +2 -0
- package/dist/esm/SplitView/types.js.map +1 -0
- package/dist/esm/Tooltip/Tooltip/index.d.ts +74 -0
- package/dist/esm/Tooltip/Tooltip/index.js +89 -0
- package/dist/esm/Tooltip/Tooltip/index.js.map +1 -0
- package/dist/esm/Tooltip/TooltipContent/index.d.ts +68 -0
- package/dist/esm/Tooltip/TooltipContent/index.js +118 -0
- package/dist/esm/Tooltip/TooltipContent/index.js.map +1 -0
- package/dist/esm/Tooltip/TooltipContent/styles.module.css.json +1 -0
- package/dist/esm/Tooltip/TooltipDelayGroup/index.d.ts +118 -0
- package/dist/esm/Tooltip/TooltipDelayGroup/index.js +113 -0
- package/dist/esm/Tooltip/TooltipDelayGroup/index.js.map +1 -0
- package/dist/esm/Tooltip/TooltipTrigger/index.d.ts +45 -0
- package/dist/esm/Tooltip/TooltipTrigger/index.js +76 -0
- package/dist/esm/Tooltip/TooltipTrigger/index.js.map +1 -0
- package/dist/esm/Tooltip/index.d.ts +8 -0
- package/dist/esm/Tooltip/index.js +5 -0
- package/dist/esm/Tooltip/index.js.map +1 -0
- package/dist/esm/Tooltip/utils.d.ts +166 -0
- package/dist/esm/Tooltip/utils.js +135 -0
- package/dist/esm/Tooltip/utils.js.map +1 -0
- package/dist/esm/VerticalSplit/index.d.ts +238 -0
- package/dist/esm/VerticalSplit/index.js +307 -0
- package/dist/esm/VerticalSplit/index.js.map +1 -0
- package/dist/esm/VerticalSplit/styles.module.css.json +1 -0
- package/dist/esm/icons.d.ts +3 -0
- package/dist/esm/icons.js +15 -0
- package/dist/esm/icons.js.map +1 -1
- package/dist/esm/index.d.ts +7 -3
- package/dist/esm/index.js +7 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/types/HotKey/index.d.ts +70 -0
- package/dist/types/SplitView/SplitViewPane/index.d.ts +7 -0
- package/dist/types/SplitView/SplitViewSash/index.d.ts +17 -0
- package/dist/types/SplitView/index.d.ts +16 -0
- package/dist/types/SplitView/types.d.ts +8 -0
- package/dist/types/Tooltip/Tooltip/index.d.ts +74 -0
- package/dist/types/Tooltip/TooltipContent/index.d.ts +68 -0
- package/dist/types/Tooltip/TooltipDelayGroup/index.d.ts +118 -0
- package/dist/types/Tooltip/TooltipTrigger/index.d.ts +45 -0
- package/dist/types/Tooltip/index.d.ts +8 -0
- package/dist/types/Tooltip/utils.d.ts +166 -0
- package/dist/types/VerticalSplit/index.d.ts +238 -0
- package/dist/types/icons.d.ts +3 -0
- package/dist/types/index.d.ts +7 -3
- package/package.json +4 -3
- package/src/HotKey/index.tsx +95 -0
- package/src/HotKey/styles.module.css +22 -0
- package/src/HotKey/styles.module.css.json +1 -0
- package/src/SplitView/SplitViewPane/index.tsx +19 -0
- package/src/SplitView/SplitViewPane/styles.module.css +6 -0
- package/src/SplitView/SplitViewPane/styles.module.css.json +1 -0
- package/src/SplitView/SplitViewSash/index.tsx +99 -0
- package/src/SplitView/SplitViewSash/styles.module.css +68 -0
- package/src/SplitView/SplitViewSash/styles.module.css.json +1 -0
- package/src/SplitView/index.tsx +256 -0
- package/src/SplitView/styles.module.css +22 -0
- package/src/SplitView/styles.module.css.json +1 -0
- package/src/SplitView/types.ts +9 -0
- package/src/Tooltip/Tooltip/index.tsx +85 -0
- package/src/Tooltip/TooltipContent/index.tsx +145 -0
- package/src/Tooltip/TooltipContent/styles.module.css +10 -0
- package/src/Tooltip/TooltipContent/styles.module.css.json +1 -0
- package/src/Tooltip/TooltipDelayGroup/index.tsx +128 -0
- package/src/Tooltip/TooltipTrigger/index.tsx +71 -0
- package/src/Tooltip/index.ts +8 -0
- package/src/Tooltip/utils.ts +176 -0
- package/src/VerticalSplit/index.tsx +401 -0
- package/src/VerticalSplit/styles.module.css +103 -0
- package/src/VerticalSplit/styles.module.css.json +1 -0
- package/src/global.css +31 -25
- package/src/icons.tsx +60 -0
- package/src/index.ts +7 -3
- package/styles.css +1 -1
- package/types.json +6126 -3451
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type VerticalSplitProps = {
|
|
3
|
+
mode?: 'overlay' | 'split';
|
|
4
|
+
minSize?: number | string;
|
|
5
|
+
maxSize?: number | string;
|
|
6
|
+
size?: number | string;
|
|
7
|
+
primaryPane: 'left' | 'right';
|
|
8
|
+
isSecondaryCollapsed?: boolean;
|
|
9
|
+
allowResize?: boolean;
|
|
10
|
+
children: [React.ReactNode, React.ReactNode];
|
|
11
|
+
onDragFinished?: (newSize: number) => void;
|
|
12
|
+
onSecondaryToggle?: (secondaryExpanded: boolean) => void;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @example Resizable, left primary panel
|
|
16
|
+
*
|
|
17
|
+
* ```js
|
|
18
|
+
* <Canvas ctx={ctx}>
|
|
19
|
+
* <div style={{ height: 500, position: 'relative' }}>
|
|
20
|
+
* <VerticalSplit primaryPane="left" size="25%" minSize={220}>
|
|
21
|
+
* <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
|
|
22
|
+
* <Toolbar>
|
|
23
|
+
* <ToolbarStack stackSize="l">
|
|
24
|
+
* <ToolbarTitle>Primary</ToolbarTitle>
|
|
25
|
+
* </ToolbarStack>
|
|
26
|
+
* </Toolbar>
|
|
27
|
+
* <div
|
|
28
|
+
* style={{
|
|
29
|
+
* flex: '1',
|
|
30
|
+
* display: 'flex',
|
|
31
|
+
* justifyContent: 'center',
|
|
32
|
+
* alignItems: 'center',
|
|
33
|
+
* height: '150px',
|
|
34
|
+
* }}
|
|
35
|
+
* >
|
|
36
|
+
* Main content
|
|
37
|
+
* </div>
|
|
38
|
+
* </div>
|
|
39
|
+
* <div style={{ display: 'flex', flexDirection: 'column', height: '100%', borderLeft: '1px solid var(--border-color)' }}>
|
|
40
|
+
* <Toolbar>
|
|
41
|
+
* <ToolbarStack stackSize="l">
|
|
42
|
+
* <ToolbarTitle>Secondary</ToolbarTitle>
|
|
43
|
+
* </ToolbarStack>
|
|
44
|
+
* </Toolbar>
|
|
45
|
+
* <div
|
|
46
|
+
* style={{
|
|
47
|
+
* flex: '1',
|
|
48
|
+
* display: 'flex',
|
|
49
|
+
* justifyContent: 'center',
|
|
50
|
+
* alignItems: 'center',
|
|
51
|
+
* height: '150px',
|
|
52
|
+
* }}
|
|
53
|
+
* >
|
|
54
|
+
* Sidebar
|
|
55
|
+
* </div>
|
|
56
|
+
* </div>
|
|
57
|
+
* </VerticalSplit>
|
|
58
|
+
* </div>
|
|
59
|
+
* </Canvas>;
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @example Resizable, right primary panel
|
|
63
|
+
*
|
|
64
|
+
* ```js
|
|
65
|
+
* <Canvas ctx={ctx}>
|
|
66
|
+
* <div style={{ height: 500, position: 'relative' }}>
|
|
67
|
+
* <VerticalSplit primaryPane="right" size="25%" minSize={220}>
|
|
68
|
+
* <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
|
|
69
|
+
* <Toolbar>
|
|
70
|
+
* <ToolbarStack stackSize="l">
|
|
71
|
+
* <ToolbarTitle>Secondary</ToolbarTitle>
|
|
72
|
+
* </ToolbarStack>
|
|
73
|
+
* </Toolbar>
|
|
74
|
+
* <div
|
|
75
|
+
* style={{
|
|
76
|
+
* flex: '1',
|
|
77
|
+
* display: 'flex',
|
|
78
|
+
* justifyContent: 'center',
|
|
79
|
+
* alignItems: 'center',
|
|
80
|
+
* height: '150px',
|
|
81
|
+
* }}
|
|
82
|
+
* >
|
|
83
|
+
* Sidebar
|
|
84
|
+
* </div>
|
|
85
|
+
* </div>
|
|
86
|
+
* <div style={{ display: 'flex', flexDirection: 'column', height: '100%', borderLeft: '1px solid var(--border-color)' }}>
|
|
87
|
+
* <Toolbar>
|
|
88
|
+
* <ToolbarStack stackSize="l">
|
|
89
|
+
* <ToolbarTitle>Primary</ToolbarTitle>
|
|
90
|
+
* </ToolbarStack>
|
|
91
|
+
* </Toolbar>
|
|
92
|
+
* <div
|
|
93
|
+
* style={{
|
|
94
|
+
* flex: '1',
|
|
95
|
+
* display: 'flex',
|
|
96
|
+
* justifyContent: 'center',
|
|
97
|
+
* alignItems: 'center',
|
|
98
|
+
* height: '150px',
|
|
99
|
+
* }}
|
|
100
|
+
* >
|
|
101
|
+
* Main content
|
|
102
|
+
* </div>
|
|
103
|
+
* </div>
|
|
104
|
+
* </VerticalSplit>
|
|
105
|
+
* </div>
|
|
106
|
+
* </Canvas>;
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example Collapsible
|
|
110
|
+
*
|
|
111
|
+
* ```js
|
|
112
|
+
* <Canvas ctx={ctx}>
|
|
113
|
+
* <div style={{ height: 500, position: 'relative' }}>
|
|
114
|
+
* <StateManager initial={true}>
|
|
115
|
+
* {(isCollapsed, setCollapsed) => (
|
|
116
|
+
* <VerticalSplit
|
|
117
|
+
* primaryPane="left"
|
|
118
|
+
* size="25%"
|
|
119
|
+
* minSize={220}
|
|
120
|
+
* isSecondaryCollapsed={isCollapsed}
|
|
121
|
+
* onSecondaryToggle={setCollapsed}
|
|
122
|
+
* >
|
|
123
|
+
* <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
|
|
124
|
+
* <Toolbar>
|
|
125
|
+
* <ToolbarStack stackSize="l">
|
|
126
|
+
* <ToolbarTitle>Primary</ToolbarTitle>
|
|
127
|
+
* </ToolbarStack>
|
|
128
|
+
* </Toolbar>
|
|
129
|
+
* <div
|
|
130
|
+
* style={{
|
|
131
|
+
* flex: '1',
|
|
132
|
+
* display: 'flex',
|
|
133
|
+
* justifyContent: 'center',
|
|
134
|
+
* alignItems: 'center',
|
|
135
|
+
* height: '150px',
|
|
136
|
+
* }}
|
|
137
|
+
* >
|
|
138
|
+
* Main content
|
|
139
|
+
* </div>
|
|
140
|
+
* </div>
|
|
141
|
+
* <div
|
|
142
|
+
* style={{
|
|
143
|
+
* display: 'flex',
|
|
144
|
+
* flexDirection: 'column',
|
|
145
|
+
* height: '100%',
|
|
146
|
+
* borderLeft: '1px solid var(--border-color)',
|
|
147
|
+
* }}
|
|
148
|
+
* >
|
|
149
|
+
* <Toolbar>
|
|
150
|
+
* <ToolbarStack stackSize="l">
|
|
151
|
+
* <ToolbarTitle>Secondary</ToolbarTitle>
|
|
152
|
+
* </ToolbarStack>
|
|
153
|
+
* </Toolbar>
|
|
154
|
+
* <div
|
|
155
|
+
* style={{
|
|
156
|
+
* flex: '1',
|
|
157
|
+
* display: 'flex',
|
|
158
|
+
* justifyContent: 'center',
|
|
159
|
+
* alignItems: 'center',
|
|
160
|
+
* height: '150px',
|
|
161
|
+
* }}
|
|
162
|
+
* >
|
|
163
|
+
* Sidebar
|
|
164
|
+
* </div>
|
|
165
|
+
* </div>
|
|
166
|
+
* </VerticalSplit>
|
|
167
|
+
* )}
|
|
168
|
+
* </StateManager>
|
|
169
|
+
* </div>
|
|
170
|
+
* </Canvas>;
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @example Overlay mode
|
|
174
|
+
*
|
|
175
|
+
* ```js
|
|
176
|
+
* <Canvas ctx={ctx}>
|
|
177
|
+
* <div style={{ height: 500, position: 'relative' }}>
|
|
178
|
+
* <StateManager initial={true}>
|
|
179
|
+
* {(isCollapsed, setCollapsed) => (
|
|
180
|
+
* <VerticalSplit
|
|
181
|
+
* mode="overlay"
|
|
182
|
+
* primaryPane="left"
|
|
183
|
+
* size="25%"
|
|
184
|
+
* minSize={220}
|
|
185
|
+
* isSecondaryCollapsed={isCollapsed}
|
|
186
|
+
* onSecondaryToggle={setCollapsed}
|
|
187
|
+
* >
|
|
188
|
+
* <div style={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
|
|
189
|
+
* <Toolbar>
|
|
190
|
+
* <ToolbarStack stackSize="l">
|
|
191
|
+
* <ToolbarTitle>Primary</ToolbarTitle>
|
|
192
|
+
* </ToolbarStack>
|
|
193
|
+
* </Toolbar>
|
|
194
|
+
* <div
|
|
195
|
+
* style={{
|
|
196
|
+
* flex: '1',
|
|
197
|
+
* display: 'flex',
|
|
198
|
+
* justifyContent: 'center',
|
|
199
|
+
* alignItems: 'center',
|
|
200
|
+
* height: '150px',
|
|
201
|
+
* }}
|
|
202
|
+
* >
|
|
203
|
+
* Main content
|
|
204
|
+
* </div>
|
|
205
|
+
* </div>
|
|
206
|
+
* <div
|
|
207
|
+
* style={{
|
|
208
|
+
* display: 'flex',
|
|
209
|
+
* flexDirection: 'column',
|
|
210
|
+
* height: '100%',
|
|
211
|
+
* borderLeft: '1px solid var(--border-color)',
|
|
212
|
+
* }}
|
|
213
|
+
* >
|
|
214
|
+
* <Toolbar>
|
|
215
|
+
* <ToolbarStack stackSize="l">
|
|
216
|
+
* <ToolbarTitle>Secondary</ToolbarTitle>
|
|
217
|
+
* </ToolbarStack>
|
|
218
|
+
* </Toolbar>
|
|
219
|
+
* <div
|
|
220
|
+
* style={{
|
|
221
|
+
* flex: '1',
|
|
222
|
+
* display: 'flex',
|
|
223
|
+
* justifyContent: 'center',
|
|
224
|
+
* alignItems: 'center',
|
|
225
|
+
* height: '150px',
|
|
226
|
+
* }}
|
|
227
|
+
* >
|
|
228
|
+
* Sidebar
|
|
229
|
+
* </div>
|
|
230
|
+
* </div>
|
|
231
|
+
* </VerticalSplit>
|
|
232
|
+
* )}
|
|
233
|
+
* </StateManager>
|
|
234
|
+
* </div>
|
|
235
|
+
* </Canvas>;
|
|
236
|
+
* ```
|
|
237
|
+
*/
|
|
238
|
+
export declare function VerticalSplit({ mode, minSize, maxSize, size, primaryPane, children, allowResize, onDragFinished, onSecondaryToggle, isSecondaryCollapsed, }: VerticalSplitProps): JSX.Element;
|
package/dist/types/icons.d.ts
CHANGED
|
@@ -10,3 +10,6 @@ export declare function SidebarLeftArrowIcon({ width, height, style, className,
|
|
|
10
10
|
export declare function SidebarRightArrowIcon({ width, height, style, className, }: IconProps): JSX.Element;
|
|
11
11
|
export declare function CaretDownIcon({ width, height, style, className, }: IconProps): JSX.Element;
|
|
12
12
|
export declare function CaretUpIcon({ width, height, style, className, }: IconProps): JSX.Element;
|
|
13
|
+
export declare function ChevronsLeftIcon({ width, height, style, className, }: IconProps): JSX.Element;
|
|
14
|
+
export declare function ChevronsRightIcon({ width, height, style, className, }: IconProps): JSX.Element;
|
|
15
|
+
export declare function SidebarFlipIcon({ width, height, style, className, }: IconProps): JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,21 +6,25 @@ export * from './Dropdown';
|
|
|
6
6
|
export * from './FieldError';
|
|
7
7
|
export * from './FieldGroup';
|
|
8
8
|
export * from './FieldHint';
|
|
9
|
-
export * from './Form';
|
|
10
9
|
export * from './FieldWrapper';
|
|
10
|
+
export * from './Form';
|
|
11
11
|
export * from './FormLabel';
|
|
12
|
+
export * from './HotKey';
|
|
12
13
|
export * from './icons';
|
|
13
14
|
export * from './Section';
|
|
14
15
|
export * from './SelectField';
|
|
15
16
|
export * from './SelectInput';
|
|
16
17
|
export * from './SidebarPanel';
|
|
17
18
|
export * from './Spinner';
|
|
19
|
+
export * from './SplitView';
|
|
18
20
|
export * from './SwitchField';
|
|
19
21
|
export * from './SwitchInput';
|
|
20
|
-
export * from './TextField';
|
|
21
|
-
export * from './TextInput';
|
|
22
22
|
export * from './TextareaField';
|
|
23
23
|
export * from './TextareaInput';
|
|
24
|
+
export * from './TextField';
|
|
25
|
+
export * from './TextInput';
|
|
24
26
|
export * from './Toolbar';
|
|
27
|
+
export * from './Tooltip';
|
|
25
28
|
export * from './useClickOutside';
|
|
26
29
|
export * from './useMediaQuery';
|
|
30
|
+
export * from './VerticalSplit';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "datocms-react-ui",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.2",
|
|
4
4
|
"description": "React components to use inside DatoCMS plugins",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datocms",
|
|
@@ -40,8 +40,9 @@
|
|
|
40
40
|
"url": "https://github.com/datocms/plugins-sdk/issues"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@floating-ui/react": "^0.27.16",
|
|
43
44
|
"classnames": "^2.3.1",
|
|
44
|
-
"datocms-plugin-sdk": "^2.1.0-alpha.
|
|
45
|
+
"datocms-plugin-sdk": "^2.1.0-alpha.2",
|
|
45
46
|
"react-intersection-observer": "^8.31.0",
|
|
46
47
|
"react-select": "^5.2.1",
|
|
47
48
|
"scroll-into-view-if-needed": "^2.2.20"
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"postcss-nested": "^5.0.6",
|
|
58
59
|
"typedoc": "^0.26.7"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "774ac774ad3125a0ee778b691a660d651cd67f29"
|
|
61
62
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styles from './styles.module.css.json';
|
|
3
|
+
|
|
4
|
+
const isMac = navigator.platform.indexOf('Mac') > -1;
|
|
5
|
+
const modifierKey = isMac ? '⌘' : 'Ctrl';
|
|
6
|
+
|
|
7
|
+
export type HotKeyProps = {
|
|
8
|
+
/**
|
|
9
|
+
* Keyboard shortcut string. Use "mod" for platform-specific modifier (Cmd on Mac, Ctrl elsewhere).
|
|
10
|
+
* Separate keys with "+". Examples: "mod+s", "mod+shift+p", "alt+enter"
|
|
11
|
+
*/
|
|
12
|
+
hotkey: string;
|
|
13
|
+
/** Optional label to display before the key combination */
|
|
14
|
+
label?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* HotKey component displays keyboard shortcuts in a platform-aware format.
|
|
19
|
+
*
|
|
20
|
+
* The component automatically detects the user's platform and renders appropriate
|
|
21
|
+
* modifier key symbols (⌘ for Mac, Ctrl for Windows/Linux).
|
|
22
|
+
*
|
|
23
|
+
* @example Basic usage
|
|
24
|
+
*
|
|
25
|
+
* Display a simple keyboard shortcut without a label:
|
|
26
|
+
*
|
|
27
|
+
* ```js
|
|
28
|
+
* <Canvas ctx={ctx}>
|
|
29
|
+
* <HotKey hotkey="mod+s" />
|
|
30
|
+
* </Canvas>;
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example With label
|
|
34
|
+
*
|
|
35
|
+
* Include a descriptive label to explain what the keyboard shortcut does:
|
|
36
|
+
*
|
|
37
|
+
* ```js
|
|
38
|
+
* <Canvas ctx={ctx}>
|
|
39
|
+
* <HotKey hotkey="mod+s" label="Save" />
|
|
40
|
+
* </Canvas>;
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @example Multiple hotkeys
|
|
44
|
+
*
|
|
45
|
+
* Display a list of keyboard shortcuts with labels for documenting available commands:
|
|
46
|
+
*
|
|
47
|
+
* ```js
|
|
48
|
+
* <Canvas ctx={ctx}>
|
|
49
|
+
* <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-m)' }}>
|
|
50
|
+
* <HotKey hotkey="mod+c" label="Copy" />
|
|
51
|
+
* <HotKey hotkey="mod+v" label="Paste" />
|
|
52
|
+
* <HotKey hotkey="mod+shift+z" label="Redo" />
|
|
53
|
+
* <HotKey hotkey="alt+enter" label="Submit" />
|
|
54
|
+
* </div>
|
|
55
|
+
* </Canvas>;
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @example Platform-specific rendering
|
|
59
|
+
*
|
|
60
|
+
* The component automatically adapts modifier keys based on the user's platform:
|
|
61
|
+
* - `mod` renders as `⌘` on Mac and `Ctrl` on Windows/Linux
|
|
62
|
+
* - `alt` renders as `⌥` on Mac and `Alt` on Windows/Linux
|
|
63
|
+
*
|
|
64
|
+
* This ensures the correct symbols are displayed for the user's operating system:
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* <Canvas ctx={ctx}>
|
|
68
|
+
* <div style={{ display: 'flex', flexDirection: 'column', gap: 'var(--spacing-m)' }}>
|
|
69
|
+
* <HotKey hotkey="mod+k" label="Open command palette" />
|
|
70
|
+
* <HotKey hotkey="alt+enter" label="Submit form" />
|
|
71
|
+
* <HotKey hotkey="mod+alt+f" label="Find and replace" />
|
|
72
|
+
* </div>
|
|
73
|
+
* </Canvas>;
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export function HotKey({ hotkey, label }: HotKeyProps) {
|
|
77
|
+
const keys = hotkey
|
|
78
|
+
.replace('mod', modifierKey)
|
|
79
|
+
.replace('alt', isMac ? '⌥' : 'Alt')
|
|
80
|
+
.split(/\+/)
|
|
81
|
+
.map((e) => e.charAt(0).toUpperCase() + e.slice(1));
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className={styles.hotKey}>
|
|
85
|
+
{label && <span className={styles.label}>{label}</span>}
|
|
86
|
+
<div className={styles.keys}>
|
|
87
|
+
{keys.map((key) => (
|
|
88
|
+
<span key={key} className={styles.hotKeyKey}>
|
|
89
|
+
{key}
|
|
90
|
+
</span>
|
|
91
|
+
))}
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.hotKey {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 15px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.label {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.keys {
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 4px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.hotKeyKey {
|
|
19
|
+
padding: 5px 8px;
|
|
20
|
+
background: var(--light-color);
|
|
21
|
+
border-radius: 3px;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"hotKey":"_hotKey_1eko8_1","label":"_label_1eko8_7","keys":"_keys_1eko8_12","hotKeyKey":"_hotKeyKey_1eko8_18"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import s from './styles.module.css.json';
|
|
3
|
+
|
|
4
|
+
export type SplitViewPaneProps = {
|
|
5
|
+
maxSize?: number | string;
|
|
6
|
+
minSize?: number | string;
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export function SplitViewPane({
|
|
11
|
+
style,
|
|
12
|
+
children,
|
|
13
|
+
}: PropsWithChildren<SplitViewPaneProps>) {
|
|
14
|
+
return (
|
|
15
|
+
<div className={s.SplitViewPane} style={style}>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"SplitViewPane":"_SplitViewPane_1cl1f_1"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import React, { ReactNode, useState } from 'react';
|
|
3
|
+
import s from './styles.module.css.json';
|
|
4
|
+
|
|
5
|
+
export type SashAction = {
|
|
6
|
+
icon: ReactNode;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type SplitViewSashProps = {
|
|
11
|
+
className?: string;
|
|
12
|
+
style: React.CSSProperties;
|
|
13
|
+
split: 'vertical' | 'horizontal';
|
|
14
|
+
allowResize?: boolean;
|
|
15
|
+
action?: SashAction;
|
|
16
|
+
onMouseDown: (x: number, y: number) => void;
|
|
17
|
+
onMouseMove: (x: number, y: number) => void;
|
|
18
|
+
onMouseUp: () => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function SplitViewSash({
|
|
22
|
+
onMouseDown,
|
|
23
|
+
onMouseMove,
|
|
24
|
+
onMouseUp,
|
|
25
|
+
style,
|
|
26
|
+
split,
|
|
27
|
+
allowResize,
|
|
28
|
+
action,
|
|
29
|
+
}: SplitViewSashProps) {
|
|
30
|
+
const [dragging, setDrag] = useState(false);
|
|
31
|
+
|
|
32
|
+
function handleMouseMove(e: MouseEvent) {
|
|
33
|
+
onMouseMove(e.pageX, e.pageY);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function handleMouseUp() {
|
|
37
|
+
setDrag(false);
|
|
38
|
+
onMouseUp();
|
|
39
|
+
window.removeEventListener('mousemove', handleMouseMove);
|
|
40
|
+
window.removeEventListener('mouseup', handleMouseUp);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function handleTouchMove(e: TouchEvent) {
|
|
44
|
+
onMouseMove(e.touches[0].pageX, e.touches[0].pageY);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function handleTouchEnd() {
|
|
48
|
+
setDrag(false);
|
|
49
|
+
onMouseUp();
|
|
50
|
+
window.removeEventListener('touchmove', handleTouchMove);
|
|
51
|
+
window.removeEventListener('touchend', handleTouchEnd);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const actionEl = action?.icon && (
|
|
55
|
+
<div
|
|
56
|
+
className={s.SplitViewSash__content}
|
|
57
|
+
onMouseDown={(e) => {
|
|
58
|
+
e.stopPropagation();
|
|
59
|
+
}}
|
|
60
|
+
onClick={() => {
|
|
61
|
+
action.onClick();
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
<div className={s.SplitViewSash__content__button}>{action?.icon}</div>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
role="Resizer"
|
|
71
|
+
className={classNames(
|
|
72
|
+
s.SplitViewSash,
|
|
73
|
+
split === 'vertical'
|
|
74
|
+
? s['SplitViewSash--vertical']
|
|
75
|
+
: s['SplitViewSash--horizontal'],
|
|
76
|
+
!allowResize && s['SplitViewSash--no-resize'],
|
|
77
|
+
dragging && s['SplitViewSash--dragging'],
|
|
78
|
+
)}
|
|
79
|
+
onMouseDown={(e) => {
|
|
80
|
+
setDrag(true);
|
|
81
|
+
onMouseDown(e.pageX, e.pageY);
|
|
82
|
+
|
|
83
|
+
window.addEventListener('mousemove', handleMouseMove);
|
|
84
|
+
window.addEventListener('mouseup', handleMouseUp);
|
|
85
|
+
}}
|
|
86
|
+
onTouchStart={(e) => {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
setDrag(true);
|
|
89
|
+
onMouseDown(e.touches[0].pageX, e.touches[0].pageY);
|
|
90
|
+
|
|
91
|
+
window.addEventListener('touchmove', handleTouchMove);
|
|
92
|
+
window.addEventListener('touchend', handleTouchEnd);
|
|
93
|
+
}}
|
|
94
|
+
style={style}
|
|
95
|
+
>
|
|
96
|
+
{actionEl}
|
|
97
|
+
</div>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.SplitViewSash {
|
|
2
|
+
height: 100%;
|
|
3
|
+
position: absolute;
|
|
4
|
+
top: 0;
|
|
5
|
+
transition: background-color 0.2s 0.15s;
|
|
6
|
+
background-color: rgba(var(--light-color-components), 0);
|
|
7
|
+
width: 100%;
|
|
8
|
+
z-index: 2;
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.SplitViewSash:hover,
|
|
15
|
+
.SplitViewSash--dragging {
|
|
16
|
+
background-color: var(--light-color);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.SplitViewSash:hover:has(.SplitViewSash__content:hover),
|
|
20
|
+
.SplitViewSash--dragging:has(.SplitViewSash__content:hover) {
|
|
21
|
+
background-color: transparent;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.SplitViewSash--no-resize {
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.SplitViewSash--vertical {
|
|
29
|
+
cursor: col-resize;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.SplitViewSash--horizontal {
|
|
33
|
+
cursor: row-resize;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.SplitViewSash__content {
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 50%;
|
|
39
|
+
left: 50%;
|
|
40
|
+
transform: translate(-50%, -50%);
|
|
41
|
+
padding: 15px 0;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
pointer-events: auto;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.SplitViewSash__content__button {
|
|
47
|
+
width: 20px;
|
|
48
|
+
height: 20px;
|
|
49
|
+
border-radius: 6px;
|
|
50
|
+
border: 1px solid var(--border-color);
|
|
51
|
+
background: white;
|
|
52
|
+
z-index: 2;
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
justify-content: center;
|
|
56
|
+
font-size: 10px;
|
|
57
|
+
color: var(--light-body-color);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.SplitViewSash__content__button svg {
|
|
61
|
+
display: block;
|
|
62
|
+
fill: currentColor;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.SplitViewSash__content:hover .SplitViewSash__content__button {
|
|
66
|
+
background: var(--light-bg-color);
|
|
67
|
+
color: var(--base-body-color);
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"SplitViewSash":"_SplitViewSash_tds51_1","SplitViewSash--dragging":"_SplitViewSash--dragging_tds51_15","SplitViewSash__content":"_SplitViewSash__content_tds51_19","SplitViewSash--no-resize":"_SplitViewSash--no-resize_tds51_24","SplitViewSash--vertical":"_SplitViewSash--vertical_tds51_28","SplitViewSash--horizontal":"_SplitViewSash--horizontal_tds51_32","SplitViewSash__content__button":"_SplitViewSash__content__button_tds51_46"}
|