Skip to content

Commit 8670651

Browse files
authored
Merge pull request #1468 from DNNCommunity/release/0.29.0
Released v0.29.0
2 parents 2dcc7fb + 39b526c commit 8670651

13 files changed

Lines changed: 596 additions & 5 deletions

File tree

packages/react-library/lib/components/stencil-generated/components.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { DnnChevron as DnnChevronElement, defineCustomElement as defineDnnChevro
1515
import { DnnCollapsible as DnnCollapsibleElement, defineCustomElement as defineDnnCollapsible } from "@dnncommunity/dnn-elements/dist/components/dnn-collapsible.js";
1616
import { DnnColorInput as DnnColorInputElement, defineCustomElement as defineDnnColorInput } from "@dnncommunity/dnn-elements/dist/components/dnn-color-input.js";
1717
import { DnnColorPicker as DnnColorPickerElement, defineCustomElement as defineDnnColorPicker } from "@dnncommunity/dnn-elements/dist/components/dnn-color-picker.js";
18+
import { DnnContextMenu as DnnContextMenuElement, defineCustomElement as defineDnnContextMenu } from "@dnncommunity/dnn-elements/dist/components/dnn-context-menu.js";
1819
import { DnnDropzone as DnnDropzoneElement, defineCustomElement as defineDnnDropzone } from "@dnncommunity/dnn-elements/dist/components/dnn-dropzone.js";
1920
import { DnnExampleForm as DnnExampleFormElement, defineCustomElement as defineDnnExampleForm } from "@dnncommunity/dnn-elements/dist/components/dnn-example-form.js";
2021
import { DnnFieldset as DnnFieldsetElement, defineCustomElement as defineDnnFieldset } from "@dnncommunity/dnn-elements/dist/components/dnn-fieldset.js";
@@ -140,6 +141,17 @@ export const DnnColorPicker: StencilReactComponent<DnnColorPickerElement, DnnCol
140141
defineCustomElement: defineDnnColorPicker
141142
});
142143

144+
export type DnnContextMenuEvents = NonNullable<unknown>;
145+
146+
export const DnnContextMenu: StencilReactComponent<DnnContextMenuElement, DnnContextMenuEvents> = /*@__PURE__*/ createComponent<DnnContextMenuElement, DnnContextMenuEvents>({
147+
tagName: 'dnn-context-menu',
148+
elementClass: DnnContextMenuElement,
149+
// @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.
150+
react: React,
151+
events: {} as DnnContextMenuEvents,
152+
defineCustomElement: defineDnnContextMenu
153+
});
154+
143155
export type DnnDropzoneEvents = { onFilesSelected: EventName<DnnDropzoneCustomEvent<File[]>> };
144156

145157
export const DnnDropzone: StencilReactComponent<DnnDropzoneElement, DnnDropzoneEvents> = /*@__PURE__*/ createComponent<DnnDropzoneElement, DnnDropzoneEvents>({

packages/react-library/test-app/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/stencil-library/custom-elements.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,60 @@
772772
}
773773
]
774774
},
775+
{
776+
"kind": "javascript-module",
777+
"path": "src/components/dnn-context-menu/dnn-context-menu.tsx",
778+
"declarations": [
779+
{
780+
"kind": "class",
781+
"name": "dnn-context-menu.tsx",
782+
"tagName": "dnn-context-menu",
783+
"description": "",
784+
"attributes": [
785+
{
786+
"name": "close-on-click",
787+
"type": {
788+
"text": "boolean"
789+
},
790+
"description": "If true, the menu will close when an item is clicked.",
791+
"default": "false",
792+
"required": false
793+
}
794+
],
795+
"members": [
796+
{
797+
"kind": "method",
798+
"name": "close",
799+
"description": "Closes the menu.",
800+
"signature": "close() => Promise<void>"
801+
},
802+
{
803+
"kind": "method",
804+
"name": "open",
805+
"description": "Opens the menu using a pointer event.",
806+
"signature": "open(event: PointerEvent) => Promise<void>"
807+
}
808+
],
809+
"events": [],
810+
"slots": [],
811+
"cssProperties": [
812+
{
813+
"name": "--color-background",
814+
"description": "The background color of the context menu."
815+
},
816+
{
817+
"name": "--color-border",
818+
"description": "The border color of the context menu."
819+
},
820+
{
821+
"name": "--padding",
822+
"description": "The padding inside the context menu."
823+
}
824+
],
825+
"cssParts": []
826+
}
827+
]
828+
},
775829
{
776830
"kind": "javascript-module",
777831
"path": "src/components/dnn-dropzone/dnn-dropzone.tsx",

packages/stencil-library/licenses.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"@dnncommunity/dnn-elements@0.28.0-beta.2": {
33
"licenses": "MIT",
4-
"repository": "https://github.com/dnncommunity/dnn-elements",
4+
"repository": "https://github.com/DNNCommunity/dnn-elements",
55
"path": "",
66
"licenseFile": "D:\\dnn-elements\\packages\\stencil-library\\README.md"
77
},

packages/stencil-library/src/components.d.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,21 @@ export namespace Components {
300300
*/
301301
"colorBoxHeight": string;
302302
}
303+
interface DnnContextMenu {
304+
/**
305+
* Closes the menu.
306+
*/
307+
"close": () => Promise<void>;
308+
/**
309+
* If true, the menu will close when an item is clicked.
310+
* @default false
311+
*/
312+
"closeOnClick": boolean;
313+
/**
314+
* Opens the menu using a pointer event.
315+
*/
316+
"open": (event: PointerEvent) => Promise<void>;
317+
}
303318
interface DnnDropzone {
304319
/**
305320
* If true, will allow the user to take a snapshot using the device camera. (only works over https).
@@ -1066,6 +1081,12 @@ declare global {
10661081
prototype: HTMLDnnColorPickerElement;
10671082
new (): HTMLDnnColorPickerElement;
10681083
};
1084+
interface HTMLDnnContextMenuElement extends Components.DnnContextMenu, HTMLStencilElement {
1085+
}
1086+
var HTMLDnnContextMenuElement: {
1087+
prototype: HTMLDnnContextMenuElement;
1088+
new (): HTMLDnnContextMenuElement;
1089+
};
10691090
interface HTMLDnnDropzoneElementEventMap {
10701091
"filesSelected": File[];
10711092
}
@@ -1377,6 +1398,7 @@ declare global {
13771398
"dnn-collapsible": HTMLDnnCollapsibleElement;
13781399
"dnn-color-input": HTMLDnnColorInputElement;
13791400
"dnn-color-picker": HTMLDnnColorPickerElement;
1401+
"dnn-context-menu": HTMLDnnContextMenuElement;
13801402
"dnn-dropzone": HTMLDnnDropzoneElement;
13811403
"dnn-example-form": HTMLDnnExampleFormElement;
13821404
"dnn-fieldset": HTMLDnnFieldsetElement;
@@ -1733,6 +1755,13 @@ declare namespace LocalJSX {
17331755
*/
17341756
"onColorChanged"?: (event: DnnColorPickerCustomEvent<ColorInfo>) => void;
17351757
}
1758+
interface DnnContextMenu {
1759+
/**
1760+
* If true, the menu will close when an item is clicked.
1761+
* @default false
1762+
*/
1763+
"closeOnClick"?: boolean;
1764+
}
17361765
interface DnnDropzone {
17371766
/**
17381767
* If true, will allow the user to take a snapshot using the device camera. (only works over https).
@@ -2392,6 +2421,9 @@ declare namespace LocalJSX {
23922421
"color": string;
23932422
"colorBoxHeight": string;
23942423
}
2424+
interface DnnContextMenuAttributes {
2425+
"closeOnClick": boolean;
2426+
}
23952427
interface DnnDropzoneAttributes {
23962428
"allowCameraMode": boolean;
23972429
"captureQuality": number;
@@ -2515,6 +2547,7 @@ declare namespace LocalJSX {
25152547
"dnn-collapsible": Omit<DnnCollapsible, keyof DnnCollapsibleAttributes> & { [K in keyof DnnCollapsible & keyof DnnCollapsibleAttributes]?: DnnCollapsible[K] } & { [K in keyof DnnCollapsible & keyof DnnCollapsibleAttributes as `attr:${K}`]?: DnnCollapsibleAttributes[K] } & { [K in keyof DnnCollapsible & keyof DnnCollapsibleAttributes as `prop:${K}`]?: DnnCollapsible[K] };
25162548
"dnn-color-input": Omit<DnnColorInput, keyof DnnColorInputAttributes> & { [K in keyof DnnColorInput & keyof DnnColorInputAttributes]?: DnnColorInput[K] } & { [K in keyof DnnColorInput & keyof DnnColorInputAttributes as `attr:${K}`]?: DnnColorInputAttributes[K] } & { [K in keyof DnnColorInput & keyof DnnColorInputAttributes as `prop:${K}`]?: DnnColorInput[K] };
25172549
"dnn-color-picker": Omit<DnnColorPicker, keyof DnnColorPickerAttributes> & { [K in keyof DnnColorPicker & keyof DnnColorPickerAttributes]?: DnnColorPicker[K] } & { [K in keyof DnnColorPicker & keyof DnnColorPickerAttributes as `attr:${K}`]?: DnnColorPickerAttributes[K] } & { [K in keyof DnnColorPicker & keyof DnnColorPickerAttributes as `prop:${K}`]?: DnnColorPicker[K] };
2550+
"dnn-context-menu": Omit<DnnContextMenu, keyof DnnContextMenuAttributes> & { [K in keyof DnnContextMenu & keyof DnnContextMenuAttributes]?: DnnContextMenu[K] } & { [K in keyof DnnContextMenu & keyof DnnContextMenuAttributes as `attr:${K}`]?: DnnContextMenuAttributes[K] } & { [K in keyof DnnContextMenu & keyof DnnContextMenuAttributes as `prop:${K}`]?: DnnContextMenu[K] };
25182551
"dnn-dropzone": Omit<DnnDropzone, keyof DnnDropzoneAttributes> & { [K in keyof DnnDropzone & keyof DnnDropzoneAttributes]?: DnnDropzone[K] } & { [K in keyof DnnDropzone & keyof DnnDropzoneAttributes as `attr:${K}`]?: DnnDropzoneAttributes[K] } & { [K in keyof DnnDropzone & keyof DnnDropzoneAttributes as `prop:${K}`]?: DnnDropzone[K] };
25192552
"dnn-example-form": DnnExampleForm;
25202553
"dnn-fieldset": Omit<DnnFieldset, keyof DnnFieldsetAttributes> & { [K in keyof DnnFieldset & keyof DnnFieldsetAttributes]?: DnnFieldset[K] } & { [K in keyof DnnFieldset & keyof DnnFieldsetAttributes as `attr:${K}`]?: DnnFieldsetAttributes[K] } & { [K in keyof DnnFieldset & keyof DnnFieldsetAttributes as `prop:${K}`]?: DnnFieldset[K] };
@@ -2554,6 +2587,7 @@ declare module "@stencil/core" {
25542587
* Color Picker for Dnn
25552588
*/
25562589
"dnn-color-picker": LocalJSX.IntrinsicElements["dnn-color-picker"] & JSXBase.HTMLAttributes<HTMLDnnColorPickerElement>;
2590+
"dnn-context-menu": LocalJSX.IntrinsicElements["dnn-context-menu"] & JSXBase.HTMLAttributes<HTMLDnnContextMenuElement>;
25572591
"dnn-dropzone": LocalJSX.IntrinsicElements["dnn-dropzone"] & JSXBase.HTMLAttributes<HTMLDnnDropzoneElement>;
25582592
/**
25592593
* Do not use this component in production, it is meant for testing purposes only and is not distributed in the production package.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
:host {
2+
/** @prop --color-background: The background color of the context menu. */
3+
--color-background: var(--dnn-color-background, white);
4+
5+
/** @prop --color-border: The border color of the context menu. */
6+
--color-border: var(--dnn-color-foreground, black);
7+
8+
/** @prop --padding: The padding inside the context menu. */
9+
--padding: 0.25rem;
10+
11+
display: none;
12+
flex-direction: column;
13+
position: fixed;
14+
z-index: 1;
15+
background-color: var(--color-background);
16+
border: 1px solid var(--color-border);
17+
padding: var(--padding);
18+
}
19+
20+
::slotted(*) {
21+
display: flex;
22+
width: 100%;
23+
white-space: nowrap;
24+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import type { Meta, StoryObj } from '@storybook/web-components-vite';
2+
import { html } from 'lit';
3+
import readme from "./readme.md?raw";
4+
5+
const meta: Meta = {
6+
title: 'Elements/ContextMenu',
7+
component: 'dnn-context-menu',
8+
tags: ['autodocs'],
9+
parameters: {
10+
docs: {
11+
description: {
12+
component: readme,
13+
}
14+
}
15+
},
16+
argTypes: {
17+
closeOnClick: { control: 'boolean' },
18+
},
19+
};
20+
export default meta;
21+
22+
const Template = (args) => html`
23+
<div style="height:240px; display:flex; align-items:center; justify-content:center;">
24+
<button id="target" style="padding:12px 18px;">Right click or press Enter/Space</button>
25+
26+
<dnn-context-menu id="menu" .closeOnClick=${args.closeOnClick}>
27+
<div role="menuitem" style="padding:8px 12px; cursor:pointer;">Action 1</div>
28+
<div role="menuitem" style="padding:8px 12px; cursor:pointer;">Action 2</div>
29+
<div role="menuitem" style="padding:8px 12px; cursor:pointer;">Action 3</div>
30+
</dnn-context-menu>
31+
</div>
32+
33+
<script>
34+
// Attach handlers after the story renders
35+
setTimeout(() => {
36+
const target = document.getElementById('target');
37+
const menu = document.getElementById('menu');
38+
39+
if (!target || !menu) return;
40+
41+
target.addEventListener('contextmenu', e => {
42+
e.preventDefault();
43+
menu.open(e);
44+
});
45+
46+
}, 0);
47+
</script>
48+
`;
49+
50+
type Story = StoryObj;
51+
52+
export const Primary: Story = Template.bind({});
53+
Primary.args = {
54+
closeOnClick: true,
55+
};

0 commit comments

Comments
 (0)