@charpente-ui/vue 1.2.1 → 1.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
@@ -8,6 +8,10 @@
8
8
 
9
9
  A logic-first, headless UI library for Vue 3. The logic you need, without the CSS you don't.
10
10
 
11
+ <p align="center">
12
+ <img src=".github/banner.svg" alt="Charpente UI" width="700"/>
13
+ </p>
14
+
11
15
  ## Philosophy: Don't Reinvent the Wheel
12
16
 
13
17
  **Charpente UI** is built on a simple promise: We handle the boring stuff, you handle the design.
@@ -30,6 +34,18 @@ Styled Components)_.
30
34
  npm install @charpente-ui/vue
31
35
  ```
32
36
 
37
+ ## Playground
38
+
39
+ Try it live on StackBlitz — no installation required:
40
+
41
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/charpente-ui/vue)
42
+
43
+ Or run it locally:
44
+
45
+ ```shell
46
+ npm run dev
47
+ ```
48
+
33
49
  ## Usage
34
50
 
35
51
  ```vue
@@ -85,7 +101,39 @@ Managing checkbox arrays in Vue can be repetitive. **Charpente UI** simplifies t
85
101
  </CSelect>
86
102
  ```
87
103
 
88
- 3. **Polymorphic Elements** _(CButton)_
104
+ 3. **Group Components** _(CRadioGroup, CCheckboxGroup)_
105
+
106
+ Groups wrap related inputs in a semantic `<fieldset>`, sharing a `v-model` and a `name` attribute across all children
107
+ automatically.
108
+
109
+ ```vue
110
+ <CRadioGroup v-model="selected">
111
+ <CLabel for="opt-a">Option A</CLabel>
112
+ <CRadio id="opt-a" value="a"/>
113
+
114
+ <CLabel for="opt-b">Option B</CLabel>
115
+ <CRadio id="opt-b" value="b"/>
116
+ </CRadioGroup>
117
+ ```
118
+
119
+ ```vue
120
+ <CCheckboxGroup v-model="selected">
121
+ <CLabel for="cb-a">Option A</CLabel>
122
+ <CCheckbox id="cb-a" value="a"/>
123
+
124
+ <CLabel for="cb-b">Option B</CLabel>
125
+ <CCheckbox id="cb-b" value="b"/>
126
+ </CCheckboxGroup>
127
+ ```
128
+
129
+ The `name` attribute is auto-generated via `useId()` and shared across all children. Override it on the group or on
130
+ individual inputs:
131
+
132
+ ```vue
133
+ <CRadioGroup v-model="selected" name="my-group">...</CRadioGroup>
134
+ ```
135
+
136
+ 4. **Polymorphic Elements** _(CButton)_
89
137
 
90
138
  The button can change its HTML tag while keeping its behavior.
91
139
 
@@ -96,14 +144,16 @@ The button can change its HTML tag while keeping its behavior.
96
144
 
97
145
  ## Components
98
146
 
99
- | Name | Core Logic | Tag | Status |
100
- |----------|----------------------------------------------------------------------------------|-------------|--------|
101
- | Button | **Polymorphic:** Switches tags _(a, button, etc...)_ while keeping logic. | `CButton` | Ready |
102
- | Checkbox | **Smart Toggle:** Handles array state, booleans, and indeterminate natively. | `CCheckbox` | Ready |
103
- | File | **File Input:** Reactive file selection with `v-model` support. | `CFile` | Ready |
104
- | Form | **Auto-Submit:** Integrated `preventDefault` and event handling. | `CForm` | Ready |
105
- | Input | **Auto-ID:** Auto-links to labels via `useId()` and full attributes inheritance. | `CInput` | Ready |
106
- | Label | **Context-Aware:** Simple, accessible binding for any input. | `CLabel` | Ready |
107
- | Radio | **Selection:** Minimalist wrapper for native radio input. | `CRadio` | Ready |
108
- | Select | **Native Wrapper:** Single and multiple selection support. | `CSelect` | Ready |
109
- | Textarea | **Flexible Binding:** Auto-ID and reactive model management. | `CTextarea` | Ready |
147
+ | Name | Core Logic | Tag | Status |
148
+ |---------------|----------------------------------------------------------------------------------|------------------|--------|
149
+ | Button | **Polymorphic:** Switches tags _(a, button, etc...)_ while keeping logic. | `CButton` | Ready |
150
+ | Checkbox | **Smart Toggle:** Handles array state, booleans, and indeterminate natively. | `CCheckbox` | Ready |
151
+ | CheckboxGroup | **Group:** Shared v-model and name across checkboxes inside a fieldset. | `CCheckboxGroup` | Ready |
152
+ | File | **File Input:** Reactive file selection with `v-model` support. | `CFile` | Ready |
153
+ | Form | **Auto-Submit:** Integrated `preventDefault` and event handling. | `CForm` | Ready |
154
+ | Input | **Auto-ID:** Auto-links to labels via `useId()` and full attributes inheritance. | `CInput` | Ready |
155
+ | Label | **Context-Aware:** Simple, accessible binding for any input. | `CLabel` | Ready |
156
+ | Radio | **Selection:** Minimalist wrapper for native radio input. | `CRadio` | Ready |
157
+ | RadioGroup | **Group:** Shared v-model and name across radios inside a fieldset. | `CRadioGroup` | Ready |
158
+ | Select | **Native Wrapper:** Single and multiple selection support. | `CSelect` | Ready |
159
+ | Textarea | **Flexible Binding:** Auto-ID and reactive model management. | `CTextarea` | Ready |
package/dist/charpente.js CHANGED
@@ -1,22 +1,22 @@
1
- import { defineComponent as u, openBlock as d, createBlock as B, resolveDynamicComponent as M, normalizeProps as g, guardReactiveProps as b, withCtx as A, renderSlot as h, useModel as _, useAttrs as c, useId as p, useTemplateRef as V, computed as f, watchEffect as k, withDirectives as $, createElementBlock as i, mergeProps as m, vModelCheckbox as x, mergeModels as C, watch as y, withModifiers as R, vModelDynamic as w, vModelRadio as S, vModelSelect as U, vModelText as F } from "vue";
2
- const H = /* @__PURE__ */ u({
1
+ import { defineComponent as d, openBlock as i, createBlock as w, resolveDynamicComponent as U, normalizeProps as C, guardReactiveProps as y, withCtx as F, renderSlot as h, useModel as f, inject as B, useAttrs as c, useId as p, useTemplateRef as M, computed as u, watchEffect as N, withDirectives as $, createElementBlock as m, mergeProps as _, isRef as I, vModelCheckbox as T, unref as k, mergeModels as A, provide as x, watch as D, withModifiers as P, vModelDynamic as E, vModelRadio as K, vModelSelect as L, vModelText as j } from "vue";
2
+ const Z = /* @__PURE__ */ d({
3
3
  inheritAttrs: !1,
4
4
  __name: "BaseButton",
5
5
  props: {
6
6
  as: { default: "button" }
7
7
  },
8
- setup(t) {
9
- return (e, s) => (d(), B(M(t.as), g(b(e.$attrs)), {
10
- default: A(() => [
11
- h(e.$slots, "default")
8
+ setup(o) {
9
+ return (t, e) => (i(), w(U(o.as), C(y(t.$attrs)), {
10
+ default: F(() => [
11
+ h(t.$slots, "default")
12
12
  ]),
13
13
  _: 3
14
14
  }, 16));
15
15
  }
16
- }), T = ["id", "value"], J = /* @__PURE__ */ u({
16
+ }), R = /* @__PURE__ */ Symbol("CRadioGroup"), G = /* @__PURE__ */ Symbol("CCheckboxGroup"), z = ["id", "name", "value"], ee = /* @__PURE__ */ d({
17
17
  inheritAttrs: !1,
18
18
  __name: "BaseCheckbox",
19
- props: /* @__PURE__ */ C({
19
+ props: /* @__PURE__ */ A({
20
20
  value: {},
21
21
  indeterminate: { type: Boolean }
22
22
  }, {
@@ -24,22 +24,41 @@ const H = /* @__PURE__ */ u({
24
24
  modelModifiers: {}
25
25
  }),
26
26
  emits: ["update:modelValue"],
27
- setup(t) {
28
- const e = t, s = _(t, "modelValue"), l = c(), r = p(), n = V("input"), a = f(() => l.id || r);
29
- return k(() => {
30
- n.value && (n.value.indeterminate = !!e.indeterminate);
31
- }), (o, v) => $((d(), i("input", m({
27
+ setup(o) {
28
+ const t = o, e = f(o, "modelValue"), n = B(G, null), a = n ? n.model : e, s = c(), r = p(), l = M("input"), v = u(() => typeof s.id == "string" ? s.id : r), V = u(() => typeof s.name == "string" ? s.name : n?.name.value);
29
+ return N(() => {
30
+ l.value && (l.value.indeterminate = !!t.indeterminate);
31
+ }), (g, b) => $((i(), m("input", _(g.$attrs, {
32
+ id: v.value,
32
33
  ref: "input",
33
- type: "checkbox"
34
- }, o.$attrs, {
35
- "onUpdate:modelValue": v[0] || (v[0] = (I) => s.value = I),
36
- id: a.value,
37
- value: t.value
38
- }), null, 16, T)), [
39
- [x, s.value]
34
+ "onUpdate:modelValue": b[0] || (b[0] = (S) => I(a) ? a.value = S : null),
35
+ name: V.value,
36
+ type: "checkbox",
37
+ value: o.value
38
+ }), null, 16, z)), [
39
+ [T, k(a)]
40
40
  ]);
41
41
  }
42
- }), D = ["id"], K = /* @__PURE__ */ u({
42
+ }), te = /* @__PURE__ */ d({
43
+ inheritAttrs: !1,
44
+ __name: "BaseCheckboxGroup",
45
+ props: {
46
+ modelValue: {
47
+ default: () => []
48
+ },
49
+ modelModifiers: {}
50
+ },
51
+ emits: ["update:modelValue"],
52
+ setup(o) {
53
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.name == "string" ? e.name : n);
54
+ return x(G, {
55
+ model: t,
56
+ name: a
57
+ }), (s, r) => (i(), m("fieldset", C(y(s.$attrs)), [
58
+ h(s.$slots, "default")
59
+ ], 16));
60
+ }
61
+ }), q = ["id"], oe = /* @__PURE__ */ d({
43
62
  inheritAttrs: !1,
44
63
  __name: "BaseFile",
45
64
  props: {
@@ -47,35 +66,35 @@ const H = /* @__PURE__ */ u({
47
66
  modelModifiers: {}
48
67
  },
49
68
  emits: ["update:modelValue"],
50
- setup(t) {
51
- const e = _(t, "modelValue"), s = c(), l = p(), r = V("input"), n = f(() => s.id || l);
52
- function a(o) {
53
- e.value = o.target.files;
69
+ setup(o) {
70
+ const t = f(o, "modelValue"), e = c(), n = p(), a = M("input"), s = u(() => typeof e.id == "string" ? e.id : n);
71
+ function r(l) {
72
+ t.value = l.target.files;
54
73
  }
55
- return y(e, (o) => {
56
- !o && r.value && (r.value.value = "");
57
- }), (o, v) => (d(), i("input", m({
74
+ return D(t, (l) => {
75
+ !l && a.value && (a.value.value = "");
76
+ }), (l, v) => (i(), m("input", _({
58
77
  type: "file",
59
78
  ref: "input"
60
- }, o.$attrs, {
61
- id: n.value,
62
- onChange: a
63
- }), null, 16, D));
79
+ }, l.$attrs, {
80
+ id: s.value,
81
+ onChange: r
82
+ }), null, 16, q));
64
83
  }
65
- }), P = ["id"], N = /* @__PURE__ */ u({
84
+ }), H = ["id"], ae = /* @__PURE__ */ d({
66
85
  inheritAttrs: !1,
67
86
  __name: "BaseForm",
68
87
  emits: ["submit"],
69
- setup(t, { emit: e }) {
70
- const s = c(), l = p(), r = e, n = f(() => s.id || l);
71
- return (a, o) => (d(), i("form", m(a.$attrs, {
72
- id: n.value,
73
- onSubmit: o[0] || (o[0] = R((v) => r("submit", v), ["prevent"]))
88
+ setup(o, { emit: t }) {
89
+ const e = c(), n = p(), a = t, s = u(() => typeof e.id == "string" ? e.id : n);
90
+ return (r, l) => (i(), m("form", _(r.$attrs, {
91
+ id: s.value,
92
+ onSubmit: l[0] || (l[0] = P((v) => a("submit", v), ["prevent"]))
74
93
  }), [
75
- h(a.$slots, "default")
76
- ], 16, P));
94
+ h(r.$slots, "default")
95
+ ], 16, H));
77
96
  }
78
- }), E = ["id"], O = /* @__PURE__ */ u({
97
+ }), J = ["id"], se = /* @__PURE__ */ d({
79
98
  inheritAttrs: !1,
80
99
  __name: "BaseInput",
81
100
  props: {
@@ -83,50 +102,68 @@ const H = /* @__PURE__ */ u({
83
102
  modelModifiers: {}
84
103
  },
85
104
  emits: ["update:modelValue"],
86
- setup(t) {
87
- const e = _(t, "modelValue"), s = c(), l = p(), r = f(() => s.id || l);
88
- return (n, a) => $((d(), i("input", m(n.$attrs, {
89
- "onUpdate:modelValue": a[0] || (a[0] = (o) => e.value = o),
90
- id: r.value
91
- }), null, 16, E)), [
92
- [w, e.value]
105
+ setup(o) {
106
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.id == "string" ? e.id : n);
107
+ return (s, r) => $((i(), m("input", _(s.$attrs, {
108
+ "onUpdate:modelValue": r[0] || (r[0] = (l) => t.value = l),
109
+ id: a.value
110
+ }), null, 16, J)), [
111
+ [E, t.value]
93
112
  ]);
94
113
  }
95
- }), L = ["for"], Q = /* @__PURE__ */ u({
114
+ }), O = ["for"], ne = /* @__PURE__ */ d({
96
115
  inheritAttrs: !1,
97
116
  __name: "BaseLabel",
98
117
  props: {
99
118
  for: {}
100
119
  },
101
- setup(t) {
102
- const e = t;
103
- return (s, l) => (d(), i("label", m(s.$attrs, {
104
- for: e.for
120
+ setup(o) {
121
+ const t = o;
122
+ return (e, n) => (i(), m("label", _(e.$attrs, {
123
+ for: t.for
105
124
  }), [
106
- h(s.$slots, "default")
107
- ], 16, L));
125
+ h(e.$slots, "default")
126
+ ], 16, O));
108
127
  }
109
- }), z = ["id", "value"], W = /* @__PURE__ */ u({
128
+ }), Q = ["id", "name", "value"], re = /* @__PURE__ */ d({
110
129
  inheritAttrs: !1,
111
130
  __name: "BaseRadio",
112
- props: /* @__PURE__ */ C({
131
+ props: /* @__PURE__ */ A({
113
132
  value: {}
114
133
  }, {
115
134
  modelValue: {},
116
135
  modelModifiers: {}
117
136
  }),
118
137
  emits: ["update:modelValue"],
119
- setup(t) {
120
- const e = _(t, "modelValue"), s = c(), l = p(), r = f(() => s.id || l);
121
- return (n, a) => $((d(), i("input", m({ type: "radio" }, n.$attrs, {
122
- "onUpdate:modelValue": a[0] || (a[0] = (o) => e.value = o),
138
+ setup(o) {
139
+ const t = f(o, "modelValue"), e = B(R, null), n = e ? e.model : t, a = c(), s = p(), r = u(() => typeof a.id == "string" ? a.id : s), l = u(() => typeof a.name == "string" ? a.name : e?.name.value);
140
+ return (v, V) => $((i(), m("input", _({
123
141
  id: r.value,
124
- value: t.value
125
- }), null, 16, z)), [
126
- [S, e.value]
142
+ "onUpdate:modelValue": V[0] || (V[0] = (g) => I(n) ? n.value = g : null),
143
+ name: l.value,
144
+ value: o.value
145
+ }, v.$attrs, { type: "radio" }), null, 16, Q)), [
146
+ [K, k(n)]
127
147
  ]);
128
148
  }
129
- }), j = ["id"], X = /* @__PURE__ */ u({
149
+ }), le = /* @__PURE__ */ d({
150
+ inheritAttrs: !1,
151
+ __name: "BaseRadioGroup",
152
+ props: {
153
+ modelValue: {},
154
+ modelModifiers: {}
155
+ },
156
+ emits: ["update:modelValue"],
157
+ setup(o) {
158
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.name == "string" ? e.name : n);
159
+ return x(R, {
160
+ model: t,
161
+ name: a
162
+ }), (s, r) => (i(), m("fieldset", C(y(s.$attrs)), [
163
+ h(s.$slots, "default")
164
+ ], 16));
165
+ }
166
+ }), W = ["id"], ue = /* @__PURE__ */ d({
130
167
  inheritAttrs: !1,
131
168
  __name: "BaseSelect",
132
169
  props: {
@@ -134,18 +171,18 @@ const H = /* @__PURE__ */ u({
134
171
  modelModifiers: {}
135
172
  },
136
173
  emits: ["update:modelValue"],
137
- setup(t) {
138
- const e = _(t, "modelValue"), s = c(), l = p(), r = f(() => s.id || l);
139
- return (n, a) => $((d(), i("select", m(n.$attrs, {
140
- "onUpdate:modelValue": a[0] || (a[0] = (o) => e.value = o),
141
- id: r.value
174
+ setup(o) {
175
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.id == "string" ? e.id : n);
176
+ return (s, r) => $((i(), m("select", _(s.$attrs, {
177
+ "onUpdate:modelValue": r[0] || (r[0] = (l) => t.value = l),
178
+ id: a.value
142
179
  }), [
143
- h(n.$slots, "default")
144
- ], 16, j)), [
145
- [U, e.value]
180
+ h(s.$slots, "default")
181
+ ], 16, W)), [
182
+ [L, t.value]
146
183
  ]);
147
184
  }
148
- }), q = ["id"], Y = /* @__PURE__ */ u({
185
+ }), X = ["id"], de = /* @__PURE__ */ d({
149
186
  inheritAttrs: !1,
150
187
  __name: "BaseTextarea",
151
188
  props: {
@@ -153,24 +190,26 @@ const H = /* @__PURE__ */ u({
153
190
  modelModifiers: {}
154
191
  },
155
192
  emits: ["update:modelValue"],
156
- setup(t) {
157
- const e = _(t, "modelValue"), s = c(), l = p(), r = f(() => s.id || l);
158
- return (n, a) => $((d(), i("textarea", m(n.$attrs, {
159
- "onUpdate:modelValue": a[0] || (a[0] = (o) => e.value = o),
160
- id: r.value
161
- }), null, 16, q)), [
162
- [F, e.value]
193
+ setup(o) {
194
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.id == "string" ? e.id : n);
195
+ return (s, r) => $((i(), m("textarea", _(s.$attrs, {
196
+ "onUpdate:modelValue": r[0] || (r[0] = (l) => t.value = l),
197
+ id: a.value
198
+ }), null, 16, X)), [
199
+ [j, t.value]
163
200
  ]);
164
201
  }
165
202
  });
166
203
  export {
167
- H as CButton,
168
- J as CCheckbox,
169
- K as CFile,
170
- N as CForm,
171
- O as CInput,
172
- Q as CLabel,
173
- W as CRadio,
174
- X as CSelect,
175
- Y as CTextarea
204
+ Z as CButton,
205
+ ee as CCheckbox,
206
+ te as CCheckboxGroup,
207
+ oe as CFile,
208
+ ae as CForm,
209
+ se as CInput,
210
+ ne as CLabel,
211
+ re as CRadio,
212
+ le as CRadioGroup,
213
+ ue as CSelect,
214
+ de as CTextarea
176
215
  };
@@ -1 +1 @@
1
- (function(r,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(r=typeof globalThis<"u"?globalThis:r||self,e(r.Charpente={},r.Vue))})(this,(function(r,e){"use strict";const c=e.defineComponent({inheritAttrs:!1,__name:"BaseButton",props:{as:{default:"button"}},setup(o){return(t,n)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.as),e.normalizeProps(e.guardReactiveProps(t.$attrs)),{default:e.withCtx(()=>[e.renderSlot(t.$slots,"default")]),_:3},16))}}),p=["id","value"],u=e.defineComponent({inheritAttrs:!1,__name:"BaseCheckbox",props:e.mergeModels({value:{},indeterminate:{type:Boolean}},{modelValue:{type:[Boolean,Array]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),d=e.useAttrs(),i=e.useId(),a=e.useTemplateRef("input"),s=e.computed(()=>d.id||i);return e.watchEffect(()=>{a.value&&(a.value.indeterminate=!!t.indeterminate)}),(l,m)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({ref:"input",type:"checkbox"},l.$attrs,{"onUpdate:modelValue":m[0]||(m[0]=P=>n.value=P),id:s.value,value:o.value}),null,16,p)),[[e.vModelCheckbox,n.value]])}}),f=["id"],_=e.defineComponent({inheritAttrs:!1,__name:"BaseFile",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(o){const t=e.useModel(o,"modelValue"),n=e.useAttrs(),d=e.useId(),i=e.useTemplateRef("input"),a=e.computed(()=>n.id||d);function s(l){t.value=l.target.files}return e.watch(t,l=>{!l&&i.value&&(i.value.value="")}),(l,m)=>(e.openBlock(),e.createElementBlock("input",e.mergeProps({type:"file",ref:"input"},l.$attrs,{id:a.value,onChange:s}),null,16,f))}}),h=["id"],B=e.defineComponent({inheritAttrs:!1,__name:"BaseForm",emits:["submit"],setup(o,{emit:t}){const n=e.useAttrs(),d=e.useId(),i=t,a=e.computed(()=>n.id||d);return(s,l)=>(e.openBlock(),e.createElementBlock("form",e.mergeProps(s.$attrs,{id:a.value,onSubmit:l[0]||(l[0]=e.withModifiers(m=>i("submit",m),["prevent"]))}),[e.renderSlot(s.$slots,"default")],16,h))}}),$=["id"],C=e.defineComponent({inheritAttrs:!1,__name:"BaseInput",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(o){const t=e.useModel(o,"modelValue"),n=e.useAttrs(),d=e.useId(),i=e.computed(()=>n.id||d);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps(a.$attrs,{"onUpdate:modelValue":s[0]||(s[0]=l=>t.value=l),id:i.value}),null,16,$)),[[e.vModelDynamic,t.value]])}}),V=["for"],k=e.defineComponent({inheritAttrs:!1,__name:"BaseLabel",props:{for:{}},setup(o){const t=o;return(n,d)=>(e.openBlock(),e.createElementBlock("label",e.mergeProps(n.$attrs,{for:t.for}),[e.renderSlot(n.$slots,"default")],16,V))}}),I=["id","value"],g=e.defineComponent({inheritAttrs:!1,__name:"BaseRadio",props:e.mergeModels({value:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.useModel(o,"modelValue"),n=e.useAttrs(),d=e.useId(),i=e.computed(()=>n.id||d);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({type:"radio"},a.$attrs,{"onUpdate:modelValue":s[0]||(s[0]=l=>t.value=l),id:i.value,value:o.value}),null,16,I)),[[e.vModelRadio,t.value]])}}),M=["id"],A=e.defineComponent({inheritAttrs:!1,__name:"BaseSelect",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(o){const t=e.useModel(o,"modelValue"),n=e.useAttrs(),d=e.useId(),i=e.computed(()=>n.id||d);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("select",e.mergeProps(a.$attrs,{"onUpdate:modelValue":s[0]||(s[0]=l=>t.value=l),id:i.value}),[e.renderSlot(a.$slots,"default")],16,M)),[[e.vModelSelect,t.value]])}}),b=["id"],y=e.defineComponent({inheritAttrs:!1,__name:"BaseTextarea",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(o){const t=e.useModel(o,"modelValue"),n=e.useAttrs(),d=e.useId(),i=e.computed(()=>n.id||d);return(a,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",e.mergeProps(a.$attrs,{"onUpdate:modelValue":s[0]||(s[0]=l=>t.value=l),id:i.value}),null,16,b)),[[e.vModelText,t.value]])}});r.CButton=c,r.CCheckbox=u,r.CFile=_,r.CForm=B,r.CInput=C,r.CLabel=k,r.CRadio=g,r.CSelect=A,r.CTextarea=y,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(i,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i.Charpente={},i.Vue))})(this,(function(i,e){"use strict";const h=e.defineComponent({inheritAttrs:!1,__name:"BaseButton",props:{as:{default:"button"}},setup(n){return(o,t)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.as),e.normalizeProps(e.guardReactiveProps(o.$attrs)),{default:e.withCtx(()=>[e.renderSlot(o.$slots,"default")]),_:3},16))}}),u=Symbol("CRadioGroup"),f=Symbol("CCheckboxGroup"),g=["id","name","value"],B=e.defineComponent({inheritAttrs:!1,__name:"BaseCheckbox",props:e.mergeModels({value:{},indeterminate:{type:Boolean}},{modelValue:{type:[Boolean,Array]},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const o=n,t=e.useModel(n,"modelValue"),l=e.inject(f,null),s=l?l.model:t,r=e.useAttrs(),a=e.useId(),d=e.useTemplateRef("input"),m=e.computed(()=>typeof r.id=="string"?r.id:a),c=e.computed(()=>typeof r.name=="string"?r.name:l?.name.value);return e.watchEffect(()=>{d.value&&(d.value.indeterminate=!!o.indeterminate)}),(p,_)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps(p.$attrs,{id:m.value,ref:"input","onUpdate:modelValue":_[0]||(_[0]=D=>e.isRef(s)?s.value=D:null),name:c.value,type:"checkbox",value:n.value}),null,16,g)),[[e.vModelCheckbox,e.unref(s)]])}}),C=e.defineComponent({inheritAttrs:!1,__name:"BaseCheckboxGroup",props:{modelValue:{default:()=>[]},modelModifiers:{}},emits:["update:modelValue"],setup(n){const o=e.useModel(n,"modelValue"),t=e.useAttrs(),l=e.useId(),s=e.computed(()=>typeof t.name=="string"?t.name:l);return e.provide(f,{model:o,name:s}),(r,a)=>(e.openBlock(),e.createElementBlock("fieldset",e.normalizeProps(e.guardReactiveProps(r.$attrs)),[e.renderSlot(r.$slots,"default")],16))}}),$=["id"],k=e.defineComponent({inheritAttrs:!1,__name:"BaseFile",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const o=e.useModel(n,"modelValue"),t=e.useAttrs(),l=e.useId(),s=e.useTemplateRef("input"),r=e.computed(()=>typeof t.id=="string"?t.id:l);function a(d){o.value=d.target.files}return e.watch(o,d=>{!d&&s.value&&(s.value.value="")}),(d,m)=>(e.openBlock(),e.createElementBlock("input",e.mergeProps({type:"file",ref:"input"},d.$attrs,{id:r.value,onChange:a}),null,16,$))}}),V=["id"],y=e.defineComponent({inheritAttrs:!1,__name:"BaseForm",emits:["submit"],setup(n,{emit:o}){const t=e.useAttrs(),l=e.useId(),s=o,r=e.computed(()=>typeof t.id=="string"?t.id:l);return(a,d)=>(e.openBlock(),e.createElementBlock("form",e.mergeProps(a.$attrs,{id:r.value,onSubmit:d[0]||(d[0]=e.withModifiers(m=>s("submit",m),["prevent"]))}),[e.renderSlot(a.$slots,"default")],16,V))}}),M=["id"],I=e.defineComponent({inheritAttrs:!1,__name:"BaseInput",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const o=e.useModel(n,"modelValue"),t=e.useAttrs(),l=e.useId(),s=e.computed(()=>typeof t.id=="string"?t.id:l);return(r,a)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps(r.$attrs,{"onUpdate:modelValue":a[0]||(a[0]=d=>o.value=d),id:s.value}),null,16,M)),[[e.vModelDynamic,o.value]])}}),b=["for"],A=e.defineComponent({inheritAttrs:!1,__name:"BaseLabel",props:{for:{}},setup(n){const o=n;return(t,l)=>(e.openBlock(),e.createElementBlock("label",e.mergeProps(t.$attrs,{for:o.for}),[e.renderSlot(t.$slots,"default")],16,b))}}),P=["id","name","value"],R=e.defineComponent({inheritAttrs:!1,__name:"BaseRadio",props:e.mergeModels({value:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const o=e.useModel(n,"modelValue"),t=e.inject(u,null),l=t?t.model:o,s=e.useAttrs(),r=e.useId(),a=e.computed(()=>typeof s.id=="string"?s.id:r),d=e.computed(()=>typeof s.name=="string"?s.name:t?.name.value);return(m,c)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({id:a.value,"onUpdate:modelValue":c[0]||(c[0]=p=>e.isRef(l)?l.value=p:null),name:d.value,value:n.value},m.$attrs,{type:"radio"}),null,16,P)),[[e.vModelRadio,e.unref(l)]])}}),S=e.defineComponent({inheritAttrs:!1,__name:"BaseRadioGroup",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const o=e.useModel(n,"modelValue"),t=e.useAttrs(),l=e.useId(),s=e.computed(()=>typeof t.name=="string"?t.name:l);return e.provide(u,{model:o,name:s}),(r,a)=>(e.openBlock(),e.createElementBlock("fieldset",e.normalizeProps(e.guardReactiveProps(r.$attrs)),[e.renderSlot(r.$slots,"default")],16))}}),E=["id"],w=e.defineComponent({inheritAttrs:!1,__name:"BaseSelect",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const o=e.useModel(n,"modelValue"),t=e.useAttrs(),l=e.useId(),s=e.computed(()=>typeof t.id=="string"?t.id:l);return(r,a)=>e.withDirectives((e.openBlock(),e.createElementBlock("select",e.mergeProps(r.$attrs,{"onUpdate:modelValue":a[0]||(a[0]=d=>o.value=d),id:s.value}),[e.renderSlot(r.$slots,"default")],16,E)),[[e.vModelSelect,o.value]])}}),G=["id"],T=e.defineComponent({inheritAttrs:!1,__name:"BaseTextarea",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const o=e.useModel(n,"modelValue"),t=e.useAttrs(),l=e.useId(),s=e.computed(()=>typeof t.id=="string"?t.id:l);return(r,a)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",e.mergeProps(r.$attrs,{"onUpdate:modelValue":a[0]||(a[0]=d=>o.value=d),id:s.value}),null,16,G)),[[e.vModelText,o.value]])}});i.CButton=h,i.CCheckbox=B,i.CCheckboxGroup=C,i.CFile=k,i.CForm=y,i.CInput=I,i.CLabel=A,i.CRadio=R,i.CRadioGroup=S,i.CSelect=w,i.CTextarea=T,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,24 @@
1
+ type __VLS_PublicProps = {
2
+ modelValue?: (string | number)[];
3
+ };
4
+ declare function __VLS_template(): {
5
+ attrs: Partial<{}>;
6
+ slots: {
7
+ default?(_: {}): any;
8
+ };
9
+ refs: {};
10
+ rootEl: any;
11
+ };
12
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
+ "update:modelValue": (value: (string | number)[]) => any;
15
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
+ "onUpdate:modelValue"?: ((value: (string | number)[]) => any) | undefined;
17
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
19
+ export default _default;
20
+ type __VLS_WithTemplateSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };
@@ -8,9 +8,9 @@ declare function __VLS_template(): {
8
8
  };
9
9
  type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
10
10
  declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
11
- submit: (event: Event) => any;
11
+ submit: (event: SubmitEvent) => any;
12
12
  }, string, import('vue').PublicProps, Readonly<{}> & Readonly<{
13
- onSubmit?: ((event: Event) => any) | undefined;
13
+ onSubmit?: ((event: SubmitEvent) => any) | undefined;
14
14
  }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
15
15
  declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
16
16
  export default _default;
@@ -0,0 +1,24 @@
1
+ type __VLS_PublicProps = {
2
+ modelValue?: string | number;
3
+ };
4
+ declare function __VLS_template(): {
5
+ attrs: Partial<{}>;
6
+ slots: {
7
+ default?(_: {}): any;
8
+ };
9
+ refs: {};
10
+ rootEl: any;
11
+ };
12
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
13
+ declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
14
+ "update:modelValue": (value: string | number) => any;
15
+ }, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
16
+ "onUpdate:modelValue"?: ((value: string | number) => any) | undefined;
17
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
19
+ export default _default;
20
+ type __VLS_WithTemplateSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { InjectionKey, ModelRef, ComputedRef } from 'vue';
2
+ export interface RadioGroupContext {
3
+ model: ModelRef<string | number | undefined>;
4
+ name: ComputedRef<string>;
5
+ }
6
+ export declare const radioGroupKey: InjectionKey<RadioGroupContext>;
7
+ export interface CheckboxGroupContext {
8
+ model: ModelRef<(string | number)[]>;
9
+ name: ComputedRef<string>;
10
+ }
11
+ export declare const checkboxGroupKey: InjectionKey<CheckboxGroupContext>;
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export { default as CButton } from './components/BaseButton';
2
2
  export { default as CCheckbox } from './components/BaseCheckbox';
3
+ export { default as CCheckboxGroup } from './components/BaseCheckboxGroup';
3
4
  export { default as CFile } from './components/BaseFile';
4
5
  export { default as CForm } from './components/BaseForm';
5
6
  export { default as CInput } from './components/BaseInput';
6
7
  export { default as CLabel } from './components/BaseLabel';
7
8
  export { default as CRadio } from './components/BaseRadio';
9
+ export { default as CRadioGroup } from './components/BaseRadioGroup';
8
10
  export { default as CSelect } from './components/BaseSelect';
9
11
  export { default as CTextarea } from './components/BaseTextarea';
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@charpente-ui/vue",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "Charpente UI is a headless CSS Vue component library.",
5
5
  "type": "module",
6
6
  "scripts": {
7
+ "dev": "vite --config playground/vite.config.ts",
7
8
  "lint:js": "eslint --fix .",
8
9
  "lint": "npm-run-all --parallel lint:*",
9
10
  "build": "vite build",
@@ -48,6 +49,9 @@
48
49
  "vitest": "^4.0.18",
49
50
  "vue": "^3.5.29"
50
51
  },
52
+ "peerDependencies": {
53
+ "vue": "^3.0.0"
54
+ },
51
55
  "keywords": [
52
56
  "vue",
53
57
  "components",