cosey 0.3.3 → 0.3.5

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.
@@ -0,0 +1,11 @@
1
+ export interface CardProps {
2
+ }
3
+ export interface CardSlots {
4
+ default?: (props: Record<string, never>) => any;
5
+ }
6
+ export interface CardEmits {
7
+ (e: 'click'): void;
8
+ }
9
+ export interface CardExpose {
10
+ method: () => void;
11
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,16 @@
1
+ import { type CardProps, type CardSlots } from './card';
2
+ type __VLS_Slots = CardSlots;
3
+ declare const __VLS_component: import("vue").DefineComponent<CardProps, {
4
+ method: () => void;
5
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
+ click: () => any;
7
+ }, string, import("vue").PublicProps, Readonly<CardProps> & Readonly<{
8
+ onClick?: (() => any) | undefined;
9
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
11
+ export default _default;
12
+ type __VLS_WithSlots<T, S> = T & {
13
+ new (): {
14
+ $slots: S;
15
+ };
16
+ };
@@ -0,0 +1,31 @@
1
+ import { defineComponent, createElementBlock, openBlock, normalizeClass, unref, renderSlot } from 'vue';
2
+ import stdin_default$1 from './style/index.js';
3
+ import { useComponentConfig } from '../config-provider/config-provider.js';
4
+
5
+ var stdin_default = /* @__PURE__ */defineComponent({
6
+ ...{
7
+ name: "Card"
8
+ },
9
+ __name: "card",
10
+ emits: ["click"],
11
+ setup(__props, {
12
+ expose: __expose
13
+ }) {
14
+ const props = __props;
15
+ const {
16
+ prefixCls
17
+ } = useComponentConfig("card", props);
18
+ const {
19
+ hashId
20
+ } = stdin_default$1(prefixCls);
21
+ __expose();
22
+ return (_ctx, _cache) => {
23
+ return openBlock(), createElementBlock("div", {
24
+ class: normalizeClass([unref(hashId), unref(prefixCls)])
25
+ }, [renderSlot(_ctx.$slots, "default")], 2
26
+ /* CLASS */);
27
+ };
28
+ }
29
+ });
30
+
31
+ export { stdin_default as default };
@@ -0,0 +1,34 @@
1
+ export * from './card';
2
+ declare const _Card: {
3
+ new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./card").CardProps> & Readonly<{
4
+ onClick?: (() => any) | undefined;
5
+ }>, {
6
+ method: () => void;
7
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
8
+ click: () => any;
9
+ }, import("vue").PublicProps, {}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
10
+ P: {};
11
+ B: {};
12
+ D: {};
13
+ C: {};
14
+ M: {};
15
+ Defaults: {};
16
+ }, Readonly<import("./card").CardProps> & Readonly<{
17
+ onClick?: (() => any) | undefined;
18
+ }>, {
19
+ method: () => void;
20
+ }, {}, {}, {}, {}>;
21
+ __isFragment?: never;
22
+ __isTeleport?: never;
23
+ __isSuspense?: never;
24
+ } & import("vue").ComponentOptionsBase<Readonly<import("./card").CardProps> & Readonly<{
25
+ onClick?: (() => any) | undefined;
26
+ }>, {
27
+ method: () => void;
28
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
29
+ click: () => any;
30
+ }, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
31
+ $slots: import("./card").CardSlots;
32
+ }) & import("vue").Plugin;
33
+ export { _Card as Card };
34
+ export default _Card;
@@ -0,0 +1,7 @@
1
+ import { withInstall } from '../utils.js';
2
+ import stdin_default$1 from './card.vue.js';
3
+
4
+ const _Card = withInstall(stdin_default$1);
5
+ var stdin_default = _Card;
6
+
7
+ export { _Card as Card, stdin_default as default };
@@ -0,0 +1,4 @@
1
+ declare const _default: (_prefixCls?: import("vue").ComputedRef<string> | string, themeManager?: import("../../theme/theme-context").ThemeManager) => {
2
+ hashId: import("vue").Ref<string, string>;
3
+ };
4
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import { getSimpleStyleHook } from 'cosey/components';
2
+
3
+ var stdin_default = getSimpleStyleHook("Card", (token) => {
4
+ const { componentCls } = token;
5
+ return {
6
+ [`${componentCls}`]: {
7
+ backgroundColor: token.colorBgContainer,
8
+ paddingInline: token.sizeSM,
9
+ paddingBlock: token.size
10
+ }
11
+ };
12
+ });
13
+
14
+ export { stdin_default as default };
@@ -1,5 +1,6 @@
1
1
  import { AudioCard } from './audio-card';
2
2
  import { AudioViewer } from './audio-viewer';
3
+ import { Card } from './card';
3
4
  import { Close } from './close';
4
5
  import { Col } from './col';
5
6
  import { ConfigProvider } from './config-provider';
@@ -46,6 +47,7 @@ declare module 'vue' {
46
47
  interface GlobalComponents {
47
48
  CoAudioCard: typeof AudioCard;
48
49
  CoAudioViewer: typeof AudioViewer;
50
+ CoCard: typeof Card;
49
51
  CoClose: typeof Close;
50
52
  CoCol: typeof Col;
51
53
  CoConfigProvider: typeof ConfigProvider;
@@ -95,4 +97,4 @@ declare module 'vue' {
95
97
  CoVideoViewer: typeof VideoViewer;
96
98
  }
97
99
  }
98
- export { AudioCard, AudioViewer, Close, Col, ConfigProvider, Container, ContextMenu, ContextMenuItem, ContextSubMenu, Copy, DndSort, DndSortItem, Editor, Field, FileCard, Form, FormItem, FormDialog, FormDrawer, FormGroup, FormList, FormQuery, Highlight, HorizontalTree, Icon, IconifyIcon, ImageCard, LongText, Mask, MediaCard, MediaCardGroup, MediaViewer, NumberFormat, OnlyChild, OptionalWrapper, Panel, Row, ScrollView, SnugMenu, SnugMenuItem, SvgIcon, Table, TableAction, Toggle, Transition, TransitionGroup, Upload, VideoCard, VideoViewer, };
100
+ export { AudioCard, AudioViewer, Card, Close, Col, ConfigProvider, Container, ContextMenu, ContextMenuItem, ContextSubMenu, Copy, DndSort, DndSortItem, Editor, Field, FileCard, Form, FormItem, FormDialog, FormDrawer, FormGroup, FormList, FormQuery, Highlight, HorizontalTree, Icon, IconifyIcon, ImageCard, LongText, Mask, MediaCard, MediaCardGroup, MediaViewer, NumberFormat, OnlyChild, OptionalWrapper, Panel, Row, ScrollView, SnugMenu, SnugMenuItem, SvgIcon, Table, TableAction, Toggle, Transition, TransitionGroup, Upload, VideoCard, VideoViewer, };
@@ -1,5 +1,6 @@
1
1
  export { AudioCard } from './audio-card/index.js';
2
2
  export { AudioViewer } from './audio-viewer/index.js';
3
+ export { Card } from './card/index.js';
3
4
  export { Close } from './close/index.js';
4
5
  export { Col } from './col/index.js';
5
6
  export { ConfigProvider } from './config-provider/index.js';
@@ -1,11 +1,13 @@
1
1
  export * from './audio-card';
2
2
  export * from './audio-viewer';
3
+ export * from './card';
3
4
  export * from './close';
4
5
  export * from './col';
5
6
  export * from './config-provider';
6
7
  export * from './container';
7
8
  export * from './context-menu';
8
9
  export * from './copy';
10
+ export * from './cssinjs';
9
11
  export * from './dnd-sort';
10
12
  export * from './editor';
11
13
  export * from './field';
@@ -44,7 +46,6 @@ export * from './transition-group';
44
46
  export * from './upload';
45
47
  export * from './video-card';
46
48
  export * from './video-viewer';
47
- export * from './cssinjs';
48
49
  import { type App } from 'vue';
49
50
  import * as components from './components';
50
51
  declare const installer: {
@@ -1,5 +1,6 @@
1
1
  export { AudioCard } from './audio-card/index.js';
2
2
  export { AudioViewer } from './audio-viewer/index.js';
3
+ export { Card } from './card/index.js';
3
4
  export { Close } from './close/index.js';
4
5
  export { Col } from './col/index.js';
5
6
  export { ConfigProvider } from './config-provider/index.js';
@@ -49,6 +50,8 @@ export { defaultColProps } from './col/col.js';
49
50
  export { defaultConfigProvider, defaultPrefixCls, useComponentConfig, useConfig, useConfigProvide } from './config-provider/config-provider.js';
50
51
  export { containerContextKey } from './container/container.js';
51
52
  export { contextMenuContextSymbol } from './context-menu/context-menu.js';
53
+ export { default as Keyframes } from './cssinjs/Keyframes.js';
54
+ export { parseStyle } from './cssinjs/parser.js';
52
55
  export { dndSortContextSymbol } from './dnd-sort/dnd-sort.js';
53
56
  export { useDndSort } from './dnd-sort/useDndSort.js';
54
57
  export { useDndSortItem } from './dnd-sort/useDndSortItem.js';
@@ -99,8 +102,6 @@ export { defaultUploadProps } from './upload/upload.js';
99
102
  export { useUpload, useUploadProvide } from './upload-context.js';
100
103
  export { defaultVideoCardProps } from './video-card/video-card.js';
101
104
  export { defaultVideoViewerProps } from './video-viewer/video-viewer.js';
102
- export { default as Keyframes } from './cssinjs/Keyframes.js';
103
- export { parseStyle } from './cssinjs/parser.js';
104
105
 
105
106
  const installer = {
106
107
  install(app) {
@@ -28,7 +28,7 @@ declare const _Table: {
28
28
  formProps: {
29
29
  type: import("vue").PropType<Partial<import("vue").ExtractPropTypes<{
30
30
  schemes: {
31
- type: import("vue").PropType<import("..").FormItemProps<import("..").FieldType>[]>;
31
+ type: import("vue").PropType<import(".").TableQueryScheme[]>;
32
32
  default: () => never[];
33
33
  };
34
34
  grid: {
@@ -351,7 +351,7 @@ declare const _Table: {
351
351
  formProps: {
352
352
  type: import("vue").PropType<Partial<import("vue").ExtractPropTypes<{
353
353
  schemes: {
354
- type: import("vue").PropType<import("..").FormItemProps<import("..").FieldType>[]>;
354
+ type: import("vue").PropType<import(".").TableQueryScheme[]>;
355
355
  default: () => never[];
356
356
  };
357
357
  grid: {
@@ -1,4 +1,4 @@
1
- import { SwitchProps, type TableColumnCtx } from 'element-plus';
1
+ import { type LinkProps, SwitchProps, type TableColumnCtx } from 'element-plus';
2
2
  import { type TableColumnProps } from './table-column';
3
3
  import { type LongTextProps } from '../../long-text';
4
4
  import { type MediaCardProps } from '../../media-card';
@@ -27,12 +27,21 @@ export type RendererType = 'text' | 'date' | 'datetime' | 'media' | {
27
27
  type: 'switch';
28
28
  props?: Partial<SwitchProps>;
29
29
  api?: (value: any, row: any) => Promise<any>;
30
+ } | {
31
+ type: 'click';
32
+ props?: Partial<LinkProps>;
33
+ onClick?: (params: {
34
+ row: any;
35
+ value: any;
36
+ index: number;
37
+ column: TableColumnCtx<any>;
38
+ }) => void;
30
39
  };
31
40
  export declare const mapRendererColumnProps: Record<string, TableColumnProps>;
32
41
  /**
33
42
  * 可组合其他组件进行渲染
34
43
  */
35
- export declare function renderer<T extends RendererType>({ cellValue, row }: RendererOptions, type: RendererType | undefined, t: Translator): any;
44
+ export declare function renderer<T extends RendererType>({ cellValue, row, index, column }: RendererOptions, type: RendererType | undefined, t: Translator): any;
36
45
  /**
37
46
  * 导出表格数据时使用的渲染器,只需要获取文本数据
38
47
  */
@@ -1,5 +1,5 @@
1
- import { ref, createVNode, mergeProps } from 'vue';
2
- import { ElSwitch, ElMessage, ElTag } from 'element-plus';
1
+ import { createVNode, mergeProps, ref, isVNode } from 'vue';
2
+ import { ElLink, ElSwitch, ElMessage, ElTag } from 'element-plus';
3
3
  import { get } from 'lodash-es';
4
4
  import { LongText as _LongText } from '../../long-text/index.js';
5
5
  import { MediaCard as _MediaCard } from '../../media-card/index.js';
@@ -9,6 +9,9 @@ import { Scope } from '../../../utils/vue.js';
9
9
  import { formatAsDate, formatAsDateTime } from '../../../utils/date.js';
10
10
  import { toArray } from '../../../utils/array.js';
11
11
 
12
+ function _isSlot(s) {
13
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
14
+ }
12
15
  const mapRendererColumnProps = {
13
16
  media: {
14
17
  minWidth: 104,
@@ -24,7 +27,9 @@ const mapRendererColumnProps = {
24
27
  };
25
28
  function renderer({
26
29
  cellValue,
27
- row
30
+ row,
31
+ index,
32
+ column
28
33
  }, type = "text", t) {
29
34
  if (isEmpty(cellValue)) {
30
35
  return "";
@@ -89,6 +94,21 @@ function renderer({
89
94
  }), null)]
90
95
  });
91
96
  }
97
+ case "click":
98
+ return createVNode(ElLink, mergeProps({
99
+ "type": "primary",
100
+ "underline": "never",
101
+ "style": "font-weight: normal; word-break: break-all;"
102
+ }, obj.props, {
103
+ "onClick": () => obj.onClick?.({
104
+ row,
105
+ value: cellValue,
106
+ index,
107
+ column
108
+ })
109
+ }), _isSlot(cellValue) ? cellValue : {
110
+ default: () => [cellValue]
111
+ });
92
112
  }
93
113
  }
94
114
  function exportRenderer(row, column, cellValue, index) {
@@ -110,6 +130,7 @@ function exportRenderer(row, column, cellValue, index) {
110
130
  case "media":
111
131
  case "longtext":
112
132
  case "switch":
133
+ case "click":
113
134
  return cellValue;
114
135
  case "mediagroup":
115
136
  return JSON.stringify(cellValue);
@@ -46,7 +46,10 @@ const TableColumn = defineComponent({
46
46
  obj.formatter = (row, column, cellValue, index) => {
47
47
  return renderer({
48
48
  cellValue,
49
- row}, obj.renderer, t);
49
+ row,
50
+ column,
51
+ index
52
+ }, obj.renderer, t);
50
53
  };
51
54
  const renderType = typeof obj.renderer === "object" ? obj.renderer.type : obj.renderer;
52
55
  const renderProps = mapRendererColumnProps[renderType];
@@ -1,10 +1,16 @@
1
1
  import { type FieldType } from '../../field';
2
2
  import { type FormItemProps } from '../../form';
3
3
  import { type FormQuerySlots, type FormQueryEmits, type FormQueryExpose } from '../../form-query';
4
- import { type PropType, type ExtractPropTypes } from 'vue';
4
+ import { type PropType, type ExtractPropTypes, VNodeChild } from 'vue';
5
+ export type TableQueryScheme = FormItemProps<FieldType> & {
6
+ render?: (params: {
7
+ model: Record<string, any>;
8
+ }) => VNodeChild;
9
+ slots?: Record<string, unknown>;
10
+ };
5
11
  export declare const tableQueryProps: {
6
12
  schemes: {
7
- type: PropType<FormItemProps<FieldType>[]>;
13
+ type: PropType<TableQueryScheme[]>;
8
14
  default: () => never[];
9
15
  };
10
16
  grid: {
@@ -2,7 +2,7 @@ import { type TableQuerySlots } from './table-query';
2
2
  type __VLS_Slots = TableQuerySlots;
3
3
  declare const __VLS_component: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
4
  schemes: {
5
- type: import("vue").PropType<import("../..").FormItemProps<import("../..").FieldType>[]>;
5
+ type: import("vue").PropType<import("./table-query").TableQueryScheme[]>;
6
6
  default: () => never[];
7
7
  };
8
8
  grid: {
@@ -155,7 +155,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
155
155
  "update:collapsed": (val: boolean) => any;
156
156
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
157
157
  schemes: {
158
- type: import("vue").PropType<import("../..").FormItemProps<import("../..").FieldType>[]>;
158
+ type: import("vue").PropType<import("./table-query").TableQueryScheme[]>;
159
159
  default: () => never[];
160
160
  };
161
161
  grid: {
@@ -318,7 +318,7 @@ declare const __VLS_component: import("vue").DefineComponent<import("vue").Extra
318
318
  scrollIntoViewOptions: boolean | Record<string, any>;
319
319
  minFields: number;
320
320
  collapsed: boolean;
321
- schemes: import("../..").FormItemProps<keyof import("../..").MapFieldTypeComponentProps>[];
321
+ schemes: import("./table-query").TableQueryScheme[];
322
322
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
323
323
  declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
324
324
  export default _default;
@@ -1,10 +1,10 @@
1
- import { defineComponent, useTemplateRef, reactive, onBeforeMount, createBlock, openBlock, unref, mergeProps, withKeys, withModifiers, withCtx, createElementBlock, Fragment, renderList } from 'vue';
1
+ import { defineComponent, ref, reactive, onBeforeMount, createBlock, openBlock, resolveDynamicComponent, unref } from 'vue';
2
2
  import { tableQueryProps, omittedTableQueryProps, tableQueryExposeKeys } from './table-query.js';
3
3
  import { reactiveOmit } from '@vueuse/core';
4
4
  import { cloneDeep } from 'lodash-es';
5
5
  import { FormItem as _FormItem } from '../../form/index.js';
6
6
  import { FormQuery as _FormQuery } from '../../form-query/index.js';
7
- import { createMergedExpose } from '../../../utils/vue.js';
7
+ import { createMergedExpose, defineTemplate } from '../../../utils/vue.js';
8
8
 
9
9
  var stdin_default = /* @__PURE__ */defineComponent({
10
10
  ...{
@@ -18,7 +18,7 @@ var stdin_default = /* @__PURE__ */defineComponent({
18
18
  }) {
19
19
  const props = __props;
20
20
  const formQueryProps = reactiveOmit(props, omittedTableQueryProps);
21
- const formQueryRef = useTemplateRef("formQuery");
21
+ const formQueryRef = ref();
22
22
  const formModel = reactive({});
23
23
  onBeforeMount(() => {
24
24
  props.schemes.forEach(item => {
@@ -40,26 +40,39 @@ var stdin_default = /* @__PURE__ */defineComponent({
40
40
  }
41
41
  };
42
42
  __expose(createMergedExpose(tableQueryExposeKeys, () => formQueryRef.value, customExpose));
43
- return (_ctx, _cache) => {
44
- return openBlock(), createBlock(unref(_FormQuery), mergeProps({
45
- ref: "formQuery"
46
- }, unref(formQueryProps), {
43
+ const template = defineTemplate(h => {
44
+ return h(_FormQuery, {
45
+ ...formQueryProps,
46
+ ref: formQueryRef,
47
47
  model: formModel,
48
- onKeyup: withKeys(withModifiers(onEnter, ["prevent"]), ["enter"])
49
- }), {
50
- default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.schemes, (item, i) => {
51
- return openBlock(), createBlock(unref(_FormItem), mergeProps({
52
- key: i,
53
- ref_for: true
54
- }, item, {
55
- modelValue: formModel[item.prop],
56
- "onUpdate:modelValue": $event => formModel[item.prop] = $event
57
- }), null, 16, ["modelValue", "onUpdate:modelValue"]);
58
- }), 128
59
- /* KEYED_FRAGMENT */))]),
60
- _: 1
61
- /* STABLE */
62
- }, 16, ["model", "onKeyup"]);
48
+ onKeyupEnterPrevent: onEnter
49
+ }, () => {
50
+ return props.schemes.map(item => {
51
+ const {
52
+ slots,
53
+ render,
54
+ ...rest
55
+ } = item;
56
+ if (render) {
57
+ return h(_FormItem, rest, {
58
+ ...slots,
59
+ default: () => {
60
+ return render({
61
+ model: formModel
62
+ });
63
+ }
64
+ });
65
+ }
66
+ return h(_FormItem, {
67
+ ...rest,
68
+ modelValue: formModel[rest.prop],
69
+ "onUpdate:modelValue": value => formModel[rest.prop] = value
70
+ }, slots);
71
+ });
72
+ });
73
+ });
74
+ return (_ctx, _cache) => {
75
+ return openBlock(), createBlock(resolveDynamicComponent(unref(template)));
63
76
  };
64
77
  }
65
78
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",