@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,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { createScrollIsland, type ScrollIslandOptions } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface ScrollIslandProps extends HTMLAttributes<HTMLDivElement>, ScrollIslandOptions {}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* <ScrollIsland style={{ height: 400, overflow: 'auto' }}>…</ScrollIsland> scrolls its children with the island;
|
|
10
|
+
* <ScrollIsland page /> puts it on the page (it renders nothing of its own then).
|
|
11
|
+
*/
|
|
12
|
+
export function ScrollIsland({ sections, reach, idle, page, onSection, className, children, ...props }: ScrollIslandProps) {
|
|
13
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
14
|
+
const section = useLatest(onSection);
|
|
15
|
+
useIsomorphicLayoutEffect(() => {
|
|
16
|
+
const created = createScrollIsland(page ? document.documentElement : ref.current, { sections, reach, idle, page, onSection: (name) => section.current?.(name) });
|
|
17
|
+
return () => created.destroy();
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
}, [sections, reach, idle, page]);
|
|
20
|
+
if (page) return null;
|
|
21
|
+
return (
|
|
22
|
+
<div {...props} ref={ref} className={['mk-scroll-island', className].filter(Boolean).join(' ')}>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* scroll-island — the scroller's bar hides and a thin pill takes its place while scrolling; near the edge it swells
|
|
2
|
+
into a dark capsule (iOS-island style) with the percentage and the current section, which can be dragged. */
|
|
3
|
+
.mk-scroll-island,
|
|
4
|
+
mk-scroll-island {
|
|
5
|
+
display: block;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
[data-mk-scroll-island-host] {
|
|
9
|
+
scrollbar-width: none;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
[data-mk-scroll-island-host]::-webkit-scrollbar {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
[data-mk-scroll-island] {
|
|
17
|
+
position: fixed;
|
|
18
|
+
z-index: 2147483640;
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[data-mk-island-rail] {
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: 0;
|
|
25
|
+
right: 0;
|
|
26
|
+
bottom: 0;
|
|
27
|
+
width: 1.5rem;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
[data-mk-island-thumb] {
|
|
33
|
+
position: absolute;
|
|
34
|
+
top: 0;
|
|
35
|
+
right: 0;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
width: 4px;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
border-radius: 999px;
|
|
42
|
+
background: color-mix(in srgb, var(--mk-text) 42%, transparent);
|
|
43
|
+
color: #fff;
|
|
44
|
+
opacity: 0;
|
|
45
|
+
transition:
|
|
46
|
+
opacity 0.25s ease,
|
|
47
|
+
background-color 0.3s ease,
|
|
48
|
+
box-shadow 0.3s ease;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[data-mk-scroll-island][data-mk-state='bar'] [data-mk-island-thumb] {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
[data-mk-scroll-island][data-mk-state='island'] [data-mk-island-rail],
|
|
56
|
+
[data-mk-scroll-island][data-mk-state='island'] [data-mk-island-thumb] {
|
|
57
|
+
pointer-events: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[data-mk-scroll-island][data-mk-state='island'] [data-mk-island-thumb] {
|
|
61
|
+
background: #0c0c0e;
|
|
62
|
+
box-shadow:
|
|
63
|
+
inset 0 0 0 1px rgb(255 255 255 / 0.08),
|
|
64
|
+
0 12px 30px -8px rgb(0 0 0 / 0.45);
|
|
65
|
+
opacity: 1;
|
|
66
|
+
cursor: grab;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
[data-mk-scroll-island][data-mk-dragging] [data-mk-island-thumb] {
|
|
70
|
+
cursor: grabbing;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[data-mk-island-content] {
|
|
74
|
+
display: inline-flex;
|
|
75
|
+
flex: none;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: 0.5rem;
|
|
78
|
+
padding: 0 14px;
|
|
79
|
+
font-family: var(--mk-font);
|
|
80
|
+
font-size: 0.8125rem;
|
|
81
|
+
font-weight: 600;
|
|
82
|
+
font-variant-numeric: tabular-nums;
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
opacity: 0;
|
|
85
|
+
transition: opacity 0.18s ease;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[data-mk-scroll-island][data-mk-state='island'] [data-mk-island-content] {
|
|
89
|
+
opacity: 1;
|
|
90
|
+
transition-delay: 0.1s;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
[data-mk-island-section] {
|
|
94
|
+
max-width: 12rem;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
color: rgb(255 255 255 / 0.68);
|
|
97
|
+
font-weight: 500;
|
|
98
|
+
text-overflow: ellipsis;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[data-mk-island-section][hidden] {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@media (prefers-reduced-motion: reduce) {
|
|
106
|
+
[data-mk-island-thumb],
|
|
107
|
+
[data-mk-island-content] {
|
|
108
|
+
transition: none;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# select
|
|
2
|
+
|
|
3
|
+
Qué hace, en una frase.
|
|
4
|
+
|
|
5
|
+
Origen: archivo del kit y parámetros (tiempos, curvas).
|
|
6
|
+
|
|
7
|
+
## HTML / Astro
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<mk-select></mk-select>
|
|
11
|
+
<script>
|
|
12
|
+
import { defineElements } from '@yewdiel21/motion-kit/elements';
|
|
13
|
+
defineElements(['mk-select']);
|
|
14
|
+
</script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## React
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<Select />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Opciones
|
|
24
|
+
|
|
25
|
+
| Opción | Atributo | Por defecto | Qué hace |
|
|
26
|
+
|---|---|---|---|
|
|
27
|
+
|
|
28
|
+
## Variables CSS
|
|
29
|
+
|
|
30
|
+
`--mk-select-radius`
|
|
31
|
+
|
|
32
|
+
## Accesibilidad
|
|
33
|
+
|
|
34
|
+
Roles, foco y teclado. Con movimiento reducido…
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createSelect, type SelectInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-select class="mk-select" label="Equipo"><select name="equipo">…</select></mk-select>
|
|
6
|
+
* The select inside gives the options and stays in step (forms post it). Emits mk:change ({value}).
|
|
7
|
+
*/
|
|
8
|
+
export class MkSelectElement extends MkElement<SelectInstance> {
|
|
9
|
+
static options: Record<string, OptionType> = { value: 'string', name: 'string', label: 'string', placeholder: 'string', disabled: 'boolean' };
|
|
10
|
+
|
|
11
|
+
protected create(options: Record<string, unknown>) {
|
|
12
|
+
return createSelect(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 !== null) this.instance.setValue(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 defineSelect = () => defineElement('mk-select', MkSelectElement);
|
|
@@ -0,0 +1,267 @@
|
|
|
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
|
+
import { createMenu } from '../menu/engine';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Select: one choice from a list, opened as the kit's menu (it grows out of its
|
|
10
|
+
* button and its items flow in) instead of the system's list, so it looks and
|
|
11
|
+
* moves like every other menu. It enhances an authored <select> (hidden, kept in
|
|
12
|
+
* step: forms post it and its `change` listeners keep working) or builds one from
|
|
13
|
+
* `options`. The chosen label slides in out of a blur, the chevron turns, typing
|
|
14
|
+
* a letter on the closed button picks the next option that starts with it, and
|
|
15
|
+
* ↓ ↑ Enter Space open the menu. Changes made to the select's options (by the app)
|
|
16
|
+
* show up on their own.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export interface SelectOption {
|
|
20
|
+
value: string;
|
|
21
|
+
label: string;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** A heading the option sits under (an <optgroup>). */
|
|
24
|
+
group?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SelectOptions {
|
|
28
|
+
/** The choices; without them, the authored <select> gives them. */
|
|
29
|
+
options?: SelectOption[];
|
|
30
|
+
value?: string;
|
|
31
|
+
/** Form name of the select it builds (an authored one keeps its own). */
|
|
32
|
+
name?: string;
|
|
33
|
+
/** Accessible name; the button reads "<label>: <chosen>". */
|
|
34
|
+
label?: string;
|
|
35
|
+
/** Text while nothing is chosen (default: the empty option's text, else 'Elige…'). */
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
onChange?: (value: string) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface SelectInstance extends Instance {
|
|
42
|
+
setValue(value: string, notify?: boolean): void;
|
|
43
|
+
setOptions(options: SelectOption[]): void;
|
|
44
|
+
/** Read the select's options again (changes to them are also noticed on their own). */
|
|
45
|
+
refresh(): void;
|
|
46
|
+
open(): void;
|
|
47
|
+
close(): void;
|
|
48
|
+
readonly value: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const CHEVRON = '<svg aria-hidden="true" data-mk-select-chevron width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M7 10l5 5 5-5"/></svg>';
|
|
52
|
+
const CHECK = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';
|
|
53
|
+
const fold = (text: string) => text.normalize('NFD').replace(/[̀-ͯ]/g, '').toLocaleLowerCase();
|
|
54
|
+
|
|
55
|
+
/** Fill a select with options (groups become <optgroup>s, in order of first appearance). */
|
|
56
|
+
function fillSelect(select: HTMLSelectElement, list: SelectOption[]) {
|
|
57
|
+
const groups = new Map<string, HTMLOptGroupElement>();
|
|
58
|
+
const nodes: Array<HTMLOptionElement | HTMLOptGroupElement> = [];
|
|
59
|
+
for (const choice of list) {
|
|
60
|
+
const option = new Option(choice.label, choice.value);
|
|
61
|
+
option.disabled = Boolean(choice.disabled);
|
|
62
|
+
if (!choice.group) {
|
|
63
|
+
nodes.push(option);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
let group = groups.get(choice.group);
|
|
67
|
+
if (!group) {
|
|
68
|
+
group = document.createElement('optgroup');
|
|
69
|
+
group.label = choice.group;
|
|
70
|
+
groups.set(choice.group, group);
|
|
71
|
+
nodes.push(group);
|
|
72
|
+
}
|
|
73
|
+
group.append(option);
|
|
74
|
+
}
|
|
75
|
+
select.replaceChildren(...nodes);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function createSelect(root: HTMLElement | null, options: SelectOptions = {}): SelectInstance {
|
|
79
|
+
if (!root) return inert({ setValue() {}, setOptions() {}, refresh() {}, open() {}, close() {}, value: '' });
|
|
80
|
+
registerMotion();
|
|
81
|
+
const scope = createScope();
|
|
82
|
+
const made: Element[] = [];
|
|
83
|
+
scope.add(() => made.forEach((element) => element.remove()));
|
|
84
|
+
|
|
85
|
+
let native = root.querySelector<HTMLSelectElement>('select:not([multiple])');
|
|
86
|
+
if (!native) {
|
|
87
|
+
native = document.createElement('select');
|
|
88
|
+
if (options.name) native.name = options.name;
|
|
89
|
+
root.append(native);
|
|
90
|
+
made.push(native);
|
|
91
|
+
} else {
|
|
92
|
+
// An authored select gets its own options and value back.
|
|
93
|
+
const select = native;
|
|
94
|
+
const children = [...select.childNodes];
|
|
95
|
+
const value = select.value;
|
|
96
|
+
scope.add(() => {
|
|
97
|
+
if (select.childNodes.length !== children.length || children.some((node, i) => select.childNodes[i] !== node)) select.replaceChildren(...children);
|
|
98
|
+
select.value = value;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
const select = native;
|
|
102
|
+
if (options.options) fillSelect(select, options.options);
|
|
103
|
+
if (options.value !== undefined) select.value = options.value;
|
|
104
|
+
scope.attr(select, 'hidden', '');
|
|
105
|
+
scope.attr(select, 'tabindex', '-1');
|
|
106
|
+
scope.attr(select, 'aria-hidden', 'true');
|
|
107
|
+
|
|
108
|
+
const trigger = document.createElement('button');
|
|
109
|
+
trigger.type = 'button';
|
|
110
|
+
trigger.dataset.mkSelectTrigger = '';
|
|
111
|
+
trigger.setAttribute('aria-haspopup', 'menu');
|
|
112
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
113
|
+
const valueText = document.createElement('span');
|
|
114
|
+
valueText.dataset.mkSelectValue = '';
|
|
115
|
+
trigger.append(valueText);
|
|
116
|
+
trigger.insertAdjacentHTML('beforeend', CHEVRON);
|
|
117
|
+
select.after(trigger);
|
|
118
|
+
made.push(trigger);
|
|
119
|
+
|
|
120
|
+
const dialog = document.createElement('dialog');
|
|
121
|
+
dialog.className = 'mk-dialog mk-menu mk-select-menu';
|
|
122
|
+
dialog.dataset.mkSelectMenu = '';
|
|
123
|
+
dialog.setAttribute('aria-label', options.label ?? 'Opciones');
|
|
124
|
+
root.append(dialog);
|
|
125
|
+
made.push(dialog);
|
|
126
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
127
|
+
|
|
128
|
+
const effects = new Set<gsap.core.Animation>();
|
|
129
|
+
const keep = (animation: gsap.core.Animation | null) => {
|
|
130
|
+
if (!animation) return;
|
|
131
|
+
effects.add(animation);
|
|
132
|
+
// Finished ones leave as new ones arrive: the animation's own onComplete stays untouched.
|
|
133
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
134
|
+
};
|
|
135
|
+
scope.add(() => {
|
|
136
|
+
for (const effect of effects) effect.kill();
|
|
137
|
+
effects.clear();
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const choices = () => [...select.options];
|
|
141
|
+
const buildItems = () => {
|
|
142
|
+
const nodes: HTMLElement[] = [];
|
|
143
|
+
const item = (option: HTMLOptionElement) => {
|
|
144
|
+
const button = document.createElement('button');
|
|
145
|
+
button.type = 'button';
|
|
146
|
+
button.dataset.mkItem = '';
|
|
147
|
+
button.dataset.mkValue = option.value;
|
|
148
|
+
const text = document.createElement('span');
|
|
149
|
+
text.textContent = option.text;
|
|
150
|
+
button.append(text);
|
|
151
|
+
button.insertAdjacentHTML('beforeend', CHECK);
|
|
152
|
+
if (option.disabled) button.setAttribute('aria-disabled', 'true');
|
|
153
|
+
return button;
|
|
154
|
+
};
|
|
155
|
+
for (const child of select.children) {
|
|
156
|
+
if (child instanceof HTMLOptGroupElement) {
|
|
157
|
+
const heading = document.createElement('p');
|
|
158
|
+
heading.dataset.mkSelectGroup = '';
|
|
159
|
+
heading.setAttribute('aria-hidden', 'true');
|
|
160
|
+
heading.textContent = child.label;
|
|
161
|
+
nodes.push(heading, ...[...child.children].filter((node): node is HTMLOptionElement => node instanceof HTMLOptionElement).map(item));
|
|
162
|
+
} else if (child instanceof HTMLOptionElement) nodes.push(item(child));
|
|
163
|
+
}
|
|
164
|
+
dialog.replaceChildren(...nodes);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const placeholderText = () => options.placeholder ?? choices().find((option) => option.value === '')?.text ?? 'Elige…';
|
|
168
|
+
/** The items are a choice: the menu marks them plain menuitems when it opens. */
|
|
169
|
+
const markItems = () => {
|
|
170
|
+
for (const item of dialog.querySelectorAll<HTMLElement>('[data-mk-item]')) {
|
|
171
|
+
item.setAttribute('role', 'menuitemradio');
|
|
172
|
+
item.setAttribute('aria-checked', String(item.dataset.mkValue === select.value));
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const paint = () => {
|
|
176
|
+
const chosen = select.selectedOptions[0];
|
|
177
|
+
const empty = !chosen || chosen.value === '';
|
|
178
|
+
valueText.textContent = empty ? placeholderText() : chosen.text;
|
|
179
|
+
root.toggleAttribute('data-mk-placeholder', empty);
|
|
180
|
+
if (options.label) trigger.setAttribute('aria-label', `${options.label}: ${valueText.textContent}`);
|
|
181
|
+
trigger.disabled = Boolean(options.disabled) || select.disabled;
|
|
182
|
+
markItems();
|
|
183
|
+
};
|
|
184
|
+
scope.add(() => root.removeAttribute('data-mk-placeholder'));
|
|
185
|
+
|
|
186
|
+
const choose = (value: string, notify: boolean) => {
|
|
187
|
+
if (value === select.value) return;
|
|
188
|
+
const before = choices().findIndex((option) => option.value === select.value);
|
|
189
|
+
select.value = value;
|
|
190
|
+
if (select.value !== value) return;
|
|
191
|
+
const after = choices().findIndex((option) => option.value === value);
|
|
192
|
+
paint();
|
|
193
|
+
if (!reduced()) {
|
|
194
|
+
gsap.killTweensOf(valueText);
|
|
195
|
+
keep(gsap.fromTo(valueText, { y: after >= before ? 6 : -6, opacity: 0, filter: 'blur(4px)' }, { y: 0, opacity: 1, filter: 'blur(0px)', duration: 0.28, ease: EASE.pop, clearProps: 'transform,opacity,filter' }));
|
|
196
|
+
}
|
|
197
|
+
if (!notify) return;
|
|
198
|
+
select.dispatchEvent(new Event('input', { bubbles: true }));
|
|
199
|
+
select.dispatchEvent(new Event('change', { bubbles: true }));
|
|
200
|
+
options.onChange?.(value);
|
|
201
|
+
root.dispatchEvent(new CustomEvent('mk:change', { bubbles: true, detail: { value } }));
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const menu = createMenu(dialog, {
|
|
205
|
+
triggers: false,
|
|
206
|
+
onOpen: markItems,
|
|
207
|
+
onClose: () => trigger.setAttribute('aria-expanded', 'false'),
|
|
208
|
+
onSelect: (value) => choose(value, true),
|
|
209
|
+
});
|
|
210
|
+
scope.add(() => menu.destroy());
|
|
211
|
+
// The menu's own selection stays inside: listeners on the select hear its change.
|
|
212
|
+
scope.on(dialog, 'mk:select', (event) => event.stopPropagation());
|
|
213
|
+
|
|
214
|
+
const open = () => {
|
|
215
|
+
if (trigger.disabled || menu.isOpen) return;
|
|
216
|
+
trigger.setAttribute('aria-expanded', 'true');
|
|
217
|
+
dialog.style.setProperty('--mk-select-width', `${trigger.offsetWidth}px`);
|
|
218
|
+
menu.open(trigger);
|
|
219
|
+
};
|
|
220
|
+
scope.on(trigger, 'click', () => {
|
|
221
|
+
if (!reduced()) keep(press(trigger));
|
|
222
|
+
open();
|
|
223
|
+
});
|
|
224
|
+
scope.on(trigger, 'keydown', (event) => {
|
|
225
|
+
const key = event as KeyboardEvent;
|
|
226
|
+
if (key.ctrlKey || key.metaKey || key.altKey) return;
|
|
227
|
+
if (['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(key.key)) {
|
|
228
|
+
key.preventDefault();
|
|
229
|
+
open();
|
|
230
|
+
} else if (key.key.length === 1 && key.key.trim()) {
|
|
231
|
+
// Type to pick: the next option (after the chosen one) whose label starts with the letter.
|
|
232
|
+
const letter = fold(key.key);
|
|
233
|
+
const list = choices();
|
|
234
|
+
const from = list.findIndex((option) => option.value === select.value);
|
|
235
|
+
for (let step = 1; step <= list.length; step++) {
|
|
236
|
+
const option = list[(from + step) % list.length]!;
|
|
237
|
+
if (!option.disabled && option.value !== '' && fold(option.text).startsWith(letter)) {
|
|
238
|
+
choose(option.value, true);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const refresh = () => {
|
|
246
|
+
buildItems();
|
|
247
|
+
paint();
|
|
248
|
+
};
|
|
249
|
+
// The app may change the select's options (or its disabled state) itself.
|
|
250
|
+
if (typeof MutationObserver === 'function') scope.observe(new MutationObserver(() => !scope.disposed && refresh())).observe(select, { childList: true, subtree: true, attributes: true, attributeFilter: ['disabled', 'label'] });
|
|
251
|
+
refresh();
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
setValue: (value, notify = true) => choose(value, notify),
|
|
255
|
+
setOptions(next) {
|
|
256
|
+
fillSelect(select, next);
|
|
257
|
+
refresh();
|
|
258
|
+
},
|
|
259
|
+
refresh,
|
|
260
|
+
open,
|
|
261
|
+
close: () => menu.close(),
|
|
262
|
+
get value() {
|
|
263
|
+
return select.value;
|
|
264
|
+
},
|
|
265
|
+
destroy: () => scope.dispose(),
|
|
266
|
+
};
|
|
267
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { createSelect, type SelectInstance, type SelectOptions } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface SelectProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'>, Omit<SelectOptions, 'value'> {
|
|
7
|
+
/** Controlled value; without it the select keeps its own (defaultValue). */
|
|
8
|
+
value?: string;
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** <Select label="Equipo" options={teams} value={team} onChange={setTeam} />. */
|
|
13
|
+
export function Select({ options, value, defaultValue, name, label, placeholder, disabled, onChange, className, ...props }: SelectProps) {
|
|
14
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
15
|
+
const instance = useRef<SelectInstance | null>(null);
|
|
16
|
+
const change = useLatest(onChange);
|
|
17
|
+
const start = useRef(value ?? defaultValue);
|
|
18
|
+
const key = JSON.stringify(options ?? null);
|
|
19
|
+
useIsomorphicLayoutEffect(() => {
|
|
20
|
+
const created = createSelect(ref.current, { options, value: value ?? start.current, name, label, placeholder, disabled, onChange: (next) => change.current?.(next) });
|
|
21
|
+
instance.current = created;
|
|
22
|
+
return () => {
|
|
23
|
+
start.current = created.value;
|
|
24
|
+
created.destroy();
|
|
25
|
+
instance.current = null;
|
|
26
|
+
};
|
|
27
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
+
}, [key, name, label, placeholder, disabled]);
|
|
29
|
+
useIsomorphicLayoutEffect(() => {
|
|
30
|
+
if (value !== undefined && instance.current && instance.current.value !== value) instance.current.setValue(value, false);
|
|
31
|
+
}, [value]);
|
|
32
|
+
return <div {...props} ref={ref} className={['mk-select', className].filter(Boolean).join(' ')} />;
|
|
33
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* select — a 12 px field button (surface-3) with the chosen label and a chevron that turns, opening the kit's menu:
|
|
2
|
+
a 16 px surface-1 panel with 8 px items, group headings and a check on the chosen one. The label slides in out of a
|
|
3
|
+
blur when it changes. The <select> it keeps in step is hidden. */
|
|
4
|
+
.mk-select,
|
|
5
|
+
mk-select {
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
min-width: 0;
|
|
8
|
+
max-width: 100%;
|
|
9
|
+
vertical-align: middle;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:is(.mk-select, mk-select) > select[hidden] {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
[data-mk-select-trigger] {
|
|
17
|
+
display: inline-flex;
|
|
18
|
+
flex: 1;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: space-between;
|
|
21
|
+
gap: 0.5rem;
|
|
22
|
+
min-width: 0;
|
|
23
|
+
height: 2.5rem;
|
|
24
|
+
padding: 0 0.55rem 0 0.8rem;
|
|
25
|
+
border: 0;
|
|
26
|
+
border-radius: 12px;
|
|
27
|
+
background: var(--mk-surface-3);
|
|
28
|
+
color: var(--mk-text);
|
|
29
|
+
font: inherit;
|
|
30
|
+
font-size: 0.875rem;
|
|
31
|
+
text-align: start;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
transition:
|
|
34
|
+
background-color 0.15s,
|
|
35
|
+
box-shadow 0.2s;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-mk-select-trigger]:hover:not(:disabled),
|
|
39
|
+
[data-mk-select-trigger][aria-expanded='true'] {
|
|
40
|
+
background: color-mix(in srgb, var(--mk-surface-3) 80%, var(--mk-text) 8%);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[data-mk-select-trigger]:focus-visible {
|
|
44
|
+
outline: none;
|
|
45
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--mk-accent) 35%, transparent);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
[data-mk-select-trigger]:disabled {
|
|
49
|
+
opacity: 0.45;
|
|
50
|
+
cursor: default;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[data-mk-select-value] {
|
|
54
|
+
flex: 1;
|
|
55
|
+
min-width: 0;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
text-overflow: ellipsis;
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:is(.mk-select, mk-select)[data-mk-placeholder] [data-mk-select-value] {
|
|
62
|
+
color: var(--mk-muted);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
[data-mk-select-chevron] {
|
|
66
|
+
flex: none;
|
|
67
|
+
color: var(--mk-muted);
|
|
68
|
+
transition: transform 0.3s cubic-bezier(0.38, 0.49, 0, 1.5);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[data-mk-select-trigger][aria-expanded='true'] [data-mk-select-chevron] {
|
|
72
|
+
transform: rotate(180deg);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* The menu: like the panels of the data table (surface-1, a hairline, 8 px items). */
|
|
76
|
+
.mk-dialog.mk-select-menu {
|
|
77
|
+
--mk-dialog-bg: var(--mk-surface-1);
|
|
78
|
+
--mk-dialog-radius: 16px;
|
|
79
|
+
--mk-dialog-shadow: 0 0 0 1px var(--mk-outline-soft), 0 16px 48px -12px color-mix(in srgb, var(--mk-shadow-color, #000) 35%, transparent);
|
|
80
|
+
gap: 0.125rem;
|
|
81
|
+
min-width: max(10rem, var(--mk-select-width, 0px));
|
|
82
|
+
max-height: min(20rem, 60dvh);
|
|
83
|
+
padding: 0.375rem;
|
|
84
|
+
overflow-y: auto;
|
|
85
|
+
-webkit-backdrop-filter: none;
|
|
86
|
+
backdrop-filter: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.mk-dialog.mk-select-menu [data-mk-item] {
|
|
90
|
+
flex: none;
|
|
91
|
+
gap: 0.625rem;
|
|
92
|
+
min-height: 2.25rem;
|
|
93
|
+
padding: 0 0.625rem;
|
|
94
|
+
border-radius: 8px;
|
|
95
|
+
font-family: inherit;
|
|
96
|
+
font-size: 0.875rem;
|
|
97
|
+
font-weight: 500;
|
|
98
|
+
letter-spacing: normal;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.mk-dialog.mk-select-menu [data-mk-item]:hover,
|
|
102
|
+
.mk-dialog.mk-select-menu [data-mk-item]:focus-visible {
|
|
103
|
+
background: var(--mk-surface-2);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.mk-dialog.mk-select-menu [data-mk-item] svg {
|
|
107
|
+
flex: none;
|
|
108
|
+
margin-left: auto;
|
|
109
|
+
opacity: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.mk-dialog.mk-select-menu [data-mk-item][aria-checked='true'] {
|
|
113
|
+
font-weight: 600;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.mk-dialog.mk-select-menu [data-mk-item][aria-checked='true'] svg {
|
|
117
|
+
opacity: 1;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
[data-mk-select-group] {
|
|
121
|
+
flex: none;
|
|
122
|
+
margin: 0.375rem 0.625rem 0.125rem;
|
|
123
|
+
color: var(--mk-muted);
|
|
124
|
+
font-size: 0.6875rem;
|
|
125
|
+
font-weight: 700;
|
|
126
|
+
letter-spacing: 0.04em;
|
|
127
|
+
text-transform: uppercase;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@media (prefers-reduced-motion: reduce) {
|
|
131
|
+
[data-mk-select-trigger],
|
|
132
|
+
[data-mk-select-chevron] {
|
|
133
|
+
transition: none;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# skeleton
|
|
2
|
+
|
|
3
|
+
Marcador de carga para texto, avatar, imagen o tarjeta. El placeholder es decorativo (`aria-hidden`) y el root marca `aria-busy` con un estado oculto que nombra lo que carga. El contenido real queda oculto sólo mientras carga.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<mk-skeleton class="mk-skeleton" shape="card" animation="shimmer" label="Cargando perfil">
|
|
7
|
+
<article data-mk-skeleton-content>…contenido real…</article>
|
|
8
|
+
</mk-skeleton>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Con `[data-mk-skeleton-placeholder]` propio se usa ese marcado; sin él, el motor crea los huesos de `shape`. `defineElements()` (atributo `loaded` para terminar), `createSkeleton(root, options)` o `<Skeleton loading={pending} shape="avatar" label="Cargando autor"><Author /></Skeleton>`.
|
|
12
|
+
|
|
13
|
+
Opciones: `loading=true`, `animation='pulse'|'shimmer'|'none'`, `shape='text'|'avatar'|'image'|'card'`, `lines=3` (texto), `label='Cargando'`. API: `setLoading(boolean)`, `loading`, `destroy()`; evento `mk:loading` con `{loading}`. `skeletonBones(shape, lines)` devuelve los huesos para dibujar el mismo placeholder desde otro framework.
|
|
14
|
+
|
|
15
|
+
El contenido que el autor ya tenía `hidden` sigue oculto al terminar. En React, placeholder y contenido son subárboles distintos de React; el motor sólo cambia `hidden` y el estado. `destroy()` quita lo generado y restaura atributos. Variables: `--mk-skeleton-bone`, `--mk-skeleton-sheen`, `--mk-skeleton-radius`, `--mk-skeleton-duration` (1.6s). Movimiento reducido: superficie estática, sin pulso ni brillo.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createSkeleton, type SkeletonInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-skeleton class="mk-skeleton" shape="card" label="Cargando perfil">
|
|
6
|
+
* <article data-mk-skeleton-content>…</article>
|
|
7
|
+
* </mk-skeleton>
|
|
8
|
+
* Loading until `loaded` is set (or `setLoading(false)`); a placeholder is made from `shape`.
|
|
9
|
+
*/
|
|
10
|
+
export class MkSkeletonElement extends MkElement<SkeletonInstance> {
|
|
11
|
+
static options: Record<string, OptionType> = { loaded: 'boolean', animation: 'string', shape: 'string', lines: 'number', label: 'string' };
|
|
12
|
+
|
|
13
|
+
protected create(options: Record<string, unknown>) {
|
|
14
|
+
return createSkeleton(this, { ...options, loading: !options.loaded });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null) {
|
|
18
|
+
if (previous === next || !this.instance) return;
|
|
19
|
+
if (name === 'loaded') this.instance.setLoading(next === null || next === 'false');
|
|
20
|
+
else super.attributeChangedCallback(name, previous, next);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
setLoading(loading: boolean) {
|
|
24
|
+
this.instance?.setLoading(loading);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get loading() {
|
|
28
|
+
return this.instance?.loading ?? false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const defineSkeleton = () => defineElement('mk-skeleton', MkSkeletonElement);
|