@cgi-learning-hub/ui 1.1.0-dev.1724331727 → 1.1.0-dev.1724423209

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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/styles2.css');require('../../assets/styles.css');const t=require("react/jsx-runtime"),r=require("@mui/material"),n=require("react"),a=require("./style.cjs.js"),R=require("./utils.cjs.js");require("../inputs/SearchInput/SearchInput.cjs.js");const E=require("../inputs/TextInput/TextInput.cjs.js");require("../../DefaultButton-y-mHSNFH.cjs");require("../feedback/Alert/Alert.cjs.js");require("../lists/FileList/FileListItem.cjs.js");;/* empty css */;/* empty css */require("../../fr-TRjulm1Q.cjs");const q=n.forwardRef(({users:p,selectedUsers:i,onUserSelectionChange:h,minSearchLength:b=1,translations:l=R.defaultTranslations,chipVariantStyle:g="filled"},v)=>{const[s,x]=n.useState(""),[S,c]=n.useState(!1),[y,I]=n.useState([]),[m,B]=n.useState(!1),f=i.length>8,j=i.length===0;n.useImperativeHandle(v,()=>({closeList:()=>c(!1)})),n.useEffect(()=>{const e=s.toLowerCase(),o=p.reduce((d,u)=>d.length<5&&u.label.toLowerCase().includes(e)&&!i.some(_=>_.id===u.id)?[...d,u]:d,[]);I(o)},[s,p,i]);const C=e=>{const{value:o}=e.target;x(o),S||c(!0)},L=e=>{h([...i,e]),c(!1),x("")},T=e=>{h(i.filter(o=>o.id!==e.id))},w=()=>B(!0);return t.jsxs(r.Box,{sx:a.wrapperBoxStyle,children:[t.jsx(r.Typography,{variant:"h2",children:l.title}),t.jsxs(r.Box,{sx:{width:"100%",position:"relative",maxWidth:"100%"},children:[t.jsx(E,{name:"search",placeholder:l.searchPlaceholder,fullWidth:!0,value:s,onChange:C}),s.length>=b&&S&&t.jsx(r.Paper,{sx:a.paperStyle,children:y.length?t.jsx(r.List,{children:y.map(e=>t.jsx(r.ListItemButton,{onClick:()=>L(e),children:t.jsx(r.ListItemText,{primary:e.label})},e.id))}):t.jsx(r.Typography,{sx:{padding:".5rem"},variant:"body1",children:l.noResults})})]}),t.jsx(a.ChipBox,{isEmpty:j,isScrollable:m&&f,children:j?t.jsx(r.Typography,{variant:"body1",children:l.emptySelection}):i.map(e=>t.jsx(r.Chip,{color:"primary",variant:g,label:e.label,onDelete:()=>T(e),sx:{maxWidth:"20%",justifyContent:"space-betweeen"}},e.id))}),t.jsx(r.Collapse,{in:f&&!m,collapsedSize:0,children:t.jsx(r.Button,{sx:a.seeMoreButtonStyle,"data-testid":"see-more",onClick:w,children:l.expandButton})})]})});q.displayName="UserSelectionSection";exports.UserSelectionSection=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../../assets/styles2.css');require('../../assets/styles.css');const t=require("react/jsx-runtime"),i=require("@mui/material"),l=require("react"),u=require("./style.cjs.js"),O=require("./utils.cjs.js");require("../inputs/SearchInput/SearchInput.cjs.js");const P=require("../inputs/TextInput/TextInput.cjs.js");require("../../DefaultButton-y-mHSNFH.cjs");require("../feedback/Alert/Alert.cjs.js");require("../lists/FileList/FileListItem.cjs.js");;/* empty css */;/* empty css */require("../../fr-TRjulm1Q.cjs");const C=l.forwardRef(({users:f,selectedUsers:n,onUserSelectionChange:y,minSearchLength:v=1,translations:r=O.defaultTranslations,chipVariantStyle:V="filled",chipProps:I},B)=>{const[c,m]=l.useState(""),[b,h]=l.useState(!1),[p,L]=l.useState([]),[o,g]=l.useState(!1),s=8,[T,j]=l.useState(s),d=n.length>s,q=n.length===0;l.useImperativeHandle(B,()=>({closeList:()=>h(!1)})),l.useEffect(()=>{const e=c.toLowerCase(),a=f.reduce((x,S)=>x.length<5&&S.label.toLowerCase().includes(e)&&!n.some(M=>M.id===S.id)?[...x,S]:x,[]);L(a)},[c,f,n]);const w=e=>{const{value:a}=e.target;m(a),b||h(!0)},_=e=>{y([...n,e]),h(!1),m("")},E=e=>{y(n.filter(a=>a.id!==e.id))},R=()=>{g(!o),j(o?s:n.length)};return l.useEffect(()=>{d||g(!1),j(o?n.length:s)},[p]),t.jsxs(i.Box,{sx:u.wrapperBoxStyle,children:[t.jsx(i.Typography,{variant:"h2",children:r.title}),t.jsxs(i.Box,{sx:{width:"100%",position:"relative",maxWidth:"100%"},children:[t.jsx(P,{name:"search",placeholder:r.searchPlaceholder,fullWidth:!0,value:c,onChange:w}),c.length>=v&&b&&t.jsx(i.Paper,{sx:u.paperStyle,children:p.length?t.jsx(i.List,{children:p.map(e=>t.jsx(i.ListItemButton,{onClick:()=>_(e),children:t.jsx(i.ListItemText,{primary:e.label})},e.id))}):t.jsx(i.Typography,{sx:{padding:".5rem"},variant:"body1",children:r.noResults})})]}),t.jsx(u.ChipBox,{isEmpty:q,isScrollable:o&&d,children:q?t.jsx(i.Typography,{variant:"body1",children:r.emptySelection}):n.slice(0,T).map(e=>t.jsx(i.Chip,{label:e.label,onDelete:()=>E(e),sx:{maxWidth:"20%",justifyContent:"space-betweeen"},...I},e.id))}),n.length>s&&t.jsx(i.Collapse,{in:d&&!o,collapsedSize:0,children:t.jsx(i.Button,{sx:u.seeMoreButtonStyle,"data-testid":"see-more",onClick:R,children:r.expandButton})})]})});C.displayName="UserSelectionSection";exports.UserSelectionSection=C;
@@ -1,62 +1,65 @@
1
- import { jsxs as b, jsx as t } from "react/jsx-runtime";
2
- import { Box as g, Typography as c, Paper as W, List as k, ListItemButton as M, ListItemText as O, Chip as P, Collapse as z, Button as D } from "@mui/material";
3
- import { forwardRef as F, useState as n, useImperativeHandle as H, useEffect as N } from "react";
4
- import { wrapperBoxStyle as q, paperStyle as A, ChipBox as G, seeMoreButtonStyle as J } from "./style.es.js";
5
- import { defaultTranslations as K } from "./utils.es.js";
1
+ import { jsxs as v, jsx as t } from "react/jsx-runtime";
2
+ import { Box as I, Typography as f, Paper as O, List as P, ListItemButton as z, ListItemText as D, Chip as F, Collapse as H, Button as N } from "@mui/material";
3
+ import { forwardRef as q, useState as a, useImperativeHandle as A, useEffect as B } from "react";
4
+ import { wrapperBoxStyle as G, paperStyle as J, ChipBox as K, seeMoreButtonStyle as Q } from "./style.es.js";
5
+ import { defaultTranslations as X } from "./utils.es.js";
6
6
  import "../inputs/SearchInput/SearchInput.es.js";
7
- import Q from "../inputs/TextInput/TextInput.es.js";
7
+ import Y from "../inputs/TextInput/TextInput.es.js";
8
8
  import "../../DefaultButton-Ctg4CY0U.js";
9
9
  import "../feedback/Alert/Alert.es.js";
10
10
  import "../lists/FileList/FileListItem.es.js";
11
11
  import '../../assets/styles2.css';import '../../assets/styles.css';/* empty css */
12
12
  /* empty css */
13
13
  import "../../fr-C9KY9a-o.js";
14
- const V = F(({ users: d, selectedUsers: o, onUserSelectionChange: h, minSearchLength: v = 1, translations: l = K, chipVariantStyle: C = "filled" }, I) => {
15
- const [i, m] = n(""), [f, a] = n(!1), [u, B] = n([]), [x, L] = n(!1), S = o.length > 8, y = o.length === 0;
16
- H(I, () => ({
17
- closeList: () => a(!1)
18
- })), N(() => {
19
- const e = i.toLowerCase(), r = d.reduce((s, p) => s.length < 5 && p.label.toLowerCase().includes(e) && !o.some((R) => R.id === p.id) ? [...s, p] : s, []);
20
- B(r);
21
- }, [i, d, o]);
22
- const w = (e) => {
14
+ const Z = q(({ users: u, selectedUsers: i, onUserSelectionChange: x, minSearchLength: L = 1, translations: l = X, chipVariantStyle: _ = "filled", chipProps: w }, T) => {
15
+ const [p, S] = a(""), [y, s] = a(!1), [c, j] = a([]), [o, b] = a(!1), n = 8, [E, g] = a(n), h = i.length > n, C = i.length === 0;
16
+ A(T, () => ({
17
+ closeList: () => s(!1)
18
+ })), B(() => {
19
+ const e = p.toLowerCase(), r = u.reduce((d, m) => d.length < 5 && m.label.toLowerCase().includes(e) && !i.some((M) => M.id === m.id) ? [...d, m] : d, []);
20
+ j(r);
21
+ }, [p, u, i]);
22
+ const R = (e) => {
23
23
  const { value: r } = e.target;
24
- m(r), f || a(!0);
25
- }, T = (e) => {
26
- h([...o, e]), a(!1), m("");
27
- }, j = (e) => {
28
- h(o.filter((r) => r.id !== e.id));
29
- }, E = () => L(!0);
30
- return /* @__PURE__ */ b(g, { sx: q, children: [
31
- /* @__PURE__ */ t(c, { variant: "h2", children: l.title }),
32
- /* @__PURE__ */ b(g, { sx: { width: "100%", position: "relative", maxWidth: "100%" }, children: [
24
+ S(r), y || s(!0);
25
+ }, V = (e) => {
26
+ x([...i, e]), s(!1), S("");
27
+ }, W = (e) => {
28
+ x(i.filter((r) => r.id !== e.id));
29
+ }, k = () => {
30
+ b(!o), g(o ? n : i.length);
31
+ };
32
+ return B(() => {
33
+ h || b(!1), g(o ? i.length : n);
34
+ }, [c]), /* @__PURE__ */ v(I, { sx: G, children: [
35
+ /* @__PURE__ */ t(f, { variant: "h2", children: l.title }),
36
+ /* @__PURE__ */ v(I, { sx: { width: "100%", position: "relative", maxWidth: "100%" }, children: [
33
37
  /* @__PURE__ */ t(
34
- Q,
38
+ Y,
35
39
  {
36
40
  name: "search",
37
41
  placeholder: l.searchPlaceholder,
38
42
  fullWidth: !0,
39
- value: i,
40
- onChange: w
43
+ value: p,
44
+ onChange: R
41
45
  }
42
46
  ),
43
- i.length >= v && f && /* @__PURE__ */ t(W, { sx: A, children: u.length ? /* @__PURE__ */ t(k, { children: u.map((e) => /* @__PURE__ */ t(M, { onClick: () => T(e), children: /* @__PURE__ */ t(O, { primary: e.label }) }, e.id)) }) : /* @__PURE__ */ t(c, { sx: { padding: ".5rem" }, variant: "body1", children: l.noResults }) })
47
+ p.length >= L && y && /* @__PURE__ */ t(O, { sx: J, children: c.length ? /* @__PURE__ */ t(P, { children: c.map((e) => /* @__PURE__ */ t(z, { onClick: () => V(e), children: /* @__PURE__ */ t(D, { primary: e.label }) }, e.id)) }) : /* @__PURE__ */ t(f, { sx: { padding: ".5rem" }, variant: "body1", children: l.noResults }) })
44
48
  ] }),
45
- /* @__PURE__ */ t(G, { isEmpty: y, isScrollable: x && S, children: y ? /* @__PURE__ */ t(c, { variant: "body1", children: l.emptySelection }) : o.map((e) => /* @__PURE__ */ t(
46
- P,
49
+ /* @__PURE__ */ t(K, { isEmpty: C, isScrollable: o && h, children: C ? /* @__PURE__ */ t(f, { variant: "body1", children: l.emptySelection }) : i.slice(0, E).map((e) => /* @__PURE__ */ t(
50
+ F,
47
51
  {
48
- color: "primary",
49
- variant: C,
50
52
  label: e.label,
51
- onDelete: () => j(e),
52
- sx: { maxWidth: "20%", justifyContent: "space-betweeen" }
53
+ onDelete: () => W(e),
54
+ sx: { maxWidth: "20%", justifyContent: "space-betweeen" },
55
+ ...w
53
56
  },
54
57
  e.id
55
58
  )) }),
56
- /* @__PURE__ */ t(z, { in: S && !x, collapsedSize: 0, children: /* @__PURE__ */ t(D, { sx: J, "data-testid": "see-more", onClick: E, children: l.expandButton }) })
59
+ i.length > n && /* @__PURE__ */ t(H, { in: h && !o, collapsedSize: 0, children: /* @__PURE__ */ t(N, { sx: Q, "data-testid": "see-more", onClick: k, children: l.expandButton }) })
57
60
  ] });
58
61
  });
59
- V.displayName = "UserSelectionSection";
62
+ Z.displayName = "UserSelectionSection";
60
63
  export {
61
- V as UserSelectionSection
64
+ Z as UserSelectionSection
62
65
  };
@@ -1,3 +1,4 @@
1
+ import { ChipProps } from '@mui/material';
1
2
  import { ForwardRefExoticComponent, RefAttributes } from 'react';
2
3
 
3
4
  export interface UserSelectionSectionTranslations {
@@ -8,12 +9,13 @@ export interface UserSelectionSectionTranslations {
8
9
  expandButton: string;
9
10
  }
10
11
  export interface UserSelectionSectionProps {
11
- users: Users[];
12
- selectedUsers: Users[];
13
- onUserSelectionChange: (newSelectedUsers: Users[]) => void;
12
+ users: User[];
13
+ selectedUsers: User[];
14
+ onUserSelectionChange: (newSelectedUsers: User[]) => void;
14
15
  minSearchLength?: number;
15
16
  translations?: UserSelectionSectionTranslations;
16
17
  chipVariantStyle?: "outlined" | "filled";
18
+ chipProps?: ChipProps;
17
19
  }
18
20
  export interface ChipBoxProps {
19
21
  isScrollable: boolean;
@@ -24,11 +26,11 @@ export interface UserSelectionSectionRef {
24
26
  }
25
27
  export type UserSelectionSectionComponent = ForwardRefExoticComponent<UserSelectionSectionProps & RefAttributes<UserSelectionSectionRef>>;
26
28
  export type BasicValueType = string | number | boolean | null | undefined;
27
- export interface Users {
29
+ export interface User {
28
30
  id: string | number;
29
31
  label: string;
30
32
  [key: string]: BasicValueType | BasicValueType[] | Record<string, BasicValueType>;
31
33
  }
32
34
  export interface InputValueState {
33
- users: Users[];
35
+ users: User[];
34
36
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="Users selection",t="Search by first name, last name, class, or group",s="No result",o="No user, class, or group selected",n="See more...",l={title:e,searchPlaceholder:t,noResults:s,emptySelection:o,expandButton:n},a={users:[]};exports.defaultTranslations=l;exports.initialInputValue=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={users:[]},t="Users selection",s="Search by first name, last name, class, or group",o="No result",n="No user, class, or group selected",l="See more...",a={title:t,searchPlaceholder:s,noResults:o,emptySelection:n,expandButton:l};exports.defaultTranslations=a;exports.initialInputValue=e;
@@ -1,5 +1,6 @@
1
1
  import { InputValueState } from './types';
2
2
 
3
+ export declare const initialInputValue: InputValueState;
3
4
  export declare const defaultTranslations: {
4
5
  title: string;
5
6
  searchPlaceholder: string;
@@ -7,4 +8,3 @@ export declare const defaultTranslations: {
7
8
  emptySelection: string;
8
9
  expandButton: string;
9
10
  };
10
- export declare const initialInputValue: InputValueState;
@@ -1,13 +1,13 @@
1
- const e = "Users selection", s = "Search by first name, last name, class, or group", t = "No result", o = "No user, class, or group selected", n = "See more...", l = {
1
+ const l = {
2
+ users: []
3
+ }, e = "Users selection", s = "Search by first name, last name, class, or group", t = "No result", o = "No user, class, or group selected", n = "See more...", c = {
2
4
  title: e,
3
5
  searchPlaceholder: s,
4
6
  noResults: t,
5
7
  emptySelection: o,
6
8
  expandButton: n
7
- }, c = {
8
- users: []
9
9
  };
10
10
  export {
11
- l as defaultTranslations,
12
- c as initialInputValue
11
+ c as defaultTranslations,
12
+ l as initialInputValue
13
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cgi-learning-hub/ui",
3
- "version": "1.1.0-dev.1724331727",
3
+ "version": "1.1.0-dev.1724423209",
4
4
  "private": false,
5
5
  "author": "CGI Learning-hub Team",
6
6
  "description": "@cgi-learning-hub/ui is an open-source React component library that implements UI for HUB's features",