@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,167 @@
|
|
|
1
|
+
/* bidirectional-slider — a chunky 12 px track whose fill grows from the origin notch towards the thumb:
|
|
2
|
+
"more" in the accent, "less" in a tint of it. − and + sit at the ends; the bubble shows the signed value while held. */
|
|
3
|
+
.mk-bidirectional-slider,
|
|
4
|
+
mk-bidirectional-slider {
|
|
5
|
+
--mk-bislider-height: 2.75rem;
|
|
6
|
+
--mk-bislider-track: var(--mk-surface-2);
|
|
7
|
+
--mk-bislider-more: var(--mk-accent);
|
|
8
|
+
--mk-bislider-less: color-mix(in srgb, var(--mk-accent) 45%, var(--mk-surface-2));
|
|
9
|
+
display: grid;
|
|
10
|
+
grid-template-columns: auto minmax(6rem, 1fr) auto;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: 0.375rem;
|
|
13
|
+
width: 100%;
|
|
14
|
+
max-width: 26rem;
|
|
15
|
+
color: var(--mk-text);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[data-mk-bislider-track] {
|
|
19
|
+
position: relative;
|
|
20
|
+
height: var(--mk-bislider-height);
|
|
21
|
+
border-radius: 12px;
|
|
22
|
+
background: var(--mk-bislider-track);
|
|
23
|
+
touch-action: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[data-mk-bislider-track]:has(input:focus-visible) {
|
|
27
|
+
outline: 2px solid var(--mk-accent);
|
|
28
|
+
outline-offset: 3px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-mk-bislider-clip] {
|
|
32
|
+
position: absolute;
|
|
33
|
+
inset: 0;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
border-radius: inherit;
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[data-mk-bislider-fill] {
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: 0;
|
|
42
|
+
bottom: 0;
|
|
43
|
+
background: var(--mk-bislider-more);
|
|
44
|
+
transition: background-color 0.2s ease;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:is(.mk-bidirectional-slider, mk-bidirectional-slider)[data-mk-side='less'] [data-mk-bislider-fill] {
|
|
48
|
+
background: var(--mk-bislider-less);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[data-mk-bislider-notch] {
|
|
52
|
+
position: absolute;
|
|
53
|
+
top: 30%;
|
|
54
|
+
bottom: 30%;
|
|
55
|
+
width: 2px;
|
|
56
|
+
margin-left: -1px;
|
|
57
|
+
border-radius: 2px;
|
|
58
|
+
background: color-mix(in srgb, var(--mk-text) 30%, transparent);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-mk-bislider-thumb] {
|
|
62
|
+
position: absolute;
|
|
63
|
+
top: 20%;
|
|
64
|
+
bottom: 20%;
|
|
65
|
+
width: 4px;
|
|
66
|
+
margin-left: -2px;
|
|
67
|
+
border-radius: 4px;
|
|
68
|
+
background: var(--mk-text);
|
|
69
|
+
pointer-events: none;
|
|
70
|
+
transition: transform 0.35s var(--mk-ease-swatch);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:is(.mk-bidirectional-slider, mk-bidirectional-slider)[data-mk-held] [data-mk-bislider-thumb] {
|
|
74
|
+
transform: scale(1.5, 1.2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
[data-mk-bislider-bubble] {
|
|
78
|
+
position: absolute;
|
|
79
|
+
bottom: calc(100% + 0.5rem);
|
|
80
|
+
padding: 0.2rem 0.55rem;
|
|
81
|
+
border-radius: var(--mk-radius-full);
|
|
82
|
+
background: var(--mk-glass-inverse);
|
|
83
|
+
box-shadow: var(--mk-glass-bevel);
|
|
84
|
+
color: var(--mk-on-glass-inverse);
|
|
85
|
+
font: 600 0.75rem/1.2 var(--mk-font);
|
|
86
|
+
font-variant-numeric: tabular-nums;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
pointer-events: none;
|
|
89
|
+
opacity: 0;
|
|
90
|
+
transform: translate(-50%, 4px) scale(0.85);
|
|
91
|
+
transform-origin: 50% 100%;
|
|
92
|
+
transition:
|
|
93
|
+
opacity 0.15s ease,
|
|
94
|
+
transform 0.3s var(--mk-ease-swatch);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
:is(.mk-bidirectional-slider, mk-bidirectional-slider):is([data-mk-held], :has(input:focus-visible)) [data-mk-bislider-bubble] {
|
|
98
|
+
opacity: 1;
|
|
99
|
+
transform: translate(-50%, 0) scale(1);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[data-mk-bislider-input] {
|
|
103
|
+
position: absolute;
|
|
104
|
+
inset: 0;
|
|
105
|
+
width: 100%;
|
|
106
|
+
height: 100%;
|
|
107
|
+
margin: 0;
|
|
108
|
+
opacity: 0;
|
|
109
|
+
cursor: grab;
|
|
110
|
+
appearance: none;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:is(.mk-bidirectional-slider, mk-bidirectional-slider)[data-mk-held] [data-mk-bislider-input] {
|
|
114
|
+
cursor: grabbing;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
:is([data-mk-bislider-less], [data-mk-bislider-more]) {
|
|
118
|
+
display: grid;
|
|
119
|
+
place-items: center;
|
|
120
|
+
width: var(--mk-bislider-height);
|
|
121
|
+
height: var(--mk-bislider-height);
|
|
122
|
+
padding: 0;
|
|
123
|
+
border: 0;
|
|
124
|
+
border-radius: 12px;
|
|
125
|
+
background: transparent;
|
|
126
|
+
color: inherit;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
transition: background-color 0.15s ease;
|
|
129
|
+
-webkit-tap-highlight-color: transparent;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
:is([data-mk-bislider-less], [data-mk-bislider-more]) svg {
|
|
133
|
+
width: 1.25rem;
|
|
134
|
+
height: 1.25rem;
|
|
135
|
+
fill: none;
|
|
136
|
+
stroke: currentColor;
|
|
137
|
+
stroke-width: 2;
|
|
138
|
+
stroke-linecap: round;
|
|
139
|
+
stroke-linejoin: round;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@media (hover: hover) {
|
|
143
|
+
:is([data-mk-bislider-less], [data-mk-bislider-more]):hover {
|
|
144
|
+
background: var(--mk-surface-2);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
:is(.mk-bidirectional-slider, mk-bidirectional-slider):has(input:disabled) {
|
|
149
|
+
opacity: 0.5;
|
|
150
|
+
pointer-events: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@media (prefers-reduced-motion: reduce) {
|
|
154
|
+
[data-mk-bislider-thumb],
|
|
155
|
+
[data-mk-bislider-bubble] {
|
|
156
|
+
transition: opacity 0.15s ease;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@media (forced-colors: active) {
|
|
161
|
+
[data-mk-bislider-fill] {
|
|
162
|
+
background: Highlight !important;
|
|
163
|
+
}
|
|
164
|
+
[data-mk-bislider-track] {
|
|
165
|
+
border: 1px solid CanvasText;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createBidirectionalSlider, type BidirectionalSliderInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-bidirectional-slider class="mk-bidirectional-slider" label="Volumen" icons="volume" value="20"></mk-bidirectional-slider>
|
|
6
|
+
* A value either side of an origin; the fill grows from it. Emits mk:input and mk:change ({value}).
|
|
7
|
+
*/
|
|
8
|
+
export class MkBidirectionalSliderElement extends MkElement<BidirectionalSliderInstance> {
|
|
9
|
+
static options: Record<string, OptionType> = {
|
|
10
|
+
min: 'number',
|
|
11
|
+
max: 'number',
|
|
12
|
+
origin: 'number',
|
|
13
|
+
step: 'number',
|
|
14
|
+
value: 'number',
|
|
15
|
+
disabled: 'boolean',
|
|
16
|
+
name: 'string',
|
|
17
|
+
label: 'string',
|
|
18
|
+
icons: 'string',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
protected create(options: Record<string, unknown>) {
|
|
22
|
+
return createBidirectionalSlider(this, { ...options, icons: options.icons === 'none' ? false : (options.icons as 'signs' | 'volume' | undefined) });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get value() {
|
|
26
|
+
return this.instance?.value ?? 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
set value(next: number) { this.setValue(next); }
|
|
30
|
+
setValue(value: number, notify = false) { this.instance?.setValue(value, notify); }
|
|
31
|
+
reset(notify = false) { this.instance?.reset(notify); }
|
|
32
|
+
|
|
33
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null) {
|
|
34
|
+
if (name === 'value' && this.instance) {
|
|
35
|
+
this.instance.setValue(Number(next ?? this.options.origin ?? 0));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
super.attributeChangedCallback(name, previous, next);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const defineBidirectionalSlider = () => defineElement('mk-bidirectional-slider', MkBidirectionalSliderElement);
|
|
@@ -0,0 +1,289 @@
|
|
|
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 { press } from '../../motion/micro';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Bidirectional slider: a value either side of an origin (−100…100 around 0 by
|
|
9
|
+
* default), for volume, balance, exposure or a correction. The fill grows from
|
|
10
|
+
* the origin towards the thumb in the "less" or "more" colour; crossing the
|
|
11
|
+
* origin pops its notch; reaching an end bumps that end's icon. Dragging past
|
|
12
|
+
* an end stretches the track like rubber (up to 4 %) and it springs back when
|
|
13
|
+
* let go. The − and + buttons step it (held, they repeat), a double click
|
|
14
|
+
* glides back to the origin, and a bubble shows the signed value while it is
|
|
15
|
+
* held or focused. Keys, the buttons and setValue glide on the swatch curve
|
|
16
|
+
* (.38,.49,0,1.5); dragging follows the pointer. Built on a native
|
|
17
|
+
* <input type="range"> (keyboard, touch, forms and assistive tech).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export interface BidirectionalSliderOptions {
|
|
21
|
+
/** Default −100. */
|
|
22
|
+
min?: number;
|
|
23
|
+
/** Default 100. */
|
|
24
|
+
max?: number;
|
|
25
|
+
/** Where the fill starts (default 0, kept inside min…max). */
|
|
26
|
+
origin?: number;
|
|
27
|
+
step?: number;
|
|
28
|
+
value?: number;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
name?: string;
|
|
31
|
+
/** Accessible name of the input. */
|
|
32
|
+
label?: string;
|
|
33
|
+
/** The end icons: − and + (default), the speaker, or none. */
|
|
34
|
+
icons?: 'signs' | 'volume' | false;
|
|
35
|
+
/** Text for the bubble and aria-valuetext (default: signed, "+24", "−12"). */
|
|
36
|
+
formatValue?: (value: number) => string;
|
|
37
|
+
onInput?: (value: number) => void;
|
|
38
|
+
onChange?: (value: number) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface BidirectionalSliderInstance extends Instance {
|
|
42
|
+
setValue(value: number, notify?: boolean): void;
|
|
43
|
+
/** Back to the origin. */
|
|
44
|
+
reset(notify?: boolean): void;
|
|
45
|
+
readonly value: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const finite = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value);
|
|
49
|
+
const ICONS = {
|
|
50
|
+
signs: ['<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 12h12"/></svg>', '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 12h12M12 6v12"/></svg>'],
|
|
51
|
+
volume: [
|
|
52
|
+
'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9.5v5h3.5L12 18.5v-13L7.5 9.5z"/><path d="M15.5 9.5a3.5 3.5 0 0 1 0 5"/></svg>',
|
|
53
|
+
'<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 9.5v5h3.5L12 18.5v-13L7.5 9.5z"/><path d="M15.5 9.5a3.5 3.5 0 0 1 0 5"/><path d="M18 7a7 7 0 0 1 0 10"/></svg>',
|
|
54
|
+
],
|
|
55
|
+
} as const;
|
|
56
|
+
|
|
57
|
+
export function createBidirectionalSlider(root: HTMLElement | null, options: BidirectionalSliderOptions = {}): BidirectionalSliderInstance {
|
|
58
|
+
if (!root) return inert({ setValue() {}, reset() {}, value: 0 });
|
|
59
|
+
registerMotion();
|
|
60
|
+
const scope = createScope();
|
|
61
|
+
const min = finite(options.min) ? options.min : -100;
|
|
62
|
+
const max = finite(options.max) && options.max > min ? options.max : Math.max(min + 1, 100);
|
|
63
|
+
const origin = Math.min(max, Math.max(min, finite(options.origin) ? options.origin : 0));
|
|
64
|
+
const step = finite(options.step) && options.step > 0 ? options.step : 1;
|
|
65
|
+
const decimals = (String(step).split('.')[1] ?? '').length;
|
|
66
|
+
const snap = (n: number) => Number(Math.min(max, Math.max(min, Math.round((n - min) / step) * step + min)).toFixed(decimals));
|
|
67
|
+
const format =
|
|
68
|
+
options.formatValue ??
|
|
69
|
+
((n: number) => {
|
|
70
|
+
const delta = Number((n - origin).toFixed(decimals));
|
|
71
|
+
const text = new Intl.NumberFormat(undefined, { maximumFractionDigits: decimals }).format(Math.abs(delta));
|
|
72
|
+
return delta > 0 ? `+${text}` : delta < 0 ? `−${text}` : text;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const made = <K extends keyof HTMLElementTagNameMap>(tag: K, parent: Element, data: string) => {
|
|
76
|
+
const element = document.createElement(tag);
|
|
77
|
+
element.setAttribute(`data-mk-bislider-${data}`, '');
|
|
78
|
+
parent.append(element);
|
|
79
|
+
scope.add(() => element.remove());
|
|
80
|
+
return element;
|
|
81
|
+
};
|
|
82
|
+
const icons = options.icons === false ? null : ICONS[options.icons ?? 'signs'];
|
|
83
|
+
const less = icons ? made('button', root, 'less') : null;
|
|
84
|
+
const track = made('span', root, 'track');
|
|
85
|
+
const more = icons ? made('button', root, 'more') : null;
|
|
86
|
+
if (less && more && icons) {
|
|
87
|
+
less.type = more.type = 'button';
|
|
88
|
+
less.tabIndex = more.tabIndex = -1;
|
|
89
|
+
less.innerHTML = icons[0];
|
|
90
|
+
more.innerHTML = icons[1];
|
|
91
|
+
less.setAttribute('aria-label', 'Menos');
|
|
92
|
+
more.setAttribute('aria-label', 'Más');
|
|
93
|
+
root.prepend(less);
|
|
94
|
+
}
|
|
95
|
+
// The fill and notch are clipped to the track's corners; the thumb and bubble are not.
|
|
96
|
+
const clip = made('span', track, 'clip');
|
|
97
|
+
clip.setAttribute('aria-hidden', 'true');
|
|
98
|
+
const fill = made('span', clip, 'fill');
|
|
99
|
+
const notch = made('span', clip, 'notch');
|
|
100
|
+
const thumb = made('span', track, 'thumb');
|
|
101
|
+
const bubble = made('span', track, 'bubble');
|
|
102
|
+
for (const part of [fill, notch, thumb, bubble]) part.setAttribute('aria-hidden', 'true');
|
|
103
|
+
|
|
104
|
+
let input = root.querySelector<HTMLInputElement>('input[type="range"]');
|
|
105
|
+
if (input) {
|
|
106
|
+
// An authored input goes into the track and back to its place (with its attributes) on destroy.
|
|
107
|
+
const kept = input;
|
|
108
|
+
const place = { parent: kept.parentNode, next: kept.nextSibling };
|
|
109
|
+
const saved = ['min', 'max', 'step', 'value', 'data-mk-bislider-input'].map((name) => [name, kept.getAttribute(name)] as const);
|
|
110
|
+
const value = kept.value;
|
|
111
|
+
scope.add(() => {
|
|
112
|
+
for (const [name, was] of saved) {
|
|
113
|
+
if (was === null) kept.removeAttribute(name);
|
|
114
|
+
else kept.setAttribute(name, was);
|
|
115
|
+
}
|
|
116
|
+
kept.value = value;
|
|
117
|
+
place.parent?.insertBefore(kept, place.next);
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
input = document.createElement('input');
|
|
121
|
+
input.type = 'range';
|
|
122
|
+
scope.add(() => input!.remove());
|
|
123
|
+
}
|
|
124
|
+
const range = input;
|
|
125
|
+
track.append(range);
|
|
126
|
+
range.dataset.mkBisliderInput = '';
|
|
127
|
+
range.min = String(min);
|
|
128
|
+
range.max = String(max);
|
|
129
|
+
range.step = String(step);
|
|
130
|
+
if (options.name) scope.attr(range, 'name', options.name);
|
|
131
|
+
if (options.label && !range.getAttribute('aria-label')) scope.attr(range, 'aria-label', options.label);
|
|
132
|
+
if (options.disabled) scope.attr(range, 'disabled', '');
|
|
133
|
+
const start = snap(finite(options.value) ? options.value : range.getAttribute('value') !== null ? Number(range.getAttribute('value')) : origin);
|
|
134
|
+
range.value = String(start);
|
|
135
|
+
range.defaultValue = String(start);
|
|
136
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
137
|
+
|
|
138
|
+
let value = start;
|
|
139
|
+
let committed = start;
|
|
140
|
+
/** What is drawn (trails the value while gliding). */
|
|
141
|
+
const shown = { v: start };
|
|
142
|
+
const pct = (n: number) => ((n - min) / (max - min)) * 100;
|
|
143
|
+
notch.style.left = `${pct(origin)}%`;
|
|
144
|
+
|
|
145
|
+
const paint = () => {
|
|
146
|
+
const at = pct(shown.v);
|
|
147
|
+
const from = pct(origin);
|
|
148
|
+
fill.style.left = `${Math.min(at, from)}%`;
|
|
149
|
+
fill.style.width = `${Math.abs(at - from)}%`;
|
|
150
|
+
thumb.style.left = `${at}%`;
|
|
151
|
+
bubble.style.left = `${at}%`;
|
|
152
|
+
root.setAttribute('data-mk-side', shown.v > origin ? 'more' : shown.v < origin ? 'less' : 'origin');
|
|
153
|
+
};
|
|
154
|
+
scope.add(() => root.removeAttribute('data-mk-side'));
|
|
155
|
+
const describe = () => {
|
|
156
|
+
const text = format(value);
|
|
157
|
+
bubble.textContent = text;
|
|
158
|
+
range.setAttribute('aria-valuetext', text);
|
|
159
|
+
};
|
|
160
|
+
scope.add(() => range.removeAttribute('aria-valuetext'));
|
|
161
|
+
|
|
162
|
+
const effects = new Set<gsap.core.Animation>();
|
|
163
|
+
const keep = (animation: gsap.core.Animation | null) => {
|
|
164
|
+
if (!animation) return;
|
|
165
|
+
effects.add(animation);
|
|
166
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
167
|
+
};
|
|
168
|
+
scope.add(() => {
|
|
169
|
+
gsap.killTweensOf(shown);
|
|
170
|
+
for (const effect of effects) effect.kill();
|
|
171
|
+
effects.clear();
|
|
172
|
+
});
|
|
173
|
+
const bump = (element: Element | null, scale = 1.25) => {
|
|
174
|
+
if (!element || reduced()) return;
|
|
175
|
+
keep(gsap.fromTo(element, { scale }, { scale: 1, duration: 0.5, ease: 'elastic.out(1, 0.4)', overwrite: 'auto' }));
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
let held = false;
|
|
179
|
+
/** Set the value; `glide` tweens the drawing, else it follows at once. */
|
|
180
|
+
const set = (next: number, glide: boolean, notify: 'input' | 'change' | false) => {
|
|
181
|
+
const before = value;
|
|
182
|
+
value = snap(next);
|
|
183
|
+
range.value = String(value);
|
|
184
|
+
describe();
|
|
185
|
+
gsap.killTweensOf(shown);
|
|
186
|
+
if (glide && !reduced()) keep(gsap.to(shown, { v: value, duration: 0.45, ease: EASE.swatch, onUpdate: paint }));
|
|
187
|
+
else {
|
|
188
|
+
shown.v = value;
|
|
189
|
+
paint();
|
|
190
|
+
}
|
|
191
|
+
// Crossing the origin pops its notch; arriving at an end bumps that end's icon.
|
|
192
|
+
if ((before - origin) * (value - origin) < 0 || (before !== origin && value === origin)) bump(notch, 1.8);
|
|
193
|
+
if (value !== before && value === max) bump(more);
|
|
194
|
+
if (value !== before && value === min) bump(less);
|
|
195
|
+
if (notify && value !== before) {
|
|
196
|
+
options.onInput?.(value);
|
|
197
|
+
root.dispatchEvent(new CustomEvent('mk:input', { bubbles: true, detail: { value } }));
|
|
198
|
+
}
|
|
199
|
+
if (notify === 'change') commit();
|
|
200
|
+
};
|
|
201
|
+
const commit = () => {
|
|
202
|
+
if (value === committed) return;
|
|
203
|
+
committed = value;
|
|
204
|
+
options.onChange?.(value);
|
|
205
|
+
root.dispatchEvent(new CustomEvent('mk:change', { bubbles: true, detail: { value } }));
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
scope.on(range, 'input', () => {
|
|
209
|
+
const next = Number(range.value);
|
|
210
|
+
const before = value;
|
|
211
|
+
set(next, !held, false);
|
|
212
|
+
if (value !== before) {
|
|
213
|
+
options.onInput?.(value);
|
|
214
|
+
root.dispatchEvent(new CustomEvent('mk:input', { bubbles: true, detail: { value } }));
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
scope.on(range, 'change', commit);
|
|
218
|
+
scope.on(range, 'dblclick', () => set(origin, true, 'change'));
|
|
219
|
+
|
|
220
|
+
// Held: the thumb grows and the bubble shows; past an end, the track stretches like rubber.
|
|
221
|
+
let pointer: number | null = null;
|
|
222
|
+
scope.on(range, 'pointerdown', (event) => {
|
|
223
|
+
const down = event as PointerEvent;
|
|
224
|
+
if (range.disabled || down.button !== 0) return;
|
|
225
|
+
held = true;
|
|
226
|
+
pointer = down.pointerId;
|
|
227
|
+
root.setAttribute('data-mk-held', '');
|
|
228
|
+
});
|
|
229
|
+
scope.on(window, 'pointermove', (event) => {
|
|
230
|
+
const move = event as PointerEvent;
|
|
231
|
+
if (!held || move.pointerId !== pointer || reduced()) return;
|
|
232
|
+
const box = track.getBoundingClientRect();
|
|
233
|
+
const over = move.clientX > box.right ? move.clientX - box.right : move.clientX < box.left ? move.clientX - box.left : 0;
|
|
234
|
+
const stretch = Math.min(1, Math.abs(over) / 80) * 0.04;
|
|
235
|
+
gsap.set(track, { scaleX: 1 + stretch, transformOrigin: over > 0 ? '0% 50%' : '100% 50%' });
|
|
236
|
+
});
|
|
237
|
+
const release = (event: Event) => {
|
|
238
|
+
if (!held || (event as PointerEvent).pointerId !== pointer) return;
|
|
239
|
+
held = false;
|
|
240
|
+
pointer = null;
|
|
241
|
+
root.removeAttribute('data-mk-held');
|
|
242
|
+
if (!reduced()) keep(gsap.to(track, { scaleX: 1, duration: 0.6, ease: 'elastic.out(1, 0.35)', clearProps: 'transform,transformOrigin' }));
|
|
243
|
+
};
|
|
244
|
+
scope.on(window, 'pointerup', release);
|
|
245
|
+
scope.on(window, 'pointercancel', release);
|
|
246
|
+
scope.add(() => {
|
|
247
|
+
root.removeAttribute('data-mk-held');
|
|
248
|
+
gsap.set(track, { clearProps: 'transform,transformOrigin' });
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// − and +: a step per press, repeating while held.
|
|
252
|
+
let repeat: ReturnType<typeof setTimeout> | undefined;
|
|
253
|
+
const stop = () => {
|
|
254
|
+
clearTimeout(repeat);
|
|
255
|
+
if (repeat !== undefined) commit();
|
|
256
|
+
repeat = undefined;
|
|
257
|
+
};
|
|
258
|
+
scope.add(() => clearTimeout(repeat));
|
|
259
|
+
for (const [button, direction] of [[less, -1], [more, 1]] as const) {
|
|
260
|
+
if (!button) continue;
|
|
261
|
+
scope.on(button, 'pointerdown', (event) => {
|
|
262
|
+
if (range.disabled || (event as PointerEvent).button !== 0) return;
|
|
263
|
+
event.preventDefault();
|
|
264
|
+
press(button);
|
|
265
|
+
const tick = (delay: number) => {
|
|
266
|
+
set(value + step * direction, true, 'input');
|
|
267
|
+
repeat = setTimeout(() => tick(Math.max(50, delay * 0.8)), delay);
|
|
268
|
+
};
|
|
269
|
+
tick(400);
|
|
270
|
+
});
|
|
271
|
+
scope.on(button, 'pointerup', stop);
|
|
272
|
+
scope.on(button, 'pointerleave', stop);
|
|
273
|
+
scope.on(button, 'pointercancel', stop);
|
|
274
|
+
}
|
|
275
|
+
const form = range.form;
|
|
276
|
+
if (form) scope.on(form, 'reset', () => setTimeout(() => set(Number(range.defaultValue), true, false)));
|
|
277
|
+
|
|
278
|
+
describe();
|
|
279
|
+
paint();
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
setValue: (next, notify = false) => set(next, true, notify ? 'change' : false),
|
|
283
|
+
reset: (notify = false) => set(origin, true, notify ? 'change' : false),
|
|
284
|
+
get value() {
|
|
285
|
+
return value;
|
|
286
|
+
},
|
|
287
|
+
destroy: () => scope.dispose(),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes, type MutableRefObject } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { createBidirectionalSlider, type BidirectionalSliderInstance, type BidirectionalSliderOptions } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface BidirectionalSliderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'onInput'>, BidirectionalSliderOptions {
|
|
7
|
+
instanceRef?: MutableRefObject<BidirectionalSliderInstance | null>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** <BidirectionalSlider label="Volumen" icons="volume" value={volume} onChange={setVolume} /> */
|
|
11
|
+
export function BidirectionalSlider({ min, max, origin, step, value, disabled, name, label, icons, formatValue, onInput, onChange, instanceRef, className, ...props }: BidirectionalSliderProps) {
|
|
12
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
13
|
+
const input = useLatest(onInput);
|
|
14
|
+
const change = useLatest(onChange);
|
|
15
|
+
const format = useLatest(formatValue);
|
|
16
|
+
const instance = useRef<BidirectionalSliderInstance | null>(null);
|
|
17
|
+
useIsomorphicLayoutEffect(() => {
|
|
18
|
+
const created = createBidirectionalSlider(ref.current, {
|
|
19
|
+
min,
|
|
20
|
+
max,
|
|
21
|
+
origin,
|
|
22
|
+
step,
|
|
23
|
+
value,
|
|
24
|
+
disabled,
|
|
25
|
+
name,
|
|
26
|
+
label,
|
|
27
|
+
icons,
|
|
28
|
+
formatValue: formatValue ? (n) => format.current!(n) : undefined,
|
|
29
|
+
onInput: (n) => input.current?.(n),
|
|
30
|
+
onChange: (n) => change.current?.(n),
|
|
31
|
+
});
|
|
32
|
+
instance.current = created;
|
|
33
|
+
if (instanceRef) instanceRef.current = created;
|
|
34
|
+
return () => {
|
|
35
|
+
created.destroy();
|
|
36
|
+
instance.current = null;
|
|
37
|
+
if (instanceRef) instanceRef.current = null;
|
|
38
|
+
};
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [min, max, origin, step, disabled, name, label, icons]);
|
|
41
|
+
useIsomorphicLayoutEffect(() => {
|
|
42
|
+
if (value !== undefined && instance.current && instance.current.value !== value) instance.current.setValue(value);
|
|
43
|
+
}, [value]);
|
|
44
|
+
return <div {...props} ref={ref} className={['mk-bidirectional-slider', className].filter(Boolean).join(' ')} />;
|
|
45
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# breadcrumb
|
|
2
|
+
|
|
3
|
+
Ruta de navegación jerárquica: una lista ordenada dentro de `<nav aria-label>`, donde el último elemento es la página actual (`aria-current="page"`). Cuando no cabe (o pasa de `maxItems`), los niveles intermedios se pliegan en un botón «…»; al pulsarlo aparecen en su sitio, entrando desde la izquierda con blur (40 ms entre niveles) mientras el resto se desliza para hacerles hueco.
|
|
4
|
+
|
|
5
|
+
`setItems()` conserva el principio común de la ruta: lo que se queda se desliza a su nuevo sitio (resorte de reflujo), lo nuevo entra desde la derecha y la antigua página actual se vuelve enlace. Los enlaces se subrayan desde la izquierda al señalarlos.
|
|
6
|
+
|
|
7
|
+
## HTML / Astro
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<mk-breadcrumb class="mk-breadcrumb"
|
|
11
|
+
items='[{"label":"Inicio","href":"/"},{"label":"Proyectos","href":"/proyectos"},{"label":"Melon"}]'></mk-breadcrumb>
|
|
12
|
+
|
|
13
|
+
<!-- O con enlaces escritos: -->
|
|
14
|
+
<div class="mk-breadcrumb" data-mk="breadcrumb"><a href="/">Inicio</a><a href="/docs">Docs</a><span>API</span></div>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## React
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<Breadcrumb items={path} onNavigate={(item, index, event) => { event.preventDefault(); router.push(item.href!); }} />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Opciones
|
|
24
|
+
|
|
25
|
+
| Opción | Atributo | Por defecto | Qué hace |
|
|
26
|
+
|---|---|---|---|
|
|
27
|
+
| `items` | `items` (JSON) | lo escrito dentro | `{ label, href? }[]`; el último es la página actual. |
|
|
28
|
+
| `label` | `label` | `'Ruta de navegación'` | Nombre accesible del `<nav>`. |
|
|
29
|
+
| `maxItems` | `max-items` | `'auto'` | Número máximo de niveles visibles; `auto` pliega solo cuando no cabe. |
|
|
30
|
+
| `onNavigate(item, index, event)` | — | — | Antes de seguir un enlace; `event.preventDefault()` deja la navegación a tu router. |
|
|
31
|
+
|
|
32
|
+
## API y eventos
|
|
33
|
+
|
|
34
|
+
`setItems(items)`, `items`, `destroy()`. Evento `mk:navigate` con `{ item, index }`, cancelable.
|
|
35
|
+
|
|
36
|
+
## Estilo
|
|
37
|
+
|
|
38
|
+
Enlaces atenuados con chevrons entre niveles; la página actual en el color del texto y con elipsis como último recurso; el «…» es un botón de 8 px sobre `--mk-surface-3`. Con movimiento reducido todo cambia sin transición.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* breadcrumb — muted links separated by chevrons, the current page in the text colour; links underline from the left
|
|
2
|
+
on hover (.25 s, wipe curve); the folded middle is a small 8 px "…" button on surface-3. The row never scrolls: it
|
|
3
|
+
folds, and the current page ellipsizes as a last resort. */
|
|
4
|
+
.mk-breadcrumb,
|
|
5
|
+
mk-breadcrumb {
|
|
6
|
+
display: block;
|
|
7
|
+
min-width: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[data-mk-breadcrumb-list] {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-wrap: nowrap;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 0.25rem;
|
|
15
|
+
min-width: 0;
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
color: var(--mk-muted);
|
|
20
|
+
font-size: 0.875rem;
|
|
21
|
+
line-height: 1.4;
|
|
22
|
+
list-style: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[data-mk-breadcrumb-nav][data-mk-expanded] [data-mk-breadcrumb-list] {
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
overflow: visible;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
[data-mk-crumb] {
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
flex: none;
|
|
33
|
+
align-items: center;
|
|
34
|
+
gap: 0.25rem;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-mk-crumb]:last-child {
|
|
39
|
+
flex: 0 1 auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* While the engine measures, the current page keeps its full width. */
|
|
43
|
+
[data-mk-breadcrumb-nav][data-mk-measuring] [data-mk-crumb]:last-child {
|
|
44
|
+
flex: none;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[data-mk-crumb] + [data-mk-crumb]::before {
|
|
48
|
+
content: '';
|
|
49
|
+
flex: none;
|
|
50
|
+
width: 1rem;
|
|
51
|
+
height: 1rem;
|
|
52
|
+
background: currentColor;
|
|
53
|
+
opacity: 0.6;
|
|
54
|
+
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6l6 6-6 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 1rem no-repeat;
|
|
55
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6l6 6-6 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 1rem no-repeat;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[data-mk-crumb-link] {
|
|
59
|
+
padding: 0.15rem 0;
|
|
60
|
+
background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
|
|
61
|
+
color: inherit;
|
|
62
|
+
text-decoration: none;
|
|
63
|
+
transition: background-size 0.25s cubic-bezier(0.38, 0.49, 0, 1), color 0.2s ease;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[data-mk-crumb-link]:hover {
|
|
67
|
+
background-size: 100% 1px;
|
|
68
|
+
color: var(--mk-text);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[data-mk-crumb-link]:focus-visible,
|
|
72
|
+
[data-mk-crumb-more]:focus-visible {
|
|
73
|
+
border-radius: 6px;
|
|
74
|
+
outline: 2px solid var(--mk-accent);
|
|
75
|
+
outline-offset: 2px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[data-mk-crumb-current] {
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
color: var(--mk-text);
|
|
81
|
+
font-weight: 600;
|
|
82
|
+
text-overflow: ellipsis;
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
[data-mk-crumb-more] {
|
|
87
|
+
height: 1.5rem;
|
|
88
|
+
padding: 0 0.45rem;
|
|
89
|
+
border: 0;
|
|
90
|
+
border-radius: 8px;
|
|
91
|
+
background: var(--mk-surface-3);
|
|
92
|
+
color: inherit;
|
|
93
|
+
font: inherit;
|
|
94
|
+
line-height: 1;
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
transition: background-color 0.2s ease, color 0.2s ease;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[data-mk-crumb-more]:hover {
|
|
100
|
+
background: var(--mk-surface-4, var(--mk-surface-3));
|
|
101
|
+
color: var(--mk-text);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@media (prefers-reduced-motion: reduce) {
|
|
105
|
+
[data-mk-crumb-link],
|
|
106
|
+
[data-mk-crumb-more] {
|
|
107
|
+
transition: none;
|
|
108
|
+
}
|
|
109
|
+
}
|