@portnet/ui 6.0.0 → 6.0.2
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 +85 -0
- package/dist/esm/index.js +214 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/v2/__tests__/FieldError.test.js +159 -0
- package/dist/esm/v2/__tests__/FieldError.test.js.map +1 -0
- package/dist/esm/v2/__tests__/FieldWidth.test.js +146 -0
- package/dist/esm/v2/__tests__/FieldWidth.test.js.map +1 -0
- package/dist/esm/v2/__tests__/FileCard.test.js +143 -0
- package/dist/esm/v2/__tests__/FileCard.test.js.map +1 -0
- package/dist/esm/v2/__tests__/FormikCheckbox.test.js +265 -0
- package/dist/esm/v2/__tests__/FormikCheckbox.test.js.map +1 -0
- package/dist/esm/v2/__tests__/FormikDateTimePicker.test.js +248 -0
- package/dist/esm/v2/__tests__/FormikDateTimePicker.test.js.map +1 -0
- package/dist/esm/v2/__tests__/FormikRadioGroup.test.js +380 -0
- package/dist/esm/v2/__tests__/FormikRadioGroup.test.js.map +1 -0
- package/dist/esm/v2/__tests__/MobileRowCard.test.js +332 -0
- package/dist/esm/v2/__tests__/MobileRowCard.test.js.map +1 -0
- package/dist/esm/v2/__tests__/SectionErrorBoundary.test.js +235 -0
- package/dist/esm/v2/__tests__/SectionErrorBoundary.test.js.map +1 -0
- package/dist/esm/v2/__tests__/apiError.test.js +181 -0
- package/dist/esm/v2/__tests__/apiError.test.js.map +1 -0
- package/dist/esm/v2/__tests__/banned-patterns.test.js +270 -0
- package/dist/esm/v2/__tests__/banned-patterns.test.js.map +1 -0
- package/dist/esm/v2/__tests__/contrast-palette.test.js +224 -0
- package/dist/esm/v2/__tests__/contrast-palette.test.js.map +1 -0
- package/dist/esm/v2/__tests__/cssVariables.test.js +157 -0
- package/dist/esm/v2/__tests__/cssVariables.test.js.map +1 -0
- package/dist/esm/v2/__tests__/labels-merge.test.js +146 -0
- package/dist/esm/v2/__tests__/labels-merge.test.js.map +1 -0
- package/dist/esm/v2/__tests__/locale-fallback.test.js +109 -0
- package/dist/esm/v2/__tests__/locale-fallback.test.js.map +1 -0
- package/dist/esm/v2/__tests__/useFocusTrap.test.js +514 -0
- package/dist/esm/v2/__tests__/useFocusTrap.test.js.map +1 -0
- package/dist/esm/v2/components/Accordion.js +230 -0
- package/dist/esm/v2/components/Accordion.js.map +1 -0
- package/dist/esm/v2/components/ActionStrip.js +146 -0
- package/dist/esm/v2/components/ActionStrip.js.map +1 -0
- package/dist/esm/v2/components/Banner.js +254 -0
- package/dist/esm/v2/components/Banner.js.map +1 -0
- package/dist/esm/v2/components/Busy.js +97 -0
- package/dist/esm/v2/components/Busy.js.map +1 -0
- package/dist/esm/v2/components/Button.js +114 -0
- package/dist/esm/v2/components/Button.js.map +1 -0
- package/dist/esm/v2/components/CategoryTag.js +81 -0
- package/dist/esm/v2/components/CategoryTag.js.map +1 -0
- package/dist/esm/v2/components/Checkbox.js +124 -0
- package/dist/esm/v2/components/Checkbox.js.map +1 -0
- package/dist/esm/v2/components/Chip.js +124 -0
- package/dist/esm/v2/components/Chip.js.map +1 -0
- package/dist/esm/v2/components/Combobox.js +394 -0
- package/dist/esm/v2/components/Combobox.js.map +1 -0
- package/dist/esm/v2/components/CommandPalette.js +660 -0
- package/dist/esm/v2/components/CommandPalette.js.map +1 -0
- package/dist/esm/v2/components/ConfirmDialog.js +144 -0
- package/dist/esm/v2/components/ConfirmDialog.js.map +1 -0
- package/dist/esm/v2/components/DatePicker.js +200 -0
- package/dist/esm/v2/components/DatePicker.js.map +1 -0
- package/dist/esm/v2/components/DateRangePicker.js +289 -0
- package/dist/esm/v2/components/DateRangePicker.js.map +1 -0
- package/dist/esm/v2/components/DateTimePicker.js +215 -0
- package/dist/esm/v2/components/DateTimePicker.js.map +1 -0
- package/dist/esm/v2/components/Drawer.js +333 -0
- package/dist/esm/v2/components/Drawer.js.map +1 -0
- package/dist/esm/v2/components/Dropzone.js +540 -0
- package/dist/esm/v2/components/Dropzone.js.map +1 -0
- package/dist/esm/v2/components/EmptyState.js +102 -0
- package/dist/esm/v2/components/EmptyState.js.map +1 -0
- package/dist/esm/v2/components/FavoriteToggle.js +127 -0
- package/dist/esm/v2/components/FavoriteToggle.js.map +1 -0
- package/dist/esm/v2/components/Field.js +259 -0
- package/dist/esm/v2/components/Field.js.map +1 -0
- package/dist/esm/v2/components/FieldError.js +124 -0
- package/dist/esm/v2/components/FieldError.js.map +1 -0
- package/dist/esm/v2/components/FieldHelp.js +202 -0
- package/dist/esm/v2/components/FieldHelp.js.map +1 -0
- package/dist/esm/v2/components/FileCard.js +162 -0
- package/dist/esm/v2/components/FileCard.js.map +1 -0
- package/dist/esm/v2/components/FilterTab.js +138 -0
- package/dist/esm/v2/components/FilterTab.js.map +1 -0
- package/dist/esm/v2/components/ForbiddenPage.js +74 -0
- package/dist/esm/v2/components/ForbiddenPage.js.map +1 -0
- package/dist/esm/v2/components/FormGrid.js +179 -0
- package/dist/esm/v2/components/FormGrid.js.map +1 -0
- package/dist/esm/v2/components/FormikDisplay.js +118 -0
- package/dist/esm/v2/components/FormikDisplay.js.map +1 -0
- package/dist/esm/v2/components/Input.js +107 -0
- package/dist/esm/v2/components/Input.js.map +1 -0
- package/dist/esm/v2/components/KPICard.js +237 -0
- package/dist/esm/v2/components/KPICard.js.map +1 -0
- package/dist/esm/v2/components/KPIStrip.js +84 -0
- package/dist/esm/v2/components/KPIStrip.js.map +1 -0
- package/dist/esm/v2/components/KV.js +75 -0
- package/dist/esm/v2/components/KV.js.map +1 -0
- package/dist/esm/v2/components/KVGrid.js +74 -0
- package/dist/esm/v2/components/KVGrid.js.map +1 -0
- package/dist/esm/v2/components/Layout.js +284 -0
- package/dist/esm/v2/components/Layout.js.map +1 -0
- package/dist/esm/v2/components/MobileRowCard.js +314 -0
- package/dist/esm/v2/components/MobileRowCard.js.map +1 -0
- package/dist/esm/v2/components/Modal.js +276 -0
- package/dist/esm/v2/components/Modal.js.map +1 -0
- package/dist/esm/v2/components/NetworkErrorPage.js +78 -0
- package/dist/esm/v2/components/NetworkErrorPage.js.map +1 -0
- package/dist/esm/v2/components/NotFoundPage.js +58 -0
- package/dist/esm/v2/components/NotFoundPage.js.map +1 -0
- package/dist/esm/v2/components/NumberInput.js +309 -0
- package/dist/esm/v2/components/NumberInput.js.map +1 -0
- package/dist/esm/v2/components/OverflowMenu.js +184 -0
- package/dist/esm/v2/components/OverflowMenu.js.map +1 -0
- package/dist/esm/v2/components/PdfViewer.js +122 -0
- package/dist/esm/v2/components/PdfViewer.js.map +1 -0
- package/dist/esm/v2/components/ProgressBar.js +202 -0
- package/dist/esm/v2/components/ProgressBar.js.map +1 -0
- package/dist/esm/v2/components/Radio.js +228 -0
- package/dist/esm/v2/components/Radio.js.map +1 -0
- package/dist/esm/v2/components/SectionErrorBoundary.js +214 -0
- package/dist/esm/v2/components/SectionErrorBoundary.js.map +1 -0
- package/dist/esm/v2/components/SectionHeader.js +132 -0
- package/dist/esm/v2/components/SectionHeader.js.map +1 -0
- package/dist/esm/v2/components/Segmented.js +254 -0
- package/dist/esm/v2/components/Segmented.js.map +1 -0
- package/dist/esm/v2/components/Select.js +490 -0
- package/dist/esm/v2/components/Select.js.map +1 -0
- package/dist/esm/v2/components/ServerErrorPage.js +74 -0
- package/dist/esm/v2/components/ServerErrorPage.js.map +1 -0
- package/dist/esm/v2/components/Skeleton.js +269 -0
- package/dist/esm/v2/components/Skeleton.js.map +1 -0
- package/dist/esm/v2/components/SkipLink.js +49 -0
- package/dist/esm/v2/components/SkipLink.js.map +1 -0
- package/dist/esm/v2/components/Spinner.js +69 -0
- package/dist/esm/v2/components/Spinner.js.map +1 -0
- package/dist/esm/v2/components/Status.js +64 -0
- package/dist/esm/v2/components/Status.js.map +1 -0
- package/dist/esm/v2/components/Stepper.js +432 -0
- package/dist/esm/v2/components/Stepper.js.map +1 -0
- package/dist/esm/v2/components/Surface.js +159 -0
- package/dist/esm/v2/components/Surface.js.map +1 -0
- package/dist/esm/v2/components/Switch.js +128 -0
- package/dist/esm/v2/components/Switch.js.map +1 -0
- package/dist/esm/v2/components/Tabs.js +150 -0
- package/dist/esm/v2/components/Tabs.js.map +1 -0
- package/dist/esm/v2/components/TelInput.js +274 -0
- package/dist/esm/v2/components/TelInput.js.map +1 -0
- package/dist/esm/v2/components/Textarea.js +72 -0
- package/dist/esm/v2/components/Textarea.js.map +1 -0
- package/dist/esm/v2/components/TimePicker.js +134 -0
- package/dist/esm/v2/components/TimePicker.js.map +1 -0
- package/dist/esm/v2/components/Toast.js +376 -0
- package/dist/esm/v2/components/Toast.js.map +1 -0
- package/dist/esm/v2/components/Tooltip.js +161 -0
- package/dist/esm/v2/components/Tooltip.js.map +1 -0
- package/dist/esm/v2/components/_ErrorPageBody.js +85 -0
- package/dist/esm/v2/components/_ErrorPageBody.js.map +1 -0
- package/dist/esm/v2/components/_pickerShared.js +60 -0
- package/dist/esm/v2/components/_pickerShared.js.map +1 -0
- package/dist/esm/v2/components/index.js +271 -0
- package/dist/esm/v2/components/index.js.map +1 -0
- package/dist/esm/v2/hooks/index.js +10 -0
- package/dist/esm/v2/hooks/index.js.map +1 -0
- package/dist/esm/v2/hooks/useDelayedFlag.js +55 -0
- package/dist/esm/v2/hooks/useDelayedFlag.js.map +1 -0
- package/dist/esm/v2/hooks/useDensity.js +119 -0
- package/dist/esm/v2/hooks/useDensity.js.map +1 -0
- package/dist/esm/v2/hooks/useFocusFirstError.js +197 -0
- package/dist/esm/v2/hooks/useFocusFirstError.js.map +1 -0
- package/dist/esm/v2/hooks/useFocusTrap.js +202 -0
- package/dist/esm/v2/hooks/useFocusTrap.js.map +1 -0
- package/dist/esm/v2/hooks/useFormAutoSave.js +181 -0
- package/dist/esm/v2/hooks/useFormAutoSave.js.map +1 -0
- package/dist/esm/v2/hooks/useFormCompletionProgress.js +131 -0
- package/dist/esm/v2/hooks/useFormCompletionProgress.js.map +1 -0
- package/dist/esm/v2/hooks/useResolvedDensity.js +44 -0
- package/dist/esm/v2/hooks/useResolvedDensity.js.map +1 -0
- package/dist/esm/v2/hooks/useSortedRows.js +32 -0
- package/dist/esm/v2/hooks/useSortedRows.js.map +1 -0
- package/dist/esm/v2/hooks/useTabLoading.js +79 -0
- package/dist/esm/v2/hooks/useTabLoading.js.map +1 -0
- package/dist/esm/v2/index.js +132 -0
- package/dist/esm/v2/index.js.map +1 -0
- package/dist/esm/v2/modalContext.js +108 -0
- package/dist/esm/v2/modalContext.js.map +1 -0
- package/dist/esm/v2/models/favorite.js +2 -0
- package/dist/esm/v2/models/favorite.js.map +1 -0
- package/dist/esm/v2/models/index.js +12 -0
- package/dist/esm/v2/models/index.js.map +1 -0
- package/dist/esm/v2/models/personalization.js +2 -0
- package/dist/esm/v2/models/personalization.js.map +1 -0
- package/dist/esm/v2/models/referentiel.js +2 -0
- package/dist/esm/v2/models/referentiel.js.map +1 -0
- package/dist/esm/v2/models/savedFilter.js +2 -0
- package/dist/esm/v2/models/savedFilter.js.map +1 -0
- package/dist/esm/v2/patterns/ActionBar.js +603 -0
- package/dist/esm/v2/patterns/ActionBar.js.map +1 -0
- package/dist/esm/v2/patterns/BulkActionBar.js +147 -0
- package/dist/esm/v2/patterns/BulkActionBar.js.map +1 -0
- package/dist/esm/v2/patterns/CollapsibleDataGrid.js +303 -0
- package/dist/esm/v2/patterns/CollapsibleDataGrid.js.map +1 -0
- package/dist/esm/v2/patterns/ColumnsToggle.js +301 -0
- package/dist/esm/v2/patterns/ColumnsToggle.js.map +1 -0
- package/dist/esm/v2/patterns/DataGrid.js +820 -0
- package/dist/esm/v2/patterns/DataGrid.js.map +1 -0
- package/dist/esm/v2/patterns/DataGridSettingsMenu.js +375 -0
- package/dist/esm/v2/patterns/DataGridSettingsMenu.js.map +1 -0
- package/dist/esm/v2/patterns/DataGridToolbar.js +249 -0
- package/dist/esm/v2/patterns/DataGridToolbar.js.map +1 -0
- package/dist/esm/v2/patterns/DataGridVirtualized.js +523 -0
- package/dist/esm/v2/patterns/DataGridVirtualized.js.map +1 -0
- package/dist/esm/v2/patterns/DeleteResourceConfirmDialog.js +70 -0
- package/dist/esm/v2/patterns/DeleteResourceConfirmDialog.js.map +1 -0
- package/dist/esm/v2/patterns/FavoriteColumn.js +117 -0
- package/dist/esm/v2/patterns/FavoriteColumn.js.map +1 -0
- package/dist/esm/v2/patterns/FavoritesFilter.js +91 -0
- package/dist/esm/v2/patterns/FavoritesFilter.js.map +1 -0
- package/dist/esm/v2/patterns/FormErrorSummary.js +101 -0
- package/dist/esm/v2/patterns/FormErrorSummary.js.map +1 -0
- package/dist/esm/v2/patterns/FormPageShell.js +126 -0
- package/dist/esm/v2/patterns/FormPageShell.js.map +1 -0
- package/dist/esm/v2/patterns/FormSection.js +190 -0
- package/dist/esm/v2/patterns/FormSection.js.map +1 -0
- package/dist/esm/v2/patterns/FormikCheckbox.js +140 -0
- package/dist/esm/v2/patterns/FormikCheckbox.js.map +1 -0
- package/dist/esm/v2/patterns/FormikCheckboxGroup.js +110 -0
- package/dist/esm/v2/patterns/FormikCheckboxGroup.js.map +1 -0
- package/dist/esm/v2/patterns/FormikCombobox.js +118 -0
- package/dist/esm/v2/patterns/FormikCombobox.js.map +1 -0
- package/dist/esm/v2/patterns/FormikDatePicker.js +162 -0
- package/dist/esm/v2/patterns/FormikDatePicker.js.map +1 -0
- package/dist/esm/v2/patterns/FormikDateTimePicker.js +150 -0
- package/dist/esm/v2/patterns/FormikDateTimePicker.js.map +1 -0
- package/dist/esm/v2/patterns/FormikErrorFocus.js +77 -0
- package/dist/esm/v2/patterns/FormikErrorFocus.js.map +1 -0
- package/dist/esm/v2/patterns/FormikFile.js +148 -0
- package/dist/esm/v2/patterns/FormikFile.js.map +1 -0
- package/dist/esm/v2/patterns/FormikInput.js +130 -0
- package/dist/esm/v2/patterns/FormikInput.js.map +1 -0
- package/dist/esm/v2/patterns/FormikRadioGroup.js +141 -0
- package/dist/esm/v2/patterns/FormikRadioGroup.js.map +1 -0
- package/dist/esm/v2/patterns/FormikReferentielField.js +116 -0
- package/dist/esm/v2/patterns/FormikReferentielField.js.map +1 -0
- package/dist/esm/v2/patterns/FormikSelect.js +162 -0
- package/dist/esm/v2/patterns/FormikSelect.js.map +1 -0
- package/dist/esm/v2/patterns/FormikTextarea.js +79 -0
- package/dist/esm/v2/patterns/FormikTextarea.js.map +1 -0
- package/dist/esm/v2/patterns/KeyboardShortcutsHelp.js +212 -0
- package/dist/esm/v2/patterns/KeyboardShortcutsHelp.js.map +1 -0
- package/dist/esm/v2/patterns/NetworkErrorBanner.js +72 -0
- package/dist/esm/v2/patterns/NetworkErrorBanner.js.map +1 -0
- package/dist/esm/v2/patterns/PageContent.js +62 -0
- package/dist/esm/v2/patterns/PageContent.js.map +1 -0
- package/dist/esm/v2/patterns/ReferentielField.js +615 -0
- package/dist/esm/v2/patterns/ReferentielField.js.map +1 -0
- package/dist/esm/v2/patterns/RowFavoriteToggle.js +122 -0
- package/dist/esm/v2/patterns/RowFavoriteToggle.js.map +1 -0
- package/dist/esm/v2/patterns/SaveFilterDialog.js +197 -0
- package/dist/esm/v2/patterns/SaveFilterDialog.js.map +1 -0
- package/dist/esm/v2/patterns/SavedFiltersMenu.js +406 -0
- package/dist/esm/v2/patterns/SavedFiltersMenu.js.map +1 -0
- package/dist/esm/v2/patterns/SkeletonPageShell.js +342 -0
- package/dist/esm/v2/patterns/SkeletonPageShell.js.map +1 -0
- package/dist/esm/v2/patterns/SortableHeader.js +179 -0
- package/dist/esm/v2/patterns/SortableHeader.js.map +1 -0
- package/dist/esm/v2/patterns/Tour.js +471 -0
- package/dist/esm/v2/patterns/Tour.js.map +1 -0
- package/dist/esm/v2/patterns/_dataGridShared.js +431 -0
- package/dist/esm/v2/patterns/_dataGridShared.js.map +1 -0
- package/dist/esm/v2/patterns/_pickerSerialisation.js +74 -0
- package/dist/esm/v2/patterns/_pickerSerialisation.js.map +1 -0
- package/dist/esm/v2/patterns/_sort.js +112 -0
- package/dist/esm/v2/patterns/_sort.js.map +1 -0
- package/dist/esm/v2/patterns/_useColumnReorder.js +257 -0
- package/dist/esm/v2/patterns/_useColumnReorder.js.map +1 -0
- package/dist/esm/v2/patterns/_useColumnResize.js +191 -0
- package/dist/esm/v2/patterns/_useColumnResize.js.map +1 -0
- package/dist/esm/v2/patterns/index.js +178 -0
- package/dist/esm/v2/patterns/index.js.map +1 -0
- package/dist/esm/v2/personalization/PersonalizationProvider.js +168 -0
- package/dist/esm/v2/personalization/PersonalizationProvider.js.map +1 -0
- package/dist/esm/v2/personalization/adapters/_storageKey.js +60 -0
- package/dist/esm/v2/personalization/adapters/_storageKey.js.map +1 -0
- package/dist/esm/v2/personalization/adapters/createLocalStorageAdapter.js +124 -0
- package/dist/esm/v2/personalization/adapters/createLocalStorageAdapter.js.map +1 -0
- package/dist/esm/v2/personalization/adapters/createMemoryAdapter.js +70 -0
- package/dist/esm/v2/personalization/adapters/createMemoryAdapter.js.map +1 -0
- package/dist/esm/v2/personalization/adapters/index.js +11 -0
- package/dist/esm/v2/personalization/adapters/index.js.map +1 -0
- package/dist/esm/v2/personalization/capabilities/favorites.js +216 -0
- package/dist/esm/v2/personalization/capabilities/favorites.js.map +1 -0
- package/dist/esm/v2/personalization/capabilities/favoritesView.js +111 -0
- package/dist/esm/v2/personalization/capabilities/favoritesView.js.map +1 -0
- package/dist/esm/v2/personalization/capabilities/gridPreferences.js +209 -0
- package/dist/esm/v2/personalization/capabilities/gridPreferences.js.map +1 -0
- package/dist/esm/v2/personalization/capabilities/index.js +22 -0
- package/dist/esm/v2/personalization/capabilities/index.js.map +1 -0
- package/dist/esm/v2/personalization/capabilities/savedFilters.js +291 -0
- package/dist/esm/v2/personalization/capabilities/savedFilters.js.map +1 -0
- package/dist/esm/v2/personalization/createPersonalizationStore.js +472 -0
- package/dist/esm/v2/personalization/createPersonalizationStore.js.map +1 -0
- package/dist/esm/v2/personalization/index.js +64 -0
- package/dist/esm/v2/personalization/index.js.map +1 -0
- package/dist/esm/v2/personalization/personalizationContext.js +108 -0
- package/dist/esm/v2/personalization/personalizationContext.js.map +1 -0
- package/dist/esm/v2/personalization/schema.js +92 -0
- package/dist/esm/v2/personalization/schema.js.map +1 -0
- package/dist/esm/v2/personalization/types.js +2 -0
- package/dist/esm/v2/personalization/types.js.map +1 -0
- package/dist/esm/v2/referentiel/ReferentielProvider.js +87 -0
- package/dist/esm/v2/referentiel/ReferentielProvider.js.map +1 -0
- package/dist/esm/v2/referentiel/index.js +15 -0
- package/dist/esm/v2/referentiel/index.js.map +1 -0
- package/dist/esm/v2/referentiel/useReferentielClient.js +37 -0
- package/dist/esm/v2/referentiel/useReferentielClient.js.map +1 -0
- package/dist/esm/v2/referentiel/useReferentielOptions.js +169 -0
- package/dist/esm/v2/referentiel/useReferentielOptions.js.map +1 -0
- package/dist/esm/v2/referentiel/useReferentielSearch.js +132 -0
- package/dist/esm/v2/referentiel/useReferentielSearch.js.map +1 -0
- package/dist/esm/v2/styles/base.css +425 -0
- package/dist/esm/v2/styles/css.d.ts +10 -0
- package/dist/esm/v2/styles/index.js +12 -0
- package/dist/esm/v2/styles/index.js.map +1 -0
- package/dist/esm/v2/theme/_brand.js +64 -0
- package/dist/esm/v2/theme/_brand.js.map +1 -0
- package/dist/esm/v2/theme/_brandSecondary.js +60 -0
- package/dist/esm/v2/theme/_brandSecondary.js.map +1 -0
- package/dist/esm/v2/theme/createPortnetTheme.js +548 -0
- package/dist/esm/v2/theme/createPortnetTheme.js.map +1 -0
- package/dist/esm/v2/theme/cssVariables.js +198 -0
- package/dist/esm/v2/theme/cssVariables.js.map +1 -0
- package/dist/esm/v2/theme/index.js +32 -0
- package/dist/esm/v2/theme/index.js.map +1 -0
- package/dist/esm/v2/tokens/breakpoints.js +106 -0
- package/dist/esm/v2/tokens/breakpoints.js.map +1 -0
- package/dist/esm/v2/tokens/colors.js +219 -0
- package/dist/esm/v2/tokens/colors.js.map +1 -0
- package/dist/esm/v2/tokens/density.js +98 -0
- package/dist/esm/v2/tokens/density.js.map +1 -0
- package/dist/esm/v2/tokens/index.js +80 -0
- package/dist/esm/v2/tokens/index.js.map +1 -0
- package/dist/esm/v2/tokens/motion.js +88 -0
- package/dist/esm/v2/tokens/motion.js.map +1 -0
- package/dist/esm/v2/tokens/radius.js +22 -0
- package/dist/esm/v2/tokens/radius.js.map +1 -0
- package/dist/esm/v2/tokens/shadows.js +40 -0
- package/dist/esm/v2/tokens/shadows.js.map +1 -0
- package/dist/esm/v2/tokens/spacing.js +51 -0
- package/dist/esm/v2/tokens/spacing.js.map +1 -0
- package/dist/esm/v2/tokens/state.js +41 -0
- package/dist/esm/v2/tokens/state.js.map +1 -0
- package/dist/esm/v2/tokens/statusPalette.js +66 -0
- package/dist/esm/v2/tokens/statusPalette.js.map +1 -0
- package/dist/esm/v2/tokens/tokens.json +153 -0
- package/dist/esm/v2/tokens/typography.js +149 -0
- package/dist/esm/v2/tokens/typography.js.map +1 -0
- package/dist/esm/v2/tokens/zIndex.js +44 -0
- package/dist/esm/v2/tokens/zIndex.js.map +1 -0
- package/dist/esm/v2/types/common.js +2 -0
- package/dist/esm/v2/types/common.js.map +1 -0
- package/dist/esm/v2/types/datagrid.js +2 -0
- package/dist/esm/v2/types/datagrid.js.map +1 -0
- package/dist/esm/v2/types/index.js +12 -0
- package/dist/esm/v2/types/index.js.map +1 -0
- package/dist/esm/v2/utils/apiError.js +281 -0
- package/dist/esm/v2/utils/apiError.js.map +1 -0
- package/dist/esm/v2/utils/contrast.js +157 -0
- package/dist/esm/v2/utils/contrast.js.map +1 -0
- package/dist/esm/v2/utils/cx.js +38 -0
- package/dist/esm/v2/utils/cx.js.map +1 -0
- package/dist/esm/v2/utils/fileDownload.js +226 -0
- package/dist/esm/v2/utils/fileDownload.js.map +1 -0
- package/dist/esm/v2/utils/fmtMoney.js +78 -0
- package/dist/esm/v2/utils/fmtMoney.js.map +1 -0
- package/dist/esm/v2/utils/index.js +43 -0
- package/dist/esm/v2/utils/index.js.map +1 -0
- package/dist/esm/v2/utils/mergeLabels.js +86 -0
- package/dist/esm/v2/utils/mergeLabels.js.map +1 -0
- package/dist/esm/v2/utils/networkStatus.js +114 -0
- package/dist/esm/v2/utils/networkStatus.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -1
- package/dist/v2/__tests__/FieldError.test.js +160 -0
- package/dist/v2/__tests__/FieldError.test.js.map +1 -0
- package/dist/v2/__tests__/FieldWidth.test.js +150 -0
- package/dist/v2/__tests__/FieldWidth.test.js.map +1 -0
- package/dist/v2/__tests__/FileCard.test.js +144 -0
- package/dist/v2/__tests__/FileCard.test.js.map +1 -0
- package/dist/v2/__tests__/FormikCheckbox.test.js +268 -0
- package/dist/v2/__tests__/FormikCheckbox.test.js.map +1 -0
- package/dist/v2/__tests__/FormikDateTimePicker.test.js +247 -0
- package/dist/v2/__tests__/FormikDateTimePicker.test.js.map +1 -0
- package/dist/v2/__tests__/FormikRadioGroup.test.js +381 -0
- package/dist/v2/__tests__/FormikRadioGroup.test.js.map +1 -0
- package/dist/v2/__tests__/MobileRowCard.test.js +52 -56
- package/dist/v2/__tests__/MobileRowCard.test.js.map +1 -1
- package/dist/v2/__tests__/SectionErrorBoundary.test.js +237 -0
- package/dist/v2/__tests__/SectionErrorBoundary.test.js.map +1 -0
- package/dist/v2/__tests__/labels-merge.test.js +20 -24
- package/dist/v2/__tests__/labels-merge.test.js.map +1 -1
- package/dist/v2/components/Accordion.d.ts +6 -6
- package/dist/v2/components/Accordion.d.ts.map +1 -1
- package/dist/v2/components/Accordion.js.map +1 -1
- package/dist/v2/components/ActionStrip.d.ts +12 -12
- package/dist/v2/components/ActionStrip.d.ts.map +1 -1
- package/dist/v2/components/ActionStrip.js.map +1 -1
- package/dist/v2/components/Banner.d.ts +48 -9
- package/dist/v2/components/Banner.d.ts.map +1 -1
- package/dist/v2/components/Banner.js +116 -35
- package/dist/v2/components/Banner.js.map +1 -1
- package/dist/v2/components/Busy.d.ts +3 -3
- package/dist/v2/components/Busy.d.ts.map +1 -1
- package/dist/v2/components/Busy.js.map +1 -1
- package/dist/v2/components/Button.d.ts +6 -6
- package/dist/v2/components/Button.d.ts.map +1 -1
- package/dist/v2/components/Button.js.map +1 -1
- package/dist/v2/components/CategoryTag.d.ts +3 -3
- package/dist/v2/components/CategoryTag.d.ts.map +1 -1
- package/dist/v2/components/CategoryTag.js.map +1 -1
- package/dist/v2/components/Checkbox.d.ts +11 -11
- package/dist/v2/components/Checkbox.d.ts.map +1 -1
- package/dist/v2/components/Checkbox.js.map +1 -1
- package/dist/v2/components/Chip.d.ts +8 -8
- package/dist/v2/components/Chip.d.ts.map +1 -1
- package/dist/v2/components/Chip.js +2 -1
- package/dist/v2/components/Chip.js.map +1 -1
- package/dist/v2/components/Combobox.d.ts +27 -27
- package/dist/v2/components/Combobox.d.ts.map +1 -1
- package/dist/v2/components/Combobox.js +3 -2
- package/dist/v2/components/Combobox.js.map +1 -1
- package/dist/v2/components/CommandPalette.d.ts +20 -20
- package/dist/v2/components/CommandPalette.d.ts.map +1 -1
- package/dist/v2/components/CommandPalette.js +2 -6
- package/dist/v2/components/CommandPalette.js.map +1 -1
- package/dist/v2/components/ConfirmDialog.d.ts +13 -13
- package/dist/v2/components/ConfirmDialog.d.ts.map +1 -1
- package/dist/v2/components/ConfirmDialog.js +2 -1
- package/dist/v2/components/ConfirmDialog.js.map +1 -1
- package/dist/v2/components/DatePicker.d.ts +11 -11
- package/dist/v2/components/DatePicker.d.ts.map +1 -1
- package/dist/v2/components/DatePicker.js.map +1 -1
- package/dist/v2/components/DateRangePicker.d.ts +16 -16
- package/dist/v2/components/DateRangePicker.d.ts.map +1 -1
- package/dist/v2/components/DateRangePicker.js +2 -1
- package/dist/v2/components/DateRangePicker.js.map +1 -1
- package/dist/v2/components/DateTimePicker.d.ts +11 -11
- package/dist/v2/components/DateTimePicker.d.ts.map +1 -1
- package/dist/v2/components/DateTimePicker.js +37 -4
- package/dist/v2/components/DateTimePicker.js.map +1 -1
- package/dist/v2/components/Drawer.d.ts +18 -18
- package/dist/v2/components/Drawer.d.ts.map +1 -1
- package/dist/v2/components/Drawer.js +2 -1
- package/dist/v2/components/Drawer.js.map +1 -1
- package/dist/v2/components/Dropzone.d.ts +34 -34
- package/dist/v2/components/Dropzone.d.ts.map +1 -1
- package/dist/v2/components/Dropzone.js +11 -3
- package/dist/v2/components/Dropzone.js.map +1 -1
- package/dist/v2/components/EmptyState.d.ts +7 -7
- package/dist/v2/components/EmptyState.d.ts.map +1 -1
- package/dist/v2/components/EmptyState.js.map +1 -1
- package/dist/v2/components/FavoriteToggle.d.ts +7 -7
- package/dist/v2/components/FavoriteToggle.d.ts.map +1 -1
- package/dist/v2/components/FavoriteToggle.js +2 -1
- package/dist/v2/components/FavoriteToggle.js.map +1 -1
- package/dist/v2/components/Field.d.ts +76 -13
- package/dist/v2/components/Field.d.ts.map +1 -1
- package/dist/v2/components/Field.js +87 -9
- package/dist/v2/components/Field.js.map +1 -1
- package/dist/v2/components/FieldError.d.ts +78 -0
- package/dist/v2/components/FieldError.d.ts.map +1 -0
- package/dist/v2/components/FieldError.js +131 -0
- package/dist/v2/components/FieldError.js.map +1 -0
- package/dist/v2/components/FieldHelp.d.ts +7 -7
- package/dist/v2/components/FieldHelp.d.ts.map +1 -1
- package/dist/v2/components/FieldHelp.js.map +1 -1
- package/dist/v2/components/FileCard.d.ts +75 -0
- package/dist/v2/components/FileCard.d.ts.map +1 -0
- package/dist/v2/components/FileCard.js +169 -0
- package/dist/v2/components/FileCard.js.map +1 -0
- package/dist/v2/components/FilterTab.d.ts +9 -9
- package/dist/v2/components/FilterTab.d.ts.map +1 -1
- package/dist/v2/components/FilterTab.js +2 -1
- package/dist/v2/components/FilterTab.js.map +1 -1
- package/dist/v2/components/FormGrid.d.ts +9 -4
- package/dist/v2/components/FormGrid.d.ts.map +1 -1
- package/dist/v2/components/FormGrid.js +11 -1
- package/dist/v2/components/FormGrid.js.map +1 -1
- package/dist/v2/components/FormikDisplay.d.ts +6 -6
- package/dist/v2/components/FormikDisplay.d.ts.map +1 -1
- package/dist/v2/components/FormikDisplay.js.map +1 -1
- package/dist/v2/components/Input.d.ts +6 -6
- package/dist/v2/components/Input.d.ts.map +1 -1
- package/dist/v2/components/Input.js.map +1 -1
- package/dist/v2/components/KPICard.d.ts +43 -13
- package/dist/v2/components/KPICard.d.ts.map +1 -1
- package/dist/v2/components/KPICard.js +53 -14
- package/dist/v2/components/KPICard.js.map +1 -1
- package/dist/v2/components/KPIStrip.d.ts +68 -0
- package/dist/v2/components/KPIStrip.d.ts.map +1 -0
- package/dist/v2/components/KPIStrip.js +92 -0
- package/dist/v2/components/KPIStrip.js.map +1 -0
- package/dist/v2/components/KV.d.ts +3 -3
- package/dist/v2/components/KV.d.ts.map +1 -1
- package/dist/v2/components/KV.js.map +1 -1
- package/dist/v2/components/KVGrid.d.ts +2 -2
- package/dist/v2/components/KVGrid.d.ts.map +1 -1
- package/dist/v2/components/KVGrid.js +8 -1
- package/dist/v2/components/KVGrid.js.map +1 -1
- package/dist/v2/components/Layout.d.ts +7 -7
- package/dist/v2/components/Layout.d.ts.map +1 -1
- package/dist/v2/components/Layout.js.map +1 -1
- package/dist/v2/components/MobileRowCard.d.ts +13 -13
- package/dist/v2/components/MobileRowCard.d.ts.map +1 -1
- package/dist/v2/components/MobileRowCard.js.map +1 -1
- package/dist/v2/components/Modal.d.ts +12 -12
- package/dist/v2/components/Modal.d.ts.map +1 -1
- package/dist/v2/components/Modal.js.map +1 -1
- package/dist/v2/components/NetworkErrorPage.d.ts +1 -1
- package/dist/v2/components/NetworkErrorPage.d.ts.map +1 -1
- package/dist/v2/components/NetworkErrorPage.js.map +1 -1
- package/dist/v2/components/NumberInput.d.ts +14 -14
- package/dist/v2/components/NumberInput.d.ts.map +1 -1
- package/dist/v2/components/NumberInput.js +7 -6
- package/dist/v2/components/NumberInput.js.map +1 -1
- package/dist/v2/components/OverflowMenu.d.ts +14 -14
- package/dist/v2/components/OverflowMenu.d.ts.map +1 -1
- package/dist/v2/components/OverflowMenu.js +4 -8
- package/dist/v2/components/OverflowMenu.js.map +1 -1
- package/dist/v2/components/PdfViewer.d.ts +9 -9
- package/dist/v2/components/PdfViewer.d.ts.map +1 -1
- package/dist/v2/components/PdfViewer.js.map +1 -1
- package/dist/v2/components/ProgressBar.d.ts +10 -10
- package/dist/v2/components/ProgressBar.d.ts.map +1 -1
- package/dist/v2/components/ProgressBar.js.map +1 -1
- package/dist/v2/components/Radio.d.ts +7 -7
- package/dist/v2/components/Radio.d.ts.map +1 -1
- package/dist/v2/components/Radio.js.map +1 -1
- package/dist/v2/components/SectionErrorBoundary.d.ts +89 -0
- package/dist/v2/components/SectionErrorBoundary.d.ts.map +1 -0
- package/dist/v2/components/SectionErrorBoundary.js +221 -0
- package/dist/v2/components/SectionErrorBoundary.js.map +1 -0
- package/dist/v2/components/SectionHeader.d.ts +5 -5
- package/dist/v2/components/SectionHeader.d.ts.map +1 -1
- package/dist/v2/components/SectionHeader.js.map +1 -1
- package/dist/v2/components/Segmented.d.ts +11 -11
- package/dist/v2/components/Segmented.d.ts.map +1 -1
- package/dist/v2/components/Segmented.js.map +1 -1
- package/dist/v2/components/Select.d.ts +33 -15
- package/dist/v2/components/Select.d.ts.map +1 -1
- package/dist/v2/components/Select.js +147 -30
- package/dist/v2/components/Select.js.map +1 -1
- package/dist/v2/components/ServerErrorPage.d.ts +1 -1
- package/dist/v2/components/ServerErrorPage.d.ts.map +1 -1
- package/dist/v2/components/ServerErrorPage.js.map +1 -1
- package/dist/v2/components/Skeleton.d.ts +15 -15
- package/dist/v2/components/Skeleton.d.ts.map +1 -1
- package/dist/v2/components/Skeleton.js.map +1 -1
- package/dist/v2/components/SkipLink.d.ts +2 -2
- package/dist/v2/components/SkipLink.d.ts.map +1 -1
- package/dist/v2/components/SkipLink.js.map +1 -1
- package/dist/v2/components/Status.d.ts +3 -3
- package/dist/v2/components/Status.d.ts.map +1 -1
- package/dist/v2/components/Status.js.map +1 -1
- package/dist/v2/components/Stepper.d.ts +28 -22
- package/dist/v2/components/Stepper.d.ts.map +1 -1
- package/dist/v2/components/Stepper.js +31 -5
- package/dist/v2/components/Stepper.js.map +1 -1
- package/dist/v2/components/Surface.d.ts +94 -0
- package/dist/v2/components/Surface.d.ts.map +1 -0
- package/dist/v2/components/Surface.js +163 -0
- package/dist/v2/components/Surface.js.map +1 -0
- package/dist/v2/components/Switch.d.ts +4 -4
- package/dist/v2/components/Switch.d.ts.map +1 -1
- package/dist/v2/components/Switch.js.map +1 -1
- package/dist/v2/components/Tabs.d.ts +6 -6
- package/dist/v2/components/Tabs.d.ts.map +1 -1
- package/dist/v2/components/Tabs.js.map +1 -1
- package/dist/v2/components/TelInput.d.ts +8 -8
- package/dist/v2/components/TelInput.d.ts.map +1 -1
- package/dist/v2/components/TelInput.js +18 -18
- package/dist/v2/components/TelInput.js.map +1 -1
- package/dist/v2/components/Textarea.d.ts +1 -1
- package/dist/v2/components/Textarea.d.ts.map +1 -1
- package/dist/v2/components/Textarea.js.map +1 -1
- package/dist/v2/components/TimePicker.d.ts +11 -11
- package/dist/v2/components/TimePicker.d.ts.map +1 -1
- package/dist/v2/components/TimePicker.js.map +1 -1
- package/dist/v2/components/Toast.d.ts +6 -6
- package/dist/v2/components/Toast.d.ts.map +1 -1
- package/dist/v2/components/Toast.js +9 -8
- package/dist/v2/components/Toast.js.map +1 -1
- package/dist/v2/components/Tooltip.d.ts +1 -1
- package/dist/v2/components/Tooltip.d.ts.map +1 -1
- package/dist/v2/components/Tooltip.js.map +1 -1
- package/dist/v2/components/index.d.ts +170 -0
- package/dist/v2/components/index.d.ts.map +1 -1
- package/dist/v2/components/index.js +35 -0
- package/dist/v2/components/index.js.map +1 -1
- package/dist/v2/index.d.ts.map +1 -1
- package/dist/v2/index.js.map +1 -1
- package/dist/v2/models/favorite.d.ts +1 -1
- package/dist/v2/models/favorite.d.ts.map +1 -1
- package/dist/v2/models/favorite.js.map +1 -1
- package/dist/v2/models/personalization.d.ts +13 -13
- package/dist/v2/models/personalization.d.ts.map +1 -1
- package/dist/v2/models/personalization.js.map +1 -1
- package/dist/v2/models/referentiel.d.ts +11 -11
- package/dist/v2/models/referentiel.d.ts.map +1 -1
- package/dist/v2/models/referentiel.js.map +1 -1
- package/dist/v2/models/savedFilter.d.ts +8 -8
- package/dist/v2/models/savedFilter.d.ts.map +1 -1
- package/dist/v2/models/savedFilter.js.map +1 -1
- package/dist/v2/patterns/ActionBar.d.ts +33 -33
- package/dist/v2/patterns/ActionBar.d.ts.map +1 -1
- package/dist/v2/patterns/ActionBar.js +2 -1
- package/dist/v2/patterns/ActionBar.js.map +1 -1
- package/dist/v2/patterns/BulkActionBar.d.ts +12 -12
- package/dist/v2/patterns/BulkActionBar.d.ts.map +1 -1
- package/dist/v2/patterns/BulkActionBar.js +2 -1
- package/dist/v2/patterns/BulkActionBar.js.map +1 -1
- package/dist/v2/patterns/CollapsibleDataGrid.d.ts +15 -15
- package/dist/v2/patterns/CollapsibleDataGrid.d.ts.map +1 -1
- package/dist/v2/patterns/CollapsibleDataGrid.js.map +1 -1
- package/dist/v2/patterns/ColumnsToggle.d.ts +7 -7
- package/dist/v2/patterns/ColumnsToggle.d.ts.map +1 -1
- package/dist/v2/patterns/ColumnsToggle.js +4 -8
- package/dist/v2/patterns/ColumnsToggle.js.map +1 -1
- package/dist/v2/patterns/DataGridSettingsMenu.d.ts +12 -12
- package/dist/v2/patterns/DataGridSettingsMenu.d.ts.map +1 -1
- package/dist/v2/patterns/DataGridSettingsMenu.js +9 -8
- package/dist/v2/patterns/DataGridSettingsMenu.js.map +1 -1
- package/dist/v2/patterns/DataGridToolbar.d.ts +40 -40
- package/dist/v2/patterns/DataGridToolbar.d.ts.map +1 -1
- package/dist/v2/patterns/DataGridToolbar.js +2 -1
- package/dist/v2/patterns/DataGridToolbar.js.map +1 -1
- package/dist/v2/patterns/DataGridVirtualized.d.ts +27 -27
- package/dist/v2/patterns/DataGridVirtualized.d.ts.map +1 -1
- package/dist/v2/patterns/DataGridVirtualized.js.map +1 -1
- package/dist/v2/patterns/DeleteResourceConfirmDialog.d.ts +5 -5
- package/dist/v2/patterns/DeleteResourceConfirmDialog.d.ts.map +1 -1
- package/dist/v2/patterns/DeleteResourceConfirmDialog.js.map +1 -1
- package/dist/v2/patterns/FavoriteColumn.d.ts +15 -15
- package/dist/v2/patterns/FavoriteColumn.d.ts.map +1 -1
- package/dist/v2/patterns/FavoriteColumn.js +14 -61
- package/dist/v2/patterns/FavoriteColumn.js.map +1 -1
- package/dist/v2/patterns/FavoritesFilter.d.ts +10 -10
- package/dist/v2/patterns/FavoritesFilter.d.ts.map +1 -1
- package/dist/v2/patterns/FavoritesFilter.js +2 -1
- package/dist/v2/patterns/FavoritesFilter.js.map +1 -1
- package/dist/v2/patterns/FormErrorSummary.d.ts +4 -4
- package/dist/v2/patterns/FormErrorSummary.d.ts.map +1 -1
- package/dist/v2/patterns/FormErrorSummary.js.map +1 -1
- package/dist/v2/patterns/FormPageShell.d.ts +4 -4
- package/dist/v2/patterns/FormPageShell.d.ts.map +1 -1
- package/dist/v2/patterns/FormPageShell.js.map +1 -1
- package/dist/v2/patterns/FormSection.d.ts +19 -8
- package/dist/v2/patterns/FormSection.d.ts.map +1 -1
- package/dist/v2/patterns/FormSection.js +106 -71
- package/dist/v2/patterns/FormSection.js.map +1 -1
- package/dist/v2/patterns/FormikCheckbox.d.ts +77 -0
- package/dist/v2/patterns/FormikCheckbox.d.ts.map +1 -0
- package/dist/v2/patterns/FormikCheckbox.js +147 -0
- package/dist/v2/patterns/FormikCheckbox.js.map +1 -0
- package/dist/v2/patterns/FormikCheckboxGroup.d.ts +6 -6
- package/dist/v2/patterns/FormikCheckboxGroup.d.ts.map +1 -1
- package/dist/v2/patterns/FormikCheckboxGroup.js.map +1 -1
- package/dist/v2/patterns/FormikCombobox.d.ts +18 -12
- package/dist/v2/patterns/FormikCombobox.d.ts.map +1 -1
- package/dist/v2/patterns/FormikCombobox.js +5 -2
- package/dist/v2/patterns/FormikCombobox.js.map +1 -1
- package/dist/v2/patterns/FormikDatePicker.d.ts +48 -8
- package/dist/v2/patterns/FormikDatePicker.d.ts.map +1 -1
- package/dist/v2/patterns/FormikDatePicker.js +58 -65
- package/dist/v2/patterns/FormikDatePicker.js.map +1 -1
- package/dist/v2/patterns/FormikDateTimePicker.d.ts +111 -0
- package/dist/v2/patterns/FormikDateTimePicker.d.ts.map +1 -0
- package/dist/v2/patterns/FormikDateTimePicker.js +158 -0
- package/dist/v2/patterns/FormikDateTimePicker.js.map +1 -0
- package/dist/v2/patterns/FormikErrorFocus.d.ts +3 -3
- package/dist/v2/patterns/FormikErrorFocus.d.ts.map +1 -1
- package/dist/v2/patterns/FormikErrorFocus.js.map +1 -1
- package/dist/v2/patterns/FormikFile.d.ts +8 -8
- package/dist/v2/patterns/FormikFile.d.ts.map +1 -1
- package/dist/v2/patterns/FormikFile.js.map +1 -1
- package/dist/v2/patterns/FormikInput.d.ts +51 -6
- package/dist/v2/patterns/FormikInput.d.ts.map +1 -1
- package/dist/v2/patterns/FormikInput.js +53 -2
- package/dist/v2/patterns/FormikInput.js.map +1 -1
- package/dist/v2/patterns/FormikRadioGroup.d.ts +80 -0
- package/dist/v2/patterns/FormikRadioGroup.d.ts.map +1 -0
- package/dist/v2/patterns/FormikRadioGroup.js +148 -0
- package/dist/v2/patterns/FormikRadioGroup.js.map +1 -0
- package/dist/v2/patterns/FormikReferentielField.d.ts +8 -8
- package/dist/v2/patterns/FormikReferentielField.d.ts.map +1 -1
- package/dist/v2/patterns/FormikReferentielField.js.map +1 -1
- package/dist/v2/patterns/FormikSelect.d.ts +41 -12
- package/dist/v2/patterns/FormikSelect.d.ts.map +1 -1
- package/dist/v2/patterns/FormikSelect.js +32 -3
- package/dist/v2/patterns/FormikSelect.js.map +1 -1
- package/dist/v2/patterns/FormikTextarea.d.ts +14 -6
- package/dist/v2/patterns/FormikTextarea.d.ts.map +1 -1
- package/dist/v2/patterns/FormikTextarea.js +5 -2
- package/dist/v2/patterns/FormikTextarea.js.map +1 -1
- package/dist/v2/patterns/KeyboardShortcutsHelp.d.ts +21 -8
- package/dist/v2/patterns/KeyboardShortcutsHelp.d.ts.map +1 -1
- package/dist/v2/patterns/KeyboardShortcutsHelp.js +27 -14
- package/dist/v2/patterns/KeyboardShortcutsHelp.js.map +1 -1
- package/dist/v2/patterns/NetworkErrorBanner.d.ts +4 -4
- package/dist/v2/patterns/NetworkErrorBanner.d.ts.map +1 -1
- package/dist/v2/patterns/NetworkErrorBanner.js.map +1 -1
- package/dist/v2/patterns/PageContent.d.ts +3 -3
- package/dist/v2/patterns/PageContent.d.ts.map +1 -1
- package/dist/v2/patterns/PageContent.js.map +1 -1
- package/dist/v2/patterns/ReferentielField.d.ts +49 -49
- package/dist/v2/patterns/ReferentielField.d.ts.map +1 -1
- package/dist/v2/patterns/ReferentielField.js +2 -1
- package/dist/v2/patterns/ReferentielField.js.map +1 -1
- package/dist/v2/patterns/RowFavoriteToggle.d.ts +92 -0
- package/dist/v2/patterns/RowFavoriteToggle.d.ts.map +1 -0
- package/dist/v2/patterns/RowFavoriteToggle.js +127 -0
- package/dist/v2/patterns/RowFavoriteToggle.js.map +1 -0
- package/dist/v2/patterns/SaveFilterDialog.d.ts +10 -10
- package/dist/v2/patterns/SaveFilterDialog.d.ts.map +1 -1
- package/dist/v2/patterns/SaveFilterDialog.js +9 -8
- package/dist/v2/patterns/SaveFilterDialog.js.map +1 -1
- package/dist/v2/patterns/SavedFiltersMenu.d.ts +7 -7
- package/dist/v2/patterns/SavedFiltersMenu.d.ts.map +1 -1
- package/dist/v2/patterns/SavedFiltersMenu.js +9 -8
- package/dist/v2/patterns/SavedFiltersMenu.js.map +1 -1
- package/dist/v2/patterns/SkeletonPageShell.d.ts +7 -7
- package/dist/v2/patterns/SkeletonPageShell.d.ts.map +1 -1
- package/dist/v2/patterns/SkeletonPageShell.js.map +1 -1
- package/dist/v2/patterns/SortableHeader.d.ts +1 -1
- package/dist/v2/patterns/SortableHeader.d.ts.map +1 -1
- package/dist/v2/patterns/SortableHeader.js.map +1 -1
- package/dist/v2/patterns/Tour.d.ts +12 -12
- package/dist/v2/patterns/Tour.d.ts.map +1 -1
- package/dist/v2/patterns/Tour.js +9 -8
- package/dist/v2/patterns/Tour.js.map +1 -1
- package/dist/v2/patterns/_dataGridShared.d.ts +25 -6
- package/dist/v2/patterns/_dataGridShared.d.ts.map +1 -1
- package/dist/v2/patterns/_dataGridShared.js +37 -3
- package/dist/v2/patterns/_dataGridShared.js.map +1 -1
- package/dist/v2/patterns/_pickerSerialisation.d.ts +44 -0
- package/dist/v2/patterns/_pickerSerialisation.d.ts.map +1 -0
- package/dist/v2/patterns/_pickerSerialisation.js +81 -0
- package/dist/v2/patterns/_pickerSerialisation.js.map +1 -0
- package/dist/v2/patterns/_useColumnReorder.d.ts +1 -1
- package/dist/v2/patterns/_useColumnReorder.d.ts.map +1 -1
- package/dist/v2/patterns/_useColumnReorder.js.map +1 -1
- package/dist/v2/patterns/_useColumnResize.d.ts +1 -1
- package/dist/v2/patterns/_useColumnResize.d.ts.map +1 -1
- package/dist/v2/patterns/_useColumnResize.js.map +1 -1
- package/dist/v2/patterns/index.d.ts +114 -0
- package/dist/v2/patterns/index.d.ts.map +1 -1
- package/dist/v2/patterns/index.js +34 -0
- package/dist/v2/patterns/index.js.map +1 -1
- package/dist/v2/personalization/PersonalizationProvider.d.ts +9 -9
- package/dist/v2/personalization/PersonalizationProvider.d.ts.map +1 -1
- package/dist/v2/personalization/PersonalizationProvider.js.map +1 -1
- package/dist/v2/personalization/adapters/createLocalStorageAdapter.d.ts +1 -1
- package/dist/v2/personalization/adapters/createLocalStorageAdapter.d.ts.map +1 -1
- package/dist/v2/personalization/adapters/createLocalStorageAdapter.js.map +1 -1
- package/dist/v2/personalization/adapters/createMemoryAdapter.d.ts +1 -1
- package/dist/v2/personalization/adapters/createMemoryAdapter.d.ts.map +1 -1
- package/dist/v2/personalization/adapters/createMemoryAdapter.js.map +1 -1
- package/dist/v2/personalization/capabilities/favoritesView.d.ts +3 -3
- package/dist/v2/personalization/capabilities/favoritesView.d.ts.map +1 -1
- package/dist/v2/personalization/capabilities/favoritesView.js.map +1 -1
- package/dist/v2/personalization/capabilities/gridPreferences.d.ts +100 -0
- package/dist/v2/personalization/capabilities/gridPreferences.d.ts.map +1 -0
- package/dist/v2/personalization/capabilities/gridPreferences.js +215 -0
- package/dist/v2/personalization/capabilities/gridPreferences.js.map +1 -0
- package/dist/v2/personalization/capabilities/index.d.ts +6 -0
- package/dist/v2/personalization/capabilities/index.d.ts.map +1 -1
- package/dist/v2/personalization/capabilities/index.js +13 -0
- package/dist/v2/personalization/capabilities/index.js.map +1 -1
- package/dist/v2/personalization/capabilities/savedFilters.d.ts +3 -3
- package/dist/v2/personalization/capabilities/savedFilters.d.ts.map +1 -1
- package/dist/v2/personalization/capabilities/savedFilters.js.map +1 -1
- package/dist/v2/personalization/createPersonalizationStore.d.ts +8 -8
- package/dist/v2/personalization/createPersonalizationStore.d.ts.map +1 -1
- package/dist/v2/personalization/createPersonalizationStore.js.map +1 -1
- package/dist/v2/personalization/index.d.ts +18 -0
- package/dist/v2/personalization/index.d.ts.map +1 -1
- package/dist/v2/personalization/index.js +13 -0
- package/dist/v2/personalization/index.js.map +1 -1
- package/dist/v2/personalization/schema.d.ts +2 -2
- package/dist/v2/personalization/schema.d.ts.map +1 -1
- package/dist/v2/personalization/schema.js.map +1 -1
- package/dist/v2/personalization/types.d.ts +19 -19
- package/dist/v2/personalization/types.d.ts.map +1 -1
- package/dist/v2/personalization/types.js.map +1 -1
- package/dist/v2/referentiel/ReferentielProvider.d.ts +4 -4
- package/dist/v2/referentiel/ReferentielProvider.d.ts.map +1 -1
- package/dist/v2/referentiel/ReferentielProvider.js.map +1 -1
- package/dist/v2/referentiel/useReferentielOptions.d.ts +4 -4
- package/dist/v2/referentiel/useReferentielOptions.d.ts.map +1 -1
- package/dist/v2/referentiel/useReferentielOptions.js.map +1 -1
- package/dist/v2/referentiel/useReferentielSearch.d.ts +3 -3
- package/dist/v2/referentiel/useReferentielSearch.d.ts.map +1 -1
- package/dist/v2/referentiel/useReferentielSearch.js.map +1 -1
- package/dist/v2/theme/createPortnetTheme.d.ts +32 -7
- package/dist/v2/theme/createPortnetTheme.d.ts.map +1 -1
- package/dist/v2/theme/createPortnetTheme.js +25 -1
- package/dist/v2/theme/createPortnetTheme.js.map +1 -1
- package/dist/v2/types/datagrid.d.ts +59 -59
- package/dist/v2/types/datagrid.d.ts.map +1 -1
- package/dist/v2/types/datagrid.js.map +1 -1
- package/dist/v2/utils/apiError.d.ts +65 -4
- package/dist/v2/utils/apiError.d.ts.map +1 -1
- package/dist/v2/utils/apiError.js +69 -6
- package/dist/v2/utils/apiError.js.map +1 -1
- package/dist/v2/utils/index.d.ts +1 -0
- package/dist/v2/utils/index.d.ts.map +1 -1
- package/dist/v2/utils/index.js +7 -0
- package/dist/v2/utils/index.js.map +1 -1
- package/dist/v2/utils/mergeLabels.d.ts +59 -0
- package/dist/v2/utils/mergeLabels.d.ts.map +1 -0
- package/dist/v2/utils/mergeLabels.js +93 -0
- package/dist/v2/utils/mergeLabels.js.map +1 -0
- package/package.json +23 -15
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
/**
|
|
3
|
+
* createLocalStorageAdapter — Portnet UI v2 · personalization
|
|
4
|
+
*
|
|
5
|
+
* Default Adapter. Persists each capability as an opaque envelope under a
|
|
6
|
+
* scoped key (see adapters/_storageKey.ts). The adapter never interprets
|
|
7
|
+
* `envelope.payload`.
|
|
8
|
+
*
|
|
9
|
+
* Safety:
|
|
10
|
+
* - SSR-safe: with no `window`, the adapter is inert (load → {}, save →
|
|
11
|
+
* resolved no-op) so it can be constructed anywhere.
|
|
12
|
+
* - Every storage access is try/catch-wrapped. `save` REJECTS on quota/
|
|
13
|
+
* private-mode failure so the store can keep the optimistic value for the
|
|
14
|
+
* session and surface the error via onError.
|
|
15
|
+
* - Reads self-heal: malformed entries are removed on sight.
|
|
16
|
+
* - Reserved-key hardening: capability ids of `__proto__` / `constructor` /
|
|
17
|
+
* `prototype` are skipped while scanning so a crafted same-origin key can't
|
|
18
|
+
* reach the `__proto__` setter on the accumulator (SEC-LS1).
|
|
19
|
+
* - NOTE: localStorage is readable by any same-origin script. Do NOT persist
|
|
20
|
+
* secrets or PII in a capability payload (SEC-LS2).
|
|
21
|
+
*
|
|
22
|
+
* Cross-tab: `subscribe` listens to the `storage` event, which the spec fires
|
|
23
|
+
* in OTHER tabs only — the writing tab is reconciled via the store's in-memory
|
|
24
|
+
* path.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { buildKey, buildScopePrefix } from "./_storageKey";
|
|
28
|
+
/** Object keys that must never be written from external (storage-derived) data. */
|
|
29
|
+
var RESERVED_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
30
|
+
export default function createLocalStorageAdapter(options) {
|
|
31
|
+
var opts = options || {};
|
|
32
|
+
var storage = opts.storage || (typeof window !== "undefined" && window.localStorage ? window.localStorage : null);
|
|
33
|
+
function isValidEnvelope(env) {
|
|
34
|
+
return !!env && _typeof(env) === "object" && Object.prototype.hasOwnProperty.call(env, "payload");
|
|
35
|
+
}
|
|
36
|
+
function safeRemove(key) {
|
|
37
|
+
if (!storage) return;
|
|
38
|
+
try {
|
|
39
|
+
storage.removeItem(key);
|
|
40
|
+
} catch (_unused) {
|
|
41
|
+
/* ignore */
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Synchronous scan of every capability blob for `scope`. */
|
|
46
|
+
function loadSync(scope) {
|
|
47
|
+
if (!storage) return {};
|
|
48
|
+
var out = {};
|
|
49
|
+
try {
|
|
50
|
+
var prefix = buildScopePrefix(scope);
|
|
51
|
+
for (var i = 0; i < storage.length; i++) {
|
|
52
|
+
var key = storage.key(i);
|
|
53
|
+
if (!key || key.indexOf(prefix) !== 0) continue;
|
|
54
|
+
var capId = key.slice(prefix.length);
|
|
55
|
+
// Skip empty + reserved keys: a same-origin writer could craft a
|
|
56
|
+
// `<prefix>__proto__` key, and `out[capId] = env` would otherwise hit
|
|
57
|
+
// the __proto__ setter on the accumulator (SEC-LS1).
|
|
58
|
+
if (!capId || RESERVED_KEYS.has(capId)) continue;
|
|
59
|
+
var raw = storage.getItem(key);
|
|
60
|
+
if (!raw) continue;
|
|
61
|
+
try {
|
|
62
|
+
var env = JSON.parse(raw);
|
|
63
|
+
if (isValidEnvelope(env)) out[capId] = env;else safeRemove(key);
|
|
64
|
+
} catch (_unused2) {
|
|
65
|
+
safeRemove(key);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} catch (_unused3) {
|
|
69
|
+
/* enumeration blocked (sandboxed) — return what we have */
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
function load(scope) {
|
|
74
|
+
return Promise.resolve(loadSync(scope));
|
|
75
|
+
}
|
|
76
|
+
function save(scope, capabilityId, envelope) {
|
|
77
|
+
if (!storage) return Promise.resolve();
|
|
78
|
+
try {
|
|
79
|
+
storage.setItem(buildKey(scope, capabilityId), JSON.stringify(envelope));
|
|
80
|
+
return Promise.resolve();
|
|
81
|
+
} catch (e) {
|
|
82
|
+
// Quota exceeded / private mode / sandboxed: reject so the store keeps
|
|
83
|
+
// the optimistic in-memory value and notifies onError.
|
|
84
|
+
return Promise.reject(e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function remove(scope, capabilityId) {
|
|
88
|
+
if (!storage) return Promise.resolve();
|
|
89
|
+
safeRemove(buildKey(scope, capabilityId));
|
|
90
|
+
return Promise.resolve();
|
|
91
|
+
}
|
|
92
|
+
function subscribe(scope, onChange) {
|
|
93
|
+
if (typeof window === "undefined" || typeof window.addEventListener !== "function") {
|
|
94
|
+
return function noop() {};
|
|
95
|
+
}
|
|
96
|
+
var prefix = buildScopePrefix(scope);
|
|
97
|
+
var handler = function handleStorage(e) {
|
|
98
|
+
if (!e || e.key == null) return; // e.key === null on storage.clear()
|
|
99
|
+
// storageArea may be undefined in some environments; only filter when present.
|
|
100
|
+
if (e.storageArea && e.storageArea !== storage) return;
|
|
101
|
+
if (e.key.indexOf(prefix) !== 0) return;
|
|
102
|
+
var capId = e.key.slice(prefix.length);
|
|
103
|
+
if (capId && !RESERVED_KEYS.has(capId)) onChange(capId);
|
|
104
|
+
};
|
|
105
|
+
window.addEventListener("storage", handler);
|
|
106
|
+
return function unsubscribe() {
|
|
107
|
+
window.removeEventListener("storage", handler);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return Object.freeze({
|
|
111
|
+
name: "localStorage",
|
|
112
|
+
load: load,
|
|
113
|
+
loadSync: loadSync,
|
|
114
|
+
save: save,
|
|
115
|
+
remove: remove,
|
|
116
|
+
subscribe: subscribe,
|
|
117
|
+
capabilities: Object.freeze({
|
|
118
|
+
crossTab: true,
|
|
119
|
+
remote: false,
|
|
120
|
+
shared: false
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=createLocalStorageAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLocalStorageAdapter.js","names":["buildKey","buildScopePrefix","RESERVED_KEYS","Set","createLocalStorageAdapter","options","opts","storage","window","localStorage","isValidEnvelope","env","_typeof","Object","prototype","hasOwnProperty","call","safeRemove","key","removeItem","_unused","loadSync","scope","out","prefix","i","length","indexOf","capId","slice","has","raw","getItem","JSON","parse","_unused2","_unused3","load","Promise","resolve","save","capabilityId","envelope","setItem","stringify","e","reject","remove","subscribe","onChange","addEventListener","noop","handler","handleStorage","storageArea","unsubscribe","removeEventListener","freeze","name","capabilities","crossTab","remote","shared"],"sources":["../../../../../src/lib/v2/personalization/adapters/createLocalStorageAdapter.ts"],"sourcesContent":["/**\r\n * createLocalStorageAdapter — Portnet UI v2 · personalization\r\n *\r\n * Default Adapter. Persists each capability as an opaque envelope under a\r\n * scoped key (see adapters/_storageKey.ts). The adapter never interprets\r\n * `envelope.payload`.\r\n *\r\n * Safety:\r\n * - SSR-safe: with no `window`, the adapter is inert (load → {}, save →\r\n * resolved no-op) so it can be constructed anywhere.\r\n * - Every storage access is try/catch-wrapped. `save` REJECTS on quota/\r\n * private-mode failure so the store can keep the optimistic value for the\r\n * session and surface the error via onError.\r\n * - Reads self-heal: malformed entries are removed on sight.\r\n * - Reserved-key hardening: capability ids of `__proto__` / `constructor` /\r\n * `prototype` are skipped while scanning so a crafted same-origin key can't\r\n * reach the `__proto__` setter on the accumulator (SEC-LS1).\r\n * - NOTE: localStorage is readable by any same-origin script. Do NOT persist\r\n * secrets or PII in a capability payload (SEC-LS2).\r\n *\r\n * Cross-tab: `subscribe` listens to the `storage` event, which the spec fires\r\n * in OTHER tabs only — the writing tab is reconciled via the store's in-memory\r\n * path.\r\n */\r\n\r\nimport { buildKey, buildScopePrefix } from \"./_storageKey\";\r\nimport type { Adapter, Envelope, Scope } from \"../types\";\r\n\r\nexport interface LocalStorageAdapterOptions {\r\n /** Inject a Storage impl (tests / custom). */\r\n storage?: Storage | undefined;\r\n}\r\n\r\n/** Object keys that must never be written from external (storage-derived) data. */\r\nconst RESERVED_KEYS = new Set([\"__proto__\", \"constructor\", \"prototype\"]);\r\n\r\nexport default function createLocalStorageAdapter(\r\n options?: LocalStorageAdapterOptions\r\n): Adapter {\r\n const opts: LocalStorageAdapterOptions = options || {};\r\n const storage: Storage | null =\r\n opts.storage ||\r\n (typeof window !== \"undefined\" && window.localStorage\r\n ? window.localStorage\r\n : null);\r\n\r\n function isValidEnvelope(env: unknown): env is Envelope {\r\n return (\r\n !!env &&\r\n typeof env === \"object\" &&\r\n Object.prototype.hasOwnProperty.call(env, \"payload\")\r\n );\r\n }\r\n\r\n function safeRemove(key: string): void {\r\n if (!storage) return;\r\n try {\r\n storage.removeItem(key);\r\n } catch {\r\n /* ignore */\r\n }\r\n }\r\n\r\n /** Synchronous scan of every capability blob for `scope`. */\r\n function loadSync(scope: Scope): Record<string, Envelope> {\r\n if (!storage) return {};\r\n const out: Record<string, Envelope> = {};\r\n try {\r\n const prefix = buildScopePrefix(scope);\r\n for (let i = 0; i < storage.length; i++) {\r\n const key = storage.key(i);\r\n if (!key || key.indexOf(prefix) !== 0) continue;\r\n const capId = key.slice(prefix.length);\r\n // Skip empty + reserved keys: a same-origin writer could craft a\r\n // `<prefix>__proto__` key, and `out[capId] = env` would otherwise hit\r\n // the __proto__ setter on the accumulator (SEC-LS1).\r\n if (!capId || RESERVED_KEYS.has(capId)) continue;\r\n const raw = storage.getItem(key);\r\n if (!raw) continue;\r\n try {\r\n const env: unknown = JSON.parse(raw);\r\n if (isValidEnvelope(env)) out[capId] = env;\r\n else safeRemove(key);\r\n } catch {\r\n safeRemove(key);\r\n }\r\n }\r\n } catch {\r\n /* enumeration blocked (sandboxed) — return what we have */\r\n }\r\n return out;\r\n }\r\n\r\n function load(scope: Scope): Promise<Record<string, Envelope>> {\r\n return Promise.resolve(loadSync(scope));\r\n }\r\n\r\n function save(\r\n scope: Scope,\r\n capabilityId: string,\r\n envelope: Envelope\r\n ): Promise<void> {\r\n if (!storage) return Promise.resolve();\r\n try {\r\n storage.setItem(buildKey(scope, capabilityId), JSON.stringify(envelope));\r\n return Promise.resolve();\r\n } catch (e) {\r\n // Quota exceeded / private mode / sandboxed: reject so the store keeps\r\n // the optimistic in-memory value and notifies onError.\r\n return Promise.reject(e);\r\n }\r\n }\r\n\r\n function remove(scope: Scope, capabilityId: string): Promise<void> {\r\n if (!storage) return Promise.resolve();\r\n safeRemove(buildKey(scope, capabilityId));\r\n return Promise.resolve();\r\n }\r\n\r\n function subscribe(\r\n scope: Scope,\r\n onChange: (capabilityId: string) => void\r\n ): () => void {\r\n if (\r\n typeof window === \"undefined\" ||\r\n typeof window.addEventListener !== \"function\"\r\n ) {\r\n return function noop() {};\r\n }\r\n const prefix = buildScopePrefix(scope);\r\n const handler = function handleStorage(e: StorageEvent) {\r\n if (!e || e.key == null) return; // e.key === null on storage.clear()\r\n // storageArea may be undefined in some environments; only filter when present.\r\n if (e.storageArea && e.storageArea !== storage) return;\r\n if (e.key.indexOf(prefix) !== 0) return;\r\n const capId = e.key.slice(prefix.length);\r\n if (capId && !RESERVED_KEYS.has(capId)) onChange(capId);\r\n };\r\n window.addEventListener(\"storage\", handler);\r\n return function unsubscribe() {\r\n window.removeEventListener(\"storage\", handler);\r\n };\r\n }\r\n\r\n return Object.freeze({\r\n name: \"localStorage\",\r\n load,\r\n loadSync,\r\n save,\r\n remove,\r\n subscribe,\r\n capabilities: Object.freeze({\r\n crossTab: true,\r\n remote: false,\r\n shared: false,\r\n }),\r\n });\r\n}\r\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,gBAAgB,QAAQ,eAAe;AAQ1D;AACA,IAAMC,aAAa,GAAG,IAAIC,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;AAExE,eAAe,SAASC,yBAAyBA,CAC/CC,OAAoC,EAC3B;EACT,IAAMC,IAAgC,GAAGD,OAAO,IAAI,CAAC,CAAC;EACtD,IAAME,OAAuB,GAC3BD,IAAI,CAACC,OAAO,KACX,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,YAAY,GACjDD,MAAM,CAACC,YAAY,GACnB,IAAI,CAAC;EAEX,SAASC,eAAeA,CAACC,GAAY,EAAmB;IACtD,OACE,CAAC,CAACA,GAAG,IACLC,OAAA,CAAOD,GAAG,MAAK,QAAQ,IACvBE,MAAM,CAACC,SAAS,CAACC,cAA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OAAO,CAAC;MACjC;MACA,IAAI2B,CAAC,CAACS,WAAW,IAAIT,CAAC,CAACS,WAAW,KAAK/C,OAAO,EAAE;MAChD,IAAIsC,CAAC,CAAC3B,GAAG,CAACS,OAAO,CAACH,MAAM,CAAC,KAAK,CAAC,EAAE;MACjC,IAAMI,KAAK,GAAGiB,CAAC,CAAC3B,GAAG,CAACW,KAAK,CAACL,MAAM,CAACE,MAAM,CAAC;MACxC,IAAIE,KAAK,IAAI,CAAC1B,aAAa,CAAC4B,GAAG,CAACF,KAAK,CAAC,EAAEqB,QAAQ,CAACrB,KAAK,CAAC;IACzD,CAAC;IACDpB,MAAM,CAAC0C,gBAAgB,CAAC,SAAS,EAAEE,OAAO,CAAC;IAC3C,OAAO,SAASG,WAAWA,CAAA,EAAG;MAC5B/C,MAAM,CAACgD,mBAAmB,CAAC,SAAS,EAAEJ,OAAO,CAAC;IAChD,CAAC;EACH;EAEA,OAAOvC,MAAM,CAAC4C,MAAM,CAAC;IACnBC,IAAI,EAAE,cAAc;IACpBrB,IAAI,EAAJA,IAAI;IACJhB,QAAQ,EAARA,QAAQ;IACRmB,IAAI,EAAJA,IAAI;IACJO,MAAM,EAANA,MAAM;IACNC,SAAS,EAATA,SAAS;IACTW,YAAY,EAAE9C,MAAM,CAAC4C,MAAM,CAAC;MAC1BG,QAAQ,EAAE,IAAI;MACdC,MAAM,EAAE,KAAK;MACbC,MAAM,EAAE;IACV,CAAC;EACH,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createMemoryAdapter — Portnet UI v2 · personalization
|
|
3
|
+
*
|
|
4
|
+
* An Adapter that keeps everything in a Map. Use it for:
|
|
5
|
+
* - unit tests (deterministic, no global storage state),
|
|
6
|
+
* - SSR / sandboxed environments where localStorage is unavailable,
|
|
7
|
+
* - Storybook stories (optionally pre-seeded),
|
|
8
|
+
* - an explicit "do not persist" opt-out.
|
|
9
|
+
*
|
|
10
|
+
* Same contract as the localStorage adapter minus `subscribe` (a single
|
|
11
|
+
* in-memory context has no cross-tab notion). `remote:false` lets the store
|
|
12
|
+
* skip the redundant async re-hydrate after a synchronous seed.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export default function createMemoryAdapter(options) {
|
|
16
|
+
var opts = options || {};
|
|
17
|
+
/** composite key -> envelope */
|
|
18
|
+
var map = new Map();
|
|
19
|
+
function compositeKey(scope, capabilityId) {
|
|
20
|
+
var tenant = scope && scope.tenantId ? scope.tenantId : "";
|
|
21
|
+
var user = scope && scope.userId ? scope.userId : "";
|
|
22
|
+
return tenant + "::" + user + "::" + capabilityId;
|
|
23
|
+
}
|
|
24
|
+
function scopePrefix(scope) {
|
|
25
|
+
var tenant = scope && scope.tenantId ? scope.tenantId : "";
|
|
26
|
+
var user = scope && scope.userId ? scope.userId : "";
|
|
27
|
+
return tenant + "::" + user + "::";
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(opts.seed)) {
|
|
30
|
+
opts.seed.forEach(function seedEntry(entry) {
|
|
31
|
+
if (entry && entry.scope && entry.capabilityId && entry.envelope) {
|
|
32
|
+
map.set(compositeKey(entry.scope, entry.capabilityId), entry.envelope);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function loadSync(scope) {
|
|
37
|
+
var out = {};
|
|
38
|
+
var prefix = scopePrefix(scope);
|
|
39
|
+
map.forEach(function collect(envelope, key) {
|
|
40
|
+
if (key.indexOf(prefix) === 0) {
|
|
41
|
+
out[key.slice(prefix.length)] = envelope;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
function load(scope) {
|
|
47
|
+
return Promise.resolve(loadSync(scope));
|
|
48
|
+
}
|
|
49
|
+
function save(scope, capabilityId, envelope) {
|
|
50
|
+
map.set(compositeKey(scope, capabilityId), envelope);
|
|
51
|
+
return Promise.resolve();
|
|
52
|
+
}
|
|
53
|
+
function remove(scope, capabilityId) {
|
|
54
|
+
map["delete"](compositeKey(scope, capabilityId));
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
}
|
|
57
|
+
return Object.freeze({
|
|
58
|
+
name: "memory",
|
|
59
|
+
load: load,
|
|
60
|
+
loadSync: loadSync,
|
|
61
|
+
save: save,
|
|
62
|
+
remove: remove,
|
|
63
|
+
capabilities: Object.freeze({
|
|
64
|
+
crossTab: false,
|
|
65
|
+
remote: false,
|
|
66
|
+
shared: false
|
|
67
|
+
})
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=createMemoryAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMemoryAdapter.js","names":["createMemoryAdapter","options","opts","map","Map","compositeKey","scope","capabilityId","tenant","tenantId","user","userId","scopePrefix","Array","isArray","seed","forEach","seedEntry","entry","envelope","set","loadSync","out","prefix","collect","key","indexOf","slice","length","load","Promise","resolve","save","remove","Object","freeze","name","capabilities","crossTab","remote","shared"],"sources":["../../../../../src/lib/v2/personalization/adapters/createMemoryAdapter.ts"],"sourcesContent":["/**\r\n * createMemoryAdapter — Portnet UI v2 · personalization\r\n *\r\n * An Adapter that keeps everything in a Map. Use it for:\r\n * - unit tests (deterministic, no global storage state),\r\n * - SSR / sandboxed environments where localStorage is unavailable,\r\n * - Storybook stories (optionally pre-seeded),\r\n * - an explicit \"do not persist\" opt-out.\r\n *\r\n * Same contract as the localStorage adapter minus `subscribe` (a single\r\n * in-memory context has no cross-tab notion). `remote:false` lets the store\r\n * skip the redundant async re-hydrate after a synchronous seed.\r\n */\r\n\r\nimport type { Adapter, Envelope, Scope } from \"../types\";\r\n\r\nexport interface MemoryAdapterSeedEntry {\r\n scope: Scope;\r\n capabilityId: string;\r\n envelope: Envelope;\r\n}\r\n\r\nexport interface MemoryAdapterOptions {\r\n /** Optional pre-populated entries for tests/stories. */\r\n seed?: MemoryAdapterSeedEntry[] | undefined;\r\n}\r\n\r\nexport default function createMemoryAdapter(\r\n options?: MemoryAdapterOptions\r\n): Adapter {\r\n const opts: MemoryAdapterOptions = options || {};\r\n /** composite key -> envelope */\r\n const map = new Map<string, Envelope>();\r\n\r\n function compositeKey(scope: Scope, capabilityId: string): string {\r\n const tenant = scope && scope.tenantId ? scope.tenantId : \"\";\r\n const user = scope && scope.userId ? scope.userId : \"\";\r\n return tenant + \"::\" + user + \"::\" + capabilityId;\r\n }\r\n\r\n function scopePrefix(scope: Scope): string {\r\n const tenant = scope && scope.tenantId ? scope.tenantId : \"\";\r\n const user = scope && scope.userId ? scope.userId : \"\";\r\n return tenant + \"::\" + user + \"::\";\r\n }\r\n\r\n if (Array.isArray(opts.seed)) {\r\n opts.seed.forEach(function seedEntry(entry) {\r\n if (entry && entry.scope && entry.capabilityId && entry.envelope) {\r\n map.set(compositeKey(entry.scope, entry.capabilityId), entry.envelope);\r\n }\r\n });\r\n }\r\n\r\n function loadSync(scope: Scope): Record<string, Envelope> {\r\n const out: Record<string, Envelope> = {};\r\n const prefix = scopePrefix(scope);\r\n map.forEach(function collect(envelope, key) {\r\n if (key.indexOf(prefix) === 0) {\r\n out[key.slice(prefix.length)] = envelope;\r\n }\r\n });\r\n return out;\r\n }\r\n\r\n function load(scope: Scope): Promise<Record<string, Envelope>> {\r\n return Promise.resolve(loadSync(scope));\r\n }\r\n\r\n function save(\r\n scope: Scope,\r\n capabilityId: string,\r\n envelope: Envelope\r\n ): Promise<void> {\r\n map.set(compositeKey(scope, capabilityId), envelope);\r\n return Promise.resolve();\r\n }\r\n\r\n function remove(scope: Scope, capabilityId: string): Promise<void> {\r\n map.delete(compositeKey(scope, capabilityId));\r\n return Promise.resolve();\r\n }\r\n\r\n return Object.freeze({\r\n name: \"memory\",\r\n load,\r\n loadSync,\r\n save,\r\n remove,\r\n capabilities: Object.freeze({\r\n crossTab: false,\r\n remote: false,\r\n shared: false,\r\n }),\r\n });\r\n}\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA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0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* adapters — Portnet UI v2 · personalization
|
|
3
|
+
*
|
|
4
|
+
* Built-in storage adapters. A future remote adapter
|
|
5
|
+
* (createRestPersonalizationAdapter) drops in here and is swappable with
|
|
6
|
+
* zero changes to the store, the slices, the hooks, or the components.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export { default as createLocalStorageAdapter } from "./createLocalStorageAdapter";
|
|
10
|
+
export { default as createMemoryAdapter } from "./createMemoryAdapter";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","createLocalStorageAdapter","createMemoryAdapter"],"sources":["../../../../../src/lib/v2/personalization/adapters/index.ts"],"sourcesContent":["/**\r\n * adapters — Portnet UI v2 · personalization\r\n *\r\n * Built-in storage adapters. A future remote adapter\r\n * (createRestPersonalizationAdapter) drops in here and is swappable with\r\n * zero changes to the store, the slices, the hooks, or the components.\r\n */\r\n\r\nexport { default as createLocalStorageAdapter } from \"./createLocalStorageAdapter\";\r\nexport { default as createMemoryAdapter } from \"./createMemoryAdapter\";\r\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,IAAIC,yBAAyB,QAAQ,6BAA6B;AAClF,SAASD,OAAO,IAAIE,mBAAmB,QAAQ,uBAAuB","ignoreList":[]}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
4
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
5
|
+
/**
|
|
6
|
+
* favorites — Portnet UI v2 · personalization capability
|
|
7
|
+
*
|
|
8
|
+
* The Favorites framework. Self-registers the "favorites" capability with
|
|
9
|
+
* the schema registry at import time, so the capability-agnostic
|
|
10
|
+
* foundation discovers its schemaVersion / defaultState / migrate without
|
|
11
|
+
* any hardcoding.
|
|
12
|
+
*
|
|
13
|
+
* State model (the capability payload):
|
|
14
|
+
* { [resourceKey]: FavoriteRef[] } FavoriteRef = { id, addedAt }
|
|
15
|
+
*
|
|
16
|
+
* `resourceKey` namespaces favorites per list/entity type (e.g.
|
|
17
|
+
* "ti:list", "declarations:list"), so one user's favorites across
|
|
18
|
+
* different screens never collide. `id` is the business row id.
|
|
19
|
+
*
|
|
20
|
+
* Performance: the pure helpers below rebuild only the touched
|
|
21
|
+
* resourceKey's array and shallow-copy the map, so the store's structural
|
|
22
|
+
* sharing keeps every OTHER resource's list referentially stable —
|
|
23
|
+
* toggling a favorite on screen B does not re-render screen A, and a
|
|
24
|
+
* boolean per-row selector lets each grid cell re-render only when its own
|
|
25
|
+
* membership flips.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import * as React from "react";
|
|
29
|
+
import { registerCapability } from "../schema";
|
|
30
|
+
import { usePersonalizationStore, useStoreSelector } from "../personalizationContext";
|
|
31
|
+
|
|
32
|
+
/** The favorites capability payload: favorites arrays keyed by resourceKey. */
|
|
33
|
+
|
|
34
|
+
export var FAVORITES_CAPABILITY_ID = "favorites";
|
|
35
|
+
var SCHEMA_VERSION = 1;
|
|
36
|
+
var EMPTY_LIST = Object.freeze([]);
|
|
37
|
+
var EMPTY_MAP = Object.freeze({});
|
|
38
|
+
|
|
39
|
+
/* Register at import time — the foundation reads this at hydration. */
|
|
40
|
+
registerCapability({
|
|
41
|
+
id: FAVORITES_CAPABILITY_ID,
|
|
42
|
+
schemaVersion: SCHEMA_VERSION,
|
|
43
|
+
defaultState: EMPTY_MAP,
|
|
44
|
+
// { [resourceKey]: FavoriteRef[] }
|
|
45
|
+
migrate: function migrateFavorites(_fromVersion, payload) {
|
|
46
|
+
// v1 is the initial schema. Defensive normalisation only.
|
|
47
|
+
return payload && _typeof(payload) === "object" ? payload : {};
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/* ── pure, resourceKey-scoped state helpers (structural sharing) ────── */
|
|
52
|
+
|
|
53
|
+
function listFor(map, resourceKey) {
|
|
54
|
+
var list = map ? map[resourceKey] : undefined;
|
|
55
|
+
return Array.isArray(list) ? list : EMPTY_LIST;
|
|
56
|
+
}
|
|
57
|
+
function hasRef(map, resourceKey, id) {
|
|
58
|
+
var list = listFor(map, resourceKey);
|
|
59
|
+
var _iterator = _createForOfIteratorHelper(list),
|
|
60
|
+
_step;
|
|
61
|
+
try {
|
|
62
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
63
|
+
var ref = _step.value;
|
|
64
|
+
if (ref.id === id) return true;
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
_iterator.e(err);
|
|
68
|
+
} finally {
|
|
69
|
+
_iterator.f();
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
function addRef(map, resourceKey, id) {
|
|
74
|
+
var base = map || EMPTY_MAP;
|
|
75
|
+
if (hasRef(base, resourceKey, id)) return base; // no-op → store short-circuits
|
|
76
|
+
var nextList = listFor(base, resourceKey).concat([{
|
|
77
|
+
id: id,
|
|
78
|
+
addedAt: new Date().toISOString()
|
|
79
|
+
}]);
|
|
80
|
+
var next = Object.assign({}, base);
|
|
81
|
+
next[resourceKey] = nextList;
|
|
82
|
+
return next;
|
|
83
|
+
}
|
|
84
|
+
function removeRef(map, resourceKey, id) {
|
|
85
|
+
var base = map || EMPTY_MAP;
|
|
86
|
+
if (!hasRef(base, resourceKey, id)) return base; // no-op
|
|
87
|
+
var nextList = listFor(base, resourceKey).filter(function keep(r) {
|
|
88
|
+
return r.id !== id;
|
|
89
|
+
});
|
|
90
|
+
var next = Object.assign({}, base);
|
|
91
|
+
if (nextList.length === 0) delete next[resourceKey]; // keep the map tidy
|
|
92
|
+
else next[resourceKey] = nextList;
|
|
93
|
+
return next;
|
|
94
|
+
}
|
|
95
|
+
function toggleRef(map, resourceKey, id) {
|
|
96
|
+
return hasRef(map, resourceKey, id) ? removeRef(map, resourceKey, id) : addRef(map, resourceKey, id);
|
|
97
|
+
}
|
|
98
|
+
function clearRefs(map, resourceKey) {
|
|
99
|
+
var base = map || EMPTY_MAP;
|
|
100
|
+
if (!base[resourceKey]) return base;
|
|
101
|
+
var next = Object.assign({}, base);
|
|
102
|
+
delete next[resourceKey];
|
|
103
|
+
return next;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* ── hooks ──────────────────────────────────────────────────────────── */
|
|
107
|
+
|
|
108
|
+
function useEnsureFavorites(store) {
|
|
109
|
+
React.useEffect(function ensure() {
|
|
110
|
+
store.ensureCapability(FAVORITES_CAPABILITY_ID);
|
|
111
|
+
}, [store]);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* useFavorites(resourceKey) — list, membership and actions for one resource.
|
|
115
|
+
*/
|
|
116
|
+
export function useFavorites(resourceKey) {
|
|
117
|
+
var store = usePersonalizationStore();
|
|
118
|
+
useEnsureFavorites(store);
|
|
119
|
+
var selectList = React.useCallback(function selectList(snapshot) {
|
|
120
|
+
var slice = snapshot[FAVORITES_CAPABILITY_ID];
|
|
121
|
+
return slice ? listFor(slice, resourceKey) : EMPTY_LIST;
|
|
122
|
+
}, [resourceKey]);
|
|
123
|
+
var items = useStoreSelector(selectList);
|
|
124
|
+
|
|
125
|
+
// Stable while `items` is stable (structural sharing) → O(1) membership.
|
|
126
|
+
var ids = React.useMemo(function buildIdSet() {
|
|
127
|
+
var set = new Set();
|
|
128
|
+
var _iterator2 = _createForOfIteratorHelper(items),
|
|
129
|
+
_step2;
|
|
130
|
+
try {
|
|
131
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
132
|
+
var ref = _step2.value;
|
|
133
|
+
set.add(ref.id);
|
|
134
|
+
}
|
|
135
|
+
} catch (err) {
|
|
136
|
+
_iterator2.e(err);
|
|
137
|
+
} finally {
|
|
138
|
+
_iterator2.f();
|
|
139
|
+
}
|
|
140
|
+
return set;
|
|
141
|
+
}, [items]);
|
|
142
|
+
var add = React.useCallback(function add(id) {
|
|
143
|
+
store.write(FAVORITES_CAPABILITY_ID, function (prev) {
|
|
144
|
+
return addRef(prev, resourceKey, id);
|
|
145
|
+
});
|
|
146
|
+
}, [store, resourceKey]);
|
|
147
|
+
var remove = React.useCallback(function remove(id) {
|
|
148
|
+
store.write(FAVORITES_CAPABILITY_ID, function (prev) {
|
|
149
|
+
return removeRef(prev, resourceKey, id);
|
|
150
|
+
});
|
|
151
|
+
}, [store, resourceKey]);
|
|
152
|
+
var toggle = React.useCallback(function toggle(id) {
|
|
153
|
+
store.write(FAVORITES_CAPABILITY_ID, function (prev) {
|
|
154
|
+
return toggleRef(prev, resourceKey, id);
|
|
155
|
+
});
|
|
156
|
+
}, [store, resourceKey]);
|
|
157
|
+
var clear = React.useCallback(function clear() {
|
|
158
|
+
store.write(FAVORITES_CAPABILITY_ID, function (prev) {
|
|
159
|
+
return clearRefs(prev, resourceKey);
|
|
160
|
+
});
|
|
161
|
+
}, [store, resourceKey]);
|
|
162
|
+
var isFavorite = React.useCallback(function isFavorite(id) {
|
|
163
|
+
return ids.has(id);
|
|
164
|
+
}, [ids]);
|
|
165
|
+
return React.useMemo(function value() {
|
|
166
|
+
return {
|
|
167
|
+
items: items,
|
|
168
|
+
ids: ids,
|
|
169
|
+
count: items.length,
|
|
170
|
+
isFavorite: isFavorite,
|
|
171
|
+
add: add,
|
|
172
|
+
remove: remove,
|
|
173
|
+
toggle: toggle,
|
|
174
|
+
clear: clear
|
|
175
|
+
};
|
|
176
|
+
}, [items, ids, isFavorite, add, remove, toggle, clear]);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* useIsFavorite(resourceKey, id) — focused per-row hook. Returns a boolean
|
|
180
|
+
* (Object.is bail-out: a row re-renders only when ITS membership flips)
|
|
181
|
+
* plus a bound toggle/add/remove. This is the cell-level hook the DataGrid
|
|
182
|
+
* favorite column consumes (Batch 5).
|
|
183
|
+
*/
|
|
184
|
+
export function useIsFavorite(resourceKey, id) {
|
|
185
|
+
var store = usePersonalizationStore();
|
|
186
|
+
useEnsureFavorites(store);
|
|
187
|
+
var selectIsFavorite = React.useCallback(function selectIsFavorite(snapshot) {
|
|
188
|
+
var slice = snapshot[FAVORITES_CAPABILITY_ID];
|
|
189
|
+
return slice ? hasRef(slice, resourceKey, id) : false;
|
|
190
|
+
}, [resourceKey, id]);
|
|
191
|
+
var isFavorite = useStoreSelector(selectIsFavorite);
|
|
192
|
+
var toggle = React.useCallback(function toggle() {
|
|
193
|
+
store.write(FAVORITES_CAPABILITY_ID, function (prev) {
|
|
194
|
+
return toggleRef(prev, resourceKey, id);
|
|
195
|
+
});
|
|
196
|
+
}, [store, resourceKey, id]);
|
|
197
|
+
var add = React.useCallback(function add() {
|
|
198
|
+
store.write(FAVORITES_CAPABILITY_ID, function (prev) {
|
|
199
|
+
return addRef(prev, resourceKey, id);
|
|
200
|
+
});
|
|
201
|
+
}, [store, resourceKey, id]);
|
|
202
|
+
var remove = React.useCallback(function remove() {
|
|
203
|
+
store.write(FAVORITES_CAPABILITY_ID, function (prev) {
|
|
204
|
+
return removeRef(prev, resourceKey, id);
|
|
205
|
+
});
|
|
206
|
+
}, [store, resourceKey, id]);
|
|
207
|
+
return React.useMemo(function value() {
|
|
208
|
+
return {
|
|
209
|
+
isFavorite: isFavorite,
|
|
210
|
+
toggle: toggle,
|
|
211
|
+
add: add,
|
|
212
|
+
remove: remove
|
|
213
|
+
};
|
|
214
|
+
}, [isFavorite, toggle, add, remove]);
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=favorites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"favorites.js","names":["React","registerCapability","usePersonalizationStore","useStoreSelector","FAVORITES_CAPABILITY_ID","SCHEMA_VERSION","EMPTY_LIST","Object","freeze","EMPTY_MAP","id","schemaVersion","defaultState","migrate","migrateFavorites","_fromVersion","payload","_typeof","listFor","map","resourceKey","list","undefined","Array","isArray","hasRef","_iterator","_createForOfIteratorHelper","_step","s","n","done","ref","value","err","e","f","addRef","base","nextList","concat","addedAt","Date","toISOString","next","assign","removeRef","filter","keep","r","length","toggleRef","clearRefs","useEnsureFavorites","store","useEffect","ensure","ensureCapability","useFavorites","selectList","useCallback","snapshot","slice","items","ids","useMemo","buildIdSet","set","Set","_iterator2","_step2","add","write","prev","remove","toggle","clear","isFavorite","has","count","useIsFavorite","selectIsFavorite"],"sources":["../../../../../src/lib/v2/personalization/capabilities/favorites.ts"],"sourcesContent":["/**\r\n * favorites — Portnet UI v2 · personalization capability\r\n *\r\n * The Favorites framework. Self-registers the \"favorites\" capability with\r\n * the schema registry at import time, so the capability-agnostic\r\n * foundation discovers its schemaVersion / defaultState / migrate without\r\n * any hardcoding.\r\n *\r\n * State model (the capability payload):\r\n * { [resourceKey]: FavoriteRef[] } FavoriteRef = { id, addedAt }\r\n *\r\n * `resourceKey` namespaces favorites per list/entity type (e.g.\r\n * \"ti:list\", \"declarations:list\"), so one user's favorites across\r\n * different screens never collide. `id` is the business row id.\r\n *\r\n * Performance: the pure helpers below rebuild only the touched\r\n * resourceKey's array and shallow-copy the map, so the store's structural\r\n * sharing keeps every OTHER resource's list referentially stable —\r\n * toggling a favorite on screen B does not re-render screen A, and a\r\n * boolean per-row selector lets each grid cell re-render only when its own\r\n * membership flips.\r\n */\r\n\r\nimport * as React from \"react\";\r\n\r\nimport { registerCapability } from \"../schema\";\r\nimport {\r\n usePersonalizationStore,\r\n useStoreSelector,\r\n} from \"../personalizationContext\";\r\nimport type {\r\n PersonalizationSnapshot,\r\n PersonalizationStore,\r\n} from \"../createPersonalizationStore\";\r\nimport type { FavoriteRef } from \"../types\";\r\nimport type { RowId } from \"../../types/common\";\r\n\r\n/** The favorites capability payload: favorites arrays keyed by resourceKey. */\r\ntype FavoritesState = Record<string, FavoriteRef[]>;\r\n\r\nexport const FAVORITES_CAPABILITY_ID = \"favorites\";\r\nconst SCHEMA_VERSION = 1;\r\n\r\nconst EMPTY_LIST: readonly FavoriteRef[] = Object.freeze([]);\r\nconst EMPTY_MAP: FavoritesState = Object.freeze({});\r\n\r\n/* Register at import time — the foundation reads this at hydration. */\r\nregisterCapability({\r\n id: FAVORITES_CAPABILITY_ID,\r\n schemaVersion: SCHEMA_VERSION,\r\n defaultState: EMPTY_MAP, // { [resourceKey]: FavoriteRef[] }\r\n migrate: function migrateFavorites(\r\n _fromVersion: number,\r\n payload: unknown\r\n ): unknown {\r\n // v1 is the initial schema. Defensive normalisation only.\r\n return payload && typeof payload === \"object\" ? payload : {};\r\n },\r\n});\r\n\r\n/* ── pure, resourceKey-scoped state helpers (structural sharing) ────── */\r\n\r\nfunction listFor(\r\n map: FavoritesState | null | undefined,\r\n resourceKey: string\r\n): readonly FavoriteRef[] {\r\n const list = map ? map[resourceKey] : undefined;\r\n return Array.isArray(list) ? list : EMPTY_LIST;\r\n}\r\n\r\nfunction hasRef(\r\n map: FavoritesState | null | undefined,\r\n resourceKey: string,\r\n id: RowId\r\n): boolean {\r\n const list = listFor(map, resourceKey);\r\n for (const ref of list) {\r\n if (ref.id === id) return true;\r\n }\r\n return false;\r\n}\r\n\r\nfunction addRef(\r\n map: FavoritesState | null | undefined,\r\n resourceKey: string,\r\n id: RowId\r\n): FavoritesState {\r\n const base = map || EMPTY_MAP;\r\n if (hasRef(base, resourceKey, id)) return base; // no-op → store short-circuits\r\n const nextList = listFor(base, resourceKey).concat([\r\n { id: id, addedAt: new Date().toISOString() },\r\n ]);\r\n const next: FavoritesState = Object.assign({}, base);\r\n next[resourceKey] = nextList;\r\n return next;\r\n}\r\n\r\nfunction removeRef(\r\n map: FavoritesState | null | undefined,\r\n resourceKey: string,\r\n id: RowId\r\n): FavoritesState {\r\n const base = map || EMPTY_MAP;\r\n if (!hasRef(base, resourceKey, id)) return base; // no-op\r\n const nextList = listFor(base, resourceKey).filter(function keep(r) {\r\n return r.id !== id;\r\n });\r\n const next: FavoritesState = Object.assign({}, base);\r\n if (nextList.length === 0) delete next[resourceKey]; // keep the map tidy\r\n else next[resourceKey] = nextList;\r\n return next;\r\n}\r\n\r\nfunction toggleRef(\r\n map: FavoritesState | null | undefined,\r\n resourceKey: string,\r\n id: RowId\r\n): FavoritesState {\r\n return hasRef(map, resourceKey, id)\r\n ? removeRef(map, resourceKey, id)\r\n : addRef(map, resourceKey, id);\r\n}\r\n\r\nfunction clearRefs(\r\n map: FavoritesState | null | undefined,\r\n resourceKey: string\r\n): FavoritesState {\r\n const base = map || EMPTY_MAP;\r\n if (!base[resourceKey]) return base;\r\n const next: FavoritesState = Object.assign({}, base);\r\n delete next[resourceKey];\r\n return next;\r\n}\r\n\r\n/* ── hooks ──────────────────────────────────────────────────────────── */\r\n\r\nfunction useEnsureFavorites(store: PersonalizationStore): void {\r\n React.useEffect(\r\n function ensure() {\r\n store.ensureCapability(FAVORITES_CAPABILITY_ID);\r\n },\r\n [store]\r\n );\r\n}\r\n\r\nexport interface UseFavoritesResult {\r\n items: readonly FavoriteRef[];\r\n ids: Set<RowId>;\r\n count: number;\r\n isFavorite: (id: RowId) => boolean;\r\n add: (id: RowId) => void;\r\n remove: (id: RowId) => void;\r\n toggle: (id: RowId) => void;\r\n clear: () => void;\r\n}\r\n\r\n/**\r\n * useFavorites(resourceKey) — list, membership and actions for one resource.\r\n */\r\nexport function useFavorites(resourceKey: string): UseFavoritesResult {\r\n const store = usePersonalizationStore();\r\n useEnsureFavorites(store);\r\n\r\n const selectList = React.useCallback(\r\n function selectList(snapshot: PersonalizationSnapshot): readonly FavoriteRef[] {\r\n const slice = snapshot[FAVORITES_CAPABILITY_ID] as\r\n | FavoritesState\r\n | undefined;\r\n return slice ? listFor(slice, resourceKey) : EMPTY_LIST;\r\n },\r\n [resourceKey]\r\n );\r\n const items = useStoreSelector(selectList);\r\n\r\n // Stable while `items` is stable (structural sharing) → O(1) membership.\r\n const ids = React.useMemo(\r\n function buildIdSet(): Set<RowId> {\r\n const set = new Set<RowId>();\r\n for (const ref of items) set.add(ref.id);\r\n return set;\r\n },\r\n [items]\r\n );\r\n\r\n const add = React.useCallback(\r\n function add(id: RowId): void {\r\n store.write<FavoritesState>(FAVORITES_CAPABILITY_ID, function (prev) {\r\n return addRef(prev, resourceKey, id);\r\n });\r\n },\r\n [store, resourceKey]\r\n );\r\n const remove = React.useCallback(\r\n function remove(id: RowId): void {\r\n store.write<FavoritesState>(FAVORITES_CAPABILITY_ID, function (prev) {\r\n return removeRef(prev, resourceKey, id);\r\n });\r\n },\r\n [store, resourceKey]\r\n );\r\n const toggle = React.useCallback(\r\n function toggle(id: RowId): void {\r\n store.write<FavoritesState>(FAVORITES_CAPABILITY_ID, function (prev) {\r\n return toggleRef(prev, resourceKey, id);\r\n });\r\n },\r\n [store, resourceKey]\r\n );\r\n const clear = React.useCallback(\r\n function clear(): void {\r\n store.write<FavoritesState>(FAVORITES_CAPABILITY_ID, function (prev) {\r\n return clearRefs(prev, resourceKey);\r\n });\r\n },\r\n [store, resourceKey]\r\n );\r\n const isFavorite = React.useCallback(\r\n function isFavorite(id: RowId): boolean {\r\n return ids.has(id);\r\n },\r\n [ids]\r\n );\r\n\r\n return React.useMemo(\r\n function value(): UseFavoritesResult {\r\n return {\r\n items: items,\r\n ids: ids,\r\n count: items.length,\r\n isFavorite: isFavorite,\r\n add: add,\r\n remove: remove,\r\n toggle: toggle,\r\n clear: clear,\r\n };\r\n },\r\n [items, ids, isFavorite, add, remove, toggle, clear]\r\n );\r\n}\r\n\r\nexport interface UseIsFavoriteResult {\r\n isFavorite: boolean;\r\n toggle: () => void;\r\n add: () => void;\r\n remove: () => void;\r\n}\r\n\r\n/**\r\n * useIsFavorite(resourceKey, id) — focused per-row hook. Returns a boolean\r\n * (Object.is bail-out: a row re-renders only when ITS membership flips)\r\n * plus a bound toggle/add/remove. This is the cell-level hook the DataGrid\r\n * favorite column consumes (Batch 5).\r\n */\r\nexport function useIsFavorite(\r\n resourceKey: string,\r\n id: RowId\r\n): UseIsFavoriteResult {\r\n const store = usePersonalizationStore();\r\n useEnsureFavorites(store);\r\n\r\n const selectIsFavorite = React.useCallback(\r\n function selectIsFavorite(snapshot: PersonalizationSnapshot): boolean {\r\n const slice = snapshot[FAVORITES_CAPABILITY_ID] as\r\n | FavoritesState\r\n | undefined;\r\n return slice ? hasRef(slice, resourceKey, id) : false;\r\n },\r\n [resourceKey, id]\r\n );\r\n const isFavorite = useStoreSelector(selectIsFavorite);\r\n\r\n const toggle = React.useCallback(\r\n function toggle(): void {\r\n store.write<FavoritesState>(FAVORITES_CAPABILITY_ID, function (prev) {\r\n return toggleRef(prev, resourceKey, id);\r\n });\r\n },\r\n [store, resourceKey, id]\r\n );\r\n const add = React.useCallback(\r\n function add(): void {\r\n store.write<FavoritesState>(FAVORITES_CAPABILITY_ID, function (prev) {\r\n return addRef(prev, resourceKey, id);\r\n });\r\n },\r\n [store, resourceKey, id]\r\n );\r\n const remove = React.useCallback(\r\n function remove(): void {\r\n store.write<FavoritesState>(FAVORITES_CAPABILITY_ID, function (prev) {\r\n return removeRef(prev, resourceKey, id);\r\n });\r\n },\r\n [store, resourceKey, id]\r\n );\r\n\r\n return React.useMemo(\r\n function value(): UseIsFavoriteResult {\r\n return {\r\n isFavorite: isFavorite,\r\n toggle: toggle,\r\n add: add,\r\n remove: remove,\r\n };\r\n },\r\n [isFavorite, toggle, add, remove]\r\n );\r\n}\r\n"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,kBAAkB,QAAQ,WAAW;AAC9C,SACEC,uBAAuB,EACvBC,gBAAgB,QACX,2BAA2B;;AAQlC;;AAGA,OAAO,IAAMC,uBAAuB,GAAG,WAAW;AAClD,IAAMC,cAAc,GAAG,CAAC;AAExB,IAAMC,UAAkC,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;AAC5D,IAAMC,SAAyB,GAAGF,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,CAAC;;AAEnD;AACAP,kBAAkB,CAAC;EACjBS,EAAE,EAAEN,uBAAuB;EAC3BO,aAAa,EAAEN,cAAc;EAC7BO,YAAY,EAAEH,SAAS;EAAE;EACzBI,OAAO,EAAE,SAASC,gBAAgBA,CAChCC,YAAoB,EACpBC,OAAgB,EACP;IACT;IACA,OAAOA,OAAO,IAAIC,OA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G,EAAEG,MAAM,CAClC,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
4
|
+
/**
|
|
5
|
+
* favoritesView — Portnet UI v2 · personalization
|
|
6
|
+
*
|
|
7
|
+
* Grid-agnostic favorites VIEW logic: filter (all / favorites-only) and
|
|
8
|
+
* sort (favorites-first / favorites-last). Pure helpers usable anywhere,
|
|
9
|
+
* plus a useFavoritesView hook that wires them to the favorites capability.
|
|
10
|
+
*
|
|
11
|
+
* The host owns its row id contract and the toggle UI (use FavoritesFilter
|
|
12
|
+
* or any control bound to `filterMode` / `sortPlacement`). These helpers
|
|
13
|
+
* only reorder/subset the rows array the host already has — they never
|
|
14
|
+
* fetch or mutate.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { useFavorites } from "./favorites";
|
|
19
|
+
export var FAVORITES_FILTER = Object.freeze({
|
|
20
|
+
ALL: "all",
|
|
21
|
+
ONLY: "only"
|
|
22
|
+
});
|
|
23
|
+
export var FAVORITES_SORT = Object.freeze({
|
|
24
|
+
NONE: "none",
|
|
25
|
+
FIRST: "first",
|
|
26
|
+
LAST: "last"
|
|
27
|
+
});
|
|
28
|
+
var EMPTY_ROWS = Object.freeze([]);
|
|
29
|
+
function toIdSet(ids) {
|
|
30
|
+
return ids instanceof Set ? ids : new Set(ids || []);
|
|
31
|
+
}
|
|
32
|
+
function resolveGetRowId(getRowId) {
|
|
33
|
+
return typeof getRowId === "function" ? getRowId : function defaultGetRowId(r) {
|
|
34
|
+
return r.id;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Keep only favorited rows when mode === "only"; otherwise return `rows`
|
|
40
|
+
* unchanged (same reference).
|
|
41
|
+
*/
|
|
42
|
+
export function filterRowsByFavorites(rows, favoriteIds, getRowId, mode) {
|
|
43
|
+
if (mode !== FAVORITES_FILTER.ONLY || !Array.isArray(rows)) return rows;
|
|
44
|
+
// Array.isArray widened `rows` to any[]; re-establish the element type.
|
|
45
|
+
var source = rows;
|
|
46
|
+
var ids = toIdSet(favoriteIds);
|
|
47
|
+
var getId = resolveGetRowId(getRowId);
|
|
48
|
+
return source.filter(function keepFavorite(r) {
|
|
49
|
+
return ids.has(getId(r));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Move favorited rows to the front ("first") or back ("last"), preserving
|
|
55
|
+
* the host's existing order WITHIN each group (stable partition). Returns
|
|
56
|
+
* `rows` unchanged when placement is "none" or when reordering is a no-op.
|
|
57
|
+
*/
|
|
58
|
+
export function sortRowsByFavorites(rows, favoriteIds, getRowId, placement) {
|
|
59
|
+
if (placement !== FAVORITES_SORT.FIRST && placement !== FAVORITES_SORT.LAST || !Array.isArray(rows)) {
|
|
60
|
+
return rows;
|
|
61
|
+
}
|
|
62
|
+
// Array.isArray widened `rows` to any[]; re-establish the element type.
|
|
63
|
+
var source = rows;
|
|
64
|
+
var ids = toIdSet(favoriteIds);
|
|
65
|
+
var getId = resolveGetRowId(getRowId);
|
|
66
|
+
var fav = [];
|
|
67
|
+
var rest = [];
|
|
68
|
+
var _iterator = _createForOfIteratorHelper(source),
|
|
69
|
+
_step;
|
|
70
|
+
try {
|
|
71
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
72
|
+
var row = _step.value;
|
|
73
|
+
if (ids.has(getId(row))) fav.push(row);else rest.push(row);
|
|
74
|
+
}
|
|
75
|
+
} catch (err) {
|
|
76
|
+
_iterator.e(err);
|
|
77
|
+
} finally {
|
|
78
|
+
_iterator.f();
|
|
79
|
+
}
|
|
80
|
+
if (fav.length === 0 || rest.length === 0) return source; // nothing to reorder
|
|
81
|
+
return placement === FAVORITES_SORT.FIRST ? fav.concat(rest) : rest.concat(fav);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* useFavoritesView(resourceKey, rows, options)
|
|
85
|
+
*
|
|
86
|
+
* Reads the favorites id Set for `resourceKey` and applies the favorites
|
|
87
|
+
* filter + sort to `rows`. In the all/none case the original `rows`
|
|
88
|
+
* reference is returned unchanged.
|
|
89
|
+
*/
|
|
90
|
+
export function useFavoritesView(resourceKey, rows, options) {
|
|
91
|
+
var opts = options || {};
|
|
92
|
+
var getRowId = opts.getRowId;
|
|
93
|
+
var filterMode = opts.filterMode || FAVORITES_FILTER.ALL;
|
|
94
|
+
var sortPlacement = opts.sortPlacement || FAVORITES_SORT.NONE;
|
|
95
|
+
var fav = useFavorites(resourceKey);
|
|
96
|
+
var ids = fav.ids;
|
|
97
|
+
var processed = React.useMemo(function compute() {
|
|
98
|
+
var base = Array.isArray(rows) ? rows : EMPTY_ROWS;
|
|
99
|
+
var filtered = filterRowsByFavorites(base, ids, getRowId, filterMode);
|
|
100
|
+
return sortRowsByFavorites(filtered, ids, getRowId, sortPlacement);
|
|
101
|
+
}, [rows, ids, getRowId, filterMode, sortPlacement]);
|
|
102
|
+
return React.useMemo(function value() {
|
|
103
|
+
return {
|
|
104
|
+
rows: processed,
|
|
105
|
+
favoriteIds: ids,
|
|
106
|
+
favoriteCount: fav.count,
|
|
107
|
+
isFiltering: filterMode === FAVORITES_FILTER.ONLY
|
|
108
|
+
};
|
|
109
|
+
}, [processed, ids, fav.count, filterMode]);
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=favoritesView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"favoritesView.js","names":["React","useFavorites","FAVORITES_FILTER","Object","freeze","ALL","ONLY","FAVORITES_SORT","NONE","FIRST","LAST","EMPTY_ROWS","toIdSet","ids","Set","resolveGetRowId","getRowId","defaultGetRowId","r","id","filterRowsByFavorites","rows","favoriteIds","mode","Array","isArray","source","getId","filter","keepFavorite","has","sortRowsByFavorites","placement","fav","rest","_iterator","_createForOfIteratorHelper","_step","s","n","done","row","value","push","err","e","f","length","concat","useFavoritesView","resourceKey","options","opts","filterMode","sortPlacement","processed","useMemo","compute","base","filtered","favoriteCount","count","isFiltering"],"sources":["../../../../../src/lib/v2/personalization/capabilities/favoritesView.ts"],"sourcesContent":["/**\r\n * favoritesView — Portnet UI v2 · personalization\r\n *\r\n * Grid-agnostic favorites VIEW logic: filter (all / favorites-only) and\r\n * sort (favorites-first / favorites-last). Pure helpers usable anywhere,\r\n * plus a useFavoritesView hook that wires them to the favorites capability.\r\n *\r\n * The host owns its row id contract and the toggle UI (use FavoritesFilter\r\n * or any control bound to `filterMode` / `sortPlacement`). These helpers\r\n * only reorder/subset the rows array the host already has — they never\r\n * fetch or mutate.\r\n */\r\n\r\nimport * as React from \"react\";\r\n\r\nimport { useFavorites } from \"./favorites\";\r\nimport type { RowId } from \"../../types/common\";\r\n\r\nexport const FAVORITES_FILTER = Object.freeze({\r\n ALL: \"all\",\r\n ONLY: \"only\",\r\n} as const);\r\nexport const FAVORITES_SORT = Object.freeze({\r\n NONE: \"none\",\r\n FIRST: \"first\",\r\n LAST: \"last\",\r\n} as const);\r\n\r\nexport type FavoritesFilterMode =\r\n (typeof FAVORITES_FILTER)[keyof typeof FAVORITES_FILTER];\r\nexport type FavoritesSortPlacement =\r\n (typeof FAVORITES_SORT)[keyof typeof FAVORITES_SORT];\r\n\r\nconst EMPTY_ROWS: readonly never[] = Object.freeze([]);\r\n\r\nfunction toIdSet(\r\n ids: Set<RowId> | readonly RowId[] | null | undefined\r\n): Set<RowId> {\r\n return ids instanceof Set ? ids : new Set(ids || []);\r\n}\r\n\r\nfunction resolveGetRowId<T>(getRowId?: (row: T) => RowId): (row: T) => RowId {\r\n return typeof getRowId === \"function\"\r\n ? getRowId\r\n : function defaultGetRowId(r: T): RowId {\r\n return (r as { id: RowId }).id;\r\n };\r\n}\r\n\r\n/**\r\n * Keep only favorited rows when mode === \"only\"; otherwise return `rows`\r\n * unchanged (same reference).\r\n */\r\nexport function filterRowsByFavorites<T>(\r\n rows: readonly T[],\r\n favoriteIds: Set<RowId> | readonly RowId[] | null | undefined,\r\n getRowId: ((row: T) => RowId) | undefined,\r\n mode: FavoritesFilterMode\r\n): readonly T[] {\r\n if (mode !== FAVORITES_FILTER.ONLY || !Array.isArray(rows)) return rows;\r\n // Array.isArray widened `rows` to any[]; re-establish the element type.\r\n const source: readonly T[] = rows;\r\n const ids = toIdSet(favoriteIds);\r\n const getId = resolveGetRowId(getRowId);\r\n return source.filter(function keepFavorite(r) {\r\n return ids.has(getId(r));\r\n });\r\n}\r\n\r\n/**\r\n * Move favorited rows to the front (\"first\") or back (\"last\"), preserving\r\n * the host's existing order WITHIN each group (stable partition). Returns\r\n * `rows` unchanged when placement is \"none\" or when reordering is a no-op.\r\n */\r\nexport function sortRowsByFavorites<T>(\r\n rows: readonly T[],\r\n favoriteIds: Set<RowId> | readonly RowId[] | null | undefined,\r\n getRowId: ((row: T) => RowId) | undefined,\r\n placement: FavoritesSortPlacement\r\n): readonly T[] {\r\n if (\r\n (placement !== FAVORITES_SORT.FIRST && placement !== FAVORITES_SORT.LAST) ||\r\n !Array.isArray(rows)\r\n ) {\r\n return rows;\r\n }\r\n // Array.isArray widened `rows` to any[]; re-establish the element type.\r\n const source: readonly T[] = rows;\r\n const ids = toIdSet(favoriteIds);\r\n const getId = resolveGetRowId(getRowId);\r\n const fav: T[] = [];\r\n const rest: T[] = [];\r\n for (const row of source) {\r\n if (ids.has(getId(row))) fav.push(row);\r\n else rest.push(row);\r\n }\r\n if (fav.length === 0 || rest.length === 0) return source; // nothing to reorder\r\n return placement === FAVORITES_SORT.FIRST\r\n ? fav.concat(rest)\r\n : rest.concat(fav);\r\n}\r\n\r\nexport interface UseFavoritesViewOptions<T> {\r\n /** Should be stable; MUST match the grid's getRowId. Defaults to (r) => r.id. */\r\n getRowId?: ((row: T) => RowId) | undefined;\r\n /** @default \"all\" */\r\n filterMode?: FavoritesFilterMode | undefined;\r\n /** @default \"none\" */\r\n sortPlacement?: FavoritesSortPlacement | undefined;\r\n}\r\n\r\nexport interface UseFavoritesViewResult<T> {\r\n rows: readonly T[];\r\n favoriteIds: Set<RowId>;\r\n favoriteCount: number;\r\n isFiltering: boolean;\r\n}\r\n\r\n/**\r\n * useFavoritesView(resourceKey, rows, options)\r\n *\r\n * Reads the favorites id Set for `resourceKey` and applies the favorites\r\n * filter + sort to `rows`. In the all/none case the original `rows`\r\n * reference is returned unchanged.\r\n */\r\nexport function useFavoritesView<T>(\r\n resourceKey: string,\r\n rows: readonly T[],\r\n options?: UseFavoritesViewOptions<T>\r\n): UseFavoritesViewResult<T> {\r\n const opts: UseFavoritesViewOptions<T> = options || {};\r\n const getRowId = opts.getRowId;\r\n const filterMode = opts.filterMode || FAVORITES_FILTER.ALL;\r\n const sortPlacement = opts.sortPlacement || FAVORITES_SORT.NONE;\r\n\r\n const fav = useFavorites(resourceKey);\r\n const ids = fav.ids;\r\n\r\n const processed = React.useMemo(\r\n function compute(): readonly T[] {\r\n const base: readonly T[] = Array.isArray(rows) ? rows : EMPTY_ROWS;\r\n const filtered = filterRowsByFavorites(base, ids, getRowId, filterMode);\r\n return sortRowsByFavorites(filtered, ids, getRowId, sortPlacement);\r\n },\r\n [rows, ids, getRowId, filterMode, sortPlacement]\r\n );\r\n\r\n return React.useMemo(\r\n function value(): UseFavoritesViewResult<T> {\r\n return {\r\n rows: processed,\r\n favoriteIds: ids,\r\n favoriteCount: fav.count,\r\n isFiltering: filterMode === FAVORITES_FILTER.ONLY,\r\n };\r\n },\r\n [processed, ids, fav.count, filterMode]\r\n );\r\n}\r\n"],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,YAAY,QAAQ,aAAa;AAG1C,OAAO,IAAMC,gBAAgB,GAAGC,MAAM,CAACC,MAAM,CAAC;EAC5CC,GAAG,EAAE,KAAK;EACVC,IAAI,EAAE;AACR,CAAU,CAAC;AACX,OAAO,IAAMC,cAAc,GAAGJ,MAAM,CAACC,MAAM,CAAC;EAC1CI,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE;AACR,CAAU,CAAC;AAOX,IAAMC,UAA4B,GAAGR,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;AAEtD,SAASQ,OAAOA,CACdC,GAAqD,EACzC;EACZ,OAAOA,GAAG,YAAYC,GAAG,GAAGD,GAAG,GAAG,IAAIC,GAAG,CAACD,GAAG,IAAI,EAAE,CAAC;AACtD;AAEA,SAASE,eAAeA,CAAIC,QAA4B,EAAqB;EAC3E,OAAO,OAAOA,Q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