@judo/expressions 0.30.1 → 0.32.0

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/dist/index.js CHANGED
@@ -1,27 +1,29 @@
1
- import { createEvalExpr } from "@judo/idem";
2
- import { addDays, differenceInDays, differenceInSeconds, parseISO, subDays } from "date-fns";
3
- import { createContext, useContext, useMemo } from "react";
4
- import { jsx } from "react/jsx-runtime";
5
- var ExpressionContext = createContext(null);
6
- function ExpressionProvider({ children: f }) {
7
- let p = useMemo(() => createEvalExpr({ dateFunctions: {
8
- addDays,
9
- subDays,
10
- parseISO,
11
- differenceInDays,
12
- differenceInSeconds
1
+ import { createEvalExpr as e } from "@judo/idem";
2
+ import { addDays as t, differenceInDays as n, differenceInSeconds as r, parseISO as i, subDays as a } from "date-fns";
3
+ import { createContext as o, useContext as s, useMemo as c } from "react";
4
+ import { jsx as l } from "react/jsx-runtime";
5
+ //#region src/expression-context.tsx
6
+ var u = o(null);
7
+ function d({ children: o }) {
8
+ let s = c(() => e({ dateFunctions: {
9
+ addDays: t,
10
+ subDays: a,
11
+ parseISO: i,
12
+ differenceInDays: n,
13
+ differenceInSeconds: r
13
14
  } }), []);
14
- return /* @__PURE__ */ jsx(ExpressionContext.Provider, {
15
- value: p,
16
- children: f
15
+ return /* @__PURE__ */ l(u.Provider, {
16
+ value: s,
17
+ children: o
17
18
  });
18
19
  }
19
- function useExpression() {
20
- let e = useContext(ExpressionContext);
20
+ function f() {
21
+ let e = s(u);
21
22
  if (!e) throw Error("useExpression must be used within ExpressionProvider");
22
23
  return e;
23
24
  }
24
- function useExpressionOptional() {
25
- return useContext(ExpressionContext);
25
+ function p() {
26
+ return s(u);
26
27
  }
27
- export { ExpressionProvider, useExpression, useExpressionOptional };
28
+ //#endregion
29
+ export { d as ExpressionProvider, f as useExpression, p as useExpressionOptional };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/expression-context.tsx"],"sourcesContent":["import { createEvalExpr, type EvalExpr } from \"@judo/idem\";\nimport { addDays, differenceInDays, differenceInSeconds, parseISO, subDays } from \"date-fns\";\nimport { type ReactNode, createContext, useContext, useMemo } from \"react\";\n\n// ============================================\n// CONTEXT\n// ============================================\n\nconst ExpressionContext = createContext<EvalExpr | null>(null);\n\n// ============================================\n// PROVIDER\n// ============================================\n\nexport interface ExpressionProviderProps {\n\tchildren: ReactNode;\n}\n\n/**\n * Provider that creates and shares a configured IDEM expression evaluator.\n *\n * Wraps `@judo/idem`'s `createEvalExpr` with date-fns implementations for\n * date manipulation functions. The evaluator is created once and shared via\n * React context.\n *\n * Must be placed in the component tree before any `useExpression()` consumers.\n *\n * @example\n * ```tsx\n * <ExpressionProvider>\n * <App />\n * </ExpressionProvider>\n * ```\n */\nexport function ExpressionProvider({ children }: ExpressionProviderProps) {\n\tconst evalExpr = useMemo(\n\t\t() =>\n\t\t\tcreateEvalExpr({\n\t\t\t\tdateFunctions: {\n\t\t\t\t\taddDays,\n\t\t\t\t\tsubDays,\n\t\t\t\t\tparseISO,\n\t\t\t\t\tdifferenceInDays,\n\t\t\t\t\tdifferenceInSeconds,\n\t\t\t\t},\n\t\t\t}),\n\t\t[]\n\t);\n\n\treturn <ExpressionContext.Provider value={evalExpr}>{children}</ExpressionContext.Provider>;\n}\n\n// ============================================\n// HOOKS\n// ============================================\n\n/**\n * Hook to access the IDEM expression evaluator.\n *\n * @throws Error if used outside ExpressionProvider\n *\n * @example\n * ```tsx\n * const evalExpr = useExpression();\n * const greeting = evalExpr<string>(\"'Hello: ' + self.name\", { self: data });\n * ```\n */\nexport function useExpression(): EvalExpr {\n\tconst evalExpr = useContext(ExpressionContext);\n\tif (!evalExpr) {\n\t\tthrow new Error(\"useExpression must be used within ExpressionProvider\");\n\t}\n\treturn evalExpr;\n}\n\n/**\n * Optional variant of useExpression.\n * Returns null if no ExpressionProvider is in the tree.\n */\nexport function useExpressionOptional(): EvalExpr | null {\n\treturn useContext(ExpressionContext);\n}\n"],"mappings":";;;;AAQA,IAAM,oBAAoB,cAA+B,KAAK;AA0B9D,SAAgB,mBAAmB,EAAE,eAAqC;CACzE,IAAM,IAAW,cAEf,eAAe,EACd,eAAe;EACd;EACA;EACA;EACA;EACA;EACA,EACD,CAAC,EACH,EAAE,CACF;AAED,QAAO,oBAAC,kBAAkB,UAAA;EAAS,OAAO;EAAW;GAAsC;;AAkB5F,SAAgB,gBAA0B;CACzC,IAAM,IAAW,WAAW,kBAAkB;AAC9C,KAAI,CAAC,EACJ,OAAU,MAAM,uDAAuD;AAExE,QAAO;;AAOR,SAAgB,wBAAyC;AACxD,QAAO,WAAW,kBAAkB"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/expression-context.tsx"],"sourcesContent":["import { createEvalExpr, type EvalExpr } from \"@judo/idem\";\nimport { addDays, differenceInDays, differenceInSeconds, parseISO, subDays } from \"date-fns\";\nimport { type ReactNode, createContext, useContext, useMemo } from \"react\";\n\n// ============================================\n// CONTEXT\n// ============================================\n\nconst ExpressionContext = createContext<EvalExpr | null>(null);\n\n// ============================================\n// PROVIDER\n// ============================================\n\nexport interface ExpressionProviderProps {\n\tchildren: ReactNode;\n}\n\n/**\n * Provider that creates and shares a configured IDEM expression evaluator.\n *\n * Wraps `@judo/idem`'s `createEvalExpr` with date-fns implementations for\n * date manipulation functions. The evaluator is created once and shared via\n * React context.\n *\n * Must be placed in the component tree before any `useExpression()` consumers.\n *\n * @example\n * ```tsx\n * <ExpressionProvider>\n * <App />\n * </ExpressionProvider>\n * ```\n */\nexport function ExpressionProvider({ children }: ExpressionProviderProps) {\n\tconst evalExpr = useMemo(\n\t\t() =>\n\t\t\tcreateEvalExpr({\n\t\t\t\tdateFunctions: {\n\t\t\t\t\taddDays,\n\t\t\t\t\tsubDays,\n\t\t\t\t\tparseISO,\n\t\t\t\t\tdifferenceInDays,\n\t\t\t\t\tdifferenceInSeconds,\n\t\t\t\t},\n\t\t\t}),\n\t\t[]\n\t);\n\n\treturn <ExpressionContext.Provider value={evalExpr}>{children}</ExpressionContext.Provider>;\n}\n\n// ============================================\n// HOOKS\n// ============================================\n\n/**\n * Hook to access the IDEM expression evaluator.\n *\n * @throws Error if used outside ExpressionProvider\n *\n * @example\n * ```tsx\n * const evalExpr = useExpression();\n * const greeting = evalExpr<string>(\"'Hello: ' + self.name\", { self: data });\n * ```\n */\nexport function useExpression(): EvalExpr {\n\tconst evalExpr = useContext(ExpressionContext);\n\tif (!evalExpr) {\n\t\tthrow new Error(\"useExpression must be used within ExpressionProvider\");\n\t}\n\treturn evalExpr;\n}\n\n/**\n * Optional variant of useExpression.\n * Returns null if no ExpressionProvider is in the tree.\n */\nexport function useExpressionOptional(): EvalExpr | null {\n\treturn useContext(ExpressionContext);\n}\n"],"mappings":";;;;;AAQA,IAAM,IAAoB,EAA+B,KAAK;AA0B9D,SAAgB,EAAmB,EAAE,eAAqC;CACzE,IAAM,IAAW,QAEf,EAAe,EACd,eAAe;EACd;EACA;EACA;EACA;EACA;EACA,EACD,CAAC,EACH,EAAE,CACF;AAED,QAAO,kBAAC,EAAkB,UAAnB;EAA4B,OAAO;EAAW;EAAsC,CAAA;;AAkB5F,SAAgB,IAA0B;CACzC,IAAM,IAAW,EAAW,EAAkB;AAC9C,KAAI,CAAC,EACJ,OAAU,MAAM,uDAAuD;AAExE,QAAO;;AAOR,SAAgB,IAAyC;AACxD,QAAO,EAAW,EAAkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@judo/expressions",
3
- "version": "0.30.1",
3
+ "version": "0.32.0",
4
4
  "description": "Expression language integration for JUDO UI Runtime, wrapping @judo/idem",
5
5
  "license": "EPL-2.0",
6
6
  "repository": {
@@ -32,14 +32,14 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@testing-library/react": "^16.3.2",
35
- "@types/node": "^25.3.3",
35
+ "@types/node": "^25.6.0",
36
36
  "@types/react": "^19.2.14",
37
37
  "antlr4ng": "^3.0.16",
38
38
  "date-fns": "^4.1.0",
39
- "react": "^19.2.4",
40
- "react-dom": "^19.2.4",
41
- "typescript": "^5.9.3",
42
- "vitest": "^4.0.18"
39
+ "react": "^19.2.5",
40
+ "react-dom": "^19.2.5",
41
+ "typescript": "^6.0.3",
42
+ "vitest": "^4.1.4"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "antlr4ng": "^3.0.16",