@crystal-neuo/vue 4.0.0 → 4.2.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/dist/Input.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { type VNode } from "vue";
1
2
  import type { InputSize, Material } from "@crystal-neuo/contract";
2
3
  type __VLS_Props = {
3
4
  material?: Material;
@@ -10,11 +11,17 @@ type __VLS_Props = {
10
11
  disabled?: boolean;
11
12
  type?: string;
12
13
  };
14
+ type __VLS_Slots = {
15
+ /** Inside the input's box, at its start, centred on the input: e.g. a search or currency icon. */
16
+ start?: () => VNode[];
17
+ /** Inside the input's box, at its end, centred on the input: e.g. a reveal or clear button. */
18
+ end?: () => VNode[];
19
+ };
13
20
  type __VLS_ModelProps = {
14
21
  modelValue?: string;
15
22
  };
16
23
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
17
- declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
24
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
25
  "update:modelValue": (value: string) => any;
19
26
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
20
27
  "onUpdate:modelValue"?: (value: string) => any;
@@ -22,6 +29,12 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
22
29
  size: "sm" | "md" | "lg";
23
30
  type: string;
24
31
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
32
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
25
33
  declare const _default: typeof __VLS_export;
26
34
  export default _default;
35
+ type __VLS_WithSlots<T, S> = T & {
36
+ new (): {
37
+ $slots: S;
38
+ };
39
+ };
27
40
  //# sourceMappingURL=Input.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.vue.d.ts","sourceRoot":"","sources":["../src/Input.vue"],"names":[],"mappings":"AA8DA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAOlE,KAAK,WAAW,GAAG;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAyBJ,KAAK,gBAAgB,GAAG;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AA2DxD,QAAA,MAAM,YAAY;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"Input.vue.d.ts","sourceRoot":"","sources":["../src/Input.vue"],"names":[],"mappings":"AAsEA,OAAO,EAAmB,KAAK,KAAK,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAOlE,KAAK,WAAW,GAAG;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAMJ,KAAK,WAAW,GAAG;IACjB,kGAAkG;IAClG,KAAK,CAAC,EAAE,MAAM,KAAK,EAAE,CAAC;IACtB,+FAA+F;IAC/F,GAAG,CAAC,EAAE,MAAM,KAAK,EAAE,CAAC;CACrB,CAAC;AA6BF,KAAK,gBAAgB,GAAG;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAOF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAgFxD,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/Input.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Input.js","names":["_sfc_main","Input_vue_vue_type_script_setup_true_lang_default","Input_default"],"sources":["../src/Input.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useId } from \"vue\";\nimport type { InputSize, 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?: InputSize;\n label?: string;\n error?: string;\n hint?: string;\n id?: string;\n placeholder?: string;\n disabled?: boolean;\n type?: string;\n }>(),\n { size: \"md\", type: \"text\" },\n);\n\nconst model = defineModel<string>({ default: \"\" });\n\nconst autoId = useId();\nconst inputId = computed(() => props.id ?? autoId);\nconst msgId = computed(() => `${inputId.value}-msg`);\nconst hintId = computed(() => `${inputId.value}-hint`);\nconst describedBy = computed(\n () =>\n [props.error ? msgId.value : null, props.hint ? hintId.value : null].filter(Boolean).join(\" \") ||\n undefined,\n);\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=\"input-field\" :data-material=\"props.material\">\n <label v-if=\"label\" class=\"cn-field__label\" :for=\"inputId\">{{ label }}</label>\n <input\n v-bind=\"controlAttrs\"\n :id=\"inputId\"\n v-model=\"model\"\n :class=\"inputClass\"\n :type=\"type\"\n :placeholder=\"placeholder\"\n :disabled=\"disabled\"\n :aria-invalid=\"error ? true : undefined\"\n :aria-describedby=\"describedBy\"\n />\n <span v-if=\"hint && !error\" class=\"cn-field__hint\" :id=\"hintId\">{{ hint }}</span>\n <span v-if=\"error\" class=\"cn-field__message\" :id=\"msgId\">{{ error }}</span>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"Input.js","names":["_sfc_main","Input_vue_vue_type_script_setup_true_lang_default","Input_default"],"sources":["../src/Input.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useId, type VNode } from \"vue\";\nimport type { InputSize, 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?: InputSize;\n label?: string;\n error?: string;\n hint?: string;\n id?: string;\n placeholder?: string;\n disabled?: boolean;\n type?: string;\n }>(),\n { size: \"md\", type: \"text\" },\n);\n\nconst slots = defineSlots<{\n /** Inside the input's box, at its start, centred on the input: e.g. a search or currency icon. */\n start?: () => VNode[];\n /** Inside the input's box, at its end, centred on the input: e.g. a reveal or clear button. */\n end?: () => VNode[];\n}>();\n\nconst model = defineModel<string>({ default: \"\" });\n\nconst autoId = useId();\nconst inputId = computed(() => props.id ?? autoId);\nconst msgId = computed(() => `${inputId.value}-msg`);\nconst hintId = computed(() => `${inputId.value}-hint`);\nconst describedBy = computed(\n () =>\n [props.error ? msgId.value : null, props.hint ? hintId.value : null].filter(Boolean).join(\" \") ||\n undefined,\n);\nconst { rootAttrs, controlAttrs } = useControlAttrs();\nconst inputAttrs = computed(() => ({\n ...controlAttrs.value,\n id: inputId.value,\n class: cn(\"cn-input\", `cn-input--size-${props.size}`, props.error && \"cn-input--error\"),\n type: props.type,\n placeholder: props.placeholder,\n disabled: props.disabled,\n \"aria-invalid\": props.error ? true : undefined,\n \"aria-describedby\": describedBy.value,\n}));\n</script>\n\n<template>\n <div v-bind=\"rootAttrs\" class=\"cn-field\" data-slot=\"input-field\" :data-material=\"props.material\">\n <label v-if=\"label\" class=\"cn-field__label\" :for=\"inputId\">{{ label }}</label>\n <div v-if=\"slots.start || slots.end\" :class=\"['cn-input-group', `cn-input-group--size-${props.size}`]\">\n <span v-if=\"slots.start\" class=\"cn-input-group__start\"><slot name=\"start\" /></span>\n <input v-bind=\"inputAttrs\" v-model=\"model\" />\n <span v-if=\"slots.end\" class=\"cn-input-group__end\"><slot name=\"end\" /></span>\n </div>\n <input v-else v-bind=\"inputAttrs\" v-model=\"model\" />\n <span v-if=\"hint && !error\" class=\"cn-field__hint\" :id=\"hintId\">{{ hint }}</span>\n <span v-if=\"error\" class=\"cn-field__message\" :id=\"msgId\">{{ error }}</span>\n </div>\n</template>\n"],"mappings":""}
@@ -1,15 +1,14 @@
1
1
  import { cn as e } from "./cn.js";
2
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, vModelDynamic as m, withDirectives as h } from "vue";
3
+ import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, defineComponent as o, mergeModels as s, mergeProps as c, normalizeClass as l, openBlock as u, renderSlot as d, toDisplayString as f, unref as p, useId as m, useModel as h, useSlots as g, vModelDynamic as _, withDirectives as v } from "vue";
4
4
  // src/Input.vue?vue&type=script&setup=true&lang.ts
5
- var g = ["data-material"], _ = ["for"], v = [
6
- "id",
7
- "type",
8
- "placeholder",
9
- "disabled",
10
- "aria-invalid",
11
- "aria-describedby"
12
- ], y = ["id"], b = ["id"], x = /*@__PURE__*/ o({
5
+ var y = ["data-material"], b = ["for"], x = {
6
+ key: 0,
7
+ class: "cn-input-group__start"
8
+ }, S = {
9
+ key: 1,
10
+ class: "cn-input-group__end"
11
+ }, C = ["id"], w = ["id"], T = /*@__PURE__*/ o({
13
12
  inheritAttrs: !1,
14
13
  __name: "Input",
15
14
  props: /*@__PURE__*/ s({
@@ -28,40 +27,47 @@ var g = ["data-material"], _ = ["for"], v = [
28
27
  }),
29
28
  emits: ["update:modelValue"],
30
29
  setup(o) {
31
- let s = o, x = p(o, "modelValue"), S = f(), C = n(() => s.id ?? S), w = n(() => `${C.value}-msg`), T = n(() => `${C.value}-hint`), E = n(() => [s.error ? w.value : null, s.hint ? T.value : null].filter(Boolean).join(" ") || void 0), D = n(() => e("cn-input", `cn-input--size-${s.size}`, s.error && "cn-input--error")), { rootAttrs: O, controlAttrs: k } = t();
32
- return (e, t) => (l(), i("div", c(d(O), {
30
+ let s = o, T = g(), E = h(o, "modelValue"), D = m(), O = n(() => s.id ?? D), k = n(() => `${O.value}-msg`), A = n(() => `${O.value}-hint`), j = n(() => [s.error ? k.value : null, s.hint ? A.value : null].filter(Boolean).join(" ") || void 0), { rootAttrs: M, controlAttrs: N } = t(), P = n(() => ({
31
+ ...N.value,
32
+ id: O.value,
33
+ class: e("cn-input", `cn-input--size-${s.size}`, s.error && "cn-input--error"),
34
+ type: s.type,
35
+ placeholder: s.placeholder,
36
+ disabled: s.disabled,
37
+ "aria-invalid": s.error ? !0 : void 0,
38
+ "aria-describedby": j.value
39
+ }));
40
+ return (e, t) => (u(), i("div", c(p(M), {
33
41
  class: "cn-field",
34
42
  "data-slot": "input-field",
35
43
  "data-material": s.material
36
44
  }), [
37
- o.label ? (l(), i("label", {
45
+ o.label ? (u(), i("label", {
38
46
  key: 0,
39
47
  class: "cn-field__label",
40
- for: C.value
41
- }, u(o.label), 9, _)) : r("", !0),
42
- h(a("input", c(d(k), {
43
- id: C.value,
44
- "onUpdate:modelValue": t[0] ||= (e) => x.value = e,
45
- class: D.value,
46
- type: o.type,
47
- placeholder: o.placeholder,
48
- disabled: o.disabled,
49
- "aria-invalid": o.error ? !0 : void 0,
50
- "aria-describedby": E.value
51
- }), null, 16, v), [[m, x.value]]),
52
- o.hint && !o.error ? (l(), i("span", {
48
+ for: O.value
49
+ }, f(o.label), 9, b)) : r("", !0),
50
+ T.start || T.end ? (u(), i("div", {
53
51
  key: 1,
52
+ class: l(["cn-input-group", `cn-input-group--size-${s.size}`])
53
+ }, [
54
+ T.start ? (u(), i("span", x, [d(e.$slots, "start")])) : r("", !0),
55
+ v(a("input", c(P.value, { "onUpdate:modelValue": t[0] ||= (e) => E.value = e }), null, 16), [[_, E.value]]),
56
+ T.end ? (u(), i("span", S, [d(e.$slots, "end")])) : r("", !0)
57
+ ], 2)) : v((u(), i("input", c({ key: 2 }, P.value, { "onUpdate:modelValue": t[1] ||= (e) => E.value = e }), null, 16)), [[_, E.value]]),
58
+ o.hint && !o.error ? (u(), i("span", {
59
+ key: 3,
54
60
  class: "cn-field__hint",
55
- id: T.value
56
- }, u(o.hint), 9, y)) : r("", !0),
57
- o.error ? (l(), i("span", {
58
- key: 2,
61
+ id: A.value
62
+ }, f(o.hint), 9, C)) : r("", !0),
63
+ o.error ? (u(), i("span", {
64
+ key: 4,
59
65
  class: "cn-field__message",
60
- id: w.value
61
- }, u(o.error), 9, b)) : r("", !0)
62
- ], 16, g));
66
+ id: k.value
67
+ }, f(o.error), 9, w)) : r("", !0)
68
+ ], 16, y));
63
69
  }
64
70
  });
65
- export { x as default };
71
+ export { T as default };
66
72
 
67
73
  //# sourceMappingURL=Input.vue_vue_type_script_setup_true_lang.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_mergeProps","_unref","_toDisplayString","_createCommentVNode","_withDirectives","_createElementVNode","_vModelDynamic","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","Input_vue_vue_type_script_setup_true_lang_default","\"modelValue\"","\"modelModifiers\"","props","__props","model","useModel","autoId","useId","inputId","computed","msgId","hintId","describedBy","inputClass","cn","useControlAttrs","openBlock","createElementBlock","mergeProps","unref","rootAttrs","toDisplayString","createCommentVNode","withDirectives","createElementVNode","controlAttrs","_cache","$event","vModelDynamic"],"sources":["../src/Input.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useId } from \"vue\";\nimport type { InputSize, 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?: InputSize;\n label?: string;\n error?: string;\n hint?: string;\n id?: string;\n placeholder?: string;\n disabled?: boolean;\n type?: string;\n }>(),\n { size: \"md\", type: \"text\" },\n);\n\nconst model = defineModel<string>({ default: \"\" });\n\nconst autoId = useId();\nconst inputId = computed(() => props.id ?? autoId);\nconst msgId = computed(() => `${inputId.value}-msg`);\nconst hintId = computed(() => `${inputId.value}-hint`);\nconst describedBy = computed(\n () =>\n [props.error ? msgId.value : null, props.hint ? hintId.value : null].filter(Boolean).join(\" \") ||\n undefined,\n);\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=\"input-field\" :data-material=\"props.material\">\n <label v-if=\"label\" class=\"cn-field__label\" :for=\"inputId\">{{ label }}</label>\n <input\n v-bind=\"controlAttrs\"\n :id=\"inputId\"\n v-model=\"model\"\n :class=\"inputClass\"\n :type=\"type\"\n :placeholder=\"placeholder\"\n :disabled=\"disabled\"\n :aria-invalid=\"error ? true : undefined\"\n :aria-describedby=\"describedBy\"\n />\n <span v-if=\"hint && !error\" class=\"cn-field__hint\" :id=\"hintId\">{{ hint }}</span>\n <span v-if=\"error\" class=\"cn-field__message\" :id=\"msgId\">{{ error }}</span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQA,IAAMkB,IAAQC,GAeRC,IAAQpB,EAAmBmB,GAAA,YAAgB,GAE3CG,IAASC,EAAM,GACfC,IAAUC,QAAeP,EAAM,MAAMI,CAAM,GAC3CI,IAAQD,QAAe,GAAGD,EAAQ,MAAM,KAAK,GAC7CG,IAASF,QAAe,GAAGD,EAAQ,MAAM,MAAM,GAC/CI,IAAcH,QAEhB,CAACP,EAAM,QAAQQ,EAAM,QAAQ,MAAMR,EAAM,OAAOS,EAAO,QAAQ,IAAI,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAC7F,KAAA,CACJ,GACME,IAAaJ,QACjBK,EAAG,YAAY,kBAAkBZ,EAAM,QAAQA,EAAM,SAAS,iBAAiB,CACjF,GACM,EAAE,cAAW,oBAAiBa,EAAgB;E,kBAIlD9B,EAAA,GAAAC,EAeM,OAfNC,EAAaC,EAePgC,CAAA,GAfgB;GAAE,OAAM;GAAW,aAAU;GAAe,iBAAelB,EAAM;;GACxEC,EAAA,SAAblB,EAAA,GAAAC,EAA8E,SAAA;;IAA1D,OAAM;IAAmB,KAAKsB,EAAA;GAAY,GAAAnB,EAAAc,EAAA,KAAK,GAAA,GAAAR,CAAA,K;GACnEJ,EAAAC,EAUE,SAVFL,EACUC,EASRqC,CAAA,GAToB;IACnB,IAAIjB,EAAA;IACI,uBAAA,AAAAkB,EAAA,QAAA,MAAA,EAAK,QAAAC;IACb,OAAOd,EAAA;IACP,MAAMV,EAAA;IACN,aAAaA,EAAA;IACb,UAAUA,EAAA;IACV,gBAAcA,EAAA,QAAK,KAAU,KAAA;IAC7B,oBAAkBS,EAAA;G,mBANV,CAAAnB,GAAAW,EAAA,KAAK,C;GAQJD,EAAA,QAAI,CAAKA,EAAA,SAArBlB,EAAA,GAAAC,EAAiF,QAAA;;IAArD,OAAM;IAAkB,IAAIyB,EAAA;GAAW,GAAAtB,EAAAc,EAAA,IAAI,GAAA,GAAAN,CAAA,K;GAC3DM,EAAA,SAAZlB,EAAA,GAAAC,EAA2E,QAAA;;IAAxD,OAAM;IAAqB,IAAIwB,EAAA;GAAU,GAAArB,EAAAc,EAAA,KAAK,GAAA,GAAAL,CAAA,K"}
1
+ {"version":3,"file":"Input.vue_vue_type_script_setup_true_lang.js","names":["_useSlots","_useModel","_openBlock","_createElementBlock","_mergeProps","_unref","_toDisplayString","_createCommentVNode","_normalizeClass","_renderSlot","_withDirectives","_createElementVNode","_vModelDynamic","_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_hoisted_5","_hoisted_6","Input_vue_vue_type_script_setup_true_lang_default","\"modelValue\"","\"modelModifiers\"","props","__props","slots","useSlots","model","useModel","autoId","useId","inputId","computed","msgId","hintId","describedBy","useControlAttrs","inputAttrs","controlAttrs","cn","openBlock","createElementBlock","mergeProps","unref","rootAttrs","toDisplayString","createCommentVNode","normalizeClass","renderSlot","_ctx","withDirectives","createElementVNode","_cache","$event","vModelDynamic"],"sources":["../src/Input.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, useId, type VNode } from \"vue\";\nimport type { InputSize, 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?: InputSize;\n label?: string;\n error?: string;\n hint?: string;\n id?: string;\n placeholder?: string;\n disabled?: boolean;\n type?: string;\n }>(),\n { size: \"md\", type: \"text\" },\n);\n\nconst slots = defineSlots<{\n /** Inside the input's box, at its start, centred on the input: e.g. a search or currency icon. */\n start?: () => VNode[];\n /** Inside the input's box, at its end, centred on the input: e.g. a reveal or clear button. */\n end?: () => VNode[];\n}>();\n\nconst model = defineModel<string>({ default: \"\" });\n\nconst autoId = useId();\nconst inputId = computed(() => props.id ?? autoId);\nconst msgId = computed(() => `${inputId.value}-msg`);\nconst hintId = computed(() => `${inputId.value}-hint`);\nconst describedBy = computed(\n () =>\n [props.error ? msgId.value : null, props.hint ? hintId.value : null].filter(Boolean).join(\" \") ||\n undefined,\n);\nconst { rootAttrs, controlAttrs } = useControlAttrs();\nconst inputAttrs = computed(() => ({\n ...controlAttrs.value,\n id: inputId.value,\n class: cn(\"cn-input\", `cn-input--size-${props.size}`, props.error && \"cn-input--error\"),\n type: props.type,\n placeholder: props.placeholder,\n disabled: props.disabled,\n \"aria-invalid\": props.error ? true : undefined,\n \"aria-describedby\": describedBy.value,\n}));\n</script>\n\n<template>\n <div v-bind=\"rootAttrs\" class=\"cn-field\" data-slot=\"input-field\" :data-material=\"props.material\">\n <label v-if=\"label\" class=\"cn-field__label\" :for=\"inputId\">{{ label }}</label>\n <div v-if=\"slots.start || slots.end\" :class=\"['cn-input-group', `cn-input-group--size-${props.size}`]\">\n <span v-if=\"slots.start\" class=\"cn-input-group__start\"><slot name=\"start\" /></span>\n <input v-bind=\"inputAttrs\" v-model=\"model\" />\n <span v-if=\"slots.end\" class=\"cn-input-group__end\"><slot name=\"end\" /></span>\n </div>\n <input v-else v-bind=\"inputAttrs\" v-model=\"model\" />\n <span v-if=\"hint && !error\" class=\"cn-field__hint\" :id=\"hintId\">{{ hint }}</span>\n <span v-if=\"error\" class=\"cn-field__message\" :id=\"msgId\">{{ error }}</span>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQA,IAAMsB,IAAQC,GAeRC,IAAQxB,EAAA,GAOR0B,IAAQzB,EAAmBsB,GAAA,YAAgB,GAE3CK,IAASC,EAAM,GACfC,IAAUC,QAAeT,EAAM,MAAMM,CAAM,GAC3CI,IAAQD,QAAe,GAAGD,EAAQ,MAAM,KAAK,GAC7CG,IAASF,QAAe,GAAGD,EAAQ,MAAM,MAAM,GAC/CI,IAAcH,QAEhB,CAACT,EAAM,QAAQU,EAAM,QAAQ,MAAMV,EAAM,OAAOW,EAAO,QAAQ,IAAI,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAC7F,KAAA,CACJ,GACM,EAAE,cAAW,oBAAiBE,EAAgB,GAC9CC,IAAaL,SAAgB;GACjC,GAAGM,EAAa;GAChB,IAAIP,EAAQ;GACZ,OAAOQ,EAAG,YAAY,kBAAkBhB,EAAM,QAAQA,EAAM,SAAS,iBAAiB;GACtF,MAAMA,EAAM;GACZ,aAAaA,EAAM;GACnB,UAAUA,EAAM;GAChB,gBAAgBA,EAAM,QAAQ,KAAO,KAAA;GACrC,oBAAoBY,EAAY;EAClC,EAAE;E,kBAIAhC,EAAA,GAAAC,EAUM,OAVNC,EAAaC,EAUPsC,CAAA,GAVgB;GAAE,OAAM;GAAW,aAAU;GAAe,iBAAerB,EAAM;;GACxEC,EAAA,SAAbrB,EAAA,GAAAC,EAA8E,SAAA;;IAA1D,OAAM;IAAmB,KAAK2B,EAAA;GAAY,GAAAxB,EAAAiB,EAAA,KAAK,GAAA,GAAAT,CAAA,K;GACxDU,EAAM,SAASA,EAAM,OAAhCtB,EAAA,GAAAC,EAIM,OAAA;;IAJgC,OAAKK,EAAA,CAAA,kBAAA,wBAA6Cc,EAAM,MAAI,CAAA;;IACpFE,EAAM,SAAlBtB,EAAA,GAAAC,EAAmF,QAAnFY,GAAmF,CAA5BN,EAAqBuC,EAAA,QAAA,OAAA,C;IAC5EtC,EAAAC,EAA6C,SAA7CP,EAAegC,EAA8B,OAApB,EAAW,uBAAA,AAAAe,EAAA,QAAA,MAAA,EAAK,QAAAC,E,gBAAL,CAAAxC,GAAAc,EAAA,KAAK,C;IAC7BF,EAAM,OAAlBtB,EAAA,GAAAC,EAA6E,QAA7Ea,GAA6E,CAA1BP,EAAmBuC,EAAA,QAAA,KAAA,C;G,SAExEtC,GAAAR,EAAA,GAAAC,EAAoD,SAApDC,EAAoD,EAAA,KAAA,EAAA,GAA9BgC,EAAA,OAAU,EAAW,uBAAA,AAAAe,EAAA,QAAA,MAAA,EAAK,QAAAC,E,iBAAL,CAAAxC,GAAAc,EAAA,KAAK,C;GACpCH,EAAA,QAAI,CAAKA,EAAA,SAArBrB,EAAA,GAAAC,EAAiF,QAAA;;IAArD,OAAM;IAAkB,IAAI8B,EAAA;GAAW,GAAA3B,EAAAiB,EAAA,IAAI,GAAA,GAAAN,CAAA,K;GAC3DM,EAAA,SAAZrB,EAAA,GAAAC,EAA2E,QAAA;;IAAxD,OAAM;IAAqB,IAAI6B,EAAA;GAAU,GAAA1B,EAAAiB,EAAA,KAAK,GAAA,GAAAL,CAAA,K"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystal-neuo/vue",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "Crystal Neuo Vue 3 components (Composition API, <script setup>, TS). API parity with @crystal-neuo/react via @crystal-neuo/contract.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,8 +29,8 @@
29
29
  "vue": ">=3.4"
30
30
  },
31
31
  "dependencies": {
32
- "@crystal-neuo/contract": "4.0.0",
33
- "@crystal-neuo/css": "4.0.0"
32
+ "@crystal-neuo/contract": "4.2.0",
33
+ "@crystal-neuo/css": "4.2.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "typescript": "^6.0.3",
package/src/Input.vue CHANGED
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, useId } from "vue";
2
+ import { computed, useId, type VNode } from "vue";
3
3
  import type { InputSize, Material } from "@crystal-neuo/contract";
4
4
  import { cn } from "./cn.ts";
5
5
  import { useControlAttrs } from "./useControlAttrs.ts";
@@ -21,6 +21,13 @@ const props = withDefaults(
21
21
  { size: "md", type: "text" },
22
22
  );
23
23
 
24
+ const slots = defineSlots<{
25
+ /** Inside the input's box, at its start, centred on the input: e.g. a search or currency icon. */
26
+ start?: () => VNode[];
27
+ /** Inside the input's box, at its end, centred on the input: e.g. a reveal or clear button. */
28
+ end?: () => VNode[];
29
+ }>();
30
+
24
31
  const model = defineModel<string>({ default: "" });
25
32
 
26
33
  const autoId = useId();
@@ -32,26 +39,28 @@ const describedBy = computed(
32
39
  [props.error ? msgId.value : null, props.hint ? hintId.value : null].filter(Boolean).join(" ") ||
33
40
  undefined,
34
41
  );
35
- const inputClass = computed(() =>
36
- cn("cn-input", `cn-input--size-${props.size}`, props.error && "cn-input--error"),
37
- );
38
42
  const { rootAttrs, controlAttrs } = useControlAttrs();
43
+ const inputAttrs = computed(() => ({
44
+ ...controlAttrs.value,
45
+ id: inputId.value,
46
+ class: cn("cn-input", `cn-input--size-${props.size}`, props.error && "cn-input--error"),
47
+ type: props.type,
48
+ placeholder: props.placeholder,
49
+ disabled: props.disabled,
50
+ "aria-invalid": props.error ? true : undefined,
51
+ "aria-describedby": describedBy.value,
52
+ }));
39
53
  </script>
40
54
 
41
55
  <template>
42
56
  <div v-bind="rootAttrs" class="cn-field" data-slot="input-field" :data-material="props.material">
43
57
  <label v-if="label" class="cn-field__label" :for="inputId">{{ label }}</label>
44
- <input
45
- v-bind="controlAttrs"
46
- :id="inputId"
47
- v-model="model"
48
- :class="inputClass"
49
- :type="type"
50
- :placeholder="placeholder"
51
- :disabled="disabled"
52
- :aria-invalid="error ? true : undefined"
53
- :aria-describedby="describedBy"
54
- />
58
+ <div v-if="slots.start || slots.end" :class="['cn-input-group', `cn-input-group--size-${props.size}`]">
59
+ <span v-if="slots.start" class="cn-input-group__start"><slot name="start" /></span>
60
+ <input v-bind="inputAttrs" v-model="model" />
61
+ <span v-if="slots.end" class="cn-input-group__end"><slot name="end" /></span>
62
+ </div>
63
+ <input v-else v-bind="inputAttrs" v-model="model" />
55
64
  <span v-if="hint && !error" class="cn-field__hint" :id="hintId">{{ hint }}</span>
56
65
  <span v-if="error" class="cn-field__message" :id="msgId">{{ error }}</span>
57
66
  </div>