@charpente-ui/vue 2.2.1 → 2.3.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
@@ -249,7 +249,9 @@ messages for free. Charpente UI exposes that instead of reinventing it — opt i
249
249
  Native escapes still work: `formnovalidate` on a submit button skips validation for that button.
250
250
 
251
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:
252
+ `:invalid` selectors, it gives you two ways to read its `invalid`/`message` state:
253
+
254
+ - **Default slot** — reaches elements placed directly inside `CField`:
253
255
 
254
256
  ```vue
255
257
  <CField v-slot="{ invalid, message }">
@@ -259,8 +261,17 @@ messages for free. Charpente UI exposes that instead of reinventing it — opt i
259
261
  </CField>
260
262
  ```
261
263
 
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
+ - **Template ref** to style `CField`'s own wrapper element instead of a child:
265
+
266
+ ```vue
267
+ <CField ref="fieldRef" :class="{ 'is-invalid': fieldRef?.invalid }">
268
+ <CLabel>Email</CLabel>
269
+ <CInput v-model="email" type="email" required/>
270
+ </CField>
271
+ ```
272
+
273
+ Both only reach elements placed directly inside `CField`'s default slot, or the `CField` element itself — a custom
274
+ component nested deeper won't receive `invalid`/`message` automatically; pass them down as props if you need that.
264
275
 
265
276
  ## Components
266
277
 
@@ -10,7 +10,10 @@ declare function __VLS_template(): {
10
10
  rootEl: any;
11
11
  };
12
12
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
- declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
13
+ declare const __VLS_component: import('vue').DefineComponent<{}, {
14
+ invalid: import('vue').Ref<boolean, boolean>;
15
+ message: import('vue').Ref<string, string>;
16
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
14
17
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
15
18
  export default _default;
16
19
  type __VLS_WithTemplateSlots<T, S> = T & {
@@ -4,42 +4,45 @@ import { computed as t, createElementBlock as n, defineComponent as r, mergeProp
4
4
  var d = /*@__PURE__*/ r({
5
5
  inheritAttrs: !1,
6
6
  __name: "BaseField",
7
- setup(r) {
8
- let d = l(), f = u(), p = s([]), m = s(""), h = s(!1), g = t(() => typeof d.id == "string" ? d.id : f), _ = t(() => p.value.at(-1));
9
- function v(e) {
10
- p.value.push(e);
11
- }
7
+ setup(r, { expose: d }) {
8
+ let f = l(), p = u(), m = s([]), h = s(""), g = s(!1), _ = t(() => typeof f.id == "string" ? f.id : p), v = t(() => m.value.at(-1));
12
9
  function y(e) {
13
- let t = p.value.indexOf(e);
14
- t !== -1 && p.value.splice(t, 1);
10
+ m.value.push(e);
11
+ }
12
+ function b(e) {
13
+ let t = m.value.indexOf(e);
14
+ t !== -1 && m.value.splice(t, 1);
15
15
  }
16
- let b = t(() => {
17
- let e = { ...d };
16
+ let x = t(() => {
17
+ let e = { ...f };
18
18
  return delete e.id, e;
19
19
  });
20
20
  o(e, {
21
- id: g,
22
- supportingTextId: _,
23
- validationMessage: m,
24
- registerSupportingText: v,
25
- unregisterSupportingText: y
21
+ id: _,
22
+ supportingTextId: v,
23
+ validationMessage: h,
24
+ registerSupportingText: y,
25
+ unregisterSupportingText: b
26
26
  });
27
- function x(e) {
28
- h.value = !0, m.value = e.target.validationMessage;
29
- }
30
27
  function S(e) {
31
- if (h.value) {
28
+ g.value = !0, h.value = e.target.validationMessage;
29
+ }
30
+ function C(e) {
31
+ if (g.value) {
32
32
  let t = e.target;
33
- h.value = !t.validity.valid, m.value = t.validationMessage;
33
+ g.value = !t.validity.valid, h.value = t.validationMessage;
34
34
  }
35
35
  }
36
- return (e, t) => (a(), n("div", i(b.value, {
37
- onInvalidCapture: x,
38
- onInputCapture: S,
39
- onChangeCapture: S
36
+ return d({
37
+ invalid: g,
38
+ message: h
39
+ }), (e, t) => (a(), n("div", i(x.value, {
40
+ onInvalidCapture: S,
41
+ onInputCapture: C,
42
+ onChangeCapture: C
40
43
  }), [c(e.$slots, "default", {
41
- invalid: h.value,
42
- message: m.value
44
+ invalid: g.value,
45
+ message: h.value
43
46
  })], 16));
44
47
  }
45
48
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charpente-ui/vue",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "description": "Charpente UI is a headless Vue component library.",
5
5
  "type": "module",
6
6
  "scripts": {