@0001-labs/design-system-1 0.3.0-alpha.13 → 0.3.0-alpha.14
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/DS1/0-face/calendar.ts +194 -0
- package/DS1/0-face/carousel.ts +623 -0
- package/DS1/0-face/component-visibility.ts +13 -0
- package/DS1/0-face/copy-text.ts +96 -0
- package/DS1/0-face/device.ts +8 -58
- package/DS1/0-face/dialog-swipe.ts +249 -0
- package/DS1/0-face/dialogs.ts +208 -0
- package/DS1/0-face/drawer.ts +258 -0
- package/DS1/0-face/feedback-words.ts +36 -0
- package/DS1/0-face/feedback.ts +40 -0
- package/DS1/0-face/format.ts +700 -0
- package/DS1/0-face/generated/toast-assets.ts +18 -0
- package/DS1/0-face/grid-fit.ts +1 -1
- package/DS1/0-face/grid.ts +3 -2
- package/DS1/0-face/header.ts +78 -0
- package/DS1/0-face/i18n.ts +93 -18
- package/DS1/0-face/keys.ts +276 -0
- package/DS1/0-face/languages.ts +4 -4
- package/DS1/0-face/layout-inspector.ts +6 -6
- package/DS1/0-face/library-styles.ts +33 -0
- package/DS1/0-face/load-toaster.ts +7 -0
- package/DS1/0-face/preference-options.ts +29 -0
- package/DS1/0-face/preferences.ts +3 -11
- package/DS1/0-face/pricing.ts +98 -43
- package/DS1/0-face/scaling.ts +160 -4
- package/DS1/0-face/shared-words.ts +9 -4
- package/DS1/0-face/sidebar.ts +201 -0
- package/DS1/0-face/theme-bootstrap.js +184 -0
- package/DS1/0-face/theme.ts +89 -47
- package/DS1/0-face/toast-queue.ts +157 -0
- package/DS1/0-face/toaster.ts +384 -0
- package/DS1/0-face/tooltips.ts +157 -15
- package/DS1/0-face/translations/da.json +60 -1
- package/DS1/0-face/translations/de.json +60 -1
- package/DS1/0-face/translations/en.json +60 -1
- package/DS1/0-face/translations/es.json +60 -1
- package/DS1/0-face/translations/fi.json +60 -1
- package/DS1/0-face/translations/fr.json +60 -1
- package/DS1/0-face/translations/is.json +60 -1
- package/DS1/0-face/translations/it.json +60 -1
- package/DS1/0-face/translations/ja.json +60 -1
- package/DS1/0-face/translations/ko.json +60 -1
- package/DS1/0-face/translations/nb.json +60 -1
- package/DS1/0-face/translations/pt-BR.json +60 -1
- package/DS1/0-face/translations/pt.json +60 -1
- package/DS1/0-face/translations/sv.json +60 -1
- package/DS1/0-face/translations/zh.json +60 -1
- package/DS1/0-face/translations-format.ts +3 -4
- package/DS1/1-root/card.css +192 -0
- package/DS1/1-root/carousel.css +136 -0
- package/DS1/1-root/cjk.css +23 -0
- package/DS1/1-root/component-metrics.css +1 -0
- package/DS1/1-root/component-tokens.css +51 -8
- package/DS1/1-root/controls.css +887 -14
- package/DS1/1-root/dialog-placement.css +191 -0
- package/DS1/1-root/document.css +183 -0
- package/DS1/1-root/drawer.css +83 -0
- package/DS1/1-root/empty.css +83 -0
- package/DS1/1-root/figures.css +141 -0
- package/DS1/1-root/fonts/Iosevka-LICENSE.md +3 -1
- package/DS1/1-root/fonts/Iosevka-Regular.woff2 +0 -0
- package/DS1/1-root/fonts.css +69 -0
- package/DS1/1-root/footer.css +186 -0
- package/DS1/1-root/header.css +165 -0
- package/DS1/1-root/kbd.css +46 -0
- package/DS1/1-root/library-tokens.ts +91 -0
- package/DS1/1-root/measures.ts +53 -0
- package/DS1/1-root/notice.css +165 -0
- package/DS1/1-root/one.css +14 -84
- package/DS1/1-root/one.semantic.css +200 -148
- package/DS1/1-root/palette.css +58 -0
- package/DS1/1-root/palette.ts +19 -0
- package/DS1/1-root/progress.css +356 -0
- package/DS1/1-root/prose.css +202 -0
- package/DS1/1-root/row.css +297 -0
- package/DS1/1-root/table.css +111 -0
- package/DS1/1-root/text.css +70 -0
- package/DS1/2-core/button-split.ts +55 -0
- package/DS1/2-core/chart/chart.css +169 -0
- package/DS1/2-core/chart/grid-chart.ts +554 -0
- package/DS1/2-core/ds-avatar.ts +25 -6
- package/DS1/2-core/ds-badge.ts +10 -10
- package/DS1/2-core/ds-button.ts +111 -26
- package/DS1/2-core/ds-card.ts +135 -105
- package/DS1/2-core/ds-chart.ts +327 -0
- package/DS1/2-core/ds-composer.ts +8 -2
- package/DS1/2-core/ds-cycle.ts +97 -21
- package/DS1/2-core/ds-empty.ts +120 -0
- package/DS1/2-core/ds-icon.ts +11 -2
- package/DS1/2-core/ds-input.ts +165 -6
- package/DS1/2-core/ds-kbd.ts +78 -0
- package/DS1/2-core/ds-loading.ts +72 -0
- package/DS1/2-core/ds-notice.ts +180 -0
- package/DS1/2-core/ds-progress.ts +380 -0
- package/DS1/2-core/ds-spacing-handle.ts +22 -0
- package/DS1/2-core/ds-stat.ts +174 -0
- package/DS1/2-core/ds-switch.ts +1 -0
- package/DS1/2-core/ds-text.ts +15 -2
- package/DS1/2-core/ds-toast.ts +354 -0
- package/DS1/2-core/figures.ts +105 -0
- package/DS1/2-core/generated/ds-icon-map.ts +234 -128
- package/DS1/2-core/generated/icon-avatar.ts +2 -0
- package/DS1/2-core/generated/icons-extra.ts +118 -65
- package/DS1/2-core/generated/icons-immediate.ts +1 -1
- package/DS1/2-core/spacing-handle.ts +95 -0
- package/DS1/2-core/styles/ds-avatar.css +9 -8
- package/DS1/2-core/styles/ds-button-host.css +26 -3
- package/DS1/2-core/styles/ds-button-split.css +67 -0
- package/DS1/2-core/styles/ds-button.css +49 -15
- package/DS1/2-core/styles/ds-card.css +34 -0
- package/DS1/2-core/styles/ds-composer.css +13 -0
- package/DS1/2-core/styles/ds-cycle.css +69 -0
- package/DS1/2-core/styles/ds-empty.css +18 -0
- package/DS1/2-core/styles/ds-gap.css +1 -0
- package/DS1/2-core/styles/ds-icon.css +1 -0
- package/DS1/2-core/styles/ds-input.css +59 -6
- package/DS1/2-core/styles/ds-kbd.css +12 -0
- package/DS1/2-core/styles/ds-loading.css +13 -0
- package/DS1/2-core/styles/ds-notice.css +30 -0
- package/DS1/2-core/styles/ds-progress.css +25 -0
- package/DS1/2-core/styles/ds-select.css +2 -2
- package/DS1/2-core/styles/ds-spacing-handle.css +8 -0
- package/DS1/2-core/styles/ds-split.css +2 -62
- package/DS1/2-core/styles/ds-stat.css +34 -0
- package/DS1/2-core/styles/ds-switch.css +16 -1
- package/DS1/2-core/styles/ds-text.css +43 -12
- package/DS1/2-core/styles/ds-toast.css +182 -0
- package/DS1/2-core/styles/ds-tooltip.css +1 -0
- package/DS1/3-unit/calendar-base.ts +263 -0
- package/DS1/3-unit/ds-accordion.ts +9 -1
- package/DS1/3-unit/ds-avatar-group.ts +1 -0
- package/DS1/3-unit/ds-calendar-large.ts +349 -0
- package/DS1/3-unit/ds-calendar.ts +344 -0
- package/DS1/3-unit/ds-carousel.ts +368 -0
- package/DS1/3-unit/ds-date-picker.ts +540 -0
- package/DS1/3-unit/ds-form.ts +45 -37
- package/DS1/3-unit/ds-list.ts +48 -1
- package/DS1/3-unit/ds-matrix.ts +318 -0
- package/DS1/3-unit/ds-menu.ts +8 -4
- package/DS1/3-unit/ds-row.ts +84 -1
- package/DS1/3-unit/ds-sidebar.ts +280 -0
- package/DS1/3-unit/ds-table.ts +75 -34
- package/DS1/3-unit/styles/ds-accordion.css +1 -0
- package/DS1/3-unit/styles/ds-avatar-group.css +2 -4
- package/DS1/3-unit/styles/ds-calendar-large.css +165 -0
- package/DS1/3-unit/styles/ds-calendar.css +238 -0
- package/DS1/3-unit/styles/ds-carousel.css +30 -0
- package/DS1/3-unit/styles/ds-date-picker.css +124 -0
- package/DS1/3-unit/styles/ds-list.css +1 -0
- package/DS1/3-unit/styles/ds-matrix.css +203 -0
- package/DS1/3-unit/styles/ds-menu.css +31 -6
- package/DS1/3-unit/styles/ds-row.css +84 -2
- package/DS1/3-unit/styles/ds-sidebar.css +117 -0
- package/DS1/3-unit/styles/ds-table.css +3 -74
- package/DS1/4-page/ds-dialog.ts +40 -4
- package/DS1/4-page/ds-document.ts +240 -0
- package/DS1/4-page/ds-footer.ts +165 -0
- package/DS1/4-page/ds-grid.ts +39 -59
- package/DS1/4-page/ds-header.ts +171 -0
- package/DS1/4-page/ds-page.ts +184 -0
- package/DS1/4-page/email.ts +2 -3
- package/DS1/4-page/styles/ds-container.css +1 -0
- package/DS1/4-page/styles/ds-document.css +18 -0
- package/DS1/4-page/styles/ds-footer.css +29 -0
- package/DS1/4-page/styles/ds-grid.css +31 -85
- package/DS1/4-page/styles/ds-header.css +57 -0
- package/DS1/4-page/styles/ds-page.css +214 -0
- package/DS1/components.ts +7 -1
- package/DS1/index.ts +26 -6
- package/DS1/react/avatar.ts +4 -5
- package/DS1/react/button-split.ts +29 -0
- package/DS1/react/button.ts +32 -13
- package/DS1/react/carousel.ts +76 -0
- package/DS1/react/dialog.ts +36 -5
- package/DS1/react/document.ts +14 -0
- package/DS1/react/empty.ts +32 -0
- package/DS1/react/footer.ts +17 -0
- package/DS1/react/header.ts +15 -0
- package/DS1/react/input.ts +28 -17
- package/DS1/react/kbd.ts +21 -0
- package/DS1/react/loading.ts +18 -0
- package/DS1/react/notice.ts +59 -0
- package/DS1/react/page.ts +13 -0
- package/DS1/react/progress.ts +99 -0
- package/DS1/react/sidebar.ts +60 -0
- package/DS1/react/spacing-handle.ts +21 -0
- package/DS1/react/stat.ts +73 -0
- package/DS1/react/toast.ts +82 -0
- package/DS1/x-icon/Tabler-LICENSE.md +27 -0
- package/DS1/x-icon/airtable.svg +5 -0
- package/DS1/x-icon/attach.svg +3 -0
- package/DS1/x-icon/audio.svg +3 -0
- package/DS1/x-icon/bag-alt.svg +3 -0
- package/DS1/x-icon/bank.svg +3 -0
- package/DS1/x-icon/banknote.svg +3 -0
- package/DS1/x-icon/bolt.svg +3 -0
- package/DS1/x-icon/book-alt.svg +3 -0
- package/DS1/x-icon/book.svg +4 -0
- package/DS1/x-icon/box.svg +3 -0
- package/DS1/x-icon/briefcase.svg +3 -0
- package/DS1/x-icon/building.svg +4 -0
- package/DS1/x-icon/car.svg +3 -0
- package/DS1/x-icon/card.svg +3 -0
- package/DS1/x-icon/cart.svg +3 -0
- package/DS1/x-icon/{ezo-item-button-start.svg → chevron-left.svg} +1 -1
- package/DS1/x-icon/{ezo-android-screen-stats.svg → chevron-right.svg} +1 -1
- package/DS1/x-icon/cloud.svg +3 -0
- package/DS1/x-icon/coffee.svg +3 -0
- package/DS1/x-icon/coins.svg +3 -0
- package/DS1/x-icon/cursor.svg +3 -0
- package/DS1/x-icon/curve.svg +7 -0
- package/DS1/x-icon/dislike.svg +4 -0
- package/DS1/x-icon/dot-bank.svg +3 -0
- package/DS1/x-icon/dot-banknote.svg +3 -0
- package/DS1/x-icon/dot-banknotes.svg +3 -0
- package/DS1/x-icon/dot-card.svg +3 -0
- package/DS1/x-icon/dot-coin.svg +3 -0
- package/DS1/x-icon/dot-coins.svg +3 -0
- package/DS1/x-icon/dot-receipt.svg +3 -0
- package/DS1/x-icon/dot-safe.svg +3 -0
- package/DS1/x-icon/dot-transfer.svg +3 -0
- package/DS1/x-icon/dot-wallet.svg +3 -0
- package/DS1/x-icon/download.svg +4 -0
- package/DS1/x-icon/drive.svg +5 -0
- package/DS1/x-icon/drop.svg +3 -0
- package/DS1/x-icon/dropbox.svg +3 -0
- package/DS1/x-icon/dumbbell.svg +3 -0
- package/DS1/x-icon/eye-off.svg +3 -0
- package/DS1/x-icon/eye.svg +3 -0
- package/DS1/x-icon/facebook.svg +3 -0
- package/DS1/x-icon/figma.svg +5 -0
- package/DS1/x-icon/flame.svg +3 -0
- package/DS1/x-icon/flip.svg +5 -0
- package/DS1/x-icon/food.svg +3 -0
- package/DS1/x-icon/fuel.svg +3 -0
- package/DS1/x-icon/game.svg +3 -0
- package/DS1/x-icon/gift.svg +3 -0
- package/DS1/x-icon/github.svg +3 -0
- package/DS1/x-icon/heart.svg +3 -0
- package/DS1/x-icon/history.svg +3 -0
- package/DS1/x-icon/home-alt.svg +3 -0
- package/DS1/x-icon/income.svg +3 -0
- package/DS1/x-icon/info.svg +5 -0
- package/DS1/x-icon/instagram.svg +5 -0
- package/DS1/x-icon/jpbank.svg +3 -0
- package/DS1/x-icon/key.svg +4 -0
- package/DS1/x-icon/keyboard.svg +3 -0
- package/DS1/x-icon/like.svg +4 -0
- package/DS1/x-icon/linkedin.svg +7 -0
- package/DS1/x-icon/loom.svg +6 -0
- package/DS1/x-icon/map.svg +4 -0
- package/DS1/x-icon/medical.svg +3 -0
- package/DS1/x-icon/{ezo-android-screen-lists.svg → minus.svg} +1 -1
- package/DS1/x-icon/moon.svg +3 -0
- package/DS1/x-icon/move.svg +3 -0
- package/DS1/x-icon/music-alt.svg +3 -0
- package/DS1/x-icon/music.svg +5 -0
- package/DS1/x-icon/notion.svg +6 -0
- package/DS1/x-icon/offline.svg +3 -0
- package/DS1/x-icon/pause.svg +4 -0
- package/DS1/x-icon/paw.svg +3 -0
- package/DS1/x-icon/pdf.svg +3 -0
- package/DS1/x-icon/people.svg +5 -0
- package/DS1/x-icon/percent.svg +3 -0
- package/DS1/x-icon/phone.svg +3 -0
- package/DS1/x-icon/pill.svg +3 -0
- package/DS1/x-icon/plane.svg +3 -0
- package/DS1/x-icon/postal.svg +3 -0
- package/DS1/x-icon/present.svg +4 -0
- package/DS1/x-icon/reaction.svg +5 -0
- package/DS1/x-icon/receipt.svg +3 -0
- package/DS1/x-icon/refresh.svg +3 -0
- package/DS1/x-icon/refund.svg +3 -0
- package/DS1/x-icon/repeat.svg +3 -0
- package/DS1/x-icon/rotate.svg +4 -0
- package/DS1/x-icon/safe.svg +3 -0
- package/DS1/x-icon/school-alt.svg +3 -0
- package/DS1/x-icon/shield-alt.svg +3 -0
- package/DS1/x-icon/shield.svg +4 -0
- package/DS1/x-icon/shirt.svg +3 -0
- package/DS1/x-icon/shop.svg +3 -0
- package/DS1/x-icon/sign-in.svg +3 -0
- package/DS1/x-icon/sign-out.svg +3 -0
- package/DS1/x-icon/slack.svg +6 -0
- package/DS1/x-icon/sparkle.svg +3 -0
- package/DS1/x-icon/start.svg +4 -0
- package/DS1/x-icon/{ezo-item-button-reopen.svg → stop.svg} +1 -1
- package/DS1/x-icon/sun.svg +3 -0
- package/DS1/x-icon/system.svg +4 -0
- package/DS1/x-icon/tag.svg +3 -0
- package/DS1/x-icon/ticket.svg +3 -0
- package/DS1/x-icon/title-struck.svg +4 -0
- package/DS1/x-icon/train.svg +3 -0
- package/DS1/x-icon/transfer.svg +3 -0
- package/DS1/x-icon/tv.svg +3 -0
- package/DS1/x-icon/upload.svg +4 -0
- package/DS1/x-icon/video.svg +4 -0
- package/DS1/x-icon/vimeo.svg +3 -0
- package/DS1/x-icon/wallet.svg +3 -0
- package/DS1/x-icon/wifi.svg +3 -0
- package/DS1/x-icon/window.svg +4 -0
- package/DS1/x-icon/wrench.svg +3 -0
- package/DS1/x-icon/x-brand.svg +4 -0
- package/DS1/x-icon/youtube.svg +4 -0
- package/README.md +3 -3
- package/dist/0-face/calendar.d.ts +75 -0
- package/dist/0-face/calendar.d.ts.map +1 -0
- package/dist/0-face/calendar.js +149 -0
- package/dist/0-face/carousel.d.ts +174 -0
- package/dist/0-face/carousel.d.ts.map +1 -0
- package/dist/0-face/carousel.js +583 -0
- package/dist/0-face/component-visibility.d.ts +7 -0
- package/dist/0-face/component-visibility.d.ts.map +1 -0
- package/dist/0-face/component-visibility.js +10 -0
- package/dist/0-face/copy-text.d.ts +11 -0
- package/dist/0-face/copy-text.d.ts.map +1 -0
- package/dist/0-face/copy-text.js +97 -0
- package/dist/0-face/device.d.ts +3 -7
- package/dist/0-face/device.d.ts.map +1 -1
- package/dist/0-face/device.js +7 -41
- package/dist/0-face/dialog-swipe.d.ts +49 -0
- package/dist/0-face/dialog-swipe.d.ts.map +1 -0
- package/dist/0-face/dialog-swipe.js +239 -0
- package/dist/0-face/dialogs.d.ts +33 -0
- package/dist/0-face/dialogs.d.ts.map +1 -0
- package/dist/0-face/dialogs.js +173 -0
- package/dist/0-face/drawer.d.ts +64 -0
- package/dist/0-face/drawer.d.ts.map +1 -0
- package/dist/0-face/drawer.js +256 -0
- package/dist/0-face/feedback-words.d.ts +21 -0
- package/dist/0-face/feedback-words.d.ts.map +1 -0
- package/dist/0-face/feedback-words.js +30 -0
- package/dist/0-face/feedback.d.ts +41 -0
- package/dist/0-face/feedback.d.ts.map +1 -0
- package/dist/0-face/feedback.js +35 -0
- package/dist/0-face/format.d.ts +166 -0
- package/dist/0-face/format.d.ts.map +1 -0
- package/dist/0-face/format.js +445 -0
- package/dist/0-face/generated/toast-assets.d.ts +11 -0
- package/dist/0-face/generated/toast-assets.d.ts.map +1 -0
- package/dist/0-face/generated/toast-assets.js +14 -0
- package/dist/0-face/grid-fit.js +1 -1
- package/dist/0-face/grid.d.ts.map +1 -1
- package/dist/0-face/grid.js +2 -1
- package/dist/0-face/header.d.ts +38 -0
- package/dist/0-face/header.d.ts.map +1 -0
- package/dist/0-face/header.js +80 -0
- package/dist/0-face/i18n.d.ts +32 -2
- package/dist/0-face/i18n.d.ts.map +1 -1
- package/dist/0-face/i18n.js +65 -19
- package/dist/0-face/keys.d.ts +104 -0
- package/dist/0-face/keys.d.ts.map +1 -0
- package/dist/0-face/keys.js +253 -0
- package/dist/0-face/languages.d.ts +2 -2
- package/dist/0-face/languages.js +3 -3
- package/dist/0-face/layout-inspector.js +6 -6
- package/dist/0-face/library-styles.d.ts +7 -0
- package/dist/0-face/library-styles.d.ts.map +1 -0
- package/dist/0-face/library-styles.js +29 -0
- package/dist/0-face/load-toaster.d.ts +8 -0
- package/dist/0-face/load-toaster.d.ts.map +1 -0
- package/dist/0-face/load-toaster.js +7 -0
- package/dist/0-face/preference-options.d.ts +34 -0
- package/dist/0-face/preference-options.d.ts.map +1 -0
- package/dist/0-face/preference-options.js +1 -0
- package/dist/0-face/preferences.d.ts +3 -12
- package/dist/0-face/preferences.d.ts.map +1 -1
- package/dist/0-face/pricing.d.ts +19 -9
- package/dist/0-face/pricing.d.ts.map +1 -1
- package/dist/0-face/pricing.js +81 -40
- package/dist/0-face/scaling.d.ts +71 -1
- package/dist/0-face/scaling.d.ts.map +1 -1
- package/dist/0-face/scaling.js +108 -3
- package/dist/0-face/shared-words.d.ts +9 -4
- package/dist/0-face/shared-words.d.ts.map +1 -1
- package/dist/0-face/sidebar.d.ts +69 -0
- package/dist/0-face/sidebar.d.ts.map +1 -0
- package/dist/0-face/sidebar.js +191 -0
- package/dist/0-face/theme-bootstrap.d.ts +1 -0
- package/dist/0-face/theme-bootstrap.d.ts.map +1 -0
- package/dist/0-face/theme-bootstrap.js +214 -0
- package/dist/0-face/theme.d.ts +32 -0
- package/dist/0-face/theme.d.ts.map +1 -1
- package/dist/0-face/theme.js +69 -43
- package/dist/0-face/toast-queue.d.ts +110 -0
- package/dist/0-face/toast-queue.d.ts.map +1 -0
- package/dist/0-face/toast-queue.js +98 -0
- package/dist/0-face/toaster.d.ts +27 -0
- package/dist/0-face/toaster.d.ts.map +1 -0
- package/dist/0-face/toaster.js +373 -0
- package/dist/0-face/tooltips.d.ts +24 -1
- package/dist/0-face/tooltips.d.ts.map +1 -1
- package/dist/0-face/tooltips.js +155 -16
- package/dist/0-face/translations/da.json +60 -1
- package/dist/0-face/translations/de.json +60 -1
- package/dist/0-face/translations/en.json +60 -1
- package/dist/0-face/translations/es.json +60 -1
- package/dist/0-face/translations/fi.json +60 -1
- package/dist/0-face/translations/fr.json +60 -1
- package/dist/0-face/translations/is.json +60 -1
- package/dist/0-face/translations/it.json +60 -1
- package/dist/0-face/translations/ja.json +60 -1
- package/dist/0-face/translations/ko.json +60 -1
- package/dist/0-face/translations/nb.json +60 -1
- package/dist/0-face/translations/pt-BR.json +60 -1
- package/dist/0-face/translations/pt.json +60 -1
- package/dist/0-face/translations/sv.json +60 -1
- package/dist/0-face/translations/zh.json +60 -1
- package/dist/0-face/translations-format.d.ts.map +1 -1
- package/dist/0-face/translations-format.js +3 -4
- package/dist/0-face/tree.d.ts +69 -0
- package/dist/0-face/tree.d.ts.map +1 -0
- package/dist/0-face/tree.js +191 -0
- package/dist/1-root/library-tokens.d.ts +31 -0
- package/dist/1-root/library-tokens.d.ts.map +1 -0
- package/dist/1-root/library-tokens.js +84 -0
- package/dist/1-root/measures.d.ts +52 -0
- package/dist/1-root/measures.d.ts.map +1 -0
- package/dist/1-root/measures.js +49 -0
- package/dist/1-root/palette.d.ts +5 -0
- package/dist/1-root/palette.d.ts.map +1 -1
- package/dist/1-root/palette.js +18 -0
- package/dist/2-core/button-split.d.ts +21 -0
- package/dist/2-core/button-split.d.ts.map +1 -0
- package/dist/2-core/button-split.js +48 -0
- package/dist/2-core/chart/grid-chart.d.ts +113 -0
- package/dist/2-core/chart/grid-chart.d.ts.map +1 -0
- package/dist/2-core/chart/grid-chart.js +466 -0
- package/dist/2-core/ds-avatar.d.ts +20 -3
- package/dist/2-core/ds-avatar.d.ts.map +1 -1
- package/dist/2-core/ds-avatar.js +19 -5
- package/dist/2-core/ds-badge.js +10 -13
- package/dist/2-core/ds-banner.d.ts +23 -7
- package/dist/2-core/ds-banner.d.ts.map +1 -1
- package/dist/2-core/ds-banner.js +48 -12
- package/dist/2-core/ds-button.d.ts +76 -0
- package/dist/2-core/ds-button.d.ts.map +1 -1
- package/dist/2-core/ds-button.js +101 -26
- package/dist/2-core/ds-card.d.ts +76 -11
- package/dist/2-core/ds-card.d.ts.map +1 -1
- package/dist/2-core/ds-card.js +129 -105
- package/dist/2-core/ds-chart.d.ts +105 -0
- package/dist/2-core/ds-chart.d.ts.map +1 -0
- package/dist/2-core/ds-chart.js +390 -0
- package/dist/2-core/ds-composer.d.ts +7 -0
- package/dist/2-core/ds-composer.d.ts.map +1 -1
- package/dist/2-core/ds-composer.js +1 -1
- package/dist/2-core/ds-cycle.d.ts +36 -2
- package/dist/2-core/ds-cycle.d.ts.map +1 -1
- package/dist/2-core/ds-cycle.js +95 -18
- package/dist/2-core/ds-empty.d.ts +74 -0
- package/dist/2-core/ds-empty.d.ts.map +1 -0
- package/dist/2-core/ds-empty.js +96 -0
- package/dist/2-core/ds-icon.d.ts +6 -0
- package/dist/2-core/ds-icon.d.ts.map +1 -1
- package/dist/2-core/ds-icon.js +12 -2
- package/dist/2-core/ds-input.d.ts +39 -1
- package/dist/2-core/ds-input.d.ts.map +1 -1
- package/dist/2-core/ds-input.js +150 -6
- package/dist/2-core/ds-kbd.d.ts +48 -0
- package/dist/2-core/ds-kbd.d.ts.map +1 -0
- package/dist/2-core/ds-kbd.js +65 -0
- package/dist/2-core/ds-language.d.ts +8 -1
- package/dist/2-core/ds-language.d.ts.map +1 -1
- package/dist/2-core/ds-language.js +2 -2
- package/dist/2-core/ds-loading.d.ts +40 -0
- package/dist/2-core/ds-loading.d.ts.map +1 -0
- package/dist/2-core/ds-loading.js +63 -0
- package/dist/2-core/ds-meter.d.ts +103 -0
- package/dist/2-core/ds-meter.d.ts.map +1 -0
- package/dist/2-core/ds-meter.js +124 -0
- package/dist/2-core/ds-notice.d.ts +103 -0
- package/dist/2-core/ds-notice.d.ts.map +1 -0
- package/dist/2-core/ds-notice.js +152 -0
- package/dist/2-core/ds-pagedots.d.ts +64 -7
- package/dist/2-core/ds-pagedots.d.ts.map +1 -1
- package/dist/2-core/ds-pagedots.js +124 -18
- package/dist/2-core/ds-progress.d.ts +200 -0
- package/dist/2-core/ds-progress.d.ts.map +1 -0
- package/dist/2-core/ds-progress.js +319 -0
- package/dist/2-core/ds-spacing-handle.d.ts +25 -0
- package/dist/2-core/ds-spacing-handle.d.ts.map +1 -0
- package/dist/2-core/ds-spacing-handle.js +25 -0
- package/dist/2-core/ds-split.d.ts +4 -67
- package/dist/2-core/ds-split.d.ts.map +1 -1
- package/dist/2-core/ds-split.js +4 -98
- package/dist/2-core/ds-stat.d.ts +126 -0
- package/dist/2-core/ds-stat.d.ts.map +1 -0
- package/dist/2-core/ds-stat.js +137 -0
- package/dist/2-core/ds-steps.d.ts +72 -0
- package/dist/2-core/ds-steps.d.ts.map +1 -0
- package/dist/2-core/ds-steps.js +114 -0
- package/dist/2-core/ds-switch.d.ts +1 -0
- package/dist/2-core/ds-switch.d.ts.map +1 -1
- package/dist/2-core/ds-switch.js +1 -0
- package/dist/2-core/ds-text.d.ts +15 -2
- package/dist/2-core/ds-text.d.ts.map +1 -1
- package/dist/2-core/ds-text.js +13 -0
- package/dist/2-core/ds-textarea.d.ts.map +1 -1
- package/dist/2-core/ds-textarea.js +1 -0
- package/dist/2-core/ds-toast.d.ts +139 -0
- package/dist/2-core/ds-toast.d.ts.map +1 -0
- package/dist/2-core/ds-toast.js +329 -0
- package/dist/2-core/ds-toggle.d.ts +11 -0
- package/dist/2-core/ds-toggle.d.ts.map +1 -0
- package/dist/2-core/ds-toggle.js +10 -0
- package/dist/2-core/figures.d.ts +56 -0
- package/dist/2-core/figures.d.ts.map +1 -0
- package/dist/2-core/figures.js +70 -0
- package/dist/2-core/generated/ds-icon-map.d.ts +118 -65
- package/dist/2-core/generated/ds-icon-map.d.ts.map +1 -1
- package/dist/2-core/generated/ds-icon-map.js +234 -128
- package/dist/2-core/generated/icon-avatar.d.ts +2 -0
- package/dist/2-core/generated/icon-avatar.d.ts.map +1 -0
- package/dist/2-core/generated/icon-avatar.js +2 -0
- package/dist/2-core/generated/icons-extra.d.ts.map +1 -1
- package/dist/2-core/generated/icons-extra.js +118 -65
- package/dist/2-core/generated/icons-immediate.d.ts +1 -1
- package/dist/2-core/generated/icons-immediate.d.ts.map +1 -1
- package/dist/2-core/generated/icons-immediate.js +1 -1
- package/dist/2-core/spacing-handle.d.ts +28 -0
- package/dist/2-core/spacing-handle.d.ts.map +1 -0
- package/dist/2-core/spacing-handle.js +146 -0
- package/dist/3-unit/calendar-base.d.ts +149 -0
- package/dist/3-unit/calendar-base.d.ts.map +1 -0
- package/dist/3-unit/calendar-base.js +172 -0
- package/dist/3-unit/ds-accordion.d.ts +9 -0
- package/dist/3-unit/ds-accordion.d.ts.map +1 -1
- package/dist/3-unit/ds-accordion.js +7 -1
- package/dist/3-unit/ds-avatar-group.d.ts +1 -0
- package/dist/3-unit/ds-avatar-group.d.ts.map +1 -1
- package/dist/3-unit/ds-calendar-large.d.ts +138 -0
- package/dist/3-unit/ds-calendar-large.d.ts.map +1 -0
- package/dist/3-unit/ds-calendar-large.js +305 -0
- package/dist/3-unit/ds-calendar.d.ts +175 -0
- package/dist/3-unit/ds-calendar.d.ts.map +1 -0
- package/dist/3-unit/ds-calendar.js +303 -0
- package/dist/3-unit/ds-carousel.d.ts +182 -0
- package/dist/3-unit/ds-carousel.d.ts.map +1 -0
- package/dist/3-unit/ds-carousel.js +327 -0
- package/dist/3-unit/ds-date-picker.d.ts +203 -0
- package/dist/3-unit/ds-date-picker.d.ts.map +1 -0
- package/dist/3-unit/ds-date-picker.js +499 -0
- package/dist/3-unit/ds-form.d.ts.map +1 -1
- package/dist/3-unit/ds-form.js +38 -28
- package/dist/3-unit/ds-list.d.ts +12 -0
- package/dist/3-unit/ds-list.d.ts.map +1 -1
- package/dist/3-unit/ds-list.js +52 -1
- package/dist/3-unit/ds-matrix.d.ts +146 -0
- package/dist/3-unit/ds-matrix.d.ts.map +1 -0
- package/dist/3-unit/ds-matrix.js +248 -0
- package/dist/3-unit/ds-menu.d.ts +1 -1
- package/dist/3-unit/ds-menu.d.ts.map +1 -1
- package/dist/3-unit/ds-menu.js +7 -4
- package/dist/3-unit/ds-row.d.ts +66 -0
- package/dist/3-unit/ds-row.d.ts.map +1 -1
- package/dist/3-unit/ds-row.js +80 -1
- package/dist/3-unit/ds-sidebar.d.ts +108 -0
- package/dist/3-unit/ds-sidebar.d.ts.map +1 -0
- package/dist/3-unit/ds-sidebar.js +268 -0
- package/dist/3-unit/ds-table.d.ts +28 -10
- package/dist/3-unit/ds-table.d.ts.map +1 -1
- package/dist/3-unit/ds-table.js +53 -25
- package/dist/3-unit/ds-tree.d.ts +69 -0
- package/dist/3-unit/ds-tree.d.ts.map +1 -0
- package/dist/3-unit/ds-tree.js +136 -0
- package/dist/4-page/ds-dialog.d.ts +16 -1
- package/dist/4-page/ds-dialog.d.ts.map +1 -1
- package/dist/4-page/ds-dialog.js +39 -3
- package/dist/4-page/ds-document.d.ts +98 -0
- package/dist/4-page/ds-document.d.ts.map +1 -0
- package/dist/4-page/ds-document.js +213 -0
- package/dist/4-page/ds-footer.d.ts +100 -0
- package/dist/4-page/ds-footer.d.ts.map +1 -0
- package/dist/4-page/ds-footer.js +119 -0
- package/dist/4-page/ds-grid.d.ts +32 -12
- package/dist/4-page/ds-grid.d.ts.map +1 -1
- package/dist/4-page/ds-grid.js +30 -39
- package/dist/4-page/ds-header.d.ts +84 -0
- package/dist/4-page/ds-header.d.ts.map +1 -0
- package/dist/4-page/ds-header.js +143 -0
- package/dist/4-page/ds-layout.d.ts +1 -0
- package/dist/4-page/ds-layout.d.ts.map +1 -1
- package/dist/4-page/ds-layout.js +1 -1
- package/dist/4-page/ds-page.d.ts +110 -0
- package/dist/4-page/ds-page.d.ts.map +1 -0
- package/dist/4-page/ds-page.js +155 -0
- package/dist/4-page/email.d.ts +2 -3
- package/dist/4-page/email.d.ts.map +1 -1
- package/dist/4-page/email.js +2 -3
- package/dist/components.d.ts +4 -1
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +4 -1
- package/dist/design-system-1.bundle.js +11304 -4322
- package/dist/design-system-1.bundle.js.map +1 -1
- package/dist/design-system-1.bundle.min.js +8867 -4132
- package/dist/design-system-1.bundle.min.js.map +1 -1
- package/dist/design-system-1.css +1 -1
- package/dist/feedback.js +541 -0
- package/dist/feedback.js.map +1 -0
- package/dist/icons-extra-B4Iotc7s.js +298 -0
- package/dist/icons-extra-B4Iotc7s.js.map +1 -0
- package/dist/icons-extra-C4sCgoUj.js +185 -0
- package/dist/icons-extra-C4sCgoUj.js.map +1 -0
- package/dist/icons-extra-DSav6uTU.js +300 -0
- package/dist/icons-extra-DSav6uTU.js.map +1 -0
- package/dist/icons-extra-Dc_yVWIz.js +1024 -0
- package/dist/icons-extra-Dc_yVWIz.js.map +1 -0
- package/dist/icons-extra-cfzoudMf.js +1030 -0
- package/dist/icons-extra-cfzoudMf.js.map +1 -0
- package/dist/icons-extra-g_xpwZhZ.js +631 -0
- package/dist/icons-extra-g_xpwZhZ.js.map +1 -0
- package/dist/index.d.ts +23 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -6
- package/dist/react/avatar.d.ts +5 -9
- package/dist/react/avatar.d.ts.map +1 -1
- package/dist/react/avatar.js +2 -2
- package/dist/react/button-split.d.ts +19 -0
- package/dist/react/button-split.d.ts.map +1 -0
- package/dist/react/button-split.js +35 -0
- package/dist/react/button.d.ts +18 -7
- package/dist/react/button.d.ts.map +1 -1
- package/dist/react/button.js +13 -4
- package/dist/react/carousel.d.ts +63 -0
- package/dist/react/carousel.d.ts.map +1 -0
- package/dist/react/carousel.js +47 -0
- package/dist/react/choice.d.ts +1 -1
- package/dist/react/context-menu.d.ts +337 -337
- package/dist/react/dialog.d.ts +684 -678
- package/dist/react/dialog.d.ts.map +1 -1
- package/dist/react/dialog.js +29 -3
- package/dist/react/document.d.ts +11 -0
- package/dist/react/document.d.ts.map +1 -0
- package/dist/react/document.js +10 -0
- package/dist/react/empty.d.ts +34 -0
- package/dist/react/empty.d.ts.map +1 -0
- package/dist/react/empty.js +8 -0
- package/dist/react/file-picker.d.ts +1 -1
- package/dist/react/footer.d.ts +13 -0
- package/dist/react/footer.d.ts.map +1 -0
- package/dist/react/footer.js +12 -0
- package/dist/react/header.d.ts +12 -0
- package/dist/react/header.d.ts.map +1 -0
- package/dist/react/header.js +11 -0
- package/dist/react/input.d.ts +31 -9
- package/dist/react/input.d.ts.map +1 -1
- package/dist/react/input.js +94 -94
- package/dist/react/kbd.d.ts +26 -0
- package/dist/react/kbd.d.ts.map +1 -0
- package/dist/react/kbd.js +8 -0
- package/dist/react/loading.d.ts +14 -0
- package/dist/react/loading.d.ts.map +1 -0
- package/dist/react/loading.js +14 -0
- package/dist/react/meter.d.ts +64 -0
- package/dist/react/meter.d.ts.map +1 -0
- package/dist/react/meter.js +15 -0
- package/dist/react/notice.d.ts +45 -0
- package/dist/react/notice.d.ts.map +1 -0
- package/dist/react/notice.js +34 -0
- package/dist/react/page.d.ts +10 -0
- package/dist/react/page.d.ts.map +1 -0
- package/dist/react/page.js +9 -0
- package/dist/react/progress.d.ts +107 -0
- package/dist/react/progress.d.ts.map +1 -0
- package/dist/react/progress.js +47 -0
- package/dist/react/sidebar.d.ts +44 -0
- package/dist/react/sidebar.d.ts.map +1 -0
- package/dist/react/sidebar.js +41 -0
- package/dist/react/spacing-handle.d.ts +13 -0
- package/dist/react/spacing-handle.d.ts.map +1 -0
- package/dist/react/spacing-handle.js +18 -0
- package/dist/react/split.d.ts +6 -14
- package/dist/react/split.d.ts.map +1 -1
- package/dist/react/split.js +5 -31
- package/dist/react/stat.d.ts +78 -0
- package/dist/react/stat.d.ts.map +1 -0
- package/dist/react/stat.js +25 -0
- package/dist/react/steps.d.ts +36 -0
- package/dist/react/steps.d.ts.map +1 -0
- package/dist/react/steps.js +10 -0
- package/dist/react/toast.d.ts +37 -0
- package/dist/react/toast.d.ts.map +1 -0
- package/dist/react/toast.js +55 -0
- package/dist/react/tree.d.ts +31 -0
- package/dist/react/tree.d.ts.map +1 -0
- package/dist/react/tree.js +37 -0
- package/dist/shared-words-BfnT24Fe.js +1635 -0
- package/dist/shared-words-BfnT24Fe.js.map +1 -0
- package/dist/shared-words-CyZYc_De.js +1818 -0
- package/dist/shared-words-CyZYc_De.js.map +1 -0
- package/dist/shared-words-DAVSET4Z.js +1800 -0
- package/dist/shared-words-DAVSET4Z.js.map +1 -0
- package/dist/shared-words-UCvnkctb.js +1653 -0
- package/dist/shared-words-UCvnkctb.js.map +1 -0
- package/package.json +16 -5
- package/DS1/2-core/ds-banner.ts +0 -122
- package/DS1/2-core/ds-date.ts +0 -24
- package/DS1/2-core/ds-language.ts +0 -94
- package/DS1/2-core/ds-pagedots.ts +0 -52
- package/DS1/2-core/ds-split.ts +0 -122
- package/DS1/2-core/ds-textarea.ts +0 -136
- package/DS1/2-core/styles/ds-banner.css +0 -77
- package/DS1/2-core/styles/ds-date.css +0 -9
- package/DS1/2-core/styles/ds-language.css +0 -78
- package/DS1/2-core/styles/ds-pagedots.css +0 -31
- package/DS1/2-core/styles/ds-textarea.css +0 -27
- package/DS1/4-page/ds-layout.ts +0 -949
- package/DS1/4-page/styles/ds-layout.css +0 -246
- package/DS1/react/split.ts +0 -42
- package/DS1/x-icon/ezo-accordion-chevron.svg +0 -11
- package/DS1/x-icon/ezo-account-close.svg +0 -1
- package/DS1/x-icon/ezo-android-screen-archive.svg +0 -4
- package/DS1/x-icon/ezo-android-screen-calendar.svg +0 -6
- package/DS1/x-icon/ezo-android-screen-camera.svg +0 -5
- package/DS1/x-icon/ezo-android-screen-check.svg +0 -3
- package/DS1/x-icon/ezo-android-screen-compose.svg +0 -4
- package/DS1/x-icon/ezo-android-screen-globe.svg +0 -1
- package/DS1/x-icon/ezo-android-screen-shared.svg +0 -5
- package/DS1/x-icon/ezo-android-screen-store.svg +0 -4
- package/DS1/x-icon/ezo-android-screen-views.svg +0 -4
- package/DS1/x-icon/ezo-android-screen-work.svg +0 -3
- package/DS1/x-icon/ezo-arrow-cursor.svg +0 -8
- package/DS1/x-icon/ezo-block-accordion.svg +0 -1
- package/DS1/x-icon/ezo-block-divider.svg +0 -1
- package/DS1/x-icon/ezo-block-group.svg +0 -1
- package/DS1/x-icon/ezo-block-image.svg +0 -1
- package/DS1/x-icon/ezo-block-section.svg +0 -1
- package/DS1/x-icon/ezo-block-table.svg +0 -1
- package/DS1/x-icon/ezo-code.svg +0 -14
- package/DS1/x-icon/ezo-down.svg +0 -3
- package/DS1/x-icon/ezo-figma-premium-star.svg +0 -5
- package/DS1/x-icon/ezo-item-button-complete.svg +0 -4
- package/DS1/x-icon/ezo-item-button-header.svg +0 -3
- package/DS1/x-icon/ezo-item-button-open.svg +0 -3
- package/DS1/x-icon/ezo-item-button-star.svg +0 -3
- package/DS1/x-icon/ezo-item-button-unheader.svg +0 -7
- package/DS1/x-icon/ezo-item-button-unstar.svg +0 -5
- package/DS1/x-icon/ezo-item-star.svg +0 -5
- package/DS1/x-icon/ezo-left.svg +0 -3
- package/DS1/x-icon/ezo-logo.svg +0 -1
- package/DS1/x-icon/ezo-mic.svg +0 -8
- package/DS1/x-icon/ezo-move-column.svg +0 -14
- package/DS1/x-icon/ezo-move-row.svg +0 -18
- package/DS1/x-icon/ezo-navigation-check.svg +0 -1
- package/DS1/x-icon/ezo-note-back.svg +0 -5
- package/DS1/x-icon/ezo-note-menu-complete.svg +0 -11
- package/DS1/x-icon/ezo-note-menu-delete.svg +0 -4
- package/DS1/x-icon/ezo-note-menu-duplicate.svg +0 -8
- package/DS1/x-icon/ezo-note-menu-note.svg +0 -5
- package/DS1/x-icon/ezo-note-menu-page.svg +0 -3
- package/DS1/x-icon/ezo-note-menu-star.svg +0 -5
- package/DS1/x-icon/ezo-note-menu-start.svg +0 -6
- package/DS1/x-icon/ezo-note-menu-stop.svg +0 -6
- package/DS1/x-icon/ezo-note-more.svg +0 -7
- package/DS1/x-icon/ezo-note-star.svg +0 -5
- package/DS1/x-icon/ezo-pattern-call-to-action.svg +0 -1
- package/DS1/x-icon/ezo-play.svg +0 -5
- package/DS1/x-icon/ezo-premium-star.svg +0 -5
- package/DS1/x-icon/ezo-setting-1xdots.svg +0 -13
- package/DS1/x-icon/ezo-setting-1xgrid.svg +0 -10
- package/DS1/x-icon/ezo-setting-1xlines.svg +0 -7
- package/DS1/x-icon/ezo-setting-2xdots.svg +0 -8
- package/DS1/x-icon/ezo-setting-2xgrid.svg +0 -8
- package/DS1/x-icon/ezo-setting-2xlines.svg +0 -6
- package/DS1/x-icon/ezo-setting-blank.svg +0 -5
- package/DS1/x-icon/ezo-store-chevron.svg +0 -1
- package/DS1/x-icon/ezo-upgrade-close.svg +0 -5
- package/DS1/x-icon/product-sources.json +0 -2557
- /package/DS1/x-icon/{ezo-password-visibility-see.svg → password-see.svg} +0 -0
- /package/DS1/x-icon/{ezo-password-visibility-unsee.svg → password-unsee.svg} +0 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page toaster: Sonner's toast stack on a page without Lit or any other
|
|
3
|
+
* framework. Import it (or `0-face/feedback.ts`) and call `toast()`; nothing
|
|
4
|
+
* else goes in the page.
|
|
5
|
+
*
|
|
6
|
+
* BASED ON SONNER, the React toast library by Emil Kowalski
|
|
7
|
+
* (https://sonner.emilkowal.ski, https://github.com/emilkowalski/sonner, MIT
|
|
8
|
+
* licence), as `<ds-toast>` is: the same calls, options, stacking, timers,
|
|
9
|
+
* hover and focus pauses, swipe, Alt+T and 400ms slide and fade.
|
|
10
|
+
*
|
|
11
|
+
* It shares the look rather than wrapping the element: it draws the element's
|
|
12
|
+
* markup in a shadow root of its own with the element's stylesheet
|
|
13
|
+
* (`2-core/styles/ds-toast.css`, as plain text in `./generated/toast-assets.ts`,
|
|
14
|
+
* which `scripts/toast-assets.mjs` writes from it), so the two cannot drift
|
|
15
|
+
* apart, and it needs no Lit, which a page without Lit does not have. It is
|
|
16
|
+
* plain TypeScript: no `?inline` or `?raw` import, so any bundler and type
|
|
17
|
+
* check reads it. It shares the queue too
|
|
18
|
+
* (`0-face/toast-queue.ts`): where a `<ds-toast>` is in the page, that element
|
|
19
|
+
* takes every toast and this one stays quiet, so a page never shows two stacks.
|
|
20
|
+
*
|
|
21
|
+
* Its region is in the page before the first toast arrives, a polite live
|
|
22
|
+
* region in which each toast is announced, and an error assertively. Only
|
|
23
|
+
* `transform` and `opacity` animate, and nothing moves with reduced motion.
|
|
24
|
+
*/
|
|
25
|
+
import { feedbackWord } from "./feedback-words";
|
|
26
|
+
import { toastIcons, toastStyles } from "./generated/toast-assets";
|
|
27
|
+
import { SWIPE_THRESHOLD, SWIPE_VELOCITY, TIME_BEFORE_UNMOUNT, TOAST_DURATION, TOAST_ICONS, VISIBLE_TOASTS, listenForToasts, setFallbackToaster, } from "./toast-queue";
|
|
28
|
+
export { toast } from "./toast-queue";
|
|
29
|
+
/** The icons the page carries: the types' own and the close button's, in the text's colour. */
|
|
30
|
+
const INK = /(fill|stroke)=("|')(#1E1E1E|#2A2A2A|#000000|#000|black)\2/gi;
|
|
31
|
+
const SVGS = Object.fromEntries(Object.entries(toastIcons)
|
|
32
|
+
.map(([name, svg]) => [name, svg.replace(INK, '$1="currentColor"')]));
|
|
33
|
+
let settings = {};
|
|
34
|
+
let current;
|
|
35
|
+
/** Set the page toaster's options, as Sonner's `<Toaster />` props. Toasts already shown take them at once. */
|
|
36
|
+
export function configureToaster(options) {
|
|
37
|
+
settings = { ...settings, ...options };
|
|
38
|
+
current?.render();
|
|
39
|
+
}
|
|
40
|
+
const frame = (callback) => typeof requestAnimationFrame === "function" ? requestAnimationFrame(callback) : setTimeout(callback, 16);
|
|
41
|
+
function element(name, attributes = {}, text) {
|
|
42
|
+
const node = document.createElement(name);
|
|
43
|
+
for (const [key, value] of Object.entries(attributes))
|
|
44
|
+
node.setAttribute(key, value);
|
|
45
|
+
if (text !== undefined)
|
|
46
|
+
node.textContent = text;
|
|
47
|
+
return node;
|
|
48
|
+
}
|
|
49
|
+
function icon(name, className) {
|
|
50
|
+
const svg = SVGS[name];
|
|
51
|
+
if (!svg)
|
|
52
|
+
return undefined;
|
|
53
|
+
const span = element("span", { class: className, "aria-hidden": "true" });
|
|
54
|
+
span.innerHTML = svg;
|
|
55
|
+
return span;
|
|
56
|
+
}
|
|
57
|
+
class PageToaster {
|
|
58
|
+
constructor() {
|
|
59
|
+
this.host = element("div", { "data-ds-toaster": "" });
|
|
60
|
+
this.section = element("section", { "aria-live": "polite", "aria-relevant": "additions text", "aria-atomic": "false" });
|
|
61
|
+
this.list = element("ol", { tabindex: "-1" });
|
|
62
|
+
this.items = [];
|
|
63
|
+
this.heights = new Map();
|
|
64
|
+
this.timers = new Map();
|
|
65
|
+
this.hovered = false;
|
|
66
|
+
this.focused = false;
|
|
67
|
+
this.interacting = false;
|
|
68
|
+
this.mounting = false;
|
|
69
|
+
this.resizes = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(() => this.measure());
|
|
70
|
+
this.receive = (signal) => {
|
|
71
|
+
if ("dismiss" in signal) {
|
|
72
|
+
for (const item of this.live)
|
|
73
|
+
if (signal.dismiss === undefined || item.data.id === signal.dismiss)
|
|
74
|
+
this.removeToast(item.data.id);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this.attach();
|
|
78
|
+
const data = signal.toast;
|
|
79
|
+
const existing = this.live.find(item => item.data.id === data.id);
|
|
80
|
+
if (existing) {
|
|
81
|
+
// An update keeps what it does not change and starts its time again, as in Sonner.
|
|
82
|
+
existing.data = { ...existing.data, ...data };
|
|
83
|
+
this.clearTimer(data.id);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.items = [{ data, mounted: false, removed: false, swipeOut: false, index: 0, offset: 0 }, ...this.items.filter(item => item.data.id !== data.id)];
|
|
87
|
+
}
|
|
88
|
+
this.render();
|
|
89
|
+
};
|
|
90
|
+
/** Sonner's timers: each toast keeps its remaining time while the stack is paused. */
|
|
91
|
+
this.syncTimers = () => {
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
for (const item of this.live) {
|
|
94
|
+
const { id, type } = item.data;
|
|
95
|
+
const duration = item.data.duration ?? settings.duration ?? TOAST_DURATION;
|
|
96
|
+
if (type === "loading" || duration === Infinity) {
|
|
97
|
+
this.clearTimer(id);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
let timer = this.timers.get(id);
|
|
101
|
+
if (!timer) {
|
|
102
|
+
timer = { remaining: duration, started: now };
|
|
103
|
+
this.timers.set(id, timer);
|
|
104
|
+
}
|
|
105
|
+
if (this.paused && timer.handle !== undefined) {
|
|
106
|
+
clearTimeout(timer.handle);
|
|
107
|
+
timer.handle = undefined;
|
|
108
|
+
timer.remaining -= now - timer.started;
|
|
109
|
+
}
|
|
110
|
+
else if (!this.paused && timer.handle === undefined) {
|
|
111
|
+
timer.started = now;
|
|
112
|
+
timer.handle = setTimeout(() => this.removeToast(id, "auto"), Math.max(0, timer.remaining));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
this.hotkey = (event) => {
|
|
117
|
+
if (event.altKey && event.code === "KeyT" && this.live.length) {
|
|
118
|
+
this.focused = true;
|
|
119
|
+
this.list.focus();
|
|
120
|
+
this.render();
|
|
121
|
+
}
|
|
122
|
+
else if (event.key === "Escape" && this.focused) {
|
|
123
|
+
this.focused = false;
|
|
124
|
+
this.render();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const root = this.host.attachShadow({ mode: "open" });
|
|
128
|
+
root.appendChild(element("style", {}, toastStyles));
|
|
129
|
+
root.appendChild(this.section);
|
|
130
|
+
this.section.appendChild(this.list);
|
|
131
|
+
this.list.addEventListener("pointerenter", () => { this.hovered = true; this.render(); });
|
|
132
|
+
this.list.addEventListener("pointerleave", () => { if (!this.interacting) {
|
|
133
|
+
this.hovered = false;
|
|
134
|
+
this.render();
|
|
135
|
+
} });
|
|
136
|
+
this.list.addEventListener("focusin", () => { this.focused = true; this.render(); });
|
|
137
|
+
this.list.addEventListener("focusout", event => {
|
|
138
|
+
if (!(event.relatedTarget instanceof Node && root.contains(event.relatedTarget))) {
|
|
139
|
+
this.focused = false;
|
|
140
|
+
this.render();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
document.addEventListener("keydown", this.hotkey);
|
|
144
|
+
document.addEventListener("visibilitychange", this.syncTimers);
|
|
145
|
+
window.addEventListener("language-changed", () => this.render());
|
|
146
|
+
listenForToasts(this.receive, { fallback: true });
|
|
147
|
+
this.attach();
|
|
148
|
+
this.render();
|
|
149
|
+
}
|
|
150
|
+
/** Back in the page if something took it out, at the end of the body. */
|
|
151
|
+
attach() {
|
|
152
|
+
if (!this.host.isConnected && document.body)
|
|
153
|
+
document.body.appendChild(this.host);
|
|
154
|
+
}
|
|
155
|
+
get live() { return this.items.filter(item => !item.removed); }
|
|
156
|
+
get position() { return settings.position ?? "bottom-right"; }
|
|
157
|
+
get expanded() { return !!settings.expand || ((this.hovered || this.focused) && this.live.length > 0); }
|
|
158
|
+
get paused() { return this.hovered || this.focused || this.interacting || document.hidden; }
|
|
159
|
+
removeToast(id, how = "dismiss") {
|
|
160
|
+
const item = this.live.find(entry => entry.data.id === id);
|
|
161
|
+
if (!item)
|
|
162
|
+
return;
|
|
163
|
+
this.clearTimer(id);
|
|
164
|
+
this.heights.delete(id);
|
|
165
|
+
(how === "auto" ? item.data.onAutoClose : item.data.onDismiss)?.(item.data);
|
|
166
|
+
item.removed = true;
|
|
167
|
+
item.swipeOut = how === "swipe";
|
|
168
|
+
this.render();
|
|
169
|
+
setTimeout(() => {
|
|
170
|
+
this.items = this.items.filter(entry => entry !== item);
|
|
171
|
+
this.render();
|
|
172
|
+
}, TIME_BEFORE_UNMOUNT);
|
|
173
|
+
}
|
|
174
|
+
clearTimer(id) {
|
|
175
|
+
clearTimeout(this.timers.get(id)?.handle);
|
|
176
|
+
this.timers.delete(id);
|
|
177
|
+
}
|
|
178
|
+
measure() {
|
|
179
|
+
let changed = false;
|
|
180
|
+
for (const item of this.live) {
|
|
181
|
+
const toast = item.element;
|
|
182
|
+
const body = toast?.querySelector(".body");
|
|
183
|
+
if (!toast || !body)
|
|
184
|
+
continue;
|
|
185
|
+
const height = body.offsetHeight + toast.offsetHeight - toast.clientHeight;
|
|
186
|
+
if (this.heights.get(item.data.id) !== height) {
|
|
187
|
+
this.heights.set(item.data.id, height);
|
|
188
|
+
changed = true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (changed)
|
|
192
|
+
this.layout();
|
|
193
|
+
}
|
|
194
|
+
press(event, id, button) {
|
|
195
|
+
button.onClick?.(event);
|
|
196
|
+
if (button.href || !event.defaultPrevented)
|
|
197
|
+
this.removeToast(id);
|
|
198
|
+
}
|
|
199
|
+
button(id, button, kind) {
|
|
200
|
+
const node = button.href ? element("a", { class: `button ${kind}`, href: button.href }, button.label) : element("button", { class: `button ${kind}`, type: "button" }, button.label);
|
|
201
|
+
node.addEventListener("click", event => this.press(event, id, button));
|
|
202
|
+
return node;
|
|
203
|
+
}
|
|
204
|
+
/** The toast's words and buttons, drawn again only when they change. */
|
|
205
|
+
draw(item) {
|
|
206
|
+
const { data } = item;
|
|
207
|
+
const dismissible = data.dismissible !== false;
|
|
208
|
+
const closeButton = (data.closeButton ?? settings.closeButton ?? false) && dismissible;
|
|
209
|
+
const closeLabel = settings.closeLabel ?? feedbackWord("Close");
|
|
210
|
+
const key = JSON.stringify([data.title, data.description, data.type, data.icon, data.action?.label, data.action?.href, data.cancel?.label, data.cancel?.href, closeButton, closeLabel]);
|
|
211
|
+
const previous = item.element?.querySelector(".body");
|
|
212
|
+
if (item.drawn === key && previous)
|
|
213
|
+
return;
|
|
214
|
+
item.drawn = key;
|
|
215
|
+
if (previous)
|
|
216
|
+
this.resizes?.unobserve(previous);
|
|
217
|
+
const body = element("div", { class: "body", "data-id": String(data.id) });
|
|
218
|
+
const symbol = data.type === "loading" ? element("span", { class: "icon", "aria-hidden": "true" }) : icon(data.icon ?? TOAST_ICONS[data.type] ?? "", "icon");
|
|
219
|
+
if (data.type === "loading")
|
|
220
|
+
symbol.appendChild(element("span", { class: "spinner" }));
|
|
221
|
+
const content = element("div", { class: "content" });
|
|
222
|
+
content.appendChild(element("div", { class: "title" }, data.title));
|
|
223
|
+
if (data.description)
|
|
224
|
+
content.appendChild(element("div", { class: "description" }, data.description));
|
|
225
|
+
if (symbol)
|
|
226
|
+
body.appendChild(symbol);
|
|
227
|
+
body.appendChild(content);
|
|
228
|
+
if (data.cancel)
|
|
229
|
+
body.appendChild(this.button(data.id, data.cancel, "cancel"));
|
|
230
|
+
if (data.action)
|
|
231
|
+
body.appendChild(this.button(data.id, data.action, "action"));
|
|
232
|
+
if (closeButton) {
|
|
233
|
+
const close = element("button", { class: "close", type: "button", "aria-label": closeLabel });
|
|
234
|
+
close.innerHTML = SVGS.close;
|
|
235
|
+
close.addEventListener("click", () => this.removeToast(data.id));
|
|
236
|
+
body.appendChild(close);
|
|
237
|
+
}
|
|
238
|
+
item.element.replaceChildren(body);
|
|
239
|
+
this.resizes?.observe(body);
|
|
240
|
+
}
|
|
241
|
+
create(item) {
|
|
242
|
+
const toast = element("li", { class: "toast", role: "status", tabindex: "0", "aria-atomic": "true" });
|
|
243
|
+
const id = item.data.id;
|
|
244
|
+
toast.addEventListener("pointerdown", event => {
|
|
245
|
+
const now = this.live.find(entry => entry.data.id === id);
|
|
246
|
+
if (!now || now.data.dismissible === false || now.data.type === "loading")
|
|
247
|
+
return;
|
|
248
|
+
if (event.composedPath()[0]?.closest?.("button, a"))
|
|
249
|
+
return;
|
|
250
|
+
toast.setPointerCapture?.(event.pointerId);
|
|
251
|
+
this.swipe = { id, start: event.clientY, time: Date.now(), amount: 0 };
|
|
252
|
+
this.interacting = true;
|
|
253
|
+
this.syncTimers();
|
|
254
|
+
});
|
|
255
|
+
toast.addEventListener("pointermove", event => {
|
|
256
|
+
if (!this.swipe || this.swipe.id !== id)
|
|
257
|
+
return;
|
|
258
|
+
const toward = this.position.startsWith("top") ? -1 : 1;
|
|
259
|
+
// Only towards the edge the toast came from.
|
|
260
|
+
this.swipe.amount = Math.max(0, (event.clientY - this.swipe.start) * toward);
|
|
261
|
+
toast.dataset.swiping = "true";
|
|
262
|
+
toast.style.setProperty("--swipe", `${this.swipe.amount * toward}px`);
|
|
263
|
+
});
|
|
264
|
+
const release = () => {
|
|
265
|
+
const swipe = this.swipe;
|
|
266
|
+
if (!swipe || swipe.id !== id)
|
|
267
|
+
return;
|
|
268
|
+
this.swipe = undefined;
|
|
269
|
+
this.interacting = false;
|
|
270
|
+
delete toast.dataset.swiping;
|
|
271
|
+
const velocity = swipe.amount / Math.max(1, Date.now() - swipe.time);
|
|
272
|
+
if (swipe.amount >= SWIPE_THRESHOLD || velocity > SWIPE_VELOCITY)
|
|
273
|
+
this.removeToast(id, "swipe");
|
|
274
|
+
else
|
|
275
|
+
toast.style.setProperty("--swipe", "0px");
|
|
276
|
+
this.syncTimers();
|
|
277
|
+
};
|
|
278
|
+
toast.addEventListener("pointerup", release);
|
|
279
|
+
toast.addEventListener("pointercancel", release);
|
|
280
|
+
return toast;
|
|
281
|
+
}
|
|
282
|
+
/** Draw the stack: every toast's place, and each toast's words where they changed. */
|
|
283
|
+
render() {
|
|
284
|
+
if (!this.live.length) {
|
|
285
|
+
this.hovered = false;
|
|
286
|
+
this.focused = false;
|
|
287
|
+
}
|
|
288
|
+
this.section.setAttribute("aria-label", `${settings.label ?? feedbackWord("Notifications")} alt+T`);
|
|
289
|
+
this.host.toggleAttribute("rich-colors", !!settings.richColors);
|
|
290
|
+
for (const item of this.items) {
|
|
291
|
+
item.element ?? (item.element = this.create(item));
|
|
292
|
+
this.draw(item);
|
|
293
|
+
}
|
|
294
|
+
this.items.forEach((item, index) => {
|
|
295
|
+
if (this.list.children[index] !== item.element)
|
|
296
|
+
this.list.insertBefore(item.element, this.list.children[index] ?? null);
|
|
297
|
+
});
|
|
298
|
+
// A copy: the live collection shrinks as children leave.
|
|
299
|
+
for (const child of Array.from(this.list.children)) {
|
|
300
|
+
if (this.items.some(item => item.element === child))
|
|
301
|
+
continue;
|
|
302
|
+
const body = child.querySelector(".body");
|
|
303
|
+
if (body)
|
|
304
|
+
this.resizes?.unobserve(body);
|
|
305
|
+
child.remove();
|
|
306
|
+
}
|
|
307
|
+
this.layout();
|
|
308
|
+
this.measure();
|
|
309
|
+
this.syncTimers();
|
|
310
|
+
if (!this.mounting && this.items.some(item => !item.mounted)) {
|
|
311
|
+
// Mount on the next frame so the toast slides in from its edge.
|
|
312
|
+
this.mounting = true;
|
|
313
|
+
frame(() => {
|
|
314
|
+
this.mounting = false;
|
|
315
|
+
for (const item of this.items)
|
|
316
|
+
item.mounted = true;
|
|
317
|
+
this.layout();
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/** Each toast's index and offset, counting live toasts only; one leaving keeps where it was. */
|
|
322
|
+
layout() {
|
|
323
|
+
let offset = 0;
|
|
324
|
+
this.live.forEach((item, index) => {
|
|
325
|
+
item.index = index;
|
|
326
|
+
item.offset = offset;
|
|
327
|
+
offset += this.heights.get(item.data.id) ?? 0;
|
|
328
|
+
});
|
|
329
|
+
const live = this.live;
|
|
330
|
+
const frontHeight = live.length ? this.heights.get(live[0].data.id) ?? 0 : 0;
|
|
331
|
+
const expanded = this.expanded;
|
|
332
|
+
const [y, x] = this.position.split("-");
|
|
333
|
+
Object.assign(this.list.dataset, { y, x, expanded: String(expanded) });
|
|
334
|
+
this.list.style.setProperty("--height", `${expanded ? offset : frontHeight}px`);
|
|
335
|
+
this.list.style.setProperty("--gaps", String(expanded ? Math.max(0, live.length - 1) : 0));
|
|
336
|
+
const visible = settings.visibleToasts ?? VISIBLE_TOASTS;
|
|
337
|
+
for (const item of this.items) {
|
|
338
|
+
const toast = item.element;
|
|
339
|
+
toast.setAttribute("aria-live", item.data.important ? "assertive" : "polite");
|
|
340
|
+
Object.assign(toast.dataset, {
|
|
341
|
+
type: item.data.type,
|
|
342
|
+
front: String(item.index === 0),
|
|
343
|
+
mounted: String(item.mounted),
|
|
344
|
+
removed: String(item.removed),
|
|
345
|
+
swipeOut: String(item.swipeOut),
|
|
346
|
+
visible: String(item.index < visible),
|
|
347
|
+
});
|
|
348
|
+
toast.style.setProperty("--index", String(item.index));
|
|
349
|
+
toast.style.setProperty("--offset", `${item.offset}px`);
|
|
350
|
+
toast.style.setProperty("--front-height", `${frontHeight}px`);
|
|
351
|
+
toast.style.zIndex = String(this.items.length - item.index);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/** The page toaster, put in the page when it is first needed. */
|
|
356
|
+
export function pageToaster() {
|
|
357
|
+
if (typeof document === "undefined" || !document.body)
|
|
358
|
+
return undefined;
|
|
359
|
+
current ?? (current = new PageToaster());
|
|
360
|
+
current.attach();
|
|
361
|
+
return current.host;
|
|
362
|
+
}
|
|
363
|
+
setFallbackToaster(() => { pageToaster(); });
|
|
364
|
+
// The region is in the page before the first toast, so the first is announced
|
|
365
|
+
// too; not where a `<ds-toast>` already draws the toasts.
|
|
366
|
+
if (typeof document !== "undefined") {
|
|
367
|
+
const ready = () => { if (typeof customElements === "undefined" || !customElements.get("ds-toast"))
|
|
368
|
+
pageToaster(); };
|
|
369
|
+
if (document.readyState === "loading")
|
|
370
|
+
document.addEventListener("DOMContentLoaded", ready, { once: true });
|
|
371
|
+
else
|
|
372
|
+
ready();
|
|
373
|
+
}
|
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One tooltip for a whole page: any element with `data-tooltip="…"` shows its text in Design system 1's tooltip,
|
|
3
|
-
*
|
|
3
|
+
* a small label: 16px high, black with white text (white on black in dark mode), 4px corners, 14px regular, 2.5px at
|
|
4
4
|
* the sides, two pixels above the element, shown at once. `data-tooltip-colour` gives it a colour of its own. The same look as `<ds-tooltip>`, without wrapping each element in a component, so a table of
|
|
5
5
|
* hundreds of cells can carry one each. Long text wraps at 320px on 20px lines.
|
|
6
|
+
* Elements inside a component's open shadow root are found as well (`ds-sidebar`
|
|
7
|
+
* marks its cut-short labels this way); the description link is set only on
|
|
8
|
+
* elements in the document itself, since an id cannot reach across a shadow root.
|
|
9
|
+
*
|
|
10
|
+
* It shows on hover with a mouse or pen, and on focus only when the focus is
|
|
11
|
+
* the keyboard's (`:focus-visible`), so a menu that moves focus into its first
|
|
12
|
+
* row does not raise one. A showing tooltip follows its text as
|
|
13
|
+
* `data-tooltip` changes. On touch, a long press shows it, and a tap does on
|
|
14
|
+
* an element marked `data-tooltip-press`; it goes at the next touch or after
|
|
15
|
+
* a moment. `showTooltip(element)` and `hideTooltip()` show and hide it from
|
|
16
|
+
* code.
|
|
6
17
|
*/
|
|
18
|
+
/** How long a tooltip raised by touch stays, in milliseconds. */
|
|
19
|
+
export declare const TOUCH_TOOLTIP_DURATION = 2000;
|
|
20
|
+
/** How long a finger rests before a long press shows the tooltip, in milliseconds. */
|
|
21
|
+
export declare const LONG_PRESS_DELAY = 500;
|
|
22
|
+
export type ShowTooltipOptions = {
|
|
23
|
+
/** Hide it after this many milliseconds; it stays until hidden by default. */
|
|
24
|
+
duration?: number;
|
|
25
|
+
};
|
|
26
|
+
/** Show an element's `data-tooltip` now, as a press would: it stays until `hideTooltip()`, or for `duration`. */
|
|
27
|
+
export declare function showTooltip(target: HTMLElement, options?: ShowTooltipOptions): void;
|
|
28
|
+
/** Hide the tooltip, however it was shown. */
|
|
29
|
+
export declare function hideTooltip(): void;
|
|
7
30
|
export declare function initTooltips(): void;
|
|
8
31
|
//# sourceMappingURL=tooltips.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltips.d.ts","sourceRoot":"","sources":["../../DS1/0-face/tooltips.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tooltips.d.ts","sourceRoot":"","sources":["../../DS1/0-face/tooltips.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAIpC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAeF,iHAAiH;AACjH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAGnF;AAED,8CAA8C;AAC9C,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAED,wBAAgB,YAAY,IAAI,IAAI,CAoKnC"}
|
package/dist/0-face/tooltips.js
CHANGED
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One tooltip for a whole page: any element with `data-tooltip="…"` shows its text in Design system 1's tooltip,
|
|
3
|
-
*
|
|
3
|
+
* a small label: 16px high, black with white text (white on black in dark mode), 4px corners, 14px regular, 2.5px at
|
|
4
4
|
* the sides, two pixels above the element, shown at once. `data-tooltip-colour` gives it a colour of its own. The same look as `<ds-tooltip>`, without wrapping each element in a component, so a table of
|
|
5
5
|
* hundreds of cells can carry one each. Long text wraps at 320px on 20px lines.
|
|
6
|
+
* Elements inside a component's open shadow root are found as well (`ds-sidebar`
|
|
7
|
+
* marks its cut-short labels this way); the description link is set only on
|
|
8
|
+
* elements in the document itself, since an id cannot reach across a shadow root.
|
|
9
|
+
*
|
|
10
|
+
* It shows on hover with a mouse or pen, and on focus only when the focus is
|
|
11
|
+
* the keyboard's (`:focus-visible`), so a menu that moves focus into its first
|
|
12
|
+
* row does not raise one. A showing tooltip follows its text as
|
|
13
|
+
* `data-tooltip` changes. On touch, a long press shows it, and a tap does on
|
|
14
|
+
* an element marked `data-tooltip-press`; it goes at the next touch or after
|
|
15
|
+
* a moment. `showTooltip(element)` and `hideTooltip()` show and hide it from
|
|
16
|
+
* code.
|
|
6
17
|
*/
|
|
18
|
+
/** How long a tooltip raised by touch stays, in milliseconds. */
|
|
19
|
+
export const TOUCH_TOOLTIP_DURATION = 2000;
|
|
20
|
+
/** How long a finger rests before a long press shows the tooltip, in milliseconds. */
|
|
21
|
+
export const LONG_PRESS_DELAY = 500;
|
|
22
|
+
/** How far a finger may move, in pixels, before a press is a scroll instead. */
|
|
23
|
+
const PRESS_SLOP = 10;
|
|
24
|
+
// Shared through the window, so two copies of this module on a page share one tooltip.
|
|
25
|
+
const KEY = Symbol.for("ds-one:tooltips");
|
|
26
|
+
function controller() {
|
|
27
|
+
return typeof window === "undefined" ? undefined : window[KEY];
|
|
28
|
+
}
|
|
29
|
+
/** Show an element's `data-tooltip` now, as a press would: it stays until `hideTooltip()`, or for `duration`. */
|
|
30
|
+
export function showTooltip(target, options) {
|
|
31
|
+
initTooltips();
|
|
32
|
+
controller()?.show(target, options);
|
|
33
|
+
}
|
|
34
|
+
/** Hide the tooltip, however it was shown. */
|
|
35
|
+
export function hideTooltip() {
|
|
36
|
+
controller()?.hide();
|
|
37
|
+
}
|
|
7
38
|
export function initTooltips() {
|
|
8
|
-
if (typeof document === "undefined")
|
|
39
|
+
if (typeof document === "undefined" || !document.body)
|
|
9
40
|
return;
|
|
10
41
|
const root = document.documentElement;
|
|
11
42
|
if (root.hasAttribute("data-ds-tooltips-ready"))
|
|
@@ -32,6 +63,7 @@ export function initTooltips() {
|
|
|
32
63
|
document.head.appendChild(style);
|
|
33
64
|
document.body.appendChild(bubble);
|
|
34
65
|
let current = null;
|
|
66
|
+
let timer;
|
|
35
67
|
const place = (target) => {
|
|
36
68
|
const box = target.getBoundingClientRect();
|
|
37
69
|
const width = bubble.offsetWidth;
|
|
@@ -41,46 +73,153 @@ export function initTooltips() {
|
|
|
41
73
|
const top = box.top - height - 2 >= 4 ? box.top - height - 2 : box.bottom + 2;
|
|
42
74
|
bubble.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
|
|
43
75
|
};
|
|
44
|
-
|
|
76
|
+
/** Draws the target's text and colour; false when it has no text. */
|
|
77
|
+
const draw = (target) => {
|
|
45
78
|
const text = target.dataset.tooltip;
|
|
46
79
|
if (!text)
|
|
47
|
-
return;
|
|
48
|
-
current = target;
|
|
80
|
+
return false;
|
|
49
81
|
bubble.textContent = text;
|
|
50
|
-
// A colour of its own, as
|
|
82
|
+
// A colour of its own, such as the accent: data-tooltip-colour="#f5aad1", lettered in the ink.
|
|
51
83
|
const colour = target.dataset.tooltipColour;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
84
|
+
if (colour) {
|
|
85
|
+
bubble.style.setProperty("--ds-tooltip-background", colour);
|
|
86
|
+
bubble.style.setProperty("--ds-tooltip-color", "#1e1e1e");
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
55
89
|
bubble.style.removeProperty("--ds-tooltip-background");
|
|
56
90
|
bubble.style.removeProperty("--ds-tooltip-color");
|
|
57
91
|
}
|
|
58
|
-
// One line
|
|
92
|
+
// One line; a long text wraps at 320px instead of running off the page.
|
|
59
93
|
bubble.classList.remove("is-wide");
|
|
60
94
|
if (bubble.scrollWidth > 320)
|
|
61
95
|
bubble.classList.add("is-wide");
|
|
62
|
-
target.setAttribute("aria-describedby", bubble.id);
|
|
63
96
|
place(target);
|
|
97
|
+
return true;
|
|
98
|
+
};
|
|
99
|
+
// A showing tooltip follows its element's text and colour, and goes when the text does.
|
|
100
|
+
const watcher = typeof MutationObserver === "function"
|
|
101
|
+
? new MutationObserver(() => { if (current && (!current.isConnected || !draw(current)))
|
|
102
|
+
hide(); })
|
|
103
|
+
: null;
|
|
104
|
+
const show = (target, options = {}) => {
|
|
105
|
+
clearTimeout(timer);
|
|
106
|
+
timer = undefined;
|
|
107
|
+
if (current && current !== target)
|
|
108
|
+
hide();
|
|
109
|
+
if (!draw(target))
|
|
110
|
+
return;
|
|
111
|
+
current = target;
|
|
112
|
+
if (target.getRootNode() === document)
|
|
113
|
+
target.setAttribute("aria-describedby", bubble.id);
|
|
114
|
+
watcher?.disconnect();
|
|
115
|
+
watcher?.observe(target, { attributes: true, attributeFilter: ["data-tooltip", "data-tooltip-colour"] });
|
|
64
116
|
bubble.classList.add("is-visible");
|
|
117
|
+
if (options.duration !== undefined && options.duration >= 0)
|
|
118
|
+
timer = setTimeout(hide, options.duration);
|
|
65
119
|
};
|
|
66
|
-
|
|
120
|
+
function hide() {
|
|
121
|
+
clearTimeout(timer);
|
|
122
|
+
timer = undefined;
|
|
123
|
+
watcher?.disconnect();
|
|
67
124
|
current?.removeAttribute("aria-describedby");
|
|
68
125
|
current = null;
|
|
69
126
|
bubble.classList.remove("is-visible");
|
|
127
|
+
}
|
|
128
|
+
window[KEY] = { show, hide };
|
|
129
|
+
// The composed path crosses open shadow roots, where `closest` stops at the host.
|
|
130
|
+
const find = (event) => {
|
|
131
|
+
for (const node of event.composedPath()) {
|
|
132
|
+
if (node === document || node === window)
|
|
133
|
+
break;
|
|
134
|
+
if (node.hasAttribute?.("data-tooltip"))
|
|
135
|
+
return node;
|
|
136
|
+
}
|
|
137
|
+
return event.target?.closest?.("[data-tooltip]") ?? null;
|
|
70
138
|
};
|
|
71
|
-
const
|
|
139
|
+
const keyboardFocus = (event) => {
|
|
140
|
+
const focused = event.composedPath()[0];
|
|
141
|
+
try {
|
|
142
|
+
return Boolean(focused?.matches?.(":focus-visible"));
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// A browser without :focus-visible cannot tell, and a pointer's focus must not raise one.
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
const touch = (event) => event.pointerType === "touch";
|
|
72
150
|
document.addEventListener("pointerover", (event) => {
|
|
151
|
+
// A finger has no hover: on touch a press shows the tooltip.
|
|
152
|
+
if (touch(event))
|
|
153
|
+
return;
|
|
73
154
|
const target = find(event);
|
|
74
155
|
if (target !== current)
|
|
75
156
|
target ? show(target) : hide();
|
|
76
157
|
}, { passive: true });
|
|
77
|
-
document.addEventListener("pointerleave",
|
|
78
|
-
|
|
79
|
-
|
|
158
|
+
document.addEventListener("pointerleave", (event) => { if (!touch(event))
|
|
159
|
+
hide(); }, { passive: true });
|
|
160
|
+
document.addEventListener("focusin", (event) => {
|
|
161
|
+
const target = find(event);
|
|
162
|
+
if (target && keyboardFocus(event))
|
|
163
|
+
show(target);
|
|
164
|
+
});
|
|
80
165
|
document.addEventListener("focusout", hide);
|
|
81
166
|
document.addEventListener("keydown", (event) => { if (event.key === "Escape")
|
|
82
167
|
hide(); });
|
|
83
168
|
window.addEventListener("scroll", hide, { passive: true, capture: true });
|
|
169
|
+
// Touch: a long press shows the label, a tap does where the element asks for it, and the next touch dismisses it.
|
|
170
|
+
let press = null;
|
|
171
|
+
let swallowClick = false;
|
|
172
|
+
const release = () => {
|
|
173
|
+
if (press)
|
|
174
|
+
clearTimeout(press.timer);
|
|
175
|
+
press = null;
|
|
176
|
+
};
|
|
177
|
+
document.addEventListener("pointerdown", (event) => {
|
|
178
|
+
swallowClick = false;
|
|
179
|
+
if (!touch(event))
|
|
180
|
+
return;
|
|
181
|
+
release();
|
|
182
|
+
hide();
|
|
183
|
+
const target = find(event);
|
|
184
|
+
if (!target?.dataset.tooltip)
|
|
185
|
+
return;
|
|
186
|
+
const pointer = event;
|
|
187
|
+
press = {
|
|
188
|
+
target,
|
|
189
|
+
id: pointer.pointerId,
|
|
190
|
+
x: pointer.clientX,
|
|
191
|
+
y: pointer.clientY,
|
|
192
|
+
timer: setTimeout(() => {
|
|
193
|
+
if (!press)
|
|
194
|
+
return;
|
|
195
|
+
// The press was for the label: the click its release makes is not the element's.
|
|
196
|
+
swallowClick = true;
|
|
197
|
+
show(press.target, { duration: TOUCH_TOOLTIP_DURATION });
|
|
198
|
+
press = null;
|
|
199
|
+
}, LONG_PRESS_DELAY),
|
|
200
|
+
};
|
|
201
|
+
}, { passive: true, capture: true });
|
|
202
|
+
document.addEventListener("pointermove", (event) => {
|
|
203
|
+
const pointer = event;
|
|
204
|
+
if (press && pointer.pointerId === press.id && Math.hypot(pointer.clientX - press.x, pointer.clientY - press.y) > PRESS_SLOP)
|
|
205
|
+
release();
|
|
206
|
+
}, { passive: true, capture: true });
|
|
207
|
+
document.addEventListener("pointerup", (event) => {
|
|
208
|
+
if (!press || event.pointerId !== press.id)
|
|
209
|
+
return;
|
|
210
|
+
const { target } = press;
|
|
211
|
+
release();
|
|
212
|
+
if (target.hasAttribute("data-tooltip-press"))
|
|
213
|
+
show(target, { duration: TOUCH_TOOLTIP_DURATION });
|
|
214
|
+
}, { passive: true, capture: true });
|
|
215
|
+
document.addEventListener("pointercancel", release, { passive: true, capture: true });
|
|
216
|
+
document.addEventListener("click", (event) => {
|
|
217
|
+
if (!swallowClick)
|
|
218
|
+
return;
|
|
219
|
+
swallowClick = false;
|
|
220
|
+
event.preventDefault();
|
|
221
|
+
event.stopPropagation();
|
|
222
|
+
}, { capture: true });
|
|
84
223
|
}
|
|
85
224
|
if (typeof document !== "undefined") {
|
|
86
225
|
if (document.readyState === "loading")
|