@vidispine/vdt-mui 23.3.0 → 23.4.0-pre.2
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/cjs/_utils/isDefinedValue.js +1 -1
- package/dist/cjs/general/Form/Form.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/inputs/DateTimeInput/index.js +1 -1
- package/dist/cjs/inputs/NumberInput/NumberInput.js +1 -1
- package/dist/cjs/inputs/NumberInput/index.js +1 -1
- package/dist/cjs/inputs/SelectInput/index.js +1 -1
- package/dist/cjs/metadata/MetadataForm/MetadataForm.js +1 -0
- package/dist/cjs/metadata/MetadataForm/hooks/UseMetadataFormInputs.js +1 -0
- package/dist/cjs/metadata/MetadataForm/index.js +1 -0
- package/dist/es/_utils/isDefinedValue.js +1 -1
- package/dist/es/general/Form/Form.js +87 -86
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +42 -38
- package/dist/es/inputs/DateTimeInput/index.js +4 -4
- package/dist/es/inputs/NumberInput/NumberInput.js +8 -8
- package/dist/es/inputs/NumberInput/index.js +3 -3
- package/dist/es/inputs/SelectInput/index.js +3 -3
- package/dist/es/metadata/MetadataForm/MetadataForm.d.ts +65 -0
- package/dist/es/metadata/MetadataForm/MetadataForm.js +70 -0
- package/dist/es/metadata/MetadataForm/hooks/UseMetadataFormInputs.d.ts +98 -0
- package/dist/es/metadata/MetadataForm/hooks/UseMetadataFormInputs.js +98 -0
- package/dist/es/metadata/MetadataForm/index.d.ts +3 -0
- package/dist/es/metadata/MetadataForm/index.js +12 -0
- package/dist/es/metadata/index.d.ts +1 -0
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=(e,{includeDateRange:r=!1}={})=>Array.isArray(e)?e.length!==0&&e.every(t=>![null,void 0].includes(t)):r&&typeof e=="object"?!!(e!=null&&e.start)||!!(e!=null&&e.end):![null,void 0].includes(e);exports.isDefinedValue=i;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=(e,{includeDateRange:r=!1}={})=>Array.isArray(e)?e.length!==0&&e.every(t=>![null,void 0].includes(t)):r&&typeof e=="object"?!!(e!=null&&e.start)||!!(e!=null&&e.end):!["",null,void 0].includes(e);exports.isDefinedValue=i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),y=require("react"),E=require("react-hook-form"),G=require("@mui/material/Box"),C=require("@mui/material/Button"),nt=require("@mui/material/ButtonGroup"),M=require("@mui/material/styles"),rt=M.styled(nt)(({theme:o})=>({marginTop:o.spacing(2),marginBottom:o.spacing(2),display:"flex",justifyContent:"center"})),ut=M.styled(G)(({theme:o})=>({"&:not(:first-of-type)":{paddingTop:o.spacing(2)}})),it={Root:G,InputContainer:ut,Controller:E.Controller,ButtonGroup:rt,ClearButton:C,ResetButton:C,SubmitButton:C},T=({inputs:o,inputProps:D,formProps:F,formReturnRef:h,size:g,variant:I,clearText:O,resetText:J,submitText:N,onClear:d,onReset:f,onChange:m,onSubmit:p,onError:b,components:w,componentsProps:r})=>{const{Root:H,InputContainer:W,Controller:_,ButtonGroup:$,ClearButton:z,ResetButton:A,SubmitButton:K}=w,j=y.useRef(),q=({multiple:t,range:e})=>t||e?[]:"",i=o.reduce((t,{name:e,defaultValue:s,...a})=>({...t,[e]:s||q(a)}),{}),R=E.useForm({defaultValues:i,...F||{}});h&&(h.current=R);const{handleSubmit:L,control:Q,reset:c,watch:V,formState:l}=R,{defaultValues:S,isDirty:v}=l,U=Object.keys((l==null?void 0:l.errors)||{}).length>0,X=t=>{const e=o.reduce((s,{name:a,defaultValue:P,...x})=>({...s,[a]:q(x)}),{});d&&d(t,e),c(e,{keepDefaultValues:!0})},Y=t=>{f&&f(t,i),c(i)};y.useEffect(()=>{const t=m?V(e=>m(j.current,e)):void 0;return()=>t==null?void 0:t.unsubscribe()},[m,V]);const Z=t=>typeof(t==null?void 0:t.required)=="string"||(t==null?void 0:t.required)===!0;return y.useEffect(()=>{JSON.stringify(i)!==JSON.stringify(S)&&c(i)},[i,S,c]),n.jsxs(H,{component:"form",onSubmit:L((t,e)=>typeof p=="function"&&p(e,t),(t,e)=>typeof b=="function"&&b(e,t)),...r.root,children:[o==null?void 0:o.map(({Component:t,name:e,rules:s,label:a,defaultValue:P,...x})=>n.jsx(W,{...r.inputContainer,children:n.jsx(_,{control:Q,name:e,rules:s,render:({field:{onChange:tt,...et},formState:{errors:B}})=>{var k;return n.jsx(t,{onChange:(ot,u)=>{j.current=ot,tt((u==null?void 0:u.value)!==void 0?u==null?void 0:u.value:u)},error:(k=B==null?void 0:B[e])==null?void 0:k.message,size:g,variant:I,label:Z(s)?`${a} *`:a,...et,...D||{},...x})},...r.controller})},e)),n.jsxs($,{variant:"text",size:g,fullWidth:!0,...r.buttonGroup,children:[d&&n.jsx(z,{onClick:X,...r.clearButton,children:O}),f&&n.jsx(A,{onClick:Y,disabled:!v,...r.resetButton,children:J}),p&&n.jsx(K,{type:"submit",disabled:U||!v,...r.submitButton,children:N})]})]})};T.defaultProps={inputs:[],inputProps:void 0,formProps:void 0,formReturn:void 0,variant:"standard",size:"medium",clearText:"Clear",resetText:"Reset",submitText:"Submit",onClear:void 0,onReset:void 0,onChange:void 0,onSubmit:void 0,onError:void 0,components:it,componentsProps:void 0};const st=T;module.exports=st;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./collection/CollectionList/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./collection/CollectionList/index.js"),r=require("./collection/CollectionListItem/index.js"),i=require("./collection/CollectionRepresentativeThumbnail/index.js"),t=require("./collection/CollectionCard/index.js"),o=require("./entity/EntityIcon/index.js"),u=require("./entity/EntityAvatar/index.js"),s=require("./entity/EntityList/index.js"),d=require("./general/AvatarMenu/index.js"),c=require("./general/BlurredBackground/index.js"),x=require("./general/CalendarPicker/index.js"),a=require("./general/CompactBadge/index.js"),q=require("./general/CompactLabel/index.js"),$=require("./general/CornerLabelPlacer/index.js"),m=require("./general/ExpandButton/index.js"),l=require("./general/ImageCollage/index.js"),I=require("./general/MediaIcon/index.js"),p=require("./general/MenuItem/index.js"),T=require("./general/VirtualizedList/index.js"),C=require("./general/ScrubLine/index.js"),b=require("./general/Sort/index.js"),L=require("./general/TablePagination/index.js"),g=require("./general/Form/index.js"),e=require("./general/ThemeContext/ThemeContext.js"),h=require("./item/ItemList/index.js"),M=require("./item/ItemListItem/index.js"),P=require("./item/ItemThumbnail/index.js"),v=require("./item/ItemCard/index.js"),B=require("./item/ItemTable/index.js"),S=require("./item/ItemTableRow/index.js"),E=require("./item/ItemPoster/index.js"),y=require("./item/ItemPosterViewer/index.js"),k=require("./item/ItemPosterList/index.js"),F=require("./inputs/BasicDateTimeInput/index.js"),w=require("./inputs/BooleanInput/index.js"),D=require("./inputs/CheckboxGroupInput/index.js"),G=require("./inputs/DateRangeInput/index.js"),R=require("./inputs/DateTimeInput/index.js"),A=require("./inputs/MaskedTextInput/index.js"),V=require("./inputs/NumberInput/index.js"),f=require("./inputs/RadioGroupInput/index.js"),j=require("./inputs/SelectInput/index.js"),z=require("./inputs/SliderInput/index.js"),N=require("./inputs/TagInput/index.js"),H=require("./inputs/TextInput/index.js"),J=require("./shape/ShapeMediaBadges/index.js"),K=require("./search/SearchFilterForm/index.js"),O=require("./transcode/TranscodePresetMediaBadges/index.js"),Q=require("./event/EventList/index.js"),U=require("./event/EventListItem/index.js"),W=require("./metadata/MetadataGroupTreeView/index.js"),X=require("./metadata/MetadataForm/index.js");exports.CollectionList=n;exports.CollectionListItem=r;exports.CollectionRepresentativeThumbnail=i;exports.CollectionCard=t;exports.EntityIcon=o;exports.EntityAvatar=u;exports.EntityList=s;exports.AvatarMenu=d;exports.BlurredBackground=c;exports.CalendarPicker=x;exports.CompactBadge=a;exports.CompactLabel=q;exports.CornerLabelPlacer=$;exports.ExpandButton=m;exports.ImageCollage=l;exports.MediaIcon=I;exports.MenuItem=p;exports.VirtualizedList=T;exports.ScrubLine=C;exports.Sort=b;exports.TablePagination=L;exports.Form=g;exports.ThemeProvider=e.ThemeProvider;exports.useThemeContext=e.useThemeContext;exports.ItemList=h;exports.ItemListItem=M;exports.ItemThumbnail=P;exports.ItemCard=v;exports.ItemTable=B;exports.ItemTableRow=S;exports.ItemPoster=E;exports.ItemPosterViewer=y;exports.ItemPosterList=k;exports.BasicDateTimeInput=F;exports.BooleanInput=w;exports.CheckboxGroupInput=D;exports.DateRangeInput=G;exports.DateTimeInput=R;exports.MaskedTextInput=A;exports.NumberInput=V;exports.RadioGroupInput=f;exports.SelectInput=j;exports.SliderInput=z;exports.TagInput=N;exports.TextInput=H;exports.ShapeMediaBadges=J;exports.SearchFilterForm=K;exports.TranscodePresetMediaBadges=O;exports.EventList=Q;exports.EventListItem=U;exports.MetadataGroupTreeView=W;exports.MetadataForm=X;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("@mui/material/styles"),r=require("./DateTimeInput.js"),i=require("../../_utils/withOverrides.js"),e="DateTimeInput",t=`Vdt${e}`,c=i.withOverrides(t)(r),
|
|
1
|
+
"use strict";const n=require("@mui/material/styles"),r=require("./DateTimeInput.js"),i=require("../../_utils/withOverrides.js"),e="DateTimeInput",t=`Vdt${e}`,c=i.withOverrides(t)(r),s=n.styled(c,{name:t,overridesResolver:(m,o)=>o.root})({});s.displayName=e;const d=s;module.exports=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const V=require("react/jsx-runtime"),w=require("@mui/material/TextField"),y={Root:w},d=({name:
|
|
1
|
+
"use strict";const V=require("react/jsx-runtime"),w=require("@mui/material/TextField"),y={Root:w},d=({name:n,label:a,value:t,defaultValue:c,helperText:r,error:e,required:v,disabled:m,fullWidth:p,variant:f,size:x,onChange:C,onBlur:g,onFocus:h,components:b,componentsProps:T})=>{const{Root:q}=b,F=o=>{var i,s,u;const P=["",void 0].includes((i=o==null?void 0:o.target)==null?void 0:i.value)?(s=o==null?void 0:o.target)==null?void 0:s.value:Number((u=o==null?void 0:o.target)==null?void 0:u.value);C(o,{value:P})},R=t!==void 0,l=!!e,j=(e||"").trim();return V.jsx(q,{id:n,name:n,label:a,...R?{value:t===null?"":t}:{defaultValue:c},helperText:(j||r)&&l?e:r,error:l,required:v,disabled:m,fullWidth:p,variant:f,size:x,type:"number",autoComplete:"off",onChange:F,onBlur:g,onFocus:h,...T.root})};d.defaultProps={name:void 0,label:void 0,value:void 0,defaultValue:void 0,helperText:void 0,error:void 0,required:!1,disabled:!1,fullWidth:!0,variant:"outlined",size:"medium",onChange:()=>null,onBlur:void 0,onFocus:void 0,components:y,componentsProps:void 0};const z=d;module.exports=z;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const o=require("@mui/material/styles"),n=require("./NumberInput.js"),i=require("../../_utils/withOverrides.js"),e="NumberInput",t=`Vdt${e}`,c=i.withOverrides(t)(n),r=o.styled(c,{name:t,overridesResolver:(d,s)=>s.root})({});r.displayName=e;const u=r;module.exports=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("@mui/material/styles"),r=require("./SelectInput.js"),c=require("../../_utils/withOverrides.js"),e="SelectInput",t=`Vdt${e}`,i=c.withOverrides(t)(r),
|
|
1
|
+
"use strict";const n=require("@mui/material/styles"),r=require("./SelectInput.js"),c=require("../../_utils/withOverrides.js"),e="SelectInput",t=`Vdt${e}`,i=c.withOverrides(t)(r),s=n.styled(i,{name:t,overridesResolver:(l,o)=>o.root})({});s.displayName=e;const d=s;module.exports=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("react/jsx-runtime"),T=require("react"),g=require("@mui/material/Box"),l=require("@vidispine/vdt-js"),P=require("../../general/Form/index.js"),S=require("./hooks/UseMetadataFormInputs.js"),B={Root:g,Form:P},p=({fieldList:f,metadata:m,dataToPropsMap:h,inputsProps:v,onReset:x,onChange:n,onSubmit:r,onError:s,components:y,componentsProps:i})=>{const{Root:R,Form:F}=y,d=T.useRef(),a=t=>{const e=Object.keys(d.current.formState.dirtyFields);return Object.keys(t).reduce((C,o)=>{const c={...C};return e.includes(o)&&(c[o]=t[o]),c},{})},b=S({fieldList:f,metadata:m,dataToPropsMap:h,inputsProps:v}),q=typeof n!="function"?void 0:(t,e)=>{n(t,{values:e,metadata:l.createMetadataType(a(e))})},M=typeof r!="function"?void 0:(t,e)=>{r(t,{values:e,metadata:l.createMetadataType(a(e))})},j=typeof s!="function"?void 0:s;return u.jsx(R,{...i.root,children:u.jsx(F,{inputs:b,onReset:x,onChange:q,onSubmit:M,onError:j,formReturnRef:d,...i.form})})};p.defaultProps={fieldList:void 0,metadata:void 0,dataToPropsMap:{label:"label",helperText:"description",placeholder:"placeholder"},inputsProps:void 0,onReset:void 0,onChange:void 0,onSubmit:void 0,onError:void 0,components:B,componentsProps:void 0};const E=p;module.exports=E;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("react"),E=require("@vidispine/vdt-js"),_=require("../../../inputs/DateRangeInput/index.js"),k=require("../../../inputs/DateTimeInput/index.js"),A=require("../../../inputs/NumberInput/index.js"),U=require("../../../inputs/SelectInput/index.js"),j=require("../../../inputs/SliderInput/index.js"),p=require("../../../inputs/TagInput/index.js"),G=require("../../../inputs/TextInput/index.js"),J="Invalid value",w={TextInput:G,TagInput:p,SliderInput:j,DateRangeInput:_,DateTimeInput:k,NumberInput:A,SelectInput:U},z=({fieldList:d,metadata:I,dataToPropsMap:g,errorMessages:l,inputsProps:u})=>{const{TextInput:a,TagInput:f,DateTimeInput:x,NumberInput:q,SelectInput:b}=w,o=i.useMemo(()=>E.parseFieldDefinitionList(d),[d]),v=i.useMemo(()=>E.parseMetadataType(I,{flat:!0}),[I]),T=i.useCallback(e=>{const n=t=>{const c=e==null?void 0:e[t],r=l==null?void 0:l[t];if(c!==void 0)return{value:c,message:(typeof r=="function"?r(t):r)||J}};return{required:n("required"),minLength:n("minLength"),maxLength:n("maxLength"),min:n("minInclusive"),max:n("maxInclusive"),pattern:n("pattern")}},[l]),$=e=>["float","integer","long"].includes(e),R=e=>["string","string-exact"].includes(e),C=e=>e==="date",h=i.useCallback(({type:e,options:n,currentValue:t})=>R(e)?{freeSolo:!n.length,multiple:(t==null?void 0:t.length)>1}:{},[]),D=i.useCallback(({type:e},n,t)=>R(e)?(n==null?void 0:n.length)>1?f:t!=null&&t.length?b:a:$(e)?q:C(e)?x:a,[x,q,b,f,a]);return i.useMemo(()=>o==null?void 0:o.map(({name:e,restrictions:n,options:t,type:c,data:r,system:F})=>{const N={...(u==null?void 0:u[c])||{},...(u==null?void 0:u[e])||{}},L=T(n),s=v[e]||void 0,O={label:e,defaultValue:s||"",options:t,rules:L,disabled:F,...Object.fromEntries(Object.entries(g).map(([m,S])=>r[S]?[m,r[S]]:void 0).filter(m=>!!m)),...N},M={...h({type:c,options:t,currentValue:s}),...O};return{name:e,Component:D({type:c},s,t),...M}}),[g,D,h,T,u,o,v])},B=z;module.exports=B;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("@mui/material/styles"),n=require("./MetadataForm.js"),i=require("../../_utils/withOverrides.js"),e="MetadataForm",t=`Vdt${e}`,d=i.withOverrides(t)(n),o=s.styled(d,{name:t,overridesResolver:(c,r)=>r.root})({});o.displayName=e;const a=o;module.exports=a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const t = (e, {
|
|
2
2
|
includeDateRange: r = !1
|
|
3
|
-
} = {}) => Array.isArray(e) ? e.length !== 0 && e.every((n) => ![null, void 0].includes(n)) : r && typeof e == "object" ? !!(e != null && e.start) || !!(e != null && e.end) : ![null, void 0].includes(e);
|
|
3
|
+
} = {}) => Array.isArray(e) ? e.length !== 0 && e.every((n) => ![null, void 0].includes(n)) : r && typeof e == "object" ? !!(e != null && e.start) || !!(e != null && e.end) : !["", null, void 0].includes(e);
|
|
4
4
|
export {
|
|
5
5
|
t as isDefinedValue
|
|
6
6
|
};
|
|
@@ -1,132 +1,133 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useForm as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import { jsxs as T, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as nt, useEffect as j } from "react";
|
|
3
|
+
import { useForm as rt, Controller as it } from "react-hook-form";
|
|
4
|
+
import k from "@mui/material/Box";
|
|
5
|
+
import y from "@mui/material/Button";
|
|
6
6
|
import ut from "@mui/material/ButtonGroup";
|
|
7
|
-
import { styled as
|
|
8
|
-
const
|
|
7
|
+
import { styled as D } from "@mui/material/styles";
|
|
8
|
+
const at = D(ut)(({
|
|
9
9
|
theme: o
|
|
10
10
|
}) => ({
|
|
11
11
|
marginTop: o.spacing(2),
|
|
12
12
|
marginBottom: o.spacing(2),
|
|
13
13
|
display: "flex",
|
|
14
14
|
justifyContent: "center"
|
|
15
|
-
})),
|
|
15
|
+
})), lt = D(k)(({
|
|
16
16
|
theme: o
|
|
17
17
|
}) => ({
|
|
18
18
|
"&:not(:first-of-type)": {
|
|
19
19
|
paddingTop: o.spacing(2)
|
|
20
20
|
}
|
|
21
|
-
})),
|
|
22
|
-
Root:
|
|
23
|
-
InputContainer:
|
|
24
|
-
Controller:
|
|
25
|
-
ButtonGroup:
|
|
26
|
-
ClearButton:
|
|
27
|
-
ResetButton:
|
|
28
|
-
SubmitButton:
|
|
29
|
-
},
|
|
21
|
+
})), dt = {
|
|
22
|
+
Root: k,
|
|
23
|
+
InputContainer: lt,
|
|
24
|
+
Controller: it,
|
|
25
|
+
ButtonGroup: at,
|
|
26
|
+
ClearButton: y,
|
|
27
|
+
ResetButton: y,
|
|
28
|
+
SubmitButton: y
|
|
29
|
+
}, E = ({
|
|
30
30
|
inputs: o,
|
|
31
|
-
inputProps:
|
|
32
|
-
formProps:
|
|
33
|
-
formReturnRef:
|
|
34
|
-
size:
|
|
35
|
-
variant:
|
|
36
|
-
clearText:
|
|
37
|
-
resetText:
|
|
38
|
-
submitText:
|
|
39
|
-
onClear:
|
|
40
|
-
onReset:
|
|
41
|
-
onChange:
|
|
42
|
-
onSubmit:
|
|
43
|
-
onError:
|
|
31
|
+
inputProps: q,
|
|
32
|
+
formProps: F,
|
|
33
|
+
formReturnRef: h,
|
|
34
|
+
size: g,
|
|
35
|
+
variant: I,
|
|
36
|
+
clearText: O,
|
|
37
|
+
resetText: J,
|
|
38
|
+
submitText: N,
|
|
39
|
+
onClear: f,
|
|
40
|
+
onReset: s,
|
|
41
|
+
onChange: m,
|
|
42
|
+
onSubmit: p,
|
|
43
|
+
onError: b,
|
|
44
44
|
components: w,
|
|
45
45
|
componentsProps: n
|
|
46
46
|
}) => {
|
|
47
47
|
const {
|
|
48
|
-
Root:
|
|
49
|
-
InputContainer:
|
|
50
|
-
Controller:
|
|
51
|
-
ButtonGroup:
|
|
52
|
-
ClearButton:
|
|
53
|
-
ResetButton:
|
|
54
|
-
SubmitButton:
|
|
55
|
-
} = w,
|
|
48
|
+
Root: W,
|
|
49
|
+
InputContainer: _,
|
|
50
|
+
Controller: $,
|
|
51
|
+
ButtonGroup: z,
|
|
52
|
+
ClearButton: A,
|
|
53
|
+
ResetButton: H,
|
|
54
|
+
SubmitButton: K
|
|
55
|
+
} = w, x = nt(), R = ({
|
|
56
56
|
multiple: t,
|
|
57
57
|
range: e
|
|
58
|
-
}) => t || e ? [] :
|
|
58
|
+
}) => t || e ? [] : "", i = o.reduce((t, {
|
|
59
59
|
name: e,
|
|
60
60
|
defaultValue: u,
|
|
61
|
-
...
|
|
61
|
+
...a
|
|
62
62
|
}) => ({
|
|
63
63
|
...t,
|
|
64
|
-
[e]: u ||
|
|
65
|
-
}), {}),
|
|
66
|
-
defaultValues:
|
|
67
|
-
...
|
|
64
|
+
[e]: u || R(a)
|
|
65
|
+
}), {}), V = rt({
|
|
66
|
+
defaultValues: i,
|
|
67
|
+
...F || {}
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
h && (h.current = V);
|
|
70
70
|
const {
|
|
71
|
-
handleSubmit:
|
|
72
|
-
control:
|
|
73
|
-
reset:
|
|
74
|
-
watch:
|
|
75
|
-
formState:
|
|
76
|
-
} =
|
|
77
|
-
defaultValues: v
|
|
78
|
-
|
|
71
|
+
handleSubmit: L,
|
|
72
|
+
control: Q,
|
|
73
|
+
reset: d,
|
|
74
|
+
watch: S,
|
|
75
|
+
formState: c
|
|
76
|
+
} = V, {
|
|
77
|
+
defaultValues: v,
|
|
78
|
+
isDirty: G
|
|
79
|
+
} = c, U = Object.keys((c == null ? void 0 : c.errors) || {}).length > 0, X = (t) => {
|
|
79
80
|
const e = o.reduce((u, {
|
|
80
|
-
name:
|
|
81
|
-
defaultValue:
|
|
82
|
-
...
|
|
81
|
+
name: a,
|
|
82
|
+
defaultValue: P,
|
|
83
|
+
...B
|
|
83
84
|
}) => ({
|
|
84
85
|
...u,
|
|
85
|
-
[
|
|
86
|
+
[a]: R(B)
|
|
86
87
|
}), {});
|
|
87
|
-
|
|
88
|
-
keepDefaultValues: !0
|
|
89
|
-
});
|
|
90
|
-
}, U = (t) => {
|
|
91
|
-
c && c(t, v), R(v, {
|
|
88
|
+
f && f(t, e), d(e, {
|
|
92
89
|
keepDefaultValues: !0
|
|
93
90
|
});
|
|
91
|
+
}, Y = (t) => {
|
|
92
|
+
s && s(t, i), d(i);
|
|
94
93
|
};
|
|
95
|
-
|
|
96
|
-
const t =
|
|
94
|
+
j(() => {
|
|
95
|
+
const t = m ? S((e) => m(x.current, e)) : void 0;
|
|
97
96
|
return () => t == null ? void 0 : t.unsubscribe();
|
|
98
|
-
}, [
|
|
99
|
-
const
|
|
100
|
-
return
|
|
97
|
+
}, [m, S]);
|
|
98
|
+
const Z = (t) => typeof (t == null ? void 0 : t.required) == "string" || (t == null ? void 0 : t.required) === !0;
|
|
99
|
+
return j(() => {
|
|
100
|
+
JSON.stringify(i) !== JSON.stringify(v) && d(i);
|
|
101
|
+
}, [i, v, d]), /* @__PURE__ */ T(W, { component: "form", onSubmit: L((t, e) => typeof p == "function" && p(e, t), (t, e) => typeof b == "function" && b(e, t)), ...n.root, children: [
|
|
101
102
|
o == null ? void 0 : o.map(({
|
|
102
103
|
Component: t,
|
|
103
104
|
name: e,
|
|
104
105
|
rules: u,
|
|
105
|
-
label:
|
|
106
|
-
defaultValue:
|
|
107
|
-
...
|
|
108
|
-
}) => /* @__PURE__ */
|
|
106
|
+
label: a,
|
|
107
|
+
defaultValue: P,
|
|
108
|
+
...B
|
|
109
|
+
}) => /* @__PURE__ */ l(_, { ...n.inputContainer, children: /* @__PURE__ */ l($, { control: Q, name: e, rules: u, render: ({
|
|
109
110
|
field: {
|
|
110
|
-
onChange:
|
|
111
|
-
...
|
|
111
|
+
onChange: tt,
|
|
112
|
+
...et
|
|
112
113
|
},
|
|
113
114
|
formState: {
|
|
114
|
-
errors:
|
|
115
|
+
errors: C
|
|
115
116
|
}
|
|
116
117
|
}) => {
|
|
117
|
-
var
|
|
118
|
-
return /* @__PURE__ */
|
|
119
|
-
|
|
120
|
-
}, error: (
|
|
118
|
+
var M;
|
|
119
|
+
return /* @__PURE__ */ l(t, { onChange: (ot, r) => {
|
|
120
|
+
x.current = ot, tt((r == null ? void 0 : r.value) !== void 0 ? r == null ? void 0 : r.value : r);
|
|
121
|
+
}, error: (M = C == null ? void 0 : C[e]) == null ? void 0 : M.message, size: g, variant: I, label: Z(u) ? `${a} *` : a, ...et, ...q || {}, ...B });
|
|
121
122
|
}, ...n.controller }) }, e)),
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
/* @__PURE__ */ T(z, { variant: "text", size: g, fullWidth: !0, ...n.buttonGroup, children: [
|
|
124
|
+
f && /* @__PURE__ */ l(A, { onClick: X, ...n.clearButton, children: O }),
|
|
125
|
+
s && /* @__PURE__ */ l(H, { onClick: Y, disabled: !G, ...n.resetButton, children: J }),
|
|
126
|
+
p && /* @__PURE__ */ l(K, { type: "submit", disabled: U || !G, ...n.submitButton, children: N })
|
|
126
127
|
] })
|
|
127
128
|
] });
|
|
128
129
|
};
|
|
129
|
-
|
|
130
|
+
E.defaultProps = {
|
|
130
131
|
inputs: [],
|
|
131
132
|
inputProps: void 0,
|
|
132
133
|
formProps: void 0,
|
|
@@ -141,10 +142,10 @@ T.defaultProps = {
|
|
|
141
142
|
onChange: void 0,
|
|
142
143
|
onSubmit: void 0,
|
|
143
144
|
onError: void 0,
|
|
144
|
-
components:
|
|
145
|
+
components: dt,
|
|
145
146
|
componentsProps: void 0
|
|
146
147
|
};
|
|
147
|
-
const
|
|
148
|
+
const yt = E;
|
|
148
149
|
export {
|
|
149
|
-
|
|
150
|
+
yt as default
|
|
150
151
|
};
|
package/dist/es/index.d.ts
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { default as a } from "./collection/CollectionList/index.js";
|
|
2
2
|
import { default as r } from "./collection/CollectionListItem/index.js";
|
|
3
3
|
import { default as m } from "./collection/CollectionRepresentativeThumbnail/index.js";
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as
|
|
4
|
+
import { default as l } from "./collection/CollectionCard/index.js";
|
|
5
|
+
import { default as d } from "./entity/EntityIcon/index.js";
|
|
6
6
|
import { default as x } from "./entity/EntityAvatar/index.js";
|
|
7
7
|
import { default as i } from "./entity/EntityList/index.js";
|
|
8
8
|
import { default as c } from "./general/AvatarMenu/index.js";
|
|
9
|
-
import { default as
|
|
9
|
+
import { default as C } from "./general/BlurredBackground/index.js";
|
|
10
10
|
import { default as b } from "./general/CalendarPicker/index.js";
|
|
11
11
|
import { default as B } from "./general/CompactBadge/index.js";
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
12
|
+
import { default as P } from "./general/CompactLabel/index.js";
|
|
13
|
+
import { default as v } from "./general/CornerLabelPlacer/index.js";
|
|
14
14
|
import { default as S } from "./general/ExpandButton/index.js";
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
18
|
-
import { default as
|
|
15
|
+
import { default as F } from "./general/ImageCollage/index.js";
|
|
16
|
+
import { default as w } from "./general/MediaIcon/index.js";
|
|
17
|
+
import { default as D } from "./general/MenuItem/index.js";
|
|
18
|
+
import { default as V } from "./general/VirtualizedList/index.js";
|
|
19
19
|
import { default as z } from "./general/ScrubLine/index.js";
|
|
20
20
|
import { default as j } from "./general/Sort/index.js";
|
|
21
21
|
import { default as H } from "./general/TablePagination/index.js";
|
|
@@ -27,75 +27,79 @@ import { default as $ } from "./item/ItemThumbnail/index.js";
|
|
|
27
27
|
import { default as te } from "./item/ItemCard/index.js";
|
|
28
28
|
import { default as oe } from "./item/ItemTable/index.js";
|
|
29
29
|
import { default as fe } from "./item/ItemTableRow/index.js";
|
|
30
|
-
import { default as
|
|
30
|
+
import { default as ue } from "./item/ItemPoster/index.js";
|
|
31
31
|
import { default as pe } from "./item/ItemPosterViewer/index.js";
|
|
32
|
-
import { default as
|
|
32
|
+
import { default as se } from "./item/ItemPosterList/index.js";
|
|
33
33
|
import { default as ne } from "./inputs/BasicDateTimeInput/index.js";
|
|
34
34
|
import { default as Ie } from "./inputs/BooleanInput/index.js";
|
|
35
|
-
import { default as
|
|
35
|
+
import { default as Te } from "./inputs/CheckboxGroupInput/index.js";
|
|
36
36
|
import { default as Le } from "./inputs/DateRangeInput/index.js";
|
|
37
37
|
import { default as ge } from "./inputs/DateTimeInput/index.js";
|
|
38
|
-
import { default as
|
|
39
|
-
import { default as
|
|
40
|
-
import { default as
|
|
38
|
+
import { default as Me } from "./inputs/MaskedTextInput/index.js";
|
|
39
|
+
import { default as he } from "./inputs/NumberInput/index.js";
|
|
40
|
+
import { default as Ee } from "./inputs/RadioGroupInput/index.js";
|
|
41
41
|
import { default as ke } from "./inputs/SelectInput/index.js";
|
|
42
|
-
import { default as
|
|
43
|
-
import { default as
|
|
44
|
-
import { default as
|
|
45
|
-
import { default as
|
|
42
|
+
import { default as Re } from "./inputs/SliderInput/index.js";
|
|
43
|
+
import { default as ye } from "./inputs/TagInput/index.js";
|
|
44
|
+
import { default as Ge } from "./inputs/TextInput/index.js";
|
|
45
|
+
import { default as Ae } from "./shape/ShapeMediaBadges/index.js";
|
|
46
46
|
import { default as Ne } from "./search/SearchFilterForm/index.js";
|
|
47
47
|
import { default as qe } from "./transcode/TranscodePresetMediaBadges/index.js";
|
|
48
48
|
import { default as Je } from "./event/EventList/index.js";
|
|
49
49
|
import { default as Oe } from "./event/EventListItem/index.js";
|
|
50
|
+
import { default as Ue } from "./metadata/MetadataGroupTreeView/index.js";
|
|
51
|
+
import { default as Xe } from "./metadata/MetadataForm/index.js";
|
|
50
52
|
export {
|
|
51
53
|
c as AvatarMenu,
|
|
52
54
|
ne as BasicDateTimeInput,
|
|
53
|
-
|
|
55
|
+
C as BlurredBackground,
|
|
54
56
|
Ie as BooleanInput,
|
|
55
57
|
b as CalendarPicker,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
Te as CheckboxGroupInput,
|
|
59
|
+
l as CollectionCard,
|
|
58
60
|
a as CollectionList,
|
|
59
61
|
r as CollectionListItem,
|
|
60
62
|
m as CollectionRepresentativeThumbnail,
|
|
61
63
|
B as CompactBadge,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
P as CompactLabel,
|
|
65
|
+
v as CornerLabelPlacer,
|
|
64
66
|
Le as DateRangeInput,
|
|
65
67
|
ge as DateTimeInput,
|
|
66
68
|
x as EntityAvatar,
|
|
67
|
-
|
|
69
|
+
d as EntityIcon,
|
|
68
70
|
i as EntityList,
|
|
69
71
|
Je as EventList,
|
|
70
72
|
Oe as EventListItem,
|
|
71
73
|
S as ExpandButton,
|
|
72
74
|
K as Form,
|
|
73
|
-
|
|
75
|
+
F as ImageCollage,
|
|
74
76
|
te as ItemCard,
|
|
75
77
|
X as ItemList,
|
|
76
78
|
Z as ItemListItem,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
ue as ItemPoster,
|
|
80
|
+
se as ItemPosterList,
|
|
79
81
|
pe as ItemPosterViewer,
|
|
80
82
|
oe as ItemTable,
|
|
81
83
|
fe as ItemTableRow,
|
|
82
84
|
$ as ItemThumbnail,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
Me as MaskedTextInput,
|
|
86
|
+
w as MediaIcon,
|
|
87
|
+
D as MenuItem,
|
|
88
|
+
Xe as MetadataForm,
|
|
89
|
+
Ue as MetadataGroupTreeView,
|
|
90
|
+
he as NumberInput,
|
|
91
|
+
Ee as RadioGroupInput,
|
|
88
92
|
z as ScrubLine,
|
|
89
93
|
Ne as SearchFilterForm,
|
|
90
94
|
ke as SelectInput,
|
|
91
|
-
|
|
92
|
-
|
|
95
|
+
Ae as ShapeMediaBadges,
|
|
96
|
+
Re as SliderInput,
|
|
93
97
|
j as Sort,
|
|
94
98
|
H as TablePagination,
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
ye as TagInput,
|
|
100
|
+
Ge as TextInput,
|
|
97
101
|
Q as ThemeProvider,
|
|
98
102
|
qe as TranscodePresetMediaBadges,
|
|
99
|
-
|
|
103
|
+
V as VirtualizedList,
|
|
100
104
|
U as useThemeContext
|
|
101
105
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { styled as m } from "@mui/material/styles";
|
|
2
2
|
import r from "./DateTimeInput.js";
|
|
3
3
|
import { withOverrides as s } from "../../_utils/withOverrides.js";
|
|
4
|
-
const
|
|
5
|
-
name:
|
|
6
|
-
overridesResolver: (
|
|
4
|
+
const t = "DateTimeInput", o = `Vdt${t}`, i = s(o)(r), e = m(i, {
|
|
5
|
+
name: o,
|
|
6
|
+
overridesResolver: (p, n) => n.root
|
|
7
7
|
})({});
|
|
8
|
-
e.displayName =
|
|
8
|
+
e.displayName = t;
|
|
9
9
|
const l = e;
|
|
10
10
|
export {
|
|
11
11
|
l as default
|
|
@@ -3,12 +3,12 @@ import w from "@mui/material/TextField";
|
|
|
3
3
|
const y = {
|
|
4
4
|
Root: w
|
|
5
5
|
}, u = ({
|
|
6
|
-
name:
|
|
6
|
+
name: n,
|
|
7
7
|
label: s,
|
|
8
|
-
value:
|
|
8
|
+
value: t,
|
|
9
9
|
defaultValue: m,
|
|
10
|
-
helperText:
|
|
11
|
-
error:
|
|
10
|
+
helperText: l,
|
|
11
|
+
error: e,
|
|
12
12
|
required: v,
|
|
13
13
|
disabled: c,
|
|
14
14
|
fullWidth: p,
|
|
@@ -28,12 +28,12 @@ const y = {
|
|
|
28
28
|
g(o, {
|
|
29
29
|
value: j
|
|
30
30
|
});
|
|
31
|
-
}, R =
|
|
32
|
-
return /* @__PURE__ */ q(F, { id:
|
|
33
|
-
value:
|
|
31
|
+
}, R = t !== void 0, r = !!e, V = (e || "").trim();
|
|
32
|
+
return /* @__PURE__ */ q(F, { id: n, name: n, label: s, ...R ? {
|
|
33
|
+
value: t === null ? "" : t
|
|
34
34
|
} : {
|
|
35
35
|
defaultValue: m
|
|
36
|
-
}, helperText: (V ||
|
|
36
|
+
}, helperText: (V || l) && r ? e : l, error: r, required: v, disabled: c, fullWidth: p, variant: f, size: C, type: "number", autoComplete: "off", onChange: P, onBlur: h, onFocus: x, ...T.root });
|
|
37
37
|
};
|
|
38
38
|
u.defaultProps = {
|
|
39
39
|
name: void 0,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { styled as
|
|
1
|
+
import { styled as n } from "@mui/material/styles";
|
|
2
2
|
import m from "./NumberInput.js";
|
|
3
3
|
import { withOverrides as s } from "../../_utils/withOverrides.js";
|
|
4
|
-
const o = "NumberInput", t = `Vdt${o}`, p = s(t)(m), e =
|
|
4
|
+
const o = "NumberInput", t = `Vdt${o}`, p = s(t)(m), e = n(p, {
|
|
5
5
|
name: t,
|
|
6
|
-
overridesResolver: (d,
|
|
6
|
+
overridesResolver: (d, r) => r.root
|
|
7
7
|
})({});
|
|
8
8
|
e.displayName = o;
|
|
9
9
|
const l = e;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { styled as r } from "@mui/material/styles";
|
|
2
2
|
import m from "./SelectInput.js";
|
|
3
3
|
import { withOverrides as s } from "../../_utils/withOverrides.js";
|
|
4
|
-
const
|
|
5
|
-
name:
|
|
4
|
+
const t = "SelectInput", o = `Vdt${t}`, p = s(o)(m), e = r(p, {
|
|
5
|
+
name: o,
|
|
6
6
|
overridesResolver: (d, n) => n.root
|
|
7
7
|
})({});
|
|
8
|
-
e.displayName =
|
|
8
|
+
e.displayName = t;
|
|
9
9
|
const a = e;
|
|
10
10
|
export {
|
|
11
11
|
a as default
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Box as MuiBox } from '@mui/material';
|
|
3
|
+
import type { MetadataFieldType, MetadataType } from '@vidispine/types';
|
|
4
|
+
import VdtForm from '../../general/Form';
|
|
5
|
+
import type { PropsFrom, WithOverrideProps } from '../../_types';
|
|
6
|
+
declare const defaultComponents: {
|
|
7
|
+
Root: typeof MuiBox;
|
|
8
|
+
Form: typeof VdtForm;
|
|
9
|
+
};
|
|
10
|
+
export interface MetadataFormProps extends WithOverrideProps<typeof defaultComponents> {
|
|
11
|
+
/**
|
|
12
|
+
* A VidiCore field definition list to create metadata inputs from
|
|
13
|
+
*/
|
|
14
|
+
fieldList?: MetadataFieldType[];
|
|
15
|
+
/**
|
|
16
|
+
* The metadata of a Vidicore entity to extract current values from
|
|
17
|
+
*/
|
|
18
|
+
metadata?: MetadataType;
|
|
19
|
+
/**
|
|
20
|
+
* Override input props using field __name__ or __type__ as key
|
|
21
|
+
*
|
|
22
|
+
* Note: `name` props has precedence if prop is applicable from both name and type
|
|
23
|
+
*
|
|
24
|
+
* E.g. `{ 'vdt_stringField': { label: 'String Field', disabled: true, Component: CheckboxGroupInput } }` or `{ 'string-exact': { ...customInputProps } }`
|
|
25
|
+
*/
|
|
26
|
+
inputsProps?: {
|
|
27
|
+
[fieldNameOrType: string]: object;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Map a field data key to an input prop (ignores data keys it can't find on fields)
|
|
31
|
+
*
|
|
32
|
+
* E.g. `{ label: 'displayName' }` would add the value from data key 'displayName' as a label prop
|
|
33
|
+
*/
|
|
34
|
+
dataToPropsMap?: {
|
|
35
|
+
[propKey: string]: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Callback when inputs are resetted to current metadata values
|
|
39
|
+
*/
|
|
40
|
+
onReset?: (event: React.SyntheticEvent) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Callback when form is changed
|
|
43
|
+
*/
|
|
44
|
+
onChange?: (event: React.SyntheticEvent | null, payload: {
|
|
45
|
+
values: {
|
|
46
|
+
[fieldName: string]: any;
|
|
47
|
+
};
|
|
48
|
+
metadata: MetadataType;
|
|
49
|
+
}) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Callback when form is submitted
|
|
52
|
+
*/
|
|
53
|
+
onSubmit?: (event: React.BaseSyntheticEvent, payload: {
|
|
54
|
+
values: {
|
|
55
|
+
[fieldName: string]: any;
|
|
56
|
+
};
|
|
57
|
+
metadata: MetadataType;
|
|
58
|
+
}) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Callback when form is submitted with errors (invalid values according to form rules)
|
|
61
|
+
*/
|
|
62
|
+
onError?: PropsFrom<typeof VdtForm>['onError'];
|
|
63
|
+
}
|
|
64
|
+
declare const MetadataForm: React.FC<MetadataFormProps>;
|
|
65
|
+
export default MetadataForm;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as P } from "react";
|
|
3
|
+
import S from "@mui/material/Box";
|
|
4
|
+
import { createMetadataType as p } from "@vidispine/vdt-js";
|
|
5
|
+
import T from "../../general/Form/index.js";
|
|
6
|
+
import V from "./hooks/UseMetadataFormInputs.js";
|
|
7
|
+
const B = {
|
|
8
|
+
Root: S,
|
|
9
|
+
Form: T
|
|
10
|
+
}, f = ({
|
|
11
|
+
fieldList: l,
|
|
12
|
+
metadata: u,
|
|
13
|
+
dataToPropsMap: h,
|
|
14
|
+
inputsProps: v,
|
|
15
|
+
onReset: F,
|
|
16
|
+
onChange: r,
|
|
17
|
+
onSubmit: n,
|
|
18
|
+
onError: i,
|
|
19
|
+
components: y,
|
|
20
|
+
componentsProps: d
|
|
21
|
+
}) => {
|
|
22
|
+
const {
|
|
23
|
+
Root: R,
|
|
24
|
+
Form: b
|
|
25
|
+
} = y, a = P(), s = (t) => {
|
|
26
|
+
const o = Object.keys(a.current.formState.dirtyFields);
|
|
27
|
+
return Object.keys(t).reduce((j, e) => {
|
|
28
|
+
const m = {
|
|
29
|
+
...j
|
|
30
|
+
};
|
|
31
|
+
return o.includes(e) && (m[e] = t[e]), m;
|
|
32
|
+
}, {});
|
|
33
|
+
}, x = V({
|
|
34
|
+
fieldList: l,
|
|
35
|
+
metadata: u,
|
|
36
|
+
dataToPropsMap: h,
|
|
37
|
+
inputsProps: v
|
|
38
|
+
}), M = typeof r != "function" ? void 0 : (t, o) => {
|
|
39
|
+
r(t, {
|
|
40
|
+
values: o,
|
|
41
|
+
metadata: p(s(o))
|
|
42
|
+
});
|
|
43
|
+
}, C = typeof n != "function" ? void 0 : (t, o) => {
|
|
44
|
+
n(t, {
|
|
45
|
+
values: o,
|
|
46
|
+
metadata: p(s(o))
|
|
47
|
+
});
|
|
48
|
+
}, g = typeof i != "function" ? void 0 : i;
|
|
49
|
+
return /* @__PURE__ */ c(R, { ...d.root, children: /* @__PURE__ */ c(b, { inputs: x, onReset: F, onChange: M, onSubmit: C, onError: g, formReturnRef: a, ...d.form }) });
|
|
50
|
+
};
|
|
51
|
+
f.defaultProps = {
|
|
52
|
+
fieldList: void 0,
|
|
53
|
+
metadata: void 0,
|
|
54
|
+
dataToPropsMap: {
|
|
55
|
+
label: "label",
|
|
56
|
+
helperText: "description",
|
|
57
|
+
placeholder: "placeholder"
|
|
58
|
+
},
|
|
59
|
+
inputsProps: void 0,
|
|
60
|
+
onReset: void 0,
|
|
61
|
+
onChange: void 0,
|
|
62
|
+
onSubmit: void 0,
|
|
63
|
+
onError: void 0,
|
|
64
|
+
components: B,
|
|
65
|
+
componentsProps: void 0
|
|
66
|
+
};
|
|
67
|
+
const q = f;
|
|
68
|
+
export {
|
|
69
|
+
q as default
|
|
70
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { MetadataType, MetadataFieldType } from '@vidispine/types';
|
|
2
|
+
declare const useMetadataFormInputs: ({ fieldList, metadata, dataToPropsMap, errorMessages, inputsProps, }: {
|
|
3
|
+
fieldList?: MetadataFieldType[];
|
|
4
|
+
metadata?: MetadataType;
|
|
5
|
+
dataToPropsMap?: {
|
|
6
|
+
[propKey: string]: string;
|
|
7
|
+
};
|
|
8
|
+
errorMessages?: {
|
|
9
|
+
[fieldName: string]: string | ((fieldName: string) => string);
|
|
10
|
+
};
|
|
11
|
+
inputsProps?: object;
|
|
12
|
+
}) => ({
|
|
13
|
+
Component: import("react").FC<{
|
|
14
|
+
name?: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
value?: any;
|
|
17
|
+
defaultValue?: any;
|
|
18
|
+
error?: string;
|
|
19
|
+
helperText?: string;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
onChange?: (event: import("react").SyntheticEvent<Element, Event>, payload: {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
value: any;
|
|
25
|
+
}) => void;
|
|
26
|
+
onBlur?: (event: import("react").SyntheticEvent<Element, Event>, payload: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
value: any;
|
|
29
|
+
}) => void;
|
|
30
|
+
onFocus?: (event: import("react").SyntheticEvent<Element, Event>, payload: {
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
value: any;
|
|
33
|
+
}) => void;
|
|
34
|
+
options?: any[];
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
fullWidth?: boolean;
|
|
37
|
+
variant?: string;
|
|
38
|
+
size?: string;
|
|
39
|
+
orientation?: string;
|
|
40
|
+
multiple?: boolean;
|
|
41
|
+
labelPlacement?: string;
|
|
42
|
+
min?: any;
|
|
43
|
+
max?: any;
|
|
44
|
+
type?: string;
|
|
45
|
+
range?: boolean;
|
|
46
|
+
locale?: string;
|
|
47
|
+
justifyContent?: string;
|
|
48
|
+
submitOnChange?: boolean;
|
|
49
|
+
onSubmit?: (event: import("react").SyntheticEvent<Element, Event>, payload: {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
value: any;
|
|
52
|
+
}) => void;
|
|
53
|
+
}>;
|
|
54
|
+
rules?: UseControllerProps;
|
|
55
|
+
} & {
|
|
56
|
+
name?: string;
|
|
57
|
+
label?: string;
|
|
58
|
+
value?: any;
|
|
59
|
+
defaultValue?: any;
|
|
60
|
+
error?: string;
|
|
61
|
+
helperText?: string;
|
|
62
|
+
required?: boolean;
|
|
63
|
+
disabled?: boolean;
|
|
64
|
+
onChange?: (event: import("react").SyntheticEvent<Element, Event>, payload: {
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
value: any;
|
|
67
|
+
}) => void;
|
|
68
|
+
onBlur?: (event: import("react").SyntheticEvent<Element, Event>, payload: {
|
|
69
|
+
[key: string]: any;
|
|
70
|
+
value: any;
|
|
71
|
+
}) => void;
|
|
72
|
+
onFocus?: (event: import("react").SyntheticEvent<Element, Event>, payload: {
|
|
73
|
+
[key: string]: any;
|
|
74
|
+
value: any;
|
|
75
|
+
}) => void;
|
|
76
|
+
options?: any[];
|
|
77
|
+
placeholder?: string;
|
|
78
|
+
fullWidth?: boolean;
|
|
79
|
+
variant?: string;
|
|
80
|
+
size?: string;
|
|
81
|
+
orientation?: string;
|
|
82
|
+
multiple?: boolean;
|
|
83
|
+
labelPlacement?: string;
|
|
84
|
+
min?: any;
|
|
85
|
+
max?: any;
|
|
86
|
+
type?: string;
|
|
87
|
+
range?: boolean;
|
|
88
|
+
locale?: string;
|
|
89
|
+
justifyContent?: string;
|
|
90
|
+
submitOnChange?: boolean;
|
|
91
|
+
onSubmit?: (event: import("react").SyntheticEvent<Element, Event>, payload: {
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
value: any;
|
|
94
|
+
}) => void;
|
|
95
|
+
} & {
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
})[];
|
|
98
|
+
export default useMetadataFormInputs;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useMemo as f, useCallback as I } from "react";
|
|
2
|
+
import { parseFieldDefinitionList as U, parseMetadataType as j } from "@vidispine/vdt-js";
|
|
3
|
+
import q from "../../../inputs/DateRangeInput/index.js";
|
|
4
|
+
import M from "../../../inputs/DateTimeInput/index.js";
|
|
5
|
+
import V from "../../../inputs/NumberInput/index.js";
|
|
6
|
+
import k from "../../../inputs/SelectInput/index.js";
|
|
7
|
+
import G from "../../../inputs/SliderInput/index.js";
|
|
8
|
+
import $ from "../../../inputs/TagInput/index.js";
|
|
9
|
+
import w from "../../../inputs/TextInput/index.js";
|
|
10
|
+
const z = "Invalid value", B = {
|
|
11
|
+
TextInput: w,
|
|
12
|
+
TagInput: $,
|
|
13
|
+
SliderInput: G,
|
|
14
|
+
DateRangeInput: q,
|
|
15
|
+
DateTimeInput: M,
|
|
16
|
+
NumberInput: V,
|
|
17
|
+
SelectInput: k
|
|
18
|
+
}, H = ({
|
|
19
|
+
fieldList: d,
|
|
20
|
+
metadata: g,
|
|
21
|
+
dataToPropsMap: p,
|
|
22
|
+
errorMessages: o,
|
|
23
|
+
inputsProps: u
|
|
24
|
+
}) => {
|
|
25
|
+
const {
|
|
26
|
+
TextInput: l,
|
|
27
|
+
TagInput: T,
|
|
28
|
+
DateTimeInput: D,
|
|
29
|
+
NumberInput: R,
|
|
30
|
+
SelectInput: S
|
|
31
|
+
} = B, i = f(() => U(d), [d]), b = f(() => j(g, {
|
|
32
|
+
flat: !0
|
|
33
|
+
}), [g]), v = I((t) => {
|
|
34
|
+
const n = (e) => {
|
|
35
|
+
const m = t == null ? void 0 : t[e], r = o == null ? void 0 : o[e];
|
|
36
|
+
if (m !== void 0)
|
|
37
|
+
return {
|
|
38
|
+
value: m,
|
|
39
|
+
message: (typeof r == "function" ? r(e) : r) || z
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
required: n("required"),
|
|
44
|
+
minLength: n("minLength"),
|
|
45
|
+
maxLength: n("maxLength"),
|
|
46
|
+
min: n("minInclusive"),
|
|
47
|
+
max: n("maxInclusive"),
|
|
48
|
+
pattern: n("pattern")
|
|
49
|
+
};
|
|
50
|
+
}, [o]), N = (t) => ["float", "integer", "long"].includes(t), x = (t) => ["string", "string-exact"].includes(t), F = (t) => t === "date", h = I(({
|
|
51
|
+
type: t,
|
|
52
|
+
options: n,
|
|
53
|
+
currentValue: e
|
|
54
|
+
}) => x(t) ? {
|
|
55
|
+
freeSolo: !n.length,
|
|
56
|
+
multiple: (e == null ? void 0 : e.length) > 1
|
|
57
|
+
} : {}, []), s = I(({
|
|
58
|
+
type: t
|
|
59
|
+
}, n, e) => x(t) ? (n == null ? void 0 : n.length) > 1 ? T : e != null && e.length ? S : l : N(t) ? R : F(t) ? D : l, [D, R, S, T, l]);
|
|
60
|
+
return f(() => i == null ? void 0 : i.map(({
|
|
61
|
+
name: t,
|
|
62
|
+
restrictions: n,
|
|
63
|
+
options: e,
|
|
64
|
+
type: m,
|
|
65
|
+
data: r,
|
|
66
|
+
system: L
|
|
67
|
+
}) => {
|
|
68
|
+
const O = {
|
|
69
|
+
...(u == null ? void 0 : u[m]) || {},
|
|
70
|
+
...(u == null ? void 0 : u[t]) || {}
|
|
71
|
+
}, C = v(n), c = b[t] || void 0, _ = {
|
|
72
|
+
label: t,
|
|
73
|
+
defaultValue: c || "",
|
|
74
|
+
options: e,
|
|
75
|
+
rules: C,
|
|
76
|
+
disabled: L,
|
|
77
|
+
...Object.fromEntries(Object.entries(p).map(([a, E]) => r[E] ? [a, r[E]] : void 0).filter((a) => !!a)),
|
|
78
|
+
...O
|
|
79
|
+
}, A = {
|
|
80
|
+
...h({
|
|
81
|
+
type: m,
|
|
82
|
+
options: e,
|
|
83
|
+
currentValue: c
|
|
84
|
+
}),
|
|
85
|
+
..._
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
name: t,
|
|
89
|
+
Component: s({
|
|
90
|
+
type: m
|
|
91
|
+
}, c, e),
|
|
92
|
+
...A
|
|
93
|
+
};
|
|
94
|
+
}), [p, s, h, v, u, i, b]);
|
|
95
|
+
}, tt = H;
|
|
96
|
+
export {
|
|
97
|
+
tt as default
|
|
98
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { styled as r } from "@mui/material/styles";
|
|
2
|
+
import m from "./MetadataForm.js";
|
|
3
|
+
import { withOverrides as s } from "../../_utils/withOverrides.js";
|
|
4
|
+
const o = "MetadataForm", t = `Vdt${o}`, d = s(t)(m), e = r(d, {
|
|
5
|
+
name: t,
|
|
6
|
+
overridesResolver: (p, n) => n.root
|
|
7
|
+
})({});
|
|
8
|
+
e.displayName = o;
|
|
9
|
+
const l = e;
|
|
10
|
+
export {
|
|
11
|
+
l as default
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vidispine/vdt-mui",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.4.0-pre.2",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"@mui/icons-material": "^5.14.8",
|
|
43
43
|
"@mui/lab": "^5.0.0-alpha.120",
|
|
44
44
|
"@mui/material": "^5.14.8",
|
|
45
|
-
"@vidispine/proptypes": "23.
|
|
46
|
-
"@vidispine/types": "23.
|
|
47
|
-
"@vidispine/vdt-api": "23.
|
|
48
|
-
"@vidispine/vdt-js": "23.
|
|
45
|
+
"@vidispine/proptypes": "23.4.0-pre.2",
|
|
46
|
+
"@vidispine/types": "23.4.0-pre.2",
|
|
47
|
+
"@vidispine/vdt-api": "23.4.0-pre.2",
|
|
48
|
+
"@vidispine/vdt-js": "23.4.0-pre.2",
|
|
49
49
|
"clsx": "^1.2.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"react-imask": "^6.4.3"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@vidispine/eslint-config-mdx": "23.
|
|
62
|
-
"@vidispine/eslint-config-react": "23.
|
|
63
|
-
"@vidispine/eslint-config-storybook": "23.
|
|
64
|
-
"@vidispine/eslint-config-typescript": "23.
|
|
65
|
-
"@vidispine/prettier-config": "23.
|
|
66
|
-
"@vidispine/proptypes": "23.
|
|
67
|
-
"@vidispine/tests": "23.
|
|
61
|
+
"@vidispine/eslint-config-mdx": "23.4.0-pre.2",
|
|
62
|
+
"@vidispine/eslint-config-react": "23.4.0-pre.2",
|
|
63
|
+
"@vidispine/eslint-config-storybook": "23.4.0-pre.2",
|
|
64
|
+
"@vidispine/eslint-config-typescript": "23.4.0-pre.2",
|
|
65
|
+
"@vidispine/prettier-config": "23.4.0-pre.2",
|
|
66
|
+
"@vidispine/proptypes": "23.4.0-pre.2",
|
|
67
|
+
"@vidispine/tests": "23.4.0-pre.2",
|
|
68
68
|
"@vitejs/plugin-react": "3.1.0",
|
|
69
69
|
"babel-plugin-transform-import": "1.5.4",
|
|
70
70
|
"eslint": "8.48.0",
|