@instincthub/react-ui 0.0.7 → 0.0.9
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/src/assets/css/forms/submit-button.css +0 -1
- package/dist/src/components/forms/SearchFieldDB.js +1 -1
- package/dist/src/components/forms/SearchObjectsFromDB.js +1 -1
- package/dist/src/types/components/forms/SearchFieldDB.d.ts +1 -1
- package/dist/src/types/components/forms/SearchObjectsFromDB.d.ts +1 -1
- package/dist/src/types/components/navbar/Breadcrumb.d.ts +9 -0
- package/dist/src/types/types/index.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,
|
|
1
|
+
import{slicedToArray as e,asyncToGenerator as r,regeneratorRuntime as a}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";import{reqOptions as c,API_HOST_URL as s}from"../lib/helpFunction.js";import o from"@mui/icons-material/SearchRounded";import{useRouter as i}from"next/navigation";import{useState as l,useEffect as u}from"react";import"../lib/utils.js";import{urlQueryHelper as h}from"../lib/queryParameters/index.js";var m=function(m){var p=i(),v=m.params.channel,d=m.searchParams.search,f=l(),b=e(f,2),x=b[0],y=b[1],k=l(d),g=e(k,2),N=g[0],j=g[1],w=function(e){var r=h({key:"search",value:e,action:"add"});p.replace(r)},C=function(){var e=r(a().mark((function e(r){var t,n,c=arguments;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=c.length>1&&void 0!==c[1]&&c[1],(13===r.keyCode||t)&&(n=r.currentTarget.value,w(n));case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),P=function(){var e=r(a().mark((function e(){var r,t,n,o,i;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(0),r=c("GET",null,m.token,!1,v),t="".concat(s).concat(m.urlPath,"search=").concat(d||""),e.prev=3,e.next=6,fetch(t,r);case 6:if(200!==(n=e.sent).status){e.next=14;break}return e.next=10,n.json();case 10:i=e.sent,m.setData(i.results),m.setNext(i.next),null===(o=m.setPrevious)||void 0===o||o.call(m,i.previous);case 14:y(n.status),e.next=21;break;case 17:e.prev=17,e.t0=e.catch(3),console.error("Search error:",e.t0),y(500);case 21:case"end":return e.stop()}}),e,null,[[3,17]])})));return function(){return e.apply(this,arguments)}}();return u((function(){void 0!==d&&(P(),j(d))}),[d]),t("div",{className:"ihub-search-field",children:n("div",{className:"ihub-search-courses",children:[t("input",{type:"search",placeholder:"Search ".concat(m.labels?m.labels:"Items"," ..."),onChange:function(e){j(e.target.value)},value:N||"",onKeyDown:C}),N?t("svg",{className:"ihub-search-cancel",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"CloseIcon",onClick:function(){var e=h({key:"search",value:"",action:"remove"});p.replace(e)},children:t("path",{d:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})}):null,t("div",{className:"ihub-search-btn",children:0===x?t("div",{className:"ihub-loader"}):t(o,{className:"ihub-material-symbols-outlined",onClick:function(){return w(N)}})})]})})};export{m as default};
|
|
2
2
|
//# sourceMappingURL=SearchFieldDB.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,asyncToGenerator as
|
|
1
|
+
import{slicedToArray as e,asyncToGenerator as i,regeneratorRuntime as n,toConsumableArray as r,typeof as c}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as t,jsxs as a}from"react/jsx-runtime";import{memo as l,useState as o,useEffect as s,useCallback as u}from"react";import{reqOptions as h,API_HOST_URL as d}from"../lib/helpFunction.js";import"../lib/utils.js";import m from"@mui/icons-material/SearchOutlined";import b from"@mui/icons-material/Check";import f from"@mui/icons-material/CloseOutlined";function p(l){var p=l.label,v=l.token,N=l.handle,g=l.setSelected,k=l.appLabel,y=l.modelName,x=l.filterChannel,C=void 0!==x&&x,_=l.limit_query,j=void 0===_?5:_,w=l.limit_select,E=void 0===w?0:w,T=l.options,S=l.key_name,O=void 0===S?"title":S,U=l.placeholder,q=void 0===U?"Search by Username or Email":U,A=l.searchUrl,D=l.selected,G=l.err,H=void 0!==G&&G,P=o(""),R=e(P,2),B=R[0],F=R[1],K=o([]),L=e(K,2),z=L[0],I=L[1],J=o(!1),M=e(J,2),Q=M[0],V=M[1],W=o(null),X=e(W,2),Y=X[0],Z=X[1];s((function(){D&&D.length>0&&0===z.length&&I(D)}),[D]),s((function(){I(T||[])}),[T]);var $=u(i(n().mark((function e(){var i,c,t,a,l;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return V(!0),Z(null),i=h("GET",null,v),c=A?A.includes("/?")?"".concat(A,"&search=").concat(B):"".concat(A,"?search=").concat(B):k?"".concat(d,"channels/").concat(N,"/dynamic-search/?app_label=").concat(k,"&model_name=").concat(y,"&value=").concat(B,"&filter_channel=").concat(C):"".concat(d,"auth/").concat(N,"/search-user/").concat(B,"/?limit=").concat(j),e.prev=4,e.next=7,fetch(c,i);case 7:if((t=e.sent).ok){e.next=10;break}throw new Error("HTTP error ".concat(t.status));case 10:return e.next=12,t.json();case 12:a=e.sent,I([].concat(r(a.results||[]),r(T||[]))),e.next=22;break;case 16:e.prev=16,e.t0=e.catch(4),l=e.t0 instanceof Error?e.t0.message:"Unknown error occurred",console.error("Error fetching search results:",l),Z(l),I(r(T||[]));case 22:return e.prev=22,V(!1),e.finish(22);case 25:case"end":return e.stop()}}),e,null,[[4,16,22,25]])}))),[B,v,A,k,y,N,C,j]),ee=u((function(e){"Enter"===e.key&&(e.preventDefault(),$())}),[$]),ie=u((function(){F(""),I(r(T||[])),Z(null)}),[]),ne=u((function(e){return D.some((function(i){return("object"===c(i)?null==i?void 0:i.id:i)===((null==e?void 0:e.username)||(null==e?void 0:e.id))}))}),[D]),re=u((function(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e&&e.id){var n=D.find((function(i){return i.id===e.id}));i?g(D.filter((function(i){return i.id!==e.id}))):!n&&(0===E||D.length<E)?g([].concat(r(D),[e])):1===E&&g([e])}}),[D,g,E]);return t("div",{className:"ihub-react-search-container",children:a("div",{className:"ihub-react-search card",children:[p&&t("h4",{className:"ihub-fs-sm ihub-mt-2 ihub-mb-2",children:p}),a("div",{className:"ihub-search-input",children:[t("input",{type:"text",placeholder:q,onKeyDown:ee,value:B,onChange:function(e){return F(e.target.value)},disabled:Q}),a("div",{className:"ihub-search-icons",children:[B&&t(f,{onClick:ie,className:"ihub-search-icon ihub-close-icon"}),t(m,{onClick:$,className:"ihub-search-icon ihub-search-button ".concat(Q?"ihub-disabled":"")})]})]}),Q&&t("div",{className:"ihub-loading",children:"Searching..."}),Y&&t("div",{className:"ihub-search-error",children:Y}),a("ul",{className:"ihub-search-results",children:[null==z?void 0:z.map((function(e,i){return a("li",{className:"ihub-search-result-item ihub-valid",onClick:function(){return e&&re(e)},children:[ne(e)&&t(b,{className:"ihub-check-icon",style:{position:"relative",top:"5px",marginRight:"10px"}}),(null==e?void 0:e[O])||(null==e?void 0:e.title)||"",ne(e)?t(f,{className:"ihub-delete-icon ihub-ml-auto",onClick:function(){return e&&re(e,!0)}}):""]},"".concat((null==e?void 0:e.id)||(null==e?void 0:e.username)||i))})),Q||Y||z.length||D.length?"":t("li",{className:"ihub-no-results",children:"No available options"})]}),a("ul",{className:"ihub-selected-options ihub-mt-2 ihub-",children:[t("h4",{className:"ihub-fs-sm ihub-mt-2 ihub-mb-2",children:"Selected Options:"}),D.map((function(e){return a("li",{className:"ihub-fs-sm ihub-border-bottom ihub-pb-2 ihub-flex ihub-items-center",children:[e[O]||e.title,t(f,{className:"ihub-delete-icon ihub-ml-auto",onClick:function(){return re(e,!0)}})]},null==e?void 0:e.id)}))]}),H&&t("p",{className:"ihub-error",children:"This field is required"})]})})}var v=l(p);export{v as default};
|
|
2
2
|
//# sourceMappingURL=SearchObjectsFromDB.js.map
|
|
@@ -7,7 +7,7 @@ interface SearchFieldDBProps {
|
|
|
7
7
|
/** Function to set next page URL */
|
|
8
8
|
setNext: React.Dispatch<React.SetStateAction<string | null>>;
|
|
9
9
|
/** Function to set previous page URL */
|
|
10
|
-
setPrevious
|
|
10
|
+
setPrevious?: React.Dispatch<React.SetStateAction<string | null>>;
|
|
11
11
|
/** Auth token for API requests */
|
|
12
12
|
token?: string | null;
|
|
13
13
|
/** Search parameters from URL */
|
|
@@ -36,7 +36,7 @@ interface SearchObjectsFromDBProps<T extends SearchObjectItemType = SearchObject
|
|
|
36
36
|
* @param {string} props.appLabel - The app label for the API request
|
|
37
37
|
* @param {string} props.modelName - The model name for the API request
|
|
38
38
|
* @param {boolean} props.filterChannel - The filter channel for the API request
|
|
39
|
-
* @param {number} props.limit_query -
|
|
39
|
+
* @param {number} props.limit_query - 0 means unlimited, 1 means only one result
|
|
40
40
|
* @param {number} props.limit_select - The limit user can select (0 means unlimited)
|
|
41
41
|
* @param {T[]} props.options - The options for the API request
|
|
42
42
|
* @param {keyof T | "name_plus_username"} props.key_name - The key_name to display search results (option[key_name])
|
|
@@ -19,6 +19,15 @@ interface BreadcrumbProps {
|
|
|
19
19
|
/**
|
|
20
20
|
* Modern breadcrumb component for InstinctHub NextJS application
|
|
21
21
|
* Automatically generates breadcrumb from current path
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <Breadcrumb homeLabel="Home" pathMapping={{ "/courses": "Courses" }} excludePaths={["/courses/1"]} />
|
|
25
|
+
* ```
|
|
26
|
+
* @param {string} props.homeLabel - The label for the home page
|
|
27
|
+
* @param {Record<string, string>} props.pathMapping - The mapping of path segments to display names
|
|
28
|
+
* @param {string[]} props.excludePaths - The paths to exclude from the breadcrumb
|
|
29
|
+
* @param {string} props.className - The class name for the breadcrumb container
|
|
30
|
+
*
|
|
22
31
|
*/
|
|
23
32
|
declare const Breadcrumb: ({ homeLabel, pathMapping, excludePaths, className, }: BreadcrumbProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
24
33
|
export default Breadcrumb;
|
|
@@ -88,8 +88,8 @@ export type SearchParamsType = {
|
|
|
88
88
|
[key: string]: string;
|
|
89
89
|
};
|
|
90
90
|
export interface SearchParamsPageProps {
|
|
91
|
-
params: SearchParamsType
|
|
92
|
-
searchParams: SearchParamsType
|
|
91
|
+
params: Promise<SearchParamsType>;
|
|
92
|
+
searchParams: Promise<SearchParamsType>;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Response interface for S3 uploads
|