@vev/silke 1.0.19 → 1.0.20
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 +9 -0
- package/dist/{chunk-FIPWO3IB.js → chunk-PP74IZDW.js} +2 -2
- package/dist/{chunk-FIPWO3IB.js.map → chunk-PP74IZDW.js.map} +2 -2
- package/dist/index.js +20 -20
- package/dist/index.js.map +4 -4
- package/dist/silke/src/components/silke-box/silke-box.d.ts +1 -2
- package/dist/silke/src/components/silke-card/silke-card.d.ts +2 -0
- package/dist/silke/src/components/silke-form-schema/fields/number-field.d.ts +3 -1
- package/dist/silke/src/components/silke-form-schema/silke-schema-field.d.ts +2 -2
- package/dist/silke/src/components/silke-tabs/silke-tab.d.ts +4 -7
- package/dist/silke/src/components/silke-tabs/silke-tabs.d.ts +4 -6
- package/dist/silke/src/components/silke-text-field/silke-text-field-outline.d.ts +1 -2
- package/dist/silke/src/components/silke-tooltip/silke-shortcuts.d.ts +1 -1
- package/dist/silke/src/components/silke-upload-field/silke-upload-field.d.ts +1 -0
- package/dist/silke/src/icons.d.ts +3 -0
- package/dist/{silke-code-editor-HB2Z4Q5W.js → silke-code-editor-4TSQ5KJ3.js} +12 -12
- package/dist/silke-code-editor-4TSQ5KJ3.js.map +7 -0
- package/dist/styles.css +386 -411
- package/dist/utils/src/interactions/get-interaction-map.d.ts +3 -0
- package/dist/utils/src/interactions/index.d.ts +2 -0
- package/dist/utils/src/interactions/interaction-map-to-array.d.ts +2 -0
- package/dist/utils/src/types/context.d.ts +1 -1
- package/dist/utils/src/types/index.d.ts +1 -0
- package/dist/utils/src/types/interaction.d.ts +9 -0
- package/dist/utils/src/types/oauth.d.ts +13 -0
- package/dist/utils/src/types/vev-plugin.d.ts +37 -6
- package/package.json +5 -4
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +1 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +18 -4
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +10 -8
- package/src/components/silke-box/silke-box.mdx +2 -2
- package/src/components/silke-box/silke-box.scss +2 -1
- package/src/components/silke-box/silke-box.tsx +1 -2
- package/src/components/silke-button/silke-button.scss +2 -2
- package/src/components/silke-card/silke-card-grid.tsx +1 -3
- package/src/components/silke-card/silke-card.scss +28 -3
- package/src/components/silke-card/silke-card.tsx +27 -9
- package/src/components/silke-code-snippet/silke-code-snippet.tsx +2 -2
- package/src/components/silke-form-schema/fields/image-field.tsx +4 -2
- package/src/components/silke-form-schema/fields/link-field.tsx +2 -6
- package/src/components/silke-form-schema/fields/number-field.tsx +47 -43
- package/src/components/silke-form-schema/fields/object-field.tsx +1 -1
- package/src/components/silke-form-schema/fields/select-field.tsx +37 -49
- package/src/components/silke-form-schema/fields/string-field.tsx +13 -28
- package/src/components/silke-form-schema/fields/toggle-field.tsx +8 -10
- package/src/components/silke-form-schema/silke-form-schema.mdx +14 -26
- package/src/components/silke-form-schema/silke-form-schema.tsx +4 -1
- package/src/components/silke-form-schema/silke-schema-field.tsx +8 -8
- package/src/components/silke-form-schema/silke-schema-fields.tsx +2 -2
- package/src/components/silke-icon-picker/silke-icon-picker.tsx +1 -1
- package/src/components/silke-list-card/silke-list-card.tsx +0 -2
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +1 -1
- package/src/components/silke-tabs/silke-tab.tsx +17 -50
- package/src/components/silke-tabs/silke-tabs.mdx +4 -16
- package/src/components/silke-tabs/silke-tabs.scss +24 -81
- package/src/components/silke-tabs/silke-tabs.tsx +12 -10
- package/src/components/silke-tag/silke-tag.mdx +78 -24
- package/src/components/silke-tag/silke-tag.scss +4 -1
- package/src/components/silke-text/silke-title.scss +0 -2
- package/src/components/silke-text-field/silke-text-field-outline.tsx +28 -16
- package/src/components/silke-text-field/silke-text-field.mdx +12 -0
- package/src/components/silke-text-field/silke-text-field.scss +8 -1
- package/src/components/silke-text-field/silke-text-field.tsx +2 -2
- package/src/components/silke-upload-field/silke-upload-field.tsx +5 -1
- package/src/icons.tsx +9 -19
- package/src/styles/core.scss +6 -0
- package/dist/silke-code-editor-HB2Z4Q5W.js.map +0 -7
- /package/dist/{chunk-FIPWO3IB.js.LEGAL.txt → chunk-PP74IZDW.js.LEGAL.txt} +0 -0
- /package/dist/{silke-code-editor-HB2Z4Q5W.js.LEGAL.txt → silke-code-editor-4TSQ5KJ3.js.LEGAL.txt} +0 -0
|
@@ -4,21 +4,22 @@ import { SilkeCssNumberField } from '../../silke-css-number-field';
|
|
|
4
4
|
import { SilkeBox } from '../../silke-box';
|
|
5
5
|
import { SilkeSlider } from '../../silke-slider';
|
|
6
6
|
import { SilkeTextSmall } from '../../silke-text';
|
|
7
|
-
import { SilkeTextField } from '../../silke-text-field';
|
|
7
|
+
import { SilkeTextField, SilkeTextFieldItem } from '../../silke-text-field';
|
|
8
8
|
|
|
9
9
|
import { getTitle } from './utils/schema-util';
|
|
10
10
|
import { SilkeIconTooltip } from '../../silke-tooltip';
|
|
11
11
|
|
|
12
|
-
const NumberField = (
|
|
12
|
+
const NumberField = (
|
|
13
|
+
props: SchemaFieldProps<Omit<NumberFieldType, 'format'>> & {
|
|
14
|
+
format?: string;
|
|
15
|
+
},
|
|
16
|
+
) => {
|
|
13
17
|
const [errorMessage, setErrorMessage] = useState<string>();
|
|
14
18
|
const {
|
|
15
19
|
value,
|
|
16
20
|
onChange,
|
|
17
21
|
schema,
|
|
18
22
|
schema: {
|
|
19
|
-
name = '',
|
|
20
|
-
title = '',
|
|
21
|
-
description = '',
|
|
22
23
|
options: {
|
|
23
24
|
min = Number.NEGATIVE_INFINITY,
|
|
24
25
|
max = Number.POSITIVE_INFINITY,
|
|
@@ -37,17 +38,17 @@ const NumberField = (props: SchemaFieldProps<NumberFieldType>) => {
|
|
|
37
38
|
}, [value, min, max]);
|
|
38
39
|
|
|
39
40
|
const scale = props.schema?.options?.scale || 1;
|
|
40
|
-
const format = props.schema?.options?.format;
|
|
41
|
+
const format = props.schema?.options?.format || '';
|
|
41
42
|
|
|
42
43
|
if (display === 'slider') {
|
|
43
44
|
const sliderValue = value ?? 0;
|
|
44
45
|
return (
|
|
45
46
|
<SilkeBox column flex>
|
|
46
47
|
<SilkeBox vAlign="center" flex>
|
|
47
|
-
<SilkeTextSmall
|
|
48
|
+
<SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
|
|
48
49
|
{schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
|
|
49
50
|
</SilkeBox>
|
|
50
|
-
<SilkeBox vPad="s">
|
|
51
|
+
<SilkeBox vPad="s" gap="s">
|
|
51
52
|
<SilkeSlider
|
|
52
53
|
value={(sliderValue - min) / (max - min)}
|
|
53
54
|
onChange={(percentage) => {
|
|
@@ -55,58 +56,61 @@ const NumberField = (props: SchemaFieldProps<NumberFieldType>) => {
|
|
|
55
56
|
onChange(value);
|
|
56
57
|
}}
|
|
57
58
|
/>
|
|
59
|
+
<SilkeBox width="l">
|
|
60
|
+
<SilkeTextField
|
|
61
|
+
value={(sliderValue * scale).toFixed(0).toString() + format}
|
|
62
|
+
onChange={(value: string) => onChange(parseFloat(value) / scale)}
|
|
63
|
+
size="xs"
|
|
64
|
+
/>
|
|
65
|
+
</SilkeBox>
|
|
58
66
|
</SilkeBox>
|
|
59
67
|
</SilkeBox>
|
|
60
68
|
);
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
if (format) {
|
|
71
|
+
if (format && scale !== 1) {
|
|
64
72
|
return (
|
|
65
73
|
<SilkeCssNumberField
|
|
66
74
|
{...rest}
|
|
67
75
|
value={(value || 0) * scale + format}
|
|
68
76
|
error={errorMessage}
|
|
69
77
|
onChange={(value) => onChange(parseFloat(value) / scale)}
|
|
70
|
-
size="
|
|
78
|
+
size="xs"
|
|
71
79
|
/>
|
|
72
80
|
);
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
const scaledValue = value ? value * scale : value;
|
|
76
84
|
return (
|
|
77
|
-
<SilkeBox
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
value
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
flex
|
|
107
|
-
/>
|
|
108
|
-
</SilkeBox>
|
|
109
|
-
</SilkeBox>
|
|
85
|
+
<SilkeBox flex>
|
|
86
|
+
<SilkeTextField
|
|
87
|
+
type="number"
|
|
88
|
+
size="xs"
|
|
89
|
+
label={getTitle(schema)}
|
|
90
|
+
tooltip={schema.description}
|
|
91
|
+
value={scaledValue}
|
|
92
|
+
error={errorMessage}
|
|
93
|
+
placeholder={schema.options?.placeholder}
|
|
94
|
+
onChange={(value: number) => {
|
|
95
|
+
if (value) {
|
|
96
|
+
onChange(value / scale);
|
|
97
|
+
} else {
|
|
98
|
+
onChange(value);
|
|
99
|
+
}
|
|
100
|
+
}}
|
|
101
|
+
onBlur={() => {
|
|
102
|
+
if (!value) {
|
|
103
|
+
onChange(0);
|
|
104
|
+
}
|
|
105
|
+
}}
|
|
106
|
+
flex
|
|
107
|
+
>
|
|
108
|
+
{format && (
|
|
109
|
+
<SilkeTextFieldItem hPad="s">
|
|
110
|
+
<SilkeTextSmall color="neutral-60">{format}</SilkeTextSmall>
|
|
111
|
+
</SilkeTextFieldItem>
|
|
112
|
+
)}
|
|
113
|
+
</SilkeTextField>
|
|
110
114
|
</SilkeBox>
|
|
111
115
|
);
|
|
112
116
|
};
|
|
@@ -13,7 +13,7 @@ export default function ObjectField({
|
|
|
13
13
|
onChange,
|
|
14
14
|
}: SchemaFieldProps<ObjectFieldType>) {
|
|
15
15
|
return (
|
|
16
|
-
<SilkeBox column flex style={{
|
|
16
|
+
<SilkeBox column flex style={{ paddingTop: '16px' }} gap="xs">
|
|
17
17
|
<SilkeTextSmall weight="strong">{getTitle(schema)}</SilkeTextSmall>
|
|
18
18
|
{schema.description && (
|
|
19
19
|
<SilkeTextSmall color="neutral-80">{schema.description}</SilkeTextSmall>
|
|
@@ -37,11 +37,13 @@ const SelectField = (props: SchemaFieldProps<SelectFieldType>) => {
|
|
|
37
37
|
if (multiselect && (!display || display === 'checkbox')) {
|
|
38
38
|
const values = (value as string[]) || [];
|
|
39
39
|
return (
|
|
40
|
-
<SilkeBox column
|
|
40
|
+
<SilkeBox column flex>
|
|
41
|
+
<SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
|
|
41
42
|
{items.map((item, index) => (
|
|
42
43
|
<SilkeCheckbox
|
|
43
44
|
key={index}
|
|
44
45
|
label={item.label}
|
|
46
|
+
size="s"
|
|
45
47
|
value={values.includes(item.value) || false}
|
|
46
48
|
onChange={(checked: boolean) =>
|
|
47
49
|
checked
|
|
@@ -56,62 +58,48 @@ const SelectField = (props: SchemaFieldProps<SelectFieldType>) => {
|
|
|
56
58
|
|
|
57
59
|
if (display === 'dropdown') {
|
|
58
60
|
return (
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<SilkeTextSmall style={{ paddingLeft: '4px' }} title={item.item.label} overflow>
|
|
76
|
-
{item.item.label}
|
|
77
|
-
</SilkeTextSmall>
|
|
78
|
-
);
|
|
79
|
-
}}
|
|
80
|
-
/>
|
|
81
|
-
</SilkeBox>
|
|
82
|
-
</SilkeBox>
|
|
61
|
+
<SilkeSelectField
|
|
62
|
+
label={getTitle(schema)}
|
|
63
|
+
value={props.value}
|
|
64
|
+
multiple={multiselect}
|
|
65
|
+
name={name}
|
|
66
|
+
items={items}
|
|
67
|
+
onChange={onChange}
|
|
68
|
+
size="xs"
|
|
69
|
+
renderItem={(item) => {
|
|
70
|
+
return (
|
|
71
|
+
<SilkeTextSmall style={{ paddingLeft: '4px' }} title={item.item.label} overflow>
|
|
72
|
+
{item.item.label}
|
|
73
|
+
</SilkeTextSmall>
|
|
74
|
+
);
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
83
77
|
);
|
|
84
78
|
}
|
|
85
79
|
if (display === 'autocomplete') {
|
|
86
80
|
return (
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
label=""
|
|
97
|
-
items={items}
|
|
98
|
-
onChange={onChange}
|
|
99
|
-
size="xs"
|
|
100
|
-
inline
|
|
101
|
-
inlineLabelWidth={80}
|
|
102
|
-
/>
|
|
103
|
-
</SilkeBox>
|
|
104
|
-
</SilkeBox>
|
|
81
|
+
<SilkeAutocompleteField
|
|
82
|
+
value={props.value}
|
|
83
|
+
multiple={multiselect}
|
|
84
|
+
name={name}
|
|
85
|
+
label={getTitle(schema)}
|
|
86
|
+
items={items}
|
|
87
|
+
onChange={onChange}
|
|
88
|
+
size="xs"
|
|
89
|
+
/>
|
|
105
90
|
);
|
|
106
91
|
}
|
|
92
|
+
|
|
107
93
|
return (
|
|
108
|
-
<SilkeBox gap="xs">
|
|
109
|
-
<
|
|
110
|
-
{getTitle(schema)}
|
|
111
|
-
</
|
|
112
|
-
<SilkeBox column
|
|
94
|
+
<SilkeBox gap="xs" flex column>
|
|
95
|
+
<SilkeBox flex>
|
|
96
|
+
<SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
|
|
97
|
+
</SilkeBox>
|
|
98
|
+
<SilkeBox column>
|
|
113
99
|
{items?.map((item, i) => (
|
|
114
|
-
<
|
|
100
|
+
<SilkeBox key={i} column>
|
|
101
|
+
<SilkeRadioButton {...item} name={name} size="small" />
|
|
102
|
+
</SilkeBox>
|
|
115
103
|
))}
|
|
116
104
|
</SilkeBox>
|
|
117
105
|
</SilkeBox>
|
|
@@ -2,39 +2,24 @@ import { SchemaFieldProps, StringField as StringFieldType } from '@vev/utils';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { SilkeTextField } from '../../silke-text-field';
|
|
4
4
|
import { getTitle } from './utils/schema-util';
|
|
5
|
-
import { SilkeBox } from '../../silke-box';
|
|
6
|
-
import { SilkeTextSmall } from '../../silke-text';
|
|
7
|
-
import { SilkeIconTooltip } from '../../silke-tooltip';
|
|
8
5
|
|
|
9
6
|
const StringField = ({ schema, value, onChange }: SchemaFieldProps<StringFieldType>) => {
|
|
10
7
|
const { options } = schema;
|
|
11
8
|
|
|
12
9
|
return (
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
inlineLabelWidth={80}
|
|
27
|
-
type={options?.type || 'text'}
|
|
28
|
-
minLength={options?.minLength}
|
|
29
|
-
maxLength={options?.maxLength}
|
|
30
|
-
onChange={onChange}
|
|
31
|
-
size="xs"
|
|
32
|
-
placeholder={options?.placeholder}
|
|
33
|
-
flex
|
|
34
|
-
/>
|
|
35
|
-
</SilkeBox>
|
|
36
|
-
</SilkeBox>
|
|
37
|
-
</SilkeBox>
|
|
10
|
+
<SilkeTextField
|
|
11
|
+
value={value}
|
|
12
|
+
multiline={!!options?.multiline}
|
|
13
|
+
label={getTitle(schema)}
|
|
14
|
+
type={options?.type || 'text'}
|
|
15
|
+
minLength={options?.minLength}
|
|
16
|
+
maxLength={options?.maxLength}
|
|
17
|
+
onChange={onChange}
|
|
18
|
+
size="xs"
|
|
19
|
+
placeholder={options?.placeholder}
|
|
20
|
+
flex
|
|
21
|
+
tooltip={schema?.description}
|
|
22
|
+
/>
|
|
38
23
|
);
|
|
39
24
|
};
|
|
40
25
|
|
|
@@ -8,18 +8,16 @@ import { SilkeIconTooltip } from '../../silke-tooltip';
|
|
|
8
8
|
|
|
9
9
|
const Toggle = ({ schema, value, onChange }: SchemaFieldProps<BooleanField>) => {
|
|
10
10
|
return (
|
|
11
|
-
<SilkeBox
|
|
12
|
-
<SilkeBox
|
|
13
|
-
<SilkeBox
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
{schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
|
|
17
|
-
</SilkeBox>
|
|
18
|
-
</SilkeBox>
|
|
19
|
-
<SilkeBox flex pad="xs">
|
|
20
|
-
<SilkeToggle value={value || false} onChange={onChange} small />
|
|
11
|
+
<SilkeBox flex>
|
|
12
|
+
<SilkeBox align="center" fill>
|
|
13
|
+
<SilkeBox vAlign="center" flex>
|
|
14
|
+
<SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
|
|
15
|
+
{schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
|
|
21
16
|
</SilkeBox>
|
|
22
17
|
</SilkeBox>
|
|
18
|
+
<SilkeBox flex pad="xs">
|
|
19
|
+
<SilkeToggle value={value || false} onChange={onChange} small />
|
|
20
|
+
</SilkeBox>
|
|
23
21
|
</SilkeBox>
|
|
24
22
|
);
|
|
25
23
|
};
|
|
@@ -26,6 +26,15 @@ const schema = [
|
|
|
26
26
|
title: "Number field",
|
|
27
27
|
description: "Field for entering numbers",
|
|
28
28
|
},
|
|
29
|
+
{
|
|
30
|
+
type: "number",
|
|
31
|
+
name: "numberMs",
|
|
32
|
+
title: "Number Seconds",
|
|
33
|
+
description: "Field with format",
|
|
34
|
+
options: {
|
|
35
|
+
format: "ms",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
29
38
|
{
|
|
30
39
|
type: "number",
|
|
31
40
|
name: "sliderKey",
|
|
@@ -35,6 +44,7 @@ const schema = [
|
|
|
35
44
|
min: -10,
|
|
36
45
|
max: 10,
|
|
37
46
|
display: "slider",
|
|
47
|
+
format: "s",
|
|
38
48
|
},
|
|
39
49
|
},
|
|
40
50
|
{
|
|
@@ -139,42 +149,20 @@ const schema = [
|
|
|
139
149
|
{
|
|
140
150
|
type: "select",
|
|
141
151
|
title: "Select field",
|
|
142
|
-
name: "multiSelectField",
|
|
143
|
-
description: "Select field for component",
|
|
144
|
-
options: {
|
|
145
|
-
items: [
|
|
146
|
-
{
|
|
147
|
-
name: "Option 1",
|
|
148
|
-
value: "one",
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: "Option 2",
|
|
152
|
-
value: "two",
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
name: "Option 3",
|
|
156
|
-
value: "three",
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
type: "select",
|
|
163
|
-
title: "Multi select field",
|
|
164
152
|
name: "selectField",
|
|
165
153
|
description: "Select field for component",
|
|
166
154
|
options: {
|
|
167
155
|
items: [
|
|
168
156
|
{
|
|
169
|
-
|
|
157
|
+
label: "Option 1",
|
|
170
158
|
value: "one",
|
|
171
159
|
},
|
|
172
160
|
{
|
|
173
|
-
|
|
161
|
+
label: "Option 2",
|
|
174
162
|
value: "two",
|
|
175
163
|
},
|
|
176
164
|
{
|
|
177
|
-
|
|
165
|
+
label: "Option 3",
|
|
178
166
|
value: "three",
|
|
179
167
|
},
|
|
180
168
|
],
|
|
@@ -183,7 +171,7 @@ const schema = [
|
|
|
183
171
|
{
|
|
184
172
|
type: "select",
|
|
185
173
|
title: "Multi select field",
|
|
186
|
-
name: "
|
|
174
|
+
name: "multiSelectField",
|
|
187
175
|
description: "Select field for component",
|
|
188
176
|
options: {
|
|
189
177
|
multiselect: true,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Schema, SchemaContextModel } from '@vev/utils';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { SilkeForm, SilkeFormProps } from '../silke-form';
|
|
4
|
+
import TextFieldContext from '../silke-text-field/text-field-context';
|
|
4
5
|
import { SilkeSchemaContext } from './silke-schema-context';
|
|
5
6
|
import { SilkeSchemaFields } from './silke-schema-fields';
|
|
6
7
|
|
|
@@ -21,7 +22,9 @@ export function SilkeFormSchema<T extends { [key: string]: any }>({
|
|
|
21
22
|
return (
|
|
22
23
|
<SilkeSchemaContext context={context}>
|
|
23
24
|
<SilkeForm {...rest} value={value}>
|
|
24
|
-
<
|
|
25
|
+
<TextFieldContext size="xs" kind="default" inline={false}>
|
|
26
|
+
<SilkeSchemaFields schema={schema} value={value} {...rest} />
|
|
27
|
+
</TextFieldContext>
|
|
25
28
|
</SilkeForm>
|
|
26
29
|
</SilkeSchemaContext>
|
|
27
30
|
);
|
|
@@ -25,7 +25,7 @@ type SilkeSchemaFieldProps = {
|
|
|
25
25
|
field: VevProps;
|
|
26
26
|
value?: any;
|
|
27
27
|
noPad?: boolean;
|
|
28
|
-
|
|
28
|
+
isFirst?: boolean;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const SCHEMA_FIELD_COMPONENTS: Partial<SchemaFieldComponents> = {
|
|
@@ -47,7 +47,7 @@ export function SilkeSchemaField({
|
|
|
47
47
|
field,
|
|
48
48
|
value: fieldValue,
|
|
49
49
|
noPad,
|
|
50
|
-
|
|
50
|
+
isFirst,
|
|
51
51
|
}: SilkeSchemaFieldProps) {
|
|
52
52
|
const extendedFields = useExtendedFields();
|
|
53
53
|
|
|
@@ -80,6 +80,11 @@ export function SilkeSchemaField({
|
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
82
|
<>
|
|
83
|
+
{['object', 'array', 'image'].includes(field?.type) && !isFirst && (
|
|
84
|
+
<SilkeBox column flex>
|
|
85
|
+
<SilkeDivider dark />
|
|
86
|
+
</SilkeBox>
|
|
87
|
+
)}
|
|
83
88
|
<SilkeBox hPad={!noPad ? 'm' : undefined} flex>
|
|
84
89
|
<Field
|
|
85
90
|
label={field.title || field.name}
|
|
@@ -91,18 +96,13 @@ export function SilkeSchemaField({
|
|
|
91
96
|
if (isEvalCallback(field.onChange)) {
|
|
92
97
|
value = await safeEvalFunction(field.onChange.value, value, context);
|
|
93
98
|
} else if (isFunction(field.onChange)) {
|
|
94
|
-
// @ts-
|
|
99
|
+
// @ts-ignore TODO: fix this
|
|
95
100
|
value = (await field.onChange(value as any, context)) as any;
|
|
96
101
|
}
|
|
97
102
|
onChange(value);
|
|
98
103
|
}}
|
|
99
104
|
/>
|
|
100
105
|
</SilkeBox>
|
|
101
|
-
{['object', 'array', 'image'].includes(field?.type) && !isLast && (
|
|
102
|
-
<SilkeBox column flex>
|
|
103
|
-
<SilkeDivider dark />
|
|
104
|
-
</SilkeBox>
|
|
105
|
-
)}
|
|
106
106
|
</>
|
|
107
107
|
);
|
|
108
108
|
}
|
|
@@ -45,11 +45,11 @@ export function SilkeSchemaFields<T extends { [key: string]: any }>(
|
|
|
45
45
|
}, [context, schema]);
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
|
-
<SilkeBox flex column={!row} gap="
|
|
48
|
+
<SilkeBox flex column={!row} gap="s" vPad="s" style={{ width: '100%' }}>
|
|
49
49
|
{filteredSchema.map((field, index) => {
|
|
50
50
|
return (
|
|
51
51
|
<span style={{ overflow: 'hidden' }} key={(field?.name || 'field') + index}>
|
|
52
|
-
<SilkeSchemaField field={field} {...rest}
|
|
52
|
+
<SilkeSchemaField field={field} {...rest} isFirst={index === 0} />
|
|
53
53
|
</span>
|
|
54
54
|
);
|
|
55
55
|
})}
|
|
@@ -66,7 +66,7 @@ export function SilkeIconPicker(props: SilkeIconPickerProps) {
|
|
|
66
66
|
targetOrigin="top-left"
|
|
67
67
|
onToggleOpen={setOpen}
|
|
68
68
|
>
|
|
69
|
-
<SilkeBox column bg="
|
|
69
|
+
<SilkeBox column bg="blur" style={{ width: 456, height: 320, borderRadius: 8 }}>
|
|
70
70
|
{!singleType && (
|
|
71
71
|
<SilkeTabs>
|
|
72
72
|
<SilkeTab
|
|
@@ -1,63 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { Link } from 'react-router-dom';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BoxButtonProps, SilkeBox } from '../silke-box';
|
|
4
3
|
import styles from './silke-tabs.scss';
|
|
5
4
|
|
|
6
|
-
const cl = classnames.bind(styles);
|
|
7
|
-
|
|
8
5
|
export type SilkeTabProps = {
|
|
9
|
-
label:
|
|
6
|
+
label: React.ReactNode;
|
|
10
7
|
active?: boolean;
|
|
11
8
|
disabled?: boolean;
|
|
12
|
-
error?: boolean;
|
|
13
9
|
href?: string;
|
|
14
|
-
|
|
15
|
-
style?: React.CSSProperties;
|
|
16
|
-
onClick?: () => void;
|
|
17
|
-
};
|
|
10
|
+
} & Omit<BoxButtonProps, 'size' | 'height' | 'width' | 'rounded' | 'children'>;
|
|
18
11
|
|
|
19
|
-
export function SilkeTab({
|
|
20
|
-
|
|
21
|
-
active
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
...rest
|
|
28
|
-
}: SilkeTabProps) {
|
|
29
|
-
const classNames = cl('tab', className, { 'tab--active': active, 'tab-error': error });
|
|
30
|
-
const onClickProxy = useCallback(
|
|
31
|
-
(e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
32
|
-
e.preventDefault();
|
|
33
|
-
if (onClick) {
|
|
34
|
-
onClick();
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
[onClick],
|
|
38
|
-
);
|
|
39
|
-
return href ? (
|
|
40
|
-
<Link
|
|
41
|
-
to={href}
|
|
42
|
-
style={style}
|
|
43
|
-
rel="button"
|
|
44
|
-
className={classNames}
|
|
45
|
-
onClick={onClick ? onClickProxy : undefined}
|
|
46
|
-
{...rest}
|
|
47
|
-
>
|
|
48
|
-
{label}
|
|
49
|
-
</Link>
|
|
50
|
-
) : (
|
|
51
|
-
<a
|
|
52
|
-
aria-selected={active}
|
|
12
|
+
export function SilkeTab({ label, active, href, className, ...rest }: SilkeTabProps) {
|
|
13
|
+
let cl = styles.tab;
|
|
14
|
+
if (active) cl += ' ' + styles.active;
|
|
15
|
+
if (className) cl += ' ' + className;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<SilkeBox
|
|
19
|
+
tag="button"
|
|
53
20
|
role="tab"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
21
|
+
hPad="s"
|
|
22
|
+
hAlign="center"
|
|
23
|
+
vAlign="center"
|
|
24
|
+
className={cl}
|
|
58
25
|
{...rest}
|
|
59
26
|
>
|
|
60
27
|
{label}
|
|
61
|
-
</
|
|
28
|
+
</SilkeBox>
|
|
62
29
|
);
|
|
63
30
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
```js
|
|
4
4
|
const [active, setActive] = React.useState(1);
|
|
5
|
-
|
|
5
|
+
<SilkeBox column gap="m">
|
|
6
6
|
<SilkeTabs>
|
|
7
7
|
{[1, 2, 3, 4].map((tab) => (
|
|
8
8
|
<SilkeTab
|
|
@@ -14,18 +14,7 @@ const [active, setActive] = React.useState(1);
|
|
|
14
14
|
/>
|
|
15
15
|
))}
|
|
16
16
|
</SilkeTabs>
|
|
17
|
-
<
|
|
18
|
-
<h1>Active tab {active}</h1>
|
|
19
|
-
</SilkeBox>
|
|
20
|
-
</>;
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Container Tabs
|
|
24
|
-
|
|
25
|
-
```js
|
|
26
|
-
const [active, setActive] = React.useState(1);
|
|
27
|
-
<SilkeBox bg="ui-1" column>
|
|
28
|
-
<SilkeTabs container>
|
|
17
|
+
<SilkeTabs size="s">
|
|
29
18
|
{[1, 2, 3, 4].map((tab) => (
|
|
30
19
|
<SilkeTab
|
|
31
20
|
key={tab}
|
|
@@ -36,8 +25,7 @@ const [active, setActive] = React.useState(1);
|
|
|
36
25
|
/>
|
|
37
26
|
))}
|
|
38
27
|
</SilkeTabs>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
</SilkeBox>
|
|
28
|
+
|
|
29
|
+
<h1>Active tab {active}</h1>
|
|
42
30
|
</SilkeBox>;
|
|
43
31
|
```
|