@charpente-ui/vue 2.1.2 → 2.2.1

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 |
@@ -1,7 +1,10 @@
1
1
  declare function __VLS_template(): {
2
2
  attrs: Partial<{}>;
3
3
  slots: {
4
- default?(_: {}): any;
4
+ default?(_: {
5
+ invalid: boolean;
6
+ message: string;
7
+ }): any;
5
8
  };
6
9
  refs: {};
7
10
  rootEl: any;
@@ -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
- h.value && (m.value = e.target.validationMessage);
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")], 16));
40
+ }), [c(e.$slots, "default", {
41
+ invalid: h.value,
42
+ message: m.value
43
+ })], 16));
38
44
  }
39
45
  });
40
46
  //#endregion
@@ -1,5 +1,7 @@
1
+ type AriaInvalid = boolean | 'true' | 'false' | 'grammar' | 'spelling' | undefined;
1
2
  export declare function useFieldControl(): {
2
3
  controlId: import('vue').ComputedRef<string>;
3
4
  describedBy: import('vue').ComputedRef<string | undefined>;
4
- ariaInvalid: import('vue').ComputedRef<unknown>;
5
+ ariaInvalid: import('vue').ComputedRef<AriaInvalid>;
5
6
  };
7
+ export {};
package/dist/index.d.ts CHANGED
@@ -1 +1,13 @@
1
- export {}
1
+ export { default as CButton } from './components/BaseButton';
2
+ export { default as CCheckbox } from './components/BaseCheckbox';
3
+ export { default as CCheckboxGroup } from './components/BaseCheckboxGroup';
4
+ export { default as CField } from './components/BaseField';
5
+ export { default as CFile } from './components/BaseFile';
6
+ export { default as CForm } from './components/BaseForm';
7
+ export { default as CInput } from './components/BaseInput';
8
+ export { default as CLabel } from './components/BaseLabel';
9
+ export { default as CRadio } from './components/BaseRadio';
10
+ export { default as CRadioGroup } from './components/BaseRadioGroup';
11
+ export { default as CSelect } from './components/BaseSelect';
12
+ export { default as CSupportingText } from './components/BaseSupportingText';
13
+ export { default as CTextarea } from './components/BaseTextarea';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charpente-ui/vue",
3
- "version": "2.1.2",
3
+ "version": "2.2.1",
4
4
  "description": "Charpente UI is a headless Vue component library.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,13 +0,0 @@
1
- export { default as CButton } from './components/BaseButton';
2
- export { default as CCheckbox } from './components/BaseCheckbox';
3
- export { default as CCheckboxGroup } from './components/BaseCheckboxGroup';
4
- export { default as CField } from './components/BaseField';
5
- export { default as CFile } from './components/BaseFile';
6
- export { default as CForm } from './components/BaseForm';
7
- export { default as CInput } from './components/BaseInput';
8
- export { default as CLabel } from './components/BaseLabel';
9
- export { default as CRadio } from './components/BaseRadio';
10
- export { default as CRadioGroup } from './components/BaseRadioGroup';
11
- export { default as CSelect } from './components/BaseSelect';
12
- export { default as CSupportingText } from './components/BaseSupportingText';
13
- export { default as CTextarea } from './components/BaseTextarea';