@ebrains/components 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/clone-846acfdd.js +5 -0
- package/dist/cjs/color-primary-palette_6.cjs.entry.js +15 -15
- package/dist/cjs/components-section.cjs.entry.js +2 -2
- package/dist/cjs/components.cjs.js +2 -2
- package/dist/cjs/correct-use-of-colors.cjs.entry.js +2 -2
- package/dist/cjs/docs-palettes.cjs.entry.js +2 -2
- package/dist/cjs/docs-tokens.cjs.entry.js +2 -2
- package/dist/cjs/edit-ff5b84d8.js +5 -0
- package/dist/cjs/{eds-avatar_26.cjs.entry.js → eds-accordion_33.cjs.entry.js} +3467 -157
- package/dist/cjs/eds-app-root.cjs.entry.js +2 -2
- package/dist/cjs/eds-card-desc_2.cjs.entry.js +3 -3
- package/dist/cjs/eds-card-generic.cjs.entry.js +1 -1
- package/dist/cjs/eds-card-project.cjs.entry.js +2 -2
- package/dist/cjs/eds-card-section.cjs.entry.js +1 -1
- package/dist/cjs/eds-card-tags.cjs.entry.js +2 -2
- package/dist/cjs/eds-card-tool.cjs.entry.js +2 -2
- package/dist/cjs/eds-cookies-preference.cjs.entry.js +2 -2
- package/dist/cjs/eds-feedback.cjs.entry.js +2 -2
- package/dist/cjs/eds-footer.cjs.entry.js +9 -3
- package/dist/cjs/eds-frame.cjs.entry.js +2 -2
- package/dist/cjs/eds-fullscreen-menu.cjs.entry.js +1 -1
- package/dist/cjs/eds-gauge.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-arrow-diagonal.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-arrow-right.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-bin.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-bluesky.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-bookmark.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-chevron-down.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-chevron-left.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-chevron-right.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-chevron-up.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-clone.cjs.entry.js +18 -0
- package/dist/cjs/eds-icon-close.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-copy.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-draft.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-edit.cjs.entry.js +3 -3
- package/dist/cjs/eds-icon-eu.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-external.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-facebook.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-gitlab.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-linkedin.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-loader.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-mastodon.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-menu.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-minus.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-more.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-paper.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-plus.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-portal.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-private.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-public.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-search.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-star.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-start.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-success.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-thumbs-down.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-thumbs-up.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-tutorial.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-twitter.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-unknown.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-updown.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-user.cjs.entry.js +2 -2
- package/dist/cjs/eds-icon-view.cjs.entry.js +18 -0
- package/dist/cjs/eds-icon-youtube.cjs.entry.js +2 -2
- package/dist/cjs/eds-modal.cjs.entry.js +3 -3
- package/dist/cjs/eds-pie.cjs.entry.js +1 -1
- package/dist/cjs/eds-progress-bar.cjs.entry.js +2 -2
- package/dist/cjs/eds-section-core_2.cjs.entry.js +4 -4
- package/dist/cjs/eds-social-networks.cjs.entry.js +2 -2
- package/dist/cjs/eds-spinner.cjs.entry.js +2 -2
- package/dist/cjs/eds-splash-screen.cjs.entry.js +1 -1
- package/dist/cjs/eds-timeline.cjs.entry.js +2 -2
- package/dist/cjs/eds-toast-manager.cjs.entry.js +2 -2
- package/dist/cjs/eds-tooltip.cjs.entry.js +2 -2
- package/dist/cjs/eds-trl.cjs.entry.js +2 -2
- package/dist/cjs/incorrect-use-of-colors.cjs.entry.js +2 -2
- package/dist/cjs/{index-88c8039f.js → index-0249a32e.js} +15 -28
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/logo-space.cjs.entry.js +2 -2
- package/dist/cjs/logo-variations-horizontal_2.cjs.entry.js +3 -3
- package/dist/cjs/logo-variations-tabs.cjs.entry.js +2 -2
- package/dist/cjs/logo-wrong-usage.cjs.entry.js +2 -2
- package/dist/cjs/svg-repository.cjs.entry.js +8 -4
- package/dist/cjs/token-list_3.cjs.entry.js +4 -4
- package/dist/cjs/token-ratios.cjs.entry.js +2 -2
- package/dist/cjs/token-spacing.cjs.entry.js +2 -2
- package/dist/cjs/token-typography.cjs.entry.js +2 -2
- package/dist/cjs/view-80d5c6c8.js +5 -0
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/eds-accordion/eds-accordion.js +1 -1
- package/dist/collection/components/eds-alert/eds-alert.js +30 -3
- package/dist/collection/components/eds-avatar/eds-avatar.js +1 -1
- package/dist/collection/components/eds-block-break/eds-block-break.js +1 -1
- package/dist/collection/components/eds-breadcrump/eds-breadcrump.js +1 -1
- package/dist/collection/components/eds-button/eds-button.css +4 -0
- package/dist/collection/components/eds-button/eds-button.js +19 -8
- package/dist/collection/components/eds-cards/eds-card-composer/eds-card-desc/eds-card-desc.js +1 -1
- package/dist/collection/components/eds-cards/eds-card-composer/eds-card-tags/eds-card-tags.js +1 -1
- package/dist/collection/components/eds-cards/eds-card-composer/eds-card-title/eds-card-title.js +1 -1
- package/dist/collection/components/eds-cards/eds-card-project/eds-card-project.js +1 -1
- package/dist/collection/components/eds-cards/eds-card-tool/eds-card-tool.js +1 -1
- package/dist/collection/components/eds-charts/eds-gauge/eds-gauge.js +1 -1
- package/dist/collection/components/eds-code-block/eds-code-block.js +1 -1
- package/dist/collection/components/eds-dropdown/eds-dropdown.js +2 -2
- package/dist/collection/components/eds-icons/chevron/eds-icon-chevron-down/eds-icon-chevron-down.js +1 -1
- package/dist/collection/components/eds-icons/chevron/eds-icon-chevron-left/eds-icon-chevron-left.js +1 -1
- package/dist/collection/components/eds-icons/chevron/eds-icon-chevron-right/eds-icon-chevron-right.js +1 -1
- package/dist/collection/components/eds-icons/chevron/eds-icon-chevron-up/eds-icon-chevron-up.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-arrow-diagonal/eds-icon-arrow-diagonal.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-arrow-right/eds-icon-arrow-right.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-bin/eds-icon-bin.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-bookmark/eds-icon-bookmark.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-clone/eds-icon-clone.js +36 -0
- package/dist/collection/components/eds-icons/eds-icon-close/eds-icon-close.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-copy/eds-icon-copy.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-draft/eds-icon-draft.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-edit/eds-icon-edit.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-eu/eds-icon-eu.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-external/eds-icon-external.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-gitlab/eds-icon-gitlab.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-loader/eds-icon-loader.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-menu/eds-icon-menu.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-minus/eds-icon-minus.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-more/eds-icon-more.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-paper/eds-icon-paper.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-plus/eds-icon-plus.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-portal/eds-icon-portal.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-private/eds-icon-private.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-public/eds-icon-public.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-search/eds-icon-search.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-star/eds-icon-star.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-start/eds-icon-start.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-success/eds-icon-success.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-thumbs-down/eds-icon-thumbs-down.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-thumbs-up/eds-icon-thumbs-up.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-tutorial/eds-icon-tutorial.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-unknown/eds-icon-unknown.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-updown/eds-icon-updown.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-user/eds-icon-user.js +1 -1
- package/dist/collection/components/eds-icons/eds-icon-view/eds-icon-view.js +36 -0
- package/dist/collection/components/eds-icons/social/eds-icon-bluesky/eds-icon-bluesky.js +1 -1
- package/dist/collection/components/eds-icons/social/eds-icon-facebook/eds-icon-facebook.js +1 -1
- package/dist/collection/components/eds-icons/social/eds-icon-linkedin/eds-icon-linkedin.js +1 -1
- package/dist/collection/components/eds-icons/social/eds-icon-mastodon/eds-icon-mastodon.js +1 -1
- package/dist/collection/components/eds-icons/social/eds-icon-twitter/eds-icon-twitter.js +1 -1
- package/dist/collection/components/eds-icons/social/eds-icon-youtube/eds-icon-youtube.js +1 -1
- package/dist/collection/components/eds-img/eds-img.js +2 -2
- package/dist/collection/components/eds-input-elements/eds-input/eds-input.js +2 -2
- package/dist/collection/components/eds-input-elements/eds-input-footer/eds-input-footer.js +1 -1
- package/dist/collection/components/eds-input-elements/eds-input-label/eds-input-label.js +1 -1
- package/dist/collection/components/eds-input-elements/eds-input-range/eds-input-range.js +1 -1
- package/dist/collection/components/eds-input-elements/eds-input-search/eds-input-search.js +1 -1
- package/dist/collection/components/eds-input-elements/eds-input-select/eds-input-select.js +2 -2
- package/dist/collection/components/eds-input-field/eds-input-field.js +3 -2
- package/dist/collection/components/eds-link/eds-link.js +27 -7
- package/dist/collection/components/eds-link/eds-link.stories.js +3 -1
- package/dist/collection/components/eds-logo/eds-logo.js +1 -1
- package/dist/collection/components/eds-modal/eds-modal.js +2 -2
- package/dist/collection/components/eds-nps/eds-npm.stories.js +36 -0
- package/dist/collection/components/eds-nps/eds-nps.css +73 -0
- package/dist/collection/components/eds-nps/eds-nps.js +163 -0
- package/dist/collection/components/eds-pagination/eds-pagination.css +4 -0
- package/dist/collection/components/eds-pagination/eds-pagination.js +130 -50
- package/dist/collection/components/eds-progress-bar/eds-progress-bar.js +1 -1
- package/dist/collection/components/eds-rating/eds-rating.js +25 -3
- package/dist/collection/components/eds-section/eds-section-core/eds-section-core.js +1 -1
- package/dist/collection/components/eds-section/eds-section-heading/eds-section-heading.js +2 -2
- package/dist/collection/components/eds-spinner/eds-spinner.js +1 -1
- package/dist/collection/components/eds-switch/eds-switch.css +15 -5
- package/dist/collection/components/eds-switch/eds-switch.js +26 -4
- package/dist/collection/components/eds-table/eds-table.js +38 -37
- package/dist/collection/components/eds-table/eds-table.stories.js +1 -1
- package/dist/collection/components/eds-tag/eds-tag.js +1 -1
- package/dist/collection/components/eds-timeline/eds-timeline.js +1 -1
- package/dist/collection/components/eds-tooltip/eds-tooltip.js +1 -1
- package/dist/collection/components/eds-trl/eds-trl.js +1 -1
- package/dist/collection/eds-docs-ui/colors/color-palette/primary.js +1 -1
- package/dist/collection/eds-docs-ui/colors/color-palette/secondary.js +1 -1
- package/dist/collection/eds-docs-ui/colors/color-palette/support.js +1 -1
- package/dist/collection/eds-docs-ui/colors/gradient-palette/primary.js +1 -1
- package/dist/collection/eds-docs-ui/colors/gradient-palette/secondary.js +7 -7
- package/dist/collection/eds-docs-ui/colors/gradient-palette/support.js +3 -3
- package/dist/collection/eds-docs-ui/colors/use-of-colors/correct-use-of-colors.js +1 -1
- package/dist/collection/eds-docs-ui/colors/use-of-colors/incorrect-use-of-colors.js +1 -1
- package/dist/collection/eds-docs-ui/components-section/components-section.js +1 -1
- package/dist/collection/eds-docs-ui/design-tokens/docs-tokens/docs-tokens.js +1 -1
- package/dist/collection/eds-docs-ui/design-tokens/token-list/token-list.js +1 -1
- package/dist/collection/eds-docs-ui/design-tokens/token-radii/token-radii.js +1 -1
- package/dist/collection/eds-docs-ui/design-tokens/token-ratios/token-ratios.js +1 -1
- package/dist/collection/eds-docs-ui/design-tokens/token-shadows/token-shadows.js +1 -1
- package/dist/collection/eds-docs-ui/design-tokens/token-spacing/token-spacing.js +1 -1
- package/dist/collection/eds-docs-ui/design-tokens/token-typography/token-typography.js +1 -1
- package/dist/collection/eds-docs-ui/docs-palettes/docs-palettes.js +1 -1
- package/dist/collection/eds-docs-ui/logo/logo-space/logo-space.js +1 -1
- package/dist/collection/eds-docs-ui/logo/logo-variations/horizontal/logo-variations-horizontal.js +1 -1
- package/dist/collection/eds-docs-ui/logo/logo-variations/vertical/logo-variations-vertical.js +1 -1
- package/dist/collection/eds-docs-ui/logo/logo-variations-tabs/logo-variations.js +1 -1
- package/dist/collection/eds-docs-ui/logo/logo-wrong-usage/logo-wrong-usage.js +1 -1
- package/dist/collection/eds-docs-ui/svg-repository/svg-repository.js +1 -1
- package/dist/collection/shared-ui/eds-cookies-preference/eds-cookies-preference.js +1 -1
- package/dist/collection/shared-ui/eds-feedback/eds-feedback.js +1 -1
- package/dist/collection/shared-ui/eds-footer/eds-footer.js +8 -2
- package/dist/collection/shared-ui/eds-form/eds-form.js +26 -4
- package/dist/collection/shared-ui/eds-form/eds-form.stories.js +1 -1
- package/dist/collection/shared-ui/eds-frame/eds-frame.js +1 -1
- package/dist/collection/shared-ui/eds-header/eds-header.js +1 -1
- package/dist/collection/shared-ui/eds-social-networks/eds-social-networks.js +1 -1
- package/dist/collection/shared-ui/eds-tabs/eds-tabs.css +26 -5
- package/dist/collection/shared-ui/eds-tabs/eds-tabs.js +89 -31
- package/dist/collection/shared-ui/eds-toast-manager/eds-toast-manager.js +1 -1
- package/dist/collection/shared-ui/eds-user/eds-user.js +1 -1
- package/dist/collection/shared-ui/examples/eds-app-root/eds-app-root.js +1 -1
- package/dist/collection/utils/eds-form/formValidators.js +33 -0
- package/dist/components/clone.js +3 -0
- package/dist/components/components-section.js +1 -1
- package/dist/components/components.css +7 -9
- package/dist/components/components.esm.js +1 -1
- package/dist/components/correct-use-of-colors.js +1 -1
- package/dist/components/docs-palettes.js +1 -1
- package/dist/components/docs-tokens.js +1 -1
- package/dist/components/edit.js +1 -1
- package/dist/components/eds-accordion2.js +1 -1
- package/dist/components/eds-alert2.js +21 -5
- package/dist/components/eds-app-root.js +1 -1
- package/dist/components/eds-avatar2.js +1 -1
- package/dist/components/eds-block-break2.js +1 -1
- package/dist/components/eds-breadcrumb.js +1 -1
- package/dist/components/eds-button2.js +21 -10
- package/dist/components/eds-card-desc2.js +1 -1
- package/dist/components/eds-card-project.js +1 -1
- package/dist/components/eds-card-tags.js +1 -1
- package/dist/components/eds-card-title2.js +1 -1
- package/dist/components/eds-card-tool.js +1 -1
- package/dist/components/eds-code-block2.js +1 -1
- package/dist/components/eds-cookies-preference.js +1 -1
- package/dist/components/eds-dropdown2.js +2 -2
- package/dist/components/eds-feedback.js +1 -1
- package/dist/components/eds-footer2.js +8 -2
- package/dist/components/eds-form.js +80 -22
- package/dist/components/eds-frame.js +1 -1
- package/dist/components/eds-gauge.js +1 -1
- package/dist/components/eds-header.js +1 -1
- package/dist/components/eds-icon-arrow-diagonal.js +1 -1
- package/dist/components/eds-icon-arrow-right.js +1 -1
- package/dist/components/eds-icon-bin.js +1 -1
- package/dist/components/eds-icon-bluesky.js +1 -1
- package/dist/components/eds-icon-bookmark.js +1 -1
- package/dist/components/eds-icon-chevron-down.js +1 -1
- package/dist/components/eds-icon-chevron-left.js +1 -1
- package/dist/components/eds-icon-chevron-right.js +1 -1
- package/dist/components/eds-icon-chevron-up.js +1 -1
- package/dist/components/eds-icon-clone.d.ts +11 -0
- package/dist/components/eds-icon-clone.js +33 -0
- package/dist/components/eds-icon-close.js +1 -1
- package/dist/components/eds-icon-copy.js +1 -1
- package/dist/components/eds-icon-draft.js +1 -1
- package/dist/components/eds-icon-edit.js +1 -1
- package/dist/components/eds-icon-eu.js +1 -1
- package/dist/components/eds-icon-external.js +1 -1
- package/dist/components/eds-icon-facebook.js +1 -1
- package/dist/components/eds-icon-gitlab.js +1 -1
- package/dist/components/eds-icon-linkedin.js +1 -1
- package/dist/components/eds-icon-loader.js +1 -1
- package/dist/components/eds-icon-mastodon.js +1 -1
- package/dist/components/eds-icon-menu.js +1 -1
- package/dist/components/eds-icon-minus.js +1 -1
- package/dist/components/eds-icon-more.js +1 -1
- package/dist/components/eds-icon-paper.js +1 -1
- package/dist/components/eds-icon-plus.js +1 -1
- package/dist/components/eds-icon-portal.js +1 -1
- package/dist/components/eds-icon-private.js +1 -1
- package/dist/components/eds-icon-public.js +1 -1
- package/dist/components/eds-icon-search.js +1 -1
- package/dist/components/eds-icon-star.js +1 -1
- package/dist/components/eds-icon-start.js +1 -1
- package/dist/components/eds-icon-success.js +1 -1
- package/dist/components/eds-icon-thumbs-down.js +1 -1
- package/dist/components/eds-icon-thumbs-up.js +1 -1
- package/dist/components/eds-icon-tutorial.js +1 -1
- package/dist/components/eds-icon-twitter.js +1 -1
- package/dist/components/eds-icon-unknown.js +1 -1
- package/dist/components/eds-icon-updown.js +1 -1
- package/dist/components/eds-icon-user.js +1 -1
- package/dist/components/eds-icon-view.d.ts +11 -0
- package/dist/components/eds-icon-view.js +33 -0
- package/dist/components/eds-icon-youtube.js +1 -1
- package/dist/components/eds-img2.js +2 -2
- package/dist/components/eds-input-field2.js +4 -3
- package/dist/components/eds-input-footer2.js +1 -1
- package/dist/components/eds-input-label2.js +1 -1
- package/dist/components/eds-input-range2.js +1 -1
- package/dist/components/eds-input-search2.js +1 -1
- package/dist/components/eds-input-select2.js +2 -2
- package/dist/components/eds-input2.js +2 -2
- package/dist/components/eds-link2.js +27 -7
- package/dist/components/eds-logo2.js +1 -1
- package/dist/components/eds-modal.js +2 -2
- package/dist/components/eds-nps.d.ts +11 -0
- package/dist/components/eds-nps.js +6 -0
- package/dist/components/eds-nps2.js +120 -0
- package/dist/components/eds-pagination2.js +119 -52
- package/dist/components/eds-progress-bar2.js +1 -1
- package/dist/components/eds-rating2.js +25 -3
- package/dist/components/eds-section-core2.js +1 -1
- package/dist/components/eds-section-heading2.js +2 -2
- package/dist/components/eds-social-networks2.js +1 -1
- package/dist/components/eds-spinner2.js +1 -1
- package/dist/components/eds-switch.js +27 -5
- package/dist/components/eds-table2.js +45 -20
- package/dist/components/eds-tabs.js +90 -32
- package/dist/components/eds-tag2.js +1 -1
- package/dist/components/eds-timeline.js +1 -1
- package/dist/components/eds-toast-manager.js +1 -1
- package/dist/components/eds-tooltip.js +1 -1
- package/dist/components/eds-trl.js +8 -2
- package/dist/components/eds-user.js +3 -9
- package/dist/components/incorrect-use-of-colors.js +9 -3
- package/dist/components/logo-space.js +8 -2
- package/dist/components/logo-variations-horizontal2.js +1 -1
- package/dist/components/logo-variations-tabs.js +1 -1
- package/dist/components/logo-variations-vertical2.js +1 -1
- package/dist/components/logo-wrong-usage.js +1 -1
- package/dist/components/p-05654483.entry.js +1 -0
- package/dist/components/{p-9e53eca3.entry.js → p-09079c5c.entry.js} +1 -1
- package/dist/components/p-10997947.entry.js +1 -0
- package/dist/components/p-19e69c03.entry.js +1 -0
- package/dist/components/p-1ab1ea29.entry.js +1 -0
- package/dist/components/p-1bcf743d.entry.js +1 -0
- package/dist/components/{p-9d18d7b1.entry.js → p-1d18106d.entry.js} +1 -1
- package/dist/components/{p-adbd0d7b.entry.js → p-265150a1.entry.js} +1 -1
- package/dist/components/p-27c4a06e.js +1 -0
- package/dist/components/{p-e35e156d.entry.js → p-2e0c3fc4.entry.js} +1 -1
- package/dist/components/{p-6d3b5818.entry.js → p-2ef4dd11.entry.js} +1 -1
- package/dist/components/p-3360e1e2.entry.js +1 -0
- package/dist/components/{p-93e6ba0f.entry.js → p-38bc21e9.entry.js} +1 -1
- package/dist/components/p-3b29e0fd.entry.js +1 -0
- package/dist/components/p-42457a0f.entry.js +1 -0
- package/dist/components/p-4a6a72db.entry.js +1 -0
- package/dist/components/p-4b33909d.entry.js +1 -0
- package/dist/components/p-4bf4bc93.entry.js +1 -0
- package/dist/components/{p-773a119a.entry.js → p-4c84fcf4.entry.js} +1 -1
- package/dist/components/p-4eb2cf7f.js +1 -0
- package/dist/components/p-5367bb59.entry.js +1 -0
- package/dist/components/p-547a53d6.entry.js +1 -0
- package/dist/components/p-560fc3a4.entry.js +1 -0
- package/dist/components/p-5a58f1c1.entry.js +1 -0
- package/dist/components/p-5b55f951.entry.js +1 -0
- package/dist/components/p-5ba49cf2.entry.js +1 -0
- package/dist/components/p-5dd85979.entry.js +1 -0
- package/dist/components/{p-356846cd.entry.js → p-5f348b0e.entry.js} +1 -1
- package/dist/components/p-634b6ca2.entry.js +1 -0
- package/dist/components/{p-b073d78f.entry.js → p-64b7a6fc.entry.js} +1 -1
- package/dist/components/{p-02d94d2d.entry.js → p-6614881d.entry.js} +1 -1
- package/dist/components/{p-2839899a.entry.js → p-67ec46b4.entry.js} +1 -1
- package/dist/components/p-6b988c76.entry.js +1 -0
- package/dist/components/p-6cd6ff0c.entry.js +1 -0
- package/dist/components/{p-f6ca2aa6.entry.js → p-706a106c.entry.js} +1 -1
- package/dist/components/p-71ee4af2.entry.js +1 -0
- package/dist/components/{p-794f11e7.entry.js → p-743f9f8f.entry.js} +1 -1
- package/dist/components/p-789f54cb.entry.js +1 -0
- package/dist/components/{p-8c0b0121.entry.js → p-79afd8aa.entry.js} +1 -1
- package/dist/components/{p-b3a40663.entry.js → p-7a3f2576.entry.js} +1 -1
- package/dist/components/p-7a5623b5.entry.js +1 -0
- package/dist/components/p-7ca6db64.entry.js +1 -0
- package/dist/components/p-7fa46b01.entry.js +1 -0
- package/dist/components/{p-3e183368.entry.js → p-8627afc0.entry.js} +1 -1
- package/dist/components/p-86eff0cb.entry.js +1 -0
- package/dist/components/p-89048f87.entry.js +1 -0
- package/dist/components/p-8cf98230.entry.js +1 -0
- package/dist/components/{p-8dee879d.entry.js → p-8d363a3c.entry.js} +1 -1
- package/dist/components/p-9261d27c.entry.js +1 -0
- package/dist/components/p-97323c46.entry.js +1 -0
- package/dist/components/p-9b90296c.entry.js +1 -0
- package/dist/components/{p-1f5c19b9.entry.js → p-9c1c5e8d.entry.js} +1 -1
- package/dist/components/p-9cb14b1f.entry.js +1 -0
- package/dist/components/p-9f0a34b4.entry.js +1 -0
- package/dist/components/p-a8ca8346.entry.js +1 -0
- package/dist/components/{p-43468b0f.entry.js → p-ab3b0a53.entry.js} +1 -1
- package/dist/components/p-b0d38b78.entry.js +1 -0
- package/dist/components/{p-66f4cdd9.entry.js → p-b31babda.entry.js} +1 -1
- package/dist/components/p-b6ee4250.entry.js +1 -0
- package/dist/components/{p-0687532c.entry.js → p-b88a2267.entry.js} +1 -1
- package/dist/components/{p-024789cc.entry.js → p-b9a1aba3.entry.js} +1 -1
- package/dist/components/p-b9fdcb1b.entry.js +1 -0
- package/dist/components/{p-73c74835.entry.js → p-ba9f41de.entry.js} +1 -1
- package/dist/components/p-beacaa4f.entry.js +1 -0
- package/dist/components/p-bfa23535.entry.js +1 -0
- package/dist/components/p-c4ac0528.entry.js +1 -0
- package/dist/components/p-cb114bf4.entry.js +1 -0
- package/dist/components/p-cd05a97b.entry.js +1 -0
- package/dist/components/{p-3a331c68.entry.js → p-cd787744.entry.js} +1 -1
- package/dist/components/p-cdc1c8e8.entry.js +1 -0
- package/dist/components/{p-4e473b4e.entry.js → p-d1927da7.entry.js} +1 -1
- package/dist/components/{p-564431ad.entry.js → p-d1d1943b.entry.js} +1 -1
- package/dist/components/{p-543f2347.entry.js → p-d2e485a1.entry.js} +1 -1
- package/dist/components/{p-e2e7250a.entry.js → p-d95d7353.entry.js} +1 -1
- package/dist/components/{p-76905315.entry.js → p-e0ada7e0.entry.js} +1 -1
- package/dist/components/{p-70e8e66f.entry.js → p-e210ddbb.entry.js} +1 -1
- package/dist/components/p-e5892379.entry.js +1 -0
- package/dist/components/p-e8374410.entry.js +1 -0
- package/dist/components/p-e90da4ba.entry.js +1 -0
- package/dist/components/p-ec706eed.entry.js +1 -0
- package/dist/components/{p-28ae3f3a.js → p-efbc374c.js} +2 -2
- package/dist/components/p-f2abe4d8.js +1 -0
- package/dist/components/p-f32963ff.entry.js +9 -0
- package/dist/components/p-f40dd50d.entry.js +1 -0
- package/dist/components/p-f6012c17.entry.js +1 -0
- package/dist/components/p-fcba31fa.entry.js +1 -0
- package/dist/components/primary.js +1 -1
- package/dist/components/primary2.js +1 -1
- package/dist/components/secondary.js +1 -1
- package/dist/components/secondary2.js +7 -7
- package/dist/components/support.js +1 -1
- package/dist/components/support2.js +3 -3
- package/dist/components/svg-repository.js +13 -3
- package/dist/components/token-list2.js +1 -1
- package/dist/components/token-radii2.js +1 -1
- package/dist/components/token-ratios.js +1 -1
- package/dist/components/token-shadows2.js +1 -1
- package/dist/components/token-spacing.js +1 -1
- package/dist/components/token-typography.js +1 -1
- package/dist/components/view.js +3 -0
- package/dist/esm/clone-dab56639.js +3 -0
- package/dist/esm/color-primary-palette_6.entry.js +15 -15
- package/dist/esm/components-section.entry.js +2 -2
- package/dist/esm/components.js +3 -3
- package/dist/esm/correct-use-of-colors.entry.js +2 -2
- package/dist/esm/docs-palettes.entry.js +2 -2
- package/dist/esm/docs-tokens.entry.js +2 -2
- package/dist/esm/edit-3893a517.js +3 -0
- package/dist/esm/{eds-avatar_26.entry.js → eds-accordion_33.entry.js} +3462 -159
- package/dist/esm/eds-app-root.entry.js +2 -2
- package/dist/esm/eds-card-desc_2.entry.js +3 -3
- package/dist/esm/eds-card-generic.entry.js +1 -1
- package/dist/esm/eds-card-project.entry.js +2 -2
- package/dist/esm/eds-card-section.entry.js +1 -1
- package/dist/esm/eds-card-tags.entry.js +2 -2
- package/dist/esm/eds-card-tool.entry.js +2 -2
- package/dist/esm/eds-cookies-preference.entry.js +2 -2
- package/dist/esm/eds-feedback.entry.js +2 -2
- package/dist/esm/eds-footer.entry.js +9 -3
- package/dist/esm/eds-frame.entry.js +2 -2
- package/dist/esm/eds-fullscreen-menu.entry.js +1 -1
- package/dist/esm/eds-gauge.entry.js +2 -2
- package/dist/esm/eds-icon-arrow-diagonal.entry.js +2 -2
- package/dist/esm/eds-icon-arrow-right.entry.js +2 -2
- package/dist/esm/eds-icon-bin.entry.js +2 -2
- package/dist/esm/eds-icon-bluesky.entry.js +2 -2
- package/dist/esm/eds-icon-bookmark.entry.js +2 -2
- package/dist/esm/eds-icon-chevron-down.entry.js +2 -2
- package/dist/esm/eds-icon-chevron-left.entry.js +2 -2
- package/dist/esm/eds-icon-chevron-right.entry.js +2 -2
- package/dist/esm/eds-icon-chevron-up.entry.js +2 -2
- package/dist/esm/eds-icon-clone.entry.js +14 -0
- package/dist/esm/eds-icon-close.entry.js +2 -2
- package/dist/esm/eds-icon-copy.entry.js +2 -2
- package/dist/esm/eds-icon-draft.entry.js +2 -2
- package/dist/esm/eds-icon-edit.entry.js +3 -3
- package/dist/esm/eds-icon-eu.entry.js +2 -2
- package/dist/esm/eds-icon-external.entry.js +2 -2
- package/dist/esm/eds-icon-facebook.entry.js +2 -2
- package/dist/esm/eds-icon-gitlab.entry.js +2 -2
- package/dist/esm/eds-icon-linkedin.entry.js +2 -2
- package/dist/esm/eds-icon-loader.entry.js +2 -2
- package/dist/esm/eds-icon-mastodon.entry.js +2 -2
- package/dist/esm/eds-icon-menu.entry.js +2 -2
- package/dist/esm/eds-icon-minus.entry.js +2 -2
- package/dist/esm/eds-icon-more.entry.js +2 -2
- package/dist/esm/eds-icon-paper.entry.js +2 -2
- package/dist/esm/eds-icon-plus.entry.js +2 -2
- package/dist/esm/eds-icon-portal.entry.js +2 -2
- package/dist/esm/eds-icon-private.entry.js +2 -2
- package/dist/esm/eds-icon-public.entry.js +2 -2
- package/dist/esm/eds-icon-search.entry.js +2 -2
- package/dist/esm/eds-icon-star.entry.js +2 -2
- package/dist/esm/eds-icon-start.entry.js +2 -2
- package/dist/esm/eds-icon-success.entry.js +2 -2
- package/dist/esm/eds-icon-thumbs-down.entry.js +2 -2
- package/dist/esm/eds-icon-thumbs-up.entry.js +2 -2
- package/dist/esm/eds-icon-tutorial.entry.js +2 -2
- package/dist/esm/eds-icon-twitter.entry.js +2 -2
- package/dist/esm/eds-icon-unknown.entry.js +2 -2
- package/dist/esm/eds-icon-updown.entry.js +2 -2
- package/dist/esm/eds-icon-user.entry.js +2 -2
- package/dist/esm/eds-icon-view.entry.js +14 -0
- package/dist/esm/eds-icon-youtube.entry.js +2 -2
- package/dist/esm/eds-modal.entry.js +3 -3
- package/dist/esm/eds-pie.entry.js +1 -1
- package/dist/esm/eds-progress-bar.entry.js +2 -2
- package/dist/esm/eds-section-core_2.entry.js +4 -4
- package/dist/esm/eds-social-networks.entry.js +2 -2
- package/dist/esm/eds-spinner.entry.js +2 -2
- package/dist/esm/eds-splash-screen.entry.js +1 -1
- package/dist/esm/eds-timeline.entry.js +2 -2
- package/dist/esm/eds-toast-manager.entry.js +2 -2
- package/dist/esm/eds-tooltip.entry.js +2 -2
- package/dist/esm/eds-trl.entry.js +2 -2
- package/dist/esm/incorrect-use-of-colors.entry.js +2 -2
- package/dist/esm/{index-fdb33359.js → index-e84b871c.js} +15 -28
- package/dist/esm/loader.js +3 -3
- package/dist/esm/logo-space.entry.js +2 -2
- package/dist/esm/logo-variations-horizontal_2.entry.js +3 -3
- package/dist/esm/logo-variations-tabs.entry.js +2 -2
- package/dist/esm/logo-wrong-usage.entry.js +2 -2
- package/dist/esm/svg-repository.entry.js +8 -4
- package/dist/esm/token-list_3.entry.js +4 -4
- package/dist/esm/token-ratios.entry.js +2 -2
- package/dist/esm/token-spacing.entry.js +2 -2
- package/dist/esm/token-typography.entry.js +2 -2
- package/dist/esm/view-e900f2d4.js +3 -0
- package/dist/hydrate/index.js +690 -257
- package/dist/hydrate/index.mjs +690 -257
- package/dist/types/Users/nigeor/Documents/Projects/EBRAINS/ebrains-ui-ecosystem/packages/components/.stencil/packages/svgs/src/lib/svgs.d.ts +3 -1
- package/dist/types/components/eds-alert/eds-alert.d.ts +6 -0
- package/dist/types/components/eds-button/eds-button.d.ts +1 -0
- package/dist/types/components/eds-icons/eds-icon-clone/eds-icon-clone.d.ts +10 -0
- package/dist/types/components/eds-icons/eds-icon-view/eds-icon-view.d.ts +10 -0
- package/dist/types/components/eds-link/eds-link.d.ts +1 -0
- package/dist/types/components/eds-nps/eds-npm.stories.d.ts +28 -0
- package/dist/types/components/eds-nps/eds-nps.d.ts +20 -0
- package/dist/types/components/eds-pagination/eds-pagination.d.ts +23 -2
- package/dist/types/components/eds-rating/eds-rating.d.ts +3 -1
- package/dist/types/components/eds-switch/eds-switch.d.ts +1 -0
- package/dist/types/components/eds-table/eds-table.d.ts +3 -4
- package/dist/types/components/eds-table/eds-table.stories.d.ts +7 -2
- package/dist/types/components.d.ts +133 -12
- package/dist/types/shared-ui/eds-form/eds-form.d.ts +1 -0
- package/dist/types/shared-ui/eds-tabs/eds-tabs.d.ts +7 -9
- package/dist/types/utils/eds-form/formValidators.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/edit-5714c144.js +0 -5
- package/dist/cjs/eds-accordion.cjs.entry.js +0 -87
- package/dist/cjs/eds-alert.cjs.entry.js +0 -104
- package/dist/cjs/eds-breadcrumb.cjs.entry.js +0 -145
- package/dist/cjs/eds-code-block.cjs.entry.js +0 -2489
- package/dist/cjs/eds-matomo-notice.cjs.entry.js +0 -125
- package/dist/cjs/eds-switch.cjs.entry.js +0 -46
- package/dist/components/p-023bc47c.entry.js +0 -1
- package/dist/components/p-02df910c.entry.js +0 -1
- package/dist/components/p-0be79e08.entry.js +0 -1
- package/dist/components/p-0e74d8b4.entry.js +0 -1
- package/dist/components/p-11efb1d1.entry.js +0 -1
- package/dist/components/p-1791ce82.entry.js +0 -1
- package/dist/components/p-19d586e6.entry.js +0 -1
- package/dist/components/p-2679926c.entry.js +0 -1
- package/dist/components/p-2d1a7471.entry.js +0 -1
- package/dist/components/p-2ff16a39.entry.js +0 -1
- package/dist/components/p-32e18e48.entry.js +0 -1
- package/dist/components/p-38e99d4b.entry.js +0 -1
- package/dist/components/p-4088ae0e.entry.js +0 -1
- package/dist/components/p-4277fb1a.entry.js +0 -1
- package/dist/components/p-42a73db4.entry.js +0 -1
- package/dist/components/p-44055e68.entry.js +0 -1
- package/dist/components/p-4a5d0dcd.entry.js +0 -1
- package/dist/components/p-4a7412ec.entry.js +0 -1
- package/dist/components/p-4b88d84c.entry.js +0 -1
- package/dist/components/p-50f43dfd.entry.js +0 -1
- package/dist/components/p-562afa88.entry.js +0 -1
- package/dist/components/p-5aa4065a.entry.js +0 -1
- package/dist/components/p-5ae1c931.entry.js +0 -1
- package/dist/components/p-634258e6.entry.js +0 -1
- package/dist/components/p-68f45098.entry.js +0 -1
- package/dist/components/p-73a44c48.entry.js +0 -1
- package/dist/components/p-7dbe791f.entry.js +0 -1
- package/dist/components/p-7ec52188.entry.js +0 -1
- package/dist/components/p-7fc84bb2.js +0 -1
- package/dist/components/p-82559816.entry.js +0 -1
- package/dist/components/p-85683b18.entry.js +0 -1
- package/dist/components/p-8681e5d8.entry.js +0 -1
- package/dist/components/p-877d13d9.entry.js +0 -1
- package/dist/components/p-911b1c0b.entry.js +0 -1
- package/dist/components/p-960aa103.entry.js +0 -1
- package/dist/components/p-996005b7.entry.js +0 -1
- package/dist/components/p-aa5e75b4.entry.js +0 -1
- package/dist/components/p-ae9393b6.entry.js +0 -1
- package/dist/components/p-af137162.entry.js +0 -1
- package/dist/components/p-b630e51a.entry.js +0 -1
- package/dist/components/p-bb9af709.entry.js +0 -1
- package/dist/components/p-c2dc3692.entry.js +0 -1
- package/dist/components/p-c91b4eec.entry.js +0 -1
- package/dist/components/p-caff3355.entry.js +0 -1
- package/dist/components/p-ce66ea37.entry.js +0 -1
- package/dist/components/p-d4f239d7.entry.js +0 -1
- package/dist/components/p-d7251d4d.entry.js +0 -1
- package/dist/components/p-deb9bbed.entry.js +0 -1
- package/dist/components/p-ed4d9bf5.entry.js +0 -1
- package/dist/components/p-ed7696a2.entry.js +0 -1
- package/dist/components/p-f2416727.entry.js +0 -1
- package/dist/components/p-f28b5da7.entry.js +0 -1
- package/dist/components/p-f3839914.entry.js +0 -1
- package/dist/components/p-f42b6251.entry.js +0 -1
- package/dist/components/p-f7a31196.entry.js +0 -1
- package/dist/components/p-f973c83b.entry.js +0 -1
- package/dist/components/p-fe167c78.entry.js +0 -9
- package/dist/esm/edit-1dc8d11b.js +0 -3
- package/dist/esm/eds-accordion.entry.js +0 -83
- package/dist/esm/eds-alert.entry.js +0 -100
- package/dist/esm/eds-breadcrumb.entry.js +0 -141
- package/dist/esm/eds-code-block.entry.js +0 -2485
- package/dist/esm/eds-matomo-notice.entry.js +0 -121
- package/dist/esm/eds-switch.entry.js +0 -42
- /package/dist/collection/shared-ui/eds-toast-manager/{eds-toast-manager.stories.js → eds-toast-manager.st.js} +0 -0
- /package/dist/types/shared-ui/eds-toast-manager/{eds-toast-manager.stories.d.ts → eds-toast-manager.st.d.ts} +0 -0
|
@@ -1,10 +1,195 @@
|
|
|
1
|
-
import { r as registerInstance, h, g as getElement,
|
|
2
|
-
import { s as sendAnalytics } from './analytics-d99780e3.js';
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-e84b871c.js';
|
|
2
|
+
import { s as sendAnalytics, m as matomoOptIn, a as matomoOptOut } from './analytics-d99780e3.js';
|
|
3
3
|
import { c as cva } from './index-39c58238.js';
|
|
4
4
|
import { p as parseData } from './sharedUtils-a550989c.js';
|
|
5
5
|
import { h as hLogoColor } from './logo-color-7f1fd803.js';
|
|
6
6
|
import { h as hLogoBlack, a as hLogoColorWhite, b as hLogoWhite, c as hLogoWhiteNoBg, v as vLogoColor, d as vLogoBlack, e as vLogoColorWhite, f as vLogoWhite, g as vLogoWhiteNoBg } from './logo-white-no-bg-f382f86f.js';
|
|
7
7
|
|
|
8
|
+
const edsAccordionCss = "blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}.min-h-56{min-height:3.5rem}.container{width:calc(var(--container-width, 100%) - (2 * var(--breakout-container-outer-gutter, var(--container-outer-gutter, var(--outer-gutter, 0)))));margin-right:auto;margin-left:auto}.container>*{--container-outer-gutter:0;--breakout-container-outer-gutter:0}.break-words{overflow-wrap:break-word}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.effect-color{transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:300ms;transition-timing-function:cubic-bezier(0, 0, 0.2, 1)}.border-softer{border:2px solid rgba(0, 0, 0, .1)}.bg-default{background-color:var(--grey-200)}.bg-inverse{background-color:var(--white)}.relative{position:relative}.absolute{position:absolute}.inset-x-16{left:1rem;right:1rem}.top-16{top:1rem}.pr-32{padding-right:2rem}.pr-36{padding-right:2.25rem}.pr-40{padding-right:2.5rem}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.line-clamp-3{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3}.line-clamp-4{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:4}.w-full{width:100%}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.rounded-md{border-radius:12px}.outline-none{outline:2px solid transparent;outline-offset:2px}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.text-light{color:var(--grey-700)}.z-1{z-index:1}.z-10{z-index:10}.effect-height{transition-duration:300ms;transition-timing-function:cubic-bezier(0, 0, 0.2, 1);transition-property:height}.h-0{height:0rem}.h-auto{height:auto}.pt-4{padding-top:0.25rem}.overflow-hidden{overflow:hidden}.grid{display:grid}.overflow-hidden{overflow:hidden}.rounded-lg{border-radius:16px}.border-2{border-width:2px}.p-16{padding:1rem}.ml-auto{margin-left:auto}.mr-auto{margin-right:auto}.f-heading-06{font-family:var(--f-heading-06-fontFamily);font-weight:var(--f-heading-06-fontWeight);font-size:var(--f-heading-06-fontSize);line-height:var(--f-heading-06-lineHeight);letter-spacing:var(--f-heading-06-letterSpacing)}.text-left{text-align:left}.text-center{text-align:center}";
|
|
9
|
+
const EdsAccordionStyle0 = edsAccordionCss;
|
|
10
|
+
|
|
11
|
+
const EdsAccordion = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
registerInstance(this, hostRef);
|
|
14
|
+
this.accordion = createEvent(this, "accordion", 7);
|
|
15
|
+
/**
|
|
16
|
+
* Handles the click event on the accordion header to toggle expansion.
|
|
17
|
+
* Toggles the `isExpanded` state and emits the `accordion` event.
|
|
18
|
+
*/
|
|
19
|
+
this.handleClick = () => {
|
|
20
|
+
var _a;
|
|
21
|
+
this.isExpanded = !this.isExpanded;
|
|
22
|
+
this.accordion.emit(this.isExpanded);
|
|
23
|
+
this.setPanelHeight();
|
|
24
|
+
sendAnalytics({
|
|
25
|
+
category: 'ui-component',
|
|
26
|
+
parentContext: null,
|
|
27
|
+
tag: this.el.tagName.toLowerCase(),
|
|
28
|
+
name: ((_a = this.heading) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '',
|
|
29
|
+
action: this.isExpanded ? 'expanded' : 'collapsed'
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Calculates and sets the panel height based on the content height
|
|
34
|
+
* and adjusts based on the `shortContent` and `isExpanded` states.
|
|
35
|
+
*/
|
|
36
|
+
this.setPanelHeight = () => {
|
|
37
|
+
if (this.childContentRef) {
|
|
38
|
+
this.shortContent =
|
|
39
|
+
this.wrapperRef.scrollWidth > 830 && !this.description
|
|
40
|
+
? this.childContentRef.scrollHeight <= 80
|
|
41
|
+
: this.childContentRef.scrollHeight <= 20;
|
|
42
|
+
this.panelHeight = this.isExpanded && !this.shortContent ? this.childContentRef.scrollHeight : 0;
|
|
43
|
+
}
|
|
44
|
+
if (this.headerRef) {
|
|
45
|
+
this.headerHeight = this.headerRef.scrollHeight - 30;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.heading = undefined;
|
|
49
|
+
this.description = undefined;
|
|
50
|
+
this.switchBg = true;
|
|
51
|
+
this.expanded = false;
|
|
52
|
+
this.clampText = true;
|
|
53
|
+
this.buttonIntent = 'tertiary';
|
|
54
|
+
this.isExpanded = this.expanded;
|
|
55
|
+
this.panelHeight = 0;
|
|
56
|
+
this.shortContent = false;
|
|
57
|
+
this.headerHeight = 0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Lifecycle method that sets up the initial panel height and adds a resize event listener
|
|
61
|
+
* to recalculate height on window resize.
|
|
62
|
+
*/
|
|
63
|
+
componentDidLoad() {
|
|
64
|
+
this.setPanelHeight();
|
|
65
|
+
window.addEventListener('resize', this.setPanelHeight);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Lifecycle method that cleans up the resize event listener when the component is removed.
|
|
69
|
+
*/
|
|
70
|
+
disconnectedCallback() {
|
|
71
|
+
window.removeEventListener('resize', this.setPanelHeight);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Renders the accordion structure, including header, content, description, and any slotted content.
|
|
75
|
+
* Adjusts styles based on `switchBg`, `tiny`, `clampText`, and other props.
|
|
76
|
+
*/
|
|
77
|
+
render() {
|
|
78
|
+
return (h("div", { key: '1abfd8bfea763bc10e6f17148dbc252d0c3ffdea', ref: (el) => (this.wrapperRef = el), class: `flex effect-color border-softer relative grid overflow-hidden rounded-lg border-2 p-16
|
|
79
|
+
${this.switchBg && this.isExpanded ? 'bg-inverse' : 'bg-default'}
|
|
80
|
+
${this.switchBg ? 'hover:bg-inverse' : ''}
|
|
81
|
+
${this.description ? 'min-h-56' : ''}` }, h("h3", { key: '137a3311195d51f46c6677558219828e5f4d06b5', ref: (el) => (this.headerRef = el), class: "mr-auto f-heading-06 text-left absolute inset-x-16 break-words top-16 pr-40" }, this.heading), h("div", { key: '0fc6d493fd61726a53a8c4311bd183eb3ad5b270', class: "ml-auto" }, h("eds-button", { key: 'cb8182e05c5c11950c0e624ce6b11e27a4d506ab', id: "toggleAccordion", intent: this.buttonIntent, "aria-expanded": this.isExpanded || this.shortContent, "aria-label": "Toggle accordion", "aria-controls": "accordionSection", class: `effect-color flex w-full items-center justify-between rounded-md`, onClick: this.handleClick, icon: "chevron-down" })), h("div", { key: '084bfb116dcccadf7253ca8ac8de6a1e1d4aa41f', class: `w-full`, style: Number.isFinite(this.headerHeight) ? { marginTop: `${this.headerHeight}px` } : {} }, this.description ? (h("span", { class: `text-light ${!this.isExpanded && this.clampText ? 'line-clamp-1' : ''}` }, this.description)) : null, h("section", { key: 'c332a210fa4ce90f1974098ff790a7600dfb1721', id: "accordionSection", "aria-labelledby": "accordionHeader", "aria-hidden": !this.isExpanded, class: `z-1 effect-height relative h-0 w-full ${!this.isExpanded && this.clampText ? 'overflow-hidden' : ''}`, style: { height: this.isExpanded ? 'auto' : '0' } }, h("div", { key: '842bc3bc7a968ef5a428a97327f38253e8a32888', ref: (el) => (this.childContentRef = el), class: `accordion-content effect-color pt-4`, "aria-hidden": !this.isExpanded }, h("span", { key: '7c8fa8040da18cc2c128b42cdf9e75bfffe4c439', class: `${!this.isExpanded && this.clampText ? 'line-clamp-2' : ''}` }, h("slot", { key: '852837c0c8c9d8a36f6263f7a943f50d82563a3c' })))))));
|
|
82
|
+
}
|
|
83
|
+
get el() { return getElement(this); }
|
|
84
|
+
};
|
|
85
|
+
EdsAccordion.style = EdsAccordionStyle0;
|
|
86
|
+
|
|
87
|
+
const edsAlertCss = "*,\n::before,\n::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n border-color: currentColor;\n}\n\np {\n margin: 0;\n}\n\n.f-ui-01 {\n font-family: var(--f-ui-01-fontFamily);\n font-weight: var(--f-ui-01-fontWeight);\n font-size: var(--f-ui-01-fontSize);\n line-height: var(--f-ui-01-lineHeight);\n letter-spacing: var(--f-ui-01-letterSpacing);\n}\n\n.border-inside {\n position: relative;\n\n &::after {\n pointer-events: none;\n }\n\n &::after {\n position: absolute;\n }\n\n &::after {\n inset: 0rem;\n }\n\n &::after {\n z-index: 1;\n }\n\n &::after {\n border-radius: 8px;\n }\n\n &::after {\n border-width: 1px;\n }\n\n &::after {\n border-width: 2px;\n }\n\n &::after {\n border-color: rgba(0, 0, 0, .1);\n }\n\n &::after {\n content: '';\n }\n}\n\n.flex {\n display: flex;\n}\n\n.w-full {\n width: 100%;\n}\n\n.flex-row {\n flex-direction: row;\n}\n\n.items-center {\n align-items: center;\n}\n\n.justify-between {\n justify-content: space-between;\n}\n\n.gap-x-12 {\n -moz-column-gap: 0.75rem;\n column-gap: 0.75rem;\n}\n\n.space-y-12> :not([hidden])~ :not([hidden]) {\n --tw-space-y-reverse: 0;\n margin-top: calc(0.75rem * calc(1 - var(--tw-space-y-reverse)));\n margin-bottom: calc(0.75rem * var(--tw-space-y-reverse));\n}\n\n.rounded-lg {\n border-radius: 16px;\n}\n\n.bg-dark {\n background-color: var(--grey-300);\n}\n\n.bg-error {\n background-color: var(--red-200);\n}\n\n.bg-success {\n background-color: var(--green-200);\n}\n\n.bg-warning {\n background-color: var(--yellow-200);\n}\n\n.p-16 {\n padding: 1rem;\n}\n\n.p-20 {\n padding: 1.25rem;\n}\n\n.px-12 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n\n.px-20 {\n padding-left: 1.25rem;\n padding-right: 1.25rem;\n}\n\n.py-12 {\n padding-top: 0.75rem;\n padding-bottom: 0.75rem;\n}\n\n.py-20 {\n padding-top: 1.25rem;\n padding-bottom: 1.25rem;\n}\n\n.py-8 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n\n.pr-12 {\n padding-right: 0.75rem;\n}\n\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n[class*=underline-] {\n text-decoration-line: underline;\n}\n\n.after\\:rounded-lg::after {\n border-radius: 16px;\n}\n\n.after\\:border-softest::after {\n border-color: rgba(0, 0, 0, .05);\n}";
|
|
88
|
+
const EdsAlertStyle0 = edsAlertCss;
|
|
89
|
+
|
|
90
|
+
const alertStyles = cva(['w-full bg-dark'], {
|
|
91
|
+
variants: {
|
|
92
|
+
intent: {
|
|
93
|
+
default: '',
|
|
94
|
+
warning: 'bg-warning',
|
|
95
|
+
error: 'bg-error',
|
|
96
|
+
success: 'bg-success'
|
|
97
|
+
},
|
|
98
|
+
brd: {
|
|
99
|
+
rounded: 'rounded-lg border-inside after:border-softest after:rounded-lg',
|
|
100
|
+
normal: ''
|
|
101
|
+
},
|
|
102
|
+
direction: {
|
|
103
|
+
vertical: 'space-y-12',
|
|
104
|
+
horizontal: 'flex flex-row items-center justify-between gap-x-12'
|
|
105
|
+
},
|
|
106
|
+
withBtn: {
|
|
107
|
+
false: '',
|
|
108
|
+
true: ''
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
compoundVariants: [
|
|
112
|
+
{
|
|
113
|
+
direction: 'horizontal',
|
|
114
|
+
withBtn: true,
|
|
115
|
+
class: 'px-20 pr-12 py-12'
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
direction: 'horizontal',
|
|
119
|
+
withBtn: false,
|
|
120
|
+
class: 'p-20'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
direction: 'vertical',
|
|
124
|
+
withBtn: true,
|
|
125
|
+
class: 'p-16'
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
direction: 'vertical',
|
|
129
|
+
withBtn: false,
|
|
130
|
+
class: 'px-12 py-20'
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
defaultVariants: {
|
|
134
|
+
intent: 'default',
|
|
135
|
+
brd: 'rounded',
|
|
136
|
+
direction: 'horizontal'
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
const EdsAlert = class {
|
|
140
|
+
constructor(hostRef) {
|
|
141
|
+
registerInstance(this, hostRef);
|
|
142
|
+
this.edsalert = createEvent(this, "edsalert", 7);
|
|
143
|
+
this.message = undefined;
|
|
144
|
+
this.pressableLabel = undefined;
|
|
145
|
+
this.pressableUrl = undefined;
|
|
146
|
+
this.direction = 'horizontal';
|
|
147
|
+
this.intent = 'default';
|
|
148
|
+
this.brd = 'rounded';
|
|
149
|
+
this.withBtn = false;
|
|
150
|
+
}
|
|
151
|
+
componentWillLoad() {
|
|
152
|
+
this.withBtn = Boolean(this.pressableLabel);
|
|
153
|
+
}
|
|
154
|
+
componentDidLoad() {
|
|
155
|
+
// Focus the alert container for immediate screen reader announcement
|
|
156
|
+
/*if (this.intent === 'error' || this.intent === 'warning') {
|
|
157
|
+
this.el.shadowRoot?.querySelector('[role="alert"]')?.setAttribute('tabindex', '-1');
|
|
158
|
+
(this.el.shadowRoot?.querySelector('[role="alert"]') as HTMLElement)?.focus();
|
|
159
|
+
}*/
|
|
160
|
+
var _a;
|
|
161
|
+
// Query for the 'eds-link' element inside the shadow root.
|
|
162
|
+
const lnk = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('eds-link');
|
|
163
|
+
if (lnk) {
|
|
164
|
+
this.emitContext(lnk);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
emitContext(linkElement) {
|
|
168
|
+
const event = new CustomEvent('parentContext', {
|
|
169
|
+
detail: {
|
|
170
|
+
componentName: this.el.tagName.toLowerCase(),
|
|
171
|
+
identifier: null
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
linkElement.dispatchEvent(event);
|
|
175
|
+
}
|
|
176
|
+
handleAction() {
|
|
177
|
+
// Emit the alertAction event for parent components to handle
|
|
178
|
+
this.edsalert.emit();
|
|
179
|
+
}
|
|
180
|
+
render() {
|
|
181
|
+
const ariaLabel = this.intent !== 'default' ? `${this.intent} alert` : 'alert';
|
|
182
|
+
return (h("div", { key: '2d22944e7ae86cf2523c194e20215a3d986083d9', class: alertStyles({
|
|
183
|
+
intent: this.intent,
|
|
184
|
+
brd: this.brd,
|
|
185
|
+
direction: this.direction,
|
|
186
|
+
withBtn: this.withBtn
|
|
187
|
+
}), role: "alert", "aria-label": ariaLabel, "aria-live": this.intent === 'error' ? 'assertive' : 'polite', "aria-labelledby": "alert-message", "aria-describedby": this.withBtn ? 'alert-action' : undefined }, h("p", { key: 'b6c22446b0d87fb01a3cb882fe205ef48ea60b05', id: "alert-message", class: "f-ui-01 py-8", innerHTML: this.message }), this.withBtn && (h("div", { key: '8414820eb7b65c83459cfb90adef3ea696e42444', id: "alert-action" }, this.pressableUrl ? (h("eds-link", { class: "eds-alert-link", label: this.pressableLabel, url: this.pressableUrl, intent: "secondary", external: true })) : (h("eds-button", { class: "eds-alert-button", label: this.pressableLabel, intent: "secondary", onClick: () => this.handleAction() }))))));
|
|
188
|
+
}
|
|
189
|
+
get el() { return getElement(this); }
|
|
190
|
+
};
|
|
191
|
+
EdsAlert.style = EdsAlertStyle0;
|
|
192
|
+
|
|
8
193
|
const edsAvatarCss = "::before,\n::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n border-color: currentColor;\n}\n\n::before,\n::after {\n --tw-content: '';\n}\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n.border-inside {\n position: relative;\n\n &::after {\n pointer-events: none;\n }\n\n &::after {\n position: absolute;\n }\n\n &::after {\n inset: 0rem;\n }\n\n &::after {\n z-index: 1;\n }\n\n &::after {\n border-radius: 8px;\n }\n\n &::after {\n border-width: 1px;\n }\n\n &::after {\n border-width: 2px;\n }\n\n &::after {\n border: 2px solid rgba(0, 0, 0, .1);\n }\n\n &::after {\n content: '';\n }\n}\n\n.border-inside-pill {\n &::after {\n border-radius: 100px;\n }\n\n &::after {\n content: '';\n }\n}\n\n.border-inside-inverse {\n &::after {\n border: 2px solid rgba(255, 255, 255, 0.3);\n }\n\n &::after {\n content: '';\n }\n}\n\n.aspect-1x1 {\n aspect-ratio: 1/1;\n}\n\n.flex {\n display: flex;\n}\n\n.inline-flex {\n display: inline-flex;\n}\n\n.items-center {\n align-items: center;\n}\n\n.justify-center {\n justify-content: center;\n}\n\n.overflow-hidden {\n overflow: hidden;\n}\n\n.px-4 {\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n}\n\n.rounded-pill {\n border-radius: 100px;\n}\n\n.rounded-sm {\n border-radius: 8px;\n}\n\n.rounded-xs {\n border-radius: 4px;\n}\n\n.rounded-full {\n border-radius: 9999px;\n}\n\n.bg-dark {\n background-color: var(--grey-300);\n}\n\n.bg-darker {\n background-color: var(--grey-400);\n}\n\n.bg-stronger {\n background-color: var(--grey-900);\n}\n\n.bg-strongest {\n background-color: var(--black);\n}\n\n.text-accent {\n color: var(--green-500);\n}\n\n.text-default {\n color: var(--black);\n}\n\n.\\!no-underline {\n text-decoration-line: none !important;\n}\n\n.f-ui-01 {\n font-family: var(--f-ui-01-fontFamily);\n font-weight: var(--f-ui-01-fontWeight);\n font-size: var(--f-ui-01-fontSize);\n line-height: var(--f-ui-01-lineHeight);\n letter-spacing: var(--f-ui-01-letterSpacing);\n}\n\n.w-32 {\n width: 2rem;\n}\n\n.w-44 {\n width: 2.75rem;\n}\n\n.w-\\[54px\\] {\n width: 54px;\n}\n\n.bg-gradient-01-top {\n background: linear-gradient(to bottom, #00E766, ease-in-out, #E6E6E6);\n}\n\n.bg-gradient-01-bottom {\n background: linear-gradient(to top, #00E766, ease-in-out, #E6E6E6);\n}\n\n.bg-gradient-02-top {\n background: linear-gradient(to bottom, #F3F30A, ease-in-out, #E6E6E6);\n}\n\n.bg-gradient-02-bottom {\n background: linear-gradient(to top, #F3F30A, ease-in-out, #E6E6E6);\n}\n\n.bg-gradient-03-top {\n background: linear-gradient(to bottom, #C461FF, ease-in-out, #E6E6E6);\n}\n\n.bg-gradient-03-bottom {\n background: linear-gradient(to top, #C461FF, ease-in-out, #E6E6E6);\n}\n\n.bg-gradient-04-top {\n background: linear-gradient(to bottom, #2B69FC, ease-in-out, #E6E6E6);\n}\n\n.bg-gradient-04-bottom {\n background: linear-gradient(to top, #2B69FC, ease-in-out, #E6E6E6);\n}";
|
|
9
194
|
const EdsAvatarStyle0 = edsAvatarCss;
|
|
10
195
|
|
|
@@ -62,7 +247,7 @@ const EdsAvatar = class {
|
|
|
62
247
|
* @returns {JSX.Element} The rendered avatar component.
|
|
63
248
|
*/
|
|
64
249
|
render() {
|
|
65
|
-
return (h("div", { key: '
|
|
250
|
+
return (h("div", { key: '34e86e50b1176efd8ae0cd9b30cd3823527d7eee', class: this.containerClasses }, this.picture ? (h("eds-img", { src: this.picture, width: 54, height: 54, sizes: "120px", alt: `${this.firstName} ${this.lastName}`, lazyload: true, withBg: true })) : (h("abbr", { title: this.computedInitials || `${this.firstName} ${this.lastName}`, class: "!no-underline f-ui-01" }, this.computedInitials))));
|
|
66
251
|
}
|
|
67
252
|
};
|
|
68
253
|
EdsAvatar.style = EdsAvatarStyle0;
|
|
@@ -76,12 +261,149 @@ const EdsBlockBreak = class {
|
|
|
76
261
|
this.inverse = false;
|
|
77
262
|
}
|
|
78
263
|
render() {
|
|
79
|
-
return h("hr", { key: '
|
|
264
|
+
return h("hr", { key: '688e11c730af1193f28db196cd144c6dd2efc3c6', class: `${this.inverse ? 'border-default' : 'border-softer'} my-16 inline-block w-full border-t-2` });
|
|
80
265
|
}
|
|
81
266
|
};
|
|
82
267
|
EdsBlockBreak.style = EdsBlockBreakStyle0;
|
|
83
268
|
|
|
84
|
-
const edsButtonCss = "*,\n::before,\n::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n border-color: currentColor;\n}\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\n 1. Change the font styles in all browsers.\n 2. Remove the margin in Firefox and Safari.\n 3. Remove default padding in all browsers.\n */\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n}\n\n/*\n Remove the inheritance of text transform in Edge and Firefox.\n */\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n 1. Correct the inability to style clickable types in iOS and Safari.\n 2. Remove default button styles.\n */\nbutton,\ninput:where([type='button']),\ninput:where([type='reset']),\ninput:where([type='submit']) {\n -webkit-appearance: button;\n /* 1 */\n background-color: transparent;\n /* 2 */\n background-image: none;\n /* 2 */\n}\n\np {\n margin: 0;\n}\n\n/*\n Set the default cursor for buttons.\n */\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\n Make sure disabled buttons don't get the pointer cursor.\n */\n:disabled {\n cursor: default;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n.f-body-01 {\n font-family: var(--f-body-01-fontFamily);\n font-weight: var(--f-body-01-fontWeight);\n font-size: var(--f-body-01-fontSize);\n line-height: var(--f-body-01-lineHeight);\n letter-spacing: var(--f-body-01-letterSpacing);\n}\n\n.f-body-02 {\n font-family: var(--f-body-02-fontFamily);\n font-weight: var(--f-body-02-fontWeight);\n font-size: var(--f-body-02-fontSize);\n line-height: var(--f-body-02-lineHeight);\n letter-spacing: var(--f-body-02-letterSpacing);\n}\n\n.f-ui-01 {\n font-family: var(--f-ui-01-fontFamily);\n font-weight: var(--f-ui-01-fontWeight);\n font-size: var(--f-ui-01-fontSize);\n line-height: var(--f-ui-01-lineHeight);\n letter-spacing: var(--f-ui-01-letterSpacing);\n}\n\n.f-ui-02 {\n font-family: var(--f-ui-02-fontFamily);\n font-weight: var(--f-ui-02-fontWeight);\n font-size: var(--f-ui-02-fontSize);\n line-height: var(--f-ui-02-lineHeight);\n letter-spacing: var(--f-ui-02-letterSpacing);\n}\n\n.border-inside {\n position: relative;\n\n &::after {\n pointer-events: none;\n }\n\n &::after {\n position: absolute;\n }\n\n &::after {\n inset: 0rem;\n }\n\n &::after {\n z-index: 1;\n }\n\n &::after {\n border-radius: 8px;\n }\n\n &::after {\n border-width: 1px;\n }\n\n &::after {\n border-width: 2px;\n }\n\n &::after {\n border-color: rgba(0, 0, 0, .1);\n }\n\n &::after {\n content: '';\n }\n}\n\n.border-inside-inverse {\n &::after {\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n &::after {\n content: '';\n }\n}\n\n.border-inside-pill {\n &::after {\n border-radius: 100px;\n }\n\n &::after {\n content: '';\n }\n}\n\n.loader {\n box-sizing: border-box;\n display: inline-block;\n height: 1rem;\n width: 1rem;\n}\n\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.loader {\n animation: spin 1s linear infinite;\n border-radius: 9999px;\n border: 3px solid rgba(0, 0, 0, .3);\n border-bottom-color: #000;\n}\n\n/** region TRANSITIONS */\n.effect-color {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 300ms;\n transition-timing-function: cubic-bezier(0, 0, 0.2, 1);\n}\n\n.effect-focus {\n outline-width: 3px;\n outline-offset: 2px;\n outline-color: var(--green-500);\n}\n\n.effect-focus:focus-visible {\n outline-style: solid;\n}\n\n.effect-focus-within {\n outline-width: 3px;\n outline-offset: 2px;\n outline-color: var(--green-500);\n}\n\n.effect-focus-within:focus-within {\n outline-style: solid;\n}\n\n.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n}\n\n.pointer-events-none {\n pointer-events: none;\n}\n\n.static {\n position: static;\n}\n\n.fixed {\n position: fixed;\n}\n\n.absolute {\n position: absolute;\n}\n\n.relative {\n position: relative;\n}\n\n.sticky {\n position: sticky;\n}\n\n.inset-0 {\n inset: 0rem;\n}\n\n.inset-x-16 {\n left: 1rem;\n right: 1rem;\n}\n\n.-top-8 {\n top: -0.5rem;\n}\n\n.left-0 {\n left: 0rem;\n}\n\n.left-1\\/2 {\n left: 50%;\n}\n\n.left-4 {\n left: 0.25rem;\n}\n\n.left-\\[4px\\] {\n left: 4px;\n}\n\n.right-0 {\n right: 0rem;\n}\n\n.right-4 {\n right: 0.25rem;\n}\n\n.right-8 {\n right: 0.5rem;\n}\n\n.right-\\[6px\\] {\n right: 6px;\n}\n\n.top-0 {\n top: 0rem;\n}\n\n.top-1\\/2 {\n top: 50%;\n}\n\n.m-0 {\n margin: 0rem;\n}\n\n.mx-auto {\n margin-left: auto;\n margin-right: auto;\n}\n\n.-ml-16 {\n margin-left: -1rem;\n}\n\n.-mr-16 {\n margin-right: -1rem;\n}\n\n.ml-0 {\n margin-left: 0rem;\n}\n\n.ml-4 {\n margin-left: 0.25rem;\n}\n\n.ml-64 {\n margin-left: 4rem;\n}\n\n.ml-8 {\n margin-left: 0.5rem;\n}\n\n.ml-auto {\n margin-left: auto;\n}\n\n.mr-4 {\n margin-right: 0.25rem;\n}\n\n.mr-8 {\n margin-right: 0.5rem;\n}\n\n.mr-auto {\n margin-right: auto;\n}\n\n.block {\n display: block;\n}\n\n.inline-block {\n display: inline-block;\n}\n\n.inline {\n display: inline;\n}\n\n.flex {\n display: flex;\n}\n\n.inline-flex {\n display: inline-flex;\n}\n\n.hidden {\n display: none;\n}\n\n.h-20 {\n height: 1.25rem;\n}\n\n.h-24 {\n height: 1.5rem;\n}\n\n.h-36 {\n height: 2.25rem;\n}\n\n.h-44 {\n height: 2.75rem;\n}\n\n.h-auto {\n height: auto;\n}\n\n.h-full {\n height: 100%;\n}\n\n.\\!min-h-20 {\n min-height: 1.25rem !important;\n}\n\n.min-h-screen {\n min-height: 100vh;\n}\n\n.w-20 {\n width: 1.25rem;\n}\n\n.w-full {\n width: 100%;\n}\n\n.flex-none {\n flex: none;\n}\n\n.grow {\n flex-grow: 1;\n}\n\n.cursor-pointer {\n cursor: pointer;\n}\n\n.resize {\n resize: both;\n}\n\n.flex-row {\n flex-direction: row;\n}\n\n.flex-row-reverse {\n flex-direction: row-reverse;\n}\n\n.flex-col {\n flex-direction: column;\n}\n\n.flex-wrap {\n flex-wrap: wrap;\n}\n\n.items-center {\n align-items: center;\n}\n\n.justify-center {\n justify-content: center;\n}\n\n.justify-between {\n justify-content: space-between;\n}\n\n.space-x-2> :not([hidden])~ :not([hidden]) {\n --tw-space-x-reverse: 0;\n margin-right: calc(0.125rem * var(--tw-space-x-reverse));\n margin-left: calc(0.125rem * calc(1 - var(--tw-space-x-reverse)));\n}\n\n.overflow-hidden {\n overflow: hidden;\n}\n\n.overflow-x-auto {\n overflow-x: auto;\n}\n\n.overflow-x-hidden {\n overflow-x: hidden;\n}\n\n.overflow-y-scroll {\n overflow-y: scroll;\n}\n\n.whitespace-nowrap {\n white-space: nowrap;\n}\n\n.break-words {\n overflow-wrap: break-word;\n}\n\n.rounded {\n border-radius: 0.25rem;\n}\n\n.rounded-full {\n border-radius: 9999px;\n}\n\n.rounded-lg {\n border-radius: 16px;\n}\n\n.rounded-md {\n border-radius: 12px;\n}\n\n.rounded-pill {\n border-radius: 100px;\n}\n\n.rounded-sm {\n border-radius: 8px;\n}\n\n.rounded-xxs {\n border-radius: 2px;\n}\n\n.border {\n border-width: 1px;\n}\n\n.border-\\[\\#0034CB\\] {\n --tw-border-opacity: 1;\n border-color: rgb(0 52 203 / var(--tw-border-opacity));\n}\n\n.border-\\[\\#d2d2d2\\] {\n --tw-border-opacity: 1;\n border-color: rgb(210 210 210 / var(--tw-border-opacity));\n}\n\n.border-softest {\n border-color: rgba(0, 0, 0, .05);\n}\n\n.border-b-softer {\n border-bottom-color: rgba(0, 0, 0, .1);\n}\n\n.\\!bg-accent-dark {\n background-color: var(--green-600) !important;\n}\n\n.\\!bg-darker {\n background-color: var(--grey-400) !important;\n}\n\n.\\!bg-strong-dark {\n background-color: var(--grey-800) !important;\n}\n\n.bg-accent {\n background-color: var(--green-500);\n}\n\n.bg-accent-dark {\n background-color: var(--green-600);\n}\n\n.bg-dark {\n background-color: var(--grey-300);\n}\n\n.bg-darker {\n background-color: var(--grey-400);\n}\n\n.bg-overlay {\n background-color: rgba(0, 0, 0, 0.25);\n}\n\n.bg-strong {\n background-color: var(--grey-700);\n}\n\n.bg-strong-dark {\n background-color: var(--grey-800);\n}\n\n.bg-stronger {\n background-color: var(--grey-900);\n}\n\n.bg-strongest {\n background-color: var(--black);\n}\n\n.p-12 {\n padding: 0.75rem;\n}\n\n.p-6 {\n padding: 0.375rem;\n}\n\n.p-8 {\n padding: 0.5rem;\n}\n\n.\\!px-0 {\n padding-left: 0rem !important;\n padding-right: 0rem !important;\n}\n\n.px-12 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n\n.px-16 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n\n.py-8 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n\n.pl-4 {\n padding-left: 0.25rem;\n}\n\n.pl-8 {\n padding-left: 0.5rem;\n}\n\n.pr-4 {\n padding-right: 0.25rem;\n}\n\n.pr-8 {\n padding-right: 0.5rem;\n}\n\n.\\!text-current {\n color: currentColor !important;\n}\n\n.text-accent {\n color: var(--green-500);\n}\n\n.text-current {\n color: currentColor;\n}\n\n.text-default {\n color: var(--black);\n}\n\n.text-inverse {\n color: var(--white);\n}\n\n.text-lightest {\n color: var(--grey-500);\n}\n\n.opacity-0 {\n opacity: 0;\n}\n\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.shadow-accent {\n --tw-shadow: 0px 0px 12px rgba(0, 201, 89, 0.6);\n --tw-shadow-colored: 0px 0px 12px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.underline-offset-4 {\n text-underline-offset: 0.2em;\n}\n\n.\\@container {\n container-type: inline-size;\n}\n\n.after\\:effect-opacity::after {\n transition-property: opacity;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 300ms;\n transition-timing-function: cubic-bezier(0, 0, 0.2, 1);\n}\n\n.even\\:bg-inverse-softer:nth-child(even) {\n background-color: rgba(255, 255, 255, .15);\n}\n\n.invalid\\:text-lightest:invalid {\n color: var(--grey-500);\n}\n\n.focus-within\\:bg-transparent:focus-within {\n background-color: var(--transparent);\n}\n\n.hover\\:bg-accent-dark:hover {\n background-color: var(--green-600);\n}\n\n.hover\\:bg-dark:hover {\n background-color: var(--grey-300);\n}\n\n.hover\\:bg-darker:hover {\n background-color: var(--grey-400);\n}\n\n.hover\\:bg-default:hover {\n background-color: var(--grey-200);\n}\n\n.hover\\:bg-inverse:hover {\n background-color: var(--white);\n}\n\n.hover\\:bg-strong-dark:hover {\n background-color: var(--grey-800);\n}\n\n.hover\\:bg-transparent:hover {\n background-color: var(--transparent);\n}\n\n.hover\\:text-default:hover {\n color: var(--black);\n}\n\n.hover\\:text-lighter:hover {\n color: var(--grey-600);\n}\n\n.hover\\:\\!underline:hover {\n text-decoration-line: underline !important;\n}\n\n.hover\\:no-underline:hover {\n text-decoration-line: none;\n}\n\n.hover\\:shadow-hover:hover {\n --tw-shadow: 0px 0px 16px rgba(0, 0, 0, 0.2);\n --tw-shadow-colored: 0px 0px 16px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.focus\\:shadow-none:focus {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.focus\\:outline-none:focus {\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n\n.disabled\\:cursor-not-allowed:disabled {\n cursor: not-allowed;\n}\n\n.disabled\\:bg-dark:disabled {\n background-color: var(--grey-300);\n}\n\n.disabled\\:text-lightest:disabled {\n color: var(--grey-500);\n}\n\n.aria-disabled\\:cursor-not-allowed[aria-disabled=\"true\"] {\n cursor: not-allowed;\n}\n\n.aria-disabled\\:\\!border-transparent[aria-disabled=\"true\"] {\n border-color: var(--transparent) !important;\n}\n\n.aria-disabled\\:bg-dark[aria-disabled=\"true\"] {\n background-color: var(--grey-300);\n}\n\n.aria-disabled\\:bg-transparent[aria-disabled=\"true\"] {\n background-color: var(--transparent);\n}\n\n.aria-disabled\\:text-light[aria-disabled=\"true\"] {\n color: var(--grey-700);\n}\n\n.aria-disabled\\:text-lightest[aria-disabled=\"true\"] {\n color: var(--grey-500);\n}\n\n.aria-disabled\\:line-through[aria-disabled=\"true\"] {\n text-decoration-line: line-through;\n}\n\n.aria-disabled\\:shadow-none[aria-disabled=\"true\"] {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.aria-current-page\\:bg-darker[aria-current=\"page\"] {\n background-color: var(--grey-400);\n}\n\n.after\\:absolute::after {\n position: absolute;\n}\n\n.after\\:inset-0::after {\n inset: 0rem;\n}\n\n.after\\:inset-x-0::after {\n left: 0rem;\n right: 0rem;\n}\n\n.after\\:bottom-0::after {\n bottom: 0rem;\n}\n\n.after\\:left-16::after {\n left: 1rem;\n}\n\n.after\\:right-16::after {\n right: 1rem;\n}\n\n.after\\:z-10::after {\n z-index: 10;\n}\n\n.after\\:rounded-lg::after {\n border-radius: 16px;\n}\n\n.after\\:rounded-t-lg::after {\n border-top-left-radius: 16px;\n border-top-right-radius: 16px;\n}\n\n.after\\:border-3::after {\n border-width: 3px;\n}\n\n.after\\:border-b-2::after {\n border-bottom-width: 2px;\n}\n\n.after\\:\\!border-transparent::after {\n border-color: var(--transparent) !important;\n}\n\n.after\\:border-accent::after {\n border-color: var(--green-500);\n}\n\n.after\\:border-softest::after {\n border-color: rgba(0, 0, 0, .05);\n}\n\n.after\\:opacity-0::after {\n opacity: 0;\n}\n\n.after\\:content-\\[\\'\\'\\]::after {\n --tw-content: '';\n content: var(--tw-content);\n}\n\n.hover\\:after\\:\\!border-transparent:hover::after {\n border-color: var(--transparent) !important;\n}\n\n.hover\\:after\\:opacity-100:hover::after {\n opacity: 1;\n}\n\n.focus-visible\\:after\\:opacity-100:focus-visible::after {\n opacity: 1;\n}\n\n.aria-disabled\\:after\\:\\!border-transparent[aria-disabled=\"true\"]::after {\n border-color: var(--transparent) !important;\n}\n\n.hover\\:before\\:opacity-100:hover::before {\n opacity: 1;\n}";
|
|
269
|
+
const edsBreadcrumbCss = "blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}.hidden{display:none}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.inline-flex{display:inline-flex}.items-center{align-items:center}.justify-center{justify-content:center}.space-x-2>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(0.125rem * var(--tw-space-x-reverse));margin-left:calc(0.125rem * calc(1 - var(--tw-space-x-reverse)))}.px-2{padding-left:0.125rem;padding-right:0.125rem}.w-20{width:1.25rem}.w-28{width:1.75rem}.w-32{width:2rem}.w-44{width:2.75rem}.h-20{height:1.25rem}.h-24{height:1.5rem}.h-28{height:1.75rem}.h-32{height:2rem}@media (min-width: 750px){.md\\:block{display:block}}";
|
|
270
|
+
const EdsBreadcrumbStyle0 = edsBreadcrumbCss;
|
|
271
|
+
|
|
272
|
+
const EdsBreadcrumb = class {
|
|
273
|
+
constructor(hostRef) {
|
|
274
|
+
registerInstance(this, hostRef);
|
|
275
|
+
/**
|
|
276
|
+
* Updates the maximum number of visible items and tracks if the screen is small.
|
|
277
|
+
*/
|
|
278
|
+
this.updateScreenSize = () => {
|
|
279
|
+
const width = window.innerWidth;
|
|
280
|
+
if (width < 769) {
|
|
281
|
+
this.maxVisibleItems = 3;
|
|
282
|
+
}
|
|
283
|
+
else if (width <= 1024) {
|
|
284
|
+
this.maxVisibleItems = 3;
|
|
285
|
+
}
|
|
286
|
+
else if (width <= 1280) {
|
|
287
|
+
this.maxVisibleItems = 3;
|
|
288
|
+
}
|
|
289
|
+
else if (width <= 2200) {
|
|
290
|
+
this.maxVisibleItems = 4;
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
this.maxVisibleItems = 6;
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
this.items = [];
|
|
297
|
+
this.intent = 'ghost';
|
|
298
|
+
this.parsedItems = [];
|
|
299
|
+
this.isSmallScreen = false;
|
|
300
|
+
this.maxVisibleItems = 6;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Watches for changes to the `items` prop and parses it.
|
|
304
|
+
*/
|
|
305
|
+
parseItems(newValue) {
|
|
306
|
+
this.parsedItems = parseData(newValue);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Lifecycle method that runs when the component is about to be loaded.
|
|
310
|
+
* It parses the initial `items` prop value.
|
|
311
|
+
*/
|
|
312
|
+
componentWillLoad() {
|
|
313
|
+
this.parseItems(this.items);
|
|
314
|
+
this.updateScreenSize();
|
|
315
|
+
window.addEventListener('resize', this.updateScreenSize);
|
|
316
|
+
}
|
|
317
|
+
disconnectedCallback() {
|
|
318
|
+
window.removeEventListener('resize', this.updateScreenSize);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Lifecycle method that runs when the component has fully loaded.
|
|
322
|
+
* It emits a custom event for each `eds-link` element contained within the breadcrumb.
|
|
323
|
+
*/
|
|
324
|
+
componentDidLoad() {
|
|
325
|
+
var _a;
|
|
326
|
+
const links = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('eds-link');
|
|
327
|
+
links === null || links === void 0 ? void 0 : links.forEach((link) => {
|
|
328
|
+
this.emitContext(link);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Emits a custom event called `parentContext` for a given link element.
|
|
333
|
+
* This event provides context information about the breadcrumb component.
|
|
334
|
+
*
|
|
335
|
+
* @param linkElement - The link element to which the event will be dispatched.
|
|
336
|
+
*/
|
|
337
|
+
emitContext(linkElement) {
|
|
338
|
+
const event = new CustomEvent('parentContext', {
|
|
339
|
+
detail: {
|
|
340
|
+
componentName: this.el.tagName.toLowerCase(),
|
|
341
|
+
identifier: null
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
linkElement.dispatchEvent(event);
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Returns breadcrumb items with potential truncation if there are too many.
|
|
348
|
+
* It inserts an ellipsis item where necessary.
|
|
349
|
+
*/
|
|
350
|
+
getTruncatedItems() {
|
|
351
|
+
const totalItems = this.parsedItems.length;
|
|
352
|
+
const ellipsis = { label: '...', url: '', isHidden: true };
|
|
353
|
+
if (totalItems > this.maxVisibleItems) {
|
|
354
|
+
const firstItem = this.parsedItems[0];
|
|
355
|
+
const lastItems = this.parsedItems.slice(-2);
|
|
356
|
+
if (this.maxVisibleItems === 3) {
|
|
357
|
+
return [firstItem, ellipsis, ...lastItems];
|
|
358
|
+
}
|
|
359
|
+
else if (this.maxVisibleItems === 4) {
|
|
360
|
+
const middleItem = this.parsedItems[Math.floor(totalItems / 2)];
|
|
361
|
+
return [firstItem, middleItem, ellipsis, ...lastItems];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return this.parsedItems;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Helper to determine the display label and full label.
|
|
368
|
+
* If the label is longer than 15 characters and the item is not the current (last) item,
|
|
369
|
+
* we display a truncated version but use the full label for aria attributes.
|
|
370
|
+
*/
|
|
371
|
+
getLabels(item, isCurrent) {
|
|
372
|
+
if (!isCurrent && item.label.length > 15) {
|
|
373
|
+
return { displayLabel: `${item.label.slice(0, 15)}...`, fullLabel: item.label };
|
|
374
|
+
}
|
|
375
|
+
return { displayLabel: item.label, fullLabel: item.label };
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Render method for the breadcrumb component.
|
|
379
|
+
* It creates a navigation element with an ordered list of breadcrumb links.
|
|
380
|
+
* The last link is marked as the current page.
|
|
381
|
+
*/
|
|
382
|
+
render() {
|
|
383
|
+
const itemsToRender = this.getTruncatedItems();
|
|
384
|
+
return (h("nav", { key: '0625a234ec9f5095abbeaafa11e56bceb0432764', "aria-label": "Breadcrumb" }, h("ol", { key: '3898a4b048eca6c606a6948b26ec25a608cb908e', class: "flex items-center space-x-2" }, itemsToRender.map((item, index) => {
|
|
385
|
+
const isLast = index === itemsToRender.length - 1;
|
|
386
|
+
return (h("li", { class: "flex items-center" }, !item.isHidden ? ((() => {
|
|
387
|
+
const { fullLabel } = this.getLabels(item, isLast);
|
|
388
|
+
const linkIntent = isLast
|
|
389
|
+
? this.intent === 'strong'
|
|
390
|
+
? 'weak'
|
|
391
|
+
: this.intent === 'weak'
|
|
392
|
+
? 'strong'
|
|
393
|
+
: this.intent
|
|
394
|
+
: this.intent;
|
|
395
|
+
return (h("eds-link", Object.assign({ label: fullLabel, url: item.url, intent: linkIntent, disabled: isLast, current: isLast, "aria-label": fullLabel, size: "small", "icon-small": "false" }, (isLast ? { 'aria-current': 'page' } : {}))));
|
|
396
|
+
})()) : (h("eds-link", { label: "...", url: "#", intent: "strong", current: false, "aria-label": "...", size: "small", "icon-small": "false", icon: "chevron-right" })), !isLast && !item.isHidden && (h("eds-icon-wrapper", { icon: "chevron-right", class: "w-20 h-20" }))));
|
|
397
|
+
}))));
|
|
398
|
+
}
|
|
399
|
+
get el() { return getElement(this); }
|
|
400
|
+
static get watchers() { return {
|
|
401
|
+
"items": ["parseItems"]
|
|
402
|
+
}; }
|
|
403
|
+
};
|
|
404
|
+
EdsBreadcrumb.style = EdsBreadcrumbStyle0;
|
|
405
|
+
|
|
406
|
+
const edsButtonCss = "*,\n::before,\n::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n border-color: currentColor;\n}\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\n 1. Change the font styles in all browsers.\n 2. Remove the margin in Firefox and Safari.\n 3. Remove default padding in all browsers.\n */\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n}\n\n/*\n Remove the inheritance of text transform in Edge and Firefox.\n */\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n 1. Correct the inability to style clickable types in iOS and Safari.\n 2. Remove default button styles.\n */\nbutton,\ninput:where([type='button']),\ninput:where([type='reset']),\ninput:where([type='submit']) {\n -webkit-appearance: button;\n /* 1 */\n background-color: transparent;\n /* 2 */\n background-image: none;\n /* 2 */\n}\n\np {\n margin: 0;\n}\n\n/*\n Set the default cursor for buttons.\n */\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\n Make sure disabled buttons don't get the pointer cursor.\n */\n:disabled {\n cursor: default;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n.f-body-01 {\n font-family: var(--f-body-01-fontFamily);\n font-weight: var(--f-body-01-fontWeight);\n font-size: var(--f-body-01-fontSize);\n line-height: var(--f-body-01-lineHeight);\n letter-spacing: var(--f-body-01-letterSpacing);\n}\n\n.f-body-02 {\n font-family: var(--f-body-02-fontFamily);\n font-weight: var(--f-body-02-fontWeight);\n font-size: var(--f-body-02-fontSize);\n line-height: var(--f-body-02-lineHeight);\n letter-spacing: var(--f-body-02-letterSpacing);\n}\n\n.f-ui-01 {\n font-family: var(--f-ui-01-fontFamily);\n font-weight: var(--f-ui-01-fontWeight);\n font-size: var(--f-ui-01-fontSize);\n line-height: var(--f-ui-01-lineHeight);\n letter-spacing: var(--f-ui-01-letterSpacing);\n}\n\n.f-ui-02 {\n font-family: var(--f-ui-02-fontFamily);\n font-weight: var(--f-ui-02-fontWeight);\n font-size: var(--f-ui-02-fontSize);\n line-height: var(--f-ui-02-lineHeight);\n letter-spacing: var(--f-ui-02-letterSpacing);\n}\n\n.border-inside {\n position: relative;\n\n &::after {\n pointer-events: none;\n }\n\n &::after {\n position: absolute;\n }\n\n &::after {\n inset: 0rem;\n }\n\n &::after {\n z-index: 1;\n }\n\n &::after {\n border-radius: 8px;\n }\n\n &::after {\n border-width: 1px;\n }\n\n &::after {\n border-width: 2px;\n }\n\n &::after {\n border-color: rgba(0, 0, 0, .1);\n }\n\n &::after {\n content: '';\n }\n}\n\n.border-inside-inverse {\n &::after {\n border-color: rgba(255, 255, 255, 0.3);\n }\n\n &::after {\n content: '';\n }\n}\n\n.border-inside-pill {\n &::after {\n border-radius: 100px;\n }\n\n &::after {\n content: '';\n }\n}\n\n.loader {\n box-sizing: border-box;\n display: inline-block;\n height: 1rem;\n width: 1rem;\n}\n\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.loader {\n animation: spin 1s linear infinite;\n border-radius: 9999px;\n border: 3px solid rgba(0, 0, 0, .3);\n border-bottom-color: #000;\n}\n\n/** region TRANSITIONS */\n.effect-color {\n transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 300ms;\n transition-timing-function: cubic-bezier(0, 0, 0.2, 1);\n}\n\n.effect-focus {\n outline-width: 3px;\n outline-offset: 2px;\n outline-color: var(--green-500);\n}\n\n.effect-focus:focus-visible {\n outline-style: solid;\n}\n\n.effect-focus-within {\n outline-width: 3px;\n outline-offset: 2px;\n outline-color: var(--green-500);\n}\n\n.effect-focus-within:focus-within {\n outline-style: solid;\n}\n\n.sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border-width: 0;\n}\n\n.pointer-events-none {\n pointer-events: none;\n}\n\n.static {\n position: static;\n}\n\n.fixed {\n position: fixed;\n}\n\n.absolute {\n position: absolute;\n}\n\n.relative {\n position: relative;\n}\n\n.sticky {\n position: sticky;\n}\n\n.inset-0 {\n inset: 0rem;\n}\n\n.inset-x-16 {\n left: 1rem;\n right: 1rem;\n}\n\n.-top-8 {\n top: -0.5rem;\n}\n\n.left-0 {\n left: 0rem;\n}\n\n.left-1\\/2 {\n left: 50%;\n}\n\n.left-4 {\n left: 0.25rem;\n}\n\n.left-\\[4px\\] {\n left: 4px;\n}\n\n.right-0 {\n right: 0rem;\n}\n\n.right-4 {\n right: 0.25rem;\n}\n\n.right-8 {\n right: 0.5rem;\n}\n\n.right-\\[6px\\] {\n right: 6px;\n}\n\n.top-0 {\n top: 0rem;\n}\n\n.top-1\\/2 {\n top: 50%;\n}\n\n.m-0 {\n margin: 0rem;\n}\n\n.mx-auto {\n margin-left: auto;\n margin-right: auto;\n}\n\n.-ml-16 {\n margin-left: -1rem;\n}\n\n.-mr-16 {\n margin-right: -1rem;\n}\n\n.ml-0 {\n margin-left: 0rem;\n}\n\n.ml-4 {\n margin-left: 0.25rem;\n}\n\n.ml-64 {\n margin-left: 4rem;\n}\n\n.ml-8 {\n margin-left: 0.5rem;\n}\n\n.ml-auto {\n margin-left: auto;\n}\n\n.mr-4 {\n margin-right: 0.25rem;\n}\n\n.mr-8 {\n margin-right: 0.5rem;\n}\n\n.mr-auto {\n margin-right: auto;\n}\n\n.block {\n display: block;\n}\n\n.\\!block {\n display: block !important;\n}\n\n.inline-block {\n display: inline-block;\n}\n\n.inline {\n display: inline;\n}\n\n.flex {\n display: flex;\n}\n\n.inline-flex {\n display: inline-flex;\n}\n\n.hidden {\n display: none;\n}\n\n.h-20 {\n height: 1.25rem;\n}\n\n.h-24 {\n height: 1.5rem;\n}\n\n.h-36 {\n height: 2.25rem;\n}\n\n.h-44 {\n height: 2.75rem;\n}\n\n.h-auto {\n height: auto;\n}\n\n.h-full {\n height: 100%;\n}\n\n.\\!min-h-20 {\n min-height: 1.25rem !important;\n}\n\n.min-h-screen {\n min-height: 100vh;\n}\n\n.w-20 {\n width: 1.25rem;\n}\n\n.w-full {\n width: 100%;\n}\n\n.flex-none {\n flex: none;\n}\n\n.grow {\n flex-grow: 1;\n}\n\n.cursor-pointer {\n cursor: pointer;\n}\n\n.resize {\n resize: both;\n}\n\n.flex-row {\n flex-direction: row;\n}\n\n.flex-row-reverse {\n flex-direction: row-reverse;\n}\n\n.flex-col {\n flex-direction: column;\n}\n\n.flex-wrap {\n flex-wrap: wrap;\n}\n\n.items-center {\n align-items: center;\n}\n\n.justify-center {\n justify-content: center;\n}\n\n.justify-between {\n justify-content: space-between;\n}\n\n.space-x-2> :not([hidden])~ :not([hidden]) {\n --tw-space-x-reverse: 0;\n margin-right: calc(0.125rem * var(--tw-space-x-reverse));\n margin-left: calc(0.125rem * calc(1 - var(--tw-space-x-reverse)));\n}\n\n.overflow-hidden {\n overflow: hidden;\n}\n\n.overflow-x-auto {\n overflow-x: auto;\n}\n\n.overflow-x-hidden {\n overflow-x: hidden;\n}\n\n.overflow-y-scroll {\n overflow-y: scroll;\n}\n\n.whitespace-nowrap {\n white-space: nowrap;\n}\n\n.break-words {\n overflow-wrap: break-word;\n}\n\n.rounded {\n border-radius: 0.25rem;\n}\n\n.rounded-full {\n border-radius: 9999px;\n}\n\n.rounded-lg {\n border-radius: 16px;\n}\n\n.rounded-md {\n border-radius: 12px;\n}\n\n.rounded-pill {\n border-radius: 100px;\n}\n\n.rounded-sm {\n border-radius: 8px;\n}\n\n.rounded-xxs {\n border-radius: 2px;\n}\n\n.border {\n border-width: 1px;\n}\n\n.border-\\[\\#0034CB\\] {\n --tw-border-opacity: 1;\n border-color: rgb(0 52 203 / var(--tw-border-opacity));\n}\n\n.border-\\[\\#d2d2d2\\] {\n --tw-border-opacity: 1;\n border-color: rgb(210 210 210 / var(--tw-border-opacity));\n}\n\n.border-softest {\n border-color: rgba(0, 0, 0, .05);\n}\n\n.border-b-softer {\n border-bottom-color: rgba(0, 0, 0, .1);\n}\n\n.\\!bg-accent-dark {\n background-color: var(--green-600) !important;\n}\n\n.\\!bg-darker {\n background-color: var(--grey-400) !important;\n}\n\n.\\!bg-strong-dark {\n background-color: var(--grey-800) !important;\n}\n\n.bg-accent {\n background-color: var(--green-500);\n}\n\n.bg-accent-dark {\n background-color: var(--green-600);\n}\n\n.bg-dark {\n background-color: var(--grey-300);\n}\n\n.bg-darker {\n background-color: var(--grey-400);\n}\n\n.bg-overlay {\n background-color: rgba(0, 0, 0, 0.25);\n}\n\n.bg-strong {\n background-color: var(--grey-700);\n}\n\n.bg-strong-dark {\n background-color: var(--grey-800);\n}\n\n.bg-stronger {\n background-color: var(--grey-900);\n}\n\n.bg-strongest {\n background-color: var(--black);\n}\n\n.p-12 {\n padding: 0.75rem;\n}\n\n.p-6 {\n padding: 0.375rem;\n}\n\n.p-8 {\n padding: 0.5rem;\n}\n\n.\\!px-0 {\n padding-left: 0rem !important;\n padding-right: 0rem !important;\n}\n\n.px-12 {\n padding-left: 0.75rem;\n padding-right: 0.75rem;\n}\n\n.px-16 {\n padding-left: 1rem;\n padding-right: 1rem;\n}\n\n.py-8 {\n padding-top: 0.5rem;\n padding-bottom: 0.5rem;\n}\n\n.pl-4 {\n padding-left: 0.25rem;\n}\n\n.pl-8 {\n padding-left: 0.5rem;\n}\n\n.pr-4 {\n padding-right: 0.25rem;\n}\n\n.pr-8 {\n padding-right: 0.5rem;\n}\n\n.\\!text-current {\n color: currentColor !important;\n}\n\n.text-accent {\n color: var(--green-500);\n}\n\n.text-current {\n color: currentColor;\n}\n\n.text-default {\n color: var(--black);\n}\n\n.text-inverse {\n color: var(--white);\n}\n\n.text-lightest {\n color: var(--grey-500);\n}\n\n.opacity-0 {\n opacity: 0;\n}\n\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.shadow-accent {\n --tw-shadow: 0px 0px 12px rgba(0, 201, 89, 0.6);\n --tw-shadow-colored: 0px 0px 12px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.underline-offset-4 {\n text-underline-offset: 0.2em;\n}\n\n.\\@container {\n container-type: inline-size;\n}\n\n.after\\:effect-opacity::after {\n transition-property: opacity;\n transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n transition-duration: 300ms;\n transition-timing-function: cubic-bezier(0, 0, 0.2, 1);\n}\n\n.even\\:bg-inverse-softer:nth-child(even) {\n background-color: rgba(255, 255, 255, .15);\n}\n\n.invalid\\:text-lightest:invalid {\n color: var(--grey-500);\n}\n\n.focus-within\\:bg-transparent:focus-within {\n background-color: var(--transparent);\n}\n\n.hover\\:bg-accent-dark:hover {\n background-color: var(--green-600);\n}\n\n.hover\\:bg-dark:hover {\n background-color: var(--grey-300);\n}\n\n.hover\\:bg-darker:hover {\n background-color: var(--grey-400);\n}\n\n.hover\\:bg-default:hover {\n background-color: var(--grey-200);\n}\n\n.hover\\:bg-inverse:hover {\n background-color: var(--white);\n}\n\n.hover\\:bg-strong-dark:hover {\n background-color: var(--grey-800);\n}\n\n.hover\\:bg-transparent:hover {\n background-color: var(--transparent);\n}\n\n.hover\\:text-default:hover {\n color: var(--black);\n}\n\n.hover\\:text-lighter:hover {\n color: var(--grey-600);\n}\n\n.hover\\:\\!underline:hover {\n text-decoration-line: underline !important;\n}\n\n.hover\\:no-underline:hover {\n text-decoration-line: none;\n}\n\n.hover\\:shadow-hover:hover {\n --tw-shadow: 0px 0px 16px rgba(0, 0, 0, 0.2);\n --tw-shadow-colored: 0px 0px 16px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.focus\\:shadow-none:focus {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.focus\\:outline-none:focus {\n outline: 2px solid transparent;\n outline-offset: 2px;\n}\n\n.disabled\\:cursor-not-allowed:disabled {\n cursor: not-allowed;\n}\n\n.disabled\\:bg-dark:disabled {\n background-color: var(--grey-300);\n}\n\n.disabled\\:text-lightest:disabled {\n color: var(--grey-500);\n}\n\n.aria-disabled\\:cursor-not-allowed[aria-disabled=\"true\"] {\n cursor: not-allowed;\n}\n\n.aria-disabled\\:\\!border-transparent[aria-disabled=\"true\"] {\n border-color: var(--transparent) !important;\n}\n\n.aria-disabled\\:bg-dark[aria-disabled=\"true\"] {\n background-color: var(--grey-300);\n}\n\n.aria-disabled\\:bg-transparent[aria-disabled=\"true\"] {\n background-color: var(--transparent);\n}\n\n.aria-disabled\\:text-light[aria-disabled=\"true\"] {\n color: var(--grey-700);\n}\n\n.aria-disabled\\:text-lightest[aria-disabled=\"true\"] {\n color: var(--grey-500);\n}\n\n.aria-disabled\\:line-through[aria-disabled=\"true\"] {\n text-decoration-line: line-through;\n}\n\n.aria-disabled\\:shadow-none[aria-disabled=\"true\"] {\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n\n.aria-current-page\\:bg-darker[aria-current=\"page\"] {\n background-color: var(--grey-400);\n}\n\n.after\\:absolute::after {\n position: absolute;\n}\n\n.after\\:inset-0::after {\n inset: 0rem;\n}\n\n.after\\:inset-x-0::after {\n left: 0rem;\n right: 0rem;\n}\n\n.after\\:bottom-0::after {\n bottom: 0rem;\n}\n\n.after\\:left-16::after {\n left: 1rem;\n}\n\n.after\\:right-16::after {\n right: 1rem;\n}\n\n.after\\:z-10::after {\n z-index: 10;\n}\n\n.after\\:rounded-lg::after {\n border-radius: 16px;\n}\n\n.after\\:rounded-t-lg::after {\n border-top-left-radius: 16px;\n border-top-right-radius: 16px;\n}\n\n.after\\:border-3::after {\n border-width: 3px;\n}\n\n.after\\:border-b-2::after {\n border-bottom-width: 2px;\n}\n\n.after\\:\\!border-transparent::after {\n border-color: var(--transparent) !important;\n}\n\n.after\\:border-accent::after {\n border-color: var(--green-500);\n}\n\n.after\\:border-softest::after {\n border-color: rgba(0, 0, 0, .05);\n}\n\n.after\\:opacity-0::after {\n opacity: 0;\n}\n\n.after\\:content-\\[\\'\\'\\]::after {\n --tw-content: '';\n content: var(--tw-content);\n}\n\n.hover\\:after\\:\\!border-transparent:hover::after {\n border-color: var(--transparent) !important;\n}\n\n.hover\\:after\\:opacity-100:hover::after {\n opacity: 1;\n}\n\n.focus-visible\\:after\\:opacity-100:focus-visible::after {\n opacity: 1;\n}\n\n.aria-disabled\\:after\\:\\!border-transparent[aria-disabled=\"true\"]::after {\n border-color: var(--transparent) !important;\n}\n\n.hover\\:before\\:opacity-100:hover::before {\n opacity: 1;\n}";
|
|
85
407
|
const EdsButtonStyle0 = edsButtonCss;
|
|
86
408
|
|
|
87
409
|
const EdsButton = class {
|
|
@@ -101,7 +423,7 @@ const EdsButton = class {
|
|
|
101
423
|
secondary: 'border-inside border-inside-inverse text-inverse bg-strongest hover:bg-strong-dark',
|
|
102
424
|
tertiary: 'border-inside after:border-softest bg-dark hover:bg-darker',
|
|
103
425
|
ghost: 'border-inside hover:bg-darker',
|
|
104
|
-
ghostInverse: 'border-inside hover:bg-dark'
|
|
426
|
+
ghostInverse: 'border-inside text-lightest hover:bg-dark'
|
|
105
427
|
},
|
|
106
428
|
loading: {
|
|
107
429
|
true: 'pointer-events-none',
|
|
@@ -211,8 +533,7 @@ const EdsButton = class {
|
|
|
211
533
|
}
|
|
212
534
|
handleClick(event) {
|
|
213
535
|
var _a, _b;
|
|
214
|
-
if (this.disabled) {
|
|
215
|
-
// Prevent navigation if the link is disabled
|
|
536
|
+
if (this.disabled || this.loading) {
|
|
216
537
|
event.preventDefault();
|
|
217
538
|
return;
|
|
218
539
|
}
|
|
@@ -228,28 +549,2522 @@ const EdsButton = class {
|
|
|
228
549
|
this.triggerClick(); // Trigger the passed-in function
|
|
229
550
|
}
|
|
230
551
|
}
|
|
552
|
+
handleKeyDown(event) {
|
|
553
|
+
if (this.disabled || this.loading) {
|
|
554
|
+
// Fix: check loading too
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (event.key === 'Enter' || (this.elementType === 'a' && event.key === ' ')) {
|
|
558
|
+
event.preventDefault();
|
|
559
|
+
this.handleClick(event);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
render() {
|
|
563
|
+
const classes = this.button({
|
|
564
|
+
intent: this.intent,
|
|
565
|
+
loading: this.loading,
|
|
566
|
+
iconPos: this.iconPos,
|
|
567
|
+
size: this.size,
|
|
568
|
+
pill: this.pill,
|
|
569
|
+
iconOnly: !this.label,
|
|
570
|
+
iconSmall: this.iconSmall
|
|
571
|
+
});
|
|
572
|
+
const ElementType = this.elementType;
|
|
573
|
+
const isInteractive = !this.disabled && !this.loading;
|
|
574
|
+
return (h(Host, { key: '835cc81d3563abf1b5cb4c21165de1ef726d1e43' }, h(ElementType, { key: 'df05b2b2152e707e5fdd6028c5f557097d7e2b04', tabindex: isInteractive ? '0' : '-1', "aria-label": this.label ? undefined : this.ariaLabel, "aria-disabled": this.disabled || this.loading ? 'true' : undefined, "aria-busy": this.loading ? 'true' : undefined, disabled: this.elementType === 'button' ? this.disabled || this.loading : undefined, role: this.elementType === 'a' ? 'button' : undefined, class: `${classes || ''} ${this.extraClass || ''}`, onClick: (event) => this.handleClick(event), onKeyDown: (event) => this.handleKeyDown(event) }, this.label && (h("span", { key: '27c7473403e7c1bfd3dfc270151d44dbb639ceb3', class: this.loading ? 'opacity-0' : '', "aria-hidden": this.loading ? 'true' : undefined }, this.label)), this.loading && (h("span", { key: 'f52496884816bc299fb76c1afae5e4798bf642d2', class: "absolute inset-0 flex items-center justify-center", "aria-hidden": "true" }, h("span", { key: 'd42bf2c229f6956a1e0dbe64aa6c79ad5608ca5c', class: "loader", style: {
|
|
575
|
+
border: `3px solid ${this.intent === 'secondary' ? 'rgba(255, 255, 255, .3)' : 'rgba(0, 0, 0, .3)'}`,
|
|
576
|
+
borderBottomColor: this.intent === 'secondary' ? '#fff' : '#000'
|
|
577
|
+
} }))), this.icon ? (h("eds-icon-wrapper", { class: `
|
|
578
|
+
flex inline-flex items-center justify-center
|
|
579
|
+
${this.size === 'large' ? 'h-24 w-24' : 'h-20 w-20'}
|
|
580
|
+
`, icon: this.icon, "aria-hidden": "true" })) : null)));
|
|
581
|
+
}
|
|
582
|
+
static get delegatesFocus() { return true; }
|
|
583
|
+
get el() { return getElement(this); }
|
|
584
|
+
};
|
|
585
|
+
EdsButton.style = EdsButtonStyle0;
|
|
586
|
+
|
|
587
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
588
|
+
|
|
589
|
+
var prism = {exports: {}};
|
|
590
|
+
|
|
591
|
+
(function (module) {
|
|
592
|
+
/* **********************************************
|
|
593
|
+
Begin prism-core.js
|
|
594
|
+
********************************************** */
|
|
595
|
+
|
|
596
|
+
/// <reference lib="WebWorker"/>
|
|
597
|
+
|
|
598
|
+
var _self = (typeof window !== 'undefined')
|
|
599
|
+
? window // if in browser
|
|
600
|
+
: (
|
|
601
|
+
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
|
|
602
|
+
? self // if in worker
|
|
603
|
+
: {} // if in node js
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
608
|
+
*
|
|
609
|
+
* @license MIT <https://opensource.org/licenses/MIT>
|
|
610
|
+
* @author Lea Verou <https://lea.verou.me>
|
|
611
|
+
* @namespace
|
|
612
|
+
* @public
|
|
613
|
+
*/
|
|
614
|
+
var Prism = (function (_self) {
|
|
615
|
+
|
|
616
|
+
// Private helper vars
|
|
617
|
+
var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
|
|
618
|
+
var uniqueId = 0;
|
|
619
|
+
|
|
620
|
+
// The grammar object for plaintext
|
|
621
|
+
var plainTextGrammar = {};
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
var _ = {
|
|
625
|
+
/**
|
|
626
|
+
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
|
|
627
|
+
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
|
|
628
|
+
* additional languages or plugins yourself.
|
|
629
|
+
*
|
|
630
|
+
* By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
|
|
631
|
+
*
|
|
632
|
+
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
|
|
633
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
634
|
+
*
|
|
635
|
+
* ```js
|
|
636
|
+
* window.Prism = window.Prism || {};
|
|
637
|
+
* Prism.manual = true;
|
|
638
|
+
* // add a new <script> to load Prism's script
|
|
639
|
+
* ```
|
|
640
|
+
*
|
|
641
|
+
* @default false
|
|
642
|
+
* @type {boolean}
|
|
643
|
+
* @memberof Prism
|
|
644
|
+
* @public
|
|
645
|
+
*/
|
|
646
|
+
manual: _self.Prism && _self.Prism.manual,
|
|
647
|
+
/**
|
|
648
|
+
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
|
|
649
|
+
* `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
|
|
650
|
+
* own worker, you don't want it to do this.
|
|
651
|
+
*
|
|
652
|
+
* By setting this value to `true`, Prism will not add its own listeners to the worker.
|
|
653
|
+
*
|
|
654
|
+
* You obviously have to change this value before Prism executes. To do this, you can add an
|
|
655
|
+
* empty Prism object into the global scope before loading the Prism script like this:
|
|
656
|
+
*
|
|
657
|
+
* ```js
|
|
658
|
+
* window.Prism = window.Prism || {};
|
|
659
|
+
* Prism.disableWorkerMessageHandler = true;
|
|
660
|
+
* // Load Prism's script
|
|
661
|
+
* ```
|
|
662
|
+
*
|
|
663
|
+
* @default false
|
|
664
|
+
* @type {boolean}
|
|
665
|
+
* @memberof Prism
|
|
666
|
+
* @public
|
|
667
|
+
*/
|
|
668
|
+
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* A namespace for utility methods.
|
|
672
|
+
*
|
|
673
|
+
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
|
|
674
|
+
* change or disappear at any time.
|
|
675
|
+
*
|
|
676
|
+
* @namespace
|
|
677
|
+
* @memberof Prism
|
|
678
|
+
*/
|
|
679
|
+
util: {
|
|
680
|
+
encode: function encode(tokens) {
|
|
681
|
+
if (tokens instanceof Token) {
|
|
682
|
+
return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
|
683
|
+
} else if (Array.isArray(tokens)) {
|
|
684
|
+
return tokens.map(encode);
|
|
685
|
+
} else {
|
|
686
|
+
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Returns the name of the type of the given value.
|
|
692
|
+
*
|
|
693
|
+
* @param {any} o
|
|
694
|
+
* @returns {string}
|
|
695
|
+
* @example
|
|
696
|
+
* type(null) === 'Null'
|
|
697
|
+
* type(undefined) === 'Undefined'
|
|
698
|
+
* type(123) === 'Number'
|
|
699
|
+
* type('foo') === 'String'
|
|
700
|
+
* type(true) === 'Boolean'
|
|
701
|
+
* type([1, 2]) === 'Array'
|
|
702
|
+
* type({}) === 'Object'
|
|
703
|
+
* type(String) === 'Function'
|
|
704
|
+
* type(/abc+/) === 'RegExp'
|
|
705
|
+
*/
|
|
706
|
+
type: function (o) {
|
|
707
|
+
return Object.prototype.toString.call(o).slice(8, -1);
|
|
708
|
+
},
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Returns a unique number for the given object. Later calls will still return the same number.
|
|
712
|
+
*
|
|
713
|
+
* @param {Object} obj
|
|
714
|
+
* @returns {number}
|
|
715
|
+
*/
|
|
716
|
+
objId: function (obj) {
|
|
717
|
+
if (!obj['__id']) {
|
|
718
|
+
Object.defineProperty(obj, '__id', { value: ++uniqueId });
|
|
719
|
+
}
|
|
720
|
+
return obj['__id'];
|
|
721
|
+
},
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* Creates a deep clone of the given object.
|
|
725
|
+
*
|
|
726
|
+
* The main intended use of this function is to clone language definitions.
|
|
727
|
+
*
|
|
728
|
+
* @param {T} o
|
|
729
|
+
* @param {Record<number, any>} [visited]
|
|
730
|
+
* @returns {T}
|
|
731
|
+
* @template T
|
|
732
|
+
*/
|
|
733
|
+
clone: function deepClone(o, visited) {
|
|
734
|
+
visited = visited || {};
|
|
735
|
+
|
|
736
|
+
var clone; var id;
|
|
737
|
+
switch (_.util.type(o)) {
|
|
738
|
+
case 'Object':
|
|
739
|
+
id = _.util.objId(o);
|
|
740
|
+
if (visited[id]) {
|
|
741
|
+
return visited[id];
|
|
742
|
+
}
|
|
743
|
+
clone = /** @type {Record<string, any>} */ ({});
|
|
744
|
+
visited[id] = clone;
|
|
745
|
+
|
|
746
|
+
for (var key in o) {
|
|
747
|
+
if (o.hasOwnProperty(key)) {
|
|
748
|
+
clone[key] = deepClone(o[key], visited);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
return /** @type {any} */ (clone);
|
|
753
|
+
|
|
754
|
+
case 'Array':
|
|
755
|
+
id = _.util.objId(o);
|
|
756
|
+
if (visited[id]) {
|
|
757
|
+
return visited[id];
|
|
758
|
+
}
|
|
759
|
+
clone = [];
|
|
760
|
+
visited[id] = clone;
|
|
761
|
+
|
|
762
|
+
(/** @type {Array} */(/** @type {any} */(o))).forEach(function (v, i) {
|
|
763
|
+
clone[i] = deepClone(v, visited);
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
return /** @type {any} */ (clone);
|
|
767
|
+
|
|
768
|
+
default:
|
|
769
|
+
return o;
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
|
|
775
|
+
*
|
|
776
|
+
* If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
|
|
777
|
+
*
|
|
778
|
+
* @param {Element} element
|
|
779
|
+
* @returns {string}
|
|
780
|
+
*/
|
|
781
|
+
getLanguage: function (element) {
|
|
782
|
+
while (element) {
|
|
783
|
+
var m = lang.exec(element.className);
|
|
784
|
+
if (m) {
|
|
785
|
+
return m[1].toLowerCase();
|
|
786
|
+
}
|
|
787
|
+
element = element.parentElement;
|
|
788
|
+
}
|
|
789
|
+
return 'none';
|
|
790
|
+
},
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Sets the Prism `language-xxxx` class of the given element.
|
|
794
|
+
*
|
|
795
|
+
* @param {Element} element
|
|
796
|
+
* @param {string} language
|
|
797
|
+
* @returns {void}
|
|
798
|
+
*/
|
|
799
|
+
setLanguage: function (element, language) {
|
|
800
|
+
// remove all `language-xxxx` classes
|
|
801
|
+
// (this might leave behind a leading space)
|
|
802
|
+
element.className = element.className.replace(RegExp(lang, 'gi'), '');
|
|
803
|
+
|
|
804
|
+
// add the new `language-xxxx` class
|
|
805
|
+
// (using `classList` will automatically clean up spaces for us)
|
|
806
|
+
element.classList.add('language-' + language);
|
|
807
|
+
},
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Returns the script element that is currently executing.
|
|
811
|
+
*
|
|
812
|
+
* This does __not__ work for line script element.
|
|
813
|
+
*
|
|
814
|
+
* @returns {HTMLScriptElement | null}
|
|
815
|
+
*/
|
|
816
|
+
currentScript: function () {
|
|
817
|
+
if (typeof document === 'undefined') {
|
|
818
|
+
return null;
|
|
819
|
+
}
|
|
820
|
+
if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
|
|
821
|
+
return /** @type {any} */ (document.currentScript);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
// IE11 workaround
|
|
825
|
+
// we'll get the src of the current script by parsing IE11's error stack trace
|
|
826
|
+
// this will not work for inline scripts
|
|
827
|
+
|
|
828
|
+
try {
|
|
829
|
+
throw new Error();
|
|
830
|
+
} catch (err) {
|
|
831
|
+
// Get file src url from stack. Specifically works with the format of stack traces in IE.
|
|
832
|
+
// A stack will look like this:
|
|
833
|
+
//
|
|
834
|
+
// Error
|
|
835
|
+
// at _.util.currentScript (http://localhost/components/prism-core.js:119:5)
|
|
836
|
+
// at Global code (http://localhost/components/prism-core.js:606:1)
|
|
837
|
+
|
|
838
|
+
var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
|
|
839
|
+
if (src) {
|
|
840
|
+
var scripts = document.getElementsByTagName('script');
|
|
841
|
+
for (var i in scripts) {
|
|
842
|
+
if (scripts[i].src == src) {
|
|
843
|
+
return scripts[i];
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return null;
|
|
848
|
+
}
|
|
849
|
+
},
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Returns whether a given class is active for `element`.
|
|
853
|
+
*
|
|
854
|
+
* The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
|
|
855
|
+
* if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the
|
|
856
|
+
* given class is just the given class with a `no-` prefix.
|
|
857
|
+
*
|
|
858
|
+
* Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
|
|
859
|
+
* closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
|
|
860
|
+
* ancestors have the given class or the negated version of it, then the default activation will be returned.
|
|
861
|
+
*
|
|
862
|
+
* In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
|
|
863
|
+
* version of it, the class is considered active.
|
|
864
|
+
*
|
|
865
|
+
* @param {Element} element
|
|
866
|
+
* @param {string} className
|
|
867
|
+
* @param {boolean} [defaultActivation=false]
|
|
868
|
+
* @returns {boolean}
|
|
869
|
+
*/
|
|
870
|
+
isActive: function (element, className, defaultActivation) {
|
|
871
|
+
var no = 'no-' + className;
|
|
872
|
+
|
|
873
|
+
while (element) {
|
|
874
|
+
var classList = element.classList;
|
|
875
|
+
if (classList.contains(className)) {
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
if (classList.contains(no)) {
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
881
|
+
element = element.parentElement;
|
|
882
|
+
}
|
|
883
|
+
return !!defaultActivation;
|
|
884
|
+
}
|
|
885
|
+
},
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
|
|
889
|
+
*
|
|
890
|
+
* @namespace
|
|
891
|
+
* @memberof Prism
|
|
892
|
+
* @public
|
|
893
|
+
*/
|
|
894
|
+
languages: {
|
|
895
|
+
/**
|
|
896
|
+
* The grammar for plain, unformatted text.
|
|
897
|
+
*/
|
|
898
|
+
plain: plainTextGrammar,
|
|
899
|
+
plaintext: plainTextGrammar,
|
|
900
|
+
text: plainTextGrammar,
|
|
901
|
+
txt: plainTextGrammar,
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Creates a deep copy of the language with the given id and appends the given tokens.
|
|
905
|
+
*
|
|
906
|
+
* If a token in `redef` also appears in the copied language, then the existing token in the copied language
|
|
907
|
+
* will be overwritten at its original position.
|
|
908
|
+
*
|
|
909
|
+
* ## Best practices
|
|
910
|
+
*
|
|
911
|
+
* Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
|
|
912
|
+
* doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
|
|
913
|
+
* understand the language definition because, normally, the order of tokens matters in Prism grammars.
|
|
914
|
+
*
|
|
915
|
+
* Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
|
|
916
|
+
* Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
|
|
917
|
+
*
|
|
918
|
+
* @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
|
|
919
|
+
* @param {Grammar} redef The new tokens to append.
|
|
920
|
+
* @returns {Grammar} The new language created.
|
|
921
|
+
* @public
|
|
922
|
+
* @example
|
|
923
|
+
* Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
|
|
924
|
+
* // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
|
|
925
|
+
* // at its original position
|
|
926
|
+
* 'comment': { ... },
|
|
927
|
+
* // CSS doesn't have a 'color' token, so this token will be appended
|
|
928
|
+
* 'color': /\b(?:red|green|blue)\b/
|
|
929
|
+
* });
|
|
930
|
+
*/
|
|
931
|
+
extend: function (id, redef) {
|
|
932
|
+
var lang = _.util.clone(_.languages[id]);
|
|
933
|
+
|
|
934
|
+
for (var key in redef) {
|
|
935
|
+
lang[key] = redef[key];
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
return lang;
|
|
939
|
+
},
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Inserts tokens _before_ another token in a language definition or any other grammar.
|
|
943
|
+
*
|
|
944
|
+
* ## Usage
|
|
945
|
+
*
|
|
946
|
+
* This helper method makes it easy to modify existing languages. For example, the CSS language definition
|
|
947
|
+
* not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
|
|
948
|
+
* in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
|
|
949
|
+
* appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
|
|
950
|
+
* this:
|
|
951
|
+
*
|
|
952
|
+
* ```js
|
|
953
|
+
* Prism.languages.markup.style = {
|
|
954
|
+
* // token
|
|
955
|
+
* };
|
|
956
|
+
* ```
|
|
957
|
+
*
|
|
958
|
+
* then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
|
|
959
|
+
* before existing tokens. For the CSS example above, you would use it like this:
|
|
960
|
+
*
|
|
961
|
+
* ```js
|
|
962
|
+
* Prism.languages.insertBefore('markup', 'cdata', {
|
|
963
|
+
* 'style': {
|
|
964
|
+
* // token
|
|
965
|
+
* }
|
|
966
|
+
* });
|
|
967
|
+
* ```
|
|
968
|
+
*
|
|
969
|
+
* ## Special cases
|
|
970
|
+
*
|
|
971
|
+
* If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
|
|
972
|
+
* will be ignored.
|
|
973
|
+
*
|
|
974
|
+
* This behavior can be used to insert tokens after `before`:
|
|
975
|
+
*
|
|
976
|
+
* ```js
|
|
977
|
+
* Prism.languages.insertBefore('markup', 'comment', {
|
|
978
|
+
* 'comment': Prism.languages.markup.comment,
|
|
979
|
+
* // tokens after 'comment'
|
|
980
|
+
* });
|
|
981
|
+
* ```
|
|
982
|
+
*
|
|
983
|
+
* ## Limitations
|
|
984
|
+
*
|
|
985
|
+
* The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
|
|
986
|
+
* properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
|
|
987
|
+
* differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
|
|
988
|
+
* deleting properties which is necessary to insert at arbitrary positions.
|
|
989
|
+
*
|
|
990
|
+
* To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
|
|
991
|
+
* Instead, it will create a new object and replace all references to the target object with the new one. This
|
|
992
|
+
* can be done without temporarily deleting properties, so the iteration order is well-defined.
|
|
993
|
+
*
|
|
994
|
+
* However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
|
|
995
|
+
* you hold the target object in a variable, then the value of the variable will not change.
|
|
996
|
+
*
|
|
997
|
+
* ```js
|
|
998
|
+
* var oldMarkup = Prism.languages.markup;
|
|
999
|
+
* var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
|
|
1000
|
+
*
|
|
1001
|
+
* assert(oldMarkup !== Prism.languages.markup);
|
|
1002
|
+
* assert(newMarkup === Prism.languages.markup);
|
|
1003
|
+
* ```
|
|
1004
|
+
*
|
|
1005
|
+
* @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
|
|
1006
|
+
* object to be modified.
|
|
1007
|
+
* @param {string} before The key to insert before.
|
|
1008
|
+
* @param {Grammar} insert An object containing the key-value pairs to be inserted.
|
|
1009
|
+
* @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
|
|
1010
|
+
* object to be modified.
|
|
1011
|
+
*
|
|
1012
|
+
* Defaults to `Prism.languages`.
|
|
1013
|
+
* @returns {Grammar} The new grammar object.
|
|
1014
|
+
* @public
|
|
1015
|
+
*/
|
|
1016
|
+
insertBefore: function (inside, before, insert, root) {
|
|
1017
|
+
root = root || /** @type {any} */ (_.languages);
|
|
1018
|
+
var grammar = root[inside];
|
|
1019
|
+
/** @type {Grammar} */
|
|
1020
|
+
var ret = {};
|
|
1021
|
+
|
|
1022
|
+
for (var token in grammar) {
|
|
1023
|
+
if (grammar.hasOwnProperty(token)) {
|
|
1024
|
+
|
|
1025
|
+
if (token == before) {
|
|
1026
|
+
for (var newToken in insert) {
|
|
1027
|
+
if (insert.hasOwnProperty(newToken)) {
|
|
1028
|
+
ret[newToken] = insert[newToken];
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
// Do not insert token which also occur in insert. See #1525
|
|
1034
|
+
if (!insert.hasOwnProperty(token)) {
|
|
1035
|
+
ret[token] = grammar[token];
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
var old = root[inside];
|
|
1041
|
+
root[inside] = ret;
|
|
1042
|
+
|
|
1043
|
+
// Update references in other language definitions
|
|
1044
|
+
_.languages.DFS(_.languages, function (key, value) {
|
|
1045
|
+
if (value === old && key != inside) {
|
|
1046
|
+
this[key] = ret;
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
return ret;
|
|
1051
|
+
},
|
|
1052
|
+
|
|
1053
|
+
// Traverse a language definition with Depth First Search
|
|
1054
|
+
DFS: function DFS(o, callback, type, visited) {
|
|
1055
|
+
visited = visited || {};
|
|
1056
|
+
|
|
1057
|
+
var objId = _.util.objId;
|
|
1058
|
+
|
|
1059
|
+
for (var i in o) {
|
|
1060
|
+
if (o.hasOwnProperty(i)) {
|
|
1061
|
+
callback.call(o, i, o[i], type || i);
|
|
1062
|
+
|
|
1063
|
+
var property = o[i];
|
|
1064
|
+
var propertyType = _.util.type(property);
|
|
1065
|
+
|
|
1066
|
+
if (propertyType === 'Object' && !visited[objId(property)]) {
|
|
1067
|
+
visited[objId(property)] = true;
|
|
1068
|
+
DFS(property, callback, null, visited);
|
|
1069
|
+
} else if (propertyType === 'Array' && !visited[objId(property)]) {
|
|
1070
|
+
visited[objId(property)] = true;
|
|
1071
|
+
DFS(property, callback, i, visited);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
},
|
|
1077
|
+
|
|
1078
|
+
plugins: {},
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* This is the most high-level function in Prism’s API.
|
|
1082
|
+
* It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
|
|
1083
|
+
* each one of them.
|
|
1084
|
+
*
|
|
1085
|
+
* This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
|
|
1086
|
+
*
|
|
1087
|
+
* @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
|
|
1088
|
+
* @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
|
|
1089
|
+
* @memberof Prism
|
|
1090
|
+
* @public
|
|
1091
|
+
*/
|
|
1092
|
+
highlightAll: function (async, callback) {
|
|
1093
|
+
_.highlightAllUnder(document, async, callback);
|
|
1094
|
+
},
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
|
|
1098
|
+
* {@link Prism.highlightElement} on each one of them.
|
|
1099
|
+
*
|
|
1100
|
+
* The following hooks will be run:
|
|
1101
|
+
* 1. `before-highlightall`
|
|
1102
|
+
* 2. `before-all-elements-highlight`
|
|
1103
|
+
* 3. All hooks of {@link Prism.highlightElement} for each element.
|
|
1104
|
+
*
|
|
1105
|
+
* @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
|
|
1106
|
+
* @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
|
|
1107
|
+
* @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
|
|
1108
|
+
* @memberof Prism
|
|
1109
|
+
* @public
|
|
1110
|
+
*/
|
|
1111
|
+
highlightAllUnder: function (container, async, callback) {
|
|
1112
|
+
var env = {
|
|
1113
|
+
callback: callback,
|
|
1114
|
+
container: container,
|
|
1115
|
+
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
_.hooks.run('before-highlightall', env);
|
|
1119
|
+
|
|
1120
|
+
env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
|
|
1121
|
+
|
|
1122
|
+
_.hooks.run('before-all-elements-highlight', env);
|
|
1123
|
+
|
|
1124
|
+
for (var i = 0, element; (element = env.elements[i++]);) {
|
|
1125
|
+
_.highlightElement(element, async === true, env.callback);
|
|
1126
|
+
}
|
|
1127
|
+
},
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* Highlights the code inside a single element.
|
|
1131
|
+
*
|
|
1132
|
+
* The following hooks will be run:
|
|
1133
|
+
* 1. `before-sanity-check`
|
|
1134
|
+
* 2. `before-highlight`
|
|
1135
|
+
* 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
|
|
1136
|
+
* 4. `before-insert`
|
|
1137
|
+
* 5. `after-highlight`
|
|
1138
|
+
* 6. `complete`
|
|
1139
|
+
*
|
|
1140
|
+
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
|
|
1141
|
+
* the element's language.
|
|
1142
|
+
*
|
|
1143
|
+
* @param {Element} element The element containing the code.
|
|
1144
|
+
* It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
|
|
1145
|
+
* @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
|
|
1146
|
+
* to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
|
|
1147
|
+
* [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
|
|
1148
|
+
*
|
|
1149
|
+
* Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
|
|
1150
|
+
* asynchronous highlighting to work. You can build your own bundle on the
|
|
1151
|
+
* [Download page](https://prismjs.com/download.html).
|
|
1152
|
+
* @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
|
|
1153
|
+
* Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
|
|
1154
|
+
* @memberof Prism
|
|
1155
|
+
* @public
|
|
1156
|
+
*/
|
|
1157
|
+
highlightElement: function (element, async, callback) {
|
|
1158
|
+
// Find language
|
|
1159
|
+
var language = _.util.getLanguage(element);
|
|
1160
|
+
var grammar = _.languages[language];
|
|
1161
|
+
|
|
1162
|
+
// Set language on the element, if not present
|
|
1163
|
+
_.util.setLanguage(element, language);
|
|
1164
|
+
|
|
1165
|
+
// Set language on the parent, for styling
|
|
1166
|
+
var parent = element.parentElement;
|
|
1167
|
+
if (parent && parent.nodeName.toLowerCase() === 'pre') {
|
|
1168
|
+
_.util.setLanguage(parent, language);
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
var code = element.textContent;
|
|
1172
|
+
|
|
1173
|
+
var env = {
|
|
1174
|
+
element: element,
|
|
1175
|
+
language: language,
|
|
1176
|
+
grammar: grammar,
|
|
1177
|
+
code: code
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
function insertHighlightedCode(highlightedCode) {
|
|
1181
|
+
env.highlightedCode = highlightedCode;
|
|
1182
|
+
|
|
1183
|
+
_.hooks.run('before-insert', env);
|
|
1184
|
+
|
|
1185
|
+
env.element.innerHTML = env.highlightedCode;
|
|
1186
|
+
|
|
1187
|
+
_.hooks.run('after-highlight', env);
|
|
1188
|
+
_.hooks.run('complete', env);
|
|
1189
|
+
callback && callback.call(env.element);
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
_.hooks.run('before-sanity-check', env);
|
|
1193
|
+
|
|
1194
|
+
// plugins may change/add the parent/element
|
|
1195
|
+
parent = env.element.parentElement;
|
|
1196
|
+
if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
|
|
1197
|
+
parent.setAttribute('tabindex', '0');
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
if (!env.code) {
|
|
1201
|
+
_.hooks.run('complete', env);
|
|
1202
|
+
callback && callback.call(env.element);
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
_.hooks.run('before-highlight', env);
|
|
1207
|
+
|
|
1208
|
+
if (!env.grammar) {
|
|
1209
|
+
insertHighlightedCode(_.util.encode(env.code));
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
if (async && _self.Worker) {
|
|
1214
|
+
var worker = new Worker(_.filename);
|
|
1215
|
+
|
|
1216
|
+
worker.onmessage = function (evt) {
|
|
1217
|
+
insertHighlightedCode(evt.data);
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
worker.postMessage(JSON.stringify({
|
|
1221
|
+
language: env.language,
|
|
1222
|
+
code: env.code,
|
|
1223
|
+
immediateClose: true
|
|
1224
|
+
}));
|
|
1225
|
+
} else {
|
|
1226
|
+
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Low-level function, only use if you know what you’re doing. It accepts a string of text as input
|
|
1232
|
+
* and the language definitions to use, and returns a string with the HTML produced.
|
|
1233
|
+
*
|
|
1234
|
+
* The following hooks will be run:
|
|
1235
|
+
* 1. `before-tokenize`
|
|
1236
|
+
* 2. `after-tokenize`
|
|
1237
|
+
* 3. `wrap`: On each {@link Token}.
|
|
1238
|
+
*
|
|
1239
|
+
* @param {string} text A string with the code to be highlighted.
|
|
1240
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
1241
|
+
*
|
|
1242
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
1243
|
+
* @param {string} language The name of the language definition passed to `grammar`.
|
|
1244
|
+
* @returns {string} The highlighted HTML.
|
|
1245
|
+
* @memberof Prism
|
|
1246
|
+
* @public
|
|
1247
|
+
* @example
|
|
1248
|
+
* Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
|
|
1249
|
+
*/
|
|
1250
|
+
highlight: function (text, grammar, language) {
|
|
1251
|
+
var env = {
|
|
1252
|
+
code: text,
|
|
1253
|
+
grammar: grammar,
|
|
1254
|
+
language: language
|
|
1255
|
+
};
|
|
1256
|
+
_.hooks.run('before-tokenize', env);
|
|
1257
|
+
if (!env.grammar) {
|
|
1258
|
+
throw new Error('The language "' + env.language + '" has no grammar.');
|
|
1259
|
+
}
|
|
1260
|
+
env.tokens = _.tokenize(env.code, env.grammar);
|
|
1261
|
+
_.hooks.run('after-tokenize', env);
|
|
1262
|
+
return Token.stringify(_.util.encode(env.tokens), env.language);
|
|
1263
|
+
},
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
|
|
1267
|
+
* and the language definitions to use, and returns an array with the tokenized code.
|
|
1268
|
+
*
|
|
1269
|
+
* When the language definition includes nested tokens, the function is called recursively on each of these tokens.
|
|
1270
|
+
*
|
|
1271
|
+
* This method could be useful in other contexts as well, as a very crude parser.
|
|
1272
|
+
*
|
|
1273
|
+
* @param {string} text A string with the code to be highlighted.
|
|
1274
|
+
* @param {Grammar} grammar An object containing the tokens to use.
|
|
1275
|
+
*
|
|
1276
|
+
* Usually a language definition like `Prism.languages.markup`.
|
|
1277
|
+
* @returns {TokenStream} An array of strings and tokens, a token stream.
|
|
1278
|
+
* @memberof Prism
|
|
1279
|
+
* @public
|
|
1280
|
+
* @example
|
|
1281
|
+
* let code = `var foo = 0;`;
|
|
1282
|
+
* let tokens = Prism.tokenize(code, Prism.languages.javascript);
|
|
1283
|
+
* tokens.forEach(token => {
|
|
1284
|
+
* if (token instanceof Prism.Token && token.type === 'number') {
|
|
1285
|
+
* console.log(`Found numeric literal: ${token.content}`);
|
|
1286
|
+
* }
|
|
1287
|
+
* });
|
|
1288
|
+
*/
|
|
1289
|
+
tokenize: function (text, grammar) {
|
|
1290
|
+
var rest = grammar.rest;
|
|
1291
|
+
if (rest) {
|
|
1292
|
+
for (var token in rest) {
|
|
1293
|
+
grammar[token] = rest[token];
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
delete grammar.rest;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
var tokenList = new LinkedList();
|
|
1300
|
+
addAfter(tokenList, tokenList.head, text);
|
|
1301
|
+
|
|
1302
|
+
matchGrammar(text, tokenList, grammar, tokenList.head, 0);
|
|
1303
|
+
|
|
1304
|
+
return toArray(tokenList);
|
|
1305
|
+
},
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* @namespace
|
|
1309
|
+
* @memberof Prism
|
|
1310
|
+
* @public
|
|
1311
|
+
*/
|
|
1312
|
+
hooks: {
|
|
1313
|
+
all: {},
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Adds the given callback to the list of callbacks for the given hook.
|
|
1317
|
+
*
|
|
1318
|
+
* The callback will be invoked when the hook it is registered for is run.
|
|
1319
|
+
* Hooks are usually directly run by a highlight function but you can also run hooks yourself.
|
|
1320
|
+
*
|
|
1321
|
+
* One callback function can be registered to multiple hooks and the same hook multiple times.
|
|
1322
|
+
*
|
|
1323
|
+
* @param {string} name The name of the hook.
|
|
1324
|
+
* @param {HookCallback} callback The callback function which is given environment variables.
|
|
1325
|
+
* @public
|
|
1326
|
+
*/
|
|
1327
|
+
add: function (name, callback) {
|
|
1328
|
+
var hooks = _.hooks.all;
|
|
1329
|
+
|
|
1330
|
+
hooks[name] = hooks[name] || [];
|
|
1331
|
+
|
|
1332
|
+
hooks[name].push(callback);
|
|
1333
|
+
},
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* Runs a hook invoking all registered callbacks with the given environment variables.
|
|
1337
|
+
*
|
|
1338
|
+
* Callbacks will be invoked synchronously and in the order in which they were registered.
|
|
1339
|
+
*
|
|
1340
|
+
* @param {string} name The name of the hook.
|
|
1341
|
+
* @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
|
|
1342
|
+
* @public
|
|
1343
|
+
*/
|
|
1344
|
+
run: function (name, env) {
|
|
1345
|
+
var callbacks = _.hooks.all[name];
|
|
1346
|
+
|
|
1347
|
+
if (!callbacks || !callbacks.length) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
for (var i = 0, callback; (callback = callbacks[i++]);) {
|
|
1352
|
+
callback(env);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
},
|
|
1356
|
+
|
|
1357
|
+
Token: Token
|
|
1358
|
+
};
|
|
1359
|
+
_self.Prism = _;
|
|
1360
|
+
|
|
1361
|
+
|
|
1362
|
+
// Typescript note:
|
|
1363
|
+
// The following can be used to import the Token type in JSDoc:
|
|
1364
|
+
//
|
|
1365
|
+
// @typedef {InstanceType<import("./prism-core")["Token"]>} Token
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* Creates a new token.
|
|
1369
|
+
*
|
|
1370
|
+
* @param {string} type See {@link Token#type type}
|
|
1371
|
+
* @param {string | TokenStream} content See {@link Token#content content}
|
|
1372
|
+
* @param {string|string[]} [alias] The alias(es) of the token.
|
|
1373
|
+
* @param {string} [matchedStr=""] A copy of the full string this token was created from.
|
|
1374
|
+
* @class
|
|
1375
|
+
* @global
|
|
1376
|
+
* @public
|
|
1377
|
+
*/
|
|
1378
|
+
function Token(type, content, alias, matchedStr) {
|
|
1379
|
+
/**
|
|
1380
|
+
* The type of the token.
|
|
1381
|
+
*
|
|
1382
|
+
* This is usually the key of a pattern in a {@link Grammar}.
|
|
1383
|
+
*
|
|
1384
|
+
* @type {string}
|
|
1385
|
+
* @see GrammarToken
|
|
1386
|
+
* @public
|
|
1387
|
+
*/
|
|
1388
|
+
this.type = type;
|
|
1389
|
+
/**
|
|
1390
|
+
* The strings or tokens contained by this token.
|
|
1391
|
+
*
|
|
1392
|
+
* This will be a token stream if the pattern matched also defined an `inside` grammar.
|
|
1393
|
+
*
|
|
1394
|
+
* @type {string | TokenStream}
|
|
1395
|
+
* @public
|
|
1396
|
+
*/
|
|
1397
|
+
this.content = content;
|
|
1398
|
+
/**
|
|
1399
|
+
* The alias(es) of the token.
|
|
1400
|
+
*
|
|
1401
|
+
* @type {string|string[]}
|
|
1402
|
+
* @see GrammarToken
|
|
1403
|
+
* @public
|
|
1404
|
+
*/
|
|
1405
|
+
this.alias = alias;
|
|
1406
|
+
// Copy of the full string this token was created from
|
|
1407
|
+
this.length = (matchedStr || '').length | 0;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
/**
|
|
1411
|
+
* A token stream is an array of strings and {@link Token Token} objects.
|
|
1412
|
+
*
|
|
1413
|
+
* Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process
|
|
1414
|
+
* them.
|
|
1415
|
+
*
|
|
1416
|
+
* 1. No adjacent strings.
|
|
1417
|
+
* 2. No empty strings.
|
|
1418
|
+
*
|
|
1419
|
+
* The only exception here is the token stream that only contains the empty string and nothing else.
|
|
1420
|
+
*
|
|
1421
|
+
* @typedef {Array<string | Token>} TokenStream
|
|
1422
|
+
* @global
|
|
1423
|
+
* @public
|
|
1424
|
+
*/
|
|
1425
|
+
|
|
1426
|
+
/**
|
|
1427
|
+
* Converts the given token or token stream to an HTML representation.
|
|
1428
|
+
*
|
|
1429
|
+
* The following hooks will be run:
|
|
1430
|
+
* 1. `wrap`: On each {@link Token}.
|
|
1431
|
+
*
|
|
1432
|
+
* @param {string | Token | TokenStream} o The token or token stream to be converted.
|
|
1433
|
+
* @param {string} language The name of current language.
|
|
1434
|
+
* @returns {string} The HTML representation of the token or token stream.
|
|
1435
|
+
* @memberof Token
|
|
1436
|
+
* @static
|
|
1437
|
+
*/
|
|
1438
|
+
Token.stringify = function stringify(o, language) {
|
|
1439
|
+
if (typeof o == 'string') {
|
|
1440
|
+
return o;
|
|
1441
|
+
}
|
|
1442
|
+
if (Array.isArray(o)) {
|
|
1443
|
+
var s = '';
|
|
1444
|
+
o.forEach(function (e) {
|
|
1445
|
+
s += stringify(e, language);
|
|
1446
|
+
});
|
|
1447
|
+
return s;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
var env = {
|
|
1451
|
+
type: o.type,
|
|
1452
|
+
content: stringify(o.content, language),
|
|
1453
|
+
tag: 'span',
|
|
1454
|
+
classes: ['token', o.type],
|
|
1455
|
+
attributes: {},
|
|
1456
|
+
language: language
|
|
1457
|
+
};
|
|
1458
|
+
|
|
1459
|
+
var aliases = o.alias;
|
|
1460
|
+
if (aliases) {
|
|
1461
|
+
if (Array.isArray(aliases)) {
|
|
1462
|
+
Array.prototype.push.apply(env.classes, aliases);
|
|
1463
|
+
} else {
|
|
1464
|
+
env.classes.push(aliases);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
_.hooks.run('wrap', env);
|
|
1469
|
+
|
|
1470
|
+
var attributes = '';
|
|
1471
|
+
for (var name in env.attributes) {
|
|
1472
|
+
attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"';
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
|
|
1476
|
+
};
|
|
1477
|
+
|
|
1478
|
+
/**
|
|
1479
|
+
* @param {RegExp} pattern
|
|
1480
|
+
* @param {number} pos
|
|
1481
|
+
* @param {string} text
|
|
1482
|
+
* @param {boolean} lookbehind
|
|
1483
|
+
* @returns {RegExpExecArray | null}
|
|
1484
|
+
*/
|
|
1485
|
+
function matchPattern(pattern, pos, text, lookbehind) {
|
|
1486
|
+
pattern.lastIndex = pos;
|
|
1487
|
+
var match = pattern.exec(text);
|
|
1488
|
+
if (match && lookbehind && match[1]) {
|
|
1489
|
+
// change the match to remove the text matched by the Prism lookbehind group
|
|
1490
|
+
var lookbehindLength = match[1].length;
|
|
1491
|
+
match.index += lookbehindLength;
|
|
1492
|
+
match[0] = match[0].slice(lookbehindLength);
|
|
1493
|
+
}
|
|
1494
|
+
return match;
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
/**
|
|
1498
|
+
* @param {string} text
|
|
1499
|
+
* @param {LinkedList<string | Token>} tokenList
|
|
1500
|
+
* @param {any} grammar
|
|
1501
|
+
* @param {LinkedListNode<string | Token>} startNode
|
|
1502
|
+
* @param {number} startPos
|
|
1503
|
+
* @param {RematchOptions} [rematch]
|
|
1504
|
+
* @returns {void}
|
|
1505
|
+
* @private
|
|
1506
|
+
*
|
|
1507
|
+
* @typedef RematchOptions
|
|
1508
|
+
* @property {string} cause
|
|
1509
|
+
* @property {number} reach
|
|
1510
|
+
*/
|
|
1511
|
+
function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
|
1512
|
+
for (var token in grammar) {
|
|
1513
|
+
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
|
1514
|
+
continue;
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
var patterns = grammar[token];
|
|
1518
|
+
patterns = Array.isArray(patterns) ? patterns : [patterns];
|
|
1519
|
+
|
|
1520
|
+
for (var j = 0; j < patterns.length; ++j) {
|
|
1521
|
+
if (rematch && rematch.cause == token + ',' + j) {
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
var patternObj = patterns[j];
|
|
1526
|
+
var inside = patternObj.inside;
|
|
1527
|
+
var lookbehind = !!patternObj.lookbehind;
|
|
1528
|
+
var greedy = !!patternObj.greedy;
|
|
1529
|
+
var alias = patternObj.alias;
|
|
1530
|
+
|
|
1531
|
+
if (greedy && !patternObj.pattern.global) {
|
|
1532
|
+
// Without the global flag, lastIndex won't work
|
|
1533
|
+
var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
|
|
1534
|
+
patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
/** @type {RegExp} */
|
|
1538
|
+
var pattern = patternObj.pattern || patternObj;
|
|
1539
|
+
|
|
1540
|
+
for ( // iterate the token list and keep track of the current token/string position
|
|
1541
|
+
var currentNode = startNode.next, pos = startPos;
|
|
1542
|
+
currentNode !== tokenList.tail;
|
|
1543
|
+
pos += currentNode.value.length, currentNode = currentNode.next
|
|
1544
|
+
) {
|
|
1545
|
+
|
|
1546
|
+
if (rematch && pos >= rematch.reach) {
|
|
1547
|
+
break;
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
var str = currentNode.value;
|
|
1551
|
+
|
|
1552
|
+
if (tokenList.length > text.length) {
|
|
1553
|
+
// Something went terribly wrong, ABORT, ABORT!
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
if (str instanceof Token) {
|
|
1558
|
+
continue;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
var removeCount = 1; // this is the to parameter of removeBetween
|
|
1562
|
+
var match;
|
|
1563
|
+
|
|
1564
|
+
if (greedy) {
|
|
1565
|
+
match = matchPattern(pattern, pos, text, lookbehind);
|
|
1566
|
+
if (!match || match.index >= text.length) {
|
|
1567
|
+
break;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
var from = match.index;
|
|
1571
|
+
var to = match.index + match[0].length;
|
|
1572
|
+
var p = pos;
|
|
1573
|
+
|
|
1574
|
+
// find the node that contains the match
|
|
1575
|
+
p += currentNode.value.length;
|
|
1576
|
+
while (from >= p) {
|
|
1577
|
+
currentNode = currentNode.next;
|
|
1578
|
+
p += currentNode.value.length;
|
|
1579
|
+
}
|
|
1580
|
+
// adjust pos (and p)
|
|
1581
|
+
p -= currentNode.value.length;
|
|
1582
|
+
pos = p;
|
|
1583
|
+
|
|
1584
|
+
// the current node is a Token, then the match starts inside another Token, which is invalid
|
|
1585
|
+
if (currentNode.value instanceof Token) {
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
// find the last node which is affected by this match
|
|
1590
|
+
for (
|
|
1591
|
+
var k = currentNode;
|
|
1592
|
+
k !== tokenList.tail && (p < to || typeof k.value === 'string');
|
|
1593
|
+
k = k.next
|
|
1594
|
+
) {
|
|
1595
|
+
removeCount++;
|
|
1596
|
+
p += k.value.length;
|
|
1597
|
+
}
|
|
1598
|
+
removeCount--;
|
|
1599
|
+
|
|
1600
|
+
// replace with the new match
|
|
1601
|
+
str = text.slice(pos, p);
|
|
1602
|
+
match.index -= pos;
|
|
1603
|
+
} else {
|
|
1604
|
+
match = matchPattern(pattern, 0, str, lookbehind);
|
|
1605
|
+
if (!match) {
|
|
1606
|
+
continue;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
// eslint-disable-next-line no-redeclare
|
|
1611
|
+
var from = match.index;
|
|
1612
|
+
var matchStr = match[0];
|
|
1613
|
+
var before = str.slice(0, from);
|
|
1614
|
+
var after = str.slice(from + matchStr.length);
|
|
1615
|
+
|
|
1616
|
+
var reach = pos + str.length;
|
|
1617
|
+
if (rematch && reach > rematch.reach) {
|
|
1618
|
+
rematch.reach = reach;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
var removeFrom = currentNode.prev;
|
|
1622
|
+
|
|
1623
|
+
if (before) {
|
|
1624
|
+
removeFrom = addAfter(tokenList, removeFrom, before);
|
|
1625
|
+
pos += before.length;
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
removeRange(tokenList, removeFrom, removeCount);
|
|
1629
|
+
|
|
1630
|
+
var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
|
|
1631
|
+
currentNode = addAfter(tokenList, removeFrom, wrapped);
|
|
1632
|
+
|
|
1633
|
+
if (after) {
|
|
1634
|
+
addAfter(tokenList, currentNode, after);
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
if (removeCount > 1) {
|
|
1638
|
+
// at least one Token object was removed, so we have to do some rematching
|
|
1639
|
+
// this can only happen if the current pattern is greedy
|
|
1640
|
+
|
|
1641
|
+
/** @type {RematchOptions} */
|
|
1642
|
+
var nestedRematch = {
|
|
1643
|
+
cause: token + ',' + j,
|
|
1644
|
+
reach: reach
|
|
1645
|
+
};
|
|
1646
|
+
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
|
|
1647
|
+
|
|
1648
|
+
// the reach might have been extended because of the rematching
|
|
1649
|
+
if (rematch && nestedRematch.reach > rematch.reach) {
|
|
1650
|
+
rematch.reach = nestedRematch.reach;
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
/**
|
|
1659
|
+
* @typedef LinkedListNode
|
|
1660
|
+
* @property {T} value
|
|
1661
|
+
* @property {LinkedListNode<T> | null} prev The previous node.
|
|
1662
|
+
* @property {LinkedListNode<T> | null} next The next node.
|
|
1663
|
+
* @template T
|
|
1664
|
+
* @private
|
|
1665
|
+
*/
|
|
1666
|
+
|
|
1667
|
+
/**
|
|
1668
|
+
* @template T
|
|
1669
|
+
* @private
|
|
1670
|
+
*/
|
|
1671
|
+
function LinkedList() {
|
|
1672
|
+
/** @type {LinkedListNode<T>} */
|
|
1673
|
+
var head = { value: null, prev: null, next: null };
|
|
1674
|
+
/** @type {LinkedListNode<T>} */
|
|
1675
|
+
var tail = { value: null, prev: head, next: null };
|
|
1676
|
+
head.next = tail;
|
|
1677
|
+
|
|
1678
|
+
/** @type {LinkedListNode<T>} */
|
|
1679
|
+
this.head = head;
|
|
1680
|
+
/** @type {LinkedListNode<T>} */
|
|
1681
|
+
this.tail = tail;
|
|
1682
|
+
this.length = 0;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
/**
|
|
1686
|
+
* Adds a new node with the given value to the list.
|
|
1687
|
+
*
|
|
1688
|
+
* @param {LinkedList<T>} list
|
|
1689
|
+
* @param {LinkedListNode<T>} node
|
|
1690
|
+
* @param {T} value
|
|
1691
|
+
* @returns {LinkedListNode<T>} The added node.
|
|
1692
|
+
* @template T
|
|
1693
|
+
*/
|
|
1694
|
+
function addAfter(list, node, value) {
|
|
1695
|
+
// assumes that node != list.tail && values.length >= 0
|
|
1696
|
+
var next = node.next;
|
|
1697
|
+
|
|
1698
|
+
var newNode = { value: value, prev: node, next: next };
|
|
1699
|
+
node.next = newNode;
|
|
1700
|
+
next.prev = newNode;
|
|
1701
|
+
list.length++;
|
|
1702
|
+
|
|
1703
|
+
return newNode;
|
|
1704
|
+
}
|
|
1705
|
+
/**
|
|
1706
|
+
* Removes `count` nodes after the given node. The given node will not be removed.
|
|
1707
|
+
*
|
|
1708
|
+
* @param {LinkedList<T>} list
|
|
1709
|
+
* @param {LinkedListNode<T>} node
|
|
1710
|
+
* @param {number} count
|
|
1711
|
+
* @template T
|
|
1712
|
+
*/
|
|
1713
|
+
function removeRange(list, node, count) {
|
|
1714
|
+
var next = node.next;
|
|
1715
|
+
for (var i = 0; i < count && next !== list.tail; i++) {
|
|
1716
|
+
next = next.next;
|
|
1717
|
+
}
|
|
1718
|
+
node.next = next;
|
|
1719
|
+
next.prev = node;
|
|
1720
|
+
list.length -= i;
|
|
1721
|
+
}
|
|
1722
|
+
/**
|
|
1723
|
+
* @param {LinkedList<T>} list
|
|
1724
|
+
* @returns {T[]}
|
|
1725
|
+
* @template T
|
|
1726
|
+
*/
|
|
1727
|
+
function toArray(list) {
|
|
1728
|
+
var array = [];
|
|
1729
|
+
var node = list.head.next;
|
|
1730
|
+
while (node !== list.tail) {
|
|
1731
|
+
array.push(node.value);
|
|
1732
|
+
node = node.next;
|
|
1733
|
+
}
|
|
1734
|
+
return array;
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
|
|
1738
|
+
if (!_self.document) {
|
|
1739
|
+
if (!_self.addEventListener) {
|
|
1740
|
+
// in Node.js
|
|
1741
|
+
return _;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
if (!_.disableWorkerMessageHandler) {
|
|
1745
|
+
// In worker
|
|
1746
|
+
_self.addEventListener('message', function (evt) {
|
|
1747
|
+
var message = JSON.parse(evt.data);
|
|
1748
|
+
var lang = message.language;
|
|
1749
|
+
var code = message.code;
|
|
1750
|
+
var immediateClose = message.immediateClose;
|
|
1751
|
+
|
|
1752
|
+
_self.postMessage(_.highlight(code, _.languages[lang], lang));
|
|
1753
|
+
if (immediateClose) {
|
|
1754
|
+
_self.close();
|
|
1755
|
+
}
|
|
1756
|
+
}, false);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
return _;
|
|
1760
|
+
}
|
|
1761
|
+
|
|
1762
|
+
// Get current script and highlight
|
|
1763
|
+
var script = _.util.currentScript();
|
|
1764
|
+
|
|
1765
|
+
if (script) {
|
|
1766
|
+
_.filename = script.src;
|
|
1767
|
+
|
|
1768
|
+
if (script.hasAttribute('data-manual')) {
|
|
1769
|
+
_.manual = true;
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
function highlightAutomaticallyCallback() {
|
|
1774
|
+
if (!_.manual) {
|
|
1775
|
+
_.highlightAll();
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
if (!_.manual) {
|
|
1780
|
+
// If the document state is "loading", then we'll use DOMContentLoaded.
|
|
1781
|
+
// If the document state is "interactive" and the prism.js script is deferred, then we'll also use the
|
|
1782
|
+
// DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they
|
|
1783
|
+
// might take longer one animation frame to execute which can create a race condition where only some plugins have
|
|
1784
|
+
// been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded.
|
|
1785
|
+
// See https://github.com/PrismJS/prism/issues/2102
|
|
1786
|
+
var readyState = document.readyState;
|
|
1787
|
+
if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
|
|
1788
|
+
document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
|
|
1789
|
+
} else {
|
|
1790
|
+
if (window.requestAnimationFrame) {
|
|
1791
|
+
window.requestAnimationFrame(highlightAutomaticallyCallback);
|
|
1792
|
+
} else {
|
|
1793
|
+
window.setTimeout(highlightAutomaticallyCallback, 16);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
return _;
|
|
1799
|
+
|
|
1800
|
+
}(_self));
|
|
1801
|
+
|
|
1802
|
+
if (module.exports) {
|
|
1803
|
+
module.exports = Prism;
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
// hack for components to work correctly in node.js
|
|
1807
|
+
if (typeof commonjsGlobal !== 'undefined') {
|
|
1808
|
+
commonjsGlobal.Prism = Prism;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// some additional documentation/types
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* The expansion of a simple `RegExp` literal to support additional properties.
|
|
1815
|
+
*
|
|
1816
|
+
* @typedef GrammarToken
|
|
1817
|
+
* @property {RegExp} pattern The regular expression of the token.
|
|
1818
|
+
* @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively)
|
|
1819
|
+
* behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token.
|
|
1820
|
+
* @property {boolean} [greedy=false] Whether the token is greedy.
|
|
1821
|
+
* @property {string|string[]} [alias] An optional alias or list of aliases.
|
|
1822
|
+
* @property {Grammar} [inside] The nested grammar of this token.
|
|
1823
|
+
*
|
|
1824
|
+
* The `inside` grammar will be used to tokenize the text value of each token of this kind.
|
|
1825
|
+
*
|
|
1826
|
+
* This can be used to make nested and even recursive language definitions.
|
|
1827
|
+
*
|
|
1828
|
+
* Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into
|
|
1829
|
+
* each another.
|
|
1830
|
+
* @global
|
|
1831
|
+
* @public
|
|
1832
|
+
*/
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
* @typedef Grammar
|
|
1836
|
+
* @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>}
|
|
1837
|
+
* @property {Grammar} [rest] An optional grammar object that will be appended to this grammar.
|
|
1838
|
+
* @global
|
|
1839
|
+
* @public
|
|
1840
|
+
*/
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* A function which will invoked after an element was successfully highlighted.
|
|
1844
|
+
*
|
|
1845
|
+
* @callback HighlightCallback
|
|
1846
|
+
* @param {Element} element The element successfully highlighted.
|
|
1847
|
+
* @returns {void}
|
|
1848
|
+
* @global
|
|
1849
|
+
* @public
|
|
1850
|
+
*/
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* @callback HookCallback
|
|
1854
|
+
* @param {Object<string, any>} env The environment variables of the hook.
|
|
1855
|
+
* @returns {void}
|
|
1856
|
+
* @global
|
|
1857
|
+
* @public
|
|
1858
|
+
*/
|
|
1859
|
+
|
|
1860
|
+
|
|
1861
|
+
/* **********************************************
|
|
1862
|
+
Begin prism-markup.js
|
|
1863
|
+
********************************************** */
|
|
1864
|
+
|
|
1865
|
+
Prism.languages.markup = {
|
|
1866
|
+
'comment': {
|
|
1867
|
+
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
1868
|
+
greedy: true
|
|
1869
|
+
},
|
|
1870
|
+
'prolog': {
|
|
1871
|
+
pattern: /<\?[\s\S]+?\?>/,
|
|
1872
|
+
greedy: true
|
|
1873
|
+
},
|
|
1874
|
+
'doctype': {
|
|
1875
|
+
// https://www.w3.org/TR/xml/#NT-doctypedecl
|
|
1876
|
+
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
1877
|
+
greedy: true,
|
|
1878
|
+
inside: {
|
|
1879
|
+
'internal-subset': {
|
|
1880
|
+
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
1881
|
+
lookbehind: true,
|
|
1882
|
+
greedy: true,
|
|
1883
|
+
inside: null // see below
|
|
1884
|
+
},
|
|
1885
|
+
'string': {
|
|
1886
|
+
pattern: /"[^"]*"|'[^']*'/,
|
|
1887
|
+
greedy: true
|
|
1888
|
+
},
|
|
1889
|
+
'punctuation': /^<!|>$|[[\]]/,
|
|
1890
|
+
'doctype-tag': /^DOCTYPE/i,
|
|
1891
|
+
'name': /[^\s<>'"]+/
|
|
1892
|
+
}
|
|
1893
|
+
},
|
|
1894
|
+
'cdata': {
|
|
1895
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1896
|
+
greedy: true
|
|
1897
|
+
},
|
|
1898
|
+
'tag': {
|
|
1899
|
+
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
1900
|
+
greedy: true,
|
|
1901
|
+
inside: {
|
|
1902
|
+
'tag': {
|
|
1903
|
+
pattern: /^<\/?[^\s>\/]+/,
|
|
1904
|
+
inside: {
|
|
1905
|
+
'punctuation': /^<\/?/,
|
|
1906
|
+
'namespace': /^[^\s>\/:]+:/
|
|
1907
|
+
}
|
|
1908
|
+
},
|
|
1909
|
+
'special-attr': [],
|
|
1910
|
+
'attr-value': {
|
|
1911
|
+
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
1912
|
+
inside: {
|
|
1913
|
+
'punctuation': [
|
|
1914
|
+
{
|
|
1915
|
+
pattern: /^=/,
|
|
1916
|
+
alias: 'attr-equals'
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
pattern: /^(\s*)["']|["']$/,
|
|
1920
|
+
lookbehind: true
|
|
1921
|
+
}
|
|
1922
|
+
]
|
|
1923
|
+
}
|
|
1924
|
+
},
|
|
1925
|
+
'punctuation': /\/?>/,
|
|
1926
|
+
'attr-name': {
|
|
1927
|
+
pattern: /[^\s>\/]+/,
|
|
1928
|
+
inside: {
|
|
1929
|
+
'namespace': /^[^\s>\/:]+:/
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
}
|
|
1934
|
+
},
|
|
1935
|
+
'entity': [
|
|
1936
|
+
{
|
|
1937
|
+
pattern: /&[\da-z]{1,8};/i,
|
|
1938
|
+
alias: 'named-entity'
|
|
1939
|
+
},
|
|
1940
|
+
/&#x?[\da-f]{1,8};/i
|
|
1941
|
+
]
|
|
1942
|
+
};
|
|
1943
|
+
|
|
1944
|
+
Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] =
|
|
1945
|
+
Prism.languages.markup['entity'];
|
|
1946
|
+
Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
|
|
1947
|
+
|
|
1948
|
+
// Plugin to make entity title show the real entity, idea by Roman Komarov
|
|
1949
|
+
Prism.hooks.add('wrap', function (env) {
|
|
1950
|
+
|
|
1951
|
+
if (env.type === 'entity') {
|
|
1952
|
+
env.attributes['title'] = env.content.replace(/&/, '&');
|
|
1953
|
+
}
|
|
1954
|
+
});
|
|
1955
|
+
|
|
1956
|
+
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
|
|
1957
|
+
/**
|
|
1958
|
+
* Adds an inlined language to markup.
|
|
1959
|
+
*
|
|
1960
|
+
* An example of an inlined language is CSS with `<style>` tags.
|
|
1961
|
+
*
|
|
1962
|
+
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
|
|
1963
|
+
* case insensitive.
|
|
1964
|
+
* @param {string} lang The language key.
|
|
1965
|
+
* @example
|
|
1966
|
+
* addInlined('style', 'css');
|
|
1967
|
+
*/
|
|
1968
|
+
value: function addInlined(tagName, lang) {
|
|
1969
|
+
var includedCdataInside = {};
|
|
1970
|
+
includedCdataInside['language-' + lang] = {
|
|
1971
|
+
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
1972
|
+
lookbehind: true,
|
|
1973
|
+
inside: Prism.languages[lang]
|
|
1974
|
+
};
|
|
1975
|
+
includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
|
|
1976
|
+
|
|
1977
|
+
var inside = {
|
|
1978
|
+
'included-cdata': {
|
|
1979
|
+
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
1980
|
+
inside: includedCdataInside
|
|
1981
|
+
}
|
|
1982
|
+
};
|
|
1983
|
+
inside['language-' + lang] = {
|
|
1984
|
+
pattern: /[\s\S]+/,
|
|
1985
|
+
inside: Prism.languages[lang]
|
|
1986
|
+
};
|
|
1987
|
+
|
|
1988
|
+
var def = {};
|
|
1989
|
+
def[tagName] = {
|
|
1990
|
+
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'),
|
|
1991
|
+
lookbehind: true,
|
|
1992
|
+
greedy: true,
|
|
1993
|
+
inside: inside
|
|
1994
|
+
};
|
|
1995
|
+
|
|
1996
|
+
Prism.languages.insertBefore('markup', 'cdata', def);
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1999
|
+
Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
|
|
2000
|
+
/**
|
|
2001
|
+
* Adds an pattern to highlight languages embedded in HTML attributes.
|
|
2002
|
+
*
|
|
2003
|
+
* An example of an inlined language is CSS with `style` attributes.
|
|
2004
|
+
*
|
|
2005
|
+
* @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
|
|
2006
|
+
* case insensitive.
|
|
2007
|
+
* @param {string} lang The language key.
|
|
2008
|
+
* @example
|
|
2009
|
+
* addAttribute('style', 'css');
|
|
2010
|
+
*/
|
|
2011
|
+
value: function (attrName, lang) {
|
|
2012
|
+
Prism.languages.markup.tag.inside['special-attr'].push({
|
|
2013
|
+
pattern: RegExp(
|
|
2014
|
+
/(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
|
|
2015
|
+
'i'
|
|
2016
|
+
),
|
|
2017
|
+
lookbehind: true,
|
|
2018
|
+
inside: {
|
|
2019
|
+
'attr-name': /^[^\s=]+/,
|
|
2020
|
+
'attr-value': {
|
|
2021
|
+
pattern: /=[\s\S]+/,
|
|
2022
|
+
inside: {
|
|
2023
|
+
'value': {
|
|
2024
|
+
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
2025
|
+
lookbehind: true,
|
|
2026
|
+
alias: [lang, 'language-' + lang],
|
|
2027
|
+
inside: Prism.languages[lang]
|
|
2028
|
+
},
|
|
2029
|
+
'punctuation': [
|
|
2030
|
+
{
|
|
2031
|
+
pattern: /^=/,
|
|
2032
|
+
alias: 'attr-equals'
|
|
2033
|
+
},
|
|
2034
|
+
/"|'/
|
|
2035
|
+
]
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
});
|
|
2042
|
+
|
|
2043
|
+
Prism.languages.html = Prism.languages.markup;
|
|
2044
|
+
Prism.languages.mathml = Prism.languages.markup;
|
|
2045
|
+
Prism.languages.svg = Prism.languages.markup;
|
|
2046
|
+
|
|
2047
|
+
Prism.languages.xml = Prism.languages.extend('markup', {});
|
|
2048
|
+
Prism.languages.ssml = Prism.languages.xml;
|
|
2049
|
+
Prism.languages.atom = Prism.languages.xml;
|
|
2050
|
+
Prism.languages.rss = Prism.languages.xml;
|
|
2051
|
+
|
|
2052
|
+
|
|
2053
|
+
/* **********************************************
|
|
2054
|
+
Begin prism-css.js
|
|
2055
|
+
********************************************** */
|
|
2056
|
+
|
|
2057
|
+
(function (Prism) {
|
|
2058
|
+
|
|
2059
|
+
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
2060
|
+
|
|
2061
|
+
Prism.languages.css = {
|
|
2062
|
+
'comment': /\/\*[\s\S]*?\*\//,
|
|
2063
|
+
'atrule': {
|
|
2064
|
+
pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
|
|
2065
|
+
inside: {
|
|
2066
|
+
'rule': /^@[\w-]+/,
|
|
2067
|
+
'selector-function-argument': {
|
|
2068
|
+
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
2069
|
+
lookbehind: true,
|
|
2070
|
+
alias: 'selector'
|
|
2071
|
+
},
|
|
2072
|
+
'keyword': {
|
|
2073
|
+
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
2074
|
+
lookbehind: true
|
|
2075
|
+
}
|
|
2076
|
+
// See rest below
|
|
2077
|
+
}
|
|
2078
|
+
},
|
|
2079
|
+
'url': {
|
|
2080
|
+
// https://drafts.csswg.org/css-values-3/#urls
|
|
2081
|
+
pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
|
2082
|
+
greedy: true,
|
|
2083
|
+
inside: {
|
|
2084
|
+
'function': /^url/i,
|
|
2085
|
+
'punctuation': /^\(|\)$/,
|
|
2086
|
+
'string': {
|
|
2087
|
+
pattern: RegExp('^' + string.source + '$'),
|
|
2088
|
+
alias: 'url'
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
},
|
|
2092
|
+
'selector': {
|
|
2093
|
+
pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
|
|
2094
|
+
lookbehind: true
|
|
2095
|
+
},
|
|
2096
|
+
'string': {
|
|
2097
|
+
pattern: string,
|
|
2098
|
+
greedy: true
|
|
2099
|
+
},
|
|
2100
|
+
'property': {
|
|
2101
|
+
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
2102
|
+
lookbehind: true
|
|
2103
|
+
},
|
|
2104
|
+
'important': /!important\b/i,
|
|
2105
|
+
'function': {
|
|
2106
|
+
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
2107
|
+
lookbehind: true
|
|
2108
|
+
},
|
|
2109
|
+
'punctuation': /[(){};:,]/
|
|
2110
|
+
};
|
|
2111
|
+
|
|
2112
|
+
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
|
2113
|
+
|
|
2114
|
+
var markup = Prism.languages.markup;
|
|
2115
|
+
if (markup) {
|
|
2116
|
+
markup.tag.addInlined('style', 'css');
|
|
2117
|
+
markup.tag.addAttribute('style', 'css');
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
}(Prism));
|
|
2121
|
+
|
|
2122
|
+
|
|
2123
|
+
/* **********************************************
|
|
2124
|
+
Begin prism-clike.js
|
|
2125
|
+
********************************************** */
|
|
2126
|
+
|
|
2127
|
+
Prism.languages.clike = {
|
|
2128
|
+
'comment': [
|
|
2129
|
+
{
|
|
2130
|
+
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
2131
|
+
lookbehind: true,
|
|
2132
|
+
greedy: true
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
pattern: /(^|[^\\:])\/\/.*/,
|
|
2136
|
+
lookbehind: true,
|
|
2137
|
+
greedy: true
|
|
2138
|
+
}
|
|
2139
|
+
],
|
|
2140
|
+
'string': {
|
|
2141
|
+
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
2142
|
+
greedy: true
|
|
2143
|
+
},
|
|
2144
|
+
'class-name': {
|
|
2145
|
+
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
2146
|
+
lookbehind: true,
|
|
2147
|
+
inside: {
|
|
2148
|
+
'punctuation': /[.\\]/
|
|
2149
|
+
}
|
|
2150
|
+
},
|
|
2151
|
+
'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
2152
|
+
'boolean': /\b(?:false|true)\b/,
|
|
2153
|
+
'function': /\b\w+(?=\()/,
|
|
2154
|
+
'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
2155
|
+
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
2156
|
+
'punctuation': /[{}[\];(),.:]/
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2159
|
+
|
|
2160
|
+
/* **********************************************
|
|
2161
|
+
Begin prism-javascript.js
|
|
2162
|
+
********************************************** */
|
|
2163
|
+
|
|
2164
|
+
Prism.languages.javascript = Prism.languages.extend('clike', {
|
|
2165
|
+
'class-name': [
|
|
2166
|
+
Prism.languages.clike['class-name'],
|
|
2167
|
+
{
|
|
2168
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
2169
|
+
lookbehind: true
|
|
2170
|
+
}
|
|
2171
|
+
],
|
|
2172
|
+
'keyword': [
|
|
2173
|
+
{
|
|
2174
|
+
pattern: /((?:^|\})\s*)catch\b/,
|
|
2175
|
+
lookbehind: true
|
|
2176
|
+
},
|
|
2177
|
+
{
|
|
2178
|
+
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
|
2179
|
+
lookbehind: true
|
|
2180
|
+
},
|
|
2181
|
+
],
|
|
2182
|
+
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
|
|
2183
|
+
'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
2184
|
+
'number': {
|
|
2185
|
+
pattern: RegExp(
|
|
2186
|
+
/(^|[^\w$])/.source +
|
|
2187
|
+
'(?:' +
|
|
2188
|
+
(
|
|
2189
|
+
// constant
|
|
2190
|
+
/NaN|Infinity/.source +
|
|
2191
|
+
'|' +
|
|
2192
|
+
// binary integer
|
|
2193
|
+
/0[bB][01]+(?:_[01]+)*n?/.source +
|
|
2194
|
+
'|' +
|
|
2195
|
+
// octal integer
|
|
2196
|
+
/0[oO][0-7]+(?:_[0-7]+)*n?/.source +
|
|
2197
|
+
'|' +
|
|
2198
|
+
// hexadecimal integer
|
|
2199
|
+
/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source +
|
|
2200
|
+
'|' +
|
|
2201
|
+
// decimal bigint
|
|
2202
|
+
/\d+(?:_\d+)*n/.source +
|
|
2203
|
+
'|' +
|
|
2204
|
+
// decimal number (integer or float) but no bigint
|
|
2205
|
+
/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source
|
|
2206
|
+
) +
|
|
2207
|
+
')' +
|
|
2208
|
+
/(?![\w$])/.source
|
|
2209
|
+
),
|
|
2210
|
+
lookbehind: true
|
|
2211
|
+
},
|
|
2212
|
+
'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
2213
|
+
});
|
|
2214
|
+
|
|
2215
|
+
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
2216
|
+
|
|
2217
|
+
Prism.languages.insertBefore('javascript', 'keyword', {
|
|
2218
|
+
'regex': {
|
|
2219
|
+
pattern: RegExp(
|
|
2220
|
+
// lookbehind
|
|
2221
|
+
// eslint-disable-next-line regexp/no-dupe-characters-character-class
|
|
2222
|
+
/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
|
|
2223
|
+
// Regex pattern:
|
|
2224
|
+
// There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
|
|
2225
|
+
// classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
|
|
2226
|
+
// with the only syntax, so we have to define 2 different regex patterns.
|
|
2227
|
+
/\//.source +
|
|
2228
|
+
'(?:' +
|
|
2229
|
+
/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source +
|
|
2230
|
+
'|' +
|
|
2231
|
+
// `v` flag syntax. This supports 3 levels of nested character classes.
|
|
2232
|
+
/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source +
|
|
2233
|
+
')' +
|
|
2234
|
+
// lookahead
|
|
2235
|
+
/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
|
|
2236
|
+
),
|
|
2237
|
+
lookbehind: true,
|
|
2238
|
+
greedy: true,
|
|
2239
|
+
inside: {
|
|
2240
|
+
'regex-source': {
|
|
2241
|
+
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
2242
|
+
lookbehind: true,
|
|
2243
|
+
alias: 'language-regex',
|
|
2244
|
+
inside: Prism.languages.regex
|
|
2245
|
+
},
|
|
2246
|
+
'regex-delimiter': /^\/|\/$/,
|
|
2247
|
+
'regex-flags': /^[a-z]+$/,
|
|
2248
|
+
}
|
|
2249
|
+
},
|
|
2250
|
+
// This must be declared before keyword because we use "function" inside the look-forward
|
|
2251
|
+
'function-variable': {
|
|
2252
|
+
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
2253
|
+
alias: 'function'
|
|
2254
|
+
},
|
|
2255
|
+
'parameter': [
|
|
2256
|
+
{
|
|
2257
|
+
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
2258
|
+
lookbehind: true,
|
|
2259
|
+
inside: Prism.languages.javascript
|
|
2260
|
+
},
|
|
2261
|
+
{
|
|
2262
|
+
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
2263
|
+
lookbehind: true,
|
|
2264
|
+
inside: Prism.languages.javascript
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
2268
|
+
lookbehind: true,
|
|
2269
|
+
inside: Prism.languages.javascript
|
|
2270
|
+
},
|
|
2271
|
+
{
|
|
2272
|
+
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
2273
|
+
lookbehind: true,
|
|
2274
|
+
inside: Prism.languages.javascript
|
|
2275
|
+
}
|
|
2276
|
+
],
|
|
2277
|
+
'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
2278
|
+
});
|
|
2279
|
+
|
|
2280
|
+
Prism.languages.insertBefore('javascript', 'string', {
|
|
2281
|
+
'hashbang': {
|
|
2282
|
+
pattern: /^#!.*/,
|
|
2283
|
+
greedy: true,
|
|
2284
|
+
alias: 'comment'
|
|
2285
|
+
},
|
|
2286
|
+
'template-string': {
|
|
2287
|
+
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
2288
|
+
greedy: true,
|
|
2289
|
+
inside: {
|
|
2290
|
+
'template-punctuation': {
|
|
2291
|
+
pattern: /^`|`$/,
|
|
2292
|
+
alias: 'string'
|
|
2293
|
+
},
|
|
2294
|
+
'interpolation': {
|
|
2295
|
+
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
2296
|
+
lookbehind: true,
|
|
2297
|
+
inside: {
|
|
2298
|
+
'interpolation-punctuation': {
|
|
2299
|
+
pattern: /^\$\{|\}$/,
|
|
2300
|
+
alias: 'punctuation'
|
|
2301
|
+
},
|
|
2302
|
+
rest: Prism.languages.javascript
|
|
2303
|
+
}
|
|
2304
|
+
},
|
|
2305
|
+
'string': /[\s\S]+/
|
|
2306
|
+
}
|
|
2307
|
+
},
|
|
2308
|
+
'string-property': {
|
|
2309
|
+
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
2310
|
+
lookbehind: true,
|
|
2311
|
+
greedy: true,
|
|
2312
|
+
alias: 'property'
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
|
|
2316
|
+
Prism.languages.insertBefore('javascript', 'operator', {
|
|
2317
|
+
'literal-property': {
|
|
2318
|
+
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
2319
|
+
lookbehind: true,
|
|
2320
|
+
alias: 'property'
|
|
2321
|
+
},
|
|
2322
|
+
});
|
|
2323
|
+
|
|
2324
|
+
if (Prism.languages.markup) {
|
|
2325
|
+
Prism.languages.markup.tag.addInlined('script', 'javascript');
|
|
2326
|
+
|
|
2327
|
+
// add attribute support for all DOM events.
|
|
2328
|
+
// https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events
|
|
2329
|
+
Prism.languages.markup.tag.addAttribute(
|
|
2330
|
+
/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
|
|
2331
|
+
'javascript'
|
|
2332
|
+
);
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
Prism.languages.js = Prism.languages.javascript;
|
|
2336
|
+
|
|
2337
|
+
|
|
2338
|
+
/* **********************************************
|
|
2339
|
+
Begin prism-file-highlight.js
|
|
2340
|
+
********************************************** */
|
|
2341
|
+
|
|
2342
|
+
(function () {
|
|
2343
|
+
|
|
2344
|
+
if (typeof Prism === 'undefined' || typeof document === 'undefined') {
|
|
2345
|
+
return;
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
|
|
2349
|
+
if (!Element.prototype.matches) {
|
|
2350
|
+
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
var LOADING_MESSAGE = 'Loading…';
|
|
2354
|
+
var FAILURE_MESSAGE = function (status, message) {
|
|
2355
|
+
return '✖ Error ' + status + ' while fetching file: ' + message;
|
|
2356
|
+
};
|
|
2357
|
+
var FAILURE_EMPTY_MESSAGE = '✖ Error: File does not exist or is empty';
|
|
2358
|
+
|
|
2359
|
+
var EXTENSIONS = {
|
|
2360
|
+
'js': 'javascript',
|
|
2361
|
+
'py': 'python',
|
|
2362
|
+
'rb': 'ruby',
|
|
2363
|
+
'ps1': 'powershell',
|
|
2364
|
+
'psm1': 'powershell',
|
|
2365
|
+
'sh': 'bash',
|
|
2366
|
+
'bat': 'batch',
|
|
2367
|
+
'h': 'c',
|
|
2368
|
+
'tex': 'latex'
|
|
2369
|
+
};
|
|
2370
|
+
|
|
2371
|
+
var STATUS_ATTR = 'data-src-status';
|
|
2372
|
+
var STATUS_LOADING = 'loading';
|
|
2373
|
+
var STATUS_LOADED = 'loaded';
|
|
2374
|
+
var STATUS_FAILED = 'failed';
|
|
2375
|
+
|
|
2376
|
+
var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])'
|
|
2377
|
+
+ ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
|
|
2378
|
+
|
|
2379
|
+
/**
|
|
2380
|
+
* Loads the given file.
|
|
2381
|
+
*
|
|
2382
|
+
* @param {string} src The URL or path of the source file to load.
|
|
2383
|
+
* @param {(result: string) => void} success
|
|
2384
|
+
* @param {(reason: string) => void} error
|
|
2385
|
+
*/
|
|
2386
|
+
function loadFile(src, success, error) {
|
|
2387
|
+
var xhr = new XMLHttpRequest();
|
|
2388
|
+
xhr.open('GET', src, true);
|
|
2389
|
+
xhr.onreadystatechange = function () {
|
|
2390
|
+
if (xhr.readyState == 4) {
|
|
2391
|
+
if (xhr.status < 400 && xhr.responseText) {
|
|
2392
|
+
success(xhr.responseText);
|
|
2393
|
+
} else {
|
|
2394
|
+
if (xhr.status >= 400) {
|
|
2395
|
+
error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
|
|
2396
|
+
} else {
|
|
2397
|
+
error(FAILURE_EMPTY_MESSAGE);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
}
|
|
2401
|
+
};
|
|
2402
|
+
xhr.send(null);
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
/**
|
|
2406
|
+
* Parses the given range.
|
|
2407
|
+
*
|
|
2408
|
+
* This returns a range with inclusive ends.
|
|
2409
|
+
*
|
|
2410
|
+
* @param {string | null | undefined} range
|
|
2411
|
+
* @returns {[number, number | undefined] | undefined}
|
|
2412
|
+
*/
|
|
2413
|
+
function parseRange(range) {
|
|
2414
|
+
var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || '');
|
|
2415
|
+
if (m) {
|
|
2416
|
+
var start = Number(m[1]);
|
|
2417
|
+
var comma = m[2];
|
|
2418
|
+
var end = m[3];
|
|
2419
|
+
|
|
2420
|
+
if (!comma) {
|
|
2421
|
+
return [start, start];
|
|
2422
|
+
}
|
|
2423
|
+
if (!end) {
|
|
2424
|
+
return [start, undefined];
|
|
2425
|
+
}
|
|
2426
|
+
return [start, Number(end)];
|
|
2427
|
+
}
|
|
2428
|
+
return undefined;
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
Prism.hooks.add('before-highlightall', function (env) {
|
|
2432
|
+
env.selector += ', ' + SELECTOR;
|
|
2433
|
+
});
|
|
2434
|
+
|
|
2435
|
+
Prism.hooks.add('before-sanity-check', function (env) {
|
|
2436
|
+
var pre = /** @type {HTMLPreElement} */ (env.element);
|
|
2437
|
+
if (pre.matches(SELECTOR)) {
|
|
2438
|
+
env.code = ''; // fast-path the whole thing and go to complete
|
|
2439
|
+
|
|
2440
|
+
pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading
|
|
2441
|
+
|
|
2442
|
+
// add code element with loading message
|
|
2443
|
+
var code = pre.appendChild(document.createElement('CODE'));
|
|
2444
|
+
code.textContent = LOADING_MESSAGE;
|
|
2445
|
+
|
|
2446
|
+
var src = pre.getAttribute('data-src');
|
|
2447
|
+
|
|
2448
|
+
var language = env.language;
|
|
2449
|
+
if (language === 'none') {
|
|
2450
|
+
// the language might be 'none' because there is no language set;
|
|
2451
|
+
// in this case, we want to use the extension as the language
|
|
2452
|
+
var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1];
|
|
2453
|
+
language = EXTENSIONS[extension] || extension;
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
// set language classes
|
|
2457
|
+
Prism.util.setLanguage(code, language);
|
|
2458
|
+
Prism.util.setLanguage(pre, language);
|
|
2459
|
+
|
|
2460
|
+
// preload the language
|
|
2461
|
+
var autoloader = Prism.plugins.autoloader;
|
|
2462
|
+
if (autoloader) {
|
|
2463
|
+
autoloader.loadLanguages(language);
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
// load file
|
|
2467
|
+
loadFile(
|
|
2468
|
+
src,
|
|
2469
|
+
function (text) {
|
|
2470
|
+
// mark as loaded
|
|
2471
|
+
pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
|
|
2472
|
+
|
|
2473
|
+
// handle data-range
|
|
2474
|
+
var range = parseRange(pre.getAttribute('data-range'));
|
|
2475
|
+
if (range) {
|
|
2476
|
+
var lines = text.split(/\r\n?|\n/g);
|
|
2477
|
+
|
|
2478
|
+
// the range is one-based and inclusive on both ends
|
|
2479
|
+
var start = range[0];
|
|
2480
|
+
var end = range[1] == null ? lines.length : range[1];
|
|
2481
|
+
|
|
2482
|
+
if (start < 0) { start += lines.length; }
|
|
2483
|
+
start = Math.max(0, Math.min(start - 1, lines.length));
|
|
2484
|
+
if (end < 0) { end += lines.length; }
|
|
2485
|
+
end = Math.max(0, Math.min(end, lines.length));
|
|
2486
|
+
|
|
2487
|
+
text = lines.slice(start, end).join('\n');
|
|
2488
|
+
|
|
2489
|
+
// add data-start for line numbers
|
|
2490
|
+
if (!pre.hasAttribute('data-start')) {
|
|
2491
|
+
pre.setAttribute('data-start', String(start + 1));
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
// highlight code
|
|
2496
|
+
code.textContent = text;
|
|
2497
|
+
Prism.highlightElement(code);
|
|
2498
|
+
},
|
|
2499
|
+
function (error) {
|
|
2500
|
+
// mark as failed
|
|
2501
|
+
pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
|
|
2502
|
+
|
|
2503
|
+
code.textContent = error;
|
|
2504
|
+
}
|
|
2505
|
+
);
|
|
2506
|
+
}
|
|
2507
|
+
});
|
|
2508
|
+
|
|
2509
|
+
Prism.plugins.fileHighlight = {
|
|
2510
|
+
/**
|
|
2511
|
+
* Executes the File Highlight plugin for all matching `pre` elements under the given container.
|
|
2512
|
+
*
|
|
2513
|
+
* Note: Elements which are already loaded or currently loading will not be touched by this method.
|
|
2514
|
+
*
|
|
2515
|
+
* @param {ParentNode} [container=document]
|
|
2516
|
+
*/
|
|
2517
|
+
highlight: function highlight(container) {
|
|
2518
|
+
var elements = (container || document).querySelectorAll(SELECTOR);
|
|
2519
|
+
|
|
2520
|
+
for (var i = 0, element; (element = elements[i++]);) {
|
|
2521
|
+
Prism.highlightElement(element);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
|
|
2526
|
+
var logged = false;
|
|
2527
|
+
/** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */
|
|
2528
|
+
Prism.fileHighlight = function () {
|
|
2529
|
+
if (!logged) {
|
|
2530
|
+
console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.');
|
|
2531
|
+
logged = true;
|
|
2532
|
+
}
|
|
2533
|
+
Prism.plugins.fileHighlight.highlight.apply(this, arguments);
|
|
2534
|
+
};
|
|
2535
|
+
|
|
2536
|
+
}());
|
|
2537
|
+
}(prism));
|
|
2538
|
+
|
|
2539
|
+
const Prism$1 = prism.exports;
|
|
2540
|
+
|
|
2541
|
+
Prism.languages.python = {
|
|
2542
|
+
'comment': {
|
|
2543
|
+
pattern: /(^|[^\\])#.*/,
|
|
2544
|
+
lookbehind: true,
|
|
2545
|
+
greedy: true
|
|
2546
|
+
},
|
|
2547
|
+
'string-interpolation': {
|
|
2548
|
+
pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
|
2549
|
+
greedy: true,
|
|
2550
|
+
inside: {
|
|
2551
|
+
'interpolation': {
|
|
2552
|
+
// "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
|
|
2553
|
+
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
2554
|
+
lookbehind: true,
|
|
2555
|
+
inside: {
|
|
2556
|
+
'format-spec': {
|
|
2557
|
+
pattern: /(:)[^:(){}]+(?=\}$)/,
|
|
2558
|
+
lookbehind: true
|
|
2559
|
+
},
|
|
2560
|
+
'conversion-option': {
|
|
2561
|
+
pattern: //,
|
|
2562
|
+
alias: 'punctuation'
|
|
2563
|
+
},
|
|
2564
|
+
rest: null
|
|
2565
|
+
}
|
|
2566
|
+
},
|
|
2567
|
+
'string': /[\s\S]+/
|
|
2568
|
+
}
|
|
2569
|
+
},
|
|
2570
|
+
'triple-quoted-string': {
|
|
2571
|
+
pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
|
2572
|
+
greedy: true,
|
|
2573
|
+
alias: 'string'
|
|
2574
|
+
},
|
|
2575
|
+
'string': {
|
|
2576
|
+
pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
|
2577
|
+
greedy: true
|
|
2578
|
+
},
|
|
2579
|
+
'function': {
|
|
2580
|
+
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
|
2581
|
+
lookbehind: true
|
|
2582
|
+
},
|
|
2583
|
+
'class-name': {
|
|
2584
|
+
pattern: /(\bclass\s+)\w+/i,
|
|
2585
|
+
lookbehind: true
|
|
2586
|
+
},
|
|
2587
|
+
'decorator': {
|
|
2588
|
+
pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
|
2589
|
+
lookbehind: true,
|
|
2590
|
+
alias: ['annotation', 'punctuation'],
|
|
2591
|
+
inside: {
|
|
2592
|
+
'punctuation': /\./
|
|
2593
|
+
}
|
|
2594
|
+
},
|
|
2595
|
+
'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
|
2596
|
+
'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
|
2597
|
+
'boolean': /\b(?:False|None|True)\b/,
|
|
2598
|
+
'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
2599
|
+
'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
2600
|
+
'punctuation': /[{}[\];(),.:]/
|
|
2601
|
+
};
|
|
2602
|
+
|
|
2603
|
+
Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
|
|
2604
|
+
|
|
2605
|
+
Prism.languages.py = Prism.languages.python;
|
|
2606
|
+
|
|
2607
|
+
(function (Prism) {
|
|
2608
|
+
// $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|'
|
|
2609
|
+
// + LC_ALL, RANDOM, REPLY, SECONDS.
|
|
2610
|
+
// + make sure PS1..4 are here as they are not always set,
|
|
2611
|
+
// - some useless things.
|
|
2612
|
+
var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b';
|
|
2613
|
+
|
|
2614
|
+
var commandAfterHeredoc = {
|
|
2615
|
+
pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
|
|
2616
|
+
lookbehind: true,
|
|
2617
|
+
alias: 'punctuation', // this looks reasonably well in all themes
|
|
2618
|
+
inside: null // see below
|
|
2619
|
+
};
|
|
2620
|
+
|
|
2621
|
+
var insideString = {
|
|
2622
|
+
'bash': commandAfterHeredoc,
|
|
2623
|
+
'environment': {
|
|
2624
|
+
pattern: RegExp('\\$' + envVars),
|
|
2625
|
+
alias: 'constant'
|
|
2626
|
+
},
|
|
2627
|
+
'variable': [
|
|
2628
|
+
// [0]: Arithmetic Environment
|
|
2629
|
+
{
|
|
2630
|
+
pattern: /\$?\(\([\s\S]+?\)\)/,
|
|
2631
|
+
greedy: true,
|
|
2632
|
+
inside: {
|
|
2633
|
+
// If there is a $ sign at the beginning highlight $(( and )) as variable
|
|
2634
|
+
'variable': [
|
|
2635
|
+
{
|
|
2636
|
+
pattern: /(^\$\(\([\s\S]+)\)\)/,
|
|
2637
|
+
lookbehind: true
|
|
2638
|
+
},
|
|
2639
|
+
/^\$\(\(/
|
|
2640
|
+
],
|
|
2641
|
+
'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
|
|
2642
|
+
// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
|
|
2643
|
+
'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
|
|
2644
|
+
// If there is no $ sign at the beginning highlight (( and )) as punctuation
|
|
2645
|
+
'punctuation': /\(\(?|\)\)?|,|;/
|
|
2646
|
+
}
|
|
2647
|
+
},
|
|
2648
|
+
// [1]: Command Substitution
|
|
2649
|
+
{
|
|
2650
|
+
pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
|
|
2651
|
+
greedy: true,
|
|
2652
|
+
inside: {
|
|
2653
|
+
'variable': /^\$\(|^`|\)$|`$/
|
|
2654
|
+
}
|
|
2655
|
+
},
|
|
2656
|
+
// [2]: Brace expansion
|
|
2657
|
+
{
|
|
2658
|
+
pattern: /\$\{[^}]+\}/,
|
|
2659
|
+
greedy: true,
|
|
2660
|
+
inside: {
|
|
2661
|
+
'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
|
|
2662
|
+
'punctuation': /[\[\]]/,
|
|
2663
|
+
'environment': {
|
|
2664
|
+
pattern: RegExp('(\\{)' + envVars),
|
|
2665
|
+
lookbehind: true,
|
|
2666
|
+
alias: 'constant'
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
},
|
|
2670
|
+
/\$(?:\w+|[#?*!@$])/
|
|
2671
|
+
],
|
|
2672
|
+
// Escape sequences from echo and printf's manuals, and escaped quotes.
|
|
2673
|
+
'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
|
|
2674
|
+
};
|
|
2675
|
+
|
|
2676
|
+
Prism.languages.bash = {
|
|
2677
|
+
'shebang': {
|
|
2678
|
+
pattern: /^#!\s*\/.*/,
|
|
2679
|
+
alias: 'important'
|
|
2680
|
+
},
|
|
2681
|
+
'comment': {
|
|
2682
|
+
pattern: /(^|[^"{\\$])#.*/,
|
|
2683
|
+
lookbehind: true
|
|
2684
|
+
},
|
|
2685
|
+
'function-name': [
|
|
2686
|
+
// a) function foo {
|
|
2687
|
+
// b) foo() {
|
|
2688
|
+
// c) function foo() {
|
|
2689
|
+
// but not “foo {”
|
|
2690
|
+
{
|
|
2691
|
+
// a) and c)
|
|
2692
|
+
pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
|
|
2693
|
+
lookbehind: true,
|
|
2694
|
+
alias: 'function'
|
|
2695
|
+
},
|
|
2696
|
+
{
|
|
2697
|
+
// b)
|
|
2698
|
+
pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
|
|
2699
|
+
alias: 'function'
|
|
2700
|
+
}
|
|
2701
|
+
],
|
|
2702
|
+
// Highlight variable names as variables in for and select beginnings.
|
|
2703
|
+
'for-or-select': {
|
|
2704
|
+
pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
|
|
2705
|
+
alias: 'variable',
|
|
2706
|
+
lookbehind: true
|
|
2707
|
+
},
|
|
2708
|
+
// Highlight variable names as variables in the left-hand part
|
|
2709
|
+
// of assignments (“=” and “+=”).
|
|
2710
|
+
'assign-left': {
|
|
2711
|
+
pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
|
|
2712
|
+
inside: {
|
|
2713
|
+
'environment': {
|
|
2714
|
+
pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars),
|
|
2715
|
+
lookbehind: true,
|
|
2716
|
+
alias: 'constant'
|
|
2717
|
+
}
|
|
2718
|
+
},
|
|
2719
|
+
alias: 'variable',
|
|
2720
|
+
lookbehind: true
|
|
2721
|
+
},
|
|
2722
|
+
// Highlight parameter names as variables
|
|
2723
|
+
'parameter': {
|
|
2724
|
+
pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
|
|
2725
|
+
alias: 'variable',
|
|
2726
|
+
lookbehind: true
|
|
2727
|
+
},
|
|
2728
|
+
'string': [
|
|
2729
|
+
// Support for Here-documents https://en.wikipedia.org/wiki/Here_document
|
|
2730
|
+
{
|
|
2731
|
+
pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
|
|
2732
|
+
lookbehind: true,
|
|
2733
|
+
greedy: true,
|
|
2734
|
+
inside: insideString
|
|
2735
|
+
},
|
|
2736
|
+
// Here-document with quotes around the tag
|
|
2737
|
+
// → No expansion (so no “inside”).
|
|
2738
|
+
{
|
|
2739
|
+
pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
|
|
2740
|
+
lookbehind: true,
|
|
2741
|
+
greedy: true,
|
|
2742
|
+
inside: {
|
|
2743
|
+
'bash': commandAfterHeredoc
|
|
2744
|
+
}
|
|
2745
|
+
},
|
|
2746
|
+
// “Normal” string
|
|
2747
|
+
{
|
|
2748
|
+
// https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
|
|
2749
|
+
pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
|
|
2750
|
+
lookbehind: true,
|
|
2751
|
+
greedy: true,
|
|
2752
|
+
inside: insideString
|
|
2753
|
+
},
|
|
2754
|
+
{
|
|
2755
|
+
// https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
|
|
2756
|
+
pattern: /(^|[^$\\])'[^']*'/,
|
|
2757
|
+
lookbehind: true,
|
|
2758
|
+
greedy: true
|
|
2759
|
+
},
|
|
2760
|
+
{
|
|
2761
|
+
// https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
|
|
2762
|
+
pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
|
|
2763
|
+
greedy: true,
|
|
2764
|
+
inside: {
|
|
2765
|
+
'entity': insideString.entity
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
],
|
|
2769
|
+
'environment': {
|
|
2770
|
+
pattern: RegExp('\\$?' + envVars),
|
|
2771
|
+
alias: 'constant'
|
|
2772
|
+
},
|
|
2773
|
+
'variable': insideString.variable,
|
|
2774
|
+
'function': {
|
|
2775
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
|
|
2776
|
+
lookbehind: true
|
|
2777
|
+
},
|
|
2778
|
+
'keyword': {
|
|
2779
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
|
|
2780
|
+
lookbehind: true
|
|
2781
|
+
},
|
|
2782
|
+
// https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
|
|
2783
|
+
'builtin': {
|
|
2784
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
|
|
2785
|
+
lookbehind: true,
|
|
2786
|
+
// Alias added to make those easier to distinguish from strings.
|
|
2787
|
+
alias: 'class-name'
|
|
2788
|
+
},
|
|
2789
|
+
'boolean': {
|
|
2790
|
+
pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
|
|
2791
|
+
lookbehind: true
|
|
2792
|
+
},
|
|
2793
|
+
'file-descriptor': {
|
|
2794
|
+
pattern: /\B&\d\b/,
|
|
2795
|
+
alias: 'important'
|
|
2796
|
+
},
|
|
2797
|
+
'operator': {
|
|
2798
|
+
// Lots of redirections here, but not just that.
|
|
2799
|
+
pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
|
|
2800
|
+
inside: {
|
|
2801
|
+
'file-descriptor': {
|
|
2802
|
+
pattern: /^\d/,
|
|
2803
|
+
alias: 'important'
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
},
|
|
2807
|
+
'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
|
|
2808
|
+
'number': {
|
|
2809
|
+
pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
|
|
2810
|
+
lookbehind: true
|
|
2811
|
+
}
|
|
2812
|
+
};
|
|
2813
|
+
|
|
2814
|
+
commandAfterHeredoc.inside = Prism.languages.bash;
|
|
2815
|
+
|
|
2816
|
+
/* Patterns in command substitution. */
|
|
2817
|
+
var toBeCopied = [
|
|
2818
|
+
'comment',
|
|
2819
|
+
'function-name',
|
|
2820
|
+
'for-or-select',
|
|
2821
|
+
'assign-left',
|
|
2822
|
+
'parameter',
|
|
2823
|
+
'string',
|
|
2824
|
+
'environment',
|
|
2825
|
+
'function',
|
|
2826
|
+
'keyword',
|
|
2827
|
+
'builtin',
|
|
2828
|
+
'boolean',
|
|
2829
|
+
'file-descriptor',
|
|
2830
|
+
'operator',
|
|
2831
|
+
'punctuation',
|
|
2832
|
+
'number'
|
|
2833
|
+
];
|
|
2834
|
+
var inside = insideString.variable[1].inside;
|
|
2835
|
+
for (var i = 0; i < toBeCopied.length; i++) {
|
|
2836
|
+
inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]];
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
Prism.languages.sh = Prism.languages.bash;
|
|
2840
|
+
Prism.languages.shell = Prism.languages.bash;
|
|
2841
|
+
}(Prism));
|
|
2842
|
+
|
|
2843
|
+
(function (Prism) {
|
|
2844
|
+
|
|
2845
|
+
// https://yaml.org/spec/1.2/spec.html#c-ns-anchor-property
|
|
2846
|
+
// https://yaml.org/spec/1.2/spec.html#c-ns-alias-node
|
|
2847
|
+
var anchorOrAlias = /[*&][^\s[\]{},]+/;
|
|
2848
|
+
// https://yaml.org/spec/1.2/spec.html#c-ns-tag-property
|
|
2849
|
+
var tag = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
|
|
2850
|
+
// https://yaml.org/spec/1.2/spec.html#c-ns-properties(n,c)
|
|
2851
|
+
var properties = '(?:' + tag.source + '(?:[ \t]+' + anchorOrAlias.source + ')?|'
|
|
2852
|
+
+ anchorOrAlias.source + '(?:[ \t]+' + tag.source + ')?)';
|
|
2853
|
+
// https://yaml.org/spec/1.2/spec.html#ns-plain(n,c)
|
|
2854
|
+
// This is a simplified version that doesn't support "#" and multiline keys
|
|
2855
|
+
// All these long scarry character classes are simplified versions of YAML's characters
|
|
2856
|
+
var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source
|
|
2857
|
+
.replace(/<PLAIN>/g, function () { return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source; });
|
|
2858
|
+
var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
|
|
2859
|
+
|
|
2860
|
+
/**
|
|
2861
|
+
*
|
|
2862
|
+
* @param {string} value
|
|
2863
|
+
* @param {string} [flags]
|
|
2864
|
+
* @returns {RegExp}
|
|
2865
|
+
*/
|
|
2866
|
+
function createValuePattern(value, flags) {
|
|
2867
|
+
flags = (flags || '').replace(/m/g, '') + 'm'; // add m flag
|
|
2868
|
+
var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source
|
|
2869
|
+
.replace(/<<prop>>/g, function () { return properties; }).replace(/<<value>>/g, function () { return value; });
|
|
2870
|
+
return RegExp(pattern, flags);
|
|
2871
|
+
}
|
|
2872
|
+
|
|
2873
|
+
Prism.languages.yaml = {
|
|
2874
|
+
'scalar': {
|
|
2875
|
+
pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source
|
|
2876
|
+
.replace(/<<prop>>/g, function () { return properties; })),
|
|
2877
|
+
lookbehind: true,
|
|
2878
|
+
alias: 'string'
|
|
2879
|
+
},
|
|
2880
|
+
'comment': /#.*/,
|
|
2881
|
+
'key': {
|
|
2882
|
+
pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source
|
|
2883
|
+
.replace(/<<prop>>/g, function () { return properties; })
|
|
2884
|
+
.replace(/<<key>>/g, function () { return '(?:' + plainKey + '|' + string + ')'; })),
|
|
2885
|
+
lookbehind: true,
|
|
2886
|
+
greedy: true,
|
|
2887
|
+
alias: 'atrule'
|
|
2888
|
+
},
|
|
2889
|
+
'directive': {
|
|
2890
|
+
pattern: /(^[ \t]*)%.+/m,
|
|
2891
|
+
lookbehind: true,
|
|
2892
|
+
alias: 'important'
|
|
2893
|
+
},
|
|
2894
|
+
'datetime': {
|
|
2895
|
+
pattern: createValuePattern(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),
|
|
2896
|
+
lookbehind: true,
|
|
2897
|
+
alias: 'number'
|
|
2898
|
+
},
|
|
2899
|
+
'boolean': {
|
|
2900
|
+
pattern: createValuePattern(/false|true/.source, 'i'),
|
|
2901
|
+
lookbehind: true,
|
|
2902
|
+
alias: 'important'
|
|
2903
|
+
},
|
|
2904
|
+
'null': {
|
|
2905
|
+
pattern: createValuePattern(/null|~/.source, 'i'),
|
|
2906
|
+
lookbehind: true,
|
|
2907
|
+
alias: 'important'
|
|
2908
|
+
},
|
|
2909
|
+
'string': {
|
|
2910
|
+
pattern: createValuePattern(string),
|
|
2911
|
+
lookbehind: true,
|
|
2912
|
+
greedy: true
|
|
2913
|
+
},
|
|
2914
|
+
'number': {
|
|
2915
|
+
pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, 'i'),
|
|
2916
|
+
lookbehind: true
|
|
2917
|
+
},
|
|
2918
|
+
'tag': tag,
|
|
2919
|
+
'important': anchorOrAlias,
|
|
2920
|
+
'punctuation': /---|[:[\]{}\-,|>?]|\.\.\./
|
|
2921
|
+
};
|
|
2922
|
+
|
|
2923
|
+
Prism.languages.yml = Prism.languages.yaml;
|
|
2924
|
+
|
|
2925
|
+
}(Prism));
|
|
2926
|
+
|
|
2927
|
+
(function (Prism) {
|
|
2928
|
+
|
|
2929
|
+
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
2930
|
+
|
|
2931
|
+
Prism.languages.css = {
|
|
2932
|
+
'comment': /\/\*[\s\S]*?\*\//,
|
|
2933
|
+
'atrule': {
|
|
2934
|
+
pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
|
|
2935
|
+
inside: {
|
|
2936
|
+
'rule': /^@[\w-]+/,
|
|
2937
|
+
'selector-function-argument': {
|
|
2938
|
+
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
2939
|
+
lookbehind: true,
|
|
2940
|
+
alias: 'selector'
|
|
2941
|
+
},
|
|
2942
|
+
'keyword': {
|
|
2943
|
+
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
2944
|
+
lookbehind: true
|
|
2945
|
+
}
|
|
2946
|
+
// See rest below
|
|
2947
|
+
}
|
|
2948
|
+
},
|
|
2949
|
+
'url': {
|
|
2950
|
+
// https://drafts.csswg.org/css-values-3/#urls
|
|
2951
|
+
pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
|
2952
|
+
greedy: true,
|
|
2953
|
+
inside: {
|
|
2954
|
+
'function': /^url/i,
|
|
2955
|
+
'punctuation': /^\(|\)$/,
|
|
2956
|
+
'string': {
|
|
2957
|
+
pattern: RegExp('^' + string.source + '$'),
|
|
2958
|
+
alias: 'url'
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
},
|
|
2962
|
+
'selector': {
|
|
2963
|
+
pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
|
|
2964
|
+
lookbehind: true
|
|
2965
|
+
},
|
|
2966
|
+
'string': {
|
|
2967
|
+
pattern: string,
|
|
2968
|
+
greedy: true
|
|
2969
|
+
},
|
|
2970
|
+
'property': {
|
|
2971
|
+
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
2972
|
+
lookbehind: true
|
|
2973
|
+
},
|
|
2974
|
+
'important': /!important\b/i,
|
|
2975
|
+
'function': {
|
|
2976
|
+
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
2977
|
+
lookbehind: true
|
|
2978
|
+
},
|
|
2979
|
+
'punctuation': /[(){};:,]/
|
|
2980
|
+
};
|
|
2981
|
+
|
|
2982
|
+
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
|
2983
|
+
|
|
2984
|
+
var markup = Prism.languages.markup;
|
|
2985
|
+
if (markup) {
|
|
2986
|
+
markup.tag.addInlined('style', 'css');
|
|
2987
|
+
markup.tag.addAttribute('style', 'css');
|
|
2988
|
+
}
|
|
2989
|
+
|
|
2990
|
+
}(Prism));
|
|
2991
|
+
|
|
2992
|
+
const edsCodeBlockCss = ":host{display:block;font-family:var(--font-family, 'Courier New', monospace)}pre[class*=\"language-\"]{white-space:pre-wrap;word-break:break-word;}.language{font-weight:bold;text-transform:uppercase}pre{margin:0;border-radius:8px;color:var(--purple-200);overflow:auto}code{font-family:'Courier New', monospace}.token.keyword{color:var(--purple-500)}.token.string{color:var(--green-500)}.token.function{color:var(--cyan-500)}.token.comment{color:var(--grey-700)}.relative{position:relative}.bg-stronger{background-color:var(--grey-900)}.rounded-sm{border-radius:8px}.rounded-xs{border-radius:4px}.text-inverse{color:var(--white)}.text-light{color:var(--grey-700)}.text-lighter{color:var(--grey-600)}.text-lightest{color:var(--grey-500)}.flex{display:flex}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.p-0{padding:0rem}.p-12{padding:0.75rem}.p-16{padding:1rem}.p-20{padding:1.25rem}.p-6{padding:0.375rem}.p-8{padding:0.5rem}.pl-8{padding-left:0.5rem}.mb-10{margin-bottom:0.625rem}.mb-12{margin-bottom:0.75rem}.mb-28{margin-bottom:1.75rem}.pb-16{padding-bottom:1rem}.pb-20{padding-bottom:1.25rem}.pb-28{padding-bottom:1.75rem}.pb-60{padding-bottom:3.75rem}.pb-8{padding-bottom:0.5rem}.mt-16{margin-top:1rem}.mt-2{margin-top:0.125rem}.mt-20{margin-top:1.25rem}.mt-28{margin-top:1.75rem}.w-20{width:1.25rem}.h-20{height:1.25rem}.f-ui-03{font-family:var(--f-ui-03-fontFamily);font-weight:var(--f-ui-03-fontWeight);font-size:var(--f-ui-03-fontSize);line-height:var(--f-ui-03-lineHeight);letter-spacing:var(--f-ui-03-letterSpacing)}.f-ui-03-light{font-family:var(--f-ui-03-light-fontFamily);font-weight:var(--f-ui-03-light-fontWeight);font-size:var(--f-ui-03-light-fontSize);line-height:var(--f-ui-03-light-lineHeight);letter-spacing:var(--f-ui-03-light-letterSpacing)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}";
|
|
2993
|
+
const EdsCodeBlockStyle0 = edsCodeBlockCss;
|
|
2994
|
+
|
|
2995
|
+
const EdsCodeBlock = class {
|
|
2996
|
+
constructor(hostRef) {
|
|
2997
|
+
registerInstance(this, hostRef);
|
|
2998
|
+
this.code = undefined;
|
|
2999
|
+
this.language = undefined;
|
|
3000
|
+
this.copied = false;
|
|
3001
|
+
}
|
|
3002
|
+
/**
|
|
3003
|
+
* Copies the current code content to the clipboard and sets a temporary copied state.
|
|
3004
|
+
*
|
|
3005
|
+
* @private
|
|
3006
|
+
* @returns {void}
|
|
3007
|
+
*/
|
|
3008
|
+
copyToClipboard() {
|
|
3009
|
+
navigator.clipboard.writeText(this.code).then(() => {
|
|
3010
|
+
this.copied = true;
|
|
3011
|
+
/*const analyticsName = this.createHumanFriendlyAnalyticsName(this.code, this.language);
|
|
3012
|
+
sendAnalytics({
|
|
3013
|
+
category: 'ui-component',
|
|
3014
|
+
parentContext: null,
|
|
3015
|
+
tag: this.el.tagName.toLowerCase(),
|
|
3016
|
+
name: analyticsName || '',
|
|
3017
|
+
action: 'copy'
|
|
3018
|
+
});*/
|
|
3019
|
+
setTimeout(() => (this.copied = false), 2000);
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
/**
|
|
3023
|
+
* Utility function that creates a human-friendly analytics name based on the code and language.
|
|
3024
|
+
* It uses:
|
|
3025
|
+
* - The language (in uppercase)
|
|
3026
|
+
* - The number of non-empty lines in the code
|
|
3027
|
+
* - The first non-empty line of code (truncated to 30 characters, if needed)
|
|
3028
|
+
*
|
|
3029
|
+
* returns A descriptive analytics name.
|
|
3030
|
+
*/
|
|
3031
|
+
/*private createHumanFriendlyAnalyticsName(code: string, language: string): string {
|
|
3032
|
+
// Count non-empty lines
|
|
3033
|
+
const lines = code.split('\n').filter(line => line.trim() !== '').length;
|
|
3034
|
+
|
|
3035
|
+
// Find the first non-empty line and trim it
|
|
3036
|
+
let firstNonEmptyLine = code.split('\n').find(line => line.trim() !== '');
|
|
3037
|
+
firstNonEmptyLine = firstNonEmptyLine ? firstNonEmptyLine.trim() : '';
|
|
3038
|
+
|
|
3039
|
+
// Truncate the snippet if it’s too long
|
|
3040
|
+
if (firstNonEmptyLine.length > 30) {
|
|
3041
|
+
firstNonEmptyLine = firstNonEmptyLine.substring(0, 30) + '...';
|
|
3042
|
+
}
|
|
3043
|
+
|
|
3044
|
+
return `CodeBlock:${language.toLowerCase()}|${lines}-line(s)|${firstNonEmptyLine.toLowerCase()}`;
|
|
3045
|
+
}*/
|
|
3046
|
+
/**
|
|
3047
|
+
* Returns the syntax-highlighted HTML for the code.
|
|
3048
|
+
* If the provided language is supported by Prism, this method returns the highlighted code.
|
|
3049
|
+
* Otherwise, it logs a warning and returns the raw code.
|
|
3050
|
+
*
|
|
3051
|
+
* @private
|
|
3052
|
+
* @returns {string} The highlighted HTML string for the code block.
|
|
3053
|
+
*/
|
|
3054
|
+
getHighlightedCode() {
|
|
3055
|
+
if (this.language && Prism$1.languages[this.language]) {
|
|
3056
|
+
return Prism$1.highlight(this.code, Prism$1.languages[this.language], this.language);
|
|
3057
|
+
}
|
|
3058
|
+
// eslint-disable-next-line
|
|
3059
|
+
//console.warn(`Unsupported or missing language: ${this.language}`);
|
|
3060
|
+
return this.code; // Fallback if language is not provided or unsupported
|
|
3061
|
+
}
|
|
231
3062
|
render() {
|
|
232
|
-
|
|
233
|
-
intent: this.intent,
|
|
234
|
-
loading: this.loading,
|
|
235
|
-
iconPos: this.iconPos,
|
|
236
|
-
size: this.size,
|
|
237
|
-
pill: this.pill,
|
|
238
|
-
iconOnly: !this.label,
|
|
239
|
-
iconSmall: this.iconSmall
|
|
240
|
-
});
|
|
241
|
-
const ElementType = this.elementType;
|
|
242
|
-
return (h(ElementType, { key: 'ecdd901c70578c07ef094aadbcd287588d4ba705', "aria-label": this.label || this.ariaLabel || undefined, "aria-disabled": this.elementType === 'button' ? this.disabled : undefined, disabled: this.elementType === 'button' ? this.disabled : undefined, class: `${classes || ''} ${this.extraClass || ''}`, onClick: (event) => this.handleClick(event) }, this.label && h("span", { key: 'af8d0ca1c5c3e54f9db3066931a69d3a5a812666', class: this.loading ? 'opacity-0' : '' }, this.label), this.loading && (h("span", { key: '29b72c15e80f46e023f829568f58d8a8dca82b78', class: "absolute inset-0 flex items-center justify-center" }, h("span", { key: 'bad8bd059b1312ca3f5ab173b1203eb395e9bbd8', class: "loader", style: {
|
|
243
|
-
border: `3px solid ${this.intent === 'secondary' ? 'rgba(255, 255, 255, .3)' : 'rgba(0, 0, 0, .3)'}`,
|
|
244
|
-
borderBottomColor: this.intent === 'secondary' ? '#fff' : '#000'
|
|
245
|
-
} }))), this.icon ? (h("eds-icon-wrapper", { class: `
|
|
246
|
-
flex inline-flex items-center justify-center
|
|
247
|
-
${this.size === 'large' ? 'h-24 w-24' : 'h-20 w-20'}
|
|
248
|
-
`, icon: this.icon })) : null));
|
|
3063
|
+
return (h("div", { key: '3cfaec27c58d05868313150f1a358ff64c8eafbd', class: "relative bg-stronger rounded-sm" }, h("div", { key: 'ed91821385f30305348750dbfffec5fdd7b4dbb8', class: "text-inverse flex justify-between items-center p-8" }, this.language ? (h("span", { class: "f-ui-03" }, this.language.toUpperCase())) : (h("pre", { class: "bg-stronger pl-8", role: "region", "aria-label": "Code block without language" }, h("code", { innerHTML: this.getHighlightedCode() }))), h("span", { key: '3e419585214883c878a8e84c440dbd29d590002d', "aria-hidden": "true", class: "w-20 h-20 mt-8" }, h("eds-icon-wrapper", { key: '051fa9c714d5c077d5d96ec9b92f8a744ec123bc', icon: this.copied ? 'success' : 'copy', onClick: () => this.copyToClipboard() })), h("span", { key: '707950ce89cb0c24b1afac42a8801d13659b6bab', class: "sr-only" }, "Copy Code")), this.language && (h("pre", { key: '59923dd4c16cfecafffa2edaaac5ef7579c3f128', class: `language-${this.language} bg-stronger pl-8 pb-8`, role: "region", "aria-label": `Code block in ${this.language}` }, h("code", { key: '8c708992c04029d71685ad8922383ecdda05ac3c', innerHTML: this.getHighlightedCode() })))));
|
|
249
3064
|
}
|
|
250
3065
|
get el() { return getElement(this); }
|
|
251
3066
|
};
|
|
252
|
-
|
|
3067
|
+
EdsCodeBlock.style = EdsCodeBlockStyle0;
|
|
253
3068
|
|
|
254
3069
|
const edsDropdownCss = ".z-focus{z-index:99}.relative{position:relative}.shadow-small{--tw-shadow:0px 1.5px 2px rgba(0, 0, 0, 0.1);--tw-shadow-colored:0px 1.5px 2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.bg-inverse{background-color:var(--white)}.border-softest{border:2px solid rgba(0, 0, 0, .05)}.z-10{z-index:10}.z-on-top{z-index:99999}.absolute{position:absolute}.top-full{top:100%}.mt-4{margin-top:0.25rem}.mt-6{margin-top:0.375rem}.mt-8{margin-top:0.5rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.flex-col{flex-direction:column}.gap-y-4{row-gap:0.25rem}.rounded-lg{border-radius:16px}.border-2{border-width:2px}.p-8{padding:0.5rem}.left-0{left:0rem}.left-1\\/2{left:50%}.left-4{left:0.25rem}.left-\\[4px\\]{left:4px}.right-0{right:0rem}.right-4{right:0.25rem}.right-8{right:0.5rem}";
|
|
255
3070
|
const EdsDropdownStyle0 = edsDropdownCss;
|
|
@@ -356,14 +3171,14 @@ const EdsDropdown = class {
|
|
|
356
3171
|
* @returns {JSX.Element} The rendered dropdown component.
|
|
357
3172
|
*/
|
|
358
3173
|
render() {
|
|
359
|
-
return (h("div", { key: '
|
|
3174
|
+
return (h("div", { key: '31e8b1fd4e146cbcad4d74bd78dff1cd1e1950bd', class: "z-focus relative", ref: (el) => (this.dropdownContent = el) }, h("eds-button", { key: '7021a0b0ff66780a324d7d9d1f6cff250ab64178', label: this.label, "aria-label": this.ariaLabel, icon: this.icon, intent: this.intent, onClick: this.handleClick, "aria-expanded": this.isOpen.toString(), "aria-haspopup": "menu" }), h("nav", { key: '904fd2a7f727a8b3966eab6cf9ebdb0efa474ae0', role: "menu", class: {
|
|
360
3175
|
'shadow-small bg-inverse border-softest z-10 z-on-top absolute top-full mt-4 flex flex-col gap-y-4 border-2 p-8': true,
|
|
361
3176
|
'left-4': this.dropdownPos === 'left' && this.dropdownOffset,
|
|
362
3177
|
'left-0': this.dropdownPos === 'left' && !this.dropdownOffset,
|
|
363
3178
|
'right-4': this.dropdownPos === 'right' && this.dropdownOffset,
|
|
364
3179
|
'right-0': this.dropdownPos === 'right' && !this.dropdownOffset,
|
|
365
3180
|
'rounded-lg': this.rounded
|
|
366
|
-
}, style: { display: this.isOpen ? 'block' : 'none' }, "aria-label": "Dropdown", "aria-hidden": !this.isOpen }, h("slot", { key: '
|
|
3181
|
+
}, style: { display: this.isOpen ? 'block' : 'none' }, "aria-label": "Dropdown", "aria-hidden": !this.isOpen }, h("slot", { key: 'b416621930c7117775fef2ee91bdca0f660302f5' }))));
|
|
367
3182
|
}
|
|
368
3183
|
get host() { return getElement(this); }
|
|
369
3184
|
};
|
|
@@ -454,6 +3269,13 @@ function findRatingElement(formEl) {
|
|
|
454
3269
|
}
|
|
455
3270
|
return null;
|
|
456
3271
|
}
|
|
3272
|
+
function findNpsElement(formEl) {
|
|
3273
|
+
const elements = Array.from(formEl.querySelectorAll('eds-nps'));
|
|
3274
|
+
for (const element of elements) {
|
|
3275
|
+
return element;
|
|
3276
|
+
}
|
|
3277
|
+
return null;
|
|
3278
|
+
}
|
|
457
3279
|
/**
|
|
458
3280
|
* Validates all fields and returns an object containing the errors and a flag indicating any errors.
|
|
459
3281
|
*/
|
|
@@ -463,6 +3285,7 @@ isFieldVisible) {
|
|
|
463
3285
|
const errors = {};
|
|
464
3286
|
let hasError = false;
|
|
465
3287
|
parsedFields.forEach((field) => {
|
|
3288
|
+
var _a;
|
|
466
3289
|
// Only validate fields that are visible.
|
|
467
3290
|
if (!isFieldVisible(field, values)) {
|
|
468
3291
|
// If a field is hidden, clear its error.
|
|
@@ -498,6 +3321,28 @@ isFieldVisible) {
|
|
|
498
3321
|
}
|
|
499
3322
|
}
|
|
500
3323
|
}
|
|
3324
|
+
// NPS type
|
|
3325
|
+
else if (field.type === 'nps') {
|
|
3326
|
+
const npsEl = findNpsElement(formEl);
|
|
3327
|
+
if (npsEl && npsEl.shadowRoot) {
|
|
3328
|
+
const raw = (_a = npsEl.shadowRoot
|
|
3329
|
+
.querySelector('div[role="radio"][aria-checked="true"] eds-button')) === null || _a === void 0 ? void 0 : _a.getAttribute('aria-label');
|
|
3330
|
+
const value = raw !== null ? parseInt(raw, 10) : null;
|
|
3331
|
+
if (value === null) {
|
|
3332
|
+
// eslint-disable-next-line
|
|
3333
|
+
if (field.required) {
|
|
3334
|
+
errors[field.name] = ['This field is required.'];
|
|
3335
|
+
hasError = true;
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
else if (field.required) {
|
|
3340
|
+
// No NPS component found but required
|
|
3341
|
+
errors[field.name] = ['This field is required.'];
|
|
3342
|
+
hasError = true;
|
|
3343
|
+
}
|
|
3344
|
+
return;
|
|
3345
|
+
}
|
|
501
3346
|
else {
|
|
502
3347
|
// For all other types, find the first matching element.
|
|
503
3348
|
const inputEl = findFieldElement(formEl, field.name);
|
|
@@ -787,6 +3632,25 @@ const EdsForm = class {
|
|
|
787
3632
|
message: `${field.name} updated`
|
|
788
3633
|
});
|
|
789
3634
|
}
|
|
3635
|
+
handleNPS(e, field) {
|
|
3636
|
+
const score = e.detail;
|
|
3637
|
+
this.values = Object.assign(Object.assign({}, this.values), { [field.name]: score });
|
|
3638
|
+
const newErrors = Object.assign({}, this.errors);
|
|
3639
|
+
if (field.required && score === null) {
|
|
3640
|
+
newErrors[field.name] = ['This field is required'];
|
|
3641
|
+
}
|
|
3642
|
+
else {
|
|
3643
|
+
delete newErrors[field.name];
|
|
3644
|
+
}
|
|
3645
|
+
this.errors = newErrors;
|
|
3646
|
+
this.hasError = Object.keys(newErrors).length > 0;
|
|
3647
|
+
this.form.emit({
|
|
3648
|
+
event: 'change',
|
|
3649
|
+
field: field.name,
|
|
3650
|
+
value: score,
|
|
3651
|
+
message: `${field.name} updated`
|
|
3652
|
+
});
|
|
3653
|
+
}
|
|
790
3654
|
handleSubmit() {
|
|
791
3655
|
var _a, _b;
|
|
792
3656
|
if (this.isSubmitting) {
|
|
@@ -855,7 +3719,7 @@ const EdsForm = class {
|
|
|
855
3719
|
return map;
|
|
856
3720
|
}
|
|
857
3721
|
renderField(field) {
|
|
858
|
-
var _a, _b;
|
|
3722
|
+
var _a, _b, _c;
|
|
859
3723
|
if (!this.isFieldVisible(field)) {
|
|
860
3724
|
return null;
|
|
861
3725
|
}
|
|
@@ -865,7 +3729,10 @@ const EdsForm = class {
|
|
|
865
3729
|
const val = this.values[field.name] || 0;
|
|
866
3730
|
return (h("div", { class: "form-group rating-field", key: field.name }, h("div", { class: "flex justify-between" }, field && (h("eds-input-label", { name: `rating-${field.name}`, label: field.label, disabled: field.disabled, required: field.required }))), h("eds-rating", { id: `rating-${field.name}`, "rating-type": field.ratingType, "rating-count": field.ratingCount, "selected-rating": val, onRating: (e) => this.handleRating(e, field) }), h("div", { class: "mt-6" }, h("eds-input-footer", { id: `${field.name}-footer`, name: field.name, message: field.message, "error-message": (_a = this.errors[field.name]) === null || _a === void 0 ? void 0 : _a.join('<br/>'), error: !!this.errors[field.name], link: field.link }))));
|
|
867
3731
|
}
|
|
868
|
-
|
|
3732
|
+
else if (field.type === 'nps') {
|
|
3733
|
+
return (h("div", { class: "form-group nps-field", key: field.name }, h("div", { class: "flex justify-between" }, field && (h("eds-input-label", { name: `nps-${field.name}`, label: field.question, disabled: field.disabled, required: field.required }))), h("eds-nps", { id: `nps-${field.name}`, "right-label": field.rightLabel, "left-label": field.leftLabel, onNps: (e) => this.handleNPS(e, field) }), h("div", { class: "mt-6" }, h("eds-input-footer", { id: `${field.name}-footer`, name: field.name, message: field.message, "error-message": (_b = this.errors[field.name]) === null || _b === void 0 ? void 0 : _b.join('<br/>'), error: !!this.errors[field.name], link: field.link }))));
|
|
3734
|
+
}
|
|
3735
|
+
return (h("eds-input-field", { key: field.name, name: field.name, label: field.label, placeholder: field.placeholder, type: field.type, value: this.values[field.name], required: field.required, hint: field.hint, message: field.message, error: !!this.errors[field.name], errorMessage: (_c = this.errors[field.name]) === null || _c === void 0 ? void 0 : _c.join('<br/>'), options: field.options, onInput: (e) => this.handleInput(e, field), onChangeNative: (e) => this.handleChange(e, field) }));
|
|
869
3736
|
}
|
|
870
3737
|
async getData() {
|
|
871
3738
|
return this.makeFormData();
|
|
@@ -874,9 +3741,9 @@ const EdsForm = class {
|
|
|
874
3741
|
const hiddenFields = this.parsedFields.filter((field) => field.type === 'hidden');
|
|
875
3742
|
//const otherFields = this.parsedFields.filter((field) => field.type !== 'hidden');
|
|
876
3743
|
const buckets = this.groupedFields;
|
|
877
|
-
return (h("form", { key: '
|
|
3744
|
+
return (h("form", { key: 'a66997f39b5be347a4d502f77bcd1da9d1a274ac', ref: (el) => (this.formEl = el), autocomplete: "on", onSubmit: this.handleSubmit }, h("div", { key: 'f8800d2ebe64b3279234ab8ebe20e535dc822872' }, h("slot", { key: 'b4194073b281dec35a79a6cc974fdf7476a67807' }), hiddenFields.map((field, index) => (h("eds-input", { key: index, type: "hidden", name: field.name, value: field.value }))), this.parsedGroups
|
|
878
3745
|
.filter((g) => Array.isArray(buckets[g.id]) && buckets[g.id].length > 0)
|
|
879
|
-
.map((g) => (h("div", { class: "container mt-20", key: g.id }, h("span", { class: "f-body-02" }, h("b", null, g.title)), h("div", { class: "border-group mt-32 mb-32 flex flex-col gap-y-24" }, buckets[g.id].map((f) => this.renderField(f)))))), h("div", { key: '
|
|
3746
|
+
.map((g) => (h("div", { class: "container mt-20", key: g.id }, h("span", { class: "f-body-02" }, h("b", null, g.title)), h("div", { class: "border-group mt-32 mb-32 flex flex-col gap-y-24" }, buckets[g.id].map((f) => this.renderField(f)))))), h("div", { key: '2fc83ebb6b0a472f6853618602c37ee83adae9ff', class: "flex flex-col mt-20 gap-y-24" }, buckets['__ungrouped'].map((f) => this.renderField(f)))), this.formBtn && (h("div", { key: '91b569b1a4513945f3228c374ae45b52ea17f91d', class: "mt-32" }, h("eds-button", { key: '1a8feaecd5a7f292f8aeae3db900700b4f7fb8d4', intent: "primary", label: this.formBtnLabel, disabled: this.isSubmitting, loading: this.isSubmitting, onClick: () => this.handleSubmit() })))));
|
|
880
3747
|
}
|
|
881
3748
|
get el() { return getElement(this); }
|
|
882
3749
|
static get watchers() { return {
|
|
@@ -934,7 +3801,7 @@ const EdsHeader = class {
|
|
|
934
3801
|
const classes = variantClasses[this.headerVariant] || variantClasses.default;
|
|
935
3802
|
// Logo color variant: default and inverse use 'color', strong uses 'color-white'
|
|
936
3803
|
const logoType = this.headerVariant === 'strong' ? 'color-white' : 'color';
|
|
937
|
-
return (h("header", { key: '
|
|
3804
|
+
return (h("header", { key: '812ad4427cbb3f4b0ca9e305870c35d63487dc59', class: `flex items-center justify-between relative z-10 ${classes}` }, h("div", { key: '531acdceb12ca45fea125091dee4d8a0ff39a10b', class: "mr-auto w-[200px] h-[85px]" }, h("eds-logo", { key: 'bb2708b3c8eacc575117bfed404b7c9db4fd05e2', type: logoType, href: this.homeUrl })), this.parsedLinks && (h("nav", { key: 'a80192d7666416c29025a1ac5812946f14feec3f', class: "absolute left-1/2 top-1/2 grow -translate-x-1/2 -translate-y-1/2 justify-center hidden md:flex" }, h("ul", { key: 'fae258c468367837a9738bcbe2442709fdc601a0', class: "flex gap-x-2" }, this.parsedLinks.map((link) => (h("eds-link", { label: link.label, "aria-label": link.label, url: link.url, intent: "ghost", size: "large", icon: link.icon, external: link.external, "extra-class": "after:effect-opacity aria-current-page:bg-darker whitespace-nowrap !text-current after:!border-transparent after:opacity-0 hover:after:!border-transparent hover:after:opacity-100" })))))), h("slot", { key: '9588ef20e19fda76115074c39d902eebead3c845' }), this.menuEnabled && (h("div", { key: 'ce2e43645a1c33ca7d6495acd820ad0a93cefdf9', class: "md:hidden flex overflow-hidden px-16" }, h("eds-button", { key: 'ed73c7e7a6544f60eea9dbf43379ffe4967c0dbd', "aria-label": "Menu", intent: this.headerVariant === 'default' ? 'ghost' : 'ghostInverse', icon: "menu", size: "small", onClick: () => this.handleToggleMenu() })))));
|
|
938
3805
|
}
|
|
939
3806
|
get hostEl() { return getElement(this); }
|
|
940
3807
|
};
|
|
@@ -1016,10 +3883,10 @@ const EdsImg = class {
|
|
|
1016
3883
|
imgOpts['loading'] = 'lazy';
|
|
1017
3884
|
imgOpts['decoding'] = 'async';
|
|
1018
3885
|
}
|
|
1019
|
-
return (h("div", { key: '
|
|
3886
|
+
return (h("div", { key: '605bff5657ca79678517527a9462b31608e5af7a', class: {
|
|
1020
3887
|
'items-center justify-center': true,
|
|
1021
3888
|
'effect-bg-pattern': this.lazyload && this.showBg
|
|
1022
|
-
} }, h("picture", { key: '
|
|
3889
|
+
} }, h("picture", { key: '0d0def26688c1ec7214211d02875160965e2ce48' }, this.formats.map((format) => (h("source", { type: format.type, srcSet: format.srcset, media: format.media, sizes: this.sizes }))), h("img", Object.assign({ key: 'c9c307a5fdf25d9792db2a76f4d08fcd27b50401', ref: (el) => (this.img = el), class: {
|
|
1023
3890
|
'effect-opacity object-cover object-center': true,
|
|
1024
3891
|
'opacity-100': this.loaded,
|
|
1025
3892
|
'opacity-0': !this.loaded
|
|
@@ -1078,7 +3945,7 @@ const EdsInput = class {
|
|
|
1078
3945
|
render() {
|
|
1079
3946
|
const withIcon = !!this.icon;
|
|
1080
3947
|
const describedBy = this.hasMessage || this.error ? `${this.name}-error` : '';
|
|
1081
|
-
return (h("div", { key: '
|
|
3948
|
+
return (h("div", { key: 'a26224d6345099df6bc5110d42b701980603f7f7', class: "relative flex items-center" }, this.type === 'textarea' ? (h("textarea", { id: this.inputId || this.name, name: this.name, placeholder: this.placeholder, value: this.innerVal.toString(), required: this.required, disabled: this.disabled, class: `min-h-80 input input-textarea ${withIcon ? 'input-with-icon' : ''} ${this.error ? 'input-error' : ''} ${this.extraClass}`, "aria-invalid": this.error ? 'true' : 'false', "aria-describedby": describedBy, maxlength: this.maxLength, onInput: this.handleInput, onChange: this.handleInput })) : this.type === 'select' ? (h("select", { id: this.inputId || this.name, name: this.name, required: this.required, disabled: this.disabled, class: `input input-select ${this.error ? 'input-error' : ''} ${this.extraClass}`, "aria-invalid": this.error ? 'true' : 'false', "aria-describedby": describedBy, onInput: this.handleInput, onChange: this.handleInput }, this.options.map((option) => (h("option", { value: option.value, selected: option.value === this.innerVal, key: option.value }, option.label))))) : (h("input", Object.assign({ id: this.inputId || this.name, name: this.name, placeholder: this.placeholder, value: this.innerVal.toString(), required: this.required, disabled: this.disabled, type: this.type, checked: ['radio', 'checkbox'].includes(this.type) ? this.checked : undefined }, (this.type === 'number'
|
|
1082
3949
|
? {
|
|
1083
3950
|
min: this.min,
|
|
1084
3951
|
max: this.max,
|
|
@@ -1089,7 +3956,7 @@ const EdsInput = class {
|
|
|
1089
3956
|
input ${this.type === 'radio' ? 'input-radio' : this.type === 'checkbox' ? 'input-checkbox' : ''}
|
|
1090
3957
|
${withIcon && this.type !== 'radio' && this.type !== 'checkbox' ? 'input-icon pl-36' : ''}
|
|
1091
3958
|
${this.error ? 'input-error' : ''}
|
|
1092
|
-
`, "aria-invalid": this.error ? 'true' : 'false', "aria-describedby": describedBy, maxlength: this.maxLength, onInput: this.handleInput, onChange: this.handleInput }))), this.maxLength && this.type === 'textarea' && (h("span", { key: '
|
|
3959
|
+
`, "aria-invalid": this.error ? 'true' : 'false', "aria-describedby": describedBy, maxlength: this.maxLength, onInput: this.handleInput, onChange: this.handleInput }))), this.maxLength && this.type === 'textarea' && (h("span", { key: 'beb48d08d18b5ca5b054b1b579e2f9527af222e9', class: `input-counter f-ui-05 absolute bottom-8 right-8 ${this.maxLengthReached ? 'input-counter-error' : ''}` }, this.maxLength)), this.icon && (h("eds-icon-wrapper", { key: '06948fe33c35c5830edd50a37411281865ef6d12', class: `absolute top-1/2 left-[4px] -translate-y-1/2 ${this.disabled ? 'text-lightest' : 'text-lightest'}`, icon: this.icon }))));
|
|
1093
3960
|
}
|
|
1094
3961
|
get el() { return getElement(this); }
|
|
1095
3962
|
static get watchers() { return {
|
|
@@ -1200,7 +4067,7 @@ const EdsInputField = class {
|
|
|
1200
4067
|
}
|
|
1201
4068
|
render() {
|
|
1202
4069
|
const inputOpts = Object.assign({ name: this.name, id: this.inputId, placeholder: this.placeholder, disabled: this.disabled, onInput: this.handleNativeInput, onChange: this.handleNativeChange, type: this.type, required: this.required, value: this.value, error: this.error, icon: this.icon, checked: this.checked }, (this.type === 'number' ? { min: this.min, max: this.max, step: this.step } : {}));
|
|
1203
|
-
return (h("div", { key: '
|
|
4070
|
+
return (h("div", { key: '615165ebb5980d2da414ad4028e053b46358eb4e' }, this.type === 'checkbox' || this.type === 'radio' ? (this.parsedOptions.length > 0 ? (h("fieldset", { class: "space-y-4 mt-8" }, h("div", { class: "flex justify-between" }, this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, required: this.required })), this.hint && (h("p", { id: `${this.name}-hint`, class: "f-ui-05 text-lighter mt-8 ml-8" }, this.hint))), this.parsedOptions.map((option) => (h("div", { class: "flex items-center gap-x-4 gap-y-4", key: option.value }, h("eds-input", Object.assign({}, inputOpts, { value: option.value, checked: typeof this.value === 'string' && this.value.split(',').includes(String(option.value)) })), h("label", { htmlFor: this.name, class: `input-label-options ${this.disabled ? 'text-lighter' : ''}` }, option.label)))))) : (h("div", { class: "flex items-center gap-x-8" }, h("eds-input", Object.assign({}, inputOpts, { value: this.value, checked: this.value === 'on' || this.checked })), this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, disabled: this.disabled, required: this.required }))))) : (h("div", null, h("div", { class: "flex justify-between" }, this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, disabled: this.disabled, required: this.required })), this.hint && (h("p", { id: `${this.name}-hint`, class: "f-ui-05 text-lighter mt-8 ml-8" }, this.hint))), this.type === 'select' ? (h("eds-input-select", Object.assign({}, inputOpts, { options: this.parsedOptions }))) : this.type === 'file' ? (h("input", { type: "file", id: this.inputId || this.name, name: this.name, onChange: this.onChangeNative, disabled: this.disabled, required: this.required })) : this.type === 'search' ? (h("eds-input-search", { name: "search-box" })) : this.type === 'range' ? ((() => {
|
|
1204
4071
|
var _a, _b, _c;
|
|
1205
4072
|
const rangeProps = {
|
|
1206
4073
|
name: inputOpts.name,
|
|
@@ -1213,8 +4080,9 @@ const EdsInputField = class {
|
|
|
1213
4080
|
const opt = this.parsedOptions;
|
|
1214
4081
|
const numberValue = typeof this.value === 'string' ? parseFloat(this.value) : this.value || 0;
|
|
1215
4082
|
return (h("eds-input-range", Object.assign({}, rangeProps, { min: (_a = opt[0]) === null || _a === void 0 ? void 0 : _a.value, max: (_b = opt[1]) === null || _b === void 0 ? void 0 : _b.value, step: (_c = opt[2]) === null || _c === void 0 ? void 0 : _c.value, value: numberValue })));
|
|
1216
|
-
})()) : (h("eds-input", Object.assign({}, inputOpts))))), h("div", { key: '
|
|
4083
|
+
})()) : (h("eds-input", Object.assign({}, inputOpts))))), h("div", { key: '4ca8edfb4538caab53e89f16008683aea28adfbc', class: "mt-6" }, h("eds-input-footer", { key: '68053a16f607a277a5c806f3c830b24acf3b1f50', id: `${this.name}-footer`, name: this.name, message: this.message, "error-message": this.errorMessage, error: this.error, link: this.link }))));
|
|
1217
4084
|
}
|
|
4085
|
+
static get delegatesFocus() { return true; }
|
|
1218
4086
|
get hostEl() { return getElement(this); }
|
|
1219
4087
|
};
|
|
1220
4088
|
EdsInputField.style = EdsInputFieldStyle0;
|
|
@@ -1232,7 +4100,7 @@ const EdsInputFooter = class {
|
|
|
1232
4100
|
this.link = undefined;
|
|
1233
4101
|
}
|
|
1234
4102
|
render() {
|
|
1235
|
-
return (h("div", { key: '
|
|
4103
|
+
return (h("div", { key: '58bce34f2ec417696ba03d6c8c0c77fa1d900f9a' }, this.error && this.errorMessage && (h("div", { key: 'be14dc0f6e9494c1ee436fd8f822112eab6d2ce2', id: `error_${this.name}`, class: "text-error flex items-center" }, h("eds-icon-wrapper", { key: 'aaa2010441b0bfe9445e4b6401115b29606ac507', icon: "warning" }), h("p", { key: '277ac1de538e873c7da9b592e60dfd276738025d', class: "f-ui-04 ml-4 mb-4", innerHTML: this.errorMessage }))), this.message && h("p", { key: '4f07c6efe398bb002322a35279e68b237eac860e', id: `desc_${this.name}`, class: "f-ui-05 text-lighter", innerHTML: this.message }), this.link && (h("a", { key: '50d042530985eeafd7334b0bb38fd2c14aed0e3f', href: this.link.url, class: "f-ui-05 effect-color hover:text-lighter underline underline-offset-4" }, this.link.label))));
|
|
1236
4104
|
}
|
|
1237
4105
|
};
|
|
1238
4106
|
EdsInputFooter.style = EdsInputFooterStyle0;
|
|
@@ -1249,7 +4117,7 @@ const EdsInputLabel = class {
|
|
|
1249
4117
|
this.disabled = false;
|
|
1250
4118
|
}
|
|
1251
4119
|
render() {
|
|
1252
|
-
return (h("label", { key: '
|
|
4120
|
+
return (h("label", { key: '622cd7e26774448ca86c1168d0a287d7b61d3e29', htmlFor: this.name, class: `input-label ${this.disabled ? 'text-lighter' : ''}` }, this.label, this.required && (h("span", { key: 'c3162e765af70dd972e3cd0ca360cd3f52003f76' }, h("span", { key: '5bca5243c95399fefff4fa21b6c1477a287a3cb4', "aria-hidden": "true" }, "*"), h("span", { key: 'bc1c229ac387161e4aa314498dbbc77fbab62955', class: "sr-only" }, "required")))));
|
|
1253
4121
|
}
|
|
1254
4122
|
};
|
|
1255
4123
|
EdsInputLabel.style = EdsInputLabelStyle0;
|
|
@@ -1296,7 +4164,7 @@ const EdsInputRange = class {
|
|
|
1296
4164
|
return this.inputElement;
|
|
1297
4165
|
}
|
|
1298
4166
|
render() {
|
|
1299
|
-
return (h("div", { key: '
|
|
4167
|
+
return (h("div", { key: '51c9adb300d50eecb48de1547c0a0475692aa97b', class: "relative flex flex-col items-start" }, h("input", { key: '65ac18497d2a4307d7f5161951b87bb38cdad892', id: this.inputId || this.name, name: this.name, min: this.min, max: this.max, step: this.step, value: this.sliderVal, required: this.required, disabled: this.disabled, type: "range", class: "w-full py-6 input", tabindex: "0", role: "slider", "aria-describedby": `desc_${this.name}`, "aria-valuemin": this.min, "aria-valuemax": this.max, "aria-valuenow": this.sliderVal, onInput: this.onInput, onChange: this.onChange }), h("p", { key: '9b717fce31d2340f3b4bc4b5583e6b1e7764314f', id: `desc_${this.name}`, class: "block f-ui-05 mt-4 text-lighter" }, "Current value: ", this.sliderVal)));
|
|
1300
4168
|
}
|
|
1301
4169
|
get el() { return getElement(this); }
|
|
1302
4170
|
static get watchers() { return {
|
|
@@ -1365,7 +4233,7 @@ const EdsInputSearch = class {
|
|
|
1365
4233
|
return this.inputElement;
|
|
1366
4234
|
}
|
|
1367
4235
|
render() {
|
|
1368
|
-
return (h("div", { key: '
|
|
4236
|
+
return (h("div", { key: '40f0faa26610671e0a89055e5a51fb17ab17c470', class: "relative flex items-center" }, h("eds-icon-wrapper", { key: '910f6681ae719608c6f2787de4b3871742dd290a', icon: "search", class: "absolute top-1/2 left-[4px] -translate-y-1/2 text-lightest", "aria-hidden": "true" }), h("input", { key: '77534918bd9f2bcd4014e5b201a4f7eb2c0753b4', id: this.inputId || this.name, name: this.name, placeholder: this.placeholder, value: this.value || '', required: this.required, disabled: this.disabled, type: "search", "aria-label": this.placeholder, class: `input pl-36 ${this.decorate}`,
|
|
1369
4237
|
//onInput={this.onInput}
|
|
1370
4238
|
onChange: this.onChange })));
|
|
1371
4239
|
}
|
|
@@ -1394,12 +4262,12 @@ const EdsInputSelect = class {
|
|
|
1394
4262
|
const selectId = this.inputId || this.name;
|
|
1395
4263
|
const placeholderText = this.placeholder || `Pick from the list`;
|
|
1396
4264
|
const describedBy = this.hasMessage || this.error ? `${this.name}-error` : undefined;
|
|
1397
|
-
return (h("div", { key: '
|
|
4265
|
+
return (h("div", { key: 'f154a5f34a0d09cf6a02e24f13ed9af46532c76c', class: "relative" }, h("select", { key: '0982936337bcbec3e2b81f7edc1436506841c782', id: selectId, name: this.name, class: {
|
|
1398
4266
|
input: true,
|
|
1399
4267
|
'input-error': this.error,
|
|
1400
4268
|
'px-4': true,
|
|
1401
4269
|
'py-2': true
|
|
1402
|
-
}, "aria-invalid": this.error ? 'true' : 'false', "aria-describedby": describedBy, disabled: this.disabled, required: this.required, onChange: this.handleChange }, h("option", { key: '
|
|
4270
|
+
}, "aria-invalid": this.error ? 'true' : 'false', "aria-describedby": describedBy, disabled: this.disabled, required: this.required, onChange: this.handleChange }, h("option", { key: '7656fa514dec6b8b05bbb8d02636bf5e2ee8d213', value: "", disabled: true, hidden: true }, placeholderText), this.options.map((opt, index) => (h("option", { key: index, value: opt.value, selected: opt.value === this.value }, opt.label)))), h("span", { key: '8464aa5ef3eab675f493b582736c25a7edd88224', class: "bg-dark rounded-xs absolute top-1/2 right-[6px] flex h-28 w-28 -translate-y-1/2 items-center justify-center" }, h("eds-icon-wrapper", { key: '092271b13e4d496a85c55fbb5f1756805cd5d3de', class: "w-20 h-20", icon: "chevron-right" }))));
|
|
1403
4271
|
}
|
|
1404
4272
|
};
|
|
1405
4273
|
|
|
@@ -1575,12 +4443,34 @@ const EdsLink = class {
|
|
|
1575
4443
|
action: 'click'
|
|
1576
4444
|
});
|
|
1577
4445
|
}
|
|
4446
|
+
handleKeyDown(event) {
|
|
4447
|
+
if (this.disabled) {
|
|
4448
|
+
return;
|
|
4449
|
+
}
|
|
4450
|
+
// Handle Enter and Space keys for activation
|
|
4451
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
4452
|
+
event.preventDefault();
|
|
4453
|
+
this.handleClick(event);
|
|
4454
|
+
// For actual navigation, trigger the native link behavior
|
|
4455
|
+
if (this.url && !this.disabled) {
|
|
4456
|
+
if (this.external) {
|
|
4457
|
+
window.open(this.url, '_blank', 'noopener,noreferrer');
|
|
4458
|
+
}
|
|
4459
|
+
else {
|
|
4460
|
+
window.location.href = this.url;
|
|
4461
|
+
}
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
1578
4465
|
getLinkSize() {
|
|
4466
|
+
if (this.intent === 'underline') {
|
|
4467
|
+
return 'underline';
|
|
4468
|
+
}
|
|
1579
4469
|
return this.size;
|
|
1580
4470
|
}
|
|
1581
4471
|
renderLeftIcon() {
|
|
1582
4472
|
if (this.icon && this.iconPos === 'left') {
|
|
1583
|
-
return (h("span", { class:
|
|
4473
|
+
return (h("span", { class: "flex" }, h("eds-icon-wrapper", { "aria-hidden": "true", class: `
|
|
1584
4474
|
flex inline-flex items-center justify-center
|
|
1585
4475
|
${this.size === 'large' ? 'h-24 w-24' : 'h-20 w-20'}
|
|
1586
4476
|
`, icon: this.icon })));
|
|
@@ -1589,7 +4479,7 @@ const EdsLink = class {
|
|
|
1589
4479
|
}
|
|
1590
4480
|
renderRightIcon() {
|
|
1591
4481
|
if (this.icon && this.iconPos === 'right') {
|
|
1592
|
-
return (h("span", { class:
|
|
4482
|
+
return (h("span", { class: "flex" }, h("eds-icon-wrapper", { "aria-hidden": "true", class: `
|
|
1593
4483
|
flex inline-flex items-center justify-center
|
|
1594
4484
|
${this.size === 'large' ? 'h-24 w-24' : 'h-20 w-20'}
|
|
1595
4485
|
`, icon: this.icon })));
|
|
@@ -1597,8 +4487,6 @@ const EdsLink = class {
|
|
|
1597
4487
|
return null;
|
|
1598
4488
|
}
|
|
1599
4489
|
render() {
|
|
1600
|
-
// If the link is disabled, use a <span>; otherwise, use an <a> element.
|
|
1601
|
-
const ComponentType = this.disabled ? 'span' : 'a';
|
|
1602
4490
|
const classes = linkStyles({
|
|
1603
4491
|
intent: this.intent,
|
|
1604
4492
|
size: this.getLinkSize(),
|
|
@@ -1606,12 +4494,12 @@ const EdsLink = class {
|
|
|
1606
4494
|
isActive: this.current,
|
|
1607
4495
|
hasIcon: !!this.icon
|
|
1608
4496
|
});
|
|
1609
|
-
|
|
1610
|
-
const
|
|
4497
|
+
const isInteractive = !this.disabled;
|
|
4498
|
+
const isIconOnly = !this.label || (this.hideLabelOnSmallScreen && this.icon);
|
|
1611
4499
|
const labelClasses = this.hideLabelOnSmallScreen
|
|
1612
4500
|
? 'hidden lg:flex' // Tailwind example: hidden on small screens, visible on larger
|
|
1613
4501
|
: '';
|
|
1614
|
-
return (h(
|
|
4502
|
+
return (h("a", { key: '929b7318ec6475113125e40d789476df76e59e38', class: `${classes || ''} ${this.extraClass || ''}`, href: isInteractive ? this.url : undefined, target: this.external && isInteractive ? '_blank' : undefined, rel: this.external && isInteractive ? 'noopener noreferrer' : undefined, tabIndex: isInteractive ? 0 : -1, "aria-label": isIconOnly ? this.ariaLabel || 'Link' : undefined, "aria-disabled": this.disabled ? 'true' : undefined, "aria-current": this.current ? 'page' : undefined, role: this.disabled ? 'link' : undefined, download: this.download ? '' : undefined, onClick: (event) => this.handleClick(event), onKeyDown: (event) => this.handleKeyDown(event) }, h("span", { key: '4b965dcb07ebca43577b0dcd9f2d11495caa761a', class: "z-1 relative inline-flex items-center justify-center" }, this.renderLeftIcon(), this.label && h("span", { key: 'a4327fe130fb8c3962096eff3415ad62e19230f4', class: labelClasses }, this.label), this.renderRightIcon())));
|
|
1615
4503
|
}
|
|
1616
4504
|
get el() { return getElement(this); }
|
|
1617
4505
|
};
|
|
@@ -1679,29 +4567,273 @@ const EdsLogo = class {
|
|
|
1679
4567
|
}
|
|
1680
4568
|
render() {
|
|
1681
4569
|
const logoContent = this.getLogo();
|
|
1682
|
-
return (h("a", { key: '
|
|
4570
|
+
return (h("a", { key: 'fff2a45eb8b41f59026ff7033824484339e3c0a9', href: this.href, onClick: () => this.handleClick(), class: "eds-logo-wrapper", "aria-label": this.label }, h("div", { key: 'bc13988a739af1c94d5eadbabf558cbbb10927b8', innerHTML: logoContent })));
|
|
1683
4571
|
}
|
|
1684
4572
|
get el() { return getElement(this); }
|
|
1685
4573
|
};
|
|
1686
4574
|
EdsLogo.style = EdsLogoStyle0;
|
|
1687
4575
|
|
|
1688
|
-
const
|
|
4576
|
+
const edsMatomoNoticeCss = ".fixed{position:fixed}.absolute{position:absolute}.w-full{width:100%}.bottom-0{bottom:0rem}.bottom-4{bottom:0.25rem}.p-4{padding:0.25rem}.p-6{padding:0.375rem}.p-8{padding:0.5rem}.z-10{z-index:10}.z-\\[999999\\]{z-index:999999}.left-0{left:0rem}.left-1\\/2{left:50%}.grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\\/2{--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.flex{display:flex}.gap-12{gap:0.75rem}.gap-20{gap:1.25rem}.gap-4{gap:0.25rem}@media (min-width: 750px){.md\\:left-1\\/2{left:50%}.md\\:flex{display:flex}.md\\:hidden{display:none}.md\\:-translate-x-1\\/2{--tw-translate-x:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.md\\:-translate-y-1\\/2{--tw-translate-y:-50%;transform:translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}}";
|
|
4577
|
+
const EdsMatomoNoticeStyle0 = edsMatomoNoticeCss;
|
|
4578
|
+
|
|
4579
|
+
const EdsMatomoNotice = class {
|
|
4580
|
+
constructor(hostRef) {
|
|
4581
|
+
registerInstance(this, hostRef);
|
|
4582
|
+
this.consent = createEvent(this, "consent", 7);
|
|
4583
|
+
this.heading = 'Analytics Consent';
|
|
4584
|
+
this.description = "We use anonymous analytics to improve our services. No data is collected unless you give your consent. If you don't wish to send data right now, you can always re-enable analytics later by clicking the Cookies Preference button in the footer. However, by opting in today, you're joining a community that shapes our product's future—all while keeping your data completely anonymous.";
|
|
4585
|
+
this.optOutMessage = "You are already part of our community, and your anonymous data helps shape our product's future! Rest assured, your privacy is fully protected.";
|
|
4586
|
+
this.forceShow = false;
|
|
4587
|
+
this.showNotice = true;
|
|
4588
|
+
}
|
|
4589
|
+
/**
|
|
4590
|
+
* Listens for global custom events to open the matomo-consent.
|
|
4591
|
+
*/
|
|
4592
|
+
toggleCookiesConsent() {
|
|
4593
|
+
this.showNotice = !this.showNotice;
|
|
4594
|
+
}
|
|
4595
|
+
/**
|
|
4596
|
+
* Checks if the consent cookie exists.
|
|
4597
|
+
*/
|
|
4598
|
+
hasCookieConsent() {
|
|
4599
|
+
return !!document.cookie.split('; ').find((row) => row.startsWith('mtm_consent='));
|
|
4600
|
+
}
|
|
4601
|
+
/**
|
|
4602
|
+
* Checks if the user has opted out after has opted in.
|
|
4603
|
+
*/
|
|
4604
|
+
optedOut() {
|
|
4605
|
+
return !!document.cookie.split('; ').find((row) => row.startsWith('mtm_consent_removed'));
|
|
4606
|
+
}
|
|
4607
|
+
/**
|
|
4608
|
+
* Generate a unique storage key based on appId or the app's domain.
|
|
4609
|
+
*/
|
|
4610
|
+
getStorageKey() {
|
|
4611
|
+
return `${window.location.host}-matomo-deferred`;
|
|
4612
|
+
}
|
|
4613
|
+
/**
|
|
4614
|
+
* Check cookies and sessionStorage (unless forceShow is true) to decide if the notice should be shown.
|
|
4615
|
+
*/
|
|
4616
|
+
componentWillLoad() {
|
|
4617
|
+
// If a decision has been made previously (opted in or out), don't show the notice.
|
|
4618
|
+
const consentGiven = localStorage.getItem(`${window.location.host}-matomo-consent-given`);
|
|
4619
|
+
if (consentGiven === 'out' || this.optedOut()) {
|
|
4620
|
+
this.showNotice = false;
|
|
4621
|
+
return;
|
|
4622
|
+
}
|
|
4623
|
+
if (this.forceShow) {
|
|
4624
|
+
// If forceShow is true, always show the notice
|
|
4625
|
+
this.showNotice = true;
|
|
4626
|
+
}
|
|
4627
|
+
else {
|
|
4628
|
+
// If user has already consented, hide the notice
|
|
4629
|
+
// eslint-disable-next-line
|
|
4630
|
+
if (this.hasCookieConsent()) {
|
|
4631
|
+
this.showNotice = false;
|
|
4632
|
+
}
|
|
4633
|
+
else {
|
|
4634
|
+
// Otherwise check if user deferred in this session
|
|
4635
|
+
const sessionDeferred = sessionStorage.getItem(this.getStorageKey());
|
|
4636
|
+
this.showNotice = !sessionDeferred;
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
}
|
|
4640
|
+
componentDidLoad() {
|
|
4641
|
+
const btns = this.el.shadowRoot.querySelectorAll('eds-button');
|
|
4642
|
+
btns.forEach((b) => {
|
|
4643
|
+
this.emitContext(b);
|
|
4644
|
+
});
|
|
4645
|
+
}
|
|
4646
|
+
emitContext(linkElement) {
|
|
4647
|
+
const event = new CustomEvent('parentContext', {
|
|
4648
|
+
detail: {
|
|
4649
|
+
componentName: this.el.tagName.toLowerCase(),
|
|
4650
|
+
identifier: null
|
|
4651
|
+
}
|
|
4652
|
+
});
|
|
4653
|
+
linkElement.dispatchEvent(event);
|
|
4654
|
+
}
|
|
4655
|
+
optInAnalytics() {
|
|
4656
|
+
matomoOptIn();
|
|
4657
|
+
localStorage.removeItem(`${window.location.host}-matomo-consent-given`);
|
|
4658
|
+
this.hideNotice();
|
|
4659
|
+
this.consent.emit('in');
|
|
4660
|
+
}
|
|
4661
|
+
optOutAnalytics() {
|
|
4662
|
+
matomoOptOut();
|
|
4663
|
+
this.hideNotice();
|
|
4664
|
+
this.consent.emit('out');
|
|
4665
|
+
}
|
|
4666
|
+
noThanks() {
|
|
4667
|
+
matomoOptOut();
|
|
4668
|
+
localStorage.setItem(`${window.location.host}-matomo-consent-given`, 'out');
|
|
4669
|
+
this.hideNotice();
|
|
4670
|
+
this.consent.emit('out');
|
|
4671
|
+
}
|
|
4672
|
+
/*private deferDecision() {
|
|
4673
|
+
sessionStorage.setItem(this.getStorageKey(), 'true');
|
|
4674
|
+
this.hideNotice();
|
|
4675
|
+
this.consent.emit('defer');
|
|
4676
|
+
}*/
|
|
4677
|
+
keepMeIn() {
|
|
4678
|
+
this.hideNotice();
|
|
4679
|
+
}
|
|
4680
|
+
hideNotice() {
|
|
4681
|
+
this.showNotice = false;
|
|
4682
|
+
}
|
|
4683
|
+
render() {
|
|
4684
|
+
if (!this.showNotice) {
|
|
4685
|
+
return null;
|
|
4686
|
+
}
|
|
4687
|
+
return (h("div", { class: "fixed bottom-0 p-8 z-[999999] grow md:left-1/2 md:-translate-x-1/2 md:-translate-y-1/2 justify-center" }, h("eds-accordion", { title: this.heading, description: this.hasCookieConsent() ? this.optOutMessage : this.description, switchBg: true, expanded: true }, this.hasCookieConsent() ? (h("div", { class: "flex items-center gap-4" }, this.optedOut() ? (h("eds-button", { intent: "primary", label: "Opt me in again", "aria-label": "Opt me in again", onClick: () => this.optInAnalytics() })) : (h("eds-button", { intent: "primary", label: "Keep Me In", "aria-label": "Keep Me In", onClick: () => this.keepMeIn() })), h("eds-button", { intent: "ghostInverse", label: "Opt-out", "aria-label": "Opt-out from analytics", onClick: () => this.optOutAnalytics() }))) : (h("div", { class: "flex items-center gap-4" }, h("eds-button", { intent: "primary", label: "I agree", "aria-label": "Opt-in for analytics", onClick: () => this.optInAnalytics() }), h("eds-button", { intent: "ghost", label: "No, thanks", "aria-label": "Opt-out from analytics", onClick: () => this.noThanks() }))))));
|
|
4688
|
+
}
|
|
4689
|
+
get el() { return getElement(this); }
|
|
4690
|
+
};
|
|
4691
|
+
EdsMatomoNotice.style = EdsMatomoNoticeStyle0;
|
|
4692
|
+
|
|
4693
|
+
const edsNpsCss = ".flex{display:flex}.justify-between{justify-content:space-between}.mt-4{margin-top:0.25rem}.mt-8{margin-top:0.5rem}.ml-4{margin-left:0.25rem}.mr-4{margin-right:0.25rem}.grid{display:grid}.grid-col-span-1{--container-grid-columns:1;grid-column:span 1 / span 1}.grid-cols-11{grid-template-columns:repeat(11, minmax(0, 1fr))}.grid-cols-11[class*=\"grid-line-x\"][class*=\"grid-line-x\"]>*:nth-child(n)::before{border-bottom-width:1px}.grid-cols-11[class*=\"grid-line-xfull\"]>*:nth-child(n)::before{inset-inline-start:calc(var(--inner-gutter) / -2);inset-inline-end:calc(var(--inner-gutter) / -2)}.grid-cols-11[class*=\"grid-line-x\"]>*:nth-child(11n+1)::before{inset-inline-start:0}.grid-cols-11[class*=\"grid-line-x\"]>*:nth-child(11n+11)::before{inset-inline-end:0}.grid-cols-11[class*=\"grid-line-x\"]>*:nth-child(11n+1):nth-last-child(-n+11)::before{border-bottom-width:0}.grid-cols-11[class*=\"grid-line-x\"]>*:nth-child(11n+1):nth-last-child(-n+11)~*::before{border-bottom-width:0}.grid-cols-11[class*=\"grid-line-y\"][class*=\"grid-line-y\"]>*:nth-child(n)::after{border-inline-end-width:1px}.grid-cols-11[class*=\"grid-line-y\"][class*=\"grid-line-y\"]>*:nth-child(11n+11)::after{border-inline-end-width:0}.grid-cols-11[class*=\"grid-line-y\"][class*=\"grid-line-y\"]>*:nth-child(-n+11)::after{top:0}.grid-cols-11[class*=\"grid-line-y\"][class*=\"grid-line-y\"]>*:nth-child(11n+1):nth-last-child(-n+11)::after{bottom:0}.grid-cols-11[class*=\"grid-line-y\"][class*=\"grid-line-y\"]>*:nth-child(11n+1):nth-last-child(-n+11)~li::after{bottom:0}.f-ui-04{font-family:var(--f-ui-04-fontFamily);font-weight:var(--f-ui-04-fontWeight);font-size:var(--f-ui-04-fontSize);line-height:var(--f-ui-04-lineHeight);letter-spacing:var(--f-ui-04-letterSpacing)}.text-light{color:var(--grey-700)}";
|
|
4694
|
+
const EdsNpsStyle0 = edsNpsCss;
|
|
4695
|
+
|
|
4696
|
+
const EdsNps = class {
|
|
4697
|
+
constructor(hostRef) {
|
|
4698
|
+
registerInstance(this, hostRef);
|
|
4699
|
+
this.nps = createEvent(this, "nps", 7);
|
|
4700
|
+
this.min = 0;
|
|
4701
|
+
this.max = 10;
|
|
4702
|
+
this.question = undefined;
|
|
4703
|
+
this.leftLabel = undefined;
|
|
4704
|
+
this.rightLabel = undefined;
|
|
4705
|
+
this.selectedValue = null;
|
|
4706
|
+
}
|
|
4707
|
+
handleClick(value) {
|
|
4708
|
+
this.selectedValue = value;
|
|
4709
|
+
this.nps.emit(value);
|
|
4710
|
+
}
|
|
4711
|
+
handleKeyNav(e) {
|
|
4712
|
+
const radios = Array.from(this.el.shadowRoot.querySelectorAll('eds-button'));
|
|
4713
|
+
const currentIndex = radios.findIndex((r) => r.tabIndex === 0);
|
|
4714
|
+
switch (e.key) {
|
|
4715
|
+
case 'ArrowRight':
|
|
4716
|
+
case 'ArrowLeft': {
|
|
4717
|
+
e.preventDefault();
|
|
4718
|
+
const delta = e.key === 'ArrowRight' ? 1 : -1;
|
|
4719
|
+
const nextIndex = Math.min(this.max, Math.max(0, currentIndex + delta));
|
|
4720
|
+
this.activateRadio(radios, nextIndex);
|
|
4721
|
+
break;
|
|
4722
|
+
}
|
|
4723
|
+
case 'Home': {
|
|
4724
|
+
e.preventDefault();
|
|
4725
|
+
this.activateRadio(radios, 0);
|
|
4726
|
+
break;
|
|
4727
|
+
}
|
|
4728
|
+
case 'End': {
|
|
4729
|
+
e.preventDefault();
|
|
4730
|
+
this.activateRadio(radios, this.max);
|
|
4731
|
+
break;
|
|
4732
|
+
}
|
|
4733
|
+
case 'Enter':
|
|
4734
|
+
case ' ': {
|
|
4735
|
+
e.preventDefault();
|
|
4736
|
+
if (currentIndex >= 0) {
|
|
4737
|
+
this.handleClick(this.min + currentIndex);
|
|
4738
|
+
}
|
|
4739
|
+
break;
|
|
4740
|
+
}
|
|
4741
|
+
case 'Escape': {
|
|
4742
|
+
e.preventDefault();
|
|
4743
|
+
if (currentIndex >= 0) {
|
|
4744
|
+
radios[currentIndex].blur();
|
|
4745
|
+
}
|
|
4746
|
+
break;
|
|
4747
|
+
}
|
|
4748
|
+
default:
|
|
4749
|
+
return;
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4752
|
+
activateRadio(radios, index) {
|
|
4753
|
+
const target = radios[index];
|
|
4754
|
+
const value = this.min + index;
|
|
4755
|
+
this.handleClick(value);
|
|
4756
|
+
target.focus();
|
|
4757
|
+
}
|
|
4758
|
+
render() {
|
|
4759
|
+
const count = this.max - this.min + 1;
|
|
4760
|
+
const fallback = 0;
|
|
4761
|
+
return (h("div", { key: 'd675e1e4ecc306511c0324d0b76ee66237cb6738', class: "eds-nps" }, h("eds-input-label", { key: '2eede06f6ee166c36b0cf315a35435c89c3c0ba5', id: "nps-question", name: "nps-question", label: this.question }), h("div", { key: '16105649fe6b3b229127c9a741367a6381db774f', role: "group", id: "nps-buttons", "aria-labelledby": "nps-question", class: "grid grid-cols-11", onKeyDown: (e) => this.handleKeyNav(e) }, Array.from({ length: count }, (_, i) => {
|
|
4762
|
+
const val = this.min + i;
|
|
4763
|
+
const isSelected = val === this.selectedValue;
|
|
4764
|
+
const tabIndex = this.selectedValue === null ? (i === fallback ? 0 : -1) : isSelected ? 0 : -1;
|
|
4765
|
+
return (h("div", { class: "grid-col-span-1", key: val }, h("eds-button", { tabindex: tabIndex, label: `${val}`, "aria-label": `${val}`, intent: isSelected ? 'primary' : 'ghost', "extra-class": "!block !px-0 w-full", triggerClick: () => this.handleClick(val) })));
|
|
4766
|
+
})), h("div", { key: 'e7bd70a4f1a8083d9c3e08fdf8de55999a27d92d', class: "flex justify-between mt-8" }, h("span", { key: 'ea3fbbac20a162e7cf5f2d5e3321c8bc9297014e', class: "f-ui-04 text-light ml-4" }, this.leftLabel), h("span", { key: '3ff59cde0c532587ead8b8a1eaaff6c630e7e7ac', class: "f-ui-04 text-light mr-4" }, this.rightLabel))));
|
|
4767
|
+
}
|
|
4768
|
+
get el() { return getElement(this); }
|
|
4769
|
+
};
|
|
4770
|
+
EdsNps.style = EdsNpsStyle0;
|
|
4771
|
+
|
|
4772
|
+
const edsPaginationCss = "ul,menu{list-style:none;margin:0;padding:0}.f-ui-03{font-family:var(--f-ui-03-fontFamily);font-weight:var(--f-ui-03-fontWeight);font-size:var(--f-ui-03-fontSize);line-height:var(--f-ui-03-lineHeight);letter-spacing:var(--f-ui-03-letterSpacing)}.f-ui-03-light{font-family:var(--f-ui-03-light-fontFamily);font-weight:var(--f-ui-03-light-fontWeight);font-size:var(--f-ui-03-light-fontSize);line-height:var(--f-ui-03-light-lineHeight);letter-spacing:var(--f-ui-03-light-letterSpacing)}.f-ui-02{font-family:var(--f-ui-02-fontFamily);font-weight:var(--f-ui-02-fontWeight);font-size:var(--f-ui-02-fontSize);line-height:var(--f-ui-02-lineHeight);letter-spacing:var(--f-ui-02-letterSpacing)}.f-ui-02-light{font-family:var(--f-ui-02-light-fontFamily);font-weight:var(--f-ui-02-light-fontWeight);font-size:var(--f-ui-02-light-fontSize);line-height:var(--f-ui-02-light-lineHeight);letter-spacing:var(--f-ui-02-light-letterSpacing)}.text-light{color:var(--grey-700)}.text-lightest{color:var(--grey-500)}.mb-28{margin-bottom:1.75rem}.w-full{width:100%}.w-20{width:1.25rem}.h-20{height:1.25rem}.h-28{height:1.75rem}.h-32{height:2rem}.h-36{height:2.25rem}.text-center{text-align:center}.flex{display:flex}.inline-flex{display:inline-flex}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-x-8{-moz-column-gap:0.5rem;column-gap:0.5rem}.mr-auto{margin-right:auto}.ml-auto{margin-left:auto}.\\!p-8{padding:0.5rem !important}.ml-4{margin-left:0.25rem}.mr-4{margin-right:0.25rem}.hidden{display:none}.gap-1{gap:0.0625rem}.py-4{padding-top:0.25rem;padding-bottom:0.25rem}.transition-colors{transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}@media (min-width: 900px){.lg\\:\\!pr-12{padding-right:0.75rem !important}.lg\\:flex{display:flex}}";
|
|
1689
4773
|
const EdsPaginationStyle0 = edsPaginationCss;
|
|
1690
4774
|
|
|
1691
4775
|
const EdsPagination = class {
|
|
1692
4776
|
constructor(hostRef) {
|
|
1693
4777
|
registerInstance(this, hostRef);
|
|
4778
|
+
/**
|
|
4779
|
+
* Handles keyboard navigation within the pagination
|
|
4780
|
+
*/
|
|
4781
|
+
this.handleKeyDown = (e) => {
|
|
4782
|
+
if (this.mode !== 'default' || !this.useButtons) {
|
|
4783
|
+
return;
|
|
4784
|
+
}
|
|
4785
|
+
const navigableItems = this.getNavigableItems();
|
|
4786
|
+
if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
|
|
4787
|
+
e.preventDefault();
|
|
4788
|
+
const increment = e.key === 'ArrowRight' ? 1 : -1;
|
|
4789
|
+
let currentIndex = this.focusedIndex;
|
|
4790
|
+
// If no item is focused, start from current page or first item
|
|
4791
|
+
if (currentIndex === -1) {
|
|
4792
|
+
const currentPageIndex = navigableItems.findIndex((item) => item.type === 'page' && item.page === this.currentPage);
|
|
4793
|
+
currentIndex = currentPageIndex !== -1 ? currentPageIndex : 0;
|
|
4794
|
+
}
|
|
4795
|
+
let newIndex = currentIndex + increment;
|
|
4796
|
+
// Wrap around navigation
|
|
4797
|
+
if (newIndex >= navigableItems.length) {
|
|
4798
|
+
newIndex = 0;
|
|
4799
|
+
}
|
|
4800
|
+
else if (newIndex < 0) {
|
|
4801
|
+
newIndex = navigableItems.length - 1;
|
|
4802
|
+
}
|
|
4803
|
+
this.focusedIndex = newIndex;
|
|
4804
|
+
this.focusPaginationItem(newIndex);
|
|
4805
|
+
}
|
|
4806
|
+
else if (e.key === 'Home') {
|
|
4807
|
+
e.preventDefault();
|
|
4808
|
+
this.focusedIndex = 0;
|
|
4809
|
+
this.focusPaginationItem(0);
|
|
4810
|
+
}
|
|
4811
|
+
else if (e.key === 'End') {
|
|
4812
|
+
e.preventDefault();
|
|
4813
|
+
const lastIndex = navigableItems.length - 1;
|
|
4814
|
+
this.focusedIndex = lastIndex;
|
|
4815
|
+
this.focusPaginationItem(lastIndex);
|
|
4816
|
+
}
|
|
4817
|
+
};
|
|
4818
|
+
/**
|
|
4819
|
+
* Handles focus events for pagination items
|
|
4820
|
+
*/
|
|
4821
|
+
this.handleItemFocus = (index) => {
|
|
4822
|
+
this.focusedIndex = index;
|
|
4823
|
+
};
|
|
1694
4824
|
this.currentPage = undefined;
|
|
1695
4825
|
this.lastPage = undefined;
|
|
1696
4826
|
this.perPage = 10;
|
|
1697
4827
|
this.total = 0;
|
|
1698
4828
|
this.url = '';
|
|
1699
4829
|
this.mode = 'default';
|
|
4830
|
+
this.useButtons = true;
|
|
1700
4831
|
this.prevLabel = 'Prev';
|
|
1701
4832
|
this.nextLabel = 'Next';
|
|
1702
4833
|
this.prevUrl = '';
|
|
1703
4834
|
this.nextUrl = '';
|
|
1704
4835
|
this.links = [];
|
|
4836
|
+
this.focusedIndex = -1;
|
|
1705
4837
|
}
|
|
1706
4838
|
/** Lifecycle hook to generate pagination links on component load */
|
|
1707
4839
|
componentWillLoad() {
|
|
@@ -1710,24 +4842,17 @@ const EdsPagination = class {
|
|
|
1710
4842
|
}
|
|
1711
4843
|
}
|
|
1712
4844
|
componentDidLoad() {
|
|
1713
|
-
//
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
this.emitContext(links[0]);
|
|
1721
|
-
|
|
1722
|
-
// Emit context for the last link, if it's different from the first
|
|
1723
|
-
if (links.length > 1) {
|
|
1724
|
-
this.emitContext(links[links.length - 1]);
|
|
1725
|
-
}
|
|
1726
|
-
}*/
|
|
4845
|
+
// Only emit context for links, not buttons
|
|
4846
|
+
if (!this.useButtons) {
|
|
4847
|
+
const links = this.hostEl.shadowRoot.querySelectorAll('eds-link');
|
|
4848
|
+
links.forEach((lnk) => {
|
|
4849
|
+
this.emitContext(lnk);
|
|
4850
|
+
});
|
|
4851
|
+
}
|
|
1727
4852
|
}
|
|
1728
4853
|
/**
|
|
1729
4854
|
* Emits a custom event called `parentContext` for a given link element.
|
|
1730
|
-
* This event provides context information about the
|
|
4855
|
+
* This event provides context information about the pagination component.
|
|
1731
4856
|
*
|
|
1732
4857
|
* @param linkElement - The link element to which the event will be dispatched.
|
|
1733
4858
|
*/
|
|
@@ -1745,6 +4870,34 @@ const EdsPagination = class {
|
|
|
1745
4870
|
this.generateLinks();
|
|
1746
4871
|
}
|
|
1747
4872
|
}
|
|
4873
|
+
/**
|
|
4874
|
+
* Gets all navigable pagination items for keyboard navigation
|
|
4875
|
+
*/
|
|
4876
|
+
getNavigableItems() {
|
|
4877
|
+
const items = [];
|
|
4878
|
+
// Previous button
|
|
4879
|
+
items.push({ type: 'prev', disabled: this.isFirstPage() });
|
|
4880
|
+
// Page numbers
|
|
4881
|
+
this.links.forEach((link) => {
|
|
4882
|
+
if (typeof link === 'object') {
|
|
4883
|
+
items.push({ type: 'page', page: parseInt(link.label), disabled: false });
|
|
4884
|
+
}
|
|
4885
|
+
});
|
|
4886
|
+
// Next button
|
|
4887
|
+
items.push({ type: 'next', disabled: this.isLastPage() });
|
|
4888
|
+
return items.filter((item) => !item.disabled);
|
|
4889
|
+
}
|
|
4890
|
+
/**
|
|
4891
|
+
* Focuses a specific pagination item by index
|
|
4892
|
+
*/
|
|
4893
|
+
focusPaginationItem(index) {
|
|
4894
|
+
var _a;
|
|
4895
|
+
const buttons = (_a = this.hostEl.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.pagination-button');
|
|
4896
|
+
const targetButton = buttons === null || buttons === void 0 ? void 0 : buttons[index];
|
|
4897
|
+
if (targetButton) {
|
|
4898
|
+
targetButton.focus();
|
|
4899
|
+
}
|
|
4900
|
+
}
|
|
1748
4901
|
/**
|
|
1749
4902
|
* Checks if the current page is the first page
|
|
1750
4903
|
* @returns {boolean} - true if current page is the first page
|
|
@@ -1767,7 +4920,7 @@ const EdsPagination = class {
|
|
|
1767
4920
|
generateLink(page) {
|
|
1768
4921
|
const urlHasQuery = this.url.includes('?');
|
|
1769
4922
|
return {
|
|
1770
|
-
ariaLabel: `
|
|
4923
|
+
ariaLabel: `Go to page ${page}`,
|
|
1771
4924
|
url: `${this.url}${urlHasQuery ? '&' : '?'}page=${page}`,
|
|
1772
4925
|
label: page.toString(),
|
|
1773
4926
|
current: this.currentPage === page,
|
|
@@ -1787,7 +4940,6 @@ const EdsPagination = class {
|
|
|
1787
4940
|
* Creates a pagination range based on delta, current, and total pages
|
|
1788
4941
|
* @param {number} current - Current page number
|
|
1789
4942
|
* @param {number} total - Total number of pages
|
|
1790
|
-
* @param {number} delta - Range of pages to display around the current page
|
|
1791
4943
|
* @returns {(number | string)[]} - Range of page numbers or ellipses
|
|
1792
4944
|
*/
|
|
1793
4945
|
getPaginationGenerator(current, total) {
|
|
@@ -1802,7 +4954,7 @@ const EdsPagination = class {
|
|
|
1802
4954
|
else {
|
|
1803
4955
|
// Always show the first page
|
|
1804
4956
|
range.push(1);
|
|
1805
|
-
// Add ellipsis if there
|
|
4957
|
+
// Add ellipsis if there's a gap between the first page and the current range start
|
|
1806
4958
|
if (current - delta > 2) {
|
|
1807
4959
|
range.push('...');
|
|
1808
4960
|
}
|
|
@@ -1810,7 +4962,7 @@ const EdsPagination = class {
|
|
|
1810
4962
|
for (let i = Math.max(2, current - delta); i <= Math.min(total - 1, current + delta); i++) {
|
|
1811
4963
|
range.push(i);
|
|
1812
4964
|
}
|
|
1813
|
-
// Add ellipsis if there
|
|
4965
|
+
// Add ellipsis if there's a gap between the current range end and the last page
|
|
1814
4966
|
if (current + delta < total - 1) {
|
|
1815
4967
|
range.push('...');
|
|
1816
4968
|
}
|
|
@@ -1825,9 +4977,11 @@ const EdsPagination = class {
|
|
|
1825
4977
|
*/
|
|
1826
4978
|
pageResults() {
|
|
1827
4979
|
if (this.total > 0) {
|
|
4980
|
+
const start = this.perPage * ((this.currentPage || 1) - 1) + 1;
|
|
4981
|
+
const end = Math.min(this.perPage * (this.currentPage || 1), this.total);
|
|
1828
4982
|
return this.total > this.perPage
|
|
1829
|
-
?
|
|
1830
|
-
:
|
|
4983
|
+
? `Showing ${start} to ${end} of ${this.total} results`
|
|
4984
|
+
: `Showing ${this.total} result${this.total !== 1 ? 's' : ''}`;
|
|
1831
4985
|
}
|
|
1832
4986
|
return '';
|
|
1833
4987
|
}
|
|
@@ -1840,7 +4994,9 @@ const EdsPagination = class {
|
|
|
1840
4994
|
if (this.mode === 'navigator') {
|
|
1841
4995
|
return; // No page clicking logic for navigator mode
|
|
1842
4996
|
}
|
|
1843
|
-
|
|
4997
|
+
if (this.useButtons) {
|
|
4998
|
+
event.preventDefault(); // Prevent default for buttons
|
|
4999
|
+
}
|
|
1844
5000
|
if (newPage !== this.currentPage) {
|
|
1845
5001
|
this.links = this.links.map((link) => typeof link === 'object' ? Object.assign(Object.assign({}, link), { current: parseInt(link.label) === newPage }) : link);
|
|
1846
5002
|
const pageChangeEvent = new CustomEvent('page', {
|
|
@@ -1853,38 +5009,25 @@ const EdsPagination = class {
|
|
|
1853
5009
|
}
|
|
1854
5010
|
}
|
|
1855
5011
|
render() {
|
|
1856
|
-
|
|
1857
|
-
|
|
5012
|
+
const navigableIndex = -1; // Track index for keyboard navigation
|
|
5013
|
+
return (h("div", { key: '753a7e573a09e7fcb66eac9e11e00f690c49543d' }, this.total > 0 && this.mode === 'default' && (h("p", { key: '6286d71622614a835d471812a55d5c6bef37a13e', class: "f-ui-03 text-light mb-28 w-full text-center", "aria-live": "polite", id: "pagination-info" }, h("span", { key: 'daa7bfa31e736a40c46641fed88653d51eeabc67', class: "text-light sr-only" }, "Results:"), this.pageResults())), this.mode === 'navigator' || (this.lastPage && this.lastPage > 1) ? (h("nav", { "aria-label": "Pagination Navigation", "aria-describedby": this.mode === 'default' ? 'pagination-info' : undefined, onKeyDown: this.handleKeyDown }, h("ul", { class: "flex items-center justify-center gap-x-8", role: "list" }, h("li", { class: "mr-auto" }, this.useButtons ? (h("div", { class: "pagination-button-wrapper", onFocus: () => this.handleItemFocus(navigableIndex) }, h("eds-button", { label: this.prevLabel, disabled: this.mode === 'navigator' ? !this.prevUrl : this.isFirstPage(), "aria-label": "Go to previous page", icon: "chevron-left", "icon-pos": "left", size: "small", "icon-small": "true", intent: "ghost", "extra-class": "!p-8 lg:!pr-12 pagination-button", onClick: (event) => {
|
|
5014
|
+
if (this.mode === 'default' && !this.isFirstPage()) {
|
|
5015
|
+
this.handlePageClick(event, (this.currentPage || 1) - 1);
|
|
5016
|
+
}
|
|
5017
|
+
} }))) : (h("eds-link", { label: this.prevLabel, url: this.mode === 'navigator'
|
|
5018
|
+
? this.prevUrl || '#'
|
|
1858
5019
|
: this.isFirstPage()
|
|
1859
5020
|
? '#'
|
|
1860
|
-
: this.generateLink(this.currentPage - 1).url, disabled: this.mode === 'navigator'
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
if (this.isFirstPage()) {
|
|
1865
|
-
event.preventDefault(); // Prevent click if disabled
|
|
1866
|
-
}
|
|
1867
|
-
else {
|
|
1868
|
-
this.handlePageClick(event, (this.currentPage || 1) - 1);
|
|
1869
|
-
}
|
|
5021
|
+
: this.generateLink(this.currentPage - 1).url, disabled: this.mode === 'navigator' ? !this.prevUrl : this.isFirstPage(), "aria-label": "Go to previous page", icon: "chevron-left", "icon-pos": "left", size: "small", "icon-small": "true", intent: "strong", "hide-label-on-small-screen": true, class: "!p-8 lg:!pr-12" }))), this.mode === 'default' &&
|
|
5022
|
+
this.links.map((link, index) => (h("li", { key: index, class: "f-ui-02 flex h-36 items-center justify-center" }, typeof link === 'string' ? (h("span", { class: "flex items-center justify-center", "aria-hidden": "true" }, link)) : this.useButtons ? (h("div", { class: "pagination-button-wrapper", onFocus: () => this.handleItemFocus(navigableIndex) }, h("eds-button", { label: link.label, "aria-label": link.current ? `Current page, page ${link.label}` : `Go to page ${link.label}`, "aria-current": link.current ? 'page' : undefined, size: "small", "extra-class": "!p-8 pagination-button", intent: link.current ? 'secondary' : 'ghost', onClick: (event) => this.handlePageClick(event, parseInt(link.label)) }))) : (h("eds-link", { url: link.url, "aria-label": link.ariaLabel, label: link.label, current: link.current, "aria-current": link.current ? 'page' : undefined, size: "small", class: "!p-8", intent: link.current ? 'secondary' : 'ghost', onClick: (event) => this.handlePageClick(event, parseInt(link.label)) }))))), h("li", { class: "ml-auto" }, this.useButtons ? (h("div", { class: "pagination-button-wrapper", onFocus: () => this.handleItemFocus(navigableIndex) }, h("eds-button", { label: this.nextLabel, disabled: this.mode === 'navigator' ? !this.nextUrl : this.isLastPage(), "aria-label": "Go to next page", size: "small", "icon-small": "true", icon: "chevron-right", intent: "ghost", "extra-class": "!p-8 lg:!pl-12 pagination-button", onClick: (event) => {
|
|
5023
|
+
if (this.mode === 'default' && !this.isLastPage()) {
|
|
5024
|
+
this.handlePageClick(event, (this.currentPage || 1) + 1);
|
|
1870
5025
|
}
|
|
1871
|
-
} })), this.mode === '
|
|
1872
|
-
|
|
1873
|
-
? this.nextUrl || '#' // Use nextUrl if provided, otherwise disable with '#'
|
|
5026
|
+
} }))) : (h("eds-link", { label: this.nextLabel, url: this.mode === 'navigator'
|
|
5027
|
+
? this.nextUrl || '#'
|
|
1874
5028
|
: this.isLastPage()
|
|
1875
5029
|
? '#'
|
|
1876
|
-
: this.generateLink(this.currentPage + 1).url, disabled: this.mode === 'navigator'
|
|
1877
|
-
? !this.nextUrl // Disable if nextUrl is not provided
|
|
1878
|
-
: this.isLastPage(), "aria-label": "Next page", size: "small", "icon-small": "true", icon: "chevron-right", intent: "strong", "hide-label-on-small-screen": true, class: "!p-8 lg:!pl-12 flex items-center gap-1 py-4 transition-colors", onClick: (event) => {
|
|
1879
|
-
if (this.mode === 'default') {
|
|
1880
|
-
if (this.isLastPage()) {
|
|
1881
|
-
event.preventDefault(); // Prevent click if disabled
|
|
1882
|
-
}
|
|
1883
|
-
else {
|
|
1884
|
-
this.handlePageClick(event, (this.currentPage || 1) + 1);
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
} }))))) : null));
|
|
5030
|
+
: this.generateLink(this.currentPage + 1).url, disabled: this.mode === 'navigator' ? !this.nextUrl : this.isLastPage(), "aria-label": "Go to next page", size: "small", "icon-small": "true", icon: "chevron-right", intent: "strong", "hide-label-on-small-screen": true, class: "!p-8 lg:!pl-12 flex items-center gap-1 py-4 transition-colors" })))))) : null));
|
|
1888
5031
|
}
|
|
1889
5032
|
get hostEl() { return getElement(this); }
|
|
1890
5033
|
static get watchers() { return {
|
|
@@ -1901,6 +5044,7 @@ const EdsRating = class {
|
|
|
1901
5044
|
constructor(hostRef) {
|
|
1902
5045
|
registerInstance(this, hostRef);
|
|
1903
5046
|
this.rating = createEvent(this, "rating", 7);
|
|
5047
|
+
this.buttonRefs = [];
|
|
1904
5048
|
this.ratingType = 'star';
|
|
1905
5049
|
this.ratingCount = 5;
|
|
1906
5050
|
this.selectedRating = 0;
|
|
@@ -1934,16 +5078,37 @@ const EdsRating = class {
|
|
|
1934
5078
|
* Handles the click event on a star.
|
|
1935
5079
|
* @param rating - The selected rating value.
|
|
1936
5080
|
*/
|
|
1937
|
-
|
|
5081
|
+
onSelect(rating) {
|
|
1938
5082
|
this.selectedRating = rating;
|
|
1939
5083
|
this.rating.emit(rating);
|
|
5084
|
+
setTimeout(() => {
|
|
5085
|
+
const btn = this.buttonRefs[rating - 1];
|
|
5086
|
+
btn === null || btn === void 0 ? void 0 : btn.focus();
|
|
5087
|
+
}, 0);
|
|
5088
|
+
}
|
|
5089
|
+
handleKeyNav(e) {
|
|
5090
|
+
const { key } = e;
|
|
5091
|
+
if (!['ArrowRight', 'ArrowLeft', 'ArrowDown', 'ArrowUp'].includes(key)) {
|
|
5092
|
+
return;
|
|
5093
|
+
}
|
|
5094
|
+
e.preventDefault();
|
|
5095
|
+
const increment = key === 'ArrowRight' || key === 'ArrowDown' ? 1 : -1;
|
|
5096
|
+
let next = (this.selectedRating || 1) + increment;
|
|
5097
|
+
if (next > this.ratingCount) {
|
|
5098
|
+
next = 1;
|
|
5099
|
+
}
|
|
5100
|
+
if (next < 1) {
|
|
5101
|
+
next = this.ratingCount;
|
|
5102
|
+
}
|
|
5103
|
+
this.onSelect(next);
|
|
1940
5104
|
}
|
|
1941
5105
|
render() {
|
|
1942
|
-
return (h("div", { key: '
|
|
5106
|
+
return (h("div", { key: 'bd72970d86f2dbb21d58671fc85feea3011749b3', id: "rating-buttons", role: "radiogroup", "aria-labelledby": "rating", class: "stars flex space-x-1 my-8", onKeyDown: (e) => this.handleKeyNav(e) }, Array.from({ length: this.ratingCount }, (_, index) => {
|
|
1943
5107
|
const starRating = index + 1;
|
|
1944
5108
|
const isSelected = starRating <= this.selectedRating;
|
|
1945
5109
|
// Use the mapping text if available; otherwise, fall back to a generic label.
|
|
1946
|
-
|
|
5110
|
+
const checked = this.selectedRating === starRating;
|
|
5111
|
+
return (h("eds-button", { ref: (el) => (this.buttonRefs[index] = el), icon: this.ratingType, role: "radio", "aria-checked": checked, "aria-label": `${starRating} ${this.ratingType}${starRating > 1 ? 's' : ''}`, onClick: () => this.onSelect(starRating), tabIndex: checked || (this.selectedRating === 0 && index === 0) ? 0 : -1, intent: isSelected ? 'primary' : 'ghost', size: "large", "extra-class": "p-2" // Optional padding or styling for the star button
|
|
1947
5112
|
}));
|
|
1948
5113
|
})));
|
|
1949
5114
|
}
|
|
@@ -2131,6 +5296,66 @@ const EdsStepsV2 = class {
|
|
|
2131
5296
|
};
|
|
2132
5297
|
EdsStepsV2.style = EdsStepsV2Style0;
|
|
2133
5298
|
|
|
5299
|
+
const edsSwitchCss = ":host{display:inline-block}.switch-container{display:inline-flex;align-items:center}.switch-label{font-family:var(--f-ui-02-light-fontFamily);font-weight:var(--f-ui-02-light-fontWeight);font-size:var(--f-ui-02-light-fontSize);line-height:var(--f-ui-02-light-lineHeight);letter-spacing:var(--f-ui-02-light-letterSpacing)}button.switch{position:relative;display:inline-flex;align-items:center;width:50px;height:26px;border:none;border-radius:13px;background-color:#ccc;padding:0;cursor:pointer;transition:background-color 0.2s}button.switch.switch--checked{background-color:var(--green-500)}button.switch.switch--disabled{opacity:0.6;cursor:not-allowed}.switch-handle{position:absolute;width:22px;height:22px;border-radius:50%;background-color:#fff;top:2px;left:2px;transition:transform 0.2s}button.switch.switch--checked .switch-handle{transform:translateX(24px)}.ml-8{margin-left:0.5rem}.mr-8{margin-right:0.5rem}.switch:focus{outline:2px solid #005fcc;outline-offset:2px}.switch:focus:not(:focus-visible){outline:none}.switch:focus-visible{outline-width:3px;outline-offset:2px;outline-color:var(--green-500)}";
|
|
5300
|
+
const EdsSwitchStyle0 = edsSwitchCss;
|
|
5301
|
+
|
|
5302
|
+
const EdsSwitch = class {
|
|
5303
|
+
constructor(hostRef) {
|
|
5304
|
+
registerInstance(this, hostRef);
|
|
5305
|
+
this.uiswitch = createEvent(this, "uiswitch", 7);
|
|
5306
|
+
this.toggleSwitch = () => {
|
|
5307
|
+
if (this.disabled) {
|
|
5308
|
+
return;
|
|
5309
|
+
}
|
|
5310
|
+
this.checked = !this.checked;
|
|
5311
|
+
this.uiswitch.emit({ value: this.checked });
|
|
5312
|
+
sendAnalytics({
|
|
5313
|
+
category: 'ui-component',
|
|
5314
|
+
tag: this.el.tagName.toLowerCase(),
|
|
5315
|
+
name: this.checked ? this.labelOn : this.labelOff || '',
|
|
5316
|
+
action: 'checked'
|
|
5317
|
+
});
|
|
5318
|
+
};
|
|
5319
|
+
this.handleKeyDown = (e) => {
|
|
5320
|
+
if (this.disabled) {
|
|
5321
|
+
return;
|
|
5322
|
+
}
|
|
5323
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
5324
|
+
e.preventDefault();
|
|
5325
|
+
this.toggleSwitch();
|
|
5326
|
+
}
|
|
5327
|
+
};
|
|
5328
|
+
this.checked = false;
|
|
5329
|
+
this.disabled = false;
|
|
5330
|
+
this.labelOn = '';
|
|
5331
|
+
this.labelOff = '';
|
|
5332
|
+
}
|
|
5333
|
+
render() {
|
|
5334
|
+
const switchId = `switch-${Math.random().toString(36).substr(2, 9)}`;
|
|
5335
|
+
const labelledBy = [];
|
|
5336
|
+
if (this.labelOff) {
|
|
5337
|
+
labelledBy.push(`${switchId}-off`);
|
|
5338
|
+
}
|
|
5339
|
+
if (this.labelOn) {
|
|
5340
|
+
labelledBy.push(`${switchId}-on`);
|
|
5341
|
+
}
|
|
5342
|
+
const accessibleLabel = labelledBy.length === 0
|
|
5343
|
+
? this.labelOn || this.labelOff
|
|
5344
|
+
? this.checked
|
|
5345
|
+
? this.labelOn
|
|
5346
|
+
: this.labelOff
|
|
5347
|
+
: 'Toggle switch'
|
|
5348
|
+
: undefined;
|
|
5349
|
+
return (h("div", { key: 'f4c99a2ec360af6030de11698bab82833b3f415f', class: "switch-container" }, this.labelOff && (h("span", { key: '8bb8d063e744c194c0d44a0c371ae8224f9611cb', id: `${switchId}-off`, class: "switch-label switch-label--off mr-8" }, this.labelOff)), h("button", { key: 'ccc49c8ac6f639707c90822e24f3ae3ab8f2c26c', id: switchId, tabindex: this.disabled ? '-1' : '0', type: "button", role: "switch", "aria-checked": this.checked ? 'true' : 'false', "aria-disabled": this.disabled ? 'true' : 'false', "aria-labelledby": labelledBy.length > 0 ? labelledBy.join(' ') : undefined, "aria-label": accessibleLabel, class: {
|
|
5350
|
+
switch: true,
|
|
5351
|
+
'switch--checked': this.checked,
|
|
5352
|
+
'switch--disabled': this.disabled
|
|
5353
|
+
}, onClick: this.toggleSwitch, onKeyDown: this.handleKeyDown, disabled: this.disabled }, h("span", { key: '2275930bc9909c0a95c6c10e28f715fe1afe9294', class: "switch-handle" })), this.labelOn && (h("span", { key: 'd789fd15943c1fadf1f87c55059261eaf5e05a8f', id: `${switchId}-on`, class: "switch-label switch-label--on ml-8" }, this.labelOn))));
|
|
5354
|
+
}
|
|
5355
|
+
get el() { return getElement(this); }
|
|
5356
|
+
};
|
|
5357
|
+
EdsSwitch.style = EdsSwitchStyle0;
|
|
5358
|
+
|
|
2134
5359
|
const edsTableCss = "table{text-indent:0;border-color:inherit;border-collapse:collapse;}.container{width:calc(var(--container-width, 100%) - (2 * var(--breakout-container-outer-gutter, var(--container-outer-gutter, var(--outer-gutter, 0)))));margin-right:auto;margin-left:auto}.container>*{--container-outer-gutter:0;--breakout-container-outer-gutter:0}.pt-32{padding-top:2rem}.pt-40{padding-top:2.5rem}.pt-48{padding-top:3rem}.pb-28{padding-bottom:1.75rem}.pb-60{padding-bottom:3.75rem}.mt-20{margin-top:1.25rem}.mt-28{margin-top:1.75rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.overflow-x-auto{overflow-x:auto}.mt-6{margin-top:0.375rem}.p-0{padding:0rem}.m-0{margin:0rem}.border{border-width:1px}.border-softer{border:1px solid rgba(0, 0, 0, .1)}.even\\:bg-inverse-softer:nth-child(even){background-color:rgba(255, 255, 255, .15)}.px-8{padding-left:0.5rem;padding-right:0.5rem}.px-20{padding-left:1.25rem;padding-right:1.25rem}.py-8{padding-top:0.5rem;padding-bottom:0.5rem}.f-ui-01{font-family:var(--f-ui-01-fontFamily);font-weight:var(--f-ui-01-fontWeight);font-size:var(--f-ui-01-fontSize);line-height:var(--f-ui-01-lineHeight);letter-spacing:var(--f-ui-01-letterSpacing)}.f-ui-02{font-family:var(--f-ui-02-fontFamily);font-weight:var(--f-ui-02-fontWeight);font-size:var(--f-ui-02-fontSize);line-height:var(--f-ui-02-lineHeight);letter-spacing:var(--f-ui-02-letterSpacing)}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.text-center{text-align:center}.break-words{overflow-wrap:anywhere}";
|
|
2135
5360
|
const EdsTableStyle0 = edsTableCss;
|
|
2136
5361
|
|
|
@@ -2141,8 +5366,33 @@ const EdsTable = class {
|
|
|
2141
5366
|
this.handleResize = () => {
|
|
2142
5367
|
this.updateContainerWidth();
|
|
2143
5368
|
};
|
|
5369
|
+
this.onActionKeyDown = (e) => {
|
|
5370
|
+
var _a;
|
|
5371
|
+
if (e.key !== 'ArrowRight' && e.key !== 'ArrowLeft') {
|
|
5372
|
+
return;
|
|
5373
|
+
}
|
|
5374
|
+
e.preventDefault();
|
|
5375
|
+
const currentButton = e.target;
|
|
5376
|
+
const toolbar = currentButton.closest('[role="toolbar"]');
|
|
5377
|
+
if (!toolbar) {
|
|
5378
|
+
return;
|
|
5379
|
+
}
|
|
5380
|
+
// Find all focusable action buttons in this row
|
|
5381
|
+
const actionButtons = Array.from(toolbar.querySelectorAll('eds-button'));
|
|
5382
|
+
const currentIndex = actionButtons.indexOf(currentButton);
|
|
5383
|
+
if (currentIndex === -1) {
|
|
5384
|
+
return;
|
|
5385
|
+
}
|
|
5386
|
+
let nextIndex;
|
|
5387
|
+
if (e.key === 'ArrowRight') {
|
|
5388
|
+
nextIndex = (currentIndex + 1) % actionButtons.length;
|
|
5389
|
+
}
|
|
5390
|
+
else {
|
|
5391
|
+
nextIndex = (currentIndex - 1 + actionButtons.length) % actionButtons.length;
|
|
5392
|
+
}
|
|
5393
|
+
(_a = actionButtons[nextIndex]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5394
|
+
};
|
|
2144
5395
|
this.data = null;
|
|
2145
|
-
this.endpoint = null;
|
|
2146
5396
|
this.config = {};
|
|
2147
5397
|
this.rowsPerPage = 10;
|
|
2148
5398
|
this.paginationEnabled = true;
|
|
@@ -2180,7 +5430,7 @@ const EdsTable = class {
|
|
|
2180
5430
|
componentWillLoad() {
|
|
2181
5431
|
this.parseConfig();
|
|
2182
5432
|
this.handleActionsChange();
|
|
2183
|
-
this.
|
|
5433
|
+
this.parseData();
|
|
2184
5434
|
}
|
|
2185
5435
|
componentDidLoad() {
|
|
2186
5436
|
this.updateContainerWidth();
|
|
@@ -2228,17 +5478,6 @@ const EdsTable = class {
|
|
|
2228
5478
|
this.parsedConfig = {};
|
|
2229
5479
|
}
|
|
2230
5480
|
}
|
|
2231
|
-
async fetchData() {
|
|
2232
|
-
try {
|
|
2233
|
-
const response = await fetch(this.endpoint);
|
|
2234
|
-
const data = await response.json();
|
|
2235
|
-
this.data = data;
|
|
2236
|
-
}
|
|
2237
|
-
catch (error) {
|
|
2238
|
-
// eslint-disable-next-line
|
|
2239
|
-
console.error('Failed to fetch data:', error);
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
5481
|
setupPaginationListener() {
|
|
2243
5482
|
if (!this.shouldEnablePagination()) {
|
|
2244
5483
|
return;
|
|
@@ -2293,7 +5532,8 @@ const EdsTable = class {
|
|
|
2293
5532
|
const checked = !!row[boundField];
|
|
2294
5533
|
return (h("eds-input-field", { name: `chc-${actionName}`, label: act.label, type: "checkbox", checked: checked, onChange: (e) => this.emitAction(act.name, row, e.target.checked) }));
|
|
2295
5534
|
}
|
|
2296
|
-
|
|
5535
|
+
// Let all action buttons be focusable naturally
|
|
5536
|
+
return (h("eds-button", { label: act.label, icon: act.icon, pill: true, size: "small", intent: "ghost", tabIndex: 0, onClick: () => this.emitAction(act.name, row) }));
|
|
2297
5537
|
}
|
|
2298
5538
|
emitAction(actionName, row, checked) {
|
|
2299
5539
|
sendAnalytics({
|
|
@@ -2339,7 +5579,7 @@ const EdsTable = class {
|
|
|
2339
5579
|
const columnWidth = visibleColumnsCount > 0 ? Math.floor((currentContainerWidth / visibleColumnsCount) * this.divisionFactor()) : 100;
|
|
2340
5580
|
const paginatedRows = this.getPaginatedRows();
|
|
2341
5581
|
const lastPage = Math.ceil(this.totalRows / this.rowsPerPage);
|
|
2342
|
-
return (h("div", { key: '
|
|
5582
|
+
return (h("div", { key: '87e7cc3c87618ede91bb51d7a07cd597a438d6c5' }, this.searchEnabled && (h("div", { key: '6b77700a913e272eef4c932d40c5c5d001ff6b5c' }, h("eds-input-field", { key: 1, name: "search", "aria-label": "Search", type: "text", placeholder: "Search...", onInput: (event) => this.handleSearch(event) }))), h("div", { key: '6f2ffc7a3ba2cc8e8194670a7ecb9e237f7dc60a', class: "mt-20" }, h("table", { key: '0227d3029f30ab9928cd01ba8dc2eccde2073f47', class: "block overflow-x-auto mt-6 p-0" }, h("thead", { key: 'c1f844d8413b596d5ca07d6b79ebd36c8a17f51f' }, h("tr", { key: 'caadaaf66314e3ea7d47a748b6e899389a7e2d55', class: "m-0 p-0 border border-softer even:bg-inverse-softer" }, this.columns.map((col) => {
|
|
2343
5583
|
var _a;
|
|
2344
5584
|
if (col === 'actions') {
|
|
2345
5585
|
return (h("th", { class: "m-0 py-8 border border-softer f-ui-02 break-words", style: { minWidth: `${columnWidth - 4}px` } }));
|
|
@@ -2348,17 +5588,22 @@ const EdsTable = class {
|
|
|
2348
5588
|
return (h("th", { class: "m-0 py-8 border border-softer f-ui-02 break-words", style: { minWidth: `${columnWidth - 4}px` } }, this.capitalize(col)));
|
|
2349
5589
|
}
|
|
2350
5590
|
return null;
|
|
2351
|
-
}))), h("tbody", { key: '
|
|
5591
|
+
}))), h("tbody", { key: 'da9286063f16a5c346ce8854361cb15573166a19' }, paginatedRows.map((row) => (h("tr", { class: "m-0 p-0 border border-softer even:bg-inverse-softer" }, this.columns.map((col) => {
|
|
2352
5592
|
var _a;
|
|
2353
5593
|
if (col === 'actions') {
|
|
2354
|
-
return (h("td", { class: "text-center border border-softer m-0 f-ui-02 break-words actions-cell", style: { minWidth: `${columnWidth - 4}px` } }, h("div", {
|
|
5594
|
+
return (h("td", { class: "text-center border border-softer m-0 f-ui-02 break-words actions-cell", style: { minWidth: `${columnWidth - 4}px` } }, h("div", { role: "toolbar", "aria-label": "Row actions", onKeyDown: this.onActionKeyDown, style: {
|
|
5595
|
+
display: 'flex',
|
|
5596
|
+
gap: '0.5rem',
|
|
5597
|
+
justifyContent: 'center',
|
|
5598
|
+
flexWrap: 'wrap'
|
|
5599
|
+
} }, this.parsedActions.map((act) => (h("span", { style: { whiteSpace: 'nowrap' } }, this.renderSingleActionCell(act.name, row)))))));
|
|
2355
5600
|
}
|
|
2356
5601
|
if (!((_a = this.parsedConfig[col]) === null || _a === void 0 ? void 0 : _a.hidden)) {
|
|
2357
5602
|
// Regular data cell
|
|
2358
5603
|
return (h("td", { class: "text-center border border-softer m-0 py-8 f-ui-2 break-words", style: { minWidth: `${columnWidth - 4}px` } }, this.renderCell(row[col], col)));
|
|
2359
5604
|
}
|
|
2360
5605
|
return null;
|
|
2361
|
-
}))))))), this.shouldEnablePagination() && (h("div", { key: '
|
|
5606
|
+
}))))))), this.shouldEnablePagination() && (h("div", { key: 'b7e7991225cf9fb16ca882dc42c7adead202aac5', class: "mt-20" }, h("eds-pagination", { key: '011f209f89300357e6052ee4d118f353419d5a45', currentPage: this.currentPage, lastPage: lastPage, perPage: this.rowsPerPage, total: this.totalRows, mode: "default" })))));
|
|
2362
5607
|
}
|
|
2363
5608
|
get hostEl() { return getElement(this); }
|
|
2364
5609
|
static get watchers() { return {
|
|
@@ -2369,22 +5614,27 @@ const EdsTable = class {
|
|
|
2369
5614
|
};
|
|
2370
5615
|
EdsTable.style = EdsTableStyle0;
|
|
2371
5616
|
|
|
2372
|
-
const edsTabsCss = "*,::before,::after{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(147 197 253 / 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}*,::before,::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor;}::before,::after{--tw-content:''}a{color:inherit;text-decoration:inherit}.relative{position:relative}.f-ui-03{font-family:var(--f-ui-03-fontFamily);font-weight:var(--f-ui-03-fontWeight);font-size:var(--f-ui-03-fontSize);line-height:var(--f-ui-03-lineHeight);letter-spacing:var(--f-ui-03-letterSpacing)}.whitespace-nowrap{white-space:nowrap}.effect-
|
|
5617
|
+
const edsTabsCss = "*,::before,::after{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scroll-snap-strictness:proximity;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgb(147 197 253 / 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;}*,::before,::after{box-sizing:border-box;border-width:0;border-style:solid;border-color:currentColor;}::before,::after{--tw-content:''}a{color:inherit;text-decoration:inherit}.relative{position:relative}.f-ui-03{font-family:var(--f-ui-03-fontFamily);font-weight:var(--f-ui-03-fontWeight);font-size:var(--f-ui-03-fontSize);line-height:var(--f-ui-03-lineHeight);letter-spacing:var(--f-ui-03-letterSpacing)}.whitespace-nowrap{white-space:nowrap}.effect-focus{outline-width:3px;outline-offset:2px;outline-color:var(--green-500)}.effect-focus:focus-visible{outline-style:solid}.effect-focus-within{outline-width:3px;outline-offset:2px;outline-color:var(--green-500)}.focus-visible\\:text-default:focus-visible{color:var(--black)}.hover\\:text-default:hover{color:var(--black)}.border-2{border-width:2px}.after\\:content-\\[\\'\\'\\]::after{--tw-content:'';content:var(--tw-content)}.after\\:bottom-0::after{bottom:0rem}.after\\:border-0::after{border-width:0px}.after\\:border-b-2::after{border-bottom-width:2px}.after\\:absolute::after{position:absolute}.after\\:inset-0::after{inset:0rem}.after\\:rounded-lg::after{border-radius:16px}.after\\:border-solid::after{border-style:solid}.after\\:border-3::after{border-width:3px}.after\\:border-accent::after{border-color:var(--green-500)}.after\\:opacity-0::after{opacity:0}.outline-none{outline:2px solid transparent;outline-offset:2px}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus-visible\\:after\\:opacity-100:focus-visible::after{opacity:1}.rounded-t-lg{border-top-left-radius:16px;border-top-right-radius:16px}.rounded-tl-lg{border-top-left-radius:16px}.rounded-tr-lg{border-top-right-radius:16px}.border-l-0{border-left-width:0px}.border-r-0{border-right-width:0px}.border-b-0{border-bottom-width:0px}.pr-28{padding-right:1.75rem}.pl-28{padding-left:1.75rem}.-mr-16{margin-right:-1rem}.-ml-16{margin-left:-1rem}.px-16{padding-left:1rem;padding-right:1rem}.py-12{padding-top:0.75rem;padding-bottom:0.75rem}.after\\:left-16::after{left:1rem}.after\\:right-16::after{right:1rem}.text-lighter{color:var(--grey-600)}.bg-dark{background-color:var(--grey-300)}.hover\\:bg-darker:hover{background-color:var(--grey-400)}.border-soft{border-color:var(--grey-400)}.border-softest{border-color:rgba(0, 0, 0, .05)}.bg-default{background-color:var(--grey-200)}.text-default{color:var(--black)}.z-99{z-index:99}.after\\:z-10::after{z-index:10}.before\\:bottom-0::before{bottom:0rem}.before\\:h-12::before{height:0.75rem}.before\\:opacity-5::before{opacity:0.05}.before\\:content-\\[\\'\\'\\]::before{--tw-content:'';content:var(--tw-content)}.before\\:absolute::before{position:absolute}.before\\:-bottom-2::before{bottom:-0.125rem}.after\\:inset-x-0::after{left:0rem;right:0rem}.before\\:inset-x-0::before{left:0rem;right:0rem}.before\\:h-3::before{height:0.1875rem}.before\\:bg-default::before{background-color:var(--grey-200)}.after\\:border-soft::after{border-color:rgba(0, 0, 0, .15 )}.after\\:border-softest::after{border-color:rgba(0, 0, 0, .05)}.overflow-x-hidden{overflow-x:hidden}.overflow-y-auto{overflow-y:auto}.before\\:bg-gradient-y::before{background:linear-gradient(to bottom, transparent, ease-in-out, black)}.scroller-x{-ms-overflow-style:none;scrollbar-width:none}.overflow-x-auto{overflow-x:auto}.max-w-xxxl{max-width:2200px}.z-1{z-index:1}.mx-auto{margin-left:auto;margin-right:auto}.pt-8{padding-top:0.5rem}.pr-16{padding-right:1rem}.pl-16{padding-left:1rem}.inline-flex{display:inline-flex}@media (min-width: 900px){.lg\\:px-28{padding-left:1.75rem;padding-right:1.75rem}}@media (min-width: 2200px){.xxxl\\:px-0{padding-left:0rem;padding-right:0rem}}";
|
|
2373
5618
|
const EdsTabsStyle0 = edsTabsCss;
|
|
2374
5619
|
|
|
2375
5620
|
const EdsTabs = class {
|
|
2376
5621
|
constructor(hostRef) {
|
|
2377
5622
|
registerInstance(this, hostRef);
|
|
2378
5623
|
this.tab = createEvent(this, "tab", 7);
|
|
5624
|
+
this.tabRefs = [];
|
|
5625
|
+
// Store tab reference
|
|
5626
|
+
this.setTabRef = (el, index) => {
|
|
5627
|
+
if (el) {
|
|
5628
|
+
this.tabRefs[index] = el;
|
|
5629
|
+
}
|
|
5630
|
+
};
|
|
2379
5631
|
// cva configuration
|
|
2380
5632
|
this.tabCva = cva([
|
|
2381
5633
|
'relative py-12',
|
|
2382
5634
|
'f-ui-03 whitespace-nowrap',
|
|
2383
|
-
'effect-color',
|
|
5635
|
+
'effect-color effect-focus',
|
|
2384
5636
|
'focus-visible:text-default hover:text-default',
|
|
2385
|
-
'border-2'
|
|
2386
|
-
"after:content-[''] after:absolute after:inset-0 after:rounded-t-lg after:opacity-0",
|
|
2387
|
-
'outline-none focus:outline-none focus-visible:outline-none focus-visible:after:opacity-100'
|
|
5637
|
+
'border-2'
|
|
2388
5638
|
], {
|
|
2389
5639
|
variants: {
|
|
2390
5640
|
position: {
|
|
@@ -2394,7 +5644,10 @@ const EdsTabs = class {
|
|
|
2394
5644
|
right: 'pl-28 pr-16 rounded-tr-lg border-l-0 -ml-16 after:left-16'
|
|
2395
5645
|
},
|
|
2396
5646
|
active: {
|
|
2397
|
-
false:
|
|
5647
|
+
false: [
|
|
5648
|
+
'text-lighter bg-dark hover:bg-darker border-softest border-b-0 z-1',
|
|
5649
|
+
"after:content-[''] after:absolute after:bottom-0 after:inset-x-0 after:h-2 after:border-soft"
|
|
5650
|
+
],
|
|
2398
5651
|
true: [
|
|
2399
5652
|
'bg-default text-default z-99',
|
|
2400
5653
|
'rounded-t-lg',
|
|
@@ -2413,28 +5666,35 @@ const EdsTabs = class {
|
|
|
2413
5666
|
componentWillLoad() {
|
|
2414
5667
|
this.parseTabs();
|
|
2415
5668
|
this.setActiveIndex();
|
|
2416
|
-
this.tab.emit({ tabId: this.identifier, index:
|
|
5669
|
+
this.tab.emit({ tabId: this.identifier, index: this.activeIndex });
|
|
2417
5670
|
}
|
|
2418
5671
|
/**
|
|
2419
|
-
* Parses the `
|
|
2420
|
-
* Returns an empty array if parsing fails or if `
|
|
2421
|
-
*
|
|
2422
|
-
* @returns {any[]} Array of parsed link objects
|
|
2423
|
-
*/
|
|
2424
|
-
/**
|
|
2425
|
-
* Parses the `links` prop into an array of link objects.
|
|
2426
|
-
* Returns an empty array if parsing fails or if `links` is not a valid JSON string or object.
|
|
5672
|
+
* Parses the `tabs` prop into an array of tab objects.
|
|
5673
|
+
* Returns an empty array if parsing fails or if `tabs` is not a valid JSON string or object.
|
|
2427
5674
|
*
|
|
2428
|
-
* @returns {any[]} Array of parsed
|
|
5675
|
+
* @returns {any[]} Array of parsed tab objects
|
|
2429
5676
|
*/
|
|
2430
5677
|
parseTabs() {
|
|
2431
5678
|
this.parsedTabs = parseData(this.tabs);
|
|
5679
|
+
// Reset tab refs when tabs change
|
|
5680
|
+
this.tabRefs = [];
|
|
2432
5681
|
}
|
|
2433
5682
|
componentDidLoad() {
|
|
2434
5683
|
this.scrollToActiveTab();
|
|
2435
5684
|
}
|
|
5685
|
+
componentDidUpdate() {
|
|
5686
|
+
// Ensure we have the correct number of tab refs after render
|
|
5687
|
+
if (this.tabRefs.length !== this.parsedTabs.length) {
|
|
5688
|
+
this.tabRefs = new Array(this.parsedTabs.length).fill(null);
|
|
5689
|
+
}
|
|
5690
|
+
}
|
|
2436
5691
|
setActiveIndex() {
|
|
2437
5692
|
this.activeIndex = this.parsedTabs.findIndex((tab) => tab.active);
|
|
5693
|
+
// If no active tab found, default to first tab
|
|
5694
|
+
if (this.activeIndex === -1 && this.parsedTabs.length > 0) {
|
|
5695
|
+
this.activeIndex = 0;
|
|
5696
|
+
this.parsedTabs[0].active = true;
|
|
5697
|
+
}
|
|
2438
5698
|
}
|
|
2439
5699
|
scrollToActiveTab() {
|
|
2440
5700
|
var _a;
|
|
@@ -2456,31 +5716,74 @@ const EdsTabs = class {
|
|
|
2456
5716
|
: index < this.activeIndex
|
|
2457
5717
|
? 'left'
|
|
2458
5718
|
: 'right';
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
5719
|
+
const rawZ = position === 'left' ? index : this.parsedTabs.length + 1 - index;
|
|
5720
|
+
// clamp inactive to at least 1
|
|
5721
|
+
const z = active ? this.parsedTabs.length + 99 : Math.max(rawZ, 1);
|
|
5722
|
+
return Object.assign({ class: this.tabCva({ active, position }), style: {
|
|
5723
|
+
// stringify the number so it matches { [key: string]: string }
|
|
5724
|
+
zIndex: `${z}`
|
|
2464
5725
|
} }, (active ? { 'data-tab-active': 'true' } : {}));
|
|
2465
5726
|
}
|
|
2466
|
-
handleTabClick(index, tabLabel) {
|
|
5727
|
+
handleTabClick(index, tabLabel, shouldFocus = true) {
|
|
5728
|
+
// Validate index
|
|
5729
|
+
if (index < 0 || index >= this.parsedTabs.length) {
|
|
5730
|
+
return;
|
|
5731
|
+
}
|
|
2467
5732
|
// Update the active index and set all tabs' active state accordingly
|
|
2468
5733
|
this.activeIndex = index;
|
|
2469
5734
|
this.parsedTabs = this.parsedTabs.map((tab, tabIndex) => (Object.assign(Object.assign({}, tab), { active: tabIndex === index })));
|
|
2470
5735
|
this.tab.emit({ tabId: this.identifier, index: index, name: tabLabel });
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
5736
|
+
// Only send analytics for actual clicks, not keyboard navigation
|
|
5737
|
+
if (shouldFocus) {
|
|
5738
|
+
sendAnalytics({
|
|
5739
|
+
category: 'ui-component',
|
|
5740
|
+
tag: this.el.tagName.toLowerCase(),
|
|
5741
|
+
name: (tabLabel === null || tabLabel === void 0 ? void 0 : tabLabel.toLowerCase()) || '',
|
|
5742
|
+
action: 'click'
|
|
5743
|
+
});
|
|
5744
|
+
}
|
|
5745
|
+
// Focus management for keyboard navigation
|
|
5746
|
+
if (shouldFocus && this.tabRefs[index]) {
|
|
5747
|
+
// Use a small timeout to ensure the DOM has updated
|
|
5748
|
+
setTimeout(() => {
|
|
5749
|
+
var _a;
|
|
5750
|
+
(_a = this.tabRefs[index]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
5751
|
+
}, 0);
|
|
5752
|
+
}
|
|
5753
|
+
}
|
|
5754
|
+
onKeyDown(ev, idx) {
|
|
5755
|
+
let newIndex = idx;
|
|
5756
|
+
switch (ev.key) {
|
|
5757
|
+
case 'ArrowRight':
|
|
5758
|
+
newIndex = (idx + 1) % this.parsedTabs.length;
|
|
5759
|
+
ev.preventDefault();
|
|
5760
|
+
break;
|
|
5761
|
+
case 'ArrowLeft':
|
|
5762
|
+
newIndex = (idx - 1 + this.parsedTabs.length) % this.parsedTabs.length;
|
|
5763
|
+
ev.preventDefault();
|
|
5764
|
+
break;
|
|
5765
|
+
case 'Home':
|
|
5766
|
+
newIndex = 0;
|
|
5767
|
+
ev.preventDefault();
|
|
5768
|
+
break;
|
|
5769
|
+
case 'End':
|
|
5770
|
+
newIndex = this.parsedTabs.length - 1;
|
|
5771
|
+
ev.preventDefault();
|
|
5772
|
+
break;
|
|
5773
|
+
default:
|
|
5774
|
+
return; // Don't handle other keys
|
|
5775
|
+
}
|
|
5776
|
+
if (newIndex !== idx) {
|
|
5777
|
+
this.handleTabClick(newIndex, this.parsedTabs[newIndex].label, true);
|
|
5778
|
+
}
|
|
2477
5779
|
}
|
|
2478
5780
|
render() {
|
|
2479
|
-
return (h("div", { key: '
|
|
2480
|
-
const TabComponent =
|
|
5781
|
+
return (h("div", { key: 'e3bd802f08f460d5f3e89860669fefe2a8006e59', id: `${this.identifier}` }, h("div", { key: 'bcbd4afb8febec0520075c8e34269f184e2d9738', class: "scroller-x overflow-x-auto relative z-[1] mx-auto px-16 pt-8 lg:px-28 after:border-soft before:bg-gradient-y relative overflow-x-hidden before:absolute before:inset-x-0 before:bottom-0 before:h-12 before:opacity-5 before:content-[''] after:absolute after:inset-x-0 after:bottom-0 after:border-b-2 after:content-['']" }, h("nav", { key: '32e93b3ee6831918fd863fb23f1a5af1ae979201', role: "tablist", ref: (el) => (this.tabContainer = el), class: "inline-flex", "aria-label": this.navAriaLabel }, this.parsedTabs.map((tab, index) => {
|
|
5782
|
+
const TabComponent = 'button';
|
|
2481
5783
|
const tabProps = this.getTabOptions(tab.active, index);
|
|
2482
|
-
|
|
2483
|
-
|
|
5784
|
+
const isActive = index === this.activeIndex;
|
|
5785
|
+
return (h(TabComponent, Object.assign({}, tabProps, { type: "button", role: "tab", "aria-selected": tab.active ? 'true' : 'false', tabIndex: isActive ? 0 : -1, "aria-label": tab.ariaLabel || tab.label, "aria-controls": `panel-${index}`, id: `tab-${index}`, ref: (el) => this.setTabRef(el, index), onClick: () => this.handleTabClick(index, tab.label, true), onKeyDown: (e) => this.onKeyDown(e, index) }), tab.label || tab.ariaLabel));
|
|
5786
|
+
}))), h("div", { key: 'ffe610574d342933121cbaca9bcb8fb483fde60b', class: "tab-panels" }, this.parsedTabs.map((_, index) => (h("div", { role: "tabpanel", id: `panel-${index}`, "aria-labelledby": `tab-${index}`, hidden: index !== this.activeIndex, tabIndex: index === this.activeIndex ? 0 : -1, class: "effect-focus" }, h("slot", { name: `panel-${index}` })))))));
|
|
2484
5787
|
}
|
|
2485
5788
|
get el() { return getElement(this); }
|
|
2486
5789
|
static get watchers() { return {
|
|
@@ -2525,7 +5828,7 @@ const EdsTag = class {
|
|
|
2525
5828
|
}
|
|
2526
5829
|
render() {
|
|
2527
5830
|
const classes = tagStyles({ intent: this.intent, size: this.size });
|
|
2528
|
-
return h("span", { key: '
|
|
5831
|
+
return h("span", { key: '939fafa4bc525b747956931f49b27e6125ecbb34', class: classes }, this.label);
|
|
2529
5832
|
}
|
|
2530
5833
|
};
|
|
2531
5834
|
EdsTag.style = EdsTagStyle0;
|
|
@@ -2633,10 +5936,10 @@ const EdsUser = class {
|
|
|
2633
5936
|
}
|
|
2634
5937
|
render() {
|
|
2635
5938
|
const user = this.parsedUser;
|
|
2636
|
-
return (h("div", { key: '
|
|
5939
|
+
return (h("div", { key: '8a1f10cc85d8e2707042c85bc597b76fb2d25da4', class: "block" }, h("div", { key: 'a744de3d113920b8ff0d01ce273672b2bff57c97', class: "flex items-center" }, h("eds-dropdown", { key: 'e9230372d79936a785050ebb3e41f40e73282a57', label: `Hi, ${user.preferred_username}`, intent: "tertiary", "aria-label": "User Menu", "dropdown-pos": "right", "dropdown-offset": "false", icon: "chevron-down", class: "text-default" }, h("div", { key: '7d4bd0ee0985c840a18764cac784726ff1c987fb', class: "min-w-[280px] p-8" }, h("div", { key: '603d6807988dd79cd4e7827918ff8932d8463fc3', class: "flex gap-x-16" }, h("eds-avatar", { key: '65ba89139cb6e3b6cb90c2072eb68cc7dc1da49c', "first-name": user.given_name, "last-name": user.family_name, initials: this.initials, color: "grey" }), h("div", { key: 'df35b758918ebccbdfe6630bd356e647522404e1', class: "max-w-full" }, user.name && h("p", { key: '7174f34445bb1a0b77a3c1b893421bd104832485', class: "f-ui-01 text-default w-full text-ellipsis" }, user.name), user.preferred_username && h("p", { key: '72d853f5014c03803dce7aa0a74d96847ed8c875', class: "f-ui-03-light text-light mt-4" }, user.preferred_username), user.email && h("p", { key: 'e406e2f3ca8504220ee9586a1d176c15c7236502', class: "f-ui-03-light text-light mt-4" }, user.email))), h("div", { key: '8fd3b42ab4eb3d1d70a0b827e3a03af8503c55d1', class: "text-default flex w-full flex-col gap-y-8" }, h("slot", { key: '6a477155c256543b7793947d52feb3f5abb0df6e' })))))));
|
|
2637
5940
|
}
|
|
2638
5941
|
get hostEl() { return getElement(this); }
|
|
2639
5942
|
};
|
|
2640
5943
|
EdsUser.style = EdsUserStyle0;
|
|
2641
5944
|
|
|
2642
|
-
export { EdsAvatar as eds_avatar, EdsBlockBreak as eds_block_break, EdsButton as eds_button, EdsDropdown as eds_dropdown, EdsForm as eds_form, EdsHeader as eds_header, EdsIconWrapper as eds_icon_wrapper, EdsImg as eds_img, EdsInput as eds_input, EdsInputField as eds_input_field, EdsInputFooter as eds_input_footer, EdsInputLabel as eds_input_label, EdsInputRange as eds_input_range, EdsInputSearch as eds_input_search, EdsInputSelect as eds_input_select, EdsLink as eds_link, EdsLogo as eds_logo, EdsPagination as eds_pagination, EdsRating as eds_rating, EdsSteps as eds_steps, EdsStepsV2 as eds_steps_v2, EdsTable as eds_table, EdsTabs as eds_tabs, EdsTag as eds_tag, EdsToast as eds_toast, EdsUser as eds_user };
|
|
5945
|
+
export { EdsAccordion as eds_accordion, EdsAlert as eds_alert, EdsAvatar as eds_avatar, EdsBlockBreak as eds_block_break, EdsBreadcrumb as eds_breadcrumb, EdsButton as eds_button, EdsCodeBlock as eds_code_block, EdsDropdown as eds_dropdown, EdsForm as eds_form, EdsHeader as eds_header, EdsIconWrapper as eds_icon_wrapper, EdsImg as eds_img, EdsInput as eds_input, EdsInputField as eds_input_field, EdsInputFooter as eds_input_footer, EdsInputLabel as eds_input_label, EdsInputRange as eds_input_range, EdsInputSearch as eds_input_search, EdsInputSelect as eds_input_select, EdsLink as eds_link, EdsLogo as eds_logo, EdsMatomoNotice as eds_matomo_notice, EdsNps as eds_nps, EdsPagination as eds_pagination, EdsRating as eds_rating, EdsSteps as eds_steps, EdsStepsV2 as eds_steps_v2, EdsSwitch as eds_switch, EdsTable as eds_table, EdsTabs as eds_tabs, EdsTag as eds_tag, EdsToast as eds_toast, EdsUser as eds_user };
|