@yewdiel21/motion-kit 0.10.0 → 0.15.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/README.md +81 -0
- package/bin/motion-kit.mjs +3 -3
- package/dist/auto/index.d.ts +56 -3
- package/dist/auto/index.js +107 -3
- package/dist/auto/index.js.map +1 -1
- package/dist/{chunk-XAKC2QY7.js → chunk-6IRJYXJU.js} +3 -28
- package/dist/chunk-6IRJYXJU.js.map +1 -0
- package/dist/chunk-A6QQCF6V.js +21333 -0
- package/dist/chunk-A6QQCF6V.js.map +1 -0
- package/dist/chunk-JXRS3OEA.js +3638 -0
- package/dist/chunk-JXRS3OEA.js.map +1 -0
- package/dist/chunk-QP4QJOEN.js +72 -0
- package/dist/chunk-QP4QJOEN.js.map +1 -0
- package/dist/css/components/activity-feed.css +240 -0
- package/dist/css/components/add-to-cart.css +72 -0
- package/dist/css/components/attachment.css +266 -0
- package/dist/css/components/bidirectional-slider.css +168 -0
- package/dist/css/components/breadcrumb.css +110 -0
- package/dist/css/components/chart-tooltip.css +168 -0
- package/dist/css/components/chart.css +296 -0
- package/dist/css/components/code-block.css +264 -0
- package/dist/css/components/color-area.css +82 -0
- package/dist/css/components/color-field.css +67 -0
- package/dist/css/components/color-picker.css +131 -0
- package/dist/css/components/color-slider.css +113 -0
- package/dist/css/components/command-search.css +252 -0
- package/dist/css/components/context-menu.css +23 -0
- package/dist/css/components/credit-card.css +288 -0
- package/dist/css/components/data-table.css +686 -0
- package/dist/css/components/date-range-picker.css +168 -0
- package/dist/css/components/date-time-picker.css +178 -0
- package/dist/css/components/drawer.css +58 -0
- package/dist/css/components/editable-table.css +201 -0
- package/dist/css/components/empty-state.css +61 -0
- package/dist/css/components/file-explorer.css +633 -0
- package/dist/css/components/filter-builder.css +227 -0
- package/dist/css/components/heatmap-chart.css +391 -0
- package/dist/css/components/hold-confirm.css +87 -0
- package/dist/css/components/hover-card.css +19 -7
- package/dist/css/components/image-preview.css +283 -0
- package/dist/css/components/json-viewer.css +304 -0
- package/dist/css/components/like-button.css +78 -0
- package/dist/css/components/link-preview.css +275 -0
- package/dist/css/components/loading-button.css +77 -0
- package/dist/css/components/multi-select.css +267 -0
- package/dist/css/components/nav.css +102 -102
- package/dist/css/components/notification-bell.css +127 -0
- package/dist/css/components/orbit-menu.css +130 -0
- package/dist/css/components/pagination.css +10 -5
- package/dist/css/components/password-strength.css +183 -0
- package/dist/css/components/pie-chart.css +390 -0
- package/dist/css/components/pill-button.css +135 -0
- package/dist/css/components/popover.css +25 -0
- package/dist/css/components/progress.css +140 -0
- package/dist/css/components/questionnaire.css +217 -0
- package/dist/css/components/radar-chart.css +370 -0
- package/dist/css/components/radial-chart.css +398 -0
- package/dist/css/components/range-calendar.css +186 -0
- package/dist/css/components/range-slider.css +192 -0
- package/dist/css/components/resizable-panel.css +243 -0
- package/dist/css/components/rich-text-editor.css +284 -0
- package/dist/css/components/sankey-chart.css +358 -0
- package/dist/css/components/scratch-card.css +75 -0
- package/dist/css/components/scroll-island.css +111 -0
- package/dist/css/components/select.css +136 -0
- package/dist/css/components/skeleton.css +108 -0
- package/dist/css/components/split-view.css +19 -0
- package/dist/css/components/star-rating.css +80 -0
- package/dist/css/components/stat-card.css +164 -0
- package/dist/css/components/swipe-actions.css +105 -0
- package/dist/css/components/tag-input.css +244 -0
- package/dist/css/components/time-field.css +88 -0
- package/dist/css/components/timeline.css +219 -0
- package/dist/css/components/toolbar.css +122 -0
- package/dist/css/components/tooltip.css +79 -0
- package/dist/css/components/tree-view.css +289 -0
- package/dist/css/components/virtual-list.css +195 -0
- package/dist/css/components/voice-dots.css +70 -0
- package/dist/css/tokens.css +185 -181
- package/dist/elements/index.d.ts +849 -7
- package/dist/elements/index.js +1642 -8
- package/dist/elements/index.js.map +1 -1
- package/dist/{engine-GDGwQnJE.d.ts → engine-5zRIssTO.d.ts} +11 -1
- package/dist/engine-QECQnGz1.d.ts +33 -0
- package/dist/index.css +10890 -311
- package/dist/index.d.ts +89 -5
- package/dist/index.js +273 -9
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +686 -24
- package/dist/react/index.js +2345 -9
- package/dist/react/index.js.map +1 -1
- package/dist/{reduced-BmBzKH94.d.ts → reduced-6X_bns60.d.ts} +9 -2
- package/dist/reveal-BfyKKsw4.d.ts +2474 -0
- package/dist/store-CA2Qcun_.d.ts +453 -0
- package/package.json +9 -16
- package/registry.json +1096 -543
- package/src/auto/auto-init.ts +104 -0
- package/src/components/activity-feed/README.md +56 -0
- package/src/components/activity-feed/activity-feed.css +239 -0
- package/src/components/activity-feed/element.ts +36 -0
- package/src/components/activity-feed/engine.ts +351 -0
- package/src/components/activity-feed/react.tsx +32 -0
- package/src/components/add-to-cart/README.md +34 -0
- package/src/components/add-to-cart/add-to-cart.css +71 -0
- package/src/components/add-to-cart/element.ts +20 -0
- package/src/components/add-to-cart/engine.ts +206 -0
- package/src/components/add-to-cart/react.tsx +29 -0
- package/src/components/attachment/README.md +27 -0
- package/src/components/attachment/attachment.css +265 -0
- package/src/components/attachment/element.ts +50 -0
- package/src/components/attachment/engine.ts +469 -0
- package/src/components/attachment/react.tsx +65 -0
- package/src/components/bidirectional-slider/README.md +46 -0
- package/src/components/bidirectional-slider/bidirectional-slider.css +167 -0
- package/src/components/bidirectional-slider/element.ts +42 -0
- package/src/components/bidirectional-slider/engine.ts +289 -0
- package/src/components/bidirectional-slider/react.tsx +45 -0
- package/src/components/breadcrumb/README.md +38 -0
- package/src/components/breadcrumb/breadcrumb.css +109 -0
- package/src/components/breadcrumb/element.ts +27 -0
- package/src/components/breadcrumb/engine.ts +249 -0
- package/src/components/breadcrumb/react.tsx +30 -0
- package/src/components/chart/README.md +34 -0
- package/src/components/chart/chart.css +295 -0
- package/src/components/chart/element.ts +43 -0
- package/src/components/chart/engine.ts +838 -0
- package/src/components/chart/parts.ts +237 -0
- package/src/components/chart/react.tsx +50 -0
- package/src/components/chart/use-chart.ts +55 -0
- package/src/components/chart-tooltip/README.md +53 -0
- package/src/components/chart-tooltip/chart-tooltip.css +167 -0
- package/src/components/chart-tooltip/element.ts +37 -0
- package/src/components/chart-tooltip/engine.ts +442 -0
- package/src/components/chart-tooltip/react.tsx +47 -0
- package/src/components/code-block/README.md +19 -0
- package/src/components/code-block/code-block.css +263 -0
- package/src/components/code-block/element.ts +34 -0
- package/src/components/code-block/engine.ts +254 -0
- package/src/components/code-block/highlight.ts +244 -0
- package/src/components/code-block/react.tsx +94 -0
- package/src/components/color-area/README.md +50 -0
- package/src/components/color-area/color-area.css +81 -0
- package/src/components/color-area/element.ts +26 -0
- package/src/components/color-area/engine.ts +246 -0
- package/src/components/color-area/react.tsx +42 -0
- package/src/components/color-field/README.md +43 -0
- package/src/components/color-field/color-field.css +66 -0
- package/src/components/color-field/element.ts +26 -0
- package/src/components/color-field/engine.ts +174 -0
- package/src/components/color-field/react.tsx +42 -0
- package/src/components/color-picker/README.md +45 -0
- package/src/components/color-picker/color-picker.css +130 -0
- package/src/components/color-picker/element.ts +45 -0
- package/src/components/color-picker/engine.ts +314 -0
- package/src/components/color-picker/react.tsx +47 -0
- package/src/components/color-slider/README.md +55 -0
- package/src/components/color-slider/color-slider.css +112 -0
- package/src/components/color-slider/element.ts +26 -0
- package/src/components/color-slider/engine.ts +234 -0
- package/src/components/color-slider/react.tsx +45 -0
- package/src/components/command-search/README.md +15 -0
- package/src/components/command-search/command-search.css +251 -0
- package/src/components/command-search/element.ts +36 -0
- package/src/components/command-search/engine.ts +356 -0
- package/src/components/command-search/match.ts +53 -0
- package/src/components/command-search/react.tsx +66 -0
- package/src/components/context-menu/README.md +31 -0
- package/src/components/context-menu/context-menu.css +22 -0
- package/src/components/context-menu/element.ts +40 -0
- package/src/components/context-menu/engine.ts +153 -0
- package/src/components/context-menu/react.tsx +57 -0
- package/src/components/credit-card/README.md +20 -0
- package/src/components/credit-card/card.ts +77 -0
- package/src/components/credit-card/credit-card.css +287 -0
- package/src/components/credit-card/element.ts +33 -0
- package/src/components/credit-card/engine.ts +410 -0
- package/src/components/credit-card/react.tsx +36 -0
- package/src/components/data-table/README.md +83 -0
- package/src/components/data-table/data-table.css +685 -0
- package/src/components/data-table/element.ts +54 -0
- package/src/components/data-table/engine.ts +1111 -0
- package/src/components/data-table/react.tsx +94 -0
- package/src/components/date-range-picker/README.md +51 -0
- package/src/components/date-range-picker/date-range-picker.css +167 -0
- package/src/components/date-range-picker/element.ts +52 -0
- package/src/components/date-range-picker/engine.ts +352 -0
- package/src/components/date-range-picker/react.tsx +57 -0
- package/src/components/date-time-picker/README.md +48 -0
- package/src/components/date-time-picker/date-time-picker.css +177 -0
- package/src/components/date-time-picker/element.ts +47 -0
- package/src/components/date-time-picker/engine.ts +350 -0
- package/src/components/date-time-picker/react.tsx +54 -0
- package/src/components/dialog/README.md +103 -102
- package/src/components/dialog/element.ts +123 -118
- package/src/components/dialog/engine.ts +449 -432
- package/src/components/drawer/README.md +28 -0
- package/src/components/drawer/drawer.css +57 -0
- package/src/components/drawer/element.ts +21 -0
- package/src/components/drawer/engine.ts +56 -0
- package/src/components/drawer/react.tsx +85 -0
- package/src/components/editable-table/README.md +67 -0
- package/src/components/editable-table/editable-table.css +200 -0
- package/src/components/editable-table/element.ts +45 -0
- package/src/components/editable-table/engine.ts +831 -0
- package/src/components/editable-table/react.tsx +79 -0
- package/src/components/empty-state/README.md +41 -0
- package/src/components/empty-state/element.ts +23 -0
- package/src/components/empty-state/empty-state.css +60 -0
- package/src/components/empty-state/engine.ts +232 -0
- package/src/components/empty-state/react.tsx +34 -0
- package/src/components/file-explorer/README.md +67 -0
- package/src/components/file-explorer/element.ts +39 -0
- package/src/components/file-explorer/engine.ts +1307 -0
- package/src/components/file-explorer/file-explorer.css +632 -0
- package/src/components/file-explorer/react.tsx +77 -0
- package/src/components/filter-builder/README.md +47 -0
- package/src/components/filter-builder/element.ts +34 -0
- package/src/components/filter-builder/engine.ts +396 -0
- package/src/components/filter-builder/filter-builder.css +226 -0
- package/src/components/filter-builder/react.tsx +36 -0
- package/src/components/heatmap-chart/README.md +48 -0
- package/src/components/heatmap-chart/element.ts +21 -0
- package/src/components/heatmap-chart/engine.ts +281 -0
- package/src/components/heatmap-chart/heatmap-chart.css +93 -0
- package/src/components/heatmap-chart/react.tsx +14 -0
- package/src/components/hold-confirm/README.md +13 -0
- package/src/components/hold-confirm/element.ts +24 -0
- package/src/components/hold-confirm/engine.ts +216 -0
- package/src/components/hold-confirm/hold-confirm.css +86 -0
- package/src/components/hold-confirm/react.tsx +28 -0
- package/src/components/hover-card/README.md +6 -2
- package/src/components/hover-card/engine.ts +98 -7
- package/src/components/hover-card/hover-card.css +19 -7
- package/src/components/image-preview/README.md +16 -0
- package/src/components/image-preview/element.ts +26 -0
- package/src/components/image-preview/engine.ts +405 -0
- package/src/components/image-preview/image-preview.css +282 -0
- package/src/components/image-preview/react.tsx +43 -0
- package/src/components/json-viewer/README.md +56 -0
- package/src/components/json-viewer/element.ts +37 -0
- package/src/components/json-viewer/engine.ts +449 -0
- package/src/components/json-viewer/json-viewer.css +303 -0
- package/src/components/json-viewer/react.tsx +56 -0
- package/src/components/like-button/README.md +13 -0
- package/src/components/like-button/element.ts +47 -0
- package/src/components/like-button/engine.ts +145 -0
- package/src/components/like-button/like-button.css +77 -0
- package/src/components/like-button/react.tsx +39 -0
- package/src/components/link-preview/README.md +19 -0
- package/src/components/link-preview/element.ts +29 -0
- package/src/components/link-preview/engine.ts +192 -0
- package/src/components/link-preview/link-preview.css +274 -0
- package/src/components/link-preview/react.tsx +101 -0
- package/src/components/loading-button/README.md +45 -0
- package/src/components/loading-button/element.ts +34 -0
- package/src/components/loading-button/engine.ts +201 -0
- package/src/components/loading-button/loading-button.css +76 -0
- package/src/components/loading-button/react.tsx +43 -0
- package/src/components/multi-select/README.md +48 -0
- package/src/components/multi-select/element.ts +28 -0
- package/src/components/multi-select/engine.ts +294 -0
- package/src/components/multi-select/multi-select.css +266 -0
- package/src/components/multi-select/react.tsx +39 -0
- package/src/components/nav/README.md +12 -10
- package/src/components/nav/element.ts +5 -5
- package/src/components/nav/engine.ts +21 -14
- package/src/components/nav/nav.css +102 -102
- package/src/components/nav/react.tsx +4 -4
- package/src/components/notification-bell/README.md +14 -0
- package/src/components/notification-bell/element.ts +48 -0
- package/src/components/notification-bell/engine.ts +202 -0
- package/src/components/notification-bell/notification-bell.css +126 -0
- package/src/components/notification-bell/react.tsx +57 -0
- package/src/components/orbit-menu/README.md +46 -0
- package/src/components/orbit-menu/element.ts +27 -0
- package/src/components/orbit-menu/engine.ts +179 -0
- package/src/components/orbit-menu/orbit-menu.css +129 -0
- package/src/components/orbit-menu/react.tsx +44 -0
- package/src/components/pagination/README.md +1 -1
- package/src/components/pagination/engine.ts +50 -4
- package/src/components/pagination/pagination.css +10 -5
- package/src/components/password-strength/README.md +17 -0
- package/src/components/password-strength/element.ts +22 -0
- package/src/components/password-strength/engine.ts +212 -0
- package/src/components/password-strength/password-strength.css +182 -0
- package/src/components/password-strength/react.tsx +36 -0
- package/src/components/password-strength/score.ts +62 -0
- package/src/components/pie-chart/README.md +48 -0
- package/src/components/pie-chart/element.ts +30 -0
- package/src/components/pie-chart/engine.ts +283 -0
- package/src/components/pie-chart/pie-chart.css +92 -0
- package/src/components/pie-chart/react.tsx +14 -0
- package/src/components/pill-button/README.md +46 -0
- package/src/components/pill-button/element.ts +16 -0
- package/src/components/pill-button/engine.ts +77 -0
- package/src/components/pill-button/pill-button.css +134 -0
- package/src/components/pill-button/react.tsx +32 -0
- package/src/components/popover/README.md +44 -0
- package/src/components/popover/element.ts +31 -0
- package/src/components/popover/engine.ts +114 -0
- package/src/components/popover/popover.css +24 -0
- package/src/components/popover/react.tsx +50 -0
- package/src/components/progress/README.md +17 -0
- package/src/components/progress/element.ts +30 -0
- package/src/components/progress/engine.ts +173 -0
- package/src/components/progress/progress.css +139 -0
- package/src/components/progress/react.tsx +35 -0
- package/src/components/questionnaire/README.md +32 -0
- package/src/components/questionnaire/element.ts +118 -0
- package/src/components/questionnaire/engine.ts +255 -0
- package/src/components/questionnaire/questionnaire.css +216 -0
- package/src/components/questionnaire/react.tsx +140 -0
- package/src/components/radar-chart/README.md +48 -0
- package/src/components/radar-chart/element.ts +30 -0
- package/src/components/radar-chart/engine.ts +327 -0
- package/src/components/radar-chart/radar-chart.css +72 -0
- package/src/components/radar-chart/react.tsx +14 -0
- package/src/components/radial-chart/README.md +48 -0
- package/src/components/radial-chart/element.ts +30 -0
- package/src/components/radial-chart/engine.ts +290 -0
- package/src/components/radial-chart/radial-chart.css +100 -0
- package/src/components/radial-chart/react.tsx +14 -0
- package/src/components/range-calendar/README.md +58 -0
- package/src/components/range-calendar/element.ts +42 -0
- package/src/components/range-calendar/engine.ts +390 -0
- package/src/components/range-calendar/range-calendar.css +185 -0
- package/src/components/range-calendar/react.tsx +56 -0
- package/src/components/range-slider/README.md +23 -0
- package/src/components/range-slider/element.ts +53 -0
- package/src/components/range-slider/engine.ts +316 -0
- package/src/components/range-slider/range-slider.css +191 -0
- package/src/components/range-slider/react.tsx +66 -0
- package/src/components/resizable-panel/README.md +61 -0
- package/src/components/resizable-panel/element.ts +36 -0
- package/src/components/resizable-panel/engine.ts +551 -0
- package/src/components/resizable-panel/react.tsx +74 -0
- package/src/components/resizable-panel/resizable-panel.css +242 -0
- package/src/components/rich-text-editor/README.md +57 -0
- package/src/components/rich-text-editor/element.ts +34 -0
- package/src/components/rich-text-editor/engine.ts +673 -0
- package/src/components/rich-text-editor/react.tsx +60 -0
- package/src/components/rich-text-editor/rich-text-editor.css +283 -0
- package/src/components/sankey-chart/README.md +48 -0
- package/src/components/sankey-chart/element.ts +31 -0
- package/src/components/sankey-chart/engine.ts +401 -0
- package/src/components/sankey-chart/react.tsx +14 -0
- package/src/components/sankey-chart/sankey-chart.css +60 -0
- package/src/components/scratch-card/README.md +15 -0
- package/src/components/scratch-card/element.ts +30 -0
- package/src/components/scratch-card/engine.ts +257 -0
- package/src/components/scratch-card/react.tsx +40 -0
- package/src/components/scratch-card/scratch-card.css +74 -0
- package/src/components/scroll-island/README.md +34 -0
- package/src/components/scroll-island/element.ts +16 -0
- package/src/components/scroll-island/engine.ts +252 -0
- package/src/components/scroll-island/react.tsx +26 -0
- package/src/components/scroll-island/scroll-island.css +110 -0
- package/src/components/select/README.md +34 -0
- package/src/components/select/element.ts +26 -0
- package/src/components/select/engine.ts +267 -0
- package/src/components/select/react.tsx +33 -0
- package/src/components/select/select.css +135 -0
- package/src/components/skeleton/README.md +15 -0
- package/src/components/skeleton/element.ts +32 -0
- package/src/components/skeleton/engine.ts +104 -0
- package/src/components/skeleton/react.tsx +41 -0
- package/src/components/skeleton/skeleton.css +107 -0
- package/src/components/split-view/README.md +50 -0
- package/src/components/split-view/element.ts +34 -0
- package/src/components/split-view/engine.ts +114 -0
- package/src/components/split-view/react.tsx +63 -0
- package/src/components/split-view/split-view.css +18 -0
- package/src/components/star-rating/README.md +14 -0
- package/src/components/star-rating/element.ts +26 -0
- package/src/components/star-rating/engine.ts +217 -0
- package/src/components/star-rating/react.tsx +33 -0
- package/src/components/star-rating/star-rating.css +79 -0
- package/src/components/stat-card/README.md +42 -0
- package/src/components/stat-card/element.ts +40 -0
- package/src/components/stat-card/engine.ts +283 -0
- package/src/components/stat-card/react.tsx +36 -0
- package/src/components/stat-card/stat-card.css +163 -0
- package/src/components/swipe-actions/README.md +19 -0
- package/src/components/swipe-actions/element.ts +26 -0
- package/src/components/swipe-actions/engine.ts +260 -0
- package/src/components/swipe-actions/react.tsx +80 -0
- package/src/components/swipe-actions/swipe-actions.css +104 -0
- package/src/components/tag-input/README.md +42 -0
- package/src/components/tag-input/element.ts +39 -0
- package/src/components/tag-input/engine.ts +313 -0
- package/src/components/tag-input/react.tsx +54 -0
- package/src/components/tag-input/tag-input.css +243 -0
- package/src/components/time-field/README.md +54 -0
- package/src/components/time-field/element.ts +38 -0
- package/src/components/time-field/engine.ts +110 -0
- package/src/components/time-field/react.tsx +45 -0
- package/src/components/time-field/time-field.css +87 -0
- package/src/components/timeline/README.md +57 -0
- package/src/components/timeline/element.ts +31 -0
- package/src/components/timeline/engine.ts +300 -0
- package/src/components/timeline/react.tsx +59 -0
- package/src/components/timeline/timeline.css +218 -0
- package/src/components/toolbar/README.md +46 -0
- package/src/components/toolbar/element.ts +30 -0
- package/src/components/toolbar/engine.ts +230 -0
- package/src/components/toolbar/react.tsx +34 -0
- package/src/components/toolbar/toolbar.css +121 -0
- package/src/components/tooltip/README.md +46 -0
- package/src/components/tooltip/element.ts +22 -0
- package/src/components/tooltip/engine.ts +288 -0
- package/src/components/tooltip/react.tsx +30 -0
- package/src/components/tooltip/tooltip.css +78 -0
- package/src/components/tree-view/README.md +61 -0
- package/src/components/tree-view/element.ts +32 -0
- package/src/components/tree-view/engine.ts +743 -0
- package/src/components/tree-view/react.tsx +82 -0
- package/src/components/tree-view/tree-view.css +288 -0
- package/src/components/virtual-list/README.md +81 -0
- package/src/components/virtual-list/element.ts +42 -0
- package/src/components/virtual-list/engine.ts +678 -0
- package/src/components/virtual-list/react.tsx +101 -0
- package/src/components/virtual-list/virtual-list.css +194 -0
- package/src/components/voice-dots/README.md +48 -0
- package/src/components/voice-dots/element.ts +45 -0
- package/src/components/voice-dots/engine.ts +243 -0
- package/src/components/voice-dots/react.tsx +52 -0
- package/src/components/voice-dots/voice-dots.css +69 -0
- package/src/core/chips.ts +196 -0
- package/src/core/color.ts +304 -0
- package/src/core/date-range.ts +67 -0
- package/src/core/dates.ts +11 -1
- package/src/core/files.ts +107 -0
- package/src/core/filter.ts +229 -0
- package/src/core/gsap.ts +80 -65
- package/src/core/listbox.ts +332 -0
- package/src/core/mark.ts +29 -0
- package/src/core/position.ts +89 -0
- package/src/core/relative-time.ts +77 -0
- package/src/core/segment-field.ts +373 -0
- package/src/core/segments.ts +153 -0
- package/src/core/tree.ts +116 -0
- package/src/core/virtual.ts +79 -0
- package/src/css/tokens.css +186 -182
- package/src/elements/index.ts +186 -0
- package/src/index.ts +88 -0
- package/src/motion/liquid.ts +14 -4
- package/src/motion/micro.ts +248 -0
- package/src/motion/sheet.ts +88 -65
- package/src/motion/surface.ts +9 -0
- package/src/react/index.ts +71 -1
- package/dist/chunk-IKQ5FODN.js +0 -1617
- package/dist/chunk-IKQ5FODN.js.map +0 -1
- package/dist/chunk-J6OCFNGU.js +0 -177
- package/dist/chunk-J6OCFNGU.js.map +0 -1
- package/dist/chunk-TFNRIZHU.js +0 -3977
- package/dist/chunk-TFNRIZHU.js.map +0 -1
- package/dist/chunk-XAKC2QY7.js.map +0 -1
- package/dist/reveal-jsX-uwUz.d.ts +0 -625
- package/dist/store-DYb3tTsZ.d.ts +0 -195
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { gsap, EASE } from '../../core/gsap';
|
|
2
|
+
import { reduced } from '../../core/reduced';
|
|
3
|
+
import type { Scope } from '../../core/scope';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* The parts the round and flow charts (pie, radar, radial, sankey, heatmap)
|
|
7
|
+
* share with chart: the same plot, inverse-glass tooltip, outlined legend,
|
|
8
|
+
* screen-reader table and colour slots, so they read as one family and use
|
|
9
|
+
* chart.css. Each chart draws its own marks.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
13
|
+
export const SLOTS = 8;
|
|
14
|
+
|
|
15
|
+
export const svg = <K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string | number> = {}) => {
|
|
16
|
+
const element = document.createElementNS(SVG_NS, tag);
|
|
17
|
+
for (const [name, value] of Object.entries(attrs)) element.setAttribute(name, String(value));
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
export const finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);
|
|
21
|
+
export const round = (n: number) => Math.round(n * 100) / 100;
|
|
22
|
+
|
|
23
|
+
/** The colour of slot `i`: monochrome alone, --mk-chart-N for up to 8, a neutral past them. */
|
|
24
|
+
export const slotColor = (i: number, total = SLOTS) => (total === 1 ? 'var(--mk-chart-mono)' : i < SLOTS ? `var(--mk-chart-${i + 1})` : 'var(--mk-chart-other)');
|
|
25
|
+
|
|
26
|
+
export const formatNumber = (value: number) => new Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format(value);
|
|
27
|
+
|
|
28
|
+
/** A point on a circle: angle 0 is 12 o'clock, clockwise. */
|
|
29
|
+
export const polar = (cx: number, cy: number, r: number, angle: number) => [cx + r * Math.sin(angle), cy - r * Math.cos(angle)] as const;
|
|
30
|
+
|
|
31
|
+
/** An annular sector (a pie slice when `inner` is 0) from angle `a0` to `a1`. */
|
|
32
|
+
export function arcPath(cx: number, cy: number, outer: number, inner: number, a0: number, a1: number) {
|
|
33
|
+
const sweep = Math.min(a1 - a0, Math.PI * 2 - 1e-4);
|
|
34
|
+
const end = a0 + sweep;
|
|
35
|
+
const large = sweep > Math.PI ? 1 : 0;
|
|
36
|
+
const [x0, y0] = polar(cx, cy, outer, a0);
|
|
37
|
+
const [x1, y1] = polar(cx, cy, outer, end);
|
|
38
|
+
if (inner <= 0) return `M${round(cx)},${round(cy)}L${round(x0)},${round(y0)}A${round(outer)},${round(outer)} 0 ${large} 1 ${round(x1)},${round(y1)}Z`;
|
|
39
|
+
const [x2, y2] = polar(cx, cy, inner, end);
|
|
40
|
+
const [x3, y3] = polar(cx, cy, inner, a0);
|
|
41
|
+
return `M${round(x0)},${round(y0)}A${round(outer)},${round(outer)} 0 ${large} 1 ${round(x1)},${round(y1)}L${round(x2)},${round(y2)}A${round(inner)},${round(inner)} 0 ${large} 0 ${round(x3)},${round(y3)}Z`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface TipRow {
|
|
45
|
+
name: string;
|
|
46
|
+
color?: string;
|
|
47
|
+
value: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ChartFrame {
|
|
51
|
+
plot: HTMLDivElement;
|
|
52
|
+
canvas: SVGSVGElement;
|
|
53
|
+
tooltip: HTMLDivElement;
|
|
54
|
+
empty: HTMLParagraphElement;
|
|
55
|
+
legend: HTMLUListElement;
|
|
56
|
+
table: HTMLTableElement;
|
|
57
|
+
live: HTMLSpanElement;
|
|
58
|
+
/** Fill and show the tooltip near (x, y) in plot px; null hides it. */
|
|
59
|
+
tip(at: { x: number; y: number; title: string; rows: TipRow[] } | null): void;
|
|
60
|
+
/** One outlined pill per item; `type` picks the swatch's shape. */
|
|
61
|
+
fillLegend(items: Array<{ name: string; color: string }>, show: boolean, type?: string): HTMLLIElement[];
|
|
62
|
+
/** The values for screen readers: a caption, the column heads and the rows. */
|
|
63
|
+
fillTable(caption: string, head: string[], rows: string[][]): void;
|
|
64
|
+
keep(animation: gsap.core.Animation | null | undefined): void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The plot, tooltip, legend and table of a chart, removed by the scope. The root gets .mk-chart for chart.css. */
|
|
68
|
+
export function chartFrame(root: HTMLElement, scope: Scope, kind: string): ChartFrame {
|
|
69
|
+
if (!root.classList.contains('mk-chart')) {
|
|
70
|
+
root.classList.add('mk-chart');
|
|
71
|
+
scope.add(() => {
|
|
72
|
+
root.classList.remove('mk-chart');
|
|
73
|
+
if (!root.classList.length) root.removeAttribute('class');
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
scope.attr(root, 'data-mk-chart-type', kind);
|
|
77
|
+
const made = <K extends keyof HTMLElementTagNameMap>(tag: K, parent: Element = root) => {
|
|
78
|
+
const element = document.createElement(tag);
|
|
79
|
+
parent.append(element);
|
|
80
|
+
scope.add(() => element.remove());
|
|
81
|
+
return element;
|
|
82
|
+
};
|
|
83
|
+
const plot = made('div');
|
|
84
|
+
plot.dataset.mkChartPlot = '';
|
|
85
|
+
const canvas = svg('svg');
|
|
86
|
+
canvas.dataset.mkChartSvg = '';
|
|
87
|
+
canvas.setAttribute('role', 'img');
|
|
88
|
+
canvas.setAttribute('tabindex', '0');
|
|
89
|
+
canvas.setAttribute('focusable', 'true');
|
|
90
|
+
plot.append(canvas);
|
|
91
|
+
const tooltip = made('div', plot);
|
|
92
|
+
tooltip.dataset.mkChartTooltip = '';
|
|
93
|
+
tooltip.setAttribute('aria-hidden', 'true');
|
|
94
|
+
tooltip.hidden = true;
|
|
95
|
+
const empty = made('p');
|
|
96
|
+
empty.dataset.mkChartEmpty = '';
|
|
97
|
+
empty.hidden = true;
|
|
98
|
+
const legend = made('ul');
|
|
99
|
+
legend.dataset.mkChartLegend = '';
|
|
100
|
+
const table = made('table');
|
|
101
|
+
table.dataset.mkChartTable = '';
|
|
102
|
+
table.className = 'mk-sr-only';
|
|
103
|
+
const live = made('span');
|
|
104
|
+
live.className = 'mk-sr-only';
|
|
105
|
+
live.setAttribute('role', 'status');
|
|
106
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
107
|
+
|
|
108
|
+
const effects = new Set<gsap.core.Animation>();
|
|
109
|
+
const keep = (animation: gsap.core.Animation | null | undefined) => {
|
|
110
|
+
if (!animation) return;
|
|
111
|
+
effects.add(animation);
|
|
112
|
+
// Finished ones leave as new ones arrive: the animation's own onComplete stays untouched.
|
|
113
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
114
|
+
};
|
|
115
|
+
scope.add(() => {
|
|
116
|
+
for (const effect of effects) effect.kill();
|
|
117
|
+
effects.clear();
|
|
118
|
+
gsap.killTweensOf(tooltip);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const tip: ChartFrame['tip'] = (at) => {
|
|
122
|
+
if (!at) {
|
|
123
|
+
if (!tooltip.hidden && !reduced()) {
|
|
124
|
+
gsap.killTweensOf(tooltip, 'opacity,scale');
|
|
125
|
+
keep(gsap.to(tooltip, { opacity: 0, scale: 0.94, duration: 0.15, ease: 'power2.in', onComplete: () => {
|
|
126
|
+
tooltip.hidden = true;
|
|
127
|
+
} }));
|
|
128
|
+
} else tooltip.hidden = true;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
tooltip.replaceChildren();
|
|
132
|
+
const title = document.createElement('strong');
|
|
133
|
+
title.textContent = at.title;
|
|
134
|
+
tooltip.append(title);
|
|
135
|
+
for (const each of at.rows) {
|
|
136
|
+
const row = document.createElement('span');
|
|
137
|
+
row.dataset.mkChartRow = '';
|
|
138
|
+
const swatch = document.createElement('i');
|
|
139
|
+
if (!each.color || /--mk-(text|chart-mono|muted)/.test(each.color)) swatch.dataset.mkMono = '';
|
|
140
|
+
else swatch.style.background = each.color;
|
|
141
|
+
const name = document.createElement('span');
|
|
142
|
+
name.textContent = each.name;
|
|
143
|
+
const amount = document.createElement('b');
|
|
144
|
+
amount.textContent = each.value;
|
|
145
|
+
row.append(swatch, name, amount);
|
|
146
|
+
tooltip.append(row);
|
|
147
|
+
}
|
|
148
|
+
const appearing = tooltip.hidden;
|
|
149
|
+
tooltip.hidden = false;
|
|
150
|
+
const width = plot.clientWidth || 300;
|
|
151
|
+
const height = plot.clientHeight || 240;
|
|
152
|
+
const tipW = tooltip.offsetWidth || 160;
|
|
153
|
+
const tipH = tooltip.offsetHeight || 60;
|
|
154
|
+
// Beside the point, towards the middle of the plot, inside it.
|
|
155
|
+
const left = round(Math.max(0, Math.min(width - tipW, at.x > width / 2 ? at.x - 16 - tipW : at.x + 16)));
|
|
156
|
+
const top = round(Math.max(0, Math.min(height - tipH, at.y - tipH - 12)));
|
|
157
|
+
if (appearing || reduced()) {
|
|
158
|
+
gsap.killTweensOf(tooltip);
|
|
159
|
+
gsap.set(tooltip, { x: left, y: top });
|
|
160
|
+
if (!reduced()) keep(gsap.fromTo(tooltip, { opacity: 0, scale: 0.9 }, { opacity: 1, scale: 1, duration: 0.25, ease: EASE.pop }));
|
|
161
|
+
else gsap.set(tooltip, { opacity: 1, scale: 1 });
|
|
162
|
+
} else {
|
|
163
|
+
gsap.killTweensOf(tooltip, 'opacity,scale');
|
|
164
|
+
gsap.set(tooltip, { opacity: 1, scale: 1 });
|
|
165
|
+
keep(gsap.to(tooltip, { x: left, y: top, duration: 0.25, ease: 'power3.out', overwrite: 'auto' }));
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const fillLegend: ChartFrame['fillLegend'] = (items, show, type = 'bar') => {
|
|
170
|
+
legend.replaceChildren();
|
|
171
|
+
legend.hidden = !show || !items.length;
|
|
172
|
+
if (legend.hidden) return [];
|
|
173
|
+
return items.map((item) => {
|
|
174
|
+
const li = document.createElement('li');
|
|
175
|
+
const swatch = document.createElement('span');
|
|
176
|
+
swatch.dataset.mkChartSwatch = '';
|
|
177
|
+
swatch.dataset.mkType = type;
|
|
178
|
+
swatch.style.background = item.color;
|
|
179
|
+
swatch.style.color = item.color;
|
|
180
|
+
swatch.setAttribute('aria-hidden', 'true');
|
|
181
|
+
const name = document.createElement('span');
|
|
182
|
+
name.textContent = item.name;
|
|
183
|
+
li.append(swatch, name);
|
|
184
|
+
legend.append(li);
|
|
185
|
+
return li;
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const fillTable: ChartFrame['fillTable'] = (caption, head, rows) => {
|
|
190
|
+
table.replaceChildren();
|
|
191
|
+
const cap = document.createElement('caption');
|
|
192
|
+
cap.textContent = caption;
|
|
193
|
+
const thead = document.createElement('thead');
|
|
194
|
+
const headRow = document.createElement('tr');
|
|
195
|
+
for (const text of head) {
|
|
196
|
+
const th = document.createElement('th');
|
|
197
|
+
th.scope = 'col';
|
|
198
|
+
th.textContent = text;
|
|
199
|
+
headRow.append(th);
|
|
200
|
+
}
|
|
201
|
+
thead.append(headRow);
|
|
202
|
+
const body = document.createElement('tbody');
|
|
203
|
+
for (const cells of rows) {
|
|
204
|
+
const row = document.createElement('tr');
|
|
205
|
+
cells.forEach((text, i) => {
|
|
206
|
+
const cell = document.createElement(i ? 'td' : 'th');
|
|
207
|
+
if (!i) (cell as HTMLTableCellElement).scope = 'row';
|
|
208
|
+
cell.textContent = text;
|
|
209
|
+
row.append(cell);
|
|
210
|
+
});
|
|
211
|
+
body.append(row);
|
|
212
|
+
}
|
|
213
|
+
table.append(cap, thead, body);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
return { plot, canvas, tooltip, empty, legend, table, live, tip, fillLegend, fillTable, keep };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Calls `draw` again when the root changes width (on the next frame, once). */
|
|
220
|
+
export function onWidth(root: HTMLElement, scope: Scope, draw: () => void) {
|
|
221
|
+
if (typeof ResizeObserver !== 'function') return;
|
|
222
|
+
let width = 0;
|
|
223
|
+
let frame = 0;
|
|
224
|
+
const observer = scope.observe(
|
|
225
|
+
new ResizeObserver(() => {
|
|
226
|
+
const next = Math.round(root.clientWidth);
|
|
227
|
+
if (!next || next === width) return;
|
|
228
|
+
const first = !width;
|
|
229
|
+
width = next;
|
|
230
|
+
if (first) return;
|
|
231
|
+
cancelAnimationFrame(frame);
|
|
232
|
+
frame = requestAnimationFrame(draw);
|
|
233
|
+
}),
|
|
234
|
+
);
|
|
235
|
+
observer.observe(root);
|
|
236
|
+
scope.add(() => cancelAnimationFrame(frame));
|
|
237
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { createChart, type ChartInstance, type ChartOptions } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface ChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect' | 'children'>, ChartOptions {
|
|
7
|
+
instanceRef?: { current: ChartInstance | null };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* <Chart type="bar" stacked labels={weeks} series={[{ name: 'Ana', values }]} formatValue={money} label="Sesiones por semana" />.
|
|
12
|
+
* Data changes redraw in place; the selection survives when its point still exists.
|
|
13
|
+
*/
|
|
14
|
+
export function Chart({ type, labels, series, points, stacked, formatValue, label, height, emptyLabel, legend, tooltip, axis, endLabel, onSelect, instanceRef, className, ...props }: ChartProps) {
|
|
15
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
16
|
+
const instance = useRef<ChartInstance | null>(null);
|
|
17
|
+
const format = useLatest(formatValue);
|
|
18
|
+
const select = useLatest(onSelect);
|
|
19
|
+
const formatted = formatValue !== undefined;
|
|
20
|
+
const data = { type, labels, series, points, stacked, label, height, emptyLabel, legend, tooltip, axis, endLabel };
|
|
21
|
+
const key = JSON.stringify(data);
|
|
22
|
+
const latest = useLatest(data);
|
|
23
|
+
const options = (): ChartOptions => ({
|
|
24
|
+
...latest.current,
|
|
25
|
+
formatValue: formatted ? (value) => format.current?.(value) ?? String(value) : undefined,
|
|
26
|
+
onSelect: (index) => select.current?.(index),
|
|
27
|
+
});
|
|
28
|
+
useIsomorphicLayoutEffect(() => {
|
|
29
|
+
const created = createChart(ref.current, options());
|
|
30
|
+
instance.current = created;
|
|
31
|
+
if (instanceRef) instanceRef.current = created;
|
|
32
|
+
return () => {
|
|
33
|
+
created.destroy();
|
|
34
|
+
instance.current = null;
|
|
35
|
+
if (instanceRef) instanceRef.current = null;
|
|
36
|
+
};
|
|
37
|
+
// Created once; data is pushed below.
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
|
+
}, []);
|
|
40
|
+
const first = useRef(true);
|
|
41
|
+
useIsomorphicLayoutEffect(() => {
|
|
42
|
+
if (first.current) {
|
|
43
|
+
first.current = false;
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
instance.current?.update(options());
|
|
47
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
+
}, [key, formatted]);
|
|
49
|
+
return <div {...props} ref={ref} className={['mk-chart', className].filter(Boolean).join(' ')} />;
|
|
50
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type RefObject } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import type { Instance } from '../../core/types';
|
|
5
|
+
|
|
6
|
+
interface Updatable<O> extends Instance {
|
|
7
|
+
update(options: O): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The React side of the round and flow charts: the engine is created once and
|
|
12
|
+
* data changes are pushed with update(), so the chart glides instead of being
|
|
13
|
+
* drawn again. `data` is compared as JSON; callbacks always call the latest.
|
|
14
|
+
*/
|
|
15
|
+
export function useChart<O extends object, I extends Updatable<O>>(
|
|
16
|
+
create: (root: HTMLElement | null, options: O) => I,
|
|
17
|
+
data: O,
|
|
18
|
+
callbacks: { formatValue?: (value: number) => string; onSelect?: (...args: never[]) => void },
|
|
19
|
+
instanceRef?: { current: I | null },
|
|
20
|
+
): RefObject<HTMLDivElement | null> {
|
|
21
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
22
|
+
const instance = useRef<I | null>(null);
|
|
23
|
+
const format = useLatest(callbacks.formatValue);
|
|
24
|
+
const select = useLatest(callbacks.onSelect);
|
|
25
|
+
const formatted = callbacks.formatValue !== undefined;
|
|
26
|
+
const key = JSON.stringify(data);
|
|
27
|
+
const latest = useLatest(data);
|
|
28
|
+
const options = (): O => ({
|
|
29
|
+
...latest.current,
|
|
30
|
+
formatValue: formatted ? (value: number) => format.current?.(value) ?? String(value) : undefined,
|
|
31
|
+
onSelect: (...args: never[]) => (select.current as ((...a: never[]) => void) | undefined)?.(...args),
|
|
32
|
+
});
|
|
33
|
+
useIsomorphicLayoutEffect(() => {
|
|
34
|
+
const created = create(ref.current, options());
|
|
35
|
+
instance.current = created;
|
|
36
|
+
if (instanceRef) instanceRef.current = created;
|
|
37
|
+
return () => {
|
|
38
|
+
created.destroy();
|
|
39
|
+
instance.current = null;
|
|
40
|
+
if (instanceRef) instanceRef.current = null;
|
|
41
|
+
};
|
|
42
|
+
// Created once; data is pushed below.
|
|
43
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
44
|
+
}, []);
|
|
45
|
+
const first = useRef(true);
|
|
46
|
+
useIsomorphicLayoutEffect(() => {
|
|
47
|
+
if (first.current) {
|
|
48
|
+
first.current = false;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
instance.current?.update(options());
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
+
}, [key, formatted]);
|
|
54
|
+
return ref;
|
|
55
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# chart-tooltip
|
|
2
|
+
|
|
3
|
+
Tooltip avanzado para gráficas. Sobre la `chart` de motion-kit (creada con `tooltip: false`) sigue la selección de la propia gráfica, que le pasa el punto, cada serie y su valor anterior por `mk:select`, y deja la guía y los marcadores a la gráfica. Sobre cualquier otra gráfica sigue al puntero por `labels` (de borde a borde en líneas, en el centro de cada hueco en barras, dentro de `inset`) y dibuja una guía punteada y, con `min`/`max`, un marcador por serie. El teclado también la mueve (flechas, Inicio, Fin, Escape).
|
|
4
|
+
|
|
5
|
+
La tarjeta es el cristal invertido de Melon Mind: la etiqueta y una fila por serie con su valor, la variación respecto al punto anterior (▲ ▼ %) y, si lo pides, su parte del total, más una fila de total. Aparece con un pop (.25 s), se desliza entre puntos hacia el lado con espacio y los valores que cambian ruedan en su dirección. Un clic la fija: se queda aunque el puntero salga (el pin aparece con un giro); otro clic o Escape la suelta.
|
|
6
|
+
|
|
7
|
+
## HTML / Astro
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<mk-chart-tooltip class="mk-chart-tooltip" share>
|
|
11
|
+
<mk-chart class="mk-chart" type="line" tooltip="false" labels="Ene,Feb,Mar"
|
|
12
|
+
series='[{"name":"Ingresos","values":[120,150,140]},{"name":"Gastos","values":[80,95,70]}]'></mk-chart>
|
|
13
|
+
</mk-chart-tooltip>
|
|
14
|
+
|
|
15
|
+
<!-- Sobre otra gráfica (SVG o canvas propios): -->
|
|
16
|
+
<mk-chart-tooltip labels="L,M,X,J,V" series='[{"name":"Visitas","values":[4,6,5,8,7]}]'
|
|
17
|
+
inset='{"left":40,"right":16,"top":12,"bottom":28}' min="0" max="10">
|
|
18
|
+
<canvas id="grafica"></canvas>
|
|
19
|
+
</mk-chart-tooltip>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## React
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
<ChartTooltip share total>
|
|
26
|
+
<Chart type="bar" labels={weeks} series={teams} tooltip={false} />
|
|
27
|
+
</ChartTooltip>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Opciones
|
|
31
|
+
|
|
32
|
+
| Opción | Atributo | Por defecto | Qué hace |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| `labels`, `series` | `labels`, `series` (JSON) | — | Datos, en modo independiente (`{ name, values, color? }`). |
|
|
35
|
+
| `align` | `align` | `'edge'` | `edge` (líneas) o `center` (barras). |
|
|
36
|
+
| `inset` | `inset` (JSON) | 0 | Margen del área de la gráfica dentro del contenedor, en px. |
|
|
37
|
+
| `min`, `max` | `min`, `max` | — | Escala vertical: con ella se dibujan marcadores. |
|
|
38
|
+
| `formatValue(n)` | — | 2 decimales | Formato de los valores. |
|
|
39
|
+
| `delta` | `delta` | `true` | Variación respecto al punto anterior. |
|
|
40
|
+
| `share` | `share` | `false` | Parte del total de cada fila. |
|
|
41
|
+
| `total` | `total` | con 2+ series | Fila de total. |
|
|
42
|
+
| `sort` | `sort` | `false` | Filas de mayor a menor. |
|
|
43
|
+
| `pin` | `pin` | `true` | Un clic fija la tarjeta. |
|
|
44
|
+
| `label` | `label` | `'Gráfica'` | Nombre accesible en modo independiente. |
|
|
45
|
+
| `onIndexChange(index)` | — | — | Al cambiar de punto. |
|
|
46
|
+
|
|
47
|
+
## API y eventos
|
|
48
|
+
|
|
49
|
+
`show(i)`, `hide()`, `update(options)`, `index`, `pinned`, `destroy()`. Evento `mk:index-change` con `{ index, pinned }`.
|
|
50
|
+
|
|
51
|
+
## Accesibilidad
|
|
52
|
+
|
|
53
|
+
Sobre `chart`, la tabla y los anuncios son los de la gráfica. En modo independiente el contenedor es enfocable y un estado discreto anuncia cada punto al moverse con el teclado. Con movimiento reducido no hay pop ni deslizamientos.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/* chart-tooltip — an overlay on the chart it wraps: a dotted guide, 10 px markers ringed in the surface colour and
|
|
2
|
+
a 12 px card in Melon Mind's inverse glass (label, rows with a swatch, value, change and share, a total). */
|
|
3
|
+
.mk-chart-tooltip,
|
|
4
|
+
mk-chart-tooltip {
|
|
5
|
+
/* The chart palette (same as chart.css), so series over any chart get their colours without it. */
|
|
6
|
+
--mk-chart-mono: var(--mk-text);
|
|
7
|
+
--mk-chart-1: #2a78d6;
|
|
8
|
+
--mk-chart-2: #eb6834;
|
|
9
|
+
--mk-chart-3: #1baf7a;
|
|
10
|
+
--mk-chart-4: #eda100;
|
|
11
|
+
--mk-chart-5: #e87ba4;
|
|
12
|
+
--mk-chart-6: #008300;
|
|
13
|
+
--mk-chart-7: #6250d6;
|
|
14
|
+
--mk-chart-8: #e34948;
|
|
15
|
+
position: relative;
|
|
16
|
+
display: block;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (prefers-color-scheme: dark) {
|
|
20
|
+
:where(:root:not([data-mk-mode='light'])) :is(.mk-chart-tooltip, mk-chart-tooltip) {
|
|
21
|
+
--mk-chart-1: #3987e5;
|
|
22
|
+
--mk-chart-2: #d95926;
|
|
23
|
+
--mk-chart-3: #199e70;
|
|
24
|
+
--mk-chart-4: #c98500;
|
|
25
|
+
--mk-chart-5: #d55181;
|
|
26
|
+
--mk-chart-6: #008300;
|
|
27
|
+
--mk-chart-7: #9085e9;
|
|
28
|
+
--mk-chart-8: #e66767;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:where(:root[data-mk-mode='dark']) :is(.mk-chart-tooltip, mk-chart-tooltip) {
|
|
33
|
+
--mk-chart-1: #3987e5;
|
|
34
|
+
--mk-chart-2: #d95926;
|
|
35
|
+
--mk-chart-3: #199e70;
|
|
36
|
+
--mk-chart-4: #c98500;
|
|
37
|
+
--mk-chart-5: #d55181;
|
|
38
|
+
--mk-chart-6: #008300;
|
|
39
|
+
--mk-chart-7: #9085e9;
|
|
40
|
+
--mk-chart-8: #e66767;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:is(.mk-chart-tooltip, mk-chart-tooltip):focus-visible {
|
|
44
|
+
border-radius: 12px;
|
|
45
|
+
outline: 2px solid var(--mk-accent);
|
|
46
|
+
outline-offset: 4px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[data-mk-ct-layer] {
|
|
50
|
+
position: absolute;
|
|
51
|
+
inset: 0;
|
|
52
|
+
z-index: 3;
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[data-mk-ct-guide] {
|
|
57
|
+
position: absolute;
|
|
58
|
+
left: 0;
|
|
59
|
+
width: 0;
|
|
60
|
+
border-left: 1.5px dotted var(--mk-muted);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[data-mk-ct-marker] {
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: -5px;
|
|
66
|
+
left: -5px;
|
|
67
|
+
width: 10px;
|
|
68
|
+
height: 10px;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
box-shadow: 0 0 0 2.5px var(--mk-surface-1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[data-mk-ct-card] {
|
|
74
|
+
position: absolute;
|
|
75
|
+
top: 0;
|
|
76
|
+
left: 0;
|
|
77
|
+
display: grid;
|
|
78
|
+
gap: 0.35rem;
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
min-width: 11rem;
|
|
81
|
+
max-width: min(18rem, calc(100% - 8px));
|
|
82
|
+
padding: 0.65rem 0.8rem;
|
|
83
|
+
border-radius: 12px;
|
|
84
|
+
background: var(--mk-glass-inverse, rgb(24 24 24 / 0.9));
|
|
85
|
+
color: var(--mk-on-glass-inverse, #fff);
|
|
86
|
+
box-shadow: var(--mk-glass-bevel, 0 12px 32px -12px rgb(0 0 0 / 0.4));
|
|
87
|
+
font-size: 0.8125rem;
|
|
88
|
+
line-height: 1.3;
|
|
89
|
+
-webkit-backdrop-filter: blur(16px);
|
|
90
|
+
backdrop-filter: blur(16px);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-mk-ct-card][hidden],
|
|
94
|
+
[data-mk-ct-guide][hidden],
|
|
95
|
+
[data-mk-ct-marker][hidden],
|
|
96
|
+
[data-mk-ct-pin][hidden],
|
|
97
|
+
[data-mk-ct-delta][hidden] {
|
|
98
|
+
display: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[data-mk-ct-head] {
|
|
102
|
+
display: flex;
|
|
103
|
+
align-items: center;
|
|
104
|
+
justify-content: space-between;
|
|
105
|
+
gap: 0.5rem;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[data-mk-ct-title] {
|
|
109
|
+
overflow: hidden;
|
|
110
|
+
font-weight: 600;
|
|
111
|
+
text-overflow: ellipsis;
|
|
112
|
+
white-space: nowrap;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
[data-mk-ct-pin] {
|
|
116
|
+
display: inline-grid;
|
|
117
|
+
place-items: center;
|
|
118
|
+
opacity: 0.8;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
[data-mk-ct-rows] {
|
|
122
|
+
display: grid;
|
|
123
|
+
gap: 0.3rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
[data-mk-ct-row] {
|
|
127
|
+
display: grid;
|
|
128
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
129
|
+
align-items: center;
|
|
130
|
+
column-gap: 0.5rem;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
[data-mk-ct-swatch] {
|
|
134
|
+
width: 0.6rem;
|
|
135
|
+
height: 0.6rem;
|
|
136
|
+
border-radius: 3px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
[data-mk-ct-swatch][data-mk-mono] {
|
|
140
|
+
height: 2px;
|
|
141
|
+
border-radius: 1px;
|
|
142
|
+
background: currentColor;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
[data-mk-ct-name] {
|
|
146
|
+
overflow: hidden;
|
|
147
|
+
text-overflow: ellipsis;
|
|
148
|
+
white-space: nowrap;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
[data-mk-ct-value] {
|
|
152
|
+
font-variant-numeric: tabular-nums;
|
|
153
|
+
font-weight: 600;
|
|
154
|
+
text-align: end;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
[data-mk-ct-delta] {
|
|
158
|
+
grid-column: 2 / -1;
|
|
159
|
+
font-size: 0.75rem;
|
|
160
|
+
font-variant-numeric: tabular-nums;
|
|
161
|
+
opacity: 0.78;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
[data-mk-ct-row='total'] {
|
|
165
|
+
padding-top: 0.3rem;
|
|
166
|
+
border-top: 1px solid color-mix(in srgb, currentColor 22%, transparent);
|
|
167
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createChartTooltip, type ChartTooltipInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-chart-tooltip class="mk-chart-tooltip" share total>
|
|
6
|
+
* <mk-chart class="mk-chart" tooltip="false" …></mk-chart>
|
|
7
|
+
* </mk-chart-tooltip>
|
|
8
|
+
* Over another chart give it labels, series (JSON), align, inset (JSON), min and max.
|
|
9
|
+
* Emits mk:index-change ({index, pinned}).
|
|
10
|
+
*/
|
|
11
|
+
export class MkChartTooltipElement extends MkElement<ChartTooltipInstance> {
|
|
12
|
+
static options: Record<string, OptionType> = {
|
|
13
|
+
labels: 'list',
|
|
14
|
+
series: 'json',
|
|
15
|
+
align: 'string',
|
|
16
|
+
inset: 'json',
|
|
17
|
+
min: 'number',
|
|
18
|
+
max: 'number',
|
|
19
|
+
delta: 'boolean',
|
|
20
|
+
share: 'boolean',
|
|
21
|
+
total: 'boolean',
|
|
22
|
+
sort: 'boolean',
|
|
23
|
+
pin: 'boolean',
|
|
24
|
+
label: 'string',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
protected create(options: Record<string, unknown>) {
|
|
28
|
+
return createChartTooltip(this, options);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
attributeChangedCallback(_name: string, previous: string | null, next: string | null) {
|
|
32
|
+
if (previous === next || !this.instance) return;
|
|
33
|
+
this.instance.update(this.options);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const defineChartTooltip = () => defineElement('mk-chart-tooltip', MkChartTooltipElement);
|