@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.
- package/dist/components/UserSelectionSection/index.cjs.js +1 -1
- package/dist/components/UserSelectionSection/index.es.js +40 -37
- package/dist/components/UserSelectionSection/types.d.ts +7 -5
- package/dist/components/UserSelectionSection/utils.cjs.js +1 -1
- package/dist/components/UserSelectionSection/utils.d.ts +1 -1
- package/dist/components/UserSelectionSection/utils.es.js +5 -5
- package/package.json +1 -1
|
@@ -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"),
|
|
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
|
|
2
|
-
import { Box as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { wrapperBoxStyle as
|
|
5
|
-
import { defaultTranslations as
|
|
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
|
|
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
|
|
15
|
-
const [
|
|
16
|
-
|
|
17
|
-
closeList: () =>
|
|
18
|
-
})),
|
|
19
|
-
const e =
|
|
20
|
-
|
|
21
|
-
}, [
|
|
22
|
-
const
|
|
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
|
-
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
38
|
+
Y,
|
|
35
39
|
{
|
|
36
40
|
name: "search",
|
|
37
41
|
placeholder: l.searchPlaceholder,
|
|
38
42
|
fullWidth: !0,
|
|
39
|
-
value:
|
|
40
|
-
onChange:
|
|
43
|
+
value: p,
|
|
44
|
+
onChange: R
|
|
41
45
|
}
|
|
42
46
|
),
|
|
43
|
-
|
|
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(
|
|
46
|
-
|
|
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: () =>
|
|
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(
|
|
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
|
-
|
|
62
|
+
Z.displayName = "UserSelectionSection";
|
|
60
63
|
export {
|
|
61
|
-
|
|
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:
|
|
12
|
-
selectedUsers:
|
|
13
|
-
onUserSelectionChange: (newSelectedUsers:
|
|
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
|
|
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:
|
|
35
|
+
users: User[];
|
|
34
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="Users selection",
|
|
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
|
|
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
|
-
|
|
12
|
-
|
|
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.
|
|
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",
|