muffin-admin 3.8.2 → 3.8.4

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/types.d.ts CHANGED
@@ -2,7 +2,7 @@ export type TProps = {
2
2
  [key: string]: any;
3
3
  };
4
4
  export type AdminAction = {
5
- view: ("show" | "edit" | "list" | "bulk")[];
5
+ view?: ("show" | "edit" | "list" | "bulk")[];
6
6
  id: string;
7
7
  label: string;
8
8
  title: string;
@@ -17,6 +17,7 @@ export type AdminField = [string, {
17
17
  export type AdminInput = [string, {
18
18
  required: boolean;
19
19
  source: string;
20
+ [key: string]: any;
20
21
  }];
21
22
  export type AdminShowLink = {
22
23
  label: string;
@@ -29,6 +30,13 @@ export type AdminShowProps = {
29
30
  links: [string, AdminShowLink][];
30
31
  edit?: boolean;
31
32
  };
33
+ export type AdminPayloadProps = {
34
+ active: boolean;
35
+ onClose: () => void;
36
+ onHandle: (payload?: any) => void;
37
+ title?: string;
38
+ schema?: AdminInput[];
39
+ };
32
40
  export type AdminResourceProps = {
33
41
  name: string;
34
42
  icon?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "3.8.2",
3
+ "version": "3.8.4",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -65,7 +65,7 @@ setupAdmin(["edit-toolbar"], MuffinEditToolbar)
65
65
  export function MuffinEditActions() {
66
66
  const { edit, actions: baseActions = [] } = useMuffinResourceOpts()
67
67
  if (!edit) return null
68
- const actions = baseActions.filter((a => a.view.includes("edit")))
68
+ const actions = baseActions.filter((a) => a.view?.includes("edit"))
69
69
  return (
70
70
  <>
71
71
  {actions.map((props, idx) => (
@@ -93,7 +93,7 @@ function MuffinListBulkActions() {
93
93
  actions: baseActions = [],
94
94
  list: { remove },
95
95
  } = useMuffinResourceOpts()
96
- const actions = baseActions.filter((a) => a.view.includes("bulk"))
96
+ const actions = baseActions.filter((a) => a.view?.includes("bulk"))
97
97
  return (
98
98
  <>
99
99
  {actions.map((props) => (
@@ -40,7 +40,7 @@ setupAdmin(["show-toolbar"], MuffinShowToolbar)
40
40
 
41
41
  export function MuffinShowActions() {
42
42
  const { actions: baseActions = [] } = useMuffinResourceOpts()
43
- const actions = baseActions.filter((a) => a.view.includes("show"))
43
+ const actions = baseActions.filter((a) => a.view?.includes("show"))
44
44
  return actions.map((props) => <ActionButton key={props.id} {...props} />)
45
45
  }
46
46
 
@@ -13,7 +13,7 @@ import { useState } from "react"
13
13
  import { buildRA } from "../buildRA"
14
14
  import { AdminModal, PayloadButtons, useConfirmation } from "../common"
15
15
  import { useAction } from "../hooks/useAction"
16
- import { AdminAction } from "../types"
16
+ import { AdminAction, AdminPayloadProps } from "../types"
17
17
  import { buildIcon, findBuilder } from "../utils"
18
18
 
19
19
  export type ActionPayloadProps = {
@@ -102,7 +102,7 @@ function ActionButtonBase({
102
102
  )
103
103
  }
104
104
 
105
- export function CommonPayload({ active, onClose, onHandle, schema, title }) {
105
+ export function CommonPayload({ active, onClose, onHandle, schema, title }: AdminPayloadProps) {
106
106
  schema[0][1] = { ...schema[0][1], autoFocus: true }
107
107
  const inputs = buildRA(schema)
108
108
  const translate = useTranslate()
package/src/types.ts CHANGED
@@ -3,7 +3,7 @@ export type TProps = {
3
3
  }
4
4
 
5
5
  export type AdminAction = {
6
- view: ("show" | "edit" | "list" | "bulk")[]
6
+ view?: ("show" | "edit" | "list" | "bulk")[]
7
7
  id: string
8
8
  label: string
9
9
  title: string
@@ -14,7 +14,7 @@ export type AdminAction = {
14
14
  }
15
15
 
16
16
  export type AdminField = [string, { source: string }]
17
- export type AdminInput = [string, { required: boolean; source: string }]
17
+ export type AdminInput = [string, { required: boolean; source: string; [key: string]: any }]
18
18
 
19
19
  export type AdminShowLink = {
20
20
  label: string
@@ -28,6 +28,14 @@ export type AdminShowProps = {
28
28
  edit?: boolean
29
29
  }
30
30
 
31
+ export type AdminPayloadProps = {
32
+ active: boolean
33
+ onClose: () => void
34
+ onHandle: (payload?: any) => void
35
+ title?: string
36
+ schema?: AdminInput[]
37
+ }
38
+
31
39
  export type AdminResourceProps = {
32
40
  name: string
33
41
  icon?: string
@@ -35,11 +43,11 @@ export type AdminResourceProps = {
35
43
  actions: AdminAction[]
36
44
  create: AdminInput[] | false
37
45
  edit:
38
- | {
39
- inputs: AdminInput[]
40
- remove?: boolean
41
- }
42
- | false
46
+ | {
47
+ inputs: AdminInput[]
48
+ remove?: boolean
49
+ }
50
+ | false
43
51
  list: {
44
52
  limit: number
45
53
  limitMax: number