@adyen/bento-vue2 1.22.0 → 1.24.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/README.md +2 -0
- package/dist/@types/index.d.ts +346 -258
- package/dist/accordion.js +3 -3
- package/dist/action-bar.js +7 -7
- package/dist/alert.js +73 -54
- package/dist/alert.js.map +1 -1
- package/dist/assets/base-modal.css +1 -1
- package/dist/assets/button.css +1 -1
- package/dist/assets/dialog-page.css +1 -1
- package/dist/assets/grid-layout.css +1 -1
- package/dist/assets/index10.css +1 -1
- package/dist/assets/index11.css +1 -1
- package/dist/assets/index12.css +1 -1
- package/dist/assets/index13.css +1 -1
- package/dist/assets/index14.css +1 -1
- package/dist/assets/index15.css +1 -1
- package/dist/assets/index16.css +1 -1
- package/dist/assets/index17.css +1 -1
- package/dist/assets/index18.css +1 -1
- package/dist/assets/index19.css +1 -1
- package/dist/assets/index2.css +1 -1
- package/dist/assets/index20.css +1 -1
- package/dist/assets/index21.css +1 -1
- package/dist/assets/index22.css +1 -1
- package/dist/assets/index23.css +1 -1
- package/dist/assets/index24.css +1 -1
- package/dist/assets/index25.css +1 -1
- package/dist/assets/index26.css +1 -1
- package/dist/assets/index27.css +1 -1
- package/dist/assets/index28.css +1 -1
- package/dist/assets/index29.css +1 -1
- package/dist/assets/index3.css +1 -1
- package/dist/assets/index30.css +1 -1
- package/dist/assets/index31.css +1 -1
- package/dist/assets/index32.css +1 -1
- package/dist/assets/index33.css +1 -1
- package/dist/assets/index34.css +1 -1
- package/dist/assets/index35.css +1 -1
- package/dist/assets/index36.css +1 -1
- package/dist/assets/index37.css +1 -1
- package/dist/assets/index38.css +1 -1
- package/dist/assets/index39.css +1 -1
- package/dist/assets/index4.css +1 -1
- package/dist/assets/index40.css +1 -1
- package/dist/assets/index41.css +1 -1
- package/dist/assets/index42.css +1 -1
- package/dist/assets/index43.css +1 -1
- package/dist/assets/index44.css +1 -1
- package/dist/assets/index45.css +1 -1
- package/dist/assets/index46.css +1 -1
- package/dist/assets/index47.css +1 -1
- package/dist/assets/index48.css +1 -1
- package/dist/assets/index5.css +1 -1
- package/dist/assets/index6.css +1 -1
- package/dist/assets/index7.css +1 -1
- package/dist/assets/index8.css +1 -1
- package/dist/assets/index9.css +1 -1
- package/dist/avatar-image.js +1 -1
- package/dist/button.js +5 -5
- package/dist/card.js +4 -4
- package/dist/checkbox.js +6 -6
- package/dist/chunks/{base-button.6bd3ae4d.js → base-button.090f511d.js} +2 -2
- package/dist/chunks/{base-button.6bd3ae4d.js.map → base-button.090f511d.js.map} +1 -1
- package/dist/chunks/{base-modal.bf917e7d.js → base-modal.aa09a60c.js} +7 -7
- package/dist/chunks/{base-modal.bf917e7d.js.map → base-modal.aa09a60c.js.map} +1 -1
- package/dist/chunks/{button-actions-with-menu.ec7dfc53.js → button-actions-with-menu.879c4573.js} +4 -4
- package/dist/chunks/{button-actions-with-menu.ec7dfc53.js.map → button-actions-with-menu.879c4573.js.map} +1 -1
- package/dist/chunks/{button-actions.2bf1d9d1.js → button-actions.239456cb.js} +3 -3
- package/dist/chunks/{button-actions.2bf1d9d1.js.map → button-actions.239456cb.js.map} +1 -1
- package/dist/chunks/{button.80c3c527.js → button.6e6324f0.js} +3 -3
- package/dist/chunks/{button.80c3c527.js.map → button.6e6324f0.js.map} +1 -1
- package/dist/chunks/{calendar.8cbb911d.js → calendar.1e416969.js} +5 -5
- package/dist/chunks/{calendar.8cbb911d.js.map → calendar.1e416969.js.map} +1 -1
- package/dist/chunks/{checkbox-input.17e832f1.js → checkbox-input.1c3cc8ed.js} +2 -2
- package/dist/chunks/{checkbox-input.17e832f1.js.map → checkbox-input.1c3cc8ed.js.map} +1 -1
- package/dist/chunks/{checkbox.11454247.js → checkbox.f38276e6.js} +4 -4
- package/dist/chunks/{checkbox.11454247.js.map → checkbox.f38276e6.js.map} +1 -1
- package/dist/chunks/{checkmark-circle-fill.75b87a2c.js → checkmark-circle-fill.345311d2.js} +2 -2
- package/dist/chunks/{checkmark-circle-fill.75b87a2c.js.map → checkmark-circle-fill.345311d2.js.map} +1 -1
- package/dist/chunks/{checkmark-small.07adbfcb.js → checkmark-small.520f01b1.js} +2 -2
- package/dist/chunks/{checkmark-small.07adbfcb.js.map → checkmark-small.520f01b1.js.map} +1 -1
- package/dist/chunks/{checkmark.9979f1c1.js → checkmark.a6ed8f47.js} +2 -2
- package/dist/chunks/{checkmark.9979f1c1.js.map → checkmark.a6ed8f47.js.map} +1 -1
- package/dist/chunks/{chevron-left.64e168be.js → chevron-left.5edf02ac.js} +2 -2
- package/dist/chunks/{chevron-left.64e168be.js.map → chevron-left.5edf02ac.js.map} +1 -1
- package/dist/chunks/{chevron-up.628ac446.js → chevron-up.81185563.js} +2 -2
- package/dist/chunks/{chevron-up.628ac446.js.map → chevron-up.81185563.js.map} +1 -1
- package/dist/chunks/{controls-group.0892d082.js → controls-group.f1dfa419.js} +3 -3
- package/dist/chunks/{controls-group.0892d082.js.map → controls-group.f1dfa419.js.map} +1 -1
- package/dist/chunks/{copy.2d2c6b85.js → copy.acc9f1b0.js} +4 -4
- package/dist/chunks/{copy.2d2c6b85.js.map → copy.acc9f1b0.js.map} +1 -1
- package/dist/chunks/{cross-circle-fill.34e86c56.js → cross-circle-fill.27580c4b.js} +2 -2
- package/dist/chunks/{cross-circle-fill.34e86c56.js.map → cross-circle-fill.27580c4b.js.map} +1 -1
- package/dist/chunks/{cross-small.e3c016cb.js → cross-small.e851e0de.js} +2 -2
- package/dist/chunks/{cross-small.e3c016cb.js.map → cross-small.e851e0de.js.map} +1 -1
- package/dist/chunks/{cross.e5433f3b.js → cross.04678d81.js} +2 -2
- package/dist/chunks/{cross.e5433f3b.js.map → cross.04678d81.js.map} +1 -1
- package/dist/chunks/{dialog-page.21f1eb92.js → dialog-page.75b295b7.js} +3 -3
- package/dist/chunks/{dialog-page.21f1eb92.js.map → dialog-page.75b295b7.js.map} +1 -1
- package/dist/chunks/{dropdown-default-textbox.9c23c94d.js → dropdown-default-textbox.c1f8fe5f.js} +57 -37
- package/dist/chunks/dropdown-default-textbox.c1f8fe5f.js.map +1 -0
- package/dist/chunks/{dropdown.dad8cedd.js → dropdown.669b858b.js} +20 -21
- package/dist/chunks/{dropdown.dad8cedd.js.map → dropdown.669b858b.js.map} +1 -1
- package/dist/chunks/{error-message.5fdafd8c.js → error-message.8734e591.js} +3 -3
- package/dist/chunks/{error-message.5fdafd8c.js.map → error-message.8734e591.js.map} +1 -1
- package/dist/chunks/{fixed-scroller.e917ed3f.js → fixed-scroller.772ad033.js} +3 -3
- package/dist/chunks/{fixed-scroller.e917ed3f.js.map → fixed-scroller.772ad033.js.map} +1 -1
- package/dist/chunks/{footer-actions.599e5a1d.js → footer-actions.11071f12.js} +4 -4
- package/dist/chunks/{footer-actions.599e5a1d.js.map → footer-actions.11071f12.js.map} +1 -1
- package/dist/chunks/{index.823243d9.js → index.03ae22b4.js} +2 -2
- package/dist/chunks/{index.823243d9.js.map → index.03ae22b4.js.map} +1 -1
- package/dist/chunks/index.49ce3f6a.js +49 -0
- package/dist/chunks/index.49ce3f6a.js.map +1 -0
- package/dist/chunks/{index.0c4a8dd9.js → index.51308a21.js} +3 -3
- package/dist/chunks/{index.0c4a8dd9.js.map → index.51308a21.js.map} +1 -1
- package/dist/chunks/{index.937a82c2.js → index.5d5f2200.js} +7 -7
- package/dist/chunks/{index.937a82c2.js.map → index.5d5f2200.js.map} +1 -1
- package/dist/chunks/{index.73634ace.js → index.73abb1a9.js} +31 -32
- package/dist/chunks/{index.73634ace.js.map → index.73abb1a9.js.map} +1 -1
- package/dist/chunks/{index.929dda57.js → index.87180cdd.js} +107 -106
- package/dist/chunks/index.87180cdd.js.map +1 -0
- package/dist/chunks/{index.d681cfda.js → index.8e6bc325.js} +12 -11
- package/dist/chunks/index.8e6bc325.js.map +1 -0
- package/dist/chunks/{index.7d2ea1de.js → index.94980f50.js} +2 -2
- package/dist/chunks/{index.7d2ea1de.js.map → index.94980f50.js.map} +1 -1
- package/dist/chunks/index.ba6c1040.js +79 -0
- package/dist/chunks/index.ba6c1040.js.map +1 -0
- package/dist/chunks/{index.3ddbe834.js → index.f19887a1.js} +2 -2
- package/dist/chunks/{index.3ddbe834.js.map → index.f19887a1.js.map} +1 -1
- package/dist/chunks/{index.66c8d79f.js → index.ff09389c.js} +7 -7
- package/dist/chunks/{index.66c8d79f.js.map → index.ff09389c.js.map} +1 -1
- package/dist/chunks/{info.b11d377e.js → info.8b6328aa.js} +2 -2
- package/dist/chunks/{info.b11d377e.js.map → info.8b6328aa.js.map} +1 -1
- package/dist/chunks/{listbox-option-tag.52ca5a60.js → listbox-option-tag.c0a56a95.js} +3 -3
- package/dist/chunks/{listbox-option-tag.52ca5a60.js.map → listbox-option-tag.c0a56a95.js.map} +1 -1
- package/dist/chunks/{listbox.6d8bd2ae.js → listbox.e6e1bc90.js} +8 -8
- package/dist/chunks/{listbox.6d8bd2ae.js.map → listbox.e6e1bc90.js.map} +1 -1
- package/dist/chunks/{loading-button.73c0bd64.js → loading-button.84a5529d.js} +4 -4
- package/dist/chunks/{loading-button.73c0bd64.js.map → loading-button.84a5529d.js.map} +1 -1
- package/dist/chunks/{payment-method.eeb54552.js → payment-method.faa302de.js} +2 -2
- package/dist/chunks/{payment-method.eeb54552.js.map → payment-method.faa302de.js.map} +1 -1
- package/dist/chunks/{refresh.f8e1b23c.js → refresh.71a03998.js} +2 -2
- package/dist/chunks/{refresh.f8e1b23c.js.map → refresh.71a03998.js.map} +1 -1
- package/dist/chunks/{search.4b38a2ef.js → search.471270fe.js} +2 -2
- package/dist/chunks/{search.4b38a2ef.js.map → search.471270fe.js.map} +1 -1
- package/dist/chunks/{tooltip.a9133b59.js → tooltip.8e9d733c.js} +3 -3
- package/dist/chunks/{tooltip.a9133b59.js.map → tooltip.8e9d733c.js.map} +1 -1
- package/dist/chunks/use-bento-toast-controller.7d4436ad.js +52 -0
- package/dist/chunks/use-bento-toast-controller.7d4436ad.js.map +1 -0
- package/dist/chunks/use-click-outside.941d1600.js +14 -0
- package/dist/chunks/use-click-outside.941d1600.js.map +1 -0
- package/dist/code-snippet.js +7 -7
- package/dist/code-snippet.js.map +1 -1
- package/dist/country.js +2 -2
- package/dist/currency.js +1 -1
- package/dist/data-grid-template.js +1 -1
- package/dist/data-grid.js +898 -805
- package/dist/data-grid.js.map +1 -1
- package/dist/date-picker.js +39 -40
- package/dist/date-picker.js.map +1 -1
- package/dist/date-range-picker.js +2 -2
- package/dist/date.js +1 -1
- package/dist/divider.js +1 -1
- package/dist/dropdown.js +7 -7
- package/dist/empty-state.js +3 -3
- package/dist/filter-bar.js +410 -421
- package/dist/filter-bar.js.map +1 -1
- package/dist/focus-trap.js +1 -1
- package/dist/form-layout.js +2 -2
- package/dist/header.js +5 -5
- package/dist/index.js +247 -269
- package/dist/index.js.map +1 -1
- package/dist/info-icon.js +4 -4
- package/dist/input-field.js +38 -34
- package/dist/input-field.js.map +1 -1
- package/dist/internal.js +8 -8
- package/dist/link.js +1 -1
- package/dist/loading-indicator.js +1 -1
- package/dist/menu.js +1 -1
- package/dist/modal-fullscreen.js +7 -7
- package/dist/modal.js +6 -6
- package/dist/pagination.js +4 -4
- package/dist/payment-method.js +1 -1
- package/dist/popover.js +1 -1
- package/dist/popper-container.js +1 -1
- package/dist/radio-group.js +4 -4
- package/dist/search-bar.js +4 -4
- package/dist/secondary-nav.js +2 -2
- package/dist/segmented-control.js +4 -4
- package/dist/selection-card.js +5 -5
- package/dist/sidepanel.js +7 -7
- package/dist/status.js +2 -2
- package/dist/stepper.js +144 -133
- package/dist/stepper.js.map +1 -1
- package/dist/structured-list.js +1 -1
- package/dist/summary-grid.js +3 -3
- package/dist/tabs.js +3 -3
- package/dist/tag.js +3 -3
- package/dist/textarea.js +4 -4
- package/dist/timeline.js +7 -7
- package/dist/toast.js +143 -98
- package/dist/toast.js.map +1 -1
- package/dist/toggle.js +3 -3
- package/dist/tutorial.js +7 -7
- package/dist/typography.js +1 -1
- package/dist/web-types.json +204 -117
- package/package.json +3 -3
- package/dist/chunks/directive.0408e565.js +0 -23
- package/dist/chunks/directive.0408e565.js.map +0 -1
- package/dist/chunks/dropdown-default-textbox.9c23c94d.js.map +0 -1
- package/dist/chunks/index.0c33067d.js +0 -127
- package/dist/chunks/index.0c33067d.js.map +0 -1
- package/dist/chunks/index.5af5de46.js +0 -83
- package/dist/chunks/index.5af5de46.js.map +0 -1
- package/dist/chunks/index.929dda57.js.map +0 -1
- package/dist/chunks/index.d681cfda.js.map +0 -1
- package/dist/chunks/info-filled.ee9571d9.js +0 -26
- package/dist/chunks/info-filled.ee9571d9.js.map +0 -1
- package/dist/chunks/toastController.fd667b68.js +0 -15
- package/dist/chunks/toastController.fd667b68.js.map +0 -1
- /package/dist/assets/{cross-small.css → cross.css} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { defineComponent as d, computed as r } from "vue";
|
|
2
2
|
import { BentoLoadingIndicator as p } from "../loading-indicator.js";
|
|
3
|
-
import { a as i } from "./button.
|
|
4
|
-
import { C as u } from "./cross-circle-fill.
|
|
5
|
-
import { C as _ } from "./checkmark-circle-fill.
|
|
3
|
+
import { a as i } from "./button.6e6324f0.js";
|
|
4
|
+
import { C as u } from "./cross-circle-fill.27580c4b.js";
|
|
5
|
+
import { C as _ } from "./checkmark-circle-fill.345311d2.js";
|
|
6
6
|
import { n as f } from "./_plugin-vue2_normalizer.71e2aa87.js";
|
|
7
7
|
import "../assets/loading-button.css";
|
|
8
8
|
var e = /* @__PURE__ */ ((s) => (s.START = "start", s.LOADING = "loading", s.SUCCESS = "success", s.FAIL = "fail", s))(e || {});
|
|
@@ -96,4 +96,4 @@ export {
|
|
|
96
96
|
T as B,
|
|
97
97
|
e as a
|
|
98
98
|
};
|
|
99
|
-
//# sourceMappingURL=loading-button.
|
|
99
|
+
//# sourceMappingURL=loading-button.84a5529d.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loading-button.
|
|
1
|
+
{"version":3,"file":"loading-button.84a5529d.js","sources":["../../src/components/button/components/loading-button/loading-button.types.ts","../../src/components/button/components/loading-button/loading-button.vue"],"sourcesContent":["export enum BentoLoadingButtonState {\n START = 'start',\n LOADING = 'loading',\n SUCCESS = 'success',\n FAIL = 'fail',\n}\n\nexport type BentoLoadingButtonIconState = Partial<{ [key in BentoLoadingButtonState]: string }>;\n","<template>\n <bento-button\n :critical=\"isCritical\"\n :variant=\"variant\"\n :condensed=\"condensed\"\n :disabled=\"disabled\"\n :inverse=\"inverse\"\n class=\"b-loading-button\"\n :class=\"conditionalClasses\"\n @click.capture.stop=\"onClick\"\n >\n <slot></slot>\n <template v-if=\"state !== 'start'\" #iconLeft>\n <span class=\"b-loading-button__icon\" data-testid=\"loading-button-rotating-icon\">\n <cross v-if=\"state === 'fail'\" svg-title=\"failed\" />\n <checkmark v-else-if=\"state === 'success'\" svg-title=\"succeded\" />\n <!-- TODO: Replace with new loading-indicator component -->\n <bento-loading-indicator v-else-if=\"state === 'loading'\" small :inverse=\"isInverseLoadingIndicator\" />\n </span>\n </template>\n </bento-button>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, PropType } from 'vue';\n import { BentoLoadingButtonState } from './loading-button.types';\n import { BentoLoadingIndicator } from '@/components/loading-indicator';\n import BentoButton from '@/components/button/button.vue';\n import Cross from '@adyen/ui-assets-icons-16/vue/cross-circle-fill';\n import Checkmark from '@adyen/ui-assets-icons-16/vue/checkmark-circle-fill';\n\n const props = defineProps({\n /**\n * Reduces sizing of button\n */\n condensed: {\n type: BentoButton.props.condensed.type,\n default: false,\n },\n\n /**\n * Displays loading-button as critical\n */\n critical: {\n type: BentoButton.props.critical.type,\n default: false,\n },\n\n /**\n * Disables button functonality\n */\n disabled: {\n type: BentoButton.props.disabled.type,\n default: false,\n },\n\n /**\n * Sets color set to inverse\n */\n inverse: {\n type: Boolean,\n default: false,\n },\n\n /**\n * State of the button.\n * @values start, loading, success, fail\n */\n state: {\n type: String as PropType<BentoLoadingButtonState | `${BentoLoadingButtonState}`>,\n default: BentoLoadingButtonState.START,\n validator: (value: BentoLoadingButtonState) => Object.values(BentoLoadingButtonState).includes(value),\n },\n\n /**\n * Types of flavour of Button\n * @values primary, secondary, tertiary\n */\n variant: {\n type: BentoButton.props.variant.type,\n default: 'primary',\n validator: BentoButton.props.variant.validator,\n },\n });\n\n const emit = defineEmits<{\n /**\n * Click event handler\n */\n (e: 'click', event: MouseEvent): void;\n }>();\n\n const conditionalClasses = computed(() => ({\n [`b-loading-button--${props.variant}-${BentoLoadingButtonState.LOADING}`]:\n props.state === BentoLoadingButtonState.LOADING && !props.disabled,\n 'b-loading-button--loading': props.state === BentoLoadingButtonState.LOADING && !props.disabled,\n [`b-loading-button--${props.variant}-${BentoLoadingButtonState.SUCCESS}`]:\n props.state === BentoLoadingButtonState.SUCCESS,\n [`b-loading-button--inverse`]: props.inverse,\n }));\n\n const isInverseLoadingIndicator = computed(\n () => (props.variant === 'primary' && !props.inverse) || (props.variant !== 'primary' && props.inverse)\n );\n const isCritical = computed(\n () =>\n (props.critical && props.state === BentoLoadingButtonState.START) ||\n props.state === BentoLoadingButtonState.FAIL\n );\n\n const onClick = (e: MouseEvent) => {\n // Prevent Vue3 from triggering event twice\n e.stopPropagation();\n\n if (props.state !== BentoLoadingButtonState.LOADING) {\n emit('click', e);\n }\n };\n</script>\n\n<script lang=\"ts\">\n /**\n * Loading Button component is used for cases where pressing a button starts an event that requires a loading state, e.g. when you have any sort of asynchronous action and are waiting for a response\n *\n * @example\n * import { BentoLoadingButton } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoLoadingButton },\n * template: `\n * <bento-loading-button state=\"loading\" variant=\"secondary\">\n * Loading\n * </bento-loading button>\n * `\n * }\n */\n export default {};\n</script>\n\n<style lang=\"scss\" scoped src=\"./loading-button.scss\" />\n"],"names":["BentoLoadingButtonState","BentoLoadingButtonState2","__default__","conditionalClasses","computed","props","isInverseLoadingIndicator","isCritical","e","emit"],"mappings":";;;;;;;AAAY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,QAAA,SACAA,EAAA,UAAA,WACAA,EAAA,UAAA,WACAA,EAAA,OAAA,QAJQA,IAAAD,KAAA,CAAA,CAAA;ACwIR,MAAAE,IAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA5CAC,IAAAC,EAAA,OAAA;AAAA,MAA2C,CAAA,qBAAAC,EAAA,WAAAL,EAAA,SAAA,GAAAK,EAAA,UAAAL,EAAA,WAAA,CAAAK,EAAA;AAAA,MAEuB,6BAAAA,EAAA,UAAAL,EAAA,WAAA,CAAAK,EAAA;AAAA,MACyB,CAAA,qBAAAA,EAAA,WAAAL,EAAA,SAAA,GAAAK,EAAA,UAAAL,EAAA;AAAA,MAE3C,CAAA,2BAAA,GAAAK,EAAA;AAAA,IACP,EAAA,GAGzCC,IAAAF;AAAA,MAAkC,MAAAC,EAAA,YAAA,aAAA,CAAAA,EAAA,WAAAA,EAAA,YAAA,aAAAA,EAAA;AAAA,IACiE,GAEnGE,IAAAH;AAAA,MAAmB,MAAAC,EAAA,YAAAA,EAAA,UAAAL,EAAA,SAAAK,EAAA,UAAAL,EAAA;AAAA,IAG6B;wHAGhD,CAAAQ,MAAA;AAEI,MAAAA,EAAA,gBAAA,GAEAH,EAAA,UAAAL,EAAA,WACIS,EAAA,SAAAD,CAAA;AAAA,IACJ;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref as a, watch as r, defineComponent as p, toRef as _, computed as u, inject as y } from "vue";
|
|
2
|
-
import { B as f } from "./index.
|
|
2
|
+
import { B as f } from "./index.ba6c1040.js";
|
|
3
3
|
import { S as h } from "./summary-grid.keys.1d1028c2.js";
|
|
4
4
|
import v from "@adyen/ui-assets-payment-method-icons/vue/unknowncard";
|
|
5
5
|
import { n as b } from "./_plugin-vue2_normalizer.71e2aa87.js";
|
|
@@ -83,4 +83,4 @@ const L = k.exports;
|
|
|
83
83
|
export {
|
|
84
84
|
L as B
|
|
85
85
|
};
|
|
86
|
-
//# sourceMappingURL=payment-method.
|
|
86
|
+
//# sourceMappingURL=payment-method.faa302de.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-method.
|
|
1
|
+
{"version":3,"file":"payment-method.faa302de.js","sources":["../../src/components/payment-method/composables/use-payment-icon/use-payment-icon.ts","../../src/components/payment-method/payment-method.vue"],"sourcesContent":["import { ref, Ref, watch } from 'vue';\n\n/**\n * Generates the payment icon URl from a payment icons string.\n * @param paymentType - the payment icon you wish to generate a URL for.\n * @returns the payment icon URL to the SVG for a specific payment icon.\n */\nexport const paymentMethodToCdnUrl = (paymentType: string) =>\n `https://checkoutshopper-live.cdn.adyen.com/checkoutshopper/images/logos/${paymentType.toLowerCase()}.svg`;\n\n/**\n * Dynamically retrieves the payment method icon SVG from the @adyen/ui-assets-payment-method-icons package.\n *\n * @param type the type of payment method\n * @param useFallback if fallback icon should be used in case of error\n * @returns\n */\nexport const usePaymentIcon = (type: Ref<string>) => {\n const paymentType = ref(type);\n const paymentIconSrc = ref<string>();\n\n watch(\n paymentType,\n newPaymentType => {\n if (newPaymentType == null || newPaymentType === 'Unknowncard') {\n return;\n }\n // TODO: what about when to use checkoutshopper-test? Should we add this to the config of Bento?\n paymentIconSrc.value = paymentMethodToCdnUrl(newPaymentType);\n },\n { immediate: true }\n );\n\n return paymentIconSrc;\n};\n","<template>\n <div class=\"b-payment-method\">\n <div class=\"b-payment-method__icon-container\">\n <img\n v-if=\"type !== 'Unknowncard' && !hasErroredOnImage\"\n aria-hidden=\"true\"\n class=\"b-payment-method__icon\"\n :class=\"conditionalIconClasses\"\n :alt=\"label\"\n :src=\"paymentMethodIconSrc\"\n @error=\"onSrcError\"\n />\n <unknown-card-icon v-else :svg-title=\"label\" aria-hidden=\"true\" />\n </div>\n <div class=\"b-payment-method__label\">\n <span v-if=\"isSummaryGridLayout\">{{ label }}</span>\n <bento-typography v-else el=\"span\">{{ label }}</bento-typography>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, inject, ref, toRef, watch } from 'vue';\n import { BentoTypography } from '@/components/typography';\n import { SUMMARY_GRID_LAYOUT_INJECTION_KEY } from '@/components/summary-grid/summary-grid.keys';\n import { BentoSummaryGridLayout } from '@/components/summary-grid';\n import { usePaymentIcon } from './composables/use-payment-icon/use-payment-icon';\n import UnknownCardIcon from '@adyen/ui-assets-payment-method-icons/vue/unknowncard';\n\n /**\n * A payment method type component to display the type's icon and label.\n *\n * @example\n * import { BentoPaymentMethod} from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoPaymentMethod },\n * template: `\n * <bento-payment-method type=\"Ideal\" />\n * `\n * }\n */\n export default defineComponent({\n name: 'bento-payment-method',\n components: { BentoTypography, UnknownCardIcon },\n props: {\n /**\n * The type of payment method to display.\n */\n type: {\n type: String,\n default: 'Unknowncard',\n },\n\n /**\n * The label describing to the payment method icon.\n */\n label: {\n type: String,\n required: true,\n },\n\n /**\n * Render payment method icon in a smaller size\n */\n small: {\n type: Boolean,\n default: false,\n },\n },\n setup(props) {\n const type = toRef(props, 'type');\n const hasErroredOnImage = ref(false);\n const paymentMethodIconSrc = usePaymentIcon(type);\n const conditionalIconClasses = computed(() => ({\n 'b-payment-method__icon--small': props.small,\n }));\n\n /* == Summary-grid styles == */\n const registerPaymentMethodInSummaryGrid: BentoSummaryGridLayout = inject(\n SUMMARY_GRID_LAYOUT_INJECTION_KEY,\n () => ({\n isSummaryGridLayout: false,\n })\n );\n\n const { isSummaryGridLayout } = registerPaymentMethodInSummaryGrid();\n\n /**\n * This funciton is fired if the payment image source is not valid and has thrown an error.\n */\n const onSrcError = () => {\n hasErroredOnImage.value = true;\n };\n\n // Reset the image error to be able to load the new payment type\n watch(\n () => type.value,\n (newType, oldType) => {\n if (newType !== oldType) {\n hasErroredOnImage.value = false;\n }\n }\n );\n\n return {\n // Values\n conditionalIconClasses,\n hasErroredOnImage,\n isSummaryGridLayout,\n paymentMethodIconSrc,\n\n // Methods\n onSrcError,\n };\n },\n });\n</script>\n\n<style lang=\"scss\" scoped src=\"./payment-method.scss\" />\n"],"names":["paymentMethodToCdnUrl","paymentType","usePaymentIcon","type","ref","paymentIconSrc","watch","newPaymentType","_sfc_main","defineComponent","BentoTypography","UnknownCardIcon","props","toRef","hasErroredOnImage","paymentMethodIconSrc","conditionalIconClasses","computed","registerPaymentMethodInSummaryGrid","inject","SUMMARY_GRID_LAYOUT_INJECTION_KEY","isSummaryGridLayout","onSrcError","newType","oldType"],"mappings":";;;;;;AAOO,MAAAA,IAAA,CAAAC,MAAA,2EAAAA,EAAA,YAAA,SAUMC,IAAA,CAAAC,MAAA;AACT,QAAAF,IAAAG,EAAAD,CAAA,GACAE,IAAAD,EAAA;AAEA,SAAAE;AAAA,IAAAL;AAAA,IACI,CAAAM,MAAA;AAEI,MAAAA,KAAA,QAAAA,MAAA,kBAIAF,EAAA,QAAAL,EAAAO,CAAA;AAAA,IAA2D;AAAA,IAC/D,EAAA,WAAA,GAAA;AAAA,EACkB,GAGtBF;AACJ,GCQAG,IAAAC,EAAA;AAAA,EAAA,MAAA;AAAA,EACA,YAAA,EAAA,iBAAAC,GAAA,iBAAAC,EAAA;AAAA,EACA,OAAA;AAAA;AAAA;AAAA;AAAA,IACA,MAAA;AAAA,MAIA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IACA,OAAA;AAAA,MAKA,MAAA;AAAA,MACA,UAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IACA,OAAA;AAAA,MAKA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA,EACA;AAAA,EACA,MAAAC,GAAA;AAEA,UAAAT,IAAAU,EAAAD,GAAA,MAAA,GACAE,IAAAV,EAAA,EAAA,GACAW,IAAAb,EAAAC,CAAA,GACAa,IAAAC,EAAA,OAAA;AAAA,MAAA,iCAAAL,EAAA;AAAA,IACA,EAAA,GAIAM,IAAAC;AAAA,MAAAC;AAAA,MACA,OAAA;AAAA,QACA,qBAAA;AAAA,MACA;AAAA,IACA,GAGA,EAAA,qBAAAC,EAAA,IAAAH,EAAA,GAKAI,IAAA,MAAA;AACA,MAAAR,EAAA,QAAA;AAAA,IAAA;AAIA,WAAAR;AAAA,MAAA,MAAAH,EAAA;AAAA,MACA,CAAAoB,GAAAC,MAAA;AAEA,QAAAD,MAAAC,MACAV,EAAA,QAAA;AAAA,MACA;AAAA,IACA,GAGA;AAAA;AAAA,MAAA,wBAAAE;AAAA,MAEA,mBAAAF;AAAA,MACA,qBAAAO;AAAA,MACA,sBAAAN;AAAA;AAAA,MACA,YAAAO;AAAA,IAGA;AAAA,EACA;AAEA,CAAA;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as r } from "./_plugin-vue2_normalizer.71e2aa87.js";
|
|
2
|
-
import "../assets/cross
|
|
2
|
+
import "../assets/cross.css";
|
|
3
3
|
let e = 0;
|
|
4
4
|
const n = {
|
|
5
5
|
beforeCreate() {
|
|
@@ -23,4 +23,4 @@ const c = i.exports;
|
|
|
23
23
|
export {
|
|
24
24
|
c as R
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=refresh.
|
|
26
|
+
//# sourceMappingURL=refresh.71a03998.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.
|
|
1
|
+
{"version":3,"file":"refresh.71a03998.js","sources":["../../../../node_modules/@adyen/ui-assets-icons-16/dist/vue/refresh.vue"],"sourcesContent":["\n<template>\n <svg role=\"img\" v-bind=\"$attrs\" class=\"ui-assets-icons-16\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\"><title v-if=\"$attrs['svg-title']\">{{ $attrs['svg-title'] }}</title><path fill=\"#00112C\" d=\"M2.75 8C2.75 5.10421 5.10421 2.75 8 2.75C9.88725 2.75 11.5441 3.74881 12.472 5.25H9.25V6.75H14.75V1.25H13.25V3.75995C12.0118 2.23 10.1214 1.25 8 1.25C4.27579 1.25 1.25 4.27579 1.25 8C1.25 11.7242 4.27579 14.75 8 14.75C11.7242 14.75 14.75 11.7242 14.75 8H13.25C13.25 10.8958 10.8958 13.25 8 13.25C5.10421 13.25 2.75 10.8958 2.75 8Z\"/></svg>\n</template>\n<script>\n let uuid = 0;\n\n export default {\n beforeCreate() {\n this.uuid = uuid.toString();\n uuid += 1;\n },\n };\n</script>\n<style>\n @import '../css/main.css';\n</style>\n"],"names":["uuid","_sfc_main"],"mappings":";;AAKA,IAAAA,IAAA;AAEA,MAAAC,IAAA;AAAA,EACA,eAAA;AACA,SAAA,OAAAD,EAAA,SAAA,GACAA,KAAA;AAAA,EACA;AACA;;;;;;;;;;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as r } from "./_plugin-vue2_normalizer.71e2aa87.js";
|
|
2
|
-
import "../assets/cross
|
|
2
|
+
import "../assets/cross.css";
|
|
3
3
|
let e = 0;
|
|
4
4
|
const a = {
|
|
5
5
|
beforeCreate() {
|
|
@@ -23,4 +23,4 @@ const c = l.exports;
|
|
|
23
23
|
export {
|
|
24
24
|
c as S
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=search.
|
|
26
|
+
//# sourceMappingURL=search.471270fe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.
|
|
1
|
+
{"version":3,"file":"search.471270fe.js","sources":["../../../../node_modules/@adyen/ui-assets-icons-16/dist/vue/search.vue"],"sourcesContent":["\n<template>\n <svg role=\"img\" v-bind=\"$attrs\" class=\"ui-assets-icons-16\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"none\"><title v-if=\"$attrs['svg-title']\">{{ $attrs['svg-title'] }}</title><g :clip-path=\"'url(#uia-icons-16-search__a' + uuid + ')'\"><path fill=\"#00112C\" d=\"M8.31686 0.379702C7.00749 0.119252 5.65029 0.252925 4.41689 0.763816C3.18349 1.27471 2.12928 2.13987 1.38758 3.2499C0.645881 4.35994 0.25 5.66498 0.25 7C0.25 8.79021 0.961159 10.5071 2.22703 11.773C3.4929 13.0388 5.20979 13.75 7 13.75C8.33502 13.75 9.64007 13.3541 10.7501 12.6124C10.9096 12.5059 11.064 12.3928 11.2131 12.2738L15.0001 16.0608L16.0608 15.0001L12.2737 11.2131C12.6674 10.7203 12.9922 10.1721 13.2362 9.58312C13.7471 8.34972 13.8808 6.99252 13.6203 5.68314C13.3598 4.37377 12.717 3.17104 11.773 2.22703C10.829 1.28303 9.62623 0.640153 8.31686 0.379702ZM4.99091 2.14964C5.95022 1.75228 7.00582 1.64831 8.02422 1.85088C9.04262 2.05345 9.97808 2.55347 10.7123 3.28769C11.4465 4.02192 11.9465 4.95738 12.1491 5.97578C12.3517 6.99418 12.2477 8.04978 11.8504 9.00909C11.453 9.9684 10.7801 10.7883 9.91674 11.3652C9.05339 11.9421 8.03835 12.25 7 12.25C5.60761 12.25 4.27225 11.6969 3.28769 10.7123C2.30312 9.72775 1.75 8.39239 1.75 7C1.75 5.96165 2.05791 4.94662 2.63478 4.08326C3.21166 3.2199 4.0316 2.547 4.99091 2.14964Z\"/></g><defs><clipPath :id=\"'uia-icons-16-search__a' + uuid\"><rect width=\"16\" height=\"16\" fill=\"#fff\"/></clipPath></defs></svg>\n</template>\n<script>\n let uuid = 0;\n\n export default {\n beforeCreate() {\n this.uuid = uuid.toString();\n uuid += 1;\n },\n };\n</script>\n<style>\n @import '../css/main.css';\n</style>\n"],"names":["uuid","_sfc_main"],"mappings":";;AAKA,IAAAA,IAAA;AAEA,MAAAC,IAAA;AAAA,EACA,eAAA;AACA,SAAA,OAAAD,EAAA,SAAA,GACAA,KAAA;AAAA,EACA;AACA;;;;;;;;;;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { computed as d, defineComponent as b, reactive as g, nextTick as w } from "vue";
|
|
2
2
|
import { l as r } from "./events.58c00e6d.js";
|
|
3
3
|
import { g as v } from "./unique-id.a2a2b458.js";
|
|
4
|
-
import { P as S, a as D, b as N } from "./index.
|
|
4
|
+
import { P as S, a as D, b as N } from "./index.51308a21.js";
|
|
5
5
|
import { V as W } from "./index.4c062058.js";
|
|
6
|
-
import { B as I } from "./index.
|
|
6
|
+
import { B as I } from "./index.ba6c1040.js";
|
|
7
7
|
import { n as x } from "./_plugin-vue2_normalizer.71e2aa87.js";
|
|
8
8
|
import "../assets/tooltip.css";
|
|
9
9
|
const l = { ...S };
|
|
@@ -170,4 +170,4 @@ export {
|
|
|
170
170
|
A as a,
|
|
171
171
|
y as b
|
|
172
172
|
};
|
|
173
|
-
//# sourceMappingURL=tooltip.
|
|
173
|
+
//# sourceMappingURL=tooltip.8e9d733c.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.a9133b59.js","sources":["../../src/directives/tooltip/tooltip.types.ts","../../src/types/utils-events.ts","../../src/components/tooltip/tooltip.vue","../../src/directives/tooltip/tooltip.ts"],"sourcesContent":["import { PopperContainerPositionBasic } from '@/components/popper-container';\nimport type { DirectiveBinding } from 'vue/types/options';\n\nexport const BentoTooltipPosition = { ...PopperContainerPositionBasic };\nexport type BentoTooltipPosition = PopperContainerPositionBasic;\n\nexport enum BentoTooltipState {\n HIDDEN = 'hidden',\n}\n\nexport interface BentoTooltipDirectiveBinding extends Readonly<DirectiveBinding> {\n readonly value: string;\n}\n","import type { Vue } from 'vue-demi';\n\nexport interface ListenOptions {\n capture?: boolean;\n passive?: boolean;\n once?: boolean;\n self?: boolean;\n vm?: Vue;\n onCleanup?: () => void;\n}\n\nexport enum EventKey {\n ESCAPE = 'Escape',\n ENTER = 'Enter',\n ARROW_LEFT = 'ArrowLeft',\n ARROW_UP = 'ArrowUp',\n ARROW_RIGHT = 'ArrowRight',\n ARROW_DOWN = 'ArrowDown',\n PAGE_UP = 'PageUp',\n PAGE_DOWN = 'PageDown',\n END = 'End',\n HOME = 'Home',\n}\n\n/**\n * @deprecated `Event.keyCode` is deprecated. Use `EventKey` instead\n */\nexport enum KeyCode {\n ESCAPE = 27,\n ENTER = 13,\n ARROW_LEFT = 37,\n ARROW_UP = 38,\n ARROW_RIGHT = 39,\n ARROW_DOWN = 40,\n PAGE_UP = 33,\n PAGE_DOWN = 34,\n END = 35,\n HOME = 36,\n}\n","<template>\n <popper-container\n :id=\"id\"\n :aria-role=\"PopperContainerAriaRole.TOOLTIP\"\n :aria-hidden=\"!isShown\"\n :arrow=\"{ classes: ['b-tooltip__arrow'] }\"\n :class=\"conditionalClasses\"\n :fallback-position=\"['top', 'bottom', 'right', 'left']\"\n :is-hidden=\"!isShown\"\n :offset=\"[0, 4]\"\n :position=\"position\"\n :tabindex=\"tabIndex\"\n :target-element=\"targetElement\"\n class=\"b-tooltip\"\n >\n <bento-typography el=\"span\" variant=\"caption\">\n {{ content }}\n </bento-typography>\n </popper-container>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType } from 'vue';\n import { BentoTooltipPosition, BentoTooltipState } from '@/directives/tooltip/tooltip.types';\n import { PopperContainer, PopperContainerAriaRole } from '@/components/popper-container';\n import { BentoTypography } from '@/components/typography';\n import { VueNodeElement } from '@/types';\n\n /**\n * Tooltip container, to be used internally to render the tooltip container where the text is shown.\n */\n export const Tooltip = {\n name: 'tooltip',\n components: { BentoTypography, PopperContainer },\n props: {\n /**\n * The tooltip's id. Necessary for accessibility purposes.\n */\n id: { type: String, default: null },\n /**\n * Tooltip's target reference to the DOM element or Vue component.\n * The tooltip will position itself relatively to target element, in the specified position.\n */\n targetElement: { type: [Element, Object] as PropType<VueNodeElement>, required: true },\n /**\n * Tooltip's position relative to the target element.\n * Possible values are: 'top', 'bottom', 'left' and 'right'.\n */\n position: {\n type: String as PropType<BentoTooltipPosition>,\n default: BentoTooltipPosition.TOP,\n validator: value => Object.values(BentoTooltipPosition).includes(value as BentoTooltipPosition),\n },\n /**\n * Tooltip's offset.\n * If specified, the tooltip will have an offset in pixels between it and the target element\n * in specified position.\n */\n offset: { type: Number, default: 0 },\n /**\n * Tooltip's text content.\n */\n content: { type: String, required: true },\n /**\n * Shows / Hides the Tooltip component\n */\n isShown: { type: Boolean, default: false },\n },\n setup(props) {\n const conditionalClasses = computed(() => ({\n [`b-tooltip--${BentoTooltipState.HIDDEN}`]: !props.isShown,\n }));\n\n const tabIndex = computed((): number => (props.isShown ? 1 : -1));\n\n return {\n // Enums\n PopperContainerAriaRole,\n\n // Values\n conditionalClasses,\n tabIndex,\n };\n },\n };\n\n export default defineComponent(Tooltip);\n</script>\n\n<style lang=\"scss\" scoped src=\"./tooltip.scss\" />\n","import { nextTick, reactive } from 'vue';\nimport { listen } from '@/utils/ts/events';\nimport { generateUid } from '@/utils/ts/unique-id';\nimport { EventKey } from '@/types/utils-events';\nimport { BentoTooltipDirectiveBinding, BentoTooltipPosition } from './tooltip.types';\nimport { createApp, h, isVue2, Vue2 } from 'vue-demi';\nimport BentoTooltip from '@/components/tooltip/tooltip.vue';\n\ninterface TooltipInstance {\n target: HTMLElement;\n content: string;\n position: BentoTooltipPosition;\n removeListeners: Array<() => void>;\n}\n\n/**\n * Tooltip directive to render a tooltip on a given HTML element or component.\n *\n * @usage\n * import { BentoTooltipDirective, BentoTooltipPosition } from '@adyen/bento-vue2';\n *\n * export default {\n * directives: { BentoTooltipDirective },\n * template: `\n * <bento-button\n * v-bento-tooltip-directive:BentoTooltipPosition.BOTTOM=\"refToTextContent\"\n * >\n * Button text\n * </bento-button>\n * `,\n * }\n */\nconst tooltipInstances: Array<TooltipInstance> = [];\nconst ariaDescribedByAttr = 'aria-describedby';\nconst tooltipId = generateUid('tooltip');\n\nlet tooltipVNode;\n\n// Reusable Tooltip component instance.\nlet tooltip;\n// Global visibility state to prevent tooltips from showing after it being instructed to hide\nlet open = false;\n\nconst tooltipProps = reactive({\n targetElement: null,\n content: 'START_MESSAGE',\n id: tooltipId,\n position: undefined,\n isShown: false,\n});\n\n/**\n * Creates a new Tooltip component instance and inserts it into DOM.\n * @param {HTMLElement} el the target element for the Tooltip\n * @internal\n */\nconst createTooltip = (el: HTMLElement) => {\n // Sets the target's tabindex so as to make the tooltip interactive via keyboard navigation\n el.setAttribute('tabindex', '0');\n\n if (isVue2) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore: Type error for Vue method in Vue 3 but this code only executes in vue 2 so ignoring.\n const TooltipComponent = Vue2.extend(BentoTooltip);\n tooltip = new TooltipComponent({ propsData: { targetElement: el, content: '', id: tooltipId } }).$mount();\n document.body.appendChild(tooltip.$el);\n } else {\n tooltipProps.targetElement = el;\n tooltip = createApp({\n components: { BentoTooltip },\n setup() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore: Type error for h method in Vue 2 but this code only executes in vue 3 so ignoring.\n return () => h(BentoTooltip, { ...tooltipProps }, '');\n },\n });\n tooltipVNode = document.createElement('div');\n tooltipVNode.id = 'tooltip-parent';\n document.body.appendChild(tooltipVNode);\n tooltip.mount('#tooltip-parent');\n }\n};\n\n/**\n * Removes Tooltip component instance from the DOM and destroys it.\n * @internal\n */\nconst destroyTooltip = () => {\n if (isVue2) {\n if (document.contains(tooltip.$el)) {\n document.body.removeChild(tooltip.$el);\n }\n tooltip.$destroy();\n } else {\n tooltip.unmount();\n if (document.contains(tooltipVNode)) {\n document.body.removeChild(tooltipVNode);\n }\n }\n\n tooltip = undefined;\n};\n\n/**\n * Returns tooltip position based on the specified argument.\n * By default returns 'top' if no argument is specified.\n * @param {BentoTooltipDirectiveBinding} binding Directive binding object.\n * @returns {string} Tooltip position.\n * @internal\n */\nconst getTooltipPosition = (binding: BentoTooltipDirectiveBinding): BentoTooltipPosition =>\n Object.values(BentoTooltipPosition).includes(binding.arg as BentoTooltipPosition)\n ? (binding.arg as BentoTooltipPosition)\n : BentoTooltipPosition.TOP;\n\n/**\n * Get the correct Tooltip instance for the given target element\n * @param {HTMLElement} el the target element for the Tooltip\n * @returns\n */\nconst getTooltipInstanceForTarget = (el: HTMLElement): TooltipInstance =>\n tooltipInstances.find(\n ctx =>\n // isEqualNode doesn't work correct for svg element, hence the second check here\n ctx.target.isEqualNode(el) && ctx.target === el\n );\n\n/**\n * On mouse enter event updates tooltip with correct content and position, and shows tooltip.\n * @param {?HTMLElement} el - Target element\n * @internal\n */\nconst showTooltip = (el?: HTMLElement) => {\n const tooltipInstance = getTooltipInstanceForTarget(el);\n\n // If tooltip content is empty – do not show the tooltip\n if (!tooltipInstance.content || !el) {\n return;\n }\n\n if (el) {\n el.setAttribute(ariaDescribedByAttr, tooltipId);\n }\n\n // If the Tooltip is inside a dialog, move tooltip element inside of it\n // It gets restored to <body> when it gets hidden\n let isDialogOpen = false;\n document.querySelectorAll('dialog').forEach(node => {\n isDialogOpen = node?.open || isDialogOpen;\n });\n\n if (isDialogOpen) {\n if (isVue2) {\n el.after(tooltip.$el);\n // eslint-disable-next-line no-underscore-dangle\n } else if (tooltip?._instance?.vnode?.el) {\n // eslint-disable-next-line no-underscore-dangle\n el.after(tooltip?._instance?.vnode?.el);\n }\n isDialogOpen = false;\n }\n\n open = true;\n\n tooltip.content = tooltipInstance.content;\n tooltip.position = tooltipInstance.position;\n\n tooltipProps.content = tooltipInstance.content;\n tooltipProps.position = tooltipInstance.position;\n\n // Do calculations on a next tick, otherwise tooltip position calculations will be wrong\n nextTick(() => {\n // Do not open tooltip if it has been instructed to hide in process\n if (!open) {\n return;\n }\n tooltip.targetElement = el;\n tooltip.isShown = true;\n\n tooltipProps.targetElement = el;\n tooltipProps.isShown = true;\n });\n};\n\n/**\n * On mouse leave event hides the tooltip.\n * @internal\n */\nconst hideTooltip = (el?: HTMLElement) => {\n // Restore the tooltip element to body if it got move out of <body>\n if (tooltip.$el?.parentElement?.tagName && tooltip.$el?.parentElement?.tagName !== 'BODY') {\n document.body.appendChild(tooltip.$el);\n }\n\n open = false;\n tooltip.isShown = false;\n tooltipProps.isShown = false;\n if (el) {\n el.removeAttribute(ariaDescribedByAttr);\n }\n};\n\nconst tooltipBind = (el: HTMLElement, binding: BentoTooltipDirectiveBinding) => {\n // eslint-disable-next-line no-prototype-builtins\n if (!binding.hasOwnProperty('value') || binding.value) {\n // Create Tooltip component singleton instance\n if (tooltipInstances.length === 0) {\n createTooltip(el);\n }\n\n const show = () => showTooltip(el);\n const hide = () => hideTooltip(el);\n\n // Create and store context object, which has directive related handlers and content.\n const tooltipInstance: TooltipInstance = {\n target: el,\n content: binding.value,\n position: getTooltipPosition(binding),\n removeListeners: [\n listen(el, 'mouseenter', show),\n listen(el, 'mouseleave', hide),\n listen(el, 'focus', show),\n listen(el, 'blur', hide),\n listen(el, 'keydown', evt => {\n const keyboardEvent = <KeyboardEvent>evt;\n if (keyboardEvent.key === EventKey.ESCAPE) {\n hide();\n }\n }),\n ],\n };\n\n tooltipInstances.push(tooltipInstance);\n }\n};\n\nconst tooltipUpdate = (el: HTMLElement, binding: BentoTooltipDirectiveBinding) => {\n const tooltipInstance = getTooltipInstanceForTarget(el);\n if (tooltipInstance) {\n // Update tooltip content value if it is changed\n if (tooltipInstance?.content !== binding.value) {\n tooltipInstance.content = binding.value;\n // If tooltip is currently shown for current element – update tooltip's content value\n if (tooltip.isShown && tooltip.targetElement.isEqualNode(el)) {\n if (!tooltipInstance.content) {\n tooltip.isShown = false;\n } else {\n tooltip.content = binding.value;\n }\n }\n }\n // Update tooltip position if it is changed\n if (tooltipInstance.position !== binding.arg) {\n const position = getTooltipPosition(binding);\n tooltipInstance.position = position;\n tooltip.position = position;\n }\n } else if (!tooltipInstance && binding.value) {\n // If I don't have a tooltip instance yet but the value passed was updated\n tooltipBind(el, binding);\n }\n};\n\nconst tooltipUnbind = (el: HTMLElement) => {\n const context = getTooltipInstanceForTarget(el);\n\n // Prevent unbinding/removing when there's nothing to unbind, leads to stack overflow errors\n if (!context) {\n return;\n }\n\n context.removeListeners.forEach(removeListener => {\n removeListener();\n });\n\n // If el is removed while tooltip is displayed, the tooltip doesnt hide as\n // there is no el to trigger mouseleave/blur.\n hideTooltip();\n\n tooltipInstances.splice(tooltipInstances.indexOf(context), 1);\n\n // If all the elements using the directive are removed, then no point having\n // the component on the page.\n if (tooltipInstances.length === 0) {\n destroyTooltip();\n }\n};\n\n/**\n * This directive allows you to bind a tooltip to an element.\n * Tooltip can be configured to be shown in one of four positions: 'top', 'left', 'right' and 'bottom'.\n *\n * @example\n * import { BentoTooltipDirective as BentoTooltip, BentoTooltipPosition } from '@adyen/bento-vue2';\n *\n * export default {\n * directives: { BentoTooltip },\n * methods: {\n * contentExpression() {\n * return 'tooltip content';\n * },\n * },\n * template: `<div>\n * <div v-bento-tooltip:left=\"refToTooltipContent\"></div>\n * <div v-bento-tooltip:[TooltipPosition.BOTTOM]=\"refToTooltipContent\"></div>\n *\n * <!-- If you don't specify the position then by default it's `TooltipPosition.TOP` -->\n * <div v-bento-tooltip=\"refToTooltipContent\"></div>\n *\n * <!-- Tooltip content can also be a data property or a method or a computed property as well -->\n * <div v-bento-tooltip=\"contentExpression()\"></div>\n * </div>`,\n * };\n */\nexport const BentoTooltipDirective = {\n // Vue 2 Directive hooks\n bind(el, binding) {\n tooltipBind(el, binding);\n },\n update(el, binding) {\n tooltipUpdate(el, binding);\n },\n unbind(el) {\n tooltipUnbind(el);\n },\n // Vue 3 Directive hooks\n beforeMount(el, binding) {\n tooltipBind(el, binding);\n },\n mounted(el, binding) {\n tooltipUpdate(el, binding);\n },\n updated(el, binding) {\n tooltipUpdate(el, binding);\n },\n unmounted(el) {\n tooltipUnbind(el);\n },\n};\n"],"names":["BentoTooltipPosition","PopperContainerPositionBasic","BentoTooltipState","BentoTooltipState2","EventKey","EventKey2","KeyCode","KeyCode2","Tooltip","BentoTypography","PopperContainer","value","props","conditionalClasses","computed","tabIndex","PopperContainerAriaRole","_sfc_main","defineComponent","tooltipInstances","ariaDescribedByAttr","tooltipId","generateUid","tooltip","open","tooltipProps","reactive","createTooltip","el","TooltipComponent","Vue2","BentoTooltip","destroyTooltip","getTooltipPosition","binding","getTooltipInstanceForTarget","ctx","showTooltip","tooltipInstance","isDialogOpen","node","nextTick","hideTooltip","_b","_a","_d","_c","tooltipBind","show","hide","listen","evt","tooltipUpdate","position","tooltipUnbind","context","removeListener","BentoTooltipDirective"],"mappings":";;;;;;;;AAGa,MAAAA,IAAA,EAAA,GAAAC,EAAA;AAGD,IAAAC,IAAA,kBAAAC,OACRA,EAAA,SAAA,UADQA,IAAAD,KAAA,CAAA,CAAA,GCKAE,IAAA,kBAAAC,OACRA,EAAA,SAAA,UACAA,EAAA,QAAA,SACAA,EAAA,aAAA,aACAA,EAAA,WAAA,WACAA,EAAA,cAAA,cACAA,EAAA,aAAA,aACAA,EAAA,UAAA,UACAA,EAAA,YAAA,YACAA,EAAA,MAAA,OACAA,EAAA,OAAA,QAVQA,IAAAD,KAAA,CAAA,CAAA,GAgBAE,IAAA,kBAAAC,OACRA,EAAAA,EAAA,SAAA,EAAA,IAAA,UACAA,EAAAA,EAAA,QAAA,EAAA,IAAA,SACAA,EAAAA,EAAA,aAAA,EAAA,IAAA,cACAA,EAAAA,EAAA,WAAA,EAAA,IAAA,YACAA,EAAAA,EAAA,cAAA,EAAA,IAAA,eACAA,EAAAA,EAAA,aAAA,EAAA,IAAA,cACAA,EAAAA,EAAA,UAAA,EAAA,IAAA,WACAA,EAAAA,EAAA,YAAA,EAAA,IAAA,aACAA,EAAAA,EAAA,MAAA,EAAA,IAAA,OACAA,EAAAA,EAAA,OAAA,EAAA,IAAA,QAVQA,IAAAD,KAAA,CAAA,CAAA;ACIZ,MAAAE,IAAA;AAAA,EAAA,MAAA;AAAA,EACA,YAAA,EAAA,iBAAAC,GAAA,iBAAAC,EAAA;AAAA,EACA,OAAA;AAAA;AAAA;AAAA;AAAA,IACA,IAAA,EAAA,MAAA,QAAA,SAAA,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAIA,eAAA,EAAA,MAAA,CAAA,SAAA,MAAA,GAAA,UAAA,GAAA;AAAA;AAAA;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A,CAAAC,MAAA;AACI,IAAAA,EAAA;AAAA,EAAe,CAAA,GAKnBd,EAAA,GAEAvB,EAAA,OAAAA,EAAA,QAAAoC,CAAA,GAAA,CAAA,GAIApC,EAAA,WAAA,KACIa,EAAA;AAER,GA4BOyB,IAAA;AAAA;AAAA,EAA8B,KAAA7B,GAAAM,GAAA;AAG7B,IAAAa,EAAAnB,GAAAM,CAAA;AAAA,EAAuB;AAAA,EAC3B,OAAAN,GAAAM,GAAA;AAEI,IAAAkB,EAAAxB,GAAAM,CAAA;AAAA,EAAyB;AAAA,EAC7B,OAAAN,GAAA;AAEI,IAAA0B,EAAA1B,CAAA;AAAA,EAAgB;AAAA;AAAA,EACpB,YAAAA,GAAAM,GAAA;AAGI,IAAAa,EAAAnB,GAAAM,CAAA;AAAA,EAAuB;AAAA,EAC3B,QAAAN,GAAAM,GAAA;AAEI,IAAAkB,EAAAxB,GAAAM,CAAA;AAAA,EAAyB;AAAA,EAC7B,QAAAN,GAAAM,GAAA;AAEI,IAAAkB,EAAAxB,GAAAM,CAAA;AAAA,EAAyB;AAAA,EAC7B,UAAAN,GAAA;AAEI,IAAA0B,EAAA1B,CAAA;AAAA,EAAgB;AAExB;"}
|
|
1
|
+
{"version":3,"file":"tooltip.8e9d733c.js","sources":["../../src/directives/tooltip/tooltip.types.ts","../../src/types/utils-events.ts","../../src/components/tooltip/tooltip.vue","../../src/directives/tooltip/tooltip.ts"],"sourcesContent":["import { PopperContainerPositionBasic } from '@/components/popper-container';\nimport type { DirectiveBinding } from 'vue/types/options';\n\nexport const BentoTooltipPosition = { ...PopperContainerPositionBasic };\nexport type BentoTooltipPosition = PopperContainerPositionBasic;\n\nexport enum BentoTooltipState {\n HIDDEN = 'hidden',\n}\n\nexport interface BentoTooltipDirectiveBinding extends Readonly<DirectiveBinding> {\n readonly value: string;\n}\n","import type { Vue } from 'vue-demi';\n\nexport interface ListenOptions {\n capture?: boolean;\n passive?: boolean;\n once?: boolean;\n self?: boolean;\n vm?: Vue;\n onCleanup?: () => void;\n}\n\nexport enum EventKey {\n ESCAPE = 'Escape',\n ENTER = 'Enter',\n ARROW_LEFT = 'ArrowLeft',\n ARROW_UP = 'ArrowUp',\n ARROW_RIGHT = 'ArrowRight',\n ARROW_DOWN = 'ArrowDown',\n PAGE_UP = 'PageUp',\n PAGE_DOWN = 'PageDown',\n END = 'End',\n HOME = 'Home',\n}\n\n/**\n * @deprecated `Event.keyCode` is deprecated. Use `EventKey` instead\n */\nexport enum KeyCode {\n ESCAPE = 27,\n ENTER = 13,\n ARROW_LEFT = 37,\n ARROW_UP = 38,\n ARROW_RIGHT = 39,\n ARROW_DOWN = 40,\n PAGE_UP = 33,\n PAGE_DOWN = 34,\n END = 35,\n HOME = 36,\n}\n","<template>\n <popper-container\n :id=\"id\"\n :aria-role=\"PopperContainerAriaRole.TOOLTIP\"\n :aria-hidden=\"!isShown\"\n :arrow=\"{ classes: ['b-tooltip__arrow'] }\"\n :class=\"conditionalClasses\"\n :fallback-position=\"['top', 'bottom', 'right', 'left']\"\n :is-hidden=\"!isShown\"\n :offset=\"[0, 4]\"\n :position=\"position\"\n :tabindex=\"tabIndex\"\n :target-element=\"targetElement\"\n class=\"b-tooltip\"\n >\n <bento-typography el=\"span\" variant=\"caption\">\n {{ content }}\n </bento-typography>\n </popper-container>\n</template>\n\n<script lang=\"ts\">\n import { computed, defineComponent, PropType } from 'vue';\n import { BentoTooltipPosition, BentoTooltipState } from '@/directives/tooltip/tooltip.types';\n import { PopperContainer, PopperContainerAriaRole } from '@/components/popper-container';\n import { BentoTypography } from '@/components/typography';\n import { VueNodeElement } from '@/types';\n\n /**\n * Tooltip container, to be used internally to render the tooltip container where the text is shown.\n */\n export const Tooltip = {\n name: 'tooltip',\n components: { BentoTypography, PopperContainer },\n props: {\n /**\n * The tooltip's id. Necessary for accessibility purposes.\n */\n id: { type: String, default: null },\n /**\n * Tooltip's target reference to the DOM element or Vue component.\n * The tooltip will position itself relatively to target element, in the specified position.\n */\n targetElement: { type: [Element, Object] as PropType<VueNodeElement>, required: true },\n /**\n * Tooltip's position relative to the target element.\n * Possible values are: 'top', 'bottom', 'left' and 'right'.\n */\n position: {\n type: String as PropType<BentoTooltipPosition>,\n default: BentoTooltipPosition.TOP,\n validator: value => Object.values(BentoTooltipPosition).includes(value as BentoTooltipPosition),\n },\n /**\n * Tooltip's offset.\n * If specified, the tooltip will have an offset in pixels between it and the target element\n * in specified position.\n */\n offset: { type: Number, default: 0 },\n /**\n * Tooltip's text content.\n */\n content: { type: String, required: true },\n /**\n * Shows / Hides the Tooltip component\n */\n isShown: { type: Boolean, default: false },\n },\n setup(props) {\n const conditionalClasses = computed(() => ({\n [`b-tooltip--${BentoTooltipState.HIDDEN}`]: !props.isShown,\n }));\n\n const tabIndex = computed((): number => (props.isShown ? 1 : -1));\n\n return {\n // Enums\n PopperContainerAriaRole,\n\n // Values\n conditionalClasses,\n tabIndex,\n };\n },\n };\n\n export default defineComponent(Tooltip);\n</script>\n\n<style lang=\"scss\" scoped src=\"./tooltip.scss\" />\n","import { nextTick, reactive } from 'vue';\nimport { listen } from '@/utils/ts/events';\nimport { generateUid } from '@/utils/ts/unique-id';\nimport { EventKey } from '@/types/utils-events';\nimport { BentoTooltipDirectiveBinding, BentoTooltipPosition } from './tooltip.types';\nimport { createApp, h, isVue2, Vue2 } from 'vue-demi';\nimport BentoTooltip from '@/components/tooltip/tooltip.vue';\n\ninterface TooltipInstance {\n target: HTMLElement;\n content: string;\n position: BentoTooltipPosition;\n removeListeners: Array<() => void>;\n}\n\n/**\n * Tooltip directive to render a tooltip on a given HTML element or component.\n *\n * @usage\n * import { BentoTooltipDirective, BentoTooltipPosition } from '@adyen/bento-vue2';\n *\n * export default {\n * directives: { BentoTooltipDirective },\n * template: `\n * <bento-button\n * v-bento-tooltip-directive:BentoTooltipPosition.BOTTOM=\"refToTextContent\"\n * >\n * Button text\n * </bento-button>\n * `,\n * }\n */\nconst tooltipInstances: Array<TooltipInstance> = [];\nconst ariaDescribedByAttr = 'aria-describedby';\nconst tooltipId = generateUid('tooltip');\n\nlet tooltipVNode;\n\n// Reusable Tooltip component instance.\nlet tooltip;\n// Global visibility state to prevent tooltips from showing after it being instructed to hide\nlet open = false;\n\nconst tooltipProps = reactive({\n targetElement: null,\n content: 'START_MESSAGE',\n id: tooltipId,\n position: undefined,\n isShown: false,\n});\n\n/**\n * Creates a new Tooltip component instance and inserts it into DOM.\n * @param {HTMLElement} el the target element for the Tooltip\n * @internal\n */\nconst createTooltip = (el: HTMLElement) => {\n // Sets the target's tabindex so as to make the tooltip interactive via keyboard navigation\n el.setAttribute('tabindex', '0');\n\n if (isVue2) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore: Type error for Vue method in Vue 3 but this code only executes in vue 2 so ignoring.\n const TooltipComponent = Vue2.extend(BentoTooltip);\n tooltip = new TooltipComponent({ propsData: { targetElement: el, content: '', id: tooltipId } }).$mount();\n document.body.appendChild(tooltip.$el);\n } else {\n tooltipProps.targetElement = el;\n tooltip = createApp({\n components: { BentoTooltip },\n setup() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore: Type error for h method in Vue 2 but this code only executes in vue 3 so ignoring.\n return () => h(BentoTooltip, { ...tooltipProps }, '');\n },\n });\n tooltipVNode = document.createElement('div');\n tooltipVNode.id = 'tooltip-parent';\n document.body.appendChild(tooltipVNode);\n tooltip.mount('#tooltip-parent');\n }\n};\n\n/**\n * Removes Tooltip component instance from the DOM and destroys it.\n * @internal\n */\nconst destroyTooltip = () => {\n if (isVue2) {\n if (document.contains(tooltip.$el)) {\n document.body.removeChild(tooltip.$el);\n }\n tooltip.$destroy();\n } else {\n tooltip.unmount();\n if (document.contains(tooltipVNode)) {\n document.body.removeChild(tooltipVNode);\n }\n }\n\n tooltip = undefined;\n};\n\n/**\n * Returns tooltip position based on the specified argument.\n * By default returns 'top' if no argument is specified.\n * @param {BentoTooltipDirectiveBinding} binding Directive binding object.\n * @returns {string} Tooltip position.\n * @internal\n */\nconst getTooltipPosition = (binding: BentoTooltipDirectiveBinding): BentoTooltipPosition =>\n Object.values(BentoTooltipPosition).includes(binding.arg as BentoTooltipPosition)\n ? (binding.arg as BentoTooltipPosition)\n : BentoTooltipPosition.TOP;\n\n/**\n * Get the correct Tooltip instance for the given target element\n * @param {HTMLElement} el the target element for the Tooltip\n * @returns\n */\nconst getTooltipInstanceForTarget = (el: HTMLElement): TooltipInstance =>\n tooltipInstances.find(\n ctx =>\n // isEqualNode doesn't work correct for svg element, hence the second check here\n ctx.target.isEqualNode(el) && ctx.target === el\n );\n\n/**\n * On mouse enter event updates tooltip with correct content and position, and shows tooltip.\n * @param {?HTMLElement} el - Target element\n * @internal\n */\nconst showTooltip = (el?: HTMLElement) => {\n const tooltipInstance = getTooltipInstanceForTarget(el);\n\n // If tooltip content is empty – do not show the tooltip\n if (!tooltipInstance.content || !el) {\n return;\n }\n\n if (el) {\n el.setAttribute(ariaDescribedByAttr, tooltipId);\n }\n\n // If the Tooltip is inside a dialog, move tooltip element inside of it\n // It gets restored to <body> when it gets hidden\n let isDialogOpen = false;\n document.querySelectorAll('dialog').forEach(node => {\n isDialogOpen = node?.open || isDialogOpen;\n });\n\n if (isDialogOpen) {\n if (isVue2) {\n el.after(tooltip.$el);\n // eslint-disable-next-line no-underscore-dangle\n } else if (tooltip?._instance?.vnode?.el) {\n // eslint-disable-next-line no-underscore-dangle\n el.after(tooltip?._instance?.vnode?.el);\n }\n isDialogOpen = false;\n }\n\n open = true;\n\n tooltip.content = tooltipInstance.content;\n tooltip.position = tooltipInstance.position;\n\n tooltipProps.content = tooltipInstance.content;\n tooltipProps.position = tooltipInstance.position;\n\n // Do calculations on a next tick, otherwise tooltip position calculations will be wrong\n nextTick(() => {\n // Do not open tooltip if it has been instructed to hide in process\n if (!open) {\n return;\n }\n tooltip.targetElement = el;\n tooltip.isShown = true;\n\n tooltipProps.targetElement = el;\n tooltipProps.isShown = true;\n });\n};\n\n/**\n * On mouse leave event hides the tooltip.\n * @internal\n */\nconst hideTooltip = (el?: HTMLElement) => {\n // Restore the tooltip element to body if it got move out of <body>\n if (tooltip.$el?.parentElement?.tagName && tooltip.$el?.parentElement?.tagName !== 'BODY') {\n document.body.appendChild(tooltip.$el);\n }\n\n open = false;\n tooltip.isShown = false;\n tooltipProps.isShown = false;\n if (el) {\n el.removeAttribute(ariaDescribedByAttr);\n }\n};\n\nconst tooltipBind = (el: HTMLElement, binding: BentoTooltipDirectiveBinding) => {\n // eslint-disable-next-line no-prototype-builtins\n if (!binding.hasOwnProperty('value') || binding.value) {\n // Create Tooltip component singleton instance\n if (tooltipInstances.length === 0) {\n createTooltip(el);\n }\n\n const show = () => showTooltip(el);\n const hide = () => hideTooltip(el);\n\n // Create and store context object, which has directive related handlers and content.\n const tooltipInstance: TooltipInstance = {\n target: el,\n content: binding.value,\n position: getTooltipPosition(binding),\n removeListeners: [\n listen(el, 'mouseenter', show),\n listen(el, 'mouseleave', hide),\n listen(el, 'focus', show),\n listen(el, 'blur', hide),\n listen(el, 'keydown', evt => {\n const keyboardEvent = <KeyboardEvent>evt;\n if (keyboardEvent.key === EventKey.ESCAPE) {\n hide();\n }\n }),\n ],\n };\n\n tooltipInstances.push(tooltipInstance);\n }\n};\n\nconst tooltipUpdate = (el: HTMLElement, binding: BentoTooltipDirectiveBinding) => {\n const tooltipInstance = getTooltipInstanceForTarget(el);\n if (tooltipInstance) {\n // Update tooltip content value if it is changed\n if (tooltipInstance?.content !== binding.value) {\n tooltipInstance.content = binding.value;\n // If tooltip is currently shown for current element – update tooltip's content value\n if (tooltip.isShown && tooltip.targetElement.isEqualNode(el)) {\n if (!tooltipInstance.content) {\n tooltip.isShown = false;\n } else {\n tooltip.content = binding.value;\n }\n }\n }\n // Update tooltip position if it is changed\n if (tooltipInstance.position !== binding.arg) {\n const position = getTooltipPosition(binding);\n tooltipInstance.position = position;\n tooltip.position = position;\n }\n } else if (!tooltipInstance && binding.value) {\n // If I don't have a tooltip instance yet but the value passed was updated\n tooltipBind(el, binding);\n }\n};\n\nconst tooltipUnbind = (el: HTMLElement) => {\n const context = getTooltipInstanceForTarget(el);\n\n // Prevent unbinding/removing when there's nothing to unbind, leads to stack overflow errors\n if (!context) {\n return;\n }\n\n context.removeListeners.forEach(removeListener => {\n removeListener();\n });\n\n // If el is removed while tooltip is displayed, the tooltip doesnt hide as\n // there is no el to trigger mouseleave/blur.\n hideTooltip();\n\n tooltipInstances.splice(tooltipInstances.indexOf(context), 1);\n\n // If all the elements using the directive are removed, then no point having\n // the component on the page.\n if (tooltipInstances.length === 0) {\n destroyTooltip();\n }\n};\n\n/**\n * This directive allows you to bind a tooltip to an element.\n * Tooltip can be configured to be shown in one of four positions: 'top', 'left', 'right' and 'bottom'.\n *\n * @example\n * import { BentoTooltipDirective as BentoTooltip, BentoTooltipPosition } from '@adyen/bento-vue2';\n *\n * export default {\n * directives: { BentoTooltip },\n * methods: {\n * contentExpression() {\n * return 'tooltip content';\n * },\n * },\n * template: `<div>\n * <div v-bento-tooltip:left=\"refToTooltipContent\"></div>\n * <div v-bento-tooltip:[TooltipPosition.BOTTOM]=\"refToTooltipContent\"></div>\n *\n * <!-- If you don't specify the position then by default it's `TooltipPosition.TOP` -->\n * <div v-bento-tooltip=\"refToTooltipContent\"></div>\n *\n * <!-- Tooltip content can also be a data property or a method or a computed property as well -->\n * <div v-bento-tooltip=\"contentExpression()\"></div>\n * </div>`,\n * };\n */\nexport const BentoTooltipDirective = {\n // Vue 2 Directive hooks\n bind(el, binding) {\n tooltipBind(el, binding);\n },\n update(el, binding) {\n tooltipUpdate(el, binding);\n },\n unbind(el) {\n tooltipUnbind(el);\n },\n // Vue 3 Directive hooks\n beforeMount(el, binding) {\n tooltipBind(el, binding);\n },\n mounted(el, binding) {\n tooltipUpdate(el, binding);\n },\n updated(el, binding) {\n tooltipUpdate(el, binding);\n },\n unmounted(el) {\n tooltipUnbind(el);\n },\n};\n"],"names":["BentoTooltipPosition","PopperContainerPositionBasic","BentoTooltipState","BentoTooltipState2","EventKey","EventKey2","KeyCode","KeyCode2","Tooltip","BentoTypography","PopperContainer","value","props","conditionalClasses","computed","tabIndex","PopperContainerAriaRole","_sfc_main","defineComponent","tooltipInstances","ariaDescribedByAttr","tooltipId","generateUid","tooltip","open","tooltipProps","reactive","createTooltip","el","TooltipComponent","Vue2","BentoTooltip","destroyTooltip","getTooltipPosition","binding","getTooltipInstanceForTarget","ctx","showTooltip","tooltipInstance","isDialogOpen","node","nextTick","hideTooltip","_b","_a","_d","_c","tooltipBind","show","hide","listen","evt","tooltipUpdate","position","tooltipUnbind","context","removeListener","BentoTooltipDirective"],"mappings":";;;;;;;;AAGa,MAAAA,IAAA,EAAA,GAAAC,EAAA;AAGD,IAAAC,IAAA,kBAAAC,OACRA,EAAA,SAAA,UADQA,IAAAD,KAAA,CAAA,CAAA,GCKAE,IAAA,kBAAAC,OACRA,EAAA,SAAA,UACAA,EAAA,QAAA,SACAA,EAAA,aAAA,aACAA,EAAA,WAAA,WACAA,EAAA,cAAA,cACAA,EAAA,aAAA,aACAA,EAAA,UAAA,UACAA,EAAA,YAAA,YACAA,EAAA,MAAA,OACAA,EAAA,OAAA,QAVQA,IAAAD,KAAA,CAAA,CAAA,GAgBAE,IAAA,kBAAAC,OACRA,EAAAA,EAAA,SAAA,EAAA,IAAA,UACAA,EAAAA,EAAA,QAAA,EAAA,IAAA,SACAA,EAAAA,EAAA,aAAA,EAAA,IAAA,cACAA,EAAAA,EAAA,WAAA,EAAA,IAAA,YACAA,EAAAA,EAAA,cAAA,EAAA,IAAA,eACAA,EAAAA,EAAA,aAAA,EAAA,IAAA,cACAA,EAAAA,EAAA,UAAA,EAAA,IAAA,WACAA,EAAAA,EAAA,YAAA,EAAA,IAAA,aACAA,EAAAA,EAAA,MAAA,EAAA,IAAA,OACAA,EAAAA,EAAA,OAAA,EAAA,IAAA,QAVQA,IAAAD,KAAA,CAAA,CAAA;ACIZ,MAAAE,IAAA;AAAA,EAAA,MAAA;AAAA,EACA,YAAA,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AI,EAAA,WAAAe,GACA9B,EAAA,WAAA8B;AAAA;AAAA;AACJ,IAAA,CAAAf,KAAAJ,EAAA,SAGAa,EAAAnB,GAAAM,CAAA;AAER,GAEAoB,IAAA,CAAA1B,MAAA;AACI,QAAA2B,IAAApB,EAAAP,CAAA;AAGA,EAAA2B,MAIAA,EAAA,gBAAA,QAAA,CAAAC,MAAA;AACI,IAAAA,EAAA;AAAA,EAAe,CAAA,GAKnBd,EAAA,GAEAvB,EAAA,OAAAA,EAAA,QAAAoC,CAAA,GAAA,CAAA,GAIApC,EAAA,WAAA,KACIa,EAAA;AAER,GA4BOyB,IAAA;AAAA;AAAA,EAA8B,KAAA7B,GAAAM,GAAA;AAG7B,IAAAa,EAAAnB,GAAAM,CAAA;AAAA,EAAuB;AAAA,EAC3B,OAAAN,GAAAM,GAAA;AAEI,IAAAkB,EAAAxB,GAAAM,CAAA;AAAA,EAAyB;AAAA,EAC7B,OAAAN,GAAA;AAEI,IAAA0B,EAAA1B,CAAA;AAAA,EAAgB;AAAA;AAAA,EACpB,YAAAA,GAAAM,GAAA;AAGI,IAAAa,EAAAnB,GAAAM,CAAA;AAAA,EAAuB;AAAA,EAC3B,QAAAN,GAAAM,GAAA;AAEI,IAAAkB,EAAAxB,GAAAM,CAAA;AAAA,EAAyB;AAAA,EAC7B,QAAAN,GAAAM,GAAA;AAEI,IAAAkB,EAAAxB,GAAAM,CAAA;AAAA,EAAyB;AAAA,EAC7B,UAAAN,GAAA;AAEI,IAAA0B,EAAA1B,CAAA;AAAA,EAAgB;AAExB;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ref as n, computed as i, getCurrentInstance as c, readonly as u } from "vue";
|
|
2
|
+
import "./index.4c062058.js";
|
|
3
|
+
import { p as d } from "./index.ba6c1040.js";
|
|
4
|
+
import { g as m } from "./unique-id.a2a2b458.js";
|
|
5
|
+
const a = (t, s) => {
|
|
6
|
+
const e = t.value.findIndex((o) => o.id === s);
|
|
7
|
+
e !== -1 && t.value.splice(e, 1);
|
|
8
|
+
}, f = Symbol("toast-stack"), g = () => {
|
|
9
|
+
const t = n([]), s = (e) => {
|
|
10
|
+
const o = m("toast"), r = {
|
|
11
|
+
...e,
|
|
12
|
+
id: o,
|
|
13
|
+
dismiss: () => a(t, o)
|
|
14
|
+
};
|
|
15
|
+
return t.value.unshift(r), {
|
|
16
|
+
dismiss: () => a(t, o)
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
// Even though stack is a reactive property, its content suppose to be only changed from this module.
|
|
21
|
+
// For this reason we return "stack" as readonly prop, but also return methods that can affect "stack" content.
|
|
22
|
+
stack: i(() => Object.freeze(Array.from(t.value))),
|
|
23
|
+
/**
|
|
24
|
+
* A function that allows to add new toasts
|
|
25
|
+
* @param {Object} params Toast parameters
|
|
26
|
+
* @param {String} params.text A text to display inside the toast
|
|
27
|
+
* @param {Object} [params.action] An object that defines action parameters for the toast
|
|
28
|
+
* @param {String} params.action.text An action button text
|
|
29
|
+
* @param {Function} params.action.handler A callback that would be called when action button is clicked
|
|
30
|
+
* @return {Object} An object that includes "dismiss" function to programatically dismiss the toast
|
|
31
|
+
*/
|
|
32
|
+
addToast: s
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
function v() {
|
|
36
|
+
var s;
|
|
37
|
+
const t = (s = c()) == null ? void 0 : s.proxy[f];
|
|
38
|
+
return t ? { ...t } : (d("Toast does not work without Vue.use(BentoPlugin, { withToast: true })"), {
|
|
39
|
+
stack: u(n([])),
|
|
40
|
+
addToast: () => ({
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function -- intentional empty function explained by the comment above
|
|
42
|
+
dismiss: () => {
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
g as c,
|
|
49
|
+
f as t,
|
|
50
|
+
v as u
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=use-bento-toast-controller.7d4436ad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-bento-toast-controller.7d4436ad.js","sources":["../../src/composables/use-bento-toast-controller/toast-stack.ts","../../src/composables/use-bento-toast-controller/use-bento-toast-controller.ts"],"sourcesContent":["import { computed, ref, type Ref } from 'vue';\nimport { generateUid } from '@/utils/ts/unique-id';\nimport type { BentoToastItemsList, ToastStack } from './use-bento-toast-controller.types';\n\nconst dismissToast: (stack: Ref<BentoToastItemsList>, id: string) => void = (stack, id) => {\n const toastIndex = stack.value.findIndex(toast => toast.id === id);\n if (toastIndex !== -1) {\n stack.value.splice(toastIndex, 1);\n }\n};\n\nexport const toastStackInjectionKey = Symbol('toast-stack');\n\n/**\n * This utility creates a global reactive state to add new toasts and keep track of them.\n * @returns {ToastStack} An object that contains reactive stack property with all add toasts and a function to add new toasts\n */\nexport const createToastStack: () => ToastStack = () => {\n const stack = ref<BentoToastItemsList>([]);\n\n const addToast = params => {\n const id = generateUid('toast');\n const toast = {\n ...params,\n id,\n dismiss: () => dismissToast(stack, id),\n };\n\n stack.value.unshift(toast);\n\n return {\n dismiss: () => dismissToast(stack, id),\n };\n };\n\n return {\n // Even though stack is a reactive property, its content suppose to be only changed from this module.\n // For this reason we return \"stack\" as readonly prop, but also return methods that can affect \"stack\" content.\n stack: computed(() => Object.freeze(Array.from(stack.value))),\n /**\n * A function that allows to add new toasts\n * @param {Object} params Toast parameters\n * @param {String} params.text A text to display inside the toast\n * @param {Object} [params.action] An object that defines action parameters for the toast\n * @param {String} params.action.text An action button text\n * @param {Function} params.action.handler A callback that would be called when action button is clicked\n * @return {Object} An object that includes \"dismiss\" function to programatically dismiss the toast\n */\n addToast,\n };\n};\n","import { getCurrentInstance, inject, readonly, ref } from 'vue';\nimport { isVue2 } from 'vue-demi';\nimport { printDevelopmentWarning } from '../../utils/ts/print-development-warning';\nimport { toastStackInjectionKey } from './toast-stack';\nimport { UseBentoToastController } from './use-bento-toast-controller.types';\n\nexport function useBentoToastController(): UseBentoToastController {\n const toastStack = isVue2\n ? getCurrentInstance()?.proxy[toastStackInjectionKey]\n : inject(toastStackInjectionKey, null);\n if (!toastStack) {\n printDevelopmentWarning('Toast does not work without Vue.use(BentoPlugin, { withToast: true })');\n // Return placeholder functions so client code won't brake, but Toasts just won't show up\n return {\n stack: readonly(ref([])),\n addToast: () => ({\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- intentional empty function explained by the comment above\n dismiss: () => {},\n }),\n };\n }\n // Return a new object so unintentional reassigning its properties won't override a global state\n return { ...toastStack };\n}\n"],"names":["dismissToast","stack","id","toastIndex","toast","toastStackInjectionKey","createToastStack","ref","addToast","params","generateUid","computed","useBentoToastController","toastStack","_a","getCurrentInstance","printDevelopmentWarning","readonly"],"mappings":";;;;AAIA,MAAMA,IAAsE,CAACC,GAAOC,MAAO;AACvF,QAAMC,IAAaF,EAAM,MAAM,UAAU,CAASG,MAAAA,EAAM,OAAOF,CAAE;AACjE,EAAIC,MAAe,MACTF,EAAA,MAAM,OAAOE,GAAY,CAAC;AAExC,GAEaE,IAAyB,OAAO,aAAa,GAM7CC,IAAqC,MAAM;AAC9C,QAAAL,IAAQM,EAAyB,CAAA,CAAE,GAEnCC,IAAW,CAAUC,MAAA;AACjB,UAAAP,IAAKQ,EAAY,OAAO,GACxBN,IAAQ;AAAA,MACV,GAAGK;AAAA,MACH,IAAAP;AAAA,MACA,SAAS,MAAMF,EAAaC,GAAOC,CAAE;AAAA,IAAA;AAGnC,WAAAD,EAAA,MAAM,QAAQG,CAAK,GAElB;AAAA,MACH,SAAS,MAAMJ,EAAaC,GAAOC,CAAE;AAAA,IAAA;AAAA,EACzC;AAGG,SAAA;AAAA;AAAA;AAAA,IAGH,OAAOS,EAAS,MAAM,OAAO,OAAO,MAAM,KAAKV,EAAM,KAAK,CAAC,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAU5D,UAAAO;AAAA,EAAA;AAER;AC5CO,SAASI,IAAmD;;AACzD,QAAAC,KACAC,IAAAC,EAAmB,MAAnB,gBAAAD,EAAsB,MAAMT;AAElC,SAAKQ,IAYE,EAAE,GAAGA,OAXRG,EAAwB,uEAAuE,GAExF;AAAA,IACH,OAAOC,EAASV,EAAI,CAAA,CAAE,CAAC;AAAA,IACvB,UAAU,OAAO;AAAA;AAAA,MAEb,SAAS,MAAM;AAAA,MAAC;AAAA,IAAA;AAAA,EACpB;AAKZ;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { o as e } from "./on-click-outside.3e0c3e2a.js";
|
|
2
|
+
import { onMounted as u, onUnmounted as s } from "vue";
|
|
3
|
+
const m = (t, i, n = {}) => {
|
|
4
|
+
let o;
|
|
5
|
+
u(() => {
|
|
6
|
+
o = e(t, i, n);
|
|
7
|
+
}), s(() => {
|
|
8
|
+
o && (o(), o = null);
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
m as u
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=use-click-outside.941d1600.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-click-outside.941d1600.js","sources":["../../src/composables/use-click-outside/use-click-outside.ts"],"sourcesContent":["import { onClickOutside } from '@/directives/click-outside/on-click-outside';\nimport { OnClickOutsideHandler, OnClickOutsideOptions } from '@/directives/click-outside/types';\nimport { MaybeElementRef } from '@/types';\nimport { onMounted, onUnmounted } from 'vue';\n\n/**\n * Composable to listen for clicks outside of an element ref.\n *\n * @param {MaybeElementRef} target - HTML Element or \"ref\" to an Element on which the click outside listener will be attached to\n * @param {OnClickOutsideHandler} handler - Function that will be called when the listener gets triggered\n * @param {OnClickOutsideOptions} options - Options to be passed to the listener\n */\nexport const useClickOutside = <T extends OnClickOutsideOptions>(\n target: MaybeElementRef,\n handler: OnClickOutsideHandler,\n options: T = {} as T\n) => {\n let onClickOutsideStop: () => void;\n\n onMounted(() => {\n onClickOutsideStop = onClickOutside(target, handler, options);\n });\n\n onUnmounted(() => {\n if (onClickOutsideStop) {\n onClickOutsideStop();\n\n onClickOutsideStop = null;\n }\n });\n};\n"],"names":["useClickOutside","target","handler","options","onClickOutsideStop","onMounted","onClickOutside","onUnmounted"],"mappings":";;AAYO,MAAMA,IAAkB,CAC3BC,GACAC,GACAC,IAAa,CAAA,MACZ;AACG,MAAAC;AAEJ,EAAAC,EAAU,MAAM;AACS,IAAAD,IAAAE,EAAeL,GAAQC,GAASC,CAAO;AAAA,EAAA,CAC/D,GAEDI,EAAY,MAAM;AACd,IAAIH,MACmBA,KAEEA,IAAA;AAAA,EACzB,CACH;AACL;"}
|
package/dist/code-snippet.js
CHANGED
|
@@ -3,20 +3,20 @@ import { highlightActiveLine as Ue, keymap as We, EditorView as Ie, lineNumbers
|
|
|
3
3
|
import { EditorSelection as Fe, Compartment as be, EditorState as Le } from "@codemirror/state";
|
|
4
4
|
import { indentWithTab as Ke, history as qe } from "@codemirror/commands";
|
|
5
5
|
import { syntaxHighlighting as Xe, HighlightStyle as Ze } from "@codemirror/language";
|
|
6
|
-
import { B as Qe } from "./chunks/dropdown.
|
|
7
|
-
import { a as Ye } from "./chunks/button.
|
|
8
|
-
import { B as et } from "./chunks/index.
|
|
6
|
+
import { B as Qe } from "./chunks/dropdown.669b858b.js";
|
|
7
|
+
import { a as Ye } from "./chunks/button.6e6324f0.js";
|
|
8
|
+
import { B as et } from "./chunks/index.ba6c1040.js";
|
|
9
9
|
import { BentoLoadingIndicator as tt } from "./loading-indicator.js";
|
|
10
10
|
import { u as nt } from "./chunks/i18n.eb5b985b.js";
|
|
11
11
|
import { n as He } from "./chunks/_plugin-vue2_normalizer.71e2aa87.js";
|
|
12
|
-
import { h as rt } from "./chunks/base-modal.
|
|
13
|
-
import { C as it } from "./chunks/copy.
|
|
12
|
+
import { h as rt } from "./chunks/base-modal.aa09a60c.js";
|
|
13
|
+
import { C as it } from "./chunks/copy.acc9f1b0.js";
|
|
14
14
|
import { json as st } from "@codemirror/lang-json";
|
|
15
15
|
import { xml as lt } from "@codemirror/lang-xml";
|
|
16
16
|
import { javascript as ot } from "@codemirror/lang-javascript";
|
|
17
17
|
import { java as at } from "@codemirror/lang-java";
|
|
18
|
-
import { b as ut } from "./chunks/tooltip.
|
|
19
|
-
import "./assets/
|
|
18
|
+
import { b as ut } from "./chunks/tooltip.8e9d733c.js";
|
|
19
|
+
import "./assets/index17.css";
|
|
20
20
|
const ft = 1024;
|
|
21
21
|
let ht = 0;
|
|
22
22
|
class v {
|