@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,206 @@
|
|
|
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, ringPulse, rollDigits } from '../../motion/micro';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Add to cart: the button packs the product and sends it to the cart. A copy of
|
|
9
|
+
* the product's picture shrinks and drops into a little box whose flaps close
|
|
10
|
+
* with a bounce and whose tape draws itself (.6 s); the box flies to the cart on
|
|
11
|
+
* an arc (x on the signature curve, y up then down, a slight spin, shrinking,
|
|
12
|
+
* .62 s), dives into it, and the cart bumps, pulses a ring and rolls its count.
|
|
13
|
+
* Each click sends its own box; the cart shows the latest count when a box
|
|
14
|
+
* lands. With reduced motion the count changes at once. The flight comes from
|
|
15
|
+
* the mini POS's flyToCart; the packing is new.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface AddToCartOptions {
|
|
19
|
+
/** Where the box goes: an element, a selector, or (default) the first visible [data-mk-cart-target]. */
|
|
20
|
+
target?: HTMLElement | string;
|
|
21
|
+
/** The picture packed: an element, a selector, or (default) the [data-mk-cart-image] of the [data-mk-cart-item] around the button. */
|
|
22
|
+
image?: HTMLElement | string;
|
|
23
|
+
/** Items each click adds (default 1). */
|
|
24
|
+
quantity?: number;
|
|
25
|
+
/** The cart's count to start from (default: the number in the target's [data-mk-cart-count], else 0). */
|
|
26
|
+
count?: number;
|
|
27
|
+
/** Announced after a box lands (default 'Añadido al carrito'). */
|
|
28
|
+
label?: string;
|
|
29
|
+
/** A click: the new count (right away). */
|
|
30
|
+
onAdd?: (count: number) => void;
|
|
31
|
+
/** A box landed in the cart. */
|
|
32
|
+
onLand?: (count: number) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface AddToCartInstance extends Instance {
|
|
36
|
+
/** Send a box, as a click does. */
|
|
37
|
+
add(): void;
|
|
38
|
+
setCount(count: number): void;
|
|
39
|
+
readonly count: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const BOX = 56;
|
|
43
|
+
const FLIGHT = 0.62;
|
|
44
|
+
|
|
45
|
+
/** An element from an option, a selector, or a default lookup. */
|
|
46
|
+
const resolve = (option: HTMLElement | string | undefined, fallback: () => HTMLElement | null) =>
|
|
47
|
+
option instanceof HTMLElement ? option : typeof option === 'string' ? document.querySelector<HTMLElement>(option) : fallback();
|
|
48
|
+
|
|
49
|
+
export function createAddToCart(root: HTMLElement | null, options: AddToCartOptions = {}): AddToCartInstance {
|
|
50
|
+
const button = root ? (root.matches('button') ? root : root.querySelector<HTMLElement>('button')) : null;
|
|
51
|
+
if (!root || !button) return inert({ add() {}, setCount() {}, count: 0 });
|
|
52
|
+
registerMotion();
|
|
53
|
+
const scope = createScope();
|
|
54
|
+
const quantity = Number.isFinite(options.quantity) && options.quantity! > 0 ? Math.round(options.quantity!) : 1;
|
|
55
|
+
|
|
56
|
+
const target = () =>
|
|
57
|
+
resolve(options.target, () => {
|
|
58
|
+
const all = [...document.querySelectorAll<HTMLElement>('[data-mk-cart-target]')];
|
|
59
|
+
return all.find((element) => {
|
|
60
|
+
const box = element.getBoundingClientRect();
|
|
61
|
+
return box.width > 0 && box.bottom > 0 && box.top < innerHeight;
|
|
62
|
+
}) ?? all[0] ?? null;
|
|
63
|
+
});
|
|
64
|
+
const image = () => resolve(options.image, () => button.closest('[data-mk-cart-item]')?.querySelector<HTMLElement>('[data-mk-cart-image]') ?? null);
|
|
65
|
+
const counter = () => target()?.querySelector<HTMLElement>('[data-mk-cart-count]') ?? null;
|
|
66
|
+
const read = Number.parseInt(counter()?.textContent ?? '', 10);
|
|
67
|
+
let count = Number.isFinite(options.count) ? Math.max(0, Math.round(options.count!)) : Number.isFinite(read) ? read : 0;
|
|
68
|
+
|
|
69
|
+
const status = document.createElement('span');
|
|
70
|
+
status.className = 'mk-sr-only';
|
|
71
|
+
status.setAttribute('role', 'status');
|
|
72
|
+
root.append(status);
|
|
73
|
+
scope.add(() => status.remove());
|
|
74
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
75
|
+
|
|
76
|
+
const boxes = new Set<HTMLElement>();
|
|
77
|
+
const effects = new Set<gsap.core.Animation>();
|
|
78
|
+
const keep = (animation: gsap.core.Animation | null) => {
|
|
79
|
+
if (!animation) return;
|
|
80
|
+
effects.add(animation);
|
|
81
|
+
// Finished ones leave as new ones arrive: the animation's own onComplete stays untouched.
|
|
82
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
83
|
+
};
|
|
84
|
+
scope.add(() => {
|
|
85
|
+
for (const effect of effects) effect.kill();
|
|
86
|
+
effects.clear();
|
|
87
|
+
for (const box of boxes) box.remove();
|
|
88
|
+
boxes.clear();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
/** The cart takes the box: it bumps, pulses and rolls its count to the latest number. */
|
|
92
|
+
const land = (animate: boolean) => {
|
|
93
|
+
const cart = target();
|
|
94
|
+
const number = counter();
|
|
95
|
+
const text = String(count);
|
|
96
|
+
if (number && number.textContent !== text) {
|
|
97
|
+
if (animate) keep(rollDigits(number, text, 1, 0.35));
|
|
98
|
+
else number.textContent = text;
|
|
99
|
+
}
|
|
100
|
+
if (cart && animate) {
|
|
101
|
+
keep(gsap.fromTo(cart, { scale: 1 }, { scale: 1.1, duration: 0.14, ease: 'power2.out', yoyo: true, repeat: 1, clearProps: 'transform' }));
|
|
102
|
+
keep(ringPulse(cart));
|
|
103
|
+
}
|
|
104
|
+
status.textContent = `${options.label ?? 'Añadido al carrito'}: ${count}`;
|
|
105
|
+
options.onLand?.(count);
|
|
106
|
+
root.dispatchEvent(new CustomEvent('mk:land', { bubbles: true, detail: { count } }));
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/** The box: the picture inside, a front, two flaps and a strip of tape. */
|
|
110
|
+
const makeBox = (picture: HTMLElement | null) => {
|
|
111
|
+
const box = document.createElement('div');
|
|
112
|
+
box.dataset.mkCartBox = '';
|
|
113
|
+
box.setAttribute('aria-hidden', 'true');
|
|
114
|
+
let thumb: HTMLImageElement | null = null;
|
|
115
|
+
const src = picture instanceof HTMLImageElement ? picture.currentSrc || picture.getAttribute('src') : null;
|
|
116
|
+
if (src) {
|
|
117
|
+
thumb = document.createElement('img');
|
|
118
|
+
thumb.src = src;
|
|
119
|
+
thumb.alt = '';
|
|
120
|
+
thumb.dataset.mkCartThumb = '';
|
|
121
|
+
box.append(thumb);
|
|
122
|
+
}
|
|
123
|
+
const front = document.createElement('span');
|
|
124
|
+
front.dataset.mkCartFront = '';
|
|
125
|
+
const tape = document.createElement('span');
|
|
126
|
+
tape.dataset.mkCartTape = '';
|
|
127
|
+
front.append(tape);
|
|
128
|
+
const left = document.createElement('span');
|
|
129
|
+
left.dataset.mkCartFlap = 'left';
|
|
130
|
+
const right = document.createElement('span');
|
|
131
|
+
right.dataset.mkCartFlap = 'right';
|
|
132
|
+
box.append(front, left, right);
|
|
133
|
+
return { box, thumb, front, tape, left, right };
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const add = () => {
|
|
137
|
+
if (scope.disposed) return;
|
|
138
|
+
count += quantity;
|
|
139
|
+
options.onAdd?.(count);
|
|
140
|
+
root.dispatchEvent(new CustomEvent('mk:add', { bubbles: true, detail: { count } }));
|
|
141
|
+
if (reduced()) return land(false);
|
|
142
|
+
keep(press(button));
|
|
143
|
+
const picture = image();
|
|
144
|
+
const from = (picture ?? button).getBoundingClientRect();
|
|
145
|
+
const cart = target();
|
|
146
|
+
const to = cart?.getBoundingClientRect() ?? null;
|
|
147
|
+
const { box, thumb, front, tape, left, right } = makeBox(picture);
|
|
148
|
+
const startX = from.left + from.width / 2 - BOX / 2;
|
|
149
|
+
const startY = from.top + from.height / 2 - BOX / 2;
|
|
150
|
+
Object.assign(box.style, { left: `${startX}px`, top: `${startY}px`, width: `${BOX}px`, height: `${BOX}px` });
|
|
151
|
+
document.body.append(box);
|
|
152
|
+
boxes.add(box);
|
|
153
|
+
const gone = () => {
|
|
154
|
+
box.remove();
|
|
155
|
+
boxes.delete(box);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const timeline = gsap.timeline({
|
|
159
|
+
onComplete: () => {
|
|
160
|
+
gone();
|
|
161
|
+
land(true);
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
// 1 · Packing: the picture shrinks into the box, the box rises around it, the flaps close, the tape draws.
|
|
165
|
+
if (thumb) {
|
|
166
|
+
const scale = Math.max(from.width, from.height) / 40 || 1;
|
|
167
|
+
timeline.fromTo(thumb, { scale, y: 0, opacity: 1 }, { scale: 1, y: -14, duration: 0.32, ease: EASE.signature }, 0);
|
|
168
|
+
timeline.to(thumb, { y: 4, duration: 0.16, ease: 'power2.in' }, 0.3);
|
|
169
|
+
}
|
|
170
|
+
timeline.fromTo(front, { scaleY: 0 }, { scaleY: 1, duration: 0.26, ease: EASE.pop }, 0.08);
|
|
171
|
+
timeline.fromTo([left, right], { opacity: 0 }, { opacity: 1, duration: 0.12 }, 0.12);
|
|
172
|
+
timeline.fromTo(left, { rotation: -70 }, { rotation: 0, duration: 0.3, ease: EASE.click }, 0.38);
|
|
173
|
+
timeline.fromTo(right, { rotation: 70 }, { rotation: 0, duration: 0.3, ease: EASE.click }, 0.43);
|
|
174
|
+
timeline.fromTo(tape, { scaleY: 0 }, { scaleY: 1, duration: 0.16, ease: EASE.wipe }, 0.62);
|
|
175
|
+
// 2 · The flight: an arc to the cart (x on the signature curve, y up then down), a slight spin, smaller.
|
|
176
|
+
const start = 0.74;
|
|
177
|
+
if (to) {
|
|
178
|
+
const dx = to.left + to.width / 2 - (startX + BOX / 2);
|
|
179
|
+
const dy = to.top + to.height / 2 - (startY + BOX / 2);
|
|
180
|
+
const lift = Math.min(dy, 0) - 70;
|
|
181
|
+
timeline.to(box, { x: dx, duration: FLIGHT, ease: EASE.signature }, start);
|
|
182
|
+
timeline.to(box, { y: lift, duration: FLIGHT * 0.42, ease: 'power2.out' }, start);
|
|
183
|
+
timeline.to(box, { y: dy, duration: FLIGHT * 0.58, ease: 'power2.in' }, start + FLIGHT * 0.42);
|
|
184
|
+
timeline.fromTo(box, { rotation: 0 }, { rotation: 10, scale: 0.55, duration: FLIGHT, ease: 'power1.inOut' }, start);
|
|
185
|
+
// 3 · Into the cart.
|
|
186
|
+
timeline.to(box, { scale: 0.15, opacity: 0, duration: 0.14, ease: 'power2.in' }, start + FLIGHT - 0.04);
|
|
187
|
+
} else timeline.to(box, { y: -24, opacity: 0, scale: 0.8, filter: 'blur(6px)', duration: 0.3, ease: 'power2.in' }, start);
|
|
188
|
+
keep(timeline);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
scope.on(button, 'click', add);
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
add,
|
|
195
|
+
setCount(next) {
|
|
196
|
+
if (!Number.isFinite(next)) return;
|
|
197
|
+
count = Math.max(0, Math.round(next));
|
|
198
|
+
const number = counter();
|
|
199
|
+
if (number) number.textContent = String(count);
|
|
200
|
+
},
|
|
201
|
+
get count() {
|
|
202
|
+
return count;
|
|
203
|
+
},
|
|
204
|
+
destroy: () => scope.dispose(),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes, type MutableRefObject } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { createAddToCart, type AddToCartInstance, type AddToCartOptions } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface AddToCartProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onAdd'>, AddToCartOptions {
|
|
7
|
+
instanceRef?: MutableRefObject<AddToCartInstance | null>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** <AddToCart target="#carrito" onAdd={setCount}><button className="mk-button">Agregar</button></AddToCart>. */
|
|
11
|
+
export function AddToCart({ target, image, quantity, count, label, onAdd, onLand, instanceRef, className, children, ...props }: AddToCartProps) {
|
|
12
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
13
|
+
const add = useLatest(onAdd);
|
|
14
|
+
const landed = useLatest(onLand);
|
|
15
|
+
useIsomorphicLayoutEffect(() => {
|
|
16
|
+
const created = createAddToCart(ref.current, { target, image, quantity, count, label, onAdd: (n) => add.current?.(n), onLand: (n) => landed.current?.(n) });
|
|
17
|
+
if (instanceRef) instanceRef.current = created;
|
|
18
|
+
return () => {
|
|
19
|
+
created.destroy();
|
|
20
|
+
if (instanceRef) instanceRef.current = null;
|
|
21
|
+
};
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
+
}, [typeof target === 'string' ? target : null, typeof image === 'string' ? image : null, quantity, label]);
|
|
24
|
+
return (
|
|
25
|
+
<div {...props} ref={ref} className={['mk-add-to-cart', className].filter(Boolean).join(' ')}>
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# attachment
|
|
2
|
+
|
|
3
|
+
Selector de archivos nativo con zona para arrastrar y soltar y una tarjeta por archivo (nombre, tipo, tamaño, progreso, estado y quitar). Valida `accept`, tamaño y cantidad; la subida pertenece a la app, que informa el progreso.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<mk-attachment class="mk-attachment" accept="image/*,.pdf" multiple max-files="4" max-size="5242880"></mk-attachment>
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const attachment = createAttachment(root, {
|
|
11
|
+
accept: 'image/*,.pdf',
|
|
12
|
+
multiple: true,
|
|
13
|
+
maxFiles: 4,
|
|
14
|
+
maxSize: 5 * 1024 * 1024,
|
|
15
|
+
onFiles: (added) => added.forEach((file) => upload(file.file!, (pct) => attachment.setProgress(file.id, pct))),
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
React: `<Attachment multiple accept=".pdf" onFiles={upload} uploads={{ [id]: { progress: 40 } }} />`, o `instanceRef` para llamar a la API.
|
|
20
|
+
|
|
21
|
+
Opciones: `accept` (extensiones, MIME y `tipo/*`), `multiple`, `maxFiles` (sólo multiple), `maxSize` (bytes), `disabled`, `name`, `initialFiles` (metadatos `{id?, name, size, type, preview?, progress?, status?}`), `hint`, `labels`, `onFiles(added, files)`, `onRemove(file, files)`, `onReject(rejections)`. API: `addFiles(files)` (devuelve los aceptados), `remove(id)`, `setProgress(id, 0–100, status?)`, `clear()`, `files` (copias), `destroy()`.
|
|
22
|
+
|
|
23
|
+
Eventos: `mk:files` `{added, files}`, `mk:remove` `{file, files}` y `mk:reject` `{file, code: 'type' | 'size' | 'count', message}` (uno por archivo). Los archivos válidos se conservan al añadir más; en modo simple el nuevo sustituye al anterior. Las vistas previas de imagen son object URLs que se revocan al quitar el archivo o al destruir. Los nombres se muestran siempre como texto.
|
|
24
|
+
|
|
25
|
+
`disabled` desactiva selector, soltar y quitar (también `remove()`). Con `name` y `DataTransfer` disponible, el input lleva los archivos conservados para un envío nativo. Quitar un archivo deja el foco en el siguiente botón o en el selector. `destroy()` elimina lo creado y restaura atributos. El custom element expone `addFiles`, `removeFile(id)` (`remove()` sigue siendo el de `HTMLElement`), `setProgress` y `files`, y conserva los archivos al cambiar un atributo.
|
|
26
|
+
|
|
27
|
+
Variables: `--mk-attachment-radius`, `--mk-attachment-accent`. Movimiento reducido elimina escalas y entradas.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/* attachment — a soft dashed drop zone and file cards with progress (Melon Mind surfaces: 16–24 px radius). */
|
|
2
|
+
.mk-attachment,
|
|
3
|
+
mk-attachment {
|
|
4
|
+
--mk-attachment-radius: var(--mk-radius-lg, 24px);
|
|
5
|
+
--mk-attachment-accent: var(--mk-accent);
|
|
6
|
+
display: grid;
|
|
7
|
+
gap: 0.75rem;
|
|
8
|
+
color: var(--mk-text);
|
|
9
|
+
font-family: var(--mk-font);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop] {
|
|
13
|
+
position: relative;
|
|
14
|
+
display: grid;
|
|
15
|
+
justify-items: center;
|
|
16
|
+
gap: 0.35rem;
|
|
17
|
+
padding: 1.75rem 1.25rem;
|
|
18
|
+
border: 1.5px dashed var(--mk-outline-soft);
|
|
19
|
+
border-radius: var(--mk-attachment-radius);
|
|
20
|
+
background: var(--mk-surface-2);
|
|
21
|
+
text-align: center;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
transition:
|
|
24
|
+
background-color 0.2s ease,
|
|
25
|
+
border-color 0.2s ease,
|
|
26
|
+
transform 0.25s var(--mk-ease-press, ease);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop]:hover,
|
|
30
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop][data-mk-dragging] {
|
|
31
|
+
border-color: var(--mk-outline);
|
|
32
|
+
background: var(--mk-surface-3);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop][data-mk-dragging] {
|
|
36
|
+
transform: scale(1.015);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop]:active {
|
|
40
|
+
transform: scale(0.99);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop]:has(input:focus-visible) {
|
|
44
|
+
outline: 2px solid var(--mk-accent);
|
|
45
|
+
outline-offset: 3px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:is(.mk-attachment, mk-attachment)[data-mk-disabled] [data-mk-attachment-drop] {
|
|
49
|
+
opacity: 0.5;
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
transform: none;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop] input[type='file'] {
|
|
55
|
+
position: absolute;
|
|
56
|
+
width: 1px;
|
|
57
|
+
height: 1px;
|
|
58
|
+
opacity: 0;
|
|
59
|
+
pointer-events: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop] [data-mk-part='icon'] {
|
|
63
|
+
display: grid;
|
|
64
|
+
place-items: center;
|
|
65
|
+
width: 2.75rem;
|
|
66
|
+
height: 2.75rem;
|
|
67
|
+
margin-bottom: 0.25rem;
|
|
68
|
+
border-radius: 50%;
|
|
69
|
+
background: var(--mk-text);
|
|
70
|
+
color: var(--mk-bg);
|
|
71
|
+
transition: translate 0.4s cubic-bezier(0.38, 0.49, 0, 2);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop]:is(:hover, [data-mk-dragging]) [data-mk-part='icon'] {
|
|
75
|
+
translate: 0 -4px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop] [data-mk-part='icon']::before {
|
|
79
|
+
content: '';
|
|
80
|
+
width: 1.25rem;
|
|
81
|
+
height: 1.25rem;
|
|
82
|
+
background: currentColor;
|
|
83
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4M6.5 9.5 12 4l5.5 5.5M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop] strong {
|
|
87
|
+
color: var(--mk-text);
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
text-decoration: underline;
|
|
90
|
+
text-underline-offset: 0.2em;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-drop] small {
|
|
94
|
+
color: var(--mk-muted);
|
|
95
|
+
font-size: 0.8125rem;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-list] {
|
|
99
|
+
display: grid;
|
|
100
|
+
gap: 0.5rem;
|
|
101
|
+
margin: 0;
|
|
102
|
+
padding: 0;
|
|
103
|
+
list-style: none;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-list]:empty {
|
|
107
|
+
display: none;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-item] {
|
|
111
|
+
display: grid;
|
|
112
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
113
|
+
align-items: center;
|
|
114
|
+
gap: 0.875rem;
|
|
115
|
+
padding: 0.625rem 0.625rem 0.625rem 0.75rem;
|
|
116
|
+
border-radius: calc(var(--mk-attachment-radius) - 8px);
|
|
117
|
+
background: var(--mk-surface-1);
|
|
118
|
+
box-shadow: inset 0 0 0 1px var(--mk-outline-soft);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-item][data-mk-status='error'] {
|
|
122
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mk-error) 45%, transparent);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-item] [data-mk-part='thumb'] {
|
|
126
|
+
display: grid;
|
|
127
|
+
place-items: center;
|
|
128
|
+
overflow: hidden;
|
|
129
|
+
width: 2.75rem;
|
|
130
|
+
height: 2.75rem;
|
|
131
|
+
border-radius: 0.875rem;
|
|
132
|
+
background: var(--mk-surface-3);
|
|
133
|
+
color: var(--mk-muted);
|
|
134
|
+
font-size: 0.6875rem;
|
|
135
|
+
font-weight: 600;
|
|
136
|
+
letter-spacing: 0.04em;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
:is(.mk-attachment, mk-attachment) [data-mk-part='thumb'] img {
|
|
140
|
+
width: 100%;
|
|
141
|
+
height: 100%;
|
|
142
|
+
object-fit: cover;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:is(.mk-attachment, mk-attachment) [data-mk-part='meta'] {
|
|
146
|
+
display: grid;
|
|
147
|
+
gap: 0.15rem;
|
|
148
|
+
min-width: 0;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
:is(.mk-attachment, mk-attachment) [data-mk-part='name'] {
|
|
152
|
+
overflow: hidden;
|
|
153
|
+
font-weight: 500;
|
|
154
|
+
text-overflow: ellipsis;
|
|
155
|
+
white-space: nowrap;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
:is(.mk-attachment, mk-attachment) [data-mk-part='detail'] {
|
|
159
|
+
color: var(--mk-muted);
|
|
160
|
+
font-size: 0.8125rem;
|
|
161
|
+
font-variant-numeric: tabular-nums;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
:is(.mk-attachment, mk-attachment) [data-mk-status='complete'] [data-mk-part='detail'] {
|
|
165
|
+
color: var(--mk-accent);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
:is(.mk-attachment, mk-attachment) [data-mk-status='error'] [data-mk-part='detail'] {
|
|
169
|
+
color: var(--mk-error);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
:is(.mk-attachment, mk-attachment) progress {
|
|
173
|
+
width: 100%;
|
|
174
|
+
height: 4px;
|
|
175
|
+
margin-top: 0.3rem;
|
|
176
|
+
overflow: hidden;
|
|
177
|
+
border: 0;
|
|
178
|
+
border-radius: var(--mk-radius-full);
|
|
179
|
+
background: var(--mk-surface-4);
|
|
180
|
+
appearance: none;
|
|
181
|
+
accent-color: var(--mk-attachment-accent);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
:is(.mk-attachment, mk-attachment) progress[hidden] {
|
|
185
|
+
display: none;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
:is(.mk-attachment, mk-attachment) progress::-webkit-progress-bar {
|
|
189
|
+
background: transparent;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
:is(.mk-attachment, mk-attachment) progress::-webkit-progress-value {
|
|
193
|
+
border-radius: inherit;
|
|
194
|
+
background: var(--mk-attachment-accent);
|
|
195
|
+
transition: width 0.3s ease;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
:is(.mk-attachment, mk-attachment) progress::-moz-progress-bar {
|
|
199
|
+
border-radius: inherit;
|
|
200
|
+
background: var(--mk-attachment-accent);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-remove] {
|
|
204
|
+
display: grid;
|
|
205
|
+
place-items: center;
|
|
206
|
+
width: 2.5rem;
|
|
207
|
+
height: 2.5rem;
|
|
208
|
+
padding: 0;
|
|
209
|
+
border: 0;
|
|
210
|
+
border-radius: 50%;
|
|
211
|
+
background: transparent;
|
|
212
|
+
color: var(--mk-muted);
|
|
213
|
+
cursor: pointer;
|
|
214
|
+
transition:
|
|
215
|
+
background-color 0.2s ease,
|
|
216
|
+
color 0.2s ease,
|
|
217
|
+
transform 0.2s var(--mk-ease-press, ease);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-remove]:hover:not(:disabled) {
|
|
221
|
+
background: color-mix(in srgb, var(--mk-error) 12%, transparent);
|
|
222
|
+
color: var(--mk-error);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-remove]:active:not(:disabled) {
|
|
226
|
+
transform: scale(0.9);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-remove]:focus-visible {
|
|
230
|
+
outline: 2px solid var(--mk-accent);
|
|
231
|
+
outline-offset: 2px;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-remove]:disabled {
|
|
235
|
+
opacity: 0.4;
|
|
236
|
+
cursor: not-allowed;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-error] {
|
|
240
|
+
margin: 0;
|
|
241
|
+
padding: 0.625rem 0.875rem;
|
|
242
|
+
border-radius: var(--mk-radius-lg);
|
|
243
|
+
background: var(--mk-error-soft);
|
|
244
|
+
color: var(--mk-on-error-soft);
|
|
245
|
+
font-size: 0.875rem;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
:is(.mk-attachment, mk-attachment) [data-mk-attachment-error][hidden] {
|
|
249
|
+
display: none;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
@keyframes mk-attachment-in {
|
|
253
|
+
from {
|
|
254
|
+
opacity: 0;
|
|
255
|
+
transform: translateY(6px) scale(0.98);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@media (prefers-reduced-motion: reduce) {
|
|
260
|
+
:is(.mk-attachment, mk-attachment) :is([data-mk-attachment-drop], [data-mk-attachment-item], [data-mk-attachment-remove]) {
|
|
261
|
+
transition: none;
|
|
262
|
+
animation: none;
|
|
263
|
+
transform: none !important;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createAttachment, type AttachmentInstance, type AttachmentStatus } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-attachment class="mk-attachment" accept="image/*,.pdf" multiple max-files="4" max-size="5000000"></mk-attachment>
|
|
6
|
+
* Emits mk:files ({added, files}), mk:remove ({file, files}) and mk:reject ({file, code, message}).
|
|
7
|
+
* Changing an attribute keeps the files already chosen.
|
|
8
|
+
*/
|
|
9
|
+
export class MkAttachmentElement extends MkElement<AttachmentInstance> {
|
|
10
|
+
static options: Record<string, OptionType> = {
|
|
11
|
+
accept: 'string',
|
|
12
|
+
multiple: 'boolean',
|
|
13
|
+
maxFiles: 'number',
|
|
14
|
+
maxSize: 'number',
|
|
15
|
+
disabled: 'boolean',
|
|
16
|
+
name: 'string',
|
|
17
|
+
hint: 'string',
|
|
18
|
+
initialFiles: 'json',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
protected create(options: Record<string, unknown>) {
|
|
22
|
+
return createAttachment(this, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null) {
|
|
26
|
+
if (previous === next || !this.isConnected || !this.instance) return;
|
|
27
|
+
const files = this.instance.files;
|
|
28
|
+
this.instance.destroy();
|
|
29
|
+
this.instance = this.create({ ...this.options, initialFiles: files });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
addFiles(files: Iterable<File> | ArrayLike<File>) {
|
|
33
|
+
return this.instance?.addFiles(files) ?? [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Remove one file (HTMLElement.remove() still removes the element). */
|
|
37
|
+
removeFile(id: string) {
|
|
38
|
+
this.instance?.remove(id);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setProgress(id: string, value: number, status?: AttachmentStatus) {
|
|
42
|
+
this.instance?.setProgress(id, value, status);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
get files() {
|
|
46
|
+
return this.instance?.files ?? [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const defineAttachment = () => defineElement('mk-attachment', MkAttachmentElement);
|