@charpente-ui/vue 1.6.0 → 2.1.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 +158 -9
- 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 +40 -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 +31 -0
- package/dist/components/BaseFile.js +5 -0
- package/dist/components/BaseFile.vue?vue&type=script&setup=true&lang.js +34 -0
- package/dist/components/BaseForm.d.ts +6 -3
- package/dist/components/BaseForm.js +5 -0
- package/dist/components/BaseForm.vue?vue&type=script&setup=true&lang.js +35 -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 +42 -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 +33 -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 +27 -0
- package/dist/components/BaseSupportingText.d.ts +20 -0
- package/dist/components/BaseSupportingText.js +5 -0
- package/dist/components/BaseSupportingText.vue?vue&type=script&setup=true&lang.js +18 -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 +42 -0
- package/dist/components/internal/field.d.ts +5 -0
- package/dist/components/internal/field.js +13 -0
- package/dist/components/internal/keys.d.ts +9 -3
- 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 +2 -0
- package/dist/index.js +14 -0
- package/package.json +9 -7
- package/dist/charpente.js +0 -182
- package/dist/charpente.umd.cjs +0 -1
package/README.md
CHANGED
|
@@ -51,31 +51,48 @@ npm run dev
|
|
|
51
51
|
```vue
|
|
52
52
|
<script setup>
|
|
53
53
|
import { ref } from 'vue';
|
|
54
|
-
import {
|
|
54
|
+
import { CForm, CField, CLabel, CInput, CSupportingText, CButton } from '@charpente-ui/vue';
|
|
55
55
|
|
|
56
56
|
const email = ref('');
|
|
57
|
+
|
|
58
|
+
function onSubmit() {
|
|
59
|
+
// Only called once the form passes native validation.
|
|
60
|
+
}
|
|
57
61
|
</script>
|
|
58
62
|
|
|
59
63
|
<template>
|
|
60
|
-
<
|
|
61
|
-
<
|
|
64
|
+
<CForm validate @submit="onSubmit">
|
|
65
|
+
<CField class="form-group">
|
|
66
|
+
<CLabel>Email Address</CLabel>
|
|
67
|
+
|
|
68
|
+
<CInput v-model="email" type="email" placeholder="hello@world.com" required
|
|
69
|
+
class="my-custom-input-style"/>
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
<CSupportingText validation>We never share your email.</CSupportingText>
|
|
72
|
+
</CField>
|
|
65
73
|
|
|
66
|
-
<CButton
|
|
74
|
+
<CButton type="submit" class="btn-primary">
|
|
67
75
|
Subscribe
|
|
68
76
|
</CButton>
|
|
69
|
-
</
|
|
77
|
+
</CForm>
|
|
70
78
|
</template>
|
|
71
79
|
```
|
|
72
80
|
|
|
81
|
+
No `for`/`id` wiring, no validation library: the label, the hint and the browser-localized error messages are linked
|
|
82
|
+
and accessible automatically — and every class lands on the native element, ready for your CSS.
|
|
83
|
+
|
|
73
84
|
## Component Reference
|
|
74
85
|
|
|
75
86
|
1. **Form Inputs** **(CInput, CTextarea, CSelect)**
|
|
76
87
|
|
|
77
88
|
These components are thin wrappers around native elements. They use `v-model` and automatically link with labels via
|
|
78
|
-
`useId()`. Full attribute inheritance.
|
|
89
|
+
`useId()`. Full attribute inheritance. `CInput` and `CTextarea` support the native `v-model` modifiers:
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<CInput v-model.trim="name"/>
|
|
93
|
+
<CInput v-model.number="age"/>
|
|
94
|
+
<CInput v-model.lazy="query"/>
|
|
95
|
+
```
|
|
79
96
|
|
|
80
97
|
2. **Selection Logic** _(CCheckbox, CRadio, CSelect)_
|
|
81
98
|
|
|
@@ -133,6 +150,12 @@ individual inputs:
|
|
|
133
150
|
<CRadioGroup v-model="selected" name="my-group">...</CRadioGroup>
|
|
134
151
|
```
|
|
135
152
|
|
|
153
|
+
> [!NOTE]
|
|
154
|
+
> Standalone `CRadio` and `CCheckbox` accept any `value` (strings, numbers, booleans, objects — `v-model` compares by
|
|
155
|
+
> reference, as in native Vue). Inside a group, the group `v-model` is typed `string | number`
|
|
156
|
+
> (`(string | number)[]` for checkboxes): stick to those value types in grouped mode, as TypeScript cannot enforce it
|
|
157
|
+
> on the `value` prop without dropping standalone object support.
|
|
158
|
+
|
|
136
159
|
4. **Polymorphic Elements** _(CButton)_
|
|
137
160
|
|
|
138
161
|
The button can change its HTML tag while keeping its behavior.
|
|
@@ -142,6 +165,89 @@ The button can change its HTML tag while keeping its behavior.
|
|
|
142
165
|
<CButton as="RouterLink" to="/dashboard">Dashboard</CButton>
|
|
143
166
|
```
|
|
144
167
|
|
|
168
|
+
When rendering a native `<button>`, `CButton` defaults to `type="button"` (instead of the native `type="submit"`) to
|
|
169
|
+
avoid accidental form submissions. Pass `type="submit"` explicitly for submit buttons.
|
|
170
|
+
|
|
171
|
+
5. **Field Wrapper** _(CField)_
|
|
172
|
+
|
|
173
|
+
`CField` links a label and an input automatically: it provides a shared auto-generated id that `CLabel` picks up as
|
|
174
|
+
`for` and the wrapped input picks up as `id` — no manual wiring.
|
|
175
|
+
|
|
176
|
+
```vue
|
|
177
|
+
<CField>
|
|
178
|
+
<CLabel>Email</CLabel>
|
|
179
|
+
<CInput v-model="email" type="email"/>
|
|
180
|
+
</CField>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`CSupportingText` renders a field's hint or error text inside a `CField`: the input automatically gets an
|
|
184
|
+
`aria-describedby` pointing to it, and the attribute is removed when the text unmounts (e.g. behind a `v-if`).
|
|
185
|
+
|
|
186
|
+
```vue
|
|
187
|
+
<CField>
|
|
188
|
+
<CLabel>Email</CLabel>
|
|
189
|
+
<CInput v-model="email" type="email"/>
|
|
190
|
+
<CSupportingText v-if="error">{{ error }}</CSupportingText>
|
|
191
|
+
</CField>
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
An explicit `aria-describedby` on the input always wins, and a standalone `CSupportingText` (outside a field)
|
|
195
|
+
simply renders its content with an id. Likewise, an explicit `id` on the input or `for` on the label always wins
|
|
196
|
+
over the field id.
|
|
197
|
+
|
|
198
|
+
Passing `id` to `CField` itself names that pairing instead of the wrapper `<div>` — reusing it on both would put
|
|
199
|
+
the same id on two different DOM elements:
|
|
200
|
+
|
|
201
|
+
```vue
|
|
202
|
+
<CField id="email-field">
|
|
203
|
+
<CLabel>Email</CLabel>
|
|
204
|
+
<CInput v-model="email" type="email"/>
|
|
205
|
+
</CField>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Renders `<label for="email-field">` and `<input id="email-field">`; the `<div>` itself gets no `id`. Use `class`
|
|
209
|
+
to target the wrapper.
|
|
210
|
+
|
|
211
|
+
A `CField` wrapping a whole group is ignored by the items (a single id must not land on every input); wrap each
|
|
212
|
+
item in its own `CField` instead:
|
|
213
|
+
|
|
214
|
+
```vue
|
|
215
|
+
<CRadioGroup v-model="selected">
|
|
216
|
+
<CField>
|
|
217
|
+
<CLabel>Option A</CLabel>
|
|
218
|
+
<CRadio value="a"/>
|
|
219
|
+
</CField>
|
|
220
|
+
|
|
221
|
+
<CField>
|
|
222
|
+
<CLabel>Option B</CLabel>
|
|
223
|
+
<CRadio value="b"/>
|
|
224
|
+
</CField>
|
|
225
|
+
</CRadioGroup>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
6. **Native Validation** _(CForm + CField + CSupportingText)_
|
|
229
|
+
|
|
230
|
+
Browsers already validate forms (`required`, `type="email"`, `minlength`, `pattern`…) and localize their error
|
|
231
|
+
messages for free. Charpente UI exposes that instead of reinventing it — opt in with the `validate` prop:
|
|
232
|
+
|
|
233
|
+
```vue
|
|
234
|
+
<CForm validate @submit="onSubmit">
|
|
235
|
+
<CField>
|
|
236
|
+
<CLabel>Email</CLabel>
|
|
237
|
+
<CInput v-model="email" type="email" required/>
|
|
238
|
+
<CSupportingText validation>We never share your email.</CSupportingText>
|
|
239
|
+
</CField>
|
|
240
|
+
</CForm>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
- `CForm validate` suppresses the native bubbles (`novalidate`), blocks `submit` until the form is valid, and
|
|
244
|
+
focuses the first invalid control.
|
|
245
|
+
- Errors appear after the first submit attempt, then update live as the user fixes the value.
|
|
246
|
+
- `CSupportingText validation` shows the browser's localized `validationMessage` while invalid, and falls back to
|
|
247
|
+
its slot content otherwise. The control also gets `aria-invalid` automatically.
|
|
248
|
+
- Without `validate`, nothing changes — bring your own validation library if you need cross-field or async rules.
|
|
249
|
+
Native escapes still work: `formnovalidate` on a submit button skips validation for that button.
|
|
250
|
+
|
|
145
251
|
## Components
|
|
146
252
|
|
|
147
253
|
| Name | Core Logic | Tag | Status |
|
|
@@ -149,11 +255,54 @@ The button can change its HTML tag while keeping its behavior.
|
|
|
149
255
|
| Button | **Polymorphic:** Switches tags _(a, button, etc...)_ while keeping logic. | `CButton` | Ready |
|
|
150
256
|
| Checkbox | **Smart Toggle:** Handles array state, booleans, and indeterminate natively. | `CCheckbox` | Ready |
|
|
151
257
|
| CheckboxGroup | **Group:** Shared v-model and name across checkboxes inside a fieldset. | `CCheckboxGroup` | Ready |
|
|
258
|
+
| Field | **Wrapper:** Auto-links a label and an input via a shared generated id. | `CField` | Ready |
|
|
152
259
|
| File | **File Input:** Reactive file selection with `v-model` support. | `CFile` | Ready |
|
|
153
|
-
| Form | **Auto-Submit:**
|
|
260
|
+
| Form | **Auto-Submit:** `preventDefault` handling and opt-in native validation. | `CForm` | Ready |
|
|
154
261
|
| Input | **Auto-ID:** Auto-links to labels via `useId()` and full attributes inheritance. | `CInput` | Ready |
|
|
155
262
|
| Label | **Context-Aware:** Simple, accessible binding for any input. | `CLabel` | Ready |
|
|
156
263
|
| Radio | **Selection:** Minimalist wrapper for native radio input. | `CRadio` | Ready |
|
|
157
264
|
| RadioGroup | **Group:** Shared v-model and name across radios inside a fieldset. | `CRadioGroup` | Ready |
|
|
158
265
|
| Select | **Native Wrapper:** Single and multiple selection support. | `CSelect` | Ready |
|
|
266
|
+
| SupportingText | **Field Text:** Hint or error text wired to its input via `aria-describedby`. | `CSupportingText` | Ready |
|
|
159
267
|
| Textarea | **Flexible Binding:** Auto-ID and reactive model management. | `CTextarea` | Ready |
|
|
268
|
+
|
|
269
|
+
## Wrapping Components
|
|
270
|
+
|
|
271
|
+
When wrapping a Charpente UI component inside your own, you must forward `$attrs` so that native HTML attributes
|
|
272
|
+
(`id`, `class`, `disabled`, etc.) reach the underlying element instead of landing on your wrapper's root node.
|
|
273
|
+
|
|
274
|
+
```vue
|
|
275
|
+
<script setup>
|
|
276
|
+
import { CField, CLabel, CSelect, CSupportingText } from '@charpente-ui/vue';
|
|
277
|
+
|
|
278
|
+
defineOptions({
|
|
279
|
+
inheritAttrs: false
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
defineProps({
|
|
283
|
+
label: String,
|
|
284
|
+
error: String
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const model = defineModel();
|
|
288
|
+
</script>
|
|
289
|
+
|
|
290
|
+
<template>
|
|
291
|
+
<CField>
|
|
292
|
+
<CLabel>{{ label }}</CLabel>
|
|
293
|
+
|
|
294
|
+
<CSelect v-bind="$attrs" v-model="model">
|
|
295
|
+
<slot/>
|
|
296
|
+
</CSelect>
|
|
297
|
+
|
|
298
|
+
<CSupportingText v-if="error">{{ error }}</CSupportingText>
|
|
299
|
+
</CField>
|
|
300
|
+
</template>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Why this matters:** Without `inheritAttrs: false`, Vue applies fallthrough attributes to the wrapper's root element
|
|
304
|
+
instead of the inner component. Adding `v-bind="$attrs"` on the Charpente component ensures attributes like `id`,
|
|
305
|
+
`class`, `required`, or `disabled` pass all the way through to the native HTML element. And since `CField` works by
|
|
306
|
+
provide/inject, the label, select and error stay linked across your wrapper's boundary — accessibility included.
|
|
307
|
+
|
|
308
|
+
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,40 @@
|
|
|
1
|
+
import { checkboxGroupKey as e } from "./internal/keys.js";
|
|
2
|
+
import { useFieldControl as t } from "./internal/field.js";
|
|
3
|
+
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, useModel as f, useTemplateRef as p, vModelCheckbox as m, watchPostEffect as h, withDirectives as g } from "vue";
|
|
4
|
+
//#region src/components/BaseCheckbox.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var _ = [
|
|
6
|
+
"id",
|
|
7
|
+
"aria-describedby",
|
|
8
|
+
"aria-invalid",
|
|
9
|
+
"name",
|
|
10
|
+
"value"
|
|
11
|
+
], v = /* @__PURE__ */ i({
|
|
12
|
+
inheritAttrs: !1,
|
|
13
|
+
__name: "BaseCheckbox",
|
|
14
|
+
props: /* @__PURE__ */ s({
|
|
15
|
+
value: {},
|
|
16
|
+
indeterminate: { type: Boolean }
|
|
17
|
+
}, {
|
|
18
|
+
modelValue: { type: [Boolean, Array] },
|
|
19
|
+
modelModifiers: {}
|
|
20
|
+
}),
|
|
21
|
+
emits: ["update:modelValue"],
|
|
22
|
+
setup(i) {
|
|
23
|
+
let s = i, v = f(i, "modelValue"), y = a(e, null), b = y ? y.model : v, x = d(), S = p("input"), { controlId: C, describedBy: w, ariaInvalid: T } = t(), E = n(() => typeof x.name == "string" ? x.name : y?.name.value);
|
|
24
|
+
return h(() => {
|
|
25
|
+
/* v8 ignore next 2 */
|
|
26
|
+
S.value && (S.value.indeterminate = !!s.indeterminate);
|
|
27
|
+
}), (e, t) => g((l(), r("input", c(e.$attrs, {
|
|
28
|
+
id: u(C),
|
|
29
|
+
ref: "input",
|
|
30
|
+
"onUpdate:modelValue": t[0] ||= (e) => o(b) ? b.value = e : null,
|
|
31
|
+
"aria-describedby": u(w),
|
|
32
|
+
"aria-invalid": u(T),
|
|
33
|
+
name: E.value,
|
|
34
|
+
type: "checkbox",
|
|
35
|
+
value: i.value
|
|
36
|
+
}), null, 16, _)), [[m, u(b)]]);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
//#endregion
|
|
40
|
+
export { v 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,31 @@
|
|
|
1
|
+
import { fieldKey as e } from "./internal/keys.js";
|
|
2
|
+
import { computed as t, createElementBlock as n, defineComponent as r, mergeProps as i, openBlock as a, provide as o, ref as s, renderSlot as c, useAttrs as l, useId as u } from "vue";
|
|
3
|
+
//#region src/components/BaseField.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var d = /* @__PURE__ */ r({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "BaseField",
|
|
7
|
+
setup(r) {
|
|
8
|
+
let d = l(), f = u(), p = s(), m = s(""), h = s(!1), g = t(() => typeof d.id == "string" ? d.id : f), _ = t(() => {
|
|
9
|
+
let e = { ...d };
|
|
10
|
+
return delete e.id, e;
|
|
11
|
+
});
|
|
12
|
+
o(e, {
|
|
13
|
+
id: g,
|
|
14
|
+
supportingTextId: p,
|
|
15
|
+
validationMessage: m
|
|
16
|
+
});
|
|
17
|
+
function v(e) {
|
|
18
|
+
h.value = !0, m.value = e.target.validationMessage;
|
|
19
|
+
}
|
|
20
|
+
function y(e) {
|
|
21
|
+
h.value && (m.value = e.target.validationMessage);
|
|
22
|
+
}
|
|
23
|
+
return (e, t) => (a(), n("div", i(_.value, {
|
|
24
|
+
onInvalidCapture: v,
|
|
25
|
+
onInputCapture: y,
|
|
26
|
+
onChangeCapture: y
|
|
27
|
+
}), [c(e.$slots, "default")], 16));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { d as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useFieldControl as e } from "./internal/field.js";
|
|
2
|
+
import { createElementBlock as t, defineComponent as n, mergeProps as r, openBlock as i, unref as a, useModel as o, useTemplateRef as s, watch as c } from "vue";
|
|
3
|
+
//#region src/components/BaseFile.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var l = [
|
|
5
|
+
"id",
|
|
6
|
+
"aria-describedby",
|
|
7
|
+
"aria-invalid"
|
|
8
|
+
], u = /* @__PURE__ */ n({
|
|
9
|
+
inheritAttrs: !1,
|
|
10
|
+
__name: "BaseFile",
|
|
11
|
+
props: {
|
|
12
|
+
modelValue: {},
|
|
13
|
+
modelModifiers: {}
|
|
14
|
+
},
|
|
15
|
+
emits: ["update:modelValue"],
|
|
16
|
+
setup(n) {
|
|
17
|
+
let u = o(n, "modelValue"), d = s("input"), { controlId: f, describedBy: p, ariaInvalid: m } = e();
|
|
18
|
+
function h(e) {
|
|
19
|
+
u.value = e.target.files;
|
|
20
|
+
}
|
|
21
|
+
return c(u, (e) => {
|
|
22
|
+
!e && d.value && (d.value.value = "");
|
|
23
|
+
}), (e, n) => (i(), t("input", r(e.$attrs, {
|
|
24
|
+
id: a(f),
|
|
25
|
+
ref: "input",
|
|
26
|
+
"aria-describedby": a(p),
|
|
27
|
+
"aria-invalid": a(m),
|
|
28
|
+
type: "file",
|
|
29
|
+
onChange: h
|
|
30
|
+
}), null, 16, l));
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
//#endregion
|
|
34
|
+
export { u as default };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
validate?: boolean;
|
|
3
|
+
};
|
|
1
4
|
declare function __VLS_template(): {
|
|
2
5
|
attrs: Partial<{}>;
|
|
3
6
|
slots: {
|
|
@@ -7,11 +10,11 @@ declare function __VLS_template(): {
|
|
|
7
10
|
rootEl: any;
|
|
8
11
|
};
|
|
9
12
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
10
|
-
declare const __VLS_component: import('vue').DefineComponent<
|
|
13
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
11
14
|
submit: (event: SubmitEvent) => any;
|
|
12
|
-
}, string, import('vue').PublicProps, Readonly<
|
|
15
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
13
16
|
onSubmit?: ((event: SubmitEvent) => any) | undefined;
|
|
14
|
-
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions,
|
|
17
|
+
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
15
18
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
16
19
|
export default _default;
|
|
17
20
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
@@ -0,0 +1,35 @@
|
|
|
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", "novalidate"], u = /* @__PURE__ */ n({
|
|
4
|
+
inheritAttrs: !1,
|
|
5
|
+
__name: "BaseForm",
|
|
6
|
+
props: { validate: { type: Boolean } },
|
|
7
|
+
emits: ["submit"],
|
|
8
|
+
setup(n, { emit: u }) {
|
|
9
|
+
let d = n, f = o(), p = s(), m = u, h = e(() => typeof f.id == "string" ? f.id : p);
|
|
10
|
+
function g(e) {
|
|
11
|
+
let t = e.target;
|
|
12
|
+
if (d.validate && !t.checkValidity()) {
|
|
13
|
+
_(t);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
m("submit", e);
|
|
17
|
+
}
|
|
18
|
+
function _(e) {
|
|
19
|
+
for (let t of Array.from(e.elements)) {
|
|
20
|
+
let e = t;
|
|
21
|
+
if (e.willValidate && !e.validity.valid) {
|
|
22
|
+
e.focus();
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return (e, o) => (i(), t("form", r(e.$attrs, {
|
|
28
|
+
id: h.value,
|
|
29
|
+
novalidate: n.validate || void 0,
|
|
30
|
+
onSubmit: c(g, ["prevent"])
|
|
31
|
+
}), [a(e.$slots, "default")], 16, l));
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
//#endregion
|
|
35
|
+
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,42 @@
|
|
|
1
|
+
import { useFieldControl as e } from "./internal/field.js";
|
|
2
|
+
import { applyModelModifiers as t } from "./internal/modifiers.js";
|
|
3
|
+
import { createElementBlock as n, defineComponent as r, isRef as i, mergeProps as a, openBlock as o, unref as s, useModel as c, vModelDynamic as l, withDirectives as u } from "vue";
|
|
4
|
+
//#region src/components/BaseInput.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var d = [
|
|
6
|
+
"id",
|
|
7
|
+
"aria-describedby",
|
|
8
|
+
"aria-invalid"
|
|
9
|
+
], f = [
|
|
10
|
+
"id",
|
|
11
|
+
"aria-describedby",
|
|
12
|
+
"aria-invalid"
|
|
13
|
+
], p = /* @__PURE__ */ r({
|
|
14
|
+
inheritAttrs: !1,
|
|
15
|
+
__name: "BaseInput",
|
|
16
|
+
props: {
|
|
17
|
+
modelValue: {},
|
|
18
|
+
modelModifiers: {}
|
|
19
|
+
},
|
|
20
|
+
emits: ["update:modelValue"],
|
|
21
|
+
setup(r) {
|
|
22
|
+
let [p, m] = c(r, "modelValue", { set: (e) => t(e, m) }), { controlId: h, describedBy: g, ariaInvalid: _ } = e();
|
|
23
|
+
return (e, t) => s(m).lazy ? u((o(), n("input", a({ key: 0 }, e.$attrs, {
|
|
24
|
+
id: s(h),
|
|
25
|
+
"onUpdate:modelValue": t[0] ||= (e) => i(p) ? p.value = e : null,
|
|
26
|
+
"aria-describedby": s(g),
|
|
27
|
+
"aria-invalid": s(_)
|
|
28
|
+
}), null, 16, d)), [[
|
|
29
|
+
l,
|
|
30
|
+
s(p),
|
|
31
|
+
void 0,
|
|
32
|
+
{ lazy: !0 }
|
|
33
|
+
]]) : u((o(), n("input", a({ key: 1 }, e.$attrs, {
|
|
34
|
+
id: s(h),
|
|
35
|
+
"onUpdate:modelValue": t[1] ||= (e) => i(p) ? p.value = e : null,
|
|
36
|
+
"aria-describedby": s(g),
|
|
37
|
+
"aria-invalid": s(_)
|
|
38
|
+
}), null, 16, f)), [[l, s(p)]]);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
//#endregion
|
|
42
|
+
export { p 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,33 @@
|
|
|
1
|
+
import { radioGroupKey as e } from "./internal/keys.js";
|
|
2
|
+
import { useFieldControl as t } from "./internal/field.js";
|
|
3
|
+
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, useModel as f, vModelRadio as p, withDirectives as m } from "vue";
|
|
4
|
+
//#region src/components/BaseRadio.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var h = [
|
|
6
|
+
"id",
|
|
7
|
+
"aria-describedby",
|
|
8
|
+
"aria-invalid",
|
|
9
|
+
"name",
|
|
10
|
+
"value"
|
|
11
|
+
], g = /* @__PURE__ */ i({
|
|
12
|
+
inheritAttrs: !1,
|
|
13
|
+
__name: "BaseRadio",
|
|
14
|
+
props: /* @__PURE__ */ s({ value: {} }, {
|
|
15
|
+
modelValue: {},
|
|
16
|
+
modelModifiers: {}
|
|
17
|
+
}),
|
|
18
|
+
emits: ["update:modelValue"],
|
|
19
|
+
setup(i) {
|
|
20
|
+
let s = f(i, "modelValue"), g = a(e, null), _ = g ? g.model : s, v = d(), { controlId: y, describedBy: b, ariaInvalid: x } = t(), S = n(() => typeof v.name == "string" ? v.name : g?.name.value);
|
|
21
|
+
return (e, t) => m((l(), r("input", c(e.$attrs, {
|
|
22
|
+
id: u(y),
|
|
23
|
+
"onUpdate:modelValue": t[0] ||= (e) => o(_) ? _.value = e : null,
|
|
24
|
+
"aria-describedby": u(b),
|
|
25
|
+
"aria-invalid": u(x),
|
|
26
|
+
name: S.value,
|
|
27
|
+
value: i.value,
|
|
28
|
+
type: "radio"
|
|
29
|
+
}), null, 16, h)), [[p, u(_)]]);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
export { g 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,27 @@
|
|
|
1
|
+
import { useFieldControl as e } from "./internal/field.js";
|
|
2
|
+
import { createElementBlock as t, defineComponent as n, mergeProps as r, openBlock as i, renderSlot as a, unref as o, useModel as s, vModelSelect as c, withDirectives as l } from "vue";
|
|
3
|
+
//#region src/components/BaseSelect.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var u = [
|
|
5
|
+
"id",
|
|
6
|
+
"aria-describedby",
|
|
7
|
+
"aria-invalid"
|
|
8
|
+
], d = /* @__PURE__ */ n({
|
|
9
|
+
inheritAttrs: !1,
|
|
10
|
+
__name: "BaseSelect",
|
|
11
|
+
props: {
|
|
12
|
+
modelValue: {},
|
|
13
|
+
modelModifiers: {}
|
|
14
|
+
},
|
|
15
|
+
emits: ["update:modelValue"],
|
|
16
|
+
setup(n) {
|
|
17
|
+
let d = s(n, "modelValue"), { controlId: f, describedBy: p, ariaInvalid: m } = e();
|
|
18
|
+
return (e, n) => l((i(), t("select", r(e.$attrs, {
|
|
19
|
+
id: o(f),
|
|
20
|
+
"onUpdate:modelValue": n[0] ||= (e) => d.value = e,
|
|
21
|
+
"aria-describedby": o(p),
|
|
22
|
+
"aria-invalid": o(m)
|
|
23
|
+
}), [a(e.$slots, "default")], 16, u)), [[c, d.value]]);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
//#endregion
|
|
27
|
+
export { d as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
validation?: boolean;
|
|
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_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
15
|
+
export default _default;
|
|
16
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
17
|
+
new (): {
|
|
18
|
+
$slots: S;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fieldKey as e } from "./internal/keys.js";
|
|
2
|
+
import { Fragment as t, computed as n, createElementBlock as r, createTextVNode as i, defineComponent as a, inject as o, mergeProps as s, onBeforeUnmount as c, openBlock as l, renderSlot as u, toDisplayString as d, useAttrs as f, useId as p, watchEffect as m } from "vue";
|
|
3
|
+
//#region src/components/BaseSupportingText.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var h = ["id"], g = /* @__PURE__ */ a({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "BaseSupportingText",
|
|
7
|
+
props: { validation: { type: Boolean } },
|
|
8
|
+
setup(a) {
|
|
9
|
+
let g = a, _ = f(), v = p(), y = o(e, null), b = n(() => typeof _.id == "string" ? _.id : v), x = n(() => g.validation ? y?.validationMessage.value ?? "" : "");
|
|
10
|
+
return m(() => {
|
|
11
|
+
y && (y.supportingTextId.value = b.value);
|
|
12
|
+
}), c(() => {
|
|
13
|
+
y && (y.supportingTextId.value = void 0);
|
|
14
|
+
}), (e, n) => (l(), r("p", s(e.$attrs, { id: b.value }), [x.value ? (l(), r(t, { key: 0 }, [i(d(x.value), 1)], 64)) : u(e.$slots, "default", { key: 1 })], 16, h));
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
export { g 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,42 @@
|
|
|
1
|
+
import { useFieldControl as e } from "./internal/field.js";
|
|
2
|
+
import { applyModelModifiers as t } from "./internal/modifiers.js";
|
|
3
|
+
import { createElementBlock as n, defineComponent as r, isRef as i, mergeProps as a, openBlock as o, unref as s, useModel as c, vModelText as l, withDirectives as u } from "vue";
|
|
4
|
+
//#region src/components/BaseTextarea.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var d = [
|
|
6
|
+
"id",
|
|
7
|
+
"aria-describedby",
|
|
8
|
+
"aria-invalid"
|
|
9
|
+
], f = [
|
|
10
|
+
"id",
|
|
11
|
+
"aria-describedby",
|
|
12
|
+
"aria-invalid"
|
|
13
|
+
], p = /* @__PURE__ */ r({
|
|
14
|
+
inheritAttrs: !1,
|
|
15
|
+
__name: "BaseTextarea",
|
|
16
|
+
props: {
|
|
17
|
+
modelValue: {},
|
|
18
|
+
modelModifiers: {}
|
|
19
|
+
},
|
|
20
|
+
emits: ["update:modelValue"],
|
|
21
|
+
setup(r) {
|
|
22
|
+
let [p, m] = c(r, "modelValue", { set: (e) => t(e, m) }), { controlId: h, describedBy: g, ariaInvalid: _ } = e();
|
|
23
|
+
return (e, t) => s(m).lazy ? u((o(), n("textarea", a({ key: 0 }, e.$attrs, {
|
|
24
|
+
id: s(h),
|
|
25
|
+
"onUpdate:modelValue": t[0] ||= (e) => i(p) ? p.value = e : null,
|
|
26
|
+
"aria-describedby": s(g),
|
|
27
|
+
"aria-invalid": s(_)
|
|
28
|
+
}), null, 16, d)), [[
|
|
29
|
+
l,
|
|
30
|
+
s(p),
|
|
31
|
+
void 0,
|
|
32
|
+
{ lazy: !0 }
|
|
33
|
+
]]) : u((o(), n("textarea", a({ key: 1 }, e.$attrs, {
|
|
34
|
+
id: s(h),
|
|
35
|
+
"onUpdate:modelValue": t[1] ||= (e) => i(p) ? p.value = e : null,
|
|
36
|
+
"aria-describedby": s(g),
|
|
37
|
+
"aria-invalid": s(_)
|
|
38
|
+
}), null, 16, f)), [[l, s(p)]]);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
//#endregion
|
|
42
|
+
export { p as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { fieldKey as e } from "./keys.js";
|
|
2
|
+
import { computed as t, inject as n, useAttrs as r, useId as i } from "vue";
|
|
3
|
+
//#region src/components/internal/field.ts
|
|
4
|
+
function a() {
|
|
5
|
+
let a = r(), o = i(), s = n(e, null);
|
|
6
|
+
return {
|
|
7
|
+
controlId: t(() => typeof a.id == "string" ? a.id : s?.id.value ?? o),
|
|
8
|
+
describedBy: t(() => typeof a["aria-describedby"] == "string" ? a["aria-describedby"] : s?.supportingTextId.value),
|
|
9
|
+
ariaInvalid: t(() => "aria-invalid" in a ? a["aria-invalid"] : s?.validationMessage.value ? "true" : void 0)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { a as useFieldControl };
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { InjectionKey, ModelRef, ComputedRef } from 'vue';
|
|
1
|
+
import { InjectionKey, ModelRef, ComputedRef, Ref } 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
|
+
supportingTextId: Ref<string | undefined>;
|
|
15
|
+
validationMessage: Ref<string>;
|
|
16
|
+
}
|
|
17
|
+
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';
|
|
@@ -8,4 +9,5 @@ export { default as CLabel } from './components/BaseLabel';
|
|
|
8
9
|
export { default as CRadio } from './components/BaseRadio';
|
|
9
10
|
export { default as CRadioGroup } from './components/BaseRadioGroup';
|
|
10
11
|
export { default as CSelect } from './components/BaseSelect';
|
|
12
|
+
export { default as CSupportingText } from './components/BaseSupportingText';
|
|
11
13
|
export { default as CTextarea } from './components/BaseTextarea';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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/BaseSupportingText.js";
|
|
13
|
+
import f from "./components/BaseTextarea.js";
|
|
14
|
+
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 CSupportingText, f as CTextarea };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charpente-ui/vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.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});
|