@charpente-ui/vue 2.1.2 → 2.2.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/README.md
CHANGED
|
@@ -248,6 +248,20 @@ messages for free. Charpente UI exposes that instead of reinventing it — opt i
|
|
|
248
248
|
- Without `validate`, nothing changes — bring your own validation library if you need cross-field or async rules.
|
|
249
249
|
Native escapes still work: `formnovalidate` on a submit button skips validation for that button.
|
|
250
250
|
|
|
251
|
+
`CField` stays zero-CSS: it never applies a class itself. If you need custom styling beyond `[aria-invalid]` or
|
|
252
|
+
`:invalid` selectors, its default slot exposes `invalid` and `message` so you can drive your own classes:
|
|
253
|
+
|
|
254
|
+
```vue
|
|
255
|
+
<CField v-slot="{ invalid, message }">
|
|
256
|
+
<CLabel>Email</CLabel>
|
|
257
|
+
<CInput v-model="email" type="email" required :class="{ 'is-invalid': invalid }"/>
|
|
258
|
+
<span v-if="invalid" class="error">{{ message }}</span>
|
|
259
|
+
</CField>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
This only reaches elements placed directly inside `CField`'s default slot — a custom component nested deeper won't
|
|
263
|
+
receive `invalid`/`message` automatically; pass them down as props if you need that.
|
|
264
|
+
|
|
251
265
|
## Components
|
|
252
266
|
|
|
253
267
|
| Name | Core Logic | Tag | Status |
|
|
@@ -28,13 +28,19 @@ var d = /*@__PURE__*/ r({
|
|
|
28
28
|
h.value = !0, m.value = e.target.validationMessage;
|
|
29
29
|
}
|
|
30
30
|
function S(e) {
|
|
31
|
-
|
|
31
|
+
if (h.value) {
|
|
32
|
+
let t = e.target;
|
|
33
|
+
h.value = !t.validity.valid, m.value = t.validationMessage;
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
return (e, t) => (a(), n("div", i(b.value, {
|
|
34
37
|
onInvalidCapture: x,
|
|
35
38
|
onInputCapture: S,
|
|
36
39
|
onChangeCapture: S
|
|
37
|
-
}), [c(e.$slots, "default"
|
|
40
|
+
}), [c(e.$slots, "default", {
|
|
41
|
+
invalid: h.value,
|
|
42
|
+
message: m.value
|
|
43
|
+
})], 16));
|
|
38
44
|
}
|
|
39
45
|
});
|
|
40
46
|
//#endregion
|