bhl-forms 0.3.3 → 0.3.4
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/bhl-forms.es.js +132 -51
- package/dist/bhl-forms.iife.js +7 -7
- package/dist/bhl-forms.modern.es.js +151 -60
- package/dist/bhl-forms.modern.iife.js +9 -9
- package/dist/bhl-forms.modern.umd.js +9 -9
- package/dist/bhl-forms.umd.js +7 -7
- package/dist/forms/vets.es.js +1 -1
- package/dist/forms/vets.iife.js +1 -1
- package/dist/forms/vets.json +1 -1
- package/package.json +5 -5
package/dist/bhl-forms.es.js
CHANGED
|
@@ -5417,31 +5417,38 @@ function syncListNodes$1(node, context) {
|
|
|
5417
5417
|
unused.delete(context.children[i2]);
|
|
5418
5418
|
} else {
|
|
5419
5419
|
newChildren.push(null);
|
|
5420
|
-
placeholderValues.
|
|
5420
|
+
const indexes = placeholderValues.get(value) || [];
|
|
5421
|
+
indexes.push(i2);
|
|
5422
|
+
placeholderValues.set(value, indexes);
|
|
5421
5423
|
}
|
|
5422
5424
|
});
|
|
5423
5425
|
if (unused.size && placeholderValues.size) {
|
|
5424
5426
|
unused.forEach((child) => {
|
|
5425
5427
|
if (placeholderValues.has(child._value)) {
|
|
5426
|
-
|
|
5428
|
+
const indexes = placeholderValues.get(child._value);
|
|
5429
|
+
const index2 = indexes.shift();
|
|
5430
|
+
newChildren[index2] = child;
|
|
5427
5431
|
unused.delete(child);
|
|
5428
|
-
|
|
5432
|
+
if (!indexes.length)
|
|
5433
|
+
placeholderValues.delete(child._value);
|
|
5429
5434
|
}
|
|
5430
5435
|
});
|
|
5431
5436
|
}
|
|
5432
|
-
|
|
5437
|
+
const emptyIndexes = [];
|
|
5438
|
+
placeholderValues.forEach((indexes) => {
|
|
5439
|
+
emptyIndexes.push(...indexes);
|
|
5440
|
+
});
|
|
5441
|
+
while (unused.size && emptyIndexes.length) {
|
|
5433
5442
|
const child = unused.values().next().value;
|
|
5434
|
-
const
|
|
5435
|
-
|
|
5443
|
+
const index2 = emptyIndexes.shift();
|
|
5444
|
+
if (index2 === void 0)
|
|
5445
|
+
break;
|
|
5436
5446
|
newChildren[index2] = child;
|
|
5437
5447
|
unused.delete(child);
|
|
5438
|
-
placeholderValues.delete(value);
|
|
5439
|
-
}
|
|
5440
|
-
if (placeholderValues.size) {
|
|
5441
|
-
placeholderValues.forEach((index2, value) => {
|
|
5442
|
-
newChildren[index2] = createPlaceholder$1({ value });
|
|
5443
|
-
});
|
|
5444
5448
|
}
|
|
5449
|
+
emptyIndexes.forEach((index2, value) => {
|
|
5450
|
+
newChildren[index2] = createPlaceholder$1({ value });
|
|
5451
|
+
});
|
|
5445
5452
|
if (unused.size) {
|
|
5446
5453
|
unused.forEach((child) => {
|
|
5447
5454
|
if (!("__FKP" in child)) {
|
|
@@ -7252,31 +7259,38 @@ function syncListNodes(node, context) {
|
|
|
7252
7259
|
unused.delete(context.children[i2]);
|
|
7253
7260
|
} else {
|
|
7254
7261
|
newChildren.push(null);
|
|
7255
|
-
placeholderValues.
|
|
7262
|
+
const indexes = placeholderValues.get(value) || [];
|
|
7263
|
+
indexes.push(i2);
|
|
7264
|
+
placeholderValues.set(value, indexes);
|
|
7256
7265
|
}
|
|
7257
7266
|
});
|
|
7258
7267
|
if (unused.size && placeholderValues.size) {
|
|
7259
7268
|
unused.forEach((child) => {
|
|
7260
7269
|
if (placeholderValues.has(child._value)) {
|
|
7261
|
-
|
|
7270
|
+
const indexes = placeholderValues.get(child._value);
|
|
7271
|
+
const index2 = indexes.shift();
|
|
7272
|
+
newChildren[index2] = child;
|
|
7262
7273
|
unused.delete(child);
|
|
7263
|
-
|
|
7274
|
+
if (!indexes.length)
|
|
7275
|
+
placeholderValues.delete(child._value);
|
|
7264
7276
|
}
|
|
7265
7277
|
});
|
|
7266
7278
|
}
|
|
7267
|
-
|
|
7279
|
+
const emptyIndexes = [];
|
|
7280
|
+
placeholderValues.forEach((indexes) => {
|
|
7281
|
+
emptyIndexes.push(...indexes);
|
|
7282
|
+
});
|
|
7283
|
+
while (unused.size && emptyIndexes.length) {
|
|
7268
7284
|
const child = unused.values().next().value;
|
|
7269
|
-
const
|
|
7270
|
-
|
|
7285
|
+
const index2 = emptyIndexes.shift();
|
|
7286
|
+
if (index2 === void 0)
|
|
7287
|
+
break;
|
|
7271
7288
|
newChildren[index2] = child;
|
|
7272
7289
|
unused.delete(child);
|
|
7273
|
-
placeholderValues.delete(value);
|
|
7274
|
-
}
|
|
7275
|
-
if (placeholderValues.size) {
|
|
7276
|
-
placeholderValues.forEach((index2, value) => {
|
|
7277
|
-
newChildren[index2] = createPlaceholder({ value });
|
|
7278
|
-
});
|
|
7279
7290
|
}
|
|
7291
|
+
emptyIndexes.forEach((index2, value) => {
|
|
7292
|
+
newChildren[index2] = createPlaceholder({ value });
|
|
7293
|
+
});
|
|
7280
7294
|
if (unused.size) {
|
|
7281
7295
|
unused.forEach((child) => {
|
|
7282
7296
|
if (!("__FKP" in child)) {
|
|
@@ -8228,7 +8242,7 @@ function clearErrors(id, clearChildren = true) {
|
|
|
8228
8242
|
warn(652, id);
|
|
8229
8243
|
}
|
|
8230
8244
|
}
|
|
8231
|
-
const FORMKIT_VERSION = "0.17.
|
|
8245
|
+
const FORMKIT_VERSION = "0.17.2";
|
|
8232
8246
|
function createLibraryPlugin(...libraries) {
|
|
8233
8247
|
const library = libraries.reduce((merged, lib) => extend$1(merged, lib), {});
|
|
8234
8248
|
const plugin2 = () => {
|
|
@@ -11229,7 +11243,7 @@ function useInput(props2, context, options2 = {}) {
|
|
|
11229
11243
|
}
|
|
11230
11244
|
if (isVModeled && node.context) {
|
|
11231
11245
|
clonedValueBeforeVmodel = cloneAny(node.value);
|
|
11232
|
-
context.emit("update:modelValue", node.value);
|
|
11246
|
+
context.emit("update:modelValue", shallowClone(node.value));
|
|
11233
11247
|
}
|
|
11234
11248
|
});
|
|
11235
11249
|
if (isVModeled) {
|
|
@@ -11269,6 +11283,9 @@ function createInput(schemaOrComponent, definitionOptions = {}) {
|
|
|
11269
11283
|
schema = createSection("input", () => cloneAny(schemaOrComponent));
|
|
11270
11284
|
}
|
|
11271
11285
|
definition2.schema = useSchema(schema || "Schema undefined");
|
|
11286
|
+
if (!definition2.schemaMemoKey) {
|
|
11287
|
+
definition2.schemaMemoKey = `${Math.random()}`;
|
|
11288
|
+
}
|
|
11272
11289
|
return definition2;
|
|
11273
11290
|
}
|
|
11274
11291
|
const messages = createSection("messages", () => ({
|
|
@@ -11539,8 +11556,12 @@ const vueBindings = function vueBindings2(node) {
|
|
|
11539
11556
|
}
|
|
11540
11557
|
});
|
|
11541
11558
|
node.on("commitRaw", ({ payload }) => {
|
|
11542
|
-
|
|
11543
|
-
|
|
11559
|
+
if (node.type !== "input" && !isRef(payload) && !isReactive(payload)) {
|
|
11560
|
+
value.value = _value.value = shallowClone(payload);
|
|
11561
|
+
} else {
|
|
11562
|
+
value.value = _value.value = payload;
|
|
11563
|
+
triggerRef(value);
|
|
11564
|
+
}
|
|
11544
11565
|
node.emit("modelUpdated");
|
|
11545
11566
|
});
|
|
11546
11567
|
node.on("commit", () => {
|
|
@@ -12190,39 +12211,99 @@ const multiStepOuter = createSection("multiStepOuter", () => ({
|
|
|
12190
12211
|
],
|
|
12191
12212
|
features: [localize$2("next"), localize$2("prev")]
|
|
12192
12213
|
});
|
|
12193
|
-
function createLocalStoragePlugin(
|
|
12214
|
+
function createLocalStoragePlugin(localStorageOptions) {
|
|
12194
12215
|
const localStoragePlugin = (node) => {
|
|
12195
|
-
if (node.
|
|
12216
|
+
if (node.type !== "group")
|
|
12196
12217
|
return;
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
12200
|
-
|
|
12201
|
-
|
|
12202
|
-
|
|
12203
|
-
|
|
12204
|
-
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
|
|
12210
|
-
|
|
12211
|
-
|
|
12212
|
-
|
|
12218
|
+
const shouldUseLocalStorage = (controlNode) => {
|
|
12219
|
+
let controlFieldValue = true;
|
|
12220
|
+
if (controlNode) {
|
|
12221
|
+
controlFieldValue = controlNode.value === true;
|
|
12222
|
+
}
|
|
12223
|
+
return undefine(node.props.useLocalStorage) && controlFieldValue;
|
|
12224
|
+
};
|
|
12225
|
+
node.on("created", () => __async(this, null, function* () {
|
|
12226
|
+
var _a, _b, _c;
|
|
12227
|
+
node.addProps(["useLocalStorage"]);
|
|
12228
|
+
yield node.settled;
|
|
12229
|
+
const controlField = (_a = localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.control) !== null && _a !== void 0 ? _a : void 0;
|
|
12230
|
+
let controlNode;
|
|
12231
|
+
if (typeof controlField === "string") {
|
|
12232
|
+
const controlNode2 = node.at(controlField);
|
|
12233
|
+
if (controlNode2) {
|
|
12234
|
+
controlNode2.on("commit", () => {
|
|
12235
|
+
useLocalStorage = shouldUseLocalStorage(controlNode2);
|
|
12236
|
+
if (!useLocalStorage) {
|
|
12237
|
+
localStorage.removeItem(storageKey);
|
|
12238
|
+
}
|
|
12239
|
+
});
|
|
12213
12240
|
}
|
|
12214
12241
|
}
|
|
12215
|
-
|
|
12216
|
-
|
|
12242
|
+
let useLocalStorage = shouldUseLocalStorage(controlNode);
|
|
12243
|
+
let saveTimeout = 0;
|
|
12244
|
+
const debounce = typeof (localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.debounce) === "number" ? localStorageOptions.debounce : 200;
|
|
12245
|
+
const prefix2 = (_b = localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.prefix) !== null && _b !== void 0 ? _b : "formkit";
|
|
12246
|
+
const maxAge = (_c = localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.maxAge) !== null && _c !== void 0 ? _c : 36e5;
|
|
12247
|
+
const key = (localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.key) ? `-${localStorageOptions.key}` : "";
|
|
12248
|
+
const storageKey = `${prefix2}${key}-${node.name}`;
|
|
12249
|
+
const loadValue = () => __async(this, null, function* () {
|
|
12250
|
+
const value = localStorage.getItem(storageKey);
|
|
12251
|
+
if (!value)
|
|
12252
|
+
return;
|
|
12253
|
+
const loadValue2 = JSON.parse(value);
|
|
12254
|
+
if (typeof (localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.beforeLoad) === "function") {
|
|
12255
|
+
node.props.disabled = true;
|
|
12256
|
+
try {
|
|
12257
|
+
loadValue2.data = yield localStorageOptions.beforeLoad(loadValue2.data);
|
|
12258
|
+
} catch (error2) {
|
|
12259
|
+
console.error(error2);
|
|
12260
|
+
}
|
|
12261
|
+
node.props.disabled = false;
|
|
12262
|
+
}
|
|
12263
|
+
if (!loadValue2 || typeof loadValue2.data !== "object")
|
|
12264
|
+
return;
|
|
12265
|
+
if (loadValue2.maxAge > Date.now()) {
|
|
12266
|
+
node.input(loadValue2.data, false);
|
|
12267
|
+
} else {
|
|
12268
|
+
localStorage.removeItem(storageKey);
|
|
12269
|
+
}
|
|
12270
|
+
});
|
|
12271
|
+
const saveValue = (payload) => __async(this, null, function* () {
|
|
12272
|
+
let savePayload = payload;
|
|
12273
|
+
if (typeof (localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.beforeSave) === "function") {
|
|
12274
|
+
try {
|
|
12275
|
+
savePayload = yield localStorageOptions.beforeSave(payload);
|
|
12276
|
+
} catch (error2) {
|
|
12277
|
+
console.error(error2);
|
|
12278
|
+
}
|
|
12279
|
+
}
|
|
12280
|
+
if (!savePayload)
|
|
12281
|
+
return;
|
|
12282
|
+
localStorage.setItem(storageKey, JSON.stringify({
|
|
12217
12283
|
maxAge: Date.now() + maxAge,
|
|
12218
|
-
data:
|
|
12284
|
+
data: savePayload
|
|
12219
12285
|
}));
|
|
12220
12286
|
});
|
|
12287
|
+
node.on("commit", ({ payload }) => {
|
|
12288
|
+
if (!useLocalStorage)
|
|
12289
|
+
return;
|
|
12290
|
+
clearTimeout(saveTimeout);
|
|
12291
|
+
saveTimeout = setTimeout(() => __async(this, null, function* () {
|
|
12292
|
+
saveValue(payload);
|
|
12293
|
+
}), debounce);
|
|
12294
|
+
});
|
|
12295
|
+
node.on("prop:useLocalStorage", () => {
|
|
12296
|
+
useLocalStorage = shouldUseLocalStorage(controlNode);
|
|
12297
|
+
if (!useLocalStorage) {
|
|
12298
|
+
localStorage.removeItem(storageKey);
|
|
12299
|
+
}
|
|
12300
|
+
});
|
|
12221
12301
|
node.hook.submit((payload, next) => {
|
|
12222
|
-
localStorage.removeItem(
|
|
12302
|
+
localStorage.removeItem(storageKey);
|
|
12223
12303
|
return next(payload);
|
|
12224
12304
|
});
|
|
12225
|
-
|
|
12305
|
+
yield loadValue();
|
|
12306
|
+
}));
|
|
12226
12307
|
};
|
|
12227
12308
|
return localStoragePlugin;
|
|
12228
12309
|
}
|