@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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @wealthx/shadcn
2
2
 
3
+ ## 1.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 6ba7ca6: Update query builder
8
+
9
+ ## 1.5.4
10
+
11
+ ### Patch Changes
12
+
13
+ - 16d9edb: Allow custom description and staff select
14
+
3
15
  ## 1.5.3
4
16
 
5
17
  ### Patch Changes
@@ -65,46 +65,38 @@ import {
65
65
  BasicConfig,
66
66
  Utils as QbUtils
67
67
  } from "@react-awesome-query-builder/ui";
68
+ var NUMERIC_OPERATORS_DEFAULT = [
69
+ "equal",
70
+ "less",
71
+ "less_or_equal",
72
+ "greater",
73
+ "greater_or_equal"
74
+ ];
68
75
  var ALERT_QUERY_FIELDS = [
69
76
  {
70
77
  key: "userMetric.max_loan_amount",
71
78
  label: "Borrowing Capacity",
72
79
  type: "number",
73
80
  unit: "dollar",
74
- operators: [
75
- "equal",
76
- "less",
77
- "less_or_equal",
78
- "greater",
79
- "greater_or_equal",
80
- "between"
81
- ]
81
+ operators: NUMERIC_OPERATORS_DEFAULT,
82
+ min: 0
82
83
  },
83
84
  {
84
85
  key: "userMetric.debt_outstanding",
85
86
  label: "Outstanding Debt",
86
87
  type: "number",
87
88
  unit: "dollar",
88
- operators: [
89
- "equal",
90
- "less",
91
- "less_or_equal",
92
- "greater",
93
- "greater_or_equal"
94
- ]
89
+ operators: NUMERIC_OPERATORS_DEFAULT,
90
+ min: 0
95
91
  },
96
92
  {
97
93
  key: "userMetric.lvr",
98
94
  label: "Current LVR",
99
95
  type: "number",
100
96
  unit: "percent",
101
- operators: [
102
- "equal",
103
- "less",
104
- "less_or_equal",
105
- "greater",
106
- "greater_or_equal"
107
- ]
97
+ operators: NUMERIC_OPERATORS_DEFAULT,
98
+ min: 0,
99
+ max: 100
108
100
  },
109
101
  {
110
102
  key: "userMetric.has_met_buying_goal",
@@ -116,116 +108,76 @@ var ALERT_QUERY_FIELDS = [
116
108
  label: "Excess Monthly Surplus",
117
109
  type: "number",
118
110
  unit: "dollar",
119
- operators: [
120
- "equal",
121
- "less",
122
- "less_or_equal",
123
- "greater",
124
- "greater_or_equal"
125
- ]
111
+ operators: NUMERIC_OPERATORS_DEFAULT,
112
+ min: 0
126
113
  },
127
114
  {
128
115
  key: "userMetric.equity",
129
116
  label: "Equity Amount",
130
117
  type: "number",
131
118
  unit: "dollar",
132
- operators: [
133
- "equal",
134
- "less",
135
- "less_or_equal",
136
- "greater",
137
- "greater_or_equal"
138
- ]
119
+ operators: NUMERIC_OPERATORS_DEFAULT,
120
+ min: 0
139
121
  },
140
122
  {
141
123
  key: "userMetric.max_debt_interest_rate",
142
124
  label: "Max Debt Interest Rate",
143
125
  type: "number",
144
126
  unit: "percent",
145
- operators: [
146
- "equal",
147
- "less",
148
- "less_or_equal",
149
- "greater",
150
- "greater_or_equal"
151
- ]
127
+ operators: NUMERIC_OPERATORS_DEFAULT,
128
+ min: 0,
129
+ max: 100
152
130
  },
153
131
  {
154
132
  key: "userMetric.min_debt_interest_rate",
155
133
  label: "Min Debt Interest Rate",
156
134
  type: "number",
157
135
  unit: "percent",
158
- operators: [
159
- "equal",
160
- "less",
161
- "less_or_equal",
162
- "greater",
163
- "greater_or_equal"
164
- ]
136
+ operators: NUMERIC_OPERATORS_DEFAULT,
137
+ min: 0,
138
+ max: 100
165
139
  }
166
140
  ];
167
- var ALL_NUMERIC_OPERATORS = [
168
- "equal",
169
- "not_equal",
170
- "less",
171
- "less_or_equal",
172
- "greater",
173
- "greater_or_equal",
174
- "between"
175
- ];
141
+ var ALL_NUMERIC_OPERATORS = NUMERIC_OPERATORS_DEFAULT;
176
142
  var BOOLEAN_OPERATORS = ["equal"];
177
143
  var OPERATOR_LABELS = {
178
144
  equal: "=",
179
- not_equal: "\u2260",
180
145
  less: "<",
181
146
  less_or_equal: "\u2264",
182
147
  greater: ">",
183
- greater_or_equal: "\u2265",
184
- between: "between"
148
+ greater_or_equal: "\u2265"
185
149
  };
186
150
  var SEVERITY_LABELS = {
187
- INSIGHT: "Insight",
151
+ HEALTHY: "Healthy",
188
152
  WATCH: "Watch",
189
153
  NEED_ACTION: "Need Action"
190
154
  };
191
155
  var QB_CONFIG = __spreadProps(__spreadValues({}, BasicConfig), {
156
+ settings: __spreadProps(__spreadValues({}, BasicConfig.settings), {
157
+ maxNesting: 3,
158
+ maxNumberOfRules: 5
159
+ }),
192
160
  fields: {
193
161
  "userMetric.max_loan_amount": {
194
162
  label: "Borrowing Capacity",
195
163
  type: "number",
196
- operators: [
197
- "equal",
198
- "less",
199
- "less_or_equal",
200
- "greater",
201
- "greater_or_equal",
202
- "between"
203
- ],
204
- valueSources: ["value"]
164
+ operators: NUMERIC_OPERATORS_DEFAULT,
165
+ valueSources: ["value"],
166
+ fieldSettings: { min: 0 }
205
167
  },
206
168
  "userMetric.debt_outstanding": {
207
169
  label: "Outstanding Debt",
208
170
  type: "number",
209
- operators: [
210
- "equal",
211
- "less",
212
- "less_or_equal",
213
- "greater",
214
- "greater_or_equal"
215
- ],
216
- valueSources: ["value"]
171
+ operators: NUMERIC_OPERATORS_DEFAULT,
172
+ valueSources: ["value"],
173
+ fieldSettings: { min: 0 }
217
174
  },
218
175
  "userMetric.lvr": {
219
176
  label: "Current LVR",
220
177
  type: "number",
221
- operators: [
222
- "equal",
223
- "less",
224
- "less_or_equal",
225
- "greater",
226
- "greater_or_equal"
227
- ],
228
- valueSources: ["value"]
178
+ operators: NUMERIC_OPERATORS_DEFAULT,
179
+ valueSources: ["value"],
180
+ fieldSettings: { min: 0, max: 100 }
229
181
  },
230
182
  "userMetric.has_met_buying_goal": {
231
183
  label: "Has Met Buying Goal",
@@ -236,50 +188,30 @@ var QB_CONFIG = __spreadProps(__spreadValues({}, BasicConfig), {
236
188
  "userMetric.excess_monthly_surplus": {
237
189
  label: "Excess Monthly Surplus",
238
190
  type: "number",
239
- operators: [
240
- "equal",
241
- "less",
242
- "less_or_equal",
243
- "greater",
244
- "greater_or_equal"
245
- ],
246
- valueSources: ["value"]
191
+ operators: NUMERIC_OPERATORS_DEFAULT,
192
+ valueSources: ["value"],
193
+ fieldSettings: { min: 0 }
247
194
  },
248
195
  "userMetric.equity": {
249
196
  label: "Equity Amount",
250
197
  type: "number",
251
- operators: [
252
- "equal",
253
- "less",
254
- "less_or_equal",
255
- "greater",
256
- "greater_or_equal"
257
- ],
258
- valueSources: ["value"]
198
+ operators: NUMERIC_OPERATORS_DEFAULT,
199
+ valueSources: ["value"],
200
+ fieldSettings: { min: 0 }
259
201
  },
260
202
  "userMetric.max_debt_interest_rate": {
261
203
  label: "Max Debt Interest Rate",
262
204
  type: "number",
263
- operators: [
264
- "equal",
265
- "less",
266
- "less_or_equal",
267
- "greater",
268
- "greater_or_equal"
269
- ],
270
- valueSources: ["value"]
205
+ operators: NUMERIC_OPERATORS_DEFAULT,
206
+ valueSources: ["value"],
207
+ fieldSettings: { min: 0, max: 100 }
271
208
  },
272
209
  "userMetric.min_debt_interest_rate": {
273
210
  label: "Min Debt Interest Rate",
274
211
  type: "number",
275
- operators: [
276
- "equal",
277
- "less",
278
- "less_or_equal",
279
- "greater",
280
- "greater_or_equal"
281
- ],
282
- valueSources: ["value"]
212
+ operators: NUMERIC_OPERATORS_DEFAULT,
213
+ valueSources: ["value"],
214
+ fieldSettings: { min: 0, max: 100 }
283
215
  }
284
216
  }
285
217
  });
@@ -332,14 +264,13 @@ function parseCommas(display) {
332
264
  return display.replace(/[^\d.]/g, "").replace(/(\..*)\./g, "$1");
333
265
  }
334
266
  function ruleSummary(ruleProps, fields) {
335
- var _a, _b, _c, _d, _e, _f;
267
+ var _a, _b, _c, _d, _e;
336
268
  const field = (_a = ruleProps == null ? void 0 : ruleProps.field) != null ? _a : "";
337
269
  const operator = (_b = ruleProps == null ? void 0 : ruleProps.operator) != null ? _b : "equal";
338
270
  const value0 = (_c = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _c[0];
339
- const value1 = (_d = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _d[1];
340
271
  const fieldDef = fields.find((f) => f.key === field);
341
- const fieldLabel = (_e = fieldDef == null ? void 0 : fieldDef.label) != null ? _e : field;
342
- const opLabel = (_f = OPERATOR_LABELS[operator]) != null ? _f : operator;
272
+ const fieldLabel = (_d = fieldDef == null ? void 0 : fieldDef.label) != null ? _d : field;
273
+ const opLabel = (_e = OPERATOR_LABELS[operator]) != null ? _e : operator;
343
274
  const formatVal = (v) => {
344
275
  if (v === null || v === void 0) return "\u2026";
345
276
  if ((fieldDef == null ? void 0 : fieldDef.type) === "boolean") return v ? "Yes" : "No";
@@ -350,9 +281,6 @@ function ruleSummary(ruleProps, fields) {
350
281
  if ((fieldDef == null ? void 0 : fieldDef.unit) === "percent") return `${n}%`;
351
282
  return String(v);
352
283
  };
353
- if (operator === "between") {
354
- return `${fieldLabel} between ${formatVal(value0)} and ${formatVal(value1)}`;
355
- }
356
284
  return `${fieldLabel} ${opLabel} ${formatVal(value0)}`;
357
285
  }
358
286
  function checkGroupValid(children) {
@@ -384,7 +312,7 @@ import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion";
384
312
  import {
385
313
  Utils as QbUtils3
386
314
  } from "@react-awesome-query-builder/ui";
387
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
315
+ import { jsx, jsxs } from "react/jsx-runtime";
388
316
  function SelectAutoWidth({
389
317
  longestLabel,
390
318
  children
@@ -405,8 +333,22 @@ function ValueInput({
405
333
  value,
406
334
  onChange,
407
335
  unit,
336
+ min,
337
+ max,
408
338
  placeholder = "0"
409
339
  }) {
340
+ function handleChange(raw) {
341
+ const parsed = parseCommas(raw);
342
+ if (parsed === "") {
343
+ onChange("");
344
+ return;
345
+ }
346
+ const n = parseFloat(parsed);
347
+ if (Number.isNaN(n)) return;
348
+ if (min !== void 0 && n < min) return;
349
+ if (max !== void 0 && n > max) return;
350
+ onChange(parsed);
351
+ }
410
352
  return /* @__PURE__ */ jsxs(InputGroup, { className: "w-36", children: [
411
353
  unit === "dollar" && /* @__PURE__ */ jsx(InputGroupAddon, { align: "inline-start", children: /* @__PURE__ */ jsx(InputGroupText, { children: "$" }) }),
412
354
  /* @__PURE__ */ jsx(
@@ -415,7 +357,7 @@ function ValueInput({
415
357
  type: "text",
416
358
  inputMode: "numeric",
417
359
  value: formatWithCommas(value),
418
- onChange: (e) => onChange(parseCommas(e.target.value)),
360
+ onChange: (e) => handleChange(e.target.value),
419
361
  placeholder
420
362
  }
421
363
  ),
@@ -430,14 +372,13 @@ function RuleEditorFields({
430
372
  longestFieldLabel,
431
373
  longestOperatorLabel
432
374
  }) {
433
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
375
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
434
376
  const field = (_c = (_b = ruleProps == null ? void 0 : ruleProps.field) != null ? _b : (_a = fields[0]) == null ? void 0 : _a.key) != null ? _c : "";
435
377
  const operator = (_d = ruleProps == null ? void 0 : ruleProps.operator) != null ? _d : "greater_or_equal";
436
378
  const value0 = (_e = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _e[0];
437
- const value1 = (_f = ruleProps == null ? void 0 : ruleProps.value) == null ? void 0 : _f[1];
438
- const fieldDef = (_g = fields.find((f) => f.key === field)) != null ? _g : fields[0];
379
+ const fieldDef = (_f = fields.find((f) => f.key === field)) != null ? _f : fields[0];
439
380
  const isBooleanField = (fieldDef == null ? void 0 : fieldDef.type) === "boolean";
440
- const availableOperators = isBooleanField ? BOOLEAN_OPERATORS : (_h = fieldDef == null ? void 0 : fieldDef.operators) != null ? _h : ALL_NUMERIC_OPERATORS;
381
+ const availableOperators = isBooleanField ? BOOLEAN_OPERATORS : (_g = fieldDef == null ? void 0 : fieldDef.operators) != null ? _g : ALL_NUMERIC_OPERATORS;
441
382
  function handleFieldChange(key) {
442
383
  actions.setField(path, key);
443
384
  }
@@ -466,7 +407,7 @@ function RuleEditorFields({
466
407
  value: field,
467
408
  onValueChange: (v) => handleFieldChange(v),
468
409
  children: [
469
- /* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { children: (_j = (_i = fields.find((f) => f.key === field)) == null ? void 0 : _i.label) != null ? _j : field }) }),
410
+ /* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { children: (_i = (_h = fields.find((f) => f.key === field)) == null ? void 0 : _h.label) != null ? _i : field }) }),
470
411
  /* @__PURE__ */ jsx(SelectContent, { children: fields.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.key, children: f.label }, f.key)) })
471
412
  ]
472
413
  }
@@ -477,7 +418,7 @@ function RuleEditorFields({
477
418
  value: operator,
478
419
  onValueChange: (v) => handleOperatorChange(v),
479
420
  children: [
480
- /* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { children: (_k = OPERATOR_LABELS[operator]) != null ? _k : operator }) }),
421
+ /* @__PURE__ */ jsx(SelectTrigger, { size: "sm", className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { children: (_j = OPERATOR_LABELS[operator]) != null ? _j : operator }) }),
481
422
  /* @__PURE__ */ jsx(SelectContent, { children: availableOperators.map((op) => /* @__PURE__ */ jsx(SelectItem, { value: op, children: OPERATOR_LABELS[op] }, op)) })
482
423
  ]
483
424
  }
@@ -495,27 +436,16 @@ function RuleEditorFields({
495
436
  ] })
496
437
  ]
497
438
  }
498
- ) : /* @__PURE__ */ jsxs(Fragment, { children: [
499
- /* @__PURE__ */ jsx(
500
- ValueInput,
501
- {
502
- value: valStr(value0),
503
- onChange: (v) => handleValueChange(0, v),
504
- unit: fieldDef == null ? void 0 : fieldDef.unit
505
- }
506
- ),
507
- operator === "between" && /* @__PURE__ */ jsxs(Fragment, { children: [
508
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: "and" }),
509
- /* @__PURE__ */ jsx(
510
- ValueInput,
511
- {
512
- value: valStr(value1),
513
- onChange: (v) => handleValueChange(1, v),
514
- unit: fieldDef == null ? void 0 : fieldDef.unit
515
- }
516
- )
517
- ] })
518
- ] })
439
+ ) : /* @__PURE__ */ jsx(
440
+ ValueInput,
441
+ {
442
+ value: valStr(value0),
443
+ onChange: (v) => handleValueChange(0, v),
444
+ unit: fieldDef == null ? void 0 : fieldDef.unit,
445
+ min: fieldDef == null ? void 0 : fieldDef.min,
446
+ max: fieldDef == null ? void 0 : fieldDef.max
447
+ }
448
+ )
519
449
  ] });
520
450
  }
521
451
  function RuleAccordionItem({
@@ -857,6 +787,7 @@ function ContactAlertDialog({
857
787
  isCompanyAdmin = false,
858
788
  initialShareAcrossCompany = false,
859
789
  onSave,
790
+ onError,
860
791
  isLoading = false,
861
792
  className
862
793
  }) {
@@ -880,10 +811,17 @@ function ContactAlertDialog({
880
811
  const canSave = name.trim().length > 0 && hasValidRule && !isLoading;
881
812
  function handleSave() {
882
813
  if (!canSave) return;
814
+ let filterSegment;
815
+ try {
816
+ filterSegment = QbUtils4.sanitizeTree(tree, QB_CONFIG).fixedTree;
817
+ } catch (e) {
818
+ onError == null ? void 0 : onError(e instanceof Error ? e : new Error(String(e)));
819
+ return;
820
+ }
883
821
  onSave({
884
822
  name: name.trim(),
885
823
  severity,
886
- filterSegment: QbUtils4.sanitizeTree(tree, QB_CONFIG).fixedTree,
824
+ filterSegment,
887
825
  sharingType: shareAcrossCompany ? "COMPANY" /* COMPANY */ : "PRIVATE" /* PRIVATE */
888
826
  });
889
827
  }
@@ -899,7 +837,7 @@ function ContactAlertDialog({
899
837
  size: "sm",
900
838
  value: severity,
901
839
  onValueChange: (v) => v && setSeverity(v),
902
- children: ["NEED_ACTION", "WATCH", "INSIGHT"].map((s) => /* @__PURE__ */ jsx2(ToggleGroupItem, { value: s, children: SEVERITY_LABELS[s] }, s))
840
+ children: ["NEED_ACTION", "WATCH", "HEALTHY"].map((s) => /* @__PURE__ */ jsx2(ToggleGroupItem, { value: s, children: SEVERITY_LABELS[s] }, s))
903
841
  }
904
842
  )
905
843
  ] }),
@@ -130,6 +130,7 @@ function FilePreviewDialog({
130
130
  staffOptions,
131
131
  selectedStaffId,
132
132
  onStaffSelect,
133
+ staffSelector,
133
134
  className
134
135
  }) {
135
136
  const [page, setPage] = React.useState(0);
@@ -140,7 +141,8 @@ function FilePreviewDialog({
140
141
  const pagedRows = rows.slice(page * pageSize, (page + 1) * pageSize);
141
142
  const pageStart = page * pageSize;
142
143
  const isImporting = state === "importing";
143
- const hasStaffSelector = !!staffOptions && staffOptions.length > 0;
144
+ const hasBuiltInStaffSelector = !!staffOptions && staffOptions.length > 0;
145
+ const hasStaffSelector = !!staffSelector || hasBuiltInStaffSelector;
144
146
  const canImport = state === "preview" && rows.length > 0 && (!hasStaffSelector || !!selectedStaffId);
145
147
  const successCount = rows.filter((r) => r._status === "success").length;
146
148
  const failedCount = rows.filter((r) => r._status === "failed").length;
@@ -177,7 +179,7 @@ function FilePreviewDialog({
177
179
  }
178
180
  ),
179
181
  state === "preview" && /* @__PURE__ */ jsxs(Fragment, { children: [
180
- hasStaffSelector && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
182
+ staffSelector ? staffSelector : hasBuiltInStaffSelector && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
181
183
  /* @__PURE__ */ jsxs("label", { className: "text-label-medium text-foreground", children: [
182
184
  "Assign staff",
183
185
  " ",
@@ -28,6 +28,7 @@ function CsvImportModal({
28
28
  onFileClear,
29
29
  onNext,
30
30
  onDownloadTemplate,
31
+ uploadDescription,
31
32
  isLoading = false,
32
33
  className
33
34
  }) {
@@ -61,7 +62,7 @@ function CsvImportModal({
61
62
  {
62
63
  size: "lg",
63
64
  label: "Drag & drop or click to upload",
64
- description: "Supports .csv files only. Max 10 MB.",
65
+ description: uploadDescription != null ? uploadDescription : "Supports .csv files only. Max 10 MB.",
65
66
  accept: ".csv",
66
67
  onFileChange: (file) => file && (onFileSelect == null ? void 0 : onFileSelect(file))
67
68
  }