@charpente-ui/vue 1.2.2 → 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 +58 -12
- package/dist/charpente.js +130 -91
- 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/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,35 @@ 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", _({
|
|
58
77
|
type: "file",
|
|
59
78
|
ref: "input"
|
|
60
|
-
},
|
|
61
|
-
id:
|
|
62
|
-
onChange:
|
|
63
|
-
}), null, 16,
|
|
79
|
+
}, l.$attrs, {
|
|
80
|
+
id: s.value,
|
|
81
|
+
onChange: r
|
|
82
|
+
}), null, 16, q));
|
|
64
83
|
}
|
|
65
|
-
}),
|
|
84
|
+
}), H = ["id"], ae = /* @__PURE__ */ d({
|
|
66
85
|
inheritAttrs: !1,
|
|
67
86
|
__name: "BaseForm",
|
|
68
87
|
emits: ["submit"],
|
|
69
|
-
setup(
|
|
70
|
-
const
|
|
71
|
-
return (
|
|
72
|
-
id:
|
|
73
|
-
onSubmit:
|
|
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(
|
|
76
|
-
], 16,
|
|
94
|
+
h(r.$slots, "default")
|
|
95
|
+
], 16, H));
|
|
77
96
|
}
|
|
78
|
-
}),
|
|
97
|
+
}), J = ["id"], se = /* @__PURE__ */ d({
|
|
79
98
|
inheritAttrs: !1,
|
|
80
99
|
__name: "BaseInput",
|
|
81
100
|
props: {
|
|
@@ -83,50 +102,68 @@ const G = /* @__PURE__ */ i({
|
|
|
83
102
|
modelModifiers: {}
|
|
84
103
|
},
|
|
85
104
|
emits: ["update:modelValue"],
|
|
86
|
-
setup(
|
|
87
|
-
const
|
|
88
|
-
return (
|
|
89
|
-
"onUpdate:modelValue":
|
|
90
|
-
id:
|
|
91
|
-
}), null, 16,
|
|
92
|
-
[
|
|
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
|
-
}),
|
|
114
|
+
}), O = ["for"], ne = /* @__PURE__ */ d({
|
|
96
115
|
inheritAttrs: !1,
|
|
97
116
|
__name: "BaseLabel",
|
|
98
117
|
props: {
|
|
99
118
|
for: {}
|
|
100
119
|
},
|
|
101
|
-
setup(
|
|
102
|
-
const
|
|
103
|
-
return (
|
|
104
|
-
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(
|
|
107
|
-
], 16,
|
|
125
|
+
h(e.$slots, "default")
|
|
126
|
+
], 16, O));
|
|
108
127
|
}
|
|
109
|
-
}),
|
|
128
|
+
}), Q = ["id", "name", "value"], re = /* @__PURE__ */ d({
|
|
110
129
|
inheritAttrs: !1,
|
|
111
130
|
__name: "BaseRadio",
|
|
112
|
-
props: /* @__PURE__ */
|
|
131
|
+
props: /* @__PURE__ */ A({
|
|
113
132
|
value: {}
|
|
114
133
|
}, {
|
|
115
134
|
modelValue: {},
|
|
116
135
|
modelModifiers: {}
|
|
117
136
|
}),
|
|
118
137
|
emits: ["update:modelValue"],
|
|
119
|
-
setup(
|
|
120
|
-
const
|
|
121
|
-
return (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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", _({
|
|
141
|
+
id: r.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
|
-
}),
|
|
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 G = /* @__PURE__ */ i({
|
|
|
134
171
|
modelModifiers: {}
|
|
135
172
|
},
|
|
136
173
|
emits: ["update:modelValue"],
|
|
137
|
-
setup(
|
|
138
|
-
const
|
|
139
|
-
return (
|
|
140
|
-
"onUpdate:modelValue":
|
|
141
|
-
id:
|
|
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(
|
|
144
|
-
], 16,
|
|
145
|
-
[
|
|
180
|
+
h(s.$slots, "default")
|
|
181
|
+
], 16, W)), [
|
|
182
|
+
[L, t.value]
|
|
146
183
|
]);
|
|
147
184
|
}
|
|
148
|
-
}),
|
|
185
|
+
}), X = ["id"], de = /* @__PURE__ */ d({
|
|
149
186
|
inheritAttrs: !1,
|
|
150
187
|
__name: "BaseTextarea",
|
|
151
188
|
props: {
|
|
@@ -153,24 +190,26 @@ const G = /* @__PURE__ */ i({
|
|
|
153
190
|
modelModifiers: {}
|
|
154
191
|
},
|
|
155
192
|
emits: ["update:modelValue"],
|
|
156
|
-
setup(
|
|
157
|
-
const
|
|
158
|
-
return (
|
|
159
|
-
"onUpdate:modelValue":
|
|
160
|
-
id:
|
|
161
|
-
}), null, 16,
|
|
162
|
-
[
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
};
|
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({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:
|
|
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.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",
|