@vev/silke 1.1.6 → 1.1.7
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 +8 -0
- package/dist/index.js +35 -35
- package/dist/index.js.LEGAL.txt +12 -12
- package/dist/styles.css +4416 -4020
- package/dist/types/components/index.d.ts +3 -2
- package/dist/types/components/silke-button/silke-dropdown-button.d.ts +8 -13
- package/dist/types/components/silke-card/silke-card-grid.d.ts +33 -1
- package/dist/types/components/silke-command-text-field/image-utils.d.ts +20 -0
- package/dist/types/components/silke-command-text-field/index.d.ts +4 -0
- package/dist/types/components/silke-command-text-field/silke-command-parser.d.ts +3 -0
- package/dist/types/components/silke-command-text-field/silke-command-parser.spec.d.ts +1 -0
- package/dist/types/components/silke-command-text-field/silke-command-text-field.d.ts +46 -0
- package/dist/types/components/silke-command-text-field/utils.d.ts +61 -0
- package/dist/types/components/silke-command-text-field/utils.spec.d.ts +1 -0
- package/dist/types/components/silke-form-schema/silke-schema-fields.d.ts +1 -0
- package/dist/types/components/silke-image/silke-image.d.ts +2 -1
- package/dist/types/components/silke-list/index.d.ts +1 -0
- package/dist/types/components/silke-list/silke-list-item.d.ts +24 -6
- package/dist/types/components/silke-list/silke-list.d.ts +9 -9
- package/dist/types/components/silke-list/types.d.ts +19 -0
- package/dist/types/components/silke-list/utils.d.ts +3 -0
- package/dist/types/components/silke-navigation-link/silke-navigation-link.d.ts +1 -0
- package/dist/types/components/silke-overflow-menu/silke-overflow-menu.d.ts +6 -1
- package/dist/types/components/silke-popover-native/silke-popover-native.d.ts +3 -1
- package/dist/types/components/silke-shortcut-button/index.d.ts +1 -0
- package/dist/types/components/silke-shortcut-button/silke-shortcut-button.d.ts +15 -0
- package/dist/types/components/silke-tag/silke-tag.d.ts +1 -1
- package/dist/types/icons.d.ts +30 -0
- package/jest.config.js +2 -3
- package/package.json +7 -2
- package/src/_variables.scss +125 -129
- package/src/components/index.ts +3 -2
- package/src/components/silke-action-box/silke-action-box.scss +2 -3
- package/src/components/silke-alert-banner/silke-alert-banner.scss +9 -10
- package/src/components/silke-autocomplete-field/autocomplete-item.tsx +2 -2
- package/src/components/silke-autocomplete-field/silke-autocomplete-field.scss +18 -12
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup-native.tsx +3 -2
- package/src/components/silke-autocomplete-field/silke-autocomplete-popup.tsx +63 -44
- package/src/components/silke-box/silke-box.mdx +321 -21
- package/src/components/silke-box/silke-box.scss +5 -5
- package/src/components/silke-breadcrumbs/silke-breadcrumb.mdx +147 -9
- package/src/components/silke-breadcrumbs/silke-breadcrumb.scss +3 -3
- package/src/components/silke-button/silke-big-button.scss +1 -1
- package/src/components/silke-button/silke-button.scss +24 -15
- package/src/components/silke-button/silke-dropdown-button.mdx +67 -0
- package/src/components/silke-button/silke-dropdown-button.tsx +40 -122
- package/src/components/silke-card/silke-card-grid.tsx +5 -3
- package/src/components/silke-card/silke-card.scss +8 -7
- package/src/components/silke-card/silke-card.tsx +7 -1
- package/src/components/silke-checkbox/silke-checkbox.mdx +139 -14
- package/src/components/silke-checkbox/silke-checkbox.scss +11 -11
- package/src/components/silke-color-picker/color-picker.scss +8 -8
- package/src/components/silke-color-swatches/silke-color-swatches.mdx +130 -0
- package/src/components/silke-command-text-field/image-utils.ts +71 -0
- package/src/components/silke-command-text-field/index.ts +12 -0
- package/src/components/silke-command-text-field/silke-command-parser.spec.ts +89 -0
- package/src/components/silke-command-text-field/silke-command-parser.ts +47 -0
- package/src/components/silke-command-text-field/silke-command-text-field.mdx +301 -0
- package/src/components/silke-command-text-field/silke-command-text-field.module.scss +119 -0
- package/src/components/silke-command-text-field/silke-command-text-field.tsx +665 -0
- package/src/components/silke-command-text-field/utils.spec.ts +366 -0
- package/src/components/silke-command-text-field/utils.ts +287 -0
- package/src/components/silke-conditions-input/silke-conditions-input.scss +4 -4
- package/src/components/silke-content-column/silke-content-column.scss +1 -1
- package/src/components/silke-context-menu/silke-context-menu.scss +3 -4
- package/src/components/silke-context-menu/silke-context-menu.tsx +1 -1
- package/src/components/silke-css-number-field/silke-css-number-field.scss +14 -12
- package/src/components/silke-divider/silke-divider.mdx +154 -32
- package/src/components/silke-divider/silke-divider.scss +3 -2
- package/src/components/silke-drawer/silke-drawer.scss +6 -2
- package/src/components/silke-form/silke-form.mdx +254 -27
- package/src/components/silke-form-schema/fields/array-field-inline.tsx +1 -0
- package/src/components/silke-form-schema/fields/array-field-modal.tsx +1 -0
- package/src/components/silke-form-schema/fields/styles.scss +34 -35
- package/src/components/silke-form-schema/silke-schema-fields.tsx +4 -3
- package/src/components/silke-gradient-picker/silke-gradient-picker.module.scss +2 -2
- package/src/components/silke-icon/silke-icon.mdx +212 -8
- package/src/components/silke-icon/silke-icon.scss +10 -2
- package/src/components/silke-icon/silke-icon.tsx +1 -0
- package/src/components/silke-icon/silke-stacked-icon.scss +42 -45
- package/src/components/silke-icon-browser/silke-icon-browser.mdx +143 -0
- package/src/components/silke-image/silke-image-color-backdrop.scss +6 -6
- package/src/components/silke-image/silke-image.mdx +189 -41
- package/src/components/silke-image/silke-image.scss +3 -3
- package/src/components/silke-image/silke-image.tsx +14 -1
- package/src/components/silke-link/silke-link.scss +3 -5
- package/src/components/silke-list/index.ts +1 -0
- package/src/components/silke-list/silke-list-item.mdx +83 -0
- package/src/components/silke-list/silke-list-item.scss +119 -0
- package/src/components/silke-list/silke-list-item.tsx +137 -12
- package/src/components/silke-list/silke-list.mdx +108 -13
- package/src/components/silke-list/silke-list.scss +8 -15
- package/src/components/silke-list/silke-list.tsx +63 -9
- package/src/components/silke-list/types.ts +22 -0
- package/src/components/silke-list/utils.ts +24 -0
- package/src/components/silke-loader/silke-loader.mdx +139 -5
- package/src/components/silke-loader/silke-loader.scss +1 -1
- package/src/components/silke-modal/silke-modal.scss +9 -9
- package/src/components/silke-navigation-link/silke-navigation-link.mdx +27 -2
- package/src/components/silke-navigation-link/silke-navigation-link.scss +34 -40
- package/src/components/silke-navigation-link/silke-navigation-link.tsx +7 -6
- package/src/components/silke-overflow-menu/silke-overflow-menu.mdx +228 -31
- package/src/components/silke-overflow-menu/silke-overflow-menu.scss +8 -8
- package/src/components/silke-overflow-menu/silke-overflow-menu.tsx +14 -8
- package/src/components/silke-popover/silke-popover.scss +5 -5
- package/src/components/silke-popover-native/silke-popover-native.scss +93 -78
- package/src/components/silke-popover-native/silke-popover-native.tsx +4 -0
- package/src/components/silke-popover-native/use-popover-positioning.ts +1 -3
- package/src/components/silke-progress-indicator/silke-progress-indicator.scss +1 -1
- package/src/components/silke-radio-button/silke-radio-button.scss +18 -11
- package/src/components/silke-search-field/silke-search-field.mdx +161 -7
- package/src/components/silke-shortcut-button/index.ts +1 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.mdx +89 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.scss +145 -0
- package/src/components/silke-shortcut-button/silke-shortcut-button.tsx +55 -0
- package/src/components/silke-skeleton/silke-skeleton.mdx +109 -0
- package/src/components/silke-skeleton/silke-skeleton.scss +1 -1
- package/src/components/silke-slider/silke-slider.module.scss +19 -19
- package/src/components/silke-sortable-list/silke-nested-sortable-list.scss +3 -3
- package/src/components/silke-sortable-list/silke-sortable-list.scss +4 -5
- package/src/components/silke-table/silke-table.scss +1 -1
- package/src/components/silke-tabs/silke-tabs.scss +3 -3
- package/src/components/silke-tag/silke-tag.mdx +179 -43
- package/src/components/silke-tag/silke-tag.scss +49 -12
- package/src/components/silke-tag/silke-tag.tsx +17 -7
- package/src/components/silke-text/silke-text.scss +6 -4
- package/src/components/silke-text/silke-title.scss +7 -14
- package/src/components/silke-text-field/silke-text-field.scss +9 -9
- package/src/components/silke-text-field/silke-text-field.tsx +1 -1
- package/src/components/silke-tile/silke-tile.scss +7 -3
- package/src/components/silke-toast-notification/silke-toast-notification.scss +4 -5
- package/src/components/silke-toggle/silke-toggle.mdx +163 -33
- package/src/components/silke-toggle/silke-toggle.scss +4 -4
- package/src/components/silke-toolbar/silke-toolbar.scss +1 -1
- package/src/components/silke-tooltip/silke-shortcuts.tsx +3 -3
- package/src/components/silke-tooltip/silke-tooltip.scss +11 -16
- package/src/components/silke-variables-wrapper/silke-variables-wrapper.scss +9 -7
- package/src/components/silke-virtual/silke-virtual.mdx +161 -0
- package/src/components/silke-virtual/silke-virtual.scss +8 -8
- package/src/icons.tsx +43 -1
- package/src/styles/core.scss +42 -45
- package/src/styles/math.scss +66 -66
- package/tsconfig.build.json +2 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.json +3 -14
- package/dist/types/components/silke-action-list/index.d.ts +0 -1
- package/dist/types/components/silke-action-list/silke-action-list.d.ts +0 -11
- package/dist/types/components/silke-list-card/index.d.ts +0 -1
- package/dist/types/components/silke-list-card/silke-list-card.d.ts +0 -14
- package/src/components/silke-action-list/index.ts +0 -1
- package/src/components/silke-action-list/silke-action-list.mdx +0 -48
- package/src/components/silke-action-list/silke-action-list.scss +0 -21
- package/src/components/silke-action-list/silke-action-list.tsx +0 -85
- package/src/components/silke-list-card/index.ts +0 -1
- package/src/components/silke-list-card/silke-list-card.mdx +0 -46
- package/src/components/silke-list-card/silke-list-card.scss +0 -57
- package/src/components/silke-list-card/silke-list-card.tsx +0 -63
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@use
|
|
1
|
+
@use '../../variables' as *;
|
|
2
2
|
|
|
3
3
|
body {
|
|
4
4
|
--nav-item-color: var(--color-neutral-80);
|
|
@@ -8,7 +8,7 @@ body {
|
|
|
8
8
|
}
|
|
9
9
|
.main {
|
|
10
10
|
position: relative;
|
|
11
|
-
margin: 0
|
|
11
|
+
margin: 0;
|
|
12
12
|
padding: 0;
|
|
13
13
|
|
|
14
14
|
&:last-child {
|
|
@@ -21,52 +21,53 @@ body {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
&.hasRightButtons{
|
|
25
|
-
.link{
|
|
24
|
+
&.hasRightButtons {
|
|
25
|
+
.link {
|
|
26
26
|
padding-right: 4px;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
&:hover
|
|
30
|
+
&:hover,
|
|
31
|
+
&.expanded {
|
|
31
32
|
.rightButtons {
|
|
32
|
-
animation: fade-in 2s cubic-bezier(0.22, 0.61, 0.36, 1);
|
|
33
33
|
display: block;
|
|
34
|
+
opacity: 1;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
&::before {
|
|
38
39
|
position: absolute;
|
|
39
|
-
content:
|
|
40
|
+
content: '';
|
|
40
41
|
display: block;
|
|
41
42
|
height: 16px;
|
|
42
43
|
width: 4px;
|
|
43
44
|
border-radius: var(--border-radius-tiny);
|
|
44
45
|
|
|
45
|
-
margin:
|
|
46
|
+
margin: 8px 0 8px 0;
|
|
46
47
|
pointer-events: none;
|
|
47
|
-
transform: translateX(-
|
|
48
|
+
transform: translateX(-20px);
|
|
48
49
|
opacity: 1;
|
|
49
50
|
transition: all 0.2s ease-out;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
&.active {
|
|
53
|
-
|
|
54
|
+
& > .linkContainer {
|
|
54
55
|
background: var(--color-surface-1);
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
&::before {
|
|
58
59
|
background: var(--color-accent-30);
|
|
59
|
-
transform: translateX(
|
|
60
|
+
transform: translateX(-8px);
|
|
60
61
|
opacity: 1;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
.linkContainer,
|
|
64
|
+
.linkContainer,
|
|
65
|
+
.link {
|
|
64
66
|
color: var(--color-neutral-100);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
.linkContainer {
|
|
69
|
-
min-height: $size-m;
|
|
70
71
|
border-radius: var(--border-radius-small);
|
|
71
72
|
color: var(--nav-item-color);
|
|
72
73
|
text-align: left;
|
|
@@ -79,24 +80,24 @@ body {
|
|
|
79
80
|
&:focus-visible {
|
|
80
81
|
outline: 1px solid var(--color-neutral-100);
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
83
|
}
|
|
85
|
-
.link{
|
|
84
|
+
.link {
|
|
86
85
|
border-radius: var(--border-radius-small);
|
|
86
|
+
min-height: $size-base;
|
|
87
87
|
color: var(--nav-item-color);
|
|
88
88
|
text-align: left;
|
|
89
89
|
background-color: transparent;
|
|
90
|
+
padding: 0 $space-xs;
|
|
90
91
|
|
|
91
92
|
&:hover {
|
|
92
93
|
background: var(--color-surface-1);
|
|
93
94
|
color: var(--nav-item-color-hover);
|
|
94
|
-
.overflowMenu{
|
|
95
|
+
.overflowMenu {
|
|
95
96
|
opacity: 1;
|
|
96
97
|
display: flex;
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
.dragIcon{
|
|
100
|
+
.dragIcon {
|
|
100
101
|
opacity: 1;
|
|
101
102
|
}
|
|
102
103
|
}
|
|
@@ -108,11 +109,10 @@ body {
|
|
|
108
109
|
right: 0;
|
|
109
110
|
top: auto;
|
|
110
111
|
//padding-right: 8px;
|
|
111
|
-
button,
|
|
112
|
+
button,
|
|
113
|
+
a {
|
|
112
114
|
pointer-events: all;
|
|
113
115
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
@each $name, $color in $colors {
|
|
@@ -120,23 +120,23 @@ body {
|
|
|
120
120
|
color: $color;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
.overflowMenu{
|
|
123
|
+
.overflowMenu {
|
|
124
124
|
opacity: 0;
|
|
125
125
|
display: none;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
.subLink{
|
|
129
|
-
.link{
|
|
128
|
+
.subLink {
|
|
129
|
+
.link {
|
|
130
130
|
color: var(--nav-item-color);
|
|
131
131
|
}
|
|
132
|
-
.main{
|
|
133
|
-
margin:0;
|
|
134
|
-
.subLink{
|
|
135
|
-
.linkIcon{
|
|
132
|
+
.main {
|
|
133
|
+
margin: 0;
|
|
134
|
+
.subLink {
|
|
135
|
+
.linkIcon {
|
|
136
136
|
margin-left: 30px;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
&.active{
|
|
139
|
+
&.active {
|
|
140
140
|
.link {
|
|
141
141
|
color: var(--color-neutral-100);
|
|
142
142
|
}
|
|
@@ -146,8 +146,6 @@ body {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
149
|
}
|
|
152
150
|
|
|
153
151
|
.label {
|
|
@@ -155,15 +153,11 @@ body {
|
|
|
155
153
|
}
|
|
156
154
|
|
|
157
155
|
.rightButtons {
|
|
158
|
-
display: none;
|
|
159
156
|
opacity: 0;
|
|
157
|
+
transition: all 0.3s ease-out;
|
|
160
158
|
}
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
position: absolute;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
160
|
+
.dragIcon {
|
|
161
|
+
opacity: 0;
|
|
162
|
+
position: absolute;
|
|
163
|
+
}
|
|
@@ -25,6 +25,7 @@ type SilkeNavigationLinkProps = {
|
|
|
25
25
|
* Buttons/icons shown only on hover
|
|
26
26
|
*/
|
|
27
27
|
rightButtons?: ReactNode;
|
|
28
|
+
expanded?: boolean;
|
|
28
29
|
} & (
|
|
29
30
|
| ({ link: string } & Omit<BoxLinkProps, 'to' | 'tag' | 'link'>)
|
|
30
31
|
| ({ link?: undefined } & Omit<BoxButtonProps, 'tag' | 'type'>)
|
|
@@ -43,8 +44,8 @@ export const SilkeNavigationLink = React.forwardRef(
|
|
|
43
44
|
link,
|
|
44
45
|
rightButtons,
|
|
45
46
|
color,
|
|
46
|
-
align,
|
|
47
47
|
draggable,
|
|
48
|
+
expanded,
|
|
48
49
|
items,
|
|
49
50
|
menu = [],
|
|
50
51
|
...rest
|
|
@@ -63,6 +64,7 @@ export const SilkeNavigationLink = React.forwardRef(
|
|
|
63
64
|
if (rightButtons) cl.push(styles.hasRightButtons);
|
|
64
65
|
if (color) linkClass.push(styles[color]);
|
|
65
66
|
if (linkClassName) linkClass.push(linkClassName);
|
|
67
|
+
if (expanded) cl.push(styles.expanded);
|
|
66
68
|
|
|
67
69
|
const toggleExpand = useMemo(
|
|
68
70
|
() => (e: React.MouseEvent) => {
|
|
@@ -90,7 +92,6 @@ export const SilkeNavigationLink = React.forwardRef(
|
|
|
90
92
|
<SilkeBox
|
|
91
93
|
ref={ref}
|
|
92
94
|
className={cl.join(' ')}
|
|
93
|
-
gap="xxs"
|
|
94
95
|
tag="div"
|
|
95
96
|
draggable={draggable}
|
|
96
97
|
onDrop={() => setExpand(true)}
|
|
@@ -125,11 +126,11 @@ export const SilkeNavigationLink = React.forwardRef(
|
|
|
125
126
|
)}
|
|
126
127
|
{icon ? (
|
|
127
128
|
<SilkeBox
|
|
128
|
-
size="
|
|
129
|
+
size="s"
|
|
129
130
|
align="center"
|
|
130
|
-
pad="
|
|
131
|
+
pad="xs"
|
|
131
132
|
className={styles.linkIcon}
|
|
132
|
-
style={{ fontSize: 14 }}
|
|
133
|
+
style={{ fontSize: 14, opacity: active ? 1 : 0.7 }}
|
|
133
134
|
>
|
|
134
135
|
{React.isValidElement(icon) || isString(icon) ? (
|
|
135
136
|
<SilkeIcon icon={icon || 'error'} />
|
|
@@ -156,7 +157,7 @@ export const SilkeNavigationLink = React.forwardRef(
|
|
|
156
157
|
)}
|
|
157
158
|
</SilkeBox>
|
|
158
159
|
{children || rightButtons ? (
|
|
159
|
-
<ButtonContext size="
|
|
160
|
+
<ButtonContext size="s" kind="ghost">
|
|
160
161
|
<SilkeBox className={styles.rightContent} vAlign="center" height="s">
|
|
161
162
|
{children}
|
|
162
163
|
{rightButtons && (
|
|
@@ -1,43 +1,240 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SilkeOverflowMenu
|
|
2
|
+
|
|
3
|
+
A dropdown menu component triggered by a button click or right-click. Perfect for action menus, context menus, and option lists.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Click or right-click trigger**: Configure how the menu opens
|
|
8
|
+
- **Item-based or custom content**: Use predefined items or render custom children
|
|
9
|
+
- **Item kinds**: Default, danger, and selected states
|
|
10
|
+
- **Dividers**: Separate groups of items
|
|
11
|
+
- **Controlled or uncontrolled**: Manage open state externally or let the component handle it
|
|
12
|
+
- **Positioning options**: Control where the menu appears relative to the trigger
|
|
13
|
+
|
|
14
|
+
## Basic Usage
|
|
2
15
|
|
|
3
16
|
```js
|
|
4
|
-
|
|
5
|
-
|
|
17
|
+
<SilkeOverflowMenu
|
|
18
|
+
items={[
|
|
19
|
+
{ label: 'Edit', icon: 'edit' },
|
|
20
|
+
{ label: 'Duplicate', icon: 'copy' },
|
|
21
|
+
{ label: 'Delete', icon: 'delete', kind: 'danger' },
|
|
22
|
+
]}
|
|
23
|
+
/>
|
|
24
|
+
```
|
|
6
25
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
26
|
+
## With Icons
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
<SilkeOverflowMenu
|
|
30
|
+
items={[
|
|
31
|
+
{ label: 'Cut', icon: 'cut', onClick: () => console.log('Cut') },
|
|
32
|
+
{ label: 'Copy', icon: 'copy', onClick: () => console.log('Copy') },
|
|
33
|
+
{ label: 'Paste', icon: 'paste', onClick: () => console.log('Paste') },
|
|
34
|
+
]}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Item Kinds
|
|
39
|
+
|
|
40
|
+
Use `kind` to style items differently:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
<SilkeOverflowMenu
|
|
44
|
+
items={[
|
|
45
|
+
{ label: 'View', icon: 'eye' },
|
|
46
|
+
{ label: 'Edit', icon: 'edit' },
|
|
47
|
+
{ label: 'Currently selected', icon: 'check', kind: 'selected' },
|
|
48
|
+
'divider',
|
|
49
|
+
{ label: 'Delete', icon: 'delete', kind: 'danger' },
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## With Dividers
|
|
55
|
+
|
|
56
|
+
Use `'divider'` string to separate groups:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
<SilkeOverflowMenu
|
|
60
|
+
items={[
|
|
61
|
+
{ label: 'New File', icon: 'file.add' },
|
|
62
|
+
{ label: 'New Folder', icon: 'folder.add' },
|
|
63
|
+
'divider',
|
|
64
|
+
{ label: 'Import', icon: 'upload' },
|
|
65
|
+
{ label: 'Export', icon: 'download' },
|
|
66
|
+
'divider',
|
|
67
|
+
{ label: 'Settings', icon: 'settings' },
|
|
68
|
+
]}
|
|
69
|
+
/>
|
|
10
70
|
```
|
|
11
71
|
|
|
12
|
-
##
|
|
72
|
+
## Custom Trigger Button
|
|
73
|
+
|
|
74
|
+
Customize the trigger button with label and icon:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
<SilkeBox gap="m">
|
|
78
|
+
<SilkeOverflowMenu
|
|
79
|
+
label="Actions"
|
|
80
|
+
items={[{ label: 'Action 1' }, { label: 'Action 2' }]}
|
|
81
|
+
/>
|
|
82
|
+
<SilkeOverflowMenu
|
|
83
|
+
icon="settings"
|
|
84
|
+
items={[{ label: 'Settings 1' }, { label: 'Settings 2' }]}
|
|
85
|
+
/>
|
|
86
|
+
<SilkeOverflowMenu
|
|
87
|
+
label="Options"
|
|
88
|
+
icon="chevron.down"
|
|
89
|
+
items={[{ label: 'Option 1' }, { label: 'Option 2' }]}
|
|
90
|
+
/>
|
|
91
|
+
</SilkeBox>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Right-Click Trigger
|
|
95
|
+
|
|
96
|
+
Open the menu on right-click (context menu):
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
<SilkeOverflowMenu
|
|
100
|
+
trigger="right-click"
|
|
101
|
+
label="Right-click me"
|
|
102
|
+
items={[
|
|
103
|
+
{ label: 'Cut' },
|
|
104
|
+
{ label: 'Copy' },
|
|
105
|
+
{ label: 'Paste' },
|
|
106
|
+
]}
|
|
107
|
+
/>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Custom Content
|
|
111
|
+
|
|
112
|
+
Render custom content instead of predefined items:
|
|
13
113
|
|
|
14
114
|
```js
|
|
15
115
|
const items = [
|
|
16
|
-
{ id: 1, label: '
|
|
17
|
-
{ id: 2, label: '
|
|
18
|
-
{ id: 3, label: '
|
|
116
|
+
{ id: 1, label: 'Option A' },
|
|
117
|
+
{ id: 2, label: 'Option B' },
|
|
118
|
+
{ id: 3, label: 'Option C' },
|
|
19
119
|
];
|
|
120
|
+
const [selected, setSelected] = React.useState([]);
|
|
121
|
+
|
|
122
|
+
<SilkeOverflowMenu label="Select options">
|
|
123
|
+
<SilkeBox column hPad="s" vPad="xs" bg="neutral-10" shadow="level2" gap="xs" rounded="small">
|
|
124
|
+
{items.map((item) => (
|
|
125
|
+
<SilkeCheckbox
|
|
126
|
+
key={item.id}
|
|
127
|
+
label={item.label}
|
|
128
|
+
value={selected.includes(item.id)}
|
|
129
|
+
onChange={(checked) => {
|
|
130
|
+
setSelected(checked ? [...selected, item.id] : selected.filter((id) => id !== item.id));
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
))}
|
|
134
|
+
</SilkeBox>
|
|
135
|
+
</SilkeOverflowMenu>;
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Controlled Open State
|
|
139
|
+
|
|
140
|
+
Manage the open state externally:
|
|
141
|
+
|
|
142
|
+
```js
|
|
143
|
+
const [open, setOpen] = React.useState(false);
|
|
20
144
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
key={item.id}
|
|
29
|
-
label={item.label}
|
|
30
|
-
value={selectedItems.includes(item.id)}
|
|
31
|
-
onChange={(checked) => {
|
|
32
|
-
if (checked) {
|
|
33
|
-
setSelectedItems([...selectedItems, item.id]);
|
|
34
|
-
} else {
|
|
35
|
-
setSelectedItems(selectedItems.filter((id) => id !== item.id));
|
|
36
|
-
}
|
|
37
|
-
}}
|
|
38
|
-
/>
|
|
39
|
-
))}
|
|
40
|
-
</SilkeBox>
|
|
41
|
-
</SilkeOverflowMenu>
|
|
145
|
+
<SilkeBox gap="m" vAlign="center">
|
|
146
|
+
<SilkeOverflowMenu
|
|
147
|
+
open={open}
|
|
148
|
+
onToggleOpen={setOpen}
|
|
149
|
+
items={[{ label: 'Item 1' }, { label: 'Item 2' }]}
|
|
150
|
+
/>
|
|
151
|
+
<SilkeText size="s">Menu is {open ? 'open' : 'closed'}</SilkeText>
|
|
42
152
|
</SilkeBox>;
|
|
43
153
|
```
|
|
154
|
+
|
|
155
|
+
## Dynamic Items
|
|
156
|
+
|
|
157
|
+
Pass a function to generate items dynamically:
|
|
158
|
+
|
|
159
|
+
```js
|
|
160
|
+
const getItems = () => [
|
|
161
|
+
{ label: `Generated at ${new Date().toLocaleTimeString()}` },
|
|
162
|
+
{ label: 'Static item' },
|
|
163
|
+
];
|
|
164
|
+
|
|
165
|
+
<SilkeOverflowMenu items={getItems} />;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Positioning
|
|
169
|
+
|
|
170
|
+
Control menu placement with origin props:
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
<SilkeBox gap="m">
|
|
174
|
+
<SilkeOverflowMenu
|
|
175
|
+
label="Bottom Right"
|
|
176
|
+
anchorOrigin="bottom-right"
|
|
177
|
+
targetOrigin="top-right"
|
|
178
|
+
items={[{ label: 'Item 1' }, { label: 'Item 2' }]}
|
|
179
|
+
/>
|
|
180
|
+
<SilkeOverflowMenu
|
|
181
|
+
label="Bottom Left"
|
|
182
|
+
anchorOrigin="bottom-left"
|
|
183
|
+
targetOrigin="top-left"
|
|
184
|
+
items={[{ label: 'Item 1' }, { label: 'Item 2' }]}
|
|
185
|
+
/>
|
|
186
|
+
</SilkeBox>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Disabled Items
|
|
190
|
+
|
|
191
|
+
```js
|
|
192
|
+
<SilkeOverflowMenu
|
|
193
|
+
items={[
|
|
194
|
+
{ label: 'Enabled action', icon: 'check' },
|
|
195
|
+
{ label: 'Disabled action', icon: 'close', disabled: true },
|
|
196
|
+
{ label: 'Another enabled', icon: 'star' },
|
|
197
|
+
]}
|
|
198
|
+
/>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Props
|
|
202
|
+
|
|
203
|
+
| Prop | Type | Default | Description |
|
|
204
|
+
| -------------- | ------------------------------------------------- | ---------------- | ---------------------------------------- |
|
|
205
|
+
| `items` | `(SilkeOverflowMenuItem \| 'divider')[] \| () => ...` | `[]` | Menu items or function returning items |
|
|
206
|
+
| `children` | `React.ReactNode` | - | Custom content instead of items |
|
|
207
|
+
| `trigger` | `'click' \| 'right-click'` | `'click'` | What opens the menu |
|
|
208
|
+
| `open` | `boolean` | - | Controlled open state |
|
|
209
|
+
| `onToggleOpen` | `(open: boolean) => void` | - | Callback when open state changes |
|
|
210
|
+
| `label` | `string` | - | Button label |
|
|
211
|
+
| `icon` | `SilkeIcons` | `'menuMore'` | Button icon |
|
|
212
|
+
| `anchorOrigin` | `PopoverOrigin` | `'bottom-right'` | Where menu attaches to button |
|
|
213
|
+
| `targetOrigin` | `PopoverOrigin` | `'top-right'` | Which corner of menu aligns to anchor |
|
|
214
|
+
| `offsetX` | `number` | - | Horizontal offset in pixels |
|
|
215
|
+
| `offsetY` | `number` | - | Vertical offset in pixels |
|
|
216
|
+
|
|
217
|
+
Also accepts all `SilkeButton` props for the trigger button.
|
|
218
|
+
|
|
219
|
+
## SilkeOverflowMenuItem
|
|
220
|
+
|
|
221
|
+
| Prop | Type | Default | Description |
|
|
222
|
+
| ------------ | ------------------------------- | ----------- | ------------------------------ |
|
|
223
|
+
| `label` | `React.ReactNode` | Required | Item text |
|
|
224
|
+
| `kind` | `'default' \| 'danger' \| 'selected'` | `'default'` | Item style variant |
|
|
225
|
+
| `icon` | `SilkeIcons` | - | Item icon |
|
|
226
|
+
| `disabled` | `boolean` | `false` | Disable the item |
|
|
227
|
+
| `onClick` | `(e: React.MouseEvent) => void` | - | Click handler |
|
|
228
|
+
| `groupLabel` | `string` | - | Label for grouping (internal) |
|
|
229
|
+
|
|
230
|
+
Also accepts most `SilkeButton` props.
|
|
231
|
+
|
|
232
|
+
## Types
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
type SilkeOverflowMenuItem = {
|
|
236
|
+
label: React.ReactNode;
|
|
237
|
+
kind?: 'default' | 'danger' | 'selected';
|
|
238
|
+
groupLabel?: string;
|
|
239
|
+
} & Omit<SilkeButtonProps, 'height' | 'width' | 'align' | 'vAlign' | 'hAlign' | 'kind'>;
|
|
240
|
+
```
|
|
@@ -6,18 +6,18 @@ $overlay-open-background: var(--color-neutral-20);
|
|
|
6
6
|
background-color: $overlay-open-background !important;
|
|
7
7
|
border: none !important;
|
|
8
8
|
|
|
9
|
-
&::before{
|
|
10
|
-
display:none !important;
|
|
9
|
+
&::before {
|
|
10
|
+
display: none !important;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.menu {
|
|
15
|
-
overflow:hidden;
|
|
15
|
+
overflow: hidden;
|
|
16
16
|
min-width: 70px;
|
|
17
|
-
background
|
|
17
|
+
background: $overlay-open-background;
|
|
18
18
|
border-radius: var(--border-radius-small);
|
|
19
|
-
filter:var(--shadow-level-4);
|
|
20
|
-
hr{
|
|
19
|
+
filter: var(--shadow-level-4);
|
|
20
|
+
hr {
|
|
21
21
|
margin: $space-s 0;
|
|
22
22
|
background: var(--color-neutral-60);
|
|
23
23
|
}
|
|
@@ -29,8 +29,8 @@ $overlay-open-background: var(--color-neutral-20);
|
|
|
29
29
|
box-shadow: 0 0 0 4px var(--color-neutral-100);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
button,
|
|
33
|
+
a {
|
|
34
34
|
justify-content: start !important;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -152,14 +152,20 @@ export function SilkeOverflowMenu({
|
|
|
152
152
|
export type SilkeOverflowMenuItem = {
|
|
153
153
|
label: React.ReactNode;
|
|
154
154
|
kind?: 'default' | 'danger' | 'selected';
|
|
155
|
+
groupLabel?: string;
|
|
155
156
|
} & Omit<SilkeButtonProps, 'height' | 'width' | 'align' | 'vAlign' | 'hAlign' | 'kind'>;
|
|
156
157
|
|
|
157
|
-
export const SilkeOverflowMenuItem =
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
158
|
+
export const SilkeOverflowMenuItem = React.forwardRef<HTMLButtonElement, SilkeOverflowMenuItem>(
|
|
159
|
+
({ label, kind, groupLabel: _groupLabel, ...rest }, ref) => (
|
|
160
|
+
<SilkeButton
|
|
161
|
+
ref={ref as any}
|
|
162
|
+
label={label}
|
|
163
|
+
style={kind === 'selected' ? { backgroundColor: '#323232' } : undefined}
|
|
164
|
+
kind={kind === 'danger' ? 'danger' : 'ghost'}
|
|
165
|
+
rounded={rest.size === 's' ? 'tiny' : 'small'}
|
|
166
|
+
{...rest}
|
|
167
|
+
/>
|
|
168
|
+
),
|
|
165
169
|
);
|
|
170
|
+
|
|
171
|
+
SilkeOverflowMenuItem.displayName = 'SilkeOverflowMenuItem';
|