@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,226 @@
|
|
|
1
|
+
/* filter-builder — the main group bare, nested groups as 16 px cards on surface-2 with an accent rail; each condition a
|
|
2
|
+
wrapping row of 12 px controls on surface-3; the Y/O switch a 10 px segmented control whose indicator slides; small
|
|
3
|
+
round connectors ("y" / "o") between the conditions; the sentence that reads the filter under it. */
|
|
4
|
+
.mk-filter-builder,
|
|
5
|
+
mk-filter-builder {
|
|
6
|
+
display: grid;
|
|
7
|
+
gap: 0.75rem;
|
|
8
|
+
min-width: 0;
|
|
9
|
+
color: var(--mk-text);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[data-mk-fb-group] {
|
|
13
|
+
display: grid;
|
|
14
|
+
gap: 0.6rem;
|
|
15
|
+
min-width: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[data-mk-fb-group]:not([data-depth='0']) {
|
|
19
|
+
padding: 0.75rem;
|
|
20
|
+
border-radius: 16px;
|
|
21
|
+
background: var(--mk-surface-2);
|
|
22
|
+
box-shadow: inset 3px 0 0 color-mix(in srgb, var(--mk-accent) 60%, transparent);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[data-mk-fb-head] {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: 0.5rem 0.75rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-mk-fb-combinator] {
|
|
33
|
+
position: relative;
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
flex: none;
|
|
36
|
+
padding: 3px;
|
|
37
|
+
border-radius: 10px;
|
|
38
|
+
background: var(--mk-surface-3);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[data-mk-fb-indicator] {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 0;
|
|
44
|
+
left: 0;
|
|
45
|
+
border-radius: 8px;
|
|
46
|
+
background: var(--mk-surface-1);
|
|
47
|
+
box-shadow: 0 1px 3px color-mix(in srgb, var(--mk-shadow-color, #000) 18%, transparent);
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[data-mk-fb-combinator] [role='radio'] {
|
|
52
|
+
position: relative;
|
|
53
|
+
z-index: 1;
|
|
54
|
+
min-width: 2.25rem;
|
|
55
|
+
height: 1.9rem;
|
|
56
|
+
padding: 0 0.6rem;
|
|
57
|
+
border: 0;
|
|
58
|
+
border-radius: 8px;
|
|
59
|
+
background: transparent;
|
|
60
|
+
color: var(--mk-muted);
|
|
61
|
+
font: inherit;
|
|
62
|
+
font-size: 0.8125rem;
|
|
63
|
+
font-weight: 700;
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
transition: color 0.2s ease;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
[data-mk-fb-combinator] [role='radio'][aria-checked='true'] {
|
|
69
|
+
color: var(--mk-text);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[data-mk-fb-caption] {
|
|
73
|
+
color: var(--mk-muted);
|
|
74
|
+
font-size: 0.875rem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[data-mk-fb-rules] {
|
|
78
|
+
display: grid;
|
|
79
|
+
gap: 0.4rem;
|
|
80
|
+
min-width: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[data-mk-fb-rule] {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-wrap: wrap;
|
|
86
|
+
align-items: center;
|
|
87
|
+
gap: 0.4rem;
|
|
88
|
+
min-width: 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Choices are the kit's select (select.css draws the button); inputs share its look. */
|
|
92
|
+
[data-mk-fb-rule] .mk-select {
|
|
93
|
+
min-width: 8rem;
|
|
94
|
+
max-width: 100%;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
[data-mk-fb-rule] input {
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
min-width: 0;
|
|
100
|
+
height: 2.5rem;
|
|
101
|
+
padding: 0 0.7rem;
|
|
102
|
+
border: 0;
|
|
103
|
+
border-radius: 12px;
|
|
104
|
+
background: var(--mk-surface-3);
|
|
105
|
+
color: var(--mk-text);
|
|
106
|
+
font: inherit;
|
|
107
|
+
font-size: 0.875rem;
|
|
108
|
+
outline: none;
|
|
109
|
+
transition: box-shadow 0.2s ease;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
[data-mk-fb-rule] input {
|
|
113
|
+
width: 9rem;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
[data-mk-fb-rule] input:focus-visible {
|
|
117
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--mk-accent) 35%, transparent);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
[data-mk-fb-rule] input[aria-invalid='true'] {
|
|
121
|
+
box-shadow: 0 0 0 2px var(--mk-error, #c62828);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
[data-mk-fb-values] {
|
|
125
|
+
display: inline-flex;
|
|
126
|
+
flex-wrap: wrap;
|
|
127
|
+
align-items: center;
|
|
128
|
+
gap: 0.4rem;
|
|
129
|
+
min-width: 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
[data-mk-fb-and] {
|
|
133
|
+
color: var(--mk-muted);
|
|
134
|
+
font-size: 0.8125rem;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
[data-mk-fb-remove],
|
|
138
|
+
[data-mk-fb-remove-group] {
|
|
139
|
+
display: grid;
|
|
140
|
+
flex: none;
|
|
141
|
+
place-items: center;
|
|
142
|
+
width: 2rem;
|
|
143
|
+
height: 2rem;
|
|
144
|
+
padding: 0;
|
|
145
|
+
border: 0;
|
|
146
|
+
border-radius: 8px;
|
|
147
|
+
background: transparent;
|
|
148
|
+
color: var(--mk-muted);
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
[data-mk-fb-remove-group] {
|
|
153
|
+
margin-left: auto;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
:is([data-mk-fb-remove], [data-mk-fb-remove-group]):hover {
|
|
157
|
+
background: color-mix(in srgb, var(--mk-error, #c62828) 12%, transparent);
|
|
158
|
+
color: var(--mk-error, #c62828);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
[data-mk-fb-connector] {
|
|
162
|
+
justify-self: start;
|
|
163
|
+
display: inline-grid;
|
|
164
|
+
place-items: center;
|
|
165
|
+
min-width: 1.6rem;
|
|
166
|
+
height: 1.4rem;
|
|
167
|
+
padding: 0 0.35rem;
|
|
168
|
+
border-radius: 999px;
|
|
169
|
+
background: var(--mk-accent-soft);
|
|
170
|
+
color: var(--mk-on-accent-soft, var(--mk-text));
|
|
171
|
+
font-size: 0.75rem;
|
|
172
|
+
font-weight: 700;
|
|
173
|
+
text-transform: uppercase;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
[data-mk-fb-actions] {
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-wrap: wrap;
|
|
179
|
+
gap: 0.4rem;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
[data-mk-fb-actions] button {
|
|
183
|
+
height: 2.1rem;
|
|
184
|
+
padding: 0 0.8rem;
|
|
185
|
+
border: 1px dashed var(--mk-outline);
|
|
186
|
+
border-radius: 10px;
|
|
187
|
+
background: transparent;
|
|
188
|
+
color: var(--mk-muted);
|
|
189
|
+
font: inherit;
|
|
190
|
+
font-size: 0.8125rem;
|
|
191
|
+
font-weight: 600;
|
|
192
|
+
cursor: pointer;
|
|
193
|
+
transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[data-mk-fb-actions] button:hover {
|
|
197
|
+
border-color: var(--mk-accent);
|
|
198
|
+
background: var(--mk-accent-soft);
|
|
199
|
+
color: var(--mk-on-accent-soft, var(--mk-text));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
:is([data-mk-fb-actions] button, [data-mk-fb-remove], [data-mk-fb-remove-group], [data-mk-fb-combinator] [role='radio']):focus-visible {
|
|
203
|
+
outline: 2px solid var(--mk-accent);
|
|
204
|
+
outline-offset: 2px;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
[data-mk-fb-summary] {
|
|
208
|
+
margin: 0;
|
|
209
|
+
color: var(--mk-muted);
|
|
210
|
+
font-size: 0.875rem;
|
|
211
|
+
line-height: 1.5;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@media (max-width: 480px) {
|
|
215
|
+
[data-mk-fb-rule] :is(.mk-select, input) {
|
|
216
|
+
flex: 1 1 8rem;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@media (prefers-reduced-motion: reduce) {
|
|
221
|
+
[data-mk-fb-combinator] [role='radio'],
|
|
222
|
+
[data-mk-fb-actions] button,
|
|
223
|
+
[data-mk-fb-rule] input {
|
|
224
|
+
transition: none;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import type { FilterGroup } from '../../core/filter';
|
|
5
|
+
import { createFilterBuilder, type FilterBuilderInstance, type FilterBuilderOptions } from './engine';
|
|
6
|
+
|
|
7
|
+
export interface FilterBuilderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'>, FilterBuilderOptions {
|
|
8
|
+
/** Controlled filter; without it the builder keeps its own (defaultValue). */
|
|
9
|
+
value?: FilterGroup;
|
|
10
|
+
defaultValue?: FilterGroup;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** <FilterBuilder fields={fields} value={filter} onChange={setFilter} />. */
|
|
14
|
+
export function FilterBuilder({ fields, value, defaultValue, maxDepth, label, summary, onChange, className, ...props }: FilterBuilderProps) {
|
|
15
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
16
|
+
const instance = useRef<FilterBuilderInstance | null>(null);
|
|
17
|
+
const change = useLatest(onChange);
|
|
18
|
+
const start = useRef(value ?? defaultValue);
|
|
19
|
+
const fieldsKey = JSON.stringify(fields);
|
|
20
|
+
useIsomorphicLayoutEffect(() => {
|
|
21
|
+
const created = createFilterBuilder(ref.current, { fields, value: value ?? start.current, maxDepth, label, summary, onChange: (next) => change.current?.(next) });
|
|
22
|
+
instance.current = created;
|
|
23
|
+
return () => {
|
|
24
|
+
start.current = created.value;
|
|
25
|
+
created.destroy();
|
|
26
|
+
instance.current = null;
|
|
27
|
+
};
|
|
28
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
+
}, [fieldsKey, maxDepth, label, summary]);
|
|
30
|
+
const valueKey = JSON.stringify(value ?? null);
|
|
31
|
+
useIsomorphicLayoutEffect(() => {
|
|
32
|
+
if (value && instance.current && JSON.stringify(instance.current.value) !== valueKey) instance.current.setValue(value);
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
}, [valueKey]);
|
|
35
|
+
return <div {...props} ref={ref} className={['mk-filter-builder', className].filter(Boolean).join(' ')} />;
|
|
36
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# heatmap-chart
|
|
2
|
+
|
|
3
|
+
Calendario de actividad tipo GitHub con intensidad por día, tooltips y desplazamiento horizontal.
|
|
4
|
+
|
|
5
|
+
## Instalación
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import '@yewdiel21/motion-kit/css';
|
|
9
|
+
import { HeatmapChart } from '@yewdiel21/motion-kit/react';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx @yewdiel21/motion-kit add heatmap-chart --react --elements
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## React
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
<HeatmapChart end="2026-10-31" weeks={26} data={{ "2026-10-30": 4, "2026-10-31": 8 }} unit="sesiones" locale="es-MX" />
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Los callbacks del ejemplo (`ask`, `run`, `setTool`, `setVolume`) pertenecen a tu aplicación. React acepta `className`, `style` y atributos HTML. Los componentes con estado exponen `instanceRef` (excepto PillButton).
|
|
23
|
+
|
|
24
|
+
## HTML / Astro
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<mk-heatmap-chart end="2026-10-31" weeks="26" data='{"2026-10-30":4,"2026-10-31":8}'></mk-heatmap-chart>
|
|
28
|
+
<script type="module">
|
|
29
|
+
import { defineElements } from '@yewdiel21/motion-kit/elements';
|
|
30
|
+
defineElements(['mk-heatmap-chart']);
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
En Astro usa un `<script>` procesado por Astro. En HTML directo el import requiere bundler o import map. También puedes usar `import { createHeatmapChart } from '@yewdiel21/motion-kit'` y llamar a la factory con el contenedor y las mismas opciones. Al desmontar, llama a `instance.destroy()`.
|
|
35
|
+
|
|
36
|
+
## Opciones
|
|
37
|
+
|
|
38
|
+
data: {date, value}[] o mapa YYYY-MM-DD a valor. end: hoy. weeks: 53. firstDay: 1 (lunes). levels: 4. color: acento. locale, unit, legend. onSelect(date, value). Instancia: select(date | null), update(options), selected.
|
|
39
|
+
|
|
40
|
+
Todos los gráficos aceptan `label`, `emptyLabel` y `formatValue`. Se actualizan con `update(options)` sin desmontarse; `select(index | null)` y `selected` controlan la selección (en heatmap se usa una fecha). `onSelect` también emite `mk:select`.
|
|
41
|
+
|
|
42
|
+
Los nombres camelCase se escriben como atributos kebab-case. Los arrays y objetos se pasan como JSON. Los booleanos aceptan atributo vacío o `"false"`.
|
|
43
|
+
|
|
44
|
+
## Estilos y accesibilidad
|
|
45
|
+
|
|
46
|
+
Variables: --mk-heatmap-color, --mk-heatmap-empty; --mk-chart-surface.
|
|
47
|
+
|
|
48
|
+
Respeta los colores del tema, foco visible y `prefers-reduced-motion`. Los gráficos incluyen una tabla accesible y selección con flechas, Home, End y Escape. Heatmap usa arriba/abajo para un día e izquierda/derecha para una semana. Toolbar usa flechas y Home/End; OrbitMenu cierra con Escape y devuelve el foco. Los controles conservan nombres accesibles; VoiceDots anuncia los estados sin leer cada fotograma.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createHeatmapChart, type HeatmapChartInstance, type HeatmapChartOptions } from './engine';
|
|
3
|
+
|
|
4
|
+
/** <mk-heatmap-chart></mk-heatmap-chart> */
|
|
5
|
+
export class MkHeatmapChartElement extends MkElement<HeatmapChartInstance> {
|
|
6
|
+
static options: Record<string, OptionType> = { data: 'json', end: 'string', weeks: 'number', firstDay: 'number', locale: 'string', levels: 'number', color: 'string', unit: 'string', label: 'string', legend: 'boolean', emptyLabel: 'string' };
|
|
7
|
+
|
|
8
|
+
protected create(options: Record<string, unknown>) {
|
|
9
|
+
return createHeatmapChart(this, options);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
attributeChangedCallback(_name: string, previous: string | null, next: string | null) {
|
|
13
|
+
if (previous === next || !this.instance) return;
|
|
14
|
+
this.instance.update({ legend: undefined, color: undefined, ...this.options });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
update(options: HeatmapChartOptions) { this.instance?.update(options); }
|
|
18
|
+
select(date: string | null) { this.instance?.select(date); }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const defineHeatmapChart = () => defineElement('mk-heatmap-chart', MkHeatmapChartElement);
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { gsap, EASE, registerMotion } from '../../core/gsap';
|
|
2
|
+
import { addDays, capitalize, dayKey, safeFormat, startOfWeek, toDate, weekdayNames, type DateInput } from '../../core/dates';
|
|
3
|
+
import { reduced } from '../../core/reduced';
|
|
4
|
+
import { createScope } from '../../core/scope';
|
|
5
|
+
import { inert, type Instance } from '../../core/types';
|
|
6
|
+
import { chartFrame, finite, formatNumber, onWidth, round, svg } from '../chart/parts';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Heatmap chart: daily activity on a calendar, a column per week like
|
|
10
|
+
* GitHub's, in chart's family. Each day is a 3 px rounded cell whose colour
|
|
11
|
+
* deepens in steps (four by default) from the track to the accent. The cells
|
|
12
|
+
* pop in along the diagonal, oldest first (.35 s, 8 ms apart); new data
|
|
13
|
+
* crossfades their colours. Pointing at a day (or the arrows: up and down a
|
|
14
|
+
* day, left and right a week, PageUp/PageDown four) lifts it with a ring and
|
|
15
|
+
* the tooltip says its value and date; the "less … more" scale lights the
|
|
16
|
+
* days of a step. Narrow screens scroll the weeks, ending on the latest.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export interface HeatmapDatum {
|
|
20
|
+
date: DateInput;
|
|
21
|
+
value: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface HeatmapChartOptions {
|
|
25
|
+
/** Values by day: a list or a { 'YYYY-MM-DD': value } map. */
|
|
26
|
+
data?: HeatmapDatum[] | Record<string, number>;
|
|
27
|
+
/** The last day shown (default: today). */
|
|
28
|
+
end?: DateInput;
|
|
29
|
+
/** Weeks shown (default 53). */
|
|
30
|
+
weeks?: number;
|
|
31
|
+
/** First day of the week, 0 Sunday … 6 Saturday (default 1, Monday). */
|
|
32
|
+
firstDay?: number;
|
|
33
|
+
locale?: string;
|
|
34
|
+
/** Coloured steps above zero (default 4). */
|
|
35
|
+
levels?: number;
|
|
36
|
+
/** The deepest step's colour (default the accent). */
|
|
37
|
+
color?: string;
|
|
38
|
+
/** What a value counts, for the tooltip (default 'actividades'). */
|
|
39
|
+
unit?: string;
|
|
40
|
+
label?: string;
|
|
41
|
+
/** The "less … more" scale (default true). */
|
|
42
|
+
legend?: boolean;
|
|
43
|
+
formatValue?: (value: number) => string;
|
|
44
|
+
emptyLabel?: string;
|
|
45
|
+
onSelect?: (date: string | null, value: number | null) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface HeatmapChartInstance extends Instance {
|
|
49
|
+
update(options: HeatmapChartOptions): void;
|
|
50
|
+
/** Choose a day ('YYYY-MM-DD') or none. */
|
|
51
|
+
select(date: string | null): void;
|
|
52
|
+
readonly selected: string | null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const LEFT = 28;
|
|
56
|
+
const TOP = 18;
|
|
57
|
+
|
|
58
|
+
export function createHeatmapChart(root: HTMLElement | null, initial: HeatmapChartOptions = {}): HeatmapChartInstance {
|
|
59
|
+
if (!root) return inert({ update() {}, select() {}, selected: null });
|
|
60
|
+
registerMotion();
|
|
61
|
+
const scope = createScope();
|
|
62
|
+
const frame = chartFrame(root, scope, 'heatmap');
|
|
63
|
+
const { plot, canvas, keep } = frame;
|
|
64
|
+
let options: HeatmapChartOptions = { ...initial };
|
|
65
|
+
let selected: number | null = null;
|
|
66
|
+
|
|
67
|
+
// The weeks scroll inside the plot; the tooltip stays over it, unclipped.
|
|
68
|
+
const scroller = document.createElement('div');
|
|
69
|
+
scroller.dataset.mkHeatmapScroll = '';
|
|
70
|
+
plot.prepend(scroller);
|
|
71
|
+
scroller.append(canvas);
|
|
72
|
+
scope.add(() => scroller.remove());
|
|
73
|
+
|
|
74
|
+
const scale = document.createElement('div');
|
|
75
|
+
scale.dataset.mkHeatmapScale = '';
|
|
76
|
+
scale.setAttribute('aria-hidden', 'true');
|
|
77
|
+
root.insertBefore(scale, frame.legend);
|
|
78
|
+
scope.add(() => scale.remove());
|
|
79
|
+
|
|
80
|
+
const locale = () => options.locale ?? (document.documentElement.lang || 'es');
|
|
81
|
+
const format = (value: number) => (options.formatValue ? options.formatValue(value) : formatNumber(value));
|
|
82
|
+
const levels = () => Math.max(1, Math.min(8, Math.round(options.levels ?? 4)));
|
|
83
|
+
|
|
84
|
+
const modelOf = () => {
|
|
85
|
+
const values = new Map<string, number>();
|
|
86
|
+
const add = (key: string, value: number) => finite(value) && values.set(key, (values.get(key) ?? 0) + value);
|
|
87
|
+
if (Array.isArray(options.data)) for (const datum of options.data) add(dayKey(toDate(datum.date)), datum.value);
|
|
88
|
+
else if (options.data) for (const [key, value] of Object.entries(options.data)) add(dayKey(toDate(key)), value);
|
|
89
|
+
const weeks = Math.max(1, Math.min(106, Math.round(options.weeks ?? 53)));
|
|
90
|
+
const firstDay = Number.isInteger(options.firstDay) && options.firstDay! >= 0 && options.firstDay! <= 6 ? options.firstDay! : 1;
|
|
91
|
+
const end = toDate(options.end ?? new Date());
|
|
92
|
+
const start = startOfWeek(addDays(end, -(weeks - 1) * 7), firstDay);
|
|
93
|
+
const days: Array<{ key: string; date: Date; value: number; week: number; day: number }> = [];
|
|
94
|
+
for (let date = start, i = 0; date <= end; date = addDays(date, 1), i++) {
|
|
95
|
+
const key = dayKey(date);
|
|
96
|
+
days.push({ key, date, value: values.get(key) ?? 0, week: Math.floor(i / 7), day: i % 7 });
|
|
97
|
+
}
|
|
98
|
+
const max = Math.max(0, ...days.map((each) => each.value));
|
|
99
|
+
return { days, weeks: (days[days.length - 1]?.week ?? 0) + 1, firstDay, max, total: days.reduce((sum, each) => sum + each.value, 0) };
|
|
100
|
+
};
|
|
101
|
+
let model = modelOf();
|
|
102
|
+
const levelOf = (value: number) => (value <= 0 || !model.max ? 0 : Math.max(1, Math.ceil((value / model.max) * levels())));
|
|
103
|
+
const fillOf = (level: number) => (level === 0 ? 'var(--mk-heatmap-empty)' : `color-mix(in srgb, ${options.color ?? 'var(--mk-heatmap-color)'} ${Math.round(22 + (78 * level) / levels())}%, var(--mk-heatmap-empty))`);
|
|
104
|
+
|
|
105
|
+
let cells: SVGRectElement[] = [];
|
|
106
|
+
/** The first day drawn: the same days keep their cells. */
|
|
107
|
+
let builtFrom = '';
|
|
108
|
+
let geometry = { cell: 12, gap: 3, width: 0, height: 0 };
|
|
109
|
+
const longDate = () => safeFormat(locale(), { weekday: 'short', day: 'numeric', month: 'long', year: 'numeric' });
|
|
110
|
+
|
|
111
|
+
const build = (animate: boolean) => {
|
|
112
|
+
canvas.replaceChildren();
|
|
113
|
+
const available = Math.max(0, (plot.clientWidth || root.clientWidth || 0) - LEFT);
|
|
114
|
+
const gap = 3;
|
|
115
|
+
// Cells fill the width between 10 and 14 px; past that the weeks scroll.
|
|
116
|
+
const fit = available ? Math.floor(available / model.weeks - gap) : 12;
|
|
117
|
+
const cell = Math.max(10, Math.min(14, fit));
|
|
118
|
+
const width = LEFT + model.weeks * (cell + gap);
|
|
119
|
+
const height = TOP + 7 * (cell + gap);
|
|
120
|
+
geometry = { cell, gap, width, height };
|
|
121
|
+
canvas.setAttribute('viewBox', `0 0 ${width} ${height}`);
|
|
122
|
+
canvas.setAttribute('width', String(width));
|
|
123
|
+
canvas.setAttribute('height', String(height));
|
|
124
|
+
plot.style.setProperty('--mk-heatmap-width', `${width}px`);
|
|
125
|
+
|
|
126
|
+
// Month names over the week where each month starts; weekday names on every other row.
|
|
127
|
+
const months = svg('g', { 'data-mk-part': 'months' });
|
|
128
|
+
const monthName = safeFormat(locale(), { month: 'short' });
|
|
129
|
+
let last = -1;
|
|
130
|
+
for (const each of model.days) {
|
|
131
|
+
if (each.day !== 0) continue;
|
|
132
|
+
const month = addDays(each.date, 6).getMonth();
|
|
133
|
+
if (month === last) continue;
|
|
134
|
+
last = month;
|
|
135
|
+
if (each.week > model.weeks - 2 && model.weeks > 4) continue;
|
|
136
|
+
const text = svg('text', { x: LEFT + each.week * (cell + gap), y: 10 });
|
|
137
|
+
text.textContent = capitalize(monthName.format(addDays(each.date, 6)).replace('.', ''));
|
|
138
|
+
months.append(text);
|
|
139
|
+
}
|
|
140
|
+
const names = weekdayNames(locale(), model.firstDay, 'short');
|
|
141
|
+
const weekdays = svg('g', { 'data-mk-part': 'weekdays' });
|
|
142
|
+
[1, 3, 5].forEach((row) => {
|
|
143
|
+
const text = svg('text', { x: 0, y: round(TOP + row * (cell + gap) + cell / 2), 'dominant-baseline': 'middle' });
|
|
144
|
+
text.textContent = capitalize(names[row]!.replace('.', '')).slice(0, 3);
|
|
145
|
+
weekdays.append(text);
|
|
146
|
+
});
|
|
147
|
+
const grid = svg('g', { 'data-mk-part': 'cells' });
|
|
148
|
+
cells = model.days.map((each, i) => {
|
|
149
|
+
const rect = svg('rect', { x: LEFT + each.week * (cell + gap), y: TOP + each.day * (cell + gap), width: cell, height: cell, rx: 3, 'data-mk-index': i, 'data-mk-level': levelOf(each.value) });
|
|
150
|
+
rect.style.fill = fillOf(levelOf(each.value));
|
|
151
|
+
grid.append(rect);
|
|
152
|
+
return rect;
|
|
153
|
+
});
|
|
154
|
+
canvas.append(months, weekdays, grid);
|
|
155
|
+
builtFrom = model.days[0]?.key ?? '';
|
|
156
|
+
// The latest weeks in view when they scroll.
|
|
157
|
+
scroller.scrollLeft = scroller.scrollWidth;
|
|
158
|
+
if (animate && !reduced()) keep(gsap.fromTo(cells, { opacity: 0, scale: 0.3 }, { opacity: 1, scale: 1, duration: 0.35, ease: EASE.pop, clearProps: 'opacity,transform', stagger: (i: number) => Math.min(0.7, (model.days[i]!.week + model.days[i]!.day) * 0.008) }));
|
|
159
|
+
};
|
|
160
|
+
scope.add(() => plot.style.removeProperty('--mk-heatmap-width'));
|
|
161
|
+
|
|
162
|
+
const paintScale = () => {
|
|
163
|
+
scale.replaceChildren();
|
|
164
|
+
scale.hidden = options.legend === false || !model.days.length;
|
|
165
|
+
if (scale.hidden) return;
|
|
166
|
+
const less = document.createElement('span');
|
|
167
|
+
less.textContent = 'Menos';
|
|
168
|
+
scale.append(less);
|
|
169
|
+
for (let level = 0; level <= levels(); level++) {
|
|
170
|
+
const swatch = document.createElement('i');
|
|
171
|
+
swatch.style.background = fillOf(level);
|
|
172
|
+
swatch.addEventListener('pointerenter', () => {
|
|
173
|
+
for (const cell of cells) cell.toggleAttribute('data-mk-dim', cell.getAttribute('data-mk-level') !== String(level));
|
|
174
|
+
});
|
|
175
|
+
swatch.addEventListener('pointerleave', () => {
|
|
176
|
+
for (const cell of cells) cell.removeAttribute('data-mk-dim');
|
|
177
|
+
});
|
|
178
|
+
scale.append(swatch);
|
|
179
|
+
}
|
|
180
|
+
const more = document.createElement('span');
|
|
181
|
+
more.textContent = 'Más';
|
|
182
|
+
scale.append(more);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const unit = () => options.unit ?? 'actividades';
|
|
186
|
+
const paintSelection = (announce: boolean) => {
|
|
187
|
+
cells.forEach((cell, i) => cell.toggleAttribute('data-mk-on', i === selected));
|
|
188
|
+
const each = selected === null ? null : model.days[selected];
|
|
189
|
+
if (!each) {
|
|
190
|
+
frame.tip(null);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const { cell, gap } = geometry;
|
|
194
|
+
const x = LEFT + each.week * (cell + gap) + cell / 2 - scroller.scrollLeft;
|
|
195
|
+
const y = TOP + each.day * (cell + gap);
|
|
196
|
+
const title = capitalize(longDate().format(each.date));
|
|
197
|
+
frame.tip({ x, y, title, rows: [{ name: unit(), color: fillOf(Math.max(1, levelOf(each.value))), value: format(each.value) }] });
|
|
198
|
+
if (announce) frame.live.textContent = `${title}: ${format(each.value)} ${unit()}`;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const draw = (animate: boolean) => {
|
|
202
|
+
const name = options.label ?? 'Actividad diaria';
|
|
203
|
+
canvas.setAttribute('aria-label', model.days.length ? `${name}. ${model.weeks} semanas, ${format(model.total)} ${unit()} en total. Usa las flechas para recorrer los días.` : `${name}: ${options.emptyLabel ?? 'sin datos'}`);
|
|
204
|
+
// The days with something, for screen readers (a year of empty rows says nothing).
|
|
205
|
+
const active = model.days.filter((each) => each.value > 0);
|
|
206
|
+
frame.fillTable(`${name}: ${format(model.total)} ${unit()}`, ['Día', capitalize(unit())], active.map((each) => [capitalize(longDate().format(each.date)), format(each.value)]));
|
|
207
|
+
frame.fillLegend([], false);
|
|
208
|
+
paintScale();
|
|
209
|
+
if (selected !== null && selected >= model.days.length) selected = null;
|
|
210
|
+
const same = cells.length === model.days.length && cells.length > 0 && builtFrom === model.days[0]!.key;
|
|
211
|
+
if (same && animate) {
|
|
212
|
+
// New values over the same days: the colours crossfade (CSS).
|
|
213
|
+
cells.forEach((cell, i) => {
|
|
214
|
+
const level = levelOf(model.days[i]!.value);
|
|
215
|
+
cell.setAttribute('data-mk-level', String(level));
|
|
216
|
+
cell.style.fill = fillOf(level);
|
|
217
|
+
});
|
|
218
|
+
} else build(animate);
|
|
219
|
+
paintSelection(false);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const select = (index: number | null, announce = false) => {
|
|
223
|
+
if (scope.disposed) return;
|
|
224
|
+
const next = index === null || !model.days.length ? null : Math.max(0, Math.min(model.days.length - 1, Math.round(index)));
|
|
225
|
+
if (next === selected) return;
|
|
226
|
+
selected = next;
|
|
227
|
+
paintSelection(announce);
|
|
228
|
+
const each = selected === null ? null : model.days[selected]!;
|
|
229
|
+
options.onSelect?.(each?.key ?? null, each?.value ?? null);
|
|
230
|
+
root.dispatchEvent(new CustomEvent('mk:select', { bubbles: true, detail: { date: each?.key ?? null, value: each?.value ?? null } }));
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
scope.on(canvas, 'pointermove', (event) => {
|
|
234
|
+
const cell = (event.target as Element).closest('[data-mk-index]');
|
|
235
|
+
select(cell ? Number(cell.getAttribute('data-mk-index')) : null);
|
|
236
|
+
});
|
|
237
|
+
scope.on(canvas, 'pointerleave', (event) => {
|
|
238
|
+
if ((event as PointerEvent).pointerType === 'mouse') select(null);
|
|
239
|
+
});
|
|
240
|
+
scope.on(canvas, 'focus', () => {
|
|
241
|
+
if (selected === null && model.days.length) select(model.days.length - 1, true);
|
|
242
|
+
});
|
|
243
|
+
scope.on(canvas, 'blur', () => select(null));
|
|
244
|
+
scope.on(canvas, 'keydown', (event) => {
|
|
245
|
+
const key = (event as KeyboardEvent).key;
|
|
246
|
+
const at = selected ?? model.days.length - 1;
|
|
247
|
+
const moves: Record<string, number | null> = { ArrowUp: at - 1, ArrowDown: at + 1, ArrowLeft: at - 7, ArrowRight: at + 7, PageUp: at - 28, PageDown: at + 28, Home: 0, End: model.days.length - 1, Escape: null };
|
|
248
|
+
if (!(key in moves) || !model.days.length) return;
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
select(moves[key]!, true);
|
|
251
|
+
// Keep the chosen day in view when the weeks scroll.
|
|
252
|
+
const cell = selected === null ? null : cells[selected];
|
|
253
|
+
if (cell) {
|
|
254
|
+
const x = Number(cell.getAttribute('x'));
|
|
255
|
+
if (x - scroller.scrollLeft < LEFT || x - scroller.scrollLeft > scroller.clientWidth - geometry.cell * 2) scroller.scrollLeft = x - scroller.clientWidth / 2;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
onWidth(root, scope, () => {
|
|
259
|
+
build(false);
|
|
260
|
+
paintSelection(false);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
draw(true);
|
|
264
|
+
|
|
265
|
+
return {
|
|
266
|
+
update(next) {
|
|
267
|
+
if (scope.disposed) return;
|
|
268
|
+
options = { ...options, ...next };
|
|
269
|
+
model = modelOf();
|
|
270
|
+
draw(true);
|
|
271
|
+
},
|
|
272
|
+
select(date) {
|
|
273
|
+
const index = date === null ? -1 : model.days.findIndex((each) => each.key === date);
|
|
274
|
+
select(index < 0 ? null : index);
|
|
275
|
+
},
|
|
276
|
+
get selected() {
|
|
277
|
+
return selected === null ? null : (model.days[selected]?.key ?? null);
|
|
278
|
+
},
|
|
279
|
+
destroy: () => scope.dispose(),
|
|
280
|
+
};
|
|
281
|
+
}
|