@process.co/ui 0.0.5 → 0.0.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.
package/dist/index.cjs CHANGED
@@ -10,35 +10,6 @@ function _array_with_holes(arr) {
10
10
  function _array_without_holes(arr) {
11
11
  if (Array.isArray(arr)) return _array_like_to_array(arr);
12
12
  }
13
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
- try {
15
- var info = gen[key](arg);
16
- var value = info.value;
17
- } catch (error) {
18
- reject(error);
19
- return;
20
- }
21
- if (info.done) {
22
- resolve(value);
23
- } else {
24
- Promise.resolve(value).then(_next, _throw);
25
- }
26
- }
27
- function _async_to_generator(fn) {
28
- return function() {
29
- var self = this, args = arguments;
30
- return new Promise(function(resolve, reject) {
31
- var gen = fn.apply(self, args);
32
- function _next(value) {
33
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
34
- }
35
- function _throw(err) {
36
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
37
- }
38
- _next(undefined);
39
- });
40
- };
41
- }
42
13
  function _define_property(obj, key, value) {
43
14
  if (key in obj) {
44
15
  Object.defineProperty(obj, key, {
@@ -52,13 +23,6 @@ function _define_property(obj, key, value) {
52
23
  }
53
24
  return obj;
54
25
  }
55
- function _instanceof(left, right) {
56
- if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
57
- return !!right[Symbol.hasInstance](left);
58
- } else {
59
- return left instanceof right;
60
- }
61
- }
62
26
  function _iterable_to_array(iter) {
63
27
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
64
28
  }
@@ -107,30 +71,6 @@ function _object_spread(target) {
107
71
  }
108
72
  return target;
109
73
  }
110
- function ownKeys(object, enumerableOnly) {
111
- var keys = Object.keys(object);
112
- if (Object.getOwnPropertySymbols) {
113
- var symbols = Object.getOwnPropertySymbols(object);
114
- if (enumerableOnly) {
115
- symbols = symbols.filter(function(sym) {
116
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
117
- });
118
- }
119
- keys.push.apply(keys, symbols);
120
- }
121
- return keys;
122
- }
123
- function _object_spread_props(target, source) {
124
- source = source != null ? source : {};
125
- if (Object.getOwnPropertyDescriptors) {
126
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
127
- } else {
128
- ownKeys(Object(source)).forEach(function(key) {
129
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
130
- });
131
- }
132
- return target;
133
- }
134
74
  function _object_without_properties(source, excluded) {
135
75
  if (source == null) return {};
136
76
  var target = _object_without_properties_loose(source, excluded);
@@ -176,102 +116,7 @@ function _unsupported_iterable_to_array(o, minLen) {
176
116
  if (n === "Map" || n === "Set") return Array.from(n);
177
117
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
178
118
  }
179
- function _ts_generator(thisArg, body) {
180
- var f, y, t, _ = {
181
- label: 0,
182
- sent: function() {
183
- if (t[0] & 1) throw t[1];
184
- return t[1];
185
- },
186
- trys: [],
187
- ops: []
188
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
189
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
190
- return this;
191
- }), g;
192
- function verb(n) {
193
- return function(v) {
194
- return step([
195
- n,
196
- v
197
- ]);
198
- };
199
- }
200
- function step(op) {
201
- if (f) throw new TypeError("Generator is already executing.");
202
- while(g && (g = 0, op[0] && (_ = 0)), _)try {
203
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
204
- if (y = 0, t) op = [
205
- op[0] & 2,
206
- t.value
207
- ];
208
- switch(op[0]){
209
- case 0:
210
- case 1:
211
- t = op;
212
- break;
213
- case 4:
214
- _.label++;
215
- return {
216
- value: op[1],
217
- done: false
218
- };
219
- case 5:
220
- _.label++;
221
- y = op[1];
222
- op = [
223
- 0
224
- ];
225
- continue;
226
- case 7:
227
- op = _.ops.pop();
228
- _.trys.pop();
229
- continue;
230
- default:
231
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
232
- _ = 0;
233
- continue;
234
- }
235
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
236
- _.label = op[1];
237
- break;
238
- }
239
- if (op[0] === 6 && _.label < t[1]) {
240
- _.label = t[1];
241
- t = op;
242
- break;
243
- }
244
- if (t && _.label < t[2]) {
245
- _.label = t[2];
246
- _.ops.push(op);
247
- break;
248
- }
249
- if (t[2]) _.ops.pop();
250
- _.trys.pop();
251
- continue;
252
- }
253
- op = body.call(thisArg, _);
254
- } catch (e) {
255
- op = [
256
- 6,
257
- e
258
- ];
259
- y = 0;
260
- } finally{
261
- f = t = 0;
262
- }
263
- if (op[0] & 5) throw op[1];
264
- return {
265
- value: op[0] ? op[1] : void 0,
266
- done: true
267
- };
268
- }
269
- }
270
119
  var React4 = require('react');
271
- var zustand = require('zustand');
272
- var react = require('@monaco-editor/react');
273
- var reactFontawesome = require('@fortawesome/react-fontawesome');
274
- var proRegularSvgIcons = require('@fortawesome/pro-regular-svg-icons');
275
120
  var reactSlot = require('@radix-ui/react-slot');
276
121
  function _interopNamespace(e) {
277
122
  if (e && e.__esModule) return e;
@@ -293,7 +138,13 @@ function _interopNamespace(e) {
293
138
  return Object.freeze(n);
294
139
  }
295
140
  var React4__namespace = /*#__PURE__*/ _interopNamespace(React4);
296
- // src/components/input.tsx
141
+ var __defProp = Object.defineProperty;
142
+ var __export = function(target, all) {
143
+ for(var name in all)__defProp(target, name, {
144
+ get: all[name],
145
+ enumerable: true
146
+ });
147
+ };
297
148
  // ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
298
149
  function r(e) {
299
150
  var t, f, n = "";
@@ -308,7 +159,47 @@ function clsx() {
308
159
  for(var e, t, f = 0, n = "", o = arguments.length; f < o; f++)(e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
309
160
  return n;
310
161
  }
311
- var clsx_default = clsx;
162
+ // ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
163
+ var falsyToString = function(value) {
164
+ return typeof value === "boolean" ? "".concat(value) : value === 0 ? "0" : value;
165
+ };
166
+ var cx = clsx;
167
+ var cva = function(base, config) {
168
+ return function(props) {
169
+ var _config_compoundVariants;
170
+ if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
171
+ var variants = config.variants, defaultVariants = config.defaultVariants;
172
+ var getVariantClassNames = Object.keys(variants).map(function(variant) {
173
+ var variantProp = props === null || props === void 0 ? void 0 : props[variant];
174
+ var defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
175
+ if (variantProp === null) return null;
176
+ var variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
177
+ return variants[variant][variantKey];
178
+ });
179
+ var propsWithoutUndefined = props && Object.entries(props).reduce(function(acc, param) {
180
+ var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
181
+ if (value === void 0) {
182
+ return acc;
183
+ }
184
+ acc[key] = value;
185
+ return acc;
186
+ }, {});
187
+ var getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce(function(acc, param) {
188
+ var cvClass = param.class, cvClassName = param.className, compoundVariantOptions = _object_without_properties(param, [
189
+ "class",
190
+ "className"
191
+ ]);
192
+ return Object.entries(compoundVariantOptions).every(function(param2) {
193
+ var _param2 = _sliced_to_array(param2, 2), key = _param2[0], value = _param2[1];
194
+ return Array.isArray(value) ? value.includes(_object_spread({}, defaultVariants, propsWithoutUndefined)[key]) : _object_spread({}, defaultVariants, propsWithoutUndefined)[key] === value;
195
+ }) ? _to_consumable_array(acc).concat([
196
+ cvClass,
197
+ cvClassName
198
+ ]) : acc;
199
+ }, []);
200
+ return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
201
+ };
202
+ };
312
203
  // ../../node_modules/.pnpm/tailwind-merge@3.4.0/node_modules/tailwind-merge/dist/bundle-mjs.mjs
313
204
  var concatArrays = function(array1, array2) {
314
205
  var combinedArray = new Array(array1.length + array2.length);
@@ -4941,2118 +4832,431 @@ function cn() {
4941
4832
  }
4942
4833
  return twMerge(clsx(inputs));
4943
4834
  }
4944
- // src/components/ui/input.tsx
4945
- function Input(_param) {
4946
- var className = _param.className, wrapperClassName = _param.wrapperClassName, type = _param.type, required = _param.required, error = _param.error, props = _object_without_properties(_param, [
4947
- "className",
4948
- "wrapperClassName",
4949
- "type",
4950
- "required",
4951
- "error"
4952
- ]);
4953
- return /* @__PURE__ */ React4__namespace.createElement("div", {
4954
- className: cn("uii:relative", wrapperClassName)
4955
- }, /* @__PURE__ */ React4__namespace.createElement("input", _object_spread({
4956
- "aria-invalid": error,
4957
- type: type,
4958
- "data-slot": "input",
4959
- className: cn("uii:border-input uii:file:text-foreground uii:placeholder:text-muted-foreground uii:selection:bg-primary uii:selection:text-primary-foreground uii:flex uii:h-9 uii:w-full uii:min-w-0 uii:rounded-sm uii:border uii:bg-transparent uii:px-3 uii:py-1 uii:text-base uii:shadow-xs uii:transition-[color,box-shadow] uii:outline-none uii:file:inline-flex uii:file:h-7 uii:file:border-0 uii:file:bg-transparent uii:file:text-sm uii:file:font-medium uii:disabled:pointer-events-none uii:disabled:cursor-not-allowed uii:disabled:opacity-50 uii:md:text-sm", "uii:focus-visible:border-ring uii:focus-visible:ring-ring/50 uii:focus-visible:ring-[3px]", "uii:aria-invalid:ring-destructive/20 uii:dark:aria-invalid:ring-destructive/40 uii:aria-invalid:border-destructive", {
4960
- "uii:pr-30": error
4961
- }, className)
4962
- }, props)), error && /* @__PURE__ */ React4__namespace.createElement("span", {
4963
- className: "uii:absolute uii:inset-y-0 uii:right-0 uii:flex uii:items-center uii:pr-2 uii:border-l-10 uii:border-l-background uii:my-[6px] uii:pointer-events-none "
4964
- }, /* @__PURE__ */ React4__namespace.createElement("span", {
4965
- className: "uii:bg-destructive uii:text-white uii:px-1.5 uii:py-1.5 uii:rounded-xs uii:uppercase uii:tracking-wide uii:font-medium uii:text-xs uii:leading-none uii:font-sans"
4966
- }, error && required ? "required" : "error")));
4967
- }
4968
- var defaultState = {
4969
- expression: "",
4970
- mode: "value",
4971
- isEditing: false,
4972
- currentValue: void 0,
4973
- isFullScreen: false
4974
- };
4975
- var useExpressionModeStore = zustand.create(function(set, get) {
4976
- return {
4977
- states: {},
4978
- setState: function(fieldName, state) {
4979
- set(function(store) {
4980
- return {
4981
- states: _object_spread_props(_object_spread({}, store.states), _define_property({}, fieldName, state))
4982
- };
4983
- });
4984
- },
4985
- getState: function(fieldName) {
4986
- var store = get();
4987
- return store.states[fieldName] || defaultState;
4988
- },
4989
- clear: function(fieldName) {
4990
- set(function(store) {
4991
- return {
4992
- states: _object_spread_props(_object_spread({}, store.states), _define_property({}, fieldName, defaultState))
4993
- };
4994
- });
4995
- },
4996
- switchToValue: function(fieldName) {
4997
- var currentState = get().getState(fieldName);
4998
- get().setState(fieldName, _object_spread_props(_object_spread({}, currentState), {
4999
- mode: "value",
5000
- isEditing: false
5001
- }));
5002
- },
5003
- switchToExpression: function(fieldName) {
5004
- var currentState = get().getState(fieldName);
5005
- get().setState(fieldName, _object_spread_props(_object_spread({}, currentState), {
5006
- mode: "expression",
5007
- isEditing: false
5008
- }));
5009
- },
5010
- switchToEditor: function(fieldName) {
5011
- var currentState = get().getState(fieldName);
5012
- get().setState(fieldName, _object_spread_props(_object_spread({}, currentState), {
5013
- mode: "expression",
5014
- isEditing: true
5015
- }));
5016
- },
5017
- setExpression: function(fieldName, expression) {
5018
- var currentState = get().getState(fieldName);
5019
- get().setState(fieldName, _object_spread_props(_object_spread({}, currentState), {
5020
- expression: expression
5021
- }));
5022
- },
5023
- setEditing: function(fieldName, isEditing) {
5024
- var currentState = get().getState(fieldName);
5025
- get().setState(fieldName, _object_spread_props(_object_spread({}, currentState), {
5026
- isEditing: isEditing
5027
- }));
5028
- },
5029
- setFullScreen: function(fieldName, isFullScreen) {
5030
- var currentState = get().getState(fieldName);
5031
- get().setState(fieldName, _object_spread_props(_object_spread({}, currentState), {
5032
- isFullScreen: isFullScreen
5033
- }));
4835
+ // src/components/ui/button.tsx
4836
+ var buttonVariants = cva("ui:inline-flex ui:items-center ui:justify-center ui:gap-2 ui:whitespace-nowrap ui:rounded-sm ui:text-sm ui:font-medium ui:transition-[color,box-shadow] ui:disabled:pointer-events-none ui:disabled:opacity-50 ui:[&_svg]:pointer-events-none ui:[&_svg:not([class*=size-])]:size-4 ui:shrink-0 ui:[&_svg]:shrink-0 ui:outline-none ui:focus-visible:border-ring ui:focus-visible:ring-ring/50 ui:focus-visible:ring-[3px] ui:aria-invalid:ring-destructive/20 ui:dark:aria-invalid:ring-destructive/40 ui:aria-invalid:border-destructive ui:cursor-pointer", {
4837
+ variants: {
4838
+ variant: {
4839
+ default: "ui:bg-primary ui:text-primary-foreground ui:shadow-xs ui:hover:bg-primary/90 ui:select-none",
4840
+ destructive: "ui:bg-destructive ui:text-white ui:shadow-xs ui:hover:bg-destructive/90 ui:focus-visible:ring-destructive/20 ui:dark:focus-visible:ring-destructive/40",
4841
+ outline: "ui:border ui:border-input ui:bg-background ui:shadow-xs ui:hover:bg-accent ui:hover:text-accent-foreground",
4842
+ secondary: "ui:bg-secondary ui:text-secondary-foreground ui:shadow-xs ui:hover:bg-secondary/80",
4843
+ ghost: "ui:hover:bg-accent ui:hover:text-accent-foreground",
4844
+ link: "ui:text-primary ui:underline-offset-4 ui:hover:underline"
5034
4845
  },
5035
- setCurrentValue: function(fieldName, value) {
5036
- var currentState = get().getState(fieldName);
5037
- get().setState(fieldName, _object_spread_props(_object_spread({}, currentState), {
5038
- currentValue: value
5039
- }));
4846
+ size: {
4847
+ default: "ui:h-9 ui:px-4 ui:py-2 ui:has-[>svg]:px-3",
4848
+ sm: "ui:h-8 ui:rounded-sm ui:gap-1.5 ui:px-3 ui:has-[>svg]:px-2.5",
4849
+ lg: "ui:h-10 ui:rounded-sm ui:px-6 ui:has-[>svg]:px-4",
4850
+ icon: "ui:size-9"
5040
4851
  }
5041
- };
4852
+ },
4853
+ defaultVariants: {
4854
+ variant: "default",
4855
+ size: "default"
4856
+ }
5042
4857
  });
5043
- // src/hooks/useExpressionMode.ts
5044
- function useExpressionMode(fieldName) {
5045
- var store = useExpressionModeStore();
5046
- var state = store.getState(fieldName);
5047
- var switchToValue = React4.useCallback(function() {
5048
- store.switchToValue(fieldName);
5049
- }, [
5050
- store,
5051
- fieldName
5052
- ]);
5053
- var switchToExpression = React4.useCallback(function() {
5054
- store.switchToExpression(fieldName);
5055
- }, [
5056
- store,
5057
- fieldName
5058
- ]);
5059
- var switchToEditor = React4.useCallback(function() {
5060
- store.switchToEditor(fieldName);
5061
- }, [
5062
- store,
5063
- fieldName
5064
- ]);
5065
- var clear = React4.useCallback(function() {
5066
- store.clear(fieldName);
5067
- }, [
5068
- store,
5069
- fieldName
5070
- ]);
5071
- var setExpression = React4.useCallback(function(expr) {
5072
- store.setExpression(fieldName, expr);
5073
- }, [
5074
- store,
5075
- fieldName
5076
- ]);
5077
- var setEditing = React4.useCallback(function(editing) {
5078
- store.setEditing(fieldName, editing);
5079
- }, [
5080
- store,
5081
- fieldName
5082
- ]);
5083
- var setCurrentValue = React4.useCallback(function(value) {
5084
- store.setCurrentValue(fieldName, value);
5085
- }, [
5086
- store,
5087
- fieldName
5088
- ]);
5089
- var setFullScreen = React4.useCallback(function(isFullScreen) {
5090
- store.setFullScreen(fieldName, isFullScreen);
5091
- }, [
5092
- store,
5093
- fieldName
4858
+ function Button(_param) {
4859
+ var className = _param.className, variant = _param.variant, size = _param.size, _param_asChild = _param.asChild, asChild = _param_asChild === void 0 ? false : _param_asChild, props = _object_without_properties(_param, [
4860
+ "className",
4861
+ "variant",
4862
+ "size",
4863
+ "asChild"
5094
4864
  ]);
5095
- return {
5096
- current: state.mode,
5097
- switchToValue: switchToValue,
5098
- switchToExpression: switchToExpression,
5099
- switchToEditor: switchToEditor,
5100
- clear: clear,
5101
- isExpressionMode: state.mode === "expression",
5102
- isEditorMode: state.isEditing,
5103
- expression: state.expression,
5104
- setExpression: setExpression,
5105
- isEditing: state.isEditing,
5106
- setEditing: setEditing,
5107
- currentValue: state.currentValue,
5108
- setCurrentValue: setCurrentValue,
5109
- isFullScreen: state.isFullScreen,
5110
- setFullScreen: setFullScreen
5111
- };
5112
- }
5113
- function inferTypeFromMonaco(editor, monaco, expression) {
5114
- var logPrefix = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "\uD83D\uDD37";
5115
- return _async_to_generator(function() {
5116
- var currentModel, markers, hasErrors, wrappedCode, tempModel, worker, client, exprIndex, position, quickInfo, extractedType, foundColon, typeParts, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, part, prevPart, typeString, error;
5117
- return _ts_generator(this, function(_state) {
5118
- switch(_state.label){
5119
- case 0:
5120
- if (!expression.trim()) {
5121
- console.log("".concat(logPrefix, " Type inference skipped - no expression"));
5122
- return [
5123
- 2,
5124
- null
5125
- ];
5126
- }
5127
- if (!editor.hasTextFocus()) {
5128
- console.log("".concat(logPrefix, " Skipping type inference - editor does not have focus"));
5129
- return [
5130
- 2,
5131
- null
5132
- ];
5133
- }
5134
- console.log("".concat(logPrefix, " Running type inference, expression:"), expression);
5135
- _state.label = 1;
5136
- case 1:
5137
- _state.trys.push([
5138
- 1,
5139
- 5,
5140
- ,
5141
- 6
5142
- ]);
5143
- currentModel = editor.getModel();
5144
- if (currentModel) {
5145
- markers = monaco.editor.getModelMarkers({
5146
- resource: currentModel.uri
5147
- });
5148
- hasErrors = markers.some(function(marker) {
5149
- return marker.severity === monaco.MarkerSeverity.Error;
5150
- });
5151
- if (hasErrors) {
5152
- console.log("".concat(logPrefix, " Type inference skipped - expression has validation errors"));
5153
- return [
5154
- 2,
5155
- "error"
5156
- ];
5157
- }
5158
- }
5159
- wrappedCode = "const __expr__ = (".concat(expression, ");");
5160
- tempModel = monaco.editor.createModel(wrappedCode, "typescript");
5161
- return [
5162
- 4,
5163
- monaco.languages.typescript.getTypeScriptWorker()
5164
- ];
5165
- case 2:
5166
- worker = _state.sent();
5167
- return [
5168
- 4,
5169
- worker(tempModel.uri)
5170
- ];
5171
- case 3:
5172
- client = _state.sent();
5173
- exprIndex = wrappedCode.indexOf("__expr__");
5174
- position = tempModel.getPositionAt(exprIndex);
5175
- return [
5176
- 4,
5177
- client.getQuickInfoAtPosition(tempModel.uri.toString(), tempModel.getOffsetAt(position))
5178
- ];
5179
- case 4:
5180
- quickInfo = _state.sent();
5181
- console.log("".concat(logPrefix, " QuickInfo response:"), quickInfo);
5182
- extractedType = null;
5183
- if (quickInfo && quickInfo.displayParts) {
5184
- foundColon = false;
5185
- typeParts = [];
5186
- _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
5187
- try {
5188
- for(_iterator = quickInfo.displayParts[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
5189
- part = _step.value;
5190
- if (foundColon) typeParts.push(part);
5191
- if (part.kind === "punctuation" && part.text === ":" && !foundColon) {
5192
- prevPart = quickInfo.displayParts[quickInfo.displayParts.indexOf(part) - 1];
5193
- if (prevPart && (prevPart.kind === "localName" || prevPart.kind === "parameterName")) {
5194
- foundColon = true;
5195
- }
5196
- }
5197
- }
5198
- } catch (err) {
5199
- _didIteratorError = true;
5200
- _iteratorError = err;
5201
- } finally{
5202
- try {
5203
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5204
- _iterator.return();
5205
- }
5206
- } finally{
5207
- if (_didIteratorError) {
5208
- throw _iteratorError;
5209
- }
5210
- }
5211
- }
5212
- if (typeParts.length > 0) {
5213
- typeString = typeParts.map(function(p) {
5214
- return p.text;
5215
- }).join("").trim();
5216
- console.log("".concat(logPrefix, " Extracted type:"), typeString);
5217
- if (typeString && typeString !== "any") {
5218
- extractedType = typeString;
5219
- }
5220
- }
5221
- }
5222
- tempModel.dispose();
5223
- return [
5224
- 2,
5225
- extractedType
5226
- ];
5227
- case 5:
5228
- error = _state.sent();
5229
- console.warn("".concat(logPrefix, " Type inference failed:"), error);
5230
- return [
5231
- 2,
5232
- null
5233
- ];
5234
- case 6:
5235
- return [
5236
- 2
5237
- ];
5238
- }
5239
- });
5240
- })();
4865
+ var Comp = asChild ? reactSlot.Slot : "button";
4866
+ return /* @__PURE__ */ React4__namespace.createElement(Comp, _object_spread({
4867
+ "data-slot": "button",
4868
+ className: cn(buttonVariants({
4869
+ variant: variant,
4870
+ size: size,
4871
+ className: className
4872
+ }))
4873
+ }, props));
5241
4874
  }
5242
- var InlineEditorOptions = {
5243
- fontSize: "14px",
5244
- // md:text-sm
5245
- fontWeight: "normal",
5246
- wordWrap: "off",
5247
- lineNumbers: "off",
5248
- lineNumbersMinChars: 0,
5249
- overviewRulerLanes: 0,
5250
- overviewRulerBorder: false,
5251
- hideCursorInOverviewRuler: true,
5252
- lineDecorationsWidth: 0,
5253
- glyphMargin: false,
5254
- folding: false,
5255
- scrollBeyondLastColumn: 0,
5256
- scrollbar: {
5257
- horizontal: "hidden",
5258
- vertical: "hidden",
5259
- alwaysConsumeMouseWheel: false
4875
+ // src/components/fields/index.tsx
4876
+ var fields_exports = {};
4877
+ __export(fields_exports, {
4878
+ InferredTypesContext: function() {
4879
+ return InferredTypesContext;
5260
4880
  },
5261
- find: {
5262
- addExtraSpaceOnTop: false,
5263
- autoFindInSelection: "never",
5264
- seedSearchStringFromSelection: false
4881
+ Input: function() {
4882
+ return Input;
5265
4883
  },
5266
- minimap: {
5267
- enabled: false
4884
+ NestedFieldProvider: function() {
4885
+ return NestedFieldProvider;
5268
4886
  },
5269
- wordBasedSuggestions: true,
5270
- // Enable for better UX
5271
- links: false,
5272
- occurrencesHighlight: false,
5273
- cursorStyle: "line",
5274
- // Match input cursor
5275
- renderLineHighlight: "none",
5276
- contextmenu: false,
5277
- roundedSelection: false,
5278
- hover: {
5279
- delay: 300
4887
+ OPERATORS_BY_TYPE: function() {
4888
+ return OPERATORS_BY_TYPE;
5280
4889
  },
5281
- acceptSuggestionOnEnter: "on",
5282
- automaticLayout: true,
5283
- fixedOverflowWidgets: true,
5284
- // Match Input component styling
5285
- padding: {
5286
- top: 4,
5287
- bottom: 4
4890
+ Select: function() {
4891
+ return Select;
5288
4892
  },
5289
- // py-1 equivalent
5290
- fontFamily: "inherit",
5291
- // Use system font
5292
- letterSpacing: "normal",
5293
- lineHeight: "normal"
5294
- };
5295
- var FullPanelEditorOptions = {
5296
- fontSize: "14px",
5297
- fontWeight: "normal",
5298
- wordWrap: "on",
5299
- lineNumbers: "on",
5300
- lineNumbersMinChars: 3,
5301
- overviewRulerLanes: 3,
5302
- overviewRulerBorder: true,
5303
- hideCursorInOverviewRuler: false,
5304
- lineDecorationsWidth: 10,
5305
- glyphMargin: true,
5306
- folding: true,
5307
- scrollBeyondLastColumn: 5,
5308
- scrollbar: {
5309
- horizontal: "auto",
5310
- vertical: "auto",
5311
- alwaysConsumeMouseWheel: false
4893
+ TemplateFieldProvider: function() {
4894
+ return TemplateFieldProvider;
5312
4895
  },
5313
- find: {
5314
- addExtraSpaceOnTop: false,
5315
- autoFindInSelection: "never",
5316
- seedSearchStringFromSelection: false
4896
+ getOperatorsForType: function() {
4897
+ return getOperatorsForType;
5317
4898
  },
5318
- minimap: {
5319
- enabled: true
4899
+ parseInferSyntax: function() {
4900
+ return parseInferSyntax;
5320
4901
  },
5321
- wordBasedSuggestions: true,
5322
- links: true,
5323
- occurrencesHighlight: true,
5324
- cursorStyle: "line",
5325
- renderLineHighlight: "line",
5326
- contextmenu: true,
5327
- roundedSelection: true,
5328
- hover: {
5329
- delay: 300
4902
+ useFieldPath: function() {
4903
+ return useFieldPath;
5330
4904
  },
5331
- // IMPORTANT: Don't accept suggestions on Enter - let Enter create new lines
5332
- acceptSuggestionOnEnter: "off",
5333
- automaticLayout: true,
5334
- fixedOverflowWidgets: true,
5335
- readOnly: false,
5336
- // Explicitly allow editing
5337
- domReadOnly: false
5338
- };
5339
- function InlineExpressionEditor(param) {
5340
- var value = param.value, onChange = param.onChange, onBlur = param.onBlur, onEnter = param.onEnter, onTypeInferred = param.onTypeInferred, onValidationChange = param.onValidationChange, _param_context = param.context, context = _param_context === void 0 ? {} : _param_context, className = param.className, _param_placeholder = param.placeholder, placeholder = _param_placeholder === void 0 ? "Enter expression..." : _param_placeholder;
5341
- var editorRef = React4.useRef(null);
5342
- var monacoRef = React4.useRef(null);
5343
- var typeInferenceTimeoutRef = React4.useRef(null);
5344
- var handleEditorWillMount = function(monaco) {
5345
- monacoRef.current = monaco;
5346
- var contextKeys = Object.keys(context);
5347
- if (contextKeys.length > 0) {
5348
- monaco.languages.typescript.javascriptDefaults.addExtraLib("\n declare const ".concat(contextKeys.join(", "), ": any;\n "), "context.d.ts");
5349
- }
5350
- };
5351
- var handleEditorDidMount = function(editor, monaco) {
5352
- editorRef.current = editor;
5353
- editor.updateOptions(InlineEditorOptions);
5354
- console.log("\uD83D\uDD37 Inline editor mounted!");
5355
- editor.getDomNode();
5356
- var findCommand = editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_F, function() {});
5357
- var enterKeyDisposable = editor.onKeyDown(function(e) {
5358
- if (e.keyCode === monaco.KeyCode.Enter) {
5359
- var _editor__contentWidgets, _contextKeyService_getContextKeyValue;
5360
- if (!editor.hasTextFocus()) {
5361
- console.log("\uD83D\uDD37 Enter keydown but inline editor does NOT have focus - allowing default");
5362
- return;
5363
- }
5364
- if (e.shiftKey) {
5365
- console.log("\uD83D\uDD37 Shift+Enter in INLINE editor - switching to full-screen");
5366
- e.preventDefault();
5367
- e.stopPropagation();
5368
- if (onEnter) {
5369
- onEnter();
5370
- }
5371
- return;
5372
- }
5373
- var suggestWidget = (_editor__contentWidgets = editor._contentWidgets) === null || _editor__contentWidgets === void 0 ? void 0 : _editor__contentWidgets["editor.widget.suggestWidget"];
5374
- var isSuggestVisible = (suggestWidget === null || suggestWidget === void 0 ? void 0 : suggestWidget.widget) && !suggestWidget.widget._hidden && suggestWidget.widget.state !== void 0 && suggestWidget.widget.state !== 0;
5375
- var contextKeyService = editor._contextKeyService;
5376
- var suggestWidgetVisible = contextKeyService === null || contextKeyService === void 0 ? void 0 : (_contextKeyService_getContextKeyValue = contextKeyService.getContextKeyValue) === null || _contextKeyService_getContextKeyValue === void 0 ? void 0 : _contextKeyService_getContextKeyValue.call(contextKeyService, "suggestWidgetVisible");
5377
- if (isSuggestVisible || suggestWidgetVisible) {
5378
- console.log("\uD83D\uDD37 Enter in INLINE editor - accepting autocomplete");
5379
- e.preventDefault();
5380
- e.stopPropagation();
5381
- editor.trigger("", "acceptSelectedSuggestion");
5382
- } else {
5383
- console.log("\uD83D\uDD37 Enter in INLINE editor - blurring (finishing edit)");
5384
- e.preventDefault();
5385
- e.stopPropagation();
5386
- onBlur === null || onBlur === void 0 ? void 0 : onBlur({});
5387
- }
5388
- }
5389
- });
5390
- editor.onDidPaste(function(e) {
5391
- if (e.endLineNumber <= 1) {
5392
- return;
5393
- }
5394
- var newContent = "";
5395
- var textModel = editor.getModel();
5396
- var lineCount = textModel.getLineCount();
5397
- for(var i = 0; i < lineCount; i += 1){
5398
- newContent += textModel.getLineContent(i + 1);
5399
- }
5400
- textModel.setValue(newContent);
5401
- editor.setPosition({
5402
- column: newContent.length + 1,
5403
- lineNumber: 1
5404
- });
5405
- });
5406
- editor.onDidBlurEditorText(function(e) {
5407
- var currentValue = editor.getValue();
5408
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(_object_spread_props(_object_spread({}, e), {
5409
- currentValue: currentValue
5410
- }));
5411
- });
5412
- editor.onDidChangeModelContent(function() {
5413
- var model = editor.getModel();
5414
- if (model) {
5415
- if (onValidationChange) {
5416
- var markers = monaco.editor.getModelMarkers({
5417
- resource: model.uri
5418
- });
5419
- var hasErrors = markers.some(function(marker) {
5420
- return marker.severity === monaco.MarkerSeverity.Error;
5421
- });
5422
- onValidationChange(!hasErrors, markers);
5423
- }
5424
- if (onTypeInferred) {
5425
- if (typeInferenceTimeoutRef.current) {
5426
- clearTimeout(typeInferenceTimeoutRef.current);
5427
- }
5428
- console.log("\uD83D\uDD37 Content changed - debouncing type inference");
5429
- typeInferenceTimeoutRef.current = setTimeout(function() {
5430
- return _async_to_generator(function() {
5431
- var expressionToAnalyze, inferredType;
5432
- return _ts_generator(this, function(_state) {
5433
- switch(_state.label){
5434
- case 0:
5435
- expressionToAnalyze = model.getValue();
5436
- return [
5437
- 4,
5438
- inferTypeFromMonaco(editor, monaco, expressionToAnalyze, "\uD83D\uDD37")
5439
- ];
5440
- case 1:
5441
- inferredType = _state.sent();
5442
- if (inferredType) {
5443
- onTypeInferred(inferredType);
5444
- }
5445
- return [
5446
- 2
5447
- ];
5448
- }
5449
- });
5450
- })();
5451
- }, 200);
5452
- }
5453
- }
5454
- });
5455
- var markerChangeDisposable = monaco.editor.onDidChangeMarkers(function(uris) {
5456
- var model = editor.getModel();
5457
- if (!model || !onTypeInferred) return;
5458
- var isOurModel = uris.some(function(uri) {
5459
- return uri.toString() === model.uri.toString();
5460
- });
5461
- if (!isOurModel) return;
5462
- var markers = monaco.editor.getModelMarkers({
5463
- resource: model.uri
5464
- });
5465
- var hasErrors = markers.some(function(marker) {
5466
- return marker.severity === monaco.MarkerSeverity.Error;
5467
- });
5468
- console.log("\uD83D\uDD37 Monaco markers changed - hasErrors:", hasErrors);
5469
- if (hasErrors) {
5470
- if (typeInferenceTimeoutRef.current) {
5471
- clearTimeout(typeInferenceTimeoutRef.current);
5472
- typeInferenceTimeoutRef.current = null;
5473
- }
5474
- console.log("\uD83D\uDD37 ERROR detected - immediately setting type to error");
5475
- onTypeInferred("error");
5476
- } else {
5477
- if (typeInferenceTimeoutRef.current) {
5478
- clearTimeout(typeInferenceTimeoutRef.current);
5479
- }
5480
- console.log("\uD83D\uDD37 Errors cleared - triggering type inference");
5481
- typeInferenceTimeoutRef.current = setTimeout(function() {
5482
- return _async_to_generator(function() {
5483
- var expressionToAnalyze, inferredType;
5484
- return _ts_generator(this, function(_state) {
5485
- switch(_state.label){
5486
- case 0:
5487
- expressionToAnalyze = model.getValue();
5488
- return [
5489
- 4,
5490
- inferTypeFromMonaco(editor, monaco, expressionToAnalyze, "\uD83D\uDD37")
5491
- ];
5492
- case 1:
5493
- inferredType = _state.sent();
5494
- if (inferredType) {
5495
- onTypeInferred(inferredType);
5496
- }
5497
- return [
5498
- 2
5499
- ];
5500
- }
5501
- });
5502
- })();
5503
- }, 100);
5504
- }
5505
- });
5506
- editor.addCommand(monaco.KeyCode.F1, function() {});
5507
- var cursorDisposable = editor.onDidChangeCursorPosition(function() {
5508
- return _async_to_generator(function() {
5509
- var model, expressionToAnalyze, inferredType;
5510
- return _ts_generator(this, function(_state) {
5511
- switch(_state.label){
5512
- case 0:
5513
- if (!(onTypeInferred && editor.hasTextFocus())) return [
5514
- 3,
5515
- 2
5516
- ];
5517
- model = editor.getModel();
5518
- if (!(model && model.getValue().trim())) return [
5519
- 3,
5520
- 2
5521
- ];
5522
- if (typeInferenceTimeoutRef.current) {
5523
- clearTimeout(typeInferenceTimeoutRef.current);
5524
- }
5525
- expressionToAnalyze = model.getValue();
5526
- return [
5527
- 4,
5528
- inferTypeFromMonaco(editor, monaco, expressionToAnalyze, "\uD83D\uDD37")
5529
- ];
5530
- case 1:
5531
- inferredType = _state.sent();
5532
- if (inferredType) {
5533
- onTypeInferred(inferredType);
5534
- }
5535
- _state.label = 2;
5536
- case 2:
5537
- return [
5538
- 2
5539
- ];
5540
- }
5541
- });
5542
- })();
5543
- });
5544
- editor.setPosition({
5545
- lineNumber: 1,
5546
- column: 999999
5547
- });
5548
- window.requestAnimationFrame(function() {
5549
- editor.focus();
5550
- setTimeout(function() {
5551
- return _async_to_generator(function() {
5552
- var model, markers, hasErrors, expressionToAnalyze, inferredType;
5553
- return _ts_generator(this, function(_state) {
5554
- switch(_state.label){
5555
- case 0:
5556
- model = editor.getModel();
5557
- if (!(onTypeInferred && model && model.getValue())) return [
5558
- 3,
5559
- 3
5560
- ];
5561
- console.log("\uD83D\uDD37 Triggering initial type inference for inline editor");
5562
- markers = monaco.editor.getModelMarkers({
5563
- resource: model.uri
5564
- });
5565
- hasErrors = markers.some(function(marker) {
5566
- return marker.severity === monaco.MarkerSeverity.Error;
5567
- });
5568
- if (!hasErrors) return [
5569
- 3,
5570
- 1
5571
- ];
5572
- onTypeInferred("error");
5573
- return [
5574
- 3,
5575
- 3
5576
- ];
5577
- case 1:
5578
- expressionToAnalyze = model.getValue();
5579
- return [
5580
- 4,
5581
- inferTypeFromMonaco(editor, monaco, expressionToAnalyze, "\uD83D\uDD37")
5582
- ];
5583
- case 2:
5584
- inferredType = _state.sent();
5585
- if (inferredType) {
5586
- onTypeInferred(inferredType);
5587
- }
5588
- _state.label = 3;
5589
- case 3:
5590
- return [
5591
- 2
5592
- ];
5593
- }
5594
- });
5595
- })();
5596
- }, 100);
5597
- });
5598
- editorRef.current._inlineDisposables = {
5599
- enterKeyDisposable: enterKeyDisposable,
5600
- findCommand: findCommand,
5601
- markerChangeDisposable: markerChangeDisposable,
5602
- cursorDisposable: cursorDisposable
5603
- };
5604
- };
5605
- React4.useEffect(function() {
5606
- return function() {
5607
- if (editorRef.current) {
5608
- console.log("\uD83D\uDD37 Inline editor unmounting - cleaning up");
5609
- if (typeInferenceTimeoutRef.current) {
5610
- clearTimeout(typeInferenceTimeoutRef.current);
5611
- }
5612
- if (editorRef.current._inlineDisposables) {
5613
- var _disposables_enterKeyDisposable_dispose, _disposables_enterKeyDisposable, _disposables_findCommand_dispose, _disposables_findCommand, _disposables_markerChangeDisposable_dispose, _disposables_markerChangeDisposable, _disposables_cursorDisposable_dispose, _disposables_cursorDisposable;
5614
- var disposables = editorRef.current._inlineDisposables;
5615
- (_disposables_enterKeyDisposable = disposables.enterKeyDisposable) === null || _disposables_enterKeyDisposable === void 0 ? void 0 : (_disposables_enterKeyDisposable_dispose = _disposables_enterKeyDisposable.dispose) === null || _disposables_enterKeyDisposable_dispose === void 0 ? void 0 : _disposables_enterKeyDisposable_dispose.call(_disposables_enterKeyDisposable);
5616
- (_disposables_findCommand = disposables.findCommand) === null || _disposables_findCommand === void 0 ? void 0 : (_disposables_findCommand_dispose = _disposables_findCommand.dispose) === null || _disposables_findCommand_dispose === void 0 ? void 0 : _disposables_findCommand_dispose.call(_disposables_findCommand);
5617
- (_disposables_markerChangeDisposable = disposables.markerChangeDisposable) === null || _disposables_markerChangeDisposable === void 0 ? void 0 : (_disposables_markerChangeDisposable_dispose = _disposables_markerChangeDisposable.dispose) === null || _disposables_markerChangeDisposable_dispose === void 0 ? void 0 : _disposables_markerChangeDisposable_dispose.call(_disposables_markerChangeDisposable);
5618
- (_disposables_cursorDisposable = disposables.cursorDisposable) === null || _disposables_cursorDisposable === void 0 ? void 0 : (_disposables_cursorDisposable_dispose = _disposables_cursorDisposable.dispose) === null || _disposables_cursorDisposable_dispose === void 0 ? void 0 : _disposables_cursorDisposable_dispose.call(_disposables_cursorDisposable);
5619
- }
5620
- editorRef.current = null;
5621
- }
5622
- };
5623
- }, []);
5624
- var handleEditorChange = function(newValue) {
5625
- onChange(newValue || "");
5626
- };
5627
- return /* @__PURE__ */ React4__namespace.default.createElement("div", {
5628
- className: cn("uii:relative uii:flex-1", className)
5629
- }, /* @__PURE__ */ React4__namespace.default.createElement(react.Editor, {
5630
- theme: "vs-dark",
5631
- height: "26px",
5632
- language: "typescript",
5633
- value: value,
5634
- onChange: handleEditorChange,
5635
- onMount: handleEditorDidMount,
5636
- beforeMount: handleEditorWillMount,
5637
- width: "100%",
5638
- loading: /* @__PURE__ */ React4__namespace.default.createElement(React4__namespace.default.Fragment, null, /* @__PURE__ */ React4__namespace.default.createElement(reactFontawesome.FontAwesomeIcon, {
5639
- icon: proRegularSvgIcons.faSpinner,
5640
- className: "uii:animate-spin"
5641
- })),
5642
- options: InlineEditorOptions,
5643
- className: "uii:-ml-[4px] uii:-mt-[1px] inline-editor"
5644
- }), !value && /* @__PURE__ */ React4__namespace.default.createElement("div", {
5645
- className: "uii:absolute uii:inset-0 uii:flex uii:items-center uii:pointer-events-none uii:text-muted-foreground uii:text-sm"
5646
- }, placeholder));
5647
- }
5648
- function FullPanelExpressionEditor(param) {
5649
- var value = param.value, onChange = param.onChange, onClose = param.onClose, onBlur = param.onBlur, onTypeInferred = param.onTypeInferred, _param_context = param.context, context = _param_context === void 0 ? {} : _param_context, className = param.className, _param_placeholder = param.placeholder, placeholder = _param_placeholder === void 0 ? "Enter expression..." : _param_placeholder;
5650
- var editorRef = React4.useRef(null);
5651
- var monacoRef = React4.useRef(null);
5652
- var typeInferenceTimeoutRef = React4.useRef(null);
5653
- var handleEditorWillMount = function(monaco) {
5654
- monacoRef.current = monaco;
5655
- var contextKeys = Object.keys(context);
5656
- if (contextKeys.length > 0) {
5657
- monaco.languages.typescript.javascriptDefaults.addExtraLib("\n declare const ".concat(contextKeys.join(", "), ": any;\n "), "context.d.ts");
5658
- }
5659
- };
5660
- var handleFPEditorDidMount = function(editor, monaco) {
5661
- editorRef.current = editor;
5662
- editor.updateOptions(FullPanelEditorOptions);
5663
- console.log("\uD83D\uDFE6 FULL-SCREEN panel editor mounted!");
5664
- console.log("Full-screen editor is read-only?", editor.getOption(monaco.editor.EditorOption.readOnly));
5665
- var escapeKeyDisposable = editor.onKeyDown(function(e) {
5666
- if (e.keyCode === monaco.KeyCode.Escape) {
5667
- console.log("\uD83D\uDFE6 Escape pressed in FULL-SCREEN editor - closing");
5668
- e.preventDefault();
5669
- e.stopPropagation();
5670
- onClose();
5671
- }
5672
- if (e.keyCode === monaco.KeyCode.Enter) {
5673
- var _editor__contentWidgets, _contextKeyService_getContextKeyValue;
5674
- var suggestWidget = (_editor__contentWidgets = editor._contentWidgets) === null || _editor__contentWidgets === void 0 ? void 0 : _editor__contentWidgets["editor.widget.suggestWidget"];
5675
- var isSuggestVisible = (suggestWidget === null || suggestWidget === void 0 ? void 0 : suggestWidget.widget) && !suggestWidget.widget._hidden && suggestWidget.widget.state !== void 0 && suggestWidget.widget.state !== 0;
5676
- var contextKeyService = editor._contextKeyService;
5677
- var suggestWidgetVisible = contextKeyService === null || contextKeyService === void 0 ? void 0 : (_contextKeyService_getContextKeyValue = contextKeyService.getContextKeyValue) === null || _contextKeyService_getContextKeyValue === void 0 ? void 0 : _contextKeyService_getContextKeyValue.call(contextKeyService, "suggestWidgetVisible");
5678
- if (isSuggestVisible || suggestWidgetVisible) {
5679
- console.log("\uD83D\uDFE6 Enter in FULL-SCREEN - accepting autocomplete");
5680
- e.preventDefault();
5681
- e.stopPropagation();
5682
- editor.trigger("", "acceptSelectedSuggestion");
5683
- } else {
5684
- console.log("\uD83D\uDFE6 Enter in FULL-SCREEN - allowing newline (default behavior)");
5685
- }
5686
- }
5687
- });
5688
- var changeCount = 0;
5689
- var changeDisposable = editor.onDidChangeModelContent(function(e) {
5690
- var _editor_getModel;
5691
- changeCount++;
5692
- var newValue = editor.getValue();
5693
- console.log("\uD83D\uDFE6 FULL-SCREEN content changed (".concat(changeCount, "):"), newValue);
5694
- console.log("\uD83D\uDFE6 Line count: ".concat((_editor_getModel = editor.getModel()) === null || _editor_getModel === void 0 ? void 0 : _editor_getModel.getLineCount()));
5695
- if (onTypeInferred) {
5696
- if (typeInferenceTimeoutRef.current) {
5697
- clearTimeout(typeInferenceTimeoutRef.current);
5698
- }
5699
- console.log("\uD83D\uDFE6 Content changed - debouncing type inference");
5700
- typeInferenceTimeoutRef.current = setTimeout(function() {
5701
- return _async_to_generator(function() {
5702
- var expressionToAnalyze, inferredType;
5703
- return _ts_generator(this, function(_state) {
5704
- switch(_state.label){
5705
- case 0:
5706
- expressionToAnalyze = newValue;
5707
- return [
5708
- 4,
5709
- inferTypeFromMonaco(editor, monaco, expressionToAnalyze, "\uD83D\uDFE6")
5710
- ];
5711
- case 1:
5712
- inferredType = _state.sent();
5713
- if (inferredType) {
5714
- onTypeInferred(inferredType);
5715
- }
5716
- return [
5717
- 2
5718
- ];
5719
- }
5720
- });
5721
- })();
5722
- }, 200);
5723
- }
5724
- });
5725
- var markerChangeDisposable = monaco.editor.onDidChangeMarkers(function(uris) {
5726
- var model2 = editor.getModel();
5727
- if (!model2 || !onTypeInferred) return;
5728
- var isOurModel = uris.some(function(uri) {
5729
- return uri.toString() === model2.uri.toString();
5730
- });
5731
- if (!isOurModel) return;
5732
- var markers = monaco.editor.getModelMarkers({
5733
- resource: model2.uri
5734
- });
5735
- var hasErrors = markers.some(function(marker) {
5736
- return marker.severity === monaco.MarkerSeverity.Error;
5737
- });
5738
- console.log("\uD83D\uDFE6 Monaco markers changed - hasErrors:", hasErrors);
5739
- if (hasErrors) {
5740
- if (typeInferenceTimeoutRef.current) {
5741
- clearTimeout(typeInferenceTimeoutRef.current);
5742
- typeInferenceTimeoutRef.current = null;
5743
- }
5744
- console.log("\uD83D\uDFE6 ERROR detected - immediately setting type to error");
5745
- onTypeInferred("error");
5746
- } else {
5747
- if (typeInferenceTimeoutRef.current) {
5748
- clearTimeout(typeInferenceTimeoutRef.current);
5749
- }
5750
- console.log("\uD83D\uDFE6 Errors cleared - triggering type inference");
5751
- typeInferenceTimeoutRef.current = setTimeout(function() {
5752
- return _async_to_generator(function() {
5753
- var expressionToAnalyze, inferredType;
5754
- return _ts_generator(this, function(_state) {
5755
- switch(_state.label){
5756
- case 0:
5757
- expressionToAnalyze = model2.getValue();
5758
- return [
5759
- 4,
5760
- inferTypeFromMonaco(editor, monaco, expressionToAnalyze, "\uD83D\uDFE6")
5761
- ];
5762
- case 1:
5763
- inferredType = _state.sent();
5764
- if (inferredType) {
5765
- onTypeInferred(inferredType);
5766
- }
5767
- return [
5768
- 2
5769
- ];
5770
- }
5771
- });
5772
- })();
5773
- }, 100);
5774
- }
5775
- });
5776
- editor.onDidBlurEditorText(function(e) {
5777
- var currentValue = editor.getValue();
5778
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(_object_spread_props(_object_spread({}, e), {
5779
- currentValue: currentValue
5780
- }));
5781
- });
5782
- var model = editor.getModel();
5783
- if (model) {
5784
- var lineCount = model.getLineCount();
5785
- var lastLineLength = model.getLineLength(lineCount);
5786
- editor.setPosition({
5787
- lineNumber: lineCount,
5788
- column: lastLineLength + 1
5789
- });
5790
- }
5791
- editor.focus();
5792
- setTimeout(function() {
5793
- return _async_to_generator(function() {
5794
- var markers, hasErrors, expressionToAnalyze, inferredType;
5795
- return _ts_generator(this, function(_state) {
5796
- switch(_state.label){
5797
- case 0:
5798
- if (!(onTypeInferred && model)) return [
5799
- 3,
5800
- 3
5801
- ];
5802
- console.log("\uD83D\uDFE6 Triggering initial type inference for full-screen editor");
5803
- markers = monaco.editor.getModelMarkers({
5804
- resource: model.uri
5805
- });
5806
- hasErrors = markers.some(function(marker) {
5807
- return marker.severity === monaco.MarkerSeverity.Error;
5808
- });
5809
- if (!hasErrors) return [
5810
- 3,
5811
- 1
5812
- ];
5813
- console.log("\uD83D\uDFE6 Initial load has error - setting type to error");
5814
- onTypeInferred("error");
5815
- return [
5816
- 3,
5817
- 3
5818
- ];
5819
- case 1:
5820
- expressionToAnalyze = model.getValue();
5821
- return [
5822
- 4,
5823
- inferTypeFromMonaco(editor, monaco, expressionToAnalyze, "\uD83D\uDFE6")
5824
- ];
5825
- case 2:
5826
- inferredType = _state.sent();
5827
- if (inferredType) {
5828
- onTypeInferred(inferredType);
5829
- }
5830
- _state.label = 3;
5831
- case 3:
5832
- return [
5833
- 2
5834
- ];
5835
- }
5836
- });
5837
- })();
5838
- }, 100);
5839
- var cursorDisposable = editor.onDidChangeCursorPosition(function() {
5840
- return _async_to_generator(function() {
5841
- var model2, expressionToAnalyze, inferredType;
5842
- return _ts_generator(this, function(_state) {
5843
- switch(_state.label){
5844
- case 0:
5845
- if (!(onTypeInferred && editor.hasTextFocus())) return [
5846
- 3,
5847
- 2
5848
- ];
5849
- model2 = editor.getModel();
5850
- if (!(model2 && model2.getValue().trim())) return [
5851
- 3,
5852
- 2
5853
- ];
5854
- if (typeInferenceTimeoutRef.current) {
5855
- clearTimeout(typeInferenceTimeoutRef.current);
5856
- }
5857
- expressionToAnalyze = model2.getValue();
5858
- return [
5859
- 4,
5860
- inferTypeFromMonaco(editor, monaco, expressionToAnalyze, "\uD83D\uDFE6")
5861
- ];
5862
- case 1:
5863
- inferredType = _state.sent();
5864
- if (inferredType) {
5865
- onTypeInferred(inferredType);
5866
- }
5867
- _state.label = 2;
5868
- case 2:
5869
- return [
5870
- 2
5871
- ];
5872
- }
5873
- });
5874
- })();
5875
- });
5876
- editorRef.current._fullScreenDisposables = {
5877
- escapeKeyDisposable: escapeKeyDisposable,
5878
- changeDisposable: changeDisposable,
5879
- markerChangeDisposable: markerChangeDisposable,
5880
- cursorDisposable: cursorDisposable
5881
- };
5882
- };
5883
- React4.useEffect(function() {
5884
- return function() {
5885
- if (editorRef.current) {
5886
- console.log("\uD83D\uDFE6 Full-screen editor unmounting - cleaning up");
5887
- if (typeInferenceTimeoutRef.current) {
5888
- clearTimeout(typeInferenceTimeoutRef.current);
5889
- }
5890
- if (editorRef.current._fullScreenDisposables) {
5891
- var _disposables_escapeKeyDisposable_dispose, _disposables_escapeKeyDisposable, _disposables_changeDisposable_dispose, _disposables_changeDisposable, _disposables_markerChangeDisposable_dispose, _disposables_markerChangeDisposable, _disposables_cursorDisposable_dispose, _disposables_cursorDisposable;
5892
- var disposables = editorRef.current._fullScreenDisposables;
5893
- (_disposables_escapeKeyDisposable = disposables.escapeKeyDisposable) === null || _disposables_escapeKeyDisposable === void 0 ? void 0 : (_disposables_escapeKeyDisposable_dispose = _disposables_escapeKeyDisposable.dispose) === null || _disposables_escapeKeyDisposable_dispose === void 0 ? void 0 : _disposables_escapeKeyDisposable_dispose.call(_disposables_escapeKeyDisposable);
5894
- (_disposables_changeDisposable = disposables.changeDisposable) === null || _disposables_changeDisposable === void 0 ? void 0 : (_disposables_changeDisposable_dispose = _disposables_changeDisposable.dispose) === null || _disposables_changeDisposable_dispose === void 0 ? void 0 : _disposables_changeDisposable_dispose.call(_disposables_changeDisposable);
5895
- (_disposables_markerChangeDisposable = disposables.markerChangeDisposable) === null || _disposables_markerChangeDisposable === void 0 ? void 0 : (_disposables_markerChangeDisposable_dispose = _disposables_markerChangeDisposable.dispose) === null || _disposables_markerChangeDisposable_dispose === void 0 ? void 0 : _disposables_markerChangeDisposable_dispose.call(_disposables_markerChangeDisposable);
5896
- (_disposables_cursorDisposable = disposables.cursorDisposable) === null || _disposables_cursorDisposable === void 0 ? void 0 : (_disposables_cursorDisposable_dispose = _disposables_cursorDisposable.dispose) === null || _disposables_cursorDisposable_dispose === void 0 ? void 0 : _disposables_cursorDisposable_dispose.call(_disposables_cursorDisposable);
5897
- }
5898
- editorRef.current = null;
5899
- }
5900
- };
5901
- }, []);
5902
- var handleEditorChange = function(newValue) {
5903
- onChange(newValue || "");
5904
- };
5905
- return /* @__PURE__ */ React4__namespace.default.createElement("div", {
5906
- className: cn("uii:relative uii:border uii:rounded-md uii:bg-background", className)
5907
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
5908
- className: "uii:flex uii:items-center uii:justify-between uii:p-2 uii:border-b uii:bg-muted/50"
5909
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
5910
- className: "uii:text-sm uii:font-medium"
5911
- }, "Expression Editor"), /* @__PURE__ */ React4__namespace.default.createElement("button", {
5912
- type: "button",
5913
- onClick: onClose,
5914
- className: "uii:text-muted-foreground hover:uii:text-foreground uii:p-1 uii:rounded uii:cursor-pointer uii:text-xs"
5915
- }, "\u2715")), /* @__PURE__ */ React4__namespace.default.createElement(react.Editor, {
5916
- height: "300px",
5917
- theme: "vs-dark",
5918
- language: "typescript",
5919
- value: value,
5920
- onChange: handleEditorChange,
5921
- onMount: handleFPEditorDidMount,
5922
- beforeMount: handleEditorWillMount,
5923
- options: FullPanelEditorOptions
5924
- }), !value && /* @__PURE__ */ React4__namespace.default.createElement("div", {
5925
- className: "uii:absolute uii:inset-0 uii:flex uii:items-center uii:justify-center uii:pointer-events-none uii:text-muted-foreground"
5926
- }, placeholder));
5927
- }
5928
- function useASTParser(expression, controlKey) {
5929
- var _React4_useState = _sliced_to_array(React4.useState(null), 2), ast = _React4_useState[0], setAST = _React4_useState[1];
5930
- var _React4_useState1 = _sliced_to_array(React4.useState([]), 2), tokens = _React4_useState1[0], setTokens = _React4_useState1[1];
5931
- var _React4_useState2 = _sliced_to_array(React4.useState([]), 2), dependencies = _React4_useState2[0], setDependencies = _React4_useState2[1];
5932
- var _React4_useState3 = _sliced_to_array(React4.useState(false), 2), isLoading = _React4_useState3[0], setIsLoading = _React4_useState3[1];
5933
- var _React4_useState4 = _sliced_to_array(React4.useState(null), 2), error = _React4_useState4[0], setError = _React4_useState4[1];
5934
- var requestIdRef = React4.useRef(0);
5935
- var messageHandlerRef = React4.useRef(null);
5936
- var controlKeyRef = React4.useRef(controlKey || "default");
5937
- React4.useEffect(function() {
5938
- controlKeyRef.current = controlKey || "default";
5939
- }, [
5940
- controlKey
5941
- ]);
5942
- React4.useEffect(function() {
5943
- if (typeof window === "undefined" || !navigator.serviceWorker) {
5944
- setError("Service worker not available");
5945
- return;
5946
- }
5947
- var handleMessage = function(event) {
5948
- if (event.data.type === "AST_PARSE_RESULT") {
5949
- var _event_data_payload = event.data.payload, id = _event_data_payload.id, controlKey2 = _event_data_payload.controlKey, result = _event_data_payload.result;
5950
- if (id === requestIdRef.current && controlKey2 === controlKeyRef.current) {
5951
- console.log("Service worker AST response:", {
5952
- id: id,
5953
- controlKey: controlKey2,
5954
- result: result
5955
- });
5956
- setAST(result.ast);
5957
- setTokens(result.tokens);
5958
- setDependencies(result.dependencies || []);
5959
- setError(result.error || null);
5960
- setIsLoading(false);
5961
- } else {
5962
- console.log("Ignoring AST response - wrong control:", {
5963
- receivedId: id,
5964
- expectedId: requestIdRef.current,
5965
- receivedKey: controlKey2,
5966
- expectedKey: controlKeyRef.current
5967
- });
5968
- }
5969
- }
5970
- };
5971
- messageHandlerRef.current = handleMessage;
5972
- navigator.serviceWorker.addEventListener("message", handleMessage);
5973
- return function() {
5974
- if (messageHandlerRef.current) {
5975
- navigator.serviceWorker.removeEventListener("message", messageHandlerRef.current);
5976
- }
5977
- };
5978
- }, []);
5979
- React4.useEffect(function() {
5980
- if (!expression.trim()) {
5981
- setAST(null);
5982
- setTokens([]);
5983
- setDependencies([]);
5984
- setError(null);
5985
- setIsLoading(false);
5986
- return;
5987
- }
5988
- if (!navigator.serviceWorker || !navigator.serviceWorker.controller) {
5989
- setError("Service worker not ready");
5990
- setIsLoading(false);
5991
- return;
5992
- }
5993
- setIsLoading(true);
5994
- setError(null);
5995
- requestIdRef.current++;
5996
- console.log("Sending expression to service worker:", {
5997
- expression: expression.trim(),
5998
- controlKey: controlKeyRef.current,
5999
- id: requestIdRef.current
6000
- });
6001
- navigator.serviceWorker.controller.postMessage({
6002
- type: "PARSE_AST",
6003
- payload: {
6004
- expression: expression.trim(),
6005
- id: requestIdRef.current,
6006
- controlKey: controlKeyRef.current
6007
- }
6008
- });
6009
- }, [
6010
- expression
6011
- ]);
6012
- return {
6013
- ast: ast,
6014
- tokens: tokens,
6015
- dependencies: dependencies,
6016
- isLoading: isLoading,
6017
- error: error
6018
- };
6019
- }
6020
- function ASTRenderer(param) {
6021
- var ast = param.ast, key = param.key, className = param.className, _param_variant = param.variant, variant = _param_variant === void 0 ? "inline" : _param_variant, _param_showTokens = param.showTokens, showTokens = _param_showTokens === void 0 ? false : _param_showTokens, _param_tokens = param.tokens, tokens = _param_tokens === void 0 ? [] : _param_tokens;
6022
- var getNodeColor = function(type) {
6023
- switch(type){
6024
- case "StringLiteral":
6025
- return "uii:text-green-600 uii:bg-green-100";
6026
- case "NumericLiteral":
6027
- return "uii:text-purple-600 uii:bg-purple-100";
6028
- case "Identifier":
6029
- return "uii:text-blue-600 uii:bg-blue-100";
6030
- case "Keyword":
6031
- case "Literal":
6032
- return "uii:text-orange-600 uii:bg-orange-100";
6033
- case "BinaryExpression":
6034
- return "uii:text-gray-700 uii:bg-gray-100";
6035
- case "CallExpression":
6036
- return "uii:text-indigo-600 uii:bg-indigo-100";
6037
- case "MemberExpression":
6038
- return "uii:text-cyan-600 uii:bg-cyan-100";
6039
- case "UnaryExpression":
6040
- return "uii:text-pink-600 uii:bg-pink-100";
6041
- case "ParenthesizedExpression":
6042
- return "uii:text-yellow-600 uii:bg-yellow-100";
6043
- default:
6044
- return "uii:text-gray-600 uii:bg-gray-100";
6045
- }
6046
- };
6047
- var renderInlineNode = function(node) {
6048
- var depth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
6049
- if (depth > 2) return null;
6050
- if (node.type === "Identifier") {
6051
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6052
- key: "".concat(node.start, "-").concat(node.end),
6053
- className: "uii:inline-flex uii:items-center uii:mr-1"
6054
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6055
- className: "uii:px-1 uii:py-0.5 uii:rounded uii:text-xs uii:bg-blue-100 uii:text-blue-800 uii:font-mono"
6056
- }, node.name || node.value));
6057
- }
6058
- if (node.type === "StringLiteral" || node.type === "NumericLiteral") {
6059
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6060
- key: "".concat(node.start, "-").concat(node.end),
6061
- className: "uii:inline-flex uii:items-center uii:mr-1"
6062
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6063
- className: "uii:px-1 uii:py-0.5 uii:rounded uii:text-xs uii:bg-green-100 uii:text-green-800 uii:font-mono"
6064
- }, node.value));
6065
- }
6066
- if (node.type === "BinaryExpression") {
6067
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6068
- key: "".concat(node.start, "-").concat(node.end),
6069
- className: "uii:inline-flex uii:items-center uii:mr-1"
6070
- }, node.left && renderInlineNode(node.left, depth + 1), /* @__PURE__ */ React4__namespace.default.createElement("span", {
6071
- className: "uii:px-1 uii:py-0.5 uii:rounded uii:text-xs uii:bg-purple-100 uii:text-purple-800 uii:font-mono uii:mx-1"
6072
- }, node.operator), node.right && renderInlineNode(node.right, depth + 1));
6073
- }
6074
- if (node.type === "CallExpression") {
6075
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6076
- key: "".concat(node.start, "-").concat(node.end),
6077
- className: "uii:inline-flex uii:items-center uii:mr-1"
6078
- }, node.callee && renderInlineNode(node.callee, depth + 1), /* @__PURE__ */ React4__namespace.default.createElement("span", {
6079
- className: "text-xs text-gray-600"
6080
- }, "()"));
6081
- }
6082
- if (node.type === "PropertyAccessExpression") {
6083
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6084
- key: "".concat(node.start, "-").concat(node.end),
6085
- className: "uii:inline-flex uii:items-center uii:mr-1"
6086
- }, node.object && renderInlineNode(node.object, depth + 1), /* @__PURE__ */ React4__namespace.default.createElement("span", {
6087
- className: "text-xs text-gray-600"
6088
- }, "."), node.property && renderInlineNode(node.property, depth + 1));
6089
- }
6090
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6091
- key: "".concat(node.start, "-").concat(node.end),
6092
- className: "uii:inline-flex uii:items-center uii:mr-1"
6093
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6094
- className: "px-1 py-0.5 rounded text-xs bg-gray-100 text-gray-600 font-mono"
6095
- }, node.type));
6096
- };
6097
- var renderTreeNode = function(node) {
6098
- var depth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
6099
- if (depth > 4) return null;
6100
- var indent = " ".repeat(depth);
6101
- return /* @__PURE__ */ React4__namespace.default.createElement("div", {
6102
- key: "".concat(node.start, "-").concat(node.end),
6103
- className: "font-mono text-xs"
6104
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6105
- className: "uii:flex uii:items-start uii:gap-2"
6106
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6107
- className: "uii:text-gray-400"
6108
- }, indent), /* @__PURE__ */ React4__namespace.default.createElement("span", {
6109
- className: cn("uii:px-1 uii:py-0.5 uii:rounded uii:text-xs uii:font-semibold", getNodeColor(node.type))
6110
- }, node.type), node.value && /* @__PURE__ */ React4__namespace.default.createElement("span", {
6111
- className: "uii:text-green-600"
6112
- }, '"', node.value, '"'), node.operator && /* @__PURE__ */ React4__namespace.default.createElement("span", {
6113
- className: "uii:text-purple-600"
6114
- }, node.operator), node.name && /* @__PURE__ */ React4__namespace.default.createElement("span", {
6115
- className: "uii:text-blue-600"
6116
- }, node.name)), node.left && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6117
- className: "uii:ml-2"
6118
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6119
- className: "uii:text-gray-500 uii:text-xs"
6120
- }, "left: "), renderTreeNode(node.left, depth + 1)), node.right && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6121
- className: "uii:ml-2"
6122
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6123
- className: "uii:text-gray-500 uii:text-xs"
6124
- }, "right: "), renderTreeNode(node.right, depth + 1)), node.argument && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6125
- className: "uii:ml-2"
6126
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6127
- className: "uii:text-gray-500 uii:text-xs"
6128
- }, "arg: "), renderTreeNode(node.argument, depth + 1)), node.object && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6129
- className: "uii:ml-2"
6130
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6131
- className: "uii:text-gray-500 uii:text-xs"
6132
- }, "obj: "), renderTreeNode(node.object, depth + 1)), node.property && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6133
- className: "uii:ml-2"
6134
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6135
- className: "uii:text-gray-500 uii:text-xs"
6136
- }, "prop: "), renderTreeNode(node.property, depth + 1)), node.index && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6137
- className: "uii:ml-2"
6138
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6139
- className: "uii:text-gray-500 uii:text-xs"
6140
- }, "idx: "), renderTreeNode(node.index, depth + 1)), !node.left && !node.right && !node.argument && !node.object && !node.property && !node.index && node.children && node.children.length > 0 && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6141
- className: "uii:ml-2"
6142
- }, node.children.slice(0, 3).map(function(child, index) {
6143
- return renderTreeNode(child, depth + 1);
6144
- }), node.children.length > 3 && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6145
- className: "uii:ml-2 uii:text-gray-500 uii:text-xs"
6146
- }, "... and ", node.children.length - 3, " more")));
6147
- };
6148
- var renderTokens = function() {
6149
- if (tokens.length === 0) return null;
6150
- var displayTokens = tokens.slice(0, 10);
6151
- return /* @__PURE__ */ React4__namespace.default.createElement("div", {
6152
- className: "uii:space-y-2"
6153
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6154
- className: "uii:text-sm uii:font-semibold uii:text-gray-700"
6155
- }, "Tokens ", tokens.length > 10 && "(".concat(tokens.length, " total)"), ":"), /* @__PURE__ */ React4__namespace.default.createElement("div", {
6156
- className: "uii:flex uii:flex-wrap uii:gap-1"
6157
- }, displayTokens.map(function(token, index) {
6158
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6159
- key: index,
6160
- className: cn("uii:px-1 uii:py-0.5 uii:rounded uii:text-xs uii:font-mono", token.type.includes("Keyword") && "uii:bg-blue-100 uii:text-blue-800", token.type.includes("Identifier") && "uii:bg-green-100 uii:text-green-800", token.type.includes("String") && "uii:bg-yellow-100 uii:text-yellow-800", token.type.includes("Numeric") && "uii:bg-purple-100 uii:text-purple-800", token.type.includes("Punctuation") && "uii:bg-gray-100 uii:text-gray-800", "uii:bg-gray-100 uii:text-gray-600")
6161
- }, token.value);
6162
- }), tokens.length > 10 && /* @__PURE__ */ React4__namespace.default.createElement("span", {
6163
- className: "uii:px-1 uii:py-0.5 uii:rounded uii:text-xs uii:bg-gray-200 uii:text-gray-600"
6164
- }, "+", tokens.length - 10, " more")));
6165
- };
6166
- if (!ast) {
6167
- return /* @__PURE__ */ React4__namespace.default.createElement("div", {
6168
- className: cn("uii:text-gray-500 uii:text-sm uii:italic", className)
6169
- }, "No AST available");
6170
- }
6171
- if (variant === "inline") {
6172
- return /* @__PURE__ */ React4__namespace.default.createElement("div", {
6173
- className: cn("uii:inline-flex uii:items-center uii:gap-2", className)
6174
- }, renderInlineNode(ast));
6175
- }
6176
- if (variant === "compact") {
6177
- return /* @__PURE__ */ React4__namespace.default.createElement("div", {
6178
- className: cn("uii:space-y-2", className)
6179
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6180
- className: "uii:flex uii:flex-wrap uii:gap-1"
6181
- }, renderInlineNode(ast)), showTokens && renderTokens());
4905
+ useInferredTypes: function() {
4906
+ return useInferredTypes;
4907
+ },
4908
+ useIsInTemplateFieldProvider: function() {
4909
+ return useIsInTemplateFieldProvider;
4910
+ },
4911
+ useTemplateFieldContext: function() {
4912
+ return useTemplateFieldContext;
6182
4913
  }
6183
- return /* @__PURE__ */ React4__namespace.default.createElement("div", {
6184
- className: cn("uii:space-y-3", className)
6185
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6186
- className: "uii:space-y-2"
6187
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6188
- className: "uii:text-sm uii:font-semibold uii:text-gray-700"
6189
- }, "AST Tree:"), /* @__PURE__ */ React4__namespace.default.createElement("div", {
6190
- className: "uii:p-3 uii:border uii:rounded-md uii:bg-gray-50 uii:max-h-64 uii:overflow-auto"
6191
- }, renderTreeNode(ast))), showTokens && renderTokens());
6192
- }
6193
- function ExpressionWrapper(param) {
6194
- var label = param.label, value = param.value, type = param.type, _param_valuesLoading = param.valuesLoading, valuesLoading = _param_valuesLoading === void 0 ? false : _param_valuesLoading, key = param.key, onValueChange = param.onValueChange, onDependenciesChange = param.onDependenciesChange, metadata = param.metadata, children = param.children, fieldName = param.fieldName, _param_expressionContext = param.expressionContext, expressionContext = _param_expressionContext === void 0 ? {} : _param_expressionContext, availableNodes = param.availableNodes, myInterface = param.myInterface, contextTypeDefinitions = param.contextTypeDefinitions, _param_inlineEditor = param.inlineEditor, inlineEditor = _param_inlineEditor === void 0 ? true : _param_inlineEditor, className = param.className, editorClassName = param.editorClassName, _param_expressionPlaceholder = param.expressionPlaceholder, expressionPlaceholder = _param_expressionPlaceholder === void 0 ? "Enter expression..." : _param_expressionPlaceholder, evaluateExpression = param.evaluateExpression, expressionResult = param.expressionResult, _param_isEvaluating = param.isEvaluating, isEvaluating = _param_isEvaluating === void 0 ? false : _param_isEvaluating, _param_isExpressionValid = param.isExpressionValid, isExpressionValid = _param_isExpressionValid === void 0 ? true : _param_isExpressionValid, _param_expectedType = param.expectedType, expectedType = _param_expectedType === void 0 ? "any" : _param_expectedType;
6195
- var _React4_useState = _sliced_to_array(React4.useState(function() {
6196
- var initialMetadata = metadata || {
6197
- expression: "",
6198
- mode: "value",
6199
- isEditing: false,
6200
- isFullScreen: false,
6201
- value: void 0
6202
- };
6203
- return _object_spread_props(_object_spread({}, initialMetadata), {
6204
- isEditing: false,
6205
- isFullScreen: false,
6206
- mode: "value"
6207
- });
6208
- }), 2), expressionMetadata = _React4_useState[0], setExpressionMetadata = _React4_useState[1];
6209
- var _React4_useState1 = _sliced_to_array(React4.useState(value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value && "type" in value && value.type === "expression" ? value.value : value), 2), originalValue = _React4_useState1[0], setOriginalValue = _React4_useState1[1];
6210
- var _React4_useState2 = _sliced_to_array(React4.useState(value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value && "type" in value && value.type === "expression" ? value.value : value), 2), currentValue = _React4_useState2[0], setCurrentValue = _React4_useState2[1];
6211
- var formatValue = React4.useCallback(function(value2) {
6212
- switch(type){
6213
- case "float":
6214
- {
6215
- return typeof value2 === "string" && !isNaN(parseFloat(value2)) ? parseFloat(value2) : value2;
6216
- }
6217
- case "integer":
6218
- case "number":
6219
- {
6220
- return typeof value2 === "string" && !isNaN(parseInt(value2)) ? parseInt(value2) : value2;
6221
- }
6222
- case "string[]":
6223
- {
6224
- return typeof value2 === "string" ? value2.split(",") : value2;
6225
- }
6226
- case "string":
6227
- default:
6228
- {
6229
- return value2;
6230
- }
6231
- }
6232
- }, [
6233
- type
6234
- ]);
6235
- var _React4_useState3 = _sliced_to_array(React4.useState(), 2), currentEditorValue = _React4_useState3[0], setCurrentEditorValue = _React4_useState3[1];
6236
- var currentExpressionValueExt = useExpressionModeStore.getState().getState(fieldName).expression;
6237
- React4.useEffect(function() {
6238
- if (metadata) {
6239
- setExpressionMetadata(_object_spread_props(_object_spread({}, metadata), {
6240
- // Don't restore editing/fullscreen state from metadata
6241
- // User needs to explicitly click to edit
6242
- isEditing: false,
6243
- isFullScreen: false
6244
- }));
4914
+ });
4915
+ function Input(param) {
4916
+ var fieldName = param.fieldName, label = param.label, value = param.value, onChange = param.onChange, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, placeholder = param.placeholder, _param_expectedType = param.expectedType, expectedType = _param_expectedType === void 0 ? "string" : _param_expectedType, _param_required = param.required, required = _param_required === void 0 ? false : _param_required, _param_hasRequiredError = param.hasRequiredError, hasRequiredError = _param_hasRequiredError === void 0 ? false : _param_hasRequiredError, className = param.className, editorClassName = param.editorClassName;
4917
+ var displayValue = React4__namespace.useMemo(function() {
4918
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value) {
4919
+ return value.expression || "";
6245
4920
  }
4921
+ return String(value !== null && value !== void 0 ? value : "");
6246
4922
  }, [
6247
- metadata
4923
+ value
6248
4924
  ]);
6249
- var isExpressionValue = React4.useMemo(function() {
6250
- return value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value && "type" in value && value.type === "expression";
4925
+ var isExpression = React4__namespace.useMemo(function() {
4926
+ return value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value;
6251
4927
  }, [
6252
4928
  value
6253
4929
  ]);
6254
- var isInitialMount = React4.useRef(true);
6255
- React4.useEffect(function() {
6256
- if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value && "type" in value && value.type === "expression") {
6257
- var exprValue = value.value;
6258
- var exprString = value.expression;
6259
- if (exprValue !== void 0) {
6260
- setCurrentValue(formatValue(exprValue));
6261
- setOriginalValue(formatValue(exprValue));
6262
- }
6263
- if (exprString && expressionMode.expression !== exprString) {
6264
- expressionMode.setExpression(exprString);
6265
- if (isInitialMount.current && !expressionMode.isEditing) {
6266
- expressionMode.switchToExpression();
6267
- }
6268
- }
6269
- var isMetadataOutOfSync = !metadata || metadata.expression !== exprString || metadata.mode === "value" || // If value has expression but mode is 'value', it's out of sync
6270
- metadata.isEditing === true || // Should never start editing on load
6271
- metadata.isFullScreen === true;
6272
- if (isInitialMount.current && isMetadataOutOfSync) {
6273
- var syncedMetadata = {
6274
- expression: exprString || "",
6275
- value: formatValue(exprValue),
6276
- mode: "expression",
6277
- // Show expression display (not editing)
6278
- isEditing: false,
6279
- isFullScreen: false
6280
- };
6281
- setTimeout(function() {
6282
- onValueChange(value, _object_spread_props(_object_spread({}, syncedMetadata), {
6283
- value: formatValue(value)
6284
- }));
6285
- }, 0);
6286
- }
4930
+ var handleChange = React4__namespace.useCallback(function(e) {
4931
+ var newValue = e.target.value;
4932
+ if (newValue.includes("{{")) {
4933
+ onChange({
4934
+ expression: newValue,
4935
+ type: "expression"
4936
+ });
6287
4937
  } else {
6288
- if (!valuesLoading) {
6289
- setCurrentValue(formatValue(value));
6290
- setOriginalValue(formatValue(value));
6291
- if (isInitialMount.current && ((metadata === null || metadata === void 0 ? void 0 : metadata.expression) || (metadata === null || metadata === void 0 ? void 0 : metadata.mode) === "expression")) {
6292
- var syncedMetadata1 = {
6293
- expression: "",
6294
- value: formatValue(value),
6295
- mode: "value",
6296
- isEditing: false,
6297
- isFullScreen: false
6298
- };
6299
- setTimeout(function() {
6300
- onValueChange(formatValue(value), _object_spread_props(_object_spread({}, syncedMetadata1), {
6301
- value: formatValue(value)
6302
- }));
6303
- }, 0);
6304
- }
6305
- }
6306
- }
6307
- if (isInitialMount.current) {
6308
- setTimeout(function() {
6309
- isInitialMount.current = false;
6310
- }, 100);
4938
+ onChange(newValue);
6311
4939
  }
6312
4940
  }, [
6313
- value,
6314
- valuesLoading
4941
+ onChange
6315
4942
  ]);
6316
- var expressionMode = useExpressionMode(fieldName);
6317
- var _useASTParser = useASTParser(expressionMode.expression, fieldName), ast = _useASTParser.ast, tokens = _useASTParser.tokens, dependencies = _useASTParser.dependencies, isParsing = _useASTParser.isLoading, parseError = _useASTParser.error;
6318
- var dependencyList = React4.useMemo(function() {
6319
- if (!ast || dependencies.length === 0) {
6320
- return [];
6321
- }
6322
- return dependencies.map(function(dep) {
6323
- return {
6324
- name: dep,
6325
- exists: expressionContext ? dep in expressionContext : false,
6326
- value: expressionContext ? expressionContext[dep] : void 0
6327
- };
4943
+ var showError = hasRequiredError || required && !displayValue;
4944
+ return /* @__PURE__ */ React4__namespace.createElement("div", {
4945
+ className: cn("uii:mb-2", className)
4946
+ }, /* @__PURE__ */ React4__namespace.createElement("div", {
4947
+ className: "uii:flex uii:items-center uii:gap-2 uii:mt-2"
4948
+ }, /* @__PURE__ */ React4__namespace.createElement("label", {
4949
+ htmlFor: fieldName,
4950
+ className: "uii:text-xs uii:font-bold uii:text-muted-foreground"
4951
+ }, label, ":"), expectedType !== "$.interface.timer" && /* @__PURE__ */ React4__namespace.createElement("span", {
4952
+ className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-gray-200 uii:rounded-sm uii:text-[10px] uii:font-mono uii:text-muted-foreground uii:font-light"
4953
+ }, expectedType), showError && /* @__PURE__ */ React4__namespace.createElement("span", {
4954
+ className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-red-100 uii:text-red-600 uii:rounded-sm uii:text-[10px] uii:font-medium"
4955
+ }, "Required")), /* @__PURE__ */ React4__namespace.createElement("div", {
4956
+ className: "uii:mt-0.5"
4957
+ }, /* @__PURE__ */ React4__namespace.createElement("input", {
4958
+ id: fieldName,
4959
+ name: fieldName,
4960
+ type: "text",
4961
+ value: displayValue,
4962
+ onChange: handleChange,
4963
+ disabled: disabled,
4964
+ placeholder: placeholder || "Enter value or {{ expression }}...",
4965
+ className: cn("uii:w-full uii:h-9 uii:px-3 uii:rounded-sm uii:border uii:bg-background uii:text-sm", "uii:outline-none uii:transition-all", "focus:uii:border-ring focus:uii:ring-ring/50 focus:uii:ring-[3px]", showError ? "uii:border-red-500 hover:uii:border-red-600" : "uii:border-input hover:uii:border-ring/50", isExpression && "uii:font-mono uii:text-amber-600", disabled && "uii:opacity-50 uii:cursor-not-allowed", editorClassName)
4966
+ })));
4967
+ }
4968
+ function Select(param) {
4969
+ var fieldName = param.fieldName, label = param.label, value = param.value, onChange = param.onChange, rawOptions = param.options, _param_disabled = param.disabled, disabled = _param_disabled === void 0 ? false : _param_disabled, placeholder = param.placeholder, _param_expectedType = param.expectedType, expectedType = _param_expectedType === void 0 ? "string" : _param_expectedType, _param_required = param.required, required = _param_required === void 0 ? false : _param_required, _param_hasRequiredError = param.hasRequiredError, hasRequiredError = _param_hasRequiredError === void 0 ? false : _param_hasRequiredError, className = param.className, children = param.children;
4970
+ var _React4__namespace_useState = _sliced_to_array(React4__namespace.useState(false), 2), isExpressionMode = _React4__namespace_useState[0], setIsExpressionMode = _React4__namespace_useState[1];
4971
+ var _React4__namespace_useState1 = _sliced_to_array(React4__namespace.useState(""), 2), expressionValue = _React4__namespace_useState1[0], setExpressionValue = _React4__namespace_useState1[1];
4972
+ var options = React4__namespace.useMemo(function() {
4973
+ return rawOptions.map(function(opt) {
4974
+ return typeof opt === "string" ? {
4975
+ value: opt,
4976
+ label: opt
4977
+ } : opt;
6328
4978
  });
6329
4979
  }, [
6330
- dependencies,
6331
- expressionContext,
6332
- ast
4980
+ rawOptions
6333
4981
  ]);
6334
- var _React4_useState4 = _sliced_to_array(React4.useState(null), 2), typeScriptInferredType = _React4_useState4[0], setTypeScriptInferredType = _React4_useState4[1];
6335
- var handleTypeInferred = React4.useCallback(function(type2) {
6336
- setTypeScriptInferredType(type2);
6337
- }, []);
6338
- var expressionHasNewlines = React4.useMemo(function() {
6339
- return expressionMode.expression.includes("\n") || expressionMode.expression.includes("\r");
4982
+ var displayValue = React4__namespace.useMemo(function() {
4983
+ if (value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value) {
4984
+ return value.expression || "";
4985
+ }
4986
+ return String(value !== null && value !== void 0 ? value : "");
6340
4987
  }, [
6341
- expressionMode.expression
4988
+ value
6342
4989
  ]);
6343
- var inferredReturnType = React4.useMemo(function() {
6344
- return typeScriptInferredType || "unknown";
4990
+ var isExpression = React4__namespace.useMemo(function() {
4991
+ return value && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "expression" in value;
6345
4992
  }, [
6346
- typeScriptInferredType
4993
+ value
6347
4994
  ]);
6348
- var hasTypeMismatch = React4.useMemo(function() {
6349
- if (!inferredReturnType || inferredReturnType === "unknown" || inferredReturnType === "any" || inferredReturnType === "error") {
6350
- return false;
6351
- }
6352
- var normalizedInferred = inferredReturnType.toLowerCase().trim();
6353
- var normalizedExpected = (type || expectedType || "any").toLowerCase().trim();
6354
- if (normalizedExpected === "array" && normalizedInferred.endsWith("[]")) {
6355
- return false;
6356
- }
6357
- if (normalizedInferred === normalizedExpected) {
6358
- return false;
6359
- }
6360
- if (normalizedExpected === "any") {
6361
- return false;
4995
+ React4__namespace.useEffect(function() {
4996
+ if (isExpression) {
4997
+ setIsExpressionMode(true);
4998
+ setExpressionValue(displayValue);
6362
4999
  }
6363
- if (normalizedExpected === "string" && (normalizedInferred.startsWith('"') || normalizedInferred.startsWith("'"))) {
6364
- return false;
6365
- }
6366
- if (normalizedExpected === "number" && /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(normalizedInferred)) {
6367
- return false;
6368
- }
6369
- if (normalizedExpected === "integer" && /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(normalizedInferred)) {
6370
- return false;
6371
- }
6372
- if (normalizedExpected === "integer" && normalizedInferred === "number") {
6373
- return false;
6374
- }
6375
- if (normalizedExpected === "float" && /^-?\d+(\.\d+)?([eE][+-]?\d+)?$/.test(normalizedInferred)) {
6376
- return false;
6377
- }
6378
- if (normalizedExpected === "float" && normalizedInferred === "number") {
6379
- return false;
6380
- }
6381
- if (normalizedExpected === "boolean" && (normalizedInferred === "true" || normalizedInferred === "false")) {
6382
- return false;
6383
- }
6384
- return true;
6385
5000
  }, [
6386
- inferredReturnType,
6387
- type,
6388
- expectedType
5001
+ isExpression,
5002
+ displayValue
6389
5003
  ]);
6390
- var _React4_useState5 = _sliced_to_array(React4.useState(null), 2), internalExpressionResult = _React4_useState5[0], setInternalExpressionResult = _React4_useState5[1];
6391
- var _React4_useState6 = _sliced_to_array(React4.useState(false), 2), internalIsEvaluating = _React4_useState6[0], setInternalIsEvaluating = _React4_useState6[1];
6392
- var _React4_useState7 = _sliced_to_array(React4.useState(false), 2), isHovering = _React4_useState7[0], setIsHovering = _React4_useState7[1];
6393
- var _React4_useState8 = _sliced_to_array(React4.useState(true), 2), internalIsExpressionValid = _React4_useState8[0], setInternalIsExpressionValid = _React4_useState8[1];
6394
- var _React4_useState9 = _sliced_to_array(React4.useState({
6395
- syntax: true,
6396
- expression: true,
6397
- context: true,
6398
- type: true,
6399
- security: true
6400
- }), 2), validationState = _React4_useState9[0], setValidationState = _React4_useState9[1];
6401
- var hasExpressionError = React4.useMemo(function() {
6402
- if (!expressionMode.expression || !expressionMode.expression.trim()) {
6403
- return false;
6404
- }
6405
- if (!internalIsExpressionValid || !isExpressionValid) {
6406
- return true;
6407
- }
6408
- if (parseError) {
6409
- return true;
6410
- }
6411
- if (!validationState.syntax || !validationState.expression) {
6412
- return true;
6413
- }
6414
- if ((expressionResult === null || expressionResult === void 0 ? void 0 : expressionResult.error) || (internalExpressionResult === null || internalExpressionResult === void 0 ? void 0 : internalExpressionResult.error)) {
6415
- return true;
5004
+ var handleSelectChange = React4__namespace.useCallback(function(newValue) {
5005
+ if (newValue === "__expression__") {
5006
+ setIsExpressionMode(true);
5007
+ return;
6416
5008
  }
6417
- return false;
5009
+ onChange(newValue);
6418
5010
  }, [
6419
- expressionMode.expression,
6420
- internalIsExpressionValid,
6421
- isExpressionValid,
6422
- parseError,
6423
- validationState,
6424
- expressionResult,
6425
- internalExpressionResult
5011
+ onChange
6426
5012
  ]);
6427
- var isProgrammaticallyClearing = React4.useRef(false);
6428
- var isSwitchingToFullScreen = React4.useRef(false);
6429
- var isBlur = React4.useRef(false);
6430
- var handleValidationChange = React4.useCallback(function(isValid, errors) {
6431
- setInternalIsExpressionValid(isValid);
6432
- setValidationState(function(prev) {
6433
- return _object_spread_props(_object_spread({}, prev), {
6434
- syntax: isValid
6435
- });
5013
+ var handleExpressionChange = React4__namespace.useCallback(function(e) {
5014
+ var newValue = e.target.value;
5015
+ setExpressionValue(newValue);
5016
+ onChange({
5017
+ expression: newValue,
5018
+ type: "expression"
6436
5019
  });
6437
- }, []);
6438
- var checkForMultiLine = React4.useCallback(function(expression) {
6439
- var hasNewlines = expression.includes("\n");
6440
- var isLong = expression.length > 80;
6441
- if (!expressionMode.isFullScreen) {
6442
- expressionMode.setFullScreen(hasNewlines || isLong);
6443
- }
6444
5020
  }, [
6445
- expressionMode.isFullScreen
5021
+ onChange
6446
5022
  ]);
6447
- var internalEvaluateExpression = React4.useCallback(function(expression, context) {
6448
- return _async_to_generator(function() {
6449
- var result, error;
6450
- return _ts_generator(this, function(_state) {
6451
- switch(_state.label){
6452
- case 0:
6453
- if (!evaluateExpression || !expression.trim()) return [
6454
- 2
6455
- ];
6456
- setInternalIsEvaluating(true);
6457
- _state.label = 1;
6458
- case 1:
6459
- _state.trys.push([
6460
- 1,
6461
- 3,
6462
- 4,
6463
- 5
6464
- ]);
6465
- return [
6466
- 4,
6467
- evaluateExpression(expression, context)
6468
- ];
6469
- case 2:
6470
- result = _state.sent();
6471
- setInternalExpressionResult(result);
6472
- return [
6473
- 3,
6474
- 5
6475
- ];
6476
- case 3:
6477
- error = _state.sent();
6478
- setInternalExpressionResult({
6479
- value: null,
6480
- ast: {
6481
- kind: 0,
6482
- text: "",
6483
- color: "#ff0000"
6484
- },
6485
- error: _instanceof(error, Error) ? error.message : "Unknown error",
6486
- isValid: false,
6487
- validation: {
6488
- syntax: false,
6489
- expression: false,
6490
- context: false,
6491
- type: false,
6492
- security: false
6493
- }
6494
- });
6495
- return [
6496
- 3,
6497
- 5
6498
- ];
6499
- case 4:
6500
- setInternalIsEvaluating(false);
6501
- return [
6502
- 7
6503
- ];
6504
- case 5:
6505
- return [
6506
- 2
6507
- ];
6508
- }
6509
- });
6510
- })();
5023
+ var handleSwitchToValue = React4__namespace.useCallback(function() {
5024
+ setIsExpressionMode(false);
5025
+ setExpressionValue("");
5026
+ onChange("");
6511
5027
  }, [
6512
- evaluateExpression
5028
+ onChange
6513
5029
  ]);
6514
- var currentMetadata = React4.useMemo(function() {
5030
+ var showError = hasRequiredError || required && !displayValue;
5031
+ var renderProps = {
5032
+ value: displayValue,
5033
+ onChange: handleSelectChange,
5034
+ onExpressionClick: function() {
5035
+ return setIsExpressionMode(true);
5036
+ },
5037
+ options: options,
5038
+ localInput: displayValue,
5039
+ setLocalInput: function() {},
5040
+ expressionMode: {
5041
+ current: isExpressionMode ? "expression" : "value",
5042
+ isExpressionMode: isExpressionMode,
5043
+ isEditorMode: false,
5044
+ isEditing: false,
5045
+ isFullScreen: false,
5046
+ expression: expressionValue,
5047
+ switchToValue: handleSwitchToValue,
5048
+ switchToExpression: function() {
5049
+ return setIsExpressionMode(true);
5050
+ },
5051
+ switchToEditor: function() {
5052
+ return setIsExpressionMode(true);
5053
+ },
5054
+ clear: handleSwitchToValue
5055
+ },
5056
+ hasError: showError
5057
+ };
5058
+ return /* @__PURE__ */ React4__namespace.createElement("div", {
5059
+ className: cn("uii:mb-2", className)
5060
+ }, /* @__PURE__ */ React4__namespace.createElement("div", {
5061
+ className: "uii:flex uii:items-center uii:gap-2 uii:mt-2"
5062
+ }, /* @__PURE__ */ React4__namespace.createElement("label", {
5063
+ htmlFor: fieldName,
5064
+ className: "uii:text-xs uii:font-bold uii:text-muted-foreground"
5065
+ }, label, ":"), expectedType !== "$.interface.timer" && /* @__PURE__ */ React4__namespace.createElement("span", {
5066
+ className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-gray-200 uii:rounded-sm uii:text-[10px] uii:font-mono uii:text-muted-foreground uii:font-light"
5067
+ }, expectedType), showError && /* @__PURE__ */ React4__namespace.createElement("span", {
5068
+ className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-red-100 uii:text-red-600 uii:rounded-sm uii:text-[10px] uii:font-medium"
5069
+ }, "Required")), /* @__PURE__ */ React4__namespace.createElement("div", {
5070
+ className: "uii:mt-0.5"
5071
+ }, children ? // Use custom render function
5072
+ children(renderProps) : isExpressionMode ? // Expression mode - show input with clear button
5073
+ /* @__PURE__ */ React4__namespace.createElement("div", {
5074
+ className: "uii:flex uii:items-center uii:h-9 uii:rounded-sm uii:border uii:border-amber-500/50 uii:bg-amber-500/5"
5075
+ }, /* @__PURE__ */ React4__namespace.createElement("input", {
5076
+ id: fieldName,
5077
+ name: fieldName,
5078
+ type: "text",
5079
+ value: expressionValue,
5080
+ onChange: handleExpressionChange,
5081
+ disabled: disabled,
5082
+ placeholder: "Enter expression...",
5083
+ className: cn("uii:flex-1 uii:h-full uii:px-3 uii:bg-transparent uii:text-sm uii:font-mono uii:text-amber-600", "uii:outline-none uii:border-none", disabled && "uii:opacity-50 uii:cursor-not-allowed")
5084
+ }), /* @__PURE__ */ React4__namespace.createElement("button", {
5085
+ type: "button",
5086
+ onClick: handleSwitchToValue,
5087
+ className: "uii:flex uii:items-center uii:justify-center uii:h-full uii:px-2 uii:text-amber-600 hover:uii:text-red-600 uii:border-l uii:border-amber-500/30",
5088
+ title: "Clear and return to value mode"
5089
+ }, "\xD7")) : // Value mode - show select
5090
+ /* @__PURE__ */ React4__namespace.createElement("select", {
5091
+ id: fieldName,
5092
+ name: fieldName,
5093
+ value: displayValue,
5094
+ onChange: function(e) {
5095
+ return handleSelectChange(e.target.value);
5096
+ },
5097
+ disabled: disabled,
5098
+ className: cn("uii:w-full uii:h-9 uii:px-3 uii:rounded-sm uii:border uii:bg-background uii:text-sm", "uii:outline-none uii:transition-all uii:cursor-pointer", "focus:uii:border-ring focus:uii:ring-ring/50 focus:uii:ring-[3px]", showError ? "uii:border-red-500 hover:uii:border-red-600" : "uii:border-input hover:uii:border-ring/50", disabled && "uii:opacity-50 uii:cursor-not-allowed")
5099
+ }, placeholder && /* @__PURE__ */ React4__namespace.createElement("option", {
5100
+ value: "",
5101
+ disabled: true
5102
+ }, placeholder), options.map(function(opt) {
5103
+ return /* @__PURE__ */ React4__namespace.createElement("option", {
5104
+ key: opt.value,
5105
+ value: opt.value
5106
+ }, opt.label);
5107
+ }), /* @__PURE__ */ React4__namespace.createElement("option", {
5108
+ value: "__expression__"
5109
+ }, "\uD83D\uDCDD Custom Expression"))));
5110
+ }
5111
+ // src/components/fields/index.tsx
5112
+ function useTemplateFieldContext() {
5113
+ return {
5114
+ yDoc: null,
5115
+ collabUser: null,
5116
+ awareness: null,
5117
+ availableNodes: null,
5118
+ myInterface: null,
5119
+ typeDeclarations: "",
5120
+ element: null,
5121
+ nodeId: "",
5122
+ onControlFocus: function() {},
5123
+ onControlBlur: function() {},
5124
+ onRecordChange: function() {},
5125
+ onValidationChange: function() {},
5126
+ parentFieldPath: null,
5127
+ disabled: false
5128
+ };
5129
+ }
5130
+ function useIsInTemplateFieldProvider() {
5131
+ return false;
5132
+ }
5133
+ function useFieldPath(fieldName) {
5134
+ return fieldName;
5135
+ }
5136
+ function TemplateFieldProvider(param) {
5137
+ var children = param.children;
5138
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
5139
+ }
5140
+ function NestedFieldProvider(param) {
5141
+ var children = param.children;
5142
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
5143
+ }
5144
+ var InferredTypesContext = React4.createContext(null);
5145
+ function useInferredTypes() {
5146
+ return React4.useContext(InferredTypesContext);
5147
+ }
5148
+ function parseInferSyntax(expectedType) {
5149
+ var _match_;
5150
+ if (!expectedType || !expectedType.startsWith("$infer<")) {
6515
5151
  return {
6516
- expression: expressionMode.expression,
6517
- value: currentValue,
6518
- mode: expressionMode.current,
6519
- isEditing: expressionMode.isEditing,
6520
- isFullScreen: expressionMode.isFullScreen
5152
+ mode: "normal"
6521
5153
  };
6522
- }, [
6523
- expressionMode.expression,
6524
- expressionMode.current,
6525
- expressionMode.isFullScreen,
6526
- expressionMode.isEditing,
6527
- currentValue
6528
- ]);
6529
- var currentExpressionValue = React4.useMemo(function() {
5154
+ }
5155
+ var match = expectedType.match(/^\$infer<(.+)>$/);
5156
+ if (!match) {
6530
5157
  return {
6531
- expression: expressionMode.expression,
6532
- type: "expression"
5158
+ mode: "normal"
6533
5159
  };
6534
- }, [
6535
- expressionMode.currentValue || expressionMode.expression
6536
- ]);
6537
- var handleValueChange = React4.useCallback(function(newValue) {
6538
- onValueChange(formatValue(newValue), _object_spread_props(_object_spread({}, currentMetadata), {
6539
- value: formatValue(newValue)
6540
- }));
6541
- }, [
6542
- onValueChange,
6543
- expressionMode,
6544
- isExpressionValue,
6545
- currentValue
6546
- ]);
6547
- var handleExpressionChange = React4.useCallback(function(newExpression) {
6548
- isProgrammaticallyClearing.current = false;
6549
- expressionMode.setExpression(newExpression);
6550
- setCurrentEditorValue(newExpression);
6551
- checkForMultiLine(newExpression);
6552
- onValueChange({
6553
- expression: newExpression,
6554
- type: "expression"
6555
- }, _object_spread_props(_object_spread({}, currentMetadata), {
6556
- expression: newExpression
6557
- }));
6558
- }, [
6559
- expressionMode,
6560
- expressionContext,
6561
- onValueChange,
6562
- evaluateExpression,
6563
- internalEvaluateExpression,
6564
- checkForMultiLine
6565
- ]);
6566
- var handleExpressionBlur = React4.useCallback(function(e) {
6567
- var forceBlur = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
6568
- return _async_to_generator(function() {
6569
- return _ts_generator(this, function(_state) {
6570
- if (isProgrammaticallyClearing.current) {
6571
- isProgrammaticallyClearing.current = false;
6572
- return [
6573
- 2
6574
- ];
6575
- }
6576
- if (isSwitchingToFullScreen.current) {
6577
- isSwitchingToFullScreen.current = false;
6578
- return [
6579
- 2
6580
- ];
6581
- }
6582
- if (expressionMode.isFullScreen && !forceBlur) {
6583
- return [
6584
- 2
6585
- ];
6586
- }
6587
- if (expressionHasNewlines && !forceBlur) {
6588
- return [
6589
- 2
6590
- ];
6591
- }
6592
- isBlur.current = true;
6593
- expressionMode.setEditing(false);
6594
- expressionMode.setFullScreen(false);
6595
- return [
6596
- 2
6597
- ];
6598
- });
6599
- })();
6600
- }, [
6601
- expressionMode,
6602
- expressionResult,
6603
- internalExpressionResult,
6604
- expressionContext,
6605
- onValueChange,
6606
- currentValue,
6607
- isEvaluating,
6608
- internalIsEvaluating,
6609
- currentExpressionValue,
6610
- expressionHasNewlines
6611
- ]);
6612
- React4.useEffect(function() {
6613
- onValueChange(currentValue, _object_spread_props(_object_spread({}, currentMetadata), {
6614
- isFullScreen: expressionMode.isFullScreen
6615
- }));
6616
- }, [
6617
- expressionMode.isFullScreen
6618
- ]);
6619
- React4.useEffect(function() {
6620
- if (expressionMode.isEditing && expressionHasNewlines && !expressionMode.isFullScreen) {
6621
- expressionMode.setFullScreen(true);
6622
- }
6623
- }, [
6624
- expressionHasNewlines,
6625
- expressionMode.isEditing,
6626
- expressionMode.isFullScreen
6627
- ]);
6628
- var handleModeChange = React4.useCallback(function(newMode) {
6629
- switch(newMode){
6630
- case "value":
6631
- expressionMode.switchToValue();
6632
- expressionMode.setFullScreen(false);
6633
- onValueChange(originalValue || value, void 0);
6634
- break;
6635
- case "editor":
6636
- expressionMode.switchToEditor();
6637
- var shouldBeFullScreen = expressionHasNewlines;
6638
- if (shouldBeFullScreen) {
6639
- expressionMode.setFullScreen(true);
6640
- }
6641
- var editorMetadata = {
6642
- expression: expressionMode.expression,
6643
- value: currentValue,
6644
- mode: "expression",
6645
- isEditing: true,
6646
- isFullScreen: shouldBeFullScreen
6647
- };
6648
- onValueChange(expressionMode.expression ? {
6649
- expression: expressionMode.expression,
6650
- type: "expression"
6651
- } : currentValue, editorMetadata);
6652
- break;
6653
- case "expression":
6654
- setOriginalValue(currentValue);
6655
- expressionMode.switchToExpression();
6656
- if (expressionHasNewlines) {
6657
- expressionMode.setFullScreen(true);
6658
- }
6659
- break;
6660
- }
6661
- }, [
6662
- expressionMode,
6663
- currentValue,
6664
- onValueChange,
6665
- expressionHasNewlines,
6666
- originalValue,
6667
- value
6668
- ]);
6669
- React4.useEffect(function() {
6670
- if (isBlur.current) {
6671
- if (!(expressionMode.expression && expressionMode.expression.trim())) {
6672
- expressionMode.switchToValue();
6673
- var _currentMetadata_value;
6674
- onValueChange((_currentMetadata_value = currentMetadata.value) !== null && _currentMetadata_value !== void 0 ? _currentMetadata_value : "", _object_spread_props(_object_spread({}, currentMetadata), {
6675
- mode: "value",
6676
- expression: "",
6677
- isEditing: false,
6678
- isFullScreen: false
6679
- }));
6680
- } else {
6681
- var _currentMetadata_value1;
6682
- onValueChange(currentMetadata.mode === "value" ? (_currentMetadata_value1 = currentMetadata.value) !== null && _currentMetadata_value1 !== void 0 ? _currentMetadata_value1 : "" : {
6683
- expression: currentMetadata.expression.trim(),
6684
- type: "expression"
6685
- }, _object_spread_props(_object_spread({}, currentMetadata), {
6686
- isEditing: false,
6687
- isFullScreen: false
6688
- }));
6689
- }
6690
- isBlur.current = false;
6691
- }
6692
- }, [
6693
- expressionMode.isEditing,
6694
- expressionMode.isFullScreen,
6695
- isBlur.current
6696
- ]);
6697
- React4.useEffect(function() {
6698
- if (onDependenciesChange) {
6699
- onDependenciesChange(dependencies);
6700
- }
6701
- }, [
6702
- dependencies,
6703
- onDependenciesChange
6704
- ]);
6705
- var handleClear = React4.useCallback(function() {
6706
- isProgrammaticallyClearing.current = true;
6707
- onValueChange(currentValue, currentMetadata);
6708
- handleModeChange("value");
6709
- expressionMode.setFullScreen(false);
6710
- }, [
6711
- onValueChange,
6712
- expressionMode,
6713
- originalValue
6714
- ]);
6715
- var _React4_useState10 = _sliced_to_array(React4.useState(currentValue), 2), localInput = _React4_useState10[0], setLocalInput = _React4_useState10[1];
6716
- React4.useEffect(function() {
6717
- setLocalInput(currentValue);
6718
- }, [
6719
- currentValue
6720
- ]);
6721
- var controlProps = React4.useMemo(function() {
5160
+ }
5161
+ var content = ((_match_ = match[1]) === null || _match_ === void 0 ? void 0 : _match_.trim()) || "";
5162
+ if (!content.includes("|") && /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(content)) {
6722
5163
  return {
6723
- value: currentValue,
6724
- onChange: handleValueChange,
6725
- onExpressionClick: function() {
6726
- return handleModeChange("editor");
6727
- },
6728
- // Click handler to trigger expression mode
6729
- inferredType: inferredReturnType,
6730
- // Inferred TypeScript type
6731
- hasTypeMismatch: hasTypeMismatch,
6732
- // Whether inferred type matches expected
6733
- hasError: hasExpressionError,
6734
- // Whether expression has syntax/validation errors
6735
- localInput: localInput,
6736
- setLocalInput: setLocalInput,
6737
- expressionMode: {
6738
- current: expressionMode.current,
6739
- switchToValue: function() {
6740
- return handleModeChange("value");
6741
- },
6742
- switchToExpression: function() {
6743
- return handleModeChange("expression");
6744
- },
6745
- switchToEditor: function() {
6746
- return handleModeChange("editor");
6747
- },
6748
- clear: handleClear,
6749
- isExpressionMode: expressionMode.isExpressionMode,
6750
- isEditorMode: expressionMode.isEditorMode,
6751
- expression: expressionMode.expression,
6752
- setExpression: handleExpressionChange,
6753
- isEditing: expressionMode.isEditing,
6754
- setEditing: expressionMode.setEditing,
6755
- isFullScreen: expressionMode.isFullScreen,
6756
- setFullScreen: expressionMode.setFullScreen
6757
- }
5164
+ mode: "subscribe",
5165
+ subscribeToField: content
6758
5166
  };
6759
- }, [
6760
- currentValue,
6761
- handleValueChange,
6762
- expressionMode,
6763
- handleModeChange,
6764
- handleClear,
6765
- handleExpressionChange,
6766
- inferredReturnType,
6767
- hasTypeMismatch,
6768
- hasExpressionError
6769
- ]);
6770
- var renderContent = function() {
6771
- switch(expressionMode.current){
6772
- // case 'value':
6773
- // return children(controlProps);
6774
- case "expression":
6775
- var _this;
6776
- expressionMode.expression && expressionMode.expression.trim();
6777
- (_this = expressionResult || internalExpressionResult) === null || _this === void 0 ? void 0 : _this.isValid;
6778
- return controlProps.expressionMode.isEditing ? /* @__PURE__ */ React4__namespace.default.createElement("div", {
6779
- key: "expression",
6780
- className: cn("relative", className)
6781
- }, inlineEditor && !expressionMode.isFullScreen && !expressionHasNewlines ? /* @__PURE__ */ React4__namespace.default.createElement("div", {
6782
- className: cn("uii:flex uii:h-9 uii:w-full \n uii:min-w-0 uii:rounded-sm \n uii:border uii:border-ring \n uii:bg-background uii:px-3 uii:py-1 uii:text-base uii:shadow-xs \n uii:ring-ring/50 uii:ring-[3px] uii:transition-[color,box-shadow] \n uii:outline-none uii:md:text-sm uii:cursor-pointer\n uii:mt-0.5 ", editorClassName)
6783
- }, /* @__PURE__ */ React4__namespace.default.createElement(InlineExpressionEditor, {
6784
- value: expressionMode.expression,
6785
- onChange: function(newValue) {
6786
- handleExpressionChange(newValue);
6787
- },
6788
- onEnter: function() {
6789
- isSwitchingToFullScreen.current = true;
6790
- expressionMode.setFullScreen(true);
6791
- setTimeout(function() {
6792
- isSwitchingToFullScreen.current = false;
6793
- }, 100);
6794
- },
6795
- onBlur: handleExpressionBlur,
6796
- onTypeInferred: handleTypeInferred,
6797
- onValidationChange: handleValidationChange,
6798
- context: expressionContext,
6799
- placeholder: expressionPlaceholder
6800
- }), /* @__PURE__ */ React4__namespace.default.createElement("div", {
6801
- className: "uii:flex uii:items-center uii:gap-2 uii:mt-0.5"
6802
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6803
- className: "uii:text-xs uii:font-mono uii:cursor-pointer uii:text-muted-foreground",
6804
- onMouseDown: function(e) {
6805
- e.preventDefault();
6806
- e.stopPropagation();
6807
- isSwitchingToFullScreen.current = true;
6808
- expressionMode.setFullScreen(true);
6809
- setTimeout(function() {
6810
- isSwitchingToFullScreen.current = false;
6811
- }, 100);
6812
- }
6813
- }, /* @__PURE__ */ React4__namespace.default.createElement(reactFontawesome.FontAwesomeIcon, {
6814
- icon: proRegularSvgIcons.faExpand
6815
- })), /* @__PURE__ */ React4__namespace.default.createElement("span", {
6816
- className: "uii:text-xs uii:font-mono uii:cursor-pointer uii:text-muted-foreground",
6817
- onMouseDown: function(e) {
6818
- e.preventDefault();
6819
- handleClear();
6820
- }
6821
- }, "Clear"))) : /* @__PURE__ */ React4__namespace.default.createElement("div", {
6822
- className: "uii:space-y-4"
6823
- }, /* @__PURE__ */ React4__namespace.default.createElement(FullPanelExpressionEditor, {
6824
- value: expressionMode.expression,
6825
- onChange: function(newValue) {
6826
- handleExpressionChange(newValue);
6827
- },
6828
- onClose: function() {
6829
- handleExpressionBlur(void 0, true);
6830
- expressionMode.setFullScreen(false);
6831
- },
6832
- onBlur: handleExpressionBlur,
6833
- onTypeInferred: handleTypeInferred,
6834
- context: expressionContext,
6835
- placeholder: expressionPlaceholder
6836
- }), (ast || dependencies.length > 0) && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6837
- className: "uii:space-y-3"
6838
- }, inferredReturnType && inferredReturnType !== "unknown" && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6839
- className: "uii:space-y-2"
6840
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6841
- className: "uii:flex uii:items-center uii:gap-2"
6842
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6843
- className: "uii:text-sm uii:font-semibold uii:text-gray-700"
6844
- }, "Inferred Return Type:"), typeScriptInferredType && inferredReturnType !== "error" && /* @__PURE__ */ React4__namespace.default.createElement("span", {
6845
- className: "uii:px-1.5 uii:py-0.5 uii:text-xs uii:rounded uii:bg-blue-100 uii:text-blue-700 uii:border uii:border-blue-200"
6846
- }, "TypeScript")), /* @__PURE__ */ React4__namespace.default.createElement("div", {
6847
- className: "uii:flex uii:items-center uii:gap-2"
6848
- }, inferredReturnType === "error" ? /* @__PURE__ */ React4__namespace.default.createElement("span", {
6849
- className: "uii:px-3 uii:py-1.5 uii:text-sm uii:font-mono uii:rounded uii:border uii:bg-red-50 uii:text-red-800 uii:border-red-200"
6850
- }, "\u274C Syntax Error") : /* @__PURE__ */ React4__namespace.default.createElement(React4__namespace.default.Fragment, null, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6851
- className: "uii:px-3 uii:py-1.5 uii:text-sm uii:font-mono uii:rounded uii:border uii:bg-purple-50 uii:text-purple-800 uii:border-purple-200"
6852
- }, inferredReturnType), hasTypeMismatch && /* @__PURE__ */ React4__namespace.default.createElement("span", {
6853
- className: "uii:text-xs uii:text-orange-600 uii:font-semibold"
6854
- }, "\u26A0\uFE0F Expected: ", type || expectedType)))), dependencyList.length > 0 && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6855
- className: "uii:space-y-2"
6856
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6857
- className: "uii:text-sm uii:font-semibold uii:text-gray-700"
6858
- }, "Dependencies (", dependencyList.length, "):"), /* @__PURE__ */ React4__namespace.default.createElement("div", {
6859
- className: "uii:flex uii:flex-wrap uii:gap-2"
6860
- }, dependencyList.map(function(dep, index) {
6861
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6862
- key: index,
6863
- className: cn("uii:px-2 uii:py-1 uii:text-sm uii:rounded uii:border", dep.exists ? "uii:bg-blue-100 uii:text-blue-800 uii:border-blue-200" : "uii:bg-red-100 uii:text-red-800 uii:border-red-200"),
6864
- title: dep.exists ? "Value: ".concat(JSON.stringify(dep.value)) : "Not found in context"
6865
- }, dep.name);
6866
- }))), ast && /* @__PURE__ */ React4__namespace.default.createElement(ASTRenderer, {
6867
- ast: ast,
6868
- tokens: tokens,
6869
- variant: "tree",
6870
- showTokens: true,
6871
- className: "uii:w-full"
6872
- }), isParsing && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6873
- className: "uii:text-sm uii:text-gray-500 uii:italic"
6874
- }, "Parsing expression..."), parseError && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6875
- className: "uii:text-sm uii:text-red-600"
6876
- }, "Parse Error: ", parseError)))) : /* @__PURE__ */ React4__namespace.default.createElement("div", {
6877
- className: cn("uii:relative", className),
6878
- key: "expression-display"
6879
- }, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6880
- className: clsx_default("uii:flex uii:h-9 uii:w-full uii:min-w-0 uii:rounded-sm uii:border uii:border-input uii:bg-transparent uii:px-3 uii:py-1 uii:text-base uii:shadow-xs uii:transition-[color,box-shadow] uii:outline-none uii:focus-visible:border-ring uii:focus-visible:ring-ring/50 uii:focus-visible:ring-[3px] uii:md:text-sm uii:cursor-pointer uii:hover:bg-muted/50", "uii:mt-0.5 uii:bg-white uii:rounded-md uii:items-center"),
6881
- onClick: function() {
6882
- return handleModeChange("editor");
6883
- },
6884
- onMouseEnter: function() {
6885
- return setIsHovering(true);
6886
- },
6887
- onMouseLeave: function() {
6888
- return setIsHovering(false);
6889
- }
6890
- }, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6891
- className: "uii:flex-1 uii:truncate uii:text-foreground uii:items-center"
6892
- }, isHovering ? // Hover state: show AST preview with dependencies
6893
- /* @__PURE__ */ React4__namespace.default.createElement("div", {
6894
- className: "uii:flex uii:items-center uii:gap-2"
6895
- }, ast ? /* @__PURE__ */ React4__namespace.default.createElement(ASTRenderer, {
6896
- key: "ast",
6897
- ast: ast,
6898
- tokens: tokens,
6899
- variant: "inline",
6900
- showTokens: false,
6901
- className: "uii:text-xs"
6902
- }) : /* @__PURE__ */ React4__namespace.default.createElement("div", {
6903
- className: "uii:text-xs uii:text-gray-500"
6904
- }, isParsing ? "Parsing..." : parseError ? "Error: ".concat(parseError) : "No AST available"), dependencies.length > 0 && /* @__PURE__ */ React4__namespace.default.createElement("div", {
6905
- className: "uii:flex uii:gap-1"
6906
- }, dependencies.map(function(dep, index) {
6907
- return /* @__PURE__ */ React4__namespace.default.createElement("span", {
6908
- key: index,
6909
- className: "uii:px-1 uii:py-0.5 uii:bg-blue-100 uii:text-blue-800 uii:text-xs uii:rounded"
6910
- }, dep);
6911
- }))) : // At rest: show the expression text
6912
- /* @__PURE__ */ React4__namespace.default.createElement("span", {
6913
- className: "uii:font-mono uii:text-sm"
6914
- }, currentExpressionValueExt || "No expression"))));
6915
- default:
6916
- return children(controlProps);
6917
- }
5167
+ }
5168
+ var allowedTypes = content.split("|").map(function(t) {
5169
+ return t.trim();
5170
+ }).filter(Boolean);
5171
+ return {
5172
+ mode: "publish",
5173
+ allowedTypes: allowedTypes
6918
5174
  };
6919
- return /* @__PURE__ */ React4__namespace.default.createElement(React4__namespace.default.Fragment, null, /* @__PURE__ */ React4__namespace.default.createElement("div", {
6920
- className: "uii:flex uii:items-center uii:gap-2 uii:mt-2"
6921
- }, /* @__PURE__ */ React4__namespace.default.createElement("label", {
6922
- className: "uii:text-xs uii:text-muted-foreground uii:font-bold",
6923
- htmlFor: fieldName
6924
- }, label, ":"), /* @__PURE__ */ React4__namespace.default.createElement("span", {
6925
- className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-gray-200 uii:rounded-sm uii:text-[10px] uii:font-mono uii:text-muted-foreground uii:font-light"
6926
- }, type), hasTypeMismatch || inferredReturnType === "error" ? /* @__PURE__ */ React4__namespace.default.createElement(React4__namespace.default.Fragment, null, expressionMode.current === "expression" ? /* @__PURE__ */ React4__namespace.default.createElement(React4__namespace.default.Fragment, null, /* @__PURE__ */ React4__namespace.default.createElement("span", {
6927
- className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-gray-200 uii:rounded-sm uii:text-[10px] uii:font-mono uii:text-muted-foreground uii:font-light"
6928
- }, expressionMode.expression.trim() !== "" ? inferredReturnType : "empty"), /* @__PURE__ */ React4__namespace.default.createElement("span", {
6929
- className: "uii:-mt-2 uii:inline-flex uii:px-1 uii:py-0.5 uii:bg-gray-200 uii:rounded-sm uii:text-[10px] uii:font-mono uii:font-light uii:text-orange-600 "
6930
- }, "\u26A0\uFE0F Expected: ", type || expectedType)) : /* @__PURE__ */ React4__namespace.default.createElement(React4__namespace.default.Fragment, null)) : /* @__PURE__ */ React4__namespace.default.createElement(React4__namespace.default.Fragment, null)), renderContent());
6931
5175
  }
6932
- // src/components/input.tsx
6933
- function Input2(_param) {
6934
- var className = _param.className, expectedType = _param.expectedType, props = _object_without_properties(_param, [
6935
- "className",
6936
- "expectedType"
6937
- ]);
6938
- var _props_label, _props_key, _props_name;
6939
- return /* @__PURE__ */ React4__namespace.createElement(ExpressionWrapper, {
6940
- label: (_props_label = props.label) !== null && _props_label !== void 0 ? _props_label : "Test Entry",
6941
- key: (_props_key = props.key) !== null && _props_key !== void 0 ? _props_key : props.name,
6942
- type: expectedType !== null && expectedType !== void 0 ? expectedType : "string",
6943
- valuesLoading: false,
6944
- value: props.value,
6945
- onValueChange: function(val, metadata) {
6946
- props.onChange && props.onChange(val);
5176
+ var OPERATORS_BY_TYPE = {
5177
+ string: [
5178
+ {
5179
+ value: "==",
5180
+ label: "equals (==)"
6947
5181
  },
6948
- expectedType: expectedType,
6949
- fieldName: (_props_name = props.name) !== null && _props_name !== void 0 ? _props_name : props.key,
6950
- children: function(param) {
6951
- var onExpressionClick = param.onExpressionClick, onChangeExpression = param.onChange, expressionValue = param.value, localInput = param.localInput, setLocalInput = param.setLocalInput;
6952
- var _props_placeholder;
6953
- return /* @__PURE__ */ React4__namespace.createElement("div", {
6954
- className: "uii:relative uii:text-xs uii:mt-0.5"
6955
- }, /* @__PURE__ */ React4__namespace.createElement(Input, {
6956
- type: "text",
6957
- value: localInput,
6958
- onChange: function(e) {
6959
- setLocalInput(e.target.value);
6960
- onChangeExpression(e.target.value);
6961
- },
6962
- placeholder: (_props_placeholder = props.placeholder) !== null && _props_placeholder !== void 0 ? _props_placeholder : "Enter value..."
6963
- }), /* @__PURE__ */ React4__namespace.createElement("div", {
6964
- className: "uii:flex uii:bg-white uii:border-white/40 uii:border-l-8 uii:items-center uii:gap-1 uii:absolute uii:right-1.5 uii:top-2.5 uii:cursor-pointer uii:truncate",
6965
- onClick: function() {
6966
- return onExpressionClick();
6967
- }
6968
- }, /* @__PURE__ */ React4__namespace.createElement("span", {
6969
- className: "uii:border-l uii:border-gray-200 uii:px-2"
6970
- }, "Custom Expression")));
5182
+ {
5183
+ value: "!=",
5184
+ label: "not equals (!=)"
5185
+ },
5186
+ {
5187
+ value: "contains",
5188
+ label: "contains"
5189
+ },
5190
+ {
5191
+ value: "startsWith",
5192
+ label: "starts with"
5193
+ },
5194
+ {
5195
+ value: "endsWith",
5196
+ label: "ends with"
6971
5197
  }
6972
- });
6973
- }
6974
- // ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
6975
- var falsyToString = function(value) {
6976
- return typeof value === "boolean" ? "".concat(value) : value === 0 ? "0" : value;
6977
- };
6978
- var cx = clsx;
6979
- var cva = function(base, config) {
6980
- return function(props) {
6981
- var _config_compoundVariants;
6982
- if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
6983
- var variants = config.variants, defaultVariants = config.defaultVariants;
6984
- var getVariantClassNames = Object.keys(variants).map(function(variant) {
6985
- var variantProp = props === null || props === void 0 ? void 0 : props[variant];
6986
- var defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
6987
- if (variantProp === null) return null;
6988
- var variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
6989
- return variants[variant][variantKey];
6990
- });
6991
- var propsWithoutUndefined = props && Object.entries(props).reduce(function(acc, param) {
6992
- var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
6993
- if (value === void 0) {
6994
- return acc;
6995
- }
6996
- acc[key] = value;
6997
- return acc;
6998
- }, {});
6999
- var getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce(function(acc, param) {
7000
- var cvClass = param.class, cvClassName = param.className, compoundVariantOptions = _object_without_properties(param, [
7001
- "class",
7002
- "className"
7003
- ]);
7004
- return Object.entries(compoundVariantOptions).every(function(param2) {
7005
- var _param2 = _sliced_to_array(param2, 2), key = _param2[0], value = _param2[1];
7006
- return Array.isArray(value) ? value.includes(_object_spread({}, defaultVariants, propsWithoutUndefined)[key]) : _object_spread({}, defaultVariants, propsWithoutUndefined)[key] === value;
7007
- }) ? _to_consumable_array(acc).concat([
7008
- cvClass,
7009
- cvClassName
7010
- ]) : acc;
7011
- }, []);
7012
- return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
7013
- };
5198
+ ],
5199
+ number: [
5200
+ {
5201
+ value: "==",
5202
+ label: "equals (==)"
5203
+ },
5204
+ {
5205
+ value: "!=",
5206
+ label: "not equals (!=)"
5207
+ },
5208
+ {
5209
+ value: "<",
5210
+ label: "less than (<)"
5211
+ },
5212
+ {
5213
+ value: ">",
5214
+ label: "greater than (>)"
5215
+ },
5216
+ {
5217
+ value: "<=",
5218
+ label: "less than or equal (<=)"
5219
+ },
5220
+ {
5221
+ value: ">=",
5222
+ label: "greater than or equal (>=)"
5223
+ }
5224
+ ],
5225
+ boolean: [
5226
+ {
5227
+ value: "==",
5228
+ label: "equals (==)"
5229
+ },
5230
+ {
5231
+ value: "!=",
5232
+ label: "not equals (!=)"
5233
+ }
5234
+ ],
5235
+ any: [
5236
+ {
5237
+ value: "==",
5238
+ label: "equals (==)"
5239
+ },
5240
+ {
5241
+ value: "!=",
5242
+ label: "not equals (!=)"
5243
+ }
5244
+ ]
7014
5245
  };
7015
- // src/components/ui/button.tsx
7016
- var buttonVariants = cva("ui:inline-flex ui:items-center ui:justify-center ui:gap-2 ui:whitespace-nowrap ui:rounded-sm ui:text-sm ui:font-medium ui:transition-[color,box-shadow] ui:disabled:pointer-events-none ui:disabled:opacity-50 ui:[&_svg]:pointer-events-none ui:[&_svg:not([class*=size-])]:size-4 ui:shrink-0 ui:[&_svg]:shrink-0 ui:outline-none ui:focus-visible:border-ring ui:focus-visible:ring-ring/50 ui:focus-visible:ring-[3px] ui:aria-invalid:ring-destructive/20 ui:dark:aria-invalid:ring-destructive/40 ui:aria-invalid:border-destructive ui:cursor-pointer", {
7017
- variants: {
7018
- variant: {
7019
- default: "ui:bg-primary ui:text-primary-foreground ui:shadow-xs ui:hover:bg-primary/90 ui:select-none",
7020
- destructive: "ui:bg-destructive ui:text-white ui:shadow-xs ui:hover:bg-destructive/90 ui:focus-visible:ring-destructive/20 ui:dark:focus-visible:ring-destructive/40",
7021
- outline: "ui:border ui:border-input ui:bg-background ui:shadow-xs ui:hover:bg-accent ui:hover:text-accent-foreground",
7022
- secondary: "ui:bg-secondary ui:text-secondary-foreground ui:shadow-xs ui:hover:bg-secondary/80",
7023
- ghost: "ui:hover:bg-accent ui:hover:text-accent-foreground",
7024
- link: "ui:text-primary ui:underline-offset-4 ui:hover:underline"
5246
+ function getOperatorsForType(type) {
5247
+ var _OPERATORS_BY_TYPE_type, _ref;
5248
+ return (_ref = (_OPERATORS_BY_TYPE_type = OPERATORS_BY_TYPE[type]) !== null && _OPERATORS_BY_TYPE_type !== void 0 ? _OPERATORS_BY_TYPE_type : OPERATORS_BY_TYPE.any) !== null && _ref !== void 0 ? _ref : [
5249
+ {
5250
+ value: "==",
5251
+ label: "equals (==)"
7025
5252
  },
7026
- size: {
7027
- default: "ui:h-9 ui:px-4 ui:py-2 ui:has-[>svg]:px-3",
7028
- sm: "ui:h-8 ui:rounded-sm ui:gap-1.5 ui:px-3 ui:has-[>svg]:px-2.5",
7029
- lg: "ui:h-10 ui:rounded-sm ui:px-6 ui:has-[>svg]:px-4",
7030
- icon: "ui:size-9"
5253
+ {
5254
+ value: "!=",
5255
+ label: "not equals (!=)"
7031
5256
  }
7032
- },
7033
- defaultVariants: {
7034
- variant: "default",
7035
- size: "default"
7036
- }
7037
- });
7038
- function Button(_param) {
7039
- var className = _param.className, variant = _param.variant, size = _param.size, _param_asChild = _param.asChild, asChild = _param_asChild === void 0 ? false : _param_asChild, props = _object_without_properties(_param, [
7040
- "className",
7041
- "variant",
7042
- "size",
7043
- "asChild"
7044
- ]);
7045
- var Comp = asChild ? reactSlot.Slot : "button";
7046
- return /* @__PURE__ */ React4__namespace.createElement(Comp, _object_spread({
7047
- "data-slot": "button",
7048
- className: cn(buttonVariants({
7049
- variant: variant,
7050
- size: size,
7051
- className: className
7052
- }))
7053
- }, props));
5257
+ ];
7054
5258
  }
7055
5259
  exports.Button = Button;
7056
- exports.Input = Input2;
7057
- exports.buttonVariants = buttonVariants; //# sourceMappingURL=index.cjs.map
5260
+ exports.buttonVariants = buttonVariants;
5261
+ exports.fields = fields_exports; //# sourceMappingURL=index.cjs.map
7058
5262
  //# sourceMappingURL=index.cjs.map