@vev/silke 1.1.2 → 1.1.6

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 (48) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/index.js +37 -35
  3. package/dist/index.js.LEGAL.txt +12 -0
  4. package/dist/styles.css +3917 -3753
  5. package/dist/types/components/index.d.ts +2 -0
  6. package/dist/types/components/silke-action-list/index.d.ts +1 -0
  7. package/dist/types/components/silke-action-list/silke-action-list.d.ts +11 -0
  8. package/dist/types/components/silke-autocomplete-field/autocomplete-types.d.ts +4 -0
  9. package/dist/types/components/silke-autocomplete-field/index.d.ts +1 -0
  10. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field-native.d.ts +60 -0
  11. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-field.d.ts +3 -0
  12. package/dist/types/components/silke-autocomplete-field/silke-autocomplete-popup-native.d.ts +15 -0
  13. package/dist/types/components/silke-conditions-input/utils.d.ts +1 -1
  14. package/dist/types/components/silke-popover-native/index.d.ts +1 -0
  15. package/dist/types/components/silke-popover-native/silke-popover-native.d.ts +35 -0
  16. package/dist/types/components/silke-popover-native/types.d.ts +6 -0
  17. package/dist/types/components/silke-popover-native/use-popover-positioning.d.ts +9 -0
  18. package/dist/types/components/silke-select-field/index.d.ts +1 -0
  19. package/dist/types/components/silke-select-field/silke-select-field-native.d.ts +4 -0
  20. package/dist/types/icons.d.ts +2 -0
  21. package/package.json +3 -2
  22. package/src/components/index.ts +2 -0
  23. package/src/components/silke-action-list/index.ts +1 -0
  24. package/src/components/silke-action-list/silke-action-list.mdx +48 -0
  25. package/src/components/silke-action-list/silke-action-list.scss +21 -0
  26. package/src/components/silke-action-list/silke-action-list.tsx +85 -0
  27. package/src/components/silke-autocomplete-field/autocomplete-types.ts +4 -0
  28. package/src/components/silke-autocomplete-field/index.ts +1 -0
  29. package/src/components/silke-autocomplete-field/silke-autocomplete-field-native.tsx +346 -0
  30. package/src/components/silke-autocomplete-field/silke-autocomplete-field.mdx +39 -0
  31. package/src/components/silke-autocomplete-field/silke-autocomplete-field.tsx +3 -0
  32. package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +541 -0
  33. package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +54 -22
  34. package/src/components/silke-button/silke-button.scss +3 -3
  35. package/src/components/silke-color-picker/silke-color-space.tsx +3 -1
  36. package/src/components/silke-form-schema/silke-schema-field.tsx +1 -1
  37. package/src/components/silke-popover-native/index.ts +1 -0
  38. package/src/components/silke-popover-native/silke-popover-native.mdx +207 -0
  39. package/src/components/silke-popover-native/silke-popover-native.scss +112 -0
  40. package/src/components/silke-popover-native/silke-popover-native.tsx +172 -0
  41. package/src/components/silke-popover-native/types.ts +21 -0
  42. package/src/components/silke-popover-native/use-popover-positioning.ts +159 -0
  43. package/src/components/silke-select-field/index.ts +1 -0
  44. package/src/components/silke-select-field/silke-select-field-native.tsx +17 -0
  45. package/src/components/silke-select-field/silke-select-field.mdx +65 -0
  46. package/src/components/silke-text-field/silke-text-field.tsx +2 -1
  47. package/src/icons.tsx +2 -0
  48. package/tsconfig.build.tsbuildinfo +1 -1
@@ -39,6 +39,8 @@ export * from './silke-tile';
39
39
  export * from './silke-toolbar';
40
40
  export * from './silke-tooltip';
41
41
  export * from './silke-action-box';
42
+ export * from './silke-popover-native';
43
+ export * from './silke-action-list';
42
44
  export * from './silke-autocomplete-field';
43
45
  export * from './silke-checkbox';
44
46
  export * from './silke-color-picker';
@@ -0,0 +1 @@
1
+ export * from './silke-action-list';
@@ -0,0 +1,11 @@
1
+ import { SilkeIcons } from '../silke-icon';
2
+ export declare const SilkeActionListItem: ({ label, icon, items, ...rest }: SilkeActionListItemData) => import("react/jsx-runtime").JSX.Element;
3
+ export type SilkeActionListItemData = {
4
+ label: string;
5
+ icon?: SilkeIcons;
6
+ items?: SilkeActionListItemData[];
7
+ };
8
+ export type SilkeActionListProps = {
9
+ items: SilkeActionListItemData[];
10
+ };
11
+ export declare function SilkeActionList({ items, ...rest }: SilkeActionListProps): import("react/jsx-runtime").JSX.Element;
@@ -25,6 +25,10 @@ export interface Data<T> {
25
25
  */
26
26
  subLabel?: string;
27
27
  value: T;
28
+ /**
29
+ * Group label for the item (creates optionGroup)
30
+ */
31
+ groupLabel?: string;
28
32
  }
29
33
  export interface Divider {
30
34
  image?: string;
@@ -1,5 +1,6 @@
1
1
  import AutocompleteTags from './autocomplete-tags';
2
2
  export * from './silke-autocomplete-field';
3
+ export * from './silke-autocomplete-field-native';
3
4
  export { Entry } from './autocomplete-types';
4
5
  export * from './autocomplete-tags';
5
6
  export { AutocompleteTags };
@@ -0,0 +1,60 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { PopoverOrigin } from '../silke-popover';
3
+ import { SilkeTextFieldProps } from '../silke-text-field';
4
+ import { AutocompleteRenderItemProps } from './autocomplete-item';
5
+ import { AutocompleteTagsProps } from './autocomplete-tags';
6
+ import { Entry, MultiProps, SingleProps } from './autocomplete-types';
7
+ /**
8
+ * Props for autocomplete field
9
+ */
10
+ export type SilkeAutocompleteFieldNativeProps<T = any, U extends Entry<T> = any> = (MultiProps<T> | SingleProps<T>) & Omit<SilkeTextFieldProps, 'multiline' | 'maxLength' | 'minLength' | 'value'> & {
11
+ disableSearch?: boolean;
12
+ disableAddFromList?: boolean;
13
+ noReset?: boolean;
14
+ hideListArrow?: boolean;
15
+ isVariable?: boolean;
16
+ maxDisplayedItems?: number;
17
+ maxDisplayedItemsLabel?: React.ReactNode;
18
+ showAddIcon?: boolean;
19
+ selectedVariableKey?: string;
20
+ /** What point of the target should be used for centering default center-center */
21
+ targetOrigin?: PopoverOrigin;
22
+ /** What point of the anchor should be used for centering default center-center */
23
+ anchorOrigin?: PopoverOrigin;
24
+ dropDownMinWidth?: number;
25
+ dropDownMaxWidth?: number;
26
+ /**
27
+ * Possible values
28
+ */
29
+ items: U[];
30
+ /**
31
+ * Minimum number of characters in search for results to show
32
+ */
33
+ minChars?: number;
34
+ buttonRight?: ReactNode;
35
+ /** Cypress tag */
36
+ 'data-cy'?: string;
37
+ /**
38
+ * If a function is passed, an "Add item" entry will be shown in the list if nothing matches text search. This function will be the callback.
39
+ * @param value The value entered
40
+ */
41
+ onAdd?: (value: string) => void;
42
+ /**
43
+ * Use custom component for rendering the autocomplete items
44
+ */
45
+ renderItem?: (props: AutocompleteRenderItemProps<U>) => React.ReactElement | null;
46
+ /**
47
+ * Use custom component for rendering autocomplete tags
48
+ */
49
+ renderTags?: (props: AutocompleteTagsProps<T>) => React.ReactElement | null;
50
+ /**
51
+ * Custom sort of items (default sorts by label)
52
+ */
53
+ sort?: (one: Entry<T>, other: Entry<T>) => number;
54
+ onSearch?: (value: string) => void;
55
+ /**
56
+ * Called when dropdown closes for any reason
57
+ */
58
+ onClose?: () => void;
59
+ };
60
+ export declare function SilkeAutocompleteFieldNative<T>(props: SilkeAutocompleteFieldNativeProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -57,4 +57,7 @@ export type SilkeAutocompleteFieldProps<T = any, U extends Entry<T> = any> = (Mu
57
57
  */
58
58
  onClose?: () => void;
59
59
  };
60
+ /**
61
+ * @deprecated Use SilkeAutocompleteFieldNative instead. This component will be removed in a future version.
62
+ */
60
63
  export declare function SilkeAutocompleteField<T>(props: SilkeAutocompleteFieldProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Entry } from './autocomplete-types';
3
+ import { SilkeAutocompleteFieldProps } from './silke-autocomplete-field';
4
+ /**
5
+ * Props for autocomplete popup
6
+ */
7
+ type SilkeAutocompletePopupNativeProps<T = any> = SilkeAutocompleteFieldProps<T> & {
8
+ containerRef?: React.RefObject<HTMLDivElement>;
9
+ searchPlaceholder?: string;
10
+ onRequestClose?: () => void;
11
+ hide?: boolean;
12
+ };
13
+ export declare const useMatchingItemsOnTop: (filteredItems: Entry<any>[], searchString?: string, selectedLabel?: string) => Entry<any>[];
14
+ export declare function SilkeAutocompletePopupNative<T>(props: SilkeAutocompletePopupNativeProps<T>): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -8,4 +8,4 @@ export declare const getSuggestions: (searchValue: string, variables: SilkeCSSCo
8
8
  export declare const getSystemSuggestionOptions: (value: string | number | boolean, systemOptions?: VevConditionSuggestion[]) => ConditionSuggestion[];
9
9
  export declare const getWidgetSuggestionOptions: (value: string | number | boolean, widgetOptions?: VevProps[]) => ConditionSuggestion[];
10
10
  export declare const isWidgetOption: (value: string | number | boolean, widgetOptions?: VevProps[]) => boolean;
11
- export declare const getWidgetOptionType: (value: string | number | boolean, widgetOptions?: VevProps[]) => "string" | "number" | "boolean" | "object" | "link" | "audio" | "menu" | "select" | "video" | "image" | "layout" | "icon" | "upload" | "divider" | "variable" | "array" | "event" | "widgetSelect" | undefined;
11
+ export declare const getWidgetOptionType: (value: string | number | boolean, widgetOptions?: VevProps[]) => "string" | "number" | "boolean" | "object" | "link" | "audio" | "menu" | "select" | "video" | "image" | "layout" | "icon" | "upload" | "divider" | "variable" | "array" | "event" | "widgetSelect" | "mainComponent" | undefined;
@@ -0,0 +1 @@
1
+ export * from './silke-popover-native';
@@ -0,0 +1,35 @@
1
+ import 'invokers';
2
+ import React from 'react';
3
+ import type { PopoverAnchorNative, PopoverPlacement } from './types';
4
+ export interface SilkePopoverNativeProps {
5
+ id?: string;
6
+ /** Should the popover be hidden */
7
+ hide?: boolean;
8
+ /** Children to add inside the popover */
9
+ children?: React.ReactElement | React.ReactElement[];
10
+ /** Element to anchor the popover to (ref) */
11
+ anchor?: PopoverAnchorNative;
12
+ /** Where to place the popover relative to the anchor. 'start' aligns the start of the popover with the start of the anchor. 'end' aligns the end of the popover with the end of the anchor. */
13
+ placement?: PopoverPlacement;
14
+ /** Advanced: What slot of the anchor should be used for positioning (overrides placement) */
15
+ anchorSlot?: string;
16
+ /** Advanced: Vertical alignment of the popover (overrides placement) */
17
+ align?: string;
18
+ /** Advanced: Horizontal alignment of the popover (overrides placement) */
19
+ justify?: string;
20
+ /** Offset the popover position horizontally */
21
+ offsetX?: number;
22
+ /** Offset the popover position vertically */
23
+ offsetY?: number;
24
+ /** Should the popover have a backdrop */
25
+ hideBackdrop?: boolean;
26
+ /** Should the popover match the width of the anchor */
27
+ matchWidth?: boolean;
28
+ /** Show popover on hover (hint mode) - automatically shows on anchor hover and stays visible when hovering popover */
29
+ hint?: boolean;
30
+ /** Should the popover be animated */
31
+ animate?: boolean;
32
+ /** Triggered when the popover is dismissed (via light dismiss or escape key) */
33
+ onRequestClose?: () => void;
34
+ }
35
+ export declare function SilkePopoverNative({ anchor, children, hide, id, placement, anchorSlot, align, justify, offsetX, offsetY, hideBackdrop, matchWidth, hint, animate, onRequestClose, }: SilkePopoverNativeProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ export type PopoverPlacement = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
2
+ export type PopoverAnchorNative = React.RefObject<HTMLElement>;
3
+ export interface PopoverToggleEvent extends Event {
4
+ newState: 'open' | 'closed';
5
+ oldState: 'open' | 'closed';
6
+ }
@@ -0,0 +1,9 @@
1
+ import { type CSSProperties } from 'react';
2
+ import type { PopoverAnchorNative, PopoverPlacement } from './types';
3
+ export declare function usePopoverPositioning(popoverRef: React.RefObject<HTMLDivElement>, anchor: PopoverAnchorNative | undefined, anchorName: string, placementStyles: ExtendedCSSProperties, offsetX?: number, offsetY?: number, matchWidth?: boolean): void;
4
+ type ExtendedCSSProperties = CSSProperties & {
5
+ positionArea?: string;
6
+ positionTryFallbacks?: string;
7
+ };
8
+ export declare function getPlacementStyles(placement: PopoverPlacement): ExtendedCSSProperties;
9
+ export {};
@@ -1 +1,2 @@
1
1
  export * from './silke-select-field';
2
+ export * from './silke-select-field-native';
@@ -0,0 +1,4 @@
1
+ import { SilkeAutocompleteFieldNativeProps } from '../silke-autocomplete-field';
2
+ import { Entry } from '../silke-autocomplete-field/autocomplete-types';
3
+ export type SilkeSelectFieldNativeProps<T, U extends Entry<T> = any> = Omit<SilkeAutocompleteFieldNativeProps<T, U>, 'disableSearch' | 'noReset'>;
4
+ export declare function SilkeSelectFieldNative<T, U extends Entry<T>>(props: SilkeSelectFieldNativeProps<T, U>): import("react/jsx-runtime").JSX.Element;
@@ -399,6 +399,8 @@ export declare const SilkeIconDefinitions: {
399
399
  'interaction.disabled': string;
400
400
  'interaction.scroll-parallax': string;
401
401
  'interaction.slider': string;
402
+ 'interaction.movement': string;
403
+ 'interaction.translate': string;
402
404
  'variable.icon': string;
403
405
  'variable.color': string;
404
406
  'variable.text': string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vev/silke",
3
- "version": "1.1.2",
3
+ "version": "1.1.6",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -25,7 +25,8 @@
25
25
  "@vev/interactions": "*",
26
26
  "@vev/react": "*",
27
27
  "@vev/utils": "*",
28
- "classnames": ">=2.2.0"
28
+ "classnames": ">=2.2.0",
29
+ "invokers": "^1.8.0"
29
30
  },
30
31
  "devDependencies": {
31
32
  "del-cli": "*",
@@ -41,6 +41,8 @@ export * from './silke-tile';
41
41
  export * from './silke-toolbar';
42
42
  export * from './silke-tooltip';
43
43
  export * from './silke-action-box';
44
+ export * from './silke-popover-native';
45
+ export * from './silke-action-list';
44
46
 
45
47
  // Form fields
46
48
  export * from './silke-autocomplete-field';
@@ -0,0 +1 @@
1
+ export * from './silke-action-list';
@@ -0,0 +1,48 @@
1
+ # Action list
2
+
3
+ Action list is a list of actions that can be used to perform actions on a resource.
4
+
5
+ ## Basic usage
6
+
7
+ ```js
8
+ const items = [{ label: 'Action 1' }, { label: 'Action 2' }];
9
+ <SilkeActionList items={items} />;
10
+ ```
11
+
12
+ ## Nested list
13
+
14
+ ```js
15
+ const items = [
16
+ { label: 'Action 1', icon: 'square' },
17
+ { label: 'Action 2', icon: 'square' },
18
+ {
19
+ label: 'Action 3',
20
+ icon: 'square',
21
+ items: [
22
+ { label: 'Action 3.1', icon: 'square' },
23
+ {
24
+ label: 'Action 3.2',
25
+ icon: 'square',
26
+ items: [
27
+ { label: 'Action 3.2.1', icon: 'square' },
28
+ { label: 'Action 3.2.2', icon: 'square' },
29
+ { label: 'Action 3.2.3', icon: 'square' },
30
+ ],
31
+ },
32
+ { label: 'Action 3.3', icon: 'square' },
33
+ ],
34
+ },
35
+ { label: 'Action 4', icon: 'square' },
36
+ { label: 'Action 5', icon: 'square' },
37
+ {
38
+ label: 'Action 6',
39
+ icon: 'square',
40
+ items: [
41
+ { label: 'Action 6.1', icon: 'square' },
42
+ { label: 'Action 6.2', icon: 'square' },
43
+ { label: 'Action 6.3', icon: 'square' },
44
+ ],
45
+ },
46
+ ];
47
+ <SilkeActionList items={items} />;
48
+ ```
@@ -0,0 +1,21 @@
1
+ @use "../../variables" as *;
2
+
3
+
4
+ .wrapper {
5
+ border: 1px solid var(--color-surface-3);
6
+ background-color: var(--color-surface-1);
7
+ }
8
+
9
+ .list {
10
+ list-style: none;
11
+ margin: 0;
12
+ padding: 0;
13
+ }
14
+
15
+ .subItems {
16
+ display: none;
17
+ }
18
+
19
+ .item:hover + .subItems {
20
+ display: block;
21
+ }
@@ -0,0 +1,85 @@
1
+ import React, { useRef } from 'react';
2
+ import { SilkeBox } from '../silke-box';
3
+ import { SilkeIcon, SilkeIcons } from '../silke-icon';
4
+
5
+ import styles from './silke-action-list.scss';
6
+ import { SilkePopoverNative } from '../silke-popover-native';
7
+
8
+ export const SilkeActionListItem = ({ label, icon, items, ...rest }: SilkeActionListItemData) => {
9
+ const boxRef = useRef<HTMLButtonElement>(null);
10
+ const hasChildren = items && items.length > 0;
11
+
12
+ return (
13
+ <>
14
+ <SilkeBox
15
+ ref={boxRef}
16
+ tag="button"
17
+ rounded="small"
18
+ gap="s"
19
+ bg="neutral-20"
20
+ bgHover="neutral-30"
21
+ className={styles.item}
22
+ {...rest}
23
+ >
24
+ {icon && (
25
+ <span className={styles.icon}>
26
+ <SilkeIcon icon={icon} />
27
+ </span>
28
+ )}
29
+ {label}
30
+ {hasChildren && (
31
+ <span className={styles.icon}>
32
+ <SilkeIcon icon="right" />
33
+ </span>
34
+ )}
35
+ </SilkeBox>
36
+
37
+ {hasChildren && (
38
+ <SilkePopoverNative hint anchor={boxRef} placement="right-start" hideBackdrop>
39
+ <SilkeActionList items={items} />
40
+ </SilkePopoverNative>
41
+ )}
42
+ </>
43
+ );
44
+ };
45
+
46
+ export type SilkeActionListItemData = {
47
+ label: string;
48
+ icon?: SilkeIcons;
49
+ items?: SilkeActionListItemData[];
50
+ };
51
+
52
+ export type SilkeActionListProps = {
53
+ items: SilkeActionListItemData[];
54
+ };
55
+
56
+ export function SilkeActionList({ items, ...rest }: SilkeActionListProps) {
57
+ const cl: string[] = [styles.wrapper];
58
+
59
+ return (
60
+ <SilkeBox
61
+ tag="ul"
62
+ tabIndex={-1}
63
+ column
64
+ pad="xs"
65
+ bg="neutral-20"
66
+ className={cl.join(' ')}
67
+ {...rest}
68
+ >
69
+ <SilkeBox tag="li" column>
70
+ {items.map((item, index) => {
71
+ const { label, icon, items: subItems, ...itemRest } = item;
72
+ return (
73
+ <SilkeActionListItem
74
+ key={index}
75
+ label={label}
76
+ icon={icon}
77
+ items={subItems}
78
+ {...itemRest}
79
+ />
80
+ );
81
+ })}
82
+ </SilkeBox>
83
+ </SilkeBox>
84
+ );
85
+ }
@@ -26,6 +26,10 @@ export interface Data<T> {
26
26
  */
27
27
  subLabel?: string;
28
28
  value: T;
29
+ /**
30
+ * Group label for the item (creates optionGroup)
31
+ */
32
+ groupLabel?: string;
29
33
  }
30
34
 
31
35
  export interface Divider {
@@ -1,6 +1,7 @@
1
1
  import AutocompleteTags from './autocomplete-tags';
2
2
 
3
3
  export * from './silke-autocomplete-field';
4
+ export * from './silke-autocomplete-field-native';
4
5
  export { Entry } from './autocomplete-types';
5
6
  export * from './autocomplete-tags';
6
7
  export { AutocompleteTags };