dinocollab-core 2.1.35 → 2.1.36
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{inherits as r,createClass as e,objectSpread2 as t,classCallCheck as n,callSuper as o,defineProperty as i,regenerator as l}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as a}from"react/jsx-runtime";import
|
|
1
|
+
import{inherits as r,createClass as e,objectSpread2 as t,classCallCheck as n,callSuper as o,defineProperty as i,regenerator as l}from"../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as a}from"react/jsx-runtime";import u,{Component as s}from"react";import{Box as c,Tooltip as p,IconButton as d}from"@mui/material";import f from"@mui/icons-material/Edit";import m from"@mui/icons-material/Delete";import{mergeObjects as v}from"../utils/helpers.js";import"../utils/dayjs-config.js";import"../utils/query-param.js";import{MapTableBaseContext as h}from"./context.js";function g(g){var b=function(){function b(){var r;n(this,b);for(var e=arguments.length,s=new Array(e),c=0;c<e;c++)s[c]=arguments[c];return r=o(this,b,[].concat(s)),i(r,"getButtons",l().m(function r(e,n,o){var i,s,c,v,h,b,y,k,C,j,x,w,D,E,A,M,P,B;return l().w(function(r){for(;;)switch(r.n){case 0:if(!(C=null!==(i=null===(s=e.props)||void 0===s?void 0:s.before)&&void 0!==i?i:null==n?void 0:n.before)){r.n=1;break}return r.n=1,a(u.Fragment,{children:C(e.props.value,o)},"Before");case 1:if(j=null!==(c=null===(v=e.props)||void 0===v?void 0:v.formEdit)&&void 0!==c?c:null==n?void 0:n.formEdit,x=j?j(e.props.value,o):void 0,!j||!x){r.n=2;break}return w=n.buttonEditProps,D="function"==typeof w?w(e.props.value):w,r.n=2,a(p,{title:"Edit",arrow:!0,children:a("span",{children:a(d,t(t({color:"primary"},D),{},{onClick:function(r){var e;null==o||o.showModal(t({renderContent:function(){return x||a(u.Fragment,{})},sx:{display:"flex",justifyContent:"center",alignItems:"center"},backdropActivated:!0},null==g?void 0:g.buttonEditConfig)),null==D||null===(e=D.onClick)||void 0===e||e.call(D,r)},children:a(f,{fontSize:"small"})}))})},"Edit");case 2:if(E=null!==(h=null===(b=e.props)||void 0===b?void 0:b.formDelete)&&void 0!==h?h:null==n?void 0:n.formDelete,A=E?E(e.props.value,o):void 0,!E||!A){r.n=3;break}return M=n.buttonDeleteProps,P="function"==typeof M?M(e.props.value):M,r.n=3,a(p,{title:"Delete",arrow:!0,children:a("span",{children:a(d,t(t({color:"error"},P),{},{onClick:function(r){var e;null==o||o.showModal(t({renderContent:function(){return A||a(u.Fragment,{})},sx:{display:"flex",justifyContent:"center",alignItems:"center"},backdropActivated:!0},null==g?void 0:g.buttonDeleteConfig)),null==P||null===(e=P.onClick)||void 0===e||e.call(P,r)},children:a(m,{fontSize:"small"})}))})},"Delete");case 3:if(!(B=null!==(y=null===(k=e.props)||void 0===k?void 0:k.after)&&void 0!==y?y:null==n?void 0:n.after)){r.n=4;break}return r.n=4,a(u.Fragment,{children:B(e.props.value,o)},"After");case 4:return r.a(2)}},r)})),r}return r(b,s),e(b,[{key:"propsMerge",get:function(){return v(g,this.props)}},{key:"render",value:function(){var r=this;return h(function(e){return a(c,t(t({sx:{display:"flex",alignItems:"center",height:"100%"}},r.propsMerge.wrapProps),{},{children:Array.from(r.getButtons(r,r.propsMerge,e))}))})}}])}();return b}export{g as default};
|
|
2
2
|
//# sourceMappingURL=create.action-row.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.action-row.js","sources":["../../../src/table/create.action-row.tsx"],"sourcesContent":["import React, { Component, ComponentType } from 'react'\r\nimport { Box, BoxProps, IconButton, Tooltip } from '@mui/material'\r\nimport EditIcon from '@mui/icons-material/Edit'\r\nimport DeleteIcon from '@mui/icons-material/Delete'\r\nimport { mergeObjects } from '../utils'\r\nimport { GlobalModalState } from '../api-context'\r\nimport { ITableBaseContext, MapTableBaseContext } from './context'\r\n\r\nexport interface IActionRowProps<T> {\r\n value: T\r\n formEdit?: (value: T, tableContext: ITableBaseContext) => React.ReactNode\r\n formDelete?: (value: T, tableContext: ITableBaseContext) => React.ReactNode\r\n after?: (value: T, tableContext: ITableBaseContext) => React.ReactNode\r\n before?: (value: T, tableContext: ITableBaseContext) => React.ReactNode\r\n wrapProps?: BoxProps\r\n buttonEditConfig?: GlobalModalState\r\n buttonDeleteConfig?: GlobalModalState\r\n}\r\n\r\nfunction CreateActionRow<T>(params?: Omit<IActionRowProps<T>, 'value'>): ComponentType<IActionRowProps<T>> {\r\n class ActionRow extends Component<IActionRowProps<T>> {\r\n get propsMerge() {\r\n return mergeObjects<IActionRowProps<T>>(params, this.props)\r\n }\r\n\r\n getButtons = function* (that: ActionRow, thatProps: Omit<IActionRowProps<T>, 'value'>, tableContext: ITableBaseContext) {\r\n const beforeFunc = that.props?.before ?? thatProps?.before\r\n if (beforeFunc) {\r\n yield <React.Fragment key='Before'>{beforeFunc(that.props.value, tableContext)}</React.Fragment>\r\n }\r\n const editFunc = that.props?.formEdit ?? thatProps?.formEdit\r\n const editContent = editFunc ? editFunc(that.props.value, tableContext) : undefined\r\n if (editFunc && !!editContent) {\r\n yield (\r\n <Tooltip title='Edit' arrow key='Edit'>\r\n <IconButton\r\n
|
|
1
|
+
{"version":3,"file":"create.action-row.js","sources":["../../../src/table/create.action-row.tsx"],"sourcesContent":["import React, { Component, ComponentType } from 'react'\r\nimport { Box, BoxProps, IconButton, IconButtonProps, Tooltip } from '@mui/material'\r\nimport EditIcon from '@mui/icons-material/Edit'\r\nimport DeleteIcon from '@mui/icons-material/Delete'\r\nimport { mergeObjects } from '../utils'\r\nimport { GlobalModalState } from '../api-context'\r\nimport { ITableBaseContext, MapTableBaseContext } from './context'\r\n\r\nexport interface IActionRowProps<T> {\r\n value: T\r\n formEdit?: (value: T, tableContext: ITableBaseContext) => React.ReactNode\r\n formDelete?: (value: T, tableContext: ITableBaseContext) => React.ReactNode\r\n after?: (value: T, tableContext: ITableBaseContext) => React.ReactNode\r\n before?: (value: T, tableContext: ITableBaseContext) => React.ReactNode\r\n wrapProps?: BoxProps\r\n buttonEditProps?: IconButtonProps | ((value: T) => IconButtonProps)\r\n buttonDeleteProps?: IconButtonProps | ((value: T) => IconButtonProps)\r\n buttonEditConfig?: GlobalModalState\r\n buttonDeleteConfig?: GlobalModalState\r\n}\r\n\r\nfunction CreateActionRow<T>(params?: Omit<IActionRowProps<T>, 'value'>): ComponentType<IActionRowProps<T>> {\r\n class ActionRow extends Component<IActionRowProps<T>> {\r\n get propsMerge() {\r\n return mergeObjects<IActionRowProps<T>>(params, this.props)\r\n }\r\n\r\n getButtons = function* (that: ActionRow, thatProps: Omit<IActionRowProps<T>, 'value'>, tableContext: ITableBaseContext) {\r\n const beforeFunc = that.props?.before ?? thatProps?.before\r\n if (beforeFunc) {\r\n yield <React.Fragment key='Before'>{beforeFunc(that.props.value, tableContext)}</React.Fragment>\r\n }\r\n const editFunc = that.props?.formEdit ?? thatProps?.formEdit\r\n const editContent = editFunc ? editFunc(that.props.value, tableContext) : undefined\r\n if (editFunc && !!editContent) {\r\n const { buttonEditProps } = thatProps\r\n const p = typeof buttonEditProps === 'function' ? buttonEditProps(that.props.value) : buttonEditProps\r\n yield (\r\n <Tooltip title='Edit' arrow key='Edit'>\r\n <span>\r\n <IconButton\r\n color='primary'\r\n {...p}\r\n onClick={(e) => {\r\n tableContext?.showModal({\r\n renderContent: () => editContent || <React.Fragment />,\r\n sx: { display: 'flex', justifyContent: 'center', alignItems: 'center' },\r\n backdropActivated: true,\r\n ...params?.buttonEditConfig\r\n })\r\n p?.onClick?.(e)\r\n }}\r\n >\r\n <EditIcon fontSize='small' />\r\n </IconButton>\r\n </span>\r\n </Tooltip>\r\n )\r\n }\r\n const deleteFunc = that.props?.formDelete ?? thatProps?.formDelete\r\n const deleteContent = deleteFunc ? deleteFunc(that.props.value, tableContext) : undefined\r\n if (deleteFunc && !!deleteContent) {\r\n const { buttonDeleteProps } = thatProps\r\n const p = typeof buttonDeleteProps === 'function' ? buttonDeleteProps(that.props.value) : buttonDeleteProps\r\n yield (\r\n <Tooltip title='Delete' arrow key='Delete'>\r\n <span>\r\n <IconButton\r\n color='error'\r\n {...p}\r\n onClick={(e) => {\r\n tableContext?.showModal({\r\n renderContent: () => deleteContent || <React.Fragment />,\r\n sx: { display: 'flex', justifyContent: 'center', alignItems: 'center' },\r\n backdropActivated: true,\r\n ...params?.buttonDeleteConfig\r\n })\r\n p?.onClick?.(e)\r\n }}\r\n >\r\n <DeleteIcon fontSize='small' />\r\n </IconButton>\r\n </span>\r\n </Tooltip>\r\n )\r\n }\r\n const afterFunc = that.props?.after ?? thatProps?.after\r\n if (afterFunc) {\r\n yield <React.Fragment key='After'>{afterFunc(that.props.value, tableContext)}</React.Fragment>\r\n }\r\n }\r\n\r\n render() {\r\n return MapTableBaseContext((context) => (\r\n <Box sx={{ display: 'flex', alignItems: 'center', height: '100%' }} {...this.propsMerge.wrapProps}>\r\n {Array.from(this.getButtons(this, this.propsMerge, context))}\r\n </Box>\r\n ))\r\n }\r\n }\r\n\r\n return ActionRow\r\n}\r\nexport default CreateActionRow\r\n"],"names":["CreateActionRow","params","ActionRow","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","this","concat","_defineProperty","_regenerator","m","_callee","that","thatProps","tableContext","_that$props$before","_that$props","_that$props$formEdit","_that$props2","_that$props$formDelet","_that$props3","_that$props$after","_that$props4","beforeFunc","editFunc","editContent","buttonEditProps","p","deleteFunc","deleteContent","buttonDeleteProps","_p","afterFunc","w","_context","n","props","before","_jsx","React","Fragment","children","value","formEdit","undefined","Tooltip","title","arrow","IconButton","_objectSpread","color","onClick","e","_p$onClick","showModal","renderContent","sx","display","justifyContent","alignItems","backdropActivated","buttonEditConfig","call","EditIcon","fontSize","formDelete","_p$onClick2","buttonDeleteConfig","DeleteIcon","after","a","_inherits","Component","_createClass","key","get","mergeObjects","_this2","MapTableBaseContext","context","Box","height","propsMerge","wrapProps","from","getButtons"],"mappings":"0jBAqBA,SA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eAAgB,SAAUC,WAAY,UAC7DC,mBAAmB,GAChBjE,aAAM,EAANA,EAAQwE,qBAEbxC,SAAU,QAATuC,EAADvC,EAAGwB,eAAO,IAAAe,GAAVA,EAAAJ,KAAAnC,EAAayB,EACd,EAEDX,SAAAH,EAAC8B,EAAU,CAACJ,SAAS,gBAfO,UAmBnC,KAAA,EAEoD,KAAjDhC,EAA6B,QAApBX,EAAaC,QAAbA,EAAGV,EAAKwB,aAALd,IAAUA,OAAVA,EAAAA,EAAY+C,aAAK,IAAAhD,EAAAA,EAAIR,aAAS,EAATA,EAAWwD,OACrC,CAAAnC,EAAAC,EAAA,EAAA,KAAA,CACX,OADWD,EAAAC,EAAA,EACLG,EAACC,EAAMC,SAAsB,CAAAC,SAAAT,EAAUpB,EAAKwB,MAAMM,MAAO5B,IAArC,SAAoE,KAAA,EAAA,OAAAoB,EAAAoC,EAAA,GAAA,EAAA3D,MAEjGd,CAAA,CAAA,OAAA0E,EAAA3E,EApEqB4E,GAoErBC,EAAA7E,EAAA,CAAA,CAAA8E,IAAA,aAAAC,IAnED,WACE,OAAOC,EAAiCjF,EAAQW,KAAK8B,MACvD,GAAC,CAAAsC,IAAA,SAAAhC,MAmED,WAAM,IAAAmC,EAAAvE,KACJ,OAAOwE,EAAoB,SAACC,GAAO,OACjCzC,EAAC0C,EAAG/B,EAAAA,EAAA,CAACO,GAAI,CAAEC,QAAS,OAAQE,WAAY,SAAUsB,OAAQ,SAAcJ,EAAKK,WAAWC,WAAS,CAAA,EAAA,CAAA1C,SAC9FtC,MAAMiF,KAAKP,EAAKQ,WAAWR,EAAMA,EAAKK,WAAYH,MAC/C,EAEV,IAAC,IAGH,OAAOnF,CACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ComponentType } from 'react';
|
|
2
|
-
import { BoxProps } from '@mui/material';
|
|
2
|
+
import { BoxProps, IconButtonProps } from '@mui/material';
|
|
3
3
|
import { GlobalModalState } from '../api-context';
|
|
4
4
|
import { ITableBaseContext } from './context';
|
|
5
5
|
export interface IActionRowProps<T> {
|
|
@@ -9,6 +9,8 @@ export interface IActionRowProps<T> {
|
|
|
9
9
|
after?: (value: T, tableContext: ITableBaseContext) => React.ReactNode;
|
|
10
10
|
before?: (value: T, tableContext: ITableBaseContext) => React.ReactNode;
|
|
11
11
|
wrapProps?: BoxProps;
|
|
12
|
+
buttonEditProps?: IconButtonProps | ((value: T) => IconButtonProps);
|
|
13
|
+
buttonDeleteProps?: IconButtonProps | ((value: T) => IconButtonProps);
|
|
12
14
|
buttonEditConfig?: GlobalModalState;
|
|
13
15
|
buttonDeleteConfig?: GlobalModalState;
|
|
14
16
|
}
|