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
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
<!DOCTYPE HTML>
|
|
2
|
+
<html lang=en>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name=viewport content="width=device-width">
|
|
6
|
+
<title>Test</title>
|
|
7
|
+
<script src="../../../u2/tests/test-init.js" type=module async></script>
|
|
8
|
+
<!-- <script src="../../u2/auto.js" type=module async></script> -->
|
|
9
|
+
|
|
10
|
+
<link rel=stylesheet href="../../../css/classless/full.css">
|
|
11
|
+
<link rel=stylesheet href="../../../css/classless/simple.css">
|
|
12
|
+
|
|
13
|
+
<script src="../../../el/code/code.js" type=module async></script>
|
|
14
|
+
<link href="../../../el/code/code.css" rel=stylesheet>
|
|
15
|
+
<script src="../../../el/tooltip/tooltip.js" type=module async></script>
|
|
16
|
+
<link href="../../../el/tooltip/tooltip.css" rel=stylesheet>
|
|
17
|
+
<script src="../../../el/ico/ico.js" type=module async></script>
|
|
18
|
+
<link href="../../../el/ico/ico.css" rel=stylesheet>
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
body {
|
|
22
|
+
place-content: initial;
|
|
23
|
+
--u2-ico-dir:'https://cdn.jsdelivr.net/npm/@material-icons/svg@1.0.11/svg/{icon}/baseline.svg';
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
26
|
+
|
|
27
|
+
<script src="../tree1.js" type=module async></script>
|
|
28
|
+
<link href="../tree1.css" rel=stylesheet>
|
|
29
|
+
|
|
30
|
+
<body>
|
|
31
|
+
|
|
32
|
+
<section id=demo class=main>
|
|
33
|
+
|
|
34
|
+
<u2-tree1 aria-expanded=true>root
|
|
35
|
+
<u2-tree1 aria-expanded=true>Folder 2
|
|
36
|
+
|
|
37
|
+
<u2-tree1>File 2.1</u2-tree1>
|
|
38
|
+
<u2-tree1>Folder 2.2
|
|
39
|
+
<u2-tree1>
|
|
40
|
+
<u2-ico slot=icon icon=home>x</u2-ico>
|
|
41
|
+
Home
|
|
42
|
+
</u2-tree1>
|
|
43
|
+
<u2-tree1>
|
|
44
|
+
<u2-ico slot=icon icon=star>x</u2-ico>
|
|
45
|
+
Star
|
|
46
|
+
</u2-tree1>
|
|
47
|
+
<u2-tree1>
|
|
48
|
+
<u2-ico slot=icon icon=search>x</u2-ico>
|
|
49
|
+
Search
|
|
50
|
+
</u2-tree1>
|
|
51
|
+
<u2-tree1>
|
|
52
|
+
<u2-ico slot=icon icon=accessible>x</u2-ico>
|
|
53
|
+
Accessible
|
|
54
|
+
</u2-tree1>
|
|
55
|
+
<u2-tree1>
|
|
56
|
+
<u2-ico slot=icon icon=alarm>x</u2-ico>
|
|
57
|
+
<u2-tooltip tabindex=-1 style="padding:0">
|
|
58
|
+
<table>
|
|
59
|
+
<tr>
|
|
60
|
+
<td>ID:
|
|
61
|
+
<td>22
|
|
62
|
+
<tr>
|
|
63
|
+
<td>Module:
|
|
64
|
+
<td>cms.cont.text
|
|
65
|
+
<tr>
|
|
66
|
+
<td>Name:
|
|
67
|
+
<td>Text
|
|
68
|
+
</table>
|
|
69
|
+
</u2-tooltip>
|
|
70
|
+
Alarm
|
|
71
|
+
</u2-tree1>
|
|
72
|
+
</u2-tree1>
|
|
73
|
+
<u2-tree1 draggable="true">
|
|
74
|
+
<u2-ico slot=icon icon=drag_indicator>x</u2-ico>
|
|
75
|
+
<label>
|
|
76
|
+
Draggable
|
|
77
|
+
<input placeholder="same baseline">
|
|
78
|
+
</label>
|
|
79
|
+
<button>clickable</button>
|
|
80
|
+
</u2-tree1>
|
|
81
|
+
|
|
82
|
+
<u2-tree1>
|
|
83
|
+
<input type=checkbox slot=icon id="check1">
|
|
84
|
+
Checkbox
|
|
85
|
+
<u2-tree1>
|
|
86
|
+
<input type=checkbox slot=icon id="check2">
|
|
87
|
+
Checkbox
|
|
88
|
+
</u2-tree1>
|
|
89
|
+
<u2-tree1>
|
|
90
|
+
<input type=checkbox slot=icon id="check3">
|
|
91
|
+
Checkbox
|
|
92
|
+
</u2-tree1>
|
|
93
|
+
</u2-tree1>
|
|
94
|
+
|
|
95
|
+
</u2-tree1>
|
|
96
|
+
<u2-tree1 aria-expanded=false aria-live=off>
|
|
97
|
+
Folder 3 (dynamic)
|
|
98
|
+
</u2-tree1>
|
|
99
|
+
</u2-tree1>
|
|
100
|
+
|
|
101
|
+
</section>
|
|
102
|
+
|
|
103
|
+
<section>
|
|
104
|
+
|
|
105
|
+
<u2-code element=demo editable trim> </u2-code>
|
|
106
|
+
|
|
107
|
+
<u2-code trim editable>
|
|
108
|
+
<style class=main>
|
|
109
|
+
u2-tree1::part(row) {
|
|
110
|
+
border-radius:.3rem;
|
|
111
|
+
}
|
|
112
|
+
u2-tree1:focus::part(row) {
|
|
113
|
+
outline:.1rem solid var(--color);
|
|
114
|
+
background:transparent;
|
|
115
|
+
}
|
|
116
|
+
u2-tree1[aria-selected=true]::part(row) {
|
|
117
|
+
background:#00000008;
|
|
118
|
+
}
|
|
119
|
+
u2-tree1::part(row):hover {
|
|
120
|
+
background:#00000004;
|
|
121
|
+
}
|
|
122
|
+
u2-tree1[aria-grabbed=true] {
|
|
123
|
+
transition:.2s .2s;
|
|
124
|
+
opacity:.4;
|
|
125
|
+
outline-width:0 !important;
|
|
126
|
+
}
|
|
127
|
+
</style>
|
|
128
|
+
</u2-code>
|
|
129
|
+
|
|
130
|
+
<u2-code trim>
|
|
131
|
+
<script type=module class=main>
|
|
132
|
+
/* load dynamic items */
|
|
133
|
+
document.addEventListener('u2-tree1-expand', event => {
|
|
134
|
+
const treeItem = event.target;
|
|
135
|
+
|
|
136
|
+
// if load is present, it requires a (async) function that loads the items
|
|
137
|
+
// (indicated by `aria-expanded=false` and `aria-live=off`)
|
|
138
|
+
//event.load?.(loadItems(treeItem)); zzz
|
|
139
|
+
event.load?.(loadItems);
|
|
140
|
+
});
|
|
141
|
+
const loadItems = async (item) => {
|
|
142
|
+
await delay(600);
|
|
143
|
+
item.innerHTML += '<u2-tree1><span slot=icon>🖼</span>Dynamic File 1</u2-tree1>';
|
|
144
|
+
item.innerHTML += '<u2-tree1><span slot=icon>📄</span>Document</u2-tree1>';
|
|
145
|
+
item.innerHTML += '<u2-tree1 aria-expanded=false aria-live=off>Folder</u2-tree1>';
|
|
146
|
+
}
|
|
147
|
+
</script>
|
|
148
|
+
</u2-code>
|
|
149
|
+
|
|
150
|
+
<script>
|
|
151
|
+
delay = function(ms) {
|
|
152
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
</section>
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
<script type=module>
|
|
161
|
+
/* drag & drop experiment */
|
|
162
|
+
|
|
163
|
+
const dropPositionIndicator = document.createElement('div');
|
|
164
|
+
dropPositionIndicator.innerHTML = '➔';
|
|
165
|
+
dropPositionIndicator.style.display = 'none';
|
|
166
|
+
dropPositionIndicator.style.position = 'absolute';
|
|
167
|
+
dropPositionIndicator.style.pointerEvents = 'none';
|
|
168
|
+
dropPositionIndicator.style.zIndex = 1000;
|
|
169
|
+
dropPositionIndicator.style.fontSize = '1.2rem';
|
|
170
|
+
dropPositionIndicator.style.transform = 'translate(0, -50%)';
|
|
171
|
+
document.body.appendChild(dropPositionIndicator);
|
|
172
|
+
|
|
173
|
+
let dragSrcEl = null;
|
|
174
|
+
|
|
175
|
+
const dragAndDropHandler = {
|
|
176
|
+
handleEvent(event) {
|
|
177
|
+
if (event.type !== 'dragstart' && !dragSrcEl) return;
|
|
178
|
+
if (!this['on' + event.type]) return
|
|
179
|
+
const target = event.target;
|
|
180
|
+
const closest = target.closest('u2-tree1');
|
|
181
|
+
if (!closest) return;
|
|
182
|
+
this['on' + event.type]({closest, target, event});
|
|
183
|
+
},
|
|
184
|
+
ondragstart({target, event}) {
|
|
185
|
+
if (target.tagName !== 'U2-TREE1') return;
|
|
186
|
+
dragSrcEl = target;
|
|
187
|
+
dragSrcEl.setAttribute('aria-grabbed', 'true'); // deprecated, but currently the best markup?
|
|
188
|
+
event.dataTransfer.effectAllowed = 'move'; // needed?
|
|
189
|
+
},
|
|
190
|
+
ondragover({closest, event}) {
|
|
191
|
+
event.preventDefault();
|
|
192
|
+
|
|
193
|
+
this.currentParent = closest;
|
|
194
|
+
this.currentNext = null;
|
|
195
|
+
|
|
196
|
+
const oHeight = closest.offsetHeight;
|
|
197
|
+
if (event.offsetY < oHeight * .2) {
|
|
198
|
+
this.currentParent = closest.parentNode;
|
|
199
|
+
this.currentNext = closest;
|
|
200
|
+
}
|
|
201
|
+
if (event.offsetY > oHeight * .7) {
|
|
202
|
+
this.currentParent = closest.parentNode;
|
|
203
|
+
this.currentNext = closest.nextElementSibling;
|
|
204
|
+
}
|
|
205
|
+
if (this.currentParent === closest && !this.expandTimer) {
|
|
206
|
+
this.resetExpandTimer(this.currentParent);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// indicator
|
|
210
|
+
let x = closest.shadowRoot.querySelector('[name=icon]').getBoundingClientRect().left - 50;
|
|
211
|
+
let y;
|
|
212
|
+
if (this.currentNext) {
|
|
213
|
+
y = this.currentNext.offsetTop;
|
|
214
|
+
} else {
|
|
215
|
+
y = closest.offsetTop + closest.offsetHeight / 2;
|
|
216
|
+
}
|
|
217
|
+
dropPositionIndicator.style.display = 'block';
|
|
218
|
+
dropPositionIndicator.style.top = y + 'px';
|
|
219
|
+
dropPositionIndicator.style.left = x + 'px';
|
|
220
|
+
},
|
|
221
|
+
ondragleave({closest}) {
|
|
222
|
+
this.resetExpandTimer();
|
|
223
|
+
closest.style.borderColor = 'transparent';
|
|
224
|
+
},
|
|
225
|
+
ondrop({closest, event}) {
|
|
226
|
+
event.stopPropagation();
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
if (dragSrcEl !== closest) {
|
|
229
|
+
if (this.currentParent && dragSrcEl !== this.currentNext) {
|
|
230
|
+
if (this.currentNext) {
|
|
231
|
+
this.currentParent.insertBefore(dragSrcEl, this.currentNext);
|
|
232
|
+
} else {
|
|
233
|
+
this.currentParent.appendChild(dragSrcEl);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
closest.toggleExpand(true);
|
|
237
|
+
}
|
|
238
|
+
closest.style.border = '';
|
|
239
|
+
},
|
|
240
|
+
ondragend() {
|
|
241
|
+
dropPositionIndicator.style.display = 'none';
|
|
242
|
+
dragSrcEl.removeAttribute('aria-grabbed');
|
|
243
|
+
dragSrcEl = null;
|
|
244
|
+
},
|
|
245
|
+
resetExpandTimer(item) {
|
|
246
|
+
clearTimeout(this.expandTimer);
|
|
247
|
+
this.expandTimer = null;
|
|
248
|
+
if (item) {
|
|
249
|
+
this.expandTimer = setTimeout(()=>{
|
|
250
|
+
this.expandTimer = null;
|
|
251
|
+
this.currentParent.toggleExpand(true);
|
|
252
|
+
}, 500);
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
['dragstart', 'dragover', 'dragenter','dragleave', 'drop', 'dragend'].forEach(eventType => {
|
|
257
|
+
document.addEventListener(eventType, dragAndDropHandler, false);
|
|
258
|
+
});
|
|
259
|
+
</script>
|
|
260
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
u2-tree1 {
|
|
2
|
+
display:block;
|
|
3
|
+
}
|
|
4
|
+
u2-tree1::part(row) {
|
|
5
|
+
white-space: nowrap;
|
|
6
|
+
cursor:pointer;
|
|
7
|
+
}
|
|
8
|
+
u2-tree1::part(row):focus {
|
|
9
|
+
outline:1px dotted black;
|
|
10
|
+
}
|
|
11
|
+
u2-tree1[aria-selected=true]::part(row) {
|
|
12
|
+
background:#00000008;
|
|
13
|
+
}
|
|
14
|
+
u2-tree1[draggable]::part(row) {
|
|
15
|
+
cursor:grab;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
u2-tree1:not(:defined) {
|
|
20
|
+
padding-block-start:.2em;
|
|
21
|
+
display:list-item;
|
|
22
|
+
list-style-position: inside;
|
|
23
|
+
> u2-tree1 {
|
|
24
|
+
padding-inline-start:1.2em;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
let css = `
|
|
2
|
+
:host {
|
|
3
|
+
display:block;
|
|
4
|
+
}
|
|
5
|
+
:host([role=tree]) {
|
|
6
|
+
--indent:1rem;
|
|
7
|
+
}
|
|
8
|
+
:host(:not([aria-expanded=true])) [part=children] {
|
|
9
|
+
display:none;
|
|
10
|
+
}
|
|
11
|
+
:host([aria-expanded=true]) .arrow::after { content:'▾' }
|
|
12
|
+
:host(:not([aria-expanded])) .arrow { opacity:0; }
|
|
13
|
+
:host([aria-expanded=true][aria-busy=true]) .arrow::after {
|
|
14
|
+
content:'◠'; /* ◝↻⭮⍉🔾◠◡◕◖◝ */
|
|
15
|
+
font-weight:bold;
|
|
16
|
+
animation: spinner .5s linear infinite;
|
|
17
|
+
line-height:1;
|
|
18
|
+
font-size:.8em;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
[part=row] {
|
|
22
|
+
display:flex;
|
|
23
|
+
align-items:baseline;
|
|
24
|
+
padding-block: .15em;
|
|
25
|
+
padding-inline-start:calc( var(--indent) * (var(--level) - 1) );
|
|
26
|
+
gap:.3em;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.arrow {
|
|
30
|
+
font-weight:normal !important;
|
|
31
|
+
min-width:1.1em;
|
|
32
|
+
text-align:center;
|
|
33
|
+
}
|
|
34
|
+
.arrow::after { content:'▸'; }
|
|
35
|
+
.arrow::after { display:inline-block; }
|
|
36
|
+
@keyframes spinner { to { transform:rotate(360deg) } }
|
|
37
|
+
|
|
38
|
+
[name=icon] {
|
|
39
|
+
display:flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content:center;
|
|
42
|
+
min-inline-size:1.7em;
|
|
43
|
+
font-weight:400;
|
|
44
|
+
align-self:stretch;
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export class tree extends HTMLElement {
|
|
50
|
+
//#internals;
|
|
51
|
+
constructor() {
|
|
52
|
+
super();
|
|
53
|
+
const shadow = this.attachShadow({mode: 'open', delegatesFocus: true});
|
|
54
|
+
//this.#internals = this.attachInternals();
|
|
55
|
+
shadow.innerHTML = `
|
|
56
|
+
<style>${css}</style>
|
|
57
|
+
<div part=row tabindex=-1>
|
|
58
|
+
<span class=arrow></span>
|
|
59
|
+
<slot name=icon>📁</slot>
|
|
60
|
+
<slot part=content></slot>
|
|
61
|
+
</div>
|
|
62
|
+
<slot part=children name=children role=group part=group></slot>`
|
|
63
|
+
|
|
64
|
+
this.row = shadow.querySelector('[part=row]');
|
|
65
|
+
|
|
66
|
+
this.addEventListener('click',e=>{
|
|
67
|
+
if (e.target !== this) return;
|
|
68
|
+
if (!getSelection()?.isCollapsed) return;
|
|
69
|
+
this.toggleExpand();
|
|
70
|
+
this.activeElement = this;
|
|
71
|
+
this._select();
|
|
72
|
+
});
|
|
73
|
+
this.addEventListener('keydown',e=>{
|
|
74
|
+
if (e.target !== this) return;
|
|
75
|
+
let fn = {
|
|
76
|
+
ArrowUp: ()=> this.prevFocusable()?.setFocus(),
|
|
77
|
+
ArrowDown: ()=> this.nextFocusable()?.setFocus(),
|
|
78
|
+
ArrowRight: ()=> !this.isExpanded() ? this.toggleExpand(true) : this.nextFocusable()?.setFocus(),
|
|
79
|
+
ArrowLeft: ()=> this.isExpanded() ? this.toggleExpand(false) : this.parentNode.setFocus?.(),
|
|
80
|
+
Enter: ()=> {this._select(); this.toggleExpand(); }, // todo toggle?
|
|
81
|
+
' ': ()=> this._select(),
|
|
82
|
+
Home: ()=> this.root().setFocus(),
|
|
83
|
+
}[e.key];
|
|
84
|
+
// focus next where text starts with the key pressed
|
|
85
|
+
const isChar = /^.$/u.test(e.key);
|
|
86
|
+
if (isChar) {
|
|
87
|
+
let current = this.nextFocusable() || this.root();
|
|
88
|
+
while (current && current !== this) {
|
|
89
|
+
let text = current.shadowRoot.querySelector('[part=content]').assignedNodes().map(item=>item.textContent).join(' ').trim().toLowerCase();
|
|
90
|
+
if (text.startsWith(e.key)) {
|
|
91
|
+
current.setFocus();
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
current = current.nextFocusable() || this.root();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (fn) {
|
|
98
|
+
fn();
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
this.addEventListener('mousedown',e=>{ // prevent dbl-click selection
|
|
104
|
+
if (e.detail >= 2) e.preventDefault();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
this.childrenObserver = new MutationObserver(mutations=>{
|
|
108
|
+
this._markup();
|
|
109
|
+
}).observe(this, {childList: true});
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
}
|
|
113
|
+
connectedCallback() {
|
|
114
|
+
this._markup();
|
|
115
|
+
}
|
|
116
|
+
_markup(){
|
|
117
|
+
// own level
|
|
118
|
+
const root = this.root();
|
|
119
|
+
const myLevel = root === this ? 1 : parseInt(this.parentNode.getAttribute('aria-level')) + 1;
|
|
120
|
+
this.setAttribute('aria-level', myLevel); // todo: internals?
|
|
121
|
+
this.style.setProperty('--level', myLevel);
|
|
122
|
+
|
|
123
|
+
// slot subnodes
|
|
124
|
+
for (const child of this.children) {
|
|
125
|
+
child.tagName === this.tagName && child.setAttribute('slot', 'children');
|
|
126
|
+
}
|
|
127
|
+
this.setAttribute('role', root === this ? 'tree' : 'treeitem');
|
|
128
|
+
//this.#internals.role = root === this ? 'tree' : 'treeitem';
|
|
129
|
+
|
|
130
|
+
// make it selectable if its the root and no other is selected
|
|
131
|
+
if (root === this && !root._activeElement) {
|
|
132
|
+
this.row.setAttribute('tabindex', '0');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// if has children, its expandable
|
|
136
|
+
if (!this.hasAttribute('aria-expanded')) {
|
|
137
|
+
if (this.items().length) {
|
|
138
|
+
this.setAttribute('aria-expanded', 'false');
|
|
139
|
+
} else {
|
|
140
|
+
this.removeAttribute('aria-expanded');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
items(){
|
|
145
|
+
return this.shadowRoot.querySelector('[part=children]').assignedElements();
|
|
146
|
+
}
|
|
147
|
+
nextFocusable(){
|
|
148
|
+
let item = this;
|
|
149
|
+
while (item) {
|
|
150
|
+
let next = null;
|
|
151
|
+
if (item.isExpanded()) {
|
|
152
|
+
next = item.items().at(0);
|
|
153
|
+
}
|
|
154
|
+
if (!next) next = item.nextElementSibling; // todo: only next treeitem
|
|
155
|
+
|
|
156
|
+
if (!next) {
|
|
157
|
+
while (item.parentNode) {
|
|
158
|
+
item = item.parentNode;
|
|
159
|
+
if (item.nextElementSibling) {
|
|
160
|
+
next = item.nextElementSibling;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (next.tagName !== this.tagName) return null;
|
|
167
|
+
if (next) return next;
|
|
168
|
+
item = next;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
prevFocusable(){
|
|
172
|
+
let item = this;
|
|
173
|
+
while (item) {
|
|
174
|
+
let next = item.previousElementSibling; // todo: only next treeitem
|
|
175
|
+
if (next) {
|
|
176
|
+
if (next.isExpanded()) {
|
|
177
|
+
next = next.items().at(-1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (!next) next = item.parentNode;
|
|
181
|
+
if (next) return next;
|
|
182
|
+
item = next;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
isExpanded() {
|
|
186
|
+
return this.getAttribute('aria-expanded') === 'true';
|
|
187
|
+
}
|
|
188
|
+
isExpandable() {
|
|
189
|
+
const attr = this.getAttribute('aria-expanded');
|
|
190
|
+
return attr === 'true' || attr === 'false' || this.items().length;
|
|
191
|
+
}
|
|
192
|
+
toggleExpand(doit) {
|
|
193
|
+
if (!this.isExpandable()) return;
|
|
194
|
+
if (doit == null) doit = !this.isExpanded();
|
|
195
|
+
|
|
196
|
+
const event = new CustomEvent(doit?'u2-tree1-expand':'u2-tree1-collapse', {bubbles: true});
|
|
197
|
+
if (this.getAttribute('aria-live') && this.getAttribute('aria-busy') !== 'true') {
|
|
198
|
+
|
|
199
|
+
event.load = fn=>{
|
|
200
|
+
|
|
201
|
+
let promise;
|
|
202
|
+
if (typeof fn.then === 'function') {
|
|
203
|
+
console.warn('event.load(promise) is deprecated, use event.load(fn)');
|
|
204
|
+
promise = fn;
|
|
205
|
+
} else {
|
|
206
|
+
promise = fn(this);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
this.setAttribute('aria-busy','true');
|
|
210
|
+
promise.then(data => {
|
|
211
|
+
this.removeAttribute('aria-live');
|
|
212
|
+
this.removeAttribute('aria-busy');
|
|
213
|
+
setTimeout(()=>{ // make unexpandable if no children
|
|
214
|
+
!this.items().length && this.removeAttribute('aria-expanded');
|
|
215
|
+
},100);
|
|
216
|
+
}).catch(data=>{
|
|
217
|
+
console.warn('todo: u2-tree: failed to load', data);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
this.dispatchEvent(event);
|
|
223
|
+
this.setAttribute('aria-expanded', doit?'true':'false');
|
|
224
|
+
}
|
|
225
|
+
root(){
|
|
226
|
+
return this.isRoot() ? this : this.parentNode.root();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
select(){
|
|
230
|
+
let old = this.root()._selected;
|
|
231
|
+
if (old) old.setAttribute('aria-selected', 'false');
|
|
232
|
+
this.setAttribute('aria-selected', 'true');
|
|
233
|
+
this.root()._selected = this;
|
|
234
|
+
}
|
|
235
|
+
_select(){ // like selected but also fires event
|
|
236
|
+
const event = new CustomEvent('u2-tree1-select', {bubbles: true});
|
|
237
|
+
this.dispatchEvent(event);
|
|
238
|
+
this.select();
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
get activeElement(){
|
|
242
|
+
return this.root()._activeElement;
|
|
243
|
+
}
|
|
244
|
+
set activeElement(el){
|
|
245
|
+
const old = this.root()._activeElement;
|
|
246
|
+
if (old) old.row.setAttribute('tabindex', '-1');
|
|
247
|
+
el.row.setAttribute('tabindex', '0');
|
|
248
|
+
el.row.focus();
|
|
249
|
+
this.root()._activeElement = el;
|
|
250
|
+
}
|
|
251
|
+
setFocus() {
|
|
252
|
+
this.activeElement = this;
|
|
253
|
+
}
|
|
254
|
+
isRoot(){
|
|
255
|
+
return this.parentNode.tagName !== this.tagName;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
path(){
|
|
259
|
+
if (this.isRoot()) return [this];
|
|
260
|
+
return this.parentNode.path().concat(this);
|
|
261
|
+
// return this.isRoot() ? [this] : [...this.parentNode.path(), this]; // as we dont cache, we dont have to make a copy
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
customElements.define('u2-tree1', tree);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# <u2-typewriter> - element
|
|
2
|
+
Simple typewriter element
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
|
|
6
|
+
```html
|
|
7
|
+
<h2>
|
|
8
|
+
<u2-typewriter autoplay loop>Typewriter</h2></u2-typewriter>
|
|
9
|
+
</h2>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```css
|
|
13
|
+
u2-typewriter {
|
|
14
|
+
--u2-typewriter-speed:100;
|
|
15
|
+
}
|
|
16
|
+
u2-typewriter h2 .-Caret {
|
|
17
|
+
color:hotpink;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## API
|
|
22
|
+
|
|
23
|
+
### Attributes
|
|
24
|
+
|
|
25
|
+
- `autostart`: starts if in viewport, stops if out of viewport
|
|
26
|
+
- `loop`: restarts if at end
|
|
27
|
+
- `audio`: plays audio="writer.mp3". If not attribute-value, a default audio is used.
|
|
28
|
+
|
|
29
|
+
### Javascript
|
|
30
|
+
|
|
31
|
+
- element.play()
|
|
32
|
+
- element.pause()
|
|
33
|
+
- element.reset()
|
|
34
|
+
- event "u2-typewriter-end"
|
|
35
|
+
|
|
36
|
+
### CSS
|
|
37
|
+
|
|
38
|
+
There no default CSS that will affect your styles.
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
u2-typewriter .-Char { ... } /* the char */
|
|
42
|
+
u2-typewriter .-Active .-Char { ... } /* the active char */
|
|
43
|
+
u2-typewriter .-Caret { ... } /* the caret (It moves and is in the active char element) */
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<link href="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/el/typewriter/typewriter.min.css" rel=stylesheet>
|
|
50
|
+
<script src="https://cdn.jsdelivr.net/gh/u2ui/u2@x.x.x/el/typewriter/typewriter.min.js" type=module async></script>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Demos
|
|
54
|
+
|
|
55
|
+
[minimal.html](http://gcdn.li/u2ui/u2@main/el/typewriter/tests/minimal.html)
|
|
56
|
+
[test.html](http://gcdn.li/u2ui/u2@main/el/typewriter/tests/test.html)
|
|
57
|
+
|
|
58
|
+
## About
|
|
59
|
+
|
|
60
|
+
- MIT License, Copyright (c) 2022 <u2> (like all repositories in this organization) <br>
|
|
61
|
+
- Suggestions, ideas, finding bugs and making pull requests make us very happy. ♥
|
|
62
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "README.md",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "typewriter.js",
|
|
8
|
+
"declarations": [
|
|
9
|
+
{
|
|
10
|
+
"kind": "class",
|
|
11
|
+
"description": "",
|
|
12
|
+
"name": "carousel",
|
|
13
|
+
"members": [
|
|
14
|
+
{
|
|
15
|
+
"kind": "method",
|
|
16
|
+
"name": "play"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"events": [
|
|
20
|
+
{
|
|
21
|
+
"name": "u2-typewriter-play",
|
|
22
|
+
"type": {
|
|
23
|
+
"text": "Event"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "u2-typewriter-end",
|
|
28
|
+
"type": {
|
|
29
|
+
"text": "Event"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "u2-typewriter-pause",
|
|
34
|
+
"type": {
|
|
35
|
+
"text": "Event"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"attributes": [
|
|
40
|
+
{
|
|
41
|
+
"name": "autoplay",
|
|
42
|
+
"u2-type": "boolean"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "loop",
|
|
46
|
+
"u2-type": "boolean"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"superclass": { "name": "HTMLElement" },
|
|
50
|
+
"tagName": "u2-typewriter",
|
|
51
|
+
"customElement": true
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"exports": [
|
|
55
|
+
{
|
|
56
|
+
"kind": "custom-element-definition",
|
|
57
|
+
"name": "u2-typewriter",
|
|
58
|
+
"declaration": {
|
|
59
|
+
"name": "MyElement",
|
|
60
|
+
"module": "typewriter.js"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|