bitboss-ui 0.2.8 → 0.2.10
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/index101.js +3 -3
- package/dist/index103.js +2 -2
- package/dist/index109.js +1 -1
- package/dist/index11.js +2 -2
- package/dist/index111.js +5 -5
- package/dist/index113.js +1 -1
- package/dist/index116.js +1 -1
- package/dist/index117.js +1 -1
- package/dist/index118.js +1 -1
- package/dist/index119.js +1 -1
- package/dist/index121.js +1 -1
- package/dist/index125.js +1 -1
- package/dist/index126.js +1 -1
- package/dist/index128.js +2 -2
- package/dist/index15.js +8 -8
- package/dist/index17.js +9 -9
- package/dist/index19.js +3 -3
- package/dist/index195.js +351 -2
- package/dist/index195.js.map +1 -1
- package/dist/index196.js +134 -2
- package/dist/index196.js.map +1 -1
- package/dist/index197.js +5 -4
- package/dist/index197.js.map +1 -1
- package/dist/index198.js +19 -3
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +2 -35
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +2 -6
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +171 -336
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +23 -134
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +369 -5
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +3 -19
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +3 -2
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +16 -2
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +14 -184
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +20 -23
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +27 -367
- package/dist/index209.js.map +1 -1
- package/dist/index21.js +2 -2
- package/dist/index210.js +8 -3
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +3 -3
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +32 -232
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +6 -2
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +2 -10
- package/dist/index214.js.map +1 -1
- package/dist/index215.js +4 -2
- package/dist/index215.js.map +1 -1
- package/dist/index216.js +235 -16
- package/dist/index216.js.map +1 -1
- package/dist/index217.js +10 -16
- package/dist/index217.js.map +1 -1
- package/dist/index218.js +2 -20
- package/dist/index218.js.map +1 -1
- package/dist/index219.js +2 -29
- package/dist/index219.js.map +1 -1
- package/dist/index220.js +2 -8
- package/dist/index220.js.map +1 -1
- package/dist/index221.js +27 -8
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +12 -115
- package/dist/index222.js.map +1 -1
- package/dist/index223.js +8 -27
- package/dist/index223.js.map +1 -1
- package/dist/index224.js +115 -12
- package/dist/index224.js.map +1 -1
- package/dist/index225.js +1 -1
- package/dist/index226.js +6 -4
- package/dist/index226.js.map +1 -1
- package/dist/index227.js +2 -435
- package/dist/index227.js.map +1 -1
- package/dist/index228.js +294 -88
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +2 -6
- package/dist/index229.js.map +1 -1
- package/dist/index23.js +1 -1
- package/dist/index230.js +2 -2
- package/dist/index231.js +116 -294
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +106 -2
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +224 -2
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +246 -105
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +2 -106
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +2 -200
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +2 -2
- package/dist/index237.js.map +1 -1
- package/dist/index238.js +2 -2
- package/dist/index238.js.map +1 -1
- package/dist/index239.js +2 -69
- package/dist/index239.js.map +1 -1
- package/dist/index240.js +4 -162
- package/dist/index240.js.map +1 -1
- package/dist/index241.js +435 -2
- package/dist/index241.js.map +1 -1
- package/dist/index242.js +83 -218
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +161 -257
- package/dist/index243.js.map +1 -1
- package/dist/index244.js +2 -2
- package/dist/index245.js +69 -2
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +2 -2
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +200 -2
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +1 -1
- package/dist/index25.js +2 -2
- package/dist/index252.js +3 -2
- package/dist/index252.js.map +1 -1
- package/dist/index253.js +2 -3
- package/dist/index253.js.map +1 -1
- package/dist/index29.js +3 -3
- package/dist/index31.js +6 -6
- package/dist/index33.js +2 -2
- package/dist/index35.js +2 -2
- package/dist/index47.js +1 -1
- package/dist/index49.js +1 -1
- package/dist/index65.js +5 -5
- package/dist/index69.js +2 -2
- package/dist/index72.js +1 -1
- package/dist/index75.js +1 -1
- package/dist/index79.js +4 -4
- package/dist/index8.js +64 -65
- package/dist/index8.js.map +1 -1
- package/dist/index81.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index239.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index239.js","sources":[
|
|
1
|
+
{"version":3,"file":"index239.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/index240.js
CHANGED
|
@@ -1,165 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { isNil as R } from "./index120.js";
|
|
5
|
-
import { isNotNil as w } from "./index124.js";
|
|
6
|
-
import { wait as L } from "./index122.js";
|
|
7
|
-
import U from "./index115.js";
|
|
8
|
-
import "./index157.js";
|
|
9
|
-
const j = { class: "bb-base-tag__input-container" }, G = ["autocomplete", "autofocus", "disabled", "id", "placeholder", "readonly"], te = /* @__PURE__ */ K({
|
|
10
|
-
__name: "BaseTag",
|
|
11
|
-
props: {
|
|
12
|
-
autocomplete: {},
|
|
13
|
-
autofocus: {},
|
|
14
|
-
comma: { type: Boolean },
|
|
15
|
-
disabled: { type: Boolean },
|
|
16
|
-
divider: { default: "Enter" },
|
|
17
|
-
hasErrors: { type: Boolean },
|
|
18
|
-
id: {},
|
|
19
|
-
modelValue: {},
|
|
20
|
-
multiple: { type: Boolean, default: !0 },
|
|
21
|
-
name: {},
|
|
22
|
-
placeholder: {},
|
|
23
|
-
readonly: {}
|
|
24
|
-
},
|
|
25
|
-
emits: ["blur", "change", "click", "duplicate", "focus", "inactive", "input", "keydown", "keyup", "update:modelValue"],
|
|
26
|
-
setup(N, { emit: I }) {
|
|
27
|
-
const a = N, u = I;
|
|
28
|
-
if (a.multiple && !Array.isArray(a.modelValue))
|
|
29
|
-
throw new Error('Multiple is set to "true" but modelValue is not an array.');
|
|
30
|
-
const i = s(null), $ = s(null), c = s(null), t = s(""), D = y(() => a.placeholder), o = y(
|
|
31
|
-
() => [].concat(a.modelValue).filter(w)
|
|
32
|
-
), h = y(() => {
|
|
33
|
-
let e = {};
|
|
34
|
-
return o.value.forEach((n, r) => {
|
|
35
|
-
e[JSON.stringify(n)] = r;
|
|
36
|
-
}), {
|
|
37
|
-
get: (n) => e[JSON.stringify(n)]
|
|
38
|
-
};
|
|
39
|
-
}), f = s(!1), l = s(null), A = (e) => {
|
|
40
|
-
if (u("keyup", e), a.readonly || a.disabled) {
|
|
41
|
-
e.preventDefault();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
if (e.key === a.divider) {
|
|
45
|
-
if (t.value[t.value.length - 1] === e.key && (t.value = t.value.slice(0, t.value.length - 1)), !t.value)
|
|
46
|
-
return;
|
|
47
|
-
l.value = null;
|
|
48
|
-
const n = h.value.get(t.value);
|
|
49
|
-
R(n) ? F(t.value) : u("duplicate", t.value), t.value = "";
|
|
50
|
-
} else if (e.key === "ArrowLeft")
|
|
51
|
-
l.value === null ? l.value = o.value.length - 1 : l.value === 0 ? l.value = null : l.value--;
|
|
52
|
-
else if (e.key === "ArrowRight")
|
|
53
|
-
l.value === null ? l.value = 1 : l.value === o.value.length - 1 ? l.value = null : l.value++;
|
|
54
|
-
else if (e.key === "Backspace") {
|
|
55
|
-
if (t.value)
|
|
56
|
-
return;
|
|
57
|
-
w(l.value) ? (b(l.value), l.value = P(
|
|
58
|
-
l.value,
|
|
59
|
-
0,
|
|
60
|
-
o.value.length - 2
|
|
61
|
-
), o.value.length === 1 && (l.value = null)) : l.value = o.value.length - 1;
|
|
62
|
-
} else
|
|
63
|
-
(e.key === "Tab" || e.key === "Escape") && (l.value = null);
|
|
64
|
-
}, F = (e) => {
|
|
65
|
-
a.multiple ? u("update:modelValue", a.modelValue.concat(e)) : u("update:modelValue", e);
|
|
66
|
-
}, b = (e) => {
|
|
67
|
-
if (typeof e == "number")
|
|
68
|
-
a.multiple ? u("update:modelValue", q(a.modelValue, 1, e)) : u("update:modelValue", null);
|
|
69
|
-
else {
|
|
70
|
-
const n = h.value.get(t.value);
|
|
71
|
-
b(n);
|
|
72
|
-
}
|
|
73
|
-
}, M = (e) => {
|
|
74
|
-
u("focus", e), f.value = !0, document.addEventListener("click", _), document.addEventListener("focusin", V), c.value instanceof HTMLInputElement && c.value.select();
|
|
75
|
-
}, O = (e) => {
|
|
76
|
-
u("click", e), !(a.disabled || a.readonly) && c.value instanceof HTMLElement && c.value.focus();
|
|
77
|
-
}, _ = (e) => {
|
|
78
|
-
if (e.target instanceof Node && i.value && !i.value.contains(e.target)) {
|
|
79
|
-
u("inactive"), document.removeEventListener("click", _), f.value = !1, a.multiple && L(500).then(() => {
|
|
80
|
-
t.value = "";
|
|
81
|
-
});
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
}, V = (e) => {
|
|
85
|
-
if (e.target instanceof Node && i.value && !i.value.contains(e.target)) {
|
|
86
|
-
u("inactive"), document.removeEventListener("focusin", V), f.value = !1, a.multiple && L(500).then(() => {
|
|
87
|
-
t.value = "";
|
|
88
|
-
});
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
}, T = {
|
|
92
|
-
onBlur: (e) => u("blur", e),
|
|
93
|
-
onChange: (e) => u("change", e),
|
|
94
|
-
onKeydown: (e) => {
|
|
95
|
-
e.key === "Enter" && a.divider === "Enter" && e.preventDefault(), u("keydown", e);
|
|
96
|
-
},
|
|
97
|
-
onInput: (e) => u("input", e)
|
|
98
|
-
};
|
|
99
|
-
return (e, n) => (p(), m("span", {
|
|
100
|
-
class: g({
|
|
101
|
-
"bb-base-tag": !0,
|
|
102
|
-
"bb-base-tag--active": f.value,
|
|
103
|
-
"bb-base-tag--disabled": e.disabled,
|
|
104
|
-
"bb-base-tag--errors": e.hasErrors,
|
|
105
|
-
"bb-base-tag--readonly": e.readonly
|
|
106
|
-
}),
|
|
107
|
-
onClick: O,
|
|
108
|
-
ref_key: "outerContainer",
|
|
109
|
-
ref: i
|
|
110
|
-
}, [
|
|
111
|
-
v(e.$slots, "prepend-outer"),
|
|
112
|
-
k("span", {
|
|
113
|
-
class: "bb-base-tag__inner-container",
|
|
114
|
-
ref_key: "innerContainer",
|
|
115
|
-
ref: $
|
|
116
|
-
}, [
|
|
117
|
-
v(e.$slots, "prepend"),
|
|
118
|
-
k("span", j, [
|
|
119
|
-
e.comma ? (p(!0), m(E, { key: 0 }, C(o.value, (r, d) => (p(), m("span", {
|
|
120
|
-
class: g({
|
|
121
|
-
"bb-base-tag__selected": !0,
|
|
122
|
-
"bb-base-tag__selected--comma": !0,
|
|
123
|
-
"bb-base-tag__selected--focused": d === l.value
|
|
124
|
-
}),
|
|
125
|
-
key: r
|
|
126
|
-
}, B(r) + B(d < o.value.length - 1 ? "," : ""), 3))), 128)) : (p(!0), m(E, { key: 1 }, C(o.value, (r, d) => (p(), S(U, {
|
|
127
|
-
class: g({
|
|
128
|
-
"bb-base-tag__selected": !0,
|
|
129
|
-
"bb-base-tag__selected--chip": !0,
|
|
130
|
-
"bb-base-tag__selected--focused": d === l.value
|
|
131
|
-
}),
|
|
132
|
-
clearable: !0,
|
|
133
|
-
key: r,
|
|
134
|
-
text: r,
|
|
135
|
-
"onClick:clear": (Q) => b(d)
|
|
136
|
-
}, null, 8, ["class", "text", "onClick:clear"]))), 128)),
|
|
137
|
-
z(k("input", H({
|
|
138
|
-
autocomplete: e.autocomplete,
|
|
139
|
-
autofocus: e.autofocus,
|
|
140
|
-
class: "bb-base-tag__text-input",
|
|
141
|
-
disabled: e.disabled,
|
|
142
|
-
id: e.id,
|
|
143
|
-
placeholder: D.value,
|
|
144
|
-
readonly: e.readonly,
|
|
145
|
-
type: "text",
|
|
146
|
-
onKeyup: A,
|
|
147
|
-
onFocus: M
|
|
148
|
-
}, T, {
|
|
149
|
-
"onUpdate:modelValue": n[0] || (n[0] = (r) => t.value = r),
|
|
150
|
-
ref_key: "input",
|
|
151
|
-
ref: c
|
|
152
|
-
}), null, 16, G), [
|
|
153
|
-
[J, t.value]
|
|
154
|
-
])
|
|
155
|
-
]),
|
|
156
|
-
v(e.$slots, "append")
|
|
157
|
-
], 512),
|
|
158
|
-
v(e.$slots, "append-outer")
|
|
159
|
-
], 2));
|
|
160
|
-
}
|
|
161
|
-
});
|
|
1
|
+
const e = function(t) {
|
|
2
|
+
return (...n) => n.length >= t.length ? t(...n) : e(t.bind(void 0, ...n));
|
|
3
|
+
};
|
|
162
4
|
export {
|
|
163
|
-
|
|
5
|
+
e as curry
|
|
164
6
|
};
|
|
165
7
|
//# sourceMappingURL=index240.js.map
|
package/dist/index240.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index240.js","sources":["../src/components/BaseTag/BaseTag.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { renderSlot as _renderSlot, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, createCommentVNode as _createCommentVNode, createBlock as _createBlock, vModelDynamic as _vModelDynamic, mergeProps as _mergeProps, createElementVNode as _createElementVNode, withDirectives as _withDirectives } from \"vue\"\n\nconst _hoisted_1 = { class: \"bb-base-tag__input-container\" }\nconst _hoisted_2 = [\"autocomplete\", \"autofocus\", \"disabled\", \"id\", \"placeholder\", \"readonly\"]\n\nimport { clamp } from \"@/utilities/functions/clamp\";\nimport { computed, ref } from \"vue\";\nimport { drop } from \"@/utilities/functions/drop\";\nimport { isNil } from \"@/utilities/functions/isNil\";\nimport { isNotNil } from \"@/utilities/functions/isNotNil\";\nimport { wait } from \"@/utilities/functions/wait\";\nimport BbChip from \"../BbChip/BbChip.vue\";\nimport type { InputHTMLAttributes, HTMLAttributes } from \"vue\";\n\nexport type BaseTagProps = {\n /**\n * Guides to the browser as to the type of information expected in the field.\n */\n autocomplete?: InputHTMLAttributes[\"autocomplete\"];\n\n /**\n * Sets autofocus on page load.\n */\n autofocus?: InputHTMLAttributes[\"autofocus\"];\n\n /**\n * Sets the display model for selected values to a list\n * of comma separated string. In this mode the user\n * cannot deselect an option by pressing the close button.\n */\n comma?: boolean;\n\n /**\n * Disables the component\n */\n disabled?: boolean;\n\n /**\n * The divider key used to separate values from one another. By default it is \"Enter\"\n */\n divider?: KeyboardEvent[\"key\"];\n\n /**\n * Define if the component should be in an error state.\n * It usually attaches a CSS class for styling purposes.\n */\n hasErrors?: boolean;\n\n /**\n * The identifier of the component.\n */\n id?: HTMLAttributes[\"id\"];\n\n /**\n * Used by v-model. Can be any serializable type.\n */\n modelValue: any;\n\n /**\n * Allows the selection of multiple items.\n */\n multiple?: boolean;\n\n /**\n * Defines the name of the input.\n */\n name?: InputHTMLAttributes[\"name\"];\n\n /**\n * String displayed when there's no data.\n */\n placeholder?: InputHTMLAttributes[\"placeholder\"];\n\n /**\n * Sets the input in a readonly state.\n */\n readonly?: InputHTMLAttributes[\"readonly\"];\n};\n\nexport type BaseTagEvents = {\n (e: \"blur\", event: FocusEvent): void;\n\n (e: \"change\", event: Event): void;\n\n (e: \"click\", event: MouseEvent): void;\n\n (e: \"duplicate\", string: string): void;\n\n (e: \"focus\", event: FocusEvent): void;\n\n (e: \"inactive\"): void;\n\n (e: \"input\", event: Event): void;\n\n (e: \"keydown\", event: KeyboardEvent): void;\n\n (e: \"keyup\", event: KeyboardEvent): void;\n\n (e: \"update:modelValue\", value: any): void;\n};\n\nexport type BaseTagSlots = {\n append?: (props: {}) => any;\n\n \"append-outer\"?: (props: {}) => any;\n\n prepend?: (props: {}) => any;\n\n \"prepend-outer\"?: (props: {}) => any;\n};\n\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BaseTag',\n props: {\n autocomplete: {},\n autofocus: {},\n comma: { type: Boolean },\n disabled: { type: Boolean },\n divider: { default: \"Enter\" },\n hasErrors: { type: Boolean },\n id: {},\n modelValue: {},\n multiple: { type: Boolean, default: true },\n name: {},\n placeholder: {},\n readonly: {}\n },\n emits: [\"blur\", \"change\", \"click\", \"duplicate\", \"focus\", \"inactive\", \"input\", \"keydown\", \"keyup\", \"update:modelValue\"],\n setup(__props: any, { emit: __emit }) {\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nif (props.multiple && !Array.isArray(props.modelValue)) {\n throw new Error('Multiple is set to \"true\" but modelValue is not an array.');\n}\n\nconst outerContainer = ref<HTMLElement | null>(null);\nconst innerContainer = ref<HTMLElement | null>(null);\nconst input = ref<HTMLElement | null>(null);\nconst query = ref<string>(\"\");\nconst computedPlaceholder = computed(() => {\n return props.placeholder;\n});\n\nconst modelValueNormalized = computed(() =>\n [].concat(props.modelValue).filter(isNotNil)\n);\n\n/**\n * Indexes modelValue to a map so when can easily know which values are selected\n */\nconst modelValueIndexed = computed(() => {\n let map: { [key: string]: number } = {};\n modelValueNormalized.value.forEach((value: any, index: number) => {\n map[JSON.stringify(value)] = index;\n });\n return {\n get: (value: any) => map[JSON.stringify(value)],\n };\n});\n\n/**\n * Applies a class when the user is inside this whole component.\n * We cannot use focus within as it doesn't work for elements that are teleported.\n * Also we cannot use the <input/> if we phisically move focus to the options so\n * we track it manually.\n */\nconst active = ref(false);\n\nconst focusedIndex = ref<null | number>(null);\n\nconst onInputKeyup = (event: KeyboardEvent) => {\n emit(\"keyup\", event);\n if (props.readonly || props.disabled) {\n event.preventDefault();\n return;\n }\n if (event.key === props.divider) {\n if (query.value[query.value.length - 1] === event.key) {\n query.value = query.value.slice(0, query.value.length - 1);\n }\n if (!query.value) return;\n focusedIndex.value = null;\n const currentIndex = modelValueIndexed.value.get(query.value);\n if (isNil(currentIndex)) selectValue(query.value);\n else emit(\"duplicate\", query.value);\n query.value = \"\";\n } else if (event.key === \"ArrowLeft\") {\n if (focusedIndex.value === null)\n focusedIndex.value = modelValueNormalized.value.length - 1;\n else if (focusedIndex.value === 0) focusedIndex.value = null;\n else focusedIndex.value--;\n } else if (event.key === \"ArrowRight\") {\n if (focusedIndex.value === null) focusedIndex.value = 1;\n else if (focusedIndex.value === modelValueNormalized.value.length - 1)\n focusedIndex.value = null;\n else focusedIndex.value++;\n } else if (event.key === \"Backspace\") {\n if (query.value) return;\n if (isNotNil(focusedIndex.value)) {\n removeValue(focusedIndex.value);\n focusedIndex.value = clamp(\n focusedIndex.value,\n 0,\n modelValueNormalized.value.length - 2\n );\n if (modelValueNormalized.value.length === 1) focusedIndex.value = null;\n } else focusedIndex.value = modelValueNormalized.value.length - 1;\n } else if (event.key === \"Tab\" || event.key === \"Escape\") {\n focusedIndex.value = null;\n }\n};\n\nconst selectValue = (text: string) => {\n if (props.multiple) emit(\"update:modelValue\", props.modelValue.concat(text));\n else emit(\"update:modelValue\", text);\n};\n\nconst removeValue = (indexOrString: number | string) => {\n if (typeof indexOrString === \"number\") {\n if (props.multiple)\n emit(\"update:modelValue\", drop(props.modelValue, 1, indexOrString));\n else emit(\"update:modelValue\", null);\n } else {\n const currentIndex = modelValueIndexed.value.get(query.value);\n removeValue(currentIndex);\n }\n};\n\nconst onInputFocus = (event: FocusEvent) => {\n emit(\"focus\", event);\n active.value = true;\n document.addEventListener(\"click\", onClickOutside);\n document.addEventListener(\"focusin\", onFocusOutside);\n if (input.value instanceof HTMLInputElement) input.value.select();\n};\n\n/**\n * When clicking on the outside container seamlessly move focus to the input and open the panel\n */\nconst onOuterContainerClick = (event: MouseEvent) => {\n emit(\"click\", event);\n if (props.disabled || props.readonly) return;\n if (input.value instanceof HTMLElement) {\n input.value.focus();\n }\n};\n\n/**\n * On click outside of the container close the panel, remove active state.\n * In multiple selection clear query after a timeout\n */\nconst onClickOutside = (event: Event) => {\n if (event.target instanceof Node) {\n if (outerContainer.value) {\n if (!outerContainer.value.contains(event.target)) {\n emit(\"inactive\");\n document.removeEventListener(\"click\", onClickOutside);\n active.value = false;\n if (props.multiple)\n wait(500).then(() => {\n query.value = \"\";\n });\n return;\n }\n }\n }\n};\n\nconst onFocusOutside = (event: FocusEvent) => {\n if (event.target instanceof Node) {\n if (outerContainer.value) {\n if (!outerContainer.value.contains(event.target)) {\n emit(\"inactive\");\n document.removeEventListener(\"focusin\", onFocusOutside);\n active.value = false;\n if (props.multiple)\n wait(500).then(() => {\n query.value = \"\";\n });\n return;\n }\n }\n }\n};\n\nconst eventListeners = {\n onBlur: (event: FocusEvent) => emit(\"blur\", event),\n onChange: (event: Event) => emit(\"change\", event),\n onKeydown: (event: KeyboardEvent) => {\n if (event.key === \"Enter\" && props.divider === \"Enter\") {\n event.preventDefault();\n }\n emit(\"keydown\", event);\n },\n onInput: (event: Event) => emit(\"input\", event),\n};\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createElementBlock(\"span\", {\n class: _normalizeClass({\n 'bb-base-tag': true,\n 'bb-base-tag--active': active.value,\n 'bb-base-tag--disabled': _ctx.disabled,\n 'bb-base-tag--errors': _ctx.hasErrors,\n 'bb-base-tag--readonly': _ctx.readonly,\n }),\n onClick: onOuterContainerClick,\n ref_key: \"outerContainer\",\n ref: outerContainer\n }, [\n _renderSlot(_ctx.$slots, \"prepend-outer\"),\n _createElementVNode(\"span\", {\n class: \"bb-base-tag__inner-container\",\n ref_key: \"innerContainer\",\n ref: innerContainer\n }, [\n _renderSlot(_ctx.$slots, \"prepend\"),\n _createElementVNode(\"span\", _hoisted_1, [\n (_ctx.comma)\n ? (_openBlock(true), _createElementBlock(_Fragment, { key: 0 }, _renderList(modelValueNormalized.value, (option, index) => {\n return (_openBlock(), _createElementBlock(\"span\", {\n class: _normalizeClass({\n 'bb-base-tag__selected': true,\n 'bb-base-tag__selected--comma': true,\n 'bb-base-tag__selected--focused': index === focusedIndex.value,\n }),\n key: option\n }, _toDisplayString(option) + _toDisplayString(index < modelValueNormalized.value.length - 1 ? \",\" : \"\"), 3))\n }), 128))\n : (_openBlock(true), _createElementBlock(_Fragment, { key: 1 }, _renderList(modelValueNormalized.value, (option, index) => {\n return (_openBlock(), _createBlock(BbChip, {\n class: _normalizeClass({\n 'bb-base-tag__selected': true,\n 'bb-base-tag__selected--chip': true,\n 'bb-base-tag__selected--focused': index === focusedIndex.value,\n }),\n clearable: true,\n key: option,\n text: option,\n \"onClick:clear\": ($event: any) => (removeValue(index))\n }, null, 8, [\"class\", \"text\", \"onClick:clear\"]))\n }), 128)),\n _withDirectives(_createElementVNode(\"input\", _mergeProps({\n autocomplete: _ctx.autocomplete,\n autofocus: _ctx.autofocus,\n class: 'bb-base-tag__text-input',\n disabled: _ctx.disabled,\n id: _ctx.id,\n placeholder: computedPlaceholder.value,\n readonly: _ctx.readonly,\n type: 'text',\n onKeyup: onInputKeyup,\n onFocus: onInputFocus\n }, eventListeners, {\n \"onUpdate:modelValue\": _cache[0] || (_cache[0] = ($event: any) => ((query).value = $event)),\n ref_key: \"input\",\n ref: input\n }), null, 16, _hoisted_2), [\n [_vModelDynamic, query.value]\n ])\n ]),\n _renderSlot(_ctx.$slots, \"append\")\n ], 512),\n _renderSlot(_ctx.$slots, \"append-outer\")\n ], 2))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_sfc_main","_defineComponent","__props","__emit","props","emit","outerContainer","ref","innerContainer","input","query","computedPlaceholder","computed","modelValueNormalized","isNotNil","modelValueIndexed","map","value","index","active","focusedIndex","onInputKeyup","event","currentIndex","isNil","selectValue","removeValue","clamp","text","indexOrString","drop","onInputFocus","onClickOutside","onFocusOutside","onOuterContainerClick","wait","eventListeners","_ctx","_cache","_openBlock","_createElementBlock","_normalizeClass","_renderSlot","_createElementVNode","_Fragment","_renderList","option","_toDisplayString","_createBlock","BbChip","$event","_withDirectives","_mergeProps","_vModelDynamic"],"mappings":";;;;;;;;AAGA,MAAMA,IAAa,EAAE,OAAO,kCACtBC,IAAa,CAAC,gBAAgB,aAAa,YAAY,MAAM,eAAe,UAAU,GA6GhEC,KAAiBC,gBAAAA,EAAA;AAAA,EAC3C,QAAQ;AAAA,EACR,OAAO;AAAA,IACL,cAAc,CAAC;AAAA,IACf,WAAW,CAAC;AAAA,IACZ,OAAO,EAAE,MAAM,QAAQ;AAAA,IACvB,UAAU,EAAE,MAAM,QAAQ;AAAA,IAC1B,SAAS,EAAE,SAAS,QAAQ;AAAA,IAC5B,WAAW,EAAE,MAAM,QAAQ;AAAA,IAC3B,IAAI,CAAC;AAAA,IACL,YAAY,CAAC;AAAA,IACb,UAAU,EAAE,MAAM,SAAS,SAAS,GAAK;AAAA,IACzC,MAAM,CAAC;AAAA,IACP,aAAa,CAAC;AAAA,IACd,UAAU,CAAC;AAAA,EACb;AAAA,EACA,OAAO,CAAC,QAAQ,UAAU,SAAS,aAAa,SAAS,YAAY,SAAS,WAAW,SAAS,mBAAmB;AAAA,EACrH,MAAMC,GAAc,EAAE,MAAMC,KAAU;AAExC,UAAMC,IAAQF,GAERG,IAAOF;AAIb,QAAIC,EAAM,YAAY,CAAC,MAAM,QAAQA,EAAM,UAAU;AAC7C,YAAA,IAAI,MAAM,2DAA2D;AAGvE,UAAAE,IAAiBC,EAAwB,IAAI,GAC7CC,IAAiBD,EAAwB,IAAI,GAC7CE,IAAQF,EAAwB,IAAI,GACpCG,IAAQH,EAAY,EAAE,GACtBI,IAAsBC,EAAS,MAC5BR,EAAM,WACd,GAEKS,IAAuBD;AAAA,MAAS,MACpC,CAAA,EAAG,OAAOR,EAAM,UAAU,EAAE,OAAOU,CAAQ;AAAA,IAAA,GAMvCC,IAAoBH,EAAS,MAAM;AACvC,UAAII,IAAiC,CAAA;AACrC,aAAAH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AMA,EAAO,CAAC,IAAI,CAACY,MAAkBxC,EAAO,QAAQwC;AAAA,YACnF,SAAS;AAAA,YACT,KAAKzC;AAAA,UACN,CAAA,GAAG,MAAM,IAAIV,CAAU,GAAG;AAAA,YACzB,CAACsD,GAAgB3C,EAAM,KAAK;AAAA,UAAA,CAC7B;AAAA,QAAA,CACF;AAAA,QACDgC,EAAYL,EAAK,QAAQ,QAAQ;AAAA,SAChC,GAAG;AAAA,MACNK,EAAYL,EAAK,QAAQ,cAAc;AAAA,OACtC,CAAC;AAAA,EAEN;AAEA,CAAC;"}
|
|
1
|
+
{"version":3,"file":"index240.js","sources":["../src/utilities/functions/curry.ts"],"sourcesContent":["export type Curried<A extends any[], R> =\n <P extends Partial<A>>(...args: P) => P extends A ? R :\n A extends [...SameLength<P>, ...infer S] ? S extends any[] ? Curried<S, R>\n : never : never;\n\ntype SameLength<T extends any[]> = Extract<{ [K in keyof T]: any }, any[]>\n\nexport const curry = function<A extends any[], R>(fn: (...args: A) => R): Curried<A, R> {\n return (...args: any[]): any =>\n args.length >= fn.length ? fn(...args as any) : curry((fn as any).bind(undefined, ...args));\n }"],"names":["curry","fn","args"],"mappings":"AAOa,MAAAA,IAAQ,SAA6BC,GAAsC;AACpF,SAAO,IAAIC,MACTA,EAAK,UAAUD,EAAG,SAASA,EAAG,GAAGC,CAAW,IAAIF,EAAOC,EAAW,KAAK,QAAW,GAAGC,CAAI,CAAC;AAC9F;"}
|
package/dist/index241.js
CHANGED
|
@@ -1,5 +1,438 @@
|
|
|
1
|
-
|
|
1
|
+
import { isFocusable as G, tabbable as te, focusable as ae, isTabbable as T, getTabIndex as K } from "./index247.js";
|
|
2
|
+
/*!
|
|
3
|
+
* focus-trap 7.5.4
|
|
4
|
+
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
5
|
+
*/
|
|
6
|
+
function z(u, a) {
|
|
7
|
+
var o = Object.keys(u);
|
|
8
|
+
if (Object.getOwnPropertySymbols) {
|
|
9
|
+
var i = Object.getOwnPropertySymbols(u);
|
|
10
|
+
a && (i = i.filter(function(m) {
|
|
11
|
+
return Object.getOwnPropertyDescriptor(u, m).enumerable;
|
|
12
|
+
})), o.push.apply(o, i);
|
|
13
|
+
}
|
|
14
|
+
return o;
|
|
15
|
+
}
|
|
16
|
+
function J(u) {
|
|
17
|
+
for (var a = 1; a < arguments.length; a++) {
|
|
18
|
+
var o = arguments[a] != null ? arguments[a] : {};
|
|
19
|
+
a % 2 ? z(Object(o), !0).forEach(function(i) {
|
|
20
|
+
ne(u, i, o[i]);
|
|
21
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(u, Object.getOwnPropertyDescriptors(o)) : z(Object(o)).forEach(function(i) {
|
|
22
|
+
Object.defineProperty(u, i, Object.getOwnPropertyDescriptor(o, i));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return u;
|
|
26
|
+
}
|
|
27
|
+
function ne(u, a, o) {
|
|
28
|
+
return a = ie(a), a in u ? Object.defineProperty(u, a, {
|
|
29
|
+
value: o,
|
|
30
|
+
enumerable: !0,
|
|
31
|
+
configurable: !0,
|
|
32
|
+
writable: !0
|
|
33
|
+
}) : u[a] = o, u;
|
|
34
|
+
}
|
|
35
|
+
function re(u, a) {
|
|
36
|
+
if (typeof u != "object" || u === null)
|
|
37
|
+
return u;
|
|
38
|
+
var o = u[Symbol.toPrimitive];
|
|
39
|
+
if (o !== void 0) {
|
|
40
|
+
var i = o.call(u, a || "default");
|
|
41
|
+
if (typeof i != "object")
|
|
42
|
+
return i;
|
|
43
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
44
|
+
}
|
|
45
|
+
return (a === "string" ? String : Number)(u);
|
|
46
|
+
}
|
|
47
|
+
function ie(u) {
|
|
48
|
+
var a = re(u, "string");
|
|
49
|
+
return typeof a == "symbol" ? a : String(a);
|
|
50
|
+
}
|
|
51
|
+
var Q = {
|
|
52
|
+
activateTrap: function(a, o) {
|
|
53
|
+
if (a.length > 0) {
|
|
54
|
+
var i = a[a.length - 1];
|
|
55
|
+
i !== o && i.pause();
|
|
56
|
+
}
|
|
57
|
+
var m = a.indexOf(o);
|
|
58
|
+
m === -1 || a.splice(m, 1), a.push(o);
|
|
59
|
+
},
|
|
60
|
+
deactivateTrap: function(a, o) {
|
|
61
|
+
var i = a.indexOf(o);
|
|
62
|
+
i !== -1 && a.splice(i, 1), a.length > 0 && a[a.length - 1].unpause();
|
|
63
|
+
}
|
|
64
|
+
}, oe = function(a) {
|
|
65
|
+
return a.tagName && a.tagName.toLowerCase() === "input" && typeof a.select == "function";
|
|
66
|
+
}, ue = function(a) {
|
|
67
|
+
return (a == null ? void 0 : a.key) === "Escape" || (a == null ? void 0 : a.key) === "Esc" || (a == null ? void 0 : a.keyCode) === 27;
|
|
68
|
+
}, L = function(a) {
|
|
69
|
+
return (a == null ? void 0 : a.key) === "Tab" || (a == null ? void 0 : a.keyCode) === 9;
|
|
70
|
+
}, se = function(a) {
|
|
71
|
+
return L(a) && !a.shiftKey;
|
|
72
|
+
}, ce = function(a) {
|
|
73
|
+
return L(a) && a.shiftKey;
|
|
74
|
+
}, W = function(a) {
|
|
75
|
+
return setTimeout(a, 0);
|
|
76
|
+
}, X = function(a, o) {
|
|
77
|
+
var i = -1;
|
|
78
|
+
return a.every(function(m, s) {
|
|
79
|
+
return o(m) ? (i = s, !1) : !0;
|
|
80
|
+
}), i;
|
|
81
|
+
}, B = function(a) {
|
|
82
|
+
for (var o = arguments.length, i = new Array(o > 1 ? o - 1 : 0), m = 1; m < o; m++)
|
|
83
|
+
i[m - 1] = arguments[m];
|
|
84
|
+
return typeof a == "function" ? a.apply(void 0, i) : a;
|
|
85
|
+
}, C = function(a) {
|
|
86
|
+
return a.target.shadowRoot && typeof a.composedPath == "function" ? a.composedPath()[0] : a.target;
|
|
87
|
+
}, le = [], de = function(a, o) {
|
|
88
|
+
var i = (o == null ? void 0 : o.document) || document, m = (o == null ? void 0 : o.trapStack) || le, s = J({
|
|
89
|
+
returnFocusOnDeactivate: !0,
|
|
90
|
+
escapeDeactivates: !0,
|
|
91
|
+
delayInitialFocus: !0,
|
|
92
|
+
isKeyForward: se,
|
|
93
|
+
isKeyBackward: ce
|
|
94
|
+
}, o), n = {
|
|
95
|
+
// containers given to createFocusTrap()
|
|
96
|
+
// @type {Array<HTMLElement>}
|
|
97
|
+
containers: [],
|
|
98
|
+
// list of objects identifying tabbable nodes in `containers` in the trap
|
|
99
|
+
// NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
|
|
100
|
+
// is active, but the trap should never get to a state where there isn't at least one group
|
|
101
|
+
// with at least one tabbable node in it (that would lead to an error condition that would
|
|
102
|
+
// result in an error being thrown)
|
|
103
|
+
// @type {Array<{
|
|
104
|
+
// container: HTMLElement,
|
|
105
|
+
// tabbableNodes: Array<HTMLElement>, // empty if none
|
|
106
|
+
// focusableNodes: Array<HTMLElement>, // empty if none
|
|
107
|
+
// posTabIndexesFound: boolean,
|
|
108
|
+
// firstTabbableNode: HTMLElement|undefined,
|
|
109
|
+
// lastTabbableNode: HTMLElement|undefined,
|
|
110
|
+
// firstDomTabbableNode: HTMLElement|undefined,
|
|
111
|
+
// lastDomTabbableNode: HTMLElement|undefined,
|
|
112
|
+
// nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
|
|
113
|
+
// }>}
|
|
114
|
+
containerGroups: [],
|
|
115
|
+
// same order/length as `containers` list
|
|
116
|
+
// references to objects in `containerGroups`, but only those that actually have
|
|
117
|
+
// tabbable nodes in them
|
|
118
|
+
// NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
|
|
119
|
+
// the same length
|
|
120
|
+
tabbableGroups: [],
|
|
121
|
+
nodeFocusedBeforeActivation: null,
|
|
122
|
+
mostRecentlyFocusedNode: null,
|
|
123
|
+
active: !1,
|
|
124
|
+
paused: !1,
|
|
125
|
+
// timer ID for when delayInitialFocus is true and initial focus in this trap
|
|
126
|
+
// has been delayed during activation
|
|
127
|
+
delayInitialFocusTimer: void 0,
|
|
128
|
+
// the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
|
|
129
|
+
recentNavEvent: void 0
|
|
130
|
+
}, g, h = function(t, e, r) {
|
|
131
|
+
return t && t[e] !== void 0 ? t[e] : s[r || e];
|
|
132
|
+
}, F = function(t, e) {
|
|
133
|
+
var r = typeof (e == null ? void 0 : e.composedPath) == "function" ? e.composedPath() : void 0;
|
|
134
|
+
return n.containerGroups.findIndex(function(c) {
|
|
135
|
+
var l = c.container, d = c.tabbableNodes;
|
|
136
|
+
return l.contains(t) || // fall back to explicit tabbable search which will take into consideration any
|
|
137
|
+
// web components if the `tabbableOptions.getShadowRoot` option was used for
|
|
138
|
+
// the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
|
|
139
|
+
// look inside web components even if open)
|
|
140
|
+
(r == null ? void 0 : r.includes(l)) || d.find(function(v) {
|
|
141
|
+
return v === t;
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}, E = function(t) {
|
|
145
|
+
var e = s[t];
|
|
146
|
+
if (typeof e == "function") {
|
|
147
|
+
for (var r = arguments.length, c = new Array(r > 1 ? r - 1 : 0), l = 1; l < r; l++)
|
|
148
|
+
c[l - 1] = arguments[l];
|
|
149
|
+
e = e.apply(void 0, c);
|
|
150
|
+
}
|
|
151
|
+
if (e === !0 && (e = void 0), !e) {
|
|
152
|
+
if (e === void 0 || e === !1)
|
|
153
|
+
return e;
|
|
154
|
+
throw new Error("`".concat(t, "` was specified but was not a node, or did not return a node"));
|
|
155
|
+
}
|
|
156
|
+
var d = e;
|
|
157
|
+
if (typeof e == "string" && (d = i.querySelector(e), !d))
|
|
158
|
+
throw new Error("`".concat(t, "` as selector refers to no known node"));
|
|
159
|
+
return d;
|
|
160
|
+
}, P = function() {
|
|
161
|
+
var t = E("initialFocus");
|
|
162
|
+
if (t === !1)
|
|
163
|
+
return !1;
|
|
164
|
+
if (t === void 0 || !G(t, s.tabbableOptions))
|
|
165
|
+
if (F(i.activeElement) >= 0)
|
|
166
|
+
t = i.activeElement;
|
|
167
|
+
else {
|
|
168
|
+
var e = n.tabbableGroups[0], r = e && e.firstTabbableNode;
|
|
169
|
+
t = r || E("fallbackFocus");
|
|
170
|
+
}
|
|
171
|
+
if (!t)
|
|
172
|
+
throw new Error("Your focus-trap needs to have at least one focusable element");
|
|
173
|
+
return t;
|
|
174
|
+
}, D = function() {
|
|
175
|
+
if (n.containerGroups = n.containers.map(function(t) {
|
|
176
|
+
var e = te(t, s.tabbableOptions), r = ae(t, s.tabbableOptions), c = e.length > 0 ? e[0] : void 0, l = e.length > 0 ? e[e.length - 1] : void 0, d = r.find(function(b) {
|
|
177
|
+
return T(b);
|
|
178
|
+
}), v = r.slice().reverse().find(function(b) {
|
|
179
|
+
return T(b);
|
|
180
|
+
}), p = !!e.find(function(b) {
|
|
181
|
+
return K(b) > 0;
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
container: t,
|
|
185
|
+
tabbableNodes: e,
|
|
186
|
+
focusableNodes: r,
|
|
187
|
+
/** True if at least one node with positive `tabindex` was found in this container. */
|
|
188
|
+
posTabIndexesFound: p,
|
|
189
|
+
/** First tabbable node in container, __tabindex__ order; `undefined` if none. */
|
|
190
|
+
firstTabbableNode: c,
|
|
191
|
+
/** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
|
|
192
|
+
lastTabbableNode: l,
|
|
193
|
+
// NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
|
|
194
|
+
// would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
|
|
195
|
+
// because that API doesn't work with Shadow DOM as well as it should (@see
|
|
196
|
+
// https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
|
|
197
|
+
// to address an edge case related to positive tabindex support, this seems like a much easier,
|
|
198
|
+
// "close enough most of the time" alternative for positive tabindexes which should generally
|
|
199
|
+
// be avoided anyway...
|
|
200
|
+
/** First tabbable node in container, __DOM__ order; `undefined` if none. */
|
|
201
|
+
firstDomTabbableNode: d,
|
|
202
|
+
/** Last tabbable node in container, __DOM__ order; `undefined` if none. */
|
|
203
|
+
lastDomTabbableNode: v,
|
|
204
|
+
/**
|
|
205
|
+
* Finds the __tabbable__ node that follows the given node in the specified direction,
|
|
206
|
+
* in this container, if any.
|
|
207
|
+
* @param {HTMLElement} node
|
|
208
|
+
* @param {boolean} [forward] True if going in forward tab order; false if going
|
|
209
|
+
* in reverse.
|
|
210
|
+
* @returns {HTMLElement|undefined} The next tabbable node, if any.
|
|
211
|
+
*/
|
|
212
|
+
nextTabbableNode: function(N) {
|
|
213
|
+
var O = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, y = e.indexOf(N);
|
|
214
|
+
return y < 0 ? O ? r.slice(r.indexOf(N) + 1).find(function(R) {
|
|
215
|
+
return T(R);
|
|
216
|
+
}) : r.slice(0, r.indexOf(N)).reverse().find(function(R) {
|
|
217
|
+
return T(R);
|
|
218
|
+
}) : e[y + (O ? 1 : -1)];
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
}), n.tabbableGroups = n.containerGroups.filter(function(t) {
|
|
222
|
+
return t.tabbableNodes.length > 0;
|
|
223
|
+
}), n.tabbableGroups.length <= 0 && !E("fallbackFocus"))
|
|
224
|
+
throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
|
|
225
|
+
if (n.containerGroups.find(function(t) {
|
|
226
|
+
return t.posTabIndexesFound;
|
|
227
|
+
}) && n.containerGroups.length > 1)
|
|
228
|
+
throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
|
|
229
|
+
}, Z = function f(t) {
|
|
230
|
+
var e = t.activeElement;
|
|
231
|
+
if (e)
|
|
232
|
+
return e.shadowRoot && e.shadowRoot.activeElement !== null ? f(e.shadowRoot) : e;
|
|
233
|
+
}, w = function f(t) {
|
|
234
|
+
if (t !== !1 && t !== Z(document)) {
|
|
235
|
+
if (!t || !t.focus) {
|
|
236
|
+
f(P());
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
t.focus({
|
|
240
|
+
preventScroll: !!s.preventScroll
|
|
241
|
+
}), n.mostRecentlyFocusedNode = t, oe(t) && t.select();
|
|
242
|
+
}
|
|
243
|
+
}, S = function(t) {
|
|
244
|
+
var e = E("setReturnFocus", t);
|
|
245
|
+
return e || (e === !1 ? !1 : t);
|
|
246
|
+
}, U = function(t) {
|
|
247
|
+
var e = t.target, r = t.event, c = t.isBackward, l = c === void 0 ? !1 : c;
|
|
248
|
+
e = e || C(r), D();
|
|
249
|
+
var d = null;
|
|
250
|
+
if (n.tabbableGroups.length > 0) {
|
|
251
|
+
var v = F(e, r), p = v >= 0 ? n.containerGroups[v] : void 0;
|
|
252
|
+
if (v < 0)
|
|
253
|
+
l ? d = n.tabbableGroups[n.tabbableGroups.length - 1].lastTabbableNode : d = n.tabbableGroups[0].firstTabbableNode;
|
|
254
|
+
else if (l) {
|
|
255
|
+
var b = X(n.tabbableGroups, function(I) {
|
|
256
|
+
var x = I.firstTabbableNode;
|
|
257
|
+
return e === x;
|
|
258
|
+
});
|
|
259
|
+
if (b < 0 && (p.container === e || G(e, s.tabbableOptions) && !T(e, s.tabbableOptions) && !p.nextTabbableNode(e, !1)) && (b = v), b >= 0) {
|
|
260
|
+
var N = b === 0 ? n.tabbableGroups.length - 1 : b - 1, O = n.tabbableGroups[N];
|
|
261
|
+
d = K(e) >= 0 ? O.lastTabbableNode : O.lastDomTabbableNode;
|
|
262
|
+
} else
|
|
263
|
+
L(r) || (d = p.nextTabbableNode(e, !1));
|
|
264
|
+
} else {
|
|
265
|
+
var y = X(n.tabbableGroups, function(I) {
|
|
266
|
+
var x = I.lastTabbableNode;
|
|
267
|
+
return e === x;
|
|
268
|
+
});
|
|
269
|
+
if (y < 0 && (p.container === e || G(e, s.tabbableOptions) && !T(e, s.tabbableOptions) && !p.nextTabbableNode(e)) && (y = v), y >= 0) {
|
|
270
|
+
var R = y === n.tabbableGroups.length - 1 ? 0 : y + 1, $ = n.tabbableGroups[R];
|
|
271
|
+
d = K(e) >= 0 ? $.firstTabbableNode : $.firstDomTabbableNode;
|
|
272
|
+
} else
|
|
273
|
+
L(r) || (d = p.nextTabbableNode(e));
|
|
274
|
+
}
|
|
275
|
+
} else
|
|
276
|
+
d = E("fallbackFocus");
|
|
277
|
+
return d;
|
|
278
|
+
}, A = function(t) {
|
|
279
|
+
var e = C(t);
|
|
280
|
+
if (!(F(e, t) >= 0)) {
|
|
281
|
+
if (B(s.clickOutsideDeactivates, t)) {
|
|
282
|
+
g.deactivate({
|
|
283
|
+
// NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
|
|
284
|
+
// which will result in the outside click setting focus to the node
|
|
285
|
+
// that was clicked (and if not focusable, to "nothing"); by setting
|
|
286
|
+
// `returnFocus: true`, we'll attempt to re-focus the node originally-focused
|
|
287
|
+
// on activation (or the configured `setReturnFocus` node), whether the
|
|
288
|
+
// outside click was on a focusable node or not
|
|
289
|
+
returnFocus: s.returnFocusOnDeactivate
|
|
290
|
+
});
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
B(s.allowOutsideClick, t) || t.preventDefault();
|
|
294
|
+
}
|
|
295
|
+
}, q = function(t) {
|
|
296
|
+
var e = C(t), r = F(e, t) >= 0;
|
|
297
|
+
if (r || e instanceof Document)
|
|
298
|
+
r && (n.mostRecentlyFocusedNode = e);
|
|
299
|
+
else {
|
|
300
|
+
t.stopImmediatePropagation();
|
|
301
|
+
var c, l = !0;
|
|
302
|
+
if (n.mostRecentlyFocusedNode)
|
|
303
|
+
if (K(n.mostRecentlyFocusedNode) > 0) {
|
|
304
|
+
var d = F(n.mostRecentlyFocusedNode), v = n.containerGroups[d].tabbableNodes;
|
|
305
|
+
if (v.length > 0) {
|
|
306
|
+
var p = v.findIndex(function(b) {
|
|
307
|
+
return b === n.mostRecentlyFocusedNode;
|
|
308
|
+
});
|
|
309
|
+
p >= 0 && (s.isKeyForward(n.recentNavEvent) ? p + 1 < v.length && (c = v[p + 1], l = !1) : p - 1 >= 0 && (c = v[p - 1], l = !1));
|
|
310
|
+
}
|
|
311
|
+
} else
|
|
312
|
+
n.containerGroups.some(function(b) {
|
|
313
|
+
return b.tabbableNodes.some(function(N) {
|
|
314
|
+
return K(N) > 0;
|
|
315
|
+
});
|
|
316
|
+
}) || (l = !1);
|
|
317
|
+
else
|
|
318
|
+
l = !1;
|
|
319
|
+
l && (c = U({
|
|
320
|
+
// move FROM the MRU node, not event-related node (which will be the node that is
|
|
321
|
+
// outside the trap causing the focus escape we're trying to fix)
|
|
322
|
+
target: n.mostRecentlyFocusedNode,
|
|
323
|
+
isBackward: s.isKeyBackward(n.recentNavEvent)
|
|
324
|
+
})), w(c || n.mostRecentlyFocusedNode || P());
|
|
325
|
+
}
|
|
326
|
+
n.recentNavEvent = void 0;
|
|
327
|
+
}, _ = function(t) {
|
|
328
|
+
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
|
|
329
|
+
n.recentNavEvent = t;
|
|
330
|
+
var r = U({
|
|
331
|
+
event: t,
|
|
332
|
+
isBackward: e
|
|
333
|
+
});
|
|
334
|
+
r && (L(t) && t.preventDefault(), w(r));
|
|
335
|
+
}, H = function(t) {
|
|
336
|
+
if (ue(t) && B(s.escapeDeactivates, t) !== !1) {
|
|
337
|
+
t.preventDefault(), g.deactivate();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
(s.isKeyForward(t) || s.isKeyBackward(t)) && _(t, s.isKeyBackward(t));
|
|
341
|
+
}, M = function(t) {
|
|
342
|
+
var e = C(t);
|
|
343
|
+
F(e, t) >= 0 || B(s.clickOutsideDeactivates, t) || B(s.allowOutsideClick, t) || (t.preventDefault(), t.stopImmediatePropagation());
|
|
344
|
+
}, Y = function() {
|
|
345
|
+
if (n.active)
|
|
346
|
+
return Q.activateTrap(m, g), n.delayInitialFocusTimer = s.delayInitialFocus ? W(function() {
|
|
347
|
+
w(P());
|
|
348
|
+
}) : w(P()), i.addEventListener("focusin", q, !0), i.addEventListener("mousedown", A, {
|
|
349
|
+
capture: !0,
|
|
350
|
+
passive: !1
|
|
351
|
+
}), i.addEventListener("touchstart", A, {
|
|
352
|
+
capture: !0,
|
|
353
|
+
passive: !1
|
|
354
|
+
}), i.addEventListener("click", M, {
|
|
355
|
+
capture: !0,
|
|
356
|
+
passive: !1
|
|
357
|
+
}), i.addEventListener("keydown", H, {
|
|
358
|
+
capture: !0,
|
|
359
|
+
passive: !1
|
|
360
|
+
}), g;
|
|
361
|
+
}, V = function() {
|
|
362
|
+
if (n.active)
|
|
363
|
+
return i.removeEventListener("focusin", q, !0), i.removeEventListener("mousedown", A, !0), i.removeEventListener("touchstart", A, !0), i.removeEventListener("click", M, !0), i.removeEventListener("keydown", H, !0), g;
|
|
364
|
+
}, ee = function(t) {
|
|
365
|
+
var e = t.some(function(r) {
|
|
366
|
+
var c = Array.from(r.removedNodes);
|
|
367
|
+
return c.some(function(l) {
|
|
368
|
+
return l === n.mostRecentlyFocusedNode;
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
e && w(P());
|
|
372
|
+
}, j = typeof window < "u" && "MutationObserver" in window ? new MutationObserver(ee) : void 0, k = function() {
|
|
373
|
+
j && (j.disconnect(), n.active && !n.paused && n.containers.map(function(t) {
|
|
374
|
+
j.observe(t, {
|
|
375
|
+
subtree: !0,
|
|
376
|
+
childList: !0
|
|
377
|
+
});
|
|
378
|
+
}));
|
|
379
|
+
};
|
|
380
|
+
return g = {
|
|
381
|
+
get active() {
|
|
382
|
+
return n.active;
|
|
383
|
+
},
|
|
384
|
+
get paused() {
|
|
385
|
+
return n.paused;
|
|
386
|
+
},
|
|
387
|
+
activate: function(t) {
|
|
388
|
+
if (n.active)
|
|
389
|
+
return this;
|
|
390
|
+
var e = h(t, "onActivate"), r = h(t, "onPostActivate"), c = h(t, "checkCanFocusTrap");
|
|
391
|
+
c || D(), n.active = !0, n.paused = !1, n.nodeFocusedBeforeActivation = i.activeElement, e == null || e();
|
|
392
|
+
var l = function() {
|
|
393
|
+
c && D(), Y(), k(), r == null || r();
|
|
394
|
+
};
|
|
395
|
+
return c ? (c(n.containers.concat()).then(l, l), this) : (l(), this);
|
|
396
|
+
},
|
|
397
|
+
deactivate: function(t) {
|
|
398
|
+
if (!n.active)
|
|
399
|
+
return this;
|
|
400
|
+
var e = J({
|
|
401
|
+
onDeactivate: s.onDeactivate,
|
|
402
|
+
onPostDeactivate: s.onPostDeactivate,
|
|
403
|
+
checkCanReturnFocus: s.checkCanReturnFocus
|
|
404
|
+
}, t);
|
|
405
|
+
clearTimeout(n.delayInitialFocusTimer), n.delayInitialFocusTimer = void 0, V(), n.active = !1, n.paused = !1, k(), Q.deactivateTrap(m, g);
|
|
406
|
+
var r = h(e, "onDeactivate"), c = h(e, "onPostDeactivate"), l = h(e, "checkCanReturnFocus"), d = h(e, "returnFocus", "returnFocusOnDeactivate");
|
|
407
|
+
r == null || r();
|
|
408
|
+
var v = function() {
|
|
409
|
+
W(function() {
|
|
410
|
+
d && w(S(n.nodeFocusedBeforeActivation)), c == null || c();
|
|
411
|
+
});
|
|
412
|
+
};
|
|
413
|
+
return d && l ? (l(S(n.nodeFocusedBeforeActivation)).then(v, v), this) : (v(), this);
|
|
414
|
+
},
|
|
415
|
+
pause: function(t) {
|
|
416
|
+
if (n.paused || !n.active)
|
|
417
|
+
return this;
|
|
418
|
+
var e = h(t, "onPause"), r = h(t, "onPostPause");
|
|
419
|
+
return n.paused = !0, e == null || e(), V(), k(), r == null || r(), this;
|
|
420
|
+
},
|
|
421
|
+
unpause: function(t) {
|
|
422
|
+
if (!n.paused || !n.active)
|
|
423
|
+
return this;
|
|
424
|
+
var e = h(t, "onUnpause"), r = h(t, "onPostUnpause");
|
|
425
|
+
return n.paused = !1, e == null || e(), D(), Y(), k(), r == null || r(), this;
|
|
426
|
+
},
|
|
427
|
+
updateContainerElements: function(t) {
|
|
428
|
+
var e = [].concat(t).filter(Boolean);
|
|
429
|
+
return n.containers = e.map(function(r) {
|
|
430
|
+
return typeof r == "string" ? i.querySelector(r) : r;
|
|
431
|
+
}), n.active && D(), k(), this;
|
|
432
|
+
}
|
|
433
|
+
}, g.updateContainerElements(a), g;
|
|
434
|
+
};
|
|
2
435
|
export {
|
|
3
|
-
|
|
436
|
+
de as createFocusTrap
|
|
4
437
|
};
|
|
5
438
|
//# sourceMappingURL=index241.js.map
|