@yewdiel21/motion-kit 0.9.1 → 0.14.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 +72 -0
- package/dist/auto/index.d.ts +72 -3
- package/dist/auto/index.js +139 -3
- package/dist/auto/index.js.map +1 -1
- package/dist/{chunk-BFC27F2G.js → chunk-6P4P7NU6.js} +2 -218
- package/dist/chunk-6P4P7NU6.js.map +1 -0
- package/dist/chunk-CU6SXW3E.js +20334 -0
- package/dist/chunk-CU6SXW3E.js.map +1 -0
- package/dist/{chunk-XDWBVFHQ.js → chunk-EY4BJKC4.js} +1203 -29
- package/dist/chunk-EY4BJKC4.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/attachment.css +266 -0
- package/dist/css/components/breadcrumb.css +110 -0
- package/dist/css/components/calendar.css +159 -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 +591 -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 +232 -0
- package/dist/css/components/hold-confirm.css +87 -0
- package/dist/css/components/hover-card.css +20 -0
- package/dist/css/components/image-preview.css +195 -0
- package/dist/css/components/input-otp.css +10 -0
- package/dist/css/components/json-viewer.css +272 -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/notification-bell.css +127 -0
- package/dist/css/components/pagination.css +11 -0
- package/dist/css/components/password-strength.css +183 -0
- package/dist/css/components/popover.css +25 -0
- package/dist/css/components/progress.css +140 -0
- package/dist/css/components/quantity.css +16 -0
- package/dist/css/components/questionnaire.css +217 -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/scratch-card.css +75 -0
- package/dist/css/components/skeleton.css +108 -0
- package/dist/css/components/slot-picker.css +126 -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/studio-dock.css +35 -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/tooltip.css +79 -0
- package/dist/css/components/trailer.css +37 -0
- package/dist/css/components/tree-view.css +210 -0
- package/dist/css/components/virtual-list.css +195 -0
- package/dist/css/controls.css +65 -0
- package/dist/css/tokens.css +185 -181
- package/dist/elements/index.d.ts +742 -5
- package/dist/elements/index.js +1527 -8
- package/dist/elements/index.js.map +1 -1
- package/dist/{engine-GDGwQnJE.d.ts → engine-Cn6IhE3z.d.ts} +1 -1
- package/dist/engine-QECQnGz1.d.ts +33 -0
- package/dist/index.css +10113 -181
- package/dist/index.d.ts +89 -5
- package/dist/index.js +285 -9
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +678 -23
- package/dist/react/index.js +2389 -7
- package/dist/react/index.js.map +1 -1
- package/dist/{reduced-B98f8LPs.d.ts → reduced-BBUusld6.d.ts} +206 -2
- package/dist/reveal-DEvp6U6T.d.ts +2381 -0
- package/dist/{store-pHiUvxP8.d.ts → store-DjkTBX7f.d.ts} +2 -2
- package/package.json +1 -1
- package/registry.json +583 -104
- package/skills/motion-kit/SKILL.md +209 -189
- package/src/auto/auto-init.ts +136 -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/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/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/calendar/README.md +82 -0
- package/src/components/calendar/calendar.css +158 -0
- package/src/components/calendar/element.ts +27 -0
- package/src/components/calendar/engine.ts +412 -0
- package/src/components/calendar/react.tsx +69 -0
- package/src/components/chart/README.md +24 -0
- package/src/components/chart/chart.css +295 -0
- package/src/components/chart/element.ts +41 -0
- package/src/components/chart/engine.ts +811 -0
- package/src/components/chart/react.tsx +50 -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 +590 -0
- package/src/components/data-table/element.ts +54 -0
- package/src/components/data-table/engine.ts +1059 -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 +775 -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 +365 -0
- package/src/components/filter-builder/filter-builder.css +231 -0
- package/src/components/filter-builder/react.tsx +36 -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 +20 -0
- package/src/components/hover-card/element.ts +8 -0
- package/src/components/hover-card/engine.ts +131 -0
- package/src/components/hover-card/hover-card.css +19 -0
- package/src/components/hover-card/react.tsx +19 -0
- 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 +325 -0
- package/src/components/image-preview/image-preview.css +194 -0
- package/src/components/image-preview/react.tsx +43 -0
- package/src/components/input-otp/README.md +18 -0
- package/src/components/input-otp/element.ts +14 -0
- package/src/components/input-otp/engine.ts +106 -0
- package/src/components/input-otp/input-otp.css +9 -0
- package/src/components/input-otp/react.tsx +21 -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 +440 -0
- package/src/components/json-viewer/json-viewer.css +271 -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/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/pagination/README.md +17 -0
- package/src/components/pagination/element.ts +14 -0
- package/src/components/pagination/engine.ts +102 -0
- package/src/components/pagination/pagination.css +10 -0
- package/src/components/pagination/react.tsx +22 -0
- 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/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/quantity/README.md +20 -0
- package/src/components/quantity/element.ts +14 -0
- package/src/components/quantity/engine.ts +85 -0
- package/src/components/quantity/quantity.css +15 -0
- package/src/components/quantity/react.tsx +21 -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/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/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/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/slot-picker/README.md +68 -0
- package/src/components/slot-picker/element.ts +27 -0
- package/src/components/slot-picker/engine.ts +412 -0
- package/src/components/slot-picker/react.tsx +76 -0
- package/src/components/slot-picker/slot-picker.css +125 -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/studio-dock/README.md +44 -0
- package/src/components/studio-dock/element.ts +11 -0
- package/src/components/studio-dock/engine.ts +212 -0
- package/src/components/studio-dock/react.tsx +23 -0
- package/src/components/studio-dock/studio-dock.css +34 -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/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/trailer/README.md +28 -0
- package/src/components/trailer/element.ts +13 -0
- package/src/components/trailer/engine.ts +189 -0
- package/src/components/trailer/react.tsx +16 -0
- package/src/components/trailer/trailer.css +36 -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 +569 -0
- package/src/components/tree-view/react.tsx +78 -0
- package/src/components/tree-view/tree-view.css +209 -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/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 +108 -0
- 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/controls/README.md +14 -0
- package/src/css/controls/status.css +63 -0
- package/src/css/tokens.css +186 -182
- package/src/elements/index.ts +171 -0
- package/src/index.ts +97 -0
- 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 +78 -0
- package/src/react/use-action-button.ts +6 -0
- package/src/react/use-editorial-reveal.ts +7 -0
- package/src/react/use-film-hero.ts +6 -0
- package/src/react/use-font-cycle.ts +7 -0
- package/src/react/use-image-zoom.ts +5 -0
- package/src/react/use-joined-cta.ts +5 -0
- package/src/react/use-local-clock.ts +5 -0
- package/src/react/use-scroll-dock.ts +5 -0
- package/src/react/use-sticker.ts +5 -0
- package/src/react/use-studio-dock.ts +8 -0
- package/src/react/use-thumbnail-nav.ts +7 -0
- package/src/react/use-trailer.ts +6 -0
- package/src/react/use-weight-hover.ts +5 -0
- package/src/recipes/action-button/README.md +31 -0
- package/src/recipes/action-button/action-button.css +113 -0
- package/src/recipes/action-button/create-action-button.ts +56 -0
- package/src/recipes/editorial-reveal/README.md +35 -0
- package/src/recipes/editorial-reveal/create-editorial-reveal.ts +91 -0
- package/src/recipes/editorial-reveal/editorial-reveal.css +17 -0
- package/src/recipes/film-hero/README.md +23 -0
- package/src/recipes/film-hero/create-film-hero.ts +65 -0
- package/src/recipes/film-hero/film-hero.css +29 -0
- package/src/recipes/font-cycle/README.md +11 -0
- package/src/recipes/font-cycle/create-font-cycle.ts +126 -0
- package/src/recipes/font-cycle/font-cycle.css +36 -0
- package/src/recipes/image-zoom/README.md +16 -0
- package/src/recipes/image-zoom/create-image-zoom.ts +27 -0
- package/src/recipes/image-zoom/image-zoom.css +7 -0
- package/src/recipes/joined-cta/README.md +13 -0
- package/src/recipes/joined-cta/create-joined-cta.ts +22 -0
- package/src/recipes/joined-cta/joined-cta.css +17 -0
- package/src/recipes/local-clock/README.md +31 -0
- package/src/recipes/local-clock/create-local-clock.ts +61 -0
- package/src/recipes/scroll-dock/README.md +46 -0
- package/src/recipes/scroll-dock/create-scroll-dock.ts +72 -0
- package/src/recipes/scroll-dock/scroll-dock.css +70 -0
- package/src/recipes/sticker/README.md +59 -0
- package/src/recipes/sticker/create-sticker.ts +490 -0
- package/src/recipes/sticker/sticker.css +112 -0
- package/src/recipes/thumbnail-nav/README.md +16 -0
- package/src/recipes/thumbnail-nav/create-thumbnail-nav.ts +165 -0
- package/src/recipes/thumbnail-nav/thumbnail-nav.css +108 -0
- package/src/recipes/weight-hover/README.md +37 -0
- package/src/recipes/weight-hover/create-weight-hover.ts +136 -0
- package/src/recipes/weight-hover/weight-hover.css +7 -0
- package/dist/chunk-BFC27F2G.js.map +0 -1
- package/dist/chunk-J6OCFNGU.js +0 -177
- package/dist/chunk-J6OCFNGU.js.map +0 -1
- package/dist/chunk-JQMJQSXD.js +0 -2374
- package/dist/chunk-JQMJQSXD.js.map +0 -1
- package/dist/chunk-XDWBVFHQ.js.map +0 -1
- package/dist/reveal-C0hCDcB_.d.ts +0 -415
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { CustomEase, gsap, registerMotion } from '../../core/gsap';
|
|
2
|
+
import { reduced } from '../../core/reduced';
|
|
3
|
+
import { createScope } from '../../core/scope';
|
|
4
|
+
import { inert, type Instance } from '../../core/types';
|
|
5
|
+
import {
|
|
6
|
+
addDays, addMonths, capitalize, clampFirstDay, dayKey, monthWeeks, safeFormat, sameDay, sameMonth,
|
|
7
|
+
fromJson, startOfWeek, toDate, weekdayNames, type DateInput,
|
|
8
|
+
} from '../../core/dates';
|
|
9
|
+
import { flowIn } from '../../motion/flow';
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Slot picker (Melon Mind "Agendar cita"): a compact month on one side and the
|
|
13
|
+
* day's times on the other. From the reference: changing day slides the times
|
|
14
|
+
* out −30 px and the new ones in from +30 px, .25 s ease-out (view transition
|
|
15
|
+
* "time-slot", schedulePicker.css); the first list grows in (scale .7, blur 32,
|
|
16
|
+
* .3 s cubic-bezier(.38,.49,0,1.1)); the day heading opens 0 → 56 px in .5 s
|
|
17
|
+
* cubic-bezier(.38,.49,0,1.4) and a picked time lights up in .7 s
|
|
18
|
+
* (animation-highlight-1). Month changes slide the days the same way.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export type SlotSource = string[] | Record<string, string[]> | ((date: Date) => string[] | Promise<string[]>);
|
|
22
|
+
|
|
23
|
+
export interface SlotValue { date: Date; time: string; key: string; value: string }
|
|
24
|
+
|
|
25
|
+
export interface SlotPickerLabels {
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
empty?: string;
|
|
28
|
+
loading?: string;
|
|
29
|
+
heading?: (date: Date) => string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SlotPickerOptions {
|
|
33
|
+
/** Month shown first (and the selected day when `value` is not given). */
|
|
34
|
+
date?: DateInput;
|
|
35
|
+
/** Initial value: "2026-10-23T10:30" or { date, time }. */
|
|
36
|
+
value?: string | { date: DateInput; time: string } | null;
|
|
37
|
+
slots?: SlotSource;
|
|
38
|
+
min?: DateInput;
|
|
39
|
+
max?: DateInput;
|
|
40
|
+
/** Weekdays never available (0 = Sunday). */
|
|
41
|
+
closedDays?: number[];
|
|
42
|
+
isDisabled?: (date: Date) => boolean;
|
|
43
|
+
firstDay?: number;
|
|
44
|
+
locale?: string;
|
|
45
|
+
labels?: SlotPickerLabels;
|
|
46
|
+
onChange?: (value: SlotValue) => void;
|
|
47
|
+
onDateChange?: (date: Date) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface SlotPickerInstance extends Instance {
|
|
51
|
+
selectDate(date: DateInput): void;
|
|
52
|
+
selectTime(time: string | null): void;
|
|
53
|
+
setSlots(slots: SlotSource): void;
|
|
54
|
+
readonly date: Date | null;
|
|
55
|
+
readonly time: string | null;
|
|
56
|
+
readonly value: string | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const SLIDE = 30;
|
|
60
|
+
const SLIDE_DURATION = 0.25;
|
|
61
|
+
let slotEaseReady = false;
|
|
62
|
+
|
|
63
|
+
export function createSlotPicker(root: HTMLElement | null, options: SlotPickerOptions = {}): SlotPickerInstance {
|
|
64
|
+
const daysHost = root?.querySelector<HTMLElement>('[data-mk-slot-days]');
|
|
65
|
+
const timesHost = root?.querySelector<HTMLElement>('[data-mk-slot-times]');
|
|
66
|
+
if (!root || !daysHost || !timesHost) {
|
|
67
|
+
return inert({ selectDate() {}, selectTime() {}, setSlots() {}, date: null, time: null, value: null });
|
|
68
|
+
}
|
|
69
|
+
registerMotion();
|
|
70
|
+
if (!slotEaseReady && typeof window !== 'undefined') {
|
|
71
|
+
CustomEase.create('mk-slot-in', '.38,.49,0,1.1');
|
|
72
|
+
slotEaseReady = true;
|
|
73
|
+
}
|
|
74
|
+
const scope = createScope();
|
|
75
|
+
const ctx = gsap.context(() => {});
|
|
76
|
+
scope.add(() => ctx.revert());
|
|
77
|
+
const locale = options.locale ?? 'es';
|
|
78
|
+
const firstDay = clampFirstDay(options.firstDay);
|
|
79
|
+
const labels = {
|
|
80
|
+
placeholder: options.labels?.placeholder ?? 'Elige un día para ver los horarios.',
|
|
81
|
+
empty: options.labels?.empty ?? 'No hay horarios este día.',
|
|
82
|
+
loading: options.labels?.loading ?? 'Cargando horarios…',
|
|
83
|
+
heading: options.labels?.heading ?? ((d: Date) => capitalize(safeFormat(locale, { weekday: 'long', day: 'numeric', month: 'long' }).format(d))),
|
|
84
|
+
};
|
|
85
|
+
const min = options.min !== undefined ? toDate(options.min) : null;
|
|
86
|
+
const max = options.max !== undefined ? toDate(options.max) : null;
|
|
87
|
+
const closedList = fromJson<number[]>(options.closedDays);
|
|
88
|
+
const closed = new Set((Array.isArray(closedList) ? closedList : []).filter((n) => Number.isInteger(n)));
|
|
89
|
+
let slots: SlotSource = fromJson<SlotSource>(options.slots) ?? [];
|
|
90
|
+
|
|
91
|
+
const initial = (() => {
|
|
92
|
+
const v = options.value;
|
|
93
|
+
if (typeof v === 'string') {
|
|
94
|
+
const match = /^(\d{4}-\d{2}-\d{2})(?:T(\d{1,2}:\d{2}))?/.exec(v);
|
|
95
|
+
return match ? { date: toDate(match[1]), time: match[2] ?? null } : null;
|
|
96
|
+
}
|
|
97
|
+
return v ? { date: toDate(v.date), time: v.time ?? null } : null;
|
|
98
|
+
})();
|
|
99
|
+
let month = initial?.date ?? toDate(options.date);
|
|
100
|
+
let date: Date | null = initial?.date ?? (options.date !== undefined ? toDate(options.date) : null);
|
|
101
|
+
let time: string | null = initial?.time ?? null;
|
|
102
|
+
let focusDay = date ?? month;
|
|
103
|
+
let times: string[] = [];
|
|
104
|
+
let request = 0;
|
|
105
|
+
|
|
106
|
+
const title = root.querySelector<HTMLElement>('[data-mk-slot-title]');
|
|
107
|
+
const heading = root.querySelector<HTMLElement>('[data-mk-slot-heading]');
|
|
108
|
+
const prev = root.querySelector<HTMLButtonElement>('[data-mk-slot-prev]');
|
|
109
|
+
const next = root.querySelector<HTMLButtonElement>('[data-mk-slot-next]');
|
|
110
|
+
const output = root.querySelector<HTMLInputElement>('[data-mk-slot-value]');
|
|
111
|
+
const originals = [daysHost, timesHost, title, heading].filter(Boolean).map((el) => [el!, [...el!.childNodes]] as const);
|
|
112
|
+
scope.add(() => originals.forEach(([el, nodes]) => el.replaceChildren(...nodes)));
|
|
113
|
+
if (output) {
|
|
114
|
+
const before = output.value;
|
|
115
|
+
scope.add(() => { output.value = before; });
|
|
116
|
+
}
|
|
117
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
118
|
+
scope.attr(daysHost, 'role', 'grid');
|
|
119
|
+
scope.attr(timesHost, 'role', 'radiogroup');
|
|
120
|
+
if (heading) {
|
|
121
|
+
if (!heading.id) scope.attr(heading, 'id', `mk-slot-${Math.random().toString(36).slice(2, 8)}`);
|
|
122
|
+
scope.attr(timesHost, 'aria-labelledby', heading.id);
|
|
123
|
+
}
|
|
124
|
+
if (title) {
|
|
125
|
+
if (!title.id) scope.attr(title, 'id', `mk-slot-month-${Math.random().toString(36).slice(2, 8)}`);
|
|
126
|
+
scope.attr(daysHost, 'aria-labelledby', title.id);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const monthTitle = safeFormat(locale, { month: 'long', year: 'numeric' });
|
|
130
|
+
const fullDay = safeFormat(locale, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
|
|
131
|
+
const disabled = (d: Date) => (min && d < min) || (max && d > max) || closed.has(d.getDay()) || !!options.isDisabled?.(d);
|
|
132
|
+
|
|
133
|
+
/* ── Days ───────────────────────────────────────────── */
|
|
134
|
+
let daysBody: HTMLElement | null = null;
|
|
135
|
+
const leaving = new Set<HTMLElement>();
|
|
136
|
+
scope.add(() => leaving.forEach((el) => el.remove()));
|
|
137
|
+
const buildDays = () => {
|
|
138
|
+
const wrap = document.createElement('div');
|
|
139
|
+
wrap.className = 'mk-slot-picker__days';
|
|
140
|
+
wrap.setAttribute('role', 'rowgroup');
|
|
141
|
+
const head = document.createElement('div');
|
|
142
|
+
head.className = 'mk-slot-picker__weekdays';
|
|
143
|
+
head.setAttribute('role', 'row');
|
|
144
|
+
for (const name of weekdayNames(locale, firstDay, 'short')) {
|
|
145
|
+
const cell = document.createElement('span');
|
|
146
|
+
cell.setAttribute('role', 'columnheader');
|
|
147
|
+
cell.textContent = name.slice(0, 2);
|
|
148
|
+
head.append(cell);
|
|
149
|
+
}
|
|
150
|
+
wrap.append(head);
|
|
151
|
+
const focusKey = dayKey(focusDay);
|
|
152
|
+
for (const week of monthWeeks(month, firstDay)) {
|
|
153
|
+
const row = document.createElement('div');
|
|
154
|
+
row.className = 'mk-slot-picker__week';
|
|
155
|
+
row.setAttribute('role', 'row');
|
|
156
|
+
for (const d of week) {
|
|
157
|
+
const cell = document.createElement('span');
|
|
158
|
+
cell.setAttribute('role', 'gridcell');
|
|
159
|
+
if (!sameMonth(d, month)) {
|
|
160
|
+
row.append(cell);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const button = document.createElement('button');
|
|
164
|
+
button.type = 'button';
|
|
165
|
+
button.className = 'mk-slot-picker__day';
|
|
166
|
+
button.dataset.mkSlotDay = dayKey(d);
|
|
167
|
+
button.textContent = String(d.getDate());
|
|
168
|
+
button.tabIndex = dayKey(d) === focusKey ? 0 : -1;
|
|
169
|
+
button.setAttribute('aria-label', capitalize(fullDay.format(d)));
|
|
170
|
+
if (disabled(d)) button.disabled = true;
|
|
171
|
+
if (sameDay(d, new Date())) button.setAttribute('aria-current', 'date');
|
|
172
|
+
cell.setAttribute('aria-selected', String(sameDay(d, date)));
|
|
173
|
+
cell.append(button);
|
|
174
|
+
row.append(cell);
|
|
175
|
+
}
|
|
176
|
+
wrap.append(row);
|
|
177
|
+
}
|
|
178
|
+
return wrap;
|
|
179
|
+
};
|
|
180
|
+
const renderDays = (direction: number) => {
|
|
181
|
+
const fresh = buildDays();
|
|
182
|
+
if (title) title.textContent = capitalize(monthTitle.format(month));
|
|
183
|
+
// No earlier month when its last day is before `min`; no later one when its first day is after `max`.
|
|
184
|
+
if (prev) scope.attr(prev, 'disabled', min && new Date(month.getFullYear(), month.getMonth(), 0) < min ? '' : null);
|
|
185
|
+
if (next) scope.attr(next, 'disabled', max && new Date(month.getFullYear(), month.getMonth() + 1, 1) > max ? '' : null);
|
|
186
|
+
if (daysBody && direction && !reduced()) {
|
|
187
|
+
const old = daysBody;
|
|
188
|
+
old.style.top = `${old.offsetTop}px`;
|
|
189
|
+
old.classList.add('mk-slot-picker__leaving');
|
|
190
|
+
old.setAttribute('aria-hidden', 'true');
|
|
191
|
+
leaving.add(old);
|
|
192
|
+
daysHost.append(fresh);
|
|
193
|
+
ctx.add(() => {
|
|
194
|
+
gsap.to(old, { x: -SLIDE * direction, opacity: 0, duration: SLIDE_DURATION, ease: 'power1.out', onComplete: () => { old.remove(); leaving.delete(old); } });
|
|
195
|
+
gsap.fromTo(fresh, { x: SLIDE * direction, opacity: 0 }, { x: 0, opacity: 1, duration: SLIDE_DURATION, ease: 'power1.out', clearProps: 'transform,opacity' });
|
|
196
|
+
});
|
|
197
|
+
} else if (daysBody) daysBody.replaceWith(fresh);
|
|
198
|
+
else daysHost.replaceChildren(fresh);
|
|
199
|
+
daysBody = fresh;
|
|
200
|
+
};
|
|
201
|
+
const dayButton = (d: Date) => daysHost.querySelector<HTMLButtonElement>(`.mk-slot-picker__days:not(.mk-slot-picker__leaving) [data-mk-slot-day="${dayKey(d)}"]`);
|
|
202
|
+
const moveFocus = (to: Date, focus: boolean) => {
|
|
203
|
+
focusDay = to;
|
|
204
|
+
if (!sameMonth(to, month)) {
|
|
205
|
+
const direction = to > month ? 1 : -1;
|
|
206
|
+
month = to;
|
|
207
|
+
renderDays(direction);
|
|
208
|
+
} else daysHost.querySelectorAll<HTMLButtonElement>('[data-mk-slot-day]').forEach((b) => (b.tabIndex = b.dataset.mkSlotDay === dayKey(to) ? 0 : -1));
|
|
209
|
+
if (focus) dayButton(to)?.focus();
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
/* ── Times ──────────────────────────────────────────── */
|
|
213
|
+
let timesBody: HTMLElement | null = null;
|
|
214
|
+
let firstList = true;
|
|
215
|
+
const buildTimes = (state: 'placeholder' | 'loading' | 'ready') => {
|
|
216
|
+
const wrap = document.createElement('div');
|
|
217
|
+
wrap.className = 'mk-slot-picker__list';
|
|
218
|
+
if (state !== 'ready' || !times.length) {
|
|
219
|
+
const note = document.createElement('p');
|
|
220
|
+
note.className = 'mk-slot-picker__note';
|
|
221
|
+
note.textContent = state === 'placeholder' ? labels.placeholder : state === 'loading' ? labels.loading : labels.empty;
|
|
222
|
+
wrap.append(note);
|
|
223
|
+
return wrap;
|
|
224
|
+
}
|
|
225
|
+
const focusTime = time && times.includes(time) ? time : times[0];
|
|
226
|
+
for (const t of times) {
|
|
227
|
+
const button = document.createElement('button');
|
|
228
|
+
button.type = 'button';
|
|
229
|
+
button.className = 'mk-slot-picker__time';
|
|
230
|
+
button.setAttribute('role', 'radio');
|
|
231
|
+
button.dataset.mkSlotTime = t;
|
|
232
|
+
button.textContent = t;
|
|
233
|
+
button.setAttribute('aria-checked', String(t === time));
|
|
234
|
+
button.tabIndex = t === focusTime ? 0 : -1;
|
|
235
|
+
wrap.append(button);
|
|
236
|
+
}
|
|
237
|
+
return wrap;
|
|
238
|
+
};
|
|
239
|
+
const renderTimes = (state: 'placeholder' | 'loading' | 'ready', direction: number) => {
|
|
240
|
+
const fresh = buildTimes(state);
|
|
241
|
+
scope.attr(timesHost, 'aria-busy', state === 'loading' ? 'true' : null);
|
|
242
|
+
const motion = !reduced();
|
|
243
|
+
if (timesBody && direction && motion) {
|
|
244
|
+
const old = timesBody;
|
|
245
|
+
old.style.top = `${old.offsetTop}px`;
|
|
246
|
+
old.classList.add('mk-slot-picker__leaving');
|
|
247
|
+
old.setAttribute('aria-hidden', 'true');
|
|
248
|
+
old.querySelectorAll('button').forEach((b) => (b.tabIndex = -1));
|
|
249
|
+
leaving.add(old);
|
|
250
|
+
timesHost.append(fresh);
|
|
251
|
+
ctx.add(() => {
|
|
252
|
+
gsap.to(old, { x: -SLIDE * direction, opacity: 0, duration: SLIDE_DURATION, ease: 'power1.out', onComplete: () => { old.remove(); leaving.delete(old); } });
|
|
253
|
+
gsap.fromTo(fresh, { x: SLIDE * direction, opacity: 0 }, { x: 0, opacity: 1, duration: SLIDE_DURATION, ease: 'power1.out', clearProps: 'transform,opacity' });
|
|
254
|
+
});
|
|
255
|
+
} else if (timesBody) timesBody.replaceWith(fresh);
|
|
256
|
+
else timesHost.replaceChildren(fresh);
|
|
257
|
+
timesBody = fresh;
|
|
258
|
+
if (state === 'ready' && times.length && motion && firstList) {
|
|
259
|
+
firstList = false;
|
|
260
|
+
ctx.add(() => flowIn(fresh, { target: '.mk-slot-picker__time', style: 2, startScale: 0.7, blur: 32, duration: 0.3, stagger: 0.02, ease: 'mk-slot-in' }));
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
const resolve = (d: Date): string[] | Promise<string[]> => {
|
|
264
|
+
const source = slots;
|
|
265
|
+
if (Array.isArray(source)) return source;
|
|
266
|
+
if (typeof source === 'function') return source(d);
|
|
267
|
+
return source?.[dayKey(d)] ?? [];
|
|
268
|
+
};
|
|
269
|
+
const clean = (list: unknown) => (Array.isArray(list) ? [...new Set(list.filter((t): t is string => typeof t === 'string' && /^\d{1,2}:\d{2}$/.test(t)))] : []);
|
|
270
|
+
const load = (direction: number) => {
|
|
271
|
+
if (!date) {
|
|
272
|
+
times = [];
|
|
273
|
+
renderTimes('placeholder', 0);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const mine = ++request;
|
|
277
|
+
let result: string[] | Promise<string[]>;
|
|
278
|
+
try {
|
|
279
|
+
result = resolve(date);
|
|
280
|
+
} catch {
|
|
281
|
+
result = [];
|
|
282
|
+
}
|
|
283
|
+
if (result && typeof (result as Promise<string[]>).then === 'function') {
|
|
284
|
+
renderTimes('loading', direction);
|
|
285
|
+
(result as Promise<string[]>).then(
|
|
286
|
+
(list) => { if (mine === request && !scope.disposed) { times = clean(list); renderTimes('ready', 0); } },
|
|
287
|
+
() => { if (mine === request && !scope.disposed) { times = []; renderTimes('ready', 0); } },
|
|
288
|
+
);
|
|
289
|
+
} else {
|
|
290
|
+
times = clean(result);
|
|
291
|
+
if (time && !times.includes(time)) time = null;
|
|
292
|
+
renderTimes('ready', direction);
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const syncHeading = () => {
|
|
297
|
+
if (!heading) return;
|
|
298
|
+
if (date) {
|
|
299
|
+
heading.textContent = labels.heading(date);
|
|
300
|
+
if (!heading.hasAttribute('data-mk-shown')) scope.attr(heading, 'data-mk-shown', '');
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
const emit = () => {
|
|
304
|
+
const key = date ? dayKey(date) : '';
|
|
305
|
+
const value = date && time ? `${key}T${time}` : null;
|
|
306
|
+
if (output) {
|
|
307
|
+
output.value = value ?? '';
|
|
308
|
+
output.dispatchEvent(new Event('input', { bubbles: true }));
|
|
309
|
+
output.dispatchEvent(new Event('change', { bubbles: true }));
|
|
310
|
+
}
|
|
311
|
+
if (date && time && value) {
|
|
312
|
+
const detail: SlotValue = { date, time, key, value };
|
|
313
|
+
options.onChange?.(detail);
|
|
314
|
+
root.dispatchEvent(new CustomEvent('mk:change', { bubbles: true, detail }));
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const selectDate = (input: DateInput, notify = true) => {
|
|
319
|
+
if (scope.disposed) return;
|
|
320
|
+
const d = toDate(input);
|
|
321
|
+
if (disabled(d)) return;
|
|
322
|
+
const direction = date ? Math.sign(d.getTime() - date.getTime()) : 0;
|
|
323
|
+
if (sameDay(d, date)) return;
|
|
324
|
+
date = d;
|
|
325
|
+
time = null;
|
|
326
|
+
focusDay = d;
|
|
327
|
+
if (!sameMonth(d, month)) {
|
|
328
|
+
const dir = d > month ? 1 : -1;
|
|
329
|
+
month = d;
|
|
330
|
+
renderDays(dir);
|
|
331
|
+
}
|
|
332
|
+
daysHost.querySelectorAll<HTMLElement>('[role="gridcell"]').forEach((cell) => {
|
|
333
|
+
const b = cell.querySelector<HTMLButtonElement>('[data-mk-slot-day]');
|
|
334
|
+
if (b) {
|
|
335
|
+
cell.setAttribute('aria-selected', String(b.dataset.mkSlotDay === dayKey(d)));
|
|
336
|
+
b.tabIndex = b.dataset.mkSlotDay === dayKey(d) ? 0 : -1;
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
syncHeading();
|
|
340
|
+
load(direction);
|
|
341
|
+
if (notify) {
|
|
342
|
+
options.onDateChange?.(d);
|
|
343
|
+
emit();
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const selectTime = (t: string | null, notify = true) => {
|
|
347
|
+
if (scope.disposed || !date) return;
|
|
348
|
+
if (t !== null && !times.includes(t)) return;
|
|
349
|
+
time = t;
|
|
350
|
+
timesHost.querySelectorAll<HTMLButtonElement>('[data-mk-slot-time]').forEach((b) => {
|
|
351
|
+
b.setAttribute('aria-checked', String(b.dataset.mkSlotTime === t));
|
|
352
|
+
b.tabIndex = (t ? b.dataset.mkSlotTime === t : b === timesHost.querySelector('[data-mk-slot-time]')) ? 0 : -1;
|
|
353
|
+
});
|
|
354
|
+
if (notify) emit();
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
scope.on(root, 'click', (e) => {
|
|
358
|
+
const target = (e.target as Element).closest<HTMLButtonElement>('button');
|
|
359
|
+
if (!target || target.disabled || !root.contains(target)) return;
|
|
360
|
+
if (target === prev) moveFocus(addMonths(month, -1), false);
|
|
361
|
+
else if (target === next) moveFocus(addMonths(month, 1), false);
|
|
362
|
+
else if (target.dataset.mkSlotDay) selectDate(target.dataset.mkSlotDay);
|
|
363
|
+
else if (target.dataset.mkSlotTime) selectTime(target.dataset.mkSlotTime);
|
|
364
|
+
});
|
|
365
|
+
scope.on(daysHost, 'keydown', (e) => {
|
|
366
|
+
const event = e as KeyboardEvent;
|
|
367
|
+
const key = (event.target as HTMLElement).dataset?.mkSlotDay;
|
|
368
|
+
if (!key) return;
|
|
369
|
+
const d = toDate(key);
|
|
370
|
+
const to = ({
|
|
371
|
+
ArrowLeft: () => addDays(d, -1), ArrowRight: () => addDays(d, 1), ArrowUp: () => addDays(d, -7), ArrowDown: () => addDays(d, 7),
|
|
372
|
+
Home: () => startOfWeek(d, firstDay), End: () => addDays(startOfWeek(d, firstDay), 6),
|
|
373
|
+
PageUp: () => addMonths(d, -1), PageDown: () => addMonths(d, 1),
|
|
374
|
+
} as Record<string, () => Date>)[event.key]?.();
|
|
375
|
+
if (!to) return;
|
|
376
|
+
event.preventDefault();
|
|
377
|
+
moveFocus(to, true);
|
|
378
|
+
});
|
|
379
|
+
scope.on(timesHost, 'keydown', (e) => {
|
|
380
|
+
const event = e as KeyboardEvent;
|
|
381
|
+
const current = (event.target as HTMLElement).dataset?.mkSlotTime;
|
|
382
|
+
if (!current) return;
|
|
383
|
+
const i = times.indexOf(current);
|
|
384
|
+
const to = ({ ArrowRight: i + 1, ArrowDown: i + 1, ArrowLeft: i - 1, ArrowUp: i - 1, Home: 0, End: times.length - 1 } as Record<string, number>)[event.key];
|
|
385
|
+
if (to === undefined) return;
|
|
386
|
+
event.preventDefault();
|
|
387
|
+
const t = times[(to + times.length) % times.length];
|
|
388
|
+
selectTime(t);
|
|
389
|
+
timesHost.querySelector<HTMLButtonElement>(`[data-mk-slot-time="${t}"]`)?.focus();
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
renderDays(0);
|
|
393
|
+
if (date) {
|
|
394
|
+
syncHeading();
|
|
395
|
+
load(0);
|
|
396
|
+
if (time && !times.includes(time)) time = null;
|
|
397
|
+
} else renderTimes('placeholder', 0);
|
|
398
|
+
|
|
399
|
+
return {
|
|
400
|
+
selectDate: (d) => selectDate(d),
|
|
401
|
+
selectTime: (t) => selectTime(t),
|
|
402
|
+
setSlots(source) {
|
|
403
|
+
if (scope.disposed) return;
|
|
404
|
+
slots = fromJson<SlotSource>(source) ?? [];
|
|
405
|
+
load(0);
|
|
406
|
+
},
|
|
407
|
+
get date() { return date; },
|
|
408
|
+
get time() { return time; },
|
|
409
|
+
get value() { return date && time ? `${dayKey(date)}T${time}` : null; },
|
|
410
|
+
destroy: () => scope.dispose(),
|
|
411
|
+
};
|
|
412
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useRef, type HTMLAttributes, type ReactNode } from 'react';
|
|
4
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
5
|
+
import { createSlotPicker, type SlotPickerInstance, type SlotPickerOptions } from './engine';
|
|
6
|
+
|
|
7
|
+
export interface SlotPickerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>, SlotPickerOptions {
|
|
8
|
+
/** Form field name: a hidden input carries "YYYY-MM-DDTHH:mm". */
|
|
9
|
+
name?: string;
|
|
10
|
+
labels?: SlotPickerOptions['labels'] & { previous?: string; next?: string };
|
|
11
|
+
/** Rendered under the times (e.g. a submit button). */
|
|
12
|
+
actions?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function SlotPicker({
|
|
16
|
+
date, value, slots, min, max, closedDays, isDisabled, firstDay, locale, labels, onChange, onDateChange,
|
|
17
|
+
name, actions, className, ...props
|
|
18
|
+
}: SlotPickerProps) {
|
|
19
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
20
|
+
const instance = useRef<SlotPickerInstance | null>(null);
|
|
21
|
+
const kept = useRef<string | Date | null>(null);
|
|
22
|
+
const change = useLatest(onChange);
|
|
23
|
+
const dateChange = useLatest(onDateChange);
|
|
24
|
+
const disabledFn = useLatest(isDisabled);
|
|
25
|
+
// A function source is read through a ref (inline functions do not reload);
|
|
26
|
+
// lists and maps reload when their content changes.
|
|
27
|
+
const source = useLatest(slots);
|
|
28
|
+
const slotsKey = typeof slots === 'function' ? 'function' : JSON.stringify(slots ?? []);
|
|
29
|
+
const stable = () => {
|
|
30
|
+
const current = source.current;
|
|
31
|
+
return typeof current === 'function' ? (d: Date) => (source.current as (day: Date) => string[] | Promise<string[]>)(d) : current ?? [];
|
|
32
|
+
};
|
|
33
|
+
useIsomorphicLayoutEffect(() => {
|
|
34
|
+
const keep = kept.current;
|
|
35
|
+
const created = createSlotPicker(ref.current, {
|
|
36
|
+
date: date ?? (keep instanceof Date ? keep : undefined),
|
|
37
|
+
value: value !== undefined ? value : typeof keep === 'string' ? keep : undefined,
|
|
38
|
+
slots: stable(), min, max, closedDays, firstDay, locale, labels,
|
|
39
|
+
isDisabled: (d) => disabledFn.current?.(d) ?? false,
|
|
40
|
+
onChange: (v) => change.current?.(v),
|
|
41
|
+
onDateChange: (d) => dateChange.current?.(d),
|
|
42
|
+
});
|
|
43
|
+
instance.current = created;
|
|
44
|
+
return () => {
|
|
45
|
+
kept.current = created.value ?? created.date;
|
|
46
|
+
created.destroy();
|
|
47
|
+
instance.current = null;
|
|
48
|
+
};
|
|
49
|
+
// `slots` updates in place; the rest recreates the picker.
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
}, [date, value, min, max, firstDay, locale, JSON.stringify(closedDays ?? [])]);
|
|
52
|
+
const firstSlots = useRef(true);
|
|
53
|
+
useIsomorphicLayoutEffect(() => {
|
|
54
|
+
if (firstSlots.current) { firstSlots.current = false; return; }
|
|
55
|
+
instance.current?.setSlots(stable());
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
}, [slotsKey]);
|
|
58
|
+
return (
|
|
59
|
+
<div {...props} ref={ref} className={['mk-slot-picker', className].filter(Boolean).join(' ')}>
|
|
60
|
+
<div className="mk-slot-picker__calendar">
|
|
61
|
+
<div className="mk-slot-picker__month">
|
|
62
|
+
<h3 className="mk-slot-picker__title" data-mk-slot-title />
|
|
63
|
+
<button type="button" className="mk-slot-picker__nav" data-mk-slot-prev aria-label={labels?.previous ?? 'Mes anterior'}>←</button>
|
|
64
|
+
<button type="button" className="mk-slot-picker__nav" data-mk-slot-next aria-label={labels?.next ?? 'Mes siguiente'}>→</button>
|
|
65
|
+
</div>
|
|
66
|
+
<div data-mk-slot-days />
|
|
67
|
+
</div>
|
|
68
|
+
<div className="mk-slot-picker__panel">
|
|
69
|
+
<p className="mk-slot-picker__heading" data-mk-slot-heading />
|
|
70
|
+
<div data-mk-slot-times />
|
|
71
|
+
{name && <input type="hidden" name={name} data-mk-slot-value />}
|
|
72
|
+
{actions && <div className="mk-slot-picker__actions">{actions}</div>}
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/* slot-picker — Melon Mind's appointment picker on the --mk-* tokens; parts are .mk-slot-picker__*. */
|
|
2
|
+
.mk-slot-picker,
|
|
3
|
+
mk-slot-picker {
|
|
4
|
+
--mk-slot-picker-radius: var(--mk-radius-md);
|
|
5
|
+
display: grid;
|
|
6
|
+
grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
border-radius: var(--mk-radius-xl);
|
|
9
|
+
background: var(--mk-surface);
|
|
10
|
+
color: var(--mk-text);
|
|
11
|
+
}
|
|
12
|
+
.mk-slot-picker__calendar { padding: var(--mk-space-5); }
|
|
13
|
+
.mk-slot-picker__panel {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: var(--mk-space-3);
|
|
17
|
+
min-height: 100%;
|
|
18
|
+
padding: var(--mk-space-5);
|
|
19
|
+
background: var(--mk-surface-2);
|
|
20
|
+
}
|
|
21
|
+
.mk-slot-picker__month { display: flex; align-items: center; gap: var(--mk-space-2); margin-bottom: var(--mk-space-3); }
|
|
22
|
+
.mk-slot-picker__title { margin: 0 auto 0 0; font-size: 1.35rem; font-weight: 400; }
|
|
23
|
+
.mk-slot-picker__nav {
|
|
24
|
+
display: grid;
|
|
25
|
+
place-items: center;
|
|
26
|
+
width: 42px;
|
|
27
|
+
height: 42px;
|
|
28
|
+
border: 0;
|
|
29
|
+
border-radius: 50%;
|
|
30
|
+
background: var(--mk-surface-2);
|
|
31
|
+
color: var(--mk-text);
|
|
32
|
+
font: inherit;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
transition: transform 0.3s var(--mk-ease-nav-move), opacity 0.2s;
|
|
35
|
+
}
|
|
36
|
+
.mk-slot-picker__nav:active { transform: scale(0.9); }
|
|
37
|
+
.mk-slot-picker__nav:disabled { opacity: 0.35; cursor: default; }
|
|
38
|
+
[data-mk-slot-days],
|
|
39
|
+
[data-mk-slot-times] { position: relative; }
|
|
40
|
+
.mk-slot-picker__days { display: flex; flex-direction: column; gap: 6px; }
|
|
41
|
+
.mk-slot-picker__weekdays,
|
|
42
|
+
.mk-slot-picker__week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
|
|
43
|
+
.mk-slot-picker__weekdays span {
|
|
44
|
+
padding: 6px 0;
|
|
45
|
+
border-radius: var(--mk-radius-sm);
|
|
46
|
+
background: color-mix(in srgb, var(--mk-surface-2) 70%, transparent);
|
|
47
|
+
text-align: center;
|
|
48
|
+
font-size: 0.9rem;
|
|
49
|
+
}
|
|
50
|
+
.mk-slot-picker__week > [role='gridcell'] { display: grid; }
|
|
51
|
+
.mk-slot-picker__day {
|
|
52
|
+
aspect-ratio: 1.15;
|
|
53
|
+
border: 0;
|
|
54
|
+
border-radius: var(--mk-slot-picker-radius);
|
|
55
|
+
background: var(--mk-surface-3);
|
|
56
|
+
color: var(--mk-text);
|
|
57
|
+
font: inherit;
|
|
58
|
+
font-size: 0.95rem;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
transition: background 0.25s, color 0.25s, border-radius 0.3s var(--mk-ease-nav-radius), transform 0.3s var(--mk-ease-nav-radius);
|
|
61
|
+
}
|
|
62
|
+
.mk-slot-picker__day:hover:not(:disabled) { background: var(--mk-surface-5); border-radius: var(--mk-radius-full); }
|
|
63
|
+
.mk-slot-picker__day:active:not(:disabled) { transform: scale(0.92); }
|
|
64
|
+
.mk-slot-picker__day:disabled { opacity: 0.35; cursor: default; }
|
|
65
|
+
.mk-slot-picker__day[aria-current='date'] { box-shadow: inset 0 0 0 1.5px var(--mk-outline); }
|
|
66
|
+
[aria-selected='true'] > .mk-slot-picker__day,
|
|
67
|
+
[aria-selected='true'] > .mk-slot-picker__day:hover:not(:disabled) { background: var(--mk-accent); color: var(--mk-on-accent); }
|
|
68
|
+
:is(.mk-slot-picker__day, .mk-slot-picker__time, .mk-slot-picker__nav):focus-visible { outline: 2px solid var(--mk-accent); outline-offset: 2px; }
|
|
69
|
+
|
|
70
|
+
.mk-slot-picker__heading {
|
|
71
|
+
margin: 0;
|
|
72
|
+
padding: 8px;
|
|
73
|
+
border-radius: var(--mk-radius-md);
|
|
74
|
+
background: var(--mk-surface);
|
|
75
|
+
font-weight: 600;
|
|
76
|
+
}
|
|
77
|
+
.mk-slot-picker__heading:not([data-mk-shown]) { display: none; }
|
|
78
|
+
.mk-slot-picker__heading[data-mk-shown] { animation: mk-slot-heading-in 0.5s cubic-bezier(0.38, 0.49, 0, 1.4); }
|
|
79
|
+
@keyframes mk-slot-heading-in {
|
|
80
|
+
0% { max-height: 0; min-height: 0; padding-block: 0; opacity: 0; }
|
|
81
|
+
100% { max-height: 56px; min-height: 40px; opacity: 1; }
|
|
82
|
+
}
|
|
83
|
+
.mk-slot-picker__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 8px; align-content: start; }
|
|
84
|
+
.mk-slot-picker__leaving { position: absolute; left: 0; right: 0; pointer-events: none; }
|
|
85
|
+
.mk-slot-picker__note { grid-column: 1 / -1; margin: 2rem 0; color: var(--mk-muted); text-align: center; }
|
|
86
|
+
.mk-slot-picker__time {
|
|
87
|
+
position: relative;
|
|
88
|
+
isolation: isolate;
|
|
89
|
+
height: 44px;
|
|
90
|
+
border: 0;
|
|
91
|
+
border-radius: var(--mk-radius-sm);
|
|
92
|
+
background: var(--mk-surface-4);
|
|
93
|
+
color: var(--mk-text);
|
|
94
|
+
font: inherit;
|
|
95
|
+
font-variant-numeric: tabular-nums;
|
|
96
|
+
cursor: pointer;
|
|
97
|
+
transition: background 0.2s, color 0.2s, transform 0.3s var(--mk-ease-nav-move);
|
|
98
|
+
}
|
|
99
|
+
.mk-slot-picker__time:hover { transform: translateY(-2px); }
|
|
100
|
+
.mk-slot-picker__time[aria-checked='true'] { color: var(--mk-on-accent); }
|
|
101
|
+
.mk-slot-picker__time[aria-checked='true']::before {
|
|
102
|
+
content: '';
|
|
103
|
+
position: absolute;
|
|
104
|
+
inset: 0;
|
|
105
|
+
z-index: -1;
|
|
106
|
+
border-radius: inherit;
|
|
107
|
+
background: var(--mk-accent);
|
|
108
|
+
animation: mk-slot-highlight 0.7s cubic-bezier(0.38, 0.49, 0, 1.1);
|
|
109
|
+
}
|
|
110
|
+
@keyframes mk-slot-highlight {
|
|
111
|
+
0% { transform: scale(0.8); opacity: 0; filter: blur(16px); box-shadow: 0 0 0 1px var(--mk-surface-2); }
|
|
112
|
+
100% { transform: scale(1); opacity: 1; filter: blur(0); }
|
|
113
|
+
}
|
|
114
|
+
.mk-slot-picker__actions { margin-top: auto; display: flex; justify-content: flex-end; }
|
|
115
|
+
|
|
116
|
+
@media (max-width: 680px) {
|
|
117
|
+
.mk-slot-picker,
|
|
118
|
+
mk-slot-picker { grid-template-columns: 1fr; }
|
|
119
|
+
.mk-slot-picker__calendar,
|
|
120
|
+
.mk-slot-picker__panel { padding: var(--mk-space-4); }
|
|
121
|
+
}
|
|
122
|
+
@media (prefers-reduced-motion: reduce) {
|
|
123
|
+
.mk-slot-picker *,
|
|
124
|
+
mk-slot-picker * { transition: none !important; animation: none !important; }
|
|
125
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# split-view
|
|
2
|
+
|
|
3
|
+
Vista dividida en dos áreas con tamaño configurable, lado a lado o una sobre otra. Por dentro usa el divisor de `resizable-panel`: se arrastra (cede como goma en los límites y regresa con un resorte), responde al teclado, cierra un lado de golpe si lo arrastras muy por debajo de su mínimo, y con doble clic vuelve a la proporción inicial. Sus botones cierran cualquiera de los dos lados y lo vuelven a abrir (.3 s, curva swing).
|
|
4
|
+
|
|
5
|
+
`setRatio()` se desliza hasta la proporción pedida (.45 s, curva signature). Con `stackBelow`, cuando la vista es más angosta que esos píxeles, las áreas se apilan y el divisor gira con ellas. La proporción se puede recordar (`storageKey`).
|
|
6
|
+
|
|
7
|
+
## HTML / Astro
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<mk-split-view class="mk-split-view" ratio="0.35" stack-below="640" labels="Bandeja,Mensaje" style="height: 28rem">
|
|
11
|
+
<section>…lista…</section>
|
|
12
|
+
<section>…mensaje…</section>
|
|
13
|
+
</mk-split-view>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## React
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
const split = useRef<SplitViewHandle>(null);
|
|
20
|
+
|
|
21
|
+
<SplitView ref={split} ratio={0.35} stackBelow={640} labels={['Bandeja', 'Mensaje']} onChange={guardar}>
|
|
22
|
+
{[<Bandeja key="bandeja" />, <Mensaje key="mensaje" />]}
|
|
23
|
+
</SplitView>;
|
|
24
|
+
|
|
25
|
+
split.current?.toggle('start');
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Una `ratio` nueva se desliza hasta ahí.
|
|
29
|
+
|
|
30
|
+
## Opciones
|
|
31
|
+
|
|
32
|
+
| Opción | Atributo | Por defecto | Qué hace |
|
|
33
|
+
|---|---|---|---|
|
|
34
|
+
| `orientation` | `orientation` | `'horizontal'` | `'horizontal'`: lado a lado; `'vertical'`: una sobre otra. |
|
|
35
|
+
| `ratio` | `ratio` | `0.5` | Parte de la primera área (0–1). |
|
|
36
|
+
| `min` | `min` | `15` | Tamaño mínimo de cada área, en %. |
|
|
37
|
+
| `collapsible` | `collapsible` | `true` | Qué lados se pueden cerrar: `true` (ambos), `'start'`, `'end'` o `false`. |
|
|
38
|
+
| `stackBelow` | `stack-below` | `0` | Apilar las áreas por debajo de este ancho en px. |
|
|
39
|
+
| `storageKey` | `storage-key` | — | Recordar la proporción en `localStorage`. |
|
|
40
|
+
| `labels` | `labels` | `'Primera área', 'Segunda área'` | Nombres de las áreas (o su `data-label`). |
|
|
41
|
+
| `onChange(ratio)` | — | — | Al terminar un cambio. |
|
|
42
|
+
| `onCollapse(side)` | — | — | `'start'`, `'end'` o `null` al abrirse. |
|
|
43
|
+
|
|
44
|
+
## API
|
|
45
|
+
|
|
46
|
+
`setRatio(ratio, animate = true)`, `collapse('start' | 'end')`, `expand()`, `toggle(side)`, `ratio`, `collapsed`, `orientation`, `destroy()`.
|
|
47
|
+
|
|
48
|
+
## Accesibilidad
|
|
49
|
+
|
|
50
|
+
El divisor es un `separator` de WAI-ARIA con su valor, su texto y una etiqueta con los nombres de las áreas; ← → (o ↑ ↓) lo mueven, Inicio y Fin lo llevan a los límites e Intro cierra o abre la primera área. Un área cerrada queda oculta también para los lectores de pantalla. Con movimiento reducido los cambios son inmediatos.
|