iking-template-inset 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,16 @@
1
+ # Vue 3 + TypeScript + Vite
2
+
3
+ This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4
+
5
+ ## Recommended IDE Setup
6
+
7
+ - [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
8
+
9
+ ## Type Support For `.vue` Imports in TS
10
+
11
+ Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
12
+
13
+ 1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
14
+ 2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
15
+
16
+ You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
@@ -0,0 +1,80 @@
1
+ import { defineComponent as g, ref as r, watch as k, openBlock as u, createElementBlock as c, createElementVNode as _, Fragment as m, renderList as h, renderSlot as b, createTextVNode as $, toDisplayString as I, withKeys as N, withModifiers as T, nextTick as w } from "vue";
2
+ const x = { class: "msg-template" }, L = { class: "left-template-tag" }, S = ["onClick"], V = /* @__PURE__ */ g({
3
+ __name: "App",
4
+ props: {
5
+ modelVlaue: {
6
+ type: String,
7
+ default: ""
8
+ },
9
+ height: { type: Number, default: 300 },
10
+ width: { type: Number, default: 600 },
11
+ tagList: {
12
+ type: Array,
13
+ default: () => []
14
+ }
15
+ },
16
+ emits: ["update:modelVlaue"],
17
+ setup(o, { emit: d }) {
18
+ const n = r(-1), a = r(), i = () => {
19
+ const e = document.getSelection();
20
+ n.value = e != null && e.baseNode ? e != null && e.baseOffset ? e == null ? void 0 : e.baseOffset : 0 : -1;
21
+ }, t = r(""), v = r("");
22
+ k(t, (e) => {
23
+ d("update:modelVlaue", e);
24
+ });
25
+ const f = (e) => {
26
+ const s = document.getSelection();
27
+ i(), w(() => {
28
+ t.value = e.target.innerHTML, v.value = s.baseNode.data;
29
+ });
30
+ }, y = (e) => {
31
+ const s = `\u3010${e.label}\${${e.value}}\u3011`;
32
+ if (n.value === -1)
33
+ t.value = `${t.value}${s}`;
34
+ else if (n.value === 0)
35
+ t.value = `${s}${t.value}`;
36
+ else {
37
+ const l = t.value;
38
+ t.value = l.substring(0, n.value) + s + l.substring(n.value);
39
+ }
40
+ a.value.innerHTML = t.value;
41
+ };
42
+ return (e, s) => (u(), c("div", x, [
43
+ _("div", L, [
44
+ (u(!0), c(m, null, h(o.tagList, (l, p) => (u(), c("div", {
45
+ onClick: (K) => y(l),
46
+ key: p
47
+ }, [
48
+ e.$slots.item ? b(e.$slots, "item", {
49
+ key: 0,
50
+ item: { ...l, index: p }
51
+ }, void 0, !0) : (u(), c(m, { key: 1 }, [
52
+ $(I(l.label), 1)
53
+ ], 64))
54
+ ], 8, S))), 128))
55
+ ]),
56
+ _("div", {
57
+ ref_key: "insetDom",
58
+ ref: a,
59
+ class: "right-template",
60
+ contenteditable: "",
61
+ onKeydown: s[0] || (s[0] = N(T(() => {
62
+ }, ["prevent"]), ["enter"])),
63
+ onKeyup: f,
64
+ onClick: i
65
+ }, null, 544)
66
+ ]));
67
+ }
68
+ });
69
+ const A = (o, d) => {
70
+ const n = o.__vccOpts || o;
71
+ for (const [a, i] of d)
72
+ n[a] = i;
73
+ return n;
74
+ }, C = /* @__PURE__ */ A(V, [["__scopeId", "data-v-18f96dd0"]]), M = (o) => {
75
+ o.component("IkingTemplateInset", C);
76
+ };
77
+ export {
78
+ C as default,
79
+ M as install
80
+ };
@@ -0,0 +1 @@
1
+ (function(o,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(o=typeof globalThis<"u"?globalThis:o||self,e(o.IkingTemplateInset={},o.Vue))})(this,function(o,e){"use strict";const f={class:"msg-template"},m={class:"left-template-tag"},_=["onClick"],y=e.defineComponent({__name:"App",props:{modelVlaue:{type:String,default:""},height:{type:Number,default:300},width:{type:Number,default:600},tagList:{type:Array,default:()=>[]}},emits:["update:modelVlaue"],setup(a,{emit:d}){const l=e.ref(-1),c=e.ref(),r=()=>{const t=document.getSelection();l.value=t!=null&&t.baseNode?t!=null&&t.baseOffset?t==null?void 0:t.baseOffset:0:-1},n=e.ref(""),g=e.ref("");e.watch(n,t=>{d("update:modelVlaue",t)});const h=t=>{const s=document.getSelection();r(),e.nextTick(()=>{n.value=t.target.innerHTML,g.value=s.baseNode.data})},b=t=>{const s=`\u3010${t.label}\${${t.value}}\u3011`;if(l.value===-1)n.value=`${n.value}${s}`;else if(l.value===0)n.value=`${s}${n.value}`;else{const i=n.value;n.value=i.substring(0,l.value)+s+i.substring(l.value)}c.value.innerHTML=n.value};return(t,s)=>(e.openBlock(),e.createElementBlock("div",f,[e.createElementVNode("div",m,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.tagList,(i,u)=>(e.openBlock(),e.createElementBlock("div",{onClick:I=>b(i),key:u},[t.$slots.item?e.renderSlot(t.$slots,"item",{key:0,item:{...i,index:u}},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(i.label),1)],64))],8,_))),128))]),e.createElementVNode("div",{ref_key:"insetDom",ref:c,class:"right-template",contenteditable:"",onKeydown:s[0]||(s[0]=e.withKeys(e.withModifiers(()=>{},["prevent"]),["enter"])),onKeyup:h,onClick:r},null,544)]))}}),v="",T="",p=((a,d)=>{const l=a.__vccOpts||a;for(const[c,r]of d)l[c]=r;return l})(y,[["__scopeId","data-v-18f96dd0"]]),k=a=>{a.component("IkingTemplateInset",p)};o.default=p,o.install=k,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,28 @@
1
+ /*
2
+ * @Author : wfl
3
+ * @LastEditors : wfl
4
+ * @description :
5
+ * @updateInfo :
6
+ * @Date : 2022-11-21 10:28:10
7
+ * @LastEditTime : 2022-11-21 10:28:43
8
+ */
9
+ /// <reference types="vite/client" />
10
+
11
+ declare module 'iking-template-inset' {
12
+ import type { Component } from 'vue'
13
+ const component: Component<{
14
+ width: number; // 宽度
15
+ height: number; // 高度
16
+ show: boolean;// 是否显示
17
+ sliderSize: number; // 滑块大小
18
+ scale: number; // 滑块缩放比例
19
+ range: number; // 误差范围
20
+ images: string[] | null; // 自定义图片数组
21
+ successText: string; // 校验通过文字
22
+ failText: string; // 校验失败文字
23
+ sliderText: string; // 滑块文字
24
+ padding: number; // 内边距
25
+ el: HTMLBaseElement | string //CSS 选择器字符串或者一个真实的 DOM 节点
26
+ }>
27
+ export default component
28
+ }
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .__templeate_param_tag{display:inline-block;padding:2px;background:#dfdfdf;font-size:13px;border-radius:4px;margin-right:2px}.msg-template[data-v-18f96dd0]{display:flex}.msg-template>div[data-v-18f96dd0]{flex:1;border:1px solid #9d9393;border-radius:4px;padding:8px;margin-right:16px}.msg-template .left-template-tag[data-v-18f96dd0]{display:flex;flex-wrap:wrap}.msg-template .left-template-tag div[data-v-18f96dd0]{cursor:pointer;user-select:none;padding:3px 8px;margin:3px 1px 3px 3px;width:100px;border-radius:4px;background:#edebeb}.msg-template .right-template[data-v-18f96dd0]{counter-increment:true}.msg-template .right-template[data-v-18f96dd0]:focus-visible{outline:none}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "iking-template-inset",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "main": "./dist/ikingtemplateinset.umd.js",
6
+ "module": "./dist/ikingtemplateinset.es.js",
7
+ "author": "金合研究院",
8
+ "description": "金合前端组件",
9
+ "homepage": "http://wfl118.cn/",
10
+ "license": "Apache-2.0",
11
+ "type": "module",
12
+ "typings": "dist/iking-template-inset.d.ts",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/ikingtemplateinset.es.js",
19
+ "require": "./dist/ikingtemplateinset.umd.js",
20
+ "module": "./dist/ikingtemplateinset.es.js"
21
+ },
22
+ "./dist/style.css": {
23
+ "import": "./dist/style.css",
24
+ "require": "./dist/style.css"
25
+ }
26
+ },
27
+ "scripts": {
28
+ "dev": "vite",
29
+ "build": "vue-tsc && vite build",
30
+ "preview": "vite preview"
31
+ },
32
+ "keywords": [
33
+ "金合",
34
+ "ikingtemplateinset",
35
+ "图片验证",
36
+ "滑动图片验证"
37
+ ],
38
+ "dependencies": {
39
+ "vue": "^3.2.41",
40
+ "vuedraggable": "^4.1.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^18.11.9",
44
+ "@vitejs/plugin-vue": "^3.2.0",
45
+ "path": "^0.12.7",
46
+ "sass": "^1.56.1",
47
+ "sass-loader": "^13.2.0",
48
+ "typescript": "^4.6.4",
49
+ "vite": "^3.2.3",
50
+ "vite-plugin-static-copy": "^0.12.0",
51
+ "vue-tsc": "^1.0.9"
52
+ }
53
+ }