espri-vue-input-text-float 0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Float Input Text - Vue component
2
+
3
+ `import FloatInputText from 'espri-vue-float-input-text';`
@@ -0,0 +1,17 @@
1
+ import type { DefineComponent } from 'vue';
2
+ import type { InputTextFloatEmitsForDoc } from './interfaces/input-text-float-emits.interface';
3
+ import type InputTextFloatProps from './interfaces/input-text-float-props.interface';
4
+ /**
5
+ * **ESPRI Digital - Select Float (Vue component)**
6
+ * --- ---
7
+ * ![ESPRIDigital](https://espridigital.fr/wp-content/uploads/2024/09/logo_espri_digital_white-100-1.png)
8
+ *
9
+ */
10
+ declare const InputTextFloat: DefineComponent<InputTextFloatProps, {}, // For slots if any
11
+ {}, // For methods or data if any
12
+ {}, // Computed
13
+ {}, // Methods
14
+ {}, // Mixin
15
+ {}, // Extends
16
+ InputTextFloatEmitsForDoc>;
17
+ export default InputTextFloat;
@@ -0,0 +1,79 @@
1
+ import { defineComponent as b, computed as c, openBlock as s, createElementBlock as m, normalizeClass as p, createBlock as f, unref as o, withCtx as k, createVNode as v, createElementVNode as h, createTextVNode as y, toDisplayString as g, createCommentVNode as B } from "vue";
2
+ import { Skeleton as C, FloatLabel as w, InputText as E } from "primevue";
3
+ const N = ["for"], $ = {
4
+ key: 0,
5
+ class: "text-danger"
6
+ }, I = { class: "text-danger" }, T = /* @__PURE__ */ b({
7
+ __name: "input-text-float",
8
+ props: {
9
+ label: {},
10
+ modelValue: {},
11
+ class: {},
12
+ classInput: {},
13
+ disabled: { type: Boolean },
14
+ required: { type: Boolean },
15
+ loading: { type: Boolean },
16
+ showError: { type: Boolean },
17
+ rules: {},
18
+ maxlength: {},
19
+ placeholder: {}
20
+ },
21
+ emits: ["update:modelValue"],
22
+ setup(e, { emit: V }) {
23
+ const n = e, d = V, r = Math.random().toString(16).slice(2), u = c({
24
+ get() {
25
+ return n.modelValue;
26
+ },
27
+ set(l) {
28
+ d("update:modelValue", l);
29
+ }
30
+ }), i = c(() => {
31
+ if (n.showError) {
32
+ const l = n.rules || [];
33
+ for (let t = 0; t < l.length; t++) {
34
+ const a = l[t];
35
+ if (a && a.$invalid && a.$message)
36
+ return a.$message;
37
+ }
38
+ }
39
+ return "";
40
+ });
41
+ function x(l) {
42
+ d("update:modelValue", l);
43
+ }
44
+ return (l, t) => (s(), m("div", {
45
+ class: p(`field ${n.class || ""}`)
46
+ }, [
47
+ e.loading ? (s(), f(o(C), {
48
+ key: 0,
49
+ class: "skeleton-input mt-3"
50
+ })) : (s(), f(o(w), {
51
+ key: 1,
52
+ class: "mt-3"
53
+ }, {
54
+ default: k(() => [
55
+ v(o(E), {
56
+ modelValue: u.value,
57
+ "onUpdate:modelValue": t[0] || (t[0] = (a) => u.value = a),
58
+ class: p(["w-full", e.classInput]),
59
+ invalid: !!i.value,
60
+ maxlength: e.maxlength,
61
+ disabled: e.disabled,
62
+ placeholder: e.placeholder,
63
+ "input-id": o(r),
64
+ onValueChange: x
65
+ }, null, 8, ["modelValue", "class", "invalid", "maxlength", "disabled", "placeholder", "input-id"]),
66
+ h("label", { for: o(r) }, [
67
+ y(g(e.label), 1),
68
+ e.required ? (s(), m("span", $, " *")) : B("", !0)
69
+ ], 8, N)
70
+ ]),
71
+ _: 1
72
+ })),
73
+ h("small", I, g(i.value), 1)
74
+ ], 2));
75
+ }
76
+ });
77
+ export {
78
+ T as default
79
+ };
@@ -0,0 +1 @@
1
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?module.exports=t(require("vue"),require("primevue")):typeof define=="function"&&define.amd?define(["vue","primevue"],t):(e=typeof globalThis<"u"?globalThis:e||self,e.SelectFloat=t(e.Vue,e.PrimeVue))})(this,(function(e,t){"use strict";const m=["for"],u={key:0,class:"text-danger"},f={class:"text-danger"};return e.defineComponent({__name:"input-text-float",props:{label:{},modelValue:{},class:{},classInput:{},disabled:{type:Boolean},required:{type:Boolean},loading:{type:Boolean},showError:{type:Boolean},rules:{},maxlength:{},placeholder:{}},emits:["update:modelValue"],setup(l,{emit:p}){const s=l,d=p,i=Math.random().toString(16).slice(2),r=e.computed({get(){return s.modelValue},set(n){d("update:modelValue",n)}}),c=e.computed(()=>{if(s.showError){const n=s.rules||[];for(let o=0;o<n.length;o++){const a=n[o];if(a&&a.$invalid&&a.$message)return a.$message}}return""});function h(n){d("update:modelValue",n)}return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(`field ${s.class||""}`)},[l.loading?(e.openBlock(),e.createBlock(e.unref(t.Skeleton),{key:0,class:"skeleton-input mt-3"})):(e.openBlock(),e.createBlock(e.unref(t.FloatLabel),{key:1,class:"mt-3"},{default:e.withCtx(()=>[e.createVNode(e.unref(t.InputText),{modelValue:r.value,"onUpdate:modelValue":o[0]||(o[0]=a=>r.value=a),class:e.normalizeClass(["w-full",l.classInput]),invalid:!!c.value,maxlength:l.maxlength,disabled:l.disabled,placeholder:l.placeholder,"input-id":e.unref(i),onValueChange:h},null,8,["modelValue","class","invalid","maxlength","disabled","placeholder","input-id"]),e.createElementVNode("label",{for:e.unref(i)},[e.createTextVNode(e.toDisplayString(l.label),1),l.required?(e.openBlock(),e.createElementBlock("span",u," *")):e.createCommentVNode("",!0)],8,m)]),_:1})),e.createElementVNode("small",f,e.toDisplayString(c.value),1)],2))}})}));
@@ -0,0 +1,10 @@
1
+ import type { ObjectEmitsOptions } from 'vue';
2
+ export default interface InputTextFloatEmits {
3
+ (e: 'update:modelValue', value: any): void;
4
+ }
5
+ export interface InputTextFloatEmitsForDoc extends ObjectEmitsOptions {
6
+ /**
7
+ * Called when modelValue is updated.
8
+ */
9
+ 'update:modelValue': (value: any) => void;
10
+ }
@@ -0,0 +1,52 @@
1
+ export default interface SelectFloatProps {
2
+ /**
3
+ * Label displayed above the input.
4
+ */
5
+ label: string;
6
+ /**
7
+ * Model value representing the current state of the input.
8
+ */
9
+ modelValue: any;
10
+ /**
11
+ * Class of the component.
12
+ */
13
+ class?: any;
14
+ /**
15
+ * Optional CSS class applied to the input element.
16
+ */
17
+ classInput?: string;
18
+ /**
19
+ * Disables the input when true.
20
+ */
21
+ disabled?: boolean;
22
+ /**
23
+ * Marks the input as required when true.
24
+ */
25
+ required?: boolean;
26
+ /**
27
+ * Indicates if the input is in a loading state.
28
+ */
29
+ loading: boolean;
30
+ /**
31
+ * Shows error messages when true.
32
+ */
33
+ showError?: boolean;
34
+ /**
35
+ * Validation rules for the input.
36
+ * Each rule can be undefined or an object containing:
37
+ * - $invalid: whether the rule is violated
38
+ * - $message: the error message associated with the rule
39
+ */
40
+ rules?: Array<{
41
+ $invalid: boolean;
42
+ $message: string;
43
+ } | undefined>;
44
+ /**
45
+ * Maximum number of characters allowed in the input.
46
+ */
47
+ maxlength?: number;
48
+ /**
49
+ * Placeholder text displayed inside the input.
50
+ */
51
+ placeholder?: string;
52
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "espri-vue-input-text-float",
3
+ "type": "module",
4
+ "version": "0.0.1",
5
+ "description": "Input Text Float - Vue component",
6
+ "author": "ESPRI Digital",
7
+ "homepage": "https://github.com/ESPRI-Digital/vue-input-text-float#readme",
8
+ "main": "dist/input-text-float.umd.js",
9
+ "module": "dist/input-text-float.es.js",
10
+ "types": "dist/index.d.ts",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "vite build && tsc --emitDeclarationOnly",
16
+ "lint": "eslint .",
17
+ "ts-check": "vue-tsc --noEmit"
18
+ },
19
+ "peerDependencies": {
20
+ "primevue": ">=4.0.0 <5.0.0",
21
+ "vue": ">=3.0.0 <4.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "@vitejs/plugin-vue": "^6.0.2",
25
+ "eslint": "^9.39.1",
26
+ "eslint-config-espri-front": "^3.0.0",
27
+ "typescript": "^5.9.3",
28
+ "vite": "^7.2.6",
29
+ "vue-tsc": "^3.1.5"
30
+ }
31
+ }