@vuetkit/components 0.0.15 → 0.0.16

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.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,27 @@
1
1
  import { RequestService } from "@vuetkit/core";
2
- import { ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, FormRules, MessageProps, MessageType, PaginationProps, StepProps, StepsProps, TabPaneName, TableProps, TabsPaneContext, TabsProps } from "element-plus";
2
+ import { CollapseItemProps, CollapseModelValue, CollapseProps, ComponentSize, DescriptionItemProps, DescriptionProps, DialogProps, FormRules, MessageProps, MessageType, PaginationProps, StepProps, StepsProps, TabPaneName, TableProps, TabsPaneContext, TabsProps } from "element-plus";
3
3
  import { CSSProperties, Component, MaybeRef, Ref, VNode } from "vue";
4
4
  import { TableColumnProps } from "element-plus/es/components/table/src/table-column/defaults.mjs";
5
5
 
6
+ //#region src/data/useCollapse/index.d.ts
7
+ interface CollapseColumn extends Partial<CollapseItemProps> {
8
+ title?: string;
9
+ name?: string | number;
10
+ render?: (val: unknown) => VNode;
11
+ renderTitle?: (val: unknown) => VNode;
12
+ renderIcon?: (val: unknown) => VNode;
13
+ }
14
+ interface CollapseOptions<T> extends Partial<CollapseProps> {
15
+ columns: CollapseColumn[];
16
+ service?: RequestService<T>;
17
+ params?: unknown;
18
+ formatData?: (data: T) => CollapseColumn[];
19
+ defaultActive?: CollapseModelValue;
20
+ onChange?: (activeNames: CollapseModelValue) => void;
21
+ }
22
+ type CollapseReturnType = [Component, Ref<CollapseModelValue>];
23
+ declare function useCollapse<T>(options: CollapseOptions<T>): CollapseReturnType;
24
+ //#endregion
6
25
  //#region src/data/useDescriptions/index.d.ts
7
26
  interface DescriptionsColumn extends Partial<DescriptionItemProps> {
8
27
  value?: string;
@@ -204,4 +223,4 @@ interface TableOptions<T extends DefaultRow> extends TableProps<T> {
204
223
  type TableReturn = [Component];
205
224
  declare function useTable<T extends DefaultRow>(options: TableOptions<T>): TableReturn;
206
225
  //#endregion
207
- export { AsyncConfirmOptions, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, StepsColumn, StepsOptions, StepsReturnType, TableColumnOptions, TableOptions, TableReturn, TabsColumn, TabsOptions, TabsReturnType, setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable, useTabs };
226
+ export { AsyncConfirmOptions, CollapseColumn, CollapseOptions, CollapseReturnType, CustomRender, DefaultComponentKey, DescriptionsColumn, DescriptionsOptions, DescriptionsReturnType, FormItemType, FormOptions, FormReturnType, FormRuleFn, FormSchema, PaginationOptions, Recordable, StepsColumn, StepsOptions, StepsReturnType, TableColumnOptions, TableOptions, TableReturn, TabsColumn, TabsOptions, TabsReturnType, setDeepProperty, useAsyncConfirm, useCollapse, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable, useTabs };
package/dist/index.js CHANGED
@@ -1,7 +1,68 @@
1
1
  import { useRequest } from "@vuetkit/core";
2
- import { ElButton, ElCascader, ElCheckbox, ElCol, ElColorPicker, ElDatePicker, ElDescriptions, ElDescriptionsItem, ElDialog, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMessage, ElMessageBox, ElPagination, ElRadio, ElRate, ElRow, ElScrollbar, ElSelect, ElSelectV2, ElSlider, ElStep, ElSteps, ElSwitch, ElTabPane, ElTable, ElTableColumn, ElTabs, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload, vLoading } from "element-plus";
2
+ import { ElButton, ElCascader, ElCheckbox, ElCol, ElCollapse, ElCollapseItem, ElColorPicker, ElDatePicker, ElDescriptions, ElDescriptionsItem, ElDialog, ElForm, ElFormItem, ElInput, ElInputNumber, ElInputOtp, ElMention, ElMessage, ElMessageBox, ElPagination, ElRadio, ElRate, ElRow, ElScrollbar, ElSelect, ElSelectV2, ElSlider, ElStep, ElSteps, ElSwitch, ElTabPane, ElTable, ElTableColumn, ElTabs, ElTimePicker, ElTimeSelect, ElTransfer, ElTreeSelect, ElUpload, vLoading } from "element-plus";
3
3
  import { computed, defineComponent, h, nextTick, onMounted, reactive, ref, toValue, useTemplateRef, watch, withDirectives } from "vue";
4
4
  import { isFunc, realObj } from "@vuetkit/shared";
5
+ //#region src/data/useCollapse/index.ts
6
+ function useCollapse(options) {
7
+ const { columns = [], service, params, formatData, defaultActive = [], onChange, ...rest } = options;
8
+ const { data, loading } = service ? useRequest(service, {
9
+ defaultParams: params,
10
+ formatData: formatData || void 0
11
+ }) : {};
12
+ const activeNames = ref(defaultActive);
13
+ const collapseColumns = computed(() => (data === null || data === void 0 ? void 0 : data.value) || columns);
14
+ return [defineComponent({
15
+ props: { modelValue: {
16
+ type: [
17
+ String,
18
+ Number,
19
+ Array
20
+ ],
21
+ default: void 0
22
+ } },
23
+ setup(props, { slots, emit }) {
24
+ const renderColumns = () => {
25
+ var _collapseColumns$valu;
26
+ return (_collapseColumns$valu = collapseColumns.value) === null || _collapseColumns$valu === void 0 ? void 0 : _collapseColumns$valu.map((item, index) => {
27
+ var _item$name;
28
+ const itemName = (_item$name = item.name) !== null && _item$name !== void 0 ? _item$name : index;
29
+ return h(ElCollapseItem, {
30
+ ...item,
31
+ name: itemName
32
+ }, {
33
+ default: () => {
34
+ if (item === null || item === void 0 ? void 0 : item.render) return item.render(item);
35
+ return "";
36
+ },
37
+ title: (item === null || item === void 0 ? void 0 : item.renderTitle) ? () => item.renderTitle(item.title) : void 0,
38
+ icon: (item === null || item === void 0 ? void 0 : item.renderIcon) ? () => item.renderIcon(item.icon) : void 0
39
+ });
40
+ });
41
+ };
42
+ const handleChange = (val) => {
43
+ activeNames.value = val;
44
+ onChange === null || onChange === void 0 || onChange(val);
45
+ emit("change", val);
46
+ };
47
+ return () => {
48
+ var _ref, _props$modelValue, _loading$value;
49
+ const finalActiveNames = (_ref = (_props$modelValue = props.modelValue) !== null && _props$modelValue !== void 0 ? _props$modelValue : rest.modelValue) !== null && _ref !== void 0 ? _ref : activeNames.value;
50
+ return withDirectives(h(ElCollapse, {
51
+ ...rest,
52
+ ...props,
53
+ "modelValue": finalActiveNames,
54
+ "onUpdate:modelValue": handleChange,
55
+ "onChange": handleChange
56
+ }, { default: () => {
57
+ if (slots.default) return slots.default();
58
+ if (!collapseColumns.value.length) return "";
59
+ return renderColumns();
60
+ } }), [[vLoading, (_loading$value = loading === null || loading === void 0 ? void 0 : loading.value) !== null && _loading$value !== void 0 ? _loading$value : false]]);
61
+ };
62
+ }
63
+ }), activeNames];
64
+ }
65
+ //#endregion
5
66
  //#region src/data/useDescriptions/index.ts
6
67
  function useDescriptions(options) {
7
68
  const { columns = [], service, params, formatData, ...rest } = options;
@@ -637,4 +698,4 @@ function useTable(options) {
637
698
  })];
638
699
  }
639
700
  //#endregion
640
- export { setDeepProperty, useAsyncConfirm, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable, useTabs };
701
+ export { setDeepProperty, useAsyncConfirm, useCollapse, useDescriptions, useDialog, useForm, useMessage, useSteps, useTable, useTabs };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vuetkit/components",
3
3
  "type": "module",
4
- "version": "0.0.15",
4
+ "version": "0.0.16",
5
5
  "description": "Collection of business development components for Vue3 projects",
6
6
  "author": "Kalu5",
7
7
  "license": "MIT",
@@ -21,8 +21,8 @@
21
21
  "vue": "^3.5.35"
22
22
  },
23
23
  "dependencies": {
24
- "@vuetkit/core": "0.0.15",
25
- "@vuetkit/shared": "0.0.15"
24
+ "@vuetkit/core": "0.0.16",
25
+ "@vuetkit/shared": "0.0.16"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsdown --config-loader tsx"