@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.
Files changed (93) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/index.js +71 -30
  3. package/dist/index.js.LEGAL.txt +10 -0
  4. package/dist/silke/src/components/index.d.ts +1 -0
  5. package/dist/silke/src/components/silke-autocomplete-field/silke-autocomplete-field.d.ts +5 -1
  6. package/dist/silke/src/components/silke-autocomplete-field/silke-autocomplete-popup.d.ts +13 -0
  7. package/dist/silke/src/components/silke-box/silke-box.d.ts +1 -1
  8. package/dist/silke/src/components/silke-button/silke-button.d.ts +11 -11
  9. package/dist/silke/src/components/silke-card/silke-card.d.ts +13 -13
  10. package/dist/silke/src/components/silke-color-swatches/silke-color-swatch-button.d.ts +1 -1
  11. package/dist/silke/src/components/silke-css-number-field/index.d.ts +0 -1
  12. package/dist/silke/src/components/silke-css-number-field/silke-css-context.d.ts +1 -1
  13. package/dist/silke/src/components/silke-css-number-field/silke-css-number-field.d.ts +0 -2
  14. package/dist/silke/src/components/silke-form/form-types.d.ts +0 -1
  15. package/dist/silke/src/components/silke-form-schema/fields/number-field.d.ts +1 -1
  16. package/dist/silke/src/components/silke-form-schema/fields/utils/generate-title.d.ts +2 -2
  17. package/dist/silke/src/components/silke-form-schema/silke-schema-context.d.ts +1 -1
  18. package/dist/silke/src/components/silke-iframe-portal/silke-iframe-context.d.ts +0 -1
  19. package/dist/silke/src/components/silke-sortable-list/silke-nested-sortable-utils.d.ts +0 -1
  20. package/dist/silke/src/components/silke-table/table-types.d.ts +0 -1
  21. package/dist/silke/src/components/silke-tag/silke-tag.d.ts +8 -8
  22. package/dist/silke/src/components/silke-text/silke-text.d.ts +11 -11
  23. package/dist/silke/src/components/silke-text-field/silke-text-field-outline.d.ts +0 -3
  24. package/dist/silke/src/components/silke-tooltip/silke-shortcuts.d.ts +2 -33
  25. package/dist/silke/src/components/silke-variables-wrapper/index.d.ts +1 -0
  26. package/dist/silke/src/components/silke-variables-wrapper/silke-variables-wrapper-form.d.ts +12 -0
  27. package/dist/silke/src/components/silke-variables-wrapper/silke-variables-wrapper.d.ts +22 -0
  28. package/dist/silke/src/docs/data/app/constants.d.ts +0 -1
  29. package/dist/silke/src/hooks/use-mouse.d.ts +0 -1
  30. package/dist/styles.css +235 -212
  31. package/dist/utils/src/css/number-format.d.ts +1 -1
  32. package/dist/utils/src/index.d.ts +0 -2
  33. package/dist/utils/src/keyboard/hooks.d.ts +0 -1
  34. package/dist/utils/src/mouse/mouse-manager.d.ts +0 -1
  35. package/dist/utils/src/types/event.d.ts +1 -2
  36. package/dist/utils/src/types/index.d.ts +0 -1
  37. package/dist/utils/src/types/vev-props.d.ts +1 -1
  38. package/esbuild.config.mjs +3 -3
  39. package/package.json +3 -3
  40. package/src/components/index.ts +1 -0
  41. package/src/components/silke-autocomplete-field/autocomplete-item.tsx +7 -2
  42. package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +40 -0
  43. package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +6 -2
  44. package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +22 -425
  45. package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +486 -0
  46. package/src/components/silke-button/silke-button.mdx +24 -0
  47. package/src/components/silke-button/silke-dropdown-button.tsx +2 -2
  48. package/src/components/silke-context-menu/silke-context-menu.tsx +2 -2
  49. package/src/components/silke-css-number-field/index.ts +0 -1
  50. package/src/components/silke-css-number-field/silke-css-context.tsx +7 -1
  51. package/src/components/silke-css-number-field/silke-css-number-field.mdx +3 -3
  52. package/src/components/silke-css-number-field/silke-css-number-field.scss +0 -12
  53. package/src/components/silke-css-number-field/silke-css-number-field.tsx +18 -101
  54. package/src/components/silke-css-number-field/utils.ts +5 -1
  55. package/src/components/silke-form-schema/fields/string-field.tsx +7 -2
  56. package/src/components/silke-form-schema/safe-eval/iframe-handler.ts +1 -0
  57. package/src/components/silke-icon/silke-icon.tsx +7 -3
  58. package/src/components/silke-navigation-link/silke-navigation-link.tsx +1 -1
  59. package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +2 -2
  60. package/src/components/silke-text-field/silke-text-field-outline.tsx +0 -17
  61. package/src/components/silke-text-field/silke-text-field.scss +1 -58
  62. package/src/components/silke-text-field/silke-text-field.tsx +0 -6
  63. package/src/components/silke-variables-wrapper/index.ts +1 -0
  64. package/src/components/silke-variables-wrapper/silke-variables-wrapper-form.tsx +64 -0
  65. package/src/components/silke-variables-wrapper/silke-variables-wrapper.mdx +126 -0
  66. package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +72 -0
  67. package/src/components/silke-variables-wrapper/silke-variables-wrapper.tsx +260 -0
  68. package/src/components/silke-virtual/silke-virtual-row.tsx +9 -6
  69. package/src/hooks/use-drop-zone.ts +1 -1
  70. package/src/hooks/use-mouse.ts +11 -4
  71. package/src/hooks/use-size.ts +14 -11
  72. package/dist/chunk-PP74IZDW.js +0 -22
  73. package/dist/chunk-PP74IZDW.js.LEGAL.txt +0 -11
  74. package/dist/chunk-PP74IZDW.js.map +0 -7
  75. package/dist/index.js.map +0 -7
  76. package/dist/silke/src/components/silke-css-number-field/variable-picker.d.ts +0 -17
  77. package/dist/silke-code-editor-LK4ESGQO.js +0 -25
  78. package/dist/silke-code-editor-LK4ESGQO.js.LEGAL.txt +0 -0
  79. package/dist/silke-code-editor-LK4ESGQO.js.map +0 -7
  80. package/dist/utils/src/events/condition-parser/evaluate-condition-expression.d.ts +0 -2
  81. package/dist/utils/src/events/condition-parser/index.d.ts +0 -1
  82. package/dist/utils/src/events/condition-parser/lexer.d.ts +0 -37
  83. package/dist/utils/src/events/condition-parser/parser.d.ts +0 -11
  84. package/dist/utils/src/interactions/get-interaction-map.d.ts +0 -3
  85. package/dist/utils/src/interactions/get-node-type.d.ts +0 -2
  86. package/dist/utils/src/interactions/has-link.d.ts +0 -5
  87. package/dist/utils/src/interactions/has-pointer-event.d.ts +0 -5
  88. package/dist/utils/src/interactions/index.d.ts +0 -7
  89. package/dist/utils/src/interactions/interaction-map-to-array.d.ts +0 -2
  90. package/dist/utils/src/interactions/is-target-global.d.ts +0 -2
  91. package/dist/utils/src/interactions/is-trigger-global.d.ts +0 -2
  92. package/dist/utils/src/types/interaction.d.ts +0 -93
  93. package/src/components/silke-css-number-field/variable-picker.tsx +0 -181
@@ -1,2 +0,0 @@
1
- export declare function evaluateEventCondition(input: string | undefined, obj?: any): boolean;
2
- export declare function isEventConditionValid(input: string | undefined): boolean;
@@ -1 +0,0 @@
1
- export * from './evaluate-condition-expression';
@@ -1,37 +0,0 @@
1
- export declare enum TokenTypes {
2
- Equal = "Equal",
3
- NotEqual = "NotEqual",
4
- Bigger = "Bigger",
5
- Smaller = "Smaller",
6
- Not = "Not",
7
- BiggerEqual = "BiggerEqual",
8
- SmallerEqual = "SmallerEqual",
9
- ObjectAccessOperator = "ObjectAccessOperator",
10
- Identifier = "Identifier",
11
- Number = "Number",
12
- String = "String",
13
- True = "True",
14
- False = "False",
15
- And = "And",
16
- Or = "Or",
17
- EOF = "EOF"
18
- }
19
- export interface Token {
20
- type: TokenTypes;
21
- pattern?: string;
22
- }
23
- export interface Tokenized {
24
- type: TokenTypes;
25
- value?: string;
26
- }
27
- export declare class Lexer {
28
- input: string;
29
- pos: number;
30
- constructor();
31
- private isHyphen;
32
- private isNumber;
33
- private processNumber;
34
- private isCharacter;
35
- private processIdentifier;
36
- tokenize(input: string): Tokenized[];
37
- }
@@ -1,11 +0,0 @@
1
- import { Tokenized } from './lexer';
2
- export declare class Parser {
3
- constructor();
4
- parse(tokens: Tokenized[]): (scope: any) => boolean;
5
- private multiConditionExpression;
6
- private comparisonExpression;
7
- private object;
8
- private comparison;
9
- private value;
10
- private getObjectValue;
11
- }
@@ -1,3 +0,0 @@
1
- import { GLOBAL_TRIGGER_TYPES, InteractionMap, ProjectInteraction } from '../types';
2
- export declare function getInteractionMap(interactions?: ProjectInteraction[]): InteractionMap;
3
- export declare function isGlobalTrigger(value: string): value is GLOBAL_TRIGGER_TYPES;
@@ -1,2 +0,0 @@
1
- import { ProjectInteraction } from '../types';
2
- export declare function getInteractionsNodeType(contentKey: string, interactions: ProjectInteraction[], defaultTag?: string): string;
@@ -1,5 +0,0 @@
1
- import { ProjectInteraction } from '../types';
2
- /**
3
- * Checks for interaction trigger DOM nodes
4
- */
5
- export declare function hasLink(interaction: Partial<ProjectInteraction>): boolean;
@@ -1,5 +0,0 @@
1
- import { ProjectInteraction } from '../types';
2
- /**
3
- * Checks for interaction trigger DOM nodes
4
- */
5
- export declare function hasPointerEvent(interaction: Partial<ProjectInteraction>): boolean;
@@ -1,7 +0,0 @@
1
- export * from './get-node-type';
2
- export * from './has-link';
3
- export * from './has-pointer-event';
4
- export * from './is-target-global';
5
- export * from './is-trigger-global';
6
- export * from './get-interaction-map';
7
- export * from './interaction-map-to-array';
@@ -1,2 +0,0 @@
1
- import { InteractionMap, ProjectInteraction } from '../types';
2
- export declare function interactionMapToArray(interactions: InteractionMap): ProjectInteraction[];
@@ -1,2 +0,0 @@
1
- import { ProjectInteraction } from '../types';
2
- export declare function isTargetGlobal(interaction: ProjectInteraction): boolean;
@@ -1,2 +0,0 @@
1
- import { ProjectInteraction } from '../types';
2
- export declare function isTriggerGlobal(interaction: ProjectInteraction): boolean;
@@ -1,93 +0,0 @@
1
- import { VevProps } from '.';
2
- export type VevCondition = string;
3
- export declare enum TRIGGER_SCOPE {
4
- POINTER_EVENT = "pointer-event",
5
- SCROLL = "scroll",
6
- GLOBAL = "global",
7
- KEYBOARD = "keyboard"
8
- }
9
- export declare enum EVENT_SCOPE {
10
- ELEMENT = "element",
11
- PAGE = "page",
12
- VARIABLE = "variable",
13
- EXTERNAL = "external",
14
- TRACKING = "tracking"
15
- }
16
- export type VevDispatchEvent = {
17
- type?: string;
18
- contentKey?: string;
19
- instanceKeyChain?: string;
20
- args?: Record<string, string>;
21
- };
22
- export type TriggerItem = {
23
- label: string;
24
- value: VevTriggerType;
25
- icon?: string;
26
- scope?: EVENT_SCOPE | TRIGGER_SCOPE;
27
- };
28
- export declare enum NATIVE_TRIGGER_TYPES {
29
- ON_CLICK = "onClick",
30
- ON_MOUSE_ENTER = "onMouseEnter",
31
- ON_MOUSE_LEAVE = "onMouseLeave",
32
- ON_MOUSE_DOWN = "onMouseDown",
33
- ON_MOUSE_UP = "onMouseUp",
34
- ON_DOUBLE_CLICK = "onDoubleClick",
35
- ON_TOUCH_START = "onTouchStart",
36
- ON_TOUCH_END = "onTouchEnd"
37
- }
38
- export declare const NATIVE_TRIGGERS: TriggerItem[];
39
- export declare enum CUSTOM_TRIGGER_TYPES {
40
- ON_VISIBLE = "onVisible",
41
- ON_LEAVE = "onLeave",
42
- ON_SWIPE = "onSwipe"
43
- }
44
- export declare const CUSTOM_TRIGGERS: TriggerItem[];
45
- export declare enum GLOBAL_TRIGGER_TYPES {
46
- ON_SCROLL = "onScroll",
47
- ON_TIMER = "onTimer",
48
- ON_KEY_DOWN = "onKeyDown",
49
- ON_KEY_UP = "onKeyUp"
50
- }
51
- export declare const GLOBAL_TRIGGERS: TriggerItem[];
52
- export declare enum GLOBAL_EVENT_TYPES {
53
- SHOW = "SHOW",
54
- HIDE = "HIDE",
55
- STICK = "STICK",
56
- UNSTICK = "UNSTICK",
57
- TOGGLE = "TOGGLE_VISIBILITY",
58
- SCROLL_TO_ELEMENT = "SCROLL_TO_ELEMENT",
59
- OPEN_PAGE = "OPEN_PAGE",
60
- OPEN_URL = "OPEN_URL",
61
- DOWNLOAD_FILE = "DOWNLOAD_FILE",
62
- SEND_EMAIL = "SEND_EMAIL",
63
- CALL_PHONE = "CALL_PHONE",
64
- SEND_SMS = "SEND_SMS",
65
- TRACK = "TRACK",
66
- SET_VARIABLE = "SET_VARIABLE"
67
- }
68
- export declare const GLOBAL_EVENTS: TriggerItem[];
69
- export type VevTriggerType = NATIVE_TRIGGER_TYPES | CUSTOM_TRIGGER_TYPES | string;
70
- export type VevTrigger = {
71
- type: VevTriggerType;
72
- contentKey?: string;
73
- name?: string;
74
- condition?: VevCondition;
75
- args?: VevProps[];
76
- };
77
- export type ProjectInteraction = {
78
- key: string;
79
- event?: VevDispatchEvent;
80
- trigger?: VevTrigger;
81
- disabled?: boolean;
82
- updated: number;
83
- deleted?: number;
84
- };
85
- export type InteractionMap = {
86
- trigger: {
87
- global: Record<GLOBAL_TRIGGER_TYPES, ProjectInteraction[]>;
88
- widget: Record<string, ProjectInteraction[]>;
89
- };
90
- event: {
91
- widget: Record<string, ProjectInteraction[]>;
92
- };
93
- };
@@ -1,181 +0,0 @@
1
- import React, { useMemo, useState } from 'react';
2
- import { Data } from '../silke-autocomplete-field/autocomplete-types';
3
- import { SilkeBox } from '../silke-box';
4
- import { SilkeIcon } from '../silke-icon';
5
- import { SilkeTextMicro, SilkeTextSmall } from '../silke-text';
6
- import { SilkeDivider } from '../silke-divider';
7
- import AutocompleteItem from '../silke-autocomplete-field/autocomplete-item';
8
- import { SilkeTextField, SilkeTextFieldItem } from '../silke-text-field';
9
- import { SilkeButton } from '../silke-button';
10
-
11
- const getVariableIcon = (variable: Variable) => {
12
- return variable.type === 'color' ? 'variable.color' : 'hashtag';
13
- };
14
-
15
- function getIndexInDir(
16
- currentIndex: number,
17
- listLength: number,
18
- dir: 'ArrowUp' | 'ArrowDown',
19
- ): number {
20
- if (dir === 'ArrowUp') {
21
- return currentIndex === 0 ? listLength - 1 : currentIndex - 1;
22
- }
23
- return currentIndex < 0 ? 0 : currentIndex === listLength - 1 ? 0 : currentIndex + 1;
24
- }
25
-
26
- type Variable = { key: string; name: string; type: string; value?: string; unit?: string };
27
-
28
- type VariablePickerProps = {
29
- variables: Variable[];
30
- type: 'color' | 'number' | 'font';
31
- onAdd?: (type: string) => void;
32
- onEdit?: (key: string) => void;
33
- onSelect: (variableKey: string) => void;
34
- };
35
-
36
- export function VariablePicker(props: VariablePickerProps) {
37
- const { variables = [], type, onAdd, onEdit, onSelect } = props;
38
- const [highlight, setHighlight] = useState<undefined | number>(-1);
39
- const [search, setSearch] = useState('');
40
-
41
- const variableItems = useMemo(() => {
42
- const items = variables.map((v) => ({
43
- label: v.name,
44
- value: v.key,
45
- subLabel: `${v.value}${v.unit ? `${v.unit}` : ''}`,
46
- icon: getVariableIcon(v),
47
- })) as Data<string>[];
48
-
49
- return search
50
- ? items.filter(
51
- (item) =>
52
- item.label?.toLowerCase().includes(search.toLowerCase()) ||
53
- item.subLabel?.toLowerCase().includes(search.toLowerCase()),
54
- )
55
- : items;
56
- }, [variables, search]);
57
-
58
- const handleChange = (value: string) => {
59
- onSelect(value);
60
- };
61
-
62
- const handleKeyUp = (e: React.KeyboardEvent) => {
63
- switch (e.key) {
64
- case 'ArrowUp':
65
- case 'ArrowDown': {
66
- e.preventDefault();
67
- e.stopPropagation();
68
- const { key } = e;
69
- setHighlight((value) => getIndexInDir(value || 0, variableItems.length, key));
70
- break;
71
- }
72
- case 'Enter': {
73
- const item = highlight !== undefined && variableItems[highlight];
74
- if (item && item.value) {
75
- onSelect(item.value);
76
- }
77
- break;
78
- }
79
- }
80
- };
81
-
82
- return (
83
- <SilkeBox column bg="neutral-20" style={{ width: '168px' }} onKeyUp={handleKeyUp}>
84
- <SilkeBox gap="s" pad="xs" vAlign="center">
85
- <SilkeTextField
86
- kind="ghost"
87
- value={search}
88
- onChange={setSearch}
89
- size="xs"
90
- inline
91
- autoFocus
92
- placeholder={type === 'color' ? 'Color' : type === 'number' ? 'Number' : 'Font'}
93
- >
94
- <SilkeTextFieldItem before align="center">
95
- <SilkeBox size="s" align="center">
96
- <SilkeIcon
97
- icon={type === 'color' ? 'variable.color' : 'hashtag'}
98
- color="neutral-60"
99
- />
100
- </SilkeBox>
101
- </SilkeTextFieldItem>
102
- {search && (
103
- <SilkeTextFieldItem>
104
- <SilkeButton icon="close" kind="ghost" size="s" onClick={() => setSearch('')} />
105
- </SilkeTextFieldItem>
106
- )}
107
- {onAdd && !search && (
108
- <SilkeTextFieldItem>
109
- <SilkeButton icon="add" kind="ghost" size="s" onClick={() => onAdd(type)} />
110
- </SilkeTextFieldItem>
111
- )}
112
- </SilkeTextField>
113
- </SilkeBox>
114
-
115
- <SilkeDivider dark />
116
-
117
- <SilkeBox
118
- role="listbox"
119
- column
120
- style={{ maxHeight: 162, overflow: 'auto' }}
121
- hPad="xs"
122
- vPad="xs"
123
- >
124
- {variableItems?.map((item, i) => (
125
- <AutocompleteItem
126
- size="base"
127
- highlight={i === highlight}
128
- ItemRender={({ item }) => (
129
- <SilkeBox
130
- key={`${item.label}-${item.value}`}
131
- gap="s"
132
- hPad="s"
133
- vAlign="center"
134
- overflow="hidden"
135
- onMouseEnter={() => setHighlight(i)}
136
- fill
137
- >
138
- <SilkeBox
139
- size="xs"
140
- hAlign
141
- vAlign
142
- rounded="tiny"
143
- bg="neutral-50"
144
- style={type === 'color' ? { backgroundColor: item.subLabel } : undefined}
145
- />
146
- <SilkeBox column style={{ minWidth: '0', flex: 1 }}>
147
- <SilkeTextSmall overflow>{item.label}</SilkeTextSmall>
148
- <SilkeTextMicro overflow color="neutral-60">
149
- {item.subLabel}
150
- </SilkeTextMicro>
151
- </SilkeBox>
152
-
153
- {onEdit && i === highlight && (
154
- <SilkeBox>
155
- <SilkeButton
156
- icon="settings"
157
- kind="ghost"
158
- size="s"
159
- onMouseDown={(e) => {
160
- e.preventDefault;
161
- e.stopPropagation();
162
- onEdit(item.value);
163
- }}
164
- />
165
- </SilkeBox>
166
- )}
167
- </SilkeBox>
168
- )}
169
- key={i}
170
- item={item}
171
- onMouseDown={(e) => {
172
- e.preventDefault();
173
- e.stopPropagation();
174
- if (!item.divider && !item.disabled) handleChange(item.value);
175
- }}
176
- />
177
- ))}
178
- </SilkeBox>
179
- </SilkeBox>
180
- );
181
- }