@featherds/input-helper
Advanced tools
Comparing version 0.10.1 to 0.10.2
@@ -21,3 +21,3 @@ var __defProp = Object.defineProperty; | ||
import { FeatherIcon } from "@featherds/icon"; | ||
import { resolveComponent, openBlock, createElementBlock, createVNode, createBlock, withModifiers, markRaw, inject, computed, normalizeClass, createElementVNode, toDisplayString, renderSlot, createCommentVNode, withDirectives, vShow, ref, nextTick, Fragment, renderList, provide, isRef, watch } from "vue"; | ||
import { resolveComponent, openBlock, createElementBlock, createVNode, createBlock, withModifiers, markRaw, inject, computed, normalizeClass, createElementVNode, toDisplayString, renderSlot, createCommentVNode, withDirectives, vShow, ref, toRef, nextTick, watch, createTextVNode, Fragment, renderList, provide, isRef, onBeforeUnmount } from "vue"; | ||
import Cancel from "@featherds/icon/navigation/Cancel"; | ||
@@ -232,4 +232,4 @@ import Error2 from "@featherds/icon/notification/Warning"; | ||
const _hoisted_2$2 = ["for"]; | ||
const _hoisted_3$1 = { class: "prefix" }; | ||
const _hoisted_4$1 = { class: "post" }; | ||
const _hoisted_3$2 = { class: "prefix" }; | ||
const _hoisted_4$2 = { class: "post" }; | ||
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) { | ||
@@ -253,7 +253,7 @@ const _component_ClearIcon = resolveComponent("ClearIcon"); | ||
}, [ | ||
createElementVNode("div", _hoisted_3$1, [ | ||
createElementVNode("div", _hoisted_3$2, [ | ||
renderSlot(_ctx.$slots, "pre", {}, void 0, true) | ||
]), | ||
renderSlot(_ctx.$slots, "default", {}, void 0, true), | ||
createElementVNode("div", _hoisted_4$1, [ | ||
createElementVNode("div", _hoisted_4$2, [ | ||
$props.showClear && $options.computedClearText ? (openBlock(), createBlock(_component_ClearIcon, { | ||
@@ -335,3 +335,3 @@ key: 0, | ||
}; | ||
const _hoisted_3 = { | ||
const _hoisted_3$1 = { | ||
key: 1, | ||
@@ -341,3 +341,3 @@ class: "feather-input-hint", | ||
}; | ||
const _hoisted_4 = { | ||
const _hoisted_4$1 = { | ||
key: 2, | ||
@@ -354,4 +354,4 @@ class: "feather-input-error", | ||
!_ctx.hint && !$setup.error.length ? (openBlock(), createElementBlock("div", _hoisted_2$1, "\xA0")) : createCommentVNode("", true), | ||
_ctx.hint && !$setup.error.length ? (openBlock(), createElementBlock("div", _hoisted_3, toDisplayString(_ctx.hint), 1)) : createCommentVNode("", true), | ||
$setup.error.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_4, toDisplayString($setup.error), 1)) : createCommentVNode("", true), | ||
_ctx.hint && !$setup.error.length ? (openBlock(), createElementBlock("div", _hoisted_3$1, toDisplayString(_ctx.hint), 1)) : createCommentVNode("", true), | ||
$setup.error.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_4$1, toDisplayString($setup.error), 1)) : createCommentVNode("", true), | ||
renderSlot(_ctx.$slots, "right", {}, void 0, true) | ||
@@ -402,2 +402,6 @@ ], 8, _hoisted_1$1)), [ | ||
} | ||
}, | ||
generalError: { | ||
type: String, | ||
default: "" | ||
} | ||
@@ -407,2 +411,3 @@ }, | ||
const errorList = inject("featherFormErrors", ref([])); | ||
const mainError = toRef(props, "generalError"); | ||
const focusElement = (id) => { | ||
@@ -427,2 +432,7 @@ document.getElementById(id).focus(); | ||
}); | ||
watch(mainError, (v) => { | ||
if (v.length) { | ||
nextTick(() => heading.value.focus()); | ||
} | ||
}); | ||
return { | ||
@@ -432,3 +442,4 @@ errors, | ||
heading, | ||
focusElement | ||
focusElement, | ||
mainError | ||
}; | ||
@@ -442,10 +453,19 @@ } | ||
}; | ||
const _hoisted_2 = ["onClick"]; | ||
const _hoisted_2 = { | ||
class: "error-heading", | ||
tabindex: "-1", | ||
ref: "heading" | ||
}; | ||
const _hoisted_3 = { key: 0 }; | ||
const _hoisted_4 = /* @__PURE__ */ createElementVNode("br", null, null, -1); | ||
const _hoisted_5 = ["onClick"]; | ||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { | ||
return $setup.errors.length ? (openBlock(), createElementBlock("div", _hoisted_1, [ | ||
createElementVNode("div", { | ||
class: "error-heading", | ||
tabindex: "-1", | ||
ref: "heading" | ||
}, toDisplayString($setup.errorsHeading), 513), | ||
return $setup.errors.length || $setup.mainError.length ? (openBlock(), createElementBlock("div", _hoisted_1, [ | ||
createElementVNode("div", _hoisted_2, [ | ||
$setup.errors.length ? (openBlock(), createElementBlock("span", _hoisted_3, [ | ||
createTextVNode(toDisplayString($setup.errorsHeading), 1), | ||
_hoisted_4 | ||
])) : createCommentVNode("", true), | ||
createTextVNode(" " + toDisplayString($setup.mainError), 1) | ||
], 512), | ||
createElementVNode("ul", null, [ | ||
@@ -459,3 +479,3 @@ (openBlock(true), createElementBlock(Fragment, null, renderList($setup.errors, (item) => { | ||
onClick: withModifiers(($event) => $setup.focusElement(item.inputId), ["prevent"]) | ||
}, toDisplayString(item.fullMessage), 9, _hoisted_2) | ||
}, toDisplayString(item.fullMessage), 9, _hoisted_5) | ||
]); | ||
@@ -545,6 +565,8 @@ }), 128)) | ||
}, { immediate: true }); | ||
const removeValidation = () => form.deregister(inputId.value, true); | ||
return { validate, removeValidation }; | ||
onBeforeUnmount(() => { | ||
form.deregister(inputId.value, true); | ||
}); | ||
return { validate }; | ||
} | ||
return { validate: () => true, removeValidation: () => null }; | ||
return { validate: () => true }; | ||
}; | ||
@@ -551,0 +573,0 @@ const useInputInheritAttrs = (attrs) => { |
{ | ||
"name": "@featherds/input-helper", | ||
"version": "0.10.1", | ||
"version": "0.10.2", | ||
"publishConfig": { | ||
@@ -12,3 +12,3 @@ "access": "public" | ||
"dependencies": { | ||
"@featherds/styles": "^0.10.1", | ||
"@featherds/styles": "^0.10.2", | ||
"vue": "^3.1.0-0" | ||
@@ -21,3 +21,3 @@ }, | ||
"types": "./src/index.d.ts", | ||
"gitHead": "a0bd85a4e26026d7fe582ccabf92a44ae85525ba" | ||
"gitHead": "962dcee415575770eb0bc2781bfd29288873176e" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { inject, ref, provide, watch, isRef } from "vue"; | ||
import { inject, ref, provide, watch, isRef, onBeforeUnmount } from "vue"; | ||
const useValidation = (inputId, value, label, schema, errorFromInput) => { | ||
@@ -52,8 +52,10 @@ const form = inject("featherForm", false); | ||
); | ||
const removeValidation = () => form.deregister(inputId.value, true); | ||
return { validate, removeValidation }; | ||
onBeforeUnmount(() => { | ||
form.deregister(inputId.value, true); | ||
}); | ||
return { validate }; | ||
} | ||
return { validate: () => true, removeValidation: () => null }; | ||
return { validate: () => true }; | ||
}; | ||
export { useValidation }; |
@@ -47,3 +47,2 @@ declare module "@featherds/input-helper" { | ||
}; | ||
removeValidation: () => void; | ||
}; | ||
@@ -50,0 +49,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76369
1346
Updated@featherds/styles@^0.10.2