@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,112 @@
|
|
|
1
|
+
/* color-slider — one colour channel: a pill track with the channel's gradient (alpha over a checkerboard) and a round
|
|
2
|
+
thumb filled with the colour; grabbing grows it and pops a loupe. The native range is a transparent hit area. */
|
|
3
|
+
.mk-color-slider,
|
|
4
|
+
mk-color-slider {
|
|
5
|
+
--mk-color-size: 1.75rem;
|
|
6
|
+
--mk-color-length: 12rem;
|
|
7
|
+
--mk-color-checker: repeating-conic-gradient(#d4d4d4 0 25%, #fff 0 50%) 0 0 / 10px 10px;
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
10
|
+
align-items: center;
|
|
11
|
+
gap: 0.75rem;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:is(.mk-color-slider, mk-color-slider) [data-mk-color-track] {
|
|
15
|
+
position: relative;
|
|
16
|
+
height: var(--mk-color-size);
|
|
17
|
+
border-radius: 999px;
|
|
18
|
+
background: var(--mk-color-track), var(--mk-color-checker);
|
|
19
|
+
box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
:is(.mk-color-slider, mk-color-slider) [data-mk-color-input] {
|
|
23
|
+
position: absolute;
|
|
24
|
+
inset: 0;
|
|
25
|
+
width: 100%;
|
|
26
|
+
height: 100%;
|
|
27
|
+
margin: 0;
|
|
28
|
+
opacity: 0;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:is(.mk-color-slider, mk-color-slider) [data-mk-color-thumb] {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 50%;
|
|
35
|
+
left: calc(clamp(0, var(--mk-color-pos, 0), 1) * (100% - var(--mk-color-size)));
|
|
36
|
+
width: var(--mk-color-size);
|
|
37
|
+
height: var(--mk-color-size);
|
|
38
|
+
margin-top: calc(var(--mk-color-size) / -2);
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
background: linear-gradient(var(--mk-color-thumb), var(--mk-color-thumb)), var(--mk-color-checker);
|
|
41
|
+
box-shadow: 0 0 0 3px #fff, 0 0 0 4px rgb(0 0 0 / 0.14), 0 4px 12px rgb(0 0 0 / 0.25);
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
:is(.mk-color-slider, mk-color-slider) [data-mk-color-track]:has(input:focus-visible) [data-mk-color-thumb] {
|
|
46
|
+
box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--mk-accent), 0 4px 12px rgb(0 0 0 / 0.25);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:is(.mk-color-slider, mk-color-slider) [data-mk-color-loupe] {
|
|
50
|
+
position: absolute;
|
|
51
|
+
bottom: calc(100% + 10px);
|
|
52
|
+
left: 50%;
|
|
53
|
+
width: 2.75rem;
|
|
54
|
+
height: 2.75rem;
|
|
55
|
+
margin-left: -1.375rem;
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
background: linear-gradient(var(--mk-color-thumb), var(--mk-color-thumb)), var(--mk-color-checker);
|
|
58
|
+
box-shadow: 0 0 0 3px #fff, 0 8px 20px rgb(0 0 0 / 0.25);
|
|
59
|
+
opacity: 0;
|
|
60
|
+
transform-origin: 50% 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Reduced motion: GSAP does not run, the attribute shows the loupe. */
|
|
64
|
+
@media (prefers-reduced-motion: reduce) {
|
|
65
|
+
:is(.mk-color-slider, mk-color-slider)[data-mk-grabbing] [data-mk-color-loupe] {
|
|
66
|
+
opacity: 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:is(.mk-color-slider, mk-color-slider) [data-mk-color-output] {
|
|
71
|
+
min-width: 3.5ch;
|
|
72
|
+
color: var(--mk-muted);
|
|
73
|
+
font-size: 0.8125rem;
|
|
74
|
+
font-variant-numeric: tabular-nums;
|
|
75
|
+
text-align: end;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
:is(.mk-color-slider, mk-color-slider) [data-mk-color-track]:has(input:disabled) {
|
|
79
|
+
opacity: 0.45;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Vertical: the track stands up, bottom is the minimum, the loupe sits on the left. */
|
|
83
|
+
:is(.mk-color-slider, mk-color-slider)[data-mk-orientation='vertical'] {
|
|
84
|
+
grid-template-columns: auto;
|
|
85
|
+
justify-items: center;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:is(.mk-color-slider, mk-color-slider)[data-mk-orientation='vertical'] [data-mk-color-track] {
|
|
89
|
+
width: var(--mk-color-size);
|
|
90
|
+
height: var(--mk-color-length);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:is(.mk-color-slider, mk-color-slider)[data-mk-orientation='vertical'] [data-mk-color-input] {
|
|
94
|
+
writing-mode: vertical-lr;
|
|
95
|
+
direction: rtl;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:is(.mk-color-slider, mk-color-slider)[data-mk-orientation='vertical'] [data-mk-color-thumb] {
|
|
99
|
+
top: auto;
|
|
100
|
+
bottom: calc(clamp(0, var(--mk-color-pos, 0), 1) * (100% - var(--mk-color-size)));
|
|
101
|
+
left: 0;
|
|
102
|
+
margin-top: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:is(.mk-color-slider, mk-color-slider)[data-mk-orientation='vertical'] [data-mk-color-loupe] {
|
|
106
|
+
top: 50%;
|
|
107
|
+
right: calc(100% + 10px);
|
|
108
|
+
bottom: auto;
|
|
109
|
+
left: auto;
|
|
110
|
+
margin: -1.375rem 0 0;
|
|
111
|
+
transform-origin: 100% 50%;
|
|
112
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createColorSlider, type ColorSliderInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-color-slider class="mk-color-slider" channel="hue" value="#ff8800" show-value></mk-color-slider>
|
|
6
|
+
* Emits mk:input / mk:change ({value, color}). Changing `value` glides the thumb.
|
|
7
|
+
*/
|
|
8
|
+
export class MkColorSliderElement extends MkElement<ColorSliderInstance> {
|
|
9
|
+
static options: Record<string, OptionType> = { channel: 'string', value: 'string', label: 'string', orientation: 'string', step: 'number', showValue: 'boolean', name: 'string', disabled: 'boolean' };
|
|
10
|
+
|
|
11
|
+
protected create(options: Record<string, unknown>) {
|
|
12
|
+
return createColorSlider(this, options);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null) {
|
|
16
|
+
if (previous === next || !this.instance) return;
|
|
17
|
+
if (name === 'value' && next) this.instance.setColor(next, false);
|
|
18
|
+
else super.attributeChangedCallback(name, previous, next);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get value() {
|
|
22
|
+
return this.instance?.value ?? '';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const defineColorSlider = () => defineElement('mk-color-slider', MkColorSliderElement);
|
|
@@ -0,0 +1,234 @@
|
|
|
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 { numberFormat } from '../../core/dates';
|
|
6
|
+
import {
|
|
7
|
+
CHANNEL_LABELS, CHANNEL_RANGE, channelGradient, channelText, formatColor, getChannel, sameColor, setChannel, toHex, toHsva,
|
|
8
|
+
type ColorChannel, type Hsva,
|
|
9
|
+
} from '../../core/color';
|
|
10
|
+
import { rollDigits } from '../../motion/micro';
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* Color slider: one channel of a colour on a native <input type="range">
|
|
14
|
+
* (keyboard, touch and forms from the platform; its thumb is transparent). The
|
|
15
|
+
* engine paints the track (that channel's gradient at the current colour, alpha
|
|
16
|
+
* over a checkerboard) and a round thumb filled with the colour, moved by a GSAP
|
|
17
|
+
* proxy: tight while dragging (.1 s), Melonmind's swing for keys and setColor
|
|
18
|
+
* (.35 s, .38,.49,0,1.5). Grabbing grows the thumb on the click curve and pops a
|
|
19
|
+
* loupe with the colour above it. Parts: [data-mk-color-track],
|
|
20
|
+
* input[data-mk-color-input], [data-mk-color-thumb] > [data-mk-color-loupe],
|
|
21
|
+
* output[data-mk-color-output]. Vars: --mk-color-track, --mk-color-thumb, --mk-color-pos.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export interface ColorSliderOptions {
|
|
25
|
+
/** Channel this slider edits (default 'hue'). */
|
|
26
|
+
channel?: ColorChannel;
|
|
27
|
+
/** Any CSS colour parseColor reads, or HSVA (default 'hsl(0 100% 50%)'). */
|
|
28
|
+
value?: string | Hsva;
|
|
29
|
+
/** Accessible name (default: the channel's Spanish name). */
|
|
30
|
+
label?: string;
|
|
31
|
+
orientation?: 'horizontal' | 'vertical';
|
|
32
|
+
/** Default 1 (alpha .01). */
|
|
33
|
+
step?: number;
|
|
34
|
+
/** Shows the value ("210°", "64 %") in an <output>. */
|
|
35
|
+
showValue?: boolean;
|
|
36
|
+
/** Form name: a hidden input submits the hex. */
|
|
37
|
+
name?: string;
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** Every move. */
|
|
40
|
+
onInput?: (value: string, color: Hsva) => void;
|
|
41
|
+
/** Committed (release, key). */
|
|
42
|
+
onChange?: (value: string, color: Hsva) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ColorSliderInstance extends Instance {
|
|
46
|
+
/** Another control changed the colour; `notify` false keeps callbacks quiet. */
|
|
47
|
+
setColor(color: string | Hsva, notify?: boolean): void;
|
|
48
|
+
/** Hex (#rrggbb, #rrggbbaa when translucent). */
|
|
49
|
+
readonly value: string;
|
|
50
|
+
readonly color: Hsva;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function createColorSlider(root: HTMLElement | null, options: ColorSliderOptions = {}): ColorSliderInstance {
|
|
54
|
+
if (!root) return inert({ setColor() {}, value: '', color: { h: 0, s: 0, v: 0, a: 1 } });
|
|
55
|
+
registerMotion();
|
|
56
|
+
const scope = createScope();
|
|
57
|
+
const effects = new Set<gsap.core.Animation>();
|
|
58
|
+
const keep = (animation: gsap.core.Animation | null) => {
|
|
59
|
+
if (!animation) return;
|
|
60
|
+
effects.add(animation);
|
|
61
|
+
// Finished ones leave as new ones arrive: the animation's own onComplete stays untouched.
|
|
62
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
63
|
+
};
|
|
64
|
+
scope.add(() => {
|
|
65
|
+
for (const effect of effects) effect.kill();
|
|
66
|
+
effects.clear();
|
|
67
|
+
});
|
|
68
|
+
scope.attr(root, 'style', root.getAttribute('style'));
|
|
69
|
+
|
|
70
|
+
const channel: ColorChannel = options.channel && options.channel in CHANNEL_RANGE ? options.channel : 'hue';
|
|
71
|
+
const [min, max] = CHANNEL_RANGE[channel];
|
|
72
|
+
const step = options.step && options.step > 0 ? options.step : channel === 'alpha' ? 0.01 : 1;
|
|
73
|
+
const vertical = options.orientation === 'vertical';
|
|
74
|
+
let color = toHsva(options.value ?? 'hsl(0 100% 50%)');
|
|
75
|
+
const format = numberFormat(root, { maximumFractionDigits: 0 });
|
|
76
|
+
|
|
77
|
+
const made: Element[] = [];
|
|
78
|
+
const part = <T extends HTMLElement>(parent: HTMLElement, selector: string, create: () => T): T => {
|
|
79
|
+
const found = parent.querySelector<T>(selector);
|
|
80
|
+
if (found) return found;
|
|
81
|
+
const element = create();
|
|
82
|
+
made.push(element);
|
|
83
|
+
return element;
|
|
84
|
+
};
|
|
85
|
+
const track = part(root, '[data-mk-color-track]', () => {
|
|
86
|
+
const element = document.createElement('div');
|
|
87
|
+
element.dataset.mkColorTrack = '';
|
|
88
|
+
root.append(element);
|
|
89
|
+
return element;
|
|
90
|
+
});
|
|
91
|
+
const input = part(track, 'input[data-mk-color-input]', () => {
|
|
92
|
+
const element = document.createElement('input');
|
|
93
|
+
element.type = 'range';
|
|
94
|
+
element.dataset.mkColorInput = '';
|
|
95
|
+
track.append(element);
|
|
96
|
+
return element;
|
|
97
|
+
});
|
|
98
|
+
const thumb = part(track, '[data-mk-color-thumb]', () => {
|
|
99
|
+
const element = document.createElement('span');
|
|
100
|
+
element.dataset.mkColorThumb = '';
|
|
101
|
+
element.setAttribute('aria-hidden', 'true');
|
|
102
|
+
track.append(element);
|
|
103
|
+
return element;
|
|
104
|
+
});
|
|
105
|
+
const loupe = part(thumb, '[data-mk-color-loupe]', () => {
|
|
106
|
+
const element = document.createElement('span');
|
|
107
|
+
element.dataset.mkColorLoupe = '';
|
|
108
|
+
thumb.append(element);
|
|
109
|
+
return element;
|
|
110
|
+
});
|
|
111
|
+
const output = options.showValue
|
|
112
|
+
? part(root, 'output[data-mk-color-output]', () => {
|
|
113
|
+
const element = document.createElement('output');
|
|
114
|
+
element.dataset.mkColorOutput = '';
|
|
115
|
+
track.after(element);
|
|
116
|
+
return element;
|
|
117
|
+
})
|
|
118
|
+
: null;
|
|
119
|
+
const hidden = options.name
|
|
120
|
+
? (() => {
|
|
121
|
+
const element = document.createElement('input');
|
|
122
|
+
element.type = 'hidden';
|
|
123
|
+
element.name = options.name!;
|
|
124
|
+
root.append(element);
|
|
125
|
+
made.push(element);
|
|
126
|
+
return element;
|
|
127
|
+
})()
|
|
128
|
+
: null;
|
|
129
|
+
scope.add(() => made.forEach((node) => node.remove()));
|
|
130
|
+
// Authored parts keep their own text and value.
|
|
131
|
+
const outputText = output?.textContent ?? '';
|
|
132
|
+
const inputValue = input.value;
|
|
133
|
+
scope.add(() => {
|
|
134
|
+
if (output?.isConnected) output.textContent = outputText;
|
|
135
|
+
if (input.isConnected) input.value = inputValue;
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
scope.attr(input, 'min', String(min));
|
|
139
|
+
scope.attr(input, 'max', String(max));
|
|
140
|
+
scope.attr(input, 'step', String(step));
|
|
141
|
+
scope.attr(input, 'aria-label', options.label ?? CHANNEL_LABELS[channel]);
|
|
142
|
+
scope.attr(input, 'aria-orientation', vertical ? 'vertical' : 'horizontal');
|
|
143
|
+
scope.attr(input, 'aria-valuetext', null);
|
|
144
|
+
if (options.disabled) scope.attr(input, 'disabled', '');
|
|
145
|
+
scope.attr(root, 'data-mk-channel', channel);
|
|
146
|
+
scope.attr(root, 'data-mk-orientation', vertical ? 'vertical' : 'horizontal');
|
|
147
|
+
scope.attr(root, 'data-mk-grabbing', null);
|
|
148
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
149
|
+
|
|
150
|
+
const shown = { pos: 0 };
|
|
151
|
+
let glide: gsap.core.Tween | null = null;
|
|
152
|
+
scope.add(() => {
|
|
153
|
+
glide?.kill();
|
|
154
|
+
gsap.killTweensOf([thumb, loupe]);
|
|
155
|
+
});
|
|
156
|
+
const place = () => root.style.setProperty('--mk-color-pos', String(Number(shown.pos.toFixed(4))));
|
|
157
|
+
const paint = (mode: 'set' | 'drag' | 'glide') => {
|
|
158
|
+
const value = getChannel(color, channel);
|
|
159
|
+
const ratio = max > min ? (value - min) / (max - min) : 0;
|
|
160
|
+
const text = channelText(channel, value, format);
|
|
161
|
+
root.style.setProperty('--mk-color-track', channelGradient(color, channel, vertical ? 'to top' : 'to right'));
|
|
162
|
+
root.style.setProperty('--mk-color-thumb', formatColor(color, 'rgb'));
|
|
163
|
+
if (document.activeElement !== input || mode !== 'drag') input.value = String(Number(value.toFixed(2)));
|
|
164
|
+
input.setAttribute('aria-valuetext', text);
|
|
165
|
+
if (output) {
|
|
166
|
+
if (mode === 'glide' && !reduced()) keep(rollDigits(output, text, ratio >= shown.pos ? 1 : -1, 0.28));
|
|
167
|
+
else output.textContent = text;
|
|
168
|
+
}
|
|
169
|
+
if (hidden) hidden.value = toHex(color);
|
|
170
|
+
glide?.kill();
|
|
171
|
+
if (mode === 'set' || reduced()) {
|
|
172
|
+
shown.pos = ratio;
|
|
173
|
+
place();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
glide = gsap.to(shown, { pos: ratio, duration: mode === 'drag' ? 0.1 : 0.35, ease: mode === 'drag' ? 'power3.out' : EASE.swatch, onUpdate: place });
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const emit = (type: 'input' | 'change') => {
|
|
180
|
+
const value = toHex(color);
|
|
181
|
+
(type === 'input' ? options.onInput : options.onChange)?.(value, { ...color });
|
|
182
|
+
root.dispatchEvent(new CustomEvent(`mk:${type}`, { bubbles: true, detail: { value, color: { ...color } } }));
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
let dragging = false;
|
|
186
|
+
const grab = (on: boolean) => {
|
|
187
|
+
if (dragging === on) return;
|
|
188
|
+
dragging = on;
|
|
189
|
+
root.toggleAttribute('data-mk-grabbing', on);
|
|
190
|
+
if (reduced()) return;
|
|
191
|
+
keep(gsap.to(thumb, { scale: on ? 1.2 : 1, duration: 0.25, ease: EASE.click }));
|
|
192
|
+
if (on) keep(gsap.fromTo(loupe, { scale: 0.6, opacity: 0, filter: 'blur(6px)' }, { scale: 1, opacity: 1, filter: 'blur(0px)', duration: 0.3, ease: EASE.pop }));
|
|
193
|
+
else keep(gsap.to(loupe, { scale: 0.8, opacity: 0, filter: 'blur(6px)', duration: 0.2, ease: 'power2.in' }));
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
scope.on(input, 'input', () => {
|
|
197
|
+
color = setChannel(color, channel, Number(input.value));
|
|
198
|
+
paint(dragging ? 'drag' : 'glide');
|
|
199
|
+
emit('input');
|
|
200
|
+
});
|
|
201
|
+
scope.on(input, 'change', () => emit('change'));
|
|
202
|
+
scope.on(input, 'pointerdown', () => {
|
|
203
|
+
if (!input.disabled) grab(true);
|
|
204
|
+
});
|
|
205
|
+
scope.on(window, 'pointerup', () => grab(false));
|
|
206
|
+
scope.on(window, 'pointercancel', () => grab(false));
|
|
207
|
+
scope.on(input, 'blur', () => grab(false));
|
|
208
|
+
scope.add(() => {
|
|
209
|
+
gsap.set([thumb, loupe], { clearProps: 'scale,opacity,filter,transform' });
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
paint('set');
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
setColor(next, notify = true) {
|
|
216
|
+
if (scope.disposed) return;
|
|
217
|
+
const target = toHsva(next, color);
|
|
218
|
+
if (sameColor(target, color) && target.h === color.h) return;
|
|
219
|
+
color = target;
|
|
220
|
+
paint('glide');
|
|
221
|
+
if (notify) {
|
|
222
|
+
emit('input');
|
|
223
|
+
emit('change');
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
get value() {
|
|
227
|
+
return toHex(color);
|
|
228
|
+
},
|
|
229
|
+
get color() {
|
|
230
|
+
return { ...color };
|
|
231
|
+
},
|
|
232
|
+
destroy: () => scope.dispose(),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { toHex, toHsva } from '../../core/color';
|
|
5
|
+
import { createColorSlider, type ColorSliderInstance, type ColorSliderOptions } from './engine';
|
|
6
|
+
|
|
7
|
+
export interface ColorSliderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onInput' | 'onChange' | 'defaultValue'>, Omit<ColorSliderOptions, 'value'> {
|
|
8
|
+
/** Controlled colour; without it the slider keeps its own (defaultValue). */
|
|
9
|
+
value?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** <ColorSlider channel="hue" value={color} onInput={setColor} />. */
|
|
14
|
+
export function ColorSlider({ value, defaultValue, channel, label, orientation, step, showValue, name, disabled, onInput, onChange, className, ...props }: ColorSliderProps) {
|
|
15
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
16
|
+
const instance = useRef<ColorSliderInstance | null>(null);
|
|
17
|
+
const input = useLatest(onInput);
|
|
18
|
+
const change = useLatest(onChange);
|
|
19
|
+
const start = useRef(value ?? defaultValue);
|
|
20
|
+
useIsomorphicLayoutEffect(() => {
|
|
21
|
+
const created = createColorSlider(ref.current, {
|
|
22
|
+
value: value ?? start.current,
|
|
23
|
+
channel,
|
|
24
|
+
label,
|
|
25
|
+
orientation,
|
|
26
|
+
step,
|
|
27
|
+
showValue,
|
|
28
|
+
name,
|
|
29
|
+
disabled,
|
|
30
|
+
onInput: (hex, color) => input.current?.(hex, color),
|
|
31
|
+
onChange: (hex, color) => change.current?.(hex, color),
|
|
32
|
+
});
|
|
33
|
+
instance.current = created;
|
|
34
|
+
return () => {
|
|
35
|
+
start.current = created.value;
|
|
36
|
+
created.destroy();
|
|
37
|
+
instance.current = null;
|
|
38
|
+
};
|
|
39
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
+
}, [channel, label, orientation, step, showValue, name, disabled]);
|
|
41
|
+
useIsomorphicLayoutEffect(() => {
|
|
42
|
+
if (value !== undefined && instance.current && instance.current.value !== toHex(toHsva(value))) instance.current.setColor(value, false);
|
|
43
|
+
}, [value]);
|
|
44
|
+
return <div {...props} ref={ref} className={['mk-color-slider', className].filter(Boolean).join(' ')} />;
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# command-search
|
|
2
|
+
|
|
3
|
+
Paleta de comandos en un `<dialog>` modal sobre vidrio oscuro. Se abre con ⌘K / Ctrl+K o con un botón `[data-mk-command-open]` y crece desde el botón que la abre (o desde el disparador visible con ⌘K/Ctrl+K) y se pliega de vuelta en él al cerrar: el color del botón se funde en el panel y la forma viaja 0,7 s; `open(origen)` elige otro control y `open(null)` la abre en su sitio. Al escribir filtra por coincidencia aproximada (letras en orden, sin tildes ni mayúsculas) y marca las letras con `<mark>` creado como texto. Los resultados se agrupan; una píldora se desliza bajo el activo con la curva swing.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<mk-command-search class="mk-command-search" items='[{"id":"charts","label":"Charts","group":"Páginas","href":"/chart"},{"id":"chart","label":"Chart","group":"Componentes","href":"/chart"}]'>
|
|
7
|
+
<button data-mk-command-open>Buscar… <kbd>⌘K</kbd></button>
|
|
8
|
+
</mk-command-search>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`defineElements()`, `createCommandSearch(root, options)` o `<CommandSearch items={commands} onSelect={run} />`.
|
|
12
|
+
|
|
13
|
+
`CommandItem`: `{id, label, group?, keywords?, hint?, href?, icon?}`. Opciones: `items`, `placeholder='Buscar…'`, `emptyLabel='Sin resultados'`, `label`, `shortcut=true`, `limit=50`, `onSelect(item)`, `onOpenChange(open)`. API: `open(origen?)`, `close()`, `setItems(items)`, `isOpen`, `destroy()`. Eventos `mk:select` `{item}` (cancelable: si nadie lo cancela y el item tiene `href`, navega), `mk:open` `{origin}`, `mk:close`. Utilidad `matchScore(query, text)`.
|
|
14
|
+
|
|
15
|
+
Teclado: flechas, Inicio, Fin, Enter y Escape; el puntero también mueve el activo. Semántica combobox + listbox con `aria-activedescendant` y un estado que anuncia cuántos resultados hay. Al cerrar, el foco vuelve a quien la abrió. El botón de origen se oculta mientras la paleta está abierta y reaparece al plegarse. Movimiento reducido: aparece y se mueve sin animación.
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/* command-search — a dark command palette (Melonmind's glass, near black in both modes): a search field, grouped
|
|
2
|
+
results with marked letters, a pill gliding under the active one and a footer with the keys. */
|
|
3
|
+
.mk-command-search,
|
|
4
|
+
mk-command-search {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
[data-mk-command] {
|
|
9
|
+
--mk-command-bg: rgb(14 15 17 / 0.92);
|
|
10
|
+
--mk-command-text: #eceef1;
|
|
11
|
+
--mk-command-muted: #8b919b;
|
|
12
|
+
--mk-command-line: rgb(255 255 255 / 0.07);
|
|
13
|
+
--mk-command-pill: rgb(255 255 255 / 0.08);
|
|
14
|
+
--mk-command-mark: #f5d76e;
|
|
15
|
+
width: min(32rem, calc(100vw - 2rem));
|
|
16
|
+
max-height: min(28rem, calc(100dvh - 4rem));
|
|
17
|
+
margin: 12vh auto auto;
|
|
18
|
+
padding: 0;
|
|
19
|
+
overflow: visible;
|
|
20
|
+
border: 0;
|
|
21
|
+
background: transparent;
|
|
22
|
+
color: var(--mk-command-text);
|
|
23
|
+
font-family: var(--mk-font);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[data-mk-command]::backdrop {
|
|
27
|
+
background: color-mix(in srgb, var(--mk-scrim, #000) 28%, transparent);
|
|
28
|
+
backdrop-filter: blur(3px);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-mk-command][open] {
|
|
32
|
+
display: block;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[data-mk-command] [data-mk-command-panel] {
|
|
36
|
+
position: relative;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
max-height: inherit;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
border-radius: 24px;
|
|
42
|
+
background: var(--mk-command-bg);
|
|
43
|
+
box-shadow:
|
|
44
|
+
inset 1px 1px 1px rgb(255 255 255 / 0.08),
|
|
45
|
+
inset -1px -1px 1px rgb(255 255 255 / 0.04),
|
|
46
|
+
0 30px 60px -20px rgb(0 0 0 / 0.6);
|
|
47
|
+
backdrop-filter: blur(24px);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-mk-command] [data-mk-command-field] {
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
gap: 0.6rem;
|
|
54
|
+
margin: 0.6rem;
|
|
55
|
+
padding: 0 0.85rem;
|
|
56
|
+
border-radius: 14px;
|
|
57
|
+
background: rgb(255 255 255 / 0.05);
|
|
58
|
+
box-shadow: inset 0 0 0 1px var(--mk-command-line);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
[data-mk-command] [data-mk-command-icon] {
|
|
62
|
+
display: grid;
|
|
63
|
+
color: var(--mk-command-muted);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
[data-mk-command] input {
|
|
67
|
+
flex: 1;
|
|
68
|
+
min-width: 0;
|
|
69
|
+
min-height: 2.75rem;
|
|
70
|
+
border: 0;
|
|
71
|
+
outline: none;
|
|
72
|
+
background: transparent;
|
|
73
|
+
color: var(--mk-command-text);
|
|
74
|
+
font: inherit;
|
|
75
|
+
font-size: 1rem;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[data-mk-command] input::placeholder {
|
|
79
|
+
color: var(--mk-command-muted);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[data-mk-command] [data-mk-command-scroll] {
|
|
83
|
+
position: relative;
|
|
84
|
+
flex: 1;
|
|
85
|
+
min-height: 0;
|
|
86
|
+
overflow-y: auto;
|
|
87
|
+
padding: 0 0.6rem 0.6rem;
|
|
88
|
+
overscroll-behavior: contain;
|
|
89
|
+
scrollbar-width: thin;
|
|
90
|
+
scrollbar-color: rgb(255 255 255 / 0.15) transparent;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-mk-command] [data-mk-command-pill] {
|
|
94
|
+
position: absolute;
|
|
95
|
+
top: 0;
|
|
96
|
+
left: 0;
|
|
97
|
+
border-radius: 12px;
|
|
98
|
+
background: var(--mk-command-pill);
|
|
99
|
+
pointer-events: none;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[data-mk-command] [data-mk-command-list] {
|
|
103
|
+
position: relative;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[data-mk-command] [data-mk-command-group-label] {
|
|
107
|
+
padding: 0.75rem 0.65rem 0.35rem;
|
|
108
|
+
color: var(--mk-command-muted);
|
|
109
|
+
font-size: 0.75rem;
|
|
110
|
+
font-weight: 500;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
[data-mk-command] [data-mk-command-item] {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
gap: 0.6rem;
|
|
117
|
+
min-height: 2.5rem;
|
|
118
|
+
padding: 0 0.65rem;
|
|
119
|
+
border-radius: 12px;
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
[data-mk-command] [data-mk-command-arrow] {
|
|
124
|
+
width: 1rem;
|
|
125
|
+
color: var(--mk-command-muted);
|
|
126
|
+
text-align: center;
|
|
127
|
+
transition: translate 0.3s cubic-bezier(0.38, 0.49, 0, 2);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
[data-mk-command] [data-mk-command-item][aria-selected='true'] [data-mk-command-arrow] {
|
|
131
|
+
color: var(--mk-command-text);
|
|
132
|
+
translate: 2px 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
[data-mk-command] [data-mk-command-label] {
|
|
136
|
+
flex: 1;
|
|
137
|
+
min-width: 0;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
font-size: 0.9375rem;
|
|
140
|
+
text-overflow: ellipsis;
|
|
141
|
+
white-space: nowrap;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
[data-mk-command] mark {
|
|
145
|
+
border-radius: 3px;
|
|
146
|
+
background: rgb(245 215 110 / 0.16);
|
|
147
|
+
color: var(--mk-command-mark);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
[data-mk-command] [data-mk-command-hint] {
|
|
151
|
+
color: var(--mk-command-muted);
|
|
152
|
+
font-size: 0.75rem;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
[data-mk-command] [data-mk-command-empty] {
|
|
156
|
+
margin: 0;
|
|
157
|
+
padding: 2rem 1rem;
|
|
158
|
+
color: var(--mk-command-muted);
|
|
159
|
+
text-align: center;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
[data-mk-command] [data-mk-command-empty][hidden] {
|
|
163
|
+
display: none;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
[data-mk-command] [data-mk-command-footer] {
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
gap: 0.4rem;
|
|
170
|
+
padding: 0.6rem 0.9rem;
|
|
171
|
+
border-top: 1px solid var(--mk-command-line);
|
|
172
|
+
color: var(--mk-command-muted);
|
|
173
|
+
font-size: 0.75rem;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
[data-mk-command] [data-mk-command-footer] span {
|
|
177
|
+
margin-right: 0.6rem;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
[data-mk-command] kbd {
|
|
181
|
+
display: inline-grid;
|
|
182
|
+
place-items: center;
|
|
183
|
+
min-width: 1.5rem;
|
|
184
|
+
height: 1.5rem;
|
|
185
|
+
padding: 0 0.3rem;
|
|
186
|
+
border-radius: 6px;
|
|
187
|
+
background: rgb(255 255 255 / 0.07);
|
|
188
|
+
box-shadow: inset 0 -1px 0 rgb(255 255 255 / 0.06);
|
|
189
|
+
color: var(--mk-command-text);
|
|
190
|
+
font-family: inherit;
|
|
191
|
+
font-size: 0.75rem;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* The trigger (optional): a search pill with the shortcut. */
|
|
195
|
+
[data-mk-command-open] {
|
|
196
|
+
display: inline-flex;
|
|
197
|
+
align-items: center;
|
|
198
|
+
gap: 0.6rem;
|
|
199
|
+
min-height: 2.75rem;
|
|
200
|
+
padding: 0 0.6rem 0 1rem;
|
|
201
|
+
border: 0;
|
|
202
|
+
border-radius: 64px;
|
|
203
|
+
background: var(--mk-surface-3);
|
|
204
|
+
color: var(--mk-muted);
|
|
205
|
+
font: inherit;
|
|
206
|
+
cursor: pointer;
|
|
207
|
+
transition: background-color 0.2s ease;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
[data-mk-command-open]:hover {
|
|
211
|
+
background: var(--mk-surface-4);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
[data-mk-command-open]:focus-visible {
|
|
215
|
+
outline: 2px solid var(--mk-accent);
|
|
216
|
+
outline-offset: 3px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
[data-mk-command-open] kbd {
|
|
220
|
+
padding: 0.15rem 0.45rem;
|
|
221
|
+
border-radius: 8px;
|
|
222
|
+
background: var(--mk-surface-1);
|
|
223
|
+
color: var(--mk-text);
|
|
224
|
+
font-family: inherit;
|
|
225
|
+
font-size: 0.75rem;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@media (max-width: 520px) {
|
|
229
|
+
[data-mk-command] {
|
|
230
|
+
margin-top: 1rem;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
[data-mk-command] [data-mk-command-footer] {
|
|
234
|
+
display: none;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* Container transform (motion/morph.ts): the trigger's look covers the panel and fades into it; the trigger hides meanwhile. */
|
|
239
|
+
[data-mk-command] .mk-morph-face {
|
|
240
|
+
position: absolute;
|
|
241
|
+
inset: 0;
|
|
242
|
+
z-index: 2147483647;
|
|
243
|
+
border-radius: inherit;
|
|
244
|
+
pointer-events: none;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
:is(.mk-command-search, mk-command-search) [data-mk-morph-origin] {
|
|
248
|
+
opacity: 0 !important;
|
|
249
|
+
transition: opacity 80ms ease !important;
|
|
250
|
+
pointer-events: none;
|
|
251
|
+
}
|