@fangzhongya/fang-ui 0.1.56 → 0.1.58

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.
@@ -23,19 +23,19 @@
23
23
  }
24
24
 
25
25
  .edit {
26
- display: inline-flex;
26
+ display: inline-block;
27
27
  align-items: center;
28
+ height: 100%;
28
29
  }
29
30
  .edit-value {
30
31
  display: inline-block;
32
+ height: 100%;
31
33
  min-width: 3px;
32
34
  }
33
35
  .edit-icon {
34
- display: inline-flex;
35
- align-items: center;
36
+ box-sizing: border-box;
36
37
  height: 100%;
37
- min-width: 3px;
38
38
  font-size: 16px;
39
- margin: 0 4px;
39
+ margin: 2px;
40
40
  cursor: pointer;
41
41
  }
@@ -2,19 +2,19 @@
2
2
 
3
3
  $edit: 'edit';
4
4
  @include b($edit) {
5
- display: inline-flex;
5
+ display: inline-block;
6
6
  align-items: center;
7
+ height: 100%;
7
8
  &-value {
8
9
  display: inline-block;
10
+ height: 100%;
9
11
  min-width: 3px;
10
12
  }
11
13
  &-icon {
12
- display: inline-flex;
13
- align-items: center;
14
+ box-sizing: border-box;
14
15
  height: 100%;
15
- min-width: 3px;
16
16
  font-size: 16px;
17
- margin: 0 4px;
17
+ margin: 2px;
18
18
  cursor: pointer;
19
19
  }
20
20
  }
@@ -15,12 +15,13 @@ const dataProps = {
15
15
  },
16
16
  textarea: Boolean,
17
17
  /**
18
- * @props { Boolean } noEmpty= ( )
18
+ * @props { Boolean } isEmpty= ( )
19
19
  * 不能为空
20
20
  */
21
21
  isEmpty: {
22
22
  type: Boolean
23
- }
23
+ },
24
+ type: { type: String, default: "icon" }
24
25
  };
25
26
  const dataEmits = ["update:modelValue"];
26
27
  const dataSlot = {
@@ -17,12 +17,16 @@ export declare const dataProps: {
17
17
  };
18
18
  textarea: BooleanConstructor;
19
19
  /**
20
- * @props { Boolean } noEmpty= ( )
20
+ * @props { Boolean } isEmpty= ( )
21
21
  * 不能为空
22
22
  */
23
23
  isEmpty: {
24
24
  type: BooleanConstructor;
25
25
  };
26
+ type: {
27
+ type: () => "icon" | "input";
28
+ default: string;
29
+ };
26
30
  };
27
31
  export type DataProps = ExtractPropTypes<typeof dataProps>;
28
32
  /**
@@ -13,12 +13,13 @@ const dataProps = {
13
13
  },
14
14
  textarea: Boolean,
15
15
  /**
16
- * @props { Boolean } noEmpty= ( )
16
+ * @props { Boolean } isEmpty= ( )
17
17
  * 不能为空
18
18
  */
19
19
  isEmpty: {
20
20
  type: Boolean
21
- }
21
+ },
22
+ type: { type: String, default: "icon" }
22
23
  };
23
24
  const dataEmits = ["update:modelValue"];
24
25
  const dataSlot = {
@@ -20,13 +20,19 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
20
20
  const isInput = vue.ref(false);
21
21
  const isIcon = vue.ref(false);
22
22
  const refEditInput = vue.ref();
23
- const refEdit = vue.ref();
23
+ const refDom = vue.ref();
24
24
  const width = vue.ref("");
25
- const display = vue.ref("");
26
25
  const getWidth = () => {
27
- const dom = refEdit.value;
26
+ const dom = refDom.value;
28
27
  if (dom) {
29
- width.value = (dom.clientWidth || dom.offsetWidth) + 40 + "px";
28
+ const f = dom.parentElement;
29
+ const d = dom.clientWidth || dom.offsetWidth;
30
+ const fw = (f == null ? void 0 : f.clientWidth) || (f == null ? void 0 : f.offsetWidth);
31
+ if (fw && fw > d + 60) {
32
+ width.value = d + 60 + "px";
33
+ } else {
34
+ width.value = d + "px";
35
+ }
30
36
  }
31
37
  };
32
38
  const value = vue.computed({
@@ -49,13 +55,19 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
49
55
  }
50
56
  function onBlur() {
51
57
  setIsIcon();
52
- isInput.value = false;
53
58
  }
54
59
  function setIsIcon() {
55
- if (!value.value && props.isEmpty) {
56
- isIcon.value = true;
60
+ if (!value.value && !props.isEmpty) {
61
+ if (props.type == "input") {
62
+ isInput.value = true;
63
+ isIcon.value = false;
64
+ } else {
65
+ isInput.value = false;
66
+ isIcon.value = true;
67
+ }
57
68
  } else {
58
69
  isIcon.value = false;
70
+ isInput.value = false;
59
71
  }
60
72
  }
61
73
  function onClick() {
@@ -65,17 +77,18 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
65
77
  refEditInput.value.focus();
66
78
  });
67
79
  }
68
- vue.onMounted(() => {
69
- let dom = refEdit.value;
70
- dom.onmouseenter = (event) => {
80
+ const onmouseenter = (event) => {
81
+ if (props.type == "input") {
82
+ isInput.value = true;
83
+ } else {
71
84
  isIcon.value = true;
72
- getWidth();
73
- };
74
- dom.onmouseleave = (event) => {
75
- setIsIcon();
76
- isInput.value = false;
77
- };
78
- display.value = dom.style.display || "inline";
85
+ }
86
+ getWidth();
87
+ };
88
+ const onmouseleave = (event) => {
89
+ setIsIcon();
90
+ };
91
+ vue.onMounted(() => {
79
92
  getWidth();
80
93
  });
81
94
  __expose({
@@ -83,13 +96,15 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
83
96
  });
84
97
  return (_ctx, _cache) => {
85
98
  return vue.openBlock(), vue.createElementBlock("span", {
86
- ref_key: "refEdit",
87
- ref: refEdit,
99
+ onMouseenter: onmouseenter,
100
+ onMouseleave: onmouseleave,
101
+ ref_key: "refDom",
102
+ ref: refDom,
88
103
  class: vue.normalizeClass(vue.unref(cs).z())
89
104
  }, [
90
105
  isInput.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$2.Inputs), {
91
106
  key: 0,
92
- style: vue.normalizeStyle({ width: width.value, display: display.value }),
107
+ style: vue.normalizeStyle({ width: width.value }),
93
108
  modelValue: value.value,
94
109
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
95
110
  ref_key: "refEditInput",
@@ -103,7 +118,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
103
118
  onDblclick: vue.withModifiers(onDblclick, ["stop"]),
104
119
  class: vue.normalizeClass(vue.unref(cs).z("value"))
105
120
  }, vue.toDisplayString(value.value), 35)),
106
- isIcon.value && !isInput.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$3.Icon), {
121
+ vue.unref(props).type == "icon" && isIcon.value && !isInput.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$3.Icon), {
107
122
  key: 2,
108
123
  onClick,
109
124
  class: vue.normalizeClass(vue.unref(cs).z("icon"))
@@ -113,7 +128,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
113
128
  ]),
114
129
  _: 1
115
130
  }, 8, ["class"])) : vue.createCommentVNode("", true)
116
- ], 2);
131
+ ], 34);
117
132
  };
118
133
  }
119
134
  });
@@ -18,13 +18,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
18
18
  const isInput = ref(false);
19
19
  const isIcon = ref(false);
20
20
  const refEditInput = ref();
21
- const refEdit = ref();
21
+ const refDom = ref();
22
22
  const width = ref("");
23
- const display = ref("");
24
23
  const getWidth = () => {
25
- const dom = refEdit.value;
24
+ const dom = refDom.value;
26
25
  if (dom) {
27
- width.value = (dom.clientWidth || dom.offsetWidth) + 40 + "px";
26
+ const f = dom.parentElement;
27
+ const d = dom.clientWidth || dom.offsetWidth;
28
+ const fw = (f == null ? void 0 : f.clientWidth) || (f == null ? void 0 : f.offsetWidth);
29
+ if (fw && fw > d + 60) {
30
+ width.value = d + 60 + "px";
31
+ } else {
32
+ width.value = d + "px";
33
+ }
28
34
  }
29
35
  };
30
36
  const value = computed({
@@ -47,13 +53,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
47
53
  }
48
54
  function onBlur() {
49
55
  setIsIcon();
50
- isInput.value = false;
51
56
  }
52
57
  function setIsIcon() {
53
- if (!value.value && props.isEmpty) {
54
- isIcon.value = true;
58
+ if (!value.value && !props.isEmpty) {
59
+ if (props.type == "input") {
60
+ isInput.value = true;
61
+ isIcon.value = false;
62
+ } else {
63
+ isInput.value = false;
64
+ isIcon.value = true;
65
+ }
55
66
  } else {
56
67
  isIcon.value = false;
68
+ isInput.value = false;
57
69
  }
58
70
  }
59
71
  function onClick() {
@@ -63,17 +75,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
63
75
  refEditInput.value.focus();
64
76
  });
65
77
  }
66
- onMounted(() => {
67
- let dom = refEdit.value;
68
- dom.onmouseenter = (event) => {
78
+ const onmouseenter = (event) => {
79
+ if (props.type == "input") {
80
+ isInput.value = true;
81
+ } else {
69
82
  isIcon.value = true;
70
- getWidth();
71
- };
72
- dom.onmouseleave = (event) => {
73
- setIsIcon();
74
- isInput.value = false;
75
- };
76
- display.value = dom.style.display || "inline";
83
+ }
84
+ getWidth();
85
+ };
86
+ const onmouseleave = (event) => {
87
+ setIsIcon();
88
+ };
89
+ onMounted(() => {
77
90
  getWidth();
78
91
  });
79
92
  __expose({
@@ -81,13 +94,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
81
94
  });
82
95
  return (_ctx, _cache) => {
83
96
  return openBlock(), createElementBlock("span", {
84
- ref_key: "refEdit",
85
- ref: refEdit,
97
+ onMouseenter: onmouseenter,
98
+ onMouseleave: onmouseleave,
99
+ ref_key: "refDom",
100
+ ref: refDom,
86
101
  class: normalizeClass(unref(cs).z())
87
102
  }, [
88
103
  isInput.value ? (openBlock(), createBlock(unref(Inputs), {
89
104
  key: 0,
90
- style: normalizeStyle({ width: width.value, display: display.value }),
105
+ style: normalizeStyle({ width: width.value }),
91
106
  modelValue: value.value,
92
107
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => value.value = $event),
93
108
  ref_key: "refEditInput",
@@ -101,7 +116,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
101
116
  onDblclick: withModifiers(onDblclick, ["stop"]),
102
117
  class: normalizeClass(unref(cs).z("value"))
103
118
  }, toDisplayString(value.value), 35)),
104
- isIcon.value && !isInput.value ? (openBlock(), createBlock(unref(Icon), {
119
+ unref(props).type == "icon" && isIcon.value && !isInput.value ? (openBlock(), createBlock(unref(Icon), {
105
120
  key: 2,
106
121
  onClick,
107
122
  class: normalizeClass(unref(cs).z("icon"))
@@ -111,7 +126,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
111
126
  ]),
112
127
  _: 1
113
128
  }, 8, ["class"])) : createCommentVNode("", true)
114
- ], 2);
129
+ ], 34);
115
130
  };
116
131
  }
117
132
  });
package/dist/css/edit.css CHANGED
@@ -23,19 +23,19 @@
23
23
  }
24
24
 
25
25
  .edit {
26
- display: inline-flex;
26
+ display: inline-block;
27
27
  align-items: center;
28
+ height: 100%;
28
29
  }
29
30
  .edit-value {
30
31
  display: inline-block;
32
+ height: 100%;
31
33
  min-width: 3px;
32
34
  }
33
35
  .edit-icon {
34
- display: inline-flex;
35
- align-items: center;
36
+ box-sizing: border-box;
36
37
  height: 100%;
37
- min-width: 3px;
38
38
  font-size: 16px;
39
- margin: 0 4px;
39
+ margin: 2px;
40
40
  cursor: pointer;
41
41
  }
@@ -1714,20 +1714,20 @@
1714
1714
  }
1715
1715
 
1716
1716
  .edit {
1717
- display: inline-flex;
1717
+ display: inline-block;
1718
1718
  align-items: center;
1719
+ height: 100%;
1719
1720
  }
1720
1721
  .edit-value {
1721
1722
  display: inline-block;
1723
+ height: 100%;
1722
1724
  min-width: 3px;
1723
1725
  }
1724
1726
  .edit-icon {
1725
- display: inline-flex;
1726
- align-items: center;
1727
+ box-sizing: border-box;
1727
1728
  height: 100%;
1728
- min-width: 3px;
1729
1729
  font-size: 16px;
1730
- margin: 0 4px;
1730
+ margin: 2px;
1731
1731
  cursor: pointer;
1732
1732
  }
1733
1733
 
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("vue");
4
- function useModel(props, emit) {
5
- const internalValue = vue.ref();
4
+ function useModel(props, emit, defaultValue) {
5
+ const internalValue = vue.ref(defaultValue);
6
6
  const instance = vue.getCurrentInstance();
7
7
  const hasExternalValue = vue.computed(() => {
8
8
  if (!instance) return false;
@@ -11,7 +11,7 @@ function useModel(props, emit) {
11
11
  });
12
12
  return vue.computed({
13
13
  get() {
14
- return hasExternalValue.value ? props.modelValue : internalValue.value;
14
+ return hasExternalValue.value ? props.modelValue ?? defaultValue : internalValue.value;
15
15
  },
16
16
  set(v) {
17
17
  if (hasExternalValue.value) {
@@ -1,2 +1,2 @@
1
1
  import { WritableComputedRef } from 'vue';
2
- export declare function useModel(props: ObjAny, emit: Function): WritableComputedRef<any, any>;
2
+ export declare function useModel(props: ObjAny, emit: Function, defaultValue?: any): WritableComputedRef<any, any>;
@@ -1,6 +1,6 @@
1
1
  import { ref, getCurrentInstance, computed } from "vue";
2
- function useModel(props, emit) {
3
- const internalValue = ref();
2
+ function useModel(props, emit, defaultValue) {
3
+ const internalValue = ref(defaultValue);
4
4
  const instance = getCurrentInstance();
5
5
  const hasExternalValue = computed(() => {
6
6
  if (!instance) return false;
@@ -9,7 +9,7 @@ function useModel(props, emit) {
9
9
  });
10
10
  return computed({
11
11
  get() {
12
- return hasExternalValue.value ? props.modelValue : internalValue.value;
12
+ return hasExternalValue.value ? props.modelValue ?? defaultValue : internalValue.value;
13
13
  },
14
14
  set(v) {
15
15
  if (hasExternalValue.value) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "prefix": "fang-ui",
3
3
  "info": {},
4
- "lastModified": 1767875434807,
4
+ "lastModified": 1768221514324,
5
5
  "icons": {
6
6
  "bar": {
7
7
  "body": " <path fill=\"currentColor\" d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z\" ></path> "
package/dist/index.css CHANGED
@@ -1714,20 +1714,20 @@
1714
1714
  }
1715
1715
 
1716
1716
  .edit {
1717
- display: inline-flex;
1717
+ display: inline-block;
1718
1718
  align-items: center;
1719
+ height: 100%;
1719
1720
  }
1720
1721
  .edit-value {
1721
1722
  display: inline-block;
1723
+ height: 100%;
1722
1724
  min-width: 3px;
1723
1725
  }
1724
1726
  .edit-icon {
1725
- display: inline-flex;
1726
- align-items: center;
1727
+ box-sizing: border-box;
1727
1728
  height: 100%;
1728
- min-width: 3px;
1729
1729
  font-size: 16px;
1730
- margin: 0 4px;
1730
+ margin: 2px;
1731
1731
  cursor: pointer;
1732
1732
  }
1733
1733
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/fang-ui",
3
3
  "private": false,
4
- "version": "0.1.56",
4
+ "version": "0.1.58",
5
5
  "type": "module",
6
6
  "description ": "fang-ui",
7
7
  "keywords": [
@@ -50,11 +50,11 @@
50
50
  "vue": "^3.5.26",
51
51
  "vue-tsc": "^3.2.2",
52
52
  "vxe-table": "4.6.20",
53
- "@fang-ui/hooks": "0.0.1-0",
54
- "@fang-ui/directives": "0.0.1-0",
55
53
  "@fang-ui/components": "0.0.1-0",
56
- "@fang-ui/locale": "0.0.1-0",
54
+ "@fang-ui/directives": "0.0.1-0",
57
55
  "@fang-ui/icons": "0.0.1-0",
56
+ "@fang-ui/hooks": "0.0.1-0",
57
+ "@fang-ui/locale": "0.0.1-0",
58
58
  "@fang-ui/theme": "0.0.1-0",
59
59
  "@fang-ui/types": "0.0.1-0",
60
60
  "@fang-ui/utils": "0.0.1-0"
File without changes
File without changes
File without changes