@oinone/kunlun-vue-ui-common 6.3.9 → 6.4.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.
Files changed (84) hide show
  1. package/dist/icons/iconfont/iconfont.css +7 -3
  2. package/dist/icons/iconfont/iconfont.js +1 -1
  3. package/dist/icons/iconfont/iconfont.json +7 -0
  4. package/dist/icons/iconfont/iconfont.ttf +0 -0
  5. package/dist/icons/iconfont/iconfont.woff +0 -0
  6. package/dist/icons/iconfont/iconfont.woff2 +0 -0
  7. package/dist/icons/oinone-iconfont/iconfont.css +171 -3
  8. package/dist/icons/oinone-iconfont/iconfont.js +1 -1
  9. package/dist/icons/oinone-iconfont/iconfont.json +294 -0
  10. package/dist/icons/oinone-iconfont/iconfont.ttf +0 -0
  11. package/dist/icons/oinone-iconfont/iconfont.woff +0 -0
  12. package/dist/icons/oinone-iconfont/iconfont.woff2 +0 -0
  13. package/dist/oinone-kunlun-vue-ui-common.esm.js +2 -3
  14. package/dist/types/src/component/index.d.ts +2 -0
  15. package/dist/types/src/component/oio-button/props.d.ts +3 -0
  16. package/dist/types/src/component/oio-card/context.d.ts +12 -0
  17. package/dist/types/src/component/oio-card/index.d.ts +1 -0
  18. package/dist/types/src/component/oio-drawer/props.d.ts +18 -4
  19. package/dist/types/src/component/oio-drawer/typing.d.ts +4 -2
  20. package/dist/types/src/component/oio-drawer/useDrawer.d.ts +5 -1
  21. package/dist/types/src/component/oio-group/props.d.ts +3 -0
  22. package/dist/types/src/component/oio-inner-popup/props.d.ts +0 -2
  23. package/dist/types/src/component/oio-input/props.d.ts +18 -0
  24. package/dist/types/src/component/oio-modal/props.d.ts +18 -3
  25. package/dist/types/src/component/oio-modal/typing.d.ts +3 -5
  26. package/dist/types/src/component/oio-modal/useModal.d.ts +8 -3
  27. package/dist/types/src/component/oio-select/model.d.ts +2 -0
  28. package/dist/types/src/component/oio-select/props.d.ts +4 -0
  29. package/dist/types/src/component/oio-tabs/index.d.ts +1 -0
  30. package/dist/types/src/component/oio-tabs/props.d.ts +4 -0
  31. package/dist/types/src/component/oio-tabs/typing.d.ts +5 -0
  32. package/dist/types/src/component/oio-tree/events.d.ts +1 -1
  33. package/dist/types/src/component/oio-tree/props.d.ts +1 -35
  34. package/dist/types/src/component/vc-popup/index.d.ts +1 -0
  35. package/dist/types/src/component/vc-popup/props.d.ts +13 -0
  36. package/dist/types/src/context/form-context.d.ts +7 -0
  37. package/dist/types/src/context/index.d.ts +1 -0
  38. package/dist/types/src/index.d.ts +1 -0
  39. package/dist/types/src/quick-utils/index.d.ts +1 -0
  40. package/dist/types/src/quick-utils/use-copy.d.ts +4 -0
  41. package/dist/types/src/util/PropRecordHelper.d.ts +1 -1
  42. package/icons/iconfont/iconfont.css +7 -3
  43. package/icons/iconfont/iconfont.js +1 -1
  44. package/icons/iconfont/iconfont.json +7 -0
  45. package/icons/iconfont/iconfont.ttf +0 -0
  46. package/icons/iconfont/iconfont.woff +0 -0
  47. package/icons/iconfont/iconfont.woff2 +0 -0
  48. package/icons/oinone-iconfont/iconfont.css +171 -3
  49. package/icons/oinone-iconfont/iconfont.js +1 -1
  50. package/icons/oinone-iconfont/iconfont.json +294 -0
  51. package/icons/oinone-iconfont/iconfont.ttf +0 -0
  52. package/icons/oinone-iconfont/iconfont.woff +0 -0
  53. package/icons/oinone-iconfont/iconfont.woff2 +0 -0
  54. package/package.json +5 -5
  55. package/src/component/index.ts +4 -0
  56. package/src/component/oio-button/props.ts +3 -0
  57. package/src/component/oio-card/context.ts +27 -0
  58. package/src/component/oio-card/index.ts +1 -0
  59. package/src/component/oio-close-icon/oio-close-icon.vue +2 -2
  60. package/src/component/oio-drawer/props.ts +13 -6
  61. package/src/component/oio-drawer/typing.ts +4 -2
  62. package/src/component/oio-drawer/useDrawer.ts +176 -27
  63. package/src/component/oio-group/props.ts +3 -0
  64. package/src/component/oio-inner-popup/props.ts +1 -2
  65. package/src/component/oio-input/props.ts +3 -0
  66. package/src/component/oio-modal/props.ts +13 -5
  67. package/src/component/oio-modal/typing.ts +3 -5
  68. package/src/component/oio-modal/useModal.ts +110 -20
  69. package/src/component/oio-select/model.ts +3 -0
  70. package/src/component/oio-select/props.ts +4 -0
  71. package/src/component/oio-tabs/index.ts +1 -0
  72. package/src/component/oio-tabs/props.ts +4 -0
  73. package/src/component/oio-tabs/typing.ts +5 -0
  74. package/src/component/oio-tree/events.ts +1 -1
  75. package/src/component/oio-tree/props.ts +1 -37
  76. package/src/component/vc-popup/index.ts +1 -0
  77. package/src/component/vc-popup/props.ts +14 -0
  78. package/src/component/vc-popup/usePopup.ts +2 -0
  79. package/src/context/form-context.ts +17 -0
  80. package/src/context/index.ts +1 -0
  81. package/src/index.ts +1 -0
  82. package/src/quick-utils/index.ts +1 -0
  83. package/src/quick-utils/use-copy.ts +56 -0
  84. package/src/util/PropRecordHelper.ts +9 -7
@@ -0,0 +1,17 @@
1
+ import { inject, InjectionKey, provide } from 'vue';
2
+
3
+ export interface OioDefaultFormContext {
4
+ getTriggerContainer: (triggerNode: Node | HTMLElement) => Node | HTMLElement;
5
+ }
6
+
7
+ export const OioDefaultFormContextKey: InjectionKey<OioDefaultFormContext> = Symbol('OioDefaultFormContext');
8
+
9
+ export const useProviderOioDefaultFormContext = (state: OioDefaultFormContext): void => {
10
+ provide(OioDefaultFormContextKey, state);
11
+ };
12
+
13
+ export const useInjectOioDefaultFormContext = (): OioDefaultFormContext => {
14
+ return inject(OioDefaultFormContextKey, {
15
+ getTriggerContainer: (triggerNode) => triggerNode.parentNode || document.body
16
+ });
17
+ };
@@ -0,0 +1 @@
1
+ export * from './form-context';
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import './style/index.scss';
2
2
 
3
3
  export * from './component';
4
+ export * from './context';
4
5
  export * from './directives';
5
6
  export * from './event';
6
7
  export * from './quick-utils';
@@ -2,6 +2,7 @@ export * from './draggable';
2
2
  export * from './use-resizable-handle';
3
3
  export * from './use-cleanable-event';
4
4
  export * from './use-click';
5
+ export * from './use-copy';
5
6
  export * from './use-debounced-ref';
6
7
  export * from './use-scroll-operator';
7
8
  export * from './use-time-difference';
@@ -0,0 +1,56 @@
1
+ import { MessageHub } from '@oinone/kunlun-request';
2
+
3
+ let isSupportedClipboardCopy = true;
4
+
5
+ export function useCopy() {
6
+ const copy = async (text: string): Promise<boolean> => {
7
+ let res = await clipboardCopy(text);
8
+ if (!res) {
9
+ // 1. 创建临时文本框(不显示在页面上)
10
+ const input = document.createElement('input');
11
+ document.body.appendChild(input);
12
+
13
+ // 2. 设置要复制的文本
14
+ input.value = text;
15
+
16
+ // 3. 选中文本框内容
17
+ input.select();
18
+ input.setSelectionRange(0, text.length); // 兼容移动设备
19
+
20
+ // 4. 执行复制命令,并设置结果
21
+ res = document.execCommand('copy');
22
+
23
+ // 5. 清理临时元素
24
+ document.body.removeChild(input);
25
+ }
26
+ return res;
27
+ };
28
+
29
+ const clipboardCopy = async (text: string): Promise<boolean> => {
30
+ if (isSupportedClipboardCopy) {
31
+ try {
32
+ await navigator.clipboard.writeText(text);
33
+ return true;
34
+ } catch (e) {
35
+ console.error('copy text error.', e);
36
+ isSupportedClipboardCopy = false;
37
+ return false;
38
+ }
39
+ }
40
+ return false;
41
+ };
42
+
43
+ const copyAndNotify = async (text: string): Promise<void> => {
44
+ const res = await copy(text);
45
+ if (res) {
46
+ MessageHub.success('复制成功');
47
+ } else {
48
+ MessageHub.error('复制失败,请手动复制');
49
+ }
50
+ };
51
+
52
+ return {
53
+ browserCopy: copy,
54
+ browserCopyAndNotify: copyAndNotify
55
+ };
56
+ }
@@ -52,13 +52,13 @@ export class PropRecordHelper {
52
52
  if (isNil(data)) {
53
53
  data = {};
54
54
  }
55
- Object.keys(propsDefine).forEach((key) => {
55
+ for (const key of Object.keys(propsDefine)) {
56
56
  const value = values[key];
57
57
  if (isNil(value)) {
58
- return;
58
+ continue;
59
59
  }
60
- data![key] = value;
61
- });
60
+ data[key] = value;
61
+ }
62
62
  return data;
63
63
  }
64
64
 
@@ -164,16 +164,18 @@ export class PropRecordHelper {
164
164
  public static collectionBasicProps(
165
165
  attrs: Record<string, unknown>,
166
166
  classNames?: string[],
167
- style?: string | CSSStyle
167
+ style?: string | Partial<CSSStyle>
168
168
  ): Record<string, unknown> {
169
169
  let basicProps: Record<string, unknown> = {};
170
170
  classNames = StringHelper.append(classNames || [], CastHelper.cast(attrs.class));
171
171
  const attrStyle = attrs.style as CSSStyle;
172
172
  if (style) {
173
173
  if (isObject(attrStyle)) {
174
+ // 组件内置 style 优先级高于外部传入的 style,否则会影响组件动态计算值;
175
+ // 如果组件需要外部修改样式的,使用 css class 设置可被替换的样式;
174
176
  style = {
175
- ...(StyleHelper.parse(style) || {}),
176
- ...attrStyle
177
+ ...attrStyle,
178
+ ...(StyleHelper.parse(style as CSSStyle) || {})
177
179
  };
178
180
  }
179
181
  } else {