@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,390 @@
|
|
|
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 {
|
|
6
|
+
addDays, addMonths, capitalize, clampFirstDay, dayKey, monthWeeks, safeFormat, sameDay, sameMonth, startOfMonth, startOfWeek, toDate, weekdayNames,
|
|
7
|
+
type DateInput,
|
|
8
|
+
} from '../../core/dates';
|
|
9
|
+
import { inRange, isPickable, pickDay, rangeKeys, rangeLength, toRange, type DateRange, type DayRules } from '../../core/date-range';
|
|
10
|
+
import { blurIn, press, ringPulse, shake } from '../../motion/micro';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Range calendar: one or two month grids (role="grid") with one tabbable day
|
|
14
|
+
* (roving tabindex). The first click (or Enter) fixes an anchor that pops; while
|
|
15
|
+
* choosing the end, pointing previews the range as a lighter band; the second
|
|
16
|
+
* click closes it and its band wipes in from the anchor to the end (EASE.wipe,
|
|
17
|
+
* 12 ms apart, .35 s at most), then the end pops. Days that cannot be picked
|
|
18
|
+
* (min, max, unavailable) are aria-disabled; a range may not cross one. Months
|
|
19
|
+
* slide like the calendar component (old grid out 30 px in .12 s, new in from
|
|
20
|
+
* the other side .25 s). Keyboard: arrows ±1/±7 days, Home/End week, PageUp/
|
|
21
|
+
* PageDown month (Shift: year), Enter/Space pick.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export interface RangeCalendarOptions {
|
|
25
|
+
value?: { start: DateInput; end: DateInput } | null;
|
|
26
|
+
/** First visible month (default: the value's start, else today). */
|
|
27
|
+
month?: DateInput;
|
|
28
|
+
visibleMonths?: 1 | 2;
|
|
29
|
+
/** 0 = Sunday … 6 = Saturday (default 1, Monday). */
|
|
30
|
+
firstDay?: number;
|
|
31
|
+
min?: DateInput | null;
|
|
32
|
+
max?: DateInput | null;
|
|
33
|
+
/** 'YYYY-MM-DD' keys or a test. */
|
|
34
|
+
unavailable?: string[] | ((day: Date) => boolean);
|
|
35
|
+
locale?: string;
|
|
36
|
+
/** Override "today" (demos, tests). */
|
|
37
|
+
today?: DateInput;
|
|
38
|
+
labels?: { prev?: string; next?: string };
|
|
39
|
+
/** 'range' (default): two clicks; 'single': one click picks a day (date-time-picker). */
|
|
40
|
+
selection?: 'range' | 'single';
|
|
41
|
+
onChange?: (range: DateRange) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RangeCalendarInstance extends Instance {
|
|
45
|
+
setValue(range: { start: DateInput; end: DateInput } | null, animate?: boolean): void;
|
|
46
|
+
next(): void;
|
|
47
|
+
prev(): void;
|
|
48
|
+
/** Move the focus to `day`, changing month if needed (`animate` false: no slide). */
|
|
49
|
+
focusDay(day: DateInput, animate?: boolean): void;
|
|
50
|
+
readonly value: DateRange | null;
|
|
51
|
+
readonly month: Date;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The band of a finished range: each day draws in .22 s, 12 ms after the one before, the run within .35 s. */
|
|
55
|
+
const BAND = { day: 0.22, gap: 0.012, spread: 0.35 };
|
|
56
|
+
const bandGap = (days: number) => Math.min(BAND.gap, BAND.spread / Math.max(1, days));
|
|
57
|
+
|
|
58
|
+
/** Seconds a finished range of `days` takes to settle: its band draws in while its end day pops (.3 s). */
|
|
59
|
+
export const bandDuration = (days: number) => Math.max(0.3, BAND.day + bandGap(days) * Math.max(0, days - 1));
|
|
60
|
+
|
|
61
|
+
const chevron = (path: string) =>
|
|
62
|
+
`<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${path}"/></svg>`;
|
|
63
|
+
|
|
64
|
+
const el = <K extends keyof HTMLElementTagNameMap>(tag: K, attrs: Record<string, string> = {}, text?: string) => {
|
|
65
|
+
const element = document.createElement(tag);
|
|
66
|
+
for (const [name, value] of Object.entries(attrs)) element.setAttribute(name, value);
|
|
67
|
+
if (text !== undefined) element.textContent = text;
|
|
68
|
+
return element;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export function createRangeCalendar(root: HTMLElement | null, options: RangeCalendarOptions = {}): RangeCalendarInstance {
|
|
72
|
+
if (!root) return inert({ setValue() {}, next() {}, prev() {}, focusDay() {}, value: null, month: startOfMonth(new Date()) });
|
|
73
|
+
registerMotion();
|
|
74
|
+
const scope = createScope();
|
|
75
|
+
const effects = new Set<gsap.core.Animation>();
|
|
76
|
+
const keep = (animation: gsap.core.Animation | null) => {
|
|
77
|
+
if (!animation) return;
|
|
78
|
+
effects.add(animation);
|
|
79
|
+
// Finished ones leave as new ones arrive: the animation's own onComplete stays untouched.
|
|
80
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const locale = options.locale ?? root.closest('[lang]')?.getAttribute('lang') ?? 'es';
|
|
84
|
+
const firstDay = options.firstDay === undefined ? 1 : clampFirstDay(options.firstDay);
|
|
85
|
+
const count = options.visibleMonths === 2 ? 2 : 1;
|
|
86
|
+
const today = toDate(options.today ?? new Date());
|
|
87
|
+
const unavailable = options.unavailable;
|
|
88
|
+
const rules: DayRules = {
|
|
89
|
+
min: options.min ? toDate(options.min) : null,
|
|
90
|
+
max: options.max ? toDate(options.max) : null,
|
|
91
|
+
isUnavailable: typeof unavailable === 'function' ? unavailable : Array.isArray(unavailable) ? (day) => unavailable.includes(dayKey(day)) : undefined,
|
|
92
|
+
};
|
|
93
|
+
let range: DateRange | null = toRange(options.value);
|
|
94
|
+
let anchor: Date | null = null;
|
|
95
|
+
let hover: Date | null = null;
|
|
96
|
+
let month = startOfMonth(toDate(options.month ?? range?.start ?? today));
|
|
97
|
+
let focused: Date = range?.start && sameMonth(range.start, month) ? range.start : sameMonth(today, month) ? today : month;
|
|
98
|
+
const monthYear = safeFormat(locale, { month: 'long', year: 'numeric' });
|
|
99
|
+
const fullDate = safeFormat(locale, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
|
|
100
|
+
const lastVisible = () => addDays(startOfMonth(addMonths(month, count)), -1);
|
|
101
|
+
const visible = (day: Date) => day >= month && day <= lastVisible();
|
|
102
|
+
|
|
103
|
+
const header = el('header', { 'data-mk-range-header': '' });
|
|
104
|
+
const prevButton = el('button', { type: 'button', 'data-mk-range-prev': '', 'aria-label': options.labels?.prev ?? 'Mes anterior' });
|
|
105
|
+
prevButton.innerHTML = chevron('M15 6l-6 6 6 6');
|
|
106
|
+
const titleEl = el('h3', { 'data-mk-range-title': '', 'aria-live': 'polite' });
|
|
107
|
+
const nextButton = el('button', { type: 'button', 'data-mk-range-next': '', 'aria-label': options.labels?.next ?? 'Mes siguiente' });
|
|
108
|
+
nextButton.innerHTML = chevron('M9 6l6 6-6 6');
|
|
109
|
+
header.append(prevButton, titleEl, nextButton);
|
|
110
|
+
const months = el('div', { 'data-mk-range-months': '' });
|
|
111
|
+
root.append(header, months);
|
|
112
|
+
scope.add(() => {
|
|
113
|
+
for (const effect of effects) effect.kill();
|
|
114
|
+
effects.clear();
|
|
115
|
+
gsap.killTweensOf([months, titleEl]);
|
|
116
|
+
header.remove();
|
|
117
|
+
months.remove();
|
|
118
|
+
});
|
|
119
|
+
scope.attr(root, 'data-mk-months', String(count));
|
|
120
|
+
const single = options.selection === 'single';
|
|
121
|
+
if (single) scope.attr(root, 'data-mk-selection', 'single');
|
|
122
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
123
|
+
|
|
124
|
+
const title = () => capitalize(count > 1 && typeof monthYear.formatRange === 'function' ? monthYear.formatRange(month, lastVisible()) : monthYear.format(month));
|
|
125
|
+
|
|
126
|
+
const buttons = () => [...months.querySelectorAll<HTMLButtonElement>('button[data-mk-day]')];
|
|
127
|
+
const buttonOf = (day: Date) => months.querySelector<HTMLButtonElement>(`button[data-mk-day="${dayKey(day)}"]`);
|
|
128
|
+
const dayOf = (button: Element) => toDate((button as HTMLElement).dataset.mkDay!);
|
|
129
|
+
|
|
130
|
+
const build = () => {
|
|
131
|
+
const short = weekdayNames(locale, firstDay, 'narrow');
|
|
132
|
+
const long = weekdayNames(locale, firstDay, 'long');
|
|
133
|
+
const grids: HTMLElement[] = [];
|
|
134
|
+
for (let i = 0; i < count; i++) {
|
|
135
|
+
const shown = addMonths(month, i);
|
|
136
|
+
const grid = el('div', { role: 'grid', 'data-mk-range-month': '', 'aria-label': monthYear.format(shown) });
|
|
137
|
+
const head = el('div', { role: 'row', 'data-mk-range-weekdays': '' });
|
|
138
|
+
short.forEach((name, j) => head.append(el('span', { role: 'columnheader', 'data-mk-range-weekday': '', 'aria-label': long[j]! }, name.toLocaleUpperCase(locale))));
|
|
139
|
+
grid.append(head);
|
|
140
|
+
for (const week of monthWeeks(shown, firstDay)) {
|
|
141
|
+
const row = el('div', { role: 'row', 'data-mk-range-week': '' });
|
|
142
|
+
for (const day of week) {
|
|
143
|
+
const cell = el('div', { role: 'gridcell', 'data-mk-range-cell': '' });
|
|
144
|
+
if (!sameMonth(day, shown)) cell.setAttribute('data-mk-outside', '');
|
|
145
|
+
else {
|
|
146
|
+
cell.append(
|
|
147
|
+
el('span', { 'data-mk-day-band': '', 'aria-hidden': 'true' }),
|
|
148
|
+
el('button', { type: 'button', 'data-mk-day': dayKey(day), tabindex: '-1', 'aria-label': fullDate.format(day) }, String(day.getDate())),
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
row.append(cell);
|
|
152
|
+
}
|
|
153
|
+
grid.append(row);
|
|
154
|
+
}
|
|
155
|
+
grids.push(grid);
|
|
156
|
+
}
|
|
157
|
+
months.replaceChildren(...grids);
|
|
158
|
+
paint();
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const ordered = (a: Date, b: Date): DateRange => (a <= b ? { start: a, end: b } : { start: b, end: a });
|
|
162
|
+
|
|
163
|
+
const paint = () => {
|
|
164
|
+
const shown = anchor ? null : range;
|
|
165
|
+
const preview = anchor && hover ? ordered(anchor, hover) : null;
|
|
166
|
+
const all = buttons();
|
|
167
|
+
const target = visible(focused) ? dayKey(focused) : dayKey(all.map(dayOf).find((day) => isPickable(day, rules)) ?? month);
|
|
168
|
+
for (const button of all) {
|
|
169
|
+
const day = dayOf(button);
|
|
170
|
+
const cell = button.parentElement!;
|
|
171
|
+
const selected = inRange(day, shown);
|
|
172
|
+
button.toggleAttribute('data-mk-today', sameDay(day, today));
|
|
173
|
+
button.toggleAttribute('data-mk-anchor', sameDay(day, anchor));
|
|
174
|
+
button.toggleAttribute('data-mk-in-range', selected);
|
|
175
|
+
button.toggleAttribute('data-mk-range-start', !!shown && sameDay(day, shown.start));
|
|
176
|
+
button.toggleAttribute('data-mk-range-end', !!shown && sameDay(day, shown.end));
|
|
177
|
+
button.toggleAttribute('data-mk-preview', inRange(day, preview));
|
|
178
|
+
button.toggleAttribute('data-mk-preview-start', !!preview && sameDay(day, preview.start));
|
|
179
|
+
button.toggleAttribute('data-mk-preview-end', !!preview && sameDay(day, preview.end));
|
|
180
|
+
if (isPickable(day, rules)) button.removeAttribute('aria-disabled');
|
|
181
|
+
else button.setAttribute('aria-disabled', 'true');
|
|
182
|
+
if (selected) cell.setAttribute('aria-selected', 'true');
|
|
183
|
+
else cell.removeAttribute('aria-selected');
|
|
184
|
+
button.setAttribute('tabindex', button.dataset.mkDay === target ? '0' : '-1');
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const go = (next: Date, direction: 1 | -1, after?: () => void, animate = true) => {
|
|
189
|
+
month = startOfMonth(next);
|
|
190
|
+
gsap.killTweensOf([months, titleEl]);
|
|
191
|
+
if (reduced() || !animate) {
|
|
192
|
+
build();
|
|
193
|
+
titleEl.textContent = title();
|
|
194
|
+
after?.();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
keep(
|
|
198
|
+
gsap.to(months, {
|
|
199
|
+
x: -direction * 30,
|
|
200
|
+
opacity: 0,
|
|
201
|
+
duration: 0.12,
|
|
202
|
+
ease: 'power2.in',
|
|
203
|
+
onComplete: () => {
|
|
204
|
+
build();
|
|
205
|
+
titleEl.textContent = title();
|
|
206
|
+
keep(blurIn(titleEl, { from: 'soft', duration: 0.3 }));
|
|
207
|
+
keep(gsap.fromTo(months, { x: direction * 30, opacity: 0 }, { x: 0, opacity: 1, duration: 0.25, ease: 'power2.out', clearProps: 'x,opacity,transform' }));
|
|
208
|
+
after?.();
|
|
209
|
+
},
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const focusDay = (input: DateInput, animate = true) => {
|
|
215
|
+
focused = toDate(input);
|
|
216
|
+
if (anchor) hover = focused;
|
|
217
|
+
if (visible(focused)) {
|
|
218
|
+
paint();
|
|
219
|
+
buttonOf(focused)?.focus();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const before = focused < month;
|
|
223
|
+
go(before ? startOfMonth(focused) : startOfMonth(addMonths(focused, -(count - 1))), before ? -1 : 1, () => buttonOf(focused)?.focus(), animate);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const pop = (button: HTMLElement | null) => {
|
|
227
|
+
if (button && !reduced()) keep(gsap.fromTo(button, { scale: 0.6 }, { scale: 1, duration: 0.3, ease: EASE.pop, clearProps: 'scale,transform' }));
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/** The band of the finished range draws itself from the anchor to the end. */
|
|
231
|
+
const wipe = (forward: boolean, last: Date | null) => {
|
|
232
|
+
if (reduced() || !range) return;
|
|
233
|
+
const bands = buttons()
|
|
234
|
+
.filter((button) => button.hasAttribute('data-mk-in-range'))
|
|
235
|
+
.map((button) => button.previousElementSibling as HTMLElement);
|
|
236
|
+
if (!forward) bands.reverse();
|
|
237
|
+
if (bands.length) {
|
|
238
|
+
keep(
|
|
239
|
+
gsap.fromTo(
|
|
240
|
+
bands,
|
|
241
|
+
{ scaleX: 0 },
|
|
242
|
+
{
|
|
243
|
+
scaleX: 1,
|
|
244
|
+
duration: BAND.day,
|
|
245
|
+
ease: EASE.wipe,
|
|
246
|
+
stagger: bandGap(bands.length),
|
|
247
|
+
transformOrigin: forward ? '0% 50%' : '100% 50%',
|
|
248
|
+
clearProps: 'scale,transform,transformOrigin',
|
|
249
|
+
},
|
|
250
|
+
),
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
pop(last ? buttonOf(last) : null);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const emit = () => {
|
|
257
|
+
if (!range) return;
|
|
258
|
+
options.onChange?.({ ...range });
|
|
259
|
+
root.dispatchEvent(new CustomEvent('mk:change', { bubbles: true, detail: { ...rangeKeys(range), length: rangeLength(range) } }));
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
const pick = (day: Date) => {
|
|
263
|
+
const button = buttonOf(day);
|
|
264
|
+
if (!isPickable(day, rules)) {
|
|
265
|
+
if (button) keep(shake(button, 3));
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (single) {
|
|
269
|
+
// One click, one day: it pops and the change is reported.
|
|
270
|
+
range = { start: day, end: day };
|
|
271
|
+
anchor = null;
|
|
272
|
+
hover = null;
|
|
273
|
+
paint();
|
|
274
|
+
pop(button);
|
|
275
|
+
emit();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const wasAnchor = anchor;
|
|
279
|
+
const next = pickDay(anchor, day, rules);
|
|
280
|
+
anchor = next.anchor;
|
|
281
|
+
hover = anchor;
|
|
282
|
+
if (!next.range) {
|
|
283
|
+
paint();
|
|
284
|
+
if (anchor && button && !reduced()) {
|
|
285
|
+
pop(button);
|
|
286
|
+
keep(ringPulse(button));
|
|
287
|
+
}
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
range = next.range;
|
|
291
|
+
paint();
|
|
292
|
+
wipe(wasAnchor !== null && wasAnchor <= day, day);
|
|
293
|
+
emit();
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const KEYS: Record<string, (day: Date, shift: boolean) => Date> = {
|
|
297
|
+
ArrowLeft: (day) => addDays(day, -1),
|
|
298
|
+
ArrowRight: (day) => addDays(day, 1),
|
|
299
|
+
ArrowUp: (day) => addDays(day, -7),
|
|
300
|
+
ArrowDown: (day) => addDays(day, 7),
|
|
301
|
+
Home: (day) => startOfWeek(day, firstDay),
|
|
302
|
+
End: (day) => addDays(startOfWeek(day, firstDay), 6),
|
|
303
|
+
PageUp: (day, shift) => addMonths(day, shift ? -12 : -1),
|
|
304
|
+
PageDown: (day, shift) => addMonths(day, shift ? 12 : 1),
|
|
305
|
+
};
|
|
306
|
+
scope.on(months, 'keydown', (event) => {
|
|
307
|
+
const key = event as KeyboardEvent;
|
|
308
|
+
const button = (key.target as Element | null)?.closest('button[data-mk-day]');
|
|
309
|
+
if (!button) return;
|
|
310
|
+
const move = KEYS[key.key];
|
|
311
|
+
if (move) {
|
|
312
|
+
key.preventDefault();
|
|
313
|
+
focusDay(move(dayOf(button), key.shiftKey));
|
|
314
|
+
} else if (key.key === 'Enter' || key.key === ' ') {
|
|
315
|
+
key.preventDefault();
|
|
316
|
+
focused = dayOf(button);
|
|
317
|
+
pick(focused);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
scope.on(months, 'click', (event) => {
|
|
321
|
+
const button = (event.target as Element | null)?.closest<HTMLButtonElement>('button[data-mk-day]');
|
|
322
|
+
if (!button) return;
|
|
323
|
+
focused = dayOf(button);
|
|
324
|
+
pick(focused);
|
|
325
|
+
});
|
|
326
|
+
scope.on(months, 'pointerover', (event) => {
|
|
327
|
+
if (!anchor) return;
|
|
328
|
+
const button = (event.target as Element | null)?.closest('button[data-mk-day]');
|
|
329
|
+
if (!button) return;
|
|
330
|
+
const day = dayOf(button);
|
|
331
|
+
if (hover && sameDay(hover, day)) return;
|
|
332
|
+
hover = day;
|
|
333
|
+
paint();
|
|
334
|
+
});
|
|
335
|
+
scope.on(months, 'pointerleave', () => {
|
|
336
|
+
if (!anchor || !hover) return;
|
|
337
|
+
hover = anchor;
|
|
338
|
+
paint();
|
|
339
|
+
});
|
|
340
|
+
const step = (direction: 1 | -1) => {
|
|
341
|
+
// The focused day follows so that the tabbable day stays in view.
|
|
342
|
+
focused = addMonths(focused, direction);
|
|
343
|
+
go(addMonths(month, direction), direction);
|
|
344
|
+
};
|
|
345
|
+
scope.on(prevButton, 'click', () => {
|
|
346
|
+
keep(press(prevButton));
|
|
347
|
+
step(-1);
|
|
348
|
+
});
|
|
349
|
+
scope.on(nextButton, 'click', () => {
|
|
350
|
+
keep(press(nextButton));
|
|
351
|
+
step(1);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
titleEl.textContent = title();
|
|
355
|
+
build();
|
|
356
|
+
|
|
357
|
+
return {
|
|
358
|
+
setValue(next, animate = true) {
|
|
359
|
+
if (scope.disposed) return;
|
|
360
|
+
range = toRange(next);
|
|
361
|
+
anchor = null;
|
|
362
|
+
hover = null;
|
|
363
|
+
if (range && !visible(range.start)) {
|
|
364
|
+
focused = range.start;
|
|
365
|
+
go(
|
|
366
|
+
startOfMonth(range.start),
|
|
367
|
+
range.start < month ? -1 : 1,
|
|
368
|
+
() => {
|
|
369
|
+
if (animate) wipe(true, null);
|
|
370
|
+
},
|
|
371
|
+
animate,
|
|
372
|
+
);
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (range) focused = range.start;
|
|
376
|
+
paint();
|
|
377
|
+
if (animate) wipe(true, null);
|
|
378
|
+
},
|
|
379
|
+
next: () => step(1),
|
|
380
|
+
prev: () => step(-1),
|
|
381
|
+
focusDay,
|
|
382
|
+
get value() {
|
|
383
|
+
return range ? { ...range } : null;
|
|
384
|
+
},
|
|
385
|
+
get month() {
|
|
386
|
+
return new Date(month);
|
|
387
|
+
},
|
|
388
|
+
destroy: () => scope.dispose(),
|
|
389
|
+
};
|
|
390
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/* range-calendar — a compact month (or two) on the Melon Mind surfaces: 2.5 rem days, the range as a soft band with
|
|
2
|
+
round ends at the range ends and at the edges of each week, ends as accent circles, a dashed preview band while
|
|
3
|
+
choosing the end, today with a ring. 20 px outer corners, 8 px buttons. */
|
|
4
|
+
.mk-range-calendar,
|
|
5
|
+
mk-range-calendar {
|
|
6
|
+
--mk-range-day: 2.5rem;
|
|
7
|
+
--mk-range-band: var(--mk-accent-soft);
|
|
8
|
+
display: inline-grid;
|
|
9
|
+
gap: 0.75rem;
|
|
10
|
+
max-width: 100%;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
padding: 0.75rem;
|
|
13
|
+
border-radius: 20px;
|
|
14
|
+
background: var(--mk-surface-1);
|
|
15
|
+
color: var(--mk-text);
|
|
16
|
+
font-variant-numeric: tabular-nums;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-header] {
|
|
20
|
+
display: grid;
|
|
21
|
+
grid-template-columns: auto 1fr auto;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 0.5rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-title] {
|
|
27
|
+
margin: 0;
|
|
28
|
+
font-size: 0.9375rem;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
text-align: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:is(.mk-range-calendar, mk-range-calendar) :is([data-mk-range-prev], [data-mk-range-next]) {
|
|
34
|
+
display: grid;
|
|
35
|
+
place-items: center;
|
|
36
|
+
width: 2.25rem;
|
|
37
|
+
height: 2.25rem;
|
|
38
|
+
padding: 0;
|
|
39
|
+
border: 0;
|
|
40
|
+
border-radius: 8px;
|
|
41
|
+
background: var(--mk-surface-3);
|
|
42
|
+
color: inherit;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:is(.mk-range-calendar, mk-range-calendar) :is([data-mk-range-prev], [data-mk-range-next]):focus-visible {
|
|
47
|
+
outline: 3px solid color-mix(in srgb, var(--mk-accent) 45%, transparent);
|
|
48
|
+
outline-offset: 2px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-months] {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-wrap: wrap;
|
|
54
|
+
gap: 1.25rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-month] {
|
|
58
|
+
display: grid;
|
|
59
|
+
grid-template-columns: repeat(7, var(--mk-range-day));
|
|
60
|
+
row-gap: 2px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:is(.mk-range-calendar, mk-range-calendar) :is([data-mk-range-weekdays], [data-mk-range-week]) {
|
|
64
|
+
display: contents;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-weekday] {
|
|
68
|
+
display: grid;
|
|
69
|
+
place-items: center;
|
|
70
|
+
height: 2rem;
|
|
71
|
+
color: var(--mk-muted);
|
|
72
|
+
font-size: 0.75rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell] {
|
|
76
|
+
position: relative;
|
|
77
|
+
height: var(--mk-range-day);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day-band] {
|
|
81
|
+
position: absolute;
|
|
82
|
+
inset: 3px 0;
|
|
83
|
+
background: transparent;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell]:has(> [data-mk-in-range]) [data-mk-day-band] {
|
|
87
|
+
background: var(--mk-range-band);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* The tentative range: a lighter band with a dashed edge around the whole run (top and bottom on every day, the
|
|
91
|
+
sides only at its ends and at the edges of each week). */
|
|
92
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell]:has(> [data-mk-preview]) [data-mk-day-band] {
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
border-block: 1px dashed color-mix(in srgb, var(--mk-accent) 55%, transparent);
|
|
95
|
+
background: color-mix(in srgb, var(--mk-range-band) 55%, transparent);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell]:has(> [data-mk-preview]):is(:has(> [data-mk-preview-start]), :first-child) [data-mk-day-band] {
|
|
99
|
+
border-left: 1px dashed color-mix(in srgb, var(--mk-accent) 55%, transparent);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell]:has(> [data-mk-preview]):is(:has(> [data-mk-preview-end]), :last-child) [data-mk-day-band] {
|
|
103
|
+
border-right: 1px dashed color-mix(in srgb, var(--mk-accent) 55%, transparent);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Round ends: the range (or preview) ends and the first/last day of each week row (rows are display: contents, so
|
|
107
|
+
every row still holds exactly seven cells and :first-child / :last-child are its ends). The layout hangs on data
|
|
108
|
+
attributes, not roles: the copy that folds back into the button when a popover closes has no roles. */
|
|
109
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell]:is(:has(> [data-mk-range-start], > [data-mk-preview-start]), :first-child) [data-mk-day-band] {
|
|
110
|
+
border-top-left-radius: 999px;
|
|
111
|
+
border-bottom-left-radius: 999px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell]:is(:has(> [data-mk-range-end], > [data-mk-preview-end]), :last-child) [data-mk-day-band] {
|
|
115
|
+
border-top-right-radius: 999px;
|
|
116
|
+
border-bottom-right-radius: 999px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* A month's first and last day also close the band (the cells around them are empty). */
|
|
120
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell][data-mk-outside] + [data-mk-range-cell] [data-mk-day-band] {
|
|
121
|
+
border-top-left-radius: 999px;
|
|
122
|
+
border-bottom-left-radius: 999px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-range-cell]:has(+ [data-mk-range-cell][data-mk-outside]) [data-mk-day-band] {
|
|
126
|
+
border-top-right-radius: 999px;
|
|
127
|
+
border-bottom-right-radius: 999px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day] {
|
|
131
|
+
position: relative;
|
|
132
|
+
z-index: 1;
|
|
133
|
+
width: 100%;
|
|
134
|
+
height: 100%;
|
|
135
|
+
padding: 0;
|
|
136
|
+
border: 0;
|
|
137
|
+
border-radius: 999px;
|
|
138
|
+
background: transparent;
|
|
139
|
+
color: inherit;
|
|
140
|
+
font: inherit;
|
|
141
|
+
cursor: pointer;
|
|
142
|
+
transition: background-color 0.2s ease, color 0.2s ease;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day]:hover {
|
|
146
|
+
background: var(--mk-surface-3);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day]:is([data-mk-range-start], [data-mk-range-end], [data-mk-anchor]) {
|
|
150
|
+
background: var(--mk-accent);
|
|
151
|
+
color: var(--mk-on-accent);
|
|
152
|
+
font-weight: 600;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day][data-mk-today]:not([data-mk-range-start], [data-mk-range-end], [data-mk-anchor]) {
|
|
156
|
+
box-shadow: inset 0 0 0 1.5px var(--mk-text);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day][aria-disabled='true'] {
|
|
160
|
+
color: var(--mk-muted);
|
|
161
|
+
text-decoration: line-through;
|
|
162
|
+
cursor: not-allowed;
|
|
163
|
+
opacity: 0.55;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day][aria-disabled='true']:hover {
|
|
167
|
+
background: transparent;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day]:focus-visible {
|
|
171
|
+
outline: 3px solid color-mix(in srgb, var(--mk-accent) 45%, transparent);
|
|
172
|
+
outline-offset: 1px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
@media (max-width: 380px) {
|
|
176
|
+
:is(.mk-range-calendar, mk-range-calendar) {
|
|
177
|
+
--mk-range-day: 2.25rem;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
@media (prefers-reduced-motion: reduce) {
|
|
182
|
+
:is(.mk-range-calendar, mk-range-calendar) [data-mk-day] {
|
|
183
|
+
transition: none;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { rangeKeys, toRange } from '../../core/date-range';
|
|
5
|
+
import type { DateInput } from '../../core/dates';
|
|
6
|
+
import { createRangeCalendar, type RangeCalendarInstance, type RangeCalendarOptions } from './engine';
|
|
7
|
+
|
|
8
|
+
type RangeValue = { start: DateInput; end: DateInput } | null;
|
|
9
|
+
|
|
10
|
+
export interface RangeCalendarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'>, Omit<RangeCalendarOptions, 'value'> {
|
|
11
|
+
/** Controlled range; without it the calendar keeps its own (defaultValue). */
|
|
12
|
+
value?: RangeValue;
|
|
13
|
+
defaultValue?: RangeValue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const keyOf = (value: RangeValue | undefined) => {
|
|
17
|
+
const range = toRange(value);
|
|
18
|
+
return range ? JSON.stringify(rangeKeys(range)) : 'null';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** <RangeCalendar value={range} onChange={setRange} visibleMonths={2} />. */
|
|
22
|
+
export function RangeCalendar({ value, defaultValue, month, visibleMonths, firstDay, min, max, unavailable, locale, today, labels, onChange, className, ...props }: RangeCalendarProps) {
|
|
23
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
24
|
+
const instance = useRef<RangeCalendarInstance | null>(null);
|
|
25
|
+
const change = useLatest(onChange);
|
|
26
|
+
const test = useLatest(unavailable);
|
|
27
|
+
const start = useRef<RangeValue>(value !== undefined ? value : (defaultValue ?? null));
|
|
28
|
+
const rules = typeof unavailable === 'function' ? 'function' : JSON.stringify(unavailable ?? null);
|
|
29
|
+
useIsomorphicLayoutEffect(() => {
|
|
30
|
+
const created = createRangeCalendar(ref.current, {
|
|
31
|
+
value: value !== undefined ? value : start.current,
|
|
32
|
+
month,
|
|
33
|
+
visibleMonths,
|
|
34
|
+
firstDay,
|
|
35
|
+
min,
|
|
36
|
+
max,
|
|
37
|
+
// A function is read through a ref so a new closure each render does not rebuild the calendar.
|
|
38
|
+
unavailable: typeof unavailable === 'function' ? (day) => (typeof test.current === 'function' ? test.current(day) : false) : unavailable,
|
|
39
|
+
locale,
|
|
40
|
+
today,
|
|
41
|
+
labels,
|
|
42
|
+
onChange: (range) => change.current?.(range),
|
|
43
|
+
});
|
|
44
|
+
instance.current = created;
|
|
45
|
+
return () => {
|
|
46
|
+
start.current = created.value;
|
|
47
|
+
created.destroy();
|
|
48
|
+
instance.current = null;
|
|
49
|
+
};
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
}, [String(month ?? ''), visibleMonths, firstDay, String(min ?? ''), String(max ?? ''), rules, locale, String(today ?? '')]);
|
|
52
|
+
useIsomorphicLayoutEffect(() => {
|
|
53
|
+
if (value !== undefined && instance.current && keyOf(value) !== keyOf(instance.current.value)) instance.current.setValue(value);
|
|
54
|
+
}, [keyOf(value)]);
|
|
55
|
+
return <div {...props} ref={ref} className={['mk-range-calendar', className].filter(Boolean).join(' ')} />;
|
|
56
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# range-slider
|
|
2
|
+
|
|
3
|
+
Valor o intervalo sobre `<input type="range">` nativos: teclado, toque, formularios y `disabled` vienen de la plataforma. Dos inputs forman un intervalo cuyos extremos nunca se cruzan.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<mk-range-slider class="mk-range-slider" min="0" max="1000" step="50" label="Presupuesto">
|
|
7
|
+
<div data-mk-range-track>
|
|
8
|
+
<input type="range" data-mk-range-input value="200" />
|
|
9
|
+
<input type="range" data-mk-range-input value="800" />
|
|
10
|
+
</div>
|
|
11
|
+
<output data-mk-range-output></output>
|
|
12
|
+
</mk-range-slider>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`defineElements()`, `createRangeSlider(root, options)` o `<RangeSlider min={0} max={1000} defaultValue={[200, 800]} label="Presupuesto" onChange={setRange} />`. Sin inputs en el root, el motor crea uno (o dos si `value` es un array).
|
|
16
|
+
|
|
17
|
+
Opciones: `min=0`, `max=100`, `step=1`, `value` (número o `[a, b]`), `disabled`, `name` (un intervalo envía `name[0]` y `name[1]`), `label` (aria-label; en intervalo «· mínimo/· máximo»), `formatValue(n)` (output y `aria-valuetext`), `onInput(value)`, `onChange(value)`. Sin opción, los límites se leen de los atributos del primer input; un `value` autorado que el navegador recortó al rango por defecto (0–100) se respeta. API: `setValue(value, notify=true)` (con `notify=false` no avisa ni cambia el valor confirmado, así un padre controlado puede reflejar cada `input` sin perder el `change`), `value` (copia), `destroy()`. En el custom element, `el.formatValue = (n) => …` aplica un formateador.
|
|
18
|
+
|
|
19
|
+
`input` actualiza valor, relleno y output al instante y emite `mk:input`; `change` confirma una sola vez cuando el valor cambió y emite `mk:change` con `{value, previous}`. Los valores se ajustan al paso desde `min` sin errores decimales, se acotan al mayor `min + n·step ≤ max` e ignoran NaN. Al arrastrar un extremo más allá del otro se queda en el otro.
|
|
20
|
+
|
|
21
|
+
El reset nativo del formulario recupera los valores por defecto de los inputs sin callbacks (un reset cancelado no cambia nada). `disabled` ignora la entrada del usuario. `destroy()` restaura valores, atributos, estilos y texto del output. React conserva la edición no controlada entre renders y la ajusta a nuevos límites; con `value` es controlado.
|
|
22
|
+
|
|
23
|
+
Movimiento: el motor dibuja relleno, pulgares y una burbuja con el valor (`[data-mk-range-visual]`; los inputs nativos quedan como zona de toque transparente). Al pulsar, el pulgar crece y la burbuja aparece; arrastrar sigue al puntero sin retraso; `setValue` y el teclado se deslizan; confirmar un cambio da un pequeño rebote al output. Variables: `--mk-range-thumb` (1.5rem), `--mk-range-height` (8px), `--mk-range-track`, `--mk-range-fill`. El output no es región viva: los inputs anuncian su propio valor. Movimiento reducido quita escalas y deslizamientos.
|