@vev/silke 1.0.23 → 1.0.25
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 +17 -0
- package/dist/index.js +71 -30
- package/dist/index.js.LEGAL.txt +10 -0
- package/dist/silke/src/components/index.d.ts +1 -0
- package/dist/silke/src/components/silke-autocomplete-field/silke-autocomplete-field.d.ts +5 -1
- package/dist/silke/src/components/silke-autocomplete-field/silke-autocomplete-popup.d.ts +13 -0
- package/dist/silke/src/components/silke-box/silke-box.d.ts +1 -1
- package/dist/silke/src/components/silke-button/silke-button.d.ts +11 -11
- package/dist/silke/src/components/silke-card/silke-card.d.ts +13 -13
- package/dist/silke/src/components/silke-color-swatches/silke-color-swatch-button.d.ts +1 -1
- package/dist/silke/src/components/silke-css-number-field/index.d.ts +0 -1
- package/dist/silke/src/components/silke-css-number-field/silke-css-context.d.ts +1 -1
- package/dist/silke/src/components/silke-css-number-field/silke-css-number-field.d.ts +0 -2
- package/dist/silke/src/components/silke-form/form-types.d.ts +0 -1
- package/dist/silke/src/components/silke-form-schema/fields/number-field.d.ts +1 -1
- package/dist/silke/src/components/silke-form-schema/fields/utils/generate-title.d.ts +2 -2
- package/dist/silke/src/components/silke-form-schema/silke-schema-context.d.ts +1 -1
- package/dist/silke/src/components/silke-iframe-portal/silke-iframe-context.d.ts +0 -1
- package/dist/silke/src/components/silke-sortable-list/silke-nested-sortable-utils.d.ts +0 -1
- package/dist/silke/src/components/silke-table/table-types.d.ts +0 -1
- package/dist/silke/src/components/silke-tag/silke-tag.d.ts +8 -8
- package/dist/silke/src/components/silke-text/silke-text.d.ts +11 -11
- package/dist/silke/src/components/silke-text-field/silke-text-field-outline.d.ts +0 -3
- package/dist/silke/src/components/silke-tooltip/silke-shortcuts.d.ts +2 -33
- package/dist/silke/src/components/silke-variables-wrapper/index.d.ts +1 -0
- package/dist/silke/src/components/silke-variables-wrapper/silke-variables-wrapper-form.d.ts +12 -0
- package/dist/silke/src/components/silke-variables-wrapper/silke-variables-wrapper.d.ts +22 -0
- package/dist/silke/src/docs/data/app/constants.d.ts +0 -1
- package/dist/silke/src/hooks/use-mouse.d.ts +0 -1
- package/dist/styles.css +235 -212
- package/dist/utils/src/css/number-format.d.ts +1 -1
- package/dist/utils/src/index.d.ts +0 -2
- package/dist/utils/src/keyboard/hooks.d.ts +0 -1
- package/dist/utils/src/mouse/mouse-manager.d.ts +0 -1
- package/dist/utils/src/types/event.d.ts +1 -2
- package/dist/utils/src/types/index.d.ts +0 -1
- package/dist/utils/src/types/vev-props.d.ts +1 -1
- package/esbuild.config.mjs +3 -3
- package/package.json +3 -3
- package/src/components/index.ts +1 -0
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +7 -2
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +40 -0
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +6 -2
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +22 -425
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +486 -0
- package/src/components/silke-button/silke-button.mdx +24 -0
- package/src/components/silke-button/silke-dropdown-button.tsx +2 -2
- package/src/components/silke-context-menu/silke-context-menu.tsx +2 -2
- package/src/components/silke-css-number-field/index.ts +0 -1
- package/src/components/silke-css-number-field/silke-css-context.tsx +7 -1
- package/src/components/silke-css-number-field/silke-css-number-field.mdx +3 -3
- package/src/components/silke-css-number-field/silke-css-number-field.scss +0 -12
- package/src/components/silke-css-number-field/silke-css-number-field.tsx +18 -101
- package/src/components/silke-css-number-field/utils.ts +5 -1
- package/src/components/silke-form-schema/fields/string-field.tsx +7 -2
- package/src/components/silke-form-schema/safe-eval/iframe-handler.ts +1 -0
- package/src/components/silke-icon/silke-icon.tsx +7 -3
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +1 -1
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +2 -2
- package/src/components/silke-text-field/silke-text-field-outline.tsx +0 -17
- package/src/components/silke-text-field/silke-text-field.scss +1 -58
- package/src/components/silke-text-field/silke-text-field.tsx +0 -6
- package/src/components/silke-variables-wrapper/index.ts +1 -0
- package/src/components/silke-variables-wrapper/silke-variables-wrapper-form.tsx +64 -0
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.mdx +126 -0
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +72 -0
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.tsx +260 -0
- package/src/components/silke-virtual/silke-virtual-row.tsx +9 -6
- package/src/hooks/use-drop-zone.ts +1 -1
- package/src/hooks/use-mouse.ts +11 -4
- package/src/hooks/use-size.ts +14 -11
- package/dist/chunk-PP74IZDW.js +0 -22
- package/dist/chunk-PP74IZDW.js.LEGAL.txt +0 -11
- package/dist/chunk-PP74IZDW.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/silke/src/components/silke-css-number-field/variable-picker.d.ts +0 -17
- package/dist/silke-code-editor-LK4ESGQO.js +0 -25
- package/dist/silke-code-editor-LK4ESGQO.js.LEGAL.txt +0 -0
- package/dist/silke-code-editor-LK4ESGQO.js.map +0 -7
- package/dist/utils/src/events/condition-parser/evaluate-condition-expression.d.ts +0 -2
- package/dist/utils/src/events/condition-parser/index.d.ts +0 -1
- package/dist/utils/src/events/condition-parser/lexer.d.ts +0 -37
- package/dist/utils/src/events/condition-parser/parser.d.ts +0 -11
- package/dist/utils/src/interactions/get-interaction-map.d.ts +0 -3
- package/dist/utils/src/interactions/get-node-type.d.ts +0 -2
- package/dist/utils/src/interactions/has-link.d.ts +0 -5
- package/dist/utils/src/interactions/has-pointer-event.d.ts +0 -5
- package/dist/utils/src/interactions/index.d.ts +0 -7
- package/dist/utils/src/interactions/interaction-map-to-array.d.ts +0 -2
- package/dist/utils/src/interactions/is-target-global.d.ts +0 -2
- package/dist/utils/src/interactions/is-trigger-global.d.ts +0 -2
- package/dist/utils/src/types/interaction.d.ts +0 -93
- package/src/components/silke-css-number-field/variable-picker.tsx +0 -181
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
roundCSSNumber,
|
|
24
24
|
} from './utils';
|
|
25
25
|
import { useTextFieldContext } from '../silke-text-field/text-field-context';
|
|
26
|
-
import { VariablePicker } from './variable-picker';
|
|
27
26
|
|
|
28
27
|
export type SilkeCssNumberFieldProps = FormFieldProps<string> &
|
|
29
28
|
SilkeTextFieldOutlineProps & {
|
|
@@ -37,8 +36,6 @@ export type SilkeCssNumberFieldProps = FormFieldProps<string> &
|
|
|
37
36
|
/** Define witch axis the number belongs to (used when converting values for the CSSContext) */
|
|
38
37
|
axis?: 'x' | 'y';
|
|
39
38
|
onEnter?: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
40
|
-
onVariableAdd?: (type: string) => void;
|
|
41
|
-
onVariableEdit?: (key: string) => void;
|
|
42
39
|
};
|
|
43
40
|
|
|
44
41
|
const handleSelectText = (el: HTMLDivElement, selectAll: boolean) => {
|
|
@@ -61,38 +58,32 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
61
58
|
formats,
|
|
62
59
|
axis,
|
|
63
60
|
allowAuto,
|
|
64
|
-
disableVariables,
|
|
65
61
|
autoFocus,
|
|
66
62
|
className,
|
|
67
63
|
onEnter,
|
|
68
64
|
onChange,
|
|
69
|
-
onVariableAdd,
|
|
70
|
-
onVariableEdit,
|
|
71
65
|
...rest
|
|
72
66
|
} = useFormField(props);
|
|
67
|
+
|
|
73
68
|
const [openFormat, setFormatOpen] = useState(false);
|
|
74
|
-
const [openVariables, setOpenVariables] = useState(false);
|
|
75
69
|
const rootRef = useRef<HTMLDivElement>(null);
|
|
76
70
|
const numberRef = useRef<HTMLDivElement>(null);
|
|
77
71
|
const context = useSilkeCSSContext();
|
|
78
72
|
const textFieldContext = useTextFieldContext();
|
|
79
73
|
const isAuto = allowAuto && value === 'auto';
|
|
80
|
-
const isVariable = value?.startsWith('var(--vev-');
|
|
81
74
|
const isMixed = value === 'mixed';
|
|
82
75
|
const number = isAuto ? 'Auto' : isMixed ? 'Mixed' : parseFloat(value || '0') || 0;
|
|
83
|
-
const format =
|
|
76
|
+
const format =
|
|
77
|
+
isAuto || isMixed ? '' : getCSSNumberFormat(value || '0', formats?.includes('None'));
|
|
84
78
|
|
|
85
79
|
let cl = styles.root;
|
|
86
80
|
if (openFormat) cl += ' ' + styles.openFormat;
|
|
87
81
|
if (className) cl += ' ' + className;
|
|
88
82
|
if (disabled) cl += ' ' + styles.disabled;
|
|
89
|
-
if (isVariable) cl += ' ' + styles.variable;
|
|
90
|
-
if (openVariables) cl += ' ' + styles.openVariables;
|
|
91
83
|
|
|
92
84
|
const variables = React.useMemo(() => {
|
|
93
85
|
return (context.variablesv2 || []).filter((v) => formats?.includes(v.unit || ''));
|
|
94
86
|
}, [context.variablesv2, formats]);
|
|
95
|
-
const showVariables = variables?.length > 0 && !disableVariables;
|
|
96
87
|
|
|
97
88
|
const handleNumberChange = () => {
|
|
98
89
|
// const formatEl = formatRef.current;
|
|
@@ -123,32 +114,13 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
123
114
|
setFormatOpen(true);
|
|
124
115
|
};
|
|
125
116
|
|
|
126
|
-
const handleOpenVariables = (e: React.MouseEvent) => {
|
|
127
|
-
e.preventDefault();
|
|
128
|
-
setOpenVariables(true);
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const handleVariablesDotClicked = (e: React.MouseEvent) => {
|
|
132
|
-
e.preventDefault();
|
|
133
|
-
|
|
134
|
-
// If active variable, remove link and set to native value
|
|
135
|
-
if (isVariable) {
|
|
136
|
-
const variable = variables.find((v) => value?.includes(v.key));
|
|
137
|
-
onChange(variable ? `${variable.value}${variable.unit}` : '0');
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
setOpenVariables(true);
|
|
142
|
-
};
|
|
143
|
-
|
|
144
117
|
const handleFocus = () => {
|
|
145
118
|
if (disabled) return;
|
|
146
119
|
const selection = window.getSelection();
|
|
147
120
|
const el = numberRef.current;
|
|
148
|
-
if (selection?.isCollapsed && el
|
|
121
|
+
if (selection?.isCollapsed && el) {
|
|
149
122
|
handleSelectText(el, true);
|
|
150
123
|
}
|
|
151
|
-
if (isVariable && !openVariables) setOpenVariables(true);
|
|
152
124
|
};
|
|
153
125
|
|
|
154
126
|
const handleNumberBlur = () => {
|
|
@@ -158,20 +130,20 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
158
130
|
if (numberEl) {
|
|
159
131
|
const parent = numberEl.parentElement;
|
|
160
132
|
if (parent) parent.scrollLeft = 0;
|
|
161
|
-
|
|
162
133
|
numberEl.innerText = formatNumberForDisplay(
|
|
163
|
-
|
|
134
|
+
format === ''
|
|
135
|
+
? `${number}`
|
|
136
|
+
: isNumber(number)
|
|
137
|
+
? roundCSSNumber(number, format).toString() + format
|
|
138
|
+
: number + format,
|
|
164
139
|
);
|
|
165
140
|
}
|
|
166
141
|
};
|
|
167
142
|
|
|
168
143
|
const handleChange = (number: number | string, format: string) => {
|
|
169
|
-
const newValue =
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
: isString(number)
|
|
173
|
-
? number + format
|
|
174
|
-
: roundCSSNumber(number, format, min, max) + format;
|
|
144
|
+
const newValue = isString(number)
|
|
145
|
+
? number + format
|
|
146
|
+
: roundCSSNumber(number, format, min, max) + format;
|
|
175
147
|
onChange(newValue);
|
|
176
148
|
};
|
|
177
149
|
|
|
@@ -207,16 +179,11 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
207
179
|
useLayoutEffect(() => {
|
|
208
180
|
const el = numberRef.current;
|
|
209
181
|
if (el && document.activeElement !== el) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
} else {
|
|
214
|
-
el.innerText = formatNumberForDisplay(
|
|
215
|
-
isNumber(number) ? roundCSSNumber(number, format).toString() + format : number + format,
|
|
216
|
-
);
|
|
217
|
-
}
|
|
182
|
+
el.innerText = formatNumberForDisplay(
|
|
183
|
+
isNumber(number) ? roundCSSNumber(number, format).toString() + format : number + format,
|
|
184
|
+
);
|
|
218
185
|
}
|
|
219
|
-
}, [number, format, variables, isAuto, isMixed
|
|
186
|
+
}, [number, format, variables, isAuto, isMixed]);
|
|
220
187
|
|
|
221
188
|
const handleNumberKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
222
189
|
if (openFormat) setFormatOpen(false);
|
|
@@ -302,13 +269,10 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
302
269
|
draw();
|
|
303
270
|
};
|
|
304
271
|
|
|
305
|
-
const
|
|
306
|
-
const showFormatsArrow =
|
|
307
|
-
!disabled && !context.readonly && (formats?.length || 0 > 1) && !isVariable;
|
|
272
|
+
const showFormatsArrow = !disabled && !context.readonly && (formats?.length || 0 > 1);
|
|
308
273
|
|
|
309
274
|
let inputCl = styles.field;
|
|
310
275
|
if (showFormatsArrow) inputCl += ' ' + styles.hasFormats;
|
|
311
|
-
if (showVariablesArrow) inputCl += ' ' + styles.hasVariables;
|
|
312
276
|
|
|
313
277
|
const size = rest.size || textFieldContext.size;
|
|
314
278
|
|
|
@@ -320,9 +284,6 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
320
284
|
hAlign="start"
|
|
321
285
|
vAlign="center"
|
|
322
286
|
onClick={handleFocus}
|
|
323
|
-
showVariableDot={showVariables && !openVariables}
|
|
324
|
-
hasActiveVariable={isVariable}
|
|
325
|
-
onVariableClick={handleVariablesDotClicked}
|
|
326
287
|
>
|
|
327
288
|
{before}
|
|
328
289
|
|
|
@@ -349,20 +310,6 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
349
310
|
}}
|
|
350
311
|
/>
|
|
351
312
|
|
|
352
|
-
{showVariablesArrow && (
|
|
353
|
-
<SilkeBox
|
|
354
|
-
className={styles.downIcon}
|
|
355
|
-
width="xs"
|
|
356
|
-
height="s"
|
|
357
|
-
align="center"
|
|
358
|
-
tag="button"
|
|
359
|
-
tabIndex={-1}
|
|
360
|
-
onMouseDown={handleOpenVariables}
|
|
361
|
-
>
|
|
362
|
-
<SilkeIcon icon={openVariables ? 'chevron.up' : 'chevron.down'} />
|
|
363
|
-
</SilkeBox>
|
|
364
|
-
)}
|
|
365
|
-
|
|
366
313
|
{showFormatsArrow && (
|
|
367
314
|
<SilkeBox
|
|
368
315
|
className={styles.downIcon}
|
|
@@ -377,7 +324,7 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
377
324
|
</SilkeBox>
|
|
378
325
|
)}
|
|
379
326
|
</SilkeBox>
|
|
380
|
-
{!disabled && !context.readonly && !isAuto &&
|
|
327
|
+
{!disabled && !context.readonly && !isAuto && (
|
|
381
328
|
<div className={styles.dragBar} onMouseDown={handleStartDrag} />
|
|
382
329
|
)}
|
|
383
330
|
{after}
|
|
@@ -420,36 +367,6 @@ export function SilkeCssNumberField(props: SilkeCssNumberFieldProps) {
|
|
|
420
367
|
</SilkeBox>
|
|
421
368
|
</SilkePopover>
|
|
422
369
|
)}
|
|
423
|
-
|
|
424
|
-
{openVariables && (
|
|
425
|
-
<SilkePopover
|
|
426
|
-
anchor={rootRef}
|
|
427
|
-
targetOrigin="top-left"
|
|
428
|
-
anchorOrigin="bottom-left"
|
|
429
|
-
shadow="level2"
|
|
430
|
-
offsetY={1}
|
|
431
|
-
onRequestClose={() => setOpenVariables(false)}
|
|
432
|
-
>
|
|
433
|
-
<SilkeBox
|
|
434
|
-
column
|
|
435
|
-
bg="neutral-20"
|
|
436
|
-
rounded={size === 'xs' ? 'tiny' : 'small'}
|
|
437
|
-
overflow="hidden"
|
|
438
|
-
className={styles.menu}
|
|
439
|
-
>
|
|
440
|
-
<VariablePicker
|
|
441
|
-
variables={variables}
|
|
442
|
-
type="number"
|
|
443
|
-
onAdd={onVariableAdd}
|
|
444
|
-
onEdit={onVariableEdit}
|
|
445
|
-
onSelect={(key) => {
|
|
446
|
-
handleChange(`var(--vev-${key})`, 'variable');
|
|
447
|
-
setOpenVariables(false);
|
|
448
|
-
}}
|
|
449
|
-
/>
|
|
450
|
-
</SilkeBox>
|
|
451
|
-
</SilkePopover>
|
|
452
|
-
)}
|
|
453
370
|
</SilkeTextFieldOutline>
|
|
454
371
|
);
|
|
455
372
|
}
|
|
@@ -69,8 +69,9 @@ export function convertCSSNumberFormat(
|
|
|
69
69
|
max?: number,
|
|
70
70
|
axis?: 'x' | 'y',
|
|
71
71
|
): string {
|
|
72
|
+
if (toFormat === 'none') return `${value}`;
|
|
72
73
|
if (toFormat === 'auto') return 'auto';
|
|
73
|
-
if (fromFormat === 'auto'
|
|
74
|
+
if (fromFormat === 'auto') value = 1;
|
|
74
75
|
const fromScale = getFormatScale(fromFormat, context, axis);
|
|
75
76
|
const toScale = getFormatScale(toFormat, context, axis);
|
|
76
77
|
value = (value * fromScale) / toScale;
|
|
@@ -125,6 +126,9 @@ export function getFormatFromText(
|
|
|
125
126
|
prevFormat: string,
|
|
126
127
|
supportedFormats?: string[],
|
|
127
128
|
): string {
|
|
129
|
+
if (supportedFormats?.includes('None') && prevFormat === '') {
|
|
130
|
+
return '';
|
|
131
|
+
}
|
|
128
132
|
if (!supportedFormats?.length || !/[a-z%]$/i.test(text)) return prevFormat || 'px';
|
|
129
133
|
const partialFormat = text.replace(/[^a-z%]/g, '');
|
|
130
134
|
const reg = new RegExp('^' + partialFormat, 'i');
|
|
@@ -2,15 +2,19 @@ import { SchemaFieldProps, StringField as StringFieldType } from '@vev/utils';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { SilkeTextField } from '../../silke-text-field';
|
|
4
4
|
import { getTitle } from './utils/schema-util';
|
|
5
|
+
import { SilkeVariablesWrapper } from '../../silke-variables-wrapper';
|
|
5
6
|
|
|
7
|
+
const REGEX = /.*/;
|
|
6
8
|
const StringField = ({ schema, value, onChange }: SchemaFieldProps<StringFieldType>) => {
|
|
7
9
|
const { options } = schema;
|
|
8
10
|
|
|
9
11
|
return (
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
+
<SilkeVariablesWrapper
|
|
13
|
+
component={SilkeTextField}
|
|
14
|
+
value={value || ''}
|
|
12
15
|
multiline={!!options?.multiline}
|
|
13
16
|
label={getTitle(schema)}
|
|
17
|
+
variableType="text"
|
|
14
18
|
type={options?.type || 'text'}
|
|
15
19
|
minLength={options?.minLength}
|
|
16
20
|
maxLength={options?.maxLength}
|
|
@@ -18,6 +22,7 @@ const StringField = ({ schema, value, onChange }: SchemaFieldProps<StringFieldTy
|
|
|
18
22
|
size="xs"
|
|
19
23
|
placeholder={options?.placeholder}
|
|
20
24
|
flex
|
|
25
|
+
fullWidthWrapper
|
|
21
26
|
tooltip={schema?.description}
|
|
22
27
|
/>
|
|
23
28
|
);
|
|
@@ -13,6 +13,10 @@ interface SilkeIconProps extends HTMLAttributes<HTMLElement> {
|
|
|
13
13
|
color?: SilkeColor | string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
function isEmojiIcon(icon: SilkeIconProps['icon']): icon is IEmojiIcon {
|
|
17
|
+
return isObject(icon) && 'type' in icon;
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
export function SilkeIcon({ icon, className, color, ...rest }: SilkeIconProps): JSX.Element {
|
|
17
21
|
let cl = styles.icon;
|
|
18
22
|
if (color) cl += ' ' + 'color-' + color;
|
|
@@ -28,7 +32,7 @@ export function SilkeIcon({ icon, className, color, ...rest }: SilkeIconProps):
|
|
|
28
32
|
icon = { type: EmojiType.upload, value: { url: icon } };
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
if (
|
|
35
|
+
if (isEmojiIcon(icon)) {
|
|
32
36
|
switch (icon.type) {
|
|
33
37
|
case EmojiType.icon:
|
|
34
38
|
return <SilkeShape {...rest} className={cl} shape={icon.value} />;
|
|
@@ -44,14 +48,14 @@ export function SilkeIcon({ icon, className, color, ...rest }: SilkeIconProps):
|
|
|
44
48
|
);
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
if (!icon || !(icon in SilkeIconDefinitions))
|
|
51
|
+
if (!icon || !((icon as any) in SilkeIconDefinitions))
|
|
48
52
|
return (
|
|
49
53
|
<span {...rest} className={cl}>
|
|
50
54
|
{icon}
|
|
51
55
|
</span>
|
|
52
56
|
);
|
|
53
57
|
|
|
54
|
-
const Icon = SilkeIconDefinitions[icon];
|
|
58
|
+
const Icon = SilkeIconDefinitions[icon as keyof typeof SilkeIconDefinitions];
|
|
55
59
|
|
|
56
60
|
if (typeof Icon === 'string') return <i {...rest} className={cl + ' ' + Icon} />;
|
|
57
61
|
return (
|
|
@@ -134,7 +134,7 @@ export const SilkeNavigationLink = React.forwardRef(
|
|
|
134
134
|
{React.isValidElement(icon) || isString(icon) ? (
|
|
135
135
|
<SilkeIcon icon={icon || 'error'} />
|
|
136
136
|
) : (
|
|
137
|
-
<SilkeImage icon={icon} avatar="s" />
|
|
137
|
+
<SilkeImage icon={icon as any} avatar="s" />
|
|
138
138
|
)}
|
|
139
139
|
</SilkeBox>
|
|
140
140
|
) : (
|
|
@@ -125,10 +125,10 @@ export function SilkeOverflowMenu({
|
|
|
125
125
|
<SilkeOverflowMenuItem
|
|
126
126
|
key={index}
|
|
127
127
|
size={rest.size}
|
|
128
|
-
{...item}
|
|
128
|
+
{...(item as SilkeOverflowMenuItem)}
|
|
129
129
|
onClick={(e) => {
|
|
130
130
|
e.stopPropagation();
|
|
131
|
-
item.onClick?.(e);
|
|
131
|
+
(item as SilkeOverflowMenuItem).onClick?.(e);
|
|
132
132
|
handleToggleOpen(e);
|
|
133
133
|
}}
|
|
134
134
|
/>
|
|
@@ -53,11 +53,8 @@ export type SilkeTextFieldOutlineProps = {
|
|
|
53
53
|
labelUsingAria?: boolean;
|
|
54
54
|
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
55
55
|
onMouseDown?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
56
|
-
onVariableClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
57
56
|
disabled?: boolean;
|
|
58
57
|
tooltip?: string;
|
|
59
|
-
showVariableDot?: boolean;
|
|
60
|
-
hasActiveVariable?: boolean;
|
|
61
58
|
};
|
|
62
59
|
|
|
63
60
|
export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextFieldOutlineProps>(
|
|
@@ -83,11 +80,8 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
|
|
|
83
80
|
flex,
|
|
84
81
|
onClick,
|
|
85
82
|
onMouseDown,
|
|
86
|
-
onVariableClick,
|
|
87
83
|
disabled,
|
|
88
84
|
tooltip,
|
|
89
|
-
showVariableDot,
|
|
90
|
-
hasActiveVariable,
|
|
91
85
|
}: SilkeTextFieldOutlineProps,
|
|
92
86
|
ref,
|
|
93
87
|
) => {
|
|
@@ -104,9 +98,6 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
|
|
|
104
98
|
if (disabled) {
|
|
105
99
|
cl += ' ' + styles.disabled;
|
|
106
100
|
}
|
|
107
|
-
if (hasActiveVariable) {
|
|
108
|
-
cl += ' ' + styles.activeVariable;
|
|
109
|
-
}
|
|
110
101
|
|
|
111
102
|
const showError = Boolean(error);
|
|
112
103
|
const showHelp = Boolean((help || helpRight) && !error);
|
|
@@ -137,14 +128,6 @@ export const SilkeTextFieldOutline = React.forwardRef<HTMLDivElement, SilkeTextF
|
|
|
137
128
|
className={styles.wrapper}
|
|
138
129
|
style={width ? { minWidth: width, maxWidth: width, width } : flex ? { flex: 1 } : undefined}
|
|
139
130
|
>
|
|
140
|
-
{showVariableDot && (
|
|
141
|
-
<SilkeBox
|
|
142
|
-
className={styles.variableDot}
|
|
143
|
-
data-icon={hasActiveVariable ? '−' : '+'}
|
|
144
|
-
onClick={onVariableClick}
|
|
145
|
-
/>
|
|
146
|
-
)}
|
|
147
|
-
|
|
148
131
|
<SilkeBox
|
|
149
132
|
data-size={`data-input-${mappedSize}`}
|
|
150
133
|
tag="div"
|
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
.wrapper {
|
|
4
4
|
position: relative;
|
|
5
5
|
width: 100%;
|
|
6
|
-
|
|
7
|
-
&:hover .variableDot:before {
|
|
8
|
-
opacity: 1;
|
|
9
|
-
transform: scale(1);
|
|
10
|
-
}
|
|
11
6
|
}
|
|
12
7
|
|
|
13
8
|
.root {
|
|
@@ -90,7 +85,7 @@
|
|
|
90
85
|
.input::placeholder {
|
|
91
86
|
color: var(--text-field-disabled-placeholder-color);
|
|
92
87
|
}
|
|
93
|
-
|
|
88
|
+
}
|
|
94
89
|
|
|
95
90
|
&:not(.disabled):hover {
|
|
96
91
|
.field {
|
|
@@ -113,12 +108,6 @@
|
|
|
113
108
|
.field:has([data-input]:focus) {
|
|
114
109
|
--current-border-color: var(--text-field-focus-border-color);
|
|
115
110
|
}
|
|
116
|
-
|
|
117
|
-
&.activeVariable {
|
|
118
|
-
.input {
|
|
119
|
-
color: var(--color-support-tertiary-30);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
111
|
}
|
|
123
112
|
|
|
124
113
|
.tiny,
|
|
@@ -226,49 +215,3 @@ textarea {
|
|
|
226
215
|
padding: 0;
|
|
227
216
|
}
|
|
228
217
|
|
|
229
|
-
.variableDot {
|
|
230
|
-
position: absolute;
|
|
231
|
-
left: 0px;
|
|
232
|
-
top: 0px;
|
|
233
|
-
width: 12px;
|
|
234
|
-
height: 12px;
|
|
235
|
-
padding: 0;
|
|
236
|
-
z-index: 1;
|
|
237
|
-
cursor: pointer;
|
|
238
|
-
|
|
239
|
-
&:after,
|
|
240
|
-
&:before {
|
|
241
|
-
content: "";
|
|
242
|
-
position: absolute;
|
|
243
|
-
width: 12px;
|
|
244
|
-
height: 12px;
|
|
245
|
-
border-radius: 50%;
|
|
246
|
-
background: var(--color-neutral-100);
|
|
247
|
-
margin-top: -6px;
|
|
248
|
-
margin-left: -6px;
|
|
249
|
-
border: 4px solid var(--color-support-tertiary-30);
|
|
250
|
-
opacity: 0;
|
|
251
|
-
transform-origin: center center;
|
|
252
|
-
transition: transform 0.2s ease;
|
|
253
|
-
}
|
|
254
|
-
&:before {
|
|
255
|
-
transform: scale(0);
|
|
256
|
-
transform-origin: center center;
|
|
257
|
-
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
258
|
-
}
|
|
259
|
-
&:after {
|
|
260
|
-
content: attr(data-icon);
|
|
261
|
-
display: flex;
|
|
262
|
-
align-items: center;
|
|
263
|
-
justify-content: center;
|
|
264
|
-
line-height: 0;
|
|
265
|
-
font-weight: bold;
|
|
266
|
-
background: var(--color-support-tertiary-30);
|
|
267
|
-
transition: opacity 0.2s ease;
|
|
268
|
-
}
|
|
269
|
-
&:hover:after {
|
|
270
|
-
transform: scale(1.2);
|
|
271
|
-
opacity: 1;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
@@ -88,9 +88,6 @@ export const SilkeTextField = React.forwardRef<HTMLDivElement, SilkeTextFieldPro
|
|
|
88
88
|
disabled,
|
|
89
89
|
readOnly,
|
|
90
90
|
tooltip,
|
|
91
|
-
showVariableDot,
|
|
92
|
-
hasActiveVariable,
|
|
93
|
-
onVariableClick,
|
|
94
91
|
...rest
|
|
95
92
|
} = useFormField(props, validateText);
|
|
96
93
|
|
|
@@ -150,9 +147,6 @@ export const SilkeTextField = React.forwardRef<HTMLDivElement, SilkeTextFieldPro
|
|
|
150
147
|
flex={flex}
|
|
151
148
|
disabled={disabled}
|
|
152
149
|
tooltip={tooltip}
|
|
153
|
-
showVariableDot={showVariableDot}
|
|
154
|
-
hasActiveVariable={hasActiveVariable}
|
|
155
|
-
onVariableClick={onVariableClick}
|
|
156
150
|
>
|
|
157
151
|
{before}
|
|
158
152
|
{React.createElement(multiline ? 'textarea' : 'input', {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './silke-variables-wrapper';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SilkeIcon } from '../silke-icon';
|
|
3
|
+
import { SilkePopover } from '../silke-popover';
|
|
4
|
+
import { SilkeTextField } from '../silke-text-field';
|
|
5
|
+
import { SilkeBox } from '../silke-box';
|
|
6
|
+
|
|
7
|
+
export type SilkeVariablesWrapperFormProps = {
|
|
8
|
+
value: string;
|
|
9
|
+
containerRef?: React.RefObject<HTMLDivElement>;
|
|
10
|
+
onChange: (value: string) => void;
|
|
11
|
+
onSubmit: () => void;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function SilkeVariablesWrapperForm(props: SilkeVariablesWrapperFormProps) {
|
|
16
|
+
const handleKeyUp = (e: React.KeyboardEvent) => {
|
|
17
|
+
switch (e.key) {
|
|
18
|
+
case 'Enter': {
|
|
19
|
+
props.onSubmit();
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
case 'Escape': {
|
|
23
|
+
props.onClose();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<SilkePopover
|
|
30
|
+
offsetY={1}
|
|
31
|
+
contextId="autocomplete-dropdown"
|
|
32
|
+
anchor={props.containerRef}
|
|
33
|
+
anchorOrigin={'bottom-left'}
|
|
34
|
+
targetOrigin={'top-left'}
|
|
35
|
+
onRequestClose={props.onClose}
|
|
36
|
+
>
|
|
37
|
+
<SilkeBox
|
|
38
|
+
role="listbox"
|
|
39
|
+
rounded="tiny"
|
|
40
|
+
shadow="level3"
|
|
41
|
+
bg="neutral-20"
|
|
42
|
+
column
|
|
43
|
+
style={{ maxHeight: 300, minWidth: 168, maxWidth: 168 }}
|
|
44
|
+
vPad="xs"
|
|
45
|
+
>
|
|
46
|
+
<SilkeTextField
|
|
47
|
+
inline="label-inside"
|
|
48
|
+
label={<SilkeIcon icon="add" />}
|
|
49
|
+
aria-label="Add new variable"
|
|
50
|
+
autoFocus
|
|
51
|
+
placeholder="Enter variable name"
|
|
52
|
+
kind="ghost"
|
|
53
|
+
onChange={(text: string) => {
|
|
54
|
+
props.onChange(text);
|
|
55
|
+
}}
|
|
56
|
+
onKeyUp={handleKeyUp}
|
|
57
|
+
value={props.value}
|
|
58
|
+
/>
|
|
59
|
+
</SilkeBox>
|
|
60
|
+
</SilkePopover>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
SilkeVariablesWrapperForm.displayName = 'SilkeVariablesWrapperForm';
|