@nubitio/devextreme 0.9.10 → 0.10.0

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
@@ -195,7 +195,7 @@ function DevExtremeDetailGridSection({ fields, url }) {
195
195
  });
196
196
  }
197
197
  //#endregion
198
- //#region packages/devextreme/DevExtremeDataGridView.tsx
198
+ //#region packages/devextreme/dxGridConfig.ts
199
199
  function resolveDxEditMode(editMode) {
200
200
  if (!editMode || editMode === "popup") return null;
201
201
  return editMode;
@@ -218,6 +218,8 @@ function resolveDxRemoteOperations(options) {
218
218
  function isHeaderFilterLookup(loadOptions) {
219
219
  return Array.isArray(loadOptions.group) || loadOptions.requireGroupCount === true;
220
220
  }
221
+ //#endregion
222
+ //#region packages/devextreme/DevExtremeDataGridView.tsx
221
223
  const DevExtremeDataGridView = (0, react.forwardRef)((options, ref) => {
222
224
  const { t } = (0, _nubitio_core.useCoreTranslation)();
223
225
  const httpClient = (0, _nubitio_core.useCoreHttpClient)();
@@ -371,9 +373,11 @@ const DevExtremeDataGridView = (0, react.forwardRef)((options, ref) => {
371
373
  return true;
372
374
  }
373
375
  }), [
374
- options.onBatchSave,
376
+ activeFilter,
377
+ options,
375
378
  refresh,
376
- source
379
+ source,
380
+ t
377
381
  ]);
378
382
  const handleSelectionChanged = (0, react.useCallback)((event) => {
379
383
  const rows = event.selectedRowsData ?? [];
@@ -433,7 +437,7 @@ const DevExtremeDataGridView = (0, react.forwardRef)((options, ref) => {
433
437
  if (changedRows.length > 0) await options.onBatchSave(changedRows);
434
438
  hasPendingEditsRef.current = false;
435
439
  refresh();
436
- }, [options.onBatchSave, refresh]);
440
+ }, [options, refresh]);
437
441
  const handleEditCanceled = (0, react.useCallback)(() => {
438
442
  hasPendingEditsRef.current = false;
439
443
  }, []);
@@ -447,7 +451,7 @@ const DevExtremeDataGridView = (0, react.forwardRef)((options, ref) => {
447
451
  const requestDelete = (0, react.useCallback)((rowData) => {
448
452
  if (!rowData || options.canDeleteRow?.(rowData) === false) return;
449
453
  setConfirmRow(rowData);
450
- }, [options.canDeleteRow]);
454
+ }, [options]);
451
455
  const renderRowActions = (0, react.useCallback)((cell) => {
452
456
  const row = cell.data;
453
457
  if (!row) return null;
@@ -474,11 +478,7 @@ const DevExtremeDataGridView = (0, react.forwardRef)((options, ref) => {
474
478
  }) : null]
475
479
  });
476
480
  }, [
477
- options.allowDelete,
478
- options.allowEdit,
479
- options.canDeleteRow,
480
- options.canEditRow,
481
- options.onEdit,
481
+ options,
482
482
  requestDelete,
483
483
  t
484
484
  ]);
@@ -495,11 +495,7 @@ const DevExtremeDataGridView = (0, react.forwardRef)((options, ref) => {
495
495
  fields: detailFields,
496
496
  url: detailUrl
497
497
  });
498
- }, [
499
- idField,
500
- options.detailFields,
501
- options.detailUrl
502
- ]);
498
+ }, [idField, options]);
503
499
  const showToolbar = options.toolbarVisible !== false;
504
500
  const showFilterRow = options.filterRow ?? true;
505
501
  const showPaging = options.paging ?? true;
@@ -648,6 +644,42 @@ function DevExtremeFormDetailGrid({ fields, rows, allowAdding = false, allowUpda
648
644
  });
649
645
  }
650
646
  //#endregion
647
+ //#region packages/devextreme/formValidation.ts
648
+ function isEmptyValue(value) {
649
+ return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
650
+ }
651
+ function withDetailRowKeys(rows) {
652
+ return rows.map((row) => ({
653
+ ...row,
654
+ __rowKey: typeof row.__rowKey === "string" ? row.__rowKey : crypto.randomUUID()
655
+ }));
656
+ }
657
+ function validateField(field, value, formData, t) {
658
+ if (field.required && isEmptyValue(value)) return t("form.fieldRequired", { label: field.label });
659
+ for (const rule of field.validators ?? []) {
660
+ if (rule.type === "required" && isEmptyValue(value)) return rule.options.message ?? t("form.fieldRequired", { label: field.label });
661
+ if (rule.type === "email" && typeof value === "string" && value !== "" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) return rule.options.message ?? t("form.invalidEmail");
662
+ if (rule.type === "numeric" && value !== "" && value != null && Number.isNaN(Number(value))) return rule.options.message ?? t("form.invalidNumeric");
663
+ if (rule.type === "pattern" && typeof value === "string" && !new RegExp(rule.options.pattern).test(value)) return rule.options.message ?? t("form.invalidPattern");
664
+ if (rule.type === "stringLength" && typeof value === "string") {
665
+ if (rule.options.min !== void 0 && value.length < rule.options.min) return rule.options.message ?? t("form.stringTooShort");
666
+ if (rule.options.max !== void 0 && value.length > rule.options.max) return rule.options.message ?? t("form.stringTooLong");
667
+ }
668
+ if (rule.type === "range" && value !== "" && value != null) {
669
+ const numericValue = Number(value);
670
+ if (rule.options.min !== void 0 && numericValue < rule.options.min) return rule.options.message ?? t("form.outOfRange");
671
+ if (rule.options.max !== void 0 && numericValue > rule.options.max) return rule.options.message ?? t("form.outOfRange");
672
+ }
673
+ if (rule.type === "custom") {
674
+ if (!rule.options.validationCallback({
675
+ value,
676
+ data: formData
677
+ })) return rule.options.message ?? t("validation.defaultError");
678
+ }
679
+ }
680
+ return null;
681
+ }
682
+ //#endregion
651
683
  //#region packages/devextreme/mapFieldsToDxFormItems.ts
652
684
  const DX_EDITOR_BY_KIND = {
653
685
  text: "dxTextBox",
@@ -705,40 +737,6 @@ function mapFieldsToDxFormItems(fields) {
705
737
  }
706
738
  //#endregion
707
739
  //#region packages/devextreme/DevExtremeFormView.tsx
708
- function isEmptyValue(value) {
709
- return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
710
- }
711
- function withDetailRowKeys(rows) {
712
- return rows.map((row) => ({
713
- ...row,
714
- __rowKey: typeof row.__rowKey === "string" ? row.__rowKey : crypto.randomUUID()
715
- }));
716
- }
717
- function validateField(field, value, formData, t) {
718
- if (field.required && isEmptyValue(value)) return t("form.fieldRequired", { label: field.label });
719
- for (const rule of field.validators ?? []) {
720
- if (rule.type === "required" && isEmptyValue(value)) return rule.options.message ?? t("form.fieldRequired", { label: field.label });
721
- if (rule.type === "email" && typeof value === "string" && value !== "" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) return rule.options.message ?? t("form.invalidEmail");
722
- if (rule.type === "numeric" && value !== "" && value != null && Number.isNaN(Number(value))) return rule.options.message ?? t("form.invalidNumeric");
723
- if (rule.type === "pattern" && typeof value === "string" && !new RegExp(rule.options.pattern).test(value)) return rule.options.message ?? t("form.invalidPattern");
724
- if (rule.type === "stringLength" && typeof value === "string") {
725
- if (rule.options.min !== void 0 && value.length < rule.options.min) return rule.options.message ?? t("form.stringTooShort");
726
- if (rule.options.max !== void 0 && value.length > rule.options.max) return rule.options.message ?? t("form.stringTooLong");
727
- }
728
- if (rule.type === "range" && value !== "" && value != null) {
729
- const numericValue = Number(value);
730
- if (rule.options.min !== void 0 && numericValue < rule.options.min) return rule.options.message ?? t("form.outOfRange");
731
- if (rule.options.max !== void 0 && numericValue > rule.options.max) return rule.options.message ?? t("form.outOfRange");
732
- }
733
- if (rule.type === "custom") {
734
- if (!rule.options.validationCallback({
735
- value,
736
- data: formData
737
- })) return rule.options.message ?? t("validation.defaultError");
738
- }
739
- }
740
- return null;
741
- }
742
740
  const DevExtremeFormView = (0, react.forwardRef)((options, ref) => {
743
741
  const { t } = (0, _nubitio_core.useCoreTranslation)();
744
742
  const httpClient = (0, _nubitio_core.useCoreHttpClient)();
package/dist/index.mjs CHANGED
@@ -168,7 +168,7 @@ function DevExtremeDetailGridSection({ fields, url }) {
168
168
  });
169
169
  }
170
170
  //#endregion
171
- //#region packages/devextreme/DevExtremeDataGridView.tsx
171
+ //#region packages/devextreme/dxGridConfig.ts
172
172
  function resolveDxEditMode(editMode) {
173
173
  if (!editMode || editMode === "popup") return null;
174
174
  return editMode;
@@ -191,6 +191,8 @@ function resolveDxRemoteOperations(options) {
191
191
  function isHeaderFilterLookup(loadOptions) {
192
192
  return Array.isArray(loadOptions.group) || loadOptions.requireGroupCount === true;
193
193
  }
194
+ //#endregion
195
+ //#region packages/devextreme/DevExtremeDataGridView.tsx
194
196
  const DevExtremeDataGridView = forwardRef((options, ref) => {
195
197
  const { t } = useCoreTranslation();
196
198
  const httpClient = useCoreHttpClient();
@@ -344,9 +346,11 @@ const DevExtremeDataGridView = forwardRef((options, ref) => {
344
346
  return true;
345
347
  }
346
348
  }), [
347
- options.onBatchSave,
349
+ activeFilter,
350
+ options,
348
351
  refresh,
349
- source
352
+ source,
353
+ t
350
354
  ]);
351
355
  const handleSelectionChanged = useCallback((event) => {
352
356
  const rows = event.selectedRowsData ?? [];
@@ -406,7 +410,7 @@ const DevExtremeDataGridView = forwardRef((options, ref) => {
406
410
  if (changedRows.length > 0) await options.onBatchSave(changedRows);
407
411
  hasPendingEditsRef.current = false;
408
412
  refresh();
409
- }, [options.onBatchSave, refresh]);
413
+ }, [options, refresh]);
410
414
  const handleEditCanceled = useCallback(() => {
411
415
  hasPendingEditsRef.current = false;
412
416
  }, []);
@@ -420,7 +424,7 @@ const DevExtremeDataGridView = forwardRef((options, ref) => {
420
424
  const requestDelete = useCallback((rowData) => {
421
425
  if (!rowData || options.canDeleteRow?.(rowData) === false) return;
422
426
  setConfirmRow(rowData);
423
- }, [options.canDeleteRow]);
427
+ }, [options]);
424
428
  const renderRowActions = useCallback((cell) => {
425
429
  const row = cell.data;
426
430
  if (!row) return null;
@@ -447,11 +451,7 @@ const DevExtremeDataGridView = forwardRef((options, ref) => {
447
451
  }) : null]
448
452
  });
449
453
  }, [
450
- options.allowDelete,
451
- options.allowEdit,
452
- options.canDeleteRow,
453
- options.canEditRow,
454
- options.onEdit,
454
+ options,
455
455
  requestDelete,
456
456
  t
457
457
  ]);
@@ -468,11 +468,7 @@ const DevExtremeDataGridView = forwardRef((options, ref) => {
468
468
  fields: detailFields,
469
469
  url: detailUrl
470
470
  });
471
- }, [
472
- idField,
473
- options.detailFields,
474
- options.detailUrl
475
- ]);
471
+ }, [idField, options]);
476
472
  const showToolbar = options.toolbarVisible !== false;
477
473
  const showFilterRow = options.filterRow ?? true;
478
474
  const showPaging = options.paging ?? true;
@@ -621,6 +617,42 @@ function DevExtremeFormDetailGrid({ fields, rows, allowAdding = false, allowUpda
621
617
  });
622
618
  }
623
619
  //#endregion
620
+ //#region packages/devextreme/formValidation.ts
621
+ function isEmptyValue(value) {
622
+ return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
623
+ }
624
+ function withDetailRowKeys(rows) {
625
+ return rows.map((row) => ({
626
+ ...row,
627
+ __rowKey: typeof row.__rowKey === "string" ? row.__rowKey : crypto.randomUUID()
628
+ }));
629
+ }
630
+ function validateField(field, value, formData, t) {
631
+ if (field.required && isEmptyValue(value)) return t("form.fieldRequired", { label: field.label });
632
+ for (const rule of field.validators ?? []) {
633
+ if (rule.type === "required" && isEmptyValue(value)) return rule.options.message ?? t("form.fieldRequired", { label: field.label });
634
+ if (rule.type === "email" && typeof value === "string" && value !== "" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) return rule.options.message ?? t("form.invalidEmail");
635
+ if (rule.type === "numeric" && value !== "" && value != null && Number.isNaN(Number(value))) return rule.options.message ?? t("form.invalidNumeric");
636
+ if (rule.type === "pattern" && typeof value === "string" && !new RegExp(rule.options.pattern).test(value)) return rule.options.message ?? t("form.invalidPattern");
637
+ if (rule.type === "stringLength" && typeof value === "string") {
638
+ if (rule.options.min !== void 0 && value.length < rule.options.min) return rule.options.message ?? t("form.stringTooShort");
639
+ if (rule.options.max !== void 0 && value.length > rule.options.max) return rule.options.message ?? t("form.stringTooLong");
640
+ }
641
+ if (rule.type === "range" && value !== "" && value != null) {
642
+ const numericValue = Number(value);
643
+ if (rule.options.min !== void 0 && numericValue < rule.options.min) return rule.options.message ?? t("form.outOfRange");
644
+ if (rule.options.max !== void 0 && numericValue > rule.options.max) return rule.options.message ?? t("form.outOfRange");
645
+ }
646
+ if (rule.type === "custom") {
647
+ if (!rule.options.validationCallback({
648
+ value,
649
+ data: formData
650
+ })) return rule.options.message ?? t("validation.defaultError");
651
+ }
652
+ }
653
+ return null;
654
+ }
655
+ //#endregion
624
656
  //#region packages/devextreme/mapFieldsToDxFormItems.ts
625
657
  const DX_EDITOR_BY_KIND = {
626
658
  text: "dxTextBox",
@@ -678,40 +710,6 @@ function mapFieldsToDxFormItems(fields) {
678
710
  }
679
711
  //#endregion
680
712
  //#region packages/devextreme/DevExtremeFormView.tsx
681
- function isEmptyValue(value) {
682
- return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
683
- }
684
- function withDetailRowKeys(rows) {
685
- return rows.map((row) => ({
686
- ...row,
687
- __rowKey: typeof row.__rowKey === "string" ? row.__rowKey : crypto.randomUUID()
688
- }));
689
- }
690
- function validateField(field, value, formData, t) {
691
- if (field.required && isEmptyValue(value)) return t("form.fieldRequired", { label: field.label });
692
- for (const rule of field.validators ?? []) {
693
- if (rule.type === "required" && isEmptyValue(value)) return rule.options.message ?? t("form.fieldRequired", { label: field.label });
694
- if (rule.type === "email" && typeof value === "string" && value !== "" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) return rule.options.message ?? t("form.invalidEmail");
695
- if (rule.type === "numeric" && value !== "" && value != null && Number.isNaN(Number(value))) return rule.options.message ?? t("form.invalidNumeric");
696
- if (rule.type === "pattern" && typeof value === "string" && !new RegExp(rule.options.pattern).test(value)) return rule.options.message ?? t("form.invalidPattern");
697
- if (rule.type === "stringLength" && typeof value === "string") {
698
- if (rule.options.min !== void 0 && value.length < rule.options.min) return rule.options.message ?? t("form.stringTooShort");
699
- if (rule.options.max !== void 0 && value.length > rule.options.max) return rule.options.message ?? t("form.stringTooLong");
700
- }
701
- if (rule.type === "range" && value !== "" && value != null) {
702
- const numericValue = Number(value);
703
- if (rule.options.min !== void 0 && numericValue < rule.options.min) return rule.options.message ?? t("form.outOfRange");
704
- if (rule.options.max !== void 0 && numericValue > rule.options.max) return rule.options.message ?? t("form.outOfRange");
705
- }
706
- if (rule.type === "custom") {
707
- if (!rule.options.validationCallback({
708
- value,
709
- data: formData
710
- })) return rule.options.message ?? t("validation.defaultError");
711
- }
712
- }
713
- return null;
714
- }
715
713
  const DevExtremeFormView = forwardRef((options, ref) => {
716
714
  const { t } = useCoreTranslation();
717
715
  const httpClient = useCoreHttpClient();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubitio/devextreme",
3
- "version": "0.9.10",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "DevExtreme-backed CRUD views for @nubitio/crud — optional drop-in for licensed DevExtreme customers.",
6
6
  "license": "MIT",
@@ -54,8 +54,8 @@
54
54
  "devextreme-react": ">=24.0.0",
55
55
  "react": "^18.2.0 || ^19.0.0",
56
56
  "react-dom": "^18.2.0 || ^19.0.0",
57
- "@nubitio/core": "^0.9.10",
58
- "@nubitio/crud": "^0.9.10",
59
- "@nubitio/ui": "^0.9.10"
57
+ "@nubitio/ui": "^0.10.0",
58
+ "@nubitio/core": "^0.10.0",
59
+ "@nubitio/crud": "^0.10.0"
60
60
  }
61
61
  }