@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,283 @@
|
|
|
1
|
+
import { gsap, EASE, registerMotion } from '../../core/gsap';
|
|
2
|
+
import { reduced } from '../../core/reduced';
|
|
3
|
+
import { createScope } from '../../core/scope';
|
|
4
|
+
import { inert, type Instance } from '../../core/types';
|
|
5
|
+
import { blurIn, rollDigits } from '../../motion/micro';
|
|
6
|
+
import { arcPath, chartFrame, finite, formatNumber, onWidth, polar, round, slotColor, svg } from '../chart/parts';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Pie chart: parts of a whole as a donut (default) or a pie, in chart's family
|
|
10
|
+
* (colour slots, inverse-glass tooltip, outlined legend, a table for screen
|
|
11
|
+
* readers). Slices sweep in clockwise from 12 o'clock on the swatch curve
|
|
12
|
+
* (.38,.49,0,1.5) while the total in the middle rolls up; new data glides each
|
|
13
|
+
* slice from its old angles. Pointing at a slice (or its legend pill, or the
|
|
14
|
+
* arrows) pulls it out along its middle and dims the others; the middle of a
|
|
15
|
+
* donut then says the slice, its value and share, else the tooltip does.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface PieSlice {
|
|
19
|
+
label: string;
|
|
20
|
+
value: number;
|
|
21
|
+
color?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PieChartOptions {
|
|
25
|
+
data?: PieSlice[];
|
|
26
|
+
/** Hole size as a share of the radius: 0 is a pie (default 0.62). */
|
|
27
|
+
donut?: number;
|
|
28
|
+
/** Degrees of surface between slices (default 1.5). */
|
|
29
|
+
gap?: number;
|
|
30
|
+
/** Diameter in px (default 240; it shrinks with its container). */
|
|
31
|
+
size?: number;
|
|
32
|
+
/** Accessible name (and table caption). */
|
|
33
|
+
label?: string;
|
|
34
|
+
/** The donut's middle when nothing is chosen (default 'Total'). */
|
|
35
|
+
totalLabel?: string;
|
|
36
|
+
legend?: boolean;
|
|
37
|
+
formatValue?: (value: number) => string;
|
|
38
|
+
emptyLabel?: string;
|
|
39
|
+
onSelect?: (index: number | null) => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface PieChartInstance extends Instance {
|
|
43
|
+
update(options: PieChartOptions): void;
|
|
44
|
+
select(index: number | null): void;
|
|
45
|
+
readonly selected: number | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const PULL = 7;
|
|
49
|
+
|
|
50
|
+
export function createPieChart(root: HTMLElement | null, initial: PieChartOptions = {}): PieChartInstance {
|
|
51
|
+
if (!root) return inert({ update() {}, select() {}, selected: null });
|
|
52
|
+
registerMotion();
|
|
53
|
+
const scope = createScope();
|
|
54
|
+
const frame = chartFrame(root, scope, 'pie');
|
|
55
|
+
const { plot, canvas, keep } = frame;
|
|
56
|
+
let options: PieChartOptions = { ...initial };
|
|
57
|
+
let selected: number | null = null;
|
|
58
|
+
|
|
59
|
+
const center = document.createElement('div');
|
|
60
|
+
center.dataset.mkPieCenter = '';
|
|
61
|
+
center.setAttribute('aria-hidden', 'true');
|
|
62
|
+
const centerValue = document.createElement('strong');
|
|
63
|
+
const centerLabel = document.createElement('span');
|
|
64
|
+
center.append(centerValue, centerLabel);
|
|
65
|
+
plot.append(center);
|
|
66
|
+
scope.add(() => center.remove());
|
|
67
|
+
|
|
68
|
+
const format = (value: number) => (options.formatValue ? options.formatValue(value) : formatNumber(value));
|
|
69
|
+
const slices = () =>
|
|
70
|
+
(options.data ?? [])
|
|
71
|
+
.filter((slice) => finite(slice.value) && slice.value > 0)
|
|
72
|
+
.map((slice, i, all) => ({ label: String(slice.label), value: slice.value, color: slice.color ?? slotColor(i, Math.max(2, all.length)) }));
|
|
73
|
+
let model = slices();
|
|
74
|
+
const total = () => model.reduce((sum, slice) => sum + slice.value, 0);
|
|
75
|
+
const share = (value: number) => new Intl.NumberFormat(undefined, { style: 'percent', maximumFractionDigits: 1 }).format(value / (total() || 1));
|
|
76
|
+
const donut = () => Math.min(0.9, Math.max(0, finite(options.donut) ? options.donut : 0.62));
|
|
77
|
+
|
|
78
|
+
/** Each slice's angles for `values` (fractions of a turn, with the gap taken from both sides). */
|
|
79
|
+
const anglesOf = (values: number[]) => {
|
|
80
|
+
const sum = values.reduce((a, b) => a + b, 0) || 1;
|
|
81
|
+
const pad = values.filter((v) => v > 0).length > 1 ? ((finite(options.gap) ? options.gap : 1.5) * Math.PI) / 180 : 0;
|
|
82
|
+
let at = 0;
|
|
83
|
+
return values.map((value) => {
|
|
84
|
+
const sweep = (value / sum) * Math.PI * 2;
|
|
85
|
+
const a0 = at + Math.min(pad / 2, sweep / 4);
|
|
86
|
+
const a1 = at + sweep - Math.min(pad / 2, sweep / 4);
|
|
87
|
+
at += sweep;
|
|
88
|
+
return [a0, Math.max(a0, a1)] as [number, number];
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
let paths: SVGPathElement[] = [];
|
|
93
|
+
let shown: Array<[number, number]> = [];
|
|
94
|
+
let geometry = { size: 240, cx: 120, cy: 120, outer: 112, inner: 70 };
|
|
95
|
+
let glide: gsap.core.Tween | null = null;
|
|
96
|
+
scope.add(() => glide?.kill());
|
|
97
|
+
|
|
98
|
+
const measure = () => {
|
|
99
|
+
const width = Math.round(plot.clientWidth || root.clientWidth || 0);
|
|
100
|
+
const wanted = finite(options.size) ? options.size : 240;
|
|
101
|
+
const size = Math.max(120, width ? Math.min(wanted, width) : wanted);
|
|
102
|
+
const outer = size / 2 - PULL - 2;
|
|
103
|
+
geometry = { size, cx: size / 2, cy: size / 2, outer, inner: outer * donut() };
|
|
104
|
+
canvas.setAttribute('viewBox', `0 0 ${size} ${size}`);
|
|
105
|
+
canvas.setAttribute('width', String(size));
|
|
106
|
+
canvas.setAttribute('height', String(size));
|
|
107
|
+
plot.style.setProperty('--mk-pie-size', `${size}px`);
|
|
108
|
+
};
|
|
109
|
+
scope.add(() => plot.style.removeProperty('--mk-pie-size'));
|
|
110
|
+
|
|
111
|
+
const paint = (angles: Array<[number, number]>) => {
|
|
112
|
+
shown = angles;
|
|
113
|
+
const { cx, cy, outer, inner } = geometry;
|
|
114
|
+
paths.forEach((path, i) => {
|
|
115
|
+
const [a0, a1] = angles[i] ?? [0, 0];
|
|
116
|
+
path.setAttribute('d', a1 - a0 > 1e-4 ? arcPath(cx, cy, outer, inner, a0, a1) : '');
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const build = () => {
|
|
121
|
+
canvas.replaceChildren();
|
|
122
|
+
const group = svg('g', { 'data-mk-part': 'series' });
|
|
123
|
+
paths = model.map((slice, i) => {
|
|
124
|
+
const path = svg('path', { 'data-mk-index': i });
|
|
125
|
+
path.style.fill = slice.color;
|
|
126
|
+
group.append(path);
|
|
127
|
+
return path;
|
|
128
|
+
});
|
|
129
|
+
canvas.append(group);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const paintCenter = (animate: boolean) => {
|
|
133
|
+
center.hidden = donut() < 0.35 || !model.length;
|
|
134
|
+
if (center.hidden) return;
|
|
135
|
+
const slice = selected === null ? null : model[selected];
|
|
136
|
+
const text = slice ? format(slice.value) : format(total());
|
|
137
|
+
const caption = slice ? `${slice.label} · ${share(slice.value)}` : (options.totalLabel ?? 'Total');
|
|
138
|
+
const changed = centerLabel.textContent !== caption;
|
|
139
|
+
if (centerValue.textContent !== text) {
|
|
140
|
+
if (animate && !reduced() && centerValue.textContent) keep(rollDigits(centerValue, text, 1, 0.35));
|
|
141
|
+
else centerValue.textContent = text;
|
|
142
|
+
}
|
|
143
|
+
centerLabel.textContent = caption;
|
|
144
|
+
if (changed && animate && !reduced()) keep(blurIn(centerLabel, { from: 'soft', duration: 0.3 }));
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const paintSelection = (announce: boolean) => {
|
|
148
|
+
const { outer } = geometry;
|
|
149
|
+
paths.forEach((path, i) => {
|
|
150
|
+
const chosen = i === selected;
|
|
151
|
+
path.toggleAttribute('data-mk-dim', selected !== null && !chosen);
|
|
152
|
+
if (!chosen) {
|
|
153
|
+
path.style.transform = '';
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const [a0, a1] = shown[i] ?? [0, 0];
|
|
157
|
+
const [dx, dy] = polar(0, 0, Math.min(PULL, outer * 0.06), (a0 + a1) / 2);
|
|
158
|
+
path.style.transform = `translate(${round(dx)}px, ${round(dy)}px)`;
|
|
159
|
+
});
|
|
160
|
+
legendItems.forEach((item, i) => item.toggleAttribute('data-mk-dim', selected !== null && i !== selected));
|
|
161
|
+
paintCenter(true);
|
|
162
|
+
const slice = selected === null ? null : model[selected];
|
|
163
|
+
// The tooltip speaks for a pie (a donut's middle already does).
|
|
164
|
+
if (slice && center.hidden) {
|
|
165
|
+
const [a0, a1] = shown[selected!] ?? [0, 0];
|
|
166
|
+
const [x, y] = polar(geometry.cx, geometry.cy, geometry.outer * 0.7, (a0 + a1) / 2);
|
|
167
|
+
frame.tip({ x, y, title: slice.label, rows: [{ name: share(slice.value), color: slice.color, value: format(slice.value) }] });
|
|
168
|
+
} else frame.tip(null);
|
|
169
|
+
if (announce && slice) frame.live.textContent = `${slice.label}: ${format(slice.value)}, ${share(slice.value)}`;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
let legendItems: HTMLLIElement[] = [];
|
|
173
|
+
const draw = (animate: boolean) => {
|
|
174
|
+
glide?.kill();
|
|
175
|
+
const before = shown;
|
|
176
|
+
const sameCount = paths.length === model.length;
|
|
177
|
+
const name = options.label ?? 'Gráfica circular';
|
|
178
|
+
canvas.setAttribute('aria-label', model.length ? `${name}. ${model.length} partes, total ${format(total())}. Usa las flechas para recorrerlas.` : `${name}: ${options.emptyLabel ?? 'sin datos'}`);
|
|
179
|
+
frame.fillTable(name, ['Parte', 'Valor', 'Porcentaje'], model.map((slice) => [slice.label, format(slice.value), share(slice.value)]));
|
|
180
|
+
legendItems = frame.fillLegend(model.map((slice) => ({ name: slice.label, color: slice.color })), options.legend ?? true);
|
|
181
|
+
legendItems.forEach((item, i) => {
|
|
182
|
+
item.addEventListener('pointerenter', () => select(i));
|
|
183
|
+
item.addEventListener('pointerleave', () => select(null));
|
|
184
|
+
});
|
|
185
|
+
frame.empty.hidden = model.length > 0;
|
|
186
|
+
frame.empty.textContent = options.emptyLabel ?? 'Sin datos para mostrar';
|
|
187
|
+
plot.hidden = !model.length;
|
|
188
|
+
if (!model.length) {
|
|
189
|
+
canvas.replaceChildren();
|
|
190
|
+
paths = [];
|
|
191
|
+
shown = [];
|
|
192
|
+
selected = null;
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (selected !== null && selected >= model.length) selected = null;
|
|
196
|
+
measure();
|
|
197
|
+
if (!sameCount || !before.length) build();
|
|
198
|
+
paths.forEach((path, i) => { path.style.fill = model[i]!.color; });
|
|
199
|
+
const target = anglesOf(model.map((slice) => slice.value));
|
|
200
|
+
const done = () => {
|
|
201
|
+
paint(target);
|
|
202
|
+
paintSelection(false);
|
|
203
|
+
};
|
|
204
|
+
if (!animate || reduced()) return done();
|
|
205
|
+
const state = { t: 0 };
|
|
206
|
+
if (sameCount && before.length) {
|
|
207
|
+
// New data: every slice glides from its old angles.
|
|
208
|
+
glide = gsap.to(state, {
|
|
209
|
+
t: 1,
|
|
210
|
+
duration: 0.6,
|
|
211
|
+
ease: EASE.swatch,
|
|
212
|
+
onUpdate: () => paint(target.map(([a0, a1], i) => [before[i]![0] + (a0 - before[i]![0]) * state.t, before[i]![1] + (a1 - before[i]![1]) * state.t])),
|
|
213
|
+
onComplete: done,
|
|
214
|
+
});
|
|
215
|
+
paintCenter(true);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// First appearance: the slices sweep in clockwise from 12 o'clock and the total rolls up.
|
|
219
|
+
paint(target.map(() => [0, 0]));
|
|
220
|
+
centerValue.textContent = format(0);
|
|
221
|
+
glide = gsap.to(state, {
|
|
222
|
+
t: 1,
|
|
223
|
+
duration: 0.9,
|
|
224
|
+
ease: EASE.signature,
|
|
225
|
+
onUpdate: () => paint(target.map(([a0, a1]) => [a0 * state.t, a1 * state.t])),
|
|
226
|
+
onComplete: done,
|
|
227
|
+
});
|
|
228
|
+
paintCenter(true);
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const select = (index: number | null, announce = false) => {
|
|
232
|
+
if (scope.disposed) return;
|
|
233
|
+
const next = index === null || !model.length ? null : ((Math.round(index) % model.length) + model.length) % model.length;
|
|
234
|
+
if (next === selected) return;
|
|
235
|
+
selected = next;
|
|
236
|
+
paintSelection(announce);
|
|
237
|
+
options.onSelect?.(selected);
|
|
238
|
+
const slice = selected === null ? null : model[selected];
|
|
239
|
+
root.dispatchEvent(new CustomEvent('mk:select', { bubbles: true, detail: { index: selected, label: slice?.label ?? null, value: slice?.value ?? null } }));
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const indexAt = (event: PointerEvent) => {
|
|
243
|
+
const target = (event.target as Element).closest('[data-mk-index]');
|
|
244
|
+
return target ? Number(target.getAttribute('data-mk-index')) : null;
|
|
245
|
+
};
|
|
246
|
+
scope.on(canvas, 'pointermove', (event) => select(indexAt(event as PointerEvent)));
|
|
247
|
+
scope.on(canvas, 'pointerdown', (event) => select(indexAt(event as PointerEvent)));
|
|
248
|
+
scope.on(canvas, 'pointerleave', (event) => {
|
|
249
|
+
if ((event as PointerEvent).pointerType === 'mouse') select(null);
|
|
250
|
+
});
|
|
251
|
+
scope.on(canvas, 'focus', () => {
|
|
252
|
+
if (selected === null && model.length) select(0, true);
|
|
253
|
+
});
|
|
254
|
+
scope.on(canvas, 'blur', () => select(null));
|
|
255
|
+
scope.on(canvas, 'keydown', (event) => {
|
|
256
|
+
const key = (event as KeyboardEvent).key;
|
|
257
|
+
const moves: Record<string, number | null> = { ArrowRight: (selected ?? -1) + 1, ArrowDown: (selected ?? -1) + 1, ArrowLeft: (selected ?? 1) - 1, ArrowUp: (selected ?? 1) - 1, Home: 0, End: model.length - 1, Escape: null };
|
|
258
|
+
if (!(key in moves) || !model.length) return;
|
|
259
|
+
event.preventDefault();
|
|
260
|
+
select(moves[key]!, true);
|
|
261
|
+
});
|
|
262
|
+
onWidth(root, scope, () => {
|
|
263
|
+
measure();
|
|
264
|
+
paint(shown);
|
|
265
|
+
paintSelection(false);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
draw(true);
|
|
269
|
+
|
|
270
|
+
return {
|
|
271
|
+
update(next) {
|
|
272
|
+
if (scope.disposed) return;
|
|
273
|
+
options = { ...options, ...next };
|
|
274
|
+
model = slices();
|
|
275
|
+
draw(true);
|
|
276
|
+
},
|
|
277
|
+
select: (index) => select(index),
|
|
278
|
+
get selected() {
|
|
279
|
+
return selected;
|
|
280
|
+
},
|
|
281
|
+
destroy: () => scope.dispose(),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/* pie-chart — a donut (or pie) in chart's family: it needs chart.css for the colours, tooltip, legend and table.
|
|
2
|
+
Slices are parted by the surface; the chosen one slides out, the others dim; the donut's middle names it. */
|
|
3
|
+
.mk-pie-chart,
|
|
4
|
+
mk-pie-chart {
|
|
5
|
+
display: grid;
|
|
6
|
+
justify-items: center;
|
|
7
|
+
gap: 1rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[data-mk-chart-type='pie'] [data-mk-chart-plot] {
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[data-mk-chart-type='pie'] [data-mk-chart-svg] {
|
|
15
|
+
width: var(--mk-pie-size, 240px);
|
|
16
|
+
max-width: 100%;
|
|
17
|
+
margin-inline: auto;
|
|
18
|
+
border-radius: 50%;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[data-mk-chart-type='pie'] [data-mk-part='series'] path {
|
|
23
|
+
stroke: var(--mk-chart-surface);
|
|
24
|
+
stroke-width: 1;
|
|
25
|
+
stroke-linejoin: round;
|
|
26
|
+
transition:
|
|
27
|
+
transform 0.45s var(--mk-ease-swatch),
|
|
28
|
+
opacity 0.2s ease;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-mk-chart-type='pie'] [data-mk-part='series'] path[data-mk-dim] {
|
|
32
|
+
opacity: 0.4;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[data-mk-pie-center] {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: 50%;
|
|
38
|
+
left: 50%;
|
|
39
|
+
display: grid;
|
|
40
|
+
justify-items: center;
|
|
41
|
+
gap: 0.15rem;
|
|
42
|
+
max-width: calc(var(--mk-pie-size, 240px) * 0.5);
|
|
43
|
+
transform: translate(-50%, -50%);
|
|
44
|
+
text-align: center;
|
|
45
|
+
pointer-events: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[data-mk-pie-center][hidden] {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[data-mk-pie-center] strong {
|
|
53
|
+
color: var(--mk-text);
|
|
54
|
+
font-size: clamp(1.1rem, calc(var(--mk-pie-size, 240px) * 0.11), 2rem);
|
|
55
|
+
font-weight: 650;
|
|
56
|
+
font-variant-numeric: tabular-nums;
|
|
57
|
+
line-height: 1.1;
|
|
58
|
+
letter-spacing: -0.02em;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-mk-pie-center] span {
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
max-width: 100%;
|
|
64
|
+
color: var(--mk-muted);
|
|
65
|
+
font-size: 0.8125rem;
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
text-overflow: ellipsis;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[data-mk-chart-type='pie'] [data-mk-chart-legend] {
|
|
71
|
+
justify-content: center;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[data-mk-chart-type='pie'] [data-mk-chart-legend] li {
|
|
75
|
+
transition: opacity 0.2s ease;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[data-mk-chart-type='pie'] [data-mk-chart-legend] li[data-mk-dim] {
|
|
79
|
+
opacity: 0.45;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (prefers-reduced-motion: reduce) {
|
|
83
|
+
[data-mk-chart-type='pie'] [data-mk-part='series'] path {
|
|
84
|
+
transition: opacity 0.2s ease;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@media (forced-colors: active) {
|
|
89
|
+
[data-mk-chart-type='pie'] [data-mk-part='series'] path {
|
|
90
|
+
stroke: Canvas;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import type { HTMLAttributes } from 'react';
|
|
3
|
+
import { useChart } from '../chart/use-chart';
|
|
4
|
+
import { createPieChart, type PieChartInstance, type PieChartOptions } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface PieChartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect' | 'children'>, PieChartOptions {
|
|
7
|
+
instanceRef?: { current: PieChartInstance | null };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** <PieChart label="Ventas por canal" data={[{ label: 'Tienda', value: 420 }, …]} formatValue={money} /> */
|
|
11
|
+
export function PieChart({ data, donut, gap, size, label, totalLabel, legend, emptyLabel, formatValue, onSelect, instanceRef, className, ...props }: PieChartProps) {
|
|
12
|
+
const ref = useChart(createPieChart, { data, donut, gap, size, label, totalLabel, legend, emptyLabel } as PieChartOptions, { formatValue, onSelect }, instanceRef);
|
|
13
|
+
return <div {...props} ref={ref} className={['mk-chart mk-pie-chart', className].filter(Boolean).join(' ')} />;
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# pill-button
|
|
2
|
+
|
|
3
|
+
Botón píldora cuyo fondo se reúne alrededor del icono al pasar el puntero, enfocar o tocar.
|
|
4
|
+
|
|
5
|
+
## Instalación
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import '@yewdiel21/motion-kit/css';
|
|
9
|
+
import { PillButton } from '@yewdiel21/motion-kit/react';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx @yewdiel21/motion-kit add pill-button --react --elements
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## React
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
<PillButton onClick={ask}>Haz una pregunta</PillButton>
|
|
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-pill-button><button type="button">Haz una pregunta</button></mk-pill-button>
|
|
28
|
+
<script type="module">
|
|
29
|
+
import { defineElements } from '@yewdiel21/motion-kit/elements';
|
|
30
|
+
defineElements(['mk-pill-button']);
|
|
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 { createPillButton } 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
|
+
expand: invierte la animación (false). icon: marcado del icono en vanilla o ReactNode en React.
|
|
39
|
+
|
|
40
|
+
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"`.
|
|
41
|
+
|
|
42
|
+
## Estilos y accesibilidad
|
|
43
|
+
|
|
44
|
+
Variables: --mk-pill-height, --mk-pill-dot, --mk-pill-ink, --mk-pill-on-ink.
|
|
45
|
+
|
|
46
|
+
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,16 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createPillButton, type PillButtonInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-pill-button><button type="button">Haz una pregunta</button></mk-pill-button>
|
|
6
|
+
* The dark fill gathers into a circle around the arrow on hover. `expand` starts as the circle.
|
|
7
|
+
*/
|
|
8
|
+
export class MkPillButtonElement extends MkElement<PillButtonInstance> {
|
|
9
|
+
static options: Record<string, OptionType> = { expand: 'boolean', icon: 'string' };
|
|
10
|
+
|
|
11
|
+
protected create(options: Record<string, unknown>) {
|
|
12
|
+
return createPillButton(this, options);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const definePillButton = () => defineElement('mk-pill-button', MkPillButtonElement);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { registerMotion } from '../../core/gsap';
|
|
2
|
+
import { createScope } from '../../core/scope';
|
|
3
|
+
import { inert, type Instance } from '../../core/types';
|
|
4
|
+
import { press } from '../../motion/micro';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Pill button: a dark pill with a label and an arrow. When the pointer comes in
|
|
8
|
+
* (or the keyboard focuses it) the dark fill gathers into a circle around the
|
|
9
|
+
* icon on the swatch curve (.38,.49,0,1.5, a small overshoot), the label slides
|
|
10
|
+
* left and turns to the text colour, and the arrow nudges forward; leaving, the
|
|
11
|
+
* fill spreads back into the pill. `expand` turns it around: a circle by the
|
|
12
|
+
* label that spreads into the pill. The motion is CSS (pill-button.css); the
|
|
13
|
+
* engine builds the label, icon and fill when the markup lacks them, presses on
|
|
14
|
+
* click, and shows the gathered state for a moment after a tap on touch.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface PillButtonOptions {
|
|
18
|
+
/** Start as the circle and spread into the pill on hover (default false). */
|
|
19
|
+
expand?: boolean;
|
|
20
|
+
/** The icon's markup when the button has no [data-mk-pill-icon] (default: an arrow). */
|
|
21
|
+
icon?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
25
|
+
export interface PillButtonInstance extends Instance {}
|
|
26
|
+
|
|
27
|
+
export const PILL_ARROW =
|
|
28
|
+
'<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="m13 6 6 6-6 6"/></svg>';
|
|
29
|
+
|
|
30
|
+
export function createPillButton(root: HTMLElement | null, options: PillButtonOptions = {}): PillButtonInstance {
|
|
31
|
+
const control = root ? (root.matches('button, a, [role="button"]') ? root : root.querySelector<HTMLElement>('button, a, [role="button"]')) : null;
|
|
32
|
+
if (!root || !control) return inert();
|
|
33
|
+
registerMotion();
|
|
34
|
+
const scope = createScope();
|
|
35
|
+
|
|
36
|
+
// Only what the engine adds is taken back (React keeps its own nodes).
|
|
37
|
+
const icon = control.querySelector<HTMLElement>('[data-mk-pill-icon]');
|
|
38
|
+
if (!control.querySelector('[data-mk-pill-label]')) {
|
|
39
|
+
const label = document.createElement('span');
|
|
40
|
+
label.dataset.mkPillLabel = '';
|
|
41
|
+
for (const node of [...control.childNodes]) if (node !== icon) label.append(node);
|
|
42
|
+
control.prepend(label);
|
|
43
|
+
scope.add(() => label.replaceWith(...label.childNodes));
|
|
44
|
+
}
|
|
45
|
+
if (!icon) {
|
|
46
|
+
const made = document.createElement('span');
|
|
47
|
+
made.dataset.mkPillIcon = '';
|
|
48
|
+
made.setAttribute('aria-hidden', 'true');
|
|
49
|
+
made.innerHTML = options.icon ?? PILL_ARROW;
|
|
50
|
+
control.append(made);
|
|
51
|
+
scope.add(() => made.remove());
|
|
52
|
+
}
|
|
53
|
+
const fill = document.createElement('span');
|
|
54
|
+
fill.dataset.mkPillFill = '';
|
|
55
|
+
fill.setAttribute('aria-hidden', 'true');
|
|
56
|
+
control.prepend(fill);
|
|
57
|
+
scope.add(() => fill.remove());
|
|
58
|
+
|
|
59
|
+
scope.attr(control, 'data-mk-pill', options.expand ? 'expand' : '');
|
|
60
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
61
|
+
|
|
62
|
+
// A tap has no hover: the gathered state shows for a moment.
|
|
63
|
+
let tapped: ReturnType<typeof setTimeout> | undefined;
|
|
64
|
+
scope.on(control, 'pointerdown', (event) => {
|
|
65
|
+
press(control);
|
|
66
|
+
if ((event as PointerEvent).pointerType !== 'touch') return;
|
|
67
|
+
control.setAttribute('data-mk-active', '');
|
|
68
|
+
clearTimeout(tapped);
|
|
69
|
+
tapped = setTimeout(() => control.removeAttribute('data-mk-active'), 650);
|
|
70
|
+
});
|
|
71
|
+
scope.add(() => {
|
|
72
|
+
clearTimeout(tapped);
|
|
73
|
+
control.removeAttribute('data-mk-active');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return { destroy: () => scope.dispose() };
|
|
77
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* pill-button — a dark pill whose fill gathers into a circle around the icon on hover (and spreads back on leave).
|
|
2
|
+
The fill is one layer clipped with inset(); the label and icon sit above it. `expand` starts as the circle. */
|
|
3
|
+
.mk-pill-button:is(button, a),
|
|
4
|
+
[data-mk-pill] {
|
|
5
|
+
--mk-pill-height: 3rem;
|
|
6
|
+
--mk-pill-dot: 2.25rem;
|
|
7
|
+
--mk-pill-ink: var(--mk-text);
|
|
8
|
+
--mk-pill-on-ink: var(--mk-bg);
|
|
9
|
+
--mk-pill-gap: calc((var(--mk-pill-height) - var(--mk-pill-dot)) / 2);
|
|
10
|
+
--mk-pill-gathered: inset(var(--mk-pill-gap) var(--mk-pill-gap) var(--mk-pill-gap) calc(100% - var(--mk-pill-gap) - var(--mk-pill-dot)) round var(--mk-radius-full));
|
|
11
|
+
--mk-pill-spread: inset(0 0 0 0 round var(--mk-radius-full));
|
|
12
|
+
position: relative;
|
|
13
|
+
isolation: isolate;
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 1.25rem;
|
|
17
|
+
height: var(--mk-pill-height);
|
|
18
|
+
padding: 0 calc(var(--mk-pill-gap) + (var(--mk-pill-dot) - 1.125rem) / 2) 0 1.5rem;
|
|
19
|
+
border: 0;
|
|
20
|
+
border-radius: var(--mk-radius-full);
|
|
21
|
+
background: transparent;
|
|
22
|
+
color: var(--mk-pill-on-ink);
|
|
23
|
+
font: 500 1rem/1 var(--mk-font);
|
|
24
|
+
text-decoration: none;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
-webkit-tap-highlight-color: transparent;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
mk-pill-button {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[data-mk-pill-fill] {
|
|
35
|
+
position: absolute;
|
|
36
|
+
inset: 0;
|
|
37
|
+
z-index: -1;
|
|
38
|
+
border-radius: inherit;
|
|
39
|
+
background: var(--mk-pill-ink);
|
|
40
|
+
clip-path: var(--mk-pill-spread);
|
|
41
|
+
transition: clip-path 0.5s var(--mk-ease-swatch);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[data-mk-pill-label] {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
color: var(--mk-pill-on-ink);
|
|
47
|
+
transition:
|
|
48
|
+
transform 0.45s var(--mk-ease-swatch),
|
|
49
|
+
color 0.2s ease 0.05s;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[data-mk-pill-icon] {
|
|
53
|
+
display: inline-grid;
|
|
54
|
+
place-items: center;
|
|
55
|
+
width: 1.125rem;
|
|
56
|
+
height: 1.125rem;
|
|
57
|
+
color: var(--mk-pill-on-ink);
|
|
58
|
+
transition: transform 0.45s var(--mk-ease-swatch);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-mk-pill-icon] svg {
|
|
62
|
+
display: block;
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Gathered: on hover, keyboard focus or a tap. */
|
|
68
|
+
@media (hover: hover) {
|
|
69
|
+
:is([data-mk-pill=''], .mk-pill-button:is(button, a):not([data-mk-pill])):hover [data-mk-pill-fill] {
|
|
70
|
+
clip-path: var(--mk-pill-gathered);
|
|
71
|
+
}
|
|
72
|
+
:is([data-mk-pill=''], .mk-pill-button:is(button, a):not([data-mk-pill])):hover [data-mk-pill-label] {
|
|
73
|
+
color: var(--mk-pill-ink);
|
|
74
|
+
transform: translateX(-0.5rem);
|
|
75
|
+
}
|
|
76
|
+
:is([data-mk-pill], .mk-pill-button:is(button, a)):hover [data-mk-pill-icon] {
|
|
77
|
+
transform: translateX(2px);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
[data-mk-pill='']:is(:focus-visible, [data-mk-active]) [data-mk-pill-fill] {
|
|
81
|
+
clip-path: var(--mk-pill-gathered);
|
|
82
|
+
}
|
|
83
|
+
[data-mk-pill='']:is(:focus-visible, [data-mk-active]) [data-mk-pill-label] {
|
|
84
|
+
color: var(--mk-pill-ink);
|
|
85
|
+
transform: translateX(-0.5rem);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* expand: the circle spreads into the pill. */
|
|
89
|
+
[data-mk-pill='expand'] [data-mk-pill-fill] {
|
|
90
|
+
clip-path: var(--mk-pill-gathered);
|
|
91
|
+
}
|
|
92
|
+
[data-mk-pill='expand'] [data-mk-pill-label] {
|
|
93
|
+
color: var(--mk-pill-ink);
|
|
94
|
+
}
|
|
95
|
+
@media (hover: hover) {
|
|
96
|
+
[data-mk-pill='expand']:hover [data-mk-pill-fill] {
|
|
97
|
+
clip-path: var(--mk-pill-spread);
|
|
98
|
+
}
|
|
99
|
+
[data-mk-pill='expand']:hover [data-mk-pill-label] {
|
|
100
|
+
color: var(--mk-pill-on-ink);
|
|
101
|
+
transform: translateX(0.25rem);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
[data-mk-pill='expand']:is(:focus-visible, [data-mk-active]) [data-mk-pill-fill] {
|
|
105
|
+
clip-path: var(--mk-pill-spread);
|
|
106
|
+
}
|
|
107
|
+
[data-mk-pill='expand']:is(:focus-visible, [data-mk-active]) [data-mk-pill-label] {
|
|
108
|
+
color: var(--mk-pill-on-ink);
|
|
109
|
+
transform: translateX(0.25rem);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
:is([data-mk-pill], .mk-pill-button:is(button, a)):focus-visible {
|
|
113
|
+
outline: 2px solid var(--mk-accent);
|
|
114
|
+
outline-offset: 3px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
:is([data-mk-pill], .mk-pill-button:is(button, a)):is(:disabled, [aria-disabled='true']) {
|
|
118
|
+
cursor: not-allowed;
|
|
119
|
+
opacity: 0.5;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@media (prefers-reduced-motion: reduce) {
|
|
123
|
+
[data-mk-pill-fill],
|
|
124
|
+
[data-mk-pill-label],
|
|
125
|
+
[data-mk-pill-icon] {
|
|
126
|
+
transition-duration: 0.01s;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@media (forced-colors: active) {
|
|
131
|
+
[data-mk-pill] {
|
|
132
|
+
border: 1px solid ButtonText;
|
|
133
|
+
}
|
|
134
|
+
}
|