@adyen/bento-vue2 1.5.0 → 1.6.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/@types/packages/vue2/src/components/avatar-image/avatar-image.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/button/button.vue.d.ts +97 -97
- package/dist/@types/packages/vue2/src/components/button/components/loading-button/loading-button.vue.d.ts +3 -3
- package/dist/@types/packages/vue2/src/components/card/card.vue.d.ts +7 -1
- package/dist/@types/packages/vue2/src/components/checkbox/components/checkbox-group/checkbox-group.vue.d.ts +3 -3
- package/dist/@types/packages/vue2/src/components/data-grid/composables/useCalculateColumnWidth/useCalculateColumnWidth.d.ts +6 -2
- package/dist/@types/packages/vue2/src/components/data-grid/composables/useCalculateStickyElementHeight/useCalculateStickyElementHeight.d.ts +2 -0
- package/dist/@types/packages/vue2/src/components/data-grid/composables/useColumnReorderer/useColumnReorderer.d.ts +2 -0
- package/dist/@types/packages/vue2/src/components/data-grid/composables/useConfigSettings/useConfigSettings.d.ts +3 -0
- package/dist/@types/packages/vue2/src/components/data-grid/data-grid.types.d.ts +2 -1
- package/dist/@types/packages/vue2/src/components/data-grid/data-grid.vue.d.ts +41 -4
- package/dist/@types/packages/vue2/src/components/dropdown/components/dropdown-base-textbox/dropdown-base-textbox.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/dropdown/components/dropdown-default-textbox/dropdown-default-textbox.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/dropdown/components/dropdown-options-container/dropdown-options-container.vue.d.ts +33 -34
- package/dist/@types/packages/vue2/src/components/dropdown/components/dropdown-small-textbox/dropdown-small-textbox.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/dropdown/components/variants/dropdown-avatar/dropdown-avatar.vue.d.ts +2 -2
- package/dist/@types/packages/vue2/src/components/dropdown/components/variants/dropdown-country/dropdown-country.vue.d.ts +2 -2
- package/dist/@types/packages/vue2/src/components/dropdown/components/variants/dropdown-currency/dropdown-currency.vue.d.ts +2 -2
- package/dist/@types/packages/vue2/src/components/dropdown/components/variants/dropdown-payment-method/dropdown-payment-method.vue.d.ts +2 -2
- package/dist/@types/packages/vue2/src/components/dropdown/components/variants/dropdown-tag/dropdown-tag.vue.d.ts +3 -3
- package/dist/@types/packages/vue2/src/components/dropdown/dropdown.vue.d.ts +2 -2
- package/dist/@types/packages/vue2/src/components/filter-bar/components/all-filters-modal/all-filters-modal.vue.d.ts +20 -20
- package/dist/@types/packages/vue2/src/components/filter-bar/components/boolean-filter/boolean-filter.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/filter-bar/components/date-filter/date-filter.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/filter-bar/components/date-range-filter/date-range-filter.vue.d.ts +2 -2
- package/dist/@types/packages/vue2/src/components/filter-bar/components/input-filter/input-filter.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/filter-bar/components/range-filter/range-filter.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/filter-bar/components/select-filter/select-filter.vue.d.ts +2 -1
- package/dist/@types/packages/vue2/src/components/filter-bar/components/select-filter/variants/select-country-filter/select-country-filter.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/filter-bar/components/select-filter/variants/select-tag-filter/select-tag-filter.vue.d.ts +2 -2
- package/dist/@types/packages/vue2/src/components/filter-bar/filter-bar.types.d.ts +7 -3
- package/dist/@types/packages/vue2/src/components/filter-bar/filter-bar.vue.d.ts +10 -1
- package/dist/@types/packages/vue2/src/components/form-layout/components/form-layout-field-tip/form-layout-field-tip.vue.d.ts +17 -1
- package/dist/@types/packages/vue2/src/components/form-layout/components/form-layout-field-tip/form-layout-tip.types.d.ts +3 -0
- package/dist/@types/packages/vue2/src/components/header/header.vue.d.ts +3 -0
- package/dist/@types/packages/vue2/src/components/info-icon/info-icon.vue.d.ts +3 -3
- package/dist/@types/packages/vue2/src/components/internal/base-button/base-button.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/internal/fixed-scroller/composables/index.d.ts +1 -0
- package/dist/@types/packages/vue2/src/components/internal/fixed-scroller/composables/useFixedScroller.d.ts +15 -0
- package/dist/@types/packages/vue2/src/components/internal/fixed-scroller/fixed-scroller.vue.d.ts +9 -0
- package/dist/@types/packages/vue2/src/components/internal/fixed-scroller/index.d.ts +1 -0
- package/dist/@types/packages/vue2/src/components/internal/index.d.ts +1 -0
- package/dist/@types/packages/vue2/src/components/internal/listbox/listbox.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/menu/components/menu-item/menu-item.vue.d.ts +4 -5
- package/dist/@types/packages/vue2/src/components/menu/menu.vue.d.ts +3 -3
- package/dist/@types/packages/vue2/src/components/modal/components/base-modal/base-modal.vue.d.ts +3 -3
- package/dist/@types/packages/vue2/src/components/modal/modal.vue.d.ts +9 -0
- package/dist/@types/packages/vue2/src/components/popover/popover.vue.d.ts +4 -4
- package/dist/@types/packages/vue2/src/components/popper-container/popper-container.vue.d.ts +4 -4
- package/dist/@types/packages/vue2/src/components/radio-group/radio-group.vue.d.ts +3 -3
- package/dist/@types/packages/vue2/src/components/status/status.vue.d.ts +2 -2
- package/dist/@types/packages/vue2/src/components/stepper/stepper.vue.d.ts +3 -3
- package/dist/@types/packages/vue2/src/components/summary-grid/components/summary-grid-item/summary-grid-item.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/summary-grid/components/summary-grid-item-amount/summary-grid-item-amount.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/summary-grid/components/summary-grid-item-numeric/summary-grid-item-numeric.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/summary-grid/components/summary-grid-item-percentage/summary-grid-item-percentage.vue.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/tabs/components/tab.types.d.ts +2 -1
- package/dist/@types/packages/vue2/src/components/tabs/tabs.types.d.ts +1 -1
- package/dist/@types/packages/vue2/src/components/tag/tag.vue.d.ts +4 -4
- package/dist/@types/packages/vue2/src/components/textarea/textarea.vue.d.ts +18 -46
- package/dist/@types/packages/vue2/src/components/timeline/components/timeline-item/timeline-item.vue.d.ts +6 -6
- package/dist/@types/packages/vue2/src/components/tooltip/tooltip.vue.d.ts +12 -12
- package/dist/@types/packages/vue2/src/composables/use-expandable-content-height/use-expandable-content-height.d.ts +4 -0
- package/dist/@types/packages/vue2/src/templates/data-grid-template/data-grid-template.keys.d.ts +1 -0
- package/dist/@types/packages/vue2/src/templates/data-grid-template/data-grid-template.types.d.ts +6 -0
- package/dist/@types/packages/vue2/src/templates/data-grid-template/data-grid-template.vue.d.ts +121 -1
- package/dist/@types/packages/vue2/src/templates/data-grid-template/index.d.ts +1 -0
- package/dist/@types/packages/vue2/src/utils/ts/truncate.d.ts +1 -1
- package/dist/accordion.js +33 -36
- package/dist/accordion.js.map +1 -1
- package/dist/alert.js +3 -3
- package/dist/assets/base-modal.css +1 -1
- package/dist/assets/button.css +1 -1
- package/dist/assets/controls-group.css +1 -1
- package/dist/assets/dropdown.css +1 -1
- package/dist/assets/index.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/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 -0
- 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/assets/loading-button.css +1 -1
- package/dist/avatar-image.js +1 -1
- package/dist/badge.js +1 -1
- package/dist/button.js +5 -5
- package/dist/card.js +84 -80
- package/dist/card.js.map +1 -1
- package/dist/checkbox.js +14 -15
- package/dist/checkbox.js.map +1 -1
- package/dist/chunks/{base-button.89e9efbd.js → base-button.431fb8cf.js} +2 -2
- package/dist/chunks/{base-button.89e9efbd.js.map → base-button.431fb8cf.js.map} +1 -1
- package/dist/chunks/{base-modal.6eaa7e53.js → base-modal.f462dac0.js} +41 -41
- package/dist/chunks/base-modal.f462dac0.js.map +1 -0
- package/dist/chunks/{button.66df5734.js → button.38099670.js} +2 -2
- package/dist/chunks/{button.66df5734.js.map → button.38099670.js.map} +1 -1
- package/dist/chunks/{calendar.44459d87.js → calendar.371e5ae2.js} +8 -7
- package/dist/chunks/{calendar.44459d87.js.map → calendar.371e5ae2.js.map} +1 -1
- package/dist/chunks/{checkbox.b69b8f22.js → checkbox.b8c2e583.js} +3 -3
- package/dist/chunks/{checkbox.b69b8f22.js.map → checkbox.b8c2e583.js.map} +1 -1
- package/dist/chunks/{controls-group.a2a2916f.js → controls-group.d75f1d37.js} +2 -2
- package/dist/chunks/{controls-group.a2a2916f.js.map → controls-group.d75f1d37.js.map} +1 -1
- package/dist/chunks/{copy.57f969d4.js → copy.8e44a660.js} +3 -3
- package/dist/chunks/{copy.57f969d4.js.map → copy.8e44a660.js.map} +1 -1
- package/dist/chunks/date-input.9186a0bf.js.map +1 -1
- package/dist/chunks/{dropdown-default-textbox.2d093874.js → dropdown-default-textbox.6135874c.js} +2 -2
- package/dist/chunks/{dropdown-default-textbox.2d093874.js.map → dropdown-default-textbox.6135874c.js.map} +1 -1
- package/dist/chunks/{dropdown.10ea8304.js → dropdown.5d22958c.js} +184 -179
- package/dist/chunks/dropdown.5d22958c.js.map +1 -0
- package/dist/chunks/{error-message.7a5db7f6.js → error-message.a04e8f9a.js} +2 -2
- package/dist/chunks/{error-message.7a5db7f6.js.map → error-message.a04e8f9a.js.map} +1 -1
- package/dist/chunks/{footer-actions.6ddac024.js → footer-actions.ee645663.js} +3 -3
- package/dist/chunks/{footer-actions.6ddac024.js.map → footer-actions.ee645663.js.map} +1 -1
- package/dist/chunks/{index.4a11da21.js → index.5d058912.js} +22 -21
- package/dist/chunks/{index.4a11da21.js.map → index.5d058912.js.map} +1 -1
- package/dist/chunks/{index.f607a3f1.js → index.64cce50b.js} +6 -6
- package/dist/chunks/{index.f607a3f1.js.map → index.64cce50b.js.map} +1 -1
- package/dist/chunks/{index.0f8690c4.js → index.74258013.js} +2 -2
- package/dist/chunks/{index.0f8690c4.js.map → index.74258013.js.map} +1 -1
- package/dist/chunks/{index.1645ffcb.js → index.74da0d41.js} +2 -2
- package/dist/chunks/{index.1645ffcb.js.map → index.74da0d41.js.map} +1 -1
- package/dist/chunks/{index.660f2f2e.js → index.98b6db0e.js} +3 -3
- package/dist/chunks/{index.660f2f2e.js.map → index.98b6db0e.js.map} +1 -1
- package/dist/chunks/index.af05ced4.js.map +1 -1
- package/dist/chunks/{index.e722eb60.js → index.fd557233.js} +2 -2
- package/dist/chunks/{index.e722eb60.js.map → index.fd557233.js.map} +1 -1
- package/dist/chunks/{listbox-option-tag.e2688e54.js → listbox-option-tag.a651fa46.js} +3 -3
- package/dist/chunks/{listbox-option-tag.e2688e54.js.map → listbox-option-tag.a651fa46.js.map} +1 -1
- package/dist/chunks/{listbox.201a8521.js → listbox.cbb27077.js} +7 -7
- package/dist/chunks/{listbox.201a8521.js.map → listbox.cbb27077.js.map} +1 -1
- package/dist/chunks/{loading-button.9d18b4f2.js → loading-button.21c48d50.js} +24 -24
- package/dist/chunks/loading-button.21c48d50.js.map +1 -0
- package/dist/chunks/on-click-outside.3e0c3e2a.js.map +1 -1
- package/dist/chunks/{tooltip.f89cb0cd.js → tooltip.ca9673ee.js} +2 -2
- package/dist/chunks/tooltip.ca9673ee.js.map +1 -0
- package/dist/chunks/use-expandable-content-height.62fc84e5.js +17 -0
- package/dist/chunks/use-expandable-content-height.62fc84e5.js.map +1 -0
- package/dist/chunks/use-has-slot.6052d56a.js.map +1 -1
- 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.js +707 -655
- package/dist/data-grid.js.map +1 -1
- package/dist/date-picker.js +26 -26
- package/dist/date-range-picker.js +2 -2
- package/dist/date.js +1 -1
- package/dist/divider.js +1 -1
- package/dist/dropdown.js +4 -4
- package/dist/empty-state.js +3 -3
- package/dist/filter-bar.js +727 -638
- package/dist/filter-bar.js.map +1 -1
- package/dist/focus-trap.js +1 -1
- package/dist/form-layout.js +71 -60
- package/dist/form-layout.js.map +1 -1
- package/dist/header.js +39 -36
- package/dist/header.js.map +1 -1
- package/dist/index.js +28 -28
- package/dist/info-icon.js +7 -7
- package/dist/info-icon.js.map +1 -1
- package/dist/input-field.js +71 -67
- package/dist/input-field.js.map +1 -1
- package/dist/internal.js +106 -18
- package/dist/internal.js.map +1 -1
- package/dist/link.js +29 -28
- package/dist/link.js.map +1 -1
- package/dist/loading-indicator.js +1 -1
- package/dist/menu.js +8 -6
- package/dist/menu.js.map +1 -1
- package/dist/modal.js +20 -13
- package/dist/modal.js.map +1 -1
- package/dist/pagination.js +4 -4
- package/dist/payment-method.js +2 -2
- package/dist/popover.js +3 -3
- package/dist/popper-container.js +2 -2
- package/dist/radio-group.js +4 -4
- package/dist/search-bar.js +6 -6
- package/dist/search-bar.js.map +1 -1
- package/dist/segmented-control.js +4 -4
- package/dist/sidepanel.js +28 -28
- package/dist/sidepanel.js.map +1 -1
- package/dist/status.js +2 -2
- package/dist/stepper.js +3 -3
- package/dist/structured-list.js +1 -1
- package/dist/summary-grid.js +2 -2
- package/dist/tabs.js +48 -48
- package/dist/tabs.js.map +1 -1
- package/dist/tag.js +3 -3
- package/dist/textarea.js +89 -126
- package/dist/textarea.js.map +1 -1
- package/dist/timeline.js +38 -38
- package/dist/timeline.js.map +1 -1
- package/dist/toast.js +3 -3
- package/dist/toggle.js +2 -2
- package/dist/typography.js +1 -1
- package/dist/web-types.json +289 -222
- package/package.json +5 -3
- package/dist/@types/packages/vue2/src/components/data-grid/composables/useCalculateColumnHeadersTopPosition/useCalculateColumnHeadersTopPosition.d.ts +0 -2
- package/dist/chunks/base-modal.6eaa7e53.js.map +0 -1
- package/dist/chunks/dropdown.10ea8304.js.map +0 -1
- package/dist/chunks/loading-button.9d18b4f2.js.map +0 -1
- package/dist/chunks/tooltip.f89cb0cd.js.map +0 -1
package/dist/input-field.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { d as F, B as W } from "./chunks/index.
|
|
1
|
+
import { defineComponent as H, useAttrs as q, useSlots as G, ref as R, toRef as z, computed as i, toRefs as j } from "vue";
|
|
2
|
+
import { d as F, B as W } from "./chunks/index.74da0d41.js";
|
|
3
3
|
import { u as Y } from "./chunks/use-has-slot.6052d56a.js";
|
|
4
4
|
import { u as X } from "./chunks/use-form-layout-loading.d03e5d48.js";
|
|
5
5
|
import { g as p } from "./chunks/unique-id.a2a2b458.js";
|
|
6
6
|
import { u as K } from "./chunks/i18n.155748d6.js";
|
|
7
|
-
import { a as J, B as Q } from "./chunks/dropdown.
|
|
7
|
+
import { a as J, B as Q } from "./chunks/dropdown.5d22958c.js";
|
|
8
8
|
import { g as Z } from "./chunks/get-slot-text.c1114034.js";
|
|
9
|
-
import { u as
|
|
10
|
-
import { E as
|
|
11
|
-
import { n as
|
|
12
|
-
import "./assets/
|
|
13
|
-
var
|
|
14
|
-
const
|
|
9
|
+
import { u as tt } from "./chunks/aria-label.ac9651a5.js";
|
|
10
|
+
import { E as et } from "./chunks/error-message.a04e8f9a.js";
|
|
11
|
+
import { n as at } from "./chunks/_plugin-vue2_normalizer.71e2aa87.js";
|
|
12
|
+
import "./assets/index31.css";
|
|
13
|
+
var s = /* @__PURE__ */ ((a) => (a.DEFAULT = "default", a.PAYMENT_METHOD = "payment-method", a.STATIC_VALUE = "static-value", a.DROPDOWN = "dropdown", a))(s || {}), n = /* @__PURE__ */ ((a) => (a.START = "start", a.END = "end", a))(n || {}), d = /* @__PURE__ */ ((a) => (a.CONDENSED = "condensed", a.DISABLED = "disabled", a.READONLY = "readonly", a.ERROR = "error", a.SMALL_PADDING_LEFT = "small-padding-left", a.SMALL_PADDING_RIGHT = "small-padding-right", a))(d || {}), D = /* @__PURE__ */ ((a) => (a.SEARCH = "search", a.TEXT = "text", a.NUMBER = "number", a))(D || {}), ot = /* @__PURE__ */ ((a) => (a.INPUT = "input", a.ESCAPE_PRESSED = "escape-pressed", a.UPDATE_DROPDOWN = "update:dropdown", a.DROPDOWN_INPUT = "dropdown-input", a.FOCUS = "focus", a.CHANGE = "change", a.BLUR = "blur", a.KEYDOWN = "keydown", a))(ot || {});
|
|
14
|
+
const rt = {
|
|
15
15
|
"en-US": {
|
|
16
16
|
optional: "optional",
|
|
17
17
|
required: "required",
|
|
18
18
|
ariaLabelFallback: "Input field"
|
|
19
19
|
}
|
|
20
|
-
},
|
|
21
|
-
i18n: { messages:
|
|
22
|
-
},
|
|
23
|
-
...
|
|
20
|
+
}, it = {
|
|
21
|
+
i18n: { messages: rt }
|
|
22
|
+
}, nt = /* @__PURE__ */ H({
|
|
23
|
+
...it,
|
|
24
24
|
__name: "input-field",
|
|
25
25
|
props: {
|
|
26
26
|
/**
|
|
@@ -114,86 +114,90 @@ const re = {
|
|
|
114
114
|
*/
|
|
115
115
|
variant: {
|
|
116
116
|
type: String,
|
|
117
|
-
default:
|
|
118
|
-
validator: (a) => Object.values(
|
|
117
|
+
default: s.DEFAULT,
|
|
118
|
+
validator: (a) => Object.values(s).includes(a)
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
emits: ["update:dropdown", "blur", "change", "dropdown-input", "escape-pressed", "focus", "keydown", "input"],
|
|
122
|
-
setup(a, { expose:
|
|
123
|
-
const
|
|
124
|
-
() =>
|
|
125
|
-
),
|
|
126
|
-
() => l.value &&
|
|
127
|
-
),
|
|
128
|
-
() => l.value &&
|
|
129
|
-
), u =
|
|
130
|
-
() => u.value &&
|
|
131
|
-
), E =
|
|
132
|
-
() => u.value &&
|
|
133
|
-
), m =
|
|
134
|
-
() => !
|
|
135
|
-
), V =
|
|
122
|
+
setup(a, { expose: e, emit: o }) {
|
|
123
|
+
const t = a, r = q(), c = G(), { t: h } = K(), b = Y(c), w = R(null), P = p("input"), y = p("input-dropdown"), v = p("input-static-value"), S = p("input-description"), A = p("input-error"), { isReadOnly: f } = X(z(t, "readonly")), l = i(
|
|
124
|
+
() => t.variant === s.STATIC_VALUE && !!c.staticValue
|
|
125
|
+
), C = i(() => t.variant === s.DEFAULT), N = i(() => t.variant === s.PAYMENT_METHOD), I = i(
|
|
126
|
+
() => l.value && t.staticValuePosition === n.START
|
|
127
|
+
), M = i(
|
|
128
|
+
() => l.value && t.staticValuePosition === n.END
|
|
129
|
+
), u = i(() => t.variant === s.DROPDOWN && !!t.dropdown), g = i(
|
|
130
|
+
() => u.value && t.dropdownPosition === n.START
|
|
131
|
+
), E = i(
|
|
132
|
+
() => u.value && t.dropdownPosition === n.END
|
|
133
|
+
), m = i(
|
|
134
|
+
() => !t.disabled && !f.value && (!!t.errorMessage || t.error)
|
|
135
|
+
), V = i(() => u.value === !0 && l.value === !0 ? `${v} ${y}` : u.value === !0 ? `${y}` : l.value === !0 ? `${v}` : null), T = R(r["aria-label"]), { ariaLabel: L } = j(t), k = tt({
|
|
136
136
|
ariaLabel: T.value,
|
|
137
137
|
// TODO: take this line away when the aria-label props is removed
|
|
138
138
|
label: L,
|
|
139
139
|
defaultFallback: b("default") ? Z(c)("default") : h("ariaLabelFallback")
|
|
140
|
-
}),
|
|
141
|
-
() => `${b("description") ? S : ""} ${m.value &&
|
|
142
|
-
),
|
|
143
|
-
[`b-input-field--${
|
|
144
|
-
[`b-input-field--${
|
|
145
|
-
[`b-input-field--${
|
|
146
|
-
[`b-input-field--${
|
|
147
|
-
[`b-input-field--${
|
|
148
|
-
[`b-input-field--${
|
|
140
|
+
}), B = i(
|
|
141
|
+
() => `${b("description") ? S : ""} ${m.value && t.errorMessage ? A : ""}`
|
|
142
|
+
), U = i(() => ({
|
|
143
|
+
[`b-input-field--${d.CONDENSED}`]: t.condensed,
|
|
144
|
+
[`b-input-field--${d.DISABLED}`]: t.disabled,
|
|
145
|
+
[`b-input-field--${d.READONLY}`]: f.value,
|
|
146
|
+
[`b-input-field--${d.ERROR}`]: m.value,
|
|
147
|
+
[`b-input-field--${d.SMALL_PADDING_LEFT}`]: g.value,
|
|
148
|
+
[`b-input-field--${d.SMALL_PADDING_RIGHT}`]: E.value
|
|
149
149
|
})), $ = (_) => {
|
|
150
|
-
!
|
|
151
|
-
},
|
|
152
|
-
o("dropdown-input", _), o("update:dropdown", { ...
|
|
150
|
+
!t.disabled && !f.value && o("input", _.target.value);
|
|
151
|
+
}, x = (_) => {
|
|
152
|
+
o("dropdown-input", _), o("update:dropdown", { ...t == null ? void 0 : t.dropdown, value: _ });
|
|
153
153
|
}, O = () => {
|
|
154
154
|
w.value.focus();
|
|
155
155
|
};
|
|
156
|
-
return
|
|
156
|
+
return e({
|
|
157
157
|
focusInput: O
|
|
158
|
-
}),
|
|
158
|
+
}), t.error && F(
|
|
159
159
|
'BentoInputField "error" property',
|
|
160
160
|
`Use the BentoInputField "errorMessage" property instead to indicate that there is a modifier error.
|
|
161
161
|
Having the field as "undefined" will hide/remove the error.
|
|
162
162
|
<bento-dropdown errorMessage="Error message text" />`,
|
|
163
163
|
"2.0.0"
|
|
164
|
-
), { __sfc: !0, attrs:
|
|
164
|
+
), { __sfc: !0, attrs: r, slots: c, props: t, emit: o, t: h, hasSlot: b, inputFieldElement: w, inputFieldId: P, dropdownId: y, staticValueId: v, descriptionId: S, errorId: A, isReadOnly: f, shouldShowStaticValue: l, isDefaultVariant: C, isPaymentMethodVariant: N, shouldDisplayStaticValueAtStart: I, shouldDisplayStaticValueAtEnd: M, shouldShowDropdown: u, shouldDisplayDropdownAtStart: g, shouldDisplayDropdownAtEnd: E, shouldShowError: m, computedAriaOwns: V, ariaLabelAttribute: T, ariaLabel: L, computedAriaLabel: k, computedAriaDescribedBy: B, inputFieldConditionalClasses: U, onInput: $, onDropdownInput: x, focusInput: O, BentoTypography: W, ErrorMessage: et, BentoDropdownSize: J, BentoDropdown: Q };
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
|
-
var
|
|
168
|
-
var
|
|
169
|
-
return o(
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
return
|
|
173
|
-
},
|
|
174
|
-
return
|
|
175
|
-
},
|
|
176
|
-
return
|
|
177
|
-
}, function(
|
|
178
|
-
return
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
167
|
+
var st = function() {
|
|
168
|
+
var e = this, o = e._self._c, t = e._self._setupProxy;
|
|
169
|
+
return o(t.BentoTypography, { staticClass: "b-input-field", class: t.inputFieldConditionalClasses, attrs: { "data-testid": "input-text-container", el: "div", variant: "body" } }, [t.hasSlot("default") ? o("label", { staticClass: "b-input-field__label", attrs: { for: t.inputFieldId, "data-testid": "input-field-label" }, on: { click: t.focusInput } }, [o(t.BentoTypography, { attrs: { el: "span", variant: "body", stronger: "" } }, [e._t("default")], 2), e.optional ? o(t.BentoTypography, { staticClass: "b-input-field__label-requirement", attrs: { el: "span" } }, [e._v(" (" + e._s(t.t("optional")) + ") ")]) : e._e(), e.required ? o(t.BentoTypography, { staticClass: "b-input-field__label-requirement", attrs: { el: "span" } }, [e._v(" (" + e._s(t.t("required")) + ") ")]) : e._e()], 1) : e._e(), o("div", { staticClass: "b-input-field__input-box", attrs: { "data-testid": "input-box", "aria-disabled": e.disabled }, on: { click: t.focusInput } }, [t.isDefaultVariant && t.hasSlot("defaultIconBefore") ? o("span", { staticClass: "b-input-field__default-icon-before", attrs: { "aria-hidden": e.ariaHidden ? "true" : void 0 } }, [e._t("defaultIconBefore")], 2) : e._e(), t.isPaymentMethodVariant && t.hasSlot("paymentMethod") ? o("span", { staticClass: "b-input-field__payment-method", attrs: { "aria-hidden": e.ariaHidden ? "true" : void 0 } }, [e._t("paymentMethod")], 2) : e._e(), t.shouldDisplayDropdownAtStart ? o("div", { staticClass: "b-input-field__dropdown b-input-field__dropdown--start", attrs: { id: t.dropdownId }, on: { click: function(r) {
|
|
170
|
+
r.stopPropagation();
|
|
171
|
+
} } }, [e.dropdown ? o(t.BentoDropdown, e._b({ attrs: { size: t.BentoDropdownSize.SMALL, disabled: e.disabled, readonly: t.isReadOnly }, on: { input: t.onDropdownInput } }, "bento-dropdown", e.dropdown, !1)) : e._e()], 1) : e._e(), t.shouldDisplayStaticValueAtStart ? o(t.BentoTypography, { staticClass: "b-input-field__static-value b-input-field__static-value--start", attrs: { id: t.staticValueId, el: "span", variant: "body" } }, [e._t("staticValue")], 2) : e._e(), o("input", e._b({ ref: "inputFieldElement", staticClass: "b-input-field__input", attrs: { id: t.inputFieldId, "aria-label": t.computedAriaLabel, "aria-describedby": t.computedAriaDescribedBy, "aria-owns": t.computedAriaOwns, "aria-invalid": t.shouldShowError, placeholder: e.placeholder, type: e.type, disabled: e.disabled, readonly: t.isReadOnly }, domProps: { value: e.value }, on: { input: t.onInput, change: function(r) {
|
|
172
|
+
return t.emit("change");
|
|
173
|
+
}, focus: function(r) {
|
|
174
|
+
return t.emit("focus");
|
|
175
|
+
}, blur: function(r) {
|
|
176
|
+
return t.emit("blur");
|
|
177
|
+
}, keydown: [function(r) {
|
|
178
|
+
return t.emit("keydown", r);
|
|
179
|
+
}, function(r) {
|
|
180
|
+
return !r.type.indexOf("key") && e._k(r.keyCode, "esc", 27, r.key, ["Esc", "Escape"]) ? null : t.emit("escape-pressed");
|
|
181
|
+
}] } }, "input", t.attrs, !1)), t.hasSlot("iconAfter") ? o("span", { staticClass: "b-input-field__icon-after", attrs: { "aria-hidden": e.ariaHidden ? "true" : void 0, "data-testid": "input-text__icon-after" } }, [e._t("iconAfter")], 2) : e._e(), t.shouldDisplayStaticValueAtEnd ? o(t.BentoTypography, { staticClass: "b-input-field__static-value b-input-field__static-value--end", attrs: { id: t.staticValueId, el: "span", variant: "body" } }, [e._t("staticValue")], 2) : e._e(), t.shouldDisplayDropdownAtEnd ? o("div", { staticClass: "b-input-field__dropdown b-input-field__dropdown--end", attrs: { id: t.dropdownId }, on: { click: function(r) {
|
|
182
|
+
r.stopPropagation();
|
|
183
|
+
} } }, [e.dropdown ? o(t.BentoDropdown, e._b({ attrs: { id: t.dropdownId, size: t.BentoDropdownSize.SMALL, disabled: e.disabled, readonly: t.isReadOnly }, on: { input: t.onDropdownInput } }, "bento-dropdown", e.dropdown, !1)) : e._e()], 1) : e._e()], 1), t.shouldShowError && e.errorMessage ? o(t.ErrorMessage, { staticClass: "b-input-field__error-message", attrs: { id: t.errorId, "error-message": e.errorMessage } }) : e._e(), t.hasSlot("description") ? o("span", { staticClass: "b-input-field__description", attrs: { id: t.descriptionId }, on: { click: t.focusInput } }, [o(t.BentoTypography, { attrs: { el: "span", variant: "body" } }, [e._t("description", null, { id: "description" })], 2)], 1) : e._e()], 1);
|
|
184
|
+
}, dt = [], lt = /* @__PURE__ */ at(
|
|
185
|
+
nt,
|
|
186
|
+
st,
|
|
187
|
+
dt,
|
|
184
188
|
!1,
|
|
185
189
|
null,
|
|
186
|
-
"
|
|
190
|
+
"b24025c3",
|
|
187
191
|
null,
|
|
188
192
|
null
|
|
189
193
|
);
|
|
190
|
-
const
|
|
194
|
+
const wt = lt.exports;
|
|
191
195
|
export {
|
|
192
|
-
|
|
196
|
+
wt as BentoInputField,
|
|
193
197
|
n as BentoInputFieldElementPosition,
|
|
194
|
-
|
|
195
|
-
|
|
198
|
+
ot as BentoInputFieldEvent,
|
|
199
|
+
d as BentoInputFieldStateClass,
|
|
196
200
|
D as BentoInputFieldType,
|
|
197
|
-
|
|
201
|
+
s as BentoInputFieldVariant
|
|
198
202
|
};
|
|
199
203
|
//# sourceMappingURL=input-field.js.map
|
package/dist/input-field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-field.js","sources":["../src/components/input-field/input-field.types.ts","../src/components/input-field/input-field.vue"],"sourcesContent":["import { BentoDropdown } from '@/components/dropdown/';\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoInputFieldVariant {\n DEFAULT = 'default',\n PAYMENT_METHOD = 'payment-method',\n STATIC_VALUE = 'static-value',\n DROPDOWN = 'dropdown',\n}\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoInputFieldElementPosition {\n START = 'start',\n END = 'end',\n}\n\nexport enum BentoInputFieldStateClass {\n CONDENSED = 'condensed',\n DISABLED = 'disabled',\n READONLY = 'readonly',\n ERROR = 'error',\n SMALL_PADDING_LEFT = 'small-padding-left',\n SMALL_PADDING_RIGHT = 'small-padding-right',\n}\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoInputFieldType {\n SEARCH = 'search',\n TEXT = 'text',\n NUMBER = 'number',\n}\n\nexport type BentoInputFieldValue = string | number;\n\ntype DropdownProps = InstanceType<typeof BentoDropdown>['$props'];\nexport type BentoInputDropdownProps = {\n items: DropdownProps['items'];\n value: DropdownProps['value'];\n};\n\n/**\n * @deprecated The use of these enums is no longer supported.\n * Use `v-on:` or `@` to listen to the events being emitted.\n * This enum will be removed in 2.0.\n */\nexport enum BentoInputFieldEvent {\n INPUT = 'input',\n ESCAPE_PRESSED = 'escape-pressed',\n UPDATE_DROPDOWN = 'update:dropdown',\n DROPDOWN_INPUT = 'dropdown-input',\n FOCUS = 'focus',\n CHANGE = 'change',\n BLUR = 'blur',\n KEYDOWN = 'keydown',\n}\n","<template>\n <bento-typography\n class=\"b-input-field\"\n data-testid=\"input-text-container\"\n :class=\"inputFieldConditionalClasses\"\n el=\"div\"\n variant=\"body\"\n >\n <!-- Label -->\n <label\n v-if=\"hasSlot('default')\"\n :for=\"inputFieldId\"\n class=\"b-input-field__label\"\n data-testid=\"input-field-label\"\n @click=\"focusInput\"\n >\n <bento-typography el=\"span\" variant=\"body\" stronger>\n <slot></slot>\n </bento-typography>\n <bento-typography v-if=\"optional\" class=\"b-input-field__label-requirement\" el=\"span\">\n ({{ t('optional') }})\n </bento-typography>\n <bento-typography v-if=\"required\" class=\"b-input-field__label-requirement\" el=\"span\">\n ({{ t('required') }})\n </bento-typography>\n </label>\n\n <div class=\"b-input-field__input-box\" :aria-disabled=\"disabled\">\n <!-- Optional Icon for Default text variant -->\n <span\n v-if=\"isDefaultVariant && hasSlot('defaultIconBefore')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__default-icon-before\"\n >\n <slot name=\"defaultIconBefore\" />\n </span>\n\n <!-- Mandatory Icon for Payment Method variant -->\n <span\n v-if=\"isPaymentMethodVariant && hasSlot('paymentMethod')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__payment-method\"\n >\n <slot name=\"paymentMethod\" />\n </span>\n\n <!-- Dropdown at start -->\n <div\n v-if=\"shouldDisplayDropdownAtStart\"\n :id=\"dropdownId\"\n class=\"b-input-field__dropdown b-input-field__dropdown--start\"\n >\n <bento-dropdown\n v-if=\"dropdown\"\n v-bind=\"dropdown\"\n :size=\"BentoDropdownSize.SMALL\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onDropdownInput\"\n />\n </div>\n\n <!-- Static Value at start -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtStart\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--start\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n\n <input\n :id=\"inputFieldId\"\n ref=\"inputFieldElement\"\n class=\"b-input-field__input\"\n :aria-label=\"computedAriaLabel\"\n :aria-describedby=\"computedAriaDescribedBy\"\n :aria-owns=\"computedAriaOwns\"\n :aria-invalid=\"shouldShowError\"\n :placeholder=\"placeholder\"\n :type=\"type\"\n :value=\"value\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onInput\"\n @change=\"emit('change')\"\n @focus=\"emit('focus')\"\n @blur=\"emit('blur')\"\n @keydown=\"emit('keydown', $event)\"\n @keydown.esc=\"emit('escape-pressed')\"\n />\n <span\n v-if=\"hasSlot('iconAfter')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__icon-after\"\n data-testid=\"input-text__icon-after\"\n >\n <slot name=\"iconAfter\" />\n </span>\n\n <!-- Static Value at the end -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtEnd\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--end\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n\n <!-- Dropdown at end -->\n <div\n v-if=\"shouldDisplayDropdownAtEnd\"\n :id=\"dropdownId\"\n class=\"b-input-field__dropdown b-input-field__dropdown--end\"\n >\n <bento-dropdown\n v-if=\"dropdown\"\n :id=\"dropdownId\"\n v-bind=\"dropdown\"\n :size=\"BentoDropdownSize.SMALL\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onDropdownInput\"\n />\n </div>\n </div>\n\n <error-message\n v-if=\"shouldShowError && !!errorMessage\"\n :id=\"errorId\"\n :error-message=\"errorMessage\"\n class=\"b-input-field__error-message\"\n />\n\n <span v-if=\"hasSlot('description')\" :id=\"descriptionId\" class=\"b-input-field__description\" @click=\"focusInput\">\n <bento-typography el=\"span\" variant=\"body\">\n <slot id=\"description\" name=\"description\" />\n </bento-typography>\n </span>\n </bento-typography>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, PropType, ref, toRef, toRefs, useAttrs, useSlots } from 'vue';\n import {\n BentoInputDropdownProps,\n BentoInputFieldElementPosition,\n BentoInputFieldStateClass,\n BentoInputFieldType,\n BentoInputFieldValue,\n BentoInputFieldVariant,\n } from './input-field.types';\n import { BentoTypography } from '@/components/typography';\n import { ErrorMessage } from '@/components/internal/error-message';\n import { useFormLayoutFieldLoading, useHasSlot } from '@/composables';\n import { generateUid } from '@/utils/ts/unique-id';\n import { useI18n } from '@/utils/ts/i18n';\n import { BentoDropdownSize } from '../dropdown/dropdown.types';\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoListboxSelectedValue } from '@/types';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { deprecate } from '@/utils/ts/deprecate';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const attrs = useAttrs();\n const slots = useSlots();\n\n const props = defineProps({\n /**\n * Indicates whether the element is exposed to an accessibility API.\n */\n ariaHidden: { type: Boolean, default: true },\n\n /**\n * @deprecated from version 2.0.0. Use the aria-label attribute instead.\n */\n /**\n * Text that labels an the input element\n */\n ariaLabel: { type: String, default: undefined },\n\n /**\n * Reduces height of the input\n */\n condensed: { type: Boolean, default: false },\n\n /**\n * Disables the possibility of changing value in the input-field\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Dropdown props for the small selectable dropdown menu.\n * @see BentoDropdown\n */\n dropdown: {\n type: Object as PropType<BentoInputDropdownProps>,\n default: undefined,\n },\n\n /**\n * Position of the dropdown before or after input value\n */\n dropdownPosition: {\n type: String as PropType<BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`>,\n default: BentoInputFieldElementPosition.START,\n validator: (value: BentoInputFieldElementPosition) =>\n Object.values(BentoInputFieldElementPosition).includes(value),\n },\n\n /**\n * Adds error validation class for outlining input-field.\n *\n * @deprecated Use \"errorMessage\" prop instead\n */\n error: { type: Boolean, default: false },\n\n /**\n * Renders input-field with an error state and the error message beneath the input box\n */\n errorMessage: { type: String, default: null },\n\n /**\n * Highlights the dropdown is optional.\n */\n optional: { type: Boolean, default: false },\n\n /**\n * Text displayed as the placeholder of the input-field\n */\n placeholder: { type: String, default: '' },\n\n /**\n * Highlights the dropdown is required.\n */\n required: { type: Boolean, default: false },\n\n /**\n * Setting this property to true will set the input field to read only state.\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * Static text that displayed before or after input value\n * Applicable to the Static Value variant\n */\n staticValue: { type: String, default: '' },\n\n /**\n * Position of Static Value before or after input value\n */\n staticValuePosition: {\n type: String as PropType<BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`>,\n default: BentoInputFieldElementPosition.START,\n validator: (value: BentoInputFieldElementPosition) =>\n Object.values(BentoInputFieldElementPosition).includes(value),\n },\n\n /**\n * A string specifying the type of control to render.\n */\n type: {\n type: String as PropType<BentoInputFieldType | `${BentoInputFieldType}`>,\n default: BentoInputFieldType.TEXT,\n validator: (value: BentoInputFieldType) => Object.values(BentoInputFieldType).includes(value),\n },\n\n /**\n * Text displayed as the value of the input-field\n */\n value: { type: [String, Number] as PropType<BentoInputFieldValue>, default: undefined },\n\n /**\n * Describes the different variants for the input element\n */\n variant: {\n type: String as PropType<BentoInputFieldVariant | `${BentoInputFieldVariant}`>,\n default: BentoInputFieldVariant.DEFAULT,\n validator: (value: BentoInputFieldVariant) => Object.values(BentoInputFieldVariant).includes(value),\n },\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the Input Field's internal dropdown changes it's value. Contains every dropdown prop passed with the updated selected value as 'value'\n */\n (e: 'update:dropdown', updatedDropdownProps: BentoInputDropdownProps): void;\n\n /**\n * Emitted when the element has lost focus\n */\n (e: 'blur'): void;\n\n /**\n * Emitted when the user modifies the element's value. Unlike the 'input' event, the change event is not necessarily fired for each alteration to an element's value\n */\n (e: 'change'): void;\n\n /**\n * Emitted when the Input Field's internal dropdown changes it's value\n */\n (e: 'dropdown-input', selectedValue: BentoListboxSelectedValue): void;\n\n /**\n * Emitted when the \"ESC\" key is pressed\n */\n (e: 'escape-pressed'): void;\n\n /**\n * Emitted when the element has received focus\n */\n (e: 'focus'): void;\n\n /**\n * Emitted when a key is pressed\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when the component's model changes\n */\n (e: 'input', inputValue: string): void;\n }>();\n\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const hasSlot = useHasSlot(slots);\n const inputFieldElement = ref(null);\n const inputFieldId = generateUid('input');\n const dropdownId = generateUid('input-dropdown');\n const staticValueId = generateUid('input-static-value');\n const descriptionId = generateUid('input-description');\n const errorId = generateUid('input-error');\n\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n\n const shouldShowStaticValue = computed(\n () => props.variant === BentoInputFieldVariant.STATIC_VALUE && !!slots.staticValue\n );\n\n const isDefaultVariant = computed(() => props.variant === BentoInputFieldVariant.DEFAULT);\n\n const isPaymentMethodVariant = computed(() => props.variant === BentoInputFieldVariant.PAYMENT_METHOD);\n\n const shouldDisplayStaticValueAtStart = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayStaticValueAtEnd = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowDropdown = computed(() => props.variant === BentoInputFieldVariant.DROPDOWN && !!props.dropdown);\n const shouldDisplayDropdownAtStart = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayDropdownAtEnd = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowError = computed(\n () => !props.disabled && !isReadOnly.value && (!!props.errorMessage || props.error)\n );\n\n const computedAriaOwns = computed(() => {\n if (shouldShowDropdown.value === true && shouldShowStaticValue.value === true) {\n return `${staticValueId} ${dropdownId}`;\n }\n if (shouldShowDropdown.value === true) {\n return `${dropdownId}`;\n }\n if (shouldShowStaticValue.value === true) {\n return `${staticValueId}`;\n }\n return null;\n });\n\n const ariaLabelAttribute = ref(attrs['aria-label']);\n const { ariaLabel } = toRefs(props);\n const computedAriaLabel = useAriaLabel({\n ariaLabel: ariaLabelAttribute.value as string,\n // TODO: take this line away when the aria-label props is removed\n label: ariaLabel,\n defaultFallback: hasSlot('default') ? (getSlotText(slots)('default') as string) : t('ariaLabelFallback'),\n });\n\n const computedAriaDescribedBy = computed(\n () =>\n `${hasSlot('description') ? descriptionId : ''} ${\n shouldShowError.value && !!props.errorMessage ? errorId : ''\n }`\n );\n\n const inputFieldConditionalClasses = computed(() => ({\n [`b-input-field--${BentoInputFieldStateClass.CONDENSED}`]: props.condensed,\n [`b-input-field--${BentoInputFieldStateClass.DISABLED}`]: props.disabled,\n [`b-input-field--${BentoInputFieldStateClass.READONLY}`]: isReadOnly.value,\n [`b-input-field--${BentoInputFieldStateClass.ERROR}`]: shouldShowError.value,\n [`b-input-field--${BentoInputFieldStateClass.SMALL_PADDING_LEFT}`]: shouldDisplayDropdownAtStart.value,\n [`b-input-field--${BentoInputFieldStateClass.SMALL_PADDING_RIGHT}`]: shouldDisplayDropdownAtEnd.value,\n }));\n\n const onInput = (event: Event) => {\n if (!props.disabled && !isReadOnly.value) {\n emit('input', (event.target as HTMLInputElement).value);\n }\n };\n\n const onDropdownInput = (selectedValue: BentoListboxSelectedValue) => {\n emit('dropdown-input', selectedValue);\n emit('update:dropdown', { ...props?.dropdown, value: selectedValue });\n };\n\n const focusInput = () => {\n inputFieldElement.value.focus();\n };\n\n // Expose method so that other components can focus on it in Vue3\n defineExpose({\n focusInput,\n });\n\n if (props.error) {\n deprecate(\n 'BentoInputField \"error\" property',\n `Use the BentoInputField \"errorMessage\" property instead to indicate that there is a modifier error.\n Having the field as \"undefined\" will hide/remove the error.\n <bento-dropdown errorMessage=\"Error message text\" />`,\n '2.0.0'\n );\n }\n</script>\n\n<script lang=\"ts\">\n /**\n * Input field component is used to create interactive controls for web-based\n * forms in order to accept data from the user.\n *\n * @example\n * import { BentoInputField } from '@adyen/bento-vue2'\n *\n * const inputValue = ref('');\n *\n * export default {\n * components: { BentoInputField },\n * tempate: `\n * <bento-input-field\n * :value=\"inputValue\"\n * :input=\"newValue => inputValue.value = newValue\"\n * >\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-field.scss\" />\n"],"names":["BentoInputFieldVariant","BentoInputFieldVariant2","BentoInputFieldElementPosition","BentoInputFieldElementPosition2","BentoInputFieldStateClass","BentoInputFieldStateClass2","BentoInputFieldType","BentoInputFieldType2","BentoInputFieldEvent","BentoInputFieldEvent2","__default__","messages","attrs","useAttrs","slots","useSlots","t","useI18n","hasSlot","useHasSlot","inputFieldElement","ref","inputFieldId","generateUid","dropdownId","staticValueId","descriptionId","errorId","isReadOnly","useFormLayoutFieldLoading","toRef","props","shouldShowStaticValue","computed","isDefaultVariant","isPaymentMethodVariant","shouldDisplayStaticValueAtStart","shouldDisplayStaticValueAtEnd","shouldShowDropdown","shouldDisplayDropdownAtStart","shouldDisplayDropdownAtEnd","shouldShowError","computedAriaOwns","ariaLabelAttribute","ariaLabel","toRefs","computedAriaLabel","useAriaLabel","getSlotText","computedAriaDescribedBy","inputFieldConditionalClasses","onInput","event","emit","onDropdownInput","selectedValue","focusInput","expose","deprecate"],"mappings":";;;;;;;;;;;;AAKY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,UAAA,WACAA,EAAA,iBAAA,kBACAA,EAAA,eAAA,gBACAA,EAAA,WAAA,YAJQA,IAAAD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WAAA,GAAA2B,EAAA;AAAA,MACgB,CAAA,kBAAA3B,EAAA,UAAA,GAAA2B,EAAA;AAAA,MACD,CAAA,kBAAA3B,EAAA,UAAA,GAAAwB,EAAA;AAAA,MACK,CAAA,kBAAAxB,EAAA,OAAA,GAAAqC,EAAA;AAAA,MACE,CAAA,kBAAArC,EAAA,oBAAA,GAAAmC,EAAA;AAAA,MAC0B,CAAA,kBAAAnC,EAAA,qBAAA,GAAAoC,EAAA;AAAA,IACD,EAAA,GAGpGW,IAAA,CAAAC,MAAA;AACI,MAAA,CAAArB,EAAA,YAAA,CAAAH,EAAA,SACIyB,EAAA,SAAAD,EAAA,OAAA,KAAA;AAAA,IACJ,GAGJE,IAAA,CAAAC,MAAA;AACI,MAAAF,EAAA,kBAAAE,CAAA,GACAF,EAAA,mBAAA,EAAA,GAAAtB,KAAA,gBAAAA,EAAA,UAAA,OAAAwB,EAAA,CAAA;AAAA,IAAoE,GAGxEC,IAAA,MAAA;AACI,MAAApC,EAAA,MAAA,MAAA;AAAA,IAA8B;AAIlC,WAAAqC,EAAA;AAAA,MAAa,YAAAD;AAAA,IACT,CAAA,GAGJzB,EAAA,SACI2B;AAAA,MAAA;AAAA,MACI;AAAA;AAAA;AAAA,MACA;AAAA,IAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"input-field.js","sources":["../src/components/input-field/input-field.types.ts","../src/components/input-field/input-field.vue"],"sourcesContent":["import { BentoDropdown } from '@/components/dropdown/';\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoInputFieldVariant {\n DEFAULT = 'default',\n PAYMENT_METHOD = 'payment-method',\n STATIC_VALUE = 'static-value',\n DROPDOWN = 'dropdown',\n}\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoInputFieldElementPosition {\n START = 'start',\n END = 'end',\n}\n\nexport enum BentoInputFieldStateClass {\n CONDENSED = 'condensed',\n DISABLED = 'disabled',\n READONLY = 'readonly',\n ERROR = 'error',\n SMALL_PADDING_LEFT = 'small-padding-left',\n SMALL_PADDING_RIGHT = 'small-padding-right',\n}\n\n/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoInputFieldType {\n SEARCH = 'search',\n TEXT = 'text',\n NUMBER = 'number',\n}\n\nexport type BentoInputFieldValue = string | number;\n\ntype DropdownProps = InstanceType<typeof BentoDropdown>['$props'];\nexport type BentoInputDropdownProps = {\n items: DropdownProps['items'];\n value: DropdownProps['value'];\n};\n\n/**\n * @deprecated The use of these enums is no longer supported.\n * Use `v-on:` or `@` to listen to the events being emitted.\n * This enum will be removed in 2.0.\n */\nexport enum BentoInputFieldEvent {\n INPUT = 'input',\n ESCAPE_PRESSED = 'escape-pressed',\n UPDATE_DROPDOWN = 'update:dropdown',\n DROPDOWN_INPUT = 'dropdown-input',\n FOCUS = 'focus',\n CHANGE = 'change',\n BLUR = 'blur',\n KEYDOWN = 'keydown',\n}\n","<template>\n <bento-typography\n class=\"b-input-field\"\n data-testid=\"input-text-container\"\n :class=\"inputFieldConditionalClasses\"\n el=\"div\"\n variant=\"body\"\n >\n <!-- Label -->\n <label\n v-if=\"hasSlot('default')\"\n :for=\"inputFieldId\"\n class=\"b-input-field__label\"\n data-testid=\"input-field-label\"\n @click=\"focusInput\"\n >\n <bento-typography el=\"span\" variant=\"body\" stronger>\n <slot></slot>\n </bento-typography>\n <bento-typography v-if=\"optional\" class=\"b-input-field__label-requirement\" el=\"span\">\n ({{ t('optional') }})\n </bento-typography>\n <bento-typography v-if=\"required\" class=\"b-input-field__label-requirement\" el=\"span\">\n ({{ t('required') }})\n </bento-typography>\n </label>\n\n <div class=\"b-input-field__input-box\" data-testid=\"input-box\" :aria-disabled=\"disabled\" @click=\"focusInput\">\n <!-- Optional Icon for Default text variant -->\n <span\n v-if=\"isDefaultVariant && hasSlot('defaultIconBefore')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__default-icon-before\"\n >\n <slot name=\"defaultIconBefore\" />\n </span>\n\n <!-- Mandatory Icon for Payment Method variant -->\n <span\n v-if=\"isPaymentMethodVariant && hasSlot('paymentMethod')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__payment-method\"\n >\n <slot name=\"paymentMethod\" />\n </span>\n\n <!-- Dropdown at start -->\n <div\n v-if=\"shouldDisplayDropdownAtStart\"\n :id=\"dropdownId\"\n class=\"b-input-field__dropdown b-input-field__dropdown--start\"\n @click.stop\n >\n <bento-dropdown\n v-if=\"dropdown\"\n v-bind=\"dropdown\"\n :size=\"BentoDropdownSize.SMALL\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onDropdownInput\"\n />\n </div>\n\n <!-- Static Value at start -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtStart\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--start\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n\n <input\n :id=\"inputFieldId\"\n v-bind=\"attrs\"\n ref=\"inputFieldElement\"\n class=\"b-input-field__input\"\n :aria-label=\"computedAriaLabel\"\n :aria-describedby=\"computedAriaDescribedBy\"\n :aria-owns=\"computedAriaOwns\"\n :aria-invalid=\"shouldShowError\"\n :placeholder=\"placeholder\"\n :type=\"type\"\n :value=\"value\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onInput\"\n @change=\"emit('change')\"\n @focus=\"emit('focus')\"\n @blur=\"emit('blur')\"\n @keydown=\"emit('keydown', $event)\"\n @keydown.esc=\"emit('escape-pressed')\"\n />\n <span\n v-if=\"hasSlot('iconAfter')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__icon-after\"\n data-testid=\"input-text__icon-after\"\n >\n <slot name=\"iconAfter\" />\n </span>\n\n <!-- Static Value at the end -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtEnd\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--end\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n\n <!-- Dropdown at end -->\n <div\n v-if=\"shouldDisplayDropdownAtEnd\"\n :id=\"dropdownId\"\n class=\"b-input-field__dropdown b-input-field__dropdown--end\"\n @click.stop\n >\n <bento-dropdown\n v-if=\"dropdown\"\n :id=\"dropdownId\"\n v-bind=\"dropdown\"\n :size=\"BentoDropdownSize.SMALL\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onDropdownInput\"\n />\n </div>\n </div>\n\n <error-message\n v-if=\"shouldShowError && !!errorMessage\"\n :id=\"errorId\"\n :error-message=\"errorMessage\"\n class=\"b-input-field__error-message\"\n />\n\n <span v-if=\"hasSlot('description')\" :id=\"descriptionId\" class=\"b-input-field__description\" @click=\"focusInput\">\n <bento-typography el=\"span\" variant=\"body\">\n <slot id=\"description\" name=\"description\" />\n </bento-typography>\n </span>\n </bento-typography>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, PropType, ref, toRef, toRefs, useAttrs, useSlots } from 'vue';\n import {\n BentoInputDropdownProps,\n BentoInputFieldElementPosition,\n BentoInputFieldStateClass,\n BentoInputFieldType,\n BentoInputFieldValue,\n BentoInputFieldVariant,\n } from './input-field.types';\n import { BentoTypography } from '@/components/typography';\n import { ErrorMessage } from '@/components/internal/error-message';\n import { useFormLayoutFieldLoading, useHasSlot } from '@/composables';\n import { generateUid } from '@/utils/ts/unique-id';\n import { useI18n } from '@/utils/ts/i18n';\n import { BentoDropdownSize } from '../dropdown/dropdown.types';\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoListboxSelectedValue } from '@/types';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { deprecate } from '@/utils/ts/deprecate';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const attrs = useAttrs();\n const slots = useSlots();\n\n const props = defineProps({\n /**\n * Indicates whether the element is exposed to an accessibility API.\n */\n ariaHidden: { type: Boolean, default: true },\n\n /**\n * @deprecated from version 2.0.0. Use the aria-label attribute instead.\n */\n /**\n * Text that labels an the input element\n */\n ariaLabel: { type: String, default: undefined },\n\n /**\n * Reduces height of the input\n */\n condensed: { type: Boolean, default: false },\n\n /**\n * Disables the possibility of changing value in the input-field\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Dropdown props for the small selectable dropdown menu.\n * @see BentoDropdown\n */\n dropdown: {\n type: Object as PropType<BentoInputDropdownProps>,\n default: undefined,\n },\n\n /**\n * Position of the dropdown before or after input value\n */\n dropdownPosition: {\n type: String as PropType<BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`>,\n default: BentoInputFieldElementPosition.START,\n validator: (value: BentoInputFieldElementPosition) =>\n Object.values(BentoInputFieldElementPosition).includes(value),\n },\n\n /**\n * Adds error validation class for outlining input-field.\n *\n * @deprecated Use \"errorMessage\" prop instead\n */\n error: { type: Boolean, default: false },\n\n /**\n * Renders input-field with an error state and the error message beneath the input box\n */\n errorMessage: { type: String, default: null },\n\n /**\n * Highlights the dropdown is optional.\n */\n optional: { type: Boolean, default: false },\n\n /**\n * Text displayed as the placeholder of the input-field\n */\n placeholder: { type: String, default: '' },\n\n /**\n * Highlights the dropdown is required.\n */\n required: { type: Boolean, default: false },\n\n /**\n * Setting this property to true will set the input field to read only state.\n */\n readonly: { type: Boolean, default: false },\n\n /**\n * Static text that displayed before or after input value\n * Applicable to the Static Value variant\n */\n staticValue: { type: String, default: '' },\n\n /**\n * Position of Static Value before or after input value\n */\n staticValuePosition: {\n type: String as PropType<BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`>,\n default: BentoInputFieldElementPosition.START,\n validator: (value: BentoInputFieldElementPosition) =>\n Object.values(BentoInputFieldElementPosition).includes(value),\n },\n\n /**\n * A string specifying the type of control to render.\n */\n type: {\n type: String as PropType<BentoInputFieldType | `${BentoInputFieldType}`>,\n default: BentoInputFieldType.TEXT,\n validator: (value: BentoInputFieldType) => Object.values(BentoInputFieldType).includes(value),\n },\n\n /**\n * Text displayed as the value of the input-field\n */\n value: { type: [String, Number] as PropType<BentoInputFieldValue>, default: undefined },\n\n /**\n * Describes the different variants for the input element\n */\n variant: {\n type: String as PropType<BentoInputFieldVariant | `${BentoInputFieldVariant}`>,\n default: BentoInputFieldVariant.DEFAULT,\n validator: (value: BentoInputFieldVariant) => Object.values(BentoInputFieldVariant).includes(value),\n },\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the Input Field's internal dropdown changes it's value. Contains every dropdown prop passed with the updated selected value as 'value'\n */\n (e: 'update:dropdown', updatedDropdownProps: BentoInputDropdownProps): void;\n\n /**\n * Emitted when the element has lost focus\n */\n (e: 'blur'): void;\n\n /**\n * Emitted when the user modifies the element's value. Unlike the 'input' event, the change event is not necessarily fired for each alteration to an element's value\n */\n (e: 'change'): void;\n\n /**\n * Emitted when the Input Field's internal dropdown changes it's value\n */\n (e: 'dropdown-input', selectedValue: BentoListboxSelectedValue): void;\n\n /**\n * Emitted when the \"ESC\" key is pressed\n */\n (e: 'escape-pressed'): void;\n\n /**\n * Emitted when the element has received focus\n */\n (e: 'focus'): void;\n\n /**\n * Emitted when a key is pressed\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when the component's model changes\n */\n (e: 'input', inputValue: string): void;\n }>();\n\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const hasSlot = useHasSlot(slots);\n const inputFieldElement = ref(null);\n const inputFieldId = generateUid('input');\n const dropdownId = generateUid('input-dropdown');\n const staticValueId = generateUid('input-static-value');\n const descriptionId = generateUid('input-description');\n const errorId = generateUid('input-error');\n\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n\n const shouldShowStaticValue = computed(\n () => props.variant === BentoInputFieldVariant.STATIC_VALUE && !!slots.staticValue\n );\n\n const isDefaultVariant = computed(() => props.variant === BentoInputFieldVariant.DEFAULT);\n\n const isPaymentMethodVariant = computed(() => props.variant === BentoInputFieldVariant.PAYMENT_METHOD);\n\n const shouldDisplayStaticValueAtStart = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayStaticValueAtEnd = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowDropdown = computed(() => props.variant === BentoInputFieldVariant.DROPDOWN && !!props.dropdown);\n const shouldDisplayDropdownAtStart = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayDropdownAtEnd = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowError = computed(\n () => !props.disabled && !isReadOnly.value && (!!props.errorMessage || props.error)\n );\n\n const computedAriaOwns = computed(() => {\n if (shouldShowDropdown.value === true && shouldShowStaticValue.value === true) {\n return `${staticValueId} ${dropdownId}`;\n }\n if (shouldShowDropdown.value === true) {\n return `${dropdownId}`;\n }\n if (shouldShowStaticValue.value === true) {\n return `${staticValueId}`;\n }\n return null;\n });\n\n const ariaLabelAttribute = ref(attrs['aria-label']);\n const { ariaLabel } = toRefs(props);\n const computedAriaLabel = useAriaLabel({\n ariaLabel: ariaLabelAttribute.value as string,\n // TODO: take this line away when the aria-label props is removed\n label: ariaLabel,\n defaultFallback: hasSlot('default') ? (getSlotText(slots)('default') as string) : t('ariaLabelFallback'),\n });\n\n const computedAriaDescribedBy = computed(\n () =>\n `${hasSlot('description') ? descriptionId : ''} ${\n shouldShowError.value && !!props.errorMessage ? errorId : ''\n }`\n );\n\n const inputFieldConditionalClasses = computed(() => ({\n [`b-input-field--${BentoInputFieldStateClass.CONDENSED}`]: props.condensed,\n [`b-input-field--${BentoInputFieldStateClass.DISABLED}`]: props.disabled,\n [`b-input-field--${BentoInputFieldStateClass.READONLY}`]: isReadOnly.value,\n [`b-input-field--${BentoInputFieldStateClass.ERROR}`]: shouldShowError.value,\n [`b-input-field--${BentoInputFieldStateClass.SMALL_PADDING_LEFT}`]: shouldDisplayDropdownAtStart.value,\n [`b-input-field--${BentoInputFieldStateClass.SMALL_PADDING_RIGHT}`]: shouldDisplayDropdownAtEnd.value,\n }));\n\n const onInput = (event: Event) => {\n if (!props.disabled && !isReadOnly.value) {\n emit('input', (event.target as HTMLInputElement).value);\n }\n };\n\n const onDropdownInput = (selectedValue: BentoListboxSelectedValue) => {\n emit('dropdown-input', selectedValue);\n emit('update:dropdown', { ...props?.dropdown, value: selectedValue });\n };\n\n const focusInput = () => {\n inputFieldElement.value.focus();\n };\n\n // Expose method so that other components can focus on it in Vue3\n defineExpose({\n focusInput,\n });\n\n if (props.error) {\n deprecate(\n 'BentoInputField \"error\" property',\n `Use the BentoInputField \"errorMessage\" property instead to indicate that there is a modifier error.\n Having the field as \"undefined\" will hide/remove the error.\n <bento-dropdown errorMessage=\"Error message text\" />`,\n '2.0.0'\n );\n }\n</script>\n\n<script lang=\"ts\">\n /**\n * Input field component is used to create interactive controls for web-based\n * forms in order to accept data from the user.\n *\n * @example\n * import { BentoInputField } from '@adyen/bento-vue2'\n *\n * const inputValue = ref('');\n *\n * export default {\n * components: { BentoInputField },\n * tempate: `\n * <bento-input-field\n * :value=\"inputValue\"\n * :input=\"newValue => inputValue.value = newValue\"\n * >\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-field.scss\" />\n"],"names":["BentoInputFieldVariant","BentoInputFieldVariant2","BentoInputFieldElementPosition","BentoInputFieldElementPosition2","BentoInputFieldStateClass","BentoInputFieldStateClass2","BentoInputFieldType","BentoInputFieldType2","BentoInputFieldEvent","BentoInputFieldEvent2","__default__","messages","attrs","useAttrs","slots","useSlots","t","useI18n","hasSlot","useHasSlot","inputFieldElement","ref","inputFieldId","generateUid","dropdownId","staticValueId","descriptionId","errorId","isReadOnly","useFormLayoutFieldLoading","toRef","props","shouldShowStaticValue","computed","isDefaultVariant","isPaymentMethodVariant","shouldDisplayStaticValueAtStart","shouldDisplayStaticValueAtEnd","shouldShowDropdown","shouldDisplayDropdownAtStart","shouldDisplayDropdownAtEnd","shouldShowError","computedAriaOwns","ariaLabelAttribute","ariaLabel","toRefs","computedAriaLabel","useAriaLabel","getSlotText","computedAriaDescribedBy","inputFieldConditionalClasses","onInput","event","emit","onDropdownInput","selectedValue","focusInput","expose","deprecate"],"mappings":";;;;;;;;;;;;AAKY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,UAAA,WACAA,EAAA,iBAAA,kBACAA,EAAA,eAAA,gBACAA,EAAA,WAAA,YAJQA,IAAAD,KAAA,CAAA,CAAA,GAUAE,IAAA,kBAAAC,OACRA,EAAA,QAAA,SACAA,EAAA,MAAA,OAFQA,IAAAD,KAAA,CAAA,CAAA,GAKAE,IAAA,kBAAAC,OACRA,EAAA,YAAA,aACAA,EAAA,WAAA,YACAA,EAAA,WAAA,YACAA,EAAA,QAAA,SACAA,EAAA,qBAAA,sBACAA,EAAA,sBAAA,uBANQA,IAAAD,KAAA,CAAA,CAAA,GAYAE,IAAA,kBAAAC,OACRA,EAAA,SAAA,UACAA,EAAA,OAAA,QACAA,EAAA,SAAA,UAHQA,IAAAD,KAAA,CAAA,CAAA,GAmBAE,KAAA,kBAAAC,OACRA,EAAA,QAAA,SACAA,EAAA,iBAAA,kBACAA,EAAA,kBAAA,mBACAA,EAAA,iBAAA,kBACAA,EAAA,QAAA,SACAA,EAAA,SAAA,UACAA,EAAA,OAAA,QACAA,EAAA,UAAA,WARQA,IAAAD,MAAA,CAAA,CAAA;;;;;;;GC0ZRE,KAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,GAAA;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAhSAC,IAAAC,EAAA,G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;;;;;;;;;;;;;;;;"}
|
package/dist/internal.js
CHANGED
|
@@ -1,21 +1,109 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
import {
|
|
3
|
-
import { C } from "./chunks/copy.
|
|
4
|
-
import { C as
|
|
5
|
-
import { E as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { B as X, L as $ } from "./chunks/listbox-option-tag.a651fa46.js";
|
|
2
|
+
import { a as q, b as H, C as J } from "./chunks/calendar.371e5ae2.js";
|
|
3
|
+
import { C as N } from "./chunks/copy.8e44a660.js";
|
|
4
|
+
import { C as Y } from "./chunks/controls-group.d75f1d37.js";
|
|
5
|
+
import { E as tt } from "./chunks/error-message.a04e8f9a.js";
|
|
6
|
+
import { ref as i, computed as a, defineComponent as g } from "vue";
|
|
7
|
+
import { a as C } from "./chunks/button.38099670.js";
|
|
8
|
+
import { u as B } from "./chunks/i18n.155748d6.js";
|
|
9
|
+
import { C as R, a as L } from "./chunks/chevron-right.3b826337.js";
|
|
10
|
+
import { n as S } from "./chunks/_plugin-vue2_normalizer.71e2aa87.js";
|
|
11
|
+
import { G as ot, a as rt } from "./chunks/grid-layout.b7e0d964.js";
|
|
12
|
+
import { b as st } from "./chunks/listbox.cbb27077.js";
|
|
13
|
+
import "./assets/index12.css";
|
|
14
|
+
const y = ({
|
|
15
|
+
contentRef: v,
|
|
16
|
+
containerRef: r,
|
|
17
|
+
leftButtonRef: e,
|
|
18
|
+
rightButtonRef: t
|
|
19
|
+
}) => {
|
|
20
|
+
const s = i(0), l = i(0), u = a(() => {
|
|
21
|
+
var o;
|
|
22
|
+
return (o = v.value) == null ? void 0 : o.scrollWidth;
|
|
23
|
+
}), c = a(() => {
|
|
24
|
+
var o;
|
|
25
|
+
return (o = r.value) == null ? void 0 : o.clientWidth;
|
|
26
|
+
}), h = a(() => {
|
|
27
|
+
var n, _;
|
|
28
|
+
const o = ((n = e.value) == null ? void 0 : n.scrollWidth) ?? 0, p = ((_ = t.value) == null ? void 0 : _.scrollWidth) ?? 0;
|
|
29
|
+
return o + p;
|
|
30
|
+
}), f = a(() => Math.ceil(u.value / c.value) ?? 0), d = a(() => {
|
|
31
|
+
const o = new Array(f.value).fill(0);
|
|
32
|
+
return o.forEach((p, n) => {
|
|
33
|
+
if (n === 0)
|
|
34
|
+
return;
|
|
35
|
+
if (n === f.value - 1) {
|
|
36
|
+
o[o.length - 1] = -(u.value - c.value);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const _ = o[n - 1];
|
|
40
|
+
o[n] = -(c.value + Math.abs(_) - h.value);
|
|
41
|
+
}), o;
|
|
42
|
+
}), m = a(() => l.value !== 0), x = a(
|
|
43
|
+
() => s.value === 0 || s.value >= -(u.value - c.value - 1)
|
|
44
|
+
);
|
|
45
|
+
return {
|
|
46
|
+
offset: s,
|
|
47
|
+
shouldShowLeftButton: m,
|
|
48
|
+
shouldShowRightButton: x,
|
|
49
|
+
// Methods
|
|
50
|
+
scrollLeft: () => {
|
|
51
|
+
l.value !== 0 && (l.value -= 1, s.value = d.value[l.value]);
|
|
52
|
+
},
|
|
53
|
+
scrollRight: () => {
|
|
54
|
+
l.value !== f.value - 1 && (l.value += 1, s.value = d.value[l.value]);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, b = {
|
|
58
|
+
"en-US": {
|
|
59
|
+
scrollLeft: "Scroll left",
|
|
60
|
+
scrollRight: "Scroll right"
|
|
61
|
+
}
|
|
62
|
+
}, W = {
|
|
63
|
+
i18n: { messages: b }
|
|
64
|
+
}, w = /* @__PURE__ */ g({
|
|
65
|
+
...W,
|
|
66
|
+
__name: "fixed-scroller",
|
|
67
|
+
setup(v) {
|
|
68
|
+
const { t: r } = B(), e = i(null), t = i(null), s = i(null), l = i(null), { offset: u, shouldShowLeftButton: c, shouldShowRightButton: h, scrollLeft: f, scrollRight: d } = y({
|
|
69
|
+
contentRef: e,
|
|
70
|
+
containerRef: t,
|
|
71
|
+
leftButtonRef: s,
|
|
72
|
+
rightButtonRef: l
|
|
73
|
+
});
|
|
74
|
+
return { __sfc: !0, t: r, contentRef: e, fixedScrollerRef: t, leftButtonRef: s, rightButtonRef: l, offset: u, shouldShowLeftButton: c, shouldShowRightButton: h, scrollLeft: f, scrollRight: d, BentoButton: C, ChevronLeftIcon: R, ChevronRightIcon: L };
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
var k = function() {
|
|
78
|
+
var r = this, e = r._self._c, t = r._self._setupProxy;
|
|
79
|
+
return e("div", { ref: "fixedScrollerRef", staticClass: "b-fixed-scroller" }, [e("div", { staticClass: "b-fixed-scroller__container" }, [e("div", { ref: "contentRef", staticClass: "b-fixed-scroller__content", style: { transform: `translateX(${t.offset}px)` } }, [r._t("default")], 2)]), t.shouldShowLeftButton ? e("div", { ref: "leftButtonRef", staticClass: "b-fixed-scroller__left" }, [e(t.BentoButton, { attrs: { variant: "secondary", "aria-label": t.t("scrollLeft") }, on: { click: t.scrollLeft }, scopedSlots: r._u([{ key: "iconLeft", fn: function() {
|
|
80
|
+
return [e(t.ChevronLeftIcon, { attrs: { "svg-title": "checked", "aria-hidden": "true" } })];
|
|
81
|
+
}, proxy: !0 }], null, !1, 1728943899) })], 1) : r._e(), t.shouldShowRightButton ? e("div", { ref: "rightButtonRef", staticClass: "b-fixed-scroller__right" }, [e(t.BentoButton, { attrs: { variant: "secondary", "aria-label": t.t("scrollRight") }, on: { click: t.scrollRight }, scopedSlots: r._u([{ key: "iconLeft", fn: function() {
|
|
82
|
+
return [e(t.ChevronRightIcon, { attrs: { "svg-title": "checked", "aria-hidden": "true" } })];
|
|
83
|
+
}, proxy: !0 }], null, !1, 29940896) })], 1) : r._e()]);
|
|
84
|
+
}, I = [], E = /* @__PURE__ */ S(
|
|
85
|
+
w,
|
|
86
|
+
k,
|
|
87
|
+
I,
|
|
88
|
+
!1,
|
|
89
|
+
null,
|
|
90
|
+
"ca3da0f2",
|
|
91
|
+
null,
|
|
92
|
+
null
|
|
93
|
+
);
|
|
94
|
+
const z = E.exports;
|
|
8
95
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
96
|
+
X as BentoAvatar,
|
|
97
|
+
st as BentoListbox,
|
|
98
|
+
q as Calendar,
|
|
99
|
+
H as CalendarEvent,
|
|
100
|
+
J as CalendarFirstDayOfWeek,
|
|
101
|
+
Y as ControlsGroup,
|
|
102
|
+
N as Copy,
|
|
103
|
+
tt as ErrorMessage,
|
|
104
|
+
z as FixedScroller,
|
|
105
|
+
ot as GridLayout,
|
|
106
|
+
rt as GridLayoutContainerType,
|
|
107
|
+
$ as ListboxOptionTag
|
|
20
108
|
};
|
|
21
109
|
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
1
|
+
{"version":3,"file":"internal.js","sources":["../src/components/internal/fixed-scroller/composables/useFixedScroller.ts","../src/components/internal/fixed-scroller/fixed-scroller.vue"],"sourcesContent":["import { computed, ref } from 'vue';\nimport type { Ref } from 'vue';\n\ninterface useFixedScrollerProps {\n contentRef?: Ref<HTMLElement | undefined>;\n containerRef?: Ref<HTMLElement | undefined>;\n leftButtonRef?: Ref<HTMLElement | undefined>;\n rightButtonRef?: Ref<HTMLElement | undefined>;\n}\n\n/**\n * Function to calculate the offset of each view and change the \"view\" via offsets\n * through the functions `scrollLeft` and `scrollRight` whilst providing a way to\n * show and hide the buttons based on the current \"view\" via\n * `shouldShowLeftButton` and `shouldShowRightButton`.\n *\n * Each view is pre-calculated (offsetArray) and updated if the content changes as a computed ref:\n * First view: Always 0 (x axis beginning).\n * Last view: total content space - visible width\n * Intermediate views: Previous offset (to the left) plus the visible space taking\n * away the space the buttons take so that the whole view can be rendered\n *\n *\n * @param {useFixedScrollerProps} props - All the necessary references to calculate the scroll\n * @param {Ref<HTMLElement | undefined>} props.containerRef - Reference to the container, this defines the visible space width\n * @param {Ref<HTMLElement | undefined>} props.contentRef - Reference to the content itself, this defines the total content width\n * @param {Ref<HTMLElement | undefined>} props.leftButtonRef - Reference to the left button, used to calculate total space in which the content will be rendered\n * @param {Ref<HTMLElement | undefined>} props.rightButtonRef - Reference to the right button, used to calculate total space in which the content will be rendered\n * @returns {Object} response - Values used in the view to show the buttons and to change the view right or left\n * @returns {Ref<number>} response.offset - Offset value by which the view will move on the x axis. To be used in `styles`.\n * @returns {ComputedRef<boolean>} response.shouldShowLeftButton - Indicates if the button on the left should be shown\n * @returns {ComputedRef<boolean>} response.shouldShowRightButton - Indicates if the button on the right should be shown\n * @returns {() => {}} response.scrollLeft - Used to shift the view to the left\n * @returns {() => {}} response.scrollRight - Used to shift the view to the right\n */\nexport const useFixedScroller = ({\n contentRef,\n containerRef,\n leftButtonRef,\n rightButtonRef,\n}: useFixedScrollerProps) => {\n const offset = ref(0);\n const currentView = ref(0);\n\n // Calculated using 'scrollWidth' to get the full width of the content\n const totalContentWidth = computed(() => contentRef.value?.scrollWidth);\n // Calculated using 'clientWidth' to get the rendered componen width\n const visibleSpaceWidth = computed(() => containerRef.value?.clientWidth);\n // Sum of the space used by the Left and Right buttons\n // Used to calculate how much space the \"actual\" visible space is\n const buttonsWidth = computed(() => {\n const leftButtonWidth = leftButtonRef.value?.scrollWidth ?? 0;\n const rightButtonWidth = rightButtonRef.value?.scrollWidth ?? 0;\n\n return leftButtonWidth + rightButtonWidth;\n });\n // Total number of pages/views available.\n // Calculated as \"ceil\" because if the space doesn't fit \"one view\" (irrational number) the content flows to the next view (integer).\n const totalViews = computed(() => Math.ceil(totalContentWidth.value / visibleSpaceWidth.value) ?? 0);\n\n // Calculation of offsets per view (index).\n // This allows to easily swap the offset without on-the-fly calculations\n const offsetArray = computed(() => {\n const calculatedOffsetList = new Array(totalViews.value).fill(0);\n\n calculatedOffsetList.forEach((_, index) => {\n // First offset will be 0\n if (index === 0) {\n return;\n }\n\n // Calculate last\n if (index === totalViews.value - 1) {\n calculatedOffsetList[calculatedOffsetList.length - 1] = -(\n totalContentWidth.value - visibleSpaceWidth.value\n );\n return;\n }\n\n // Calculate each offset - Move 1 view\n const previousOffset = calculatedOffsetList[index - 1];\n calculatedOffsetList[index] = -(visibleSpaceWidth.value + Math.abs(previousOffset) - buttonsWidth.value);\n });\n\n return calculatedOffsetList;\n });\n\n // Hide left button when it's the first view\n const shouldShowLeftButton = computed(() => currentView.value !== 0);\n // Hide right button if it's the last view\n const shouldShowRightButton = computed(\n () => offset.value === 0 || offset.value >= -(totalContentWidth.value - visibleSpaceWidth.value - 1)\n );\n\n /**\n * Shifts the current offset by one view to the left.\n */\n const scrollLeft = () => {\n // Do nothing if it is already in page 0\n if (currentView.value === 0) {\n return;\n }\n\n currentView.value -= 1;\n offset.value = offsetArray.value[currentView.value];\n };\n\n /**\n * Shifts the current offset by one view to the right.\n */\n const scrollRight = () => {\n // Do nothing if it is already in last page\n if (currentView.value === totalViews.value - 1) {\n return;\n }\n\n currentView.value += 1;\n offset.value = offsetArray.value[currentView.value];\n };\n\n return {\n offset,\n shouldShowLeftButton,\n shouldShowRightButton,\n\n // Methods\n scrollLeft,\n scrollRight,\n };\n};\n","<template>\n <div ref=\"fixedScrollerRef\" class=\"b-fixed-scroller\">\n <div class=\"b-fixed-scroller__container\">\n <div ref=\"contentRef\" class=\"b-fixed-scroller__content\" :style=\"{ transform: `translateX(${offset}px)` }\">\n <slot></slot>\n </div>\n </div>\n\n <div v-if=\"shouldShowLeftButton\" ref=\"leftButtonRef\" class=\"b-fixed-scroller__left\">\n <bento-button variant=\"secondary\" :aria-label=\"t('scrollLeft')\" @click=\"scrollLeft\">\n <template #iconLeft>\n <chevron-left-icon svg-title=\"checked\" aria-hidden=\"true\" />\n </template>\n </bento-button>\n </div>\n <div v-if=\"shouldShowRightButton\" ref=\"rightButtonRef\" class=\"b-fixed-scroller__right\">\n <bento-button variant=\"secondary\" :aria-label=\"t('scrollRight')\" @click=\"scrollRight\">\n <template #iconLeft>\n <chevron-right-icon svg-title=\"checked\" aria-hidden=\"true\" />\n </template>\n </bento-button>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\n import { ref } from 'vue';\n import { BentoButton } from '@/components/button';\n import { useFixedScroller } from './composables';\n import { useI18n } from '@/utils/ts/i18n';\n import ChevronLeftIcon from '@adyen/ui-assets-icons-16/vue/chevron-left';\n import ChevronRightIcon from '@adyen/ui-assets-icons-16/vue/chevron-right';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n const contentRef = ref(null);\n const fixedScrollerRef = ref(null);\n const leftButtonRef = ref(null);\n const rightButtonRef = ref(null);\n\n const { offset, shouldShowLeftButton, shouldShowRightButton, scrollLeft, scrollRight } = useFixedScroller({\n contentRef,\n containerRef: fixedScrollerRef,\n leftButtonRef,\n rightButtonRef,\n });\n</script>\n\n<script lang=\"ts\">\n /**\n * Allows to horizontally scroll content by one view at a time.\n *\n * @example\n * import { FixedScroller } from '@/internal';\n *\n * export default {\n * components: { FixedScroller },\n * template: `\n * <fixed-scroller>\n * <div style=\"display: flex; gap: 8px;\">\n * {{ Content here }}\n * </div>\n * </fixed-scroller>\n * `\n * }\n */\n export default {\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./fixed-scroller.scss\" />\n"],"names":["useFixedScroller","contentRef","containerRef","leftButtonRef","rightButtonRef","offset","ref","currentView","totalContentWidth","computed","_a","visibleSpaceWidth","buttonsWidth","leftButtonWidth","rightButtonWidth","_b","totalViews","offsetArray","calculatedOffsetList","_","index","previousOffset","shouldShowLeftButton","shouldShowRightButton","__default__","messages","t","useI18n","fixedScrollerRef","scrollLeft","scrollRight"],"mappings":";;;;;;;;;;;;;AAmCO,MAAAA,IAAA,CAAA;AAAA,EAA0B,YAAAC;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ACA,uBAAAC;AAAA;AAAA,IACA,YA1BJ,MAAA;AAEI,MAAAhB,EAAA,UAAA,MAIAA,EAAA,SAAA,GACAF,EAAA,QAAAY,EAAA,MAAAV,EAAA,KAAA;AAAA,IAAkD;AAAA,IAsBlD,aAhBJ,MAAA;AAEI,MAAAA,EAAA,UAAAS,EAAA,QAAA,MAIAT,EAAA,SAAA,GACAF,EAAA,QAAAY,EAAA,MAAAV,EAAA,KAAA;AAAA,IAAkD;AAAA,EAUlD;AAER;;;;;GC3DIiB,IAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,EAAA;AAEf;;;;AAnCA,UAAA,EAAA,GAAAC,EAAA,IAAAC,EAAA,GAEA1B,IAAAK,EAAA,IAAA,GACAsB,IAAAtB,EAAA,IAAA,GACAH,IAAAG,EAAA,IAAA,GACAF,IAAAE,EAAA,IAAA,GAEA,EAAA,QAAAD,GAAA,sBAAAiB,GAAA,uBAAAC,GAAA,YAAAM,GAAA,aAAAC,EAAA,IAAA9B,EAAA;AAAA,MAA0G,YAAAC;AAAA,MACtG,cAAA2B;AAAA,MACc,eAAAzB;AAAA,MACd,gBAAAC;AAAA,IACA,CAAA;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/link.js
CHANGED
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { RouterLink as
|
|
3
|
-
import { B as
|
|
4
|
-
import { n as
|
|
5
|
-
import "./assets/
|
|
6
|
-
var
|
|
7
|
-
const
|
|
8
|
-
name: "bento-link"
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { defineComponent as c, computed as p, useAttrs as _ } from "vue";
|
|
2
|
+
import { RouterLink as u } from "vue-router";
|
|
3
|
+
import { B as f } from "./chunks/index.74da0d41.js";
|
|
4
|
+
import { n as d } from "./chunks/_plugin-vue2_normalizer.71e2aa87.js";
|
|
5
|
+
import "./assets/index18.css";
|
|
6
|
+
var a = /* @__PURE__ */ ((s) => (s.DEFAULT = "default", s.QUIET = "quiet", s))(a || {});
|
|
7
|
+
const k = {
|
|
8
|
+
name: "bento-link",
|
|
9
|
+
inheritAttrs: !1
|
|
10
|
+
}, y = /* @__PURE__ */ c({
|
|
11
|
+
...k,
|
|
11
12
|
props: {
|
|
12
13
|
args: null,
|
|
13
14
|
external: { type: Boolean },
|
|
14
|
-
variant: { default:
|
|
15
|
+
variant: { default: a.DEFAULT },
|
|
15
16
|
disableTypography: { type: Boolean },
|
|
16
17
|
target: { default: null }
|
|
17
18
|
},
|
|
18
19
|
emits: ["click"],
|
|
19
20
|
setup(s, { emit: t }) {
|
|
20
|
-
const
|
|
21
|
-
[`b-link--${
|
|
22
|
-
})),
|
|
23
|
-
return { __sfc: !0, props:
|
|
24
|
-
t("click",
|
|
25
|
-
}, RouterLink:
|
|
21
|
+
const n = s, e = p(() => ({
|
|
22
|
+
[`b-link--${a.QUIET}`]: n.variant === a.QUIET
|
|
23
|
+
})), { to: o, ...r } = _();
|
|
24
|
+
return { __sfc: !0, props: n, conditionalClasses: e, to: o, attributes: r, linkProps: r, emit: t, onClick: (i, l) => {
|
|
25
|
+
t("click", i), l && l();
|
|
26
|
+
}, RouterLink: u, BentoTypography: f };
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
|
-
var
|
|
29
|
-
var t = this,
|
|
30
|
-
return t.external ?
|
|
31
|
-
return
|
|
32
|
-
} } }, "router-link",
|
|
33
|
-
}, m = [], g = /* @__PURE__ */
|
|
34
|
-
k,
|
|
29
|
+
var b = function() {
|
|
30
|
+
var t = this, n = t._self._c, e = t._self._setupProxy;
|
|
31
|
+
return t.external ? n("a", t._b({ staticClass: "b-link", class: e.conditionalClasses, attrs: { href: e.to.toString(), title: e.linkProps.title, target: t.target || "_blank" }, on: { click: e.onClick } }, "a", e.attributes, !1), [t.disableTypography ? t._t("default") : n(e.BentoTypography, { attrs: { el: "span", variant: "body" } }, [t._t("default")], 2)], 2) : n(e.RouterLink, t._b({ staticClass: "b-link", class: e.conditionalClasses, attrs: { target: t.target, to: e.to, custom: "" }, nativeOn: { click: function(o) {
|
|
32
|
+
return e.onClick.apply(null, arguments);
|
|
33
|
+
} } }, "router-link", e.linkProps, !1), [t.disableTypography ? t._t("default") : n(e.BentoTypography, { attrs: { el: "span", variant: "body" } }, [t._t("default")], 2)], 2);
|
|
34
|
+
}, m = [], g = /* @__PURE__ */ d(
|
|
35
35
|
y,
|
|
36
|
+
b,
|
|
36
37
|
m,
|
|
37
38
|
!1,
|
|
38
39
|
null,
|
|
39
|
-
"
|
|
40
|
+
"5bfdba21",
|
|
40
41
|
null,
|
|
41
42
|
null
|
|
42
43
|
);
|
|
43
|
-
const
|
|
44
|
+
const E = g.exports;
|
|
44
45
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
E as BentoLink,
|
|
47
|
+
a as BentoLinkVariant
|
|
47
48
|
};
|
|
48
49
|
//# sourceMappingURL=link.js.map
|
package/dist/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../core/src/components/link/link.types.ts","../src/components/link/link.vue"],"sourcesContent":["/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoLinkVariant {\n DEFAULT = 'default',\n QUIET = 'quiet',\n}\n","<template>\n <a\n v-if=\"external\"\n class=\"b-link\"\n :class=\"conditionalClasses\"\n :href=\"
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../core/src/components/link/link.types.ts","../src/components/link/link.vue"],"sourcesContent":["/**\n * @deprecated for usage with properties since version 2.0. Use the string literal instead.\n */\nexport enum BentoLinkVariant {\n DEFAULT = 'default',\n QUIET = 'quiet',\n}\n","<template>\n <a\n v-if=\"external\"\n class=\"b-link\"\n :class=\"conditionalClasses\"\n v-bind=\"attributes\"\n :href=\"to.toString()\"\n :title=\"linkProps.title\"\n :target=\"target || '_blank'\"\n @click=\"onClick\"\n >\n <bento-typography v-if=\"!disableTypography\" el=\"span\" variant=\"body\">\n <slot />\n </bento-typography>\n <slot v-else />\n </a>\n <router-link\n v-else\n v-bind=\"linkProps\"\n class=\"b-link\"\n :class=\"conditionalClasses\"\n :target=\"target\"\n :to=\"to\"\n custom\n @click.native=\"onClick\"\n >\n <bento-typography v-if=\"!disableTypography\" el=\"span\" variant=\"body\">\n <slot />\n </bento-typography>\n <slot v-else />\n </router-link>\n</template>\n\n<script lang=\"ts\">\n import { RouterLink } from 'vue-router';\n import { computed, useAttrs } from 'vue';\n import { BentoLinkVariant } from '@/core/components/link/link.types';\n import { BentoTypography } from '@/components/typography';\n import type { RouterLinkProps, RouterLinkSlotArgument } from 'vue-router/types/router';\n import type { AnchorHTMLAttributes } from 'vue/types/jsx';\n\n /**\n * Extends the `router-link` from the `vue-router` NPM package.\n *\n * @example\n * import { BentoLink } from '@adyen/bento-vue2';\n *\n * export default {\n * components: { BentoLink },\n * template: `\n * <bento-link to=\"/\">\n * link\n * </bento-link>\n * `\n * }\n */\n export default {\n name: 'bento-link',\n inheritAttrs: false,\n };\n</script>\n\n<script setup lang=\"ts\">\n // TODO: replace all this code when migrated to Vue 3 is complete as this is the only\n // current way to extend the `router-link` component in Vue 2 and Vue Router 3\n export interface Props extends RouterLinkProps, AnchorHTMLAttributes {\n // eslint-disable-next-line vue/require-default-prop\n args?: { props: RouterLinkProps };\n\n /**\n * Set the rendered link to a regular external anchor link.\n */\n external?: boolean;\n\n /**\n * Link variant type affecting visual style.\n * @values default, quiet\n */\n variant?: BentoLinkVariant | `${BentoLinkVariant}`;\n\n /**\n * Disable the default typography for the component. Only use this when the component is inside another typography component.\n */\n disableTypography?: boolean;\n\n /**\n * Sets the target of the rendered link.\n */\n target?: string;\n }\n\n const props = withDefaults(defineProps<Props>(), {\n variant: BentoLinkVariant.DEFAULT,\n target: null,\n });\n\n const conditionalClasses = computed(() => ({\n [`b-link--${BentoLinkVariant.QUIET}`]: props.variant === BentoLinkVariant.QUIET,\n }));\n\n // TODO: replace this when Vue allows users to extend props properly, read above for more info\n const { to, ...attributes } = useAttrs() as unknown as Props;\n const linkProps = attributes;\n\n const emit = defineEmits<{\n (e: 'click', clickEvent: MouseEvent): void;\n }>();\n\n const onClick = (e: MouseEvent, navigateCallback?: RouterLinkSlotArgument['navigate']) => {\n emit('click', e);\n if (navigateCallback) {\n navigateCallback();\n }\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"@/core/components/link/link.scss\" />\n"],"names":["BentoLinkVariant","BentoLinkVariant2","__default__","conditionalClasses","computed","props","to","attributes","useAttrs","e","navigateCallback","emit"],"mappings":";;;;;AAGY,IAAAA,IAAA,kBAAAC,OACRA,EAAA,UAAA,WACAA,EAAA,QAAA,SAFQA,IAAAD,KAAA,CAAA,CAAA;ACqDR,MAAAE,IAAA;AAAA,EAAe,MAAA;AAAA,EACL,cAAA;AAEV;;;;;;;;;;;iBAqCAC,IAAAC,EAAA,OAAA;AAAA,MAA2C,CAAA,WAAAJ,EAAA,OAAA,GAAAK,EAAA,YAAAL,EAAA;AAAA,IACmC,EAAA,GAI9E,EAAA,IAAAM,GAAA,GAAAC,EAAA,IAAAC,EAAA;0FACAD,qBAMA,CAAAE,GAAAC,MAAA;AACI,MAAAC,EAAA,SAAAF,CAAA,GACAC,KACIA,EAAA;AAAA,IACJ;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as t, onMounted as s, onUnmounted as l, computed as i } from "vue";
|
|
2
2
|
import { n as r } from "./chunks/_plugin-vue2_normalizer.71e2aa87.js";
|
|
3
|
-
import "./assets/
|
|
3
|
+
import "./assets/index19.css";
|
|
4
4
|
var a = /* @__PURE__ */ ((n) => (n.START = "loading-start", n.END = "loading-end", n))(a || {});
|
|
5
5
|
const d = t({
|
|
6
6
|
name: "bento-loading-indicator",
|