@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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useRef, type HTMLAttributes, type MouseEvent, type ReactNode } from 'react';
|
|
4
4
|
import { useIsomorphicLayoutEffect } from '../../react/use-recipe';
|
|
5
|
-
import { revealShell, type NavStyle } from './engine';
|
|
5
|
+
import { revealShell, toNavStyle, type NavStyle, type NavStyleAlias } from './engine';
|
|
6
6
|
|
|
7
7
|
export interface NavItem {
|
|
8
8
|
value: string;
|
|
@@ -19,7 +19,7 @@ export interface NavProps extends Omit<HTMLAttributes<HTMLElement>, 'onSelect'>
|
|
|
19
19
|
/** Value of the current page. */
|
|
20
20
|
active?: string;
|
|
21
21
|
onSelect?: (value: string, event: MouseEvent<HTMLElement>) => void;
|
|
22
|
-
navStyle?: NavStyle;
|
|
22
|
+
navStyle?: NavStyle | NavStyleAlias;
|
|
23
23
|
accent?: boolean;
|
|
24
24
|
/** Reveal the surrounding .mk-shell from the first button on mount. */
|
|
25
25
|
reveal?: boolean;
|
|
@@ -34,7 +34,7 @@ export function Nav({
|
|
|
34
34
|
items,
|
|
35
35
|
active,
|
|
36
36
|
onSelect,
|
|
37
|
-
navStyle = '
|
|
37
|
+
navStyle = 'pills',
|
|
38
38
|
accent = false,
|
|
39
39
|
reveal = false,
|
|
40
40
|
first,
|
|
@@ -50,7 +50,7 @@ export function Nav({
|
|
|
50
50
|
// Only on mount.
|
|
51
51
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
52
|
}, []);
|
|
53
|
-
const classes = ['mk-nav', `mk-nav--${navStyle}`, accent && 'mk-nav--accent', className].filter(Boolean).join(' ');
|
|
53
|
+
const classes = ['mk-nav', `mk-nav--${toNavStyle(navStyle) ?? 'pills'}`, accent && 'mk-nav--accent', className].filter(Boolean).join(' ');
|
|
54
54
|
return (
|
|
55
55
|
<nav ref={ref} aria-label="Principal" {...props} className={classes}>
|
|
56
56
|
{first}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# notification-bell
|
|
2
|
+
|
|
3
|
+
Campana de notificaciones con insignia. `notify()` la hace sonar: la campana oscila desde arriba con amortiguación (±18°) y el badajo va un instante detrás, salen ondas, la insignia aparece con curva elástica (o su cifra rueda hacia arriba) y un mensaje opcional sube a su lado en vidrio invertido durante unos segundos.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<mk-notification-bell class="mk-notification-bell" count="2"></mk-notification-bell>
|
|
7
|
+
<script>document.querySelector('mk-notification-bell').notify('Nueva cita a las 10:00');</script>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
`defineElements()`, `createNotificationBell(root, options)` (root es el botón o lo contiene) o `<NotificationBell count={unread} message={latest} onOpen={openPanel} />` (una cifra mayor o un mensaje nuevo la hacen sonar).
|
|
11
|
+
|
|
12
|
+
Opciones: `count=0`, `label='Notificaciones'`, `messageDuration=3200` ms, `max=99` (más se lee «99+»), `onOpen()`. API: `notify(message?)`, `setCount(n)`, `clear()`, `count`, `destroy()`. Eventos `mk:open` (clic) y `mk:count`. El nombre accesible incluye el número («Notificaciones, 3 sin leer») y un estado educado anuncia las nuevas. Las notificaciones reales (push, servidor) son de la app.
|
|
13
|
+
|
|
14
|
+
Movimiento reducido: la cifra y el mensaje cambian sin oscilación ni ondas.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createNotificationBell, type NotificationBellInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-notification-bell class="mk-notification-bell" count="2"></mk-notification-bell>
|
|
6
|
+
* el.notify('Nueva cita a las 10:00') rings it. Emits mk:open on click and mk:count when the count changes.
|
|
7
|
+
*/
|
|
8
|
+
export class MkNotificationBellElement extends MkElement<NotificationBellInstance> {
|
|
9
|
+
static options: Record<string, OptionType> = { count: 'number', label: 'string', messageDuration: 'number', max: 'number' };
|
|
10
|
+
|
|
11
|
+
protected create(options: Record<string, unknown>) {
|
|
12
|
+
let made: HTMLButtonElement | null = null;
|
|
13
|
+
if (!this.querySelector('button')) {
|
|
14
|
+
made = document.createElement('button');
|
|
15
|
+
made.type = 'button';
|
|
16
|
+
this.append(made);
|
|
17
|
+
}
|
|
18
|
+
const engine = createNotificationBell(this, options);
|
|
19
|
+
if (made) {
|
|
20
|
+
const destroy = engine.destroy;
|
|
21
|
+
engine.destroy = () => {
|
|
22
|
+
destroy();
|
|
23
|
+
made!.remove();
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return engine;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null) {
|
|
30
|
+
if (previous === next || !this.instance) return;
|
|
31
|
+
if (name === 'count') this.instance.setCount(Number(next) || 0);
|
|
32
|
+
else super.attributeChangedCallback(name, previous, next);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
notify(message?: string) {
|
|
36
|
+
this.instance?.notify(message);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
clear() {
|
|
40
|
+
this.instance?.clear();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get count() {
|
|
44
|
+
return this.instance?.count ?? 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const defineNotificationBell = () => defineElement('mk-notification-bell', MkNotificationBellElement);
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { gsap, ELASTIC, 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, blurOut, rollDigits } from '../../motion/micro';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Notification bell: a bell with a badge on a button. notify() rings it — the
|
|
9
|
+
* bell swings from its top in a damped arc (±18°) with the clapper a beat
|
|
10
|
+
* behind, waves ripple out, the badge pops in elastically (or its number rolls
|
|
11
|
+
* up), and an optional message rises beside it for a few seconds. The button's
|
|
12
|
+
* name carries the count and a polite status announces new ones.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export interface NotificationBellOptions {
|
|
16
|
+
count?: number;
|
|
17
|
+
/** Accessible name before the count (default 'Notificaciones'). */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** How long a message stays, in ms (default 3200). */
|
|
20
|
+
messageDuration?: number;
|
|
21
|
+
/** Above this the badge reads n+ (default 99). */
|
|
22
|
+
max?: number;
|
|
23
|
+
onOpen?: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface NotificationBellInstance extends Instance {
|
|
27
|
+
/** Ring with a new notification (and show `message`, as text). */
|
|
28
|
+
notify(message?: string): void;
|
|
29
|
+
setCount(count: number): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
readonly count: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
35
|
+
const BODY = 'M6 16.5V11a6 6 0 0 1 12 0v5.5l1.5 2H4.5z';
|
|
36
|
+
|
|
37
|
+
export function createNotificationBell(root: HTMLElement | null, options: NotificationBellOptions = {}): NotificationBellInstance {
|
|
38
|
+
const button = root ? ((root.matches('button') ? root : root.querySelector('button')) as HTMLButtonElement | null) : null;
|
|
39
|
+
if (!root || !button) return inert({ notify() {}, setCount() {}, clear() {}, count: 0 });
|
|
40
|
+
registerMotion();
|
|
41
|
+
const scope = createScope();
|
|
42
|
+
const max = Number.isFinite(options.max) && options.max! > 0 ? Math.floor(options.max!) : 99;
|
|
43
|
+
const label = options.label ?? 'Notificaciones';
|
|
44
|
+
const stay = Number.isFinite(options.messageDuration) ? Math.max(0, options.messageDuration!) : 3200;
|
|
45
|
+
let count = Math.max(0, Math.round(Number.isFinite(options.count) ? options.count! : 0));
|
|
46
|
+
|
|
47
|
+
const made: Element[] = [];
|
|
48
|
+
scope.add(() => made.forEach((element) => element.remove()));
|
|
49
|
+
const icon = document.createElementNS(SVG, 'svg');
|
|
50
|
+
icon.setAttribute('viewBox', '0 0 24 24');
|
|
51
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
52
|
+
icon.dataset.mkBellIcon = '';
|
|
53
|
+
const bell = document.createElementNS(SVG, 'g');
|
|
54
|
+
bell.dataset.mkPart = 'bell';
|
|
55
|
+
const body = document.createElementNS(SVG, 'path');
|
|
56
|
+
body.setAttribute('d', BODY);
|
|
57
|
+
const top = document.createElementNS(SVG, 'path');
|
|
58
|
+
top.setAttribute('d', 'M12 3v2');
|
|
59
|
+
bell.append(body, top);
|
|
60
|
+
const clapper = document.createElementNS(SVG, 'path');
|
|
61
|
+
clapper.setAttribute('d', 'M10 20.5a2 2 0 0 0 4 0');
|
|
62
|
+
clapper.dataset.mkPart = 'clapper';
|
|
63
|
+
icon.append(bell, clapper);
|
|
64
|
+
const waves = document.createElement('span');
|
|
65
|
+
waves.dataset.mkBellWaves = '';
|
|
66
|
+
waves.setAttribute('aria-hidden', 'true');
|
|
67
|
+
const badge = document.createElement('span');
|
|
68
|
+
badge.dataset.mkBellBadge = '';
|
|
69
|
+
badge.setAttribute('aria-hidden', 'true');
|
|
70
|
+
button.prepend(waves, icon);
|
|
71
|
+
button.append(badge);
|
|
72
|
+
const bubble = document.createElement('span');
|
|
73
|
+
bubble.dataset.mkBellMessage = '';
|
|
74
|
+
bubble.setAttribute('aria-hidden', 'true');
|
|
75
|
+
bubble.hidden = true;
|
|
76
|
+
const live = document.createElement('span');
|
|
77
|
+
live.className = 'mk-sr-only';
|
|
78
|
+
live.setAttribute('role', 'status');
|
|
79
|
+
(root === button ? button : root).append(bubble, live);
|
|
80
|
+
made.push(waves, icon, badge, bubble, live);
|
|
81
|
+
|
|
82
|
+
scope.attr(button, 'type', button.getAttribute('type') ?? 'button');
|
|
83
|
+
scope.attr(button, 'data-mk-bell', '');
|
|
84
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
85
|
+
|
|
86
|
+
let hideTimer: ReturnType<typeof setTimeout> | undefined;
|
|
87
|
+
const effects = new Set<gsap.core.Animation>();
|
|
88
|
+
const keep = (animation: gsap.core.Animation | null) => {
|
|
89
|
+
if (!animation) return;
|
|
90
|
+
effects.add(animation);
|
|
91
|
+
// Finished ones leave as new ones arrive: the animation's own onComplete stays untouched.
|
|
92
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
93
|
+
};
|
|
94
|
+
scope.add(() => {
|
|
95
|
+
clearTimeout(hideTimer);
|
|
96
|
+
for (const effect of effects) effect.kill();
|
|
97
|
+
effects.clear();
|
|
98
|
+
gsap.killTweensOf([bell, clapper, badge, bubble]);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const text = (n: number) => (n > max ? `${max}+` : String(n));
|
|
102
|
+
const name = () => (count ? `${label}, ${count} sin leer` : label);
|
|
103
|
+
const paint = () => {
|
|
104
|
+
scope.attr(button, 'aria-label', name());
|
|
105
|
+
badge.hidden = count === 0;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const showBadge = (previous: number) => {
|
|
109
|
+
if (count === 0) {
|
|
110
|
+
if (reduced() || previous === 0) {
|
|
111
|
+
badge.hidden = true;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
keep(gsap.to(badge, { scale: 0, duration: 0.2, ease: 'power2.in', onComplete: () => void (badge.hidden = true), clearProps: 'scale,transform' }));
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (previous === 0) {
|
|
118
|
+
badge.textContent = text(count);
|
|
119
|
+
badge.hidden = false;
|
|
120
|
+
if (!reduced()) keep(gsap.fromTo(badge, { scale: 0 }, { scale: 1, duration: 0.8, ease: ELASTIC, clearProps: 'scale,transform' }));
|
|
121
|
+
} else keep(rollDigits(badge, text(count), count >= previous ? 1 : -1, 0.4));
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const ring = () => {
|
|
125
|
+
if (reduced()) return;
|
|
126
|
+
gsap.killTweensOf([bell, clapper]);
|
|
127
|
+
keep(gsap.fromTo(bell, { rotation: 0 }, { keyframes: { rotation: [18, -14, 10, -6, 3, 0] }, duration: 1, ease: 'power1.out', svgOrigin: '12 4', clearProps: 'rotation,transform' }));
|
|
128
|
+
keep(gsap.fromTo(clapper, { x: 0 }, { keyframes: { x: [0, -2.5, 2, -1.4, 0.8, 0] }, duration: 1, delay: 0.06, ease: 'power1.out', clearProps: 'x,transform' }));
|
|
129
|
+
for (let i = 0; i < 2; i++) {
|
|
130
|
+
const wave = document.createElement('i');
|
|
131
|
+
waves.append(wave);
|
|
132
|
+
keep(gsap.fromTo(wave, { scale: 0.6, opacity: 0.55 }, { scale: 1.9, opacity: 0, duration: 0.8, delay: i * 0.18, ease: 'power2.out', onComplete: () => wave.remove() }));
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
// The message rises on the side with room inside the bell's container (and the window), so a bell at the
|
|
137
|
+
// right edge of a card speaks to its left instead of running over the next thing.
|
|
138
|
+
const place = () => {
|
|
139
|
+
bubble.style.maxWidth = '';
|
|
140
|
+
const box = root.getBoundingClientRect();
|
|
141
|
+
const frame = root.parentElement?.getBoundingClientRect();
|
|
142
|
+
const right = Math.min(frame?.right ?? innerWidth, innerWidth) - box.right;
|
|
143
|
+
const left = box.left - Math.max(frame?.left ?? 0, 0);
|
|
144
|
+
const side = right >= bubble.offsetWidth + 12 || right >= left ? 'right' : 'left';
|
|
145
|
+
bubble.dataset.mkSide = side;
|
|
146
|
+
bubble.style.maxWidth = `min(16rem, ${Math.max(140, (side === 'right' ? right : left) - 12)}px)`;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const say = (message: string) => {
|
|
150
|
+
clearTimeout(hideTimer);
|
|
151
|
+
gsap.killTweensOf(bubble);
|
|
152
|
+
bubble.textContent = message;
|
|
153
|
+
bubble.hidden = false;
|
|
154
|
+
place();
|
|
155
|
+
keep(blurIn(bubble, { from: 'pop' }));
|
|
156
|
+
hideTimer = setTimeout(() => {
|
|
157
|
+
if (scope.disposed) return;
|
|
158
|
+
const out = blurOut(bubble, {
|
|
159
|
+
to: 'up',
|
|
160
|
+
onComplete: () => {
|
|
161
|
+
bubble.hidden = true;
|
|
162
|
+
gsap.set(bubble, { clearProps: 'all' });
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
keep(out);
|
|
166
|
+
}, stay);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const setCount = (next: number, announce = false) => {
|
|
170
|
+
if (scope.disposed || !Number.isFinite(next)) return;
|
|
171
|
+
const previous = count;
|
|
172
|
+
count = Math.max(0, Math.round(next));
|
|
173
|
+
if (count === previous) return;
|
|
174
|
+
paint();
|
|
175
|
+
showBadge(previous);
|
|
176
|
+
if (announce) live.textContent = name();
|
|
177
|
+
root.dispatchEvent(new CustomEvent('mk:count', { bubbles: true, detail: { count } }));
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
scope.on(button, 'click', () => {
|
|
181
|
+
options.onOpen?.();
|
|
182
|
+
root.dispatchEvent(new CustomEvent('mk:open', { bubbles: true, detail: { count } }));
|
|
183
|
+
});
|
|
184
|
+
badge.textContent = text(count);
|
|
185
|
+
paint();
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
notify(message) {
|
|
189
|
+
if (scope.disposed) return;
|
|
190
|
+
setCount(count + 1, true);
|
|
191
|
+
ring();
|
|
192
|
+
if (message) say(String(message));
|
|
193
|
+
if (message) live.textContent = `${name()}. ${message}`;
|
|
194
|
+
},
|
|
195
|
+
setCount: (next) => setCount(next),
|
|
196
|
+
clear: () => setCount(0),
|
|
197
|
+
get count() {
|
|
198
|
+
return count;
|
|
199
|
+
},
|
|
200
|
+
destroy: () => scope.dispose(),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/* notification-bell — a round Melonmind icon button (surface tone) with a bell, a badge in the error tone and a
|
|
2
|
+
message that rises beside it in the inverse glass. */
|
|
3
|
+
.mk-notification-bell,
|
|
4
|
+
mk-notification-bell {
|
|
5
|
+
position: relative;
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
[data-mk-bell] {
|
|
10
|
+
position: relative;
|
|
11
|
+
display: grid;
|
|
12
|
+
place-items: center;
|
|
13
|
+
width: 3rem;
|
|
14
|
+
height: 3rem;
|
|
15
|
+
padding: 0;
|
|
16
|
+
border: 0;
|
|
17
|
+
border-radius: 50%;
|
|
18
|
+
background: var(--mk-surface-3);
|
|
19
|
+
color: var(--mk-text);
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
transition: background-color 0.2s ease;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
[data-mk-bell]:hover {
|
|
25
|
+
background: var(--mk-surface-4);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[data-mk-bell]:active {
|
|
29
|
+
animation: mk-bell-press 500ms cubic-bezier(0.37, 1.42, 0.37, 1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-mk-bell]:focus-visible {
|
|
33
|
+
outline: 2px solid var(--mk-accent);
|
|
34
|
+
outline-offset: 3px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[data-mk-bell] [data-mk-bell-icon] {
|
|
38
|
+
width: 1.5rem;
|
|
39
|
+
height: 1.5rem;
|
|
40
|
+
overflow: visible;
|
|
41
|
+
fill: none;
|
|
42
|
+
stroke: currentColor;
|
|
43
|
+
stroke-width: 1.8;
|
|
44
|
+
stroke-linecap: round;
|
|
45
|
+
stroke-linejoin: round;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[data-mk-bell] [data-mk-bell-waves] {
|
|
49
|
+
position: absolute;
|
|
50
|
+
inset: 0;
|
|
51
|
+
display: grid;
|
|
52
|
+
place-items: center;
|
|
53
|
+
pointer-events: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[data-mk-bell] [data-mk-bell-waves] i {
|
|
57
|
+
position: absolute;
|
|
58
|
+
inset: 0;
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
box-shadow: inset 0 0 0 2px var(--mk-text);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[data-mk-bell] [data-mk-bell-badge] {
|
|
64
|
+
position: absolute;
|
|
65
|
+
top: 0.15rem;
|
|
66
|
+
right: 0.1rem;
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
min-width: 1.25rem;
|
|
71
|
+
height: 1.25rem;
|
|
72
|
+
padding: 0 0.3rem;
|
|
73
|
+
border-radius: 64px;
|
|
74
|
+
background: var(--mk-error);
|
|
75
|
+
box-shadow: 0 0 0 2px var(--mk-bg);
|
|
76
|
+
color: var(--mk-on-error);
|
|
77
|
+
font-size: 0.6875rem;
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
font-variant-numeric: tabular-nums;
|
|
80
|
+
line-height: 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
[data-mk-bell] [data-mk-bell-badge][hidden] {
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
:is(.mk-notification-bell, mk-notification-bell) [data-mk-bell-message] {
|
|
88
|
+
position: absolute;
|
|
89
|
+
top: 50%;
|
|
90
|
+
left: calc(100% + 0.75rem);
|
|
91
|
+
width: max-content;
|
|
92
|
+
max-width: 16rem;
|
|
93
|
+
padding: 0.5rem 0.85rem;
|
|
94
|
+
border-radius: 16px;
|
|
95
|
+
background: var(--mk-glass-inverse);
|
|
96
|
+
box-shadow: var(--mk-glass-bevel);
|
|
97
|
+
backdrop-filter: blur(16px);
|
|
98
|
+
color: var(--mk-on-glass-inverse);
|
|
99
|
+
font-size: 0.8125rem;
|
|
100
|
+
translate: 0 -50%;
|
|
101
|
+
pointer-events: none;
|
|
102
|
+
transform-origin: 0 50%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:is(.mk-notification-bell, mk-notification-bell) [data-mk-bell-message][data-mk-side='left'] {
|
|
106
|
+
right: calc(100% + 0.75rem);
|
|
107
|
+
left: auto;
|
|
108
|
+
transform-origin: 100% 50%;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:is(.mk-notification-bell, mk-notification-bell) [data-mk-bell-message][hidden] {
|
|
112
|
+
display: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@keyframes mk-bell-press {
|
|
116
|
+
50% {
|
|
117
|
+
transform: scale(0.92);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@media (prefers-reduced-motion: reduce) {
|
|
122
|
+
[data-mk-bell] {
|
|
123
|
+
animation: none !important;
|
|
124
|
+
transition: none;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type ButtonHTMLAttributes, type MutableRefObject } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { createNotificationBell, type NotificationBellInstance } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface NotificationBellProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> {
|
|
7
|
+
/** Unread count. A higher count than before rings the bell. */
|
|
8
|
+
count?: number;
|
|
9
|
+
/** The newest message: a new value rings the bell and shows it. */
|
|
10
|
+
message?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
messageDuration?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
onOpen?: () => void;
|
|
15
|
+
instanceRef?: MutableRefObject<NotificationBellInstance | null>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** <NotificationBell count={unread} message={latest} onOpen={openPanel} />. */
|
|
19
|
+
export function NotificationBell({ count = 0, message, label, messageDuration, max, onOpen, instanceRef, className, ...props }: NotificationBellProps) {
|
|
20
|
+
const ref = useRef<HTMLSpanElement>(null);
|
|
21
|
+
const instance = useRef<NotificationBellInstance | null>(null);
|
|
22
|
+
const open = useLatest(onOpen);
|
|
23
|
+
const initial = useRef(count);
|
|
24
|
+
useIsomorphicLayoutEffect(() => {
|
|
25
|
+
const created = createNotificationBell(ref.current, { count: initial.current, label, messageDuration, max, onOpen: () => open.current?.() });
|
|
26
|
+
instance.current = created;
|
|
27
|
+
if (instanceRef) instanceRef.current = created;
|
|
28
|
+
return () => {
|
|
29
|
+
initial.current = created.count;
|
|
30
|
+
created.destroy();
|
|
31
|
+
instance.current = null;
|
|
32
|
+
if (instanceRef) instanceRef.current = null;
|
|
33
|
+
};
|
|
34
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
|
+
}, [label, messageDuration, max]);
|
|
36
|
+
const seen = useRef({ count, message });
|
|
37
|
+
useIsomorphicLayoutEffect(() => {
|
|
38
|
+
const bell = instance.current;
|
|
39
|
+
if (!bell) return;
|
|
40
|
+
const before = seen.current;
|
|
41
|
+
seen.current = { count, message };
|
|
42
|
+
const fresh = message !== undefined && message !== before.message;
|
|
43
|
+
if (count > bell.count) {
|
|
44
|
+
// One ring for the newest; the rest of the jump is set at once.
|
|
45
|
+
bell.setCount(count - 1);
|
|
46
|
+
bell.notify(fresh ? message : undefined);
|
|
47
|
+
} else {
|
|
48
|
+
bell.setCount(count);
|
|
49
|
+
if (fresh && message) bell.notify(message);
|
|
50
|
+
}
|
|
51
|
+
}, [count, message]);
|
|
52
|
+
return (
|
|
53
|
+
<span ref={ref} className={['mk-notification-bell', className].filter(Boolean).join(' ')}>
|
|
54
|
+
<button type="button" {...props} />
|
|
55
|
+
</span>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# orbit-menu
|
|
2
|
+
|
|
3
|
+
Menú central que despliega acciones en cruz o círculo con giro, desenfoque y resorte.
|
|
4
|
+
|
|
5
|
+
## Instalación
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import '@yewdiel21/motion-kit/css';
|
|
9
|
+
import { OrbitMenu } from '@yewdiel21/motion-kit/react';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx @yewdiel21/motion-kit add orbit-menu --react --elements
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## React
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
<OrbitMenu label="Acciones" items={[{ value: "add", label: "Crear", icon: "+" }, { value: "download", label: "Descargar", icon: "↓" }]} onSelect={run} />
|
|
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-orbit-menu radius="88"><button data-mk-orbit-toggle aria-label="Acciones"></button><button data-mk-orbit-item data-mk-value="add" aria-label="Crear">+</button><button data-mk-orbit-item data-mk-value="download" aria-label="Descargar">↓</button></mk-orbit-menu>
|
|
28
|
+
<script type="module">
|
|
29
|
+
import { defineElements } from '@yewdiel21/motion-kit/elements';
|
|
30
|
+
defineElements(['mk-orbit-menu']);
|
|
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 { createOrbitMenu } 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
|
+
radius: 96 px. start: 0 grados desde arriba. closeOnSelect: true. onToggle(open), onSelect(value). Reserva espacio alrededor del botón. Instancia: open(), close(), toggle(), isOpen.
|
|
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-orbit-size, --mk-orbit-face, --mk-orbit-ink, --mk-orbit-shadow.
|
|
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,27 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createOrbitMenu, type OrbitMenuInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-orbit-menu class="mk-orbit-menu">
|
|
6
|
+
* <button data-mk-orbit-toggle aria-label="Acciones"></button>
|
|
7
|
+
* <button data-mk-orbit-item data-mk-value="nuevo" aria-label="Nuevo">…svg…</button> …
|
|
8
|
+
* </mk-orbit-menu>
|
|
9
|
+
* Options swirl out around the middle button. Emits mk:toggle ({open}) and mk:select ({value}).
|
|
10
|
+
*/
|
|
11
|
+
export class MkOrbitMenuElement extends MkElement<OrbitMenuInstance> {
|
|
12
|
+
static options: Record<string, OptionType> = { radius: 'number', start: 'number', closeOnSelect: 'boolean' };
|
|
13
|
+
|
|
14
|
+
protected create(options: Record<string, unknown>) {
|
|
15
|
+
return createOrbitMenu(this, options);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
open() {
|
|
19
|
+
this.instance?.open();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
close() {
|
|
23
|
+
this.instance?.close();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const defineOrbitMenu = () => defineElement('mk-orbit-menu', MkOrbitMenuElement);
|