dinocollab-core 1.0.15 → 1.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.form-grid-layout.js","sources":["../../src/form/create.form-grid-layout.tsx"],"sourcesContent":["import React, { Component, ComponentType, Fragment } from 'react'\r\nimport { BoxProps, Grid, RegularBreakpoints, SxProps, Theme } from '@mui/material'\r\nimport { IFormBase, IFormInputBase } from './types'\r\nimport { mapGlobalModalContext } from '../api-context'\r\nimport { ContentWrap, CreateFormBottomBar } from './create.form-grid-layout.units'\r\nimport FormValidator from './validator'\r\nimport CreateInput from './create.input'\r\nimport CreateFormBase from './create.form-base'\r\n\r\nexport interface IFormGridLayoutConfig<T> {\r\n key: keyof T\r\n label?: string\r\n placeholder?: string\r\n reponsives?: RegularBreakpoints\r\n defaultValue?: any\r\n inputElement?: React.ComponentType<IFormInputBase<T>>\r\n}\r\n\r\nexport type SubmitMappingEvent<T> = (value: Partial<T>, oldValue?: T) => Partial<T>\r\n\r\nexport interface IFormGridLayoutSlots<T> {\r\n action?: React.ComponentType<IFormBase<T>>\r\n actionBefore?: JSX.Element\r\n contentBefore?: JSX.Element\r\n contentAfter?: JSX.Element\r\n inputVisibility?: Partial<Record<keyof T, boolean>>\r\n inputDisabled?: Partial<Record<keyof T, boolean>>\r\n closeState?: { Success?: boolean; Fail?: boolean }\r\n contentProps?: BoxProps\r\n submitMapping?: SubmitMappingEvent<T>\r\n}\r\n\r\nexport interface IFormGridLayoutParams<T> extends IFormGridLayoutSlots<T> {\r\n configs: IFormGridLayoutConfig<T>[]\r\n validate: FormValidator<Partial<T>>\r\n}\r\n\r\nexport interface IFormGridLayoutProps<T> {\r\n data?: T\r\n onSubmit: (value: Partial<T>, signal?: AbortSignal) => Promise<void>\r\n onError?: (error: any) => void\r\n onClose?: () => void\r\n sx?: SxProps<Theme>\r\n slots?: IFormGridLayoutSlots<T>\r\n}\r\n\r\nexport interface IFormGridLayoutState {\r\n loadding?: boolean\r\n}\r\n\r\nconst CreateFormGridLayout = function <T>(params: IFormGridLayoutParams<T>): ComponentType<IFormGridLayoutProps<T>> {\r\n const FormBaseInstance = CreateFormBase<T>()\r\n const BottomBarInstance = CreateFormBottomBar<T>()\r\n const InputBaseInstance = CreateInput<T>({ maxLength: 250 })\r\n\r\n class FormGridLayout extends Component<IFormGridLayoutProps<T>, IFormGridLayoutState> {\r\n private abortController?: AbortController\r\n constructor(props: IFormGridLayoutProps<T>) {\r\n super(props)\r\n this.state = { loadding: false }\r\n }\r\n\r\n get configMerged() {\r\n return {\r\n inputVisibility: this.props.slots?.inputVisibility ?? params.inputVisibility,\r\n inputDisabled: this.props.slots?.inputDisabled ?? params.inputDisabled\r\n }\r\n }\r\n\r\n render() {\r\n const BottomBar = params?.action ?? this.props.slots?.action ?? BottomBarInstance\r\n return mapGlobalModalContext(({ close }) => (\r\n <FormBaseInstance.Form validate={params.validate} onSubmit={(v) => this.onSubmit(v, close)} sx={this.getSxProps()}>\r\n {this.renderContent()}\r\n {FormBaseInstance.contextMapping((context) => (\r\n <BottomBar data={this.props.data} onBlur={context.onBlur} messageErrors={context.messageErrors} before={this.props.slots?.actionBefore} />\r\n ))}\r\n </FormBaseInstance.Form>\r\n ))\r\n }\r\n\r\n renderContent = () => {\r\n const { slots } = this.props\r\n return (\r\n <ContentWrap {...this.props?.slots?.contentProps}>\r\n {slots?.contentBefore && slots?.contentBefore}\r\n {params?.contentBefore}\r\n <Grid container spacing={2}>\r\n {params.configs.map((config, index) => {\r\n const visibility: boolean | undefined = this.configMerged.inputVisibility?.[config.key] ? true : undefined\r\n if (visibility) return <Fragment key={config.key.toString() + index} />\r\n return (\r\n <Fragment key={config.key.toString() + index}>\r\n <Grid item xs={12} {...config.reponsives}>\r\n {this.renderFormFieldElement(config)}\r\n </Grid>\r\n </Fragment>\r\n )\r\n })}\r\n </Grid>\r\n {params?.contentAfter}\r\n {slots?.contentAfter && slots?.contentAfter}\r\n </ContentWrap>\r\n )\r\n }\r\n\r\n renderFormFieldElement = (config: IFormGridLayoutConfig<T>) => {\r\n const { slots, ...otherProps } = this.props\r\n const ElementComponent = config.inputElement ?? InputBaseInstance\r\n const dValue = otherProps.data?.[config.key] ?? config?.defaultValue\r\n const disabled: boolean | undefined = this.configMerged.inputDisabled?.[config.key] ? true : undefined\r\n return FormBaseInstance.contextMapping((context) => (\r\n <ElementComponent\r\n data={this.props.data}\r\n onBlur={context.onBlur}\r\n messageErrors={context.messageErrors}\r\n name={config.key}\r\n label={config.label}\r\n placeholder={config.placeholder}\r\n disabled={disabled}\r\n defaultValue={dValue}\r\n />\r\n ))\r\n }\r\n\r\n loading = () => this.setState({ loadding: true })\r\n\r\n unloading = () => this.setState({ loadding: false })\r\n\r\n componentWillUnmount(): void {\r\n this.abortController?.abort()\r\n }\r\n\r\n onSubmit = async (value: Partial<T>, close?: () => void) => {\r\n const { slots } = this.props\r\n const mapping = this.props.slots?.submitMapping ?? params.submitMapping ?? this.submitMapping\r\n const data = mapping(value, this.props.data)\r\n try {\r\n this.loading()\r\n this.abortController?.abort()\r\n this.abortController = new AbortController()\r\n await this.props.onSubmit(data, this.abortController.signal)\r\n if (!slots?.closeState || slots.closeState.Success !== false) {\r\n close && close()\r\n this.props.onClose && this.props.onClose()\r\n }\r\n } catch (error) {\r\n if (slots?.closeState && slots.closeState.Fail === true) {\r\n close && close()\r\n this.props.onClose && this.props.onClose()\r\n }\r\n if (this.props.onError) this.props.onError(error)\r\n } finally {\r\n this.unloading()\r\n }\r\n }\r\n\r\n submitMapping: SubmitMappingEvent<T> = (value) => value\r\n\r\n getSxProps = (): SxProps<Theme> => {\r\n const isLoading = this.state.loadding\r\n return { ...this.props.sx, opacity: isLoading ? 0.7 : 1, pointerEvents: isLoading ? 'none' : 'auto' }\r\n }\r\n }\r\n return FormGridLayout\r\n}\r\n\r\nexport default CreateFormGridLayout\r\n"],"names":["CreateFormGridLayout","params","FormBaseInstance","CreateFormBase","BottomBarInstance","CreateFormBottomBar","InputBaseInstance","CreateInput","maxLength","FormGridLayout","props","_this","_classCallCheck","_callSuper","_defineProperty","_this$props","slots","_jsxs","ContentWrap","_objectSpread","contentProps","children","contentBefore","_jsx","Grid","container","spacing","configs","map","config","index","_this$configMerged$in","visibility","configMerged","inputVisibility","key","undefined","Fragment","item","xs","reponsives","renderFormFieldElement","toString","contentAfter","_config$inputElement","_otherProps$data$conf","_otherProps$data","_this$configMerged$in2","_this$props2","otherProps","_objectWithoutProperties","_excluded","ElementComponent","inputElement","dValue","data","defaultValue","disabled","inputDisabled","contextMapping","context","onBlur","messageErrors","name","label","placeholder","setState","loadding","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","value","close","_ref2","_this$props$slots$sub","_this$props$slots","mapping","_this$abortController","wrap","_context","prev","next","submitMapping","loading","abortController","abort","AbortController","onSubmit","signal","closeState","Success","onClose","t0","Fail","onError","unloading","finish","stop","_x","_x2","apply","this","arguments","isLoading","state","sx","opacity","pointerEvents","_inherits","Component","_createClass","get","_this$props$slots$inp","_this$props$slots2","_this$props$slots$inp2","_this$props$slots3","_ref3","_params$action","_this$props$slots4","_this2","BottomBar","action","mapGlobalModalContext","_ref4","Form","validate","v","getSxProps","renderContent","_this2$props$slots","before","actionBefore","_this$abortController2"],"mappings":"urBAkDMA,EAAuB,SAAaC,GACxC,IAAMC,EAAmBC,IACnBC,EAAoBC,IACpBC,EAAoBC,EAAe,CAAEC,UAAW,MAEhDC,aAEJ,SAAAA,EAAYC,GAA8B,IAAAC,EAER,OAFQC,OAAAH,GACxCE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAAA,iBAuBE,WAAK,IAAAI,EACXC,EAAUL,EAAKD,MAAfM,MACR,OACEC,EAACC,EAAWC,EAAAA,EAAAJ,CAAAA,UAAAA,EAAKJ,EAAKD,aAAK,IAAAK,GAAO,QAAPA,EAAVA,EAAYC,aAAK,IAAAD,OAAA,EAAjBA,EA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AAAlB,KACEmB,EAAsDJ,QAA7CA,EAAiBC,QAAjBA,EAAGtH,aAAM,EAANA,EAAQ0H,kBAAMJ,EAAAA,UAAAC,EAAIjB,KAAK7F,MAAMM,aAAK,IAAAwG,OAAA,EAAhBA,EAAkBG,cAAML,IAAAA,EAAAA,EAAIlH,EAChE,OAAOwH,GAAsB,SAAAC,GAAA,IAAGnD,EAAKmD,EAALnD,MAAK,OACnCzD,EAACf,EAAiB4H,KAAK,CAAAC,SAAU9H,EAAO8H,SAAUtC,SAAU,SAACuC,GAAC,OAAKP,EAAKhC,SAASuC,EAAGtD,EAAM,EAAEiC,GAAIc,EAAKQ,aAAY5G,SAAA,CAC9GoG,EAAKS,gBACLhI,EAAiByD,gBAAe,SAACC,GAAO,IAAAuE,EAAA,OACvC5G,EAACmG,EAAU,CAAAnE,KAAMkE,EAAK/G,MAAM6C,KAAMM,OAAQD,EAAQC,OAAQC,cAAeF,EAAQE,cAAesE,OAAwBD,QAAlBA,EAAEV,EAAK/G,MAAMM,aAAXmH,IAAgBA,OAAhBA,EAAAA,EAAkBE,cAAgB,MAEtH,GAE5B,GAAC,CAAAlG,IAAA,uBAAAsC,MAkDD,WAAoB,IAAA6D,EACE,QAApBA,EAAI/B,KAACjB,uBAAe,IAAAgD,GAApBA,EAAsB/C,OACxB,IAAC,IAiCH,OAAO9E,CACT"}
|
|
1
|
+
{"version":3,"file":"create.form-grid-layout.js","sources":["../../src/form/create.form-grid-layout.tsx"],"sourcesContent":["import React, { Component, ComponentType, Fragment } from 'react'\r\nimport { BoxProps, Grid, RegularBreakpoints, SxProps, Theme } from '@mui/material'\r\nimport { IFormBase, IFormInputBase } from './types'\r\nimport { mapGlobalModalContext } from '../api-context'\r\nimport { ContentWrap, CreateFormBottomBar } from './create.form-grid-layout.units'\r\nimport FormValidator from './validator'\r\nimport CreateInput from './create.input'\r\nimport CreateFormBase from './create.form-base'\r\n\r\nexport interface IFormGridLayoutConfig<T> {\r\n key: keyof T\r\n label?: string\r\n placeholder?: string\r\n reponsives?: RegularBreakpoints\r\n defaultValue?: any\r\n inputElement?: React.ComponentType<IFormInputBase<T>>\r\n}\r\n\r\nexport type SubmitMappingEvent<T> = (value: Partial<T>, oldValue?: T) => Partial<T>\r\n\r\nexport interface IFormGridLayoutSlots<T> {\r\n action?: React.ComponentType<IFormBase<T>>\r\n actionBefore?: JSX.Element\r\n contentBefore?: JSX.Element\r\n contentAfter?: JSX.Element\r\n inputVisibility?: Partial<Record<keyof T, boolean>>\r\n // inputVisibilityGetter?: (value: Partial<T>) => Partial<Record<keyof T, boolean>>\r\n inputDisabled?: Partial<Record<keyof T, boolean>>\r\n closeState?: { Success?: boolean; Fail?: boolean }\r\n contentProps?: BoxProps\r\n submitMapping?: SubmitMappingEvent<T>\r\n}\r\n\r\nexport interface IFormGridLayoutParams<T> extends IFormGridLayoutSlots<T> {\r\n configs: IFormGridLayoutConfig<T>[]\r\n validate: FormValidator<Partial<T>>\r\n}\r\n\r\nexport interface IFormGridLayoutProps<T> {\r\n data?: T\r\n onSubmit: (value: Partial<T>, signal?: AbortSignal) => Promise<void>\r\n onError?: (error: any) => void\r\n onClose?: () => void\r\n sx?: SxProps<Theme>\r\n slots?: IFormGridLayoutSlots<T>\r\n}\r\n\r\nexport interface IFormGridLayoutState {\r\n loadding?: boolean\r\n}\r\n\r\nconst CreateFormGridLayout = function <T>(params: IFormGridLayoutParams<T>): ComponentType<IFormGridLayoutProps<T>> {\r\n const FormBaseInstance = CreateFormBase<T>()\r\n const BottomBarInstance = CreateFormBottomBar<T>()\r\n const InputBaseInstance = CreateInput<T>({ maxLength: 250 })\r\n\r\n class FormGridLayout extends Component<IFormGridLayoutProps<T>, IFormGridLayoutState> {\r\n private abortController?: AbortController\r\n constructor(props: IFormGridLayoutProps<T>) {\r\n super(props)\r\n this.state = { loadding: false }\r\n }\r\n\r\n get configMerged() {\r\n return {\r\n inputVisibility: this.props.slots?.inputVisibility ?? params.inputVisibility,\r\n inputDisabled: this.props.slots?.inputDisabled ?? params.inputDisabled\r\n }\r\n }\r\n\r\n render() {\r\n const BottomBar = params?.action ?? this.props.slots?.action ?? BottomBarInstance\r\n return mapGlobalModalContext(({ close }) => (\r\n <FormBaseInstance.Form validate={params.validate} onSubmit={(v) => this.onSubmit(v, close)} sx={this.getSxProps()}>\r\n {this.renderContent()}\r\n {FormBaseInstance.contextMapping((context) => (\r\n <BottomBar data={this.props.data} onBlur={context.onBlur} messageErrors={context.messageErrors} before={this.props.slots?.actionBefore} />\r\n ))}\r\n </FormBaseInstance.Form>\r\n ))\r\n }\r\n\r\n renderContent = () => {\r\n const { slots } = this.props\r\n return (\r\n <ContentWrap {...this.props?.slots?.contentProps}>\r\n {slots?.contentBefore && slots?.contentBefore}\r\n {params?.contentBefore}\r\n <Grid container spacing={2}>\r\n {params.configs.map((config, index) => {\r\n const visibility: boolean | undefined = this.configMerged.inputVisibility?.[config.key] ? true : undefined\r\n if (visibility) return <Fragment key={config.key.toString() + index} />\r\n return (\r\n <Fragment key={config.key.toString() + index}>\r\n <Grid item xs={12} {...config.reponsives}>\r\n {this.renderFormFieldElement(config)}\r\n </Grid>\r\n </Fragment>\r\n )\r\n })}\r\n </Grid>\r\n {params?.contentAfter}\r\n {slots?.contentAfter && slots?.contentAfter}\r\n </ContentWrap>\r\n )\r\n }\r\n\r\n renderFormFieldElement = (config: IFormGridLayoutConfig<T>) => {\r\n const { slots, ...otherProps } = this.props\r\n const ElementComponent = config.inputElement ?? InputBaseInstance\r\n const dValue = otherProps.data?.[config.key] ?? config?.defaultValue\r\n const disabled: boolean | undefined = this.configMerged.inputDisabled?.[config.key] ? true : undefined\r\n return FormBaseInstance.contextMapping((context) => (\r\n <ElementComponent\r\n data={this.props.data}\r\n onBlur={context.onBlur}\r\n messageErrors={context.messageErrors}\r\n name={config.key}\r\n label={config.label}\r\n placeholder={config.placeholder}\r\n disabled={disabled}\r\n defaultValue={dValue}\r\n />\r\n ))\r\n }\r\n\r\n loading = () => this.setState({ loadding: true })\r\n\r\n unloading = () => this.setState({ loadding: false })\r\n\r\n componentWillUnmount(): void {\r\n this.abortController?.abort()\r\n }\r\n\r\n onSubmit = async (value: Partial<T>, close?: () => void) => {\r\n const { slots } = this.props\r\n const mapping = this.props.slots?.submitMapping ?? params.submitMapping ?? this.submitMapping\r\n const data = mapping(value, this.props.data)\r\n try {\r\n this.loading()\r\n this.abortController?.abort()\r\n this.abortController = new AbortController()\r\n await this.props.onSubmit(data, this.abortController.signal)\r\n if (!slots?.closeState || slots.closeState.Success !== false) {\r\n close && close()\r\n this.props.onClose && this.props.onClose()\r\n }\r\n } catch (error) {\r\n if (slots?.closeState && slots.closeState.Fail === true) {\r\n close && close()\r\n this.props.onClose && this.props.onClose()\r\n }\r\n if (this.props.onError) this.props.onError(error)\r\n } finally {\r\n this.unloading()\r\n }\r\n }\r\n\r\n submitMapping: SubmitMappingEvent<T> = (value) => value\r\n\r\n getSxProps = (): SxProps<Theme> => {\r\n const isLoading = this.state.loadding\r\n return { ...this.props.sx, opacity: isLoading ? 0.7 : 1, pointerEvents: isLoading ? 'none' : 'auto' }\r\n }\r\n }\r\n return FormGridLayout\r\n}\r\n\r\nexport default CreateFormGridLayout\r\n"],"names":["CreateFormGridLayout","params","FormBaseInstance","CreateFormBase","BottomBarInstance","CreateFormBottomBar","InputBaseInstance","CreateInput","maxLength","FormGridLayout","props","_this","_classCallCheck","_callSuper","_defineProperty","_this$props","slots","_jsxs","ContentWrap","_objectSpread","contentProps","children","contentBefore","_jsx","Grid","container","spacing","configs","map","config","index","_this$configMerged$in","visibility","configMerged","inputVisibility","key","undefined","Fragment","item","xs","reponsives","renderFormFieldElement","toString","contentAfter","_config$inputElement","_otherProps$data$conf","_otherProps$data","_this$configMerged$in2","_this$props2","otherProps","_objectWithoutProperties","_excluded","ElementComponent","inputElement","dValue","data","defaultValue","disabled","inputDisabled","contextMapping","context","onBlur","messageErrors","name","label","placeholder","setState","loadding","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","value","close","_ref2","_this$props$slots$sub","_this$props$slots","mapping","_this$abortController","wrap","_context","prev","next","submitMapping","loading","abortController","abort","AbortController","onSubmit","signal","closeState","Success","onClose","t0","Fail","onError","unloading","finish","stop","_x","_x2","apply","this","arguments","isLoading","state","sx","opacity","pointerEvents","_inherits","Component","_createClass","get","_this$props$slots$inp","_this$props$slots2","_this$props$slots$inp2","_this$props$slots3","_ref3","_params$action","_this$props$slots4","_this2","BottomBar","action","mapGlobalModalContext","_ref4","Form","validate","v","getSxProps","renderContent","_this2$props$slots","before","actionBefore","_this$abortController2"],"mappings":"urBAmDMA,EAAuB,SAAaC,GACxC,IAAMC,EAAmBC,IACnBC,EAAoBC,IACpBC,EAAoBC,EAAe,CAAEC,UAAW,MAEhDC,aAEJ,SAAAA,EAAYC,GAA8B,IAAAC,EAER,OAFQC,OAAAH,GACxCE,EAAAE,EAAAJ,KAAAA,GAAMC,IAAMI,EAAAH,EAAA,iBAuBE,WAAK,IAAAI,EACXC,EAAUL,EAAKD,MAAfM,MACR,OACEC,EAACC,EAAWC,EAAAA,EAAAJ,CAAAA,UAAAA,EAAKJ,EAAKD,aAAK,IAAAK,GAAO,QAAPA,EAAVA,EAAYC,aAAK,IAAAD,OAAA,EAAjBA,EAAmBK,cAAY,CAAA,EAAA,CAC7CC,SAAA,EAAAL,aAAAA,EAAAA,EAAOM,iBAAiBN,aAAK,EAALA,EAAOM,eAC/BrB,aAAM,EAANA,EAAQqB,cACTC,EAACC,EAAK,CAAAC,aAAUC,QAAS,EACtBL,SAAApB,EAAO0B,QAAQC,KAAI,SAACC,EAAQC,GAAS,IAAAC,EAC9BC,IAAmE,QAAjCD,EAAApB,EAAKsB,aAAaC,uBAAlBH,IAAiCA,IAAjCA,EAAoCF,EAAOM,YAAcC,EACjG,OAAuBb,EAACc,EAApBL,EAAkC,CAAA,EAE3B,CAAAX,SACPE,EAACC,EAAIL,EAAAA,EAAA,CAACmB,MAAI,EAACC,GAAI,IAAQV,EAAOW,YAAU,GAAA,CAA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O,IAAAuE,EAAA,OACvC5G,EAACmG,EAAU,CAAAnE,KAAMkE,EAAK/G,MAAM6C,KAAMM,OAAQD,EAAQC,OAAQC,cAAeF,EAAQE,cAAesE,OAAwBD,QAAlBA,EAAEV,EAAK/G,MAAMM,aAAXmH,IAAgBA,OAAhBA,EAAAA,EAAkBE,cAAgB,MAEtH,GAE5B,GAAC,CAAAlG,IAAA,uBAAAsC,MAkDD,WAAoB,IAAA6D,EACE,QAApBA,EAAI/B,KAACjB,uBAAe,IAAAgD,GAApBA,EAAsB/C,OACxB,IAAC,IAiCH,OAAO9E,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{inherits as r,createClass as e,classCallCheck as i,callSuper as o,defineProperty as t,objectSpread2 as n}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as l,Fragment as a,jsxs as s}from"react/jsx-runtime";import{Component as p}from"react";import{styled as
|
|
1
|
+
import{inherits as r,createClass as e,classCallCheck as i,callSuper as o,defineProperty as t,objectSpread2 as n}from"../_virtual/_rollupPluginBabelHelpers.js";import{jsx as l,Fragment as a,jsxs as s}from"react/jsx-runtime";import{Component as p}from"react";import{styled as m,Box as c,colors as u,IconButton as d,List as f,ListItem as h,ListItemButton as v,ListItemIcon as b,ListItemText as g}from"@mui/material";import C from"@mui/icons-material/Edit";import x from"@mui/icons-material/MoreVert";import k from"@mui/icons-material/DeleteOutline";import"../api-context/alert-global.js";import"../api-context/drawer-global.js";import{mapGlobalModalContext as I}from"../api-context/global-modal.js";import y from"../api-context/popover-global.js";var A={Edit:l(C,{fontSize:"small",color:"primary"}),Delete:l(k,{fontSize:"small",color:"error"})};function E(){var m=function(){function m(){var r;i(this,m);for(var e=arguments.length,p=new Array(e),c=0;c<e;c++)p[c]=arguments[c];return r=o(this,m,[].concat(p)),t(r,"isVisible",(function(){return!!r.props.formEdit||!!r.props.formDelete})),t(r,"renderItems",(function(e){return e?(Array.isArray(e)?e:[e]).map((function(e,i){var o=e.name+i,t=e.override;if(t)return l(t,{onClose:y.Api.close},o);var a=e.listItemPropsGetter?e.listItemPropsGetter(r.props.value):e.listItemProps;return l(h,n(n({disablePadding:!0,sx:{minWidth:"170px"},onClick:function(i){!1!==e.closableOnClick&&y.Api.close(),e.onClick&&e.onClick(i,r.props.value)}},a),{},{children:s(v,{children:[l(b,{children:e.icon}),l(g,{primary:e.name})]})}),o)})):l(a,{})})),t(r,"renderItemWithForm",(function(e,i,o){return i?I((function(t){return l(h,{disablePadding:!0,sx:{minWidth:"170px"},onClick:function(){y.Api.close(),t.show(n({renderContent:function(){return i(r.props.value)}},o))},children:s(v,{children:[l(b,{children:A[e]}),l(g,{primary:e})]})})})):l(a,{})})),r}return r(m,p),e(m,[{key:"render",value:function(){var r=this;return this.isVisible()?l(P,{children:l(d,{size:"small",onClick:function(e){var i,o,t;y.Api.open({anchorEl:e.currentTarget,popoverProps:{anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"}},content:s(f,{children:[r.renderItems(null===(i=r.props.menuList)||void 0===i?void 0:i.before),r.renderItemWithForm("Edit",r.props.formEdit,r.props.buttonEditConfig),r.renderItemWithForm("Delete",r.props.formDelete,null!==(o=r.props.buttonEditConfig)&&void 0!==o?o:{backdropActivated:!0}),r.renderItems(null===(t=r.props.menuList)||void 0===t?void 0:t.after)]})})},children:l(x,{fontSize:"small"})})}):l(a,{})}}])}();return m}var P=m(c)({background:u.common.white,borderRadius:"6px","& > .MuiButtonBase-root":{borderRadius:"6px"}});export{E as CreateTableGridItemActions};
|
|
2
2
|
//# sourceMappingURL=item-actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-actions.js","sources":["../../src/table-grid/item-actions.tsx"],"sourcesContent":["import React, { Component, ComponentType, ReactNode } from 'react'\r\nimport { Box, colors, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemProps, ListItemText, styled } from '@mui/material'\r\nimport EditIcon from '@mui/icons-material/Edit'\r\nimport MoreVertIcon from '@mui/icons-material/MoreVert'\r\nimport DeleteOutlineIcon from '@mui/icons-material/DeleteOutline'\r\nimport { ClosePopover, GlobalModalState, mapGlobalModalContext, PopoverGlobal } from '../api-context'\r\n\r\nexport type ITableGridItemActionType = 'Edit' | 'Delete'\r\n\r\nconst mapIcons: { [key in ITableGridItemActionType]: ReactNode } = {\r\n Edit: <EditIcon fontSize='small' color='primary' />,\r\n Delete: <DeleteOutlineIcon fontSize='small' color='error' />\r\n}\r\n\r\nexport interface ITableGridItemActionsBaseProps<T> {\r\n value: T\r\n}\r\n\r\nexport type IActionFormGetter<T> = (value: T) => React.ReactNode\r\n\r\nexport interface IActionMenuItemDef<T> {\r\n name: string\r\n icon?: ReactNode\r\n /** Whether this item should trigger a close action when clicked. @default true */\r\n closableOnClick?: boolean\r\n /** Handler called when item is clicked */\r\n onClick?: (event: React.MouseEvent<HTMLLIElement, MouseEvent>, value: T) => void\r\n listItemProps?: ListItemProps\r\n /**\r\n * Optional custom ReactNode to override the entire ListItem UI.\r\n * If provided, this will be rendered instead of the default ListItem structure\r\n * (icon + text + click behavior).\r\n */\r\n override?: ComponentType<{ onClose?: ClosePopover }>\r\n}\r\n\r\nexport interface TableGridItemActionsConfig<T> {\r\n formEdit?: IActionFormGetter<T>\r\n formDelete?: IActionFormGetter<T>\r\n buttonEditConfig?: GlobalModalState\r\n buttonDeleteConfig?: GlobalModalState\r\n menuList?: {\r\n before?: SingleOrArray<IActionMenuItemDef<T>>\r\n after?: SingleOrArray<IActionMenuItemDef<T>>\r\n }\r\n}\r\n\r\nexport interface ITableGridItemActionsProps<T> extends ITableGridItemActionsBaseProps<T>, TableGridItemActionsConfig<T> {}\r\n\r\nexport function CreateTableGridItemActions<T>() {\r\n class TableGridItemActions extends Component<ITableGridItemActionsProps<T>> {\r\n render() {\r\n if (!this.isVisible()) return <></>\r\n return (\r\n <Wrap>\r\n <IconButton\r\n size='small'\r\n onClick={(e) => {\r\n PopoverGlobal.Api.open({\r\n anchorEl: e.currentTarget,\r\n popoverProps: { anchorOrigin: { vertical: 'top', horizontal: 'right' }, transformOrigin: { vertical: 'top', horizontal: 'right' } },\r\n content: (\r\n <List>\r\n {this.renderItems(this.props.menuList?.before)}\r\n {this.renderItemWithForm('Edit', this.props.formEdit, this.props.buttonEditConfig)}\r\n {this.renderItemWithForm('Delete', this.props.formDelete, this.props.buttonEditConfig ?? { backdropActivated: true })}\r\n {this.renderItems(this.props.menuList?.after)}\r\n </List>\r\n )\r\n })\r\n }}\r\n >\r\n <MoreVertIcon fontSize='small' />\r\n </IconButton>\r\n </Wrap>\r\n )\r\n }\r\n\r\n isVisible = () => {\r\n return !!this.props.formEdit || !!this.props.formDelete\r\n }\r\n\r\n renderItems = (value?: SingleOrArray<IActionMenuItemDef<T>>) => {\r\n if (!value) return <></>\r\n const list = Array.isArray(value) ? value : [value]\r\n return list.map((item, index) => {\r\n const key = item.name + index\r\n const { override: Override } = item\r\n if (Override) return <Override key={key} onClose={PopoverGlobal.Api.close} />\r\n return (\r\n <ListItem\r\n key={key}\r\n disablePadding\r\n sx={{ minWidth: '170px' }}\r\n onClick={(e) => {\r\n if (item.closableOnClick !== false) PopoverGlobal.Api.close()\r\n item.onClick && item.onClick(e, this.props.value)\r\n }}\r\n {...
|
|
1
|
+
{"version":3,"file":"item-actions.js","sources":["../../src/table-grid/item-actions.tsx"],"sourcesContent":["import React, { Component, ComponentType, ReactNode } from 'react'\r\nimport { Box, colors, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemProps, ListItemText, styled } from '@mui/material'\r\nimport EditIcon from '@mui/icons-material/Edit'\r\nimport MoreVertIcon from '@mui/icons-material/MoreVert'\r\nimport DeleteOutlineIcon from '@mui/icons-material/DeleteOutline'\r\nimport { ClosePopover, GlobalModalState, mapGlobalModalContext, PopoverGlobal } from '../api-context'\r\n\r\nexport type ITableGridItemActionType = 'Edit' | 'Delete'\r\n\r\nconst mapIcons: { [key in ITableGridItemActionType]: ReactNode } = {\r\n Edit: <EditIcon fontSize='small' color='primary' />,\r\n Delete: <DeleteOutlineIcon fontSize='small' color='error' />\r\n}\r\n\r\nexport interface ITableGridItemActionsBaseProps<T> {\r\n value: T\r\n}\r\n\r\nexport type IActionFormGetter<T> = (value: T) => React.ReactNode\r\n\r\nexport interface IActionMenuItemDef<T> {\r\n name: string\r\n icon?: ReactNode\r\n /** Whether this item should trigger a close action when clicked. @default true */\r\n closableOnClick?: boolean\r\n /** Handler called when item is clicked */\r\n onClick?: (event: React.MouseEvent<HTMLLIElement, MouseEvent>, value: T) => void\r\n listItemProps?: ListItemProps\r\n listItemPropsGetter?: (value: T) => ListItemProps & { [key: string]: any }\r\n /**\r\n * Optional custom ReactNode to override the entire ListItem UI.\r\n * If provided, this will be rendered instead of the default ListItem structure\r\n * (icon + text + click behavior).\r\n */\r\n override?: ComponentType<{ onClose?: ClosePopover }>\r\n}\r\n\r\nexport interface TableGridItemActionsConfig<T> {\r\n formEdit?: IActionFormGetter<T>\r\n formDelete?: IActionFormGetter<T>\r\n buttonEditConfig?: GlobalModalState\r\n buttonDeleteConfig?: GlobalModalState\r\n menuList?: {\r\n before?: SingleOrArray<IActionMenuItemDef<T>>\r\n after?: SingleOrArray<IActionMenuItemDef<T>>\r\n }\r\n}\r\n\r\nexport interface ITableGridItemActionsProps<T> extends ITableGridItemActionsBaseProps<T>, TableGridItemActionsConfig<T> {}\r\n\r\nexport function CreateTableGridItemActions<T>() {\r\n class TableGridItemActions extends Component<ITableGridItemActionsProps<T>> {\r\n render() {\r\n if (!this.isVisible()) return <></>\r\n return (\r\n <Wrap>\r\n <IconButton\r\n size='small'\r\n onClick={(e) => {\r\n PopoverGlobal.Api.open({\r\n anchorEl: e.currentTarget,\r\n popoverProps: { anchorOrigin: { vertical: 'top', horizontal: 'right' }, transformOrigin: { vertical: 'top', horizontal: 'right' } },\r\n content: (\r\n <List>\r\n {this.renderItems(this.props.menuList?.before)}\r\n {this.renderItemWithForm('Edit', this.props.formEdit, this.props.buttonEditConfig)}\r\n {this.renderItemWithForm('Delete', this.props.formDelete, this.props.buttonEditConfig ?? { backdropActivated: true })}\r\n {this.renderItems(this.props.menuList?.after)}\r\n </List>\r\n )\r\n })\r\n }}\r\n >\r\n <MoreVertIcon fontSize='small' />\r\n </IconButton>\r\n </Wrap>\r\n )\r\n }\r\n\r\n isVisible = () => {\r\n return !!this.props.formEdit || !!this.props.formDelete\r\n }\r\n\r\n renderItems = (value?: SingleOrArray<IActionMenuItemDef<T>>) => {\r\n if (!value) return <></>\r\n const list = Array.isArray(value) ? value : [value]\r\n return list.map((item, index) => {\r\n const key = item.name + index\r\n const { override: Override } = item\r\n if (Override) return <Override key={key} onClose={PopoverGlobal.Api.close} />\r\n const itemProps = item.listItemPropsGetter ? item.listItemPropsGetter(this.props.value) : item.listItemProps\r\n return (\r\n <ListItem\r\n key={key}\r\n disablePadding\r\n sx={{ minWidth: '170px' }}\r\n onClick={(e) => {\r\n if (item.closableOnClick !== false) PopoverGlobal.Api.close()\r\n item.onClick && item.onClick(e, this.props.value)\r\n }}\r\n {...itemProps}\r\n >\r\n <ListItemButton>\r\n <ListItemIcon>{item.icon}</ListItemIcon>\r\n <ListItemText primary={item.name} />\r\n </ListItemButton>\r\n </ListItem>\r\n )\r\n })\r\n }\r\n\r\n renderItemWithForm = (name: ITableGridItemActionType, form?: IActionFormGetter<T>, globalState?: GlobalModalState) => {\r\n if (!form) return <></>\r\n return mapGlobalModalContext((context) => (\r\n <ListItem\r\n disablePadding\r\n sx={{ minWidth: '170px' }}\r\n onClick={() => {\r\n PopoverGlobal.Api.close()\r\n context.show({ renderContent: () => form(this.props.value), ...globalState })\r\n }}\r\n >\r\n <ListItemButton>\r\n <ListItemIcon>{mapIcons[name]}</ListItemIcon>\r\n <ListItemText primary={name} />\r\n </ListItemButton>\r\n </ListItem>\r\n ))\r\n }\r\n }\r\n return TableGridItemActions\r\n}\r\n\r\nconst Wrap = styled(Box)({\r\n background: colors.common.white,\r\n borderRadius: '6px',\r\n '& > .MuiButtonBase-root': {\r\n borderRadius: '6px'\r\n }\r\n})\r\n"],"names":["mapIcons","Edit","_jsx","EditIcon","fontSize","color","Delete","DeleteOutlineIcon","CreateTableGridItemActions","TableGridItemActions","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","this","concat","_defineProperty","props","formEdit","formDelete","value","isArray","map","item","index","key","name","Override","override","onClose","PopoverGlobal","Api","close","itemProps","listItemPropsGetter","listItemProps","ListItem","_objectSpread","disablePadding","sx","minWidth","onClick","e","closableOnClick","children","_jsxs","ListItemButton","ListItemIcon","icon","ListItemText","primary","form","globalState","mapGlobalModalContext","context","show","renderContent","_inherits","Component","_createClass","_this2","isVisible","Wrap","IconButton","size","_this2$props$menuList","_this2$props$buttonEd","_this2$props$menuList2","open","anchorEl","currentTarget","popoverProps","anchorOrigin","vertical","horizontal","transformOrigin","content","List","renderItems","menuList","before","renderItemWithForm","buttonEditConfig","backdropActivated","after","MoreVertIcon","styled","Box","background","colors","common","white","borderRadius"],"mappings":"wuBASA,IAAMA,EAA6D,CACjEC,KAAMC,EAACC,EAAS,CAAAC,SAAS,QAAQC,MAAM,YACvCC,OAAQJ,EAACK,EAAkB,CAAAH,SAAS,QAAQC,MAAM,oBAuCpCG,IAA0B,IAClCC,aAAqB,SAAAA,IAAA,IAAAC,EAAAC,OAAAF,GAAA,IAAA,IAAAG,EAAAC,UAAAC,OAAAC,EAAAC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAAF,EAAAE,GAAAJ,UAAAI,GA6ExB,OA7EwBP,EAAAQ,EAAAC,KAAAV,EAAAW,GAAAA,OAAAL,IAAAM,EAAAX,EAAA,aA4Bb,WACV,QAASA,EAAKY,MAAMC,YAAcb,EAAKY,MAAME,cAC9CH,EAAAX,EAEa,eAAA,SAACe,GACb,OAAKA,GACQT,MAAMU,QAAQD,GAASA,EAAQ,CAACA,IACjCE,KAAI,SAACC,EAAMC,GACrB,IAAMC,EAAMF,EAAKG,KAAOF,EACN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IAAAuB,EAAAC,EAAAC,EACbrC,EAAcC,IAAIqC,KAAK,CACrBC,SAAU3B,EAAE4B,cACZC,aAAc,CAAEC,aAAc,CAAEC,SAAU,MAAOC,WAAY,SAAWC,gBAAiB,CAAEF,SAAU,MAAOC,WAAY,UACxHE,QACE/B,EAACgC,aACEjB,EAAKkB,YAA+B,QAApBb,EAACL,EAAK3C,MAAM8D,gBAAQ,IAAAd,OAAA,EAAnBA,EAAqBe,QACtCpB,EAAKqB,mBAAmB,OAAQrB,EAAK3C,MAAMC,SAAU0C,EAAK3C,MAAMiE,kBAChEtB,EAAKqB,mBAAmB,SAAUrB,EAAK3C,MAAME,WAAuC,QAA7B+C,EAAEN,EAAK3C,MAAMiE,wBAAgB,IAAAhB,EAAAA,EAAI,CAAEiB,mBAAmB,IAC7GvB,EAAKkB,YAA+BX,QAApBA,EAACP,EAAK3C,MAAM8D,oBAAQZ,SAAnBA,EAAqBiB,WAI9C,EAAAxC,SAED/C,EAACwF,EAAa,CAAAtF,SAAS,cApBCF,OAwBhC,IAAC,IAqDH,OAAOO,CACT,CAEA,IAAM0D,EAAOwB,EAAOC,EAAPD,CAAY,CACvBE,WAAYC,EAAOC,OAAOC,MAC1BC,aAAc,MACd,0BAA2B,CACzBA,aAAc"}
|
|
@@ -14,6 +14,9 @@ export interface IActionMenuItemDef<T> {
|
|
|
14
14
|
/** Handler called when item is clicked */
|
|
15
15
|
onClick?: (event: React.MouseEvent<HTMLLIElement, MouseEvent>, value: T) => void;
|
|
16
16
|
listItemProps?: ListItemProps;
|
|
17
|
+
listItemPropsGetter?: (value: T) => ListItemProps & {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
17
20
|
/**
|
|
18
21
|
* Optional custom ReactNode to override the entire ListItem UI.
|
|
19
22
|
* If provided, this will be rendered instead of the default ListItem structure
|