kui-vue 3.6.8 → 3.6.10

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.
Files changed (93) hide show
  1. package/components/alert/alert.jsx +1 -1
  2. package/components/alert/demo/basic.md +2 -2
  3. package/components/alert/demo/close.md +2 -2
  4. package/components/alert/demo/customIcon.md +2 -2
  5. package/components/alert/styles/index.less +0 -1
  6. package/components/backtop/backtop.jsx +1 -1
  7. package/components/button/button.jsx +1 -1
  8. package/components/carousel/carousel.jsx +1 -1
  9. package/components/checkbox/checkbox.jsx +1 -1
  10. package/components/checkbox/styles/index.less +3 -0
  11. package/components/collapse/collapsePanel.jsx +1 -1
  12. package/components/colorPicker/presets.jsx +1 -1
  13. package/components/components.js +1 -2
  14. package/components/datePicker/datepicker.jsx +1 -1
  15. package/components/drawer/drawer.jsx +1 -1
  16. package/components/dropdown/dropdownButton.jsx +1 -1
  17. package/components/empty/empty.jsx +1 -1
  18. package/components/form/demo/valid.md +8 -7
  19. package/components/image/demo/group.md +1 -1
  20. package/components/image/group.jsx +10 -4
  21. package/components/image/image.jsx +48 -100
  22. package/components/image/preview.jsx +132 -117
  23. package/components/image/styles/index.less +211 -224
  24. package/components/image/utils.js +31 -0
  25. package/components/index.js +16 -35
  26. package/components/input/demo/event.md +0 -1
  27. package/components/input/input.jsx +1 -1
  28. package/components/inputNumber/inputNumber.jsx +1 -1
  29. package/components/inputNumber/styles/index.less +2 -2
  30. package/components/layout/demo/layout5.md +0 -1
  31. package/components/loading/loading.jsx +5 -27
  32. package/components/message/index.js +0 -6
  33. package/components/message/inner.jsx +1 -1
  34. package/components/modal/index.js +4 -7
  35. package/components/modal/modal.jsx +2 -3
  36. package/components/modal/styles/index.less +1 -0
  37. package/components/modal/toast.jsx +1 -1
  38. package/components/notice/index.js +0 -6
  39. package/components/page/demo/basic.md +3 -3
  40. package/components/page/demo/size.md +4 -4
  41. package/components/page/demo/sizer-elevator.md +6 -6
  42. package/components/page/index.md +1 -1
  43. package/components/page/page.jsx +9 -9
  44. package/components/popconfirm/popconfirm.jsx +1 -1
  45. package/components/progress/progress.jsx +1 -1
  46. package/components/radio/styles/index.less +3 -0
  47. package/components/rate/star.jsx +1 -1
  48. package/components/select/demo/theme.md +2 -1
  49. package/components/select/option.jsx +1 -1
  50. package/components/select/select.jsx +2 -2
  51. package/components/slider/demo/formatter.md +8 -9
  52. package/components/slider/slider.jsx +3 -4
  53. package/components/slider/thumb.jsx +4 -3
  54. package/components/space/demo/compact.md +9 -9
  55. package/components/statCard/statNumber.jsx +2 -2
  56. package/components/statCard/{countup.jsx → statup/countup.jsx} +1 -1
  57. package/components/styles/less-var.less +1 -1
  58. package/components/switch/switch.jsx +1 -1
  59. package/components/table/table.jsx +1 -1
  60. package/components/tabs/styles/index.less +2 -2
  61. package/components/tabs/tabs.jsx +1 -1
  62. package/components/tag/tag.jsx +1 -1
  63. package/components/tree/tree.jsx +1 -1
  64. package/components/treeselect/treeselect.jsx +1 -1
  65. package/components/upload/fileList.jsx +1 -1
  66. package/components/upload/selector.jsx +1 -1
  67. package/components/utils/theme.js +0 -10
  68. package/components/utils/vue.js +8 -0
  69. package/dist/k-ui.cjs.js +2 -2
  70. package/dist/k-ui.css +2 -2
  71. package/dist/k-ui.d.ts +332 -331
  72. package/dist/k-ui.esm.js +2 -2
  73. package/dist/k-ui.umd.js +2 -2
  74. package/dist/locale/de.js +1 -1
  75. package/dist/locale/el.js +1 -1
  76. package/dist/locale/en.js +1 -1
  77. package/dist/locale/fr.js +1 -1
  78. package/dist/locale/it.js +1 -1
  79. package/dist/locale/ja.js +1 -1
  80. package/dist/locale/ko.js +1 -1
  81. package/dist/locale/ru.js +1 -1
  82. package/dist/locale/th.js +1 -1
  83. package/dist/locale/uk.js +1 -1
  84. package/dist/locale/vi.js +1 -1
  85. package/dist/locale/zh-CN.js +1 -1
  86. package/dist/locale/zh-TW.js +1 -1
  87. package/package.json +13 -14
  88. package/types/index.d.ts +34 -34
  89. package/types/page/Page.d.ts +1 -1
  90. package/types/slider/Slider.d.ts +1 -0
  91. package/components/utils/i18n.js +0 -32
  92. /package/components/statCard/{countup.js → statup/countup.js} +0 -0
  93. /package/components/statCard/{rollup.jsx → statup/rollup.jsx} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
  CheckmarkCircle,
7
7
  AlertCircle,
8
8
  Close,
9
- } from "kui-icons";
9
+ } from "kui-icons/dist/icons";
10
10
  import { getTransitionProp } from "../base/transition";
11
11
  import { withInstall } from "../utils/vue";
12
12
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  ```vue
7
7
  <template>
8
- <div>
8
+ <Space vertical block>
9
9
  <Alert :showIcon="false" type="success">Success Text</Alert>
10
10
  <Alert :showIcon="false" type="info">Info Text</Alert>
11
11
  <Alert :showIcon="false" type="warning">Warning Text</Alert>
12
12
  <Alert :showIcon="false" type="error">Error Text</Alert>
13
- </div>
13
+ </Space>
14
14
  </template>
15
15
  ```
@@ -5,7 +5,7 @@
5
5
 
6
6
  ```vue
7
7
  <template>
8
- <div>
8
+ <Space vertical block>
9
9
  <Alert type="success" showIcon closable>Success Text</Alert>
10
10
  <Alert type="info" showIcon closable>Info Text</Alert>
11
11
  <Alert type="warning" showIcon closable>Warning Text</Alert>
@@ -17,6 +17,6 @@
17
17
  message="Success Tip"
18
18
  description="Congratulations, the operation is successful."
19
19
  />
20
- </div>
20
+ </Space>
21
21
  </template>
22
22
  ```
@@ -5,7 +5,7 @@
5
5
 
6
6
  ```vue
7
7
  <template>
8
- <div>
8
+ <Space vertical block>
9
9
  <Alert type="success" showIcon :icon="LogoAlipay">Success Text</Alert>
10
10
  <Alert type="info" showIcon :icon="LogoWechat">Info Text</Alert>
11
11
  <Alert type="warning" showIcon :icon="LogoApple">Warning Text</Alert>
@@ -39,7 +39,7 @@
39
39
  message="Error"
40
40
  description="Encountered an error, please press any key to continue."
41
41
  />
42
- </div>
42
+ </Space>
43
43
  </template>
44
44
  <script setup>
45
45
  import { LogoAlipay, LogoWechat, LogoApple, LogoGoogle } from "kui-icons";
@@ -2,7 +2,6 @@
2
2
 
3
3
  .k-alert {
4
4
  border-radius: var(--kui-border-radius);
5
- margin-bottom: 16px;
6
5
  padding: 8px 12px;
7
6
  box-sizing: border-box;
8
7
  position: relative;
@@ -1,7 +1,7 @@
1
1
 
2
2
  import Icon from "../icon";
3
3
  import scroll from "../directives/scroll";
4
- import { ArrowUp } from "kui-icons";
4
+ import { ArrowUp } from "kui-icons/dist/icons";
5
5
  import { withInstall } from '../utils/vue';
6
6
  import { defineComponent, ref } from "vue";
7
7
  const BackTop = defineComponent({
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, inject, computed } from "vue";
2
2
  import Icon from "../icon";
3
- import { Loading } from "kui-icons";
3
+ import { Loading } from "kui-icons/dist/icons";
4
4
  import { getChildren } from "../utils/vnode";
5
5
  import { withInstall } from "../utils/vue";
6
6
  import { colors } from "../const/var";
@@ -1,6 +1,6 @@
1
1
  import Icon from "../icon";
2
2
  import resize from "../directives/resize";
3
- import { ArrowBack, ArrowForward } from "kui-icons";
3
+ import { ArrowBack, ArrowForward } from "kui-icons/dist/icons";
4
4
  import {
5
5
  defineComponent,
6
6
  provide,
@@ -1,5 +1,5 @@
1
1
  import Icon from "../icon";
2
- import { Checkmark } from "kui-icons";
2
+ import { Checkmark } from "kui-icons/dist/icons";
3
3
  import { defineComponent, ref, watch } from "vue";
4
4
  import { withInstall } from "../utils/vue";
5
5
 
@@ -35,6 +35,7 @@
35
35
  outline: 2px solid transparent;
36
36
  outline-offset: 1px;
37
37
  border-radius: 3px;
38
+ flex-shrink: 0;
38
39
  }
39
40
 
40
41
  .k-icon {
@@ -91,6 +92,8 @@
91
92
  padding-left: 8px;
92
93
  vertical-align: middle;
93
94
  font-size: 14px;
95
+ overflow: hidden;
96
+ text-overflow: ellipsis;
94
97
  }
95
98
  }
96
99
 
@@ -1,6 +1,6 @@
1
1
  import Icon from "../icon";
2
2
  import { getTransitionProp } from "../base/transition";
3
- import { ChevronUp } from "kui-icons";
3
+ import { ChevronUp } from "kui-icons/dist/icons";
4
4
  import {
5
5
  defineComponent,
6
6
  ref,
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, reactive, ref, onMounted, watch } from "vue";
2
2
  import Color from "color";
3
- import { Checkmark } from "kui-icons";
3
+ import { Checkmark } from "kui-icons/dist/icons";
4
4
  import Icon from "../icon";
5
5
  export default defineComponent({
6
6
  name: "Presets",
@@ -77,8 +77,7 @@ import loading from "./loading";
77
77
  export { loading };
78
78
 
79
79
  import modal from "./modal";
80
- const Modal = modal;
81
- export { modal, Modal };
80
+ export { modal, modal as Modal };
82
81
 
83
82
  import { Menu, MenuGroup, MenuItem, SubMenu, MenuDivider } from "./menu";
84
83
  export { Menu, MenuGroup, MenuItem, SubMenu, MenuDivider };
@@ -21,7 +21,7 @@ import {
21
21
  ChevronForward,
22
22
  ChevronDoubleForward,
23
23
  ArrowForward,
24
- } from "kui-icons";
24
+ } from "kui-icons/dist/icons";
25
25
  import { setPlacement } from "../utils/placement";
26
26
  import transfer from "../directives/transfer";
27
27
  import resize from "../directives/resize";
@@ -1,6 +1,6 @@
1
1
  import { Button } from "../button";
2
2
  import transfer from "../directives/transfer";
3
- import { Close } from "kui-icons";
3
+ import { Close } from "kui-icons/dist/icons";
4
4
  import {
5
5
  defineComponent,
6
6
  inject,
@@ -3,7 +3,7 @@ import ButtonGroup from "../button/buttonGroup";
3
3
  import Dropdown from "./dropdown";
4
4
  import TriggerButton from "./trigger";
5
5
  import { defineComponent, ref, inject } from "vue";
6
- import { Ellipsis } from "kui-icons";
6
+ import { Ellipsis } from "kui-icons/dist/icons";
7
7
  import { withInstall } from "../utils/vue";
8
8
  const DropdownButton = defineComponent({
9
9
  name: "DropdownButton",
@@ -1,5 +1,5 @@
1
1
  import Icon from "../icon";
2
- import { FileTrayOutline } from "kui-icons";
2
+ import { FileTrayOutline } from "kui-icons/dist/icons";
3
3
  import zhCN from "../locale/zh-CN";
4
4
  import { defineComponent, inject, computed } from "vue";
5
5
  import { withInstall } from "../utils/vue";
@@ -22,30 +22,31 @@
22
22
  </RadioGroup>
23
23
  </FormItem>
24
24
  <FormItem label="E-mail" prop="email">
25
- <Input clearable placeholder="Email"/>
25
+ <Input clearable placeholder="Email" />
26
26
  </FormItem>
27
27
  <FormItem label="Number" prop="number">
28
- <InputNumber placeholder="Number"/>
28
+ <InputNumber placeholder="Number" />
29
29
  </FormItem>
30
30
  <FormItem label="Password" prop="password">
31
- <Input type="password" placeholder="password"/>
31
+ <Input type="password" placeholder="password" />
32
32
  </FormItem>
33
33
  <FormItem label="Confirm Password" prop="repassword">
34
- <Input type="password" placeholder="Confirm Password"/>
34
+ <Input type="password" placeholder="Confirm Password" />
35
35
  </FormItem>
36
36
  <FormItem label="Phone Number" prop="phone">
37
- <Input placeholder="Phone Number"/>
37
+ <Input placeholder="Phone Number" />
38
38
  </FormItem>
39
39
  <FormItem label="Captcha" prop="captcha">
40
- <Input placeholder="Captcha"/>
40
+ <Input placeholder="Captcha">
41
41
  <Button
42
42
  slot="suffix"
43
43
  :size="size"
44
44
  :disabled="time != 60"
45
45
  style="width:100px;"
46
46
  @click="sendCode"
47
- >{{ time == 60 ? "获取验证码" : time + "(s)" }}</Button
48
47
  >
48
+ {{ time == 60 ? "获取验证码" : time + "(s)" }}
49
+ </Button>
49
50
  </Input>
50
51
  </FormItem>
51
52
  <FormItem label="Country">
@@ -31,7 +31,7 @@ const data = [
31
31
  "https://cdn.chuchur.com/upload/cat/cat2.webp",
32
32
  "https://cdn.chuchur.com/upload/cat/cat3.webp",
33
33
  "https://cdn.chuchur.com/upload/cat/cat4.jpg",
34
- "https://cdn.chuchur.com/upload/cat/cat5.jpg",
34
+ "https://cdn.chuchur.com/upload/cat/cat5---.jpg",
35
35
  ];
36
36
  </script>
37
37
  ```
@@ -7,7 +7,7 @@ const ImageGroup = defineComponent({
7
7
  props: {
8
8
  data: Array,
9
9
  },
10
- setup(props, { emit, slots, expose }) {
10
+ setup(props, { slots }) {
11
11
  const data = ref(props.data || []);
12
12
  const preview = ref();
13
13
  const show = (options) => {
@@ -33,14 +33,20 @@ const ImageGroup = defineComponent({
33
33
  data.value.splice(index, 1);
34
34
  }
35
35
  };
36
-
37
- provide("ImageGroup", { show, register, unregister, data, togglePanel });
38
-
39
36
  const destroy = () => {
40
37
  if (preview.value) {
41
38
  document.body.removeChild(preview.value.$el);
39
+ preview.value = null;
42
40
  }
43
41
  };
42
+ provide("ImageGroup", {
43
+ show,
44
+ destroy,
45
+ register,
46
+ unregister,
47
+ data,
48
+ togglePanel,
49
+ });
44
50
 
45
51
  onUnmounted(() => {
46
52
  destroy();
@@ -5,13 +5,12 @@ import {
5
5
  onBeforeUnmount,
6
6
  watch,
7
7
  inject,
8
- computed,
9
8
  } from "vue";
10
9
  import Icon from "../icon";
11
10
  import newInstance from "./instance";
12
- import { Loading, IconImage, EyeOutline } from "kui-icons";
11
+ import { Loading, IconImage, EyeOutline } from "kui-icons/dist/icons";
13
12
  import { withInstall } from "../utils/vue";
14
- import zhCN from "../locale/zh-CN";
13
+ import { loadImage } from "./utils";
15
14
 
16
15
  const KImage = defineComponent({
17
16
  name: "KImage",
@@ -29,48 +28,41 @@ const KImage = defineComponent({
29
28
  },
30
29
  setup(props, { emit, slots, expose, listeners }) {
31
30
  const loading = ref(false);
32
- const showImg = ref(false);
31
+ const showPlaceholder = ref(false);
33
32
  const imageUrl = ref(null);
34
- const error = ref(false);
35
33
  const imgWidth = ref(0);
36
34
  const imgHeight = ref(0);
37
35
 
38
36
  const preview = ref();
39
37
  const ImageGroup = inject("ImageGroup", null);
40
- const injectedLocale = inject("locale", zhCN);
41
-
42
- const locale = computed(() => {
43
- return injectedLocale instanceof Object && "value" in injectedLocale
44
- ? injectedLocale.value
45
- : injectedLocale;
46
- });
47
38
 
48
39
  // global api
49
40
  const togglePanel = () => {
50
- if (ImageGroup) {
51
- ImageGroup.togglePanel();
52
- return;
53
- }
54
- if (preview.value) {
55
- preview.value.togglePanel();
41
+ const instance = ImageGroup || preview.value;
42
+ if (instance) {
43
+ instance.togglePanel();
56
44
  }
57
45
  };
58
46
  // global api
59
- const show = (options) => {
47
+ const show = (props) => {
60
48
  if (ImageGroup) {
61
- ImageGroup.show(options);
49
+ ImageGroup.show(props);
62
50
  return;
63
51
  }
64
52
  if (!preview.value) {
65
- preview.value = newInstance({ ...options });
53
+ preview.value = newInstance({ ...props });
66
54
  }
67
- preview.value.show();
55
+ preview.value.show(props);
68
56
  };
69
57
 
70
58
  // global api
71
59
  const destroy = () => {
72
60
  if (preview.value) {
73
61
  document.body.removeChild(preview.value.$el);
62
+ preview.value = null;
63
+ }
64
+ if (ImageGroup) {
65
+ ImageGroup.destroy();
74
66
  }
75
67
  };
76
68
 
@@ -78,11 +70,14 @@ const KImage = defineComponent({
78
70
 
79
71
  const showPreview = (e) => {
80
72
  const { origin, src } = props;
81
- if ((!src && !origin) || error.value) return;
73
+ if ((!src && !origin) || showPlaceholder.value || loading.value) return;
82
74
  const options = {
83
75
  on: {
84
76
  close: () => {
85
77
  emit("close");
78
+ setTimeout(() => {
79
+ destroy();
80
+ }, 200);
86
81
  },
87
82
  switch: (index) => {
88
83
  emit("switch", index);
@@ -96,79 +91,32 @@ const KImage = defineComponent({
96
91
  scopedSlots: { ...slots },
97
92
  };
98
93
 
99
- if (!origin || props.type == "media") {
100
- show(options);
101
- } else {
102
- loading.value = true;
103
- loadImage(
104
- origin,
105
- () => {
106
- loading.value = false;
107
- options.props.src = origin;
108
- show(options);
109
- },
110
- () => {
111
- loading.value = false;
112
- }
113
- );
114
- }
94
+ show(options);
115
95
  e.preventDefault();
116
96
  };
117
97
 
118
- const loadImage = (src, callback, err) => {
119
- if (!src) return;
120
-
121
- let image = new Image();
122
- let isCompleted = false;
123
-
124
- const cleanup = () => {
125
- if (isCompleted) return;
126
- isCompleted = true;
127
- image.onload = null;
128
- image.onerror = null;
129
- image = null;
130
- };
131
-
132
- image.onload = () => {
133
- if (!isCompleted) {
134
- const { width, height } = image;
135
- callback && callback({ width, height });
136
- }
137
- cleanup();
138
- };
139
-
140
- image.onerror = () => {
141
- if (!isCompleted) {
142
- err && err();
143
- }
144
- cleanup();
145
- };
146
-
147
- image.src = src;
148
- };
149
-
150
98
  const reload = () => {
151
99
  const { src, placeholder } = props;
152
100
  if (src) {
101
+ loading.value = true;
153
102
  loadImage(
154
103
  src,
155
104
  ({ width, height }) => {
156
- showImg.value = true;
105
+ showPlaceholder.value = false;
106
+ loading.value = false;
157
107
  imageUrl.value = src;
158
- error.value = false;
159
108
  imgWidth.value = width;
160
109
  imgHeight.value = height;
161
110
  },
162
111
  () => {
163
- error.value = true;
164
- showImg.value = !!placeholder || false;
112
+ loading.value = false;
113
+ showPlaceholder.value = true;
165
114
  imageUrl.value = placeholder || null;
166
- }
115
+ },
167
116
  );
168
117
  } else {
169
- error.value = true;
170
- showImg.value = false;
171
- imageUrl.value = null;
118
+ showPlaceholder.value = true;
119
+ imageUrl.value = placeholder || null;
172
120
  }
173
121
  };
174
122
 
@@ -176,7 +124,7 @@ const KImage = defineComponent({
176
124
  () => props.src,
177
125
  () => {
178
126
  reload();
179
- }
127
+ },
180
128
  );
181
129
 
182
130
  onMounted(() => {
@@ -185,9 +133,6 @@ const KImage = defineComponent({
185
133
  });
186
134
 
187
135
  onBeforeUnmount(() => {
188
- // if (preview) {
189
- // preview.destroy();
190
- // }
191
136
  destroy();
192
137
  ImageGroup?.unregister(props.origin || props.src);
193
138
  });
@@ -212,26 +157,29 @@ const KImage = defineComponent({
212
157
  src: imageUrl.value,
213
158
  },
214
159
  };
160
+ const nodes = [];
161
+
162
+ if (loading.value) {
163
+ nodes.push(
164
+ <div class="k-image-loading">
165
+ <Icon type={Loading} spin class="k-image-loading-icon" />
166
+ </div>,
167
+ );
168
+ } else {
169
+ if (showPlaceholder.value) {
170
+ if (imageUrl.value) {
171
+ nodes.push(<img {...imgProps} />);
172
+ } else {
173
+ nodes.push(<Icon type={IconImage} class="k-image-error" />);
174
+ }
175
+ } else {
176
+ nodes.push(<img {...imgProps} />);
177
+ }
178
+ }
215
179
 
216
180
  return (
217
181
  <div {...containerProps}>
218
- {showImg.value || (!showImg.value && placeholder) ? (
219
- <img {...imgProps} />
220
- ) : null}
221
- {(!showImg.value || error.value) && !placeholder ? (
222
- <Icon type={IconImage} class="k-image-error" />
223
- ) : null}
224
- {loading.value ? (
225
- <div class="k-image-loading" key="image-loading">
226
- <Icon type={Loading} spin class="k-image-loading-icon" />
227
- </div>
228
- ) : null}
229
- {!loading.value && !error.value ? (
230
- <div class="k-image-preview-mask">
231
- <Icon type={EyeOutline} />
232
- {locale?.value.k.image.preview}
233
- </div>
234
- ) : null}
182
+ {nodes}
235
183
  {slots.default?.()}
236
184
  </div>
237
185
  );