@vev/silke 1.1.7 → 1.1.8
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 +6 -0
- package/dist/index.js +26 -26
- package/dist/styles.css +45 -45
- package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/color-field.d.ts +3 -0
- package/dist/types/components/silke-form-schema/schema-utils.d.ts +6 -1
- package/dist/types/icons.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/silke-command-text-field/silke-command-text-field.tsx +7 -0
- package/src/components/silke-form-schema/fields/array-field-modal.tsx +8 -4
- package/src/components/silke-form-schema/fields/array-field.tsx +27 -3
- package/src/components/silke-form-schema/fields/color-field.tsx +36 -0
- package/src/components/silke-form-schema/schema-utils.ts +27 -1
- package/src/components/silke-form-schema/silke-schema-field.tsx +2 -0
- package/src/components/silke-tag/silke-tag.scss +1 -1
- package/src/icons.tsx +15 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/dist/styles.css
CHANGED
|
@@ -2526,51 +2526,6 @@ img.silke-icon_icon_84f9e9d6b3 {
|
|
|
2526
2526
|
* Get font size base on base font size
|
|
2527
2527
|
* scaling = round(size * 1.200) (Minor Third)
|
|
2528
2528
|
*/
|
|
2529
|
-
.silke-overflow-menu_btnOpen_9d7478ea25 {
|
|
2530
|
-
background-color: var(--color-neutral-20) !important;
|
|
2531
|
-
border: none !important;
|
|
2532
|
-
}
|
|
2533
|
-
.silke-overflow-menu_btnOpen_9d7478ea25::before {
|
|
2534
|
-
display: none !important;
|
|
2535
|
-
}
|
|
2536
|
-
|
|
2537
|
-
.silke-overflow-menu_menu_9d7478ea25 {
|
|
2538
|
-
overflow: hidden;
|
|
2539
|
-
min-width: 70px;
|
|
2540
|
-
background: var(--color-neutral-20);
|
|
2541
|
-
border-radius: var(--border-radius-small);
|
|
2542
|
-
filter: var(--shadow-level-4);
|
|
2543
|
-
}
|
|
2544
|
-
.silke-overflow-menu_menu_9d7478ea25 hr {
|
|
2545
|
-
margin: 8px 0;
|
|
2546
|
-
background: var(--color-neutral-60);
|
|
2547
|
-
}
|
|
2548
|
-
.silke-overflow-menu_menu_9d7478ea25:focus {
|
|
2549
|
-
outline: none;
|
|
2550
|
-
}
|
|
2551
|
-
.silke-overflow-menu_menu_9d7478ea25:focus-visible {
|
|
2552
|
-
box-shadow: 0 0 0 4px var(--color-neutral-100);
|
|
2553
|
-
}
|
|
2554
|
-
.silke-overflow-menu_menu_9d7478ea25 button,
|
|
2555
|
-
.silke-overflow-menu_menu_9d7478ea25 a {
|
|
2556
|
-
justify-content: start !important;
|
|
2557
|
-
}
|
|
2558
|
-
/**********************
|
|
2559
|
-
* SOME MATH
|
|
2560
|
-
************************/
|
|
2561
|
-
/**********************
|
|
2562
|
-
* FONT
|
|
2563
|
-
************************/
|
|
2564
|
-
/**********************
|
|
2565
|
-
* SPACING
|
|
2566
|
-
************************/
|
|
2567
|
-
/**********************
|
|
2568
|
-
* SIZES
|
|
2569
|
-
************************/
|
|
2570
|
-
/**
|
|
2571
|
-
* Get font size base on base font size
|
|
2572
|
-
* scaling = round(size * 1.200) (Minor Third)
|
|
2573
|
-
*/
|
|
2574
2529
|
.silke-image_img_45cd7ad714 {
|
|
2575
2530
|
-o-object-position: center center;
|
|
2576
2531
|
object-position: center center;
|
|
@@ -2616,6 +2571,51 @@ img.silke-icon_icon_84f9e9d6b3 {
|
|
|
2616
2571
|
* Get font size base on base font size
|
|
2617
2572
|
* scaling = round(size * 1.200) (Minor Third)
|
|
2618
2573
|
*/
|
|
2574
|
+
.silke-overflow-menu_btnOpen_9d7478ea25 {
|
|
2575
|
+
background-color: var(--color-neutral-20) !important;
|
|
2576
|
+
border: none !important;
|
|
2577
|
+
}
|
|
2578
|
+
.silke-overflow-menu_btnOpen_9d7478ea25::before {
|
|
2579
|
+
display: none !important;
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
.silke-overflow-menu_menu_9d7478ea25 {
|
|
2583
|
+
overflow: hidden;
|
|
2584
|
+
min-width: 70px;
|
|
2585
|
+
background: var(--color-neutral-20);
|
|
2586
|
+
border-radius: var(--border-radius-small);
|
|
2587
|
+
filter: var(--shadow-level-4);
|
|
2588
|
+
}
|
|
2589
|
+
.silke-overflow-menu_menu_9d7478ea25 hr {
|
|
2590
|
+
margin: 8px 0;
|
|
2591
|
+
background: var(--color-neutral-60);
|
|
2592
|
+
}
|
|
2593
|
+
.silke-overflow-menu_menu_9d7478ea25:focus {
|
|
2594
|
+
outline: none;
|
|
2595
|
+
}
|
|
2596
|
+
.silke-overflow-menu_menu_9d7478ea25:focus-visible {
|
|
2597
|
+
box-shadow: 0 0 0 4px var(--color-neutral-100);
|
|
2598
|
+
}
|
|
2599
|
+
.silke-overflow-menu_menu_9d7478ea25 button,
|
|
2600
|
+
.silke-overflow-menu_menu_9d7478ea25 a {
|
|
2601
|
+
justify-content: start !important;
|
|
2602
|
+
}
|
|
2603
|
+
/**********************
|
|
2604
|
+
* SOME MATH
|
|
2605
|
+
************************/
|
|
2606
|
+
/**********************
|
|
2607
|
+
* FONT
|
|
2608
|
+
************************/
|
|
2609
|
+
/**********************
|
|
2610
|
+
* SPACING
|
|
2611
|
+
************************/
|
|
2612
|
+
/**********************
|
|
2613
|
+
* SIZES
|
|
2614
|
+
************************/
|
|
2615
|
+
/**
|
|
2616
|
+
* Get font size base on base font size
|
|
2617
|
+
* scaling = round(size * 1.200) (Minor Third)
|
|
2618
|
+
*/
|
|
2619
2619
|
.silke-code-snippet_main_4e986d6b6d {
|
|
2620
2620
|
position: relative;
|
|
2621
2621
|
flex-direction: column;
|
|
@@ -8,4 +8,4 @@ export declare const getSuggestions: (searchValue: string, variables: SilkeCSSCo
|
|
|
8
8
|
export declare const getSystemSuggestionOptions: (value: string | number | boolean, systemOptions?: VevConditionSuggestion[]) => ConditionSuggestion[];
|
|
9
9
|
export declare const getWidgetSuggestionOptions: (value: string | number | boolean, widgetOptions?: VevProps[]) => ConditionSuggestion[];
|
|
10
10
|
export declare const isWidgetOption: (value: string | number | boolean, widgetOptions?: VevProps[]) => boolean;
|
|
11
|
-
export declare const getWidgetOptionType: (value: string | number | boolean, widgetOptions?: VevProps[]) => "string" | "number" | "boolean" | "object" | "link" | "audio" | "menu" | "select" | "video" | "image" | "layout" | "icon" | "upload" | "divider" | "variable" | "array" | "event" | "widgetSelect" | "mainComponent" | undefined;
|
|
11
|
+
export declare const getWidgetOptionType: (value: string | number | boolean, widgetOptions?: VevProps[]) => "string" | "number" | "boolean" | "object" | "link" | "audio" | "menu" | "select" | "video" | "image" | "color" | "layout" | "icon" | "upload" | "divider" | "variable" | "array" | "event" | "widgetSelect" | "mainComponent" | undefined;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { EvalCallback, Schema, SchemaContextModel } from '@vev/utils';
|
|
1
|
+
import { EvalCallback, Schema, SchemaContextModel, VevProps } from '@vev/utils';
|
|
2
2
|
export declare function isEvalCallback(value: any): value is EvalCallback;
|
|
3
3
|
type InitialValue = {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
};
|
|
6
6
|
export declare function getSchemaInitialValue<T extends InitialValue>(schema: Schema, context: Omit<SchemaContextModel, 'actions'>): Promise<InitialValue>;
|
|
7
|
+
/**
|
|
8
|
+
* Synchronously compute default/initial values from a schema.
|
|
9
|
+
* Handles static initialValue only (skips eval callbacks and functions).
|
|
10
|
+
*/
|
|
11
|
+
export declare function getSchemaDefaultValue(schema: VevProps | VevProps[]): InitialValue;
|
|
7
12
|
export declare function useStorageField<T>(name: string, storageScope: 'project' | 'workspace' | 'account'): {
|
|
8
13
|
value: T | undefined;
|
|
9
14
|
onChange: (value: T) => Promise<void>;
|
package/dist/types/icons.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export declare const SilkeIconDefinitions: {
|
|
|
29
29
|
'ai.sparkels': string;
|
|
30
30
|
'ai.gradient': typeof AiGradientIcon;
|
|
31
31
|
'ai.image': string;
|
|
32
|
+
'ai.component': typeof AiGradientComponent;
|
|
32
33
|
'ai.text': string;
|
|
33
34
|
'ai.file': string;
|
|
34
35
|
sparkles: string;
|
|
@@ -494,4 +495,5 @@ declare function AnimationFillBackwards(): import("react/jsx-runtime").JSX.Eleme
|
|
|
494
495
|
declare function AnimationFillForwards(): import("react/jsx-runtime").JSX.Element;
|
|
495
496
|
declare function AnimationFillBoth(): import("react/jsx-runtime").JSX.Element;
|
|
496
497
|
declare function AiGradientIcon(): import("react/jsx-runtime").JSX.Element;
|
|
498
|
+
declare function AiGradientComponent(): import("react/jsx-runtime").JSX.Element;
|
|
497
499
|
export {};
|
package/package.json
CHANGED
|
@@ -430,6 +430,13 @@ const SilkeCommandTextField = React.forwardRef<
|
|
|
430
430
|
return;
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
+
// Cmd+Enter or Shift+Enter inserts a line break
|
|
434
|
+
if (e.key === 'Enter' && (e.metaKey || e.shiftKey)) {
|
|
435
|
+
e.preventDefault();
|
|
436
|
+
document.execCommand('insertLineBreak');
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
|
|
433
440
|
const element = inputRef.current;
|
|
434
441
|
if (!element) return;
|
|
435
442
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { RefObject, useCallback, useRef } from 'react';
|
|
1
|
+
import React, { RefObject, useCallback, useMemo, useRef } from 'react';
|
|
2
2
|
import { SilkeSchemaFields } from '../silke-schema-fields';
|
|
3
3
|
import { SilkeTextField } from '../../silke-text-field';
|
|
4
4
|
import { SilkePopover } from '../../silke-popover';
|
|
@@ -8,6 +8,7 @@ import { SilkeBox } from '../../silke-box';
|
|
|
8
8
|
import { SilkeButton } from '../../silke-button';
|
|
9
9
|
import { generateTitle } from './utils';
|
|
10
10
|
import { VevProps } from '@vev/utils';
|
|
11
|
+
import { getSchemaDefaultValue } from '../schema-utils';
|
|
11
12
|
import styles from './styles.scss';
|
|
12
13
|
|
|
13
14
|
type Props = {
|
|
@@ -38,6 +39,8 @@ export function ArrayFieldModal({
|
|
|
38
39
|
fieldRefs.current[name] = v;
|
|
39
40
|
}, []);
|
|
40
41
|
|
|
42
|
+
const defaultItemValue = useMemo(() => getSchemaDefaultValue(schema as VevProps | VevProps[]), [schema]);
|
|
43
|
+
|
|
41
44
|
const anchorRect = anchor.current.getBoundingClientRect();
|
|
42
45
|
const anchorPos: [number, number] = [anchorRect.left - 16, anchorRect.top];
|
|
43
46
|
|
|
@@ -73,11 +76,12 @@ export function ArrayFieldModal({
|
|
|
73
76
|
<FormObjectProvider
|
|
74
77
|
errors={{}}
|
|
75
78
|
valueRef={valueRef}
|
|
76
|
-
value={value[selected] ||
|
|
77
|
-
validate={() => {}}
|
|
79
|
+
value={value[selected] || defaultItemValue}
|
|
80
|
+
validate={() => { }}
|
|
78
81
|
onChange={(name, update) => {
|
|
79
82
|
const newValue = [...(value || [])];
|
|
80
83
|
newValue[selected] = {
|
|
84
|
+
...defaultItemValue,
|
|
81
85
|
...value[selected],
|
|
82
86
|
[name]: update,
|
|
83
87
|
};
|
|
@@ -88,7 +92,7 @@ export function ArrayFieldModal({
|
|
|
88
92
|
<SilkeSchemaFields
|
|
89
93
|
disabled={disabled}
|
|
90
94
|
schema={Array.isArray(schema) ? schema : [schema]}
|
|
91
|
-
value={
|
|
95
|
+
value={value[selected] || defaultItemValue}
|
|
92
96
|
noPad
|
|
93
97
|
itemIndex={selected}
|
|
94
98
|
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArrayField as ArrayFieldType, SchemaFieldProps, VevProps } from '@vev/utils';
|
|
2
|
-
import React, { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { SilkeBox } from '../../silke-box';
|
|
4
4
|
import { SilkeButton } from '../../silke-button';
|
|
5
5
|
import { SilkeIcon } from '../../silke-icon';
|
|
@@ -12,6 +12,7 @@ import { SilkeOverflowMenu } from '../../silke-overflow-menu';
|
|
|
12
12
|
import { generateImage, generateTitle } from './utils';
|
|
13
13
|
import { isString, startCase } from 'lodash';
|
|
14
14
|
import { getTitle } from './utils/schema-util';
|
|
15
|
+
import { getSchemaDefaultValue } from '../schema-utils';
|
|
15
16
|
|
|
16
17
|
const ArrayField = ({
|
|
17
18
|
value = [],
|
|
@@ -26,6 +27,21 @@ const ArrayField = ({
|
|
|
26
27
|
|
|
27
28
|
const listRefs = useRef<any[]>([]);
|
|
28
29
|
const headerRef = useRef<any>(null);
|
|
30
|
+
const valueRef = useRef(value);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
valueRef.current = value;
|
|
34
|
+
}, [value]);
|
|
35
|
+
|
|
36
|
+
const addItem = useCallback(
|
|
37
|
+
(defaultValue: any) => {
|
|
38
|
+
const newValue = [...valueRef.current, defaultValue];
|
|
39
|
+
valueRef.current = newValue;
|
|
40
|
+
onChange(newValue);
|
|
41
|
+
setSelected(newValue.length - 1);
|
|
42
|
+
},
|
|
43
|
+
[onChange],
|
|
44
|
+
);
|
|
29
45
|
|
|
30
46
|
const handleDeleteItem = useCallback(() => {
|
|
31
47
|
const update = value.filter((_, i) => i !== selected);
|
|
@@ -63,7 +79,7 @@ const ArrayField = ({
|
|
|
63
79
|
icon: <Icon />,
|
|
64
80
|
onClick: () => {
|
|
65
81
|
setSchemaIndex(i);
|
|
66
|
-
|
|
82
|
+
addItem(getSchemaDefaultValue((schema.of as VevProps[])[i]));
|
|
67
83
|
},
|
|
68
84
|
};
|
|
69
85
|
})}
|
|
@@ -74,7 +90,15 @@ const ArrayField = ({
|
|
|
74
90
|
kind="ghost"
|
|
75
91
|
size="base"
|
|
76
92
|
onClick={() => {
|
|
77
|
-
|
|
93
|
+
const defaultValue =
|
|
94
|
+
Array.isArray(schema.of)
|
|
95
|
+
? getSchemaDefaultValue(schema.of[0])
|
|
96
|
+
: schema.of === 'object' && 'fields' in schema
|
|
97
|
+
? getSchemaDefaultValue(schema.fields)
|
|
98
|
+
: schema.of === 'number'
|
|
99
|
+
? 0
|
|
100
|
+
: '';
|
|
101
|
+
addItem(defaultValue);
|
|
78
102
|
}}
|
|
79
103
|
/>
|
|
80
104
|
)}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SchemaFieldProps, ColorField as ColorFieldType } from '@vev/utils';
|
|
2
|
+
import { SilkeColorPickerButton } from '../../silke-color-picker';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { SilkeBox } from '../../silke-box';
|
|
5
|
+
import { getTitle } from './utils/schema-util';
|
|
6
|
+
import { SilkeTextSmall } from '../../silke-text';
|
|
7
|
+
import { SilkeIconTooltip } from '../../silke-tooltip';
|
|
8
|
+
|
|
9
|
+
const ColorField = ({
|
|
10
|
+
schema,
|
|
11
|
+
value,
|
|
12
|
+
disabled,
|
|
13
|
+
readonly,
|
|
14
|
+
onChange,
|
|
15
|
+
}: SchemaFieldProps<ColorFieldType>) => {
|
|
16
|
+
return (
|
|
17
|
+
<SilkeBox flex align="center">
|
|
18
|
+
<SilkeBox align="center" fill>
|
|
19
|
+
<SilkeBox vAlign="center" flex>
|
|
20
|
+
<SilkeTextSmall>{getTitle(schema)}</SilkeTextSmall>
|
|
21
|
+
{schema.description && <SilkeIconTooltip tooltip={schema.description} icon="tooltip" />}
|
|
22
|
+
</SilkeBox>
|
|
23
|
+
</SilkeBox>
|
|
24
|
+
<SilkeBox flex pad="xs">
|
|
25
|
+
<SilkeColorPickerButton
|
|
26
|
+
disabled={disabled}
|
|
27
|
+
value={value as any}
|
|
28
|
+
onChange={onChange}
|
|
29
|
+
size="s"
|
|
30
|
+
/>
|
|
31
|
+
</SilkeBox>
|
|
32
|
+
</SilkeBox>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default ColorField;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EvalCallback, Schema, SchemaContextModel } from '@vev/utils';
|
|
1
|
+
import { EvalCallback, Schema, SchemaContextModel, VevProps } from '@vev/utils';
|
|
2
2
|
import { isFunction } from 'lodash';
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import { safeEvalFunction } from './safe-eval';
|
|
@@ -37,6 +37,32 @@ export async function getSchemaInitialValue<T extends InitialValue>(
|
|
|
37
37
|
return res;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Synchronously compute default/initial values from a schema.
|
|
42
|
+
* Handles static initialValue only (skips eval callbacks and functions).
|
|
43
|
+
*/
|
|
44
|
+
export function getSchemaDefaultValue(schema: VevProps | VevProps[]): InitialValue {
|
|
45
|
+
const fields = Array.isArray(schema) ? schema : [schema];
|
|
46
|
+
const res: InitialValue = {};
|
|
47
|
+
for (const field of fields) {
|
|
48
|
+
if (field.name && field.type) {
|
|
49
|
+
if (field.type === 'object') {
|
|
50
|
+
res[field.name] = getSchemaDefaultValue(field.fields);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (
|
|
55
|
+
field.initialValue &&
|
|
56
|
+
!isEvalCallback(field.initialValue) &&
|
|
57
|
+
!isFunction(field.initialValue)
|
|
58
|
+
) {
|
|
59
|
+
res[field.name] = field.initialValue as any;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
|
|
40
66
|
export function useStorageField<T>(
|
|
41
67
|
name: string,
|
|
42
68
|
storageScope: 'project' | 'workspace' | 'account',
|
|
@@ -27,6 +27,7 @@ import IconField from './fields/icon-field';
|
|
|
27
27
|
import EventField from './fields/event-field';
|
|
28
28
|
import UploadField from './fields/upload-field';
|
|
29
29
|
import AudioField from './fields/audio-field';
|
|
30
|
+
import ColorField from './fields/color-field';
|
|
30
31
|
|
|
31
32
|
type SilkeSchemaFieldProps = {
|
|
32
33
|
field: VevProps;
|
|
@@ -39,6 +40,7 @@ type SilkeSchemaFieldProps = {
|
|
|
39
40
|
|
|
40
41
|
const SCHEMA_FIELD_COMPONENTS: Partial<SchemaFieldComponents> = {
|
|
41
42
|
string: StringField,
|
|
43
|
+
color: ColorField,
|
|
42
44
|
number: NumberField,
|
|
43
45
|
array: ArrayField,
|
|
44
46
|
image: ImageField,
|
package/src/icons.tsx
CHANGED
|
@@ -32,6 +32,7 @@ export const SilkeIconDefinitions = {
|
|
|
32
32
|
'ai.sparkels': 'fal fa-sparkles',
|
|
33
33
|
'ai.gradient': AiGradientIcon,
|
|
34
34
|
'ai.image': 'fa-kit fa-light-image-sparkle-tr',
|
|
35
|
+
'ai.component': AiGradientComponent,
|
|
35
36
|
'ai.text': 'fa-kit fa-light-text-sparkle-tr',
|
|
36
37
|
'ai.file': 'fa-kit fa-light-file-lines-sparkle',
|
|
37
38
|
sparkles: 'fa-solid fa-sparkles',
|
|
@@ -870,3 +871,17 @@ function AiGradientIcon() {
|
|
|
870
871
|
/>
|
|
871
872
|
);
|
|
872
873
|
}
|
|
874
|
+
|
|
875
|
+
function AiGradientComponent() {
|
|
876
|
+
return (
|
|
877
|
+
<i
|
|
878
|
+
className="fa-kit fa-light-cube-sparkle-tr"
|
|
879
|
+
style={{
|
|
880
|
+
background: 'linear-gradient(208deg, #B38FFF 31.76%, #2AEEE1 123.33%)',
|
|
881
|
+
backgroundClip: 'text',
|
|
882
|
+
WebkitTextFillColor: 'transparent',
|
|
883
|
+
lineHeight: 'inherit',
|
|
884
|
+
}}
|
|
885
|
+
/>
|
|
886
|
+
);
|
|
887
|
+
}
|