@dgshahr/ui-kit 0.0.70 → 0.0.72

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,7 +1,8 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  interface AccordionGroupProps {
3
- defaultActiveKey?: string;
3
+ defaultActiveKey?: string | string[];
4
4
  className?: string;
5
+ disableAccordion?: boolean;
5
6
  }
6
7
  declare const AccordionGroup: FC<PropsWithChildren<AccordionGroupProps>>;
7
8
  export default AccordionGroup;
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionGroup.d.ts","sourceRoot":"","sources":["../../src/components/Accordion/AccordionGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGnD,UAAU,mBAAmB;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAgB9D,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"AccordionGroup.d.ts","sourceRoot":"","sources":["../../src/components/Accordion/AccordionGroup.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGnD,UAAU,mBAAmB;IAC3B,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAcD,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAkB9D,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { FC, PropsWithChildren, ReactNode } from 'react';
2
2
  interface AccordionItemProps {
3
- title: string | ReactNode;
3
+ title: ReactNode;
4
4
  accordionKey?: string;
5
5
  className?: string;
6
6
  contentClassName?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../src/components/Accordion/AccordionItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK9D,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAiD5D,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"AccordionItem.d.ts","sourceRoot":"","sources":["../../src/components/Accordion/AccordionItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK9D,UAAU,kBAAkB;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CA0D5D,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,5 +1,5 @@
1
1
  interface IAccordionContext {
2
- activeKey: string | null;
2
+ activeKey: string | string[] | null;
3
3
  setActiveKey: (key: IAccordionContext['activeKey']) => void;
4
4
  }
5
5
  export declare const accordionContext: import('react').Context<IAccordionContext>;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/components/Accordion/context.ts"],"names":[],"mappings":"AAEA,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CAC7D;AAED,eAAO,MAAM,gBAAgB,4CAG3B,CAAC;AAEH,eAAO,MAAM,gBAAgB,yBAAqC,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/components/Accordion/context.ts"],"names":[],"mappings":"AAEA,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,YAAY,EAAE,CAAC,GAAG,EAAE,iBAAiB,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CAC7D;AAED,eAAO,MAAM,gBAAgB,4CAG3B,CAAC;AAEH,eAAO,MAAM,gBAAgB,yBAAqC,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../assets/styles.css');;/* empty css */const o=require("../AccordionItem-D6fa9S1H.cjs");exports.AccordionGroup=o.AccordionGroup;exports.AccordionItem=o.AccordionItem;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('../assets/styles.css');;/* empty css */const o=require("../AccordionItem-U3jVG5e6.cjs");exports.AccordionGroup=o.AccordionGroup;exports.AccordionItem=o.AccordionItem;
@@ -1,5 +1,5 @@
1
1
  import '../assets/styles.css';/* empty css */
2
- import { A as a, a as i } from "../AccordionItem-DVi9UM43.js";
2
+ import { A as a, a as i } from "../AccordionItem-249c_E9c.js";
3
3
  export {
4
4
  a as AccordionGroup,
5
5
  i as AccordionItem
@@ -0,0 +1,85 @@
1
+ "use client";
2
+ import { jsx as s, jsxs as k } from "react/jsx-runtime";
3
+ import { c as d } from "./clsx-OuTLNxxd.js";
4
+ import { createContext as p, useContext as x, useState as v, useId as w } from "react";
5
+ import { A } from "./ArrowDown2-CMeKw_vj.js";
6
+ import N from "./Divider/index.js";
7
+ const m = p({
8
+ activeKey: null,
9
+ setActiveKey: () => {
10
+ }
11
+ }), I = () => x(m);
12
+ function b(i, e = !1) {
13
+ if (!i) return e ? [] : null;
14
+ const o = Array.isArray(i);
15
+ return e ? o ? i : [i] : o ? i[0] : i;
16
+ }
17
+ const S = (i) => {
18
+ const { defaultActiveKey: e, className: o, children: a, disableAccordion: u } = i, [l, t] = v(
19
+ b(e, u)
20
+ );
21
+ return /* @__PURE__ */ s("div", { className: d("dgs-ui-kit-flex dgs-ui-kit-flex-col", o), children: /* @__PURE__ */ s(
22
+ m.Provider,
23
+ {
24
+ value: {
25
+ activeKey: l,
26
+ setActiveKey: t
27
+ },
28
+ children: a
29
+ }
30
+ ) });
31
+ }, G = (i) => {
32
+ const { children: e, title: o, accordionKey: a, className: u, contentClassName: l } = i, { activeKey: t, setActiveKey: c } = I(), f = w(), r = a ?? f, g = Array.isArray(t), n = g ? t.includes(r) : r === t;
33
+ function h() {
34
+ c(n ? g ? t.filter((y) => y !== r) : null : g ? [...t, r] : r);
35
+ }
36
+ return /* @__PURE__ */ k("div", { className: d("dgs-ui-kit-bg-white dgs-ui-kit-px-4 dgs-ui-kit-pt-4", u), children: [
37
+ /* @__PURE__ */ k(
38
+ "button",
39
+ {
40
+ className: d(
41
+ "dgs-ui-kit-flex dgs-ui-kit-justify-between dgs-ui-kit-items-center dgs-ui-kit-w-full",
42
+ n ? "dgs-ui-kit-text-primary-500" : "dgs-ui-kit-text-gray-600"
43
+ ),
44
+ onClick: h,
45
+ children: [
46
+ /* @__PURE__ */ s("div", { className: n ? "dgs-ui-kit-font-h5-bold" : "dgs-ui-kit-font-p1-medium", children: o }),
47
+ /* @__PURE__ */ s(
48
+ A,
49
+ {
50
+ className: d(
51
+ "dgs-ui-kit-transition dgs-ui-kit-duration-300 dgs-ui-kit-ease-in-out dgs-ui-kit-shrink-0 dgs-ui-kit-w-auto dgs-ui-kit-h-auto",
52
+ n && "dgs-ui-kit-rotate-180"
53
+ ),
54
+ width: 20,
55
+ height: 20
56
+ }
57
+ )
58
+ ]
59
+ }
60
+ ),
61
+ /* @__PURE__ */ s(
62
+ "div",
63
+ {
64
+ className: d(
65
+ "dgs-ui-kit-grid dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-600 dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-duration-300 dgs-ui-kit-ease-in-out",
66
+ n ? "dgs-ui-kit-grid-rows-[1fr] dgs-ui-kit-opacity-100 dgs-ui-kit-mt-3" : "dgs-ui-kit-grid-rows-[0fr] dgs-ui-kit-opacity-0",
67
+ l
68
+ ),
69
+ children: /* @__PURE__ */ s("div", { className: "dgs-ui-kit-overflow-hidden", children: e })
70
+ }
71
+ ),
72
+ /* @__PURE__ */ s(
73
+ N,
74
+ {
75
+ type: "horizontal",
76
+ color: "white",
77
+ className: "dgs-ui-kit-mt-4"
78
+ }
79
+ )
80
+ ] });
81
+ };
82
+ export {
83
+ S as A,
84
+ G as a
85
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";const t=require("react/jsx-runtime"),n=require("./clsx-C11secjj.cjs"),u=require("react"),y=require("./ArrowDown2-O11Hxz6e.cjs"),w=require("./Divider/index.cjs"),x=u.createContext({activeKey:null,setActiveKey:()=>{}}),v=()=>u.useContext(x);function A(i,e=!1){if(!i)return e?[]:null;const r=Array.isArray(i);return e?r?i:[i]:r?i[0]:i}const j=i=>{const{defaultActiveKey:e,className:r,children:a,disableAccordion:l}=i,[g,s]=u.useState(A(e,l));return t.jsx("div",{className:n.clsx("dgs-ui-kit-flex dgs-ui-kit-flex-col",r),children:t.jsx(x.Provider,{value:{activeKey:g,setActiveKey:s},children:a})})},N=i=>{const{children:e,title:r,accordionKey:a,className:l,contentClassName:g}=i,{activeKey:s,setActiveKey:d}=v(),m=u.useId(),o=a??m,k=Array.isArray(s),c=k?s.includes(o):o===s;function f(){d(c?k?s.filter(h=>h!==o):null:k?[...s,o]:o)}return t.jsxs("div",{className:n.clsx("dgs-ui-kit-bg-white dgs-ui-kit-px-4 dgs-ui-kit-pt-4",l),children:[t.jsxs("button",{className:n.clsx("dgs-ui-kit-flex dgs-ui-kit-justify-between dgs-ui-kit-items-center dgs-ui-kit-w-full",c?"dgs-ui-kit-text-primary-500":"dgs-ui-kit-text-gray-600"),onClick:f,children:[t.jsx("div",{className:c?"dgs-ui-kit-font-h5-bold":"dgs-ui-kit-font-p1-medium",children:r}),t.jsx(y.ArrowDown2Icon,{className:n.clsx("dgs-ui-kit-transition dgs-ui-kit-duration-300 dgs-ui-kit-ease-in-out dgs-ui-kit-shrink-0 dgs-ui-kit-w-auto dgs-ui-kit-h-auto",c&&"dgs-ui-kit-rotate-180"),width:20,height:20})]}),t.jsx("div",{className:n.clsx("dgs-ui-kit-grid dgs-ui-kit-font-p1-regular dgs-ui-kit-text-gray-600 dgs-ui-kit-overflow-hidden dgs-ui-kit-transition-all dgs-ui-kit-duration-300 dgs-ui-kit-ease-in-out",c?"dgs-ui-kit-grid-rows-[1fr] dgs-ui-kit-opacity-100 dgs-ui-kit-mt-3":"dgs-ui-kit-grid-rows-[0fr] dgs-ui-kit-opacity-0",g),children:t.jsx("div",{className:"dgs-ui-kit-overflow-hidden",children:e})}),t.jsx(w,{type:"horizontal",color:"white",className:"dgs-ui-kit-mt-4"})]})};exports.AccordionGroup=j;exports.AccordionItem=N;
@@ -1,8 +1,4 @@
1
- import { Dispatch, SetStateAction } from 'react';
2
1
  import { SelectProps } from './types';
3
- type OptionsProps<T> = Partial<SelectProps<T>> & {
4
- setIsShowOptions: Dispatch<SetStateAction<boolean>>;
5
- };
6
- declare const Options: <T>(props: OptionsProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ declare const Options: <T>(props: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
7
3
  export default Options;
8
4
  //# sourceMappingURL=Options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Options.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Select/Options.tsx"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,WAAW,EAAgD,MAAM,SAAS,CAAC;AAGzF,KAAK,YAAY,CAAC,CAAC,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG;IAC/C,gBAAgB,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;CACrD,CAAC;AAIF,QAAA,MAAM,OAAO,GAAI,CAAC,SAAU,YAAY,CAAC,CAAC,CAAC,4CAiK1C,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Options.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Select/Options.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAgD,MAAM,SAAS,CAAC;AAOzF,QAAA,MAAM,OAAO,GAAI,CAAC,SAAU,WAAW,CAAC,CAAC,CAAC,4CAuLzC,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1 +1 @@
1
- "use client";"use strict";require('../../assets/styles.css');const t=require("react/jsx-runtime"),l=require("../../clsx-C11secjj.cjs"),n=require("react"),B=require("../../ArrowDown2-O11Hxz6e.cjs"),H=require("../Checkbox/index.cjs"),D=require("../Input/index.cjs"),P=require("../../Drawer/index.cjs");;/* empty css */const U=r=>{const i=n.useRef(null);return n.useEffect(()=>{const s=o=>{i.current&&!i.current.contains(o.target)&&r()};return document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}},[i,r]),i},$=r=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...r,children:t.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M11.767 20.755a8.989 8.989 0 1 0 0-17.977 8.989 8.989 0 0 0 0 17.977M18.018 18.485 21.542 22"})});function z({label:r,isMultiple:i,isActive:s,disabled:o}){return i?t.jsx(H,{checked:s,label:r,readOnly:!0,disabled:o}):r}const V=r=>{const{option:i,onClick:s,value:o,mode:p,optionCellClassName:k,optionCell:u}=r;function f(){return Array.isArray(o)?o.includes(i.value):i.value===o}return t.jsx("button",{onClick:s,className:l.clsx("dgs-ui-kit-w-full dgs-ui-kit-text-start dgs-ui-kit-px-3 disabled:dgs-ui-kit-cursor-not-allowed dgs-ui-kit-py-3 dgs-ui-kit-font-p1-regular disabled:dgs-ui-kit-bg-gray-50 dgs-ui-kit-transition",f()?"dgs-ui-kit-bg-primary-50 dgs-ui-kit-text-primary-500":"dgs-ui-kit-text-gray-700 disabled:dgs-ui-kit-text-gray-400",k),disabled:i.disabled,children:u?u(i,f()):z({label:i.label,isMultiple:p==="multiple",isActive:f(),disabled:i.disabled??!1})})},M=n.memo(V),W=20,L=r=>{const{options:i,mode:s="single",afterOptions:o,beforOptions:p,onChange:k,searchable:u=!0,setIsShowOptions:f,separateSelectedOptions:m=!0,optionsTitle:d="عنوان‌ها",value:g,optionCellClassName:v}=r,[c,h]=n.useState(""),[w,y]=n.useState(0),x=n.useRef(null),j=l.clsx("dgs-ui-kit-border-t dgs-ui-kit-border-solid dgs-ui-kit-border-gray-100",(!u&&!p||s==="multiple"&&m)&&"first-of-type:dgs-ui-kit-border-t-0",!!o&&"last-of-type:dgs-ui-kit-border-b");let C;const b=u;typeof u=="boolean"?C=u:C=Object.keys(u).length>0;const O=n.useMemo(()=>c?i?.filter(e=>e.label.includes(c)):i,[c,i]),T=n.useMemo(()=>s==="multiple"&&m?i?.filter(e=>g.includes(e.value))??[]:[],[i,g]),F=n.useMemo(()=>{let e=O;s==="multiple"&&m&&(e=e?.filter(S=>!g.includes(S.value)));const a=Math.min(w+W,e?.length??0);return e?.slice(w,a)},[O,w,g]),N=x?.current?.children[0]?.clientHeight??50,_=(O?.length??0)*N,I=n.useCallback(()=>{const e=x?.current?.parentElement;if(!e)return;const a=e.scrollTop,S=x.current.offsetTop,A=Math.floor((a-S)/N);y(A>=0?A:0)},[N]);n.useEffect(()=>{const e=x.current?.parentElement;if(e)return e.addEventListener("scroll",I),()=>e.removeEventListener("scroll",I)},[I]);const E=n.useCallback(e=>{if(typeof k=="function")if(s==="multiple"){const a=[...g??[]];a.includes(e)?a.splice(a.indexOf(e),1):a.push(e),k(a)}else k(e),f(!1)},[g]);return t.jsxs(t.Fragment,{children:[C&&t.jsx(D,{wrapperClassName:l.clsx("dgs-ui-kit-sticky dgs-ui-kit-top-0 dgs-ui-kit-pt-3 dgs-ui-kit-right-0 dgs-ui-kit-bg-white dgs-ui-kit-z-10 dgs-ui-kit-px-3",p?"dgs-ui-kit-pb-2":"dgs-ui-kit-pb-3",b?.wrapperClassName),placeholder:b?.placeholder??"جستجوی عنوان",onChange:e=>h(e.currentTarget.value),rightIcon:b?.rightIcon??t.jsx($,{width:20,height:20}),autoFocus:!0,...typeof u=="object"?u:{}}),p,s==="multiple"&&m&&T.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"dgs-ui-kit-font-p2-regular dgs-ui-kit-text-gray-400 dgs-ui-kit-px-3 dgs-ui-kit-py-2",children:`${d}‌ی انتخاب شده`}),T.map(e=>t.jsx(M,{onClick:()=>E(e.value),option:e,optionCellClassName:l.clsx(j,v),...r},e.value))]}),t.jsxs(t.Fragment,{children:[s==="multiple"&&m&&t.jsx("p",{className:"dgs-ui-kit-font-p2-regular dgs-ui-kit-text-gray-400 dgs-ui-kit-px-3 dgs-ui-kit-py-2",children:d}),t.jsx("div",{ref:x,className:"dgs-ui-kit-relative",style:{height:_},children:F?.map((e,a)=>t.jsx("div",{className:l.clsx("dgs-ui-kit-absolute dgs-ui-kit-w-full",j),style:{top:`${(w+a)*N}px`},children:t.jsx(M,{onClick:()=>E(e.value),option:e,...r})},e.value))})]}),o]})},R="dgs-ui-kit-duration-300",q=400;function G(r,i){return Array.isArray(r)?i.filter(s=>r.includes(s.value)).map(s=>s.label).join(", "):i.find(s=>s.value===r)?.label??""}const J=r=>{const{options:i,optionsContainer:s="popover",className:o,customInput:p,inputProps:k,drawerProps:u,popoverClassName:f,value:m,isLoading:d,searchable:g=!0,disabled:v=d}=r,[c,h]=n.useState(!1),[w,y]=n.useState(!1),x=U(()=>{s==="popover"&&c&&(h(!1),setTimeout(()=>{y(!1)},q))});function j(){if(v||d)return;!c?(y(!0),setTimeout(()=>{h(!0)},0)):(h(!1),setTimeout(()=>{y(!1)},q))}const C={...r,setIsShowOptions:h},b=l.clsx({"!dgs-ui-kit-cursor-not-allowed":v,"!dgs-ui-kit-cursor-wait":d,"!dgs-ui-kit-cursor-pointer":!d&&!v});return t.jsxs("div",{ref:x,className:l.clsx("dgs-ui-kit-relative",o),children:[t.jsx("button",{className:l.clsx("dgs-ui-kit-w-full",b),onClick:j,children:p?p(c):t.jsx(D,{leftIcon:d?t.jsx("div",{className:"dot-flashing dgs-ui-kit-mr-2"}):t.jsx(B.ArrowDown2Icon,{width:20,height:20,className:l.clsx("dgs-ui-kit-transition",R,{"dgs-ui-kit-rotate-180":c})}),containerClassName:l.clsx(b,{"dgs-ui-kit-items-baseline":d}),className:l.clsx("dgs-ui-kit-caret-transparent",b),value:G(m,i),disabled:v,...k})}),w&&t.jsx(t.Fragment,{children:s==="popover"?t.jsx("div",{className:l.clsx("dgs-ui-kit-absolute dgs-ui-kit-min-w-[300px] dgs-ui-kit-bottom-0 dgs-ui-kit-right-0 dgs-ui-kit-translate-y-[calc(100%+8px)] dgs-ui-kit-overflow-y-auto dgs-ui-kit-overflow-x-hidden dgs-ui-kit-shadow-lg dgs-ui-kit-w-full dgs-ui-kit-max-h-[360px] dgs-ui-kit-transition-all dgs-ui-kit-bg-white dgs-ui-kit-z-50 dgs-ui-kit-rounded-lg dgs-ui-kit-border dgs-ui-kit-border-solid dgs-ui-kit-border-gray-200 dgs-ui-kit-pb-3",R,c?"dgs-ui-kit-opacity-100":"dgs-ui-kit-opacity-0 dgs-ui-kit-max-h-0 dgs-ui-kit-overflow-y-hidden",{"dgs-ui-kit-pt-3":!g},f),children:t.jsx(L,{...C})}):t.jsx(P,{open:c,onClose:()=>h(!1),containerClassName:l.clsx("!dgs-ui-kit-pb-3 !dgs-ui-kit-px-0",g?"!dgs-ui-kit-pt-0":"!dgs-ui-kit-pt-3"),...u,children:t.jsx(L,{...C})})})]})};module.exports=J;
1
+ "use client";"use strict";require('../../assets/styles.css');const t=require("react/jsx-runtime"),u=require("../../clsx-C11secjj.cjs"),l=require("react"),B=require("../Checkbox/index.cjs"),F=require("../../Button/index.cjs"),D=require("../Input/index.cjs"),V=require("../../Drawer/index.cjs"),z=require("../../ArrowDown2-O11Hxz6e.cjs");;/* empty css */const H=r=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...r,children:t.jsx("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M11.767 20.755a8.989 8.989 0 1 0 0-17.977 8.989 8.989 0 0 0 0 17.977M18.018 18.485 21.542 22"})});function U(r,i=100){if(!r)return;const e=document.createElement("input");e.style.position="absolute",e.style.top=`${r.offsetTop+7}px`,e.style.left=`${r.offsetLeft}px`,e.style.height="0px",e.style.opacity="0px",document.body.appendChild(e),e.focus(),setTimeout(()=>{r.focus(),r.click(),document.body.removeChild(e)},i)}function K({label:r,isMultiple:i,isActive:e,disabled:o}){return i?t.jsx(B,{checked:e,label:r,readOnly:!0,disabled:o}):r}const G=r=>{const{option:i,onClick:e,value:o,mode:n,optionCellClassName:k,optionCell:a}=r;function c(){return Array.isArray(o)?o.includes(i.value):i.value===o}return t.jsx("button",{onClick:e,className:u.clsx("dgs-ui-kit-w-full dgs-ui-kit-text-start dgs-ui-kit-px-3 disabled:dgs-ui-kit-cursor-not-allowed dgs-ui-kit-py-3 dgs-ui-kit-font-p1-regular disabled:dgs-ui-kit-bg-gray-50 dgs-ui-kit-transition",c()?"dgs-ui-kit-bg-primary-50 dgs-ui-kit-text-primary-500":"dgs-ui-kit-text-gray-700 disabled:dgs-ui-kit-text-gray-400",k),disabled:i.disabled,children:a?a(i,c()):K({label:i.label,isMultiple:n==="multiple",isActive:c(),disabled:i.disabled??!1})})},W=l.memo(G),_=l.createContext({toggleWrapperVisibility:()=>{}}),J=()=>l.useContext(_),Q=20,X=r=>{const{options:i,mode:e="single",afterOptions:o,beforOptions:n,onChange:k,searchable:a=!0,separateSelectedOptions:c=!0,optionsTitle:y="عنوان‌ها",value:m,optionCellClassName:x,emptyContent:h="نتیجه‌ای یافت نشد !",showClearButtonOnEmpty:v=!0}=r,[f,p]=l.useState(""),[b,C]=l.useState(0),g=l.useRef(null),{toggleWrapperVisibility:N}=J(),A=u.clsx("dgs-ui-kit-border-t dgs-ui-kit-border-solid dgs-ui-kit-border-gray-100",(!a&&!n||e==="multiple"&&c)&&"first-of-type:dgs-ui-kit-border-t-0",!!o&&"last-of-type:dgs-ui-kit-border-b");let w;const I=a;typeof a=="boolean"?w=a:w=Object.keys(a).length>0;const O=l.useMemo(()=>f?i?.filter(s=>s.label.includes(f)):i,[f,i]),T=l.useMemo(()=>e==="multiple"&&c?i?.filter(s=>m.includes(s.value))??[]:[],[i,m]),L=l.useMemo(()=>{let s=O;e==="multiple"&&c&&(s=s?.filter(S=>!m.includes(S.value)));const d=Math.min(b+Q,s?.length??0);return s?.slice(b,d)},[O,b,m]),j=g?.current?.children[0]?.clientHeight??50,$=(O?.length??0)*j,E=l.useCallback(()=>{const s=g?.current?.parentElement;if(!s)return;const d=s.scrollTop,S=g.current.offsetTop,P=Math.floor((d-S)/j);C(P>=0?P:0)},[j]);l.useEffect(()=>{const s=g.current?.parentElement;if(s)return s.addEventListener("scroll",E),()=>s.removeEventListener("scroll",E)},[E]),l.useEffect(()=>{w&&U(document.getElementById("search-input"),400)},[]);const M=l.useCallback(s=>{if(typeof k=="function")if(e==="multiple"){const d=[...m??[]];d.includes(s)?d.splice(d.indexOf(s),1):d.push(s),k(d)}else k(s),N()},[m]);return t.jsxs(t.Fragment,{children:[w&&t.jsx(D,{id:"search-input",wrapperClassName:u.clsx("dgs-ui-kit-sticky dgs-ui-kit-top-0 dgs-ui-kit-pt-3 dgs-ui-kit-right-0 dgs-ui-kit-bg-white dgs-ui-kit-z-10 dgs-ui-kit-px-3",n?"dgs-ui-kit-pb-2":"dgs-ui-kit-pb-3",I?.wrapperClassName),placeholder:I?.placeholder??"جستجوی عنوان",value:f,onChange:s=>p(s.currentTarget.value),rightIcon:I?.rightIcon??t.jsx(H,{width:20,height:20}),...typeof a=="object"?a:{}}),n,e==="multiple"&&c&&T.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"dgs-ui-kit-font-p2-regular dgs-ui-kit-text-gray-400 dgs-ui-kit-px-3 dgs-ui-kit-py-2",children:`${y}‌ی انتخاب شده`}),T.map(s=>t.jsx(W,{onClick:()=>M(s.value),option:s,optionCellClassName:u.clsx(A,x),...r},s.value))]}),t.jsxs(t.Fragment,{children:[e==="multiple"&&c&&t.jsx("p",{className:"dgs-ui-kit-font-p2-regular dgs-ui-kit-text-gray-400 dgs-ui-kit-px-3 dgs-ui-kit-py-2",children:y}),t.jsx("div",{ref:g,className:"dgs-ui-kit-relative",style:{height:$},children:L?.map((s,d)=>t.jsx("div",{className:u.clsx("dgs-ui-kit-absolute dgs-ui-kit-w-full",A),style:{top:`${(b+d)*j}px`},children:t.jsx(W,{onClick:()=>M(s.value),option:s,...r})},s.value))}),!L?.length&&!T.length&&t.jsxs("div",{className:"dgs-ui-kit-text-center dgs-ui-kit-flex dgs-ui-kit-flex-col dgs-ui-kit-items-center dgs-ui-kit-mt-2",children:[t.jsx("p",{className:"dgs-ui-kit-text-gray-500 dgs-ui-kit-font-p3-medium",children:h}),v&&t.jsx(F,{className:"dgs-ui-kit-mt-1",variant:"text",size:"small",onClick:()=>p(""),children:"پاک کردن"})]})]}),o]})},Y=r=>{const i=l.useRef(null);return l.useEffect(()=>{const e=o=>{i.current&&!i.current.contains(o.target)&&r()};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}},[i,r]),i},q="dgs-ui-kit-duration-300",R=400,Z=r=>{const{dropdownType:i="popover",disabled:e,isLoading:o,wrapperClassName:n,customInput:k,children:a,drawerProps:c,inputProps:y,popoverClassName:m}=r,[x,h]=l.useState(!1),[v,f]=l.useState(!1);let p;const b=Y(()=>{i==="popover"&&x&&(h(!1),p&&clearTimeout(p),p=setTimeout(()=>{f(!1)},R))});function C(){if(e||o)return;const N=!v;p&&clearTimeout(p),N?(f(!0),p=setTimeout(()=>{h(!0)},0)):(h(!1),p=setTimeout(()=>{f(!1)},R))}const g=u.clsx({"!dgs-ui-kit-cursor-not-allowed":e,"!dgs-ui-kit-cursor-wait":o,"!dgs-ui-kit-cursor-pointer":!o&&!e});return t.jsxs("div",{ref:b,className:u.clsx("dgs-ui-kit-relative",n),children:[t.jsx("button",{className:u.clsx("dgs-ui-kit-w-full",g),onClick:C,children:k?k(x):t.jsx(D,{leftIcon:o?t.jsx("div",{className:"dot-flashing dgs-ui-kit-mr-2"}):t.jsx(z.ArrowDown2Icon,{width:20,height:20,className:u.clsx("dgs-ui-kit-transition",q,{"dgs-ui-kit-rotate-180":x})}),containerClassName:u.clsx(g,{"dgs-ui-kit-items-baseline":o}),className:u.clsx("dgs-ui-kit-caret-transparent",g),disabled:e,...y})}),t.jsx(_.Provider,{value:{toggleWrapperVisibility:C},children:v&&t.jsx(t.Fragment,{children:i==="popover"?t.jsx("div",{className:u.clsx("dgs-ui-kit-absolute dgs-ui-kit-min-w-[300px] dgs-ui-kit-bottom-0 dgs-ui-kit-right-0 dgs-ui-kit-translate-y-[calc(100%+8px)] dgs-ui-kit-overflow-y-auto dgs-ui-kit-overflow-x-hidden dgs-ui-kit-shadow-lg dgs-ui-kit-w-full dgs-ui-kit-max-h-[360px] dgs-ui-kit-transition-all dgs-ui-kit-bg-white dgs-ui-kit-z-50 dgs-ui-kit-rounded-lg dgs-ui-kit-border dgs-ui-kit-border-solid dgs-ui-kit-border-gray-200 dgs-ui-kit-pb-3",q,x?"dgs-ui-kit-opacity-100":"dgs-ui-kit-opacity-0 dgs-ui-kit-max-h-0 dgs-ui-kit-overflow-y-hidden",m),children:a}):t.jsx(V,{...c,open:x,onClose:()=>h(!1),containerClassName:u.clsx("!dgs-ui-kit-pb-3 !dgs-ui-kit-px-0",c?.containerClassName),children:a})})})]})};function ee(r,i){return Array.isArray(r)?i.filter(e=>r.includes(e.value)).map(e=>e.label).join(", "):i.find(e=>e.value===r)?.label??""}const te=r=>{const{searchable:i=!0,value:e,options:o}=r,n={...r};return n.dropdownType==="popover"&&!i&&(n.popoverClassName=u.clsx("dgs-ui-kit-pt-3",n.popoverClassName)),n.dropdownType==="drawer"&&(n.drawerProps={...n.drawerProps,containerClassName:u.clsx(i?"!dgs-ui-kit-pt-0":"!dgs-ui-kit-pt-3",n.drawerProps?.containerClassName)}),n.customInput||(n.inputProps={...n.inputProps,value:ee(e,o)}),t.jsx(Z,{...n,children:t.jsx(X,{...r})})};module.exports=te;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Select/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3C,OAAO,kBAAkB,CAAC;AAgB1B,QAAA,MAAM,MAAM,GAAI,CAAC,SAAU,WAAW,CAAC,CAAC,CAAC,4CA2HxC,CAAC;AAEF,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Select/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,OAAO,kBAAkB,CAAC;AAa1B,QAAA,MAAM,MAAM,GAAI,CAAC,SAAU,WAAW,CAAC,CAAC,CAAC,4CAsBxC,CAAC;AAEF,eAAe,MAAM,CAAC"}