@ailaw/venus 0.1.0 → 0.1.1

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/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  import './index.css';
2
+ export { default as useMe } from './hooks/useMe';
2
3
  export { default as ProfileSelect } from './profile-select/index.vue';
4
+ export { default as ProfileTypeIcon } from './profile-type-icon/index.vue';
@@ -0,0 +1,49 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var m=require("@vue/apollo-composable"),E=require("graphql-tag"),i=require("vue-demi"),c=require("ant-design-vue"),T=require("ramda");function N(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var y=N(E);const k=y.default`
2
+ query Me {
3
+ me {
4
+ id
5
+ lawFirmId
6
+ }
7
+ }
8
+ `;function h(){const{result:e}=m.useQuery(k);return m.useResult(e)}function x(e){switch(e){case"./icons/attorney.svg":return Promise.resolve().then(function(){return require("./attorney.js")});case"./icons/company.svg":return Promise.resolve().then(function(){return require("./company.js")});case"./icons/individual.svg":return Promise.resolve().then(function(){return require("./individual.js")});default:return new Promise(function(r,t){(typeof queueMicrotask=="function"?queueMicrotask:setTimeout)(t.bind(null,new Error("Unknown variable dynamic import: "+e)))})}}var M=i.defineComponent({props:{type:{type:String,required:!0}},setup(e){const r=i.ref();return i.watch(()=>e.type,t=>{let n="";switch(t){case"USERPROFILE":n="individual";break;case"CLIENTPROFILE":n="company";break;default:n="attorney";break}x(`./icons/${n}.svg`).then(l=>r.value=l.default)},{immediate:!0}),{iconUrl:r}}}),O=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("img",{staticClass:"w-6 h-6",attrs:{src:e.iconUrl,alt:e.type}})},q=[];function v(e,r,t,n,l,o,d,f){var a=typeof e=="function"?e.options:e;r&&(a.render=r,a.staticRenderFns=t,a._compiled=!0),n&&(a.functional=!0),o&&(a._scopeId="data-v-"+o);var s;if(d?(s=function(p){p=p||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!p&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(p=__VUE_SSR_CONTEXT__),l&&l.call(this,p),p&&p._registeredComponents&&p._registeredComponents.add(d)},a._ssrRegister=s):l&&(s=f?function(){l.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:l),s)if(a.functional){a._injectStyles=s;var _=a.render;a.render=function(F,P){return s.call(P),_(F,P)}}else{var u=a.beforeCreate;a.beforeCreate=u?[].concat(u,s):[s]}return{exports:e,options:a}}const S={};var L=v(M,O,q,!1,U,null,null,null);function U(e){for(let r in S)this[r]=S[r]}var $=function(){return L.exports}(),j=i.defineComponent({props:{source:{type:Object,required:!0}},components:{ProfileTypeIcon:$}}),V=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("div",{staticClass:"flex space-x-1 items-center"},[t("ProfileTypeIcon",{attrs:{type:e.source.profileType}}),t("div",{staticClass:"text-secondary"},[e._v(e._s(e.source.profileName))])],1)},D=[];const g={};var A=v(j,V,D,!1,B,null,null,null);function B(e){for(let r in g)this[r]=g[r]}var Q=function(){return A.exports}();const z=y.default`
9
+ query ProfileSearch(
10
+ $lawFirmId: Int!
11
+ $keywords: String
12
+ $profileType: String
13
+ ) {
14
+ profileSearch(
15
+ query: {
16
+ lawFirmId: $lawFirmId
17
+ keywords: $keywords
18
+ profileType: $profileType
19
+ }
20
+ ) {
21
+ numResult
22
+ profileList(startIndex: 0, endIndex: 99) {
23
+ id
24
+ profileType
25
+ profileName
26
+ }
27
+ }
28
+ }
29
+ `,X=y.default`
30
+ mutation addProfileUser(
31
+ $email: String
32
+ $name: String
33
+ $petitionerProfileName: String
34
+ $lawFirmId: Int!
35
+ ) {
36
+ addProfileUserNoNotify(
37
+ email: $email
38
+ name: $name
39
+ petitionerProfileName: $petitionerProfileName
40
+ selfLawFirmId: $lawFirmId
41
+ ) {
42
+ profile {
43
+ id
44
+ profileName
45
+ profileType
46
+ }
47
+ }
48
+ }
49
+ `;function W(){const e=h(),{mutate:r,loading:t}=m.useMutation(X);return{createProfile:async l=>{var f;const o={email:l.email,lawFirmId:(f=e.value)==null?void 0:f.lawFirmId};l.profileType==="USERPROFILE"?o.name=l.profileName:o.petitionerProfileName=l.profileName;const d=await r(o);return T.path(["data","addProfileUserNoNotify","profile"],d)},loading:t}}const G={USERPROFILE:"Individual",CLIENTPROFILE:"Company",PREPARERPROFILE:"Attorney"};var H=i.defineComponent({props:{value:{type:String},enabledTypes:{type:Array,default:["USERPROFILE","CLIENTPROFILE","PREPARERPROFILE"]}},components:{Select:c.Select,Option:c.Select.Option,ProfileTypeIcon:$},setup(e,{emit:r}){return{profileTypes:G,handleChange:n=>r("input",n)}}}),J=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("Select",{attrs:{value:e.value},on:{change:e.handleChange}},e._l(e.enabledTypes,function(n){return t("Option",{key:n,attrs:{value:n}},[t("div",{staticClass:"flex items-center space-x-1"},[t("ProfileTypeIcon",{attrs:{type:n}}),t("div",{staticClass:"text-secondary"},[e._v(e._s(e.profileTypes[n]))])],1)])}),1)},K=[];const I={};var Y=v(H,J,K,!1,Z,null,null,null);function Z(e){for(let r in I)this[r]=I[r]}var ee=function(){return Y.exports}(),te=i.defineComponent({components:{Modal:c.Modal,Form:c.Form,FormItem:c.Form.Item,ProfileTypeSelect:ee,Input:c.Input,Checkbox:c.Checkbox},setup(e,{emit:r}){const t=i.ref({}),n=i.ref(!1),l=i.computed(()=>t.value.profileName&&t.value.profileType),o={profileType:{required:!0},profileName:{required:!0},email:{type:"email"}},d=()=>t.value={},{createProfile:f,loading:a}=W(),s=()=>r("cancel");return{value:t,rules:o,shouldSendPassword:n,clearValue:d,loading:a,canSubmit:l,handleSubmit:async()=>{const u=await f(t.value);s(),r("profile-created",u)}}}}),re=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("modal",e._g(e._b({attrs:{closable:!1,"ok-text":"Create",width:320,okButtonProps:{props:{disabled:!e.canSubmit,loading:e.loading}}},on:{cancel:e.clearValue,ok:e.handleSubmit}},"modal",e.$attrs,!1),e.$listeners),[t("Form",{attrs:{layout:"vertical","validate-trigger":"blur",model:e.value,rules:e.rules}},[t("form-item",{attrs:{label:"Profile type",name:"profileType"}},[t("profile-type-select",{attrs:{enabledTypes:["USERPROFILE","CLIENTPROFILE"]},model:{value:e.value.profileType,callback:function(n){e.$set(e.value,"profileType",n)},expression:"value.profileType"}})],1),t("form-item",{attrs:{label:"Name",name:"profileName"}},[t("Input",{model:{value:e.value.profileName,callback:function(n){e.$set(e.value,"profileName",n)},expression:"value.profileName"}})],1),t("form-item",{attrs:{label:"Email"}},[t("Input",{model:{value:e.value.email,callback:function(n){e.$set(e.value,"email",n)},expression:"value.email"}})],1),t("form-item",[t("checkbox",{model:{value:e.shouldSendPassword,callback:function(n){e.shouldSendPassword=n},expression:"shouldSendPassword"}},[e._v("Send client portal login password (System will email client a login password)")])],1)],1)],1)},ne=[];const b={};var oe=v(te,re,ne,!1,le,null,null,null);function le(e){for(let r in b)this[r]=b[r]}var C=function(){return oe.exports}(),ae=i.defineComponent({props:{value:{type:Object},keywords:{type:String,required:!0},source:{type:Array,required:!0}},components:{Select:c.Select,Option:c.Select.Option,Divider:c.Divider,Button:c.Button,ProfileSelectItem:Q,ProfileCreateModal:C,VNodes:{functional:!0,render:(e,r)=>r.props.vnodes}},setup(e,{emit:r}){return{selectedId:i.computed(()=>{var o;return(o=e.value)==null?void 0:o.id}),handleSelect:o=>r("input",e.source.find(d=>String(d.id)==o)),handleProfileCreate:()=>r("create-profile"),menu:{}}}}),ie=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("Select",e._g(e._b({staticClass:"w-72",attrs:{allowClear:"",showSearch:"",optionFilterProp:"name",value:e.selectedId},on:{select:e.handleSelect},scopedSlots:e._u([{key:"dropdownRender",fn:function(n){return t("div",{},[t("v-nodes",{attrs:{vnodes:n}}),t("Divider",{staticClass:"my-1"}),t("div",{staticClass:"flex justify-end px-3 py-1"},[t("Button",{attrs:{size:"small"},on:{click:e.handleProfileCreate}},[e._v("Create new profile")])],1)],1)}}])},"Select",e.$attrs,!1),e.$listeners),e._l(e.source,function(n){return t("Option",{key:n.id,attrs:{value:n.id}},[t("ProfileSelectItem",{attrs:{source:n}})],1)}),1)},se=[];const w={};var ue=v(ae,ie,se,!1,ce,null,null,null);function ce(e){for(let r in w)this[r]=w[r]}var de=function(){return ue.exports}();function fe(e){const r=h(),{result:t,loading:n}=m.useQuery(z,()=>{var o;return{lawFirmId:(o=r.value)==null?void 0:o.lawFirmId,keywords:e.value}},()=>({enabled:r.value!=null}));return{profiles:m.useResult(t,[],o=>o.profileSearch.profileList),loading:n}}var pe=i.defineComponent({components:{ProfileSelector:de,ProfileCreateModal:C},props:{value:{type:Object}},setup(e,{emit:r}){const t=i.ref(""),n=u=>t.value=u,{profiles:l}=fe(t),o=i.ref(),d=i.computed(()=>o.value?[o.value,...l.value]:l.value),f=i.ref(!1),a=u=>f.value=u,s=u=>r("input",u);return{profiles:d,isModalVisible:f,toggleModal:a,updateValue:s,handleProfileCreated:u=>{o.value=u,s(u)},keywords:t,handleSearch:n}}}),ve=function(){var e=this,r=e.$createElement,t=e._self._c||r;return t("div",[t("profile-selector",e._g(e._b({attrs:{source:e.profiles,value:e.value,keywords:e.keywords},on:{search:e.handleSearch,"create-profile":function(n){return e.toggleModal(!0)},input:e.updateValue}},"profile-selector",e.$attrs,!1),e.$listeners)),t("profile-create-modal",{attrs:{visible:e.isModalVisible},on:{cancel:function(n){return e.toggleModal(!1)},"profile-created":e.handleProfileCreated}})],1)},me=[];const R={};var _e=v(pe,ve,me,!1,ye,null,null,null);function ye(e){for(let r in R)this[r]=R[r]}var he=function(){return _e.exports}();exports.ProfileSelect=he;exports.ProfileTypeIcon=$;exports.useMe=h;