@wealthx/shadcn 1.5.3 → 1.5.5

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
@@ -13538,6 +13538,7 @@ function CsvImportModal({
13538
13538
  onFileClear,
13539
13539
  onNext,
13540
13540
  onDownloadTemplate,
13541
+ uploadDescription,
13541
13542
  isLoading = false,
13542
13543
  className
13543
13544
  }) {
@@ -13571,7 +13572,7 @@ function CsvImportModal({
13571
13572
  {
13572
13573
  size: "lg",
13573
13574
  label: "Drag & drop or click to upload",
13574
- description: "Supports .csv files only. Max 10 MB.",
13575
+ description: uploadDescription != null ? uploadDescription : "Supports .csv files only. Max 10 MB.",
13575
13576
  accept: ".csv",
13576
13577
  onFileChange: (file) => file && (onFileSelect == null ? void 0 : onFileSelect(file))
13577
13578
  }
@@ -13922,46 +13923,38 @@ var AlertSharingType = /* @__PURE__ */ ((AlertSharingType2) => {
13922
13923
 
13923
13924
  // src/components/ui/contact-alert-dialog/config.ts
13924
13925
  var import_ui = require("@react-awesome-query-builder/ui");
13926
+ var NUMERIC_OPERATORS_DEFAULT = [
13927
+ "equal",
13928
+ "less",
13929
+ "less_or_equal",
13930
+ "greater",
13931
+ "greater_or_equal"
13932
+ ];
13925
13933
  var ALERT_QUERY_FIELDS = [
13926
13934
  {
13927
13935
  key: "userMetric.max_loan_amount",
13928
13936
  label: "Borrowing Capacity",
13929
13937
  type: "number",
13930
13938
  unit: "dollar",
13931
- operators: [
13932
- "equal",
13933
- "less",
13934
- "less_or_equal",
13935
- "greater",
13936
- "greater_or_equal",
13937
- "between"
13938
- ]
13939
+ operators: NUMERIC_OPERATORS_DEFAULT,
13940
+ min: 0
13939
13941
  },
13940
13942
  {
13941
13943
  key: "userMetric.debt_outstanding",
13942
13944
  label: "Outstanding Debt",
13943
13945
  type: "number",
13944
13946
  unit: "dollar",
13945
- operators: [
13946
- "equal",
13947
- "less",
13948
- "less_or_equal",
13949
- "greater",
13950
- "greater_or_equal"
13951
- ]
13947
+ operators: NUMERIC_OPERATORS_DEFAULT,
13948
+ min: 0
13952
13949
  },
13953
13950
  {
13954
13951
  key: "userMetric.lvr",
13955
13952
  label: "Current LVR",
13956
13953
  type: "number",
13957
13954
  unit: "percent",
13958
- operators: [
13959
- "equal",
13960
- "less",
13961
- "less_or_equal",
13962
- "greater",
13963
- "greater_or_equal"
13964
- ]
13955
+ operators: NUMERIC_OPERATORS_DEFAULT,
13956
+ min: 0,
13957
+ max: 100
13965
13958
  },
13966
13959
  {
13967
13960
  key: "userMetric.has_met_buying_goal",
@@ -13973,116 +13966,76 @@ var ALERT_QUERY_FIELDS = [
13973
13966
  label: "Excess Monthly Surplus",
13974
13967
  type: "number",
13975
13968
  unit: "dollar",
13976
- operators: [
13977
- "equal",
13978
- "less",
13979
- "less_or_equal",
13980
- "greater",
13981
- "greater_or_equal"
13982
- ]
13969
+ operators: NUMERIC_OPERATORS_DEFAULT,
13970
+ min: 0
13983
13971
  },
13984
13972
  {
13985
13973
  key: "userMetric.equity",
13986
13974
  label: "Equity Amount",
13987
13975
  type: "number",
13988
13976
  unit: "dollar",
13989
- operators: [
13990
- "equal",
13991
- "less",
13992
- "less_or_equal",
13993
- "greater",
13994
- "greater_or_equal"
13995
- ]
13977
+ operators: NUMERIC_OPERATORS_DEFAULT,
13978
+ min: 0
13996
13979
  },
13997
13980
  {
13998
13981
  key: "userMetric.max_debt_interest_rate",
13999
13982
  label: "Max Debt Interest Rate",
14000
13983
  type: "number",
14001
13984
  unit: "percent",
14002
- operators: [
14003
- "equal",
14004
- "less",
14005
- "less_or_equal",
14006
- "greater",
14007
- "greater_or_equal"
14008
- ]
13985
+ operators: NUMERIC_OPERATORS_DEFAULT,
13986
+ min: 0,
13987
+ max: 100
14009
13988
  },
14010
13989
  {
14011
13990
  key: "userMetric.min_debt_interest_rate",
14012
13991
  label: "Min Debt Interest Rate",
14013
13992
  type: "number",
14014
13993
  unit: "percent",
14015
- operators: [
14016
- "equal",
14017
- "less",
14018
- "less_or_equal",
14019
- "greater",
14020
- "greater_or_equal"
14021
- ]
13994
+ operators: NUMERIC_OPERATORS_DEFAULT,
13995
+ min: 0,
13996
+ max: 100
14022
13997
  }
14023
13998
  ];
14024
- var ALL_NUMERIC_OPERATORS = [
14025
- "equal",
14026
- "not_equal",
14027
- "less",
14028
- "less_or_equal",
14029
- "greater",
14030
- "greater_or_equal",
14031
- "between"
14032
- ];
13999
+ var ALL_NUMERIC_OPERATORS = NUMERIC_OPERATORS_DEFAULT;
14033
14000
  var BOOLEAN_OPERATORS = ["equal"];
14034
14001
  var OPERATOR_LABELS = {
14035
14002
  equal: "=",
14036
- not_equal: "\u2260",
14037
14003
  less: "<",
14038
14004
  less_or_equal: "\u2264",
14039
14005
  greater: ">",
14040
- greater_or_equal: "\u2265",
14041
- between: "between"
14006
+ greater_or_equal: "\u2265"
14042
14007
  };
14043
14008
  var SEVERITY_LABELS = {
14044
- INSIGHT: "Insight",
14009
+ HEALTHY: "Healthy",
14045
14010
  WATCH: "Watch",
14046
14011
  NEED_ACTION: "Need Action"
14047
14012
  };
14048
14013
  var QB_CONFIG = __spreadProps(__spreadValues({}, import_ui.BasicConfig), {
14014
+ settings: __spreadProps(__spreadValues({}, import_ui.BasicConfig.settings), {
14015
+ maxNesting: 3,
14016
+ maxNumberOfRules: 5
14017
+ }),
14049
14018
  fields: {
14050
14019
  "userMetric.max_loan_amount": {
14051
14020
  label: "Borrowing Capacity",
14052
14021
  type: "number",
14053
- operators: [
14054
- "equal",
14055
- "less",
14056
- "less_or_equal",
14057
- "greater",
14058
- "greater_or_equal",
14059
- "between"
14060
- ],
14061
- valueSources: ["value"]
14022
+ operators: NUMERIC_OPERATORS_DEFAULT,
14023
+ valueSources: ["value"],
14024
+ fieldSettings: { min: 0 }
14062
14025
  },
14063
14026
  "userMetric.debt_outstanding": {
14064
14027
  label: "Outstanding Debt",
14065
14028
  type: "number",
14066
- operators: [
14067
- "equal",
14068
- "less",
14069
- "less_or_equal",
14070
- "greater",
14071
- "greater_or_equal"
14072
- ],
14073
- valueSources: ["value"]
14029
+ operators: NUMERIC_OPERATORS_DEFAULT,
14030
+ valueSources: ["value"],
14031
+ fieldSettings: { min: 0 }
14074
14032
  },
14075
14033
  "userMetric.lvr": {
14076
14034
  label: "Current LVR",
14077
14035
  type: "number",
14078
- operators: [
14079
- "equal",
14080
- "less",
14081
- "less_or_equal",
14082
- "greater",
14083
- "greater_or_equal"
14084
- ],
14085
- valueSources: ["value"]
14036
+ operators: NUMERIC_OPERATORS_DEFAULT,
14037
+ valueSources: ["value"],
14038
+ fieldSettings: { min: 0, max: 100 }
14086
14039
  },
14087
14040
  "userMetric.has_met_buying_goal": {
14088
14041
  label: "Has Met Buying Goal",
@@ -14093,50 +14046,30 @@ var QB_CONFIG = __spreadProps(__spreadValues({}, import_ui.BasicConfig), {
14093
14046
  "userMetric.excess_monthly_surplus": {
14094
14047
  label: "Excess Monthly Surplus",
14095
14048
  type: "number",
14096
- operators: [
14097
- "equal",
14098
- "less",
14099
- "less_or_equal",
14100
- "greater",
14101
- "greater_or_equal"
14102
- ],
14103
- valueSources: ["value"]
14049
+ operators: NUMERIC_OPERATORS_DEFAULT,
14050
+ valueSources: ["value"],
14051
+ fieldSettings: { min: 0 }
14104
14052
  },
14105
14053
  "userMetric.equity": {
14106
14054
  label: "Equity Amount",
14107
14055
  type: "number",
14108
- operators: [
14109
- "equal",
14110
- "less",
14111
- "less_or_equal",
14112
- "greater",
14113
- "greater_or_equal"
14114
- ],
14115
- valueSources: ["value"]
14056
+ operators: NUMERIC_OPERATORS_DEFAULT,
14057
+ valueSources: ["value"],
14058
+ fieldSettings: { min: 0 }
14116
14059
  },
14117
14060
  "userMetric.max_debt_interest_rate": {
14118
14061
  label: "Max Debt Interest Rate",
14119
14062
  type: "number",
14120
- operators: [
14121
- "equal",
14122
- "less",
14123
- "less_or_equal",
14124
- "greater",
14125
- "greater_or_equal"
14126
- ],
14127
- valueSources: ["value"]
14063
+ operators: NUMERIC_OPERATORS_DEFAULT,
14064
+ valueSources: ["value"],
14065
+ fieldSettings: { min: 0, max: 100 }
14128
14066
  },
14129
14067
  "userMetric.min_debt_interest_rate": {
14130
14068
  label: "Min Debt Interest Rate",
14131
14069
  type: "number",
14132
- operators: [
14133
- "equal",
14134
- "less",
14135
- "less_or_equal",
14136
- "greater",
14137
- "greater_or_equal"
14138
- ],
14139
- valueSources: ["value"]
14070
+ operators: NUMERIC_OPERATORS_DEFAULT,
14071
+ valueSources: ["value"],
14072
+ fieldSettings: { min: 0, max: 100 }
14140
14073
  }
14141
14074
  }
14142
14075
  });
@@ -14187,14 +14120,13 @@ function parseCommas(display) {
14187
14120
  return display.replace(/[^\d.]/g, "").replace(/(\..*)\./g, "$1");
14188
14121
  }
14189
14122
  function ruleSummary(ruleProps, fields) {
14190
- var _a, _b, _c, _d, _e, _f;
14123
+ var _a, _b, _c, _d, _e;
14191
14124
  const field = (_a = ruleProps == null ? void 0 : ruleProps.field) != null ? _a : "";
14192
14125
  const operator = (_b = ruleProps == null ? void 0 : ruleProps.operator) != null ? _b : "equal";
14193
14126
  const value0 = (_c = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _c[0];
14194
- const value1 = (_d = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _d[1];
14195
14127
  const fieldDef = fields.find((f) => f.key === field);
14196
- const fieldLabel = (_e = fieldDef == null ? void 0 : fieldDef.label) != null ? _e : field;
14197
- const opLabel = (_f = OPERATOR_LABELS[operator]) != null ? _f : operator;
14128
+ const fieldLabel = (_d = fieldDef == null ? void 0 : fieldDef.label) != null ? _d : field;
14129
+ const opLabel = (_e = OPERATOR_LABELS[operator]) != null ? _e : operator;
14198
14130
  const formatVal = (v) => {
14199
14131
  if (v === null || v === void 0) return "\u2026";
14200
14132
  if ((fieldDef == null ? void 0 : fieldDef.type) === "boolean") return v ? "Yes" : "No";
@@ -14205,9 +14137,6 @@ function ruleSummary(ruleProps, fields) {
14205
14137
  if ((fieldDef == null ? void 0 : fieldDef.unit) === "percent") return `${n}%`;
14206
14138
  return String(v);
14207
14139
  };
14208
- if (operator === "between") {
14209
- return `${fieldLabel} between ${formatVal(value0)} and ${formatVal(value1)}`;
14210
- }
14211
14140
  return `${fieldLabel} ${opLabel} ${formatVal(value0)}`;
14212
14141
  }
14213
14142
  function checkGroupValid(children) {
@@ -14426,8 +14355,22 @@ function ValueInput({
14426
14355
  value,
14427
14356
  onChange,
14428
14357
  unit,
14358
+ min,
14359
+ max,
14429
14360
  placeholder = "0"
14430
14361
  }) {
14362
+ function handleChange(raw) {
14363
+ const parsed = parseCommas(raw);
14364
+ if (parsed === "") {
14365
+ onChange("");
14366
+ return;
14367
+ }
14368
+ const n = parseFloat(parsed);
14369
+ if (Number.isNaN(n)) return;
14370
+ if (min !== void 0 && n < min) return;
14371
+ if (max !== void 0 && n > max) return;
14372
+ onChange(parsed);
14373
+ }
14431
14374
  return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(InputGroup, { className: "w-36", children: [
14432
14375
  unit === "dollar" && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(InputGroupAddon, { align: "inline-start", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(InputGroupText, { children: "$" }) }),
14433
14376
  /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
@@ -14436,7 +14379,7 @@ function ValueInput({
14436
14379
  type: "text",
14437
14380
  inputMode: "numeric",
14438
14381
  value: formatWithCommas(value),
14439
- onChange: (e) => onChange(parseCommas(e.target.value)),
14382
+ onChange: (e) => handleChange(e.target.value),
14440
14383
  placeholder
14441
14384
  }
14442
14385
  ),
@@ -14451,14 +14394,13 @@ function RuleEditorFields({
14451
14394
  longestFieldLabel,
14452
14395
  longestOperatorLabel
14453
14396
  }) {
14454
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
14397
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
14455
14398
  const field = (_c = (_b = ruleProps == null ? void 0 : ruleProps.field) != null ? _b : (_a = fields[0]) == null ? void 0 : _a.key) != null ? _c : "";
14456
14399
  const operator = (_d = ruleProps == null ? void 0 : ruleProps.operator) != null ? _d : "greater_or_equal";
14457
14400
  const value0 = (_e = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _e[0];
14458
- const value1 = (_f = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _f[1];
14459
- const fieldDef = (_g = fields.find((f) => f.key === field)) != null ? _g : fields[0];
14401
+ const fieldDef = (_f = fields.find((f) => f.key === field)) != null ? _f : fields[0];
14460
14402
  const isBooleanField = (fieldDef == null ? void 0 : fieldDef.type) === "boolean";
14461
- const availableOperators = isBooleanField ? BOOLEAN_OPERATORS : (_h = fieldDef == null ? void 0 : fieldDef.operators) != null ? _h : ALL_NUMERIC_OPERATORS;
14403
+ const availableOperators = isBooleanField ? BOOLEAN_OPERATORS : (_g = fieldDef == null ? void 0 : fieldDef.operators) != null ? _g : ALL_NUMERIC_OPERATORS;
14462
14404
  function handleFieldChange(key) {
14463
14405
  actions.setField(path, key);
14464
14406
  }
@@ -14487,7 +14429,7 @@ function RuleEditorFields({
14487
14429
  value: field,
14488
14430
  onValueChange: (v) => handleFieldChange(v),
14489
14431
  children: [
14490
- /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectValue, { children: (_j = (_i = fields.find((f) => f.key === field)) == null ? void 0 : _i.label) != null ? _j : field }) }),
14432
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectValue, { children: (_i = (_h = fields.find((f) => f.key === field)) == null ? void 0 : _h.label) != null ? _i : field }) }),
14491
14433
  /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectContent, { children: fields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectItem, { value: f.key, children: f.label }, f.key)) })
14492
14434
  ]
14493
14435
  }
@@ -14498,7 +14440,7 @@ function RuleEditorFields({
14498
14440
  value: operator,
14499
14441
  onValueChange: (v) => handleOperatorChange(v),
14500
14442
  children: [
14501
- /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectValue, { children: (_k = OPERATOR_LABELS[operator]) != null ? _k : operator }) }),
14443
+ /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectValue, { children: (_j = OPERATOR_LABELS[operator]) != null ? _j : operator }) }),
14502
14444
  /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectContent, { children: availableOperators.map((op) => /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectItem, { value: op, children: OPERATOR_LABELS[op] }, op)) })
14503
14445
  ]
14504
14446
  }
@@ -14516,27 +14458,16 @@ function RuleEditorFields({
14516
14458
  ] })
14517
14459
  ]
14518
14460
  }
14519
- ) : /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
14520
- /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14521
- ValueInput,
14522
- {
14523
- value: valStr(value0),
14524
- onChange: (v) => handleValueChange(0, v),
14525
- unit: fieldDef == null ? void 0 : fieldDef.unit
14526
- }
14527
- ),
14528
- operator === "between" && /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_jsx_runtime76.Fragment, { children: [
14529
- /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "text-xs text-muted-foreground", children: "and" }),
14530
- /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14531
- ValueInput,
14532
- {
14533
- value: valStr(value1),
14534
- onChange: (v) => handleValueChange(1, v),
14535
- unit: fieldDef == null ? void 0 : fieldDef.unit
14536
- }
14537
- )
14538
- ] })
14539
- ] })
14461
+ ) : /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14462
+ ValueInput,
14463
+ {
14464
+ value: valStr(value0),
14465
+ onChange: (v) => handleValueChange(0, v),
14466
+ unit: fieldDef == null ? void 0 : fieldDef.unit,
14467
+ min: fieldDef == null ? void 0 : fieldDef.min,
14468
+ max: fieldDef == null ? void 0 : fieldDef.max
14469
+ }
14470
+ )
14540
14471
  ] });
14541
14472
  }
14542
14473
  function RuleAccordionItem({
@@ -14878,6 +14809,7 @@ function ContactAlertDialog({
14878
14809
  isCompanyAdmin = false,
14879
14810
  initialShareAcrossCompany = false,
14880
14811
  onSave,
14812
+ onError,
14881
14813
  isLoading = false,
14882
14814
  className
14883
14815
  }) {
@@ -14901,10 +14833,17 @@ function ContactAlertDialog({
14901
14833
  const canSave = name.trim().length > 0 && hasValidRule && !isLoading;
14902
14834
  function handleSave() {
14903
14835
  if (!canSave) return;
14836
+ let filterSegment;
14837
+ try {
14838
+ filterSegment = import_ui4.Utils.sanitizeTree(tree, QB_CONFIG).fixedTree;
14839
+ } catch (e) {
14840
+ onError == null ? void 0 : onError(e instanceof Error ? e : new Error(String(e)));
14841
+ return;
14842
+ }
14904
14843
  onSave({
14905
14844
  name: name.trim(),
14906
14845
  severity,
14907
- filterSegment: import_ui4.Utils.sanitizeTree(tree, QB_CONFIG).fixedTree,
14846
+ filterSegment,
14908
14847
  sharingType: shareAcrossCompany ? "COMPANY" /* COMPANY */ : "PRIVATE" /* PRIVATE */
14909
14848
  });
14910
14849
  }
@@ -14920,7 +14859,7 @@ function ContactAlertDialog({
14920
14859
  size: "sm",
14921
14860
  value: severity,
14922
14861
  onValueChange: (v) => v && setSeverity(v),
14923
- children: ["NEED_ACTION", "WATCH", "INSIGHT"].map((s) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ToggleGroupItem, { value: s, children: SEVERITY_LABELS[s] }, s))
14862
+ children: ["NEED_ACTION", "WATCH", "HEALTHY"].map((s) => /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(ToggleGroupItem, { value: s, children: SEVERITY_LABELS[s] }, s))
14924
14863
  }
14925
14864
  )
14926
14865
  ] }),
@@ -15235,6 +15174,7 @@ function FilePreviewDialog({
15235
15174
  staffOptions,
15236
15175
  selectedStaffId,
15237
15176
  onStaffSelect,
15177
+ staffSelector,
15238
15178
  className
15239
15179
  }) {
15240
15180
  const [page, setPage] = React35.useState(0);
@@ -15245,7 +15185,8 @@ function FilePreviewDialog({
15245
15185
  const pagedRows = rows.slice(page * pageSize, (page + 1) * pageSize);
15246
15186
  const pageStart = page * pageSize;
15247
15187
  const isImporting = state === "importing";
15248
- const hasStaffSelector = !!staffOptions && staffOptions.length > 0;
15188
+ const hasBuiltInStaffSelector = !!staffOptions && staffOptions.length > 0;
15189
+ const hasStaffSelector = !!staffSelector || hasBuiltInStaffSelector;
15249
15190
  const canImport = state === "preview" && rows.length > 0 && (!hasStaffSelector || !!selectedStaffId);
15250
15191
  const successCount = rows.filter((r) => r._status === "success").length;
15251
15192
  const failedCount = rows.filter((r) => r._status === "failed").length;
@@ -15282,7 +15223,7 @@ function FilePreviewDialog({
15282
15223
  }
15283
15224
  ),
15284
15225
  state === "preview" && /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)(import_jsx_runtime80.Fragment, { children: [
15285
- hasStaffSelector && /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "flex flex-col gap-1", children: [
15226
+ staffSelector ? staffSelector : hasBuiltInStaffSelector && /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "flex flex-col gap-1", children: [
15286
15227
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("label", { className: "text-label-medium text-foreground", children: [
15287
15228
  "Assign staff",
15288
15229
  " ",
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  ContactAlertDialog,
5
5
  ContactAlertQueryBuilder,
6
6
  createAlertTree
7
- } from "./chunk-G2EWIP2N.mjs";
7
+ } from "./chunk-CKPEFZNH.mjs";
8
8
  import {
9
9
  TransactionsExpenseCategoriesDoughnutChart
10
10
  } from "./chunk-KB7MZMED.mjs";
@@ -181,7 +181,7 @@ import {
181
181
  } from "./chunk-KLJLDNCA.mjs";
182
182
  import {
183
183
  FilePreviewDialog
184
- } from "./chunk-PX4M67XQ.mjs";
184
+ } from "./chunk-HXU5JGLQ.mjs";
185
185
  import {
186
186
  Progress
187
187
  } from "./chunk-JPGL36WQ.mjs";
@@ -229,7 +229,7 @@ import {
229
229
  } from "./chunk-2A53WPEC.mjs";
230
230
  import {
231
231
  CsvImportModal
232
- } from "./chunk-CUSHAIUL.mjs";
232
+ } from "./chunk-QBPNYXTI.mjs";
233
233
  import {
234
234
  InputGroup,
235
235
  InputGroupAddon,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wealthx/shadcn",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./src/index.ts",
@@ -70,13 +70,30 @@ function ValueInput({
70
70
  value,
71
71
  onChange,
72
72
  unit,
73
+ min,
74
+ max,
73
75
  placeholder = "0",
74
76
  }: {
75
77
  value: string;
76
78
  onChange: (v: string) => void;
77
79
  unit?: "dollar" | "percent";
80
+ min?: number;
81
+ max?: number;
78
82
  placeholder?: string;
79
83
  }) {
84
+ function handleChange(raw: string) {
85
+ const parsed = parseCommas(raw);
86
+ if (parsed === "") {
87
+ onChange("");
88
+ return;
89
+ }
90
+ const n = parseFloat(parsed);
91
+ if (Number.isNaN(n)) return;
92
+ if (min !== undefined && n < min) return;
93
+ if (max !== undefined && n > max) return;
94
+ onChange(parsed);
95
+ }
96
+
80
97
  return (
81
98
  <InputGroup className="w-36">
82
99
  {unit === "dollar" && (
@@ -88,7 +105,7 @@ function ValueInput({
88
105
  type="text"
89
106
  inputMode="numeric"
90
107
  value={formatWithCommas(value)}
91
- onChange={(e) => onChange(parseCommas(e.target.value))}
108
+ onChange={(e) => handleChange(e.target.value)}
92
109
  placeholder={placeholder}
93
110
  />
94
111
  {unit === "percent" && (
@@ -123,7 +140,6 @@ function RuleEditorFields({
123
140
  const field: string = ruleProps?.field ?? fields[0]?.key ?? "";
124
141
  const operator: string = ruleProps?.operator ?? "greater_or_equal";
125
142
  const value0 = ruleProps?.value?.[0];
126
- const value1 = ruleProps?.value?.[1];
127
143
 
128
144
  const fieldDef = fields.find((f) => f.key === field) ?? fields[0];
129
145
  const isBooleanField = fieldDef?.type === "boolean";
@@ -217,23 +233,13 @@ function RuleEditorFields({
217
233
  </SelectContent>
218
234
  </Select>
219
235
  ) : (
220
- <>
221
- <ValueInput
222
- value={valStr(value0)}
223
- onChange={(v) => handleValueChange(0, v)}
224
- unit={fieldDef?.unit}
225
- />
226
- {operator === "between" && (
227
- <>
228
- <span className="text-xs text-muted-foreground">and</span>
229
- <ValueInput
230
- value={valStr(value1)}
231
- onChange={(v) => handleValueChange(1, v)}
232
- unit={fieldDef?.unit}
233
- />
234
- </>
235
- )}
236
- </>
236
+ <ValueInput
237
+ value={valStr(value0)}
238
+ onChange={(v) => handleValueChange(0, v)}
239
+ unit={fieldDef?.unit}
240
+ min={fieldDef?.min}
241
+ max={fieldDef?.max}
242
+ />
237
243
  )}
238
244
  </div>
239
245
  );