@xy-planning-network/trees 0.6.6-rc-7 → 0.6.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xy-planning-network/trees",
3
- "version": "0.6.6-rc-7",
3
+ "version": "0.6.6",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "repository": "github:xy-planning-network/trees",
@@ -12,13 +12,11 @@ import { toRef } from "vue"
12
12
  const props = withDefaults(
13
13
  defineProps<{
14
14
  tableActions?: TableActions<any>
15
- tableActionsType?: "dropdown" | "buttons"
16
15
  tableColumns: TableColumns<any>
17
16
  tableData: TableRowsData
18
17
  }>(),
19
18
  {
20
- tableActions: () => [],
21
- tableActionsType: "dropdown",
19
+ tableActions: () => ({ type: "dropdown", actions: [] }),
22
20
  }
23
21
  )
24
22
 
@@ -78,7 +76,7 @@ const { columns, hasActions, isEmptyCellValue, rows } = useTable(
78
76
  class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap leading-5"
79
77
  >
80
78
  <ActionsDropdown
81
- v-if="tableActionsType === 'dropdown'"
79
+ v-if="tableActions.type === 'dropdown'"
82
80
  :actions="row.actions"
83
81
  />
84
82
  <template v-else>
@@ -17,23 +17,17 @@ import TableActionButtons from "./TableActionButtons.vue"
17
17
 
18
18
  const props = withDefaults(
19
19
  defineProps<{
20
- clickable?: boolean
21
- loader?: boolean
22
20
  tableActions?: TableActions<any>
23
- tableActionsType?: "dropdown" | "buttons"
24
21
  tableColumns: TableColumns<any>
25
22
  tableOptions: DynamicTableOptions
26
23
  }>(),
27
24
  {
28
- clickable: false,
29
- loader: true,
30
- tableActions: () => [],
31
- tableActionsType: "dropdown",
25
+ tableActions: () => ({ type: "dropdown", actions: [] }),
32
26
  }
33
27
  )
34
28
 
35
29
  defineEmits<{
36
- (e: "click:row", v: any, i: number, c: typeof publicMethods): void
30
+ (e: "click:row", v: any): void
37
31
  }>()
38
32
 
39
33
  const loadAndRender = (): void => {
@@ -49,7 +43,7 @@ const loadAndRender = (): void => {
49
43
 
50
44
  BaseAPI.get<TrailsRespPaged<unknown>>(
51
45
  props.tableOptions.url,
52
- { skipLoader: !props.loader },
46
+ { skipLoader: true },
53
47
  params
54
48
  ).then(
55
49
  (success) => {
@@ -266,18 +260,13 @@ loadAndRender()
266
260
  <tr
267
261
  v-for="(row, rowIdx) in rows"
268
262
  :key="rowIdx"
269
- class="group"
270
- :class="{ 'cursor-pointer': clickable }"
271
- @click.stop="$emit('click:row', row.rowData, rowIdx, publicMethods)"
263
+ @click="$emit('click:row', row.rowData)"
272
264
  >
273
265
  <template v-for="(cell, cellIdx) in row.cells" :key="cellIdx">
274
266
  <component
275
267
  :is="'td'"
276
268
  class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap leading-5"
277
- :class="{
278
- [cell.alignment]: true,
279
- 'group-hover:bg-gray-50': clickable,
280
- }"
269
+ :class="cell.alignment"
281
270
  >
282
271
  <template v-if="cell.isComponent">
283
272
  <component :is="cell.val" />
@@ -295,7 +284,7 @@ loadAndRender()
295
284
  class="px-6 py-4 text-sm text-gray-700 whitespace-nowrap leading-5"
296
285
  >
297
286
  <ActionsDropdown
298
- v-if="tableActionsType === 'dropdown'"
287
+ v-if="tableActions.type === 'dropdown'"
299
288
  :actions="row.actions"
300
289
  />
301
290
  <template v-else>
@@ -29,7 +29,7 @@ const { actions, hasActions } = useActionItems(toRef(props, "actions"))
29
29
  'rounded-r-md': actionIdx === actions.length - 1,
30
30
  }"
31
31
  :disabled="action.disabled"
32
- @click="action.event"
32
+ @click.stop="action.onClick"
33
33
  >
34
34
  <span class="relative inline-flex items-center gap-x-1.5">
35
35
  <component
@@ -46,7 +46,7 @@ const { actions, hasActions } = useActionItems(toRef(props, "actions"))
46
46
  active ? 'bg-gray-100 text-gray-900' : 'text-gray-700',
47
47
  'block w-full text-left px-4 py-2 text-sm font-semibold disabled:cursor-not-allowed',
48
48
  ]"
49
- @click="action.event"
49
+ @click="action.onClick"
50
50
  >
51
51
  <span class="relative inline-flex items-center gap-x-1.5">
52
52
  <component
@@ -13,7 +13,7 @@ export interface Pagination {
13
13
  }
14
14
  export interface ActionItem {
15
15
  disabled?: boolean | ((...args: any[]) => boolean);
16
- event: (...args: any[]) => void;
16
+ onClick: (...args: any[]) => void;
17
17
  icon?: FunctionalComponent | RenderFunction;
18
18
  label: string;
19
19
  show?: boolean | ((...args: any[]) => boolean);
@@ -22,10 +22,41 @@ export interface DynamicTableAPI {
22
22
  reset: () => void;
23
23
  }
24
24
  export interface TableActionItem<T = TableRowData> extends ActionItem {
25
+ /**
26
+ * The disabled property determines the value of the disabled attribute on the button
27
+ * attached to the action. Allowing the action to stay visible to the user, but keeping the action
28
+ * disabled from use.
29
+ *
30
+ * disabled accepts a boolean value or a function with the table row data as
31
+ * the first argument and the row index as the second.
32
+ */
25
33
  disabled?: boolean | ((rowData: T, rowIndex: number) => boolean);
26
- event: (rowData: T, rowIndex: number, tableAPI: DynamicTableAPI) => void;
34
+ /**
35
+ * onClick is the callback function triggered by the button rendered in the table actions.
36
+ * @param rowData T
37
+ * @param rowIndex number
38
+ * @param tableAPI DynamicTableAPI
39
+ * @returns void
40
+ */
41
+ onClick: (rowData: T, rowIndex: number, tableAPI: DynamicTableAPI) => void;
42
+ /**
43
+ * The show property determines whether the action is visible.
44
+ *
45
+ * show accepts a boolean value or a function with the table row data as
46
+ * the first argument and the row index as the second.
47
+ */
27
48
  show?: boolean | ((rowData: T, rowIndex: number) => boolean);
28
49
  }
50
+ export interface TableActions<T = TableRowData> {
51
+ /**
52
+ * an array of TableActionItem definitions
53
+ */
54
+ actions: TableActionItem<T>[];
55
+ /**
56
+ * type determines what component will render the actions
57
+ */
58
+ type: "dropdown" | "buttons";
59
+ }
29
60
  export interface TableColumn<T = TableRowData> {
30
61
  /**
31
62
  * The alignment the table cell should have
@@ -51,7 +82,6 @@ export interface TableColumn<T = TableRowData> {
51
82
  */
52
83
  sort?: string;
53
84
  }
54
- export type TableActions<T = TableRowData> = TableActionItem<T>[];
55
85
  export type TableCellAlignment = "left" | "center" | "right";
56
86
  export type TableRowData = Record<string, any>;
57
87
  export type TableColumns<T = TableRowData> = TableColumn<T>[];
@@ -4,7 +4,7 @@ export declare const useActionItems: (items: ActionItem[] | Ref<ActionItem[]>) =
4
4
  actions: import("vue").ComputedRef<{
5
5
  disabled: boolean;
6
6
  show: boolean;
7
- event: (...args: any[]) => void;
7
+ onClick: (...args: any[]) => void;
8
8
  icon?: import("vue").RenderFunction | import("vue").FunctionalComponent<{}, {}> | undefined;
9
9
  label: string;
10
10
  }[]>;
@@ -13,7 +13,7 @@ export declare const useTable: (rowData: TableRowsData | Ref<TableRowsData>, col
13
13
  rows: import("vue").ComputedRef<{
14
14
  actions: {
15
15
  disabled: boolean | undefined;
16
- event: () => void;
16
+ onClick: () => void;
17
17
  show: boolean | undefined;
18
18
  icon?: import("vue").RenderFunction | import("vue").FunctionalComponent<{}, {}> | undefined;
19
19
  label: string;
@@ -1,25 +1,23 @@
1
1
  import type { TableActions, TableColumns, TableRowsData } from "../../composables/table";
2
2
  declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
3
  tableActions?: TableActions<any> | undefined;
4
- tableActionsType?: "dropdown" | "buttons" | undefined;
5
4
  tableColumns: TableColumns<any>;
6
5
  tableData: TableRowsData;
7
6
  }>, {
8
- tableActions: () => never[];
9
- tableActionsType: string;
7
+ tableActions: () => {
8
+ type: string;
9
+ actions: never[];
10
+ };
10
11
  }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
11
12
  tableActions?: unknown;
12
- tableActionsType?: unknown;
13
13
  tableColumns?: unknown;
14
14
  tableData?: unknown;
15
15
  } & {
16
16
  tableActions: TableActions<any>;
17
- tableActionsType: "dropdown" | "buttons";
18
17
  tableColumns: TableColumns<any>;
19
18
  tableData: TableRowsData;
20
19
  } & {}>, {
21
20
  tableActions: TableActions<any>;
22
- tableActionsType: "dropdown" | "buttons";
23
21
  }>;
24
22
  export default _default;
25
23
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,42 +1,30 @@
1
- import type { DynamicTableAPI, DynamicTableOptions, TableActions, TableColumns } from "../../composables/table";
1
+ import type { DynamicTableOptions, TableActions, TableColumns } from "../../composables/table";
2
2
  declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
- clickable?: boolean | undefined;
4
- loader?: boolean | undefined;
5
3
  tableActions?: TableActions<any> | undefined;
6
- tableActionsType?: "dropdown" | "buttons" | undefined;
7
4
  tableColumns: TableColumns<any>;
8
5
  tableOptions: DynamicTableOptions;
9
6
  }>, {
10
- clickable: boolean;
11
- loader: boolean;
12
- tableActions: () => never[];
13
- tableActionsType: string;
7
+ tableActions: () => {
8
+ type: string;
9
+ actions: never[];
10
+ };
14
11
  }>, {
15
12
  refresh: () => void;
16
13
  reset: () => void;
17
14
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
- "click:row": (v: any, i: number, c: DynamicTableAPI) => void;
15
+ "click:row": (v: any) => void;
19
16
  }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
20
- clickable?: unknown;
21
- loader?: unknown;
22
17
  tableActions?: unknown;
23
- tableActionsType?: unknown;
24
18
  tableColumns?: unknown;
25
19
  tableOptions?: unknown;
26
20
  } & {
27
- clickable: boolean;
28
- loader: boolean;
29
21
  tableActions: TableActions<any>;
30
- tableActionsType: "dropdown" | "buttons";
31
22
  tableColumns: TableColumns<any>;
32
23
  tableOptions: DynamicTableOptions;
33
24
  } & {}> & {
34
- "onClick:row"?: ((v: any, i: number, c: DynamicTableAPI) => any) | undefined;
25
+ "onClick:row"?: ((v: any) => any) | undefined;
35
26
  }, {
36
- clickable: boolean;
37
- loader: boolean;
38
27
  tableActions: TableActions<any>;
39
- tableActionsType: "dropdown" | "buttons";
40
28
  }>;
41
29
  export default _default;
42
30
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,21 +0,0 @@
1
- import type { TableColumn, TableRow } from "../../composables/table";
2
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
- columns: TableColumn<TableRow>[];
4
- rows: TableRow[];
5
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
6
- columns?: unknown;
7
- rows?: unknown;
8
- } & {
9
- columns: TableColumn<TableRow>[];
10
- rows: TableRow[];
11
- } & {}>, {}>;
12
- export default _default;
13
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
14
- type __VLS_TypePropsToRuntimeProps<T> = {
15
- [K in keyof T]-?: {} extends Pick<T, K> ? {
16
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
17
- } : {
18
- type: import('vue').PropType<T[K]>;
19
- required: true;
20
- };
21
- };
@@ -1,27 +0,0 @@
1
- import * as TableTypes from "../../composables/table";
2
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
- tableData: Omit<TableTypes.Static, "currentUser">;
4
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
5
- tableData?: unknown;
6
- } & {
7
- tableData: Omit<TableTypes.Static, "currentUser">;
8
- } & {}>, {}>, {
9
- actions: (_: {
10
- row: Record<string, unknown>;
11
- }) => any;
12
- }>;
13
- export default _default;
14
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
15
- type __VLS_TypePropsToRuntimeProps<T> = {
16
- [K in keyof T]-?: {} extends Pick<T, K> ? {
17
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
18
- } : {
19
- type: import('vue').PropType<T[K]>;
20
- required: true;
21
- };
22
- };
23
- type __VLS_WithTemplateSlots<T, S> = T & {
24
- new (): {
25
- $slots: S;
26
- };
27
- };
@@ -1,39 +0,0 @@
1
- import * as TableTypes from "../../composables/table";
2
- declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
- clickable?: boolean | undefined;
4
- loader?: boolean | undefined;
5
- tableData: TableTypes.Dynamic;
6
- }>, {
7
- clickable: boolean;
8
- loader: boolean;
9
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- handleClick: (v: any) => void;
11
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
12
- tableData?: unknown;
13
- clickable?: unknown;
14
- loader?: unknown;
15
- } & {
16
- tableData: TableTypes.Dynamic;
17
- clickable: boolean;
18
- loader: boolean;
19
- } & {}> & {
20
- onHandleClick?: ((v: any) => any) | undefined;
21
- }, {
22
- clickable: boolean;
23
- loader: boolean;
24
- }>;
25
- export default _default;
26
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
27
- type __VLS_TypePropsToRuntimeProps<T> = {
28
- [K in keyof T]-?: {} extends Pick<T, K> ? {
29
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
30
- } : {
31
- type: import('vue').PropType<T[K]>;
32
- required: true;
33
- };
34
- };
35
- type __VLS_WithDefaults<P, D> = {
36
- [K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
37
- default: D[K];
38
- } : P[K];
39
- };
@@ -1,18 +0,0 @@
1
- import type { ActionMenuItemCallback } from "../../composables/nav";
2
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
- items: ActionMenuItemCallback[];
4
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
5
- items?: unknown;
6
- } & {
7
- items: ActionMenuItemCallback[];
8
- } & {}>, {}>;
9
- export default _default;
10
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
11
- type __VLS_TypePropsToRuntimeProps<T> = {
12
- [K in keyof T]-?: {} extends Pick<T, K> ? {
13
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
14
- } : {
15
- type: import('vue').PropType<T[K]>;
16
- required: true;
17
- };
18
- };
@@ -1,22 +0,0 @@
1
- import type { ActionMenuEmit } from "../../composables/nav";
2
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
3
- items: ActionMenuEmit[];
4
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
- click: (v: string) => void;
6
- }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
7
- items?: unknown;
8
- } & {
9
- items: ActionMenuEmit[];
10
- } & {}> & {
11
- onClick?: ((v: string) => any) | undefined;
12
- }, {}>;
13
- export default _default;
14
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
15
- type __VLS_TypePropsToRuntimeProps<T> = {
16
- [K in keyof T]-?: {} extends Pick<T, K> ? {
17
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
18
- } : {
19
- type: import('vue').PropType<T[K]>;
20
- required: true;
21
- };
22
- };