@charpente-ui/vue 1.2.2 → 1.3.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
@@ -34,6 +34,18 @@ Styled Components)_.
34
34
  npm install @charpente-ui/vue
35
35
  ```
36
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.com/charpente-ui/vue)
42
+
43
+ Or run it locally:
44
+
45
+ ```shell
46
+ npm run dev
47
+ ```
48
+
37
49
  ## Usage
38
50
 
39
51
  ```vue
@@ -89,7 +101,39 @@ Managing checkbox arrays in Vue can be repetitive. **Charpente UI** simplifies t
89
101
  </CSelect>
90
102
  ```
91
103
 
92
- 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)_
93
137
 
94
138
  The button can change its HTML tag while keeping its behavior.
95
139
 
@@ -100,14 +144,16 @@ The button can change its HTML tag while keeping its behavior.
100
144
 
101
145
  ## Components
102
146
 
103
- | Name | Core Logic | Tag | Status |
104
- |----------|----------------------------------------------------------------------------------|-------------|--------|
105
- | Button | **Polymorphic:** Switches tags _(a, button, etc...)_ while keeping logic. | `CButton` | Ready |
106
- | Checkbox | **Smart Toggle:** Handles array state, booleans, and indeterminate natively. | `CCheckbox` | Ready |
107
- | File | **File Input:** Reactive file selection with `v-model` support. | `CFile` | Ready |
108
- | Form | **Auto-Submit:** Integrated `preventDefault` and event handling. | `CForm` | Ready |
109
- | Input | **Auto-ID:** Auto-links to labels via `useId()` and full attributes inheritance. | `CInput` | Ready |
110
- | Label | **Context-Aware:** Simple, accessible binding for any input. | `CLabel` | Ready |
111
- | Radio | **Selection:** Minimalist wrapper for native radio input. | `CRadio` | Ready |
112
- | Select | **Native Wrapper:** Single and multiple selection support. | `CSelect` | Ready |
113
- | 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 i, openBlock as d, createBlock as B, resolveDynamicComponent as y, normalizeProps as M, guardReactiveProps as b, withCtx as A, renderSlot as h, useModel as _, useAttrs as c, useId as p, useTemplateRef as V, computed as f, watch as g, withDirectives as $, createElementBlock as u, mergeProps as m, vModelCheckbox as k, mergeModels as C, withModifiers as x, vModelDynamic as R, vModelRadio as S, vModelSelect as U, vModelText as w } from "vue";
2
- const G = /* @__PURE__ */ i({
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(s) {
9
- return (e, t) => (d(), B(y(s.as), M(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
- }), F = ["id", "value"], H = /* @__PURE__ */ i({
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 G = /* @__PURE__ */ i({
24
24
  modelModifiers: {}
25
25
  }),
26
26
  emits: ["update:modelValue"],
27
- setup(s) {
28
- const e = s, t = _(s, "modelValue"), r = c(), l = p(), n = V("input"), o = f(() => typeof r.id == "string" ? r.id : l);
29
- return g([n, () => e.indeterminate], () => {
30
- n.value && (n.value.indeterminate = !!e.indeterminate);
31
- }, { immediate: !0 }), (a, v) => $((d(), u("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
- }, a.$attrs, {
35
- "onUpdate:modelValue": v[0] || (v[0] = (I) => t.value = I),
36
- id: o.value,
37
- value: s.value
38
- }), null, 16, F)), [
39
- [k, t.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
- }), T = ["id"], J = /* @__PURE__ */ i({
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,34 @@ const G = /* @__PURE__ */ i({
47
66
  modelModifiers: {}
48
67
  },
49
68
  emits: ["update:modelValue"],
50
- setup(s) {
51
- const e = _(s, "modelValue"), t = c(), r = p(), l = V("input"), n = f(() => typeof t.id == "string" ? t.id : r);
52
- function o(a) {
53
- e.value = a.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 g(e, (a) => {
56
- !a && l.value && (l.value.value = "");
57
- }), (a, v) => (d(), u("input", m({
74
+ return D(t, (l) => {
75
+ !l && a.value && (a.value.value = "");
76
+ }), (l, v) => (i(), m("input", _(l.$attrs, {
77
+ id: s.value,
78
+ ref: "input",
58
79
  type: "file",
59
- ref: "input"
60
- }, a.$attrs, {
61
- id: n.value,
62
- onChange: o
63
- }), null, 16, T));
80
+ onChange: r
81
+ }), null, 16, q));
64
82
  }
65
- }), D = ["id"], K = /* @__PURE__ */ i({
83
+ }), H = ["id"], ae = /* @__PURE__ */ d({
66
84
  inheritAttrs: !1,
67
85
  __name: "BaseForm",
68
86
  emits: ["submit"],
69
- setup(s, { emit: e }) {
70
- const t = c(), r = p(), l = e, n = f(() => typeof t.id == "string" ? t.id : r);
71
- return (o, a) => (d(), u("form", m(o.$attrs, {
72
- id: n.value,
73
- onSubmit: a[0] || (a[0] = x((v) => l("submit", v), ["prevent"]))
87
+ setup(o, { emit: t }) {
88
+ const e = c(), n = p(), a = t, s = u(() => typeof e.id == "string" ? e.id : n);
89
+ return (r, l) => (i(), m("form", _(r.$attrs, {
90
+ id: s.value,
91
+ onSubmit: l[0] || (l[0] = P((v) => a("submit", v), ["prevent"]))
74
92
  }), [
75
- h(o.$slots, "default")
76
- ], 16, D));
93
+ h(r.$slots, "default")
94
+ ], 16, H));
77
95
  }
78
- }), P = ["id"], N = /* @__PURE__ */ i({
96
+ }), J = ["id"], se = /* @__PURE__ */ d({
79
97
  inheritAttrs: !1,
80
98
  __name: "BaseInput",
81
99
  props: {
@@ -83,50 +101,68 @@ const G = /* @__PURE__ */ i({
83
101
  modelModifiers: {}
84
102
  },
85
103
  emits: ["update:modelValue"],
86
- setup(s) {
87
- const e = _(s, "modelValue"), t = c(), r = p(), l = f(() => typeof t.id == "string" ? t.id : r);
88
- return (n, o) => $((d(), u("input", m(n.$attrs, {
89
- "onUpdate:modelValue": o[0] || (o[0] = (a) => e.value = a),
90
- id: l.value
91
- }), null, 16, P)), [
92
- [R, e.value]
104
+ setup(o) {
105
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.id == "string" ? e.id : n);
106
+ return (s, r) => $((i(), m("input", _(s.$attrs, {
107
+ id: a.value,
108
+ "onUpdate:modelValue": r[0] || (r[0] = (l) => t.value = l)
109
+ }), null, 16, J)), [
110
+ [E, t.value]
93
111
  ]);
94
112
  }
95
- }), L = ["for"], O = /* @__PURE__ */ i({
113
+ }), O = ["for"], ne = /* @__PURE__ */ d({
96
114
  inheritAttrs: !1,
97
115
  __name: "BaseLabel",
98
116
  props: {
99
117
  for: {}
100
118
  },
101
- setup(s) {
102
- const e = s;
103
- return (t, r) => (d(), u("label", m(t.$attrs, {
104
- for: e.for
119
+ setup(o) {
120
+ const t = o;
121
+ return (e, n) => (i(), m("label", _(e.$attrs, {
122
+ for: t.for
105
123
  }), [
106
- h(t.$slots, "default")
107
- ], 16, L));
124
+ h(e.$slots, "default")
125
+ ], 16, O));
108
126
  }
109
- }), z = ["id", "value"], Q = /* @__PURE__ */ i({
127
+ }), Q = ["id", "name", "value"], re = /* @__PURE__ */ d({
110
128
  inheritAttrs: !1,
111
129
  __name: "BaseRadio",
112
- props: /* @__PURE__ */ C({
130
+ props: /* @__PURE__ */ A({
113
131
  value: {}
114
132
  }, {
115
133
  modelValue: {},
116
134
  modelModifiers: {}
117
135
  }),
118
136
  emits: ["update:modelValue"],
119
- setup(s) {
120
- const e = _(s, "modelValue"), t = c(), r = p(), l = f(() => typeof t.id == "string" ? t.id : r);
121
- return (n, o) => $((d(), u("input", m({ type: "radio" }, n.$attrs, {
122
- "onUpdate:modelValue": o[0] || (o[0] = (a) => e.value = a),
123
- id: l.value,
124
- value: s.value
125
- }), null, 16, z)), [
126
- [S, e.value]
137
+ setup(o) {
138
+ 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);
139
+ return (v, V) => $((i(), m("input", _({
140
+ id: r.value,
141
+ "onUpdate:modelValue": V[0] || (V[0] = (g) => I(n) ? n.value = g : null),
142
+ name: l.value,
143
+ value: o.value
144
+ }, v.$attrs, { type: "radio" }), null, 16, Q)), [
145
+ [K, k(n)]
127
146
  ]);
128
147
  }
129
- }), E = ["id"], W = /* @__PURE__ */ i({
148
+ }), le = /* @__PURE__ */ d({
149
+ inheritAttrs: !1,
150
+ __name: "BaseRadioGroup",
151
+ props: {
152
+ modelValue: {},
153
+ modelModifiers: {}
154
+ },
155
+ emits: ["update:modelValue"],
156
+ setup(o) {
157
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.name == "string" ? e.name : n);
158
+ return x(R, {
159
+ model: t,
160
+ name: a
161
+ }), (s, r) => (i(), m("fieldset", C(y(s.$attrs)), [
162
+ h(s.$slots, "default")
163
+ ], 16));
164
+ }
165
+ }), W = ["id"], ue = /* @__PURE__ */ d({
130
166
  inheritAttrs: !1,
131
167
  __name: "BaseSelect",
132
168
  props: {
@@ -134,18 +170,18 @@ const G = /* @__PURE__ */ i({
134
170
  modelModifiers: {}
135
171
  },
136
172
  emits: ["update:modelValue"],
137
- setup(s) {
138
- const e = _(s, "modelValue"), t = c(), r = p(), l = f(() => typeof t.id == "string" ? t.id : r);
139
- return (n, o) => $((d(), u("select", m(n.$attrs, {
140
- "onUpdate:modelValue": o[0] || (o[0] = (a) => e.value = a),
141
- id: l.value
173
+ setup(o) {
174
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.id == "string" ? e.id : n);
175
+ return (s, r) => $((i(), m("select", _(s.$attrs, {
176
+ id: a.value,
177
+ "onUpdate:modelValue": r[0] || (r[0] = (l) => t.value = l)
142
178
  }), [
143
- h(n.$slots, "default")
144
- ], 16, E)), [
145
- [U, e.value]
179
+ h(s.$slots, "default")
180
+ ], 16, W)), [
181
+ [L, t.value]
146
182
  ]);
147
183
  }
148
- }), j = ["id"], X = /* @__PURE__ */ i({
184
+ }), X = ["id"], de = /* @__PURE__ */ d({
149
185
  inheritAttrs: !1,
150
186
  __name: "BaseTextarea",
151
187
  props: {
@@ -153,24 +189,26 @@ const G = /* @__PURE__ */ i({
153
189
  modelModifiers: {}
154
190
  },
155
191
  emits: ["update:modelValue"],
156
- setup(s) {
157
- const e = _(s, "modelValue"), t = c(), r = p(), l = f(() => typeof t.id == "string" ? t.id : r);
158
- return (n, o) => $((d(), u("textarea", m(n.$attrs, {
159
- "onUpdate:modelValue": o[0] || (o[0] = (a) => e.value = a),
160
- id: l.value
161
- }), null, 16, j)), [
162
- [w, e.value]
192
+ setup(o) {
193
+ const t = f(o, "modelValue"), e = c(), n = p(), a = u(() => typeof e.id == "string" ? e.id : n);
194
+ return (s, r) => $((i(), m("textarea", _(s.$attrs, {
195
+ id: a.value,
196
+ "onUpdate:modelValue": r[0] || (r[0] = (l) => t.value = l)
197
+ }), null, 16, X)), [
198
+ [j, t.value]
163
199
  ]);
164
200
  }
165
201
  });
166
202
  export {
167
- G as CButton,
168
- H as CCheckbox,
169
- J as CFile,
170
- K as CForm,
171
- N as CInput,
172
- O as CLabel,
173
- Q as CRadio,
174
- W as CSelect,
175
- X as CTextarea
203
+ Z as CButton,
204
+ ee as CCheckbox,
205
+ te as CCheckboxGroup,
206
+ oe as CFile,
207
+ ae as CForm,
208
+ se as CInput,
209
+ ne as CLabel,
210
+ re as CRadio,
211
+ le as CRadioGroup,
212
+ ue as CSelect,
213
+ de as CTextarea
176
214
  };
@@ -1 +1 @@
1
- (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d.Charpente={},d.Vue))})(this,(function(d,e){"use strict";const c=e.defineComponent({inheritAttrs:!1,__name:"BaseButton",props:{as:{default:"button"}},setup(n){return(t,o)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.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(n){const t=n,o=e.useModel(n,"modelValue"),a=e.useAttrs(),i=e.useId(),l=e.useTemplateRef("input"),s=e.computed(()=>typeof a.id=="string"?a.id:i);return e.watch([l,()=>t.indeterminate],()=>{l.value&&(l.value.indeterminate=!!t.indeterminate)},{immediate:!0}),(r,m)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({ref:"input",type:"checkbox"},r.$attrs,{"onUpdate:modelValue":m[0]||(m[0]=P=>o.value=P),id:s.value,value:n.value}),null,16,p)),[[e.vModelCheckbox,o.value]])}}),f=["id"],_=e.defineComponent({inheritAttrs:!1,__name:"BaseFile",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const t=e.useModel(n,"modelValue"),o=e.useAttrs(),a=e.useId(),i=e.useTemplateRef("input"),l=e.computed(()=>typeof o.id=="string"?o.id:a);function s(r){t.value=r.target.files}return e.watch(t,r=>{!r&&i.value&&(i.value.value="")}),(r,m)=>(e.openBlock(),e.createElementBlock("input",e.mergeProps({type:"file",ref:"input"},r.$attrs,{id:l.value,onChange:s}),null,16,f))}}),h=["id"],B=e.defineComponent({inheritAttrs:!1,__name:"BaseForm",emits:["submit"],setup(n,{emit:t}){const o=e.useAttrs(),a=e.useId(),i=t,l=e.computed(()=>typeof o.id=="string"?o.id:a);return(s,r)=>(e.openBlock(),e.createElementBlock("form",e.mergeProps(s.$attrs,{id:l.value,onSubmit:r[0]||(r[0]=e.withModifiers(m=>i("submit",m),["prevent"]))}),[e.renderSlot(s.$slots,"default")],16,h))}}),g=["id"],$=e.defineComponent({inheritAttrs:!1,__name:"BaseInput",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const t=e.useModel(n,"modelValue"),o=e.useAttrs(),a=e.useId(),i=e.computed(()=>typeof o.id=="string"?o.id:a);return(l,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps(l.$attrs,{"onUpdate:modelValue":s[0]||(s[0]=r=>t.value=r),id:i.value}),null,16,g)),[[e.vModelDynamic,t.value]])}}),C=["for"],V=e.defineComponent({inheritAttrs:!1,__name:"BaseLabel",props:{for:{}},setup(n){const t=n;return(o,a)=>(e.openBlock(),e.createElementBlock("label",e.mergeProps(o.$attrs,{for:t.for}),[e.renderSlot(o.$slots,"default")],16,C))}}),k=["id","value"],I=e.defineComponent({inheritAttrs:!1,__name:"BaseRadio",props:e.mergeModels({value:{}},{modelValue:{},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const t=e.useModel(n,"modelValue"),o=e.useAttrs(),a=e.useId(),i=e.computed(()=>typeof o.id=="string"?o.id:a);return(l,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",e.mergeProps({type:"radio"},l.$attrs,{"onUpdate:modelValue":s[0]||(s[0]=r=>t.value=r),id:i.value,value:n.value}),null,16,k)),[[e.vModelRadio,t.value]])}}),M=["id"],y=e.defineComponent({inheritAttrs:!1,__name:"BaseSelect",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const t=e.useModel(n,"modelValue"),o=e.useAttrs(),a=e.useId(),i=e.computed(()=>typeof o.id=="string"?o.id:a);return(l,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("select",e.mergeProps(l.$attrs,{"onUpdate:modelValue":s[0]||(s[0]=r=>t.value=r),id:i.value}),[e.renderSlot(l.$slots,"default")],16,M)),[[e.vModelSelect,t.value]])}}),A=["id"],b=e.defineComponent({inheritAttrs:!1,__name:"BaseTextarea",props:{modelValue:{},modelModifiers:{}},emits:["update:modelValue"],setup(n){const t=e.useModel(n,"modelValue"),o=e.useAttrs(),a=e.useId(),i=e.computed(()=>typeof o.id=="string"?o.id:a);return(l,s)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",e.mergeProps(l.$attrs,{"onUpdate:modelValue":s[0]||(s[0]=r=>t.value=r),id:i.value}),null,16,A)),[[e.vModelText,t.value]])}});d.CButton=c,d.CCheckbox=u,d.CFile=_,d.CForm=B,d.CInput=$,d.CLabel=V,d.CRadio=I,d.CSelect=y,d.CTextarea=b,Object.defineProperty(d,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(d.$attrs,{id:r.value,ref:"input",type:"file",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,{id:s.value,"onUpdate:modelValue":a[0]||(a[0]=d=>o.value=d)}),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,{id:s.value,"onUpdate:modelValue":a[0]||(a[0]=d=>o.value=d)}),[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,{id:s.value,"onUpdate:modelValue":a[0]||(a[0]=d=>o.value=d)}),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.2",
3
+ "version": "1.3.1",
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",