mis-crystal-design-system 18.1.9 → 18.1.10-test-1
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/esm2022/table/table.component.mjs +71 -10
- package/esm2022/timepicker/timepicker.component.mjs +22 -9
- package/esm2022/timerangepicker/timerangepicker.component.mjs +21 -1
- package/fesm2022/mis-crystal-design-system-table.mjs +70 -9
- package/fesm2022/mis-crystal-design-system-table.mjs.map +1 -1
- package/fesm2022/mis-crystal-design-system-timepicker.mjs +21 -8
- package/fesm2022/mis-crystal-design-system-timepicker.mjs.map +1 -1
- package/fesm2022/mis-crystal-design-system-timerangepicker.mjs +20 -0
- package/fesm2022/mis-crystal-design-system-timerangepicker.mjs.map +1 -1
- package/package.json +19 -19
- package/styles/mis-old-icon-styles.scss +0 -498
- package/table/table.component.d.ts +14 -0
|
@@ -371,7 +371,21 @@ class TableComponent {
|
|
|
371
371
|
// Pagination related variables
|
|
372
372
|
this.pages = signal([]);
|
|
373
373
|
this.tableLength = signal(0);
|
|
374
|
-
this.selectedPage = signal(1); // Internal state for selected page
|
|
374
|
+
this.selectedPage = signal(1); // Internal state for selected page - this is the source of truth
|
|
375
|
+
this.isInternalPageUpdate = false; // Flag to prevent effect from overwriting during user-initiated updates
|
|
376
|
+
/**
|
|
377
|
+
* LEGACY CODE WORKAROUND: Track user-initiated page selections to prevent config overwrites.
|
|
378
|
+
*
|
|
379
|
+
* Some legacy parent components don't update tableConfig.paginationConfig.selectedPage when
|
|
380
|
+
* the page changes. This causes the effect to overwrite user selections with stale config values.
|
|
381
|
+
*
|
|
382
|
+
* IDEAL SOLUTION: Parent components should always update config.selectedPage in their
|
|
383
|
+
* pageSelected event handler. This workaround protects user actions until legacy code
|
|
384
|
+
* can be updated.
|
|
385
|
+
*
|
|
386
|
+
* TODO: Remove this workaround once all parent components properly update config.selectedPage
|
|
387
|
+
*/
|
|
388
|
+
this.userSelectedPage = null;
|
|
375
389
|
this.pageSelected = output();
|
|
376
390
|
this.pageSizeChanged = output();
|
|
377
391
|
this.pageSizeOptions = computed(() => {
|
|
@@ -417,14 +431,49 @@ class TableComponent {
|
|
|
417
431
|
// --- PAGINATION PAGE ARRAY LOGIC (MOVED/REPLACED initializePagination) ---
|
|
418
432
|
const len = config?.paginationConfig?.noOfPages;
|
|
419
433
|
const disablePageJumping = config?.paginationConfig?.disablePageJumping;
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
434
|
+
/**
|
|
435
|
+
* LEGACY CODE WORKAROUND: Protect user-initiated page selections from config overwrites.
|
|
436
|
+
*
|
|
437
|
+
* When users click pagination arrows, we update internal state immediately. However,
|
|
438
|
+
* some legacy parent components don't update config.selectedPage, causing the effect
|
|
439
|
+
* to run with stale config values that would overwrite the user's selection.
|
|
440
|
+
*
|
|
441
|
+
* Strategy: Treat internal state as source of truth for user-initiated changes.
|
|
442
|
+
* Only sync from config when it's safe (not a user-selected page).
|
|
443
|
+
*
|
|
444
|
+
* IDEAL: Parent should always update config.selectedPage in pageSelected handler.
|
|
445
|
+
*/
|
|
446
|
+
const currentSelectedPage = this.selectedPage();
|
|
447
|
+
const configSelectedPage = config?.paginationConfig?.selectedPage;
|
|
448
|
+
const isUserSelectedPage = this.userSelectedPage !== null && currentSelectedPage === this.userSelectedPage;
|
|
449
|
+
if (!this.isInternalPageUpdate) {
|
|
450
|
+
// Only sync from config if:
|
|
451
|
+
// 1. Config has a selectedPage value
|
|
452
|
+
// 2. Current page is NOT a user-initiated selection (protect user actions)
|
|
453
|
+
// 3. Config value is valid and different from current
|
|
454
|
+
if (configSelectedPage !== undefined && configSelectedPage !== null && !isUserSelectedPage) {
|
|
455
|
+
const maxPages = config?.paginationConfig?.noOfPages || 1;
|
|
456
|
+
if (currentSelectedPage !== configSelectedPage &&
|
|
457
|
+
configSelectedPage >= 1 &&
|
|
458
|
+
configSelectedPage <= maxPages) {
|
|
459
|
+
this.selectedPage.set(configSelectedPage);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
// If config doesn't have selectedPage, only initialize invalid state
|
|
463
|
+
// Never reset a valid page number, especially user-selected ones
|
|
464
|
+
if ((configSelectedPage === undefined || configSelectedPage === null) &&
|
|
465
|
+
!isUserSelectedPage &&
|
|
466
|
+
(currentSelectedPage === 0 || currentSelectedPage < 1)) {
|
|
467
|
+
this.selectedPage.set(1);
|
|
468
|
+
}
|
|
469
|
+
// Clear user selection tracking when config matches user's selection
|
|
470
|
+
// This indicates parent has updated config correctly
|
|
471
|
+
if (configSelectedPage === this.userSelectedPage) {
|
|
472
|
+
this.userSelectedPage = null;
|
|
426
473
|
}
|
|
427
474
|
}
|
|
475
|
+
// Reset the flag after processing
|
|
476
|
+
this.isInternalPageUpdate = false;
|
|
428
477
|
// Only run if pagination is configured and page jumping is enabled
|
|
429
478
|
if (len && len > 0 && !disablePageJumping) {
|
|
430
479
|
// Read the internal state of the selected page for calculating the pages array.
|
|
@@ -645,7 +694,19 @@ class TableComponent {
|
|
|
645
694
|
// Guard clause to prevent out-of-range updates
|
|
646
695
|
if (pageNumber < 1 || pageNumber > this.tableConfig().paginationConfig.noOfPages)
|
|
647
696
|
return;
|
|
648
|
-
|
|
697
|
+
/**
|
|
698
|
+
* LEGACY CODE WORKAROUND: Track user-initiated page selection.
|
|
699
|
+
*
|
|
700
|
+
* We track this to prevent the effect from overwriting user selections when
|
|
701
|
+
* legacy parent components don't update config.selectedPage. The effect will
|
|
702
|
+
* skip syncing from config while this page is marked as user-selected.
|
|
703
|
+
*
|
|
704
|
+
* IDEAL: Parent should update config.selectedPage in pageSelected handler.
|
|
705
|
+
* Once all parents do this, we can remove userSelectedPage tracking.
|
|
706
|
+
*/
|
|
707
|
+
this.isInternalPageUpdate = true;
|
|
708
|
+
this.userSelectedPage = pageNumber;
|
|
709
|
+
// Update internal state immediately - this is the source of truth
|
|
649
710
|
this.selectedPage.set(pageNumber);
|
|
650
711
|
// Reset header checkbox when navigating to a different page
|
|
651
712
|
this.selectAllCheckbox.set(false);
|
|
@@ -662,7 +723,7 @@ class TableComponent {
|
|
|
662
723
|
this.pages.set([1, 0, len - 3, len - 2, len - 1, len]);
|
|
663
724
|
}
|
|
664
725
|
}
|
|
665
|
-
// Emit to parent
|
|
726
|
+
// Emit to parent - they may or may not update config, but we protect our state
|
|
666
727
|
this.pageSelected.emit(pageNumber);
|
|
667
728
|
}
|
|
668
729
|
// Main container related functions
|