@crystal-neuo/vue 0.0.0-stage → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/Alert.d.ts +24 -0
- package/dist/Alert.d.ts.map +1 -0
- package/dist/Alert.js +6 -0
- package/dist/Alert.js.map +1 -0
- package/dist/Alert.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/Alert.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Avatar.d.ts +16 -0
- package/dist/Avatar.d.ts.map +1 -0
- package/dist/Avatar.js +6 -0
- package/dist/Avatar.js.map +1 -0
- package/dist/Avatar.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/Avatar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Badge.d.ts +24 -0
- package/dist/Badge.d.ts.map +1 -0
- package/dist/Badge.js +6 -0
- package/dist/Badge.js.map +1 -0
- package/dist/Badge.vue_vue_type_script_setup_true_lang.js +23 -0
- package/dist/Badge.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Breadcrumb.d.ts +17 -0
- package/dist/Breadcrumb.d.ts.map +1 -0
- package/dist/Breadcrumb.js +6 -0
- package/dist/Breadcrumb.js.map +1 -0
- package/dist/Breadcrumb.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/Breadcrumb.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Button.d.ts +34 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +6 -0
- package/dist/Button.js.map +1 -0
- package/dist/Button.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/Button.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Card.d.ts +24 -0
- package/dist/Card.d.ts.map +1 -0
- package/dist/Card.js +6 -0
- package/dist/Card.js.map +1 -0
- package/dist/Card.vue_vue_type_script_setup_true_lang.js +23 -0
- package/dist/Card.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Checkbox.d.ts +24 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +6 -0
- package/dist/Checkbox.js.map +1 -0
- package/dist/Checkbox.vue_vue_type_script_setup_true_lang.js +55 -0
- package/dist/Checkbox.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/DatePicker.d.ts +25 -0
- package/dist/DatePicker.d.ts.map +1 -0
- package/dist/DatePicker.js +6 -0
- package/dist/DatePicker.js.map +1 -0
- package/dist/DatePicker.vue_vue_type_script_setup_true_lang.js +62 -0
- package/dist/DatePicker.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Dialog.d.ts +40 -0
- package/dist/Dialog.d.ts.map +1 -0
- package/dist/Dialog.js +6 -0
- package/dist/Dialog.js.map +1 -0
- package/dist/Dialog.vue_vue_type_script_setup_true_lang.js +75 -0
- package/dist/Dialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Drawer.d.ts +33 -0
- package/dist/Drawer.d.ts.map +1 -0
- package/dist/Drawer.js +6 -0
- package/dist/Drawer.js.map +1 -0
- package/dist/Drawer.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/Drawer.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/FileUpload.d.ts +33 -0
- package/dist/FileUpload.d.ts.map +1 -0
- package/dist/FileUpload.js +6 -0
- package/dist/FileUpload.js.map +1 -0
- package/dist/FileUpload.vue_vue_type_script_setup_true_lang.js +108 -0
- package/dist/FileUpload.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Input.d.ts +27 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +6 -0
- package/dist/Input.js.map +1 -0
- package/dist/Input.vue_vue_type_script_setup_true_lang.js +67 -0
- package/dist/Input.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/List.d.ts +24 -0
- package/dist/List.d.ts.map +1 -0
- package/dist/List.js +6 -0
- package/dist/List.js.map +1 -0
- package/dist/List.vue_vue_type_script_setup_true_lang.js +23 -0
- package/dist/List.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/ListItem.d.ts +19 -0
- package/dist/ListItem.d.ts.map +1 -0
- package/dist/ListItem.js +6 -0
- package/dist/ListItem.js.map +1 -0
- package/dist/ListItem.vue_vue_type_script_setup_true_lang.js +21 -0
- package/dist/ListItem.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Menu.d.ts +25 -0
- package/dist/Menu.d.ts.map +1 -0
- package/dist/Menu.js +6 -0
- package/dist/Menu.js.map +1 -0
- package/dist/Menu.vue_vue_type_script_setup_true_lang.js +94 -0
- package/dist/Menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Modal.d.ts +31 -0
- package/dist/Modal.d.ts.map +1 -0
- package/dist/Modal.js +6 -0
- package/dist/Modal.js.map +1 -0
- package/dist/Modal.vue_vue_type_script_setup_true_lang.js +46 -0
- package/dist/Modal.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Nav.d.ts +23 -0
- package/dist/Nav.d.ts.map +1 -0
- package/dist/Nav.js +6 -0
- package/dist/Nav.js.map +1 -0
- package/dist/Nav.vue_vue_type_script_setup_true_lang.js +24 -0
- package/dist/Nav.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/NavLink.d.ts +21 -0
- package/dist/NavLink.d.ts.map +1 -0
- package/dist/NavLink.js +6 -0
- package/dist/NavLink.js.map +1 -0
- package/dist/NavLink.vue_vue_type_script_setup_true_lang.js +29 -0
- package/dist/NavLink.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Pagination.d.ts +24 -0
- package/dist/Pagination.d.ts.map +1 -0
- package/dist/Pagination.js +6 -0
- package/dist/Pagination.js.map +1 -0
- package/dist/Pagination.vue_vue_type_script_setup_true_lang.js +84 -0
- package/dist/Pagination.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Progress.d.ts +19 -0
- package/dist/Progress.d.ts.map +1 -0
- package/dist/Progress.js +6 -0
- package/dist/Progress.js.map +1 -0
- package/dist/Progress.vue_vue_type_script_setup_true_lang.js +40 -0
- package/dist/Progress.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Radio.d.ts +29 -0
- package/dist/Radio.d.ts.map +1 -0
- package/dist/Radio.js +6 -0
- package/dist/Radio.js.map +1 -0
- package/dist/Radio.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/Radio.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/SegmentedControl.d.ts +32 -0
- package/dist/SegmentedControl.d.ts.map +1 -0
- package/dist/SegmentedControl.js +6 -0
- package/dist/SegmentedControl.js.map +1 -0
- package/dist/SegmentedControl.vue_vue_type_script_setup_true_lang.js +47 -0
- package/dist/SegmentedControl.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Select.d.ts +29 -0
- package/dist/Select.d.ts.map +1 -0
- package/dist/Select.js +6 -0
- package/dist/Select.js.map +1 -0
- package/dist/Select.vue_vue_type_script_setup_true_lang.js +69 -0
- package/dist/Select.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Sheet.d.ts +28 -0
- package/dist/Sheet.d.ts.map +1 -0
- package/dist/Sheet.js +6 -0
- package/dist/Sheet.js.map +1 -0
- package/dist/Sheet.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/Sheet.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Skeleton.d.ts +14 -0
- package/dist/Skeleton.d.ts.map +1 -0
- package/dist/Skeleton.js +6 -0
- package/dist/Skeleton.js.map +1 -0
- package/dist/Skeleton.vue_vue_type_script_setup_true_lang.js +24 -0
- package/dist/Skeleton.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Slider.d.ts +29 -0
- package/dist/Slider.d.ts.map +1 -0
- package/dist/Slider.js +6 -0
- package/dist/Slider.js.map +1 -0
- package/dist/Slider.vue_vue_type_script_setup_true_lang.js +61 -0
- package/dist/Slider.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/TabBar.d.ts +27 -0
- package/dist/TabBar.d.ts.map +1 -0
- package/dist/TabBar.js +6 -0
- package/dist/TabBar.js.map +1 -0
- package/dist/TabBar.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/TabBar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Table.d.ts +32 -0
- package/dist/Table.d.ts.map +1 -0
- package/dist/Table.js +6 -0
- package/dist/Table.js.map +1 -0
- package/dist/Table.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/Table.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Tabs.d.ts +39 -0
- package/dist/Tabs.d.ts.map +1 -0
- package/dist/Tabs.js +6 -0
- package/dist/Tabs.js.map +1 -0
- package/dist/Tabs.vue_vue_type_script_setup_true_lang.js +82 -0
- package/dist/Tabs.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Textarea.d.ts +26 -0
- package/dist/Textarea.d.ts.map +1 -0
- package/dist/Textarea.js +6 -0
- package/dist/Textarea.js.map +1 -0
- package/dist/Textarea.vue_vue_type_script_setup_true_lang.js +67 -0
- package/dist/Textarea.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Toast.d.ts +31 -0
- package/dist/Toast.d.ts.map +1 -0
- package/dist/Toast.js +6 -0
- package/dist/Toast.js.map +1 -0
- package/dist/Toast.vue_vue_type_script_setup_true_lang.js +75 -0
- package/dist/Toast.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Toggle.d.ts +22 -0
- package/dist/Toggle.d.ts.map +1 -0
- package/dist/Toggle.js +6 -0
- package/dist/Toggle.js.map +1 -0
- package/dist/Toggle.vue_vue_type_script_setup_true_lang.js +48 -0
- package/dist/Toggle.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/Tooltip.d.ts +22 -0
- package/dist/Tooltip.d.ts.map +1 -0
- package/dist/Tooltip.js +6 -0
- package/dist/Tooltip.js.map +1 -0
- package/dist/Tooltip.vue_vue_type_script_setup_true_lang.js +36 -0
- package/dist/Tooltip.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/cn.d.ts +2 -0
- package/dist/cn.d.ts.map +1 -0
- package/dist/cn.js +7 -0
- package/dist/cn.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/useControlAttrs.d.ts +16 -0
- package/dist/useControlAttrs.d.ts.map +1 -0
- package/dist/useControlAttrs.js +18 -0
- package/dist/useControlAttrs.js.map +1 -0
- package/dist/useFocusTrap.d.ts +10 -0
- package/dist/useFocusTrap.d.ts.map +1 -0
- package/dist/useFocusTrap.js +37 -0
- package/dist/useFocusTrap.js.map +1 -0
- package/dist/useModalDialog.d.ts +12 -0
- package/dist/useModalDialog.d.ts.map +1 -0
- package/dist/useModalDialog.js +29 -0
- package/dist/useModalDialog.js.map +1 -0
- package/package.json +42 -4
- package/src/Alert.vue +31 -0
- package/src/Avatar.vue +35 -0
- package/src/Badge.vue +21 -0
- package/src/Breadcrumb.vue +34 -0
- package/src/Button.vue +38 -0
- package/src/Card.vue +21 -0
- package/src/Checkbox.vue +56 -0
- package/src/DatePicker.vue +51 -0
- package/src/Dialog.vue +73 -0
- package/src/Drawer.vue +55 -0
- package/src/FileUpload.vue +107 -0
- package/src/Input.vue +58 -0
- package/src/List.vue +23 -0
- package/src/ListItem.vue +12 -0
- package/src/Menu.vue +132 -0
- package/src/Modal.vue +44 -0
- package/src/Nav.vue +18 -0
- package/src/NavLink.vue +20 -0
- package/src/Pagination.vue +69 -0
- package/src/Progress.vue +41 -0
- package/src/Radio.vue +53 -0
- package/src/SegmentedControl.vue +53 -0
- package/src/Select.vue +62 -0
- package/src/Sheet.vue +40 -0
- package/src/Skeleton.vue +18 -0
- package/src/Slider.vue +49 -0
- package/src/TabBar.vue +39 -0
- package/src/Table.vue +47 -0
- package/src/Tabs.vue +95 -0
- package/src/Textarea.vue +58 -0
- package/src/Toast.vue +83 -0
- package/src/Toggle.vue +45 -0
- package/src/Tooltip.vue +39 -0
- package/src/cn.ts +5 -0
- package/src/index.ts +47 -0
- package/src/shims-vue.d.ts +5 -0
- package/src/useControlAttrs.ts +18 -0
- package/src/useFocusTrap.ts +74 -0
- package/src/useModalDialog.ts +65 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { cn as e } from "./cn.js";
|
|
2
|
+
import { useControlAttrs as t } from "./useControlAttrs.js";
|
|
3
|
+
import { computed as n, createElementBlock as r, createElementVNode as i, defineComponent as a, mergeModels as o, mergeProps as s, onMounted as c, openBlock as l, toDisplayString as u, unref as d, useId as f, useModel as p, useTemplateRef as m, vModelCheckbox as h, watch as g, withDirectives as _ } from "vue";
|
|
4
|
+
// src/Checkbox.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var v = ["for", "data-material"], y = [
|
|
6
|
+
"id",
|
|
7
|
+
"disabled",
|
|
8
|
+
"aria-invalid"
|
|
9
|
+
], b = { class: "cn-choice__label" }, x = /*@__PURE__*/ a({
|
|
10
|
+
inheritAttrs: !1,
|
|
11
|
+
__name: "Checkbox",
|
|
12
|
+
props: /*@__PURE__*/ o({
|
|
13
|
+
material: {},
|
|
14
|
+
size: { default: "md" },
|
|
15
|
+
label: {},
|
|
16
|
+
error: { type: Boolean },
|
|
17
|
+
indeterminate: { type: Boolean },
|
|
18
|
+
id: {},
|
|
19
|
+
disabled: { type: Boolean }
|
|
20
|
+
}, {
|
|
21
|
+
checked: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: !1
|
|
24
|
+
},
|
|
25
|
+
checkedModifiers: {}
|
|
26
|
+
}),
|
|
27
|
+
emits: ["update:checked"],
|
|
28
|
+
setup(a) {
|
|
29
|
+
let o = a, x = p(a, "checked"), S = f(), C = n(() => o.id ?? S), w = m("inputEl");
|
|
30
|
+
function T() {
|
|
31
|
+
w.value && (w.value.indeterminate = o.indeterminate ?? !1);
|
|
32
|
+
}
|
|
33
|
+
c(T), g(() => o.indeterminate, T, { flush: "post" });
|
|
34
|
+
let E = n(() => e("cn-choice", `cn-choice--size-${o.size}`, o.error && "cn-choice--error")), { rootAttrs: D, controlAttrs: O } = t();
|
|
35
|
+
return (e, t) => (l(), r("label", s(d(D), {
|
|
36
|
+
class: E.value,
|
|
37
|
+
for: C.value,
|
|
38
|
+
"data-slot": "checkbox",
|
|
39
|
+
"data-material": o.material
|
|
40
|
+
}), [_(i("input", s(d(O), {
|
|
41
|
+
ref_key: "inputEl",
|
|
42
|
+
ref: w,
|
|
43
|
+
id: C.value,
|
|
44
|
+
"onUpdate:modelValue": t[0] ||= (e) => x.value = e,
|
|
45
|
+
type: "checkbox",
|
|
46
|
+
class: "cn-choice__input",
|
|
47
|
+
disabled: a.disabled,
|
|
48
|
+
"aria-invalid": a.error ? !0 : void 0,
|
|
49
|
+
onChange: T
|
|
50
|
+
}), null, 16, y), [[h, x.value]]), i("span", b, u(a.label), 1)], 16, v));
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
export { x as default };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=Checkbox.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_mergeProps","_unref","_withDirectives","_createElementVNode","_vModelCheckbox","_toDisplayString","_hoisted_1","_hoisted_2","_hoisted_3","Checkbox_vue_vue_type_script_setup_true_lang_default","\"checked\"","\"checkedModifiers\"","props","__props","checked","useModel","autoId","useId","cbId","computed","inputEl","useTemplateRef","syncIndeterminate","onMounted","watch","classes","cn","useControlAttrs","openBlock","createElementBlock","mergeProps","unref","rootAttrs","withDirectives","createElementVNode","controlAttrs","_cache","$event","vModelCheckbox","toDisplayString"],"sources":["../src/Checkbox.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, onMounted, useId, useTemplateRef, watch } from \"vue\";\nimport type { CheckboxSize, Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\nimport { useControlAttrs } from \"./useControlAttrs.ts\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n size?: CheckboxSize;\n label: string;\n error?: boolean;\n indeterminate?: boolean;\n id?: string;\n disabled?: boolean;\n }>(),\n { size: \"md\" },\n);\n\nconst checked = defineModel<boolean>(\"checked\", { default: false });\n\nconst autoId = useId();\nconst cbId = computed(() => props.id ?? autoId);\nconst inputEl = useTemplateRef<HTMLInputElement>(\"inputEl\");\n// `indeterminate` is a DOM property, not an attribute. Sync it once the input\n// exists, whenever the prop changes, and after a click (which clears the flag):\n// the prop stays the source of truth until the owner changes it.\nfunction syncIndeterminate() {\n if (inputEl.value) inputEl.value.indeterminate = props.indeterminate ?? false;\n}\nonMounted(syncIndeterminate);\nwatch(() => props.indeterminate, syncIndeterminate, { flush: \"post\" });\nconst classes = computed(() =>\n cn(\"cn-choice\", `cn-choice--size-${props.size}`, props.error && \"cn-choice--error\"),\n);\nconst { rootAttrs, controlAttrs } = useControlAttrs();\n</script>\n\n<template>\n <label v-bind=\"rootAttrs\" :class=\"classes\" :for=\"cbId\" data-slot=\"checkbox\" :data-material=\"props.material\">\n <input\n v-bind=\"controlAttrs\"\n ref=\"inputEl\"\n :id=\"cbId\"\n v-model=\"checked\"\n type=\"checkbox\"\n class=\"cn-choice__input\"\n :disabled=\"disabled\"\n :aria-invalid=\"error ? true : undefined\"\n @change=\"syncIndeterminate\"\n />\n <span class=\"cn-choice__label\">{{ label }}</span>\n </label>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQA,IAAMe,IAAQC,GAaRC,IAAUjB,EAAoBgB,GAAC,SAA6B,GAE5DG,IAASC,EAAM,GACfC,IAAOC,QAAeP,EAAM,MAAMI,CAAM,GACxCI,IAAUC,EAAiC,SAAS;EAI1D,SAASC,IAAoB;GAC3B,AAAIF,EAAQ,UAAO,EAAQ,MAAM,gBAAgBR,EAAM,iBAAiB;EAC1E;EAEA,AADAW,EAAUD,CAAiB,GAC3BE,QAAYZ,EAAM,eAAeU,GAAmB,EAAE,OAAO,OAAO,CAAC;EACrE,IAAMG,IAAUN,QACdO,EAAG,aAAa,mBAAmBd,EAAM,QAAQA,EAAM,SAAS,kBAAkB,CACpF,GACM,EAAE,cAAW,oBAAiBe,EAAgB;E,kBAIlD7B,EAAA,GAAAC,EAaQ,SAbRC,EAAeC,EAaP+B,CAAA,GAbgB;GAAG,OAAOP,EAAA;GAAU,KAAKP,EAAA;GAAM,aAAU;GAAY,iBAAeN,EAAM;E,KAChGV,EAAAC,EAUE,SAVFH,EACUC,EASRkC,CAAA,GAToB;GAChB,SAAA;GAAJ,KAAIf;GACH,IAAIF,EAAA;GACI,uBAAA,AAAAkB,EAAA,QAAA,MAAA,EAAO,QAAAC;GAChB,MAAK;GACL,OAAM;GACL,UAAUxB,EAAA;GACV,gBAAcA,EAAA,QAAK,KAAU,KAAA;GAC7B,UAAQS;E,mBALA,CAAAlB,GAAAU,EAAA,KAAO,C,IAOlBX,EAAiD,QAAjDK,GAAiDH,EAAfQ,EAAA,KAAK,GAAA,CAAA,C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DatePickerSize, Material } from "@crystal-neuo/contract";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
material?: Material;
|
|
4
|
+
size?: DatePickerSize;
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
min?: string;
|
|
9
|
+
max?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_ModelProps = {
|
|
13
|
+
modelValue?: string;
|
|
14
|
+
};
|
|
15
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
16
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
"update:modelValue": (value: string) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
19
|
+
"onUpdate:modelValue"?: (value: string) => any;
|
|
20
|
+
}>, {
|
|
21
|
+
size: "sm" | "md" | "lg";
|
|
22
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
23
|
+
declare const _default: typeof __VLS_export;
|
|
24
|
+
export default _default;
|
|
25
|
+
//# sourceMappingURL=DatePicker.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.vue.d.ts","sourceRoot":"","sources":["../src/DatePicker.vue"],"names":[],"mappings":"AAuDA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAOvE,KAAK,WAAW,GAAG;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAmBJ,KAAK,gBAAgB,GAAG;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAoDxD,QAAA,MAAM,YAAY;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.js","names":["_sfc_main","DatePicker_vue_vue_type_script_setup_true_lang_default","DatePicker_default"],"sources":["../src/DatePicker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useId } from \"vue\";\nimport type { DatePickerSize, Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\nimport { useControlAttrs } from \"./useControlAttrs.ts\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n size?: DatePickerSize;\n label?: string;\n error?: string;\n id?: string;\n min?: string;\n max?: string;\n disabled?: boolean;\n }>(),\n { size: \"md\" },\n);\n\nconst model = defineModel<string>({ default: \"\" });\n\nconst autoId = useId();\nconst dpId = computed(() => props.id ?? autoId);\nconst msgId = computed(() => `${dpId.value}-msg`);\nconst inputClass = computed(() =>\n cn(\"cn-input\", `cn-input--size-${props.size}`, props.error && \"cn-input--error\"),\n);\nconst { rootAttrs, controlAttrs } = useControlAttrs();\n</script>\n\n<template>\n <div v-bind=\"rootAttrs\" class=\"cn-field\" data-slot=\"date-field\" :data-material=\"props.material\">\n <label v-if=\"label\" class=\"cn-field__label\" :for=\"dpId\">{{ label }}</label>\n <input\n v-bind=\"controlAttrs\"\n :id=\"dpId\"\n v-model=\"model\"\n type=\"date\"\n :class=\"inputClass\"\n :min=\"min\"\n :max=\"max\"\n :disabled=\"disabled\"\n :aria-invalid=\"error ? true : undefined\"\n :aria-describedby=\"error ? msgId : undefined\"\n />\n <span v-if=\"error\" class=\"cn-field__message\" :id=\"msgId\">{{ error }}</span>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { cn as e } from "./cn.js";
|
|
2
|
+
import { useControlAttrs as t } from "./useControlAttrs.js";
|
|
3
|
+
import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, mergeModels as s, mergeProps as c, openBlock as l, toDisplayString as u, unref as d, useId as f, useModel as p, vModelText as m, withDirectives as h } from "vue";
|
|
4
|
+
// src/DatePicker.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var g = ["data-material"], _ = ["for"], v = [
|
|
6
|
+
"id",
|
|
7
|
+
"min",
|
|
8
|
+
"max",
|
|
9
|
+
"disabled",
|
|
10
|
+
"aria-invalid",
|
|
11
|
+
"aria-describedby"
|
|
12
|
+
], y = ["id"], b = /*@__PURE__*/ o({
|
|
13
|
+
inheritAttrs: !1,
|
|
14
|
+
__name: "DatePicker",
|
|
15
|
+
props: /*@__PURE__*/ s({
|
|
16
|
+
material: {},
|
|
17
|
+
size: { default: "md" },
|
|
18
|
+
label: {},
|
|
19
|
+
error: {},
|
|
20
|
+
id: {},
|
|
21
|
+
min: {},
|
|
22
|
+
max: {},
|
|
23
|
+
disabled: { type: Boolean }
|
|
24
|
+
}, {
|
|
25
|
+
modelValue: { default: "" },
|
|
26
|
+
modelModifiers: {}
|
|
27
|
+
}),
|
|
28
|
+
emits: ["update:modelValue"],
|
|
29
|
+
setup(o) {
|
|
30
|
+
let s = o, b = p(o, "modelValue"), x = f(), S = n(() => s.id ?? x), C = n(() => `${S.value}-msg`), w = n(() => e("cn-input", `cn-input--size-${s.size}`, s.error && "cn-input--error")), { rootAttrs: T, controlAttrs: E } = t();
|
|
31
|
+
return (e, t) => (l(), i("div", c(d(T), {
|
|
32
|
+
class: "cn-field",
|
|
33
|
+
"data-slot": "date-field",
|
|
34
|
+
"data-material": s.material
|
|
35
|
+
}), [
|
|
36
|
+
o.label ? (l(), i("label", {
|
|
37
|
+
key: 0,
|
|
38
|
+
class: "cn-field__label",
|
|
39
|
+
for: S.value
|
|
40
|
+
}, u(o.label), 9, _)) : r("", !0),
|
|
41
|
+
h(a("input", c(d(E), {
|
|
42
|
+
id: S.value,
|
|
43
|
+
"onUpdate:modelValue": t[0] ||= (e) => b.value = e,
|
|
44
|
+
type: "date",
|
|
45
|
+
class: w.value,
|
|
46
|
+
min: o.min,
|
|
47
|
+
max: o.max,
|
|
48
|
+
disabled: o.disabled,
|
|
49
|
+
"aria-invalid": o.error ? !0 : void 0,
|
|
50
|
+
"aria-describedby": o.error ? C.value : void 0
|
|
51
|
+
}), null, 16, v), [[m, b.value]]),
|
|
52
|
+
o.error ? (l(), i("span", {
|
|
53
|
+
key: 1,
|
|
54
|
+
class: "cn-field__message",
|
|
55
|
+
id: C.value
|
|
56
|
+
}, u(o.error), 9, y)) : r("", !0)
|
|
57
|
+
], 16, g));
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
export { b as default };
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=DatePicker.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatePicker.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_mergeProps","_unref","_toDisplayString","_createCommentVNode","_withDirectives","_createElementVNode","_vModelText","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","DatePicker_vue_vue_type_script_setup_true_lang_default","\"modelValue\"","\"modelModifiers\"","props","__props","model","useModel","autoId","useId","dpId","computed","msgId","inputClass","cn","useControlAttrs","openBlock","createElementBlock","mergeProps","unref","rootAttrs","toDisplayString","createCommentVNode","withDirectives","createElementVNode","controlAttrs","_cache","$event","vModelText"],"sources":["../src/DatePicker.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useId } from \"vue\";\nimport type { DatePickerSize, Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\nimport { useControlAttrs } from \"./useControlAttrs.ts\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n size?: DatePickerSize;\n label?: string;\n error?: string;\n id?: string;\n min?: string;\n max?: string;\n disabled?: boolean;\n }>(),\n { size: \"md\" },\n);\n\nconst model = defineModel<string>({ default: \"\" });\n\nconst autoId = useId();\nconst dpId = computed(() => props.id ?? autoId);\nconst msgId = computed(() => `${dpId.value}-msg`);\nconst inputClass = computed(() =>\n cn(\"cn-input\", `cn-input--size-${props.size}`, props.error && \"cn-input--error\"),\n);\nconst { rootAttrs, controlAttrs } = useControlAttrs();\n</script>\n\n<template>\n <div v-bind=\"rootAttrs\" class=\"cn-field\" data-slot=\"date-field\" :data-material=\"props.material\">\n <label v-if=\"label\" class=\"cn-field__label\" :for=\"dpId\">{{ label }}</label>\n <input\n v-bind=\"controlAttrs\"\n :id=\"dpId\"\n v-model=\"model\"\n type=\"date\"\n :class=\"inputClass\"\n :min=\"min\"\n :max=\"max\"\n :disabled=\"disabled\"\n :aria-invalid=\"error ? true : undefined\"\n :aria-describedby=\"error ? msgId : undefined\"\n />\n <span v-if=\"error\" class=\"cn-field__message\" :id=\"msgId\">{{ error }}</span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQA,IAAMiB,IAAQC,GAcRC,IAAQnB,EAAmBkB,GAAA,YAAgB,GAE3CG,IAASC,EAAM,GACfC,IAAOC,QAAeP,EAAM,MAAMI,CAAM,GACxCI,IAAQD,QAAe,GAAGD,EAAK,MAAM,KAAK,GAC1CG,IAAaF,QACjBG,EAAG,YAAY,kBAAkBV,EAAM,QAAQA,EAAM,SAAS,iBAAiB,CACjF,GACM,EAAE,cAAW,oBAAiBW,EAAgB;E,kBAIlD3B,EAAA,GAAAC,EAeM,OAfNC,EAAaC,EAeP6B,CAAA,GAfgB;GAAE,OAAM;GAAW,aAAU;GAAc,iBAAehB,EAAM;;GACvEC,EAAA,SAAbjB,EAAA,GAAAC,EAA2E,SAAA;;IAAvD,OAAM;IAAmB,KAAKqB,EAAA;GAAS,GAAAlB,EAAAa,EAAA,KAAK,GAAA,GAAAP,CAAA,K;GAChEJ,EAAAC,EAWE,SAXFL,EACUC,EAURkC,CAAA,GAVoB;IACnB,IAAIf,EAAA;IACI,uBAAA,AAAAgB,EAAA,QAAA,MAAA,EAAK,QAAAC;IACd,MAAK;IACJ,OAAOd,EAAA;IACP,KAAKR,EAAA;IACL,KAAKA,EAAA;IACL,UAAUA,EAAA;IACV,gBAAcA,EAAA,QAAK,KAAU,KAAA;IAC7B,oBAAkBA,EAAA,QAAQO,EAAA,QAAQ,KAAA;G,mBAP1B,CAAAhB,GAAAU,EAAA,KAAK,C;GASJD,EAAA,SAAZjB,EAAA,GAAAC,EAA2E,QAAA;;IAAxD,OAAM;IAAqB,IAAIuB,EAAA;GAAU,GAAApB,EAAAa,EAAA,KAAK,GAAA,GAAAL,CAAA,K"}
|
package/dist/Dialog.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DialogVariant, DialogSize, Material } from "@crystal-neuo/contract";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
material?: Material;
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
variant?: DialogVariant;
|
|
7
|
+
size?: DialogSize;
|
|
8
|
+
confirmLabel?: string;
|
|
9
|
+
cancelLabel?: string;
|
|
10
|
+
class?: string;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_ModelProps = {
|
|
13
|
+
"open"?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
16
|
+
declare var __VLS_1: {};
|
|
17
|
+
type __VLS_Slots = {} & {
|
|
18
|
+
default?: (props: typeof __VLS_1) => any;
|
|
19
|
+
};
|
|
20
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
"update:open": (value: boolean) => any;
|
|
22
|
+
confirm: () => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
24
|
+
"onUpdate:open"?: (value: boolean) => any;
|
|
25
|
+
onConfirm?: () => any;
|
|
26
|
+
}>, {
|
|
27
|
+
variant: "default" | "destructive";
|
|
28
|
+
size: "sm" | "md";
|
|
29
|
+
confirmLabel: string;
|
|
30
|
+
cancelLabel: string;
|
|
31
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
33
|
+
declare const _default: typeof __VLS_export;
|
|
34
|
+
export default _default;
|
|
35
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
36
|
+
new (): {
|
|
37
|
+
$slots: S;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=Dialog.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.vue.d.ts","sourceRoot":"","sources":["../src/Dialog.vue"],"names":[],"mappings":"AA6EA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAKlF,KAAK,WAAW,GAAG;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAsCJ,KAAK,gBAAgB,GAAG;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAyExD,QAAA,IAAI,OAAO,IAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU;;;;;;;;;;;6EAId,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
package/dist/Dialog.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["_sfc_main","Dialog_vue_vue_type_script_setup_true_lang_default","Dialog_default"],"sources":["../src/Dialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useId } from \"vue\";\nimport type { DialogVariant, DialogSize, Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\nimport { useModalDialog } from \"./useModalDialog.ts\";\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n title: string;\n description?: string;\n variant?: DialogVariant;\n size?: DialogSize;\n confirmLabel?: string;\n cancelLabel?: string;\n class?: string;\n }>(),\n { variant: \"default\", size: \"sm\", confirmLabel: \"Confirm\", cancelLabel: \"Cancel\" },\n);\n\nconst open = defineModel<boolean>(\"open\", { default: false });\nconst emit = defineEmits<{ confirm: [] }>();\n\nconst dialog = ref<HTMLDialogElement | null>(null);\nconst titleId = useId();\nconst descId = useId();\nuseModalDialog(dialog, open);\n\nconst classes = computed(() => cn(\"cn-dialog\", `cn-dialog--size-${props.size}`, props.class));\nconst confirmClass = computed(() =>\n cn(\n \"cn-button\",\n props.variant === \"destructive\" ? \"cn-button--danger\" : \"cn-button--primary\",\n \"cn-button--size-md\",\n ),\n);\n\nfunction onScrim(e: MouseEvent) {\n if (e.target !== e.currentTarget) return;\n // Keep the press from moving focus to the closing dialog, so focus returns to the opener.\n e.preventDefault();\n open.value = false;\n}\nfunction confirm() {\n emit(\"confirm\");\n open.value = false;\n}\n</script>\n\n<template>\n <dialog\n ref=\"dialog\"\n class=\"cn-scrim\"\n data-slot=\"dialog-scrim\"\n :data-material=\"props.material\"\n role=\"alertdialog\"\n :aria-labelledby=\"titleId\"\n :aria-describedby=\"description ? descId : undefined\"\n @mousedown=\"onScrim\"\n >\n <div v-if=\"open\" :class=\"classes\">\n <h2 :id=\"titleId\" class=\"cn-dialog__title\">{{ title }}</h2>\n <p v-if=\"description\" :id=\"descId\">{{ description }}</p>\n <slot />\n <div class=\"cn-dialog__actions\">\n <button type=\"button\" class=\"cn-button cn-button--ghost cn-button--size-md\" @click=\"open = false\">\n {{ cancelLabel }}\n </button>\n <button type=\"button\" :class=\"confirmClass\" @click=\"confirm\">{{ confirmLabel }}</button>\n </div>\n </div>\n </dialog>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { cn as e } from "./cn.js";
|
|
2
|
+
import { useModalDialog as t } from "./useModalDialog.js";
|
|
3
|
+
import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, mergeModels as s, normalizeClass as c, openBlock as l, ref as u, renderSlot as d, toDisplayString as f, unref as p, useId as m, useModel as h } from "vue";
|
|
4
|
+
// src/Dialog.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var g = [
|
|
6
|
+
"data-material",
|
|
7
|
+
"aria-labelledby",
|
|
8
|
+
"aria-describedby"
|
|
9
|
+
], _ = ["id"], v = ["id"], y = { class: "cn-dialog__actions" }, b = /*@__PURE__*/ o({
|
|
10
|
+
__name: "Dialog",
|
|
11
|
+
props: /*@__PURE__*/ s({
|
|
12
|
+
material: {},
|
|
13
|
+
title: {},
|
|
14
|
+
description: {},
|
|
15
|
+
variant: { default: "default" },
|
|
16
|
+
size: { default: "sm" },
|
|
17
|
+
confirmLabel: { default: "Confirm" },
|
|
18
|
+
cancelLabel: { default: "Cancel" },
|
|
19
|
+
class: {}
|
|
20
|
+
}, {
|
|
21
|
+
open: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: !1
|
|
24
|
+
},
|
|
25
|
+
openModifiers: {}
|
|
26
|
+
}),
|
|
27
|
+
emits: /*@__PURE__*/ s(["confirm"], ["update:open"]),
|
|
28
|
+
setup(o, { emit: s }) {
|
|
29
|
+
let b = o, x = h(o, "open"), S = s, C = u(null), w = m(), T = m();
|
|
30
|
+
t(C, x);
|
|
31
|
+
let E = n(() => e("cn-dialog", `cn-dialog--size-${b.size}`, b.class)), D = n(() => e("cn-button", b.variant === "destructive" ? "cn-button--danger" : "cn-button--primary", "cn-button--size-md"));
|
|
32
|
+
function O(e) {
|
|
33
|
+
e.target === e.currentTarget && (e.preventDefault(), x.value = !1);
|
|
34
|
+
}
|
|
35
|
+
function k() {
|
|
36
|
+
S("confirm"), x.value = !1;
|
|
37
|
+
}
|
|
38
|
+
return (e, t) => (l(), i("dialog", {
|
|
39
|
+
ref_key: "dialog",
|
|
40
|
+
ref: C,
|
|
41
|
+
class: "cn-scrim",
|
|
42
|
+
"data-slot": "dialog-scrim",
|
|
43
|
+
"data-material": b.material,
|
|
44
|
+
role: "alertdialog",
|
|
45
|
+
"aria-labelledby": p(w),
|
|
46
|
+
"aria-describedby": o.description ? p(T) : void 0,
|
|
47
|
+
onMousedown: O
|
|
48
|
+
}, [x.value ? (l(), i("div", {
|
|
49
|
+
key: 0,
|
|
50
|
+
class: c(E.value)
|
|
51
|
+
}, [
|
|
52
|
+
a("h2", {
|
|
53
|
+
id: p(w),
|
|
54
|
+
class: "cn-dialog__title"
|
|
55
|
+
}, f(o.title), 9, _),
|
|
56
|
+
o.description ? (l(), i("p", {
|
|
57
|
+
key: 0,
|
|
58
|
+
id: p(T)
|
|
59
|
+
}, f(o.description), 9, v)) : r("", !0),
|
|
60
|
+
d(e.$slots, "default"),
|
|
61
|
+
a("div", y, [a("button", {
|
|
62
|
+
type: "button",
|
|
63
|
+
class: "cn-button cn-button--ghost cn-button--size-md",
|
|
64
|
+
onClick: t[0] ||= (e) => x.value = !1
|
|
65
|
+
}, f(o.cancelLabel), 1), a("button", {
|
|
66
|
+
type: "button",
|
|
67
|
+
class: c(D.value),
|
|
68
|
+
onClick: k
|
|
69
|
+
}, f(o.confirmLabel), 3)])
|
|
70
|
+
], 2)) : r("", !0)], 40, g));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export { b as default };
|
|
74
|
+
|
|
75
|
+
//# sourceMappingURL=Dialog.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dialog.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_unref","_normalizeClass","_createElementVNode","_toDisplayString","_createCommentVNode","_renderSlot","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","Dialog_vue_vue_type_script_setup_true_lang_default","\"open\"","\"openModifiers\"","__emit","props","__props","open","useModel","emit","dialog","ref","titleId","useId","descId","classes","computed","cn","confirmClass","onScrim","confirm","openBlock","createElementBlock","unref","normalizeClass","createElementVNode","toDisplayString","createCommentVNode","renderSlot","_ctx","_cache"],"sources":["../src/Dialog.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useId } from \"vue\";\nimport type { DialogVariant, DialogSize, Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\nimport { useModalDialog } from \"./useModalDialog.ts\";\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n title: string;\n description?: string;\n variant?: DialogVariant;\n size?: DialogSize;\n confirmLabel?: string;\n cancelLabel?: string;\n class?: string;\n }>(),\n { variant: \"default\", size: \"sm\", confirmLabel: \"Confirm\", cancelLabel: \"Cancel\" },\n);\n\nconst open = defineModel<boolean>(\"open\", { default: false });\nconst emit = defineEmits<{ confirm: [] }>();\n\nconst dialog = ref<HTMLDialogElement | null>(null);\nconst titleId = useId();\nconst descId = useId();\nuseModalDialog(dialog, open);\n\nconst classes = computed(() => cn(\"cn-dialog\", `cn-dialog--size-${props.size}`, props.class));\nconst confirmClass = computed(() =>\n cn(\n \"cn-button\",\n props.variant === \"destructive\" ? \"cn-button--danger\" : \"cn-button--primary\",\n \"cn-button--size-md\",\n ),\n);\n\nfunction onScrim(e: MouseEvent) {\n if (e.target !== e.currentTarget) return;\n // Keep the press from moving focus to the closing dialog, so focus returns to the opener.\n e.preventDefault();\n open.value = false;\n}\nfunction confirm() {\n emit(\"confirm\");\n open.value = false;\n}\n</script>\n\n<template>\n <dialog\n ref=\"dialog\"\n class=\"cn-scrim\"\n data-slot=\"dialog-scrim\"\n :data-material=\"props.material\"\n role=\"alertdialog\"\n :aria-labelledby=\"titleId\"\n :aria-describedby=\"description ? descId : undefined\"\n @mousedown=\"onScrim\"\n >\n <div v-if=\"open\" :class=\"classes\">\n <h2 :id=\"titleId\" class=\"cn-dialog__title\">{{ title }}</h2>\n <p v-if=\"description\" :id=\"descId\">{{ description }}</p>\n <slot />\n <div class=\"cn-dialog__actions\">\n <button type=\"button\" class=\"cn-button cn-button--ghost cn-button--size-md\" @click=\"open = false\">\n {{ cancelLabel }}\n </button>\n <button type=\"button\" :class=\"confirmClass\" @click=\"confirm\">{{ confirmLabel }}</button>\n </div>\n </div>\n </dialog>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMA,IAAMiB,IAAQC,GAcRC,IAAOnB,EAAoBkB,GAAC,MAA0B,GACtDG,IAAOL,GAEPM,IAASC,EAA8B,IAAI,GAC3CC,IAAUC,EAAM,GAChBC,IAASD,EAAM;EACrB,EAAeH,GAAQH,CAAI;EAE3B,IAAMQ,IAAUC,QAAeC,EAAG,aAAa,mBAAmBZ,EAAM,QAAQA,EAAM,KAAK,CAAC,GACtFa,IAAeF,QACnBC,EACE,aACAZ,EAAM,YAAY,gBAAgB,sBAAsB,sBACxD,oBACF,CACF;EAEA,SAASc,EAAQ,GAAe;GAC9B,AAAI,EAAE,WAAW,EAAE,kBAEnB,EAAE,eAAe,GACjB,EAAK,QAAQ;EACf;EACA,SAASC,IAAU;GAEjB,AADAX,EAAK,SAAS,GACd,EAAK,QAAQ;EACf;E,kBAIEpB,EAAA,GAAAC,EAqBS,UAAA;GApBH,SAAA;GAAJ,KAAIoB;GACJ,OAAM;GACN,aAAU;GACT,iBAAeL,EAAM;GACtB,MAAK;GACJ,mBAAiBd,EAAAqB,CAAA;GACjB,oBAAkBN,EAAA,cAAcf,EAAAuB,CAAA,IAAS,KAAA;GACzC,aAAWK;E,IAEDZ,EAAA,SAAXlB,EAAA,GAAAC,EAUM,OAAA;;GAVY,OAAKE,EAAEuB,EAAA,KAAO;;GAC9BtB,EAA2D,MAAA;IAAtD,IAAIF,EAAAqB,CAAA;IAAS,OAAM;GAAsB,GAAAlB,EAAAY,EAAA,KAAK,GAAA,GAAAR,CAAA;GAC1CQ,EAAA,eAATjB,EAAA,GAAAC,EAAwD,KAAA;;IAAjC,IAAIC,EAAAuB,CAAA;GAAW,GAAApB,EAAAY,EAAA,WAAW,GAAA,GAAAP,CAAA,K;GACjDH,EAAQiC,EAAA,QAAA,SAAA;GACRpC,EAKM,OALNO,GAKM,CAJJP,EAES,UAAA;IAFD,MAAK;IAAS,OAAM;IAAiD,SAAK,AAAAqC,EAAA,QAAA,MAAE,EAAA,QAAI;GACnF,GAAApC,EAAAY,EAAA,WAAW,GAAA,CAAA,GAEhBb,EAAwF,UAAA;IAAhF,MAAK;IAAU,OAAKD,EAAE0B,EAAA,KAAY;IAAG,SAAOE;GAAY,GAAA1B,EAAAY,EAAA,YAAY,GAAA,CAAA,C"}
|
package/dist/Drawer.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DrawerSize, Material } from "@crystal-neuo/contract";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
material?: Material;
|
|
4
|
+
title: string;
|
|
5
|
+
placement?: "start" | "end";
|
|
6
|
+
size?: DrawerSize;
|
|
7
|
+
class?: string;
|
|
8
|
+
};
|
|
9
|
+
type __VLS_ModelProps = {
|
|
10
|
+
"open"?: boolean;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
13
|
+
declare var __VLS_1: {};
|
|
14
|
+
type __VLS_Slots = {} & {
|
|
15
|
+
default?: (props: typeof __VLS_1) => any;
|
|
16
|
+
};
|
|
17
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
+
"update:open": (value: boolean) => any;
|
|
19
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
20
|
+
"onUpdate:open"?: (value: boolean) => any;
|
|
21
|
+
}>, {
|
|
22
|
+
size: "sm" | "md" | "lg";
|
|
23
|
+
placement: "start" | "end";
|
|
24
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
28
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
29
|
+
new (): {
|
|
30
|
+
$slots: S;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=Drawer.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.vue.d.ts","sourceRoot":"","sources":["../src/Drawer.vue"],"names":[],"mappings":"AA2DA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAKnE,KAAK,WAAW,GAAG;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC5B,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA+BJ,KAAK,gBAAgB,GAAG;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAwCxD,QAAA,IAAI,OAAO,IAAW,CAAC;AACvB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAG/C,QAAA,MAAM,UAAU;;;;;;;6EAId,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
package/dist/Drawer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.js","names":["_sfc_main","Drawer_vue_vue_type_script_setup_true_lang_default","Drawer_default"],"sources":["../src/Drawer.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useId } from \"vue\";\nimport type { DrawerSize, Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\nimport { useModalDialog } from \"./useModalDialog.ts\";\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n title: string;\n placement?: \"start\" | \"end\";\n size?: DrawerSize;\n class?: string;\n }>(),\n { placement: \"start\", size: \"md\" },\n);\n\nconst open = defineModel<boolean>(\"open\", { default: false });\n\nconst dialog = ref<HTMLDialogElement | null>(null);\nconst titleId = useId();\nuseModalDialog(dialog, open);\n\nconst classes = computed(() =>\n cn(\n \"cn-drawer\",\n `cn-drawer--size-${props.size}`,\n props.placement === \"end\" && \"cn-drawer--end\",\n props.class,\n ),\n);\n\nfunction onScrim(e: MouseEvent) {\n if (e.target !== e.currentTarget) return;\n // Keep the press from moving focus to the closing dialog, so focus returns to the opener.\n e.preventDefault();\n open.value = false;\n}\n</script>\n\n<template>\n <dialog\n ref=\"dialog\"\n class=\"cn-scrim cn-scrim--drawer\"\n data-slot=\"drawer-scrim\"\n :data-material=\"props.material\"\n :aria-labelledby=\"titleId\"\n @mousedown=\"onScrim\"\n >\n <div v-if=\"open\" :class=\"classes\">\n <h2 :id=\"titleId\" class=\"cn-drawer__title\">{{ title }}</h2>\n <slot />\n </div>\n </dialog>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { cn as e } from "./cn.js";
|
|
2
|
+
import { useModalDialog as t } from "./useModalDialog.js";
|
|
3
|
+
import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, mergeModels as s, normalizeClass as c, openBlock as l, ref as u, renderSlot as d, toDisplayString as f, unref as p, useId as m, useModel as h } from "vue";
|
|
4
|
+
// src/Drawer.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var g = ["data-material", "aria-labelledby"], _ = ["id"], v = /*@__PURE__*/ o({
|
|
6
|
+
__name: "Drawer",
|
|
7
|
+
props: /*@__PURE__*/ s({
|
|
8
|
+
material: {},
|
|
9
|
+
title: {},
|
|
10
|
+
placement: { default: "start" },
|
|
11
|
+
size: { default: "md" },
|
|
12
|
+
class: {}
|
|
13
|
+
}, {
|
|
14
|
+
open: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: !1
|
|
17
|
+
},
|
|
18
|
+
openModifiers: {}
|
|
19
|
+
}),
|
|
20
|
+
emits: ["update:open"],
|
|
21
|
+
setup(o) {
|
|
22
|
+
let s = o, v = h(o, "open"), y = u(null), b = m();
|
|
23
|
+
t(y, v);
|
|
24
|
+
let x = n(() => e("cn-drawer", `cn-drawer--size-${s.size}`, s.placement === "end" && "cn-drawer--end", s.class));
|
|
25
|
+
function S(e) {
|
|
26
|
+
e.target === e.currentTarget && (e.preventDefault(), v.value = !1);
|
|
27
|
+
}
|
|
28
|
+
return (e, t) => (l(), i("dialog", {
|
|
29
|
+
ref_key: "dialog",
|
|
30
|
+
ref: y,
|
|
31
|
+
class: "cn-scrim cn-scrim--drawer",
|
|
32
|
+
"data-slot": "drawer-scrim",
|
|
33
|
+
"data-material": s.material,
|
|
34
|
+
"aria-labelledby": p(b),
|
|
35
|
+
onMousedown: S
|
|
36
|
+
}, [v.value ? (l(), i("div", {
|
|
37
|
+
key: 0,
|
|
38
|
+
class: c(x.value)
|
|
39
|
+
}, [a("h2", {
|
|
40
|
+
id: p(b),
|
|
41
|
+
class: "cn-drawer__title"
|
|
42
|
+
}, f(o.title), 9, _), d(e.$slots, "default")], 2)) : r("", !0)], 40, g));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export { v as default };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=Drawer.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Drawer.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_unref","_normalizeClass","_createElementVNode","_toDisplayString","_renderSlot","_createCommentVNode","_hoisted_1","_hoisted_2","Drawer_vue_vue_type_script_setup_true_lang_default","\"open\"","\"openModifiers\"","props","__props","open","useModel","dialog","ref","titleId","useId","classes","computed","cn","onScrim","openBlock","createElementBlock","unref","normalizeClass","createElementVNode","toDisplayString","renderSlot","_ctx","createCommentVNode"],"sources":["../src/Drawer.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useId } from \"vue\";\nimport type { DrawerSize, Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\nimport { useModalDialog } from \"./useModalDialog.ts\";\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n title: string;\n placement?: \"start\" | \"end\";\n size?: DrawerSize;\n class?: string;\n }>(),\n { placement: \"start\", size: \"md\" },\n);\n\nconst open = defineModel<boolean>(\"open\", { default: false });\n\nconst dialog = ref<HTMLDialogElement | null>(null);\nconst titleId = useId();\nuseModalDialog(dialog, open);\n\nconst classes = computed(() =>\n cn(\n \"cn-drawer\",\n `cn-drawer--size-${props.size}`,\n props.placement === \"end\" && \"cn-drawer--end\",\n props.class,\n ),\n);\n\nfunction onScrim(e: MouseEvent) {\n if (e.target !== e.currentTarget) return;\n // Keep the press from moving focus to the closing dialog, so focus returns to the opener.\n e.preventDefault();\n open.value = false;\n}\n</script>\n\n<template>\n <dialog\n ref=\"dialog\"\n class=\"cn-scrim cn-scrim--drawer\"\n data-slot=\"drawer-scrim\"\n :data-material=\"props.material\"\n :aria-labelledby=\"titleId\"\n @mousedown=\"onScrim\"\n >\n <div v-if=\"open\" :class=\"classes\">\n <h2 :id=\"titleId\" class=\"cn-drawer__title\">{{ title }}</h2>\n <slot />\n </div>\n </dialog>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAMA,IAAMc,IAAQC,GAWRC,IAAOhB,EAAoBe,GAAC,MAA0B,GAEtDG,IAASC,EAA8B,IAAI,GAC3CC,IAAUC,EAAM;EACtB,EAAeH,GAAQF,CAAI;EAE3B,IAAMM,IAAUC,QACdC,EACE,aACA,mBAAmBV,EAAM,QACzBA,EAAM,cAAc,SAAS,kBAC7BA,EAAM,KACR,CACF;EAEA,SAASW,EAAQ,GAAe;GAC9B,AAAI,EAAE,WAAW,EAAE,kBAEnB,EAAE,eAAe,GACjB,EAAK,QAAQ;EACf;E,kBAIExB,EAAA,GAAAC,EAYS,UAAA;GAXH,SAAA;GAAJ,KAAIgB;GACJ,OAAM;GACN,aAAU;GACT,iBAAeJ,EAAM;GACrB,mBAAiBX,EAAAiB,CAAA;GACjB,aAAWK;E,IAEDT,EAAA,SAAXf,EAAA,GAAAC,EAGM,OAAA;;GAHY,OAAKE,EAAEkB,EAAA,KAAO;E,IAC9BjB,EAA2D,MAAA;GAAtD,IAAIF,EAAAiB,CAAA;GAAS,OAAM;EAAsB,GAAAd,EAAAS,EAAA,KAAK,GAAA,GAAAL,CAAA,GACnDH,EAAQ0B,EAAA,QAAA,SAAA,C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type FileUploadSize, type Material } from "@crystal-neuo/contract";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
material?: Material;
|
|
4
|
+
size?: FileUploadSize;
|
|
5
|
+
label: string;
|
|
6
|
+
hint?: string;
|
|
7
|
+
/** Error message; switches to the error variant. */
|
|
8
|
+
error?: string;
|
|
9
|
+
/** Announced while files are dragged over the zone. */
|
|
10
|
+
dropLabel?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
accept?: string;
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
class?: string;
|
|
18
|
+
};
|
|
19
|
+
type __VLS_ModelProps = {
|
|
20
|
+
"files"?: File[];
|
|
21
|
+
};
|
|
22
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
23
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
24
|
+
"update:files": (value: File[]) => any;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
26
|
+
"onUpdate:files"?: (value: File[]) => any;
|
|
27
|
+
}>, {
|
|
28
|
+
size: "md" | "lg";
|
|
29
|
+
dropLabel: string;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|
|
33
|
+
//# sourceMappingURL=FileUpload.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUpload.vue.d.ts","sourceRoot":"","sources":["../src/FileUpload.vue"],"names":[],"mappings":"AA+GA,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAM3F,KAAK,WAAW,GAAG;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAoDJ,KAAK,gBAAgB,GAAG;IACxB,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AA2FxD,QAAA,MAAM,YAAY;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUpload.js","names":["_sfc_main","FileUpload_vue_vue_type_script_setup_true_lang_default","FileUpload_default"],"sources":["../src/FileUpload.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useId, useTemplateRef } from \"vue\";\nimport { acceptedFiles, type FileUploadSize, type Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n size?: FileUploadSize;\n label: string;\n hint?: string;\n /** Error message; switches to the error variant. */\n error?: string;\n /** Announced while files are dragged over the zone. */\n dropLabel?: string;\n id?: string;\n name?: string;\n accept?: string;\n multiple?: boolean;\n required?: boolean;\n disabled?: boolean;\n class?: string;\n }>(),\n { size: \"md\", dropLabel: \"Drop to upload\" },\n);\n\nconst files = defineModel<File[]>(\"files\", { default: () => [] });\n\nconst autoId = useId();\nconst fileId = computed(() => props.id ?? autoId);\nconst hintId = computed(() => `${fileId.value}-hint`);\nconst msgId = computed(() => `${fileId.value}-msg`);\nconst describedBy = computed(\n () =>\n [props.hint ? hintId.value : null, props.error ? msgId.value : null].filter(Boolean).join(\" \") ||\n undefined,\n);\nconst dragover = ref(false);\nconst inputEl = useTemplateRef<HTMLInputElement>(\"inputEl\");\nconst classes = computed(() =>\n cn(\n \"cn-fileupload\",\n `cn-fileupload--size-${props.size}`,\n props.error && \"cn-fileupload--error\",\n props.class,\n ),\n);\n\nfunction onDragOver() {\n if (!props.disabled) dragover.value = true;\n}\nfunction onDrop(e: DragEvent) {\n dragover.value = false;\n if (props.disabled || !e.dataTransfer) return;\n const picked = acceptedFiles(e.dataTransfer.files, props.accept, props.multiple);\n if (!picked.length) return;\n // The native input stays the source of truth, so a form post carries the drop.\n if (inputEl.value) {\n const transfer = new DataTransfer();\n picked.forEach((f) => transfer.items.add(f));\n inputEl.value.files = transfer.files;\n }\n files.value = picked;\n}\nfunction onChange(e: Event) {\n const target = e.target as HTMLInputElement;\n if (target.files?.length) files.value = Array.from(target.files);\n}\n</script>\n\n<template>\n <div :class=\"classes\" data-slot=\"file-upload\" :data-material=\"props.material\">\n <button\n type=\"button\"\n class=\"cn-fileupload__zone\"\n :data-dragover=\"dragover || undefined\"\n :disabled=\"disabled\"\n :aria-describedby=\"describedBy\"\n @click=\"inputEl?.click()\"\n @dragover.prevent=\"onDragOver\"\n @dragleave=\"dragover = false\"\n @drop.prevent=\"onDrop\"\n >\n <span>{{ label }}</span>\n <span v-if=\"hint\" class=\"cn-field__hint\" :id=\"hintId\">{{ hint }}</span>\n </button>\n <input\n ref=\"inputEl\"\n v-bind=\"$attrs\"\n :id=\"fileId\"\n type=\"file\"\n class=\"cn-fileupload__input\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n :name=\"name\"\n :accept=\"accept\"\n :multiple=\"multiple\"\n :required=\"required\"\n :disabled=\"disabled\"\n @change=\"onChange\"\n />\n <span class=\"cn-visually-hidden\" aria-live=\"polite\">{{ dragover ? dropLabel : \"\" }}</span>\n <span v-if=\"error\" class=\"cn-field__message\" :id=\"msgId\">{{ error }}</span>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { cn as e } from "./cn.js";
|
|
2
|
+
import { computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, defineComponent as a, mergeModels as o, mergeProps as s, normalizeClass as c, openBlock as l, ref as u, toDisplayString as d, useId as f, useModel as p, useTemplateRef as m, withModifiers as h } from "vue";
|
|
3
|
+
import { acceptedFiles as g } from "@crystal-neuo/contract";
|
|
4
|
+
// src/FileUpload.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
+
var _ = ["data-material"], v = [
|
|
6
|
+
"data-dragover",
|
|
7
|
+
"disabled",
|
|
8
|
+
"aria-describedby"
|
|
9
|
+
], y = ["id"], b = [
|
|
10
|
+
"id",
|
|
11
|
+
"name",
|
|
12
|
+
"accept",
|
|
13
|
+
"multiple",
|
|
14
|
+
"required",
|
|
15
|
+
"disabled"
|
|
16
|
+
], x = {
|
|
17
|
+
class: "cn-visually-hidden",
|
|
18
|
+
"aria-live": "polite"
|
|
19
|
+
}, S = ["id"], C = /*@__PURE__*/ a({
|
|
20
|
+
inheritAttrs: !1,
|
|
21
|
+
__name: "FileUpload",
|
|
22
|
+
props: /*@__PURE__*/ o({
|
|
23
|
+
material: {},
|
|
24
|
+
size: { default: "md" },
|
|
25
|
+
label: {},
|
|
26
|
+
hint: {},
|
|
27
|
+
error: {},
|
|
28
|
+
dropLabel: { default: "Drop to upload" },
|
|
29
|
+
id: {},
|
|
30
|
+
name: {},
|
|
31
|
+
accept: {},
|
|
32
|
+
multiple: { type: Boolean },
|
|
33
|
+
required: { type: Boolean },
|
|
34
|
+
disabled: { type: Boolean },
|
|
35
|
+
class: {}
|
|
36
|
+
}, {
|
|
37
|
+
files: { default: () => [] },
|
|
38
|
+
filesModifiers: {}
|
|
39
|
+
}),
|
|
40
|
+
emits: ["update:files"],
|
|
41
|
+
setup(a) {
|
|
42
|
+
let o = a, C = p(a, "files"), w = f(), T = t(() => o.id ?? w), E = t(() => `${T.value}-hint`), D = t(() => `${T.value}-msg`), O = t(() => [o.hint ? E.value : null, o.error ? D.value : null].filter(Boolean).join(" ") || void 0), k = u(!1), A = m("inputEl"), j = t(() => e("cn-fileupload", `cn-fileupload--size-${o.size}`, o.error && "cn-fileupload--error", o.class));
|
|
43
|
+
function M() {
|
|
44
|
+
o.disabled || (k.value = !0);
|
|
45
|
+
}
|
|
46
|
+
function N(e) {
|
|
47
|
+
if (k.value = !1, o.disabled || !e.dataTransfer) return;
|
|
48
|
+
let t = g(e.dataTransfer.files, o.accept, o.multiple);
|
|
49
|
+
if (t.length) {
|
|
50
|
+
if (A.value) {
|
|
51
|
+
let e = new DataTransfer();
|
|
52
|
+
t.forEach((t) => e.items.add(t)), A.value.files = e.files;
|
|
53
|
+
}
|
|
54
|
+
C.value = t;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function P(e) {
|
|
58
|
+
let t = e.target;
|
|
59
|
+
t.files?.length && (C.value = Array.from(t.files));
|
|
60
|
+
}
|
|
61
|
+
return (e, t) => (l(), r("div", {
|
|
62
|
+
class: c(j.value),
|
|
63
|
+
"data-slot": "file-upload",
|
|
64
|
+
"data-material": o.material
|
|
65
|
+
}, [
|
|
66
|
+
i("button", {
|
|
67
|
+
type: "button",
|
|
68
|
+
class: "cn-fileupload__zone",
|
|
69
|
+
"data-dragover": k.value || void 0,
|
|
70
|
+
disabled: a.disabled,
|
|
71
|
+
"aria-describedby": O.value,
|
|
72
|
+
onClick: t[0] ||= (e) => A.value?.click(),
|
|
73
|
+
onDragover: h(M, ["prevent"]),
|
|
74
|
+
onDragleave: t[1] ||= (e) => k.value = !1,
|
|
75
|
+
onDrop: h(N, ["prevent"])
|
|
76
|
+
}, [i("span", null, d(a.label), 1), a.hint ? (l(), r("span", {
|
|
77
|
+
key: 0,
|
|
78
|
+
class: "cn-field__hint",
|
|
79
|
+
id: E.value
|
|
80
|
+
}, d(a.hint), 9, y)) : n("", !0)], 40, v),
|
|
81
|
+
i("input", s({
|
|
82
|
+
ref_key: "inputEl",
|
|
83
|
+
ref: A
|
|
84
|
+
}, e.$attrs, {
|
|
85
|
+
id: T.value,
|
|
86
|
+
type: "file",
|
|
87
|
+
class: "cn-fileupload__input",
|
|
88
|
+
tabindex: "-1",
|
|
89
|
+
"aria-hidden": "true",
|
|
90
|
+
name: a.name,
|
|
91
|
+
accept: a.accept,
|
|
92
|
+
multiple: a.multiple,
|
|
93
|
+
required: a.required,
|
|
94
|
+
disabled: a.disabled,
|
|
95
|
+
onChange: P
|
|
96
|
+
}), null, 16, b),
|
|
97
|
+
i("span", x, d(k.value ? a.dropLabel : ""), 1),
|
|
98
|
+
a.error ? (l(), r("span", {
|
|
99
|
+
key: 0,
|
|
100
|
+
class: "cn-field__message",
|
|
101
|
+
id: D.value
|
|
102
|
+
}, d(a.error), 9, S)) : n("", !0)
|
|
103
|
+
], 10, _));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
export { C as default };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=FileUpload.vue_vue_type_script_setup_true_lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileUpload.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_useModel","_openBlock","_createElementBlock","_normalizeClass","_createElementVNode","_withModifiers","_toDisplayString","_createCommentVNode","_mergeProps","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","FileUpload_vue_vue_type_script_setup_true_lang_default","\"files\"","\"filesModifiers\"","props","__props","files","useModel","autoId","useId","fileId","computed","hintId","msgId","describedBy","dragover","ref","inputEl","useTemplateRef","classes","cn","onDragOver","onDrop","picked","acceptedFiles","transfer","f","onChange","target","openBlock","createElementBlock","normalizeClass","createElementVNode","_cache","withModifiers","toDisplayString","createCommentVNode","mergeProps","_ctx"],"sources":["../src/FileUpload.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, ref, useId, useTemplateRef } from \"vue\";\nimport { acceptedFiles, type FileUploadSize, type Material } from \"@crystal-neuo/contract\";\nimport { cn } from \"./cn.ts\";\n\ndefineOptions({ inheritAttrs: false });\n\nconst props = withDefaults(\n defineProps<{\n material?: Material;\n size?: FileUploadSize;\n label: string;\n hint?: string;\n /** Error message; switches to the error variant. */\n error?: string;\n /** Announced while files are dragged over the zone. */\n dropLabel?: string;\n id?: string;\n name?: string;\n accept?: string;\n multiple?: boolean;\n required?: boolean;\n disabled?: boolean;\n class?: string;\n }>(),\n { size: \"md\", dropLabel: \"Drop to upload\" },\n);\n\nconst files = defineModel<File[]>(\"files\", { default: () => [] });\n\nconst autoId = useId();\nconst fileId = computed(() => props.id ?? autoId);\nconst hintId = computed(() => `${fileId.value}-hint`);\nconst msgId = computed(() => `${fileId.value}-msg`);\nconst describedBy = computed(\n () =>\n [props.hint ? hintId.value : null, props.error ? msgId.value : null].filter(Boolean).join(\" \") ||\n undefined,\n);\nconst dragover = ref(false);\nconst inputEl = useTemplateRef<HTMLInputElement>(\"inputEl\");\nconst classes = computed(() =>\n cn(\n \"cn-fileupload\",\n `cn-fileupload--size-${props.size}`,\n props.error && \"cn-fileupload--error\",\n props.class,\n ),\n);\n\nfunction onDragOver() {\n if (!props.disabled) dragover.value = true;\n}\nfunction onDrop(e: DragEvent) {\n dragover.value = false;\n if (props.disabled || !e.dataTransfer) return;\n const picked = acceptedFiles(e.dataTransfer.files, props.accept, props.multiple);\n if (!picked.length) return;\n // The native input stays the source of truth, so a form post carries the drop.\n if (inputEl.value) {\n const transfer = new DataTransfer();\n picked.forEach((f) => transfer.items.add(f));\n inputEl.value.files = transfer.files;\n }\n files.value = picked;\n}\nfunction onChange(e: Event) {\n const target = e.target as HTMLInputElement;\n if (target.files?.length) files.value = Array.from(target.files);\n}\n</script>\n\n<template>\n <div :class=\"classes\" data-slot=\"file-upload\" :data-material=\"props.material\">\n <button\n type=\"button\"\n class=\"cn-fileupload__zone\"\n :data-dragover=\"dragover || undefined\"\n :disabled=\"disabled\"\n :aria-describedby=\"describedBy\"\n @click=\"inputEl?.click()\"\n @dragover.prevent=\"onDragOver\"\n @dragleave=\"dragover = false\"\n @drop.prevent=\"onDrop\"\n >\n <span>{{ label }}</span>\n <span v-if=\"hint\" class=\"cn-field__hint\" :id=\"hintId\">{{ hint }}</span>\n </button>\n <input\n ref=\"inputEl\"\n v-bind=\"$attrs\"\n :id=\"fileId\"\n type=\"file\"\n class=\"cn-fileupload__input\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n :name=\"name\"\n :accept=\"accept\"\n :multiple=\"multiple\"\n :required=\"required\"\n :disabled=\"disabled\"\n @change=\"onChange\"\n />\n <span class=\"cn-visually-hidden\" aria-live=\"polite\">{{ dragover ? dropLabel : \"\" }}</span>\n <span v-if=\"error\" class=\"cn-field__message\" :id=\"msgId\">{{ error }}</span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOA,IAAMmB,IAAQC,GAqBRC,IAAQpB,EAAmBmB,GAAC,OAA8B,GAE1DG,IAASC,EAAM,GACfC,IAASC,QAAeP,EAAM,MAAMI,CAAM,GAC1CI,IAASD,QAAe,GAAGD,EAAO,MAAM,MAAM,GAC9CG,IAAQF,QAAe,GAAGD,EAAO,MAAM,KAAK,GAC5CI,IAAcH,QAEhB,CAACP,EAAM,OAAOQ,EAAO,QAAQ,MAAMR,EAAM,QAAQS,EAAM,QAAQ,IAAI,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAC7F,KAAA,CACJ,GACME,IAAWC,EAAI,EAAK,GACpBC,IAAUC,EAAiC,SAAS,GACpDC,IAAUR,QACdS,EACE,iBACA,uBAAuBhB,EAAM,QAC7BA,EAAM,SAAS,wBACfA,EAAM,KACR,CACF;EAEA,SAASiB,IAAa;GACpB,AAAKjB,EAAM,aAAU,EAAS,QAAQ;EACxC;EACA,SAASkB,EAAO,GAAc;GAE5B,IADA,EAAS,QAAQ,IACblB,EAAM,YAAY,CAAC,EAAE,cAAc;GACvC,IAAMmB,IAASC,EAAc,EAAE,aAAa,OAAOpB,EAAM,QAAQA,EAAM,QAAQ;GAC/E,IAAKmB,EAAO,QAEZ;QAAIN,EAAQ,OAAO;KACjB,IAAMQ,IAAW,IAAI,aAAa;KAElC,AADAF,EAAO,SAAS,MAAME,EAAS,MAAM,IAAIC,CAAC,CAAC,GAC3C,EAAQ,MAAM,QAAQD,EAAS;IACjC;IACA,EAAM,QAAQF;GADd;EAEF;EACA,SAASI,EAAS,GAAU;GAC1B,IAAMC,IAAS,EAAE;GACjB,AAAIA,EAAO,OAAO,WAAQ,EAAM,QAAQ,MAAM,KAAKA,EAAO,KAAK;EACjE;E,kBAIEzC,EAAA,GAAAC,EAgCM,OAAA;GAhCA,OAAKC,EAAE8B,EAAA,KAAO;GAAE,aAAU;GAAe,iBAAef,EAAM;;GAClEd,EAaS,UAAA;IAZP,MAAK;IACL,OAAM;IACL,iBAAeyB,EAAA,SAAY,KAAA;IAC3B,UAAUV,EAAA;IACV,oBAAkBS,EAAA;IAClB,SAAK,AAAAmB,EAAA,QAAA,MAAEhB,EAAA,OAAS,MAAK;IACrB,YAAQ1B,EAAU8B,GAAU,CAAA,SAAA,CAAA;IAC5B,aAAS,AAAAY,EAAA,QAAA,MAAE,EAAA,QAAQ;IACnB,QAAI1C,EAAU+B,GAAM,CAAA,SAAA,CAAA;G,IAErBhC,EAAwB,QAAA,MAAAE,EAAfa,EAAA,KAAK,GAAA,CAAA,GACFA,EAAA,QAAZlB,EAAA,GAAAC,EAAuE,QAAA;;IAArD,OAAM;IAAkB,IAAIwB,EAAA;GAAW,GAAApB,EAAAa,EAAA,IAAI,GAAA,GAAAR,CAAA,K;GAE/DP,EAcE,SAdFI,EAcE;IAbI,SAAA;IAAJ,KAAIuB;GACIhC,GAAAA,EAAAA,QAAM;IACb,IAAIyB,EAAA;IACL,MAAK;IACL,OAAM;IACN,UAAS;IACT,eAAY;IACX,MAAML,EAAA;IACN,QAAQA,EAAA;IACR,UAAUA,EAAA;IACV,UAAUA,EAAA;IACV,UAAUA,EAAA;IACF;;GAEXf,EAA0F,QAA1FS,GAA0FP,EAAnCuB,EAAA,QAAWV,EAAA,YAAS,EAAA,GAAA,CAAA;GAC/DA,EAAA,SAAZlB,EAAA,GAAAC,EAA2E,QAAA;;IAAxD,OAAM;IAAqB,IAAIyB,EAAA;GAAU,GAAArB,EAAAa,EAAA,KAAK,GAAA,GAAAL,CAAA,K"}
|