@vev/silke 1.1.10 → 1.2.1
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/.turbo/turbo-build.log +162 -77
- package/CHANGELOG.md +41 -0
- package/dist/index.js +44 -41
- package/dist/index.js.LEGAL.txt +1 -1
- package/dist/index.js.map +7 -0
- package/dist/styles.css +1596 -1013
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/silke-autocomplete-field/autocomplete-item.d.ts +1 -1
- package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field-native.d.ts +5 -0
- package/dist/types/components/silke-box/silke-box.d.ts +2 -0
- package/dist/types/components/silke-button/silke-dropdown-button.d.ts +3 -1
- package/dist/types/components/silke-card/silke-card-grid.d.ts +1 -0
- package/dist/types/components/silke-card/silke-card.d.ts +1 -0
- package/dist/types/components/silke-command-text-field/index.d.ts +1 -1
- package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +16 -0
- package/dist/types/components/silke-command-text-field/utils.d.ts +25 -0
- package/dist/types/components/silke-css-number-field/silke-css-number-field.spec.d.ts +1 -0
- package/dist/types/components/silke-expression-input/index.d.ts +3 -0
- package/dist/types/components/silke-expression-input/silke-expression-input-tag.d.ts +6 -0
- package/dist/types/components/silke-expression-input/silke-expression-input.d.ts +29 -0
- package/dist/types/components/silke-expression-input/utils.d.ts +18 -0
- package/dist/types/components/silke-form-schema/fields/array-field-inline.d.ts +2 -1
- package/dist/types/components/silke-form-schema/fields/array-field-modal.d.ts +2 -1
- package/dist/types/components/silke-form-schema/fields/array-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/group-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/layout-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/object-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/popover-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/string-field.d.ts +1 -1
- package/dist/types/components/silke-form-schema/fields/utils/generate-preview.spec.d.ts +1 -0
- package/dist/types/components/silke-form-schema/fields/utils/generate-title.d.ts +10 -0
- package/dist/types/components/silke-form-schema/index.d.ts +1 -0
- package/dist/types/components/silke-form-schema/silke-form-schema.d.ts +4 -1
- package/dist/types/components/silke-form-schema/silke-schema-decorator.d.ts +17 -0
- package/dist/types/components/silke-form-schema/silke-schema-field.d.ts +2 -1
- package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +2 -0
- package/dist/types/components/silke-form-schema/silke-schema-path.spec.d.ts +1 -0
- package/dist/types/components/silke-gradient-picker/silke-gradient-utils.d.ts +2 -0
- package/dist/types/components/silke-icon-picker/color-swatch-section.d.ts +6 -0
- package/dist/types/components/silke-icon-picker/emoji-tab.d.ts +1 -1
- package/dist/types/components/silke-icon-picker/icons-tab.d.ts +1 -1
- package/dist/types/components/silke-icon-picker/silke-icon-picker.d.ts +2 -0
- package/dist/types/components/silke-icon-picker/utils.d.ts +2 -0
- package/dist/types/components/silke-list/silke-list-item.d.ts +5 -1
- package/dist/types/components/silke-list/types.d.ts +1 -0
- package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +15 -0
- package/dist/types/components/silke-popover/popover-context.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/blockquote.d.ts +21 -0
- package/dist/types/components/silke-rich-text-field/blockquote.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/dropcap.d.ts +27 -0
- package/dist/types/components/silke-rich-text-field/dropcap.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/floating-layer.d.ts +12 -0
- package/dist/types/components/silke-rich-text-field/font-size.d.ts +2 -0
- package/dist/types/components/silke-rich-text-field/formatting-toolbar.d.ts +9 -0
- package/dist/types/components/silke-rich-text-field/index.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/jsdom-rects.d.ts +10 -0
- package/dist/types/components/silke-rich-text-field/link-menu.d.ts +26 -0
- package/dist/types/components/silke-rich-text-field/link-menu.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/link-suggestions.d.ts +48 -0
- package/dist/types/components/silke-rich-text-field/link-suggestions.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/link-tooltip.d.ts +15 -0
- package/dist/types/components/silke-rich-text-field/list-item.d.ts +15 -0
- package/dist/types/components/silke-rich-text-field/list-link-fontsize.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/lorem-ipsum.d.ts +10 -0
- package/dist/types/components/silke-rich-text-field/lorem-ipsum.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/paste.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/paste.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/plugins.d.ts +18 -0
- package/dist/types/components/silke-rich-text-field/plugins.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/silke-rich-text-field.d.ts +60 -0
- package/dist/types/components/silke-rich-text-field/slash-menu-items.d.ts +10 -0
- package/dist/types/components/silke-rich-text-field/slash-menu.d.ts +11 -0
- package/dist/types/components/silke-rich-text-field/table-content-sync.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/table-toolbar.d.ts +17 -0
- package/dist/types/components/silke-rich-text-field/table-toolbar.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/table.spec.d.ts +1 -0
- package/dist/types/components/silke-rich-text-field/use-link-hover.d.ts +15 -0
- package/dist/types/components/silke-rich-text-field/use-slash-menu.d.ts +13 -0
- package/dist/types/components/silke-rich-text-field/utils.d.ts +13 -0
- package/dist/types/components/silke-sortable-list/index.d.ts +1 -1
- package/dist/types/components/silke-sortable-list/silke-nested-sortable-list.d.ts +8 -1
- package/dist/types/components/silke-theme-card/silke-theme-card.d.ts +13 -6
- package/dist/types/components/silke-theme-swatch/silke-theme-swatch.d.ts +6 -1
- package/dist/types/icons.d.ts +16 -0
- package/esbuild.config.mjs +9 -4
- package/package.json +22 -9
- package/src/components/index.ts +2 -0
- package/src/components/silke-alert-banner/silke-alert-banner.tsx +1 -1
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +47 -61
- package/src/components/silke-autocomplete-field/silke-autocomplete-field-native.tsx +13 -2
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +8 -5
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +2 -1
- package/src/components/silke-box/silke-box.scss +4 -0
- package/src/components/silke-box/silke-box.tsx +4 -0
- package/src/components/silke-button/silke-dropdown-button.tsx +4 -1
- package/src/components/silke-card/silke-card.scss +4 -0
- package/src/components/silke-card/silke-card.tsx +3 -0
- package/src/components/silke-command-text-field/index.ts +1 -0
- package/src/components/silke-command-text-field/silke-command-parser.spec.ts +55 -0
- package/src/components/silke-command-text-field/silke-command-parser.ts +33 -2
- package/src/components/silke-command-text-field/silke-command-text-field.module.scss +3 -0
- package/src/components/silke-command-text-field/silke-command-text-field.tsx +53 -48
- package/src/components/silke-command-text-field/utils.spec.ts +192 -0
- package/src/components/silke-command-text-field/utils.ts +99 -16
- package/src/components/silke-css-number-field/silke-css-number-field.spec.tsx +115 -0
- package/src/components/silke-css-number-field/silke-css-number-field.tsx +33 -0
- package/src/components/silke-expression-input/index.ts +3 -0
- package/src/components/silke-expression-input/silke-expression-input-tag.tsx +37 -0
- package/src/components/silke-expression-input/silke-expression-input.mdx +40 -0
- package/src/components/silke-expression-input/silke-expression-input.scss +24 -0
- package/src/components/silke-expression-input/silke-expression-input.tsx +343 -0
- package/src/components/silke-expression-input/utils.ts +144 -0
- package/src/components/silke-form-schema/fields/array-field-inline.tsx +4 -0
- package/src/components/silke-form-schema/fields/array-field-modal.tsx +4 -0
- package/src/components/silke-form-schema/fields/array-field.tsx +6 -11
- package/src/components/silke-form-schema/fields/group-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/layout-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/object-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/popover-field.tsx +2 -0
- package/src/components/silke-form-schema/fields/string-field.tsx +33 -5
- package/src/components/silke-form-schema/fields/utils/generate-image.ts +5 -14
- package/src/components/silke-form-schema/fields/utils/generate-preview.spec.ts +49 -0
- package/src/components/silke-form-schema/fields/utils/generate-title.ts +23 -10
- package/src/components/silke-form-schema/index.ts +1 -0
- package/src/components/silke-form-schema/silke-form-schema.mdx +30 -1
- package/src/components/silke-form-schema/silke-form-schema.tsx +12 -6
- package/src/components/silke-form-schema/silke-schema-decorator.tsx +32 -0
- package/src/components/silke-form-schema/silke-schema-field.tsx +19 -2
- package/src/components/silke-form-schema/silke-schema-fields.tsx +30 -4
- package/src/components/silke-form-schema/silke-schema-path.spec.tsx +160 -0
- package/src/components/silke-gradient-picker/silke-gradient-picker.tsx +3 -1
- package/src/components/silke-gradient-picker/silke-gradient-utils.ts +23 -3
- package/src/components/silke-icon/silke-shape.tsx +1 -1
- package/src/components/silke-icon-picker/color-swatch-section.tsx +61 -0
- package/src/components/silke-icon-picker/emoji-tab.tsx +8 -6
- package/src/components/silke-icon-picker/icons-tab.tsx +8 -7
- package/src/components/silke-icon-picker/silke-icon-picker.tsx +52 -25
- package/src/components/silke-icon-picker/styles.scss +66 -1
- package/src/components/silke-icon-picker/utils.ts +2 -0
- package/src/components/silke-list/silke-list-item.scss +10 -0
- package/src/components/silke-list/silke-list-item.tsx +16 -3
- package/src/components/silke-list/silke-list.mdx +18 -0
- package/src/components/silke-list/types.ts +1 -0
- package/src/components/silke-navigation-link/silke-navigation-link.scss +162 -42
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +99 -21
- package/src/components/silke-popover/popover-context.spec.tsx +44 -0
- package/src/components/silke-popover-native/silke-popover-native.scss +5 -3
- package/src/components/silke-rich-text-field/blockquote.spec.ts +151 -0
- package/src/components/silke-rich-text-field/blockquote.ts +90 -0
- package/src/components/silke-rich-text-field/dropcap.spec.ts +67 -0
- package/src/components/silke-rich-text-field/dropcap.ts +59 -0
- package/src/components/silke-rich-text-field/floating-layer.tsx +15 -0
- package/src/components/silke-rich-text-field/font-size.ts +62 -0
- package/src/components/silke-rich-text-field/formatting-toolbar.tsx +145 -0
- package/src/components/silke-rich-text-field/index.ts +1 -0
- package/src/components/silke-rich-text-field/jsdom-rects.ts +15 -0
- package/src/components/silke-rich-text-field/link-menu.spec.tsx +502 -0
- package/src/components/silke-rich-text-field/link-menu.tsx +553 -0
- package/src/components/silke-rich-text-field/link-suggestions.spec.ts +203 -0
- package/src/components/silke-rich-text-field/link-suggestions.ts +188 -0
- package/src/components/silke-rich-text-field/link-tooltip.tsx +60 -0
- package/src/components/silke-rich-text-field/list-item.ts +64 -0
- package/src/components/silke-rich-text-field/list-link-fontsize.spec.ts +135 -0
- package/src/components/silke-rich-text-field/lorem-ipsum.spec.ts +131 -0
- package/src/components/silke-rich-text-field/lorem-ipsum.ts +51 -0
- package/src/components/silke-rich-text-field/paste.spec.ts +93 -0
- package/src/components/silke-rich-text-field/paste.ts +39 -0
- package/src/components/silke-rich-text-field/plugins.spec.ts +143 -0
- package/src/components/silke-rich-text-field/plugins.ts +230 -0
- package/src/components/silke-rich-text-field/silke-rich-text-field.mdx +180 -0
- package/src/components/silke-rich-text-field/silke-rich-text-field.scss +343 -0
- package/src/components/silke-rich-text-field/silke-rich-text-field.tsx +505 -0
- package/src/components/silke-rich-text-field/slash-menu-items.ts +112 -0
- package/src/components/silke-rich-text-field/slash-menu.tsx +50 -0
- package/src/components/silke-rich-text-field/table-content-sync.spec.tsx +61 -0
- package/src/components/silke-rich-text-field/table-toolbar.spec.tsx +168 -0
- package/src/components/silke-rich-text-field/table-toolbar.tsx +121 -0
- package/src/components/silke-rich-text-field/table.spec.ts +87 -0
- package/src/components/silke-rich-text-field/use-link-hover.ts +63 -0
- package/src/components/silke-rich-text-field/use-slash-menu.ts +130 -0
- package/src/components/silke-rich-text-field/utils.ts +55 -0
- package/src/components/silke-sortable-list/index.ts +1 -1
- package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +11 -1
- package/src/components/silke-sortable-list/silke-nested-sortable-list.tsx +9 -0
- package/src/components/silke-sortable-list/silke-sortable-list.mdx +13 -0
- package/src/components/silke-tag/silke-tag.scss +12 -3
- package/src/components/silke-theme-card/silke-theme-card.module.scss +141 -45
- package/src/components/silke-theme-card/silke-theme-card.tsx +76 -47
- package/src/components/silke-theme-swatch/silke-theme-swatch.mdx +56 -0
- package/src/components/silke-theme-swatch/silke-theme-swatch.module.scss +53 -63
- package/src/components/silke-theme-swatch/silke-theme-swatch.tsx +99 -14
- package/src/icons.tsx +51 -5
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SchemaFieldProps, StringField as StringFieldType } from '@vev/utils';
|
|
2
|
-
import React, { useRef, useState } from 'react';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { SilkeTextField } from '../../silke-text-field';
|
|
4
|
+
import { SilkeRichTextField } from '../../silke-rich-text-field';
|
|
4
5
|
import { getTitle } from './utils/schema-util';
|
|
5
6
|
import { SilkeBox } from '../../silke-box';
|
|
6
7
|
import { SilkeText, SilkeTextSmall } from '../../silke-text';
|
|
@@ -15,9 +16,19 @@ const StringField = ({
|
|
|
15
16
|
disabled,
|
|
16
17
|
readonly,
|
|
17
18
|
onChange,
|
|
19
|
+
context,
|
|
18
20
|
}: SchemaFieldProps<StringFieldType>) => {
|
|
19
21
|
const { options } = schema;
|
|
20
22
|
|
|
23
|
+
const [linkItems, setLinkItems] = useState<
|
|
24
|
+
{ label: string; value: string; icon?: any; subLabel?: string }[]
|
|
25
|
+
>([]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (options?.html && context?.actions?.availableLinks) {
|
|
28
|
+
Promise.resolve(context.actions.availableLinks()).then(setLinkItems);
|
|
29
|
+
}
|
|
30
|
+
}, [options?.html, context?.actions?.availableLinks]);
|
|
31
|
+
|
|
21
32
|
const textFieldRef = useRef(null);
|
|
22
33
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
23
34
|
|
|
@@ -27,7 +38,7 @@ const StringField = ({
|
|
|
27
38
|
return suggestion.value === `${value}`;
|
|
28
39
|
});
|
|
29
40
|
|
|
30
|
-
if (schema.options?.suggestions && schema.options?.suggestions.length) {
|
|
41
|
+
if (!schema.secret && schema.options?.suggestions && schema.options?.suggestions.length) {
|
|
31
42
|
if (suggestion) {
|
|
32
43
|
return (
|
|
33
44
|
<SilkeBox column>
|
|
@@ -52,6 +63,23 @@ const StringField = ({
|
|
|
52
63
|
}
|
|
53
64
|
}
|
|
54
65
|
|
|
66
|
+
if (!schema.secret && options?.html) {
|
|
67
|
+
return (
|
|
68
|
+
<SilkeRichTextField
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
readOnly={readonly}
|
|
71
|
+
value={value || ''}
|
|
72
|
+
label={getTitle(schema)}
|
|
73
|
+
placeholder={options?.placeholder}
|
|
74
|
+
onChange={onChange}
|
|
75
|
+
linkItems={linkItems.length > 0 ? linkItems : undefined}
|
|
76
|
+
kind="zombie"
|
|
77
|
+
size="s"
|
|
78
|
+
flex
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
55
83
|
return (
|
|
56
84
|
<SilkeBox>
|
|
57
85
|
<SilkeTextField
|
|
@@ -59,10 +87,10 @@ const StringField = ({
|
|
|
59
87
|
disabled={disabled}
|
|
60
88
|
readOnly={readonly}
|
|
61
89
|
value={value || ''}
|
|
62
|
-
multiline={!!options?.multiline}
|
|
90
|
+
multiline={!schema.secret && !!options?.multiline}
|
|
63
91
|
style={{}}
|
|
64
92
|
label={getTitle(schema)}
|
|
65
|
-
type={options?.type || 'text'}
|
|
93
|
+
type={schema.secret ? 'password' : options?.type || 'text'}
|
|
66
94
|
minLength={options?.minLength}
|
|
67
95
|
maxLength={options?.maxLength}
|
|
68
96
|
onChange={onChange}
|
|
@@ -79,7 +107,7 @@ const StringField = ({
|
|
|
79
107
|
}
|
|
80
108
|
}}
|
|
81
109
|
/>
|
|
82
|
-
{showSuggestions && schema.options?.suggestions && (
|
|
110
|
+
{!schema.secret && showSuggestions && schema.options?.suggestions && (
|
|
83
111
|
<SilkePopover
|
|
84
112
|
anchorOrigin="bottom-center"
|
|
85
113
|
targetOrigin="top-center"
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { isObject,
|
|
2
|
+
import { isObject, isArray } from 'lodash';
|
|
3
3
|
import { VevProps } from '@vev/utils';
|
|
4
|
-
import { flattenObject } from './generate-title';
|
|
4
|
+
import { flattenObject, getPreview } from './generate-title';
|
|
5
5
|
|
|
6
6
|
export const generateImage = (
|
|
7
7
|
data: VevProps | VevProps[] | string,
|
|
8
8
|
schema?: VevProps | VevProps[] | string,
|
|
9
9
|
): string | ReactNode | undefined => {
|
|
10
|
-
let image
|
|
11
|
-
|
|
12
|
-
if (Array.isArray(schema)) schema = schema.find((s) => s.preview) || schema[0];
|
|
13
|
-
|
|
14
|
-
if (isObject(schema) && schema?.preview) {
|
|
15
|
-
if (isFunction(schema.preview)) {
|
|
16
|
-
({ image } = schema.preview(data as VevProps));
|
|
17
|
-
} else {
|
|
18
|
-
image = schema?.preview?.image;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
10
|
+
let { image } = getPreview(data, schema);
|
|
21
11
|
|
|
22
12
|
if (!image) {
|
|
23
|
-
|
|
13
|
+
// Items can be null (or a primitive) in stored content — only objects have values to scan.
|
|
14
|
+
const values = isArray(data) ? data : isObject(data) ? flattenObject(data) : [];
|
|
24
15
|
|
|
25
16
|
for (const value of values) {
|
|
26
17
|
const data: string[] = Object.values(value || {}) as string[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { VevProps } from '@vev/utils';
|
|
2
|
+
import { generateImage } from './generate-image';
|
|
3
|
+
import { generateTitle } from './generate-title';
|
|
4
|
+
|
|
5
|
+
const cardsSchema = (preview: any) =>
|
|
6
|
+
({
|
|
7
|
+
type: 'array',
|
|
8
|
+
name: 'cards',
|
|
9
|
+
of: 'object',
|
|
10
|
+
fields: [
|
|
11
|
+
{ type: 'image', name: 'image' },
|
|
12
|
+
{ type: 'string', name: 'title' },
|
|
13
|
+
],
|
|
14
|
+
preview,
|
|
15
|
+
}) as VevProps;
|
|
16
|
+
|
|
17
|
+
describe('array item preview', () => {
|
|
18
|
+
beforeEach(() => jest.spyOn(console, 'warn').mockImplementation(() => undefined));
|
|
19
|
+
afterEach(() => jest.restoreAllMocks());
|
|
20
|
+
|
|
21
|
+
it('uses the preview function when it succeeds', () => {
|
|
22
|
+
const schema = cardsSchema((item: any) => ({ title: item.title, image: item.image.url }));
|
|
23
|
+
const item = { title: 'Paris', image: { url: 'https://cdn/paris.jpg' } };
|
|
24
|
+
|
|
25
|
+
expect(generateTitle(item, schema)).toBe('Paris');
|
|
26
|
+
expect(generateImage(item as any, schema)).toBe('https://cdn/paris.jpg');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('falls back to the item values when the preview function throws', () => {
|
|
30
|
+
const schema = cardsSchema((item: any) => ({ title: item.title, image: item.image.url }));
|
|
31
|
+
const item = { title: 'Card without image' };
|
|
32
|
+
|
|
33
|
+
expect(generateTitle(item, schema)).toBe('Card without image');
|
|
34
|
+
expect(generateImage(item as any, schema)).toBeUndefined();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('falls back to the item values when the preview function returns nothing', () => {
|
|
38
|
+
const schema = cardsSchema(() => undefined);
|
|
39
|
+
const item = { title: 'Rome' };
|
|
40
|
+
|
|
41
|
+
expect(generateTitle(item, schema)).toBe('Rome');
|
|
42
|
+
expect(generateImage(item as any, schema)).toBeUndefined();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('handles null items without a preview', () => {
|
|
46
|
+
expect(generateTitle(null as any, 'object')).toBe('Unknown');
|
|
47
|
+
expect(generateImage(null as any, 'object')).toBeUndefined();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { isObject, capitalize, isFunction } from 'lodash';
|
|
2
3
|
import { VevProps } from '@vev/utils';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the schema's `preview` for an array item. A `preview` function is component code
|
|
7
|
+
* (often AI-generated) that runs for every item as soon as the list renders, so a throw or a
|
|
8
|
+
* missing return value falls back to the derived title/image instead of crashing the form.
|
|
9
|
+
*/
|
|
10
|
+
export const getPreview = (
|
|
11
|
+
data: any,
|
|
6
12
|
schema?: VevProps | VevProps[] | string,
|
|
7
|
-
): string |
|
|
13
|
+
): { title?: string; image?: string | ReactNode } => {
|
|
8
14
|
if (Array.isArray(schema)) schema = schema.find((s) => s.preview) || schema[0];
|
|
9
|
-
|
|
15
|
+
if (!isObject(schema) || !schema.preview) return {};
|
|
16
|
+
if (!isFunction(schema.preview)) return schema.preview;
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
18
|
+
try {
|
|
19
|
+
return schema.preview(data) || {};
|
|
20
|
+
} catch (e) {
|
|
21
|
+
console.warn(`Failed to generate preview for "${schema.name}"`, e);
|
|
22
|
+
return {};
|
|
17
23
|
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const generateTitle = (
|
|
27
|
+
data: { [key: string]: any } | { [key: string]: any }[] | string,
|
|
28
|
+
schema?: VevProps | VevProps[] | string,
|
|
29
|
+
): string | undefined => {
|
|
30
|
+
let { title } = getPreview(data, schema);
|
|
18
31
|
|
|
19
32
|
if (!title) {
|
|
20
33
|
if (typeof data === 'string' || typeof data === 'number') return data.toString();
|
|
@@ -91,6 +91,35 @@ const [value, setValue] = React.useState({});
|
|
|
91
91
|
</div>;
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
## Rich text field
|
|
95
|
+
|
|
96
|
+
Use `options.html: true` on a string field to render a rich text editor with formatting support (bold, italic, headings, lists, blockquotes, code blocks, links, and dividers). The value is stored as an HTML string.
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
const schema = [
|
|
100
|
+
{
|
|
101
|
+
type: 'string',
|
|
102
|
+
name: 'bio',
|
|
103
|
+
title: 'Bio',
|
|
104
|
+
options: { html: true, placeholder: 'Tell us about yourself...' },
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'string',
|
|
108
|
+
name: 'notes',
|
|
109
|
+
title: 'Notes',
|
|
110
|
+
options: { html: true, placeholder: 'Meeting notes...' },
|
|
111
|
+
initialValue: '<h2>Agenda</h2><ul><li>Review design tokens</li><li>Ship rich text field</li></ul>',
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
const [value, setValue] = React.useState({});
|
|
116
|
+
|
|
117
|
+
<div style={{ width: '300px' }}>
|
|
118
|
+
<SilkeFormSchema schema={schema} value={value} onChange={setValue} context={{}} />
|
|
119
|
+
<pre>{JSON.stringify(value, null, 2)}</pre>
|
|
120
|
+
</div>;
|
|
121
|
+
```
|
|
122
|
+
|
|
94
123
|
## Select fields
|
|
95
124
|
|
|
96
125
|
Dropdown, radio, checkbox, and autocomplete selection.
|
|
@@ -410,7 +439,7 @@ const schema = [
|
|
|
410
439
|
type: 'string',
|
|
411
440
|
name: 'body',
|
|
412
441
|
title: 'Body Text',
|
|
413
|
-
options: {
|
|
442
|
+
options: { html: true, placeholder: 'Enter body text...' },
|
|
414
443
|
},
|
|
415
444
|
{ type: 'link', name: 'ctaLink', title: 'CTA Link' },
|
|
416
445
|
{
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { SilkeForm, SilkeFormProps } from '../silke-form';
|
|
4
4
|
import TextFieldContext from '../silke-text-field/text-field-context';
|
|
5
5
|
import { SilkeSchemaContext } from './silke-schema-context';
|
|
6
|
+
import { SilkeSchemaDecoratorProvider, SilkeSchemaFieldDecorator } from './silke-schema-decorator';
|
|
6
7
|
import { SilkeSchemaFields } from './silke-schema-fields';
|
|
7
8
|
import { SilkeTextFieldOutlineProps } from '../silke-text-field/silke-text-field-outline';
|
|
8
9
|
|
|
@@ -15,6 +16,8 @@ type SilkeFormSchemaProps<T extends { [key: string]: any }> = {
|
|
|
15
16
|
readonly?: boolean;
|
|
16
17
|
disabled?: boolean;
|
|
17
18
|
variables?: LocalVariable[];
|
|
19
|
+
/** Renders extra UI beside every field, eg a per-breakpoint status dot. */
|
|
20
|
+
fieldDecorator?: SilkeSchemaFieldDecorator;
|
|
18
21
|
} & SilkeFormProps<T>;
|
|
19
22
|
|
|
20
23
|
// pages?: { title: string; key: string; path?: string }[];
|
|
@@ -25,15 +28,18 @@ export function SilkeFormSchema<T extends { [key: string]: any }>({
|
|
|
25
28
|
value,
|
|
26
29
|
context,
|
|
27
30
|
inline = false,
|
|
31
|
+
fieldDecorator,
|
|
28
32
|
...rest
|
|
29
33
|
}: SilkeFormSchemaProps<T>) {
|
|
30
34
|
return (
|
|
31
|
-
<SilkeSchemaContext context={context}>
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
<SilkeSchemaContext context={{ ...context, value: context.value ?? value }}>
|
|
36
|
+
<SilkeSchemaDecoratorProvider decorator={fieldDecorator}>
|
|
37
|
+
<SilkeForm {...rest} value={value}>
|
|
38
|
+
<TextFieldContext size="s" kind="default" inline={inline}>
|
|
39
|
+
<SilkeSchemaFields schema={schema} value={value} {...rest} />
|
|
40
|
+
</TextFieldContext>
|
|
41
|
+
</SilkeForm>
|
|
42
|
+
</SilkeSchemaDecoratorProvider>
|
|
37
43
|
</SilkeSchemaContext>
|
|
38
44
|
);
|
|
39
45
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { VevProps } from '@vev/utils';
|
|
2
|
+
import React, { createContext, ReactNode, useContext } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Renders extra UI beside a schema field — a status dot, a badge, a menu.
|
|
6
|
+
*
|
|
7
|
+
* `path` is the field's address inside the form value, eg `slides.1.label`, so
|
|
8
|
+
* the decorator can look the field's stored value up. It is undefined when the
|
|
9
|
+
* form was rendered without a path.
|
|
10
|
+
*/
|
|
11
|
+
export type SilkeSchemaFieldDecorator = (field: VevProps, path?: string) => ReactNode;
|
|
12
|
+
|
|
13
|
+
const DecoratorContext = createContext<SilkeSchemaFieldDecorator | undefined>(undefined);
|
|
14
|
+
|
|
15
|
+
export function SilkeSchemaDecoratorProvider({
|
|
16
|
+
decorator,
|
|
17
|
+
children,
|
|
18
|
+
}: {
|
|
19
|
+
decorator?: SilkeSchemaFieldDecorator;
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}) {
|
|
22
|
+
return <DecoratorContext.Provider value={decorator}>{children}</DecoratorContext.Provider>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useSchemaFieldDecorator(): SilkeSchemaFieldDecorator | undefined {
|
|
26
|
+
return useContext(DecoratorContext);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Joins a parent path with a field name or an array index. */
|
|
30
|
+
export function joinSchemaPath(path: string | undefined, segment: string | number): string {
|
|
31
|
+
return path === undefined ? String(segment) : `${path}.${segment}`;
|
|
32
|
+
}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { safeEvalFunction } from './safe-eval';
|
|
12
12
|
import { isEvalCallback } from './schema-utils';
|
|
13
13
|
import { useSchemaContext } from './silke-schema-context';
|
|
14
|
+
import { useSchemaFieldDecorator } from './silke-schema-decorator';
|
|
14
15
|
import { SilkeDivider } from '../silke-divider';
|
|
15
16
|
|
|
16
17
|
import ArrayField from './fields/array-field';
|
|
@@ -39,6 +40,7 @@ type SilkeSchemaFieldProps = {
|
|
|
39
40
|
disabled?: boolean;
|
|
40
41
|
readonly?: boolean;
|
|
41
42
|
itemIndex?: number;
|
|
43
|
+
path?: string;
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
const SCHEMA_FIELD_COMPONENTS: Partial<SchemaFieldComponents> = {
|
|
@@ -69,8 +71,10 @@ export function SilkeSchemaField({
|
|
|
69
71
|
disabled,
|
|
70
72
|
readonly,
|
|
71
73
|
itemIndex,
|
|
74
|
+
path,
|
|
72
75
|
}: SilkeSchemaFieldProps) {
|
|
73
76
|
const extendedFields = useExtendedFields();
|
|
77
|
+
const decorator = useSchemaFieldDecorator();
|
|
74
78
|
|
|
75
79
|
const { value, onChange } = useFormField({ name: field?.name, value: fieldValue });
|
|
76
80
|
|
|
@@ -99,11 +103,17 @@ export function SilkeSchemaField({
|
|
|
99
103
|
|
|
100
104
|
const getVariableType = (field: VevProps) => {
|
|
101
105
|
if (field.component) return 'none';
|
|
102
|
-
if (
|
|
106
|
+
if (
|
|
107
|
+
field.type === 'number' &&
|
|
108
|
+
(field.options?.display === 'slider' || field.options?.display === 'range-slider')
|
|
109
|
+
)
|
|
110
|
+
return 'none';
|
|
103
111
|
if (field.type === 'string') return 'text';
|
|
104
112
|
return field.type;
|
|
105
113
|
};
|
|
106
114
|
|
|
115
|
+
const decoration = decorator?.(field, path);
|
|
116
|
+
|
|
107
117
|
return (
|
|
108
118
|
<>
|
|
109
119
|
{['object', 'divider'].includes(field?.type) && !isFirst && (
|
|
@@ -111,7 +121,12 @@ export function SilkeSchemaField({
|
|
|
111
121
|
<SilkeDivider dark />
|
|
112
122
|
</SilkeBox>
|
|
113
123
|
)}
|
|
114
|
-
<SilkeBox
|
|
124
|
+
<SilkeBox
|
|
125
|
+
hPad={!noPad ? 'm' : undefined}
|
|
126
|
+
flex
|
|
127
|
+
vAlign={decoration ? 'end' : undefined}
|
|
128
|
+
gap={decoration ? 'xs' : undefined}
|
|
129
|
+
>
|
|
115
130
|
<SilkeVariablesWrapper
|
|
116
131
|
component={Field}
|
|
117
132
|
disabled={disabled}
|
|
@@ -125,6 +140,7 @@ export function SilkeSchemaField({
|
|
|
125
140
|
context={context}
|
|
126
141
|
help={field.description}
|
|
127
142
|
itemIndex={itemIndex}
|
|
143
|
+
path={path}
|
|
128
144
|
onChange={async (value: any) => {
|
|
129
145
|
if (isEvalCallback(field.onChange)) {
|
|
130
146
|
value = await safeEvalFunction(field.onChange.value, value, context);
|
|
@@ -135,6 +151,7 @@ export function SilkeSchemaField({
|
|
|
135
151
|
onChange(value);
|
|
136
152
|
}}
|
|
137
153
|
/>
|
|
154
|
+
{decoration}
|
|
138
155
|
</SilkeBox>
|
|
139
156
|
</>
|
|
140
157
|
);
|
|
@@ -5,6 +5,18 @@ import { SilkeSchemaField } from './silke-schema-field';
|
|
|
5
5
|
import { SilkeBox } from '../silke-box';
|
|
6
6
|
import { isFunction } from 'lodash';
|
|
7
7
|
import { useSchemaContext } from './silke-schema-context';
|
|
8
|
+
import { joinSchemaPath } from './silke-schema-decorator';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* layout, group, popover and divider render their children into the parent
|
|
12
|
+
* value, so they do not add a segment of their own.
|
|
13
|
+
*/
|
|
14
|
+
const TRANSPARENT_TYPES = ['layout', 'group', 'popover', 'divider'];
|
|
15
|
+
|
|
16
|
+
function getFieldPath(path: string | undefined, field: VevProps): string | undefined {
|
|
17
|
+
if (!field?.name || TRANSPARENT_TYPES.includes(field.type)) return path;
|
|
18
|
+
return joinSchemaPath(path, field.name);
|
|
19
|
+
}
|
|
8
20
|
|
|
9
21
|
type SilkeSchemaFieldsProps<T extends { [key: string]: any }> = {
|
|
10
22
|
schema: VevProps[];
|
|
@@ -13,18 +25,20 @@ type SilkeSchemaFieldsProps<T extends { [key: string]: any }> = {
|
|
|
13
25
|
disabled?: boolean;
|
|
14
26
|
readonly?: boolean;
|
|
15
27
|
itemIndex?: number;
|
|
28
|
+
/** Address of the object these fields write into, eg `slides.1`. */
|
|
29
|
+
path?: string;
|
|
16
30
|
} & SilkeFormProps<T>;
|
|
17
31
|
|
|
18
32
|
export function SilkeSchemaFields<T extends { [key: string]: any }>(
|
|
19
33
|
props: SilkeSchemaFieldsProps<T>,
|
|
20
34
|
) {
|
|
21
|
-
const { schema = [], row, ...rest } = props;
|
|
35
|
+
const { schema = [], row, path, ...rest } = props;
|
|
22
36
|
const context = useSchemaContext();
|
|
23
37
|
const [filteredSchema, setFilteredSchema] = useState(schema);
|
|
24
38
|
|
|
25
39
|
// Filter hidden fields here, so they don't use any space in the sidebar
|
|
26
40
|
useEffect(() => {
|
|
27
|
-
const ctxWithValue = { ...context, value:
|
|
41
|
+
const ctxWithValue = { ...context, value: context.value ?? rest?.value };
|
|
28
42
|
const isHidden = async (field: VevProps) => {
|
|
29
43
|
if (isFunction(field?.hidden)) {
|
|
30
44
|
return await field?.hidden(ctxWithValue, rest?.itemIndex);
|
|
@@ -49,14 +63,26 @@ export function SilkeSchemaFields<T extends { [key: string]: any }>(
|
|
|
49
63
|
}, [context, schema, rest?.itemIndex, rest?.value]);
|
|
50
64
|
|
|
51
65
|
return (
|
|
52
|
-
<SilkeBox
|
|
66
|
+
<SilkeBox
|
|
67
|
+
flex
|
|
68
|
+
column={!row}
|
|
69
|
+
gap="s"
|
|
70
|
+
vPad={row ? undefined : 's'}
|
|
71
|
+
vAlign={row ? 'end' : undefined}
|
|
72
|
+
style={{ width: '100%' }}
|
|
73
|
+
>
|
|
53
74
|
{filteredSchema.map((field, index) => {
|
|
54
75
|
return (
|
|
55
76
|
<span
|
|
56
77
|
key={(field?.name || 'field') + index}
|
|
57
78
|
style={field?.flex ? { flex: 1, minWidth: 0 } : undefined}
|
|
58
79
|
>
|
|
59
|
-
<SilkeSchemaField
|
|
80
|
+
<SilkeSchemaField
|
|
81
|
+
field={field}
|
|
82
|
+
{...rest}
|
|
83
|
+
path={getFieldPath(path, field)}
|
|
84
|
+
isFirst={index === 0}
|
|
85
|
+
/>
|
|
60
86
|
</span>
|
|
61
87
|
);
|
|
62
88
|
})}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { act, fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import { SchemaContextModel, VevProps } from '@vev/utils';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { SilkeFormSchema } from './silke-form-schema';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The decorator is the only consumer of a field's path, so recording what it is
|
|
8
|
+
* handed is the way to check the path survives every level of nesting.
|
|
9
|
+
*/
|
|
10
|
+
/** SilkeSchemaFields filters hidden fields in an async effect, so let it settle. */
|
|
11
|
+
const settle = () => act(async () => undefined);
|
|
12
|
+
|
|
13
|
+
async function renderSchema(schema: VevProps[], value: Record<string, any>) {
|
|
14
|
+
const paths: { name?: string; path?: string }[] = [];
|
|
15
|
+
|
|
16
|
+
render(
|
|
17
|
+
<SilkeFormSchema
|
|
18
|
+
schema={schema}
|
|
19
|
+
value={value}
|
|
20
|
+
context={{ value } as SchemaContextModel}
|
|
21
|
+
fieldDecorator={(field, path) => {
|
|
22
|
+
paths.push({ name: field.name, path });
|
|
23
|
+
return null;
|
|
24
|
+
}}
|
|
25
|
+
/>,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
await settle();
|
|
29
|
+
return paths;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('schema field paths', () => {
|
|
33
|
+
it('uses the field name at the top level', async () => {
|
|
34
|
+
const paths = await renderSchema([{ type: 'number', name: 'columns' }] as VevProps[], {
|
|
35
|
+
columns: 3,
|
|
36
|
+
});
|
|
37
|
+
expect(paths).toContainEqual({ name: 'columns', path: 'columns' });
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('nests under an object field', async () => {
|
|
41
|
+
const schema = [
|
|
42
|
+
{
|
|
43
|
+
type: 'object',
|
|
44
|
+
name: 'padding',
|
|
45
|
+
fields: [{ type: 'number', name: 'top' }],
|
|
46
|
+
},
|
|
47
|
+
] as VevProps[];
|
|
48
|
+
|
|
49
|
+
const paths = await renderSchema(schema, { padding: { top: 24 } });
|
|
50
|
+
expect(paths).toContainEqual({ name: 'top', path: 'padding.top' });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('does not nest under a group, which writes into the parent value', async () => {
|
|
54
|
+
const schema = [
|
|
55
|
+
{
|
|
56
|
+
type: 'group',
|
|
57
|
+
title: 'Advanced',
|
|
58
|
+
fields: [{ type: 'number', name: 'gap' }],
|
|
59
|
+
},
|
|
60
|
+
] as VevProps[];
|
|
61
|
+
|
|
62
|
+
const paths = await renderSchema(schema, { gap: 8 });
|
|
63
|
+
expect(paths).toContainEqual({ name: 'gap', path: 'gap' });
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('does not nest under a layout, which writes into the parent value', async () => {
|
|
67
|
+
const schema = [
|
|
68
|
+
{
|
|
69
|
+
type: 'layout',
|
|
70
|
+
options: { display: 'row' },
|
|
71
|
+
fields: [{ type: 'number', name: 'width' }],
|
|
72
|
+
},
|
|
73
|
+
] as VevProps[];
|
|
74
|
+
|
|
75
|
+
const paths = await renderSchema(schema, { width: 100 });
|
|
76
|
+
expect(paths).toContainEqual({ name: 'width', path: 'width' });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('does not nest under a named group either, because its children still write flat', async () => {
|
|
80
|
+
const schema = [
|
|
81
|
+
{
|
|
82
|
+
type: 'group',
|
|
83
|
+
name: 'advanced',
|
|
84
|
+
title: 'Advanced',
|
|
85
|
+
fields: [{ type: 'number', name: 'gap' }],
|
|
86
|
+
},
|
|
87
|
+
] as VevProps[];
|
|
88
|
+
|
|
89
|
+
const paths = await renderSchema(schema, { gap: 8 });
|
|
90
|
+
expect(paths).toContainEqual({ name: 'gap', path: 'gap' });
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('does not nest under a named layout either', async () => {
|
|
94
|
+
const schema = [
|
|
95
|
+
{
|
|
96
|
+
type: 'layout',
|
|
97
|
+
name: 'row',
|
|
98
|
+
options: { display: 'row' },
|
|
99
|
+
fields: [{ type: 'number', name: 'width' }],
|
|
100
|
+
},
|
|
101
|
+
] as VevProps[];
|
|
102
|
+
|
|
103
|
+
const paths = await renderSchema(schema, { width: 100 });
|
|
104
|
+
expect(paths).toContainEqual({ name: 'width', path: 'width' });
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('nests a group inside an object under the object only', async () => {
|
|
108
|
+
const schema = [
|
|
109
|
+
{
|
|
110
|
+
type: 'object',
|
|
111
|
+
name: 'padding',
|
|
112
|
+
fields: [
|
|
113
|
+
{
|
|
114
|
+
type: 'group',
|
|
115
|
+
title: 'Advanced',
|
|
116
|
+
fields: [{ type: 'number', name: 'top' }],
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
] as VevProps[];
|
|
121
|
+
|
|
122
|
+
const paths = await renderSchema(schema, { padding: { top: 24 } });
|
|
123
|
+
expect(paths).toContainEqual({ name: 'top', path: 'padding.top' });
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe('array item paths', () => {
|
|
128
|
+
const schema = [
|
|
129
|
+
{
|
|
130
|
+
type: 'array',
|
|
131
|
+
name: 'slides',
|
|
132
|
+
of: 'object',
|
|
133
|
+
fields: [{ type: 'string', name: 'label' }],
|
|
134
|
+
},
|
|
135
|
+
] as VevProps[];
|
|
136
|
+
|
|
137
|
+
it('includes the index of the item being edited', async () => {
|
|
138
|
+
const value = { slides: [{ label: 'One' }, { label: 'Two' }] };
|
|
139
|
+
const paths: (string | undefined)[] = [];
|
|
140
|
+
|
|
141
|
+
render(
|
|
142
|
+
<SilkeFormSchema
|
|
143
|
+
schema={schema}
|
|
144
|
+
value={value}
|
|
145
|
+
context={{ value } as SchemaContextModel}
|
|
146
|
+
fieldDecorator={(field, path) => {
|
|
147
|
+
if (field.name === 'label') paths.push(path);
|
|
148
|
+
return null;
|
|
149
|
+
}}
|
|
150
|
+
/>,
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
// The item editor only mounts once an item is opened.
|
|
154
|
+
await settle();
|
|
155
|
+
fireEvent.click(screen.getByText('Two'));
|
|
156
|
+
await settle();
|
|
157
|
+
|
|
158
|
+
expect(paths).toContain('slides.1.label');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
@@ -41,7 +41,9 @@ export function SilkeGradientPicker({ ...props }: SilkeGradientPickerProps) {
|
|
|
41
41
|
|
|
42
42
|
const newGradient = { ...gradient };
|
|
43
43
|
newGradient.stops = newGradient.stops.slice();
|
|
44
|
-
|
|
44
|
+
const next = { ...newGradient.stops[selectedIndex], color };
|
|
45
|
+
if (!color.startsWith('var(')) delete next.opacity;
|
|
46
|
+
newGradient.stops[selectedIndex] = next;
|
|
45
47
|
handleChange(newGradient);
|
|
46
48
|
};
|
|
47
49
|
|