@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,294 @@
|
|
|
1
|
+
import { registerMotion } from '../../core/gsap';
|
|
2
|
+
import { createScope } from '../../core/scope';
|
|
3
|
+
import { inert, type Instance } from '../../core/types';
|
|
4
|
+
import { createChips, type ChipItem } from '../../core/chips';
|
|
5
|
+
import { createListbox, filterOptions, type ListboxOption } from '../../core/listbox';
|
|
6
|
+
import { press, shake } from '../../motion/micro';
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Multi select: a combobox field holding the chosen options as chips and a
|
|
10
|
+
* search input. Typing filters the options (letters in order, accents
|
|
11
|
+
* ignored, the matches marked); the list opens out of the field and its active
|
|
12
|
+
* option is a pill that glides (core/listbox.ts). Enter or a click toggles an
|
|
13
|
+
* option (its check draws itself); chips pop in and fold away
|
|
14
|
+
* (core/chips.ts). Backspace in an empty search arms the last chip (a ring),
|
|
15
|
+
* then removes it; ← reaches the chips. `max` stops further choices (the
|
|
16
|
+
* field shakes and the rest of the options turn off). An authored
|
|
17
|
+
* <select multiple> gives the options and stays in sync, so forms post as
|
|
18
|
+
* usual; otherwise `name` adds hidden inputs.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export interface MultiSelectOption {
|
|
22
|
+
value: string;
|
|
23
|
+
label: string;
|
|
24
|
+
group?: string;
|
|
25
|
+
hint?: string;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface MultiSelectOptions {
|
|
30
|
+
/** The options; without them, an authored <select multiple> gives them. */
|
|
31
|
+
options?: MultiSelectOption[];
|
|
32
|
+
value?: string[];
|
|
33
|
+
/** Search placeholder (default 'Buscar…'). */
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
/** Accessible name (default: the authored <label>, else 'Selección'). */
|
|
36
|
+
label?: string;
|
|
37
|
+
/** Hidden inputs name[] (when there is no authored select). */
|
|
38
|
+
name?: string;
|
|
39
|
+
/** At most this many choices. */
|
|
40
|
+
max?: number;
|
|
41
|
+
/** Close the list after each choice (default false). */
|
|
42
|
+
closeOnSelect?: boolean;
|
|
43
|
+
disabled?: boolean;
|
|
44
|
+
onChange?: (values: string[]) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface MultiSelectInstance extends Instance {
|
|
48
|
+
setValue(values: string[], notify?: boolean): void;
|
|
49
|
+
setOptions(options: MultiSelectOption[]): void;
|
|
50
|
+
open(): void;
|
|
51
|
+
close(): void;
|
|
52
|
+
readonly value: string[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const CHEVRON = '<svg aria-hidden="true" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>';
|
|
56
|
+
const CLEAR = '<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M7 7l10 10M17 7L7 17"/></svg>';
|
|
57
|
+
|
|
58
|
+
const readSelect = (select: HTMLSelectElement): MultiSelectOption[] =>
|
|
59
|
+
[...select.options].map((option) => ({
|
|
60
|
+
value: option.value,
|
|
61
|
+
label: option.label || option.textContent?.trim() || option.value,
|
|
62
|
+
group: option.parentElement instanceof HTMLOptGroupElement ? option.parentElement.label : undefined,
|
|
63
|
+
disabled: option.disabled,
|
|
64
|
+
}));
|
|
65
|
+
|
|
66
|
+
export function createMultiSelect(root: HTMLElement | null, settings: MultiSelectOptions = {}): MultiSelectInstance {
|
|
67
|
+
if (!root) return inert({ setValue() {}, setOptions() {}, open() {}, close() {}, value: [] });
|
|
68
|
+
registerMotion();
|
|
69
|
+
const scope = createScope();
|
|
70
|
+
const select = root.querySelector<HTMLSelectElement>('select[multiple]');
|
|
71
|
+
let all: MultiSelectOption[] = settings.options ?? (select ? readSelect(select) : []);
|
|
72
|
+
const max = Number.isFinite(settings.max) && settings.max! > 0 ? Math.floor(settings.max!) : Infinity;
|
|
73
|
+
const known = (value: string) => all.some((option) => option.value === value);
|
|
74
|
+
let value: string[] = (settings.value ?? (select ? [...select.selectedOptions].map((option) => option.value) : [])).filter(known).slice(0, max);
|
|
75
|
+
const labelText = settings.label ?? root.querySelector('label')?.textContent?.trim() ?? select?.getAttribute('aria-label') ?? 'Selección';
|
|
76
|
+
|
|
77
|
+
if (select) {
|
|
78
|
+
// The native select keeps posting the value; it is synced and out of sight.
|
|
79
|
+
const before = [...select.options].map((option) => option.selected);
|
|
80
|
+
scope.attr(select, 'hidden', '');
|
|
81
|
+
scope.attr(select, 'aria-hidden', 'true');
|
|
82
|
+
scope.attr(select, 'tabindex', '-1');
|
|
83
|
+
scope.add(() => [...select.options].forEach((option, i) => (option.selected = before[i] ?? false)));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const field = document.createElement('div');
|
|
87
|
+
field.dataset.mkMsField = '';
|
|
88
|
+
const chips = createChips({
|
|
89
|
+
disabled: settings.disabled,
|
|
90
|
+
onRemove: (removed) => toggle(removed, false),
|
|
91
|
+
onExit: () => input.focus(),
|
|
92
|
+
});
|
|
93
|
+
scope.add(() => chips.destroy());
|
|
94
|
+
const input = document.createElement('input');
|
|
95
|
+
input.type = 'text';
|
|
96
|
+
input.dataset.mkMsInput = '';
|
|
97
|
+
input.setAttribute('role', 'combobox');
|
|
98
|
+
input.setAttribute('aria-autocomplete', 'list');
|
|
99
|
+
input.setAttribute('aria-label', labelText);
|
|
100
|
+
input.autocomplete = 'off';
|
|
101
|
+
input.spellcheck = false;
|
|
102
|
+
input.placeholder = settings.placeholder ?? 'Buscar…';
|
|
103
|
+
input.disabled = Boolean(settings.disabled);
|
|
104
|
+
const clear = document.createElement('button');
|
|
105
|
+
clear.type = 'button';
|
|
106
|
+
clear.dataset.mkMsClear = '';
|
|
107
|
+
clear.setAttribute('aria-label', 'Quitar todo');
|
|
108
|
+
clear.innerHTML = CLEAR;
|
|
109
|
+
clear.disabled = Boolean(settings.disabled);
|
|
110
|
+
const chevron = document.createElement('span');
|
|
111
|
+
chevron.dataset.mkMsChevron = '';
|
|
112
|
+
chevron.innerHTML = CHEVRON;
|
|
113
|
+
field.append(chips.element, input, clear, chevron);
|
|
114
|
+
const status = document.createElement('span');
|
|
115
|
+
status.className = 'mk-sr-only';
|
|
116
|
+
status.setAttribute('role', 'status');
|
|
117
|
+
const hiddenHost = document.createElement('span');
|
|
118
|
+
hiddenHost.hidden = true;
|
|
119
|
+
root.append(field, status, hiddenHost);
|
|
120
|
+
scope.add(() => {
|
|
121
|
+
field.remove();
|
|
122
|
+
status.remove();
|
|
123
|
+
hiddenHost.remove();
|
|
124
|
+
});
|
|
125
|
+
scope.attr(root, 'data-mk-open', null);
|
|
126
|
+
scope.attr(root, 'data-mk-has-value', null);
|
|
127
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
128
|
+
|
|
129
|
+
const listbox = createListbox({
|
|
130
|
+
input,
|
|
131
|
+
anchor: field,
|
|
132
|
+
host: root,
|
|
133
|
+
multiselectable: true,
|
|
134
|
+
label: labelText,
|
|
135
|
+
isSelected: (option) => value.includes(option),
|
|
136
|
+
onPick: (option) => toggle(option.value, !value.includes(option.value), true),
|
|
137
|
+
});
|
|
138
|
+
scope.add(() => listbox.destroy());
|
|
139
|
+
|
|
140
|
+
const labelOf = (option: string) => all.find((entry) => entry.value === option)?.label ?? option;
|
|
141
|
+
const listed = (): ListboxOption[] => {
|
|
142
|
+
const full = value.length >= max;
|
|
143
|
+
return filterOptions(all, input.value).map((option) => ({ ...option, disabled: option.disabled || (full && !value.includes(option.value)) }));
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const sync = (animate: boolean) => {
|
|
147
|
+
chips.set(value.map((option): ChipItem => ({ value: option, label: labelOf(option) })), animate);
|
|
148
|
+
root.toggleAttribute('data-mk-has-value', value.length > 0);
|
|
149
|
+
input.placeholder = value.length ? '' : (settings.placeholder ?? 'Buscar…');
|
|
150
|
+
if (select) for (const option of select.options) option.selected = value.includes(option.value);
|
|
151
|
+
else if (settings.name) {
|
|
152
|
+
hiddenHost.replaceChildren(
|
|
153
|
+
...value.map((option) => {
|
|
154
|
+
const hidden = document.createElement('input');
|
|
155
|
+
hidden.type = 'hidden';
|
|
156
|
+
hidden.name = `${settings.name}[]`;
|
|
157
|
+
hidden.value = option;
|
|
158
|
+
return hidden;
|
|
159
|
+
}),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (listbox.isOpen) listbox.show(listed(), input.value);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const emit = () => {
|
|
166
|
+
settings.onChange?.([...value]);
|
|
167
|
+
root.dispatchEvent(new CustomEvent('mk:change', { bubbles: true, detail: { value: [...value] } }));
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const toggle = (option: string, on: boolean, fromList = false) => {
|
|
171
|
+
if (settings.disabled || on === value.includes(option)) return;
|
|
172
|
+
if (on && value.length >= max) {
|
|
173
|
+
shake(field);
|
|
174
|
+
status.textContent = `Máximo ${max} ${max === 1 ? 'opción' : 'opciones'}`;
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
value = on ? [...value, option] : value.filter((entry) => entry !== option);
|
|
178
|
+
chips.arm(null);
|
|
179
|
+
sync(true);
|
|
180
|
+
status.textContent = `${labelOf(option)} ${on ? 'añadida' : 'quitada'}. ${value.length} ${value.length === 1 ? 'seleccionada' : 'seleccionadas'}.`;
|
|
181
|
+
if (fromList && input.value) {
|
|
182
|
+
input.value = '';
|
|
183
|
+
listbox.show(listed(), '');
|
|
184
|
+
}
|
|
185
|
+
if (fromList && settings.closeOnSelect) listbox.hide();
|
|
186
|
+
emit();
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const open = () => {
|
|
190
|
+
if (settings.disabled || listbox.isOpen) return;
|
|
191
|
+
root.setAttribute('data-mk-open', '');
|
|
192
|
+
listbox.show(listed(), input.value);
|
|
193
|
+
};
|
|
194
|
+
const close = () => {
|
|
195
|
+
root.removeAttribute('data-mk-open');
|
|
196
|
+
listbox.hide();
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
scope.on(field, 'pointerdown', (event) => {
|
|
200
|
+
const target = event.target as Element | null;
|
|
201
|
+
if (target?.closest('[data-mk-chip-remove], [data-mk-ms-clear]')) return;
|
|
202
|
+
if (target !== input) event.preventDefault();
|
|
203
|
+
input.focus();
|
|
204
|
+
if (listbox.isOpen && target?.closest('[data-mk-ms-chevron]')) close();
|
|
205
|
+
else open();
|
|
206
|
+
});
|
|
207
|
+
scope.on(input, 'input', () => {
|
|
208
|
+
chips.arm(null);
|
|
209
|
+
open();
|
|
210
|
+
listbox.show(listed(), input.value);
|
|
211
|
+
});
|
|
212
|
+
scope.on(input, 'keydown', (event) => {
|
|
213
|
+
const key = event as KeyboardEvent;
|
|
214
|
+
switch (key.key) {
|
|
215
|
+
case 'ArrowDown':
|
|
216
|
+
key.preventDefault();
|
|
217
|
+
if (!listbox.isOpen) open();
|
|
218
|
+
listbox.move(1);
|
|
219
|
+
return;
|
|
220
|
+
case 'ArrowUp':
|
|
221
|
+
key.preventDefault();
|
|
222
|
+
if (!listbox.isOpen) open();
|
|
223
|
+
listbox.move(-1);
|
|
224
|
+
return;
|
|
225
|
+
case 'Home':
|
|
226
|
+
case 'End':
|
|
227
|
+
if (!listbox.isOpen || input.value) return;
|
|
228
|
+
key.preventDefault();
|
|
229
|
+
listbox.move(key.key === 'Home' ? 'first' : 'last');
|
|
230
|
+
return;
|
|
231
|
+
case 'Enter':
|
|
232
|
+
if (listbox.isOpen && listbox.pick()) key.preventDefault();
|
|
233
|
+
return;
|
|
234
|
+
case 'Escape':
|
|
235
|
+
if (listbox.isOpen) {
|
|
236
|
+
key.preventDefault();
|
|
237
|
+
close();
|
|
238
|
+
} else if (input.value) input.value = '';
|
|
239
|
+
return;
|
|
240
|
+
case 'Backspace':
|
|
241
|
+
if (input.value || !value.length) return;
|
|
242
|
+
key.preventDefault();
|
|
243
|
+
if (chips.armed) toggle(chips.armed, false);
|
|
244
|
+
else chips.arm(value[value.length - 1]!);
|
|
245
|
+
return;
|
|
246
|
+
case 'ArrowLeft':
|
|
247
|
+
if (input.selectionStart === 0 && input.selectionEnd === 0 && chips.focusLast()) {
|
|
248
|
+
key.preventDefault();
|
|
249
|
+
close();
|
|
250
|
+
}
|
|
251
|
+
return;
|
|
252
|
+
case 'Tab':
|
|
253
|
+
close();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
scope.on(input, 'blur', () => {
|
|
258
|
+
chips.arm(null);
|
|
259
|
+
// A click on an option keeps the focus (pointerdown is cancelled there); anything else closes.
|
|
260
|
+
close();
|
|
261
|
+
});
|
|
262
|
+
scope.on(clear, 'click', () => {
|
|
263
|
+
if (!value.length) return;
|
|
264
|
+
press(clear);
|
|
265
|
+
value = [];
|
|
266
|
+
sync(true);
|
|
267
|
+
status.textContent = 'Selección vacía';
|
|
268
|
+
input.focus();
|
|
269
|
+
emit();
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
sync(false);
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
setValue(next, notify = false) {
|
|
276
|
+
if (scope.disposed) return;
|
|
277
|
+
value = next.filter(known).slice(0, max);
|
|
278
|
+
sync(true);
|
|
279
|
+
if (notify) emit();
|
|
280
|
+
},
|
|
281
|
+
setOptions(next) {
|
|
282
|
+
if (scope.disposed) return;
|
|
283
|
+
all = [...next];
|
|
284
|
+
value = value.filter(known);
|
|
285
|
+
sync(false);
|
|
286
|
+
},
|
|
287
|
+
open,
|
|
288
|
+
close,
|
|
289
|
+
get value() {
|
|
290
|
+
return [...value];
|
|
291
|
+
},
|
|
292
|
+
destroy: () => scope.dispose(),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/* multi-select — a 12 px field on surface-3 holding 8 px chips and a search input; a chevron that turns when the list
|
|
2
|
+
is open; a clear button when something is chosen. The chips and the listbox rules below are shared with tag-input
|
|
3
|
+
(each stylesheet works alone). */
|
|
4
|
+
.mk-multi-select,
|
|
5
|
+
mk-multi-select {
|
|
6
|
+
display: block;
|
|
7
|
+
min-width: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[data-mk-ms-field] {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 0.35rem;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
min-height: 2.75rem;
|
|
17
|
+
padding: 0.35rem 0.4rem 0.35rem 0.5rem;
|
|
18
|
+
border-radius: 12px;
|
|
19
|
+
background: var(--mk-surface-3);
|
|
20
|
+
color: var(--mk-text);
|
|
21
|
+
cursor: text;
|
|
22
|
+
transition: box-shadow 0.2s ease;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[data-mk-ms-field]:focus-within {
|
|
26
|
+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--mk-accent) 35%, transparent);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[data-mk-ms-input] {
|
|
30
|
+
flex: 1;
|
|
31
|
+
min-width: 6ch;
|
|
32
|
+
height: 1.75rem;
|
|
33
|
+
padding: 0 0.25rem;
|
|
34
|
+
border: 0;
|
|
35
|
+
background: transparent;
|
|
36
|
+
color: inherit;
|
|
37
|
+
font: inherit;
|
|
38
|
+
outline: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[data-mk-ms-input]::placeholder {
|
|
42
|
+
color: var(--mk-muted);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-mk-ms-clear],
|
|
46
|
+
[data-mk-ms-chevron] {
|
|
47
|
+
display: grid;
|
|
48
|
+
flex: none;
|
|
49
|
+
place-items: center;
|
|
50
|
+
width: 1.75rem;
|
|
51
|
+
height: 1.75rem;
|
|
52
|
+
color: var(--mk-muted);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
[data-mk-ms-clear] {
|
|
56
|
+
padding: 0;
|
|
57
|
+
border: 0;
|
|
58
|
+
border-radius: 8px;
|
|
59
|
+
background: transparent;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[data-mk-ms-clear]:hover {
|
|
64
|
+
background: color-mix(in srgb, var(--mk-text) 8%, transparent);
|
|
65
|
+
color: var(--mk-text);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:is(.mk-multi-select, mk-multi-select):not([data-mk-has-value]) [data-mk-ms-clear] {
|
|
69
|
+
display: none;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
[data-mk-ms-chevron] {
|
|
73
|
+
transition: rotate 0.3s cubic-bezier(0.38, 0.49, 0, 1.5);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:is(.mk-multi-select, mk-multi-select)[data-mk-open] [data-mk-ms-chevron] {
|
|
77
|
+
rotate: 180deg;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@media (prefers-reduced-motion: reduce) {
|
|
81
|
+
[data-mk-ms-field],
|
|
82
|
+
[data-mk-ms-chevron] {
|
|
83
|
+
transition: none;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Chips (core/chips.ts): 8 px, accent-soft, a round remove button; the armed one (next Backspace) gets a ring. */
|
|
88
|
+
[data-mk-chips] {
|
|
89
|
+
display: contents;
|
|
90
|
+
margin: 0;
|
|
91
|
+
padding: 0;
|
|
92
|
+
list-style: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[data-mk-chip] {
|
|
96
|
+
display: inline-flex;
|
|
97
|
+
flex: none;
|
|
98
|
+
align-items: center;
|
|
99
|
+
gap: 0.15rem;
|
|
100
|
+
box-sizing: border-box;
|
|
101
|
+
max-width: 100%;
|
|
102
|
+
height: 1.75rem;
|
|
103
|
+
padding: 0 0.2rem 0 0.6rem;
|
|
104
|
+
overflow: hidden;
|
|
105
|
+
border-radius: 8px;
|
|
106
|
+
background: var(--mk-accent-soft);
|
|
107
|
+
color: var(--mk-on-accent-soft, var(--mk-text));
|
|
108
|
+
font-size: 0.8125rem;
|
|
109
|
+
font-weight: 500;
|
|
110
|
+
white-space: nowrap;
|
|
111
|
+
outline: none;
|
|
112
|
+
transition: box-shadow 0.2s ease;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
[data-mk-chip-label] {
|
|
116
|
+
overflow: hidden;
|
|
117
|
+
text-overflow: ellipsis;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
[data-mk-chip]:focus-visible,
|
|
121
|
+
[data-mk-chip][data-mk-armed] {
|
|
122
|
+
box-shadow: 0 0 0 2px var(--mk-accent);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
[data-mk-chip-remove] {
|
|
126
|
+
display: grid;
|
|
127
|
+
flex: none;
|
|
128
|
+
place-items: center;
|
|
129
|
+
width: 1.25rem;
|
|
130
|
+
height: 1.25rem;
|
|
131
|
+
padding: 0;
|
|
132
|
+
border: 0;
|
|
133
|
+
border-radius: 50%;
|
|
134
|
+
background: transparent;
|
|
135
|
+
color: inherit;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
opacity: 0.7;
|
|
138
|
+
transition: background-color 0.15s ease, opacity 0.15s ease;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
[data-mk-chip-remove]:hover {
|
|
142
|
+
background: color-mix(in srgb, currentColor 14%, transparent);
|
|
143
|
+
opacity: 1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Listbox (core/listbox.ts): a 16 px panel in the top layer under the field; the active option sits on a pill. */
|
|
147
|
+
[data-mk-listbox] {
|
|
148
|
+
position: fixed;
|
|
149
|
+
inset: auto;
|
|
150
|
+
z-index: 2147482000;
|
|
151
|
+
box-sizing: border-box;
|
|
152
|
+
max-height: min(18rem, 50vh);
|
|
153
|
+
margin: 0;
|
|
154
|
+
padding: 0.35rem;
|
|
155
|
+
overflow: auto;
|
|
156
|
+
border: 1px solid var(--mk-outline-soft);
|
|
157
|
+
border-radius: 16px;
|
|
158
|
+
background: var(--mk-surface-1);
|
|
159
|
+
color: var(--mk-text);
|
|
160
|
+
box-shadow: 0 16px 40px -14px color-mix(in srgb, var(--mk-shadow-color, #000) 35%, transparent);
|
|
161
|
+
font: 0.9375rem/1.3 var(--mk-font, system-ui, sans-serif);
|
|
162
|
+
overscroll-behavior: contain;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
[data-mk-listbox][hidden] {
|
|
166
|
+
display: none;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[data-mk-listbox-items] {
|
|
170
|
+
position: relative;
|
|
171
|
+
display: grid;
|
|
172
|
+
gap: 2px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
[data-mk-listbox-pill] {
|
|
176
|
+
position: absolute;
|
|
177
|
+
top: 0.35rem;
|
|
178
|
+
right: 0.35rem;
|
|
179
|
+
left: 0.35rem;
|
|
180
|
+
border-radius: 10px;
|
|
181
|
+
background: var(--mk-accent-soft);
|
|
182
|
+
opacity: 0;
|
|
183
|
+
pointer-events: none;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
[data-mk-option] {
|
|
187
|
+
position: relative;
|
|
188
|
+
z-index: 1;
|
|
189
|
+
display: flex;
|
|
190
|
+
align-items: center;
|
|
191
|
+
gap: 0.6rem;
|
|
192
|
+
min-height: 2.5rem;
|
|
193
|
+
padding: 0 0.75rem;
|
|
194
|
+
border-radius: 10px;
|
|
195
|
+
cursor: pointer;
|
|
196
|
+
user-select: none;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
[data-mk-option][aria-disabled='true'] {
|
|
200
|
+
color: var(--mk-muted);
|
|
201
|
+
cursor: not-allowed;
|
|
202
|
+
opacity: 0.55;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
[data-mk-option-label] {
|
|
206
|
+
flex: 1;
|
|
207
|
+
min-width: 0;
|
|
208
|
+
overflow-wrap: anywhere;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
[data-mk-option-label] mark {
|
|
212
|
+
background: transparent;
|
|
213
|
+
color: inherit;
|
|
214
|
+
font-weight: 700;
|
|
215
|
+
text-decoration: underline;
|
|
216
|
+
text-decoration-color: var(--mk-accent);
|
|
217
|
+
text-decoration-thickness: 2px;
|
|
218
|
+
text-underline-offset: 3px;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
[data-mk-option-hint] {
|
|
222
|
+
color: var(--mk-muted);
|
|
223
|
+
font-size: 0.8125rem;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
[data-mk-option-check] {
|
|
227
|
+
display: grid;
|
|
228
|
+
flex: none;
|
|
229
|
+
place-items: center;
|
|
230
|
+
width: 1.15rem;
|
|
231
|
+
height: 1.15rem;
|
|
232
|
+
border: 1.5px solid var(--mk-outline);
|
|
233
|
+
border-radius: 5px;
|
|
234
|
+
color: transparent;
|
|
235
|
+
transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
[data-mk-option][aria-selected='true'] [data-mk-option-check] {
|
|
239
|
+
border-color: var(--mk-accent);
|
|
240
|
+
background: var(--mk-accent);
|
|
241
|
+
color: var(--mk-on-accent);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
[data-mk-listbox-group] {
|
|
245
|
+
padding: 0.6rem 0.75rem 0.25rem;
|
|
246
|
+
color: var(--mk-muted);
|
|
247
|
+
font-size: 0.75rem;
|
|
248
|
+
font-weight: 600;
|
|
249
|
+
letter-spacing: 0.02em;
|
|
250
|
+
text-transform: uppercase;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
[data-mk-listbox-empty] {
|
|
254
|
+
padding: 0.75rem;
|
|
255
|
+
color: var(--mk-muted);
|
|
256
|
+
font-size: 0.875rem;
|
|
257
|
+
text-align: center;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@media (prefers-reduced-motion: reduce) {
|
|
261
|
+
[data-mk-chip],
|
|
262
|
+
[data-mk-chip-remove],
|
|
263
|
+
[data-mk-option-check] {
|
|
264
|
+
transition: none;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type HTMLAttributes } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { createMultiSelect, type MultiSelectInstance, type MultiSelectOptions } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface MultiSelectProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'>, MultiSelectOptions {
|
|
7
|
+
/** Controlled values; without it the field keeps its own (defaultValue). */
|
|
8
|
+
value?: string[];
|
|
9
|
+
defaultValue?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** <MultiSelect options={people} value={chosen} onChange={setChosen} max={3} />. */
|
|
13
|
+
export function MultiSelect({ options, value, defaultValue, placeholder, label, name, max, closeOnSelect, disabled, onChange, className, ...props }: MultiSelectProps) {
|
|
14
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
15
|
+
const instance = useRef<MultiSelectInstance | null>(null);
|
|
16
|
+
const change = useLatest(onChange);
|
|
17
|
+
const start = useRef(value ?? defaultValue ?? []);
|
|
18
|
+
const optionsKey = JSON.stringify(options ?? null);
|
|
19
|
+
useIsomorphicLayoutEffect(() => {
|
|
20
|
+
const created = createMultiSelect(ref.current, { options, value: value ?? start.current, placeholder, label, name, max, closeOnSelect, disabled, onChange: (next) => change.current?.(next) });
|
|
21
|
+
instance.current = created;
|
|
22
|
+
return () => {
|
|
23
|
+
start.current = created.value;
|
|
24
|
+
created.destroy();
|
|
25
|
+
instance.current = null;
|
|
26
|
+
};
|
|
27
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
28
|
+
}, [placeholder, label, name, max, closeOnSelect, disabled]);
|
|
29
|
+
useIsomorphicLayoutEffect(() => {
|
|
30
|
+
if (options && instance.current) instance.current.setOptions(options);
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
}, [optionsKey]);
|
|
33
|
+
const valueKey = JSON.stringify(value ?? null);
|
|
34
|
+
useIsomorphicLayoutEffect(() => {
|
|
35
|
+
if (value && instance.current && JSON.stringify(instance.current.value) !== valueKey) instance.current.setValue(value);
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [valueKey]);
|
|
38
|
+
return <div {...props} ref={ref} className={['mk-multi-select', className].filter(Boolean).join(' ')} />;
|
|
39
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# notification-bell
|
|
2
|
+
|
|
3
|
+
Campana de notificaciones con insignia. `notify()` la hace sonar: la campana oscila desde arriba con amortiguación (±18°) y el badajo va un instante detrás, salen ondas, la insignia aparece con curva elástica (o su cifra rueda hacia arriba) y un mensaje opcional sube a su lado en vidrio invertido durante unos segundos.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<mk-notification-bell class="mk-notification-bell" count="2"></mk-notification-bell>
|
|
7
|
+
<script>document.querySelector('mk-notification-bell').notify('Nueva cita a las 10:00');</script>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
`defineElements()`, `createNotificationBell(root, options)` (root es el botón o lo contiene) o `<NotificationBell count={unread} message={latest} onOpen={openPanel} />` (una cifra mayor o un mensaje nuevo la hacen sonar).
|
|
11
|
+
|
|
12
|
+
Opciones: `count=0`, `label='Notificaciones'`, `messageDuration=3200` ms, `max=99` (más se lee «99+»), `onOpen()`. API: `notify(message?)`, `setCount(n)`, `clear()`, `count`, `destroy()`. Eventos `mk:open` (clic) y `mk:count`. El nombre accesible incluye el número («Notificaciones, 3 sin leer») y un estado educado anuncia las nuevas. Las notificaciones reales (push, servidor) son de la app.
|
|
13
|
+
|
|
14
|
+
Movimiento reducido: la cifra y el mensaje cambian sin oscilación ni ondas.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createNotificationBell, type NotificationBellInstance } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-notification-bell class="mk-notification-bell" count="2"></mk-notification-bell>
|
|
6
|
+
* el.notify('Nueva cita a las 10:00') rings it. Emits mk:open on click and mk:count when the count changes.
|
|
7
|
+
*/
|
|
8
|
+
export class MkNotificationBellElement extends MkElement<NotificationBellInstance> {
|
|
9
|
+
static options: Record<string, OptionType> = { count: 'number', label: 'string', messageDuration: 'number', max: 'number' };
|
|
10
|
+
|
|
11
|
+
protected create(options: Record<string, unknown>) {
|
|
12
|
+
let made: HTMLButtonElement | null = null;
|
|
13
|
+
if (!this.querySelector('button')) {
|
|
14
|
+
made = document.createElement('button');
|
|
15
|
+
made.type = 'button';
|
|
16
|
+
this.append(made);
|
|
17
|
+
}
|
|
18
|
+
const engine = createNotificationBell(this, options);
|
|
19
|
+
if (made) {
|
|
20
|
+
const destroy = engine.destroy;
|
|
21
|
+
engine.destroy = () => {
|
|
22
|
+
destroy();
|
|
23
|
+
made!.remove();
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return engine;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
attributeChangedCallback(name: string, previous: string | null, next: string | null) {
|
|
30
|
+
if (previous === next || !this.instance) return;
|
|
31
|
+
if (name === 'count') this.instance.setCount(Number(next) || 0);
|
|
32
|
+
else super.attributeChangedCallback(name, previous, next);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
notify(message?: string) {
|
|
36
|
+
this.instance?.notify(message);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
clear() {
|
|
40
|
+
this.instance?.clear();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get count() {
|
|
44
|
+
return this.instance?.count ?? 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const defineNotificationBell = () => defineElement('mk-notification-bell', MkNotificationBellElement);
|