@vev/silke 1.0.12 → 1.0.13
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/CHANGELOG.md +7 -0
- package/dist/chunk-KMZFUBRE.js +22 -0
- package/dist/{chunk-4MB64AQL.js.map → chunk-KMZFUBRE.js.map} +3 -3
- package/dist/index.js +8 -8
- package/dist/index.js.map +4 -4
- package/dist/{silke-code-editor-HZRG3D6C.js → silke-code-editor-UX2ML2WG.js} +2 -2
- package/dist/styles.css +463 -179
- package/package.json +2 -2
- package/src/_variables.scss +0 -1
- package/src/components/silke-box/silke-box.scss +17 -0
- package/src/components/silke-box/silke-box.tsx +6 -2
- package/src/components/silke-button/silke-button.tsx +2 -0
- package/src/components/silke-checkbox/silke-checkbox.tsx +1 -1
- package/src/components/silke-form-schema/fields/event-field.tsx +1 -1
- package/src/components/silke-form-schema/fields/icon-field.tsx +1 -1
- package/src/components/silke-form-schema/fields/image-field.tsx +1 -3
- package/src/components/silke-form-schema/fields/link-field.tsx +3 -1
- package/src/components/silke-form-schema/fields/number-field.tsx +2 -4
- package/src/components/silke-form-schema/fields/select-field.tsx +49 -31
- package/src/components/silke-form-schema/fields/toggle-field.tsx +1 -1
- package/src/components/silke-form-schema/fields/upload-field.tsx +3 -2
- package/src/components/silke-form-schema/silke-schema-fields.tsx +1 -2
- package/src/components/silke-loader/silke-loader.tsx +6 -3
- package/src/components/silke-navigation-link/silke-navigation-link.scss +7 -0
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +6 -1
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +1 -1
- package/src/components/silke-radio-button/silke-radio-button.scss +1 -1
- package/src/components/silke-tag/silke-tag.scss +4 -0
- package/src/components/silke-tag/silke-tag.tsx +16 -3
- package/src/components/silke-text/index.ts +1 -0
- package/src/components/silke-tooltip/index.ts +1 -0
- package/src/components/silke-tooltip/silke-icon-tooltip.tsx +2 -13
- package/src/components/silke-tooltip/silke-shortcuts.tsx +43 -0
- package/src/components/silke-tooltip/silke-tooltip.scss +11 -5
- package/src/hooks/use-drop-zone.ts +5 -1
- package/src/icons.tsx +16 -1
- package/dist/chunk-4MB64AQL.js +0 -22
- /package/dist/{chunk-4MB64AQL.js.LEGAL.txt → chunk-KMZFUBRE.js.LEGAL.txt} +0 -0
- /package/dist/{silke-code-editor-HZRG3D6C.js.map → silke-code-editor-UX2ML2WG.js.map} +0 -0
package/src/_variables.scss
CHANGED
|
@@ -31,6 +31,11 @@ button, input{
|
|
|
31
31
|
overflow-x: hidden;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
.showScroll {
|
|
35
|
+
overflow-y: scroll;
|
|
36
|
+
overflow-x: hidden;
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
button.box {
|
|
35
40
|
cursor: pointer;
|
|
36
41
|
line-height: 24px;
|
|
@@ -54,6 +59,18 @@ button.box {
|
|
|
54
59
|
padding-bottom: 100%;
|
|
55
60
|
}
|
|
56
61
|
|
|
62
|
+
.cursor-pointer {
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.cursor-text {
|
|
67
|
+
cursor: text;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.cursor-grab {
|
|
71
|
+
cursor: grab;
|
|
72
|
+
}
|
|
73
|
+
|
|
57
74
|
.box:not(.column) {
|
|
58
75
|
flex-direction: row;
|
|
59
76
|
&.h-start {
|
|
@@ -66,6 +66,8 @@ type BaseProps = {
|
|
|
66
66
|
|
|
67
67
|
overflow?: 'hidden' | 'scroll-y';
|
|
68
68
|
|
|
69
|
+
cursor?: 'pointer' | 'grab' | 'text';
|
|
70
|
+
|
|
69
71
|
/** Text color on hover */
|
|
70
72
|
colorHover?: SilkeColor;
|
|
71
73
|
aspectRatio?: '16:9' | '4:3' | '1:1';
|
|
@@ -80,7 +82,7 @@ type BaseProps = {
|
|
|
80
82
|
hAlign?: BoxAlign;
|
|
81
83
|
/** Debug adds an out line to all box and child boxes */
|
|
82
84
|
debug?: boolean;
|
|
83
|
-
scroll?: boolean;
|
|
85
|
+
scroll?: boolean | 'show';
|
|
84
86
|
rel?: string;
|
|
85
87
|
};
|
|
86
88
|
|
|
@@ -205,6 +207,7 @@ function BoxComp(
|
|
|
205
207
|
rounded,
|
|
206
208
|
shadow,
|
|
207
209
|
overflow,
|
|
210
|
+
cursor,
|
|
208
211
|
...rest
|
|
209
212
|
}: BoxProps,
|
|
210
213
|
ref: any,
|
|
@@ -219,6 +222,7 @@ function BoxComp(
|
|
|
219
222
|
if (wrap) cl.push(styles.wrap);
|
|
220
223
|
if (shadow) cl.push(styles['shadow-' + shadow]);
|
|
221
224
|
if (rounded) cl.push(styles[`rounded-${rounded === true ? 'small' : rounded}`]);
|
|
225
|
+
if (cursor) cl.push(styles['cursor-' + cursor]);
|
|
222
226
|
if (aspectRatio) {
|
|
223
227
|
rest.style = { ...rest.style, aspectRatio: aspectRatio.replace(':', '/') };
|
|
224
228
|
}
|
|
@@ -251,7 +255,7 @@ function BoxComp(
|
|
|
251
255
|
if (hAlign) cl.push(styles['h-' + (hAlign === true ? 'center' : hAlign)]);
|
|
252
256
|
if (vAlign) cl.push(styles['v-' + (vAlign === true ? 'center' : vAlign)]);
|
|
253
257
|
|
|
254
|
-
if (scroll) cl.push(styles.scroll);
|
|
258
|
+
if (scroll) cl.push(scroll === 'show' ? styles.showScroll : styles.scroll);
|
|
255
259
|
if (debug) cl.push(styles.debug);
|
|
256
260
|
|
|
257
261
|
return React.createElement(
|
|
@@ -48,7 +48,7 @@ export function SilkeCheckbox(props: SilkeCheckboxProps) {
|
|
|
48
48
|
onChange={(e) => onChange && onChange(e.currentTarget.checked || false)}
|
|
49
49
|
/>
|
|
50
50
|
<SilkeBox className={styles.check} align="center">
|
|
51
|
-
<SilkeIcon className={styles.checkmark} icon="check" />
|
|
51
|
+
<SilkeIcon className={styles.checkmark} icon="check" style={{ fontSize: 12 }} />
|
|
52
52
|
</SilkeBox>
|
|
53
53
|
{hasLabel && (
|
|
54
54
|
<label htmlFor={checkboxId} className={styles.label}>
|
|
@@ -33,7 +33,7 @@ const EventField = ({ value = [], onChange, context }: SchemaFieldProps<EventFie
|
|
|
33
33
|
const name = events.find((e) => e.content.key === key)?.content?.name;
|
|
34
34
|
return (
|
|
35
35
|
<SilkeBox column key={key} gap="s">
|
|
36
|
-
<SilkeTextSmall>{name}</SilkeTextSmall>
|
|
36
|
+
<SilkeTextSmall weight="strong">{name}</SilkeTextSmall>
|
|
37
37
|
<SilkeBox column gap="s">
|
|
38
38
|
{grouped[key].map((event, i) => {
|
|
39
39
|
const curr = `${event.content.key}:${event.name}`;
|
|
@@ -26,7 +26,7 @@ const IconField = ({ value, schema, onChange }: SchemaFieldProps<IconFieldType>)
|
|
|
26
26
|
|
|
27
27
|
return (
|
|
28
28
|
<SilkeBox flex vPad="s" align="center" style={{ justifyContent: 'space-between' }}>
|
|
29
|
-
<SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
|
|
29
|
+
<SilkeTextSmall weight="strong">{getTitle(schema)}</SilkeTextSmall>
|
|
30
30
|
{schema.description && (
|
|
31
31
|
<SilkeTextSmall color="neutral-80">{schema.description}</SilkeTextSmall>
|
|
32
32
|
)}
|
|
@@ -26,9 +26,7 @@ const ImageField = ({ value, schema, onChange }: SchemaFieldProps<ImageFieldType
|
|
|
26
26
|
return (
|
|
27
27
|
<SilkeBox column flex vPad="s">
|
|
28
28
|
<SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
|
|
29
|
-
{schema.description &&
|
|
30
|
-
<SilkeTextSmall color="neutral-80">{schema.description}</SilkeTextSmall>
|
|
31
|
-
)}
|
|
29
|
+
{schema.description && <SilkeTextSmall weight="strong">{schema.description}</SilkeTextSmall>}
|
|
32
30
|
<SilkeBox column>
|
|
33
31
|
<SilkeImage
|
|
34
32
|
aspectRatio="16:9"
|
|
@@ -93,7 +93,9 @@ const SelectField = (props: SchemaFieldProps<LinkFieldType>) => {
|
|
|
93
93
|
}}
|
|
94
94
|
/>
|
|
95
95
|
<SilkeBox>
|
|
96
|
-
<SilkeTextSmall flex>
|
|
96
|
+
<SilkeTextSmall weight="strong" flex>
|
|
97
|
+
Open in new tab
|
|
98
|
+
</SilkeTextSmall>
|
|
97
99
|
<SilkeToggle
|
|
98
100
|
small
|
|
99
101
|
value={target}
|
|
@@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react';
|
|
|
3
3
|
import { SilkeCssNumberField } from '../../silke-css-number-field';
|
|
4
4
|
import { SilkeBox } from '../../silke-box';
|
|
5
5
|
import { SilkeSlider } from '../../silke-slider';
|
|
6
|
-
import { SilkeText } from '../../silke-text';
|
|
6
|
+
import { SilkeText, SilkeTextSmall } from '../../silke-text';
|
|
7
7
|
import { SilkeTextField } from '../../silke-text-field';
|
|
8
8
|
import { getTitle } from './string-field';
|
|
9
9
|
|
|
@@ -41,9 +41,7 @@ const NumberField = (props: SchemaFieldProps<NumberFieldType>) => {
|
|
|
41
41
|
const sliderValue = value ?? 0;
|
|
42
42
|
return (
|
|
43
43
|
<SilkeBox column flex>
|
|
44
|
-
<
|
|
45
|
-
{title || name}
|
|
46
|
-
</SilkeText>
|
|
44
|
+
<SilkeTextSmall weight="strong">{title || name}</SilkeTextSmall>
|
|
47
45
|
{description && <SilkeText color="neutral-80">{description}</SilkeText>}
|
|
48
46
|
<SilkeBox vPad="s">
|
|
49
47
|
<SilkeSlider
|
|
@@ -57,47 +57,65 @@ const SelectField = (props: SchemaFieldProps<SelectFieldType>) => {
|
|
|
57
57
|
|
|
58
58
|
if (display === 'dropdown') {
|
|
59
59
|
return (
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
60
|
+
<SilkeBox gap="xs" style={{ alignItems: 'center' }}>
|
|
61
|
+
<SilkeTextSmall weight="strong" style={{ width: '80px' }}>
|
|
62
|
+
{getTitle(schema)}
|
|
63
|
+
</SilkeTextSmall>
|
|
64
|
+
<SilkeBox style={{ width: '140px' }}>
|
|
65
|
+
<SilkeSelectField
|
|
66
|
+
value={props.value}
|
|
67
|
+
multiple={multiselect}
|
|
68
|
+
name={name}
|
|
69
|
+
items={items}
|
|
70
|
+
inline
|
|
71
|
+
label=""
|
|
72
|
+
onChange={onChange}
|
|
73
|
+
size="xs"
|
|
74
|
+
renderItem={(item) => {
|
|
75
|
+
return (
|
|
76
|
+
<SilkeText
|
|
77
|
+
style={{ paddingLeft: '4px' }}
|
|
78
|
+
size="small"
|
|
79
|
+
title={item.item.label}
|
|
80
|
+
overflow
|
|
81
|
+
>
|
|
82
|
+
{item.item.label}
|
|
83
|
+
</SilkeText>
|
|
84
|
+
);
|
|
85
|
+
}}
|
|
86
|
+
/>
|
|
87
|
+
</SilkeBox>
|
|
88
|
+
</SilkeBox>
|
|
78
89
|
);
|
|
79
90
|
}
|
|
80
91
|
if (display === 'autocomplete') {
|
|
81
92
|
return (
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
<SilkeBox gap="xs" style={{ alignItems: 'center' }}>
|
|
94
|
+
<SilkeTextSmall weight="strong" style={{ width: '80px' }}>
|
|
95
|
+
{getTitle(schema)}
|
|
96
|
+
</SilkeTextSmall>
|
|
97
|
+
<SilkeBox style={{ width: '140px' }}>
|
|
98
|
+
<SilkeAutocompleteField
|
|
99
|
+
value={props.value}
|
|
100
|
+
multiple={multiselect}
|
|
101
|
+
name={name}
|
|
102
|
+
label=""
|
|
103
|
+
items={items}
|
|
104
|
+
onChange={onChange}
|
|
105
|
+
size="xs"
|
|
106
|
+
inline
|
|
107
|
+
inlineLabelWidth={80}
|
|
108
|
+
/>
|
|
109
|
+
</SilkeBox>
|
|
110
|
+
</SilkeBox>
|
|
93
111
|
);
|
|
94
112
|
}
|
|
95
113
|
return (
|
|
96
114
|
<SilkeBox gap="xs">
|
|
97
|
-
<SilkeTextSmall
|
|
115
|
+
<SilkeTextSmall weight="strong" style={{ width: '80px' }}>
|
|
98
116
|
{getTitle(schema)}
|
|
99
117
|
</SilkeTextSmall>
|
|
100
|
-
<SilkeBox column>
|
|
118
|
+
<SilkeBox column style={{ width: '100px' }}>
|
|
101
119
|
{items?.map((item, i) => (
|
|
102
120
|
<SilkeRadioButton key={i} {...item} name={name} size="small" />
|
|
103
121
|
))}
|
|
@@ -9,7 +9,7 @@ const Toggle = (props: SchemaFieldProps<BooleanField>) => {
|
|
|
9
9
|
<SilkeBox flex>
|
|
10
10
|
<SilkeBox align="start" style={{ width: '80px' }}>
|
|
11
11
|
<SilkeBox vAlign="center" flex>
|
|
12
|
-
<SilkeTextSmall
|
|
12
|
+
<SilkeTextSmall weight="strong">
|
|
13
13
|
{props.schema.title || props.schema.description || props.schema.name}
|
|
14
14
|
</SilkeTextSmall>
|
|
15
15
|
</SilkeBox>
|
|
@@ -7,10 +7,11 @@ import { startCase } from 'lodash';
|
|
|
7
7
|
|
|
8
8
|
const UploadField = (props: SchemaFieldProps<UploadFieldType>) => {
|
|
9
9
|
const { schema, onChange } = props;
|
|
10
|
+
const maxSize = schema.maxSize || 4096;
|
|
10
11
|
|
|
11
12
|
return (
|
|
12
13
|
<SilkeBox column flex vPad="s">
|
|
13
|
-
<SilkeTextSmall>{schema.title || startCase(schema.name)}</SilkeTextSmall>
|
|
14
|
+
<SilkeTextSmall weight="strong">{schema.title || startCase(schema.name)}</SilkeTextSmall>
|
|
14
15
|
{schema.description && (
|
|
15
16
|
<SilkeTextSmall color="neutral-80">{schema.description}</SilkeTextSmall>
|
|
16
17
|
)}
|
|
@@ -21,7 +22,7 @@ const UploadField = (props: SchemaFieldProps<UploadFieldType>) => {
|
|
|
21
22
|
multiple={false}
|
|
22
23
|
dropzoneStyle={{ width: '100%' }}
|
|
23
24
|
fileItemStyle={{ width: '100%' }}
|
|
24
|
-
maxSize={
|
|
25
|
+
maxSize={Math.min(76800, maxSize)} // Set absolute max size to 75 MB
|
|
25
26
|
name={props.schema.name}
|
|
26
27
|
value={props.value}
|
|
27
28
|
useFileModel
|
|
@@ -14,8 +14,7 @@ type SilkeSchemaFieldsProps<T> = {
|
|
|
14
14
|
export function SilkeSchemaFields<T>(props: SilkeSchemaFieldsProps<T>) {
|
|
15
15
|
const { schema = [], row, ...rest } = props;
|
|
16
16
|
return (
|
|
17
|
-
<SilkeBox flex column={!row} gap="m" style={{ width: '100%' }}>
|
|
18
|
-
{schema[0]?.type !== 'array' && <div />}
|
|
17
|
+
<SilkeBox flex column={!row} gap="m" vPad="m" style={{ width: '100%' }}>
|
|
19
18
|
{schema.map((field, index) => {
|
|
20
19
|
const comp = SilkeSchemaField({ field, ...rest });
|
|
21
20
|
return comp ? (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BoxDivProps, BoxSize, SilkeBox } from '../silke-box';
|
|
3
3
|
import './silke-loader.scss';
|
|
4
|
+
import { SilkeTextSmall } from '../silke-text';
|
|
4
5
|
|
|
5
6
|
interface SilkeLoaderProps extends BoxDivProps {
|
|
6
7
|
message?: string;
|
|
@@ -22,9 +23,11 @@ export function SilkeLoader({
|
|
|
22
23
|
}: SilkeLoaderProps) {
|
|
23
24
|
return (
|
|
24
25
|
<SilkeBox column align="center" {...rest}>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
<SilkeBox size={size}>
|
|
27
|
+
<LoaderSVG stop={stop} style={style} />
|
|
28
|
+
</SilkeBox>
|
|
29
|
+
{message && <SilkeTextSmall>{message}</SilkeTextSmall>}
|
|
30
|
+
{randomGenerator && <SilkeTextSmall>{randomGenerator()}</SilkeTextSmall>}
|
|
28
31
|
</SilkeBox>
|
|
29
32
|
);
|
|
30
33
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IEmojiIcon } from '@vev/utils';
|
|
2
2
|
import { isString } from 'lodash';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
|
+
import { SilkeColor } from '../../';
|
|
4
5
|
import { BoxButtonProps, BoxLinkProps, SilkeBox } from '../silke-box';
|
|
5
6
|
import ButtonContext from '../silke-button/context';
|
|
6
7
|
import { SilkeIcon, SilkeIcons } from '../silke-icon';
|
|
@@ -13,6 +14,7 @@ type SilkeNavigationLinkProps = {
|
|
|
13
14
|
icon?: IEmojiIcon | SilkeIcons | React.ReactElement;
|
|
14
15
|
label: ReactNode;
|
|
15
16
|
linkClassName?: string;
|
|
17
|
+
color?: SilkeColor;
|
|
16
18
|
/**
|
|
17
19
|
* Buttons/icons shown only on hover
|
|
18
20
|
*/
|
|
@@ -31,15 +33,18 @@ export function SilkeNavigationLink({
|
|
|
31
33
|
children,
|
|
32
34
|
link,
|
|
33
35
|
rightButtons,
|
|
36
|
+
color,
|
|
34
37
|
align,
|
|
35
38
|
...rest
|
|
36
39
|
}: SilkeNavigationLinkProps) {
|
|
37
40
|
const cl = [styles.main];
|
|
41
|
+
const linkClass = [styles.link];
|
|
38
42
|
|
|
39
43
|
if (className) cl.push(className);
|
|
40
44
|
if (active) cl.push(styles.active);
|
|
41
45
|
if (rightButtons) cl.push(styles.hasRightButtons);
|
|
42
|
-
|
|
46
|
+
if (color) linkClass.push(styles[color]);
|
|
47
|
+
if (linkClassName) linkClass.push(linkClassName);
|
|
43
48
|
|
|
44
49
|
return (
|
|
45
50
|
<SilkeBox className={cl.join(' ')} gap="xxs" tag="div">
|
|
@@ -6,7 +6,7 @@ import { ButtonContext, SilkeButton, SilkeButtonProps } from '../silke-button';
|
|
|
6
6
|
import { SilkePopover, SilkePopoverProps } from '../silke-popover';
|
|
7
7
|
import styles from './silke-overflow-menu.scss';
|
|
8
8
|
|
|
9
|
-
type SilkeOverflowMenuProps = {
|
|
9
|
+
export type SilkeOverflowMenuProps = {
|
|
10
10
|
children?: React.ReactNode;
|
|
11
11
|
open?: boolean;
|
|
12
12
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { BoxProps, SilkeBox } from '../silke-box';
|
|
2
|
+
import { BoxProps, BoxSpace, SilkeBox } from '../silke-box';
|
|
3
3
|
import { SilkeText } from '../silke-text';
|
|
4
4
|
import styles from './silke-tag.scss';
|
|
5
5
|
import { SilkeIcon, SilkeIcons } from '../silke-icon';
|
|
@@ -14,6 +14,7 @@ export type SilkeTagProps = {
|
|
|
14
14
|
size?: SilkeTagSize;
|
|
15
15
|
outline?: boolean;
|
|
16
16
|
icon?: SilkeIcons;
|
|
17
|
+
innerGap?: BoxSpace;
|
|
17
18
|
/**
|
|
18
19
|
* Will add a remove button to tag
|
|
19
20
|
*/
|
|
@@ -21,18 +22,30 @@ export type SilkeTagProps = {
|
|
|
21
22
|
} & BoxProps;
|
|
22
23
|
|
|
23
24
|
function SilkeTagComp(
|
|
24
|
-
{
|
|
25
|
+
{
|
|
26
|
+
className,
|
|
27
|
+
disabled,
|
|
28
|
+
kind,
|
|
29
|
+
label,
|
|
30
|
+
outline,
|
|
31
|
+
onRemove,
|
|
32
|
+
size,
|
|
33
|
+
icon,
|
|
34
|
+
innerGap = 'xs',
|
|
35
|
+
...rest
|
|
36
|
+
}: SilkeTagProps,
|
|
25
37
|
ref: any,
|
|
26
38
|
) {
|
|
27
39
|
const cl = [styles.tag, disabled ? styles.disabled : styles[kind || 'gray']];
|
|
28
40
|
if (className) cl.push(className);
|
|
29
41
|
if (outline) cl.push(styles.outline);
|
|
30
42
|
if (size) cl.push(styles[size]);
|
|
43
|
+
if (rest?.onClick) cl.push(styles.selectable);
|
|
31
44
|
|
|
32
45
|
return (
|
|
33
46
|
<SilkeBox {...rest} className={cl.join(' ')} hPad="xs" vAlign="center" ref={ref}>
|
|
34
47
|
<SilkeText overflow flex className={styles.label}>
|
|
35
|
-
<SilkeBox gap=
|
|
48
|
+
<SilkeBox gap={innerGap} align="center">
|
|
36
49
|
{icon && <SilkeIcon icon={icon} />}
|
|
37
50
|
<span>{label}</span>
|
|
38
51
|
</SilkeBox>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { KeyboardEventCode } from '@vev/utils';
|
|
2
2
|
import { isString } from 'lodash';
|
|
3
3
|
import React, { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { SilkeBox } from '../silke-box';
|
|
5
5
|
import { SilkeIcon, SilkeIcons } from '../silke-icon';
|
|
6
|
+
import { SilkeShortcuts } from './silke-shortcuts';
|
|
6
7
|
import { SilkeTooltip, SilkeTooltipProps } from './silke-tooltip';
|
|
7
|
-
import styles from './silke-tooltip.scss';
|
|
8
8
|
|
|
9
9
|
type SilkeIconTooltipProps = {
|
|
10
10
|
icon?: SilkeIcons;
|
|
@@ -106,14 +106,3 @@ export function SilkeIconTooltip({
|
|
|
106
106
|
</>
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
export const SilkeShortcuts = ({ shortcuts }: { shortcuts?: KeyboardEventCode[] }) =>
|
|
111
|
-
shortcuts ? (
|
|
112
|
-
<SilkeBox gap="s" style={{ display: 'inline' }}>
|
|
113
|
-
{shortcuts.map((s, i) => (
|
|
114
|
-
<span key={i} className={styles.shortcut}>
|
|
115
|
-
{Keyboard.getFormatted(s)}
|
|
116
|
-
</span>
|
|
117
|
-
))}
|
|
118
|
-
</SilkeBox>
|
|
119
|
-
) : null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Keyboard, KeyboardEventCode } from '@vev/utils';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { SilkeIconDefinitions } from '../../icons';
|
|
4
|
+
import { BoxDivProps, SilkeBox } from '../silke-box';
|
|
5
|
+
import { SilkeIcon } from '../silke-icon';
|
|
6
|
+
import styles from './silke-tooltip.scss';
|
|
7
|
+
|
|
8
|
+
type IconSymbol = keyof typeof SilkeIconDefinitions;
|
|
9
|
+
|
|
10
|
+
function isShortcutIcon(key: string) {
|
|
11
|
+
return SilkeIconDefinitions[key as IconSymbol] !== undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const SilkeShortcuts = ({
|
|
15
|
+
shortcuts,
|
|
16
|
+
...rest
|
|
17
|
+
}: { shortcuts?: KeyboardEventCode[] } & BoxDivProps) =>
|
|
18
|
+
shortcuts ? (
|
|
19
|
+
<SilkeBox gap="s">
|
|
20
|
+
{shortcuts.map((s, i) => (
|
|
21
|
+
<SilkeBox key={i}>
|
|
22
|
+
<SilkeBox
|
|
23
|
+
className={styles.shortcut}
|
|
24
|
+
rounded="tiny"
|
|
25
|
+
bg="neutral-0"
|
|
26
|
+
pad="xs"
|
|
27
|
+
vAlign="center"
|
|
28
|
+
flex
|
|
29
|
+
gap="xs"
|
|
30
|
+
{...rest}
|
|
31
|
+
>
|
|
32
|
+
{Keyboard.getFormatted(s).map((keys) =>
|
|
33
|
+
keys
|
|
34
|
+
.split(' ')
|
|
35
|
+
.map((f) =>
|
|
36
|
+
isShortcutIcon(f) ? <SilkeIcon icon={f as IconSymbol} /> : <span>{f}</span>,
|
|
37
|
+
),
|
|
38
|
+
)}
|
|
39
|
+
</SilkeBox>
|
|
40
|
+
</SilkeBox>
|
|
41
|
+
))}
|
|
42
|
+
</SilkeBox>
|
|
43
|
+
) : null;
|
|
@@ -57,12 +57,18 @@ $border-color: rgba(
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.shortcut {
|
|
60
|
-
|
|
61
|
-
color: var(--color-neutral-100);
|
|
60
|
+
font-size: 12px;
|
|
62
61
|
border: 1px solid var(--color-neutral-20);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
|
|
63
|
+
span {
|
|
64
|
+
line-height: 14px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
i {
|
|
68
|
+
line-height: 14px;
|
|
69
|
+
font-weight: 300;
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
|
|
@@ -18,16 +18,19 @@ export function useDropZone(
|
|
|
18
18
|
onDrop: (e: DragEvent) => void,
|
|
19
19
|
onEnter?: (e: DragEvent) => void,
|
|
20
20
|
onLeave?: (e: DragEvent) => void,
|
|
21
|
+
onOver?: (e: DragEvent) => void,
|
|
21
22
|
) {
|
|
22
23
|
const dropRef = useCallbackRef(onDrop);
|
|
23
24
|
const enterRef = useCallbackRef(onEnter);
|
|
24
25
|
const leaveRef = useCallbackRef(onLeave);
|
|
26
|
+
const overRef = useCallbackRef(onOver);
|
|
25
27
|
useEffect(() => {
|
|
26
28
|
const el = target.current;
|
|
27
29
|
if (el) {
|
|
28
30
|
let eventTarget: EventTarget | null;
|
|
29
31
|
preventDragDefault(el);
|
|
30
32
|
const onEnter = (e: DragEvent) => {
|
|
33
|
+
if (overRef.current) overRef.current(e);
|
|
31
34
|
if (eventTarget === e.target) return null;
|
|
32
35
|
eventTarget = e.target;
|
|
33
36
|
|
|
@@ -49,6 +52,7 @@ export function useDropZone(
|
|
|
49
52
|
e.preventDefault();
|
|
50
53
|
if (dropRef.current) dropRef.current(e);
|
|
51
54
|
};
|
|
55
|
+
|
|
52
56
|
el.addEventListener('dragenter', onEnter);
|
|
53
57
|
el.addEventListener('dragover', onEnter);
|
|
54
58
|
el.addEventListener('dragleave', onLeave);
|
|
@@ -60,5 +64,5 @@ export function useDropZone(
|
|
|
60
64
|
el.removeEventListener('drop', onDrop);
|
|
61
65
|
};
|
|
62
66
|
}
|
|
63
|
-
}, [target, dropRef, enterRef, leaveRef]);
|
|
67
|
+
}, [target, dropRef, enterRef, leaveRef, overRef]);
|
|
64
68
|
}
|