@yewdiel21/motion-kit 0.10.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +81 -0
- package/bin/motion-kit.mjs +3 -3
- package/dist/auto/index.d.ts +56 -3
- package/dist/auto/index.js +107 -3
- package/dist/auto/index.js.map +1 -1
- package/dist/{chunk-XAKC2QY7.js → chunk-6IRJYXJU.js} +3 -28
- package/dist/chunk-6IRJYXJU.js.map +1 -0
- package/dist/chunk-A6QQCF6V.js +21333 -0
- package/dist/chunk-A6QQCF6V.js.map +1 -0
- package/dist/chunk-JXRS3OEA.js +3638 -0
- package/dist/chunk-JXRS3OEA.js.map +1 -0
- package/dist/chunk-QP4QJOEN.js +72 -0
- package/dist/chunk-QP4QJOEN.js.map +1 -0
- package/dist/css/components/activity-feed.css +240 -0
- package/dist/css/components/add-to-cart.css +72 -0
- package/dist/css/components/attachment.css +266 -0
- package/dist/css/components/bidirectional-slider.css +168 -0
- package/dist/css/components/breadcrumb.css +110 -0
- package/dist/css/components/chart-tooltip.css +168 -0
- package/dist/css/components/chart.css +296 -0
- package/dist/css/components/code-block.css +264 -0
- package/dist/css/components/color-area.css +82 -0
- package/dist/css/components/color-field.css +67 -0
- package/dist/css/components/color-picker.css +131 -0
- package/dist/css/components/color-slider.css +113 -0
- package/dist/css/components/command-search.css +252 -0
- package/dist/css/components/context-menu.css +23 -0
- package/dist/css/components/credit-card.css +288 -0
- package/dist/css/components/data-table.css +686 -0
- package/dist/css/components/date-range-picker.css +168 -0
- package/dist/css/components/date-time-picker.css +178 -0
- package/dist/css/components/drawer.css +58 -0
- package/dist/css/components/editable-table.css +201 -0
- package/dist/css/components/empty-state.css +61 -0
- package/dist/css/components/file-explorer.css +633 -0
- package/dist/css/components/filter-builder.css +227 -0
- package/dist/css/components/heatmap-chart.css +391 -0
- package/dist/css/components/hold-confirm.css +87 -0
- package/dist/css/components/hover-card.css +19 -7
- package/dist/css/components/image-preview.css +283 -0
- package/dist/css/components/json-viewer.css +304 -0
- package/dist/css/components/like-button.css +78 -0
- package/dist/css/components/link-preview.css +275 -0
- package/dist/css/components/loading-button.css +77 -0
- package/dist/css/components/multi-select.css +267 -0
- package/dist/css/components/nav.css +102 -102
- package/dist/css/components/notification-bell.css +127 -0
- package/dist/css/components/orbit-menu.css +130 -0
- package/dist/css/components/pagination.css +10 -5
- package/dist/css/components/password-strength.css +183 -0
- package/dist/css/components/pie-chart.css +390 -0
- package/dist/css/components/pill-button.css +135 -0
- package/dist/css/components/popover.css +25 -0
- package/dist/css/components/progress.css +140 -0
- package/dist/css/components/questionnaire.css +217 -0
- package/dist/css/components/radar-chart.css +370 -0
- package/dist/css/components/radial-chart.css +398 -0
- package/dist/css/components/range-calendar.css +186 -0
- package/dist/css/components/range-slider.css +192 -0
- package/dist/css/components/resizable-panel.css +243 -0
- package/dist/css/components/rich-text-editor.css +284 -0
- package/dist/css/components/sankey-chart.css +358 -0
- package/dist/css/components/scratch-card.css +75 -0
- package/dist/css/components/scroll-island.css +111 -0
- package/dist/css/components/select.css +136 -0
- package/dist/css/components/skeleton.css +108 -0
- package/dist/css/components/split-view.css +19 -0
- package/dist/css/components/star-rating.css +80 -0
- package/dist/css/components/stat-card.css +164 -0
- package/dist/css/components/swipe-actions.css +105 -0
- package/dist/css/components/tag-input.css +244 -0
- package/dist/css/components/time-field.css +88 -0
- package/dist/css/components/timeline.css +219 -0
- package/dist/css/components/toolbar.css +122 -0
- package/dist/css/components/tooltip.css +79 -0
- package/dist/css/components/tree-view.css +289 -0
- package/dist/css/components/virtual-list.css +195 -0
- package/dist/css/components/voice-dots.css +70 -0
- package/dist/css/tokens.css +185 -181
- package/dist/elements/index.d.ts +849 -7
- package/dist/elements/index.js +1642 -8
- package/dist/elements/index.js.map +1 -1
- package/dist/{engine-GDGwQnJE.d.ts → engine-5zRIssTO.d.ts} +11 -1
- package/dist/engine-QECQnGz1.d.ts +33 -0
- package/dist/index.css +10890 -311
- package/dist/index.d.ts +89 -5
- package/dist/index.js +273 -9
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +686 -24
- package/dist/react/index.js +2345 -9
- package/dist/react/index.js.map +1 -1
- package/dist/{reduced-BmBzKH94.d.ts → reduced-6X_bns60.d.ts} +9 -2
- package/dist/reveal-BfyKKsw4.d.ts +2474 -0
- package/dist/store-CA2Qcun_.d.ts +453 -0
- package/package.json +9 -16
- package/registry.json +1096 -543
- package/src/auto/auto-init.ts +104 -0
- package/src/components/activity-feed/README.md +56 -0
- package/src/components/activity-feed/activity-feed.css +239 -0
- package/src/components/activity-feed/element.ts +36 -0
- package/src/components/activity-feed/engine.ts +351 -0
- package/src/components/activity-feed/react.tsx +32 -0
- package/src/components/add-to-cart/README.md +34 -0
- package/src/components/add-to-cart/add-to-cart.css +71 -0
- package/src/components/add-to-cart/element.ts +20 -0
- package/src/components/add-to-cart/engine.ts +206 -0
- package/src/components/add-to-cart/react.tsx +29 -0
- package/src/components/attachment/README.md +27 -0
- package/src/components/attachment/attachment.css +265 -0
- package/src/components/attachment/element.ts +50 -0
- package/src/components/attachment/engine.ts +469 -0
- package/src/components/attachment/react.tsx +65 -0
- package/src/components/bidirectional-slider/README.md +46 -0
- package/src/components/bidirectional-slider/bidirectional-slider.css +167 -0
- package/src/components/bidirectional-slider/element.ts +42 -0
- package/src/components/bidirectional-slider/engine.ts +289 -0
- package/src/components/bidirectional-slider/react.tsx +45 -0
- package/src/components/breadcrumb/README.md +38 -0
- package/src/components/breadcrumb/breadcrumb.css +109 -0
- package/src/components/breadcrumb/element.ts +27 -0
- package/src/components/breadcrumb/engine.ts +249 -0
- package/src/components/breadcrumb/react.tsx +30 -0
- package/src/components/chart/README.md +34 -0
- package/src/components/chart/chart.css +295 -0
- package/src/components/chart/element.ts +43 -0
- package/src/components/chart/engine.ts +838 -0
- package/src/components/chart/parts.ts +237 -0
- package/src/components/chart/react.tsx +50 -0
- package/src/components/chart/use-chart.ts +55 -0
- package/src/components/chart-tooltip/README.md +53 -0
- package/src/components/chart-tooltip/chart-tooltip.css +167 -0
- package/src/components/chart-tooltip/element.ts +37 -0
- package/src/components/chart-tooltip/engine.ts +442 -0
- package/src/components/chart-tooltip/react.tsx +47 -0
- package/src/components/code-block/README.md +19 -0
- package/src/components/code-block/code-block.css +263 -0
- package/src/components/code-block/element.ts +34 -0
- package/src/components/code-block/engine.ts +254 -0
- package/src/components/code-block/highlight.ts +244 -0
- package/src/components/code-block/react.tsx +94 -0
- package/src/components/color-area/README.md +50 -0
- package/src/components/color-area/color-area.css +81 -0
- package/src/components/color-area/element.ts +26 -0
- package/src/components/color-area/engine.ts +246 -0
- package/src/components/color-area/react.tsx +42 -0
- package/src/components/color-field/README.md +43 -0
- package/src/components/color-field/color-field.css +66 -0
- package/src/components/color-field/element.ts +26 -0
- package/src/components/color-field/engine.ts +174 -0
- package/src/components/color-field/react.tsx +42 -0
- package/src/components/color-picker/README.md +45 -0
- package/src/components/color-picker/color-picker.css +130 -0
- package/src/components/color-picker/element.ts +45 -0
- package/src/components/color-picker/engine.ts +314 -0
- package/src/components/color-picker/react.tsx +47 -0
- package/src/components/color-slider/README.md +55 -0
- package/src/components/color-slider/color-slider.css +112 -0
- package/src/components/color-slider/element.ts +26 -0
- package/src/components/color-slider/engine.ts +234 -0
- package/src/components/color-slider/react.tsx +45 -0
- package/src/components/command-search/README.md +15 -0
- package/src/components/command-search/command-search.css +251 -0
- package/src/components/command-search/element.ts +36 -0
- package/src/components/command-search/engine.ts +356 -0
- package/src/components/command-search/match.ts +53 -0
- package/src/components/command-search/react.tsx +66 -0
- package/src/components/context-menu/README.md +31 -0
- package/src/components/context-menu/context-menu.css +22 -0
- package/src/components/context-menu/element.ts +40 -0
- package/src/components/context-menu/engine.ts +153 -0
- package/src/components/context-menu/react.tsx +57 -0
- package/src/components/credit-card/README.md +20 -0
- package/src/components/credit-card/card.ts +77 -0
- package/src/components/credit-card/credit-card.css +287 -0
- package/src/components/credit-card/element.ts +33 -0
- package/src/components/credit-card/engine.ts +410 -0
- package/src/components/credit-card/react.tsx +36 -0
- package/src/components/data-table/README.md +83 -0
- package/src/components/data-table/data-table.css +685 -0
- package/src/components/data-table/element.ts +54 -0
- package/src/components/data-table/engine.ts +1111 -0
- package/src/components/data-table/react.tsx +94 -0
- package/src/components/date-range-picker/README.md +51 -0
- package/src/components/date-range-picker/date-range-picker.css +167 -0
- package/src/components/date-range-picker/element.ts +52 -0
- package/src/components/date-range-picker/engine.ts +352 -0
- package/src/components/date-range-picker/react.tsx +57 -0
- package/src/components/date-time-picker/README.md +48 -0
- package/src/components/date-time-picker/date-time-picker.css +177 -0
- package/src/components/date-time-picker/element.ts +47 -0
- package/src/components/date-time-picker/engine.ts +350 -0
- package/src/components/date-time-picker/react.tsx +54 -0
- package/src/components/dialog/README.md +103 -102
- package/src/components/dialog/element.ts +123 -118
- package/src/components/dialog/engine.ts +449 -432
- package/src/components/drawer/README.md +28 -0
- package/src/components/drawer/drawer.css +57 -0
- package/src/components/drawer/element.ts +21 -0
- package/src/components/drawer/engine.ts +56 -0
- package/src/components/drawer/react.tsx +85 -0
- package/src/components/editable-table/README.md +67 -0
- package/src/components/editable-table/editable-table.css +200 -0
- package/src/components/editable-table/element.ts +45 -0
- package/src/components/editable-table/engine.ts +831 -0
- package/src/components/editable-table/react.tsx +79 -0
- package/src/components/empty-state/README.md +41 -0
- package/src/components/empty-state/element.ts +23 -0
- package/src/components/empty-state/empty-state.css +60 -0
- package/src/components/empty-state/engine.ts +232 -0
- package/src/components/empty-state/react.tsx +34 -0
- package/src/components/file-explorer/README.md +67 -0
- package/src/components/file-explorer/element.ts +39 -0
- package/src/components/file-explorer/engine.ts +1307 -0
- package/src/components/file-explorer/file-explorer.css +632 -0
- package/src/components/file-explorer/react.tsx +77 -0
- package/src/components/filter-builder/README.md +47 -0
- package/src/components/filter-builder/element.ts +34 -0
- package/src/components/filter-builder/engine.ts +396 -0
- package/src/components/filter-builder/filter-builder.css +226 -0
- package/src/components/filter-builder/react.tsx +36 -0
- package/src/components/heatmap-chart/README.md +48 -0
- package/src/components/heatmap-chart/element.ts +21 -0
- package/src/components/heatmap-chart/engine.ts +281 -0
- package/src/components/heatmap-chart/heatmap-chart.css +93 -0
- package/src/components/heatmap-chart/react.tsx +14 -0
- package/src/components/hold-confirm/README.md +13 -0
- package/src/components/hold-confirm/element.ts +24 -0
- package/src/components/hold-confirm/engine.ts +216 -0
- package/src/components/hold-confirm/hold-confirm.css +86 -0
- package/src/components/hold-confirm/react.tsx +28 -0
- package/src/components/hover-card/README.md +6 -2
- package/src/components/hover-card/engine.ts +98 -7
- package/src/components/hover-card/hover-card.css +19 -7
- package/src/components/image-preview/README.md +16 -0
- package/src/components/image-preview/element.ts +26 -0
- package/src/components/image-preview/engine.ts +405 -0
- package/src/components/image-preview/image-preview.css +282 -0
- package/src/components/image-preview/react.tsx +43 -0
- package/src/components/json-viewer/README.md +56 -0
- package/src/components/json-viewer/element.ts +37 -0
- package/src/components/json-viewer/engine.ts +449 -0
- package/src/components/json-viewer/json-viewer.css +303 -0
- package/src/components/json-viewer/react.tsx +56 -0
- package/src/components/like-button/README.md +13 -0
- package/src/components/like-button/element.ts +47 -0
- package/src/components/like-button/engine.ts +145 -0
- package/src/components/like-button/like-button.css +77 -0
- package/src/components/like-button/react.tsx +39 -0
- package/src/components/link-preview/README.md +19 -0
- package/src/components/link-preview/element.ts +29 -0
- package/src/components/link-preview/engine.ts +192 -0
- package/src/components/link-preview/link-preview.css +274 -0
- package/src/components/link-preview/react.tsx +101 -0
- package/src/components/loading-button/README.md +45 -0
- package/src/components/loading-button/element.ts +34 -0
- package/src/components/loading-button/engine.ts +201 -0
- package/src/components/loading-button/loading-button.css +76 -0
- package/src/components/loading-button/react.tsx +43 -0
- package/src/components/multi-select/README.md +48 -0
- package/src/components/multi-select/element.ts +28 -0
- package/src/components/multi-select/engine.ts +294 -0
- package/src/components/multi-select/multi-select.css +266 -0
- package/src/components/multi-select/react.tsx +39 -0
- package/src/components/nav/README.md +12 -10
- package/src/components/nav/element.ts +5 -5
- package/src/components/nav/engine.ts +21 -14
- package/src/components/nav/nav.css +102 -102
- package/src/components/nav/react.tsx +4 -4
- package/src/components/notification-bell/README.md +14 -0
- package/src/components/notification-bell/element.ts +48 -0
- package/src/components/notification-bell/engine.ts +202 -0
- package/src/components/notification-bell/notification-bell.css +126 -0
- package/src/components/notification-bell/react.tsx +57 -0
- package/src/components/orbit-menu/README.md +46 -0
- package/src/components/orbit-menu/element.ts +27 -0
- package/src/components/orbit-menu/engine.ts +179 -0
- package/src/components/orbit-menu/orbit-menu.css +129 -0
- package/src/components/orbit-menu/react.tsx +44 -0
- package/src/components/pagination/README.md +1 -1
- package/src/components/pagination/engine.ts +50 -4
- package/src/components/pagination/pagination.css +10 -5
- package/src/components/password-strength/README.md +17 -0
- package/src/components/password-strength/element.ts +22 -0
- package/src/components/password-strength/engine.ts +212 -0
- package/src/components/password-strength/password-strength.css +182 -0
- package/src/components/password-strength/react.tsx +36 -0
- package/src/components/password-strength/score.ts +62 -0
- package/src/components/pie-chart/README.md +48 -0
- package/src/components/pie-chart/element.ts +30 -0
- package/src/components/pie-chart/engine.ts +283 -0
- package/src/components/pie-chart/pie-chart.css +92 -0
- package/src/components/pie-chart/react.tsx +14 -0
- package/src/components/pill-button/README.md +46 -0
- package/src/components/pill-button/element.ts +16 -0
- package/src/components/pill-button/engine.ts +77 -0
- package/src/components/pill-button/pill-button.css +134 -0
- package/src/components/pill-button/react.tsx +32 -0
- package/src/components/popover/README.md +44 -0
- package/src/components/popover/element.ts +31 -0
- package/src/components/popover/engine.ts +114 -0
- package/src/components/popover/popover.css +24 -0
- package/src/components/popover/react.tsx +50 -0
- package/src/components/progress/README.md +17 -0
- package/src/components/progress/element.ts +30 -0
- package/src/components/progress/engine.ts +173 -0
- package/src/components/progress/progress.css +139 -0
- package/src/components/progress/react.tsx +35 -0
- package/src/components/questionnaire/README.md +32 -0
- package/src/components/questionnaire/element.ts +118 -0
- package/src/components/questionnaire/engine.ts +255 -0
- package/src/components/questionnaire/questionnaire.css +216 -0
- package/src/components/questionnaire/react.tsx +140 -0
- package/src/components/radar-chart/README.md +48 -0
- package/src/components/radar-chart/element.ts +30 -0
- package/src/components/radar-chart/engine.ts +327 -0
- package/src/components/radar-chart/radar-chart.css +72 -0
- package/src/components/radar-chart/react.tsx +14 -0
- package/src/components/radial-chart/README.md +48 -0
- package/src/components/radial-chart/element.ts +30 -0
- package/src/components/radial-chart/engine.ts +290 -0
- package/src/components/radial-chart/radial-chart.css +100 -0
- package/src/components/radial-chart/react.tsx +14 -0
- package/src/components/range-calendar/README.md +58 -0
- package/src/components/range-calendar/element.ts +42 -0
- package/src/components/range-calendar/engine.ts +390 -0
- package/src/components/range-calendar/range-calendar.css +185 -0
- package/src/components/range-calendar/react.tsx +56 -0
- package/src/components/range-slider/README.md +23 -0
- package/src/components/range-slider/element.ts +53 -0
- package/src/components/range-slider/engine.ts +316 -0
- package/src/components/range-slider/range-slider.css +191 -0
- package/src/components/range-slider/react.tsx +66 -0
- package/src/components/resizable-panel/README.md +61 -0
- package/src/components/resizable-panel/element.ts +36 -0
- package/src/components/resizable-panel/engine.ts +551 -0
- package/src/components/resizable-panel/react.tsx +74 -0
- package/src/components/resizable-panel/resizable-panel.css +242 -0
- package/src/components/rich-text-editor/README.md +57 -0
- package/src/components/rich-text-editor/element.ts +34 -0
- package/src/components/rich-text-editor/engine.ts +673 -0
- package/src/components/rich-text-editor/react.tsx +60 -0
- package/src/components/rich-text-editor/rich-text-editor.css +283 -0
- package/src/components/sankey-chart/README.md +48 -0
- package/src/components/sankey-chart/element.ts +31 -0
- package/src/components/sankey-chart/engine.ts +401 -0
- package/src/components/sankey-chart/react.tsx +14 -0
- package/src/components/sankey-chart/sankey-chart.css +60 -0
- package/src/components/scratch-card/README.md +15 -0
- package/src/components/scratch-card/element.ts +30 -0
- package/src/components/scratch-card/engine.ts +257 -0
- package/src/components/scratch-card/react.tsx +40 -0
- package/src/components/scratch-card/scratch-card.css +74 -0
- package/src/components/scroll-island/README.md +34 -0
- package/src/components/scroll-island/element.ts +16 -0
- package/src/components/scroll-island/engine.ts +252 -0
- package/src/components/scroll-island/react.tsx +26 -0
- package/src/components/scroll-island/scroll-island.css +110 -0
- package/src/components/select/README.md +34 -0
- package/src/components/select/element.ts +26 -0
- package/src/components/select/engine.ts +267 -0
- package/src/components/select/react.tsx +33 -0
- package/src/components/select/select.css +135 -0
- package/src/components/skeleton/README.md +15 -0
- package/src/components/skeleton/element.ts +32 -0
- package/src/components/skeleton/engine.ts +104 -0
- package/src/components/skeleton/react.tsx +41 -0
- package/src/components/skeleton/skeleton.css +107 -0
- package/src/components/split-view/README.md +50 -0
- package/src/components/split-view/element.ts +34 -0
- package/src/components/split-view/engine.ts +114 -0
- package/src/components/split-view/react.tsx +63 -0
- package/src/components/split-view/split-view.css +18 -0
- package/src/components/star-rating/README.md +14 -0
- package/src/components/star-rating/element.ts +26 -0
- package/src/components/star-rating/engine.ts +217 -0
- package/src/components/star-rating/react.tsx +33 -0
- package/src/components/star-rating/star-rating.css +79 -0
- package/src/components/stat-card/README.md +42 -0
- package/src/components/stat-card/element.ts +40 -0
- package/src/components/stat-card/engine.ts +283 -0
- package/src/components/stat-card/react.tsx +36 -0
- package/src/components/stat-card/stat-card.css +163 -0
- package/src/components/swipe-actions/README.md +19 -0
- package/src/components/swipe-actions/element.ts +26 -0
- package/src/components/swipe-actions/engine.ts +260 -0
- package/src/components/swipe-actions/react.tsx +80 -0
- package/src/components/swipe-actions/swipe-actions.css +104 -0
- package/src/components/tag-input/README.md +42 -0
- package/src/components/tag-input/element.ts +39 -0
- package/src/components/tag-input/engine.ts +313 -0
- package/src/components/tag-input/react.tsx +54 -0
- package/src/components/tag-input/tag-input.css +243 -0
- package/src/components/time-field/README.md +54 -0
- package/src/components/time-field/element.ts +38 -0
- package/src/components/time-field/engine.ts +110 -0
- package/src/components/time-field/react.tsx +45 -0
- package/src/components/time-field/time-field.css +87 -0
- package/src/components/timeline/README.md +57 -0
- package/src/components/timeline/element.ts +31 -0
- package/src/components/timeline/engine.ts +300 -0
- package/src/components/timeline/react.tsx +59 -0
- package/src/components/timeline/timeline.css +218 -0
- package/src/components/toolbar/README.md +46 -0
- package/src/components/toolbar/element.ts +30 -0
- package/src/components/toolbar/engine.ts +230 -0
- package/src/components/toolbar/react.tsx +34 -0
- package/src/components/toolbar/toolbar.css +121 -0
- package/src/components/tooltip/README.md +46 -0
- package/src/components/tooltip/element.ts +22 -0
- package/src/components/tooltip/engine.ts +288 -0
- package/src/components/tooltip/react.tsx +30 -0
- package/src/components/tooltip/tooltip.css +78 -0
- package/src/components/tree-view/README.md +61 -0
- package/src/components/tree-view/element.ts +32 -0
- package/src/components/tree-view/engine.ts +743 -0
- package/src/components/tree-view/react.tsx +82 -0
- package/src/components/tree-view/tree-view.css +288 -0
- package/src/components/virtual-list/README.md +81 -0
- package/src/components/virtual-list/element.ts +42 -0
- package/src/components/virtual-list/engine.ts +678 -0
- package/src/components/virtual-list/react.tsx +101 -0
- package/src/components/virtual-list/virtual-list.css +194 -0
- package/src/components/voice-dots/README.md +48 -0
- package/src/components/voice-dots/element.ts +45 -0
- package/src/components/voice-dots/engine.ts +243 -0
- package/src/components/voice-dots/react.tsx +52 -0
- package/src/components/voice-dots/voice-dots.css +69 -0
- package/src/core/chips.ts +196 -0
- package/src/core/color.ts +304 -0
- package/src/core/date-range.ts +67 -0
- package/src/core/dates.ts +11 -1
- package/src/core/files.ts +107 -0
- package/src/core/filter.ts +229 -0
- package/src/core/gsap.ts +80 -65
- package/src/core/listbox.ts +332 -0
- package/src/core/mark.ts +29 -0
- package/src/core/position.ts +89 -0
- package/src/core/relative-time.ts +77 -0
- package/src/core/segment-field.ts +373 -0
- package/src/core/segments.ts +153 -0
- package/src/core/tree.ts +116 -0
- package/src/core/virtual.ts +79 -0
- package/src/css/tokens.css +186 -182
- package/src/elements/index.ts +186 -0
- package/src/index.ts +88 -0
- package/src/motion/liquid.ts +14 -4
- package/src/motion/micro.ts +248 -0
- package/src/motion/sheet.ts +88 -65
- package/src/motion/surface.ts +9 -0
- package/src/react/index.ts +71 -1
- package/dist/chunk-IKQ5FODN.js +0 -1617
- package/dist/chunk-IKQ5FODN.js.map +0 -1
- package/dist/chunk-J6OCFNGU.js +0 -177
- package/dist/chunk-J6OCFNGU.js.map +0 -1
- package/dist/chunk-TFNRIZHU.js +0 -3977
- package/dist/chunk-TFNRIZHU.js.map +0 -1
- package/dist/chunk-XAKC2QY7.js.map +0 -1
- package/dist/reveal-jsX-uwUz.d.ts +0 -625
- package/dist/store-DYb3tTsZ.d.ts +0 -195
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { gsap, EASE, registerMotion } from '../../core/gsap';
|
|
2
|
+
import { reduced } from '../../core/reduced';
|
|
3
|
+
import { createScope } from '../../core/scope';
|
|
4
|
+
import { inert, type Instance } from '../../core/types';
|
|
5
|
+
import { scorePassword, type PasswordChecks, type PasswordScore } from './score';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Password strength: a native password field with a show/hide toggle (the eye
|
|
9
|
+
* swaps with a blur), a four-segment meter whose segments light up one after
|
|
10
|
+
* another and change colour by level (error → warning → good → strong), a label
|
|
11
|
+
* that changes with a blur and a list of requirements whose checks draw
|
|
12
|
+
* themselves. A polite status announces the level once typing pauses.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export interface PasswordStrengthOptions {
|
|
16
|
+
minLength?: number;
|
|
17
|
+
/** Replace the built-in scoring. */
|
|
18
|
+
score?: (value: string) => PasswordScore;
|
|
19
|
+
/** Below this score the field reports itself invalid (setCustomValidity). */
|
|
20
|
+
requireScore?: number;
|
|
21
|
+
labels?: { show?: string; hide?: string; invalid?: string; checks?: Partial<Record<keyof PasswordChecks, string>> };
|
|
22
|
+
onChange?: (result: PasswordScore) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PasswordStrengthInstance extends Instance {
|
|
26
|
+
readonly score: number;
|
|
27
|
+
readonly value: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const EYE = 'M2.5 12s3.5-6.5 9.5-6.5 9.5 6.5 9.5 6.5-3.5 6.5-9.5 6.5S2.5 12 2.5 12z';
|
|
31
|
+
const PUPIL = 'M12 9.2a2.8 2.8 0 1 0 0 5.6 2.8 2.8 0 0 0 0-5.6z';
|
|
32
|
+
const SLASH = 'M4 4l16 16';
|
|
33
|
+
const CHECK = 'M5 12.5l4.5 4.5L19 7.5';
|
|
34
|
+
const ORDER: Array<keyof PasswordChecks> = ['length', 'lower', 'upper', 'number', 'symbol'];
|
|
35
|
+
let sequence = 0;
|
|
36
|
+
|
|
37
|
+
const icon = (paths: string[], part: string) => {
|
|
38
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
39
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
40
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
41
|
+
svg.dataset.mkPart = part;
|
|
42
|
+
for (const d of paths) {
|
|
43
|
+
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
44
|
+
path.setAttribute('d', d);
|
|
45
|
+
path.setAttribute('pathLength', '1');
|
|
46
|
+
svg.append(path);
|
|
47
|
+
}
|
|
48
|
+
return svg;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function createPasswordStrength(root: HTMLElement | null, options: PasswordStrengthOptions = {}): PasswordStrengthInstance {
|
|
52
|
+
if (!root) return inert({ score: 0, value: '' });
|
|
53
|
+
registerMotion();
|
|
54
|
+
const scope = createScope();
|
|
55
|
+
const uid = `mk-password-${++sequence}`;
|
|
56
|
+
const minLength = Number.isFinite(options.minLength) && options.minLength! > 0 ? Math.floor(options.minLength!) : 8;
|
|
57
|
+
const score = options.score ?? ((value: string) => scorePassword(value, minLength));
|
|
58
|
+
const labels = {
|
|
59
|
+
show: 'Mostrar contraseña',
|
|
60
|
+
hide: 'Ocultar contraseña',
|
|
61
|
+
invalid: 'Elige una contraseña más fuerte.',
|
|
62
|
+
...options.labels,
|
|
63
|
+
checks: { length: `Al menos ${minLength} caracteres`, lower: 'Una minúscula', upper: 'Una mayúscula', number: 'Un número', symbol: 'Un símbolo', ...options.labels?.checks },
|
|
64
|
+
};
|
|
65
|
+
const made: Element[] = [];
|
|
66
|
+
scope.add(() => made.forEach((element) => element.remove()));
|
|
67
|
+
|
|
68
|
+
let input = root.querySelector<HTMLInputElement>('input[type="password"], input[data-mk-password]');
|
|
69
|
+
if (!input) {
|
|
70
|
+
input = document.createElement('input');
|
|
71
|
+
input.autocomplete = 'new-password';
|
|
72
|
+
input.setAttribute('aria-label', 'Contraseña');
|
|
73
|
+
root.append(input);
|
|
74
|
+
made.push(input);
|
|
75
|
+
}
|
|
76
|
+
scope.attr(input, 'type', 'password');
|
|
77
|
+
scope.attr(input, 'data-mk-password', '');
|
|
78
|
+
const field = document.createElement('span');
|
|
79
|
+
field.dataset.mkPasswordField = '';
|
|
80
|
+
input.replaceWith(field);
|
|
81
|
+
field.append(input);
|
|
82
|
+
scope.add(() => field.replaceWith(input!));
|
|
83
|
+
const toggle = document.createElement('button');
|
|
84
|
+
toggle.type = 'button';
|
|
85
|
+
toggle.dataset.mkPasswordToggle = '';
|
|
86
|
+
toggle.setAttribute('aria-pressed', 'false');
|
|
87
|
+
toggle.setAttribute('aria-label', labels.show);
|
|
88
|
+
if (input.id) toggle.setAttribute('aria-controls', input.id);
|
|
89
|
+
const eye = icon([EYE, PUPIL, SLASH], 'eye');
|
|
90
|
+
toggle.append(eye);
|
|
91
|
+
field.append(toggle);
|
|
92
|
+
|
|
93
|
+
const meter = document.createElement('div');
|
|
94
|
+
meter.dataset.mkPasswordMeter = '';
|
|
95
|
+
meter.setAttribute('aria-hidden', 'true');
|
|
96
|
+
const segments = Array.from({ length: 4 }, () => {
|
|
97
|
+
const segment = document.createElement('span');
|
|
98
|
+
segment.append(document.createElement('i'));
|
|
99
|
+
meter.append(segment);
|
|
100
|
+
return segment;
|
|
101
|
+
});
|
|
102
|
+
const label = document.createElement('span');
|
|
103
|
+
label.dataset.mkPasswordLabel = '';
|
|
104
|
+
meter.append(label);
|
|
105
|
+
const list = document.createElement('ul');
|
|
106
|
+
list.dataset.mkPasswordChecks = '';
|
|
107
|
+
list.id = `${uid}-checks`;
|
|
108
|
+
const items = ORDER.map((key) => {
|
|
109
|
+
const item = document.createElement('li');
|
|
110
|
+
item.dataset.mkCheck = key;
|
|
111
|
+
item.append(icon([CHECK], 'check'), labels.checks[key] ?? key);
|
|
112
|
+
list.append(item);
|
|
113
|
+
return item;
|
|
114
|
+
});
|
|
115
|
+
const live = document.createElement('span');
|
|
116
|
+
live.className = 'mk-sr-only';
|
|
117
|
+
live.setAttribute('role', 'status');
|
|
118
|
+
root.append(meter, list, live);
|
|
119
|
+
made.push(meter, list, live);
|
|
120
|
+
scope.attr(input, 'aria-describedby', [input.getAttribute('aria-describedby'), list.id].filter(Boolean).join(' '));
|
|
121
|
+
scope.attr(root, 'data-mk-ready', '');
|
|
122
|
+
|
|
123
|
+
const effects = new Set<gsap.core.Animation>();
|
|
124
|
+
const keep = (animation: gsap.core.Animation | null) => {
|
|
125
|
+
if (!animation) return;
|
|
126
|
+
effects.add(animation);
|
|
127
|
+
// Finished ones leave as new ones arrive: the animation's own onComplete stays untouched.
|
|
128
|
+
for (const effect of effects) if (effect.totalProgress() === 1) effects.delete(effect);
|
|
129
|
+
};
|
|
130
|
+
let announce: ReturnType<typeof setTimeout> | undefined;
|
|
131
|
+
scope.add(() => {
|
|
132
|
+
clearTimeout(announce);
|
|
133
|
+
for (const effect of effects) effect.kill();
|
|
134
|
+
effects.clear();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
let result = score(input.value);
|
|
138
|
+
let lit = 0;
|
|
139
|
+
const paint = (animate: boolean) => {
|
|
140
|
+
const previous = lit;
|
|
141
|
+
const level = input!.value ? Math.max(1, result.score) : 0;
|
|
142
|
+
lit = level;
|
|
143
|
+
scope.attr(root, 'data-mk-score', input!.value ? String(result.score) : null);
|
|
144
|
+
const bars = segments.map((segment) => segment.firstElementChild as HTMLElement);
|
|
145
|
+
if (!animate || reduced()) gsap.set(bars, { scaleX: (i: number) => (i < level ? 1 : 0) });
|
|
146
|
+
else if (level > previous) keep(gsap.fromTo(bars.slice(previous, level), { scaleX: 0 }, { scaleX: 1, duration: 0.35, ease: EASE.swatch, stagger: 0.07 }));
|
|
147
|
+
else if (level < previous) keep(gsap.to(bars.slice(level, previous).reverse(), { scaleX: 0, duration: 0.2, ease: 'power2.in', stagger: 0.04 }));
|
|
148
|
+
if (label.textContent !== result.label) {
|
|
149
|
+
if (!animate || reduced()) label.textContent = result.label;
|
|
150
|
+
else {
|
|
151
|
+
gsap.killTweensOf(label);
|
|
152
|
+
keep(
|
|
153
|
+
gsap
|
|
154
|
+
.timeline()
|
|
155
|
+
.to(label, { opacity: 0, filter: 'blur(4px)', y: -3, duration: 0.12 })
|
|
156
|
+
.call(() => {
|
|
157
|
+
label.textContent = result.label;
|
|
158
|
+
})
|
|
159
|
+
.fromTo(label, { opacity: 0, filter: 'blur(4px)', y: 3 }, { opacity: 1, filter: 'blur(0px)', y: 0, duration: 0.25, ease: EASE.pop, clearProps: 'all' }),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
items.forEach((item, i) => {
|
|
164
|
+
const met = result.checks[ORDER[i]!];
|
|
165
|
+
if (item.hasAttribute('data-mk-met') === met) return;
|
|
166
|
+
item.toggleAttribute('data-mk-met', met);
|
|
167
|
+
const path = item.querySelector('path');
|
|
168
|
+
if (met && path && animate && !reduced()) keep(gsap.fromTo(path, { strokeDashoffset: 1 }, { strokeDashoffset: 0, duration: 0.35, ease: 'power2.out' }));
|
|
169
|
+
});
|
|
170
|
+
if (Number.isFinite(options.requireScore)) input!.setCustomValidity(input!.value && result.score < options.requireScore! ? labels.invalid : '');
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const update = () => {
|
|
174
|
+
result = score(input!.value);
|
|
175
|
+
paint(true);
|
|
176
|
+
options.onChange?.(result);
|
|
177
|
+
root.dispatchEvent(new CustomEvent('mk:strength', { bubbles: true, detail: { score: result.score, label: result.label, met: result.checks } }));
|
|
178
|
+
clearTimeout(announce);
|
|
179
|
+
announce = setTimeout(() => {
|
|
180
|
+
if (!scope.disposed) live.textContent = input!.value ? `Fortaleza: ${result.label}` : '';
|
|
181
|
+
}, 700);
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
scope.on(input, 'input', update);
|
|
185
|
+
scope.on(toggle, 'click', () => {
|
|
186
|
+
const show = input!.type === 'password';
|
|
187
|
+
input!.type = show ? 'text' : 'password';
|
|
188
|
+
toggle.setAttribute('aria-pressed', String(show));
|
|
189
|
+
toggle.setAttribute('aria-label', show ? labels.hide : labels.show);
|
|
190
|
+
root.toggleAttribute('data-mk-visible', show);
|
|
191
|
+
const slash = eye.querySelectorAll('path')[2];
|
|
192
|
+
if (!reduced()) {
|
|
193
|
+
keep(gsap.fromTo(eye, { scale: 0.7, filter: 'blur(3px)' }, { scale: 1, filter: 'blur(0px)', duration: 0.35, ease: EASE.click, clearProps: 'all' }));
|
|
194
|
+
if (slash) keep(gsap.fromTo(slash, { strokeDashoffset: show ? 1 : 0 }, { strokeDashoffset: show ? 0 : 1, duration: 0.3, ease: 'power2.out' }));
|
|
195
|
+
} else if (slash) gsap.set(slash, { strokeDashoffset: show ? 0 : 1 });
|
|
196
|
+
});
|
|
197
|
+
scope.add(() => root.removeAttribute('data-mk-visible'));
|
|
198
|
+
scope.add(() => input!.setCustomValidity(''));
|
|
199
|
+
gsap.set(eye.querySelectorAll('path')[2]!, { strokeDasharray: 1, strokeDashoffset: 1 });
|
|
200
|
+
for (const item of items) gsap.set(item.querySelector('path')!, { strokeDasharray: 1, strokeDashoffset: 0 });
|
|
201
|
+
paint(false);
|
|
202
|
+
|
|
203
|
+
return {
|
|
204
|
+
get score() {
|
|
205
|
+
return result.score;
|
|
206
|
+
},
|
|
207
|
+
get value() {
|
|
208
|
+
return input!.value;
|
|
209
|
+
},
|
|
210
|
+
destroy: () => scope.dispose(),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/* password-strength — a Melonmind field (16 px radius, surface-container-high, 3 px focus ring) with an eye toggle,
|
|
2
|
+
four rounded segments that light up by level and a checklist whose checks draw themselves. */
|
|
3
|
+
.mk-password-strength,
|
|
4
|
+
mk-password-strength {
|
|
5
|
+
--mk-password-weak: var(--mk-error);
|
|
6
|
+
--mk-password-fair: #e8a317;
|
|
7
|
+
--mk-password-good: #3c9a5f;
|
|
8
|
+
--mk-password-strong: var(--mk-accent);
|
|
9
|
+
--mk-password-tone: var(--mk-outline);
|
|
10
|
+
display: grid;
|
|
11
|
+
gap: 0.75rem;
|
|
12
|
+
color: var(--mk-text);
|
|
13
|
+
font-family: var(--mk-font);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:is(.mk-password-strength, mk-password-strength):is([data-mk-score='0'], [data-mk-score='1']) {
|
|
17
|
+
--mk-password-tone: var(--mk-password-weak);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
:is(.mk-password-strength, mk-password-strength)[data-mk-score='2'] {
|
|
21
|
+
--mk-password-tone: var(--mk-password-fair);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
:is(.mk-password-strength, mk-password-strength)[data-mk-score='3'] {
|
|
25
|
+
--mk-password-tone: var(--mk-password-good);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
:is(.mk-password-strength, mk-password-strength)[data-mk-score='4'] {
|
|
29
|
+
--mk-password-tone: var(--mk-password-strong);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-field] {
|
|
33
|
+
position: relative;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password] {
|
|
39
|
+
width: 100%;
|
|
40
|
+
min-height: 3.25rem;
|
|
41
|
+
padding: 0 3.5rem 0 1.1rem;
|
|
42
|
+
border: 0;
|
|
43
|
+
border-radius: 16px;
|
|
44
|
+
outline: none;
|
|
45
|
+
background: var(--mk-surface-4);
|
|
46
|
+
color: var(--mk-text);
|
|
47
|
+
font: inherit;
|
|
48
|
+
font-size: 1rem;
|
|
49
|
+
letter-spacing: 0.02em;
|
|
50
|
+
transition:
|
|
51
|
+
box-shadow 0.5s,
|
|
52
|
+
background-color 0.5s;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password]:hover {
|
|
56
|
+
background: var(--mk-surface-5);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password]:focus {
|
|
60
|
+
background: var(--mk-surface-2);
|
|
61
|
+
box-shadow:
|
|
62
|
+
0 0 0 3px var(--mk-outline-soft),
|
|
63
|
+
0 0.5px 2.5px rgb(0 0 0 / 0.3);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-toggle] {
|
|
67
|
+
position: absolute;
|
|
68
|
+
right: 0.4rem;
|
|
69
|
+
display: grid;
|
|
70
|
+
place-items: center;
|
|
71
|
+
width: 2.5rem;
|
|
72
|
+
height: 2.5rem;
|
|
73
|
+
padding: 0;
|
|
74
|
+
border: 0;
|
|
75
|
+
border-radius: 50%;
|
|
76
|
+
background: transparent;
|
|
77
|
+
color: var(--mk-muted);
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
transition:
|
|
80
|
+
background-color 0.2s ease,
|
|
81
|
+
color 0.2s ease;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-toggle]:hover {
|
|
85
|
+
background: var(--mk-surface-3);
|
|
86
|
+
color: var(--mk-text);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-toggle]:focus-visible {
|
|
90
|
+
outline: 2px solid var(--mk-accent);
|
|
91
|
+
outline-offset: 2px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
:is(.mk-password-strength, mk-password-strength) svg {
|
|
95
|
+
width: 1.25rem;
|
|
96
|
+
height: 1.25rem;
|
|
97
|
+
fill: none;
|
|
98
|
+
stroke: currentColor;
|
|
99
|
+
stroke-width: 1.8;
|
|
100
|
+
stroke-linecap: round;
|
|
101
|
+
stroke-linejoin: round;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-meter] {
|
|
105
|
+
display: grid;
|
|
106
|
+
grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
|
|
107
|
+
align-items: center;
|
|
108
|
+
gap: 0.35rem;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-meter] > span:not([data-mk-password-label]) {
|
|
112
|
+
height: 6px;
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
border-radius: 64px;
|
|
115
|
+
background: var(--mk-surface-4);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-meter] i {
|
|
119
|
+
display: block;
|
|
120
|
+
height: 100%;
|
|
121
|
+
border-radius: inherit;
|
|
122
|
+
background: var(--mk-password-tone);
|
|
123
|
+
transform: scaleX(0);
|
|
124
|
+
transform-origin: left center;
|
|
125
|
+
transition: background-color 0.3s ease;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-label] {
|
|
129
|
+
min-width: 6.5rem;
|
|
130
|
+
margin-left: 0.4rem;
|
|
131
|
+
color: var(--mk-password-tone);
|
|
132
|
+
font-size: 0.8125rem;
|
|
133
|
+
font-weight: 500;
|
|
134
|
+
text-align: right;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-password-checks] {
|
|
138
|
+
display: grid;
|
|
139
|
+
grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
|
|
140
|
+
gap: 0.3rem 1rem;
|
|
141
|
+
margin: 0;
|
|
142
|
+
padding: 0;
|
|
143
|
+
color: var(--mk-muted);
|
|
144
|
+
font-size: 0.8125rem;
|
|
145
|
+
list-style: none;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-check] {
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
gap: 0.4rem;
|
|
152
|
+
transition: color 0.2s ease;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-check] svg {
|
|
156
|
+
flex: none;
|
|
157
|
+
width: 1rem;
|
|
158
|
+
height: 1rem;
|
|
159
|
+
padding: 2px;
|
|
160
|
+
border-radius: 50%;
|
|
161
|
+
background: var(--mk-surface-3);
|
|
162
|
+
stroke: transparent;
|
|
163
|
+
stroke-width: 3;
|
|
164
|
+
transition:
|
|
165
|
+
background-color 0.2s ease,
|
|
166
|
+
stroke 0.2s ease;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-check][data-mk-met] {
|
|
170
|
+
color: var(--mk-text);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
:is(.mk-password-strength, mk-password-strength) [data-mk-check][data-mk-met] svg {
|
|
174
|
+
background: var(--mk-password-good);
|
|
175
|
+
stroke: #fff;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@media (prefers-reduced-motion: reduce) {
|
|
179
|
+
:is(.mk-password-strength, mk-password-strength) :is([data-mk-password], [data-mk-check], [data-mk-check] svg, [data-mk-password-meter] i) {
|
|
180
|
+
transition: none;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, type InputHTMLAttributes } from 'react';
|
|
3
|
+
import { useIsomorphicLayoutEffect, useLatest } from '../../react/use-recipe';
|
|
4
|
+
import { createPasswordStrength, type PasswordStrengthOptions } from './engine';
|
|
5
|
+
|
|
6
|
+
export interface PasswordStrengthProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'onChange'>, Omit<PasswordStrengthOptions, 'onChange'> {
|
|
7
|
+
onStrength?: PasswordStrengthOptions['onChange'];
|
|
8
|
+
/** The text of the field as it changes. */
|
|
9
|
+
onValueChange?: (value: string) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** <PasswordStrength name="password" aria-label="Contraseña" requireScore={3} onStrength={setResult} />. The field stays uncontrolled. */
|
|
13
|
+
export function PasswordStrength({ minLength, score, requireScore, labels, onStrength, onValueChange, className, ...props }: PasswordStrengthProps) {
|
|
14
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
15
|
+
const strength = useLatest(onStrength);
|
|
16
|
+
const value = useLatest(onValueChange);
|
|
17
|
+
const scorer = useLatest(score);
|
|
18
|
+
const custom = score !== undefined;
|
|
19
|
+
const key = JSON.stringify(labels ?? {});
|
|
20
|
+
useIsomorphicLayoutEffect(() => {
|
|
21
|
+
const instance = createPasswordStrength(ref.current, {
|
|
22
|
+
minLength,
|
|
23
|
+
requireScore,
|
|
24
|
+
labels,
|
|
25
|
+
score: custom ? (text) => scorer.current!(text) : undefined,
|
|
26
|
+
onChange: (result) => strength.current?.(result),
|
|
27
|
+
});
|
|
28
|
+
return () => instance.destroy();
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
}, [minLength, requireScore, key, custom]);
|
|
31
|
+
return (
|
|
32
|
+
<div ref={ref} className={['mk-password-strength', className].filter(Boolean).join(' ')}>
|
|
33
|
+
<input autoComplete="new-password" aria-label="Contraseña" {...props} type="password" onInput={(event) => value.current?.(event.currentTarget.value)} />
|
|
34
|
+
</div>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Password strength (pure): length and variety raise the score, common
|
|
3
|
+
* passwords, runs (abc, 123) and repeats (aaa) lower it. 0–4, a label and the
|
|
4
|
+
* checks met. A heuristic for feedback, not a security guarantee: the server
|
|
5
|
+
* decides what it accepts.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface PasswordChecks {
|
|
9
|
+
length: boolean;
|
|
10
|
+
lower: boolean;
|
|
11
|
+
upper: boolean;
|
|
12
|
+
number: boolean;
|
|
13
|
+
symbol: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface PasswordScore {
|
|
17
|
+
score: 0 | 1 | 2 | 3 | 4;
|
|
18
|
+
label: string;
|
|
19
|
+
checks: PasswordChecks;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const STRENGTH_LABELS = ['Muy débil', 'Débil', 'Aceptable', 'Fuerte', 'Muy fuerte'] as const;
|
|
23
|
+
|
|
24
|
+
const COMMON = new Set(
|
|
25
|
+
'password password1 123456 1234567 12345678 123456789 1234567890 qwerty qwerty123 abc123 111111 000000 iloveyou admin welcome letmein monkey dragon contraseña contrasena secreto hola123 football baseball sunshine princess'.split(' '),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const runs = (value: string) => {
|
|
29
|
+
const text = value.toLowerCase();
|
|
30
|
+
for (let i = 0; i + 2 < text.length; i++) {
|
|
31
|
+
const [a, b, c] = [text.charCodeAt(i), text.charCodeAt(i + 1), text.charCodeAt(i + 2)];
|
|
32
|
+
if ((b - a === 1 && c - b === 1) || (a - b === 1 && b - c === 1)) return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function scorePassword(value: string, minLength = 8): PasswordScore {
|
|
38
|
+
const text = String(value ?? '');
|
|
39
|
+
const checks: PasswordChecks = {
|
|
40
|
+
length: text.length >= minLength,
|
|
41
|
+
lower: /[a-zà-ÿ]/.test(text),
|
|
42
|
+
upper: /[A-ZÀ-Þ]/.test(text),
|
|
43
|
+
number: /\d/.test(text),
|
|
44
|
+
symbol: /[^\p{L}\p{N}\s]/u.test(text),
|
|
45
|
+
};
|
|
46
|
+
if (!text) return { score: 0, label: '', checks };
|
|
47
|
+
const variety = [checks.lower, checks.upper, checks.number, checks.symbol].filter(Boolean).length;
|
|
48
|
+
let points = 0;
|
|
49
|
+
if (text.length >= minLength) points += 1;
|
|
50
|
+
if (text.length >= minLength + 4) points += 1;
|
|
51
|
+
if (text.length >= minLength + 8) points += 1;
|
|
52
|
+
if (variety >= 3) points += 1;
|
|
53
|
+
if (variety === 4) points += 1;
|
|
54
|
+
// Penalties count after the cap: a long, varied password with a pattern is not the best.
|
|
55
|
+
points = Math.min(4, points);
|
|
56
|
+
if (/(.)\1\1/.test(text)) points -= 1;
|
|
57
|
+
if (runs(text)) points -= 1;
|
|
58
|
+
if (text.length < minLength) points = Math.min(points, 1);
|
|
59
|
+
if (COMMON.has(text.toLowerCase())) points = 0;
|
|
60
|
+
const score = Math.max(0, Math.min(4, points)) as PasswordScore['score'];
|
|
61
|
+
return { score, label: STRENGTH_LABELS[score], checks };
|
|
62
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# pie-chart
|
|
2
|
+
|
|
3
|
+
Gráfica circular o donut con entrada de barrido, selección expansiva y total animado.
|
|
4
|
+
|
|
5
|
+
## Instalación
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import '@yewdiel21/motion-kit/css';
|
|
9
|
+
import { PieChart } from '@yewdiel21/motion-kit/react';
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx @yewdiel21/motion-kit add pie-chart --react --elements
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## React
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
<PieChart label="Ventas" data={[{ label: "Tienda", value: 60 }, { label: "Web", value: 40 }]} />
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Los callbacks del ejemplo (`ask`, `run`, `setTool`, `setVolume`) pertenecen a tu aplicación. React acepta `className`, `style` y atributos HTML. Los componentes con estado exponen `instanceRef` (excepto PillButton).
|
|
23
|
+
|
|
24
|
+
## HTML / Astro
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<mk-pie-chart label="Ventas" data='[{"label":"Tienda","value":60},{"label":"Web","value":40}]'></mk-pie-chart>
|
|
28
|
+
<script type="module">
|
|
29
|
+
import { defineElements } from '@yewdiel21/motion-kit/elements';
|
|
30
|
+
defineElements(['mk-pie-chart']);
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
En Astro usa un `<script>` procesado por Astro. En HTML directo el import requiere bundler o import map. También puedes usar `import { createPieChart } from '@yewdiel21/motion-kit'` y llamar a la factory con el contenedor y las mismas opciones. Al desmontar, llama a `instance.destroy()`.
|
|
35
|
+
|
|
36
|
+
## Opciones
|
|
37
|
+
|
|
38
|
+
data: {label, value, color?}[]. donut: 0.62 (0 para pie). gap: 1.5 grados. size: 240 px. totalLabel: Total. legend: true. Se omiten valores no finitos o no positivos.
|
|
39
|
+
|
|
40
|
+
Todos los gráficos aceptan `label`, `emptyLabel` y `formatValue`. Se actualizan con `update(options)` sin desmontarse; `select(index | null)` y `selected` controlan la selección (en heatmap se usa una fecha). `onSelect` también emite `mk:select`.
|
|
41
|
+
|
|
42
|
+
Los nombres camelCase se escriben como atributos kebab-case. Los arrays y objetos se pasan como JSON. Los booleanos aceptan atributo vacío o `"false"`.
|
|
43
|
+
|
|
44
|
+
## Estilos y accesibilidad
|
|
45
|
+
|
|
46
|
+
Variables: --mk-chart-1…8, --mk-chart-surface.
|
|
47
|
+
|
|
48
|
+
Respeta los colores del tema, foco visible y `prefers-reduced-motion`. Los gráficos incluyen una tabla accesible y selección con flechas, Home, End y Escape. Heatmap usa arriba/abajo para un día e izquierda/derecha para una semana. Toolbar usa flechas y Home/End; OrbitMenu cierra con Escape y devuelve el foco. Los controles conservan nombres accesibles; VoiceDots anuncia los estados sin leer cada fotograma.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MkElement, defineElement, type OptionType } from '../../elements/base';
|
|
2
|
+
import { createPieChart, type PieChartInstance, type PieChartOptions } from './engine';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* <mk-pie-chart class="mk-chart mk-pie-chart" label="Ventas por canal"
|
|
6
|
+
* data='[{"label":"Tienda","value":420},{"label":"En línea","value":310}]'></mk-pie-chart>
|
|
7
|
+
* donut="0" draws a pie. Attribute changes glide in place. Emits mk:select ({index, label, value}).
|
|
8
|
+
*/
|
|
9
|
+
export class MkPieChartElement extends MkElement<PieChartInstance> {
|
|
10
|
+
static options: Record<string, OptionType> = { data: 'json', donut: 'number', gap: 'number', size: 'number', label: 'string', totalLabel: 'string', legend: 'boolean', emptyLabel: 'string' };
|
|
11
|
+
|
|
12
|
+
protected create(options: Record<string, unknown>) {
|
|
13
|
+
return createPieChart(this, options as PieChartOptions);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
attributeChangedCallback(_name: string, previous: string | null, next: string | null) {
|
|
17
|
+
if (previous === next || !this.instance) return;
|
|
18
|
+
this.instance.update({ legend: undefined, ...(this.options as PieChartOptions) });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
update(options: PieChartOptions) {
|
|
22
|
+
this.instance?.update(options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
select(index: number | null) {
|
|
26
|
+
this.instance?.select(index);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const definePieChart = () => defineElement('mk-pie-chart', MkPieChartElement);
|