@dgshahr/ui-kit 0.0.71 → 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 +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,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,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;AAIf,OAAO,KAAK,EAAE,WAAW,EAAgD,MAAM,SAAS,CAAC;AAIzF,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,4CAuL1C,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"),r=require("react"),z=require("../../ArrowDown2-O11Hxz6e.cjs"),H=require("../Checkbox/index.cjs"),P=require("../../Button/index.cjs"),B=require("../Input/index.cjs"),U=require("../../Drawer/index.cjs");;/* empty css */const K=s=>{const n=r.useRef(null);return r.useEffect(()=>{const e=o=>{n.current&&!n.current.contains(o.target)&&s()};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}},[n,s]),n},V=s=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...s,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 W(s,n=100){if(!s)return;const e=document.createElement("input");e.style.position="absolute",e.style.top=`${s.offsetTop+7}px`,e.style.left=`${s.offsetLeft}px`,e.style.height="0px",e.style.opacity="0px",document.body.appendChild(e),e.focus(),setTimeout(()=>{s.focus(),s.click(),document.body.removeChild(e)},n)}function G({label:s,isMultiple:n,isActive:e,disabled:o}){return n?t.jsx(H,{checked:e,label:s,readOnly:!0,disabled:o}):s}const J=s=>{const{option:n,onClick:e,value:o,mode:g,optionCellClassName:m,optionCell:u}=s;function f(){return Array.isArray(o)?o.includes(n.value):n.value===o}return t.jsx("button",{onClick:e,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",m),disabled:n.disabled,children:u?u(n,f()):G({label:n.label,isMultiple:g==="multiple",isActive:f(),disabled:n.disabled??!1})})},R=r.memo(J),Q=20,D=s=>{const{options:n,mode:e="single",afterOptions:o,beforOptions:g,onChange:m,searchable:u=!0,setIsShowOptions:f,separateSelectedOptions:h=!0,optionsTitle:c="عنوان‌ها",value:d,optionCellClassName:b,emptyContent:p="نتیجه‌ای یافت نشد !",showClearButtonOnEmpty:x=!0}=s,[v,y]=r.useState(""),[C,O]=r.useState(0),k=r.useRef(null),w=l.clsx("dgs-ui-kit-border-t dgs-ui-kit-border-solid dgs-ui-kit-border-gray-100",(!u&&!g||e==="multiple"&&h)&&"first-of-type:dgs-ui-kit-border-t-0",!!o&&"last-of-type:dgs-ui-kit-border-b");let j;const I=u;typeof u=="boolean"?j=u:j=Object.keys(u).length>0;const S=r.useMemo(()=>v?n?.filter(i=>i.label.includes(v)):n,[v,n]),E=r.useMemo(()=>e==="multiple"&&h?n?.filter(i=>d.includes(i.value))??[]:[],[n,d]),L=r.useMemo(()=>{let i=S;e==="multiple"&&h&&(i=i?.filter(A=>!d.includes(A.value)));const a=Math.min(C+Q,i?.length??0);return i?.slice(C,a)},[S,C,d]),N=k?.current?.children[0]?.clientHeight??50,F=(S?.length??0)*N,T=r.useCallback(()=>{const i=k?.current?.parentElement;if(!i)return;const a=i.scrollTop,A=k.current.offsetTop,q=Math.floor((a-A)/N);O(q>=0?q:0)},[N]);r.useEffect(()=>{const i=k.current?.parentElement;if(i)return i.addEventListener("scroll",T),()=>i.removeEventListener("scroll",T)},[T]),r.useEffect(()=>{j&&W(document.getElementById("search-input"),400)},[]);const M=r.useCallback(i=>{if(typeof m=="function")if(e==="multiple"){const a=[...d??[]];a.includes(i)?a.splice(a.indexOf(i),1):a.push(i),m(a)}else m(i),f(!1)},[d]);return t.jsxs(t.Fragment,{children:[j&&t.jsx(B,{id:"search-input",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",g?"dgs-ui-kit-pb-2":"dgs-ui-kit-pb-3",I?.wrapperClassName),placeholder:I?.placeholder??"جستجوی عنوان",value:v,onChange:i=>y(i.currentTarget.value),rightIcon:I?.rightIcon??t.jsx(V,{width:20,height:20}),...typeof u=="object"?u:{}}),g,e==="multiple"&&h&&E.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:`${c}‌ی انتخاب شده`}),E.map(i=>t.jsx(R,{onClick:()=>M(i.value),option:i,optionCellClassName:l.clsx(w,b),...s},i.value))]}),t.jsxs(t.Fragment,{children:[e==="multiple"&&h&&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:c}),t.jsx("div",{ref:k,className:"dgs-ui-kit-relative",style:{height:F},children:L?.map((i,a)=>t.jsx("div",{className:l.clsx("dgs-ui-kit-absolute dgs-ui-kit-w-full",w),style:{top:`${(C+a)*N}px`},children:t.jsx(R,{onClick:()=>M(i.value),option:i,...s})},i.value))}),!L?.length&&!E.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:p}),x&&t.jsx(P,{className:"dgs-ui-kit-mt-1",variant:"text",size:"small",onClick:()=>y(""),children:"پاک کردن"})]})]}),o]})},_="dgs-ui-kit-duration-300",$=400;function X(s,n){return Array.isArray(s)?n.filter(e=>s.includes(e.value)).map(e=>e.label).join(", "):n.find(e=>e.value===s)?.label??""}const Y=s=>{const{options:n,optionsContainer:e="popover",className:o,customInput:g,inputProps:m,drawerProps:u,popoverClassName:f,value:h,isLoading:c,searchable:d=!0,disabled:b=c}=s,[p,x]=r.useState(!1),[v,y]=r.useState(!1),C=K(()=>{e==="popover"&&p&&(x(!1),setTimeout(()=>{y(!1)},$))});function O(){if(b||c)return;!p?(y(!0),setTimeout(()=>{x(!0)},0)):(x(!1),setTimeout(()=>{y(!1)},$))}const k={...s,setIsShowOptions:x},w=l.clsx({"!dgs-ui-kit-cursor-not-allowed":b,"!dgs-ui-kit-cursor-wait":c,"!dgs-ui-kit-cursor-pointer":!c&&!b});return t.jsxs("div",{ref:C,className:l.clsx("dgs-ui-kit-relative",o),children:[t.jsx("button",{className:l.clsx("dgs-ui-kit-w-full",w),onClick:O,children:g?g(p):t.jsx(B,{leftIcon:c?t.jsx("div",{className:"dot-flashing dgs-ui-kit-mr-2"}):t.jsx(z.ArrowDown2Icon,{width:20,height:20,className:l.clsx("dgs-ui-kit-transition",_,{"dgs-ui-kit-rotate-180":p})}),containerClassName:l.clsx(w,{"dgs-ui-kit-items-baseline":c}),className:l.clsx("dgs-ui-kit-caret-transparent",w),value:X(h,n),disabled:b,...m})}),v&&t.jsx(t.Fragment,{children:e==="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",_,p?"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":!d},f),children:t.jsx(D,{...k})}):t.jsx(U,{open:p,onClose:()=>x(!1),containerClassName:l.clsx("!dgs-ui-kit-pb-3 !dgs-ui-kit-px-0",d?"!dgs-ui-kit-pt-0":"!dgs-ui-kit-pt-3"),...u,children:t.jsx(D,{...k})})})]})};module.exports=Y;
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"}
@@ -1,24 +1,14 @@
1
1
  "use client";
2
- import { jsx as n, jsxs as N, Fragment as I } from "react/jsx-runtime";
3
- import { c as r } from "../../clsx-OuTLNxxd.js";
4
- import { useRef as K, useEffect as B, memo as q, useState as S, useMemo as j, useCallback as z } from "react";
5
- import { A as G } from "../../ArrowDown2-CMeKw_vj.js";
6
- import J from "../Checkbox/index.js";
7
- import Q from "../../Button/index.js";
8
- import V from "../Input/index.js";
9
- import X from "../../Drawer/index.js";
2
+ import { jsx as r, jsxs as y, Fragment as I } from "react/jsx-runtime";
3
+ import { c as l } from "../../clsx-OuTLNxxd.js";
4
+ import { memo as q, createContext as G, useContext as J, useState as O, useRef as H, useMemo as W, useCallback as R, useEffect as M } from "react";
5
+ import Q from "../Checkbox/index.js";
6
+ import X from "../../Button/index.js";
7
+ import U from "../Input/index.js";
8
+ import Y from "../../Drawer/index.js";
9
+ import { A as Z } from "../../ArrowDown2-CMeKw_vj.js";
10
10
  import '../../assets/styles.css';/* empty css */
11
- const Y = (i) => {
12
- const s = K(null);
13
- return B(() => {
14
- const t = (o) => {
15
- s.current && !s.current.contains(o.target) && i();
16
- };
17
- return document.addEventListener("click", t, !0), () => {
18
- document.removeEventListener("click", t, !0);
19
- };
20
- }, [s, i]), s;
21
- }, Z = (i) => /* @__PURE__ */ n(
11
+ const tt = (s) => /* @__PURE__ */ r(
22
12
  "svg",
23
13
  {
24
14
  xmlns: "http://www.w3.org/2000/svg",
@@ -26,8 +16,8 @@ const Y = (i) => {
26
16
  height: "1em",
27
17
  fill: "none",
28
18
  viewBox: "0 0 24 24",
29
- ...i,
30
- children: /* @__PURE__ */ n(
19
+ ...s,
20
+ children: /* @__PURE__ */ r(
31
21
  "path",
32
22
  {
33
23
  stroke: "currentColor",
@@ -39,176 +29,178 @@ const Y = (i) => {
39
29
  )
40
30
  }
41
31
  );
42
- function tt(i, s = 100) {
43
- if (!i) return;
32
+ function et(s, e = 100) {
33
+ if (!s) return;
44
34
  const t = document.createElement("input");
45
- t.style.position = "absolute", t.style.top = `${i.offsetTop + 7}px`, t.style.left = `${i.offsetLeft}px`, t.style.height = "0px", t.style.opacity = "0px", document.body.appendChild(t), t.focus(), setTimeout(() => {
46
- i.focus(), i.click(), document.body.removeChild(t);
47
- }, s);
35
+ t.style.position = "absolute", t.style.top = `${s.offsetTop + 7}px`, t.style.left = `${s.offsetLeft}px`, t.style.height = "0px", t.style.opacity = "0px", document.body.appendChild(t), t.focus(), setTimeout(() => {
36
+ s.focus(), s.click(), document.body.removeChild(t);
37
+ }, e);
48
38
  }
49
- function et({
50
- label: i,
51
- isMultiple: s,
39
+ function it({
40
+ label: s,
41
+ isMultiple: e,
52
42
  isActive: t,
53
43
  disabled: o
54
44
  }) {
55
- return s ? /* @__PURE__ */ n(
56
- J,
45
+ return e ? /* @__PURE__ */ r(
46
+ Q,
57
47
  {
58
48
  checked: t,
59
- label: i,
49
+ label: s,
60
50
  readOnly: !0,
61
51
  disabled: o
62
52
  }
63
- ) : i;
53
+ ) : s;
64
54
  }
65
- const it = (i) => {
66
- const { option: s, onClick: t, value: o, mode: c, optionCellClassName: m, optionCell: l } = i;
67
- function k() {
68
- return Array.isArray(o) ? o.includes(s.value) : s.value === o;
55
+ const st = (s) => {
56
+ const { option: e, onClick: t, value: o, mode: n, optionCellClassName: g, optionCell: a } = s;
57
+ function u() {
58
+ return Array.isArray(o) ? o.includes(e.value) : e.value === o;
69
59
  }
70
- return /* @__PURE__ */ n(
60
+ return /* @__PURE__ */ r(
71
61
  "button",
72
62
  {
73
63
  onClick: t,
74
- className: r(
64
+ className: l(
75
65
  "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",
76
- k() ? "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",
77
- m
66
+ u() ? "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",
67
+ g
78
68
  ),
79
- disabled: s.disabled,
80
- children: l ? l(s, k()) : et({
81
- label: s.label,
82
- isMultiple: c === "multiple",
83
- isActive: k(),
84
- disabled: s.disabled ?? !1
69
+ disabled: e.disabled,
70
+ children: a ? a(e, u()) : it({
71
+ label: e.label,
72
+ isMultiple: n === "multiple",
73
+ isActive: u(),
74
+ disabled: e.disabled ?? !1
85
75
  })
86
76
  }
87
77
  );
88
- }, H = q(it), st = 20, P = (i) => {
78
+ }, _ = q(st), F = G({
79
+ toggleWrapperVisibility: () => {
80
+ }
81
+ }), rt = () => J(F), nt = 20, ot = (s) => {
89
82
  const {
90
- options: s,
83
+ options: e,
91
84
  mode: t = "single",
92
85
  afterOptions: o,
93
- beforOptions: c,
94
- onChange: m,
95
- searchable: l = !0,
96
- setIsShowOptions: k,
97
- separateSelectedOptions: f = !0,
98
- optionsTitle: a = "عنوان‌ها",
99
- value: d,
100
- optionCellClassName: b,
101
- emptyContent: g = "نتیجه‌ای یافت نشد !",
102
- showClearButtonOnEmpty: h = !0
103
- } = i, [v, y] = S(""), [x, E] = S(0), p = K(null), C = r(
86
+ beforOptions: n,
87
+ onChange: g,
88
+ searchable: a = !0,
89
+ separateSelectedOptions: u = !0,
90
+ optionsTitle: v = "عنوان‌ها",
91
+ value: m,
92
+ optionCellClassName: f,
93
+ emptyContent: h = "نتیجه‌ای یافت نشد !",
94
+ showClearButtonOnEmpty: C = !0
95
+ } = s, [k, c] = O(""), [b, w] = O(0), p = H(null), { toggleWrapperVisibility: T } = rt(), $ = l(
104
96
  "dgs-ui-kit-border-t dgs-ui-kit-border-solid dgs-ui-kit-border-gray-100",
105
- (!l && !c || t === "multiple" && f) && "first-of-type:dgs-ui-kit-border-t-0",
97
+ (!a && !n || t === "multiple" && u) && "first-of-type:dgs-ui-kit-border-t-0",
106
98
  !!o && "last-of-type:dgs-ui-kit-border-b"
107
99
  );
108
- let w;
109
- const T = l;
110
- typeof l == "boolean" ? w = l : w = Object.keys(l).length > 0;
111
- const A = j(() => v ? s?.filter((e) => e.label.includes(v)) : s, [v, s]), L = j(() => t === "multiple" && f ? s?.filter((e) => d.includes(e.value)) ?? [] : [], [s, d]), D = j(() => {
112
- let e = A;
113
- t === "multiple" && f && (e = e?.filter(($) => !d.includes($.value)));
114
- const u = Math.min(x + st, e?.length ?? 0);
115
- return e?.slice(x, u);
116
- }, [A, x, d]), O = p?.current?.children[0]?.clientHeight ?? 50, W = (A?.length ?? 0) * O, M = z(() => {
117
- const e = p?.current?.parentElement;
118
- if (!e) return;
119
- const u = e.scrollTop, $ = p.current.offsetTop, _ = Math.floor((u - $) / O);
120
- E(_ >= 0 ? _ : 0);
121
- }, [O]);
122
- B(() => {
123
- const e = p.current?.parentElement;
124
- if (e)
125
- return e.addEventListener("scroll", M), () => e.removeEventListener("scroll", M);
126
- }, [M]), B(() => {
127
- w && tt(document.getElementById("search-input"), 400);
100
+ let x;
101
+ const E = a;
102
+ typeof a == "boolean" ? x = a : x = Object.keys(a).length > 0;
103
+ const S = W(() => k ? e?.filter((i) => i.label.includes(k)) : e, [k, e]), A = W(() => t === "multiple" && u ? e?.filter((i) => m.includes(i.value)) ?? [] : [], [e, m]), j = W(() => {
104
+ let i = S;
105
+ t === "multiple" && u && (i = i?.filter((P) => !m.includes(P.value)));
106
+ const d = Math.min(b + nt, i?.length ?? 0);
107
+ return i?.slice(b, d);
108
+ }, [S, b, m]), N = p?.current?.children[0]?.clientHeight ?? 50, K = (S?.length ?? 0) * N, L = R(() => {
109
+ const i = p?.current?.parentElement;
110
+ if (!i) return;
111
+ const d = i.scrollTop, P = p.current.offsetTop, D = Math.floor((d - P) / N);
112
+ w(D >= 0 ? D : 0);
113
+ }, [N]);
114
+ M(() => {
115
+ const i = p.current?.parentElement;
116
+ if (i)
117
+ return i.addEventListener("scroll", L), () => i.removeEventListener("scroll", L);
118
+ }, [L]), M(() => {
119
+ x && et(document.getElementById("search-input"), 400);
128
120
  }, []);
129
- const R = z(
130
- (e) => {
131
- if (typeof m == "function")
121
+ const B = R(
122
+ (i) => {
123
+ if (typeof g == "function")
132
124
  if (t === "multiple") {
133
- const u = [...d ?? []];
134
- u.includes(e) ? u.splice(u.indexOf(e), 1) : u.push(e), m(u);
125
+ const d = [...m ?? []];
126
+ d.includes(i) ? d.splice(d.indexOf(i), 1) : d.push(i), g(d);
135
127
  } else
136
- m(e), k(!1);
128
+ g(i), T();
137
129
  },
138
- [d]
130
+ [m]
139
131
  );
140
- return /* @__PURE__ */ N(I, { children: [
141
- w && /* @__PURE__ */ n(
142
- V,
132
+ return /* @__PURE__ */ y(I, { children: [
133
+ x && /* @__PURE__ */ r(
134
+ U,
143
135
  {
144
136
  id: "search-input",
145
- wrapperClassName: r(
137
+ wrapperClassName: l(
146
138
  "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",
147
- c ? "dgs-ui-kit-pb-2" : "dgs-ui-kit-pb-3",
148
- T?.wrapperClassName
139
+ n ? "dgs-ui-kit-pb-2" : "dgs-ui-kit-pb-3",
140
+ E?.wrapperClassName
149
141
  ),
150
- placeholder: T?.placeholder ?? "جستجوی عنوان",
151
- value: v,
152
- onChange: (e) => y(e.currentTarget.value),
153
- rightIcon: T?.rightIcon ?? /* @__PURE__ */ n(
154
- Z,
142
+ placeholder: E?.placeholder ?? "جستجوی عنوان",
143
+ value: k,
144
+ onChange: (i) => c(i.currentTarget.value),
145
+ rightIcon: E?.rightIcon ?? /* @__PURE__ */ r(
146
+ tt,
155
147
  {
156
148
  width: 20,
157
149
  height: 20
158
150
  }
159
151
  ),
160
- ...typeof l == "object" ? l : {}
152
+ ...typeof a == "object" ? a : {}
161
153
  }
162
154
  ),
163
- c,
164
- t === "multiple" && f && L.length > 0 && /* @__PURE__ */ N(I, { children: [
165
- /* @__PURE__ */ n("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: `${a}‌ی انتخاب شده` }),
166
- L.map((e) => /* @__PURE__ */ n(
167
- H,
155
+ n,
156
+ t === "multiple" && u && A.length > 0 && /* @__PURE__ */ y(I, { children: [
157
+ /* @__PURE__ */ r("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: `${v}‌ی انتخاب شده` }),
158
+ A.map((i) => /* @__PURE__ */ r(
159
+ _,
168
160
  {
169
- onClick: () => R(e.value),
170
- option: e,
171
- optionCellClassName: r(C, b),
172
- ...i
161
+ onClick: () => B(i.value),
162
+ option: i,
163
+ optionCellClassName: l($, f),
164
+ ...s
173
165
  },
174
- e.value
166
+ i.value
175
167
  ))
176
168
  ] }),
177
- /* @__PURE__ */ N(I, { children: [
178
- t === "multiple" && f && /* @__PURE__ */ n("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: a }),
179
- /* @__PURE__ */ n(
169
+ /* @__PURE__ */ y(I, { children: [
170
+ t === "multiple" && u && /* @__PURE__ */ r("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: v }),
171
+ /* @__PURE__ */ r(
180
172
  "div",
181
173
  {
182
174
  ref: p,
183
175
  className: "dgs-ui-kit-relative",
184
- style: { height: W },
185
- children: D?.map((e, u) => /* @__PURE__ */ n(
176
+ style: { height: K },
177
+ children: j?.map((i, d) => /* @__PURE__ */ r(
186
178
  "div",
187
179
  {
188
- className: r("dgs-ui-kit-absolute dgs-ui-kit-w-full", C),
189
- style: { top: `${(x + u) * O}px` },
190
- children: /* @__PURE__ */ n(
191
- H,
180
+ className: l("dgs-ui-kit-absolute dgs-ui-kit-w-full", $),
181
+ style: { top: `${(b + d) * N}px` },
182
+ children: /* @__PURE__ */ r(
183
+ _,
192
184
  {
193
- onClick: () => R(e.value),
194
- option: e,
195
- ...i
185
+ onClick: () => B(i.value),
186
+ option: i,
187
+ ...s
196
188
  }
197
189
  )
198
190
  },
199
- e.value
191
+ i.value
200
192
  ))
201
193
  }
202
194
  ),
203
- !D?.length && !L.length && /* @__PURE__ */ N("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: [
204
- /* @__PURE__ */ n("p", { className: "dgs-ui-kit-text-gray-500 dgs-ui-kit-font-p3-medium", children: g }),
205
- h && /* @__PURE__ */ n(
206
- Q,
195
+ !j?.length && !A.length && /* @__PURE__ */ y("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: [
196
+ /* @__PURE__ */ r("p", { className: "dgs-ui-kit-text-gray-500 dgs-ui-kit-font-p3-medium", children: h }),
197
+ C && /* @__PURE__ */ r(
198
+ X,
207
199
  {
208
200
  className: "dgs-ui-kit-mt-1",
209
201
  variant: "text",
210
202
  size: "small",
211
- onClick: () => y(""),
203
+ onClick: () => c(""),
212
204
  children: "پاک کردن"
213
205
  }
214
206
  )
@@ -216,108 +208,131 @@ const it = (i) => {
216
208
  ] }),
217
209
  o
218
210
  ] });
219
- }, U = "dgs-ui-kit-duration-300", F = 400;
220
- function nt(i, s) {
221
- return Array.isArray(i) ? s.filter((t) => i.includes(t.value)).map((t) => t.label).join(", ") : s.find((t) => t.value === i)?.label ?? "";
222
- }
223
- const mt = (i) => {
211
+ }, lt = (s) => {
212
+ const e = H(null);
213
+ return M(() => {
214
+ const t = (o) => {
215
+ e.current && !e.current.contains(o.target) && s();
216
+ };
217
+ return document.addEventListener("click", t, !0), () => {
218
+ document.removeEventListener("click", t, !0);
219
+ };
220
+ }, [e, s]), e;
221
+ }, V = "dgs-ui-kit-duration-300", z = 400, at = (s) => {
224
222
  const {
225
- options: s,
226
- optionsContainer: t = "popover",
227
- className: o,
228
- customInput: c,
229
- inputProps: m,
230
- drawerProps: l,
231
- popoverClassName: k,
232
- value: f,
233
- isLoading: a,
234
- searchable: d = !0,
235
- disabled: b = a
236
- } = i, [g, h] = S(!1), [v, y] = S(!1), x = Y(() => {
237
- t === "popover" && g && (h(!1), setTimeout(() => {
238
- y(!1);
239
- }, F));
223
+ dropdownType: e = "popover",
224
+ disabled: t,
225
+ isLoading: o,
226
+ wrapperClassName: n,
227
+ customInput: g,
228
+ children: a,
229
+ drawerProps: u,
230
+ inputProps: v,
231
+ popoverClassName: m
232
+ } = s, [f, h] = O(!1), [C, k] = O(!1);
233
+ let c;
234
+ const b = lt(() => {
235
+ e === "popover" && f && (h(!1), c && clearTimeout(c), c = setTimeout(() => {
236
+ k(!1);
237
+ }, z));
240
238
  });
241
- function E() {
242
- if (b || a) return;
243
- !g ? (y(!0), setTimeout(() => {
239
+ function w() {
240
+ if (t || o) return;
241
+ const T = !C;
242
+ c && clearTimeout(c), T ? (k(!0), c = setTimeout(() => {
244
243
  h(!0);
245
- }, 0)) : (h(!1), setTimeout(() => {
246
- y(!1);
247
- }, F));
244
+ }, 0)) : (h(!1), c = setTimeout(() => {
245
+ k(!1);
246
+ }, z));
248
247
  }
249
- const p = {
250
- ...i,
251
- setIsShowOptions: h
252
- }, C = r({
253
- "!dgs-ui-kit-cursor-not-allowed": b,
254
- "!dgs-ui-kit-cursor-wait": a,
255
- "!dgs-ui-kit-cursor-pointer": !a && !b
248
+ const p = l({
249
+ "!dgs-ui-kit-cursor-not-allowed": t,
250
+ "!dgs-ui-kit-cursor-wait": o,
251
+ "!dgs-ui-kit-cursor-pointer": !o && !t
256
252
  });
257
- return /* @__PURE__ */ N(
253
+ return /* @__PURE__ */ y(
258
254
  "div",
259
255
  {
260
- ref: x,
261
- className: r("dgs-ui-kit-relative", o),
256
+ ref: b,
257
+ className: l("dgs-ui-kit-relative", n),
262
258
  children: [
263
- /* @__PURE__ */ n(
259
+ /* @__PURE__ */ r(
264
260
  "button",
265
261
  {
266
- className: r("dgs-ui-kit-w-full", C),
267
- onClick: E,
268
- children: c ? c(g) : /* @__PURE__ */ n(
269
- V,
262
+ className: l("dgs-ui-kit-w-full", p),
263
+ onClick: w,
264
+ children: g ? g(f) : /* @__PURE__ */ r(
265
+ U,
270
266
  {
271
- leftIcon: a ? /* @__PURE__ */ n("div", { className: "dot-flashing dgs-ui-kit-mr-2" }) : /* @__PURE__ */ n(
272
- G,
267
+ leftIcon: o ? /* @__PURE__ */ r("div", { className: "dot-flashing dgs-ui-kit-mr-2" }) : /* @__PURE__ */ r(
268
+ Z,
273
269
  {
274
270
  width: 20,
275
271
  height: 20,
276
- className: r("dgs-ui-kit-transition", U, {
277
- "dgs-ui-kit-rotate-180": g
272
+ className: l("dgs-ui-kit-transition", V, {
273
+ "dgs-ui-kit-rotate-180": f
278
274
  })
279
275
  }
280
276
  ),
281
- containerClassName: r(C, {
282
- "dgs-ui-kit-items-baseline": a
277
+ containerClassName: l(p, {
278
+ "dgs-ui-kit-items-baseline": o
283
279
  }),
284
- className: r("dgs-ui-kit-caret-transparent", C),
285
- value: nt(f, s),
286
- disabled: b,
287
- ...m
280
+ className: l("dgs-ui-kit-caret-transparent", p),
281
+ disabled: t,
282
+ ...v
288
283
  }
289
284
  )
290
285
  }
291
286
  ),
292
- v && /* @__PURE__ */ n(I, { children: t === "popover" ? /* @__PURE__ */ n(
293
- "div",
287
+ /* @__PURE__ */ r(
288
+ F.Provider,
294
289
  {
295
- className: r(
296
- "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",
297
- U,
298
- g ? "dgs-ui-kit-opacity-100" : "dgs-ui-kit-opacity-0 dgs-ui-kit-max-h-0 dgs-ui-kit-overflow-y-hidden",
299
- { "dgs-ui-kit-pt-3": !d },
300
- k
301
- ),
302
- children: /* @__PURE__ */ n(P, { ...p })
303
- }
304
- ) : /* @__PURE__ */ n(
305
- X,
306
- {
307
- open: g,
308
- onClose: () => h(!1),
309
- containerClassName: r(
310
- "!dgs-ui-kit-pb-3 !dgs-ui-kit-px-0",
311
- d ? "!dgs-ui-kit-pt-0" : "!dgs-ui-kit-pt-3"
312
- ),
313
- ...l,
314
- children: /* @__PURE__ */ n(P, { ...p })
290
+ value: {
291
+ toggleWrapperVisibility: w
292
+ },
293
+ children: C && /* @__PURE__ */ r(I, { children: e === "popover" ? /* @__PURE__ */ r(
294
+ "div",
295
+ {
296
+ className: l(
297
+ "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",
298
+ V,
299
+ f ? "dgs-ui-kit-opacity-100" : "dgs-ui-kit-opacity-0 dgs-ui-kit-max-h-0 dgs-ui-kit-overflow-y-hidden",
300
+ m
301
+ ),
302
+ children: a
303
+ }
304
+ ) : /* @__PURE__ */ r(
305
+ Y,
306
+ {
307
+ ...u,
308
+ open: f,
309
+ onClose: () => h(!1),
310
+ containerClassName: l(
311
+ "!dgs-ui-kit-pb-3 !dgs-ui-kit-px-0",
312
+ u?.containerClassName
313
+ ),
314
+ children: a
315
+ }
316
+ ) })
315
317
  }
316
- ) })
318
+ )
317
319
  ]
318
320
  }
319
321
  );
320
322
  };
323
+ function ut(s, e) {
324
+ return Array.isArray(s) ? e.filter((t) => s.includes(t.value)).map((t) => t.label).join(", ") : e.find((t) => t.value === s)?.label ?? "";
325
+ }
326
+ const yt = (s) => {
327
+ const { searchable: e = !0, value: t, options: o } = s, n = { ...s };
328
+ return n.dropdownType === "popover" && !e && (n.popoverClassName = l("dgs-ui-kit-pt-3", n.popoverClassName)), n.dropdownType === "drawer" && (n.drawerProps = {
329
+ ...n.drawerProps,
330
+ containerClassName: l(
331
+ e ? "!dgs-ui-kit-pt-0" : "!dgs-ui-kit-pt-3",
332
+ n.drawerProps?.containerClassName
333
+ )
334
+ }), n.customInput || (n.inputProps = { ...n.inputProps, value: ut(t, o) }), /* @__PURE__ */ r(at, { ...n, children: /* @__PURE__ */ r(ot, { ...s }) });
335
+ };
321
336
  export {
322
- mt as default
337
+ yt as default
323
338
  };
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import { DrawerProps } from '../../Drawer';
3
2
  import { InputProps } from '../Input';
3
+ import { PickerWrapperProps } from '../Wrappers/PickerWrapper/type';
4
4
  export type Option<T> = {
5
5
  value: T;
6
6
  label: string;
@@ -10,11 +10,8 @@ type SelectPropsBase<T> = {
10
10
  options: Option<T>[];
11
11
  optionsContainer?: 'drawer' | 'popover';
12
12
  searchable?: boolean | Omit<InputProps, 'onChange'>;
13
- isLoading?: boolean;
14
- disabled?: boolean;
15
13
  optionCell?: (option: Option<T>, isActive: boolean) => ReactNode;
16
14
  optionCellClassName?: string;
17
- className?: string;
18
15
  beforOptions?: ReactNode;
19
16
  afterOptions?: ReactNode;
20
17
  emptyContent?: ReactNode;
@@ -34,24 +31,6 @@ export type SelectWithMultipleMode<T> = {
34
31
  optionsTitle?: string;
35
32
  separateSelectedOptions?: boolean;
36
33
  };
37
- type SelectWithCustomInput = {
38
- customInput?: (isShowOptions: boolean) => ReactNode;
39
- inputProps?: never;
40
- };
41
- type SelectWithoutCustomInput = {
42
- inputProps?: Omit<InputProps, 'leftIcon' | 'id'>;
43
- customInput?: never;
44
- };
45
- type SelectWithDrawerContainer = {
46
- optionsContainer: 'drawer';
47
- drawerProps?: Omit<DrawerProps, 'children' | 'onClose' | 'open'>;
48
- popoverClassName?: never;
49
- };
50
- type SelectWithPopoverContainer = {
51
- optionsContainer?: 'popover';
52
- popoverClassName?: string;
53
- drawerProps?: never;
54
- };
55
- export type SelectProps<T> = SelectPropsBase<T> & (SelectWithSingleMode<T> | SelectWithMultipleMode<T>) & (SelectWithoutCustomInput | SelectWithCustomInput) & (SelectWithDrawerContainer | SelectWithPopoverContainer);
34
+ export type SelectProps<T> = SelectPropsBase<T> & Omit<PickerWrapperProps, 'children'> & (SelectWithSingleMode<T> | SelectWithMultipleMode<T>);
56
35
  export {};
57
36
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Select/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IACtB,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACpD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,KAAK,SAAS,CAAC;IACjE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,uBAAuB,CAAC,EAAE,KAAK,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,WAAW,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,SAAS,CAAC;IACpD,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC9B,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC,CAAC;IACjD,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC;IACjE,gBAAgB,CAAC,EAAE,KAAK,CAAC;CAC1B,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,GAC7C,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,GACrD,CAAC,wBAAwB,GAAG,qBAAqB,CAAC,GAClD,CAAC,yBAAyB,GAAG,0BAA0B,CAAC,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Form/Select/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI;IACtB,KAAK,EAAE,CAAC,CAAC;IACT,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,KAAK,eAAe,CAAC,CAAC,IAAI;IACxB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACxC,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,KAAK,SAAS,CAAC;IACjE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAAI;IACpC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,uBAAuB,CAAC,EAAE,KAAK,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;IACtC,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,GAC7C,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,GACpC,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { PickerWrapperProps } from './type';
3
+ declare const PickerWrapper: FC<PickerWrapperProps>;
4
+ export default PickerWrapper;
5
+ //# sourceMappingURL=PickerWrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PickerWrapper.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/Wrappers/PickerWrapper/PickerWrapper.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAK1C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAGjD,OAAO,kBAAkB,CAAC;AAM1B,QAAA,MAAM,aAAa,EAAE,EAAE,CAAC,kBAAkB,CA4HzC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface IPickerWrapperContext {
2
+ toggleWrapperVisibility: () => void;
3
+ }
4
+ export declare const pickerWrapperContext: import('react').Context<IPickerWrapperContext>;
5
+ export declare const usePickerWrapper: () => IPickerWrapperContext;
6
+ export {};
7
+ //# sourceMappingURL=contexts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contexts.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/Wrappers/PickerWrapper/contexts.ts"],"names":[],"mappings":"AAEA,UAAU,qBAAqB;IAC7B,uBAAuB,EAAE,MAAM,IAAI,CAAC;CACrC;AAED,eAAO,MAAM,oBAAoB,gDAE/B,CAAC;AAEH,eAAO,MAAM,gBAAgB,6BAAyC,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { ReactNode } from 'react';
2
+ import { DrawerProps } from '../../../Drawer';
3
+ import { InputProps } from '../../Input';
4
+ interface PickerWrapperPropsBase {
5
+ isLoading?: boolean;
6
+ disabled?: boolean;
7
+ wrapperClassName?: string;
8
+ children: ReactNode;
9
+ }
10
+ interface PickerWrapperWithCustomInput {
11
+ customInput?: (isOpen: boolean) => ReactNode;
12
+ inputProps?: never;
13
+ }
14
+ interface PickerWrapperWithoutCustomInput {
15
+ inputProps?: Omit<InputProps, 'leftIcon'>;
16
+ customInput?: never;
17
+ }
18
+ interface PickerWrapperWithDrawerContainer {
19
+ dropdownType: 'drawer';
20
+ drawerProps?: Omit<DrawerProps, 'children' | 'onClose' | 'open'>;
21
+ popoverClassName?: never;
22
+ }
23
+ interface PickerWrapperWithPopoverContainer {
24
+ dropdownType?: 'popover';
25
+ popoverClassName?: string;
26
+ drawerProps?: never;
27
+ }
28
+ export type PickerWrapperProps = PickerWrapperPropsBase & (PickerWrapperWithCustomInput | PickerWrapperWithoutCustomInput) & (PickerWrapperWithDrawerContainer | PickerWrapperWithPopoverContainer);
29
+ export {};
30
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/Wrappers/PickerWrapper/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,UAAU,sBAAsB;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,UAAU,4BAA4B;IACpC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,SAAS,CAAC;IAC7C,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,UAAU,+BAA+B;IACvC,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC1C,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED,UAAU,gCAAgC;IACxC,YAAY,EAAE,QAAQ,CAAC;IACvB,WAAW,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC;IACjE,gBAAgB,CAAC,EAAE,KAAK,CAAC;CAC1B;AAED,UAAU,iCAAiC;IACzC,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GACrD,CAAC,4BAA4B,GAAG,+BAA+B,CAAC,GAChE,CAAC,gCAAgC,GAAG,iCAAiC,CAAC,CAAC"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./assets/styles.css');;/* empty css */const r=require("./AccordionItem-D6fa9S1H.cjs"),o=require("./Alert/index.cjs"),t=require("./Badge/index.cjs"),i=require("./Breadcrumb/index.cjs"),n=require("./Button/index.cjs"),c=require("./Divider/index.cjs"),u=require("./Drawer/index.cjs"),s=require("./Form/Checkbox/index.cjs"),a=require("./Form/Input/index.cjs"),d=require("./Form/OtpInput/index.cjs"),q=require("./Form/RadioButton/index.cjs"),l=require("./Form/Select/index.cjs"),m=require("./Form/Textarea/index.cjs"),B=require("./Pagination/index.cjs"),p=require("./Progress/Bar/index.cjs"),e=require("./Slide-aMCvZQnM.cjs"),S=require("./Tabs/index.cjs");exports.AccordionGroup=r.AccordionGroup;exports.AccordionItem=r.AccordionItem;exports.Alert=o;exports.Badge=t;exports.Breadcrumb=i;exports.Button=n;exports.Divider=c;exports.Drawer=u;exports.Checkbox=s;exports.Input=a;exports.OtpInput=d;exports.RadioButton=q;exports.Select=l;exports.Textarea=m;exports.Pagination=B;exports.ProgressBar=p;exports.Slide=e.Slide;exports.Slider=e.Slider;exports.Tabs=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./assets/styles.css');;/* empty css */const r=require("./AccordionItem-U3jVG5e6.cjs"),o=require("./Alert/index.cjs"),t=require("./Badge/index.cjs"),i=require("./Breadcrumb/index.cjs"),n=require("./Button/index.cjs"),c=require("./Divider/index.cjs"),u=require("./Drawer/index.cjs"),s=require("./Form/Checkbox/index.cjs"),a=require("./Form/Input/index.cjs"),d=require("./Form/OtpInput/index.cjs"),q=require("./Form/RadioButton/index.cjs"),l=require("./Form/Select/index.cjs"),m=require("./Form/Textarea/index.cjs"),B=require("./Pagination/index.cjs"),p=require("./Progress/Bar/index.cjs"),e=require("./Slide-aMCvZQnM.cjs"),S=require("./Tabs/index.cjs");exports.AccordionGroup=r.AccordionGroup;exports.AccordionItem=r.AccordionItem;exports.Alert=o;exports.Badge=t;exports.Breadcrumb=i;exports.Button=n;exports.Divider=c;exports.Drawer=u;exports.Checkbox=s;exports.Input=a;exports.OtpInput=d;exports.RadioButton=q;exports.Select=l;exports.Textarea=m;exports.Pagination=B;exports.ProgressBar=p;exports.Slide=e.Slide;exports.Slider=e.Slider;exports.Tabs=S;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import './assets/styles.css';/* empty css */
2
- import { A as o, a as t } from "./AccordionItem-DVi9UM43.js";
2
+ import { A as o, a as t } from "./AccordionItem-249c_E9c.js";
3
3
  import { default as d } from "./Alert/index.js";
4
4
  import { default as s } from "./Badge/index.js";
5
5
  import { default as m } from "./Breadcrumb/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dgshahr/ui-kit",
3
- "version": "0.0.71",
3
+ "version": "0.0.72",
4
4
  "description": "dgshahr ui-kit",
5
5
  "author": "dgshahr",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- "use client";"use strict";const i=require("react/jsx-runtime"),s=require("./clsx-C11secjj.cjs"),e=require("react"),m=require("./ArrowDown2-O11Hxz6e.cjs"),h=require("./Divider/index.cjs"),g=e.createContext({activeKey:null,setActiveKey:()=>{}}),v=()=>e.useContext(g),y=c=>{const{defaultActiveKey:o=null,className:d,children:u}=c,[n,r]=e.useState(o);return i.jsx("div",{className:s.clsx("dgs-ui-kit-flex dgs-ui-kit-flex-col",d),children:i.jsx(g.Provider,{value:{activeKey:n,setActiveKey:r},children:u})})},f=c=>{const{children:o,title:d,accordionKey:u,className:n,contentClassName:r}=c,{activeKey:k,setActiveKey:a}=v(),x=e.useId(),l=u??x,t=l===k;return i.jsxs("div",{className:s.clsx("dgs-ui-kit-bg-white dgs-ui-kit-px-4 dgs-ui-kit-pt-4",n),children:[i.jsxs("button",{className:s.clsx("dgs-ui-kit-flex dgs-ui-kit-justify-between dgs-ui-kit-items-center dgs-ui-kit-w-full",t?"dgs-ui-kit-text-primary-500":"dgs-ui-kit-text-gray-600"),onClick:()=>{a(t?null:l)},children:[i.jsx("div",{className:t?"dgs-ui-kit-font-h5-bold":"dgs-ui-kit-font-p1-medium",children:d}),i.jsx(m.ArrowDown2Icon,{className:s.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",t&&"dgs-ui-kit-rotate-180"),width:20,height:20})]}),i.jsx("div",{className:s.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",t?"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",r),children:i.jsx("div",{className:"dgs-ui-kit-overflow-hidden",children:o})}),i.jsx(h,{type:"horizontal",color:"white",className:"dgs-ui-kit-mt-4"})]})};exports.AccordionGroup=y;exports.AccordionItem=f;
@@ -1,76 +0,0 @@
1
- "use client";
2
- import { jsx as i, jsxs as l } from "react/jsx-runtime";
3
- import { c as s } from "./clsx-OuTLNxxd.js";
4
- import { createContext as f, useContext as h, useState as v, useId as y } from "react";
5
- import { A as p } from "./ArrowDown2-CMeKw_vj.js";
6
- import x from "./Divider/index.js";
7
- const g = f({
8
- activeKey: null,
9
- setActiveKey: () => {
10
- }
11
- }), w = () => h(g), b = (e) => {
12
- const { defaultActiveKey: o = null, className: d, children: c } = e, [r, u] = v(o);
13
- return /* @__PURE__ */ i("div", { className: s("dgs-ui-kit-flex dgs-ui-kit-flex-col", d), children: /* @__PURE__ */ i(
14
- g.Provider,
15
- {
16
- value: {
17
- activeKey: r,
18
- setActiveKey: u
19
- },
20
- children: c
21
- }
22
- ) });
23
- }, j = (e) => {
24
- const { children: o, title: d, accordionKey: c, className: r, contentClassName: u } = e, { activeKey: k, setActiveKey: a } = w(), m = y(), n = c ?? m, t = n === k;
25
- return /* @__PURE__ */ l("div", { className: s("dgs-ui-kit-bg-white dgs-ui-kit-px-4 dgs-ui-kit-pt-4", r), children: [
26
- /* @__PURE__ */ l(
27
- "button",
28
- {
29
- className: s(
30
- "dgs-ui-kit-flex dgs-ui-kit-justify-between dgs-ui-kit-items-center dgs-ui-kit-w-full",
31
- t ? "dgs-ui-kit-text-primary-500" : "dgs-ui-kit-text-gray-600"
32
- ),
33
- onClick: () => {
34
- a(t ? null : n);
35
- },
36
- children: [
37
- /* @__PURE__ */ i("div", { className: t ? "dgs-ui-kit-font-h5-bold" : "dgs-ui-kit-font-p1-medium", children: d }),
38
- /* @__PURE__ */ i(
39
- p,
40
- {
41
- className: s(
42
- "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",
43
- t && "dgs-ui-kit-rotate-180"
44
- ),
45
- width: 20,
46
- height: 20
47
- }
48
- )
49
- ]
50
- }
51
- ),
52
- /* @__PURE__ */ i(
53
- "div",
54
- {
55
- className: s(
56
- "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",
57
- t ? "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",
58
- u
59
- ),
60
- children: /* @__PURE__ */ i("div", { className: "dgs-ui-kit-overflow-hidden", children: o })
61
- }
62
- ),
63
- /* @__PURE__ */ i(
64
- x,
65
- {
66
- type: "horizontal",
67
- color: "white",
68
- className: "dgs-ui-kit-mt-4"
69
- }
70
- )
71
- ] });
72
- };
73
- export {
74
- b as A,
75
- j as a
76
- };