@sendbird/actionbook-core 0.10.13 → 0.10.15

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/ui/index.js CHANGED
@@ -4790,6 +4790,20 @@ function analyzeJinjaBlocks(doc2) {
4790
4790
  }
4791
4791
 
4792
4792
  // src/jinja/evaluator.ts
4793
+ var ERROR_MESSAGES = {
4794
+ UNTERMINATED_STRING: "Unfinished statement.",
4795
+ EMPTY_EXPRESSION: "Empty expression.",
4796
+ INVALID_EXPRESSION: "Invalid expression.",
4797
+ unexpectedChar: (char) => `Invalid character. ${char}`,
4798
+ expectedToken: (expected, got) => `Expected ${expected}, got ${got}`,
4799
+ unexpectedToken: (value) => `Invalid text at the end of the statement. ${value}`,
4800
+ unexpectedTokenInPrimary: (type, value) => {
4801
+ if (type === "RPAREN") {
4802
+ return "Missing closing parenthesis.";
4803
+ }
4804
+ return `Missing value.`;
4805
+ }
4806
+ };
4793
4807
  var KEYWORDS2 = {
4794
4808
  and: "AND",
4795
4809
  or: "OR",
@@ -4824,7 +4838,7 @@ function tokenize(input) {
4824
4838
  i++;
4825
4839
  }
4826
4840
  }
4827
- if (i >= input.length) return { tokens: [], error: "Unterminated string literal" };
4841
+ if (i >= input.length) return { tokens: [], error: ERROR_MESSAGES.UNTERMINATED_STRING };
4828
4842
  i++;
4829
4843
  tokens.push({ type: "STRING", value: str });
4830
4844
  continue;
@@ -4912,7 +4926,7 @@ function tokenize(input) {
4912
4926
  i++;
4913
4927
  continue;
4914
4928
  }
4915
- return { tokens: [], error: `Unexpected character: ${input[i]}` };
4929
+ return { tokens: [], error: ERROR_MESSAGES.unexpectedChar(input[i]) };
4916
4930
  }
4917
4931
  tokens.push({ type: "EOF", value: "" });
4918
4932
  return { tokens };
@@ -4936,7 +4950,7 @@ var Parser = class {
4936
4950
  expect(type) {
4937
4951
  const t = this.peek();
4938
4952
  if (t.type !== type) {
4939
- throw new Error(`Expected ${type}, got ${t.type}`);
4953
+ throw new Error(ERROR_MESSAGES.expectedToken(type, t.type));
4940
4954
  }
4941
4955
  return this.advance();
4942
4956
  }
@@ -4950,7 +4964,7 @@ var Parser = class {
4950
4964
  evaluate() {
4951
4965
  const result = this.orExpr();
4952
4966
  if (this.peek().type !== "EOF") {
4953
- throw new Error(`Unexpected token: ${this.peek().value}`);
4967
+ throw new Error(ERROR_MESSAGES.unexpectedToken(this.peek().value));
4954
4968
  }
4955
4969
  return result;
4956
4970
  }
@@ -5062,7 +5076,7 @@ var Parser = class {
5062
5076
  return val;
5063
5077
  }
5064
5078
  default:
5065
- throw new Error(`Unexpected token in primary: ${t.type} "${t.value}"`);
5079
+ throw new Error(ERROR_MESSAGES.unexpectedTokenInPrimary(t.type, t.value));
5066
5080
  }
5067
5081
  }
5068
5082
  resolveVariable(name) {
@@ -5108,13 +5122,13 @@ function validateCondition(condition) {
5108
5122
  if (trimmed === "") return { valid: true };
5109
5123
  const { tokens, error: tokenError } = tokenize(trimmed);
5110
5124
  if (tokenError) return { valid: false, error: tokenError };
5111
- if (tokens.length === 0) return { valid: false, error: "Empty expression" };
5125
+ if (tokens.length === 0) return { valid: false, error: ERROR_MESSAGES.EMPTY_EXPRESSION };
5112
5126
  try {
5113
5127
  const parser = new Parser(tokens, /* @__PURE__ */ new Map());
5114
5128
  parser.evaluate();
5115
5129
  return { valid: true };
5116
5130
  } catch (e) {
5117
- const msg = e instanceof Error ? e.message : "Invalid expression";
5131
+ const msg = e instanceof Error ? e.message : ERROR_MESSAGES.INVALID_EXPRESSION;
5118
5132
  return { valid: false, error: msg };
5119
5133
  }
5120
5134
  }
@@ -6735,11 +6749,11 @@ function JinjaBranchHeader({
6735
6749
  }, [menuSource]);
6736
6750
  const menuItems = [];
6737
6751
  if (editable) {
6752
+ menuItems.push({
6753
+ label: "Else if",
6754
+ onSelect: () => onAddBranch("elif")
6755
+ });
6738
6756
  if (!hasElseBranch) {
6739
- menuItems.push({
6740
- label: "Else if",
6741
- onSelect: () => onAddBranch("elif")
6742
- });
6743
6757
  menuItems.push({
6744
6758
  label: "Else",
6745
6759
  onSelect: () => onAddBranch("else")
@@ -6750,7 +6764,7 @@ function JinjaBranchHeader({
6750
6764
  onSelect: onDelete
6751
6765
  });
6752
6766
  }
6753
- const canOpenFooterMenu = editable && isLastBranch && branchType !== "else" && !hasElseBranch;
6767
+ const canOpenFooterMenu = editable && isLastBranch && branchType !== "else";
6754
6768
  const isMenuOpen = (source) => menuSource === source && menuItems.length > 0;
6755
6769
  const [conditionTouched, setConditionTouched] = useState3(false);
6756
6770
  const conditionError = (() => {