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.
@@ -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: any;
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|nullText"
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>;
@@ -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|nullText"
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
- return expr(arg, (x) => Format.value(x, fmt));
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
- export declare function tpl(text: string): {
2
- tpl: string;
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
- export function tpl(text) {
2
- return {
3
- tpl: text
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(): any;
159
+ render(): import("react/jsx-runtime").JSX.Element | null;
160
160
  renderOverlay(): import("react/jsx-runtime").JSX.Element;
161
- renderOverlayBody(): any;
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(): any;
184
+ getOverlayCssClass(): string;
185
185
  overlayDidUpdate(): void;
186
186
  componentDidUpdate(): void;
187
187
  }