tosijs-ui 1.4.0 → 1.4.2
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/dist/ab-test.d.ts +1 -0
- package/dist/ab-test.js +113 -0
- package/dist/babylon-3d.d.ts +2 -1
- package/dist/babylon-3d.js +293 -0
- package/dist/bodymovin-player.d.ts +2 -1
- package/dist/bodymovin-player.js +172 -0
- package/dist/bp-loader.js +26 -0
- package/dist/carousel.d.ts +18 -1
- package/dist/carousel.js +307 -0
- package/dist/code-editor.d.ts +2 -1
- package/dist/code-editor.js +112 -0
- package/dist/color-input.d.ts +2 -1
- package/dist/color-input.js +110 -0
- package/dist/data-table.d.ts +52 -0
- package/dist/data-table.js +803 -0
- package/dist/dialog.d.ts +40 -0
- package/dist/dialog.js +268 -0
- package/dist/doc-browser.js +792 -0
- package/dist/drag-and-drop.js +428 -0
- package/dist/editable-rect.d.ts +2 -1
- package/dist/editable-rect.js +449 -0
- package/dist/filter-builder.d.ts +56 -0
- package/dist/filter-builder.js +470 -0
- package/dist/float.d.ts +4 -1
- package/dist/float.js +169 -0
- package/dist/form.d.ts +35 -1
- package/dist/form.js +721 -0
- package/dist/gamepad.js +135 -0
- package/dist/icon-data.js +315 -0
- package/dist/icon-types.js +1 -0
- package/dist/icons/data/activity.js +1 -0
- package/dist/icons/data/airplay.js +1 -0
- package/dist/icons/data/alertCircle.js +1 -0
- package/dist/icons/data/alertOctagon.js +1 -0
- package/dist/icons/data/alertTriangle.js +1 -0
- package/dist/icons/data/alignCenter.js +1 -0
- package/dist/icons/data/alignJustify.js +1 -0
- package/dist/icons/data/alignLeft.js +1 -0
- package/dist/icons/data/alignRight.js +1 -0
- package/dist/icons/data/anchor.js +1 -0
- package/dist/icons/data/aperture.js +1 -0
- package/dist/icons/data/archive.js +1 -0
- package/dist/icons/data/arrowDown.js +1 -0
- package/dist/icons/data/arrowDownCircle.js +1 -0
- package/dist/icons/data/arrowDownLeft.js +1 -0
- package/dist/icons/data/arrowDownRight.js +1 -0
- package/dist/icons/data/arrowLeft.js +1 -0
- package/dist/icons/data/arrowLeftCircle.js +1 -0
- package/dist/icons/data/arrowRight.js +1 -0
- package/dist/icons/data/arrowRightCircle.js +1 -0
- package/dist/icons/data/arrowUp.js +1 -0
- package/dist/icons/data/arrowUpCircle.js +1 -0
- package/dist/icons/data/arrowUpLeft.js +1 -0
- package/dist/icons/data/arrowUpRight.js +1 -0
- package/dist/icons/data/atSign.js +1 -0
- package/dist/icons/data/award.js +1 -0
- package/dist/icons/data/barChart.js +1 -0
- package/dist/icons/data/barChart2.js +1 -0
- package/dist/icons/data/battery.js +1 -0
- package/dist/icons/data/batteryCharging.js +1 -0
- package/dist/icons/data/bell.js +1 -0
- package/dist/icons/data/bellOff.js +1 -0
- package/dist/icons/data/blog.js +1 -0
- package/dist/icons/data/blueprint.js +1 -0
- package/dist/icons/data/bluetooth.js +1 -0
- package/dist/icons/data/bold.js +1 -0
- package/dist/icons/data/book.js +1 -0
- package/dist/icons/data/bookOpen.js +1 -0
- package/dist/icons/data/bookmark.js +1 -0
- package/dist/icons/data/box.js +1 -0
- package/dist/icons/data/briefcase.js +1 -0
- package/dist/icons/data/bug.js +1 -0
- package/dist/icons/data/calendar.js +1 -0
- package/dist/icons/data/camera.js +1 -0
- package/dist/icons/data/cameraOff.js +1 -0
- package/dist/icons/data/cast.js +1 -0
- package/dist/icons/data/check.js +1 -0
- package/dist/icons/data/checkCircle.js +1 -0
- package/dist/icons/data/checkSquare.js +1 -0
- package/dist/icons/data/chevronDown.js +1 -0
- package/dist/icons/data/chevronLeft.js +1 -0
- package/dist/icons/data/chevronRight.js +1 -0
- package/dist/icons/data/chevronUp.js +1 -0
- package/dist/icons/data/chevronsDown.js +1 -0
- package/dist/icons/data/chevronsLeft.js +1 -0
- package/dist/icons/data/chevronsRight.js +1 -0
- package/dist/icons/data/chevronsUp.js +1 -0
- package/dist/icons/data/chrome.js +1 -0
- package/dist/icons/data/circle.js +1 -0
- package/dist/icons/data/clipboard.js +1 -0
- package/dist/icons/data/clock.js +1 -0
- package/dist/icons/data/cloud.js +1 -0
- package/dist/icons/data/cloudDrizzle.js +1 -0
- package/dist/icons/data/cloudLightning.js +1 -0
- package/dist/icons/data/cloudOff.js +1 -0
- package/dist/icons/data/cloudRain.js +1 -0
- package/dist/icons/data/cloudSnow.js +1 -0
- package/dist/icons/data/cmy.js +1 -0
- package/dist/icons/data/code.js +1 -0
- package/dist/icons/data/codepen.js +1 -0
- package/dist/icons/data/codesandbox.js +1 -0
- package/dist/icons/data/coffee.js +1 -0
- package/dist/icons/data/columns.js +1 -0
- package/dist/icons/data/command.js +1 -0
- package/dist/icons/data/compass.js +1 -0
- package/dist/icons/data/copy.js +1 -0
- package/dist/icons/data/cornerDownLeft.js +1 -0
- package/dist/icons/data/cornerDownRight.js +1 -0
- package/dist/icons/data/cornerLeftDown.js +1 -0
- package/dist/icons/data/cornerLeftUp.js +1 -0
- package/dist/icons/data/cornerRightDown.js +1 -0
- package/dist/icons/data/cornerRightUp.js +1 -0
- package/dist/icons/data/cornerUpLeft.js +1 -0
- package/dist/icons/data/cornerUpRight.js +1 -0
- package/dist/icons/data/cpu.js +1 -0
- package/dist/icons/data/creditCard.js +1 -0
- package/dist/icons/data/crop.js +1 -0
- package/dist/icons/data/crosshair.js +1 -0
- package/dist/icons/data/database.js +1 -0
- package/dist/icons/data/delete.js +1 -0
- package/dist/icons/data/disc.js +1 -0
- package/dist/icons/data/discord.js +1 -0
- package/dist/icons/data/divide.js +1 -0
- package/dist/icons/data/divideCircle.js +1 -0
- package/dist/icons/data/divideSquare.js +1 -0
- package/dist/icons/data/dollarSign.js +1 -0
- package/dist/icons/data/download.js +1 -0
- package/dist/icons/data/downloadCloud.js +1 -0
- package/dist/icons/data/dribbble.js +1 -0
- package/dist/icons/data/droplet.js +1 -0
- package/dist/icons/data/earth.js +1 -0
- package/dist/icons/data/edit.js +1 -0
- package/dist/icons/data/edit2.js +1 -0
- package/dist/icons/data/edit3.js +1 -0
- package/dist/icons/data/externalLink.js +1 -0
- package/dist/icons/data/eye.js +1 -0
- package/dist/icons/data/eyeOff.js +1 -0
- package/dist/icons/data/facebook.js +1 -0
- package/dist/icons/data/fastForward.js +1 -0
- package/dist/icons/data/feather.js +1 -0
- package/dist/icons/data/figma.js +1 -0
- package/dist/icons/data/file.js +1 -0
- package/dist/icons/data/fileMinus.js +1 -0
- package/dist/icons/data/filePlus.js +1 -0
- package/dist/icons/data/fileText.js +1 -0
- package/dist/icons/data/film.js +1 -0
- package/dist/icons/data/filter.js +1 -0
- package/dist/icons/data/flag.js +1 -0
- package/dist/icons/data/folder.js +1 -0
- package/dist/icons/data/folderMinus.js +1 -0
- package/dist/icons/data/folderPlus.js +1 -0
- package/dist/icons/data/fontBold.js +1 -0
- package/dist/icons/data/fontItalic.js +1 -0
- package/dist/icons/data/fontUnderline.js +1 -0
- package/dist/icons/data/framer.js +1 -0
- package/dist/icons/data/frown.js +1 -0
- package/dist/icons/data/game.js +1 -0
- package/dist/icons/data/gift.js +1 -0
- package/dist/icons/data/gitBranch.js +1 -0
- package/dist/icons/data/gitCommit.js +1 -0
- package/dist/icons/data/gitMerge.js +1 -0
- package/dist/icons/data/gitPullRequest.js +1 -0
- package/dist/icons/data/github.js +1 -0
- package/dist/icons/data/gitlab.js +1 -0
- package/dist/icons/data/globe.js +1 -0
- package/dist/icons/data/google.js +1 -0
- package/dist/icons/data/grid.js +1 -0
- package/dist/icons/data/hardDrive.js +1 -0
- package/dist/icons/data/hash.js +1 -0
- package/dist/icons/data/headphones.js +1 -0
- package/dist/icons/data/heart.js +1 -0
- package/dist/icons/data/helpCircle.js +1 -0
- package/dist/icons/data/hexagon.js +1 -0
- package/dist/icons/data/home.js +1 -0
- package/dist/icons/data/image.js +1 -0
- package/dist/icons/data/inbox.js +1 -0
- package/dist/icons/data/indent.js +1 -0
- package/dist/icons/data/index.js +313 -0
- package/dist/icons/data/info.js +1 -0
- package/dist/icons/data/instagram.js +1 -0
- package/dist/icons/data/italic.js +1 -0
- package/dist/icons/data/key.js +1 -0
- package/dist/icons/data/layers.js +1 -0
- package/dist/icons/data/layout.js +1 -0
- package/dist/icons/data/lifeBuoy.js +1 -0
- package/dist/icons/data/link.js +1 -0
- package/dist/icons/data/link2.js +1 -0
- package/dist/icons/data/linkedin.js +1 -0
- package/dist/icons/data/list.js +1 -0
- package/dist/icons/data/listBullet.js +1 -0
- package/dist/icons/data/listNumber.js +1 -0
- package/dist/icons/data/loader.js +1 -0
- package/dist/icons/data/lock.js +1 -0
- package/dist/icons/data/logIn.js +1 -0
- package/dist/icons/data/logOut.js +1 -0
- package/dist/icons/data/mail.js +1 -0
- package/dist/icons/data/map.js +1 -0
- package/dist/icons/data/mapPin.js +1 -0
- package/dist/icons/data/maximize.js +1 -0
- package/dist/icons/data/maximize2.js +1 -0
- package/dist/icons/data/meh.js +1 -0
- package/dist/icons/data/menu.js +1 -0
- package/dist/icons/data/messageCircle.js +1 -0
- package/dist/icons/data/messageSquare.js +1 -0
- package/dist/icons/data/mic.js +1 -0
- package/dist/icons/data/micOff.js +1 -0
- package/dist/icons/data/minimize.js +1 -0
- package/dist/icons/data/minimize2.js +1 -0
- package/dist/icons/data/minus.js +1 -0
- package/dist/icons/data/minusCircle.js +1 -0
- package/dist/icons/data/minusSquare.js +1 -0
- package/dist/icons/data/monitor.js +1 -0
- package/dist/icons/data/moon.js +1 -0
- package/dist/icons/data/moreHorizontal.js +1 -0
- package/dist/icons/data/moreVertical.js +1 -0
- package/dist/icons/data/mousePointer.js +1 -0
- package/dist/icons/data/move.js +1 -0
- package/dist/icons/data/music.js +1 -0
- package/dist/icons/data/navigation.js +1 -0
- package/dist/icons/data/navigation2.js +1 -0
- package/dist/icons/data/npm.js +1 -0
- package/dist/icons/data/octagon.js +1 -0
- package/dist/icons/data/outdent.js +1 -0
- package/dist/icons/data/package.js +1 -0
- package/dist/icons/data/paperclip.js +1 -0
- package/dist/icons/data/pause.js +1 -0
- package/dist/icons/data/pauseCircle.js +1 -0
- package/dist/icons/data/penTool.js +1 -0
- package/dist/icons/data/percent.js +1 -0
- package/dist/icons/data/phone.js +1 -0
- package/dist/icons/data/phoneCall.js +1 -0
- package/dist/icons/data/phoneForwarded.js +1 -0
- package/dist/icons/data/phoneIncoming.js +1 -0
- package/dist/icons/data/phoneMissed.js +1 -0
- package/dist/icons/data/phoneOff.js +1 -0
- package/dist/icons/data/phoneOutgoing.js +1 -0
- package/dist/icons/data/pieChart.js +1 -0
- package/dist/icons/data/play.js +1 -0
- package/dist/icons/data/playCircle.js +1 -0
- package/dist/icons/data/plus.js +1 -0
- package/dist/icons/data/plusCircle.js +1 -0
- package/dist/icons/data/plusSquare.js +1 -0
- package/dist/icons/data/pocket.js +1 -0
- package/dist/icons/data/power.js +1 -0
- package/dist/icons/data/printer.js +1 -0
- package/dist/icons/data/radio.js +1 -0
- package/dist/icons/data/refreshCcw.js +1 -0
- package/dist/icons/data/refreshCw.js +1 -0
- package/dist/icons/data/repeat.js +1 -0
- package/dist/icons/data/resize.js +1 -0
- package/dist/icons/data/rewind.js +1 -0
- package/dist/icons/data/rgb.js +1 -0
- package/dist/icons/data/rotateCcw.js +1 -0
- package/dist/icons/data/rotateCw.js +1 -0
- package/dist/icons/data/rss.js +1 -0
- package/dist/icons/data/save.js +1 -0
- package/dist/icons/data/scissors.js +1 -0
- package/dist/icons/data/search.js +1 -0
- package/dist/icons/data/send.js +1 -0
- package/dist/icons/data/server.js +1 -0
- package/dist/icons/data/settings.js +1 -0
- package/dist/icons/data/share.js +1 -0
- package/dist/icons/data/share2.js +1 -0
- package/dist/icons/data/shield.js +1 -0
- package/dist/icons/data/shieldOff.js +1 -0
- package/dist/icons/data/shoppingBag.js +1 -0
- package/dist/icons/data/shoppingCart.js +1 -0
- package/dist/icons/data/shuffle.js +1 -0
- package/dist/icons/data/sidebar.js +1 -0
- package/dist/icons/data/skipBack.js +1 -0
- package/dist/icons/data/skipForward.js +1 -0
- package/dist/icons/data/slack.js +1 -0
- package/dist/icons/data/slash.js +1 -0
- package/dist/icons/data/sliders.js +1 -0
- package/dist/icons/data/smartphone.js +1 -0
- package/dist/icons/data/smile.js +1 -0
- package/dist/icons/data/sortAscending.js +1 -0
- package/dist/icons/data/sortDescending.js +1 -0
- package/dist/icons/data/speaker.js +1 -0
- package/dist/icons/data/square.js +1 -0
- package/dist/icons/data/star.js +1 -0
- package/dist/icons/data/stopCircle.js +1 -0
- package/dist/icons/data/sun.js +1 -0
- package/dist/icons/data/sunrise.js +1 -0
- package/dist/icons/data/sunset.js +1 -0
- package/dist/icons/data/table.js +1 -0
- package/dist/icons/data/tablet.js +1 -0
- package/dist/icons/data/tag.js +1 -0
- package/dist/icons/data/target.js +1 -0
- package/dist/icons/data/terminal.js +1 -0
- package/dist/icons/data/thermometer.js +1 -0
- package/dist/icons/data/thumbsDown.js +1 -0
- package/dist/icons/data/thumbsUp.js +1 -0
- package/dist/icons/data/toggleLeft.js +1 -0
- package/dist/icons/data/toggleRight.js +1 -0
- package/dist/icons/data/tool.js +1 -0
- package/dist/icons/data/tosi.js +1 -0
- package/dist/icons/data/tosiFavicon.js +1 -0
- package/dist/icons/data/tosiPlatform.js +1 -0
- package/dist/icons/data/tosiUi.js +1 -0
- package/dist/icons/data/tosiXr.js +1 -0
- package/dist/icons/data/trash.js +1 -0
- package/dist/icons/data/trash2.js +1 -0
- package/dist/icons/data/trello.js +1 -0
- package/dist/icons/data/trendingDown.js +1 -0
- package/dist/icons/data/trendingUp.js +1 -0
- package/dist/icons/data/triangle.js +1 -0
- package/dist/icons/data/truck.js +1 -0
- package/dist/icons/data/tv.js +1 -0
- package/dist/icons/data/twitch.js +1 -0
- package/dist/icons/data/twitter.js +1 -0
- package/dist/icons/data/type.js +1 -0
- package/dist/icons/data/umbrella.js +1 -0
- package/dist/icons/data/underline.js +1 -0
- package/dist/icons/data/unlock.js +1 -0
- package/dist/icons/data/upload.js +1 -0
- package/dist/icons/data/uploadCloud.js +1 -0
- package/dist/icons/data/user.js +1 -0
- package/dist/icons/data/userCheck.js +1 -0
- package/dist/icons/data/userMinus.js +1 -0
- package/dist/icons/data/userPlus.js +1 -0
- package/dist/icons/data/userX.js +1 -0
- package/dist/icons/data/users.js +1 -0
- package/dist/icons/data/video.js +1 -0
- package/dist/icons/data/videoOff.js +1 -0
- package/dist/icons/data/voicemail.js +1 -0
- package/dist/icons/data/volume.js +1 -0
- package/dist/icons/data/volume1.js +1 -0
- package/dist/icons/data/volume2.js +1 -0
- package/dist/icons/data/volumeX.js +1 -0
- package/dist/icons/data/watch.js +1 -0
- package/dist/icons/data/wifi.js +1 -0
- package/dist/icons/data/wifiOff.js +1 -0
- package/dist/icons/data/wind.js +1 -0
- package/dist/icons/data/x.js +1 -0
- package/dist/icons/data/xCircle.js +1 -0
- package/dist/icons/data/xOctagon.js +1 -0
- package/dist/icons/data/xSquare.js +1 -0
- package/dist/icons/data/xrColor.js +1 -0
- package/dist/icons/data/youtube.js +1 -0
- package/dist/icons/data/zap.js +1 -0
- package/dist/icons/data/zapOff.js +1 -0
- package/dist/icons/data/zoomIn.js +1 -0
- package/dist/icons/data/zoomOut.js +1 -0
- package/dist/icons.d.ts +19 -0
- package/dist/icons.js +488 -0
- package/dist/iife.js +67 -67
- package/dist/iife.js.map +39 -39
- package/dist/index-iife.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +42 -29
- package/dist/live-example/code-transform.d.ts +6 -2
- package/dist/live-example/code-transform.js +71 -0
- package/dist/live-example/component.d.ts +188 -0
- package/dist/live-example/component.js +702 -0
- package/dist/live-example/execution.js +165 -0
- package/dist/live-example/index.js +9 -0
- package/dist/live-example/insert-examples.js +44 -0
- package/dist/live-example/remote-sync.js +146 -0
- package/dist/live-example/styles.d.ts +10 -0
- package/dist/live-example/styles.js +178 -0
- package/dist/live-example/test-harness.js +242 -0
- package/dist/live-example/types.d.ts +1 -1
- package/dist/live-example/types.js +1 -0
- package/dist/live-example.js +2 -0
- package/dist/localize.d.ts +11 -0
- package/dist/localize.js +430 -0
- package/dist/make-sorter.js +119 -0
- package/dist/mapbox.d.ts +2 -1
- package/dist/mapbox.js +245 -0
- package/dist/markdown-viewer.d.ts +3 -0
- package/dist/markdown-viewer.js +181 -0
- package/dist/match-shortcut.d.ts +16 -2
- package/dist/match-shortcut.js +100 -0
- package/dist/menu.d.ts +20 -0
- package/dist/menu.js +1453 -0
- package/dist/month.d.ts +65 -0
- package/dist/month.js +530 -0
- package/dist/notifications.d.ts +4 -1
- package/dist/notifications.js +328 -0
- package/dist/password-strength.d.ts +40 -0
- package/dist/password-strength.js +303 -0
- package/dist/pop-float.js +344 -0
- package/dist/rating.d.ts +4 -1
- package/dist/rating.js +237 -0
- package/dist/rich-text.d.ts +5 -1
- package/dist/rich-text.js +418 -0
- package/dist/segmented.d.ts +4 -1
- package/dist/segmented.js +395 -0
- package/dist/select.d.ts +54 -0
- package/dist/select.js +538 -0
- package/dist/side-nav.d.ts +4 -1
- package/dist/side-nav.js +110 -0
- package/dist/size-break.d.ts +2 -1
- package/dist/size-break.js +115 -0
- package/dist/sizer.d.ts +4 -1
- package/dist/sizer.js +95 -0
- package/dist/tab-selector.d.ts +4 -1
- package/dist/tab-selector.js +333 -0
- package/dist/tag-list.d.ts +53 -1
- package/dist/tag-list.js +431 -0
- package/dist/theme.js +286 -0
- package/dist/track-drag.js +143 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -0
- package/dist/via-tag.js +102 -0
- package/package.json +11 -2
- package/dist/index.js.map +0 -57
package/dist/ab-test.d.ts
CHANGED
package/dist/ab-test.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*#
|
|
2
|
+
# ab-test
|
|
3
|
+
|
|
4
|
+
`<tosi-ab>` provides a simple method for implementing A|B-testing.
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
import { AbTest } from 'tosijs-ui'
|
|
8
|
+
|
|
9
|
+
function randomize() {
|
|
10
|
+
const conditions = {
|
|
11
|
+
testA: Math.random() < 0.5,
|
|
12
|
+
testB: Math.random() < 0.5,
|
|
13
|
+
testC: Math.random() < 0.5
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
AbTest.conditions = conditions
|
|
17
|
+
|
|
18
|
+
preview.querySelector('pre').innerText = JSON.stringify(conditions, null, 2)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
preview.querySelector('.randomize-conditions').addEventListener('click', randomize)
|
|
22
|
+
|
|
23
|
+
randomize()
|
|
24
|
+
```
|
|
25
|
+
```html
|
|
26
|
+
<div style="display: flex; gap: 10px; align-items: center;">
|
|
27
|
+
<div style="display: flex; flex-direction: column; gap: 10px;">
|
|
28
|
+
<tosi-ab class="a" condition="testA">
|
|
29
|
+
<p>testA</p>
|
|
30
|
+
</tosi-ab>
|
|
31
|
+
<tosi-ab class="not-a" not condition="testA">
|
|
32
|
+
<p>not testA</p>
|
|
33
|
+
</tosi-ab>
|
|
34
|
+
<tosi-ab class="b" condition="testB">
|
|
35
|
+
<p>testB</p>
|
|
36
|
+
</tosi-ab>
|
|
37
|
+
<tosi-ab class="not-b" not condition="testB">
|
|
38
|
+
<p>not testB</p>
|
|
39
|
+
</tosi-ab>
|
|
40
|
+
<tosi-ab class="c" condition="testC">
|
|
41
|
+
<p>testC</p>
|
|
42
|
+
</tosi-ab>
|
|
43
|
+
<tosi-ab class="not-c" not condition="testC">
|
|
44
|
+
<p>not testC</p>
|
|
45
|
+
</tosi-ab>
|
|
46
|
+
</div>
|
|
47
|
+
<pre>
|
|
48
|
+
</pre>
|
|
49
|
+
</div>
|
|
50
|
+
<button class="randomize-conditions">Randomize</button>
|
|
51
|
+
```
|
|
52
|
+
```css
|
|
53
|
+
.preview {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
gap: 4px;
|
|
57
|
+
align-items: flex-start;
|
|
58
|
+
}
|
|
59
|
+
.preview p {
|
|
60
|
+
background: #44c;
|
|
61
|
+
color: white;
|
|
62
|
+
display: block;
|
|
63
|
+
border-radius: 99px;
|
|
64
|
+
padding: 4px 10px;
|
|
65
|
+
margin: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.preview tosi-ab[not] p {
|
|
69
|
+
background: red;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- Set `AbTest.conditions` to anything you like.
|
|
74
|
+
- Use `<tosi-ab>` elements to display conditional content.
|
|
75
|
+
- `condition` attribute determines which value in `AbTest.conditions` controls the element
|
|
76
|
+
- `not` reverses the condition (so `<tosi-ab not condition="foo">` will be visible if `conditions.foo` is `false`)
|
|
77
|
+
*/
|
|
78
|
+
import { Component } from 'tosijs';
|
|
79
|
+
const abTestConditions = {};
|
|
80
|
+
export class AbTest extends Component {
|
|
81
|
+
static preferredTagName = 'tosi-ab';
|
|
82
|
+
static set conditions(context) {
|
|
83
|
+
Object.assign(abTestConditions, context);
|
|
84
|
+
for (const abTest of [...AbTest.instances]) {
|
|
85
|
+
abTest.queueRender();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
static initAttributes = {
|
|
89
|
+
condition: '',
|
|
90
|
+
not: false,
|
|
91
|
+
};
|
|
92
|
+
static instances = new Set();
|
|
93
|
+
connectedCallback() {
|
|
94
|
+
super.connectedCallback();
|
|
95
|
+
AbTest.instances.add(this);
|
|
96
|
+
}
|
|
97
|
+
disconnectedCallback() {
|
|
98
|
+
super.disconnectedCallback();
|
|
99
|
+
AbTest.instances.delete(this);
|
|
100
|
+
}
|
|
101
|
+
render() {
|
|
102
|
+
if (this.condition !== '' &&
|
|
103
|
+
(this.not
|
|
104
|
+
? abTestConditions[this.condition] !== true
|
|
105
|
+
: abTestConditions[this.condition] === true)) {
|
|
106
|
+
this.toggleAttribute('hidden', false);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
this.toggleAttribute('hidden', true);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export const abTest = AbTest.elementCreator();
|
package/dist/babylon-3d.d.ts
CHANGED
|
@@ -8,9 +8,10 @@ interface B3dUIOptions {
|
|
|
8
8
|
}
|
|
9
9
|
type MeshProcessCallback = (meshes: any[]) => void;
|
|
10
10
|
export declare class B3d extends WebComponent {
|
|
11
|
+
static preferredTagName: string;
|
|
11
12
|
babylonReady: Promise<any>;
|
|
12
13
|
BABYLON?: any;
|
|
13
|
-
static
|
|
14
|
+
static shadowStyleSpec: {
|
|
14
15
|
':host': {
|
|
15
16
|
display: string;
|
|
16
17
|
position: string;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/*#
|
|
2
|
+
# 3d
|
|
3
|
+
|
|
4
|
+
A [babylonjs](https://www.babylonjs.com/) wrapper.
|
|
5
|
+
|
|
6
|
+
A `<tosi-3d>` element is initialized with an `engine`, `canvas`, `scene`, and an update-loop.
|
|
7
|
+
|
|
8
|
+
If you view this example with an XR-enabled device, such as the
|
|
9
|
+
[Meta Quest 3](https://www.meta.com/quest/quest-3/), then you should be able to view this
|
|
10
|
+
as an AR scene.
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { b3d, gamepadText, xrControllers, xrControllersText } from 'tosijs-ui'
|
|
14
|
+
|
|
15
|
+
preview.append(b3d({
|
|
16
|
+
async sceneCreated(element, BABYLON) {
|
|
17
|
+
const camera = new BABYLON.FreeCamera(
|
|
18
|
+
'camera',
|
|
19
|
+
new BABYLON.Vector3(0, 1, -4),
|
|
20
|
+
element.scene
|
|
21
|
+
)
|
|
22
|
+
camera.attachControl(element.parts.canvas, true)
|
|
23
|
+
|
|
24
|
+
new BABYLON.HemisphericLight('light', new BABYLON.Vector3(0.25, 1, -0.5))
|
|
25
|
+
|
|
26
|
+
this.loadScene('/', 'xin3d.glb')
|
|
27
|
+
|
|
28
|
+
const size = 1024
|
|
29
|
+
const textTexture = new BABYLON.DynamicTexture('Text', size, element.scene)
|
|
30
|
+
const textContext = textTexture.getContext()
|
|
31
|
+
textTexture.update()
|
|
32
|
+
|
|
33
|
+
const textMaterial = new BABYLON.StandardMaterial('Text', element.scene)
|
|
34
|
+
textMaterial.diffuseTexture = textTexture
|
|
35
|
+
textMaterial.emissiveTexture = textTexture
|
|
36
|
+
textMaterial.backfaceCulling = false
|
|
37
|
+
|
|
38
|
+
const plaque = BABYLON.MeshBuilder.CreatePlane('Plaque', {size: 1}, element.scene)
|
|
39
|
+
plaque.position.x = 0
|
|
40
|
+
plaque.position.y = 2
|
|
41
|
+
plaque.billboardMode = BABYLON.Mesh.BILLBOARDMODE_ALL
|
|
42
|
+
plaque.material = textMaterial
|
|
43
|
+
|
|
44
|
+
let controllers
|
|
45
|
+
if (navigator.xr) {
|
|
46
|
+
const xrHelper = await element.scene.createDefaultXRExperienceAsync({
|
|
47
|
+
uiOptions: {
|
|
48
|
+
sessionMode: 'immersive-ar'
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
controllers = xrControllers(xrHelper)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const interval = setInterval(() => {
|
|
55
|
+
if (document.body.contains(element)) {
|
|
56
|
+
textContext.fillStyle = '#204020'
|
|
57
|
+
textContext.fillRect(0, 0, size, size)
|
|
58
|
+
const text = gamepadText() + '\n' + xrControllersText(controllers)
|
|
59
|
+
const lines = text.split('\n')
|
|
60
|
+
textContext.fillStyle = '#afa'
|
|
61
|
+
textContext.font = '32px monospace'
|
|
62
|
+
for(let i = 0; i < lines.length; i++) {
|
|
63
|
+
const line = lines[i]
|
|
64
|
+
textContext.fillText(line, 40, 70 + i * 40)
|
|
65
|
+
}
|
|
66
|
+
textContext.fillStyle = '#bbb'
|
|
67
|
+
textContext.fillText('tosijs-xr — debug info', 40, 984)
|
|
68
|
+
textTexture.update()
|
|
69
|
+
} else {
|
|
70
|
+
clearInterval(interval)
|
|
71
|
+
}
|
|
72
|
+
}, 100)
|
|
73
|
+
},
|
|
74
|
+
}))
|
|
75
|
+
```
|
|
76
|
+
```css
|
|
77
|
+
.preview tosi-3d {
|
|
78
|
+
width: 100%;
|
|
79
|
+
height: 100%;
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
You can access the `scene` and `engine` properties. You can also assign `sceneCreated`
|
|
84
|
+
and `update` callbacks that will be executed when the scene is first initialized and
|
|
85
|
+
before each update, respectively. (See the example, it does both.)
|
|
86
|
+
|
|
87
|
+
Both `sceneCreated` and `update` may be `async`. The component will `await` `sceneCreated`
|
|
88
|
+
before starting the renderLoop, but `update` is simply passed to babylon, so be careful.
|
|
89
|
+
|
|
90
|
+
By default, this component loads `babylon.js` from the [babylonjs CDN](https://doc.babylonjs.com/setup/frameworkPackages/CDN),
|
|
91
|
+
but if `BABYLON` is already defined (e.g. if you've bundled it) then it will use that instead.
|
|
92
|
+
|
|
93
|
+
If you need additional libraries, e.g. `https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js` for loading models such as `gltf` and `glb` files, you should load those in `sceneCreated`.
|
|
94
|
+
|
|
95
|
+
Here's a simple example of a terrain mesh comprising 125k triangles, 50% of which is being scaled using a `profileScale` function that
|
|
96
|
+
takes an array of numbers that use a linear profile to change the landform.
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
import { b3d } from 'tosijs-ui'
|
|
100
|
+
import { MoreMath } from 'tosijs'
|
|
101
|
+
|
|
102
|
+
const debugCutoff = 0.5
|
|
103
|
+
const defaultProfile = [0, 1, 5, 8, 10].map(x => x/10)
|
|
104
|
+
|
|
105
|
+
const { clamp } = MoreMath
|
|
106
|
+
function profileScale(t = 0, bypass = false, profile = defaultProfile) {
|
|
107
|
+
if (bypass) {
|
|
108
|
+
return t
|
|
109
|
+
}
|
|
110
|
+
const count = profile.length - 1
|
|
111
|
+
if (count < 1) {
|
|
112
|
+
throw new Error('profile must be of length ≥ 2')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const s = clamp(0, (t + 1) / 2, 1)
|
|
116
|
+
const index = Math.floor(s * count)
|
|
117
|
+
const dt = (s - index / count) * count
|
|
118
|
+
const min = profile[index]
|
|
119
|
+
const max = profile[index + 1]
|
|
120
|
+
const p = dt * (max - min) + min
|
|
121
|
+
return 2 * p - 1
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
preview.append(b3d({
|
|
125
|
+
async sceneCreated(element, BABYLON) {
|
|
126
|
+
const { scene } = element
|
|
127
|
+
const { createNoise2D } = await import('https://cdn.jsdelivr.net/npm/simplex-noise@4.0.1/+esm')
|
|
128
|
+
|
|
129
|
+
new BABYLON.HemisphericLight('light', new BABYLON.Vector3(0.25, 1, 2))
|
|
130
|
+
|
|
131
|
+
const terrain = new BABYLON.Mesh('terrain', scene)
|
|
132
|
+
const vertexData = new BABYLON.VertexData()
|
|
133
|
+
|
|
134
|
+
const noise2D = createNoise2D()
|
|
135
|
+
const positions = []
|
|
136
|
+
const indices = []
|
|
137
|
+
const gridSize = 100
|
|
138
|
+
const gridResolution = 250
|
|
139
|
+
const gridPoints = gridResolution + 1
|
|
140
|
+
const noiseScale = 0.03
|
|
141
|
+
const heightScale = 4.5
|
|
142
|
+
terrain.position.y = -5
|
|
143
|
+
const scale = t => t * gridSize / gridResolution - gridSize * 0.5
|
|
144
|
+
for(let x = 0; x <= gridResolution; x++) {
|
|
145
|
+
for(let z = 0; z <= gridResolution; z++) {
|
|
146
|
+
const y = profileScale(noise2D(scale(x) * noiseScale, scale(z) * noiseScale), x < gridResolution * debugCutoff)
|
|
147
|
+
positions.push(scale(x), y * heightScale, scale(z))
|
|
148
|
+
if (x > 0 && z > 0) {
|
|
149
|
+
const i = x * gridPoints + z
|
|
150
|
+
indices.push(
|
|
151
|
+
i, i - gridPoints - 1, i - 1,
|
|
152
|
+
i, i - gridPoints, i - gridPoints - 1,
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const normals = []
|
|
158
|
+
BABYLON.VertexData.ComputeNormals(positions, indices, normals);
|
|
159
|
+
|
|
160
|
+
vertexData.positions = positions
|
|
161
|
+
vertexData.indices = indices
|
|
162
|
+
vertexData.normals = normals
|
|
163
|
+
vertexData.applyToMesh(terrain)
|
|
164
|
+
},
|
|
165
|
+
}))
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## loadScene
|
|
169
|
+
|
|
170
|
+
`<tosi-3d>.loadScene(path: string, file: string, callBack(meshes: any[]): void)` can
|
|
171
|
+
be used to load `.glb` files.
|
|
172
|
+
|
|
173
|
+
## loadUI
|
|
174
|
+
|
|
175
|
+
`<tosi-3d>.loadUI(options: B3dUIOptions)` loads babylonjs guis, which you can create programmatically or using the [babylonjs gui tool](https://gui.babylonjs.com/).
|
|
176
|
+
*/
|
|
177
|
+
import { Component as WebComponent, elements } from 'tosijs';
|
|
178
|
+
import { scriptTag } from './via-tag';
|
|
179
|
+
import { icons, svg2DataUrl } from './icons';
|
|
180
|
+
const noop = () => {
|
|
181
|
+
/* do not care */
|
|
182
|
+
};
|
|
183
|
+
export class B3d extends WebComponent {
|
|
184
|
+
static preferredTagName = 'tosi-3d';
|
|
185
|
+
babylonReady;
|
|
186
|
+
BABYLON;
|
|
187
|
+
static shadowStyleSpec = {
|
|
188
|
+
':host': {
|
|
189
|
+
display: 'block',
|
|
190
|
+
position: 'relative',
|
|
191
|
+
},
|
|
192
|
+
':host canvas': {
|
|
193
|
+
width: '100%',
|
|
194
|
+
height: '100%',
|
|
195
|
+
},
|
|
196
|
+
':host .babylonVRicon': {
|
|
197
|
+
height: 50,
|
|
198
|
+
width: 80,
|
|
199
|
+
backgroundColor: 'transparent',
|
|
200
|
+
filter: 'drop-shadow(0 0 4px #000c)',
|
|
201
|
+
backgroundImage: svg2DataUrl(icons.xrColor()),
|
|
202
|
+
backgroundPosition: 'center',
|
|
203
|
+
backgroundRepeat: 'no-repeat',
|
|
204
|
+
border: 'none',
|
|
205
|
+
borderRadius: 5,
|
|
206
|
+
borderStyle: 'none',
|
|
207
|
+
outline: 'none',
|
|
208
|
+
transition: 'transform 0.125s ease-out',
|
|
209
|
+
},
|
|
210
|
+
':host .babylonVRicon:hover': {
|
|
211
|
+
transform: 'scale(1.1)',
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
content = elements.canvas({ part: 'canvas' });
|
|
215
|
+
constructor() {
|
|
216
|
+
super();
|
|
217
|
+
this.babylonReady = (async () => {
|
|
218
|
+
const { BABYLON } = await scriptTag('https://cdn.babylonjs.com/babylon.js', 'BABYLON');
|
|
219
|
+
return BABYLON;
|
|
220
|
+
})();
|
|
221
|
+
}
|
|
222
|
+
scene;
|
|
223
|
+
engine;
|
|
224
|
+
sceneCreated = noop;
|
|
225
|
+
update = noop;
|
|
226
|
+
_update = () => {
|
|
227
|
+
if (this.scene) {
|
|
228
|
+
if (this.update !== undefined) {
|
|
229
|
+
this.update(this, this.BABYLON);
|
|
230
|
+
}
|
|
231
|
+
if (this.scene.activeCamera !== undefined) {
|
|
232
|
+
this.scene.render();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
onResize() {
|
|
237
|
+
if (this.engine) {
|
|
238
|
+
this.engine.resize();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
loadScene = async (path, file, processCallback) => {
|
|
242
|
+
const { BABYLON } = await scriptTag('https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js', 'BABYLON');
|
|
243
|
+
BABYLON.SceneLoader.Append(path, file, this.scene, processCallback);
|
|
244
|
+
};
|
|
245
|
+
loadUI = async (options) => {
|
|
246
|
+
const { BABYLON } = await scriptTag('https://cdn.babylonjs.com/gui/babylon.gui.min.js', 'BABYLON');
|
|
247
|
+
const advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI('GUI', true, this.scene);
|
|
248
|
+
const { snippetId, jsonUrl, data, size } = options;
|
|
249
|
+
if (size) {
|
|
250
|
+
advancedTexture.idealWidth = size;
|
|
251
|
+
advancedTexture.renderAtIdealSize = true;
|
|
252
|
+
}
|
|
253
|
+
// edit or create your own snippet here
|
|
254
|
+
// https://gui.babylonjs.com/
|
|
255
|
+
let gui;
|
|
256
|
+
if (snippetId) {
|
|
257
|
+
gui = await advancedTexture.parseFromSnippetAsync(snippetId);
|
|
258
|
+
}
|
|
259
|
+
else if (jsonUrl) {
|
|
260
|
+
gui = await advancedTexture.parseFromURLAsync(jsonUrl);
|
|
261
|
+
}
|
|
262
|
+
else if (data) {
|
|
263
|
+
gui = advancedTexture.parseContent(data);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
const root = advancedTexture.getChildren()[0];
|
|
269
|
+
const widgets = root.children.reduce((map, widget) => {
|
|
270
|
+
map[widget.name] = widget;
|
|
271
|
+
return map;
|
|
272
|
+
}, {});
|
|
273
|
+
return { advancedTexture, gui, root, widgets };
|
|
274
|
+
};
|
|
275
|
+
connectedCallback() {
|
|
276
|
+
super.connectedCallback();
|
|
277
|
+
const { canvas } = this.parts;
|
|
278
|
+
this.babylonReady.then(async (BABYLON) => {
|
|
279
|
+
this.BABYLON = BABYLON;
|
|
280
|
+
this.engine = new BABYLON.Engine(canvas, true);
|
|
281
|
+
this.scene = new BABYLON.Scene(this.engine);
|
|
282
|
+
if (this.sceneCreated) {
|
|
283
|
+
await this.sceneCreated(this, BABYLON);
|
|
284
|
+
}
|
|
285
|
+
if (this.scene.activeCamera === undefined) {
|
|
286
|
+
const camera = new BABYLON.ArcRotateCamera('default-camera', -Math.PI / 2, Math.PI / 2.5, 3, new BABYLON.Vector3(0, 0, 0));
|
|
287
|
+
camera.attachControl(this.parts.canvas, true);
|
|
288
|
+
}
|
|
289
|
+
this.engine.runRenderLoop(this._update);
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
export const b3d = B3d.elementCreator();
|
|
@@ -9,6 +9,7 @@ export interface LottieConfig {
|
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
}
|
|
11
11
|
export declare class BodymovinPlayer extends WebComponent {
|
|
12
|
+
static preferredTagName: string;
|
|
12
13
|
static initAttributes: {
|
|
13
14
|
src: string;
|
|
14
15
|
json: string;
|
|
@@ -17,7 +18,7 @@ export declare class BodymovinPlayer extends WebComponent {
|
|
|
17
18
|
config: LottieConfig;
|
|
18
19
|
static bodymovinAvailable?: Promise<any>;
|
|
19
20
|
animation: any;
|
|
20
|
-
static
|
|
21
|
+
static shadowStyleSpec: {
|
|
21
22
|
':host': {
|
|
22
23
|
width: number;
|
|
23
24
|
height: number;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/*#
|
|
2
|
+
# lottie / bodymovin
|
|
3
|
+
|
|
4
|
+
A [lottie](https://airbnb.io/lottie/#/web) (a.k.a. **bodymovin**) player.
|
|
5
|
+
|
|
6
|
+
It's designed to work like an `<img>` element (just set its `src` attribute).
|
|
7
|
+
|
|
8
|
+
```js
|
|
9
|
+
import { icons, popFloat, tosiSelect } from 'tosijs-ui'
|
|
10
|
+
import { div, label, input, select, option, span } from 'tosijs'.elements
|
|
11
|
+
|
|
12
|
+
const tosiPlatform = preview.querySelector('tosi-lottie')
|
|
13
|
+
setTimeout(
|
|
14
|
+
() => {
|
|
15
|
+
preview.append(
|
|
16
|
+
popFloat({
|
|
17
|
+
draggable: true,
|
|
18
|
+
content: [
|
|
19
|
+
{ class: 'panel' },
|
|
20
|
+
div({ class: 'panel-header' }, 'Player Controls' ),
|
|
21
|
+
label(
|
|
22
|
+
{ class: 'no-drag' },
|
|
23
|
+
'speed',
|
|
24
|
+
input({ type: 'range', min: -1, max: 1, step: 0.1, value: 0, onInput(event) {
|
|
25
|
+
const speed = Math.pow(5, Number(event.target.value))
|
|
26
|
+
tosiPlatform.animation.setSpeed(speed)
|
|
27
|
+
event.target.nextSibling.textContent = (speed * 100).toFixed(0) + '%'
|
|
28
|
+
} }),
|
|
29
|
+
span('100%', {style: { textAlign: 'right', width: '40px'}})
|
|
30
|
+
),
|
|
31
|
+
label(
|
|
32
|
+
{ class: 'no-drag' },
|
|
33
|
+
'direction',
|
|
34
|
+
tosiSelect({
|
|
35
|
+
value: '1',
|
|
36
|
+
options: [
|
|
37
|
+
{ caption: 'Forward', value: '1' },
|
|
38
|
+
{ caption: 'Backward', value: '-1' }
|
|
39
|
+
],
|
|
40
|
+
onChange(event) {
|
|
41
|
+
tosiPlatform.animation.setDirection(event.target.value)
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
)
|
|
45
|
+
],
|
|
46
|
+
target: tosiPlatform,
|
|
47
|
+
position: 's'
|
|
48
|
+
})
|
|
49
|
+
)
|
|
50
|
+
},
|
|
51
|
+
500
|
|
52
|
+
)
|
|
53
|
+
```
|
|
54
|
+
```html
|
|
55
|
+
<tosi-lottie
|
|
56
|
+
style="width: 200px; height: 200px;"
|
|
57
|
+
src="/tosi-platform.json"
|
|
58
|
+
></tosi-lottie>
|
|
59
|
+
<div class="caption">
|
|
60
|
+
Animation created by <a target="_blank" href="https://pro.fiverr.com/freelancers/anicoremotion">@anicoremotion</a>
|
|
61
|
+
</div>
|
|
62
|
+
```
|
|
63
|
+
```css
|
|
64
|
+
.preview {
|
|
65
|
+
padding: var(--spacing);
|
|
66
|
+
text-align: center;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.preview .panel {
|
|
70
|
+
padding: 10px;
|
|
71
|
+
border-radius: 5px;
|
|
72
|
+
gap: 5px;
|
|
73
|
+
background: var(--background);
|
|
74
|
+
box-shadow: var(--menu-shadow);
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: column;
|
|
77
|
+
overflow: hidden;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.preview .caption {
|
|
81
|
+
position: absolute;
|
|
82
|
+
right: 5px;
|
|
83
|
+
bottom: 5px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.preview .panel-header {
|
|
87
|
+
margin: 0;
|
|
88
|
+
text-align: center;
|
|
89
|
+
font-weight: bold;
|
|
90
|
+
background: var(--brand-color);
|
|
91
|
+
color: white;
|
|
92
|
+
padding: 5px;
|
|
93
|
+
margin: -10px -10px 0 -10px;
|
|
94
|
+
cursor: move;
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You can also directly set its `json` property to the content of a `lottie.json` file.
|
|
99
|
+
|
|
100
|
+
And of course just access the element's `animation` property to [use the bodymovin API](https://airbnb.io/lottie/#/web).
|
|
101
|
+
|
|
102
|
+
Also see the [documentation for advanced interactions](https://lottiefiles.github.io/lottie-docs/advanced_interactions/)
|
|
103
|
+
*/
|
|
104
|
+
import { Component as WebComponent } from 'tosijs';
|
|
105
|
+
import { scriptTag } from './via-tag';
|
|
106
|
+
export class BodymovinPlayer extends WebComponent {
|
|
107
|
+
static preferredTagName = 'tosi-lottie';
|
|
108
|
+
static initAttributes = {
|
|
109
|
+
src: '',
|
|
110
|
+
json: '',
|
|
111
|
+
};
|
|
112
|
+
content = null;
|
|
113
|
+
config = {
|
|
114
|
+
renderer: 'svg',
|
|
115
|
+
loop: true,
|
|
116
|
+
autoplay: true,
|
|
117
|
+
};
|
|
118
|
+
static bodymovinAvailable;
|
|
119
|
+
animation;
|
|
120
|
+
static shadowStyleSpec = {
|
|
121
|
+
':host': {
|
|
122
|
+
width: 400,
|
|
123
|
+
height: 400,
|
|
124
|
+
display: 'inline-block',
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
_loading = false;
|
|
128
|
+
get loading() {
|
|
129
|
+
return this._loading;
|
|
130
|
+
}
|
|
131
|
+
constructor() {
|
|
132
|
+
super();
|
|
133
|
+
if (BodymovinPlayer.bodymovinAvailable === undefined) {
|
|
134
|
+
BodymovinPlayer.bodymovinAvailable = scriptTag('https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.12.2/lottie.min.js', 'bodymovin');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
doneLoading = () => {
|
|
138
|
+
this._loading = false;
|
|
139
|
+
};
|
|
140
|
+
load = ({ bodymovin }) => {
|
|
141
|
+
this._loading = true;
|
|
142
|
+
this.config.container =
|
|
143
|
+
this.shadowRoot !== null ? this.shadowRoot : undefined;
|
|
144
|
+
if (this.json !== '') {
|
|
145
|
+
this.config.animationData = this.json;
|
|
146
|
+
delete this.config.path;
|
|
147
|
+
}
|
|
148
|
+
else if (this.src !== '') {
|
|
149
|
+
delete this.config.animationData;
|
|
150
|
+
this.config.path = this.src;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
console.log('%c<tosi-lottie>%c expected either %cjson%c (animation data) or %csrc% c(url) but found neither.', 'color: #44f; background: #fff; padding: 0 5px', 'color: default', 'color: #44f; background: #fff; padding: 0 5px', 'color: default', 'color: #44f; background: #fff; padding: 0 5px', 'color: default');
|
|
154
|
+
}
|
|
155
|
+
if (this.animation) {
|
|
156
|
+
this.animation.destroy();
|
|
157
|
+
const root = this.shadowRoot;
|
|
158
|
+
if (root !== null) {
|
|
159
|
+
root.querySelector('svg')?.remove();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
this.animation = bodymovin.loadAnimation(this.config);
|
|
163
|
+
this.animation.addEventListener('DOMLoaded', this.doneLoading);
|
|
164
|
+
};
|
|
165
|
+
render() {
|
|
166
|
+
super.render();
|
|
167
|
+
BodymovinPlayer.bodymovinAvailable.then(this.load).catch((e) => {
|
|
168
|
+
console.error(e);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
export const bodymovinPlayer = BodymovinPlayer.elementCreator();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/*#
|
|
3
|
+
# blueprint loading
|
|
4
|
+
|
|
5
|
+
<center>
|
|
6
|
+
<tosi-icon icon="blueprint" class="logo" size=256></tosi-icon>
|
|
7
|
+
</center>
|
|
8
|
+
|
|
9
|
+
`<xin-loader>` and `<xin-blueprint>` are simple elements provided by `tosijs` for the dynamic loading
|
|
10
|
+
of component **blueprints**.
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<xin-loader>
|
|
14
|
+
<xin-blueprint tag="swiss-clock" src="https://tonioloewald.github.io/xin-clock/dist/blueprint.js"></xin-blueprint>
|
|
15
|
+
</xin-loader>
|
|
16
|
+
<swiss-clock></swiss-clock>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Attributes
|
|
20
|
+
|
|
21
|
+
- `blueprint` is the url of the `blueprint` javascript module (required)
|
|
22
|
+
- `tag` is the tagName you wish to use. If the name of the blueprint is
|
|
23
|
+
hyphenated, then that will be used by default
|
|
24
|
+
- `property` if the blueprint module exports the blueprint function as
|
|
25
|
+
a property, you can specify the property here.
|
|
26
|
+
*/
|
package/dist/carousel.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component as WebComponent, ElementCreator } from 'tosijs';
|
|
2
2
|
export declare class TosiCarousel extends WebComponent {
|
|
3
|
+
static preferredTagName: string;
|
|
3
4
|
static initAttributes: {
|
|
4
5
|
dots: boolean;
|
|
5
6
|
arrows: boolean;
|
|
@@ -17,12 +18,26 @@ export declare class TosiCarousel extends WebComponent {
|
|
|
17
18
|
set page(p: number);
|
|
18
19
|
get visibleItems(): HTMLElement[];
|
|
19
20
|
get lastPage(): number;
|
|
20
|
-
static
|
|
21
|
+
static shadowStyleSpec: {
|
|
21
22
|
':host': {
|
|
23
|
+
_carouselIconSize: number;
|
|
24
|
+
_carouselButtonColor: string;
|
|
25
|
+
_carouselButtonHoverColor: string;
|
|
26
|
+
_carouselButtonActiveColor: string;
|
|
27
|
+
_carouseButtonWidth: number;
|
|
28
|
+
_carouselDotCurrentColor: string;
|
|
29
|
+
_carouselDotSize: number;
|
|
30
|
+
_carouselDotSpacing: string;
|
|
31
|
+
_carouselProgressPadding: number;
|
|
32
|
+
_carouselDotTransition: string;
|
|
22
33
|
display: string;
|
|
23
34
|
flexDirection: string;
|
|
24
35
|
position: string;
|
|
25
36
|
};
|
|
37
|
+
':host:focus': {
|
|
38
|
+
outline: string;
|
|
39
|
+
boxShadow: string;
|
|
40
|
+
};
|
|
26
41
|
':host svg': {
|
|
27
42
|
height: string;
|
|
28
43
|
};
|
|
@@ -112,6 +127,8 @@ export declare class TosiCarousel extends WebComponent {
|
|
|
112
127
|
render(): void;
|
|
113
128
|
}
|
|
114
129
|
/** @deprecated Use TosiCarousel instead */
|
|
130
|
+
export type XinCarousel = TosiCarousel;
|
|
131
|
+
/** @deprecated Use TosiCarousel instead */
|
|
115
132
|
export declare const XinCarousel: typeof TosiCarousel;
|
|
116
133
|
export declare const tosiCarousel: ElementCreator<TosiCarousel>;
|
|
117
134
|
/** @deprecated Use tosiCarousel instead */
|