vrembem 4.0.0-next.29 → 4.0.0-next.30
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/dev/index.js +43 -19
- package/dev/index.js.map +1 -1
- package/dev/index.umd.cjs +43 -19
- package/dev/index.umd.cjs.map +1 -1
- package/dist/index.js +295 -270
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +3 -3
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +22 -22
package/dev/index.js
CHANGED
|
@@ -58,7 +58,7 @@ function getConfig(el, dataConfig = "config") {
|
|
|
58
58
|
function getCustomProps(entry) {
|
|
59
59
|
const styles = getComputedStyle(entry.el);
|
|
60
60
|
const result = {};
|
|
61
|
-
const keys =
|
|
61
|
+
const keys = entry.getSetting("customProps");
|
|
62
62
|
for (let i = 0; i < keys.length; i++) {
|
|
63
63
|
const prefix = getPrefix();
|
|
64
64
|
const module = entry.context.module.toLowerCase();
|
|
@@ -79,6 +79,27 @@ function getElement(query) {
|
|
|
79
79
|
return null;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
function maybeReturnSetting(prop, key, type = "camel") {
|
|
83
|
+
key = type === "camel" ? toCamel(key) : toKebab(key);
|
|
84
|
+
return prop.split(".").concat(key).reduce((obj, key2) => obj == null ? void 0 : obj[key2], this);
|
|
85
|
+
}
|
|
86
|
+
function getSetting(key, options = {}) {
|
|
87
|
+
const {
|
|
88
|
+
fallback,
|
|
89
|
+
props = ["dataConfig", "customProps", "settings", "context.settings"]
|
|
90
|
+
} = options;
|
|
91
|
+
for (const prop of props) {
|
|
92
|
+
const type = prop !== "customProps" ? "camel" : "kebab";
|
|
93
|
+
const result = maybeReturnSetting.call(this, prop, key, type);
|
|
94
|
+
if (result !== void 0) {
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (fallback !== void 0) {
|
|
99
|
+
return fallback;
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`${this.context.module} setting does not exist: ${key}`);
|
|
102
|
+
}
|
|
82
103
|
async function lifecycleHook(name, ...args) {
|
|
83
104
|
if (name in this && typeof this[name] === "function") {
|
|
84
105
|
await this[name](...args);
|
|
@@ -167,6 +188,7 @@ class Collection {
|
|
|
167
188
|
this.collection = [];
|
|
168
189
|
this.settings = Object.assign({
|
|
169
190
|
dataConfig: "config",
|
|
191
|
+
customProps: [],
|
|
170
192
|
teleport: null,
|
|
171
193
|
teleportMethod: "append"
|
|
172
194
|
}, options);
|
|
@@ -247,22 +269,8 @@ class CollectionEntry {
|
|
|
247
269
|
getCustomProps() {
|
|
248
270
|
return Object.assign(this.customProps, getCustomProps(this));
|
|
249
271
|
}
|
|
250
|
-
getSetting(key) {
|
|
251
|
-
|
|
252
|
-
const kebab = toKebab(key);
|
|
253
|
-
if ("dataConfig" in this && camel in this.dataConfig) {
|
|
254
|
-
return this.dataConfig[camel];
|
|
255
|
-
}
|
|
256
|
-
if ("customProps" in this && kebab in this.customProps) {
|
|
257
|
-
return this.customProps[kebab];
|
|
258
|
-
}
|
|
259
|
-
if ("settings" in this && camel in this.settings) {
|
|
260
|
-
return this.settings[camel];
|
|
261
|
-
}
|
|
262
|
-
if ("settings" in this.context && camel in this.context.settings) {
|
|
263
|
-
return this.context.settings[camel];
|
|
264
|
-
}
|
|
265
|
-
throw new Error(`${this.context.module} setting does not exist: ${key}`);
|
|
272
|
+
getSetting(key, options = {}) {
|
|
273
|
+
return getSetting.call(this, key, options);
|
|
266
274
|
}
|
|
267
275
|
async mount(options = {}) {
|
|
268
276
|
if (this.el === null) {
|
|
@@ -519,6 +527,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
519
527
|
getCustomProps,
|
|
520
528
|
getElement,
|
|
521
529
|
getPrefix,
|
|
530
|
+
getSetting,
|
|
522
531
|
lifecycleHook,
|
|
523
532
|
localStore,
|
|
524
533
|
setGlobalState,
|
|
@@ -550,6 +559,9 @@ const defaults$2 = {
|
|
|
550
559
|
// Classes
|
|
551
560
|
classModal: "drawer_modal",
|
|
552
561
|
// Feature toggles
|
|
562
|
+
customProps: [
|
|
563
|
+
"transition-duration"
|
|
564
|
+
],
|
|
553
565
|
breakpoints: null,
|
|
554
566
|
customEventPrefix: "drawer:",
|
|
555
567
|
store: true,
|
|
@@ -558,7 +570,7 @@ const defaults$2 = {
|
|
|
558
570
|
teleport: null,
|
|
559
571
|
teleportMethod: "prepend",
|
|
560
572
|
transition: true,
|
|
561
|
-
transitionDuration:
|
|
573
|
+
transitionDuration: 300
|
|
562
574
|
};
|
|
563
575
|
function applyInitialState(entry) {
|
|
564
576
|
if (entry.store === "opened") {
|
|
@@ -930,12 +942,15 @@ const defaults$1 = {
|
|
|
930
942
|
stateClosing: "is-closing",
|
|
931
943
|
stateClosed: "is-closed",
|
|
932
944
|
// Feature settings
|
|
945
|
+
customProps: [
|
|
946
|
+
"transition-duration"
|
|
947
|
+
],
|
|
933
948
|
customEventPrefix: "modal:",
|
|
934
949
|
setTabindex: true,
|
|
935
950
|
teleport: null,
|
|
936
951
|
teleportMethod: "append",
|
|
937
952
|
transition: true,
|
|
938
|
-
transitionDuration:
|
|
953
|
+
transitionDuration: 300
|
|
939
954
|
};
|
|
940
955
|
class ModalEntry extends CollectionEntry {
|
|
941
956
|
constructor(context, query, options = {}) {
|
|
@@ -1233,6 +1248,15 @@ const defaults = {
|
|
|
1233
1248
|
// State classes
|
|
1234
1249
|
stateActive: "is-active",
|
|
1235
1250
|
// Custom properties and their defaults
|
|
1251
|
+
customProps: [
|
|
1252
|
+
"placement",
|
|
1253
|
+
"event",
|
|
1254
|
+
"offset",
|
|
1255
|
+
"flip-padding",
|
|
1256
|
+
"shift-padding",
|
|
1257
|
+
"arrow-padding",
|
|
1258
|
+
"toggle-delay"
|
|
1259
|
+
],
|
|
1236
1260
|
placement: "bottom",
|
|
1237
1261
|
event: "click",
|
|
1238
1262
|
offset: 0,
|