Skip to content

Commit c3dd8c6

Browse files
committed
Minor improvements
1 parent 69b8d6d commit c3dd8c6

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

packages/cx/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cx",
3-
"version": "26.0.5",
3+
"version": "26.0.6",
44
"description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
55
"exports": {
66
"./data/": "./build/data/",
@@ -19,7 +19,7 @@
1919
"./charts": "./build/charts/index.js",
2020
"./jsx-runtime": "./build/jsx-runtime.js",
2121
"./jsx-runtime.js": "./build/jsx-runtime.js",
22-
"./src/": "./build/",
22+
"./src/": "./src/",
2323
"./sass/": "./src/",
2424
"./build/": "./build/",
2525
"./locale/": "./build/locale/",

packages/cx/src/charts/LineGraph.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Instance } from "../ui/Instance";
77
import { RenderingContext } from "../ui/RenderingContext";
88
import { NumberProp, BooleanProp, StringProp, RecordsProp, StyleProp } from "../ui/Prop";
99
import type { ChartRenderingContext } from "./Chart";
10+
import { ClassProp } from "../core";
1011

1112
interface LinePoint {
1213
x: number;
@@ -88,6 +89,18 @@ export interface LineGraphConfig extends WidgetConfig {
8889

8990
/** Shape to use in legend. */
9091
legendShape?: string;
92+
93+
/**
94+
* Additional CSS classes to be applied to the field.
95+
* If an object is provided, all keys with a "truthy" value will be added to the CSS class list.
96+
*/
97+
class?: ClassProp;
98+
99+
/**
100+
* Additional CSS classes to be applied to the field.
101+
* If an object is provided, all keys with a "truthy" value will be added to the CSS class list.
102+
*/
103+
className?: ClassProp;
91104
}
92105

93106
export interface LineGraphInstance extends Instance {
@@ -437,5 +450,6 @@ LineGraph.prototype.hiddenBase = false;
437450

438451
LineGraph.prototype.smooth = false;
439452
LineGraph.prototype.smoothingRatio = 0.05;
453+
LineGraph.prototype.styled = true;
440454

441455
Widget.alias("line-graph", LineGraph);

packages/cx/src/jsx-runtime.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type { JSX as ReactJSX } from "react";
22
import { Instance } from "./ui/Instance";
3-
import type { Prop } from "./ui/Prop";
3+
import type { ClassProp, Prop } from "./ui/Prop";
44
import { Widget } from "./ui/Widget";
55
import { isArray } from "./util/isArray";
66
import { isString } from "./util/isString";
77
import { HtmlElement, HtmlElementConfig } from "./widgets/HtmlElement";
8+
import { ChildNode } from "./ui/Container";
89

910
export function jsx(typeName: any, props: any, key?: string): any {
1011
if (isArray(typeName)) return typeName;
@@ -45,10 +46,12 @@ type CxEventHandler<T> = T extends (event: infer E) => any
4546

4647
type CxIntrinsicElement<T> = {
4748
[K in keyof T]: K extends "children"
48-
? any
49-
: IsEventHandler<K, T[K]> extends true
50-
? CxEventHandler<T[K]>
51-
: Prop<T[K]>;
49+
? ChildNode | ChildNode[]
50+
: K extends "className" | "class"
51+
? ClassProp
52+
: IsEventHandler<K, T[K]> extends true
53+
? CxEventHandler<T[K]>
54+
: Prop<T[K]>;
5255
} & HtmlElementConfig;
5356

5457
type CxIntrinsicElements = {

packages/cx/src/util/addEventListenerWithOptions.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ interface EventMap {
1616
}
1717

1818
export function addEventListenerWithOptions<K extends keyof EventMap>(
19-
element: Element,
19+
element: Element | Document,
2020
event: K,
2121
callback: (event: EventMap[K]) => void,
22-
options: AddEventListenerOptions
22+
options: AddEventListenerOptions,
2323
): () => void;
2424
export function addEventListenerWithOptions(
25-
element: Element,
25+
element: Element | Document,
2626
event: string,
2727
callback: (event: Event) => void,
28-
options: AddEventListenerOptions
28+
options: AddEventListenerOptions,
2929
): () => void;
3030
export function addEventListenerWithOptions(
31-
element: Element,
31+
element: Element | Document,
3232
event: string,
3333
callback: (event: Event) => void,
34-
options: AddEventListenerOptions
34+
options: AddEventListenerOptions,
3535
): () => void {
3636
let thirdParam = browserSupportsPassiveEventHandlers() ? options : options.capture === true;
3737
element.addEventListener(event, callback as any, thirdParam);

packages/cx/src/widgets/nav/MenuItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface MenuItemConfig extends HtmlElementConfig {
6161
padding?: string;
6262
hideCursor?: boolean;
6363
dropdown?: any;
64+
onClick?: string | ((e: React.MouseEvent | null, instance: HtmlElementInstance<MenuItem>) => void);
6465
}
6566

6667
export class MenuItemInstance extends HtmlElementInstance<MenuItem> {

0 commit comments

Comments
 (0)