@charpente-ui/vue 1.6.0 → 2.0.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 +87 -1
- package/dist/components/BaseButton.js +5 -0
- package/dist/components/BaseButton.vue?vue&type=script&setup=true&lang.js +16 -0
- package/dist/components/BaseCheckbox.js +5 -0
- package/dist/components/BaseCheckbox.vue?vue&type=script&setup=true&lang.js +35 -0
- package/dist/components/BaseCheckboxGroup.js +5 -0
- package/dist/components/BaseCheckboxGroup.vue?vue&type=script&setup=true&lang.js +21 -0
- package/dist/components/BaseField.d.ts +17 -0
- package/dist/components/BaseField.js +5 -0
- package/dist/components/BaseField.vue?vue&type=script&setup=true&lang.js +13 -0
- package/dist/components/BaseFile.js +5 -0
- package/dist/components/BaseFile.vue?vue&type=script&setup=true&lang.js +28 -0
- package/dist/components/BaseForm.js +5 -0
- package/dist/components/BaseForm.vue?vue&type=script&setup=true&lang.js +16 -0
- package/dist/components/BaseInput.d.ts +1 -0
- package/dist/components/BaseInput.js +5 -0
- package/dist/components/BaseInput.vue?vue&type=script&setup=true&lang.js +30 -0
- package/dist/components/BaseLabel.js +5 -0
- package/dist/components/BaseLabel.vue?vue&type=script&setup=true&lang.js +14 -0
- package/dist/components/BaseRadio.js +5 -0
- package/dist/components/BaseRadio.vue?vue&type=script&setup=true&lang.js +28 -0
- package/dist/components/BaseRadioGroup.js +5 -0
- package/dist/components/BaseRadioGroup.vue?vue&type=script&setup=true&lang.js +21 -0
- package/dist/components/BaseSelect.js +5 -0
- package/dist/components/BaseSelect.vue?vue&type=script&setup=true&lang.js +21 -0
- package/dist/components/BaseTextarea.d.ts +1 -0
- package/dist/components/BaseTextarea.js +5 -0
- package/dist/components/BaseTextarea.vue?vue&type=script&setup=true&lang.js +30 -0
- package/dist/components/internal/keys.d.ts +6 -2
- package/dist/components/internal/keys.js +4 -0
- package/dist/components/internal/modifiers.d.ts +6 -0
- package/dist/components/internal/modifiers.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +13 -0
- package/package.json +9 -7
- package/dist/charpente.js +0 -182
- package/dist/charpente.umd.cjs +0 -1
package/README.md
CHANGED
|
@@ -75,7 +75,13 @@ npm run dev
|
|
|
75
75
|
1. **Form Inputs** **(CInput, CTextarea, CSelect)**
|
|
76
76
|
|
|
77
77
|
These components are thin wrappers around native elements. They use `v-model` and automatically link with labels via
|
|
78
|
-
`useId()`. Full attribute inheritance.
|
|
78
|
+
`useId()`. Full attribute inheritance. `CInput` and `CTextarea` support the native `v-model` modifiers:
|
|
79
|
+
|
|
80
|
+
```vue
|
|
81
|
+
<CInput v-model.trim="name"/>
|
|
82
|
+
<CInput v-model.number="age"/>
|
|
83
|
+
<CInput v-model.lazy="query"/>
|
|
84
|
+
```
|
|
79
85
|
|
|
80
86
|
2. **Selection Logic** _(CCheckbox, CRadio, CSelect)_
|
|
81
87
|
|
|
@@ -133,6 +139,12 @@ individual inputs:
|
|
|
133
139
|
<CRadioGroup v-model="selected" name="my-group">...</CRadioGroup>
|
|
134
140
|
```
|
|
135
141
|
|
|
142
|
+
> [!NOTE]
|
|
143
|
+
> Standalone `CRadio` and `CCheckbox` accept any `value` (strings, numbers, booleans, objects — `v-model` compares by
|
|
144
|
+
> reference, as in native Vue). Inside a group, the group `v-model` is typed `string | number`
|
|
145
|
+
> (`(string | number)[]` for checkboxes): stick to those value types in grouped mode, as TypeScript cannot enforce it
|
|
146
|
+
> on the `value` prop without dropping standalone object support.
|
|
147
|
+
|
|
136
148
|
4. **Polymorphic Elements** _(CButton)_
|
|
137
149
|
|
|
138
150
|
The button can change its HTML tag while keeping its behavior.
|
|
@@ -142,6 +154,39 @@ The button can change its HTML tag while keeping its behavior.
|
|
|
142
154
|
<CButton as="RouterLink" to="/dashboard">Dashboard</CButton>
|
|
143
155
|
```
|
|
144
156
|
|
|
157
|
+
When rendering a native `<button>`, `CButton` defaults to `type="button"` (instead of the native `type="submit"`) to
|
|
158
|
+
avoid accidental form submissions. Pass `type="submit"` explicitly for submit buttons.
|
|
159
|
+
|
|
160
|
+
5. **Field Wrapper** _(CField)_
|
|
161
|
+
|
|
162
|
+
`CField` links a label and an input automatically: it provides a shared auto-generated id that `CLabel` picks up as
|
|
163
|
+
`for` and the wrapped input picks up as `id` — no manual wiring.
|
|
164
|
+
|
|
165
|
+
```vue
|
|
166
|
+
<CField>
|
|
167
|
+
<CLabel>Email</CLabel>
|
|
168
|
+
<CInput v-model="email" type="email"/>
|
|
169
|
+
</CField>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
An explicit `id` on the input or `for` on the label always wins over the field id. A `CField` wrapping a whole
|
|
173
|
+
group is ignored by the items (a single id must not land on every input); wrap each item in its own `CField`
|
|
174
|
+
instead:
|
|
175
|
+
|
|
176
|
+
```vue
|
|
177
|
+
<CRadioGroup v-model="selected">
|
|
178
|
+
<CField>
|
|
179
|
+
<CLabel>Option A</CLabel>
|
|
180
|
+
<CRadio value="a"/>
|
|
181
|
+
</CField>
|
|
182
|
+
|
|
183
|
+
<CField>
|
|
184
|
+
<CLabel>Option B</CLabel>
|
|
185
|
+
<CRadio value="b"/>
|
|
186
|
+
</CField>
|
|
187
|
+
</CRadioGroup>
|
|
188
|
+
```
|
|
189
|
+
|
|
145
190
|
## Components
|
|
146
191
|
|
|
147
192
|
| Name | Core Logic | Tag | Status |
|
|
@@ -149,6 +194,7 @@ The button can change its HTML tag while keeping its behavior.
|
|
|
149
194
|
| Button | **Polymorphic:** Switches tags _(a, button, etc...)_ while keeping logic. | `CButton` | Ready |
|
|
150
195
|
| Checkbox | **Smart Toggle:** Handles array state, booleans, and indeterminate natively. | `CCheckbox` | Ready |
|
|
151
196
|
| CheckboxGroup | **Group:** Shared v-model and name across checkboxes inside a fieldset. | `CCheckboxGroup` | Ready |
|
|
197
|
+
| Field | **Wrapper:** Auto-links a label and an input via a shared generated id. | `CField` | Ready |
|
|
152
198
|
| File | **File Input:** Reactive file selection with `v-model` support. | `CFile` | Ready |
|
|
153
199
|
| Form | **Auto-Submit:** Integrated `preventDefault` and event handling. | `CForm` | Ready |
|
|
154
200
|
| Input | **Auto-ID:** Auto-links to labels via `useId()` and full attributes inheritance. | `CInput` | Ready |
|
|
@@ -157,3 +203,43 @@ The button can change its HTML tag while keeping its behavior.
|
|
|
157
203
|
| RadioGroup | **Group:** Shared v-model and name across radios inside a fieldset. | `CRadioGroup` | Ready |
|
|
158
204
|
| Select | **Native Wrapper:** Single and multiple selection support. | `CSelect` | Ready |
|
|
159
205
|
| Textarea | **Flexible Binding:** Auto-ID and reactive model management. | `CTextarea` | Ready |
|
|
206
|
+
|
|
207
|
+
## Wrapping Components
|
|
208
|
+
|
|
209
|
+
When wrapping a Charpente UI component inside your own, you must forward `$attrs` so that native HTML attributes
|
|
210
|
+
(`id`, `class`, `disabled`, etc.) reach the underlying element instead of landing on your wrapper's root node.
|
|
211
|
+
|
|
212
|
+
```vue
|
|
213
|
+
<script setup>
|
|
214
|
+
import { CSelect } from '@charpente-ui/vue';
|
|
215
|
+
|
|
216
|
+
defineOptions({
|
|
217
|
+
inheritAttrs: false
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
defineProps({
|
|
221
|
+
label: String,
|
|
222
|
+
error: String
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const model = defineModel();
|
|
226
|
+
</script>
|
|
227
|
+
|
|
228
|
+
<template>
|
|
229
|
+
<div>
|
|
230
|
+
<label>{{ label }}</label>
|
|
231
|
+
|
|
232
|
+
<CSelect v-bind="$attrs" v-model="model">
|
|
233
|
+
<slot/>
|
|
234
|
+
</CSelect>
|
|
235
|
+
|
|
236
|
+
<span v-if="error">{{ error }}</span>
|
|
237
|
+
</div>
|
|
238
|
+
</template>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Why this matters:** Without `inheritAttrs: false`, Vue applies fallthrough attributes to the wrapper's root element
|
|
242
|
+
(`<div>`) instead of the inner component. Adding `v-bind="$attrs"` on the Charpente component ensures attributes like
|
|
243
|
+
`id`, `class`, `required`, or `disabled` pass all the way through to the native HTML element.
|
|
244
|
+
|
|
245
|
+
This pattern works the same way for all Charpente components (`CInput`, `CCheckbox`, `CRadio`, etc.).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { computed as e, createBlock as t, defineComponent as n, mergeProps as r, openBlock as i, renderSlot as a, resolveDynamicComponent as o, useAttrs as s, withCtx as c } from "vue";
|
|
2
|
+
//#region src/components/BaseButton.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var l = /* @__PURE__ */ n({
|
|
4
|
+
inheritAttrs: !1,
|
|
5
|
+
__name: "BaseButton",
|
|
6
|
+
props: { as: { default: "button" } },
|
|
7
|
+
setup(n) {
|
|
8
|
+
let l = n, u = s(), d = e(() => typeof u.type == "string" ? u.type : l.as === "button" ? "button" : void 0);
|
|
9
|
+
return (e, s) => (i(), t(o(n.as), r(e.$attrs, { type: d.value }), {
|
|
10
|
+
default: c(() => [a(e.$slots, "default")]),
|
|
11
|
+
_: 3
|
|
12
|
+
}, 16, ["type"]));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { l as default };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { checkboxGroupKey as e, fieldKey as t } from "./internal/keys.js";
|
|
2
|
+
import { computed as n, createElementBlock as r, defineComponent as i, inject as a, isRef as o, mergeModels as s, mergeProps as c, openBlock as l, unref as u, useAttrs as d, useId as f, useModel as p, useTemplateRef as m, vModelCheckbox as h, watchPostEffect as g, withDirectives as _ } from "vue";
|
|
3
|
+
//#region src/components/BaseCheckbox.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var v = [
|
|
5
|
+
"id",
|
|
6
|
+
"name",
|
|
7
|
+
"value"
|
|
8
|
+
], y = /* @__PURE__ */ i({
|
|
9
|
+
inheritAttrs: !1,
|
|
10
|
+
__name: "BaseCheckbox",
|
|
11
|
+
props: /* @__PURE__ */ s({
|
|
12
|
+
value: {},
|
|
13
|
+
indeterminate: { type: Boolean }
|
|
14
|
+
}, {
|
|
15
|
+
modelValue: { type: [Boolean, Array] },
|
|
16
|
+
modelModifiers: {}
|
|
17
|
+
}),
|
|
18
|
+
emits: ["update:modelValue"],
|
|
19
|
+
setup(i) {
|
|
20
|
+
let s = i, y = p(i, "modelValue"), b = a(e, null), x = b ? b.model : y, S = d(), C = f(), w = m("input"), T = a(t, null), E = n(() => typeof S.id == "string" ? S.id : T?.id.value ?? C), D = n(() => typeof S.name == "string" ? S.name : b?.name.value);
|
|
21
|
+
return g(() => {
|
|
22
|
+
/* v8 ignore next 2 */
|
|
23
|
+
w.value && (w.value.indeterminate = !!s.indeterminate);
|
|
24
|
+
}), (e, t) => _((l(), r("input", c(e.$attrs, {
|
|
25
|
+
id: E.value,
|
|
26
|
+
ref: "input",
|
|
27
|
+
"onUpdate:modelValue": t[0] ||= (e) => o(x) ? x.value = e : null,
|
|
28
|
+
name: D.value,
|
|
29
|
+
type: "checkbox",
|
|
30
|
+
value: i.value
|
|
31
|
+
}), null, 16, v)), [[h, u(x)]]);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
//#endregion
|
|
35
|
+
export { y as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { checkboxGroupKey as e, fieldKey as t } from "./internal/keys.js";
|
|
2
|
+
import { computed as n, createElementBlock as r, defineComponent as i, guardReactiveProps as a, normalizeProps as o, openBlock as s, provide as c, renderSlot as l, useAttrs as u, useId as d, useModel as f } from "vue";
|
|
3
|
+
//#region src/components/BaseCheckboxGroup.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var p = /* @__PURE__ */ i({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "BaseCheckboxGroup",
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: { default: () => [] },
|
|
9
|
+
modelModifiers: {}
|
|
10
|
+
},
|
|
11
|
+
emits: ["update:modelValue"],
|
|
12
|
+
setup(i) {
|
|
13
|
+
let p = f(i, "modelValue"), m = u(), h = d();
|
|
14
|
+
return c(e, {
|
|
15
|
+
model: p,
|
|
16
|
+
name: n(() => typeof m.name == "string" ? m.name : h)
|
|
17
|
+
}), c(t, null), (e, t) => (s(), r("fieldset", o(a(e.$attrs)), [l(e.$slots, "default")], 16));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { p as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare function __VLS_template(): {
|
|
2
|
+
attrs: Partial<{}>;
|
|
3
|
+
slots: {
|
|
4
|
+
default?(_: {}): any;
|
|
5
|
+
};
|
|
6
|
+
refs: {};
|
|
7
|
+
rootEl: any;
|
|
8
|
+
};
|
|
9
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
10
|
+
declare const __VLS_component: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
11
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
12
|
+
export default _default;
|
|
13
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
14
|
+
new (): {
|
|
15
|
+
$slots: S;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { fieldKey as e } from "./internal/keys.js";
|
|
2
|
+
import { computed as t, createElementBlock as n, defineComponent as r, guardReactiveProps as i, normalizeProps as a, openBlock as o, provide as s, renderSlot as c, useId as l } from "vue";
|
|
3
|
+
//#region src/components/BaseField.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var u = /* @__PURE__ */ r({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "BaseField",
|
|
7
|
+
setup(r) {
|
|
8
|
+
let u = l();
|
|
9
|
+
return s(e, { id: t(() => u) }), (e, t) => (o(), n("div", a(i(e.$attrs)), [c(e.$slots, "default")], 16));
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
//#endregion
|
|
13
|
+
export { u as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fieldKey as e } from "./internal/keys.js";
|
|
2
|
+
import { computed as t, createElementBlock as n, defineComponent as r, inject as i, mergeProps as a, openBlock as o, useAttrs as s, useId as c, useModel as l, useTemplateRef as u, watch as d } from "vue";
|
|
3
|
+
//#region src/components/BaseFile.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var f = ["id"], p = /* @__PURE__ */ r({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "BaseFile",
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {},
|
|
9
|
+
modelModifiers: {}
|
|
10
|
+
},
|
|
11
|
+
emits: ["update:modelValue"],
|
|
12
|
+
setup(r) {
|
|
13
|
+
let p = l(r, "modelValue"), m = s(), h = c(), g = u("input"), _ = i(e, null), v = t(() => typeof m.id == "string" ? m.id : _?.id.value ?? h);
|
|
14
|
+
function y(e) {
|
|
15
|
+
p.value = e.target.files;
|
|
16
|
+
}
|
|
17
|
+
return d(p, (e) => {
|
|
18
|
+
!e && g.value && (g.value.value = "");
|
|
19
|
+
}), (e, t) => (o(), n("input", a(e.$attrs, {
|
|
20
|
+
id: v.value,
|
|
21
|
+
ref: "input",
|
|
22
|
+
type: "file",
|
|
23
|
+
onChange: y
|
|
24
|
+
}), null, 16, f));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { p as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { computed as e, createElementBlock as t, defineComponent as n, mergeProps as r, openBlock as i, renderSlot as a, useAttrs as o, useId as s, withModifiers as c } from "vue";
|
|
2
|
+
//#region src/components/BaseForm.vue?vue&type=script&setup=true&lang.ts
|
|
3
|
+
var l = ["id"], u = /* @__PURE__ */ n({
|
|
4
|
+
inheritAttrs: !1,
|
|
5
|
+
__name: "BaseForm",
|
|
6
|
+
emits: ["submit"],
|
|
7
|
+
setup(n, { emit: u }) {
|
|
8
|
+
let d = o(), f = s(), p = u, m = e(() => typeof d.id == "string" ? d.id : f);
|
|
9
|
+
return (e, n) => (i(), t("form", r(e.$attrs, {
|
|
10
|
+
id: m.value,
|
|
11
|
+
onSubmit: n[0] ||= c((e) => p("submit", e), ["prevent"])
|
|
12
|
+
}), [a(e.$slots, "default")], 16, l));
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
//#endregion
|
|
16
|
+
export { u as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type __VLS_PublicProps = {
|
|
2
2
|
modelValue?: string | number;
|
|
3
|
+
'modelModifiers'?: Partial<Record<'trim' | 'number' | 'lazy', true>>;
|
|
3
4
|
};
|
|
4
5
|
declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
5
6
|
"update:modelValue": (value: string | number) => any;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { fieldKey as e } from "./internal/keys.js";
|
|
2
|
+
import { applyModelModifiers as t } from "./internal/modifiers.js";
|
|
3
|
+
import { computed as n, createElementBlock as r, defineComponent as i, inject as a, isRef as o, mergeProps as s, openBlock as c, unref as l, useAttrs as u, useId as d, useModel as f, vModelDynamic as p, withDirectives as m } from "vue";
|
|
4
|
+
//#region src/components/BaseInput.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var h = ["id"], g = ["id"], _ = /* @__PURE__ */ i({
|
|
6
|
+
inheritAttrs: !1,
|
|
7
|
+
__name: "BaseInput",
|
|
8
|
+
props: {
|
|
9
|
+
modelValue: {},
|
|
10
|
+
modelModifiers: {}
|
|
11
|
+
},
|
|
12
|
+
emits: ["update:modelValue"],
|
|
13
|
+
setup(i) {
|
|
14
|
+
let [_, v] = f(i, "modelValue", { set: (e) => t(e, v) }), y = u(), b = d(), x = a(e, null), S = n(() => typeof y.id == "string" ? y.id : x?.id.value ?? b);
|
|
15
|
+
return (e, t) => l(v).lazy ? m((c(), r("input", s({ key: 0 }, e.$attrs, {
|
|
16
|
+
id: S.value,
|
|
17
|
+
"onUpdate:modelValue": t[0] ||= (e) => o(_) ? _.value = e : null
|
|
18
|
+
}), null, 16, h)), [[
|
|
19
|
+
p,
|
|
20
|
+
l(_),
|
|
21
|
+
void 0,
|
|
22
|
+
{ lazy: !0 }
|
|
23
|
+
]]) : m((c(), r("input", s({ key: 1 }, e.$attrs, {
|
|
24
|
+
id: S.value,
|
|
25
|
+
"onUpdate:modelValue": t[1] ||= (e) => o(_) ? _.value = e : null
|
|
26
|
+
}), null, 16, g)), [[p, l(_)]]);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
export { _ as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { fieldKey as e } from "./internal/keys.js";
|
|
2
|
+
import { computed as t, createElementBlock as n, defineComponent as r, inject as i, mergeProps as a, openBlock as o, renderSlot as s } from "vue";
|
|
3
|
+
//#region src/components/BaseLabel.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var c = ["for"], l = /* @__PURE__ */ r({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "BaseLabel",
|
|
7
|
+
props: { for: {} },
|
|
8
|
+
setup(r) {
|
|
9
|
+
let l = r, u = i(e, null), d = t(() => l.for ?? u?.id.value);
|
|
10
|
+
return (e, t) => (o(), n("label", a(e.$attrs, { for: d.value }), [s(e.$slots, "default")], 16, c));
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { l as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fieldKey as e, radioGroupKey as t } from "./internal/keys.js";
|
|
2
|
+
import { computed as n, createElementBlock as r, defineComponent as i, inject as a, isRef as o, mergeModels as s, mergeProps as c, openBlock as l, unref as u, useAttrs as d, useId as f, useModel as p, vModelRadio as m, withDirectives as h } from "vue";
|
|
3
|
+
//#region src/components/BaseRadio.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var g = [
|
|
5
|
+
"id",
|
|
6
|
+
"name",
|
|
7
|
+
"value"
|
|
8
|
+
], _ = /* @__PURE__ */ i({
|
|
9
|
+
inheritAttrs: !1,
|
|
10
|
+
__name: "BaseRadio",
|
|
11
|
+
props: /* @__PURE__ */ s({ value: {} }, {
|
|
12
|
+
modelValue: {},
|
|
13
|
+
modelModifiers: {}
|
|
14
|
+
}),
|
|
15
|
+
emits: ["update:modelValue"],
|
|
16
|
+
setup(i) {
|
|
17
|
+
let s = p(i, "modelValue"), _ = a(t, null), v = _ ? _.model : s, y = d(), b = f(), x = a(e, null), S = n(() => typeof y.id == "string" ? y.id : x?.id.value ?? b), C = n(() => typeof y.name == "string" ? y.name : _?.name.value);
|
|
18
|
+
return (e, t) => h((l(), r("input", c(e.$attrs, {
|
|
19
|
+
id: S.value,
|
|
20
|
+
"onUpdate:modelValue": t[0] ||= (e) => o(v) ? v.value = e : null,
|
|
21
|
+
name: C.value,
|
|
22
|
+
value: i.value,
|
|
23
|
+
type: "radio"
|
|
24
|
+
}), null, 16, g)), [[m, u(v)]]);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
//#endregion
|
|
28
|
+
export { _ as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { fieldKey as e, radioGroupKey as t } from "./internal/keys.js";
|
|
2
|
+
import { computed as n, createElementBlock as r, defineComponent as i, guardReactiveProps as a, normalizeProps as o, openBlock as s, provide as c, renderSlot as l, useAttrs as u, useId as d, useModel as f } from "vue";
|
|
3
|
+
//#region src/components/BaseRadioGroup.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var p = /* @__PURE__ */ i({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "BaseRadioGroup",
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {},
|
|
9
|
+
modelModifiers: {}
|
|
10
|
+
},
|
|
11
|
+
emits: ["update:modelValue"],
|
|
12
|
+
setup(i) {
|
|
13
|
+
let p = f(i, "modelValue"), m = u(), h = d();
|
|
14
|
+
return c(t, {
|
|
15
|
+
model: p,
|
|
16
|
+
name: n(() => typeof m.name == "string" ? m.name : h)
|
|
17
|
+
}), c(e, null), (e, t) => (s(), r("fieldset", o(a(e.$attrs)), [l(e.$slots, "default")], 16));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { p as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { fieldKey as e } from "./internal/keys.js";
|
|
2
|
+
import { computed as t, createElementBlock as n, defineComponent as r, inject as i, mergeProps as a, openBlock as o, renderSlot as s, useAttrs as c, useId as l, useModel as u, vModelSelect as d, withDirectives as f } from "vue";
|
|
3
|
+
//#region src/components/BaseSelect.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var p = ["id"], m = /* @__PURE__ */ r({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "BaseSelect",
|
|
7
|
+
props: {
|
|
8
|
+
modelValue: {},
|
|
9
|
+
modelModifiers: {}
|
|
10
|
+
},
|
|
11
|
+
emits: ["update:modelValue"],
|
|
12
|
+
setup(r) {
|
|
13
|
+
let m = u(r, "modelValue"), h = c(), g = l(), _ = i(e, null), v = t(() => typeof h.id == "string" ? h.id : _?.id.value ?? g);
|
|
14
|
+
return (e, t) => f((o(), n("select", a(e.$attrs, {
|
|
15
|
+
id: v.value,
|
|
16
|
+
"onUpdate:modelValue": t[0] ||= (e) => m.value = e
|
|
17
|
+
}), [s(e.$slots, "default")], 16, p)), [[d, m.value]]);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { m as default };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type __VLS_PublicProps = {
|
|
2
2
|
modelValue?: string | number;
|
|
3
|
+
'modelModifiers'?: Partial<Record<'trim' | 'number' | 'lazy', true>>;
|
|
3
4
|
};
|
|
4
5
|
declare const _default: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
5
6
|
"update:modelValue": (value: string | number) => any;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { fieldKey as e } from "./internal/keys.js";
|
|
2
|
+
import { applyModelModifiers as t } from "./internal/modifiers.js";
|
|
3
|
+
import { computed as n, createElementBlock as r, defineComponent as i, inject as a, isRef as o, mergeProps as s, openBlock as c, unref as l, useAttrs as u, useId as d, useModel as f, vModelText as p, withDirectives as m } from "vue";
|
|
4
|
+
//#region src/components/BaseTextarea.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var h = ["id"], g = ["id"], _ = /* @__PURE__ */ i({
|
|
6
|
+
inheritAttrs: !1,
|
|
7
|
+
__name: "BaseTextarea",
|
|
8
|
+
props: {
|
|
9
|
+
modelValue: {},
|
|
10
|
+
modelModifiers: {}
|
|
11
|
+
},
|
|
12
|
+
emits: ["update:modelValue"],
|
|
13
|
+
setup(i) {
|
|
14
|
+
let [_, v] = f(i, "modelValue", { set: (e) => t(e, v) }), y = u(), b = d(), x = a(e, null), S = n(() => typeof y.id == "string" ? y.id : x?.id.value ?? b);
|
|
15
|
+
return (e, t) => l(v).lazy ? m((c(), r("textarea", s({ key: 0 }, e.$attrs, {
|
|
16
|
+
id: S.value,
|
|
17
|
+
"onUpdate:modelValue": t[0] ||= (e) => o(_) ? _.value = e : null
|
|
18
|
+
}), null, 16, h)), [[
|
|
19
|
+
p,
|
|
20
|
+
l(_),
|
|
21
|
+
void 0,
|
|
22
|
+
{ lazy: !0 }
|
|
23
|
+
]]) : m((c(), r("textarea", s({ key: 1 }, e.$attrs, {
|
|
24
|
+
id: S.value,
|
|
25
|
+
"onUpdate:modelValue": t[1] ||= (e) => o(_) ? _.value = e : null
|
|
26
|
+
}), null, 16, g)), [[p, l(_)]]);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
export { _ as default };
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { InjectionKey, ModelRef, ComputedRef } from 'vue';
|
|
2
2
|
export interface RadioGroupContext {
|
|
3
|
-
model: ModelRef<
|
|
3
|
+
model: ModelRef<string | number | undefined>;
|
|
4
4
|
name: ComputedRef<string>;
|
|
5
5
|
}
|
|
6
6
|
export declare const radioGroupKey: InjectionKey<RadioGroupContext>;
|
|
7
7
|
export interface CheckboxGroupContext {
|
|
8
|
-
model: ModelRef<
|
|
8
|
+
model: ModelRef<(string | number)[]>;
|
|
9
9
|
name: ComputedRef<string>;
|
|
10
10
|
}
|
|
11
11
|
export declare const checkboxGroupKey: InjectionKey<CheckboxGroupContext>;
|
|
12
|
+
export interface FieldContext {
|
|
13
|
+
id: ComputedRef<string>;
|
|
14
|
+
}
|
|
15
|
+
export declare const fieldKey: InjectionKey<FieldContext | null>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/components/internal/modifiers.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
if (t.trim && typeof e == "string" && (e = e.trim()), t.number && typeof e == "string") {
|
|
4
|
+
let t = parseFloat(e);
|
|
5
|
+
e = isNaN(t) ? e : t;
|
|
6
|
+
}
|
|
7
|
+
return e;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { e as applyModelModifiers };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as CButton } from './components/BaseButton';
|
|
2
2
|
export { default as CCheckbox } from './components/BaseCheckbox';
|
|
3
3
|
export { default as CCheckboxGroup } from './components/BaseCheckboxGroup';
|
|
4
|
+
export { default as CField } from './components/BaseField';
|
|
4
5
|
export { default as CFile } from './components/BaseFile';
|
|
5
6
|
export { default as CForm } from './components/BaseForm';
|
|
6
7
|
export { default as CInput } from './components/BaseInput';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import e from "./components/BaseButton.js";
|
|
2
|
+
import t from "./components/BaseCheckbox.js";
|
|
3
|
+
import n from "./components/BaseCheckboxGroup.js";
|
|
4
|
+
import r from "./components/BaseField.js";
|
|
5
|
+
import i from "./components/BaseFile.js";
|
|
6
|
+
import a from "./components/BaseForm.js";
|
|
7
|
+
import o from "./components/BaseInput.js";
|
|
8
|
+
import s from "./components/BaseLabel.js";
|
|
9
|
+
import c from "./components/BaseRadio.js";
|
|
10
|
+
import l from "./components/BaseRadioGroup.js";
|
|
11
|
+
import u from "./components/BaseSelect.js";
|
|
12
|
+
import d from "./components/BaseTextarea.js";
|
|
13
|
+
export { e as CButton, t as CCheckbox, n as CCheckboxGroup, r as CField, i as CFile, a as CForm, o as CInput, s as CLabel, c as CRadio, l as CRadioGroup, u as CSelect, d as CTextarea };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charpente-ui/vue",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Charpente UI is a headless Vue component library.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -10,21 +10,23 @@
|
|
|
10
10
|
"build": "vite build",
|
|
11
11
|
"test": "vitest",
|
|
12
12
|
"test:coverage": "vitest run --coverage",
|
|
13
|
-
"prepare": "husky
|
|
13
|
+
"prepare": "husky",
|
|
14
|
+
"prepack": "npm run build",
|
|
14
15
|
"release": "semantic-release"
|
|
15
16
|
},
|
|
16
17
|
"engines": {
|
|
17
18
|
"node": ">=20"
|
|
18
19
|
},
|
|
19
|
-
"main": "./dist/
|
|
20
|
-
"module": "./dist/
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
21
22
|
"types": "./dist/index.d.ts",
|
|
22
23
|
"exports": {
|
|
23
24
|
".": {
|
|
24
25
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"import": "./dist/
|
|
26
|
-
"
|
|
27
|
-
}
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"@commitlint/cli": "^20.4.2",
|
package/dist/charpente.js
DELETED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { computed as e, createBlock as t, createElementBlock as n, defineComponent as r, guardReactiveProps as i, inject as a, isRef as o, mergeModels as s, mergeProps as c, normalizeProps as l, openBlock as u, provide as d, renderSlot as f, resolveDynamicComponent as p, unref as m, useAttrs as h, useId as g, useModel as _, useTemplateRef as v, vModelCheckbox as y, vModelDynamic as b, vModelRadio as x, vModelSelect as S, vModelText as C, watch as w, watchPostEffect as T, withCtx as E, withDirectives as D, withModifiers as O } from "vue";
|
|
2
|
-
//#endregion
|
|
3
|
-
//#region src/components/BaseButton.vue
|
|
4
|
-
var k = /* @__PURE__ */ r({
|
|
5
|
-
inheritAttrs: !1,
|
|
6
|
-
__name: "BaseButton",
|
|
7
|
-
props: { as: { default: "button" } },
|
|
8
|
-
setup(e) {
|
|
9
|
-
return (n, r) => (u(), t(p(e.as), l(i(n.$attrs)), {
|
|
10
|
-
default: E(() => [f(n.$slots, "default")]),
|
|
11
|
-
_: 3
|
|
12
|
-
}, 16));
|
|
13
|
-
}
|
|
14
|
-
}), A = Symbol("CRadioGroup"), j = Symbol("CCheckboxGroup"), M = [
|
|
15
|
-
"id",
|
|
16
|
-
"name",
|
|
17
|
-
"value"
|
|
18
|
-
], N = /* @__PURE__ */ r({
|
|
19
|
-
inheritAttrs: !1,
|
|
20
|
-
__name: "BaseCheckbox",
|
|
21
|
-
props: /* @__PURE__ */ s({
|
|
22
|
-
value: {},
|
|
23
|
-
indeterminate: { type: Boolean }
|
|
24
|
-
}, {
|
|
25
|
-
modelValue: { type: [Boolean, Array] },
|
|
26
|
-
modelModifiers: {}
|
|
27
|
-
}),
|
|
28
|
-
emits: ["update:modelValue"],
|
|
29
|
-
setup(t) {
|
|
30
|
-
let r = t, i = _(t, "modelValue"), s = a(j, null), l = s ? s.model : i, d = h(), f = g(), p = v("input"), b = e(() => typeof d.id == "string" ? d.id : f), x = e(() => typeof d.name == "string" ? d.name : s?.name.value);
|
|
31
|
-
return T(() => {
|
|
32
|
-
p.value && (p.value.indeterminate = !!r.indeterminate);
|
|
33
|
-
}), (e, r) => D((u(), n("input", c(e.$attrs, {
|
|
34
|
-
id: b.value,
|
|
35
|
-
ref: "input",
|
|
36
|
-
"onUpdate:modelValue": r[0] ||= (e) => o(l) ? l.value = e : null,
|
|
37
|
-
name: x.value,
|
|
38
|
-
type: "checkbox",
|
|
39
|
-
value: t.value
|
|
40
|
-
}), null, 16, M)), [[y, m(l)]]);
|
|
41
|
-
}
|
|
42
|
-
}), P = /* @__PURE__ */ r({
|
|
43
|
-
inheritAttrs: !1,
|
|
44
|
-
__name: "BaseCheckboxGroup",
|
|
45
|
-
props: {
|
|
46
|
-
modelValue: { default: () => [] },
|
|
47
|
-
modelModifiers: {}
|
|
48
|
-
},
|
|
49
|
-
emits: ["update:modelValue"],
|
|
50
|
-
setup(t) {
|
|
51
|
-
let r = _(t, "modelValue"), a = h(), o = g();
|
|
52
|
-
return d(j, {
|
|
53
|
-
model: r,
|
|
54
|
-
name: e(() => typeof a.name == "string" ? a.name : o)
|
|
55
|
-
}), (e, t) => (u(), n("fieldset", l(i(e.$attrs)), [f(e.$slots, "default")], 16));
|
|
56
|
-
}
|
|
57
|
-
}), F = ["id"], I = /* @__PURE__ */ r({
|
|
58
|
-
inheritAttrs: !1,
|
|
59
|
-
__name: "BaseFile",
|
|
60
|
-
props: {
|
|
61
|
-
modelValue: {},
|
|
62
|
-
modelModifiers: {}
|
|
63
|
-
},
|
|
64
|
-
emits: ["update:modelValue"],
|
|
65
|
-
setup(t) {
|
|
66
|
-
let r = _(t, "modelValue"), i = h(), a = g(), o = v("input"), s = e(() => typeof i.id == "string" ? i.id : a);
|
|
67
|
-
function l(e) {
|
|
68
|
-
r.value = e.target.files;
|
|
69
|
-
}
|
|
70
|
-
return w(r, (e) => {
|
|
71
|
-
!e && o.value && (o.value.value = "");
|
|
72
|
-
}), (e, t) => (u(), n("input", c(e.$attrs, {
|
|
73
|
-
id: s.value,
|
|
74
|
-
ref: "input",
|
|
75
|
-
type: "file",
|
|
76
|
-
onChange: l
|
|
77
|
-
}), null, 16, F));
|
|
78
|
-
}
|
|
79
|
-
}), L = ["id"], R = /* @__PURE__ */ r({
|
|
80
|
-
inheritAttrs: !1,
|
|
81
|
-
__name: "BaseForm",
|
|
82
|
-
emits: ["submit"],
|
|
83
|
-
setup(t, { emit: r }) {
|
|
84
|
-
let i = h(), a = g(), o = r, s = e(() => typeof i.id == "string" ? i.id : a);
|
|
85
|
-
return (e, t) => (u(), n("form", c(e.$attrs, {
|
|
86
|
-
id: s.value,
|
|
87
|
-
onSubmit: t[0] ||= O((e) => o("submit", e), ["prevent"])
|
|
88
|
-
}), [f(e.$slots, "default")], 16, L));
|
|
89
|
-
}
|
|
90
|
-
}), z = ["id"], B = /* @__PURE__ */ r({
|
|
91
|
-
inheritAttrs: !1,
|
|
92
|
-
__name: "BaseInput",
|
|
93
|
-
props: {
|
|
94
|
-
modelValue: {},
|
|
95
|
-
modelModifiers: {}
|
|
96
|
-
},
|
|
97
|
-
emits: ["update:modelValue"],
|
|
98
|
-
setup(t) {
|
|
99
|
-
let r = _(t, "modelValue"), i = h(), a = g(), o = e(() => typeof i.id == "string" ? i.id : a);
|
|
100
|
-
return (e, t) => D((u(), n("input", c(e.$attrs, {
|
|
101
|
-
id: o.value,
|
|
102
|
-
"onUpdate:modelValue": t[0] ||= (e) => r.value = e
|
|
103
|
-
}), null, 16, z)), [[b, r.value]]);
|
|
104
|
-
}
|
|
105
|
-
}), V = ["for"], H = /* @__PURE__ */ r({
|
|
106
|
-
inheritAttrs: !1,
|
|
107
|
-
__name: "BaseLabel",
|
|
108
|
-
props: { for: {} },
|
|
109
|
-
setup(e) {
|
|
110
|
-
let t = e;
|
|
111
|
-
return (e, r) => (u(), n("label", c(e.$attrs, { for: t.for }), [f(e.$slots, "default")], 16, V));
|
|
112
|
-
}
|
|
113
|
-
}), U = [
|
|
114
|
-
"id",
|
|
115
|
-
"name",
|
|
116
|
-
"value"
|
|
117
|
-
], W = /* @__PURE__ */ r({
|
|
118
|
-
inheritAttrs: !1,
|
|
119
|
-
__name: "BaseRadio",
|
|
120
|
-
props: /* @__PURE__ */ s({ value: {} }, {
|
|
121
|
-
modelValue: {},
|
|
122
|
-
modelModifiers: {}
|
|
123
|
-
}),
|
|
124
|
-
emits: ["update:modelValue"],
|
|
125
|
-
setup(t) {
|
|
126
|
-
let r = _(t, "modelValue"), i = a(A, null), s = i ? i.model : r, l = h(), d = g(), f = e(() => typeof l.id == "string" ? l.id : d), p = e(() => typeof l.name == "string" ? l.name : i?.name.value);
|
|
127
|
-
return (e, r) => D((u(), n("input", c(e.$attrs, {
|
|
128
|
-
id: f.value,
|
|
129
|
-
"onUpdate:modelValue": r[0] ||= (e) => o(s) ? s.value = e : null,
|
|
130
|
-
name: p.value,
|
|
131
|
-
value: t.value,
|
|
132
|
-
type: "radio"
|
|
133
|
-
}), null, 16, U)), [[x, m(s)]]);
|
|
134
|
-
}
|
|
135
|
-
}), G = /* @__PURE__ */ r({
|
|
136
|
-
inheritAttrs: !1,
|
|
137
|
-
__name: "BaseRadioGroup",
|
|
138
|
-
props: {
|
|
139
|
-
modelValue: {},
|
|
140
|
-
modelModifiers: {}
|
|
141
|
-
},
|
|
142
|
-
emits: ["update:modelValue"],
|
|
143
|
-
setup(t) {
|
|
144
|
-
let r = _(t, "modelValue"), a = h(), o = g();
|
|
145
|
-
return d(A, {
|
|
146
|
-
model: r,
|
|
147
|
-
name: e(() => typeof a.name == "string" ? a.name : o)
|
|
148
|
-
}), (e, t) => (u(), n("fieldset", l(i(e.$attrs)), [f(e.$slots, "default")], 16));
|
|
149
|
-
}
|
|
150
|
-
}), K = ["id"], q = /* @__PURE__ */ r({
|
|
151
|
-
inheritAttrs: !1,
|
|
152
|
-
__name: "BaseSelect",
|
|
153
|
-
props: {
|
|
154
|
-
modelValue: {},
|
|
155
|
-
modelModifiers: {}
|
|
156
|
-
},
|
|
157
|
-
emits: ["update:modelValue"],
|
|
158
|
-
setup(t) {
|
|
159
|
-
let r = _(t, "modelValue"), i = h(), a = g(), o = e(() => typeof i.id == "string" ? i.id : a);
|
|
160
|
-
return (e, t) => D((u(), n("select", c(e.$attrs, {
|
|
161
|
-
id: o.value,
|
|
162
|
-
"onUpdate:modelValue": t[0] ||= (e) => r.value = e
|
|
163
|
-
}), [f(e.$slots, "default")], 16, K)), [[S, r.value]]);
|
|
164
|
-
}
|
|
165
|
-
}), J = ["id"], Y = /* @__PURE__ */ r({
|
|
166
|
-
inheritAttrs: !1,
|
|
167
|
-
__name: "BaseTextarea",
|
|
168
|
-
props: {
|
|
169
|
-
modelValue: {},
|
|
170
|
-
modelModifiers: {}
|
|
171
|
-
},
|
|
172
|
-
emits: ["update:modelValue"],
|
|
173
|
-
setup(t) {
|
|
174
|
-
let r = _(t, "modelValue"), i = h(), a = g(), o = e(() => typeof i.id == "string" ? i.id : a);
|
|
175
|
-
return (e, t) => D((u(), n("textarea", c(e.$attrs, {
|
|
176
|
-
id: o.value,
|
|
177
|
-
"onUpdate:modelValue": t[0] ||= (e) => r.value = e
|
|
178
|
-
}), null, 16, J)), [[C, r.value]]);
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
//#endregion
|
|
182
|
-
export { k as CButton, N as CCheckbox, P as CCheckboxGroup, I as CFile, R as CForm, B as CInput, H as CLabel, W as CRadio, G as CRadioGroup, q as CSelect, Y as CTextarea };
|
package/dist/charpente.umd.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`)):typeof define==`function`&&define.amd?define([`exports`,`vue`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.Charpente={},e.Vue))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseButton`,props:{as:{default:`button`}},setup(e){return(n,r)=>((0,t.openBlock)(),(0,t.createBlock)((0,t.resolveDynamicComponent)(e.as),(0,t.normalizeProps)((0,t.guardReactiveProps)(n.$attrs)),{default:(0,t.withCtx)(()=>[(0,t.renderSlot)(n.$slots,`default`)]),_:3},16))}}),r=Symbol(`CRadioGroup`),i=Symbol(`CCheckboxGroup`),a=[`id`,`name`,`value`],o=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseCheckbox`,props:(0,t.mergeModels)({value:{},indeterminate:{type:Boolean}},{modelValue:{type:[Boolean,Array]},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let n=e,r=(0,t.useModel)(e,`modelValue`),o=(0,t.inject)(i,null),s=o?o.model:r,c=(0,t.useAttrs)(),l=(0,t.useId)(),u=(0,t.useTemplateRef)(`input`),d=(0,t.computed)(()=>typeof c.id==`string`?c.id:l),f=(0,t.computed)(()=>typeof c.name==`string`?c.name:o?.name.value);return(0,t.watchPostEffect)(()=>{u.value&&(u.value.indeterminate=!!n.indeterminate)}),(n,r)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`input`,(0,t.mergeProps)(n.$attrs,{id:d.value,ref:`input`,"onUpdate:modelValue":r[0]||=e=>(0,t.isRef)(s)?s.value=e:null,name:f.value,type:`checkbox`,value:e.value}),null,16,a)),[[t.vModelCheckbox,(0,t.unref)(s)]])}}),s=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseCheckboxGroup`,props:{modelValue:{default:()=>[]},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let n=(0,t.useModel)(e,`modelValue`),r=(0,t.useAttrs)(),a=(0,t.useId)();return(0,t.provide)(i,{model:n,name:(0,t.computed)(()=>typeof r.name==`string`?r.name:a)}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`fieldset`,(0,t.normalizeProps)((0,t.guardReactiveProps)(e.$attrs)),[(0,t.renderSlot)(e.$slots,`default`)],16))}}),c=[`id`],l=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseFile`,props:{modelValue:{},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let n=(0,t.useModel)(e,`modelValue`),r=(0,t.useAttrs)(),i=(0,t.useId)(),a=(0,t.useTemplateRef)(`input`),o=(0,t.computed)(()=>typeof r.id==`string`?r.id:i);function s(e){n.value=e.target.files}return(0,t.watch)(n,e=>{!e&&a.value&&(a.value.value=``)}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`input`,(0,t.mergeProps)(e.$attrs,{id:o.value,ref:`input`,type:`file`,onChange:s}),null,16,c))}}),u=[`id`],d=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseForm`,emits:[`submit`],setup(e,{emit:n}){let r=(0,t.useAttrs)(),i=(0,t.useId)(),a=n,o=(0,t.computed)(()=>typeof r.id==`string`?r.id:i);return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`form`,(0,t.mergeProps)(e.$attrs,{id:o.value,onSubmit:n[0]||=(0,t.withModifiers)(e=>a(`submit`,e),[`prevent`])}),[(0,t.renderSlot)(e.$slots,`default`)],16,u))}}),f=[`id`],p=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseInput`,props:{modelValue:{},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let n=(0,t.useModel)(e,`modelValue`),r=(0,t.useAttrs)(),i=(0,t.useId)(),a=(0,t.computed)(()=>typeof r.id==`string`?r.id:i);return(e,r)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`input`,(0,t.mergeProps)(e.$attrs,{id:a.value,"onUpdate:modelValue":r[0]||=e=>n.value=e}),null,16,f)),[[t.vModelDynamic,n.value]])}}),m=[`for`],h=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseLabel`,props:{for:{}},setup(e){let n=e;return(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`label`,(0,t.mergeProps)(e.$attrs,{for:n.for}),[(0,t.renderSlot)(e.$slots,`default`)],16,m))}}),g=[`id`,`name`,`value`],_=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseRadio`,props:(0,t.mergeModels)({value:{}},{modelValue:{},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let n=(0,t.useModel)(e,`modelValue`),i=(0,t.inject)(r,null),a=i?i.model:n,o=(0,t.useAttrs)(),s=(0,t.useId)(),c=(0,t.computed)(()=>typeof o.id==`string`?o.id:s),l=(0,t.computed)(()=>typeof o.name==`string`?o.name:i?.name.value);return(n,r)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`input`,(0,t.mergeProps)(n.$attrs,{id:c.value,"onUpdate:modelValue":r[0]||=e=>(0,t.isRef)(a)?a.value=e:null,name:l.value,value:e.value,type:`radio`}),null,16,g)),[[t.vModelRadio,(0,t.unref)(a)]])}}),v=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseRadioGroup`,props:{modelValue:{},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let n=(0,t.useModel)(e,`modelValue`),i=(0,t.useAttrs)(),a=(0,t.useId)();return(0,t.provide)(r,{model:n,name:(0,t.computed)(()=>typeof i.name==`string`?i.name:a)}),(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`fieldset`,(0,t.normalizeProps)((0,t.guardReactiveProps)(e.$attrs)),[(0,t.renderSlot)(e.$slots,`default`)],16))}}),y=[`id`],b=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseSelect`,props:{modelValue:{},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let n=(0,t.useModel)(e,`modelValue`),r=(0,t.useAttrs)(),i=(0,t.useId)(),a=(0,t.computed)(()=>typeof r.id==`string`?r.id:i);return(e,r)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`select`,(0,t.mergeProps)(e.$attrs,{id:a.value,"onUpdate:modelValue":r[0]||=e=>n.value=e}),[(0,t.renderSlot)(e.$slots,`default`)],16,y)),[[t.vModelSelect,n.value]])}}),x=[`id`],S=(0,t.defineComponent)({inheritAttrs:!1,__name:`BaseTextarea`,props:{modelValue:{},modelModifiers:{}},emits:[`update:modelValue`],setup(e){let n=(0,t.useModel)(e,`modelValue`),r=(0,t.useAttrs)(),i=(0,t.useId)(),a=(0,t.computed)(()=>typeof r.id==`string`?r.id:i);return(e,r)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`textarea`,(0,t.mergeProps)(e.$attrs,{id:a.value,"onUpdate:modelValue":r[0]||=e=>n.value=e}),null,16,x)),[[t.vModelText,n.value]])}});e.CButton=n,e.CCheckbox=o,e.CCheckboxGroup=s,e.CFile=l,e.CForm=d,e.CInput=p,e.CLabel=h,e.CRadio=_,e.CRadioGroup=v,e.CSelect=b,e.CTextarea=S});
|