@trops/dash-react 1.0.38 → 1.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3181,6 +3181,39 @@ var WidgetChrome = function WidgetChrome(_ref) {
3181
3181
  });
3182
3182
  };
3183
3183
 
3184
+ /**
3185
+ * Dispatch an onChange callback in a way that supports both signatures:
3186
+ *
3187
+ * - dash-style: (value, event) => ...
3188
+ * - React-idiomatic: (event) => event.target.value
3189
+ *
3190
+ * The dash inputs (InputText / TextArea / SearchInput) historically passed
3191
+ * the unwrapped string value as the first arg. AI-generated widget code,
3192
+ * trained on plain React, almost always writes `(e) => e.target.value`
3193
+ * instead — which throws "Cannot read properties of undefined (reading
3194
+ * 'value')" because `e` is the string and `e.target` is undefined.
3195
+ *
3196
+ * To support both without a breaking change we inspect the handler's
3197
+ * source once per call: if it accesses `.target`, route the raw event
3198
+ * (React-idiomatic); otherwise pass `(value, event)` (legacy dash style).
3199
+ * Property names survive minification, so the check works on bundled
3200
+ * code too.
3201
+ */
3202
+ function dispatchInputChange(handler, event) {
3203
+ if (typeof handler !== "function") return;
3204
+ var source = "";
3205
+ try {
3206
+ source = handler.toString();
3207
+ } catch (_unused) {
3208
+ // Bound or native functions throw — fall through as value-style.
3209
+ }
3210
+ if (/\.target\b/.test(source)) {
3211
+ handler(event);
3212
+ } else {
3213
+ handler(event.target.value, event);
3214
+ }
3215
+ }
3216
+
3184
3217
  function _typeof$u(o) { "@babel/helpers - typeof"; return _typeof$u = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$u(o); }
3185
3218
  var _excluded$n = ["label", "value", "onChange", "placeholder", "type", "id", "className", "inputClassName", "autoFocus", "disabled", "backgroundColor", "textColor", "borderColor", "placeholderTextColor", "focusRingColor", "focusBorderColor"];
3186
3219
  function ownKeys$p(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -3253,7 +3286,7 @@ var InputText = function InputText(_ref) {
3253
3286
  type: type,
3254
3287
  value: value,
3255
3288
  onChange: function onChange(event) {
3256
- return _onChange(event.target.value, event);
3289
+ return dispatchInputChange(_onChange, event);
3257
3290
  },
3258
3291
  placeholder: placeholder,
3259
3292
  disabled: disabled,
@@ -3333,7 +3366,7 @@ var TextArea = function TextArea(_ref) {
3333
3366
  rows: rows,
3334
3367
  value: value,
3335
3368
  onChange: function onChange(event) {
3336
- return _onChange(event.target.value, event);
3369
+ return dispatchInputChange(_onChange, event);
3337
3370
  },
3338
3371
  placeholder: placeholder,
3339
3372
  disabled: disabled,
@@ -3822,7 +3855,7 @@ var SearchInput = function SearchInput(_ref) {
3822
3855
  type: "search",
3823
3856
  value: value,
3824
3857
  onChange: function onChange(event) {
3825
- return _onChange(event.target.value, event);
3858
+ return dispatchInputChange(_onChange, event);
3826
3859
  },
3827
3860
  placeholder: placeholder,
3828
3861
  disabled: disabled,