@cratis/scene.primereact 4.5.0 → 4.7.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/.storybook/preview.tsx +8 -1
- package/EnumerationResolution.ts +7 -0
- package/README.md +42 -10
- package/chart/ChartGallery.stories.tsx +63 -0
- package/chart/ChartType.ts +14 -0
- package/chart/ChartTypeResolution.ts +14 -0
- package/chart/PrimeChart.tsx +62 -0
- package/chart/chartHasData.ts +22 -0
- package/chart/chartTypeChoices.ts +32 -0
- package/chart/index.ts +7 -0
- package/chart/resolveChartType.ts +61 -0
- package/chart/useChart.ts +61 -0
- package/data/DataGallery.stories.tsx +6 -0
- package/data/DataScrollerRow.tsx +35 -0
- package/data/PrimeDataScroller.tsx +84 -0
- package/data/PrimeTreeTable.tsx +145 -0
- package/data/TreeTableCheckState.ts +9 -0
- package/data/TreeTableRow.ts +22 -0
- package/data/TreeTableRowView.tsx +86 -0
- package/data/TreeTableSelectionMode.ts +10 -0
- package/data/checkboxSelection.ts +92 -0
- package/data/index.ts +4 -0
- package/data/isSerializedLegacyElement.ts +30 -0
- package/data/readableValue.ts +32 -0
- package/data/selectionKeysOf.ts +40 -0
- package/data/treeTableRows.ts +32 -0
- package/data/useIncrementalLoad.ts +36 -0
- package/data/useLoadOnReach.ts +31 -0
- package/data/useTreeGridNavigation.ts +81 -0
- package/dist/cjs/chart/ChartType.js +18 -0
- package/dist/cjs/chart/ChartType.js.map +1 -0
- package/dist/cjs/chart/PrimeChart.js +92 -0
- package/dist/cjs/chart/PrimeChart.js.map +1 -0
- package/dist/cjs/chart/chartHasData.js +24 -0
- package/dist/cjs/chart/chartHasData.js.map +1 -0
- package/dist/cjs/chart/chartTypeChoices.js +43 -0
- package/dist/cjs/chart/chartTypeChoices.js.map +1 -0
- package/dist/cjs/chart/resolveChartType.js +69 -0
- package/dist/cjs/chart/resolveChartType.js.map +1 -0
- package/dist/cjs/chart/useChart.js +62 -0
- package/dist/cjs/chart/useChart.js.map +1 -0
- package/dist/cjs/data/DataScrollerRow.js +50 -0
- package/dist/cjs/data/DataScrollerRow.js.map +1 -0
- package/dist/cjs/data/PrimeDataScroller.js +120 -0
- package/dist/cjs/data/PrimeDataScroller.js.map +1 -0
- package/dist/cjs/data/PrimeTreeTable.js +217 -0
- package/dist/cjs/data/PrimeTreeTable.js.map +1 -0
- package/dist/cjs/data/TreeTableCheckState.js +13 -0
- package/dist/cjs/data/TreeTableCheckState.js.map +1 -0
- package/dist/cjs/data/TreeTableRowView.js +76 -0
- package/dist/cjs/data/TreeTableRowView.js.map +1 -0
- package/dist/cjs/data/TreeTableSelectionMode.js +14 -0
- package/dist/cjs/data/TreeTableSelectionMode.js.map +1 -0
- package/dist/cjs/data/checkboxSelection.js +88 -0
- package/dist/cjs/data/checkboxSelection.js.map +1 -0
- package/dist/cjs/data/isSerializedLegacyElement.js +30 -0
- package/dist/cjs/data/isSerializedLegacyElement.js.map +1 -0
- package/dist/cjs/data/readableValue.js +31 -0
- package/dist/cjs/data/readableValue.js.map +1 -0
- package/dist/cjs/data/selectionKeysOf.js +40 -0
- package/dist/cjs/data/selectionKeysOf.js.map +1 -0
- package/dist/cjs/data/treeTableRows.js +42 -0
- package/dist/cjs/data/treeTableRows.js.map +1 -0
- package/dist/cjs/data/useIncrementalLoad.js +46 -0
- package/dist/cjs/data/useIncrementalLoad.js.map +1 -0
- package/dist/cjs/data/useLoadOnReach.js +42 -0
- package/dist/cjs/data/useLoadOnReach.js.map +1 -0
- package/dist/cjs/data/useTreeGridNavigation.js +75 -0
- package/dist/cjs/data/useTreeGridNavigation.js.map +1 -0
- package/dist/cjs/editor/PrimeEditor.js +96 -0
- package/dist/cjs/editor/PrimeEditor.js.map +1 -0
- package/dist/cjs/editor/QuillLoaderContext.js +10 -0
- package/dist/cjs/editor/QuillLoaderContext.js.map +1 -0
- package/dist/cjs/editor/QuillLoaderProvider.js +21 -0
- package/dist/cjs/editor/QuillLoaderProvider.js.map +1 -0
- package/dist/cjs/editor/applyHtml.js +25 -0
- package/dist/cjs/editor/applyHtml.js.map +1 -0
- package/dist/cjs/editor/characterCount.js +10 -0
- package/dist/cjs/editor/characterCount.js.map +1 -0
- package/dist/cjs/editor/htmlToPlainText.js +101 -0
- package/dist/cjs/editor/htmlToPlainText.js.map +1 -0
- package/dist/cjs/editor/renderSafeNodes.js +35 -0
- package/dist/cjs/editor/renderSafeNodes.js.map +1 -0
- package/dist/cjs/editor/safeUrls.js +44 -0
- package/dist/cjs/editor/safeUrls.js.map +1 -0
- package/dist/cjs/editor/sanitizeHtml.js +140 -0
- package/dist/cjs/editor/sanitizeHtml.js.map +1 -0
- package/dist/cjs/editor/serializeSafeNodes.js +33 -0
- package/dist/cjs/editor/serializeSafeNodes.js.map +1 -0
- package/dist/cjs/editor/toolbarLayout.js +35 -0
- package/dist/cjs/editor/toolbarLayout.js.map +1 -0
- package/dist/cjs/editor/useQuillEditor.js +137 -0
- package/dist/cjs/editor/useQuillEditor.js.map +1 -0
- package/dist/cjs/file/FileUploadContext.js +13 -0
- package/dist/cjs/file/FileUploadContext.js.map +1 -0
- package/dist/cjs/file/FileUploadHandlerProvider.js +25 -0
- package/dist/cjs/file/FileUploadHandlerProvider.js.map +1 -0
- package/dist/cjs/file/FileUploadMode.js +13 -0
- package/dist/cjs/file/FileUploadMode.js.map +1 -0
- package/dist/cjs/file/PrimeFileUpload.js +161 -0
- package/dist/cjs/file/PrimeFileUpload.js.map +1 -0
- package/dist/cjs/file/postFiles.js +31 -0
- package/dist/cjs/file/postFiles.js.map +1 -0
- package/dist/cjs/file/resolveUploadTarget.js +68 -0
- package/dist/cjs/file/resolveUploadTarget.js.map +1 -0
- package/dist/cjs/file/useUploadSession.js +62 -0
- package/dist/cjs/file/useUploadSession.js.map +1 -0
- package/dist/cjs/form/MultiStateGlyph.js +59 -0
- package/dist/cjs/form/MultiStateGlyph.js.map +1 -0
- package/dist/cjs/form/PrimeMultiStateCheckbox.js +123 -0
- package/dist/cjs/form/PrimeMultiStateCheckbox.js.map +1 -0
- package/dist/cjs/form/multiStateOptions.js +77 -0
- package/dist/cjs/form/multiStateOptions.js.map +1 -0
- package/dist/cjs/form/multiStateStates.js +32 -0
- package/dist/cjs/form/multiStateStates.js.map +1 -0
- package/dist/cjs/form/useMultiStateSelection.js +51 -0
- package/dist/cjs/form/useMultiStateSelection.js.map +1 -0
- package/dist/cjs/index.js +44 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/legacyEnumerationChoices.js +39 -0
- package/dist/cjs/legacyEnumerationChoices.js.map +1 -0
- package/dist/cjs/loadQuill/index.js +22 -0
- package/dist/cjs/loadQuill/index.js.map +1 -0
- package/dist/cjs/primeReactComponents.js +15 -0
- package/dist/cjs/primeReactComponents.js.map +1 -1
- package/dist/cjs/primeReactDescriptors.js +400 -0
- package/dist/cjs/primeReactDescriptors.js.map +1 -0
- package/dist/cjs/primeReactPackage.js +8 -0
- package/dist/cjs/primeReactPackage.js.map +1 -1
- package/dist/cjs/properties.js +11 -0
- package/dist/cjs/properties.js.map +1 -1
- package/dist/cjs/resolveEnumeration.js +55 -0
- package/dist/cjs/resolveEnumeration.js.map +1 -0
- package/dist/cjs/structurallyEqual.js +27 -0
- package/dist/cjs/structurallyEqual.js.map +1 -0
- package/dist/cjs/treeNodes.js +42 -7
- package/dist/cjs/treeNodes.js.map +1 -1
- package/dist/cjs/useResettingState.js +47 -0
- package/dist/cjs/useResettingState.js.map +1 -0
- package/dist/cjs/useStructuralValue.js +20 -0
- package/dist/cjs/useStructuralValue.js.map +1 -0
- package/dist/esm/EnumerationResolution.d.ts +9 -0
- package/dist/esm/EnumerationResolution.d.ts.map +1 -0
- package/dist/esm/EnumerationResolution.js +2 -0
- package/dist/esm/EnumerationResolution.js.map +1 -0
- package/dist/esm/chart/ChartGallery.stories.d.ts +14 -0
- package/dist/esm/chart/ChartGallery.stories.d.ts.map +1 -0
- package/dist/esm/chart/ChartGallery.stories.js +47 -0
- package/dist/esm/chart/ChartGallery.stories.js.map +1 -0
- package/dist/esm/chart/ChartType.d.ts +11 -0
- package/dist/esm/chart/ChartType.d.ts.map +1 -0
- package/dist/esm/chart/ChartType.js +16 -0
- package/dist/esm/chart/ChartType.js.map +1 -0
- package/dist/esm/chart/ChartTypeResolution.d.ts +10 -0
- package/dist/esm/chart/ChartTypeResolution.d.ts.map +1 -0
- package/dist/esm/chart/ChartTypeResolution.js +2 -0
- package/dist/esm/chart/ChartTypeResolution.js.map +1 -0
- package/dist/esm/chart/PrimeChart.d.ts +3 -0
- package/dist/esm/chart/PrimeChart.d.ts.map +1 -0
- package/dist/esm/chart/PrimeChart.js +90 -0
- package/dist/esm/chart/PrimeChart.js.map +1 -0
- package/dist/esm/chart/chartHasData.d.ts +2 -0
- package/dist/esm/chart/chartHasData.d.ts.map +1 -0
- package/dist/esm/chart/chartHasData.js +22 -0
- package/dist/esm/chart/chartHasData.js.map +1 -0
- package/dist/esm/chart/chartTypeChoices.d.ts +3 -0
- package/dist/esm/chart/chartTypeChoices.d.ts.map +1 -0
- package/dist/esm/chart/chartTypeChoices.js +41 -0
- package/dist/esm/chart/chartTypeChoices.js.map +1 -0
- package/dist/esm/chart/index.d.ts +5 -0
- package/dist/esm/chart/index.d.ts.map +1 -0
- package/dist/esm/chart/index.js +5 -0
- package/dist/esm/chart/index.js.map +1 -0
- package/dist/esm/chart/resolveChartType.d.ts +6 -0
- package/dist/esm/chart/resolveChartType.d.ts.map +1 -0
- package/dist/esm/chart/resolveChartType.js +66 -0
- package/dist/esm/chart/resolveChartType.js.map +1 -0
- package/dist/esm/chart/useChart.d.ts +4 -0
- package/dist/esm/chart/useChart.d.ts.map +1 -0
- package/dist/esm/chart/useChart.js +60 -0
- package/dist/esm/chart/useChart.js.map +1 -0
- package/dist/esm/data/DataGallery.stories.d.ts.map +1 -1
- package/dist/esm/data/DataGallery.stories.js +6 -0
- package/dist/esm/data/DataGallery.stories.js.map +1 -1
- package/dist/esm/data/DataScrollerRow.d.ts +4 -0
- package/dist/esm/data/DataScrollerRow.d.ts.map +1 -0
- package/dist/esm/data/DataScrollerRow.js +48 -0
- package/dist/esm/data/DataScrollerRow.js.map +1 -0
- package/dist/esm/data/PrimeDataScroller.d.ts +3 -0
- package/dist/esm/data/PrimeDataScroller.d.ts.map +1 -0
- package/dist/esm/data/PrimeDataScroller.js +118 -0
- package/dist/esm/data/PrimeDataScroller.js.map +1 -0
- package/dist/esm/data/PrimeTreeTable.d.ts +3 -0
- package/dist/esm/data/PrimeTreeTable.d.ts.map +1 -0
- package/dist/esm/data/PrimeTreeTable.js +215 -0
- package/dist/esm/data/PrimeTreeTable.js.map +1 -0
- package/dist/esm/data/TreeTableCheckState.d.ts +6 -0
- package/dist/esm/data/TreeTableCheckState.d.ts.map +1 -0
- package/dist/esm/data/TreeTableCheckState.js +11 -0
- package/dist/esm/data/TreeTableCheckState.js.map +1 -0
- package/dist/esm/data/TreeTableRow.d.ts +10 -0
- package/dist/esm/data/TreeTableRow.d.ts.map +1 -0
- package/dist/esm/data/TreeTableRow.js +2 -0
- package/dist/esm/data/TreeTableRow.js.map +1 -0
- package/dist/esm/data/TreeTableRowView.d.ts +21 -0
- package/dist/esm/data/TreeTableRowView.d.ts.map +1 -0
- package/dist/esm/data/TreeTableRowView.js +74 -0
- package/dist/esm/data/TreeTableRowView.js.map +1 -0
- package/dist/esm/data/TreeTableSelectionMode.d.ts +7 -0
- package/dist/esm/data/TreeTableSelectionMode.d.ts.map +1 -0
- package/dist/esm/data/TreeTableSelectionMode.js +12 -0
- package/dist/esm/data/TreeTableSelectionMode.js.map +1 -0
- package/dist/esm/data/checkboxSelection.d.ts +9 -0
- package/dist/esm/data/checkboxSelection.d.ts.map +1 -0
- package/dist/esm/data/checkboxSelection.js +85 -0
- package/dist/esm/data/checkboxSelection.js.map +1 -0
- package/dist/esm/data/index.d.ts +4 -0
- package/dist/esm/data/index.d.ts.map +1 -1
- package/dist/esm/data/index.js +4 -0
- package/dist/esm/data/index.js.map +1 -1
- package/dist/esm/data/isSerializedLegacyElement.d.ts +3 -0
- package/dist/esm/data/isSerializedLegacyElement.d.ts.map +1 -0
- package/dist/esm/data/isSerializedLegacyElement.js +27 -0
- package/dist/esm/data/isSerializedLegacyElement.js.map +1 -0
- package/dist/esm/data/readableValue.d.ts +2 -0
- package/dist/esm/data/readableValue.d.ts.map +1 -0
- package/dist/esm/data/readableValue.js +29 -0
- package/dist/esm/data/readableValue.js.map +1 -0
- package/dist/esm/data/selectionKeysOf.d.ts +2 -0
- package/dist/esm/data/selectionKeysOf.d.ts.map +1 -0
- package/dist/esm/data/selectionKeysOf.js +38 -0
- package/dist/esm/data/selectionKeysOf.js.map +1 -0
- package/dist/esm/data/treeTableRows.d.ts +6 -0
- package/dist/esm/data/treeTableRows.d.ts.map +1 -0
- package/dist/esm/data/treeTableRows.js +38 -0
- package/dist/esm/data/treeTableRows.js.map +1 -0
- package/dist/esm/data/useIncrementalLoad.d.ts +6 -0
- package/dist/esm/data/useIncrementalLoad.d.ts.map +1 -0
- package/dist/esm/data/useIncrementalLoad.js +44 -0
- package/dist/esm/data/useIncrementalLoad.js.map +1 -0
- package/dist/esm/data/useLoadOnReach.d.ts +3 -0
- package/dist/esm/data/useLoadOnReach.d.ts.map +1 -0
- package/dist/esm/data/useLoadOnReach.js +40 -0
- package/dist/esm/data/useLoadOnReach.js.map +1 -0
- package/dist/esm/data/useTreeGridNavigation.d.ts +17 -0
- package/dist/esm/data/useTreeGridNavigation.d.ts.map +1 -0
- package/dist/esm/data/useTreeGridNavigation.js +73 -0
- package/dist/esm/data/useTreeGridNavigation.js.map +1 -0
- package/dist/esm/editor/PrimeEditor.d.ts +3 -0
- package/dist/esm/editor/PrimeEditor.d.ts.map +1 -0
- package/dist/esm/editor/PrimeEditor.js +94 -0
- package/dist/esm/editor/PrimeEditor.js.map +1 -0
- package/dist/esm/editor/QuillConstructor.d.ts +4 -0
- package/dist/esm/editor/QuillConstructor.d.ts.map +1 -0
- package/dist/esm/editor/QuillConstructor.js +2 -0
- package/dist/esm/editor/QuillConstructor.js.map +1 -0
- package/dist/esm/editor/QuillEditorOptions.d.ts +13 -0
- package/dist/esm/editor/QuillEditorOptions.d.ts.map +1 -0
- package/dist/esm/editor/QuillEditorOptions.js +2 -0
- package/dist/esm/editor/QuillEditorOptions.js.map +1 -0
- package/dist/esm/editor/QuillEditorState.d.ts +6 -0
- package/dist/esm/editor/QuillEditorState.d.ts.map +1 -0
- package/dist/esm/editor/QuillEditorState.js +2 -0
- package/dist/esm/editor/QuillEditorState.js.map +1 -0
- package/dist/esm/editor/QuillInstance.d.ts +16 -0
- package/dist/esm/editor/QuillInstance.d.ts.map +1 -0
- package/dist/esm/editor/QuillInstance.js +2 -0
- package/dist/esm/editor/QuillInstance.js.map +1 -0
- package/dist/esm/editor/QuillLoader.d.ts +5 -0
- package/dist/esm/editor/QuillLoader.d.ts.map +1 -0
- package/dist/esm/editor/QuillLoader.js +2 -0
- package/dist/esm/editor/QuillLoader.js.map +1 -0
- package/dist/esm/editor/QuillLoaderContext.d.ts +3 -0
- package/dist/esm/editor/QuillLoaderContext.d.ts.map +1 -0
- package/dist/esm/editor/QuillLoaderContext.js +8 -0
- package/dist/esm/editor/QuillLoaderContext.js.map +1 -0
- package/dist/esm/editor/QuillLoaderProvider.d.ts +8 -0
- package/dist/esm/editor/QuillLoaderProvider.d.ts.map +1 -0
- package/dist/esm/editor/QuillLoaderProvider.js +19 -0
- package/dist/esm/editor/QuillLoaderProvider.js.map +1 -0
- package/dist/esm/editor/QuillOptions.d.ts +9 -0
- package/dist/esm/editor/QuillOptions.d.ts.map +1 -0
- package/dist/esm/editor/QuillOptions.js +2 -0
- package/dist/esm/editor/QuillOptions.js.map +1 -0
- package/dist/esm/editor/SafeElement.d.ts +7 -0
- package/dist/esm/editor/SafeElement.d.ts.map +1 -0
- package/dist/esm/editor/SafeElement.js +2 -0
- package/dist/esm/editor/SafeElement.js.map +1 -0
- package/dist/esm/editor/SafeNode.d.ts +3 -0
- package/dist/esm/editor/SafeNode.d.ts.map +1 -0
- package/dist/esm/editor/SafeNode.js +2 -0
- package/dist/esm/editor/SafeNode.js.map +1 -0
- package/dist/esm/editor/applyHtml.d.ts +3 -0
- package/dist/esm/editor/applyHtml.d.ts.map +1 -0
- package/dist/esm/editor/applyHtml.js +23 -0
- package/dist/esm/editor/applyHtml.js.map +1 -0
- package/dist/esm/editor/characterCount.d.ts +3 -0
- package/dist/esm/editor/characterCount.d.ts.map +1 -0
- package/dist/esm/editor/characterCount.js +8 -0
- package/dist/esm/editor/characterCount.js.map +1 -0
- package/dist/esm/editor/htmlToPlainText.d.ts +2 -0
- package/dist/esm/editor/htmlToPlainText.d.ts.map +1 -0
- package/dist/esm/editor/htmlToPlainText.js +99 -0
- package/dist/esm/editor/htmlToPlainText.js.map +1 -0
- package/dist/esm/editor/index.d.ts +14 -0
- package/dist/esm/editor/index.d.ts.map +1 -0
- package/dist/esm/editor/index.js +14 -0
- package/dist/esm/editor/index.js.map +1 -0
- package/dist/esm/editor/renderSafeNodes.d.ts +4 -0
- package/dist/esm/editor/renderSafeNodes.d.ts.map +1 -0
- package/dist/esm/editor/renderSafeNodes.js +33 -0
- package/dist/esm/editor/renderSafeNodes.js.map +1 -0
- package/dist/esm/editor/safeUrls.d.ts +3 -0
- package/dist/esm/editor/safeUrls.d.ts.map +1 -0
- package/dist/esm/editor/safeUrls.js +41 -0
- package/dist/esm/editor/safeUrls.js.map +1 -0
- package/dist/esm/editor/sanitizeHtml.d.ts +3 -0
- package/dist/esm/editor/sanitizeHtml.d.ts.map +1 -0
- package/dist/esm/editor/sanitizeHtml.js +138 -0
- package/dist/esm/editor/sanitizeHtml.js.map +1 -0
- package/dist/esm/editor/serializeSafeNodes.d.ts +3 -0
- package/dist/esm/editor/serializeSafeNodes.d.ts.map +1 -0
- package/dist/esm/editor/serializeSafeNodes.js +31 -0
- package/dist/esm/editor/serializeSafeNodes.js.map +1 -0
- package/dist/esm/editor/toolbarLayout.d.ts +2 -0
- package/dist/esm/editor/toolbarLayout.d.ts.map +1 -0
- package/dist/esm/editor/toolbarLayout.js +33 -0
- package/dist/esm/editor/toolbarLayout.js.map +1 -0
- package/dist/esm/editor/useQuillEditor.d.ts +4 -0
- package/dist/esm/editor/useQuillEditor.d.ts.map +1 -0
- package/dist/esm/editor/useQuillEditor.js +135 -0
- package/dist/esm/editor/useQuillEditor.js.map +1 -0
- package/dist/esm/file/FileGallery.stories.d.ts +19 -0
- package/dist/esm/file/FileGallery.stories.d.ts.map +1 -0
- package/dist/esm/file/FileGallery.stories.js +23 -0
- package/dist/esm/file/FileGallery.stories.js.map +1 -0
- package/dist/esm/file/FileUploadContext.d.ts +7 -0
- package/dist/esm/file/FileUploadContext.d.ts.map +1 -0
- package/dist/esm/file/FileUploadContext.js +11 -0
- package/dist/esm/file/FileUploadContext.js.map +1 -0
- package/dist/esm/file/FileUploadHandler.d.ts +4 -0
- package/dist/esm/file/FileUploadHandler.d.ts.map +1 -0
- package/dist/esm/file/FileUploadHandler.js +2 -0
- package/dist/esm/file/FileUploadHandler.js.map +1 -0
- package/dist/esm/file/FileUploadHandlerProvider.d.ts +9 -0
- package/dist/esm/file/FileUploadHandlerProvider.d.ts.map +1 -0
- package/dist/esm/file/FileUploadHandlerProvider.js +23 -0
- package/dist/esm/file/FileUploadHandlerProvider.js.map +1 -0
- package/dist/esm/file/FileUploadMode.d.ts +6 -0
- package/dist/esm/file/FileUploadMode.d.ts.map +1 -0
- package/dist/esm/file/FileUploadMode.js +11 -0
- package/dist/esm/file/FileUploadMode.js.map +1 -0
- package/dist/esm/file/PrimeFileUpload.d.ts +3 -0
- package/dist/esm/file/PrimeFileUpload.d.ts.map +1 -0
- package/dist/esm/file/PrimeFileUpload.js +159 -0
- package/dist/esm/file/PrimeFileUpload.js.map +1 -0
- package/dist/esm/file/UploadStatus.d.ts +5 -0
- package/dist/esm/file/UploadStatus.d.ts.map +1 -0
- package/dist/esm/file/UploadStatus.js +2 -0
- package/dist/esm/file/UploadStatus.js.map +1 -0
- package/dist/esm/file/UploadTarget.d.ts +8 -0
- package/dist/esm/file/UploadTarget.d.ts.map +1 -0
- package/dist/esm/file/UploadTarget.js +2 -0
- package/dist/esm/file/UploadTarget.js.map +1 -0
- package/dist/esm/file/index.d.ts +7 -0
- package/dist/esm/file/index.d.ts.map +1 -0
- package/dist/esm/file/index.js +7 -0
- package/dist/esm/file/index.js.map +1 -0
- package/dist/esm/file/postFiles.d.ts +2 -0
- package/dist/esm/file/postFiles.d.ts.map +1 -0
- package/dist/esm/file/postFiles.js +29 -0
- package/dist/esm/file/postFiles.js.map +1 -0
- package/dist/esm/file/resolveUploadTarget.d.ts +3 -0
- package/dist/esm/file/resolveUploadTarget.d.ts.map +1 -0
- package/dist/esm/file/resolveUploadTarget.js +66 -0
- package/dist/esm/file/resolveUploadTarget.js.map +1 -0
- package/dist/esm/file/useUploadSession.d.ts +10 -0
- package/dist/esm/file/useUploadSession.d.ts.map +1 -0
- package/dist/esm/file/useUploadSession.js +60 -0
- package/dist/esm/file/useUploadSession.js.map +1 -0
- package/dist/esm/form/FormGallery.stories.d.ts.map +1 -1
- package/dist/esm/form/FormGallery.stories.js +9 -0
- package/dist/esm/form/FormGallery.stories.js.map +1 -1
- package/dist/esm/form/MultiStateGlyph.d.ts +8 -0
- package/dist/esm/form/MultiStateGlyph.d.ts.map +1 -0
- package/dist/esm/form/MultiStateGlyph.js +57 -0
- package/dist/esm/form/MultiStateGlyph.js.map +1 -0
- package/dist/esm/form/MultiStateOption.d.ts +7 -0
- package/dist/esm/form/MultiStateOption.d.ts.map +1 -0
- package/dist/esm/form/MultiStateOption.js +2 -0
- package/dist/esm/form/MultiStateOption.js.map +1 -0
- package/dist/esm/form/PrimeMultiStateCheckbox.d.ts +3 -0
- package/dist/esm/form/PrimeMultiStateCheckbox.d.ts.map +1 -0
- package/dist/esm/form/PrimeMultiStateCheckbox.js +121 -0
- package/dist/esm/form/PrimeMultiStateCheckbox.js.map +1 -0
- package/dist/esm/form/index.d.ts +1 -0
- package/dist/esm/form/index.d.ts.map +1 -1
- package/dist/esm/form/index.js +1 -0
- package/dist/esm/form/index.js.map +1 -1
- package/dist/esm/form/multiStateOptions.d.ts +4 -0
- package/dist/esm/form/multiStateOptions.d.ts.map +1 -0
- package/dist/esm/form/multiStateOptions.js +75 -0
- package/dist/esm/form/multiStateOptions.js.map +1 -0
- package/dist/esm/form/multiStateStates.d.ts +4 -0
- package/dist/esm/form/multiStateStates.d.ts.map +1 -0
- package/dist/esm/form/multiStateStates.js +30 -0
- package/dist/esm/form/multiStateStates.js.map +1 -0
- package/dist/esm/form/useMultiStateSelection.d.ts +6 -0
- package/dist/esm/form/useMultiStateSelection.d.ts.map +1 -0
- package/dist/esm/form/useMultiStateSelection.js +49 -0
- package/dist/esm/form/useMultiStateSelection.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +22 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/legacyEnumerationChoices.d.ts +3 -0
- package/dist/esm/legacyEnumerationChoices.d.ts.map +1 -0
- package/dist/esm/legacyEnumerationChoices.js +37 -0
- package/dist/esm/legacyEnumerationChoices.js.map +1 -0
- package/dist/esm/loadQuill/index.d.ts +3 -0
- package/dist/esm/loadQuill/index.d.ts.map +1 -0
- package/dist/esm/loadQuill/index.js +20 -0
- package/dist/esm/loadQuill/index.js.map +1 -0
- package/dist/esm/primeReactComponents.d.ts.map +1 -1
- package/dist/esm/primeReactComponents.js +15 -0
- package/dist/esm/primeReactComponents.js.map +1 -1
- package/dist/esm/primeReactDescriptors.d.ts +3 -0
- package/dist/esm/primeReactDescriptors.d.ts.map +1 -0
- package/dist/esm/primeReactDescriptors.js +398 -0
- package/dist/esm/primeReactDescriptors.js.map +1 -0
- package/dist/esm/primeReactPackage.d.ts.map +1 -1
- package/dist/esm/primeReactPackage.js +8 -0
- package/dist/esm/primeReactPackage.js.map +1 -1
- package/dist/esm/properties.d.ts +1 -0
- package/dist/esm/properties.d.ts.map +1 -1
- package/dist/esm/properties.js +11 -1
- package/dist/esm/properties.js.map +1 -1
- package/dist/esm/resolveEnumeration.d.ts +3 -0
- package/dist/esm/resolveEnumeration.d.ts.map +1 -0
- package/dist/esm/resolveEnumeration.js +53 -0
- package/dist/esm/resolveEnumeration.js.map +1 -0
- package/dist/esm/structurallyEqual.d.ts +2 -0
- package/dist/esm/structurallyEqual.d.ts.map +1 -0
- package/dist/esm/structurallyEqual.js +25 -0
- package/dist/esm/structurallyEqual.js.map +1 -0
- package/dist/esm/treeNodes.d.ts +2 -1
- package/dist/esm/treeNodes.d.ts.map +1 -1
- package/dist/esm/treeNodes.js +42 -8
- package/dist/esm/treeNodes.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/useResettingState.d.ts +3 -0
- package/dist/esm/useResettingState.d.ts.map +1 -0
- package/dist/esm/useResettingState.js +45 -0
- package/dist/esm/useResettingState.js.map +1 -0
- package/dist/esm/useStructuralValue.d.ts +2 -0
- package/dist/esm/useStructuralValue.d.ts.map +1 -0
- package/dist/esm/useStructuralValue.js +18 -0
- package/dist/esm/useStructuralValue.js.map +1 -0
- package/editor/PrimeEditor.tsx +83 -0
- package/editor/QuillConstructor.ts +8 -0
- package/editor/QuillEditorOptions.ts +29 -0
- package/editor/QuillEditorState.ts +14 -0
- package/editor/QuillInstance.ts +27 -0
- package/editor/QuillLoader.ts +13 -0
- package/editor/QuillLoaderContext.ts +8 -0
- package/editor/QuillLoaderProvider.tsx +24 -0
- package/editor/QuillOptions.ts +10 -0
- package/editor/SafeElement.ts +15 -0
- package/editor/SafeNode.ts +7 -0
- package/editor/applyHtml.ts +21 -0
- package/editor/characterCount.ts +9 -0
- package/editor/htmlToPlainText.ts +74 -0
- package/editor/index.ts +16 -0
- package/editor/renderSafeNodes.tsx +26 -0
- package/editor/safeUrls.ts +43 -0
- package/editor/sanitizeHtml.ts +94 -0
- package/editor/serializeSafeNodes.ts +26 -0
- package/editor/toolbarLayout.ts +10 -0
- package/editor/useQuillEditor.ts +114 -0
- package/file/FileGallery.stories.tsx +32 -0
- package/file/FileUploadContext.ts +17 -0
- package/file/FileUploadHandler.ts +15 -0
- package/file/FileUploadHandlerProvider.tsx +33 -0
- package/file/FileUploadMode.ts +9 -0
- package/file/PrimeFileUpload.tsx +129 -0
- package/file/UploadStatus.ts +9 -0
- package/file/UploadTarget.ts +12 -0
- package/file/index.ts +9 -0
- package/file/postFiles.ts +23 -0
- package/file/resolveUploadTarget.ts +61 -0
- package/file/useUploadSession.ts +67 -0
- package/form/FormGallery.stories.tsx +9 -0
- package/form/MultiStateGlyph.tsx +55 -0
- package/form/MultiStateOption.ts +17 -0
- package/form/PrimeMultiStateCheckbox.tsx +101 -0
- package/form/index.ts +1 -0
- package/form/multiStateOptions.ts +78 -0
- package/form/multiStateStates.ts +23 -0
- package/form/useMultiStateSelection.ts +48 -0
- package/index.ts +4 -0
- package/legacyEnumerationChoices.ts +35 -0
- package/loadQuill/index.ts +21 -0
- package/package.json +27 -7
- package/primeReactComponents.ts +12 -0
- package/primeReactDescriptors.ts +111 -0
- package/primeReactPackage.ts +5 -3
- package/primeReactTheme.css +69 -0
- package/properties.ts +14 -0
- package/resolveEnumeration.ts +50 -0
- package/structurallyEqual.ts +29 -0
- package/treeNodes.ts +44 -6
- package/useResettingState.ts +34 -0
- package/useStructuralValue.ts +17 -0
package/.storybook/preview.tsx
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import type { Decorator, Preview } from '@storybook/react';
|
|
5
5
|
import { PrimeReactProvider } from '@primereact/core';
|
|
6
|
+
import { QuillLoaderProvider } from '../editor';
|
|
7
|
+
import { loadQuill } from '../loadQuill';
|
|
6
8
|
import { primeReactTheme, usePrimeReactTheme } from '../theme';
|
|
7
9
|
import '../primeReactTheme.css';
|
|
8
10
|
import './preview.css';
|
|
@@ -12,6 +14,9 @@ import './preview.css';
|
|
|
12
14
|
// resolve to. Only the icon font is still a stylesheet.
|
|
13
15
|
import 'primeicons/primeicons.css';
|
|
14
16
|
|
|
17
|
+
// A host that wants editable rich text installs Quill and its stylesheet, and provides the loader.
|
|
18
|
+
import 'quill/dist/quill.snow.css';
|
|
19
|
+
|
|
15
20
|
/**
|
|
16
21
|
* Puts every story inside a `PrimeReactProvider` carrying a real Scene theme.
|
|
17
22
|
*
|
|
@@ -29,7 +34,9 @@ const withTheme: Decorator = (Story) => {
|
|
|
29
34
|
|
|
30
35
|
return (
|
|
31
36
|
<PrimeReactProvider value={configuration}>
|
|
32
|
-
<
|
|
37
|
+
<QuillLoaderProvider loader={loadQuill}>
|
|
38
|
+
<Story />
|
|
39
|
+
</QuillLoaderProvider>
|
|
33
40
|
</PrimeReactProvider>
|
|
34
41
|
);
|
|
35
42
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
/** The outcome of resolving an authored enumeration value: the member, or the reason none could be chosen. */
|
|
5
|
+
export type EnumerationResolution<TMember extends string> =
|
|
6
|
+
| { isValid: true; value: TMember }
|
|
7
|
+
| { isValid: false; value: unknown; message: string };
|
package/README.md
CHANGED
|
@@ -109,15 +109,47 @@ twenty-fifth theme cannot be added without it. The full attribution table is in
|
|
|
109
109
|
components - through the semantic token layer `SceneThemeProvider` applies to the whole subtree, though
|
|
110
110
|
not through the `--p-*` properties, which only PrimeReact's own components read.
|
|
111
111
|
|
|
112
|
-
##
|
|
112
|
+
## Optional peers
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
### Chart.js peer dependency
|
|
115
|
+
|
|
116
|
+
PrimeReact 11 removed its former Chart.js wrapper, so the Scene `chart` adapter mounts a Chart.js canvas
|
|
117
|
+
itself. `chart.js@^4.5.1` is an optional peer dependency of `@cratis/scene.primereact`, optional only in that
|
|
118
|
+
a host that never renders a chart can omit it. **A host that renders charts must install `chart.js`**,
|
|
119
|
+
including when a bundler resolves imports statically: without it the build can fail to resolve
|
|
120
|
+
`chart.js/auto`, or the chart reports that it could not be drawn.
|
|
121
|
+
|
|
122
|
+
The adapter only imports Chart.js after its canvas mounts, which keeps SSR safe. It rebuilds the chart when
|
|
123
|
+
the type, data or options change in content, not when a document edit hands it equal data in a new object.
|
|
124
|
+
|
|
125
|
+
`chart` accepts canonical string types (`bar`, `line`, `pie`, `doughnut`, `polarArea`, `radar`, `bubble`,
|
|
126
|
+
`scatter`), the numeric values `0` to `7` of the old .NET enum, and that enum's Pascal case names, without
|
|
127
|
+
rewriting the stored element. Any other type is reported instead of drawn as a bar chart. A chart without data
|
|
128
|
+
points shows its `emptyLabel`.
|
|
129
|
+
|
|
130
|
+
### Quill peer dependency
|
|
131
|
+
|
|
132
|
+
`quill` is not imported by the package root, so a host that renders no rich text needs neither `quill` nor its
|
|
133
|
+
stylesheet to build. A host that wants editable rich text installs `quill@^2.0.3` and opts in explicitly:
|
|
134
|
+
|
|
135
|
+
```tsx
|
|
136
|
+
import 'quill/dist/quill.snow.css';
|
|
137
|
+
import { QuillLoaderProvider } from '@cratis/scene.primereact';
|
|
138
|
+
import { loadQuill } from '@cratis/scene.primereact/quill';
|
|
139
|
+
|
|
140
|
+
<QuillLoaderProvider loader={loadQuill}>{screen}</QuillLoaderProvider>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`@cratis/scene.primereact/quill` (sources in `loadQuill/`) is the only module that names `quill`. Without a
|
|
144
|
+
loader the editor shows its content read-only and says so. Authored HTML always passes an allowlist first; see
|
|
145
|
+
the [component reference](../../../Documentation/primereact-package/component-reference.md#rich-text-and-quill).
|
|
146
|
+
|
|
147
|
+
## Browser specifications
|
|
118
148
|
|
|
119
|
-
|
|
120
|
-
|
|
149
|
+
Most specifications run under jsdom with `yarn test`. Painted pixels, keyboard behavior and computed theme
|
|
150
|
+
styles need a real browser, so `yarn test:browser` bundles the controls and drives headless Chromium through
|
|
151
|
+
`playwright-core`. Install the browser once with `yarn playwright-core install chromium`. These specifications
|
|
152
|
+
are not part of `yarn test` and fail, rather than skip, when Chromium is missing.
|
|
121
153
|
|
|
122
154
|
Also worth knowing: `column` renders nothing on its own, and since PrimeReact 11 that is *our* semantics
|
|
123
155
|
rather than PrimeReact's. v11 removed `primereact/column`, so `data/Column.tsx` is a Cratis-owned
|
|
@@ -140,9 +172,9 @@ The short version for a contributor:
|
|
|
140
172
|
compiles cleanly and silently swaps an overlay for a static shell.
|
|
141
173
|
- **v11 ships zero CSS.** There is no `primereact/resources` directory. A look comes from a preset handed
|
|
142
174
|
to `PrimeReactProvider`; `usePrimeReactTheme` returns that configuration for a Scene theme.
|
|
143
|
-
- **
|
|
144
|
-
2 are expressed over `@primereact/headless` hooks, and
|
|
145
|
-
(`cascadeSelect`, `inputMask`, `
|
|
175
|
+
- **16 abstract names are now backed by Cratis-owned components** built here because v11 removed theirs,
|
|
176
|
+
2 are expressed over `@primereact/headless` hooks, and 3 were dropped from the manifest
|
|
177
|
+
(`cascadeSelect`, `inputMask`, `virtualScroller`).
|
|
146
178
|
- **`MenuItem` and `TreeNode` are Scene's types now** - `primereact/menuitem` and `primereact/treenode`
|
|
147
179
|
were removed. Import them from this package, never from `primereact/*`.
|
|
148
180
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import { SceneElementView } from '@cratis/scene.react';
|
|
6
|
+
import { primeReactComponents } from '../primeReactComponents';
|
|
7
|
+
import { sceneComponent } from '../storyElements';
|
|
8
|
+
|
|
9
|
+
const meta = {
|
|
10
|
+
title: 'PrimeReact/Chart',
|
|
11
|
+
component: SceneElementView,
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
} satisfies Meta<typeof SceneElementView>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
|
|
17
|
+
type Story = StoryObj<typeof meta>;
|
|
18
|
+
|
|
19
|
+
/** A Chart.js chart rendered through the Scene element and package registry. */
|
|
20
|
+
const salesData = {
|
|
21
|
+
labels: ['January', 'February', 'March'],
|
|
22
|
+
datasets: [{ label: 'Sales', data: [12, 19, 8], backgroundColor: '#6366f1' }],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Bar: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
element: sceneComponent('sales', 'chart', {
|
|
28
|
+
type: 'bar', data: salesData, options: { maintainAspectRatio: false }, style: { height: 240 }, ariaLabel: 'Monthly sales',
|
|
29
|
+
}),
|
|
30
|
+
registry: primeReactComponents,
|
|
31
|
+
resolveBinding: () => undefined,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** A migrated chart that has no data yet. It says so instead of drawing a blank canvas or inventing values. */
|
|
36
|
+
export const MigratedWithoutData: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
element: sceneComponent('legacy-empty', 'chart', { type: 0, style: { height: 72 }, ariaLabel: 'Migrated chart without data', legacyType: 'PrimeReact.Chart' }),
|
|
39
|
+
registry: primeReactComponents,
|
|
40
|
+
resolveBinding: () => undefined,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** A chart type the renderer does not know is reported rather than drawn as a bar chart. */
|
|
45
|
+
export const UnsupportedType: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
element: sceneComponent('unsupported', 'chart', { type: 8, data: salesData }),
|
|
48
|
+
registry: primeReactComponents,
|
|
49
|
+
resolveBinding: () => undefined,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** A migrated element that retains the original numeric ChartType enum value in its own properties. */
|
|
54
|
+
export const MigratedLegacyBar: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
element: sceneComponent('legacy-sales', 'chart', {
|
|
57
|
+
type: 0, data: salesData, options: { maintainAspectRatio: false }, style: { height: 240 }, ariaLabel: 'Migrated monthly sales',
|
|
58
|
+
legacyType: 'PrimeReact.Chart', legacyExtras: { canvas: { x: 256, y: 184 } },
|
|
59
|
+
}),
|
|
60
|
+
registry: primeReactComponents,
|
|
61
|
+
resolveBinding: () => undefined,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
/** The canonical names of the Chart.js chart types Scene's `chart` component supports. */
|
|
5
|
+
export enum ChartType {
|
|
6
|
+
Bar = 'bar',
|
|
7
|
+
Line = 'line',
|
|
8
|
+
Pie = 'pie',
|
|
9
|
+
Doughnut = 'doughnut',
|
|
10
|
+
PolarArea = 'polarArea',
|
|
11
|
+
Radar = 'radar',
|
|
12
|
+
Bubble = 'bubble',
|
|
13
|
+
Scatter = 'scatter',
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { ChartType } from './ChartType';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What an authored chart `type` resolved to: a Chart.js type, or the reason it names none.
|
|
8
|
+
*
|
|
9
|
+
* A value that is not a known type is never replaced by a default. Drawing a bar chart for a document that
|
|
10
|
+
* asked for something else hides a data problem behind a plausible picture.
|
|
11
|
+
*/
|
|
12
|
+
export type ChartTypeResolution =
|
|
13
|
+
| { isValid: true; type: ChartType }
|
|
14
|
+
| { isValid: false; value: unknown; message: string };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { CSSProperties, useMemo, useRef } from 'react';
|
|
5
|
+
import type { ChartConfiguration, ChartData, ChartOptions } from 'chart.js';
|
|
6
|
+
import { RegisteredComponentProps } from '@cratis/scene.react';
|
|
7
|
+
import { booleanProperty, recordProperty, stringProperty } from '../properties';
|
|
8
|
+
import { useStructuralValue } from '../useStructuralValue';
|
|
9
|
+
import { chartHasData } from './chartHasData';
|
|
10
|
+
import { resolveChartType } from './resolveChartType';
|
|
11
|
+
import { useChart } from './useChart';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The `PrimeReact:chart` component, rendered by Chart.js because PrimeReact 11 no longer ships its
|
|
15
|
+
* former Chart.js wrapper.
|
|
16
|
+
*
|
|
17
|
+
* Three states are explicit rather than a blank canvas: an unsupported `type` is reported (the right chart
|
|
18
|
+
* cannot be guessed), a chart with no data points shows its `emptyLabel` (data is never invented), and a
|
|
19
|
+
* chart Chart.js could not draw says why. Only a chart with data and a supported type reaches Chart.js.
|
|
20
|
+
*
|
|
21
|
+
* Chart.js is an optional peer dependency of this package: a host that renders charts must install
|
|
22
|
+
* `chart.js` itself. The chart rebuilds only when its resolved type, data or options change in content -
|
|
23
|
+
* every edit to a Scene document clones the whole document, and a clone with equal content is not a change.
|
|
24
|
+
*
|
|
25
|
+
* The chart fills the authored size: `maintainAspectRatio` defaults to `false` here (Chart.js defaults to
|
|
26
|
+
* `true`, which shrinks the chart inside its box) and an authored `options.maintainAspectRatio` wins. The
|
|
27
|
+
* `responsive` property is authoritative over `options.responsive` when both are set.
|
|
28
|
+
*/
|
|
29
|
+
export function PrimeChart({ element, interactions }: RegisteredComponentProps) {
|
|
30
|
+
const canvas = useRef<HTMLCanvasElement>(null);
|
|
31
|
+
const resolution = resolveChartType(element);
|
|
32
|
+
const data = useStructuralValue(recordProperty(element, 'data') as ChartData | undefined);
|
|
33
|
+
const options = useStructuralValue(recordProperty(element, 'options') as ChartOptions | undefined);
|
|
34
|
+
const style = recordProperty(element, 'style') as CSSProperties | undefined;
|
|
35
|
+
const responsive = booleanProperty(element, 'responsive', options?.responsive ?? true);
|
|
36
|
+
const ariaLabel = stringProperty(element, 'ariaLabel', element.name || 'Chart');
|
|
37
|
+
const emptyLabel = stringProperty(element, 'emptyLabel', 'No chart data');
|
|
38
|
+
const hasData = chartHasData(data);
|
|
39
|
+
const type = resolution.isValid ? resolution.type : undefined;
|
|
40
|
+
const enabled = type !== undefined && hasData;
|
|
41
|
+
|
|
42
|
+
const configuration = useMemo(() => ({
|
|
43
|
+
type,
|
|
44
|
+
data: data ?? { datasets: [] },
|
|
45
|
+
options: { maintainAspectRatio: false, ...options, responsive },
|
|
46
|
+
}) as unknown as ChartConfiguration, [type, data, options, responsive]);
|
|
47
|
+
|
|
48
|
+
const failure = useChart(canvas, configuration, enabled);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
data-scene-id={element.id}
|
|
53
|
+
data-scene-component='chart'
|
|
54
|
+
style={{ position: 'relative', width: element.size.width ?? '100%', height: element.size.height ?? '100%', ...style }}
|
|
55
|
+
{...interactions}>
|
|
56
|
+
{!resolution.isValid && <div role='alert' data-scene-state='unsupported-type'>{resolution.message}</div>}
|
|
57
|
+
{resolution.isValid && !hasData && <div role='status' data-scene-state='empty'>{emptyLabel}</div>}
|
|
58
|
+
{failure !== undefined && <div role='alert' data-scene-state='unavailable'>{`The chart could not be drawn: ${failure}`}</div>}
|
|
59
|
+
{enabled && <canvas ref={canvas} role='img' aria-label={ariaLabel} hidden={failure !== undefined} />}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Whether chart data holds at least one data point to draw.
|
|
6
|
+
*
|
|
7
|
+
* Datasets whose `data` is empty (or absent) draw nothing but axes, so the chart reports it instead.
|
|
8
|
+
* A dataset may also give its points as keyed records (Chart.js `parsing` over an object), which counts
|
|
9
|
+
* when it has any keys.
|
|
10
|
+
*/
|
|
11
|
+
export function chartHasData(data: unknown): boolean {
|
|
12
|
+
if (data === null || typeof data !== 'object') return false;
|
|
13
|
+
const datasets = (data as Record<string, unknown>).datasets;
|
|
14
|
+
if (!Array.isArray(datasets)) return false;
|
|
15
|
+
|
|
16
|
+
return datasets.some(dataset => {
|
|
17
|
+
if (dataset === null || typeof dataset !== 'object') return false;
|
|
18
|
+
const points = (dataset as Record<string, unknown>).data;
|
|
19
|
+
if (Array.isArray(points)) return points.length > 0;
|
|
20
|
+
return points !== null && typeof points === 'object' && Object.keys(points).length > 0;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { PropertyChoice } from '@cratis/scene.model';
|
|
5
|
+
import { ChartType } from './ChartType';
|
|
6
|
+
import { legacyChartTypes } from './resolveChartType';
|
|
7
|
+
|
|
8
|
+
const chartTypeLabels: Record<ChartType, string> = {
|
|
9
|
+
[ChartType.Bar]: 'Bar',
|
|
10
|
+
[ChartType.Line]: 'Line',
|
|
11
|
+
[ChartType.Pie]: 'Pie',
|
|
12
|
+
[ChartType.Doughnut]: 'Doughnut',
|
|
13
|
+
[ChartType.PolarArea]: 'Polar area',
|
|
14
|
+
[ChartType.Radar]: 'Radar',
|
|
15
|
+
[ChartType.Bubble]: 'Bubble',
|
|
16
|
+
[ChartType.Scatter]: 'Scatter',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The chart type choices: the stable names new documents use, then the ordinals migrated documents carry,
|
|
21
|
+
* then the Pascal case member names of the original .NET enum that a serialized enum produces.
|
|
22
|
+
* A migrated chart stores its original `type`; offering every form the renderer accepts keeps that stored
|
|
23
|
+
* value valid (and its type visible and re-selectable) without rewriting it to another form behind the
|
|
24
|
+
* author's back. The choices are the same set `resolveChartType` accepts, so what the renderer draws is
|
|
25
|
+
* exactly what the descriptor allows.
|
|
26
|
+
*/
|
|
27
|
+
export const chartTypeChoices: PropertyChoice[] = [
|
|
28
|
+
...Object.values(ChartType).map(type => ({ value: type, label: chartTypeLabels[type] })),
|
|
29
|
+
...legacyChartTypes.map((type, ordinal) => ({ value: ordinal, label: `${chartTypeLabels[type]} (legacy ${ordinal})`, description: `The ordinal ${ordinal} of the original chart type enum, as stored by migrated documents.` })),
|
|
30
|
+
...(Object.keys(ChartType) as (keyof typeof ChartType)[]).map(name => ({ value: name, label: `${chartTypeLabels[ChartType[name]]} (legacy name ${name})`, description: `The member name ${name} of the original chart type enum, as a serialized enum stores it.` })),
|
|
31
|
+
];
|
|
32
|
+
|
package/chart/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
export * from './ChartType';
|
|
5
|
+
export * from './ChartTypeResolution';
|
|
6
|
+
export * from './PrimeChart';
|
|
7
|
+
export * from './resolveChartType';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { SceneElement } from '@cratis/scene.model';
|
|
5
|
+
import { ChartType } from './ChartType';
|
|
6
|
+
import { ChartTypeResolution } from './ChartTypeResolution';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The ordinals of the original .NET `PrimeReact.Charts.ChartType` enum, in declaration order
|
|
10
|
+
* (`Studio/Source/PrimeReact/Charts/Chart.cs`). Migrated documents keep the ordinal, so the position of
|
|
11
|
+
* each entry here is part of the stored-data contract and must never be reordered.
|
|
12
|
+
*/
|
|
13
|
+
export const legacyChartTypes: readonly ChartType[] = [
|
|
14
|
+
ChartType.Bar,
|
|
15
|
+
ChartType.Line,
|
|
16
|
+
ChartType.Pie,
|
|
17
|
+
ChartType.Doughnut,
|
|
18
|
+
ChartType.PolarArea,
|
|
19
|
+
ChartType.Radar,
|
|
20
|
+
ChartType.Bubble,
|
|
21
|
+
ChartType.Scatter,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Resolves an authored chart type to the Chart.js vocabulary.
|
|
26
|
+
*
|
|
27
|
+
* Three forms are accepted, and the stored value is never rewritten:
|
|
28
|
+
* - a canonical Chart.js name from {@link ChartType} (`'polarArea'`), which new documents use;
|
|
29
|
+
* - the ordinal of the original .NET enum (`4`), which migrated documents carry;
|
|
30
|
+
* - the .NET member name in its original Pascal case (`'PolarArea'`), which a JSON serialization of that
|
|
31
|
+
* enum produces.
|
|
32
|
+
*
|
|
33
|
+
* Anything else - an unknown or fractional ordinal, a numeric string, a differently cased name, `null` -
|
|
34
|
+
* resolves to a finding with a message, because the right chart cannot be known. An absent `type` is the
|
|
35
|
+
* one default: the original control defaulted to `Bar`.
|
|
36
|
+
*/
|
|
37
|
+
export function resolveChartType(element: SceneElement): ChartTypeResolution {
|
|
38
|
+
const value = element.properties.type;
|
|
39
|
+
if (value === undefined) return { isValid: true, type: ChartType.Bar };
|
|
40
|
+
|
|
41
|
+
if (typeof value === 'number') {
|
|
42
|
+
const type = Number.isInteger(value) ? legacyChartTypes[value] : undefined;
|
|
43
|
+
return type === undefined ? unsupported(value) : { isValid: true, type };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (typeof value === 'string') {
|
|
47
|
+
if (Object.values(ChartType).includes(value as ChartType)) return { isValid: true, type: value as ChartType };
|
|
48
|
+
if (Object.hasOwn(ChartType, value)) return { isValid: true, type: ChartType[value as keyof typeof ChartType] };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return unsupported(value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function unsupported(value: unknown): ChartTypeResolution {
|
|
55
|
+
const shown = typeof value === 'string' ? `'${value}'` : JSON.stringify(value) ?? String(value);
|
|
56
|
+
return {
|
|
57
|
+
isValid: false,
|
|
58
|
+
value,
|
|
59
|
+
message: `Unsupported chart type ${shown}. Use one of ${Object.values(ChartType).join(', ')}, or a legacy ordinal from 0 to ${legacyChartTypes.length - 1}.`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { RefObject, useEffect, useState } from 'react';
|
|
5
|
+
import type { ChartConfiguration } from 'chart.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Draws a Chart.js chart on a canvas and owns its lifetime.
|
|
9
|
+
*
|
|
10
|
+
* Chart.js loads only after the canvas has mounted, which keeps server rendering independent of browser
|
|
11
|
+
* globals. The chart is destroyed before it is rebuilt and when the component unmounts - Chart.js owns
|
|
12
|
+
* listeners and resize observers, so a retained instance would draw twice and leak them.
|
|
13
|
+
*
|
|
14
|
+
* A chart that cannot be drawn is reported rather than left as a blank canvas: `chart.js` not being
|
|
15
|
+
* installed (it is an optional peer dependency), a failed dynamic import and a rejected configuration all
|
|
16
|
+
* come back as the returned failure message. A rejected configuration is released from the canvas as well,
|
|
17
|
+
* so correcting it draws again on the same canvas.
|
|
18
|
+
*
|
|
19
|
+
* @param canvas The canvas to draw on. It must be rendered whenever `enabled` is true.
|
|
20
|
+
* @param configuration The Chart.js configuration. Pass a structurally stable value (see
|
|
21
|
+
* {@link useStructuralValue}); a new identity rebuilds the chart.
|
|
22
|
+
* @param enabled Whether there is something to draw.
|
|
23
|
+
* @returns The reason the chart could not be drawn, or `undefined`.
|
|
24
|
+
*/
|
|
25
|
+
export function useChart(canvas: RefObject<HTMLCanvasElement | null>, configuration: ChartConfiguration, enabled: boolean): string | undefined {
|
|
26
|
+
const [failure, setFailure] = useState<string | undefined>(undefined);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setFailure(undefined);
|
|
30
|
+
const target = canvas.current;
|
|
31
|
+
if (!enabled || target === null) return undefined;
|
|
32
|
+
|
|
33
|
+
let disposed = false;
|
|
34
|
+
let instance: { destroy(): void } | undefined;
|
|
35
|
+
|
|
36
|
+
const create = async () => {
|
|
37
|
+
let chartType: typeof import('chart.js/auto').default | undefined;
|
|
38
|
+
try {
|
|
39
|
+
chartType = (await import('chart.js/auto')).default;
|
|
40
|
+
if (disposed) return;
|
|
41
|
+
instance = new chartType(target, structuredClone(configuration));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
// Chart.js registers a chart on its canvas before the constructor finishes, so a constructor
|
|
44
|
+
// that throws still leaves a registered instance behind - one `instance` never points at. Left
|
|
45
|
+
// alone it makes every later attempt fail with "Canvas is already in use" and hides the real
|
|
46
|
+
// reason, so release whatever is bound to this canvas before reporting.
|
|
47
|
+
chartType?.getChart(target)?.destroy();
|
|
48
|
+
if (!disposed) setFailure(error instanceof Error ? error.message : String(error));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
void create();
|
|
53
|
+
return () => {
|
|
54
|
+
disposed = true;
|
|
55
|
+
instance?.destroy();
|
|
56
|
+
instance = undefined;
|
|
57
|
+
};
|
|
58
|
+
}, [canvas, configuration, enabled]);
|
|
59
|
+
|
|
60
|
+
return failure;
|
|
61
|
+
}
|
|
@@ -37,7 +37,13 @@ export const Gallery: Story = {
|
|
|
37
37
|
),
|
|
38
38
|
sceneComponent('dataTable', 'dataTable', { rows: [{ id: 1, title: 'Inferred columns' }] }),
|
|
39
39
|
sceneComponent('dataView', 'dataView', { rows: [{ title: 'Kickoff', description: 'Agree the scope' }] }),
|
|
40
|
+
sceneComponent('dataScroller', 'dataScroller', { items: ['First', 'Second', 'Third'], rows: 2, inline: true, scrollHeight: 96 }),
|
|
40
41
|
sceneComponent('tree', 'tree', { nodes: [{ label: 'Documents', children: ['Work', 'Home'] }] }),
|
|
42
|
+
sceneComponent('treeTable', 'treeTable', {
|
|
43
|
+
columns: [{ field: 'name', header: 'Name' }, { field: 'type', header: 'Type' }],
|
|
44
|
+
items: [{ label: 'Documents', data: { name: 'Documents', type: 'Folder' }, children: [{ label: 'Plan', data: { name: 'Plan', type: 'File' } }] }],
|
|
45
|
+
selectionMode: 'checkbox', paginator: true, rows: 1,
|
|
46
|
+
}),
|
|
41
47
|
sceneComponent('timeline', 'timeline', {
|
|
42
48
|
events: [{ title: 'Ordered', description: 'Order placed', date: '09:00' }, { title: 'Shipped', description: 'Left the depot', date: '14:20' }],
|
|
43
49
|
}),
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { readableValue } from './readableValue';
|
|
5
|
+
|
|
6
|
+
/** The fields that, when present as text, name a record. */
|
|
7
|
+
const titleFields = ['label', 'title', 'name', 'text', 'header'];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* One authored data row, shown readably.
|
|
11
|
+
*
|
|
12
|
+
* A scalar is its text. A record is titled by its first text field among `label`, `title`, `name`, `text` and
|
|
13
|
+
* `header`, and every other field follows as a name and a readable value. No row is ever dumped as JSON.
|
|
14
|
+
*/
|
|
15
|
+
export function DataScrollerRow({ value }: { value: unknown }) {
|
|
16
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) return <>{readableValue(value)}</>;
|
|
17
|
+
|
|
18
|
+
const record = value as Record<string, unknown>;
|
|
19
|
+
const titleField = titleFields.find(field => typeof record[field] === 'string' && record[field] !== '');
|
|
20
|
+
const details = Object.entries(record)
|
|
21
|
+
.filter(([name]) => name !== titleField)
|
|
22
|
+
.map(([name, entry]) => [name, readableValue(entry)] as const)
|
|
23
|
+
.filter(([, text]) => text !== '');
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
{titleField !== undefined && <strong>{record[titleField] as string}</strong>}
|
|
28
|
+
{details.length > 0 && (
|
|
29
|
+
<dl>
|
|
30
|
+
{details.map(([name, text]) => <div key={name}><dt>{name}</dt><dd>{text}</dd></div>)}
|
|
31
|
+
</dl>
|
|
32
|
+
)}
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { ReactNode, useEffect, useMemo, useRef } from 'react';
|
|
5
|
+
import { RegisteredComponentProps } from '@cratis/scene.react';
|
|
6
|
+
import { arrayProperty, booleanProperty, numberProperty, stringProperty } from '../properties';
|
|
7
|
+
import { useStructuralValue } from '../useStructuralValue';
|
|
8
|
+
import { DataScrollerRow } from './DataScrollerRow';
|
|
9
|
+
import { isSerializedLegacyElement, legacyElementMessage } from './isSerializedLegacyElement';
|
|
10
|
+
import { useIncrementalLoad } from './useIncrementalLoad';
|
|
11
|
+
import { useLoadOnReach } from './useLoadOnReach';
|
|
12
|
+
|
|
13
|
+
/** How tall an inline scroller is when no `scrollHeight` was authored: without a height it would never overflow. */
|
|
14
|
+
const defaultScrollHeight = 320;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The `PrimeReact:dataScroller` component, a list that loads a chunk at a time as its end is reached.
|
|
18
|
+
*
|
|
19
|
+
* The entries are read as data: strings, numbers and records (see {@link DataScrollerRow}) from `items`, then
|
|
20
|
+
* any child elements authored in the `items` (or `content`) slot, which render as themselves. Serialized
|
|
21
|
+
* legacy UI elements in `items` are refused with a visible message, not shown as JSON.
|
|
22
|
+
*
|
|
23
|
+
* - `inline: true` scrolls inside the control, `scrollHeight` pixels tall (320 when omitted). `inline: false`
|
|
24
|
+
* loads as the page scrolls the end of the list into view.
|
|
25
|
+
* - The "Load more" button remains for keyboard and assistive technology; focus moves to the first entry it
|
|
26
|
+
* loads, and the number shown is announced.
|
|
27
|
+
* - A disabled element loads nothing on scroll and its button is disabled.
|
|
28
|
+
* - The loaded count restarts when `rows` or the content of `items` changes.
|
|
29
|
+
*/
|
|
30
|
+
export function PrimeDataScroller({ element, slots, interactions }: RegisteredComponentProps) {
|
|
31
|
+
const authored = useStructuralValue(arrayProperty(element, 'items'));
|
|
32
|
+
const data = useMemo(() => authored.filter(entry => !isSerializedLegacyElement(entry) && entry !== null && entry !== undefined), [authored]);
|
|
33
|
+
const refusal = legacyElementMessage(authored, 'items', "Author them as child elements in the 'items' slot, or as data.");
|
|
34
|
+
const slotted = slots.items ?? slots.content ?? [];
|
|
35
|
+
const rows = useMemo<ReactNode[]>(() => [...data.map((value, index) => <DataScrollerRow key={index} value={value} />), ...slotted], [data, slotted]);
|
|
36
|
+
const chunk = Math.max(Math.floor(numberProperty(element, 'rows', 10)), 1);
|
|
37
|
+
const inline = booleanProperty(element, 'inline', false);
|
|
38
|
+
const scrollHeight = numberProperty(element, 'scrollHeight', defaultScrollHeight);
|
|
39
|
+
const enabled = element.isEnabled;
|
|
40
|
+
const { loaded, loadMore } = useIncrementalLoad(rows.length, chunk, data);
|
|
41
|
+
const canLoad = loaded < rows.length;
|
|
42
|
+
const scroller = useRef<HTMLDivElement>(null);
|
|
43
|
+
const sentinel = useRef<HTMLDivElement>(null);
|
|
44
|
+
const entries = useRef<(HTMLLIElement | null)[]>([]);
|
|
45
|
+
const focusIndex = useRef<number | undefined>(undefined);
|
|
46
|
+
|
|
47
|
+
useLoadOnReach(sentinel, inline ? scroller : null, enabled && canLoad, loaded, loadMore);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (focusIndex.current === undefined) return;
|
|
51
|
+
entries.current[focusIndex.current]?.focus();
|
|
52
|
+
focusIndex.current = undefined;
|
|
53
|
+
}, [loaded]);
|
|
54
|
+
|
|
55
|
+
const loadByButton = () => {
|
|
56
|
+
focusIndex.current = loaded;
|
|
57
|
+
loadMore();
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
data-scene-id={element.id}
|
|
63
|
+
data-scene-component='dataScroller'
|
|
64
|
+
aria-disabled={!enabled}
|
|
65
|
+
onClick={interactions?.onClick}
|
|
66
|
+
onDoubleClick={interactions?.onDoubleClick}>
|
|
67
|
+
<div
|
|
68
|
+
ref={scroller}
|
|
69
|
+
role='region'
|
|
70
|
+
tabIndex={inline ? 0 : undefined}
|
|
71
|
+
aria-label={stringProperty(element, 'ariaLabel', 'Scrollable data')}
|
|
72
|
+
style={inline ? { maxHeight: `${scrollHeight}px`, overflowY: 'auto' } : undefined}>
|
|
73
|
+
<ol>
|
|
74
|
+
{rows.slice(0, loaded).map((row, index) => <li key={index} tabIndex={-1} ref={node => { entries.current[index] = node; }}>{row}</li>)}
|
|
75
|
+
</ol>
|
|
76
|
+
{canLoad && <div ref={sentinel} aria-hidden='true' />}
|
|
77
|
+
</div>
|
|
78
|
+
{rows.length === 0 && <p role='status'>{stringProperty(element, 'emptyLabel', 'No items to show')}</p>}
|
|
79
|
+
{refusal !== undefined && <p role='alert' data-scene-state='legacy-elements'>{refusal}</p>}
|
|
80
|
+
{canLoad && <button type='button' disabled={!enabled} onClick={loadByButton}>Load more</button>}
|
|
81
|
+
{rows.length > 0 && <output aria-live='polite'>{`Showing ${loaded} of ${rows.length} items`}</output>}
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|