cx 26.1.4 → 26.1.5
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/build/ui/Widget.d.ts +1 -1
- package/build/ui/exprHelpers.d.ts +6 -2
- package/build/ui/exprHelpers.js +9 -3
- package/build/ui/tpl.d.ts +5 -3
- package/build/ui/tpl.js +11 -4
- package/build/widgets/overlay/Overlay.d.ts +3 -3
- package/dist/manifest.js +827 -824
- package/dist/ui.js +30 -22
- package/dist/util.js +4 -0
- package/dist/widgets.js +395 -320
- package/package.json +1 -1
- package/src/ui/exprHelpers.ts +96 -95
- package/src/ui/tpl.spec.ts +69 -0
- package/src/ui/tpl.ts +17 -4
package/build/ui/Widget.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { RenderingContext } from "./RenderingContext";
|
|
|
5
5
|
import type { Controller, ControllerConfig, ControllerFactory } from "./Controller";
|
|
6
6
|
import { BooleanProp, ClassProp, ModProp, StyleProp } from "./Prop";
|
|
7
7
|
import { Instance } from "./Instance";
|
|
8
|
-
export declare const VDOM:
|
|
8
|
+
export declare const VDOM: import("cx-react").CxVDOM;
|
|
9
9
|
export type ControllerProp = CreateConfig<typeof Controller> | (ControllerConfig & {
|
|
10
10
|
type?: never;
|
|
11
11
|
$type?: never;
|
|
@@ -31,10 +31,14 @@ export declare function strictEqual<V>(arg: AccessorChain<V>, value: V): Selecto
|
|
|
31
31
|
/** Returns a selector that checks if the value strictly does not equal the given value using !== */
|
|
32
32
|
export declare function strictNotEqual<V>(arg: AccessorChain<V>, value: V): Selector<boolean>;
|
|
33
33
|
/** Returns a selector that formats the value using the specified format string.
|
|
34
|
-
* Format strings use semicolon-separated syntax: "formatType;param1;param2
|
|
34
|
+
* Format strings use semicolon-separated syntax: "formatType;param1;param2"
|
|
35
|
+
* @param arg - The accessor chain to the value
|
|
36
|
+
* @param fmt - The format string
|
|
37
|
+
* @param nullText - Optional text to display for null/undefined values
|
|
35
38
|
* @example
|
|
36
39
|
* format(m.price, "n;2") // formats as number with 2 decimal places
|
|
37
40
|
* format(m.date, "d") // formats as date
|
|
38
41
|
* format(m.value, "p;0;2") // formats as percentage with 0-2 decimal places
|
|
42
|
+
* format(m.value, "n;2", "N/A") // shows "N/A" for null values
|
|
39
43
|
*/
|
|
40
|
-
export declare function format<V>(arg: AccessorChain<V>, fmt: string): Selector<string>;
|
|
44
|
+
export declare function format<V>(arg: AccessorChain<V>, fmt: string, nullText?: string): Selector<string>;
|
package/build/ui/exprHelpers.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { computable } from "../data/computable";
|
|
1
2
|
import { Format } from "../util/Format";
|
|
2
3
|
import { expr } from "./expr";
|
|
3
4
|
/** Returns a selector that converts the value to boolean using !! */
|
|
@@ -61,12 +62,17 @@ export function strictNotEqual(arg, value) {
|
|
|
61
62
|
return expr(arg, (x) => x !== value);
|
|
62
63
|
}
|
|
63
64
|
/** Returns a selector that formats the value using the specified format string.
|
|
64
|
-
* Format strings use semicolon-separated syntax: "formatType;param1;param2
|
|
65
|
+
* Format strings use semicolon-separated syntax: "formatType;param1;param2"
|
|
66
|
+
* @param arg - The accessor chain to the value
|
|
67
|
+
* @param fmt - The format string
|
|
68
|
+
* @param nullText - Optional text to display for null/undefined values
|
|
65
69
|
* @example
|
|
66
70
|
* format(m.price, "n;2") // formats as number with 2 decimal places
|
|
67
71
|
* format(m.date, "d") // formats as date
|
|
68
72
|
* format(m.value, "p;0;2") // formats as percentage with 0-2 decimal places
|
|
73
|
+
* format(m.value, "n;2", "N/A") // shows "N/A" for null values
|
|
69
74
|
*/
|
|
70
|
-
export function format(arg, fmt) {
|
|
71
|
-
|
|
75
|
+
export function format(arg, fmt, nullText) {
|
|
76
|
+
let f = nullText != null ? `${fmt}|${nullText}` : fmt;
|
|
77
|
+
return computable(arg, (x) => Format.value(x, f));
|
|
72
78
|
}
|
package/build/ui/tpl.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
};
|
|
1
|
+
import { ComputableSelector } from "../data/computable";
|
|
2
|
+
import { MemoSelector } from "../data/Selector";
|
|
3
|
+
import { Tpl } from "./Prop";
|
|
4
|
+
export declare function tpl(text: string): Tpl;
|
|
5
|
+
export declare function tpl<T extends ComputableSelector[]>(...args: [...T, string]): MemoSelector<string>;
|
package/build/ui/tpl.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { computable } from "../data/computable";
|
|
2
|
+
import { StringTemplate } from "../data/StringTemplate";
|
|
3
|
+
export function tpl(...args) {
|
|
4
|
+
if (args.length === 1)
|
|
5
|
+
return {
|
|
6
|
+
tpl: args[0],
|
|
7
|
+
};
|
|
8
|
+
let template = args[args.length - 1];
|
|
9
|
+
let formatter = StringTemplate.get(template);
|
|
10
|
+
let selectors = args.slice(0, -1);
|
|
11
|
+
return computable(...selectors, (...values) => formatter(values));
|
|
5
12
|
}
|
|
@@ -156,9 +156,9 @@ export declare class OverlayComponent<Props extends OverlayComponentProps = Over
|
|
|
156
156
|
customStyle: any;
|
|
157
157
|
root: Root;
|
|
158
158
|
constructor(props: Props);
|
|
159
|
-
render():
|
|
159
|
+
render(): import("react/jsx-runtime").JSX.Element | null;
|
|
160
160
|
renderOverlay(): import("react/jsx-runtime").JSX.Element;
|
|
161
|
-
renderOverlayBody():
|
|
161
|
+
renderOverlayBody(): Props["children"];
|
|
162
162
|
onFocus(): void;
|
|
163
163
|
onBlur(): void;
|
|
164
164
|
onFocusIn(): void;
|
|
@@ -181,7 +181,7 @@ export declare class OverlayComponent<Props extends OverlayComponentProps = Over
|
|
|
181
181
|
setCustomStyle(style: Partial<CSSStyleDeclaration>): void;
|
|
182
182
|
getOverlayStyle(): any;
|
|
183
183
|
setCSSState(mods: Record<string, boolean>): void;
|
|
184
|
-
getOverlayCssClass():
|
|
184
|
+
getOverlayCssClass(): string;
|
|
185
185
|
overlayDidUpdate(): void;
|
|
186
186
|
componentDidUpdate(): void;
|
|
187
187
|
}
|