@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 +58 -12
- package/dist/charpente.js +130 -92
- package/dist/charpente.umd.cjs +1 -1
- package/dist/components/BaseCheckboxGroup.d.ts +24 -0
- package/dist/components/BaseForm.d.ts +2 -2
- package/dist/components/BaseRadioGroup.d.ts +24 -0
- package/dist/components/__tests__/BaseCheckboxGroup.spec.d.ts +1 -0
- package/dist/components/__tests__/BaseRadioGroup.spec.d.ts +1 -0
- package/dist/components/internal/keys.d.ts +11 -0
- package/dist/index.d.ts +2 -0
- package/package.json +2 -1
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
|
+
[](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. **
|
|
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
|
|
104
|
-
|
|
105
|
-
| Button
|
|
106
|
-
| Checkbox
|
|
107
|
-
|
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
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
|
|
2
|
-
const
|
|
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(
|
|
9
|
-
return (
|
|
10
|
-
default:
|
|
11
|
-
h(
|
|
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
|
-
}),
|
|
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__ */
|
|
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(
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
}
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
}),
|
|
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(
|
|
51
|
-
const
|
|
52
|
-
function
|
|
53
|
-
|
|
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
|
|
56
|
-
!
|
|
57
|
-
}), (
|
|
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
|
-
|
|
60
|
-
},
|
|
61
|
-
id: n.value,
|
|
62
|
-
onChange: o
|
|
63
|
-
}), null, 16, T));
|
|
80
|
+
onChange: r
|
|
81
|
+
}), null, 16, q));
|
|
64
82
|
}
|
|
65
|
-
}),
|
|
83
|
+
}), H = ["id"], ae = /* @__PURE__ */ d({
|
|
66
84
|
inheritAttrs: !1,
|
|
67
85
|
__name: "BaseForm",
|
|
68
86
|
emits: ["submit"],
|
|
69
|
-
setup(
|
|
70
|
-
const
|
|
71
|
-
return (
|
|
72
|
-
id:
|
|
73
|
-
onSubmit:
|
|
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(
|
|
76
|
-
], 16,
|
|
93
|
+
h(r.$slots, "default")
|
|
94
|
+
], 16, H));
|
|
77
95
|
}
|
|
78
|
-
}),
|
|
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(
|
|
87
|
-
const
|
|
88
|
-
return (
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}), null, 16,
|
|
92
|
-
[
|
|
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
|
-
}),
|
|
113
|
+
}), O = ["for"], ne = /* @__PURE__ */ d({
|
|
96
114
|
inheritAttrs: !1,
|
|
97
115
|
__name: "BaseLabel",
|
|
98
116
|
props: {
|
|
99
117
|
for: {}
|
|
100
118
|
},
|
|
101
|
-
setup(
|
|
102
|
-
const
|
|
103
|
-
return (
|
|
104
|
-
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(
|
|
107
|
-
], 16,
|
|
124
|
+
h(e.$slots, "default")
|
|
125
|
+
], 16, O));
|
|
108
126
|
}
|
|
109
|
-
}),
|
|
127
|
+
}), Q = ["id", "name", "value"], re = /* @__PURE__ */ d({
|
|
110
128
|
inheritAttrs: !1,
|
|
111
129
|
__name: "BaseRadio",
|
|
112
|
-
props: /* @__PURE__ */
|
|
130
|
+
props: /* @__PURE__ */ A({
|
|
113
131
|
value: {}
|
|
114
132
|
}, {
|
|
115
133
|
modelValue: {},
|
|
116
134
|
modelModifiers: {}
|
|
117
135
|
}),
|
|
118
136
|
emits: ["update:modelValue"],
|
|
119
|
-
setup(
|
|
120
|
-
const
|
|
121
|
-
return (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
}),
|
|
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(
|
|
138
|
-
const
|
|
139
|
-
return (
|
|
140
|
-
|
|
141
|
-
|
|
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(
|
|
144
|
-
], 16,
|
|
145
|
-
[
|
|
179
|
+
h(s.$slots, "default")
|
|
180
|
+
], 16, W)), [
|
|
181
|
+
[L, t.value]
|
|
146
182
|
]);
|
|
147
183
|
}
|
|
148
|
-
}),
|
|
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(
|
|
157
|
-
const
|
|
158
|
-
return (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}), null, 16,
|
|
162
|
-
[
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
};
|
package/dist/charpente.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
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:
|
|
11
|
+
submit: (event: SubmitEvent) => any;
|
|
12
12
|
}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{
|
|
13
|
-
onSubmit?: ((event:
|
|
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 @@
|
|
|
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.
|
|
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",
|