@ikun2274/spiritechoui 0.1.41 → 0.1.50

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.
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createElementVNode, toDisplayString, defineComponent, withDirectives, vModelDynamic } from "vue";
7
+ import { openBlock, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createElementVNode, toDisplayString, defineComponent, withDirectives, vModelDynamic, ref, vShow } from "vue";
8
8
  class MyUI {
9
9
  /**
10
10
  * 支持 app.use(MyUI) 注册的静态方法
@@ -59,7 +59,7 @@ const _export_sfc = (sfc, props) => {
59
59
  }
60
60
  return target;
61
61
  };
62
- const _sfc_main$1 = {
62
+ const _sfc_main$2 = {
63
63
  props: {
64
64
  // 文本样式类型
65
65
  textType: {
@@ -106,8 +106,8 @@ const _sfc_main$1 = {
106
106
  }
107
107
  }
108
108
  };
109
- const _hoisted_1$1 = ["disabled"];
110
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
109
+ const _hoisted_1$2 = ["disabled"];
110
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
111
111
  return openBlock(), createElementBlock("button", {
112
112
  class: normalizeClass(["SpiritEchoBtn", [
113
113
  `SpiritEchoBtn--${$props.type}`,
@@ -124,10 +124,10 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
124
124
  style: normalizeStyle($props.textStyle)
125
125
  }, toDisplayString($props.text), 7)
126
126
  ])
127
- ], 14, _hoisted_1$1);
127
+ ], 14, _hoisted_1$2);
128
128
  }
129
- const myButton = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
130
- const _sfc_main = defineComponent({
129
+ const speButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
130
+ const _sfc_main$1 = defineComponent({
131
131
  name: "SpInput",
132
132
  props: {
133
133
  modelValue: {
@@ -242,10 +242,10 @@ const _sfc_main = defineComponent({
242
242
  }
243
243
  });
244
244
  const SpInput_vue_vue_type_style_index_0_lang = "";
245
- const _hoisted_1 = { class: "SPInput-container" };
246
- const _hoisted_2 = ["type", "placeholder", "disabled", "maxlength", "name", "readonly"];
247
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
248
- return openBlock(), createElementBlock("div", _hoisted_1, [
245
+ const _hoisted_1$1 = { class: "SPInput-container" };
246
+ const _hoisted_2$1 = ["type", "placeholder", "disabled", "maxlength", "name", "readonly"];
247
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
248
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
249
249
  withDirectives(createElementVNode("input", {
250
250
  type: _ctx.type,
251
251
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.inputValue = $event),
@@ -258,21 +258,66 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
258
258
  onBlur: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("blur", $event)),
259
259
  onChange: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("change", $event)),
260
260
  class: "SPInput"
261
- }, null, 40, _hoisted_2), [
261
+ }, null, 40, _hoisted_2$1), [
262
262
  [vModelDynamic, _ctx.inputValue]
263
263
  ])
264
264
  ]);
265
265
  }
266
- const myinput = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
266
+ const speinput = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
267
+ const _sfc_main = defineComponent({
268
+ name: "SimpleCodeDemo",
269
+ // 仅接收一个核心prop:源码字符串
270
+ props: {
271
+ sourceCode: {
272
+ type: String,
273
+ required: true,
274
+ // 必须传入源码字符串
275
+ description: "要渲染效果+展示的源码字符串"
276
+ }
277
+ },
278
+ setup() {
279
+ const isShowCode = ref(false);
280
+ return { isShowCode };
281
+ }
282
+ });
283
+ const SPEBlock_vue_vue_type_style_index_0_scoped_e0daeed3_lang = "";
284
+ const _hoisted_1 = { class: "code-demo" };
285
+ const _hoisted_2 = ["innerHTML"];
286
+ const _hoisted_3 = { class: "code-area" };
287
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
288
+ return openBlock(), createElementBlock("div", _hoisted_1, [
289
+ createElementVNode("div", {
290
+ class: "demo-preview",
291
+ innerHTML: _ctx.sourceCode
292
+ }, null, 8, _hoisted_2),
293
+ createElementVNode("div", {
294
+ class: "toggle-btn",
295
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.isShowCode = !_ctx.isShowCode)
296
+ }, toDisplayString(_ctx.isShowCode ? "收起源码" : "查看源码"), 1),
297
+ withDirectives(createElementVNode("div", _hoisted_3, [
298
+ createElementVNode("pre", null, [
299
+ createElementVNode("code", null, toDisplayString(_ctx.sourceCode), 1)
300
+ ])
301
+ ], 512), [
302
+ [vShow, _ctx.isShowCode]
303
+ ])
304
+ ]);
305
+ }
306
+ const speblock = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e0daeed3"]]);
267
307
  const injector = new ComponentInjector(MyUI);
268
- injector.register("form", "myButton", myButton, {
308
+ injector.register("form", "speButton", speButton, {
269
309
  type: "default",
270
310
  size: "medium"
271
311
  });
272
- injector.register("form", "myinput", myinput);
312
+ injector.register("form", "speinput", speinput);
313
+ injector.register("tool", "speblock", speblock);
273
314
  MyUI.install = (app) => {
274
- app.component("SPE-Button", MyUI.form.myButton({}));
275
- app.component("SPE-Input", MyUI.form.myinput({}));
315
+ app.component("SPE-Button", MyUI.form.speButton({}));
316
+ app.component("SPE-Input", MyUI.form.speinput({}));
317
+ app.component(
318
+ "SPE-Block",
319
+ MyUI.tool.speblock({})
320
+ );
276
321
  };
277
322
  export {
278
323
  MyUI
@@ -62,7 +62,7 @@ var __publicField = (obj, key, value) => {
62
62
  }
63
63
  return target;
64
64
  };
65
- const _sfc_main$1 = {
65
+ const _sfc_main$2 = {
66
66
  props: {
67
67
  // 文本样式类型
68
68
  textType: {
@@ -109,8 +109,8 @@ var __publicField = (obj, key, value) => {
109
109
  }
110
110
  }
111
111
  };
112
- const _hoisted_1$1 = ["disabled"];
113
- function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
112
+ const _hoisted_1$2 = ["disabled"];
113
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
114
114
  return vue.openBlock(), vue.createElementBlock("button", {
115
115
  class: vue.normalizeClass(["SpiritEchoBtn", [
116
116
  `SpiritEchoBtn--${$props.type}`,
@@ -127,10 +127,10 @@ var __publicField = (obj, key, value) => {
127
127
  style: vue.normalizeStyle($props.textStyle)
128
128
  }, vue.toDisplayString($props.text), 7)
129
129
  ])
130
- ], 14, _hoisted_1$1);
130
+ ], 14, _hoisted_1$2);
131
131
  }
132
- const myButton = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
133
- const _sfc_main = vue.defineComponent({
132
+ const speButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
133
+ const _sfc_main$1 = vue.defineComponent({
134
134
  name: "SpInput",
135
135
  props: {
136
136
  modelValue: {
@@ -245,10 +245,10 @@ var __publicField = (obj, key, value) => {
245
245
  }
246
246
  });
247
247
  const SpInput_vue_vue_type_style_index_0_lang = "";
248
- const _hoisted_1 = { class: "SPInput-container" };
249
- const _hoisted_2 = ["type", "placeholder", "disabled", "maxlength", "name", "readonly"];
250
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
251
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
248
+ const _hoisted_1$1 = { class: "SPInput-container" };
249
+ const _hoisted_2$1 = ["type", "placeholder", "disabled", "maxlength", "name", "readonly"];
250
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
251
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
252
252
  vue.withDirectives(vue.createElementVNode("input", {
253
253
  type: _ctx.type,
254
254
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.inputValue = $event),
@@ -261,21 +261,66 @@ var __publicField = (obj, key, value) => {
261
261
  onBlur: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("blur", $event)),
262
262
  onChange: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("change", $event)),
263
263
  class: "SPInput"
264
- }, null, 40, _hoisted_2), [
264
+ }, null, 40, _hoisted_2$1), [
265
265
  [vue.vModelDynamic, _ctx.inputValue]
266
266
  ])
267
267
  ]);
268
268
  }
269
- const myinput = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
269
+ const speinput = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
270
+ const _sfc_main = vue.defineComponent({
271
+ name: "SimpleCodeDemo",
272
+ // 仅接收一个核心prop:源码字符串
273
+ props: {
274
+ sourceCode: {
275
+ type: String,
276
+ required: true,
277
+ // 必须传入源码字符串
278
+ description: "要渲染效果+展示的源码字符串"
279
+ }
280
+ },
281
+ setup() {
282
+ const isShowCode = vue.ref(false);
283
+ return { isShowCode };
284
+ }
285
+ });
286
+ const SPEBlock_vue_vue_type_style_index_0_scoped_e0daeed3_lang = "";
287
+ const _hoisted_1 = { class: "code-demo" };
288
+ const _hoisted_2 = ["innerHTML"];
289
+ const _hoisted_3 = { class: "code-area" };
290
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
291
+ return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
292
+ vue.createElementVNode("div", {
293
+ class: "demo-preview",
294
+ innerHTML: _ctx.sourceCode
295
+ }, null, 8, _hoisted_2),
296
+ vue.createElementVNode("div", {
297
+ class: "toggle-btn",
298
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.isShowCode = !_ctx.isShowCode)
299
+ }, vue.toDisplayString(_ctx.isShowCode ? "收起源码" : "查看源码"), 1),
300
+ vue.withDirectives(vue.createElementVNode("div", _hoisted_3, [
301
+ vue.createElementVNode("pre", null, [
302
+ vue.createElementVNode("code", null, vue.toDisplayString(_ctx.sourceCode), 1)
303
+ ])
304
+ ], 512), [
305
+ [vue.vShow, _ctx.isShowCode]
306
+ ])
307
+ ]);
308
+ }
309
+ const speblock = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-e0daeed3"]]);
270
310
  const injector = new ComponentInjector(MyUI);
271
- injector.register("form", "myButton", myButton, {
311
+ injector.register("form", "speButton", speButton, {
272
312
  type: "default",
273
313
  size: "medium"
274
314
  });
275
- injector.register("form", "myinput", myinput);
315
+ injector.register("form", "speinput", speinput);
316
+ injector.register("tool", "speblock", speblock);
276
317
  MyUI.install = (app) => {
277
- app.component("SPE-Button", MyUI.form.myButton({}));
278
- app.component("SPE-Input", MyUI.form.myinput({}));
318
+ app.component("SPE-Button", MyUI.form.speButton({}));
319
+ app.component("SPE-Input", MyUI.form.speinput({}));
320
+ app.component(
321
+ "SPE-Block",
322
+ MyUI.tool.speblock({})
323
+ );
279
324
  };
280
325
  exports2.MyUI = MyUI;
281
326
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
package/dist/style.css CHANGED
@@ -106,4 +106,36 @@
106
106
  }
107
107
  .SPInput:read-only {
108
108
  background-color: #f5f7fa;
109
+ }.code-demo[data-v-e0daeed3] {
110
+ border: 1px solid rgba(221, 216, 216, 0.4666666667);
111
+ margin: 10px 0;
112
+ align-items: center;
113
+ }
114
+ .code-demo .demo-preview[data-v-e0daeed3] {
115
+ padding: 20px;
116
+ background: #ffffff;
117
+ }
118
+ .code-demo .toggle-btn[data-v-e0daeed3] {
119
+ padding: 8px;
120
+ text-align: center;
121
+ background: #ebecec;
122
+ cursor: pointer;
123
+ border-top: 1px solid #eee;
124
+ user-select: none;
125
+ }
126
+ .code-demo .code-area[data-v-e0daeed3] {
127
+ background: #fbfbfb;
128
+ padding: 20px;
129
+ border-top: 1px solid #eee;
130
+ font-family: Consolas, Monaco, "Courier New", monospace;
131
+ }
132
+ .code-demo .code-area pre[data-v-e0daeed3],
133
+ .code-demo .code-area code[data-v-e0daeed3] {
134
+ margin: 0;
135
+ font-size: 14px;
136
+ line-height: 1.5;
137
+ color: #7cdd28;
138
+ white-space: pre-wrap;
139
+ word-break: break-all;
140
+ line-height: 1.8;
109
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikun2274/spiritechoui",
3
- "version": "0.1.41",
3
+ "version": "0.1.50",
4
4
  "main": "dist/spiritechoui.umd.cjs",
5
5
  "module": "dist/spiritechoui.es.js",
6
6
  "exports": {
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "scripts": {
25
25
  "build": "vite build"
26
+
26
27
  },
27
28
  "keywords": [],
28
29
  "author": "",
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 我的第一个UI组件库 SpiritEchoUI
2
2
 
3
- ### 目前还是0.1.41版本
3
+ ### 目前还是0.1.5版本
4
4
 
5
5
 
6
6
  ## 安装组件
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <div class="code-demo">
3
+ <!-- 1. 渲染源码成UI效果(核心:v-html 直接渲染字符串为DOM) -->
4
+ <div class="demo-preview" v-html="sourceCode"></div>
5
+
6
+ <!-- 2. 点击按钮:展开/收起 -->
7
+ <div class="toggle-btn" @click="isShowCode = !isShowCode">
8
+ {{ isShowCode ? "收起源码" : "查看源码" }}
9
+ </div>
10
+
11
+ <!-- 3. 源码展示区:插值表达式直接展示字符串 -->
12
+ <div class="code-area" v-show="isShowCode">
13
+ <pre><code >{{ sourceCode }}</code></pre>
14
+ </div>
15
+ </div>
16
+ </template>
17
+
18
+ <script lang="ts">
19
+ import { defineComponent, ref } from "vue";
20
+
21
+ export default defineComponent({
22
+ name: "SimpleCodeDemo",
23
+ // 仅接收一个核心prop:源码字符串
24
+ props: {
25
+ sourceCode: {
26
+ type: String,
27
+ required: true, // 必须传入源码字符串
28
+ description: "要渲染效果+展示的源码字符串",
29
+ },
30
+ },
31
+ setup() {
32
+ // 仅维护一个状态:源码区是否显示
33
+ const isShowCode = ref(false);
34
+ return { isShowCode };
35
+ },
36
+ });
37
+ </script>
38
+
39
+ <style lang="scss" scoped>
40
+ // 极简样式:只保证功能,无多余美化
41
+ .code-demo {
42
+ border: 1px solid #ddd8d877;
43
+ margin: 10px 0;
44
+
45
+ align-items: center;
46
+
47
+ // 效果渲染区
48
+ .demo-preview {
49
+ padding: 20px;
50
+ background: #ffffff;
51
+ }
52
+
53
+ // 点击按钮
54
+ .toggle-btn {
55
+ padding: 8px;
56
+ text-align: center;
57
+ background: #ebecec;
58
+ cursor: pointer;
59
+ border-top: 1px solid #eee;
60
+ user-select: none; // 禁止选中文本
61
+ }
62
+
63
+ // 源码展示区
64
+ .code-area {
65
+ background: #fbfbfb;
66
+ padding: 20px;
67
+ border-top: 1px solid #eee;
68
+
69
+ font-family: Consolas, Monaco, "Courier New", monospace;
70
+
71
+ pre,
72
+ code {
73
+ margin: 0;
74
+ font-size: 14px;
75
+ line-height: 1.5;
76
+ color: #7cdd28;
77
+ white-space: pre-wrap; // 保留换行+自动换行
78
+ word-break: break-all;
79
+ line-height: 1.8; // 加大行高,阅读更舒适
80
+ }
81
+
82
+ }
83
+ }
84
+ </style>
@@ -3,26 +3,29 @@ import MyUI from './MyUI';
3
3
  import ComponentInjector from './ComponentInjector';
4
4
 
5
5
  //引入组件
6
- import myButton from './components/Button.vue';
7
- import myinput from './components/SpInput.vue';
6
+ import speButton from './components/Button.vue';
7
+ import speinput from './components/SpInput.vue';
8
+ import speblock from './components/SPEBlock.vue'
8
9
 
9
10
  const injector = new ComponentInjector(MyUI);
10
11
 
11
- injector.register('form', 'myButton', myButton, {
12
+ injector.register('form', 'speButton', speButton, {
12
13
  type: 'default',
13
14
  size: 'medium'
14
15
  });
15
-
16
16
  //假设有第二个组件
17
- injector.register('form', 'myinput', myinput);
17
+ injector.register('form', 'speinput', speinput);
18
+ injector.register('tool', 'speblock', speblock);
18
19
 
19
20
  //Spirit EchoUI
20
21
 
21
22
  //全局激活组件
22
23
 
23
24
  MyUI.install = (app) => {
24
- app.component('SPE-Button', MyUI.form.myButton({}));
25
- app.component('SPE-Input', MyUI.form.myinput({}));
25
+ app.component('SPE-Button', MyUI.form.speButton({}));
26
+ app.component('SPE-Input', MyUI.form.speinput({}));
27
+ app.component('SPE-Block', MyUI.tool.speblock({})
28
+ );
26
29
 
27
30
 
28
31
  };