@multiplatform.one/frappe-ui 7.23.1 → 7.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/FrappeCalendar.cjs +1 -1
- package/dist/cjs/FrappeCalendar.native.js +1 -1
- package/dist/cjs/FrappeCalendar.native.js.map +1 -1
- package/dist/cjs/FrappeDashboard.cjs +1 -1
- package/dist/cjs/FrappeDashboard.native.js +1 -1
- package/dist/cjs/FrappeDashboard.native.js.map +1 -1
- package/dist/cjs/FrappeForm.cjs +8 -0
- package/dist/cjs/FrappeForm.native.js +9 -0
- package/dist/cjs/FrappeForm.native.js.map +1 -1
- package/dist/cjs/FrappeImageView.cjs +1 -1
- package/dist/cjs/FrappeImageView.native.js +1 -1
- package/dist/cjs/FrappeImageView.native.js.map +1 -1
- package/dist/cjs/FrappeInsights.cjs +380 -0
- package/dist/cjs/FrappeInsights.native.js +447 -0
- package/dist/cjs/FrappeInsights.native.js.map +1 -0
- package/dist/cjs/FrappeLikedBy.cjs +5 -2
- package/dist/cjs/FrappeLikedBy.native.js +5 -2
- package/dist/cjs/FrappeLikedBy.native.js.map +1 -1
- package/dist/cjs/FrappeListView.cjs +406 -39
- package/dist/cjs/FrappeListView.native.js +469 -42
- package/dist/cjs/FrappeListView.native.js.map +1 -1
- package/dist/cjs/FrappeNotConfigured.cjs +54 -0
- package/dist/cjs/FrappeNotConfigured.native.js +58 -0
- package/dist/cjs/FrappeNotConfigured.native.js.map +1 -0
- package/dist/cjs/FrappeRecordView.cjs +199 -0
- package/dist/cjs/FrappeRecordView.native.js +218 -0
- package/dist/cjs/FrappeRecordView.native.js.map +1 -0
- package/dist/cjs/FrappeReportBuilder.cjs +2 -2
- package/dist/cjs/FrappeReportBuilder.native.js +2 -2
- package/dist/cjs/FrappeReportBuilder.native.js.map +1 -1
- package/dist/cjs/FrappeReportView.cjs +1 -1
- package/dist/cjs/FrappeReportView.native.js +2 -2
- package/dist/cjs/FrappeReportView.native.js.map +1 -1
- package/dist/cjs/FrappeTreeView.cjs +1 -1
- package/dist/cjs/FrappeTreeView.native.js +1 -1
- package/dist/cjs/desk/awesomebar.cjs +1 -1
- package/dist/cjs/desk/awesomebar.native.js +3 -3
- package/dist/cjs/desk/awesomebar.native.js.map +1 -1
- package/dist/cjs/fields/CodeEditor/index.cjs +1 -1
- package/dist/cjs/fields/CodeEditor/index.native.js +1 -1
- package/dist/cjs/fields/CodeEditor/index.native.js.map +1 -1
- package/dist/cjs/fields/Color/index.cjs +1 -0
- package/dist/cjs/fields/Color/index.native.js +1 -0
- package/dist/cjs/fields/Color/index.native.js.map +1 -1
- package/dist/cjs/fields/FileUpload.cjs +1 -1
- package/dist/cjs/fields/FileUpload.native.js +1 -1
- package/dist/cjs/fields/FileUpload.native.js.map +1 -1
- package/dist/cjs/fields/Heading/index.cjs +19 -12
- package/dist/cjs/fields/Heading/index.native.js +22 -13
- package/dist/cjs/fields/Heading/index.native.js.map +1 -1
- package/dist/cjs/fields/MarkdownEditor/index.cjs +2 -1
- package/dist/cjs/fields/MarkdownEditor/index.native.js +1 -1
- package/dist/cjs/fields/MarkdownEditor/index.native.js.map +1 -1
- package/dist/cjs/frappeNavigation.cjs +12 -2
- package/dist/cjs/frappeNavigation.native.js +13 -2
- package/dist/cjs/frappeNavigation.native.js.map +1 -1
- package/dist/cjs/index.cjs +34 -0
- package/dist/cjs/index.native.js +34 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/insights/InsightsFacetTags.cjs +147 -0
- package/dist/cjs/insights/InsightsFacetTags.native.js +165 -0
- package/dist/cjs/insights/InsightsFacetTags.native.js.map +1 -0
- package/dist/cjs/insights/InsightsKpiBand.cjs +124 -0
- package/dist/cjs/insights/InsightsKpiBand.native.js +133 -0
- package/dist/cjs/insights/InsightsKpiBand.native.js.map +1 -0
- package/dist/cjs/insights/InsightsLeaders.cjs +150 -0
- package/dist/cjs/insights/InsightsLeaders.native.js +178 -0
- package/dist/cjs/insights/InsightsLeaders.native.js.map +1 -0
- package/dist/cjs/insights/InsightsRecords.cjs +105 -0
- package/dist/cjs/insights/InsightsRecords.native.js +109 -0
- package/dist/cjs/insights/InsightsRecords.native.js.map +1 -0
- package/dist/cjs/insights/InsightsTable.cjs +157 -0
- package/dist/cjs/insights/InsightsTable.native.js +194 -0
- package/dist/cjs/insights/InsightsTable.native.js.map +1 -0
- package/dist/cjs/insights/insightsData.cjs +114 -0
- package/dist/cjs/insights/insightsData.native.js +220 -0
- package/dist/cjs/insights/insightsData.native.js.map +1 -0
- package/dist/cjs/insights/insightsRecord.cjs +35 -0
- package/dist/cjs/insights/insightsRecord.native.js +38 -0
- package/dist/cjs/insights/insightsRecord.native.js.map +1 -0
- package/dist/cjs/list/FacetBadge.cjs +62 -0
- package/dist/cjs/list/FacetBadge.native.js +66 -0
- package/dist/cjs/list/FacetBadge.native.js.map +1 -0
- package/dist/cjs/list/FacetRail.cjs +199 -0
- package/dist/cjs/list/FacetRail.native.js +223 -0
- package/dist/cjs/list/FacetRail.native.js.map +1 -0
- package/dist/cjs/list/ImageWell.cjs +111 -0
- package/dist/cjs/list/ImageWell.native.js +126 -0
- package/dist/cjs/list/ImageWell.native.js.map +1 -0
- package/dist/cjs/list/ListControls.cjs +226 -0
- package/dist/cjs/list/ListControls.native.js +252 -0
- package/dist/cjs/list/ListControls.native.js.map +1 -0
- package/dist/cjs/list/ListToastHost.cjs +54 -0
- package/dist/cjs/list/ListToastHost.native.js +59 -0
- package/dist/cjs/list/ListToastHost.native.js.map +1 -0
- package/dist/cjs/list/RangeFilter.cjs +122 -0
- package/dist/cjs/list/RangeFilter.native.js +135 -0
- package/dist/cjs/list/RangeFilter.native.js.map +1 -0
- package/dist/cjs/list/RecordCard.cjs +233 -0
- package/dist/cjs/list/RecordCard.native.js +173 -0
- package/dist/cjs/list/RecordCard.native.js.map +1 -0
- package/dist/cjs/list/ShufflePanel.cjs +112 -0
- package/dist/cjs/list/ShufflePanel.native.js +139 -0
- package/dist/cjs/list/ShufflePanel.native.js.map +1 -0
- package/dist/cjs/list/facetReading.cjs +71 -0
- package/dist/cjs/list/facetReading.native.js +163 -0
- package/dist/cjs/list/facetReading.native.js.map +1 -0
- package/dist/cjs/list/favorites.cjs +79 -0
- package/dist/cjs/list/favorites.native.js +91 -0
- package/dist/cjs/list/favorites.native.js.map +1 -0
- package/dist/cjs/list/listState.cjs +100 -0
- package/dist/cjs/list/listState.native.js +234 -0
- package/dist/cjs/list/listState.native.js.map +1 -0
- package/dist/cjs/list/recordLook.cjs +35 -0
- package/dist/cjs/list/recordLook.native.js +39 -0
- package/dist/cjs/list/recordLook.native.js.map +1 -0
- package/dist/cjs/list/useListControls.cjs +189 -0
- package/dist/cjs/list/useListControls.native.js +272 -0
- package/dist/cjs/list/useListControls.native.js.map +1 -0
- package/dist/cjs/record/RecordBars.cjs +200 -0
- package/dist/cjs/record/RecordBars.native.js +225 -0
- package/dist/cjs/record/RecordBars.native.js.map +1 -0
- package/dist/cjs/record/RecordGallery.cjs +67 -0
- package/dist/cjs/record/RecordGallery.native.js +75 -0
- package/dist/cjs/record/RecordGallery.native.js.map +1 -0
- package/dist/cjs/record/RecordHero.cjs +239 -0
- package/dist/cjs/record/RecordHero.native.js +250 -0
- package/dist/cjs/record/RecordHero.native.js.map +1 -0
- package/dist/cjs/record/RecordPage.cjs +330 -0
- package/dist/cjs/record/RecordPage.native.js +364 -0
- package/dist/cjs/record/RecordPage.native.js.map +1 -0
- package/dist/cjs/record/RecordPager.cjs +125 -0
- package/dist/cjs/record/RecordPager.native.js +130 -0
- package/dist/cjs/record/RecordPager.native.js.map +1 -0
- package/dist/cjs/record/RecordRows.cjs +126 -0
- package/dist/cjs/record/RecordRows.native.js +140 -0
- package/dist/cjs/record/RecordRows.native.js.map +1 -0
- package/dist/cjs/record/recordData.cjs +122 -0
- package/dist/cjs/record/recordData.native.js +189 -0
- package/dist/cjs/record/recordData.native.js.map +1 -0
- package/dist/cjs/record/recordSections.cjs +30 -0
- package/dist/cjs/record/recordSections.native.js +33 -0
- package/dist/cjs/record/recordSections.native.js.map +1 -0
- package/dist/cjs/useFrappeFacets.cjs +1 -1
- package/dist/cjs/useFrappeFacets.native.js +1 -1
- package/dist/cjs/useFrappeFacets.native.js.map +1 -1
- package/dist/esm/FrappeCalendar.mjs +1 -1
- package/dist/esm/FrappeCalendar.mjs.map +1 -1
- package/dist/esm/FrappeCalendar.native.js +1 -1
- package/dist/esm/FrappeCalendar.native.js.map +1 -1
- package/dist/esm/FrappeDashboard.mjs +1 -1
- package/dist/esm/FrappeDashboard.mjs.map +1 -1
- package/dist/esm/FrappeDashboard.native.js +1 -1
- package/dist/esm/FrappeDashboard.native.js.map +1 -1
- package/dist/esm/FrappeForm.mjs +8 -0
- package/dist/esm/FrappeForm.mjs.map +1 -1
- package/dist/esm/FrappeForm.native.js +9 -0
- package/dist/esm/FrappeForm.native.js.map +1 -1
- package/dist/esm/FrappeImageView.mjs +1 -1
- package/dist/esm/FrappeImageView.mjs.map +1 -1
- package/dist/esm/FrappeImageView.native.js +1 -1
- package/dist/esm/FrappeImageView.native.js.map +1 -1
- package/dist/esm/FrappeInsights.mjs +355 -0
- package/dist/esm/FrappeInsights.mjs.map +1 -0
- package/dist/esm/FrappeInsights.native.js +419 -0
- package/dist/esm/FrappeInsights.native.js.map +1 -0
- package/dist/esm/FrappeLikedBy.mjs +6 -3
- package/dist/esm/FrappeLikedBy.mjs.map +1 -1
- package/dist/esm/FrappeLikedBy.native.js +6 -3
- package/dist/esm/FrappeLikedBy.native.js.map +1 -1
- package/dist/esm/FrappeListView.mjs +410 -43
- package/dist/esm/FrappeListView.mjs.map +1 -1
- package/dist/esm/FrappeListView.native.js +473 -46
- package/dist/esm/FrappeListView.native.js.map +1 -1
- package/dist/esm/FrappeNotConfigured.mjs +29 -0
- package/dist/esm/FrappeNotConfigured.mjs.map +1 -0
- package/dist/esm/FrappeNotConfigured.native.js +30 -0
- package/dist/esm/FrappeNotConfigured.native.js.map +1 -0
- package/dist/esm/FrappeRecordView.mjs +174 -0
- package/dist/esm/FrappeRecordView.mjs.map +1 -0
- package/dist/esm/FrappeRecordView.native.js +190 -0
- package/dist/esm/FrappeRecordView.native.js.map +1 -0
- package/dist/esm/FrappeReportBuilder.mjs +2 -2
- package/dist/esm/FrappeReportBuilder.mjs.map +1 -1
- package/dist/esm/FrappeReportBuilder.native.js +2 -2
- package/dist/esm/FrappeReportBuilder.native.js.map +1 -1
- package/dist/esm/FrappeReportView.mjs +1 -1
- package/dist/esm/FrappeReportView.mjs.map +1 -1
- package/dist/esm/FrappeReportView.native.js +2 -2
- package/dist/esm/FrappeReportView.native.js.map +1 -1
- package/dist/esm/FrappeTreeView.mjs +1 -1
- package/dist/esm/FrappeTreeView.mjs.map +1 -1
- package/dist/esm/FrappeTreeView.native.js +1 -1
- package/dist/esm/desk/awesomebar.mjs +1 -1
- package/dist/esm/desk/awesomebar.mjs.map +1 -1
- package/dist/esm/desk/awesomebar.native.js +3 -3
- package/dist/esm/desk/awesomebar.native.js.map +1 -1
- package/dist/esm/fields/CodeEditor/index.mjs +2 -2
- package/dist/esm/fields/CodeEditor/index.mjs.map +1 -1
- package/dist/esm/fields/CodeEditor/index.native.js +2 -2
- package/dist/esm/fields/CodeEditor/index.native.js.map +1 -1
- package/dist/esm/fields/Color/index.mjs +1 -0
- package/dist/esm/fields/Color/index.mjs.map +1 -1
- package/dist/esm/fields/Color/index.native.js +1 -0
- package/dist/esm/fields/Color/index.native.js.map +1 -1
- package/dist/esm/fields/FileUpload.mjs +2 -2
- package/dist/esm/fields/FileUpload.mjs.map +1 -1
- package/dist/esm/fields/FileUpload.native.js +2 -2
- package/dist/esm/fields/FileUpload.native.js.map +1 -1
- package/dist/esm/fields/Heading/index.mjs +21 -14
- package/dist/esm/fields/Heading/index.mjs.map +1 -1
- package/dist/esm/fields/Heading/index.native.js +24 -15
- package/dist/esm/fields/Heading/index.native.js.map +1 -1
- package/dist/esm/fields/MarkdownEditor/index.mjs +2 -1
- package/dist/esm/fields/MarkdownEditor/index.mjs.map +1 -1
- package/dist/esm/fields/MarkdownEditor/index.native.js +2 -2
- package/dist/esm/fields/MarkdownEditor/index.native.js.map +1 -1
- package/dist/esm/frappeNavigation.mjs +11 -2
- package/dist/esm/frappeNavigation.mjs.map +1 -1
- package/dist/esm/frappeNavigation.native.js +12 -2
- package/dist/esm/frappeNavigation.native.js.map +1 -1
- package/dist/esm/index.mjs +14 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +14 -2
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/insights/InsightsFacetTags.mjs +122 -0
- package/dist/esm/insights/InsightsFacetTags.mjs.map +1 -0
- package/dist/esm/insights/InsightsFacetTags.native.js +137 -0
- package/dist/esm/insights/InsightsFacetTags.native.js.map +1 -0
- package/dist/esm/insights/InsightsKpiBand.mjs +99 -0
- package/dist/esm/insights/InsightsKpiBand.mjs.map +1 -0
- package/dist/esm/insights/InsightsKpiBand.native.js +105 -0
- package/dist/esm/insights/InsightsKpiBand.native.js.map +1 -0
- package/dist/esm/insights/InsightsLeaders.mjs +125 -0
- package/dist/esm/insights/InsightsLeaders.mjs.map +1 -0
- package/dist/esm/insights/InsightsLeaders.native.js +150 -0
- package/dist/esm/insights/InsightsLeaders.native.js.map +1 -0
- package/dist/esm/insights/InsightsRecords.mjs +80 -0
- package/dist/esm/insights/InsightsRecords.mjs.map +1 -0
- package/dist/esm/insights/InsightsRecords.native.js +81 -0
- package/dist/esm/insights/InsightsRecords.native.js.map +1 -0
- package/dist/esm/insights/InsightsTable.mjs +132 -0
- package/dist/esm/insights/InsightsTable.mjs.map +1 -0
- package/dist/esm/insights/InsightsTable.native.js +166 -0
- package/dist/esm/insights/InsightsTable.native.js.map +1 -0
- package/dist/esm/insights/insightsData.mjs +82 -0
- package/dist/esm/insights/insightsData.mjs.map +1 -0
- package/dist/esm/insights/insightsData.native.js +185 -0
- package/dist/esm/insights/insightsData.native.js.map +1 -0
- package/dist/esm/insights/insightsRecord.mjs +9 -0
- package/dist/esm/insights/insightsRecord.mjs.map +1 -0
- package/dist/esm/insights/insightsRecord.native.js +9 -0
- package/dist/esm/insights/insightsRecord.native.js.map +1 -0
- package/dist/esm/list/FacetBadge.mjs +37 -0
- package/dist/esm/list/FacetBadge.mjs.map +1 -0
- package/dist/esm/list/FacetBadge.native.js +38 -0
- package/dist/esm/list/FacetBadge.native.js.map +1 -0
- package/dist/esm/list/FacetRail.mjs +174 -0
- package/dist/esm/list/FacetRail.mjs.map +1 -0
- package/dist/esm/list/FacetRail.native.js +195 -0
- package/dist/esm/list/FacetRail.native.js.map +1 -0
- package/dist/esm/list/ImageWell.mjs +86 -0
- package/dist/esm/list/ImageWell.mjs.map +1 -0
- package/dist/esm/list/ImageWell.native.js +98 -0
- package/dist/esm/list/ImageWell.native.js.map +1 -0
- package/dist/esm/list/ListControls.mjs +201 -0
- package/dist/esm/list/ListControls.mjs.map +1 -0
- package/dist/esm/list/ListControls.native.js +224 -0
- package/dist/esm/list/ListControls.native.js.map +1 -0
- package/dist/esm/list/ListToastHost.mjs +18 -0
- package/dist/esm/list/ListToastHost.mjs.map +1 -0
- package/dist/esm/list/ListToastHost.native.js +20 -0
- package/dist/esm/list/ListToastHost.native.js.map +1 -0
- package/dist/esm/list/RangeFilter.mjs +85 -0
- package/dist/esm/list/RangeFilter.mjs.map +1 -0
- package/dist/esm/list/RangeFilter.native.js +95 -0
- package/dist/esm/list/RangeFilter.native.js.map +1 -0
- package/dist/esm/list/RecordCard.mjs +208 -0
- package/dist/esm/list/RecordCard.mjs.map +1 -0
- package/dist/esm/list/RecordCard.native.js +145 -0
- package/dist/esm/list/RecordCard.native.js.map +1 -0
- package/dist/esm/list/ShufflePanel.mjs +87 -0
- package/dist/esm/list/ShufflePanel.mjs.map +1 -0
- package/dist/esm/list/ShufflePanel.native.js +111 -0
- package/dist/esm/list/ShufflePanel.native.js.map +1 -0
- package/dist/esm/list/facetReading.mjs +45 -0
- package/dist/esm/list/facetReading.mjs.map +1 -0
- package/dist/esm/list/facetReading.native.js +134 -0
- package/dist/esm/list/facetReading.native.js.map +1 -0
- package/dist/esm/list/favorites.mjs +50 -0
- package/dist/esm/list/favorites.mjs.map +1 -0
- package/dist/esm/list/favorites.native.js +59 -0
- package/dist/esm/list/favorites.native.js.map +1 -0
- package/dist/esm/list/listState.mjs +71 -0
- package/dist/esm/list/listState.mjs.map +1 -0
- package/dist/esm/list/listState.native.js +202 -0
- package/dist/esm/list/listState.native.js.map +1 -0
- package/dist/esm/list/recordLook.mjs +10 -0
- package/dist/esm/list/recordLook.mjs.map +1 -0
- package/dist/esm/list/recordLook.native.js +11 -0
- package/dist/esm/list/recordLook.native.js.map +1 -0
- package/dist/esm/list/useListControls.mjs +164 -0
- package/dist/esm/list/useListControls.mjs.map +1 -0
- package/dist/esm/list/useListControls.native.js +244 -0
- package/dist/esm/list/useListControls.native.js.map +1 -0
- package/dist/esm/record/RecordBars.mjs +175 -0
- package/dist/esm/record/RecordBars.mjs.map +1 -0
- package/dist/esm/record/RecordBars.native.js +197 -0
- package/dist/esm/record/RecordBars.native.js.map +1 -0
- package/dist/esm/record/RecordGallery.mjs +42 -0
- package/dist/esm/record/RecordGallery.mjs.map +1 -0
- package/dist/esm/record/RecordGallery.native.js +47 -0
- package/dist/esm/record/RecordGallery.native.js.map +1 -0
- package/dist/esm/record/RecordHero.mjs +205 -0
- package/dist/esm/record/RecordHero.mjs.map +1 -0
- package/dist/esm/record/RecordHero.native.js +213 -0
- package/dist/esm/record/RecordHero.native.js.map +1 -0
- package/dist/esm/record/RecordPage.mjs +305 -0
- package/dist/esm/record/RecordPage.mjs.map +1 -0
- package/dist/esm/record/RecordPage.native.js +336 -0
- package/dist/esm/record/RecordPage.native.js.map +1 -0
- package/dist/esm/record/RecordPager.mjs +100 -0
- package/dist/esm/record/RecordPager.mjs.map +1 -0
- package/dist/esm/record/RecordPager.native.js +102 -0
- package/dist/esm/record/RecordPager.native.js.map +1 -0
- package/dist/esm/record/RecordRows.mjs +101 -0
- package/dist/esm/record/RecordRows.mjs.map +1 -0
- package/dist/esm/record/RecordRows.native.js +112 -0
- package/dist/esm/record/RecordRows.native.js.map +1 -0
- package/dist/esm/record/recordData.mjs +92 -0
- package/dist/esm/record/recordData.mjs.map +1 -0
- package/dist/esm/record/recordData.native.js +156 -0
- package/dist/esm/record/recordData.native.js.map +1 -0
- package/dist/esm/record/recordSections.mjs +5 -0
- package/dist/esm/record/recordSections.mjs.map +1 -0
- package/dist/esm/record/recordSections.native.js +5 -0
- package/dist/esm/record/recordSections.native.js.map +1 -0
- package/dist/esm/useFrappeFacets.mjs +1 -1
- package/dist/esm/useFrappeFacets.mjs.map +1 -1
- package/dist/esm/useFrappeFacets.native.js +1 -1
- package/dist/esm/useFrappeFacets.native.js.map +1 -1
- package/dist/jsx/FrappeCalendar.mjs +1 -1
- package/dist/jsx/FrappeCalendar.mjs.map +1 -1
- package/dist/jsx/FrappeCalendar.native.js +1 -1
- package/dist/jsx/FrappeCalendar.native.js.map +1 -1
- package/dist/jsx/FrappeDashboard.mjs +1 -1
- package/dist/jsx/FrappeDashboard.mjs.map +1 -1
- package/dist/jsx/FrappeDashboard.native.js +1 -1
- package/dist/jsx/FrappeDashboard.native.js.map +1 -1
- package/dist/jsx/FrappeForm.mjs +8 -0
- package/dist/jsx/FrappeForm.mjs.map +1 -1
- package/dist/jsx/FrappeForm.native.js +9 -0
- package/dist/jsx/FrappeForm.native.js.map +1 -1
- package/dist/jsx/FrappeImageView.mjs +1 -1
- package/dist/jsx/FrappeImageView.mjs.map +1 -1
- package/dist/jsx/FrappeImageView.native.js +1 -1
- package/dist/jsx/FrappeImageView.native.js.map +1 -1
- package/dist/jsx/FrappeInsights.mjs +355 -0
- package/dist/jsx/FrappeInsights.mjs.map +1 -0
- package/dist/jsx/FrappeInsights.native.js +447 -0
- package/dist/jsx/FrappeInsights.native.js.map +1 -0
- package/dist/jsx/FrappeLikedBy.mjs +6 -3
- package/dist/jsx/FrappeLikedBy.mjs.map +1 -1
- package/dist/jsx/FrappeLikedBy.native.js +5 -2
- package/dist/jsx/FrappeLikedBy.native.js.map +1 -1
- package/dist/jsx/FrappeListView.mjs +410 -43
- package/dist/jsx/FrappeListView.mjs.map +1 -1
- package/dist/jsx/FrappeListView.native.js +469 -42
- package/dist/jsx/FrappeListView.native.js.map +1 -1
- package/dist/jsx/FrappeNotConfigured.mjs +29 -0
- package/dist/jsx/FrappeNotConfigured.mjs.map +1 -0
- package/dist/jsx/FrappeNotConfigured.native.js +58 -0
- package/dist/jsx/FrappeNotConfigured.native.js.map +1 -0
- package/dist/jsx/FrappeRecordView.mjs +174 -0
- package/dist/jsx/FrappeRecordView.mjs.map +1 -0
- package/dist/jsx/FrappeRecordView.native.js +218 -0
- package/dist/jsx/FrappeRecordView.native.js.map +1 -0
- package/dist/jsx/FrappeReportBuilder.mjs +2 -2
- package/dist/jsx/FrappeReportBuilder.mjs.map +1 -1
- package/dist/jsx/FrappeReportBuilder.native.js +2 -2
- package/dist/jsx/FrappeReportBuilder.native.js.map +1 -1
- package/dist/jsx/FrappeReportView.mjs +1 -1
- package/dist/jsx/FrappeReportView.mjs.map +1 -1
- package/dist/jsx/FrappeReportView.native.js +2 -2
- package/dist/jsx/FrappeReportView.native.js.map +1 -1
- package/dist/jsx/FrappeTreeView.mjs +1 -1
- package/dist/jsx/FrappeTreeView.mjs.map +1 -1
- package/dist/jsx/FrappeTreeView.native.js +1 -1
- package/dist/jsx/desk/awesomebar.mjs +1 -1
- package/dist/jsx/desk/awesomebar.mjs.map +1 -1
- package/dist/jsx/desk/awesomebar.native.js +3 -3
- package/dist/jsx/desk/awesomebar.native.js.map +1 -1
- package/dist/jsx/fields/CodeEditor/index.mjs +2 -2
- package/dist/jsx/fields/CodeEditor/index.mjs.map +1 -1
- package/dist/jsx/fields/CodeEditor/index.native.js +1 -1
- package/dist/jsx/fields/CodeEditor/index.native.js.map +1 -1
- package/dist/jsx/fields/Color/index.mjs +1 -0
- package/dist/jsx/fields/Color/index.mjs.map +1 -1
- package/dist/jsx/fields/Color/index.native.js +1 -0
- package/dist/jsx/fields/Color/index.native.js.map +1 -1
- package/dist/jsx/fields/FileUpload.mjs +2 -2
- package/dist/jsx/fields/FileUpload.mjs.map +1 -1
- package/dist/jsx/fields/FileUpload.native.js +1 -1
- package/dist/jsx/fields/FileUpload.native.js.map +1 -1
- package/dist/jsx/fields/Heading/index.mjs +21 -14
- package/dist/jsx/fields/Heading/index.mjs.map +1 -1
- package/dist/jsx/fields/Heading/index.native.js +22 -13
- package/dist/jsx/fields/Heading/index.native.js.map +1 -1
- package/dist/jsx/fields/MarkdownEditor/index.mjs +2 -1
- package/dist/jsx/fields/MarkdownEditor/index.mjs.map +1 -1
- package/dist/jsx/fields/MarkdownEditor/index.native.js +1 -1
- package/dist/jsx/fields/MarkdownEditor/index.native.js.map +1 -1
- package/dist/jsx/frappeNavigation.mjs +11 -2
- package/dist/jsx/frappeNavigation.mjs.map +1 -1
- package/dist/jsx/frappeNavigation.native.js +13 -2
- package/dist/jsx/frappeNavigation.native.js.map +1 -1
- package/dist/jsx/index.js +14 -2
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +14 -2
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/index.native.js +34 -0
- package/dist/jsx/index.native.js.map +1 -1
- package/dist/jsx/insights/InsightsFacetTags.mjs +122 -0
- package/dist/jsx/insights/InsightsFacetTags.mjs.map +1 -0
- package/dist/jsx/insights/InsightsFacetTags.native.js +165 -0
- package/dist/jsx/insights/InsightsFacetTags.native.js.map +1 -0
- package/dist/jsx/insights/InsightsKpiBand.mjs +99 -0
- package/dist/jsx/insights/InsightsKpiBand.mjs.map +1 -0
- package/dist/jsx/insights/InsightsKpiBand.native.js +133 -0
- package/dist/jsx/insights/InsightsKpiBand.native.js.map +1 -0
- package/dist/jsx/insights/InsightsLeaders.mjs +125 -0
- package/dist/jsx/insights/InsightsLeaders.mjs.map +1 -0
- package/dist/jsx/insights/InsightsLeaders.native.js +178 -0
- package/dist/jsx/insights/InsightsLeaders.native.js.map +1 -0
- package/dist/jsx/insights/InsightsRecords.mjs +80 -0
- package/dist/jsx/insights/InsightsRecords.mjs.map +1 -0
- package/dist/jsx/insights/InsightsRecords.native.js +109 -0
- package/dist/jsx/insights/InsightsRecords.native.js.map +1 -0
- package/dist/jsx/insights/InsightsTable.mjs +132 -0
- package/dist/jsx/insights/InsightsTable.mjs.map +1 -0
- package/dist/jsx/insights/InsightsTable.native.js +194 -0
- package/dist/jsx/insights/InsightsTable.native.js.map +1 -0
- package/dist/jsx/insights/insightsData.mjs +82 -0
- package/dist/jsx/insights/insightsData.mjs.map +1 -0
- package/dist/jsx/insights/insightsData.native.js +220 -0
- package/dist/jsx/insights/insightsData.native.js.map +1 -0
- package/dist/jsx/insights/insightsRecord.mjs +9 -0
- package/dist/jsx/insights/insightsRecord.mjs.map +1 -0
- package/dist/jsx/insights/insightsRecord.native.js +38 -0
- package/dist/jsx/insights/insightsRecord.native.js.map +1 -0
- package/dist/jsx/list/FacetBadge.mjs +37 -0
- package/dist/jsx/list/FacetBadge.mjs.map +1 -0
- package/dist/jsx/list/FacetBadge.native.js +66 -0
- package/dist/jsx/list/FacetBadge.native.js.map +1 -0
- package/dist/jsx/list/FacetRail.mjs +174 -0
- package/dist/jsx/list/FacetRail.mjs.map +1 -0
- package/dist/jsx/list/FacetRail.native.js +223 -0
- package/dist/jsx/list/FacetRail.native.js.map +1 -0
- package/dist/jsx/list/ImageWell.mjs +86 -0
- package/dist/jsx/list/ImageWell.mjs.map +1 -0
- package/dist/jsx/list/ImageWell.native.js +126 -0
- package/dist/jsx/list/ImageWell.native.js.map +1 -0
- package/dist/jsx/list/ListControls.mjs +201 -0
- package/dist/jsx/list/ListControls.mjs.map +1 -0
- package/dist/jsx/list/ListControls.native.js +252 -0
- package/dist/jsx/list/ListControls.native.js.map +1 -0
- package/dist/jsx/list/ListToastHost.mjs +18 -0
- package/dist/jsx/list/ListToastHost.mjs.map +1 -0
- package/dist/jsx/list/ListToastHost.native.js +59 -0
- package/dist/jsx/list/ListToastHost.native.js.map +1 -0
- package/dist/jsx/list/RangeFilter.mjs +85 -0
- package/dist/jsx/list/RangeFilter.mjs.map +1 -0
- package/dist/jsx/list/RangeFilter.native.js +135 -0
- package/dist/jsx/list/RangeFilter.native.js.map +1 -0
- package/dist/jsx/list/RecordCard.mjs +208 -0
- package/dist/jsx/list/RecordCard.mjs.map +1 -0
- package/dist/jsx/list/RecordCard.native.js +173 -0
- package/dist/jsx/list/RecordCard.native.js.map +1 -0
- package/dist/jsx/list/ShufflePanel.mjs +87 -0
- package/dist/jsx/list/ShufflePanel.mjs.map +1 -0
- package/dist/jsx/list/ShufflePanel.native.js +139 -0
- package/dist/jsx/list/ShufflePanel.native.js.map +1 -0
- package/dist/jsx/list/facetReading.mjs +45 -0
- package/dist/jsx/list/facetReading.mjs.map +1 -0
- package/dist/jsx/list/facetReading.native.js +163 -0
- package/dist/jsx/list/facetReading.native.js.map +1 -0
- package/dist/jsx/list/favorites.mjs +50 -0
- package/dist/jsx/list/favorites.mjs.map +1 -0
- package/dist/jsx/list/favorites.native.js +91 -0
- package/dist/jsx/list/favorites.native.js.map +1 -0
- package/dist/jsx/list/listState.mjs +71 -0
- package/dist/jsx/list/listState.mjs.map +1 -0
- package/dist/jsx/list/listState.native.js +234 -0
- package/dist/jsx/list/listState.native.js.map +1 -0
- package/dist/jsx/list/recordLook.mjs +10 -0
- package/dist/jsx/list/recordLook.mjs.map +1 -0
- package/dist/jsx/list/recordLook.native.js +39 -0
- package/dist/jsx/list/recordLook.native.js.map +1 -0
- package/dist/jsx/list/useListControls.mjs +164 -0
- package/dist/jsx/list/useListControls.mjs.map +1 -0
- package/dist/jsx/list/useListControls.native.js +272 -0
- package/dist/jsx/list/useListControls.native.js.map +1 -0
- package/dist/jsx/record/RecordBars.mjs +175 -0
- package/dist/jsx/record/RecordBars.mjs.map +1 -0
- package/dist/jsx/record/RecordBars.native.js +225 -0
- package/dist/jsx/record/RecordBars.native.js.map +1 -0
- package/dist/jsx/record/RecordGallery.mjs +42 -0
- package/dist/jsx/record/RecordGallery.mjs.map +1 -0
- package/dist/jsx/record/RecordGallery.native.js +75 -0
- package/dist/jsx/record/RecordGallery.native.js.map +1 -0
- package/dist/jsx/record/RecordHero.mjs +205 -0
- package/dist/jsx/record/RecordHero.mjs.map +1 -0
- package/dist/jsx/record/RecordHero.native.js +250 -0
- package/dist/jsx/record/RecordHero.native.js.map +1 -0
- package/dist/jsx/record/RecordPage.mjs +305 -0
- package/dist/jsx/record/RecordPage.mjs.map +1 -0
- package/dist/jsx/record/RecordPage.native.js +364 -0
- package/dist/jsx/record/RecordPage.native.js.map +1 -0
- package/dist/jsx/record/RecordPager.mjs +100 -0
- package/dist/jsx/record/RecordPager.mjs.map +1 -0
- package/dist/jsx/record/RecordPager.native.js +130 -0
- package/dist/jsx/record/RecordPager.native.js.map +1 -0
- package/dist/jsx/record/RecordRows.mjs +101 -0
- package/dist/jsx/record/RecordRows.mjs.map +1 -0
- package/dist/jsx/record/RecordRows.native.js +140 -0
- package/dist/jsx/record/RecordRows.native.js.map +1 -0
- package/dist/jsx/record/recordData.mjs +92 -0
- package/dist/jsx/record/recordData.mjs.map +1 -0
- package/dist/jsx/record/recordData.native.js +189 -0
- package/dist/jsx/record/recordData.native.js.map +1 -0
- package/dist/jsx/record/recordSections.mjs +5 -0
- package/dist/jsx/record/recordSections.mjs.map +1 -0
- package/dist/jsx/record/recordSections.native.js +33 -0
- package/dist/jsx/record/recordSections.native.js.map +1 -0
- package/dist/jsx/useFrappeFacets.mjs +1 -1
- package/dist/jsx/useFrappeFacets.mjs.map +1 -1
- package/dist/jsx/useFrappeFacets.native.js +1 -1
- package/dist/jsx/useFrappeFacets.native.js.map +1 -1
- package/package.json +16 -16
- package/src/FormSidebar.stories.tsx +2 -0
- package/src/FrappeCalendar.stories.tsx +2 -0
- package/src/FrappeCalendar.tsx +2 -2
- package/src/FrappeChartCard.stories.tsx +2 -0
- package/src/FrappeDashboard.stories.tsx +2 -0
- package/src/FrappeDashboard.tsx +2 -2
- package/src/FrappeForm.tsx +7 -1
- package/src/FrappeImageView.stories.tsx +2 -0
- package/src/FrappeImageView.tsx +2 -1
- package/src/FrappeInsights.spec.tsx +171 -0
- package/src/FrappeInsights.tsx +422 -0
- package/src/FrappeKPICard.stories.tsx +3 -3
- package/src/FrappeKanban.stories.tsx +4 -8
- package/src/FrappeLikedBy.tsx +7 -5
- package/src/FrappeListView.card.spec.tsx +157 -0
- package/src/FrappeListView.controls.spec.tsx +225 -0
- package/src/FrappeListView.seed.spec.tsx +30 -0
- package/src/FrappeListView.stories.tsx +2 -0
- package/src/FrappeListView.tsx +589 -45
- package/src/FrappeNotConfigured.tsx +29 -0
- package/src/FrappeRecordView.spec.tsx +276 -0
- package/src/FrappeRecordView.tsx +231 -0
- package/src/FrappeReportBuilder.tsx +4 -5
- package/src/FrappeReportView.tsx +1 -1
- package/src/FrappeTreeView.tsx +1 -1
- package/src/clientCache.auth.spec.tsx +94 -0
- package/src/desk/DeskFormSidebar.stories.tsx +2 -0
- package/src/desk/DeskShell.stories.tsx +12 -6
- package/src/desk/awesomebar.auth.spec.tsx +77 -0
- package/src/desk/awesomebar.tsx +1 -1
- package/src/fields/CodeEditor/index.tsx +8 -2
- package/src/fields/Color/Color.stories.tsx +2 -0
- package/src/fields/Color/index.tsx +1 -0
- package/src/fields/FileUpload.tsx +8 -2
- package/src/fields/Heading/index.tsx +41 -17
- package/src/fields/MarkdownEditor/index.native.tsx +8 -2
- package/src/fields/MarkdownEditor/index.tsx +8 -1
- package/src/fields/ReadOnly/ReadOnly.stories.tsx +2 -0
- package/src/frappeNavigation.loader.spec.tsx +45 -0
- package/src/frappeNavigation.tsx +32 -1
- package/src/frappeRoutes.notConfigured.spec.tsx +77 -0
- package/src/index.ts +53 -1
- package/src/insights/InsightsFacetTags.tsx +131 -0
- package/src/insights/InsightsKpiBand.tsx +114 -0
- package/src/insights/InsightsLeaders.tsx +146 -0
- package/src/insights/InsightsRecords.tsx +71 -0
- package/src/insights/InsightsTable.tsx +169 -0
- package/src/insights/insightsData.spec.ts +143 -0
- package/src/insights/insightsData.ts +122 -0
- package/src/insights/insightsRecord.ts +36 -0
- package/src/list/FacetBadge.tsx +41 -0
- package/src/list/FacetRail.tsx +235 -0
- package/src/list/ImageWell.tsx +110 -0
- package/src/list/ListControls.tsx +208 -0
- package/src/list/ListToastHost.tsx +27 -0
- package/src/list/RangeFilter.tsx +83 -0
- package/src/list/RecordCard.native.tsx +126 -0
- package/src/list/RecordCard.tsx +260 -0
- package/src/list/ShufflePanel.tsx +107 -0
- package/src/list/facetReading.ts +79 -0
- package/src/list/favorites.spec.ts +80 -0
- package/src/list/favorites.ts +79 -0
- package/src/list/listState.spec.ts +156 -0
- package/src/list/listState.ts +184 -0
- package/src/list/recordLook.ts +37 -0
- package/src/list/useListControls.tsx +223 -0
- package/src/record/RecordBars.tsx +187 -0
- package/src/record/RecordGallery.tsx +47 -0
- package/src/record/RecordHero.tsx +186 -0
- package/src/record/RecordPage.tsx +358 -0
- package/src/record/RecordPager.tsx +97 -0
- package/src/record/RecordRows.tsx +90 -0
- package/src/record/recordData.spec.ts +148 -0
- package/src/record/recordData.ts +124 -0
- package/src/record/recordSections.ts +62 -0
- package/src/schemaForm/SchemaForm.stories.tsx +2 -2
- package/src/useFrappeFacets.ts +14 -7
- package/types/FrappeForm.d.ts +2 -1
- package/types/FrappeForm.d.ts.map +1 -1
- package/types/FrappeImageView.d.ts.map +1 -1
- package/types/FrappeInsights.d.ts +55 -0
- package/types/FrappeInsights.d.ts.map +1 -0
- package/types/FrappeLikedBy.d.ts.map +1 -1
- package/types/FrappeListView.d.ts +85 -3
- package/types/FrappeListView.d.ts.map +1 -1
- package/types/FrappeNotConfigured.d.ts +11 -0
- package/types/FrappeNotConfigured.d.ts.map +1 -0
- package/types/FrappeRecordView.d.ts +69 -0
- package/types/FrappeRecordView.d.ts.map +1 -0
- package/types/FrappeReportBuilder.d.ts.map +1 -1
- package/types/fields/CodeEditor/index.d.ts.map +1 -1
- package/types/fields/Color/index.d.ts.map +1 -1
- package/types/fields/FileUpload.d.ts.map +1 -1
- package/types/fields/Heading/index.d.ts.map +1 -1
- package/types/fields/MarkdownEditor/index.d.ts.map +1 -1
- package/types/fields/MarkdownEditor/index.native.d.ts.map +1 -1
- package/types/frappeNavigation.d.ts +21 -0
- package/types/frappeNavigation.d.ts.map +1 -1
- package/types/index.d.ts +14 -2
- package/types/index.d.ts.map +1 -1
- package/types/insights/InsightsFacetTags.d.ts +11 -0
- package/types/insights/InsightsFacetTags.d.ts.map +1 -0
- package/types/insights/InsightsKpiBand.d.ts +22 -0
- package/types/insights/InsightsKpiBand.d.ts.map +1 -0
- package/types/insights/InsightsLeaders.d.ts +16 -0
- package/types/insights/InsightsLeaders.d.ts.map +1 -0
- package/types/insights/InsightsRecords.d.ts +19 -0
- package/types/insights/InsightsRecords.d.ts.map +1 -0
- package/types/insights/InsightsTable.d.ts +17 -0
- package/types/insights/InsightsTable.d.ts.map +1 -0
- package/types/insights/insightsData.d.ts +45 -0
- package/types/insights/insightsData.d.ts.map +1 -0
- package/types/insights/insightsRecord.d.ts +29 -0
- package/types/insights/insightsRecord.d.ts.map +1 -0
- package/types/list/FacetBadge.d.ts +13 -0
- package/types/list/FacetBadge.d.ts.map +1 -0
- package/types/list/FacetRail.d.ts +26 -0
- package/types/list/FacetRail.d.ts.map +1 -0
- package/types/list/ImageWell.d.ts +24 -0
- package/types/list/ImageWell.d.ts.map +1 -0
- package/types/list/ListControls.d.ts +30 -0
- package/types/list/ListControls.d.ts.map +1 -0
- package/types/list/ListToastHost.d.ts +7 -0
- package/types/list/ListToastHost.d.ts.map +1 -0
- package/types/list/RangeFilter.d.ts +14 -0
- package/types/list/RangeFilter.d.ts.map +1 -0
- package/types/list/RecordCard.d.ts +38 -0
- package/types/list/RecordCard.d.ts.map +1 -0
- package/types/list/RecordCard.native.d.ts +9 -0
- package/types/list/RecordCard.native.d.ts.map +1 -0
- package/types/list/ShufflePanel.d.ts +24 -0
- package/types/list/ShufflePanel.d.ts.map +1 -0
- package/types/list/facetReading.d.ts +33 -0
- package/types/list/facetReading.d.ts.map +1 -0
- package/types/list/favorites.d.ts +26 -0
- package/types/list/favorites.d.ts.map +1 -0
- package/types/list/listState.d.ts +94 -0
- package/types/list/listState.d.ts.map +1 -0
- package/types/list/recordLook.d.ts +25 -0
- package/types/list/recordLook.d.ts.map +1 -0
- package/types/list/useListControls.d.ts +48 -0
- package/types/list/useListControls.d.ts.map +1 -0
- package/types/record/RecordBars.d.ts +11 -0
- package/types/record/RecordBars.d.ts.map +1 -0
- package/types/record/RecordGallery.d.ts +17 -0
- package/types/record/RecordGallery.d.ts.map +1 -0
- package/types/record/RecordHero.d.ts +42 -0
- package/types/record/RecordHero.d.ts.map +1 -0
- package/types/record/RecordPage.d.ts +54 -0
- package/types/record/RecordPage.d.ts.map +1 -0
- package/types/record/RecordPager.d.ts +13 -0
- package/types/record/RecordPager.d.ts.map +1 -0
- package/types/record/RecordRows.d.ts +13 -0
- package/types/record/RecordRows.d.ts.map +1 -0
- package/types/record/recordData.d.ts +46 -0
- package/types/record/recordData.d.ts.map +1 -0
- package/types/record/recordSections.d.ts +67 -0
- package/types/record/recordSections.d.ts.map +1 -0
- package/types/useFrappeFacets.d.ts.map +1 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { Anchor, Card, Text, XStack, YStack, isWeb } from "@multiplatform.one/components";
|
|
2
|
+
import { Button } from "@multiplatform.one/forms";
|
|
3
|
+
import {
|
|
4
|
+
ensureFocusVisibleRing,
|
|
5
|
+
ensureKeyboardModalityTracking,
|
|
6
|
+
keyboardFocusRingProps,
|
|
7
|
+
useResolvedKnobs,
|
|
8
|
+
wasKeyboardFocus,
|
|
9
|
+
} from "@multiplatform.one/theme";
|
|
10
|
+
import { HeartIcon } from "@phosphor-icons/react";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { useTranslation } from "react-i18next";
|
|
13
|
+
import { FacetBadge } from "./FacetBadge";
|
|
14
|
+
import { ImageWell } from "./ImageWell";
|
|
15
|
+
|
|
16
|
+
export interface RecordCardBadge {
|
|
17
|
+
value: string;
|
|
18
|
+
label: string;
|
|
19
|
+
tint?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface RecordCardProps {
|
|
23
|
+
title: string;
|
|
24
|
+
subtitle?: string;
|
|
25
|
+
/** Stamped on the well's corner ("#025"). */
|
|
26
|
+
code?: string;
|
|
27
|
+
/** Image candidates in order; a failed load moves to the next. */
|
|
28
|
+
images: readonly string[];
|
|
29
|
+
/** Theme hues painting the well: one fills it, two split it. */
|
|
30
|
+
tints?: readonly (string | undefined)[];
|
|
31
|
+
/** Facet values stickered on the well. */
|
|
32
|
+
badges?: readonly RecordCardBadge[];
|
|
33
|
+
/** The record's page: the card becomes a real link (SSR, new tab). */
|
|
34
|
+
href?: string;
|
|
35
|
+
onPress?: () => void;
|
|
36
|
+
favorite?: { active: boolean; toggle: () => void };
|
|
37
|
+
/** Fetch the image only as it nears the viewport. */
|
|
38
|
+
lazy?: boolean;
|
|
39
|
+
testID?: string;
|
|
40
|
+
favoriteTestID?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface PressLikeEvent {
|
|
44
|
+
metaKey?: boolean;
|
|
45
|
+
ctrlKey?: boolean;
|
|
46
|
+
shiftKey?: boolean;
|
|
47
|
+
altKey?: boolean;
|
|
48
|
+
button?: number;
|
|
49
|
+
preventDefault?: () => void;
|
|
50
|
+
stopPropagation?: () => void;
|
|
51
|
+
nativeEvent?: PressLikeEvent;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function isModifiedPress(event?: PressLikeEvent): boolean {
|
|
55
|
+
const native = event?.nativeEvent ?? event;
|
|
56
|
+
return Boolean(
|
|
57
|
+
native &&
|
|
58
|
+
(native.metaKey ||
|
|
59
|
+
native.ctrlKey ||
|
|
60
|
+
native.shiftKey ||
|
|
61
|
+
native.altKey ||
|
|
62
|
+
(native.button ?? 0) !== 0),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A record as a tile: the image well is the card (tinted by the record's
|
|
68
|
+
* facet, its values stickered on it, its code stamped in the corner) with
|
|
69
|
+
* the title and a muted subtitle under it. A routed card is a stretched
|
|
70
|
+
* link with the heart as its sibling button (LC-74), so a first-paint click
|
|
71
|
+
* on the heart never follows the link; modified clicks keep the browser's
|
|
72
|
+
* new-tab semantics.
|
|
73
|
+
*/
|
|
74
|
+
export function RecordCard({
|
|
75
|
+
title,
|
|
76
|
+
subtitle,
|
|
77
|
+
code,
|
|
78
|
+
images,
|
|
79
|
+
tints,
|
|
80
|
+
badges = [],
|
|
81
|
+
href,
|
|
82
|
+
onPress,
|
|
83
|
+
favorite,
|
|
84
|
+
lazy = false,
|
|
85
|
+
testID,
|
|
86
|
+
favoriteTestID,
|
|
87
|
+
}: RecordCardProps) {
|
|
88
|
+
const { t } = useTranslation();
|
|
89
|
+
const { knobProps, elevation: elevationState } = useResolvedKnobs({ component: "Card" });
|
|
90
|
+
const focusRing = ensureFocusVisibleRing({ outlineOffset: -2 });
|
|
91
|
+
const [anchorKeyboardFocus, setAnchorKeyboardFocus] = useState(false);
|
|
92
|
+
if (isWeb) ensureKeyboardModalityTracking();
|
|
93
|
+
|
|
94
|
+
const handlePress = (event: unknown) => {
|
|
95
|
+
const press = event as PressLikeEvent | undefined;
|
|
96
|
+
if (href && isModifiedPress(press)) return;
|
|
97
|
+
press?.preventDefault?.();
|
|
98
|
+
press?.stopPropagation?.();
|
|
99
|
+
onPress?.();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const handleToggleFavorite = (event: unknown) => {
|
|
103
|
+
const press = event as PressLikeEvent | undefined;
|
|
104
|
+
press?.preventDefault?.();
|
|
105
|
+
press?.stopPropagation?.();
|
|
106
|
+
press?.nativeEvent?.preventDefault?.();
|
|
107
|
+
press?.nativeEvent?.stopPropagation?.();
|
|
108
|
+
favorite?.toggle();
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const passThrough = href ? "box-none" : undefined;
|
|
112
|
+
const inert = href ? "none" : undefined;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Card
|
|
116
|
+
testID={testID}
|
|
117
|
+
position="relative"
|
|
118
|
+
{...knobProps.cardSurface}
|
|
119
|
+
elevation={knobProps.elevation}
|
|
120
|
+
cursor="pointer"
|
|
121
|
+
transition={knobProps.transition}
|
|
122
|
+
hoverStyle={{ ...elevationState.hoverKnobProps }}
|
|
123
|
+
pressStyle={{ ...elevationState.pressKnobProps }}
|
|
124
|
+
{...(href
|
|
125
|
+
? anchorKeyboardFocus
|
|
126
|
+
? keyboardFocusRingProps
|
|
127
|
+
: null
|
|
128
|
+
: {
|
|
129
|
+
role: "button",
|
|
130
|
+
"aria-label": title,
|
|
131
|
+
onPress: handlePress,
|
|
132
|
+
focusVisibleStyle: focusRing,
|
|
133
|
+
})}
|
|
134
|
+
>
|
|
135
|
+
{href ? (
|
|
136
|
+
<Anchor
|
|
137
|
+
href={href as never}
|
|
138
|
+
position="absolute"
|
|
139
|
+
top={0}
|
|
140
|
+
left={0}
|
|
141
|
+
right={0}
|
|
142
|
+
bottom={0}
|
|
143
|
+
zIndex={0}
|
|
144
|
+
textDecorationLine="none"
|
|
145
|
+
outlineWidth={0}
|
|
146
|
+
aria-label={title}
|
|
147
|
+
onPress={handlePress}
|
|
148
|
+
{...(isWeb
|
|
149
|
+
? {
|
|
150
|
+
onFocus: () => {
|
|
151
|
+
if (wasKeyboardFocus()) setAnchorKeyboardFocus(true);
|
|
152
|
+
},
|
|
153
|
+
onBlur: () => setAnchorKeyboardFocus(false),
|
|
154
|
+
}
|
|
155
|
+
: undefined)}
|
|
156
|
+
/>
|
|
157
|
+
) : null}
|
|
158
|
+
<YStack gap="$1.5" zIndex={1} pointerEvents={passThrough}>
|
|
159
|
+
<YStack position="relative" pointerEvents={passThrough}>
|
|
160
|
+
<ImageWell
|
|
161
|
+
sources={images}
|
|
162
|
+
alt={title}
|
|
163
|
+
tints={tints}
|
|
164
|
+
inset={0.04}
|
|
165
|
+
lazy={lazy}
|
|
166
|
+
pointerEvents={inert}
|
|
167
|
+
/>
|
|
168
|
+
{code ? (
|
|
169
|
+
<XStack
|
|
170
|
+
position="absolute"
|
|
171
|
+
top="$2"
|
|
172
|
+
left="$2"
|
|
173
|
+
{...knobProps.borderRadius}
|
|
174
|
+
borderWidth={0}
|
|
175
|
+
backgroundColor="$background08"
|
|
176
|
+
paddingHorizontal="$1.5"
|
|
177
|
+
paddingVertical="$0.5"
|
|
178
|
+
zIndex={1}
|
|
179
|
+
pointerEvents={inert}
|
|
180
|
+
>
|
|
181
|
+
<Text fontSize="$1" fontWeight="800" letterSpacing={1} color="$color12">
|
|
182
|
+
{code}
|
|
183
|
+
</Text>
|
|
184
|
+
</XStack>
|
|
185
|
+
) : null}
|
|
186
|
+
{favorite ? (
|
|
187
|
+
<XStack
|
|
188
|
+
position="absolute"
|
|
189
|
+
top="$1"
|
|
190
|
+
right="$1"
|
|
191
|
+
zIndex={2}
|
|
192
|
+
pointerEvents="auto"
|
|
193
|
+
{...(isWeb
|
|
194
|
+
? {
|
|
195
|
+
onClickCapture: (event: { preventDefault: () => void }) => {
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
: undefined)}
|
|
200
|
+
>
|
|
201
|
+
<Button
|
|
202
|
+
size="$3"
|
|
203
|
+
circular
|
|
204
|
+
chromeless
|
|
205
|
+
minWidth={knobProps.sizeToken}
|
|
206
|
+
minHeight={knobProps.sizeToken}
|
|
207
|
+
transition={knobProps.transition}
|
|
208
|
+
backgroundColor="$background08"
|
|
209
|
+
hoverStyle={{ backgroundColor: "$background", scale: 1.08 }}
|
|
210
|
+
pressStyle={{ backgroundColor: "$background", scale: 0.92 }}
|
|
211
|
+
onPress={handleToggleFavorite}
|
|
212
|
+
render="button"
|
|
213
|
+
type="button"
|
|
214
|
+
col={(favorite.active ? "$red9" : "$color11") as never}
|
|
215
|
+
icon={<HeartIcon size={20} weight={favorite.active ? "fill" : "regular"} />}
|
|
216
|
+
aria-label={
|
|
217
|
+
favorite.active
|
|
218
|
+
? t("Remove {{name}} from favorites", { name: title })
|
|
219
|
+
: t("Add {{name}} to favorites", { name: title })
|
|
220
|
+
}
|
|
221
|
+
aria-pressed={favorite.active}
|
|
222
|
+
testID={favoriteTestID}
|
|
223
|
+
/>
|
|
224
|
+
</XStack>
|
|
225
|
+
) : null}
|
|
226
|
+
{badges.length > 0 ? (
|
|
227
|
+
<XStack
|
|
228
|
+
position="absolute"
|
|
229
|
+
bottom="$2"
|
|
230
|
+
left="$2"
|
|
231
|
+
right="$2"
|
|
232
|
+
gap="$1.5"
|
|
233
|
+
flexWrap="wrap"
|
|
234
|
+
zIndex={1}
|
|
235
|
+
pointerEvents="none"
|
|
236
|
+
>
|
|
237
|
+
{badges.map((badge) => (
|
|
238
|
+
<FacetBadge key={badge.value} label={badge.label} tint={badge.tint} compact />
|
|
239
|
+
))}
|
|
240
|
+
</XStack>
|
|
241
|
+
) : null}
|
|
242
|
+
</YStack>
|
|
243
|
+
<YStack gap="$0.5" pointerEvents={inert}>
|
|
244
|
+
<Text
|
|
245
|
+
{...knobProps.heading}
|
|
246
|
+
fontWeight="700"
|
|
247
|
+
fontSize="$4"
|
|
248
|
+
numberOfLines={1}
|
|
249
|
+
color="$color12"
|
|
250
|
+
>
|
|
251
|
+
{title}
|
|
252
|
+
</Text>
|
|
253
|
+
<Text {...knobProps.body} fontSize="$2" color="$color10" numberOfLines={1}>
|
|
254
|
+
{subtitle || " "}
|
|
255
|
+
</Text>
|
|
256
|
+
</YStack>
|
|
257
|
+
</YStack>
|
|
258
|
+
</Card>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Button, Wheel, XStack, YStack } from "@multiplatform.one/components";
|
|
2
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
3
|
+
import { ArrowCounterClockwiseIcon, ArrowRightIcon } from "@phosphor-icons/react";
|
|
4
|
+
import type React from "react";
|
|
5
|
+
import { useMemo, useState } from "react";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
|
|
8
|
+
export interface ShufflePanelProps<TDoc extends { name?: string }> {
|
|
9
|
+
/** DOM id the toggle names in aria-controls. */
|
|
10
|
+
id?: string;
|
|
11
|
+
label: string;
|
|
12
|
+
/** Records to pick from, in wheel order. */
|
|
13
|
+
rows: readonly TDoc[];
|
|
14
|
+
/** A record's wheel label. */
|
|
15
|
+
itemLabel: (doc: TDoc) => string;
|
|
16
|
+
/** Draws the current pick beside the wheel. */
|
|
17
|
+
renderPick: (doc: TDoc) => React.ReactNode;
|
|
18
|
+
onGo: (doc: TDoc) => void;
|
|
19
|
+
testID?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const pickWidth = "$12";
|
|
23
|
+
|
|
24
|
+
function randomOtherIndex(current: number, length: number): number {
|
|
25
|
+
if (length < 2) return Math.max(0, current);
|
|
26
|
+
const offset = 1 + Math.floor(Math.random() * (length - 1));
|
|
27
|
+
return (Math.max(0, current) + offset) % length;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Pick a random record: a wheel of record labels beside the current pick.
|
|
32
|
+
* Drag or flick the wheel, or Spin for a random jump, then Go opens it.
|
|
33
|
+
*/
|
|
34
|
+
export function ShufflePanel<TDoc extends { name?: string }>({
|
|
35
|
+
id,
|
|
36
|
+
label,
|
|
37
|
+
rows,
|
|
38
|
+
itemLabel,
|
|
39
|
+
renderPick,
|
|
40
|
+
onGo,
|
|
41
|
+
testID,
|
|
42
|
+
}: ShufflePanelProps<TDoc>) {
|
|
43
|
+
const { t } = useTranslation();
|
|
44
|
+
const { knobProps } = useResolvedKnobs();
|
|
45
|
+
const named = useMemo(() => rows.filter((row) => row.name), [rows]);
|
|
46
|
+
const items = useMemo(
|
|
47
|
+
() => named.map((row) => ({ value: row.name as string, label: itemLabel(row) })),
|
|
48
|
+
[named, itemLabel],
|
|
49
|
+
);
|
|
50
|
+
const [selected, setSelected] = useState<string>(
|
|
51
|
+
() => named[randomOtherIndex(0, named.length)]?.name ?? "",
|
|
52
|
+
);
|
|
53
|
+
// The rows can change while the panel is open; a pick that dropped out
|
|
54
|
+
// falls back to the first row.
|
|
55
|
+
const pick = named.find((row) => row.name === selected) ?? named[0];
|
|
56
|
+
if (!pick) return null;
|
|
57
|
+
|
|
58
|
+
const spin = () => {
|
|
59
|
+
const current = named.findIndex((row) => row.name === pick.name);
|
|
60
|
+
setSelected(named[randomOtherIndex(current, named.length)]?.name ?? "");
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<XStack
|
|
65
|
+
id={id}
|
|
66
|
+
role="region"
|
|
67
|
+
aria-label={label}
|
|
68
|
+
{...knobProps.surface}
|
|
69
|
+
{...knobProps.borderRadius}
|
|
70
|
+
{...knobProps.panelPadding}
|
|
71
|
+
{...knobProps.gap}
|
|
72
|
+
alignItems="center"
|
|
73
|
+
flexWrap="wrap"
|
|
74
|
+
testID={testID}
|
|
75
|
+
>
|
|
76
|
+
<Wheel
|
|
77
|
+
items={items}
|
|
78
|
+
value={pick.name as string}
|
|
79
|
+
onChange={(next) => setSelected(String(next))}
|
|
80
|
+
visibleItems={3}
|
|
81
|
+
loop
|
|
82
|
+
aria-label={label}
|
|
83
|
+
/>
|
|
84
|
+
<YStack width={pickWidth} flexShrink={0}>
|
|
85
|
+
{renderPick(pick)}
|
|
86
|
+
</YStack>
|
|
87
|
+
<XStack {...knobProps.gap} alignItems="center" flexShrink={0}>
|
|
88
|
+
<Button
|
|
89
|
+
outlined
|
|
90
|
+
onPress={spin}
|
|
91
|
+
icon={<ArrowCounterClockwiseIcon size={16} />}
|
|
92
|
+
testID={testID ? `${testID}-spin` : undefined}
|
|
93
|
+
>
|
|
94
|
+
{t("Spin")}
|
|
95
|
+
</Button>
|
|
96
|
+
<Button
|
|
97
|
+
theme="accent"
|
|
98
|
+
onPress={() => onGo(pick)}
|
|
99
|
+
iconAfter={<ArrowRightIcon size={16} />}
|
|
100
|
+
testID={testID ? `${testID}-go` : undefined}
|
|
101
|
+
>
|
|
102
|
+
{t("Go")}
|
|
103
|
+
</Button>
|
|
104
|
+
</XStack>
|
|
105
|
+
</XStack>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a facet's values are read: which rows, and how they fold into each
|
|
3
|
+
* record's values and each value's record count. Pure: no React, no IO.
|
|
4
|
+
*/
|
|
5
|
+
import type { FrappeConnection } from "../frappeConnections";
|
|
6
|
+
import type { FrappeListFacet } from "./listState";
|
|
7
|
+
|
|
8
|
+
type Row = Record<string, unknown>;
|
|
9
|
+
|
|
10
|
+
export interface FacetReading {
|
|
11
|
+
/** Record name to its values, ordered by the facet's `orderBy`. */
|
|
12
|
+
values: ReadonlyMap<string, string[]>;
|
|
13
|
+
/** Value to the number of records carrying it. */
|
|
14
|
+
counts: Readonly<Record<string, number>>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface FacetRead {
|
|
18
|
+
/** The doctype whose rows carry the facet's field. */
|
|
19
|
+
doctype: string;
|
|
20
|
+
/** The field of those rows naming the record; "name" on the list doctype. */
|
|
21
|
+
linkField: string;
|
|
22
|
+
options: { fields: string[]; limit: number };
|
|
23
|
+
/** False while a connection doctype's link is still unknown. */
|
|
24
|
+
ready: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The read behind a facet. A connection doctype's read asks for the fields
|
|
29
|
+
* its declared connection reads too, so both share one collection.
|
|
30
|
+
*/
|
|
31
|
+
export function facetRead(
|
|
32
|
+
facet: FrappeListFacet,
|
|
33
|
+
doctype: string,
|
|
34
|
+
connections: readonly FrappeConnection[] | undefined,
|
|
35
|
+
limit: number | undefined,
|
|
36
|
+
): FacetRead {
|
|
37
|
+
const link = facet.doctype
|
|
38
|
+
? connections?.find((candidate) => candidate.doctype === facet.doctype)
|
|
39
|
+
: undefined;
|
|
40
|
+
const linkField = facet.doctype ? (link?.fieldname ?? "") : "name";
|
|
41
|
+
const fields = new Set<string>(["name", linkField, facet.field]);
|
|
42
|
+
if (facet.orderBy) fields.add(facet.orderBy);
|
|
43
|
+
for (const field of link?.fields ?? []) fields.add(field);
|
|
44
|
+
fields.delete("");
|
|
45
|
+
return {
|
|
46
|
+
doctype: facet.doctype ?? doctype,
|
|
47
|
+
linkField,
|
|
48
|
+
options: { fields: [...fields], limit: facet.doctype ? (link?.limit ?? 0) : (limit ?? 0) },
|
|
49
|
+
ready: !facet.doctype || Boolean(link),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function readFacet(
|
|
54
|
+
facet: FrappeListFacet,
|
|
55
|
+
linkField: string,
|
|
56
|
+
rows: readonly Row[],
|
|
57
|
+
): FacetReading {
|
|
58
|
+
const byRecord = new Map<string, Array<{ value: string; order: number }>>();
|
|
59
|
+
for (const row of rows) {
|
|
60
|
+
const record = row[linkField];
|
|
61
|
+
const value = row[facet.field];
|
|
62
|
+
if (typeof record !== "string" || !record || value === null || value === undefined) continue;
|
|
63
|
+
if (value === "") continue;
|
|
64
|
+
const entry = byRecord.get(record) ?? [];
|
|
65
|
+
entry.push({
|
|
66
|
+
value: String(value),
|
|
67
|
+
order: Number(facet.orderBy ? row[facet.orderBy] : 0) || 0,
|
|
68
|
+
});
|
|
69
|
+
byRecord.set(record, entry);
|
|
70
|
+
}
|
|
71
|
+
const values = new Map<string, string[]>();
|
|
72
|
+
const counts: Record<string, number> = {};
|
|
73
|
+
for (const [record, entries] of byRecord) {
|
|
74
|
+
const ordered = [...new Set(entries.sort((a, b) => a.order - b.order).map((e) => e.value))];
|
|
75
|
+
values.set(record, ordered);
|
|
76
|
+
for (const value of ordered) counts[value] = (counts[value] ?? 0) + 1;
|
|
77
|
+
}
|
|
78
|
+
return { values, counts };
|
|
79
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The list's favorites: a persistent store per storage key (the
|
|
3
|
+
* persistent-stores standard: hydration-gated writes, immutable updates),
|
|
4
|
+
* shared by every reader of that key.
|
|
5
|
+
*/
|
|
6
|
+
import type { Storage } from "@multiplatform.one/store";
|
|
7
|
+
import { describe, expect, it } from "vitest";
|
|
8
|
+
import { createFavoritesStore, favoritesStore, toggleFavoriteIn } from "./favorites";
|
|
9
|
+
|
|
10
|
+
function makeFakeStorage(seed: Record<string, string> = {}) {
|
|
11
|
+
const data = new Map(Object.entries(seed));
|
|
12
|
+
const storage: Storage = {
|
|
13
|
+
getItem: (name) => data.get(name) ?? null,
|
|
14
|
+
setItem: (name, value) => {
|
|
15
|
+
data.set(name, value);
|
|
16
|
+
},
|
|
17
|
+
removeItem: (name) => {
|
|
18
|
+
data.delete(name);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
return { storage, data };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
|
25
|
+
|
|
26
|
+
describe("favorites store", () => {
|
|
27
|
+
it("toggle adds then removes a name, preserving insertion order", async () => {
|
|
28
|
+
const { storage } = makeFakeStorage();
|
|
29
|
+
const store = createFavoritesStore("favs", storage);
|
|
30
|
+
await flush();
|
|
31
|
+
|
|
32
|
+
toggleFavoriteIn(store, "pikachu");
|
|
33
|
+
toggleFavoriteIn(store, "gengar");
|
|
34
|
+
expect(store.state.names).toEqual(["pikachu", "gengar"]);
|
|
35
|
+
|
|
36
|
+
toggleFavoriteIn(store, "pikachu");
|
|
37
|
+
expect(store.state.names).toEqual(["gengar"]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("persists under its key after hydration completes", async () => {
|
|
41
|
+
const { storage, data } = makeFakeStorage();
|
|
42
|
+
const store = createFavoritesStore("pokemon-favorites", storage);
|
|
43
|
+
await flush();
|
|
44
|
+
|
|
45
|
+
toggleFavoriteIn(store, "snorlax");
|
|
46
|
+
await flush();
|
|
47
|
+
|
|
48
|
+
expect(JSON.parse(data.get("pokemon-favorites") ?? "{}")).toEqual({ names: ["snorlax"] });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("rehydrates previously persisted favorites", async () => {
|
|
52
|
+
const { storage } = makeFakeStorage({
|
|
53
|
+
"pokemon-favorites": JSON.stringify({ names: ["mewtwo", "eevee"] }),
|
|
54
|
+
});
|
|
55
|
+
const store = createFavoritesStore("pokemon-favorites", storage);
|
|
56
|
+
await flush();
|
|
57
|
+
|
|
58
|
+
expect(store.state.names).toEqual(["mewtwo", "eevee"]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("clearPersistedState removes the storage entry", async () => {
|
|
62
|
+
const { storage, data } = makeFakeStorage({
|
|
63
|
+
favs: JSON.stringify({ names: ["mew"] }),
|
|
64
|
+
});
|
|
65
|
+
const store = createFavoritesStore("favs", storage);
|
|
66
|
+
await flush();
|
|
67
|
+
|
|
68
|
+
await store.clearPersistedState();
|
|
69
|
+
expect(data.has("favs")).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("hands every reader of one key the same store", () => {
|
|
73
|
+
expect(favoritesStore("frappe-favorites-Pokemon")).toBe(
|
|
74
|
+
favoritesStore("frappe-favorites-Pokemon"),
|
|
75
|
+
);
|
|
76
|
+
expect(favoritesStore("frappe-favorites-Pokemon")).not.toBe(
|
|
77
|
+
favoritesStore("frappe-favorites-Poke Move"),
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list's favorites: the record names a reader starred, kept on the device
|
|
3
|
+
* (no bench write, so a guest can star too). One persistent store per
|
|
4
|
+
* storage key, following docs/standards/frontend/persistent-stores.md.
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
Store,
|
|
8
|
+
createPersistStore,
|
|
9
|
+
storage,
|
|
10
|
+
useStore,
|
|
11
|
+
type PersistStore,
|
|
12
|
+
type Storage,
|
|
13
|
+
} from "@multiplatform.one/store";
|
|
14
|
+
import { useMemo } from "react";
|
|
15
|
+
|
|
16
|
+
export interface FavoritesState {
|
|
17
|
+
/** Starred record names, in the order they were starred. */
|
|
18
|
+
names: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createFavoritesStore(
|
|
22
|
+
key: string,
|
|
23
|
+
storageImpl: Storage = storage,
|
|
24
|
+
): PersistStore<FavoritesState> {
|
|
25
|
+
return createPersistStore<FavoritesState>({ names: [] }, { key, storage: storageImpl });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const stores = new Map<string, PersistStore<FavoritesState>>();
|
|
29
|
+
|
|
30
|
+
/** The shared store for a storage key. */
|
|
31
|
+
export function favoritesStore(key: string): PersistStore<FavoritesState> {
|
|
32
|
+
let store = stores.get(key);
|
|
33
|
+
if (!store) {
|
|
34
|
+
store = createFavoritesStore(key);
|
|
35
|
+
stores.set(key, store);
|
|
36
|
+
}
|
|
37
|
+
return store;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The storage key a doctype's favorites default to. */
|
|
41
|
+
export function favoritesKey(doctype: string): string {
|
|
42
|
+
return `frappe-favorites-${doctype}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function toggleFavoriteIn(store: PersistStore<FavoritesState>, name: string): void {
|
|
46
|
+
store.setState((prev) =>
|
|
47
|
+
prev.names.includes(name)
|
|
48
|
+
? { names: prev.names.filter((n) => n !== name) }
|
|
49
|
+
: { names: [...prev.names, name] },
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface UseFavorites {
|
|
54
|
+
favorites: string[];
|
|
55
|
+
favoriteSet: ReadonlySet<string>;
|
|
56
|
+
isFavorite: (name: string) => boolean;
|
|
57
|
+
toggle: (name: string) => void;
|
|
58
|
+
count: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const noFavorites = new Store<FavoritesState>({ names: [] });
|
|
62
|
+
|
|
63
|
+
/** A key's favorites; without a key, none (and toggling does nothing). */
|
|
64
|
+
export function useFavorites(key: string | undefined): UseFavorites {
|
|
65
|
+
const store = key ? favoritesStore(key) : noFavorites;
|
|
66
|
+
const names = useStore(store, (state) => state.names);
|
|
67
|
+
return useMemo(() => {
|
|
68
|
+
const favoriteSet = new Set(names);
|
|
69
|
+
return {
|
|
70
|
+
favorites: names,
|
|
71
|
+
favoriteSet,
|
|
72
|
+
isFavorite: (name: string) => favoriteSet.has(name),
|
|
73
|
+
toggle: (name: string) => {
|
|
74
|
+
if (store !== noFavorites) toggleFavoriteIn(store as PersistStore<FavoritesState>, name);
|
|
75
|
+
},
|
|
76
|
+
count: names.length,
|
|
77
|
+
};
|
|
78
|
+
}, [names, store]);
|
|
79
|
+
}
|