@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
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import React, { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { DisplayToken, tokenizeForDisplay, tokensToExpression } from '@vev/variables';
|
|
3
|
+
import {
|
|
4
|
+
SilkeTextFieldOutline,
|
|
5
|
+
SilkeTextFieldOutlineProps,
|
|
6
|
+
} from '../silke-text-field/silke-text-field-outline';
|
|
7
|
+
import { SilkeBox } from '../silke-box';
|
|
8
|
+
import { SilkeText } from '../silke-text';
|
|
9
|
+
import { SilkeTextFieldItem } from '../silke-text-field';
|
|
10
|
+
import { SilkePopover } from '../silke-popover';
|
|
11
|
+
import { SilkeButton } from '../silke-button';
|
|
12
|
+
import { SilkeConditionsInputOptions } from '../silke-conditions-input/silke-conditions-input-options';
|
|
13
|
+
import { ConditionSuggestion, VevConditionSuggestion } from '../silke-conditions-input';
|
|
14
|
+
import { SilkeExpressionInputTag } from './silke-expression-input-tag';
|
|
15
|
+
import {
|
|
16
|
+
DEFAULT_FUNCTIONS,
|
|
17
|
+
ExpressionSource,
|
|
18
|
+
ExpressionVariable,
|
|
19
|
+
getFunctionFollowupSuggestions,
|
|
20
|
+
getOperandSuggestions,
|
|
21
|
+
getOperatorSuggestions,
|
|
22
|
+
isZeroArgFunction,
|
|
23
|
+
} from './utils';
|
|
24
|
+
import styles from './silke-expression-input.scss';
|
|
25
|
+
|
|
26
|
+
export type SilkeExpressionInputProps = SilkeTextFieldOutlineProps & {
|
|
27
|
+
value: string;
|
|
28
|
+
onChange: (next: string) => void;
|
|
29
|
+
variables?: ExpressionVariable[];
|
|
30
|
+
triggerSources?: ExpressionSource[];
|
|
31
|
+
systemSources?: ExpressionSource[];
|
|
32
|
+
functions?: string[];
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
onClear?: () => void;
|
|
36
|
+
onFocus?: (e: FocusEvent) => void;
|
|
37
|
+
onBlur?: (e: FocusEvent) => void;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const PLACEHOLDER_PATTERN = /^\[\[[^\]]+\]\]$/;
|
|
41
|
+
const NUMERIC_LITERAL_PATTERN = /^-?\d+(\.\d+)?$/;
|
|
42
|
+
const OPERATOR_CHARS = new Set(['+', '-', '*', '/', '^']);
|
|
43
|
+
const PAREN_CHARS = new Set(['(', ')']);
|
|
44
|
+
|
|
45
|
+
// What the user is allowed to enter next, given the tokens entered so far.
|
|
46
|
+
type NextSlot = 'operand' | 'operator' | 'function-open-paren';
|
|
47
|
+
|
|
48
|
+
const nextSlotFor = (tokens: DisplayToken[]): NextSlot => {
|
|
49
|
+
const last = tokens[tokens.length - 1];
|
|
50
|
+
if (!last) return 'operand';
|
|
51
|
+
if (last.type === 'function') return 'function-open-paren';
|
|
52
|
+
if (last.type === 'operator') return 'operand';
|
|
53
|
+
if (last.type === 'paren' && last.value === '(') return 'operand';
|
|
54
|
+
return 'operator';
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const countOpenParens = (tokens: DisplayToken[]): number => {
|
|
58
|
+
let open = 0;
|
|
59
|
+
for (const token of tokens) {
|
|
60
|
+
if (token.type === 'paren' && token.value === '(') open++;
|
|
61
|
+
else if (token.type === 'paren' && token.value === ')') open--;
|
|
62
|
+
}
|
|
63
|
+
return Math.max(0, open);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const SilkeExpressionInput = forwardRef<HTMLDivElement, SilkeExpressionInputProps>(
|
|
67
|
+
function SilkeExpressionInput(props, forwardedRef) {
|
|
68
|
+
const {
|
|
69
|
+
value,
|
|
70
|
+
onChange,
|
|
71
|
+
variables = [],
|
|
72
|
+
triggerSources = [],
|
|
73
|
+
systemSources = [],
|
|
74
|
+
functions = DEFAULT_FUNCTIONS,
|
|
75
|
+
placeholder,
|
|
76
|
+
disabled,
|
|
77
|
+
onClear,
|
|
78
|
+
onFocus: _onFocus,
|
|
79
|
+
onBlur: _onBlur,
|
|
80
|
+
...outlineProps
|
|
81
|
+
} = props;
|
|
82
|
+
|
|
83
|
+
// Text the user has typed but not yet committed as a token.
|
|
84
|
+
const [typedText, setTypedText] = useState('');
|
|
85
|
+
const [showDropdown, setShowDropdown] = useState(false);
|
|
86
|
+
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
87
|
+
|
|
88
|
+
const wrapperRef = useRef<HTMLDivElement | null>(null);
|
|
89
|
+
const setWrapperRef = useCallback(
|
|
90
|
+
(node: HTMLDivElement | null) => {
|
|
91
|
+
wrapperRef.current = node;
|
|
92
|
+
if (typeof forwardedRef === 'function') forwardedRef(node);
|
|
93
|
+
else if (forwardedRef)
|
|
94
|
+
(forwardedRef as React.MutableRefObject<HTMLDivElement | null>).current = node;
|
|
95
|
+
},
|
|
96
|
+
[forwardedRef],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const variableNames = useMemo(() => variables.map((v) => v.name), [variables]);
|
|
100
|
+
const tokens = useMemo(
|
|
101
|
+
() => tokenizeForDisplay(value || '', variableNames),
|
|
102
|
+
[value, variableNames],
|
|
103
|
+
);
|
|
104
|
+
const nextSlot = useMemo(() => nextSlotFor(tokens), [tokens]);
|
|
105
|
+
const openParens = useMemo(() => countOpenParens(tokens), [tokens]);
|
|
106
|
+
|
|
107
|
+
const suggestions: ConditionSuggestion[] = useMemo(() => {
|
|
108
|
+
if (nextSlot === 'function-open-paren') return getFunctionFollowupSuggestions();
|
|
109
|
+
if (nextSlot === 'operand')
|
|
110
|
+
return getOperandSuggestions(typedText, variables, functions, triggerSources, systemSources);
|
|
111
|
+
return getOperatorSuggestions(typedText, openParens);
|
|
112
|
+
}, [nextSlot, typedText, variables, functions, triggerSources, systemSources, openParens]);
|
|
113
|
+
|
|
114
|
+
// Friendly label lookup for trigger/system pills (they store raw `[[…]]` placeholders).
|
|
115
|
+
const sourceLabels = useMemo(() => {
|
|
116
|
+
const map = new Map<string, string>();
|
|
117
|
+
triggerSources.forEach((s) => map.set(s.value, s.label));
|
|
118
|
+
systemSources.forEach((s) => map.set(s.value, s.label));
|
|
119
|
+
return map;
|
|
120
|
+
}, [triggerSources, systemSources]);
|
|
121
|
+
|
|
122
|
+
const labelFor = (token: DisplayToken): string | undefined =>
|
|
123
|
+
token.type === 'variable' ? sourceLabels.get(token.value) : undefined;
|
|
124
|
+
|
|
125
|
+
const replaceTokens = (next: DisplayToken[]) => onChange(tokensToExpression(next));
|
|
126
|
+
const addTokens = (more: DisplayToken[]) => replaceTokens([...tokens, ...more]);
|
|
127
|
+
|
|
128
|
+
// Convert the user's typed text into a single token, or return null if it isn't anything we recognise yet.
|
|
129
|
+
const textToToken = (raw: string): DisplayToken | null => {
|
|
130
|
+
const trimmed = raw.trim();
|
|
131
|
+
if (!trimmed) return null;
|
|
132
|
+
if (NUMERIC_LITERAL_PATTERN.test(trimmed)) return { type: 'number', value: trimmed };
|
|
133
|
+
if (PLACEHOLDER_PATTERN.test(trimmed)) return { type: 'variable', value: trimmed };
|
|
134
|
+
if (variables.some((v) => v.name === trimmed)) return { type: 'variable', value: trimmed };
|
|
135
|
+
if (functions.includes(trimmed)) return { type: 'function', value: trimmed };
|
|
136
|
+
return null;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// Finalise whatever's in the typed-text input, appending it as a token if it parses to one.
|
|
140
|
+
const commitTypedText = () => {
|
|
141
|
+
const token = textToToken(typedText);
|
|
142
|
+
if (token) addTokens([token]);
|
|
143
|
+
setTypedText('');
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const focusInput = () => {
|
|
147
|
+
const input = wrapperRef.current?.querySelector('input');
|
|
148
|
+
if (input) setTimeout(() => input.focus());
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// Build the tokens the dropdown should add when a suggestion is selected.
|
|
152
|
+
const tokensForSuggestion = (raw: string): DisplayToken[] => {
|
|
153
|
+
if (PLACEHOLDER_PATTERN.test(raw)) return [{ type: 'variable', value: raw }];
|
|
154
|
+
if (variables.some((v) => v.name === raw)) return [{ type: 'variable', value: raw }];
|
|
155
|
+
if (functions.includes(raw)) {
|
|
156
|
+
const result: DisplayToken[] = [
|
|
157
|
+
{ type: 'function', value: raw },
|
|
158
|
+
{ type: 'paren', value: '(' },
|
|
159
|
+
];
|
|
160
|
+
// Zero-arg functions (just `random` today) are inserted complete so the user
|
|
161
|
+
// doesn't get stuck inside an empty group.
|
|
162
|
+
if (isZeroArgFunction(raw)) result.push({ type: 'paren', value: ')' });
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
if (raw === '(' || raw === ')') return [{ type: 'paren', value: raw }];
|
|
166
|
+
return [{ type: 'operator', value: raw }];
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const pickSuggestion = (item: ConditionSuggestion, isBlurEvent?: boolean) => {
|
|
170
|
+
if (typeof item === 'string') return;
|
|
171
|
+
const raw = String((item as VevConditionSuggestion).value);
|
|
172
|
+
addTokens(tokensForSuggestion(raw));
|
|
173
|
+
setTypedText('');
|
|
174
|
+
if (!isBlurEvent) focusInput();
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// Called for every keystroke in the typed-text input. If the user typed an
|
|
178
|
+
// operator or paren character, commit any preceding text first then append
|
|
179
|
+
// the operator/paren as its own token.
|
|
180
|
+
const onTypedTextChange = (raw: string) => {
|
|
181
|
+
if (!raw) {
|
|
182
|
+
setTypedText('');
|
|
183
|
+
setHighlightedIndex(1);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const last = raw[raw.length - 1];
|
|
188
|
+
const isOperatorOrParen = OPERATOR_CHARS.has(last) || PAREN_CHARS.has(last);
|
|
189
|
+
if (isOperatorOrParen) {
|
|
190
|
+
const prefixToken = textToToken(raw.slice(0, -1));
|
|
191
|
+
const lastToken: DisplayToken = PAREN_CHARS.has(last)
|
|
192
|
+
? { type: 'paren', value: last }
|
|
193
|
+
: { type: 'operator', value: last };
|
|
194
|
+
addTokens(prefixToken ? [prefixToken, lastToken] : [lastToken]);
|
|
195
|
+
setTypedText('');
|
|
196
|
+
} else {
|
|
197
|
+
setTypedText(raw);
|
|
198
|
+
}
|
|
199
|
+
setHighlightedIndex(1);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const confirmSelection = () => {
|
|
203
|
+
const item = suggestions[highlightedIndex];
|
|
204
|
+
if (item && typeof item !== 'string') {
|
|
205
|
+
pickSuggestion(item);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
commitTypedText();
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// Walk forwards/backwards through the suggestion list, skipping section headers (which are plain strings).
|
|
212
|
+
const moveHighlight = (delta: number) => {
|
|
213
|
+
if (suggestions.length === 0) return;
|
|
214
|
+
let next = highlightedIndex + delta;
|
|
215
|
+
let safety = suggestions.length;
|
|
216
|
+
while (safety-- > 0) {
|
|
217
|
+
if (next < 0) next = suggestions.length - 1;
|
|
218
|
+
else if (next >= suggestions.length) next = 0;
|
|
219
|
+
if (typeof suggestions[next] !== 'string') {
|
|
220
|
+
setHighlightedIndex(next);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
next += delta || 1;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const clearAll = () => {
|
|
228
|
+
onChange('');
|
|
229
|
+
setTypedText('');
|
|
230
|
+
onClear?.();
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const handleBackspace = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
234
|
+
if (typedText) return;
|
|
235
|
+
e.stopPropagation();
|
|
236
|
+
e.preventDefault();
|
|
237
|
+
if (e.metaKey) {
|
|
238
|
+
clearAll();
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
replaceTokens(tokens.slice(0, -1));
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
245
|
+
switch (e.key) {
|
|
246
|
+
case 'Enter':
|
|
247
|
+
confirmSelection();
|
|
248
|
+
break;
|
|
249
|
+
case ' ':
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
confirmSelection();
|
|
252
|
+
break;
|
|
253
|
+
case 'ArrowUp':
|
|
254
|
+
e.preventDefault();
|
|
255
|
+
moveHighlight(-1);
|
|
256
|
+
break;
|
|
257
|
+
case 'ArrowDown':
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
moveHighlight(1);
|
|
260
|
+
break;
|
|
261
|
+
case 'Backspace':
|
|
262
|
+
handleBackspace(e);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
268
|
+
setShowDropdown(true);
|
|
269
|
+
setHighlightedIndex(1);
|
|
270
|
+
props.onFocus?.(e.nativeEvent);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
274
|
+
commitTypedText();
|
|
275
|
+
setShowDropdown(false);
|
|
276
|
+
setHighlightedIndex(-1);
|
|
277
|
+
props.onBlur?.(e.nativeEvent);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const isEmpty = !typedText && tokens.length === 0;
|
|
281
|
+
|
|
282
|
+
return (
|
|
283
|
+
<SilkeBox style={{ width: '100%' }}>
|
|
284
|
+
<SilkeTextFieldOutline
|
|
285
|
+
onClick={focusInput}
|
|
286
|
+
ref={setWrapperRef}
|
|
287
|
+
size="s"
|
|
288
|
+
{...outlineProps}
|
|
289
|
+
>
|
|
290
|
+
<SilkeBox className={styles.inner} wrap align="start" fill vPad="xs" hPad="s">
|
|
291
|
+
<SilkeTextFieldItem>
|
|
292
|
+
<SilkeText color="neutral-60" size="small">
|
|
293
|
+
=
|
|
294
|
+
</SilkeText>
|
|
295
|
+
</SilkeTextFieldItem>
|
|
296
|
+
{tokens.map((token, index) => (
|
|
297
|
+
<SilkeExpressionInputTag
|
|
298
|
+
key={`${token.type}-${index}-${token.value}`}
|
|
299
|
+
token={token}
|
|
300
|
+
label={labelFor(token)}
|
|
301
|
+
/>
|
|
302
|
+
))}
|
|
303
|
+
|
|
304
|
+
<input
|
|
305
|
+
value={typedText}
|
|
306
|
+
className={styles.field}
|
|
307
|
+
placeholder={isEmpty ? placeholder : undefined}
|
|
308
|
+
disabled={disabled}
|
|
309
|
+
data-empty={isEmpty}
|
|
310
|
+
data-hidden={!showDropdown}
|
|
311
|
+
onChange={(e) => onTypedTextChange(e.target.value)}
|
|
312
|
+
onKeyDown={handleKeyDown}
|
|
313
|
+
onFocus={handleFocus}
|
|
314
|
+
onBlur={handleBlur}
|
|
315
|
+
/>
|
|
316
|
+
</SilkeBox>
|
|
317
|
+
|
|
318
|
+
{tokens.length > 0 && !disabled && (
|
|
319
|
+
<SilkeTextFieldItem vAlign="start" hPad="xs" vPad="xs">
|
|
320
|
+
<SilkeButton size="s" icon="close" kind="ghost" onClick={clearAll} />
|
|
321
|
+
</SilkeTextFieldItem>
|
|
322
|
+
)}
|
|
323
|
+
</SilkeTextFieldOutline>
|
|
324
|
+
|
|
325
|
+
<SilkePopover
|
|
326
|
+
hide={!showDropdown || suggestions.length === 0}
|
|
327
|
+
anchor={wrapperRef}
|
|
328
|
+
anchorOrigin="bottom-left"
|
|
329
|
+
targetOrigin="top-left"
|
|
330
|
+
matchAnchorWidth
|
|
331
|
+
>
|
|
332
|
+
<SilkeConditionsInputOptions
|
|
333
|
+
suggestions={suggestions}
|
|
334
|
+
highlightedItem={highlightedIndex}
|
|
335
|
+
onSelect={pickSuggestion}
|
|
336
|
+
/>
|
|
337
|
+
</SilkePopover>
|
|
338
|
+
</SilkeBox>
|
|
339
|
+
);
|
|
340
|
+
},
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
SilkeExpressionInput.displayName = 'SilkeExpressionInput';
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { SilkeIcons } from '../silke-icon';
|
|
2
|
+
import { ConditionSuggestion, VevConditionSuggestion } from '../silke-conditions-input';
|
|
3
|
+
|
|
4
|
+
export interface ExpressionVariable {
|
|
5
|
+
key: string;
|
|
6
|
+
name: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ExpressionSource {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
icon?: SilkeIcons;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const OPERATOR_OPTIONS: VevConditionSuggestion[] = [
|
|
17
|
+
{ value: '+', label: 'Add', type: 'operator', icon: 'add' },
|
|
18
|
+
{ value: '-', label: 'Subtract', type: 'operator', icon: 'remove' },
|
|
19
|
+
{ value: '*', label: 'Multiply', type: 'operator' },
|
|
20
|
+
{ value: '/', label: 'Divide', type: 'operator' },
|
|
21
|
+
{ value: '^', label: 'Power', type: 'operator' },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export const DEFAULT_FUNCTIONS = [
|
|
25
|
+
'sqrt',
|
|
26
|
+
'sin',
|
|
27
|
+
'cos',
|
|
28
|
+
'acos',
|
|
29
|
+
'asin',
|
|
30
|
+
'tan',
|
|
31
|
+
'atan',
|
|
32
|
+
'log',
|
|
33
|
+
'round',
|
|
34
|
+
'random',
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
export const ZERO_ARG_FUNCTIONS = new Set(['random']);
|
|
38
|
+
|
|
39
|
+
export const isZeroArgFunction = (name: string): boolean => ZERO_ARG_FUNCTIONS.has(name);
|
|
40
|
+
|
|
41
|
+
const formatFunctionLabel = (name: string): string =>
|
|
42
|
+
isZeroArgFunction(name) ? `${name}()` : `${name}(x)`;
|
|
43
|
+
|
|
44
|
+
const PAREN_OPEN: VevConditionSuggestion = {
|
|
45
|
+
value: '(',
|
|
46
|
+
label: 'Open group',
|
|
47
|
+
type: 'operator',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const PAREN_CLOSE: VevConditionSuggestion = {
|
|
51
|
+
value: ')',
|
|
52
|
+
label: 'Close group',
|
|
53
|
+
type: 'operator',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const filterByQuery = <T extends { label: string; value: string | number | boolean }>(
|
|
57
|
+
list: T[],
|
|
58
|
+
query: string,
|
|
59
|
+
): T[] => {
|
|
60
|
+
if (!query) return list;
|
|
61
|
+
const q = query.toLowerCase();
|
|
62
|
+
return list.filter(
|
|
63
|
+
(item) =>
|
|
64
|
+
item.label.toLowerCase().includes(q) || String(item.value).toLowerCase().includes(q),
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const sourceToSuggestion = (source: ExpressionSource): VevConditionSuggestion => ({
|
|
69
|
+
type: 'number',
|
|
70
|
+
label: source.label,
|
|
71
|
+
value: source.value,
|
|
72
|
+
icon: source.icon,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export const getOperandSuggestions = (
|
|
76
|
+
query: string,
|
|
77
|
+
variables: ExpressionVariable[],
|
|
78
|
+
functions: string[] = DEFAULT_FUNCTIONS,
|
|
79
|
+
triggerSources: ExpressionSource[] = [],
|
|
80
|
+
systemSources: ExpressionSource[] = [],
|
|
81
|
+
): ConditionSuggestion[] => {
|
|
82
|
+
const variableItems: VevConditionSuggestion[] = variables
|
|
83
|
+
.filter((v) => !v.type || v.type === 'number')
|
|
84
|
+
.map((v) => ({
|
|
85
|
+
type: 'number',
|
|
86
|
+
label: v.name,
|
|
87
|
+
value: v.name,
|
|
88
|
+
icon: 'hashtag',
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
const functionItems: VevConditionSuggestion[] = functions.map((fn) => ({
|
|
92
|
+
type: 'operator',
|
|
93
|
+
label: formatFunctionLabel(fn),
|
|
94
|
+
value: fn,
|
|
95
|
+
}));
|
|
96
|
+
|
|
97
|
+
const triggerItems = triggerSources.map(sourceToSuggestion);
|
|
98
|
+
const systemItems = systemSources.map(sourceToSuggestion);
|
|
99
|
+
|
|
100
|
+
const filteredTrigger = filterByQuery(triggerItems, query);
|
|
101
|
+
const filteredSystem = filterByQuery(systemItems, query);
|
|
102
|
+
const filteredVariables = filterByQuery(variableItems, query);
|
|
103
|
+
const filteredFunctions = filterByQuery(functionItems, query);
|
|
104
|
+
const filteredParen = filterByQuery([PAREN_OPEN], query);
|
|
105
|
+
|
|
106
|
+
const result: ConditionSuggestion[] = [];
|
|
107
|
+
if (filteredTrigger.length > 0) {
|
|
108
|
+
result.push('Trigger', ...filteredTrigger);
|
|
109
|
+
}
|
|
110
|
+
if (filteredVariables.length > 0) {
|
|
111
|
+
result.push('Variables', ...filteredVariables);
|
|
112
|
+
}
|
|
113
|
+
if (filteredSystem.length > 0) {
|
|
114
|
+
result.push('System', ...filteredSystem);
|
|
115
|
+
}
|
|
116
|
+
if (filteredFunctions.length > 0) {
|
|
117
|
+
result.push('Functions', ...filteredFunctions);
|
|
118
|
+
}
|
|
119
|
+
if (filteredParen.length > 0) {
|
|
120
|
+
result.push('Group', ...filteredParen);
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const getOperatorSuggestions = (
|
|
126
|
+
query: string,
|
|
127
|
+
openParens: number,
|
|
128
|
+
): ConditionSuggestion[] => {
|
|
129
|
+
const filteredOps = filterByQuery(OPERATOR_OPTIONS, query);
|
|
130
|
+
const closeParen = openParens > 0 ? filterByQuery([PAREN_CLOSE], query) : [];
|
|
131
|
+
|
|
132
|
+
const result: ConditionSuggestion[] = [];
|
|
133
|
+
if (filteredOps.length > 0) {
|
|
134
|
+
result.push('Operators', ...filteredOps);
|
|
135
|
+
}
|
|
136
|
+
if (closeParen.length > 0) {
|
|
137
|
+
result.push('Group', ...closeParen);
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const getFunctionFollowupSuggestions = (): ConditionSuggestion[] => {
|
|
143
|
+
return ['Group', PAREN_OPEN];
|
|
144
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useCallback, useRef } from 'react';
|
|
2
|
+
import { joinSchemaPath } from '../silke-schema-decorator';
|
|
2
3
|
import { SilkeSchemaFields } from '../silke-schema-fields';
|
|
3
4
|
import { SilkeTextField } from '../../silke-text-field';
|
|
4
5
|
import { FieldRegisterModel, FormObjectProvider } from '../../silke-form/form-context';
|
|
@@ -16,6 +17,7 @@ type Props = {
|
|
|
16
17
|
onChange: (value: any[]) => void;
|
|
17
18
|
onDelete: () => void;
|
|
18
19
|
onClose: () => void;
|
|
20
|
+
path?: string;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export function ArrayFieldInline({
|
|
@@ -26,6 +28,7 @@ export function ArrayFieldInline({
|
|
|
26
28
|
onChange,
|
|
27
29
|
onDelete,
|
|
28
30
|
onClose,
|
|
31
|
+
path,
|
|
29
32
|
}: Props) {
|
|
30
33
|
const valueRef = useRef<any>(value);
|
|
31
34
|
const fieldRefs = useRef<any>({});
|
|
@@ -77,6 +80,7 @@ export function ArrayFieldInline({
|
|
|
77
80
|
noPad
|
|
78
81
|
disabled={disabled}
|
|
79
82
|
itemIndex={selected}
|
|
83
|
+
path={joinSchemaPath(path, selected)}
|
|
80
84
|
/>
|
|
81
85
|
</FormObjectProvider>
|
|
82
86
|
)}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { RefObject, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { joinSchemaPath } from '../silke-schema-decorator';
|
|
2
3
|
import { SilkeSchemaFields } from '../silke-schema-fields';
|
|
3
4
|
import { SilkeTextField } from '../../silke-text-field';
|
|
4
5
|
import { SilkePopover } from '../../silke-popover';
|
|
@@ -21,6 +22,7 @@ type Props = {
|
|
|
21
22
|
onChange: (value: any[]) => void;
|
|
22
23
|
onDelete: () => void;
|
|
23
24
|
onClose: () => void;
|
|
25
|
+
path?: string;
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export function ArrayFieldModal({
|
|
@@ -32,6 +34,7 @@ export function ArrayFieldModal({
|
|
|
32
34
|
onChange,
|
|
33
35
|
onDelete,
|
|
34
36
|
onClose,
|
|
37
|
+
path,
|
|
35
38
|
}: Props) {
|
|
36
39
|
const schemaContext = useSchemaContext();
|
|
37
40
|
const valueRef = useRef<any>(value);
|
|
@@ -115,6 +118,7 @@ export function ArrayFieldModal({
|
|
|
115
118
|
value={value[selected] || defaultItemValue}
|
|
116
119
|
noPad
|
|
117
120
|
itemIndex={selected}
|
|
121
|
+
path={joinSchemaPath(path, selected)}
|
|
118
122
|
/>
|
|
119
123
|
</FormObjectProvider>
|
|
120
124
|
)}
|
|
@@ -37,10 +37,7 @@ function getNormalizedOf(schema: ArrayFieldType): VevProps[] | 'string' | 'numbe
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
/** Resolves a list item icon: emoji icon for image URLs, silke icon name for fallback. */
|
|
40
|
-
function resolveItemIcon(
|
|
41
|
-
item: any,
|
|
42
|
-
fieldSchema: VevProps | VevProps[] | string | undefined,
|
|
43
|
-
): any {
|
|
40
|
+
function resolveItemIcon(item: any, fieldSchema: VevProps | VevProps[] | string | undefined): any {
|
|
44
41
|
// Check preview/custom image first
|
|
45
42
|
const imageUrl = generateImage(item, fieldSchema);
|
|
46
43
|
if (imageUrl && isString(imageUrl)) {
|
|
@@ -78,6 +75,7 @@ const ArrayField = ({
|
|
|
78
75
|
disabled,
|
|
79
76
|
readonly,
|
|
80
77
|
onChange,
|
|
78
|
+
path,
|
|
81
79
|
}: SchemaFieldProps<ArrayFieldType>) => {
|
|
82
80
|
const [selected, setSelected] = useState<number | undefined>(undefined);
|
|
83
81
|
const [schemaIndex, setSchemaIndex] = useState(0);
|
|
@@ -106,7 +104,8 @@ const ArrayField = ({
|
|
|
106
104
|
|
|
107
105
|
if (!Array.isArray(value)) value = [];
|
|
108
106
|
|
|
109
|
-
const isMultiType =
|
|
107
|
+
const isMultiType =
|
|
108
|
+
Array.isArray(schema.of) && !isSingleFieldOf(schema.of) && schema.of.length > 1;
|
|
110
109
|
|
|
111
110
|
const listItems: SilkeListItemData[] = useMemo(
|
|
112
111
|
() =>
|
|
@@ -162,12 +161,7 @@ const ArrayField = ({
|
|
|
162
161
|
}))}
|
|
163
162
|
/>
|
|
164
163
|
) : (
|
|
165
|
-
<SilkeButton
|
|
166
|
-
icon="add"
|
|
167
|
-
kind="ghost"
|
|
168
|
-
size="s"
|
|
169
|
-
onClick={handleAddDefault}
|
|
170
|
-
/>
|
|
164
|
+
<SilkeButton icon="add" kind="ghost" size="s" onClick={handleAddDefault} />
|
|
171
165
|
)}
|
|
172
166
|
</SilkeBox>
|
|
173
167
|
</SilkeBox>
|
|
@@ -190,6 +184,7 @@ const ArrayField = ({
|
|
|
190
184
|
: schema.of
|
|
191
185
|
}
|
|
192
186
|
onClose={() => setSelected(undefined)}
|
|
187
|
+
path={path}
|
|
193
188
|
/>
|
|
194
189
|
)}
|
|
195
190
|
{!value.length && (
|
|
@@ -11,6 +11,7 @@ export default function GroupField({
|
|
|
11
11
|
schema,
|
|
12
12
|
disabled,
|
|
13
13
|
readonly,
|
|
14
|
+
path,
|
|
14
15
|
}: SchemaFieldProps<GroupFieldType>) {
|
|
15
16
|
const [collapsed, setCollapsed] = useState(schema.options?.collapsed ?? false);
|
|
16
17
|
|
|
@@ -41,6 +42,7 @@ export default function GroupField({
|
|
|
41
42
|
disabled={disabled}
|
|
42
43
|
readonly={readonly}
|
|
43
44
|
noPad
|
|
45
|
+
path={path}
|
|
44
46
|
/>
|
|
45
47
|
)}
|
|
46
48
|
</SilkeBox>
|
|
@@ -8,6 +8,7 @@ export default function LayoutField({
|
|
|
8
8
|
schema,
|
|
9
9
|
disabled,
|
|
10
10
|
readonly,
|
|
11
|
+
path,
|
|
11
12
|
}: SchemaFieldProps<LayoutFieldType>) {
|
|
12
13
|
const display = schema?.options?.display;
|
|
13
14
|
|
|
@@ -20,6 +21,7 @@ export default function LayoutField({
|
|
|
20
21
|
readonly={readonly}
|
|
21
22
|
noPad
|
|
22
23
|
row={!display || display === 'row'}
|
|
24
|
+
path={path}
|
|
23
25
|
/>
|
|
24
26
|
</SilkeBox>
|
|
25
27
|
);
|
|
@@ -14,6 +14,7 @@ export default function ObjectField({
|
|
|
14
14
|
readonly,
|
|
15
15
|
onChange,
|
|
16
16
|
itemIndex,
|
|
17
|
+
path,
|
|
17
18
|
}: SchemaFieldProps<ObjectFieldType>) {
|
|
18
19
|
return (
|
|
19
20
|
<SilkeBox column flex style={{ paddingTop: '16px' }} gap="xs">
|
|
@@ -30,6 +31,7 @@ export default function ObjectField({
|
|
|
30
31
|
key={schema.name}
|
|
31
32
|
noPad
|
|
32
33
|
itemIndex={itemIndex}
|
|
34
|
+
path={path}
|
|
33
35
|
/>
|
|
34
36
|
</SilkeObjectField>
|
|
35
37
|
</SilkeBox>
|
|
@@ -15,6 +15,7 @@ export default function PopoverField({
|
|
|
15
15
|
schema,
|
|
16
16
|
disabled,
|
|
17
17
|
readonly,
|
|
18
|
+
path,
|
|
18
19
|
}: SchemaFieldProps<PopoverFieldType>) {
|
|
19
20
|
const schemaContext = useSchemaContext();
|
|
20
21
|
const [open, setOpen] = useState(false);
|
|
@@ -54,6 +55,7 @@ export default function PopoverField({
|
|
|
54
55
|
disabled={disabled}
|
|
55
56
|
readonly={readonly}
|
|
56
57
|
noPad
|
|
58
|
+
path={path}
|
|
57
59
|
/>
|
|
58
60
|
</SilkeBox>
|
|
59
61
|
</SilkeBox>
|