xmlui 0.9.5 → 0.9.7

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.
@@ -12,7 +12,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _executor, _DeferredPromise_instances, decorate_fn, _a2;
13
13
  import { delay as delay$1, HttpResponse, http } from "msw";
14
14
  import { isArray, isObject as isObject$1, mapValues } from "lodash-es";
15
- import { r as runEventHandlerCode, g as getDate, d as delay, m as miscellaneousUtils, a as dateFunctions, o as orderBy, T as ThrowStatementError } from "./index-tLddBc_K.mjs";
15
+ import { r as runEventHandlerCode, g as getDate, d as delay, m as miscellaneousUtils, a as dateFunctions, o as orderBy, T as ThrowStatementError } from "./index-ohXvHX94.mjs";
16
16
  import Dexie from "dexie";
17
17
  var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
18
18
  function serializePositional(positional, flag) {
@@ -7,7 +7,7 @@ import { useQuery, useInfiniteQuery, QueryClientProvider, QueryClient } from "@t
7
7
  import produce, { createDraft, finishDraft, enableMapSet } from "immer";
8
8
  import { throttle, get, isNil, omitBy, isUndefined, noop as noop$2, isPlainObject, isEqual, union, uniq, orderBy as orderBy$1, isEmpty, isObject, isArray, groupBy, sortBy, omit, isNumber, isString, cloneDeep, merge, defaultTo, capitalize, unset, setWith, keyBy, pick } from "lodash-es";
9
9
  import { formatDistanceToNow, parse, format, parseISO, isValid, isTomorrow, isYesterday, isToday, isThisWeek, formatRelative, isThisYear, isSameDay, differenceInMinutes } from "date-fns";
10
- import { v as validationStatusMd, l as labelPositionMd, o as orientationOptionMd, a as alignmentOptionValues, L as LinkTargetMd, b as alignmentOptionMd, i as iconPositionMd, c as buttonTypesMd, s as sizeMd, d as buttonThemeMd, e as buttonVariantMd, P as Parser, T as T_CALCULATED_MEMBER_ACCESS_EXPRESSION, f as T_MEMBER_ACCESS_EXPRESSION, g as T_IDENTIFIER, h as T_PREFIX_OP_EXPRESSION, j as T_FUNCTION_DECLARATION, k as T_ARROW_EXPRESSION, m as createXmlUiTreeNodeId, n as T_EMPTY_STATEMENT, p as T_SWITCH_STATEMENT, q as T_TRY_STATEMENT, r as T_THROW_STATEMENT, t as T_FOR_OF_STATEMENT, u as T_FOR_IN_STATEMENT, w as T_FOR_STATEMENT, x as T_EXPRESSION_STATEMENT, y as T_BREAK_STATEMENT, z as T_CONTINUE_STATEMENT, A as T_DO_WHILE_STATEMENT, B as T_WHILE_STATEMENT, C as T_RETURN_STATEMENT, D as T_IF_STATEMENT, E as T_CONST_STATEMENT, F as T_LET_STATEMENT, G as T_ARROW_EXPRESSION_STATEMENT, H as T_BLOCK_STATEMENT, I as T_VAR_STATEMENT, J as T_ASSIGNMENT_EXPRESSION, K as T_LITERAL, M as T_SPREAD_EXPRESSION, N as T_FUNCTION_INVOCATION_EXPRESSION, O as T_POSTFIX_OP_EXPRESSION, Q as T_CONDITIONAL_EXPRESSION, R as T_BINARY_EXPRESSION, S as T_UNARY_EXPRESSION, U as T_OBJECT_LITERAL, V as T_ARRAY_LITERAL, W as T_SEQUENCE_EXPRESSION, X as T_TEMPLATE_LITERAL_EXPRESSION, Y as T_VAR_DECLARATION, Z as T_DESTRUCTURE, _ as TextVariantElement, $ as VariantPropsKeys, a0 as variantOptionsMd, a1 as scrollAnchoringValues, a2 as buttonThemeNames, a3 as iconPositionNames, a4 as buttonVariantNames, a5 as nodeToComponentDef, a6 as triggerPositionNames, a7 as statusColorMd, a8 as placementMd, a9 as httpMethodNames, aa as PARSED_MARK_PROP, ab as layoutOptionKeys, ac as viewportSizeNames, ad as componentFileExtension, ae as codeBehindFileExtension, af as getLintSeverity, ag as LintSeverity, ah as lintApp, ai as printComponentLints, aj as lintErrorsComponent, ak as collectCodeBehindFromSource, al as removeCodeBehindTokensFromTree } from "./lint-gX2osbkz.mjs";
10
+ import { v as validationStatusMd, l as labelPositionMd, o as orientationOptionMd, a as alignmentOptionValues, L as LinkTargetMd, b as alignmentOptionMd, i as iconPositionMd, c as buttonTypesMd, s as sizeMd, d as buttonThemeMd, e as buttonVariantMd, P as Parser, T as T_CALCULATED_MEMBER_ACCESS_EXPRESSION, f as T_MEMBER_ACCESS_EXPRESSION, g as T_IDENTIFIER, h as T_PREFIX_OP_EXPRESSION, j as T_FUNCTION_DECLARATION, k as T_ARROW_EXPRESSION, m as createXmlUiTreeNodeId, n as T_EMPTY_STATEMENT, p as T_SWITCH_STATEMENT, q as T_TRY_STATEMENT, r as T_THROW_STATEMENT, t as T_FOR_OF_STATEMENT, u as T_FOR_IN_STATEMENT, w as T_FOR_STATEMENT, x as T_EXPRESSION_STATEMENT, y as T_BREAK_STATEMENT, z as T_CONTINUE_STATEMENT, A as T_DO_WHILE_STATEMENT, B as T_WHILE_STATEMENT, C as T_RETURN_STATEMENT, D as T_IF_STATEMENT, E as T_CONST_STATEMENT, F as T_LET_STATEMENT, G as T_ARROW_EXPRESSION_STATEMENT, H as T_BLOCK_STATEMENT, I as T_VAR_STATEMENT, J as T_ASSIGNMENT_EXPRESSION, K as T_LITERAL, M as T_SPREAD_EXPRESSION, N as T_FUNCTION_INVOCATION_EXPRESSION, O as T_POSTFIX_OP_EXPRESSION, Q as T_CONDITIONAL_EXPRESSION, R as T_BINARY_EXPRESSION, S as T_UNARY_EXPRESSION, U as T_OBJECT_LITERAL, V as T_ARRAY_LITERAL, W as T_SEQUENCE_EXPRESSION, X as T_TEMPLATE_LITERAL_EXPRESSION, Y as T_VAR_DECLARATION, Z as T_DESTRUCTURE, _ as TextVariantElement, $ as VariantPropsKeys, a0 as variantOptionsMd, a1 as scrollAnchoringValues, a2 as buttonThemeNames, a3 as iconPositionNames, a4 as buttonVariantNames, a5 as nodeToComponentDef, a6 as triggerPositionNames, a7 as statusColorMd, a8 as placementMd, a9 as httpMethodNames, aa as PARSED_MARK_PROP, ab as layoutOptionKeys, ac as viewportSizeNames, ad as componentFileExtension, ae as codeBehindFileExtension, af as getLintSeverity, ag as LintSeverity, ah as lintApp, ai as printComponentLints, aj as lintErrorsComponent, ak as collectCodeBehindFromSource, al as removeCodeBehindTokensFromTree } from "./lint-B9tKGcOX.mjs";
11
11
  import classnames from "classnames";
12
12
  import Color from "color";
13
13
  import TextareaAutosize from "react-textarea-autosize";
@@ -4481,10 +4481,10 @@ const navLinkComponentRenderer = createComponentRenderer(
4481
4481
  }
4482
4482
  );
4483
4483
  const themeVars$E = `'{"padding-Link": "var(--xmlui-padding-Link)", "paddingHorizontal-Link": "var(--xmlui-paddingHorizontal-Link, var(--xmlui-padding-Link))", "paddingVertical-Link": "var(--xmlui-paddingVertical-Link, var(--xmlui-padding-Link))", "paddingLeft-Link": "var(--xmlui-paddingLeft-Link, var(--xmlui-paddingHorizontal-Link, var(--xmlui-padding-Link)))", "paddingRight-Link": "var(--xmlui-paddingRight-Link, var(--xmlui-paddingHorizontal-Link, var(--xmlui-padding-Link)))", "paddingTop-Link": "var(--xmlui-paddingTop-Link, var(--xmlui-paddingVertical-Link, var(--xmlui-padding-Link)))", "paddingBottom-Link": "var(--xmlui-paddingBottom-Link, var(--xmlui-paddingVertical-Link, var(--xmlui-padding-Link)))", "padding-icon-Link": "var(--xmlui-padding-icon-Link)", "paddingHorizontal-icon-Link": "var(--xmlui-paddingHorizontal-icon-Link, var(--xmlui-padding-icon-Link))", "paddingVertical-icon-Link": "var(--xmlui-paddingVertical-icon-Link, var(--xmlui-padding-icon-Link))", "paddingLeft-icon-Link": "var(--xmlui-paddingLeft-icon-Link, var(--xmlui-paddingHorizontal-icon-Link, var(--xmlui-padding-icon-Link)))", "paddingRight-icon-Link": "var(--xmlui-paddingRight-icon-Link, var(--xmlui-paddingHorizontal-icon-Link, var(--xmlui-padding-icon-Link)))", "paddingTop-icon-Link": "var(--xmlui-paddingTop-icon-Link, var(--xmlui-paddingVertical-icon-Link, var(--xmlui-padding-icon-Link)))", "paddingBottom-icon-Link": "var(--xmlui-paddingBottom-icon-Link, var(--xmlui-paddingVertical-icon-Link, var(--xmlui-padding-icon-Link)))", "border-Link": "var(--xmlui-border-Link)", "borderHorizontal-Link": "var(--xmlui-borderHorizontal-Link, var(--xmlui-border-Link))", "borderVertical-Link": "var(--xmlui-borderVertical-Link, var(--xmlui-border-Link))", "borderLeft-Link": "var(--xmlui-borderLeft-Link, var(--xmlui-borderHorizontal-Link, var(--xmlui-border-Link)))", "borderRight-Link": "var(--xmlui-borderRight-Link, var(--xmlui-borderHorizontal-Link, var(--xmlui-border-Link)))", "borderTop-Link": "var(--xmlui-borderTop-Link, var(--xmlui-borderVertical-Link, var(--xmlui-border-Link)))", "borderBottom-Link": "var(--xmlui-borderBottom-Link, var(--xmlui-borderVertical-Link, var(--xmlui-border-Link)))", "borderWidth-Link": "var(--xmlui-borderWidth-Link)", "borderHorizontalWidth-Link": "var(--xmlui-borderHorizontalWidth-Link, var(--xmlui-borderWidth-Link))", "borderLeftWidth-Link": "var(--xmlui-borderLeftWidth-Link, var(--xmlui-borderHorizontalWidth-Link, var(--xmlui-borderWidth-Link)))", "borderRightWidth-Link": "var(--xmlui-borderRightWidth-Link, var(--xmlui-borderHorizontalWidth-Link, var(--xmlui-borderWidth-Link)))", "borderVerticalWidth-Link": "var(--xmlui-borderVerticalWidth-Link, var(--xmlui-borderWidth-Link))", "borderTopWidth-Link": "var(--xmlui-borderTopWidth-Link, var(--xmlui-borderVerticalWidth-Link, var(--xmlui-borderWidth-Link)))", "borderBottomWidth-Link": "var(--xmlui-borderBottomWidth-Link, var(--xmlui-borderVerticalWidth-Link, var(--xmlui-borderWidth-Link)))", "borderStyle-Link": "var(--xmlui-borderStyle-Link)", "borderHorizontalStyle-Link": "var(--xmlui-borderHorizontalStyle-Link, var(--xmlui-borderStyle-Link))", "borderLeftStyle-Link": "var(--xmlui-borderLeftStyle-Link, var(--xmlui-borderHorizontalStyle-Link, var(--xmlui-borderStyle-Link)))", "borderRightStyle-Link": "var(--xmlui-borderRightStyle-Link, var(--xmlui-borderHorizontalStyle-Link, var(--xmlui-borderStyle-Link)))", "borderVerticalStyle-Link": "var(--xmlui-borderVerticalStyle-Link, var(--xmlui-borderStyle-Link))", "borderTopStyle-Link": "var(--xmlui-borderTopStyle-Link, var(--xmlui-borderVerticalStyle-Link, var(--xmlui-borderStyle-Link)))", "borderBottomStyle-Link": "var(--xmlui-borderBottomStyle-Link, var(--xmlui-borderVerticalStyle-Link, var(--xmlui-borderStyle-Link)))", "borderColor-Link": "var(--xmlui-borderColor-Link)", "borderHorizontalColor-Link": "var(--xmlui-borderHorizontalColor-Link, var(--xmlui-borderColor-Link))", "borderLeftColor-Link": "var(--xmlui-borderLeftColor-Link, var(--xmlui-borderHorizontalColor-Link, var(--xmlui-borderColor-Link)))", "borderRightColor-Link": "var(--xmlui-borderRightColor-Link, var(--xmlui-borderHorizontalColor-Link, var(--xmlui-borderColor-Link)))", "borderVerticalColor-Link": "var(--xmlui-borderVerticalColor-Link, var(--xmlui-borderColor-Link))", "borderTopColor-Link": "var(--xmlui-borderTopColor-Link, var(--xmlui-borderVerticalColor-Link, var(--xmlui-borderColor-Link)))", "borderBottomColor-Link": "var(--xmlui-borderBottomColor-Link, var(--xmlui-borderVerticalColor-Link, var(--xmlui-borderColor-Link)))", "borderStartStartRadius-Link": "var(--xmlui-borderStartStartRadius-Link, var(--xmlui-borderRadius-Link))", "borderStartEndRadius-Link": "var(--xmlui-borderStartEndRadius-Link, var(--xmlui-borderRadius-Link))", "borderEndStartRadius-Link": "var(--xmlui-borderEndStartRadius-Link, var(--xmlui-borderRadius-Link))", "borderEndEndRadius-Link": "var(--xmlui-borderEndEndRadius-Link, var(--xmlui-borderRadius-Link))", "textColor-Link": "var(--xmlui-textColor-Link)", "textColor-Link--active": "var(--xmlui-textColor-Link--active)", "textColor-Link--hover": "var(--xmlui-textColor-Link--hover)", "textColor-Link--hover--active": "var(--xmlui-textColor-Link--hover--active)", "fontFamily-Link": "var(--xmlui-fontFamily-Link)", "fontSize-Link": "var(--xmlui-fontSize-Link)", "fontWeight-Link": "var(--xmlui-fontWeight-Link)", "fontWeight-Link--active": "var(--xmlui-fontWeight-Link--active)", "textDecorationColor-Link": "var(--xmlui-textDecorationColor-Link)", "textUnderlineOffset-Link": "var(--xmlui-textUnderlineOffset-Link)", "textDecorationLine-Link": "var(--xmlui-textDecorationLine-Link)", "textDecorationStyle-Link": "var(--xmlui-textDecorationStyle-Link)", "textDecorationThickness-Link": "var(--xmlui-textDecorationThickness-Link)", "gap-icon-Link": "var(--xmlui-gap-icon-Link)", "outlineWidth-Link--focus": "var(--xmlui-outlineWidth-Link--focus)", "outlineColor-Link--focus": "var(--xmlui-outlineColor-Link--focus)", "outlineStyle-Link--focus": "var(--xmlui-outlineStyle-Link--focus)", "outlineOffset-Link--focus": "var(--xmlui-outlineOffset-Link--focus)"}'`;
4484
- const container$2 = "_container_1pdwf_13";
4485
- const active$3 = "_active_1pdwf_53";
4486
- const disabled$5 = "_disabled_1pdwf_57";
4487
- const iconWrapper = "_iconWrapper_1pdwf_73";
4484
+ const container$2 = "_container_k8i4t_13";
4485
+ const active$3 = "_active_k8i4t_53";
4486
+ const disabled$5 = "_disabled_k8i4t_57";
4487
+ const iconWrapper = "_iconWrapper_k8i4t_73";
4488
4488
  const styles$V = {
4489
4489
  themeVars: themeVars$E,
4490
4490
  container: container$2,
@@ -23117,6 +23117,11 @@ function ThemeProvider({
23117
23117
  }
23118
23118
  return defaultTone;
23119
23119
  });
23120
+ useEffect(() => {
23121
+ if (defaultTone) {
23122
+ setActiveThemeTone(defaultTone);
23123
+ }
23124
+ }, [defaultTone]);
23120
23125
  const themes = useMemo(() => {
23121
23126
  return [...custThemes, ...builtInThemes];
23122
23127
  }, [custThemes]);
@@ -31666,7 +31671,7 @@ function IconProvider({ children }) {
31666
31671
  /* @__PURE__ */ jsx("svg", { style: { display: "none" }, ref: spriteRootRef })
31667
31672
  ] });
31668
31673
  }
31669
- const version = "0.9.5";
31674
+ const version = "0.9.7";
31670
31675
  const ApiInterceptorContext = createContext(null);
31671
31676
  function useApiInterceptorContext() {
31672
31677
  return useContext(ApiInterceptorContext);
@@ -33517,6 +33522,15 @@ const Container = memo(
33517
33522
  );
33518
33523
  }
33519
33524
  statements = parsedStatementsRef.current[source];
33525
+ } else if (isParsedEventValue(source)) {
33526
+ const parseId = source.parseId.toString();
33527
+ if (!parsedStatementsRef.current[parseId]) {
33528
+ parsedStatementsRef.current[parseId] = prepareHandlerStatements(
33529
+ source.statements,
33530
+ evalContext
33531
+ );
33532
+ }
33533
+ statements = parsedStatementsRef.current[parseId];
33520
33534
  } else {
33521
33535
  statements = [
33522
33536
  {
@@ -33634,23 +33648,44 @@ const Container = memo(
33634
33648
  );
33635
33649
  const getOrCreateEventHandlerFn = useEvent(
33636
33650
  (src, uid, options2) => {
33637
- var _a2;
33651
+ var _a2, _b;
33638
33652
  if (Array.isArray(src)) {
33639
33653
  throw new Error("Multiple event handlers are not supported");
33640
33654
  }
33641
- const stringSrc = typeof src === "string" ? src : src.statement.nodeId;
33642
- const fnCacheKey = `${options2 == null ? void 0 : options2.eventName};${stringSrc}`;
33643
- const handler = (...eventArgs) => {
33644
- return runCodeAsync(src, uid, options2, ...cloneDeep(eventArgs));
33645
- };
33646
- if (options2 == null ? void 0 : options2.ephemeral) {
33647
- return handler;
33655
+ if (typeof src === "string") {
33656
+ const fnCacheKey = `${options2 == null ? void 0 : options2.eventName};${src}`;
33657
+ const handler = (...eventArgs) => {
33658
+ return runCodeAsync(src, uid, options2, ...cloneDeep(eventArgs));
33659
+ };
33660
+ if (options2 == null ? void 0 : options2.ephemeral) {
33661
+ return handler;
33662
+ }
33663
+ if (!((_a2 = fnsRef.current[uid]) == null ? void 0 : _a2[fnCacheKey])) {
33664
+ fnsRef.current[uid] = fnsRef.current[uid] || {};
33665
+ fnsRef.current[uid][fnCacheKey] = handler;
33666
+ }
33667
+ return fnsRef.current[uid][fnCacheKey];
33648
33668
  }
33649
- if (!((_a2 = fnsRef.current[uid]) == null ? void 0 : _a2[fnCacheKey])) {
33650
- fnsRef.current[uid] = fnsRef.current[uid] || {};
33651
- fnsRef.current[uid][fnCacheKey] = handler;
33669
+ if (isParsedEventValue(src)) {
33670
+ return (...eventArgs) => {
33671
+ return runCodeAsync(src, uid, options2, ...cloneDeep(eventArgs));
33672
+ };
33652
33673
  }
33653
- return fnsRef.current[uid][fnCacheKey];
33674
+ if (isArrowExpression(src)) {
33675
+ const fnCacheKey = `${options2 == null ? void 0 : options2.eventName};${src.statement.nodeId}`;
33676
+ const handler = (...eventArgs) => {
33677
+ return runCodeAsync(src, uid, options2, ...cloneDeep(eventArgs));
33678
+ };
33679
+ if (options2 == null ? void 0 : options2.ephemeral) {
33680
+ return handler;
33681
+ }
33682
+ if (!((_b = fnsRef.current[uid]) == null ? void 0 : _b[fnCacheKey])) {
33683
+ fnsRef.current[uid] = fnsRef.current[uid] || {};
33684
+ fnsRef.current[uid][fnCacheKey] = handler;
33685
+ }
33686
+ return fnsRef.current[uid][fnCacheKey];
33687
+ }
33688
+ throw new Error("Invalid event handler");
33654
33689
  }
33655
33690
  );
33656
33691
  const getOrCreateSyncCallbackFn = useCallback(
@@ -33938,6 +33973,12 @@ function renderLoaders({
33938
33973
  );
33939
33974
  }
33940
33975
  }
33976
+ function isParsedEventValue(value) {
33977
+ return value.__PARSED === true;
33978
+ }
33979
+ function isArrowExpression(value) {
33980
+ return value.type === T_ARROW_EXPRESSION;
33981
+ }
33941
33982
  const StateContainer = memo(
33942
33983
  forwardRef(function StateContainer2({
33943
33984
  node,
@@ -35213,7 +35254,8 @@ function AppContent({
35213
35254
  standalone,
35214
35255
  trackContainerHeight,
35215
35256
  decorateComponentsWithTestId,
35216
- debugEnabled
35257
+ debugEnabled,
35258
+ children
35217
35259
  }) {
35218
35260
  const [loggedInUser, setLoggedInUser] = useState(null);
35219
35261
  const debugView = useDebugView();
@@ -35510,7 +35552,10 @@ function AppContent({
35510
35552
  cleanup: noop$1,
35511
35553
  memoedVarsRef
35512
35554
  });
35513
- return /* @__PURE__ */ jsx(AppContext.Provider, { value: appContextValue, children: /* @__PURE__ */ jsx(AppStateContext.Provider, { value: appStateContextValue, children: renderedRoot }) });
35555
+ return /* @__PURE__ */ jsx(AppContext.Provider, { value: appContextValue, children: /* @__PURE__ */ jsxs(AppStateContext.Provider, { value: appStateContextValue, children: [
35556
+ renderedRoot,
35557
+ children
35558
+ ] }) });
35514
35559
  }
35515
35560
  function signError(error2) {
35516
35561
  toast.error(typeof error2 === "string" ? error2 : error2.message || "Something went wrong");
@@ -35529,7 +35574,8 @@ const AppWrapper = ({
35529
35574
  defaultTone,
35530
35575
  resources,
35531
35576
  resourceMap,
35532
- sources
35577
+ sources,
35578
+ children
35533
35579
  }) => {
35534
35580
  if (previewMode) {
35535
35581
  HelmetProvider.canUseDOM = false;
@@ -35554,7 +35600,8 @@ const AppWrapper = ({
35554
35600
  globalProps,
35555
35601
  standalone,
35556
35602
  decorateComponentsWithTestId,
35557
- debugEnabled
35603
+ debugEnabled,
35604
+ children
35558
35605
  }
35559
35606
  ) }) })
35560
35607
  }
@@ -35593,7 +35640,8 @@ function AppRoot({
35593
35640
  previewMode,
35594
35641
  resourceMap,
35595
35642
  sources,
35596
- extensionManager
35643
+ extensionManager,
35644
+ children
35597
35645
  }) {
35598
35646
  const rootNode = useMemo(() => {
35599
35647
  const themedRoot = node.type === "Theme" ? {
@@ -35633,7 +35681,8 @@ function AppRoot({
35633
35681
  standalone,
35634
35682
  trackContainerHeight,
35635
35683
  previewMode,
35636
- sources
35684
+ sources,
35685
+ children
35637
35686
  }
35638
35687
  ) }) });
35639
35688
  }
@@ -35650,7 +35699,7 @@ function ApiInterceptorProvider({
35650
35699
  let interceptorWorker;
35651
35700
  (async () => {
35652
35701
  if (process.env.VITE_MOCK_ENABLED) {
35653
- const { createApiInterceptorWorker } = await import("./apiInterceptorWorker-Be8IJaBL.mjs");
35702
+ const { createApiInterceptorWorker } = await import("./apiInterceptorWorker-DJ9I-JAW.mjs");
35654
35703
  if (interceptor) {
35655
35704
  interceptorWorker = await createApiInterceptorWorker(interceptor, apiWorker);
35656
35705
  if (!apiWorker) {
package/dist/index.css CHANGED
@@ -1960,7 +1960,7 @@
1960
1960
  * This function allows other CSS modules to get the value of the CSS variable specified in $componentVariable.
1961
1961
  Optionally, you can provide a $fallbackValue to set the variable's value if that is not defined.
1962
1962
  */
1963
- ._container_1pdwf_13 {
1963
+ ._container_k8i4t_13 {
1964
1964
  border-left: var(--xmlui-borderLeft-Link, var(--xmlui-borderHorizontal-Link, var(--xmlui-border-Link)));
1965
1965
  border-right: var(--xmlui-borderRight-Link, var(--xmlui-borderHorizontal-Link, var(--xmlui-border-Link)));
1966
1966
  border-top: var(--xmlui-borderTop-Link, var(--xmlui-borderVertical-Link, var(--xmlui-border-Link)));
@@ -2000,27 +2000,27 @@
2000
2000
  flex-direction: row;
2001
2001
  align-items: center;
2002
2002
  }
2003
- ._container_1pdwf_13._active_1pdwf_53 {
2003
+ ._container_k8i4t_13._active_k8i4t_53 {
2004
2004
  color: var(--xmlui-textColor-Link--active);
2005
2005
  font-weight: var(--xmlui-fontWeight-Link--active);
2006
2006
  }
2007
- ._container_1pdwf_13._disabled_1pdwf_57 {
2007
+ ._container_k8i4t_13._disabled_k8i4t_57 {
2008
2008
  pointer-events: none;
2009
2009
  }
2010
- ._container_1pdwf_13:not(._disabled_1pdwf_57):hover {
2010
+ ._container_k8i4t_13:not(._disabled_k8i4t_57):hover {
2011
2011
  color: var(--xmlui-textColor-Link--hover);
2012
2012
  }
2013
- ._container_1pdwf_13:not(._disabled_1pdwf_57):focus-visible {
2013
+ ._container_k8i4t_13:not(._disabled_k8i4t_57):focus-visible {
2014
2014
  outline-width: var(--xmlui-outlineWidth-Link--focus);
2015
2015
  outline-color: var(--xmlui-outlineColor-Link--focus);
2016
2016
  outline-style: var(--xmlui-outlineStyle-Link--focus);
2017
2017
  outline-offset: var(--xmlui-outlineOffset-Link--focus);
2018
2018
  }
2019
- ._container_1pdwf_13:not(._disabled_1pdwf_57)._active_1pdwf_53:hover {
2019
+ ._container_k8i4t_13:not(._disabled_k8i4t_57)._active_k8i4t_53:hover {
2020
2020
  color: var(--xmlui-textColor-Link--hover--active);
2021
2021
  }
2022
2022
 
2023
- ._iconWrapper_1pdwf_73 {
2023
+ ._iconWrapper_k8i4t_73 {
2024
2024
  padding: var(--xmlui-padding-icon-Link);
2025
2025
  padding-left: var(--xmlui-paddingLeft-icon-Link, var(--xmlui-paddingHorizontal-icon-Link, var(--xmlui-padding-icon-Link)));
2026
2026
  padding-right: var(--xmlui-paddingRight-icon-Link, var(--xmlui-paddingHorizontal-icon-Link, var(--xmlui-padding-icon-Link)));
@@ -2030,25 +2030,24 @@
2030
2030
  line-height: 0;
2031
2031
  }
2032
2032
 
2033
- ._container_1pdwf_13:not(._active_1pdwf_53) {
2033
+ ._container_k8i4t_13:not(._active_k8i4t_53) {
2034
2034
  text-underline-offset: var(--xmlui-textUnderlineOffset-Link);
2035
- }
2036
- ._container_1pdwf_13:not(._active_1pdwf_53):not([disabled]):hover {
2037
2035
  text-decoration-line: var(--xmlui-textDecorationLine-Link);
2036
+ }
2037
+ ._container_k8i4t_13:not(._active_k8i4t_53):not([disabled]):hover {
2038
2038
  text-decoration-color: var(--xmlui-textDecorationColor-Link);
2039
2039
  text-decoration-style: var(--xmlui-textDecorationStyle-Link);
2040
2040
  text-decoration-thickness: var(--xmlui-textDecorationThickness-Link);
2041
2041
  }
2042
- ._container_1pdwf_13:not(._active_1pdwf_53):not([disabled]):hover:has(> button) {
2042
+ ._container_k8i4t_13:not(._active_k8i4t_53):not([disabled]):hover:has(> button) {
2043
2043
  text-decoration-line: none;
2044
2044
  }
2045
- ._container_1pdwf_13:not(._active_1pdwf_53):not([disabled]):active {
2046
- text-decoration-line: var(--xmlui-textDecorationLine-Link);
2045
+ ._container_k8i4t_13:not(._active_k8i4t_53):not([disabled]):active {
2047
2046
  text-decoration-color: var(--xmlui-textDecorationColor-Link);
2048
2047
  text-decoration-style: var(--xmlui-textDecorationStyle-Link);
2049
2048
  text-decoration-thickness: var(--xmlui-textDecorationThickness-Link);
2050
2049
  }
2051
- ._container_1pdwf_13:not(._active_1pdwf_53):not([disabled]):active:has(> button) {
2050
+ ._container_k8i4t_13:not(._active_k8i4t_53):not([disabled]):active:has(> button) {
2052
2051
  text-decoration-line: none;
2053
2052
  }
2054
2053
  /*
@@ -1552,7 +1552,11 @@ class Parser {
1552
1552
  case TokenType.Function:
1553
1553
  return this.parseFunctionDeclaration();
1554
1554
  default:
1555
- return this.isExpressionStart(startToken) ? this.parseExpressionStatement(allowSequence) : null;
1555
+ if (this.isExpressionStart(startToken)) {
1556
+ return this.parseExpressionStatement(allowSequence);
1557
+ }
1558
+ this.reportError("W002", startToken, startToken.text);
1559
+ return null;
1556
1560
  }
1557
1561
  } finally {
1558
1562
  this._statementLevel--;
@@ -3701,7 +3705,9 @@ class Parser {
3701
3705
  }
3702
3706
  this._parseErrors.push({
3703
3707
  code: errorCode,
3704
- text: errorText
3708
+ text: errorText,
3709
+ line: token.startLine,
3710
+ column: token.startColumn
3705
3711
  });
3706
3712
  throw new ParserError$1(errorText, errorCode);
3707
3713
  function replace(input, placeholder, replacement) {
@@ -4808,8 +4814,7 @@ function parseScriptModule(moduleName, source) {
4808
4814
  exports,
4809
4815
  functions,
4810
4816
  statements,
4811
- sources: /* @__PURE__ */ new Map(),
4812
- executed: false
4817
+ sources: /* @__PURE__ */ new Map()
4813
4818
  };
4814
4819
  parsedModules.set(moduleName2, parsedModule2);
4815
4820
  if (errors.length > 0) {
@@ -4864,7 +4869,7 @@ function collectCodeBehindFromSource(moduleName, source) {
4864
4869
  addFunctionDeclaration(stmt);
4865
4870
  break;
4866
4871
  default:
4867
- throw new Error(`'${stmt.type}' is not allowed in a code-behind module.`);
4872
+ throw new Error(`Only reactive variable and function definitions are allowed in a code-behind module.`);
4868
4873
  }
4869
4874
  });
4870
4875
  return result;
@@ -4995,6 +5000,7 @@ const HelperNode = {
4995
5000
  item: "item",
4996
5001
  field: "field"
4997
5002
  };
5003
+ let lastParseId = 0;
4998
5004
  function nodeToComponentDef(node, originalGetText, fileId) {
4999
5005
  const getText = (node2) => {
5000
5006
  return node2.text ?? originalGetText(node2);
@@ -5202,7 +5208,7 @@ function nodeToComponentDef(node, originalGetText, fileId) {
5202
5208
  (name, value) => {
5203
5209
  if (!isComponent(comp)) return;
5204
5210
  comp.events ?? (comp.events = {});
5205
- comp.events[name] = value;
5211
+ comp.events[name] = parseEvent(value);
5206
5212
  },
5207
5213
  (name) => {
5208
5214
  if (onPrefixRegex.test(name)) {
@@ -5311,11 +5317,11 @@ function nodeToComponentDef(node, originalGetText, fileId) {
5311
5317
  comp.api[name] = value;
5312
5318
  } else if (startSegment === "event") {
5313
5319
  comp.events ?? (comp.events = {});
5314
- comp.events[name] = value;
5320
+ comp.events[name] = parseEvent(value);
5315
5321
  } else if (onPrefixRegex.test(name)) {
5316
5322
  comp.events ?? (comp.events = {});
5317
5323
  const eventName = name[2].toLowerCase() + name.substring(3);
5318
- comp.events[eventName] = value;
5324
+ comp.events[eventName] = parseEvent(value);
5319
5325
  } else {
5320
5326
  comp.props ?? (comp.props = {});
5321
5327
  comp.props[name] = value;
@@ -5734,6 +5740,27 @@ function nodeToComponentDef(node, originalGetText, fileId) {
5734
5740
  }
5735
5741
  }
5736
5742
  }
5743
+ function parseEvent(value) {
5744
+ if (typeof value !== "string") {
5745
+ return value;
5746
+ }
5747
+ const parser = new Parser(value);
5748
+ try {
5749
+ const statements = parser.parseStatements();
5750
+ return {
5751
+ __PARSED: true,
5752
+ statements,
5753
+ parseId: ++lastParseId,
5754
+ // TODO: retrieve the event source code only in dev mode
5755
+ source: value
5756
+ };
5757
+ } catch {
5758
+ if (parser.errors.length > 0) {
5759
+ const errMsg = parser.errors[0];
5760
+ throw new ParserError2(`${errMsg.text} [${errMsg.line}: ${errMsg.column}]`, errMsg.code);
5761
+ }
5762
+ }
5763
+ }
5737
5764
  }
5738
5765
  function createTextNodeCDataElement(textValue) {
5739
5766
  return {
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -160,6 +160,13 @@ exports.Container = (0, react_1.memo)((0, react_1.forwardRef)(function Container
160
160
  }
161
161
  statements = parsedStatementsRef.current[source];
162
162
  }
163
+ else if (isParsedEventValue(source)) {
164
+ const parseId = source.parseId.toString();
165
+ if (!parsedStatementsRef.current[parseId]) {
166
+ parsedStatementsRef.current[parseId] = (0, statementUtils_1.prepareHandlerStatements)(source.statements, evalContext);
167
+ }
168
+ statements = parsedStatementsRef.current[parseId];
169
+ }
163
170
  else {
164
171
  statements = [
165
172
  {
@@ -293,23 +300,48 @@ exports.Container = (0, react_1.memo)((0, react_1.forwardRef)(function Container
293
300
  }
294
301
  }, [appContext]);
295
302
  const getOrCreateEventHandlerFn = (0, misc_1.useEvent)((src, uid, options) => {
296
- var _a;
303
+ var _a, _b;
297
304
  if (Array.isArray(src)) {
298
305
  throw new Error("Multiple event handlers are not supported");
299
306
  }
300
- const stringSrc = typeof src === "string" ? src : src.statement.nodeId;
301
- const fnCacheKey = `${options === null || options === void 0 ? void 0 : options.eventName};${stringSrc}`;
302
- const handler = (...eventArgs) => {
303
- return runCodeAsync(src, uid, options, ...(0, lodash_es_1.cloneDeep)(eventArgs));
304
- };
305
- if (options === null || options === void 0 ? void 0 : options.ephemeral) {
306
- return handler;
307
+ if (typeof src === "string") {
308
+ // --- We have a string event handler
309
+ const fnCacheKey = `${options === null || options === void 0 ? void 0 : options.eventName};${src}`;
310
+ const handler = (...eventArgs) => {
311
+ return runCodeAsync(src, uid, options, ...(0, lodash_es_1.cloneDeep)(eventArgs));
312
+ };
313
+ if (options === null || options === void 0 ? void 0 : options.ephemeral) {
314
+ return handler;
315
+ }
316
+ if (!((_a = fnsRef.current[uid]) === null || _a === void 0 ? void 0 : _a[fnCacheKey])) {
317
+ fnsRef.current[uid] = fnsRef.current[uid] || {};
318
+ fnsRef.current[uid][fnCacheKey] = handler;
319
+ }
320
+ return fnsRef.current[uid][fnCacheKey];
307
321
  }
308
- if (!((_a = fnsRef.current[uid]) === null || _a === void 0 ? void 0 : _a[fnCacheKey])) {
309
- fnsRef.current[uid] = fnsRef.current[uid] || {};
310
- fnsRef.current[uid][fnCacheKey] = handler;
322
+ if (isParsedEventValue(src)) {
323
+ // --- We have the syntax tree to execute, no need to cache
324
+ return (...eventArgs) => {
325
+ return runCodeAsync(src, uid, options, ...(0, lodash_es_1.cloneDeep)(eventArgs));
326
+ };
327
+ }
328
+ if (isArrowExpression(src)) {
329
+ // --- We have an arrow expression to execute
330
+ const fnCacheKey = `${options === null || options === void 0 ? void 0 : options.eventName};${src.statement.nodeId}`;
331
+ const handler = (...eventArgs) => {
332
+ return runCodeAsync(src, uid, options, ...(0, lodash_es_1.cloneDeep)(eventArgs));
333
+ };
334
+ if (options === null || options === void 0 ? void 0 : options.ephemeral) {
335
+ return handler;
336
+ }
337
+ if (!((_b = fnsRef.current[uid]) === null || _b === void 0 ? void 0 : _b[fnCacheKey])) {
338
+ fnsRef.current[uid] = fnsRef.current[uid] || {};
339
+ fnsRef.current[uid][fnCacheKey] = handler;
340
+ }
341
+ return fnsRef.current[uid][fnCacheKey];
311
342
  }
312
- return fnsRef.current[uid][fnCacheKey];
343
+ // --- We have an unknown event handler
344
+ throw new Error("Invalid event handler");
313
345
  });
314
346
  const getOrCreateSyncCallbackFn = (0, react_1.useCallback)((arrowExpression, uid) => {
315
347
  var _a;
@@ -565,3 +597,9 @@ function renderLoaders({ uidInfo, uidInfoRef, loaders = constants_1.EMPTY_ARRAY,
565
597
  return ((0, jsx_runtime_1.jsx)(LoaderComponent_1.LoaderComponent, { onUnmount: cleanup, node: loader, state: componentState, dispatch: dispatch, registerComponentApi: registerComponentApi, lookupAction: lookupAction, lookupSyncCallback: lookupSyncCallback, memoedVarsRef: memoedVarsRef, appContext: appContext }));
566
598
  }
567
599
  }
600
+ function isParsedEventValue(value) {
601
+ return value.__PARSED === true;
602
+ }
603
+ function isArrowExpression(value) {
604
+ return value.type === ScriptingSourceTree_1.T_ARROW_EXPRESSION;
605
+ }
@@ -208,6 +208,11 @@ function ThemeProvider({ children, themes: custThemes = constants_1.EMPTY_ARRAY,
208
208
  }
209
209
  return defaultTone;
210
210
  });
211
+ (0, react_1.useEffect)(() => {
212
+ if (defaultTone) {
213
+ setActiveThemeTone(defaultTone);
214
+ }
215
+ }, [defaultTone]);
211
216
  const themes = (0, react_1.useMemo)(() => {
212
217
  return [...custThemes, ...exports.builtInThemes];
213
218
  }, [custThemes]);
@@ -152,9 +152,11 @@ class Parser {
152
152
  case TokenType_1.TokenType.Function:
153
153
  return this.parseFunctionDeclaration();
154
154
  default:
155
- return this.isExpressionStart(startToken)
156
- ? this.parseExpressionStatement(allowSequence)
157
- : null;
155
+ if (this.isExpressionStart(startToken)) {
156
+ return this.parseExpressionStatement(allowSequence);
157
+ }
158
+ this.reportError("W002", startToken, startToken.text);
159
+ return null;
158
160
  }
159
161
  }
160
162
  finally {
@@ -2144,6 +2146,8 @@ class Parser {
2144
2146
  this._parseErrors.push({
2145
2147
  code: errorCode,
2146
2148
  text: errorText,
2149
+ line: token.startLine,
2150
+ column: token.startColumn,
2147
2151
  });
2148
2152
  throw new ParserError_1.ParserError(errorText, errorCode);
2149
2153
  function replace(input, placeholder, replacement) {
@@ -38,7 +38,7 @@ function collectCodeBehindFromSource(moduleName, source) {
38
38
  addFunctionDeclaration(stmt);
39
39
  break;
40
40
  default:
41
- throw new Error(`'${stmt.type}' is not allowed in a code-behind module.`);
41
+ throw new Error(`Only reactive variable and function definitions are allowed in a code-behind module.`);
42
42
  }
43
43
  });
44
44
  return result;
@@ -78,7 +78,6 @@ function parseScriptModule(moduleName, source) {
78
78
  functions,
79
79
  statements: statements,
80
80
  sources: new Map(),
81
- executed: false,
82
81
  };
83
82
  // --- Sign this module as parsed
84
83
  parsedModules.set(moduleName, parsedModule);
@@ -28,6 +28,7 @@ const HelperNode = {
28
28
  item: "item",
29
29
  field: "field",
30
30
  };
31
+ let lastParseId = 0;
31
32
  function nodeToComponentDef(node, originalGetText, fileId) {
32
33
  const getText = (node) => {
33
34
  var _a;
@@ -249,7 +250,7 @@ function nodeToComponentDef(node, originalGetText, fileId) {
249
250
  if (!isComponent(comp))
250
251
  return;
251
252
  (_a = comp.events) !== null && _a !== void 0 ? _a : (comp.events = {});
252
- comp.events[name] = value;
253
+ comp.events[name] = parseEvent(value);
253
254
  }, (name) => {
254
255
  if (exports.onPrefixRegex.test(name)) {
255
256
  reportError("T008", name);
@@ -354,12 +355,12 @@ function nodeToComponentDef(node, originalGetText, fileId) {
354
355
  }
355
356
  else if (startSegment === "event") {
356
357
  (_c = comp.events) !== null && _c !== void 0 ? _c : (comp.events = {});
357
- comp.events[name] = value;
358
+ comp.events[name] = parseEvent(value);
358
359
  }
359
360
  else if (exports.onPrefixRegex.test(name)) {
360
361
  (_d = comp.events) !== null && _d !== void 0 ? _d : (comp.events = {});
361
362
  const eventName = name[2].toLowerCase() + name.substring(3);
362
- comp.events[eventName] = value;
363
+ comp.events[eventName] = parseEvent(value);
363
364
  }
364
365
  else {
365
366
  (_e = comp.props) !== null && _e !== void 0 ? _e : (comp.props = {});
@@ -849,6 +850,30 @@ function nodeToComponentDef(node, originalGetText, fileId) {
849
850
  }
850
851
  }
851
852
  }
853
+ function parseEvent(value) {
854
+ if (typeof value !== "string") {
855
+ // --- It must be a component definition in the event code
856
+ return value;
857
+ }
858
+ // --- Parse the event code
859
+ const parser = new Parser_1.Parser(value);
860
+ try {
861
+ const statements = parser.parseStatements();
862
+ return {
863
+ __PARSED: true,
864
+ statements,
865
+ parseId: ++lastParseId,
866
+ // TODO: retrieve the event source code only in dev mode
867
+ source: value,
868
+ };
869
+ }
870
+ catch (_a) {
871
+ if (parser.errors.length > 0) {
872
+ const errMsg = parser.errors[0];
873
+ throw new ParserError_1.ParserError(`${errMsg.text} [${errMsg.line}: ${errMsg.column}]`, errMsg.code);
874
+ }
875
+ }
876
+ }
852
877
  }
853
878
  function createTextNodeCDataElement(textValue) {
854
879
  return {