u2ui 1.0.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/.htaccess +7 -0
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/attr/behavior/README.md +25 -0
- package/attr/behavior/behavior.js +261 -0
- package/attr/behavior/manifest.json +43 -0
- package/attr/behavior/tests/minimal.html +19 -0
- package/attr/behavior/tests/test.html +98 -0
- package/attr/confirm/README.md +36 -0
- package/attr/confirm/confirm.js +90 -0
- package/attr/confirm/manifest.json +43 -0
- package/attr/confirm/tests/minimal.html +23 -0
- package/attr/confirm/tests/test.html +79 -0
- package/attr/draghandle/README.md +41 -0
- package/attr/draghandle/draghandle.js +42 -0
- package/attr/draghandle/tests/minimal.html +44 -0
- package/attr/focusgroup/README.md +49 -0
- package/attr/focusgroup/focusgroup.js +100 -0
- package/attr/focusgroup/manifest.json +38 -0
- package/attr/focusgroup/tests/minimal.html +27 -0
- package/attr/focusgroup/tests/test.html +154 -0
- package/attr/href/README.md +38 -0
- package/attr/href/href.js +42 -0
- package/attr/href/manifest.json +43 -0
- package/attr/href/tests/minimal.html +17 -0
- package/attr/href/tests/test.html +70 -0
- package/attr/intersect/README.md +42 -0
- package/attr/intersect/intersect.js +99 -0
- package/attr/intersect/manifest.json +57 -0
- package/attr/intersect/tests/minimal.html +30 -0
- package/attr/intersect/tests/test.html +64 -0
- package/attr/navigable/README.md +31 -0
- package/attr/navigable/TargetObserver.js +91 -0
- package/attr/navigable/U2TargetObserver.js +75 -0
- package/attr/navigable/manifest.json +42 -0
- package/attr/navigable/navigable.js +87 -0
- package/attr/navigable/tests/U1TargetObserver.html +56 -0
- package/attr/navigable/tests/minimal.html +17 -0
- package/attr/navigable/tests/targetObserver.html +106 -0
- package/attr/navigable/tests/test.html +84 -0
- package/attr/parallax/README.md +48 -0
- package/attr/parallax/parallax.js +119 -0
- package/attr/parallax/tests/minimal.html +25 -0
- package/attr/parallax/tests/performance.html +102 -0
- package/attr/parallax/tests/test.html +108 -0
- package/attr/skin/README.md +59 -0
- package/attr/skin/skin.css +51 -0
- package/attr/skin/tests/minimal.html +34 -0
- package/attr/skin/tests/test.html +96 -0
- package/class/badge/README.md +25 -0
- package/class/badge/badge.css +35 -0
- package/class/badge/tests/minimal.html +17 -0
- package/class/badge/tests/test.html +112 -0
- package/class/card1/README.md +45 -0
- package/class/card1/card1.css +30 -0
- package/class/card1/tests/minimal.html +33 -0
- package/class/card1/tests/test.html +78 -0
- package/class/flex/README.md +62 -0
- package/class/flex/flex.css +25 -0
- package/class/flex/tests/minimal.html +31 -0
- package/class/flex/tests/test.html +58 -0
- package/class/grid/README.md +52 -0
- package/class/grid/grid.css +40 -0
- package/class/grid/tests/minimal.html +34 -0
- package/class/grid/tests/test.html +78 -0
- package/class/input/README.md +49 -0
- package/class/input/input.css +33 -0
- package/class/input/tests/minimal.html +39 -0
- package/class/input/tests/test.html +29 -0
- package/class/reset/README.md +47 -0
- package/class/reset/reset.css +8 -0
- package/class/reset/tests/minimal.html +23 -0
- package/class/table/README.md +57 -0
- package/class/table/table.css +126 -0
- package/class/table/tests/minimal.html +40 -0
- package/class/table/tests/test.html +226 -0
- package/class/unstyle/README.md +32 -0
- package/class/unstyle/tests/minimal.html +22 -0
- package/class/unstyle/tests/test.html +32 -0
- package/class/unstyle/unstyle.css +12 -0
- package/class/width/README.md +48 -0
- package/class/width/tests/minimal.html +27 -0
- package/class/width/tests/test.html +101 -0
- package/class/width/width.css +22 -0
- package/css/base/README.md +25 -0
- package/css/base/base.css +127 -0
- package/css/base/beta.css +50 -0
- package/css/base/full.css +5 -0
- package/css/base/nomotion.css +9 -0
- package/css/base/print.css +36 -0
- package/css/base/tests/nomotion.html +89 -0
- package/css/base/tests/test.html +539 -0
- package/css/classes/README.md +17 -0
- package/css/classes/classes.css +78 -0
- package/css/classes/tests/test.html +63 -0
- package/css/classless/README.md +26 -0
- package/css/classless/aria.css +64 -0
- package/css/classless/classless.css +124 -0
- package/css/classless/full.css +11 -0
- package/css/classless/more.css +340 -0
- package/css/classless/simple.css +103 -0
- package/css/classless/snippeds/a/icons.css +12 -0
- package/css/classless/snippeds/experiments/conventions.css +41 -0
- package/css/classless/snippeds/hr/gradient.css +3 -0
- package/css/classless/snippeds/hr/section_sign.css +16 -0
- package/css/classless/snippeds/hr/tests.html +50 -0
- package/css/classless/tests/aria.html +101 -0
- package/css/classless/tests/foreign/classless-almond.css.html +445 -0
- package/css/classless/tests/foreign/classless-classless.css.html +831 -0
- package/css/classless/tests/foreign/classless-mvp.html +415 -0
- package/css/classless/tests/foreign/classless.sakura.html +224 -0
- package/css/classless/tests/foreign/stylestage.dev.html +304 -0
- package/css/classless/tests/foreign/test-homogenizer.html +433 -0
- package/css/classless/tests/foreign/test-html5-elements-tester.html +956 -0
- package/css/classless/tests/foreign/test-opinionated_css.html +148 -0
- package/css/classless/tests/list-bullet.html +110 -0
- package/css/classless/tests/more.html +246 -0
- package/css/classless/tests/oklch.experiments.html +280 -0
- package/css/classless/tests/test.html +106 -0
- package/css/classless/tests/variables.html +109 -0
- package/css/classless/variables.css +99 -0
- package/css/norm/README.md +37 -0
- package/css/norm/beta.css +40 -0
- package/css/norm/norm.css +98 -0
- package/css/norm/oldies.css +60 -0
- package/css/norm/tests/test.html +434 -0
- package/css/norm/tests/test.js +103 -0
- package/el/accordion/README.md +59 -0
- package/el/accordion/accordion.css +7 -0
- package/el/accordion/accordion.js +258 -0
- package/el/accordion/manifest.json +57 -0
- package/el/accordion/tests/minimal.html +44 -0
- package/el/accordion/tests/test.html +168 -0
- package/el/alert/README.md +67 -0
- package/el/alert/alert copy.js +224 -0
- package/el/alert/alert.css +73 -0
- package/el/alert/alert.js +187 -0
- package/el/alert/manifest.json +77 -0
- package/el/alert/tests/minimal.html +36 -0
- package/el/alert/tests/test.html +105 -0
- package/el/buttongroup/README.md +36 -0
- package/el/buttongroup/buttongroup.css +30 -0
- package/el/buttongroup/buttongroup.js +56 -0
- package/el/buttongroup/tests/minimal.html +31 -0
- package/el/buttongroup/tests/test.html +83 -0
- package/el/bytes/README.md +41 -0
- package/el/bytes/bytes.css +6 -0
- package/el/bytes/bytes.js +97 -0
- package/el/bytes/manifest.json +95 -0
- package/el/bytes/tests/minimal.html +19 -0
- package/el/bytes/tests/test.html +117 -0
- package/el/carousel/README.md +52 -0
- package/el/carousel/carousel.css +46 -0
- package/el/carousel/carousel.js +371 -0
- package/el/carousel/manifest.json +58 -0
- package/el/carousel/tests/experiments.html +77 -0
- package/el/carousel/tests/minimal.html +31 -0
- package/el/carousel/tests/nested.html +54 -0
- package/el/carousel/tests/test.html +136 -0
- package/el/carousel-nav/README.md +40 -0
- package/el/carousel-nav/carousel-nav.js +74 -0
- package/el/carousel-nav/tests/minimal.html +32 -0
- package/el/carousel-nav/tests/test.html +59 -0
- package/el/code/README.md +68 -0
- package/el/code/code.css +46 -0
- package/el/code/code.js +289 -0
- package/el/code/manifest.json +66 -0
- package/el/code/tests/minimal.html +35 -0
- package/el/code/tests/test.html +162 -0
- package/el/copy/README.md +35 -0
- package/el/copy/copy.css +3 -0
- package/el/copy/copy.js +118 -0
- package/el/copy/manifest.json +49 -0
- package/el/copy/tests/minimal.html +21 -0
- package/el/copy/tests/test.html +75 -0
- package/el/counter/README.md +47 -0
- package/el/counter/counter.css +8 -0
- package/el/counter/counter.js +95 -0
- package/el/counter/manifest.json +59 -0
- package/el/counter/tests/minimal.html +27 -0
- package/el/counter/tests/test.html +106 -0
- package/el/ico/README.md +162 -0
- package/el/ico/font/Font Awesome.css +22 -0
- package/el/ico/font/LigatureSymbols.css +7 -0
- package/el/ico/font/Material Icons.css +6 -0
- package/el/ico/font/RemixFilled.css +8 -0
- package/el/ico/font/RemixOutlined.css +8 -0
- package/el/ico/font/old/anicons.css +31 -0
- package/el/ico/font/old/devicons.css +210 -0
- package/el/ico/font/old/material.all.css +36 -0
- package/el/ico/font/old/remix.css +15 -0
- package/el/ico/font/old/utf8.css +54 -0
- package/el/ico/ico.css +111 -0
- package/el/ico/ico.js +189 -0
- package/el/ico/manifest.json +86 -0
- package/el/ico/tests/combinations.html +86 -0
- package/el/ico/tests/emojis.html +213 -0
- package/el/ico/tests/fonts.html +110 -0
- package/el/ico/tests/ico-directory.html +254 -0
- package/el/ico/tests/minimal.html +46 -0
- package/el/ico/tests/test.html +210 -0
- package/el/ico/tests/util-multi.svg +6 -0
- package/el/ico/tests/util.css +2 -0
- package/el/ico/tests/util.js +110 -0
- package/el/input/README.md +39 -0
- package/el/input/input.css +35 -0
- package/el/input/input.js +331 -0
- package/el/input/tests/formParticipation.html +113 -0
- package/el/input/tests/minimal.html +33 -0
- package/el/input/tests/test.html +258 -0
- package/el/masonry/README.md +51 -0
- package/el/masonry/manifest.json +60 -0
- package/el/masonry/masonry.css +27 -0
- package/el/masonry/masonry.js +92 -0
- package/el/masonry/tests/minimal.html +39 -0
- package/el/masonry/tests/test.html +42 -0
- package/el/number/README.md +47 -0
- package/el/number/manifest.json +121 -0
- package/el/number/number.css +6 -0
- package/el/number/number.js +67 -0
- package/el/number/tests/minimal.html +25 -0
- package/el/number/tests/test.html +138 -0
- package/el/out/README.md +32 -0
- package/el/out/manifest.json +38 -0
- package/el/out/out.css +2 -0
- package/el/out/out.js +59 -0
- package/el/out/tests/minimal.html +25 -0
- package/el/out/tests/test.html +37 -0
- package/el/parallax-bg/README.md +36 -0
- package/el/parallax-bg/parallax-bg.css +13 -0
- package/el/parallax-bg/parallax-bg.js +186 -0
- package/el/parallax-bg/tests/bg.jpg +0 -0
- package/el/parallax-bg/tests/bg1.jpg +0 -0
- package/el/parallax-bg/tests/bg2.jpg +0 -0
- package/el/parallax-bg/tests/demo.html +88 -0
- package/el/parallax-bg/tests/minimal.html +30 -0
- package/el/parallax-bg/tests/test.html +64 -0
- package/el/parallax-bg/tests/visible.html +90 -0
- package/el/qrcode/README.md +38 -0
- package/el/qrcode/manifest.json +43 -0
- package/el/qrcode/package.json +22 -0
- package/el/qrcode/qrcode.css +13 -0
- package/el/qrcode/qrcode.js +46 -0
- package/el/qrcode/tests/minimal.html +26 -0
- package/el/qrcode/tests/test.html +31 -0
- package/el/rating/README.md +45 -0
- package/el/rating/manifest.json +65 -0
- package/el/rating/rating.css +11 -0
- package/el/rating/rating.js +139 -0
- package/el/rating/tests/minimal.html +26 -0
- package/el/rating/tests/tests.html +77 -0
- package/el/rte/README.md +37 -0
- package/el/rte/rte.css +9 -0
- package/el/rte/rte.js +56 -0
- package/el/rte/tests/minimal.html +25 -0
- package/el/rte/tests/test.html +37 -0
- package/el/skeleton/README.md +30 -0
- package/el/skeleton/manifest.json +51 -0
- package/el/skeleton/skeleton.css +61 -0
- package/el/skeleton/skeleton.js +72 -0
- package/el/skeleton/tests/minimal.html +22 -0
- package/el/skeleton/tests/test.html +22 -0
- package/el/splitbutton/README.md +39 -0
- package/el/splitbutton/splitbutton.css +48 -0
- package/el/splitbutton/splitbutton.js +26 -0
- package/el/splitbutton/tests/minimal.html +30 -0
- package/el/splitbutton/tests/test.html +68 -0
- package/el/splitpanel/README.md +39 -0
- package/el/splitpanel/manifest.json +49 -0
- package/el/splitpanel/splitpanel.css +17 -0
- package/el/splitpanel/splitpanel.js +116 -0
- package/el/splitpanel/tests/minimal.html +31 -0
- package/el/splitpanel/tests/tests.html +121 -0
- package/el/table/README.md +68 -0
- package/el/table/manifest.json +43 -0
- package/el/table/table.css +59 -0
- package/el/table/table.js +194 -0
- package/el/table/tests/minimal.html +38 -0
- package/el/table/tests/test.html +108 -0
- package/el/tabs/README.md +50 -0
- package/el/tabs/manifest.json +59 -0
- package/el/tabs/tabs.css +23 -0
- package/el/tabs/tabs.js +210 -0
- package/el/tabs/tests/minimal.html +35 -0
- package/el/tabs/tests/test.html +180 -0
- package/el/textfit/README.md +34 -0
- package/el/textfit/manifest.json +45 -0
- package/el/textfit/tests/minimal.html +25 -0
- package/el/textfit/tests/test.html +26 -0
- package/el/textfit/textfit.css +6 -0
- package/el/textfit/textfit.js +80 -0
- package/el/time/README.md +72 -0
- package/el/time/manifest.json +118 -0
- package/el/time/tests/minimal.html +19 -0
- package/el/time/tests/test.html +160 -0
- package/el/time/time copy.js +141 -0
- package/el/time/time.js +168 -0
- package/el/time/time.old.uhtml.js +129 -0
- package/el/tooltip/README.md +48 -0
- package/el/tooltip/manifest.json +69 -0
- package/el/tooltip/tests/minimal.html +25 -0
- package/el/tooltip/tests/test.html +178 -0
- package/el/tooltip/tooltip.css +97 -0
- package/el/tooltip/tooltip.js +82 -0
- package/el/tree1/README.md +111 -0
- package/el/tree1/manifest.json +78 -0
- package/el/tree1/tests/animated.html +134 -0
- package/el/tree1/tests/custom.html +51 -0
- package/el/tree1/tests/minimal.html +44 -0
- package/el/tree1/tests/test.html +260 -0
- package/el/tree1/tree1.css +26 -0
- package/el/tree1/tree1.js +265 -0
- package/el/typewriter/README.md +62 -0
- package/el/typewriter/manifest.json +66 -0
- package/el/typewriter/tests/minimal.html +25 -0
- package/el/typewriter/tests/test.html +78 -0
- package/el/typewriter/typewriter.css +6 -0
- package/el/typewriter/typewriter.js +166 -0
- package/el/typewriter/typewriter.mp3 +0 -0
- package/js/Placer/Placer.js +156 -0
- package/js/Placer/README.md +62 -0
- package/js/Placer/tests/minimal.html +34 -0
- package/js/Placer/tests/test.html +49 -0
- package/js/PointerObserver/PointerObserver.js +130 -0
- package/js/PointerObserver/README.md +34 -0
- package/js/PointerObserver/tests/minimal.html +29 -0
- package/js/PointerObserver/tests/test.html +35 -0
- package/js/SelectorObserver/README.md +47 -0
- package/js/SelectorObserver/SelectorObserver.js +201 -0
- package/js/SelectorObserver/tests/minimal.html +21 -0
- package/js/SelectorObserver/tests/test.html +57 -0
- package/js/SelectorObserver/tests/tests.html +161 -0
- package/js/contextmenu/README.md +93 -0
- package/js/contextmenu/contextmenu.js +336 -0
- package/js/contextmenu/tests/minimal.html +44 -0
- package/js/contextmenu/tests/test.html +131 -0
- package/js/dialog/README.md +49 -0
- package/js/dialog/dialog.js +261 -0
- package/js/dialog/notification.mp3 +0 -0
- package/js/dialog/tests/minimal.html +29 -0
- package/js/dialog/tests/notification.mp3 +0 -0
- package/js/dialog/tests/test.html +135 -0
- package/js/rte/README.md +44 -0
- package/js/rte/old/NodeCleaner.js +315 -0
- package/js/rte/old/Rte/Rte.mjs +316 -0
- package/js/rte/old/Rte/Rte.ui.items.mjs +543 -0
- package/js/rte/old/Rte/Rte.ui.mjs +154 -0
- package/js/rte/old/Rte/crossbrowser.mjs +323 -0
- package/js/rte/old/Rte/font/tinymce.svg +98 -0
- package/js/rte/old/Rte/font/tinymce.woff +0 -0
- package/js/rte/old/Rte/helpers.mjs +159 -0
- package/js/rte/old/Rte/htmlparser.mjs +178 -0
- package/js/rte/old/Rte/index.mjs +5 -0
- package/js/rte/old/Rte/main.css +189 -0
- package/js/rte/old/old.rte.js +132 -0
- package/js/rte/old/range-selection.old.js +394 -0
- package/js/rte/rte.js +7 -0
- package/js/rte/src/behavior.js +228 -0
- package/js/rte/src/events.js +73 -0
- package/js/rte/src/fixes.js +251 -0
- package/js/rte/src/range.js +472 -0
- package/js/rte/src/rte.js +72 -0
- package/js/rte/src/ui/items/ai.js +167 -0
- package/js/rte/src/ui/items/code.js +93 -0
- package/js/rte/src/ui/items/undo.js +183 -0
- package/js/rte/src/ui.items.js +571 -0
- package/js/rte/src/ui.js +269 -0
- package/js/rte/src/util/htmlparser.js +178 -0
- package/js/rte/src/util/indentHtml.js +48 -0
- package/js/rte/tests/ai.html +81 -0
- package/js/rte/tests/behavior.html +88 -0
- package/js/rte/tests/events.html +69 -0
- package/js/rte/tests/fixes.html +95 -0
- package/js/rte/tests/minimal.html +34 -0
- package/js/rte/tests/notes.md +6 -0
- package/js/rte/tests/range.html +167 -0
- package/js/rte/tests/selection-explorer.html +222 -0
- package/js/rte/tests/test.html +92 -0
- package/js/shortcut/README.md +33 -0
- package/js/shortcut/shortcut.js +89 -0
- package/js/shortcut/tests/minimal.html +23 -0
- package/js/shortcut/tests/test.html +68 -0
- package/package.json +12 -0
- package/u2/README.md +4 -0
- package/u2/auto.js +161 -0
- package/u2/auto.ui.js +85 -0
- package/u2/experiments/Waiter/test.html +132 -0
- package/u2/experiments/getElementByIdPromise/test.html +76 -0
- package/u2/experiments/patchInputValue.html +124 -0
- package/u2/experiments/radiobutton/test.html +75 -0
- package/u2/experiments/tests/test.html +223 -0
- package/u2/experiments/u1-responsive/responsive.js +62 -0
- package/u2/experiments/u1-responsive/test.html +65 -0
- package/u2/experiments/u2Element.js +139 -0
- package/u2/experiments/u2Element.test.html +47 -0
- package/u2/old-stuff/IterableWeakMap/mod.js +70 -0
- package/u2/old-stuff/css/onStyleSheet/mod.js +114 -0
- package/u2/old-stuff/css/onStyleSheet/monkeypatches.js +28 -0
- package/u2/old-stuff/css/onStyleSheet/test/include.css +19 -0
- package/u2/old-stuff/css/onStyleSheet/test/style-has-include.css +6 -0
- package/u2/old-stuff/css/onStyleSheet/test/style-no-include.css +3 -0
- package/u2/old-stuff/css/onStyleSheet/test/test.html +48 -0
- package/u2/old-stuff/css/parser/mod.js +182 -0
- package/u2/old-stuff/css/parser/parser_old/mod.js +128 -0
- package/u2/old-stuff/css/parser/parser_old/test.html +43 -0
- package/u2/old-stuff/css/parser/parser_old/util.js +22 -0
- package/u2/old-stuff/css/parser/style.html +52 -0
- package/u2/old-stuff/css/parser/test.html +38 -0
- package/u2/old-stuff/el/ai-texter/README.md +23 -0
- package/u2/old-stuff/el/ai-texter/ai-texter.css +12 -0
- package/u2/old-stuff/el/ai-texter/ai-texter.js +153 -0
- package/u2/old-stuff/el/ai-texter/tests/minimal.html +47 -0
- package/u2/old-stuff/el/ai-texter/tests/test.html +71 -0
- package/u2/old-stuff/init.js +38 -0
- package/u2/old-stuff/markHashLinks.js +51 -0
- package/u2/old-stuff/onElement/mod.js +73 -0
- package/u2/old-stuff/test-helpers/mod.js +36 -0
- package/u2/old-stuff/test-helpers/test.html +4 -0
- package/u2/old-stuff/tests/init.js.html +51 -0
- package/u2/old-stuff/viewport.js +64 -0
- package/u2/projects.json +468 -0
- package/u2/tests/boilerplate.html +46 -0
- package/u2/tests/kacheln.html +245 -0
- package/u2/tests/showcase.html +270 -0
- package/u2/tests/showcase2.html +157 -0
- package/u2/tests/test-init.js +35 -0
- package/u2/tests/test.html +355 -0
- package/u2/tools/baseElement.js +95 -0
- package/u2/tools/baseElement.test.html +119 -0
- package/u2/tools/ce-inspector.js +308 -0
- package/u2/tools/ce-inspector.test.html +66 -0
- package/u2/tools/ce-manfest-from-element.js +207 -0
- package/u2/tools/dev-iframe.js +213 -0
- package/u2/tools/dev-iframe.test.html +75 -0
- package/u2/tools/eventsExplorer.js +101 -0
- package/u2/tools/logo/u1.svg +9 -0
- package/u2/tools/logo/u1ui.svg +6 -0
- package/u2/tools/update.repos.json.js +234 -0
- package/u2/u2.js +14 -0
- package/u2/utils.js +59 -0
package/.htaccess
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 u2ui
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# u2 - Design System
|
|
2
|
+
HTML Advanced: More Capabilities, Same Feel, Same Simplicity
|
|
3
|
+
|
|
4
|
+
<p align="center">
|
|
5
|
+
<img src="./u2/tools/logo/u1.svg">
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
u2 is a design system that is intended to fulfill the following goals:
|
|
11
|
+
|
|
12
|
+
- Minimalistic
|
|
13
|
+
- Based on standards
|
|
14
|
+
- Tooling is optional
|
|
15
|
+
- Minimal styled, style it as you like
|
|
16
|
+
- Works without JS if possible
|
|
17
|
+
|
|
18
|
+
## Demos
|
|
19
|
+
|
|
20
|
+
[kacheln.html](http://gcdn.li/u2ui/u2@main/u2/tests/kacheln.html)
|
|
21
|
+
[showcase2.html](http://gcdn.li/u2ui/u2@main/u2/tests/showcase2.html)
|
|
22
|
+
[test.html](http://gcdn.li/u2ui/u2@main/u2/tests/test.html)
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
Just add this script to have all the u2-stuff available on demand, without including them separately:
|
|
27
|
+
```html
|
|
28
|
+
<script type=module async src="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/u2/auto.min.js"></script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## About
|
|
33
|
+
|
|
34
|
+
- MIT License, Copyright (c) 2022 <u2> (like all repositories in this organization) <br>
|
|
35
|
+
- Suggestions, ideas, finding bugs and making pull requests make us very happy. ♥
|
|
36
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# [u2-behavior] - attribute
|
|
2
|
+
behavior before action
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
|
|
6
|
+
```html
|
|
7
|
+
<button u2-behavior=share>behavior=share</button>
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/attr/behavior/behavior.min.js" type=module async></script>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Demos
|
|
17
|
+
|
|
18
|
+
[minimal.html](http://gcdn.li/u2ui/u2@main/attr/behavior/tests/minimal.html)
|
|
19
|
+
[test.html](http://gcdn.li/u2ui/u2@main/attr/behavior/tests/test.html)
|
|
20
|
+
|
|
21
|
+
## About
|
|
22
|
+
|
|
23
|
+
- MIT License, Copyright (c) 2022 <u2> (like all repositories in this organization) <br>
|
|
24
|
+
- Suggestions, ideas, finding bugs and making pull requests make us very happy. ♥
|
|
25
|
+
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import {SelectorObserver} from '../../js/SelectorObserver/SelectorObserver.js';
|
|
2
|
+
|
|
3
|
+
const observer = new SelectorObserver({
|
|
4
|
+
on: (el) => {
|
|
5
|
+
|
|
6
|
+
const name = el.getAttribute('u2-behavior');
|
|
7
|
+
const behavior = registry.get(name);
|
|
8
|
+
|
|
9
|
+
const active = behavior.init?.(el);
|
|
10
|
+
setStates(el, {active: active, inactive: !active, success: false, error: false});
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
if ('hidden' in behavior) {
|
|
14
|
+
el.hidden = behavior.hidden(el);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (behavior.text) {
|
|
18
|
+
let textEl = el;
|
|
19
|
+
if (!textEl || textEl.innerHTML) textEl = el.querySelector('.-text');
|
|
20
|
+
if (textEl && !textEl.innerHTML) textEl.innerHTML = behavior.text.en;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (behavior.action) {
|
|
24
|
+
el.addEventListener('click', async (e)=>{
|
|
25
|
+
el.inert = true;
|
|
26
|
+
let active = null;
|
|
27
|
+
try {
|
|
28
|
+
active = await behavior.action(e, el);
|
|
29
|
+
setStates(el, {active, inactive: !active});
|
|
30
|
+
setStates(el, {success: true, error: false});
|
|
31
|
+
} catch (e) {
|
|
32
|
+
setStates(el, {error: true, success: false});
|
|
33
|
+
}
|
|
34
|
+
setTimeout(()=>setStates(el, {success: false, error: false}), 2000);
|
|
35
|
+
el.inert = false;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
},
|
|
40
|
+
off: (el) => {
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
function setStates(el, states) {
|
|
45
|
+
for (const state in states) {
|
|
46
|
+
setAttr(el.querySelector('.-'+state), 'hidden', !states[state]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function setAttr(el, name, value) {
|
|
50
|
+
if (!el) return;
|
|
51
|
+
if (value == null || value === false) return el.removeAttribute(name);
|
|
52
|
+
if (value === true) return el.setAttribute(name, '');
|
|
53
|
+
el.setAttribute(name, value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
const registry = new Map();
|
|
58
|
+
|
|
59
|
+
export function register(name, fn) {
|
|
60
|
+
registry.set(name, fn);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
/* default behavoirs */
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
register('close',{
|
|
70
|
+
init: (el) => {
|
|
71
|
+
},
|
|
72
|
+
action: (e, el) => {
|
|
73
|
+
const target = el.closest('dialog,[popover]');
|
|
74
|
+
target.close?.();
|
|
75
|
+
target.hidePopover?.();
|
|
76
|
+
},
|
|
77
|
+
text: {
|
|
78
|
+
de: 'Schließen',
|
|
79
|
+
en: 'Close',
|
|
80
|
+
fr: 'Fermer',
|
|
81
|
+
it: 'Chiudi',
|
|
82
|
+
es: 'Cerrar'
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
register('share',{
|
|
87
|
+
init: (el) => {
|
|
88
|
+
},
|
|
89
|
+
action: (e, el) => {
|
|
90
|
+
const data = {
|
|
91
|
+
title: el.dataset.title || document.title,
|
|
92
|
+
text: el.dataset.text || document.title,
|
|
93
|
+
url: el.dataset.url || location.href
|
|
94
|
+
};
|
|
95
|
+
return navigator.share(data);
|
|
96
|
+
},
|
|
97
|
+
text: {
|
|
98
|
+
de: 'Teilen',
|
|
99
|
+
en: 'Share',
|
|
100
|
+
fr: 'Partager',
|
|
101
|
+
it: 'Condividi',
|
|
102
|
+
es: 'Compartir'
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
register('once',{
|
|
108
|
+
init: (el) => {},
|
|
109
|
+
action: (e, el) => {
|
|
110
|
+
const id = el.id;
|
|
111
|
+
localStorage.setItem('u2-behavior-once-'+id, true);
|
|
112
|
+
el.hidden = true;
|
|
113
|
+
},
|
|
114
|
+
hidden(el){
|
|
115
|
+
const id = el.id;
|
|
116
|
+
return localStorage.getItem('u2-behavior-once-'+id);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
register('print',{
|
|
121
|
+
init: (el) => {},
|
|
122
|
+
action: (e, el) => {
|
|
123
|
+
window.print();
|
|
124
|
+
},
|
|
125
|
+
text: {
|
|
126
|
+
de: 'Drucken',
|
|
127
|
+
en: 'Print',
|
|
128
|
+
fr: 'Imprimer',
|
|
129
|
+
it: 'Stampa',
|
|
130
|
+
es: 'Imprimir'
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
register('webapp.install',{
|
|
135
|
+
init: (el) => {
|
|
136
|
+
addEventListener('beforeinstallprompt', (e) => {
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
el.hidden = false;
|
|
139
|
+
el.addEventListener('click', () => {
|
|
140
|
+
e.prompt();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
hidden(){
|
|
145
|
+
return navigator.standalone;
|
|
146
|
+
},
|
|
147
|
+
action: (e, el) => {
|
|
148
|
+
},
|
|
149
|
+
text: {
|
|
150
|
+
de: 'Installieren',
|
|
151
|
+
en: 'Install',
|
|
152
|
+
fr: 'Installer',
|
|
153
|
+
it: 'Installa',
|
|
154
|
+
es: 'Instalar'
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
register('fullscreen.toggle',{
|
|
159
|
+
init: (el) => {
|
|
160
|
+
return !!document.fullscreenElement;
|
|
161
|
+
},
|
|
162
|
+
async action(e, el){
|
|
163
|
+
const state = document.fullscreenElement;
|
|
164
|
+
if (state) {
|
|
165
|
+
await document.exitFullscreen();
|
|
166
|
+
} else {
|
|
167
|
+
await el.parentElement.requestFullscreen();
|
|
168
|
+
}
|
|
169
|
+
return !state;
|
|
170
|
+
},
|
|
171
|
+
text: {
|
|
172
|
+
de: 'Vollbild',
|
|
173
|
+
en: 'Fullscreen',
|
|
174
|
+
fr: 'Plein écran',
|
|
175
|
+
it: 'Schermo intero',
|
|
176
|
+
es: 'Pantalla completa'
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
register('darkmode.toggle',{
|
|
183
|
+
init: (el) => {
|
|
184
|
+
const value = localStorage.u2Skin;
|
|
185
|
+
document.documentElement.setAttribute('u2-skin', value);
|
|
186
|
+
document.documentElement.setAttribute('data-theme', value); // compatibility
|
|
187
|
+
const state = value === 'dark';
|
|
188
|
+
return state;
|
|
189
|
+
},
|
|
190
|
+
action: (e, el) => {
|
|
191
|
+
const newVal = localStorage.u2Skin === 'dark' ? 'light' : 'dark';
|
|
192
|
+
localStorage.u2Skin = newVal;
|
|
193
|
+
document.documentElement.setAttribute('u2-skin', newVal);
|
|
194
|
+
document.documentElement.setAttribute('data-theme', newVal);
|
|
195
|
+
return newVal === 'dark';
|
|
196
|
+
},
|
|
197
|
+
text: {
|
|
198
|
+
de: 'Dunkelmodus',
|
|
199
|
+
en: 'Dark mode',
|
|
200
|
+
fr: 'Mode sombre',
|
|
201
|
+
it: 'Modalità scura',
|
|
202
|
+
es: 'Modo oscuro'
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
register('scroll', {
|
|
209
|
+
init: (el) => {
|
|
210
|
+
const checkScroll = () => {
|
|
211
|
+
el.hidden = window.scrollY < innerHeight / 2;
|
|
212
|
+
};
|
|
213
|
+
addEventListener('scroll', checkScroll);
|
|
214
|
+
checkScroll();
|
|
215
|
+
},
|
|
216
|
+
action: (e, el) => {
|
|
217
|
+
window.scrollTo({
|
|
218
|
+
top: 0,
|
|
219
|
+
behavior: 'smooth'
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
// disconnect: (el) => {
|
|
223
|
+
// removeEventListener('scroll', checkScroll);
|
|
224
|
+
// }
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
let wakeLock = null;
|
|
229
|
+
register('wakeLock', {
|
|
230
|
+
init: (el) => {
|
|
231
|
+
el.disabled = "wakeLock" in navigator ? false : true;
|
|
232
|
+
},
|
|
233
|
+
async action(e, el){
|
|
234
|
+
if (wakeLock) {
|
|
235
|
+
await wakeLock.release();
|
|
236
|
+
wakeLock = null;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
wakeLock = await navigator.wakeLock.request("screen");
|
|
241
|
+
wakeLock.addEventListener('release', () => {
|
|
242
|
+
setStates(el, {active:false, inactive: true});
|
|
243
|
+
wakeLock = null;
|
|
244
|
+
});
|
|
245
|
+
return true;
|
|
246
|
+
} catch (err) {
|
|
247
|
+
console.error(`${err.name}, ${err.message}`);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
text: {
|
|
251
|
+
de: 'Bildschirm wach halten',
|
|
252
|
+
en: 'Keep screen awake',
|
|
253
|
+
fr: 'Garder l\'écran allumé',
|
|
254
|
+
it: 'Mantieni lo schermo acceso',
|
|
255
|
+
es: 'Mantener la pantalla encendida'
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
observer.observe('[u2-behavior]');
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "README.md",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "behavior.js",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"// kind": "class",
|
|
11
|
+
"description": "Change behavior of Elements",
|
|
12
|
+
"name": "u2-behavior",
|
|
13
|
+
"members": [],
|
|
14
|
+
"events": [],
|
|
15
|
+
"attributes": [
|
|
16
|
+
{
|
|
17
|
+
"name": "u2-behavior",
|
|
18
|
+
"description": "Initial only! The behavior to apply to the element",
|
|
19
|
+
"u2Examples": ["share","close","print","once","fullscreen","darkmode","scroll"]
|
|
20
|
+
},{
|
|
21
|
+
"name": "lang",
|
|
22
|
+
"description": "The language to use for internationalization",
|
|
23
|
+
"u2Examples": ["en-US","fr-FR","de-DE","es-ES","it-IT","ja-JP","ko-KR","zh-CN","zh-TW"]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"cssProperties": [],
|
|
27
|
+
"attributeName": "u2-behavior"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"exports": [
|
|
31
|
+
{
|
|
32
|
+
"kind": "custom-attribute-definition",
|
|
33
|
+
"name": "u2-behavior",
|
|
34
|
+
"declaration": {
|
|
35
|
+
"name": "u2-behavior",
|
|
36
|
+
"module": "behavior.js"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!DOCTYPE HTML>
|
|
2
|
+
<html lang=en>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name=viewport content="width=device-width">
|
|
6
|
+
<script src="../../../u2/tests/test-init.js" type=module async></script>
|
|
7
|
+
|
|
8
|
+
<link rel=stylesheet href="../../../css/classless/full.css">
|
|
9
|
+
<link rel=stylesheet href="../../../css/classless/simple.css">
|
|
10
|
+
|
|
11
|
+
<script src="../behavior.js" type=module async></script>
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
|
|
15
|
+
<section class=main>
|
|
16
|
+
|
|
17
|
+
<button u2-behavior=share>behavior=share</button>
|
|
18
|
+
|
|
19
|
+
</section>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<!DOCTYPE HTML>
|
|
2
|
+
<html lang=en>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name=viewport content="width=device-width">
|
|
6
|
+
<title>tests</title>
|
|
7
|
+
<script src="../../../u2/tests/test-init.js" type=module async></script>
|
|
8
|
+
|
|
9
|
+
<script src="../../../u2/auto.js" type=module async></script>
|
|
10
|
+
|
|
11
|
+
<link rel=stylesheet href="../../../css/classless/full.css">
|
|
12
|
+
<link rel=stylesheet href="../../../css/classless/simple.css">
|
|
13
|
+
|
|
14
|
+
<script src="../behavior.js" type=module async></script>
|
|
15
|
+
|
|
16
|
+
<style>
|
|
17
|
+
body {
|
|
18
|
+
--u2-ico-dir: 'https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/icons/';
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<body>
|
|
24
|
+
|
|
25
|
+
<section>
|
|
26
|
+
|
|
27
|
+
<h3>share</h3>
|
|
28
|
+
<button u2-behavior="share"></button>
|
|
29
|
+
|
|
30
|
+
<h3>custom text</h3>
|
|
31
|
+
<button u2-behavior="share">share this</button>
|
|
32
|
+
|
|
33
|
+
<h3>state elements</h3>
|
|
34
|
+
<button u2-behavior="share" data-url="https://example.com" data-title="Example" data-text="This is an example">
|
|
35
|
+
<span class="-text"></span>
|
|
36
|
+
<u2-ico class="-success" inline>check</u2-ico>
|
|
37
|
+
<u2-ico class="-error" inline>exclamation-triangle</u2-ico>
|
|
38
|
+
</button>
|
|
39
|
+
|
|
40
|
+
<h2>using class "-text" as text-content</h2>
|
|
41
|
+
<button u2-behavior="share" style="padding:.5rem">
|
|
42
|
+
<u2-ico>share</u2-ico>
|
|
43
|
+
<u2-tooltip class="-text"></u2-tooltip>
|
|
44
|
+
</button>
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
<h3>close</h3>
|
|
48
|
+
<button popovertarget="my-popover">Open Popover</button>
|
|
49
|
+
<div popover id="my-popover">
|
|
50
|
+
<button u2-behavior="close"></button>
|
|
51
|
+
Greetings, one and all!
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<h3>print</h3>
|
|
55
|
+
<button u2-behavior="print"></button>
|
|
56
|
+
|
|
57
|
+
<h3>install</h3>
|
|
58
|
+
<button u2-behavior="webapp.install"></button>
|
|
59
|
+
|
|
60
|
+
<h3>once</h3>
|
|
61
|
+
<button u2-behavior="once" id="once-test">Once</button>
|
|
62
|
+
<br>
|
|
63
|
+
<button onclick="localStorage.removeItem('u2-behavior-once-once-test');">reset</button>
|
|
64
|
+
|
|
65
|
+
<h3>Fullscreen toggle</h3>
|
|
66
|
+
<button u2-behavior="fullscreen.toggle" style="padding:.5rem">
|
|
67
|
+
<u2-tooltip class="-text"></u2-tooltip>
|
|
68
|
+
<u2-ico class="-active">fullscreen-exit</u2-ico>
|
|
69
|
+
<u2-ico class="-inactive">fullscreen</u2-ico>
|
|
70
|
+
</button>
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
<h3>darkmode.toggle</h3>
|
|
74
|
+
<button u2-behavior="darkmode.toggle">
|
|
75
|
+
<span class="-text"></span>:
|
|
76
|
+
<span class="-active">on</span>
|
|
77
|
+
<span class="-inactive" hidden>off</span>
|
|
78
|
+
</button>
|
|
79
|
+
|
|
80
|
+
<h3>wakeLock</h3>
|
|
81
|
+
<button u2-behavior="wakeLock">
|
|
82
|
+
<span class="-text"></span>:
|
|
83
|
+
<span class="-active">on</span>
|
|
84
|
+
<span class="-inactive" hidden>off</span>
|
|
85
|
+
</button>
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
|
90
|
+
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
|
91
|
+
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
|
|
92
|
+
|
|
93
|
+
<div style="position:fixed; bottom:1rem; right:1rem;">
|
|
94
|
+
<h3>scroll</h3>
|
|
95
|
+
<button u2-behavior="scroll">⬆️</button>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
</section>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# [u2-confirm] - attribute
|
|
2
|
+
Confirm before action
|
|
3
|
+
|
|
4
|
+
## Features
|
|
5
|
+
|
|
6
|
+
- Interupts form submit and requestSubmit
|
|
7
|
+
- Interupts click on button
|
|
8
|
+
- Uses native Dialog-Element (unstyled)
|
|
9
|
+
- Has a translated default confirm text
|
|
10
|
+
- Lightweight
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<form u2-confirm="Save name?" target=_blank>
|
|
16
|
+
<label><input name=name></label>
|
|
17
|
+
<button>confirm</button>
|
|
18
|
+
</form>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/attr/confirm/confirm.min.js" type=module async></script>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Demos
|
|
28
|
+
|
|
29
|
+
[minimal.html](http://gcdn.li/u2ui/u2@main/attr/confirm/tests/minimal.html)
|
|
30
|
+
[test.html](http://gcdn.li/u2ui/u2@main/attr/confirm/tests/test.html)
|
|
31
|
+
|
|
32
|
+
## About
|
|
33
|
+
|
|
34
|
+
- MIT License, Copyright (c) 2022 <u2> (like all repositories in this organization) <br>
|
|
35
|
+
- Suggestions, ideas, finding bugs and making pull requests make us very happy. ♥
|
|
36
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
|
|
2
|
+
let resentConfirmed = false;
|
|
3
|
+
|
|
4
|
+
// submit
|
|
5
|
+
// todo: test if it works inside shadow dom
|
|
6
|
+
|
|
7
|
+
document.addEventListener('submit', e=>{
|
|
8
|
+
if (resentConfirmed) return; // dont check again
|
|
9
|
+
const form = e.target;
|
|
10
|
+
const btn = e.submitter;
|
|
11
|
+
let element = null;
|
|
12
|
+
if (form.hasAttribute('u2-confirm')) element = form;
|
|
13
|
+
if (btn && btn.hasAttribute('u2-confirm')) element = btn;
|
|
14
|
+
if (!element) return;
|
|
15
|
+
confirmEvent(e, element, ()=> form.requestSubmit(btn) );
|
|
16
|
+
},true);
|
|
17
|
+
|
|
18
|
+
// click
|
|
19
|
+
document.addEventListener('click', e=>{
|
|
20
|
+
if (resentConfirmed) return;
|
|
21
|
+
|
|
22
|
+
//const target = e.target;
|
|
23
|
+
const target = e.composedPath()[0];
|
|
24
|
+
|
|
25
|
+
const element = target.closest('button[u2-confirm]');
|
|
26
|
+
if (!element) return;
|
|
27
|
+
if (element.form && element.type==='submit') return; // handled by submit event. What about "reset"?
|
|
28
|
+
confirmEvent(e, element, ()=> element.click() );
|
|
29
|
+
},true);
|
|
30
|
+
|
|
31
|
+
async function confirmEvent(e, element, then){
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
e.stopImmediatePropagation();
|
|
34
|
+
const {confirm} = await import('../../js/dialog/dialog.js');
|
|
35
|
+
const lang = langOf(element);
|
|
36
|
+
const ok = await confirm({
|
|
37
|
+
body: getMessage(element, lang),
|
|
38
|
+
lang,
|
|
39
|
+
});
|
|
40
|
+
if (ok) {
|
|
41
|
+
resentConfirmed = true;
|
|
42
|
+
then();
|
|
43
|
+
resentConfirmed = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getMessage(el, lang) {
|
|
48
|
+
// get lang of el
|
|
49
|
+
let msg = el.getAttribute('u2-confirm');
|
|
50
|
+
if (msg) return msg;
|
|
51
|
+
msg = sure[lang];
|
|
52
|
+
if (msg) return msg;
|
|
53
|
+
console.warn('no translation for lang "'+lang+'" in confirm.js. Please report!');
|
|
54
|
+
return sure.en;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function langOf(el) {
|
|
58
|
+
return el.closest('[lang]')?.getAttribute('lang') || navigator.language.substring(0,2) || 'en';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const sure = {
|
|
62
|
+
en: 'Are you sure?',
|
|
63
|
+
de: 'Sind Sie sicher?',
|
|
64
|
+
fr: 'Êtes-vous sûr?',
|
|
65
|
+
es: '¿Estás seguro?',
|
|
66
|
+
it: 'Sei sicuro?',
|
|
67
|
+
pt: 'Tem certeza?',
|
|
68
|
+
ua: 'Ви впевнені?',
|
|
69
|
+
ru: 'Вы уверены?',
|
|
70
|
+
ja: '本気ですか?',
|
|
71
|
+
ko: '확실합니까?',
|
|
72
|
+
zh: '你确定吗?',
|
|
73
|
+
nl: 'Weet je het zeker?',
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
/* TODO: button and link confirm?
|
|
78
|
+
document.addEventListener('click', async e=>{
|
|
79
|
+
if (resentConfirmed) return;
|
|
80
|
+
let element = e.target.closest('[u2-confirm]');
|
|
81
|
+
if (!element) return;
|
|
82
|
+
if (element.form || element.tagName === 'FORM') {
|
|
83
|
+
console.log('handled by submit event');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
confirmEvent(e, element, ()=>
|
|
87
|
+
element.click()
|
|
88
|
+
);
|
|
89
|
+
},true);
|
|
90
|
+
*/
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "README.md",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "confirm.js",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"// kind": "class",
|
|
11
|
+
"description": "Show confirm dialog before click triggers or form submission",
|
|
12
|
+
"name": "u2-confirm",
|
|
13
|
+
"members": [],
|
|
14
|
+
"events": [],
|
|
15
|
+
"attributes": [
|
|
16
|
+
{
|
|
17
|
+
"name": "u2-confirm",
|
|
18
|
+
"description": "If set to true, the confirm will be shown before click triggers or the associated form is submitted. Its value may be a string to be used as the message to show in the confirm dialog. The attribute works for buttons and form-elements.",
|
|
19
|
+
"u2Examples": ["", "Are you sure you want to delete this item?"]
|
|
20
|
+
},{
|
|
21
|
+
"name": "lang",
|
|
22
|
+
"description": "The language to use for internationalization",
|
|
23
|
+
"u2Examples": ["en-US","fr-FR","de-DE","es-ES","it-IT","ja-JP","ko-KR","zh-CN","zh-TW"]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"cssProperties": [],
|
|
27
|
+
"attributeName": "u2-confirm"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"exports": [
|
|
31
|
+
{
|
|
32
|
+
"kind": "custom-attribute-definition",
|
|
33
|
+
"name": "u2-confirm",
|
|
34
|
+
"declaration": {
|
|
35
|
+
"name": "u2-confirm",
|
|
36
|
+
"module": "confirm.js"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
|