@iziui/react 0.0.93-rc → 0.0.94-rc
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/.types/core/createComponent.d.ts.map +1 -1
- package/dist/.types/feedback/Alert/Alert.d.ts.map +1 -1
- package/dist/chunks/Alert-CD6hOvos.js +2 -0
- package/dist/chunks/Alert-CD6hOvos.js.map +1 -0
- package/dist/chunks/Alert-DCB56IAI.cjs +2 -0
- package/dist/chunks/Alert-DCB56IAI.cjs.map +1 -0
- package/dist/chunks/{Box-BCKQa2JS.cjs → Box-CNg55MFq.cjs} +2 -2
- package/dist/chunks/{Box-BCKQa2JS.cjs.map → Box-CNg55MFq.cjs.map} +1 -1
- package/dist/chunks/{Box-Cs7u6zrl.js → Box-DqBZgXYR.js} +2 -2
- package/dist/chunks/{Box-Cs7u6zrl.js.map → Box-DqBZgXYR.js.map} +1 -1
- package/dist/chunks/{ButtonIcon-CJ5Iz-uJ.cjs → ButtonIcon-Ccq88QaY.cjs} +2 -2
- package/dist/chunks/{ButtonIcon-CJ5Iz-uJ.cjs.map → ButtonIcon-Ccq88QaY.cjs.map} +1 -1
- package/dist/chunks/{ButtonIcon-mMZe5V_1.js → ButtonIcon-DMetcfYt.js} +2 -2
- package/dist/chunks/{ButtonIcon-mMZe5V_1.js.map → ButtonIcon-DMetcfYt.js.map} +1 -1
- package/dist/chunks/{Card-CcOpPKfS.cjs → Card-Bqgukgip.cjs} +2 -2
- package/dist/chunks/{Card-CcOpPKfS.cjs.map → Card-Bqgukgip.cjs.map} +1 -1
- package/dist/chunks/{Card-DDRUwdlG.js → Card-C2mSdoXV.js} +2 -2
- package/dist/chunks/{Card-DDRUwdlG.js.map → Card-C2mSdoXV.js.map} +1 -1
- package/dist/chunks/{CardContent-DYAWf3xO.js → CardContent-CViecz1a.js} +2 -2
- package/dist/chunks/{CardContent-DYAWf3xO.js.map → CardContent-CViecz1a.js.map} +1 -1
- package/dist/chunks/{CardContent-D2cDaP4l.cjs → CardContent-DPL-tBOS.cjs} +2 -2
- package/dist/chunks/{CardContent-D2cDaP4l.cjs.map → CardContent-DPL-tBOS.cjs.map} +1 -1
- package/dist/chunks/{DrawerContent-C6nd8E0E.cjs → DrawerContent-BkSL16Os.cjs} +2 -2
- package/dist/chunks/{DrawerContent-C6nd8E0E.cjs.map → DrawerContent-BkSL16Os.cjs.map} +1 -1
- package/dist/chunks/{DrawerContent-OuMcge27.js → DrawerContent-D8NDBDBf.js} +2 -2
- package/dist/chunks/{DrawerContent-OuMcge27.js.map → DrawerContent-D8NDBDBf.js.map} +1 -1
- package/dist/chunks/{Icon-CFvy-l1V.cjs → Icon-BN4Kp4Aq.cjs} +2 -2
- package/dist/chunks/{Icon-CFvy-l1V.cjs.map → Icon-BN4Kp4Aq.cjs.map} +1 -1
- package/dist/chunks/{Icon-B2zjgYkr.js → Icon-DTU52KQE.js} +2 -2
- package/dist/chunks/{Icon-B2zjgYkr.js.map → Icon-DTU52KQE.js.map} +1 -1
- package/dist/chunks/{Loading-CD7bT3lU.js → Loading-BjCfYdLa.js} +2 -2
- package/dist/chunks/{Loading-CD7bT3lU.js.map → Loading-BjCfYdLa.js.map} +1 -1
- package/dist/chunks/{Loading-zx7Fg7_c.cjs → Loading-DVK2G3KT.cjs} +2 -2
- package/dist/chunks/{Loading-zx7Fg7_c.cjs.map → Loading-DVK2G3KT.cjs.map} +1 -1
- package/dist/chunks/{MenuButton-nVBc0ieJ.js → MenuButton-31ZFG3JW.js} +2 -2
- package/dist/chunks/{MenuButton-nVBc0ieJ.js.map → MenuButton-31ZFG3JW.js.map} +1 -1
- package/dist/chunks/{MenuButton-CsePYu0b.cjs → MenuButton-Dpbow8YC.cjs} +2 -2
- package/dist/chunks/{MenuButton-CsePYu0b.cjs.map → MenuButton-Dpbow8YC.cjs.map} +1 -1
- package/dist/chunks/{Stack-lvjI3kV3.cjs → Stack-CF3Wyma9.cjs} +2 -2
- package/dist/chunks/{Stack-lvjI3kV3.cjs.map → Stack-CF3Wyma9.cjs.map} +1 -1
- package/dist/chunks/{Stack-C2zMFX0w.js → Stack-CHR_pZC4.js} +2 -2
- package/dist/chunks/{Stack-C2zMFX0w.js.map → Stack-CHR_pZC4.js.map} +1 -1
- package/dist/chunks/{TableHeader-Bra59bV0.js → TableHeader-CrbbJXyv.js} +2 -2
- package/dist/chunks/{TableHeader-Bra59bV0.js.map → TableHeader-CrbbJXyv.js.map} +1 -1
- package/dist/chunks/{TableHeader-D_fGRq9B.cjs → TableHeader-D0wXM5mO.cjs} +2 -2
- package/dist/chunks/{TableHeader-D_fGRq9B.cjs.map → TableHeader-D0wXM5mO.cjs.map} +1 -1
- package/dist/chunks/{Typography-BkvvYn5T.js → Typography-B_WR62ip.js} +2 -2
- package/dist/chunks/{Typography-BkvvYn5T.js.map → Typography-B_WR62ip.js.map} +1 -1
- package/dist/chunks/{Typography-B2gBDBkp.cjs → Typography-Ch-BLqCH.cjs} +2 -2
- package/dist/chunks/{Typography-B2gBDBkp.cjs.map → Typography-Ch-BLqCH.cjs.map} +1 -1
- package/dist/chunks/createComponent-Bls5N6x8.cjs +2 -0
- package/dist/chunks/{createComponent-B2C4sTOb.cjs.map → createComponent-Bls5N6x8.cjs.map} +1 -1
- package/dist/chunks/createComponent-BmdhWozT.js +2 -0
- package/dist/chunks/{createComponent-D-IheGJm.js.map → createComponent-BmdhWozT.js.map} +1 -1
- package/dist/chunks/{useMenu-C2KhwKNS.cjs → useMenu-CvPJe62S.cjs} +2 -2
- package/dist/chunks/{useMenu-C2KhwKNS.cjs.map → useMenu-CvPJe62S.cjs.map} +1 -1
- package/dist/chunks/{useMenu-DLaxCUF_.js → useMenu-we523Eob.js} +2 -2
- package/dist/chunks/{useMenu-DLaxCUF_.js.map → useMenu-we523Eob.js.map} +1 -1
- package/dist/chunks/{useTabs-De_vpYsm.js → useTabs-DG53jo4T.js} +2 -2
- package/dist/chunks/{useTabs-De_vpYsm.js.map → useTabs-DG53jo4T.js.map} +1 -1
- package/dist/chunks/{useTabs-DaDm5Ou4.cjs → useTabs-Dcksp_re.cjs} +2 -2
- package/dist/chunks/{useTabs-DaDm5Ou4.cjs.map → useTabs-Dcksp_re.cjs.map} +1 -1
- package/dist/components/Alert/index.cjs +1 -1
- package/dist/components/Alert/index.js +1 -1
- package/dist/components/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Box/index.cjs +1 -1
- package/dist/components/Box/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ButtonIcon/index.cjs +1 -1
- package/dist/components/ButtonIcon/index.js +1 -1
- package/dist/components/Card/index.cjs +1 -1
- package/dist/components/Card/index.js +1 -1
- package/dist/components/Checkbox/index.cjs +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/CheckboxGroup/index.cjs +1 -1
- package/dist/components/CheckboxGroup/index.js +1 -1
- package/dist/components/Chip/index.cjs +1 -1
- package/dist/components/Chip/index.js +1 -1
- package/dist/components/ColorPicker/index.cjs +1 -1
- package/dist/components/ColorPicker/index.js +1 -1
- package/dist/components/Container/index.cjs +1 -1
- package/dist/components/Container/index.js +1 -1
- package/dist/components/Divider/index.cjs +1 -1
- package/dist/components/Divider/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/Input/index.cjs +1 -1
- package/dist/components/Input/index.js +1 -1
- package/dist/components/InputFile/index.cjs +1 -1
- package/dist/components/InputFile/index.js +1 -1
- package/dist/components/Loading/index.cjs +1 -1
- package/dist/components/Loading/index.js +1 -1
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.js +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Skeleton/index.cjs +1 -1
- package/dist/components/Skeleton/index.js +1 -1
- package/dist/components/Stack/index.cjs +1 -1
- package/dist/components/Stack/index.js +1 -1
- package/dist/components/Switch/index.cjs +1 -1
- package/dist/components/Switch/index.js +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Tabs/index.cjs +1 -1
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/Tooltip/index.cjs +1 -1
- package/dist/components/Tooltip/index.js +1 -1
- package/dist/components/Typography/index.cjs +1 -1
- package/dist/components/Typography/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/Alert-B-zwGEUF.js +0 -2
- package/dist/chunks/Alert-B-zwGEUF.js.map +0 -1
- package/dist/chunks/Alert-BCDrxwmz.cjs +0 -2
- package/dist/chunks/Alert-BCDrxwmz.cjs.map +0 -1
- package/dist/chunks/createComponent-B2C4sTOb.cjs +0 -2
- package/dist/chunks/createComponent-D-IheGJm.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableHeader-
|
|
1
|
+
{"version":3,"file":"TableHeader-D0wXM5mO.cjs","sources":["../../src/display/Table/Table.tsx","../../src/display/Table/TableBody.tsx","../../src/display/Table/TableCell.tsx","../../src/display/Table/TableHeader.tsx"],"sourcesContent":["import type { TableHTMLAttributes } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { joinClass } from '@iziui/core/utils/joinClass';\n\nimport createComponent from '@/core/createComponent';\n\nimport { Card } from '../Card';\n\nimport '@iziui/styles/components/Table.scss';\n\nexport type TableProps = TableHTMLAttributes<HTMLTableElement>;\n\nfunction Table({ children, ...props }: TableProps) {\n const cls = joinClass(\n `${prefix}-table`,\n props.className\n );\n\n return (\n <Card fullWidth style={{ overflow: 'auto' }}>\n <table className={cls} {...props}>\n {children}\n </table>\n </Card>\n );\n}\n\nexport default createComponent(Table);\n","import type { TableHTMLAttributes } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { joinClass } from '@iziui/core/utils/joinClass';\n\ninterface TableBodyProps extends TableHTMLAttributes<HTMLTableSectionElement> {\n children: React.ReactNode;\n}\n\nfunction TableBody({ children, ...props }: TableBodyProps) {\n\n const cls = joinClass(\n `${prefix}-table__body`,\n props.className\n );\n\n return (\n <tbody className={cls} {...props}>\n {children}\n </tbody>\n );\n}\n\nTableBody.displayName = 'TableBody';\n\nexport default TableBody;","import { TdHTMLAttributes } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { joinClass } from '@iziui/core/utils/joinClass';\n\nimport createComponent from '../../core/createComponent';\n\ninterface TableCellProps extends TdHTMLAttributes<HTMLTableDataCellElement> {\n align?: 'left' | 'center' | 'right';\n children: React.JSX.Element | string | number | null;\n}\nfunction TableCell({ align = 'left', children, ...props }: TableCellProps) {\n const className = joinClass(\n `${prefix}-table__cell`,\n `${prefix}-table__cell--${align}`,\n );\n\n return (\n <td className={className} {...props}>\n {children}\n </td>\n );\n}\n\nexport default createComponent(TableCell);","import type { PropsWithChildren } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { joinClass } from '@iziui/core/utils/joinClass';\n\nfunction TableHeader({ children }: PropsWithChildren) {\n const className = joinClass(\n `${prefix}-table__header`,\n );\n\n return (\n <thead className={className}>\n <tr>\n {children}\n </tr>\n </thead>\n );\n}\n\nTableHeader.displayName = 'TableHeader';\n\nexport default TableHeader;"],"names":["Table","children","props","cls","joinClass","prefix","Card","jsx","Table_default","createComponent","TableBody","TableCell","align","className","TableCell_default","TableHeader"],"mappings":"uMAcA,SAASA,EAAM,CAAE,SAAAC,EAAU,GAAGC,GAAqB,CACjD,MAAMC,EAAMC,EAAAA,UACV,GAAGC,EAAAA,MAAM,SACTH,EAAM,SAAA,EAGR,aACGI,EAAAA,KAAA,CAAK,UAAS,GAAC,MAAO,CAAE,SAAU,MAAA,EACjC,SAAAC,MAAC,SAAM,UAAWJ,EAAM,GAAGD,EACxB,SAAAD,EACH,EACF,CAEJ,CAEA,MAAAO,EAAeC,EAAAA,gBAAgBT,CAAK,ECnBpC,SAASU,EAAU,CAAE,SAAAT,EAAU,GAAGC,GAAyB,CAEzD,MAAMC,EAAMC,EAAAA,UACV,GAAGC,EAAAA,MAAM,eACTH,EAAM,SAAA,EAGR,aACG,QAAA,CAAM,UAAWC,EAAM,GAAGD,EACxB,SAAAD,EACH,CAEJ,CAEAS,EAAU,YAAc,YCZxB,SAASC,EAAU,CAAE,MAAAC,EAAQ,OAAQ,SAAAX,EAAU,GAAGC,GAAyB,CACzE,MAAMW,EAAYT,EAAAA,UAChB,GAAGC,EAAAA,MAAM,eACT,GAAGA,EAAAA,MAAM,iBAAiBO,CAAK,EAAA,EAGjC,OACEL,EAAAA,IAAC,KAAA,CAAG,UAAAM,EAAuB,GAAGX,EAC3B,SAAAD,EACH,CAEJ,CAEA,MAAAa,EAAeL,EAAAA,gBAAgBE,CAAS,ECnBxC,SAASI,EAAY,CAAE,SAAAd,GAA+B,CACpD,MAAMY,EAAYT,EAAAA,UAChB,GAAGC,EAAAA,MAAM,gBAAA,EAGX,aACG,QAAA,CAAM,UAAAQ,EACL,SAAAN,EAAAA,IAAC,KAAA,CACE,SAAAN,EACH,EACF,CAEJ,CAEAc,EAAY,YAAc"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as i}from"react/jsx-runtime";import{p as t}from"./index-CZ41y9Hn.js";import{j as l}from"./joinClass-anSpaauN.js";import{c as n}from"./convertPathToColor-DtOjH4ZP.js";import{u as b}from"./useTheme-BYuNiCiH.js";import{c as u}from"./createComponent-
|
|
2
|
-
//# sourceMappingURL=Typography-
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import{p as t}from"./index-CZ41y9Hn.js";import{j as l}from"./joinClass-anSpaauN.js";import{c as n}from"./convertPathToColor-DtOjH4ZP.js";import{u as b}from"./useTheme-BYuNiCiH.js";import{c as u}from"./createComponent-BmdhWozT.js";const v=["h1","h2","h3","h4","h5","h6","subtitle1","subtitle2","body1","body2"],f={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",subtitle1:"h6",subtitle2:"h6",body1:"p",body2:"p"};function g({children:e,variant:s="body1",color:a="text.primary",weight:h,textAlign:p,...o}){const{theme:{palette:m}}=b(),y=f[s],c=l(`${t}-typography`,`${t}-typography--${s}`,h&&`${t}-typography--weight-${h}`,o.className),r=n(a,m);return i(y,{...o,className:c,style:{...r?{color:r}:{},textAlign:p,...o.style},children:e})}const N=u(g);export{N as T,v};
|
|
2
|
+
//# sourceMappingURL=Typography-B_WR62ip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography-
|
|
1
|
+
{"version":3,"file":"Typography-B_WR62ip.js","sources":["../../src/display/Typography/Typography.tsx"],"sourcesContent":["import { type PropsWithChildren, type HTMLAttributes, type CSSProperties } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport type { MappedColors } from '@iziui/core/theme';\nimport { joinClass } from '@iziui/core/utils/joinClass';\nimport { convertPathToColor } from '@iziui/core/utils/convertPathToColor';\n\nimport { useTheme } from '@/theme';\nimport createComponent from '@/core/createComponent';\n\nimport '@iziui/styles/components/Typography.scss';\n\nexport const variants = [\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'subtitle1',\n 'subtitle2',\n 'body1',\n 'body2',\n] as const;\n\nexport type Variant = typeof variants[number];\n\nconst MAP: { [x: string]: React.ElementType } = {\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n h5: 'h5',\n h6: 'h6',\n subtitle1: 'h6',\n subtitle2: 'h6',\n body1: 'p',\n body2: 'p',\n};\n\nexport interface TypographyProps extends PropsWithChildren<HTMLAttributes<HTMLParagraphElement>> {\n variant?: Variant;\n color?: MappedColors;\n textAlign?: CSSProperties['textAlign'];\n weight?: 'bold' | 'normal' | 'light';\n}\n\nfunction Typography({\n children,\n variant = 'body1',\n color: _color = 'text.primary',\n weight,\n textAlign,\n ...props\n}: TypographyProps) {\n const { theme: { palette } } = useTheme();\n\n const CustomTag = MAP[variant];\n\n const cls = joinClass(\n `${prefix}-typography`,\n `${prefix}-typography--${variant}`,\n weight && `${prefix}-typography--weight-${weight}`,\n props.className\n );\n\n const color = convertPathToColor(_color, palette);\n\n return (\n <CustomTag\n {...props}\n className={cls}\n style={{\n ...(color ? { color } : {}),\n textAlign,\n ...props.style\n }}\n >\n {children}\n </CustomTag>\n );\n}\n\nexport default createComponent(Typography);"],"names":["variants","MAP","Typography","children","variant","_color","weight","textAlign","props","palette","useTheme","CustomTag","cls","joinClass","prefix","color","convertPathToColor","jsx","Typography$1","createComponent"],"mappings":"8QAaO,MAAMA,EAAW,CACtB,KACA,KACA,KACA,KACA,KACA,KACA,YACA,YACA,QACA,OACF,EAIMC,EAA0C,CAC9C,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,UAAW,KACX,UAAW,KACX,MAAO,IACP,MAAO,GACT,EASA,SAASC,EAAW,CAClB,SAAAC,EACA,QAAAC,EAAU,QACV,MAAOC,EAAS,eAChB,OAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAoB,CAClB,KAAM,CAAE,MAAO,CAAE,QAAAC,CAAA,CAAQ,EAAMC,EAAA,EAEzBC,EAAYV,EAAIG,CAAO,EAEvBQ,EAAMC,EACV,GAAGC,CAAM,cACT,GAAGA,CAAM,gBAAgBV,CAAO,GAChCE,GAAU,GAAGQ,CAAM,uBAAuBR,CAAM,GAChDE,EAAM,SAAA,EAGFO,EAAQC,EAAmBX,EAAQI,CAAO,EAEhD,OACEQ,EAACN,EAAA,CACE,GAAGH,EACJ,UAAWI,EACX,MAAO,CACL,GAAIG,EAAQ,CAAE,MAAAA,CAAA,EAAU,CAAA,EACxB,UAAAR,EACA,GAAGC,EAAM,KAAA,EAGV,SAAAL,CAAA,CAAA,CAGP,CAEA,MAAAe,EAAeC,EAAgBjB,CAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const p=require("react/jsx-runtime"),t=require("./index-DYxwT4uW.cjs"),u=require("./joinClass-Jk3EszKD.cjs"),l=require("./convertPathToColor-D8eBpd_D.cjs"),m=require("./useTheme-DsrjDJKC.cjs"),b=require("./createComponent-
|
|
2
|
-
//# sourceMappingURL=Typography-
|
|
1
|
+
"use strict";const p=require("react/jsx-runtime"),t=require("./index-DYxwT4uW.cjs"),u=require("./joinClass-Jk3EszKD.cjs"),l=require("./convertPathToColor-D8eBpd_D.cjs"),m=require("./useTheme-DsrjDJKC.cjs"),b=require("./createComponent-Bls5N6x8.cjs"),T=["h1","h2","h3","h4","h5","h6","subtitle1","subtitle2","body1","body2"],g={h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",subtitle1:"h6",subtitle2:"h6",body1:"p",body2:"p"};function x({children:h,variant:o="body1",color:n="text.primary",weight:s,textAlign:c,...e}){const{theme:{palette:a}}=m.useTheme(),i=g[o],y=u.joinClass(`${t.prefix}-typography`,`${t.prefix}-typography--${o}`,s&&`${t.prefix}-typography--weight-${s}`,e.className),r=l.convertPathToColor(n,a);return p.jsx(i,{...e,className:y,style:{...r?{color:r}:{},textAlign:c,...e.style},children:h})}const C=b.createComponent(x);exports.Typography=C;exports.variants=T;
|
|
2
|
+
//# sourceMappingURL=Typography-Ch-BLqCH.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography-
|
|
1
|
+
{"version":3,"file":"Typography-Ch-BLqCH.cjs","sources":["../../src/display/Typography/Typography.tsx"],"sourcesContent":["import { type PropsWithChildren, type HTMLAttributes, type CSSProperties } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport type { MappedColors } from '@iziui/core/theme';\nimport { joinClass } from '@iziui/core/utils/joinClass';\nimport { convertPathToColor } from '@iziui/core/utils/convertPathToColor';\n\nimport { useTheme } from '@/theme';\nimport createComponent from '@/core/createComponent';\n\nimport '@iziui/styles/components/Typography.scss';\n\nexport const variants = [\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'subtitle1',\n 'subtitle2',\n 'body1',\n 'body2',\n] as const;\n\nexport type Variant = typeof variants[number];\n\nconst MAP: { [x: string]: React.ElementType } = {\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n h4: 'h4',\n h5: 'h5',\n h6: 'h6',\n subtitle1: 'h6',\n subtitle2: 'h6',\n body1: 'p',\n body2: 'p',\n};\n\nexport interface TypographyProps extends PropsWithChildren<HTMLAttributes<HTMLParagraphElement>> {\n variant?: Variant;\n color?: MappedColors;\n textAlign?: CSSProperties['textAlign'];\n weight?: 'bold' | 'normal' | 'light';\n}\n\nfunction Typography({\n children,\n variant = 'body1',\n color: _color = 'text.primary',\n weight,\n textAlign,\n ...props\n}: TypographyProps) {\n const { theme: { palette } } = useTheme();\n\n const CustomTag = MAP[variant];\n\n const cls = joinClass(\n `${prefix}-typography`,\n `${prefix}-typography--${variant}`,\n weight && `${prefix}-typography--weight-${weight}`,\n props.className\n );\n\n const color = convertPathToColor(_color, palette);\n\n return (\n <CustomTag\n {...props}\n className={cls}\n style={{\n ...(color ? { color } : {}),\n textAlign,\n ...props.style\n }}\n >\n {children}\n </CustomTag>\n );\n}\n\nexport default createComponent(Typography);"],"names":["variants","MAP","Typography","children","variant","_color","weight","textAlign","props","palette","useTheme","CustomTag","cls","joinClass","prefix","color","convertPathToColor","jsx","createComponent"],"mappings":"0PAaaA,EAAW,CACtB,KACA,KACA,KACA,KACA,KACA,KACA,YACA,YACA,QACA,OACF,EAIMC,EAA0C,CAC9C,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,GAAI,KACJ,UAAW,KACX,UAAW,KACX,MAAO,IACP,MAAO,GACT,EASA,SAASC,EAAW,CAClB,SAAAC,EACA,QAAAC,EAAU,QACV,MAAOC,EAAS,eAChB,OAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAoB,CAClB,KAAM,CAAE,MAAO,CAAE,QAAAC,CAAA,CAAQ,EAAMC,EAAAA,SAAA,EAEzBC,EAAYV,EAAIG,CAAO,EAEvBQ,EAAMC,EAAAA,UACV,GAAGC,EAAAA,MAAM,cACT,GAAGA,EAAAA,MAAM,gBAAgBV,CAAO,GAChCE,GAAU,GAAGQ,EAAAA,MAAM,uBAAuBR,CAAM,GAChDE,EAAM,SAAA,EAGFO,EAAQC,EAAAA,mBAAmBX,EAAQI,CAAO,EAEhD,OACEQ,EAAAA,IAACN,EAAA,CACE,GAAGH,EACJ,UAAWI,EACX,MAAO,CACL,GAAIG,EAAQ,CAAE,MAAAA,CAAA,EAAU,CAAA,EACxB,UAAAR,EACA,GAAGC,EAAM,KAAA,EAGV,SAAAL,CAAA,CAAA,CAGP,CAEA,MAAAD,EAAegB,EAAAA,gBAAgBhB,CAAU"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const P=require("react/jsx-runtime"),b=require("./index-DYxwT4uW.cjs"),M=require("./useTheme-DsrjDJKC.cjs");function S({sx:t,theme:n},...e){return e.reduce((s,a)=>(s={...s,...a(n,t)},s),{})}const y=(t,{color:n})=>{const{palette:e}=t;return n?{color:n(e)}:{}},B=(t,{background:n})=>{const{palette:e}=t;return n?{background:n(e)}:{}},j=(t,{borderColor:n})=>{const{palette:e}=t;return n?{borderColor:n(e)}:{}},w=(t,{backgroundColor:n})=>{const{palette:e}=t;return n?{backgroundColor:n(e)}:{}},C=(t,{borderRadius:n})=>{const{shape:e}=t;return n?{borderRadius:`${e.radius*n}px`}:{}},R=(t,{m:n,mb:e,ml:s,mr:a,mt:c,mx:u,my:l})=>{const{spacing:h}=t,r=i=>i||i===0?`${String(i*h)}px`:"",o=r(n),f=r(c),m=r(e),d=r(l),g=r(u),p=r(s),x=r(a);return{margin:o,marginTop:f||d||o,marginBottom:m||d||o,marginLeft:p||g||o,marginRight:x||g||o}},T=(t,{p:n,pb:e,pl:s,pr:a,pt:c,px:u,py:l})=>{const{spacing:h}=t,r=i=>i||i===0?`${String(i*h)}px`:"",o=r(n),f=r(c),m=r(e),d=r(l),g=r(u),p=r(s),x=r(a);return{padding:o,paddingTop:f||d||o,paddingBottom:m||d||o,paddingLeft:p||g||o,paddingRight:x||g||o}},_=(t,{boxShadow:n})=>n?{boxShadow:{sm:b.boxShadowSmall,md:b.boxShadowRegular,lg:b.boxShadowLarge}[n]}:{},z=Object.freeze(Object.defineProperty({__proto__:null,defineBackground:B,defineBackgroundColor:w,defineBorderColor:j,defineBorderRadius:C,defineBoxShadow:_,defineColor:y,defineMargin:R,definePadding:T},Symbol.toStringTag,{value:"Module"}));function O(t){return Object.values(t).map(n=>n)}function q(t){return t.displayName=t.name,({sx:e,fullWidth:s,...a})=>{const{theme:c}=M.useTheme(),u=e&&S({theme:c,sx:e},...O(z));return P.jsx(t,{...a,style:{boxSizing:"border-box",...a.style,...u,...s?{width:"100%"}:{}}})}}exports.createComponent=q;
|
|
2
|
+
//# sourceMappingURL=createComponent-Bls5N6x8.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponent-
|
|
1
|
+
{"version":3,"file":"createComponent-Bls5N6x8.cjs","sources":["../../../../core/src/options/createOptions/createOptions.ts","../../../../core/src/plugin/color/defineColor/defineColor.ts","../../../../core/src/plugin/color/defineBackground/defineBackground.ts","../../../../core/src/plugin/color/defineBorderColor/defineBorderColor.ts","../../../../core/src/plugin/color/defineBackgroundColor/defineBackgroundColor.ts","../../../../core/src/plugin/shape/defineBorderRadius/defineBorderRadius.ts","../../../../core/src/plugin/spacing/defineMargin/defineMargin.ts","../../../../core/src/plugin/spacing/definePadding/definePadding.ts","../../../../core/src/plugin/behavior/defineBoxShadow/defineBoxShadow.ts","../../src/core/createComponent.tsx"],"sourcesContent":["import type { Properties } from 'csstype';\n\nimport type { Plugin } from '../../plugin';\nimport type { ThemeBuilded } from '../../theme';\nimport type { CustomOptions } from '../CustomOptions';\n\ntype Data = {\n sx: CustomOptions;\n theme: ThemeBuilded;\n}\n\nexport default function createOptions({ sx, theme }: Data, ...plugins: Plugin[]): Properties {\n return plugins.reduce<Properties>((acc, plugin) => {\n acc = { ...acc, ...plugin(theme, sx) };\n\n return acc;\n }, {});\n}","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { color }) => {\n const { palette } = theme;\n\n if (!color) { return {}; }\n\n return {\n color: color(palette)\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { background }) => {\n const { palette } = theme;\n\n if (!background) { return {}; }\n\n return {\n background: background(palette)\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { borderColor }) => {\n const { palette } = theme;\n\n if (!borderColor) { return {}; }\n\n return {\n borderColor: borderColor(palette)\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { backgroundColor }) => {\n const { palette } = theme;\n\n if (!backgroundColor) { return {}; }\n\n return {\n backgroundColor: backgroundColor(palette)\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { borderRadius }) => {\n const { shape } = theme;\n\n if (!borderRadius) { return {}; }\n\n return {\n borderRadius: `${shape.radius * borderRadius}px`\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { m, mb, ml, mr, mt, mx, my }) => {\n const { spacing } = theme;\n\n const calculateMargin = (mg?: number) => {\n return !!mg || mg === 0 ? `${String(mg * spacing)}px` : '';\n };\n\n const hasM = calculateMargin(m);\n\n const hasMt = calculateMargin(mt);\n const hasMb = calculateMargin(mb);\n\n const hasMy = calculateMargin(my);\n const hasMx = calculateMargin(mx);\n\n const hasMl = calculateMargin(ml);\n const hasMr = calculateMargin(mr);\n\n return {\n margin: hasM,\n marginTop: hasMt || hasMy || hasM,\n marginBottom: hasMb || hasMy || hasM,\n marginLeft: hasMl || hasMx || hasM,\n marginRight: hasMr || hasMx || hasM,\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { p, pb, pl, pr, pt, px, py }) => {\n const { spacing } = theme;\n\n const calculatePadding = (pd?: number) => {\n return !!pd || pd === 0 ? `${String(pd * spacing)}px` : '';\n };\n\n const hasP = calculatePadding(p);\n\n const hasPt = calculatePadding(pt);\n const hasPb = calculatePadding(pb);\n\n const hasPy = calculatePadding(py);\n const hasPx = calculatePadding(px);\n\n const hasPl = calculatePadding(pl);\n const hasPr = calculatePadding(pr);\n\n return {\n padding: hasP,\n paddingTop: hasPt || hasPy || hasP,\n paddingBottom: hasPb || hasPy || hasP,\n paddingLeft: hasPl || hasPx || hasP,\n paddingRight: hasPr || hasPx || hasP,\n };\n});","import { boxShadowSmall, boxShadowRegular, boxShadowLarge } from '@iziui/tokens/web/js';\n\nimport definePlugin from '../../definePlugin';\nimport type { CustomOptions } from '../../../options/CustomOptions';\n\ntype ExtractSize = NonNullable<CustomOptions['boxShadow']>;\n\nexport default definePlugin((_, { boxShadow }) => {\n\n if (!boxShadow) { return {}; }\n\n const sizes: { [s in ExtractSize]: string } = {\n sm: boxShadowSmall,\n md: boxShadowRegular,\n lg: boxShadowLarge,\n };\n\n return {\n boxShadow: sizes[boxShadow]\n };\n});","import type { ComponentType, FC } from 'react';\n\nimport type { Sx } from '@iziui/core/system';\nimport type { Plugin } from '@iziui/core/plugin';\nimport createOptions from '@iziui/core/options';\nimport * as plugins from '@iziui/core/plugin';\n\nimport { useTheme } from '@/theme';\n\nfunction extract(module: { [key: string]: Plugin }) {\n return Object.values(module).map((fn) => fn);\n}\n\nexport default function createComponent<P>(WrappedComponent: ComponentType<P>) {\n WrappedComponent.displayName = WrappedComponent.name;\n\n const EnhancedComponent: FC<Sx<P>> = ({ sx, fullWidth, ...props }) => {\n const { theme } = useTheme();\n\n const options = sx && createOptions({ theme, sx },\n ...extract(plugins),\n );\n\n return (\n <WrappedComponent\n {...(props as P)}\n style={{\n boxSizing: 'border-box',\n ...props['style'],\n ...options,\n ...(fullWidth ? { width: '100%' } : {}),\n }}\n />\n );\n };\n\n return EnhancedComponent;\n}"],"names":["createOptions","sx","theme","plugins","acc","plugin","defineColor","color","palette","defineBackground","background","defineBorderColor","borderColor","defineBackgroundColor","backgroundColor","defineBorderRadius","borderRadius","shape","defineMargin","m","mb","ml","mr","mt","mx","my","spacing","calculateMargin","mg","hasM","hasMt","hasMb","hasMy","hasMx","hasMl","hasMr","definePadding","p","pb","pl","pr","pt","px","py","calculatePadding","pd","hasP","hasPt","hasPb","hasPy","hasPx","hasPl","hasPr","defineBoxShadow","_","boxShadow","boxShadowSmall","boxShadowRegular","boxShadowLarge","extract","module","fn","createComponent","WrappedComponent","fullWidth","props","useTheme","options","jsx"],"mappings":"yHAWA,SAAwBA,EAAc,CAAE,GAAAC,EAAI,MAAAC,CAAA,KAAkBC,EAA+B,CAC3F,OAAOA,EAAQ,OAAmB,CAACC,EAAKC,KACtCD,EAAM,CAAE,GAAGA,EAAK,GAAGC,EAAOH,EAAOD,CAAE,CAAA,EAE5BG,GACN,CAAA,CAAE,CACP,CCfA,MAAAE,EAA4B,CAACJ,EAAO,CAAE,MAAAK,KAAY,CAChD,KAAM,CAAE,QAAAC,GAAYN,EAEpB,OAAKK,EAEE,CACL,MAAOA,EAAMC,CAAO,CAAA,EAHD,CAAA,CAKvB,ECRAC,EAA4B,CAACP,EAAO,CAAE,WAAAQ,KAAiB,CACrD,KAAM,CAAE,QAAAF,GAAYN,EAEpB,OAAKQ,EAEE,CACL,WAAYA,EAAWF,CAAO,CAAA,EAHN,CAAA,CAK5B,ECRAG,EAA4B,CAACT,EAAO,CAAE,YAAAU,KAAkB,CACtD,KAAM,CAAE,QAAAJ,GAAYN,EAEpB,OAAKU,EAEE,CACL,YAAaA,EAAYJ,CAAO,CAAA,EAHP,CAAA,CAK7B,ECRAK,EAA4B,CAACX,EAAO,CAAE,gBAAAY,K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AiBD,CAAE,EAC3BO,EAAQN,EAAiBF,CAAE,EAE3BS,EAAQP,EAAiBL,CAAE,EAC3Ba,EAAQR,EAAiBJ,CAAE,EAEjC,MAAO,CACL,QAASM,EACT,WAAYC,GAASE,GAASH,EAC9B,cAAeE,GAASC,GAASH,EACjC,YAAaK,GAASD,GAASJ,EAC/B,aAAcM,GAASF,GAASJ,CAAA,CAEpC,ECpBAO,EAA4B,CAACC,EAAG,CAAE,UAAAC,KAE3BA,EAQE,CACL,UAP4C,CAC5C,GAAIC,EAAAA,eACJ,GAAIC,EAAAA,iBACJ,GAAIC,EAAAA,cAAA,EAIaH,CAAS,CAAA,EATH,CAAA,kPCA3B,SAASI,EAAQC,EAAmC,CAClD,OAAO,OAAO,OAAOA,CAAM,EAAE,IAAKC,GAAOA,CAAE,CAC7C,CAEA,SAAwBC,EAAmBC,EAAoC,CAC7E,OAAAA,EAAiB,YAAcA,EAAiB,KAEX,CAAC,CAAE,GAAA9D,EAAI,UAAA+D,EAAW,GAAGC,KAAY,CACpE,KAAM,CAAE,MAAA/D,CAAA,EAAUgE,WAAA,EAEZC,EAAUlE,GAAMD,EAAc,CAAE,MAAAE,EAAO,GAAAD,CAAA,EAC3C,GAAG0D,EAAQxD,CAAO,CAAA,EAGpB,OACEiE,EAAAA,IAACL,EAAA,CACE,GAAIE,EACL,MAAO,CACL,UAAW,aACX,GAAGA,EAAM,MACT,GAAGE,EACH,GAAIH,EAAY,CAAE,MAAO,QAAW,CAAA,CAAC,CACvC,CAAA,CAGN,CAGF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsx as x}from"react/jsx-runtime";import{b as P,c as M,d as S}from"./index-CZ41y9Hn.js";import{u as y}from"./useTheme-BYuNiCiH.js";function B({sx:t,theme:n},...e){return e.reduce((s,a)=>(s={...s,...a(n,t)},s),{})}const w=(t,{color:n})=>{const{palette:e}=t;return n?{color:n(e)}:{}},_=(t,{background:n})=>{const{palette:e}=t;return n?{background:n(e)}:{}},j=(t,{borderColor:n})=>{const{palette:e}=t;return n?{borderColor:n(e)}:{}},z=(t,{backgroundColor:n})=>{const{palette:e}=t;return n?{backgroundColor:n(e)}:{}},C=(t,{borderRadius:n})=>{const{shape:e}=t;return n?{borderRadius:`${e.radius*n}px`}:{}},O=(t,{m:n,mb:e,ml:s,mr:a,mt:c,mx:u,my:l})=>{const{spacing:f}=t,o=i=>i||i===0?`${String(i*f)}px`:"",r=o(n),h=o(c),m=o(e),d=o(l),g=o(u),p=o(s),b=o(a);return{margin:r,marginTop:h||d||r,marginBottom:m||d||r,marginLeft:p||g||r,marginRight:b||g||r}},R=(t,{p:n,pb:e,pl:s,pr:a,pt:c,px:u,py:l})=>{const{spacing:f}=t,o=i=>i||i===0?`${String(i*f)}px`:"",r=o(n),h=o(c),m=o(e),d=o(l),g=o(u),p=o(s),b=o(a);return{padding:r,paddingTop:h||d||r,paddingBottom:m||d||r,paddingLeft:p||g||r,paddingRight:b||g||r}},T=(t,{boxShadow:n})=>n?{boxShadow:{sm:S,md:M,lg:P}[n]}:{},L=Object.freeze(Object.defineProperty({__proto__:null,defineBackground:_,defineBackgroundColor:z,defineBorderColor:j,defineBorderRadius:C,defineBoxShadow:T,defineColor:w,defineMargin:O,definePadding:R},Symbol.toStringTag,{value:"Module"}));function $(t){return Object.values(t).map(n=>n)}function N(t){return t.displayName=t.name,({sx:e,fullWidth:s,...a})=>{const{theme:c}=y(),u=e&&B({theme:c,sx:e},...$(L));return x(t,{...a,style:{boxSizing:"border-box",...a.style,...u,...s?{width:"100%"}:{}}})}}export{N as c};
|
|
2
|
+
//# sourceMappingURL=createComponent-BmdhWozT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createComponent-
|
|
1
|
+
{"version":3,"file":"createComponent-BmdhWozT.js","sources":["../../../../core/src/options/createOptions/createOptions.ts","../../../../core/src/plugin/color/defineColor/defineColor.ts","../../../../core/src/plugin/color/defineBackground/defineBackground.ts","../../../../core/src/plugin/color/defineBorderColor/defineBorderColor.ts","../../../../core/src/plugin/color/defineBackgroundColor/defineBackgroundColor.ts","../../../../core/src/plugin/shape/defineBorderRadius/defineBorderRadius.ts","../../../../core/src/plugin/spacing/defineMargin/defineMargin.ts","../../../../core/src/plugin/spacing/definePadding/definePadding.ts","../../../../core/src/plugin/behavior/defineBoxShadow/defineBoxShadow.ts","../../src/core/createComponent.tsx"],"sourcesContent":["import type { Properties } from 'csstype';\n\nimport type { Plugin } from '../../plugin';\nimport type { ThemeBuilded } from '../../theme';\nimport type { CustomOptions } from '../CustomOptions';\n\ntype Data = {\n sx: CustomOptions;\n theme: ThemeBuilded;\n}\n\nexport default function createOptions({ sx, theme }: Data, ...plugins: Plugin[]): Properties {\n return plugins.reduce<Properties>((acc, plugin) => {\n acc = { ...acc, ...plugin(theme, sx) };\n\n return acc;\n }, {});\n}","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { color }) => {\n const { palette } = theme;\n\n if (!color) { return {}; }\n\n return {\n color: color(palette)\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { background }) => {\n const { palette } = theme;\n\n if (!background) { return {}; }\n\n return {\n background: background(palette)\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { borderColor }) => {\n const { palette } = theme;\n\n if (!borderColor) { return {}; }\n\n return {\n borderColor: borderColor(palette)\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { backgroundColor }) => {\n const { palette } = theme;\n\n if (!backgroundColor) { return {}; }\n\n return {\n backgroundColor: backgroundColor(palette)\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { borderRadius }) => {\n const { shape } = theme;\n\n if (!borderRadius) { return {}; }\n\n return {\n borderRadius: `${shape.radius * borderRadius}px`\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { m, mb, ml, mr, mt, mx, my }) => {\n const { spacing } = theme;\n\n const calculateMargin = (mg?: number) => {\n return !!mg || mg === 0 ? `${String(mg * spacing)}px` : '';\n };\n\n const hasM = calculateMargin(m);\n\n const hasMt = calculateMargin(mt);\n const hasMb = calculateMargin(mb);\n\n const hasMy = calculateMargin(my);\n const hasMx = calculateMargin(mx);\n\n const hasMl = calculateMargin(ml);\n const hasMr = calculateMargin(mr);\n\n return {\n margin: hasM,\n marginTop: hasMt || hasMy || hasM,\n marginBottom: hasMb || hasMy || hasM,\n marginLeft: hasMl || hasMx || hasM,\n marginRight: hasMr || hasMx || hasM,\n };\n});","import definePlugin from '../../definePlugin';\n\nexport default definePlugin((theme, { p, pb, pl, pr, pt, px, py }) => {\n const { spacing } = theme;\n\n const calculatePadding = (pd?: number) => {\n return !!pd || pd === 0 ? `${String(pd * spacing)}px` : '';\n };\n\n const hasP = calculatePadding(p);\n\n const hasPt = calculatePadding(pt);\n const hasPb = calculatePadding(pb);\n\n const hasPy = calculatePadding(py);\n const hasPx = calculatePadding(px);\n\n const hasPl = calculatePadding(pl);\n const hasPr = calculatePadding(pr);\n\n return {\n padding: hasP,\n paddingTop: hasPt || hasPy || hasP,\n paddingBottom: hasPb || hasPy || hasP,\n paddingLeft: hasPl || hasPx || hasP,\n paddingRight: hasPr || hasPx || hasP,\n };\n});","import { boxShadowSmall, boxShadowRegular, boxShadowLarge } from '@iziui/tokens/web/js';\n\nimport definePlugin from '../../definePlugin';\nimport type { CustomOptions } from '../../../options/CustomOptions';\n\ntype ExtractSize = NonNullable<CustomOptions['boxShadow']>;\n\nexport default definePlugin((_, { boxShadow }) => {\n\n if (!boxShadow) { return {}; }\n\n const sizes: { [s in ExtractSize]: string } = {\n sm: boxShadowSmall,\n md: boxShadowRegular,\n lg: boxShadowLarge,\n };\n\n return {\n boxShadow: sizes[boxShadow]\n };\n});","import type { ComponentType, FC } from 'react';\n\nimport type { Sx } from '@iziui/core/system';\nimport type { Plugin } from '@iziui/core/plugin';\nimport createOptions from '@iziui/core/options';\nimport * as plugins from '@iziui/core/plugin';\n\nimport { useTheme } from '@/theme';\n\nfunction extract(module: { [key: string]: Plugin }) {\n return Object.values(module).map((fn) => fn);\n}\n\nexport default function createComponent<P>(WrappedComponent: ComponentType<P>) {\n WrappedComponent.displayName = WrappedComponent.name;\n\n const EnhancedComponent: FC<Sx<P>> = ({ sx, fullWidth, ...props }) => {\n const { theme } = useTheme();\n\n const options = sx && createOptions({ theme, sx },\n ...extract(plugins),\n );\n\n return (\n <WrappedComponent\n {...(props as P)}\n style={{\n boxSizing: 'border-box',\n ...props['style'],\n ...options,\n ...(fullWidth ? { width: '100%' } : {}),\n }}\n />\n );\n };\n\n return EnhancedComponent;\n}"],"names":["createOptions","sx","theme","plugins","acc","plugin","defineColor","color","palette","defineBackground","background","defineBorderColor","borderColor","defineBackgroundColor","backgroundColor","defineBorderRadius","borderRadius","shape","defineMargin","m","mb","ml","mr","mt","mx","my","spacing","calculateMargin","mg","hasM","hasMt","hasMb","hasMy","hasMx","hasMl","hasMr","definePadding","p","pb","pl","pr","pt","px","py","calculatePadding","pd","hasP","hasPt","hasPb","hasPy","hasPx","hasPl","hasPr","defineBoxShadow","_","boxShadow","boxShadowSmall","boxShadowRegular","boxShadowLarge","extract","module","fn","createComponent","WrappedComponent","fullWidth","props","useTheme","options","jsx"],"mappings":"yIAWA,SAAwBA,EAAc,CAAE,GAAAC,EAAI,MAAAC,CAAA,KAAkBC,EAA+B,CAC3F,OAAOA,EAAQ,OAAmB,CAACC,EAAKC,KACtCD,EAAM,CAAE,GAAGA,EAAK,GAAGC,EAAOH,EAAOD,CAAE,CAAA,EAE5BG,GACN,CAAA,CAAE,CACP,CCfA,MAAAE,EAA4B,CAACJ,EAAO,CAAE,MAAAK,KAAY,CAChD,KAAM,CAAE,QAAAC,GAAYN,EAEpB,OAAKK,EAEE,CACL,MAAOA,EAAMC,CAAO,CAAA,EAHD,CAAA,CAKvB,ECRAC,EAA4B,CAACP,EAAO,CAAE,WAAAQ,KAAiB,CACrD,KAAM,CAAE,QAAAF,GAAYN,EAEpB,OAAKQ,EAEE,C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("react"),l=require("./index-DYxwT4uW.cjs"),z=require("./joinClass-Jk3EszKD.cjs"),D=require("./uuid-omnJ9TjZ.cjs"),E=require("./useListenerResized-AwpsZLcP.cjs"),L=require("./Card-
|
|
2
|
-
//# sourceMappingURL=useMenu-
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),n=require("react"),l=require("./index-DYxwT4uW.cjs"),z=require("./joinClass-Jk3EszKD.cjs"),D=require("./uuid-omnJ9TjZ.cjs"),E=require("./useListenerResized-AwpsZLcP.cjs"),L=require("./Card-Bqgukgip.cjs"),S=require("./CardContent-DPL-tBOS.cjs"),B=require("./createComponent-Bls5N6x8.cjs");class P{delay(t,s=500){if(!s){t();return}clearTimeout(this.timeout),this.timeout=setTimeout(()=>{t()},s)}}const W=new P,F=n.forwardRef(function({open:t,width:s,children:f,anchorEl:o,direction:d="left",maxHeight:i,autoClose:_,onClose:$,...m},j){const[g,M]=n.useState(),[h,a]=n.useState({state:"invisible",animation:"close",width:"auto"}),N=16,y=150,k=n.Children.toArray(f),T=n.useMemo(()=>D.uuid(),[]),v=z.joinClass(`${l.prefix}-menu`,`${l.prefix}-menu--${h?.animation}`,m.className);E.useListenerResized(()=>b(),[o]),n.useEffect(()=>{b()},[o]),n.useEffect(()=>{t?w():C()},[t]);const b=()=>{o&&setTimeout(()=>{let e={};const{offsetWidth:r,offsetHeight:p,offsetLeft:q,offsetTop:I}=o;a(O=>({...O,width:r}));const x=I+p+N/2,R=document.getElementById(T);d==="center"&&(e={top:x,right:r}),d==="left"&&(e={top:x,left:q}),d==="right"&&(e={top:x,left:q-(R.offsetWidth-r)}),M(e)},0)},w=()=>{a(e=>({...e,state:"visible"})),setTimeout(()=>{a(e=>({...e,animation:"open"}))},10)},C=()=>{a(e=>({...e,animation:"close"})),setTimeout(()=>{a(e=>({...e,state:"invisible"})),$()},y)},A=()=>k.map((e,r)=>n.cloneElement(e,{tabIndex:r+1,key:`button-${r}`,onClick:p=>{W.delay(()=>{_&&C(),e.props.onClick&&e.props.onClick(p)},0)}}));return c.jsxs(c.Fragment,{children:[c.jsx("div",{id:T,ref:j,...m,style:{width:s||h.width,top:g?.top,left:g?.left,display:h?.state==="visible"?"block":"none",transition:`all ${y}ms ease-in`,zIndex:50,...m.style},className:v,children:t&&c.jsx(L.Card,{className:`${l.prefix}-menu__card`,children:c.jsx(S.CardContent,{className:`${l.prefix}-menu__card__content`,sx:{py:1},style:{display:"flex",flexDirection:"column",maxHeight:i},children:A()})})}),t&&c.jsx("div",{className:`${l.prefix}-menu__overlay`,onClick:C})]})}),G=B.createComponent(F);function H(){const[u,t]=n.useState(null),s=!!u,f=i=>{t(i?i.currentTarget:null)},o=()=>{t(null)};return[s,u,i=>{if(s){o();return}f(i)}]}exports.Menu=G;exports.useMenu=H;
|
|
2
|
+
//# sourceMappingURL=useMenu-CvPJe62S.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenu-
|
|
1
|
+
{"version":3,"file":"useMenu-CvPJe62S.cjs","sources":["../../../../toolkit/src/debounce/debounce.ts","../../src/navigation/Menu/Menu.tsx","../../src/navigation/Menu/useMenu.ts"],"sourcesContent":["class Debounce {\n private timeout: NodeJS.Timeout | undefined;\n public delay(func: (a?: any) => void, milliseconds = 500) {\n if (!milliseconds) {\n func();\n return;\n }\n\n clearTimeout(this.timeout);\n this.timeout = setTimeout(() => { func(); }, milliseconds);\n }\n}\n\nexport const debounce = new Debounce();\n","import {\n useMemo,\n useState,\n useEffect,\n Children,\n forwardRef,\n type ReactElement,\n type CSSProperties,\n type HTMLAttributes,\n cloneElement\n} from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { joinClass } from '@iziui/core/utils';\n\nimport { uuid } from '@iziui/toolkit/uuid';\nimport { debounce } from '@iziui/toolkit/debounce';\n\nimport useListenerResized from '@/hooks/useListenerResized';\nimport { Card, CardContent } from '@/display/Card';\n\nimport createComponent from '../../core/createComponent';\n\nimport '@iziui/styles/components/Menu.scss';\n\ntype Direction = 'left' | 'right' | 'center';\ntype AnimationClass = 'open' | 'close';\ntype State = 'visible' | 'invisible';\ntype Coordinates = { top?: number; right?: number; bottom?: number; left?: number; };\ntype Config = { animation: AnimationClass, state: State; width: CSSProperties['width'] };\n\nexport interface MenuProps extends HTMLAttributes<HTMLDivElement> {\n open: boolean;\n autoClose?: boolean;\n maxHeight?: CSSProperties['maxHeight'];\n direction?: Direction;\n anchorEl: HTMLElement | null;\n width?: CSSProperties['width'];\n children: React.JSX.Element | React.JSX.Element[];\n onClose: (e?: React.MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu({\n open,\n width,\n children,\n anchorEl,\n direction = 'left',\n maxHeight,\n autoClose,\n onClose,\n ...props\n}: MenuProps, ref) {\n const [coordinate, setCoordinate] = useState<Coordinates>();\n const [config, setConfig] = useState<Config>({ state: 'invisible', animation: 'close', width: 'auto' });\n\n const GAP = 16;\n const ANIMATION_DURATION = 150;\n\n const arrayChildren = Children.toArray(children) as ReactElement<any>[];\n\n const id = useMemo(() => uuid(), []);\n\n const classes = joinClass(\n `${prefix}-menu`,\n `${prefix}-menu--${config?.animation}`,\n props.className\n );\n\n useListenerResized(() => changePosition(), [anchorEl]);\n\n useEffect(() => { changePosition(); }, [anchorEl]);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n useEffect(() => { open ? handleOpen() : handleClose(); }, [open]);\n\n const changePosition = () => {\n if (!anchorEl) { return; }\n\n setTimeout(() => {\n let coordinates: Coordinates = {};\n\n const { offsetWidth, offsetHeight, offsetLeft, offsetTop } = anchorEl;\n\n setConfig(prev => ({ ...prev, width: offsetWidth }));\n\n const top = offsetTop + offsetHeight + (GAP / 2);\n\n const el = document.getElementById(id) as HTMLElement;\n\n if (direction === 'center') { coordinates = { top, right: offsetWidth }; }\n\n if (direction === 'left') { coordinates = { top, left: offsetLeft }; }\n\n if (direction === 'right') { coordinates = { top, left: offsetLeft - (el.offsetWidth - offsetWidth) }; }\n\n setCoordinate(coordinates);\n }, 0);\n };\n\n const handleOpen = () => {\n setConfig(prev => ({ ...prev, state: 'visible' }));\n\n setTimeout(() => { setConfig(prev => ({ ...prev, animation: 'open' })); }, 10);\n };\n\n const handleClose = () => {\n setConfig(prev => ({ ...prev, animation: 'close' }));\n\n setTimeout(() => {\n setConfig(prev => ({ ...prev, state: 'invisible' }));\n onClose();\n }, ANIMATION_DURATION);\n };\n\n const renderChildren = () => {\n return arrayChildren.map((child, index) => {\n return cloneElement(child, {\n 'tabIndex': index + 1,\n key: `button-${index}`,\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => {\n debounce.delay(() => {\n\n if (autoClose) { handleClose(); }\n\n if (child.props.onClick) { child.props.onClick(e); }\n }, 0);\n },\n });\n });\n };\n\n return (\n <>\n <div\n id={id}\n ref={ref}\n {...props}\n style={{\n width: width || config.width,\n top: coordinate?.top,\n left: coordinate?.left,\n display: config?.state === 'visible' ? 'block' : 'none',\n transition: `all ${ANIMATION_DURATION}ms ease-in`,\n zIndex: 50,\n ...props.style\n }}\n className={classes}\n >\n {\n open && (\n <Card className={`${prefix}-menu__card`}>\n <CardContent\n className={`${prefix}-menu__card__content`}\n sx={{ py: 1 }}\n style={{ display: 'flex', flexDirection: 'column', maxHeight }}\n >\n {renderChildren()}\n </CardContent>\n </Card>\n )\n }\n </div>\n {open && <div className={`${prefix}-menu__overlay`} onClick={handleClose} />}\n </>\n );\n});\n\nexport default createComponent(Menu);\n","import { useState } from 'react';\n\ntype UseMenu = [\n boolean,\n HTMLElement | null,\n (event?: React.MouseEvent<HTMLButtonElement>) => void,\n];\n\nexport default function useMenu(): UseMenu {\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n\n const open = Boolean(anchorEl);\n\n const handleOpen = (event?: React.MouseEvent<HTMLElement, MouseEvent>) => {\n setAnchorEl(event ? event.currentTarget : null);\n };\n\n const handleClose = () => { setAnchorEl(null); };\n\n const handleToggle = (event?: React.MouseEvent<HTMLElement, MouseEvent>) => {\n if (open) {\n handleClose();\n return;\n }\n\n handleOpen(event);\n };\n\n return [open, anchorEl, handleToggle];\n}\n"],"names":["Debounce","func","milliseconds","debounce","Menu","forwardRef","open","width","children","anchorEl","direction","maxHeight","autoClose","onClose","props","ref","coordinate","setCoordinate","useState","config","setConfig","GAP","ANIMATION_DURATION","arrayChildren","Children","id","useMemo","uuid","classes","joinClass","prefix","useListenerResized","changePosition","useEffect","handleOpen","handleClose","coordinates","offsetWidth","offsetHeight","offsetLeft","offsetTop","prev","top","el","renderChildren","child","index","cloneElement","e","jsxs","Fragment","jsx","Card","CardContent","createComponent","useMenu","setAnchorEl","event"],"mappings":"kVAAA,MAAMA,CAAS,CAEN,MAAMC,EAAyBC,EAAe,IAAK,CACxD,GAAI,CAACA,EAAc,CACjBD,EAAA,EACA,MACF,CAEA,aAAa,KAAK,OAAO,EACzB,KAAK,QAAU,WAAW,IAAM,CAAEA,EAAA,CAAQ,EAAGC,CAAY,CAC3D,CACF,CAEO,MAAMC,EAAW,IAAIH,EC8BtBI,EAAOC,EAAAA,WAAsC,SAAc,CAC/D,KAAAC,EACA,MAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EAAY,OACZ,UAAAC,EACA,UAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EAAcC,EAAK,CACjB,KAAM,CAACC,EAAYC,CAAa,EAAIC,WAAA,EAC9B,CAACC,EAAQC,CAAS,EAAIF,EAAAA,SAAiB,CAAE,MAAO,YAAa,UAAW,QAAS,MAAO,MAAA,CAAQ,EAEhGG,EAAM,GACNC,EAAqB,IAErBC,EAAgBC,EAAAA,SAAS,QAAQhB,CAAQ,EAEzCiB,EAAKC,EAAAA,QAAQ,IAAMC,EAAAA,KAAA,EAAQ,CAAA,CAAE,EAE7BC,EAAUC,EAAAA,UACd,GAAGC,EAAAA,MAAM,QACT,GAAGA,EAAAA,MAAM,UAAUX,GAAQ,SAAS,GACpCL,EAAM,SAAA,EAGRiB,EA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
|
|
|
1
|
-
import{jsxs as B,Fragment as E,jsx as m}from"react/jsx-runtime";import{forwardRef as L,useState as g,Children as P,useMemo as W,useEffect as x,cloneElement as F}from"react";import{p as r}from"./index-CZ41y9Hn.js";import{j as G}from"./joinClass-anSpaauN.js";import{u as H}from"./uuid-dGvr9vBZ.js";import{u as S}from"./useListenerResized-Bnqxrt7k.js";import{C as U}from"./Card-
|
|
2
|
-
//# sourceMappingURL=useMenu-
|
|
1
|
+
import{jsxs as B,Fragment as E,jsx as m}from"react/jsx-runtime";import{forwardRef as L,useState as g,Children as P,useMemo as W,useEffect as x,cloneElement as F}from"react";import{p as r}from"./index-CZ41y9Hn.js";import{j as G}from"./joinClass-anSpaauN.js";import{u as H}from"./uuid-dGvr9vBZ.js";import{u as S}from"./useListenerResized-Bnqxrt7k.js";import{C as U}from"./Card-C2mSdoXV.js";import{C as q}from"./CardContent-CViecz1a.js";import{c as J}from"./createComponent-BmdhWozT.js";class K{delay(t,n=500){if(!n){t();return}clearTimeout(this.timeout),this.timeout=setTimeout(()=>{t()},n)}}const Q=new K,V=L(function({open:t,width:n,children:f,anchorEl:o,direction:c="left",maxHeight:s,autoClose:N,onClose:M,...u},k){const[y,v]=g(),[d,a]=g({state:"invisible",animation:"close",width:"auto"}),w=16,T=150,A=P.toArray(f),b=W(()=>H(),[]),I=G(`${r}-menu`,`${r}-menu--${d?.animation}`,u.className);S(()=>_(),[o]),x(()=>{_()},[o]),x(()=>{t?j():h()},[t]);const _=()=>{o&&setTimeout(()=>{let e={};const{offsetWidth:i,offsetHeight:p,offsetLeft:$,offsetTop:D}=o;a(z=>({...z,width:i}));const C=D+p+w/2,R=document.getElementById(b);c==="center"&&(e={top:C,right:i}),c==="left"&&(e={top:C,left:$}),c==="right"&&(e={top:C,left:$-(R.offsetWidth-i)}),v(e)},0)},j=()=>{a(e=>({...e,state:"visible"})),setTimeout(()=>{a(e=>({...e,animation:"open"}))},10)},h=()=>{a(e=>({...e,animation:"close"})),setTimeout(()=>{a(e=>({...e,state:"invisible"})),M()},T)},O=()=>A.map((e,i)=>F(e,{tabIndex:i+1,key:`button-${i}`,onClick:p=>{Q.delay(()=>{N&&h(),e.props.onClick&&e.props.onClick(p)},0)}}));return B(E,{children:[m("div",{id:b,ref:k,...u,style:{width:n||d.width,top:y?.top,left:y?.left,display:d?.state==="visible"?"block":"none",transition:`all ${T}ms ease-in`,zIndex:50,...u.style},className:I,children:t&&m(U,{className:`${r}-menu__card`,children:m(q,{className:`${r}-menu__card__content`,sx:{py:1},style:{display:"flex",flexDirection:"column",maxHeight:s},children:O()})})}),t&&m("div",{className:`${r}-menu__overlay`,onClick:h})]})}),ae=J(V);function re(){const[l,t]=g(null),n=!!l,f=s=>{t(s?s.currentTarget:null)},o=()=>{t(null)};return[n,l,s=>{if(n){o();return}f(s)}]}export{ae as M,re as u};
|
|
2
|
+
//# sourceMappingURL=useMenu-we523Eob.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMenu-
|
|
1
|
+
{"version":3,"file":"useMenu-we523Eob.js","sources":["../../../../toolkit/src/debounce/debounce.ts","../../src/navigation/Menu/Menu.tsx","../../src/navigation/Menu/useMenu.ts"],"sourcesContent":["class Debounce {\n private timeout: NodeJS.Timeout | undefined;\n public delay(func: (a?: any) => void, milliseconds = 500) {\n if (!milliseconds) {\n func();\n return;\n }\n\n clearTimeout(this.timeout);\n this.timeout = setTimeout(() => { func(); }, milliseconds);\n }\n}\n\nexport const debounce = new Debounce();\n","import {\n useMemo,\n useState,\n useEffect,\n Children,\n forwardRef,\n type ReactElement,\n type CSSProperties,\n type HTMLAttributes,\n cloneElement\n} from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { joinClass } from '@iziui/core/utils';\n\nimport { uuid } from '@iziui/toolkit/uuid';\nimport { debounce } from '@iziui/toolkit/debounce';\n\nimport useListenerResized from '@/hooks/useListenerResized';\nimport { Card, CardContent } from '@/display/Card';\n\nimport createComponent from '../../core/createComponent';\n\nimport '@iziui/styles/components/Menu.scss';\n\ntype Direction = 'left' | 'right' | 'center';\ntype AnimationClass = 'open' | 'close';\ntype State = 'visible' | 'invisible';\ntype Coordinates = { top?: number; right?: number; bottom?: number; left?: number; };\ntype Config = { animation: AnimationClass, state: State; width: CSSProperties['width'] };\n\nexport interface MenuProps extends HTMLAttributes<HTMLDivElement> {\n open: boolean;\n autoClose?: boolean;\n maxHeight?: CSSProperties['maxHeight'];\n direction?: Direction;\n anchorEl: HTMLElement | null;\n width?: CSSProperties['width'];\n children: React.JSX.Element | React.JSX.Element[];\n onClose: (e?: React.MouseEvent<HTMLButtonElement>) => void;\n}\n\nconst Menu = forwardRef<HTMLDivElement, MenuProps>(function Menu({\n open,\n width,\n children,\n anchorEl,\n direction = 'left',\n maxHeight,\n autoClose,\n onClose,\n ...props\n}: MenuProps, ref) {\n const [coordinate, setCoordinate] = useState<Coordinates>();\n const [config, setConfig] = useState<Config>({ state: 'invisible', animation: 'close', width: 'auto' });\n\n const GAP = 16;\n const ANIMATION_DURATION = 150;\n\n const arrayChildren = Children.toArray(children) as ReactElement<any>[];\n\n const id = useMemo(() => uuid(), []);\n\n const classes = joinClass(\n `${prefix}-menu`,\n `${prefix}-menu--${config?.animation}`,\n props.className\n );\n\n useListenerResized(() => changePosition(), [anchorEl]);\n\n useEffect(() => { changePosition(); }, [anchorEl]);\n\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n useEffect(() => { open ? handleOpen() : handleClose(); }, [open]);\n\n const changePosition = () => {\n if (!anchorEl) { return; }\n\n setTimeout(() => {\n let coordinates: Coordinates = {};\n\n const { offsetWidth, offsetHeight, offsetLeft, offsetTop } = anchorEl;\n\n setConfig(prev => ({ ...prev, width: offsetWidth }));\n\n const top = offsetTop + offsetHeight + (GAP / 2);\n\n const el = document.getElementById(id) as HTMLElement;\n\n if (direction === 'center') { coordinates = { top, right: offsetWidth }; }\n\n if (direction === 'left') { coordinates = { top, left: offsetLeft }; }\n\n if (direction === 'right') { coordinates = { top, left: offsetLeft - (el.offsetWidth - offsetWidth) }; }\n\n setCoordinate(coordinates);\n }, 0);\n };\n\n const handleOpen = () => {\n setConfig(prev => ({ ...prev, state: 'visible' }));\n\n setTimeout(() => { setConfig(prev => ({ ...prev, animation: 'open' })); }, 10);\n };\n\n const handleClose = () => {\n setConfig(prev => ({ ...prev, animation: 'close' }));\n\n setTimeout(() => {\n setConfig(prev => ({ ...prev, state: 'invisible' }));\n onClose();\n }, ANIMATION_DURATION);\n };\n\n const renderChildren = () => {\n return arrayChildren.map((child, index) => {\n return cloneElement(child, {\n 'tabIndex': index + 1,\n key: `button-${index}`,\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => {\n debounce.delay(() => {\n\n if (autoClose) { handleClose(); }\n\n if (child.props.onClick) { child.props.onClick(e); }\n }, 0);\n },\n });\n });\n };\n\n return (\n <>\n <div\n id={id}\n ref={ref}\n {...props}\n style={{\n width: width || config.width,\n top: coordinate?.top,\n left: coordinate?.left,\n display: config?.state === 'visible' ? 'block' : 'none',\n transition: `all ${ANIMATION_DURATION}ms ease-in`,\n zIndex: 50,\n ...props.style\n }}\n className={classes}\n >\n {\n open && (\n <Card className={`${prefix}-menu__card`}>\n <CardContent\n className={`${prefix}-menu__card__content`}\n sx={{ py: 1 }}\n style={{ display: 'flex', flexDirection: 'column', maxHeight }}\n >\n {renderChildren()}\n </CardContent>\n </Card>\n )\n }\n </div>\n {open && <div className={`${prefix}-menu__overlay`} onClick={handleClose} />}\n </>\n );\n});\n\nexport default createComponent(Menu);\n","import { useState } from 'react';\n\ntype UseMenu = [\n boolean,\n HTMLElement | null,\n (event?: React.MouseEvent<HTMLButtonElement>) => void,\n];\n\nexport default function useMenu(): UseMenu {\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\n\n const open = Boolean(anchorEl);\n\n const handleOpen = (event?: React.MouseEvent<HTMLElement, MouseEvent>) => {\n setAnchorEl(event ? event.currentTarget : null);\n };\n\n const handleClose = () => { setAnchorEl(null); };\n\n const handleToggle = (event?: React.MouseEvent<HTMLElement, MouseEvent>) => {\n if (open) {\n handleClose();\n return;\n }\n\n handleOpen(event);\n };\n\n return [open, anchorEl, handleToggle];\n}\n"],"names":["Debounce","func","milliseconds","debounce","Menu","forwardRef","open","width","children","anchorEl","direction","maxHeight","autoClose","onClose","props","ref","coordinate","setCoordinate","useState","config","setConfig","GAP","ANIMATION_DURATION","arrayChildren","Children","id","useMemo","uuid","classes","joinClass","prefix","useListenerResized","changePosition","useEffect","handleOpen","handleClose","coordinates","offsetWidth","offsetHeight","offsetLeft","offsetTop","prev","top","el","renderChildren","child","index","cloneElement","e","jsxs","Fragment","jsx","Card","CardContent","Menu$1","createComponent","useMenu","setAnchorEl","event"],"mappings":"oeAAA,MAAMA,CAAS,CAEN,MAAMC,EAAyBC,EAAe,IAAK,CACxD,GAAI,CAACA,EAAc,CACjBD,EAAA,EACA,MACF,CAEA,aAAa,KAAK,OAAO,EACzB,KAAK,QAAU,WAAW,IAAM,CAAEA,EAAA,CAAQ,EAAGC,CAAY,CAC3D,CACF,CAEO,MAAMC,EAAW,IAAIH,EC8BtBI,EAAOC,EAAsC,SAAc,CAC/D,KAAAC,EACA,MAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EAAY,OACZ,UAAAC,EACA,UAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EAAcC,EAAK,CACjB,KAAM,CAACC,EAAYC,CAAa,EAAIC,EAAA,EAC9B,CAACC,EAAQC,CAAS,EAAIF,EAAiB,CAAE,MAAO,YAAa,UAAW,QAAS,MAAO,MAAA,CAAQ,EAEhGG,EAAM,GACNC,EAAqB,IAErBC,EAAgBC,EAAS,QAAQhB,CAAQ,EAEzCiB,EAAKC,EAAQ,IAAMC,EAAA,EAAQ,CAAA,CAAE,EAE7BC,EAAUC,EACd,GAAGC,CAAM,QACT,GAAGA,CAAM,UAAUX,GAAQ,SAAS,GACpCL,EAAM,SAAA,EAGRiB,EAAmB,IAAMC,IAAk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EAEbU,EAAM,MAAM,SAAWA,EAAM,MAAM,QAAQG,CAAC,CAClD,EAAG,CAAC,CACN,CAAA,CACD,CACF,EAGH,OACEC,EAAAC,EAAA,CACE,SAAA,CAAAC,EAAC,MAAA,CACC,GAAA1B,EACA,IAAAV,EACC,GAAGD,EACJ,MAAO,CACL,MAAOP,GAASY,EAAO,MACvB,IAAKH,GAAY,IACjB,KAAMA,GAAY,KAClB,QAASG,GAAQ,QAAU,UAAY,QAAU,OACjD,WAAY,OAAOG,CAAkB,aACrC,OAAQ,GACR,GAAGR,EAAM,KAAA,EAEX,UAAWc,EAGT,YACEuB,EAACC,EAAA,CAAK,UAAW,GAAGtB,CAAM,cACxB,SAAAqB,EAACE,EAAA,CACC,UAAW,GAAGvB,CAAM,uBACpB,GAAI,CAAE,GAAI,CAAA,EACV,MAAO,CAAE,QAAS,OAAQ,cAAe,SAAU,UAAAnB,CAAA,EAElD,SAAAiC,EAAA,CAAe,CAAA,CAClB,CACF,CAAA,CAAA,EAILtC,KAAS,MAAA,CAAI,UAAW,GAAGwB,CAAM,iBAAkB,QAASK,CAAA,CAAa,CAAA,EAC5E,CAEJ,CAAC,EAEDmB,GAAeC,EAAgBnD,CAAI,ECjKnC,SAAwBoD,IAAmB,CACzC,KAAM,CAAC/C,EAAUgD,CAAW,EAAIvC,EAA6B,IAAI,EAE3DZ,EAAO,EAAQG,EAEfyB,EAAcwB,GAAsD,CACxED,EAAYC,EAAQA,EAAM,cAAgB,IAAI,CAChD,EAEMvB,EAAc,IAAM,CAAEsB,EAAY,IAAI,CAAG,EAW/C,MAAO,CAACnD,EAAMG,EATQiD,GAAsD,CAC1E,GAAIpD,EAAM,CACR6B,EAAA,EACA,MACF,CAEAD,EAAWwB,CAAK,CAClB,CAEoC,CACtC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as C,jsx as f}from"react/jsx-runtime";import{Children as j,useState as k,useRef as x,useMemo as B,useEffect as b,cloneElement as y}from"react";import{p as c}from"./index-CZ41y9Hn.js";import{j as h}from"./joinClass-anSpaauN.js";import{u as R}from"./uuid-dGvr9vBZ.js";import{c as S}from"./createComponent-
|
|
2
|
-
//# sourceMappingURL=useTabs-
|
|
1
|
+
import{jsxs as C,jsx as f}from"react/jsx-runtime";import{Children as j,useState as k,useRef as x,useMemo as B,useEffect as b,cloneElement as y}from"react";import{p as c}from"./index-CZ41y9Hn.js";import{j as h}from"./joinClass-anSpaauN.js";import{u as R}from"./uuid-dGvr9vBZ.js";import{c as S}from"./createComponent-BmdhWozT.js";import{u as L}from"./useListenerResized-Bnqxrt7k.js";import{S as g}from"./Slide-BxEwoZ70.js";function A(t,n){if(n>t)throw new Error(`Current tab index (${n}) is greater than the number of tabs (${t})`)}function M({children:t,color:n="primary",current:s=0,onChange:i,...o}){const l=j.toArray(t),[a,$]=k(s),d=x([]),T=h(`${c}-tabs`,`${c}-tabs--${n}`,o.className),v=h(`${c}-tabs__marker`,`${c}-tabs__marker--${n}`),m=B(()=>`marker-${R()}`,[]);L(()=>p(),[a]),b(()=>{A(l.length-1,a)},[]),b(()=>{const e=l.findIndex(u=>!u.props.disabled),r=l[s].props.disabled;$(r?e:s)},[s]),b(()=>{p(),N(a)},[a]);const I=e=>{i&&i(e),$(e)},N=e=>{d.current&&d.current[e].scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},w=(e,r)=>{!d.current||!r||(d.current[e]=r)},p=()=>{const e=document.querySelector(`#tab-${m}-${a}`),r=document.getElementById(m),u=e.offsetWidth,_=e.offsetLeft;r.style.width=`${u}px`,r.style.left=`${_}px`};return C("div",{...o,className:T,children:[l.map((e,r)=>{const u=`tab-${m}-${r}`,_=a===r;return f("div",{ref:E=>w(r,E),style:{width:"100%"},children:y(e,{id:u,tabIndex:r+1,"aria-checked":_,onClick:()=>I(r)})},u)}),f("div",{id:m,className:v})]})}const K=S(M);function O({icon:t,label:n,disabled:s,color:i="primary",...o}){const{"aria-checked":l}=o,a=h(`${c}-tabs__button`,s&&`${c}-tabs__button--disabled`,l&&`${c}-tabs__button--active-${i}`,o.className);return C("button",{type:"button",disabled:s,className:a,...o,children:[t&&y(t,{className:h(`${c}-tabs__button__icon`)}),n]})}function P({children:t,value:n,current:s,...i}){return n===s&&f(g,{enter:!0,direction:"left",children:f("div",{...i,children:t})})}function Q(t){const[n,s]=k(t);return b(()=>{s(t)},[t]),[o=>{s(o)},n]}export{O as T,P as a,K as b,Q as u};
|
|
2
|
+
//# sourceMappingURL=useTabs-DG53jo4T.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTabs-
|
|
1
|
+
{"version":3,"file":"useTabs-DG53jo4T.js","sources":["../../src/navigation/Tabs/Tabs.tsx","../../src/navigation/Tabs/TabButton.tsx","../../src/navigation/Tabs/TabContent.tsx","../../src/navigation/Tabs/useTabs.ts"],"sourcesContent":["import { Children, cloneElement, ReactElement, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { joinClass } from '@iziui/core/utils';\nimport { Colors } from '@iziui/core/theme';\n\nimport { uuid } from '@iziui/toolkit/uuid';\n\nimport createComponent from '@/core/createComponent';\nimport useListenerResized from '@/hooks/useListenerResized';\n\nimport '@iziui/styles/components/Tabs.scss';\n\nfunction validateCurrent(length: number, current: number) {\n if (current > length) {\n throw new Error(`Current tab index (${current}) is greater than the number of tabs (${length})`);\n }\n}\n\nexport interface TabsProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange'> {\n current?: number;\n color?: Colors;\n children: React.ReactNode;\n onChange?: (index: number) => void;\n};\n\nfunction Tabs({\n children,\n color = 'primary',\n current = 0,\n onChange,\n ...props\n}: TabsProps) {\n const arrayChildren = Children.toArray(children) as ReactElement<TabsProps>[];\n\n const [_current, setCurrent] = useState(current);\n const scrollRef = useRef<HTMLDivElement[] | null>([]);\n\n const cls = joinClass(\n `${prefix}-tabs`,\n `${prefix}-tabs--${color}`,\n props.className\n );\n\n const classNameMarker = joinClass(\n `${prefix}-tabs__marker`,\n `${prefix}-tabs__marker--${color}`,\n );\n\n const id = useMemo(() => `marker-${uuid()}`, []);\n\n useListenerResized(() => setBorderLine(), [_current]);\n\n useEffect(() => { validateCurrent(arrayChildren.length - 1, _current); }, []);\n\n useEffect(() => {\n const firstEnableButton = arrayChildren.findIndex(children => !children.props.disabled);\n const currentIsDisabled = arrayChildren[current].props.disabled;\n\n setCurrent(currentIsDisabled ? firstEnableButton : current);\n }, [current]);\n\n useEffect(() => {\n setBorderLine();\n goToTab(_current);\n }, [_current]);\n\n const handleClick = (index: number) => {\n if (onChange) { onChange(index); };\n setCurrent(index);\n };\n\n const goToTab = (index: number) => {\n if (!scrollRef.current) { return; }\n scrollRef.current[index].scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center', });\n };\n\n const setRef = (index: number, ref: HTMLDivElement | null) => {\n if (!scrollRef.current || !ref) { return; }\n\n scrollRef.current[index] = ref;\n };\n\n const setBorderLine = () => {\n const element = document.querySelector(`#tab-${id}-${_current}`) as HTMLElement;\n const el = document.getElementById(id) as HTMLElement;\n\n const width = element['offsetWidth'];\n const left = element['offsetLeft'];\n\n el.style.width = `${width}px`;\n el.style.left = `${left}px`;\n };\n\n const renderChildren = () => {\n return arrayChildren.map((child, index) => {\n const _id = `tab-${id}-${index}`;\n const isActive = _current === index;\n\n return (\n <div key={_id} ref={ref => setRef(index, ref)} style={{ width: '100%' }}>\n {\n cloneElement(child, {\n id: _id,\n tabIndex: index + 1,\n 'aria-checked': isActive,\n onClick: () => handleClick(index),\n })\n }\n </div>\n );\n });\n };\n\n return (\n <div {...props} className={cls}>\n {renderChildren()}\n <div id={id} className={classNameMarker} />\n </div>\n );\n}\n\nexport default createComponent(Tabs);\n","import { cloneElement, HTMLAttributes } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { Colors } from '@iziui/core/theme';\nimport { joinClass } from '@iziui/core/utils';\n\nimport type { IconProps } from '@/display/Icon';\n\nexport interface TabButtonProps extends HTMLAttributes<HTMLButtonElement> {\n label: string;\n disabled?: boolean;\n color?: Colors;\n icon?: React.JSX.Element;\n}\n\nexport default function TabButton({ icon, label, disabled, color = 'primary', ...props }: TabButtonProps) {\n const { 'aria-checked': checked } = props;\n\n const className = joinClass(\n `${prefix}-tabs__button`,\n disabled && `${prefix}-tabs__button--disabled`,\n checked && `${prefix}-tabs__button--active-${color}`,\n props.className\n );\n\n const renderIcon = () => {\n return icon && cloneElement<IconProps>(icon, {\n className: joinClass(\n `${prefix}-tabs__button__icon`,\n ),\n });\n };\n\n return (\n <button\n type=\"button\"\n disabled={disabled}\n className={className}\n {...props}\n >\n {renderIcon()}\n {label}\n </button>\n );\n}","import type { HTMLAttributes } from 'react';\n\nimport Slide from '@/animations/Slide';\n\nexport interface TabContentProps extends HTMLAttributes<HTMLDivElement> {\n children: React.JSX.Element;\n value: number;\n current: number;\n}\n\nexport default function TabContent({ children, value, current, ...props }: TabContentProps) {\n return (\n value === current && (\n <Slide enter direction=\"left\">\n <div {...props}>\n {children}\n </div>\n </Slide>\n )\n );\n}","import { useEffect, useState } from 'react';\n\ntype UseTabs = [(index: number) => void, number]\n\nexport default function useTabs(current: number): UseTabs {\n const [_current, setCurrent] = useState(current);\n\n useEffect(() => { setCurrent(current); }, [current]);\n\n const setTab = (index: number) => { setCurrent(index); };\n\n return [\n setTab,\n _current,\n ];\n}"],"names":["validateCurrent","length","current","Tabs","children","color","onChange","props","arrayChildren","Children","_current","setCurrent","useState","scrollRef","useRef","cls","joinClass","prefix","classNameMarker","id","useMemo","uuid","useListenerResized","setBorderLine","useEffect","firstEnableButton","currentIsDisabled","goToTab","handleClick","index","setRef","ref","element","el","width","left","jsxs","child","_id","isActive","jsx","Tabs_default","createComponent","TabButton","icon","label","disabled","checked","className","cloneElement","TabContent","value","Slide","useTabs"],"mappings":"qaAcA,SAASA,EAAgBC,EAAgBC,EAAiB,CACxD,GAAIA,EAAUD,EACZ,MAAM,IAAI,MAAM,sBAAsBC,CAAO,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CAAA,CAGP,CCnCA,SAAwBK,EAAW,CAAE,SAAA9C,EAAU,MAAA+C,EAAO,QAAAjD,EAAS,GAAGK,GAA0B,CAC1F,OACE4C,IAAUjD,GACRsC,EAACY,EAAA,CAAM,MAAK,GAAC,UAAU,OACrB,SAAAZ,EAAC,MAAA,CAAK,GAAGjC,EACN,SAAAH,EACH,EACF,CAGN,CChBA,SAAwBiD,EAAQnD,EAA0B,CACxD,KAAM,CAACQ,EAAUC,CAAU,EAAIC,EAASV,CAAO,EAE/C,OAAAsB,EAAU,IAAM,CAAEb,EAAWT,CAAO,CAAG,EAAG,CAACA,CAAO,CAAC,EAI5C,CAFS2B,GAAkB,CAAElB,EAAWkB,CAAK,CAAG,EAIrDnB,CAAA,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const f=require("react/jsx-runtime"),c=require("react"),a=require("./index-DYxwT4uW.cjs"),h=require("./joinClass-Jk3EszKD.cjs"),E=require("./uuid-omnJ9TjZ.cjs"),v=require("./createComponent-
|
|
2
|
-
//# sourceMappingURL=useTabs-
|
|
1
|
+
"use strict";const f=require("react/jsx-runtime"),c=require("react"),a=require("./index-DYxwT4uW.cjs"),h=require("./joinClass-Jk3EszKD.cjs"),E=require("./uuid-omnJ9TjZ.cjs"),v=require("./createComponent-Bls5N6x8.cjs"),N=require("./useListenerResized-AwpsZLcP.cjs"),w=require("./Slide-D4aLHjYS.cjs");function I(e,r){if(r>e)throw new Error(`Current tab index (${r}) is greater than the number of tabs (${e})`)}function R({children:e,color:r="primary",current:n=0,onChange:u,...o}){const l=c.Children.toArray(e),[i,b]=c.useState(n),m=c.useRef([]),x=h.joinClass(`${a.prefix}-tabs`,`${a.prefix}-tabs--${r}`,o.className),p=h.joinClass(`${a.prefix}-tabs__marker`,`${a.prefix}-tabs__marker--${r}`),$=c.useMemo(()=>`marker-${E.uuid()}`,[]);N.useListenerResized(()=>C(),[i]),c.useEffect(()=>{I(l.length-1,i)},[]),c.useEffect(()=>{const t=l.findIndex(d=>!d.props.disabled),s=l[n].props.disabled;b(s?t:n)},[n]),c.useEffect(()=>{C(),j(i)},[i]);const T=t=>{u&&u(t),b(t)},j=t=>{m.current&&m.current[t].scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},k=(t,s)=>{!m.current||!s||(m.current[t]=s)},C=()=>{const t=document.querySelector(`#tab-${$}-${i}`),s=document.getElementById($),d=t.offsetWidth,_=t.offsetLeft;s.style.width=`${d}px`,s.style.left=`${_}px`},y=()=>l.map((t,s)=>{const d=`tab-${$}-${s}`,_=i===s;return f.jsx("div",{ref:q=>k(s,q),style:{width:"100%"},children:c.cloneElement(t,{id:d,tabIndex:s+1,"aria-checked":_,onClick:()=>T(s)})},d)});return f.jsxs("div",{...o,className:x,children:[y(),f.jsx("div",{id:$,className:p})]})}const B=v.createComponent(R);function S({icon:e,label:r,disabled:n,color:u="primary",...o}){const{"aria-checked":l}=o,i=h.joinClass(`${a.prefix}-tabs__button`,n&&`${a.prefix}-tabs__button--disabled`,l&&`${a.prefix}-tabs__button--active-${u}`,o.className),b=()=>e&&c.cloneElement(e,{className:h.joinClass(`${a.prefix}-tabs__button__icon`)});return f.jsxs("button",{type:"button",disabled:n,className:i,...o,children:[b(),r]})}function L({children:e,value:r,current:n,...u}){return r===n&&f.jsx(w.Slide,{enter:!0,direction:"left",children:f.jsx("div",{...u,children:e})})}function g(e){const[r,n]=c.useState(e);return c.useEffect(()=>{n(e)},[e]),[o=>{n(o)},r]}exports.TabButton=S;exports.TabContent=L;exports.Tabs_default=B;exports.useTabs=g;
|
|
2
|
+
//# sourceMappingURL=useTabs-Dcksp_re.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTabs-
|
|
1
|
+
{"version":3,"file":"useTabs-Dcksp_re.cjs","sources":["../../src/navigation/Tabs/Tabs.tsx","../../src/navigation/Tabs/TabButton.tsx","../../src/navigation/Tabs/TabContent.tsx","../../src/navigation/Tabs/useTabs.ts"],"sourcesContent":["import { Children, cloneElement, ReactElement, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { joinClass } from '@iziui/core/utils';\nimport { Colors } from '@iziui/core/theme';\n\nimport { uuid } from '@iziui/toolkit/uuid';\n\nimport createComponent from '@/core/createComponent';\nimport useListenerResized from '@/hooks/useListenerResized';\n\nimport '@iziui/styles/components/Tabs.scss';\n\nfunction validateCurrent(length: number, current: number) {\n if (current > length) {\n throw new Error(`Current tab index (${current}) is greater than the number of tabs (${length})`);\n }\n}\n\nexport interface TabsProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onChange'> {\n current?: number;\n color?: Colors;\n children: React.ReactNode;\n onChange?: (index: number) => void;\n};\n\nfunction Tabs({\n children,\n color = 'primary',\n current = 0,\n onChange,\n ...props\n}: TabsProps) {\n const arrayChildren = Children.toArray(children) as ReactElement<TabsProps>[];\n\n const [_current, setCurrent] = useState(current);\n const scrollRef = useRef<HTMLDivElement[] | null>([]);\n\n const cls = joinClass(\n `${prefix}-tabs`,\n `${prefix}-tabs--${color}`,\n props.className\n );\n\n const classNameMarker = joinClass(\n `${prefix}-tabs__marker`,\n `${prefix}-tabs__marker--${color}`,\n );\n\n const id = useMemo(() => `marker-${uuid()}`, []);\n\n useListenerResized(() => setBorderLine(), [_current]);\n\n useEffect(() => { validateCurrent(arrayChildren.length - 1, _current); }, []);\n\n useEffect(() => {\n const firstEnableButton = arrayChildren.findIndex(children => !children.props.disabled);\n const currentIsDisabled = arrayChildren[current].props.disabled;\n\n setCurrent(currentIsDisabled ? firstEnableButton : current);\n }, [current]);\n\n useEffect(() => {\n setBorderLine();\n goToTab(_current);\n }, [_current]);\n\n const handleClick = (index: number) => {\n if (onChange) { onChange(index); };\n setCurrent(index);\n };\n\n const goToTab = (index: number) => {\n if (!scrollRef.current) { return; }\n scrollRef.current[index].scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center', });\n };\n\n const setRef = (index: number, ref: HTMLDivElement | null) => {\n if (!scrollRef.current || !ref) { return; }\n\n scrollRef.current[index] = ref;\n };\n\n const setBorderLine = () => {\n const element = document.querySelector(`#tab-${id}-${_current}`) as HTMLElement;\n const el = document.getElementById(id) as HTMLElement;\n\n const width = element['offsetWidth'];\n const left = element['offsetLeft'];\n\n el.style.width = `${width}px`;\n el.style.left = `${left}px`;\n };\n\n const renderChildren = () => {\n return arrayChildren.map((child, index) => {\n const _id = `tab-${id}-${index}`;\n const isActive = _current === index;\n\n return (\n <div key={_id} ref={ref => setRef(index, ref)} style={{ width: '100%' }}>\n {\n cloneElement(child, {\n id: _id,\n tabIndex: index + 1,\n 'aria-checked': isActive,\n onClick: () => handleClick(index),\n })\n }\n </div>\n );\n });\n };\n\n return (\n <div {...props} className={cls}>\n {renderChildren()}\n <div id={id} className={classNameMarker} />\n </div>\n );\n}\n\nexport default createComponent(Tabs);\n","import { cloneElement, HTMLAttributes } from 'react';\n\nimport { prefix } from '@iziui/tokens/web/js';\n\nimport { Colors } from '@iziui/core/theme';\nimport { joinClass } from '@iziui/core/utils';\n\nimport type { IconProps } from '@/display/Icon';\n\nexport interface TabButtonProps extends HTMLAttributes<HTMLButtonElement> {\n label: string;\n disabled?: boolean;\n color?: Colors;\n icon?: React.JSX.Element;\n}\n\nexport default function TabButton({ icon, label, disabled, color = 'primary', ...props }: TabButtonProps) {\n const { 'aria-checked': checked } = props;\n\n const className = joinClass(\n `${prefix}-tabs__button`,\n disabled && `${prefix}-tabs__button--disabled`,\n checked && `${prefix}-tabs__button--active-${color}`,\n props.className\n );\n\n const renderIcon = () => {\n return icon && cloneElement<IconProps>(icon, {\n className: joinClass(\n `${prefix}-tabs__button__icon`,\n ),\n });\n };\n\n return (\n <button\n type=\"button\"\n disabled={disabled}\n className={className}\n {...props}\n >\n {renderIcon()}\n {label}\n </button>\n );\n}","import type { HTMLAttributes } from 'react';\n\nimport Slide from '@/animations/Slide';\n\nexport interface TabContentProps extends HTMLAttributes<HTMLDivElement> {\n children: React.JSX.Element;\n value: number;\n current: number;\n}\n\nexport default function TabContent({ children, value, current, ...props }: TabContentProps) {\n return (\n value === current && (\n <Slide enter direction=\"left\">\n <div {...props}>\n {children}\n </div>\n </Slide>\n )\n );\n}","import { useEffect, useState } from 'react';\n\ntype UseTabs = [(index: number) => void, number]\n\nexport default function useTabs(current: number): UseTabs {\n const [_current, setCurrent] = useState(current);\n\n useEffect(() => { setCurrent(current); }, [current]);\n\n const setTab = (index: number) => { setCurrent(index); };\n\n return [\n setTab,\n _current,\n ];\n}"],"names":["validateCurrent","length","current","Tabs","children","color","onChange","props","arrayChildren","Children","_current","setCurrent","useState","scrollRef","useRef","cls","joinClass","prefix","classNameMarker","id","useMemo","uuid","useListenerResized","setBorderLine","useEffect","firstEnableButton","currentIsDisabled","goToTab","handleClick","index","setRef","ref","element","el","width","left","renderChildren","child","_id","isActive","jsx","jsxs","Tabs_default","createComponent","TabButton","icon","label","disabled","checked","className","renderIcon","cloneElement","TabContent","value","Slide","useTabs"],"mappings":"2SAcA,SAASA,EAAgBC,EAAgBC,EAAiB,CACxD,GAAIA,EAAUD,EACZ,MAAM,IAAI,MAAM,sBAAsBC,CAAO,yCAAyCD,CAAM,GAAG,CAEnG,CASA,SAASE,EAAK,CACZ,SAAAC,EACA,MAAAC,EAAQ,UACR,QAAAH,EAAU,EACV,SAAAI,EACA,GAAGC,CACL,EAAc,CACZ,MAAMC,EAAgBC,EAAAA,SAAS,QAAQL,CAAQ,EAEzC,CAACM,EAAUC,CAAU,EAAIC,EAAAA,SAASV,CAAO,EACzCW,EAAYC,EAAAA,OAAgC,EAAE,EAE9CC,EAAMC,EAAAA,UACV,GAAGC,EAAAA,MAAM,QACT,GAAGA,EAAAA,MAAM,UAAUZ,CAAK,GACxBE,EAAM,SAAA,EAGFW,EAAkBF,EAAAA,UACtB,GAAGC,EAAAA,MAAM,gBACT,GAAGA,EAAAA,MAAM,kBAAkBZ,CAAK,EAAA,EAG5Bc,EAAKC,EAAAA,QAAQ,IAA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EAAQrD,EAA0B,CACxD,KAAM,CAACQ,EAAUC,CAAU,EAAIC,EAAAA,SAASV,CAAO,EAE/CsB,OAAAA,EAAAA,UAAU,IAAM,CAAEb,EAAWT,CAAO,CAAG,EAAG,CAACA,CAAO,CAAC,EAI5C,CAFS2B,GAAkB,CAAElB,EAAWkB,CAAK,CAAG,EAIrDnB,CAAA,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../chunks/Alert-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../chunks/Alert-DCB56IAI.cjs");require("react/jsx-runtime");require("../../chunks/index-DYxwT4uW.cjs");require("../../chunks/joinClass-Jk3EszKD.cjs");require("../../chunks/useTheme-DsrjDJKC.cjs");require("react");require("../../chunks/generateSupportColors-CTMoGhDf.cjs");require("../../chunks/Stack-CF3Wyma9.cjs");require("../../chunks/createComponent-Bls5N6x8.cjs");require("../../chunks/Typography-Ch-BLqCH.cjs");require("../../chunks/convertPathToColor-D8eBpd_D.cjs");require("../../chunks/ButtonIcon-Ccq88QaY.cjs");require("../../chunks/Ripple-Dy4i91j1.cjs");require("../../chunks/Icon-BN4Kp4Aq.cjs");exports.default=e.Alert;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as b}from"../../chunks/Alert-
|
|
1
|
+
import{A as b}from"../../chunks/Alert-CD6hOvos.js";import"react/jsx-runtime";import"../../chunks/index-CZ41y9Hn.js";import"../../chunks/joinClass-anSpaauN.js";import"../../chunks/useTheme-BYuNiCiH.js";import"react";import"../../chunks/generateSupportColors-BN5t8dA-.js";import"../../chunks/Stack-CHR_pZC4.js";import"../../chunks/createComponent-BmdhWozT.js";import"../../chunks/Typography-B_WR62ip.js";import"../../chunks/convertPathToColor-DtOjH4ZP.js";import"../../chunks/ButtonIcon-DMetcfYt.js";import"../../chunks/Ripple-Bq9bxg4k.js";import"../../chunks/Icon-DTU52KQE.js";export{b as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),t=require("../../chunks/index-DYxwT4uW.cjs"),f=require("../../chunks/joinClass-Jk3EszKD.cjs"),d=require("../../chunks/Ripple-Dy4i91j1.cjs"),g=require("../../chunks/createComponent-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),t=require("../../chunks/index-DYxwT4uW.cjs"),f=require("../../chunks/joinClass-Jk3EszKD.cjs"),d=require("../../chunks/Ripple-Dy4i91j1.cjs"),g=require("../../chunks/createComponent-Bls5N6x8.cjs"),v=require("../../chunks/Icon-BN4Kp4Aq.cjs"),x=require("../../chunks/Typography-Ch-BLqCH.cjs");require("react");require("../../chunks/useTheme-DsrjDJKC.cjs");require("../../chunks/generateSupportColors-CTMoGhDf.cjs");require("../../chunks/convertPathToColor-D8eBpd_D.cjs");function s(e){return e.normalize("NFD").trim().toLowerCase().replace(/a-zA-Z0-9_.-+/g,"").replace(/_/g,"").replace(/[^\w\s]/gi,"")}function m(e){const a=e.trim().split(" "),i=a.length===1,r=s(a[0]).charAt(0).toLocaleUpperCase(),c=i?s(a[0]).charAt(1).toLocaleUpperCase():s(a.reverse()[0]).charAt(0).toLocaleUpperCase();return r+c}function y({src:e,alt:a,name:i,size:r=40,variant:c="circular",color:u="primary",icon:l,...n}){const h=f.joinClass(`${t.prefix}-avatar`,`${t.prefix}-avatar--${c}`,`${t.prefix}-avatar--${u}`,e&&`${t.prefix}-avatar--image`,i&&`${t.prefix}-avatar--name`,!e&&!i||l&&`${t.prefix}-avatar--icon`,n.onClick&&`${t.prefix}-avatar--clickable`,n.className),p=()=>e?o.jsx("img",{src:e,alt:a,width:r,height:r,sizes:"100vw",loading:"lazy",style:{width:"100%",height:"auto"}}):i?o.jsx(x.Typography,{style:{fontSize:r/2,color:"currentColor"},children:m(i)}):l||o.jsx(v.Icon,{name:"user",size:r/1.6,style:{color:"currentColor"}});return o.jsxs("div",{...n,style:{width:r,height:r,...n.style},className:h,children:[p(),n.children,n.onClick&&o.jsx(d.Ripple,{})]})}const C=g.createComponent(y);exports.default=C;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as h,jsx as n}from"react/jsx-runtime";import{p as r}from"../../chunks/index-CZ41y9Hn.js";import{j as u}from"../../chunks/joinClass-anSpaauN.js";import{R as g}from"../../chunks/Ripple-Bq9bxg4k.js";import{c as v}from"../../chunks/createComponent-
|
|
1
|
+
import{jsxs as h,jsx as n}from"react/jsx-runtime";import{p as r}from"../../chunks/index-CZ41y9Hn.js";import{j as u}from"../../chunks/joinClass-anSpaauN.js";import{R as g}from"../../chunks/Ripple-Bq9bxg4k.js";import{c as v}from"../../chunks/createComponent-BmdhWozT.js";import{I as d}from"../../chunks/Icon-DTU52KQE.js";import{T as C}from"../../chunks/Typography-B_WR62ip.js";import"react";import"../../chunks/useTheme-BYuNiCiH.js";import"../../chunks/generateSupportColors-BN5t8dA-.js";import"../../chunks/convertPathToColor-DtOjH4ZP.js";function s(t){return t.normalize("NFD").trim().toLowerCase().replace(/a-zA-Z0-9_.-+/g,"").replace(/_/g,"").replace(/[^\w\s]/gi,"")}function y(t){const e=t.trim().split(" "),o=e.length===1,a=s(e[0]).charAt(0).toLocaleUpperCase(),l=o?s(e[0]).charAt(1).toLocaleUpperCase():s(e.reverse()[0]).charAt(0).toLocaleUpperCase();return a+l}function $({src:t,alt:e,name:o,size:a=40,variant:l="circular",color:m="primary",icon:c,...i}){const p=u(`${r}-avatar`,`${r}-avatar--${l}`,`${r}-avatar--${m}`,t&&`${r}-avatar--image`,o&&`${r}-avatar--name`,!t&&!o||c&&`${r}-avatar--icon`,i.onClick&&`${r}-avatar--clickable`,i.className),f=()=>t?n("img",{src:t,alt:e,width:a,height:a,sizes:"100vw",loading:"lazy",style:{width:"100%",height:"auto"}}):o?n(C,{style:{fontSize:a/2,color:"currentColor"},children:y(o)}):c||n(d,{name:"user",size:a/1.6,style:{color:"currentColor"}});return h("div",{...i,style:{width:a,height:a,...i.style},className:p,children:[f(),i.children,i.onClick&&n(g,{})]})}const R=v($);export{R as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../chunks/Box-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../../chunks/Box-CNg55MFq.cjs");require("react/jsx-runtime");require("react");require("../../chunks/createComponent-Bls5N6x8.cjs");require("../../chunks/index-DYxwT4uW.cjs");require("../../chunks/useTheme-DsrjDJKC.cjs");require("../../chunks/generateSupportColors-CTMoGhDf.cjs");exports.default=e.Box;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as f}from"../../chunks/Box-
|
|
1
|
+
import{B as f}from"../../chunks/Box-DqBZgXYR.js";import"react/jsx-runtime";import"react";import"../../chunks/createComponent-BmdhWozT.js";import"../../chunks/index-CZ41y9Hn.js";import"../../chunks/useTheme-BYuNiCiH.js";import"../../chunks/generateSupportColors-BN5t8dA-.js";export{f as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),m=require("react"),e=require("../../chunks/index-DYxwT4uW.cjs"),i=require("../../chunks/joinClass-Jk3EszKD.cjs"),d=require("../../chunks/Ripple-Dy4i91j1.cjs"),_=require("../../chunks/createComponent-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("react/jsx-runtime"),m=require("react"),e=require("../../chunks/index-DYxwT4uW.cjs"),i=require("../../chunks/joinClass-Jk3EszKD.cjs"),d=require("../../chunks/Ripple-Dy4i91j1.cjs"),_=require("../../chunks/createComponent-Bls5N6x8.cjs");require("../../chunks/useTheme-DsrjDJKC.cjs");require("../../chunks/generateSupportColors-CTMoGhDf.cjs");function j({size:o="medium",color:u="primary",variant:p="contained",startIcon:c,endIcon:l,loading:r,children:$,...s}){const f=i.joinClass(`${e.prefix}-button`,`${e.prefix}-button--${o}`,`${e.prefix}-button--${u}`,`${e.prefix}-button--${u}--${p}`,s.className),a=(t,b)=>m.cloneElement(t,{className:i.joinClass(t.props.className,`${e.prefix}-button__icon`,`${e.prefix}-button__icon--${b}`)}),x=t=>m.cloneElement(t,{className:i.joinClass(t.props.className,`${e.prefix}-button__loading`,`${e.prefix}-button__loading--${o}`),size:"1.1rem"});return n.jsxs("button",{...s,className:f,onClick:t=>!r&&s.onClick?.(t),children:[r?x(r):n.jsxs(n.Fragment,{children:[c&&a(c,"left"),$,l&&a(l,"right")]}),n.jsx(d.Ripple,{})]})}const q=_.createComponent(j);exports.default=q;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as u,Fragment as d,jsx as _}from"react/jsx-runtime";import{cloneElement as l}from"react";import{p as t}from"../../chunks/index-CZ41y9Hn.js";import{j as e}from"../../chunks/joinClass-anSpaauN.js";import{R as N}from"../../chunks/Ripple-Bq9bxg4k.js";import{c as j}from"../../chunks/createComponent-
|
|
1
|
+
import{jsxs as u,Fragment as d,jsx as _}from"react/jsx-runtime";import{cloneElement as l}from"react";import{p as t}from"../../chunks/index-CZ41y9Hn.js";import{j as e}from"../../chunks/joinClass-anSpaauN.js";import{R as N}from"../../chunks/Ripple-Bq9bxg4k.js";import{c as j}from"../../chunks/createComponent-BmdhWozT.js";import"../../chunks/useTheme-BYuNiCiH.js";import"../../chunks/generateSupportColors-BN5t8dA-.js";function x({size:m="medium",color:s="primary",variant:p="contained",startIcon:a,endIcon:i,loading:n,children:$,...r}){const f=e(`${t}-button`,`${t}-button--${m}`,`${t}-button--${s}`,`${t}-button--${s}--${p}`,r.className),c=(o,b)=>l(o,{className:e(o.props.className,`${t}-button__icon`,`${t}-button__icon--${b}`)});return u("button",{...r,className:f,onClick:o=>!n&&r.onClick?.(o),children:[n?(o=>l(o,{className:e(o.props.className,`${t}-button__loading`,`${t}-button__loading--${m}`),size:"1.1rem"}))(n):u(d,{children:[a&&c(a,"left"),$,i&&c(i,"right")]}),_(N,{})]})}const F=j(x);export{F as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|