@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,143 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
average,
|
|
4
|
+
bucketWidth,
|
|
5
|
+
facetDistribution,
|
|
6
|
+
foldDistribution,
|
|
7
|
+
histogram,
|
|
8
|
+
multiValued,
|
|
9
|
+
orderRows,
|
|
10
|
+
topBy,
|
|
11
|
+
} from "./insightsData";
|
|
12
|
+
|
|
13
|
+
const rows = [
|
|
14
|
+
{ name: "bulbasaur", xp: 64, height: 7 },
|
|
15
|
+
{ name: "charmander", xp: 62, height: 6 },
|
|
16
|
+
{ name: "charizard", xp: 240, height: 17 },
|
|
17
|
+
{ name: "pikachu", xp: 112, height: 4 },
|
|
18
|
+
{ name: "mew", xp: null, height: 4 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const types = new Map<string, string[]>([
|
|
22
|
+
["bulbasaur", ["grass", "poison"]],
|
|
23
|
+
["charmander", ["fire"]],
|
|
24
|
+
["charizard", ["fire", "flying"]],
|
|
25
|
+
["pikachu", ["electric"]],
|
|
26
|
+
["missingno", ["normal"]],
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
describe("facetDistribution", () => {
|
|
30
|
+
it("counts the listed records per value, most common first, ties A to Z", () => {
|
|
31
|
+
expect(facetDistribution(types, rows)).toEqual([
|
|
32
|
+
{ value: "fire", count: 2 },
|
|
33
|
+
{ value: "electric", count: 1 },
|
|
34
|
+
{ value: "flying", count: 1 },
|
|
35
|
+
{ value: "grass", count: 1 },
|
|
36
|
+
{ value: "poison", count: 1 },
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("ignores values of records outside the rows", () => {
|
|
41
|
+
expect(facetDistribution(types, rows).some((entry) => entry.value === "normal")).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("foldDistribution", () => {
|
|
46
|
+
const entries = facetDistribution(types, rows);
|
|
47
|
+
|
|
48
|
+
it("keeps a distribution that fits", () => {
|
|
49
|
+
expect(foldDistribution(entries, 5)).toEqual(entries);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("folds the tail into one other entry holding its sum", () => {
|
|
53
|
+
expect(foldDistribution(entries, 3)).toEqual([
|
|
54
|
+
{ value: "fire", count: 2 },
|
|
55
|
+
{ value: "electric", count: 1 },
|
|
56
|
+
{ value: "", count: 3, other: true },
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe("multiValued", () => {
|
|
62
|
+
it("counts the listed records carrying more than one value", () => {
|
|
63
|
+
expect(multiValued(types, rows)).toBe(2);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("average", () => {
|
|
68
|
+
it("means a field over every row, a missing value as 0", () => {
|
|
69
|
+
expect(average(rows, "xp")).toBeCloseTo((64 + 62 + 240 + 112) / 5);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("is 0 for no rows", () => {
|
|
73
|
+
expect(average([], "xp")).toBe(0);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe("topBy", () => {
|
|
78
|
+
it("ranks by a field, largest first, ties in the rows' order", () => {
|
|
79
|
+
expect(topBy(rows, "height", 3).map((row) => row.name)).toEqual([
|
|
80
|
+
"charizard",
|
|
81
|
+
"bulbasaur",
|
|
82
|
+
"charmander",
|
|
83
|
+
]);
|
|
84
|
+
expect(
|
|
85
|
+
topBy(rows, "height", 5)
|
|
86
|
+
.slice(3)
|
|
87
|
+
.map((row) => row.name),
|
|
88
|
+
).toEqual(["pikachu", "mew"]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("never mutates its input", () => {
|
|
92
|
+
const before = rows.map((row) => row.name);
|
|
93
|
+
topBy(rows, "xp", 2);
|
|
94
|
+
expect(rows.map((row) => row.name)).toEqual(before);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe("histogram", () => {
|
|
99
|
+
it("buckets a field from 0 and keeps the empty buckets between", () => {
|
|
100
|
+
expect(histogram(rows, "xp", 60)).toEqual([
|
|
101
|
+
{ label: "0–59", value: 1 },
|
|
102
|
+
{ label: "60–119", value: 3 },
|
|
103
|
+
{ label: "120–179", value: 0 },
|
|
104
|
+
{ label: "180–239", value: 0 },
|
|
105
|
+
{ label: "240–299", value: 1 },
|
|
106
|
+
]);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("is empty for no rows", () => {
|
|
110
|
+
expect(histogram([], "xp", 60)).toEqual([]);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("picks a round width for about six buckets when none is given", () => {
|
|
114
|
+
expect(bucketWidth(240)).toBe(50);
|
|
115
|
+
expect(bucketWidth(17)).toBe(5);
|
|
116
|
+
expect(bucketWidth(0)).toBe(1);
|
|
117
|
+
expect(histogram(rows, "height").map((bucket) => bucket.label)).toEqual([
|
|
118
|
+
"0–4",
|
|
119
|
+
"5–9",
|
|
120
|
+
"10–14",
|
|
121
|
+
"15–19",
|
|
122
|
+
]);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe("orderRows", () => {
|
|
127
|
+
it("orders by each key in turn, a missing value first ascending", () => {
|
|
128
|
+
expect(
|
|
129
|
+
orderRows(rows, [
|
|
130
|
+
{ field: "height", order: "desc" },
|
|
131
|
+
{ field: "name", order: "asc" },
|
|
132
|
+
]).map((row) => row.name),
|
|
133
|
+
).toEqual(["charizard", "bulbasaur", "charmander", "mew", "pikachu"]);
|
|
134
|
+
expect(orderRows(rows, [{ field: "xp", order: "asc" }])[0].name).toBe("mew");
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("keeps the rows as they are without an order, and never mutates them", () => {
|
|
138
|
+
expect(orderRows(rows, undefined)).toEqual(rows);
|
|
139
|
+
const before = rows.map((row) => row.name);
|
|
140
|
+
orderRows(rows, [{ field: "xp", order: "desc" }]);
|
|
141
|
+
expect(rows.map((row) => row.name)).toEqual(before);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The aggregates an insights page draws from the rows one list reads and the
|
|
3
|
+
* values its facet reading found: no React, no IO.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
type Row = { name?: string } & Record<string, unknown>;
|
|
7
|
+
|
|
8
|
+
export interface InsightsCount {
|
|
9
|
+
value: string;
|
|
10
|
+
count: number;
|
|
11
|
+
/** The folded tail of a distribution. */
|
|
12
|
+
other?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface InsightsBucket {
|
|
16
|
+
/** The bucket's range, "60–119". */
|
|
17
|
+
label: string;
|
|
18
|
+
value: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function numberOf(row: Row, field: string): number {
|
|
22
|
+
const value = Number(row[field]);
|
|
23
|
+
return Number.isFinite(value) ? value : 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Records per facet value among `rows`, most common first, ties A to Z. */
|
|
27
|
+
export function facetDistribution(
|
|
28
|
+
values: ReadonlyMap<string, readonly string[]>,
|
|
29
|
+
rows: readonly Row[],
|
|
30
|
+
): InsightsCount[] {
|
|
31
|
+
const counts = new Map<string, number>();
|
|
32
|
+
for (const row of rows) {
|
|
33
|
+
for (const value of values.get(row.name ?? "") ?? []) {
|
|
34
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return [...counts]
|
|
38
|
+
.map(([value, count]) => ({ value, count }))
|
|
39
|
+
.sort((a, b) => b.count - a.count || a.value.localeCompare(b.value));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** At most `max` entries: the tail folds into one `other` entry holding its sum. */
|
|
43
|
+
export function foldDistribution(entries: readonly InsightsCount[], max: number): InsightsCount[] {
|
|
44
|
+
if (entries.length <= max) return [...entries];
|
|
45
|
+
const kept = entries.slice(0, Math.max(0, max - 1));
|
|
46
|
+
const tail = entries.slice(kept.length).reduce((sum, entry) => sum + entry.count, 0);
|
|
47
|
+
return [...kept, { value: "", count: tail, other: true }];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Records among `rows` carrying more than one facet value. */
|
|
51
|
+
export function multiValued(
|
|
52
|
+
values: ReadonlyMap<string, readonly string[]>,
|
|
53
|
+
rows: readonly Row[],
|
|
54
|
+
): number {
|
|
55
|
+
return rows.filter((row) => (values.get(row.name ?? "") ?? []).length > 1).length;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function average(rows: readonly Row[], field: string): number {
|
|
59
|
+
if (rows.length === 0) return 0;
|
|
60
|
+
return rows.reduce((sum, row) => sum + numberOf(row, field), 0) / rows.length;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function compareValues(a: unknown, b: unknown): number {
|
|
64
|
+
if (a === b) return 0;
|
|
65
|
+
if (a === null || a === undefined) return -1;
|
|
66
|
+
if (b === null || b === undefined) return 1;
|
|
67
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
68
|
+
return String(a).localeCompare(String(b));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The rows in an order-by's order, key by key: a collection does not promise
|
|
73
|
+
* it (a fixture corpus answers in insertion order), and ranks break their
|
|
74
|
+
* ties in this order.
|
|
75
|
+
*/
|
|
76
|
+
export function orderRows<TRow extends Row>(
|
|
77
|
+
rows: readonly TRow[],
|
|
78
|
+
orderBy: ReadonlyArray<{ field: string; order: string }> | undefined,
|
|
79
|
+
): TRow[] {
|
|
80
|
+
if (!orderBy?.length) return [...rows];
|
|
81
|
+
return [...rows].sort((a, b) => {
|
|
82
|
+
for (const { field, order } of orderBy) {
|
|
83
|
+
const compared = compareValues(a[field], b[field]);
|
|
84
|
+
if (compared !== 0) return order === "desc" ? -compared : compared;
|
|
85
|
+
}
|
|
86
|
+
return 0;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The `n` rows with the largest `field`; ties keep the rows' order. */
|
|
91
|
+
export function topBy<TRow extends Row>(rows: readonly TRow[], field: string, n: number): TRow[] {
|
|
92
|
+
return [...rows].sort((a, b) => numberOf(b, field) - numberOf(a, field)).slice(0, Math.max(0, n));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A round bucket width (1, 2 or 5 times a power of ten) for about six buckets up to `max`. */
|
|
96
|
+
export function bucketWidth(max: number): number {
|
|
97
|
+
const raw = max / 6;
|
|
98
|
+
if (!(raw > 1)) return 1;
|
|
99
|
+
const magnitude = 10 ** Math.floor(Math.log10(raw));
|
|
100
|
+
return [1, 2, 5, 10].map((step) => step * magnitude).find((width) => width >= raw) ?? raw;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Counts of `field` in `width`-wide buckets from 0, empty buckets between
|
|
105
|
+
* occupied ones kept so a bar chart's axis reads as a scale.
|
|
106
|
+
*/
|
|
107
|
+
export function histogram(rows: readonly Row[], field: string, width?: number): InsightsBucket[] {
|
|
108
|
+
if (rows.length === 0) return [];
|
|
109
|
+
const values = rows.map((row) => Math.max(0, numberOf(row, field)));
|
|
110
|
+
const size = width && width > 0 ? width : bucketWidth(Math.max(...values));
|
|
111
|
+
const counts = new Map<number, number>();
|
|
112
|
+
let last = 0;
|
|
113
|
+
for (const value of values) {
|
|
114
|
+
const bucket = Math.floor(value / size);
|
|
115
|
+
counts.set(bucket, (counts.get(bucket) ?? 0) + 1);
|
|
116
|
+
last = Math.max(last, bucket);
|
|
117
|
+
}
|
|
118
|
+
return Array.from({ length: last + 1 }, (_, bucket) => ({
|
|
119
|
+
label: `${bucket * size}–${(bucket + 1) * size - 1}`,
|
|
120
|
+
value: counts.get(bucket) ?? 0,
|
|
121
|
+
}));
|
|
122
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** A record as the insights sections draw it, resolved once by FrappeInsights. */
|
|
2
|
+
export interface InsightsRecordView<TDoc> {
|
|
3
|
+
title: (doc: TDoc) => string;
|
|
4
|
+
code: (doc: TDoc) => string | undefined;
|
|
5
|
+
images: (doc: TDoc) => string[];
|
|
6
|
+
/** The facet values' tints, first value first. */
|
|
7
|
+
tints: (doc: TDoc) => (string | undefined)[];
|
|
8
|
+
/** The record's facet values. */
|
|
9
|
+
values: (doc: TDoc) => string[];
|
|
10
|
+
valueLabel: (value: string) => string;
|
|
11
|
+
valueTint: (value: string) => string | undefined;
|
|
12
|
+
open: (doc: TDoc) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface FrappeInsightsMetric {
|
|
16
|
+
/** A numeric field of the doctype. */
|
|
17
|
+
field: string;
|
|
18
|
+
label: string;
|
|
19
|
+
/** A value as shown (units, precision); defaults to the number. */
|
|
20
|
+
format?: (value: number) => string;
|
|
21
|
+
/** Names the metric's record-holder tile ("Tallest"); without it, no tile. */
|
|
22
|
+
record?: string;
|
|
23
|
+
/** Histogram bucket width; defaults to a round width for about six buckets. */
|
|
24
|
+
bucket?: number;
|
|
25
|
+
/** A record page fills a bar under the value to this ceiling. */
|
|
26
|
+
max?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function metricValue(doc: unknown, field: string): number {
|
|
30
|
+
const value = Number((doc as Record<string, unknown>)[field]);
|
|
31
|
+
return Number.isFinite(value) ? value : 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function formatMetric(metric: FrappeInsightsMetric, value: number): string {
|
|
35
|
+
return metric.format ? metric.format(value) : String(value);
|
|
36
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Text, XStack } from "@multiplatform.one/components";
|
|
2
|
+
import { hairlineWidth, useResolvedKnobs } from "@multiplatform.one/theme";
|
|
3
|
+
|
|
4
|
+
export interface FacetBadgeProps {
|
|
5
|
+
label: string;
|
|
6
|
+
/** Theme hue (`"grass"`) painting the badge from its ramp. */
|
|
7
|
+
tint?: string;
|
|
8
|
+
/** A step smaller, for image wells and table cells. */
|
|
9
|
+
compact?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* One facet value as a static badge: nested density (LC-73), the tint's
|
|
14
|
+
* step-4 fill, step-7 border and step-12 text (DF-04, AA in both schemes).
|
|
15
|
+
*/
|
|
16
|
+
export function FacetBadge({ label, tint = "gray", compact = false }: FacetBadgeProps) {
|
|
17
|
+
const { knobProps } = useResolvedKnobs({ compact: true });
|
|
18
|
+
return (
|
|
19
|
+
<XStack
|
|
20
|
+
{...knobProps.borderRadius}
|
|
21
|
+
paddingHorizontal={compact ? "$1.5" : "$2"}
|
|
22
|
+
paddingVertical={compact ? "$0.5" : "$1"}
|
|
23
|
+
backgroundColor={`$${tint}4` as never}
|
|
24
|
+
borderColor={`$${tint}7` as never}
|
|
25
|
+
borderWidth={hairlineWidth}
|
|
26
|
+
alignItems="center"
|
|
27
|
+
>
|
|
28
|
+
<Text
|
|
29
|
+
{...knobProps.label}
|
|
30
|
+
{...knobProps.body}
|
|
31
|
+
textTransform="capitalize"
|
|
32
|
+
fontWeight="700"
|
|
33
|
+
color={`$${tint}12` as never}
|
|
34
|
+
{...(compact ? { fontSize: "$1" as const } : null)}
|
|
35
|
+
letterSpacing={0.3}
|
|
36
|
+
>
|
|
37
|
+
{label}
|
|
38
|
+
</Text>
|
|
39
|
+
</XStack>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { ScrollView, Text, XStack, isWeb } from "@multiplatform.one/components";
|
|
2
|
+
import {
|
|
3
|
+
ensureKeyboardModalityTracking,
|
|
4
|
+
keyboardFocusRingProps,
|
|
5
|
+
pressTargetHitSlop,
|
|
6
|
+
transitionProps,
|
|
7
|
+
useResolvedKnobs,
|
|
8
|
+
wasKeyboardFocus,
|
|
9
|
+
} from "@multiplatform.one/theme";
|
|
10
|
+
import { useRef, useState } from "react";
|
|
11
|
+
|
|
12
|
+
export interface FacetRailOption {
|
|
13
|
+
/** Facet value; "" is the chip that clears the facet. */
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
/** Theme hue (`"grass"`) painting the chip from its ramp. */
|
|
17
|
+
tint?: string;
|
|
18
|
+
count?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface FacetRailProps {
|
|
22
|
+
/** Names the radiogroup. */
|
|
23
|
+
label: string;
|
|
24
|
+
/** Active value, or "" for none. */
|
|
25
|
+
value: string;
|
|
26
|
+
options: readonly FacetRailOption[];
|
|
27
|
+
onChange: (value: string) => void;
|
|
28
|
+
testID?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface RailChipProps {
|
|
32
|
+
option: FacetRailOption;
|
|
33
|
+
selected: boolean;
|
|
34
|
+
tabStop: boolean;
|
|
35
|
+
onPress: () => void;
|
|
36
|
+
onFocusChip: () => void;
|
|
37
|
+
onBlurChip: () => void;
|
|
38
|
+
onMove: (direction: -1 | 1 | "home" | "end") => void;
|
|
39
|
+
testID?: string;
|
|
40
|
+
register: (node: { focus?: () => void } | null) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Chips paint a notch under the ~40px toolbar controls; hitSlop restores the
|
|
44
|
+
// 44px press target (DG-LAY-04, ViewSwitcher precedent).
|
|
45
|
+
const chipVisualHeight = 38;
|
|
46
|
+
const chipHitSlop = pressTargetHitSlop(chipVisualHeight);
|
|
47
|
+
const pipSize = "$1";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* One chip. Neutral until active; the active chip fills from its tint ramp
|
|
51
|
+
* (DF-04 pairing: tint fill, step-12 text), so selected is fill, never a
|
|
52
|
+
* sibling border (LC-71). An unselected tinted chip carries a hue pip.
|
|
53
|
+
*/
|
|
54
|
+
function RailChip({
|
|
55
|
+
option,
|
|
56
|
+
selected,
|
|
57
|
+
tabStop,
|
|
58
|
+
onPress,
|
|
59
|
+
onFocusChip,
|
|
60
|
+
onBlurChip,
|
|
61
|
+
onMove,
|
|
62
|
+
testID,
|
|
63
|
+
register,
|
|
64
|
+
}: RailChipProps) {
|
|
65
|
+
const { knobProps } = useResolvedKnobs();
|
|
66
|
+
const [kbFocus, setKbFocus] = useState(false);
|
|
67
|
+
if (isWeb) ensureKeyboardModalityTracking();
|
|
68
|
+
const hue = option.tint;
|
|
69
|
+
const fill = selected ? (hue ? `$${hue}5` : "$color5") : hue ? `$${hue}3` : "$color3";
|
|
70
|
+
const hoverFill = selected ? fill : hue ? `$${hue}4` : "$color4";
|
|
71
|
+
const textColor = selected ? (hue ? `$${hue}12` : "$color12") : hue ? `$${hue}11` : "$color11";
|
|
72
|
+
const keys: Record<string, -1 | 1 | "home" | "end"> = {
|
|
73
|
+
ArrowRight: 1,
|
|
74
|
+
ArrowLeft: -1,
|
|
75
|
+
Home: "home",
|
|
76
|
+
End: "end",
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<XStack
|
|
81
|
+
ref={register}
|
|
82
|
+
{...knobProps.borderRadius}
|
|
83
|
+
backgroundColor={fill as never}
|
|
84
|
+
borderWidth={0}
|
|
85
|
+
paddingHorizontal="$3"
|
|
86
|
+
minHeight={chipVisualHeight}
|
|
87
|
+
hitSlop={chipHitSlop}
|
|
88
|
+
alignItems="center"
|
|
89
|
+
gap="$1.5"
|
|
90
|
+
cursor="pointer"
|
|
91
|
+
role="radio"
|
|
92
|
+
aria-checked={selected}
|
|
93
|
+
{...(isWeb ? { tabIndex: tabStop ? 0 : -1 } : undefined)}
|
|
94
|
+
{...transitionProps(knobProps.transition)}
|
|
95
|
+
hoverStyle={{ backgroundColor: hoverFill as never }}
|
|
96
|
+
pressStyle={{ backgroundColor: fill as never }}
|
|
97
|
+
outlineWidth={0}
|
|
98
|
+
focusStyle={{ outlineWidth: 0, backgroundColor: fill as never }}
|
|
99
|
+
focusVisibleStyle={{ outlineWidth: 0 }}
|
|
100
|
+
{...(isWeb
|
|
101
|
+
? {
|
|
102
|
+
onFocus: () => {
|
|
103
|
+
onFocusChip();
|
|
104
|
+
if (wasKeyboardFocus()) setKbFocus(true);
|
|
105
|
+
},
|
|
106
|
+
onBlur: () => {
|
|
107
|
+
onBlurChip();
|
|
108
|
+
setKbFocus(false);
|
|
109
|
+
},
|
|
110
|
+
onKeyDown: (event: { key?: string; preventDefault?: () => void }) => {
|
|
111
|
+
const direction = event.key ? keys[event.key] : undefined;
|
|
112
|
+
if (direction !== undefined) {
|
|
113
|
+
event.preventDefault?.();
|
|
114
|
+
onMove(direction);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
118
|
+
event.preventDefault?.();
|
|
119
|
+
onPress();
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
}
|
|
123
|
+
: undefined)}
|
|
124
|
+
{...(kbFocus ? keyboardFocusRingProps : undefined)}
|
|
125
|
+
onPress={onPress}
|
|
126
|
+
testID={testID}
|
|
127
|
+
>
|
|
128
|
+
{hue ? (
|
|
129
|
+
<XStack
|
|
130
|
+
width={pipSize}
|
|
131
|
+
height={pipSize}
|
|
132
|
+
borderRadius={1000}
|
|
133
|
+
backgroundColor={`$${hue}9` as never}
|
|
134
|
+
flexShrink={0}
|
|
135
|
+
/>
|
|
136
|
+
) : null}
|
|
137
|
+
<Text
|
|
138
|
+
{...knobProps.label}
|
|
139
|
+
fontWeight={selected ? "700" : "500"}
|
|
140
|
+
color={textColor as never}
|
|
141
|
+
textTransform="capitalize"
|
|
142
|
+
userSelect="none"
|
|
143
|
+
>
|
|
144
|
+
{option.label}
|
|
145
|
+
</Text>
|
|
146
|
+
{typeof option.count === "number" ? (
|
|
147
|
+
<Text
|
|
148
|
+
{...knobProps.label}
|
|
149
|
+
fontSize="$1"
|
|
150
|
+
fontWeight="700"
|
|
151
|
+
color={textColor as never}
|
|
152
|
+
opacity={0.7}
|
|
153
|
+
userSelect="none"
|
|
154
|
+
>
|
|
155
|
+
{option.count}
|
|
156
|
+
</Text>
|
|
157
|
+
) : null}
|
|
158
|
+
</XStack>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A single-select facet as a horizontally scrolling chip rail. One tap
|
|
164
|
+
* narrows, a second tap on the active chip clears. One tab stop (LC-49):
|
|
165
|
+
* arrows, Home and End move and select like a radiogroup, and the focused
|
|
166
|
+
* chip paints the only ring (LC-71). Scrolls on narrow viewports instead of
|
|
167
|
+
* wrapping into a wall of chips.
|
|
168
|
+
*/
|
|
169
|
+
export function FacetRail({ label, value, options, onChange, testID }: FacetRailProps) {
|
|
170
|
+
const itemRefs = useRef<Record<string, { focus?: () => void } | null>>({});
|
|
171
|
+
const [focusValue, setFocusValue] = useState<string | null>(null);
|
|
172
|
+
if (isWeb) ensureKeyboardModalityTracking();
|
|
173
|
+
|
|
174
|
+
const anchor =
|
|
175
|
+
focusValue !== null && options.some((option) => option.value === focusValue)
|
|
176
|
+
? focusValue
|
|
177
|
+
: value;
|
|
178
|
+
|
|
179
|
+
const focusAndSelect = (next: string) => {
|
|
180
|
+
setFocusValue(next);
|
|
181
|
+
onChange(next);
|
|
182
|
+
if (!isWeb) return;
|
|
183
|
+
requestAnimationFrame(() => {
|
|
184
|
+
const node = itemRefs.current[next] as
|
|
185
|
+
| ({ focus?: () => void } & { scrollIntoView?: (options: object) => void })
|
|
186
|
+
| null;
|
|
187
|
+
node?.focus?.();
|
|
188
|
+
node?.scrollIntoView?.({ inline: "nearest", block: "nearest" });
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const moveFrom = (from: string, direction: -1 | 1 | "home" | "end") => {
|
|
193
|
+
if (options.length === 0) return;
|
|
194
|
+
if (direction === "home") return focusAndSelect(options[0].value);
|
|
195
|
+
if (direction === "end") return focusAndSelect(options[options.length - 1].value);
|
|
196
|
+
const index = Math.max(
|
|
197
|
+
0,
|
|
198
|
+
options.findIndex((option) => option.value === from),
|
|
199
|
+
);
|
|
200
|
+
focusAndSelect(options[(index + direction + options.length) % options.length].value);
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<ScrollView horizontal showsHorizontalScrollIndicator={false} flexShrink={0}>
|
|
205
|
+
<XStack
|
|
206
|
+
role="radiogroup"
|
|
207
|
+
aria-label={label}
|
|
208
|
+
aria-orientation="horizontal"
|
|
209
|
+
gap="$1.5"
|
|
210
|
+
alignItems="center"
|
|
211
|
+
paddingVertical="$1"
|
|
212
|
+
testID={testID}
|
|
213
|
+
>
|
|
214
|
+
{options.map((option) => (
|
|
215
|
+
<RailChip
|
|
216
|
+
key={option.value || "__all"}
|
|
217
|
+
option={option}
|
|
218
|
+
selected={option.value === value}
|
|
219
|
+
tabStop={option.value === anchor}
|
|
220
|
+
onPress={() =>
|
|
221
|
+
onChange(option.value === value && option.value !== "" ? "" : option.value)
|
|
222
|
+
}
|
|
223
|
+
onFocusChip={() => setFocusValue(option.value)}
|
|
224
|
+
onBlurChip={() => setFocusValue((prev) => (prev === option.value ? null : prev))}
|
|
225
|
+
onMove={(direction) => moveFrom(option.value, direction)}
|
|
226
|
+
testID={testID ? `${testID}-${option.value || "all"}` : undefined}
|
|
227
|
+
register={(node) => {
|
|
228
|
+
itemRefs.current[option.value] = node;
|
|
229
|
+
}}
|
|
230
|
+
/>
|
|
231
|
+
))}
|
|
232
|
+
</XStack>
|
|
233
|
+
</ScrollView>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Image,
|
|
3
|
+
Text,
|
|
4
|
+
XStack,
|
|
5
|
+
YStack,
|
|
6
|
+
isWeb,
|
|
7
|
+
type YStackProps,
|
|
8
|
+
} from "@multiplatform.one/components";
|
|
9
|
+
import { useResolvedKnobs } from "@multiplatform.one/theme";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
|
|
12
|
+
export interface ImageWellProps extends Omit<YStackProps, "children"> {
|
|
13
|
+
/** Candidate URLs in order; a failed load moves to the next. */
|
|
14
|
+
sources: readonly string[];
|
|
15
|
+
alt: string;
|
|
16
|
+
/**
|
|
17
|
+
* Theme hues (`"grass"`) painting the well from their ramps: one fills it,
|
|
18
|
+
* two split it down the middle.
|
|
19
|
+
*/
|
|
20
|
+
tints?: readonly (string | undefined)[];
|
|
21
|
+
/** Nearest-neighbor upscaling, for pixel art. */
|
|
22
|
+
pixelated?: boolean;
|
|
23
|
+
/** Gap between the well's edge and the image, as a fraction of its width. */
|
|
24
|
+
inset?: number;
|
|
25
|
+
/** Fetch only as the image nears the viewport (web). */
|
|
26
|
+
lazy?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A square image well: a tinted surface (the tint is data, from the theme's
|
|
31
|
+
* ramps) holding an image that walks its candidate list on error and fades
|
|
32
|
+
* in on web, with a "?" when every candidate fails.
|
|
33
|
+
*/
|
|
34
|
+
export function ImageWell({
|
|
35
|
+
sources,
|
|
36
|
+
alt,
|
|
37
|
+
tints,
|
|
38
|
+
pixelated = false,
|
|
39
|
+
inset = 0.06,
|
|
40
|
+
lazy = false,
|
|
41
|
+
...wellProps
|
|
42
|
+
}: ImageWellProps) {
|
|
43
|
+
const { knobProps } = useResolvedKnobs();
|
|
44
|
+
const [sourceIndex, setSourceIndex] = useState(0);
|
|
45
|
+
const [revealedSrc, setRevealedSrc] = useState<string | null>(null);
|
|
46
|
+
const hue = tints?.[0] ?? "gray";
|
|
47
|
+
const secondHue = tints?.[1];
|
|
48
|
+
|
|
49
|
+
const sourceKey = sources.join("|");
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
setSourceIndex(0);
|
|
52
|
+
}, [sourceKey]);
|
|
53
|
+
|
|
54
|
+
const src = sources[sourceIndex] ?? "";
|
|
55
|
+
// onLoad can be missed for a cached or server-rendered image, so a short
|
|
56
|
+
// timer reveals it anyway: a slow image may pop, but none stays invisible.
|
|
57
|
+
const revealed = !isWeb || !src || revealedSrc === src;
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!isWeb || !src || revealedSrc === src) return;
|
|
60
|
+
const timer = setTimeout(() => setRevealedSrc(src), 350);
|
|
61
|
+
return () => clearTimeout(timer);
|
|
62
|
+
}, [src, revealedSrc]);
|
|
63
|
+
|
|
64
|
+
const imageSize = `${Math.round((1 - inset * 2) * 100)}%`;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<YStack
|
|
68
|
+
{...knobProps.borderRadius}
|
|
69
|
+
borderWidth={0}
|
|
70
|
+
backgroundColor={secondHue ? "transparent" : (`$${hue}5` as never)}
|
|
71
|
+
aspectRatio={1}
|
|
72
|
+
width="100%"
|
|
73
|
+
alignItems="center"
|
|
74
|
+
justifyContent="center"
|
|
75
|
+
overflow="hidden"
|
|
76
|
+
position="relative"
|
|
77
|
+
{...wellProps}
|
|
78
|
+
>
|
|
79
|
+
{secondHue ? (
|
|
80
|
+
<XStack fullscreen zIndex={0} pointerEvents="none">
|
|
81
|
+
<YStack flex={1} backgroundColor={`$${hue}5` as never} />
|
|
82
|
+
<YStack flex={1} backgroundColor={`$${secondHue}5` as never} />
|
|
83
|
+
</XStack>
|
|
84
|
+
) : null}
|
|
85
|
+
{src ? (
|
|
86
|
+
<Image
|
|
87
|
+
key={src}
|
|
88
|
+
src={src}
|
|
89
|
+
alt={alt}
|
|
90
|
+
width={imageSize as never}
|
|
91
|
+
height={imageSize as never}
|
|
92
|
+
objectFit="contain"
|
|
93
|
+
opacity={revealed ? 1 : 0}
|
|
94
|
+
transition={knobProps.transition}
|
|
95
|
+
zIndex={1}
|
|
96
|
+
{...((isWeb ? { loading: lazy ? "lazy" : "eager", decoding: "async" } : undefined) as
|
|
97
|
+
| Record<string, unknown>
|
|
98
|
+
| undefined)}
|
|
99
|
+
{...(pixelated && isWeb ? { style: { imageRendering: "pixelated" } as never } : null)}
|
|
100
|
+
onLoad={() => setRevealedSrc(src)}
|
|
101
|
+
onError={() => setSourceIndex((index) => index + 1)}
|
|
102
|
+
/>
|
|
103
|
+
) : (
|
|
104
|
+
<Text fontSize="$10" color={`$${hue}8` as never} fontWeight="700" aria-hidden zIndex={1}>
|
|
105
|
+
?
|
|
106
|
+
</Text>
|
|
107
|
+
)}
|
|
108
|
+
</YStack>
|
|
109
|
+
);
|
|
110
|
+
}
|